@fluidframework/fluid-static 2.0.0-rc.4.0.5 → 2.0.0-rc.5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/api-extractor/api-extractor-lint-bundle.json +5 -0
  3. package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
  4. package/api-extractor/api-extractor-lint-public.esm.json +5 -0
  5. package/api-extractor.json +1 -1
  6. package/api-report/{fluid-static.api.md → fluid-static.alpha.api.md} +15 -57
  7. package/api-report/fluid-static.beta.api.md +94 -0
  8. package/api-report/fluid-static.public.api.md +94 -0
  9. package/biome.jsonc +4 -0
  10. package/dist/compatibilityConfiguration.d.ts +12 -0
  11. package/dist/compatibilityConfiguration.d.ts.map +1 -0
  12. package/dist/compatibilityConfiguration.js +38 -0
  13. package/dist/compatibilityConfiguration.js.map +1 -0
  14. package/dist/fluidContainer.d.ts +22 -10
  15. package/dist/fluidContainer.d.ts.map +1 -1
  16. package/dist/fluidContainer.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/public.d.ts +1 -3
  21. package/dist/rootDataObject.d.ts +4 -3
  22. package/dist/rootDataObject.d.ts.map +1 -1
  23. package/dist/rootDataObject.js +11 -18
  24. package/dist/rootDataObject.js.map +1 -1
  25. package/dist/serviceAudience.d.ts +3 -3
  26. package/dist/serviceAudience.d.ts.map +1 -1
  27. package/dist/serviceAudience.js.map +1 -1
  28. package/dist/types.d.ts +19 -21
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js.map +1 -1
  31. package/dist/utils.d.ts +7 -14
  32. package/dist/utils.d.ts.map +1 -1
  33. package/dist/utils.js.map +1 -1
  34. package/lib/compatibilityConfiguration.d.ts +12 -0
  35. package/lib/compatibilityConfiguration.d.ts.map +1 -0
  36. package/lib/compatibilityConfiguration.js +35 -0
  37. package/lib/compatibilityConfiguration.js.map +1 -0
  38. package/lib/fluidContainer.d.ts +22 -10
  39. package/lib/fluidContainer.d.ts.map +1 -1
  40. package/lib/fluidContainer.js.map +1 -1
  41. package/lib/index.d.ts +1 -1
  42. package/lib/index.d.ts.map +1 -1
  43. package/lib/index.js.map +1 -1
  44. package/lib/public.d.ts +1 -3
  45. package/lib/rootDataObject.d.ts +4 -3
  46. package/lib/rootDataObject.d.ts.map +1 -1
  47. package/lib/rootDataObject.js +9 -16
  48. package/lib/rootDataObject.js.map +1 -1
  49. package/lib/serviceAudience.d.ts +3 -3
  50. package/lib/serviceAudience.d.ts.map +1 -1
  51. package/lib/serviceAudience.js.map +1 -1
  52. package/lib/tsdoc-metadata.json +1 -1
  53. package/lib/types.d.ts +19 -21
  54. package/lib/types.d.ts.map +1 -1
  55. package/lib/types.js.map +1 -1
  56. package/lib/utils.d.ts +7 -14
  57. package/lib/utils.d.ts.map +1 -1
  58. package/lib/utils.js.map +1 -1
  59. package/package.json +49 -29
  60. package/src/compatibilityConfiguration.ts +44 -0
  61. package/src/fluidContainer.ts +24 -21
  62. package/src/index.ts +13 -15
  63. package/src/rootDataObject.ts +38 -41
  64. package/src/serviceAudience.ts +5 -10
  65. package/src/types.ts +20 -23
  66. package/src/utils.ts +10 -22
  67. package/tsconfig.json +1 -0
  68. package/tsdoc.json +4 -0
package/dist/public.d.ts CHANGED
@@ -10,9 +10,9 @@
10
10
 
11
11
  export {
12
12
  // @public APIs
13
+ CompatibilityMode,
13
14
  ContainerAttachProps,
14
15
  ContainerSchema,
15
- DataObjectClass,
16
16
  IConnection,
17
17
  IFluidContainer,
18
18
  IFluidContainerEvents,
@@ -20,8 +20,6 @@ export {
20
20
  IServiceAudience,
21
21
  IServiceAudienceEvents,
22
22
  InitialObjects,
23
- LoadableObjectClass,
24
- LoadableObjectClassRecord,
25
23
  MemberChangedListener,
26
24
  Myself
27
25
  } from "./index.js";
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IRuntimeFactory } from "@fluidframework/container-definitions/internal";
6
- import { type ContainerSchema, type LoadableObjectClassRecord } from "./types.js";
5
+ import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
6
+ import type { CompatibilityMode, ContainerSchema, LoadableObjectClassRecord } from "./types.js";
7
7
  /**
8
8
  * Input props for {@link RootDataObject.initializingFirstTime}.
9
9
  */
@@ -13,7 +13,7 @@ export interface RootDataObjectProps {
13
13
  *
14
14
  * @see {@link RootDataObject.initializingFirstTime}
15
15
  */
16
- initialObjects: LoadableObjectClassRecord;
16
+ readonly initialObjects: LoadableObjectClassRecord;
17
17
  }
18
18
  /**
19
19
  * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single
@@ -23,5 +23,6 @@ export interface RootDataObjectProps {
23
23
  */
24
24
  export declare function createDOProviderContainerRuntimeFactory(props: {
25
25
  schema: ContainerSchema;
26
+ compatibilityMode: CompatibilityMode;
26
27
  }): IRuntimeFactory;
27
28
  //# sourceMappingURL=rootDataObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gDAAgD,CAAC;AActF,OAAO,EACN,KAAK,eAAe,EAGpB,KAAK,yBAAyB,EAE9B,MAAM,YAAY,CAAC;AAQpB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,cAAc,EAAE,yBAAyB,CAAC;CAC1C;AA+GD;;;;;GAKG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D,MAAM,EAAE,eAAe,CAAC;CACxB,GAAG,eAAe,CAElB"}
1
+ {"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAetF,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAIf,yBAAyB,EAEzB,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,yBAAyB,CAAC;CACnD;AAkHD;;;;;GAKG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D,MAAM,EAAE,eAAe,CAAC;IACxB,iBAAiB,EAAE,iBAAiB,CAAC;CACrC,GAAG,eAAe,CAElB"}
@@ -6,8 +6,8 @@
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/runtime-definitions/internal");
10
- const internal_3 = require("@fluidframework/runtime-utils/internal");
9
+ const internal_2 = require("@fluidframework/runtime-utils/internal");
10
+ const compatibilityConfiguration_js_1 = require("./compatibilityConfiguration.js");
11
11
  const utils_js_1 = require("./utils.js");
12
12
  /**
13
13
  * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
@@ -80,11 +80,12 @@ class RootDataObject extends internal_1.DataObject {
80
80
  * {@inheritDoc IRootDataObject.create}
81
81
  */
82
82
  async create(objectClass) {
83
- if ((0, utils_js_1.isDataObjectClass)(objectClass)) {
84
- return this.createDataObject(objectClass);
83
+ const internal = objectClass;
84
+ if ((0, utils_js_1.isDataObjectClass)(internal)) {
85
+ return this.createDataObject(internal);
85
86
  }
86
- else if ((0, utils_js_1.isSharedObjectKind)(objectClass)) {
87
- return this.createSharedObject(objectClass);
87
+ else if ((0, utils_js_1.isSharedObjectKind)(internal)) {
88
+ return this.createSharedObject(internal);
88
89
  }
89
90
  throw new Error("Could not create new Fluid object because an unknown object was passed");
90
91
  }
@@ -109,7 +110,7 @@ const rootDataStoreId = "rootDOId";
109
110
  * @internal
110
111
  */
111
112
  function createDOProviderContainerRuntimeFactory(props) {
112
- return new DOProviderContainerRuntimeFactory(props.schema);
113
+ return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode);
113
114
  }
114
115
  exports.createDOProviderContainerRuntimeFactory = createDOProviderContainerRuntimeFactory;
115
116
  /**
@@ -123,7 +124,7 @@ exports.createDOProviderContainerRuntimeFactory = createDOProviderContainerRunti
123
124
  * @internal
124
125
  */
125
126
  class DOProviderContainerRuntimeFactory extends internal_1.BaseContainerRuntimeFactory {
126
- constructor(schema) {
127
+ constructor(schema, compatibilityMode) {
127
128
  const [registryEntries, sharedObjects] = (0, utils_js_1.parseDataObjectsFromSharedObjects)(schema);
128
129
  const rootDataObjectFactory = new internal_1.DataObjectFactory("rootDO", RootDataObject, sharedObjects, {}, registryEntries);
129
130
  const provideEntryPoint = async (containerRuntime) => {
@@ -134,7 +135,7 @@ class DOProviderContainerRuntimeFactory extends internal_1.BaseContainerRuntimeF
134
135
  return entryPoint.get();
135
136
  };
136
137
  const getDefaultObject = async (request, runtime) => {
137
- const parser = internal_3.RequestParser.create(request);
138
+ const parser = internal_2.RequestParser.create(request);
138
139
  if (parser.pathParts.length === 0) {
139
140
  // This cast is safe as ContainerRuntime.loadRuntime is called in the base class
140
141
  return runtime.resolveHandle({
@@ -147,15 +148,7 @@ class DOProviderContainerRuntimeFactory extends internal_1.BaseContainerRuntimeF
147
148
  super({
148
149
  registryEntries: [rootDataObjectFactory.registryEntry],
149
150
  requestHandlers: [getDefaultObject],
150
- // WARNING: These settigs are not compatible with FF 1.3 clients!
151
- runtimeOptions: {
152
- // temporary workaround to disable message batching until the message batch size issue is resolved
153
- // resolution progress is tracked by the Feature 465 work item in AzDO
154
- flushMode: internal_2.FlushMode.Immediate,
155
- // The runtime compressor is required to be on to use @fluidframework/tree.
156
- enableRuntimeIdCompressor: "on",
157
- explicitSchemaControl: true,
158
- },
151
+ runtimeOptions: compatibilityConfiguration_js_1.compatibilityModeRuntimeOptions[compatibilityMode],
159
152
  provideEntryPoint,
160
153
  });
161
154
  this.rootDataObjectFactory = rootDataObjectFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAI2C;AAW3C,2EAAyE;AACzE,qEAAuE;AAUvE,yCAKoB;AAcpB;;;GAGG;AACH,MAAM,cACL,SAAQ,qBAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IAgG7D,CAAC;IA9FA,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;YACtB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACpE;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;YACrE,MAAM,YAAY,GAAG,KAAK,IAAmB,EAAE;gBAC9C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAiB,WAAW,CAAC,CAAC;gBAC3D,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;YAC5C,CAAC,CAAC;YACF,eAAe,CAAC,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C;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\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport { type IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport { type ContainerRuntime } from \"@fluidframework/container-runtime/internal\";\nimport { type IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport {\n\ttype FluidObject,\n\ttype IFluidLoadable,\n\ttype IRequest,\n\ttype IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { type IDirectory } from \"@fluidframework/map/internal\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions/internal\";\nimport { RequestParser } from \"@fluidframework/runtime-utils/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport {\n\ttype ContainerSchema,\n\ttype IRootDataObject,\n\ttype LoadableObjectClass,\n\ttype LoadableObjectClassRecord,\n\ttype LoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\ttype InternalDataObjectClass,\n\tisDataObjectClass,\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\tinitialObjects: LoadableObjectClassRecord;\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>(objectClass);\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 extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n\t\tif (isDataObjectClass(objectClass)) {\n\t\t\treturn this.createDataObject(objectClass);\n\t\t} else if (isSharedObjectKind(objectClass)) {\n\t\t\treturn this.createSharedObject(objectClass);\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: InternalDataObjectClass<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 unknown 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}): IRuntimeFactory {\n\treturn new DOProviderContainerRuntimeFactory(props.schema);\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: LoadableObjectClassRecord;\n\n\tpublic constructor(schema: ContainerSchema) {\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 =\n\t\t\t\tawait 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\tconst getDefaultObject = async (\n\t\t\trequest: IRequest,\n\t\t\truntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<IResponse | undefined> => {\n\t\t\tconst parser = RequestParser.create(request);\n\t\t\tif (parser.pathParts.length === 0) {\n\t\t\t\t// This cast is safe as ContainerRuntime.loadRuntime is called in the base class\n\t\t\t\treturn (runtime as ContainerRuntime).resolveHandle({\n\t\t\t\t\turl: `/${rootDataStoreId}${parser.query}`,\n\t\t\t\t\theaders: request.headers,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined; // continue search\n\t\t};\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\trequestHandlers: [getDefaultObject],\n\t\t\t// WARNING: These settigs are not compatible with FF 1.3 clients!\n\t\t\truntimeOptions: {\n\t\t\t\t// temporary workaround to disable message batching until the message batch size issue is resolved\n\t\t\t\t// resolution progress is tracked by the Feature 465 work item in AzDO\n\t\t\t\tflushMode: FlushMode.Immediate,\n\t\t\t\t// The runtime compressor is required to be on to use @fluidframework/tree.\n\t\t\t\tenableRuntimeIdCompressor: \"on\",\n\t\t\t\texplicitSchemaControl: true,\n\t\t\t},\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,gEAI2C;AAW3C,qEAAuE;AAIvE,mFAAkF;AAUlF,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,I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CAAC;YACL,eAAe,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC;YACtD,eAAe,EAAE,CAAC,gBAAgB,CAAC;YACnC,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\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport type { ContainerRuntime } from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIFluidLoadable,\n\tIRequest,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport type { IDirectory } from \"@fluidframework/map/internal\";\nimport { RequestParser } from \"@fluidframework/runtime-utils/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tDataObjectClass,\n\tIRootDataObject,\n\tLoadableObjectClass,\n\tLoadableObjectClassRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tisDataObjectClass,\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: LoadableObjectClassRecord;\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 LoadableObjectClass<T & IFluidLoadable>;\n\t\tif (isDataObjectClass(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: DataObjectClass<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: LoadableObjectClassRecord;\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\tconst getDefaultObject = async (\n\t\t\trequest: IRequest,\n\t\t\truntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<IResponse | undefined> => {\n\t\t\tconst parser = RequestParser.create(request);\n\t\t\tif (parser.pathParts.length === 0) {\n\t\t\t\t// This cast is safe as ContainerRuntime.loadRuntime is called in the base class\n\t\t\t\treturn (runtime as ContainerRuntime).resolveHandle({\n\t\t\t\t\turl: `/${rootDataStoreId}${parser.query}`,\n\t\t\t\t\theaders: request.headers,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined; // continue search\n\t\t};\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\trequestHandlers: [getDefaultObject],\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"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IContainer } from "@fluidframework/container-definitions/internal";
6
- import { type IClient } from "@fluidframework/protocol-definitions";
7
- import { type IMember, type IServiceAudience } from "./types.js";
5
+ import type { IContainer } from "@fluidframework/container-definitions/internal";
6
+ import type { IClient } from "@fluidframework/driver-definitions";
7
+ import type { IMember, IServiceAudience } from "./types.js";
8
8
  /**
9
9
  * Creates a service audience for the provided container.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"serviceAudience.d.ts","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,gBAAgB,EAGrB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,EAAE,KAAK,EAAE;IAC/E,SAAS,EAAE,UAAU,CAAC;IACtB,mBAAmB,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,OAAO,CAAC;CAC1D,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAE5B"}
1
+ {"version":3,"file":"serviceAudience.d.ts","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAkC,MAAM,YAAY,CAAC;AAE5F;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,EAAE,KAAK,EAAE;IAC/E,SAAS,EAAE,UAAU,CAAC;IACtB,mBAAmB,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,OAAO,CAAC;CAC1D,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAE5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"serviceAudience.js","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAE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,SAAS,CAAC;SACjB;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,MAAM,KAAK,SAAS,EAAE;YACzB,OAAO,SAAS,CAAC;SACjB;QAED,MAAM,MAAM,GAAoB,EAAE,GAAG,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC;QAE3E,OAAO,MAAM,CAAC;IACf,CAAC;IAEO,SAAS,CAAC,QAAgB;QACjC,oEAAoE;QACpE,MAAM,sBAAsB,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACjE,IAAI,sBAAsB,KAAK,SAAS,EAAE;YACzC,OAAO,SAAS,CAAC;SACjB;QACD,2EAA2E;QAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/D,IAAI,MAAM,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,KAAK,CACd,6BAA6B,QAAQ,8CAA8C,CACnF,CAAC;SACF;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,MAAe;QAC5C,6BAA6B;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { type IAudience } from \"@fluidframework/container-definitions\";\nimport { type IContainer } from \"@fluidframework/container-definitions/internal\";\nimport { type IClient } from \"@fluidframework/protocol-definitions\";\n\nimport {\n\ttype IMember,\n\ttype IServiceAudience,\n\ttype IServiceAudienceEvents,\n\ttype Myself,\n} from \"./types.js\";\n\n/**\n * Creates a service audience for the provided container.\n *\n * @param container - The container with which the audience is associated.\n * @param createServiceMember - A function for creating audience members.\n *\n * @typeParam TMember - The {@link IMember} representation used by the audience.\n *\n * @internal\n */\nexport function createServiceAudience<TMember extends IMember = IMember>(props: {\n\tcontainer: IContainer;\n\tcreateServiceMember: (audienceMember: IClient) => TMember;\n}): IServiceAudience<TMember> {\n\treturn new ServiceAudience(props.container, props.createServiceMember);\n}\n\n/**\n * Base class for providing audience information for sessions interacting with {@link IFluidContainer}\n *\n * @remarks\n *\n * This can be extended by different service-specific client packages to additional parameters to\n * the user and client details returned in {@link IMember}.\n *\n * @typeParam TMember - A service-specific {@link IMember} implementation.\n *\n * @internal\n */\nclass ServiceAudience<TMember extends IMember = IMember>\n\textends TypedEventEmitter<IServiceAudienceEvents<TMember>>\n\timplements IServiceAudience<TMember>\n{\n\t/**\n\t * Audience object which includes all the existing members of the {@link IFluidContainer | container}.\n\t */\n\tprivate readonly audience: IAudience;\n\n\t/**\n\t * Retain the most recent member list.\n\t *\n\t * @remarks\n\t *\n\t * This is so we have more information about a member leaving the audience in the `removeMember` event.\n\t *\n\t * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this\n\t * class exposes (and would actually produce a change in what `getMembers` returns).\n\t *\n\t * It also allows us to provide the client details in the event which makes it easier to find that client connection\n\t * in a map keyed on the `userId` and not `clientId`.\n\t *\n\t * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in\n\t * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}\n\t * events provide.\n\t */\n\tprivate lastMembers = new Map<string, TMember>();\n\n\tpublic constructor(\n\t\t/**\n\t\t * Fluid Container to read the audience from.\n\t\t */\n\t\tprivate readonly container: IContainer,\n\t\tprivate readonly createServiceMember: (audienceMember: IClient) => TMember,\n\t) {\n\t\tsuper();\n\t\tthis.audience = container.audience;\n\n\t\t// getMembers will assign lastMembers so the removeMember event has what it needs\n\t\t// in case it would fire before getMembers otherwise gets called the first time\n\t\tthis.getMembers();\n\n\t\tthis.audience.on(\"addMember\", (clientId: string, details: IClient) => {\n\t\t\tif (this.shouldIncludeAsMember(details)) {\n\t\t\t\tconst member = this.getMember(clientId);\n\t\t\t\tthis.emit(\"memberAdded\", clientId, member);\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.audience.on(\"removeMember\", (clientId: string) => {\n\t\t\tif (this.lastMembers.has(clientId)) {\n\t\t\t\tthis.emit(\"memberRemoved\", clientId, this.lastMembers.get(clientId));\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.container.on(\"connected\", () => this.emit(\"membersChanged\"));\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMembers}\n\t */\n\tpublic getMembers(): Map<string, TMember> {\n\t\tconst users = new Map<string, TMember>();\n\t\tconst clientMemberMap = new Map<string, TMember>();\n\t\t// Iterate through the members and get the user specifics.\n\t\tfor (const [clientId, member] of this.audience.getMembers()) {\n\t\t\tif (this.shouldIncludeAsMember(member)) {\n\t\t\t\tconst userId = member.user.id;\n\t\t\t\t// Ensure we're tracking the user\n\t\t\t\tlet user = users.get(userId);\n\t\t\t\tif (user === undefined) {\n\t\t\t\t\tuser = this.createServiceMember(member);\n\t\t\t\t\tusers.set(userId, user);\n\t\t\t\t}\n\n\t\t\t\t// Add this connection to their collection\n\t\t\t\tuser.connections.push({ id: clientId, mode: member.mode });\n\t\t\t\tclientMemberMap.set(clientId, user);\n\t\t\t}\n\t\t}\n\t\tthis.lastMembers = clientMemberMap;\n\t\treturn users;\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMyself}\n\t */\n\tpublic getMyself(): Myself<TMember> | undefined {\n\t\tconst clientId = this.container.clientId;\n\t\tif (clientId === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst member = this.getMember(clientId);\n\t\tif (member === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst myself: Myself<TMember> = { ...member, currentConnection: clientId };\n\n\t\treturn myself;\n\t}\n\n\tprivate getMember(clientId: string): TMember | undefined {\n\t\t// Fetch the user ID assoicated with this client ID from the runtime\n\t\tconst internalAudienceMember = this.audience.getMember(clientId);\n\t\tif (internalAudienceMember === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Return the member object with any other clients associated for this user\n\t\tconst allMembers = this.getMembers();\n\t\tconst member = allMembers.get(internalAudienceMember?.user.id);\n\t\tif (member === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempted to fetch client ${clientId} that is not part of the current member list`,\n\t\t\t);\n\t\t}\n\t\treturn member;\n\t}\n\n\t/**\n\t * Provides ability for the inheriting class to include/omit specific members.\n\t * An example use case is omitting the summarizer client.\n\t *\n\t * @param member - Member to be included/omitted.\n\t */\n\tprivate shouldIncludeAsMember(member: IClient): boolean {\n\t\t// Include only human members\n\t\treturn member.details.capabilities.interactive;\n\t}\n}\n"]}
1
+ {"version":3,"file":"serviceAudience.js","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAOjE;;;;;;;;;GASG;AACH,SAAgB,qBAAqB,CAAoC,KAGxE;IACA,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACxE,CAAC;AALD,sDAKC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,eACL,SAAQ,gCAAkD;IA2B1D;IACC;;OAEG;IACc,SAAqB,EACrB,mBAAyD;QAE1E,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAY;QACrB,wBAAmB,GAAnB,mBAAmB,CAAsC;QAxB3E;;;;;;;;;;;;;;;;WAgBG;QACK,gBAAW,GAAG,IAAI,GAAG,EAAmB,CAAC;QAUhD,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;QAEnC,iFAAiF;QACjF,+EAA+E;QAC/E,IAAI,CAAC,UAAU,EAAE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EAA2E;QAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACd,6BAA6B,QAAQ,8CAA8C,CACnF,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,MAAe;QAC5C,6BAA6B;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport type { IContainer } from \"@fluidframework/container-definitions/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\n\nimport type { IMember, IServiceAudience, IServiceAudienceEvents, Myself } from \"./types.js\";\n\n/**\n * Creates a service audience for the provided container.\n *\n * @param container - The container with which the audience is associated.\n * @param createServiceMember - A function for creating audience members.\n *\n * @typeParam TMember - The {@link IMember} representation used by the audience.\n *\n * @internal\n */\nexport function createServiceAudience<TMember extends IMember = IMember>(props: {\n\tcontainer: IContainer;\n\tcreateServiceMember: (audienceMember: IClient) => TMember;\n}): IServiceAudience<TMember> {\n\treturn new ServiceAudience(props.container, props.createServiceMember);\n}\n\n/**\n * Base class for providing audience information for sessions interacting with {@link IFluidContainer}\n *\n * @remarks\n *\n * This can be extended by different service-specific client packages to additional parameters to\n * the user and client details returned in {@link IMember}.\n *\n * @typeParam TMember - A service-specific {@link IMember} implementation.\n *\n * @internal\n */\nclass ServiceAudience<TMember extends IMember = IMember>\n\textends TypedEventEmitter<IServiceAudienceEvents<TMember>>\n\timplements IServiceAudience<TMember>\n{\n\t/**\n\t * Audience object which includes all the existing members of the {@link IFluidContainer | container}.\n\t */\n\tprivate readonly audience: IAudience;\n\n\t/**\n\t * Retain the most recent member list.\n\t *\n\t * @remarks\n\t *\n\t * This is so we have more information about a member leaving the audience in the `removeMember` event.\n\t *\n\t * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this\n\t * class exposes (and would actually produce a change in what `getMembers` returns).\n\t *\n\t * It also allows us to provide the client details in the event which makes it easier to find that client connection\n\t * in a map keyed on the `userId` and not `clientId`.\n\t *\n\t * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in\n\t * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}\n\t * events provide.\n\t */\n\tprivate lastMembers = new Map<string, TMember>();\n\n\tpublic constructor(\n\t\t/**\n\t\t * Fluid Container to read the audience from.\n\t\t */\n\t\tprivate readonly container: IContainer,\n\t\tprivate readonly createServiceMember: (audienceMember: IClient) => TMember,\n\t) {\n\t\tsuper();\n\t\tthis.audience = container.audience;\n\n\t\t// getMembers will assign lastMembers so the removeMember event has what it needs\n\t\t// in case it would fire before getMembers otherwise gets called the first time\n\t\tthis.getMembers();\n\n\t\tthis.audience.on(\"addMember\", (clientId: string, details: IClient) => {\n\t\t\tif (this.shouldIncludeAsMember(details)) {\n\t\t\t\tconst member = this.getMember(clientId);\n\t\t\t\tthis.emit(\"memberAdded\", clientId, member);\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.audience.on(\"removeMember\", (clientId: string) => {\n\t\t\tif (this.lastMembers.has(clientId)) {\n\t\t\t\tthis.emit(\"memberRemoved\", clientId, this.lastMembers.get(clientId));\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.container.on(\"connected\", () => this.emit(\"membersChanged\"));\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMembers}\n\t */\n\tpublic getMembers(): Map<string, TMember> {\n\t\tconst users = new Map<string, TMember>();\n\t\tconst clientMemberMap = new Map<string, TMember>();\n\t\t// Iterate through the members and get the user specifics.\n\t\tfor (const [clientId, member] of this.audience.getMembers()) {\n\t\t\tif (this.shouldIncludeAsMember(member)) {\n\t\t\t\tconst userId = member.user.id;\n\t\t\t\t// Ensure we're tracking the user\n\t\t\t\tlet user = users.get(userId);\n\t\t\t\tif (user === undefined) {\n\t\t\t\t\tuser = this.createServiceMember(member);\n\t\t\t\t\tusers.set(userId, user);\n\t\t\t\t}\n\n\t\t\t\t// Add this connection to their collection\n\t\t\t\tuser.connections.push({ id: clientId, mode: member.mode });\n\t\t\t\tclientMemberMap.set(clientId, user);\n\t\t\t}\n\t\t}\n\t\tthis.lastMembers = clientMemberMap;\n\t\treturn users;\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMyself}\n\t */\n\tpublic getMyself(): Myself<TMember> | undefined {\n\t\tconst clientId = this.container.clientId;\n\t\tif (clientId === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst member = this.getMember(clientId);\n\t\tif (member === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst myself: Myself<TMember> = { ...member, currentConnection: clientId };\n\n\t\treturn myself;\n\t}\n\n\tprivate getMember(clientId: string): TMember | undefined {\n\t\t// Fetch the user ID assoicated with this client ID from the runtime\n\t\tconst internalAudienceMember = this.audience.getMember(clientId);\n\t\tif (internalAudienceMember === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Return the member object with any other clients associated for this user\n\t\tconst allMembers = this.getMembers();\n\t\tconst member = allMembers.get(internalAudienceMember?.user.id);\n\t\tif (member === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempted to fetch client ${clientId} that is not part of the current member list`,\n\t\t\t);\n\t\t}\n\t\treturn member;\n\t}\n\n\t/**\n\t * Provides ability for the inheriting class to include/omit specific members.\n\t * An example use case is omitting the summarizer client.\n\t *\n\t * @param member - Member to be included/omitted.\n\t */\n\tprivate shouldIncludeAsMember(member: IClient): boolean {\n\t\t// Include only human members\n\t\treturn member.details.capabilities.interactive;\n\t}\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -2,8 +2,15 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IEvent, type IEventProvider, type IFluidLoadable } from "@fluidframework/core-interfaces";
6
- import { type ISharedObjectKind } from "@fluidframework/shared-object-base";
5
+ import type { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
6
+ import type { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions/internal";
7
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base";
8
+ import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
9
+ /**
10
+ * Valid compatibility modes that may be specified when creating a DOProviderContainerRuntimeFactory.
11
+ * @public
12
+ */
13
+ export type CompatibilityMode = "1" | "2";
7
14
  /**
8
15
  * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
9
16
  * @internal
@@ -12,14 +19,12 @@ export type LoadableObjectRecord = Record<string, IFluidLoadable>;
12
19
  /**
13
20
  * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
14
21
  * or `SharedObject`.
15
- * @public
16
22
  */
17
- export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
23
+ export type LoadableObjectClassRecord = Record<string, SharedObjectKind>;
18
24
  /**
19
25
  * A class object of `DataObject` or `SharedObject`.
20
26
  *
21
27
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
22
- * @public
23
28
  *
24
29
  * @privateRemarks
25
30
  * There are some edge cases in TypeScript where the order of the members in a union matter.
@@ -35,20 +40,13 @@ export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = ISh
35
40
  *
36
41
  * @typeParam T - The class of the `DataObject`.
37
42
  * @privateRemarks
38
- * Having both `factory` and `LoadableObjectCtor` is redundant.
39
- * TODO: It appears the factory is what's used, so the constructor should be removed.
40
- * @public
43
+ * Having both `factory` and constructor is redundant.
44
+ * TODO: It appears the factory is what's used, so the constructor should be removed once factory provides strong typing.
41
45
  */
42
- export type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
43
- /**
44
- * @privateRemarks
45
- * This has to implement {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory}.
46
- * TODO: Gain type safety for this without leaking IFluidDataStoreFactory as public using type erasure.
47
- */
48
- readonly factory: {
49
- readonly IFluidDataStoreFactory: DataObjectClass<T>["factory"];
50
- };
51
- } & (new (...args: any[]) => T);
46
+ export interface DataObjectClass<T extends IFluidLoadable> {
47
+ readonly factory: IFluidDataStoreFactory;
48
+ new (...args: any[]): T;
49
+ }
52
50
  /**
53
51
  * Represents properties that can be attached to a container.
54
52
  * @public
@@ -82,7 +80,7 @@ export interface ContainerSchema {
82
80
  * }
83
81
  * ```
84
82
  */
85
- readonly initialObjects: LoadableObjectClassRecord;
83
+ readonly initialObjects: Record<string, SharedObjectKind>;
86
84
  /**
87
85
  * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.
88
86
  *
@@ -93,7 +91,7 @@ export interface ContainerSchema {
93
91
  * For best practice it's recommended to define all the dynamic types you create even if they are
94
92
  * included via initialObjects.
95
93
  */
96
- readonly dynamicObjectTypes?: readonly LoadableObjectClass[];
94
+ readonly dynamicObjectTypes?: readonly SharedObjectKind[];
97
95
  }
98
96
  /**
99
97
  * @internal
@@ -118,7 +116,7 @@ export interface IRootDataObject extends IProvideRootDataObject {
118
116
  *
119
117
  * @typeParam T - The class of the `DataObject` or `SharedObject`.
120
118
  */
121
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
119
+ create<T>(objectClass: SharedObjectKind<T>): Promise<T>;
122
120
  }
123
121
  /**
124
122
  * Signature for {@link IMember} change events.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,O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CAAC,CAAC,SAAS,OAAO,CAClD,SAAQ,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;IACjD;;;;OAIG;IACH,UAAU,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAErC;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,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 {\n\ttype IEvent,\n\ttype IEventProvider,\n\ttype IFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { type ISharedObjectKind } from \"@fluidframework/shared-object-base\";\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 * @public\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n * @public\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 LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectClass<T>;\n\n/**\n * A class that has a factory that can create a `DataObject` and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `DataObject`.\n * @privateRemarks\n * Having both `factory` and `LoadableObjectCtor` is redundant.\n * TODO: It appears the factory is what's used, so the constructor should be removed.\n * @public\n */\nexport type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {\n\t/**\n\t * @privateRemarks\n\t * This has to implement {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory}.\n\t * TODO: Gain type safety for this without leaking IFluidDataStoreFactory as public using type erasure.\n\t */\n\treadonly factory: { readonly IFluidDataStoreFactory: DataObjectClass<T>[\"factory\"] };\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & (new (...args: any[]) => 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: LoadableObjectClassRecord;\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 LoadableObjectClass[];\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 extends IFluidLoadable>(objectClass: LoadableObjectClass<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 { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions/internal\";\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 LoadableObjectClassRecord = Record<string, SharedObjectKind>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `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 LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectClass<T>;\n\n/**\n * A class that has a factory that can create a `DataObject` and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `DataObject`.\n * @privateRemarks\n * Having both `factory` and constructor is redundant.\n * TODO: It appears the factory is what's used, so the constructor should be removed once factory provides strong typing.\n */\nexport interface DataObjectClass<T extends IFluidLoadable> {\n\treadonly factory: IFluidDataStoreFactory;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tnew (...args: any[]): T;\n}\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/dist/utils.d.ts CHANGED
@@ -2,26 +2,19 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IFluidLoadable } from "@fluidframework/core-interfaces";
6
- import { type IChannelFactory } from "@fluidframework/datastore-definitions";
7
- import { type IFluidDataStoreFactory, type NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions/internal";
8
- import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
9
- import { type ContainerSchema, type DataObjectClass, type LoadableObjectClass } from "./types.js";
10
- /**
11
- * An internal type used by the internal type guard isDataObjectClass to cast a
12
- * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
13
- * Unlike the external and exported type DataObjectClass which is
14
- * weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.
15
- */
16
- export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> & Record<"factory", IFluidDataStoreFactory>;
5
+ import type { IFluidLoadable } from "@fluidframework/core-interfaces";
6
+ import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
7
+ import type { NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions/internal";
8
+ import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
9
+ import type { ContainerSchema, DataObjectClass, LoadableObjectClass } from "./types.js";
17
10
  /**
18
11
  * Runtime check to determine if a class is a DataObject type.
19
12
  */
20
- export declare function isDataObjectClass<T extends IFluidLoadable>(obj: LoadableObjectClass<T>): obj is InternalDataObjectClass<T>;
13
+ export declare function isDataObjectClass<T extends IFluidLoadable>(obj: LoadableObjectClass<T>): obj is DataObjectClass<T>;
21
14
  /**
22
15
  * Runtime check to determine if a class is a DataObject type.
23
16
  */
24
- export declare function isDataObjectClass(obj: LoadableObjectClass): obj is InternalDataObjectClass<IFluidLoadable>;
17
+ export declare function isDataObjectClass(obj: LoadableObjectClass): obj is DataObjectClass<IFluidLoadable>;
25
18
  /**
26
19
  * Runtime check to determine if a class is a SharedObject type
27
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACrC,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAG5E,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAElG;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,GACjF,MAAM,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;AAE3C;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,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AAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SACtE;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACnE;IACF,CAAC,CAAC;IAEF,gDAAgD;IAChD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;QAC9B,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;QACvC,GAAG,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC;KACpC,CAAC,CAAC;IACH,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE;QACjC,YAAY,CAAC,GAAG,CAAC,CAAC;KAClB;IAED,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KACzE;IAED,OAAO,CAAC,CAAC,GAAG,eAAe,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC;AA9BW,QAAA,iCAAiC,qCA8B5C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype IFluidDataStoreFactory,\n\ttype NamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type ContainerSchema, type DataObjectClass, type LoadableObjectClass } from \"./types.js\";\n\n/**\n * An internal type used by the internal type guard isDataObjectClass to cast a\n * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.\n * Unlike the external and exported type DataObjectClass which is\n * weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.\n */\nexport type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> &\n\tRecord<\"factory\", IFluidDataStoreFactory>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass<T extends IFluidLoadable>(\n\tobj: LoadableObjectClass<T>,\n): obj is InternalDataObjectClass<T>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(\n\tobj: LoadableObjectClass,\n): obj is InternalDataObjectClass<IFluidLoadable>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(\n\tobj: LoadableObjectClass,\n): obj is InternalDataObjectClass<IFluidLoadable> {\n\tconst maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;\n\tconst isDataObject =\n\t\tmaybe?.factory?.IFluidDataStoreFactory !== undefined &&\n\t\tmaybe.factory.IFluidDataStoreFactory === maybe.factory;\n\n\tif (\n\t\tisDataObject ===\n\t\t((obj as Partial<ISharedObjectKind<IFluidLoadable>>).getFactory !== undefined)\n\t) {\n\t\t// TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called \"getFactory\" so there is a risk of this being a false positive.\n\t\t// Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.\n\t\tthrow new UsageError(\"Invalid LoadableObjectClass\");\n\t}\n\n\treturn isDataObject;\n}\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport function isSharedObjectKind(\n\tobj: LoadableObjectClass,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectClass(obj);\n}\n\n/**\n * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be\n * of both SharedObject or DataObject. This function separates the two and returns a registry\n * of DataObject types and an array of SharedObjects.\n */\nexport const parseDataObjectsFromSharedObjects = (\n\tschema: ContainerSchema,\n): [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]] => {\n\tconst registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();\n\tconst sharedObjects = new Set<IChannelFactory>();\n\n\tconst tryAddObject = (obj: LoadableObjectClass): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectClass(obj)) {\n\t\t\tregistryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);\n\t\t} else {\n\t\t\tthrow new Error(`Entry is neither a DataObject or a SharedObject`);\n\t\t}\n\t};\n\n\t// Add the object types that will be initialized\n\tconst dedupedObjects = new Set([\n\t\t...Object.values(schema.initialObjects),\n\t\t...(schema.dynamicObjectTypes ?? []),\n\t]);\n\tfor (const obj of dedupedObjects) {\n\t\ttryAddObject(obj);\n\t}\n\n\tif (registryEntries.size === 0 && sharedObjects.size === 0) {\n\t\tthrow new Error(\"Container cannot be initialized without any DataTypes\");\n\t}\n\n\treturn [[...registryEntries], [...sharedObjects]];\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,uEAAsE;AAkBtE;;GAEG;AACH,SAAgB,iBAAiB,CAChC,GAAwB;IAExB,MAAM,KAAK,GAAG,GAA2D,CAAC;IAC1E,MAAM,YAAY,GACjB,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,SAAS;QACpD,KAAK,CAAC,OAAO,CAAC,sBAAsB,KAAK,KAAK,CAAC,OAAO,CAAC;IAExD,IACC,YAAY;QACZ,CAAE,GAAkD,CAAC,UAAU,KAAK,SAAS,CAAC,EAC7E,CAAC;QACF,8KAA8K;QAC9K,+LAA+L;QAC/L,MAAM,IAAI,qBAAU,CAAC,6BAA6B,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,YAAY,CAAC;AACrB,CAAC;AAlBD,8CAkBC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CACjC,GAAwB;IAExB,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAJD,gDAIC;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yright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { NamedFluidDataStoreRegistryEntry } from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { ContainerSchema, DataObjectClass, LoadableObjectClass } from \"./types.js\";\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass<T extends IFluidLoadable>(\n\tobj: LoadableObjectClass<T>,\n): obj is DataObjectClass<T>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(\n\tobj: LoadableObjectClass,\n): obj is DataObjectClass<IFluidLoadable>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(\n\tobj: LoadableObjectClass,\n): obj is DataObjectClass<IFluidLoadable> {\n\tconst maybe = obj as Partial<DataObjectClass<IFluidLoadable>> | undefined;\n\tconst isDataObject =\n\t\tmaybe?.factory?.IFluidDataStoreFactory !== undefined &&\n\t\tmaybe.factory.IFluidDataStoreFactory === maybe.factory;\n\n\tif (\n\t\tisDataObject ===\n\t\t((obj as Partial<ISharedObjectKind<IFluidLoadable>>).getFactory !== undefined)\n\t) {\n\t\t// TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called \"getFactory\" so there is a risk of this being a false positive.\n\t\t// Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.\n\t\tthrow new UsageError(\"Invalid LoadableObjectClass\");\n\t}\n\n\treturn isDataObject;\n}\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport function isSharedObjectKind(\n\tobj: LoadableObjectClass,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectClass(obj);\n}\n\n/**\n * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be\n * of both SharedObject or DataObject. This function separates the two and returns a registry\n * of DataObject types and an array of SharedObjects.\n */\nexport const parseDataObjectsFromSharedObjects = (\n\tschema: ContainerSchema,\n): [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]] => {\n\tconst registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();\n\tconst sharedObjects = new Set<IChannelFactory>();\n\n\tconst tryAddObject = (obj: LoadableObjectClass): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectClass(obj)) {\n\t\t\tregistryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);\n\t\t} else {\n\t\t\tthrow new Error(`Entry is neither a DataObject or a SharedObject`);\n\t\t}\n\t};\n\n\t// Add the object types that will be initialized\n\tconst dedupedObjects = new Set([\n\t\t...Object.values(schema.initialObjects),\n\t\t...(schema.dynamicObjectTypes ?? []),\n\t]);\n\tfor (const obj of dedupedObjects) {\n\t\ttryAddObject(obj as unknown as LoadableObjectClass);\n\t}\n\n\tif (registryEntries.size === 0 && sharedObjects.size === 0) {\n\t\tthrow new Error(\"Container cannot be initialized without any DataTypes\");\n\t}\n\n\treturn [[...registryEntries], [...sharedObjects]];\n};\n"]}
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
6
+ import type { CompatibilityMode } from "./types.js";
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.
10
+ */
11
+ export declare const compatibilityModeRuntimeOptions: Record<CompatibilityMode, IContainerRuntimeOptions>;
12
+ //# sourceMappingURL=compatibilityConfiguration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,wBAAwB,CAwBxB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { CompressionAlgorithms, } from "@fluidframework/container-runtime/internal";
6
+ import { FlushMode } from "@fluidframework/runtime-definitions/internal";
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.
10
+ */
11
+ export const compatibilityModeRuntimeOptions = {
12
+ "1": {
13
+ // 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode
14
+ // as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as
15
+ // fewer messages will be included per flush.
16
+ flushMode: FlushMode.Immediate,
17
+ // Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.
18
+ compressionOptions: {
19
+ minimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled
20
+ compressionAlgorithm: CompressionAlgorithms.lz4,
21
+ },
22
+ // Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.
23
+ enableGroupedBatching: false,
24
+ // TODO: Include explicit disables for things that are currently off-by-default?
25
+ },
26
+ "2": {
27
+ // Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their
28
+ // ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.
29
+ explicitSchemaControl: true,
30
+ // The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.
31
+ // It introduces a new type of op which is not compatible with 1.x clients.
32
+ enableRuntimeIdCompressor: "on",
33
+ },
34
+ };
35
+ //# sourceMappingURL=compatibilityConfiguration.js.map
@@ -0,0 +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;KAChF;IACD,GAAG,EAAE;QACJ,uGAAuG;QACvG,sHAAsH;QACtH,qBAAqB,EAAE,IAAI;QAC3B,sHAAsH;QACtH,2EAA2E;QAC3E,yBAAyB,EAAE,IAAI;KAC/B;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCompressionAlgorithms,\n\ttype IContainerRuntimeOptions,\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\tIContainerRuntimeOptions\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\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},\n};\n"]}
@@ -3,15 +3,16 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { AttachState, type ConnectionState, type ICriticalContainerError } from "@fluidframework/container-definitions";
6
- import { type IContainer } from "@fluidframework/container-definitions/internal";
7
- import { type IEvent, type IEventProvider, type IFluidLoadable } from "@fluidframework/core-interfaces";
8
- import type { ContainerAttachProps, ContainerSchema, IRootDataObject, LoadableObjectClass } from "./types.js";
6
+ import type { IContainer } from "@fluidframework/container-definitions/internal";
7
+ import type { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
8
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base";
9
+ import type { ContainerAttachProps, ContainerSchema, IRootDataObject } from "./types.js";
9
10
  /**
10
11
  * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
11
12
  * @public
12
13
  */
13
14
  export type InitialObjects<T extends ContainerSchema> = {
14
- [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<infer TChannel> ? TChannel : never;
15
+ [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends SharedObjectKind<infer TChannel> ? TChannel : never;
15
16
  };
16
17
  /**
17
18
  * Events emitted from {@link IFluidContainer}.
@@ -168,17 +169,28 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
168
169
  /**
169
170
  * Create a new data object or Distributed Data Store (DDS) of the specified type.
170
171
  *
172
+ * @param objectClass - The class of the `DataObject` or `SharedObject` to create.
173
+ *
174
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
175
+ *
171
176
  * @remarks
172
177
  *
173
- * In order to share the data object or DDS with other
174
- * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
175
- * initialObjects.
178
+ * In order to share the data object or DDS with other collaborators and retrieve it later,
179
+ * store its handle in a collection like a SharedDirectory from your initialObjects.
180
+ * It's typically a good idea to set any initial state on the object before doing so,
181
+ * as it is both more efficient and helpful to maintain domain model invariants
182
+ * (e.g. this approach easily allows state to only be set once).
176
183
  *
177
- * @param objectClass - The class of the `DataObject` or `SharedObject` to create.
184
+ * @example
178
185
  *
179
- * @typeParam T - The class of the `DataObject` or `SharedObject`.
186
+ * ```typescript
187
+ * const existingDirectory = container.initialObjects.myDirectory;
188
+ * const map = await container.create(SharedMap);
189
+ * map.set("initialState", "someValue");
190
+ * existingDirectory.set("myMap", map.handle);
191
+ * ```
180
192
  */
181
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
193
+ create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T>;
182
194
  /**
183
195
  * Dispose of the container instance, permanently disabling it.
184
196
  */