@fluidframework/fluid-static 2.0.0-internal.1.4.1 → 2.0.0-internal.2.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.
- package/dist/fluidContainer.d.ts +51 -14
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +13 -4
- package/dist/fluidContainer.js.map +1 -1
- package/dist/rootDataObject.d.ts +18 -10
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +15 -8
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +25 -13
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js +23 -12
- package/dist/serviceAudience.js.map +1 -1
- package/dist/types.d.ts +75 -69
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/fluidContainer.d.ts +51 -14
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +13 -4
- package/lib/fluidContainer.js.map +1 -1
- package/lib/rootDataObject.d.ts +18 -10
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +15 -8
- package/lib/rootDataObject.js.map +1 -1
- package/lib/serviceAudience.d.ts +25 -13
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.js +23 -12
- package/lib/serviceAudience.js.map +1 -1
- package/lib/types.d.ts +75 -69
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +36 -17
- package/src/fluidContainer.ts +64 -18
- package/src/rootDataObject.ts +18 -10
- package/src/serviceAudience.ts +25 -13
- package/src/types.ts +80 -69
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions\";\n\n/**\n * A mapping of string identifiers to instantiated
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject` in a {@link LoadableObjectRecord}.\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n */\nexport type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;\n\n/**\n * A class that has a factory that can create a `DataObject` and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `DataObject`.\n */\nexport type DataObjectClass<T extends IFluidLoadable>\n = { readonly factory: IFluidDataStoreFactory; } & LoadableObjectCtor<T>;\n\n/**\n * A class that has a factory that can create a DDSes (`SharedObject`s) and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `SharedObject`.\n */\nexport type SharedObjectClass<T extends IFluidLoadable>\n = { readonly getFactory: () => IChannelFactory; } & LoadableObjectCtor<T>;\n\n/**\n * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.\n *\n * @typeParam T - The class of the loadable object.\n */\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new(...args: any[]) => T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n */\nexport interface ContainerSchema {\n /**\n * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n *\n * @remarks It uses the key as the id and the value as the loadable object to create.\n *\n * @example\n *\n * In the example below two objects will be created when the `Container` is first\n * created. One with id \"map1\" that will return a `SharedMap` and the other with\n * id \"pair1\" that will return a `KeyValueDataObject`.\n *\n * ```typescript\n * {\n * map1: SharedMap,\n * pair1: KeyValueDataObject,\n * }\n * ```\n */\n initialObjects: LoadableObjectClassRecord;\n\n /**\n * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n *\n * @remarks\n *\n * Types defined in `initialObjects` will always be available and are not required to be provided here.\n *\n * For best practice it's recommended to define all the dynamic types you create even if they are\n * included via initialObjects.\n */\n dynamicObjectTypes?: LoadableObjectClass<any>[];\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n /* eslint-disable @typescript-eslint/unified-signatures */\n /**\n * Emitted when a {@link IMember | member}(s) are either added or removed.\n *\n * @eventProperty\n */\n (event: \"membersChanged\", listener: () => void): void;\n\n /**\n * Emitted when a {@link IMember | member} joins the audience.\n *\n * @eventProperty\n */\n (event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n /**\n * Emitted when a {@link IMember | member} leaves the audience.\n *\n * @eventProperty\n */\n (event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n /* eslint-enable @typescript-eslint/unified-signatures */\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n */\nexport interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {\n /**\n * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n * member object. The implementation may choose to exclude certain connections from the returned map.\n * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n */\n getMembers(): Map<string, M>;\n\n /**\n * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n */\n getMyself(): M | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n */\nexport interface IConnection {\n /**\n * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n */\n id: string;\n\n /**\n * Whether the connection is in read or read/write mode.\n */\n mode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n */\nexport interface IMember {\n /**\n * An ID for the user, unique among each individual user connecting to the session.\n */\n userId: string;\n\n /**\n * The set of connections the user has made, e.g. from multiple tabs or devices.\n */\n connections: IConnection[];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.0.0-internal.
|
|
3
|
+
"version": "2.0.0-internal.2.0.0",
|
|
4
4
|
"description": "A tool to enable consumption of Fluid Data Objects without requiring custom container code.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -38,29 +38,48 @@
|
|
|
38
38
|
"tsfmt:fix": "tsfmt --replace",
|
|
39
39
|
"typetests:gen": "fluid-type-validator -g -d ."
|
|
40
40
|
},
|
|
41
|
+
"nyc": {
|
|
42
|
+
"all": true,
|
|
43
|
+
"cache-dir": "nyc/.cache",
|
|
44
|
+
"exclude": [
|
|
45
|
+
"src/test/**/*.ts",
|
|
46
|
+
"dist/test/**/*.js"
|
|
47
|
+
],
|
|
48
|
+
"exclude-after-remap": false,
|
|
49
|
+
"include": [
|
|
50
|
+
"src/**/*.ts",
|
|
51
|
+
"dist/**/*.js"
|
|
52
|
+
],
|
|
53
|
+
"report-dir": "nyc/report",
|
|
54
|
+
"reporter": [
|
|
55
|
+
"cobertura",
|
|
56
|
+
"html",
|
|
57
|
+
"text"
|
|
58
|
+
],
|
|
59
|
+
"temp-directory": "nyc/.nyc_output"
|
|
60
|
+
},
|
|
41
61
|
"dependencies": {
|
|
42
|
-
"@fluidframework/aqueduct": "^2.0.0-internal.
|
|
62
|
+
"@fluidframework/aqueduct": "^2.0.0-internal.2.0.0",
|
|
43
63
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
44
64
|
"@fluidframework/common-utils": "^1.0.0",
|
|
45
|
-
"@fluidframework/container-definitions": "^2.0.0-internal.
|
|
46
|
-
"@fluidframework/container-loader": "^2.0.0-internal.
|
|
47
|
-
"@fluidframework/container-runtime-definitions": "^2.0.0-internal.
|
|
48
|
-
"@fluidframework/core-interfaces": "^2.0.0-internal.
|
|
49
|
-
"@fluidframework/datastore-definitions": "^2.0.0-internal.
|
|
50
|
-
"@fluidframework/protocol-definitions": "^1.
|
|
51
|
-
"@fluidframework/request-handler": "^2.0.0-internal.
|
|
52
|
-
"@fluidframework/runtime-definitions": "^2.0.0-internal.
|
|
53
|
-
"@fluidframework/runtime-utils": "^2.0.0-internal.
|
|
65
|
+
"@fluidframework/container-definitions": "^2.0.0-internal.2.0.0",
|
|
66
|
+
"@fluidframework/container-loader": "^2.0.0-internal.2.0.0",
|
|
67
|
+
"@fluidframework/container-runtime-definitions": "^2.0.0-internal.2.0.0",
|
|
68
|
+
"@fluidframework/core-interfaces": "^2.0.0-internal.2.0.0",
|
|
69
|
+
"@fluidframework/datastore-definitions": "^2.0.0-internal.2.0.0",
|
|
70
|
+
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
71
|
+
"@fluidframework/request-handler": "^2.0.0-internal.2.0.0",
|
|
72
|
+
"@fluidframework/runtime-definitions": "^2.0.0-internal.2.0.0",
|
|
73
|
+
"@fluidframework/runtime-utils": "^2.0.0-internal.2.0.0"
|
|
54
74
|
},
|
|
55
75
|
"devDependencies": {
|
|
56
|
-
"@fluid-experimental/get-container": "^2.0.0-internal.1.4.1",
|
|
57
76
|
"@fluidframework/build-common": "^1.0.0",
|
|
58
|
-
"@fluidframework/build-tools": "^0.4.
|
|
77
|
+
"@fluidframework/build-tools": "^0.4.6000",
|
|
59
78
|
"@fluidframework/eslint-config-fluid": "^1.0.0",
|
|
60
|
-
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static
|
|
61
|
-
"@fluidframework/map": "^2.0.0-internal.
|
|
62
|
-
"@fluidframework/mocha-test-setup": "^2.0.0-internal.
|
|
63
|
-
"@fluidframework/sequence": "^2.0.0-internal.
|
|
79
|
+
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@>=2.0.0-internal.1.4.0 <2.0.0-internal.2.0.0",
|
|
80
|
+
"@fluidframework/map": "^2.0.0-internal.2.0.0",
|
|
81
|
+
"@fluidframework/mocha-test-setup": "^2.0.0-internal.2.0.0",
|
|
82
|
+
"@fluidframework/sequence": "^2.0.0-internal.2.0.0",
|
|
64
83
|
"@microsoft/api-extractor": "^7.22.2",
|
|
65
84
|
"@rushstack/eslint-config": "^2.5.1",
|
|
66
85
|
"@types/mocha": "^9.1.1",
|
package/src/fluidContainer.ts
CHANGED
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
6
6
|
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { IEvent, IEventProvider } from "@fluidframework/common-definitions";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
AttachState,
|
|
10
|
+
IContainer,
|
|
11
|
+
ICriticalContainerError,
|
|
12
|
+
ConnectionState,
|
|
13
|
+
} from "@fluidframework/container-definitions";
|
|
9
14
|
import { LoadableObjectClass, LoadableObjectRecord } from "./types";
|
|
10
15
|
import { RootDataObject } from "./rootDataObject";
|
|
11
16
|
|
|
@@ -26,9 +31,9 @@ import { RootDataObject } from "./rootDataObject";
|
|
|
26
31
|
* () => void;
|
|
27
32
|
* ```
|
|
28
33
|
*
|
|
29
|
-
* ### "
|
|
34
|
+
* ### "disposed"
|
|
30
35
|
*
|
|
31
|
-
* The "
|
|
36
|
+
* The "disposed" event is emitted when the `IFluidContainer` is disposed, which permanently disables it.
|
|
32
37
|
*
|
|
33
38
|
* #### Listener signature
|
|
34
39
|
*
|
|
@@ -68,7 +73,22 @@ import { RootDataObject } from "./rootDataObject";
|
|
|
68
73
|
* ```
|
|
69
74
|
*/
|
|
70
75
|
export interface IFluidContainerEvents extends IEvent {
|
|
71
|
-
|
|
76
|
+
/**
|
|
77
|
+
* **connected** & **disconnected** events reflect connection state changes against the (delta)
|
|
78
|
+
* service acknowledging ops/edits.
|
|
79
|
+
*/
|
|
80
|
+
(event: "connected" | "disconnected", listener: () => void): void;
|
|
81
|
+
/**
|
|
82
|
+
* **saved** event is raised when all local changes/edits have been acknowledged by the service.
|
|
83
|
+
* **dirty** event is raised when first local change has been made, following a "saved" state.
|
|
84
|
+
*/
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
|
86
|
+
(event: "saved" | "dirty", listener: () => void): void;
|
|
87
|
+
/**
|
|
88
|
+
* Disposed event is raised when container is closed. If container was closed due to error
|
|
89
|
+
* (vs explicit **dispose** action), optional argument contains further details about the error.
|
|
90
|
+
*/
|
|
91
|
+
(event: "disposed", listener: (error?: ICriticalContainerError) => void);
|
|
72
92
|
}
|
|
73
93
|
|
|
74
94
|
/**
|
|
@@ -83,6 +103,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
83
103
|
|
|
84
104
|
/**
|
|
85
105
|
* A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
*
|
|
86
109
|
* You should always check the `isDirty` flag before closing the container or navigating away from the page.
|
|
87
110
|
* Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
|
|
88
111
|
* acknowledged by the service.
|
|
@@ -101,18 +124,23 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
101
124
|
readonly isDirty: boolean;
|
|
102
125
|
|
|
103
126
|
/**
|
|
104
|
-
* Whether the container is disposed, which permanently disables it.
|
|
127
|
+
* Whether or not the container is disposed, which permanently disables it.
|
|
105
128
|
*/
|
|
106
129
|
readonly disposed: boolean;
|
|
107
130
|
|
|
108
131
|
/**
|
|
109
132
|
* The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
|
|
110
|
-
*
|
|
133
|
+
*
|
|
134
|
+
* @remarks These data objects and DDSes exist for the lifetime of the container.
|
|
111
135
|
*/
|
|
112
136
|
readonly initialObjects: LoadableObjectRecord;
|
|
113
137
|
|
|
114
138
|
/**
|
|
115
|
-
* The current attachment state of the container.
|
|
139
|
+
* The current attachment state of the container.
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
*
|
|
143
|
+
* Once a container has been attached, it remains attached.
|
|
116
144
|
* When loading an existing container, it will already be attached.
|
|
117
145
|
*/
|
|
118
146
|
readonly attachState: AttachState;
|
|
@@ -121,7 +149,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
121
149
|
* A newly created container starts detached from the collaborative service.
|
|
122
150
|
* Calling `attach()` uploads the new container to the service and connects to the collaborative service.
|
|
123
151
|
*
|
|
124
|
-
* @remarks
|
|
152
|
+
* @remarks
|
|
153
|
+
*
|
|
154
|
+
* This should only be called when the container is in the
|
|
125
155
|
* {@link @fluidframework/container-definitions#AttachState.Detatched} state.
|
|
126
156
|
*
|
|
127
157
|
* This can be determined by observing {@link IFluidContainer.attachState}.
|
|
@@ -134,7 +164,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
134
164
|
* Attempts to connect the container to the delta stream and process operations.
|
|
135
165
|
* Will throw an error if unsuccessful.
|
|
136
166
|
*
|
|
137
|
-
* @remarks
|
|
167
|
+
* @remarks
|
|
168
|
+
*
|
|
169
|
+
* This should only be called when the container is in the
|
|
138
170
|
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
139
171
|
*
|
|
140
172
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
@@ -144,7 +176,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
144
176
|
/**
|
|
145
177
|
* Disconnects the container from the delta stream and stops processing operations.
|
|
146
178
|
*
|
|
147
|
-
* @remarks
|
|
179
|
+
* @remarks
|
|
180
|
+
*
|
|
181
|
+
* This should only be called when the container is in the
|
|
148
182
|
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
149
183
|
*
|
|
150
184
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
@@ -154,11 +188,15 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
154
188
|
/**
|
|
155
189
|
* Create a new data object or Distributed Data Store (DDS) of the specified type.
|
|
156
190
|
*
|
|
157
|
-
* @remarks
|
|
191
|
+
* @remarks
|
|
192
|
+
*
|
|
193
|
+
* In order to share the data object or DDS with other
|
|
158
194
|
* collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
|
|
159
195
|
* initialObjects.
|
|
160
196
|
*
|
|
161
|
-
* @param objectClass - The class of
|
|
197
|
+
* @param objectClass - The class of the `DataObject` or `SharedObject` to create.
|
|
198
|
+
*
|
|
199
|
+
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
162
200
|
*/
|
|
163
201
|
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
|
|
164
202
|
|
|
@@ -171,13 +209,15 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
171
209
|
/**
|
|
172
210
|
* Base {@link IFluidContainer} implementation.
|
|
173
211
|
*
|
|
174
|
-
* @remarks
|
|
212
|
+
* @remarks
|
|
213
|
+
*
|
|
214
|
+
* Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
|
|
175
215
|
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
176
216
|
*/
|
|
177
217
|
export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {
|
|
178
218
|
private readonly connectedHandler = () => this.emit("connected");
|
|
179
219
|
private readonly disconnectedHandler = () => this.emit("disconnected");
|
|
180
|
-
private readonly disposedHandler = () => this.emit("disposed");
|
|
220
|
+
private readonly disposedHandler = (error?: ICriticalContainerError) => this.emit("disposed", error);
|
|
181
221
|
private readonly savedHandler = () => this.emit("saved");
|
|
182
222
|
private readonly dirtyHandler = () => this.emit("dirty");
|
|
183
223
|
|
|
@@ -196,7 +236,7 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
196
236
|
/**
|
|
197
237
|
* {@inheritDoc IFluidContainer.isDirty}
|
|
198
238
|
*/
|
|
199
|
-
|
|
239
|
+
public get isDirty(): boolean {
|
|
200
240
|
return this.container.isDirty;
|
|
201
241
|
}
|
|
202
242
|
|
|
@@ -217,7 +257,7 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
217
257
|
/**
|
|
218
258
|
* {@inheritDoc IFluidContainer.connectionState}
|
|
219
259
|
*/
|
|
220
|
-
|
|
260
|
+
public get connectionState(): ConnectionState {
|
|
221
261
|
return this.container.connectionState;
|
|
222
262
|
}
|
|
223
263
|
|
|
@@ -230,7 +270,10 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
230
270
|
|
|
231
271
|
/**
|
|
232
272
|
* Incomplete base implementation of {@link IFluidContainer.attach}.
|
|
233
|
-
*
|
|
273
|
+
*
|
|
274
|
+
* @remarks
|
|
275
|
+
*
|
|
276
|
+
* Note: this implementation will unconditionally throw.
|
|
234
277
|
* Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
|
|
235
278
|
* that provides an implementation of this method.
|
|
236
279
|
*
|
|
@@ -238,7 +281,10 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
238
281
|
* but internally this separation is not there.
|
|
239
282
|
*/
|
|
240
283
|
public async attach(): Promise<string> {
|
|
241
|
-
|
|
284
|
+
if (this.container.attachState !== AttachState.Detached) {
|
|
285
|
+
throw new Error("Cannot attach container. Container is not in detached state.");
|
|
286
|
+
}
|
|
287
|
+
throw new Error("Cannot attach container. Attach method not provided.");
|
|
242
288
|
}
|
|
243
289
|
|
|
244
290
|
/**
|
package/src/rootDataObject.ts
CHANGED
|
@@ -23,20 +23,20 @@ import {
|
|
|
23
23
|
import { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from "./utils";
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Input props for {@link RootDataObject.initializingFirstTime}
|
|
26
|
+
* Input props for {@link RootDataObject.initializingFirstTime}.
|
|
27
27
|
*/
|
|
28
28
|
export interface RootDataObjectProps {
|
|
29
29
|
/**
|
|
30
30
|
* Initial object structure with which the {@link RootDataObject} will be first-time initialized.
|
|
31
|
-
*
|
|
31
|
+
*
|
|
32
|
+
* @see {@link RootDataObject.initializingFirstTime}
|
|
32
33
|
*/
|
|
33
34
|
initialObjects: LoadableObjectClassRecord;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
|
-
* The entry-point/root collaborative object of the Fluid Container.
|
|
38
|
-
*
|
|
39
|
-
* for end customers.
|
|
38
|
+
* The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
|
|
39
|
+
* Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
|
|
40
40
|
*/
|
|
41
41
|
export class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> {
|
|
42
42
|
private readonly initialObjectsDirKey = "initial-objects-key";
|
|
@@ -54,7 +54,7 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
54
54
|
* The first time this object is initialized, creates each object identified in
|
|
55
55
|
* {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.
|
|
56
56
|
*
|
|
57
|
-
*
|
|
57
|
+
* @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
|
|
58
58
|
*/
|
|
59
59
|
protected async initializingFirstTime(props: RootDataObjectProps) {
|
|
60
60
|
this.root.createSubDirectory(this.initialObjectsDirKey);
|
|
@@ -76,7 +76,7 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
76
76
|
* Every time an instance is initialized, loads all of the initial objects in the root directory so they can be
|
|
77
77
|
* accessed immediately.
|
|
78
78
|
*
|
|
79
|
-
*
|
|
79
|
+
* @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
|
|
80
80
|
*/
|
|
81
81
|
protected async hasInitialized() {
|
|
82
82
|
// We will always load the initial objects so they are available to the developer
|
|
@@ -94,7 +94,8 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Provides a record of the initial objects defined on creation.
|
|
97
|
-
*
|
|
97
|
+
*
|
|
98
|
+
* @see {@link RootDataObject.initializingFirstTime}
|
|
98
99
|
*/
|
|
99
100
|
public get initialObjects(): LoadableObjectRecord {
|
|
100
101
|
if (Object.keys(this._initialObjects).length === 0) {
|
|
@@ -105,7 +106,10 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
105
106
|
|
|
106
107
|
/**
|
|
107
108
|
* Dynamically creates a new detached collaborative object (DDS/DataObject).
|
|
109
|
+
*
|
|
108
110
|
* @param objectClass - Type of the collaborative object to be created.
|
|
111
|
+
*
|
|
112
|
+
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
109
113
|
*/
|
|
110
114
|
public async create<T extends IFluidLoadable>(
|
|
111
115
|
objectClass: LoadableObjectClass<T>,
|
|
@@ -137,8 +141,12 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
137
141
|
const rootDataStoreId = "rootDOId";
|
|
138
142
|
|
|
139
143
|
/**
|
|
140
|
-
* Container code that provides a single {@link RootDataObject}.
|
|
141
|
-
*
|
|
144
|
+
* Container code that provides a single {@link RootDataObject}.
|
|
145
|
+
*
|
|
146
|
+
* @remarks
|
|
147
|
+
*
|
|
148
|
+
* This data object is dynamically customized (registry and initial objects) based on the schema provided.
|
|
149
|
+
* to the container runtime factory.
|
|
142
150
|
*/
|
|
143
151
|
export class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
144
152
|
private readonly rootDataObjectFactory: DataObjectFactory<RootDataObject, {
|
package/src/serviceAudience.ts
CHANGED
|
@@ -9,29 +9,39 @@ import { IClient } from "@fluidframework/protocol-definitions";
|
|
|
9
9
|
import { IServiceAudience, IServiceAudienceEvents, IMember } from "./types";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Base class for providing audience information for sessions interacting with
|
|
12
|
+
* Base class for providing audience information for sessions interacting with {@link IFluidContainer}
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
*
|
|
13
16
|
* This can be extended by different service-specific client packages to additional parameters to
|
|
14
|
-
* the user and client details returned in IMember
|
|
15
|
-
*
|
|
17
|
+
* the user and client details returned in {@link IMember}.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam M - A service-specific {@link IMember} implementation.
|
|
16
20
|
*/
|
|
17
21
|
export abstract class ServiceAudience<M extends IMember = IMember>
|
|
18
22
|
extends TypedEventEmitter<IServiceAudienceEvents<M>>
|
|
19
23
|
implements IServiceAudience<M> {
|
|
20
24
|
/**
|
|
21
|
-
* Audience object which includes all the existing members of the container.
|
|
25
|
+
* Audience object which includes all the existing members of the {@link IFluidContainer | container}.
|
|
22
26
|
*/
|
|
23
27
|
protected readonly audience: IAudience;
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
|
-
* Retain the most recent member list.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
* Retain the most recent member list.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
*
|
|
34
|
+
* This is so we have more information about a member leaving the audience in the `removeMember` event.
|
|
35
|
+
*
|
|
36
|
+
* It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this
|
|
37
|
+
* class exposes (and would actually produce a change in what `getMembers` returns).
|
|
38
|
+
*
|
|
39
|
+
* It also allows us to provide the client details in the event which makes it easier to find that client connection
|
|
40
|
+
* in a map keyed on the `userId` and not `clientId`.
|
|
41
|
+
*
|
|
42
|
+
* This map will always be up-to-date in a `removeMember` event because it is set once at construction and in
|
|
43
|
+
* every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}
|
|
44
|
+
* events provide.
|
|
35
45
|
*/
|
|
36
46
|
protected lastMembers: Map<string, M> = new Map();
|
|
37
47
|
|
|
@@ -68,6 +78,7 @@ export abstract class ServiceAudience<M extends IMember = IMember>
|
|
|
68
78
|
|
|
69
79
|
/**
|
|
70
80
|
* Provides ability for inheriting class to modify/extend the audience object.
|
|
81
|
+
*
|
|
71
82
|
* @param audienceMember - Record of a specific audience member.
|
|
72
83
|
*/
|
|
73
84
|
protected abstract createServiceMember(audienceMember: IClient): M;
|
|
@@ -127,6 +138,7 @@ export abstract class ServiceAudience<M extends IMember = IMember>
|
|
|
127
138
|
/**
|
|
128
139
|
* Provides ability for the inheriting class to include/omit specific members.
|
|
129
140
|
* An example use case is omitting the summarizer client.
|
|
141
|
+
*
|
|
130
142
|
* @param member - Member to be included/omitted.
|
|
131
143
|
*/
|
|
132
144
|
protected shouldIncludeAsMember(member: IClient): boolean {
|