@fluidframework/shared-object-base 2.40.0-336023 → 2.40.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 +14 -0
- package/api-report/shared-object-base.legacy.alpha.api.md +1 -0
- package/dist/gcHandleVisitor.d.ts +1 -1
- package/dist/gcHandleVisitor.d.ts.map +1 -1
- package/dist/gcHandleVisitor.js +1 -1
- package/dist/gcHandleVisitor.js.map +1 -1
- package/dist/handle.d.ts +21 -1
- package/dist/handle.d.ts.map +1 -1
- package/dist/handle.js +10 -1
- package/dist/handle.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- 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/serializer.d.ts +3 -2
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +4 -2
- package/dist/serializer.js.map +1 -1
- package/dist/sharedObject.d.ts +11 -0
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +39 -6
- package/dist/sharedObject.js.map +1 -1
- package/dist/sharedObjectKernel.d.ts +186 -0
- package/dist/sharedObjectKernel.d.ts.map +1 -0
- package/dist/sharedObjectKernel.js +227 -0
- package/dist/sharedObjectKernel.js.map +1 -0
- package/lib/gcHandleVisitor.d.ts +1 -1
- package/lib/gcHandleVisitor.d.ts.map +1 -1
- package/lib/gcHandleVisitor.js +1 -1
- package/lib/gcHandleVisitor.js.map +1 -1
- package/lib/handle.d.ts +21 -1
- package/lib/handle.d.ts.map +1 -1
- package/lib/handle.js +8 -0
- package/lib/handle.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- 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/serializer.d.ts +3 -2
- package/lib/serializer.d.ts.map +1 -1
- package/lib/serializer.js +4 -2
- package/lib/serializer.js.map +1 -1
- package/lib/sharedObject.d.ts +11 -0
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +40 -7
- package/lib/sharedObject.js.map +1 -1
- package/lib/sharedObjectKernel.d.ts +186 -0
- package/lib/sharedObjectKernel.d.ts.map +1 -0
- package/lib/sharedObjectKernel.js +222 -0
- package/lib/sharedObjectKernel.js.map +1 -0
- package/package.json +15 -14
- package/src/gcHandleVisitor.ts +1 -4
- package/src/handle.ts +29 -1
- package/src/index.ts +11 -0
- package/src/packageVersion.ts +1 -1
- package/src/serializer.ts +7 -4
- package/src/sharedObject.ts +42 -5
- package/src/sharedObjectKernel.ts +467 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @fluidframework/shared-object-base
|
|
2
2
|
|
|
3
|
+
## 2.40.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- IFluidHandleInternal.bind has been deprecated ([#24553](https://github.com/microsoft/FluidFramework/pull/24553)) [8a4362a7ed](https://github.com/microsoft/FluidFramework/commit/8a4362a7edef3a97fee13c9d23bea49448ba2a6a)
|
|
8
|
+
|
|
9
|
+
Handle binding is an internal concept used to make sure objects attach to the Container graph when their handle is stored in a DDS which is itself attached.
|
|
10
|
+
The source of the "bind" operation has been assumed to be any handle, but only one implementation is actually supported (`SharedObjectHandle`, not exported itself).
|
|
11
|
+
|
|
12
|
+
So the `bind` function is now deprecated on the `IFluidHandleInterface`, moving instead to internal types supporting the one valid implementation.
|
|
13
|
+
It's also deprecated on the various exported handle implementations that don't support it (each is either no-op, pass-through, or throwing).
|
|
14
|
+
|
|
15
|
+
No replacement is offered, this API was never meant to be called from outside of the Fluid Framework.
|
|
16
|
+
|
|
3
17
|
## 2.33.0
|
|
4
18
|
|
|
5
19
|
Dependency updates only.
|
|
@@ -84,6 +84,7 @@ export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISha
|
|
|
84
84
|
protected abstract processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
|
|
85
85
|
protected processMessagesCore?(messagesCollection: IRuntimeMessageCollection): void;
|
|
86
86
|
protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
|
|
87
|
+
protected reSubmitSquashed(content: unknown, localOpMetadata: unknown): void;
|
|
87
88
|
protected rollback(content: unknown, localOpMetadata: unknown): void;
|
|
88
89
|
protected runtime: IFluidDataStoreRuntime;
|
|
89
90
|
protected abstract get serializer(): IFluidSerializer;
|
|
@@ -14,6 +14,6 @@ import { FluidSerializer } from "./serializer.js";
|
|
|
14
14
|
export declare class GCHandleVisitor extends FluidSerializer {
|
|
15
15
|
private readonly visitedHandlePaths;
|
|
16
16
|
getVisitedHandlePaths(): string[];
|
|
17
|
-
protected bindAndEncodeHandle(handle: IFluidHandleInternal
|
|
17
|
+
protected bindAndEncodeHandle(handle: IFluidHandleInternal): ISerializedHandle;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=gcHandleVisitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcHandleVisitor.d.ts","sourceRoot":"","sources":["../src/gcHandleVisitor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,eAAe;IACnD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA0B;IACtD,qBAAqB,IAAI,MAAM,EAAE;IAIxC,SAAS,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"gcHandleVisitor.d.ts","sourceRoot":"","sources":["../src/gcHandleVisitor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,eAAe;IACnD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA0B;IACtD,qBAAqB,IAAI,MAAM,EAAE;IAIxC,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,GAAG,iBAAiB;CAU9E"}
|
package/dist/gcHandleVisitor.js
CHANGED
|
@@ -20,7 +20,7 @@ class GCHandleVisitor extends serializer_js_1.FluidSerializer {
|
|
|
20
20
|
getVisitedHandlePaths() {
|
|
21
21
|
return [...this.visitedHandlePaths];
|
|
22
22
|
}
|
|
23
|
-
bindAndEncodeHandle(handle
|
|
23
|
+
bindAndEncodeHandle(handle) {
|
|
24
24
|
this.visitedHandlePaths.add(handle.absolutePath);
|
|
25
25
|
// Just return a dummy value. The serialization itself is not used.
|
|
26
26
|
// It's especially important we don't bind since that has side effects that are irrelevant to GC.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcHandleVisitor.js","sourceRoot":"","sources":["../src/gcHandleVisitor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,mDAAkD;AAElD;;;;;GAKG;AACH,MAAa,eAAgB,SAAQ,+BAAe;IAApD;;QACkB,uBAAkB,GAAgB,IAAI,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"gcHandleVisitor.js","sourceRoot":"","sources":["../src/gcHandleVisitor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,mDAAkD;AAElD;;;;;GAKG;AACH,MAAa,eAAgB,SAAQ,+BAAe;IAApD;;QACkB,uBAAkB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAe9D,CAAC;IAdO,qBAAqB;QAC3B,OAAO,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAES,mBAAmB,CAAC,MAA4B;QACzD,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAEjD,mEAAmE;QACnE,iGAAiG;QACjG,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,8BAA8B;SACnC,CAAC;IACH,CAAC;CACD;AAhBD,0CAgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { type ISerializedHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport { FluidSerializer } from \"./serializer.js\";\n\n/**\n * Implementation of IFluidSerializer used by GC to visit all the handles in the DDS to collect its outbound routes\n *\n * @remarks - This is given to DDS code that typically produces a serialization of the data, which is then ignored.\n * All that is needed is getSerializedRoutes() to get the routes. This strategy could be optimized if needed.\n */\nexport class GCHandleVisitor extends FluidSerializer {\n\tprivate readonly visitedHandlePaths: Set<string> = new Set();\n\tpublic getVisitedHandlePaths(): string[] {\n\t\treturn [...this.visitedHandlePaths];\n\t}\n\n\tprotected bindAndEncodeHandle(handle: IFluidHandleInternal): ISerializedHandle {\n\t\tthis.visitedHandlePaths.add(handle.absolutePath);\n\n\t\t// Just return a dummy value. The serialization itself is not used.\n\t\t// It's especially important we don't bind since that has side effects that are irrelevant to GC.\n\t\treturn {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: \"UNUSED (see GCHandleVisitor)\",\n\t\t};\n\t}\n}\n"]}
|
package/dist/handle.d.ts
CHANGED
|
@@ -6,6 +6,26 @@ import { type IFluidHandleInternal } from "@fluidframework/core-interfaces/inter
|
|
|
6
6
|
import { FluidObjectHandle } from "@fluidframework/datastore/internal";
|
|
7
7
|
import type { IFluidDataStoreRuntimeExperimental } from "@fluidframework/datastore-definitions/internal";
|
|
8
8
|
import { ISharedObject } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Handle for a shared object. See also {@link SharedObjectHandle}.
|
|
11
|
+
* Supports binding other handles to the underlying Shared Object (see {@link ISharedObjectHandle.bind}).
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export interface ISharedObjectHandle extends IFluidHandleInternal<ISharedObject> {
|
|
16
|
+
/**
|
|
17
|
+
* Binds the given handle to this DDS or attach the given handle if this DDS is attached.
|
|
18
|
+
* A bound handle will also be attached once this DDS is attached.
|
|
19
|
+
*
|
|
20
|
+
* @param handle - The target handle to bind to this DDS
|
|
21
|
+
*/
|
|
22
|
+
bind(handle: IFluidHandleInternal): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Type guard for {@link ISharedObjectHandle}.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function isISharedObjectHandle(handle: unknown): handle is ISharedObjectHandle;
|
|
9
29
|
/**
|
|
10
30
|
* Handle for a shared object.
|
|
11
31
|
*
|
|
@@ -17,7 +37,7 @@ import { ISharedObject } from "./types.js";
|
|
|
17
37
|
* {@link @fluidframework/datastore#FluidDataStoreRuntime.request} recognizes requests in the form of
|
|
18
38
|
* '/\<shared object id\>' and loads shared object.
|
|
19
39
|
*/
|
|
20
|
-
export declare class SharedObjectHandle extends FluidObjectHandle<ISharedObject> {
|
|
40
|
+
export declare class SharedObjectHandle extends FluidObjectHandle<ISharedObject> implements ISharedObjectHandle {
|
|
21
41
|
protected readonly value: ISharedObject;
|
|
22
42
|
private readonly runtime;
|
|
23
43
|
/**
|
package/dist/handle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src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,17 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.SharedObjectHandle = void 0;
|
|
7
|
+
exports.SharedObjectHandle = exports.isISharedObjectHandle = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/datastore/internal");
|
|
9
|
+
const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
10
|
+
/**
|
|
11
|
+
* Type guard for {@link ISharedObjectHandle}.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
function isISharedObjectHandle(handle) {
|
|
15
|
+
return (0, runtime_utils_1.isFluidHandle)(handle) && typeof handle.bind === "function";
|
|
16
|
+
}
|
|
17
|
+
exports.isISharedObjectHandle = isISharedObjectHandle;
|
|
9
18
|
/**
|
|
10
19
|
* Handle for a shared object.
|
|
11
20
|
*
|
package/dist/handle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAAuE;
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAAuE;AAGvE,iEAA8D;AAoB9D;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,MAAe;IACpD,OAAO,IAAA,6BAAa,EAAC,MAAM,CAAC,IAAI,OAAQ,MAA8B,CAAC,IAAI,KAAK,UAAU,CAAC;AAC5F,CAAC;AAFD,sDAEC;AAED;;;;;;;;;;GAUG;AACH,MAAa,kBACZ,SAAQ,4BAAgC;IAGxC;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,YACoB,KAAoB,EACvC,IAAY;IACZ,gDAAgD;IAC/B,OAA2C;QAE5D,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAL7B,UAAK,GAAL,KAAK,CAAe;QAGtB,YAAO,GAAP,OAAO,CAAoC;IAG7D,CAAC;IAED;;;OAGG;IACI,WAAW;QACjB,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC3B,KAAK,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAEM,IAAI,CAAC,MAA4B;QACvC,mFAAmF;QACnF,8GAA8G;QAC9G,wEAAwE;QACxE,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YACzC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;IACF,CAAC;CACD;AA5CD,gDA4CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore/internal\";\n// eslint-disable-next-line import/no-deprecated\nimport type { IFluidDataStoreRuntimeExperimental } from \"@fluidframework/datastore-definitions/internal\";\nimport { isFluidHandle } from \"@fluidframework/runtime-utils\";\n\nimport { ISharedObject } from \"./types.js\";\n\n/**\n * Handle for a shared object. See also {@link SharedObjectHandle}.\n * Supports binding other handles to the underlying Shared Object (see {@link ISharedObjectHandle.bind}).\n *\n * @internal\n */\nexport interface ISharedObjectHandle extends IFluidHandleInternal<ISharedObject> {\n\t/**\n\t * Binds the given handle to this DDS or attach the given handle if this DDS is attached.\n\t * A bound handle will also be attached once this DDS is attached.\n\t *\n\t * @param handle - The target handle to bind to this DDS\n\t */\n\tbind(handle: IFluidHandleInternal): void;\n}\n\n/**\n * Type guard for {@link ISharedObjectHandle}.\n * @internal\n */\nexport function isISharedObjectHandle(handle: unknown): handle is ISharedObjectHandle {\n\treturn isFluidHandle(handle) && typeof (handle as ISharedObjectHandle).bind === \"function\";\n}\n\n/**\n * Handle for a shared object.\n *\n * @remarks\n *\n * This object is used for already loaded (in-memory) shared objects and is used only for serialization purposes.\n *\n * De-serialization process goes through {@link @fluidframework/datastore#FluidObjectHandle}, and request flow:\n * {@link @fluidframework/datastore#FluidDataStoreRuntime.request} recognizes requests in the form of\n * '/\\<shared object id\\>' and loads shared object.\n */\nexport class SharedObjectHandle\n\textends FluidObjectHandle<ISharedObject>\n\timplements ISharedObjectHandle\n{\n\t/**\n\t * Whether services have been attached for the associated shared object.\n\t */\n\tpublic get isAttached(): boolean {\n\t\treturn this.value.isAttached();\n\t}\n\n\t/**\n\t * Creates a new SharedObjectHandle.\n\t * @param value - The shared object this handle is for.\n\t * @param path - The id of the shared object. It is also the path to this object relative to the routeContext.\n\t * @param routeContext - The parent {@link @fluidframework/core-interfaces#IFluidHandleContext} that has a route\n\t * to this handle.\n\t */\n\tconstructor(\n\t\tprotected readonly value: ISharedObject,\n\t\tpath: string,\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\tprivate readonly runtime: IFluidDataStoreRuntimeExperimental,\n\t) {\n\t\tsuper(value, path, runtime.IFluidHandleContext);\n\t}\n\n\t/**\n\t * Attaches all bound handles first (which may in turn attach further handles), then attaches this handle.\n\t * When attaching the handle, it registers the associated shared object.\n\t */\n\tpublic attachGraph(): void {\n\t\tthis.value.bindToContext();\n\t\tsuper.attachGraph();\n\t}\n\n\tpublic bind(handle: IFluidHandleInternal): void {\n\t\t// We don't bind handles in staging mode to defer the attachment of any new objects\n\t\t// until we've exited staging mode. This way if we discard changes or a new handle is not present in the final\n\t\t// committed state, we will never end up attaching the discarded object.\n\t\tif (this.runtime.inStagingMode !== true) {\n\t\t\tsuper.bind(handle);\n\t\t}\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
export { ISharedObjectHandle, isISharedObjectHandle } from "./handle.js";
|
|
5
6
|
export { FluidSerializer, IFluidSerializer } from "./serializer.js";
|
|
6
7
|
export { SharedObject, SharedObjectCore, ISharedObjectKind, SharedObjectKind, createSharedObjectKind, } from "./sharedObject.js";
|
|
7
8
|
export { ISharedObject, ISharedObjectEvents } from "./types.js";
|
|
8
9
|
export { createSingleBlobSummary, makeHandlesSerializable, parseHandles, serializeHandles, bindHandles, type IChannelView, } from "./utils.js";
|
|
9
10
|
export { ValueType } from "./valueType.js";
|
|
11
|
+
export { SharedKernel, thisWrap, KernelArgs, makeSharedObjectKind, SharedKernelFactory, FactoryOut, SharedObjectOptions, mergeAPIs, } from "./sharedObjectKernel.js";
|
|
10
12
|
//# 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,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EACN,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,KAAK,YAAY,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EACN,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,KAAK,YAAY,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACN,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,mBAAmB,EACnB,SAAS,GACT,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ValueType = exports.bindHandles = exports.serializeHandles = exports.parseHandles = exports.makeHandlesSerializable = exports.createSingleBlobSummary = exports.createSharedObjectKind = exports.SharedObjectCore = exports.SharedObject = exports.FluidSerializer = void 0;
|
|
7
|
+
exports.mergeAPIs = exports.makeSharedObjectKind = exports.thisWrap = exports.ValueType = exports.bindHandles = exports.serializeHandles = exports.parseHandles = exports.makeHandlesSerializable = exports.createSingleBlobSummary = exports.createSharedObjectKind = exports.SharedObjectCore = exports.SharedObject = exports.FluidSerializer = exports.isISharedObjectHandle = void 0;
|
|
8
|
+
var handle_js_1 = require("./handle.js");
|
|
9
|
+
Object.defineProperty(exports, "isISharedObjectHandle", { enumerable: true, get: function () { return handle_js_1.isISharedObjectHandle; } });
|
|
8
10
|
var serializer_js_1 = require("./serializer.js");
|
|
9
11
|
Object.defineProperty(exports, "FluidSerializer", { enumerable: true, get: function () { return serializer_js_1.FluidSerializer; } });
|
|
10
12
|
var sharedObject_js_1 = require("./sharedObject.js");
|
|
@@ -19,4 +21,8 @@ Object.defineProperty(exports, "serializeHandles", { enumerable: true, get: func
|
|
|
19
21
|
Object.defineProperty(exports, "bindHandles", { enumerable: true, get: function () { return utils_js_1.bindHandles; } });
|
|
20
22
|
var valueType_js_1 = require("./valueType.js");
|
|
21
23
|
Object.defineProperty(exports, "ValueType", { enumerable: true, get: function () { return valueType_js_1.ValueType; } });
|
|
24
|
+
var sharedObjectKernel_js_1 = require("./sharedObjectKernel.js");
|
|
25
|
+
Object.defineProperty(exports, "thisWrap", { enumerable: true, get: function () { return sharedObjectKernel_js_1.thisWrap; } });
|
|
26
|
+
Object.defineProperty(exports, "makeSharedObjectKind", { enumerable: true, get: function () { return sharedObjectKernel_js_1.makeSharedObjectKind; } });
|
|
27
|
+
Object.defineProperty(exports, "mergeAPIs", { enumerable: true, get: function () { return sharedObjectKernel_js_1.mergeAPIs; } });
|
|
22
28
|
//# 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,iDAAoE;AAA3D,gHAAA,eAAe,OAAA;AACxB,qDAM2B;AAL1B,+GAAA,YAAY,OAAA;AACZ,mHAAA,gBAAgB,OAAA;AAGhB,yHAAA,sBAAsB,OAAA;AAGvB,uCAOoB;AANnB,mHAAA,uBAAuB,OAAA;AACvB,mHAAA,uBAAuB,OAAA;AACvB,wGAAA,YAAY,OAAA;AACZ,4GAAA,gBAAgB,OAAA;AAChB,uGAAA,WAAW,OAAA;AAGZ,+CAA2C;AAAlC,yGAAA,SAAS,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { FluidSerializer, IFluidSerializer } from \"./serializer.js\";\nexport {\n\tSharedObject,\n\tSharedObjectCore,\n\tISharedObjectKind,\n\tSharedObjectKind,\n\tcreateSharedObjectKind,\n} from \"./sharedObject.js\";\nexport { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nexport {\n\tcreateSingleBlobSummary,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tserializeHandles,\n\tbindHandles,\n\ttype IChannelView,\n} from \"./utils.js\";\nexport { ValueType } from \"./valueType.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAAyE;AAA3C,kHAAA,qBAAqB,OAAA;AACnD,iDAAoE;AAA3D,gHAAA,eAAe,OAAA;AACxB,qDAM2B;AAL1B,+GAAA,YAAY,OAAA;AACZ,mHAAA,gBAAgB,OAAA;AAGhB,yHAAA,sBAAsB,OAAA;AAGvB,uCAOoB;AANnB,mHAAA,uBAAuB,OAAA;AACvB,mHAAA,uBAAuB,OAAA;AACvB,wGAAA,YAAY,OAAA;AACZ,4GAAA,gBAAgB,OAAA;AAChB,uGAAA,WAAW,OAAA;AAGZ,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,iEASiC;AAPhC,iHAAA,QAAQ,OAAA;AAER,6HAAA,oBAAoB,OAAA;AAIpB,kHAAA,SAAS,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ISharedObjectHandle, isISharedObjectHandle } from \"./handle.js\";\nexport { FluidSerializer, IFluidSerializer } from \"./serializer.js\";\nexport {\n\tSharedObject,\n\tSharedObjectCore,\n\tISharedObjectKind,\n\tSharedObjectKind,\n\tcreateSharedObjectKind,\n} from \"./sharedObject.js\";\nexport { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nexport {\n\tcreateSingleBlobSummary,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tserializeHandles,\n\tbindHandles,\n\ttype IChannelView,\n} from \"./utils.js\";\nexport { ValueType } from \"./valueType.js\";\nexport {\n\tSharedKernel,\n\tthisWrap,\n\tKernelArgs,\n\tmakeSharedObjectKind,\n\tSharedKernelFactory,\n\tFactoryOut,\n\tSharedObjectOptions,\n\tmergeAPIs,\n} from \"./sharedObjectKernel.js\";\n"]}
|
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/shared-object-base";
|
|
8
|
-
export declare const pkgVersion = "2.40.0
|
|
8
|
+
export declare const pkgVersion = "2.40.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,uCAAuC,CAAC;AAC5D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,uCAAuC,CAAC;AAC5D,eAAO,MAAM,UAAU,WAAW,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/shared-object-base";
|
|
11
|
-
exports.pkgVersion = "2.40.0
|
|
11
|
+
exports.pkgVersion = "2.40.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,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,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/shared-object-base\";\nexport const pkgVersion = \"2.40.0\";\n"]}
|
package/dist/serializer.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IFluidHandleContext, type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
|
|
7
7
|
import { type ISerializedHandle } from "@fluidframework/runtime-utils/internal";
|
|
8
|
+
import { type ISharedObjectHandle } from "./handle.js";
|
|
8
9
|
/**
|
|
9
10
|
* @legacy
|
|
10
11
|
* @alpha
|
|
@@ -81,7 +82,7 @@ export declare class FluidSerializer implements IFluidSerializer {
|
|
|
81
82
|
* If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.
|
|
82
83
|
* Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.
|
|
83
84
|
*/
|
|
84
|
-
protected encodeValue(value: unknown, bind?:
|
|
85
|
+
protected encodeValue(value: unknown, bind?: ISharedObjectHandle): unknown;
|
|
85
86
|
/**
|
|
86
87
|
* If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
|
|
87
88
|
* Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
@@ -100,6 +101,6 @@ export declare class FluidSerializer implements IFluidSerializer {
|
|
|
100
101
|
* @param bind - The binding context for the handle (the handle will become attached whenever this context is attached).
|
|
101
102
|
* @returns The serialized handle.
|
|
102
103
|
*/
|
|
103
|
-
protected bindAndEncodeHandle(handle: IFluidHandleInternal, bind:
|
|
104
|
+
protected bindAndEncodeHandle(handle: IFluidHandleInternal, bind: ISharedObjectHandle): ISerializedHandle;
|
|
104
105
|
}
|
|
105
106
|
//# sourceMappingURL=serializer.d.ts.map
|
package/dist/serializer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACN,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAMN,KAAK,iBAAiB,EAEtB,MAAM,wCAAwC,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC;IAEpD;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAEhC;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,MAAM,CAAC;IAEtD;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IAGpC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAF3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsB;gBAEP,OAAO,EAAE,mBAAmB;IAOhE,IAAW,gBAAgB,IAAI,gBAAgB,CAE9C;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO;
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mapp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AAE,mBAAmB,GAAG,OAAO;IAS1E;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAmB9C;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IA4C1B;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,mBAAmB,GACvB,iBAAiB;CAIpB"}
|
package/dist/serializer.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.FluidSerializer = void 0;
|
|
8
8
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
9
|
const internal_2 = require("@fluidframework/runtime-utils/internal");
|
|
10
|
+
const handle_js_1 = require("./handle.js");
|
|
10
11
|
/**
|
|
11
12
|
* Data Store serializer implementation
|
|
12
13
|
* @internal
|
|
@@ -32,6 +33,7 @@ class FluidSerializer {
|
|
|
32
33
|
* Any unbound handles encountered are bound to the provided IFluidHandle.
|
|
33
34
|
*/
|
|
34
35
|
encode(input, bind) {
|
|
36
|
+
(0, internal_1.assert)((0, handle_js_1.isISharedObjectHandle)(bind), 0xb8c /* bind must be an ISharedObjectHandle */);
|
|
35
37
|
// If the given 'input' cannot contain handles, return it immediately. Otherwise,
|
|
36
38
|
// return the result of 'recursivelyReplace()'.
|
|
37
39
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
@@ -62,8 +64,8 @@ class FluidSerializer {
|
|
|
62
64
|
* being bound to the given bind context in the process.
|
|
63
65
|
*/
|
|
64
66
|
stringify(input, bind) {
|
|
65
|
-
|
|
66
|
-
return JSON.stringify(input, (key, value) => this.encodeValue(value,
|
|
67
|
+
(0, internal_1.assert)((0, handle_js_1.isISharedObjectHandle)(bind), 0xb8d /* bind must be an ISharedObjectHandle */);
|
|
68
|
+
return JSON.stringify(input, (key, value) => this.encodeValue(value, bind));
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
* Parses the serialized data - context must match the context with which the JSON was stringified
|
package/dist/serializer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,kEAAiF;AACjF,qEAQgD;AAuChD;;;GAGG;AACH,MAAa,eAAe;IAG3B,YAAoC,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;QACpC,CAAC;IACF,CAAC;IAED,IAAW,gBAAgB;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAc,EAAE,IAA0B;QACvD,kFAAkF;QAClF,+CAA+C;QAC/C,yEAAyE;QACzE,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;YAC1C,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;YACnE,CAAC,CAAC,KAAK,CAAC;IACV,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAc;QAC3B,kFAAkF;QAClF,+CAA+C;QAC/C,yEAAyE;QACzE,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;YAC1C,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7D,CAAC,CAAC,KAAK,CAAC;IACV,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,KAAc,EAAE,I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AAC;QAClB,OAAO,IAAA,uCAA4B,EAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACD;AAtKD,0CAsKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert, shallowCloneObject } from \"@fluidframework/core-utils/internal\";\nimport {\n\tencodeHandleForSerialization,\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n\tisFluidHandle,\n\ttoFluidHandleInternal,\n\ttype ISerializedHandle,\n\tRemoteFluidObjectHandle,\n} from \"@fluidframework/runtime-utils/internal\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IFluidSerializer {\n\t/**\n\t * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n\t * where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t */\n\tencode(value: unknown, bind: IFluidHandle): unknown;\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tdecode(input: unknown): unknown;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\tstringify(value: unknown, bind: IFluidHandle): string;\n\n\t/**\n\t * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n\t * handles will be realized as part of the parse\n\t */\n\tparse(value: string): unknown;\n}\n\n/**\n * Data Store serializer implementation\n * @internal\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(private readonly context: IFluidHandleContext) {\n\t\tthis.root = this.context;\n\t\twhile (this.root.routeContext !== undefined) {\n\t\t\tthis.root = this.root.routeContext;\n\t\t}\n\t}\n\n\tpublic get IFluidSerializer(): IFluidSerializer {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n\t * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * Any unbound handles encountered are bound to the provided IFluidHandle.\n\t */\n\tpublic encode(input: unknown, bind: IFluidHandleInternal): unknown {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.encodeValue.bind(this), bind)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tpublic decode(input: unknown): unknown {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.decodeValue.bind(this))\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Serializes the input object into a JSON string.\n\t * Any IFluidHandles in the object will be replaced with their serialized form before stringify,\n\t * being bound to the given bind context in the process.\n\t */\n\tpublic stringify(input: unknown, bind: IFluidHandle): string {\n\t\tconst bindInternal = toFluidHandleInternal(bind);\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));\n\t}\n\n\t/**\n\t * Parses the serialized data - context must match the context with which the JSON was stringified\n\t */\n\tpublic parse(input: string): unknown {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\n\t/**\n\t * If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.\n\t * Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.\n\t */\n\tprotected encodeValue(value: unknown, bind?: IFluidHandleInternal): unknown {\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\tif (isFluidHandle(value)) {\n\t\t\tassert(bind !== undefined, 0xa93 /* Cannot encode a handle without a bind context */);\n\t\t\treturn this.bindAndEncodeHandle(toFluidHandleInternal(value), bind);\n\t\t}\n\t\treturn value;\n\t}\n\n\t/**\n\t * If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.\n\t * Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.\n\t */\n\tprotected decodeValue(value: unknown): unknown {\n\t\t// If 'value' is a serialized IFluidHandle return the deserialized result.\n\t\tif (isSerializedHandle(value)) {\n\t\t\t// Old documents may have handles with relative path in their summaries. Convert these to absolute\n\t\t\t// paths. This will ensure that future summaries will have absolute paths for these handles.\n\t\t\tconst absolutePath = value.url.startsWith(\"/\")\n\t\t\t\t? value.url\n\t\t\t\t: generateHandleContextPath(value.url, this.context);\n\n\t\t\treturn new RemoteFluidObjectHandle(\n\t\t\t\tabsolutePath,\n\t\t\t\tthis.root,\n\t\t\t\tvalue.payloadPending === true,\n\t\t\t);\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t}\n\n\t/**\n\t * Invoked for non-null objects to recursively replace references to IFluidHandles.\n\t * Clones as-needed to avoid mutating the `input` object. If no IFluidHandles are present,\n\t * returns the original `input`.\n\t */\n\tprivate recursivelyReplace<TContext = unknown>(\n\t\tinput: object,\n\t\treplacer: (input: unknown, context?: TContext) => unknown,\n\t\tcontext?: TContext,\n\t): unknown {\n\t\t// Note: Caller is responsible for ensuring that `input` is defined / non-null.\n\t\t// (Required for Object.keys() below.)\n\n\t\t// Execute the `replace` on the current input. Note that Caller is responsible for ensuring that `input`\n\t\t// is a non-null object.\n\t\tconst maybeReplaced = replacer(input, context);\n\n\t\t// If either input or the replaced result is a Fluid Handle, there is no need to descend further.\n\t\t// IFluidHandles are always leaves in the object graph, and the code below cannot deal with IFluidHandle's structure.\n\t\tif (isFluidHandle(input) || isFluidHandle(maybeReplaced)) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\n\t\t// Otherwise descend into the object graph looking for IFluidHandle instances.\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value: unknown = input[key];\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\tif (!!value && typeof value === \"object\") {\n\t\t\t\t// Note: Except for IFluidHandle, `input` must not contain circular references (as object must\n\t\t\t\t// be JSON serializable.) Therefore, guarding against infinite recursion here would only\n\t\t\t\t// lead to a later error when attempting to stringify().\n\t\t\t\tconst replaced = this.recursivelyReplace(value, replacer, context);\n\n\t\t\t\t// If the `replaced` object is different than the original `value` then the subgraph contained one\n\t\t\t\t// or more handles. If this happens, we need to return a clone of the `input` object where the\n\t\t\t\t// current property is replaced by the `replaced` value.\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\t// Lazily create a shallow clone of the `input` object if we haven't done so already.\n\t\t\t\t\tclone ??= shallowCloneObject(input);\n\n\t\t\t\t\t// Overwrite the current property `key` in the clone with the `replaced` value.\n\t\t\t\t\tclone[key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn clone ?? input;\n\t}\n\n\t/**\n\t * Encodes the given IFluidHandle into a JSON-serializable form,\n\t * also binding it to another node to ensure it attaches at the right time.\n\t * @param handle - The IFluidHandle to serialize.\n\t * @param bind - The binding context for the handle (the handle will become attached whenever this context is attached).\n\t * @returns The serialized handle.\n\t */\n\tprotected bindAndEncodeHandle(\n\t\thandle: IFluidHandleInternal,\n\t\tbind: IFluidHandleInternal,\n\t): ISerializedHandle {\n\t\tbind.bind(handle);\n\t\treturn encodeHandleForSerialization(handle);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,kEAAiF;AACjF,qEAQgD;AAEhD,2CAA8E;AAuC9E;;;GAGG;AACH,MAAa,eAAe;IAG3B,YAAoC,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;QACpC,CAAC;IACF,CAAC;IAED,IAAW,gBAAgB;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAc,EAAE,IAA0B;QACvD,IAAA,iBAAM,EAAC,IAAA,iCAAqB,EAAC,IAAI,CAAC,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACrF,kFAAkF;QAClF,+CAA+C;QAC/C,yEAAyE;QACzE,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;YAC1C,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;YACnE,CAAC,CAAC,KAAK,CAAC;IACV,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAc;QAC3B,kFAAkF;QAClF,+CAA+C;QAC/C,yEAAyE;QACzE,OAAO,CAAC,CAAC,KAAK,I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AAC,CAAC;oBAEpC,+EAA+E;oBAC/E,KAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACvB,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,KAAK,IAAI,KAAK,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACO,mBAAmB,CAC5B,MAA4B,EAC5B,IAAyB;QAEzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO,IAAA,uCAA4B,EAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACD;AAvKD,0CAuKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert, shallowCloneObject } from \"@fluidframework/core-utils/internal\";\nimport {\n\tencodeHandleForSerialization,\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n\tisFluidHandle,\n\ttoFluidHandleInternal,\n\ttype ISerializedHandle,\n\tRemoteFluidObjectHandle,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport { isISharedObjectHandle, type ISharedObjectHandle } from \"./handle.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IFluidSerializer {\n\t/**\n\t * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n\t * where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t */\n\tencode(value: unknown, bind: IFluidHandle): unknown;\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tdecode(input: unknown): unknown;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\tstringify(value: unknown, bind: IFluidHandle): string;\n\n\t/**\n\t * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n\t * handles will be realized as part of the parse\n\t */\n\tparse(value: string): unknown;\n}\n\n/**\n * Data Store serializer implementation\n * @internal\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(private readonly context: IFluidHandleContext) {\n\t\tthis.root = this.context;\n\t\twhile (this.root.routeContext !== undefined) {\n\t\t\tthis.root = this.root.routeContext;\n\t\t}\n\t}\n\n\tpublic get IFluidSerializer(): IFluidSerializer {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n\t * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * Any unbound handles encountered are bound to the provided IFluidHandle.\n\t */\n\tpublic encode(input: unknown, bind: IFluidHandleInternal): unknown {\n\t\tassert(isISharedObjectHandle(bind), 0xb8c /* bind must be an ISharedObjectHandle */);\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.encodeValue.bind(this), bind)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tpublic decode(input: unknown): unknown {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.decodeValue.bind(this))\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Serializes the input object into a JSON string.\n\t * Any IFluidHandles in the object will be replaced with their serialized form before stringify,\n\t * being bound to the given bind context in the process.\n\t */\n\tpublic stringify(input: unknown, bind: IFluidHandle): string {\n\t\tassert(isISharedObjectHandle(bind), 0xb8d /* bind must be an ISharedObjectHandle */);\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bind));\n\t}\n\n\t/**\n\t * Parses the serialized data - context must match the context with which the JSON was stringified\n\t */\n\tpublic parse(input: string): unknown {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\n\t/**\n\t * If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.\n\t * Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.\n\t */\n\tprotected encodeValue(value: unknown, bind?: ISharedObjectHandle): unknown {\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\tif (isFluidHandle(value)) {\n\t\t\tassert(bind !== undefined, 0xa93 /* Cannot encode a handle without a bind context */);\n\t\t\treturn this.bindAndEncodeHandle(toFluidHandleInternal(value), bind);\n\t\t}\n\t\treturn value;\n\t}\n\n\t/**\n\t * If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.\n\t * Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.\n\t */\n\tprotected decodeValue(value: unknown): unknown {\n\t\t// If 'value' is a serialized IFluidHandle return the deserialized result.\n\t\tif (isSerializedHandle(value)) {\n\t\t\t// Old documents may have handles with relative path in their summaries. Convert these to absolute\n\t\t\t// paths. This will ensure that future summaries will have absolute paths for these handles.\n\t\t\tconst absolutePath = value.url.startsWith(\"/\")\n\t\t\t\t? value.url\n\t\t\t\t: generateHandleContextPath(value.url, this.context);\n\n\t\t\treturn new RemoteFluidObjectHandle(\n\t\t\t\tabsolutePath,\n\t\t\t\tthis.root,\n\t\t\t\tvalue.payloadPending === true,\n\t\t\t);\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t}\n\n\t/**\n\t * Invoked for non-null objects to recursively replace references to IFluidHandles.\n\t * Clones as-needed to avoid mutating the `input` object. If no IFluidHandles are present,\n\t * returns the original `input`.\n\t */\n\tprivate recursivelyReplace<TContext = unknown>(\n\t\tinput: object,\n\t\treplacer: (input: unknown, context?: TContext) => unknown,\n\t\tcontext?: TContext,\n\t): unknown {\n\t\t// Note: Caller is responsible for ensuring that `input` is defined / non-null.\n\t\t// (Required for Object.keys() below.)\n\n\t\t// Execute the `replace` on the current input. Note that Caller is responsible for ensuring that `input`\n\t\t// is a non-null object.\n\t\tconst maybeReplaced = replacer(input, context);\n\n\t\t// If either input or the replaced result is a Fluid Handle, there is no need to descend further.\n\t\t// IFluidHandles are always leaves in the object graph, and the code below cannot deal with IFluidHandle's structure.\n\t\tif (isFluidHandle(input) || isFluidHandle(maybeReplaced)) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\n\t\t// Otherwise descend into the object graph looking for IFluidHandle instances.\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value: unknown = input[key];\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\tif (!!value && typeof value === \"object\") {\n\t\t\t\t// Note: Except for IFluidHandle, `input` must not contain circular references (as object must\n\t\t\t\t// be JSON serializable.) Therefore, guarding against infinite recursion here would only\n\t\t\t\t// lead to a later error when attempting to stringify().\n\t\t\t\tconst replaced = this.recursivelyReplace(value, replacer, context);\n\n\t\t\t\t// If the `replaced` object is different than the original `value` then the subgraph contained one\n\t\t\t\t// or more handles. If this happens, we need to return a clone of the `input` object where the\n\t\t\t\t// current property is replaced by the `replaced` value.\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\t// Lazily create a shallow clone of the `input` object if we haven't done so already.\n\t\t\t\t\tclone ??= shallowCloneObject(input);\n\n\t\t\t\t\t// Overwrite the current property `key` in the clone with the `replaced` value.\n\t\t\t\t\tclone[key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn clone ?? input;\n\t}\n\n\t/**\n\t * Encodes the given IFluidHandle into a JSON-serializable form,\n\t * also binding it to another node to ensure it attaches at the right time.\n\t * @param handle - The IFluidHandle to serialize.\n\t * @param bind - The binding context for the handle (the handle will become attached whenever this context is attached).\n\t * @returns The serialized handle.\n\t */\n\tprotected bindAndEncodeHandle(\n\t\thandle: IFluidHandleInternal,\n\t\tbind: ISharedObjectHandle,\n\t): ISerializedHandle {\n\t\tbind.bind(handle);\n\t\treturn encodeHandleForSerialization(handle);\n\t}\n}\n"]}
|
package/dist/sharedObject.d.ts
CHANGED
|
@@ -237,6 +237,14 @@ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvent
|
|
|
237
237
|
* @param localOpMetadata - The local metadata associated with the original message.
|
|
238
238
|
*/
|
|
239
239
|
protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
|
|
240
|
+
/**
|
|
241
|
+
* Called when a message has to be resubmitted but its content should be "squashed" if any subsequent pending changes
|
|
242
|
+
* override the content in the fashion described on {@link @fluidframework/datastore-definitions#IDeltaHandler.reSubmit}.
|
|
243
|
+
*
|
|
244
|
+
* @param content - The content of the original message.
|
|
245
|
+
* @param localOpMetadata - The local metadata associated with the original message.
|
|
246
|
+
*/
|
|
247
|
+
protected reSubmitSquashed(content: unknown, localOpMetadata: unknown): void;
|
|
240
248
|
/**
|
|
241
249
|
* Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.
|
|
242
250
|
* It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),
|
|
@@ -277,6 +285,8 @@ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvent
|
|
|
277
285
|
* reconnection.
|
|
278
286
|
* @param content - The content of the original message.
|
|
279
287
|
* @param localOpMetadata - The local metadata associated with the original message.
|
|
288
|
+
* @param squash - Optional. If `true`, the message will be resubmitted in a squashed form. If `undefined` or `false`,
|
|
289
|
+
* the legacy behavior (no squashing) will be used. Defaults to `false` for backward compatibility.
|
|
280
290
|
*/
|
|
281
291
|
private reSubmit;
|
|
282
292
|
/**
|
|
@@ -320,6 +330,7 @@ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvent
|
|
|
320
330
|
* @returns Whatever `super.emit()` returns.
|
|
321
331
|
*/
|
|
322
332
|
private emitInternal;
|
|
333
|
+
private throwUnsupported;
|
|
323
334
|
}
|
|
324
335
|
/**
|
|
325
336
|
* Helper for implementing {@link ISharedObject} with simplified, synchronous summarization and garbage collection.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACN,gBAAgB,EAChB,sBAAsB,EAEtB,kBAAkB,EAClB,KAAK,eAAe,EACpB,sBAAsB,EAGtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,KAAK,gBAAgB,EACrB,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,sCAAsC,EACtC,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EAGtB,KAAK,yBAAyB,EAE9B,MAAM,8CAA8C,CAAC;AAKtD,OAAO,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OAGG;IACH,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,IAAI,cAAc,GAAG,aAAa,CAAC;CACnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EACnD,OAAO,EAAE,CAAC,UAAU,eAAe,CAAC,aAAa,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC7E,iBAAiB,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAiBpE"}
|
package/dist/sharedObject.js
CHANGED
|
@@ -291,6 +291,24 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
291
291
|
reSubmitCore(content, localOpMetadata) {
|
|
292
292
|
this.submitLocalMessage(content, localOpMetadata);
|
|
293
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Called when a message has to be resubmitted but its content should be "squashed" if any subsequent pending changes
|
|
296
|
+
* override the content in the fashion described on {@link @fluidframework/datastore-definitions#IDeltaHandler.reSubmit}.
|
|
297
|
+
*
|
|
298
|
+
* @param content - The content of the original message.
|
|
299
|
+
* @param localOpMetadata - The local metadata associated with the original message.
|
|
300
|
+
*/
|
|
301
|
+
reSubmitSquashed(content, localOpMetadata) {
|
|
302
|
+
const allowStagingModeWithoutSquashing = (0, internal_4.loggerToMonitoringContext)(this.logger).config.getBoolean("Fluid.SharedObject.AllowStagingModeWithoutSquashing") ??
|
|
303
|
+
this.runtime.options.allowStagingModeWithoutSquashing ??
|
|
304
|
+
true;
|
|
305
|
+
if (allowStagingModeWithoutSquashing) {
|
|
306
|
+
this.reSubmitCore(content, localOpMetadata);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
this.throwUnsupported("reSubmitSquashed");
|
|
310
|
+
}
|
|
311
|
+
}
|
|
294
312
|
/**
|
|
295
313
|
* Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.
|
|
296
314
|
* It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),
|
|
@@ -323,8 +341,8 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
323
341
|
setConnectionState: (connected) => {
|
|
324
342
|
this.setConnectionState(connected);
|
|
325
343
|
},
|
|
326
|
-
reSubmit: (content, localOpMetadata) => {
|
|
327
|
-
this.reSubmit(content, localOpMetadata);
|
|
344
|
+
reSubmit: (content, localOpMetadata, squash) => {
|
|
345
|
+
this.reSubmit(content, localOpMetadata, squash);
|
|
328
346
|
},
|
|
329
347
|
applyStashedOp: (content) => {
|
|
330
348
|
this.applyStashedOp((0, utils_js_1.parseHandles)(content, this.serializer));
|
|
@@ -421,15 +439,24 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
421
439
|
* reconnection.
|
|
422
440
|
* @param content - The content of the original message.
|
|
423
441
|
* @param localOpMetadata - The local metadata associated with the original message.
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
442
|
+
* @param squash - Optional. If `true`, the message will be resubmitted in a squashed form. If `undefined` or `false`,
|
|
443
|
+
* the legacy behavior (no squashing) will be used. Defaults to `false` for backward compatibility.
|
|
444
|
+
*/
|
|
445
|
+
reSubmit(content, localOpMetadata, squash) {
|
|
446
|
+
// Back-compat: squash argument may not be provided by container-runtime layer.
|
|
447
|
+
// Default to previous behavior (no squash).
|
|
448
|
+
if (squash ?? false) {
|
|
449
|
+
this.reSubmitSquashed(content, localOpMetadata);
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
this.reSubmitCore(content, localOpMetadata);
|
|
453
|
+
}
|
|
427
454
|
}
|
|
428
455
|
/**
|
|
429
456
|
* Revert an op
|
|
430
457
|
*/
|
|
431
458
|
rollback(content, localOpMetadata) {
|
|
432
|
-
|
|
459
|
+
this.throwUnsupported("rollback");
|
|
433
460
|
}
|
|
434
461
|
/**
|
|
435
462
|
* Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,
|
|
@@ -457,6 +484,12 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
457
484
|
emitInternal(event, ...args) {
|
|
458
485
|
return super.emit(event, ...args);
|
|
459
486
|
}
|
|
487
|
+
throwUnsupported(featureName) {
|
|
488
|
+
throw new internal_4.LoggingError("Unsupported DDS feature", {
|
|
489
|
+
featureName,
|
|
490
|
+
...(0, internal_4.tagCodeArtifacts)({ ddsType: this.attributes.type }),
|
|
491
|
+
});
|
|
492
|
+
}
|
|
460
493
|
}
|
|
461
494
|
exports.SharedObjectCore = SharedObjectCore;
|
|
462
495
|
/**
|