Skip to content

Commit b57ea83

Browse files
committed
Consolidate docstring comments for types
1 parent d4cdc3c commit b57ea83

File tree

1 file changed

+58
-72
lines changed

1 file changed

+58
-72
lines changed

src/types.ts

Lines changed: 58 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,218 +2,204 @@ import { Types } from 'ably';
22
import type { LockAttributes } from './Locks.js';
33

44
/**
5-
* Options to configure the behaviour of a {@link Cursors | `Cursors`} instance.
5+
* Options to configure the behavior of a {@link Cursors | `Cursors`} instance.
66
*/
77
export interface CursorsOptions {
88
/**
9-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
10-
* The interval in milliseconds at which a batch of cursor positions are published. This is multiplied by the number of members in the space minus 1. The default value is 25ms.
11-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
9+
* The interval, in milliseconds, at which a batch of cursor positions are published. This is multiplied by the number of members in a space, minus 1. The default value is 25ms. Decreasing the value will improve performance by further ‘smoothing’ the movement of cursors at the cost of increasing the number of events sent.
1210
*/
1311
outboundBatchInterval: number;
1412
/**
15-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
1613
* The number of pages searched from [history](https://ably.com/docs/storage-history/history) for the last published cursor position. The default is 5.
17-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
1814
*/
1915
paginationLimit: number;
2016
}
2117

2218
/**
23-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
2419
* Represents a cursors position.
25-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
2620
*/
2721
export interface CursorPosition {
2822
/**
29-
* <!-- MOVED FROM Cursors.set -->
3023
* The position of the member’s cursor on the X-axis.
3124
*/
3225
x: number;
3326
/**
34-
* <!-- MOVED FROM Cursors.set -->
3527
* The position of the member’s cursor on the Y-axis.
3628
*/
3729
y: number;
3830
}
3931

4032
/**
41-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
42-
* Represent data that can be associated with a cursor update.
43-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
33+
* Represents data that can be associated with a cursor update. A JSON-serializable object containing additional information about the cursor, such as a color or the ID of an element the cursor is dragging.
4434
*/
4535
export type CursorData = Record<string, unknown>;
4636

4737
/**
48-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
49-
* Represents an update to a cursor.
50-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
38+
* Represents a cursor update event.
39+
*
40+
* The following is an example payload of a cursor event. Cursor events are uniquely identifiable by the {@link CursorUpdate.connectionId | `connectionId`} of a cursor.
41+
*
42+
* ```json
43+
* {
44+
* "hd9743gjDc": {
45+
* "connectionId": "hd9743gjDc",
46+
* "clientId": "clemons#142",
47+
* "position": {
48+
* "x": 864,
49+
* "y": 32
50+
* },
51+
* "data": {
52+
* "color": "red"
53+
* }
54+
* }
55+
* }
56+
* ```
5157
*/
5258
export interface CursorUpdate {
5359
/**
54-
* <!-- MOVED FROM Cursors.set -->
5560
* The [client identifier](https://ably.com/docs/auth/identified-clients) for the member.
5661
*/
5762
clientId: string;
5863
/**
59-
* <!-- MOVED FROM Cursors.set -->
6064
* The unique identifier of the member’s [connection](https://ably.com/docs/connect).
6165
*/
6266
connectionId: string;
6367
/**
64-
* <!-- MOVED FROM Cursors.set -->
6568
* An object containing the position of a member’s cursor.
6669
*/
6770
position: CursorPosition;
6871
/**
69-
* <!-- MOVED FROM Cursors.set -->
7072
* An optional arbitrary JSON-serializable object containing additional information about the cursor.
7173
*/
7274
data?: CursorData;
7375
}
7476

7577
/**
76-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
77-
* Used to configure a Space instance on creation.
78-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
78+
* Options to configure a {@link Space | Space} instance on its creation.
7979
*/
8080
export interface SpaceOptions {
8181
/**
82-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
8382
* Number of milliseconds after a user loses connection or closes their browser window to wait before their {@link SpaceMember} object is removed from the members list. The default is 120000ms (2 minutes).
84-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
8583
*/
8684
offlineTimeout: number;
8785
/**
88-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
89-
* Options relating to configuring the cursors API (see below).
90-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
86+
* Options to configure live cursors behavior.
9187
*/
9288
cursors: CursorsOptions;
9389
}
9490

9591
/**
96-
* <!-- MOVED WITH EDITING FROM Space.enter -->
97-
* Profile data can be set when {@link Space.enter | entering } a space. It is optional data that can be used to associate information with a member, such as a preferred username, or profile picture that can be subsequently displayed in their avatar. Profile data can be any arbitrary JSON-serializable object.
92+
* Optional data that is associated with a member. Examples include a preferred username, or a profile picture that can be subsequently displayed in their avatar. Can be any arbitrary JSON-serializable object.
9893
*/
9994
export type ProfileData = Record<string, unknown> | null;
10095

10196
/**
102-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
103-
* A SpaceMember represents a member within a Space instance. Each new connection that enters will create a new member, even if they have the same [`clientId`](https://ably.com/docs/auth/identified-clients?lang=javascript).
104-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
97+
* Represents a member within a Space instance. Each new connection that enters will create a new member, even if they have the same [`clientId`](https://ably.com/docs/auth/identified-clients).
98+
*
99+
* The following is an example payload of a `SpaceMember`:
100+
*
101+
* ```json
102+
* {
103+
* "clientId": "clemons#142",
104+
* "connectionId": "hd9743gjDc",
105+
* "isConnected": false,
106+
* "lastEvent": {
107+
* "name": "leave",
108+
* "timestamp": 1677595689759
109+
* },
110+
* "location": null,
111+
* "profileData": {
112+
* "username": "Claire Lemons",
113+
* "avatar": "https://slides-internal.com/users/clemons.png"
114+
* }
115+
* }
116+
* ```
105117
*/
106118
export interface SpaceMember {
107119
/**
108-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
109-
* The client identifier for the user, provided to the ably client instance.
110-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
120+
* The [client identifier](https://ably.com/docs/auth/identified-clients) for the member.
111121
*/
112122
clientId: string;
113123
/**
114-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
115-
* Identifier for the connection used by the user. This is a unique identifier.
116-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
124+
* The unique identifier of the member’s [connection](https://ably.com/docs/connect).
117125
*/
118126
connectionId: string;
119127
/**
120-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
121-
* Whether the user is connected to Ably.
122-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
128+
* Whether the user is connected to Ably or not.
123129
*/
124130
isConnected: boolean;
125131
/**
126-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
127-
* Optional user data that can be attached to a user, such as a username or image to display in an avatar stack.
128-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
132+
* Optional data that is associated with a member, such as a preferred username or profile picture to display in an avatar stack.
129133
*/
130134
profileData: ProfileData;
131135
/**
132-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
133136
* The current location of the user within the space.
134-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
135137
*/
136138
location: unknown;
137139
/**
138-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
139-
* The most recent event emitted by [presence](https://ably.com/docs/presence-occupancy/presence?lang=javascript) and its timestamp. Events will be either `enter`, `leave`, `update` or `present`.
140-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
140+
* The most recent event emitted by [presence](https://ably.com/docs/presence-occupancy/presence) and its timestamp. Events will be either `enter`, `leave`, `update` or `present`.
141141
*/
142142
lastEvent: {
143143
/**
144-
* <!-- MOVED FROM Locations.subscribe -->
145144
* The most recent event emitted by the member.
146145
*/
147146
name: Types.PresenceAction;
148147
/**
149-
* <!-- MOVED FROM Locations.subscribe -->
150148
* The timestamp of the most recently emitted event.
151149
*/
152150
timestamp: number;
153151
};
154152
}
155153

156154
/**
157-
* The `LockStatuses` namespace describes the possible values of the {@link LockStatus} type.
155+
* Describes the possible values of the {@link LockStatus} type.
158156
*/
159157
export namespace LockStatuses {
160158
/**
161-
* <!-- MOVED WITH EDITING FROM Locks -->
162-
* A member has requested a lock by calling { @link Locks.acquire | `acquire()` }.
159+
* A member has requested a lock by calling {@link Locks.acquire | `acquire()`}.
163160
*/
164161
export type Pending = 'pending';
165162
/**
166-
* <!-- MOVED FROM Locks -->
167-
* The lock is confirmed to be held by the requesting member.
163+
* A lock is confirmed to be held by the requesting member.
168164
*/
169165
export type Locked = 'locked';
170166
/**
171-
* <!-- MOVED WITH EDITING FROM Locks -->
172-
* The lock is confirmed to not be locked by the requesting member, or has been { @link Locks.release | released } by a member previously holding the lock.
167+
* A lock is confirmed to not be locked by the requesting member, or has been {@link Locks.release | released} by a member previously holding the lock.
173168
*/
174169
export type Unlocked = 'unlocked';
175170
}
176171

177172
/**
178-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
179-
* Represents a status of a lock.
180-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
173+
* Represents the status of a lock.
181174
*/
182175
export type LockStatus = LockStatuses.Pending | LockStatuses.Locked | LockStatuses.Unlocked;
183176

184177
/**
185-
* <!-- BEGIN CLASS-DEFINITIONS DOCUMENTATION -->
186178
* Represents a Lock.
187-
* <!-- END CLASS-DEFINITIONS DOCUMENTATION -->
188179
*/
189180
export type Lock = {
190181
/**
191-
* <!-- MOVED FROM Locks.subscribe -->
192182
* The unique ID of the lock request.
193183
*/
194184
id: string;
195185
/**
196-
* <!-- MOVED WITH EDITING FROM Locks.subscribe -->
197-
* The lock status of the event.
186+
* The status of the lock event.
198187
*/
199188
status: LockStatus;
200189
/**
201-
* Information about the space member who requested the lock.
190+
* Information about the member who requested the lock.
202191
*/
203192
member: SpaceMember;
204193
/**
205-
* <!-- MOVED FROM Locks.subscribe -->
206194
* The timestamp of the lock event.
207195
*/
208196
timestamp: number;
209197
/**
210-
* <!-- MOVED FROM Locks.subscribe -->
211198
* The optional attributes of the lock, such as the ID of the component it relates to.
212199
*/
213200
attributes?: LockAttributes;
214201
/**
215-
* <!-- MOVED FROM Locks.subscribe -->
216-
* The reason why the `request.status` is `unlocked`.
202+
* The reason why the lock status is {@link LockStatuses.Unlocked | `unlocked`}.
217203
*/
218204
reason?: Types.ErrorInfo;
219205
};

0 commit comments

Comments
 (0)