@fluidframework/fluid-static 2.40.0-336023 → 2.40.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/CHANGELOG.md +4 -0
- package/dist/compatibilityConfiguration.d.ts +7 -2
- package/dist/compatibilityConfiguration.d.ts.map +1 -1
- package/dist/compatibilityConfiguration.js +9 -27
- package/dist/compatibilityConfiguration.js.map +1 -1
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +13 -1
- package/dist/rootDataObject.js.map +1 -1
- package/lib/compatibilityConfiguration.d.ts +7 -2
- package/lib/compatibilityConfiguration.d.ts.map +1 -1
- package/lib/compatibilityConfiguration.js +9 -27
- package/lib/compatibilityConfiguration.js.map +1 -1
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +14 -2
- package/lib/rootDataObject.js.map +1 -1
- package/package.json +18 -18
- package/src/compatibilityConfiguration.ts +10 -31
- package/src/rootDataObject.ts +18 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import type { IContainerRuntimeOptionsInternal } from "@fluidframework/container-runtime/internal";
|
|
6
6
|
import type { CompatibilityMode } from "./types.js";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
|
|
9
|
+
* full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
|
|
10
|
+
*
|
|
11
|
+
* @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply
|
|
12
|
+
* the proper configurations. However, there are some options that we need to explicity set that differ
|
|
13
|
+
* from the default values (i.e. `enableRuntimeIdCompressor` below).
|
|
9
14
|
*/
|
|
10
15
|
export declare const compatibilityModeRuntimeOptions: Record<CompatibilityMode, IContainerRuntimeOptionsInternal>;
|
|
11
16
|
//# sourceMappingURL=compatibilityConfiguration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAEnG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,gCAAgC,CAShC,CAAC"}
|
|
@@ -5,39 +5,21 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.compatibilityModeRuntimeOptions = void 0;
|
|
8
|
-
const internal_1 = require("@fluidframework/container-runtime/internal");
|
|
9
|
-
const internal_2 = require("@fluidframework/runtime-definitions/internal");
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
9
|
+
* The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
|
|
10
|
+
* full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
|
|
11
|
+
*
|
|
12
|
+
* @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply
|
|
13
|
+
* the proper configurations. However, there are some options that we need to explicity set that differ
|
|
14
|
+
* from the default values (i.e. `enableRuntimeIdCompressor` below).
|
|
12
15
|
*/
|
|
13
16
|
exports.compatibilityModeRuntimeOptions = {
|
|
14
|
-
"1": {
|
|
15
|
-
// 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode
|
|
16
|
-
// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as
|
|
17
|
-
// fewer messages will be included per flush.
|
|
18
|
-
flushMode: internal_2.FlushMode.Immediate,
|
|
19
|
-
// Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.
|
|
20
|
-
compressionOptions: {
|
|
21
|
-
minimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled
|
|
22
|
-
compressionAlgorithm: internal_1.CompressionAlgorithms.lz4,
|
|
23
|
-
},
|
|
24
|
-
// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.
|
|
25
|
-
enableGroupedBatching: false,
|
|
26
|
-
// TODO: Include explicit disables for things that are currently off-by-default?
|
|
27
|
-
// Explicitly disable running Sweep in compat mode "1". Sweep is supported only in 2.x. So, when 1.x and 2.x
|
|
28
|
-
// clients are running in parallel, running sweep will fail 1.x clients.
|
|
29
|
-
gcOptions: { enableGCSweep: undefined },
|
|
30
|
-
},
|
|
17
|
+
"1": {},
|
|
31
18
|
"2": {
|
|
32
|
-
// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their
|
|
33
|
-
// ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.
|
|
34
|
-
explicitSchemaControl: true,
|
|
35
19
|
// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.
|
|
36
|
-
//
|
|
20
|
+
// In general, we don't want to enable this by default since it increases the bundle size. However, since SharedTree
|
|
21
|
+
// is bundled with the fluid-framework package, we need to enable it here to support SharedTree.
|
|
37
22
|
enableRuntimeIdCompressor: "on",
|
|
38
|
-
// Explicitly disable running Sweep in compat mode "2". Although sweep is supported in 2.x, it is disabled by default.
|
|
39
|
-
// This setting explicitly disables it to be extra safe.
|
|
40
|
-
gcOptions: { enableGCSweep: undefined },
|
|
41
23
|
},
|
|
42
24
|
};
|
|
43
25
|
//# sourceMappingURL=compatibilityConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;;;;;GAOG;AACU,QAAA,+BAA+B,GAGxC;IACH,GAAG,EAAE,EAAE;IACP,GAAG,EAAE;QACJ,sHAAsH;QACtH,oHAAoH;QACpH,gGAAgG;QAChG,yBAAyB,EAAE,IAAI;KAC/B;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IContainerRuntimeOptionsInternal } from \"@fluidframework/container-runtime/internal\";\n\nimport type { CompatibilityMode } from \"./types.js\";\n\n/**\n * The CompatibilityMode selected determines the set of runtime options to use. In \"1\" mode we support\n * full interop with true 1.x clients, while in \"2\" mode we only support interop with 2.x clients.\n *\n * @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply\n * the proper configurations. However, there are some options that we need to explicity set that differ\n * from the default values (i.e. `enableRuntimeIdCompressor` below).\n */\nexport const compatibilityModeRuntimeOptions: Record<\n\tCompatibilityMode,\n\tIContainerRuntimeOptionsInternal\n> = {\n\t\"1\": {},\n\t\"2\": {\n\t\t// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.\n\t\t// In general, we don't want to enable this by default since it increases the bundle size. However, since SharedTree\n\t\t// is bundled with the fluid-framework package, we need to enable it here to support SharedTree.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t},\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAStF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAO5F,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAKf,MAAM,YAAY,CAAC;AA2IpB;;;;;;GAMG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,uBAAuB,CAAC;CAChD,GAAG,eAAe,CASlB"}
|
package/dist/rootDataObject.js
CHANGED
|
@@ -9,6 +9,13 @@ const internal_1 = require("@fluidframework/aqueduct/internal");
|
|
|
9
9
|
const internal_2 = require("@fluidframework/container-runtime/internal");
|
|
10
10
|
const compatibilityConfiguration_js_1 = require("./compatibilityConfiguration.js");
|
|
11
11
|
const utils_js_1 = require("./utils.js");
|
|
12
|
+
/**
|
|
13
|
+
* Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
|
|
14
|
+
*/
|
|
15
|
+
const compatibilityModeToMinVersionForCollab = {
|
|
16
|
+
"1": "1.0.0",
|
|
17
|
+
"2": "2.0.0",
|
|
18
|
+
};
|
|
12
19
|
/**
|
|
13
20
|
* The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
|
|
14
21
|
* Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
|
|
@@ -147,6 +154,7 @@ class DOProviderContainerRuntimeFactory extends internal_1.BaseContainerRuntimeF
|
|
|
147
154
|
registryEntries: [rootDataObjectFactory.registryEntry],
|
|
148
155
|
runtimeOptions: compatibilityConfiguration_js_1.compatibilityModeRuntimeOptions[compatibilityMode],
|
|
149
156
|
provideEntryPoint,
|
|
157
|
+
minVersionForCollab: compatibilityModeToMinVersionForCollab[compatibilityMode],
|
|
150
158
|
});
|
|
151
159
|
this.rootDataObjectFactory = rootDataObjectFactory;
|
|
152
160
|
this.initialObjects = schema.initialObjects;
|
|
@@ -168,7 +176,11 @@ class RootDataObjectFactory extends internal_1.DataObjectFactory {
|
|
|
168
176
|
constructor(sharedObjects = [], dataStoreRegistry) {
|
|
169
177
|
// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,
|
|
170
178
|
// and instead we override the necessary methods in this class to use the registry received in the constructor.
|
|
171
|
-
super(
|
|
179
|
+
super({
|
|
180
|
+
type: "rootDO",
|
|
181
|
+
ctor: RootDataObject,
|
|
182
|
+
sharedObjects,
|
|
183
|
+
});
|
|
172
184
|
this.dataStoreRegistry = dataStoreRegistry;
|
|
173
185
|
}
|
|
174
186
|
get IFluidDataStoreRegistry() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAK2C;AAE3C,yEAAoF;AAWpF,mFAAkF;AASlF,yCAIoB;AAcpB;;;GAGG;AACH,MAAM,cACL,SAAQ,qBAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IAmG7D,CAAC;IAjGA,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAA0B;QAC/D,IAAI,CAAC,IAAI,CAAC,kBAAkB,CA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;YAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;SACnC,CAAC,CAAC;IACJ,CAAC;CACD;AAED;;GAEG;AACH,MAAM,qBAAsB,SAAQ,4BAGnC;IACA,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAE3D,2GAA2G;QAC3G,+GAA+G;QAC/G,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;QAJ7C,sBAAiB,GAAjB,iBAAiB,CAAyB;IAK5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\ttype DataObjectKind,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport { FluidDataStoreRegistry } from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { FluidObject, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreRegistry } from \"@fluidframework/runtime-definitions/internal\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tIRootDataObject,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\ninterface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\treadonly initialObjects: LoadableObjectKindRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get IRootDataObject(): IRootDataObject {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir(): IDirectory {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tfor (const [id, objectClass] of Object.entries(props.initialObjects)) {\n\t\t\tconst createObject = async (): Promise<void> => {\n\t\t\t\tconst obj = await this.create<IFluidLoadable>(\n\t\t\t\t\tobjectClass as SharedObjectKind<IFluidLoadable>,\n\t\t\t\t);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t}\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized(): Promise<void> {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of this.initialObjectsDir.entries()) {\n\t\t\tconst loadDir = async (): Promise<void> => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\tconst obj: unknown = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.initialObjects}\n\t */\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.create}\n\t */\n\tpublic async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\tconst internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;\n\t\tif (isDataObjectKind(internal)) {\n\t\t\treturn this.createDataObject(internal);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn this.createSharedObject(internal);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tprivate async createDataObject<T extends IFluidLoadable>(\n\t\tdataObjectClass: DataObjectKind<T>,\n\t): Promise<T> {\n\t\tconst factory = dataObjectClass.factory;\n\t\tconst packagePath = [...this.context.packagePath, factory.type];\n\t\tconst dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\treturn entryPoint as T;\n\t}\n\n\tprivate createSharedObject<T extends IFluidLoadable>(\n\t\tsharedObjectClass: ISharedObjectKind<T>,\n\t): T {\n\t\tconst factory = sharedObjectClass.getFactory();\n\t\tconst obj = this.runtime.createChannel(undefined, factory.type);\n\t\treturn obj as unknown as T;\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers\n * with a single {@link IRootDataObject} as their entry point, where the root data object's registry\n * and initial objects are configured based on the provided schema (and optionally, data store registry).\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\tschema: ContainerSchema;\n\t/**\n\t * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.\n\t */\n\tcompatibilityMode: CompatibilityMode;\n\t/**\n\t * Optional registry of data stores to pass to the DataObject factory.\n\t * If not provided, one will be created based on the schema.\n\t */\n\trootDataStoreRegistry?: IFluidDataStoreRegistry;\n}): IRuntimeFactory {\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);\n\tconst registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new DOProviderContainerRuntimeFactory(\n\t\tprops.schema,\n\t\tprops.compatibilityMode,\n\t\tnew RootDataObjectFactory(sharedObjects, registry),\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a single {@link IRootDataObject}\n * as their entry point.\n */\nclass DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectKindRecord;\n\n\t/**\n\t * Create a new instance of a container runtime factory.\n\t * @remarks\n\t * The caller is responsible for making sure that the provided root data object factory is configured\n\t * appropriately based on the schema of the container (e.g. its registry entries contain all the\n\t * DataStore/DDS types that the schema says can be constructed).\n\t *\n\t * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,\n\t * since it can take care of constructing the root data object factory based on the schema.\n\t *\n\t * @param schema - The schema for the container\n\t * @param compatibilityMode - Compatibility mode\n\t * @param rootDataObjectFactory - A factory that can construct the root data object.\n\t */\n\tpublic constructor(\n\t\tschema: ContainerSchema,\n\t\tcompatibilityMode: CompatibilityMode,\n\t\trootDataObjectFactory: DataObjectFactory<\n\t\t\tRootDataObject,\n\t\t\t{ InitialState: RootDataObjectProps }\n\t\t>,\n\t) {\n\t\tconst provideEntryPoint = async (\n\t\t\tcontainerRuntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<FluidObject> => {\n\t\t\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\tif (entryPoint === undefined) {\n\t\t\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t\t\t}\n\t\t\treturn entryPoint.get();\n\t\t};\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\tprovideEntryPoint,\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper(\"rootDO\", RootDataObject, sharedObjects, {}, undefined);\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAK2C;AAE3C,yEAGoD;AAWpD,mFAAkF;AASlF,yCAIoB;AAEpB;;GAEG;AACH,MAAM,sCAAsC,GAAG;IAC9C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,OAAO;CAC0D,CAAC;AAcxE;;;GAGG;AACH,MAAM,cACL,SAAQ,qBAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IAmG7D,CAAC;IAjGA,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAA0B;QAC/D,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAExD,mDAAmD;QACnD,MAAM,eAAe,GAAoB,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,EAAE,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CA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,EAAE,EAC7B,iBAA0C;QAE3D,2GAA2G;QAC3G,+GAA+G;QAC/G,KAAK,CAAC;YACL,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,cAAc;YACpB,aAAa;SACb,CAAC,CAAC;QARc,sBAAiB,GAAjB,iBAAiB,CAAyB;IAS5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\ttype DataObjectKind,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype MinimumVersionForCollab,\n} from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { FluidObject, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreRegistry } from \"@fluidframework/runtime-definitions/internal\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tIRootDataObject,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nconst compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\ninterface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\treadonly initialObjects: LoadableObjectKindRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get IRootDataObject(): IRootDataObject {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir(): IDirectory {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tfor (const [id, objectClass] of Object.entries(props.initialObjects)) {\n\t\t\tconst createObject = async (): Promise<void> => {\n\t\t\t\tconst obj = await this.create<IFluidLoadable>(\n\t\t\t\t\tobjectClass as SharedObjectKind<IFluidLoadable>,\n\t\t\t\t);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t}\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized(): Promise<void> {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of this.initialObjectsDir.entries()) {\n\t\t\tconst loadDir = async (): Promise<void> => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\tconst obj: unknown = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.initialObjects}\n\t */\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.create}\n\t */\n\tpublic async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\tconst internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;\n\t\tif (isDataObjectKind(internal)) {\n\t\t\treturn this.createDataObject(internal);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn this.createSharedObject(internal);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tprivate async createDataObject<T extends IFluidLoadable>(\n\t\tdataObjectClass: DataObjectKind<T>,\n\t): Promise<T> {\n\t\tconst factory = dataObjectClass.factory;\n\t\tconst packagePath = [...this.context.packagePath, factory.type];\n\t\tconst dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\treturn entryPoint as T;\n\t}\n\n\tprivate createSharedObject<T extends IFluidLoadable>(\n\t\tsharedObjectClass: ISharedObjectKind<T>,\n\t): T {\n\t\tconst factory = sharedObjectClass.getFactory();\n\t\tconst obj = this.runtime.createChannel(undefined, factory.type);\n\t\treturn obj as unknown as T;\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers\n * with a single {@link IRootDataObject} as their entry point, where the root data object's registry\n * and initial objects are configured based on the provided schema (and optionally, data store registry).\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\tschema: ContainerSchema;\n\t/**\n\t * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.\n\t */\n\tcompatibilityMode: CompatibilityMode;\n\t/**\n\t * Optional registry of data stores to pass to the DataObject factory.\n\t * If not provided, one will be created based on the schema.\n\t */\n\trootDataStoreRegistry?: IFluidDataStoreRegistry;\n}): IRuntimeFactory {\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);\n\tconst registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new DOProviderContainerRuntimeFactory(\n\t\tprops.schema,\n\t\tprops.compatibilityMode,\n\t\tnew RootDataObjectFactory(sharedObjects, registry),\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a single {@link IRootDataObject}\n * as their entry point.\n */\nclass DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectKindRecord;\n\n\t/**\n\t * Create a new instance of a container runtime factory.\n\t * @remarks\n\t * The caller is responsible for making sure that the provided root data object factory is configured\n\t * appropriately based on the schema of the container (e.g. its registry entries contain all the\n\t * DataStore/DDS types that the schema says can be constructed).\n\t *\n\t * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,\n\t * since it can take care of constructing the root data object factory based on the schema.\n\t *\n\t * @param schema - The schema for the container\n\t * @param compatibilityMode - Compatibility mode\n\t * @param rootDataObjectFactory - A factory that can construct the root data object.\n\t */\n\tpublic constructor(\n\t\tschema: ContainerSchema,\n\t\tcompatibilityMode: CompatibilityMode,\n\t\trootDataObjectFactory: DataObjectFactory<\n\t\t\tRootDataObject,\n\t\t\t{ InitialState: RootDataObjectProps }\n\t\t>,\n\t) {\n\t\tconst provideEntryPoint = async (\n\t\t\tcontainerRuntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<FluidObject> => {\n\t\t\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\tif (entryPoint === undefined) {\n\t\t\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t\t\t}\n\t\t\treturn entryPoint.get();\n\t\t};\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab: compatibilityModeToMinVersionForCollab[compatibilityMode],\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: \"rootDO\",\n\t\t\tctor: RootDataObject,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
|
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import type { IContainerRuntimeOptionsInternal } from "@fluidframework/container-runtime/internal";
|
|
6
6
|
import type { CompatibilityMode } from "./types.js";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
|
|
9
|
+
* full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
|
|
10
|
+
*
|
|
11
|
+
* @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply
|
|
12
|
+
* the proper configurations. However, there are some options that we need to explicity set that differ
|
|
13
|
+
* from the default values (i.e. `enableRuntimeIdCompressor` below).
|
|
9
14
|
*/
|
|
10
15
|
export declare const compatibilityModeRuntimeOptions: Record<CompatibilityMode, IContainerRuntimeOptionsInternal>;
|
|
11
16
|
//# sourceMappingURL=compatibilityConfiguration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAEnG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,gCAAgC,CAShC,CAAC"}
|
|
@@ -2,39 +2,21 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { CompressionAlgorithms, } from "@fluidframework/container-runtime/internal";
|
|
6
|
-
import { FlushMode } from "@fluidframework/runtime-definitions/internal";
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
6
|
+
* The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
|
|
7
|
+
* full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
|
|
8
|
+
*
|
|
9
|
+
* @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply
|
|
10
|
+
* the proper configurations. However, there are some options that we need to explicity set that differ
|
|
11
|
+
* from the default values (i.e. `enableRuntimeIdCompressor` below).
|
|
9
12
|
*/
|
|
10
13
|
export const compatibilityModeRuntimeOptions = {
|
|
11
|
-
"1": {
|
|
12
|
-
// 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode
|
|
13
|
-
// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as
|
|
14
|
-
// fewer messages will be included per flush.
|
|
15
|
-
flushMode: FlushMode.Immediate,
|
|
16
|
-
// Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.
|
|
17
|
-
compressionOptions: {
|
|
18
|
-
minimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled
|
|
19
|
-
compressionAlgorithm: CompressionAlgorithms.lz4,
|
|
20
|
-
},
|
|
21
|
-
// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.
|
|
22
|
-
enableGroupedBatching: false,
|
|
23
|
-
// TODO: Include explicit disables for things that are currently off-by-default?
|
|
24
|
-
// Explicitly disable running Sweep in compat mode "1". Sweep is supported only in 2.x. So, when 1.x and 2.x
|
|
25
|
-
// clients are running in parallel, running sweep will fail 1.x clients.
|
|
26
|
-
gcOptions: { enableGCSweep: undefined },
|
|
27
|
-
},
|
|
14
|
+
"1": {},
|
|
28
15
|
"2": {
|
|
29
|
-
// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their
|
|
30
|
-
// ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.
|
|
31
|
-
explicitSchemaControl: true,
|
|
32
16
|
// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.
|
|
33
|
-
//
|
|
17
|
+
// In general, we don't want to enable this by default since it increases the bundle size. However, since SharedTree
|
|
18
|
+
// is bundled with the fluid-framework package, we need to enable it here to support SharedTree.
|
|
34
19
|
enableRuntimeIdCompressor: "on",
|
|
35
|
-
// Explicitly disable running Sweep in compat mode "2". Although sweep is supported in 2.x, it is disabled by default.
|
|
36
|
-
// This setting explicitly disables it to be extra safe.
|
|
37
|
-
gcOptions: { enableGCSweep: undefined },
|
|
38
20
|
},
|
|
39
21
|
};
|
|
40
22
|
//# sourceMappingURL=compatibilityConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAGxC;IACH,GAAG,EAAE,EAAE;IACP,GAAG,EAAE;QACJ,sHAAsH;QACtH,oHAAoH;QACpH,gGAAgG;QAChG,yBAAyB,EAAE,IAAI;KAC/B;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IContainerRuntimeOptionsInternal } from \"@fluidframework/container-runtime/internal\";\n\nimport type { CompatibilityMode } from \"./types.js\";\n\n/**\n * The CompatibilityMode selected determines the set of runtime options to use. In \"1\" mode we support\n * full interop with true 1.x clients, while in \"2\" mode we only support interop with 2.x clients.\n *\n * @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply\n * the proper configurations. However, there are some options that we need to explicity set that differ\n * from the default values (i.e. `enableRuntimeIdCompressor` below).\n */\nexport const compatibilityModeRuntimeOptions: Record<\n\tCompatibilityMode,\n\tIContainerRuntimeOptionsInternal\n> = {\n\t\"1\": {},\n\t\"2\": {\n\t\t// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.\n\t\t// In general, we don't want to enable this by default since it increases the bundle size. However, since SharedTree\n\t\t// is bundled with the fluid-framework package, we need to enable it here to support SharedTree.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t},\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAStF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAO5F,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAKf,MAAM,YAAY,CAAC;AA2IpB;;;;;;GAMG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,uBAAuB,CAAC;CAChD,GAAG,eAAe,CASlB"}
|
package/lib/rootDataObject.js
CHANGED
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { BaseContainerRuntimeFactory, DataObject, DataObjectFactory, } from "@fluidframework/aqueduct/internal";
|
|
6
|
-
import { FluidDataStoreRegistry } from "@fluidframework/container-runtime/internal";
|
|
6
|
+
import { FluidDataStoreRegistry, } from "@fluidframework/container-runtime/internal";
|
|
7
7
|
import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
|
|
8
8
|
import { isDataObjectKind, isSharedObjectKind, parseDataObjectsFromSharedObjects, } from "./utils.js";
|
|
9
|
+
/**
|
|
10
|
+
* Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
|
|
11
|
+
*/
|
|
12
|
+
const compatibilityModeToMinVersionForCollab = {
|
|
13
|
+
"1": "1.0.0",
|
|
14
|
+
"2": "2.0.0",
|
|
15
|
+
};
|
|
9
16
|
/**
|
|
10
17
|
* The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
|
|
11
18
|
* Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
|
|
@@ -143,6 +150,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
143
150
|
registryEntries: [rootDataObjectFactory.registryEntry],
|
|
144
151
|
runtimeOptions: compatibilityModeRuntimeOptions[compatibilityMode],
|
|
145
152
|
provideEntryPoint,
|
|
153
|
+
minVersionForCollab: compatibilityModeToMinVersionForCollab[compatibilityMode],
|
|
146
154
|
});
|
|
147
155
|
this.rootDataObjectFactory = rootDataObjectFactory;
|
|
148
156
|
this.initialObjects = schema.initialObjects;
|
|
@@ -164,7 +172,11 @@ class RootDataObjectFactory extends DataObjectFactory {
|
|
|
164
172
|
constructor(sharedObjects = [], dataStoreRegistry) {
|
|
165
173
|
// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,
|
|
166
174
|
// and instead we override the necessary methods in this class to use the registry received in the constructor.
|
|
167
|
-
super(
|
|
175
|
+
super({
|
|
176
|
+
type: "rootDO",
|
|
177
|
+
ctor: RootDataObject,
|
|
178
|
+
sharedObjects,
|
|
179
|
+
});
|
|
168
180
|
this.dataStoreRegistry = dataStoreRegistry;
|
|
169
181
|
}
|
|
170
182
|
get IFluidDataStoreRegistry() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,EAC3B,UAAU,EAEV,iBAAiB,GACjB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAWpF,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AASlF,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,iCAAiC,GACjC,MAAM,YAAY,CAAC;AAcpB;;;GAGG;AACH,MAAM,cACL,SAAQ,UAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IAmG7D,CAAC;IAjGA,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,GAAG,CAAC;IAC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;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE;YAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;SACnC,CAAC,CAAC;IACJ,CAAC;CACD;AAED;;GAEG;AACH,MAAM,qBAAsB,SAAQ,iBAGnC;IACA,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAE3D,2GAA2G;QAC3G,+GAA+G;QAC/G,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;QAJ7C,sBAAiB,GAAjB,iBAAiB,CAAyB;IAK5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\ttype DataObjectKind,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport { FluidDataStoreRegistry } from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { FluidObject, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreRegistry } from \"@fluidframework/runtime-definitions/internal\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tIRootDataObject,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\ninterface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\treadonly initialObjects: LoadableObjectKindRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get IRootDataObject(): IRootDataObject {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir(): IDirectory {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tfor (const [id, objectClass] of Object.entries(props.initialObjects)) {\n\t\t\tconst createObject = async (): Promise<void> => {\n\t\t\t\tconst obj = await this.create<IFluidLoadable>(\n\t\t\t\t\tobjectClass as SharedObjectKind<IFluidLoadable>,\n\t\t\t\t);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t}\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized(): Promise<void> {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of this.initialObjectsDir.entries()) {\n\t\t\tconst loadDir = async (): Promise<void> => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\tconst obj: unknown = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.initialObjects}\n\t */\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.create}\n\t */\n\tpublic async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\tconst internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;\n\t\tif (isDataObjectKind(internal)) {\n\t\t\treturn this.createDataObject(internal);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn this.createSharedObject(internal);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tprivate async createDataObject<T extends IFluidLoadable>(\n\t\tdataObjectClass: DataObjectKind<T>,\n\t): Promise<T> {\n\t\tconst factory = dataObjectClass.factory;\n\t\tconst packagePath = [...this.context.packagePath, factory.type];\n\t\tconst dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\treturn entryPoint as T;\n\t}\n\n\tprivate createSharedObject<T extends IFluidLoadable>(\n\t\tsharedObjectClass: ISharedObjectKind<T>,\n\t): T {\n\t\tconst factory = sharedObjectClass.getFactory();\n\t\tconst obj = this.runtime.createChannel(undefined, factory.type);\n\t\treturn obj as unknown as T;\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers\n * with a single {@link IRootDataObject} as their entry point, where the root data object's registry\n * and initial objects are configured based on the provided schema (and optionally, data store registry).\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\tschema: ContainerSchema;\n\t/**\n\t * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.\n\t */\n\tcompatibilityMode: CompatibilityMode;\n\t/**\n\t * Optional registry of data stores to pass to the DataObject factory.\n\t * If not provided, one will be created based on the schema.\n\t */\n\trootDataStoreRegistry?: IFluidDataStoreRegistry;\n}): IRuntimeFactory {\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);\n\tconst registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new DOProviderContainerRuntimeFactory(\n\t\tprops.schema,\n\t\tprops.compatibilityMode,\n\t\tnew RootDataObjectFactory(sharedObjects, registry),\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a single {@link IRootDataObject}\n * as their entry point.\n */\nclass DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectKindRecord;\n\n\t/**\n\t * Create a new instance of a container runtime factory.\n\t * @remarks\n\t * The caller is responsible for making sure that the provided root data object factory is configured\n\t * appropriately based on the schema of the container (e.g. its registry entries contain all the\n\t * DataStore/DDS types that the schema says can be constructed).\n\t *\n\t * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,\n\t * since it can take care of constructing the root data object factory based on the schema.\n\t *\n\t * @param schema - The schema for the container\n\t * @param compatibilityMode - Compatibility mode\n\t * @param rootDataObjectFactory - A factory that can construct the root data object.\n\t */\n\tpublic constructor(\n\t\tschema: ContainerSchema,\n\t\tcompatibilityMode: CompatibilityMode,\n\t\trootDataObjectFactory: DataObjectFactory<\n\t\t\tRootDataObject,\n\t\t\t{ InitialState: RootDataObjectProps }\n\t\t>,\n\t) {\n\t\tconst provideEntryPoint = async (\n\t\t\tcontainerRuntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<FluidObject> => {\n\t\t\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\tif (entryPoint === undefined) {\n\t\t\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t\t\t}\n\t\t\treturn entryPoint.get();\n\t\t};\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\tprovideEntryPoint,\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper(\"rootDO\", RootDataObject, sharedObjects, {}, undefined);\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,EAC3B,UAAU,EAEV,iBAAiB,GACjB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACN,sBAAsB,GAEtB,MAAM,4CAA4C,CAAC;AAWpD,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AASlF,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,iCAAiC,GACjC,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,sCAAsC,GAAG;IAC9C,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,OAAO;CAC0D,CAAC;AAcxE;;;GAGG;AACH,MAAM,cACL,SAAQ,UAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IAmG7D,CAAC;IAjGA,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;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,8BAA8B,CAAC,OAA0B;QACxE,sEAAsE;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE;YAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;SACnC,CAAC,CAAC;IACJ,CAAC;CACD;AAED;;GAEG;AACH,MAAM,qBAAsB,SAAQ,iBAGnC;IACA,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAE3D,2GAA2G;QAC3G,+GAA+G;QAC/G,KAAK,CAAC;YACL,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,cAAc;YACpB,aAAa;SACb,CAAC,CAAC;QARc,sBAAiB,GAAjB,iBAAiB,CAAyB;IAS5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\ttype DataObjectKind,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype MinimumVersionForCollab,\n} from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { FluidObject, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport type { IFluidDataStoreRegistry } from \"@fluidframework/runtime-definitions/internal\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tIRootDataObject,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nconst compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\ninterface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\treadonly initialObjects: LoadableObjectKindRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get IRootDataObject(): IRootDataObject {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir(): IDirectory {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps): Promise<void> {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tfor (const [id, objectClass] of Object.entries(props.initialObjects)) {\n\t\t\tconst createObject = async (): Promise<void> => {\n\t\t\t\tconst obj = await this.create<IFluidLoadable>(\n\t\t\t\t\tobjectClass as SharedObjectKind<IFluidLoadable>,\n\t\t\t\t);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t}\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized(): Promise<void> {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of this.initialObjectsDir.entries()) {\n\t\t\tconst loadDir = async (): Promise<void> => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\tconst obj: unknown = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.initialObjects}\n\t */\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.create}\n\t */\n\tpublic async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\tconst internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;\n\t\tif (isDataObjectKind(internal)) {\n\t\t\treturn this.createDataObject(internal);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn this.createSharedObject(internal);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tprivate async createDataObject<T extends IFluidLoadable>(\n\t\tdataObjectClass: DataObjectKind<T>,\n\t): Promise<T> {\n\t\tconst factory = dataObjectClass.factory;\n\t\tconst packagePath = [...this.context.packagePath, factory.type];\n\t\tconst dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\treturn entryPoint as T;\n\t}\n\n\tprivate createSharedObject<T extends IFluidLoadable>(\n\t\tsharedObjectClass: ISharedObjectKind<T>,\n\t): T {\n\t\tconst factory = sharedObjectClass.getFactory();\n\t\tconst obj = this.runtime.createChannel(undefined, factory.type);\n\t\treturn obj as unknown as T;\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers\n * with a single {@link IRootDataObject} as their entry point, where the root data object's registry\n * and initial objects are configured based on the provided schema (and optionally, data store registry).\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\tschema: ContainerSchema;\n\t/**\n\t * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.\n\t */\n\tcompatibilityMode: CompatibilityMode;\n\t/**\n\t * Optional registry of data stores to pass to the DataObject factory.\n\t * If not provided, one will be created based on the schema.\n\t */\n\trootDataStoreRegistry?: IFluidDataStoreRegistry;\n}): IRuntimeFactory {\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);\n\tconst registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new DOProviderContainerRuntimeFactory(\n\t\tprops.schema,\n\t\tprops.compatibilityMode,\n\t\tnew RootDataObjectFactory(sharedObjects, registry),\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a single {@link IRootDataObject}\n * as their entry point.\n */\nclass DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectKindRecord;\n\n\t/**\n\t * Create a new instance of a container runtime factory.\n\t * @remarks\n\t * The caller is responsible for making sure that the provided root data object factory is configured\n\t * appropriately based on the schema of the container (e.g. its registry entries contain all the\n\t * DataStore/DDS types that the schema says can be constructed).\n\t *\n\t * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,\n\t * since it can take care of constructing the root data object factory based on the schema.\n\t *\n\t * @param schema - The schema for the container\n\t * @param compatibilityMode - Compatibility mode\n\t * @param rootDataObjectFactory - A factory that can construct the root data object.\n\t */\n\tpublic constructor(\n\t\tschema: ContainerSchema,\n\t\tcompatibilityMode: CompatibilityMode,\n\t\trootDataObjectFactory: DataObjectFactory<\n\t\t\tRootDataObject,\n\t\t\t{ InitialState: RootDataObjectProps }\n\t\t>,\n\t) {\n\t\tconst provideEntryPoint = async (\n\t\t\tcontainerRuntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<FluidObject> => {\n\t\t\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\tif (entryPoint === undefined) {\n\t\t\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t\t\t}\n\t\t\treturn entryPoint.get();\n\t\t};\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab: compatibilityModeToMinVersionForCollab[compatibilityMode],\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: \"rootDO\",\n\t\t\tctor: RootDataObject,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.40.0
|
|
3
|
+
"version": "2.40.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": {
|
|
@@ -59,32 +59,32 @@
|
|
|
59
59
|
"temp-directory": "nyc/.nyc_output"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@fluid-internal/client-utils": "2.40.0
|
|
63
|
-
"@fluidframework/aqueduct": "2.40.0
|
|
64
|
-
"@fluidframework/container-definitions": "2.40.0
|
|
65
|
-
"@fluidframework/container-loader": "2.40.0
|
|
66
|
-
"@fluidframework/container-runtime": "2.40.0
|
|
67
|
-
"@fluidframework/container-runtime-definitions": "2.40.0
|
|
68
|
-
"@fluidframework/core-interfaces": "2.40.0
|
|
69
|
-
"@fluidframework/datastore-definitions": "2.40.0
|
|
70
|
-
"@fluidframework/driver-definitions": "2.40.0
|
|
71
|
-
"@fluidframework/request-handler": "2.40.0
|
|
72
|
-
"@fluidframework/runtime-definitions": "2.40.0
|
|
73
|
-
"@fluidframework/runtime-utils": "2.40.0
|
|
74
|
-
"@fluidframework/shared-object-base": "2.40.0
|
|
75
|
-
"@fluidframework/telemetry-utils": "2.40.0
|
|
62
|
+
"@fluid-internal/client-utils": "~2.40.0",
|
|
63
|
+
"@fluidframework/aqueduct": "~2.40.0",
|
|
64
|
+
"@fluidframework/container-definitions": "~2.40.0",
|
|
65
|
+
"@fluidframework/container-loader": "~2.40.0",
|
|
66
|
+
"@fluidframework/container-runtime": "~2.40.0",
|
|
67
|
+
"@fluidframework/container-runtime-definitions": "~2.40.0",
|
|
68
|
+
"@fluidframework/core-interfaces": "~2.40.0",
|
|
69
|
+
"@fluidframework/datastore-definitions": "~2.40.0",
|
|
70
|
+
"@fluidframework/driver-definitions": "~2.40.0",
|
|
71
|
+
"@fluidframework/request-handler": "~2.40.0",
|
|
72
|
+
"@fluidframework/runtime-definitions": "~2.40.0",
|
|
73
|
+
"@fluidframework/runtime-utils": "~2.40.0",
|
|
74
|
+
"@fluidframework/shared-object-base": "~2.40.0",
|
|
75
|
+
"@fluidframework/telemetry-utils": "~2.40.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
79
79
|
"@biomejs/biome": "~1.9.3",
|
|
80
|
-
"@fluid-internal/mocha-test-setup": "2.40.0
|
|
80
|
+
"@fluid-internal/mocha-test-setup": "~2.40.0",
|
|
81
81
|
"@fluid-tools/build-cli": "^0.55.0",
|
|
82
82
|
"@fluidframework/build-common": "^2.0.3",
|
|
83
83
|
"@fluidframework/build-tools": "^0.55.0",
|
|
84
84
|
"@fluidframework/eslint-config-fluid": "^5.7.3",
|
|
85
85
|
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.33.0",
|
|
86
|
-
"@fluidframework/map": "2.40.0
|
|
87
|
-
"@fluidframework/sequence": "2.40.0
|
|
86
|
+
"@fluidframework/map": "~2.40.0",
|
|
87
|
+
"@fluidframework/sequence": "~2.40.0",
|
|
88
88
|
"@microsoft/api-extractor": "7.52.5",
|
|
89
89
|
"@types/mocha": "^10.0.10",
|
|
90
90
|
"@types/node": "^18.19.0",
|
|
@@ -3,48 +3,27 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
CompressionAlgorithms,
|
|
8
|
-
type IContainerRuntimeOptionsInternal,
|
|
9
|
-
} from "@fluidframework/container-runtime/internal";
|
|
10
|
-
import { FlushMode } from "@fluidframework/runtime-definitions/internal";
|
|
6
|
+
import type { IContainerRuntimeOptionsInternal } from "@fluidframework/container-runtime/internal";
|
|
11
7
|
|
|
12
8
|
import type { CompatibilityMode } from "./types.js";
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
|
-
*
|
|
11
|
+
* The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
|
|
12
|
+
* full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
|
|
13
|
+
*
|
|
14
|
+
* @privateRemarks In general, we can use the `compatibilityMode` property of `LoadContainerRuntimeParams` to apply
|
|
15
|
+
* the proper configurations. However, there are some options that we need to explicity set that differ
|
|
16
|
+
* from the default values (i.e. `enableRuntimeIdCompressor` below).
|
|
16
17
|
*/
|
|
17
18
|
export const compatibilityModeRuntimeOptions: Record<
|
|
18
19
|
CompatibilityMode,
|
|
19
20
|
IContainerRuntimeOptionsInternal
|
|
20
21
|
> = {
|
|
21
|
-
"1": {
|
|
22
|
-
// 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode
|
|
23
|
-
// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as
|
|
24
|
-
// fewer messages will be included per flush.
|
|
25
|
-
flushMode: FlushMode.Immediate,
|
|
26
|
-
// Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.
|
|
27
|
-
compressionOptions: {
|
|
28
|
-
minimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled
|
|
29
|
-
compressionAlgorithm: CompressionAlgorithms.lz4,
|
|
30
|
-
},
|
|
31
|
-
// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.
|
|
32
|
-
enableGroupedBatching: false,
|
|
33
|
-
// TODO: Include explicit disables for things that are currently off-by-default?
|
|
34
|
-
|
|
35
|
-
// Explicitly disable running Sweep in compat mode "1". Sweep is supported only in 2.x. So, when 1.x and 2.x
|
|
36
|
-
// clients are running in parallel, running sweep will fail 1.x clients.
|
|
37
|
-
gcOptions: { enableGCSweep: undefined },
|
|
38
|
-
},
|
|
22
|
+
"1": {},
|
|
39
23
|
"2": {
|
|
40
|
-
// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their
|
|
41
|
-
// ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.
|
|
42
|
-
explicitSchemaControl: true,
|
|
43
24
|
// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.
|
|
44
|
-
//
|
|
25
|
+
// In general, we don't want to enable this by default since it increases the bundle size. However, since SharedTree
|
|
26
|
+
// is bundled with the fluid-framework package, we need to enable it here to support SharedTree.
|
|
45
27
|
enableRuntimeIdCompressor: "on",
|
|
46
|
-
// Explicitly disable running Sweep in compat mode "2". Although sweep is supported in 2.x, it is disabled by default.
|
|
47
|
-
// This setting explicitly disables it to be extra safe.
|
|
48
|
-
gcOptions: { enableGCSweep: undefined },
|
|
49
28
|
},
|
|
50
29
|
};
|
package/src/rootDataObject.ts
CHANGED
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
DataObjectFactory,
|
|
11
11
|
} from "@fluidframework/aqueduct/internal";
|
|
12
12
|
import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
FluidDataStoreRegistry,
|
|
15
|
+
type MinimumVersionForCollab,
|
|
16
|
+
} from "@fluidframework/container-runtime/internal";
|
|
14
17
|
import type { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
|
|
15
18
|
import type { FluidObject, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
16
19
|
import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
|
|
@@ -36,6 +39,14 @@ import {
|
|
|
36
39
|
parseDataObjectsFromSharedObjects,
|
|
37
40
|
} from "./utils.js";
|
|
38
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
|
|
44
|
+
*/
|
|
45
|
+
const compatibilityModeToMinVersionForCollab = {
|
|
46
|
+
"1": "1.0.0",
|
|
47
|
+
"2": "2.0.0",
|
|
48
|
+
} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;
|
|
49
|
+
|
|
39
50
|
/**
|
|
40
51
|
* Input props for {@link RootDataObject.initializingFirstTime}.
|
|
41
52
|
*/
|
|
@@ -242,6 +253,7 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
242
253
|
registryEntries: [rootDataObjectFactory.registryEntry],
|
|
243
254
|
runtimeOptions: compatibilityModeRuntimeOptions[compatibilityMode],
|
|
244
255
|
provideEntryPoint,
|
|
256
|
+
minVersionForCollab: compatibilityModeToMinVersionForCollab[compatibilityMode],
|
|
245
257
|
});
|
|
246
258
|
this.rootDataObjectFactory = rootDataObjectFactory;
|
|
247
259
|
this.initialObjects = schema.initialObjects;
|
|
@@ -271,7 +283,11 @@ class RootDataObjectFactory extends DataObjectFactory<
|
|
|
271
283
|
) {
|
|
272
284
|
// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,
|
|
273
285
|
// and instead we override the necessary methods in this class to use the registry received in the constructor.
|
|
274
|
-
super(
|
|
286
|
+
super({
|
|
287
|
+
type: "rootDO",
|
|
288
|
+
ctor: RootDataObject,
|
|
289
|
+
sharedObjects,
|
|
290
|
+
});
|
|
275
291
|
}
|
|
276
292
|
|
|
277
293
|
public get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {
|