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