@fluidframework/shared-object-base 2.11.0 → 2.13.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/.eslintrc.cjs +1 -4
- package/CHANGELOG.md +8 -0
- package/api-report/shared-object-base.legacy.alpha.api.md +2 -2
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/remoteObjectHandle.d.ts +0 -1
- package/dist/remoteObjectHandle.d.ts.map +1 -1
- package/dist/remoteObjectHandle.js +0 -3
- package/dist/remoteObjectHandle.js.map +1 -1
- package/dist/serializer.d.ts +6 -8
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +16 -10
- package/dist/serializer.js.map +1 -1
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +11 -6
- package/dist/sharedObject.js.map +1 -1
- package/dist/summarySerializer.d.ts +2 -4
- package/dist/summarySerializer.d.ts.map +1 -1
- package/dist/summarySerializer.js +1 -1
- package/dist/summarySerializer.js.map +1 -1
- package/dist/utils.d.ts +4 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -4
- package/dist/utils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/remoteObjectHandle.d.ts +0 -1
- package/lib/remoteObjectHandle.d.ts.map +1 -1
- package/lib/remoteObjectHandle.js +0 -3
- package/lib/remoteObjectHandle.js.map +1 -1
- package/lib/serializer.d.ts +6 -8
- package/lib/serializer.d.ts.map +1 -1
- package/lib/serializer.js +11 -5
- package/lib/serializer.js.map +1 -1
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +11 -6
- package/lib/sharedObject.js.map +1 -1
- package/lib/summarySerializer.d.ts +2 -4
- package/lib/summarySerializer.d.ts.map +1 -1
- package/lib/summarySerializer.js +1 -1
- package/lib/summarySerializer.js.map +1 -1
- package/lib/utils.d.ts +4 -4
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +2 -4
- package/lib/utils.js.map +1 -1
- package/package.json +18 -18
- package/src/packageVersion.ts +1 -1
- package/src/remoteObjectHandle.ts +1 -5
- package/src/serializer.ts +34 -23
- package/src/sharedObject.ts +44 -31
- package/src/summarySerializer.ts +6 -2
- package/src/utils.ts +8 -9
package/.eslintrc.cjs
CHANGED
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
extends: [
|
|
8
|
-
require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
|
|
9
|
-
"prettier",
|
|
10
|
-
],
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/recommended"), "prettier"],
|
|
11
8
|
parserOptions: {
|
|
12
9
|
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
13
10
|
},
|
package/CHANGELOG.md
CHANGED
|
@@ -33,10 +33,10 @@ export interface ISharedObjectKind<TSharedObject> {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// @alpha
|
|
36
|
-
export function makeHandlesSerializable(value:
|
|
36
|
+
export function makeHandlesSerializable(value: unknown, serializer: IFluidSerializer, bind: IFluidHandle): any;
|
|
37
37
|
|
|
38
38
|
// @alpha
|
|
39
|
-
export function parseHandles(value:
|
|
39
|
+
export function parseHandles(value: unknown, serializer: IFluidSerializer): any;
|
|
40
40
|
|
|
41
41
|
// @alpha
|
|
42
42
|
export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends SharedObjectCore<TEvent> {
|
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.
|
|
8
|
+
export declare const pkgVersion = "2.13.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
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.
|
|
11
|
+
exports.pkgVersion = "2.13.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,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.
|
|
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.13.0\";\n"]}
|
|
@@ -15,7 +15,6 @@ import { FluidHandleBase } from "@fluidframework/runtime-utils/internal";
|
|
|
15
15
|
export declare class RemoteFluidObjectHandle extends FluidHandleBase<FluidObject> {
|
|
16
16
|
readonly absolutePath: string;
|
|
17
17
|
readonly routeContext: IFluidHandleContext;
|
|
18
|
-
get IFluidHandleContext(): this;
|
|
19
18
|
readonly isAttached = true;
|
|
20
19
|
private objectP;
|
|
21
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAY,MAAM,iCAAiC,CAAC;AACxE,OAAO,EACN,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,eAAe,EAAuB,MAAM,wCAAwC,CAAC;AAE9F;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,eAAe,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAY,MAAM,iCAAiC,CAAC;AACxE,OAAO,EACN,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,eAAe,EAAuB,MAAM,wCAAwC,CAAC;AAE9F;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,eAAe,CAAC,WAAW,CAAC;aAUvD,YAAY,EAAE,MAAM;aACpB,YAAY,EAAE,mBAAmB;IAVlD,SAAgB,UAAU,QAAQ;IAClC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;OAIG;gBAEc,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,mBAAmB;IASrC,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;IAkBjC,WAAW,IAAI,IAAI;IAInB,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;CAG/C"}
|
|
@@ -16,9 +16,6 @@ const internal_3 = require("@fluidframework/runtime-utils/internal");
|
|
|
16
16
|
* IFluidHandle can be retrieved by calling `get` on it.
|
|
17
17
|
*/
|
|
18
18
|
class RemoteFluidObjectHandle extends internal_3.FluidHandleBase {
|
|
19
|
-
get IFluidHandleContext() {
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
19
|
/**
|
|
23
20
|
* Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.
|
|
24
21
|
* @param absolutePath - The absolute path to the handle from the container runtime.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAA4E;AAM5E,kEAA6D;AAC7D,qEAA8F;AAE9F;;;;;;GAMG;AACH,MAAa,uBAAwB,SAAQ,0BAA4B;
|
|
1
|
+
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAA4E;AAM5E,kEAA6D;AAC7D,qEAA8F;AAE9F;;;;;;GAMG;AACH,MAAa,uBAAwB,SAAQ,0BAA4B;IAIxE;;;;OAIG;IACH,YACiB,YAAoB,EACpB,YAAiC;QAEjD,KAAK,EAAE,CAAC;QAHQ,iBAAY,GAAZ,YAAY,CAAQ;QACpB,iBAAY,GAAZ,YAAY,CAAqB;QAVlC,eAAU,GAAG,IAAI,CAAC;QAajC,IAAA,iBAAM,EACL,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAC5B,KAAK,CAAC,iDAAiD,CACvD,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,GAAG;QACf,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAChC,6EAA6E;YAC7E,MAAM,OAAO,GAAa;gBACzB,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,OAAO,EAAE,EAAE,CAAC,yBAAc,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE;aAC7C,CAAC;YACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAc,CAAC,QAAQ,EAAE,EAAE;gBACtF,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;oBAC1C,MAAM,WAAW,GAAgB,QAAQ,CAAC,KAAoB,CAAC;oBAC/D,OAAO,WAAW,CAAC;gBACpB,CAAC;gBACD,MAAM,IAAA,8BAAmB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,WAAW;QACjB,OAAO;IACR,CAAC;IAEM,IAAI,CAAC,MAA4B;QACvC,MAAM,CAAC,WAAW,EAAE,CAAC;IACtB,CAAC;CACD;AA7CD,0DA6CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { RuntimeHeaders } from \"@fluidframework/container-runtime/internal\";\nimport { FluidObject, IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { FluidHandleBase, responseToException } from \"@fluidframework/runtime-utils/internal\";\n\n/**\n * This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized\n * FluidObjectHandle.\n * This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,\n * custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the\n * IFluidHandle can be retrieved by calling `get` on it.\n */\nexport class RemoteFluidObjectHandle extends FluidHandleBase<FluidObject> {\n\tpublic readonly isAttached = true;\n\tprivate objectP: Promise<FluidObject> | undefined;\n\n\t/**\n\t * Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.\n\t * @param absolutePath - The absolute path to the handle from the container runtime.\n\t * @param routeContext - The root IFluidHandleContext that has a route to this handle.\n\t */\n\tconstructor(\n\t\tpublic readonly absolutePath: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t) {\n\t\tsuper();\n\t\tassert(\n\t\t\tabsolutePath.startsWith(\"/\"),\n\t\t\t0x19d /* \"Handles should always have absolute paths\" */,\n\t\t);\n\t}\n\n\tpublic async get(): Promise<FluidObject> {\n\t\tif (this.objectP === undefined) {\n\t\t\t// Add `viaHandle` header to distinguish from requests from non-handle paths.\n\t\t\tconst request: IRequest = {\n\t\t\t\turl: this.absolutePath,\n\t\t\t\theaders: { [RuntimeHeaders.viaHandle]: true },\n\t\t\t};\n\t\t\tthis.objectP = this.routeContext.resolveHandle(request).then<FluidObject>((response) => {\n\t\t\t\tif (response.mimeType === \"fluid/object\") {\n\t\t\t\t\tconst fluidObject: FluidObject = response.value as FluidObject;\n\t\t\t\t\treturn fluidObject;\n\t\t\t\t}\n\t\t\t\tthrow responseToException(response, request);\n\t\t\t});\n\t\t}\n\t\treturn this.objectP;\n\t}\n\n\tpublic attachGraph(): void {\n\t\treturn;\n\t}\n\n\tpublic bind(handle: IFluidHandleInternal): void {\n\t\thandle.attachGraph();\n\t}\n}\n"]}
|
package/dist/serializer.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IFluidHandleContext, type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
|
|
7
|
+
import { type ISerializedHandle } from "@fluidframework/runtime-utils/internal";
|
|
7
8
|
/**
|
|
8
9
|
* @legacy
|
|
9
10
|
* @alpha
|
|
@@ -45,7 +46,7 @@ export declare class FluidSerializer implements IFluidSerializer {
|
|
|
45
46
|
private readonly context;
|
|
46
47
|
private readonly root;
|
|
47
48
|
constructor(context: IFluidHandleContext);
|
|
48
|
-
get IFluidSerializer():
|
|
49
|
+
get IFluidSerializer(): IFluidSerializer;
|
|
49
50
|
/**
|
|
50
51
|
* Given a mostly-jsonable object tree that may have handle objects embedded within, will return a
|
|
51
52
|
* fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.
|
|
@@ -55,7 +56,7 @@ export declare class FluidSerializer implements IFluidSerializer {
|
|
|
55
56
|
*
|
|
56
57
|
* Any unbound handles encountered are bound to the provided IFluidHandle.
|
|
57
58
|
*/
|
|
58
|
-
encode(input: any, bind:
|
|
59
|
+
encode(input: any, bind: IFluidHandleInternal): any;
|
|
59
60
|
/**
|
|
60
61
|
* Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an
|
|
61
62
|
* equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.
|
|
@@ -65,15 +66,12 @@ export declare class FluidSerializer implements IFluidSerializer {
|
|
|
65
66
|
*
|
|
66
67
|
* The decoded handles are implicitly bound to the handle context of this serializer.
|
|
67
68
|
*/
|
|
68
|
-
decode(input:
|
|
69
|
+
decode(input: unknown): any;
|
|
69
70
|
stringify(input: unknown, bind: IFluidHandle): string;
|
|
70
|
-
parse(input: string):
|
|
71
|
+
parse(input: string): unknown;
|
|
71
72
|
private readonly encodeValue;
|
|
72
73
|
private readonly decodeValue;
|
|
73
74
|
private recursivelyReplace;
|
|
74
|
-
protected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal):
|
|
75
|
-
type: string;
|
|
76
|
-
url: string;
|
|
77
|
-
};
|
|
75
|
+
protected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal): ISerializedHandle;
|
|
78
76
|
}
|
|
79
77
|
//# 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;
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAE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AAE,oBAAoB,GACxB,iBAAiB;CAOpB"}
|
package/dist/serializer.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.FluidSerializer = void 0;
|
|
8
|
-
const internal_1 = require("@fluidframework/
|
|
8
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
+
const internal_2 = require("@fluidframework/runtime-utils/internal");
|
|
9
10
|
const remoteObjectHandle_js_1 = require("./remoteObjectHandle.js");
|
|
10
11
|
/**
|
|
11
12
|
* Data Store serializer implementation
|
|
@@ -18,20 +19,22 @@ class FluidSerializer {
|
|
|
18
19
|
// Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.
|
|
19
20
|
this.encodeValue = (value, bind) => {
|
|
20
21
|
// If 'value' is an IFluidHandle return its encoded form.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
if ((0, internal_2.isFluidHandle)(value)) {
|
|
23
|
+
(0, internal_1.assert)(bind !== undefined, 0xa93 /* Cannot encode a handle without a bind context */);
|
|
24
|
+
return this.serializeHandle((0, internal_2.toFluidHandleInternal)(value), bind);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
24
27
|
};
|
|
25
28
|
// If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
|
|
26
29
|
// Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
27
30
|
this.decodeValue = (value) => {
|
|
28
31
|
// If 'value' is a serialized IFluidHandle return the deserialized result.
|
|
29
|
-
if ((0,
|
|
32
|
+
if ((0, internal_2.isSerializedHandle)(value)) {
|
|
30
33
|
// Old documents may have handles with relative path in their summaries. Convert these to absolute
|
|
31
34
|
// paths. This will ensure that future summaries will have absolute paths for these handles.
|
|
32
35
|
const absolutePath = value.url.startsWith("/")
|
|
33
36
|
? value.url
|
|
34
|
-
: (0,
|
|
37
|
+
: (0, internal_2.generateHandleContextPath)(value.url, this.context);
|
|
35
38
|
return new remoteObjectHandle_js_1.RemoteFluidObjectHandle(absolutePath, this.root);
|
|
36
39
|
}
|
|
37
40
|
else {
|
|
@@ -55,12 +58,14 @@ class FluidSerializer {
|
|
|
55
58
|
*
|
|
56
59
|
* Any unbound handles encountered are bound to the provided IFluidHandle.
|
|
57
60
|
*/
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 ddsFuzzHarness breaks when we update any->unknown
|
|
58
62
|
encode(input, bind) {
|
|
59
63
|
// If the given 'input' cannot contain handles, return it immediately. Otherwise,
|
|
60
64
|
// return the result of 'recursivelyReplace()'.
|
|
61
65
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
62
66
|
return !!input && typeof input === "object"
|
|
63
|
-
?
|
|
67
|
+
? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- TODO: AB#26129 ddsFuzzHarness breaks when we update any->unknown
|
|
68
|
+
this.recursivelyReplace(input, this.encodeValue, bind)
|
|
64
69
|
: input;
|
|
65
70
|
}
|
|
66
71
|
/**
|
|
@@ -72,6 +77,7 @@ class FluidSerializer {
|
|
|
72
77
|
*
|
|
73
78
|
* The decoded handles are implicitly bound to the handle context of this serializer.
|
|
74
79
|
*/
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 ddsFuzzHarness breaks when we update any->unknown
|
|
75
81
|
decode(input) {
|
|
76
82
|
// If the given 'input' cannot contain handles, return it immediately. Otherwise,
|
|
77
83
|
// return the result of 'recursivelyReplace()'.
|
|
@@ -81,7 +87,7 @@ class FluidSerializer {
|
|
|
81
87
|
: input;
|
|
82
88
|
}
|
|
83
89
|
stringify(input, bind) {
|
|
84
|
-
const bindInternal = (0,
|
|
90
|
+
const bindInternal = (0, internal_2.toFluidHandleInternal)(bind);
|
|
85
91
|
return JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));
|
|
86
92
|
}
|
|
87
93
|
// Parses the serialized data - context must match the context with which the JSON was stringified
|
|
@@ -99,7 +105,7 @@ class FluidSerializer {
|
|
|
99
105
|
const maybeReplaced = replacer(input, context);
|
|
100
106
|
// If either input or the replaced result is a Fluid Handle, there is no need to descend further.
|
|
101
107
|
// IFluidHandles are always leaves in the object graph, and the code below cannot deal with IFluidHandle's structure.
|
|
102
|
-
if ((0,
|
|
108
|
+
if ((0, internal_2.isFluidHandle)(input) || (0, internal_2.isFluidHandle)(maybeReplaced)) {
|
|
103
109
|
return maybeReplaced;
|
|
104
110
|
}
|
|
105
111
|
// Otherwise descend into the object graph looking for IFluidHandle instances.
|
|
@@ -117,9 +123,9 @@ class FluidSerializer {
|
|
|
117
123
|
// current property is replaced by the `replaced` value.
|
|
118
124
|
if (replaced !== value) {
|
|
119
125
|
// Lazily create a shallow clone of the `input` object if we haven't done so already.
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- TODO: not sure if there's a good solution
|
|
120
127
|
clone = clone ?? (Array.isArray(input) ? [...input] : { ...input });
|
|
121
128
|
// Overwrite the current property `key` in the clone with the `replaced` value.
|
|
122
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
123
129
|
clone[key] = replaced;
|
|
124
130
|
}
|
|
125
131
|
}
|
package/dist/serializer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUH,qEAKgD;AAEhD,mEAAkE;AAuClE;;;GAGG;AACH,MAAa,eAAe;IAG3B,YAAoC,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAyDhE,6EAA6E;QAC7E,iFAAiF;QAChE,gBAAW,GAAG,CAAC,KAAc,EAAE,IAA0B,EAAE,EAAE;YAC7E,yDAAyD;YACzD,OAAO,IAAA,wBAAa,EAAC,KAAK,CAAC;gBAC1B,CAAC,CAAC,IA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KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACzB,yEAAyE;YACzE,IAAI,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC1C,8FAA8F;gBAC9F,+FAA+F;gBAC/F,8DAA8D;gBAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAEnE,kGAAkG;gBAClG,+FAA+F;gBAC/F,wDAAwD;gBACxD,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;oBACxB,qFAAqF;oBACrF,KAAK,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;oBAEpE,+EAA+E;oBAC/E,oEAAoE;oBACpE,KAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACxB,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,KAAK,IAAI,KAAK,CAAC;IACvB,CAAC;IAES,eAAe,CAAC,MAA4B,EAAE,IAA0B;QACjF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,MAAM,CAAC,YAAY;SACxB,CAAC;IACH,CAAC;CACD;AA7ID,0CA6IC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// RATIONALE: Many methods consume and return 'any' by necessity.\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport {\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n\tisFluidHandle,\n\ttoFluidHandleInternal,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle.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: any, bind: IFluidHandle): any;\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: any): any;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\tstringify(value: any, 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): any;\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() {\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: any, bind: IFluidHandle) {\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)\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: any) {\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)\n\t\t\t: input;\n\t}\n\n\tpublic stringify(input: unknown, bind: IFluidHandle) {\n\t\tconst bindInternal = toFluidHandleInternal(bind);\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));\n\t}\n\n\t// Parses the serialized data - context must match the context with which the JSON was stringified\n\tpublic parse(input: string) {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\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\tprivate readonly encodeValue = (value: unknown, bind: IFluidHandleInternal) => {\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\treturn isFluidHandle(value)\n\t\t\t? this.serializeHandle(toFluidHandleInternal(value), bind)\n\t\t\t: value;\n\t};\n\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\tprivate readonly decodeValue = (value: any) => {\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(absolutePath, this.root);\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t};\n\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 IFluidHandes are present,\n\t// returns the original `input`.\n\tprivate recursivelyReplace(\n\t\tinput: any,\n\t\treplacer: (input: any, context: any) => any,\n\t\tcontext?: any,\n\t) {\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 = 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 = clone ?? (Array.isArray(input) ? [...input] : { ...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\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\tprotected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal) {\n\t\tbind.bind(handle);\n\t\treturn {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: handle.absolutePath,\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,kEAA6D;AAC7D,qEAMgD;AAEhD,mEAAkE;AA2ClE;;;GAGG;AACH,MAAa,eAAe;IAG3B,YAAoC,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QA4DhE,6EAA6E;QAC7E,iFAAiF;QAChE,gBAAW,GAAG,CAAC,KAAc,EAAE,IAA2B,EAAW,EAAE;YACvF,yDAAyD;YACzD,IAAI,IAAA,wBAAa,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC1B,IAAA,iBAAM,EAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;gBACtF,OAAO,IAAI,CAAC,eAAe,CAAC,IAAA,gCAAqB,EAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;YACjE,CAAC;YACD,OAAO,KAAK,CAAC;QACd,CAAC,CAAC;QAEF,qFAAqF;QACrF,6EAA6E;QAC5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,QAAQ,EAAE,CAAC;gBAC1C,8FAA8F;gBAC9F,+FAA+F;gBAC/F,8DAA8D;gBAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAEnE,kGAAkG;gBAClG,+FAA+F;gBAC/F,wDAAwD;gBACxD,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;oBACxB,qFAAqF;oBACrF,gHAAgH;oBAChH,KAAK,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;oBAEpE,+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;IAES,eAAe,CACxB,MAA4B,EAC5B,IAA0B;QAE1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,MAAM,CAAC,YAAY;SACxB,CAAC;IACH,CAAC;CACD;AArJD,0CAqJC","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 } from \"@fluidframework/core-utils/internal\";\nimport {\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n\tisFluidHandle,\n\ttoFluidHandleInternal,\n\ttype ISerializedHandle,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle.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\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tencode(value: any, bind: IFluidHandle): any;\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\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tdecode(input: any): any;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tstringify(value: any, 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\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tparse(value: string): any;\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\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 ddsFuzzHarness breaks when we update any->unknown\n\tpublic encode(input: any, bind: IFluidHandleInternal): any {\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? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- TODO: AB#26129 ddsFuzzHarness breaks when we update any->unknown\n\t\t\t\tthis.recursivelyReplace(input, this.encodeValue, 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\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 ddsFuzzHarness breaks when we update any->unknown\n\tpublic decode(input: unknown): any {\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)\n\t\t\t: input;\n\t}\n\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// Parses the serialized data - context must match the context with which the JSON was stringified\n\tpublic parse(input: string): unknown {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\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\tprivate readonly 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.serializeHandle(toFluidHandleInternal(value), bind);\n\t\t}\n\t\treturn value;\n\t};\n\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\tprivate readonly 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(absolutePath, this.root);\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t};\n\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 IFluidHandes are present,\n\t// returns the original `input`.\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\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- TODO: not sure if there's a good solution\n\t\t\t\t\tclone = clone ?? (Array.isArray(input) ? [...input] : { ...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\tprotected serializeHandle(\n\t\thandle: IFluidHandleInternal,\n\t\tbind: IFluidHandleInternal,\n\t): ISerializedHandle {\n\t\tbind.bind(handle);\n\t\treturn {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: handle.absolutePath,\n\t\t};\n\t}\n}\n"]}
|
|
@@ -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,EAEtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,KAAK,gBAAgB,EACrB,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,sCAAsC,EACtC,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EAItB,MAAM,8CAA8C,CAAC;AAKtD,OAAO,EACN,mBAAmB,EAEnB,6BAA6B,
|
|
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,EAEtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,KAAK,gBAAgB,EACrB,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,sCAAsC,EACtC,qBAAqB,EACrB,iBAAiB,EACjB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,aAAa,CAAC;CACpE;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB,CAAC,GAAG,CAAC,aAAa,GAAG,OAAO,CAC5D,SAAQ,UAAU,CAAC,SAAS,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAChE;;;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
|
@@ -138,6 +138,7 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
138
138
|
// always propagate connection state
|
|
139
139
|
this.setBoundAndHandleAttach = () => this.setConnectionState(this.runtime.connected);
|
|
140
140
|
this._isBoundToContext = true;
|
|
141
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
141
142
|
const runDidAttach = () => {
|
|
142
143
|
// Allows objects to do any custom processing if it is attached.
|
|
143
144
|
this.didAttach();
|
|
@@ -224,6 +225,7 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
224
225
|
* and not sent to the server. This will be sent back when this message is received back from the server. This is
|
|
225
226
|
* also sent if we are asked to resubmit the message.
|
|
226
227
|
*/
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)
|
|
227
229
|
submitLocalMessage(content, localOpMetadata = undefined) {
|
|
228
230
|
this.verifyNotClosed();
|
|
229
231
|
if (this.isAttached()) {
|
|
@@ -255,6 +257,7 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
255
257
|
* @param content - The content of the original message.
|
|
256
258
|
* @param localOpMetadata - The local metadata associated with the original message.
|
|
257
259
|
*/
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)
|
|
258
261
|
reSubmitCore(content, localOpMetadata) {
|
|
259
262
|
this.submitLocalMessage(content, localOpMetadata);
|
|
260
263
|
}
|
|
@@ -318,7 +321,12 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
318
321
|
}
|
|
319
322
|
// Should I change the state at the end? So that we *can't* send new stuff before we send old?
|
|
320
323
|
this._connected = connected;
|
|
321
|
-
if (
|
|
324
|
+
if (connected) {
|
|
325
|
+
// Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending
|
|
326
|
+
// messages will work.
|
|
327
|
+
this.onConnect();
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
322
330
|
// Things that are true now...
|
|
323
331
|
// - if we had a connection we can no longer send messages over it
|
|
324
332
|
// - if we had outbound messages some may or may not be ACK'd. Won't know until next message
|
|
@@ -326,11 +334,6 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
326
334
|
// - nack could get a new msn - but might as well do it in the join?
|
|
327
335
|
this.onDisconnect();
|
|
328
336
|
}
|
|
329
|
-
else {
|
|
330
|
-
// Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending
|
|
331
|
-
// messages will work.
|
|
332
|
-
this.onConnect();
|
|
333
|
-
}
|
|
334
337
|
}
|
|
335
338
|
/**
|
|
336
339
|
* Handles a message being received from the remote delta server.
|
|
@@ -379,6 +382,7 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
379
382
|
/**
|
|
380
383
|
* Revert an op
|
|
381
384
|
*/
|
|
385
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)
|
|
382
386
|
rollback(content, localOpMetadata) {
|
|
383
387
|
throw new Error("rollback not supported");
|
|
384
388
|
}
|
|
@@ -394,6 +398,7 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
394
398
|
*/
|
|
395
399
|
emit(event, ...args) {
|
|
396
400
|
return this.callbacksHelper.measure(() => {
|
|
401
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
397
402
|
return super.emit(event, ...args);
|
|
398
403
|
});
|
|
399
404
|
}
|