@fluidframework/runtime-utils 2.113.0-411909 → 2.114.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 +73 -0
- package/api-report/runtime-utils.legacy.alpha.api.md +6 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/legacyAlpha.d.ts +5 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serviceClientBase.d.ts +96 -0
- package/dist/serviceClientBase.d.ts.map +1 -0
- package/dist/serviceClientBase.js +165 -0
- package/dist/serviceClientBase.js.map +1 -0
- package/dist/serviceClientUtils.d.ts +90 -0
- package/dist/serviceClientUtils.d.ts.map +1 -0
- package/dist/serviceClientUtils.js +128 -0
- package/dist/serviceClientUtils.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/legacyAlpha.d.ts +5 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/serviceClientBase.d.ts +96 -0
- package/lib/serviceClientBase.d.ts.map +1 -0
- package/lib/serviceClientBase.js +159 -0
- package/lib/serviceClientBase.js.map +1 -0
- package/lib/serviceClientUtils.d.ts +90 -0
- package/lib/serviceClientUtils.d.ts.map +1 -0
- package/lib/serviceClientUtils.js +121 -0
- package/lib/serviceClientUtils.js.map +1 -0
- package/package.json +17 -17
- package/src/index.ts +18 -0
- package/src/packageVersion.ts +1 -1
- package/src/serviceClientBase.ts +261 -0
- package/src/serviceClientUtils.ts +236 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,78 @@
|
|
|
1
1
|
# @fluidframework/runtime-utils
|
|
2
2
|
|
|
3
|
+
## 2.114.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add new @alpha ServiceClient API for creating and loading Fluid containers ([#27693](https://github.com/microsoft/FluidFramework/pull/27693)) [ee47192d4a](https://github.com/microsoft/FluidFramework/commit/ee47192d4ae91bc28f9154c4d1ead2acad762f3c)
|
|
8
|
+
|
|
9
|
+
This introduces an experimental (`@alpha`), service-agnostic API for working with Fluid containers whose root is an arbitrary data store, along with an in-memory implementation for testing.
|
|
10
|
+
|
|
11
|
+
The new surface is made up of:
|
|
12
|
+
- `ServiceClient` (`@fluidframework/driver-definitions`): the entry point for creating and loading containers. Along with it come the supporting container types (`FluidContainer`, `FluidContainerWithService`, `FluidContainerAttached`), the data store model (`DataStoreKind`, `DataStoreKey`, `DataStoreRegistry`, `DataStoreCreator`), and the generic registry primitives (`Registry`, `RegistryKey`, `lookupInRegistry`, `createBasicRegistryKey`).
|
|
13
|
+
- `defineDataStore` and `sharedObjectRegistryFromIterable` (`@fluidframework/shared-object-base`): build a `DataStoreKind` from a root shared object and a registry of shared object kinds.
|
|
14
|
+
- `defineTreeDataStore` and `instantiateTreeFirstTime` (`@fluidframework/tree`): a SharedTree-specific convenience wrapper that produces a `DataStoreKind` backed by a `TreeView`.
|
|
15
|
+
- `startEphemeralService` (`@fluidframework/local-driver`): starts an in-memory `EphemeralService` for tests. The service owns the lifetime of the in-memory documents and resources, and produces `ServiceClient`s connected to it (via `EphemeralService.newClient` or `EphemeralService.defaultClient`). The helpers `cleanupEphemeralService` and `getDefaultEphemeralService` manage an optional default service instance.
|
|
16
|
+
|
|
17
|
+
Apart from the `@fluidframework/local-driver` helpers (which come from `@fluidframework/local-driver/alpha`), these APIs are also re-exported from `fluid-framework`. None reference any `@legacy` types.
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { startEphemeralService } from "@fluidframework/local-driver/alpha";
|
|
23
|
+
import {
|
|
24
|
+
ServiceClient,
|
|
25
|
+
defineTreeDataStore,
|
|
26
|
+
TreeViewConfiguration,
|
|
27
|
+
SchemaFactory,
|
|
28
|
+
} from "fluid-framework/alpha";
|
|
29
|
+
import { strict as assert } from "node:assert";
|
|
30
|
+
|
|
31
|
+
// Start an ephemeral in-memory service and get a ServiceClient connected to it.
|
|
32
|
+
const service = startEphemeralService();
|
|
33
|
+
const client: ServiceClient = service.defaultClient;
|
|
34
|
+
// Define a DataStoreKind which uses a SharedTree.
|
|
35
|
+
// In this case the schema is for a single number with an initializer that starts the it at 1.
|
|
36
|
+
// This schema is captures in the type allowing for strongly typed access to the data in the tree,
|
|
37
|
+
// where the type matches the schema based runtime enforcement of the schema.
|
|
38
|
+
const numberStore = defineTreeDataStore({
|
|
39
|
+
type: "my-app-root",
|
|
40
|
+
config: new TreeViewConfiguration({ schema: SchemaFactory.number }),
|
|
41
|
+
initializer: () => 1,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Create a container in the service with the above DataStoreKind.
|
|
45
|
+
// Ideally this creation would use a service independent API, and only the attach call would be service dependent,
|
|
46
|
+
// but that is not supported yet.
|
|
47
|
+
const detachedContainer1 = await client.createContainer(numberStore);
|
|
48
|
+
const container1 = await detachedContainer1.attach();
|
|
49
|
+
|
|
50
|
+
// We now have easy and type safe access to the data in the tree, which will be synced over the service.
|
|
51
|
+
assert.equal(container1.data.root, 1);
|
|
52
|
+
|
|
53
|
+
// A second client can load the same container from the service, and will see the same data.
|
|
54
|
+
const container2 = await client.loadContainer(container1.id, numberStore);
|
|
55
|
+
assert.equal(container2.data.root, 1);
|
|
56
|
+
|
|
57
|
+
// Both clients can modify the data, and the changes will be synced over the service.
|
|
58
|
+
container2.data.root = 2;
|
|
59
|
+
// Since we are using an ephemeral service, we can await the synchronization using service.synchronize.
|
|
60
|
+
await service.synchronize();
|
|
61
|
+
|
|
62
|
+
// And now the changes are visible for all clients.
|
|
63
|
+
assert.equal(container1.data.root, 2);
|
|
64
|
+
assert.equal(container2.data.root, 2);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Note that this example does a couple of things which are difficult to do with the other API surfaces:
|
|
68
|
+
1. It creates a container, then loads a second copy of it, allowing for collaboration. There is currently no non-legacy API surface which allows this without spawning a server process. This is also cleaner than the exacting legacy API options, and can replace the test specific APIs for this as well.
|
|
69
|
+
2. It creates a container which has a SharedTree at the root, and nothing else. This avoids depending on legacy DDS implementations, which is great for long-term document support and bundle size. This is currently impossible using `fluid-static`, which forces a special root data store. It is also impossible if using `aqueduct`, which forces a root directory in every data store. It can be done using the low level legacy APIs directly, but this new API for it is much simpler.
|
|
70
|
+
3. There is a common interface all services implement (`ServiceClient`), making the container creation part of the code work for any service implementation.
|
|
71
|
+
|
|
72
|
+
## 2.113.0
|
|
73
|
+
|
|
74
|
+
Dependency updates only.
|
|
75
|
+
|
|
3
76
|
## 2.112.0
|
|
4
77
|
|
|
5
78
|
Dependency updates only.
|
|
@@ -10,6 +10,9 @@ export function asLegacyAlpha(runtime: IContainerRuntimeBase): ContainerRuntimeB
|
|
|
10
10
|
// @alpha @legacy
|
|
11
11
|
export function asLegacyAlpha(runtime: IFluidDataStoreRuntime): IFluidDataStoreRuntimeAlpha;
|
|
12
12
|
|
|
13
|
+
// @alpha @sealed
|
|
14
|
+
export type Audience = IAudience;
|
|
15
|
+
|
|
13
16
|
// @public
|
|
14
17
|
export function compareFluidHandles(a: IFluidHandle, b: IFluidHandle): boolean;
|
|
15
18
|
|
|
@@ -34,6 +37,9 @@ export abstract class FluidHandleBase<T> implements IFluidHandleInternal<T> {
|
|
|
34
37
|
abstract readonly isAttached: boolean;
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
// @alpha
|
|
41
|
+
export function getContainerAudience(container: FluidContainerAttached): Audience;
|
|
42
|
+
|
|
37
43
|
// @public
|
|
38
44
|
export function isFluidHandle(value: unknown): value is IFluidHandle;
|
|
39
45
|
|
package/dist/index.d.ts
CHANGED
|
@@ -19,4 +19,8 @@ export { isSnapshotFetchRequiredForLoadingGroupId } from "./snapshotUtils.js";
|
|
|
19
19
|
export { toDeltaManagerErased, toDeltaManagerInternal, } from "./deltaManager.js";
|
|
20
20
|
export { configValueToMinVersionForCollab, defaultMinVersionForCollab, validateConfigMapOverrides, getConfigForMinVersionForCollab, getConfigsForMinVersionForCollab, isValidMinVersionForCollab, validateMinimumVersionForCollab, lowestMinVersionForCollab, getConfigForMinVersionForCollabIterable, cleanedPackageVersion, selectVersionRoundedDown, } from "./compatibilityBase.js";
|
|
21
21
|
export type { ConfigMap, ConfigMapEntry, ConfigValidationMap, MinimumMinorSemanticVersion, SemanticVersion, } from "./compatibilityBase.js";
|
|
22
|
+
export type { Audience } from "./serviceClientBase.js";
|
|
23
|
+
export { DataStoreKindImplementation, ServiceContainerBase, getContainerAudience, } from "./serviceClientBase.js";
|
|
24
|
+
export { convertRegistry, makeCodeLoader, normalizeRegistry, rootDataStoreId, ServiceClientImplementation, } from "./serviceClientUtils.js";
|
|
25
|
+
export type { ContainerRuntimeLoader, ContainerRuntimeLoaderParams, ServiceContainerStatics, } from "./serviceClientUtils.js";
|
|
22
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,2BAA2B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,mBAAmB,EACnB,4BAA4B,EAC5B,eAAe,EACf,aAAa,EACb,mCAAmC,EACnC,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,E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GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,gCAAgC,EAChC,0BAA0B,EAC1B,0BAA0B,EAC1B,+BAA+B,EAC/B,gCAAgC,EAChC,0BAA0B,EAC1B,+BAA+B,EAC/B,yBAAyB,EACzB,uCAAuC,EACvC,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,2BAA2B,EAC3B,eAAe,GACf,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACN,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,2BAA2B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,sBAAsB,EACtB,4BAA4B,EAC5B,uBAAuB,GACvB,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.getConfigsForMinVersionForCollab = exports.getConfigForMinVersionForCollab = exports.validateConfigMapOverrides = exports.defaultMinVersionForCollab = exports.configValueToMinVersionForCollab = exports.toDeltaManagerInternal = exports.toDeltaManagerErased = exports.isSnapshotFetchRequiredForLoadingGroupId = exports.encodeCompactIdToString = exports.seqFromTree = exports.RuntimeHeaders = exports.unpackChildNodesUsedRoutes = exports.utf8ByteLength = exports.TelemetryContext = exports.SummaryTreeBuilder = exports.processAttachMessageGCData = exports.mergeStats = exports.getBlobSize = exports.GCDataBuilder = exports.convertToSummaryTreeWithStats = exports.convertToSummaryTree = exports.convertSummaryTreeToITree = exports.convertSnapshotTreeToSummaryTree = exports.calculateStats = exports.addSummarizeResultToSummary = exports.addBlobToSummary = exports.RuntimeFactoryHelper = exports.RequestParser = exports.RemoteFluidObjectHandle = exports.listBlobsAtTreePath = exports.getNormalizedObjectStoragePathParts = exports.ObjectStoragePartition = exports.toFluidHandleInternal = exports.toFluidHandleErased = exports.lookupTemporaryBlobStorageId = exports.isSerializedHandle = exports.isLocalFluidHandle = exports.isFluidHandlePayloadPending = exports.isFluidHandleInternalPayloadPending = exports.isFluidHandle = exports.FluidHandleBase = exports.encodeHandleForSerialization = exports.compareFluidHandles = exports.dataStoreLoadTelemetryProps = exports.asLegacyAlpha = exports.responseToException = exports.exceptionToResponse = exports.createResponseError = exports.create404Response = exports.generateHandleContextPath = void 0;
|
|
8
|
-
exports.selectVersionRoundedDown = exports.cleanedPackageVersion = exports.getConfigForMinVersionForCollabIterable = exports.lowestMinVersionForCollab = exports.validateMinimumVersionForCollab = exports.isValidMinVersionForCollab = void 0;
|
|
8
|
+
exports.ServiceClientImplementation = exports.rootDataStoreId = exports.normalizeRegistry = exports.makeCodeLoader = exports.convertRegistry = exports.getContainerAudience = exports.ServiceContainerBase = exports.DataStoreKindImplementation = exports.selectVersionRoundedDown = exports.cleanedPackageVersion = exports.getConfigForMinVersionForCollabIterable = exports.lowestMinVersionForCollab = exports.validateMinimumVersionForCollab = exports.isValidMinVersionForCollab = void 0;
|
|
9
9
|
var dataStoreHandleContextUtils_js_1 = require("./dataStoreHandleContextUtils.js");
|
|
10
10
|
Object.defineProperty(exports, "generateHandleContextPath", { enumerable: true, get: function () { return dataStoreHandleContextUtils_js_1.generateHandleContextPath; } });
|
|
11
11
|
var dataStoreHelpers_js_1 = require("./dataStoreHelpers.js");
|
|
@@ -76,4 +76,14 @@ Object.defineProperty(exports, "lowestMinVersionForCollab", { enumerable: true,
|
|
|
76
76
|
Object.defineProperty(exports, "getConfigForMinVersionForCollabIterable", { enumerable: true, get: function () { return compatibilityBase_js_1.getConfigForMinVersionForCollabIterable; } });
|
|
77
77
|
Object.defineProperty(exports, "cleanedPackageVersion", { enumerable: true, get: function () { return compatibilityBase_js_1.cleanedPackageVersion; } });
|
|
78
78
|
Object.defineProperty(exports, "selectVersionRoundedDown", { enumerable: true, get: function () { return compatibilityBase_js_1.selectVersionRoundedDown; } });
|
|
79
|
+
var serviceClientBase_js_1 = require("./serviceClientBase.js");
|
|
80
|
+
Object.defineProperty(exports, "DataStoreKindImplementation", { enumerable: true, get: function () { return serviceClientBase_js_1.DataStoreKindImplementation; } });
|
|
81
|
+
Object.defineProperty(exports, "ServiceContainerBase", { enumerable: true, get: function () { return serviceClientBase_js_1.ServiceContainerBase; } });
|
|
82
|
+
Object.defineProperty(exports, "getContainerAudience", { enumerable: true, get: function () { return serviceClientBase_js_1.getContainerAudience; } });
|
|
83
|
+
var serviceClientUtils_js_1 = require("./serviceClientUtils.js");
|
|
84
|
+
Object.defineProperty(exports, "convertRegistry", { enumerable: true, get: function () { return serviceClientUtils_js_1.convertRegistry; } });
|
|
85
|
+
Object.defineProperty(exports, "makeCodeLoader", { enumerable: true, get: function () { return serviceClientUtils_js_1.makeCodeLoader; } });
|
|
86
|
+
Object.defineProperty(exports, "normalizeRegistry", { enumerable: true, get: function () { return serviceClientUtils_js_1.normalizeRegistry; } });
|
|
87
|
+
Object.defineProperty(exports, "rootDataStoreId", { enumerable: true, get: function () { return serviceClientUtils_js_1.rootDataStoreId; } });
|
|
88
|
+
Object.defineProperty(exports, "ServiceClientImplementation", { enumerable: true, get: function () { return serviceClientUtils_js_1.ServiceClientImplementation; } });
|
|
79
89
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,mFAA6E;AAApE,2IAAA,yBAAyB,OAAA;AAClC,6DAO+B;AAN9B,wHAAA,iBAAiB,OAAA;AACjB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AACnB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AA,sBAAsB,OAAA;AAEvB,+DAYgC;AAX/B,wIAAA,gCAAgC,OAAA;AAChC,kIAAA,0BAA0B,OAAA;AAC1B,kIAAA,0BAA0B,OAAA;AAC1B,uIAAA,+BAA+B,OAAA;AAC/B,wIAAA,gCAAgC,OAAA;AAChC,kIAAA,0BAA0B,OAAA;AAC1B,uIAAA,+BAA+B,OAAA;AAC/B,iIAAA,yBAAyB,OAAA;AACzB,+IAAA,uCAAuC,OAAA;AACvC,6HAAA,qBAAqB,OAAA;AACrB,gIAAA,wBAAwB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { generateHandleContextPath } from \"./dataStoreHandleContextUtils.js\";\nexport {\n\tcreate404Response,\n\tcreateResponseError,\n\texceptionToResponse,\n\tresponseToException,\n\tasLegacyAlpha,\n\tdataStoreLoadTelemetryProps,\n} from \"./dataStoreHelpers.js\";\nexport {\n\tcompareFluidHandles,\n\tencodeHandleForSerialization,\n\tFluidHandleBase,\n\tisFluidHandle,\n\tisFluidHandleInternalPayloadPending,\n\tisFluidHandlePayloadPending,\n\tisLocalFluidHandle,\n\tisSerializedHandle,\n\tlookupTemporaryBlobStorageId,\n\ttoFluidHandleErased,\n\ttoFluidHandleInternal,\n} from \"./handles.js\";\nexport type { ISerializedHandle } from \"./handles.js\";\nexport { ObjectStoragePartition } from \"./objectstoragepartition.js\";\nexport {\n\tgetNormalizedObjectStoragePathParts,\n\tlistBlobsAtTreePath,\n} from \"./objectstorageutils.js\";\nexport { RemoteFluidObjectHandle } from \"./remoteFluidObjectHandle.js\";\nexport { RequestParser } from \"./requestParser.js\";\nexport { RuntimeFactoryHelper } from \"./runtimeFactoryHelper.js\";\nexport {\n\taddBlobToSummary,\n\taddSummarizeResultToSummary,\n\tcalculateStats,\n\tconvertSnapshotTreeToSummaryTree,\n\tconvertSummaryTreeToITree,\n\tconvertToSummaryTree,\n\tconvertToSummaryTreeWithStats,\n\tGCDataBuilder,\n\tgetBlobSize,\n\tmergeStats,\n\tprocessAttachMessageGCData,\n\tSummaryTreeBuilder,\n\tTelemetryContext,\n\tutf8ByteLength,\n} from \"./summaryUtils.js\";\nexport { unpackChildNodesUsedRoutes } from \"./unpackUsedRoutes.js\";\nexport {\n\tRuntimeHeaders,\n\tseqFromTree,\n\tencodeCompactIdToString,\n} from \"./utils.js\";\nexport type { ReadAndParseBlob } from \"./utils.js\";\nexport { isSnapshotFetchRequiredForLoadingGroupId } from \"./snapshotUtils.js\";\nexport {\n\ttoDeltaManagerErased,\n\ttoDeltaManagerInternal,\n} from \"./deltaManager.js\";\nexport {\n\tconfigValueToMinVersionForCollab,\n\tdefaultMinVersionForCollab,\n\tvalidateConfigMapOverrides,\n\tgetConfigForMinVersionForCollab,\n\tgetConfigsForMinVersionForCollab,\n\tisValidMinVersionForCollab,\n\tvalidateMinimumVersionForCollab,\n\tlowestMinVersionForCollab,\n\tgetConfigForMinVersionForCollabIterable,\n\tcleanedPackageVersion,\n\tselectVersionRoundedDown,\n} from \"./compatibilityBase.js\";\nexport type {\n\tConfigMap,\n\tConfigMapEntry,\n\tConfigValidationMap,\n\tMinimumMinorSemanticVersion,\n\tSemanticVersion,\n} from \"./compatibilityBase.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,mFAA6E;AAApE,2IAAA,yBAAyB,OAAA;AAClC,6DAO+B;AAN9B,wHAAA,iBAAiB,OAAA;AACjB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA;AACnB,oHAAA,aAAa,OAAA;AACb,kIAAA,2BAA2B,OAAA;AAE5B,2CAYsB;AAXrB,iHAAA,mBAAmB,OAAA;AACnB,0HAAA,4BAA4B,OAAA;AAC5B,6GAAA,eAAe,OAAA;AACf,2GAAA,aAAa,OAAA;AACb,iIAAA,mCAAmC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,0BAA0B,OAAA;AAC1B,uIAAA,+BAA+B,OAAA;AAC/B,iIAAA,yBAAyB,OAAA;AACzB,+IAAA,uCAAuC,OAAA;AACvC,6HAAA,qBAAqB,OAAA;AACrB,gIAAA,wBAAwB,OAAA;AAUzB,+DAIgC;AAH/B,mIAAA,2BAA2B,OAAA;AAC3B,4HAAA,oBAAoB,OAAA;AACpB,4HAAA,oBAAoB,OAAA;AAErB,iEAMiC;AALhC,wHAAA,eAAe,OAAA;AACf,uHAAA,cAAc,OAAA;AACd,0HAAA,iBAAiB,OAAA;AACjB,wHAAA,eAAe,OAAA;AACf,oIAAA,2BAA2B,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { generateHandleContextPath } from \"./dataStoreHandleContextUtils.js\";\nexport {\n\tcreate404Response,\n\tcreateResponseError,\n\texceptionToResponse,\n\tresponseToException,\n\tasLegacyAlpha,\n\tdataStoreLoadTelemetryProps,\n} from \"./dataStoreHelpers.js\";\nexport {\n\tcompareFluidHandles,\n\tencodeHandleForSerialization,\n\tFluidHandleBase,\n\tisFluidHandle,\n\tisFluidHandleInternalPayloadPending,\n\tisFluidHandlePayloadPending,\n\tisLocalFluidHandle,\n\tisSerializedHandle,\n\tlookupTemporaryBlobStorageId,\n\ttoFluidHandleErased,\n\ttoFluidHandleInternal,\n} from \"./handles.js\";\nexport type { ISerializedHandle } from \"./handles.js\";\nexport { ObjectStoragePartition } from \"./objectstoragepartition.js\";\nexport {\n\tgetNormalizedObjectStoragePathParts,\n\tlistBlobsAtTreePath,\n} from \"./objectstorageutils.js\";\nexport { RemoteFluidObjectHandle } from \"./remoteFluidObjectHandle.js\";\nexport { RequestParser } from \"./requestParser.js\";\nexport { RuntimeFactoryHelper } from \"./runtimeFactoryHelper.js\";\nexport {\n\taddBlobToSummary,\n\taddSummarizeResultToSummary,\n\tcalculateStats,\n\tconvertSnapshotTreeToSummaryTree,\n\tconvertSummaryTreeToITree,\n\tconvertToSummaryTree,\n\tconvertToSummaryTreeWithStats,\n\tGCDataBuilder,\n\tgetBlobSize,\n\tmergeStats,\n\tprocessAttachMessageGCData,\n\tSummaryTreeBuilder,\n\tTelemetryContext,\n\tutf8ByteLength,\n} from \"./summaryUtils.js\";\nexport { unpackChildNodesUsedRoutes } from \"./unpackUsedRoutes.js\";\nexport {\n\tRuntimeHeaders,\n\tseqFromTree,\n\tencodeCompactIdToString,\n} from \"./utils.js\";\nexport type { ReadAndParseBlob } from \"./utils.js\";\nexport { isSnapshotFetchRequiredForLoadingGroupId } from \"./snapshotUtils.js\";\nexport {\n\ttoDeltaManagerErased,\n\ttoDeltaManagerInternal,\n} from \"./deltaManager.js\";\nexport {\n\tconfigValueToMinVersionForCollab,\n\tdefaultMinVersionForCollab,\n\tvalidateConfigMapOverrides,\n\tgetConfigForMinVersionForCollab,\n\tgetConfigsForMinVersionForCollab,\n\tisValidMinVersionForCollab,\n\tvalidateMinimumVersionForCollab,\n\tlowestMinVersionForCollab,\n\tgetConfigForMinVersionForCollabIterable,\n\tcleanedPackageVersion,\n\tselectVersionRoundedDown,\n} from \"./compatibilityBase.js\";\nexport type {\n\tConfigMap,\n\tConfigMapEntry,\n\tConfigValidationMap,\n\tMinimumMinorSemanticVersion,\n\tSemanticVersion,\n} from \"./compatibilityBase.js\";\nexport type { Audience } from \"./serviceClientBase.js\";\nexport {\n\tDataStoreKindImplementation,\n\tServiceContainerBase,\n\tgetContainerAudience,\n} from \"./serviceClientBase.js\";\nexport {\n\tconvertRegistry,\n\tmakeCodeLoader,\n\tnormalizeRegistry,\n\trootDataStoreId,\n\tServiceClientImplementation,\n} from \"./serviceClientUtils.js\";\nexport type {\n\tContainerRuntimeLoader,\n\tContainerRuntimeLoaderParams,\n\tServiceContainerStatics,\n} from \"./serviceClientUtils.js\";\n"]}
|
package/dist/legacyAlpha.d.ts
CHANGED
package/dist/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/runtime-utils";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.114.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,YAAY,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/runtime-utils";
|
|
11
|
-
exports.pkgVersion = "2.
|
|
11
|
+
exports.pkgVersion = "2.114.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,SAAS,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/runtime-utils\";\nexport const pkgVersion = \"2.114.0\";\n"]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { IAudience } from "@fluidframework/container-definitions";
|
|
6
|
+
import { type IContainer } from "@fluidframework/container-definitions/internal";
|
|
7
|
+
import type { IRequest } from "@fluidframework/core-interfaces";
|
|
8
|
+
import { ErasedTypeImplementation } from "@fluidframework/core-interfaces/internal";
|
|
9
|
+
import { type DataStoreKey, type DataStoreKind, type FluidContainerAttached, type FluidContainerWithService, type Registry } from "@fluidframework/driver-definitions/internal";
|
|
10
|
+
import type { IContainerRuntimeBase, IFluidDataStoreChannel, IFluidDataStoreContext, IFluidDataStoreFactory } from "@fluidframework/runtime-definitions/internal";
|
|
11
|
+
/**
|
|
12
|
+
* Implementation of `DataStoreKind`.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare class DataStoreKindImplementation<T> extends ErasedTypeImplementation<DataStoreKind<T>> implements DataStoreKind<T>, IFluidDataStoreFactory {
|
|
16
|
+
private readonly factory;
|
|
17
|
+
/**
|
|
18
|
+
* Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.
|
|
19
|
+
*/
|
|
20
|
+
static guard<T>(value: T): value is DataStoreKindImplementation<T extends DataStoreKind<infer T2> ? T2 : never> & T;
|
|
21
|
+
/**
|
|
22
|
+
* Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.
|
|
23
|
+
*/
|
|
24
|
+
static narrowGeneric<T>(value: T): asserts value is DataStoreKindImplementation<T extends DataStoreKind<infer T2> ? T2 : never> & T;
|
|
25
|
+
readonly type: string;
|
|
26
|
+
readonly createDataStore?: (context: IFluidDataStoreContext) => {
|
|
27
|
+
readonly runtime: IFluidDataStoreChannel;
|
|
28
|
+
};
|
|
29
|
+
constructor(factory: Pick<DataStoreKindImplementation<T>, "type" | "instantiateDataStore" | "createDataStore">);
|
|
30
|
+
instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<IFluidDataStoreChannel>;
|
|
31
|
+
get IFluidDataStoreFactory(): IFluidDataStoreFactory;
|
|
32
|
+
adapt(value: Promise<DataStoreKind>): Promise<DataStoreKind<T>>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Shared base class for all `ServiceClient` container implementations.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* Extends `ErasedTypeImplementation` so that
|
|
39
|
+
* {@link getContainerAudience} can narrow via `ServiceContainerBase.narrow()`.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export declare abstract class ServiceContainerBase<TData, TOptions = unknown> extends ErasedTypeImplementation<FluidContainerWithService<TData>> implements FluidContainerWithService<TData> {
|
|
44
|
+
readonly registry: Registry<Promise<DataStoreKind<TData>>>;
|
|
45
|
+
readonly options: TOptions;
|
|
46
|
+
readonly container: IContainer;
|
|
47
|
+
readonly data: TData;
|
|
48
|
+
id: string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* True if an attempt to attach has been started. This is used to prevent multiple concurrent attach attempts.
|
|
51
|
+
*/
|
|
52
|
+
private startedAttach;
|
|
53
|
+
protected constructor(registry: Registry<Promise<DataStoreKind<TData>>>, options: TOptions, container: IContainer, data: TData, id: string | undefined);
|
|
54
|
+
/**
|
|
55
|
+
* Creates the service-specific request used to attach this container.
|
|
56
|
+
* @remarks
|
|
57
|
+
* Called by {@link ServiceContainerBase.attach} after validating that no attach is already in progress.
|
|
58
|
+
*/
|
|
59
|
+
protected abstract createAttachRequest(): IRequest;
|
|
60
|
+
/**
|
|
61
|
+
* Extracts the container ID from {@link ServiceContainerBase.container}'s resolved URL after attachment.
|
|
62
|
+
* @remarks
|
|
63
|
+
* Override when the service's resolved URL stores the id in a non-standard field.
|
|
64
|
+
*/
|
|
65
|
+
protected getContainerId(): string;
|
|
66
|
+
attach(): Promise<FluidContainerAttached<TData>>;
|
|
67
|
+
get audience(): IAudience;
|
|
68
|
+
getRuntime(): IContainerRuntimeBase;
|
|
69
|
+
close(): void;
|
|
70
|
+
createDataStore<T>(key: DataStoreKey<T>): Promise<T>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* All clients connected to the op stream, both read-only and read/write.
|
|
74
|
+
* @remarks
|
|
75
|
+
* Currently just {@link @fluidframework/container-definitions#IAudience}, but may diverge before stabilizing.
|
|
76
|
+
* @privateRemarks
|
|
77
|
+
* This is currently just an alias for IAudience, but it is defined separately to allow for:
|
|
78
|
+
* 1. Following the no I prefix naming convention.
|
|
79
|
+
* 2. The possibility of diverging from IAudience in the future if desired.
|
|
80
|
+
* 3. Make it easy for the reexport from fluid-framework to be `@alpha` so the name is not locked down prematurely.
|
|
81
|
+
* @sealed @alpha
|
|
82
|
+
*/
|
|
83
|
+
export type Audience = IAudience;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the {@link Audience} from a Fluid container
|
|
86
|
+
* created by any {@link @fluidframework/driver-definitions#ServiceClient}.
|
|
87
|
+
* @privateRemarks
|
|
88
|
+
* This is exposed via a free function rather than as a property of FluidContainerAttached
|
|
89
|
+
* for a few minor reasons:
|
|
90
|
+
* 1. This allows stabilizing the FluidContainerAttached API independently committing to how we want to expose the audience.
|
|
91
|
+
* 2. This demonstrates the pattern of how we can have possible less stable APIs to expose service specific features without them being part of the core FluidContainer API.
|
|
92
|
+
* This will be important for both new feature stabilization, and also exposing anything needed for legacy interop.
|
|
93
|
+
* @alpha
|
|
94
|
+
*/
|
|
95
|
+
export declare function getContainerAudience(container: FluidContainerAttached): Audience;
|
|
96
|
+
//# sourceMappingURL=serviceClientBase.d.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;IA2B7D,IAAW,QAAQ,IAAI,SAAS,CAE/B;IAEM,UAAU,IAAI,qBAAqB;IAqBnC,KAAK,IAAI,IAAI;IAcP,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAcjE;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,sBAAsB,GAAG,QAAQ,CAGhF"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getContainerAudience = exports.ServiceContainerBase = exports.DataStoreKindImplementation = void 0;
|
|
8
|
+
const internal_1 = require("@fluidframework/container-definitions/internal");
|
|
9
|
+
const internal_2 = require("@fluidframework/core-interfaces/internal");
|
|
10
|
+
const internal_3 = require("@fluidframework/core-utils/internal");
|
|
11
|
+
const internal_4 = require("@fluidframework/driver-definitions/internal");
|
|
12
|
+
const internal_5 = require("@fluidframework/telemetry-utils/internal");
|
|
13
|
+
/*
|
|
14
|
+
* This file provides common implementation logic for ServiceClient implementations.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Implementation of `DataStoreKind`.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
class DataStoreKindImplementation extends internal_2.ErasedTypeImplementation {
|
|
21
|
+
/**
|
|
22
|
+
* Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.
|
|
23
|
+
*/
|
|
24
|
+
static guard(value) {
|
|
25
|
+
return value instanceof DataStoreKindImplementation;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.
|
|
29
|
+
*/
|
|
30
|
+
static narrowGeneric(value) {
|
|
31
|
+
if (!DataStoreKindImplementation.guard(value)) {
|
|
32
|
+
throw new Error("Invalid DataStoreKindImplementation");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
constructor(factory) {
|
|
36
|
+
super();
|
|
37
|
+
this.factory = factory;
|
|
38
|
+
this.type = factory.type;
|
|
39
|
+
if (factory.createDataStore !== undefined) {
|
|
40
|
+
this.createDataStore = factory.createDataStore.bind(factory);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async instantiateDataStore(context, existing) {
|
|
44
|
+
return this.factory.instantiateDataStore(context, existing);
|
|
45
|
+
}
|
|
46
|
+
get IFluidDataStoreFactory() {
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
async adapt(value) {
|
|
50
|
+
const input = await value;
|
|
51
|
+
if (input === this) {
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
if (input.type === this.type) {
|
|
55
|
+
throw new internal_5.UsageError(`Conflicting DataStoreKinds with same type: ${this.type}`);
|
|
56
|
+
}
|
|
57
|
+
throw new internal_5.UsageError(`Mismatched DataStoreKind type. Expected: ${this.type}, got: ${input.type}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.DataStoreKindImplementation = DataStoreKindImplementation;
|
|
61
|
+
/**
|
|
62
|
+
* Shared base class for all `ServiceClient` container implementations.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* Extends `ErasedTypeImplementation` so that
|
|
66
|
+
* {@link getContainerAudience} can narrow via `ServiceContainerBase.narrow()`.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
class ServiceContainerBase extends internal_2.ErasedTypeImplementation {
|
|
71
|
+
constructor(registry, options, container, data, id) {
|
|
72
|
+
super();
|
|
73
|
+
this.registry = registry;
|
|
74
|
+
this.options = options;
|
|
75
|
+
this.container = container;
|
|
76
|
+
this.data = data;
|
|
77
|
+
this.id = id;
|
|
78
|
+
/**
|
|
79
|
+
* True if an attempt to attach has been started. This is used to prevent multiple concurrent attach attempts.
|
|
80
|
+
*/
|
|
81
|
+
this.startedAttach = false;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Extracts the container ID from {@link ServiceContainerBase.container}'s resolved URL after attachment.
|
|
85
|
+
* @remarks
|
|
86
|
+
* Override when the service's resolved URL stores the id in a non-standard field.
|
|
87
|
+
*/
|
|
88
|
+
getContainerId() {
|
|
89
|
+
if (this.container.resolvedUrl === undefined) {
|
|
90
|
+
throw new Error("Resolved URL unexpectedly missing!");
|
|
91
|
+
}
|
|
92
|
+
return this.container.resolvedUrl.id;
|
|
93
|
+
}
|
|
94
|
+
async attach() {
|
|
95
|
+
if (this.id !== undefined) {
|
|
96
|
+
throw new internal_5.UsageError("Container already attached");
|
|
97
|
+
}
|
|
98
|
+
if (this.startedAttach) {
|
|
99
|
+
throw new internal_5.UsageError("Container attach already in progress");
|
|
100
|
+
}
|
|
101
|
+
(0, internal_3.assert)(this.container.attachState === internal_1.AttachState.Detached, 0xd15 /* Container not detached */);
|
|
102
|
+
this.startedAttach = true;
|
|
103
|
+
// TODO: support setting where attach can fail, and leave the container in a valid (non-closed) state.
|
|
104
|
+
// Likely the best way to support this is by adding a `tryAttach(request): Promise<FluidContainerAttached<TData> | undefined>`.
|
|
105
|
+
await this.container.attach(this.createAttachRequest());
|
|
106
|
+
// This type cast is needed to work around the fact that TypeScript assumes the "attach" methods can't modify "attachState".
|
|
107
|
+
(0, internal_3.assert)(this.container.attachState === internal_1.AttachState.Attached, 0xd16 /* Container failed to attach */);
|
|
108
|
+
this.id = this.getContainerId();
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
get audience() {
|
|
112
|
+
return this.container.audience;
|
|
113
|
+
}
|
|
114
|
+
getRuntime() {
|
|
115
|
+
const container = this.container;
|
|
116
|
+
if (container.runtime === undefined) {
|
|
117
|
+
throw new Error("Container does not expose a runtime: incompatible container implementation.");
|
|
118
|
+
}
|
|
119
|
+
return container.runtime;
|
|
120
|
+
}
|
|
121
|
+
close() {
|
|
122
|
+
// TODO: `container.close()` cancels the container runtime's GC timers, but a couple of
|
|
123
|
+
// container-level timers are only bounded `setTimeout`s that survive close (they are not
|
|
124
|
+
// cancelled here, nor even on `dispose`):
|
|
125
|
+
// - The container-loader `NoopHeuristic` timer (~2s), which has no disposal hook.
|
|
126
|
+
// - The container-runtime `SummaryManager` "delay before creating summarizer" timer, whose
|
|
127
|
+
// pending timeout is not cleared when the SummaryManager is torn down.
|
|
128
|
+
// These self-expire, so they do not cause indefinite hangs, but until they fire they keep the
|
|
129
|
+
// Node.js event loop alive, delaying a clean process exit after close. That is a common reason
|
|
130
|
+
// tests resort to Mocha's `--exit` flag. Ideally close() (via the runtime's close path) would
|
|
131
|
+
// cancel these too so that closing a single container is sufficient to release all its timers.
|
|
132
|
+
this.container.close();
|
|
133
|
+
}
|
|
134
|
+
async createDataStore(key) {
|
|
135
|
+
const kind = await (0, internal_4.lookupInRegistry)(this.registry, key);
|
|
136
|
+
DataStoreKindImplementation.narrowGeneric(kind);
|
|
137
|
+
const containerRuntime = this.getRuntime();
|
|
138
|
+
// TODO: There should probably be a higher level more type safe way to do this.
|
|
139
|
+
const context = containerRuntime.createDetachedDataStore([kind.type]);
|
|
140
|
+
const channel = await kind.instantiateDataStore(context, false);
|
|
141
|
+
const dataStore = await context.attachRuntime(kind, channel);
|
|
142
|
+
const entryPoint = await dataStore.entryPoint.get();
|
|
143
|
+
// The data store's entry point type is erased at the registry boundary;
|
|
144
|
+
// the DataStoreKind<T> used to create it guarantees the entry point is a T.
|
|
145
|
+
return entryPoint;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.ServiceContainerBase = ServiceContainerBase;
|
|
149
|
+
/**
|
|
150
|
+
* Gets the {@link Audience} from a Fluid container
|
|
151
|
+
* created by any {@link @fluidframework/driver-definitions#ServiceClient}.
|
|
152
|
+
* @privateRemarks
|
|
153
|
+
* This is exposed via a free function rather than as a property of FluidContainerAttached
|
|
154
|
+
* for a few minor reasons:
|
|
155
|
+
* 1. This allows stabilizing the FluidContainerAttached API independently committing to how we want to expose the audience.
|
|
156
|
+
* 2. This demonstrates the pattern of how we can have possible less stable APIs to expose service specific features without them being part of the core FluidContainer API.
|
|
157
|
+
* This will be important for both new feature stabilization, and also exposing anything needed for legacy interop.
|
|
158
|
+
* @alpha
|
|
159
|
+
*/
|
|
160
|
+
function getContainerAudience(container) {
|
|
161
|
+
ServiceContainerBase.narrow(container);
|
|
162
|
+
return container.audience;
|
|
163
|
+
}
|
|
164
|
+
exports.getContainerAudience = getContainerAudience;
|
|
165
|
+
//# sourceMappingURL=serviceClientBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceClientBase.js","sourceRoot":"","sources":["../src/serviceClientBase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6EAA8F;AAE9F,uEAAoF;AACpF,kEAA6D;AAC7D,0EAOqD;AAOrD,uEAAsE;AAEtE;;GAEG;AAEH;;;GAGG;AACH,MAAa,2BACZ,SAAQ,mCAA0C;IAGlD;;OAEG;IACI,MAAM,CAAC,KAAK,CAClB,KAAQ;QAER,OAAO,KAAK,YAAY,2BAA2B,CAAC;IACrD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,aAAa,CAC1B,KAAQ;QAKR,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAOD,YACkB,OAGhB;QAED,KAAK,EAAE,CAAC;QALS,YAAO,GAAP,OAAO,CAGvB;QAGD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,OAAO,CAAC,eAAe,K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F,yFAAyF;QACzF,0CAA0C;QAC1C,kFAAkF;QAClF,2FAA2F;QAC3F,yEAAyE;QACzE,8FAA8F;QAC9F,+FAA+F;QAC/F,8FAA8F;QAC9F,+FAA+F;QAC/F,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEM,KAAK,CAAC,eAAe,CAAI,GAAoB;QACnD,MAAM,IAAI,GAAG,MAAM,IAAA,2BAAgB,EAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACxD,2BAA2B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAE3C,+EAA+E;QAC/E,MAAM,OAAO,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAChE,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7D,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;QACpD,wEAAwE;QACxE,4EAA4E;QAC5E,OAAO,UAAe,CAAC;IACxB,CAAC;CACD;AAtHD,oDAsHC;AAeD;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAAC,SAAiC;IACrE,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,SAAS,CAAC,QAAQ,CAAC;AAC3B,CAAC;AAHD,oDAGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport { AttachState, type IContainer } from \"@fluidframework/container-definitions/internal\";\nimport type { IRequest } from \"@fluidframework/core-interfaces\";\nimport { ErasedTypeImplementation } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype DataStoreKey,\n\ttype DataStoreKind,\n\ttype FluidContainerAttached,\n\ttype FluidContainerWithService,\n\ttype Registry,\n\tlookupInRegistry,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIContainerRuntimeBase,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\n/*\n * This file provides common implementation logic for ServiceClient implementations.\n */\n\n/**\n * Implementation of `DataStoreKind`.\n * @internal\n */\nexport class DataStoreKindImplementation<T>\n\textends ErasedTypeImplementation<DataStoreKind<T>>\n\timplements DataStoreKind<T>, IFluidDataStoreFactory\n{\n\t/**\n\t * Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.\n\t */\n\tpublic static guard<T>(\n\t\tvalue: T,\n\t): value is DataStoreKindImplementation<T extends DataStoreKind<infer T2> ? T2 : never> & T {\n\t\treturn value instanceof DataStoreKindImplementation;\n\t}\n\n\t/**\n\t * Type guard for narrowing unions which contain DataStoreKind<T> to DataStoreKind<T>.\n\t */\n\tpublic static narrowGeneric<T>(\n\t\tvalue: T,\n\t): asserts value is DataStoreKindImplementation<\n\t\tT extends DataStoreKind<infer T2> ? T2 : never\n\t> &\n\t\tT {\n\t\tif (!DataStoreKindImplementation.guard(value)) {\n\t\t\tthrow new Error(\"Invalid DataStoreKindImplementation\");\n\t\t}\n\t}\n\n\tpublic readonly type: string;\n\tpublic readonly createDataStore?: (context: IFluidDataStoreContext) => {\n\t\treadonly runtime: IFluidDataStoreChannel;\n\t};\n\n\tpublic constructor(\n\t\tprivate readonly factory: Pick<\n\t\t\tDataStoreKindImplementation<T>,\n\t\t\t\"type\" | \"instantiateDataStore\" | \"createDataStore\"\n\t\t>,\n\t) {\n\t\tsuper();\n\t\tthis.type = factory.type;\n\t\tif (factory.createDataStore !== undefined) {\n\t\t\tthis.createDataStore = factory.createDataStore.bind(factory);\n\t\t}\n\t}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\treturn this.factory.instantiateDataStore(context, existing);\n\t}\n\n\tpublic get IFluidDataStoreFactory(): IFluidDataStoreFactory {\n\t\treturn this;\n\t}\n\n\tpublic async adapt(value: Promise<DataStoreKind>): Promise<DataStoreKind<T>> {\n\t\tconst input = await value;\n\t\tif (input === this) {\n\t\t\treturn this;\n\t\t}\n\t\tif (input.type === this.type) {\n\t\t\tthrow new UsageError(`Conflicting DataStoreKinds with same type: ${this.type}`);\n\t\t}\n\t\tthrow new UsageError(\n\t\t\t`Mismatched DataStoreKind type. Expected: ${this.type}, got: ${input.type}`,\n\t\t);\n\t}\n}\n\n/**\n * Shared base class for all `ServiceClient` container implementations.\n *\n * @remarks\n * Extends `ErasedTypeImplementation` so that\n * {@link getContainerAudience} can narrow via `ServiceContainerBase.narrow()`.\n *\n * @internal\n */\nexport abstract class ServiceContainerBase<TData, TOptions = unknown>\n\textends ErasedTypeImplementation<FluidContainerWithService<TData>>\n\timplements FluidContainerWithService<TData>\n{\n\t/**\n\t * True if an attempt to attach has been started. This is used to prevent multiple concurrent attach attempts.\n\t */\n\tprivate startedAttach = false;\n\n\tprotected constructor(\n\t\tpublic readonly registry: Registry<Promise<DataStoreKind<TData>>>,\n\t\tpublic readonly options: TOptions,\n\t\tpublic readonly container: IContainer,\n\t\tpublic readonly data: TData,\n\t\tpublic id: string | undefined,\n\t) {\n\t\tsuper();\n\t}\n\n\t/**\n\t * Creates the service-specific request used to attach this container.\n\t * @remarks\n\t * Called by {@link ServiceContainerBase.attach} after validating that no attach is already in progress.\n\t */\n\tprotected abstract createAttachRequest(): IRequest;\n\n\t/**\n\t * Extracts the container ID from {@link ServiceContainerBase.container}'s resolved URL after attachment.\n\t * @remarks\n\t * Override when the service's resolved URL stores the id in a non-standard field.\n\t */\n\tprotected getContainerId(): string {\n\t\tif (this.container.resolvedUrl === undefined) {\n\t\t\tthrow new Error(\"Resolved URL unexpectedly missing!\");\n\t\t}\n\t\treturn this.container.resolvedUrl.id;\n\t}\n\n\tpublic async attach(): Promise<FluidContainerAttached<TData>> {\n\t\tif (this.id !== undefined) {\n\t\t\tthrow new UsageError(\"Container already attached\");\n\t\t}\n\t\tif (this.startedAttach) {\n\t\t\tthrow new UsageError(\"Container attach already in progress\");\n\t\t}\n\n\t\tassert(\n\t\t\tthis.container.attachState === AttachState.Detached,\n\t\t\t0xd15 /* Container not detached */,\n\t\t);\n\t\tthis.startedAttach = true;\n\n\t\t// TODO: support setting where attach can fail, and leave the container in a valid (non-closed) state.\n\t\t// Likely the best way to support this is by adding a `tryAttach(request): Promise<FluidContainerAttached<TData> | undefined>`.\n\n\t\tawait this.container.attach(this.createAttachRequest());\n\t\t// This type cast is needed to work around the fact that TypeScript assumes the \"attach\" methods can't modify \"attachState\".\n\t\tassert(\n\t\t\tthis.container.attachState === (AttachState.Attached as AttachState),\n\t\t\t0xd16 /* Container failed to attach */,\n\t\t);\n\t\tthis.id = this.getContainerId();\n\t\treturn this as typeof this & { id: string };\n\t}\n\n\tpublic get audience(): IAudience {\n\t\treturn this.container.audience;\n\t}\n\n\tpublic getRuntime(): IContainerRuntimeBase {\n\t\t// The runtime is not part of the public IContainer surface, so it is reached via a structural cast.\n\t\t// This relies on an implementation detail of the containers produced by the loader\n\t\t// (createDetachedContainer / loadExistingContainer): they carry a `runtime` property.\n\t\t// The undefined guard below turns an incompatible container implementation into a clear error\n\t\t// instead of a confusing failure later when the missing runtime is used.\n\t\t// This is extra risky since IContainer is not marked sealed.\n\t\t// TODO: Replace this with a supported, type-safe accessor once the loader exposes one.\n\t\tinterface IContainerWithRuntime extends IContainer {\n\t\t\treadonly runtime?: IContainerRuntimeBase;\n\t\t}\n\n\t\tconst container = this.container as IContainerWithRuntime;\n\t\tif (container.runtime === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Container does not expose a runtime: incompatible container implementation.\",\n\t\t\t);\n\t\t}\n\t\treturn container.runtime;\n\t}\n\n\tpublic close(): void {\n\t\t// TODO: `container.close()` cancels the container runtime's GC timers, but a couple of\n\t\t// container-level timers are only bounded `setTimeout`s that survive close (they are not\n\t\t// cancelled here, nor even on `dispose`):\n\t\t// - The container-loader `NoopHeuristic` timer (~2s), which has no disposal hook.\n\t\t// - The container-runtime `SummaryManager` \"delay before creating summarizer\" timer, whose\n\t\t// pending timeout is not cleared when the SummaryManager is torn down.\n\t\t// These self-expire, so they do not cause indefinite hangs, but until they fire they keep the\n\t\t// Node.js event loop alive, delaying a clean process exit after close. That is a common reason\n\t\t// tests resort to Mocha's `--exit` flag. Ideally close() (via the runtime's close path) would\n\t\t// cancel these too so that closing a single container is sufficient to release all its timers.\n\t\tthis.container.close();\n\t}\n\n\tpublic async createDataStore<T>(key: DataStoreKey<T>): Promise<T> {\n\t\tconst kind = await lookupInRegistry(this.registry, key);\n\t\tDataStoreKindImplementation.narrowGeneric(kind);\n\t\tconst containerRuntime = this.getRuntime();\n\n\t\t// TODO: There should probably be a higher level more type safe way to do this.\n\t\tconst context = containerRuntime.createDetachedDataStore([kind.type]);\n\t\tconst channel = await kind.instantiateDataStore(context, false);\n\t\tconst dataStore = await context.attachRuntime(kind, channel);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\t// The data store's entry point type is erased at the registry boundary;\n\t\t// the DataStoreKind<T> used to create it guarantees the entry point is a T.\n\t\treturn entryPoint as T;\n\t}\n}\n\n/**\n * All clients connected to the op stream, both read-only and read/write.\n * @remarks\n * Currently just {@link @fluidframework/container-definitions#IAudience}, but may diverge before stabilizing.\n * @privateRemarks\n * This is currently just an alias for IAudience, but it is defined separately to allow for:\n * 1. Following the no I prefix naming convention.\n * 2. The possibility of diverging from IAudience in the future if desired.\n * 3. Make it easy for the reexport from fluid-framework to be `@alpha` so the name is not locked down prematurely.\n * @sealed @alpha\n */\nexport type Audience = IAudience;\n\n/**\n * Gets the {@link Audience} from a Fluid container\n * created by any {@link @fluidframework/driver-definitions#ServiceClient}.\n * @privateRemarks\n * This is exposed via a free function rather than as a property of FluidContainerAttached\n * for a few minor reasons:\n * 1. This allows stabilizing the FluidContainerAttached API independently committing to how we want to expose the audience.\n * 2. This demonstrates the pattern of how we can have possible less stable APIs to expose service specific features without them being part of the core FluidContainer API.\n * This will be important for both new feature stabilization, and also exposing anything needed for legacy interop.\n * @alpha\n */\nexport function getContainerAudience(container: FluidContainerAttached): Audience {\n\tServiceContainerBase.narrow(container);\n\treturn container.audience;\n}\n"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { ICodeDetailsLoader, IContainerContext, IRuntime } from "@fluidframework/container-definitions/internal";
|
|
6
|
+
import type { FluidObject } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { type DataStoreKey, type DataStoreKind, type DataStoreRegistry, type FluidContainerAttached, type FluidContainerWithService, type Registry, type ServiceClient } from "@fluidframework/driver-definitions/internal";
|
|
8
|
+
import type { IContainerRuntimeBase, IFluidDataStoreRegistry, MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal";
|
|
9
|
+
/**
|
|
10
|
+
* The constant ID used for the root data store alias in service containers.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const rootDataStoreId = "root";
|
|
14
|
+
/**
|
|
15
|
+
* Converts a `DataStoreRegistry` to the `IFluidDataStoreRegistry` interface expected by the container runtime.
|
|
16
|
+
* @remarks
|
|
17
|
+
* This does not leverage the ability for `IFluidDataStoreRegistry.get` to return undefined.
|
|
18
|
+
* Note that all use-cases of `IFluidDataStoreRegistry.get` returning undefined currently end up as a fatal error.
|
|
19
|
+
* Therefore it should be fine for the error to instead be thrown by the registry function, which is what this function does.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare function convertRegistry<T>(registry: DataStoreRegistry<T>): IFluidDataStoreRegistry;
|
|
23
|
+
/**
|
|
24
|
+
* Normalizes a `DataStoreKind` or registry function into a registry function.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare function normalizeRegistry<T>(input: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>): Registry<Promise<DataStoreKind<T>>>;
|
|
28
|
+
/**
|
|
29
|
+
* Parameters passed to a {@link ContainerRuntimeLoader}.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export interface ContainerRuntimeLoaderParams {
|
|
33
|
+
context: IContainerContext;
|
|
34
|
+
registry: IFluidDataStoreRegistry;
|
|
35
|
+
provideEntryPoint: (runtime: IContainerRuntimeBase) => Promise<FluidObject>;
|
|
36
|
+
existing: boolean;
|
|
37
|
+
minVersionForCollab: MinimumVersionForCollab;
|
|
38
|
+
/**
|
|
39
|
+
* The type string of the root data store to create. Only set when `existing` is false.
|
|
40
|
+
*/
|
|
41
|
+
newContainerRootType: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A service-specific callback that creates or loads the container runtime.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Receives the runtime parameters assembled by {@link makeCodeLoader} and is responsible for
|
|
48
|
+
* calling the concrete runtime factory (e.g. `ContainerRuntime.loadRuntime2`) and, when
|
|
49
|
+
* `existing` is `false`, initializing the root data store before returning.
|
|
50
|
+
*
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export type ContainerRuntimeLoader = (parameters: ContainerRuntimeLoaderParams) => Promise<IRuntime>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates an `ICodeDetailsLoader` that wires up the container runtime via the supplied
|
|
56
|
+
* `loadRuntime` callback.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* The `loadRuntime` callback is responsible for invoking the concrete runtime factory and,
|
|
60
|
+
* when `parameters.existing` is `false` and `parameters.newContainerRootType` is set, creating and
|
|
61
|
+
* aliasing the root data store.
|
|
62
|
+
*
|
|
63
|
+
* This loader never does any code loading, and always assumes it is compatible.
|
|
64
|
+
* TODO: We should reevaluate this before promoting ServiceClient APIs to beta.
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export declare function makeCodeLoader<T>(registry: DataStoreRegistry<T>, minVersionForCollab: MinimumVersionForCollab, loadRuntime: ContainerRuntimeLoader, root?: DataStoreKind<T>): ICodeDetailsLoader;
|
|
69
|
+
/**
|
|
70
|
+
* Minimal interface for the static container factory methods used by {@link ServiceClientImplementation}.
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
export interface ServiceContainerStatics<TOptions> {
|
|
74
|
+
createDetached<T>(registry: DataStoreRegistry<T>, options: TOptions, root: DataStoreKind<T>): Promise<FluidContainerWithService<T>>;
|
|
75
|
+
load<T>(registry: DataStoreRegistry<T>, options: TOptions, id: string): Promise<FluidContainerAttached<T>>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates a {@link @fluidframework/driver-definitions#ServiceClient} that delegates container
|
|
79
|
+
* creation and loading to the supplied container class statics.
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export declare class ServiceClientImplementation<TOptions> implements ServiceClient {
|
|
83
|
+
private readonly options;
|
|
84
|
+
private readonly statics;
|
|
85
|
+
constructor(options: TOptions, statics: ServiceContainerStatics<TOptions>);
|
|
86
|
+
createContainer<T>(root: DataStoreKind<T>): Promise<FluidContainerWithService<T>>;
|
|
87
|
+
createContainer<T>(root: DataStoreKey<T>, registry: Registry<Promise<DataStoreKind>>): Promise<FluidContainerWithService<T>>;
|
|
88
|
+
loadContainer<T>(id: string, root: DataStoreKind<T> | Registry<Promise<DataStoreKind<T>>>): Promise<FluidContainerAttached<T>>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=serviceClientUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceClientUtils.d.ts","sourceRoot":"","sources":["../src/serviceClientUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,iBAAiB,EAIjB,QAAQ,EAER,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,QAAQ,EAEb,KAAK,aAAa,EAClB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAEX,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,MAAM,8CAA8C,CAAC;AAItD;;;GAGG;AACH,eAAO,MAAM,eAAe,SAAS,CAAC;AAEtC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,uBAAuB,CAW1F;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAClC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GAC3D,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAMrC;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC5C,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,EAAE,uBAAuB,CAAC;IAClC,iBAAiB,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAC5E,QAAQ,EAAE,OAAO,C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