@fluidframework/shared-object-base 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +3 -3
- package/api-report/shared-object-base.api.md +14 -15
- package/dist/{handle.js → handle.cjs} +1 -1
- package/dist/handle.cjs.map +1 -0
- package/dist/{index.js → index.cjs} +6 -6
- package/dist/index.cjs.map +1 -0
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/{remoteObjectHandle.js → remoteObjectHandle.cjs} +1 -1
- package/dist/remoteObjectHandle.cjs.map +1 -0
- package/dist/{serializer.js → serializer.cjs} +6 -2
- package/dist/serializer.cjs.map +1 -0
- package/dist/serializer.d.ts +8 -0
- package/dist/serializer.d.ts.map +1 -1
- package/dist/shared-object-base-alpha.d.ts +443 -0
- package/dist/shared-object-base-beta.d.ts +82 -0
- package/dist/shared-object-base-public.d.ts +82 -0
- package/dist/shared-object-base-untrimmed.d.ts +506 -0
- package/dist/{sharedObject.js → sharedObject.cjs} +6 -7
- package/dist/sharedObject.cjs.map +1 -0
- package/dist/sharedObject.d.ts +2 -3
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/{summarySerializer.js → summarySerializer.cjs} +3 -2
- package/dist/summarySerializer.cjs.map +1 -0
- package/dist/summarySerializer.d.ts +1 -0
- package/dist/summarySerializer.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{types.js → types.cjs} +1 -1
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{utils.js → utils.cjs} +5 -1
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/{valueType.js → valueType.cjs} +2 -1
- package/dist/valueType.cjs.map +1 -0
- package/dist/valueType.d.ts +1 -0
- package/dist/valueType.d.ts.map +1 -1
- package/lib/handle.d.ts +1 -1
- package/lib/handle.d.ts.map +1 -1
- package/lib/{handle.js → handle.mjs} +1 -1
- package/lib/handle.mjs.map +1 -0
- package/lib/index.d.ts +6 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.mjs +10 -0
- package/lib/index.mjs.map +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/remoteObjectHandle.d.ts.map +1 -1
- package/lib/{remoteObjectHandle.js → remoteObjectHandle.mjs} +1 -1
- package/lib/remoteObjectHandle.mjs.map +1 -0
- package/lib/serializer.d.ts +8 -0
- package/lib/serializer.d.ts.map +1 -1
- package/lib/{serializer.js → serializer.mjs} +6 -4
- package/lib/serializer.mjs.map +1 -0
- package/lib/shared-object-base-alpha.d.ts +443 -0
- package/lib/shared-object-base-beta.d.ts +82 -0
- package/lib/shared-object-base-public.d.ts +82 -0
- package/lib/shared-object-base-untrimmed.d.ts +506 -0
- package/lib/sharedObject.d.ts +5 -6
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/{sharedObject.js → sharedObject.mjs} +6 -7
- package/lib/sharedObject.mjs.map +1 -0
- package/lib/summarySerializer.d.ts +2 -1
- package/lib/summarySerializer.d.ts.map +1 -1
- package/lib/{summarySerializer.js → summarySerializer.mjs} +3 -2
- package/lib/summarySerializer.mjs.map +1 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/{types.js → types.mjs} +1 -1
- package/lib/types.mjs.map +1 -0
- package/lib/utils.d.ts +5 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/{utils.js → utils.mjs} +5 -1
- package/lib/utils.mjs.map +1 -0
- package/lib/valueType.d.ts +1 -0
- package/lib/valueType.d.ts.map +1 -1
- package/lib/{valueType.js → valueType.mjs} +2 -1
- package/lib/valueType.mjs.map +1 -0
- package/package.json +50 -30
- package/src/packageVersion.ts +1 -1
- package/src/serializer.ts +8 -0
- package/src/sharedObject.ts +2 -3
- package/src/summarySerializer.ts +1 -0
- package/src/types.ts +2 -0
- package/src/utils.ts +4 -0
- package/src/valueType.ts +1 -0
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +5 -3
- package/dist/handle.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/remoteObjectHandle.js.map +0 -1
- package/dist/serializer.js.map +0 -1
- package/dist/sharedObject.js.map +0 -1
- package/dist/summarySerializer.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/dist/valueType.js.map +0 -1
- package/lib/handle.js.map +0 -1
- package/lib/index.js +0 -10
- package/lib/index.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/remoteObjectHandle.js.map +0 -1
- package/lib/serializer.js.map +0 -1
- package/lib/sharedObject.js.map +0 -1
- package/lib/summarySerializer.js.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/utils.js.map +0 -1
- package/lib/valueType.js.map +0 -1
- package/tsconfig.esnext.json +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-lint.json",
|
|
4
|
+
"messages": {
|
|
5
|
+
"extractorMessageReporting": {
|
|
6
|
+
// TODO: remove once base config has this enabled as an error
|
|
7
|
+
"ae-incompatible-release-tags": {
|
|
8
|
+
"logLevel": "error",
|
|
9
|
+
"addToApiReportFile": false
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
package/api-extractor.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-base.json",
|
|
4
4
|
"messages": {
|
|
5
5
|
"extractorMessageReporting": {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// TODO: Add missing documentation and remove this rule override
|
|
7
|
+
"ae-undocumented": {
|
|
8
8
|
"logLevel": "none"
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -23,10 +23,10 @@ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
|
|
|
23
23
|
import { ITelemetryContext } from '@fluidframework/runtime-definitions';
|
|
24
24
|
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
|
|
25
25
|
|
|
26
|
-
// @
|
|
26
|
+
// @internal
|
|
27
27
|
export function createSingleBlobSummary(key: string, content: string | Uint8Array): ISummaryTreeWithStats;
|
|
28
28
|
|
|
29
|
-
// @
|
|
29
|
+
// @alpha
|
|
30
30
|
export class FluidSerializer implements IFluidSerializer {
|
|
31
31
|
constructor(context: IFluidHandleContext, handleParsedCb: (handle: IFluidHandle) => void);
|
|
32
32
|
decode(input: any): any;
|
|
@@ -44,7 +44,7 @@ export class FluidSerializer implements IFluidSerializer {
|
|
|
44
44
|
stringify(input: any, bind: IFluidHandle): string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// @
|
|
47
|
+
// @alpha (undocumented)
|
|
48
48
|
export interface IFluidSerializer {
|
|
49
49
|
decode(input: any): any;
|
|
50
50
|
encode(value: any, bind: IFluidHandle): any;
|
|
@@ -52,7 +52,7 @@ export interface IFluidSerializer {
|
|
|
52
52
|
stringify(value: any, bind: IFluidHandle): string;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
// @
|
|
55
|
+
// @internal
|
|
56
56
|
export interface ISerializedHandle {
|
|
57
57
|
// (undocumented)
|
|
58
58
|
type: "__fluid_handle__";
|
|
@@ -60,13 +60,13 @@ export interface ISerializedHandle {
|
|
|
60
60
|
url: string;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
// @
|
|
63
|
+
// @alpha
|
|
64
64
|
export interface ISharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends IChannel, IEventProvider<TEvent> {
|
|
65
65
|
bindToContext(): void;
|
|
66
66
|
getGCData(fullGC?: boolean): IGarbageCollectionData;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
// @
|
|
69
|
+
// @alpha
|
|
70
70
|
export interface ISharedObjectEvents extends IErrorEvent {
|
|
71
71
|
// @eventProperty
|
|
72
72
|
(event: "pre-op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
@@ -74,19 +74,19 @@ export interface ISharedObjectEvents extends IErrorEvent {
|
|
|
74
74
|
(event: "op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
// @
|
|
77
|
+
// @internal (undocumented)
|
|
78
78
|
export const isSerializedHandle: (value: any) => value is ISerializedHandle;
|
|
79
79
|
|
|
80
|
-
// @
|
|
80
|
+
// @internal
|
|
81
81
|
export function makeHandlesSerializable(value: any, serializer: IFluidSerializer, bind: IFluidHandle): any;
|
|
82
82
|
|
|
83
|
-
// @
|
|
83
|
+
// @internal
|
|
84
84
|
export function parseHandles(value: any, serializer: IFluidSerializer): any;
|
|
85
85
|
|
|
86
|
-
// @
|
|
86
|
+
// @internal
|
|
87
87
|
export function serializeHandles(value: any, serializer: IFluidSerializer, bind: IFluidHandle): string | undefined;
|
|
88
88
|
|
|
89
|
-
// @
|
|
89
|
+
// @alpha
|
|
90
90
|
export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends SharedObjectCore<TEvent> {
|
|
91
91
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, telemetryContextPrefix: string);
|
|
92
92
|
// (undocumented)
|
|
@@ -100,7 +100,7 @@ export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedO
|
|
|
100
100
|
protected abstract summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): ISummaryTreeWithStats;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
// @
|
|
103
|
+
// @alpha
|
|
104
104
|
export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {
|
|
105
105
|
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
|
|
106
106
|
protected abstract applyStashedOp(content: any): unknown;
|
|
@@ -112,7 +112,6 @@ export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISha
|
|
|
112
112
|
get connected(): boolean;
|
|
113
113
|
protected didAttach(): void;
|
|
114
114
|
protected dirty(): void;
|
|
115
|
-
// @internal
|
|
116
115
|
emit(event: EventEmitterEventType, ...args: any[]): boolean;
|
|
117
116
|
// (undocumented)
|
|
118
117
|
abstract getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
@@ -143,7 +142,7 @@ export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISha
|
|
|
143
142
|
abstract summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
// @
|
|
145
|
+
// @alpha
|
|
147
146
|
export class SummarySerializer extends FluidSerializer {
|
|
148
147
|
// (undocumented)
|
|
149
148
|
getSerializedRoutes(): string[];
|
|
@@ -154,7 +153,7 @@ export class SummarySerializer extends FluidSerializer {
|
|
|
154
153
|
};
|
|
155
154
|
}
|
|
156
155
|
|
|
157
|
-
// @
|
|
156
|
+
// @internal
|
|
158
157
|
export enum ValueType {
|
|
159
158
|
Plain = 1,
|
|
160
159
|
// @deprecated
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.cjs","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yDAA8D;AAG9D;;;;;;;;;;GAUG;AACH,MAAa,kBAAmB,SAAQ,6BAAgC;IACvE;;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\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { ISharedObject } from \"./types\";\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"]}
|
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ValueType = exports.serializeHandles = exports.parseHandles = exports.makeHandlesSerializable = exports.createSingleBlobSummary = exports.SummarySerializer = exports.SharedObjectCore = exports.SharedObject = exports.isSerializedHandle = exports.FluidSerializer = void 0;
|
|
8
|
-
var serializer_1 = require("./serializer");
|
|
8
|
+
var serializer_1 = require("./serializer.cjs");
|
|
9
9
|
Object.defineProperty(exports, "FluidSerializer", { enumerable: true, get: function () { return serializer_1.FluidSerializer; } });
|
|
10
10
|
Object.defineProperty(exports, "isSerializedHandle", { enumerable: true, get: function () { return serializer_1.isSerializedHandle; } });
|
|
11
|
-
var sharedObject_1 = require("./sharedObject");
|
|
11
|
+
var sharedObject_1 = require("./sharedObject.cjs");
|
|
12
12
|
Object.defineProperty(exports, "SharedObject", { enumerable: true, get: function () { return sharedObject_1.SharedObject; } });
|
|
13
13
|
Object.defineProperty(exports, "SharedObjectCore", { enumerable: true, get: function () { return sharedObject_1.SharedObjectCore; } });
|
|
14
|
-
var summarySerializer_1 = require("./summarySerializer");
|
|
14
|
+
var summarySerializer_1 = require("./summarySerializer.cjs");
|
|
15
15
|
Object.defineProperty(exports, "SummarySerializer", { enumerable: true, get: function () { return summarySerializer_1.SummarySerializer; } });
|
|
16
|
-
var utils_1 = require("./utils");
|
|
16
|
+
var utils_1 = require("./utils.cjs");
|
|
17
17
|
Object.defineProperty(exports, "createSingleBlobSummary", { enumerable: true, get: function () { return utils_1.createSingleBlobSummary; } });
|
|
18
18
|
Object.defineProperty(exports, "makeHandlesSerializable", { enumerable: true, get: function () { return utils_1.makeHandlesSerializable; } });
|
|
19
19
|
Object.defineProperty(exports, "parseHandles", { enumerable: true, get: function () { return utils_1.parseHandles; } });
|
|
20
20
|
Object.defineProperty(exports, "serializeHandles", { enumerable: true, get: function () { return utils_1.serializeHandles; } });
|
|
21
|
-
var valueType_1 = require("./valueType");
|
|
21
|
+
var valueType_1 = require("./valueType.cjs");
|
|
22
22
|
Object.defineProperty(exports, "ValueType", { enumerable: true, get: function () { return valueType_1.ValueType; } });
|
|
23
|
-
//# sourceMappingURL=index.
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAKsB;AAJrB,6GAAA,eAAe,OAAA;AAGf,gHAAA,kBAAkB,OAAA;AAEnB,mDAAgE;AAAvD,4GAAA,YAAY,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AACvC,6DAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAE1B,qCAKiB;AAJhB,gHAAA,uBAAuB,OAAA;AACvB,gHAAA,uBAAuB,OAAA;AACvB,qGAAA,YAAY,OAAA;AACZ,yGAAA,gBAAgB,OAAA;AAEjB,6CAAwC;AAA/B,sGAAA,SAAS,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tFluidSerializer,\n\tIFluidSerializer,\n\tISerializedHandle,\n\tisSerializedHandle,\n} from \"./serializer\";\nexport { SharedObject, SharedObjectCore } from \"./sharedObject\";\nexport { SummarySerializer } from \"./summarySerializer\";\nexport { ISharedObject, ISharedObjectEvents } from \"./types\";\nexport {\n\tcreateSingleBlobSummary,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tserializeHandles,\n} from \"./utils\";\nexport { ValueType } from \"./valueType\";\n"]}
|
|
@@ -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-internal.7.
|
|
12
|
-
//# sourceMappingURL=packageVersion.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.7.4.0";
|
|
12
|
+
//# sourceMappingURL=packageVersion.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.cjs","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,sBAAsB,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-internal.7.4.0\";\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-internal.7.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.7.4.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteObjectHandle.cjs","sourceRoot":"","sources":["../src/remoteObjectHandle.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,CAAC,MAAoB;QAC/B,MAAM,CAAC,WAAW,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,IAAI;YACH,gDAAgD;YAChD,MAAM,MAAM,GAA8B,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;YAEnC,OAAO,MAAM,KAAK,SAAS;gBAC1B,CAAC,CAAC,IAAA,iCAAiB,EAAC,OAAO,CAAC;gBAC5B,CAAC,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;SACjC;QAAC,OAAO,KAAK,EAAE;YACf,OAAO,IAAA,mCAAmB,EAAC,KAAK,CAAC,CAAC;SAClC;IACF,CAAC;CACD;AA5ED,0DA4EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { RuntimeHeaders } from \"@fluidframework/container-runtime\";\nimport {\n\tIFluidHandle,\n\tIFluidHandleContext,\n\tIRequest,\n\tIResponse,\n\tFluidObject,\n\t// eslint-disable-next-line import/no-deprecated\n\tIFluidRouter,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tcreate404Response,\n\texceptionToResponse,\n\tresponseToException,\n} from \"@fluidframework/runtime-utils\";\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 implements IFluidHandle {\n\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\tpublic get IFluidRouter() {\n\t\treturn this;\n\t}\n\tpublic get IFluidHandleContext() {\n\t\treturn this;\n\t}\n\tpublic get IFluidHandle() {\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\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<any> {\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: IFluidHandle): void {\n\t\thandle.attachGraph();\n\t}\n\n\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\ttry {\n\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\tconst object: FluidObject<IFluidRouter> = await this.get();\n\t\t\tconst router = object.IFluidRouter;\n\n\t\t\treturn router === undefined\n\t\t\t\t? create404Response(request)\n\t\t\t\t: await router.request(request);\n\t\t} catch (error) {\n\t\t\treturn exceptionToResponse(error);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -8,11 +8,15 @@ exports.FluidSerializer = exports.isSerializedHandle = void 0;
|
|
|
8
8
|
// RATIONALE: Many methods consume and return 'any' by necessity.
|
|
9
9
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
10
10
|
const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
11
|
-
const remoteObjectHandle_1 = require("./remoteObjectHandle");
|
|
11
|
+
const remoteObjectHandle_1 = require("./remoteObjectHandle.cjs");
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
12
15
|
const isSerializedHandle = (value) => value?.type === "__fluid_handle__";
|
|
13
16
|
exports.isSerializedHandle = isSerializedHandle;
|
|
14
17
|
/**
|
|
15
18
|
* Data Store serializer implementation
|
|
19
|
+
* @alpha
|
|
16
20
|
*/
|
|
17
21
|
class FluidSerializer {
|
|
18
22
|
constructor(context,
|
|
@@ -142,4 +146,4 @@ class FluidSerializer {
|
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
exports.FluidSerializer = FluidSerializer;
|
|
145
|
-
//# sourceMappingURL=serializer.
|
|
149
|
+
//# sourceMappingURL=serializer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.cjs","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iEAAiE;AACjE,wDAAwD;AAExD,iEAA0E;AAE1E,iEAA+D;AAc/D;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAU,EAA8B,EAAE,CAC5E,KAAK,EAAE,IAAI,KAAK,kBAAkB,CAAC;AADvB,QAAA,kBAAkB,sBACK;AAsCpC;;;GAGG;AACH,MAAa,eAAe;IAG3B,YACkB,OAA4B;IAC7C,+DAA+D;IAC9C,cAA8C;QAF9C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KAAK,KAAK,EAAE;YAC5B,OAAO,aAAa,CAAC;SACrB;QAED,8EAA8E;QAC9E,IAAI,KAAyB,CAAC;QAC9B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACrC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACzB,yEAAyE;YACzE,IAAI,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBACzC,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;oBACvB,qFAAqF;oBACrF,KAAK,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;oBAEpE,+EAA+E;oBAC/E,oEAAoE;oBACpE,KAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;iBACvB;aACD;SACD;QACD,OAAO,KAAK,IAAI,KAAK,CAAC;IACvB,CAAC;IAES,eAAe,CAAC,MAAoB,EAAE,IAAkB;QACjE,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 { generateHandleContextPath } from \"@fluidframework/runtime-utils\";\nimport { IFluidHandle, IFluidHandleContext } from \"@fluidframework/core-interfaces\";\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle\";\n\n/**\n * JSON serialized form of an IFluidHandle\n * @internal\n */\nexport interface ISerializedHandle {\n\t// Marker to indicate to JSON.parse that the object is a Fluid handle\n\ttype: \"__fluid_handle__\";\n\n\t// URL to the object. Relative URLs are relative to the handle context passed to the stringify.\n\turl: string;\n}\n\n/**\n * @internal\n */\nexport const isSerializedHandle = (value: any): value is ISerializedHandle =>\n\tvalue?.type === \"__fluid_handle__\";\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 * @alpha\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: any, bind: IFluidHandle) {\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bind));\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: any, bind: IFluidHandle) => {\n\t\t// Detect if 'value' is an IFluidHandle.\n\t\tconst handle = value?.IFluidHandle;\n\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\treturn handle !== undefined ? this.serializeHandle(handle, bind) : 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 the replacer made a substitution there is no need to decscend further. IFluidHandles are always\n\t\t// leaves in the object graph.\n\t\tif (maybeReplaced !== input) {\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: IFluidHandle, bind: IFluidHandle) {\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/serializer.d.ts
CHANGED
|
@@ -5,12 +5,19 @@
|
|
|
5
5
|
import { IFluidHandle, IFluidHandleContext } from "@fluidframework/core-interfaces";
|
|
6
6
|
/**
|
|
7
7
|
* JSON serialized form of an IFluidHandle
|
|
8
|
+
* @internal
|
|
8
9
|
*/
|
|
9
10
|
export interface ISerializedHandle {
|
|
10
11
|
type: "__fluid_handle__";
|
|
11
12
|
url: string;
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
13
17
|
export declare const isSerializedHandle: (value: any) => value is ISerializedHandle;
|
|
18
|
+
/**
|
|
19
|
+
* @alpha
|
|
20
|
+
*/
|
|
14
21
|
export interface IFluidSerializer {
|
|
15
22
|
/**
|
|
16
23
|
* Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object
|
|
@@ -42,6 +49,7 @@ export interface IFluidSerializer {
|
|
|
42
49
|
}
|
|
43
50
|
/**
|
|
44
51
|
* Data Store serializer implementation
|
|
52
|
+
* @alpha
|
|
45
53
|
*/
|
|
46
54
|
export declare class FluidSerializer implements IFluidSerializer {
|
|
47
55
|
private readonly context;
|
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;AAMH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGpF
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGpF;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAEjC,IAAI,EAAE,kBAAkB,CAAC;IAGzB,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,UAAW,GAAG,+BACV,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,GAAG,GAAG,CAAC;IAE5C;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAAC;IAExB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,GAAG,MAA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