@fluidframework/datastore 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277

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 (146) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +273 -0
  4. package/README.md +41 -0
  5. package/api-extractor-esm.json +4 -0
  6. package/api-extractor-lint.json +4 -0
  7. package/api-extractor.json +2 -2
  8. package/api-report/datastore.api.md +168 -0
  9. package/dist/channelContext.cjs +86 -0
  10. package/dist/channelContext.cjs.map +1 -0
  11. package/dist/channelContext.d.ts +15 -9
  12. package/dist/channelContext.d.ts.map +1 -1
  13. package/dist/{channelDeltaConnection.js → channelDeltaConnection.cjs} +14 -15
  14. package/dist/channelDeltaConnection.cjs.map +1 -0
  15. package/dist/channelDeltaConnection.d.ts +4 -5
  16. package/dist/channelDeltaConnection.d.ts.map +1 -1
  17. package/dist/{channelStorageService.js → channelStorageService.cjs} +13 -16
  18. package/dist/channelStorageService.cjs.map +1 -0
  19. package/dist/channelStorageService.d.ts +2 -2
  20. package/dist/channelStorageService.d.ts.map +1 -1
  21. package/dist/{dataStoreRuntime.js → dataStoreRuntime.cjs} +302 -225
  22. package/dist/dataStoreRuntime.cjs.map +1 -0
  23. package/dist/dataStoreRuntime.d.ts +81 -37
  24. package/dist/dataStoreRuntime.d.ts.map +1 -1
  25. package/dist/datastore-alpha.d.ts +317 -0
  26. package/dist/datastore-beta.d.ts +47 -0
  27. package/dist/datastore-public.d.ts +47 -0
  28. package/dist/datastore-untrimmed.d.ts +324 -0
  29. package/dist/{fluidHandle.js → fluidHandle.cjs} +44 -16
  30. package/dist/fluidHandle.cjs.map +1 -0
  31. package/dist/fluidHandle.d.ts +33 -6
  32. package/dist/fluidHandle.d.ts.map +1 -1
  33. package/dist/index.cjs +15 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/localChannelContext.cjs +190 -0
  38. package/dist/localChannelContext.cjs.map +1 -0
  39. package/dist/localChannelContext.d.ts +12 -21
  40. package/dist/localChannelContext.d.ts.map +1 -1
  41. package/dist/{localChannelStorageService.js → localChannelStorageService.cjs} +3 -3
  42. package/dist/localChannelStorageService.cjs.map +1 -0
  43. package/dist/localChannelStorageService.d.ts.map +1 -1
  44. package/dist/remoteChannelContext.cjs +124 -0
  45. package/dist/remoteChannelContext.cjs.map +1 -0
  46. package/dist/remoteChannelContext.d.ts +5 -10
  47. package/dist/remoteChannelContext.d.ts.map +1 -1
  48. package/dist/tsdoc-metadata.json +11 -0
  49. package/lib/{channelContext.d.ts → channelContext.d.mts} +17 -11
  50. package/lib/channelContext.d.mts.map +1 -0
  51. package/lib/channelContext.mjs +78 -0
  52. package/lib/channelContext.mjs.map +1 -0
  53. package/lib/{channelDeltaConnection.d.ts → channelDeltaConnection.d.mts} +5 -6
  54. package/lib/channelDeltaConnection.d.mts.map +1 -0
  55. package/lib/{channelDeltaConnection.js → channelDeltaConnection.mjs} +11 -12
  56. package/lib/channelDeltaConnection.mjs.map +1 -0
  57. package/lib/{channelStorageService.d.ts → channelStorageService.d.mts} +3 -3
  58. package/lib/channelStorageService.d.mts.map +1 -0
  59. package/lib/{channelStorageService.js → channelStorageService.mjs} +13 -16
  60. package/lib/channelStorageService.mjs.map +1 -0
  61. package/lib/{dataStoreRuntime.d.ts → dataStoreRuntime.d.mts} +82 -38
  62. package/lib/dataStoreRuntime.d.mts.map +1 -0
  63. package/lib/{dataStoreRuntime.js → dataStoreRuntime.mjs} +286 -209
  64. package/lib/dataStoreRuntime.mjs.map +1 -0
  65. package/lib/datastore-alpha.d.mts +317 -0
  66. package/lib/datastore-beta.d.mts +47 -0
  67. package/lib/datastore-public.d.mts +47 -0
  68. package/lib/datastore-untrimmed.d.mts +324 -0
  69. package/lib/fluidHandle.d.mts +57 -0
  70. package/lib/fluidHandle.d.mts.map +1 -0
  71. package/lib/{fluidHandle.js → fluidHandle.mjs} +44 -16
  72. package/lib/fluidHandle.mjs.map +1 -0
  73. package/lib/index.d.mts +7 -0
  74. package/lib/index.d.mts.map +1 -0
  75. package/lib/index.mjs +7 -0
  76. package/lib/index.mjs.map +1 -0
  77. package/lib/{localChannelContext.d.ts → localChannelContext.d.mts} +14 -23
  78. package/lib/localChannelContext.d.mts.map +1 -0
  79. package/lib/{localChannelContext.js → localChannelContext.mjs} +73 -85
  80. package/lib/localChannelContext.mjs.map +1 -0
  81. package/lib/{localChannelStorageService.d.ts → localChannelStorageService.d.mts} +1 -1
  82. package/lib/localChannelStorageService.d.mts.map +1 -0
  83. package/lib/{localChannelStorageService.js → localChannelStorageService.mjs} +2 -2
  84. package/lib/localChannelStorageService.mjs.map +1 -0
  85. package/lib/{remoteChannelContext.d.ts → remoteChannelContext.d.mts} +8 -13
  86. package/lib/remoteChannelContext.d.mts.map +1 -0
  87. package/lib/remoteChannelContext.mjs +120 -0
  88. package/lib/remoteChannelContext.mjs.map +1 -0
  89. package/package.json +139 -71
  90. package/{lib/index.js → prettier.config.cjs} +4 -3
  91. package/src/channelContext.ts +168 -71
  92. package/src/channelDeltaConnection.ts +52 -47
  93. package/src/channelStorageService.ts +59 -55
  94. package/src/dataStoreRuntime.ts +1158 -983
  95. package/src/fluidHandle.ts +92 -64
  96. package/src/index.ts +8 -2
  97. package/src/localChannelContext.ts +278 -272
  98. package/src/localChannelStorageService.ts +48 -46
  99. package/src/remoteChannelContext.ts +237 -300
  100. package/tsc-multi.test.json +4 -0
  101. package/tsconfig.json +11 -13
  102. package/dist/channelContext.js +0 -35
  103. package/dist/channelContext.js.map +0 -1
  104. package/dist/channelDeltaConnection.js.map +0 -1
  105. package/dist/channelStorageService.js.map +0 -1
  106. package/dist/dataStoreRuntime.js.map +0 -1
  107. package/dist/fluidHandle.js.map +0 -1
  108. package/dist/index.js +0 -19
  109. package/dist/index.js.map +0 -1
  110. package/dist/localChannelContext.js +0 -202
  111. package/dist/localChannelContext.js.map +0 -1
  112. package/dist/localChannelStorageService.js.map +0 -1
  113. package/dist/packageVersion.d.ts +0 -9
  114. package/dist/packageVersion.d.ts.map +0 -1
  115. package/dist/packageVersion.js +0 -12
  116. package/dist/packageVersion.js.map +0 -1
  117. package/dist/remoteChannelContext.js +0 -207
  118. package/dist/remoteChannelContext.js.map +0 -1
  119. package/lib/channelContext.d.ts.map +0 -1
  120. package/lib/channelContext.js +0 -29
  121. package/lib/channelContext.js.map +0 -1
  122. package/lib/channelDeltaConnection.d.ts.map +0 -1
  123. package/lib/channelDeltaConnection.js.map +0 -1
  124. package/lib/channelStorageService.d.ts.map +0 -1
  125. package/lib/channelStorageService.js.map +0 -1
  126. package/lib/dataStoreRuntime.d.ts.map +0 -1
  127. package/lib/dataStoreRuntime.js.map +0 -1
  128. package/lib/fluidHandle.d.ts +0 -30
  129. package/lib/fluidHandle.d.ts.map +0 -1
  130. package/lib/fluidHandle.js.map +0 -1
  131. package/lib/index.d.ts +0 -7
  132. package/lib/index.d.ts.map +0 -1
  133. package/lib/index.js.map +0 -1
  134. package/lib/localChannelContext.d.ts.map +0 -1
  135. package/lib/localChannelContext.js.map +0 -1
  136. package/lib/localChannelStorageService.d.ts.map +0 -1
  137. package/lib/localChannelStorageService.js.map +0 -1
  138. package/lib/packageVersion.d.ts +0 -9
  139. package/lib/packageVersion.d.ts.map +0 -1
  140. package/lib/packageVersion.js +0 -9
  141. package/lib/packageVersion.js.map +0 -1
  142. package/lib/remoteChannelContext.d.ts.map +0 -1
  143. package/lib/remoteChannelContext.js +0 -203
  144. package/lib/remoteChannelContext.js.map +0 -1
  145. package/src/packageVersion.ts +0 -9
  146. package/tsconfig.esnext.json +0 -7
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.LocalChannelContext = exports.RehydratedLocalChannelContext = exports.LocalChannelContextBase = void 0;
11
+ const lodash_1 = __importDefault(require("lodash"));
12
+ // eslint-disable-next-line @typescript-eslint/unbound-method
13
+ const { cloneDeep } = lodash_1.default;
14
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
15
+ const core_utils_1 = require("@fluidframework/core-utils");
16
+ const channelContext_1 = require("./channelContext.cjs");
17
+ /**
18
+ * Channel context for a locally created channel
19
+ */
20
+ class LocalChannelContextBase {
21
+ constructor(id, runtime, services, channelP, _channel) {
22
+ this.id = id;
23
+ this.runtime = runtime;
24
+ this.services = services;
25
+ this.channelP = channelP;
26
+ this._channel = _channel;
27
+ this.globallyVisible = false;
28
+ this.pending = [];
29
+ (0, core_utils_1.assert)(!this.id.includes("/"), 0x30f /* Channel context ID cannot contain slashes */);
30
+ }
31
+ async getChannel() {
32
+ if (this._channel === undefined) {
33
+ return this.channelP.then((c) => (this._channel = c));
34
+ }
35
+ return this.channelP;
36
+ }
37
+ get isLoaded() {
38
+ return this._channel !== undefined;
39
+ }
40
+ setConnectionState(connected, clientId) {
41
+ // Connection events are ignored if the data store is not yet globallyVisible or loaded
42
+ if (this.globallyVisible && this.isLoaded) {
43
+ this.services.value.deltaConnection.setConnectionState(connected);
44
+ }
45
+ }
46
+ processOp(message, local, localOpMetadata) {
47
+ (0, core_utils_1.assert)(this.globallyVisible, 0x2d3 /* "Local channel must be globally visible when processing op" */);
48
+ // A local channel may not be loaded in case where we rehydrate the container from a snapshot because of
49
+ // delay loading. So after the container is attached and some other client joins which start generating
50
+ // ops for this channel. So not loaded local channel can still receive ops and we store them to process later.
51
+ if (this.isLoaded) {
52
+ this.services.value.deltaConnection.process(message, local, localOpMetadata);
53
+ }
54
+ else {
55
+ (0, core_utils_1.assert)(local === false, 0x189 /* "Should always be remote because a local dds shouldn't generate ops before loading" */);
56
+ this.pending.push(message);
57
+ }
58
+ }
59
+ reSubmit(content, localOpMetadata) {
60
+ (0, core_utils_1.assert)(this.isLoaded, 0x18a /* "Channel should be loaded to resubmit ops" */);
61
+ (0, core_utils_1.assert)(this.globallyVisible, 0x2d4 /* "Local channel must be globally visible when resubmitting op" */);
62
+ this.services.value.deltaConnection.reSubmit(content, localOpMetadata);
63
+ }
64
+ rollback(content, localOpMetadata) {
65
+ (0, core_utils_1.assert)(this.isLoaded, 0x2ee /* "Channel should be loaded to rollback ops" */);
66
+ (0, core_utils_1.assert)(this.globallyVisible, 0x2ef /* "Local channel must be globally visible when rolling back op" */);
67
+ this.services.value.deltaConnection.rollback(content, localOpMetadata);
68
+ }
69
+ applyStashedOp() {
70
+ throw new Error("no stashed ops on local channel");
71
+ }
72
+ /**
73
+ * Returns a summary at the current sequence number.
74
+ * @param fullTree - true to bypass optimizations and force a full summary tree
75
+ * @param trackState - This tells whether we should track state from this summary.
76
+ * @param telemetryContext - summary data passed through the layers for telemetry purposes
77
+ */
78
+ async summarize(fullTree = false, trackState = false, telemetryContext) {
79
+ const channel = await this.getChannel();
80
+ return (0, channelContext_1.summarizeChannelAsync)(channel, fullTree, trackState, telemetryContext);
81
+ }
82
+ getAttachSummary(telemetryContext) {
83
+ (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);
85
+ }
86
+ makeVisible() {
87
+ if (this.globallyVisible) {
88
+ throw new Error("Channel is already globally visible");
89
+ }
90
+ if (this.isLoaded) {
91
+ (0, core_utils_1.assert)(!!this._channel, 0x192 /* "Channel should be there if loaded!!" */);
92
+ this._channel.connect(this.services.value);
93
+ }
94
+ this.globallyVisible = true;
95
+ }
96
+ /**
97
+ * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.
98
+ * Each node has a set of outbound routes to other GC nodes in the document. This should be called only after
99
+ * the context has loaded.
100
+ * @param fullGC - true to bypass optimizations and force full generation of GC data.
101
+ */
102
+ async getGCData(fullGC = false) {
103
+ const channel = await this.getChannel();
104
+ return channel.getGCData(fullGC);
105
+ }
106
+ updateUsedRoutes(usedRoutes) {
107
+ /**
108
+ * Currently, DDSes are always considered referenced and are not garbage collected.
109
+ * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed
110
+ * value. See - https://github.com/microsoft/FluidFramework/issues/4611
111
+ */
112
+ }
113
+ }
114
+ exports.LocalChannelContextBase = LocalChannelContextBase;
115
+ class RehydratedLocalChannelContext extends LocalChannelContextBase {
116
+ constructor(id, registry, runtime, dataStoreContext, storageService, logger, submitFn, dirtyFn, addedGCOutboundReferenceFn, snapshotTree) {
117
+ super(id, runtime, new core_utils_1.Lazy(() => {
118
+ const blobMap = new Map();
119
+ const clonedSnapshotTree = cloneDeep(this.snapshotTree);
120
+ // 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.
121
+ // This is for older snapshot which is generated by loader <=0.47 version which still contains
122
+ // the contents within blobs. After a couple of revisions we can remove it.
123
+ if (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {
124
+ this.sanitizeSnapshot(clonedSnapshotTree);
125
+ }
126
+ return (0, channelContext_1.createChannelServiceEndpoints)(dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, storageService, logger, clonedSnapshotTree, blobMap);
127
+ }), new core_utils_1.LazyPromise(async () => {
128
+ 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);
131
+ // Send all pending messages to the channel
132
+ for (const message of this.pending) {
133
+ this.services.value.deltaConnection.process(message, false, undefined /* localOpMetadata */);
134
+ }
135
+ return channel;
136
+ }
137
+ catch (err) {
138
+ throw telemetry_utils_1.DataProcessingError.wrapIfUnrecognized(err, "rehydratedLocalChannelContextFailedToLoadChannel", undefined);
139
+ }
140
+ }));
141
+ this.snapshotTree = snapshotTree;
142
+ this.dirtyFn = () => {
143
+ dirtyFn(id);
144
+ };
145
+ }
146
+ isSnapshotInOldFormatAndCollectBlobs(snapshotTree, blobMap) {
147
+ let sanitize = false;
148
+ const blobsContents = snapshotTree.blobsContents;
149
+ if (blobsContents !== undefined) {
150
+ Object.entries(blobsContents).forEach(([key, value]) => {
151
+ blobMap.set(key, value);
152
+ if (snapshotTree.blobs[key] !== undefined) {
153
+ sanitize = true;
154
+ }
155
+ });
156
+ }
157
+ for (const value of Object.values(snapshotTree.trees)) {
158
+ sanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);
159
+ }
160
+ return sanitize;
161
+ }
162
+ sanitizeSnapshot(snapshotTree) {
163
+ const blobMapInitial = new Map(Object.entries(snapshotTree.blobs));
164
+ for (const [blobName, blobId] of blobMapInitial.entries()) {
165
+ const blobValue = blobMapInitial.get(blobId);
166
+ if (blobValue === undefined) {
167
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
168
+ delete snapshotTree.blobs[blobName];
169
+ }
170
+ }
171
+ for (const value of Object.values(snapshotTree.trees)) {
172
+ this.sanitizeSnapshot(value);
173
+ }
174
+ }
175
+ }
176
+ exports.RehydratedLocalChannelContext = RehydratedLocalChannelContext;
177
+ class LocalChannelContext extends LocalChannelContextBase {
178
+ constructor(channel, runtime, dataStoreContext, storageService, logger, submitFn, dirtyFn, addedGCOutboundReferenceFn) {
179
+ super(channel.id, runtime, new core_utils_1.Lazy(() => {
180
+ return (0, channelContext_1.createChannelServiceEndpoints)(dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, storageService, logger);
181
+ }), Promise.resolve(channel), channel);
182
+ this.channel = channel;
183
+ this.channel = channel;
184
+ this.dirtyFn = () => {
185
+ dirtyFn(channel.id);
186
+ };
187
+ }
188
+ }
189
+ exports.LocalChannelContext = LocalChannelContext;
190
+ //# sourceMappingURL=localChann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E;YAC1D,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC7C,IAAI,SAAS,KAAK,SAAS,EAAE;gBAC5B,gEAAgE;gBAChE,OAAO,YAAY,CAAC,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;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"]}
@@ -2,33 +2,27 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
5
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
6
6
  import { IDocumentStorageService } from "@fluidframework/driver-definitions";
7
7
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
8
- import { IChannel, IFluidDataStoreRuntime, IChannelFactory } from "@fluidframework/datastore-definitions";
8
+ import { IChannel, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
9
9
  import { IFluidDataStoreContext, IGarbageCollectionData, ISummarizeResult, ITelemetryContext } from "@fluidframework/runtime-definitions";
10
- import { Lazy } from "@fluidframework/common-utils";
10
+ import { Lazy } from "@fluidframework/core-utils";
11
11
  import { IFluidHandle } from "@fluidframework/core-interfaces";
12
- import { IChannelContext } from "./channelContext";
13
- import { ChannelDeltaConnection } from "./channelDeltaConnection";
12
+ import { ChannelServiceEndpoints, IChannelContext } from "./channelContext";
14
13
  import { ISharedObjectRegistry } from "./dataStoreRuntime";
15
- import { ChannelStorageService } from "./channelStorageService";
16
14
  /**
17
15
  * Channel context for a locally created channel
18
16
  */
19
17
  export declare abstract class LocalChannelContextBase implements IChannelContext {
20
18
  protected readonly id: string;
21
- protected readonly registry: ISharedObjectRegistry;
22
19
  protected readonly runtime: IFluidDataStoreRuntime;
23
- private readonly servicesGetter;
24
- channel: IChannel | undefined;
20
+ protected readonly services: Lazy<ChannelServiceEndpoints>;
21
+ private readonly channelP;
22
+ private _channel?;
25
23
  private globallyVisible;
26
24
  protected readonly pending: ISequencedDocumentMessage[];
27
- protected factory: IChannelFactory | undefined;
28
- constructor(id: string, registry: ISharedObjectRegistry, runtime: IFluidDataStoreRuntime, servicesGetter: () => Lazy<{
29
- readonly deltaConnection: ChannelDeltaConnection;
30
- readonly objectStorage: ChannelStorageService;
31
- }>);
25
+ constructor(id: string, runtime: IFluidDataStoreRuntime, services: Lazy<ChannelServiceEndpoints>, channelP: Promise<IChannel>, _channel?: IChannel | undefined);
32
26
  getChannel(): Promise<IChannel>;
33
27
  get isLoaded(): boolean;
34
28
  setConnectionState(connected: boolean, clientId?: string): void;
@@ -52,21 +46,18 @@ export declare abstract class LocalChannelContextBase implements IChannelContext
52
46
  * @param fullGC - true to bypass optimizations and force full generation of GC data.
53
47
  */
54
48
  getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
55
- updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): void;
49
+ updateUsedRoutes(usedRoutes: string[]): void;
56
50
  }
57
51
  export declare class RehydratedLocalChannelContext extends LocalChannelContextBase {
58
52
  private readonly snapshotTree;
59
- private readonly services;
60
53
  private readonly dirtyFn;
61
- constructor(id: string, registry: ISharedObjectRegistry, runtime: IFluidDataStoreRuntime, dataStoreContext: IFluidDataStoreContext, storageService: IDocumentStorageService, logger: ITelemetryLogger, submitFn: (content: any, localOpMetadata: unknown) => void, dirtyFn: (address: string) => void, addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void, snapshotTree: ISnapshotTree);
62
- getChannel(): Promise<IChannel>;
63
- private loadChannel;
54
+ 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);
64
55
  private isSnapshotInOldFormatAndCollectBlobs;
65
56
  private sanitizeSnapshot;
66
57
  }
67
58
  export declare class LocalChannelContext extends LocalChannelContextBase {
68
- private readonly services;
59
+ readonly channel: IChannel;
69
60
  private readonly dirtyFn;
70
- constructor(id: string, registry: ISharedObjectRegistry, type: string, runtime: IFluidDataStoreRuntime, dataStoreContext: IFluidDataStoreContext, storageService: IDocumentStorageService, logger: ITelemetryLogger, submitFn: (content: any, localOpMetadata: unknown) => void, dirtyFn: (address: string) => void, addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void);
61
+ 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);
71
62
  }
72
63
  //# sourceMappingURL=localChannelContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localChannelContext.d.ts","sourceRoot":"","sources":["../src/localChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAChG,OAAO,EACH,QAAQ,EACR,sBAAsB,EACtB,eAAe,EAElB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAAU,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAEH,eAAe,EAGlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,8BAAsB,uBAAwB,YAAW,eAAe;IAMhE,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM;IAC7B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB;IAClD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,sBAAsB;IAClD,OAAO,CAAC,QAAQ,CAAC,cAAc;IAR5B,OAAO,EAAE,QAAQ,GAAG,SAAS,CAAC;IACrC,OAAO,CAAC,eAAe,CAAS;IAChC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,yBAAyB,EAAE,CAAM;IAC7D,SAAS,CAAC,OAAO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Q,CAAC,OAAO,CAAa;gBAEpB,OAAO,EAAE,QAAQ,EACjC,OAAO,EAAE,sBAAsB,EAC/B,gBAAgB,EAAE,sBAAsB,EACxC,cAAc,EAAE,uBAAuB,EACvC,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,KAAK,IAAI,EAC1D,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,EAClC,0BAA0B,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,KAAK,IAAI;CAwB5F"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.LocalChannelStorageService = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
8
+ const client_utils_1 = require("@fluid-internal/client-utils");
9
9
  const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
10
10
  const runtime_utils_1 = require("@fluidframework/runtime-utils");
11
11
  class LocalChannelStorageService {
@@ -17,7 +17,7 @@ class LocalChannelStorageService {
17
17
  if (blob === undefined) {
18
18
  throw new Error("Blob Not Found");
19
19
  }
20
- return (0, common_utils_1.stringToBuffer)(blob.contents, blob.encoding);
20
+ return (0, client_utils_1.stringToBuffer)(blob.contents, blob.encoding);
21
21
  }
22
22
  async contains(path) {
23
23
  const blob = this.readBlobSync(path);
@@ -49,4 +49,4 @@ class LocalChannelStorageService {
49
49
  }
50
50
  }
51
51
  exports.LocalChannelStorageService = LocalChannelStorageService;
52
- //# sourceMappingURL=localChannelStorageService.js.map
52
+ //# sourceMappingURL=localChannelStorageService.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localChannelStorageService.cjs","sourceRoot":"","sources":["../src/localChannelStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA8D;AAC9D,+EAA+E;AAC/E,iEAAoE;AAEpE,MAAa,0BAA0B;IACtC,YAA6B,IAAW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,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAClC,KAAK,CAAC,KAAK,CACX,CAAC;qBACF;oBACD,MAAM;gBAEP,QAAQ;aACR;SACD;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AAhDD,gEAgDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { IBlob, ITree, TreeEntry } from \"@fluidframework/protocol-definitions\";\nimport { listBlobsAtTreePath } from \"@fluidframework/runtime-utils\";\n\nexport class LocalChannelStorageService implements IChannelStorageService {\n\tconstructor(private readonly tree: ITree) {}\n\n\tpublic async readBlob(path: string): Promise<ArrayBufferLike> {\n\t\tconst blob = this.readBlobSync(path);\n\t\tif (blob === undefined) {\n\t\t\tthrow new Error(\"Blob Not Found\");\n\t\t}\n\t\treturn stringToBuffer(blob.contents, blob.encoding);\n\t}\n\n\tpublic async contains(path: string): Promise<boolean> {\n\t\tconst blob = this.readBlobSync(path);\n\t\treturn blob !== undefined ? blob.contents !== undefined : false;\n\t}\n\n\tpublic async list(path: string): Promise<string[]> {\n\t\treturn listBlobsAtTreePath(this.tree, path);\n\t}\n\n\tprivate readBlobSync(path: string): IBlob | undefined {\n\t\treturn this.readBlobSyncInternal(path, this.tree);\n\t}\n\n\tprivate readBlobSyncInternal(path: string, tree: ITree): IBlob | undefined {\n\t\tfor (const entry of tree.entries) {\n\t\t\tswitch (entry.type) {\n\t\t\t\tcase TreeEntry.Blob:\n\t\t\t\t\tif (path === entry.path) {\n\t\t\t\t\t\treturn entry.value;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase TreeEntry.Tree:\n\t\t\t\t\tif (path.startsWith(entry.path)) {\n\t\t\t\t\t\treturn this.readBlobSyncInternal(\n\t\t\t\t\t\t\tpath.substr(entry.path.length + 1),\n\t\t\t\t\t\t\tentry.value,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localChannelStorageService.d.ts","sourceRoot":"","sources":["../src/localChannelStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAS,KAAK,EAAa,MAAM,sCAAsC,CAAC;AAG/E,qBAAa,0BAA2B,YAAW,sBAAsB;IACzD,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,KAAK;IAG3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAQhD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIlD,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,oBAAoB;CAqB/B"}
1
+ {"version":3,"file":"localChannelStorageService.d.ts","sourceRoot":"","sources":["../src/localChannelStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAS,KAAK,EAAa,MAAM,sCAAsC,CAAC;AAG/E,qBAAa,0BAA2B,YAAW,sBAAsB;IAC5D,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,KAAK;IAE3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAQhD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIlD,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,oBAAoB;CAwB5B"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.RemoteChannelContext = void 0;
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
10
+ const channelContext_1 = require("./channelContext.cjs");
11
+ class RemoteChannelContext {
12
+ constructor(runtime, dataStoreContext, storageService, submitFn, dirtyFn, addedGCOutboundReferenceFn, id, baseSnapshot, registry, extraBlobs, createSummarizerNode, attachMessageType) {
13
+ this.id = id;
14
+ this.isLoaded = false;
15
+ this.pending = [];
16
+ (0, core_utils_1.assert)(!this.id.includes("/"), 0x310 /* Channel context ID cannot contain slashes */);
17
+ this.subLogger = (0, telemetry_utils_1.createChildLogger)({
18
+ logger: runtime.logger,
19
+ namespace: "RemoteChannelContext",
20
+ });
21
+ this.services = (0, channelContext_1.createChannelServiceEndpoints)(dataStoreContext.connected, submitFn, () => dirtyFn(this.id), addedGCOutboundReferenceFn, storageService, this.subLogger, baseSnapshot, extraBlobs);
22
+ 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);
25
+ // Send all pending messages to the channel
26
+ (0, core_utils_1.assert)(this.pending !== undefined, 0x23f /* "pending undefined" */);
27
+ for (const message of this.pending) {
28
+ this.services.deltaConnection.process(message, false, undefined /* localOpMetadata */);
29
+ }
30
+ this.thresholdOpsCounter.send("ProcessPendingOps", this.pending.length);
31
+ // Commit changes.
32
+ this.channel = channel;
33
+ this.pending = undefined;
34
+ this.isLoaded = true;
35
+ // Because have some await between we created the service and here, the connection state might have changed
36
+ // and we don't propagate the connection state when we are not loaded. So we have to set it again here.
37
+ this.services.deltaConnection.setConnectionState(dataStoreContext.connected);
38
+ return this.channel;
39
+ });
40
+ const thisSummarizeInternal = async (fullTree, trackState, telemetryContext, incrementalSummaryContext) => this.summarizeInternal(fullTree, trackState, telemetryContext, incrementalSummaryContext);
41
+ this.summarizerNode = createSummarizerNode(thisSummarizeInternal, async (fullGC) => this.getGCDataInternal(fullGC));
42
+ this.thresholdOpsCounter = new telemetry_utils_1.ThresholdCounter(RemoteChannelContext.pendingOpsCountThreshold, this.subLogger);
43
+ }
44
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
45
+ getChannel() {
46
+ return this.channelP;
47
+ }
48
+ setConnectionState(connected, clientId) {
49
+ // Connection events are ignored if the data store is not yet loaded
50
+ if (!this.isLoaded) {
51
+ return;
52
+ }
53
+ this.services.deltaConnection.setConnectionState(connected);
54
+ }
55
+ applyStashedOp(content) {
56
+ (0, core_utils_1.assert)(this.isLoaded, 0x194 /* "Remote channel must be loaded when rebasing op" */);
57
+ return this.services.deltaConnection.applyStashedOp(content);
58
+ }
59
+ processOp(message, local, localOpMetadata) {
60
+ this.summarizerNode.invalidate(message.sequenceNumber);
61
+ if (this.isLoaded) {
62
+ this.services.deltaConnection.process(message, local, localOpMetadata);
63
+ }
64
+ else {
65
+ (0, core_utils_1.assert)(!local, 0x195 /* "Remote channel must not be local when processing op" */);
66
+ (0, core_utils_1.assert)(this.pending !== undefined, 0x23e /* "pending is undefined" */);
67
+ this.pending.push(message);
68
+ this.thresholdOpsCounter.sendIfMultiple("StorePendingOps", this.pending.length);
69
+ }
70
+ }
71
+ reSubmit(content, localOpMetadata) {
72
+ (0, core_utils_1.assert)(this.isLoaded, 0x196 /* "Remote channel must be loaded when resubmitting op" */);
73
+ this.services.deltaConnection.reSubmit(content, localOpMetadata);
74
+ }
75
+ rollback(content, localOpMetadata) {
76
+ (0, core_utils_1.assert)(this.isLoaded, 0x2f0 /* "Remote channel must be loaded when rolling back op" */);
77
+ this.services.deltaConnection.rollback(content, localOpMetadata);
78
+ }
79
+ /**
80
+ * Returns a summary at the current sequence number.
81
+ * @param fullTree - true to bypass optimizations and force a full summary tree
82
+ * @param trackState - This tells whether we should track state from this summary.
83
+ * @param telemetryContext - summary data passed through the layers for telemetry purposes
84
+ */
85
+ async summarize(fullTree = false, trackState = true, telemetryContext) {
86
+ return this.summarizerNode.summarize(fullTree, trackState, telemetryContext);
87
+ }
88
+ async summarizeInternal(fullTree, trackState, telemetryContext, incrementalSummaryContext) {
89
+ const channel = await this.getChannel();
90
+ const summarizeResult = await (0, channelContext_1.summarizeChannelAsync)(channel, fullTree, trackState, telemetryContext, incrementalSummaryContext);
91
+ return { ...summarizeResult, id: this.id };
92
+ }
93
+ /**
94
+ * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.
95
+ * Each node has a set of outbound routes to other GC nodes in the document.
96
+ * If there is no new data in this context since the last summary, previous GC data is used.
97
+ * If there is new data, the GC data is generated again (by calling getGCDataInternal).
98
+ * @param fullGC - true to bypass optimizations and force full generation of GC data.
99
+ */
100
+ async getGCData(fullGC = false) {
101
+ return this.summarizerNode.getGCData(fullGC);
102
+ }
103
+ /**
104
+ * Generates the data used for garbage collection. This is called when there is new data since last summary. It
105
+ * loads the context and calls into the channel to get its GC data.
106
+ * @param fullGC - true to bypass optimizations and force full generation of GC data.
107
+ */
108
+ async getGCDataInternal(fullGC = false) {
109
+ const channel = await this.getChannel();
110
+ return channel.getGCData(fullGC);
111
+ }
112
+ updateUsedRoutes(usedRoutes) {
113
+ /**
114
+ * Currently, DDSes are always considered referenced and are not garbage collected. Update the summarizer node's
115
+ * used routes to contain a route to this channel context.
116
+ * Once we have GC at DDS level, this will be updated to use the passed usedRoutes. See -
117
+ * https://github.com/microsoft/FluidFramework/issues/4611
118
+ */
119
+ this.summarizerNode.updateUsedRoutes([""]);
120
+ }
121
+ }
122
+ exports.RemoteChannelContext = RemoteChannelContext;
123
+ RemoteChannelContext.pendingOpsCountThreshold = 1000;
124
+ //# sourceMappingURL=remoteChannelContext.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteChannelContext.cjs","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAiE;AAejE,qEAIyC;AACzC,yDAO0B;AAG1B,MAAa,oBAAoB;IAWhC,YACC,OAA+B,EAC/B,gBAAwC,EACxC,cAAuC,EACvC,QAA0D,EAC1D,OAAkC,EAClC,0BAA2F,EAC1E,EAAU,EAC3B,YAA2B,EAC3B,QAA+B,EAC/B,UAAoD,EACpD,oBAAiD,EACjD,iBAA0B;QALT,OAAE,GAAF,EAAE,CAAQ;QAjBpB,aAAQ,GAAG,KAAK,CAAC;QACjB,YAAO,GAA4C,EAAE,CAAC;QAuB7D,IAAA,mBAAM,EAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAEtF,IAAI,CAAC,SAAS,GAAG,IAAA,mCAAiB,EAAC;YAClC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,sBAAsB;SACjC,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,GAAG,IAAA,8CAA6B,EAC5C,gBAAgB,CAAC,SAAS,EAC1B,QAAQ,EACR,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EACtB,0BAA0B,EAC1B,cAAc,EACd,IAAI,CAAC,SAAS,EACd,YAAY,EACZ,UAAU,CACV,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,IAAI,wBAAW,CAAW,KAAK,IAAI,EAAE;YACpD,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,gDAA+B,EACpE,gBAAgB,EAChB,IAAI,CAAC,QAAQ,EACb,IAA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I,CAAC,UAAU,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAEM,gBAAgB,CAAC,UAAoB;QAC3C;;;;;WAKG;QACH,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;;AAvNF,oDAwNC;AA/MwB,6CAAwB,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, LazyPromise } from \"@fluidframework/core-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { IChannel, IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tCreateChildSummarizerNodeFn,\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n\tIExperimentalIncrementalSummaryContext,\n\tISummarizeInternalResult,\n\tISummarizeResult,\n\tISummarizerNodeWithGC,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tcreateChildLogger,\n\tITelemetryLoggerExt,\n\tThresholdCounter,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tChannelServiceEndpoints,\n\tcreateChannelServiceEndpoints,\n\tIChannelContext,\n\tloadChannel,\n\tloadChannelFactoryAndAttributes,\n\tsummarizeChannelAsync,\n} from \"./channelContext\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\n\nexport class RemoteChannelContext implements IChannelContext {\n\tprivate isLoaded = false;\n\tprivate pending: ISequencedDocumentMessage[] | undefined = [];\n\tprivate readonly channelP: Promise<IChannel>;\n\tprivate channel: IChannel | undefined;\n\tprivate readonly services: ChannelServiceEndpoints;\n\tprivate readonly summarizerNode: ISummarizerNodeWithGC;\n\tprivate readonly subLogger: ITelemetryLoggerExt;\n\tprivate readonly thresholdOpsCounter: ThresholdCounter;\n\tprivate static readonly pendingOpsCountThreshold = 1000;\n\n\tconstructor(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tdataStoreContext: IFluidDataStoreContext,\n\t\tstorageService: IDocumentStorageService,\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 id: string,\n\t\tbaseSnapshot: ISnapshotTree,\n\t\tregistry: ISharedObjectRegistry,\n\t\textraBlobs: Map<string, ArrayBufferLike> | undefined,\n\t\tcreateSummarizerNode: CreateChildSummarizerNodeFn,\n\t\tattachMessageType?: string,\n\t) {\n\t\tassert(!this.id.includes(\"/\"), 0x310 /* Channel context ID cannot contain slashes */);\n\n\t\tthis.subLogger = createChildLogger({\n\t\t\tlogger: runtime.logger,\n\t\t\tnamespace: \"RemoteChannelContext\",\n\t\t});\n\n\t\tthis.services = createChannelServiceEndpoints(\n\t\t\tdataStoreContext.connected,\n\t\t\tsubmitFn,\n\t\t\t() => dirtyFn(this.id),\n\t\t\taddedGCOutboundReferenceFn,\n\t\t\tstorageService,\n\t\t\tthis.subLogger,\n\t\t\tbaseSnapshot,\n\t\t\textraBlobs,\n\t\t);\n\n\t\tthis.channelP = new LazyPromise<IChannel>(async () => {\n\t\t\tconst { attributes, factory } = await loadChannelFactoryAndAttributes(\n\t\t\t\tdataStoreContext,\n\t\t\t\tthis.services,\n\t\t\t\tthis.id,\n\t\t\t\tregistry,\n\t\t\t\tattachMessageType,\n\t\t\t);\n\n\t\t\tconst channel = await loadChannel(\n\t\t\t\truntime,\n\t\t\t\tattributes,\n\t\t\t\tfactory,\n\t\t\t\tthis.services,\n\t\t\t\tthis.subLogger,\n\t\t\t\tthis.id,\n\t\t\t);\n\n\t\t\t// Send all pending messages to the channel\n\t\t\tassert(this.pending !== undefined, 0x23f /* \"pending undefined\" */);\n\t\t\tfor (const message of this.pending) {\n\t\t\t\tthis.services.deltaConnection.process(\n\t\t\t\t\tmessage,\n\t\t\t\t\tfalse,\n\t\t\t\t\tundefined /* localOpMetadata */,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.thresholdOpsCounter.send(\"ProcessPendingOps\", this.pending.length);\n\n\t\t\t// Commit changes.\n\t\t\tthis.channel = channel;\n\t\t\tthis.pending = undefined;\n\t\t\tthis.isLoaded = true;\n\n\t\t\t// Because have some await between we created the service and here, the connection state might have changed\n\t\t\t// and we don't propagate the connection state when we are not loaded. So we have to set it again here.\n\t\t\tthis.services.deltaConnection.setConnectionState(dataStoreContext.connected);\n\t\t\treturn this.channel;\n\t\t});\n\n\t\tconst thisSummarizeInternal = async (\n\t\t\tfullTree: boolean,\n\t\t\ttrackState: boolean,\n\t\t\ttelemetryContext?: ITelemetryContext,\n\t\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\t) =>\n\t\t\tthis.summarizeInternal(\n\t\t\t\tfullTree,\n\t\t\t\ttrackState,\n\t\t\t\ttelemetryContext,\n\t\t\t\tincrementalSummaryContext,\n\t\t\t);\n\n\t\tthis.summarizerNode = createSummarizerNode(\n\t\t\tthisSummarizeInternal,\n\t\t\tasync (fullGC?: boolean) => this.getGCDataInternal(fullGC),\n\t\t);\n\n\t\tthis.thresholdOpsCounter = new ThresholdCounter(\n\t\t\tRemoteChannelContext.pendingOpsCountThreshold,\n\t\t\tthis.subLogger,\n\t\t);\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tpublic getChannel(): Promise<IChannel> {\n\t\treturn this.channelP;\n\t}\n\n\tpublic setConnectionState(connected: boolean, clientId?: string) {\n\t\t// Connection events are ignored if the data store is not yet loaded\n\t\tif (!this.isLoaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.services.deltaConnection.setConnectionState(connected);\n\t}\n\n\tpublic applyStashedOp(content: any): unknown {\n\t\tassert(this.isLoaded, 0x194 /* \"Remote channel must be loaded when rebasing op\" */);\n\t\treturn this.services.deltaConnection.applyStashedOp(content);\n\t}\n\n\tpublic processOp(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.summarizerNode.invalidate(message.sequenceNumber);\n\n\t\tif (this.isLoaded) {\n\t\t\tthis.services.deltaConnection.process(message, local, localOpMetadata);\n\t\t} else {\n\t\t\tassert(!local, 0x195 /* \"Remote channel must not be local when processing op\" */);\n\t\t\tassert(this.pending !== undefined, 0x23e /* \"pending is undefined\" */);\n\t\t\tthis.pending.push(message);\n\t\t\tthis.thresholdOpsCounter.sendIfMultiple(\"StorePendingOps\", this.pending.length);\n\t\t}\n\t}\n\n\tpublic reSubmit(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x196 /* \"Remote channel must be loaded when resubmitting op\" */);\n\n\t\tthis.services.deltaConnection.reSubmit(content, localOpMetadata);\n\t}\n\n\tpublic rollback(content: any, localOpMetadata: unknown) {\n\t\tassert(this.isLoaded, 0x2f0 /* \"Remote channel must be loaded when rolling back op\" */);\n\n\t\tthis.services.deltaConnection.rollback(content, localOpMetadata);\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 = true,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummarizeResult> {\n\t\treturn this.summarizerNode.summarize(fullTree, trackState, telemetryContext);\n\t}\n\n\tprivate async summarizeInternal(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummarizeInternalResult> {\n\t\tconst channel = await this.getChannel();\n\t\tconst summarizeResult = await summarizeChannelAsync(\n\t\t\tchannel,\n\t\t\tfullTree,\n\t\t\ttrackState,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\t\treturn { ...summarizeResult, id: this.id };\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.\n\t * If there is no new data in this context since the last summary, previous GC data is used.\n\t * If there is new data, the GC data is generated again (by calling getGCDataInternal).\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\treturn this.summarizerNode.getGCData(fullGC);\n\t}\n\n\t/**\n\t * Generates the data used for garbage collection. This is called when there is new data since last summary. It\n\t * loads the context and calls into the channel to get its GC data.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tprivate async getGCDataInternal(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. Update the summarizer node's\n\t\t * used routes to contain a route to this channel context.\n\t\t * Once we have GC at DDS level, this will be updated to use the passed usedRoutes. See -\n\t\t * https://github.com/microsoft/FluidFramework/issues/4611\n\t\t */\n\t\tthis.summarizerNode.updateUsedRoutes([\"\"]);\n\t}\n}\n"]}
@@ -6,28 +6,24 @@ import { IFluidHandle } from "@fluidframework/core-interfaces";
6
6
  import { IChannel, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
7
7
  import { IDocumentStorageService } from "@fluidframework/driver-definitions";
8
8
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
9
- import { CreateChildSummarizerNodeFn, IFluidDataStoreContext, IGarbageCollectionData, IGarbageCollectionDetailsBase, ISummarizeResult, ITelemetryContext } from "@fluidframework/runtime-definitions";
9
+ import { CreateChildSummarizerNodeFn, IFluidDataStoreContext, IGarbageCollectionData, ISummarizeResult, ITelemetryContext } from "@fluidframework/runtime-definitions";
10
10
  import { IChannelContext } from "./channelContext";
11
11
  import { ISharedObjectRegistry } from "./dataStoreRuntime";
12
12
  export declare class RemoteChannelContext implements IChannelContext {
13
- private readonly runtime;
14
- private readonly dataStoreContext;
15
13
  private readonly id;
16
- private readonly registry;
17
- private readonly attachMessageType?;
18
14
  private isLoaded;
19
15
  private pending;
20
- private channelP;
16
+ private readonly channelP;
21
17
  private channel;
22
18
  private readonly services;
23
19
  private readonly summarizerNode;
24
20
  private readonly subLogger;
25
21
  private readonly thresholdOpsCounter;
26
22
  private static readonly pendingOpsCountThreshold;
27
- constructor(runtime: IFluidDataStoreRuntime, dataStoreContext: IFluidDataStoreContext, storageService: IDocumentStorageService, submitFn: (content: any, localOpMetadata: unknown) => void, dirtyFn: (address: string) => void, addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void, id: string, baseSnapshot: ISnapshotTree, registry: ISharedObjectRegistry, extraBlobs: Map<string, ArrayBufferLike> | undefined, createSummarizerNode: CreateChildSummarizerNodeFn, getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase>, attachMessageType?: string | undefined);
23
+ constructor(runtime: IFluidDataStoreRuntime, dataStoreContext: IFluidDataStoreContext, storageService: IDocumentStorageService, submitFn: (content: any, localOpMetadata: unknown) => void, dirtyFn: (address: string) => void, addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void, id: string, baseSnapshot: ISnapshotTree, registry: ISharedObjectRegistry, extraBlobs: Map<string, ArrayBufferLike> | undefined, createSummarizerNode: CreateChildSummarizerNodeFn, attachMessageType?: string);
28
24
  getChannel(): Promise<IChannel>;
29
25
  setConnectionState(connected: boolean, clientId?: string): void;
30
- applyStashedOp(message: ISequencedDocumentMessage): unknown;
26
+ applyStashedOp(content: any): unknown;
31
27
  processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
32
28
  reSubmit(content: any, localOpMetadata: unknown): void;
33
29
  rollback(content: any, localOpMetadata: unknown): void;
@@ -39,7 +35,6 @@ export declare class RemoteChannelContext implements IChannelContext {
39
35
  */
40
36
  summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummarizeResult>;
41
37
  private summarizeInternal;
42
- private loadChannel;
43
38
  /**
44
39
  * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.
45
40
  * Each node has a set of outbound routes to other GC nodes in the document.
@@ -54,6 +49,6 @@ export declare class RemoteChannelContext implements IChannelContext {
54
49
  * @param fullGC - true to bypass optimizations and force full generation of GC data.
55
50
  */
56
51
  private getGCDataInternal;
57
- updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): void;
52
+ updateUsedRoutes(usedRoutes: string[]): void;
58
53
  }
59
54
  //# sourceMappingURL=remoteChannelContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"remoteChannelContext.d.ts","sourceRoot":"","sources":["../src/remoteChannelContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACH,QAAQ,EAER,sBAAsB,EAEzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EACH,yBAAyB,EACzB,aAAa,EAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,6BAA6B,EAE7B,gBAAgB,EAEhB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAGH,eAAe,EAElB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3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O,GACtB,IAAI;IAaA,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO;IAM/C,QAAQ,CAAC,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"}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.38.3"
9
+ }
10
+ ]
11
+ }