@fluidframework/shared-object-base 2.0.0-rc.2.0.2 → 2.0.0-rc.3.0.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 +31 -0
- package/api-report/shared-object-base.api.md +8 -1
- package/dist/handle.d.ts +1 -1
- package/dist/handle.d.ts.map +1 -1
- package/dist/handle.js +2 -2
- package/dist/handle.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +23 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +17 -0
- package/dist/remoteObjectHandle.d.ts.map +1 -1
- package/dist/remoteObjectHandle.js +6 -6
- package/dist/remoteObjectHandle.js.map +1 -1
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +3 -5
- package/dist/serializer.js.map +1 -1
- package/dist/sharedObject.d.ts +52 -4
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +22 -22
- package/dist/sharedObject.js.map +1 -1
- package/dist/summarySerializer.d.ts.map +1 -1
- package/dist/summarySerializer.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -2
- package/dist/utils.js.map +1 -1
- package/internal.d.ts +11 -0
- package/legacy.d.ts +11 -0
- package/lib/handle.d.ts +1 -1
- package/lib/handle.d.ts.map +1 -1
- package/lib/handle.js +1 -1
- package/lib/handle.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +23 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +17 -0
- package/lib/remoteObjectHandle.d.ts.map +1 -1
- package/lib/remoteObjectHandle.js +3 -3
- package/lib/remoteObjectHandle.js.map +1 -1
- package/lib/serializer.d.ts.map +1 -1
- package/lib/serializer.js +1 -3
- package/lib/serializer.js.map +1 -1
- package/lib/sharedObject.d.ts +52 -4
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +5 -5
- package/lib/sharedObject.js.map +1 -1
- package/lib/summarySerializer.d.ts.map +1 -1
- package/lib/summarySerializer.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +36 -57
- package/src/handle.ts +2 -1
- package/src/index.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/remoteObjectHandle.ts +4 -4
- package/src/serializer.ts +5 -1
- package/src/sharedObject.ts +71 -18
- package/src/summarySerializer.ts +1 -0
- package/src/utils.ts +2 -1
- package/api-extractor-cjs.json +0 -8
- package/dist/shared-object-base-alpha.d.ts +0 -427
- package/dist/shared-object-base-beta.d.ts +0 -118
- package/dist/shared-object-base-public.d.ts +0 -118
- package/dist/shared-object-base-untrimmed.d.ts +0 -513
- package/lib/shared-object-base-alpha.d.ts +0 -427
- package/lib/shared-object-base-beta.d.ts +0 -118
- package/lib/shared-object-base-public.d.ts +0 -118
- package/lib/shared-object-base-untrimmed.d.ts +0 -513
- package/lib/test/attachingBindingAndConnecting.spec.js +0 -334
- package/lib/test/attachingBindingAndConnecting.spec.js.map +0 -1
- package/lib/test/serializer.spec.js +0 -166
- package/lib/test/serializer.spec.js.map +0 -1
- package/lib/test/sharedObject.spec.js +0 -72
- package/lib/test/sharedObject.spec.js.map +0 -1
- package/lib/test/types/validateSharedObjectBasePrevious.generated.js +0 -26
- package/lib/test/types/validateSharedObjectBasePrevious.generated.js.map +0 -1
- package/lib/test/utils.js +0 -37
- package/lib/test/utils.js.map +0 -1
- /package/{dist → lib}/tsdoc-metadata.json +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @fluidframework/shared-object-base
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Packages now use package.json "exports" and require modern module resolution [97d68aa06b](https://github.com/microsoft/FluidFramework/commit/97d68aa06bd5c022ecb026655814aea222a062ae)
|
|
8
|
+
|
|
9
|
+
Fluid Framework packages have been updated to use the [package.json "exports"
|
|
10
|
+
field](https://nodejs.org/docs/latest-v18.x/api/packages.html#exports) to define explicit entry points for both
|
|
11
|
+
TypeScript types and implementation code.
|
|
12
|
+
|
|
13
|
+
This means that using Fluid Framework packages require the following TypeScript settings in tsconfig.json:
|
|
14
|
+
|
|
15
|
+
- `"moduleResolution": "Node16"` with `"module": "Node16"`
|
|
16
|
+
- `"moduleResolution": "Bundler"` with `"module": "ESNext"`
|
|
17
|
+
|
|
18
|
+
We recommend using Node16/Node16 unless absolutely necessary. That will produce transpiled JavaScript that is suitable
|
|
19
|
+
for use with modern versions of Node.js _and_ Bundlers.
|
|
20
|
+
[See the TypeScript documentation](https://www.typescriptlang.org/tsconfig#moduleResolution) for more information
|
|
21
|
+
regarding the module and moduleResolution options.
|
|
22
|
+
|
|
23
|
+
**Node10 moduleResolution is not supported; it does not support Fluid Framework's API structuring pattern that is used
|
|
24
|
+
to distinguish stable APIs from those that are in development.**
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- fluid-framework: Replace SharedObjectClass with new ISharedObjectKind type. [97d68aa06b](https://github.com/microsoft/FluidFramework/commit/97d68aa06bd5c022ecb026655814aea222a062ae)
|
|
29
|
+
|
|
30
|
+
The static objects used as SharedObjectClass now explicitly implement the new ISharedObjectKind type.
|
|
31
|
+
SharedObjectClass has been removed as ISharedObjectKind now fills that role.
|
|
32
|
+
LoadableObjectCtor has been inlined as it only had one use: an external user of it can replace it with `(new (...args: any[]) => T)`.
|
|
33
|
+
|
|
3
34
|
## 2.0.0-rc.2.0.0
|
|
4
35
|
|
|
5
36
|
### Minor Changes
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
7
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
8
|
-
import { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';
|
|
8
|
+
import { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils/internal';
|
|
9
9
|
import { IChannel } from '@fluidframework/datastore-definitions';
|
|
10
10
|
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
|
|
11
|
+
import { IChannelFactory } from '@fluidframework/datastore-definitions';
|
|
11
12
|
import { IChannelServices } from '@fluidframework/datastore-definitions';
|
|
12
13
|
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
|
|
13
14
|
import { IErrorEvent } from '@fluidframework/core-interfaces';
|
|
@@ -69,6 +70,12 @@ export interface ISharedObjectEvents extends IErrorEvent {
|
|
|
69
70
|
(event: "op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
// @public
|
|
74
|
+
export interface ISharedObjectKind<TSharedObject> {
|
|
75
|
+
create(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;
|
|
76
|
+
getFactory(): IChannelFactory<TSharedObject>;
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
// @alpha
|
|
73
80
|
export function makeHandlesSerializable(value: any, serializer: IFluidSerializer, bind: IFluidHandle): any;
|
|
74
81
|
|
package/dist/handle.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { IFluidHandleContext } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { FluidObjectHandle } from "@fluidframework/datastore";
|
|
6
|
+
import { FluidObjectHandle } from "@fluidframework/datastore/internal";
|
|
7
7
|
import { ISharedObject } from "./types.js";
|
|
8
8
|
/**
|
|
9
9
|
* Handle for a shared object.
|
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,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,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;IAfxC;;OAEG;IACH,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED;;;;;;OAMG;gBAEiB,KAAK,EAAE,aAAa,EACvC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,mBAAmB;IAKlC;;;OAGG;IACI,WAAW,IAAI,IAAI;CAI1B"}
|
package/dist/handle.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.SharedObjectHandle = void 0;
|
|
8
|
-
const
|
|
8
|
+
const internal_1 = require("@fluidframework/datastore/internal");
|
|
9
9
|
/**
|
|
10
10
|
* Handle for a shared object.
|
|
11
11
|
*
|
|
@@ -17,7 +17,7 @@ const datastore_1 = require("@fluidframework/datastore");
|
|
|
17
17
|
* {@link @fluidframework/datastore#FluidDataStoreRuntime.request} recognizes requests in the form of
|
|
18
18
|
* '/\<shared object id\>' and loads shared object.
|
|
19
19
|
*/
|
|
20
|
-
class SharedObjectHandle extends
|
|
20
|
+
class SharedObjectHandle extends internal_1.FluidObjectHandle {
|
|
21
21
|
/**
|
|
22
22
|
* Whether services have been attached for the associated shared object.
|
|
23
23
|
*/
|
package/dist/handle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iEAAuE;AAIvE;;;;;;;;;;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,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/internal\";\n\nimport { ISharedObject } from \"./types.js\";\n\n/**\n * Handle for a shared object.\n *\n * @remarks\n *\n * This object is used for already loaded (in-memory) shared objects and is used only for serialization purposes.\n *\n * De-serialization process goes through {@link @fluidframework/datastore#FluidObjectHandle}, and request flow:\n * {@link @fluidframework/datastore#FluidDataStoreRuntime.request} recognizes requests in the form of\n * '/\\<shared object id\\>' and loads shared object.\n */\nexport class SharedObjectHandle extends FluidObjectHandle<ISharedObject> {\n\t/**\n\t * Whether services have been attached for the associated shared object.\n\t */\n\tpublic get isAttached(): boolean {\n\t\treturn this.value.isAttached();\n\t}\n\n\t/**\n\t * Creates a new SharedObjectHandle.\n\t * @param value - The shared object this handle is for.\n\t * @param path - The id of the shared object. It is also the path to this object relative to the routeContext.\n\t * @param routeContext - The parent {@link @fluidframework/core-interfaces#IFluidHandleContext} that has a route\n\t * to this handle.\n\t */\n\tconstructor(\n\t\tprotected readonly value: ISharedObject,\n\t\tpath: string,\n\t\trouteContext: IFluidHandleContext,\n\t) {\n\t\tsuper(value, path, routeContext);\n\t}\n\n\t/**\n\t * Attaches all bound handles first (which may in turn attach further handles), then attaches this handle.\n\t * When attaching the handle, it registers the associated shared object.\n\t */\n\tpublic attachGraph(): void {\n\t\tthis.value.bindToContext();\n\t\tsuper.attachGraph();\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
export { FluidSerializer, IFluidSerializer } from "./serializer.js";
|
|
6
|
-
export { SharedObject, SharedObjectCore } from "./sharedObject.js";
|
|
6
|
+
export { SharedObject, SharedObjectCore, ISharedObjectKind } from "./sharedObject.js";
|
|
7
7
|
export { SummarySerializer } from "./summarySerializer.js";
|
|
8
8
|
export { ISharedObject, ISharedObjectEvents } from "./types.js";
|
|
9
9
|
export { createSingleBlobSummary, makeHandlesSerializable, parseHandles, serializeHandles, bindHandles, } from "./utils.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,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
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,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EACN,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EAChB,WAAW,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAAoE;AAA3D,gHAAA,eAAe,OAAA;AACxB,qDAAsF;AAA7E,+GAAA,YAAY,OAAA;AAAE,mHAAA,gBAAgB,OAAA;AACvC,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAE1B,uCAMoB;AALnB,mHAAA,uBAAuB,OAAA;AACvB,mHAAA,uBAAuB,OAAA;AACvB,wGAAA,YAAY,OAAA;AACZ,4GAAA,gBAAgB,OAAA;AAChB,uGAAA,WAAW,OAAA;AAEZ,+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 { SharedObject, SharedObjectCore, ISharedObjectKind } from \"./sharedObject.js\";\nexport { SummarySerializer } from \"./summarySerializer.js\";\nexport { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nexport {\n\tcreateSingleBlobSummary,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tserializeHandles,\n\tbindHandles,\n} from \"./utils.js\";\nexport { ValueType } from \"./valueType.js\";\n"]}
|
package/dist/legacy.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluidframework/build-tools.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
// public APIs
|
|
13
|
+
IFluidSerializer,
|
|
14
|
+
ISharedObject,
|
|
15
|
+
ISharedObjectEvents,
|
|
16
|
+
ISharedObjectKind,
|
|
17
|
+
|
|
18
|
+
// alpha APIs
|
|
19
|
+
SharedObject,
|
|
20
|
+
SharedObjectCore,
|
|
21
|
+
makeHandlesSerializable,
|
|
22
|
+
parseHandles
|
|
23
|
+
} from "./index.js";
|
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-rc.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-rc.3.0.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/shared-object-base";
|
|
11
|
-
exports.pkgVersion = "2.0.0-rc.
|
|
11
|
+
exports.pkgVersion = "2.0.0-rc.3.0.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,gBAAgB,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-rc.
|
|
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,gBAAgB,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-rc.3.0.0\";\n"]}
|
package/dist/public.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluidframework/build-tools.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
// public APIs
|
|
13
|
+
IFluidSerializer,
|
|
14
|
+
ISharedObject,
|
|
15
|
+
ISharedObjectEvents,
|
|
16
|
+
ISharedObjectKind
|
|
17
|
+
} from "./index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,YAAY,EACZ,mBAAmB,EAEnB,MAAM,iCAAiC,CAAC;AAIzC;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,YAAY;aAiB1C,YAAY,EAAE,MAAM;aACpB,YAAY,EAAE,mBAAmB;IAjBlD,IAAW,mBAAmB,SAE7B;IACD,IAAW,YAAY,SAEtB;IAED,SAAgB,UAAU,QAAQ;IAClC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;OAIG;gBAEc,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,mBAAmB;IAQrC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IAoBzB,WAAW,IAAI,IAAI;IAInB,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;CAGvC"}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.RemoteFluidObjectHandle = void 0;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
8
|
+
const internal_1 = require("@fluidframework/container-runtime/internal");
|
|
9
|
+
const internal_2 = require("@fluidframework/core-utils/internal");
|
|
10
|
+
const internal_3 = require("@fluidframework/runtime-utils/internal");
|
|
11
11
|
/**
|
|
12
12
|
* This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized
|
|
13
13
|
* FluidObjectHandle.
|
|
@@ -31,14 +31,14 @@ class RemoteFluidObjectHandle {
|
|
|
31
31
|
this.absolutePath = absolutePath;
|
|
32
32
|
this.routeContext = routeContext;
|
|
33
33
|
this.isAttached = true;
|
|
34
|
-
(0,
|
|
34
|
+
(0, internal_2.assert)(absolutePath.startsWith("/"), 0x19d /* "Handles should always have absolute paths" */);
|
|
35
35
|
}
|
|
36
36
|
async get() {
|
|
37
37
|
if (this.objectP === undefined) {
|
|
38
38
|
// Add `viaHandle` header to distinguish from requests from non-handle paths.
|
|
39
39
|
const request = {
|
|
40
40
|
url: this.absolutePath,
|
|
41
|
-
headers: { [
|
|
41
|
+
headers: { [internal_1.RuntimeHeaders.viaHandle]: true },
|
|
42
42
|
};
|
|
43
43
|
this.objectP = this.routeContext
|
|
44
44
|
.resolveHandle(request)
|
|
@@ -47,7 +47,7 @@ class RemoteFluidObjectHandle {
|
|
|
47
47
|
const fluidObject = response.value;
|
|
48
48
|
return fluidObject;
|
|
49
49
|
}
|
|
50
|
-
throw (0,
|
|
50
|
+
throw (0, internal_3.responseToException)(response, request);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
return this.objectP;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAA4E;AAO5E,kEAA6D;AAC7D,qEAA6E;AAE7E;;;;;;GAMG;AACH,MAAa,uBAAuB;IACnC,IAAW,mBAAmB;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAKD;;;;OAIG;IACH,YACiB,YAAoB,EACpB,YAAiC;QADjC,iBAAY,GAAZ,YAAY,CAAQ;QACpB,iBAAY,GAAZ,YAAY,CAAqB;QAVlC,eAAU,GAAG,IAAI,CAAC;QAYjC,IAAA,iBAAM,EACL,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAC5B,KAAK,CAAC,iDAAiD,CACvD,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,GAAG;QACf,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;YAC/B,6EAA6E;YAC7E,MAAM,OAAO,GAAa;gBACzB,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,OAAO,EAAE,EAAE,CAAC,yBAAc,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE;aAC7C,CAAC;YACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY;iBAC9B,aAAa,CAAC,OAAO,CAAC;iBACtB,IAAI,CAAc,CAAC,QAAQ,EAAE,EAAE;gBAC/B,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;oBACzC,MAAM,WAAW,GAAgB,QAAQ,CAAC,KAAK,CAAC;oBAChD,OAAO,WAAW,CAAC;iBACnB;gBACD,MAAM,IAAA,8BAAmB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,WAAW;QACjB,OAAO;IACR,CAAC;IAEM,IAAI,CAAC,MAAoB;QAC/B,MAAM,CAAC,WAAW,EAAE,CAAC;IACtB,CAAC;CACD;AArDD,0DAqDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { RuntimeHeaders } from \"@fluidframework/container-runtime/internal\";\nimport {\n\tFluidObject,\n\tIFluidHandle,\n\tIFluidHandleContext,\n\tIRequest,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { responseToException } from \"@fluidframework/runtime-utils/internal\";\n\n/**\n * This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized\n * FluidObjectHandle.\n * This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,\n * custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the\n * IFluidHandle can be retrieved by calling `get` on it.\n */\nexport class RemoteFluidObjectHandle implements IFluidHandle {\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"]}
|
package/dist/serializer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAQpF;;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,MAAM,CAAC;IAElD;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IAItD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAExB,OAAO,CAAC,QAAQ,CAAC,cAAc;IALhC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsB;gBAGzB,OAAO,EAAE,mBAAmB,EAE5B,cAAc,GAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAe;IAQ3E,IAAW,gBAAgB,SAE1B;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY;IAS5C;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAK,EAAE,GAAG;IASjB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY;IAKxC,KAAK,CAAC,KAAK,EAAE,MAAM;IAM1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAM1B;IAIF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAe1B;IAKF,OAAO,CAAC,kBAAkB;IA6C1B,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY;;;;CAOlE"}
|
package/dist/serializer.js
CHANGED
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.FluidSerializer = void 0;
|
|
8
|
-
|
|
9
|
-
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
10
|
-
const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
8
|
+
const internal_1 = require("@fluidframework/runtime-utils/internal");
|
|
11
9
|
const remoteObjectHandle_js_1 = require("./remoteObjectHandle.js");
|
|
12
10
|
/**
|
|
13
11
|
* Data Store serializer implementation
|
|
@@ -31,12 +29,12 @@ class FluidSerializer {
|
|
|
31
29
|
// Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
32
30
|
this.decodeValue = (value) => {
|
|
33
31
|
// If 'value' is a serialized IFluidHandle return the deserialized result.
|
|
34
|
-
if ((0,
|
|
32
|
+
if ((0, internal_1.isSerializedHandle)(value)) {
|
|
35
33
|
// Old documents may have handles with relative path in their summaries. Convert these to absolute
|
|
36
34
|
// paths. This will ensure that future summaries will have absolute paths for these handles.
|
|
37
35
|
const absolutePath = value.url.startsWith("/")
|
|
38
36
|
? value.url
|
|
39
|
-
: (0,
|
|
37
|
+
: (0, internal_1.generateHandleContextPath)(value.url, this.context);
|
|
40
38
|
const parsedHandle = new remoteObjectHandle_js_1.RemoteFluidObjectHandle(absolutePath, this.root);
|
|
41
39
|
this.handleParsedCb(parsedHandle);
|
|
42
40
|
return parsedHandle;
|
package/dist/serializer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts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ACxB,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, isSerializedHandle } from \"@fluidframework/runtime-utils\";\nimport { IFluidHandle, IFluidHandleContext } from \"@fluidframework/core-interfaces\";\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle.js\";\n\n/**\n * @public\n */\nexport interface IFluidSerializer {\n\t/**\n\t * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n\t * where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t */\n\tencode(value: any, bind: IFluidHandle): any;\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tdecode(input: any): any;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\tstringify(value: any, bind: IFluidHandle): string;\n\n\t/**\n\t * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n\t * handles will be realized as part of the parse\n\t */\n\tparse(value: string): any;\n}\n\n/**\n * Data Store serializer implementation\n * @internal\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(\n\t\tprivate readonly context: IFluidHandleContext,\n\t\t// To be called whenever a handle is parsed by this serializer.\n\t\tprivate readonly handleParsedCb: (handle: IFluidHandle) => void = () => {},\n\t) {\n\t\tthis.root = this.context;\n\t\twhile (this.root.routeContext !== undefined) {\n\t\t\tthis.root = this.root.routeContext;\n\t\t}\n\t}\n\n\tpublic get IFluidSerializer() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n\t * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * Any unbound handles encountered are bound to the provided IFluidHandle.\n\t */\n\tpublic encode(input: any, bind: IFluidHandle) {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.encodeValue, bind)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tpublic decode(input: any) {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.decodeValue)\n\t\t\t: input;\n\t}\n\n\tpublic stringify(input: 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"]}
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,qEAGgD;AAEhD,mEAAkE;AAsClE;;;GAGG;AACH,MAAa,eAAe;IAG3B,YACkB,OAA4B;IAC7C,+DAA+D;IAC9C,iBAAiD,GAAG,EAAE,GAAE,CAAC;QAFzD,YAAO,GAAP,OAAO,CAAqB;QAE5B,mBAAc,GAAd,cAAc,CAA2C;QAyD3E,6EAA6E;QAC7E,iFAAiF;QAChE,gBAAW,GAAG,CAAC,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I,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 { IFluidHandle, IFluidHandleContext } from \"@fluidframework/core-interfaces\";\nimport {\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle.js\";\n\n/**\n * @public\n */\nexport interface IFluidSerializer {\n\t/**\n\t * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n\t * where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t */\n\tencode(value: any, bind: IFluidHandle): any;\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tdecode(input: any): any;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\tstringify(value: any, bind: IFluidHandle): string;\n\n\t/**\n\t * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n\t * handles will be realized as part of the parse\n\t */\n\tparse(value: string): any;\n}\n\n/**\n * Data Store serializer implementation\n * @internal\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(\n\t\tprivate readonly context: IFluidHandleContext,\n\t\t// To be called whenever a handle is parsed by this serializer.\n\t\tprivate readonly handleParsedCb: (handle: IFluidHandle) => void = () => {},\n\t) {\n\t\tthis.root = this.context;\n\t\twhile (this.root.routeContext !== undefined) {\n\t\t\tthis.root = this.root.routeContext;\n\t\t}\n\t}\n\n\tpublic get IFluidSerializer() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n\t * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * Any unbound handles encountered are bound to the provided IFluidHandle.\n\t */\n\tpublic encode(input: any, bind: IFluidHandle) {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.encodeValue, bind)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tpublic decode(input: any) {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.decodeValue)\n\t\t\t: input;\n\t}\n\n\tpublic stringify(input: 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/sharedObject.d.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { ITelemetryLoggerExt, EventEmitterWithErrorHandling } from "@fluidframework/telemetry-utils";
|
|
7
5
|
import { EventEmitterEventType } from "@fluid-internal/client-utils";
|
|
8
|
-
import {
|
|
6
|
+
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { IChannelAttributes, type IChannelFactory, IChannelServices, IChannelStorageService, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
|
|
9
8
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
10
|
-
import { IGarbageCollectionData, ISummaryTreeWithStats, ITelemetryContext
|
|
9
|
+
import { IExperimentalIncrementalSummaryContext, IGarbageCollectionData, ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
10
|
+
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
11
|
+
import { EventEmitterWithErrorHandling } from "@fluidframework/telemetry-utils/internal";
|
|
11
12
|
import { IFluidSerializer } from "./serializer.js";
|
|
12
13
|
import { ISharedObject, ISharedObjectEvents } from "./types.js";
|
|
13
14
|
/**
|
|
@@ -301,4 +302,51 @@ export declare abstract class SharedObject<TEvent extends ISharedObjectEvents =
|
|
|
301
302
|
protected abstract summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): ISummaryTreeWithStats;
|
|
302
303
|
private incrementTelemetryMetric;
|
|
303
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Defines a kind of shared object.
|
|
307
|
+
* Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.
|
|
308
|
+
* @public
|
|
309
|
+
*/
|
|
310
|
+
export interface ISharedObjectKind<TSharedObject> {
|
|
311
|
+
/**
|
|
312
|
+
* Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.
|
|
313
|
+
* @remarks
|
|
314
|
+
* The produced factory is intended for use with the FluidDataStoreRegistry and is used by the Fluid Framework to instantiate already existing Channels.
|
|
315
|
+
* To create new shared objects use:
|
|
316
|
+
*
|
|
317
|
+
* - {@link @fluidframework/fluid-static#IFluidContainer.create} if using `@fluidframework/fluid-static`, for example via `@fluidframework/azure-client`.
|
|
318
|
+
*
|
|
319
|
+
* - {@link ISharedObjectKind.create} if using a custom container definitions (and thus not using {@link @fluidframework/fluid-static#IFluidContainer}).
|
|
320
|
+
*
|
|
321
|
+
* @privateRemarks
|
|
322
|
+
* TODO:
|
|
323
|
+
* Many tests use this and can't use {@link ISharedObjectKind.create}.
|
|
324
|
+
* The docs should make it clear why that's ok, and why {@link ISharedObjectKind.create} isn't in such a way that when reading non app code (like tests in this package)
|
|
325
|
+
* someone can tell if the wrong one is being used without running it and seeing if it works.
|
|
326
|
+
*/
|
|
327
|
+
getFactory(): IChannelFactory<TSharedObject>;
|
|
328
|
+
/**
|
|
329
|
+
* Create a shared object.
|
|
330
|
+
* @param runtime - The data store runtime that the new shared object belongs to.
|
|
331
|
+
* @param id - Optional name of the shared object.
|
|
332
|
+
* @returns Newly created shared object.
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* To create a `SharedTree`, call the static create method:
|
|
336
|
+
*
|
|
337
|
+
* ```typescript
|
|
338
|
+
* const myTree = SharedTree.create(this.runtime, id);
|
|
339
|
+
* ```
|
|
340
|
+
* @remarks
|
|
341
|
+
* If using `@fluidframework/fluid-static` (for example via `@fluidframework/azure-client`), use {@link @fluidframework/fluid-static#IFluidContainer.create} instead of calling this directly.
|
|
342
|
+
*
|
|
343
|
+
* @privateRemarks
|
|
344
|
+
* TODO:
|
|
345
|
+
* This returns null when used with MockFluidDataStoreRuntime, so its unclear how tests should create DDS instances unless using `RootDataObject.create` (which most tests shouldn't to minimize dependencies).
|
|
346
|
+
* In practice tests either avoid mock runtimes, use getFactory(), or call the DDS constructor directly. It is unclear (from docs) how getFactory().create differs but it does not rely on runtime.createChannel so it works with mock runtimes.
|
|
347
|
+
* TODO:
|
|
348
|
+
* See note on ISharedObjectKind.getFactory.
|
|
349
|
+
*/
|
|
350
|
+
create(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;
|
|
351
|
+
}
|
|
304
352
|
//# sourceMappingURL=sharedObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
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,EAAE,YAAY,EAA4B,MAAM,iCAAiC,CAAC;AAEzF,OAAO,EAC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AO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;CACpE"}
|
package/dist/sharedObject.js
CHANGED
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.SharedObject = exports.SharedObjectCore = void 0;
|
|
8
|
-
const uuid_1 = require("uuid");
|
|
9
|
-
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
10
|
-
const core_utils_1 = require("@fluidframework/core-utils");
|
|
11
8
|
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
9
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
10
|
+
const internal_2 = require("@fluidframework/runtime-definitions/internal");
|
|
11
|
+
const internal_3 = require("@fluidframework/telemetry-utils/internal");
|
|
12
|
+
const uuid_1 = require("uuid");
|
|
14
13
|
const handle_js_1 = require("./handle.js");
|
|
14
|
+
const serializer_js_1 = require("./serializer.js");
|
|
15
15
|
const summarySerializer_js_1 = require("./summarySerializer.js");
|
|
16
16
|
const utils_js_1 = require("./utils.js");
|
|
17
17
|
/**
|
|
18
18
|
* Base class from which all shared objects derive.
|
|
19
19
|
* @alpha
|
|
20
20
|
*/
|
|
21
|
-
class SharedObjectCore extends
|
|
21
|
+
class SharedObjectCore extends internal_3.EventEmitterWithErrorHandling {
|
|
22
22
|
get IFluidLoadable() {
|
|
23
23
|
return this;
|
|
24
24
|
}
|
|
@@ -47,20 +47,20 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
47
47
|
* True if the dds is bound to its parent.
|
|
48
48
|
*/
|
|
49
49
|
this._isBoundToContext = false;
|
|
50
|
-
(0,
|
|
50
|
+
(0, internal_1.assert)(!id.includes("/"), 0x304 /* Id cannot contain slashes */);
|
|
51
51
|
this.handle = new handle_js_1.SharedObjectHandle(this, id, runtime.IFluidHandleContext);
|
|
52
|
-
this.logger = (0,
|
|
52
|
+
this.logger = (0, internal_3.createChildLogger)({
|
|
53
53
|
logger: runtime.logger,
|
|
54
54
|
properties: {
|
|
55
55
|
all: {
|
|
56
56
|
sharedObjectId: (0, uuid_1.v4)(),
|
|
57
|
-
...(0,
|
|
57
|
+
...(0, internal_3.tagCodeArtifacts)({
|
|
58
58
|
ddsType: this.attributes.type,
|
|
59
59
|
}),
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
});
|
|
63
|
-
this.mc = (0,
|
|
63
|
+
this.mc = (0, internal_3.loggerToMonitoringContext)(this.logger);
|
|
64
64
|
[this.opProcessingHelper, this.callbacksHelper] = this.setUpSampledTelemetryHelpers();
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
@@ -70,15 +70,15 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
70
70
|
* to variables to avoid complaints from TypeScript.
|
|
71
71
|
*/
|
|
72
72
|
setUpSampledTelemetryHelpers() {
|
|
73
|
-
(0,
|
|
74
|
-
const opProcessingHelper = new
|
|
73
|
+
(0, internal_1.assert)(this.mc !== undefined && this.logger !== undefined, 0x349 /* this.mc and/or this.logger has not been set */);
|
|
74
|
+
const opProcessingHelper = new internal_3.SampledTelemetryHelper({
|
|
75
75
|
eventName: "ddsOpProcessing",
|
|
76
76
|
category: "performance",
|
|
77
77
|
}, this.logger, this.mc.config.getNumber("Fluid.SharedObject.OpProcessingTelemetrySampling") ?? 1000, true, new Map([
|
|
78
78
|
["local", { localOp: true }],
|
|
79
79
|
["remote", { localOp: false }],
|
|
80
80
|
]));
|
|
81
|
-
const callbacksHelper = new
|
|
81
|
+
const callbacksHelper = new internal_3.SampledTelemetryHelper({
|
|
82
82
|
eventName: "ddsEventCallbacks",
|
|
83
83
|
category: "performance",
|
|
84
84
|
}, this.logger, this.mc.config.getNumber("Fluid.SharedObject.DdsCallbacksTelemetrySampling") ?? 1000, true);
|
|
@@ -117,7 +117,7 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
117
117
|
* allow processing of ops or local changes, which very quickly results in container closure.
|
|
118
118
|
*/
|
|
119
119
|
eventListenerErrorHandler(event, e) {
|
|
120
|
-
const error =
|
|
120
|
+
const error = internal_3.DataProcessingError.wrapIfUnrecognized(e, "SharedObjectEventListenerException");
|
|
121
121
|
error.addTelemetryProperties({ emittedEventName: String(event) });
|
|
122
122
|
this.closeWithError(error);
|
|
123
123
|
throw error;
|
|
@@ -282,7 +282,7 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
282
282
|
}
|
|
283
283
|
attachDeltaHandler() {
|
|
284
284
|
// Services should already be there in case we are attaching delta handler.
|
|
285
|
-
(0,
|
|
285
|
+
(0, internal_1.assert)(this.services !== undefined, 0x07a /* "Services should be there to attach delta handler" */);
|
|
286
286
|
// attachDeltaHandler is only called after services is assigned
|
|
287
287
|
this.services.deltaConnection.attach({
|
|
288
288
|
process: (message, local, localOpMetadata) => {
|
|
@@ -413,7 +413,7 @@ class SharedObject extends SharedObjectCore {
|
|
|
413
413
|
* This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content
|
|
414
414
|
* in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.
|
|
415
415
|
*/
|
|
416
|
-
(0,
|
|
416
|
+
(0, internal_1.assert)(!this._isGCing, 0x075 /* "SummarySerializer should be used for serializing data during summary." */);
|
|
417
417
|
return this._serializer;
|
|
418
418
|
}
|
|
419
419
|
/**
|
|
@@ -435,8 +435,8 @@ class SharedObject extends SharedObjectCore {
|
|
|
435
435
|
*/
|
|
436
436
|
getAttachSummary(fullTree = false, trackState = false, telemetryContext) {
|
|
437
437
|
const result = this.summarizeCore(this.serializer, telemetryContext);
|
|
438
|
-
this.incrementTelemetryMetric(
|
|
439
|
-
this.incrementTelemetryMetric(
|
|
438
|
+
this.incrementTelemetryMetric(internal_2.blobCountPropertyName, result.stats.blobNodeCount, telemetryContext);
|
|
439
|
+
this.incrementTelemetryMetric(internal_2.totalBlobSizePropertyName, result.stats.totalBlobSize, telemetryContext);
|
|
440
440
|
return result;
|
|
441
441
|
}
|
|
442
442
|
/**
|
|
@@ -444,8 +444,8 @@ class SharedObject extends SharedObjectCore {
|
|
|
444
444
|
*/
|
|
445
445
|
async summarize(fullTree = false, trackState = false, telemetryContext, incrementalSummaryContext) {
|
|
446
446
|
const result = this.summarizeCore(this.serializer, telemetryContext, incrementalSummaryContext);
|
|
447
|
-
this.incrementTelemetryMetric(
|
|
448
|
-
this.incrementTelemetryMetric(
|
|
447
|
+
this.incrementTelemetryMetric(internal_2.blobCountPropertyName, result.stats.blobNodeCount, telemetryContext);
|
|
448
|
+
this.incrementTelemetryMetric(internal_2.totalBlobSizePropertyName, result.stats.totalBlobSize, telemetryContext);
|
|
449
449
|
return result;
|
|
450
450
|
}
|
|
451
451
|
/**
|
|
@@ -454,7 +454,7 @@ class SharedObject extends SharedObjectCore {
|
|
|
454
454
|
getGCData(fullGC = false) {
|
|
455
455
|
// Set _isGCing to true. This flag is used to ensure that we only use SummarySerializer to serialize handles
|
|
456
456
|
// in this object's data.
|
|
457
|
-
(0,
|
|
457
|
+
(0, internal_1.assert)(!this._isGCing, 0x078 /* "Possible re-entrancy! Summary should not already be in progress." */);
|
|
458
458
|
this._isGCing = true;
|
|
459
459
|
let gcData;
|
|
460
460
|
try {
|
|
@@ -463,7 +463,7 @@ class SharedObject extends SharedObjectCore {
|
|
|
463
463
|
// The GC data for this shared object contains a single GC node. The outbound routes of this node are the
|
|
464
464
|
// routes of handles serialized during summarization.
|
|
465
465
|
gcData = { gcNodes: { "/": serializer.getSerializedRoutes() } };
|
|
466
|
-
(0,
|
|
466
|
+
(0, internal_1.assert)(this._isGCing, 0x079 /* "Possible re-entrancy! Summary should have been in progress." */);
|
|
467
467
|
}
|
|
468
468
|
finally {
|
|
469
469
|
this._isGCing = false;
|