@fluidframework/container-loader 2.63.0-359461 → 2.63.0-359962
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.
- package/api-report/container-loader.legacy.alpha.api.md +3 -0
- package/dist/attachment.d.ts +2 -7
- package/dist/attachment.d.ts.map +1 -1
- package/dist/attachment.js +2 -4
- package/dist/attachment.js.map +1 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +7 -7
- package/dist/container.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +2 -2
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +1 -1
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/createAndLoadContainerUtils.js +1 -1
- package/dist/createAndLoadContainerUtils.js.map +1 -1
- package/dist/frozenServices.d.ts +10 -1
- package/dist/frozenServices.d.ts.map +1 -1
- package/dist/frozenServices.js +24 -4
- package/dist/frozenServices.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/legacyAlpha.d.ts +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serializedStateManager.d.ts +19 -12
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +112 -98
- package/dist/serializedStateManager.js.map +1 -1
- package/dist/utils.d.ts +10 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +43 -25
- package/dist/utils.js.map +1 -1
- package/lib/attachment.d.ts +2 -7
- package/lib/attachment.d.ts.map +1 -1
- package/lib/attachment.js +3 -5
- package/lib/attachment.js.map +1 -1
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +8 -8
- package/lib/container.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +2 -2
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +1 -1
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/createAndLoadContainerUtils.js +2 -2
- package/lib/createAndLoadContainerUtils.js.map +1 -1
- package/lib/frozenServices.d.ts +10 -1
- package/lib/frozenServices.d.ts.map +1 -1
- package/lib/frozenServices.js +20 -1
- package/lib/frozenServices.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/legacyAlpha.d.ts +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/serializedStateManager.d.ts +19 -12
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +114 -100
- package/lib/serializedStateManager.js.map +1 -1
- package/lib/utils.d.ts +10 -4
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +41 -24
- package/lib/utils.js.map +1 -1
- package/package.json +11 -11
- package/src/attachment.ts +7 -13
- package/src/container.ts +12 -10
- package/src/containerStorageAdapter.ts +5 -6
- package/src/createAndLoadContainerUtils.ts +2 -2
- package/src/frozenServices.ts +28 -2
- package/src/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/serializedStateManager.ts +166 -132
- package/src/utils.ts +53 -31
package/src/utils.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
Uint8ArrayToString,
|
|
8
7
|
bufferToString,
|
|
9
8
|
stringToBuffer,
|
|
9
|
+
Uint8ArrayToArrayBuffer,
|
|
10
10
|
} from "@fluid-internal/client-utils";
|
|
11
11
|
import { assert, compareArrays, unreachableCase } from "@fluidframework/core-utils/internal";
|
|
12
12
|
import { type ISummaryTree, SummaryType } from "@fluidframework/driver-definitions";
|
|
@@ -34,7 +34,7 @@ import type { ISerializableBlobContents } from "./containerStorageAdapter.js";
|
|
|
34
34
|
import type {
|
|
35
35
|
IPendingContainerState,
|
|
36
36
|
IPendingDetachedContainerState,
|
|
37
|
-
|
|
37
|
+
SerializedSnapshotInfo,
|
|
38
38
|
SnapshotWithBlobs,
|
|
39
39
|
} from "./serializedStateManager.js";
|
|
40
40
|
|
|
@@ -132,35 +132,39 @@ export function combineAppAndProtocolSummary(
|
|
|
132
132
|
* to align detached container format with IPendingContainerState
|
|
133
133
|
* @param summary - ISummaryTree
|
|
134
134
|
*/
|
|
135
|
-
function
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
function convertSummaryToISnapshot(
|
|
136
|
+
summary: ISummaryTree,
|
|
137
|
+
blobContents = new Map<string, ArrayBuffer>(),
|
|
138
|
+
): ISnapshot {
|
|
139
|
+
const snapshotTree: ISnapshotTree = {
|
|
138
140
|
blobs: {},
|
|
139
141
|
trees: {},
|
|
140
142
|
id: uuid(),
|
|
141
143
|
unreferenced: summary.unreferenced,
|
|
142
144
|
groupId: summary.groupId,
|
|
143
145
|
};
|
|
146
|
+
|
|
144
147
|
for (const [key, summaryObject] of Object.entries(summary.tree)) {
|
|
145
148
|
switch (summaryObject.type) {
|
|
146
149
|
case SummaryType.Tree: {
|
|
147
|
-
const innerSnapshot =
|
|
148
|
-
|
|
149
|
-
blobContents = { ...blobContents, ...innerSnapshot.snapshotBlobs };
|
|
150
|
+
const innerSnapshot = convertSummaryToISnapshot(summaryObject, blobContents);
|
|
151
|
+
snapshotTree.trees[key] = innerSnapshot.snapshotTree;
|
|
150
152
|
break;
|
|
151
153
|
}
|
|
152
154
|
case SummaryType.Attachment: {
|
|
153
|
-
|
|
155
|
+
snapshotTree.blobs[key] = summaryObject.id;
|
|
154
156
|
break;
|
|
155
157
|
}
|
|
156
158
|
case SummaryType.Blob: {
|
|
157
159
|
const blobId = uuid();
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
snapshotTree.blobs[key] = blobId;
|
|
161
|
+
blobContents.set(
|
|
162
|
+
blobId,
|
|
160
163
|
summaryObject.content instanceof Uint8Array
|
|
161
|
-
?
|
|
162
|
-
: summaryObject.content
|
|
163
|
-
|
|
164
|
+
? Uint8ArrayToArrayBuffer(summaryObject.content)
|
|
165
|
+
: stringToBuffer(summaryObject.content, "utf8"),
|
|
166
|
+
);
|
|
167
|
+
|
|
164
168
|
break;
|
|
165
169
|
}
|
|
166
170
|
case SummaryType.Handle: {
|
|
@@ -174,8 +178,14 @@ function convertSummaryToSnapshotAndBlobs(summary: ISummaryTree): SnapshotWithBl
|
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
}
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
return {
|
|
182
|
+
blobContents,
|
|
183
|
+
latestSequenceNumber: undefined,
|
|
184
|
+
ops: [],
|
|
185
|
+
sequenceNumber: 0,
|
|
186
|
+
snapshotFormatV: 1,
|
|
187
|
+
snapshotTree,
|
|
188
|
+
};
|
|
179
189
|
}
|
|
180
190
|
|
|
181
191
|
/**
|
|
@@ -185,7 +195,7 @@ function convertSummaryToSnapshotAndBlobs(summary: ISummaryTree): SnapshotWithBl
|
|
|
185
195
|
* Note, this assumes the ISnapshot sequence number is defined. Otherwise an assert will be thrown
|
|
186
196
|
* @param snapshot - ISnapshot
|
|
187
197
|
*/
|
|
188
|
-
export function convertSnapshotToSnapshotInfo(snapshot: ISnapshot):
|
|
198
|
+
export function convertSnapshotToSnapshotInfo(snapshot: ISnapshot): SerializedSnapshotInfo {
|
|
189
199
|
assert(
|
|
190
200
|
snapshot.sequenceNumber !== undefined,
|
|
191
201
|
0x93a /* Snapshot sequence number is missing */,
|
|
@@ -209,10 +219,9 @@ export function convertSnapshotToSnapshotInfo(snapshot: ISnapshot): ISnapshotInf
|
|
|
209
219
|
* @param snapshot - ISnapshot
|
|
210
220
|
*/
|
|
211
221
|
export function convertSnapshotInfoToSnapshot(
|
|
212
|
-
snapshotInfo:
|
|
213
|
-
snapshotSequenceNumber: number,
|
|
222
|
+
snapshotInfo: SerializedSnapshotInfo,
|
|
214
223
|
): ISnapshot {
|
|
215
|
-
const blobContents = new Map<string,
|
|
224
|
+
const blobContents = new Map<string, ArrayBuffer>();
|
|
216
225
|
for (const [blobId, serializedContent] of Object.entries(snapshotInfo.snapshotBlobs)) {
|
|
217
226
|
blobContents.set(blobId, stringToBuffer(serializedContent, "utf8"));
|
|
218
227
|
}
|
|
@@ -220,7 +229,7 @@ export function convertSnapshotInfoToSnapshot(
|
|
|
220
229
|
snapshotTree: snapshotInfo.baseSnapshot,
|
|
221
230
|
blobContents,
|
|
222
231
|
ops: [],
|
|
223
|
-
sequenceNumber: snapshotSequenceNumber,
|
|
232
|
+
sequenceNumber: snapshotInfo.snapshotSequenceNumber,
|
|
224
233
|
latestSequenceNumber: undefined,
|
|
225
234
|
snapshotFormatV: 1,
|
|
226
235
|
};
|
|
@@ -231,30 +240,30 @@ export function convertSnapshotInfoToSnapshot(
|
|
|
231
240
|
* @param protocolSummaryTree - Protocol Summary Tree
|
|
232
241
|
* @param appSummaryTree - App Summary Tree
|
|
233
242
|
*/
|
|
234
|
-
function
|
|
243
|
+
function convertProtocolAndAppSummaryToISnapshot(
|
|
235
244
|
protocolSummaryTree: ISummaryTree,
|
|
236
245
|
appSummaryTree: ISummaryTree,
|
|
237
|
-
):
|
|
246
|
+
): ISnapshot {
|
|
238
247
|
const combinedSummary: ISummaryTree = {
|
|
239
248
|
type: SummaryType.Tree,
|
|
240
249
|
tree: { ...appSummaryTree.tree },
|
|
241
250
|
};
|
|
242
251
|
|
|
243
252
|
combinedSummary.tree[".protocol"] = protocolSummaryTree;
|
|
244
|
-
const snapshotTreeWithBlobContents =
|
|
253
|
+
const snapshotTreeWithBlobContents = convertSummaryToISnapshot(combinedSummary);
|
|
245
254
|
return snapshotTreeWithBlobContents;
|
|
246
255
|
}
|
|
247
256
|
|
|
248
|
-
export const
|
|
257
|
+
export const getISnapshotFromSerializedContainer = (
|
|
249
258
|
detachedContainerSnapshot: ISummaryTree,
|
|
250
|
-
):
|
|
259
|
+
): ISnapshot => {
|
|
251
260
|
assert(
|
|
252
261
|
isCombinedAppAndProtocolSummary(detachedContainerSnapshot),
|
|
253
262
|
0x8e6 /* Protocol and App summary trees should be present */,
|
|
254
263
|
);
|
|
255
264
|
const protocolSummaryTree = detachedContainerSnapshot.tree[".protocol"];
|
|
256
265
|
const appSummaryTree = detachedContainerSnapshot.tree[".app"];
|
|
257
|
-
const snapshotTreeWithBlobContents =
|
|
266
|
+
const snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToISnapshot(
|
|
258
267
|
protocolSummaryTree,
|
|
259
268
|
appSummaryTree,
|
|
260
269
|
);
|
|
@@ -322,6 +331,21 @@ function isPendingDetachedContainerState(
|
|
|
322
331
|
}
|
|
323
332
|
return true;
|
|
324
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Converts an ISnapshot to a SnapshotWithBlobs, extracting and serializing its blob contents.
|
|
336
|
+
* @param snapshot - The ISnapshot to convert.
|
|
337
|
+
* @returns A SnapshotWithBlobs containing the base snapshot and serialized blob contents.
|
|
338
|
+
*/
|
|
339
|
+
export function convertISnapshotToSnapshotWithBlobs(snapshot: ISnapshot): SnapshotWithBlobs {
|
|
340
|
+
const snapshotBlobs: ISerializableBlobContents = {};
|
|
341
|
+
for (const [id, blob] of snapshot.blobContents.entries()) {
|
|
342
|
+
snapshotBlobs[id] = bufferToString(blob, "utf8");
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
baseSnapshot: snapshot.snapshotTree,
|
|
346
|
+
snapshotBlobs,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
325
349
|
|
|
326
350
|
/**
|
|
327
351
|
* Parses the given string into {@link IPendingDetachedContainerState} format,
|
|
@@ -339,12 +363,10 @@ export function getDetachedContainerStateFromSerializedContainer(
|
|
|
339
363
|
return parsedContainerState;
|
|
340
364
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
341
365
|
} else if (isCombinedAppAndProtocolSummary(parsedContainerState)) {
|
|
342
|
-
const
|
|
343
|
-
getSnapshotTreeAndBlobsFromSerializedContainer(parsedContainerState);
|
|
366
|
+
const snapshot = getISnapshotFromSerializedContainer(parsedContainerState);
|
|
344
367
|
const detachedContainerState: IPendingDetachedContainerState = {
|
|
345
368
|
attached: false,
|
|
346
|
-
|
|
347
|
-
snapshotBlobs,
|
|
369
|
+
...convertISnapshotToSnapshotWithBlobs(snapshot),
|
|
348
370
|
hasAttachmentBlobs: parsedContainerState.tree[hasBlobsSummaryTree] !== undefined,
|
|
349
371
|
};
|
|
350
372
|
return detachedContainerState;
|