@fluidframework/fluid-static 2.32.0 → 2.33.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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/fluid-static
2
2
 
3
+ ## 2.33.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.32.0
4
8
 
5
9
  Dependency updates only.
@@ -5,8 +5,7 @@
5
5
  import { type IContainerRuntimeOptionsInternal } from "@fluidframework/container-runtime/internal";
6
6
  import type { CompatibilityMode } from "./types.js";
7
7
  /**
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.
8
+ * Specifies the configured runtime options for each {@link CompatibilityMode}..
10
9
  */
11
10
  export declare const compatibilityModeRuntimeOptions: Record<CompatibilityMode, IContainerRuntimeOptionsInternal>;
12
11
  //# 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,EAEN,KAAK,gCAAgC,EACrC,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,gCAAgC,CA+BhC,CAAC"}
1
+ {"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,gCAAgC,EACrC,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,gCAAgC,CA+BhC,CAAC"}
@@ -8,8 +8,7 @@ exports.compatibilityModeRuntimeOptions = void 0;
8
8
  const internal_1 = require("@fluidframework/container-runtime/internal");
9
9
  const internal_2 = require("@fluidframework/runtime-definitions/internal");
10
10
  /**
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.
11
+ * Specifies the configured runtime options for each {@link CompatibilityMode}..
13
12
  */
14
13
  exports.compatibilityModeRuntimeOptions = {
15
14
  "1": {
@@ -1 +1 @@
1
- {"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAGoD;AACpD,2EAAyE;AAIzE;;;GAGG;AACU,QAAA,+BAA+B,GAGxC;IACH,GAAG,EAAE;QACJ,0GAA0G;QAC1G,8GAA8G;QAC9G,6CAA6C;QAC7C,SAAS,EAAE,oBAAS,CAAC,SAAS;QAC9B,4GAA4G;QAC5G,kBAAkB,EAAE;YACnB,uBAAuB,EAAE,MAAM,CAAC,iBAAiB,EAAE,WAAW;YAC9D,oBAAoB,EAAE,gCAAqB,CAAC,GAAG;SAC/C;QACD,8GAA8G;QAC9G,qBAAqB,EAAE,KAAK;QAC5B,gFAAgF;QAEhF,4GAA4G;QAC5G,wEAAwE;QACxE,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;IACD,GAAG,EAAE;QACJ,uGAAuG;QACvG,sHAAsH;QACtH,qBAAqB,EAAE,IAAI;QAC3B,sHAAsH;QACtH,2EAA2E;QAC3E,yBAAyB,EAAE,IAAI;QAC/B,sHAAsH;QACtH,wDAAwD;QACxD,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCompressionAlgorithms,\n\ttype IContainerRuntimeOptionsInternal,\n} from \"@fluidframework/container-runtime/internal\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions/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 */\nexport const compatibilityModeRuntimeOptions: Record<\n\tCompatibilityMode,\n\tIContainerRuntimeOptionsInternal\n> = {\n\t\"1\": {\n\t\t// 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode\n\t\t// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as\n\t\t// fewer messages will be included per flush.\n\t\tflushMode: FlushMode.Immediate,\n\t\t// Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tcompressionOptions: {\n\t\t\tminimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled\n\t\t\tcompressionAlgorithm: CompressionAlgorithms.lz4,\n\t\t},\n\t\t// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableGroupedBatching: false,\n\t\t// TODO: Include explicit disables for things that are currently off-by-default?\n\n\t\t// Explicitly disable running Sweep in compat mode \"1\". Sweep is supported only in 2.x. So, when 1.x and 2.x\n\t\t// clients are running in parallel, running sweep will fail 1.x clients.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n\t\"2\": {\n\t\t// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their\n\t\t// ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.\n\t\texplicitSchemaControl: true,\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// It introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t\t// Explicitly disable running Sweep in compat mode \"2\". Although sweep is supported in 2.x, it is disabled by default.\n\t\t// This setting explicitly disables it to be extra safe.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n};\n"]}
1
+ {"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAGoD;AACpD,2EAAyE;AAIzE;;GAEG;AACU,QAAA,+BAA+B,GAGxC;IACH,GAAG,EAAE;QACJ,0GAA0G;QAC1G,8GAA8G;QAC9G,6CAA6C;QAC7C,SAAS,EAAE,oBAAS,CAAC,SAAS;QAC9B,4GAA4G;QAC5G,kBAAkB,EAAE;YACnB,uBAAuB,EAAE,MAAM,CAAC,iBAAiB,EAAE,WAAW;YAC9D,oBAAoB,EAAE,gCAAqB,CAAC,GAAG;SAC/C;QACD,8GAA8G;QAC9G,qBAAqB,EAAE,KAAK;QAC5B,gFAAgF;QAEhF,4GAA4G;QAC5G,wEAAwE;QACxE,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;IACD,GAAG,EAAE;QACJ,uGAAuG;QACvG,sHAAsH;QACtH,qBAAqB,EAAE,IAAI;QAC3B,sHAAsH;QACtH,2EAA2E;QAC3E,yBAAyB,EAAE,IAAI;QAC/B,sHAAsH;QACtH,wDAAwD;QACxD,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCompressionAlgorithms,\n\ttype IContainerRuntimeOptionsInternal,\n} from \"@fluidframework/container-runtime/internal\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { CompatibilityMode } from \"./types.js\";\n\n/**\n * Specifies the configured runtime options for each {@link CompatibilityMode}..\n */\nexport const compatibilityModeRuntimeOptions: Record<\n\tCompatibilityMode,\n\tIContainerRuntimeOptionsInternal\n> = {\n\t\"1\": {\n\t\t// 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode\n\t\t// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as\n\t\t// fewer messages will be included per flush.\n\t\tflushMode: FlushMode.Immediate,\n\t\t// Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tcompressionOptions: {\n\t\t\tminimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled\n\t\t\tcompressionAlgorithm: CompressionAlgorithms.lz4,\n\t\t},\n\t\t// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableGroupedBatching: false,\n\t\t// TODO: Include explicit disables for things that are currently off-by-default?\n\n\t\t// Explicitly disable running Sweep in compat mode \"1\". Sweep is supported only in 2.x. So, when 1.x and 2.x\n\t\t// clients are running in parallel, running sweep will fail 1.x clients.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n\t\"2\": {\n\t\t// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their\n\t\t// ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.\n\t\texplicitSchemaControl: true,\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// It introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t\t// Explicitly disable running Sweep in compat mode \"2\". Although sweep is supported in 2.x, it is disabled by default.\n\t\t// This setting explicitly disables it to be extra safe.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n};\n"]}
@@ -3,26 +3,28 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
6
- import type { CompatibilityMode, ContainerSchema, LoadableObjectKindRecord } from "./types.js";
6
+ import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
7
+ import type { CompatibilityMode, ContainerSchema } from "./types.js";
7
8
  /**
8
- * Input props for {@link RootDataObject.initializingFirstTime}.
9
- */
10
- export interface RootDataObjectProps {
11
- /**
12
- * Initial object structure with which the {@link RootDataObject} will be first-time initialized.
13
- *
14
- * @see {@link RootDataObject.initializingFirstTime}
15
- */
16
- readonly initialObjects: LoadableObjectKindRecord;
17
- }
18
- /**
19
- * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single
20
- * {@link IRootDataObject}, which is constructed from the provided schema.
9
+ * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
10
+ * with a single {@link IRootDataObject} as their entry point, where the root data object's registry
11
+ * and initial objects are configured based on the provided schema (and optionally, data store registry).
21
12
  *
22
13
  * @internal
23
14
  */
24
15
  export declare function createDOProviderContainerRuntimeFactory(props: {
16
+ /**
17
+ * The schema for the container.
18
+ */
25
19
  schema: ContainerSchema;
20
+ /**
21
+ * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.
22
+ */
26
23
  compatibilityMode: CompatibilityMode;
24
+ /**
25
+ * Optional registry of data stores to pass to the DataObject factory.
26
+ * If not provided, one will be created based on the schema.
27
+ */
28
+ rootDataStoreRegistry?: IFluidDataStoreRegistry;
27
29
  }): IRuntimeFactory;
28
30
  //# sourceMappingURL=rootDataObject.d.ts.map
@@ -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;AAUtF,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAGf,wBAAwB,EAExB,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,wBAAwB,CAAC;CAClD;AAkHD;;;;;GAKG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D,MAAM,EAAE,eAAe,CAAC;IACxB,iBAAiB,EAAE,iBAAiB,CAAC;CACrC,GAAG,eAAe,CAElB"}
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;AAMtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAO5F,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAKf,MAAM,YAAY,CAAC;AAmIpB;;;;;;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"}
@@ -6,6 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.createDOProviderContainerRuntimeFactory = void 0;
8
8
  const internal_1 = require("@fluidframework/aqueduct/internal");
9
+ const internal_2 = require("@fluidframework/container-runtime/internal");
9
10
  const compatibilityConfiguration_js_1 = require("./compatibilityConfiguration.js");
10
11
  const utils_js_1 = require("./utils.js");
11
12
  /**
@@ -103,29 +104,38 @@ class RootDataObject extends internal_1.DataObject {
103
104
  }
104
105
  const rootDataStoreId = "rootDOId";
105
106
  /**
106
- * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single
107
- * {@link IRootDataObject}, which is constructed from the provided schema.
107
+ * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
108
+ * with a single {@link IRootDataObject} as their entry point, where the root data object's registry
109
+ * and initial objects are configured based on the provided schema (and optionally, data store registry).
108
110
  *
109
111
  * @internal
110
112
  */
111
113
  function createDOProviderContainerRuntimeFactory(props) {
112
- return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode);
114
+ const [registryEntries, sharedObjects] = (0, utils_js_1.parseDataObjectsFromSharedObjects)(props.schema);
115
+ const registry = props.rootDataStoreRegistry ?? new internal_2.FluidDataStoreRegistry(registryEntries);
116
+ return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode, new RootDataObjectFactory(sharedObjects, registry));
113
117
  }
114
118
  exports.createDOProviderContainerRuntimeFactory = createDOProviderContainerRuntimeFactory;
115
119
  /**
116
- * Container code that provides a single {@link IRootDataObject}.
117
- *
118
- * @remarks
119
- *
120
- * This data object is dynamically customized (registry and initial objects) based on the schema provided.
121
- * to the container runtime factory.
122
- *
123
- * @internal
120
+ * Factory for Container Runtime instances that provide a single {@link IRootDataObject}
121
+ * as their entry point.
124
122
  */
125
123
  class DOProviderContainerRuntimeFactory extends internal_1.BaseContainerRuntimeFactory {
126
- constructor(schema, compatibilityMode) {
127
- const [registryEntries, sharedObjects] = (0, utils_js_1.parseDataObjectsFromSharedObjects)(schema);
128
- const rootDataObjectFactory = new internal_1.DataObjectFactory("rootDO", RootDataObject, sharedObjects, {}, registryEntries);
124
+ /**
125
+ * Create a new instance of a container runtime factory.
126
+ * @remarks
127
+ * The caller is responsible for making sure that the provided root data object factory is configured
128
+ * appropriately based on the schema of the container (e.g. its registry entries contain all the
129
+ * DataStore/DDS types that the schema says can be constructed).
130
+ *
131
+ * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,
132
+ * since it can take care of constructing the root data object factory based on the schema.
133
+ *
134
+ * @param schema - The schema for the container
135
+ * @param compatibilityMode - Compatibility mode
136
+ * @param rootDataObjectFactory - A factory that can construct the root data object.
137
+ */
138
+ constructor(schema, compatibilityMode, rootDataObjectFactory) {
129
139
  const provideEntryPoint = async (containerRuntime) => {
130
140
  const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
131
141
  if (entryPoint === undefined) {
@@ -151,4 +161,18 @@ class DOProviderContainerRuntimeFactory extends internal_1.BaseContainerRuntimeF
151
161
  });
152
162
  }
153
163
  }
164
+ /**
165
+ * Factory that creates instances of a root data object.
166
+ */
167
+ class RootDataObjectFactory extends internal_1.DataObjectFactory {
168
+ constructor(sharedObjects = [], dataStoreRegistry) {
169
+ // Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,
170
+ // and instead we override the necessary methods in this class to use the registry received in the constructor.
171
+ super("rootDO", RootDataObject, sharedObjects, {}, undefined);
172
+ this.dataStoreRegistry = dataStoreRegistry;
173
+ }
174
+ get IFluidDataStoreRegistry() {
175
+ return this.dataStoreRegistry;
176
+ }
177
+ }
154
178
  //# sourceMappingURL=rootDataObject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAK2C;AAU3C,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,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,CAAC,EAAE,CAAC;YACtE,MAAM,YAAY,GAAG,KAAK,IAAmB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;QAC/E,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC,GAAG,IAAA,4CAAiC,EAAC,MAAM,CAAC,CAAC;QACnF,MAAM,qBAAqB,GAAG,IAAI,4BAAiB,CAClD,QAAQ,EACR,cAAc,EACd,aAAa,EACb,EAAE,EACF,eAAe,CACf,CAAC;QACF,MAAM,iBAAiB,GAAG,KAAK,EAC9B,gBAAmC,EAEZ,EAAE;YACzB,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;YACzF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,sBAAsB,eAAe,cAAc,CAAC,CAAC;YACtE,CAAC;YACD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC;QACzB,CAAC,CAAC;QACF,KAAK,CAAC;YACL,eAAe,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC;YACtD,cAAc,EAAE,+DAA+B,CAAC,iBAAiB,CAAC;YAClE,iBAAiB;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,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","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 type { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { FluidObject, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IDirectory } from \"@fluidframework/map/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 */\nexport interface 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} for a container with a single\n * {@link IRootDataObject}, which is constructed from the provided schema.\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\tschema: ContainerSchema;\n\tcompatibilityMode: CompatibilityMode;\n}): IRuntimeFactory {\n\treturn new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode);\n}\n\n/**\n * Container code that provides a single {@link IRootDataObject}.\n *\n * @remarks\n *\n * This data object is dynamically customized (registry and initial objects) based on the schema provided.\n * to the container runtime factory.\n *\n * @internal\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\tpublic constructor(schema: ContainerSchema, compatibilityMode: CompatibilityMode) {\n\t\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\t\tconst rootDataObjectFactory = new DataObjectFactory(\n\t\t\t\"rootDO\",\n\t\t\tRootDataObject,\n\t\t\tsharedObjects,\n\t\t\t{},\n\t\t\tregistryEntries,\n\t\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"]}
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,CAA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C,qBAAqB,CAAC,aAAa,CAAC;YACtD,cAAc,EAAE,+DAA+B,CAAC,iBAAiB,CAAC;YAClE,iBAAiB;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,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,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"]}
package/dist/types.d.ts CHANGED
@@ -7,7 +7,10 @@ import type { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/cor
7
7
  import type { SharedObjectKind } from "@fluidframework/shared-object-base";
8
8
  import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
9
9
  /**
10
- * Valid compatibility modes that may be specified when creating a DOProviderContainerRuntimeFactory.
10
+ * Determines the set of runtime options that Fluid Framework will use when running.
11
+ * In "1" mode we support full interop between 2.x clients and 1.x clients,
12
+ * while in "2" mode we only support interop between 2.x clients.
13
+ *
11
14
  * @public
12
15
  */
13
16
  export type CompatibilityMode = "1" | "2";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAA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,OAAO;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\n/**\n * Valid compatibility modes that may be specified when creating a DOProviderContainerRuntimeFactory.\n * @public\n */\nexport type CompatibilityMode = \"1\" | \"2\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @internal\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject`.\n */\nexport type LoadableObjectKindRecord = Record<string, SharedObjectKind>;\n\n/**\n * A kind of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The kind of `DataObject` or `SharedObject`.\n *\n * @privateRemarks\n * There are some edge cases in TypeScript where the order of the members in a union matter.\n * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.\n * In this case, its better to have the desired match and/or the simpler type first.\n * In this case placing ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.\n * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].\n */\nexport type LoadableObjectKind<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectKind<T>;\n\n/**\n * Represents properties that can be attached to a container.\n * @public\n */\nexport type ContainerAttachProps<T = unknown> = T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n * @public\n */\nexport interface ContainerSchema {\n\t/**\n\t * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n\t *\n\t * @remarks It uses the key as the id and the value as the loadable object to create.\n\t *\n\t * @example\n\t *\n\t * In the example below two objects will be created when the `Container` is first\n\t * created. One with id \"map1\" that will return a `SharedMap` and the other with\n\t * id \"pair1\" that will return a `KeyValueDataObject`.\n\t *\n\t * ```typescript\n\t * {\n\t * map1: SharedMap,\n\t * pair1: KeyValueDataObject,\n\t * }\n\t * ```\n\t */\n\treadonly initialObjects: Record<string, SharedObjectKind>;\n\n\t/**\n\t * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n\t *\n\t * @remarks\n\t *\n\t * Types defined in `initialObjects` will always be available and are not required to be provided here.\n\t *\n\t * For best practice it's recommended to define all the dynamic types you create even if they are\n\t * included via initialObjects.\n\t */\n\treadonly dynamicObjectTypes?: readonly SharedObjectKind[];\n}\n\n/**\n * @internal\n */\nexport interface IProvideRootDataObject {\n\treadonly IRootDataObject: IRootDataObject;\n}\n\n/**\n * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n * @internal\n */\nexport interface IRootDataObject extends IProvideRootDataObject {\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * Dynamically creates a new detached collaborative object (DDS/DataObject).\n\t *\n\t * @param objectClass - Type of the collaborative object to be created.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T>(objectClass: SharedObjectKind<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n * @public\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n * @public\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n\t/**\n\t * Emitted when a {@link IMember | member}(s) are either added or removed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"membersChanged\", listener: () => void): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} joins the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} leaves the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n * @public\n */\nexport interface IServiceAudience<M extends IMember>\n\textends IEventProvider<IServiceAudienceEvents<M>> {\n\t/**\n\t * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n\t * member object. The implementation may choose to exclude certain connections from the returned map.\n\t * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n\t */\n\tgetMembers(): ReadonlyMap<string, M>;\n\n\t/**\n\t * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n\t */\n\tgetMyself(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n * @public\n */\nexport interface IConnection {\n\t/**\n\t * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\treadonly mode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n * @public\n */\nexport interface IMember {\n\t/**\n\t * An ID for the user, unique among each individual user connecting to the session.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\treadonly connections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { readonly currentConnection: string };\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\n/**\n * Determines the set of runtime options that Fluid Framework will use when running.\n * In \"1\" mode we support full interop between 2.x clients and 1.x clients,\n * while in \"2\" mode we only support interop between 2.x clients.\n *\n * @public\n */\nexport type CompatibilityMode = \"1\" | \"2\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @internal\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject`.\n */\nexport type LoadableObjectKindRecord = Record<string, SharedObjectKind>;\n\n/**\n * A kind of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The kind of `DataObject` or `SharedObject`.\n *\n * @privateRemarks\n * There are some edge cases in TypeScript where the order of the members in a union matter.\n * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.\n * In this case, its better to have the desired match and/or the simpler type first.\n * In this case placing ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.\n * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].\n */\nexport type LoadableObjectKind<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectKind<T>;\n\n/**\n * Represents properties that can be attached to a container.\n * @public\n */\nexport type ContainerAttachProps<T = unknown> = T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n * @public\n */\nexport interface ContainerSchema {\n\t/**\n\t * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n\t *\n\t * @remarks It uses the key as the id and the value as the loadable object to create.\n\t *\n\t * @example\n\t *\n\t * In the example below two objects will be created when the `Container` is first\n\t * created. One with id \"map1\" that will return a `SharedMap` and the other with\n\t * id \"pair1\" that will return a `KeyValueDataObject`.\n\t *\n\t * ```typescript\n\t * {\n\t * map1: SharedMap,\n\t * pair1: KeyValueDataObject,\n\t * }\n\t * ```\n\t */\n\treadonly initialObjects: Record<string, SharedObjectKind>;\n\n\t/**\n\t * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n\t *\n\t * @remarks\n\t *\n\t * Types defined in `initialObjects` will always be available and are not required to be provided here.\n\t *\n\t * For best practice it's recommended to define all the dynamic types you create even if they are\n\t * included via initialObjects.\n\t */\n\treadonly dynamicObjectTypes?: readonly SharedObjectKind[];\n}\n\n/**\n * @internal\n */\nexport interface IProvideRootDataObject {\n\treadonly IRootDataObject: IRootDataObject;\n}\n\n/**\n * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n * @internal\n */\nexport interface IRootDataObject extends IProvideRootDataObject {\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * Dynamically creates a new detached collaborative object (DDS/DataObject).\n\t *\n\t * @param objectClass - Type of the collaborative object to be created.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T>(objectClass: SharedObjectKind<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n * @public\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n * @public\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n\t/**\n\t * Emitted when a {@link IMember | member}(s) are either added or removed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"membersChanged\", listener: () => void): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} joins the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} leaves the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n * @public\n */\nexport interface IServiceAudience<M extends IMember>\n\textends IEventProvider<IServiceAudienceEvents<M>> {\n\t/**\n\t * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n\t * member object. The implementation may choose to exclude certain connections from the returned map.\n\t * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n\t */\n\tgetMembers(): ReadonlyMap<string, M>;\n\n\t/**\n\t * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n\t */\n\tgetMyself(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n * @public\n */\nexport interface IConnection {\n\t/**\n\t * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\treadonly mode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n * @public\n */\nexport interface IMember {\n\t/**\n\t * An ID for the user, unique among each individual user connecting to the session.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\treadonly connections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { readonly currentConnection: string };\n"]}
@@ -5,8 +5,7 @@
5
5
  import { type IContainerRuntimeOptionsInternal } from "@fluidframework/container-runtime/internal";
6
6
  import type { CompatibilityMode } from "./types.js";
7
7
  /**
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.
8
+ * Specifies the configured runtime options for each {@link CompatibilityMode}..
10
9
  */
11
10
  export declare const compatibilityModeRuntimeOptions: Record<CompatibilityMode, IContainerRuntimeOptionsInternal>;
12
11
  //# 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,EAEN,KAAK,gCAAgC,EACrC,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,gCAAgC,CA+BhC,CAAC"}
1
+ {"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,gCAAgC,EACrC,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,gCAAgC,CA+BhC,CAAC"}
@@ -5,8 +5,7 @@
5
5
  import { CompressionAlgorithms, } from "@fluidframework/container-runtime/internal";
6
6
  import { FlushMode } from "@fluidframework/runtime-definitions/internal";
7
7
  /**
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.
8
+ * Specifies the configured runtime options for each {@link CompatibilityMode}..
10
9
  */
11
10
  export const compatibilityModeRuntimeOptions = {
12
11
  "1": {
@@ -1 +1 @@
1
- {"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,qBAAqB,GAErB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AAIzE;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAGxC;IACH,GAAG,EAAE;QACJ,0GAA0G;QAC1G,8GAA8G;QAC9G,6CAA6C;QAC7C,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,4GAA4G;QAC5G,kBAAkB,EAAE;YACnB,uBAAuB,EAAE,MAAM,CAAC,iBAAiB,EAAE,WAAW;YAC9D,oBAAoB,EAAE,qBAAqB,CAAC,GAAG;SAC/C;QACD,8GAA8G;QAC9G,qBAAqB,EAAE,KAAK;QAC5B,gFAAgF;QAEhF,4GAA4G;QAC5G,wEAAwE;QACxE,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;IACD,GAAG,EAAE;QACJ,uGAAuG;QACvG,sHAAsH;QACtH,qBAAqB,EAAE,IAAI;QAC3B,sHAAsH;QACtH,2EAA2E;QAC3E,yBAAyB,EAAE,IAAI;QAC/B,sHAAsH;QACtH,wDAAwD;QACxD,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCompressionAlgorithms,\n\ttype IContainerRuntimeOptionsInternal,\n} from \"@fluidframework/container-runtime/internal\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions/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 */\nexport const compatibilityModeRuntimeOptions: Record<\n\tCompatibilityMode,\n\tIContainerRuntimeOptionsInternal\n> = {\n\t\"1\": {\n\t\t// 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode\n\t\t// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as\n\t\t// fewer messages will be included per flush.\n\t\tflushMode: FlushMode.Immediate,\n\t\t// Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tcompressionOptions: {\n\t\t\tminimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled\n\t\t\tcompressionAlgorithm: CompressionAlgorithms.lz4,\n\t\t},\n\t\t// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableGroupedBatching: false,\n\t\t// TODO: Include explicit disables for things that are currently off-by-default?\n\n\t\t// Explicitly disable running Sweep in compat mode \"1\". Sweep is supported only in 2.x. So, when 1.x and 2.x\n\t\t// clients are running in parallel, running sweep will fail 1.x clients.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n\t\"2\": {\n\t\t// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their\n\t\t// ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.\n\t\texplicitSchemaControl: true,\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// It introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t\t// Explicitly disable running Sweep in compat mode \"2\". Although sweep is supported in 2.x, it is disabled by default.\n\t\t// This setting explicitly disables it to be extra safe.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n};\n"]}
1
+ {"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,qBAAqB,GAErB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AAIzE;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAGxC;IACH,GAAG,EAAE;QACJ,0GAA0G;QAC1G,8GAA8G;QAC9G,6CAA6C;QAC7C,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,4GAA4G;QAC5G,kBAAkB,EAAE;YACnB,uBAAuB,EAAE,MAAM,CAAC,iBAAiB,EAAE,WAAW;YAC9D,oBAAoB,EAAE,qBAAqB,CAAC,GAAG;SAC/C;QACD,8GAA8G;QAC9G,qBAAqB,EAAE,KAAK;QAC5B,gFAAgF;QAEhF,4GAA4G;QAC5G,wEAAwE;QACxE,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;IACD,GAAG,EAAE;QACJ,uGAAuG;QACvG,sHAAsH;QACtH,qBAAqB,EAAE,IAAI;QAC3B,sHAAsH;QACtH,2EAA2E;QAC3E,yBAAyB,EAAE,IAAI;QAC/B,sHAAsH;QACtH,wDAAwD;QACxD,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCompressionAlgorithms,\n\ttype IContainerRuntimeOptionsInternal,\n} from \"@fluidframework/container-runtime/internal\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { CompatibilityMode } from \"./types.js\";\n\n/**\n * Specifies the configured runtime options for each {@link CompatibilityMode}..\n */\nexport const compatibilityModeRuntimeOptions: Record<\n\tCompatibilityMode,\n\tIContainerRuntimeOptionsInternal\n> = {\n\t\"1\": {\n\t\t// 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode\n\t\t// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as\n\t\t// fewer messages will be included per flush.\n\t\tflushMode: FlushMode.Immediate,\n\t\t// Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tcompressionOptions: {\n\t\t\tminimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled\n\t\t\tcompressionAlgorithm: CompressionAlgorithms.lz4,\n\t\t},\n\t\t// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableGroupedBatching: false,\n\t\t// TODO: Include explicit disables for things that are currently off-by-default?\n\n\t\t// Explicitly disable running Sweep in compat mode \"1\". Sweep is supported only in 2.x. So, when 1.x and 2.x\n\t\t// clients are running in parallel, running sweep will fail 1.x clients.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n\t\"2\": {\n\t\t// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their\n\t\t// ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.\n\t\texplicitSchemaControl: true,\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// It introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t\t// Explicitly disable running Sweep in compat mode \"2\". Although sweep is supported in 2.x, it is disabled by default.\n\t\t// This setting explicitly disables it to be extra safe.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n};\n"]}
@@ -3,26 +3,28 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
6
- import type { CompatibilityMode, ContainerSchema, LoadableObjectKindRecord } from "./types.js";
6
+ import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
7
+ import type { CompatibilityMode, ContainerSchema } from "./types.js";
7
8
  /**
8
- * Input props for {@link RootDataObject.initializingFirstTime}.
9
- */
10
- export interface RootDataObjectProps {
11
- /**
12
- * Initial object structure with which the {@link RootDataObject} will be first-time initialized.
13
- *
14
- * @see {@link RootDataObject.initializingFirstTime}
15
- */
16
- readonly initialObjects: LoadableObjectKindRecord;
17
- }
18
- /**
19
- * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single
20
- * {@link IRootDataObject}, which is constructed from the provided schema.
9
+ * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
10
+ * with a single {@link IRootDataObject} as their entry point, where the root data object's registry
11
+ * and initial objects are configured based on the provided schema (and optionally, data store registry).
21
12
  *
22
13
  * @internal
23
14
  */
24
15
  export declare function createDOProviderContainerRuntimeFactory(props: {
16
+ /**
17
+ * The schema for the container.
18
+ */
25
19
  schema: ContainerSchema;
20
+ /**
21
+ * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.
22
+ */
26
23
  compatibilityMode: CompatibilityMode;
24
+ /**
25
+ * Optional registry of data stores to pass to the DataObject factory.
26
+ * If not provided, one will be created based on the schema.
27
+ */
28
+ rootDataStoreRegistry?: IFluidDataStoreRegistry;
27
29
  }): IRuntimeFactory;
28
30
  //# sourceMappingURL=rootDataObject.d.ts.map
@@ -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;AAUtF,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAGf,wBAAwB,EAExB,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,wBAAwB,CAAC;CAClD;AAkHD;;;;;GAKG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D,MAAM,EAAE,eAAe,CAAC;IACxB,iBAAiB,EAAE,iBAAiB,CAAC;CACrC,GAAG,eAAe,CAElB"}
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;AAMtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAO5F,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAKf,MAAM,YAAY,CAAC;AAmIpB;;;;;;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"}
@@ -3,6 +3,7 @@
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
7
  import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
7
8
  import { isDataObjectKind, isSharedObjectKind, parseDataObjectsFromSharedObjects, } from "./utils.js";
8
9
  /**
@@ -100,28 +101,37 @@ class RootDataObject extends DataObject {
100
101
  }
101
102
  const rootDataStoreId = "rootDOId";
102
103
  /**
103
- * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single
104
- * {@link IRootDataObject}, which is constructed from the provided schema.
104
+ * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
105
+ * with a single {@link IRootDataObject} as their entry point, where the root data object's registry
106
+ * and initial objects are configured based on the provided schema (and optionally, data store registry).
105
107
  *
106
108
  * @internal
107
109
  */
108
110
  export function createDOProviderContainerRuntimeFactory(props) {
109
- return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode);
111
+ const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);
112
+ const registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
113
+ return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode, new RootDataObjectFactory(sharedObjects, registry));
110
114
  }
111
115
  /**
112
- * Container code that provides a single {@link IRootDataObject}.
113
- *
114
- * @remarks
115
- *
116
- * This data object is dynamically customized (registry and initial objects) based on the schema provided.
117
- * to the container runtime factory.
118
- *
119
- * @internal
116
+ * Factory for Container Runtime instances that provide a single {@link IRootDataObject}
117
+ * as their entry point.
120
118
  */
121
119
  class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
122
- constructor(schema, compatibilityMode) {
123
- const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
124
- const rootDataObjectFactory = new DataObjectFactory("rootDO", RootDataObject, sharedObjects, {}, registryEntries);
120
+ /**
121
+ * Create a new instance of a container runtime factory.
122
+ * @remarks
123
+ * The caller is responsible for making sure that the provided root data object factory is configured
124
+ * appropriately based on the schema of the container (e.g. its registry entries contain all the
125
+ * DataStore/DDS types that the schema says can be constructed).
126
+ *
127
+ * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,
128
+ * since it can take care of constructing the root data object factory based on the schema.
129
+ *
130
+ * @param schema - The schema for the container
131
+ * @param compatibilityMode - Compatibility mode
132
+ * @param rootDataObjectFactory - A factory that can construct the root data object.
133
+ */
134
+ constructor(schema, compatibilityMode, rootDataObjectFactory) {
125
135
  const provideEntryPoint = async (containerRuntime) => {
126
136
  const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
127
137
  if (entryPoint === undefined) {
@@ -147,4 +157,18 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
147
157
  });
148
158
  }
149
159
  }
160
+ /**
161
+ * Factory that creates instances of a root data object.
162
+ */
163
+ class RootDataObjectFactory extends DataObjectFactory {
164
+ constructor(sharedObjects = [], dataStoreRegistry) {
165
+ // Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,
166
+ // and instead we override the necessary methods in this class to use the registry received in the constructor.
167
+ super("rootDO", RootDataObject, sharedObjects, {}, undefined);
168
+ this.dataStoreRegistry = dataStoreRegistry;
169
+ }
170
+ get IFluidDataStoreRegistry() {
171
+ return this.dataStoreRegistry;
172
+ }
173
+ }
150
174
  //# sourceMappingURL=rootDataObject.js.map
@@ -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;AAU3C,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AASlF,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,iCAAiC,GACjC,MAAM,YAAY,CAAC;AAcpB;;;GAGG;A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;QACzB,CAAC,CAAC;QACF,KAAK,CAAC;YACL,eAAe,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC;YACtD,cAAc,EAAE,+BAA+B,CAAC,iBAAiB,CAAC;YAClE,iBAAiB;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,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","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 type { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { FluidObject, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IDirectory } from \"@fluidframework/map/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 */\nexport interface 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} for a container with a single\n * {@link IRootDataObject}, which is constructed from the provided schema.\n *\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\tschema: ContainerSchema;\n\tcompatibilityMode: CompatibilityMode;\n}): IRuntimeFactory {\n\treturn new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode);\n}\n\n/**\n * Container code that provides a single {@link IRootDataObject}.\n *\n * @remarks\n *\n * This data object is dynamically customized (registry and initial objects) based on the schema provided.\n * to the container runtime factory.\n *\n * @internal\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\tpublic constructor(schema: ContainerSchema, compatibilityMode: CompatibilityMode) {\n\t\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\t\tconst rootDataObjectFactory = new DataObjectFactory(\n\t\t\t\"rootDO\",\n\t\t\tRootDataObject,\n\t\t\tsharedObjects,\n\t\t\t{},\n\t\t\tregistryEntries,\n\t\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"]}
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;IACZ,CAAC;IAED;;;;;OAKG;IACO,KAAK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AAC,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"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.50.1"
8
+ "packageVersion": "7.52.5"
9
9
  }
10
10
  ]
11
11
  }
package/lib/types.d.ts CHANGED
@@ -7,7 +7,10 @@ import type { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/cor
7
7
  import type { SharedObjectKind } from "@fluidframework/shared-object-base";
8
8
  import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
9
9
  /**
10
- * Valid compatibility modes that may be specified when creating a DOProviderContainerRuntimeFactory.
10
+ * Determines the set of runtime options that Fluid Framework will use when running.
11
+ * In "1" mode we support full interop between 2.x clients and 1.x clients,
12
+ * while in "2" mode we only support interop between 2.x clients.
13
+ *
11
14
  * @public
12
15
  */
13
16
  export type CompatibilityMode = "1" | "2";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAErF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,GAAG,GAAG,GAAG,CA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AC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC"}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\n/**\n * Valid compatibility modes that may be specified when creating a DOProviderContainerRuntimeFactory.\n * @public\n */\nexport type CompatibilityMode = \"1\" | \"2\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @internal\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject`.\n */\nexport type LoadableObjectKindRecord = Record<string, SharedObjectKind>;\n\n/**\n * A kind of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The kind of `DataObject` or `SharedObject`.\n *\n * @privateRemarks\n * There are some edge cases in TypeScript where the order of the members in a union matter.\n * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.\n * In this case, its better to have the desired match and/or the simpler type first.\n * In this case placing ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.\n * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].\n */\nexport type LoadableObjectKind<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectKind<T>;\n\n/**\n * Represents properties that can be attached to a container.\n * @public\n */\nexport type ContainerAttachProps<T = unknown> = T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n * @public\n */\nexport interface ContainerSchema {\n\t/**\n\t * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n\t *\n\t * @remarks It uses the key as the id and the value as the loadable object to create.\n\t *\n\t * @example\n\t *\n\t * In the example below two objects will be created when the `Container` is first\n\t * created. One with id \"map1\" that will return a `SharedMap` and the other with\n\t * id \"pair1\" that will return a `KeyValueDataObject`.\n\t *\n\t * ```typescript\n\t * {\n\t * map1: SharedMap,\n\t * pair1: KeyValueDataObject,\n\t * }\n\t * ```\n\t */\n\treadonly initialObjects: Record<string, SharedObjectKind>;\n\n\t/**\n\t * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n\t *\n\t * @remarks\n\t *\n\t * Types defined in `initialObjects` will always be available and are not required to be provided here.\n\t *\n\t * For best practice it's recommended to define all the dynamic types you create even if they are\n\t * included via initialObjects.\n\t */\n\treadonly dynamicObjectTypes?: readonly SharedObjectKind[];\n}\n\n/**\n * @internal\n */\nexport interface IProvideRootDataObject {\n\treadonly IRootDataObject: IRootDataObject;\n}\n\n/**\n * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n * @internal\n */\nexport interface IRootDataObject extends IProvideRootDataObject {\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * Dynamically creates a new detached collaborative object (DDS/DataObject).\n\t *\n\t * @param objectClass - Type of the collaborative object to be created.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T>(objectClass: SharedObjectKind<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n * @public\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n * @public\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n\t/**\n\t * Emitted when a {@link IMember | member}(s) are either added or removed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"membersChanged\", listener: () => void): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} joins the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} leaves the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n * @public\n */\nexport interface IServiceAudience<M extends IMember>\n\textends IEventProvider<IServiceAudienceEvents<M>> {\n\t/**\n\t * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n\t * member object. The implementation may choose to exclude certain connections from the returned map.\n\t * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n\t */\n\tgetMembers(): ReadonlyMap<string, M>;\n\n\t/**\n\t * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n\t */\n\tgetMyself(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n * @public\n */\nexport interface IConnection {\n\t/**\n\t * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\treadonly mode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n * @public\n */\nexport interface IMember {\n\t/**\n\t * An ID for the user, unique among each individual user connecting to the session.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\treadonly connections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { readonly currentConnection: string };\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\n/**\n * Determines the set of runtime options that Fluid Framework will use when running.\n * In \"1\" mode we support full interop between 2.x clients and 1.x clients,\n * while in \"2\" mode we only support interop between 2.x clients.\n *\n * @public\n */\nexport type CompatibilityMode = \"1\" | \"2\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @internal\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject`.\n */\nexport type LoadableObjectKindRecord = Record<string, SharedObjectKind>;\n\n/**\n * A kind of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The kind of `DataObject` or `SharedObject`.\n *\n * @privateRemarks\n * There are some edge cases in TypeScript where the order of the members in a union matter.\n * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.\n * In this case, its better to have the desired match and/or the simpler type first.\n * In this case placing ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.\n * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].\n */\nexport type LoadableObjectKind<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectKind<T>;\n\n/**\n * Represents properties that can be attached to a container.\n * @public\n */\nexport type ContainerAttachProps<T = unknown> = T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n * @public\n */\nexport interface ContainerSchema {\n\t/**\n\t * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n\t *\n\t * @remarks It uses the key as the id and the value as the loadable object to create.\n\t *\n\t * @example\n\t *\n\t * In the example below two objects will be created when the `Container` is first\n\t * created. One with id \"map1\" that will return a `SharedMap` and the other with\n\t * id \"pair1\" that will return a `KeyValueDataObject`.\n\t *\n\t * ```typescript\n\t * {\n\t * map1: SharedMap,\n\t * pair1: KeyValueDataObject,\n\t * }\n\t * ```\n\t */\n\treadonly initialObjects: Record<string, SharedObjectKind>;\n\n\t/**\n\t * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n\t *\n\t * @remarks\n\t *\n\t * Types defined in `initialObjects` will always be available and are not required to be provided here.\n\t *\n\t * For best practice it's recommended to define all the dynamic types you create even if they are\n\t * included via initialObjects.\n\t */\n\treadonly dynamicObjectTypes?: readonly SharedObjectKind[];\n}\n\n/**\n * @internal\n */\nexport interface IProvideRootDataObject {\n\treadonly IRootDataObject: IRootDataObject;\n}\n\n/**\n * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n * @internal\n */\nexport interface IRootDataObject extends IProvideRootDataObject {\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * Dynamically creates a new detached collaborative object (DDS/DataObject).\n\t *\n\t * @param objectClass - Type of the collaborative object to be created.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T>(objectClass: SharedObjectKind<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n * @public\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n * @public\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n\t/**\n\t * Emitted when a {@link IMember | member}(s) are either added or removed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"membersChanged\", listener: () => void): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} joins the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} leaves the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n * @public\n */\nexport interface IServiceAudience<M extends IMember>\n\textends IEventProvider<IServiceAudienceEvents<M>> {\n\t/**\n\t * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n\t * member object. The implementation may choose to exclude certain connections from the returned map.\n\t * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n\t */\n\tgetMembers(): ReadonlyMap<string, M>;\n\n\t/**\n\t * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n\t */\n\tgetMyself(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n * @public\n */\nexport interface IConnection {\n\t/**\n\t * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\treadonly mode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n * @public\n */\nexport interface IMember {\n\t/**\n\t * An ID for the user, unique among each individual user connecting to the session.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\treadonly connections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { readonly currentConnection: string };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/fluid-static",
3
- "version": "2.32.0",
3
+ "version": "2.33.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,33 +59,33 @@
59
59
  "temp-directory": "nyc/.nyc_output"
60
60
  },
61
61
  "dependencies": {
62
- "@fluid-internal/client-utils": "~2.32.0",
63
- "@fluidframework/aqueduct": "~2.32.0",
64
- "@fluidframework/container-definitions": "~2.32.0",
65
- "@fluidframework/container-loader": "~2.32.0",
66
- "@fluidframework/container-runtime": "~2.32.0",
67
- "@fluidframework/container-runtime-definitions": "~2.32.0",
68
- "@fluidframework/core-interfaces": "~2.32.0",
69
- "@fluidframework/datastore-definitions": "~2.32.0",
70
- "@fluidframework/driver-definitions": "~2.32.0",
71
- "@fluidframework/request-handler": "~2.32.0",
72
- "@fluidframework/runtime-definitions": "~2.32.0",
73
- "@fluidframework/runtime-utils": "~2.32.0",
74
- "@fluidframework/shared-object-base": "~2.32.0",
75
- "@fluidframework/telemetry-utils": "~2.32.0"
62
+ "@fluid-internal/client-utils": "~2.33.0",
63
+ "@fluidframework/aqueduct": "~2.33.0",
64
+ "@fluidframework/container-definitions": "~2.33.0",
65
+ "@fluidframework/container-loader": "~2.33.0",
66
+ "@fluidframework/container-runtime": "~2.33.0",
67
+ "@fluidframework/container-runtime-definitions": "~2.33.0",
68
+ "@fluidframework/core-interfaces": "~2.33.0",
69
+ "@fluidframework/datastore-definitions": "~2.33.0",
70
+ "@fluidframework/driver-definitions": "~2.33.0",
71
+ "@fluidframework/request-handler": "~2.33.0",
72
+ "@fluidframework/runtime-definitions": "~2.33.0",
73
+ "@fluidframework/runtime-utils": "~2.33.0",
74
+ "@fluidframework/shared-object-base": "~2.33.0",
75
+ "@fluidframework/telemetry-utils": "~2.33.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.32.0",
80
+ "@fluid-internal/mocha-test-setup": "~2.33.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
- "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.31.0",
86
- "@fluidframework/map": "~2.32.0",
87
- "@fluidframework/sequence": "~2.32.0",
88
- "@microsoft/api-extractor": "7.50.1",
85
+ "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.32.0",
86
+ "@fluidframework/map": "~2.33.0",
87
+ "@fluidframework/sequence": "~2.33.0",
88
+ "@microsoft/api-extractor": "7.52.5",
89
89
  "@types/mocha": "^10.0.10",
90
90
  "@types/node": "^18.19.0",
91
91
  "c8": "^8.0.1",
@@ -95,7 +95,6 @@
95
95
  "eslint": "~8.55.0",
96
96
  "mocha": "^10.8.2",
97
97
  "mocha-multi-reporters": "^1.5.1",
98
- "moment": "^2.21.0",
99
98
  "rimraf": "^4.4.0",
100
99
  "typescript": "~5.4.5"
101
100
  },
@@ -12,8 +12,7 @@ import { FlushMode } from "@fluidframework/runtime-definitions/internal";
12
12
  import type { CompatibilityMode } from "./types.js";
13
13
 
14
14
  /**
15
- * The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
16
- * full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
15
+ * Specifies the configured runtime options for each {@link CompatibilityMode}..
17
16
  */
18
17
  export const compatibilityModeRuntimeOptions: Record<
19
18
  CompatibilityMode,
@@ -10,9 +10,12 @@ import {
10
10
  DataObjectFactory,
11
11
  } from "@fluidframework/aqueduct/internal";
12
12
  import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
13
+ import { FluidDataStoreRegistry } from "@fluidframework/container-runtime/internal";
13
14
  import type { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
14
15
  import type { FluidObject, IFluidLoadable } from "@fluidframework/core-interfaces";
16
+ import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
15
17
  import type { IDirectory } from "@fluidframework/map/internal";
18
+ import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
16
19
  import type {
17
20
  ISharedObjectKind,
18
21
  SharedObjectKind,
@@ -36,7 +39,7 @@ import {
36
39
  /**
37
40
  * Input props for {@link RootDataObject.initializingFirstTime}.
38
41
  */
39
- export interface RootDataObjectProps {
42
+ interface RootDataObjectProps {
40
43
  /**
41
44
  * Initial object structure with which the {@link RootDataObject} will be first-time initialized.
42
45
  *
@@ -158,27 +161,40 @@ class RootDataObject
158
161
  const rootDataStoreId = "rootDOId";
159
162
 
160
163
  /**
161
- * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single
162
- * {@link IRootDataObject}, which is constructed from the provided schema.
164
+ * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
165
+ * with a single {@link IRootDataObject} as their entry point, where the root data object's registry
166
+ * and initial objects are configured based on the provided schema (and optionally, data store registry).
163
167
  *
164
168
  * @internal
165
169
  */
166
170
  export function createDOProviderContainerRuntimeFactory(props: {
171
+ /**
172
+ * The schema for the container.
173
+ */
167
174
  schema: ContainerSchema;
175
+ /**
176
+ * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.
177
+ */
168
178
  compatibilityMode: CompatibilityMode;
179
+ /**
180
+ * Optional registry of data stores to pass to the DataObject factory.
181
+ * If not provided, one will be created based on the schema.
182
+ */
183
+ rootDataStoreRegistry?: IFluidDataStoreRegistry;
169
184
  }): IRuntimeFactory {
170
- return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode);
185
+ const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);
186
+ const registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
187
+
188
+ return new DOProviderContainerRuntimeFactory(
189
+ props.schema,
190
+ props.compatibilityMode,
191
+ new RootDataObjectFactory(sharedObjects, registry),
192
+ );
171
193
  }
172
194
 
173
195
  /**
174
- * Container code that provides a single {@link IRootDataObject}.
175
- *
176
- * @remarks
177
- *
178
- * This data object is dynamically customized (registry and initial objects) based on the schema provided.
179
- * to the container runtime factory.
180
- *
181
- * @internal
196
+ * Factory for Container Runtime instances that provide a single {@link IRootDataObject}
197
+ * as their entry point.
182
198
  */
183
199
  class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
184
200
  private readonly rootDataObjectFactory: DataObjectFactory<
@@ -190,15 +206,28 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
190
206
 
191
207
  private readonly initialObjects: LoadableObjectKindRecord;
192
208
 
193
- public constructor(schema: ContainerSchema, compatibilityMode: CompatibilityMode) {
194
- const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
195
- const rootDataObjectFactory = new DataObjectFactory(
196
- "rootDO",
209
+ /**
210
+ * Create a new instance of a container runtime factory.
211
+ * @remarks
212
+ * The caller is responsible for making sure that the provided root data object factory is configured
213
+ * appropriately based on the schema of the container (e.g. its registry entries contain all the
214
+ * DataStore/DDS types that the schema says can be constructed).
215
+ *
216
+ * Most scenarios probably want to use {@link createDOProviderContainerRuntimeFactory} instead,
217
+ * since it can take care of constructing the root data object factory based on the schema.
218
+ *
219
+ * @param schema - The schema for the container
220
+ * @param compatibilityMode - Compatibility mode
221
+ * @param rootDataObjectFactory - A factory that can construct the root data object.
222
+ */
223
+ public constructor(
224
+ schema: ContainerSchema,
225
+ compatibilityMode: CompatibilityMode,
226
+ rootDataObjectFactory: DataObjectFactory<
197
227
  RootDataObject,
198
- sharedObjects,
199
- {},
200
- registryEntries,
201
- );
228
+ { InitialState: RootDataObjectProps }
229
+ >,
230
+ ) {
202
231
  const provideEntryPoint = async (
203
232
  containerRuntime: IContainerRuntime,
204
233
  // eslint-disable-next-line unicorn/consistent-function-scoping
@@ -228,3 +257,24 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
228
257
  });
229
258
  }
230
259
  }
260
+
261
+ /**
262
+ * Factory that creates instances of a root data object.
263
+ */
264
+ class RootDataObjectFactory extends DataObjectFactory<
265
+ RootDataObject,
266
+ { InitialState: RootDataObjectProps }
267
+ > {
268
+ public constructor(
269
+ sharedObjects: readonly IChannelFactory[] = [],
270
+ private readonly dataStoreRegistry: IFluidDataStoreRegistry,
271
+ ) {
272
+ // Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,
273
+ // and instead we override the necessary methods in this class to use the registry received in the constructor.
274
+ super("rootDO", RootDataObject, sharedObjects, {}, undefined);
275
+ }
276
+
277
+ public get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {
278
+ return this.dataStoreRegistry;
279
+ }
280
+ }
package/src/types.ts CHANGED
@@ -9,7 +9,10 @@ import type { SharedObjectKind } from "@fluidframework/shared-object-base";
9
9
  import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
10
10
 
11
11
  /**
12
- * Valid compatibility modes that may be specified when creating a DOProviderContainerRuntimeFactory.
12
+ * Determines the set of runtime options that Fluid Framework will use when running.
13
+ * In "1" mode we support full interop between 2.x clients and 1.x clients,
14
+ * while in "2" mode we only support interop between 2.x clients.
15
+ *
13
16
  * @public
14
17
  */
15
18
  export type CompatibilityMode = "1" | "2";