@fluidframework/container-definitions 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.3.1.0.125672

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/.eslintrc.js +20 -9
  2. package/README.md +5 -5
  3. package/api-extractor.json +2 -2
  4. package/dist/audience.d.ts +3 -4
  5. package/dist/audience.d.ts.map +1 -1
  6. package/dist/audience.js.map +1 -1
  7. package/dist/browserPackage.d.ts.map +1 -1
  8. package/dist/browserPackage.js +3 -3
  9. package/dist/browserPackage.js.map +1 -1
  10. package/dist/deltas.d.ts +12 -0
  11. package/dist/deltas.d.ts.map +1 -1
  12. package/dist/deltas.js.map +1 -1
  13. package/dist/error.d.ts.map +1 -1
  14. package/dist/error.js.map +1 -1
  15. package/dist/fluidModule.d.ts.map +1 -1
  16. package/dist/fluidModule.js.map +1 -1
  17. package/dist/fluidPackage.d.ts.map +1 -1
  18. package/dist/fluidPackage.js +5 -6
  19. package/dist/fluidPackage.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/loader.d.ts +20 -2
  24. package/dist/loader.d.ts.map +1 -1
  25. package/dist/loader.js.map +1 -1
  26. package/dist/runtime.d.ts +2 -1
  27. package/dist/runtime.d.ts.map +1 -1
  28. package/dist/runtime.js.map +1 -1
  29. package/dist/tokenProvider.d.ts.map +1 -1
  30. package/dist/tokenProvider.js.map +1 -1
  31. package/lib/audience.d.ts +3 -4
  32. package/lib/audience.d.ts.map +1 -1
  33. package/lib/audience.js.map +1 -1
  34. package/lib/browserPackage.d.ts.map +1 -1
  35. package/lib/browserPackage.js +3 -3
  36. package/lib/browserPackage.js.map +1 -1
  37. package/lib/deltas.d.ts +12 -0
  38. package/lib/deltas.d.ts.map +1 -1
  39. package/lib/deltas.js.map +1 -1
  40. package/lib/error.d.ts.map +1 -1
  41. package/lib/error.js.map +1 -1
  42. package/lib/fluidModule.d.ts.map +1 -1
  43. package/lib/fluidModule.js.map +1 -1
  44. package/lib/fluidPackage.d.ts.map +1 -1
  45. package/lib/fluidPackage.js +5 -6
  46. package/lib/fluidPackage.js.map +1 -1
  47. package/lib/index.d.ts +1 -1
  48. package/lib/index.d.ts.map +1 -1
  49. package/lib/index.js +1 -1
  50. package/lib/index.js.map +1 -1
  51. package/lib/loader.d.ts +20 -2
  52. package/lib/loader.d.ts.map +1 -1
  53. package/lib/loader.js.map +1 -1
  54. package/lib/runtime.d.ts +2 -1
  55. package/lib/runtime.d.ts.map +1 -1
  56. package/lib/runtime.js.map +1 -1
  57. package/lib/tokenProvider.d.ts.map +1 -1
  58. package/lib/tokenProvider.js.map +1 -1
  59. package/package.json +17 -14
  60. package/prettier.config.cjs +1 -1
  61. package/src/audience.ts +25 -22
  62. package/src/browserPackage.ts +33 -34
  63. package/src/deltas.ts +267 -245
  64. package/src/error.ts +58 -58
  65. package/src/fluidModule.ts +1 -1
  66. package/src/fluidPackage.ts +86 -86
  67. package/src/index.ts +51 -47
  68. package/src/loader.ts +498 -489
  69. package/src/runtime.ts +144 -148
  70. package/src/tokenProvider.ts +2 -2
  71. package/tsconfig.esnext.json +6 -6
  72. package/tsconfig.json +8 -15
package/src/deltas.ts CHANGED
@@ -3,307 +3,329 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IDisposable, IEventProvider, IEvent, IErrorEvent } from "@fluidframework/common-definitions";
7
6
  import {
8
- ConnectionMode,
9
- IClientConfiguration,
10
- IClientDetails,
11
- IDocumentMessage,
12
- ISequencedDocumentMessage,
13
- ISignalClient,
14
- ISignalMessage,
15
- ITokenClaims,
7
+ IDisposable,
8
+ IEventProvider,
9
+ IEvent,
10
+ IErrorEvent,
11
+ } from "@fluidframework/common-definitions";
12
+ import {
13
+ ConnectionMode,
14
+ IClientConfiguration,
15
+ IClientDetails,
16
+ IDocumentMessage,
17
+ ISequencedDocumentMessage,
18
+ ISignalClient,
19
+ ISignalMessage,
20
+ ITokenClaims,
16
21
  } from "@fluidframework/protocol-definitions";
17
22
 
18
23
  /**
19
24
  * Contract representing the result of a newly established connection to the server for syncing deltas.
20
25
  */
21
26
  export interface IConnectionDetails {
22
- clientId: string;
23
- claims: ITokenClaims;
24
- existing: boolean;
25
- mode: ConnectionMode;
26
- version: string;
27
- initialClients: ISignalClient[];
28
- serviceConfiguration: IClientConfiguration;
29
-
30
- /**
31
- * Last known sequence number to ordering service at the time of connection.
32
- *
33
- * @remarks
34
- *
35
- * It may lap actual last sequence number (quite a bit, if container is very active).
36
- * But it's the best information for client to figure out how far it is behind, at least
37
- * for "read" connections. "write" connections may use own "join" op to similar information,
38
- * that is likely to be more up-to-date.
39
- */
40
- checkpointSequenceNumber: number | undefined;
27
+ clientId: string;
28
+ claims: ITokenClaims;
29
+
30
+ /**
31
+ * @deprecated No replacement API recommended.
32
+ */
33
+ existing: boolean;
34
+
35
+ /**
36
+ * @deprecated No replacement API recommended.
37
+ */
38
+ mode: ConnectionMode;
39
+
40
+ /**
41
+ * @deprecated No replacement API recommended.
42
+ */
43
+ version: string;
44
+
45
+ /**
46
+ * @deprecated No replacement API recommended.
47
+ */
48
+ initialClients: ISignalClient[];
49
+ serviceConfiguration: IClientConfiguration;
50
+
51
+ /**
52
+ * Last known sequence number to ordering service at the time of connection.
53
+ *
54
+ * @remarks
55
+ *
56
+ * It may lap actual last sequence number (quite a bit, if container is very active).
57
+ * But it's the best information for client to figure out how far it is behind, at least
58
+ * for "read" connections. "write" connections may use own "join" op to similar information,
59
+ * that is likely to be more up-to-date.
60
+ */
61
+ checkpointSequenceNumber: number | undefined;
41
62
  }
42
63
 
43
64
  /**
44
65
  * Interface used to define a strategy for handling incoming delta messages
45
66
  */
46
67
  export interface IDeltaHandlerStrategy {
47
- /**
48
- * Processes the message.
49
- */
50
- process: (message: ISequencedDocumentMessage) => void;
51
-
52
- /**
53
- * Processes the signal.
54
- */
55
- processSignal: (message: ISignalMessage) => void;
68
+ /**
69
+ * Processes the message.
70
+ */
71
+ process: (message: ISequencedDocumentMessage) => void;
72
+
73
+ /**
74
+ * Processes the signal.
75
+ */
76
+ processSignal: (message: ISignalMessage) => void;
56
77
  }
57
78
 
58
79
  /**
59
80
  * Contract supporting delivery of outbound messages to the server
60
81
  */
61
82
  export interface IDeltaSender {
62
- /**
63
- * Flush all pending messages through the outbound queue
64
- */
65
- flush(): void;
83
+ /**
84
+ * Flush all pending messages through the outbound queue
85
+ */
86
+ flush(): void;
66
87
  }
67
88
 
68
89
  /**
69
90
  * Events emitted by {@link IDeltaManager}.
70
91
  */
71
- /* eslint-disable @typescript-eslint/unified-signatures */
72
92
  export interface IDeltaManagerEvents extends IEvent {
73
- /**
74
- * @deprecated No replacement API recommended.
75
- */
76
- (event: "prepareSend", listener: (messageBuffer: any[]) => void);
77
-
78
- /**
79
- * @deprecated No replacement API recommended.
80
- */
81
- (event: "submitOp", listener: (message: IDocumentMessage) => void);
82
-
83
- /**
84
- * Emitted immediately after processing an incoming operation (op).
85
- *
86
- * @remarks
87
- *
88
- * Note: this event is not intended for general use.
89
- * Prefer to listen to events on the appropriate ultimate recipients of the ops, rather than listening to the
90
- * ops directly on the {@link IDeltaManager}.
91
- *
92
- * Listener parameters:
93
- *
94
- * - `message`: The op that was processed.
95
- *
96
- * - `processingTime`: The amount of time it took to process the inbound operation (op), expressed in milliseconds.
97
- */
98
- (event: "op", listener: (message: ISequencedDocumentMessage, processingTime: number) => void);
99
-
100
- /**
101
- * @deprecated No replacement API recommended.
102
- */
103
- (event: "allSentOpsAckd", listener: () => void);
104
-
105
- /**
106
- * @deprecated No replacement API recommended.
107
- */
108
- (event: "pong", listener: (latency: number) => void);
109
-
110
- /**
111
- * @deprecated No replacement API recommended.
112
- */
113
- (event: "processTime", listener: (latency: number) => void);
114
-
115
- /**
116
- * Emitted when the {@link IDeltaManager} completes connecting to the Fluid service.
117
- *
118
- * @remarks
119
- * This occurs once we've received the connect_document_success message from the server,
120
- * and happens prior to the client's join message (if there is a join message).
121
- *
122
- * Listener parameters:
123
- *
124
- * - `details`: Connection metadata.
125
- *
126
- * - `opsBehind`: An estimate of far behind the client is relative to the service in terms of ops.
127
- * Will not be specified if an estimate cannot be determined.
128
- */
129
- (event: "connect", listener: (details: IConnectionDetails, opsBehind?: number) => void);
130
-
131
- /**
132
- * Emitted when the {@link IDeltaManager} becomes disconnected from the Fluid service.
133
- *
134
- * @remarks Listener parameters:
135
- *
136
- * - `reason`: Describes the reason for which the delta manager was disconnected.
137
- */
138
- (event: "disconnect", listener: (reason: string) => void);
139
-
140
- /**
141
- * Emitted when read/write permissions change.
142
- *
143
- * @remarks Listener parameters:
144
- *
145
- * - `readonly`: Whether or not the delta manager is now read-only.
146
- */
147
- (event: "readonly", listener: (readonly: boolean) => void);
93
+ /**
94
+ * @deprecated No replacement API recommended.
95
+ */
96
+ (event: "prepareSend", listener: (messageBuffer: any[]) => void);
97
+
98
+ /**
99
+ * @deprecated No replacement API recommended.
100
+ */
101
+ (event: "submitOp", listener: (message: IDocumentMessage) => void);
102
+
103
+ /**
104
+ * Emitted immediately after processing an incoming operation (op).
105
+ *
106
+ * @remarks
107
+ *
108
+ * Note: this event is not intended for general use.
109
+ * Prefer to listen to events on the appropriate ultimate recipients of the ops, rather than listening to the
110
+ * ops directly on the {@link IDeltaManager}.
111
+ *
112
+ * Listener parameters:
113
+ *
114
+ * - `message`: The op that was processed.
115
+ *
116
+ * - `processingTime`: The amount of time it took to process the inbound operation (op), expressed in milliseconds.
117
+ */
118
+ (event: "op", listener: (message: ISequencedDocumentMessage, processingTime: number) => void);
119
+
120
+ /**
121
+ * @deprecated No replacement API recommended.
122
+ */
123
+ (event: "allSentOpsAckd", listener: () => void);
124
+
125
+ /**
126
+ * @deprecated No replacement API recommended.
127
+ */
128
+ (event: "pong", listener: (latency: number) => void);
129
+
130
+ /**
131
+ * @deprecated No replacement API recommended.
132
+ */
133
+ (event: "processTime", listener: (latency: number) => void);
134
+
135
+ /**
136
+ * Emitted when the {@link IDeltaManager} completes connecting to the Fluid service.
137
+ *
138
+ * @remarks
139
+ * This occurs once we've received the connect_document_success message from the server,
140
+ * and happens prior to the client's join message (if there is a join message).
141
+ *
142
+ * Listener parameters:
143
+ *
144
+ * - `details`: Connection metadata.
145
+ *
146
+ * - `opsBehind`: An estimate of far behind the client is relative to the service in terms of ops.
147
+ * Will not be specified if an estimate cannot be determined.
148
+ */
149
+ (event: "connect", listener: (details: IConnectionDetails, opsBehind?: number) => void);
150
+
151
+ /**
152
+ * Emitted when the {@link IDeltaManager} becomes disconnected from the Fluid service.
153
+ *
154
+ * @remarks Listener parameters:
155
+ *
156
+ * - `reason`: Describes the reason for which the delta manager was disconnected.
157
+ */
158
+ (event: "disconnect", listener: (reason: string) => void);
159
+
160
+ /**
161
+ * Emitted when read/write permissions change.
162
+ *
163
+ * @remarks Listener parameters:
164
+ *
165
+ * - `readonly`: Whether or not the delta manager is now read-only.
166
+ */
167
+ (event: "readonly", listener: (readonly: boolean) => void);
148
168
  }
149
- /* eslint-enable @typescript-eslint/unified-signatures */
150
169
 
151
170
  /**
152
171
  * Manages the transmission of ops between the runtime and storage.
153
172
  */
154
- export interface IDeltaManager<T, U> extends IEventProvider<IDeltaManagerEvents>, IDeltaSender, IDisposable {
155
- /** The queue of inbound delta messages */
156
- readonly inbound: IDeltaQueue<T>;
173
+ export interface IDeltaManager<T, U>
174
+ extends IEventProvider<IDeltaManagerEvents>,
175
+ IDeltaSender,
176
+ IDisposable {
177
+ /** The queue of inbound delta messages */
178
+ readonly inbound: IDeltaQueue<T>;
157
179
 
158
- /** The queue of outbound delta messages */
159
- readonly outbound: IDeltaQueue<U[]>;
180
+ /** The queue of outbound delta messages */
181
+ readonly outbound: IDeltaQueue<U[]>;
160
182
 
161
- /** The queue of inbound delta signals */
162
- readonly inboundSignal: IDeltaQueue<ISignalMessage>;
183
+ /** The queue of inbound delta signals */
184
+ readonly inboundSignal: IDeltaQueue<ISignalMessage>;
163
185
 
164
- /** The current minimum sequence number */
165
- readonly minimumSequenceNumber: number;
186
+ /** The current minimum sequence number */
187
+ readonly minimumSequenceNumber: number;
166
188
 
167
- /** The last sequence number processed by the delta manager */
168
- readonly lastSequenceNumber: number;
189
+ /** The last sequence number processed by the delta manager */
190
+ readonly lastSequenceNumber: number;
169
191
 
170
- /** The last message processed by the delta manager */
171
- readonly lastMessage: ISequencedDocumentMessage | undefined;
192
+ /** The last message processed by the delta manager */
193
+ readonly lastMessage: ISequencedDocumentMessage | undefined;
172
194
 
173
- /** The latest sequence number the delta manager is aware of */
174
- readonly lastKnownSeqNumber: number;
195
+ /** The latest sequence number the delta manager is aware of */
196
+ readonly lastKnownSeqNumber: number;
175
197
 
176
- /** The initial sequence number set when attaching the op handler */
177
- readonly initialSequenceNumber: number;
198
+ /** The initial sequence number set when attaching the op handler */
199
+ readonly initialSequenceNumber: number;
178
200
 
179
- /**
180
- * Tells if current connection has checkpoint information.
181
- * I.e. we know how far behind the client was at the time of establishing connection
182
- */
183
- readonly hasCheckpointSequenceNumber: boolean;
201
+ /**
202
+ * Tells if current connection has checkpoint information.
203
+ * I.e. we know how far behind the client was at the time of establishing connection
204
+ */
205
+ readonly hasCheckpointSequenceNumber: boolean;
184
206
 
185
- /** Details of client */
186
- readonly clientDetails: IClientDetails;
207
+ /** Details of client */
208
+ readonly clientDetails: IClientDetails;
187
209
 
188
- /** Protocol version being used to communicate with the service */
189
- readonly version: string;
210
+ /** Protocol version being used to communicate with the service */
211
+ readonly version: string;
190
212
 
191
- /** Max message size allowed to the delta manager */
192
- readonly maxMessageSize: number;
213
+ /** Max message size allowed to the delta manager */
214
+ readonly maxMessageSize: number;
193
215
 
194
- /** Service configuration provided by the service. */
195
- readonly serviceConfiguration: IClientConfiguration | undefined;
216
+ /** Service configuration provided by the service. */
217
+ readonly serviceConfiguration: IClientConfiguration | undefined;
196
218
 
197
- /** Flag to indicate whether the client can write or not. */
198
- readonly active: boolean;
219
+ /** Flag to indicate whether the client can write or not. */
220
+ readonly active: boolean;
199
221
 
200
- readonly readOnlyInfo: ReadOnlyInfo;
222
+ readonly readOnlyInfo: ReadOnlyInfo;
201
223
 
202
- /** Submit a signal to the service to be broadcast to other connected clients, but not persisted */
203
- submitSignal(content: any): void;
224
+ /** Submit a signal to the service to be broadcast to other connected clients, but not persisted */
225
+ submitSignal(content: any): void;
204
226
  }
205
227
 
206
228
  /**
207
229
  * Events emitted by {@link IDeltaQueue}.
208
230
  */
209
- /* eslint-disable @typescript-eslint/unified-signatures */
210
231
  export interface IDeltaQueueEvents<T> extends IErrorEvent {
211
- /**
212
- * Emitted when a task is enqueued.
213
- *
214
- * @remarks Listener parameters:
215
- *
216
- * - `task`: The task being enqueued.
217
- */
218
- (event: "push", listener: (task: T) => void);
219
-
220
- /**
221
- * Emitted immediately after processing an enqueued task and removing it from the queue.
222
- *
223
- * @remarks
224
- *
225
- * Note: this event is not intended for general use.
226
- * Prefer to listen to events on the appropriate ultimate recipients of the ops, rather than listening to the
227
- * ops directly on the {@link IDeltaQueue}.
228
- *
229
- * Listener parameters:
230
- *
231
- * - `task`: The task that was processed.
232
- */
233
- (event: "op", listener: (task: T) => void);
234
-
235
- /**
236
- * Emitted when the queue of tasks to process is emptied.
237
- *
238
- * @remarks Listener parameters:
239
- *
240
- * - `count`: The number of events (`T`) processed before becoming idle.
241
- *
242
- * - `duration`: The amount of time it took to process elements (in milliseconds).
243
- *
244
- * @see {@link IDeltaQueue.idle}
245
- */
246
- (event: "idle", listener: (count: number, duration: number) => void);
232
+ /**
233
+ * Emitted when a task is enqueued.
234
+ *
235
+ * @remarks Listener parameters:
236
+ *
237
+ * - `task`: The task being enqueued.
238
+ */
239
+ (event: "push", listener: (task: T) => void);
240
+
241
+ /**
242
+ * Emitted immediately after processing an enqueued task and removing it from the queue.
243
+ *
244
+ * @remarks
245
+ *
246
+ * Note: this event is not intended for general use.
247
+ * Prefer to listen to events on the appropriate ultimate recipients of the ops, rather than listening to the
248
+ * ops directly on the {@link IDeltaQueue}.
249
+ *
250
+ * Listener parameters:
251
+ *
252
+ * - `task`: The task that was processed.
253
+ */
254
+ (event: "op", listener: (task: T) => void);
255
+
256
+ /**
257
+ * Emitted when the queue of tasks to process is emptied.
258
+ *
259
+ * @remarks Listener parameters:
260
+ *
261
+ * - `count`: The number of events (`T`) processed before becoming idle.
262
+ *
263
+ * - `duration`: The amount of time it took to process elements (in milliseconds).
264
+ *
265
+ * @see {@link IDeltaQueue.idle}
266
+ */
267
+ (event: "idle", listener: (count: number, duration: number) => void);
247
268
  }
248
- /* eslint-enable @typescript-eslint/unified-signatures */
249
269
 
250
270
  /**
251
271
  * Queue of ops to be sent to or processed from storage
252
272
  */
253
273
  export interface IDeltaQueue<T> extends IEventProvider<IDeltaQueueEvents<T>>, IDisposable {
254
- /**
255
- * Flag indicating whether or not the queue was paused
256
- */
257
- paused: boolean;
258
-
259
- /**
260
- * The number of messages remaining in the queue
261
- */
262
- length: number;
263
-
264
- /**
265
- * Flag indicating whether or not the queue is idle.
266
- * I.e. there are no remaining messages to processes.
267
- */
268
- idle: boolean;
269
-
270
- /**
271
- * Pauses processing on the queue.
272
- *
273
- * @returns A promise which resolves when processing has been paused.
274
- */
275
- pause(): Promise<void>;
276
-
277
- /**
278
- * Resumes processing on the queue
279
- */
280
- resume(): void;
281
-
282
- /**
283
- * Peeks at the next message in the queue
284
- */
285
- peek(): T | undefined;
286
-
287
- /**
288
- * Returns all the items in the queue as an array. Does not remove them from the queue.
289
- */
290
- toArray(): T[];
291
-
292
- /**
293
- * returns number of ops processed and time it took to process these ops.
294
- * Zeros if queue did not process anything (had no messages, was paused or had hit an error before)
295
- */
296
- waitTillProcessingDone(): Promise<{ count: number; duration: number; }>;
274
+ /**
275
+ * Flag indicating whether or not the queue was paused
276
+ */
277
+ paused: boolean;
278
+
279
+ /**
280
+ * The number of messages remaining in the queue
281
+ */
282
+ length: number;
283
+
284
+ /**
285
+ * Flag indicating whether or not the queue is idle.
286
+ * I.e. there are no remaining messages to processes.
287
+ */
288
+ idle: boolean;
289
+
290
+ /**
291
+ * Pauses processing on the queue.
292
+ *
293
+ * @returns A promise which resolves when processing has been paused.
294
+ */
295
+ pause(): Promise<void>;
296
+
297
+ /**
298
+ * Resumes processing on the queue
299
+ */
300
+ resume(): void;
301
+
302
+ /**
303
+ * Peeks at the next message in the queue
304
+ */
305
+ peek(): T | undefined;
306
+
307
+ /**
308
+ * Returns all the items in the queue as an array. Does not remove them from the queue.
309
+ */
310
+ toArray(): T[];
311
+
312
+ /**
313
+ * returns number of ops processed and time it took to process these ops.
314
+ * Zeros if queue did not process anything (had no messages, was paused or had hit an error before)
315
+ */
316
+ waitTillProcessingDone(): Promise<{ count: number; duration: number }>;
297
317
  }
298
318
 
299
- export type ReadOnlyInfo = {
300
- readonly readonly: false | undefined;
301
- } | {
302
- readonly readonly: true;
303
- /** read-only because forceReadOnly() was called */
304
- readonly forced: boolean;
305
- /** read-only because client does not have write permissions for document */
306
- readonly permissions: boolean | undefined;
307
- /** read-only with no delta stream connection */
308
- readonly storageOnly: boolean;
309
- };
319
+ export type ReadOnlyInfo =
320
+ | {
321
+ readonly readonly: false | undefined;
322
+ }
323
+ | {
324
+ readonly readonly: true;
325
+ /** read-only because forceReadOnly() was called */
326
+ readonly forced: boolean;
327
+ /** read-only because client does not have write permissions for document */
328
+ readonly permissions: boolean | undefined;
329
+ /** read-only with no delta stream connection */
330
+ readonly storageOnly: boolean;
331
+ };