@fluidframework/container-loader 2.0.0-dev-rc.1.0.0.232845 → 2.0.0-dev-rc.2.0.0.246488

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 (297) hide show
  1. package/.eslintrc.cjs +5 -6
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +48 -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/container-loader.api.md +2 -2
  8. package/dist/attachment.d.ts +6 -7
  9. package/dist/attachment.d.ts.map +1 -1
  10. package/dist/attachment.js +8 -7
  11. package/dist/attachment.js.map +1 -1
  12. package/dist/audience.d.ts +9 -4
  13. package/dist/audience.d.ts.map +1 -1
  14. package/dist/audience.js +12 -6
  15. package/dist/audience.js.map +1 -1
  16. package/dist/connectionManager.d.ts +3 -3
  17. package/dist/connectionManager.d.ts.map +1 -1
  18. package/dist/connectionManager.js +20 -18
  19. package/dist/connectionManager.js.map +1 -1
  20. package/dist/connectionState.d.ts +1 -0
  21. package/dist/connectionState.d.ts.map +1 -1
  22. package/dist/connectionState.js +1 -0
  23. package/dist/connectionState.js.map +1 -1
  24. package/dist/connectionStateHandler.d.ts +7 -7
  25. package/dist/connectionStateHandler.d.ts.map +1 -1
  26. package/dist/connectionStateHandler.js +32 -32
  27. package/dist/connectionStateHandler.js.map +1 -1
  28. package/dist/container-loader-alpha.d.ts +1 -0
  29. package/dist/container-loader-beta.d.ts +3 -0
  30. package/dist/container-loader-public.d.ts +3 -0
  31. package/dist/container-loader-untrimmed.d.ts +4 -4
  32. package/dist/container.d.ts +11 -22
  33. package/dist/container.d.ts.map +1 -1
  34. package/dist/container.js +101 -194
  35. package/dist/container.js.map +1 -1
  36. package/dist/containerStorageAdapter.d.ts +2 -3
  37. package/dist/containerStorageAdapter.d.ts.map +1 -1
  38. package/dist/containerStorageAdapter.js +4 -10
  39. package/dist/containerStorageAdapter.js.map +1 -1
  40. package/dist/contracts.d.ts +3 -3
  41. package/dist/contracts.d.ts.map +1 -1
  42. package/dist/contracts.js.map +1 -1
  43. package/dist/debugLogger.js.map +1 -1
  44. package/dist/deltaManager.d.ts +5 -5
  45. package/dist/deltaManager.d.ts.map +1 -1
  46. package/dist/deltaManager.js +6 -6
  47. package/dist/deltaManager.js.map +1 -1
  48. package/dist/error.d.ts.map +1 -1
  49. package/dist/error.js.map +1 -1
  50. package/dist/index.d.ts +6 -6
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +11 -11
  53. package/dist/index.js.map +1 -1
  54. package/dist/loader.d.ts +2 -2
  55. package/dist/loader.d.ts.map +1 -1
  56. package/dist/loader.js +13 -17
  57. package/dist/loader.js.map +1 -1
  58. package/dist/location-redirection-utilities/index.d.ts +1 -1
  59. package/dist/location-redirection-utilities/index.d.ts.map +1 -1
  60. package/dist/location-redirection-utilities/index.js +3 -3
  61. package/dist/location-redirection-utilities/index.js.map +1 -1
  62. package/dist/package.json +3 -0
  63. package/dist/packageVersion.d.ts +1 -1
  64. package/dist/packageVersion.js +1 -1
  65. package/dist/packageVersion.js.map +1 -1
  66. package/dist/protocolTreeDocumentStorageService.d.ts +0 -1
  67. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  68. package/dist/protocolTreeDocumentStorageService.js +0 -3
  69. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  70. package/dist/quorum.d.ts.map +1 -1
  71. package/dist/quorum.js +4 -0
  72. package/dist/quorum.js.map +1 -1
  73. package/dist/retriableDocumentStorageService.d.ts +0 -1
  74. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  75. package/dist/retriableDocumentStorageService.js +0 -6
  76. package/dist/retriableDocumentStorageService.js.map +1 -1
  77. package/dist/serializedStateManager.d.ts +44 -0
  78. package/dist/serializedStateManager.d.ts.map +1 -0
  79. package/dist/serializedStateManager.js +149 -0
  80. package/dist/serializedStateManager.js.map +1 -0
  81. package/dist/tsdoc-metadata.json +1 -1
  82. package/dist/utils.d.ts +5 -6
  83. package/dist/utils.d.ts.map +1 -1
  84. package/dist/utils.js +10 -4
  85. package/dist/utils.js.map +1 -1
  86. package/lib/{attachment.d.mts → attachment.d.ts} +11 -8
  87. package/lib/attachment.d.ts.map +1 -0
  88. package/lib/{attachment.mjs → attachment.js} +11 -6
  89. package/lib/attachment.js.map +1 -0
  90. package/lib/{audience.d.mts → audience.d.ts} +14 -5
  91. package/lib/audience.d.ts.map +1 -0
  92. package/lib/{audience.mjs → audience.js} +14 -4
  93. package/lib/audience.js.map +1 -0
  94. package/lib/{catchUpMonitor.d.mts → catchUpMonitor.d.ts} +1 -1
  95. package/lib/catchUpMonitor.d.ts.map +1 -0
  96. package/lib/{catchUpMonitor.mjs → catchUpMonitor.js} +1 -1
  97. package/lib/catchUpMonitor.js.map +1 -0
  98. package/lib/{connectionManager.d.mts → connectionManager.d.ts} +4 -4
  99. package/lib/connectionManager.d.ts.map +1 -0
  100. package/lib/{connectionManager.mjs → connectionManager.js} +9 -7
  101. package/lib/connectionManager.js.map +1 -0
  102. package/lib/{connectionState.d.mts → connectionState.d.ts} +2 -1
  103. package/lib/connectionState.d.ts.map +1 -0
  104. package/lib/{connectionState.mjs → connectionState.js} +2 -1
  105. package/lib/connectionState.js.map +1 -0
  106. package/lib/{connectionStateHandler.d.mts → connectionStateHandler.d.ts} +8 -8
  107. package/lib/connectionStateHandler.d.ts.map +1 -0
  108. package/lib/{connectionStateHandler.mjs → connectionStateHandler.js} +3 -3
  109. package/lib/connectionStateHandler.js.map +1 -0
  110. package/lib/{container-loader-alpha.d.mts → container-loader-alpha.d.ts} +1 -0
  111. package/lib/{container-loader-beta.d.mts → container-loader-beta.d.ts} +3 -0
  112. package/lib/{container-loader-public.d.mts → container-loader-public.d.ts} +3 -0
  113. package/lib/{container-loader-untrimmed.d.mts → container-loader-untrimmed.d.ts} +4 -4
  114. package/lib/{container.d.mts → container.d.ts} +12 -23
  115. package/lib/container.d.ts.map +1 -0
  116. package/lib/{container.mjs → container.js} +55 -148
  117. package/lib/container.js.map +1 -0
  118. package/lib/{containerContext.d.mts → containerContext.d.ts} +1 -1
  119. package/lib/containerContext.d.ts.map +1 -0
  120. package/lib/{containerContext.mjs → containerContext.js} +1 -1
  121. package/lib/containerContext.js.map +1 -0
  122. package/lib/{containerStorageAdapter.d.mts → containerStorageAdapter.d.ts} +3 -4
  123. package/lib/containerStorageAdapter.d.ts.map +1 -0
  124. package/lib/{containerStorageAdapter.mjs → containerStorageAdapter.js} +3 -9
  125. package/lib/containerStorageAdapter.js.map +1 -0
  126. package/lib/{contracts.d.mts → contracts.d.ts} +4 -4
  127. package/lib/contracts.d.ts.map +1 -0
  128. package/lib/{contracts.mjs → contracts.js} +1 -1
  129. package/lib/contracts.js.map +1 -0
  130. package/lib/{debugLogger.d.mts → debugLogger.d.ts} +1 -1
  131. package/lib/debugLogger.d.ts.map +1 -0
  132. package/lib/{debugLogger.mjs → debugLogger.js} +2 -1
  133. package/lib/debugLogger.js.map +1 -0
  134. package/lib/{deltaManager.d.mts → deltaManager.d.ts} +6 -6
  135. package/lib/deltaManager.d.ts.map +1 -0
  136. package/lib/{deltaManager.mjs → deltaManager.js} +4 -4
  137. package/lib/deltaManager.js.map +1 -0
  138. package/lib/{deltaQueue.d.mts → deltaQueue.d.ts} +1 -1
  139. package/lib/deltaQueue.d.ts.map +1 -0
  140. package/lib/{deltaQueue.mjs → deltaQueue.js} +1 -1
  141. package/lib/deltaQueue.js.map +1 -0
  142. package/lib/{disposal.d.mts → disposal.d.ts} +1 -1
  143. package/lib/disposal.d.ts.map +1 -0
  144. package/lib/{disposal.mjs → disposal.js} +1 -1
  145. package/lib/disposal.js.map +1 -0
  146. package/lib/{error.d.mts → error.d.ts} +1 -1
  147. package/lib/error.d.ts.map +1 -0
  148. package/lib/{error.mjs → error.js} +1 -1
  149. package/lib/error.js.map +1 -0
  150. package/lib/{index.d.mts → index.d.ts} +7 -7
  151. package/lib/index.d.ts.map +1 -0
  152. package/lib/index.js +10 -0
  153. package/lib/index.js.map +1 -0
  154. package/lib/{loader.d.mts → loader.d.ts} +3 -3
  155. package/lib/loader.d.ts.map +1 -0
  156. package/lib/{loader.mjs → loader.js} +7 -11
  157. package/lib/loader.js.map +1 -0
  158. package/lib/location-redirection-utilities/{index.mjs → index.d.ts} +2 -2
  159. package/lib/location-redirection-utilities/index.d.ts.map +1 -0
  160. package/lib/location-redirection-utilities/{index.d.mts → index.js} +2 -2
  161. package/lib/location-redirection-utilities/index.js.map +1 -0
  162. package/lib/location-redirection-utilities/{resolveWithLocationRedirection.d.mts → resolveWithLocationRedirection.d.ts} +1 -1
  163. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
  164. package/lib/location-redirection-utilities/{resolveWithLocationRedirection.mjs → resolveWithLocationRedirection.js} +1 -1
  165. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
  166. package/lib/{noopHeuristic.d.mts → noopHeuristic.d.ts} +1 -1
  167. package/lib/noopHeuristic.d.ts.map +1 -0
  168. package/lib/{noopHeuristic.mjs → noopHeuristic.js} +1 -1
  169. package/lib/noopHeuristic.js.map +1 -0
  170. package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
  171. package/lib/packageVersion.d.ts.map +1 -0
  172. package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
  173. package/lib/packageVersion.js.map +1 -0
  174. package/lib/{protocol.d.mts → protocol.d.ts} +1 -1
  175. package/lib/protocol.d.ts.map +1 -0
  176. package/lib/{protocol.mjs → protocol.js} +1 -1
  177. package/lib/protocol.js.map +1 -0
  178. package/lib/{protocolTreeDocumentStorageService.d.mts → protocolTreeDocumentStorageService.d.ts} +1 -2
  179. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -0
  180. package/lib/{protocolTreeDocumentStorageService.mjs → protocolTreeDocumentStorageService.js} +1 -4
  181. package/lib/protocolTreeDocumentStorageService.js.map +1 -0
  182. package/lib/{quorum.d.mts → quorum.d.ts} +5 -1
  183. package/lib/quorum.d.ts.map +1 -0
  184. package/lib/{quorum.mjs → quorum.js} +5 -1
  185. package/lib/quorum.js.map +1 -0
  186. package/lib/{retriableDocumentStorageService.d.mts → retriableDocumentStorageService.d.ts} +1 -2
  187. package/lib/retriableDocumentStorageService.d.ts.map +1 -0
  188. package/lib/{retriableDocumentStorageService.mjs → retriableDocumentStorageService.js} +1 -7
  189. package/lib/retriableDocumentStorageService.js.map +1 -0
  190. package/lib/serializedStateManager.d.ts +44 -0
  191. package/lib/serializedStateManager.d.ts.map +1 -0
  192. package/lib/serializedStateManager.js +145 -0
  193. package/lib/serializedStateManager.js.map +1 -0
  194. package/lib/test/attachment.spec.js +380 -0
  195. package/lib/test/attachment.spec.js.map +1 -0
  196. package/lib/test/catchUpMonitor.spec.js +88 -0
  197. package/lib/test/catchUpMonitor.spec.js.map +1 -0
  198. package/lib/test/connectionManager.spec.js +201 -0
  199. package/lib/test/connectionManager.spec.js.map +1 -0
  200. package/lib/test/connectionStateHandler.spec.js +555 -0
  201. package/lib/test/connectionStateHandler.spec.js.map +1 -0
  202. package/lib/test/container.spec.js +64 -0
  203. package/lib/test/container.spec.js.map +1 -0
  204. package/lib/test/deltaManager.spec.js +405 -0
  205. package/lib/test/deltaManager.spec.js.map +1 -0
  206. package/lib/test/loader.spec.js +212 -0
  207. package/lib/test/loader.spec.js.map +1 -0
  208. package/lib/test/locationRedirectionTests.spec.js +44 -0
  209. package/lib/test/locationRedirectionTests.spec.js.map +1 -0
  210. package/lib/test/serializedStateManager.spec.js +148 -0
  211. package/lib/test/serializedStateManager.spec.js.map +1 -0
  212. package/lib/test/snapshotConversionTest.spec.js +79 -0
  213. package/lib/test/snapshotConversionTest.spec.js.map +1 -0
  214. package/lib/test/types/validateContainerLoaderPrevious.generated.js +38 -0
  215. package/lib/test/types/validateContainerLoaderPrevious.generated.js.map +1 -0
  216. package/lib/test/utils.spec.js +31 -0
  217. package/lib/test/utils.spec.js.map +1 -0
  218. package/lib/{utils.d.mts → utils.d.ts} +6 -7
  219. package/lib/utils.d.ts.map +1 -0
  220. package/lib/{utils.mjs → utils.js} +11 -5
  221. package/lib/utils.js.map +1 -0
  222. package/package.json +56 -62
  223. package/src/attachment.ts +16 -12
  224. package/src/audience.ts +10 -3
  225. package/src/connectionManager.ts +13 -9
  226. package/src/connectionState.ts +1 -0
  227. package/src/connectionStateHandler.ts +8 -7
  228. package/src/container.ts +96 -191
  229. package/src/containerStorageAdapter.ts +6 -14
  230. package/src/contracts.ts +3 -3
  231. package/src/debugLogger.ts +2 -2
  232. package/src/deltaManager.ts +8 -8
  233. package/src/error.ts +2 -2
  234. package/src/index.ts +6 -6
  235. package/src/loader.ts +8 -12
  236. package/src/location-redirection-utilities/index.ts +1 -1
  237. package/src/packageVersion.ts +1 -1
  238. package/src/protocolTreeDocumentStorageService.ts +0 -3
  239. package/src/quorum.ts +1 -0
  240. package/src/retriableDocumentStorageService.ts +0 -7
  241. package/src/serializedStateManager.ts +217 -0
  242. package/src/utils.ts +15 -10
  243. package/tsconfig.cjs.json +7 -0
  244. package/tsconfig.json +2 -5
  245. package/lib/attachment.d.mts.map +0 -1
  246. package/lib/attachment.mjs.map +0 -1
  247. package/lib/audience.d.mts.map +0 -1
  248. package/lib/audience.mjs.map +0 -1
  249. package/lib/catchUpMonitor.d.mts.map +0 -1
  250. package/lib/catchUpMonitor.mjs.map +0 -1
  251. package/lib/connectionManager.d.mts.map +0 -1
  252. package/lib/connectionManager.mjs.map +0 -1
  253. package/lib/connectionState.d.mts.map +0 -1
  254. package/lib/connectionState.mjs.map +0 -1
  255. package/lib/connectionStateHandler.d.mts.map +0 -1
  256. package/lib/connectionStateHandler.mjs.map +0 -1
  257. package/lib/container.d.mts.map +0 -1
  258. package/lib/container.mjs.map +0 -1
  259. package/lib/containerContext.d.mts.map +0 -1
  260. package/lib/containerContext.mjs.map +0 -1
  261. package/lib/containerStorageAdapter.d.mts.map +0 -1
  262. package/lib/containerStorageAdapter.mjs.map +0 -1
  263. package/lib/contracts.d.mts.map +0 -1
  264. package/lib/contracts.mjs.map +0 -1
  265. package/lib/debugLogger.d.mts.map +0 -1
  266. package/lib/debugLogger.mjs.map +0 -1
  267. package/lib/deltaManager.d.mts.map +0 -1
  268. package/lib/deltaManager.mjs.map +0 -1
  269. package/lib/deltaQueue.d.mts.map +0 -1
  270. package/lib/deltaQueue.mjs.map +0 -1
  271. package/lib/disposal.d.mts.map +0 -1
  272. package/lib/disposal.mjs.map +0 -1
  273. package/lib/error.d.mts.map +0 -1
  274. package/lib/error.mjs.map +0 -1
  275. package/lib/index.d.mts.map +0 -1
  276. package/lib/index.mjs +0 -10
  277. package/lib/index.mjs.map +0 -1
  278. package/lib/loader.d.mts.map +0 -1
  279. package/lib/loader.mjs.map +0 -1
  280. package/lib/location-redirection-utilities/index.d.mts.map +0 -1
  281. package/lib/location-redirection-utilities/index.mjs.map +0 -1
  282. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts.map +0 -1
  283. package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs.map +0 -1
  284. package/lib/noopHeuristic.d.mts.map +0 -1
  285. package/lib/noopHeuristic.mjs.map +0 -1
  286. package/lib/packageVersion.d.mts.map +0 -1
  287. package/lib/packageVersion.mjs.map +0 -1
  288. package/lib/protocol.d.mts.map +0 -1
  289. package/lib/protocol.mjs.map +0 -1
  290. package/lib/protocolTreeDocumentStorageService.d.mts.map +0 -1
  291. package/lib/protocolTreeDocumentStorageService.mjs.map +0 -1
  292. package/lib/quorum.d.mts.map +0 -1
  293. package/lib/quorum.mjs.map +0 -1
  294. package/lib/retriableDocumentStorageService.d.mts.map +0 -1
  295. package/lib/retriableDocumentStorageService.mjs.map +0 -1
  296. package/lib/utils.d.mts.map +0 -1
  297. package/lib/utils.mjs.map +0 -1
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { v4 as uuid } from "uuid";
6
- import { assert, unreachableCase } from "@fluidframework/core-utils";
6
+ import { assert, unreachableCase, isPromiseLike } from "@fluidframework/core-utils";
7
7
  import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
8
8
  import { LogLevel, } from "@fluidframework/core-interfaces";
9
9
  import { AttachState, isFluidCodeDetails, } from "@fluidframework/container-definitions";
@@ -11,21 +11,22 @@ import { readAndParse, OnlineStatus, isOnline, isCombinedAppAndProtocolSummary,
11
11
  import { MessageType, SummaryType, } from "@fluidframework/protocol-definitions";
12
12
  import { createChildLogger, EventEmitterWithErrorHandling, PerformanceEvent, raiseConnectedEvent, connectedEventName, normalizeError, createChildMonitoringContext, wrapError, formatTick, GenericError, UsageError, } from "@fluidframework/telemetry-utils";
13
13
  import structuredClone from "@ungap/structured-clone";
14
- import { Audience } from "./audience.mjs";
15
- import { ContainerContext } from "./containerContext.mjs";
16
- import { ReconnectMode, getPackageName, } from "./contracts.mjs";
17
- import { DeltaManager } from "./deltaManager.mjs";
18
- import { RelativeLoader } from "./loader.mjs";
19
- import { pkgVersion } from "./packageVersion.mjs";
20
- import { ContainerStorageAdapter, getBlobContentsFromTree, } from "./containerStorageAdapter.mjs";
21
- import { createConnectionStateHandler } from "./connectionStateHandler.mjs";
22
- import { combineAppAndProtocolSummary, getProtocolSnapshotTree, getSnapshotTreeAndBlobsFromSerializedContainer, combineSnapshotTreeAndSnapshotBlobs, getDetachedContainerStateFromSerializedContainer, runSingle, } from "./utils.mjs";
23
- import { initQuorumValuesFromCodeDetails } from "./quorum.mjs";
24
- import { NoopHeuristic } from "./noopHeuristic.mjs";
25
- import { ConnectionManager } from "./connectionManager.mjs";
26
- import { ConnectionState } from "./connectionState.mjs";
27
- import { ProtocolHandler, protocolHandlerShouldProcessSignal, } from "./protocol.mjs";
28
- import { runRetriableAttachProcess } from "./attachment.mjs";
14
+ import { Audience } from "./audience.js";
15
+ import { ContainerContext } from "./containerContext.js";
16
+ import { ReconnectMode, getPackageName, } from "./contracts.js";
17
+ import { DeltaManager } from "./deltaManager.js";
18
+ import { RelativeLoader } from "./loader.js";
19
+ import { pkgVersion } from "./packageVersion.js";
20
+ import { ContainerStorageAdapter } from "./containerStorageAdapter.js";
21
+ import { createConnectionStateHandler } from "./connectionStateHandler.js";
22
+ import { combineAppAndProtocolSummary, getProtocolSnapshotTree, getSnapshotTreeAndBlobsFromSerializedContainer, combineSnapshotTreeAndSnapshotBlobs, getDetachedContainerStateFromSerializedContainer, runSingle, } from "./utils.js";
23
+ import { initQuorumValuesFromCodeDetails } from "./quorum.js";
24
+ import { NoopHeuristic } from "./noopHeuristic.js";
25
+ import { ConnectionManager } from "./connectionManager.js";
26
+ import { ConnectionState } from "./connectionState.js";
27
+ import { ProtocolHandler, protocolHandlerShouldProcessSignal, } from "./protocol.js";
28
+ import { runRetriableAttachProcess } from "./attachment.js";
29
+ import { SerializedStateManager } from "./serializedStateManager.js";
29
30
  const detachedContainerRefSeqNumber = 0;
30
31
  const dirtyContainerEvent = "dirty";
31
32
  const savedContainerEvent = "saved";
@@ -104,9 +105,7 @@ export async function waitContainerToCatchUp(container) {
104
105
  }
105
106
  });
106
107
  }
107
- const getCodeProposal =
108
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
109
- (quorum) => quorum.get("code") ?? quorum.get("code2");
108
+ const getCodeProposal = (quorum) => quorum.get("code") ?? quorum.get("code2");
110
109
  /**
111
110
  * Helper function to report to telemetry cases where operation takes longer than expected (200ms)
112
111
  * @param logger - logger to use
@@ -124,7 +123,6 @@ const summarizerClientType = "summarizer";
124
123
  export class Container extends EventEmitterWithErrorHandling {
125
124
  /**
126
125
  * Load an existing container.
127
- * @internal
128
126
  */
129
127
  static async load(loadProps, createProps) {
130
128
  const { version, pendingLocalState, loadMode, resolvedUrl, loadToSequenceNumber } = loadProps;
@@ -272,11 +270,8 @@ export class Container extends EventEmitterWithErrorHandling {
272
270
  get clientId() {
273
271
  return this._clientId;
274
272
  }
275
- get offlineLoadEnabled() {
276
- const enabled = this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad") ??
277
- this.options?.enableOfflineLoad === true;
278
- // summarizer will not have any pending state we want to save
279
- return enabled && this.deltaManager.clientDetails.capabilities.interactive;
273
+ get isInteractiveClient() {
274
+ return this.deltaManager.clientDetails.capabilities.interactive;
280
275
  }
281
276
  /**
282
277
  * Get the code details that are currently specified for the container.
@@ -331,9 +326,6 @@ export class Container extends EventEmitterWithErrorHandling {
331
326
  this._lifecycleEvents.once("disposed", disposedHandler);
332
327
  });
333
328
  }
334
- /**
335
- * @internal
336
- */
337
329
  constructor(createProps, loadProps) {
338
330
  super((name, error) => {
339
331
  this.mc.logger.sendErrorEvent({
@@ -362,7 +354,6 @@ export class Container extends EventEmitterWithErrorHandling {
362
354
  this.firstConnection = true;
363
355
  this.connectionTransitionTimes = [];
364
356
  this._dirtyContainer = false;
365
- this.savedOps = [];
366
357
  this.attachmentData = { state: AttachState.Detached };
367
358
  this.clientsWhoShouldHaveLeft = new Set();
368
359
  this._containerMetadata = {};
@@ -423,7 +414,7 @@ export class Container extends EventEmitterWithErrorHandling {
423
414
  };
424
415
  let attachP = runRetriableAttachProcess({
425
416
  initialAttachmentData: this.attachmentData,
426
- offlineLoadEnabled: this.offlineLoadEnabled,
417
+ offlineLoadEnabled: this.serializedStateManager.offlineLoadEnabled,
427
418
  detachedBlobStorage: this.detachedBlobStorage,
428
419
  setAttachmentData,
429
420
  createAttachmentSummary,
@@ -435,7 +426,7 @@ export class Container extends EventEmitterWithErrorHandling {
435
426
  throw normalizeErrorAndClose(error);
436
427
  });
437
428
  }
438
- await attachP;
429
+ this.serializedStateManager.setSnapshot(await attachP);
439
430
  if (!this.closed) {
440
431
  this.handleDeltaConnectionArg({
441
432
  fetchOpsFromStorage: false,
@@ -487,7 +478,7 @@ export class Container extends EventEmitterWithErrorHandling {
487
478
  });
488
479
  };
489
480
  this._containerId = uuid();
490
- this.client = Container.setupClient(this._containerId, this.options, this.clientDetailsOverride);
481
+ this.client = Container.setupClient(this._containerId, options.client, this.clientDetailsOverride);
491
482
  // Create logger for data stores to use
492
483
  const type = this.client.details.type;
493
484
  const interactive = this.client.details.capabilities.interactive;
@@ -593,6 +584,10 @@ export class Container extends EventEmitterWithErrorHandling {
593
584
  const forceEnableSummarizeProtocolTree = this.mc.config.getBoolean("Fluid.Container.summarizeProtocolTree2") ??
594
585
  options.summarizeProtocolTree;
595
586
  this.storageAdapter = new ContainerStorageAdapter(detachedBlobStorage, this.mc.logger, pendingLocalState?.snapshotBlobs, addProtocolSummaryIfMissing, forceEnableSummarizeProtocolTree);
587
+ const offlineLoadEnabled = (this.isInteractiveClient &&
588
+ this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad")) ??
589
+ options.enableOfflineLoad === true;
590
+ this.serializedStateManager = new SerializedStateManager(pendingLocalState, this.subLogger, this.storageAdapter, offlineLoadEnabled);
596
591
  const isDomAvailable = typeof document === "object" &&
597
592
  document !== null &&
598
593
  typeof document.addEventListener === "function" &&
@@ -731,47 +726,32 @@ export class Container extends EventEmitterWithErrorHandling {
731
726
  return this.getPendingLocalStateCore({ notifyImminentClosure: false });
732
727
  }
733
728
  async getPendingLocalStateCore(props) {
734
- return PerformanceEvent.timedExecAsync(this.mc.logger, {
735
- eventName: "getPendingLocalState",
736
- notifyImminentClosure: props.notifyImminentClosure,
737
- savedOpsSize: this.savedOps.length,
738
- clientId: this.clientId,
739
- }, async () => {
740
- if (!this.offlineLoadEnabled) {
741
- throw new UsageError("Can't get pending local state unless offline load is enabled");
742
- }
743
- if (this.closed || this._disposed) {
744
- throw new UsageError("Pending state cannot be retried if the container is closed or disposed");
745
- }
746
- assert(this.attachmentData.state === AttachState.Attached, 0x0d1 /* "Container should be attached before close" */);
747
- assert(this.resolvedUrl !== undefined && this.resolvedUrl.type === "fluid", 0x0d2 /* "resolved url should be valid Fluid url" */);
748
- assert(this.attachmentData.snapshot !== undefined, 0x5d5 /* no base data */);
749
- const pendingRuntimeState = await this.runtime.getPendingLocalState(props);
750
- const pendingState = {
751
- pendingRuntimeState,
752
- baseSnapshot: this.attachmentData.snapshot.tree,
753
- snapshotBlobs: this.attachmentData.snapshot.blobs,
754
- savedOps: this.savedOps,
755
- url: this.resolvedUrl.url,
756
- // no need to save this if there is no pending runtime state
757
- clientId: pendingRuntimeState !== undefined ? this.clientId : undefined,
758
- };
759
- return JSON.stringify(pendingState);
760
- });
729
+ if (this.closed || this._disposed) {
730
+ throw new UsageError("Pending state cannot be retried if the container is closed or disposed");
731
+ }
732
+ assert(this.attachmentData.state === AttachState.Attached, 0x0d1 /* "Container should be attached before close" */);
733
+ assert(this.resolvedUrl !== undefined && this.resolvedUrl.type === "fluid", 0x0d2 /* "resolved url should be valid Fluid url" */);
734
+ const pendingState = await this.serializedStateManager.getPendingLocalStateCore(props, this.clientId, this.runtime, this.resolvedUrl);
735
+ return pendingState;
761
736
  }
762
737
  get attachState() {
763
738
  return this.attachmentData.state;
764
739
  }
765
740
  serialize() {
766
- assert(this.attachState === AttachState.Detached, 0x0d3 /* "Should only be called in detached container" */);
767
- const appSummary = this.runtime.createSummary();
768
- const protocolSummary = this.captureProtocolSummary();
769
- const combinedSummary = combineAppAndProtocolSummary(appSummary, protocolSummary);
741
+ if (this.attachmentData.state === AttachState.Attached || this.closed) {
742
+ throw new UsageError("Container must not be attached or closed.");
743
+ }
744
+ const attachingData = this.attachmentData.state === AttachState.Attaching ? this.attachmentData : undefined;
745
+ const combinedSummary = attachingData?.summary ??
746
+ combineAppAndProtocolSummary(this.runtime.createSummary(), this.captureProtocolSummary());
770
747
  const { tree: snapshot, blobs } = getSnapshotTreeAndBlobsFromSerializedContainer(combinedSummary);
748
+ const pendingRuntimeState = attachingData !== undefined ? this.runtime.getPendingLocalState() : undefined;
749
+ assert(!isPromiseLike(pendingRuntimeState), 0x8e3 /* should not be a promise */);
771
750
  const detachedContainerState = {
772
751
  attached: false,
773
752
  baseSnapshot: snapshot,
774
753
  snapshotBlobs: blobs,
754
+ pendingRuntimeState,
775
755
  hasAttachmentBlobs: !!this.detachedBlobStorage && this.detachedBlobStorage.size > 0,
776
756
  };
777
757
  return JSON.stringify(detachedContainerState);
@@ -904,10 +884,6 @@ export class Container extends EventEmitterWithErrorHandling {
904
884
  }
905
885
  return true;
906
886
  }
907
- async getVersion(version) {
908
- const versions = await this.storageAdapter.getVersions(version, 1);
909
- return versions[0];
910
- }
911
887
  connectToDeltaStream(args) {
912
888
  // All agents need "write" access, including summarizer.
913
889
  if (!this._canReconnect || !this.client.details.capabilities.interactive) {
@@ -952,31 +928,8 @@ export class Container extends EventEmitterWithErrorHandling {
952
928
  };
953
929
  timings.phase2 = performance.now();
954
930
  // Fetch specified snapshot.
955
- const { snapshot, versionId } = pendingLocalState === undefined
956
- ? await this.fetchSnapshot(specifiedVersion)
957
- : { snapshot: pendingLocalState.baseSnapshot, versionId: undefined };
958
- const snapshotTree = isInstanceOfISnapshot(snapshot)
959
- ? snapshot.snapshotTree
960
- : snapshot;
961
- if (pendingLocalState) {
962
- this.attachmentData = {
963
- state: AttachState.Attached,
964
- snapshot: {
965
- tree: pendingLocalState.baseSnapshot,
966
- blobs: pendingLocalState.snapshotBlobs,
967
- },
968
- };
969
- }
970
- else {
971
- assert(snapshotTree !== undefined, 0x237 /* "Snapshot should exist" */);
972
- if (this.offlineLoadEnabled) {
973
- const blobs = await getBlobContentsFromTree(snapshotTree, this.storageAdapter);
974
- this.attachmentData = {
975
- state: AttachState.Attached,
976
- snapshot: { tree: snapshotTree, blobs },
977
- };
978
- }
979
- }
931
+ const { snapshotTree, version } = await this.serializedStateManager.fetchSnapshot(specifiedVersion, this.service?.policies?.supportGetSnapshotApi);
932
+ this._loadedFromVersion = version;
980
933
  const attributes = await this.getDocumentAttributes(this.storageAdapter, snapshotTree);
981
934
  // If we saved ops, we will replay them and don't need DeltaManager to fetch them
982
935
  const sequenceNumber = pendingLocalState?.savedOps[pendingLocalState.savedOps.length - 1]?.sequenceNumber;
@@ -1047,7 +1000,7 @@ export class Container extends EventEmitterWithErrorHandling {
1047
1000
  const codeDetails = this.getCodeDetailsFromQuorum();
1048
1001
  await this.instantiateRuntime(codeDetails, snapshotTree,
1049
1002
  // give runtime a dummy value so it knows we're loading from a stash blob
1050
- pendingLocalState ? pendingLocalState?.pendingRuntimeState ?? {} : undefined, isInstanceOfISnapshot(snapshot) ? snapshot : undefined);
1003
+ pendingLocalState ? pendingLocalState?.pendingRuntimeState ?? {} : undefined, isInstanceOfISnapshot(snapshotTree) ? snapshotTree : undefined);
1051
1004
  // replay saved ops
1052
1005
  if (pendingLocalState) {
1053
1006
  for (const message of pendingLocalState.savedOps) {
@@ -1102,7 +1055,7 @@ export class Container extends EventEmitterWithErrorHandling {
1102
1055
  }, undefined, LogLevel.verbose);
1103
1056
  return {
1104
1057
  sequenceNumber: attributes.sequenceNumber,
1105
- version: versionId,
1058
+ version: version?.id,
1106
1059
  dmLastProcessedSeqNumber: this._deltaManager.lastSequenceNumber,
1107
1060
  dmLastKnownSeqNumber: this._deltaManager.lastKnownSeqNumber,
1108
1061
  };
@@ -1123,7 +1076,7 @@ export class Container extends EventEmitterWithErrorHandling {
1123
1076
  await this.instantiateRuntime(codeDetails, undefined);
1124
1077
  this.setLoaded();
1125
1078
  }
1126
- async rehydrateDetachedFromSnapshot({ attached, baseSnapshot, snapshotBlobs, hasAttachmentBlobs, }) {
1079
+ async rehydrateDetachedFromSnapshot({ baseSnapshot, snapshotBlobs, hasAttachmentBlobs, pendingRuntimeState, }) {
1127
1080
  if (hasAttachmentBlobs) {
1128
1081
  assert(!!this.detachedBlobStorage && this.detachedBlobStorage.size > 0, 0x250 /* "serialized container with attachment blobs must be rehydrated with detached blob storage" */);
1129
1082
  }
@@ -1140,7 +1093,7 @@ export class Container extends EventEmitterWithErrorHandling {
1140
1093
  values: qValues,
1141
1094
  });
1142
1095
  const codeDetails = this.getCodeDetailsFromQuorum();
1143
- await this.instantiateRuntime(codeDetails, snapshotTreeWithBlobContents);
1096
+ await this.instantiateRuntime(codeDetails, snapshotTreeWithBlobContents, pendingRuntimeState);
1144
1097
  this.setLoaded();
1145
1098
  }
1146
1099
  async getDocumentAttributes(storage, tree) {
@@ -1240,10 +1193,9 @@ export class Container extends EventEmitterWithErrorHandling {
1240
1193
  const pkg = getCodeProposal(quorum);
1241
1194
  return pkg;
1242
1195
  }
1243
- static setupClient(containerId, options, clientDetailsOverride) {
1244
- const loaderOptionsClient = structuredClone(options?.client);
1196
+ static setupClient(containerId, loaderOptionsClient, clientDetailsOverride) {
1245
1197
  const client = loaderOptionsClient !== undefined
1246
- ? loaderOptionsClient
1198
+ ? structuredClone(loaderOptionsClient)
1247
1199
  : {
1248
1200
  details: {
1249
1201
  capabilities: { interactive: true },
@@ -1297,10 +1249,10 @@ export class Container extends EventEmitterWithErrorHandling {
1297
1249
  deltaManager.on("cancelEstablishingConnection", (reason) => {
1298
1250
  this.connectionStateHandler.cancelEstablishingConnection(reason);
1299
1251
  });
1300
- deltaManager.on("disconnect", (reason) => {
1252
+ deltaManager.on("disconnect", (text, error) => {
1301
1253
  this.noopHeuristic?.notifyDisconnect();
1302
1254
  if (!this.closed) {
1303
- this.connectionStateHandler.receivedDisconnectEvent(reason);
1255
+ this.connectionStateHandler.receivedDisconnectEvent({ text, error });
1304
1256
  }
1305
1257
  });
1306
1258
  deltaManager.on("throttled", (warning) => {
@@ -1445,14 +1397,12 @@ export class Container extends EventEmitterWithErrorHandling {
1445
1397
  return this._deltaManager.submit(type, contents, batch, metadata, compression, referenceSequenceNumber);
1446
1398
  }
1447
1399
  processRemoteMessage(message) {
1448
- if (this.offlineLoadEnabled) {
1449
- this.savedOps.push(message);
1450
- }
1451
1400
  const local = this.clientId === message.clientId;
1452
1401
  // Allow the protocol handler to process the message
1453
1402
  const result = this.protocolHandler.processMessage(message, local);
1454
1403
  // Forward messages to the loaded runtime for processing
1455
1404
  this.runtime.process(message, local);
1405
+ this.serializedStateManager.addProcessedOp(message);
1456
1406
  // Inactive (not in quorum or not writers) clients don't take part in the minimum sequence number calculation.
1457
1407
  if (this.activeConnection()) {
1458
1408
  if (this.noopHeuristic === undefined) {
@@ -1493,49 +1443,6 @@ export class Container extends EventEmitterWithErrorHandling {
1493
1443
  this.runtime.processSignal(message, local);
1494
1444
  }
1495
1445
  }
1496
- /**
1497
- * Get the most recent snapshot, or a specific version.
1498
- * @param specifiedVersion - The specific version of the snapshot to retrieve
1499
- * @returns The snapshot requested, or the latest snapshot if no version was specified, plus version ID
1500
- */
1501
- async fetchSnapshotTree(specifiedVersion) {
1502
- const version = await this.getVersion(specifiedVersion ?? null);
1503
- if (version === undefined && specifiedVersion !== undefined) {
1504
- // We should have a defined version to load from if specified version requested
1505
- this.mc.logger.sendErrorEvent({
1506
- eventName: "NoVersionFoundWhenSpecified",
1507
- id: specifiedVersion,
1508
- });
1509
- }
1510
- this._loadedFromVersion = version;
1511
- const snapshot = (await this.storageAdapter.getSnapshotTree(version)) ?? undefined;
1512
- if (snapshot === undefined && version !== undefined) {
1513
- this.mc.logger.sendErrorEvent({ eventName: "getSnapshotTreeFailed", id: version.id });
1514
- }
1515
- return { snapshot, versionId: version?.id };
1516
- }
1517
- async fetchSnapshot(specifiedVersion) {
1518
- if (this.mc.config.getBoolean("Fluid.Container.FetchSnapshotUsingGetSnapshotApi") ===
1519
- true &&
1520
- this.service?.policies?.supportGetSnapshotApi === true) {
1521
- const snapshot = await this.storageAdapter.getSnapshot({
1522
- versionId: specifiedVersion,
1523
- });
1524
- const version = {
1525
- id: snapshot.snapshotTree.id ?? "",
1526
- treeId: snapshot.snapshotTree.id ?? "",
1527
- };
1528
- this._loadedFromVersion = version;
1529
- if (snapshot === undefined && specifiedVersion !== undefined) {
1530
- this.mc.logger.sendErrorEvent({
1531
- eventName: "getSnapshotTreeFailed",
1532
- id: version.id,
1533
- });
1534
- }
1535
- return { snapshot, versionId: version.id };
1536
- }
1537
- return this.fetchSnapshotTree(specifiedVersion);
1538
- }
1539
1446
  async instantiateRuntime(codeDetails, snapshotTree, pendingLocalState, snapshot) {
1540
1447
  assert(this._runtime?.disposed !== false, 0x0dd /* "Existing runtime not disposed" */);
1541
1448
  // The relative loader will proxy requests to '/' to the loader itself assuming no non-cache flags
@@ -1601,4 +1508,4 @@ export class Container extends EventEmitterWithErrorHandling {
1601
1508
  }
1602
1509
  }
1603
1510
  }
1604
- //# sourceMappingURL=container.mjs.map
1511
+ //# sourceMappingURL=container.js.map