@fluidframework/container-loader 2.63.0-359461 → 2.63.0-359734
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/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 +6 -6
- package/dist/container.js.map +1 -1
- 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 +11 -8
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +51 -35
- package/dist/serializedStateManager.js.map +1 -1
- package/dist/utils.d.ts +7 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +41 -23
- 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 +7 -7
- package/lib/container.js.map +1 -1
- 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 +11 -8
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +52 -36
- package/lib/serializedStateManager.js.map +1 -1
- package/lib/utils.d.ts +7 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +39 -22
- package/lib/utils.js.map +1 -1
- package/package.json +11 -11
- package/src/attachment.ts +7 -13
- package/src/container.ts +7 -8
- package/src/packageVersion.ts +1 -1
- package/src/serializedStateManager.ts +68 -40
- package/src/utils.ts +49 -26
package/src/utils.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
Uint8ArrayToArrayBuffer,
|
|
8
8
|
bufferToString,
|
|
9
9
|
stringToBuffer,
|
|
10
10
|
} from "@fluid-internal/client-utils";
|
|
@@ -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
|
/**
|
|
@@ -212,7 +222,7 @@ export function convertSnapshotInfoToSnapshot(
|
|
|
212
222
|
snapshotInfo: ISnapshotInfo,
|
|
213
223
|
snapshotSequenceNumber: number,
|
|
214
224
|
): ISnapshot {
|
|
215
|
-
const blobContents = new Map<string,
|
|
225
|
+
const blobContents = new Map<string, ArrayBuffer>();
|
|
216
226
|
for (const [blobId, serializedContent] of Object.entries(snapshotInfo.snapshotBlobs)) {
|
|
217
227
|
blobContents.set(blobId, stringToBuffer(serializedContent, "utf8"));
|
|
218
228
|
}
|
|
@@ -231,30 +241,30 @@ export function convertSnapshotInfoToSnapshot(
|
|
|
231
241
|
* @param protocolSummaryTree - Protocol Summary Tree
|
|
232
242
|
* @param appSummaryTree - App Summary Tree
|
|
233
243
|
*/
|
|
234
|
-
function
|
|
244
|
+
function convertProtocolAndAppSummaryToISnapshot(
|
|
235
245
|
protocolSummaryTree: ISummaryTree,
|
|
236
246
|
appSummaryTree: ISummaryTree,
|
|
237
|
-
):
|
|
247
|
+
): ISnapshot {
|
|
238
248
|
const combinedSummary: ISummaryTree = {
|
|
239
249
|
type: SummaryType.Tree,
|
|
240
250
|
tree: { ...appSummaryTree.tree },
|
|
241
251
|
};
|
|
242
252
|
|
|
243
253
|
combinedSummary.tree[".protocol"] = protocolSummaryTree;
|
|
244
|
-
const snapshotTreeWithBlobContents =
|
|
254
|
+
const snapshotTreeWithBlobContents = convertSummaryToISnapshot(combinedSummary);
|
|
245
255
|
return snapshotTreeWithBlobContents;
|
|
246
256
|
}
|
|
247
257
|
|
|
248
|
-
export const
|
|
258
|
+
export const getISnapshotFromSerializedContainer = (
|
|
249
259
|
detachedContainerSnapshot: ISummaryTree,
|
|
250
|
-
):
|
|
260
|
+
): ISnapshot => {
|
|
251
261
|
assert(
|
|
252
262
|
isCombinedAppAndProtocolSummary(detachedContainerSnapshot),
|
|
253
263
|
0x8e6 /* Protocol and App summary trees should be present */,
|
|
254
264
|
);
|
|
255
265
|
const protocolSummaryTree = detachedContainerSnapshot.tree[".protocol"];
|
|
256
266
|
const appSummaryTree = detachedContainerSnapshot.tree[".app"];
|
|
257
|
-
const snapshotTreeWithBlobContents =
|
|
267
|
+
const snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToISnapshot(
|
|
258
268
|
protocolSummaryTree,
|
|
259
269
|
appSummaryTree,
|
|
260
270
|
);
|
|
@@ -322,6 +332,21 @@ function isPendingDetachedContainerState(
|
|
|
322
332
|
}
|
|
323
333
|
return true;
|
|
324
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Converts an ISnapshot to a SnapshotWithBlobs, extracting and serializing its blob contents.
|
|
337
|
+
* @param snapshot - The ISnapshot to convert.
|
|
338
|
+
* @returns A SnapshotWithBlobs containing the base snapshot and serialized blob contents.
|
|
339
|
+
*/
|
|
340
|
+
export function convertISnapshotToSnapshotWithBlobs(snapshot: ISnapshot): SnapshotWithBlobs {
|
|
341
|
+
const snapshotBlobs: ISerializableBlobContents = {};
|
|
342
|
+
for (const [id, blob] of snapshot.blobContents.entries()) {
|
|
343
|
+
snapshotBlobs[id] = bufferToString(blob, "utf8");
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
baseSnapshot: snapshot.snapshotTree,
|
|
347
|
+
snapshotBlobs,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
325
350
|
|
|
326
351
|
/**
|
|
327
352
|
* Parses the given string into {@link IPendingDetachedContainerState} format,
|
|
@@ -339,12 +364,10 @@ export function getDetachedContainerStateFromSerializedContainer(
|
|
|
339
364
|
return parsedContainerState;
|
|
340
365
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
341
366
|
} else if (isCombinedAppAndProtocolSummary(parsedContainerState)) {
|
|
342
|
-
const
|
|
343
|
-
getSnapshotTreeAndBlobsFromSerializedContainer(parsedContainerState);
|
|
367
|
+
const snapshot = getISnapshotFromSerializedContainer(parsedContainerState);
|
|
344
368
|
const detachedContainerState: IPendingDetachedContainerState = {
|
|
345
369
|
attached: false,
|
|
346
|
-
|
|
347
|
-
snapshotBlobs,
|
|
370
|
+
...convertISnapshotToSnapshotWithBlobs(snapshot),
|
|
348
371
|
hasAttachmentBlobs: parsedContainerState.tree[hasBlobsSummaryTree] !== undefined,
|
|
349
372
|
};
|
|
350
373
|
return detachedContainerState;
|