@fluidframework/container-loader 2.0.0-dev-rc.5.0.0.270987 → 2.0.0-dev-rc.5.0.0.271262

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 (44) hide show
  1. package/dist/container.d.ts +1 -1
  2. package/dist/container.d.ts.map +1 -1
  3. package/dist/container.js +7 -7
  4. package/dist/container.js.map +1 -1
  5. package/dist/containerStorageAdapter.d.ts +2 -2
  6. package/dist/containerStorageAdapter.d.ts.map +1 -1
  7. package/dist/containerStorageAdapter.js +15 -8
  8. package/dist/containerStorageAdapter.js.map +1 -1
  9. package/dist/packageVersion.d.ts +1 -1
  10. package/dist/packageVersion.js +1 -1
  11. package/dist/packageVersion.js.map +1 -1
  12. package/dist/protocolTreeDocumentStorageService.d.ts +8 -1
  13. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  14. package/dist/protocolTreeDocumentStorageService.js +12 -2
  15. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  16. package/dist/serializedStateManager.d.ts +4 -6
  17. package/dist/serializedStateManager.d.ts.map +1 -1
  18. package/dist/serializedStateManager.js +7 -15
  19. package/dist/serializedStateManager.js.map +1 -1
  20. package/lib/container.d.ts +1 -1
  21. package/lib/container.d.ts.map +1 -1
  22. package/lib/container.js +7 -7
  23. package/lib/container.js.map +1 -1
  24. package/lib/containerStorageAdapter.d.ts +2 -2
  25. package/lib/containerStorageAdapter.d.ts.map +1 -1
  26. package/lib/containerStorageAdapter.js +15 -8
  27. package/lib/containerStorageAdapter.js.map +1 -1
  28. package/lib/packageVersion.d.ts +1 -1
  29. package/lib/packageVersion.js +1 -1
  30. package/lib/packageVersion.js.map +1 -1
  31. package/lib/protocolTreeDocumentStorageService.d.ts +8 -1
  32. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  33. package/lib/protocolTreeDocumentStorageService.js +12 -2
  34. package/lib/protocolTreeDocumentStorageService.js.map +1 -1
  35. package/lib/serializedStateManager.d.ts +4 -6
  36. package/lib/serializedStateManager.d.ts.map +1 -1
  37. package/lib/serializedStateManager.js +7 -15
  38. package/lib/serializedStateManager.js.map +1 -1
  39. package/package.json +11 -11
  40. package/src/container.ts +8 -13
  41. package/src/containerStorageAdapter.ts +19 -12
  42. package/src/packageVersion.ts +1 -1
  43. package/src/protocolTreeDocumentStorageService.ts +13 -4
  44. package/src/serializedStateManager.ts +5 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/container-loader",
3
- "version": "2.0.0-dev-rc.5.0.0.270987",
3
+ "version": "2.0.0-dev-rc.5.0.0.271262",
4
4
  "description": "Fluid container loader",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -117,13 +117,13 @@
117
117
  "temp-directory": "nyc/.nyc_output"
118
118
  },
119
119
  "dependencies": {
120
- "@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.270987",
121
- "@fluidframework/container-definitions": "2.0.0-dev-rc.5.0.0.270987",
122
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.270987",
123
- "@fluidframework/core-utils": "2.0.0-dev-rc.5.0.0.270987",
124
- "@fluidframework/driver-definitions": "2.0.0-dev-rc.5.0.0.270987",
125
- "@fluidframework/driver-utils": "2.0.0-dev-rc.5.0.0.270987",
126
- "@fluidframework/telemetry-utils": "2.0.0-dev-rc.5.0.0.270987",
120
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.271262",
121
+ "@fluidframework/container-definitions": "2.0.0-dev-rc.5.0.0.271262",
122
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.271262",
123
+ "@fluidframework/core-utils": "2.0.0-dev-rc.5.0.0.271262",
124
+ "@fluidframework/driver-definitions": "2.0.0-dev-rc.5.0.0.271262",
125
+ "@fluidframework/driver-utils": "2.0.0-dev-rc.5.0.0.271262",
126
+ "@fluidframework/telemetry-utils": "2.0.0-dev-rc.5.0.0.271262",
127
127
  "@types/events_pkg": "npm:@types/events@^3.0.0",
128
128
  "@ungap/structured-clone": "^1.2.0",
129
129
  "debug": "^4.3.4",
@@ -134,9 +134,9 @@
134
134
  "devDependencies": {
135
135
  "@arethetypeswrong/cli": "^0.15.2",
136
136
  "@biomejs/biome": "^1.7.3",
137
- "@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.270987",
138
- "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.270987",
139
- "@fluid-private/test-loader-utils": "2.0.0-dev-rc.5.0.0.270987",
137
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.271262",
138
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.271262",
139
+ "@fluid-private/test-loader-utils": "2.0.0-dev-rc.5.0.0.271262",
140
140
  "@fluid-tools/build-cli": "^0.39.0",
141
141
  "@fluidframework/build-common": "^2.0.3",
142
142
  "@fluidframework/build-tools": "^0.39.0",
package/src/container.ts CHANGED
@@ -678,7 +678,7 @@ export class Container
678
678
  return this.deltaManager.clientDetails.capabilities.interactive;
679
679
  }
680
680
 
681
- private get supportGetSnapshotApi(): boolean {
681
+ private supportGetSnapshotApi(): boolean {
682
682
  const supportGetSnapshotApi: boolean =
683
683
  this.mc.config.getBoolean("Fluid.Container.UseLoadingGroupIdForSnapshotFetch2") ===
684
684
  true && this.service?.policies?.supportGetSnapshotApi === true;
@@ -965,9 +965,9 @@ export class Container
965
965
  ? summaryTree
966
966
  : combineAppAndProtocolSummary(summaryTree, this.captureProtocolSummary());
967
967
 
968
- // Whether the combined summary tree has been forced on by either the loader option or the monitoring context.
968
+ // Whether the combined summary tree has been forced on by either the loader option or the monitoring context or supportedFeatures flag by the service.
969
969
  // Even if not forced on via this flag, combined summaries may still be enabled by service policy.
970
- const forceEnableSummarizeProtocolTree =
970
+ const shouldSummarizeProtocolTree =
971
971
  this.mc.config.getBoolean("Fluid.Container.summarizeProtocolTree2") ??
972
972
  options.summarizeProtocolTree;
973
973
 
@@ -977,7 +977,7 @@ export class Container
977
977
  pendingLocalState?.snapshotBlobs,
978
978
  pendingLocalState?.loadedGroupIdSnapshots,
979
979
  addProtocolSummaryIfMissing,
980
- forceEnableSummarizeProtocolTree,
980
+ shouldSummarizeProtocolTree,
981
981
  );
982
982
 
983
983
  const offlineLoadEnabled =
@@ -991,6 +991,7 @@ export class Container
991
991
  offlineLoadEnabled,
992
992
  this,
993
993
  () => this._deltaManager.connectionManager.shouldJoinWrite(),
994
+ () => this.supportGetSnapshotApi(),
994
995
  );
995
996
 
996
997
  const isDomAvailable =
@@ -1354,11 +1355,7 @@ export class Container
1354
1355
 
1355
1356
  // If offline load is enabled, attachP will return the attach summary (in Snapshot format) so we can initialize SerializedStateManager
1356
1357
  const snapshotWithBlobs = await attachP;
1357
- this.serializedStateManager.setInitialSnapshot(
1358
- snapshotWithBlobs,
1359
- this.supportGetSnapshotApi,
1360
- );
1361
-
1358
+ this.serializedStateManager.setInitialSnapshot(snapshotWithBlobs);
1362
1359
  if (!this.closed) {
1363
1360
  this.detachedBlobStorage.dispose?.();
1364
1361
  this.handleDeltaConnectionArg(attachProps?.deltaConnection, {
@@ -1626,10 +1623,8 @@ export class Container
1626
1623
  timings.phase2 = performance.now();
1627
1624
 
1628
1625
  // Fetch specified snapshot.
1629
- const { baseSnapshot, version } = await this.serializedStateManager.fetchSnapshot(
1630
- specifiedVersion,
1631
- this.supportGetSnapshotApi,
1632
- );
1626
+ const { baseSnapshot, version } =
1627
+ await this.serializedStateManager.fetchSnapshot(specifiedVersion);
1633
1628
  const baseSnapshotTree: ISnapshotTree | undefined = getSnapshotTree(baseSnapshot);
1634
1629
  this._loadedFromVersion = version;
1635
1630
  const attributes: IDocumentAttributes = await getDocumentAttributes(
@@ -74,7 +74,7 @@ export class ContainerStorageAdapter
74
74
  * @param loadingGroupIdSnapshotsFromPendingState - in offline mode, any loading group snapshots we've downloaded from the service that were stored in the pending state
75
75
  * @param addProtocolSummaryIfMissing - a callback to permit the container to inspect the summary we're about to
76
76
  * upload, and fix it up with a protocol tree if needed
77
- * @param forceEnableSummarizeProtocolTree - Enforce uploading a protocol summary regardless of the service's policy
77
+ * @param shouldSummarizeProtocolTree - Enforce uploading a protocol summary regardless of the service's policy.
78
78
  */
79
79
  public constructor(
80
80
  // eslint-disable-next-line import/no-deprecated
@@ -86,10 +86,10 @@ export class ContainerStorageAdapter
86
86
  private readonly blobContents: { [id: string]: ArrayBufferLike | string } = {},
87
87
  private loadingGroupIdSnapshotsFromPendingState: Record<string, ISnapshotInfo> | undefined,
88
88
  private readonly addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree,
89
- forceEnableSummarizeProtocolTree: boolean | undefined,
89
+ shouldSummarizeProtocolTree: boolean | undefined,
90
90
  ) {
91
91
  this._storageService = new BlobOnlyStorage(detachedBlobStorage, logger);
92
- this._summarizeProtocolTree = forceEnableSummarizeProtocolTree;
92
+ this._summarizeProtocolTree = shouldSummarizeProtocolTree;
93
93
  }
94
94
 
95
95
  disposed: boolean = false;
@@ -109,15 +109,22 @@ export class ContainerStorageAdapter
109
109
  this.logger,
110
110
  ));
111
111
 
112
- this._summarizeProtocolTree =
113
- this._summarizeProtocolTree ?? service.policies?.summarizeProtocolTree;
114
- if (this.summarizeProtocolTree) {
115
- this.logger.sendTelemetryEvent({ eventName: "summarizeProtocolTreeEnabled" });
116
- this._storageService = new ProtocolTreeStorageService(
117
- retriableStorage,
118
- this.addProtocolSummaryIfMissing,
119
- );
120
- }
112
+ // A storage service wrapper which intercept calls to uploadSummaryWithContext and ensure they include
113
+ // the protocol summary, provided single-commit summary is enabled.
114
+ this._storageService = new ProtocolTreeStorageService(
115
+ retriableStorage,
116
+ (...props) => {
117
+ this.logger.sendTelemetryEvent({ eventName: "summarizeProtocolTreeEnabled" });
118
+ return this.addProtocolSummaryIfMissing(...props);
119
+ },
120
+ // A callback to ensure we fetch the most updated value of service.policies.summarizeProtocolTree, which could be set
121
+ // based on the response received from the service after connection is established.
122
+ () => {
123
+ this._summarizeProtocolTree =
124
+ this._summarizeProtocolTree ?? service.policies?.summarizeProtocolTree ?? false;
125
+ return this._summarizeProtocolTree;
126
+ },
127
+ );
121
128
  }
122
129
 
123
130
  public loadSnapshotFromSnapshotBlobs(snapshotBlobs: ISerializableBlobContents) {
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/container-loader";
9
- export const pkgVersion = "2.0.0-dev-rc.5.0.0.270987";
9
+ export const pkgVersion = "2.0.0-dev-rc.5.0.0.271262";
@@ -15,9 +15,16 @@ import {
15
15
  * the protocol summary, using the provided callback to add it if necessary.
16
16
  */
17
17
  export class ProtocolTreeStorageService implements IDocumentStorageService, IDisposable {
18
+ /**
19
+ *
20
+ * @param internalStorageService - Document storage service responsible to make api calls to the storage.
21
+ * @param addProtocolSummaryIfMissing - Function to add protocol summary tree to the summary. Used in scenarios where single-commit summaries are used.
22
+ * @param shouldSummarizeProtocolTree - Callback function to learn about the service preference on whether single-commit summaries are enabled.
23
+ */
18
24
  constructor(
19
25
  private readonly internalStorageService: IDocumentStorageService & IDisposable,
20
26
  private readonly addProtocolSummaryIfMissing: (summaryTree: ISummaryTree) => ISummaryTree,
27
+ private readonly shouldSummarizeProtocolTree: () => boolean,
21
28
  ) {
22
29
  this.getSnapshotTree = internalStorageService.getSnapshotTree.bind(internalStorageService);
23
30
  this.getSnapshot = internalStorageService.getSnapshot?.bind(internalStorageService);
@@ -46,9 +53,11 @@ export class ProtocolTreeStorageService implements IDocumentStorageService, IDis
46
53
  summary: ISummaryTree,
47
54
  context: ISummaryContext,
48
55
  ): Promise<string> {
49
- return this.internalStorageService.uploadSummaryWithContext(
50
- this.addProtocolSummaryIfMissing(summary),
51
- context,
52
- );
56
+ return this.shouldSummarizeProtocolTree()
57
+ ? this.internalStorageService.uploadSummaryWithContext(
58
+ this.addProtocolSummaryIfMissing(summary),
59
+ context,
60
+ )
61
+ : this.internalStorageService.uploadSummaryWithContext(summary, context);
53
62
  }
54
63
  }
@@ -131,19 +131,6 @@ export class SerializedStateManager {
131
131
  private latestSnapshot: ISnapshotInfo | undefined;
132
132
  private refreshSnapshotP: Promise<void> | undefined;
133
133
  private readonly lastSavedOpSequenceNumber: number = 0;
134
- private _supportGetSnapshotApi: boolean | undefined;
135
-
136
- private set supportGetSnapshotApi(value: boolean | undefined) {
137
- assert(
138
- this._supportGetSnapshotApi === undefined,
139
- "supportGetSnapshotApi should be declared just once",
140
- );
141
- this._supportGetSnapshotApi = value;
142
- }
143
-
144
- private get supportGetSnapshotApi(): boolean | undefined {
145
- return this._supportGetSnapshotApi;
146
- }
147
134
 
148
135
  /**
149
136
  * @param pendingLocalState - The pendingLocalState being rehydrated, if any (undefined when loading directly from storage)
@@ -160,6 +147,7 @@ export class SerializedStateManager {
160
147
  private readonly _offlineLoadEnabled: boolean,
161
148
  containerEvent: IEventProvider<ISerializerEvent>,
162
149
  private readonly containerDirty: () => boolean,
150
+ private readonly supportGetSnapshotApi: () => boolean,
163
151
  ) {
164
152
  this.mc = createChildMonitoringContext({
165
153
  logger: subLogger,
@@ -208,16 +196,12 @@ export class SerializedStateManager {
208
196
  * @param supportGetSnapshotApi - a boolean indicating whether to use the fetchISnapshot or fetchISnapshotTree.
209
197
  * @returns The snapshot to boot the container from
210
198
  */
211
- public async fetchSnapshot(
212
- specifiedVersion: string | undefined,
213
- supportGetSnapshotApi: boolean,
214
- ) {
215
- this.supportGetSnapshotApi = supportGetSnapshotApi;
199
+ public async fetchSnapshot(specifiedVersion: string | undefined) {
216
200
  if (this.pendingLocalState === undefined) {
217
201
  const { baseSnapshot, version } = await getSnapshot(
218
202
  this.mc,
219
203
  this.storageAdapter,
220
- this.supportGetSnapshotApi,
204
+ this.supportGetSnapshotApi(),
221
205
  specifiedVersion,
222
206
  );
223
207
  const baseSnapshotTree: ISnapshotTree | undefined = getSnapshotTree(baseSnapshot);
@@ -252,7 +236,7 @@ export class SerializedStateManager {
252
236
  this.mc.config.getBoolean("Fluid.Container.enableOfflineSnapshotRefresh") === true
253
237
  ) {
254
238
  // Don't block on the refresh snapshot call - it is for the next time we serialize, not booting this incarnation
255
- this.refreshSnapshotP = this.refreshLatestSnapshot(this.supportGetSnapshotApi);
239
+ this.refreshSnapshotP = this.refreshLatestSnapshot(this.supportGetSnapshotApi());
256
240
  this.refreshSnapshotP.catch((e) => {
257
241
  this.mc.logger.sendErrorEvent({
258
242
  eventName: "RefreshLatestSnapshotFailed",
@@ -370,11 +354,7 @@ export class SerializedStateManager {
370
354
  * base snapshot when attaching.
371
355
  * @param snapshot - snapshot and blobs collected while attaching (a form of the attach summary)
372
356
  */
373
- public setInitialSnapshot(
374
- snapshot: SnapshotWithBlobs | undefined,
375
- supportGetSnapshotApi: boolean,
376
- ) {
377
- this.supportGetSnapshotApi = supportGetSnapshotApi;
357
+ public setInitialSnapshot(snapshot: SnapshotWithBlobs | undefined) {
378
358
  if (this.offlineLoadEnabled) {
379
359
  assert(
380
360
  this.snapshot === undefined,