@fluidframework/fluid-static 2.0.0-dev.1.4.6.106135 → 2.0.0-dev.2.3.0.115467
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/.eslintrc.js +1 -1
- package/dist/fluidContainer.d.ts +100 -71
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +26 -4
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -14
- package/dist/index.js.map +1 -1
- package/dist/rootDataObject.d.ts +17 -15
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +16 -14
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +27 -15
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js +29 -13
- package/dist/serviceAudience.js.map +1 -1
- package/dist/types.d.ts +100 -70
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/fluidContainer.d.ts +100 -71
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +26 -4
- package/lib/fluidContainer.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -4
- package/lib/index.js.map +1 -1
- package/lib/rootDataObject.d.ts +17 -15
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +16 -14
- package/lib/rootDataObject.js.map +1 -1
- package/lib/serviceAudience.d.ts +27 -15
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.js +29 -13
- package/lib/serviceAudience.js.map +1 -1
- package/lib/types.d.ts +100 -70
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +49 -25
- package/prettier.config.cjs +8 -0
- package/src/fluidContainer.ts +121 -75
- package/src/index.ts +19 -4
- package/src/rootDataObject.ts +20 -17
- package/src/serviceAudience.ts +36 -16
- package/src/types.ts +108 -71
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.2.3.0.115467",
|
|
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": {
|
|
@@ -27,40 +27,62 @@
|
|
|
27
27
|
"clean": "rimraf dist *.tsbuildinfo *.build.log",
|
|
28
28
|
"eslint": "eslint --format stylish src",
|
|
29
29
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
30
|
+
"format": "npm run prettier:fix",
|
|
30
31
|
"lint": "npm run eslint",
|
|
31
32
|
"lint:fix": "npm run eslint:fix",
|
|
33
|
+
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
34
|
+
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
32
35
|
"test": "npm run test:mocha",
|
|
33
36
|
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
34
37
|
"test:mocha": "mocha --recursive dist/test/**/*.spec.js -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
35
38
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
36
39
|
"tsc": "tsc",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
+
"typetests:gen": "flub generate typetests --generate --dir .",
|
|
41
|
+
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
42
|
+
},
|
|
43
|
+
"nyc": {
|
|
44
|
+
"all": true,
|
|
45
|
+
"cache-dir": "nyc/.cache",
|
|
46
|
+
"exclude": [
|
|
47
|
+
"src/test/**/*.ts",
|
|
48
|
+
"dist/test/**/*.js"
|
|
49
|
+
],
|
|
50
|
+
"exclude-after-remap": false,
|
|
51
|
+
"include": [
|
|
52
|
+
"src/**/*.ts",
|
|
53
|
+
"dist/**/*.js"
|
|
54
|
+
],
|
|
55
|
+
"report-dir": "nyc/report",
|
|
56
|
+
"reporter": [
|
|
57
|
+
"cobertura",
|
|
58
|
+
"html",
|
|
59
|
+
"text"
|
|
60
|
+
],
|
|
61
|
+
"temp-directory": "nyc/.nyc_output"
|
|
40
62
|
},
|
|
41
63
|
"dependencies": {
|
|
42
|
-
"@fluidframework/aqueduct": "2.0.0-dev.
|
|
64
|
+
"@fluidframework/aqueduct": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
43
65
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
44
66
|
"@fluidframework/common-utils": "^1.0.0",
|
|
45
|
-
"@fluidframework/container-definitions": "2.0.0-dev.
|
|
46
|
-
"@fluidframework/container-loader": "2.0.0-dev.
|
|
47
|
-
"@fluidframework/container-runtime-definitions": "2.0.0-dev.
|
|
48
|
-
"@fluidframework/core-interfaces": "2.0.0-dev.
|
|
49
|
-
"@fluidframework/datastore-definitions": "2.0.0-dev.
|
|
50
|
-
"@fluidframework/protocol-definitions": "^1.
|
|
51
|
-
"@fluidframework/request-handler": "2.0.0-dev.
|
|
52
|
-
"@fluidframework/runtime-definitions": "2.0.0-dev.
|
|
53
|
-
"@fluidframework/runtime-utils": "2.0.0-dev.
|
|
67
|
+
"@fluidframework/container-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
68
|
+
"@fluidframework/container-loader": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
69
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
70
|
+
"@fluidframework/core-interfaces": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
71
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
72
|
+
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
73
|
+
"@fluidframework/request-handler": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
74
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
75
|
+
"@fluidframework/runtime-utils": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0"
|
|
54
76
|
},
|
|
55
77
|
"devDependencies": {
|
|
56
|
-
"@fluid-
|
|
57
|
-
"@fluidframework/build-common": "^1.
|
|
58
|
-
"@fluidframework/build-tools": "^0.
|
|
59
|
-
"@fluidframework/eslint-config-fluid": "^1.
|
|
60
|
-
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static
|
|
61
|
-
"@fluidframework/map": "2.0.0-dev.
|
|
62
|
-
"@fluidframework/mocha-test-setup": "2.0.0-dev.
|
|
63
|
-
"@fluidframework/sequence": "2.0.0-dev.
|
|
78
|
+
"@fluid-tools/build-cli": "^0.7.0",
|
|
79
|
+
"@fluidframework/build-common": "^1.1.0",
|
|
80
|
+
"@fluidframework/build-tools": "^0.7.0",
|
|
81
|
+
"@fluidframework/eslint-config-fluid": "^1.2.0",
|
|
82
|
+
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.2.2.0",
|
|
83
|
+
"@fluidframework/map": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
84
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
85
|
+
"@fluidframework/sequence": ">=2.0.0-dev.2.3.0.115467 <2.0.0-dev.3.0.0",
|
|
64
86
|
"@microsoft/api-extractor": "^7.22.2",
|
|
65
87
|
"@rushstack/eslint-config": "^2.5.1",
|
|
66
88
|
"@types/mocha": "^9.1.1",
|
|
@@ -71,12 +93,14 @@
|
|
|
71
93
|
"eslint": "~8.6.0",
|
|
72
94
|
"mocha": "^10.0.0",
|
|
73
95
|
"nyc": "^15.0.0",
|
|
96
|
+
"prettier": "~2.6.2",
|
|
74
97
|
"rimraf": "^2.6.2",
|
|
75
|
-
"typescript": "~4.5.5"
|
|
76
|
-
"typescript-formatter": "7.1.0"
|
|
98
|
+
"typescript": "~4.5.5"
|
|
77
99
|
},
|
|
78
100
|
"typeValidation": {
|
|
79
|
-
"version": "2.0.0",
|
|
101
|
+
"version": "2.0.0-internal.2.3.0",
|
|
102
|
+
"baselineRange": ">=2.0.0-internal.2.2.0 <2.0.0-internal.2.3.0",
|
|
103
|
+
"baselineVersion": "2.0.0-internal.2.2.0",
|
|
80
104
|
"broken": {}
|
|
81
105
|
}
|
|
82
106
|
}
|
package/src/fluidContainer.ts
CHANGED
|
@@ -5,75 +5,80 @@
|
|
|
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 {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import {
|
|
9
|
+
AttachState,
|
|
10
|
+
IContainer,
|
|
11
|
+
ICriticalContainerError,
|
|
12
|
+
ConnectionState,
|
|
13
|
+
} from "@fluidframework/container-definitions";
|
|
14
|
+
import type { IRootDataObject, LoadableObjectClass, LoadableObjectRecord } from "./types";
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
* Events emitted from {@link IFluidContainer}.
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
*
|
|
17
|
-
* The following is the list of events emitted.
|
|
18
|
-
*
|
|
19
|
-
* ### "connected"
|
|
20
|
-
*
|
|
21
|
-
* The "connected" event is emitted when the `IFluidContainer` completes connecting to the Fluid service.
|
|
22
|
-
*
|
|
23
|
-
* #### Listener signature
|
|
24
|
-
*
|
|
25
|
-
* ```typescript
|
|
26
|
-
* () => void;
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* ### "dispose"
|
|
30
|
-
*
|
|
31
|
-
* The "dispose" event is emitted when the `IFluidContainer` is disposed, which permanently disables it.
|
|
32
|
-
*
|
|
33
|
-
* #### Listener signature
|
|
34
|
-
*
|
|
35
|
-
* ```typescript
|
|
36
|
-
* () => void;
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* ### "disconnected"
|
|
40
|
-
*
|
|
41
|
-
* The "disconnected" event is emitted when the `IFluidContainer` becomes disconnected from the Fluid service.
|
|
42
|
-
*
|
|
43
|
-
* #### Listener signature
|
|
44
|
-
*
|
|
45
|
-
* ```typescript
|
|
46
|
-
* () => void;
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* ### "saved"
|
|
50
|
-
*
|
|
51
|
-
* The "saved" event is emitted when the `IFluidContainer` has local changes acknowledged by the service.
|
|
52
|
-
*
|
|
53
|
-
* #### Listener signature
|
|
54
|
-
*
|
|
55
|
-
* ```typescript
|
|
56
|
-
* () => void
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* ### "dirty"
|
|
60
|
-
*
|
|
61
|
-
* The "dirty" event is emitted when the `IFluidContainer` has local changes that have not yet
|
|
62
|
-
* been acknowledged by the service.
|
|
63
|
-
*
|
|
64
|
-
* #### Listener signature
|
|
65
|
-
*
|
|
66
|
-
* ```typescript
|
|
67
|
-
* () => void
|
|
68
|
-
* ```
|
|
69
18
|
*/
|
|
19
|
+
/* eslint-disable @typescript-eslint/unified-signatures */
|
|
70
20
|
export interface IFluidContainerEvents extends IEvent {
|
|
71
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.
|
|
23
|
+
*
|
|
24
|
+
* @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
|
|
25
|
+
*
|
|
26
|
+
* @see
|
|
27
|
+
*
|
|
28
|
+
* - {@link IFluidContainer.connectionState}
|
|
29
|
+
*
|
|
30
|
+
* - {@link IFluidContainer.connect}
|
|
31
|
+
*/
|
|
32
|
+
(event: "connected", listener: () => void): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.
|
|
36
|
+
*
|
|
37
|
+
* @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
|
|
38
|
+
*
|
|
39
|
+
* @see
|
|
40
|
+
*
|
|
41
|
+
* - {@link IFluidContainer.connectionState}
|
|
42
|
+
*
|
|
43
|
+
* - {@link IFluidContainer.disconnect}
|
|
44
|
+
*/
|
|
45
|
+
(event: "disconnected", listener: () => void): void;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Emitted when all local changes/edits have been acknowledged by the service.
|
|
49
|
+
*
|
|
50
|
+
* @remarks "dirty" event will be emitted when the next local change has been made.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link IFluidContainer.isDirty}
|
|
53
|
+
*/
|
|
54
|
+
(event: "saved", listener: () => void): void;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Emitted when the first local change has been made, following a "saved" event.
|
|
58
|
+
*
|
|
59
|
+
* @remarks "saved" event will be emitted once all local changes have been acknowledged by the service.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link IFluidContainer.isDirty}
|
|
62
|
+
*/
|
|
63
|
+
(event: "dirty", listener: () => void): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
|
|
67
|
+
*
|
|
68
|
+
* @remarks Listener parameters:
|
|
69
|
+
*
|
|
70
|
+
* - `error`: If the container was closed due to error (as opposed to an explicit call to
|
|
71
|
+
* {@link IFluidContainer.dispose}), this will contain details about the error that caused it.
|
|
72
|
+
*/
|
|
73
|
+
(event: "disposed", listener: (error?: ICriticalContainerError) => void);
|
|
72
74
|
}
|
|
75
|
+
/* eslint-enable @typescript-eslint/unified-signatures */
|
|
73
76
|
|
|
74
77
|
/**
|
|
75
78
|
* Provides an entrypoint into the client side of collaborative Fluid data.
|
|
76
79
|
* Provides access to the data as well as status on the collaboration session.
|
|
80
|
+
*
|
|
81
|
+
* @remarks Note: external implementations of this interface are not supported.
|
|
77
82
|
*/
|
|
78
83
|
export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
79
84
|
/**
|
|
@@ -83,6 +88,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
83
88
|
|
|
84
89
|
/**
|
|
85
90
|
* A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
*
|
|
86
94
|
* You should always check the `isDirty` flag before closing the container or navigating away from the page.
|
|
87
95
|
* Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
|
|
88
96
|
* acknowledged by the service.
|
|
@@ -101,18 +109,23 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
101
109
|
readonly isDirty: boolean;
|
|
102
110
|
|
|
103
111
|
/**
|
|
104
|
-
* Whether the container is disposed, which permanently disables it.
|
|
112
|
+
* Whether or not the container is disposed, which permanently disables it.
|
|
105
113
|
*/
|
|
106
114
|
readonly disposed: boolean;
|
|
107
115
|
|
|
108
116
|
/**
|
|
109
117
|
* The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
|
|
110
|
-
*
|
|
118
|
+
*
|
|
119
|
+
* @remarks These data objects and DDSes exist for the lifetime of the container.
|
|
111
120
|
*/
|
|
112
121
|
readonly initialObjects: LoadableObjectRecord;
|
|
113
122
|
|
|
114
123
|
/**
|
|
115
|
-
* The current attachment state of the container.
|
|
124
|
+
* The current attachment state of the container.
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
*
|
|
128
|
+
* Once a container has been attached, it remains attached.
|
|
116
129
|
* When loading an existing container, it will already be attached.
|
|
117
130
|
*/
|
|
118
131
|
readonly attachState: AttachState;
|
|
@@ -121,7 +134,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
121
134
|
* A newly created container starts detached from the collaborative service.
|
|
122
135
|
* Calling `attach()` uploads the new container to the service and connects to the collaborative service.
|
|
123
136
|
*
|
|
124
|
-
* @remarks
|
|
137
|
+
* @remarks
|
|
138
|
+
*
|
|
139
|
+
* This should only be called when the container is in the
|
|
125
140
|
* {@link @fluidframework/container-definitions#AttachState.Detatched} state.
|
|
126
141
|
*
|
|
127
142
|
* This can be determined by observing {@link IFluidContainer.attachState}.
|
|
@@ -132,9 +147,12 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
132
147
|
|
|
133
148
|
/**
|
|
134
149
|
* Attempts to connect the container to the delta stream and process operations.
|
|
135
|
-
* Will throw an error if unsuccessful.
|
|
136
150
|
*
|
|
137
|
-
* @
|
|
151
|
+
* @throws Will throw an error if connection is unsuccessful.
|
|
152
|
+
*
|
|
153
|
+
* @remarks
|
|
154
|
+
*
|
|
155
|
+
* This should only be called when the container is in the
|
|
138
156
|
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
139
157
|
*
|
|
140
158
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
@@ -144,7 +162,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
144
162
|
/**
|
|
145
163
|
* Disconnects the container from the delta stream and stops processing operations.
|
|
146
164
|
*
|
|
147
|
-
* @remarks
|
|
165
|
+
* @remarks
|
|
166
|
+
*
|
|
167
|
+
* This should only be called when the container is in the
|
|
148
168
|
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
149
169
|
*
|
|
150
170
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
@@ -154,11 +174,15 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
154
174
|
/**
|
|
155
175
|
* Create a new data object or Distributed Data Store (DDS) of the specified type.
|
|
156
176
|
*
|
|
157
|
-
* @remarks
|
|
177
|
+
* @remarks
|
|
178
|
+
*
|
|
179
|
+
* In order to share the data object or DDS with other
|
|
158
180
|
* collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
|
|
159
181
|
* initialObjects.
|
|
160
182
|
*
|
|
161
|
-
* @param objectClass - The class of
|
|
183
|
+
* @param objectClass - The class of the `DataObject` or `SharedObject` to create.
|
|
184
|
+
*
|
|
185
|
+
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
162
186
|
*/
|
|
163
187
|
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
|
|
164
188
|
|
|
@@ -171,19 +195,21 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
171
195
|
/**
|
|
172
196
|
* Base {@link IFluidContainer} implementation.
|
|
173
197
|
*
|
|
174
|
-
* @remarks
|
|
198
|
+
* @remarks
|
|
199
|
+
*
|
|
200
|
+
* Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
|
|
175
201
|
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
176
202
|
*/
|
|
177
203
|
export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {
|
|
178
204
|
private readonly connectedHandler = () => this.emit("connected");
|
|
179
205
|
private readonly disconnectedHandler = () => this.emit("disconnected");
|
|
180
|
-
private readonly disposedHandler = () => this.emit("disposed");
|
|
206
|
+
private readonly disposedHandler = (error?: ICriticalContainerError) => this.emit("disposed", error);
|
|
181
207
|
private readonly savedHandler = () => this.emit("saved");
|
|
182
208
|
private readonly dirtyHandler = () => this.emit("dirty");
|
|
183
209
|
|
|
184
210
|
public constructor(
|
|
185
211
|
private readonly container: IContainer,
|
|
186
|
-
private readonly rootDataObject:
|
|
212
|
+
private readonly rootDataObject: IRootDataObject,
|
|
187
213
|
) {
|
|
188
214
|
super();
|
|
189
215
|
container.on("connected", this.connectedHandler);
|
|
@@ -196,7 +222,7 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
196
222
|
/**
|
|
197
223
|
* {@inheritDoc IFluidContainer.isDirty}
|
|
198
224
|
*/
|
|
199
|
-
|
|
225
|
+
public get isDirty(): boolean {
|
|
200
226
|
return this.container.isDirty;
|
|
201
227
|
}
|
|
202
228
|
|
|
@@ -217,7 +243,7 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
217
243
|
/**
|
|
218
244
|
* {@inheritDoc IFluidContainer.connectionState}
|
|
219
245
|
*/
|
|
220
|
-
|
|
246
|
+
public get connectionState(): ConnectionState {
|
|
221
247
|
return this.container.connectionState;
|
|
222
248
|
}
|
|
223
249
|
|
|
@@ -230,7 +256,10 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
230
256
|
|
|
231
257
|
/**
|
|
232
258
|
* Incomplete base implementation of {@link IFluidContainer.attach}.
|
|
233
|
-
*
|
|
259
|
+
*
|
|
260
|
+
* @remarks
|
|
261
|
+
*
|
|
262
|
+
* Note: this implementation will unconditionally throw.
|
|
234
263
|
* Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
|
|
235
264
|
* that provides an implementation of this method.
|
|
236
265
|
*
|
|
@@ -238,7 +267,10 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
238
267
|
* but internally this separation is not there.
|
|
239
268
|
*/
|
|
240
269
|
public async attach(): Promise<string> {
|
|
241
|
-
|
|
270
|
+
if (this.container.attachState !== AttachState.Detached) {
|
|
271
|
+
throw new Error("Cannot attach container. Container is not in detached state.");
|
|
272
|
+
}
|
|
273
|
+
throw new Error("Cannot attach container. Attach method not provided.");
|
|
242
274
|
}
|
|
243
275
|
|
|
244
276
|
/**
|
|
@@ -273,4 +305,18 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
|
|
|
273
305
|
this.container.off("saved", this.savedHandler);
|
|
274
306
|
this.container.off("dirty", this.dirtyHandler);
|
|
275
307
|
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* FOR INTERNAL USE ONLY. NOT FOR EXTERNAL USE.
|
|
311
|
+
* We make no stability guarantees here whatsoever.
|
|
312
|
+
*
|
|
313
|
+
* Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
314
|
+
*
|
|
315
|
+
* @remarks Used to power debug tooling.
|
|
316
|
+
*
|
|
317
|
+
* @internal
|
|
318
|
+
*/
|
|
319
|
+
public readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer = () => {
|
|
320
|
+
return this.container;
|
|
321
|
+
}
|
|
276
322
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,22 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
12
|
+
export { FluidContainer, IFluidContainer, IFluidContainerEvents } from "./fluidContainer";
|
|
13
|
+
export { DOProviderContainerRuntimeFactory, RootDataObject, RootDataObjectProps } from "./rootDataObject";
|
|
14
|
+
export { ServiceAudience } from "./serviceAudience";
|
|
15
|
+
export {
|
|
16
|
+
ContainerSchema,
|
|
17
|
+
DataObjectClass,
|
|
18
|
+
IConnection,
|
|
19
|
+
IMember,
|
|
20
|
+
IRootDataObject,
|
|
21
|
+
IServiceAudience,
|
|
22
|
+
IServiceAudienceEvents,
|
|
23
|
+
LoadableObjectClass,
|
|
24
|
+
LoadableObjectClassRecord,
|
|
25
|
+
LoadableObjectCtor,
|
|
26
|
+
LoadableObjectRecord,
|
|
27
|
+
MemberChangedListener,
|
|
28
|
+
SharedObjectClass,
|
|
29
|
+
Myself,
|
|
30
|
+
} from "./types";
|
package/src/rootDataObject.ts
CHANGED
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
12
12
|
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
13
13
|
import { FlushMode } from "@fluidframework/runtime-definitions";
|
|
14
|
-
import { requestFluidObject } from "@fluidframework/runtime-utils";
|
|
15
14
|
import {
|
|
16
15
|
ContainerSchema,
|
|
17
16
|
DataObjectClass,
|
|
17
|
+
IRootDataObject,
|
|
18
18
|
LoadableObjectClass,
|
|
19
19
|
LoadableObjectClassRecord,
|
|
20
20
|
LoadableObjectRecord,
|
|
@@ -23,22 +23,22 @@ 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
|
-
export class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> {
|
|
41
|
+
export class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> implements IRootDataObject {
|
|
42
42
|
private readonly initialObjectsDirKey = "initial-objects-key";
|
|
43
43
|
private readonly _initialObjects: LoadableObjectRecord = {};
|
|
44
44
|
|
|
@@ -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
|
|
@@ -93,8 +93,7 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
97
|
-
* See {@link RootDataObject.initializingFirstTime}
|
|
96
|
+
* {@inheritDoc IRootDataObject.initialObjects}
|
|
98
97
|
*/
|
|
99
98
|
public get initialObjects(): LoadableObjectRecord {
|
|
100
99
|
if (Object.keys(this._initialObjects).length === 0) {
|
|
@@ -104,8 +103,7 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
/**
|
|
107
|
-
*
|
|
108
|
-
* @param objectClass - Type of the collaborative object to be created.
|
|
106
|
+
* {@inheritDoc IRootDataObject.create}
|
|
109
107
|
*/
|
|
110
108
|
public async create<T extends IFluidLoadable>(
|
|
111
109
|
objectClass: LoadableObjectClass<T>,
|
|
@@ -121,8 +119,9 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
121
119
|
private async createDataObject<T extends IFluidLoadable>(dataObjectClass: DataObjectClass<T>): Promise<T> {
|
|
122
120
|
const factory = dataObjectClass.factory;
|
|
123
121
|
const packagePath = [...this.context.packagePath, factory.type];
|
|
124
|
-
const
|
|
125
|
-
|
|
122
|
+
const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
|
|
123
|
+
const entryPoint = await dataStore.entryPoint?.get();
|
|
124
|
+
return entryPoint as unknown as T;
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
private createSharedObject<T extends IFluidLoadable>(
|
|
@@ -137,8 +136,12 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
|
|
|
137
136
|
const rootDataStoreId = "rootDOId";
|
|
138
137
|
|
|
139
138
|
/**
|
|
140
|
-
* Container code that provides a single {@link RootDataObject}.
|
|
141
|
-
*
|
|
139
|
+
* Container code that provides a single {@link RootDataObject}.
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
*
|
|
143
|
+
* This data object is dynamically customized (registry and initial objects) based on the schema provided.
|
|
144
|
+
* to the container runtime factory.
|
|
142
145
|
*/
|
|
143
146
|
export class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
144
147
|
private readonly rootDataObjectFactory: DataObjectFactory<RootDataObject, {
|
package/src/serviceAudience.ts
CHANGED
|
@@ -6,32 +6,42 @@
|
|
|
6
6
|
import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
7
7
|
import { IAudience, IContainer } from "@fluidframework/container-definitions";
|
|
8
8
|
import { IClient } from "@fluidframework/protocol-definitions";
|
|
9
|
-
import { IServiceAudience, IServiceAudienceEvents, IMember } from "./types";
|
|
9
|
+
import { IServiceAudience, IServiceAudienceEvents, IMember, Myself } 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;
|
|
@@ -101,12 +112,20 @@ export abstract class ServiceAudience<M extends IMember = IMember>
|
|
|
101
112
|
/**
|
|
102
113
|
* {@inheritDoc IServiceAudience.getMyself}
|
|
103
114
|
*/
|
|
104
|
-
public getMyself(): M | undefined {
|
|
115
|
+
public getMyself(): Myself<M> | undefined {
|
|
105
116
|
const clientId = this.container.clientId;
|
|
106
117
|
if (clientId === undefined) {
|
|
107
118
|
return undefined;
|
|
108
119
|
}
|
|
109
|
-
|
|
120
|
+
|
|
121
|
+
const member = this.getMember(clientId);
|
|
122
|
+
if (member === undefined) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const myself: Myself<M> = { ...member, currentConnection: clientId };
|
|
127
|
+
|
|
128
|
+
return myself;
|
|
110
129
|
}
|
|
111
130
|
|
|
112
131
|
private getMember(clientId: string): M | undefined {
|
|
@@ -127,6 +146,7 @@ export abstract class ServiceAudience<M extends IMember = IMember>
|
|
|
127
146
|
/**
|
|
128
147
|
* Provides ability for the inheriting class to include/omit specific members.
|
|
129
148
|
* An example use case is omitting the summarizer client.
|
|
149
|
+
*
|
|
130
150
|
* @param member - Member to be included/omitted.
|
|
131
151
|
*/
|
|
132
152
|
protected shouldIncludeAsMember(member: IClient): boolean {
|