@fluidframework/shared-object-base 2.0.0-dev-rc.5.0.0.268409 → 2.0.0-dev-rc.5.0.0.270987
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/api-report/shared-object-base.alpha.api.md +1 -2
- package/api-report/shared-object-base.beta.api.md +1 -1
- package/api-report/shared-object-base.public.api.md +1 -1
- package/biome.jsonc +4 -0
- package/dist/handle.js +1 -0
- package/dist/handle.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/remoteObjectHandle.js +4 -1
- package/dist/remoteObjectHandle.js.map +1 -1
- package/dist/serializer.d.ts +1 -2
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +27 -30
- package/dist/serializer.js.map +1 -1
- package/dist/sharedObject.d.ts +2 -9
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +41 -25
- package/dist/sharedObject.js.map +1 -1
- package/dist/summarySerializer.js +1 -4
- package/dist/summarySerializer.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/handle.js +1 -0
- package/lib/handle.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.js +4 -1
- package/lib/remoteObjectHandle.js.map +1 -1
- package/lib/serializer.d.ts +1 -2
- package/lib/serializer.d.ts.map +1 -1
- package/lib/serializer.js +27 -30
- package/lib/serializer.js.map +1 -1
- package/lib/sharedObject.d.ts +2 -9
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +41 -25
- package/lib/sharedObject.js.map +1 -1
- package/lib/summarySerializer.js +1 -4
- package/lib/summarySerializer.js.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +21 -18
- package/src/packageVersion.ts +1 -1
- package/src/serializer.ts +2 -8
- package/src/sharedObject.ts +7 -27
- package/src/types.ts +1 -1
- package/tsconfig.json +2 -0
|
@@ -23,7 +23,7 @@ import { IFluidHandle } from '@fluidframework/core-interfaces';
|
|
|
23
23
|
import { IFluidHandleContext } from '@fluidframework/core-interfaces/internal';
|
|
24
24
|
import { IFluidHandleInternal } from '@fluidframework/core-interfaces/internal';
|
|
25
25
|
import { IGarbageCollectionData } from '@fluidframework/runtime-definitions/internal';
|
|
26
|
-
import { ISequencedDocumentMessage } from '@fluidframework/driver-definitions';
|
|
26
|
+
import { ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';
|
|
27
27
|
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions/internal';
|
|
28
28
|
import { ITelemetryContext } from '@fluidframework/runtime-definitions/internal';
|
|
29
29
|
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils/internal';
|
|
@@ -90,7 +90,6 @@ export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISha
|
|
|
90
90
|
abstract getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
91
91
|
abstract getGCData(fullGC?: boolean): IGarbageCollectionData;
|
|
92
92
|
readonly handle: IFluidHandleInternal;
|
|
93
|
-
protected handleDecoded(decodedHandle: IFluidHandle): void;
|
|
94
93
|
// (undocumented)
|
|
95
94
|
id: string;
|
|
96
95
|
// (undocumented)
|
|
@@ -23,7 +23,7 @@ import { IFluidHandle } from '@fluidframework/core-interfaces';
|
|
|
23
23
|
import { IFluidHandleContext } from '@fluidframework/core-interfaces/internal';
|
|
24
24
|
import { IFluidHandleInternal } from '@fluidframework/core-interfaces/internal';
|
|
25
25
|
import { IGarbageCollectionData } from '@fluidframework/runtime-definitions/internal';
|
|
26
|
-
import { ISequencedDocumentMessage } from '@fluidframework/driver-definitions';
|
|
26
|
+
import { ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';
|
|
27
27
|
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions/internal';
|
|
28
28
|
import { ITelemetryContext } from '@fluidframework/runtime-definitions/internal';
|
|
29
29
|
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils/internal';
|
|
@@ -23,7 +23,7 @@ import { IFluidHandle } from '@fluidframework/core-interfaces';
|
|
|
23
23
|
import { IFluidHandleContext } from '@fluidframework/core-interfaces/internal';
|
|
24
24
|
import { IFluidHandleInternal } from '@fluidframework/core-interfaces/internal';
|
|
25
25
|
import { IGarbageCollectionData } from '@fluidframework/runtime-definitions/internal';
|
|
26
|
-
import { ISequencedDocumentMessage } from '@fluidframework/driver-definitions';
|
|
26
|
+
import { ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';
|
|
27
27
|
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions/internal';
|
|
28
28
|
import { ITelemetryContext } from '@fluidframework/runtime-definitions/internal';
|
|
29
29
|
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils/internal';
|
package/biome.jsonc
ADDED
package/dist/handle.js
CHANGED
|
@@ -18,6 +18,7 @@ const internal_1 = require("@fluidframework/datastore/internal");
|
|
|
18
18
|
* '/\<shared object id\>' and loads shared object.
|
|
19
19
|
*/
|
|
20
20
|
class SharedObjectHandle extends internal_1.FluidObjectHandle {
|
|
21
|
+
value;
|
|
21
22
|
/**
|
|
22
23
|
* Whether services have been attached for the associated shared object.
|
|
23
24
|
*/
|
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;AAIvE;;;;;;;;;;GAUG;AACH,MAAa,kBAAmB,SAAQ,4BAAgC;
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAAuE;AAIvE;;;;;;;;;;GAUG;AACH,MAAa,kBAAmB,SAAQ,4BAAgC;IAgBnD;IAfpB;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,YACoB,KAAoB,EACvC,IAAY,EACZ,YAAiC;QAEjC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAJd,UAAK,GAAL,KAAK,CAAe;IAKxC,CAAC;IAED;;;OAGG;IACI,WAAW;QACjB,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC3B,KAAK,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;CACD;AA/BD,gDA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandleContext } from \"@fluidframework/core-interfaces/internal\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore/internal\";\n\nimport { ISharedObject } from \"./types.js\";\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 extends FluidObjectHandle<ISharedObject> {\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\trouteContext: IFluidHandleContext,\n\t) {\n\t\tsuper(value, path, routeContext);\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"]}
|
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.0.0-dev-rc.5.0.0.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev-rc.5.0.0.270987";
|
|
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.0.0-dev-rc.5.0.0.
|
|
11
|
+
exports.pkgVersion = "2.0.0-dev-rc.5.0.0.270987";
|
|
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,2BAA2B,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.0.0-dev-rc.5.0.0.
|
|
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,2BAA2B,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.0.0-dev-rc.5.0.0.270987\";\n"]}
|
|
@@ -16,9 +16,13 @@ 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
|
+
absolutePath;
|
|
20
|
+
routeContext;
|
|
19
21
|
get IFluidHandleContext() {
|
|
20
22
|
return this;
|
|
21
23
|
}
|
|
24
|
+
isAttached = true;
|
|
25
|
+
objectP;
|
|
22
26
|
/**
|
|
23
27
|
* Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.
|
|
24
28
|
* @param absolutePath - The absolute path to the handle from the container runtime.
|
|
@@ -28,7 +32,6 @@ class RemoteFluidObjectHandle extends internal_3.FluidHandleBase {
|
|
|
28
32
|
super();
|
|
29
33
|
this.absolutePath = absolutePath;
|
|
30
34
|
this.routeContext = routeContext;
|
|
31
|
-
this.isAttached = true;
|
|
32
35
|
(0, internal_2.assert)(absolutePath.startsWith("/"), 0x19d /* "Handles should always have absolute paths" */);
|
|
33
36
|
}
|
|
34
37
|
async get() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAA4E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,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;QACL,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;AAnDD,0DAmDC","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 get IFluidHandleContext() {\n\t\treturn this;\n\t}\n\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\n\t\t\t\t.resolveHandle(request)\n\t\t\t\t.then<FluidObject>((response) => {\n\t\t\t\t\tif (response.mimeType === \"fluid/object\") {\n\t\t\t\t\t\tconst fluidObject: FluidObject = response.value;\n\t\t\t\t\t\treturn fluidObject;\n\t\t\t\t\t}\n\t\t\t\t\tthrow responseToException(response, request);\n\t\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
|
@@ -42,9 +42,8 @@ export interface IFluidSerializer {
|
|
|
42
42
|
*/
|
|
43
43
|
export declare class FluidSerializer implements IFluidSerializer {
|
|
44
44
|
private readonly context;
|
|
45
|
-
private readonly handleParsedCb;
|
|
46
45
|
private readonly root;
|
|
47
|
-
constructor(context: IFluidHandleContext
|
|
46
|
+
constructor(context: IFluidHandleContext);
|
|
48
47
|
get IFluidSerializer(): this;
|
|
49
48
|
/**
|
|
50
49
|
* Given a mostly-jsonable object tree that may have handle objects embedded within, will return a
|
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;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACN,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,MAAM,0CAA0C,CAAC;AAUlD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE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AAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY;IAM5C,KAAK,CAAC,KAAK,EAAE,MAAM;IAM1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAK1B;IAIF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAa1B;IAKF,OAAO,CAAC,kBAAkB;IA6C1B,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,oBAAoB,EAAE,IAAI,EAAE,oBAAoB;;;;CAOlF"}
|
package/dist/serializer.js
CHANGED
|
@@ -12,37 +12,10 @@ const remoteObjectHandle_js_1 = require("./remoteObjectHandle.js");
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
class FluidSerializer {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
context;
|
|
16
|
+
root;
|
|
17
|
+
constructor(context) {
|
|
18
18
|
this.context = context;
|
|
19
|
-
this.handleParsedCb = handleParsedCb;
|
|
20
|
-
// If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.
|
|
21
|
-
// Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.
|
|
22
|
-
this.encodeValue = (value, bind) => {
|
|
23
|
-
// If 'value' is an IFluidHandle return its encoded form.
|
|
24
|
-
return (0, internal_1.isFluidHandle)(value)
|
|
25
|
-
? this.serializeHandle((0, internal_1.toFluidHandleInternal)(value), bind)
|
|
26
|
-
: value;
|
|
27
|
-
};
|
|
28
|
-
// If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
|
|
29
|
-
// Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
30
|
-
this.decodeValue = (value) => {
|
|
31
|
-
// If 'value' is a serialized IFluidHandle return the deserialized result.
|
|
32
|
-
if ((0, internal_1.isSerializedHandle)(value)) {
|
|
33
|
-
// Old documents may have handles with relative path in their summaries. Convert these to absolute
|
|
34
|
-
// paths. This will ensure that future summaries will have absolute paths for these handles.
|
|
35
|
-
const absolutePath = value.url.startsWith("/")
|
|
36
|
-
? value.url
|
|
37
|
-
: (0, internal_1.generateHandleContextPath)(value.url, this.context);
|
|
38
|
-
const parsedHandle = new remoteObjectHandle_js_1.RemoteFluidObjectHandle(absolutePath, this.root);
|
|
39
|
-
this.handleParsedCb(parsedHandle);
|
|
40
|
-
return parsedHandle;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
19
|
this.root = this.context;
|
|
47
20
|
while (this.root.routeContext !== undefined) {
|
|
48
21
|
this.root = this.root.routeContext;
|
|
@@ -93,6 +66,30 @@ class FluidSerializer {
|
|
|
93
66
|
parse(input) {
|
|
94
67
|
return JSON.parse(input, (key, value) => this.decodeValue(value));
|
|
95
68
|
}
|
|
69
|
+
// If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.
|
|
70
|
+
// Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.
|
|
71
|
+
encodeValue = (value, bind) => {
|
|
72
|
+
// If 'value' is an IFluidHandle return its encoded form.
|
|
73
|
+
return (0, internal_1.isFluidHandle)(value)
|
|
74
|
+
? this.serializeHandle((0, internal_1.toFluidHandleInternal)(value), bind)
|
|
75
|
+
: value;
|
|
76
|
+
};
|
|
77
|
+
// If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
|
|
78
|
+
// Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
79
|
+
decodeValue = (value) => {
|
|
80
|
+
// If 'value' is a serialized IFluidHandle return the deserialized result.
|
|
81
|
+
if ((0, internal_1.isSerializedHandle)(value)) {
|
|
82
|
+
// Old documents may have handles with relative path in their summaries. Convert these to absolute
|
|
83
|
+
// paths. This will ensure that future summaries will have absolute paths for these handles.
|
|
84
|
+
const absolutePath = value.url.startsWith("/")
|
|
85
|
+
? value.url
|
|
86
|
+
: (0, internal_1.generateHandleContextPath)(value.url, this.context);
|
|
87
|
+
return new remoteObjectHandle_js_1.RemoteFluidObjectHandle(absolutePath, this.root);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
96
93
|
// Invoked for non-null objects to recursively replace references to IFluidHandles.
|
|
97
94
|
// Clones as-needed to avoid mutating the `input` object. If no IFluidHandes are present,
|
|
98
95
|
// returns the original `input`.
|
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;AAsClE;;;GAGG;AACH,MAAa,eAAe;IAG3B,YACkB,OAA4B;IAC7C,+DAA+D;IAC9C,iBAAiD,GAAG,EAAE,GAAE,CAAC;QAFzD,YAAO,GAAP,OAAO,CAAqB;QAE5B,mBAAc,GAAd,cAAc,CAA2C;QA0D3E,6EAA6E;QAC7E,iFAAiF;QAChE,gBAAW,GAAG,CAAC,KAAc,EAAE,IAA0B,EAAE,EAAE;YAC7E,yDAAyD;YACzD,OAAO,IAAA,wBAAa,EAAC,KAAK,CAAC;gBAC1B,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,IAAA,gCAAqB,EAAC,KAAK,CAAC,EAAE,IAAI,CAAC;gBAC1D,CAAC,CAAC,KAAK,CAAC;QACV,CAAC,CAAC;QAEF,qFAAqF;QACrF,6EAA6E;QAC5D,gBAAW,GAAG,CAAC,KAAU,EAAE,EAAE;YAC7C,0EAA0E;YAC1E,IAAI,IAAA,6BAAkB,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,kGAAkG;gBAClG,4FAA4F;gBAC5F,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;oBAC7C,CAAC,CAAC,KAAK,CAAC,GAAG;oBACX,CAAC,CAAC,IAAA,oCAAyB,EAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEtD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AK,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;AAnJD,0CAmJC","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 * @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(\n\t\tprivate readonly context: IFluidHandleContext,\n\t\t// To be called whenever a handle is parsed by this serializer.\n\t\tprivate readonly handleParsedCb: (handle: IFluidHandle) => void = () => {},\n\t) {\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\tconst parsedHandle = new RemoteFluidObjectHandle(absolutePath, this.root);\n\t\t\tthis.handleParsedCb(parsedHandle);\n\t\t\treturn parsedHandle;\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;;;AAUH,qEAKgD;AAEhD,mEAAkE;AAsClE;;;GAGG;AACH,MAAa,eAAe;IAGS;IAFnB,IAAI,CAAsB;IAE3C,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,KAAU,EAAE,IAAkB;QAC3C,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,EAAE,IAAI,CAAC;YACxD,CAAC,CAAC,KAAK,CAAC;IACV,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAU;QACvB,kFAAkF;QAClF,+CAA+C;QAC/C,yEAAyE;QACzE,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,K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AAE,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 * @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"]}
|
package/dist/sharedObject.d.ts
CHANGED
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { EventEmitterEventType } from "@fluid-internal/client-utils";
|
|
6
6
|
import type { IDeltaManager } from "@fluidframework/container-definitions/internal";
|
|
7
|
-
import {
|
|
7
|
+
import { type ErasedType } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
|
|
9
9
|
import { IChannelServices, IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
10
10
|
import { IChannelAttributes, type IChannelFactory, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
|
|
11
|
-
import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions";
|
|
12
|
-
import { type IDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
11
|
+
import { type IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
13
12
|
import { IExperimentalIncrementalSummaryContext, ISummaryTreeWithStats, ITelemetryContext, IGarbageCollectionData } from "@fluidframework/runtime-definitions/internal";
|
|
14
13
|
import { ITelemetryLoggerExt, EventEmitterWithErrorHandling } from "@fluidframework/telemetry-utils/internal";
|
|
15
14
|
import { IFluidSerializer } from "./serializer.js";
|
|
@@ -129,12 +128,6 @@ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvent
|
|
|
129
128
|
* {@inheritDoc (ISharedObject:interface).getGCData}
|
|
130
129
|
*/
|
|
131
130
|
abstract getGCData(fullGC?: boolean): IGarbageCollectionData;
|
|
132
|
-
/**
|
|
133
|
-
* Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference
|
|
134
|
-
* to another object in the container.
|
|
135
|
-
* @param decodedHandle - The handle of the Fluid object that is decoded.
|
|
136
|
-
*/
|
|
137
|
-
protected handleDecoded(decodedHandle: IFluidHandle): void;
|
|
138
131
|
/**
|
|
139
132
|
* Allows the distributed data type to perform custom loading
|
|
140
133
|
* @param services - Storage used by the shared object
|
|
@@ -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,
|
|
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,EAAE,KAAK,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAErF,OAAO,EACN,gBAAgB,EAChB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,kBAAkB,EAClB,KAAK,eAAe,EACpB,sBAAsB,EACtB,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,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EACN,mBAAmB,EAEnB,6BAA6B,EAM7B,MAAM,0CAA0C,CAAC;AAIlD,OAAO,EAAmB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGhE;;;GAGG;AACH,8BAAsB,gBAAgB,CAAC,MAAM,SAAS,mBAAmB,GAAG,mBAAmB,CAC9F,SAAQ,6BAA6B,CAAC,MAAM,CAC5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* @alpha
|
|
21
21
|
*/
|
|
22
22
|
class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
23
|
+
id;
|
|
24
|
+
runtime;
|
|
25
|
+
attributes;
|
|
23
26
|
get IFluidLoadable() {
|
|
24
27
|
return this;
|
|
25
28
|
}
|
|
29
|
+
opProcessingHelper;
|
|
30
|
+
callbacksHelper;
|
|
31
|
+
/**
|
|
32
|
+
* The handle referring to this SharedObject
|
|
33
|
+
*/
|
|
34
|
+
handle;
|
|
35
|
+
/**
|
|
36
|
+
* Telemetry logger for the shared object
|
|
37
|
+
*/
|
|
38
|
+
logger;
|
|
39
|
+
mc;
|
|
40
|
+
/**
|
|
41
|
+
* Connection state
|
|
42
|
+
*/
|
|
43
|
+
_connected = false;
|
|
44
|
+
/**
|
|
45
|
+
* Services used by the shared object
|
|
46
|
+
*/
|
|
47
|
+
services;
|
|
48
|
+
/**
|
|
49
|
+
* True if the dds is bound to its parent.
|
|
50
|
+
*/
|
|
51
|
+
_isBoundToContext = false;
|
|
52
|
+
/**
|
|
53
|
+
* Tracks error that closed this object.
|
|
54
|
+
*/
|
|
55
|
+
closeError;
|
|
26
56
|
/**
|
|
27
57
|
* Gets the connection state
|
|
28
58
|
* @returns The state of the connection
|
|
@@ -40,14 +70,6 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
40
70
|
this.id = id;
|
|
41
71
|
this.runtime = runtime;
|
|
42
72
|
this.attributes = attributes;
|
|
43
|
-
/**
|
|
44
|
-
* Connection state
|
|
45
|
-
*/
|
|
46
|
-
this._connected = false;
|
|
47
|
-
/**
|
|
48
|
-
* True if the dds is bound to its parent.
|
|
49
|
-
*/
|
|
50
|
-
this._isBoundToContext = false;
|
|
51
73
|
(0, internal_1.assert)(!id.includes("/"), 0x304 /* Id cannot contain slashes */);
|
|
52
74
|
this.handle = new handle_js_1.SharedObjectHandle(this, id, runtime.IFluidHandleContext);
|
|
53
75
|
this.logger = (0, internal_4.createChildLogger)({
|
|
@@ -200,17 +222,6 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
200
222
|
isAttached() {
|
|
201
223
|
return this._isBoundToContext && this.runtime.attachState !== container_definitions_1.AttachState.Detached;
|
|
202
224
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference
|
|
205
|
-
* to another object in the container.
|
|
206
|
-
* @param decodedHandle - The handle of the Fluid object that is decoded.
|
|
207
|
-
*/
|
|
208
|
-
handleDecoded(decodedHandle) {
|
|
209
|
-
if (this.isAttached()) {
|
|
210
|
-
// This represents an outbound reference from this object to the node represented by decodedHandle.
|
|
211
|
-
this.services?.deltaConnection.addedGCOutboundReference?.(this.handle, decodedHandle);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
225
|
/**
|
|
215
226
|
* Allows the distributed data type to perform custom local loading.
|
|
216
227
|
*/
|
|
@@ -400,6 +411,15 @@ exports.SharedObjectCore = SharedObjectCore;
|
|
|
400
411
|
* @alpha
|
|
401
412
|
*/
|
|
402
413
|
class SharedObject extends SharedObjectCore {
|
|
414
|
+
telemetryContextPrefix;
|
|
415
|
+
/**
|
|
416
|
+
* True while we are garbage collecting this object's data.
|
|
417
|
+
*/
|
|
418
|
+
_isGCing = false;
|
|
419
|
+
/**
|
|
420
|
+
* The serializer to use to serialize / parse handles, if any.
|
|
421
|
+
*/
|
|
422
|
+
_serializer;
|
|
403
423
|
get serializer() {
|
|
404
424
|
/**
|
|
405
425
|
* During garbage collection, the SummarySerializer keeps track of IFluidHandles that are serialized. These
|
|
@@ -419,11 +439,7 @@ class SharedObject extends SharedObjectCore {
|
|
|
419
439
|
constructor(id, runtime, attributes, telemetryContextPrefix) {
|
|
420
440
|
super(id, runtime, attributes);
|
|
421
441
|
this.telemetryContextPrefix = telemetryContextPrefix;
|
|
422
|
-
|
|
423
|
-
* True while we are garbage collecting this object's data.
|
|
424
|
-
*/
|
|
425
|
-
this._isGCing = false;
|
|
426
|
-
this._serializer = new serializer_js_1.FluidSerializer(this.runtime.channelsRoutingContext, (handle) => this.handleDecoded(handle));
|
|
442
|
+
this._serializer = new serializer_js_1.FluidSerializer(this.runtime.channelsRoutingContext);
|
|
427
443
|
}
|
|
428
444
|
/**
|
|
429
445
|
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
|
|
@@ -453,7 +469,7 @@ class SharedObject extends SharedObjectCore {
|
|
|
453
469
|
this._isGCing = true;
|
|
454
470
|
let gcData;
|
|
455
471
|
try {
|
|
456
|
-
const serializer = new summarySerializer_js_1.SummarySerializer(this.runtime.channelsRoutingContext
|
|
472
|
+
const serializer = new summarySerializer_js_1.SummarySerializer(this.runtime.channelsRoutingContext);
|
|
457
473
|
this.processGCDataCore(serializer);
|
|
458
474
|
// The GC data for this shared object contains a single GC node. The outbound routes of this node are the
|
|
459
475
|
// routes of handles serialized during summarization.
|