@fluidframework/container-loader 2.0.0-rc.2.0.1 → 2.0.0-rc.3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/api-report/container-loader.api.md +13 -13
  3. package/dist/attachment.d.ts +6 -9
  4. package/dist/attachment.d.ts.map +1 -1
  5. package/dist/attachment.js +5 -5
  6. package/dist/attachment.js.map +1 -1
  7. package/dist/audience.d.ts +1 -1
  8. package/dist/audience.d.ts.map +1 -1
  9. package/dist/audience.js +4 -4
  10. package/dist/audience.js.map +1 -1
  11. package/dist/catchUpMonitor.d.ts +1 -1
  12. package/dist/catchUpMonitor.d.ts.map +1 -1
  13. package/dist/catchUpMonitor.js +2 -2
  14. package/dist/catchUpMonitor.js.map +1 -1
  15. package/dist/connectionManager.d.ts +4 -4
  16. package/dist/connectionManager.d.ts.map +1 -1
  17. package/dist/connectionManager.js +48 -43
  18. package/dist/connectionManager.js.map +1 -1
  19. package/dist/connectionStateHandler.d.ts +3 -3
  20. package/dist/connectionStateHandler.d.ts.map +1 -1
  21. package/dist/connectionStateHandler.js +27 -27
  22. package/dist/connectionStateHandler.js.map +1 -1
  23. package/dist/container.d.ts +9 -46
  24. package/dist/container.d.ts.map +1 -1
  25. package/dist/container.js +105 -116
  26. package/dist/container.js.map +1 -1
  27. package/dist/containerContext.d.ts +19 -7
  28. package/dist/containerContext.d.ts.map +1 -1
  29. package/dist/containerContext.js +7 -2
  30. package/dist/containerContext.js.map +1 -1
  31. package/dist/containerStorageAdapter.d.ts +3 -3
  32. package/dist/containerStorageAdapter.d.ts.map +1 -1
  33. package/dist/containerStorageAdapter.js +6 -6
  34. package/dist/containerStorageAdapter.js.map +1 -1
  35. package/dist/contracts.d.ts +4 -3
  36. package/dist/contracts.d.ts.map +1 -1
  37. package/dist/contracts.js +2 -2
  38. package/dist/contracts.js.map +1 -1
  39. package/dist/debugLogger.d.ts +2 -1
  40. package/dist/debugLogger.d.ts.map +1 -1
  41. package/dist/debugLogger.js +4 -4
  42. package/dist/debugLogger.js.map +1 -1
  43. package/dist/deltaManager.d.ts +11 -7
  44. package/dist/deltaManager.d.ts.map +1 -1
  45. package/dist/deltaManager.js +53 -50
  46. package/dist/deltaManager.js.map +1 -1
  47. package/dist/deltaQueue.d.ts +1 -1
  48. package/dist/deltaQueue.d.ts.map +1 -1
  49. package/dist/deltaQueue.js +5 -5
  50. package/dist/deltaQueue.js.map +1 -1
  51. package/dist/error.d.ts +3 -2
  52. package/dist/error.d.ts.map +1 -1
  53. package/dist/error.js +5 -5
  54. package/dist/error.js.map +1 -1
  55. package/dist/legacy.d.ts +29 -0
  56. package/dist/loader.d.ts +4 -4
  57. package/dist/loader.d.ts.map +1 -1
  58. package/dist/loader.js +23 -23
  59. package/dist/loader.js.map +1 -1
  60. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -2
  61. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
  62. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +2 -2
  63. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
  64. package/dist/noopHeuristic.d.ts +1 -1
  65. package/dist/noopHeuristic.d.ts.map +1 -1
  66. package/dist/noopHeuristic.js +6 -6
  67. package/dist/noopHeuristic.js.map +1 -1
  68. package/dist/packageVersion.d.ts +1 -1
  69. package/dist/packageVersion.js +1 -1
  70. package/dist/packageVersion.js.map +1 -1
  71. package/dist/protocol.d.ts +1 -1
  72. package/dist/protocol.d.ts.map +1 -1
  73. package/dist/protocol.js +2 -2
  74. package/dist/protocol.js.map +1 -1
  75. package/dist/protocolTreeDocumentStorageService.d.ts +4 -4
  76. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  77. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  78. package/dist/public.d.ts +14 -0
  79. package/dist/quorum.d.ts +1 -1
  80. package/dist/quorum.d.ts.map +1 -1
  81. package/dist/quorum.js +4 -0
  82. package/dist/quorum.js.map +1 -1
  83. package/dist/retriableDocumentStorageService.d.ts +2 -2
  84. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  85. package/dist/retriableDocumentStorageService.js +7 -7
  86. package/dist/retriableDocumentStorageService.js.map +1 -1
  87. package/dist/serializedStateManager.d.ts +86 -16
  88. package/dist/serializedStateManager.d.ts.map +1 -1
  89. package/dist/serializedStateManager.js +182 -82
  90. package/dist/serializedStateManager.js.map +1 -1
  91. package/dist/utils.d.ts +24 -9
  92. package/dist/utils.d.ts.map +1 -1
  93. package/dist/utils.js +82 -25
  94. package/dist/utils.js.map +1 -1
  95. package/internal.d.ts +11 -0
  96. package/legacy.d.ts +11 -0
  97. package/lib/attachment.d.ts +6 -9
  98. package/lib/attachment.d.ts.map +1 -1
  99. package/lib/attachment.js +1 -1
  100. package/lib/attachment.js.map +1 -1
  101. package/lib/audience.d.ts +1 -1
  102. package/lib/audience.d.ts.map +1 -1
  103. package/lib/audience.js +1 -1
  104. package/lib/audience.js.map +1 -1
  105. package/lib/catchUpMonitor.d.ts +1 -1
  106. package/lib/catchUpMonitor.d.ts.map +1 -1
  107. package/lib/catchUpMonitor.js +1 -1
  108. package/lib/catchUpMonitor.js.map +1 -1
  109. package/lib/connectionManager.d.ts +4 -4
  110. package/lib/connectionManager.d.ts.map +1 -1
  111. package/lib/connectionManager.js +11 -6
  112. package/lib/connectionManager.js.map +1 -1
  113. package/lib/connectionStateHandler.d.ts +3 -3
  114. package/lib/connectionStateHandler.d.ts.map +1 -1
  115. package/lib/connectionStateHandler.js +2 -2
  116. package/lib/connectionStateHandler.js.map +1 -1
  117. package/lib/container.d.ts +9 -46
  118. package/lib/container.d.ts.map +1 -1
  119. package/lib/container.js +37 -48
  120. package/lib/container.js.map +1 -1
  121. package/lib/containerContext.d.ts +19 -7
  122. package/lib/containerContext.d.ts.map +1 -1
  123. package/lib/containerContext.js +7 -2
  124. package/lib/containerContext.js.map +1 -1
  125. package/lib/containerStorageAdapter.d.ts +3 -3
  126. package/lib/containerStorageAdapter.d.ts.map +1 -1
  127. package/lib/containerStorageAdapter.js +2 -2
  128. package/lib/containerStorageAdapter.js.map +1 -1
  129. package/lib/contracts.d.ts +4 -3
  130. package/lib/contracts.d.ts.map +1 -1
  131. package/lib/contracts.js +1 -1
  132. package/lib/contracts.js.map +1 -1
  133. package/lib/debugLogger.d.ts +2 -1
  134. package/lib/debugLogger.d.ts.map +1 -1
  135. package/lib/debugLogger.js +1 -1
  136. package/lib/debugLogger.js.map +1 -1
  137. package/lib/deltaManager.d.ts +11 -7
  138. package/lib/deltaManager.d.ts.map +1 -1
  139. package/lib/deltaManager.js +13 -10
  140. package/lib/deltaManager.js.map +1 -1
  141. package/lib/deltaQueue.d.ts +1 -1
  142. package/lib/deltaQueue.d.ts.map +1 -1
  143. package/lib/deltaQueue.js +2 -2
  144. package/lib/deltaQueue.js.map +1 -1
  145. package/lib/error.d.ts +3 -2
  146. package/lib/error.d.ts.map +1 -1
  147. package/lib/error.js +2 -2
  148. package/lib/error.js.map +1 -1
  149. package/lib/legacy.d.ts +29 -0
  150. package/lib/loader.d.ts +4 -4
  151. package/lib/loader.d.ts.map +1 -1
  152. package/lib/loader.js +4 -4
  153. package/lib/loader.js.map +1 -1
  154. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -2
  155. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
  156. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +2 -2
  157. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
  158. package/lib/noopHeuristic.d.ts +1 -1
  159. package/lib/noopHeuristic.d.ts.map +1 -1
  160. package/lib/noopHeuristic.js +2 -2
  161. package/lib/noopHeuristic.js.map +1 -1
  162. package/lib/packageVersion.d.ts +1 -1
  163. package/lib/packageVersion.js +1 -1
  164. package/lib/packageVersion.js.map +1 -1
  165. package/lib/protocol.d.ts +1 -1
  166. package/lib/protocol.d.ts.map +1 -1
  167. package/lib/protocol.js +1 -1
  168. package/lib/protocol.js.map +1 -1
  169. package/lib/protocolTreeDocumentStorageService.d.ts +4 -4
  170. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  171. package/lib/protocolTreeDocumentStorageService.js.map +1 -1
  172. package/lib/public.d.ts +14 -0
  173. package/lib/quorum.d.ts +1 -1
  174. package/lib/quorum.d.ts.map +1 -1
  175. package/lib/quorum.js +4 -0
  176. package/lib/quorum.js.map +1 -1
  177. package/lib/retriableDocumentStorageService.d.ts +2 -2
  178. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  179. package/lib/retriableDocumentStorageService.js +3 -3
  180. package/lib/retriableDocumentStorageService.js.map +1 -1
  181. package/lib/serializedStateManager.d.ts +86 -16
  182. package/lib/serializedStateManager.d.ts.map +1 -1
  183. package/lib/serializedStateManager.js +174 -77
  184. package/lib/serializedStateManager.js.map +1 -1
  185. package/lib/utils.d.ts +24 -9
  186. package/lib/utils.d.ts.map +1 -1
  187. package/lib/utils.js +69 -15
  188. package/lib/utils.js.map +1 -1
  189. package/package.json +37 -58
  190. package/src/attachment.ts +10 -8
  191. package/src/audience.ts +3 -2
  192. package/src/catchUpMonitor.ts +2 -2
  193. package/src/connectionManager.ts +27 -20
  194. package/src/connectionStateHandler.ts +7 -7
  195. package/src/container.ts +90 -143
  196. package/src/containerContext.ts +22 -12
  197. package/src/containerStorageAdapter.ts +7 -6
  198. package/src/contracts.ts +4 -5
  199. package/src/debugLogger.ts +3 -4
  200. package/src/deltaManager.ts +40 -30
  201. package/src/deltaQueue.ts +2 -2
  202. package/src/error.ts +5 -4
  203. package/src/loader.ts +25 -23
  204. package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +4 -4
  205. package/src/noopHeuristic.ts +3 -3
  206. package/src/packageVersion.ts +1 -1
  207. package/src/protocol.ts +2 -2
  208. package/src/protocolTreeDocumentStorageService.ts +4 -1
  209. package/src/quorum.ts +2 -1
  210. package/src/retriableDocumentStorageService.ts +6 -5
  211. package/src/serializedStateManager.ts +299 -111
  212. package/src/utils.ts +103 -24
  213. package/api-extractor-cjs.json +0 -8
  214. package/dist/container-loader-alpha.d.ts +0 -275
  215. package/dist/container-loader-beta.d.ts +0 -101
  216. package/dist/container-loader-public.d.ts +0 -101
  217. package/dist/container-loader-untrimmed.d.ts +0 -331
  218. package/lib/container-loader-alpha.d.ts +0 -275
  219. package/lib/container-loader-beta.d.ts +0 -101
  220. package/lib/container-loader-public.d.ts +0 -101
  221. package/lib/container-loader-untrimmed.d.ts +0 -331
  222. package/lib/test/attachment.spec.js +0 -380
  223. package/lib/test/attachment.spec.js.map +0 -1
  224. package/lib/test/catchUpMonitor.spec.js +0 -88
  225. package/lib/test/catchUpMonitor.spec.js.map +0 -1
  226. package/lib/test/connectionManager.spec.js +0 -201
  227. package/lib/test/connectionManager.spec.js.map +0 -1
  228. package/lib/test/connectionStateHandler.spec.js +0 -555
  229. package/lib/test/connectionStateHandler.spec.js.map +0 -1
  230. package/lib/test/container.spec.js +0 -64
  231. package/lib/test/container.spec.js.map +0 -1
  232. package/lib/test/deltaManager.spec.js +0 -405
  233. package/lib/test/deltaManager.spec.js.map +0 -1
  234. package/lib/test/loader.spec.js +0 -212
  235. package/lib/test/loader.spec.js.map +0 -1
  236. package/lib/test/locationRedirectionTests.spec.js +0 -44
  237. package/lib/test/locationRedirectionTests.spec.js.map +0 -1
  238. package/lib/test/serializedStateManager.spec.js +0 -148
  239. package/lib/test/serializedStateManager.spec.js.map +0 -1
  240. package/lib/test/snapshotConversionTest.spec.js +0 -79
  241. package/lib/test/snapshotConversionTest.spec.js.map +0 -1
  242. package/lib/test/types/validateContainerLoaderPrevious.generated.js +0 -38
  243. package/lib/test/types/validateContainerLoaderPrevious.generated.js.map +0 -1
  244. package/lib/test/utils.spec.js +0 -31
  245. package/lib/test/utils.spec.js.map +0 -1
  246. /package/{dist → lib}/tsdoc-metadata.json +0 -0
package/src/container.ts CHANGED
@@ -3,38 +3,40 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { v4 as uuid } from "uuid";
7
- import { assert, unreachableCase, isPromiseLike } from "@fluidframework/core-utils";
8
6
  import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
9
- import {
10
- IEvent,
11
- ITelemetryBaseProperties,
12
- FluidObject,
13
- LogLevel,
14
- IRequest,
15
- } from "@fluidframework/core-interfaces";
16
7
  import {
17
8
  AttachState,
18
- ContainerWarning,
19
9
  IAudience,
10
+ ICriticalContainerError,
11
+ IDeltaManager,
12
+ ReadOnlyInfo,
13
+ } from "@fluidframework/container-definitions";
14
+ import {
15
+ ContainerWarning,
20
16
  IBatchMessage,
21
17
  ICodeDetailsLoader,
22
18
  IContainer,
23
19
  IContainerEvents,
24
20
  IContainerLoadMode,
25
- ICriticalContainerError,
26
- IDeltaManager,
27
21
  IFluidCodeDetails,
28
- IHostLoader,
22
+ IFluidCodeDetailsComparer,
29
23
  IFluidModuleWithDetails,
30
- IProvideRuntimeFactory,
24
+ IGetPendingLocalStateProps,
25
+ IHostLoader,
31
26
  IProvideFluidCodeDetailsComparer,
32
- IFluidCodeDetailsComparer,
27
+ IProvideRuntimeFactory,
33
28
  IRuntime,
34
- ReadOnlyInfo,
35
29
  isFluidCodeDetails,
36
- IGetPendingLocalStateProps,
37
- } from "@fluidframework/container-definitions";
30
+ } from "@fluidframework/container-definitions/internal";
31
+ import {
32
+ FluidObject,
33
+ IEvent,
34
+ IRequest,
35
+ ITelemetryBaseProperties,
36
+ LogLevel,
37
+ } from "@fluidframework/core-interfaces";
38
+ import { type ISignalEnvelope } from "@fluidframework/core-interfaces/internal";
39
+ import { assert, isPromiseLike, unreachableCase } from "@fluidframework/core-utils/internal";
38
40
  import {
39
41
  IDocumentService,
40
42
  IDocumentServiceFactory,
@@ -43,16 +45,16 @@ import {
43
45
  ISnapshot,
44
46
  IThrottlingWarning,
45
47
  IUrlResolver,
46
- } from "@fluidframework/driver-definitions";
48
+ } from "@fluidframework/driver-definitions/internal";
47
49
  import {
48
- readAndParse,
50
+ MessageType2,
49
51
  OnlineStatus,
50
- isOnline,
51
52
  isCombinedAppAndProtocolSummary,
52
- MessageType2,
53
53
  isInstanceOfISnapshot,
54
+ isOnline,
55
+ readAndParse,
54
56
  runWithRetry,
55
- } from "@fluidframework/driver-utils";
57
+ } from "@fluidframework/driver-utils/internal";
56
58
  import { IQuorumSnapshot } from "@fluidframework/protocol-base";
57
59
  import {
58
60
  IClient,
@@ -73,59 +75,65 @@ import {
73
75
  MessageType,
74
76
  SummaryType,
75
77
  } from "@fluidframework/protocol-definitions";
78
+ import { ITelemetryLoggerExt, type TelemetryEventCategory } from "@fluidframework/telemetry-utils";
76
79
  import {
77
- createChildLogger,
78
80
  EventEmitterWithErrorHandling,
81
+ GenericError,
82
+ IFluidErrorBase,
83
+ MonitoringContext,
79
84
  PerformanceEvent,
80
- raiseConnectedEvent,
85
+ UsageError,
81
86
  connectedEventName,
82
- normalizeError,
83
- MonitoringContext,
87
+ createChildLogger,
84
88
  createChildMonitoringContext,
85
- wrapError,
86
- ITelemetryLoggerExt,
87
89
  formatTick,
88
- GenericError,
89
- UsageError,
90
- IFluidErrorBase,
91
- type TelemetryEventCategory,
92
- } from "@fluidframework/telemetry-utils";
90
+ normalizeError,
91
+ raiseConnectedEvent,
92
+ wrapError,
93
+ } from "@fluidframework/telemetry-utils/internal";
93
94
  import structuredClone from "@ungap/structured-clone";
95
+ import { v4 as uuid } from "uuid";
96
+
97
+ import { AttachProcessProps, AttachmentData, runRetriableAttachProcess } from "./attachment.js";
94
98
  import { Audience } from "./audience.js";
99
+ import { ConnectionManager } from "./connectionManager.js";
100
+ import { ConnectionState } from "./connectionState.js";
101
+ import { IConnectionStateHandler, createConnectionStateHandler } from "./connectionStateHandler.js";
95
102
  import { ContainerContext } from "./containerContext.js";
103
+ import { ContainerStorageAdapter } from "./containerStorageAdapter.js";
96
104
  import {
97
- ReconnectMode,
98
- IConnectionManagerFactoryArgs,
99
- getPackageName,
100
105
  IConnectionDetailsInternal,
106
+ IConnectionManagerFactoryArgs,
101
107
  IConnectionStateChangeReason,
108
+ ReconnectMode,
109
+ getPackageName,
102
110
  } from "./contracts.js";
103
111
  import { DeltaManager, IConnectionArgs } from "./deltaManager.js";
104
112
  import { IDetachedBlobStorage, ILoaderOptions, RelativeLoader } from "./loader.js";
113
+ import { NoopHeuristic } from "./noopHeuristic.js";
105
114
  import { pkgVersion } from "./packageVersion.js";
106
- import { ContainerStorageAdapter, ISerializableBlobContents } from "./containerStorageAdapter.js";
107
- import { IConnectionStateHandler, createConnectionStateHandler } from "./connectionStateHandler.js";
115
+ import {
116
+ IProtocolHandler,
117
+ ProtocolHandler,
118
+ ProtocolHandlerBuilder,
119
+ protocolHandlerShouldProcessSignal,
120
+ } from "./protocol.js";
121
+ import { initQuorumValuesFromCodeDetails } from "./quorum.js";
122
+ import {
123
+ type IPendingContainerState,
124
+ type IPendingDetachedContainerState,
125
+ SerializedStateManager,
126
+ } from "./serializedStateManager.js";
108
127
  import {
109
128
  ISnapshotTreeWithBlobContents,
110
129
  combineAppAndProtocolSummary,
111
- getProtocolSnapshotTree,
112
- getSnapshotTreeAndBlobsFromSerializedContainer,
113
130
  combineSnapshotTreeAndSnapshotBlobs,
114
131
  getDetachedContainerStateFromSerializedContainer,
132
+ getDocumentAttributes,
133
+ getProtocolSnapshotTree,
134
+ getSnapshotTreeAndBlobsFromSerializedContainer,
115
135
  runSingle,
116
136
  } from "./utils.js";
117
- import { initQuorumValuesFromCodeDetails } from "./quorum.js";
118
- import { NoopHeuristic } from "./noopHeuristic.js";
119
- import { ConnectionManager } from "./connectionManager.js";
120
- import { ConnectionState } from "./connectionState.js";
121
- import {
122
- IProtocolHandler,
123
- ProtocolHandler,
124
- ProtocolHandlerBuilder,
125
- protocolHandlerShouldProcessSignal,
126
- } from "./protocol.js";
127
- import { AttachProcessProps, AttachmentData, runRetriableAttachProcess } from "./attachment.js";
128
- import { SerializedStateManager } from "./serializedStateManager.js";
129
137
 
130
138
  const detachedContainerRefSeqNumber = 0;
131
139
 
@@ -335,46 +343,6 @@ export async function ReportIfTooLong(
335
343
  }
336
344
  }
337
345
 
338
- /**
339
- * State saved by a container at close time, to be used to load a new instance
340
- * of the container to the same state
341
- * @internal
342
- */
343
- export interface IPendingContainerState {
344
- attached: true;
345
- pendingRuntimeState: unknown;
346
- /**
347
- * Snapshot from which container initially loaded.
348
- */
349
- baseSnapshot: ISnapshotTree;
350
- /**
351
- * Serializable blobs from the base snapshot. Used to load offline since
352
- * storage is not available.
353
- */
354
- snapshotBlobs: ISerializableBlobContents;
355
- /**
356
- * All ops since base snapshot sequence number up to the latest op
357
- * seen when the container was closed. Used to apply stashed (saved pending)
358
- * ops at the same sequence number at which they were made.
359
- */
360
- savedOps: ISequencedDocumentMessage[];
361
- url: string;
362
- clientId?: string;
363
- }
364
-
365
- /**
366
- * State saved by a container in detached state, to be used to load a new instance
367
- * of the container to the same state (rehydrate)
368
- * @internal
369
- */
370
- export interface IPendingDetachedContainerState {
371
- attached: false;
372
- baseSnapshot: ISnapshotTree;
373
- snapshotBlobs: ISerializableBlobContents;
374
- hasAttachmentBlobs: boolean;
375
- pendingRuntimeState?: unknown;
376
- }
377
-
378
346
  const summarizerClientType = "summarizer";
379
347
 
380
348
  interface IContainerLifecycleEvents extends IEvent {
@@ -1188,17 +1156,16 @@ export class Container
1188
1156
  this.captureProtocolSummary(),
1189
1157
  );
1190
1158
 
1191
- const { tree: snapshot, blobs } =
1159
+ const { baseSnapshot, snapshotBlobs } =
1192
1160
  getSnapshotTreeAndBlobsFromSerializedContainer(combinedSummary);
1193
-
1194
1161
  const pendingRuntimeState =
1195
1162
  attachingData !== undefined ? this.runtime.getPendingLocalState() : undefined;
1196
1163
  assert(!isPromiseLike(pendingRuntimeState), 0x8e3 /* should not be a promise */);
1197
1164
 
1198
1165
  const detachedContainerState: IPendingDetachedContainerState = {
1199
1166
  attached: false,
1200
- baseSnapshot: snapshot,
1201
- snapshotBlobs: blobs,
1167
+ baseSnapshot,
1168
+ snapshotBlobs,
1202
1169
  pendingRuntimeState,
1203
1170
  hasAttachmentBlobs: !!this.detachedBlobStorage && this.detachedBlobStorage.size > 0,
1204
1171
  };
@@ -1314,8 +1281,8 @@ export class Container
1314
1281
  throw normalizeErrorAndClose(error);
1315
1282
  });
1316
1283
  }
1317
-
1318
- this.serializedStateManager.setSnapshot(await attachP);
1284
+ const snapshotWithBlobs = await attachP;
1285
+ this.serializedStateManager.setInitialSnapshot(snapshotWithBlobs);
1319
1286
  if (!this.closed) {
1320
1287
  this.handleDeltaConnectionArg(
1321
1288
  {
@@ -1578,23 +1545,25 @@ export class Container
1578
1545
  };
1579
1546
 
1580
1547
  timings.phase2 = performance.now();
1548
+
1549
+ const supportGetSnapshotApi: boolean =
1550
+ this.mc.config.getBoolean("Fluid.Container.UseLoadingGroupIdForSnapshotFetch") ===
1551
+ true && this.service?.policies?.supportGetSnapshotApi === true;
1581
1552
  // Fetch specified snapshot.
1582
- const { snapshotTree, version } = await this.serializedStateManager.fetchSnapshot(
1553
+ const { baseSnapshot, version } = await this.serializedStateManager.fetchSnapshot(
1583
1554
  specifiedVersion,
1584
- this.service?.policies?.supportGetSnapshotApi,
1555
+ supportGetSnapshotApi,
1585
1556
  );
1586
1557
  this._loadedFromVersion = version;
1587
- const attributes: IDocumentAttributes = await this.getDocumentAttributes(
1558
+ const attributes: IDocumentAttributes = await getDocumentAttributes(
1588
1559
  this.storageAdapter,
1589
- snapshotTree,
1560
+ baseSnapshot,
1590
1561
  );
1591
1562
 
1592
1563
  // If we saved ops, we will replay them and don't need DeltaManager to fetch them
1593
- const sequenceNumber =
1594
- pendingLocalState?.savedOps[pendingLocalState.savedOps.length - 1]?.sequenceNumber;
1595
- const dmAttributes =
1596
- sequenceNumber !== undefined ? { ...attributes, sequenceNumber } : attributes;
1597
-
1564
+ const lastProcessedSequenceNumber =
1565
+ pendingLocalState?.savedOps[pendingLocalState.savedOps.length - 1]?.sequenceNumber ??
1566
+ attributes.sequenceNumber;
1598
1567
  let opsBeforeReturnP: Promise<void> | undefined;
1599
1568
 
1600
1569
  if (loadMode.pauseAfterLoad === true) {
@@ -1607,7 +1576,7 @@ export class Container
1607
1576
  // Note: It is possible that we think the latest snapshot is newer than the specified sequence number
1608
1577
  // due to saved ops that may be replayed after the snapshot.
1609
1578
  // https://dev.azure.com/fluidframework/internal/_workitems/edit/5055
1610
- if (dmAttributes.sequenceNumber > loadToSequenceNumber) {
1579
+ if (lastProcessedSequenceNumber > loadToSequenceNumber) {
1611
1580
  throw new Error(
1612
1581
  "Cannot satisfy request to pause the container at the specified sequence number. Most recent snapshot is newer than the specified sequence number.",
1613
1582
  );
@@ -1655,16 +1624,18 @@ export class Container
1655
1624
  // Start prefetch, but not set opsBeforeReturnP - boot is not blocked by it!
1656
1625
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
1657
1626
  this.attachDeltaManagerOpHandler(
1658
- dmAttributes,
1627
+ attributes,
1659
1628
  loadMode.deltaConnection !== "none" ? "all" : "none",
1629
+ lastProcessedSequenceNumber,
1660
1630
  );
1661
1631
  break;
1662
1632
  case "sequenceNumber":
1663
1633
  case "cached":
1664
1634
  case "all":
1665
1635
  opsBeforeReturnP = this.attachDeltaManagerOpHandler(
1666
- dmAttributes,
1636
+ attributes,
1667
1637
  loadMode.opsBeforeReturn,
1638
+ lastProcessedSequenceNumber,
1668
1639
  );
1669
1640
  break;
1670
1641
  default:
@@ -1676,17 +1647,17 @@ export class Container
1676
1647
  await this.initializeProtocolStateFromSnapshot(
1677
1648
  attributes,
1678
1649
  this.storageAdapter,
1679
- snapshotTree,
1650
+ baseSnapshot,
1680
1651
  );
1681
1652
 
1682
1653
  timings.phase3 = performance.now();
1683
1654
  const codeDetails = this.getCodeDetailsFromQuorum();
1684
1655
  await this.instantiateRuntime(
1685
1656
  codeDetails,
1686
- snapshotTree,
1657
+ baseSnapshot,
1687
1658
  // give runtime a dummy value so it knows we're loading from a stash blob
1688
1659
  pendingLocalState ? pendingLocalState?.pendingRuntimeState ?? {} : undefined,
1689
- isInstanceOfISnapshot(snapshotTree) ? snapshotTree : undefined,
1660
+ isInstanceOfISnapshot(baseSnapshot) ? baseSnapshot : undefined,
1690
1661
  );
1691
1662
 
1692
1663
  // replay saved ops
@@ -1814,7 +1785,7 @@ export class Container
1814
1785
  const snapshotTreeWithBlobContents: ISnapshotTreeWithBlobContents =
1815
1786
  combineSnapshotTreeAndSnapshotBlobs(baseSnapshot, snapshotBlobs);
1816
1787
  this.storageAdapter.loadSnapshotFromSnapshotBlobs(snapshotBlobs);
1817
- const attributes = await this.getDocumentAttributes(
1788
+ const attributes = await getDocumentAttributes(
1818
1789
  this.storageAdapter,
1819
1790
  snapshotTreeWithBlobContents,
1820
1791
  );
@@ -1846,28 +1817,6 @@ export class Container
1846
1817
  this.setLoaded();
1847
1818
  }
1848
1819
 
1849
- private async getDocumentAttributes(
1850
- storage: IDocumentStorageService,
1851
- tree: ISnapshotTree | undefined,
1852
- ): Promise<IDocumentAttributes> {
1853
- if (tree === undefined) {
1854
- return {
1855
- minimumSequenceNumber: 0,
1856
- sequenceNumber: 0,
1857
- };
1858
- }
1859
-
1860
- // Backward compatibility: old docs would have ".attributes" instead of "attributes"
1861
- const attributesHash =
1862
- ".protocol" in tree.trees
1863
- ? tree.trees[".protocol"].blobs.attributes
1864
- : tree.blobs[".attributes"];
1865
-
1866
- const attributes = await readAndParse<IDocumentAttributes>(storage, attributesHash);
1867
-
1868
- return attributes;
1869
- }
1870
-
1871
1820
  private async initializeProtocolStateFromSnapshot(
1872
1821
  attributes: IDocumentAttributes,
1873
1822
  storage: IDocumentStorageService,
@@ -2107,6 +2056,7 @@ export class Container
2107
2056
  private async attachDeltaManagerOpHandler(
2108
2057
  attributes: IDocumentAttributes,
2109
2058
  prefetchType?: "sequenceNumber" | "cached" | "all" | "none",
2059
+ lastProcessedSequenceNumber?: number,
2110
2060
  ) {
2111
2061
  return this._deltaManager.attachOpHandler(
2112
2062
  attributes.minimumSequenceNumber,
@@ -2118,6 +2068,7 @@ export class Container
2118
2068
  },
2119
2069
  },
2120
2070
  prefetchType,
2071
+ lastProcessedSequenceNumber,
2121
2072
  );
2122
2073
  }
2123
2074
 
@@ -2341,7 +2292,8 @@ export class Container
2341
2292
  this.emit("op", message);
2342
2293
  }
2343
2294
 
2344
- private submitSignal(content: any, targetClientId?: string) {
2295
+ // unknown should be removed once `@alpha` tag is removed from IContainerContext
2296
+ private submitSignal(content: unknown | ISignalEnvelope, targetClientId?: string) {
2345
2297
  this._deltaManager.submitSignal(JSON.stringify(content), targetClientId);
2346
2298
  }
2347
2299
 
@@ -2389,10 +2341,6 @@ export class Container
2389
2341
  throw new Error(packageNotFactoryError);
2390
2342
  }
2391
2343
 
2392
- const getSpecifiedCodeDetails = () =>
2393
- (this.protocolHandler.quorum.get("code") ??
2394
- this.protocolHandler.quorum.get("code2")) as IFluidCodeDetails | undefined;
2395
-
2396
2344
  const existing = snapshotTree !== undefined;
2397
2345
 
2398
2346
  const context = new ContainerContext(
@@ -2420,7 +2368,6 @@ export class Container
2420
2368
  () => this.clientId,
2421
2369
  () => this.attachState,
2422
2370
  () => this.connected,
2423
- getSpecifiedCodeDetails,
2424
2371
  this._deltaManager.clientDetails,
2425
2372
  existing,
2426
2373
  this.subLogger,
@@ -3,30 +3,32 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
7
6
  import {
7
+ AttachState,
8
8
  IAudience,
9
- IContainerContext,
9
+ ICriticalContainerError,
10
10
  IDeltaManager,
11
+ } from "@fluidframework/container-definitions";
12
+ import {
13
+ IBatchMessage,
14
+ IContainerContext,
11
15
  ILoader,
12
- ICriticalContainerError,
13
- AttachState,
14
16
  ILoaderOptions,
15
- IFluidCodeDetails,
16
- IBatchMessage,
17
- } from "@fluidframework/container-definitions";
18
- import { FluidObject } from "@fluidframework/core-interfaces";
19
- import { IDocumentStorageService, ISnapshot } from "@fluidframework/driver-definitions";
17
+ } from "@fluidframework/container-definitions/internal";
18
+ import { type FluidObject } from "@fluidframework/core-interfaces";
19
+ import { type ISignalEnvelope } from "@fluidframework/core-interfaces/internal";
20
+ import { IDocumentStorageService, ISnapshot } from "@fluidframework/driver-definitions/internal";
20
21
  import {
21
22
  IClientDetails,
22
23
  IDocumentMessage,
23
24
  IQuorumClients,
24
25
  ISequencedDocumentMessage,
25
26
  ISnapshotTree,
27
+ ISummaryContent,
26
28
  IVersion,
27
29
  MessageType,
28
- ISummaryContent,
29
30
  } from "@fluidframework/protocol-definitions";
31
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
30
32
 
31
33
  /**
32
34
  * {@inheritDoc @fluidframework/container-definitions#IContainerContext}
@@ -85,7 +87,16 @@ export class ContainerContext implements IContainerContext {
85
87
  batch: IBatchMessage[],
86
88
  referenceSequenceNumber?: number,
87
89
  ) => number,
88
- public readonly submitSignalFn: (content: any, targetClientId?: string) => void,
90
+
91
+ /**
92
+ * `unknown` should be removed once `@alpha` tag is removed from IContainerContext
93
+ * @see {@link https://dev.azure.com/fluidframework/internal/_workitems/edit/7462}
94
+ * Any changes to submitSignalFn `content` should be checked internally by temporarily changing IContainerContext and removing all `unknown`s
95
+ */
96
+ public readonly submitSignalFn: (
97
+ content: unknown | ISignalEnvelope,
98
+ targetClientId?: string,
99
+ ) => void,
89
100
  public readonly disposeFn: (error?: ICriticalContainerError) => void,
90
101
  public readonly closeFn: (error?: ICriticalContainerError) => void,
91
102
  public readonly updateDirtyContainerState: (dirty: boolean) => void,
@@ -94,7 +105,6 @@ export class ContainerContext implements IContainerContext {
94
105
  private readonly _getClientId: () => string | undefined,
95
106
  private readonly _getAttachState: () => AttachState,
96
107
  private readonly _getConnected: () => boolean,
97
- public readonly getSpecifiedCodeDetails: () => IFluidCodeDetails | undefined,
98
108
  public readonly clientDetails: IClientDetails,
99
109
  public readonly existing: boolean,
100
110
  public readonly taggedLogger: ITelemetryLoggerExt,
@@ -3,11 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IDisposable } from "@fluidframework/core-interfaces";
7
- import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
8
6
  import { bufferToString, stringToBuffer } from "@fluid-internal/client-utils";
9
- import { assert } from "@fluidframework/core-utils";
10
- import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions";
7
+ import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions/internal";
8
+ import { IDisposable } from "@fluidframework/core-interfaces";
9
+ import { assert } from "@fluidframework/core-utils/internal";
11
10
  import {
12
11
  FetchSource,
13
12
  IDocumentService,
@@ -16,8 +15,8 @@ import {
16
15
  ISnapshot,
17
16
  ISnapshotFetchOptions,
18
17
  ISummaryContext,
19
- } from "@fluidframework/driver-definitions";
20
- import { UsageError } from "@fluidframework/driver-utils";
18
+ } from "@fluidframework/driver-definitions/internal";
19
+ import { UsageError } from "@fluidframework/driver-utils/internal";
21
20
  import {
22
21
  ICreateBlobResponse,
23
22
  ISnapshotTree,
@@ -25,6 +24,8 @@ import {
25
24
  ISummaryTree,
26
25
  IVersion,
27
26
  } from "@fluidframework/protocol-definitions";
27
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
28
+
28
29
  import { IDetachedBlobStorage } from "./loader.js";
29
30
  import { ProtocolTreeStorageService } from "./protocolTreeDocumentStorageService.js";
30
31
  import { RetriableDocumentStorageService } from "./retriableDocumentStorageService.js";
package/src/contracts.ts CHANGED
@@ -3,15 +3,15 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IErrorBase, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
7
6
  import {
8
7
  IConnectionDetails,
9
8
  ICriticalContainerError,
10
9
  IDeltaQueue,
11
- IFluidCodeDetails,
12
- isFluidPackage,
13
10
  ReadOnlyInfo,
14
11
  } from "@fluidframework/container-definitions";
12
+ import { IFluidCodeDetails, isFluidPackage } from "@fluidframework/container-definitions/internal";
13
+ import { IErrorBase, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
14
+ import { IContainerPackageInfo } from "@fluidframework/driver-definitions/internal";
15
15
  import {
16
16
  ConnectionMode,
17
17
  IClientConfiguration,
@@ -21,7 +21,6 @@ import {
21
21
  ISignalClient,
22
22
  ISignalMessage,
23
23
  } from "@fluidframework/protocol-definitions";
24
- import { IContainerPackageInfo } from "@fluidframework/driver-definitions";
25
24
 
26
25
  export enum ReconnectMode {
27
26
  Never = "Never",
@@ -100,7 +99,7 @@ export interface IConnectionManager {
100
99
  * Submits signal to relay service.
101
100
  * Called only when active connection is present.
102
101
  */
103
- submitSignal(content: any, targetClientId?: string): void;
102
+ submitSignal: (content: string, targetClientId?: string) => void;
104
103
 
105
104
  /**
106
105
  * Submits messages to relay service.
@@ -3,20 +3,19 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { performance } from "@fluid-internal/client-utils";
6
7
  import {
7
8
  ITelemetryBaseEvent,
8
9
  ITelemetryBaseLogger,
9
10
  ITelemetryBaseProperties,
10
11
  } from "@fluidframework/core-interfaces";
11
- import { performance } from "@fluid-internal/client-utils";
12
-
12
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
13
13
  import {
14
- ITelemetryLoggerExt,
15
14
  ITelemetryLoggerPropertyBags,
16
15
  createMultiSinkLogger,
17
16
  eventNamespaceSeparator,
18
17
  formatTick,
19
- } from "@fluidframework/telemetry-utils";
18
+ } from "@fluidframework/telemetry-utils/internal";
20
19
 
21
20
  // This import style is necessary to ensure the emitted JS code works in both CJS and ESM.
22
21
  import debugPkg from "debug";