@fluidframework/datastore 2.0.0-rc.1.0.3 → 2.0.0-rc.2.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 (117) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +4 -1
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +42 -0
  4. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  5. package/api-extractor-lint.json +1 -1
  6. package/api-extractor.json +1 -1
  7. package/api-report/datastore.api.md +5 -11
  8. package/dist/channelContext.d.ts +5 -4
  9. package/dist/channelContext.d.ts.map +1 -1
  10. package/dist/channelContext.js +6 -5
  11. package/dist/channelContext.js.map +1 -1
  12. package/dist/channelDeltaConnection.d.ts +6 -3
  13. package/dist/channelDeltaConnection.d.ts.map +1 -1
  14. package/dist/channelDeltaConnection.js +46 -7
  15. package/dist/channelDeltaConnection.js.map +1 -1
  16. package/dist/dataStoreRuntime.d.ts +24 -6
  17. package/dist/dataStoreRuntime.d.ts.map +1 -1
  18. package/dist/dataStoreRuntime.js +103 -36
  19. package/dist/dataStoreRuntime.js.map +1 -1
  20. package/dist/datastore-alpha.d.ts +22 -6
  21. package/dist/datastore-beta.d.ts +1 -2
  22. package/dist/datastore-public.d.ts +1 -2
  23. package/dist/datastore-untrimmed.d.ts +22 -6
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +7 -7
  27. package/dist/index.js.map +1 -1
  28. package/dist/localChannelContext.d.ts +18 -3
  29. package/dist/localChannelContext.d.ts.map +1 -1
  30. package/dist/localChannelContext.js +32 -10
  31. package/dist/localChannelContext.js.map +1 -1
  32. package/dist/package.json +3 -0
  33. package/dist/remoteChannelContext.d.ts +2 -2
  34. package/dist/remoteChannelContext.d.ts.map +1 -1
  35. package/dist/remoteChannelContext.js +6 -5
  36. package/dist/remoteChannelContext.js.map +1 -1
  37. package/dist/tsdoc-metadata.json +1 -1
  38. package/lib/{channelContext.d.mts → channelContext.d.ts} +6 -5
  39. package/lib/channelContext.d.ts.map +1 -0
  40. package/lib/{channelContext.mjs → channelContext.js} +6 -5
  41. package/lib/channelContext.js.map +1 -0
  42. package/lib/{channelDeltaConnection.d.mts → channelDeltaConnection.d.ts} +7 -4
  43. package/lib/channelDeltaConnection.d.ts.map +1 -0
  44. package/lib/channelDeltaConnection.js +92 -0
  45. package/lib/channelDeltaConnection.js.map +1 -0
  46. package/lib/{channelStorageService.d.mts → channelStorageService.d.ts} +1 -1
  47. package/lib/channelStorageService.d.ts.map +1 -0
  48. package/lib/{channelStorageService.mjs → channelStorageService.js} +1 -1
  49. package/lib/channelStorageService.js.map +1 -0
  50. package/lib/{dataStoreRuntime.d.mts → dataStoreRuntime.d.ts} +25 -7
  51. package/lib/dataStoreRuntime.d.ts.map +1 -0
  52. package/lib/{dataStoreRuntime.mjs → dataStoreRuntime.js} +100 -33
  53. package/lib/dataStoreRuntime.js.map +1 -0
  54. package/lib/{datastore-alpha.d.mts → datastore-alpha.d.ts} +22 -6
  55. package/lib/{datastore-public.d.mts → datastore-beta.d.ts} +1 -2
  56. package/lib/{datastore-beta.d.mts → datastore-public.d.ts} +1 -2
  57. package/lib/{datastore-untrimmed.d.mts → datastore-untrimmed.d.ts} +22 -6
  58. package/lib/{fluidHandle.d.mts → fluidHandle.d.ts} +1 -1
  59. package/lib/fluidHandle.d.ts.map +1 -0
  60. package/lib/{fluidHandle.mjs → fluidHandle.js} +1 -1
  61. package/lib/fluidHandle.js.map +1 -0
  62. package/lib/{index.d.mts → index.d.ts} +3 -3
  63. package/lib/index.d.ts.map +1 -0
  64. package/lib/{index.mjs → index.js} +3 -3
  65. package/lib/index.js.map +1 -0
  66. package/lib/{localChannelContext.d.mts → localChannelContext.d.ts} +19 -4
  67. package/lib/localChannelContext.d.ts.map +1 -0
  68. package/lib/{localChannelContext.mjs → localChannelContext.js} +29 -7
  69. package/lib/localChannelContext.js.map +1 -0
  70. package/lib/{localChannelStorageService.d.mts → localChannelStorageService.d.ts} +1 -1
  71. package/lib/localChannelStorageService.d.ts.map +1 -0
  72. package/lib/{localChannelStorageService.mjs → localChannelStorageService.js} +1 -1
  73. package/lib/localChannelStorageService.js.map +1 -0
  74. package/lib/{remoteChannelContext.d.mts → remoteChannelContext.d.ts} +3 -3
  75. package/lib/remoteChannelContext.d.ts.map +1 -0
  76. package/lib/{remoteChannelContext.mjs → remoteChannelContext.js} +4 -3
  77. package/lib/remoteChannelContext.js.map +1 -0
  78. package/lib/test/channelStorageService.spec.js +70 -0
  79. package/lib/test/channelStorageService.spec.js.map +1 -0
  80. package/lib/test/dataStoreRuntime.spec.js +121 -0
  81. package/lib/test/dataStoreRuntime.spec.js.map +1 -0
  82. package/lib/test/localChannelContext.spec.js +41 -0
  83. package/lib/test/localChannelContext.spec.js.map +1 -0
  84. package/lib/test/localChannelStorageService.spec.js +72 -0
  85. package/lib/test/localChannelStorageService.spec.js.map +1 -0
  86. package/lib/test/remoteChannelContext.spec.js +33 -0
  87. package/lib/test/remoteChannelContext.spec.js.map +1 -0
  88. package/lib/test/types/validateDatastorePrevious.generated.js +16 -0
  89. package/lib/test/types/validateDatastorePrevious.generated.js.map +1 -0
  90. package/package.json +48 -50
  91. package/src/channelContext.ts +6 -3
  92. package/src/channelDeltaConnection.ts +69 -5
  93. package/src/dataStoreRuntime.ts +127 -46
  94. package/src/index.ts +2 -2
  95. package/src/localChannelContext.ts +38 -5
  96. package/src/remoteChannelContext.ts +4 -2
  97. package/tsconfig.cjs.json +7 -0
  98. package/tsconfig.json +2 -5
  99. package/lib/channelContext.d.mts.map +0 -1
  100. package/lib/channelContext.mjs.map +0 -1
  101. package/lib/channelDeltaConnection.d.mts.map +0 -1
  102. package/lib/channelDeltaConnection.mjs +0 -53
  103. package/lib/channelDeltaConnection.mjs.map +0 -1
  104. package/lib/channelStorageService.d.mts.map +0 -1
  105. package/lib/channelStorageService.mjs.map +0 -1
  106. package/lib/dataStoreRuntime.d.mts.map +0 -1
  107. package/lib/dataStoreRuntime.mjs.map +0 -1
  108. package/lib/fluidHandle.d.mts.map +0 -1
  109. package/lib/fluidHandle.mjs.map +0 -1
  110. package/lib/index.d.mts.map +0 -1
  111. package/lib/index.mjs.map +0 -1
  112. package/lib/localChannelContext.d.mts.map +0 -1
  113. package/lib/localChannelContext.mjs.map +0 -1
  114. package/lib/localChannelStorageService.d.mts.map +0 -1
  115. package/lib/localChannelStorageService.mjs.map +0 -1
  116. package/lib/remoteChannelContext.d.mts.map +0 -1
  117. package/lib/remoteChannelContext.mjs.map +0 -1
@@ -13,9 +13,8 @@ import { IFluidDataStoreRuntimeEvents } from '@fluidframework/datastore-definiti
13
13
  import { IFluidHandle } from '@fluidframework/core-interfaces';
14
14
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
15
15
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
16
- import { IIdCompressor } from '@fluidframework/runtime-definitions';
16
+ import { IIdCompressor } from '@fluidframework/id-compressor';
17
17
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
18
- import { ILoaderOptions } from '@fluidframework/container-definitions';
19
18
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
20
19
  import { IRequest } from '@fluidframework/core-interfaces';
21
20
  import { IResponse } from '@fluidframework/core-interfaces';
@@ -68,7 +67,7 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
68
67
  visibilityState: VisibilityState;
69
68
  private readonly pendingHandlesToMakeVisible;
70
69
  readonly id: string;
71
- readonly options: ILoaderOptions;
70
+ readonly options: Record<string | number, any>;
72
71
  readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
73
72
  private readonly quorum;
74
73
  private readonly audience;
@@ -105,6 +104,13 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
105
104
  resolveHandle(request: IRequest): Promise<IResponse>;
106
105
  request(request: IRequest): Promise<IResponse>;
107
106
  getChannel(id: string): Promise<IChannel>;
107
+ /**
108
+ * Validate user provided channel ID
109
+ * Channel ID has limitations. "/" is not allowed as IDs in storage can not have slashes - we parse tree paths and use "/" as separator.
110
+ * IDs cannot start with "_" as it could result in collision of IDs with auto-assigned (by FF) short IDs.
111
+ * @param id - channel ID.
112
+ */
113
+ protected validateChannelId(id: string): void;
108
114
  /**
109
115
  * Api which allows caller to create the channel first and then add it to the runtime.
110
116
  * The channel type should be present in the registry, otherwise the runtime would reject
@@ -113,7 +119,7 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
113
119
  * @param channel - channel which needs to be added to the runtime.
114
120
  */
115
121
  addChannel(channel: IChannel): void;
116
- createChannel(id: string | undefined, type: string): IChannel;
122
+ createChannel(idArg: string | undefined, type: string): IChannel;
117
123
  private createChannelContext;
118
124
  /**
119
125
  * Binds a channel with the runtime. If the runtime is attached we will attach the channel right away.
@@ -196,6 +202,15 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
196
202
  */
197
203
  summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
198
204
  getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
205
+ /**
206
+ * Get the GC Data for the initial state being attached so remote clients can learn of this DataStore's outbound routes
207
+ */
208
+ getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData;
209
+ /**
210
+ * Helper method for preparing to attach this dataStore.
211
+ * Runs the callback for each bound context to incorporate its data however the caller specifies
212
+ */
213
+ private visitLocalBoundContextsDuringAttach;
199
214
  submitMessage(type: DataStoreMessageType, content: any, localOpMetadata: unknown): void;
200
215
  /**
201
216
  * Submits the signal to be sent to other clients.
@@ -209,9 +224,10 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
209
224
  */
210
225
  waitAttached(): Promise<void>;
211
226
  /**
212
- * Attach channel should only be called after the data store has been attached
227
+ * Assuming this DataStore is already attached, this will make the given channel locally visible
228
+ * by submitting its attach op.
213
229
  */
214
- private attachChannel;
230
+ private makeChannelLocallyVisible;
215
231
  private submitChannelOp;
216
232
  private submit;
217
233
  /**
@@ -13,9 +13,8 @@ import { IFluidDataStoreRuntimeEvents } from '@fluidframework/datastore-definiti
13
13
  import { IFluidHandle } from '@fluidframework/core-interfaces';
14
14
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
15
15
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
16
- import { IIdCompressor } from '@fluidframework/runtime-definitions';
16
+ import { IIdCompressor } from '@fluidframework/id-compressor';
17
17
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
18
- import { ILoaderOptions } from '@fluidframework/container-definitions';
19
18
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
20
19
  import { IRequest } from '@fluidframework/core-interfaces';
21
20
  import { IResponse } from '@fluidframework/core-interfaces';
@@ -13,9 +13,8 @@ import { IFluidDataStoreRuntimeEvents } from '@fluidframework/datastore-definiti
13
13
  import { IFluidHandle } from '@fluidframework/core-interfaces';
14
14
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
15
15
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
16
- import { IIdCompressor } from '@fluidframework/runtime-definitions';
16
+ import { IIdCompressor } from '@fluidframework/id-compressor';
17
17
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
18
- import { ILoaderOptions } from '@fluidframework/container-definitions';
19
18
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
20
19
  import { IRequest } from '@fluidframework/core-interfaces';
21
20
  import { IResponse } from '@fluidframework/core-interfaces';
@@ -13,9 +13,8 @@ import { IFluidDataStoreRuntimeEvents } from '@fluidframework/datastore-definiti
13
13
  import { IFluidHandle } from '@fluidframework/core-interfaces';
14
14
  import { IFluidHandleContext } from '@fluidframework/core-interfaces';
15
15
  import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
16
- import { IIdCompressor } from '@fluidframework/runtime-definitions';
16
+ import { IIdCompressor } from '@fluidframework/id-compressor';
17
17
  import { IInboundSignalMessage } from '@fluidframework/runtime-definitions';
18
- import { ILoaderOptions } from '@fluidframework/container-definitions';
19
18
  import { IQuorumClients } from '@fluidframework/protocol-definitions';
20
19
  import { IRequest } from '@fluidframework/core-interfaces';
21
20
  import { IResponse } from '@fluidframework/core-interfaces';
@@ -68,7 +67,7 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
68
67
  visibilityState: VisibilityState;
69
68
  private readonly pendingHandlesToMakeVisible;
70
69
  readonly id: string;
71
- readonly options: ILoaderOptions;
70
+ readonly options: Record<string | number, any>;
72
71
  readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;
73
72
  private readonly quorum;
74
73
  private readonly audience;
@@ -105,6 +104,13 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
105
104
  resolveHandle(request: IRequest): Promise<IResponse>;
106
105
  request(request: IRequest): Promise<IResponse>;
107
106
  getChannel(id: string): Promise<IChannel>;
107
+ /**
108
+ * Validate user provided channel ID
109
+ * Channel ID has limitations. "/" is not allowed as IDs in storage can not have slashes - we parse tree paths and use "/" as separator.
110
+ * IDs cannot start with "_" as it could result in collision of IDs with auto-assigned (by FF) short IDs.
111
+ * @param id - channel ID.
112
+ */
113
+ protected validateChannelId(id: string): void;
108
114
  /**
109
115
  * Api which allows caller to create the channel first and then add it to the runtime.
110
116
  * The channel type should be present in the registry, otherwise the runtime would reject
@@ -113,7 +119,7 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
113
119
  * @param channel - channel which needs to be added to the runtime.
114
120
  */
115
121
  addChannel(channel: IChannel): void;
116
- createChannel(id: string | undefined, type: string): IChannel;
122
+ createChannel(idArg: string | undefined, type: string): IChannel;
117
123
  private createChannelContext;
118
124
  /**
119
125
  * Binds a channel with the runtime. If the runtime is attached we will attach the channel right away.
@@ -196,6 +202,15 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
196
202
  */
197
203
  summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
198
204
  getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
205
+ /**
206
+ * Get the GC Data for the initial state being attached so remote clients can learn of this DataStore's outbound routes
207
+ */
208
+ getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData;
209
+ /**
210
+ * Helper method for preparing to attach this dataStore.
211
+ * Runs the callback for each bound context to incorporate its data however the caller specifies
212
+ */
213
+ private visitLocalBoundContextsDuringAttach;
199
214
  submitMessage(type: DataStoreMessageType, content: any, localOpMetadata: unknown): void;
200
215
  /**
201
216
  * Submits the signal to be sent to other clients.
@@ -209,9 +224,10 @@ export declare class FluidDataStoreRuntime extends TypedEventEmitter<IFluidDataS
209
224
  */
210
225
  waitAttached(): Promise<void>;
211
226
  /**
212
- * Attach channel should only be called after the data store has been attached
227
+ * Assuming this DataStore is already attached, this will make the given channel locally visible
228
+ * by submitting its attach op.
213
229
  */
214
- private attachChannel;
230
+ private makeChannelLocallyVisible;
215
231
  private submitChannelOp;
216
232
  private submit;
217
233
  /**
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { FluidObjectHandle } from "./fluidHandle";
6
- export { DataStoreMessageType, FluidDataStoreRuntime, ISharedObjectRegistry, mixinRequestHandler, mixinSummaryHandler, } from "./dataStoreRuntime";
5
+ export { FluidObjectHandle } from "./fluidHandle.js";
6
+ export { DataStoreMessageType, FluidDataStoreRuntime, ISharedObjectRegistry, mixinRequestHandler, mixinSummaryHandler, } from "./dataStoreRuntime.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACN,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACN,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -5,11 +5,11 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.mixinSummaryHandler = exports.mixinRequestHandler = exports.FluidDataStoreRuntime = exports.DataStoreMessageType = exports.FluidObjectHandle = void 0;
8
- var fluidHandle_1 = require("./fluidHandle");
9
- Object.defineProperty(exports, "FluidObjectHandle", { enumerable: true, get: function () { return fluidHandle_1.FluidObjectHandle; } });
10
- var dataStoreRuntime_1 = require("./dataStoreRuntime");
11
- Object.defineProperty(exports, "DataStoreMessageType", { enumerable: true, get: function () { return dataStoreRuntime_1.DataStoreMessageType; } });
12
- Object.defineProperty(exports, "FluidDataStoreRuntime", { enumerable: true, get: function () { return dataStoreRuntime_1.FluidDataStoreRuntime; } });
13
- Object.defineProperty(exports, "mixinRequestHandler", { enumerable: true, get: function () { return dataStoreRuntime_1.mixinRequestHandler; } });
14
- Object.defineProperty(exports, "mixinSummaryHandler", { enumerable: true, get: function () { return dataStoreRuntime_1.mixinSummaryHandler; } });
8
+ var fluidHandle_js_1 = require("./fluidHandle.js");
9
+ Object.defineProperty(exports, "FluidObjectHandle", { enumerable: true, get: function () { return fluidHandle_js_1.FluidObjectHandle; } });
10
+ var dataStoreRuntime_js_1 = require("./dataStoreRuntime.js");
11
+ Object.defineProperty(exports, "DataStoreMessageType", { enumerable: true, get: function () { return dataStoreRuntime_js_1.DataStoreMessageType; } });
12
+ Object.defineProperty(exports, "FluidDataStoreRuntime", { enumerable: true, get: function () { return dataStoreRuntime_js_1.FluidDataStoreRuntime; } });
13
+ Object.defineProperty(exports, "mixinRequestHandler", { enumerable: true, get: function () { return dataStoreRuntime_js_1.mixinRequestHandler; } });
14
+ Object.defineProperty(exports, "mixinSummaryHandler", { enumerable: true, get: function () { return dataStoreRuntime_js_1.mixinSummaryHandler; } });
15
15
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,uDAM4B;AAL3B,wHAAA,oBAAoB,OAAA;AACpB,yHAAA,qBAAqB,OAAA;AAErB,uHAAA,mBAAmB,OAAA;AACnB,uHAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { FluidObjectHandle } from \"./fluidHandle\";\nexport {\n\tDataStoreMessageType,\n\tFluidDataStoreRuntime,\n\tISharedObjectRegistry,\n\tmixinRequestHandler,\n\tmixinSummaryHandler,\n} from \"./dataStoreRuntime\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAAqD;AAA5C,mHAAA,iBAAiB,OAAA;AAC1B,6DAM+B;AAL9B,2HAAA,oBAAoB,OAAA;AACpB,4HAAA,qBAAqB,OAAA;AAErB,0HAAA,mBAAmB,OAAA;AACnB,0HAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { FluidObjectHandle } from \"./fluidHandle.js\";\nexport {\n\tDataStoreMessageType,\n\tFluidDataStoreRuntime,\n\tISharedObjectRegistry,\n\tmixinRequestHandler,\n\tmixinSummaryHandler,\n} from \"./dataStoreRuntime.js\";\n"]}
@@ -9,8 +9,8 @@ import { IChannel, IFluidDataStoreRuntime } from "@fluidframework/datastore-defi
9
9
  import { IFluidDataStoreContext, IGarbageCollectionData, ISummarizeResult, ITelemetryContext } from "@fluidframework/runtime-definitions";
10
10
  import { Lazy } from "@fluidframework/core-utils";
11
11
  import { IFluidHandle } from "@fluidframework/core-interfaces";
12
- import { ChannelServiceEndpoints, IChannelContext } from "./channelContext";
13
- import { ISharedObjectRegistry } from "./dataStoreRuntime";
12
+ import { ChannelServiceEndpoints, IChannelContext } from "./channelContext.js";
13
+ import { ISharedObjectRegistry } from "./dataStoreRuntime.js";
14
14
  /**
15
15
  * Channel context for a locally created channel
16
16
  */
@@ -23,13 +23,14 @@ export declare abstract class LocalChannelContextBase implements IChannelContext
23
23
  private globallyVisible;
24
24
  protected readonly pending: ISequencedDocumentMessage[];
25
25
  constructor(id: string, runtime: IFluidDataStoreRuntime, services: Lazy<ChannelServiceEndpoints>, channelP: Promise<IChannel>, _channel?: IChannel | undefined);
26
+ protected get isGloballyVisible(): boolean;
26
27
  getChannel(): Promise<IChannel>;
27
28
  get isLoaded(): boolean;
28
29
  setConnectionState(connected: boolean, clientId?: string): void;
29
30
  processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
30
31
  reSubmit(content: any, localOpMetadata: unknown): void;
31
32
  rollback(content: any, localOpMetadata: unknown): void;
32
- applyStashedOp(): void;
33
+ abstract applyStashedOp(content: unknown): unknown;
33
34
  /**
34
35
  * Returns a summary at the current sequence number.
35
36
  * @param fullTree - true to bypass optimizations and force a full summary tree
@@ -37,7 +38,19 @@ export declare abstract class LocalChannelContextBase implements IChannelContext
37
38
  * @param telemetryContext - summary data passed through the layers for telemetry purposes
38
39
  */
39
40
  summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummarizeResult>;
41
+ /**
42
+ * For crafting the DataStore attach op. Only to be called when the channel is loaded (if applicable).
43
+ *
44
+ * Synchronously generates the channel's attach summary to be joined with the same from the DataStore's other channels
45
+ */
40
46
  getAttachSummary(telemetryContext?: ITelemetryContext): ISummarizeResult;
47
+ /**
48
+ * For crafting the DataStore attach op. Only to be called when the channel is loaded (if applicable).
49
+ *
50
+ * Synchronously generates the channel's attach GC data (set of outbound routes in the initial state)
51
+ * to be joined with the same from the DataStore's other channels
52
+ */
53
+ getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData;
41
54
  makeVisible(): void;
42
55
  /**
43
56
  * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.
@@ -52,6 +65,7 @@ export declare class RehydratedLocalChannelContext extends LocalChannelContextBa
52
65
  private readonly snapshotTree;
53
66
  private readonly dirtyFn;
54
67
  constructor(id: string, registry: ISharedObjectRegistry, runtime: IFluidDataStoreRuntime, dataStoreContext: IFluidDataStoreContext, storageService: IDocumentStorageService, logger: ITelemetryLoggerExt, submitFn: (content: any, localOpMetadata: unknown) => void, dirtyFn: (address: string) => void, addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void, snapshotTree: ISnapshotTree);
68
+ applyStashedOp(content: any): unknown;
55
69
  private isSnapshotInOldFormatAndCollectBlobs;
56
70
  private sanitizeSnapshot;
57
71
  }
@@ -59,5 +73,6 @@ export declare class LocalChannelContext extends LocalChannelContextBase {
59
73
  readonly channel: IChannel;
60
74
  private readonly dirtyFn;
61
75
  constructor(channel: IChannel, runtime: IFluidDataStoreRuntime, dataStoreContext: IFluidDataStoreContext, storageService: IDocumentStorageService, logger: ITelemetryLoggerExt, submitFn: (content: any, localOpMetadata: unknown) => void, dirtyFn: (address: string) => void, addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void);
76
+ applyStashedOp(): void;
62
77
  }
63
78
  //# sourceMappingURL=localChannelContext.d.ts.map
@@ -1 +1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AAK,IAAI,EAClC,0BAA0B,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,KAAK,IAAI;IA0BrF,cAAc;CAGrB"}
@@ -13,7 +13,7 @@ const lodash_1 = __importDefault(require("lodash"));
13
13
  const { cloneDeep } = lodash_1.default;
14
14
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
15
15
  const core_utils_1 = require("@fluidframework/core-utils");
16
- const channelContext_1 = require("./channelContext");
16
+ const channelContext_js_1 = require("./channelContext.js");
17
17
  /**
18
18
  * Channel context for a locally created channel
19
19
  */
@@ -28,6 +28,9 @@ class LocalChannelContextBase {
28
28
  this.pending = [];
29
29
  (0, core_utils_1.assert)(!this.id.includes("/"), 0x30f /* Channel context ID cannot contain slashes */);
30
30
  }
31
+ get isGloballyVisible() {
32
+ return this.globallyVisible;
33
+ }
31
34
  async getChannel() {
32
35
  if (this._channel === undefined) {
33
36
  return this.channelP.then((c) => (this._channel = c));
@@ -66,9 +69,6 @@ class LocalChannelContextBase {
66
69
  (0, core_utils_1.assert)(this.globallyVisible, 0x2ef /* "Local channel must be globally visible when rolling back op" */);
67
70
  this.services.value.deltaConnection.rollback(content, localOpMetadata);
68
71
  }
69
- applyStashedOp() {
70
- throw new Error("no stashed ops on local channel");
71
- }
72
72
  /**
73
73
  * Returns a summary at the current sequence number.
74
74
  * @param fullTree - true to bypass optimizations and force a full summary tree
@@ -77,11 +77,27 @@ class LocalChannelContextBase {
77
77
  */
78
78
  async summarize(fullTree = false, trackState = false, telemetryContext) {
79
79
  const channel = await this.getChannel();
80
- return (0, channelContext_1.summarizeChannelAsync)(channel, fullTree, trackState, telemetryContext);
80
+ return (0, channelContext_js_1.summarizeChannelAsync)(channel, fullTree, trackState, telemetryContext);
81
81
  }
82
+ /**
83
+ * For crafting the DataStore attach op. Only to be called when the channel is loaded (if applicable).
84
+ *
85
+ * Synchronously generates the channel's attach summary to be joined with the same from the DataStore's other channels
86
+ */
82
87
  getAttachSummary(telemetryContext) {
83
88
  (0, core_utils_1.assert)(this._channel !== undefined, 0x18d /* "Channel should be loaded to take snapshot" */);
84
- return (0, channelContext_1.summarizeChannel)(this._channel, true /* fullTree */, false /* trackState */, telemetryContext);
89
+ return (0, channelContext_js_1.summarizeChannel)(this._channel, true /* fullTree */, false /* trackState */, telemetryContext);
90
+ }
91
+ /**
92
+ * For crafting the DataStore attach op. Only to be called when the channel is loaded (if applicable).
93
+ *
94
+ * Synchronously generates the channel's attach GC data (set of outbound routes in the initial state)
95
+ * to be joined with the same from the DataStore's other channels
96
+ */
97
+ getAttachGCData(telemetryContext) {
98
+ (0, core_utils_1.assert)(this._channel !== undefined, 0x8fd /* Local Channel should be loaded before being attached */);
99
+ // We need the GC Data to detect references added in this attach op
100
+ return this._channel.getGCData(/* fullGC: */ true);
85
101
  }
86
102
  makeVisible() {
87
103
  if (this.globallyVisible) {
@@ -123,11 +139,11 @@ class RehydratedLocalChannelContext extends LocalChannelContextBase {
123
139
  if (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {
124
140
  this.sanitizeSnapshot(clonedSnapshotTree);
125
141
  }
126
- return (0, channelContext_1.createChannelServiceEndpoints)(dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, storageService, logger, clonedSnapshotTree, blobMap);
142
+ return (0, channelContext_js_1.createChannelServiceEndpoints)(dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, () => this.isGloballyVisible, storageService, logger, clonedSnapshotTree, blobMap);
127
143
  }), new core_utils_1.LazyPromise(async () => {
128
144
  try {
129
- const { attributes, factory } = await (0, channelContext_1.loadChannelFactoryAndAttributes)(dataStoreContext, this.services.value, this.id, registry);
130
- const channel = await (0, channelContext_1.loadChannel)(runtime, attributes, factory, this.services.value, logger, this.id);
145
+ const { attributes, factory } = await (0, channelContext_js_1.loadChannelFactoryAndAttributes)(dataStoreContext, this.services.value, this.id, registry);
146
+ const channel = await (0, channelContext_js_1.loadChannel)(runtime, attributes, factory, this.services.value, logger, this.id);
131
147
  // Send all pending messages to the channel
132
148
  for (const message of this.pending) {
133
149
  this.services.value.deltaConnection.process(message, false, undefined /* localOpMetadata */);
@@ -143,6 +159,9 @@ class RehydratedLocalChannelContext extends LocalChannelContextBase {
143
159
  dirtyFn(id);
144
160
  };
145
161
  }
162
+ applyStashedOp(content) {
163
+ return this.services.value.deltaConnection.applyStashedOp(content);
164
+ }
146
165
  isSnapshotInOldFormatAndCollectBlobs(snapshotTree, blobMap) {
147
166
  let sanitize = false;
148
167
  const blobsContents = snapshotTree.blobsContents;
@@ -177,7 +196,7 @@ exports.RehydratedLocalChannelContext = RehydratedLocalChannelContext;
177
196
  class LocalChannelContext extends LocalChannelContextBase {
178
197
  constructor(channel, runtime, dataStoreContext, storageService, logger, submitFn, dirtyFn, addedGCOutboundReferenceFn) {
179
198
  super(channel.id, runtime, new core_utils_1.Lazy(() => {
180
- return (0, channelContext_1.createChannelServiceEndpoints)(dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, storageService, logger);
199
+ return (0, channelContext_js_1.createChannelServiceEndpoints)(dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, () => this.isGloballyVisible, storageService, logger);
181
200
  }), Promise.resolve(channel), channel);
182
201
  this.channel = channel;
183
202
  this.channel = channel;
@@ -185,6 +204,9 @@ class LocalChannelContext extends LocalChannelContextBase {
185
204
  dirtyFn(channel.id);
186
205
  };
187
206
  }
207
+ applyStashedOp() {
208
+ throw new Error("no stashed ops on local channel");
209
+ }
188
210
  }
189
211
  exports.LocalChannelContext = LocalChannelContext;
190
212
  //# sourceMappingURL=localChannelContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"localChannelContext.js","sourceRoot":"","sources":["../src/localChannelContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oDAA+B;AAC/B,6DAA6D;AAC7D,MAAM,EAAE,SAAS,EAAE,GAAG,gBAAS,CAAC;A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,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YACtD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;SAC7B;IACF,CAAC;CACD;AA9GD,sEA8GC;AAED,MAAa,mBAAoB,SAAQ,uBAAuB;IAE/D,YACiB,OAAiB,EACjC,OAA+B,EAC/B,gBAAwC,EACxC,cAAuC,EACvC,MAA2B,EAC3B,QAA0D,EAC1D,OAAkC,EAClC,0BAA2F;QAE3F,KAAK,CACJ,OAAO,CAAC,EAAE,EACV,OAAO,EACP,IAAI,iBAAI,CAAC,GAAG,EAAE;YACb,OAAO,IAAA,8CAA6B,EACnC,gBAAgB,CAAC,SAAS,EAC1B,QAAQ,EACR,IAAI,CAAC,OAAO,EACZ,0BAA0B,EAC1B,cAAc,EACd,MAAM,CACN,CAAC;QACH,CAAC,CAAC,EACF,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EACxB,OAAO,CACP,CAAC;QAxBc,YAAO,GAAP,OAAO,CAAU;QAyBjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE;YACnB,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC,CAAC;IACH,CAAC;CACD;AAlCD,kDAkCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport lodashPkg from \"lodash\";\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst { cloneDeep } = lodashPkg;\n\nimport { DataProcessingError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { IChannel, IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { assert, Lazy, LazyPromise } from \"@fluidframework/core-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions\";\nimport {\n\tChannelServiceEndpoints,\n\tcreateChannelServiceEndpoints,\n\tIChannelContext,\n\tloadChannel,\n\tloadChannelFactoryAndAttributes,\n\tsummarizeChannel,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\n/**\n * Channel context for a locally created channel\n */\nexport abstract class LocalChannelContextBase implements IChannelContext {\n\tprivate globallyVisible = false;\n\tprotected readonly pending: ISequencedDocumentMessage[] = [];\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly runtime: IFluidDataStoreRuntime,\n\t\tprotected readonly services: Lazy<ChannelServiceEndpoints>,\n\t\tprivate readonly channelP: Promise<IChannel>,\n\t\tprivate _channel?: IChannel,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x30f /* Channel context ID cannot contain slashes */);\n\t}\n\n\tpublic async getChannel(): Promise<IChannel> {\n\t\tif (this._channel === undefined) {\n\t\t\treturn this.channelP.then((c) => (this._channel = c));\n\t\t}\n\t\treturn this.channelP;\n\t}\n\n\tpublic get isLoaded(): boolean {\n\t\treturn this._channel !== undefined;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet globallyVisible or loaded\n\t\tif (this.globallyVisible && this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.setConnectionState(connected);\n\t\t}\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d3 /* \"Local channel must be globally visible when processing op\" */,\n\t\t);\n\n\t\t// A local channel may not be loaded in case where we rehydrate the container from a snapshot because of\n\t\t// delay loading. So after the container is attached and some other client joins which start generating\n\t\t// ops for this channel. So not loaded local channel can still receive ops and we store them to process later.\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tlocal === false,\n\t\t\t\t0x189 /* \"Should always be remote because a local dds shouldn't generate ops before loading\" */,\n\t\t\t);\n\t\t\tthis.pending.push(message);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x18a /* \"Channel should be loaded to resubmit ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d4 /* \"Local channel must be globally visible when resubmitting op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2ee /* \"Channel should be loaded to rollback ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2ef /* \"Local channel must be globally visible when rolling back op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\tpublic applyStashedOp() {\n\t\tthrow new Error(\"no stashed ops on local channel\");\n\t}\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\tconst channel = await this.getChannel();\n\t\treturn summarizeChannelAsync(channel, fullTree, trackState, telemetryContext);\n\t}\n\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummarizeResult {\n\t\tassert(\n\t\t\tthis._channel !== undefined,\n\t\t\t0x18d /* \"Channel should be loaded to take snapshot\" */,\n\t\t);\n\t\treturn summarizeChannel(\n\t\t\tthis._channel,\n\t\t\ttrue /* fullTree */,\n\t\t\tfalse /* trackState */,\n\t\t\ttelemetryContext,\n\t\t);\n\t}\n\n\tpublic makeVisible(): void {\n\t\tif (this.globallyVisible) {\n\t\t\tthrow new Error(\"Channel is already globally visible\");\n\t\t}\n\n\t\tif (this.isLoaded) {\n\t\t\tassert(!!this._channel, 0x192 /* \"Channel should be there if loaded!!\" */);\n\t\t\tthis._channel.connect(this.services.value);\n\t\t}\n\t\tthis.globallyVisible = true;\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document. This should be called only after\n\t * the context has loaded.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tconst channel = await this.getChannel();\n\t\treturn channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected.\n\t\t * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed\n\t\t * value. See - https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t}\n}\n\nexport class RehydratedLocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tconstructor(\n\t\tid: string,\n\t\tregistry: ISharedObjectRegistry,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly snapshotTree: ISnapshotTree,\n\t) {\n\t\tsuper(\n\t\t\tid,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\tconst blobMap: Map<string, ArrayBufferLike> = new Map<string, ArrayBufferLike>();\n\t\t\t\tconst clonedSnapshotTree = cloneDeep(this.snapshotTree);\n\t\t\t\t// 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.\n\t\t\t\t// This is for older snapshot which is generated by loader <=0.47 version which still contains\n\t\t\t\t// the contents within blobs. After a couple of revisions we can remove it.\n\t\t\t\tif (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {\n\t\t\t\t\tthis.sanitizeSnapshot(clonedSnapshotTree);\n\t\t\t\t}\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t\tclonedSnapshotTree,\n\t\t\t\t\tblobMap,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tnew LazyPromise<IChannel>(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { attributes, factory } = await loadChannelFactoryAndAttributes(\n\t\t\t\t\t\tdataStoreContext,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t);\n\t\t\t\t\tconst channel = await loadChannel(\n\t\t\t\t\t\truntime,\n\t\t\t\t\t\tattributes,\n\t\t\t\t\t\tfactory,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t);\n\t\t\t\t\t// Send all pending messages to the channel\n\t\t\t\t\tfor (const message of this.pending) {\n\t\t\t\t\t\tthis.services.value.deltaConnection.process(\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tundefined /* localOpMetadata */,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn channel;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tthrow DataProcessingError.wrapIfUnrecognized(\n\t\t\t\t\t\terr,\n\t\t\t\t\t\t\"rehydratedLocalChannelContextFailedToLoadChannel\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(id);\n\t\t};\n\t}\n\n\tprivate isSnapshotInOldFormatAndCollectBlobs(\n\t\tsnapshotTree: ISnapshotTreeWithBlobContents,\n\t\tblobMap: Map<string, ArrayBufferLike>,\n\t): boolean {\n\t\tlet sanitize = false;\n\t\tconst blobsContents = snapshotTree.blobsContents;\n\t\tif (blobsContents !== undefined) {\n\t\t\tObject.entries(blobsContents).forEach(([key, value]) => {\n\t\t\t\tblobMap.set(key, value);\n\t\t\t\tif (snapshotTree.blobs[key] !== undefined) {\n\t\t\t\t\tsanitize = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tsanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);\n\t\t}\n\t\treturn sanitize;\n\t}\n\n\tprivate sanitizeSnapshot(snapshotTree: ISnapshotTree) {\n\t\tconst blobMapInitial = new Map(Object.entries(snapshotTree.blobs));\n\t\tfor (const [blobName, blobId] of blobMapInitial.entries()) {\n\t\t\tconst blobValue = blobMapInitial.get(blobId);\n\t\t\tif (blobValue === undefined) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete snapshotTree.blobs[blobName];\n\t\t\t}\n\t\t}\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tthis.sanitizeSnapshot(value);\n\t\t}\n\t}\n}\n\nexport class LocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tconstructor(\n\t\tpublic readonly channel: IChannel,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t) {\n\t\tsuper(\n\t\t\tchannel.id,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tPromise.resolve(channel),\n\t\t\tchannel,\n\t\t);\n\t\tthis.channel = channel;\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(channel.id);\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"localChannelContext.js","sourceRoot":"","sources":["../src/localChannelContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oDAA+B;AAC/B,6DAA6D;AAC7D,MAAM,EAAE,SAAS,EAAE,GAAG,gBAAS,CAAC;AAEhC,qEAA2F;AAU3F,2DAAuE;AAGvE,2DAQ6B;AAG7B;;GAEG;AACH,MAAsB,uBAAuB;IAG5C,YACoB,EAAU,EACV,OAA+B,EAC/B,QAAuC,EACzC,QAA2B,EACpC,QAAmB;QAJR,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAwB;QAC/B,aAAQ,GAAR,QAAQ,CAA+B;QACzC,aAAQ,GAAR,QAAQ,CAAmB;QACpC,aAAQ,GAAR,QAAQ,CAAW;QAPpB,oBAAe,GAAG,KAAK,CAAC;QACb,YAAO,GAAgC,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,KAAK,CAAC,QAAQ,CAAC,CAAC;aACpC;SACD;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YACtD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;SAC7B;IACF,CAAC;CACD;AAnHD,sEAmHC;AAED,MAAa,mBAAoB,SAAQ,uBAAuB;IAE/D,YACiB,OAAiB,EACjC,OAA+B,EAC/B,gBAAwC,EACxC,cAAuC,EACvC,MAA2B,EAC3B,QAA0D,EAC1D,OAAkC,EAClC,0BAA2F;QAE3F,KAAK,CACJ,OAAO,CAAC,EAAE,EACV,OAAO,EACP,IAAI,iBAAI,CAAC,GAAG,EAAE;YACb,OAAO,IAAA,iDAA6B,EACnC,gBAAgB,CAAC,SAAS,EAC1B,QAAQ,EACR,IAAI,CAAC,OAAO,EACZ,0BAA0B,EAC1B,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAC5B,cAAc,EACd,MAAM,CACN,CAAC;QACH,CAAC,CAAC,EACF,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EACxB,OAAO,CACP,CAAC;QAzBc,YAAO,GAAP,OAAO,CAAU;QA0BjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE;YACnB,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC,CAAC;IACH,CAAC;IAEM,cAAc;QACpB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACpD,CAAC;CACD;AAvCD,kDAuCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport lodashPkg from \"lodash\";\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst { cloneDeep } = lodashPkg;\n\nimport { DataProcessingError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { IChannel, IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { assert, Lazy, LazyPromise } from \"@fluidframework/core-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions\";\nimport {\n\tChannelServiceEndpoints,\n\tcreateChannelServiceEndpoints,\n\tIChannelContext,\n\tloadChannel,\n\tloadChannelFactoryAndAttributes,\n\tsummarizeChannel,\n\tsummarizeChannelAsync,\n} from \"./channelContext.js\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime.js\";\n\n/**\n * Channel context for a locally created channel\n */\nexport abstract class LocalChannelContextBase implements IChannelContext {\n\tprivate globallyVisible = false;\n\tprotected readonly pending: ISequencedDocumentMessage[] = [];\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly runtime: IFluidDataStoreRuntime,\n\t\tprotected readonly services: Lazy<ChannelServiceEndpoints>,\n\t\tprivate readonly channelP: Promise<IChannel>,\n\t\tprivate _channel?: IChannel,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x30f /* Channel context ID cannot contain slashes */);\n\t}\n\n\tprotected get isGloballyVisible() {\n\t\treturn this.globallyVisible;\n\t}\n\n\tpublic async getChannel(): Promise<IChannel> {\n\t\tif (this._channel === undefined) {\n\t\t\treturn this.channelP.then((c) => (this._channel = c));\n\t\t}\n\t\treturn this.channelP;\n\t}\n\n\tpublic get isLoaded(): boolean {\n\t\treturn this._channel !== undefined;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet globallyVisible or loaded\n\t\tif (this.globallyVisible && this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.setConnectionState(connected);\n\t\t}\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d3 /* \"Local channel must be globally visible when processing op\" */,\n\t\t);\n\n\t\t// A local channel may not be loaded in case where we rehydrate the container from a snapshot because of\n\t\t// delay loading. So after the container is attached and some other client joins which start generating\n\t\t// ops for this channel. So not loaded local channel can still receive ops and we store them to process later.\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.value.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(\n\t\t\t\tlocal === false,\n\t\t\t\t0x189 /* \"Should always be remote because a local dds shouldn't generate ops before loading\" */,\n\t\t\t);\n\t\t\tthis.pending.push(message);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x18a /* \"Channel should be loaded to resubmit ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2d4 /* \"Local channel must be globally visible when resubmitting op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2ee /* \"Channel should be loaded to rollback ops\" */);\n\t\tassert(\n\t\t\tthis.globallyVisible,\n\t\t\t0x2ef /* \"Local channel must be globally visible when rolling back op\" */,\n\t\t);\n\t\tthis.services.value.deltaConnection.rollback(content, localOpMetadata);\n\t}\n\n\tpublic abstract applyStashedOp(content: unknown): unknown;\n\n\t/**\n\t * Returns a summary at the current sequence number.\n\t * @param fullTree - true to bypass optimizations and force a full summary tree\n\t * @param trackState - This tells whether we should track state from this summary.\n\t * @param telemetryContext - summary data passed through the layers for telemetry purposes\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\tconst channel = await this.getChannel();\n\t\treturn summarizeChannelAsync(channel, fullTree, trackState, telemetryContext);\n\t}\n\n\t/**\n\t * For crafting the DataStore attach op. Only to be called when the channel is loaded (if applicable).\n\t *\n\t * Synchronously generates the channel's attach summary to be joined with the same from the DataStore's other channels\n\t */\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummarizeResult {\n\t\tassert(\n\t\t\tthis._channel !== undefined,\n\t\t\t0x18d /* \"Channel should be loaded to take snapshot\" */,\n\t\t);\n\t\treturn summarizeChannel(\n\t\t\tthis._channel,\n\t\t\ttrue /* fullTree */,\n\t\t\tfalse /* trackState */,\n\t\t\ttelemetryContext,\n\t\t);\n\t}\n\n\t/**\n\t * For crafting the DataStore attach op. Only to be called when the channel is loaded (if applicable).\n\t *\n\t * Synchronously generates the channel's attach GC data (set of outbound routes in the initial state)\n\t * to be joined with the same from the DataStore's other channels\n\t */\n\tpublic getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData {\n\t\tassert(\n\t\t\tthis._channel !== undefined,\n\t\t\t0x8fd /* Local Channel should be loaded before being attached */,\n\t\t);\n\n\t\t// We need the GC Data to detect references added in this attach op\n\t\treturn this._channel.getGCData(/* fullGC: */ true);\n\t}\n\n\tpublic makeVisible(): void {\n\t\tif (this.globallyVisible) {\n\t\t\tthrow new Error(\"Channel is already globally visible\");\n\t\t}\n\n\t\tif (this.isLoaded) {\n\t\t\tassert(!!this._channel, 0x192 /* \"Channel should be there if loaded!!\" */);\n\t\t\tthis._channel.connect(this.services.value);\n\t\t}\n\t\tthis.globallyVisible = true;\n\t}\n\n\t/**\n\t * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n\t * Each node has a set of outbound routes to other GC nodes in the document. This should be called only after\n\t * the context has loaded.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tpublic async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n\t\tconst channel = await this.getChannel();\n\t\treturn channel.getGCData(fullGC);\n\t}\n\n\tpublic updateUsedRoutes(usedRoutes: string[]) {\n\t\t/**\n\t\t * Currently, DDSes are always considered referenced and are not garbage collected.\n\t\t * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed\n\t\t * value. See - https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t}\n}\n\nexport class RehydratedLocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tconstructor(\n\t\tid: string,\n\t\tregistry: ISharedObjectRegistry,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t\tprivate readonly snapshotTree: ISnapshotTree,\n\t) {\n\t\tsuper(\n\t\t\tid,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\tconst blobMap: Map<string, ArrayBufferLike> = new Map<string, ArrayBufferLike>();\n\t\t\t\tconst clonedSnapshotTree = cloneDeep(this.snapshotTree);\n\t\t\t\t// 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.\n\t\t\t\t// This is for older snapshot which is generated by loader <=0.47 version which still contains\n\t\t\t\t// the contents within blobs. After a couple of revisions we can remove it.\n\t\t\t\tif (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {\n\t\t\t\t\tthis.sanitizeSnapshot(clonedSnapshotTree);\n\t\t\t\t}\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\t() => this.isGloballyVisible,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t\tclonedSnapshotTree,\n\t\t\t\t\tblobMap,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tnew LazyPromise<IChannel>(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { attributes, factory } = await loadChannelFactoryAndAttributes(\n\t\t\t\t\t\tdataStoreContext,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t\tregistry,\n\t\t\t\t\t);\n\t\t\t\t\tconst channel = await loadChannel(\n\t\t\t\t\t\truntime,\n\t\t\t\t\t\tattributes,\n\t\t\t\t\t\tfactory,\n\t\t\t\t\t\tthis.services.value,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\tthis.id,\n\t\t\t\t\t);\n\t\t\t\t\t// Send all pending messages to the channel\n\t\t\t\t\tfor (const message of this.pending) {\n\t\t\t\t\t\tthis.services.value.deltaConnection.process(\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tundefined /* localOpMetadata */,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn channel;\n\t\t\t\t} catch (err) {\n\t\t\t\t\tthrow DataProcessingError.wrapIfUnrecognized(\n\t\t\t\t\t\terr,\n\t\t\t\t\t\t\"rehydratedLocalChannelContextFailedToLoadChannel\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(id);\n\t\t};\n\t}\n\n\tpublic override applyStashedOp(content) {\n\t\treturn this.services.value.deltaConnection.applyStashedOp(content);\n\t}\n\n\tprivate isSnapshotInOldFormatAndCollectBlobs(\n\t\tsnapshotTree: ISnapshotTreeWithBlobContents,\n\t\tblobMap: Map<string, ArrayBufferLike>,\n\t): boolean {\n\t\tlet sanitize = false;\n\t\tconst blobsContents = snapshotTree.blobsContents;\n\t\tif (blobsContents !== undefined) {\n\t\t\tObject.entries(blobsContents).forEach(([key, value]) => {\n\t\t\t\tblobMap.set(key, value);\n\t\t\t\tif (snapshotTree.blobs[key] !== undefined) {\n\t\t\t\t\tsanitize = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tsanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);\n\t\t}\n\t\treturn sanitize;\n\t}\n\n\tprivate sanitizeSnapshot(snapshotTree: ISnapshotTree) {\n\t\tconst blobMapInitial = new Map(Object.entries(snapshotTree.blobs));\n\t\tfor (const [blobName, blobId] of blobMapInitial.entries()) {\n\t\t\tconst blobValue = blobMapInitial.get(blobId);\n\t\t\tif (blobValue === undefined) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\t\t\tdelete snapshotTree.blobs[blobName];\n\t\t\t}\n\t\t}\n\t\tfor (const value of Object.values(snapshotTree.trees)) {\n\t\t\tthis.sanitizeSnapshot(value);\n\t\t}\n\t}\n}\n\nexport class LocalChannelContext extends LocalChannelContextBase {\n\tprivate readonly dirtyFn: () => void;\n\tconstructor(\n\t\tpublic readonly channel: IChannel,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tsubmitFn: (content: any, localOpMetadata: unknown) => void,\n\t\tdirtyFn: (address: string) => void,\n\t\taddedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n\t) {\n\t\tsuper(\n\t\t\tchannel.id,\n\t\t\truntime,\n\t\t\tnew Lazy(() => {\n\t\t\t\treturn createChannelServiceEndpoints(\n\t\t\t\t\tdataStoreContext.connected,\n\t\t\t\t\tsubmitFn,\n\t\t\t\t\tthis.dirtyFn,\n\t\t\t\t\taddedGCOutboundReferenceFn,\n\t\t\t\t\t() => this.isGloballyVisible,\n\t\t\t\t\tstorageService,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\t\t\t}),\n\t\t\tPromise.resolve(channel),\n\t\t\tchannel,\n\t\t);\n\t\tthis.channel = channel;\n\n\t\tthis.dirtyFn = () => {\n\t\t\tdirtyFn(channel.id);\n\t\t};\n\t}\n\n\tpublic applyStashedOp() {\n\t\tthrow new Error(\"no stashed ops on local channel\");\n\t}\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -7,8 +7,8 @@ import { IChannel, IFluidDataStoreRuntime } from "@fluidframework/datastore-defi
7
7
  import { IDocumentStorageService } from "@fluidframework/driver-definitions";
8
8
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
9
9
  import { CreateChildSummarizerNodeFn, IFluidDataStoreContext, IGarbageCollectionData, ISummarizeResult, ITelemetryContext } from "@fluidframework/runtime-definitions";
10
- import { IChannelContext } from "./channelContext";
11
- import { ISharedObjectRegistry } from "./dataStoreRuntime";
10
+ import { IChannelContext } from "./channelContext.js";
11
+ import { ISharedObjectRegistry } from "./dataStoreRuntime.js";
12
12
  export declare class RemoteChannelContext implements IChannelContext {
13
13
  private readonly id;
14
14
  private isLoaded;
@@ -1 +1 @@
1
- {"version":3,"file":"remoteChannelContext.d.ts","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,EACN,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EAGtB,gBAAgB,EAEh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OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAMtD;;;;;OAKG;IACU,SAAS,CACrB,QAAQ,GAAE,OAAe,EACzB,UAAU,GAAE,OAAc,EAC1B,gBAAgB,CAAC,EAAE,iBAAiB,GAClC,OAAO,CAAC,gBAAgB,CAAC;YAId,iBAAiB;IAiB/B;;;;;;OAMG;IACU,SAAS,CAAC,MAAM,GAAE,OAAe,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAIhF;;;;OAIG;YACW,iBAAiB;IAKxB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE;CAS5C"}
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.RemoteChannelContext = void 0;
8
8
  const core_utils_1 = require("@fluidframework/core-utils");
9
9
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
10
- const channelContext_1 = require("./channelContext");
10
+ const container_definitions_1 = require("@fluidframework/container-definitions");
11
+ const channelContext_js_1 = require("./channelContext.js");
11
12
  class RemoteChannelContext {
12
13
  constructor(runtime, dataStoreContext, storageService, submitFn, dirtyFn, addedGCOutboundReferenceFn, id, baseSnapshot, registry, extraBlobs, createSummarizerNode, attachMessageType) {
13
14
  this.id = id;
@@ -18,10 +19,10 @@ class RemoteChannelContext {
18
19
  logger: runtime.logger,
19
20
  namespace: "RemoteChannelContext",
20
21
  });
21
- this.services = (0, channelContext_1.createChannelServiceEndpoints)(dataStoreContext.connected, submitFn, () => dirtyFn(this.id), addedGCOutboundReferenceFn, storageService, this.subLogger, baseSnapshot, extraBlobs);
22
+ this.services = (0, channelContext_js_1.createChannelServiceEndpoints)(dataStoreContext.connected, submitFn, () => dirtyFn(this.id), addedGCOutboundReferenceFn, () => runtime.attachState !== container_definitions_1.AttachState.Detached, storageService, this.subLogger, baseSnapshot, extraBlobs);
22
23
  this.channelP = new core_utils_1.LazyPromise(async () => {
23
- const { attributes, factory } = await (0, channelContext_1.loadChannelFactoryAndAttributes)(dataStoreContext, this.services, this.id, registry, attachMessageType);
24
- const channel = await (0, channelContext_1.loadChannel)(runtime, attributes, factory, this.services, this.subLogger, this.id);
24
+ const { attributes, factory } = await (0, channelContext_js_1.loadChannelFactoryAndAttributes)(dataStoreContext, this.services, this.id, registry, attachMessageType);
25
+ const channel = await (0, channelContext_js_1.loadChannel)(runtime, attributes, factory, this.services, this.subLogger, this.id);
25
26
  // Send all pending messages to the channel
26
27
  (0, core_utils_1.assert)(this.pending !== undefined, 0x23f /* "pending undefined" */);
27
28
  for (const message of this.pending) {
@@ -87,7 +88,7 @@ class RemoteChannelContext {
87
88
  }
88
89
  async summarizeInternal(fullTree, trackState, telemetryContext, incrementalSummaryContext) {
89
90
  const channel = await this.getChannel();
90
- const summarizeResult = await (0, channelContext_1.summarizeChannelAsync)(channel, fullTree, trackState, telemetryContext, incrementalSummaryContext);
91
+ const summarizeResult = await (0, channelContext_js_1.summarizeChannelAsync)(channel, fullTree, trackState, telemetryContext, incrementalSummaryContext);
91
92
  return { ...summarizeResult, id: this.id };
92
93
  }
93
94
  /**