@fluidframework/fluid-static 2.0.0-internal.8.0.0 → 2.0.0-rc.1.0.0

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 (64) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +0 -6
  3. package/api-extractor-esm.json +4 -0
  4. package/api-extractor-lint.json +1 -10
  5. package/api-extractor.json +1 -9
  6. package/api-report/fluid-static.api.md +16 -16
  7. package/dist/fluid-static-alpha.d.ts +20 -20
  8. package/dist/fluid-static-beta.d.ts +363 -29
  9. package/dist/fluid-static-public.d.ts +363 -29
  10. package/dist/fluid-static-untrimmed.d.ts +20 -16
  11. package/dist/fluidContainer.d.ts +7 -3
  12. package/dist/fluidContainer.d.ts.map +1 -1
  13. package/dist/{fluidContainer.cjs → fluidContainer.js} +1 -1
  14. package/dist/fluidContainer.js.map +1 -0
  15. package/dist/{index.cjs → index.js} +4 -4
  16. package/dist/index.js.map +1 -0
  17. package/dist/{rootDataObject.cjs → rootDataObject.js} +9 -5
  18. package/dist/rootDataObject.js.map +1 -0
  19. package/dist/{serviceAudience.cjs → serviceAudience.js} +1 -1
  20. package/dist/serviceAudience.js.map +1 -0
  21. package/dist/types.d.ts +13 -13
  22. package/dist/{types.cjs → types.js} +1 -1
  23. package/dist/types.js.map +1 -0
  24. package/dist/{utils.cjs → utils.js} +1 -1
  25. package/dist/utils.js.map +1 -0
  26. package/lib/fluid-static-alpha.d.mts +402 -0
  27. package/lib/{fluid-static-alpha.d.ts → fluid-static-beta.d.mts} +24 -26
  28. package/lib/fluid-static-public.d.mts +406 -0
  29. package/lib/{fluid-static-untrimmed.d.ts → fluid-static-untrimmed.d.mts} +20 -22
  30. package/lib/{fluidContainer.d.ts → fluidContainer.d.mts} +8 -4
  31. package/lib/fluidContainer.d.mts.map +1 -0
  32. package/lib/fluidContainer.mjs.map +1 -1
  33. package/lib/{index.d.ts → index.d.mts} +1 -1
  34. package/lib/index.d.mts.map +1 -0
  35. package/lib/{rootDataObject.d.ts → rootDataObject.d.mts} +1 -1
  36. package/lib/rootDataObject.d.mts.map +1 -0
  37. package/lib/rootDataObject.mjs +7 -3
  38. package/lib/rootDataObject.mjs.map +1 -1
  39. package/lib/{serviceAudience.d.ts → serviceAudience.d.mts} +1 -1
  40. package/lib/serviceAudience.d.mts.map +1 -0
  41. package/lib/{types.d.ts → types.d.mts} +14 -14
  42. package/lib/types.d.mts.map +1 -0
  43. package/lib/types.mjs.map +1 -1
  44. package/lib/{utils.d.ts → utils.d.mts} +1 -1
  45. package/lib/utils.d.mts.map +1 -0
  46. package/package.json +84 -48
  47. package/src/fluidContainer.ts +7 -3
  48. package/src/rootDataObject.ts +7 -3
  49. package/src/types.ts +13 -13
  50. package/dist/fluidContainer.cjs.map +0 -1
  51. package/dist/index.cjs.map +0 -1
  52. package/dist/rootDataObject.cjs.map +0 -1
  53. package/dist/serviceAudience.cjs.map +0 -1
  54. package/dist/types.cjs.map +0 -1
  55. package/dist/utils.cjs.map +0 -1
  56. package/lib/fluid-static-beta.d.ts +0 -78
  57. package/lib/fluid-static-public.d.ts +0 -78
  58. package/lib/fluidContainer.d.ts.map +0 -1
  59. package/lib/index.d.ts.map +0 -1
  60. package/lib/rootDataObject.d.ts.map +0 -1
  61. package/lib/serviceAudience.d.ts.map +0 -1
  62. package/lib/types.d.ts.map +0 -1
  63. package/lib/utils.d.ts.map +0 -1
  64. package/tsc-multi.test.json +0 -4
@@ -15,11 +15,47 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
15
15
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
16
16
  import { IRuntimeFactory } from '@fluidframework/container-definitions';
17
17
 
18
- /* Excluded from this release type: AttachState */
19
-
20
- /* Excluded from this release type: ConnectionState */
21
-
22
- /* Excluded from this release type: ContainerSchema */
18
+ /**
19
+ * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
20
+ *
21
+ * @remarks
22
+ *
23
+ * It includes both the instances of objects that are initially available upon `Container` creation, as well
24
+ * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
25
+ * @public
26
+ */
27
+ export declare interface ContainerSchema {
28
+ /**
29
+ * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.
30
+ *
31
+ * @remarks It uses the key as the id and the value as the loadable object to create.
32
+ *
33
+ * @example
34
+ *
35
+ * In the example below two objects will be created when the `Container` is first
36
+ * created. One with id "map1" that will return a `SharedMap` and the other with
37
+ * id "pair1" that will return a `KeyValueDataObject`.
38
+ *
39
+ * ```typescript
40
+ * {
41
+ * map1: SharedMap,
42
+ * pair1: KeyValueDataObject,
43
+ * }
44
+ * ```
45
+ */
46
+ initialObjects: LoadableObjectClassRecord;
47
+ /**
48
+ * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
49
+ *
50
+ * @remarks
51
+ *
52
+ * Types defined in `initialObjects` will always be available and are not required to be provided here.
53
+ *
54
+ * For best practice it's recommended to define all the dynamic types you create even if they are
55
+ * included via initialObjects.
56
+ */
57
+ dynamicObjectTypes?: LoadableObjectClass<any>[];
58
+ }
23
59
 
24
60
  /* Excluded from this release type: createDOProviderContainerRuntimeFactory */
25
61
 
@@ -27,29 +63,234 @@ import { IRuntimeFactory } from '@fluidframework/container-definitions';
27
63
 
28
64
  /* Excluded from this release type: createServiceAudience */
29
65
 
30
- /* Excluded from this release type: DataObjectClass */
31
-
32
- /* Excluded from this release type: IChannelFactory */
66
+ /**
67
+ * A class that has a factory that can create a `DataObject` and a
68
+ * constructor that will return the type of the `DataObject`.
69
+ *
70
+ * @typeParam T - The class of the `DataObject`.
71
+ * @public
72
+ */
73
+ export declare type DataObjectClass<T extends IFluidLoadable> = {
74
+ readonly factory: {
75
+ IFluidDataStoreFactory: DataObjectClass<T>["factory"];
76
+ };
77
+ } & LoadableObjectCtor<T>;
33
78
 
34
- /* Excluded from this release type: IConnection */
79
+ /**
80
+ * Base interface for information for each connection made to the Fluid session.
81
+ *
82
+ * @remarks This interface can be extended to provide additional information specific to each service.
83
+ * @public
84
+ */
85
+ export declare interface IConnection {
86
+ /**
87
+ * A unique ID for the connection. A single user may have multiple connections, each with a different ID.
88
+ */
89
+ id: string;
90
+ /**
91
+ * Whether the connection is in read or read/write mode.
92
+ */
93
+ mode: "write" | "read";
94
+ }
35
95
 
36
96
  /* Excluded from this release type: IContainer */
37
97
 
38
- /* Excluded from this release type: ICriticalContainerError */
39
-
40
- /* Excluded from this release type: IEvent */
41
-
42
- /* Excluded from this release type: IEventProvider */
43
-
44
- /* Excluded from this release type: IFluidContainer */
45
-
46
- /* Excluded from this release type: IFluidContainerEvents */
98
+ /**
99
+ * Provides an entrypoint into the client side of collaborative Fluid data.
100
+ * Provides access to the data as well as status on the collaboration session.
101
+ *
102
+ * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
103
+ *
104
+ * @remarks Note: external implementations of this interface are not supported.
105
+ * @sealed
106
+ * @public
107
+ */
108
+ export declare interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends IEventProvider<IFluidContainerEvents> {
109
+ /**
110
+ * Provides the current connected state of the container
111
+ */
112
+ readonly connectionState: ConnectionState;
113
+ /**
114
+ * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
115
+ *
116
+ * @remarks
117
+ *
118
+ * You should always check the `isDirty` flag before closing the container or navigating away from the page.
119
+ * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
120
+ * acknowledged by the service.
121
+ *
122
+ * A container is considered dirty in the following cases:
123
+ *
124
+ * 1. The container has been created in the detached state, and either it has not been attached yet or it is
125
+ * in the process of being attached (container is in `attaching` state). If container is closed prior to being
126
+ * attached, host may never know if the file was created or not.
127
+ *
128
+ * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.
129
+ * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the
130
+ * service. In some cases this can be due to lack of network connection. If the network connection is down,
131
+ * it needs to be restored for the pending changes to be acknowledged.
132
+ */
133
+ readonly isDirty: boolean;
134
+ /**
135
+ * Whether or not the container is disposed, which permanently disables it.
136
+ */
137
+ readonly disposed: boolean;
138
+ /**
139
+ * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
140
+ *
141
+ * @remarks These data objects and DDSes exist for the lifetime of the container.
142
+ */
143
+ readonly initialObjects: InitialObjects<TContainerSchema>;
144
+ /**
145
+ * The current attachment state of the container.
146
+ *
147
+ * @remarks
148
+ *
149
+ * Once a container has been attached, it remains attached.
150
+ * When loading an existing container, it will already be attached.
151
+ */
152
+ readonly attachState: AttachState;
153
+ /**
154
+ * A newly created container starts detached from the collaborative service.
155
+ * Calling `attach()` uploads the new container to the service and connects to the collaborative service.
156
+ *
157
+ * @remarks
158
+ *
159
+ * This should only be called when the container is in the
160
+ * {@link @fluidframework/container-definitions#AttachState.Detatched} state.
161
+ *
162
+ * This can be determined by observing {@link IFluidContainer.attachState}.
163
+ *
164
+ * @returns A promise which resolves when the attach is complete, with the string identifier of the container.
165
+ */
166
+ attach(): Promise<string>;
167
+ /**
168
+ * Attempts to connect the container to the delta stream and process operations.
169
+ *
170
+ * @throws Will throw an error if connection is unsuccessful.
171
+ *
172
+ * @remarks
173
+ *
174
+ * This should only be called when the container is in the
175
+ * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
176
+ *
177
+ * This can be determined by observing {@link IFluidContainer.connectionState}.
178
+ */
179
+ connect(): void;
180
+ /**
181
+ * Disconnects the container from the delta stream and stops processing operations.
182
+ *
183
+ * @remarks
184
+ *
185
+ * This should only be called when the container is in the
186
+ * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
187
+ *
188
+ * This can be determined by observing {@link IFluidContainer.connectionState}.
189
+ */
190
+ disconnect(): void;
191
+ /**
192
+ * Create a new data object or Distributed Data Store (DDS) of the specified type.
193
+ *
194
+ * @remarks
195
+ *
196
+ * In order to share the data object or DDS with other
197
+ * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
198
+ * initialObjects.
199
+ *
200
+ * @param objectClass - The class of the `DataObject` or `SharedObject` to create.
201
+ *
202
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
203
+ */
204
+ create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
205
+ /**
206
+ * Dispose of the container instance, permanently disabling it.
207
+ */
208
+ dispose(): void;
209
+ }
47
210
 
48
- /* Excluded from this release type: IFluidLoadable */
211
+ /**
212
+ * Events emitted from {@link IFluidContainer}.
213
+ *
214
+ * @remarks Note: external implementations of this interface are not supported.
215
+ * @sealed
216
+ * @public
217
+ */
218
+ export declare interface IFluidContainerEvents extends IEvent {
219
+ /**
220
+ * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.
221
+ *
222
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
223
+ *
224
+ * @see
225
+ *
226
+ * - {@link IFluidContainer.connectionState}
227
+ *
228
+ * - {@link IFluidContainer.connect}
229
+ */
230
+ (event: "connected", listener: () => void): void;
231
+ /**
232
+ * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.
233
+ *
234
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
235
+ *
236
+ * @see
237
+ *
238
+ * - {@link IFluidContainer.connectionState}
239
+ *
240
+ * - {@link IFluidContainer.disconnect}
241
+ */
242
+ (event: "disconnected", listener: () => void): void;
243
+ /**
244
+ * Emitted when all local changes/edits have been acknowledged by the service.
245
+ *
246
+ * @remarks "dirty" event will be emitted when the next local change has been made.
247
+ *
248
+ * @see {@link IFluidContainer.isDirty}
249
+ */
250
+ (event: "saved", listener: () => void): void;
251
+ /**
252
+ * Emitted when the first local change has been made, following a "saved" event.
253
+ *
254
+ * @remarks "saved" event will be emitted once all local changes have been acknowledged by the service.
255
+ *
256
+ * @see {@link IFluidContainer.isDirty}
257
+ */
258
+ (event: "dirty", listener: () => void): void;
259
+ /**
260
+ * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
261
+ *
262
+ * @remarks Listener parameters:
263
+ *
264
+ * - `error`: If the container was closed due to error (as opposed to an explicit call to
265
+ * {@link IFluidContainer.dispose}), this will contain details about the error that caused it.
266
+ */
267
+ (event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
268
+ }
49
269
 
50
- /* Excluded from this release type: IMember */
270
+ /**
271
+ * Base interface to be implemented to fetch each service's member.
272
+ *
273
+ * @remarks This interface can be extended by each service to provide additional service-specific user metadata.
274
+ * @public
275
+ */
276
+ export declare interface IMember {
277
+ /**
278
+ * An ID for the user, unique among each individual user connecting to the session.
279
+ */
280
+ userId: string;
281
+ /**
282
+ * The set of connections the user has made, e.g. from multiple tabs or devices.
283
+ */
284
+ connections: IConnection[];
285
+ }
51
286
 
52
- /* Excluded from this release type: InitialObjects */
287
+ /**
288
+ * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
289
+ * @public
290
+ */
291
+ export declare type InitialObjects<T extends ContainerSchema> = {
292
+ [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<infer TChannel> ? TChannel : never;
293
+ };
53
294
 
54
295
  /* Excluded from this release type: IProvideRootDataObject */
55
296
 
@@ -57,22 +298,115 @@ import { IRuntimeFactory } from '@fluidframework/container-definitions';
57
298
 
58
299
  /* Excluded from this release type: IRuntimeFactory */
59
300
 
60
- /* Excluded from this release type: IServiceAudience */
301
+ /**
302
+ * Base interface to be implemented to fetch each service's audience.
303
+ *
304
+ * @remarks
305
+ *
306
+ * The type parameter `M` allows consumers to further extend the client object with service-specific
307
+ * details about the connecting client, such as device information, environment, or a username.
308
+ *
309
+ * @typeParam M - A service-specific {@link IMember} type.
310
+ * @public
311
+ */
312
+ export declare interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
313
+ /**
314
+ * Returns an map of all users currently in the Fluid session where key is the userId and the value is the
315
+ * member object. The implementation may choose to exclude certain connections from the returned map.
316
+ * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.
317
+ */
318
+ getMembers(): Map<string, M>;
319
+ /**
320
+ * Returns the current active user on this client once they are connected. Otherwise, returns undefined.
321
+ */
322
+ getMyself(): Myself<M> | undefined;
323
+ }
61
324
 
62
- /* Excluded from this release type: IServiceAudienceEvents */
325
+ /**
326
+ * Events that trigger when the roster of members in the Fluid session change.
327
+ *
328
+ * @remarks
329
+ *
330
+ * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s
331
+ * {@link IServiceAudience.getMembers} method will emit events.
332
+ *
333
+ * @typeParam M - A service-specific {@link IMember} implementation.
334
+ * @public
335
+ */
336
+ export declare interface IServiceAudienceEvents<M extends IMember> extends IEvent {
337
+ /**
338
+ * Emitted when a {@link IMember | member}(s) are either added or removed.
339
+ *
340
+ * @eventProperty
341
+ */
342
+ (event: "membersChanged", listener: () => void): void;
343
+ /**
344
+ * Emitted when a {@link IMember | member} joins the audience.
345
+ *
346
+ * @eventProperty
347
+ */
348
+ (event: "memberAdded", listener: MemberChangedListener<M>): void;
349
+ /**
350
+ * Emitted when a {@link IMember | member} leaves the audience.
351
+ *
352
+ * @eventProperty
353
+ */
354
+ (event: "memberRemoved", listener: MemberChangedListener<M>): void;
355
+ }
63
356
 
64
- /* Excluded from this release type: LoadableObjectClass */
357
+ /**
358
+ * A class object of `DataObject` or `SharedObject`.
359
+ *
360
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
361
+ * @public
362
+ */
363
+ export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;
65
364
 
66
- /* Excluded from this release type: LoadableObjectClassRecord */
365
+ /**
366
+ * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
367
+ * or `SharedObject` in a {@link LoadableObjectRecord}.
368
+ * @public
369
+ */
370
+ export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
67
371
 
68
- /* Excluded from this release type: LoadableObjectCtor */
372
+ /**
373
+ * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
374
+ *
375
+ * @typeParam T - The class of the loadable object.
376
+ * @public
377
+ */
378
+ export declare type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
69
379
 
70
380
  /* Excluded from this release type: LoadableObjectRecord */
71
381
 
72
- /* Excluded from this release type: MemberChangedListener */
382
+ /**
383
+ * Signature for {@link IMember} change events.
384
+ *
385
+ * @param clientId - A unique identifier for the client.
386
+ * @param member - The service-specific member object for the client.
387
+ *
388
+ * @see See {@link IServiceAudienceEvents} for usage details.
389
+ * @public
390
+ */
391
+ export declare type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
73
392
 
74
- /* Excluded from this release type: Myself */
393
+ /**
394
+ * An extended member object that includes currentConnection
395
+ * @public
396
+ */
397
+ export declare type Myself<M extends IMember = IMember> = M & {
398
+ currentConnection: string;
399
+ };
75
400
 
76
- /* Excluded from this release type: SharedObjectClass */
401
+ /**
402
+ * A class that has a factory that can create a DDSes (`SharedObject`s) and a
403
+ * constructor that will return the type of the `DataObject`.
404
+ *
405
+ * @typeParam T - The class of the `SharedObject`.
406
+ * @public
407
+ */
408
+ export declare type SharedObjectClass<T extends IFluidLoadable> = {
409
+ readonly getFactory: () => IChannelFactory;
410
+ } & LoadableObjectCtor<T>;
77
411
 
78
412
  export { }