@fluidframework/fluid-static 2.50.0-345060 → 2.51.0-347100

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 (53) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-report/fluid-static.alpha.api.md +17 -0
  3. package/dist/fluidContainer.d.ts +1 -1
  4. package/dist/fluidContainer.d.ts.map +1 -1
  5. package/dist/fluidContainer.js.map +1 -1
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +5 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/rootDataObject.d.ts +6 -3
  11. package/dist/rootDataObject.d.ts.map +1 -1
  12. package/dist/rootDataObject.js +27 -44
  13. package/dist/rootDataObject.js.map +1 -1
  14. package/dist/treeRootDataObject.d.ts +47 -0
  15. package/dist/treeRootDataObject.d.ts.map +1 -0
  16. package/dist/treeRootDataObject.js +157 -0
  17. package/dist/treeRootDataObject.js.map +1 -0
  18. package/dist/types.d.ts +23 -8
  19. package/dist/types.d.ts.map +1 -1
  20. package/dist/types.js.map +1 -1
  21. package/dist/utils.d.ts +29 -4
  22. package/dist/utils.d.ts.map +1 -1
  23. package/dist/utils.js +62 -3
  24. package/dist/utils.js.map +1 -1
  25. package/lib/fluidContainer.d.ts +1 -1
  26. package/lib/fluidContainer.d.ts.map +1 -1
  27. package/lib/fluidContainer.js.map +1 -1
  28. package/lib/index.d.ts +3 -1
  29. package/lib/index.d.ts.map +1 -1
  30. package/lib/index.js +2 -0
  31. package/lib/index.js.map +1 -1
  32. package/lib/rootDataObject.d.ts +6 -3
  33. package/lib/rootDataObject.d.ts.map +1 -1
  34. package/lib/rootDataObject.js +25 -42
  35. package/lib/rootDataObject.js.map +1 -1
  36. package/lib/treeRootDataObject.d.ts +47 -0
  37. package/lib/treeRootDataObject.d.ts.map +1 -0
  38. package/lib/treeRootDataObject.js +153 -0
  39. package/lib/treeRootDataObject.js.map +1 -0
  40. package/lib/types.d.ts +23 -8
  41. package/lib/types.d.ts.map +1 -1
  42. package/lib/types.js.map +1 -1
  43. package/lib/utils.d.ts +29 -4
  44. package/lib/utils.d.ts.map +1 -1
  45. package/lib/utils.js +55 -0
  46. package/lib/utils.js.map +1 -1
  47. package/package.json +21 -20
  48. package/src/fluidContainer.ts +1 -1
  49. package/src/index.ts +3 -0
  50. package/src/rootDataObject.ts +46 -69
  51. package/src/treeRootDataObject.ts +249 -0
  52. package/src/types.ts +30 -9
  53. package/src/utils.ts +90 -4
package/lib/index.js CHANGED
@@ -10,4 +10,6 @@
10
10
  export { createFluidContainer, isInternalFluidContainer, } from "./fluidContainer.js";
11
11
  export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
12
12
  export { createServiceAudience } from "./serviceAudience.js";
13
+ export { createTreeContainerRuntimeFactory } from "./treeRootDataObject.js";
14
+ export { isTreeContainerSchema } from "./utils.js";
13
15
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,GAKxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport {\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\n\ttype IFluidContainerInternal,\n\ttype InitialObjects,\n} from \"./fluidContainer.js\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject.js\";\nexport { createServiceAudience } from \"./serviceAudience.js\";\nexport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tContainerAttachProps,\n\tIConnection,\n\tIMember,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tMemberChangedListener,\n\tMyself,\n} from \"./types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,GAKxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAa5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport {\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\n\ttype IFluidContainerInternal,\n\ttype InitialObjects,\n} from \"./fluidContainer.js\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject.js\";\nexport { createServiceAudience } from \"./serviceAudience.js\";\nexport { createTreeContainerRuntimeFactory } from \"./treeRootDataObject.js\";\nexport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tContainerAttachProps,\n\tIConnection,\n\tIMember,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tMemberChangedListener,\n\tMyself,\n\tTreeContainerSchema,\n} from \"./types.js\";\nexport { isTreeContainerSchema } from \"./utils.js\";\n"]}
@@ -7,9 +7,12 @@ import { type IContainerRuntimeOptions, type MinimumVersionForCollab } from "@fl
7
7
  import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
8
8
  import type { CompatibilityMode, ContainerSchema } from "./types.js";
9
9
  /**
10
- * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
11
- * with an entry point containing single IRootDataObject (entry point is opaque to caller),
12
- * where the root data object's registry and initial objects are configured based on the provided
10
+ * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
11
+ * with an entry point containing single directory-based root data object.
12
+ *
13
+ * @remarks
14
+ * The entry point is opaque to caller.
15
+ * The root data object's registry and initial objects are configured based on the provided
13
16
  * schema (and optionally, data store registry).
14
17
  *
15
18
  * @internal
@@ -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;AACtF,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,MAAM,4CAA4C,CAAC;AAcpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAO5F,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAMf,MAAM,YAAY,CAAC;AA6IpB;;;;;;;GAOG;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;IAChD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC3D;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,uBAAuB,CAAC;CACtD,GAAG,eAAe,CAalB"}
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;AACtF,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,MAAM,4CAA4C,CAAC;AAapD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAI5F,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAMf,MAAM,YAAY,CAAC;AA2IpB;;;;;;;;;;GAUG;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;IAChD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC3D;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,uBAAuB,CAAC;CACtD,GAAG,eAAe,CAoBlB"}
@@ -6,14 +6,7 @@ import { BaseContainerRuntimeFactory, DataObject, DataObjectFactory, } from "@fl
6
6
  import { FluidDataStoreRegistry, } from "@fluidframework/container-runtime/internal";
7
7
  import { assert } from "@fluidframework/core-utils/internal";
8
8
  import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
9
- import { isDataObjectKind, isSharedObjectKind, parseDataObjectsFromSharedObjects, } from "./utils.js";
10
- /**
11
- * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
12
- */
13
- const compatibilityModeToMinVersionForCollab = {
14
- "1": "1.0.0",
15
- "2": "2.0.0",
16
- };
9
+ import { compatibilityModeToMinVersionForCollab, createDataObject, createSharedObject, isDataObjectKind, isSharedObjectKind, makeFluidObject, parseDataObjectsFromSharedObjects, } from "./utils.js";
17
10
  /**
18
11
  * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
19
12
  * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
@@ -81,49 +74,19 @@ class RootDataObject extends DataObject {
81
74
  async create(objectClass) {
82
75
  const internal = objectClass;
83
76
  if (isDataObjectKind(internal)) {
84
- return this.createDataObject(internal);
77
+ return createDataObject(internal, this.context);
85
78
  }
86
79
  else if (isSharedObjectKind(internal)) {
87
- return this.createSharedObject(internal);
80
+ return createSharedObject(internal, this.runtime);
88
81
  }
89
82
  throw new Error("Could not create new Fluid object because an unknown object was passed");
90
83
  }
91
84
  async uploadBlob(blob) {
92
85
  return this.runtime.uploadBlob(blob);
93
86
  }
94
- async createDataObject(dataObjectClass) {
95
- const factory = dataObjectClass.factory;
96
- const packagePath = [...this.context.packagePath, factory.type];
97
- const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
98
- const entryPoint = await dataStore.entryPoint.get();
99
- return entryPoint;
100
- }
101
- createSharedObject(sharedObjectClass) {
102
- const factory = sharedObjectClass.getFactory();
103
- const obj = this.runtime.createChannel(undefined, factory.type);
104
- return obj;
105
- }
106
87
  }
107
88
  const rootDataStoreId = "rootDOId";
108
- /**
109
- * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
110
- * with an entry point containing single IRootDataObject (entry point is opaque to caller),
111
- * where the root data object's registry and initial objects are configured based on the provided
112
- * schema (and optionally, data store registry).
113
- *
114
- * @internal
115
- */
116
- export function createDOProviderContainerRuntimeFactory(props) {
117
- const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);
118
- const registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
119
- return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode, new RootDataObjectFactory(sharedObjects, registry), {
120
- runtimeOptions: props.runtimeOptionOverrides,
121
- minVersionForCollab: props.minVersionForCollabOverride,
122
- });
123
- }
124
- function makeFluidObject(object, providerKey) {
125
- return Object.defineProperty(object, providerKey, { value: object });
126
- }
89
+ const rootDataObjectType = "rootDO";
127
90
  async function provideEntryPoint(containerRuntime) {
128
91
  const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
129
92
  if (entryPoint === undefined) {
@@ -137,6 +100,26 @@ async function provideEntryPoint(containerRuntime) {
137
100
  extensionStore: containerRuntime,
138
101
  }, "IStaticEntryPoint");
139
102
  }
103
+ /**
104
+ * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
105
+ * with an entry point containing single directory-based root data object.
106
+ *
107
+ * @remarks
108
+ * The entry point is opaque to caller.
109
+ * The root data object's registry and initial objects are configured based on the provided
110
+ * schema (and optionally, data store registry).
111
+ *
112
+ * @internal
113
+ */
114
+ export function createDOProviderContainerRuntimeFactory(props) {
115
+ const { compatibilityMode, minVersionForCollabOverride, rootDataStoreRegistry, runtimeOptionOverrides, schema, } = props;
116
+ const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
117
+ const registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
118
+ return new DOProviderContainerRuntimeFactory(schema, compatibilityMode, new RootDataObjectFactory(sharedObjects, registry), {
119
+ runtimeOptions: runtimeOptionOverrides,
120
+ minVersionForCollab: minVersionForCollabOverride,
121
+ });
122
+ }
140
123
  /**
141
124
  * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}
142
125
  * (containing single {@link IRootDataObject}) as their entry point.
@@ -185,7 +168,7 @@ class RootDataObjectFactory extends DataObjectFactory {
185
168
  // Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,
186
169
  // and instead we override the necessary methods in this class to use the registry received in the constructor.
187
170
  super({
188
- type: "rootDO",
171
+ type: rootDataObjectType,
189
172
  ctor: RootDataObject,
190
173
  sharedObjects,
191
174
  });
@@ -1 +1 @@
1
- {"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,EAC3B,UAAU,EAEV,iBAAiB,GACjB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACN,sBAAsB,GAGtB,MAAM,4CAA4C,CAAC;AA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,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,CAAC;IAES,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,iBAGnC;IACA,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAE3D,2GAA2G;QAC3G,+GAA+G;QAC/G,KAAK,CAAC;YACL,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,cAAc;YACpB,aAAa;SACb,CAAC,CAAC;QARc,sBAAiB,GAAjB,iBAAiB,CAAyB;IAS5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\ttype DataObjectKind,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype IContainerRuntimeOptions,\n\ttype MinimumVersionForCollab,\n} from \"@fluidframework/container-runtime/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeInternal,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tFluidObjectKeys,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\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\tIStaticEntryPoint,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nconst compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\ninterface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\treadonly initialObjects: LoadableObjectKindRecord;\n}\n\ninterface IProvideRootDataObject {\n\treadonly RootDataObject: RootDataObject;\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, IProvideRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get RootDataObject(): RootDataObject {\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\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\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\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.runtime.uploadBlob(blob);\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 an entry point containing single IRootDataObject (entry point is opaque to caller),\n * where the root data object's registry and initial objects are configured based on the provided\n * 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\t/**\n\t * Optional overrides for the container runtime options.\n\t * If not provided, only the default options for the given compatibilityMode will be used.\n\t */\n\truntimeOptionOverrides?: Partial<IContainerRuntimeOptions>;\n\t/**\n\t * Optional override for minimum version for collab.\n\t * If not provided, the default for the given compatibilityMode will be used.\n\t * @remarks\n\t * This is useful when runtime options are overridden and change the minimum version for collab.\n\t */\n\tminVersionForCollabOverride?: MinimumVersionForCollab;\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\t{\n\t\t\truntimeOptions: props.runtimeOptionOverrides,\n\t\t\tminVersionForCollab: props.minVersionForCollabOverride,\n\t\t},\n\t);\n}\n\nfunction makeFluidObject<T extends object, K extends FluidObjectKeys<T> = FluidObjectKeys<T>>(\n\tobject: Omit<T, K>,\n\tproviderKey: K,\n): T {\n\treturn Object.defineProperty(object, providerKey, { value: object }) as T;\n}\n\nasync function provideEntryPoint(\n\tcontainerRuntime: IContainerRuntime,\n): Promise<IStaticEntryPoint> {\n\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t}\n\tconst rootDataObject = ((await entryPoint.get()) as FluidObject<RootDataObject>)\n\t\t.RootDataObject;\n\tassert(rootDataObject !== undefined, 0xb9f /* entryPoint must be of type RootDataObject */);\n\treturn makeFluidObject<IStaticEntryPoint>(\n\t\t{\n\t\t\trootDataObject,\n\t\t\textensionStore: containerRuntime as IContainerRuntimeInternal,\n\t\t},\n\t\t\"IStaticEntryPoint\",\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}\n * (containing single {@link IRootDataObject}) 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\toverrides?: Partial<{\n\t\t\truntimeOptions: Partial<IContainerRuntimeOptions>;\n\t\t\tminVersionForCollab: MinimumVersionForCollab;\n\t\t}>,\n\t) {\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: {\n\t\t\t\t...compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\t\t...overrides?.runtimeOptions,\n\t\t\t},\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab:\n\t\t\t\toverrides?.minVersionForCollab ??\n\t\t\t\tcompatibilityModeToMinVersionForCollab[compatibilityMode],\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: \"rootDO\",\n\t\t\tctor: RootDataObject,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
1
+ {"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,EAC3B,UAAU,EACV,iBAAiB,GACjB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACN,sBAAsB,GAGtB,MAAM,4CAA4C,CAAC;AAUpD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AAUlF,OAAO,EACN,sCAAsC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,iCAAiC,GACjC,MAAM,YAAY,CAAC;AAkBpB;;;GAGG;AACH,MAAM,cACL,SAAQ,UAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IA+E7D,CAAC;IA7EA,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBAAiB;QAC5B,MAAM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C1D,CAAC,CAAC;QACH,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,CAAC;IAES,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,iBAGnC;IACA,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAE3D,2GAA2G;QAC3G,+GAA+G;QAC/G,KAAK,CAAC;YACL,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,cAAc;YACpB,aAAa;SACb,CAAC,CAAC;QARc,sBAAiB,GAAjB,iBAAiB,CAAyB;IAS5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype IContainerRuntimeOptions,\n\ttype MinimumVersionForCollab,\n} from \"@fluidframework/container-runtime/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeInternal,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\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 { SharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tIRootDataObject,\n\tIStaticEntryPoint,\n\tLoadableObjectKind,\n\tLoadableObjectKindRecord,\n\tLoadableObjectRecord,\n} from \"./types.js\";\nimport {\n\tcompatibilityModeToMinVersionForCollab,\n\tcreateDataObject,\n\tcreateSharedObject,\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tmakeFluidObject,\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\ninterface IProvideRootDataObject {\n\treadonly RootDataObject: RootDataObject;\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, IProvideRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\n\tpublic get RootDataObject(): RootDataObject {\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\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\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 createDataObject(internal, this.context);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn createSharedObject(internal, this.runtime);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.runtime.uploadBlob(blob);\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\nconst rootDataObjectType = \"rootDO\";\n\nasync function provideEntryPoint(\n\tcontainerRuntime: IContainerRuntime,\n): Promise<IStaticEntryPoint> {\n\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t}\n\tconst rootDataObject = ((await entryPoint.get()) as FluidObject<RootDataObject>)\n\t\t.RootDataObject;\n\tassert(rootDataObject !== undefined, 0xb9f /* entryPoint must be of type RootDataObject */);\n\treturn makeFluidObject<IStaticEntryPoint>(\n\t\t{\n\t\t\trootDataObject,\n\t\t\textensionStore: containerRuntime as IContainerRuntimeInternal,\n\t\t},\n\t\t\"IStaticEntryPoint\",\n\t);\n}\n\n/**\n * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers\n * with an entry point containing single directory-based root data object.\n *\n * @remarks\n * The entry point is opaque to caller.\n * The root data object's registry and initial objects are configured based on the provided\n * 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\t/**\n\t * Optional overrides for the container runtime options.\n\t * If not provided, only the default options for the given compatibilityMode will be used.\n\t */\n\truntimeOptionOverrides?: Partial<IContainerRuntimeOptions>;\n\t/**\n\t * Optional override for minimum version for collab.\n\t * If not provided, the default for the given compatibilityMode will be used.\n\t * @remarks\n\t * This is useful when runtime options are overridden and change the minimum version for collab.\n\t */\n\tminVersionForCollabOverride?: MinimumVersionForCollab;\n}): IRuntimeFactory {\n\tconst {\n\t\tcompatibilityMode,\n\t\tminVersionForCollabOverride,\n\t\trootDataStoreRegistry,\n\t\truntimeOptionOverrides,\n\t\tschema,\n\t} = props;\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\tconst registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new DOProviderContainerRuntimeFactory(\n\t\tschema,\n\t\tcompatibilityMode,\n\t\tnew RootDataObjectFactory(sharedObjects, registry),\n\t\t{\n\t\t\truntimeOptions: runtimeOptionOverrides,\n\t\t\tminVersionForCollab: minVersionForCollabOverride,\n\t\t},\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}\n * (containing single {@link IRootDataObject}) 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\toverrides?: Partial<{\n\t\t\truntimeOptions: Partial<IContainerRuntimeOptions>;\n\t\t\tminVersionForCollab: MinimumVersionForCollab;\n\t\t}>,\n\t) {\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: {\n\t\t\t\t...compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\t\t...overrides?.runtimeOptions,\n\t\t\t},\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab:\n\t\t\t\toverrides?.minVersionForCollab ??\n\t\t\t\tcompatibilityModeToMinVersionForCollab[compatibilityMode],\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n\n/**\n * Factory that creates instances of a root data object.\n */\nclass RootDataObjectFactory extends DataObjectFactory<\n\tRootDataObject,\n\t{ InitialState: RootDataObjectProps }\n> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\t// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: rootDataObjectType,\n\t\t\tctor: RootDataObject,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n"]}
@@ -0,0 +1,47 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
6
+ import { type IContainerRuntimeOptions, type MinimumVersionForCollab } from "@fluidframework/container-runtime/internal";
7
+ import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
8
+ import type { CompatibilityMode, TreeContainerSchema } from "./types.js";
9
+ /**
10
+ * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
11
+ * with an entry point containing single tree-based root data object.
12
+ *
13
+ * @remarks
14
+ * The entry point is opaque to caller.
15
+ * The root data object's registry and shared objects are configured based on the provided
16
+ * SharedTree and optionally data store registry.
17
+ *
18
+ * @legacy @alpha
19
+ */
20
+ export declare function createTreeContainerRuntimeFactory(props: {
21
+ /**
22
+ * The schema for the container.
23
+ */
24
+ readonly schema: TreeContainerSchema;
25
+ /**
26
+ * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.
27
+ */
28
+ readonly compatibilityMode: CompatibilityMode;
29
+ /**
30
+ * Optional registry of data stores to pass to the DataObject factory.
31
+ * If not provided, one will be created based on the schema.
32
+ */
33
+ readonly rootDataStoreRegistry?: IFluidDataStoreRegistry;
34
+ /**
35
+ * Optional overrides for the container runtime options.
36
+ * If not provided, only the default options for the given compatibilityMode will be used.
37
+ */
38
+ readonly runtimeOptionOverrides?: Partial<IContainerRuntimeOptions>;
39
+ /**
40
+ * Optional override for minimum version for collab.
41
+ * If not provided, the default for the given compatibilityMode will be used.
42
+ * @remarks
43
+ * This is useful when runtime options are overridden and change the minimum version for collab.
44
+ */
45
+ readonly minVersionForCollabOverride?: MinimumVersionForCollab;
46
+ }): IRuntimeFactory;
47
+ //# sourceMappingURL=treeRootDataObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeRootDataObject.d.ts","sourceRoot":"","sources":["../src/treeRootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,MAAM,4CAA4C,CAAC;AAYpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAI5F,OAAO,KAAK,EACX,iBAAiB,EAKjB,mBAAmB,EACnB,MAAM,YAAY,CAAC;AAuJpB;;;;;;;;;;GAUG;AACH,wBAAgB,iCAAiC,CAAC,KAAK,EAAE;IACxD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,uBAAuB,CAAC;IACzD;;;OAGG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACpE;;;;;OAKG;IACH,QAAQ,CAAC,2BAA2B,CAAC,EAAE,uBAAuB,CAAC;CAC/D,GAAG,eAAe,CAoBlB"}
@@ -0,0 +1,153 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
6
+ if (kind === "m") throw new TypeError("Private method is not writable");
7
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
9
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _TreeContainerRuntimeFactory_treeRootDataObjectFactory;
17
+ import { BaseContainerRuntimeFactory, TreeDataObject, TreeDataObjectFactory, } from "@fluidframework/aqueduct/internal";
18
+ import { FluidDataStoreRegistry, } from "@fluidframework/container-runtime/internal";
19
+ import { assert } from "@fluidframework/core-utils/internal";
20
+ import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
21
+ import { compatibilityModeToMinVersionForCollab, createDataObject, createSharedObject, isDataObjectKind, isSharedObjectKind, makeFluidObject, parseDataObjectsFromSharedObjects, } from "./utils.js";
22
+ /**
23
+ * This module contains types and factories for creating tree-based root data objects.
24
+ * They exist as an alternative to the APIs in `rootDataObject.ts`.
25
+ *
26
+ * These APIs are currently shaped to parallel `RootDataObject`, but this is not intended as the long-term design.
27
+ * The current shape is a short-term solution to allow for easier migration from the old APIs.
28
+ */
29
+ /**
30
+ * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
31
+ *
32
+ * @remarks
33
+ * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
34
+ */
35
+ class TreeRootDataObject extends TreeDataObject {
36
+ constructor(props) {
37
+ super(props);
38
+ }
39
+ get TreeRootDataObject() {
40
+ return this;
41
+ }
42
+ // TODO: longer term, it would be better to not have to fit into the `initialObjects` model for tree-based containers.
43
+ // But in the short term, fitting into this model makes migration easier.
44
+ get initialObjects() {
45
+ return {
46
+ tree: this.tree,
47
+ };
48
+ }
49
+ async create(objectClass) {
50
+ const internal = objectClass;
51
+ if (isDataObjectKind(internal)) {
52
+ return createDataObject(internal, this.context);
53
+ }
54
+ else if (isSharedObjectKind(internal)) {
55
+ return createSharedObject(internal, this.runtime);
56
+ }
57
+ throw new Error("Could not create new Fluid object because an unknown object was passed");
58
+ }
59
+ async uploadBlob(blob) {
60
+ return this.runtime.uploadBlob(blob);
61
+ }
62
+ }
63
+ const treeRootDataStoreId = "treeRootDOId";
64
+ /**
65
+ * Type of the {@link TreeRootDataObject}.
66
+ * @remarks Used in the PureDataObjectFactory to create the root data object.
67
+ */
68
+ const treeRootDataObjectType = "treeRootDO";
69
+ async function provideEntryPoint(containerRuntime) {
70
+ const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(treeRootDataStoreId);
71
+ if (entryPoint === undefined) {
72
+ throw new Error(`default dataStore [${treeRootDataStoreId}] must exist`);
73
+ }
74
+ const treeRootDataObject = (await entryPoint.get())
75
+ .TreeRootDataObject;
76
+ assert(treeRootDataObject !== undefined, "entryPoint must be of type TreeRootDataObject");
77
+ return makeFluidObject({
78
+ rootDataObject: treeRootDataObject,
79
+ extensionStore: containerRuntime,
80
+ }, "IStaticEntryPoint");
81
+ }
82
+ /**
83
+ * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}
84
+ * (containing single {@link IRootDataObject}) as their entry point.
85
+ */
86
+ class TreeContainerRuntimeFactory extends BaseContainerRuntimeFactory {
87
+ constructor(compatibilityMode, treeRootDataObjectFactory, overrides) {
88
+ super({
89
+ registryEntries: [treeRootDataObjectFactory.registryEntry],
90
+ runtimeOptions: {
91
+ ...compatibilityModeRuntimeOptions[compatibilityMode],
92
+ ...overrides?.runtimeOptions,
93
+ },
94
+ provideEntryPoint,
95
+ minVersionForCollab: overrides?.minVersionForCollab ??
96
+ compatibilityModeToMinVersionForCollab[compatibilityMode],
97
+ });
98
+ // TODO: use for runtime factory.
99
+ _TreeContainerRuntimeFactory_treeRootDataObjectFactory.set(this, void 0);
100
+ __classPrivateFieldSet(this, _TreeContainerRuntimeFactory_treeRootDataObjectFactory, treeRootDataObjectFactory, "f");
101
+ }
102
+ async containerInitializingFirstTime(runtime) {
103
+ // The first time we create the container we create the RootDataObject
104
+ await __classPrivateFieldGet(this, _TreeContainerRuntimeFactory_treeRootDataObjectFactory, "f").createRootInstance(treeRootDataStoreId, runtime);
105
+ }
106
+ }
107
+ _TreeContainerRuntimeFactory_treeRootDataObjectFactory = new WeakMap();
108
+ /**
109
+ * Factory that creates instances of a tree-based root data object.
110
+ */
111
+ class TreeRootDataObjectFactory extends TreeDataObjectFactory {
112
+ constructor(sharedObjects = [], dataStoreRegistry) {
113
+ const ctor = function (_props) {
114
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
115
+ return new TreeRootDataObject({
116
+ ..._props,
117
+ // Add any additional injected properties here
118
+ });
119
+ };
120
+ // Note: we're not specifying registry entries to the base class, so it won't create a registry itself,
121
+ // and instead we override the necessary methods in this class to use the registry received in the constructor.
122
+ super({
123
+ type: treeRootDataObjectType,
124
+ ctor,
125
+ sharedObjects,
126
+ });
127
+ this.dataStoreRegistry = dataStoreRegistry;
128
+ }
129
+ get IFluidDataStoreRegistry() {
130
+ return this.dataStoreRegistry;
131
+ }
132
+ }
133
+ /**
134
+ * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
135
+ * with an entry point containing single tree-based root data object.
136
+ *
137
+ * @remarks
138
+ * The entry point is opaque to caller.
139
+ * The root data object's registry and shared objects are configured based on the provided
140
+ * SharedTree and optionally data store registry.
141
+ *
142
+ * @legacy @alpha
143
+ */
144
+ export function createTreeContainerRuntimeFactory(props) {
145
+ const { compatibilityMode, minVersionForCollabOverride, rootDataStoreRegistry, runtimeOptionOverrides, schema, } = props;
146
+ const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
147
+ const registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
148
+ return new TreeContainerRuntimeFactory(compatibilityMode, new TreeRootDataObjectFactory(sharedObjects, registry), {
149
+ runtimeOptions: runtimeOptionOverrides,
150
+ minVersionForCollab: minVersionForCollabOverride,
151
+ });
152
+ }
153
+ //# sourceMappingURL=treeRootDataObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeRootDataObject.js","sour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BAAmB,EAAE,OAAO,CAAC,CAAC;IACxF,CAAC;CACD;;AAED;;GAEG;AACH,MAAM,yBAA0B,SAAQ,qBAAyC;IAChF,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAG3D,MAAM,IAAI,GAAS,UAAU,MAAM;YAClC,iEAAiE;YACjE,OAAO,IAAI,kBAAkB,CAAC;gBAC7B,GAAG,MAAM;gBACT,8CAA8C;aAC9C,CAAC,CAAC;QACJ,CAAoB,CAAC;QAErB,uGAAuG;QACvG,+GAA+G;QAC/G,KAAK,CAAC;YACL,IAAI,EAAE,sBAAsB;YAC5B,IAAI;YACJ,aAAa;SACb,CAAC,CAAC;QAjBc,sBAAiB,GAAjB,iBAAiB,CAAyB;IAkB5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iCAAiC,CAAC,KA2BjD;IACA,MAAM,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,MAAM,GACN,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC,GAAG,iCAAiC,CAAC,MAAM,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,qBAAqB,IAAI,IAAI,sBAAsB,CAAC,eAAe,CAAC,CAAC;IAEtF,OAAO,IAAI,2BAA2B,CACrC,iBAAiB,EACjB,IAAI,yBAAyB,CAAC,aAAa,EAAE,QAAQ,CAAC,EACtD;QACC,cAAc,EAAE,sBAAsB;QACtC,mBAAmB,EAAE,2BAA2B;KAChD,CACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tTreeDataObject,\n\tTreeDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IDataObjectProps } from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype IContainerRuntimeOptions,\n\ttype MinimumVersionForCollab,\n} from \"@fluidframework/container-runtime/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeInternal,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IFluidDataStoreRegistry } from \"@fluidframework/runtime-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tIRootDataObject,\n\tIStaticEntryPoint,\n\tLoadableObjectKind,\n\tLoadableObjectRecord,\n\tTreeContainerSchema,\n} from \"./types.js\";\nimport {\n\tcompatibilityModeToMinVersionForCollab,\n\tcreateDataObject,\n\tcreateSharedObject,\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tmakeFluidObject,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * This module contains types and factories for creating tree-based root data objects.\n * They exist as an alternative to the APIs in `rootDataObject.ts`.\n *\n * These APIs are currently shaped to parallel `RootDataObject`, but this is not intended as the long-term design.\n * The current shape is a short-term solution to allow for easier migration from the old APIs.\n */\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n *\n * @remarks\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass TreeRootDataObject extends TreeDataObject implements IRootDataObject {\n\tpublic constructor(props: IDataObjectProps) {\n\t\tsuper(props);\n\t}\n\n\tpublic get TreeRootDataObject(): TreeRootDataObject {\n\t\treturn this;\n\t}\n\n\t// TODO: longer term, it would be better to not have to fit into the `initialObjects` model for tree-based containers.\n\t// But in the short term, fitting into this model makes migration easier.\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\treturn {\n\t\t\ttree: this.tree,\n\t\t};\n\t}\n\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 createDataObject(internal, this.context);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn createSharedObject(internal, this.runtime);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.runtime.uploadBlob(blob);\n\t}\n}\n\nconst treeRootDataStoreId = \"treeRootDOId\";\n\n/**\n * Type of the {@link TreeRootDataObject}.\n * @remarks Used in the PureDataObjectFactory to create the root data object.\n */\nconst treeRootDataObjectType = \"treeRootDO\";\n\nasync function provideEntryPoint(\n\tcontainerRuntime: IContainerRuntime,\n): Promise<IStaticEntryPoint> {\n\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(treeRootDataStoreId);\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(`default dataStore [${treeRootDataStoreId}] must exist`);\n\t}\n\tconst treeRootDataObject = ((await entryPoint.get()) as FluidObject<TreeRootDataObject>)\n\t\t.TreeRootDataObject;\n\tassert(treeRootDataObject !== undefined, \"entryPoint must be of type TreeRootDataObject\");\n\treturn makeFluidObject<IStaticEntryPoint>(\n\t\t{\n\t\t\trootDataObject: treeRootDataObject,\n\t\t\textensionStore: containerRuntime as IContainerRuntimeInternal,\n\t\t},\n\t\t\"IStaticEntryPoint\",\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}\n * (containing single {@link IRootDataObject}) as their entry point.\n */\nclass TreeContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\t// TODO: use for runtime factory.\n\treadonly #treeRootDataObjectFactory: TreeDataObjectFactory<TreeRootDataObject>;\n\n\tpublic constructor(\n\t\tcompatibilityMode: CompatibilityMode,\n\t\ttreeRootDataObjectFactory: TreeDataObjectFactory<TreeRootDataObject>,\n\t\toverrides?: Partial<{\n\t\t\truntimeOptions: Partial<IContainerRuntimeOptions>;\n\t\t\tminVersionForCollab: MinimumVersionForCollab;\n\t\t}>,\n\t) {\n\t\tsuper({\n\t\t\tregistryEntries: [treeRootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: {\n\t\t\t\t...compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\t\t...overrides?.runtimeOptions,\n\t\t\t},\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab:\n\t\t\t\toverrides?.minVersionForCollab ??\n\t\t\t\tcompatibilityModeToMinVersionForCollab[compatibilityMode],\n\t\t});\n\t\tthis.#treeRootDataObjectFactory = treeRootDataObjectFactory;\n\t}\n\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.#treeRootDataObjectFactory.createRootInstance(treeRootDataStoreId, runtime);\n\t}\n}\n\n/**\n * Factory that creates instances of a tree-based root data object.\n */\nclass TreeRootDataObjectFactory extends TreeDataObjectFactory<TreeRootDataObject> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\ttype Ctor = new (props: IDataObjectProps) => TreeRootDataObject;\n\t\tconst ctor: Ctor = function (_props) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn new TreeRootDataObject({\n\t\t\t\t..._props,\n\t\t\t\t// Add any additional injected properties here\n\t\t\t});\n\t\t} as unknown as Ctor;\n\n\t\t// Note: we're not specifying registry entries to the base class, so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: treeRootDataObjectType,\n\t\t\tctor,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n\n/**\n * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers\n * with an entry point containing single tree-based root data object.\n *\n * @remarks\n * The entry point is opaque to caller.\n * The root data object's registry and shared objects are configured based on the provided\n * SharedTree and optionally data store registry.\n *\n * @legacy @alpha\n */\nexport function createTreeContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\treadonly schema: TreeContainerSchema;\n\n\t/**\n\t * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.\n\t */\n\treadonly compatibilityMode: 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\treadonly rootDataStoreRegistry?: IFluidDataStoreRegistry;\n\t/**\n\t * Optional overrides for the container runtime options.\n\t * If not provided, only the default options for the given compatibilityMode will be used.\n\t */\n\treadonly runtimeOptionOverrides?: Partial<IContainerRuntimeOptions>;\n\t/**\n\t * Optional override for minimum version for collab.\n\t * If not provided, the default for the given compatibilityMode will be used.\n\t * @remarks\n\t * This is useful when runtime options are overridden and change the minimum version for collab.\n\t */\n\treadonly minVersionForCollabOverride?: MinimumVersionForCollab;\n}): IRuntimeFactory {\n\tconst {\n\t\tcompatibilityMode,\n\t\tminVersionForCollabOverride,\n\t\trootDataStoreRegistry,\n\t\truntimeOptionOverrides,\n\t\tschema,\n\t} = props;\n\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\tconst registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new TreeContainerRuntimeFactory(\n\t\tcompatibilityMode,\n\t\tnew TreeRootDataObjectFactory(sharedObjects, registry),\n\t\t{\n\t\t\truntimeOptions: runtimeOptionOverrides,\n\t\t\tminVersionForCollab: minVersionForCollabOverride,\n\t\t},\n\t);\n}\n"]}
package/lib/types.d.ts CHANGED
@@ -5,8 +5,8 @@
5
5
  import type { DataObjectKind } from "@fluidframework/aqueduct/internal";
6
6
  import type { ContainerExtensionStore } from "@fluidframework/container-runtime-definitions/internal";
7
7
  import type { IEvent, IEventProvider, IFluidHandle, IFluidLoadable } from "@fluidframework/core-interfaces";
8
- import type { SharedObjectKind } from "@fluidframework/shared-object-base";
9
- import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
8
+ import type { ISharedObjectKind, SharedObjectKind } from "@fluidframework/shared-object-base/internal";
9
+ import type { ITree } from "@fluidframework/tree";
10
10
  /**
11
11
  * Determines the set of runtime options that Fluid Framework will use when running.
12
12
  * In "1" mode we support full interop between 2.x clients and 1.x clients,
@@ -84,14 +84,25 @@ export interface ContainerSchema {
84
84
  readonly dynamicObjectTypes?: readonly SharedObjectKind[];
85
85
  }
86
86
  /**
87
- * Holds the collection of objects that the container was initially created with, as well as provides the ability
88
- * to dynamically create further objects during usage.
87
+ * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
88
+ *
89
+ * @remarks
90
+ *
91
+ * It includes both the kind of `SharedTree` that will be initially available upon `Container` creation, as well
92
+ * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
93
+ *
94
+ * @legacy @alpha
95
+ */
96
+ export interface TreeContainerSchema extends ContainerSchema {
97
+ readonly initialObjects: {
98
+ readonly tree: SharedObjectKind<ITree>;
99
+ };
100
+ }
101
+ /**
102
+ * Holds the collection of objects that the container was initially created with.
103
+ * Additionally provides the ability to dynamically create further objects during usage.
89
104
  */
90
105
  export interface IRootDataObject {
91
- /**
92
- * Provides a record of the initial objects defined on creation.
93
- */
94
- readonly initialObjects: LoadableObjectRecord;
95
106
  /**
96
107
  * Dynamically creates a new detached collaborative object (DDS/DataObject).
97
108
  *
@@ -109,6 +120,10 @@ export interface IRootDataObject {
109
120
  * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).
110
121
  */
111
122
  uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;
123
+ /**
124
+ * Provides a record of the initial objects defined on creation.
125
+ */
126
+ readonly initialObjects: LoadableObjectRecord;
112
127
  }
113
128
  interface IProvideStaticEntryPoint {
114
129
  readonly IStaticEntryPoint: IStaticEntryPoint;
@@ -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,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EACX,MAAM,EACN,cAAc,EACd,YAAY,EACZ,cAAc,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAErF;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,GAAG,GAAG,GAAG,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAExE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IACrE,iBAAiB,CAAC,CAAC,CAAC,GACpB,cAAc,CAAC,CAAC,CAAC,CAAC;AAErB;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;AAElD;;;;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;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/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 { ContainerExtensionStore } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tIFluidHandle,\n\tIFluidLoadable,\n} 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 */\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 * 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 */\nexport interface IRootDataObject {\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\t/**\n\t * Upload a blob of data.\n\t * Although it is marked as internal, there is external usage of this function for experimental purposes.\n\t * Please contact yunho-microsoft or vladsud if you need to change it.\n\t * @param blob - blob to be uploaded.\n\t *\n\t * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).\n\t */\n\tuploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;\n}\n\ninterface IProvideStaticEntryPoint {\n\treadonly IStaticEntryPoint: IStaticEntryPoint;\n}\n\n/**\n * This is the internal entry point fluid-static creates.\n */\nexport interface IStaticEntryPoint extends IProvideStaticEntryPoint {\n\treadonly rootDataObject: IRootDataObject;\n\treadonly extensionStore: ContainerExtensionStore;\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 { ContainerExtensionStore } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\nimport type { ITree } from \"@fluidframework/tree\";\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 */\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 * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the kind of `SharedTree` that will be 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 *\n * @legacy @alpha\n */\nexport interface TreeContainerSchema extends ContainerSchema {\n\t// TODO: longer term, it would be better to not have to fit into the `initialObjects` model for tree-based containers.\n\t// But in the short term, fitting into this model makes migration easier.\n\treadonly initialObjects: {\n\t\treadonly tree: SharedObjectKind<ITree>;\n\t};\n}\n\n/**\n * Holds the collection of objects that the container was initially created with.\n * Additionally provides the ability to dynamically create further objects during usage.\n */\nexport interface IRootDataObject {\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\t/**\n\t * Upload a blob of data.\n\t * Although it is marked as internal, there is external usage of this function for experimental purposes.\n\t * Please contact yunho-microsoft or vladsud if you need to change it.\n\t * @param blob - blob to be uploaded.\n\t *\n\t * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).\n\t */\n\tuploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;\n\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n}\n\ninterface IProvideStaticEntryPoint {\n\treadonly IStaticEntryPoint: IStaticEntryPoint;\n}\n\n/**\n * This is the internal entry point fluid-static creates.\n */\nexport interface IStaticEntryPoint extends IProvideStaticEntryPoint {\n\treadonly rootDataObject: IRootDataObject;\n\treadonly extensionStore: ContainerExtensionStore;\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"]}