@fluidframework/shared-object-base 2.0.0-rc.3.0.2 → 2.0.0-rc.4.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/api-report/shared-object-base.api.md +20 -10
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +2 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/legacy.d.ts +2 -2
  8. package/dist/packageVersion.d.ts +1 -1
  9. package/dist/packageVersion.js +1 -1
  10. package/dist/packageVersion.js.map +1 -1
  11. package/dist/public.d.ts +1 -1
  12. package/dist/remoteObjectHandle.d.ts +5 -5
  13. package/dist/remoteObjectHandle.d.ts.map +1 -1
  14. package/dist/remoteObjectHandle.js +2 -4
  15. package/dist/remoteObjectHandle.js.map +1 -1
  16. package/dist/serializer.d.ts +3 -3
  17. package/dist/serializer.d.ts.map +1 -1
  18. package/dist/serializer.js +5 -4
  19. package/dist/serializer.js.map +1 -1
  20. package/dist/sharedObject.d.ts +18 -16
  21. package/dist/sharedObject.d.ts.map +1 -1
  22. package/dist/sharedObject.js +24 -14
  23. package/dist/sharedObject.js.map +1 -1
  24. package/dist/summarySerializer.d.ts +2 -2
  25. package/dist/summarySerializer.d.ts.map +1 -1
  26. package/dist/summarySerializer.js.map +1 -1
  27. package/lib/index.d.ts +1 -1
  28. package/lib/index.d.ts.map +1 -1
  29. package/lib/index.js +1 -1
  30. package/lib/index.js.map +1 -1
  31. package/lib/legacy.d.ts +2 -2
  32. package/lib/packageVersion.d.ts +1 -1
  33. package/lib/packageVersion.js +1 -1
  34. package/lib/packageVersion.js.map +1 -1
  35. package/lib/public.d.ts +1 -1
  36. package/lib/remoteObjectHandle.d.ts +5 -5
  37. package/lib/remoteObjectHandle.d.ts.map +1 -1
  38. package/lib/remoteObjectHandle.js +3 -5
  39. package/lib/remoteObjectHandle.js.map +1 -1
  40. package/lib/serializer.d.ts +3 -3
  41. package/lib/serializer.d.ts.map +1 -1
  42. package/lib/serializer.js +6 -5
  43. package/lib/serializer.js.map +1 -1
  44. package/lib/sharedObject.d.ts +18 -16
  45. package/lib/sharedObject.d.ts.map +1 -1
  46. package/lib/sharedObject.js +22 -13
  47. package/lib/sharedObject.js.map +1 -1
  48. package/lib/summarySerializer.d.ts +2 -2
  49. package/lib/summarySerializer.d.ts.map +1 -1
  50. package/lib/summarySerializer.js.map +1 -1
  51. package/lib/tsdoc-metadata.json +1 -1
  52. package/package.json +25 -23
  53. package/src/index.ts +6 -1
  54. package/src/packageVersion.ts +1 -1
  55. package/src/remoteObjectHandle.ts +7 -9
  56. package/src/serializer.ts +15 -9
  57. package/src/sharedObject.ts +41 -28
  58. package/src/summarySerializer.ts +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @fluidframework/shared-object-base
2
2
 
3
+ ## 2.0.0-rc.4.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Deprecated members of IFluidHandle are split off into new IFluidHandleInternal interface [96872186d0](https://github.com/microsoft/FluidFramework/commit/96872186d0d0f245c1fece7d19b3743e501679b6)
8
+
9
+ Split IFluidHandle into two interfaces, `IFluidHandle` and `IFluidHandleInternal`.
10
+ Code depending on the previously deprecated members of IFluidHandle can access them by using `toFluidHandleInternal` from `@fluidframework/runtime-utils/legacy`.
11
+
12
+ External implementation of the `IFluidHandle` interface are not supported: this change makes the typing better convey this using the `ErasedType` pattern.
13
+ Any existing and previously working, and now broken, external implementations of `IFluidHandle` should still work at runtime, but will need some unsafe type casts to compile.
14
+ Such handle implementation may break in the future and thus should be replaced with use of handles produced by the Fluid Framework client packages.
15
+
3
16
  ## 2.0.0-rc.3.0.0
4
17
 
5
18
  ### Major Changes
@@ -11,21 +11,30 @@ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
11
11
  import { IChannelFactory } from '@fluidframework/datastore-definitions';
12
12
  import { IChannelServices } from '@fluidframework/datastore-definitions';
13
13
  import { IChannelStorageService } from '@fluidframework/datastore-definitions';
14
+ import type { IDeltaManager } from '@fluidframework/container-definitions/internal';
15
+ import { IDocumentMessage } from '@fluidframework/protocol-definitions';
14
16
  import { IErrorEvent } from '@fluidframework/core-interfaces';
15
17
  import { IEventProvider } from '@fluidframework/core-interfaces';
16
18
  import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
17
19
  import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-definitions';
18
20
  import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
19
- import { IFluidHandle } from '@fluidframework/core-interfaces';
20
- import { IFluidHandleContext } from '@fluidframework/core-interfaces';
21
+ import { IFluidHandle } from '@fluidframework/core-interfaces/internal';
22
+ import { IFluidHandle as IFluidHandle_2 } from '@fluidframework/core-interfaces';
23
+ import { IFluidHandleContext } from '@fluidframework/core-interfaces/internal';
24
+ import { IFluidHandleInternal } from '@fluidframework/core-interfaces/internal';
21
25
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
22
26
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
23
27
  import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
24
28
  import { ITelemetryContext } from '@fluidframework/runtime-definitions';
25
- import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
29
+ import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils/internal';
26
30
 
27
31
  // @internal
28
- export function bindHandles(value: any, serializer: IFluidSerializer, bind: IFluidHandle): void;
32
+ export function bindHandles(value: any, serializer: IFluidSerializer, bind: IFluidHandle_2): void;
33
+
34
+ // @internal
35
+ export function createSharedObjectKind<TSharedObject>(factory: (new () => IChannelFactory<TSharedObject>) & {
36
+ Type: string;
37
+ }): ISharedObjectKind<TSharedObject>;
29
38
 
30
39
  // @internal
31
40
  export function createSingleBlobSummary(key: string, content: string | Uint8Array): ISummaryTreeWithStats;
@@ -40,12 +49,12 @@ export class FluidSerializer implements IFluidSerializer {
40
49
  // (undocumented)
41
50
  parse(input: string): any;
42
51
  // (undocumented)
43
- protected serializeHandle(handle: IFluidHandle, bind: IFluidHandle): {
52
+ protected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal): {
44
53
  type: string;
45
54
  url: string;
46
55
  };
47
56
  // (undocumented)
48
- stringify(input: any, bind: IFluidHandle): string;
57
+ stringify(input: unknown, bind: IFluidHandle): string;
49
58
  }
50
59
 
51
60
  // @public (undocumented)
@@ -77,13 +86,13 @@ export interface ISharedObjectKind<TSharedObject> {
77
86
  }
78
87
 
79
88
  // @alpha
80
- export function makeHandlesSerializable(value: any, serializer: IFluidSerializer, bind: IFluidHandle): any;
89
+ export function makeHandlesSerializable(value: any, serializer: IFluidSerializer, bind: IFluidHandle_2): any;
81
90
 
82
91
  // @alpha
83
92
  export function parseHandles(value: any, serializer: IFluidSerializer): any;
84
93
 
85
94
  // @internal
86
- export function serializeHandles(value: any, serializer: IFluidSerializer, bind: IFluidHandle): string | undefined;
95
+ export function serializeHandles(value: any, serializer: IFluidSerializer, bind: IFluidHandle_2): string | undefined;
87
96
 
88
97
  // @alpha
89
98
  export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends SharedObjectCore<TEvent> {
@@ -106,12 +115,13 @@ export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISha
106
115
  bindToContext(): void;
107
116
  connect(services: IChannelServices): void;
108
117
  get connected(): boolean;
118
+ protected get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
109
119
  protected didAttach(): void;
110
120
  protected dirty(): void;
111
121
  emit(event: EventEmitterEventType, ...args: any[]): boolean;
112
122
  abstract getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
113
123
  abstract getGCData(fullGC?: boolean): IGarbageCollectionData;
114
- readonly handle: IFluidHandle;
124
+ readonly handle: IFluidHandleInternal;
115
125
  protected handleDecoded(decodedHandle: IFluidHandle): void;
116
126
  // (undocumented)
117
127
  id: string;
@@ -141,7 +151,7 @@ export class SummarySerializer extends FluidSerializer {
141
151
  // (undocumented)
142
152
  getSerializedRoutes(): string[];
143
153
  // (undocumented)
144
- protected serializeHandle(handle: IFluidHandle, bind: IFluidHandle): {
154
+ protected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal): {
145
155
  type: string;
146
156
  url: string;
147
157
  };
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, ISharedObjectKind } from "./sharedObject.js";
6
+ export { SharedObject, SharedObjectCore, ISharedObjectKind, createSharedObjectKind, } 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";
@@ -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,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,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 CHANGED
@@ -4,12 +4,13 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ValueType = exports.bindHandles = exports.serializeHandles = exports.parseHandles = exports.makeHandlesSerializable = exports.createSingleBlobSummary = exports.SummarySerializer = exports.SharedObjectCore = exports.SharedObject = exports.FluidSerializer = void 0;
7
+ exports.ValueType = exports.bindHandles = exports.serializeHandles = exports.parseHandles = exports.makeHandlesSerializable = exports.createSingleBlobSummary = exports.SummarySerializer = exports.createSharedObjectKind = exports.SharedObjectCore = exports.SharedObject = exports.FluidSerializer = void 0;
8
8
  var serializer_js_1 = require("./serializer.js");
9
9
  Object.defineProperty(exports, "FluidSerializer", { enumerable: true, get: function () { return serializer_js_1.FluidSerializer; } });
10
10
  var sharedObject_js_1 = require("./sharedObject.js");
11
11
  Object.defineProperty(exports, "SharedObject", { enumerable: true, get: function () { return sharedObject_js_1.SharedObject; } });
12
12
  Object.defineProperty(exports, "SharedObjectCore", { enumerable: true, get: function () { return sharedObject_js_1.SharedObjectCore; } });
13
+ Object.defineProperty(exports, "createSharedObjectKind", { enumerable: true, get: function () { return sharedObject_js_1.createSharedObjectKind; } });
13
14
  var summarySerializer_js_1 = require("./summarySerializer.js");
14
15
  Object.defineProperty(exports, "SummarySerializer", { enumerable: true, get: function () { return summarySerializer_js_1.SummarySerializer; } });
15
16
  var utils_js_1 = require("./utils.js");
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,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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAAoE;AAA3D,gHAAA,eAAe,OAAA;AACxB,qDAK2B;AAJ1B,+GAAA,YAAY,OAAA;AACZ,mHAAA,gBAAgB,OAAA;AAEhB,yHAAA,sBAAsB,OAAA;AAEvB,+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 {\n\tSharedObject,\n\tSharedObjectCore,\n\tISharedObjectKind,\n\tcreateSharedObjectKind,\n} 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 CHANGED
@@ -9,13 +9,13 @@
9
9
  */
10
10
 
11
11
  export {
12
- // public APIs
12
+ // @public APIs
13
13
  IFluidSerializer,
14
14
  ISharedObject,
15
15
  ISharedObjectEvents,
16
16
  ISharedObjectKind,
17
17
 
18
- // alpha APIs
18
+ // @alpha APIs
19
19
  SharedObject,
20
20
  SharedObjectCore,
21
21
  makeHandlesSerializable,
@@ -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.3.0.2";
8
+ export declare const pkgVersion = "2.0.0-rc.4.0.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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.3.0.2";
11
+ exports.pkgVersion = "2.0.0-rc.4.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.3.0.2\";\n"]}
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.4.0.0\";\n"]}
package/dist/public.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  export {
12
- // public APIs
12
+ // @public APIs
13
13
  IFluidSerializer,
14
14
  ISharedObject,
15
15
  ISharedObjectEvents,
@@ -2,7 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IFluidHandle, IFluidHandleContext } from "@fluidframework/core-interfaces";
5
+ import { FluidObject, IFluidHandleContext, type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
6
+ import { FluidHandleBase } from "@fluidframework/runtime-utils/internal";
6
7
  /**
7
8
  * This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized
8
9
  * FluidObjectHandle.
@@ -10,11 +11,10 @@ import { IFluidHandle, IFluidHandleContext } from "@fluidframework/core-interfac
10
11
  * custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the
11
12
  * IFluidHandle can be retrieved by calling `get` on it.
12
13
  */
13
- export declare class RemoteFluidObjectHandle implements IFluidHandle {
14
+ export declare class RemoteFluidObjectHandle extends FluidHandleBase<FluidObject> {
14
15
  readonly absolutePath: string;
15
16
  readonly routeContext: IFluidHandleContext;
16
17
  get IFluidHandleContext(): this;
17
- get IFluidHandle(): this;
18
18
  readonly isAttached = true;
19
19
  private objectP;
20
20
  /**
@@ -23,8 +23,8 @@ export declare class RemoteFluidObjectHandle implements IFluidHandle {
23
23
  * @param routeContext - The root IFluidHandleContext that has a route to this handle.
24
24
  */
25
25
  constructor(absolutePath: string, routeContext: IFluidHandleContext);
26
- get(): Promise<any>;
26
+ get(): Promise<FluidObject>;
27
27
  attachGraph(): void;
28
- bind(handle: IFluidHandle): void;
28
+ bind(handle: IFluidHandleInternal): void;
29
29
  }
30
30
  //# sourceMappingURL=remoteObjectHandle.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,mBAAmB,EACnB,KAAK,oBAAoB,EAEzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,eAAe,EAAuB,MAAM,wCAAwC,CAAC;AAE9F;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,eAAe,CAAC,WAAW,CAAC;aAcvD,YAAY,EAAE,MAAM;aACpB,YAAY,EAAE,mBAAmB;IAdlD,IAAW,mBAAmB,SAE7B;IAED,SAAgB,UAAU,QAAQ;IAClC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;OAIG;gBAEc,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,mBAAmB;IASrC,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;IAoBjC,WAAW,IAAI,IAAI;IAInB,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;CAG/C"}
@@ -15,19 +15,17 @@ const internal_3 = require("@fluidframework/runtime-utils/internal");
15
15
  * custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the
16
16
  * IFluidHandle can be retrieved by calling `get` on it.
17
17
  */
18
- class RemoteFluidObjectHandle {
18
+ class RemoteFluidObjectHandle extends internal_3.FluidHandleBase {
19
19
  get IFluidHandleContext() {
20
20
  return this;
21
21
  }
22
- get IFluidHandle() {
23
- return this;
24
- }
25
22
  /**
26
23
  * Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.
27
24
  * @param absolutePath - The absolute path to the handle from the container runtime.
28
25
  * @param routeContext - The root IFluidHandleContext that has a route to this handle.
29
26
  */
30
27
  constructor(absolutePath, routeContext) {
28
+ super();
31
29
  this.absolutePath = absolutePath;
32
30
  this.routeContext = routeContext;
33
31
  this.isAttached = true;
@@ -1 +1 @@
1
- {"version":3,"file":"remoteObj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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"]}
1
+ {"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAA4E;AAO5E,kEAA6D;AAC7D,qEAA8F;AAE9F;;;;;;GAMG;AACH,MAAa,uBAAwB,SAAQ,0BAA4B;IACxE,IAAW,mBAAmB;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAKD;;;;OAIG;IACH,YACiB,YAAoB,EACpB,YAAiC;QAEjD,KAAK,EAAE,CAAC;QAHQ,iBAAY,GAAZ,YAAY,CAAQ;QACpB,iBAAY,GAAZ,YAAY,CAAqB;QAVlC,eAAU,GAAG,IAAI,CAAC;QAajC,IAAA,iBAAM,EACL,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAC5B,KAAK,CAAC,iDAAiD,CACvD,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,GAAG;QACf,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;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,MAA4B;QACvC,MAAM,CAAC,WAAW,EAAE,CAAC;IACtB,CAAC;CACD;AAnDD,0DAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { RuntimeHeaders } from \"@fluidframework/container-runtime/internal\";\nimport {\n\tFluidObject,\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n\tIRequest,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { FluidHandleBase, responseToException } from \"@fluidframework/runtime-utils/internal\";\n\n/**\n * This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized\n * FluidObjectHandle.\n * This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,\n * custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the\n * IFluidHandle can be retrieved by calling `get` on it.\n */\nexport class RemoteFluidObjectHandle extends FluidHandleBase<FluidObject> {\n\tpublic get IFluidHandleContext() {\n\t\treturn this;\n\t}\n\n\tpublic readonly isAttached = true;\n\tprivate objectP: Promise<FluidObject> | undefined;\n\n\t/**\n\t * Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.\n\t * @param absolutePath - The absolute path to the handle from the container runtime.\n\t * @param routeContext - The root IFluidHandleContext that has a route to this handle.\n\t */\n\tconstructor(\n\t\tpublic readonly absolutePath: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t) {\n\t\tsuper();\n\t\tassert(\n\t\t\tabsolutePath.startsWith(\"/\"),\n\t\t\t0x19d /* \"Handles should always have absolute paths\" */,\n\t\t);\n\t}\n\n\tpublic async get(): Promise<FluidObject> {\n\t\tif (this.objectP === undefined) {\n\t\t\t// Add `viaHandle` header to distinguish from requests from non-handle paths.\n\t\t\tconst request: IRequest = {\n\t\t\t\turl: this.absolutePath,\n\t\t\t\theaders: { [RuntimeHeaders.viaHandle]: true },\n\t\t\t};\n\t\t\tthis.objectP = this.routeContext\n\t\t\t\t.resolveHandle(request)\n\t\t\t\t.then<FluidObject>((response) => {\n\t\t\t\t\tif (response.mimeType === \"fluid/object\") {\n\t\t\t\t\t\tconst fluidObject: FluidObject = response.value;\n\t\t\t\t\t\treturn fluidObject;\n\t\t\t\t\t}\n\t\t\t\t\tthrow responseToException(response, request);\n\t\t\t\t});\n\t\t}\n\t\treturn this.objectP;\n\t}\n\n\tpublic attachGraph(): void {\n\t\treturn;\n\t}\n\n\tpublic bind(handle: IFluidHandleInternal): void {\n\t\thandle.attachGraph();\n\t}\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IFluidHandle, IFluidHandleContext } from "@fluidframework/core-interfaces";
5
+ import { IFluidHandle, IFluidHandleContext, type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
6
6
  /**
7
7
  * @public
8
8
  */
@@ -65,12 +65,12 @@ export declare class FluidSerializer implements IFluidSerializer {
65
65
  * The decoded handles are implicitly bound to the handle context of this serializer.
66
66
  */
67
67
  decode(input: any): any;
68
- stringify(input: any, bind: IFluidHandle): string;
68
+ stringify(input: unknown, bind: IFluidHandle): string;
69
69
  parse(input: string): any;
70
70
  private readonly encodeValue;
71
71
  private readonly decodeValue;
72
72
  private recursivelyReplace;
73
- protected serializeHandle(handle: IFluidHandle, bind: IFluidHandle): {
73
+ protected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal): {
74
74
  type: string;
75
75
  url: string;
76
76
  };
@@ -1 +1 @@
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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B;IA6C1B,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,oBAAoB,EAAE,IAAI,EAAE,oBAAoB;;;;CAOlF"}
@@ -20,10 +20,10 @@ class FluidSerializer {
20
20
  // If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.
21
21
  // Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.
22
22
  this.encodeValue = (value, bind) => {
23
- // Detect if 'value' is an IFluidHandle.
24
- const handle = value?.IFluidHandle;
25
23
  // If 'value' is an IFluidHandle return its encoded form.
26
- return handle !== undefined ? this.serializeHandle(handle, bind) : value;
24
+ return (0, internal_1.isFluidHandle)(value)
25
+ ? this.serializeHandle((0, internal_1.toFluidHandleInternal)(value), bind)
26
+ : value;
27
27
  };
28
28
  // If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
29
29
  // Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
@@ -86,7 +86,8 @@ class FluidSerializer {
86
86
  : input;
87
87
  }
88
88
  stringify(input, bind) {
89
- return JSON.stringify(input, (key, value) => this.encodeValue(value, bind));
89
+ const bindInternal = (0, internal_1.toFluidHandleInternal)(bind);
90
+ return JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));
90
91
  }
91
92
  // Parses the serialized data - context must match the context with which the JSON was stringified
92
93
  parse(input) {
@@ -1 +1 @@
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,KAAU,EAAE,IAAkB,EAAE,EAAE;YACjE,wCAAwC;YACxC,MAA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,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"]}
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUH,qEAKgD;AAEhD,mEAAkE;AAsClE;;;GAGG;AACH,MAAa,eAAe;IAG3B,YACkB,OAA4B;IAC7C,+DAA+D;IAC9C,iBAAiD,GAAG,EAAE,GAAE,CAAC;QAFzD,YAAO,GAAP,OAAO,CAAqB;QAE5B,mBAAc,GAAd,cAAc,CAA2C;QA0D3E,6EAA6E;QAC7E,iFAAiF;QAChE,gBAAW,GAAG,CAAC,KAAc,EAAE,IAA0B,EAAE,EAAE;YAC7E,yDAAyD;YACzD,OAAO,IAAA,wBAAa,EAAC,KAAK,CAAC;gBAC1B,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,IAAA,gCAAqB,EAAC,KAAK,CAAC,EAAE,IAAI,CAAC;gBAC1D,CAAC,CAAC,KAAK,CAAC;QACV,CAAC,CAAC;QAEF,qFAAqF;QACrF,6EAA6E;QAC5D,gBAAW,GAAG,CAAC,KAAU,EAAE,EAAE;YAC7C,0EAA0E;YAC1E,IAAI,IAAA,6BAAkB,EAAC,KAAK,C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C;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,MAA4B,EAAE,IAA0B;QACjF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,MAAM,CAAC,YAAY;SACxB,CAAC;IACH,CAAC;CACD;AAnJD,0CAmJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// RATIONALE: Many methods consume and return 'any' by necessity.\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n\nimport {\n\tIFluidHandle,\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport {\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n\tisFluidHandle,\n\ttoFluidHandleInternal,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle.js\";\n\n/**\n * @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: unknown, bind: IFluidHandle) {\n\t\tconst bindInternal = toFluidHandleInternal(bind);\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));\n\t}\n\n\t// Parses the serialized data - context must match the context with which the JSON was stringified\n\tpublic parse(input: string) {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\n\t// If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.\n\t// Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.\n\tprivate readonly encodeValue = (value: unknown, bind: IFluidHandleInternal) => {\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\treturn isFluidHandle(value)\n\t\t\t? this.serializeHandle(toFluidHandleInternal(value), bind)\n\t\t\t: value;\n\t};\n\n\t// If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.\n\t// Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.\n\tprivate readonly decodeValue = (value: any) => {\n\t\t// If 'value' is a serialized IFluidHandle return the deserialized result.\n\t\tif (isSerializedHandle(value)) {\n\t\t\t// Old documents may have handles with relative path in their summaries. Convert these to absolute\n\t\t\t// paths. This will ensure that future summaries will have absolute paths for these handles.\n\t\t\tconst absolutePath = value.url.startsWith(\"/\")\n\t\t\t\t? value.url\n\t\t\t\t: generateHandleContextPath(value.url, this.context);\n\n\t\t\tconst parsedHandle = new RemoteFluidObjectHandle(absolutePath, this.root);\n\t\t\tthis.handleParsedCb(parsedHandle);\n\t\t\treturn parsedHandle;\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t};\n\n\t// Invoked for non-null objects to recursively replace references to IFluidHandles.\n\t// Clones as-needed to avoid mutating the `input` object. If no IFluidHandes are present,\n\t// returns the original `input`.\n\tprivate recursivelyReplace(\n\t\tinput: any,\n\t\treplacer: (input: any, context: any) => any,\n\t\tcontext?: any,\n\t) {\n\t\t// Note: Caller is responsible for ensuring that `input` is defined / non-null.\n\t\t// (Required for Object.keys() below.)\n\n\t\t// Execute the `replace` on the current input. Note that Caller is responsible for ensuring that `input`\n\t\t// is a non-null object.\n\t\tconst maybeReplaced = replacer(input, context);\n\n\t\t// If 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: IFluidHandleInternal, bind: IFluidHandleInternal) {\n\t\tbind.bind(handle);\n\t\treturn {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: handle.absolutePath,\n\t\t};\n\t}\n}\n"]}
@@ -3,12 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { EventEmitterEventType } from "@fluid-internal/client-utils";
6
- import { IFluidHandle } from "@fluidframework/core-interfaces";
6
+ import { IFluidHandle, type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
7
7
  import { IChannelAttributes, type IChannelFactory, IChannelServices, IChannelStorageService, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
8
- import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
+ import { ISequencedDocumentMessage, type IDocumentMessage } from "@fluidframework/protocol-definitions";
9
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";
10
+ import { ITelemetryLoggerExt, EventEmitterWithErrorHandling } from "@fluidframework/telemetry-utils/internal";
11
+ import type { IDeltaManager } from "@fluidframework/container-definitions/internal";
12
12
  import { IFluidSerializer } from "./serializer.js";
13
13
  import { ISharedObject, ISharedObjectEvents } from "./types.js";
14
14
  /**
@@ -25,7 +25,7 @@ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvent
25
25
  /**
26
26
  * The handle referring to this SharedObject
27
27
  */
28
- readonly handle: IFluidHandle;
28
+ readonly handle: IFluidHandleInternal;
29
29
  /**
30
30
  * Telemetry logger for the shared object
31
31
  */
@@ -58,6 +58,10 @@ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvent
58
58
  * @param attributes - Attributes of the shared object
59
59
  */
60
60
  constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
61
+ /**
62
+ * Accessor for `this.runtime`'s {@link @fluidframework/datastore-definitions#IFluidDataStoreRuntime.deltaManager} as a {@link @fluidframework/container-definitions/internal#IDeltaManager}
63
+ */
64
+ protected get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
61
65
  /**
62
66
  * This function is only supposed to be called from SharedObjectCore's constructor and
63
67
  * depends on a few things being set already. assert() calls make sure of it.
@@ -317,12 +321,6 @@ export interface ISharedObjectKind<TSharedObject> {
317
321
  * - {@link @fluidframework/fluid-static#IFluidContainer.create} if using `@fluidframework/fluid-static`, for example via `@fluidframework/azure-client`.
318
322
  *
319
323
  * - {@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
324
  */
327
325
  getFactory(): IChannelFactory<TSharedObject>;
328
326
  /**
@@ -338,15 +336,19 @@ export interface ISharedObjectKind<TSharedObject> {
338
336
  * const myTree = SharedTree.create(this.runtime, id);
339
337
  * ```
340
338
  * @remarks
339
+ * The created object is local (detached): insert a handle to it into an attached object to share (attach) it.
341
340
  * If using `@fluidframework/fluid-static` (for example via `@fluidframework/azure-client`), use {@link @fluidframework/fluid-static#IFluidContainer.create} instead of calling this directly.
342
341
  *
343
342
  * @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.
343
+ * This can only be used with a `MockFluidDataStoreRuntime` when that mock is created with a `registry` containing a factory for this shared object.
349
344
  */
350
345
  create(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;
351
346
  }
347
+ /**
348
+ * Utility for creating ISharedObjectKind instances.
349
+ * @internal
350
+ */
351
+ export declare function createSharedObjectKind<TSharedObject>(factory: (new () => IChannelFactory<TSharedObject>) & {
352
+ Type: string;
353
+ }): ISharedObjectKind<TSharedObject>;
352
354
  //# sourceMappingURL=sharedObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,YAAY,EAA4B,MAAM,iCAAiC,CAAC;AAEzF,OAAO,EACN,kBAAkB,EAClB,KAAK,eAAe,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,sCAAsC,EACtC,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAK7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAEN,6BAA6B,EAM7B,MAAM,0CAA0C,CAAC;AAIlD,OAAO,EAAmB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGhE;;;GAGG;AACH,8BAAsB,gBAAgB,CAAC,MAAM,SA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,CAAC,aAAa,EACnD,OAAO,EAAE,CAAC,UAAU,eAAe,CAAC,aAAa,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GACpE,iBAAiB,CAAC,aAAa,CAAC,CAUlC"}
@@ -4,12 +4,13 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.SharedObject = exports.SharedObjectCore = void 0;
7
+ exports.createSharedObjectKind = exports.SharedObject = exports.SharedObjectCore = void 0;
8
8
  const container_definitions_1 = require("@fluidframework/container-definitions");
9
9
  const internal_1 = require("@fluidframework/core-utils/internal");
10
10
  const internal_2 = require("@fluidframework/runtime-definitions/internal");
11
11
  const internal_3 = require("@fluidframework/telemetry-utils/internal");
12
12
  const uuid_1 = require("uuid");
13
+ const internal_4 = require("@fluidframework/runtime-utils/internal");
13
14
  const handle_js_1 = require("./handle.js");
14
15
  const serializer_js_1 = require("./serializer.js");
15
16
  const summarySerializer_js_1 = require("./summarySerializer.js");
@@ -63,6 +64,12 @@ class SharedObjectCore extends internal_3.EventEmitterWithErrorHandling {
63
64
  this.mc = (0, internal_3.loggerToMonitoringContext)(this.logger);
64
65
  [this.opProcessingHelper, this.callbacksHelper] = this.setUpSampledTelemetryHelpers();
65
66
  }
67
+ /**
68
+ * Accessor for `this.runtime`'s {@link @fluidframework/datastore-definitions#IFluidDataStoreRuntime.deltaManager} as a {@link @fluidframework/container-definitions/internal#IDeltaManager}
69
+ */
70
+ get deltaManager() {
71
+ return (0, internal_4.toDeltaManagerInternal)(this.runtime.deltaManager);
72
+ }
66
73
  /**
67
74
  * This function is only supposed to be called from SharedObjectCore's constructor and
68
75
  * depends on a few things being set already. assert() calls make sure of it.
@@ -372,19 +379,7 @@ class SharedObjectCore extends internal_3.EventEmitterWithErrorHandling {
372
379
  */
373
380
  emit(event, ...args) {
374
381
  return this.callbacksHelper.measure(() => {
375
- // Creating ops while handling a DDS event can lead
376
- // to undefined behavior and events observed in the wrong order.
377
- // For example, we have two callbacks registered for a DDS, A and B.
378
- // Then if on change #1 callback A creates change #2, the invocation flow will be:
379
- //
380
- // A because of #1
381
- // A because of #2
382
- // B because of #2
383
- // B because of #1
384
- //
385
- // The runtime must enforce op coherence by not allowing any ops to be created during
386
- // the event handler
387
- return this.runtime.ensureNoDataModelChanges(() => super.emit(event, ...args));
382
+ return super.emit(event, ...args);
388
383
  });
389
384
  }
390
385
  /**
@@ -487,4 +482,19 @@ class SharedObject extends SharedObjectCore {
487
482
  }
488
483
  }
489
484
  exports.SharedObject = SharedObject;
485
+ /**
486
+ * Utility for creating ISharedObjectKind instances.
487
+ * @internal
488
+ */
489
+ function createSharedObjectKind(factory) {
490
+ return {
491
+ getFactory() {
492
+ return new factory();
493
+ },
494
+ create(runtime, id) {
495
+ return runtime.createChannel(id, factory.Type);
496
+ },
497
+ };
498
+ }
499
+ exports.createSharedObjectKind = createSharedObjectKind;
490
500
  //# sourceMappingURL=sharedObject.js.map