@fluidframework/aqueduct 0.59.2001 → 0.59.3000-66610

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/container-runtime-factories/baseContainerRuntimeFactory.js +1 -1
  2. package/dist/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
  3. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js +1 -1
  4. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  5. package/dist/container-services/containerServices.js +3 -3
  6. package/dist/container-services/containerServices.js.map +1 -1
  7. package/dist/data-object-factories/dataObjectFactory.d.ts.map +1 -1
  8. package/dist/data-object-factories/dataObjectFactory.js.map +1 -1
  9. package/dist/data-object-factories/pureDataObjectFactory.d.ts.map +1 -1
  10. package/dist/data-object-factories/pureDataObjectFactory.js +1 -1
  11. package/dist/data-object-factories/pureDataObjectFactory.js.map +1 -1
  12. package/dist/data-objects/dataObject.d.ts.map +1 -1
  13. package/dist/data-objects/dataObject.js +1 -1
  14. package/dist/data-objects/dataObject.js.map +1 -1
  15. package/dist/data-objects/pureDataObject.js +5 -5
  16. package/dist/data-objects/pureDataObject.js.map +1 -1
  17. package/dist/request-handlers/requestHandlers.js +2 -2
  18. package/dist/request-handlers/requestHandlers.js.map +1 -1
  19. package/dist/test/containerServices.spec.js +31 -31
  20. package/dist/test/containerServices.spec.js.map +1 -1
  21. package/dist/test/defaultRoute.spec.js +9 -9
  22. package/dist/test/defaultRoute.spec.js.map +1 -1
  23. package/dist/test/tsconfig.tsbuildinfo +1 -4917
  24. package/lib/data-object-factories/dataObjectFactory.js.map +1 -1
  25. package/lib/data-object-factories/pureDataObjectFactory.js.map +1 -1
  26. package/lib/data-objects/dataObject.js.map +1 -1
  27. package/lib/data-objects/pureDataObject.js.map +1 -1
  28. package/lib/request-handlers/requestHandlers.js.map +1 -1
  29. package/package.json +18 -17
@@ -1 +1 @@
1
- {"version":3,"file":"dataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,SAAS,GACZ,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,OAAO,iBACT,SAAQ,qBAA8B;IAEtC,YACI,IAAY,EACZ,IAA8C,EAC9C,gBAA4C,EAAE,EAC9C,iBAAoE,EACpE,eAAoD,EACpD,iBAA+C,qBAAqB;QAEpE,MAAM,aAAa,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;QAEzC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,gBAAgB,CAAC,IAAI,CAAC,EAAE;YAC1E,sCAAsC;YACtC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;SACpD;QAED,0GAA0G;QAC1G,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,EAAE;YACpE,gCAAgC;YAChC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;SAC9C;QAED,KAAK,CACD,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,cAAc,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n DirectoryFactory,\n MapFactory,\n SharedDirectory,\n SharedMap,\n} from \"@fluidframework/map\";\nimport {\n NamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { FluidObjectSymbolProvider } from \"@fluidframework/synthesize\";\nimport { FluidDataStoreRuntime } from \"@fluidframework/datastore\";\n\nimport { DataObject, DataObjectTypes, IDataObjectProps } from \"../data-objects\";\nimport { PureDataObjectFactory } from \"./pureDataObjectFactory\";\n\n/**\n * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.\n * It facilitates DataObject's features (such as its shared directory) by\n * ensuring relevant shared objects etc are available to the factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n */\nexport class DataObjectFactory<TObj extends DataObject<I>, I extends DataObjectTypes = DataObjectTypes>\n extends PureDataObjectFactory<TObj, I>\n{\n constructor(\n type: string,\n ctor: new (props: IDataObjectProps<I>) => TObj,\n sharedObjects: readonly IChannelFactory[] = [],\n optionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n registryEntries?: NamedFluidDataStoreRegistryEntries,\n runtimeFactory: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n ) {\n const mergedObjects = [...sharedObjects];\n\n if (!sharedObjects.find((factory) => factory.type === DirectoryFactory.Type)) {\n // User did not register for directory\n mergedObjects.push(SharedDirectory.getFactory());\n }\n\n // TODO: Remove SharedMap factory when compatibility with SharedMap DataObject is no longer needed in 0.10\n if (!sharedObjects.find((factory) => factory.type === MapFactory.Type)) {\n // User did not register for map\n mergedObjects.push(SharedMap.getFactory());\n }\n\n super(\n type,\n ctor,\n mergedObjects,\n optionalProviders,\n registryEntries,\n runtimeFactory,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"dataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,SAAS,GACZ,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,OAAO,iBACT,SAAQ,qBAA8B;IACtC,YACI,IAAY,EACZ,IAA8C,EAC9C,gBAA4C,EAAE,EAC9C,iBAAoE,EACpE,eAAoD,EACpD,iBAA+C,qBAAqB;QAEpE,MAAM,aAAa,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;QAEzC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,gBAAgB,CAAC,IAAI,CAAC,EAAE;YAC1E,sCAAsC;YACtC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;SACpD;QAED,0GAA0G;QAC1G,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,EAAE;YACpE,gCAAgC;YAChC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;SAC9C;QAED,KAAK,CACD,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,cAAc,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n DirectoryFactory,\n MapFactory,\n SharedDirectory,\n SharedMap,\n} from \"@fluidframework/map\";\nimport {\n NamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { FluidObjectSymbolProvider } from \"@fluidframework/synthesize\";\nimport { FluidDataStoreRuntime } from \"@fluidframework/datastore\";\n\nimport { DataObject, DataObjectTypes, IDataObjectProps } from \"../data-objects\";\nimport { PureDataObjectFactory } from \"./pureDataObjectFactory\";\n\n/**\n * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.\n * It facilitates DataObject's features (such as its shared directory) by\n * ensuring relevant shared objects etc are available to the factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n */\nexport class DataObjectFactory<TObj extends DataObject<I>, I extends DataObjectTypes = DataObjectTypes>\n extends PureDataObjectFactory<TObj, I> {\n constructor(\n type: string,\n ctor: new (props: IDataObjectProps<I>) => TObj,\n sharedObjects: readonly IChannelFactory[] = [],\n optionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n registryEntries?: NamedFluidDataStoreRegistryEntries,\n runtimeFactory: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n ) {\n const mergedObjects = [...sharedObjects];\n\n if (!sharedObjects.find((factory) => factory.type === DirectoryFactory.Type)) {\n // User did not register for directory\n mergedObjects.push(SharedDirectory.getFactory());\n }\n\n // TODO: Remove SharedMap factory when compatibility with SharedMap DataObject is no longer needed in 0.10\n if (!sharedObjects.find((factory) => factory.type === MapFactory.Type)) {\n // User did not register for map\n mergedObjects.push(SharedMap.getFactory());\n }\n\n super(\n type,\n ctor,\n mergedObjects,\n optionalProviders,\n registryEntries,\n runtimeFactory,\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,qBAAqB,EAErB,mBAAmB,GACrB,MAAM,2BAA2B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAa3E,OAAO,EAEH,mBAAmB,GAEtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAEH,cAAc,GAEjB,MAAM,iBAAiB,CAAC;AAUzB;;;EAGE;AACF,KAAK,UAAU,gBAAgB,CAC3B,I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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","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"]}
1
+ {"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,qBAAqB,EAErB,mBAAmB,GACrB,MAAM,2BAA2B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAa3E,OAAO,EAEH,mBAAmB,GAEtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAEH,cAAc,GAEjB,MAAM,iBAAiB,CAAC;AAUzB;;;EAGE;AACF,KAAK,UAAU,gBAAgB,CAC3B,IAA8C,EAC9C,OAA+B,EAC/B,oBAA2C,EAC3C,iBAAoE,EACpE,eAA6C,EAC7C,QAAiB,EACjB,SAA6B;IAC7B,OAAO;IACP,IAAI,YAAY,GAAG,eAAe,CAAC;IAEnC,mBAAmB;IACnB,YAAY,GAAG,mBAAmB,CAC9B,KAAK,EAAE,OAAiB,EAAE,UAAiC,EAAE,EAAE,CAC3D,CAAC,MAAM,cAAc,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,uGAA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;;;;;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","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 // 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 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 +1 @@
1
- {"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAoB,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACj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AoG;YACpG,IAAI,CAAC,YAAY,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAqB,CAAC;YAE5F,oGAAoG;YACpG,gGAAgG;YAChG,qGAAqG;YACrG,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,EAAE;gBACvD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;oBACrB,QAAQ,EAAE,SAAS;oBACnB,SAAS,EAAE,eAAe;oBAC1B,OAAO,EAAE,6EAA6E;iBACzF,CAAC,CAAC;aACN;SACJ;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAES,2BAA2B,CAAC,IAAY;QAC9C,OAAO,GAAG,IAAI,6CAA6C,CAAC;IAChE,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IRequest,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { ISharedDirectory, MapFactory, SharedDirectory } from \"@fluidframework/map\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\nimport { PureDataObject } from \"./pureDataObject\";\nimport { DataObjectTypes } from \"./types\";\n\n/**\n * DataObject is a base data store that is primed with a root directory. It\n * ensures that it is created and ready before you can access it.\n *\n * Having a single root directory allows for easier development. Instead of creating\n * and registering channels with the runtime any new DDS that is set on the root\n * will automatically be registered.\n *\n * @typeParam I - The optional input types used to strongly type the data object\n */\nexport abstract class DataObject<I extends DataObjectTypes = DataObjectTypes> extends PureDataObject<I>\n{\n private internalRoot: ISharedDirectory | undefined;\n private readonly rootDirectoryId = \"root\";\n\n public async request(request: IRequest): Promise<IResponse> {\n const requestParser = RequestParser.create(request);\n const itemId = requestParser.pathParts[0];\n if (itemId === \"bigBlobs\") {\n const value = this.root.get<string>(requestParser.pathParts.join(\"/\"));\n if (value === undefined) {\n return create404Response(requestParser);\n }\n return { mimeType: \"fluid/object\", status: 200, value };\n } else {\n return super.request(requestParser);\n }\n }\n\n /**\n * The root directory will either be ready or will return an error. If an error is thrown\n * the root has not been correctly created/set.\n */\n protected get root(): ISharedDirectory {\n if (!this.internalRoot) {\n throw new Error(this.getUninitializedErrorString(`root`));\n }\n\n return this.internalRoot;\n }\n\n /**\n * Initializes internal objects and calls initialization overrides.\n * Caller is responsible for ensuring this is only invoked once.\n */\n public async initializeInternal(existing: boolean): Promise<void> {\n if (!existing) {\n // Create a root directory and register it before calling initializingFirstTime\n this.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);\n this.internalRoot.bindToContext();\n } else {\n // data store has a root directory so we just need to set it before calling initializingFromExisting\n this.internalRoot = await this.runtime.getChannel(this.rootDirectoryId) as ISharedDirectory;\n\n // This will actually be an ISharedMap if the channel was previously created by the older version of\n // DataObject which used a SharedMap. Since SharedMap and SharedDirectory are compatible unless\n // SharedDirectory-only commands are used on SharedMap, this will mostly just work for compatibility.\n if (this.internalRoot.attributes.type === MapFactory.Type) {\n this.runtime.logger.send({\n category: \"generic\",\n eventName: \"MapDataObject\",\n message: \"Legacy document, SharedMap is masquerading as SharedDirectory in DataObject\",\n });\n }\n }\n\n await super.initializeInternal(existing);\n }\n\n protected getUninitializedErrorString(item: string) {\n return `${item} must be initialized before being accessed.`;\n }\n}\n"]}
1
+ {"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAoB,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;;GASG;AACH,MAAM,OAAgB,UAAwD,SAAQ,cAAiB;IAAvG;;QAEqB,oBAAe,G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AAgG;YAChG,qGAAqG;YACrG,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,EAAE;gBACvD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;oBACrB,QAAQ,EAAE,SAAS;oBACnB,SAAS,EAAE,eAAe;oBAC1B,OAAO,EAAE,6EAA6E;iBACzF,CAAC,CAAC;aACN;SACJ;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAES,2BAA2B,CAAC,IAAY;QAC9C,OAAO,GAAG,IAAI,6CAA6C,CAAC;IAChE,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IRequest,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { ISharedDirectory, MapFactory, SharedDirectory } from \"@fluidframework/map\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\nimport { PureDataObject } from \"./pureDataObject\";\nimport { DataObjectTypes } from \"./types\";\n\n/**\n * DataObject is a base data store that is primed with a root directory. It\n * ensures that it is created and ready before you can access it.\n *\n * Having a single root directory allows for easier development. Instead of creating\n * and registering channels with the runtime any new DDS that is set on the root\n * will automatically be registered.\n *\n * @typeParam I - The optional input types used to strongly type the data object\n */\nexport abstract class DataObject<I extends DataObjectTypes = DataObjectTypes> extends PureDataObject<I> {\n private internalRoot: ISharedDirectory | undefined;\n private readonly rootDirectoryId = \"root\";\n\n public async request(request: IRequest): Promise<IResponse> {\n const requestParser = RequestParser.create(request);\n const itemId = requestParser.pathParts[0];\n if (itemId === \"bigBlobs\") {\n const value = this.root.get<string>(requestParser.pathParts.join(\"/\"));\n if (value === undefined) {\n return create404Response(requestParser);\n }\n return { mimeType: \"fluid/object\", status: 200, value };\n } else {\n return super.request(requestParser);\n }\n }\n\n /**\n * The root directory will either be ready or will return an error. If an error is thrown\n * the root has not been correctly created/set.\n */\n protected get root(): ISharedDirectory {\n if (!this.internalRoot) {\n throw new Error(this.getUninitializedErrorString(`root`));\n }\n\n return this.internalRoot;\n }\n\n /**\n * Initializes internal objects and calls initialization overrides.\n * Caller is responsible for ensuring this is only invoked once.\n */\n public async initializeInternal(existing: boolean): Promise<void> {\n if (!existing) {\n // Create a root directory and register it before calling initializingFirstTime\n this.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);\n this.internalRoot.bindToContext();\n } else {\n // data store has a root directory so we just need to set it before calling initializingFromExisting\n this.internalRoot = await this.runtime.getChannel(this.rootDirectoryId) as ISharedDirectory;\n\n // This will actually be an ISharedMap if the channel was previously created by the older version of\n // DataObject which used a SharedMap. Since SharedMap and SharedDirectory are compatible unless\n // SharedDirectory-only commands are used on SharedMap, this will mostly just work for compatibility.\n if (this.internalRoot.attributes.type === MapFactory.Type) {\n this.runtime.logger.send({\n category: \"generic\",\n eventName: \"MapDataObject\",\n message: \"Legacy document, SharedMap is masquerading as SharedDirectory in DataObject\",\n });\n }\n }\n\n await super.initializeInternal(existing);\n }\n\n protected getUninitializedErrorString(item: string) {\n return `${item} must be initialized before being accessed.`;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAUtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAGvE;;;;;;GAMG;AACH,MAAM,OAAgB,cAClB,SAAQ,cAAoC;IA+C5C,YAAmB,KAA0B;QACzC,KAAK,EAAE,CAA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CAAC,CAAC,sBAAsB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzG,MAAM,MAAM,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,YAAY,CAAC;QACzC,IAAI,MAAM,EAAE;YACR,+DAA+D;YAC/D,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC;SACvB;IACL,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,UAAU,CAAwB,EAAU;QACxD,OAAO,mBAAmB,CAAI,IAAI,oBAAoB,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACzG,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,KAAoB,CAAC;IAElD;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAAyB,IAAmB,CAAC;IAEnF;;;OAGG;IACO,KAAK,CAAC,wBAAwB,KAAoB,CAAC;IAE7D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAoB,CAAC;IAEnD;;OAEG;IACI,OAAO;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport {\n IFluidHandle,\n IFluidLoadable,\n IFluidRouter,\n IProvideFluidHandle,\n IRequest,\n IResponse,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { handleFromLegacyUri } from \"@fluidframework/request-handler\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { AsyncFluidObjectProvider } from \"@fluidframework/synthesize\";\nimport { serviceRoutePathRoot } from \"../container-services\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\nimport { DataObjectTypes, IDataObjectProps } from \"./types\";\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam I - The optional input types used to strongly type the data object\n */\nexport abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes>\n extends EventForwarder<I[\"Events\"] & IEvent>\n implements IFluidLoadable, IFluidRouter, IProvideFluidHandle {\n private readonly innerHandle: IFluidHandle<this>;\n private _disposed = false;\n\n /**\n * This is your FluidDataStoreRuntime object\n */\n protected readonly runtime: IFluidDataStoreRuntime;\n\n /**\n * This context is used to talk up to the ContainerRuntime\n */\n protected readonly context: IFluidDataStoreContext;\n\n /**\n * Providers are FluidObject keyed objects that provide back\n * a promise to the corresponding FluidObject or undefined.\n * Providers injected/provided by the Container and/or HostingApplication\n *\n * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n */\n protected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n protected initProps?: I[\"InitialState\"];\n\n protected initializeP: Promise<void> | undefined;\n\n public get disposed() { return this._disposed; }\n\n public get id() { return this.runtime.id; }\n public get IFluidRouter() { return this; }\n public get IFluidLoadable() { return this; }\n public get IFluidHandle() { return this.innerHandle; }\n\n /**\n * Handle to a data store\n */\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n\n public static async getDataObject(runtime: IFluidDataStoreRuntime) {\n const obj = (runtime as any)._dataObject as PureDataObject;\n assert(obj !== undefined, 0x0bc /* \"Runtime has no DataObject!\" */);\n await obj.finishInitialization(true);\n return obj;\n }\n\n public constructor(props: IDataObjectProps<I>) {\n super();\n this.runtime = props.runtime;\n this.context = props.context;\n this.providers = props.providers;\n this.initProps = props.initProps;\n\n assert((this.runtime as any)._dataObject === undefined, 0x0bd /* \"Object runtime already has DataObject!\" */);\n (this.runtime as any)._dataObject = this;\n\n // Create a FluidObjectHandle with empty string as `path`. This is because reaching this PureDataObject is the\n // same as reaching its routeContext (FluidDataStoreRuntime) so there is so the relative path to it from the\n // routeContext is empty.\n this.innerHandle = new FluidObjectHandle(this, \"\", this.runtime.objectsRoutingContext);\n\n // Container event handlers\n this.runtime.once(\"dispose\", () => {\n this._disposed = true;\n this.dispose();\n });\n }\n\n // #region IFluidRouter\n\n /**\n * Return this object if someone requests it directly\n * We will return this object in two scenarios:\n * 1. the request url is a \"/\"\n * 2. the request url is empty\n */\n public async request(req: IRequest): Promise<IResponse> {\n return defaultFluidObjectRequestHandler(this, req);\n }\n\n // #endregion IFluidRouter\n\n // #region IFluidLoadable\n\n // #endregion IFluidLoadable\n\n /**\n * Call this API to ensure PureDataObject is fully initialized\n * initialization happens on demand, only on as-needed bases.\n * In most cases you should allow factory/object to decide when to finish initialization.\n * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n * and need fully initialized object, then you can call this API to ensure object is fully initialized.\n */\n public async finishInitialization(existing: boolean): Promise<void> {\n if (this.initializeP !== undefined) {\n return this.initializeP;\n }\n this.initializeP = this.initializeInternal(existing);\n return this.initializeP;\n }\n\n /**\n * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n * generally not be done.\n *\n * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n * responsible for ensuring this is only invoked once.\n */\n public async initializeInternal(existing: boolean): Promise<void> {\n await this.preInitialize();\n if (existing) {\n assert(this.initProps === undefined,\n 0x0be /* \"Trying to initialize from existing while initProps is set!\" */);\n await this.initializingFromExisting();\n } else {\n await this.initializingFirstTime(\n this.context.createProps as I[\"InitialState\"] ?? this.initProps);\n }\n await this.hasInitialized();\n }\n\n /**\n * Retrieve Fluid object using the handle get\n *\n * @param key - key that object (handle/id) is stored with in the directory\n * @param directory - directory containing the object\n * @param getObjectFromDirectory - optional callback for fetching object from the directory, allows users to\n * define custom types/getters for object retrieval\n */\n public async getFluidObjectFromDirectory<T extends IFluidLoadable>(\n key: string,\n directory: IDirectory,\n getObjectFromDirectory?: (id: string, directory: IDirectory) => IFluidHandle | undefined):\n Promise<T | undefined> {\n const handleMaybe = getObjectFromDirectory ? getObjectFromDirectory(key, directory) : directory.get(key);\n const handle = handleMaybe?.IFluidHandle;\n if (handle) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return handle.get();\n }\n }\n\n /**\n * Gets the service at a given id.\n * @param id - service id\n */\n protected async getService<T extends FluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${serviceRoutePathRoot}/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Called every time the data store is initialized, before initializingFirstTime or\n * initializingFromExisting is called.\n */\n protected async preInitialize(): Promise<void> { }\n\n /**\n * Called the first time the data store is initialized (new creations with a new\n * data store runtime)\n *\n * @param props - Optional props to be passed in on create\n */\n protected async initializingFirstTime(props?: I[\"InitialState\"]): Promise<void> { }\n\n /**\n * Called every time but the first time the data store is initialized (creations\n * with an existing data store runtime)\n */\n protected async initializingFromExisting(): Promise<void> { }\n\n /**\n * Called every time the data store is initialized after create or existing.\n */\n protected async hasInitialized(): Promise<void> { }\n\n /**\n * Called when the host container closes and disposes itself\n */\n public dispose(): void {\n super.dispose();\n }\n}\n"]}
1
+ {"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAUtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAGvE;;;;;;GAMG;AACH,MAAM,OAAgB,cAClB,S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ACX,SAAqB,EACrB,sBAAwF;QAExF,MAAM,WAAW,GAAG,sBAAsB,CAAC,CAAC,CAAC,sBAAsB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzG,MAAM,MAAM,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,YAAY,CAAC;QACzC,IAAI,MAAM,EAAE;YACR,+DAA+D;YAC/D,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC;SACvB;IACL,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,UAAU,CAAwB,EAAU;QACxD,OAAO,mBAAmB,CAAI,IAAI,oBAAoB,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACzG,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,KAAoB,CAAC;IAElD;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAAyB,IAAmB,CAAC;IAEnF;;;OAGG;IACO,KAAK,CAAC,wBAAwB,KAAoB,CAAC;IAE7D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAoB,CAAC;IAEnD;;OAEG;IACI,OAAO;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport {\n IFluidHandle,\n IFluidLoadable,\n IFluidRouter,\n IProvideFluidHandle,\n IRequest,\n IResponse,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { handleFromLegacyUri } from \"@fluidframework/request-handler\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { AsyncFluidObjectProvider } from \"@fluidframework/synthesize\";\nimport { serviceRoutePathRoot } from \"../container-services\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\nimport { DataObjectTypes, IDataObjectProps } from \"./types\";\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam I - The optional input types used to strongly type the data object\n */\nexport abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes>\n extends EventForwarder<I[\"Events\"] & IEvent>\n implements IFluidLoadable, IFluidRouter, IProvideFluidHandle {\n private readonly innerHandle: IFluidHandle<this>;\n private _disposed = false;\n\n /**\n * This is your FluidDataStoreRuntime object\n */\n protected readonly runtime: IFluidDataStoreRuntime;\n\n /**\n * This context is used to talk up to the ContainerRuntime\n */\n protected readonly context: IFluidDataStoreContext;\n\n /**\n * Providers are FluidObject keyed objects that provide back\n * a promise to the corresponding FluidObject or undefined.\n * Providers injected/provided by the Container and/or HostingApplication\n *\n * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n */\n protected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n protected initProps?: I[\"InitialState\"];\n\n protected initializeP: Promise<void> | undefined;\n\n public get disposed() { return this._disposed; }\n\n public get id() { return this.runtime.id; }\n public get IFluidRouter() { return this; }\n public get IFluidLoadable() { return this; }\n public get IFluidHandle() { return this.innerHandle; }\n\n /**\n * Handle to a data store\n */\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n\n public static async getDataObject(runtime: IFluidDataStoreRuntime) {\n const obj = (runtime as any)._dataObject as PureDataObject;\n assert(obj !== undefined, 0x0bc /* \"Runtime has no DataObject!\" */);\n await obj.finishInitialization(true);\n return obj;\n }\n\n public constructor(props: IDataObjectProps<I>) {\n super();\n this.runtime = props.runtime;\n this.context = props.context;\n this.providers = props.providers;\n this.initProps = props.initProps;\n\n assert((this.runtime as any)._dataObject === undefined, 0x0bd /* \"Object runtime already has DataObject!\" */);\n (this.runtime as any)._dataObject = this;\n\n // Create a FluidObjectHandle with empty string as `path`. This is because reaching this PureDataObject is the\n // same as reaching its routeContext (FluidDataStoreRuntime) so there is so the relative path to it from the\n // routeContext is empty.\n this.innerHandle = new FluidObjectHandle(this, \"\", this.runtime.objectsRoutingContext);\n\n // Container event handlers\n this.runtime.once(\"dispose\", () => {\n this._disposed = true;\n this.dispose();\n });\n }\n\n // #region IFluidRouter\n\n /**\n * Return this object if someone requests it directly\n * We will return this object in two scenarios:\n * 1. the request url is a \"/\"\n * 2. the request url is empty\n */\n public async request(req: IRequest): Promise<IResponse> {\n return defaultFluidObjectRequestHandler(this, req);\n }\n\n // #endregion IFluidRouter\n\n // #region IFluidLoadable\n\n // #endregion IFluidLoadable\n\n /**\n * Call this API to ensure PureDataObject is fully initialized\n * initialization happens on demand, only on as-needed bases.\n * In most cases you should allow factory/object to decide when to finish initialization.\n * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n * and need fully initialized object, then you can call this API to ensure object is fully initialized.\n */\n public async finishInitialization(existing: boolean): Promise<void> {\n if (this.initializeP !== undefined) {\n return this.initializeP;\n }\n this.initializeP = this.initializeInternal(existing);\n return this.initializeP;\n }\n\n /**\n * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n * generally not be done.\n *\n * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n * responsible for ensuring this is only invoked once.\n */\n public async initializeInternal(existing: boolean): Promise<void> {\n await this.preInitialize();\n if (existing) {\n assert(this.initProps === undefined,\n 0x0be /* \"Trying to initialize from existing while initProps is set!\" */);\n await this.initializingFromExisting();\n } else {\n await this.initializingFirstTime(\n this.context.createProps as I[\"InitialState\"] ?? this.initProps);\n }\n await this.hasInitialized();\n }\n\n /**\n * Retrieve Fluid object using the handle get\n *\n * @param key - key that object (handle/id) is stored with in the directory\n * @param directory - directory containing the object\n * @param getObjectFromDirectory - optional callback for fetching object from the directory, allows users to\n * define custom types/getters for object retrieval\n */\n public async getFluidObjectFromDirectory<T extends IFluidLoadable>(\n key: string,\n directory: IDirectory,\n getObjectFromDirectory?: (id: string, directory: IDirectory) => IFluidHandle | undefined):\n Promise<T | undefined> {\n const handleMaybe = getObjectFromDirectory ? getObjectFromDirectory(key, directory) : directory.get(key);\n const handle = handleMaybe?.IFluidHandle;\n if (handle) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return handle.get();\n }\n }\n\n /**\n * Gets the service at a given id.\n * @param id - service id\n */\n protected async getService<T extends FluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${serviceRoutePathRoot}/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Called every time the data store is initialized, before initializingFirstTime or\n * initializingFromExisting is called.\n */\n protected async preInitialize(): Promise<void> { }\n\n /**\n * Called the first time the data store is initialized (new creations with a new\n * data store runtime)\n *\n * @param props - Optional props to be passed in on create\n */\n protected async initializingFirstTime(props?: I[\"InitialState\"]): Promise<void> { }\n\n /**\n * Called every time but the first time the data store is initialized (creations\n * with an existing data store runtime)\n */\n protected async initializingFromExisting(): Promise<void> { }\n\n /**\n * Called every time the data store is initialized after create or existing.\n */\n protected async hasInitialized(): Promise<void> { }\n\n /**\n * Called when the host container closes and disposes itself\n */\n public dispose(): void {\n super.dispose();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../src/request-handlers/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAyB,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACpC,CAAC,kBAA4C,EAAE,QAAiC,EAAE,EAAE;IAChF,MAAM,aAAa,GAAG,0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AE,OAAO,CAAC,OAAO;aAAE,CAAC,CAAC;SACnC;QACD,OAAO,SAAS,CAAC,CAAC,kBAAkB;IACxC,CAAC,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAwB,EAAE,OAAiB;IACxF,IAAI,OAAO,CAAC,GAAG,KAAK,EAAE,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC3E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;KACxE;SAAM;QACH,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;KACrC;AACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { FluidObject, IRequest, IRequestHeader, IResponse } from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidMountableViewClass } from \"@fluidframework/view-interfaces\";\nimport { RuntimeRequestHandler, buildRuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\n\n/**\n * A mountable view is only required if the view needs to be mounted across a bundle boundary. Mounting across\n * bundle boundaries breaks some frameworks, so the mountable view is used to ensure the mounting is done within\n * the same bundle as the view. For example, React hooks don't work if mounted across bundles since there will\n * be two React instances, breaking the Rules of Hooks. When cross-bundle mounting isn't required, the mountable\n * view isn't necessary.\n *\n * When a request is received with a mountableView: true header, this request handler will reissue the request\n * without the header, and respond with a mountable view of the given class using the response.\n * @param MountableViewClass - The type of mountable view to use when responding\n */\nexport const mountableViewRequestHandler =\n (MountableViewClass: IFluidMountableViewClass, handlers: RuntimeRequestHandler[]) => {\n const nestedHandler = buildRuntimeRequestHandler(...handlers);\n return async (request: RequestParser, runtime: IContainerRuntime) => {\n const mountableView = request.headers?.mountableView === true;\n let newRequest: IRequest = request;\n if (mountableView) {\n // Reissue the request without the mountableView header.\n // We'll repack whatever the response is if we can.\n const headers: IRequestHeader = { ...request.headers };\n delete (headers as any).mountableView;\n newRequest = {\n url: request.url,\n headers,\n };\n }\n const response = await nestedHandler(newRequest, runtime);\n\n if (mountableView && response.status === 200 && MountableViewClass.canMount(response.value)) {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: new MountableViewClass(response.value),\n };\n }\n return response;\n };\n };\n\n/**\n * Pipe through container request into internal request.\n * If request is empty and default url is provided, redirect request to such default url.\n * @param defaultRootId - optional default root data store ID to pass request in case request is empty.\n */\nexport const defaultRouteRequestHandler = (defaultRootId: string) => {\n return async (request: IRequest, runtime: IContainerRuntime) => {\n const parser = RequestParser.create(request);\n if (parser.pathParts.length === 0) {\n return runtime.IFluidHandleContext.resolveHandle({\n url: `/${defaultRootId}${parser.query}`,\n headers: request.headers });\n }\n return undefined; // continue search\n };\n};\n\n/**\n * Default request handler for a Fluid object that returns the object itself if:\n * 1. the request url is empty\n * 2. the request url is \"/\"\n * 3. the request url starts with \"/\" and is followed by a query param, such as /?key=value\n * Returns a 404 error for any other url.\n */\nexport function defaultFluidObjectRequestHandler(fluidObject: FluidObject, request: IRequest): IResponse {\n if (request.url === \"\" || request.url === \"/\" || request.url.startsWith(\"/?\")) {\n return { mimeType: \"fluid/object\", status: 200, value: fluidObject };\n } else {\n return create404Response(request);\n }\n}\n"]}
1
+ {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../src/request-handlers/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAyB,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACpC,CAAC,kBAA4C,EAAE,QA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a,GAAG,MAAM,CAAC,KAAK,EAAE;gBACvC,OAAO,EAAE,OAAO,CAAC,OAAO;aAAE,CAAC,CAAC;SACnC;QACD,OAAO,SAAS,CAAC,CAAC,kBAAkB;IACxC,CAAC,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAwB,EAAE,OAAiB;IACxF,IAAI,OAAO,CAAC,GAAG,KAAK,EAAE,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC3E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;KACxE;SAAM;QACH,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;KACrC;AACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { FluidObject, IRequest, IRequestHeader, IResponse } from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidMountableViewClass } from \"@fluidframework/view-interfaces\";\nimport { RuntimeRequestHandler, buildRuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\n\n/**\n * A mountable view is only required if the view needs to be mounted across a bundle boundary. Mounting across\n * bundle boundaries breaks some frameworks, so the mountable view is used to ensure the mounting is done within\n * the same bundle as the view. For example, React hooks don't work if mounted across bundles since there will\n * be two React instances, breaking the Rules of Hooks. When cross-bundle mounting isn't required, the mountable\n * view isn't necessary.\n *\n * When a request is received with a mountableView: true header, this request handler will reissue the request\n * without the header, and respond with a mountable view of the given class using the response.\n * @param MountableViewClass - The type of mountable view to use when responding\n */\nexport const mountableViewRequestHandler =\n (MountableViewClass: IFluidMountableViewClass, handlers: RuntimeRequestHandler[]) => {\n const nestedHandler = buildRuntimeRequestHandler(...handlers);\n return async (request: RequestParser, runtime: IContainerRuntime) => {\n const mountableView = request.headers?.mountableView === true;\n let newRequest: IRequest = request;\n if (mountableView) {\n // Reissue the request without the mountableView header.\n // We'll repack whatever the response is if we can.\n const headers: IRequestHeader = { ...request.headers };\n delete (headers as any).mountableView;\n newRequest = {\n url: request.url,\n headers,\n };\n }\n const response = await nestedHandler(newRequest, runtime);\n\n if (mountableView && response.status === 200 && MountableViewClass.canMount(response.value)) {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: new MountableViewClass(response.value),\n };\n }\n return response;\n };\n };\n\n/**\n * Pipe through container request into internal request.\n * If request is empty and default url is provided, redirect request to such default url.\n * @param defaultRootId - optional default root data store ID to pass request in case request is empty.\n */\nexport const defaultRouteRequestHandler = (defaultRootId: string) => {\n return async (request: IRequest, runtime: IContainerRuntime) => {\n const parser = RequestParser.create(request);\n if (parser.pathParts.length === 0) {\n return runtime.IFluidHandleContext.resolveHandle({\n url: `/${defaultRootId}${parser.query}`,\n headers: request.headers });\n }\n return undefined; // continue search\n };\n};\n\n/**\n * Default request handler for a Fluid object that returns the object itself if:\n * 1. the request url is empty\n * 2. the request url is \"/\"\n * 3. the request url starts with \"/\" and is followed by a query param, such as /?key=value\n * Returns a 404 error for any other url.\n */\nexport function defaultFluidObjectRequestHandler(fluidObject: FluidObject, request: IRequest): IResponse {\n if (request.url === \"\" || request.url === \"/\" || request.url.startsWith(\"/?\")) {\n return { mimeType: \"fluid/object\", status: 200, value: fluidObject };\n } else {\n return create404Response(request);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/aqueduct",
3
- "version": "0.59.2001",
3
+ "version": "0.59.3000-66610",
4
4
  "description": "A set of implementations for Fluid Framework interfaces.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -66,25 +66,26 @@
66
66
  "@fluidframework/common-definitions": "^0.20.1",
67
67
  "@fluidframework/common-utils": "^0.32.1",
68
68
  "@fluidframework/container-definitions": "^0.48.1000",
69
- "@fluidframework/container-loader": "^0.59.2001",
70
- "@fluidframework/container-runtime": "^0.59.2001",
71
- "@fluidframework/container-runtime-definitions": "^0.59.2001",
69
+ "@fluidframework/container-loader": "0.59.3000-66610",
70
+ "@fluidframework/container-runtime": "0.59.3000-66610",
71
+ "@fluidframework/container-runtime-definitions": "0.59.3000-66610",
72
72
  "@fluidframework/core-interfaces": "^0.43.1000",
73
- "@fluidframework/datastore": "^0.59.2001",
74
- "@fluidframework/datastore-definitions": "^0.59.2001",
75
- "@fluidframework/map": "^0.59.2001",
76
- "@fluidframework/request-handler": "^0.59.2001",
77
- "@fluidframework/runtime-definitions": "^0.59.2001",
78
- "@fluidframework/runtime-utils": "^0.59.2001",
79
- "@fluidframework/synthesize": "^0.59.2001",
80
- "@fluidframework/view-interfaces": "^0.59.2001",
73
+ "@fluidframework/datastore": "0.59.3000-66610",
74
+ "@fluidframework/datastore-definitions": "0.59.3000-66610",
75
+ "@fluidframework/map": "0.59.3000-66610",
76
+ "@fluidframework/request-handler": "0.59.3000-66610",
77
+ "@fluidframework/runtime-definitions": "0.59.3000-66610",
78
+ "@fluidframework/runtime-utils": "0.59.3000-66610",
79
+ "@fluidframework/synthesize": "0.59.3000-66610",
80
+ "@fluidframework/view-interfaces": "0.59.3000-66610",
81
81
  "uuid": "^8.3.1"
82
82
  },
83
83
  "devDependencies": {
84
- "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@0.59.1000",
84
+ "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@0.59.2000",
85
85
  "@fluidframework/build-common": "^0.23.0",
86
- "@fluidframework/eslint-config-fluid": "^0.28.1000",
87
- "@fluidframework/mocha-test-setup": "^0.59.2001",
86
+ "@fluidframework/build-tools": "^0.2.66048",
87
+ "@fluidframework/eslint-config-fluid": "^0.28.2000-0",
88
+ "@fluidframework/mocha-test-setup": "0.59.3000-66610",
88
89
  "@microsoft/api-extractor": "^7.22.2",
89
90
  "@rushstack/eslint-config": "^2.5.1",
90
91
  "@types/mocha": "^8.2.2",
@@ -107,12 +108,12 @@
107
108
  "mocha": "^8.4.0",
108
109
  "nyc": "^15.0.0",
109
110
  "rimraf": "^2.6.2",
110
- "typescript": "~4.1.3",
111
+ "typescript": "~4.5.5",
111
112
  "typescript-formatter": "7.1.0"
112
113
  },
113
114
  "module:es5": "es5/index.js",
114
115
  "typeValidation": {
115
- "version": "0.59.2000",
116
+ "version": "0.59.3000",
116
117
  "broken": {}
117
118
  }
118
119
  }