@fluidframework/fluid-static 2.0.0-rc.1.0.3 → 2.0.0-rc.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/{.eslintrc.js → .eslintrc.cjs} +1 -1
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +10 -0
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor.json +1 -1
- package/api-report/fluid-static.api.md +17 -14
- package/dist/fluid-static-alpha.d.ts +29 -13
- package/dist/fluid-static-beta.d.ts +29 -13
- package/dist/fluid-static-public.d.ts +29 -13
- package/dist/fluid-static-untrimmed.d.ts +44 -16
- package/dist/fluidContainer.d.ts +9 -6
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +3 -1
- 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 +6 -6
- package/dist/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/rootDataObject.d.ts +5 -2
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +12 -8
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +13 -6
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js +12 -4
- package/dist/serviceAudience.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types.d.ts +26 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +13 -9
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +11 -8
- package/dist/utils.js.map +1 -1
- package/lib/{fluid-static-alpha.d.mts → fluid-static-alpha.d.ts} +35 -13
- package/lib/{fluid-static-beta.d.mts → fluid-static-beta.d.ts} +35 -13
- package/lib/{fluid-static-public.d.mts → fluid-static-public.d.ts} +35 -13
- package/lib/{fluid-static-untrimmed.d.mts → fluid-static-untrimmed.d.ts} +50 -16
- package/lib/{fluidContainer.d.mts → fluidContainer.d.ts} +10 -7
- package/lib/fluidContainer.d.ts.map +1 -0
- package/lib/{fluidContainer.mjs → fluidContainer.js} +8 -2
- package/lib/fluidContainer.js.map +1 -0
- package/lib/index.d.ts +14 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +13 -0
- package/lib/index.js.map +1 -0
- package/lib/{rootDataObject.d.mts → rootDataObject.d.ts} +6 -3
- package/lib/rootDataObject.d.ts.map +1 -0
- package/lib/{rootDataObject.mjs → rootDataObject.js} +14 -6
- package/lib/rootDataObject.js.map +1 -0
- package/lib/serviceAudience.d.ts +22 -0
- package/lib/serviceAudience.d.ts.map +1 -0
- package/lib/{serviceAudience.mjs → serviceAudience.js} +13 -5
- package/lib/serviceAudience.js.map +1 -0
- package/lib/test/fluidContainer.spec.js +21 -0
- package/lib/test/fluidContainer.spec.js.map +1 -0
- package/lib/test/types/validateFluidStaticPrevious.generated.js +46 -0
- package/lib/test/types/validateFluidStaticPrevious.generated.js.map +1 -0
- package/lib/test/utils.spec.js +86 -0
- package/lib/test/utils.spec.js.map +1 -0
- package/lib/{types.d.mts → types.d.ts} +27 -13
- package/lib/types.d.ts.map +1 -0
- package/lib/{types.mjs → types.js} +1 -1
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +34 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/{utils.mjs → utils.js} +11 -8
- package/lib/utils.js.map +1 -0
- package/package.json +45 -58
- package/src/fluidContainer.ts +29 -17
- package/src/index.ts +23 -22
- package/src/rootDataObject.ts +48 -29
- package/src/serviceAudience.ts +35 -22
- package/src/types.ts +34 -14
- package/src/utils.ts +36 -16
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +4 -8
- package/lib/fluidContainer.d.mts.map +0 -1
- package/lib/fluidContainer.mjs.map +0 -1
- package/lib/index.d.mts +0 -9
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs +0 -8
- package/lib/index.mjs.map +0 -1
- package/lib/rootDataObject.d.mts.map +0 -1
- package/lib/rootDataObject.mjs.map +0 -1
- package/lib/serviceAudience.d.mts +0 -15
- package/lib/serviceAudience.d.mts.map +0 -1
- package/lib/serviceAudience.mjs.map +0 -1
- package/lib/types.d.mts.map +0 -1
- package/lib/types.mjs.map +0 -1
- package/lib/utils.d.mts +0 -30
- package/lib/utils.d.mts.map +0 -1
- package/lib/utils.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.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": {
|
|
@@ -11,60 +11,40 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Microsoft and contributors",
|
|
13
13
|
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
16
17
|
"import": {
|
|
17
|
-
"types": "./lib/index.d.
|
|
18
|
-
"default": "./lib/index.
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
19
20
|
},
|
|
20
21
|
"require": {
|
|
21
22
|
"types": "./dist/index.d.ts",
|
|
22
23
|
"default": "./dist/index.js"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
|
-
"./
|
|
26
|
-
"import": {
|
|
27
|
-
"types": "./lib/fluid-static-alpha.d.mts",
|
|
28
|
-
"default": "./lib/index.mjs"
|
|
29
|
-
},
|
|
30
|
-
"require": {
|
|
31
|
-
"types": "./dist/fluid-static-alpha.d.ts",
|
|
32
|
-
"default": "./dist/index.js"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"./beta": {
|
|
26
|
+
"./public": {
|
|
36
27
|
"import": {
|
|
37
|
-
"types": "./lib/fluid-static-
|
|
38
|
-
"default": "./lib/index.
|
|
28
|
+
"types": "./lib/fluid-static-public.d.ts",
|
|
29
|
+
"default": "./lib/index.js"
|
|
39
30
|
},
|
|
40
31
|
"require": {
|
|
41
|
-
"types": "./dist/fluid-static-
|
|
32
|
+
"types": "./dist/fluid-static-public.d.ts",
|
|
42
33
|
"default": "./dist/index.js"
|
|
43
34
|
}
|
|
44
35
|
},
|
|
45
36
|
"./internal": {
|
|
46
37
|
"import": {
|
|
47
|
-
"types": "./lib/index.d.
|
|
48
|
-
"default": "./lib/index.
|
|
38
|
+
"types": "./lib/index.d.ts",
|
|
39
|
+
"default": "./lib/index.js"
|
|
49
40
|
},
|
|
50
41
|
"require": {
|
|
51
42
|
"types": "./dist/index.d.ts",
|
|
52
43
|
"default": "./dist/index.js"
|
|
53
44
|
}
|
|
54
|
-
},
|
|
55
|
-
"./public": {
|
|
56
|
-
"import": {
|
|
57
|
-
"types": "./lib/fluid-static-public.d.mts",
|
|
58
|
-
"default": "./lib/index.mjs"
|
|
59
|
-
},
|
|
60
|
-
"require": {
|
|
61
|
-
"types": "./dist/fluid-static-public.d.ts",
|
|
62
|
-
"default": "./dist/index.js"
|
|
63
|
-
}
|
|
64
45
|
}
|
|
65
46
|
},
|
|
66
47
|
"main": "dist/index.js",
|
|
67
|
-
"module": "lib/index.mjs",
|
|
68
48
|
"types": "dist/index.d.ts",
|
|
69
49
|
"c8": {
|
|
70
50
|
"all": true,
|
|
@@ -87,43 +67,42 @@
|
|
|
87
67
|
"temp-directory": "nyc/.nyc_output"
|
|
88
68
|
},
|
|
89
69
|
"dependencies": {
|
|
90
|
-
"@fluid-internal/client-utils": ">=2.0.0-rc.
|
|
91
|
-
"@fluidframework/aqueduct": ">=2.0.0-rc.
|
|
92
|
-
"@fluidframework/container-definitions": ">=2.0.0-rc.
|
|
93
|
-
"@fluidframework/container-loader": ">=2.0.0-rc.
|
|
94
|
-
"@fluidframework/container-runtime": ">=2.0.0-rc.
|
|
95
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-rc.
|
|
96
|
-
"@fluidframework/core-interfaces": ">=2.0.0-rc.
|
|
97
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-rc.
|
|
98
|
-
"@fluidframework/protocol-definitions": "^3.
|
|
99
|
-
"@fluidframework/request-handler": ">=2.0.0-rc.
|
|
100
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-rc.
|
|
101
|
-
"@fluidframework/runtime-utils": ">=2.0.0-rc.
|
|
70
|
+
"@fluid-internal/client-utils": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
71
|
+
"@fluidframework/aqueduct": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
72
|
+
"@fluidframework/container-definitions": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
73
|
+
"@fluidframework/container-loader": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
74
|
+
"@fluidframework/container-runtime": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
75
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
76
|
+
"@fluidframework/core-interfaces": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
77
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
78
|
+
"@fluidframework/protocol-definitions": "^3.2.0",
|
|
79
|
+
"@fluidframework/request-handler": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
80
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
81
|
+
"@fluidframework/runtime-utils": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0"
|
|
102
82
|
},
|
|
103
83
|
"devDependencies": {
|
|
104
84
|
"@arethetypeswrong/cli": "^0.13.3",
|
|
105
|
-
"@fluid-
|
|
85
|
+
"@fluid-internal/mocha-test-setup": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
86
|
+
"@fluid-tools/build-cli": "^0.34.0",
|
|
106
87
|
"@fluidframework/build-common": "^2.0.3",
|
|
107
|
-
"@fluidframework/build-tools": "^0.
|
|
108
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
88
|
+
"@fluidframework/build-tools": "^0.34.0",
|
|
89
|
+
"@fluidframework/eslint-config-fluid": "^4.0.0",
|
|
109
90
|
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.8.0.0",
|
|
110
|
-
"@fluidframework/map": ">=2.0.0-rc.
|
|
111
|
-
"@fluidframework/
|
|
112
|
-
"@
|
|
113
|
-
"@microsoft/api-extractor": "^7.38.3",
|
|
91
|
+
"@fluidframework/map": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
92
|
+
"@fluidframework/sequence": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
93
|
+
"@microsoft/api-extractor": "^7.42.3",
|
|
114
94
|
"@types/mocha": "^9.1.1",
|
|
115
95
|
"@types/node": "^18.19.0",
|
|
116
96
|
"c8": "^8.0.1",
|
|
117
97
|
"copyfiles": "^2.4.1",
|
|
118
98
|
"cross-env": "^7.0.3",
|
|
119
|
-
"eslint": "~8.
|
|
99
|
+
"eslint": "~8.55.0",
|
|
120
100
|
"mocha": "^10.2.0",
|
|
121
101
|
"mocha-json-output-reporter": "^2.0.1",
|
|
122
102
|
"mocha-multi-reporters": "^1.5.1",
|
|
123
103
|
"moment": "^2.21.0",
|
|
124
104
|
"prettier": "~3.0.3",
|
|
125
105
|
"rimraf": "^4.4.0",
|
|
126
|
-
"tsc-multi": "^1.1.0",
|
|
127
106
|
"typescript": "~5.1.6"
|
|
128
107
|
},
|
|
129
108
|
"fluidBuild": {
|
|
@@ -139,18 +118,24 @@
|
|
|
139
118
|
}
|
|
140
119
|
},
|
|
141
120
|
"typeValidation": {
|
|
142
|
-
"broken": {
|
|
121
|
+
"broken": {
|
|
122
|
+
"InterfaceDeclaration_ContainerSchema": {
|
|
123
|
+
"backCompat": false
|
|
124
|
+
}
|
|
125
|
+
}
|
|
143
126
|
},
|
|
144
127
|
"scripts": {
|
|
145
128
|
"api": "fluid-build . --task api",
|
|
146
|
-
"api-extractor:commonjs": "api-extractor run --
|
|
147
|
-
"api-extractor:esnext": "api-extractor run --
|
|
129
|
+
"api-extractor:commonjs": "api-extractor run --config ./api-extractor-cjs.json",
|
|
130
|
+
"api-extractor:esnext": "api-extractor run --local",
|
|
148
131
|
"build": "fluid-build . --task build",
|
|
149
132
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
150
133
|
"build:compile": "fluid-build . --task compile",
|
|
151
134
|
"build:docs": "fluid-build . --task api",
|
|
152
|
-
"build:esnext": "tsc
|
|
153
|
-
"build:test": "
|
|
135
|
+
"build:esnext": "tsc --project ./tsconfig.json",
|
|
136
|
+
"build:test": "npm run build:test:esm && npm run build:test:cjs",
|
|
137
|
+
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
138
|
+
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
154
139
|
"check:are-the-types-wrong": "attw --pack . --entrypoints .",
|
|
155
140
|
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
156
141
|
"ci:build:docs": "api-extractor run",
|
|
@@ -164,9 +149,11 @@
|
|
|
164
149
|
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
165
150
|
"test": "npm run test:mocha",
|
|
166
151
|
"test:coverage": "c8 npm test",
|
|
167
|
-
"test:mocha": "
|
|
152
|
+
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
153
|
+
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit -r node_modules/@fluid-internal/mocha-test-setup",
|
|
154
|
+
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit -r node_modules/@fluid-internal/mocha-test-setup",
|
|
168
155
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
169
|
-
"tsc": "tsc",
|
|
156
|
+
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
170
157
|
"typetests:gen": "fluid-type-test-generator",
|
|
171
158
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
172
159
|
}
|
package/src/fluidContainer.ts
CHANGED
|
@@ -3,14 +3,23 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type IEvent,
|
|
8
|
+
type IEventProvider,
|
|
9
|
+
type IFluidLoadable,
|
|
10
|
+
} from "@fluidframework/core-interfaces";
|
|
7
11
|
import {
|
|
8
12
|
AttachState,
|
|
9
|
-
IContainer,
|
|
10
|
-
ICriticalContainerError,
|
|
11
|
-
ConnectionState,
|
|
13
|
+
type IContainer,
|
|
14
|
+
type ICriticalContainerError,
|
|
15
|
+
type ConnectionState,
|
|
12
16
|
} from "@fluidframework/container-definitions";
|
|
13
|
-
import type {
|
|
17
|
+
import type {
|
|
18
|
+
ContainerSchema,
|
|
19
|
+
ContainerAttachProps,
|
|
20
|
+
IRootDataObject,
|
|
21
|
+
LoadableObjectClass,
|
|
22
|
+
} from "./types.js";
|
|
14
23
|
|
|
15
24
|
/**
|
|
16
25
|
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
@@ -18,7 +27,7 @@ import type { ContainerSchema, IRootDataObject, LoadableObjectClass } from "./ty
|
|
|
18
27
|
*/
|
|
19
28
|
export type InitialObjects<T extends ContainerSchema> = {
|
|
20
29
|
// Construct a LoadableObjectRecord type by enumerating the keys of
|
|
21
|
-
// 'ContainerSchema.initialObjects' and
|
|
30
|
+
// 'ContainerSchema.initialObjects' and inferring the value type of each key.
|
|
22
31
|
//
|
|
23
32
|
// The '? TChannel : never' is required because infer can only be used in
|
|
24
33
|
// a conditional 'extends' expression.
|
|
@@ -99,6 +108,7 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
99
108
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
100
109
|
*
|
|
101
110
|
* @remarks Note: external implementations of this interface are not supported.
|
|
111
|
+
*
|
|
102
112
|
* @sealed
|
|
103
113
|
* @public
|
|
104
114
|
*/
|
|
@@ -166,7 +176,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
166
176
|
*
|
|
167
177
|
* @returns A promise which resolves when the attach is complete, with the string identifier of the container.
|
|
168
178
|
*/
|
|
169
|
-
attach(): Promise<string>;
|
|
179
|
+
attach(props?: ContainerAttachProps): Promise<string>;
|
|
170
180
|
|
|
171
181
|
/**
|
|
172
182
|
* Attempts to connect the container to the delta stream and process operations.
|
|
@@ -176,7 +186,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
176
186
|
* @remarks
|
|
177
187
|
*
|
|
178
188
|
* This should only be called when the container is in the
|
|
179
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
189
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
|
|
180
190
|
*
|
|
181
191
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
182
192
|
*/
|
|
@@ -188,7 +198,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
188
198
|
* @remarks
|
|
189
199
|
*
|
|
190
200
|
* This should only be called when the container is in the
|
|
191
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
201
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
|
|
192
202
|
*
|
|
193
203
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
194
204
|
*/
|
|
@@ -216,6 +226,8 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
216
226
|
}
|
|
217
227
|
|
|
218
228
|
/**
|
|
229
|
+
* Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.
|
|
230
|
+
*
|
|
219
231
|
* @internal
|
|
220
232
|
*/
|
|
221
233
|
export function createFluidContainer<
|
|
@@ -242,12 +254,12 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
|
242
254
|
extends TypedEventEmitter<IFluidContainerEvents>
|
|
243
255
|
implements IFluidContainer<TContainerSchema>
|
|
244
256
|
{
|
|
245
|
-
private readonly connectedHandler = () => this.emit("connected");
|
|
246
|
-
private readonly disconnectedHandler = () => this.emit("disconnected");
|
|
247
|
-
private readonly disposedHandler = (error?: ICriticalContainerError) =>
|
|
257
|
+
private readonly connectedHandler = (): boolean => this.emit("connected");
|
|
258
|
+
private readonly disconnectedHandler = (): boolean => this.emit("disconnected");
|
|
259
|
+
private readonly disposedHandler = (error?: ICriticalContainerError): boolean =>
|
|
248
260
|
this.emit("disposed", error);
|
|
249
|
-
private readonly savedHandler = () => this.emit("saved");
|
|
250
|
-
private readonly dirtyHandler = () => this.emit("dirty");
|
|
261
|
+
private readonly savedHandler = (): boolean => this.emit("saved");
|
|
262
|
+
private readonly dirtyHandler = (): boolean => this.emit("dirty");
|
|
251
263
|
|
|
252
264
|
public constructor(
|
|
253
265
|
private readonly container: IContainer,
|
|
@@ -278,7 +290,7 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
|
278
290
|
/**
|
|
279
291
|
* {@inheritDoc IFluidContainer.disposed}
|
|
280
292
|
*/
|
|
281
|
-
public get disposed() {
|
|
293
|
+
public get disposed(): boolean {
|
|
282
294
|
return this.container.closed;
|
|
283
295
|
}
|
|
284
296
|
|
|
@@ -308,7 +320,7 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
|
308
320
|
* The reason is because externally we are presenting a separation between the service and the `FluidContainer`,
|
|
309
321
|
* but internally this separation is not there.
|
|
310
322
|
*/
|
|
311
|
-
public async attach(): Promise<string> {
|
|
323
|
+
public async attach(props?: ContainerAttachProps): Promise<string> {
|
|
312
324
|
if (this.container.attachState !== AttachState.Detached) {
|
|
313
325
|
throw new Error("Cannot attach container. Container is not in detached state.");
|
|
314
326
|
}
|
|
@@ -339,7 +351,7 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
|
339
351
|
/**
|
|
340
352
|
* {@inheritDoc IFluidContainer.dispose}
|
|
341
353
|
*/
|
|
342
|
-
public dispose() {
|
|
354
|
+
public dispose(): void {
|
|
343
355
|
this.container.close();
|
|
344
356
|
this.container.off("connected", this.connectedHandler);
|
|
345
357
|
this.container.off("closed", this.disposedHandler);
|
package/src/index.ts
CHANGED
|
@@ -11,26 +11,27 @@
|
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
13
|
createFluidContainer,
|
|
14
|
-
IFluidContainer,
|
|
15
|
-
IFluidContainerEvents,
|
|
16
|
-
InitialObjects,
|
|
17
|
-
} from "./fluidContainer";
|
|
18
|
-
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject";
|
|
19
|
-
export { createServiceAudience } from "./serviceAudience";
|
|
14
|
+
type IFluidContainer,
|
|
15
|
+
type IFluidContainerEvents,
|
|
16
|
+
type InitialObjects,
|
|
17
|
+
} from "./fluidContainer.js";
|
|
18
|
+
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
|
|
19
|
+
export { createServiceAudience } from "./serviceAudience.js";
|
|
20
20
|
export {
|
|
21
|
-
ContainerSchema,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
type ContainerSchema,
|
|
22
|
+
type ContainerAttachProps,
|
|
23
|
+
type DataObjectClass,
|
|
24
|
+
type IConnection,
|
|
25
|
+
type IMember,
|
|
26
|
+
type IRootDataObject,
|
|
27
|
+
type IServiceAudience,
|
|
28
|
+
type IServiceAudienceEvents,
|
|
29
|
+
type LoadableObjectClass,
|
|
30
|
+
type LoadableObjectClassRecord,
|
|
31
|
+
type LoadableObjectCtor,
|
|
32
|
+
type LoadableObjectRecord,
|
|
33
|
+
type MemberChangedListener,
|
|
34
|
+
type Myself,
|
|
35
|
+
type SharedObjectClass,
|
|
36
|
+
type IProvideRootDataObject,
|
|
37
|
+
} from "./types.js";
|
package/src/rootDataObject.ts
CHANGED
|
@@ -7,26 +7,33 @@ import {
|
|
|
7
7
|
DataObject,
|
|
8
8
|
DataObjectFactory,
|
|
9
9
|
} from "@fluidframework/aqueduct";
|
|
10
|
-
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
11
|
-
import {
|
|
10
|
+
import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
11
|
+
import {
|
|
12
|
+
type FluidObject,
|
|
13
|
+
type IFluidLoadable,
|
|
14
|
+
type IRequest,
|
|
15
|
+
type IResponse,
|
|
16
|
+
} from "@fluidframework/core-interfaces";
|
|
12
17
|
import { FlushMode } from "@fluidframework/runtime-definitions";
|
|
13
|
-
import { IRuntimeFactory } from "@fluidframework/container-definitions";
|
|
18
|
+
import { type IRuntimeFactory } from "@fluidframework/container-definitions";
|
|
14
19
|
import { RequestParser } from "@fluidframework/runtime-utils";
|
|
15
|
-
import { ContainerRuntime } from "@fluidframework/container-runtime";
|
|
20
|
+
import { type ContainerRuntime } from "@fluidframework/container-runtime";
|
|
21
|
+
import { type IDirectory } from "@fluidframework/map";
|
|
22
|
+
|
|
16
23
|
import {
|
|
17
|
-
ContainerSchema,
|
|
18
|
-
IRootDataObject,
|
|
19
|
-
LoadableObjectClass,
|
|
20
|
-
LoadableObjectClassRecord,
|
|
21
|
-
LoadableObjectRecord,
|
|
22
|
-
SharedObjectClass,
|
|
23
|
-
} from "./types";
|
|
24
|
+
type ContainerSchema,
|
|
25
|
+
type IRootDataObject,
|
|
26
|
+
type LoadableObjectClass,
|
|
27
|
+
type LoadableObjectClassRecord,
|
|
28
|
+
type LoadableObjectRecord,
|
|
29
|
+
type SharedObjectClass,
|
|
30
|
+
} from "./types.js";
|
|
24
31
|
import {
|
|
25
|
-
InternalDataObjectClass,
|
|
32
|
+
type InternalDataObjectClass,
|
|
26
33
|
isDataObjectClass,
|
|
27
34
|
isSharedObjectClass,
|
|
28
35
|
parseDataObjectsFromSharedObjects,
|
|
29
|
-
} from "./utils";
|
|
36
|
+
} from "./utils.js";
|
|
30
37
|
|
|
31
38
|
/**
|
|
32
39
|
* Input props for {@link RootDataObject.initializingFirstTime}.
|
|
@@ -50,11 +57,12 @@ class RootDataObject
|
|
|
50
57
|
{
|
|
51
58
|
private readonly initialObjectsDirKey = "initial-objects-key";
|
|
52
59
|
private readonly _initialObjects: LoadableObjectRecord = {};
|
|
53
|
-
|
|
60
|
+
|
|
61
|
+
public get IRootDataObject(): IRootDataObject {
|
|
54
62
|
return this;
|
|
55
63
|
}
|
|
56
64
|
|
|
57
|
-
private get initialObjectsDir() {
|
|
65
|
+
private get initialObjectsDir(): IDirectory {
|
|
58
66
|
const dir = this.root.getSubDirectory(this.initialObjectsDirKey);
|
|
59
67
|
if (dir === undefined) {
|
|
60
68
|
throw new Error("InitialObjects sub-directory was not initialized");
|
|
@@ -68,18 +76,18 @@ class RootDataObject
|
|
|
68
76
|
*
|
|
69
77
|
* @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
|
|
70
78
|
*/
|
|
71
|
-
protected async initializingFirstTime(props: RootDataObjectProps) {
|
|
79
|
+
protected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {
|
|
72
80
|
this.root.createSubDirectory(this.initialObjectsDirKey);
|
|
73
81
|
|
|
74
82
|
// Create initial objects provided by the developer
|
|
75
83
|
const initialObjectsP: Promise<void>[] = [];
|
|
76
|
-
Object.entries(props.initialObjects)
|
|
77
|
-
const createObject = async () => {
|
|
78
|
-
const obj = await this.create(objectClass);
|
|
84
|
+
for (const [id, objectClass] of Object.entries(props.initialObjects)) {
|
|
85
|
+
const createObject = async (): Promise<void> => {
|
|
86
|
+
const obj = await this.create<IFluidLoadable>(objectClass);
|
|
79
87
|
this.initialObjectsDir.set(id, obj.handle);
|
|
80
88
|
};
|
|
81
89
|
initialObjectsP.push(createObject());
|
|
82
|
-
}
|
|
90
|
+
}
|
|
83
91
|
|
|
84
92
|
await Promise.all(initialObjectsP);
|
|
85
93
|
}
|
|
@@ -90,12 +98,13 @@ class RootDataObject
|
|
|
90
98
|
*
|
|
91
99
|
* @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
|
|
92
100
|
*/
|
|
93
|
-
protected async hasInitialized() {
|
|
101
|
+
protected async hasInitialized(): Promise<void> {
|
|
94
102
|
// We will always load the initial objects so they are available to the developer
|
|
95
103
|
const loadInitialObjectsP: Promise<void>[] = [];
|
|
96
|
-
for (const [key, value] of
|
|
97
|
-
const loadDir = async () => {
|
|
98
|
-
|
|
104
|
+
for (const [key, value] of this.initialObjectsDir.entries()) {
|
|
105
|
+
const loadDir = async (): Promise<void> => {
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
107
|
+
const obj: unknown = await value.get();
|
|
99
108
|
Object.assign(this._initialObjects, { [key]: obj });
|
|
100
109
|
};
|
|
101
110
|
loadInitialObjectsP.push(loadDir());
|
|
@@ -148,6 +157,9 @@ class RootDataObject
|
|
|
148
157
|
const rootDataStoreId = "rootDOId";
|
|
149
158
|
|
|
150
159
|
/**
|
|
160
|
+
* Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single
|
|
161
|
+
* {@link IRootDataObject}, which is constructed from the provided schema.
|
|
162
|
+
*
|
|
151
163
|
* @internal
|
|
152
164
|
*/
|
|
153
165
|
export function createDOProviderContainerRuntimeFactory(props: {
|
|
@@ -176,7 +188,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
176
188
|
|
|
177
189
|
private readonly initialObjects: LoadableObjectClassRecord;
|
|
178
190
|
|
|
179
|
-
constructor(schema: ContainerSchema) {
|
|
191
|
+
public constructor(schema: ContainerSchema) {
|
|
180
192
|
const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
|
|
181
193
|
const rootDataObjectFactory = new DataObjectFactory(
|
|
182
194
|
"rootDO",
|
|
@@ -185,7 +197,10 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
185
197
|
{},
|
|
186
198
|
registryEntries,
|
|
187
199
|
);
|
|
188
|
-
const provideEntryPoint = async (
|
|
200
|
+
const provideEntryPoint = async (
|
|
201
|
+
containerRuntime: IContainerRuntime,
|
|
202
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
203
|
+
): Promise<FluidObject> => {
|
|
189
204
|
const entryPoint =
|
|
190
205
|
await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
|
|
191
206
|
if (entryPoint === undefined) {
|
|
@@ -193,7 +208,11 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
193
208
|
}
|
|
194
209
|
return entryPoint.get();
|
|
195
210
|
};
|
|
196
|
-
const getDefaultObject = async (
|
|
211
|
+
const getDefaultObject = async (
|
|
212
|
+
request: IRequest,
|
|
213
|
+
runtime: IContainerRuntime,
|
|
214
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
215
|
+
): Promise<IResponse | undefined> => {
|
|
197
216
|
const parser = RequestParser.create(request);
|
|
198
217
|
if (parser.pathParts.length === 0) {
|
|
199
218
|
// This cast is safe as ContainerRuntime.loadRuntime is called in the base class
|
|
@@ -212,7 +231,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
212
231
|
// resolution progress is tracked by the Feature 465 work item in AzDO
|
|
213
232
|
flushMode: FlushMode.Immediate,
|
|
214
233
|
// The runtime compressor is required to be on to use @fluidframework/tree.
|
|
215
|
-
enableRuntimeIdCompressor:
|
|
234
|
+
enableRuntimeIdCompressor: "on",
|
|
216
235
|
},
|
|
217
236
|
provideEntryPoint,
|
|
218
237
|
});
|
|
@@ -223,7 +242,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
223
242
|
/**
|
|
224
243
|
* {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}
|
|
225
244
|
*/
|
|
226
|
-
protected async containerInitializingFirstTime(runtime: IContainerRuntime) {
|
|
245
|
+
protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {
|
|
227
246
|
// The first time we create the container we create the RootDataObject
|
|
228
247
|
await this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {
|
|
229
248
|
initialObjects: this.initialObjects,
|
package/src/serviceAudience.ts
CHANGED
|
@@ -4,17 +4,29 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
7
|
-
import { IAudience, IContainer } from "@fluidframework/container-definitions";
|
|
8
|
-
import { IClient } from "@fluidframework/protocol-definitions";
|
|
9
|
-
import {
|
|
7
|
+
import { type IAudience, type IContainer } from "@fluidframework/container-definitions";
|
|
8
|
+
import { type IClient } from "@fluidframework/protocol-definitions";
|
|
9
|
+
import {
|
|
10
|
+
type IServiceAudience,
|
|
11
|
+
type IServiceAudienceEvents,
|
|
12
|
+
type IMember,
|
|
13
|
+
type Myself,
|
|
14
|
+
} from "./types.js";
|
|
10
15
|
|
|
11
16
|
/**
|
|
17
|
+
* Creates a service audience for the provided container.
|
|
18
|
+
*
|
|
19
|
+
* @param container - The container with which the audience is associated.
|
|
20
|
+
* @param createServiceMember - A function for creating audience members.
|
|
21
|
+
*
|
|
22
|
+
* @typeParam TMember - The {@link IMember} representation used by the audience.
|
|
23
|
+
*
|
|
12
24
|
* @internal
|
|
13
25
|
*/
|
|
14
|
-
export function createServiceAudience<
|
|
26
|
+
export function createServiceAudience<TMember extends IMember = IMember>(props: {
|
|
15
27
|
container: IContainer;
|
|
16
|
-
createServiceMember: (audienceMember: IClient) =>
|
|
17
|
-
}): IServiceAudience<
|
|
28
|
+
createServiceMember: (audienceMember: IClient) => TMember;
|
|
29
|
+
}): IServiceAudience<TMember> {
|
|
18
30
|
return new ServiceAudience(props.container, props.createServiceMember);
|
|
19
31
|
}
|
|
20
32
|
|
|
@@ -26,12 +38,13 @@ export function createServiceAudience<M extends IMember = IMember>(props: {
|
|
|
26
38
|
* This can be extended by different service-specific client packages to additional parameters to
|
|
27
39
|
* the user and client details returned in {@link IMember}.
|
|
28
40
|
*
|
|
29
|
-
* @typeParam
|
|
41
|
+
* @typeParam TMember - A service-specific {@link IMember} implementation.
|
|
42
|
+
*
|
|
30
43
|
* @internal
|
|
31
44
|
*/
|
|
32
|
-
class ServiceAudience<
|
|
33
|
-
extends TypedEventEmitter<IServiceAudienceEvents<
|
|
34
|
-
implements IServiceAudience<
|
|
45
|
+
class ServiceAudience<TMember extends IMember = IMember>
|
|
46
|
+
extends TypedEventEmitter<IServiceAudienceEvents<TMember>>
|
|
47
|
+
implements IServiceAudience<TMember>
|
|
35
48
|
{
|
|
36
49
|
/**
|
|
37
50
|
* Audience object which includes all the existing members of the {@link IFluidContainer | container}.
|
|
@@ -55,14 +68,14 @@ class ServiceAudience<M extends IMember = IMember>
|
|
|
55
68
|
* every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}
|
|
56
69
|
* events provide.
|
|
57
70
|
*/
|
|
58
|
-
private lastMembers = new Map<string,
|
|
71
|
+
private lastMembers = new Map<string, TMember>();
|
|
59
72
|
|
|
60
|
-
constructor(
|
|
73
|
+
public constructor(
|
|
61
74
|
/**
|
|
62
75
|
* Fluid Container to read the audience from.
|
|
63
76
|
*/
|
|
64
77
|
private readonly container: IContainer,
|
|
65
|
-
private readonly createServiceMember: (audienceMember: IClient) =>
|
|
78
|
+
private readonly createServiceMember: (audienceMember: IClient) => TMember,
|
|
66
79
|
) {
|
|
67
80
|
super();
|
|
68
81
|
this.audience = container.audience;
|
|
@@ -92,11 +105,11 @@ class ServiceAudience<M extends IMember = IMember>
|
|
|
92
105
|
/**
|
|
93
106
|
* {@inheritDoc IServiceAudience.getMembers}
|
|
94
107
|
*/
|
|
95
|
-
public getMembers(): Map<string,
|
|
96
|
-
const users = new Map<string,
|
|
97
|
-
const clientMemberMap = new Map<string,
|
|
108
|
+
public getMembers(): Map<string, TMember> {
|
|
109
|
+
const users = new Map<string, TMember>();
|
|
110
|
+
const clientMemberMap = new Map<string, TMember>();
|
|
98
111
|
// Iterate through the members and get the user specifics.
|
|
99
|
-
this.audience.getMembers()
|
|
112
|
+
for (const [clientId, member] of this.audience.getMembers()) {
|
|
100
113
|
if (this.shouldIncludeAsMember(member)) {
|
|
101
114
|
const userId = member.user.id;
|
|
102
115
|
// Ensure we're tracking the user
|
|
@@ -110,7 +123,7 @@ class ServiceAudience<M extends IMember = IMember>
|
|
|
110
123
|
user.connections.push({ id: clientId, mode: member.mode });
|
|
111
124
|
clientMemberMap.set(clientId, user);
|
|
112
125
|
}
|
|
113
|
-
}
|
|
126
|
+
}
|
|
114
127
|
this.lastMembers = clientMemberMap;
|
|
115
128
|
return users;
|
|
116
129
|
}
|
|
@@ -118,7 +131,7 @@ class ServiceAudience<M extends IMember = IMember>
|
|
|
118
131
|
/**
|
|
119
132
|
* {@inheritDoc IServiceAudience.getMyself}
|
|
120
133
|
*/
|
|
121
|
-
public getMyself(): Myself<
|
|
134
|
+
public getMyself(): Myself<TMember> | undefined {
|
|
122
135
|
const clientId = this.container.clientId;
|
|
123
136
|
if (clientId === undefined) {
|
|
124
137
|
return undefined;
|
|
@@ -129,12 +142,12 @@ class ServiceAudience<M extends IMember = IMember>
|
|
|
129
142
|
return undefined;
|
|
130
143
|
}
|
|
131
144
|
|
|
132
|
-
const myself: Myself<
|
|
145
|
+
const myself: Myself<TMember> = { ...member, currentConnection: clientId };
|
|
133
146
|
|
|
134
147
|
return myself;
|
|
135
148
|
}
|
|
136
149
|
|
|
137
|
-
private getMember(clientId: string):
|
|
150
|
+
private getMember(clientId: string): TMember | undefined {
|
|
138
151
|
// Fetch the user ID assoicated with this client ID from the runtime
|
|
139
152
|
const internalAudienceMember = this.audience.getMember(clientId);
|
|
140
153
|
if (internalAudienceMember === undefined) {
|
|
@@ -144,7 +157,7 @@ class ServiceAudience<M extends IMember = IMember>
|
|
|
144
157
|
const allMembers = this.getMembers();
|
|
145
158
|
const member = allMembers.get(internalAudienceMember?.user.id);
|
|
146
159
|
if (member === undefined) {
|
|
147
|
-
throw Error(
|
|
160
|
+
throw new Error(
|
|
148
161
|
`Attempted to fetch client ${clientId} that is not part of the current member list`,
|
|
149
162
|
);
|
|
150
163
|
}
|