@fluidframework/fluid-static 2.0.0-internal.7.3.0 → 2.0.0-internal.7.4.1
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.
- package/CHANGELOG.md +16 -0
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +3 -3
- package/api-report/fluid-static.api.md +45 -22
- package/dist/fluid-static-alpha.d.ts +417 -0
- package/dist/fluid-static-beta.d.ts +99 -0
- package/dist/fluid-static-public.d.ts +99 -0
- package/dist/fluid-static-untrimmed.d.ts +619 -0
- package/dist/fluidContainer.cjs +10 -3
- package/dist/fluidContainer.cjs.map +1 -1
- package/dist/fluidContainer.d.ts +12 -2
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/rootDataObject.cjs +13 -2
- package/dist/rootDataObject.cjs.map +1 -1
- package/dist/rootDataObject.d.ts +9 -36
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/serviceAudience.cjs +16 -1
- package/dist/serviceAudience.cjs.map +1 -1
- package/dist/serviceAudience.d.ts +9 -0
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +21 -1
- package/dist/types.d.ts.map +1 -1
- package/lib/fluid-static-alpha.d.ts +417 -0
- package/lib/fluid-static-beta.d.ts +99 -0
- package/lib/fluid-static-public.d.ts +99 -0
- package/lib/fluid-static-untrimmed.d.ts +619 -0
- package/lib/fluidContainer.d.ts +13 -7
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.mjs +8 -2
- package/lib/fluidContainer.mjs.map +1 -1
- package/lib/index.d.ts +4 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.mjs +3 -3
- package/lib/index.mjs.map +1 -1
- package/lib/rootDataObject.d.ts +9 -40
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.mjs +12 -1
- package/lib/rootDataObject.mjs.map +1 -1
- package/lib/serviceAudience.d.ts +10 -1
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.mjs +14 -0
- package/lib/serviceAudience.mjs.map +1 -1
- package/lib/types.d.ts +21 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.mjs.map +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/package.json +38 -31
- package/src/fluidContainer.ts +17 -2
- package/src/index.ts +7 -2
- package/src/rootDataObject.ts +16 -1
- package/src/serviceAudience.ts +18 -0
- package/src/types.ts +22 -1
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides a simple and powerful way to consume collaborative Fluid data.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { AttachState } from '@fluidframework/container-definitions';
|
|
8
|
+
import { BaseContainerRuntimeFactory } from '@fluidframework/aqueduct';
|
|
9
|
+
import { ConnectionState } from '@fluidframework/container-definitions';
|
|
10
|
+
import { IAudience } from '@fluidframework/container-definitions';
|
|
11
|
+
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
12
|
+
import { IClient } from '@fluidframework/protocol-definitions';
|
|
13
|
+
import { IContainer } from '@fluidframework/container-definitions';
|
|
14
|
+
import { IContainerRuntime } from '@fluidframework/container-runtime-definitions';
|
|
15
|
+
import { ICriticalContainerError } from '@fluidframework/container-definitions';
|
|
16
|
+
import { IEvent } from '@fluidframework/core-interfaces';
|
|
17
|
+
import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
18
|
+
import { IFluidDataStoreFactory } from '@fluidframework/runtime-definitions';
|
|
19
|
+
import { IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
20
|
+
import { IRuntimeFactory } from '@fluidframework/container-definitions';
|
|
21
|
+
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
*
|
|
28
|
+
* It includes both the instances of objects that are initially available upon `Container` creation, as well
|
|
29
|
+
* as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
|
|
30
|
+
* @alpha
|
|
31
|
+
*/
|
|
32
|
+
export declare interface ContainerSchema {
|
|
33
|
+
/**
|
|
34
|
+
* Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.
|
|
35
|
+
*
|
|
36
|
+
* @remarks It uses the key as the id and the value as the loadable object to create.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
*
|
|
40
|
+
* In the example below two objects will be created when the `Container` is first
|
|
41
|
+
* created. One with id "map1" that will return a `SharedMap` and the other with
|
|
42
|
+
* id "pair1" that will return a `KeyValueDataObject`.
|
|
43
|
+
*
|
|
44
|
+
* ```typescript
|
|
45
|
+
* {
|
|
46
|
+
* map1: SharedMap,
|
|
47
|
+
* pair1: KeyValueDataObject,
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
initialObjects: LoadableObjectClassRecord;
|
|
52
|
+
/**
|
|
53
|
+
* Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
*
|
|
57
|
+
* Types defined in `initialObjects` will always be available and are not required to be provided here.
|
|
58
|
+
*
|
|
59
|
+
* For best practice it's recommended to define all the dynamic types you create even if they are
|
|
60
|
+
* included via initialObjects.
|
|
61
|
+
*/
|
|
62
|
+
dynamicObjectTypes?: LoadableObjectClass<any>[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export declare function createDOProviderContainerRuntimeFactory(props: {
|
|
69
|
+
schema: ContainerSchema;
|
|
70
|
+
}): IRuntimeFactory;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export declare function createFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>(props: {
|
|
76
|
+
container: IContainer;
|
|
77
|
+
rootDataObject: IRootDataObject;
|
|
78
|
+
}): IFluidContainer<TContainerSchema>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
export declare function createServiceAudience<M extends IMember = IMember>(props: {
|
|
84
|
+
container: IContainer;
|
|
85
|
+
createServiceMember: (audienceMember: IClient) => M;
|
|
86
|
+
}): IServiceAudience<M>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A class that has a factory that can create a `DataObject` and a
|
|
90
|
+
* constructor that will return the type of the `DataObject`.
|
|
91
|
+
*
|
|
92
|
+
* @typeParam T - The class of the `DataObject`.
|
|
93
|
+
* @alpha
|
|
94
|
+
*/
|
|
95
|
+
export declare type DataObjectClass<T extends IFluidLoadable> = {
|
|
96
|
+
readonly factory: IFluidDataStoreFactory;
|
|
97
|
+
} & LoadableObjectCtor<T>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Container code that provides a single {@link IRootDataObject}.
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
*
|
|
104
|
+
* This data object is dynamically customized (registry and initial objects) based on the schema provided.
|
|
105
|
+
* to the container runtime factory.
|
|
106
|
+
* @deprecated use {@link createDOProviderContainerRuntimeFactory} instead
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export declare class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
110
|
+
private readonly rootDataObjectFactory;
|
|
111
|
+
private readonly initialObjects;
|
|
112
|
+
constructor(schema: ContainerSchema);
|
|
113
|
+
/**
|
|
114
|
+
* {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}
|
|
115
|
+
*/
|
|
116
|
+
protected containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Base {@link IFluidContainer} implementation.
|
|
121
|
+
*
|
|
122
|
+
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
123
|
+
* @remarks
|
|
124
|
+
*
|
|
125
|
+
* Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
|
|
126
|
+
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
127
|
+
* @deprecated use {@link createFluidContainer} and {@link IFluidContainer} instead
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
export declare class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer<TContainerSchema> {
|
|
131
|
+
private readonly container;
|
|
132
|
+
private readonly rootDataObject;
|
|
133
|
+
private readonly connectedHandler;
|
|
134
|
+
private readonly disconnectedHandler;
|
|
135
|
+
private readonly disposedHandler;
|
|
136
|
+
private readonly savedHandler;
|
|
137
|
+
private readonly dirtyHandler;
|
|
138
|
+
constructor(container: IContainer, rootDataObject: IRootDataObject);
|
|
139
|
+
/**
|
|
140
|
+
* {@inheritDoc IFluidContainer.isDirty}
|
|
141
|
+
*/
|
|
142
|
+
get isDirty(): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* {@inheritDoc IFluidContainer.attachState}
|
|
145
|
+
*/
|
|
146
|
+
get attachState(): AttachState;
|
|
147
|
+
/**
|
|
148
|
+
* {@inheritDoc IFluidContainer.disposed}
|
|
149
|
+
*/
|
|
150
|
+
get disposed(): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* {@inheritDoc IFluidContainer.connectionState}
|
|
153
|
+
*/
|
|
154
|
+
get connectionState(): ConnectionState;
|
|
155
|
+
/**
|
|
156
|
+
* {@inheritDoc IFluidContainer.initialObjects}
|
|
157
|
+
*/
|
|
158
|
+
get initialObjects(): InitialObjects<TContainerSchema>;
|
|
159
|
+
/**
|
|
160
|
+
* Incomplete base implementation of {@link IFluidContainer.attach}.
|
|
161
|
+
*
|
|
162
|
+
* @remarks
|
|
163
|
+
*
|
|
164
|
+
* Note: this implementation will unconditionally throw.
|
|
165
|
+
* Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
|
|
166
|
+
* that provides an implementation of this method.
|
|
167
|
+
*
|
|
168
|
+
* The reason is because externally we are presenting a separation between the service and the `FluidContainer`,
|
|
169
|
+
* but internally this separation is not there.
|
|
170
|
+
*/
|
|
171
|
+
attach(): Promise<string>;
|
|
172
|
+
/**
|
|
173
|
+
* {@inheritDoc IFluidContainer.connect}
|
|
174
|
+
*/
|
|
175
|
+
connect(): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* {@inheritDoc IFluidContainer.connect}
|
|
178
|
+
*/
|
|
179
|
+
disconnect(): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* {@inheritDoc IFluidContainer.create}
|
|
182
|
+
*/
|
|
183
|
+
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
|
|
184
|
+
/**
|
|
185
|
+
* {@inheritDoc IFluidContainer.dispose}
|
|
186
|
+
*/
|
|
187
|
+
dispose(): void;
|
|
188
|
+
/**
|
|
189
|
+
* FOR INTERNAL USE ONLY. NOT FOR EXTERNAL USE.
|
|
190
|
+
* We make no stability guarantees here whatsoever.
|
|
191
|
+
*
|
|
192
|
+
* Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
193
|
+
*
|
|
194
|
+
* @remarks Used to power debug tooling.
|
|
195
|
+
*/
|
|
196
|
+
readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Base interface for information for each connection made to the Fluid session.
|
|
201
|
+
*
|
|
202
|
+
* @remarks This interface can be extended to provide additional information specific to each service.
|
|
203
|
+
* @alpha
|
|
204
|
+
*/
|
|
205
|
+
export declare interface IConnection {
|
|
206
|
+
/**
|
|
207
|
+
* A unique ID for the connection. A single user may have multiple connections, each with a different ID.
|
|
208
|
+
*/
|
|
209
|
+
id: string;
|
|
210
|
+
/**
|
|
211
|
+
* Whether the connection is in read or read/write mode.
|
|
212
|
+
*/
|
|
213
|
+
mode: "write" | "read";
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Provides an entrypoint into the client side of collaborative Fluid data.
|
|
218
|
+
* Provides access to the data as well as status on the collaboration session.
|
|
219
|
+
*
|
|
220
|
+
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
221
|
+
*
|
|
222
|
+
* @remarks Note: external implementations of this interface are not supported.
|
|
223
|
+
* @alpha
|
|
224
|
+
*/
|
|
225
|
+
export declare interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends IEventProvider<IFluidContainerEvents> {
|
|
226
|
+
/**
|
|
227
|
+
* Provides the current connected state of the container
|
|
228
|
+
*/
|
|
229
|
+
readonly connectionState: ConnectionState;
|
|
230
|
+
/**
|
|
231
|
+
* A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
|
|
232
|
+
*
|
|
233
|
+
* @remarks
|
|
234
|
+
*
|
|
235
|
+
* You should always check the `isDirty` flag before closing the container or navigating away from the page.
|
|
236
|
+
* Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
|
|
237
|
+
* acknowledged by the service.
|
|
238
|
+
*
|
|
239
|
+
* A container is considered dirty in the following cases:
|
|
240
|
+
*
|
|
241
|
+
* 1. The container has been created in the detached state, and either it has not been attached yet or it is
|
|
242
|
+
* in the process of being attached (container is in `attaching` state). If container is closed prior to being
|
|
243
|
+
* attached, host may never know if the file was created or not.
|
|
244
|
+
*
|
|
245
|
+
* 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.
|
|
246
|
+
* This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the
|
|
247
|
+
* service. In some cases this can be due to lack of network connection. If the network connection is down,
|
|
248
|
+
* it needs to be restored for the pending changes to be acknowledged.
|
|
249
|
+
*/
|
|
250
|
+
readonly isDirty: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Whether or not the container is disposed, which permanently disables it.
|
|
253
|
+
*/
|
|
254
|
+
readonly disposed: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
|
|
257
|
+
*
|
|
258
|
+
* @remarks These data objects and DDSes exist for the lifetime of the container.
|
|
259
|
+
*/
|
|
260
|
+
readonly initialObjects: InitialObjects<TContainerSchema>;
|
|
261
|
+
/**
|
|
262
|
+
* The current attachment state of the container.
|
|
263
|
+
*
|
|
264
|
+
* @remarks
|
|
265
|
+
*
|
|
266
|
+
* Once a container has been attached, it remains attached.
|
|
267
|
+
* When loading an existing container, it will already be attached.
|
|
268
|
+
*/
|
|
269
|
+
readonly attachState: AttachState;
|
|
270
|
+
/**
|
|
271
|
+
* A newly created container starts detached from the collaborative service.
|
|
272
|
+
* Calling `attach()` uploads the new container to the service and connects to the collaborative service.
|
|
273
|
+
*
|
|
274
|
+
* @remarks
|
|
275
|
+
*
|
|
276
|
+
* This should only be called when the container is in the
|
|
277
|
+
* {@link @fluidframework/container-definitions#AttachState.Detatched} state.
|
|
278
|
+
*
|
|
279
|
+
* This can be determined by observing {@link IFluidContainer.attachState}.
|
|
280
|
+
*
|
|
281
|
+
* @returns A promise which resolves when the attach is complete, with the string identifier of the container.
|
|
282
|
+
*/
|
|
283
|
+
attach(): Promise<string>;
|
|
284
|
+
/**
|
|
285
|
+
* Attempts to connect the container to the delta stream and process operations.
|
|
286
|
+
*
|
|
287
|
+
* @throws Will throw an error if connection is unsuccessful.
|
|
288
|
+
*
|
|
289
|
+
* @remarks
|
|
290
|
+
*
|
|
291
|
+
* This should only be called when the container is in the
|
|
292
|
+
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
293
|
+
*
|
|
294
|
+
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
295
|
+
*/
|
|
296
|
+
connect(): void;
|
|
297
|
+
/**
|
|
298
|
+
* Disconnects the container from the delta stream and stops processing operations.
|
|
299
|
+
*
|
|
300
|
+
* @remarks
|
|
301
|
+
*
|
|
302
|
+
* This should only be called when the container is in the
|
|
303
|
+
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
304
|
+
*
|
|
305
|
+
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
306
|
+
*/
|
|
307
|
+
disconnect(): void;
|
|
308
|
+
/**
|
|
309
|
+
* Create a new data object or Distributed Data Store (DDS) of the specified type.
|
|
310
|
+
*
|
|
311
|
+
* @remarks
|
|
312
|
+
*
|
|
313
|
+
* In order to share the data object or DDS with other
|
|
314
|
+
* collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
|
|
315
|
+
* initialObjects.
|
|
316
|
+
*
|
|
317
|
+
* @param objectClass - The class of the `DataObject` or `SharedObject` to create.
|
|
318
|
+
*
|
|
319
|
+
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
320
|
+
*/
|
|
321
|
+
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
|
|
322
|
+
/**
|
|
323
|
+
* Dispose of the container instance, permanently disabling it.
|
|
324
|
+
*/
|
|
325
|
+
dispose(): void;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Events emitted from {@link IFluidContainer}.
|
|
330
|
+
* @alpha
|
|
331
|
+
*/
|
|
332
|
+
export declare interface IFluidContainerEvents extends IEvent {
|
|
333
|
+
/**
|
|
334
|
+
* Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.
|
|
335
|
+
*
|
|
336
|
+
* @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
|
|
337
|
+
*
|
|
338
|
+
* @see
|
|
339
|
+
*
|
|
340
|
+
* - {@link IFluidContainer.connectionState}
|
|
341
|
+
*
|
|
342
|
+
* - {@link IFluidContainer.connect}
|
|
343
|
+
*/
|
|
344
|
+
(event: "connected", listener: () => void): void;
|
|
345
|
+
/**
|
|
346
|
+
* Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.
|
|
347
|
+
*
|
|
348
|
+
* @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
|
|
349
|
+
*
|
|
350
|
+
* @see
|
|
351
|
+
*
|
|
352
|
+
* - {@link IFluidContainer.connectionState}
|
|
353
|
+
*
|
|
354
|
+
* - {@link IFluidContainer.disconnect}
|
|
355
|
+
*/
|
|
356
|
+
(event: "disconnected", listener: () => void): void;
|
|
357
|
+
/**
|
|
358
|
+
* Emitted when all local changes/edits have been acknowledged by the service.
|
|
359
|
+
*
|
|
360
|
+
* @remarks "dirty" event will be emitted when the next local change has been made.
|
|
361
|
+
*
|
|
362
|
+
* @see {@link IFluidContainer.isDirty}
|
|
363
|
+
*/
|
|
364
|
+
(event: "saved", listener: () => void): void;
|
|
365
|
+
/**
|
|
366
|
+
* Emitted when the first local change has been made, following a "saved" event.
|
|
367
|
+
*
|
|
368
|
+
* @remarks "saved" event will be emitted once all local changes have been acknowledged by the service.
|
|
369
|
+
*
|
|
370
|
+
* @see {@link IFluidContainer.isDirty}
|
|
371
|
+
*/
|
|
372
|
+
(event: "dirty", listener: () => void): void;
|
|
373
|
+
/**
|
|
374
|
+
* Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
|
|
375
|
+
*
|
|
376
|
+
* @remarks Listener parameters:
|
|
377
|
+
*
|
|
378
|
+
* - `error`: If the container was closed due to error (as opposed to an explicit call to
|
|
379
|
+
* {@link IFluidContainer.dispose}), this will contain details about the error that caused it.
|
|
380
|
+
*/
|
|
381
|
+
(event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Base interface to be implemented to fetch each service's member.
|
|
386
|
+
*
|
|
387
|
+
* @remarks This interface can be extended by each service to provide additional service-specific user metadata.
|
|
388
|
+
* @alpha
|
|
389
|
+
*/
|
|
390
|
+
export declare interface IMember {
|
|
391
|
+
/**
|
|
392
|
+
* An ID for the user, unique among each individual user connecting to the session.
|
|
393
|
+
*/
|
|
394
|
+
userId: string;
|
|
395
|
+
/**
|
|
396
|
+
* The set of connections the user has made, e.g. from multiple tabs or devices.
|
|
397
|
+
*/
|
|
398
|
+
connections: IConnection[];
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
403
|
+
* @alpha
|
|
404
|
+
*/
|
|
405
|
+
export declare type InitialObjects<T extends ContainerSchema> = {
|
|
406
|
+
[K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<infer TChannel> ? TChannel : never;
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* @internal
|
|
411
|
+
*/
|
|
412
|
+
export declare interface IProvideRootDataObject {
|
|
413
|
+
readonly IRootDataObject?: IRootDataObject;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Holds the collection of objects that the container was initially created with, as well as provides the ability
|
|
418
|
+
* to dynamically create further objects during usage.
|
|
419
|
+
* @internal
|
|
420
|
+
*/
|
|
421
|
+
export declare interface IRootDataObject extends IProvideRootDataObject {
|
|
422
|
+
/**
|
|
423
|
+
* Provides a record of the initial objects defined on creation.
|
|
424
|
+
*/
|
|
425
|
+
readonly initialObjects: LoadableObjectRecord;
|
|
426
|
+
/**
|
|
427
|
+
* Dynamically creates a new detached collaborative object (DDS/DataObject).
|
|
428
|
+
*
|
|
429
|
+
* @param objectClass - Type of the collaborative object to be created.
|
|
430
|
+
*
|
|
431
|
+
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
432
|
+
*/
|
|
433
|
+
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Base interface to be implemented to fetch each service's audience.
|
|
438
|
+
*
|
|
439
|
+
* @remarks
|
|
440
|
+
*
|
|
441
|
+
* The type parameter `M` allows consumers to further extend the client object with service-specific
|
|
442
|
+
* details about the connecting client, such as device information, environment, or a username.
|
|
443
|
+
*
|
|
444
|
+
* @typeParam M - A service-specific {@link IMember} type.
|
|
445
|
+
* @alpha
|
|
446
|
+
*/
|
|
447
|
+
export declare interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
|
|
448
|
+
/**
|
|
449
|
+
* Returns an map of all users currently in the Fluid session where key is the userId and the value is the
|
|
450
|
+
* member object. The implementation may choose to exclude certain connections from the returned map.
|
|
451
|
+
* E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.
|
|
452
|
+
*/
|
|
453
|
+
getMembers(): Map<string, M>;
|
|
454
|
+
/**
|
|
455
|
+
* Returns the current active user on this client once they are connected. Otherwise, returns undefined.
|
|
456
|
+
*/
|
|
457
|
+
getMyself(): Myself<M> | undefined;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Events that trigger when the roster of members in the Fluid session change.
|
|
462
|
+
*
|
|
463
|
+
* @remarks
|
|
464
|
+
*
|
|
465
|
+
* Only changes that would be reflected in the returned map of {@link IServiceAudience}'s
|
|
466
|
+
* {@link IServiceAudience.getMembers} method will emit events.
|
|
467
|
+
*
|
|
468
|
+
* @typeParam M - A service-specific {@link IMember} implementation.
|
|
469
|
+
* @alpha
|
|
470
|
+
*/
|
|
471
|
+
export declare interface IServiceAudienceEvents<M extends IMember> extends IEvent {
|
|
472
|
+
/**
|
|
473
|
+
* Emitted when a {@link IMember | member}(s) are either added or removed.
|
|
474
|
+
*
|
|
475
|
+
* @eventProperty
|
|
476
|
+
*/
|
|
477
|
+
(event: "membersChanged", listener: () => void): void;
|
|
478
|
+
/**
|
|
479
|
+
* Emitted when a {@link IMember | member} joins the audience.
|
|
480
|
+
*
|
|
481
|
+
* @eventProperty
|
|
482
|
+
*/
|
|
483
|
+
(event: "memberAdded", listener: MemberChangedListener<M>): void;
|
|
484
|
+
/**
|
|
485
|
+
* Emitted when a {@link IMember | member} leaves the audience.
|
|
486
|
+
*
|
|
487
|
+
* @eventProperty
|
|
488
|
+
*/
|
|
489
|
+
(event: "memberRemoved", listener: MemberChangedListener<M>): void;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* A class object of `DataObject` or `SharedObject`.
|
|
494
|
+
*
|
|
495
|
+
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
496
|
+
* @alpha
|
|
497
|
+
*/
|
|
498
|
+
export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
502
|
+
* or `SharedObject` in a {@link LoadableObjectRecord}.
|
|
503
|
+
* @alpha
|
|
504
|
+
*/
|
|
505
|
+
export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
|
|
509
|
+
*
|
|
510
|
+
* @typeParam T - The class of the loadable object.
|
|
511
|
+
* @alpha
|
|
512
|
+
*/
|
|
513
|
+
export declare type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
|
|
517
|
+
* @alpha
|
|
518
|
+
*/
|
|
519
|
+
export declare type LoadableObjectRecord = Record<string, IFluidLoadable>;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Signature for {@link IMember} change events.
|
|
523
|
+
*
|
|
524
|
+
* @param clientId - A unique identifier for the client.
|
|
525
|
+
* @param member - The service-specific member object for the client.
|
|
526
|
+
*
|
|
527
|
+
* @see See {@link IServiceAudienceEvents} for usage details.
|
|
528
|
+
* @alpha
|
|
529
|
+
*/
|
|
530
|
+
export declare type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* An extended member object that includes currentConnection
|
|
534
|
+
* @alpha
|
|
535
|
+
*/
|
|
536
|
+
export declare type Myself<M extends IMember = IMember> = M & {
|
|
537
|
+
currentConnection: string;
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Base class for providing audience information for sessions interacting with {@link IFluidContainer}
|
|
542
|
+
*
|
|
543
|
+
* @remarks
|
|
544
|
+
*
|
|
545
|
+
* This can be extended by different service-specific client packages to additional parameters to
|
|
546
|
+
* the user and client details returned in {@link IMember}.
|
|
547
|
+
*
|
|
548
|
+
* @typeParam M - A service-specific {@link IMember} implementation.
|
|
549
|
+
* @deprecated use {@link createServiceAudience} and {@link IServiceAudience} instead
|
|
550
|
+
* @internal
|
|
551
|
+
*/
|
|
552
|
+
export declare abstract class ServiceAudience<M extends IMember = IMember> extends TypedEventEmitter<IServiceAudienceEvents<M>> implements IServiceAudience<M> {
|
|
553
|
+
/**
|
|
554
|
+
* Fluid Container to read the audience from.
|
|
555
|
+
*/
|
|
556
|
+
protected readonly container: IContainer;
|
|
557
|
+
/**
|
|
558
|
+
* Audience object which includes all the existing members of the {@link IFluidContainer | container}.
|
|
559
|
+
*/
|
|
560
|
+
protected readonly audience: IAudience;
|
|
561
|
+
/**
|
|
562
|
+
* Retain the most recent member list.
|
|
563
|
+
*
|
|
564
|
+
* @remarks
|
|
565
|
+
*
|
|
566
|
+
* This is so we have more information about a member leaving the audience in the `removeMember` event.
|
|
567
|
+
*
|
|
568
|
+
* It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this
|
|
569
|
+
* class exposes (and would actually produce a change in what `getMembers` returns).
|
|
570
|
+
*
|
|
571
|
+
* It also allows us to provide the client details in the event which makes it easier to find that client connection
|
|
572
|
+
* in a map keyed on the `userId` and not `clientId`.
|
|
573
|
+
*
|
|
574
|
+
* This map will always be up-to-date in a `removeMember` event because it is set once at construction and in
|
|
575
|
+
* every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}
|
|
576
|
+
* events provide.
|
|
577
|
+
*/
|
|
578
|
+
protected lastMembers: Map<string, M>;
|
|
579
|
+
constructor(
|
|
580
|
+
/**
|
|
581
|
+
* Fluid Container to read the audience from.
|
|
582
|
+
*/
|
|
583
|
+
container: IContainer);
|
|
584
|
+
/**
|
|
585
|
+
* Provides ability for inheriting class to modify/extend the audience object.
|
|
586
|
+
*
|
|
587
|
+
* @param audienceMember - Record of a specific audience member.
|
|
588
|
+
*/
|
|
589
|
+
protected abstract createServiceMember(audienceMember: IClient): M;
|
|
590
|
+
/**
|
|
591
|
+
* {@inheritDoc IServiceAudience.getMembers}
|
|
592
|
+
*/
|
|
593
|
+
getMembers(): Map<string, M>;
|
|
594
|
+
/**
|
|
595
|
+
* {@inheritDoc IServiceAudience.getMyself}
|
|
596
|
+
*/
|
|
597
|
+
getMyself(): Myself<M> | undefined;
|
|
598
|
+
private getMember;
|
|
599
|
+
/**
|
|
600
|
+
* Provides ability for the inheriting class to include/omit specific members.
|
|
601
|
+
* An example use case is omitting the summarizer client.
|
|
602
|
+
*
|
|
603
|
+
* @param member - Member to be included/omitted.
|
|
604
|
+
*/
|
|
605
|
+
protected shouldIncludeAsMember(member: IClient): boolean;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* A class that has a factory that can create a DDSes (`SharedObject`s) and a
|
|
610
|
+
* constructor that will return the type of the `DataObject`.
|
|
611
|
+
*
|
|
612
|
+
* @typeParam T - The class of the `SharedObject`.
|
|
613
|
+
* @alpha
|
|
614
|
+
*/
|
|
615
|
+
export declare type SharedObjectClass<T extends IFluidLoadable> = {
|
|
616
|
+
readonly getFactory: () => IChannelFactory;
|
|
617
|
+
} & LoadableObjectCtor<T>;
|
|
618
|
+
|
|
619
|
+
export { }
|
package/lib/fluidContainer.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
1
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
2
|
import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
3
|
import { AttachState, IContainer, ICriticalContainerError, ConnectionState } from "@fluidframework/container-definitions";
|
|
8
|
-
import type { ContainerSchema, IRootDataObject, LoadableObjectClass } from "./types";
|
|
4
|
+
import type { ContainerSchema, IRootDataObject, LoadableObjectClass } from "./types.mjs";
|
|
9
5
|
/**
|
|
10
6
|
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
7
|
+
* @alpha
|
|
11
8
|
*/
|
|
12
9
|
export type InitialObjects<T extends ContainerSchema> = {
|
|
13
10
|
[K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<infer TChannel> ? TChannel : never;
|
|
14
11
|
};
|
|
15
12
|
/**
|
|
16
13
|
* Events emitted from {@link IFluidContainer}.
|
|
14
|
+
* @alpha
|
|
17
15
|
*/
|
|
18
16
|
export interface IFluidContainerEvents extends IEvent {
|
|
19
17
|
/**
|
|
@@ -73,6 +71,7 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
73
71
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
74
72
|
*
|
|
75
73
|
* @remarks Note: external implementations of this interface are not supported.
|
|
74
|
+
* @alpha
|
|
76
75
|
*/
|
|
77
76
|
export interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends IEventProvider<IFluidContainerEvents> {
|
|
78
77
|
/**
|
|
@@ -176,6 +175,13 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
176
175
|
*/
|
|
177
176
|
dispose(): void;
|
|
178
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
181
|
+
export declare function createFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>(props: {
|
|
182
|
+
container: IContainer;
|
|
183
|
+
rootDataObject: IRootDataObject;
|
|
184
|
+
}): IFluidContainer<TContainerSchema>;
|
|
179
185
|
/**
|
|
180
186
|
* Base {@link IFluidContainer} implementation.
|
|
181
187
|
*
|
|
@@ -184,6 +190,8 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
184
190
|
*
|
|
185
191
|
* Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
|
|
186
192
|
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
193
|
+
* @deprecated use {@link createFluidContainer} and {@link IFluidContainer} instead
|
|
194
|
+
* @internal
|
|
187
195
|
*/
|
|
188
196
|
export declare class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer<TContainerSchema> {
|
|
189
197
|
private readonly container;
|
|
@@ -250,8 +258,6 @@ export declare class FluidContainer<TContainerSchema extends ContainerSchema = C
|
|
|
250
258
|
* Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
251
259
|
*
|
|
252
260
|
* @remarks Used to power debug tooling.
|
|
253
|
-
*
|
|
254
|
-
* @internal
|
|
255
261
|
*/
|
|
256
262
|
readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer;
|
|
257
263
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"OAIO,EAAE,iBAAiB,EAAE,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