@fluidframework/fluid-static 2.0.0-dev-rc.1.0.0.225277 → 2.0.0-dev-rc.1.0.0.232845
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/CHANGELOG.md +34 -0
- package/README.md +0 -6
- package/api-report/fluid-static.api.md +10 -7
- package/dist/fluid-static-alpha.d.ts +11 -4
- package/dist/fluid-static-beta.d.ts +11 -4
- package/dist/fluid-static-public.d.ts +11 -4
- package/dist/fluid-static-untrimmed.d.ts +26 -7
- package/dist/fluidContainer.d.ts +9 -6
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/{fluidContainer.cjs → fluidContainer.js} +4 -2
- package/dist/fluidContainer.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/{index.cjs → index.js} +4 -4
- package/dist/index.js.map +1 -0
- package/dist/rootDataObject.d.ts +5 -2
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/{rootDataObject.cjs → rootDataObject.js} +16 -8
- package/dist/rootDataObject.js.map +1 -0
- package/dist/serviceAudience.d.ts +13 -6
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/{serviceAudience.cjs → serviceAudience.js} +13 -5
- package/dist/serviceAudience.js.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types.d.ts +8 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/{types.cjs → types.js} +1 -1
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +6 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/{utils.cjs → utils.js} +7 -4
- package/dist/utils.js.map +1 -0
- package/lib/fluid-static-alpha.d.mts +11 -4
- package/lib/fluid-static-beta.d.mts +11 -4
- package/lib/fluid-static-public.d.mts +11 -4
- package/lib/fluid-static-untrimmed.d.mts +26 -7
- package/lib/fluidContainer.d.mts +9 -6
- package/lib/fluidContainer.d.mts.map +1 -1
- package/lib/fluidContainer.mjs +3 -1
- package/lib/fluidContainer.mjs.map +1 -1
- package/lib/index.d.mts +2 -2
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/rootDataObject.d.mts +5 -2
- package/lib/rootDataObject.d.mts.map +1 -1
- package/lib/rootDataObject.mjs +14 -6
- package/lib/rootDataObject.mjs.map +1 -1
- package/lib/serviceAudience.d.mts +13 -6
- package/lib/serviceAudience.d.mts.map +1 -1
- package/lib/serviceAudience.mjs +12 -4
- package/lib/serviceAudience.mjs.map +1 -1
- package/lib/types.d.mts +8 -3
- package/lib/types.d.mts.map +1 -1
- package/lib/types.mjs.map +1 -1
- package/lib/utils.d.mts +6 -6
- package/lib/utils.d.mts.map +1 -1
- package/lib/utils.mjs +6 -3
- package/lib/utils.mjs.map +1 -1
- package/package.json +29 -29
- package/src/fluidContainer.ts +28 -16
- package/src/index.ts +19 -18
- package/src/rootDataObject.ts +52 -29
- package/src/serviceAudience.ts +35 -22
- package/src/types.ts +16 -3
- package/src/utils.ts +15 -12
- package/dist/fluidContainer.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/rootDataObject.cjs.map +0 -1
- package/dist/serviceAudience.cjs.map +0 -1
- package/dist/types.cjs.map +0 -1
- package/dist/utils.cjs.map +0 -1
- package/tsc-multi.test.json +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.0.0-dev-rc.1.0.0.
|
|
3
|
+
"version": "2.0.0-dev-rc.1.0.0.232845",
|
|
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": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"require": {
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
|
-
"default": "./dist/index.
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"./alpha": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"require": {
|
|
31
31
|
"types": "./dist/fluid-static-alpha.d.ts",
|
|
32
|
-
"default": "./dist/index.
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"./beta": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"require": {
|
|
41
41
|
"types": "./dist/fluid-static-beta.d.ts",
|
|
42
|
-
"default": "./dist/index.
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"./internal": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"require": {
|
|
51
51
|
"types": "./dist/index.d.ts",
|
|
52
|
-
"default": "./dist/index.
|
|
52
|
+
"default": "./dist/index.js"
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"./public": {
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
},
|
|
60
60
|
"require": {
|
|
61
61
|
"types": "./dist/fluid-static-public.d.ts",
|
|
62
|
-
"default": "./dist/index.
|
|
62
|
+
"default": "./dist/index.js"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"main": "dist/index.
|
|
66
|
+
"main": "dist/index.js",
|
|
67
67
|
"module": "lib/index.mjs",
|
|
68
68
|
"types": "dist/index.d.ts",
|
|
69
69
|
"c8": {
|
|
@@ -87,30 +87,30 @@
|
|
|
87
87
|
"temp-directory": "nyc/.nyc_output"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@fluid-internal/client-utils": "2.0.0-dev-rc.1.0.0.
|
|
91
|
-
"@fluidframework/aqueduct": "2.0.0-dev-rc.1.0.0.
|
|
92
|
-
"@fluidframework/container-definitions": "2.0.0-dev-rc.1.0.0.
|
|
93
|
-
"@fluidframework/container-loader": "2.0.0-dev-rc.1.0.0.
|
|
94
|
-
"@fluidframework/container-runtime": "2.0.0-dev-rc.1.0.0.
|
|
95
|
-
"@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.1.0.0.
|
|
96
|
-
"@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.
|
|
97
|
-
"@fluidframework/datastore-definitions": "2.0.0-dev-rc.1.0.0.
|
|
98
|
-
"@fluidframework/protocol-definitions": "^3.
|
|
99
|
-
"@fluidframework/request-handler": "2.0.0-dev-rc.1.0.0.
|
|
100
|
-
"@fluidframework/runtime-definitions": "2.0.0-dev-rc.1.0.0.
|
|
101
|
-
"@fluidframework/runtime-utils": "2.0.0-dev-rc.1.0.0.
|
|
90
|
+
"@fluid-internal/client-utils": "2.0.0-dev-rc.1.0.0.232845",
|
|
91
|
+
"@fluidframework/aqueduct": "2.0.0-dev-rc.1.0.0.232845",
|
|
92
|
+
"@fluidframework/container-definitions": "2.0.0-dev-rc.1.0.0.232845",
|
|
93
|
+
"@fluidframework/container-loader": "2.0.0-dev-rc.1.0.0.232845",
|
|
94
|
+
"@fluidframework/container-runtime": "2.0.0-dev-rc.1.0.0.232845",
|
|
95
|
+
"@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.1.0.0.232845",
|
|
96
|
+
"@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.232845",
|
|
97
|
+
"@fluidframework/datastore-definitions": "2.0.0-dev-rc.1.0.0.232845",
|
|
98
|
+
"@fluidframework/protocol-definitions": "^3.2.0-231454",
|
|
99
|
+
"@fluidframework/request-handler": "2.0.0-dev-rc.1.0.0.232845",
|
|
100
|
+
"@fluidframework/runtime-definitions": "2.0.0-dev-rc.1.0.0.232845",
|
|
101
|
+
"@fluidframework/runtime-utils": "2.0.0-dev-rc.1.0.0.232845"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@arethetypeswrong/cli": "^0.13.3",
|
|
105
|
-
"@fluid-tools/build-cli": "0.29.0
|
|
105
|
+
"@fluid-tools/build-cli": "^0.29.0",
|
|
106
106
|
"@fluidframework/build-common": "^2.0.3",
|
|
107
|
-
"@fluidframework/build-tools": "0.29.0
|
|
108
|
-
"@fluidframework/eslint-config-fluid": "^3.
|
|
107
|
+
"@fluidframework/build-tools": "^0.29.0",
|
|
108
|
+
"@fluidframework/eslint-config-fluid": "^3.3.0",
|
|
109
109
|
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.8.0.0",
|
|
110
|
-
"@fluidframework/map": "2.0.0-dev-rc.1.0.0.
|
|
111
|
-
"@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.
|
|
112
|
-
"@fluidframework/sequence": "2.0.0-dev-rc.1.0.0.
|
|
113
|
-
"@microsoft/api-extractor": "^7.
|
|
110
|
+
"@fluidframework/map": "2.0.0-dev-rc.1.0.0.232845",
|
|
111
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.232845",
|
|
112
|
+
"@fluidframework/sequence": "2.0.0-dev-rc.1.0.0.232845",
|
|
113
|
+
"@microsoft/api-extractor": "^7.39.1",
|
|
114
114
|
"@types/mocha": "^9.1.1",
|
|
115
115
|
"@types/node": "^18.19.0",
|
|
116
116
|
"c8": "^8.0.1",
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"build:compile": "fluid-build . --task compile",
|
|
151
151
|
"build:docs": "fluid-build . --task api",
|
|
152
152
|
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
|
|
153
|
-
"build:test": "tsc
|
|
153
|
+
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
154
154
|
"check:are-the-types-wrong": "attw --pack . --entrypoints .",
|
|
155
155
|
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
156
156
|
"ci:build:docs": "api-extractor run",
|
|
@@ -164,9 +164,9 @@
|
|
|
164
164
|
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
165
165
|
"test": "npm run test:mocha",
|
|
166
166
|
"test:coverage": "c8 npm test",
|
|
167
|
-
"test:mocha": "mocha --recursive \"dist/test/**/*.spec
|
|
167
|
+
"test:mocha": "mocha --recursive \"dist/test/**/*.spec.*js\" -r node_modules/@fluidframework/mocha-test-setup",
|
|
168
168
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
169
|
-
"tsc": "tsc
|
|
169
|
+
"tsc": "tsc",
|
|
170
170
|
"typetests:gen": "fluid-type-test-generator",
|
|
171
171
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
172
172
|
}
|
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";
|
|
14
23
|
|
|
15
24
|
/**
|
|
16
25
|
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
@@ -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,
|
|
14
|
+
type IFluidContainer,
|
|
15
|
+
type IFluidContainerEvents,
|
|
16
|
+
type InitialObjects,
|
|
17
17
|
} from "./fluidContainer";
|
|
18
18
|
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject";
|
|
19
19
|
export { createServiceAudience } from "./serviceAudience";
|
|
20
20
|
export {
|
|
21
|
-
ContainerSchema,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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,
|
|
36
37
|
} from "./types";
|
package/src/rootDataObject.ts
CHANGED
|
@@ -7,22 +7,29 @@ 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,
|
|
24
|
+
type ContainerSchema,
|
|
25
|
+
type IRootDataObject,
|
|
26
|
+
type LoadableObjectClass,
|
|
27
|
+
type LoadableObjectClassRecord,
|
|
28
|
+
type LoadableObjectRecord,
|
|
29
|
+
type SharedObjectClass,
|
|
23
30
|
} from "./types";
|
|
24
31
|
import {
|
|
25
|
-
InternalDataObjectClass,
|
|
32
|
+
type InternalDataObjectClass,
|
|
26
33
|
isDataObjectClass,
|
|
27
34
|
isSharedObjectClass,
|
|
28
35
|
parseDataObjectsFromSharedObjects,
|
|
@@ -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
|
|
@@ -207,9 +226,13 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
207
226
|
super({
|
|
208
227
|
registryEntries: [rootDataObjectFactory.registryEntry],
|
|
209
228
|
requestHandlers: [getDefaultObject],
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
229
|
+
runtimeOptions: {
|
|
230
|
+
// temporary workaround to disable message batching until the message batch size issue is resolved
|
|
231
|
+
// resolution progress is tracked by the Feature 465 work item in AzDO
|
|
232
|
+
flushMode: FlushMode.Immediate,
|
|
233
|
+
// The runtime compressor is required to be on to use @fluidframework/tree.
|
|
234
|
+
enableRuntimeIdCompressor: true,
|
|
235
|
+
},
|
|
213
236
|
provideEntryPoint,
|
|
214
237
|
});
|
|
215
238
|
this.rootDataObjectFactory = rootDataObjectFactory;
|
|
@@ -219,7 +242,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
219
242
|
/**
|
|
220
243
|
* {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}
|
|
221
244
|
*/
|
|
222
|
-
protected async containerInitializingFirstTime(runtime: IContainerRuntime) {
|
|
245
|
+
protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {
|
|
223
246
|
// The first time we create the container we create the RootDataObject
|
|
224
247
|
await this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {
|
|
225
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";
|
|
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
|
}
|
package/src/types.ts
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
type IEvent,
|
|
8
|
+
type IEventProvider,
|
|
9
|
+
type IFluidLoadable,
|
|
10
|
+
} from "@fluidframework/core-interfaces";
|
|
11
|
+
import { type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
|
|
@@ -14,9 +18,10 @@ export type LoadableObjectRecord = Record<string, IFluidLoadable>;
|
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
17
|
-
* or `SharedObject
|
|
21
|
+
* or `SharedObject`.
|
|
18
22
|
* @public
|
|
19
23
|
*/
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
25
|
export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
21
26
|
|
|
22
27
|
/**
|
|
@@ -57,8 +62,15 @@ export type SharedObjectClass<T extends IFluidLoadable> = {
|
|
|
57
62
|
* @typeParam T - The class of the loadable object.
|
|
58
63
|
* @public
|
|
59
64
|
*/
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
66
|
export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
|
|
61
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Represents properties that can be attached to a container.
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export type ContainerAttachProps<T = unknown> = T;
|
|
73
|
+
|
|
62
74
|
/**
|
|
63
75
|
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
64
76
|
*
|
|
@@ -99,6 +111,7 @@ export interface ContainerSchema {
|
|
|
99
111
|
* For best practice it's recommended to define all the dynamic types you create even if they are
|
|
100
112
|
* included via initialObjects.
|
|
101
113
|
*/
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
115
|
dynamicObjectTypes?: LoadableObjectClass<any>[];
|
|
103
116
|
}
|
|
104
117
|
|