@fluidframework/shared-object-base 2.33.0-333010 → 2.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/api-report/shared-object-base.legacy.alpha.api.md +8 -8
- package/dist/gcHandleVisitor.d.ts +19 -0
- package/dist/gcHandleVisitor.d.ts.map +1 -0
- package/dist/gcHandleVisitor.js +34 -0
- package/dist/gcHandleVisitor.js.map +1 -0
- package/dist/handle.d.ts +5 -2
- package/dist/handle.d.ts.map +1 -1
- package/dist/handle.js +13 -2
- package/dist/handle.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serializer.d.ts +2 -2
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +32 -32
- package/dist/serializer.js.map +1 -1
- package/dist/sharedObject.d.ts +6 -0
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +20 -11
- package/dist/sharedObject.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -1
- package/lib/gcHandleVisitor.d.ts +19 -0
- package/lib/gcHandleVisitor.d.ts.map +1 -0
- package/lib/gcHandleVisitor.js +30 -0
- package/lib/gcHandleVisitor.js.map +1 -0
- package/lib/handle.d.ts +5 -2
- package/lib/handle.d.ts.map +1 -1
- package/lib/handle.js +13 -2
- package/lib/handle.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/serializer.d.ts +2 -2
- package/lib/serializer.d.ts.map +1 -1
- package/lib/serializer.js +32 -32
- package/lib/serializer.js.map +1 -1
- package/lib/sharedObject.d.ts +6 -0
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +21 -12
- package/lib/sharedObject.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +2 -0
- package/lib/utils.js.map +1 -1
- package/package.json +18 -18
- package/src/gcHandleVisitor.ts +36 -0
- package/src/handle.ts +15 -3
- package/src/index.ts +0 -1
- package/src/packageVersion.ts +1 -1
- package/src/serializer.ts +11 -7
- package/src/sharedObject.ts +23 -12
- package/src/utils.ts +6 -3
- package/dist/summarySerializer.d.ts +0 -17
- package/dist/summarySerializer.d.ts.map +0 -1
- package/dist/summarySerializer.js +0 -27
- package/dist/summarySerializer.js.map +0 -1
- package/lib/summarySerializer.d.ts +0 -17
- package/lib/summarySerializer.d.ts.map +0 -1
- package/lib/summarySerializer.js +0 -23
- package/lib/summarySerializer.js.map +0 -1
- package/src/summarySerializer.ts +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
// @alpha (undocumented)
|
|
7
|
+
// @alpha @legacy (undocumented)
|
|
8
8
|
export interface IFluidSerializer {
|
|
9
9
|
decode(input: unknown): unknown;
|
|
10
10
|
encode(value: unknown, bind: IFluidHandle): unknown;
|
|
@@ -12,12 +12,12 @@ export interface IFluidSerializer {
|
|
|
12
12
|
stringify(value: unknown, bind: IFluidHandle): string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
// @alpha
|
|
15
|
+
// @alpha @legacy
|
|
16
16
|
export interface ISharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends IChannel, IEventProvider<TEvent> {
|
|
17
17
|
bindToContext(): void;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// @alpha
|
|
20
|
+
// @alpha @legacy
|
|
21
21
|
export interface ISharedObjectEvents extends IErrorEvent {
|
|
22
22
|
// @eventProperty
|
|
23
23
|
(event: "pre-op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
@@ -25,19 +25,19 @@ export interface ISharedObjectEvents extends IErrorEvent {
|
|
|
25
25
|
(event: "op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// @alpha
|
|
28
|
+
// @alpha @legacy
|
|
29
29
|
export interface ISharedObjectKind<TSharedObject> {
|
|
30
30
|
create(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;
|
|
31
31
|
getFactory(): IChannelFactory<TSharedObject>;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
// @alpha
|
|
34
|
+
// @alpha @legacy
|
|
35
35
|
export function makeHandlesSerializable(value: unknown, serializer: IFluidSerializer, bind: IFluidHandle): unknown;
|
|
36
36
|
|
|
37
|
-
// @alpha
|
|
37
|
+
// @alpha @legacy
|
|
38
38
|
export function parseHandles(value: unknown, serializer: IFluidSerializer): unknown;
|
|
39
39
|
|
|
40
|
-
// @alpha
|
|
40
|
+
// @alpha @legacy
|
|
41
41
|
export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends SharedObjectCore<TEvent> {
|
|
42
42
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, telemetryContextPrefix: string);
|
|
43
43
|
getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
@@ -49,7 +49,7 @@ export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedO
|
|
|
49
49
|
protected abstract summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): ISummaryTreeWithStats;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// @alpha
|
|
52
|
+
// @alpha @legacy
|
|
53
53
|
export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {
|
|
54
54
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
55
55
|
protected abstract applyStashedOp(content: unknown): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
|
|
6
|
+
import { type ISerializedHandle } from "@fluidframework/runtime-utils/internal";
|
|
7
|
+
import { FluidSerializer } from "./serializer.js";
|
|
8
|
+
/**
|
|
9
|
+
* Implementation of IFluidSerializer used by GC to visit all the handles in the DDS to collect its outbound routes
|
|
10
|
+
*
|
|
11
|
+
* @remarks - This is given to DDS code that typically produces a serialization of the data, which is then ignored.
|
|
12
|
+
* All that is needed is getSerializedRoutes() to get the routes. This strategy could be optimized if needed.
|
|
13
|
+
*/
|
|
14
|
+
export declare class GCHandleVisitor extends FluidSerializer {
|
|
15
|
+
private readonly visitedHandlePaths;
|
|
16
|
+
getVisitedHandlePaths(): string[];
|
|
17
|
+
protected bindAndEncodeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal): ISerializedHandle;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=gcHandleVisitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcHandleVisitor.d.ts","sourceRoot":"","sources":["../src/gcHandleVisitor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,eAAe;IACnD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA0B;IACtD,qBAAqB,IAAI,MAAM,EAAE;IAIxC,SAAS,CAAC,mBAAmB,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,oBAAoB,GACxB,iBAAiB;CAUpB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.GCHandleVisitor = void 0;
|
|
8
|
+
const serializer_js_1 = require("./serializer.js");
|
|
9
|
+
/**
|
|
10
|
+
* Implementation of IFluidSerializer used by GC to visit all the handles in the DDS to collect its outbound routes
|
|
11
|
+
*
|
|
12
|
+
* @remarks - This is given to DDS code that typically produces a serialization of the data, which is then ignored.
|
|
13
|
+
* All that is needed is getSerializedRoutes() to get the routes. This strategy could be optimized if needed.
|
|
14
|
+
*/
|
|
15
|
+
class GCHandleVisitor extends serializer_js_1.FluidSerializer {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.visitedHandlePaths = new Set();
|
|
19
|
+
}
|
|
20
|
+
getVisitedHandlePaths() {
|
|
21
|
+
return [...this.visitedHandlePaths];
|
|
22
|
+
}
|
|
23
|
+
bindAndEncodeHandle(handle, bind) {
|
|
24
|
+
this.visitedHandlePaths.add(handle.absolutePath);
|
|
25
|
+
// Just return a dummy value. The serialization itself is not used.
|
|
26
|
+
// It's especially important we don't bind since that has side effects that are irrelevant to GC.
|
|
27
|
+
return {
|
|
28
|
+
type: "__fluid_handle__",
|
|
29
|
+
url: "UNUSED (see GCHandleVisitor)",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.GCHandleVisitor = GCHandleVisitor;
|
|
34
|
+
//# sourceMappingURL=gcHandleVisitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcHandleVisitor.js","sourceRoot":"","sources":["../src/gcHandleVisitor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,mDAAkD;AAElD;;;;;GAKG;AACH,MAAa,eAAgB,SAAQ,+BAAe;IAApD;;QACkB,uBAAkB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAkB9D,CAAC;IAjBO,qBAAqB;QAC3B,OAAO,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAES,mBAAmB,CAC5B,MAA4B,EAC5B,IAA0B;QAE1B,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAEjD,mEAAmE;QACnE,iGAAiG;QACjG,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,8BAA8B;SACnC,CAAC;IACH,CAAC;CACD;AAnBD,0CAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { type ISerializedHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport { FluidSerializer } from \"./serializer.js\";\n\n/**\n * Implementation of IFluidSerializer used by GC to visit all the handles in the DDS to collect its outbound routes\n *\n * @remarks - This is given to DDS code that typically produces a serialization of the data, which is then ignored.\n * All that is needed is getSerializedRoutes() to get the routes. This strategy could be optimized if needed.\n */\nexport class GCHandleVisitor extends FluidSerializer {\n\tprivate readonly visitedHandlePaths: Set<string> = new Set();\n\tpublic getVisitedHandlePaths(): string[] {\n\t\treturn [...this.visitedHandlePaths];\n\t}\n\n\tprotected bindAndEncodeHandle(\n\t\thandle: IFluidHandleInternal,\n\t\tbind: IFluidHandleInternal,\n\t): ISerializedHandle {\n\t\tthis.visitedHandlePaths.add(handle.absolutePath);\n\n\t\t// Just return a dummy value. The serialization itself is not used.\n\t\t// It's especially important we don't bind since that has side effects that are irrelevant to GC.\n\t\treturn {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: \"UNUSED (see GCHandleVisitor)\",\n\t\t};\n\t}\n}\n"]}
|
package/dist/handle.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
|
|
6
6
|
import { FluidObjectHandle } from "@fluidframework/datastore/internal";
|
|
7
|
+
import type { IFluidDataStoreRuntimeExperimental } from "@fluidframework/datastore-definitions/internal";
|
|
7
8
|
import { ISharedObject } from "./types.js";
|
|
8
9
|
/**
|
|
9
10
|
* Handle for a shared object.
|
|
@@ -18,6 +19,7 @@ import { ISharedObject } from "./types.js";
|
|
|
18
19
|
*/
|
|
19
20
|
export declare class SharedObjectHandle extends FluidObjectHandle<ISharedObject> {
|
|
20
21
|
protected readonly value: ISharedObject;
|
|
22
|
+
private readonly runtime;
|
|
21
23
|
/**
|
|
22
24
|
* Whether services have been attached for the associated shared object.
|
|
23
25
|
*/
|
|
@@ -29,11 +31,12 @@ export declare class SharedObjectHandle extends FluidObjectHandle<ISharedObject>
|
|
|
29
31
|
* @param routeContext - The parent {@link @fluidframework/core-interfaces#IFluidHandleContext} that has a route
|
|
30
32
|
* to this handle.
|
|
31
33
|
*/
|
|
32
|
-
constructor(value: ISharedObject, path: string,
|
|
34
|
+
constructor(value: ISharedObject, path: string, runtime: IFluidDataStoreRuntimeExperimental);
|
|
33
35
|
/**
|
|
34
36
|
* Attaches all bound handles first (which may in turn attach further handles), then attaches this handle.
|
|
35
37
|
* When attaching the handle, it registers the associated shared object.
|
|
36
38
|
*/
|
|
37
39
|
attachGraph(): void;
|
|
40
|
+
bind(handle: IFluidHandleInternal): void;
|
|
38
41
|
}
|
|
39
42
|
//# sourceMappingURL=handle.d.ts.map
|
package/dist/handle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,gDAAgD,CAAC;AAEzG,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB,CAAC,aAAa,CAAC;IAgBtE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa;IAGvC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAlBzB;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;;;;;;OAMG;gBAEiB,KAAK,EAAE,aAAa,EACvC,IAAI,EAAE,MAAM,EAEK,OAAO,EAAE,kCAAkC;IAK7D;;;OAGG;IACI,WAAW,IAAI,IAAI;IAKnB,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;CAQ/C"}
|
package/dist/handle.js
CHANGED
|
@@ -31,9 +31,12 @@ class SharedObjectHandle extends internal_1.FluidObjectHandle {
|
|
|
31
31
|
* @param routeContext - The parent {@link @fluidframework/core-interfaces#IFluidHandleContext} that has a route
|
|
32
32
|
* to this handle.
|
|
33
33
|
*/
|
|
34
|
-
constructor(value, path,
|
|
35
|
-
|
|
34
|
+
constructor(value, path,
|
|
35
|
+
// eslint-disable-next-line import/no-deprecated
|
|
36
|
+
runtime) {
|
|
37
|
+
super(value, path, runtime.IFluidHandleContext);
|
|
36
38
|
this.value = value;
|
|
39
|
+
this.runtime = runtime;
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
42
|
* Attaches all bound handles first (which may in turn attach further handles), then attaches this handle.
|
|
@@ -43,6 +46,14 @@ class SharedObjectHandle extends internal_1.FluidObjectHandle {
|
|
|
43
46
|
this.value.bindToContext();
|
|
44
47
|
super.attachGraph();
|
|
45
48
|
}
|
|
49
|
+
bind(handle) {
|
|
50
|
+
// We don't bind handles in staging mode to defer the attachment of any new objects
|
|
51
|
+
// until we've exited staging mode. This way if we discard changes or a new handle is not present in the final
|
|
52
|
+
// committed state, we will never end up attaching the discarded object.
|
|
53
|
+
if (this.runtime.inStagingMode !== true) {
|
|
54
|
+
super.bind(handle);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
exports.SharedObjectHandle = SharedObjectHandle;
|
|
48
59
|
//# sourceMappingURL=handle.js.map
|
package/dist/handle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAAuE;
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAAuE;AAMvE;;;;;;;;;;GAUG;AACH,MAAa,kBAAmB,SAAQ,4BAAgC;IACvE;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,YACoB,KAAoB,EACvC,IAAY;IACZ,gDAAgD;IAC/B,OAA2C;QAE5D,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAL7B,UAAK,GAAL,KAAK,CAAe;QAGtB,YAAO,GAAP,OAAO,CAAoC;IAG7D,CAAC;IAED;;;OAGG;IACI,WAAW;QACjB,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC3B,KAAK,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAEM,IAAI,CAAC,MAA4B;QACvC,mFAAmF;QACnF,8GAA8G;QAC9G,wEAAwE;QACxE,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YACzC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;IACF,CAAC;CACD;AAzCD,gDAyCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore/internal\";\n// eslint-disable-next-line import/no-deprecated\nimport type { IFluidDataStoreRuntimeExperimental } from \"@fluidframework/datastore-definitions/internal\";\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\t// eslint-disable-next-line import/no-deprecated\n\t\tprivate readonly runtime: IFluidDataStoreRuntimeExperimental,\n\t) {\n\t\tsuper(value, path, runtime.IFluidHandleContext);\n\t}\n\n\t/**\n\t * Attaches all bound handles first (which may in turn attach further handles), then attaches this handle.\n\t * When attaching the handle, it registers the associated shared object.\n\t */\n\tpublic attachGraph(): void {\n\t\tthis.value.bindToContext();\n\t\tsuper.attachGraph();\n\t}\n\n\tpublic bind(handle: IFluidHandleInternal): void {\n\t\t// We don't bind handles in staging mode to defer the attachment of any new objects\n\t\t// until we've exited staging mode. This way if we discard changes or a new handle is not present in the final\n\t\t// committed state, we will never end up attaching the discarded object.\n\t\tif (this.runtime.inStagingMode !== true) {\n\t\t\tsuper.bind(handle);\n\t\t}\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { FluidSerializer, IFluidSerializer } from "./serializer.js";
|
|
6
6
|
export { SharedObject, SharedObjectCore, ISharedObjectKind, SharedObjectKind, createSharedObjectKind, } from "./sharedObject.js";
|
|
7
|
-
export { SummarySerializer } from "./summarySerializer.js";
|
|
8
7
|
export { ISharedObject, ISharedObjectEvents } from "./types.js";
|
|
9
8
|
export { createSingleBlobSummary, makeHandlesSerializable, parseHandles, serializeHandles, bindHandles, type IChannelView, } from "./utils.js";
|
|
10
9
|
export { ValueType } from "./valueType.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EACN,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,KAAK,YAAY,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ValueType = exports.bindHandles = exports.serializeHandles = exports.parseHandles = exports.makeHandlesSerializable = exports.createSingleBlobSummary = exports.
|
|
7
|
+
exports.ValueType = exports.bindHandles = exports.serializeHandles = exports.parseHandles = exports.makeHandlesSerializable = exports.createSingleBlobSummary = exports.createSharedObjectKind = exports.SharedObjectCore = exports.SharedObject = exports.FluidSerializer = void 0;
|
|
8
8
|
var serializer_js_1 = require("./serializer.js");
|
|
9
9
|
Object.defineProperty(exports, "FluidSerializer", { enumerable: true, get: function () { return serializer_js_1.FluidSerializer; } });
|
|
10
10
|
var sharedObject_js_1 = require("./sharedObject.js");
|
|
11
11
|
Object.defineProperty(exports, "SharedObject", { enumerable: true, get: function () { return sharedObject_js_1.SharedObject; } });
|
|
12
12
|
Object.defineProperty(exports, "SharedObjectCore", { enumerable: true, get: function () { return sharedObject_js_1.SharedObjectCore; } });
|
|
13
13
|
Object.defineProperty(exports, "createSharedObjectKind", { enumerable: true, get: function () { return sharedObject_js_1.createSharedObjectKind; } });
|
|
14
|
-
var summarySerializer_js_1 = require("./summarySerializer.js");
|
|
15
|
-
Object.defineProperty(exports, "SummarySerializer", { enumerable: true, get: function () { return summarySerializer_js_1.SummarySerializer; } });
|
|
16
14
|
var utils_js_1 = require("./utils.js");
|
|
17
15
|
Object.defineProperty(exports, "createSingleBlobSummary", { enumerable: true, get: function () { return utils_js_1.createSingleBlobSummary; } });
|
|
18
16
|
Object.defineProperty(exports, "makeHandlesSerializable", { enumerable: true, get: function () { return utils_js_1.makeHandlesSerializable; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAAoE;AAA3D,gHAAA,eAAe,OAAA;AACxB,qDAM2B;AAL1B,+GAAA,YAAY,OAAA;AACZ,mHAAA,gBAAgB,OAAA;AAGhB,yHAAA,sBAAsB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAAoE;AAA3D,gHAAA,eAAe,OAAA;AACxB,qDAM2B;AAL1B,+GAAA,YAAY,OAAA;AACZ,mHAAA,gBAAgB,OAAA;AAGhB,yHAAA,sBAAsB,OAAA;AAGvB,uCAOoB;AANnB,mHAAA,uBAAuB,OAAA;AACvB,mHAAA,uBAAuB,OAAA;AACvB,wGAAA,YAAY,OAAA;AACZ,4GAAA,gBAAgB,OAAA;AAChB,uGAAA,WAAW,OAAA;AAGZ,+CAA2C;AAAlC,yGAAA,SAAS,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { FluidSerializer, IFluidSerializer } from \"./serializer.js\";\nexport {\n\tSharedObject,\n\tSharedObjectCore,\n\tISharedObjectKind,\n\tSharedObjectKind,\n\tcreateSharedObjectKind,\n} from \"./sharedObject.js\";\nexport { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nexport {\n\tcreateSingleBlobSummary,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tserializeHandles,\n\tbindHandles,\n\ttype IChannelView,\n} from \"./utils.js\";\nexport { ValueType } from \"./valueType.js\";\n"]}
|
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.33.
|
|
8
|
+
export declare const pkgVersion = "2.33.1";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,uCAAuC,CAAC;AAC5D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,uCAAuC,CAAC;AAC5D,eAAO,MAAM,UAAU,WAAW,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/shared-object-base";
|
|
11
|
-
exports.pkgVersion = "2.33.
|
|
11
|
+
exports.pkgVersion = "2.33.1";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/shared-object-base\";\nexport const pkgVersion = \"2.33.1\";\n"]}
|
package/dist/serializer.d.ts
CHANGED
|
@@ -81,12 +81,12 @@ export declare class FluidSerializer implements IFluidSerializer {
|
|
|
81
81
|
* If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.
|
|
82
82
|
* Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.
|
|
83
83
|
*/
|
|
84
|
-
|
|
84
|
+
protected encodeValue(value: unknown, bind?: IFluidHandleInternal): unknown;
|
|
85
85
|
/**
|
|
86
86
|
* If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
|
|
87
87
|
* Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
88
88
|
*/
|
|
89
|
-
|
|
89
|
+
protected decodeValue(value: unknown): unknown;
|
|
90
90
|
/**
|
|
91
91
|
* Invoked for non-null objects to recursively replace references to IFluidHandles.
|
|
92
92
|
* Clones as-needed to avoid mutating the `input` object. If no IFluidHandles are present,
|
package/dist/serializer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings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;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IA4C1B;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,oBAAoB,GACxB,iBAAiB;CAIpB"}
|
package/dist/serializer.js
CHANGED
|
@@ -14,36 +14,6 @@ const internal_2 = require("@fluidframework/runtime-utils/internal");
|
|
|
14
14
|
class FluidSerializer {
|
|
15
15
|
constructor(context) {
|
|
16
16
|
this.context = context;
|
|
17
|
-
/**
|
|
18
|
-
* If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.
|
|
19
|
-
* Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.
|
|
20
|
-
*/
|
|
21
|
-
this.encodeValue = (value, bind) => {
|
|
22
|
-
// If 'value' is an IFluidHandle return its encoded form.
|
|
23
|
-
if ((0, internal_2.isFluidHandle)(value)) {
|
|
24
|
-
(0, internal_1.assert)(bind !== undefined, 0xa93 /* Cannot encode a handle without a bind context */);
|
|
25
|
-
return this.bindAndEncodeHandle((0, internal_2.toFluidHandleInternal)(value), bind);
|
|
26
|
-
}
|
|
27
|
-
return value;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
|
|
31
|
-
* Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
32
|
-
*/
|
|
33
|
-
this.decodeValue = (value) => {
|
|
34
|
-
// If 'value' is a serialized IFluidHandle return the deserialized result.
|
|
35
|
-
if ((0, internal_2.isSerializedHandle)(value)) {
|
|
36
|
-
// Old documents may have handles with relative path in their summaries. Convert these to absolute
|
|
37
|
-
// paths. This will ensure that future summaries will have absolute paths for these handles.
|
|
38
|
-
const absolutePath = value.url.startsWith("/")
|
|
39
|
-
? value.url
|
|
40
|
-
: (0, internal_2.generateHandleContextPath)(value.url, this.context);
|
|
41
|
-
return new internal_2.RemoteFluidObjectHandle(absolutePath, this.root);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
17
|
this.root = this.context;
|
|
48
18
|
while (this.root.routeContext !== undefined) {
|
|
49
19
|
this.root = this.root.routeContext;
|
|
@@ -66,7 +36,7 @@ class FluidSerializer {
|
|
|
66
36
|
// return the result of 'recursivelyReplace()'.
|
|
67
37
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
68
38
|
return !!input && typeof input === "object"
|
|
69
|
-
? this.recursivelyReplace(input, this.encodeValue, bind)
|
|
39
|
+
? this.recursivelyReplace(input, this.encodeValue.bind(this), bind)
|
|
70
40
|
: input;
|
|
71
41
|
}
|
|
72
42
|
/**
|
|
@@ -83,7 +53,7 @@ class FluidSerializer {
|
|
|
83
53
|
// return the result of 'recursivelyReplace()'.
|
|
84
54
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
85
55
|
return !!input && typeof input === "object"
|
|
86
|
-
? this.recursivelyReplace(input, this.decodeValue)
|
|
56
|
+
? this.recursivelyReplace(input, this.decodeValue.bind(this))
|
|
87
57
|
: input;
|
|
88
58
|
}
|
|
89
59
|
/**
|
|
@@ -101,6 +71,36 @@ class FluidSerializer {
|
|
|
101
71
|
parse(input) {
|
|
102
72
|
return JSON.parse(input, (key, value) => this.decodeValue(value));
|
|
103
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.
|
|
76
|
+
* Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.
|
|
77
|
+
*/
|
|
78
|
+
encodeValue(value, bind) {
|
|
79
|
+
// If 'value' is an IFluidHandle return its encoded form.
|
|
80
|
+
if ((0, internal_2.isFluidHandle)(value)) {
|
|
81
|
+
(0, internal_1.assert)(bind !== undefined, 0xa93 /* Cannot encode a handle without a bind context */);
|
|
82
|
+
return this.bindAndEncodeHandle((0, internal_2.toFluidHandleInternal)(value), bind);
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
|
|
88
|
+
* Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
89
|
+
*/
|
|
90
|
+
decodeValue(value) {
|
|
91
|
+
// If 'value' is a serialized IFluidHandle return the deserialized result.
|
|
92
|
+
if ((0, internal_2.isSerializedHandle)(value)) {
|
|
93
|
+
// Old documents may have handles with relative path in their summaries. Convert these to absolute
|
|
94
|
+
// paths. This will ensure that future summaries will have absolute paths for these handles.
|
|
95
|
+
const absolutePath = value.url.startsWith("/")
|
|
96
|
+
? value.url
|
|
97
|
+
: (0, internal_2.generateHandleContextPath)(value.url, this.context);
|
|
98
|
+
return new internal_2.RemoteFluidObjectHandle(absolutePath, this.root, value.payloadPending === true);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
104
|
/**
|
|
105
105
|
* Invoked for non-null objects to recursively replace references to IFluidHandles.
|
|
106
106
|
* Clones as-needed to avoid mutating the `input` object. If no IFluidHandles are present,
|
package/dist/serializer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,kEAAiF;AACjF,qEAQgD;AAuChD;;;GAGG;AACH,MAAa,eAAe;IAG3B,YAAoC,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAgEhE;;;WAGG;QACc,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,mBAAmB,CA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,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,KAAK,IAAA,6BAAkB,EAAC,KAAK,CAAC,CAAC;oBAEpC,+EAA+E;oBAC/E,KAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACvB,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,KAAK,IAAI,KAAK,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACO,mBAAmB,CAC5B,MAA4B,EAC5B,IAA0B;QAE1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO,IAAA,uCAA4B,EAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACD;AAlKD,0CAkKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert, shallowCloneObject } from \"@fluidframework/core-utils/internal\";\nimport {\n\tencodeHandleForSerialization,\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n\tisFluidHandle,\n\ttoFluidHandleInternal,\n\ttype ISerializedHandle,\n\tRemoteFluidObjectHandle,\n} from \"@fluidframework/runtime-utils/internal\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IFluidSerializer {\n\t/**\n\t * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n\t * where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t */\n\tencode(value: unknown, bind: IFluidHandle): unknown;\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tdecode(input: unknown): unknown;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\tstringify(value: unknown, bind: IFluidHandle): string;\n\n\t/**\n\t * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n\t * handles will be realized as part of the parse\n\t */\n\tparse(value: string): unknown;\n}\n\n/**\n * Data Store serializer implementation\n * @internal\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(private readonly context: IFluidHandleContext) {\n\t\tthis.root = this.context;\n\t\twhile (this.root.routeContext !== undefined) {\n\t\t\tthis.root = this.root.routeContext;\n\t\t}\n\t}\n\n\tpublic get IFluidSerializer(): IFluidSerializer {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n\t * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * Any unbound handles encountered are bound to the provided IFluidHandle.\n\t */\n\tpublic encode(input: unknown, bind: IFluidHandleInternal): unknown {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.encodeValue, bind)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tpublic decode(input: unknown): unknown {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.decodeValue)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Serializes the input object into a JSON string.\n\t * Any IFluidHandles in the object will be replaced with their serialized form before stringify,\n\t * being bound to the given bind context in the process.\n\t */\n\tpublic stringify(input: unknown, bind: IFluidHandle): string {\n\t\tconst bindInternal = toFluidHandleInternal(bind);\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));\n\t}\n\n\t/**\n\t * Parses the serialized data - context must match the context with which the JSON was stringified\n\t */\n\tpublic parse(input: string): unknown {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\n\t/**\n\t * If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.\n\t * Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.\n\t */\n\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.bindAndEncodeHandle(toFluidHandleInternal(value), bind);\n\t\t}\n\t\treturn value;\n\t};\n\n\t/**\n\t * If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.\n\t * Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.\n\t */\n\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/**\n\t * Invoked for non-null objects to recursively replace references to IFluidHandles.\n\t * Clones as-needed to avoid mutating the `input` object. If no IFluidHandles are present,\n\t * returns the original `input`.\n\t */\n\tprivate recursivelyReplace<TContext = unknown>(\n\t\tinput: object,\n\t\treplacer: (input: unknown, context?: TContext) => unknown,\n\t\tcontext?: TContext,\n\t): unknown {\n\t\t// Note: Caller is responsible for ensuring that `input` is defined / non-null.\n\t\t// (Required for Object.keys() below.)\n\n\t\t// Execute the `replace` on the current input. Note that Caller is responsible for ensuring that `input`\n\t\t// is a non-null object.\n\t\tconst maybeReplaced = replacer(input, context);\n\n\t\t// If either input or the replaced result is a Fluid Handle, there is no need to descend further.\n\t\t// IFluidHandles are always leaves in the object graph, and the code below cannot deal with IFluidHandle's structure.\n\t\tif (isFluidHandle(input) || isFluidHandle(maybeReplaced)) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\n\t\t// Otherwise descend into the object graph looking for IFluidHandle instances.\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value: unknown = input[key];\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\tif (!!value && typeof value === \"object\") {\n\t\t\t\t// Note: Except for IFluidHandle, `input` must not contain circular references (as object must\n\t\t\t\t// be JSON serializable.) Therefore, guarding against infinite recursion here would only\n\t\t\t\t// lead to a later error when attempting to stringify().\n\t\t\t\tconst replaced = this.recursivelyReplace(value, replacer, context);\n\n\t\t\t\t// If the `replaced` object is different than the original `value` then the subgraph contained one\n\t\t\t\t// or more handles. If this happens, we need to return a clone of the `input` object where the\n\t\t\t\t// current property is replaced by the `replaced` value.\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\t// Lazily create a shallow clone of the `input` object if we haven't done so already.\n\t\t\t\t\tclone ??= shallowCloneObject(input);\n\n\t\t\t\t\t// Overwrite the current property `key` in the clone with the `replaced` value.\n\t\t\t\t\tclone[key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn clone ?? input;\n\t}\n\n\t/**\n\t * Encodes the given IFluidHandle into a JSON-serializable form,\n\t * also binding it to another node to ensure it attaches at the right time.\n\t * @param handle - The IFluidHandle to serialize.\n\t * @param bind - The binding context for the handle (the handle will become attached whenever this context is attached).\n\t * @returns The serialized handle.\n\t */\n\tprotected bindAndEncodeHandle(\n\t\thandle: IFluidHandleInternal,\n\t\tbind: IFluidHandleInternal,\n\t): ISerializedHandle {\n\t\tbind.bind(handle);\n\t\treturn encodeHandleForSerialization(handle);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,kEAAiF;AACjF,qEAQgD;AAuChD;;;GAGG;AACH,MAAa,eAAe;IAG3B,YAAoC,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;QACpC,CAAC;IACF,CAAC;IAED,IAAW,gBAAgB;QAC1B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AAM,KAAK,GAAY,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,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,KAAK,IAAA,6BAAkB,EAAC,KAAK,CAAC,CAAC;oBAEpC,+EAA+E;oBAC/E,KAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACvB,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,KAAK,IAAI,KAAK,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACO,mBAAmB,CAC5B,MAA4B,EAC5B,IAA0B;QAE1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO,IAAA,uCAA4B,EAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACD;AAtKD,0CAsKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert, shallowCloneObject } from \"@fluidframework/core-utils/internal\";\nimport {\n\tencodeHandleForSerialization,\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n\tisFluidHandle,\n\ttoFluidHandleInternal,\n\ttype ISerializedHandle,\n\tRemoteFluidObjectHandle,\n} from \"@fluidframework/runtime-utils/internal\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IFluidSerializer {\n\t/**\n\t * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n\t * where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t */\n\tencode(value: unknown, bind: IFluidHandle): unknown;\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tdecode(input: unknown): unknown;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\tstringify(value: unknown, bind: IFluidHandle): string;\n\n\t/**\n\t * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n\t * handles will be realized as part of the parse\n\t */\n\tparse(value: string): unknown;\n}\n\n/**\n * Data Store serializer implementation\n * @internal\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(private readonly context: IFluidHandleContext) {\n\t\tthis.root = this.context;\n\t\twhile (this.root.routeContext !== undefined) {\n\t\t\tthis.root = this.root.routeContext;\n\t\t}\n\t}\n\n\tpublic get IFluidSerializer(): IFluidSerializer {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n\t * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * Any unbound handles encountered are bound to the provided IFluidHandle.\n\t */\n\tpublic encode(input: unknown, bind: IFluidHandleInternal): unknown {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.encodeValue.bind(this), bind)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tpublic decode(input: unknown): unknown {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.decodeValue.bind(this))\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Serializes the input object into a JSON string.\n\t * Any IFluidHandles in the object will be replaced with their serialized form before stringify,\n\t * being bound to the given bind context in the process.\n\t */\n\tpublic stringify(input: unknown, bind: IFluidHandle): string {\n\t\tconst bindInternal = toFluidHandleInternal(bind);\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));\n\t}\n\n\t/**\n\t * Parses the serialized data - context must match the context with which the JSON was stringified\n\t */\n\tpublic parse(input: string): unknown {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\n\t/**\n\t * If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.\n\t * Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.\n\t */\n\tprotected encodeValue(value: unknown, bind?: IFluidHandleInternal): unknown {\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\tif (isFluidHandle(value)) {\n\t\t\tassert(bind !== undefined, 0xa93 /* Cannot encode a handle without a bind context */);\n\t\t\treturn this.bindAndEncodeHandle(toFluidHandleInternal(value), bind);\n\t\t}\n\t\treturn value;\n\t}\n\n\t/**\n\t * If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.\n\t * Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.\n\t */\n\tprotected decodeValue(value: unknown): unknown {\n\t\t// If 'value' is a serialized IFluidHandle return the deserialized result.\n\t\tif (isSerializedHandle(value)) {\n\t\t\t// Old documents may have handles with relative path in their summaries. Convert these to absolute\n\t\t\t// paths. This will ensure that future summaries will have absolute paths for these handles.\n\t\t\tconst absolutePath = value.url.startsWith(\"/\")\n\t\t\t\t? value.url\n\t\t\t\t: generateHandleContextPath(value.url, this.context);\n\n\t\t\treturn new RemoteFluidObjectHandle(\n\t\t\t\tabsolutePath,\n\t\t\t\tthis.root,\n\t\t\t\tvalue.payloadPending === true,\n\t\t\t);\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t}\n\n\t/**\n\t * Invoked for non-null objects to recursively replace references to IFluidHandles.\n\t * Clones as-needed to avoid mutating the `input` object. If no IFluidHandles are present,\n\t * returns the original `input`.\n\t */\n\tprivate recursivelyReplace<TContext = unknown>(\n\t\tinput: object,\n\t\treplacer: (input: unknown, context?: TContext) => unknown,\n\t\tcontext?: TContext,\n\t): unknown {\n\t\t// Note: Caller is responsible for ensuring that `input` is defined / non-null.\n\t\t// (Required for Object.keys() below.)\n\n\t\t// Execute the `replace` on the current input. Note that Caller is responsible for ensuring that `input`\n\t\t// is a non-null object.\n\t\tconst maybeReplaced = replacer(input, context);\n\n\t\t// If either input or the replaced result is a Fluid Handle, there is no need to descend further.\n\t\t// IFluidHandles are always leaves in the object graph, and the code below cannot deal with IFluidHandle's structure.\n\t\tif (isFluidHandle(input) || isFluidHandle(maybeReplaced)) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\n\t\t// Otherwise descend into the object graph looking for IFluidHandle instances.\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value: unknown = input[key];\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\tif (!!value && typeof value === \"object\") {\n\t\t\t\t// Note: Except for IFluidHandle, `input` must not contain circular references (as object must\n\t\t\t\t// be JSON serializable.) Therefore, guarding against infinite recursion here would only\n\t\t\t\t// lead to a later error when attempting to stringify().\n\t\t\t\tconst replaced = this.recursivelyReplace(value, replacer, context);\n\n\t\t\t\t// If the `replaced` object is different than the original `value` then the subgraph contained one\n\t\t\t\t// or more handles. If this happens, we need to return a clone of the `input` object where the\n\t\t\t\t// current property is replaced by the `replaced` value.\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\t// Lazily create a shallow clone of the `input` object if we haven't done so already.\n\t\t\t\t\tclone ??= shallowCloneObject(input);\n\n\t\t\t\t\t// Overwrite the current property `key` in the clone with the `replaced` value.\n\t\t\t\t\tclone[key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn clone ?? input;\n\t}\n\n\t/**\n\t * Encodes the given IFluidHandle into a JSON-serializable form,\n\t * also binding it to another node to ensure it attaches at the right time.\n\t * @param handle - The IFluidHandle to serialize.\n\t * @param bind - The binding context for the handle (the handle will become attached whenever this context is attached).\n\t * @returns The serialized handle.\n\t */\n\tprotected bindAndEncodeHandle(\n\t\thandle: IFluidHandleInternal,\n\t\tbind: IFluidHandleInternal,\n\t): ISerializedHandle {\n\t\tbind.bind(handle);\n\t\treturn encodeHandleForSerialization(handle);\n\t}\n}\n"]}
|
package/dist/sharedObject.d.ts
CHANGED
|
@@ -332,6 +332,12 @@ export declare abstract class SharedObject<TEvent extends ISharedObjectEvents =
|
|
|
332
332
|
/**
|
|
333
333
|
* Calls the serializer over all data in this object that reference other GC nodes.
|
|
334
334
|
* Derived classes must override this to provide custom list of references to other GC nodes.
|
|
335
|
+
*
|
|
336
|
+
* @remarks Serialization itself doesn't matter (the result is ignored). We're tapping into the serialization infrastructure
|
|
337
|
+
* as a way to visit all the content in this content that may reference other objects via handle.
|
|
338
|
+
*
|
|
339
|
+
* @param serializer - The "serializer" (more like handle visitor) to use.
|
|
340
|
+
* Implementations should ensure that serialize is called on all handles, as the way to visit them.
|
|
335
341
|
*/
|
|
336
342
|
protected processGCDataCore(serializer: IFluidSerializer): void;
|
|
337
343
|
/**
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACN,gBAAgB,EAChB,sBAAsB,EAEtB,kBAAkB,EAClB,KAAK,eAAe,EACpB,sBAAsB,EAGtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,KAAK,gBAAgB,EACrB,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,sCAAsC,EACtC,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EAGtB,KAAK,yBAAyB,E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/C;;;;;;;;;OASG;IACH,UAAU,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;IAE7C;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,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
|
@@ -11,9 +11,9 @@ const internal_2 = require("@fluidframework/runtime-definitions/internal");
|
|
|
11
11
|
const internal_3 = require("@fluidframework/runtime-utils/internal");
|
|
12
12
|
const internal_4 = require("@fluidframework/telemetry-utils/internal");
|
|
13
13
|
const uuid_1 = require("uuid");
|
|
14
|
+
const gcHandleVisitor_js_1 = require("./gcHandleVisitor.js");
|
|
14
15
|
const handle_js_1 = require("./handle.js");
|
|
15
16
|
const serializer_js_1 = require("./serializer.js");
|
|
16
|
-
const summarySerializer_js_1 = require("./summarySerializer.js");
|
|
17
17
|
const utils_js_1 = require("./utils.js");
|
|
18
18
|
/**
|
|
19
19
|
* Base class from which all shared objects derive.
|
|
@@ -50,7 +50,7 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
50
50
|
*/
|
|
51
51
|
this._isBoundToContext = false;
|
|
52
52
|
(0, internal_1.assert)(!id.includes("/"), 0x304 /* Id cannot contain slashes */);
|
|
53
|
-
this.handle = new handle_js_1.SharedObjectHandle(this, id, runtime
|
|
53
|
+
this.handle = new handle_js_1.SharedObjectHandle(this, id, runtime);
|
|
54
54
|
this.logger = (0, internal_4.createChildLogger)({
|
|
55
55
|
logger: runtime.logger,
|
|
56
56
|
properties: {
|
|
@@ -236,8 +236,12 @@ class SharedObjectCore extends internal_4.EventEmitterWithErrorHandling {
|
|
|
236
236
|
this.verifyNotClosed();
|
|
237
237
|
if (this.isAttached()) {
|
|
238
238
|
// NOTE: We may also be encoding in the ContainerRuntime layer.
|
|
239
|
-
// Once the layer-compat window passes we can
|
|
240
|
-
const
|
|
239
|
+
// Once the layer-compat window passes we can remove the encoding codepath here altogether
|
|
240
|
+
const onlyBind = this.runtime
|
|
241
|
+
.submitMessagesWithoutEncodingHandles === true;
|
|
242
|
+
const contentToSubmit = onlyBind
|
|
243
|
+
? (0, utils_js_1.bindHandles)(content, this.serializer, this.handle)
|
|
244
|
+
: (0, utils_js_1.makeHandlesSerializable)(content, this.serializer, this.handle);
|
|
241
245
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
242
246
|
this.services.deltaConnection.submit(contentToSubmit, localOpMetadata);
|
|
243
247
|
}
|
|
@@ -446,10 +450,10 @@ exports.SharedObjectCore = SharedObjectCore;
|
|
|
446
450
|
class SharedObject extends SharedObjectCore {
|
|
447
451
|
get serializer() {
|
|
448
452
|
/**
|
|
449
|
-
* During garbage collection, the
|
|
453
|
+
* During garbage collection, the GCHandleVisitor "serializer" keeps track of IFluidHandles that are serialized. These
|
|
450
454
|
* handles represent references to other Fluid objects.
|
|
451
455
|
*
|
|
452
|
-
* This is fine for now. However, if we implement delay loading in
|
|
456
|
+
* This is fine for now. However, if we implement delay loading in DDSes, they may load and de-serialize content
|
|
453
457
|
* in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.
|
|
454
458
|
*/
|
|
455
459
|
(0, internal_1.assert)(!this._isGCing, 0x075 /* "SummarySerializer should be used for serializing data during summary." */);
|
|
@@ -491,17 +495,16 @@ class SharedObject extends SharedObjectCore {
|
|
|
491
495
|
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}
|
|
492
496
|
*/
|
|
493
497
|
getGCData(fullGC = false) {
|
|
494
|
-
// Set _isGCing to true. This flag is used to ensure that we only use
|
|
495
|
-
// in this object's data.
|
|
498
|
+
// Set _isGCing to true. This flag is used to ensure that we only use GCHandleVisitor in this codepath and not when trying to truly serialize.
|
|
496
499
|
(0, internal_1.assert)(!this._isGCing, 0x078 /* "Possible re-entrancy! Summary should not already be in progress." */);
|
|
497
500
|
this._isGCing = true;
|
|
498
501
|
let gcData;
|
|
499
502
|
try {
|
|
500
|
-
const
|
|
501
|
-
this.processGCDataCore(
|
|
503
|
+
const handleVisitor = new gcHandleVisitor_js_1.GCHandleVisitor(this.runtime.channelsRoutingContext);
|
|
504
|
+
this.processGCDataCore(handleVisitor);
|
|
502
505
|
// The GC data for this shared object contains a single GC node. The outbound routes of this node are the
|
|
503
506
|
// routes of handles serialized during summarization.
|
|
504
|
-
gcData = { gcNodes: { "/":
|
|
507
|
+
gcData = { gcNodes: { "/": handleVisitor.getVisitedHandlePaths() } };
|
|
505
508
|
(0, internal_1.assert)(this._isGCing, 0x079 /* "Possible re-entrancy! Summary should have been in progress." */);
|
|
506
509
|
}
|
|
507
510
|
finally {
|
|
@@ -512,6 +515,12 @@ class SharedObject extends SharedObjectCore {
|
|
|
512
515
|
/**
|
|
513
516
|
* Calls the serializer over all data in this object that reference other GC nodes.
|
|
514
517
|
* Derived classes must override this to provide custom list of references to other GC nodes.
|
|
518
|
+
*
|
|
519
|
+
* @remarks Serialization itself doesn't matter (the result is ignored). We're tapping into the serialization infrastructure
|
|
520
|
+
* as a way to visit all the content in this content that may reference other objects via handle.
|
|
521
|
+
*
|
|
522
|
+
* @param serializer - The "serializer" (more like handle visitor) to use.
|
|
523
|
+
* Implementations should ensure that serialize is called on all handles, as the way to visit them.
|
|
515
524
|
*/
|
|
516
525
|
processGCDataCore(serializer) {
|
|
517
526
|
// We run the full summarize logic to get the list of outbound routes from this object. This is a little
|