@fluidframework/test-utils 2.22.1 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/TestSummaryUtils.d.ts +2 -2
- package/dist/TestSummaryUtils.d.ts.map +1 -1
- package/dist/TestSummaryUtils.js +17 -17
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/containerRuntimeFactories.d.ts +80 -0
- package/dist/containerRuntimeFactories.d.ts.map +1 -0
- package/dist/containerRuntimeFactories.js +94 -0
- package/dist/containerRuntimeFactories.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/localCodeLoader.d.ts.map +1 -1
- package/dist/localCodeLoader.js +6 -4
- package/dist/localCodeLoader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +42 -10
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +9 -7
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/dist/testFluidObject.d.ts +1 -0
- package/dist/testFluidObject.d.ts.map +1 -1
- package/dist/testFluidObject.js +5 -4
- package/dist/testFluidObject.js.map +1 -1
- package/lib/TestSummaryUtils.d.ts +2 -2
- package/lib/TestSummaryUtils.d.ts.map +1 -1
- package/lib/TestSummaryUtils.js +8 -8
- package/lib/TestSummaryUtils.js.map +1 -1
- package/lib/containerRuntimeFactories.d.ts +80 -0
- package/lib/containerRuntimeFactories.d.ts.map +1 -0
- package/lib/containerRuntimeFactories.js +92 -0
- package/lib/containerRuntimeFactories.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/localCodeLoader.d.ts.map +1 -1
- package/lib/localCodeLoader.js +3 -1
- package/lib/localCodeLoader.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +42 -10
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js +9 -7
- package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/lib/testFluidObject.d.ts +1 -0
- package/lib/testFluidObject.d.ts.map +1 -1
- package/lib/testFluidObject.js +5 -4
- package/lib/testFluidObject.js.map +1 -1
- package/package.json +23 -24
- package/src/TestSummaryUtils.ts +9 -6
- package/src/containerRuntimeFactories.ts +183 -0
- package/src/index.ts +5 -1
- package/src/localCodeLoader.ts +4 -1
- package/src/packageVersion.ts +1 -1
- package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +57 -17
- package/src/testFluidObject.ts +8 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localCodeLoader.js","sourceRoot":"","sources":["../src/localCodeLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"localCodeLoader.js","sourceRoot":"","sources":["../src/localCodeLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAe5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAEhF,gDAAgD;AAChD,OAAO,EAAE,2CAA2C,EAAE,MAAM,gCAAgC,CAAC;AAkB7F;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAG3B,YACC,cAA8D,EAC9D,cAAyC;QAJzB,sBAAiB,GAAG,IAAI,GAAG,EAAmC,CAAC;QAM/E,KAAK,MAAM,KAA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AAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,MAAyB;QAC1C,iFAAiF;QACjF,8EAA8E;QAC9E,qGAAqG;QACrG,MAAM,KAAK,GACV,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;YACjC,CAAC,CAAC,MAAM,CAAC,OAAO;YAChB,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAEvD,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACrD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport assert from \"assert\";\n\nimport {\n\tICodeDetailsLoader,\n\tIFluidCodeDetails,\n\tIFluidModule,\n\tIFluidModuleWithDetails,\n\tIProvideFluidCodeDetailsComparer,\n\tIProvideRuntimeFactory,\n} from \"@fluidframework/container-definitions/internal\";\nimport { IContainerRuntimeOptions } from \"@fluidframework/container-runtime/internal\";\nimport {\n\tIProvideFluidDataStoreFactory,\n\tIProvideFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { createDataStoreFactory } from \"@fluidframework/runtime-utils/internal\";\n\n// eslint-disable-next-line import/no-deprecated\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"./containerRuntimeFactories.js\";\n\n/**\n * @internal\n */\nexport type SupportedExportInterfaces = Partial<\n\tIProvideRuntimeFactory &\n\t\tIProvideFluidDataStoreFactory &\n\t\tIProvideFluidDataStoreRegistry &\n\t\tIProvideFluidCodeDetailsComparer\n>;\n\n// Represents the entry point for a Fluid container.\n/**\n * @internal\n */\nexport type fluidEntryPoint = SupportedExportInterfaces | IFluidModule;\n\n/**\n * A simple code loader that caches a mapping of package name to a Fluid entry point.\n * On load, it retrieves the entry point matching the package name in the given code details.\n * @internal\n */\nexport class LocalCodeLoader implements ICodeDetailsLoader {\n\tprivate readonly fluidPackageCache = new Map<string, IFluidModuleWithDetails>();\n\n\tconstructor(\n\t\tpackageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>,\n\t\truntimeOptions?: IContainerRuntimeOptions,\n\t) {\n\t\tfor (const entry of packageEntries) {\n\t\t\t// Store the entry point against a unique id in the fluidPackageCache.\n\t\t\t// For code details containing a package name, use the package name as the id.\n\t\t\t// For code details containing a Fluid package, create a unique id from the package name and version.\n\t\t\tconst source = entry[0];\n\t\t\tconst pkgId =\n\t\t\t\ttypeof source.package === \"string\"\n\t\t\t\t\t? source.package\n\t\t\t\t\t: `${source.package.name}@${source.package.version}`;\n\t\t\tlet fluidModule = entry[1] as IFluidModule;\n\t\t\tif (fluidModule?.fluidExport === undefined) {\n\t\t\t\tconst maybeExport = fluidModule as SupportedExportInterfaces;\n\n\t\t\t\tif (maybeExport.IRuntimeFactory !== undefined) {\n\t\t\t\t\tfluidModule = { fluidExport: maybeExport };\n\t\t\t\t} else {\n\t\t\t\t\tassert(maybeExport.IFluidDataStoreFactory !== undefined);\n\t\t\t\t\tconst defaultFactory = createDataStoreFactory(\n\t\t\t\t\t\t\"default\",\n\t\t\t\t\t\tmaybeExport.IFluidDataStoreFactory,\n\t\t\t\t\t);\n\t\t\t\t\tfluidModule = {\n\t\t\t\t\t\tfluidExport: {\n\t\t\t\t\t\t\t...maybeExport,\n\t\t\t\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\t\t\t\tIRuntimeFactory: new ContainerRuntimeFactoryWithDefaultDataStore({\n\t\t\t\t\t\t\t\tdefaultFactory,\n\t\t\t\t\t\t\t\tregistryEntries: [[defaultFactory.type, Promise.resolve(defaultFactory)]],\n\t\t\t\t\t\t\t\truntimeOptions,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst runtimeFactory = {\n\t\t\t\tmodule: fluidModule,\n\t\t\t\tdetails: source,\n\t\t\t};\n\n\t\t\tthis.fluidPackageCache.set(pkgId, runtimeFactory);\n\t\t}\n\t}\n\n\t/**\n\t * It finds the entry point for the package name in the given source and return it\n\t * as a Fluid module.\n\t * @param source - Details of where to find chaincode\n\t */\n\tpublic async load(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails> {\n\t\t// Get the entry point for from the fluidPackageCache for the given code details.\n\t\t// For code details containing a package name, use the package name as the id.\n\t\t// For code details containing a Fluid package, create a unique id from the package name and version.\n\t\tconst pkdId =\n\t\t\ttypeof source.package === \"string\"\n\t\t\t\t? source.package\n\t\t\t\t: `${source.package.name}@${source.package.version}`;\n\n\t\tconst entryPoint = this.fluidPackageCache.get(pkdId);\n\t\tif (entryPoint === undefined) {\n\t\t\tthrow new Error(`Cannot find package ${pkdId}`);\n\t\t}\n\t\treturn entryPoint;\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/test-utils";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.23.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CAAC;AACpD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/test-utils\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CAAC;AACpD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/test-utils\";\nexport const pkgVersion = \"2.23.0\";\n"]}
|
|
@@ -2,22 +2,54 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
|
|
6
6
|
import { IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
|
|
7
7
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
|
|
8
8
|
import { FluidObject } from "@fluidframework/core-interfaces";
|
|
9
9
|
import { RuntimeRequestHandler } from "@fluidframework/request-handler/internal";
|
|
10
10
|
import { IFluidDataStoreFactory, NamedFluidDataStoreRegistryEntries } from "@fluidframework/runtime-definitions/internal";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* {@link ContainerRuntimeFactoryWithDefaultDataStoreConstructor} input properties.
|
|
13
|
+
*
|
|
13
14
|
* @internal
|
|
14
15
|
*/
|
|
15
|
-
export
|
|
16
|
-
defaultFactory: IFluidDataStoreFactory;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
export interface ContainerRuntimeFactoryWithDefaultDataStoreProps {
|
|
17
|
+
readonly defaultFactory: IFluidDataStoreFactory;
|
|
18
|
+
/**
|
|
19
|
+
* The data store registry for containers produced.
|
|
20
|
+
*/
|
|
21
|
+
readonly registryEntries: NamedFluidDataStoreRegistryEntries;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Do not use. This strictly exists for backwards compatibility.
|
|
24
|
+
*/
|
|
25
|
+
readonly dependencyContainer?: never;
|
|
26
|
+
/**
|
|
27
|
+
* Request handlers for containers produced.
|
|
28
|
+
* @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
29
|
+
*/
|
|
30
|
+
readonly requestHandlers?: RuntimeRequestHandler[];
|
|
31
|
+
/**
|
|
32
|
+
* The runtime options passed to the IContainerRuntime when instantiating it
|
|
33
|
+
*/
|
|
34
|
+
readonly runtimeOptions?: IContainerRuntimeOptions;
|
|
35
|
+
/**
|
|
36
|
+
* Function that will initialize the entryPoint of the IContainerRuntime instances
|
|
37
|
+
* created with this factory
|
|
38
|
+
*/
|
|
39
|
+
readonly provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* {@link @fluidframework/container-definitions#IRuntimeFactory} construct signature.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export type ContainerRuntimeFactoryWithDefaultDataStoreConstructor = new (props: ContainerRuntimeFactoryWithDefaultDataStoreProps) => IRuntimeFactory;
|
|
47
|
+
/**
|
|
48
|
+
* @remarks
|
|
49
|
+
* This function is purely needed for back-compat as the constructor argument structure of
|
|
50
|
+
* `ContainerRuntimeFactoryWithDefaultDataStore` was changed.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export declare const createContainerRuntimeFactoryWithDefaultDataStore: (ctor: ContainerRuntimeFactoryWithDefaultDataStoreConstructor, ctorProps: ContainerRuntimeFactoryWithDefaultDataStoreProps) => IRuntimeFactory;
|
|
23
55
|
//# sourceMappingURL=testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.d.ts","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.d.ts","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EACN,sBAAsB,EACtB,kCAAkC,EAClC,MAAM,8CAA8C,CAAC;AAUtD;;;;GAIG;AACH,MAAM,WAAW,gDAAgD;IAChE,QAAQ,CAAC,cAAc,EAAE,sBAAsB,CAAC;IAChD;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,kCAAkC,CAAC;IAE7D;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,KAAK,CAAC;IAErC;;;OAGG;IAEH,QAAQ,CAAC,eAAe,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAEnD;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAEnD;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CAClF;AAED;;;;GAIG;AACH,MAAM,MAAM,sDAAsD,GAAG,KACpE,KAAK,EAAE,gDAAgD,KACnD,eAAe,CAAC;AAErB;;;;;;GAMG;AACH,eAAO,MAAM,iDAAiD,SACvD,sDAAsD,aACjD,gDAAgD,KACzD,eAuBF,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct/internal";
|
|
6
5
|
const getDefaultFluidObject = async (runtime) => {
|
|
7
6
|
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
8
7
|
if (entryPoint === undefined) {
|
|
@@ -11,18 +10,21 @@ const getDefaultFluidObject = async (runtime) => {
|
|
|
11
10
|
return entryPoint.get();
|
|
12
11
|
};
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* This function is purely needed for back-compat as the constructor argument structure of
|
|
15
|
+
* `ContainerRuntimeFactoryWithDefaultDataStore` was changed.
|
|
16
|
+
*
|
|
15
17
|
* @internal
|
|
16
18
|
*/
|
|
17
|
-
export const createContainerRuntimeFactoryWithDefaultDataStore = (
|
|
19
|
+
export const createContainerRuntimeFactoryWithDefaultDataStore = (ctor, ctorProps) => {
|
|
18
20
|
try {
|
|
19
|
-
return new
|
|
21
|
+
return new ctor(ctorProps);
|
|
20
22
|
}
|
|
21
23
|
catch (err) {
|
|
22
|
-
// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older ContainerRuntimeFactoryWithDefaultDataStore
|
|
23
|
-
const { defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions, provideEntryPoint, } =
|
|
24
|
+
// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older `ContainerRuntimeFactoryWithDefaultDataStore`s
|
|
25
|
+
const { defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions, provideEntryPoint, } = ctorProps;
|
|
24
26
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
25
|
-
return new
|
|
27
|
+
return new ctor(defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions, provideEntryPoint ?? getDefaultFluidObject);
|
|
26
28
|
}
|
|
27
29
|
};
|
|
28
30
|
//# sourceMappingURL=testContainerRuntimeFactoryWithDefaultDataStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,MAAM,qBAAqB,GAAG,KAAK,EAAE,OAA0B,EAAE,EAAE;IAClE,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;IAC1E,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC;AACzB,CAAC,CAAC;AA+CF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iDAAiD,GAAG,CAChE,IAA4D,EAC5D,SAA2D,EACzC,EAAE;IACpB,IAAI,CAAC;QACJ,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,sJAAsJ;QACtJ,MAAM,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,iBAAiB,GACjB,GAAG,SAAS,CAAC;QACd,+DAA+D;QAC/D,OAAO,IAAK,IAAY,CACvB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,iBAAiB,IAAI,qBAAqB,CAC1C,CAAC;IACH,CAAC;AACF,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport { IContainerRuntimeOptions } from \"@fluidframework/container-runtime/internal\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\n// eslint-disable-next-line import/no-deprecated\nimport { RuntimeRequestHandler } from \"@fluidframework/request-handler/internal\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nconst getDefaultFluidObject = async (runtime: IContainerRuntime) => {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(\"default\");\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(\"default dataStore must exist\");\n\t}\n\treturn entryPoint.get();\n};\n\n/**\n * {@link ContainerRuntimeFactoryWithDefaultDataStoreConstructor} input properties.\n *\n * @internal\n */\nexport interface ContainerRuntimeFactoryWithDefaultDataStoreProps {\n\treadonly defaultFactory: IFluidDataStoreFactory;\n\t/**\n\t * The data store registry for containers produced.\n\t */\n\treadonly registryEntries: NamedFluidDataStoreRegistryEntries;\n\n\t/**\n\t * @deprecated Do not use. This strictly exists for backwards compatibility.\n\t */\n\treadonly dependencyContainer?: never;\n\n\t/**\n\t * Request handlers for containers produced.\n\t * @deprecated Will be removed once Loader LTS version is \"2.0.0-internal.7.0.0\". Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\t// eslint-disable-next-line import/no-deprecated\n\treadonly requestHandlers?: RuntimeRequestHandler[];\n\n\t/**\n\t * The runtime options passed to the IContainerRuntime when instantiating it\n\t */\n\treadonly runtimeOptions?: IContainerRuntimeOptions;\n\n\t/**\n\t * Function that will initialize the entryPoint of the IContainerRuntime instances\n\t * created with this factory\n\t */\n\treadonly provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;\n}\n\n/**\n * {@link @fluidframework/container-definitions#IRuntimeFactory} construct signature.\n *\n * @internal\n */\nexport type ContainerRuntimeFactoryWithDefaultDataStoreConstructor = new (\n\tprops: ContainerRuntimeFactoryWithDefaultDataStoreProps,\n) => IRuntimeFactory;\n\n/**\n * @remarks\n * This function is purely needed for back-compat as the constructor argument structure of\n * `ContainerRuntimeFactoryWithDefaultDataStore` was changed.\n *\n * @internal\n */\nexport const createContainerRuntimeFactoryWithDefaultDataStore = (\n\tctor: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,\n\tctorProps: ContainerRuntimeFactoryWithDefaultDataStoreProps,\n): IRuntimeFactory => {\n\ttry {\n\t\treturn new ctor(ctorProps);\n\t} catch (err) {\n\t\t// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older `ContainerRuntimeFactoryWithDefaultDataStore`s\n\t\tconst {\n\t\t\tdefaultFactory,\n\t\t\tregistryEntries,\n\t\t\tdependencyContainer,\n\t\t\trequestHandlers,\n\t\t\truntimeOptions,\n\t\t\tprovideEntryPoint,\n\t\t} = ctorProps;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn new (ctor as any)(\n\t\t\tdefaultFactory,\n\t\t\tregistryEntries,\n\t\t\tdependencyContainer,\n\t\t\trequestHandlers,\n\t\t\truntimeOptions,\n\t\t\tprovideEntryPoint ?? getDefaultFluidObject,\n\t\t);\n\t}\n};\n"]}
|
package/lib/testFluidObject.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare class TestFluidObject implements ITestFluidObject {
|
|
|
42
42
|
initialize(existing: boolean): Promise<void>;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
+
* Iterable\<[ChannelId, IChannelFactory]\>.
|
|
45
46
|
* @internal
|
|
46
47
|
*/
|
|
47
48
|
export type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testFluidObject.d.ts","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEpF,OAAO,EACN,qBAAqB,EAGrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,eAAe,EACf,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,UAAU,EAAa,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;aAyBtC,OAAO,EAAE,sBAAsB;aAC/B,OAAO,EAAE,sBAAsB;aAC/B,OAAO,EAAE,sBAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IA3BnC,IAAW,gBAAgB,SAE1B;IAED,IAAW,cAAc,SAExB;IAED,IAAW,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAEtC;IAEM,IAAI,EAAG,UAAU,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,qBAAqB,CAA4B;IAEzD;;;;;;OAMG;gBAEc,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,sBAAsB,EAC9B,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,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C,CAAC,CAAC;IAkBhD,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAM9C,UAAU,CAAC,QAAQ,EAAE,OAAO;CAmBzC;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,CAAC,MAAM,GAAG,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,sBAAuB,YAAW,sBAAsB;IAYnE,OAAO,CAAC,QAAQ,CAAC,cAAc;aACf,IAAI;IAZrB,IAAW,sBAAsB,SAEhC;IAED;;;;;OAKG;gBAEe,cAAc,EAAE,sBAAsB,EACvC,IAAI,SAA2B;IAGnC,oBAAoB,CAChC,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,OAAO,GACf,OAAO,CAAC,qBAAqB,CAAC;CAmDjC"}
|
package/lib/testFluidObject.js
CHANGED
|
@@ -44,11 +44,12 @@ export class TestFluidObject {
|
|
|
44
44
|
if (this.factoryEntriesMap === undefined) {
|
|
45
45
|
throw new Error("Shared objects were not provided during creation.");
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
if (this.factoryEntriesMap.has(id)) {
|
|
48
|
+
const handle = this.root.get(id);
|
|
49
|
+
if (handle === undefined) {
|
|
50
|
+
throw new Error(`Shared object with id '${id}' is in factoryEntriesMap but not found under root.`);
|
|
51
51
|
}
|
|
52
|
+
return handle.get();
|
|
52
53
|
}
|
|
53
54
|
throw new Error(`Shared object with id ${id} not found.`);
|
|
54
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testFluidObject.js","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAEN,iBAAiB,EACjB,mB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AAS,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE;YACzE,MAAM,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,QAAQ,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAoB,IAAI,eAAe,CACpD,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,UAAU;QACnB,OAAO,EACP,0BAA0B,CAC1B,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle, IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tFluidDataStoreRuntime,\n\tFluidObjectHandle,\n\tmixinRequestHandler,\n} from \"@fluidframework/datastore/internal\";\nimport {\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { ISharedMap, SharedMap } from \"@fluidframework/map/internal\";\nimport {\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { create404Response } from \"@fluidframework/runtime-utils/internal\";\n\nimport { ITestFluidObject } from \"./interfaces.js\";\n\n/**\n * A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.\n * The shared objects can be retrieved by passing the key of the entry to getSharedObject.\n * It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.\n * @internal\n */\nexport class TestFluidObject implements ITestFluidObject {\n\tpublic get ITestFluidObject() {\n\t\treturn this;\n\t}\n\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\tpublic get handle(): IFluidHandle<this> {\n\t\treturn this.innerHandle;\n\t}\n\n\tpublic root!: ISharedMap;\n\tprivate readonly innerHandle: IFluidHandle<this>;\n\tprivate initializationPromise: Promise<void> | undefined;\n\n\t/**\n\t * Creates a new TestFluidObject.\n\t * @param runtime - The data store runtime.\n\t * @param context - The data store context.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. For each item in the list,\n\t * a shared object is created which can be retrieved by calling getSharedObject() with the id;\n\t */\n\tconstructor(\n\t\tpublic readonly runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly channel: IFluidDataStoreChannel,\n\t\tpublic readonly context: IFluidDataStoreContext,\n\t\tprivate readonly factoryEntriesMap: Map<string, IChannelFactory>,\n\t) {\n\t\tthis.innerHandle = new FluidObjectHandle(this, \"\", runtime.objectsRoutingContext);\n\t}\n\n\t/**\n\t * Retrieves a shared object with the given id.\n\t * @param id - The id of the shared object to retrieve.\n\t */\n\tpublic async getSharedObject<T = any>(id: string): Promise<T> {\n\t\tif (this.factoryEntriesMap === undefined) {\n\t\t\tthrow new Error(\"Shared objects were not provided during creation.\");\n\t\t}\n\n\t\tfor (const key of this.factoryEntriesMap.keys()) {\n\t\t\tif (key === id) {\n\t\t\t\tconst handle = this.root.get<IFluidHandle>(id);\n\t\t\t\treturn handle?.get() as Promise<T>;\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`Shared object with id ${id} not found.`);\n\t}\n\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\treturn request.url === \"\" || request.url === \"/\" || request.url.startsWith(\"/?\")\n\t\t\t? { mimeType: \"fluid/object\", status: 200, value: this }\n\t\t\t: create404Response(request);\n\t}\n\n\tpublic async initialize(existing: boolean) {\n\t\tconst doInitialization = async () => {\n\t\t\tif (!existing) {\n\t\t\t\tthis.root = SharedMap.create(this.runtime, \"root\");\n\n\t\t\t\tthis.factoryEntriesMap.forEach((sharedObjectFactory: IChannelFactory, key: string) => {\n\t\t\t\t\tconst sharedObject = this.runtime.createChannel(key, sharedObjectFactory.type);\n\t\t\t\t\tthis.root.set(key, sharedObject.handle);\n\t\t\t\t});\n\n\t\t\t\tthis.root.bindToContext();\n\t\t\t}\n\n\t\t\tthis.root = (await this.runtime.getChannel(\"root\")) as ISharedMap;\n\t\t};\n\n\t\tthis.initializationPromise ??= doInitialization();\n\t\treturn this.initializationPromise;\n\t}\n}\n\n/**\n * @internal\n */\nexport type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;\n\n/**\n * Creates a factory for a TestFluidObject with the given object factory entries. It creates a data store runtime\n * with the object factories in the entry list. All the entries with an id other than undefined are passed to the\n * Fluid object so that it can create a shared object for each.\n *\n * @example\n *\n * The following will create a Fluid object that creates and loads a SharedString and SharedDirectory.\n * It will add SparseMatrix to the data store's factory so that it can be created later.\n *\n * ```typescript\n * new TestFluidObjectFactory([\n * [ \"sharedString\", SharedString.getFactory() ],\n * [ \"sharedDirectory\", SharedDirectory.getFactory() ],\n * [ undefined, SparseMatrix.getFactory() ],\n * ]);\n * ```\n *\n * The SharedString and SharedDirectory can be retrieved via getSharedObject() on the TestFluidObject as follows:\n *\n * ```typescript\n * sharedString = testFluidObject.getSharedObject<SharedString>(\"sharedString\");\n * sharedDir = testFluidObject.getSharedObject<SharedDirectory>(\"sharedDirectory\");\n * ```\n *\n * @privateRemarks Beware that using this class generally forfeits some compatibility coverage\n * `describeCompat` aims to provide:\n * `SharedMap`s always reference the current version of SharedMap.\n * AB#4670 tracks improving this situation.\n * @internal\n */\nexport class TestFluidObjectFactory implements IFluidDataStoreFactory {\n\tpublic get IFluidDataStoreFactory() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a new TestFluidObjectFactory.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. It creates a data store runtime with each\n\t * IChannelFactory. Entries with string ids are passed to the Fluid object so that it can create a shared object\n\t * for it.\n\t */\n\tconstructor(\n\t\tprivate readonly factoryEntries: ChannelFactoryRegistry,\n\t\tpublic readonly type = \"TestFluidObjectFactory\",\n\t) {}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<FluidDataStoreRuntime> {\n\t\tconst dataTypes = new Map<string, IChannelFactory>();\n\n\t\t// Add SharedMap's factory which will be used to create the root map.\n\t\tconst sharedMapFactory = SharedMap.getFactory();\n\t\tdataTypes.set(sharedMapFactory.type, sharedMapFactory);\n\n\t\t// Add the object factories to the list to be sent to data store runtime.\n\t\tfor (const [, factory] of this.factoryEntries) {\n\t\t\tdataTypes.set(factory.type, factory);\n\t\t}\n\n\t\t// Create a map from the factory entries with entries that don't have the id as undefined. This will be\n\t\t// passed to the Fluid object.\n\t\tconst factoryEntriesMapForObject = new Map<string, IChannelFactory>();\n\t\tfor (const [id, factory] of this.factoryEntries) {\n\t\t\tif (id !== undefined) {\n\t\t\t\tfactoryEntriesMapForObject.set(id, factory);\n\t\t\t}\n\t\t}\n\n\t\tconst runtimeClass = mixinRequestHandler(\n\t\t\tasync (request: IRequest, rt: FluidDataStoreRuntime) => {\n\t\t\t\t// The provideEntryPoint callback below always returns TestFluidObject.\n\t\t\t\tconst dataObject = await rt.entryPoint.get();\n\t\t\t\tassert(\n\t\t\t\t\tdataObject instanceof TestFluidObject,\n\t\t\t\t\t\"entryPoint should have been initialized by now\",\n\t\t\t\t);\n\t\t\t\treturn dataObject.request(request);\n\t\t\t},\n\t\t);\n\n\t\tconst runtime = new runtimeClass(context, dataTypes, existing, async () => {\n\t\t\tawait instance.initialize(true);\n\t\t\treturn instance;\n\t\t});\n\n\t\tconst instance: TestFluidObject = new TestFluidObject(\n\t\t\truntime, // runtime\n\t\t\truntime, // channel\n\t\t\tcontext,\n\t\t\tfactoryEntriesMapForObject,\n\t\t);\n\n\t\tif (!existing) {\n\t\t\tawait instance.initialize(false);\n\t\t}\n\n\t\treturn runtime;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"testFluidObject.js","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,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AAC;YACF,OAAO,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC,CACD,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE;YACzE,MAAM,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,QAAQ,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAoB,IAAI,eAAe,CACpD,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,UAAU;QACnB,OAAO,EACP,0BAA0B,CAC1B,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle, IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tFluidDataStoreRuntime,\n\tFluidObjectHandle,\n\tmixinRequestHandler,\n} from \"@fluidframework/datastore/internal\";\nimport {\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { ISharedMap, SharedMap } from \"@fluidframework/map/internal\";\nimport {\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { create404Response } from \"@fluidframework/runtime-utils/internal\";\n\nimport { ITestFluidObject } from \"./interfaces.js\";\n\n/**\n * A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.\n * The shared objects can be retrieved by passing the key of the entry to getSharedObject.\n * It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.\n * @internal\n */\nexport class TestFluidObject implements ITestFluidObject {\n\tpublic get ITestFluidObject() {\n\t\treturn this;\n\t}\n\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\tpublic get handle(): IFluidHandle<this> {\n\t\treturn this.innerHandle;\n\t}\n\n\tpublic root!: ISharedMap;\n\tprivate readonly innerHandle: IFluidHandle<this>;\n\tprivate initializationPromise: Promise<void> | undefined;\n\n\t/**\n\t * Creates a new TestFluidObject.\n\t * @param runtime - The data store runtime.\n\t * @param context - The data store context.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. For each item in the list,\n\t * a shared object is created which can be retrieved by calling getSharedObject() with the id;\n\t */\n\tconstructor(\n\t\tpublic readonly runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly channel: IFluidDataStoreChannel,\n\t\tpublic readonly context: IFluidDataStoreContext,\n\t\tprivate readonly factoryEntriesMap: Map<string, IChannelFactory>,\n\t) {\n\t\tthis.innerHandle = new FluidObjectHandle(this, \"\", runtime.objectsRoutingContext);\n\t}\n\n\t/**\n\t * Retrieves a shared object with the given id.\n\t * @param id - The id of the shared object to retrieve.\n\t */\n\tpublic async getSharedObject<T = any>(id: string): Promise<T> {\n\t\tif (this.factoryEntriesMap === undefined) {\n\t\t\tthrow new Error(\"Shared objects were not provided during creation.\");\n\t\t}\n\n\t\tif (this.factoryEntriesMap.has(id)) {\n\t\t\tconst handle = this.root.get<IFluidHandle<T>>(id);\n\t\t\tif (handle === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Shared object with id '${id}' is in factoryEntriesMap but not found under root.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn handle.get();\n\t\t}\n\n\t\tthrow new Error(`Shared object with id ${id} not found.`);\n\t}\n\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\treturn request.url === \"\" || request.url === \"/\" || request.url.startsWith(\"/?\")\n\t\t\t? { mimeType: \"fluid/object\", status: 200, value: this }\n\t\t\t: create404Response(request);\n\t}\n\n\tpublic async initialize(existing: boolean) {\n\t\tconst doInitialization = async () => {\n\t\t\tif (!existing) {\n\t\t\t\tthis.root = SharedMap.create(this.runtime, \"root\");\n\n\t\t\t\tthis.factoryEntriesMap.forEach((sharedObjectFactory: IChannelFactory, key: string) => {\n\t\t\t\t\tconst sharedObject = this.runtime.createChannel(key, sharedObjectFactory.type);\n\t\t\t\t\tthis.root.set(key, sharedObject.handle);\n\t\t\t\t});\n\n\t\t\t\tthis.root.bindToContext();\n\t\t\t}\n\n\t\t\tthis.root = (await this.runtime.getChannel(\"root\")) as ISharedMap;\n\t\t};\n\n\t\tthis.initializationPromise ??= doInitialization();\n\t\treturn this.initializationPromise;\n\t}\n}\n\n/**\n * Iterable\\<[ChannelId, IChannelFactory]\\>.\n * @internal\n */\nexport type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;\n\n/**\n * Creates a factory for a TestFluidObject with the given object factory entries. It creates a data store runtime\n * with the object factories in the entry list. All the entries with an id other than undefined are passed to the\n * Fluid object so that it can create a shared object for each.\n *\n * @example\n *\n * The following will create a Fluid object that creates and loads a SharedString and SharedDirectory.\n * It will add SparseMatrix to the data store's factory so that it can be created later.\n *\n * ```typescript\n * new TestFluidObjectFactory([\n * [ \"sharedString\", SharedString.getFactory() ],\n * [ \"sharedDirectory\", SharedDirectory.getFactory() ],\n * [ undefined, SparseMatrix.getFactory() ],\n * ]);\n * ```\n *\n * The SharedString and SharedDirectory can be retrieved via getSharedObject() on the TestFluidObject as follows:\n *\n * ```typescript\n * sharedString = testFluidObject.getSharedObject<SharedString>(\"sharedString\");\n * sharedDir = testFluidObject.getSharedObject<SharedDirectory>(\"sharedDirectory\");\n * ```\n *\n * @privateRemarks Beware that using this class generally forfeits some compatibility coverage\n * `describeCompat` aims to provide:\n * `SharedMap`s always reference the current version of SharedMap.\n * AB#4670 tracks improving this situation.\n * @internal\n */\nexport class TestFluidObjectFactory implements IFluidDataStoreFactory {\n\tpublic get IFluidDataStoreFactory() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a new TestFluidObjectFactory.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. It creates a data store runtime with each\n\t * IChannelFactory. Entries with string ids are passed to the Fluid object so that it can create a shared object\n\t * for it.\n\t */\n\tconstructor(\n\t\tprivate readonly factoryEntries: ChannelFactoryRegistry,\n\t\tpublic readonly type = \"TestFluidObjectFactory\",\n\t) {}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<FluidDataStoreRuntime> {\n\t\tconst dataTypes = new Map<string, IChannelFactory>();\n\n\t\t// Add SharedMap's factory which will be used to create the root map.\n\t\tconst sharedMapFactory = SharedMap.getFactory();\n\t\tdataTypes.set(sharedMapFactory.type, sharedMapFactory);\n\n\t\t// Add the object factories to the list to be sent to data store runtime.\n\t\tfor (const [, factory] of this.factoryEntries) {\n\t\t\tdataTypes.set(factory.type, factory);\n\t\t}\n\n\t\t// Create a map from the factory entries with entries that don't have the id as undefined. This will be\n\t\t// passed to the Fluid object.\n\t\tconst factoryEntriesMapForObject = new Map<string, IChannelFactory>();\n\t\tfor (const [id, factory] of this.factoryEntries) {\n\t\t\tif (id !== undefined) {\n\t\t\t\tfactoryEntriesMapForObject.set(id, factory);\n\t\t\t}\n\t\t}\n\n\t\tconst runtimeClass = mixinRequestHandler(\n\t\t\tasync (request: IRequest, rt: FluidDataStoreRuntime) => {\n\t\t\t\t// The provideEntryPoint callback below always returns TestFluidObject.\n\t\t\t\tconst dataObject = await rt.entryPoint.get();\n\t\t\t\tassert(\n\t\t\t\t\tdataObject instanceof TestFluidObject,\n\t\t\t\t\t\"entryPoint should have been initialized by now\",\n\t\t\t\t);\n\t\t\t\treturn dataObject.request(request);\n\t\t\t},\n\t\t);\n\n\t\tconst runtime = new runtimeClass(context, dataTypes, existing, async () => {\n\t\t\tawait instance.initialize(true);\n\t\t\treturn instance;\n\t\t});\n\n\t\tconst instance: TestFluidObject = new TestFluidObject(\n\t\t\truntime, // runtime\n\t\t\truntime, // channel\n\t\t\tcontext,\n\t\t\tfactoryEntriesMapForObject,\n\t\t);\n\n\t\tif (!existing) {\n\t\t\tawait instance.initialize(false);\n\t\t}\n\n\t\treturn runtime;\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/test-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "Utilities for Fluid tests",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -67,26 +67,25 @@
|
|
|
67
67
|
"temp-directory": "nyc/.nyc_output"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@fluid-internal/test-driver-definitions": "~2.
|
|
71
|
-
"@fluidframework/
|
|
72
|
-
"@fluidframework/container-
|
|
73
|
-
"@fluidframework/container-
|
|
74
|
-
"@fluidframework/container-runtime": "~2.
|
|
75
|
-
"@fluidframework/
|
|
76
|
-
"@fluidframework/core-
|
|
77
|
-
"@fluidframework/
|
|
78
|
-
"@fluidframework/datastore": "~2.
|
|
79
|
-
"@fluidframework/
|
|
80
|
-
"@fluidframework/driver-
|
|
81
|
-
"@fluidframework/driver
|
|
82
|
-
"@fluidframework/
|
|
83
|
-
"@fluidframework/
|
|
84
|
-
"@fluidframework/
|
|
85
|
-
"@fluidframework/
|
|
86
|
-
"@fluidframework/
|
|
87
|
-
"@fluidframework/runtime-
|
|
88
|
-
"@fluidframework/
|
|
89
|
-
"@fluidframework/telemetry-utils": "~2.22.1",
|
|
70
|
+
"@fluid-internal/test-driver-definitions": "~2.23.0",
|
|
71
|
+
"@fluidframework/container-definitions": "~2.23.0",
|
|
72
|
+
"@fluidframework/container-loader": "~2.23.0",
|
|
73
|
+
"@fluidframework/container-runtime": "~2.23.0",
|
|
74
|
+
"@fluidframework/container-runtime-definitions": "~2.23.0",
|
|
75
|
+
"@fluidframework/core-interfaces": "~2.23.0",
|
|
76
|
+
"@fluidframework/core-utils": "~2.23.0",
|
|
77
|
+
"@fluidframework/datastore": "~2.23.0",
|
|
78
|
+
"@fluidframework/datastore-definitions": "~2.23.0",
|
|
79
|
+
"@fluidframework/driver-definitions": "~2.23.0",
|
|
80
|
+
"@fluidframework/driver-utils": "~2.23.0",
|
|
81
|
+
"@fluidframework/local-driver": "~2.23.0",
|
|
82
|
+
"@fluidframework/map": "~2.23.0",
|
|
83
|
+
"@fluidframework/odsp-driver": "~2.23.0",
|
|
84
|
+
"@fluidframework/request-handler": "~2.23.0",
|
|
85
|
+
"@fluidframework/routerlicious-driver": "~2.23.0",
|
|
86
|
+
"@fluidframework/runtime-definitions": "~2.23.0",
|
|
87
|
+
"@fluidframework/runtime-utils": "~2.23.0",
|
|
88
|
+
"@fluidframework/telemetry-utils": "~2.23.0",
|
|
90
89
|
"best-random": "^1.0.0",
|
|
91
90
|
"debug": "^4.3.4",
|
|
92
91
|
"mocha": "^10.2.0",
|
|
@@ -95,10 +94,10 @@
|
|
|
95
94
|
"devDependencies": {
|
|
96
95
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
97
96
|
"@biomejs/biome": "~1.9.3",
|
|
98
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
99
|
-
"@fluid-tools/build-cli": "^0.
|
|
97
|
+
"@fluid-internal/mocha-test-setup": "~2.23.0",
|
|
98
|
+
"@fluid-tools/build-cli": "^0.54.0",
|
|
100
99
|
"@fluidframework/build-common": "^2.0.3",
|
|
101
|
-
"@fluidframework/build-tools": "^0.
|
|
100
|
+
"@fluidframework/build-tools": "^0.54.0",
|
|
102
101
|
"@fluidframework/eslint-config-fluid": "^5.7.3",
|
|
103
102
|
"@fluidframework/test-utils-previous": "npm:@fluidframework/test-utils@2.22.0",
|
|
104
103
|
"@microsoft/api-extractor": "7.47.8",
|
package/src/TestSummaryUtils.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct/internal";
|
|
7
6
|
import {
|
|
8
7
|
IContainer,
|
|
9
8
|
IHostLoader,
|
|
@@ -30,8 +29,13 @@ import {
|
|
|
30
29
|
} from "@fluidframework/runtime-definitions/internal";
|
|
31
30
|
|
|
32
31
|
import { createTestConfigProvider } from "./TestConfigs.js";
|
|
32
|
+
// eslint-disable-next-line import/no-deprecated
|
|
33
|
+
import { ContainerRuntimeFactoryWithDefaultDataStore } from "./containerRuntimeFactories.js";
|
|
33
34
|
import { waitForContainerConnection } from "./containerUtils.js";
|
|
34
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
type ContainerRuntimeFactoryWithDefaultDataStoreConstructor,
|
|
37
|
+
createContainerRuntimeFactoryWithDefaultDataStore,
|
|
38
|
+
} from "./testContainerRuntimeFactoryWithDefaultDataStore.js";
|
|
35
39
|
import { ITestContainerConfig, ITestObjectProvider } from "./testObjectProvider.js";
|
|
36
40
|
import { timeoutAwait } from "./timeoutUtils.js";
|
|
37
41
|
|
|
@@ -118,13 +122,14 @@ export async function createSummarizerFromFactory(
|
|
|
118
122
|
container: IContainer,
|
|
119
123
|
dataStoreFactory: IFluidDataStoreFactory,
|
|
120
124
|
summaryVersion?: string,
|
|
121
|
-
containerRuntimeFactoryType
|
|
125
|
+
containerRuntimeFactoryType?: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,
|
|
122
126
|
registryEntries?: NamedFluidDataStoreRegistryEntries,
|
|
123
127
|
logger?: ITelemetryBaseLogger,
|
|
124
128
|
configProvider: IConfigProviderBase = createTestConfigProvider(),
|
|
125
129
|
): Promise<{ container: IContainer; summarizer: ISummarizer }> {
|
|
126
130
|
const runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(
|
|
127
|
-
|
|
131
|
+
// eslint-disable-next-line import/no-deprecated
|
|
132
|
+
containerRuntimeFactoryType ?? ContainerRuntimeFactoryWithDefaultDataStore,
|
|
128
133
|
{
|
|
129
134
|
defaultFactory: dataStoreFactory,
|
|
130
135
|
registryEntries: registryEntries ?? [
|
|
@@ -182,10 +187,8 @@ export async function createSummarizer(
|
|
|
182
187
|
*/
|
|
183
188
|
export async function summarizeNow(
|
|
184
189
|
summarizer: ISummarizer,
|
|
185
|
-
// eslint-disable-next-line import/no-deprecated
|
|
186
190
|
inputs: string | IOnDemandSummarizeOptions = "end-to-end test",
|
|
187
191
|
): Promise<SummaryInfo> {
|
|
188
|
-
// eslint-disable-next-line import/no-deprecated
|
|
189
192
|
const options: IOnDemandSummarizeOptions =
|
|
190
193
|
typeof inputs === "string" ? { reason: inputs } : inputs;
|
|
191
194
|
const result = summarizer.summarizeOnDemand(options);
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
IContainerContext,
|
|
8
|
+
IRuntime,
|
|
9
|
+
} from "@fluidframework/container-definitions/internal";
|
|
10
|
+
import {
|
|
11
|
+
FluidDataStoreRegistry,
|
|
12
|
+
loadContainerRuntime,
|
|
13
|
+
type IContainerRuntimeOptions,
|
|
14
|
+
} from "@fluidframework/container-runtime/internal";
|
|
15
|
+
import type {
|
|
16
|
+
IContainerRuntime,
|
|
17
|
+
// eslint-disable-next-line import/no-deprecated
|
|
18
|
+
IContainerRuntimeWithResolveHandle_Deprecated,
|
|
19
|
+
} from "@fluidframework/container-runtime-definitions/internal";
|
|
20
|
+
import type { FluidObject, IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
21
|
+
import {
|
|
22
|
+
// eslint-disable-next-line import/no-deprecated
|
|
23
|
+
type RuntimeRequestHandler,
|
|
24
|
+
// eslint-disable-next-line import/no-deprecated
|
|
25
|
+
buildRuntimeRequestHandler,
|
|
26
|
+
} from "@fluidframework/request-handler/internal";
|
|
27
|
+
import type {
|
|
28
|
+
IFluidDataStoreFactory,
|
|
29
|
+
IFluidDataStoreRegistry,
|
|
30
|
+
IProvideFluidDataStoreRegistry,
|
|
31
|
+
NamedFluidDataStoreRegistryEntries,
|
|
32
|
+
} from "@fluidframework/runtime-definitions/internal";
|
|
33
|
+
import { RequestParser, RuntimeFactoryHelper } from "@fluidframework/runtime-utils/internal";
|
|
34
|
+
|
|
35
|
+
const defaultDataStoreId = "default";
|
|
36
|
+
|
|
37
|
+
async function getDefaultFluidObject(runtime: IContainerRuntime): Promise<FluidObject> {
|
|
38
|
+
const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
|
|
39
|
+
if (entryPoint === undefined) {
|
|
40
|
+
throw new Error("default dataStore must exist");
|
|
41
|
+
}
|
|
42
|
+
return entryPoint.get();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* {@link ContainerRuntimeFactoryWithDefaultDataStore} construction properties.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated See notice on {@link ContainerRuntimeFactoryWithDefaultDataStore}.
|
|
49
|
+
*/
|
|
50
|
+
export interface ContainerRuntimeFactoryWithDefaultDataStoreProps {
|
|
51
|
+
readonly defaultFactory: IFluidDataStoreFactory;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The data store registry for containers produced.
|
|
55
|
+
*/
|
|
56
|
+
readonly registryEntries: NamedFluidDataStoreRegistryEntries;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The runtime options passed to the IContainerRuntime when instantiating it
|
|
60
|
+
*/
|
|
61
|
+
readonly runtimeOptions?: IContainerRuntimeOptions;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Function that will initialize the entryPoint of the IContainerRuntime instances
|
|
65
|
+
* created with this factory
|
|
66
|
+
*/
|
|
67
|
+
readonly provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A ContainerRuntimeFactory that initializes Containers with a single default data store, which can be requested from
|
|
72
|
+
* the container with an empty URL.
|
|
73
|
+
*
|
|
74
|
+
* @deprecated
|
|
75
|
+
* Do not reference this type directly. It will be removed in the future.
|
|
76
|
+
* E.g. use {@link IRuntimeFactory} instead.
|
|
77
|
+
*/
|
|
78
|
+
export class ContainerRuntimeFactoryWithDefaultDataStore
|
|
79
|
+
extends RuntimeFactoryHelper
|
|
80
|
+
implements IProvideFluidDataStoreRegistry
|
|
81
|
+
{
|
|
82
|
+
public static readonly defaultDataStoreId = defaultDataStoreId;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}
|
|
86
|
+
*/
|
|
87
|
+
public get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {
|
|
88
|
+
return this.registry;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
protected readonly defaultFactory: IFluidDataStoreFactory;
|
|
92
|
+
|
|
93
|
+
private readonly registry: IFluidDataStoreRegistry;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.registryEntries}
|
|
97
|
+
*/
|
|
98
|
+
private readonly registryEntries: NamedFluidDataStoreRegistryEntries;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.runtimeOptions}
|
|
102
|
+
*/
|
|
103
|
+
private readonly runtimeOptions?: IContainerRuntimeOptions;
|
|
104
|
+
|
|
105
|
+
// eslint-disable-next-line import/no-deprecated
|
|
106
|
+
private readonly requestHandlers: readonly RuntimeRequestHandler[];
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* {@inheritDoc ContainerRuntimeFactoryWithDefaultDataStoreProps.provideEntryPoint}
|
|
110
|
+
*/
|
|
111
|
+
private readonly provideEntryPoint: (runtime: IContainerRuntime) => Promise<FluidObject>;
|
|
112
|
+
|
|
113
|
+
public constructor(props: ContainerRuntimeFactoryWithDefaultDataStoreProps) {
|
|
114
|
+
super();
|
|
115
|
+
|
|
116
|
+
const getDefaultObject = async (
|
|
117
|
+
request: IRequest,
|
|
118
|
+
runtime: IContainerRuntime,
|
|
119
|
+
): Promise<IResponse | undefined> => {
|
|
120
|
+
const parser = RequestParser.create(request);
|
|
121
|
+
if (parser.pathParts.length === 0) {
|
|
122
|
+
// This cast is safe as loadContainerRuntime is called in the base class
|
|
123
|
+
// eslint-disable-next-line import/no-deprecated
|
|
124
|
+
return (runtime as IContainerRuntimeWithResolveHandle_Deprecated).resolveHandle({
|
|
125
|
+
url: `/${defaultDataStoreId}${parser.query}`,
|
|
126
|
+
headers: request.headers,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return undefined; // continue search
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
this.defaultFactory = props.defaultFactory;
|
|
133
|
+
this.registryEntries = props.registryEntries;
|
|
134
|
+
this.runtimeOptions = props.runtimeOptions;
|
|
135
|
+
this.provideEntryPoint = props.provideEntryPoint ?? getDefaultFluidObject;
|
|
136
|
+
this.requestHandlers = [getDefaultObject];
|
|
137
|
+
this.registry = new FluidDataStoreRegistry(this.registryEntries);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public async instantiateFirstTime(runtime: IContainerRuntime): Promise<void> {
|
|
141
|
+
await this.containerInitializingFirstTime(runtime);
|
|
142
|
+
await this.containerHasInitialized(runtime);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public async instantiateFromExisting(runtime: IContainerRuntime): Promise<void> {
|
|
146
|
+
await this.containerHasInitialized(runtime);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public async preInitialize(
|
|
150
|
+
context: IContainerContext,
|
|
151
|
+
existing: boolean,
|
|
152
|
+
): Promise<IContainerRuntime & IRuntime> {
|
|
153
|
+
return loadContainerRuntime({
|
|
154
|
+
context,
|
|
155
|
+
existing,
|
|
156
|
+
runtimeOptions: this.runtimeOptions,
|
|
157
|
+
registryEntries: this.registryEntries,
|
|
158
|
+
containerScope: context.scope,
|
|
159
|
+
// eslint-disable-next-line import/no-deprecated
|
|
160
|
+
requestHandler: buildRuntimeRequestHandler(...this.requestHandlers),
|
|
161
|
+
provideEntryPoint: this.provideEntryPoint,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Subclasses may override containerInitializingFirstTime to perform any setup steps at the time the container
|
|
167
|
+
* is created. This likely includes creating any initial data stores that are expected to be there at the outset.
|
|
168
|
+
* @param runtime - The container runtime for the container being initialized.
|
|
169
|
+
* @virtual
|
|
170
|
+
*/
|
|
171
|
+
protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {
|
|
172
|
+
const dataStore = await runtime.createDataStore(this.defaultFactory.type);
|
|
173
|
+
await dataStore.trySetAlias(defaultDataStoreId);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Subclasses may override containerHasInitialized to perform any steps after the container has initialized.
|
|
178
|
+
* This likely includes loading any data stores that are expected to be there at the outset.
|
|
179
|
+
* @param runtime - The container runtime for the container being initialized.
|
|
180
|
+
* @virtual
|
|
181
|
+
*/
|
|
182
|
+
protected async containerHasInitialized(runtime: IContainerRuntime): Promise<void> {}
|
|
183
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -60,4 +60,8 @@ export {
|
|
|
60
60
|
getContainerEntryPointBackCompat,
|
|
61
61
|
getDataStoreEntryPointBackCompat,
|
|
62
62
|
} from "./containerUtils.js";
|
|
63
|
-
export {
|
|
63
|
+
export {
|
|
64
|
+
type ContainerRuntimeFactoryWithDefaultDataStoreConstructor,
|
|
65
|
+
type ContainerRuntimeFactoryWithDefaultDataStoreProps,
|
|
66
|
+
createContainerRuntimeFactoryWithDefaultDataStore,
|
|
67
|
+
} from "./testContainerRuntimeFactoryWithDefaultDataStore.js";
|
package/src/localCodeLoader.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
|
|
8
|
-
import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct/internal";
|
|
9
8
|
import {
|
|
10
9
|
ICodeDetailsLoader,
|
|
11
10
|
IFluidCodeDetails,
|
|
@@ -21,6 +20,9 @@ import {
|
|
|
21
20
|
} from "@fluidframework/runtime-definitions/internal";
|
|
22
21
|
import { createDataStoreFactory } from "@fluidframework/runtime-utils/internal";
|
|
23
22
|
|
|
23
|
+
// eslint-disable-next-line import/no-deprecated
|
|
24
|
+
import { ContainerRuntimeFactoryWithDefaultDataStore } from "./containerRuntimeFactories.js";
|
|
25
|
+
|
|
24
26
|
/**
|
|
25
27
|
* @internal
|
|
26
28
|
*/
|
|
@@ -73,6 +75,7 @@ export class LocalCodeLoader implements ICodeDetailsLoader {
|
|
|
73
75
|
fluidModule = {
|
|
74
76
|
fluidExport: {
|
|
75
77
|
...maybeExport,
|
|
78
|
+
// eslint-disable-next-line import/no-deprecated
|
|
76
79
|
IRuntimeFactory: new ContainerRuntimeFactoryWithDefaultDataStore({
|
|
77
80
|
defaultFactory,
|
|
78
81
|
registryEntries: [[defaultFactory.type, Promise.resolve(defaultFactory)]],
|
package/src/packageVersion.ts
CHANGED