@fluidframework/aqueduct 0.58.2001 → 0.59.2000-61729
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +4231 -234
- package/dist/test/types/validateAqueductPrevious.js +45 -0
- package/dist/test/types/validateAqueductPrevious.js.map +1 -0
- package/lib/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
- package/lib/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/package.json +29 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseContainerRuntimeFactory.js","sourceRoot":"","sources":["../../src/container-runtime-factories/baseContainerRuntimeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yEAI2C;AAC3C,iGAEuD;AACvD,qEAGyC;AAMzC,2DAIoC;AACpC,iEAAqE;AAGrE;;;;GAIG;AACH,MAAa,2BACT,SAAQ,oCAAoB;IAK5B;;;;;OAKG;IACH,YACqB,eAAmD,EACnD,mBAAiD,EACjD,kBAA2C,EAAE,EAC7C,cAAyC;QAE1D,KAAK,EAAE,CAAC;QALS,oBAAe,GAAf,eAAe,CAAoC;QACnD,wBAAmB,GAAnB,mBAAmB,CAA8B;QACjD,oBAAe,GAAf,eAAe,CAA8B;QAC7C,mBAAc,GAAd,cAAc,CAA2B;QAG1D,IAAI,CAAC,QAAQ,GAAG,IAAI,0CAAsB,CAAC,eAAe,CAAC,CAAC;IAChE,CAAC;IAjBD,IAAW,uBAAuB,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAmBvD,KAAK,CAAC,oBAAoB,CAAC,OAAyB;QACvD,MAAM,IAAI,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,OAAyB;QAC1D,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,aAAa,CACtB,OAA0B,EAC1B,QAAiB;QAEjB,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"baseContainerRuntimeFactory.js","sourceRoot":"","sources":["../../src/container-runtime-factories/baseContainerRuntimeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yEAI2C;AAC3C,iGAEuD;AACvD,qEAGyC;AAMzC,2DAIoC;AACpC,iEAAqE;AAGrE;;;;GAIG;AACH,MAAa,2BACT,SAAQ,oCAAoB;IAK5B;;;;;OAKG;IACH,YACqB,eAAmD,EACnD,mBAAiD,EACjD,kBAA2C,EAAE,EAC7C,cAAyC;QAE1D,KAAK,EAAE,CAAC;QALS,oBAAe,GAAf,eAAe,CAAoC;QACnD,wBAAmB,GAAnB,mBAAmB,CAA8B;QACjD,oBAAe,GAAf,eAAe,CAA8B;QAC7C,mBAAc,GAAd,cAAc,CAA2B;QAG1D,IAAI,CAAC,QAAQ,GAAG,IAAI,0CAAsB,CAAC,eAAe,CAAC,CAAC;IAChE,CAAC;IAjBD,IAAW,uBAAuB,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAmBvD,KAAK,CAAC,oBAAoB,CAAC,OAAyB;QACvD,MAAM,IAAI,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,OAAyB;QAC1D,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,aAAa,CACtB,OAA0B,EAC1B,QAAiB;QAEjB,MAAM,KAAK,GAAgD,OAAO,CAAC,KAAK,CAAC;QACzE,MAAM,EAAE,GAAG,IAAI,gCAAmB,CAC9B,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;QACjE,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC;QAEvC,MAAM,OAAO,GAAqB,MAAM,oCAAgB,CAAC,IAAI,CACzD,OAAO,EACP,IAAI,CAAC,eAAe,EACpB,4CAA0B,CACtB,GAAG,IAAI,CAAC,eAAe,CAAC,EAC5B,IAAI,CAAC,cAAc,EACnB,KAAK,EACL,QAAQ,CACX,CAAC;QAEF,wFAAwF;QACxF,EAAE,CAAC,QAAQ,CAAC,iDAAiB,EAAE,OAAO,CAAC,CAAC;QAExC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B,IAAI,CAAC;IAE9E;;;;OAIG;IACO,KAAK,CAAC,uBAAuB,CAAC,OAA0B,IAAI,CAAC;CAC1E;AArED,kEAqEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IContainerContext } from \"@fluidframework/container-definitions\";\nimport {\n IContainerRuntimeOptions,\n FluidDataStoreRegistry,\n ContainerRuntime,\n} from \"@fluidframework/container-runtime\";\nimport {\n IContainerRuntime,\n} from \"@fluidframework/container-runtime-definitions\";\nimport {\n RuntimeRequestHandler,\n buildRuntimeRequestHandler,\n} from \"@fluidframework/request-handler\";\nimport {\n IFluidDataStoreRegistry,\n IProvideFluidDataStoreRegistry,\n NamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n DependencyContainer,\n IFluidDependencySynthesizer,\n IProvideFluidDependencySynthesizer,\n} from \"@fluidframework/synthesize\";\nimport { RuntimeFactoryHelper } from \"@fluidframework/runtime-utils\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\n\n/**\n * BaseContainerRuntimeFactory produces container runtimes with a given data store and service registry, as well as\n * given request handlers. It can be subclassed to implement a first-time initialization procedure for the containers\n * it creates.\n */\nexport class BaseContainerRuntimeFactory\n extends RuntimeFactoryHelper\n implements IProvideFluidDataStoreRegistry {\n public get IFluidDataStoreRegistry() { return this.registry; }\n private readonly registry: IFluidDataStoreRegistry;\n\n /**\n * @param registryEntries - The data store registry for containers produced\n * @param serviceRegistry - The service registry for containers produced\n * @param requestHandlers - Request handlers for containers produced\n * @param runtimeOptions - The runtime options passed to the ContainerRuntime when instantiating it\n */\n constructor(\n private readonly registryEntries: NamedFluidDataStoreRegistryEntries,\n private readonly dependencyContainer?: IFluidDependencySynthesizer,\n private readonly requestHandlers: RuntimeRequestHandler[] = [],\n private readonly runtimeOptions?: IContainerRuntimeOptions,\n ) {\n super();\n this.registry = new FluidDataStoreRegistry(registryEntries);\n }\n\n public async instantiateFirstTime(runtime: ContainerRuntime): Promise<void> {\n await this.containerInitializingFirstTime(runtime);\n await this.containerHasInitialized(runtime);\n }\n\n public async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {\n await this.containerHasInitialized(runtime);\n }\n\n public async preInitialize(\n context: IContainerContext,\n existing: boolean,\n ): Promise<ContainerRuntime> {\n const scope: Partial<IProvideFluidDependencySynthesizer> = context.scope;\n const dc = new DependencyContainer<FluidObject<IContainerRuntime>>(\n this.dependencyContainer, scope.IFluidDependencySynthesizer);\n scope.IFluidDependencySynthesizer = dc;\n\n const runtime: ContainerRuntime = await ContainerRuntime.load(\n context,\n this.registryEntries,\n buildRuntimeRequestHandler(\n ...this.requestHandlers),\n this.runtimeOptions,\n scope,\n existing,\n );\n\n // we register the runtime so developers of providers can use it in the factory pattern.\n dc.register(IContainerRuntime, runtime);\n\n return runtime;\n }\n\n /**\n * Subclasses may override containerInitializingFirstTime to perform any setup steps at the time the container\n * is created. This likely includes creating any initial data stores that are expected to be there at the outset.\n * @param runtime - The container runtime for the container being initialized\n */\n protected async containerInitializingFirstTime(runtime: IContainerRuntime) { }\n\n /**\n * Subclasses may override containerHasInitialized to perform any steps after the container has initialized.\n * This likely includes loading any data stores that are expected to be there at the outset.\n * @param runtime - The container runtime for the container being initialized\n */\n protected async containerHasInitialized(runtime: IContainerRuntime) { }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yDAIoC;AACpC,yEAA2E;AAa3E,2DAIoC;AAEpC,kDAIyB;AAUzB;;;EAGE;AACF,KAAK,UAAU,gBAAgB,CAC3B,IAA8C,EAC9C,OAA+B,EAC/B,oBAA2C,EAC3C,iBAAoE,EACpE,eAA6C,EAC7C,QAAiB,EACjB,SAA6B;IAE7B,OAAO;IACP,IAAI,YAAY,GAAG,eAAe,CAAC;IAEnC,mBAAmB;IACnB,YAAY,GAAG,+BAAmB,CAC9B,KAAK,EAAE,OAAiB,EAAE,UAAiC,EAAE,EAAE,CAC3D,CAAC,MAAM,6BAAc,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EACjE,YAAY,CAAC,CAAC;IAEtB,0CAA0C;IAC1C,6EAA6E;IAC7E,MAAM,OAAO,GAAG,IAAI,YAAY,CAC5B,OAAO,EACP,oBAAoB,EACpB,QAAQ,CACX,CAAC;IAEF,4BAA4B;IAC5B,+EAA+E;IAC/E,mFAAmF;IACnF,iFAAiF;IACjF,uGAAuG;IACvG,MAAM,KAAK,GAAG,OAAO,CAAC,KAAiD,CAAC;IACxE,MAAM,mBAAmB,GAAG,IAAI,gCAAmB,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACvF,MAAM,SAAS,GAAG,mBAAmB,CAAC,UAAU,CAAyB,iBAAiB,EAAE,EAAE,CAAC,CAAC;IAChG,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CA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AgC;QAEhC,MAAM,OAAO,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;IAES,KAAK,CAAC,kBAAkB,CAC9B,OAAuC,EACvC,YAAgC;QAEhC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,gBAAgB,CAChD,IAAI,CAAC,IAAI,EACT,OAAO,EACP,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,YAAY,EACjB,KAAK,EAAE,WAAW;QAClB,YAAY,CAAC,CAAC;QAElB,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE3C,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAlKD,sDAkKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, IFluidRouter, FluidObject } from \"@fluidframework/core-interfaces\";\nimport {\n FluidDataStoreRuntime,\n ISharedObjectRegistry,\n mixinRequestHandler,\n } from \"@fluidframework/datastore\";\nimport { FluidDataStoreRegistry } from \"@fluidframework/container-runtime\";\nimport {\n IFluidDataStoreContext,\n IContainerRuntimeBase,\n IFluidDataStoreFactory,\n IFluidDataStoreRegistry,\n IProvideFluidDataStoreRegistry,\n NamedFluidDataStoreRegistryEntries,\n NamedFluidDataStoreRegistryEntry,\n IFluidDataStoreContextDetached,\n} from \"@fluidframework/runtime-definitions\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n FluidObjectSymbolProvider,\n DependencyContainer,\n IFluidDependencySynthesizer,\n} from \"@fluidframework/synthesize\";\n\nimport {\n IDataObjectProps,\n PureDataObject,\n DataObjectTypes,\n} from \"../data-objects\";\n/*\n * Useful interface in places where it's useful to do type erasure for PureDataObject generic\n */\nexport interface IRootDataObjectFactory extends IFluidDataStoreFactory {\n createRootInstance(\n rootDataStoreId: string,\n runtime: IContainerRuntime): Promise<IFluidRouter>;\n}\n\n/**\n * Proxy over PureDataObject\n * Does delayed creation & initialization of PureDataObject\n*/\nasync function createDataObject<TObj extends PureDataObject,I extends DataObjectTypes = DataObjectTypes>(\n ctor: new (props: IDataObjectProps<I>) => TObj,\n context: IFluidDataStoreContext,\n sharedObjectRegistry: ISharedObjectRegistry,\n optionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n runtimeClassArg: typeof FluidDataStoreRuntime,\n existing: boolean,\n initProps?: I[\"InitialState\"])\n{\n // base\n let runtimeClass = runtimeClassArg;\n\n // request mixin in\n runtimeClass = mixinRequestHandler(\n async (request: IRequest, runtimeArg: FluidDataStoreRuntime) =>\n (await PureDataObject.getDataObject(runtimeArg)).request(request),\n runtimeClass);\n\n // Create a new runtime for our data store\n // The runtime is what Fluid uses to create DDS' and route to your data store\n const runtime = new runtimeClass(\n context,\n sharedObjectRegistry,\n existing,\n );\n\n // Create object right away.\n // This allows object to register various callbacks with runtime before runtime\n // becomes globally available. But it's not full initialization - constructor can't\n // access DDSs or other services of runtime as objects are not fully initialized.\n // In order to use object, we need to go through full initialization by calling finishInitialization().\n const scope = context.scope as FluidObject<IFluidDependencySynthesizer>;\n const dependencyContainer = new DependencyContainer(scope.IFluidDependencySynthesizer);\n const providers = dependencyContainer.synthesize<I[\"OptionalProviders\"]>(optionalProviders, {});\n const instance = new ctor({ runtime, context, providers, initProps });\n\n // if it's a newly created object, we need to wait for it to finish initialization\n // as that results in creation of DDSs, before it gets attached, providing atomic\n // guarantee of creation.\n // WARNING: we can't do the same (yet) for already existing PureDataObject!\n // This will result in deadlock, as it tries to resolve internal handles, but any\n // handle resolution goes through root (container runtime), which can't route it back\n // to this data store, as it's still not initialized and not known to container runtime yet.\n // In the future, we should address it by using relative paths for handles and be able to resolve\n // local DDSs while data store is not fully initialized.\n if (!existing) {\n await instance.finishInitialization(existing);\n }\n\n return { instance, runtime };\n}\n\n/**\n * PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject.\n * Consumers should typically use DataObjectFactory instead unless creating\n * another base data store factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n */\nexport class PureDataObjectFactory<TObj extends PureDataObject<I>, I extends DataObjectTypes = DataObjectTypes>\n implements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>, IRootDataObjectFactory\n{\n private readonly sharedObjectRegistry: ISharedObjectRegistry;\n private readonly registry: IFluidDataStoreRegistry | undefined;\n\n constructor(\n public readonly type: string,\n private readonly ctor: new (props: IDataObjectProps<I>) => TObj,\n sharedObjects: readonly IChannelFactory[],\n private readonly optionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n registryEntries?: NamedFluidDataStoreRegistryEntries,\n private readonly runtimeClass: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n ) {\n if (this.type === \"\") {\n throw new Error(\"undefined type member\");\n }\n if (registryEntries !== undefined) {\n this.registry = new FluidDataStoreRegistry(registryEntries);\n }\n this.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));\n }\n\n public get IFluidDataStoreFactory() { return this; }\n\n public get IFluidDataStoreRegistry() {\n return this.registry;\n }\n\n /**\n * Convenience helper to get the data store's/factory's data store registry entry.\n * The return type hides the factory's generics, easing grouping of registry\n * entries that differ only in this way into the same array.\n * @returns The NamedFluidDataStoreRegistryEntry\n */\n public get registryEntry(): NamedFluidDataStoreRegistryEntry {\n return [this.type, Promise.resolve(this)];\n }\n\n /**\n * This is where we do data store setup.\n *\n * @param context - data store context used to load a data store runtime\n */\n public async instantiateDataStore(context: IFluidDataStoreContext, existing: boolean) {\n const { runtime } = await createDataObject(\n this.ctor,\n context,\n this.sharedObjectRegistry,\n this.optionalProviders,\n this.runtimeClass,\n existing);\n\n return runtime;\n }\n\n /**\n * Creates a new instance of the object. Uses parent context's registry to build package path to this factory.\n * In other words, registry of context passed in has to contain this factory, with the name that matches\n * this factory's type.\n * It is intended to be used by data store objects that create sub-objects.\n * @param context - The context being used to create the runtime\n * (the created object will have its own new context created as well)\n * @param initialState - The initial state to provide to the created data store.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createChildInstance(\n parentContext: IFluidDataStoreContext,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n parentContext.containerRuntime,\n [...parentContext.packagePath, this.type],\n initialState);\n }\n\n /**\n * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.\n * In other words, registry of context passed in has to have this factory.\n * Intended to be used by data store objects that need to create peers (similar) instances of existing objects.\n * @param context - The component context being used to create the object\n * (the created object will have its own new context created as well)\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createPeerInstance(\n peerContext: IFluidDataStoreContext,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n peerContext.containerRuntime,\n peerContext.packagePath,\n initialState);\n }\n\n /**\n * Creates a new instance of the object. Uses container's registry to find this factory.\n * It's expected that only container owners would use this functionality, as only such developers\n * have knowledge of entries in container registry.\n * The name in this registry for such record should match type of this factory.\n * @param runtime - container runtime. It's registry is used to create an object.\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createInstance(\n runtime: IContainerRuntimeBase,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n runtime,\n [this.type],\n initialState);\n }\n\n /**\n * Creates a new root instance of the object. Uses container's registry to find this factory.\n * It's expected that only container owners would use this functionality, as only such developers\n * have knowledge of entries in container registry.\n * The name in this registry for such record should match type of this factory.\n * @param runtime - container runtime. It's registry is used to create an object.\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createRootInstance(\n rootDataStoreId: string,\n runtime: IContainerRuntime,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n const context = runtime.createDetachedRootDataStore([this.type], rootDataStoreId);\n return this.createInstanceCore(context, initialState);\n }\n\n protected async createNonRootInstanceCore(\n containerRuntime: IContainerRuntimeBase,\n packagePath: Readonly<string[]>,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n const context = containerRuntime.createDetachedDataStore(packagePath);\n return this.createInstanceCore(context, initialState);\n }\n\n protected async createInstanceCore(\n context: IFluidDataStoreContextDetached,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n const { instance, runtime } = await createDataObject(\n this.ctor,\n context,\n this.sharedObjectRegistry,\n this.optionalProviders,\n this.runtimeClass,\n false, // existing\n initialState);\n\n await context.attachRuntime(this, runtime);\n\n return instance;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yDAIoC;AACpC,yEAA2E;AAa3E,2DAIoC;AAEpC,kDAIyB;AAUzB;;;EAGE;AACF,KAAK,UAAU,gBAAgB,CAC3B,IAA8C,EAC9C,OAA+B,EAC/B,oBAA2C,EAC3C,iBAAoE,EACpE,eAA6C,EAC7C,QAAiB,EACjB,SAA6B;IAE7B,OAAO;IACP,IAAI,YAAY,GAAG,eAAe,CAAC;IAEnC,mBAAmB;IACnB,YAAY,GAAG,+BAAmB,CAC9B,KAAK,EAAE,OAAiB,EAAE,UAAiC,EAAE,EAAE,CAC3D,CAAC,MAAM,6BAAc,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAA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AAC,CAAC;IACtB,CAAC;IAED;;;;;;;;;OASG;IACI,KAAK,CAAC,cAAc,CACvB,OAA8B,EAC9B,YAAgC;QAEhC,OAAO,IAAI,CAAC,yBAAyB,CACjC,OAAO,EACP,CAAC,IAAI,CAAC,IAAI,CAAC,EACX,YAAY,CAAC,CAAC;IACtB,CAAC;IAED;;;;;;;;;OASG;IACI,KAAK,CAAC,kBAAkB,CAC3B,eAAuB,EACvB,OAA0B,EAC1B,YAAgC;QAEhC,MAAM,OAAO,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,CAAC;QAClF,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;IAES,KAAK,CAAC,yBAAyB,CACrC,gBAAuC,EACvC,WAA+B,EAC/B,YAAgC;QAEhC,MAAM,OAAO,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;IAES,KAAK,CAAC,kBAAkB,CAC9B,OAAuC,EACvC,YAAgC;QAEhC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,gBAAgB,CAChD,IAAI,CAAC,IAAI,EACT,OAAO,EACP,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,YAAY,EACjB,KAAK,EAAE,WAAW;QAClB,YAAY,CAAC,CAAC;QAElB,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE3C,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAlKD,sDAkKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, IFluidRouter, FluidObject } from \"@fluidframework/core-interfaces\";\nimport {\n FluidDataStoreRuntime,\n ISharedObjectRegistry,\n mixinRequestHandler,\n } from \"@fluidframework/datastore\";\nimport { FluidDataStoreRegistry } from \"@fluidframework/container-runtime\";\nimport {\n IFluidDataStoreContext,\n IContainerRuntimeBase,\n IFluidDataStoreFactory,\n IFluidDataStoreRegistry,\n IProvideFluidDataStoreRegistry,\n NamedFluidDataStoreRegistryEntries,\n NamedFluidDataStoreRegistryEntry,\n IFluidDataStoreContextDetached,\n} from \"@fluidframework/runtime-definitions\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n FluidObjectSymbolProvider,\n DependencyContainer,\n IFluidDependencySynthesizer,\n} from \"@fluidframework/synthesize\";\n\nimport {\n IDataObjectProps,\n PureDataObject,\n DataObjectTypes,\n} from \"../data-objects\";\n/*\n * Useful interface in places where it's useful to do type erasure for PureDataObject generic\n */\nexport interface IRootDataObjectFactory extends IFluidDataStoreFactory {\n createRootInstance(\n rootDataStoreId: string,\n runtime: IContainerRuntime): Promise<IFluidRouter>;\n}\n\n/**\n * Proxy over PureDataObject\n * Does delayed creation & initialization of PureDataObject\n*/\nasync function createDataObject<TObj extends PureDataObject,I extends DataObjectTypes = DataObjectTypes>(\n ctor: new (props: IDataObjectProps<I>) => TObj,\n context: IFluidDataStoreContext,\n sharedObjectRegistry: ISharedObjectRegistry,\n optionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n runtimeClassArg: typeof FluidDataStoreRuntime,\n existing: boolean,\n initProps?: I[\"InitialState\"])\n{\n // base\n let runtimeClass = runtimeClassArg;\n\n // request mixin in\n runtimeClass = mixinRequestHandler(\n async (request: IRequest, runtimeArg: FluidDataStoreRuntime) =>\n (await PureDataObject.getDataObject(runtimeArg)).request(request),\n runtimeClass);\n\n // Create a new runtime for our data store\n // The runtime is what Fluid uses to create DDS' and route to your data store\n const runtime = new runtimeClass(\n context,\n sharedObjectRegistry,\n existing,\n );\n\n // Create object right away.\n // This allows object to register various callbacks with runtime before runtime\n // becomes globally available. But it's not full initialization - constructor can't\n // access DDSs or other services of runtime as objects are not fully initialized.\n // In order to use object, we need to go through full initialization by calling finishInitialization().\n const scope: FluidObject<IFluidDependencySynthesizer> = context.scope;\n const dependencyContainer = new DependencyContainer(scope.IFluidDependencySynthesizer);\n const providers = dependencyContainer.synthesize<I[\"OptionalProviders\"]>(optionalProviders, {});\n const instance = new ctor({ runtime, context, providers, initProps });\n\n // if it's a newly created object, we need to wait for it to finish initialization\n // as that results in creation of DDSs, before it gets attached, providing atomic\n // guarantee of creation.\n // WARNING: we can't do the same (yet) for already existing PureDataObject!\n // This will result in deadlock, as it tries to resolve internal handles, but any\n // handle resolution goes through root (container runtime), which can't route it back\n // to this data store, as it's still not initialized and not known to container runtime yet.\n // In the future, we should address it by using relative paths for handles and be able to resolve\n // local DDSs while data store is not fully initialized.\n if (!existing) {\n await instance.finishInitialization(existing);\n }\n\n return { instance, runtime };\n}\n\n/**\n * PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject.\n * Consumers should typically use DataObjectFactory instead unless creating\n * another base data store factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n */\nexport class PureDataObjectFactory<TObj extends PureDataObject<I>, I extends DataObjectTypes = DataObjectTypes>\n implements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>, IRootDataObjectFactory\n{\n private readonly sharedObjectRegistry: ISharedObjectRegistry;\n private readonly registry: IFluidDataStoreRegistry | undefined;\n\n constructor(\n public readonly type: string,\n private readonly ctor: new (props: IDataObjectProps<I>) => TObj,\n sharedObjects: readonly IChannelFactory[],\n private readonly optionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n registryEntries?: NamedFluidDataStoreRegistryEntries,\n private readonly runtimeClass: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n ) {\n if (this.type === \"\") {\n throw new Error(\"undefined type member\");\n }\n if (registryEntries !== undefined) {\n this.registry = new FluidDataStoreRegistry(registryEntries);\n }\n this.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));\n }\n\n public get IFluidDataStoreFactory() { return this; }\n\n public get IFluidDataStoreRegistry() {\n return this.registry;\n }\n\n /**\n * Convenience helper to get the data store's/factory's data store registry entry.\n * The return type hides the factory's generics, easing grouping of registry\n * entries that differ only in this way into the same array.\n * @returns The NamedFluidDataStoreRegistryEntry\n */\n public get registryEntry(): NamedFluidDataStoreRegistryEntry {\n return [this.type, Promise.resolve(this)];\n }\n\n /**\n * This is where we do data store setup.\n *\n * @param context - data store context used to load a data store runtime\n */\n public async instantiateDataStore(context: IFluidDataStoreContext, existing: boolean) {\n const { runtime } = await createDataObject(\n this.ctor,\n context,\n this.sharedObjectRegistry,\n this.optionalProviders,\n this.runtimeClass,\n existing);\n\n return runtime;\n }\n\n /**\n * Creates a new instance of the object. Uses parent context's registry to build package path to this factory.\n * In other words, registry of context passed in has to contain this factory, with the name that matches\n * this factory's type.\n * It is intended to be used by data store objects that create sub-objects.\n * @param context - The context being used to create the runtime\n * (the created object will have its own new context created as well)\n * @param initialState - The initial state to provide to the created data store.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createChildInstance(\n parentContext: IFluidDataStoreContext,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n parentContext.containerRuntime,\n [...parentContext.packagePath, this.type],\n initialState);\n }\n\n /**\n * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.\n * In other words, registry of context passed in has to have this factory.\n * Intended to be used by data store objects that need to create peers (similar) instances of existing objects.\n * @param context - The component context being used to create the object\n * (the created object will have its own new context created as well)\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createPeerInstance(\n peerContext: IFluidDataStoreContext,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n peerContext.containerRuntime,\n peerContext.packagePath,\n initialState);\n }\n\n /**\n * Creates a new instance of the object. Uses container's registry to find this factory.\n * It's expected that only container owners would use this functionality, as only such developers\n * have knowledge of entries in container registry.\n * The name in this registry for such record should match type of this factory.\n * @param runtime - container runtime. It's registry is used to create an object.\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createInstance(\n runtime: IContainerRuntimeBase,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n runtime,\n [this.type],\n initialState);\n }\n\n /**\n * Creates a new root instance of the object. Uses container's registry to find this factory.\n * It's expected that only container owners would use this functionality, as only such developers\n * have knowledge of entries in container registry.\n * The name in this registry for such record should match type of this factory.\n * @param runtime - container runtime. It's registry is used to create an object.\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createRootInstance(\n rootDataStoreId: string,\n runtime: IContainerRuntime,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n const context = runtime.createDetachedRootDataStore([this.type], rootDataStoreId);\n return this.createInstanceCore(context, initialState);\n }\n\n protected async createNonRootInstanceCore(\n containerRuntime: IContainerRuntimeBase,\n packagePath: Readonly<string[]>,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n const context = containerRuntime.createDetachedDataStore(packagePath);\n return this.createInstanceCore(context, initialState);\n }\n\n protected async createInstanceCore(\n context: IFluidDataStoreContextDetached,\n initialState?: I[\"InitialState\"],\n ): Promise<TObj> {\n const { instance, runtime } = await createDataObject(\n this.ctor,\n context,\n this.sharedObjectRegistry,\n this.optionalProviders,\n this.runtimeClass,\n false, // existing\n initialState);\n\n await context.attachRuntime(this, runtime);\n\n return instance;\n }\n}\n"]}
|