@fluidframework/fluid-static 2.70.0-360753 → 2.70.0-361248

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.
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
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";
6
+ import { type IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
7
+ import type { IFluidDataStoreRegistry, MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
8
8
  import type { CompatibilityMode, ContainerSchema } from "./types.js";
9
9
  /**
10
10
  * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
@@ -1 +1 @@
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"}
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,MAAM,4CAA4C,CAAC;AAapD,OAAO,KAAK,EACX,uBAAuB,EACvB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AAItD,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gEAI2C;AAE3C,yEAIoD;AAUpD,kEAA6D;AAM7D,mFAAkF;AAUlF,yCAQoB;AAkBpB;;;GAGG;AACH,MAAM,cACL,SAAQ,qBAAiD;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,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,o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AC,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,4BAGnC;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}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tC,mBAAmB,EAAE,2BAA2B;KAChD,CACD,CAAC;AACH,CAAC;AA9CD,0FA8CC;AAED;;;GAGG;AACH,MAAM,iCAAkC,SAAQ,sCAA2B;IAU1E;;;;;;;;;;;;;OAaG;IACH,YACC,MAAuB,EACvB,iBAAoC,EACpC,qBAGC,EACD,SAGE;QAEF,KAAK,CAAC;YACL,eAAe,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC;YACtD,cAAc,EAAE;gBACf,GAAG,+DAA+B,CAAC,iBAAiB,CAAC;gBACrD,GAAG,SAAS,EAAE,cAAc;aAC5B;YACD,iBAAiB;YACjB,mBAAmB,EAClB,SAAS,EAAE,mBAAmB;gBAC9B,iDAAsC,CAAC,iBAAiB,CAAC;SAC1D,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,4BAGnC;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} 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 {\n\tIFluidDataStoreRegistry,\n\tMinimumVersionForCollab,\n} 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"]}
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
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";
6
+ import { type IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
7
+ import type { IFluidDataStoreRegistry, MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
8
8
  import type { CompatibilityMode, TreeContainerSchema } from "./types.js";
9
9
  /**
10
10
  * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
@@ -1 +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,E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M,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,SAAgB,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,IAAA,4CAAiC,EAAC,MAAM,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,qBAAqB,IAAI,IAAI,iCAAsB,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;AA/CD,8EA+CC","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(\n\t\ttreeRootDataObject !== undefined,\n\t\t0xbe7 /* entryPoint must be of type TreeRootDataObject */,\n\t);\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 @beta\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"]}
1
+ {"version":3,"file":"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B,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,SAAgB,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,IAAA,4CAAiC,EAAC,MAAM,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,qBAAqB,IAAI,IAAI,iCAAsB,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;AA/CD,8EA+CC","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} 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 {\n\tIFluidDataStoreRegistry,\n\tMinimumVersionForCollab,\n} 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(\n\t\ttreeRootDataObject !== undefined,\n\t\t0xbe7 /* entryPoint must be of type TreeRootDataObject */,\n\t);\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 @beta\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;G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EAAE,OAAO;CAC0D,CAAC;AAExE;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,MAAuB;IAC5D,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC5D,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAkC,CAAC;IAC7D,IACC,kBAAkB,CAAC,UAAU,CAAC;QAC9B,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,KAAK,gCAAqB,EACrD,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AArBD,sDAqBC","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 { MinimumVersionForCollab } from \"@fluidframework/container-runtime/internal\";\nimport type { FluidObjectKeys, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIFluidDataStoreContext,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { SharedTreeFactoryType } from \"@fluidframework/tree/internal\";\n\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tLoadableObjectKind,\n\tTreeContainerSchema,\n} from \"./types.js\";\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind<T extends IFluidLoadable>(\n\tobj: LoadableObjectKind<T>,\n): obj is DataObjectKind<T>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable> {\n\tconst maybe = obj as Partial<DataObjectKind<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: LoadableObjectKind,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectKind(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: LoadableObjectKind): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectKind(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 LoadableObjectKind);\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\n/**\n * Creates a new data object of the specified type.\n */\nexport async function createDataObject<T extends IFluidLoadable>(\n\tdataObjectClass: DataObjectKind<T>,\n\tcontext: IFluidDataStoreContext,\n): Promise<T> {\n\tconst factory = dataObjectClass.factory;\n\tconst packagePath = [...context.packagePath, factory.type];\n\tconst dataStore = await context.containerRuntime.createDataStore(packagePath);\n\tconst entryPoint = await dataStore.entryPoint.get();\n\treturn entryPoint as T;\n}\n\n/**\n * Creates a new shared object of the specified type.\n */\nexport function createSharedObject<T extends IFluidLoadable>(\n\tsharedObjectClass: ISharedObjectKind<T>,\n\truntime: IFluidDataStoreRuntime,\n): T {\n\tconst factory = sharedObjectClass.getFactory();\n\tconst obj = runtime.createChannel(undefined, factory.type);\n\treturn obj as unknown as T;\n}\n\n/**\n * Creates a Fluid object that has a property with the key `providerKey` that points to itself.\n * @remarks This is useful for creating objects that need to reference themselves, such as DataObjects.\n */\nexport function makeFluidObject<\n\tT extends object,\n\tK extends FluidObjectKeys<T> = FluidObjectKeys<T>,\n>(object: Omit<T, K>, providerKey: K): T {\n\treturn Object.defineProperty(object, providerKey, { value: object }) as T;\n}\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nexport const compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Determines if the provided schema is a valid tree-based container schema.\n * @internal\n */\nexport function isTreeContainerSchema(schema: ContainerSchema): schema is TreeContainerSchema {\n\tconst schemaEntries = Object.entries(schema.initialObjects);\n\tif (schemaEntries.length !== 1) {\n\t\treturn false;\n\t}\n\n\tconst entry = schemaEntries[0] ?? oob();\n\tconst key = entry[0];\n\tif (key !== \"tree\") {\n\t\treturn false;\n\t}\n\n\tconst objectKind = entry[1] as unknown as LoadableObjectKind;\n\tif (\n\t\tisSharedObjectKind(objectKind) &&\n\t\tobjectKind.getFactory().type === SharedTreeFactoryType\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA0D;AAW1D,uEAAsE;AACtE,4DAAsE;AAuBtE;;GAEG;AACH,SAAgB,gBAAgB,CAC/B,GAAuB;IAEvB,MAAM,KAAK,GAAG,GAA0D,CAAC;IACzE,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,4CAkBC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAC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AC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAkC,CAAC;IAC7D,IACC,kBAAkB,CAAC,UAAU,CAAC;QAC9B,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,KAAK,gCAAqB,EACrD,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AArBD,sDAqBC","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 { FluidObjectKeys, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIFluidDataStoreContext,\n\tMinimumVersionForCollab,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { SharedTreeFactoryType } from \"@fluidframework/tree/internal\";\n\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tLoadableObjectKind,\n\tTreeContainerSchema,\n} from \"./types.js\";\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind<T extends IFluidLoadable>(\n\tobj: LoadableObjectKind<T>,\n): obj is DataObjectKind<T>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable> {\n\tconst maybe = obj as Partial<DataObjectKind<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: LoadableObjectKind,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectKind(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: LoadableObjectKind): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectKind(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 LoadableObjectKind);\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\n/**\n * Creates a new data object of the specified type.\n */\nexport async function createDataObject<T extends IFluidLoadable>(\n\tdataObjectClass: DataObjectKind<T>,\n\tcontext: IFluidDataStoreContext,\n): Promise<T> {\n\tconst factory = dataObjectClass.factory;\n\tconst packagePath = [...context.packagePath, factory.type];\n\tconst dataStore = await context.containerRuntime.createDataStore(packagePath);\n\tconst entryPoint = await dataStore.entryPoint.get();\n\treturn entryPoint as T;\n}\n\n/**\n * Creates a new shared object of the specified type.\n */\nexport function createSharedObject<T extends IFluidLoadable>(\n\tsharedObjectClass: ISharedObjectKind<T>,\n\truntime: IFluidDataStoreRuntime,\n): T {\n\tconst factory = sharedObjectClass.getFactory();\n\tconst obj = runtime.createChannel(undefined, factory.type);\n\treturn obj as unknown as T;\n}\n\n/**\n * Creates a Fluid object that has a property with the key `providerKey` that points to itself.\n * @remarks This is useful for creating objects that need to reference themselves, such as DataObjects.\n */\nexport function makeFluidObject<\n\tT extends object,\n\tK extends FluidObjectKeys<T> = FluidObjectKeys<T>,\n>(object: Omit<T, K>, providerKey: K): T {\n\treturn Object.defineProperty(object, providerKey, { value: object }) as T;\n}\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nexport const compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Determines if the provided schema is a valid tree-based container schema.\n * @internal\n */\nexport function isTreeContainerSchema(schema: ContainerSchema): schema is TreeContainerSchema {\n\tconst schemaEntries = Object.entries(schema.initialObjects);\n\tif (schemaEntries.length !== 1) {\n\t\treturn false;\n\t}\n\n\tconst entry = schemaEntries[0] ?? oob();\n\tconst key = entry[0];\n\tif (key !== \"tree\") {\n\t\treturn false;\n\t}\n\n\tconst objectKind = entry[1] as unknown as LoadableObjectKind;\n\tif (\n\t\tisSharedObjectKind(objectKind) &&\n\t\tobjectKind.getFactory().type === SharedTreeFactoryType\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"]}
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
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";
6
+ import { type IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
7
+ import type { IFluidDataStoreRegistry, MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
8
8
  import type { CompatibilityMode, ContainerSchema } from "./types.js";
9
9
  /**
10
10
  * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
@@ -1 +1 @@
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"}
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,MAAM,4CAA4C,CAAC;AAapD,OAAO,KAAK,EACX,uBAAuB,EACvB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AAItD,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"}
@@ -1 +1 @@
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,4CAA4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;QACC,cAAc,EAAE,sBAAsB;QACtC,mBAAmB,EAAE,2BAA2B;KAChD,CACD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,iCAAkC,SAAQ,2BAA2B;IAU1E;;;;;;;;;;;;;OAaG;IACH,YACC,MAAuB,EACvB,iBAAoC,EACpC,qBAGC,EACD,SAGE;QAEF,KAAK,CAAC;YACL,eAAe,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC;YACtD,cAAc,EAAE;gBACf,GAAG,+BAA+B,CAAC,iBAAiB,CAAC;gBACrD,GAAG,SAAS,EAAE,cAAc;aAC5B;YACD,iBAAiB;YACjB,mBAAmB,EAClB,SAAS,EAAE,mBAAmB;gBAC9B,sCAAsC,CAAC,iBAAiB,CAAC;SAC1D,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"]}
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,GAEtB,MAAM,4CAA4C,CAAC;AAUpD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAS7D,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,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,C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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} 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 {\n\tIFluidDataStoreRegistry,\n\tMinimumVersionForCollab,\n} 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"]}
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
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";
6
+ import { type IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
7
+ import type { IFluidDataStoreRegistry, MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
8
8
  import type { CompatibilityMode, TreeContainerSchema } from "./types.js";
9
9
  /**
10
10
  * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
@@ -1 +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;AA0JpB;;;;;;;;;;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"}
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,MAAM,4CAA4C,CAAC;AAYpD,OAAO,KAAK,EACX,uBAAuB,EACvB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AAItD,OAAO,KAAK,EACX,iBAAiB,EAKjB,mBAAmB,EACnB,MAAM,YAAY,CAAC;AA0JpB;;;;;;;;;;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"}
@@ -1 +1 @@
1
- {"version":3,"file":"treeRootDataObject.js","sourceRoot":"","sources":["../src/treeRootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EACN,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,GACrB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EACN,sBAAsB,GAGtB,MAAM,4CAA4C,CAAC;AAUpD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AASlF,OAAO,EACN,sCAAsC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,iCAAiC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AjBc,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(\n\t\ttreeRootDataObject !== undefined,\n\t\t0xbe7 /* entryPoint must be of type TreeRootDataObject */,\n\t);\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 @beta\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"]}
1
+ {"version":3,"file":"treeRootDataObject.js","sourceRoot":"","sources":["../src/treeRootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAEH,OAAO,EACN,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,GACrB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EACN,sBAAsB,GAEtB,MAAM,4CAA4C,CAAC;AAUpD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7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;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} 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 {\n\tIFluidDataStoreRegistry,\n\tMinimumVersionForCollab,\n} 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(\n\t\ttreeRootDataObject !== undefined,\n\t\t0xbe7 /* entryPoint must be of type TreeRootDataObject */,\n\t);\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 @beta\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAA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AE,OAAO;IACZ,GAAG,EAAE,OAAO;CAC0D,CAAC;AAExE;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAuB;IAC5D,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC5D,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAkC,CAAC;IAC7D,IACC,kBAAkB,CAAC,UAAU,CAAC;QAC9B,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,KAAK,qBAAqB,EACrD,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","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 { MinimumVersionForCollab } from \"@fluidframework/container-runtime/internal\";\nimport type { FluidObjectKeys, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIFluidDataStoreContext,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { SharedTreeFactoryType } from \"@fluidframework/tree/internal\";\n\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tLoadableObjectKind,\n\tTreeContainerSchema,\n} from \"./types.js\";\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind<T extends IFluidLoadable>(\n\tobj: LoadableObjectKind<T>,\n): obj is DataObjectKind<T>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable> {\n\tconst maybe = obj as Partial<DataObjectKind<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: LoadableObjectKind,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectKind(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: LoadableObjectKind): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectKind(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 LoadableObjectKind);\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\n/**\n * Creates a new data object of the specified type.\n */\nexport async function createDataObject<T extends IFluidLoadable>(\n\tdataObjectClass: DataObjectKind<T>,\n\tcontext: IFluidDataStoreContext,\n): Promise<T> {\n\tconst factory = dataObjectClass.factory;\n\tconst packagePath = [...context.packagePath, factory.type];\n\tconst dataStore = await context.containerRuntime.createDataStore(packagePath);\n\tconst entryPoint = await dataStore.entryPoint.get();\n\treturn entryPoint as T;\n}\n\n/**\n * Creates a new shared object of the specified type.\n */\nexport function createSharedObject<T extends IFluidLoadable>(\n\tsharedObjectClass: ISharedObjectKind<T>,\n\truntime: IFluidDataStoreRuntime,\n): T {\n\tconst factory = sharedObjectClass.getFactory();\n\tconst obj = runtime.createChannel(undefined, factory.type);\n\treturn obj as unknown as T;\n}\n\n/**\n * Creates a Fluid object that has a property with the key `providerKey` that points to itself.\n * @remarks This is useful for creating objects that need to reference themselves, such as DataObjects.\n */\nexport function makeFluidObject<\n\tT extends object,\n\tK extends FluidObjectKeys<T> = FluidObjectKeys<T>,\n>(object: Omit<T, K>, providerKey: K): T {\n\treturn Object.defineProperty(object, providerKey, { value: object }) as T;\n}\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nexport const compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Determines if the provided schema is a valid tree-based container schema.\n * @internal\n */\nexport function isTreeContainerSchema(schema: ContainerSchema): schema is TreeContainerSchema {\n\tconst schemaEntries = Object.entries(schema.initialObjects);\n\tif (schemaEntries.length !== 1) {\n\t\treturn false;\n\t}\n\n\tconst entry = schemaEntries[0] ?? oob();\n\tconst key = entry[0];\n\tif (key !== \"tree\") {\n\t\treturn false;\n\t}\n\n\tconst objectKind = entry[1] as unknown as LoadableObjectKind;\n\tif (\n\t\tisSharedObjectKind(objectKind) &&\n\t\tobjectKind.getFactory().type === SharedTreeFactoryType\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAW1D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAuBtE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC/B,GAAuB;IAEvB,MAAM,KAAK,GAAG,GAA0D,CAAC;IACzE,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,UAAU,CAAC,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;IAC5D,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAkC,CAAC;IAC7D,IACC,kBAAkB,CAAC,UAAU,CAAC;QAC9B,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,KAAK,qBAAqB,EACrD,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","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 { FluidObjectKeys, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIFluidDataStoreContext,\n\tMinimumVersionForCollab,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { SharedTreeFactoryType } from \"@fluidframework/tree/internal\";\n\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tLoadableObjectKind,\n\tTreeContainerSchema,\n} from \"./types.js\";\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind<T extends IFluidLoadable>(\n\tobj: LoadableObjectKind<T>,\n): obj is DataObjectKind<T>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable> {\n\tconst maybe = obj as Partial<DataObjectKind<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: LoadableObjectKind,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectKind(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: LoadableObjectKind): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectKind(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 LoadableObjectKind);\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\n/**\n * Creates a new data object of the specified type.\n */\nexport async function createDataObject<T extends IFluidLoadable>(\n\tdataObjectClass: DataObjectKind<T>,\n\tcontext: IFluidDataStoreContext,\n): Promise<T> {\n\tconst factory = dataObjectClass.factory;\n\tconst packagePath = [...context.packagePath, factory.type];\n\tconst dataStore = await context.containerRuntime.createDataStore(packagePath);\n\tconst entryPoint = await dataStore.entryPoint.get();\n\treturn entryPoint as T;\n}\n\n/**\n * Creates a new shared object of the specified type.\n */\nexport function createSharedObject<T extends IFluidLoadable>(\n\tsharedObjectClass: ISharedObjectKind<T>,\n\truntime: IFluidDataStoreRuntime,\n): T {\n\tconst factory = sharedObjectClass.getFactory();\n\tconst obj = runtime.createChannel(undefined, factory.type);\n\treturn obj as unknown as T;\n}\n\n/**\n * Creates a Fluid object that has a property with the key `providerKey` that points to itself.\n * @remarks This is useful for creating objects that need to reference themselves, such as DataObjects.\n */\nexport function makeFluidObject<\n\tT extends object,\n\tK extends FluidObjectKeys<T> = FluidObjectKeys<T>,\n>(object: Omit<T, K>, providerKey: K): T {\n\treturn Object.defineProperty(object, providerKey, { value: object }) as T;\n}\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nexport const compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Determines if the provided schema is a valid tree-based container schema.\n * @internal\n */\nexport function isTreeContainerSchema(schema: ContainerSchema): schema is TreeContainerSchema {\n\tconst schemaEntries = Object.entries(schema.initialObjects);\n\tif (schemaEntries.length !== 1) {\n\t\treturn false;\n\t}\n\n\tconst entry = schemaEntries[0] ?? oob();\n\tconst key = entry[0];\n\tif (key !== \"tree\") {\n\t\treturn false;\n\t}\n\n\tconst objectKind = entry[1] as unknown as LoadableObjectKind;\n\tif (\n\t\tisSharedObjectKind(objectKind) &&\n\t\tobjectKind.getFactory().type === SharedTreeFactoryType\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/fluid-static",
3
- "version": "2.70.0-360753",
3
+ "version": "2.70.0-361248",
4
4
  "description": "A tool to enable consumption of Fluid Data Objects without requiring custom container code.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -69,34 +69,34 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "2.70.0-360753",
73
- "@fluidframework/aqueduct": "2.70.0-360753",
74
- "@fluidframework/container-definitions": "2.70.0-360753",
75
- "@fluidframework/container-loader": "2.70.0-360753",
76
- "@fluidframework/container-runtime": "2.70.0-360753",
77
- "@fluidframework/container-runtime-definitions": "2.70.0-360753",
78
- "@fluidframework/core-interfaces": "2.70.0-360753",
79
- "@fluidframework/core-utils": "2.70.0-360753",
80
- "@fluidframework/datastore-definitions": "2.70.0-360753",
81
- "@fluidframework/driver-definitions": "2.70.0-360753",
82
- "@fluidframework/request-handler": "2.70.0-360753",
83
- "@fluidframework/runtime-definitions": "2.70.0-360753",
84
- "@fluidframework/runtime-utils": "2.70.0-360753",
85
- "@fluidframework/shared-object-base": "2.70.0-360753",
86
- "@fluidframework/telemetry-utils": "2.70.0-360753",
87
- "@fluidframework/tree": "2.70.0-360753"
72
+ "@fluid-internal/client-utils": "2.70.0-361248",
73
+ "@fluidframework/aqueduct": "2.70.0-361248",
74
+ "@fluidframework/container-definitions": "2.70.0-361248",
75
+ "@fluidframework/container-loader": "2.70.0-361248",
76
+ "@fluidframework/container-runtime": "2.70.0-361248",
77
+ "@fluidframework/container-runtime-definitions": "2.70.0-361248",
78
+ "@fluidframework/core-interfaces": "2.70.0-361248",
79
+ "@fluidframework/core-utils": "2.70.0-361248",
80
+ "@fluidframework/datastore-definitions": "2.70.0-361248",
81
+ "@fluidframework/driver-definitions": "2.70.0-361248",
82
+ "@fluidframework/request-handler": "2.70.0-361248",
83
+ "@fluidframework/runtime-definitions": "2.70.0-361248",
84
+ "@fluidframework/runtime-utils": "2.70.0-361248",
85
+ "@fluidframework/shared-object-base": "2.70.0-361248",
86
+ "@fluidframework/telemetry-utils": "2.70.0-361248",
87
+ "@fluidframework/tree": "2.70.0-361248"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@arethetypeswrong/cli": "^0.17.1",
91
91
  "@biomejs/biome": "~1.9.3",
92
- "@fluid-internal/mocha-test-setup": "2.70.0-360753",
92
+ "@fluid-internal/mocha-test-setup": "2.70.0-361248",
93
93
  "@fluid-tools/build-cli": "^0.58.3",
94
94
  "@fluidframework/build-common": "^2.0.3",
95
95
  "@fluidframework/build-tools": "^0.58.3",
96
- "@fluidframework/eslint-config-fluid": "^6.0.0",
96
+ "@fluidframework/eslint-config-fluid": "^6.1.0",
97
97
  "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.63.0",
98
- "@fluidframework/map": "2.70.0-360753",
99
- "@fluidframework/sequence": "2.70.0-360753",
98
+ "@fluidframework/map": "2.70.0-361248",
99
+ "@fluidframework/sequence": "2.70.0-361248",
100
100
  "@microsoft/api-extractor": "7.52.11",
101
101
  "@types/mocha": "^10.0.10",
102
102
  "@types/node": "^18.19.0",
@@ -104,7 +104,7 @@
104
104
  "concurrently": "^8.2.1",
105
105
  "copyfiles": "^2.4.1",
106
106
  "cross-env": "^7.0.3",
107
- "eslint": "~8.55.0",
107
+ "eslint": "~8.57.1",
108
108
  "mocha": "^10.8.2",
109
109
  "mocha-multi-reporters": "^1.5.1",
110
110
  "rimraf": "^4.4.0",
@@ -12,7 +12,6 @@ import type { IRuntimeFactory } from "@fluidframework/container-definitions/inte
12
12
  import {
13
13
  FluidDataStoreRegistry,
14
14
  type IContainerRuntimeOptions,
15
- type MinimumVersionForCollab,
16
15
  } from "@fluidframework/container-runtime/internal";
17
16
  import type {
18
17
  IContainerRuntime,
@@ -26,7 +25,10 @@ import type {
26
25
  import { assert } from "@fluidframework/core-utils/internal";
27
26
  import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
28
27
  import type { IDirectory } from "@fluidframework/map/internal";
29
- import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
28
+ import type {
29
+ IFluidDataStoreRegistry,
30
+ MinimumVersionForCollab,
31
+ } from "@fluidframework/runtime-definitions/internal";
30
32
  import type { SharedObjectKind } from "@fluidframework/shared-object-base/internal";
31
33
 
32
34
  import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
@@ -13,7 +13,6 @@ import type { IRuntimeFactory } from "@fluidframework/container-definitions/inte
13
13
  import {
14
14
  FluidDataStoreRegistry,
15
15
  type IContainerRuntimeOptions,
16
- type MinimumVersionForCollab,
17
16
  } from "@fluidframework/container-runtime/internal";
18
17
  import type {
19
18
  IContainerRuntime,
@@ -26,7 +25,10 @@ import type {
26
25
  } from "@fluidframework/core-interfaces";
27
26
  import { assert } from "@fluidframework/core-utils/internal";
28
27
  import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
29
- import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
28
+ import type {
29
+ IFluidDataStoreRegistry,
30
+ MinimumVersionForCollab,
31
+ } from "@fluidframework/runtime-definitions/internal";
30
32
  import type { SharedObjectKind } from "@fluidframework/shared-object-base/internal";
31
33
 
32
34
  import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
package/src/utils.ts CHANGED
@@ -4,7 +4,6 @@
4
4
  */
5
5
 
6
6
  import type { DataObjectKind } from "@fluidframework/aqueduct/internal";
7
- import type { MinimumVersionForCollab } from "@fluidframework/container-runtime/internal";
8
7
  import type { FluidObjectKeys, IFluidLoadable } from "@fluidframework/core-interfaces";
9
8
  import { oob } from "@fluidframework/core-utils/internal";
10
9
  import type {
@@ -13,6 +12,7 @@ import type {
13
12
  } from "@fluidframework/datastore-definitions/internal";
14
13
  import type {
15
14
  IFluidDataStoreContext,
15
+ MinimumVersionForCollab,
16
16
  NamedFluidDataStoreRegistryEntry,
17
17
  } from "@fluidframework/runtime-definitions/internal";
18
18
  import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";