@waffle-os/runtime 0.0.154 → 0.0.156

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 (42) hide show
  1. package/core/filesystem.ts +22 -0
  2. package/core/wasi.ts +78 -5
  3. package/dist/core/filesystem.js +1 -0
  4. package/dist/core/wasi.js +71 -6
  5. package/dist/fs/backend.js +22 -1
  6. package/dist/fs/client.js +11 -3
  7. package/dist/fs/cold-read-cache.js +23 -0
  8. package/dist/fs/guest-watch.js +267 -94
  9. package/dist/fs/indexeddb-chunks.js +88 -11
  10. package/dist/fs/indexeddb.js +78 -14
  11. package/dist/fs/memory.js +17 -1
  12. package/dist/fs/multitab-backend.js +198 -64
  13. package/dist/fs/multitab-protocol.js +1 -0
  14. package/dist/fs/persistent.js +19 -1
  15. package/dist/fs/service.js +30 -1
  16. package/dist/fs/shared.js +4 -0
  17. package/dist/fs/storage.js +107 -8
  18. package/dist/fs/watch-service.js +97 -2
  19. package/dist/fs/watch-subscriptions.js +121 -8
  20. package/dist/proc/intrinsics/core.js +5 -0
  21. package/dist/proc/intrinsics.js +1 -0
  22. package/dist/tooling/program/program-transformer.json +1 -1
  23. package/fs/backend.ts +27 -1
  24. package/fs/client.ts +11 -0
  25. package/fs/cold-read-cache.ts +38 -0
  26. package/fs/guest-watch.ts +298 -102
  27. package/fs/indexeddb-chunks.ts +103 -9
  28. package/fs/indexeddb.ts +98 -11
  29. package/fs/memory.ts +18 -0
  30. package/fs/multitab-backend.ts +273 -72
  31. package/fs/multitab-protocol.ts +1 -0
  32. package/fs/persistent.ts +38 -1
  33. package/fs/service.ts +28 -0
  34. package/fs/shared.ts +4 -0
  35. package/fs/storage.ts +128 -10
  36. package/fs/watch-service.ts +110 -3
  37. package/fs/watch-subscriptions.ts +115 -7
  38. package/package.json +1 -1
  39. package/proc/intrinsics/core.ts +7 -0
  40. package/proc/intrinsics.ts +1 -0
  41. package/testing/indexeddb-storage-browser.ts +129 -0
  42. package/tooling/program/program-transformer.json +1 -1
@@ -1,9 +1,12 @@
1
- import { FilesystemError } from "../core/filesystem.js";
1
+ import {
2
+ FilesystemError
3
+ } from "../core/filesystem.js";
2
4
  import {
3
5
  arrayAppend,
4
6
  atomicsLoad,
5
7
  MapConstructor,
6
8
  mapDelete,
9
+ mapFirst,
7
10
  mapForEach,
8
11
  mapGet,
9
12
  mapSet,
@@ -12,6 +15,7 @@ import {
12
15
  const EAGAIN = 6;
13
16
  const EBADF = 8;
14
17
  const ECANCELED = 11;
18
+ const ENOTSUP = 58;
15
19
  const CHANGE = 1;
16
20
  const RENAME = 2;
17
21
  const OVERFLOW = 3;
@@ -22,147 +26,316 @@ const END = { kind: "records", records: [], length: 0 };
22
26
  function failure(errno) {
23
27
  return { kind: "error", errno };
24
28
  }
29
+ function watchError(id, errno) {
30
+ return { kind: "watch_error", id, errno };
31
+ }
32
+ function nextOf(id, result) {
33
+ return result.kind === "error" ? watchError(id, result.errno) : { ...result, id };
34
+ }
35
+ function rotate(map, watch) {
36
+ mapDelete(map, watch.id);
37
+ mapSet(map, watch.id, watch);
38
+ }
25
39
 
26
40
  export class GuestWatchTable {
27
- fs;
28
- watches = new MapConstructor;
29
- nextId = 1;
30
- revocationNotified = false;
41
+ #fs;
42
+ #watches;
43
+ #byService;
44
+ #buffered;
45
+ #errored;
46
+ #ended;
47
+ #nextId = 1;
48
+ #revocationNotified = false;
49
+ #activeCount = 0;
50
+ #observedGen = 0;
51
+ #observedCount = 0;
52
+ #tableObserved;
53
+ #drainMore = false;
54
+ #noDrain = false;
55
+ #flip = false;
31
56
  constructor(fs) {
32
- this.fs = fs;
57
+ this.#fs = fs;
58
+ this.drop();
33
59
  }
34
60
  get word() {
35
- return this.fs.cells;
61
+ return this.#fs.cells;
36
62
  }
37
63
  get active() {
38
- let active = false;
39
- mapForEach(this.watches, (watch) => {
40
- if (!watch.ended)
41
- active = true;
42
- });
43
- return active;
64
+ return this.#activeCount > 0;
65
+ }
66
+ #useDrain() {
67
+ if (typeof this.#fs.drain !== "function" || this.#noDrain)
68
+ return false;
69
+ if (this.#fs.canDrain === false) {
70
+ this.#tableObserved = undefined;
71
+ this.#drainMore = false;
72
+ return false;
73
+ }
74
+ return true;
75
+ }
76
+ #allObserved(generation) {
77
+ return this.#observedCount === this.#activeCount && this.#observedGen === generation || this.#useDrain() && !this.#drainMore && this.#tableObserved === generation;
44
78
  }
45
79
  pending() {
46
- if (this.fs.revoked)
47
- return !!this.fs.remote && !this.revocationNotified && this.active;
48
- return this.hasPending(false);
80
+ if (this.#fs.revoked)
81
+ return !!this.#fs.remote && !this.#revocationNotified && this.#activeCount > 0;
82
+ return this.#activeCount > 0 && (mapSize(this.#buffered) > 0 || mapSize(this.#errored) > 0 || !this.#allObserved(atomicsLoad(this.#fs.cells, 3)));
49
83
  }
50
84
  ready() {
51
- if (!mapSize(this.watches))
85
+ if (!mapSize(this.#watches))
52
86
  return false;
53
- return this.fs.revoked || this.hasPending(true);
54
- }
55
- hasPending(includeEnded) {
56
- const generation = atomicsLoad(this.fs.cells, 3);
57
- let pending = false;
58
- mapForEach(this.watches, (watch) => {
59
- if (watch.ended ? includeEnded : watch.head < watch.queue.length || watch.observed !== generation)
60
- pending = true;
61
- });
62
- return pending;
87
+ return this.#fs.revoked || mapSize(this.#buffered) > 0 || mapSize(this.#errored) > 0 || mapSize(this.#ended) > 0 || this.#activeCount > 0 && !this.#allObserved(atomicsLoad(this.#fs.cells, 3));
88
+ }
89
+ #setObserved(watch, generation) {
90
+ if (watch.observed === generation)
91
+ return;
92
+ if (!watch.ended) {
93
+ if (watch.observed === this.#observedGen)
94
+ this.#observedCount--;
95
+ if (generation !== this.#observedGen) {
96
+ this.#observedGen = generation;
97
+ this.#observedCount = 1;
98
+ } else
99
+ this.#observedCount++;
100
+ }
101
+ watch.observed = generation;
102
+ }
103
+ #markEnded(watch) {
104
+ if (watch.ended)
105
+ return;
106
+ watch.ended = true;
107
+ this.#activeCount--;
108
+ if (watch.observed === this.#observedGen)
109
+ this.#observedCount--;
110
+ watch.errno = 0;
111
+ mapDelete(this.#buffered, watch.id);
112
+ mapDelete(this.#errored, watch.id);
113
+ mapSet(this.#ended, watch.id, watch);
63
114
  }
64
115
  open(handle, recursive) {
65
- if (this.nextId > LAST_ID)
116
+ if (this.#nextId > LAST_ID)
66
117
  throw new FilesystemError(EAGAIN, "watch ids exhausted");
67
- const observed = atomicsLoad(this.fs.cells, 3);
68
- const service = this.fs.open(handle, recursive);
69
- const id = this.nextId++;
70
- mapSet(this.watches, id, { service, observed, queue: [], head: 0, ended: false });
118
+ const observed = atomicsLoad(this.#fs.cells, 3);
119
+ const service = this.#fs.open(handle, recursive);
120
+ const id = this.#nextId++;
121
+ const watch = { id, service, observed: NaN, queue: [], head: 0, ended: false, errno: 0 };
122
+ mapSet(this.#watches, id, watch);
123
+ mapSet(this.#byService, service, watch);
124
+ this.#activeCount++;
125
+ this.#setObserved(watch, observed);
71
126
  return id;
72
127
  }
73
128
  read(id, capacity) {
74
- const watch = mapGet(this.watches, id);
129
+ const watch = mapGet(this.#watches, id);
75
130
  if (!watch)
76
131
  return failure(EBADF);
77
132
  if (watch.ended)
78
133
  return END;
79
- if (watch.head === watch.queue.length) {
80
- const refused = this.refill(watch);
81
- if (refused)
82
- return refused;
134
+ if (watch.head < watch.queue.length)
135
+ return this.#takeFrom(watch, capacity);
136
+ const force = watch.errno !== 0;
137
+ if (force) {
138
+ watch.errno = 0;
139
+ mapDelete(this.#errored, id);
140
+ }
141
+ return this.#refillSingle(watch, force) ?? this.#takeFrom(watch, capacity);
142
+ }
143
+ readNext(capacity) {
144
+ if (!mapSize(this.#watches))
145
+ return failure(EAGAIN);
146
+ if (this.#fs.revoked) {
147
+ if (this.#fs.remote)
148
+ this.#revocationNotified = true;
149
+ const first = mapFirst(this.#watches);
150
+ rotate(this.#watches, first);
151
+ return watchError(first.id, ECANCELED);
152
+ }
153
+ if (this.#useDrain() && (mapSize(this.#buffered) || mapSize(this.#errored) || !this.#drainService()))
154
+ return this.#takeNextReady(capacity);
155
+ return this.#readNextFallback(capacity);
156
+ }
157
+ #takeNextReady(capacity) {
158
+ const buffered = mapFirst(this.#buffered);
159
+ if (buffered) {
160
+ const read = this.#takeFrom(buffered, capacity);
161
+ if (buffered.head < buffered.queue.length)
162
+ rotate(this.#buffered, buffered);
163
+ return nextOf(buffered.id, read);
83
164
  }
84
- return take(watch, capacity);
165
+ const ended = mapFirst(this.#ended);
166
+ const errored = mapFirst(this.#errored);
167
+ const pick = this.#flip ? ended ?? errored : errored ?? ended;
168
+ if (!pick)
169
+ return failure(EAGAIN);
170
+ this.#flip = !pick.ended;
171
+ if (pick.ended) {
172
+ rotate(this.#ended, pick);
173
+ return nextOf(pick.id, END);
174
+ }
175
+ const errno = pick.errno;
176
+ pick.errno = 0;
177
+ if (pick.observed === this.#observedGen)
178
+ this.#observedCount--;
179
+ pick.observed = NaN;
180
+ this.#drainMore = true;
181
+ mapDelete(this.#errored, pick.id);
182
+ return watchError(pick.id, errno);
183
+ }
184
+ #readNextFallback(capacity) {
185
+ let result;
186
+ let reported;
187
+ mapForEach(this.#watches, (watch) => {
188
+ if (result)
189
+ return;
190
+ try {
191
+ const read = this.read(watch.id, capacity);
192
+ if (read.kind !== "error" || read.errno !== EAGAIN) {
193
+ result = nextOf(watch.id, read);
194
+ reported = watch;
195
+ }
196
+ } catch (error) {
197
+ if (!(error instanceof FilesystemError))
198
+ throw error;
199
+ result = watchError(watch.id, error.errno);
200
+ reported = watch;
201
+ }
202
+ });
203
+ if (reported)
204
+ rotate(this.#watches, reported);
205
+ return result ?? failure(EAGAIN);
85
206
  }
86
207
  close(id) {
87
- const watch = mapGet(this.watches, id);
208
+ const watch = mapGet(this.#watches, id);
88
209
  if (!watch)
89
210
  return EBADF;
90
- if (!this.fs.revoked)
91
- this.closeService(watch.service);
92
- mapDelete(this.watches, id);
93
- return 0;
94
- }
95
- closeService(service) {
96
- try {
97
- this.fs.close(service);
98
- } catch (error) {
99
- if (!(error instanceof FilesystemError) || error.errno !== ECANCELED)
100
- throw error;
211
+ if (!this.#fs.revoked) {
212
+ try {
213
+ this.#fs.close(watch.service);
214
+ } catch (error) {
215
+ if (!(error instanceof FilesystemError) || error.errno !== ECANCELED)
216
+ throw error;
217
+ }
218
+ }
219
+ if (!watch.ended) {
220
+ this.#activeCount--;
221
+ if (watch.observed === this.#observedGen)
222
+ this.#observedCount--;
101
223
  }
224
+ mapDelete(this.#buffered, id);
225
+ mapDelete(this.#errored, id);
226
+ mapDelete(this.#ended, id);
227
+ mapDelete(this.#watches, id);
228
+ mapDelete(this.#byService, watch.service);
229
+ if (!mapSize(this.#watches)) {
230
+ this.#tableObserved = undefined;
231
+ this.#drainMore = false;
232
+ }
233
+ return 0;
102
234
  }
103
235
  drop() {
104
- this.watches = new MapConstructor;
236
+ this.#watches = new MapConstructor;
237
+ this.#byService = new MapConstructor;
238
+ this.#buffered = new MapConstructor;
239
+ this.#errored = new MapConstructor;
240
+ this.#ended = new MapConstructor;
241
+ this.#activeCount = this.#observedCount = 0;
242
+ this.#tableObserved = undefined;
243
+ this.#drainMore = false;
105
244
  }
106
- refill(watch) {
107
- if (this.fs.revoked) {
108
- if (this.fs.remote)
109
- this.revocationNotified = true;
110
- return failure(ECANCELED);
245
+ #applyBatch(watch, batch, generation) {
246
+ if (batch.kind === "closed") {
247
+ this.#markEnded(watch);
248
+ return true;
111
249
  }
112
- const generation = atomicsLoad(this.fs.cells, 3);
113
- if (!this.fs.remote && generation === watch.observed)
114
- return failure(EAGAIN);
115
- const previous = watch.observed;
116
- watch.observed = generation;
117
- let batch;
250
+ this.#setObserved(watch, generation);
251
+ watch.queue = encodeBatch(batch);
252
+ watch.head = 0;
253
+ if (watch.queue.length)
254
+ mapSet(this.#buffered, watch.id, watch);
255
+ return false;
256
+ }
257
+ #drainService() {
258
+ const generation = atomicsLoad(this.#fs.cells, 3);
259
+ if (!this.#drainMore && this.#allObserved(generation))
260
+ return false;
261
+ const previous = this.#tableObserved;
262
+ this.#tableObserved = generation;
263
+ let drained;
118
264
  try {
119
- batch = this.fs.read(watch.service);
265
+ drained = this.#fs.drain();
120
266
  } catch (error) {
121
- watch.observed = previous;
267
+ if (error instanceof FilesystemError && error.errno === ENOTSUP) {
268
+ this.#tableObserved = undefined;
269
+ this.#drainMore = false;
270
+ if (this.#fs.canDrain === undefined)
271
+ this.#noDrain = true;
272
+ return true;
273
+ }
274
+ this.#tableObserved = previous;
122
275
  throw error;
123
276
  }
124
- if (batch.kind === "closed") {
125
- watch.ended = true;
126
- return END;
277
+ this.#drainMore = drained.more;
278
+ for (let index = 0;index < drained.entries.length; index++) {
279
+ const entry = drained.entries[index];
280
+ const watch = mapGet(this.#byService, entry.id);
281
+ if (!watch || watch.ended)
282
+ continue;
283
+ if ("errno" in entry) {
284
+ watch.errno = entry.errno;
285
+ mapSet(this.#errored, watch.id, watch);
286
+ } else {
287
+ this.#applyBatch(watch, entry.batch, generation);
288
+ }
127
289
  }
128
- watch.queue = encodeBatch(batch);
129
- watch.head = 0;
290
+ return false;
291
+ }
292
+ #refillSingle(watch, force) {
293
+ if (this.#fs.revoked) {
294
+ if (this.#fs.remote)
295
+ this.#revocationNotified = true;
296
+ return failure(ECANCELED);
297
+ }
298
+ const generation = atomicsLoad(this.#fs.cells, 3);
299
+ if (!force && !this.#fs.remote && (generation === watch.observed || this.#useDrain() && !this.#drainMore && generation === this.#tableObserved))
300
+ return failure(EAGAIN);
301
+ if (this.#applyBatch(watch, this.#fs.read(watch.service), generation))
302
+ return END;
130
303
  if (!watch.queue.length)
131
304
  return failure(EAGAIN);
132
305
  }
133
- }
134
- function take(watch, capacity) {
135
- const records = [];
136
- let length = 0;
137
- while (watch.head < watch.queue.length) {
138
- const record = watch.queue[watch.head];
139
- if (length + record.length > capacity)
140
- break;
141
- arrayAppend(records, record);
142
- length += record.length;
143
- watch.head++;
144
- if (record[0] === OVERFLOW)
145
- watch.ended = true;
146
- }
147
- if (!length)
148
- return { kind: "short", needed: watch.queue[watch.head].length };
149
- if (watch.head === watch.queue.length) {
150
- watch.queue = [];
151
- watch.head = 0;
306
+ #takeFrom(watch, capacity) {
307
+ const records = [];
308
+ let length = 0;
309
+ while (watch.head < watch.queue.length) {
310
+ const record = watch.queue[watch.head];
311
+ if (length + record.length > capacity)
312
+ break;
313
+ arrayAppend(records, record);
314
+ length += record.length;
315
+ watch.head++;
316
+ if (record[0] === OVERFLOW)
317
+ this.#markEnded(watch);
318
+ }
319
+ if (!length)
320
+ return { kind: "short", needed: watch.queue[watch.head].length };
321
+ if (watch.head === watch.queue.length) {
322
+ watch.queue = [];
323
+ watch.head = 0;
324
+ mapDelete(this.#buffered, watch.id);
325
+ }
326
+ return { kind: "records", records, length };
152
327
  }
153
- return { kind: "records", records, length };
154
328
  }
155
329
  function encodeBatch(batch) {
156
330
  if (batch.kind === "overflow")
157
331
  return [encodeRecord(OVERFLOW, null)];
158
332
  const records = [];
159
- for (let index = 0;index < batch.events.length; index++)
160
- arrayAppend(records, encodeEvent(batch.events[index]));
333
+ for (let index = 0;index < batch.events.length; index++) {
334
+ const event = batch.events[index];
335
+ arrayAppend(records, encodeRecord(event.type === "change" ? CHANGE : RENAME, event.name));
336
+ }
161
337
  return records;
162
338
  }
163
- function encodeEvent(event) {
164
- return encodeRecord(event.type === "change" ? CHANGE : RENAME, event.name);
165
- }
166
339
  function encodeRecord(type, name) {
167
340
  const bytes = name === null ? undefined : encoder.encode(name);
168
341
  const size = bytes ? bytes.length : 0;
@@ -23,22 +23,45 @@ export function parseChunk(value, size, key) {
23
23
  export function chunkLength(manifest, index) {
24
24
  return Math.min(CHUNK_SIZE, manifest.size - index * CHUNK_SIZE);
25
25
  }
26
+ const HEX = Array.from({ length: 256 }, (_, byte) => byte.toString(16).padStart(2, "0"));
27
+ const PREPARE_CONCURRENCY = 32;
26
28
  export async function chunkChecksum(bytes) {
27
29
  const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
28
- return Array.from(digest, (byte) => byte.toString(16).padStart(2, "0")).join("");
30
+ let hex = "";
31
+ for (let i = 0;i < digest.length; i++)
32
+ hex += HEX[digest[i]];
33
+ return hex;
29
34
  }
30
- export async function preparePayload(bytes, signal) {
31
- const chunks = [];
32
- for (let offset = 0;offset < bytes.length; offset += CHUNK_SIZE) {
35
+ async function prepareOwnedPayload(bytes, signal) {
36
+ if (!bytes.length) {
33
37
  signal?.throwIfAborted();
34
- const part = bytes.slice(offset, offset + CHUNK_SIZE);
35
- chunks.push({ bytes: part, checksum: await chunkChecksum(part) });
38
+ return {
39
+ manifest: { version: 2, size: 0, chunkSize: CHUNK_SIZE, count: 0 },
40
+ chunks: []
41
+ };
36
42
  }
43
+ const count = Math.ceil(bytes.length / CHUNK_SIZE);
44
+ const chunks = Array.from({ length: count });
45
+ let next = 0;
46
+ const workers = Math.min(PREPARE_CONCURRENCY, count);
47
+ await Promise.all(Array.from({ length: workers }, async () => {
48
+ while (next < count) {
49
+ signal?.throwIfAborted();
50
+ const index = next++;
51
+ const offset = index * CHUNK_SIZE;
52
+ const part = bytes.slice(offset, offset + CHUNK_SIZE);
53
+ chunks[index] = { bytes: part, checksum: await chunkChecksum(part) };
54
+ }
55
+ }));
56
+ signal?.throwIfAborted();
37
57
  return {
38
- manifest: { version: 2, size: bytes.length, chunkSize: CHUNK_SIZE, count: chunks.length },
58
+ manifest: { version: 2, size: bytes.length, chunkSize: CHUNK_SIZE, count },
39
59
  chunks
40
60
  };
41
61
  }
62
+ export function preparePayload(bytes, signal) {
63
+ return prepareOwnedPayload(bytes, signal);
64
+ }
42
65
  export function validateRange(range) {
43
66
  if (!validInteger(range.offset) || !validInteger(range.length) || !Number.isSafeInteger(range.offset + range.length))
44
67
  throw new RangeError("Invalid filesystem byte range");
@@ -48,7 +71,7 @@ export function deletePayload(store, key) {
48
71
  store.delete(key);
49
72
  store.delete(IDBKeyRange.bound([key, 0], [key, Number.MAX_SAFE_INTEGER]));
50
73
  }
51
- function putPayload(store, key, payload) {
74
+ export function putPayload(store, key, payload) {
52
75
  for (const [index, chunk] of payload.chunks.entries())
53
76
  store.put(chunk, [key, index]);
54
77
  store.put(payload.manifest, key);
@@ -96,10 +119,64 @@ function compareChunk(value, chunk, key, finish, abort) {
96
119
  abort(error);
97
120
  }
98
121
  }
99
- export async function preparePayloads(data) {
122
+ export async function preparePayloads(data, owned = false, checkAbort) {
100
123
  const prepared = new Map;
101
- for (const [key, bytes] of data)
102
- prepared.set(key, await preparePayload(bytes));
124
+ checkAbort?.();
125
+ if (!data.size)
126
+ return prepared;
127
+ const tasks = [];
128
+ for (const [key, bytes] of data) {
129
+ if (!bytes.length) {
130
+ prepared.set(key, {
131
+ manifest: { version: 2, size: 0, chunkSize: CHUNK_SIZE, count: 0 },
132
+ chunks: []
133
+ });
134
+ continue;
135
+ }
136
+ const count = Math.ceil(bytes.length / CHUNK_SIZE);
137
+ const chunks = Array.from({ length: count });
138
+ prepared.set(key, {
139
+ manifest: { version: 2, size: bytes.length, chunkSize: CHUNK_SIZE, count },
140
+ chunks
141
+ });
142
+ const direct = owned && count === 1 && bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength && bytes.buffer instanceof ArrayBuffer;
143
+ for (let index = 0;index < count; index++)
144
+ tasks.push({ chunks, index, bytes, offset: index * CHUNK_SIZE, direct });
145
+ }
146
+ if (!tasks.length)
147
+ return prepared;
148
+ let next = 0;
149
+ let failed = false;
150
+ let failure;
151
+ const fail = (error) => {
152
+ if (!failed) {
153
+ failed = true;
154
+ failure = error;
155
+ }
156
+ };
157
+ const workers = Math.min(PREPARE_CONCURRENCY, tasks.length);
158
+ await Promise.allSettled(Array.from({ length: workers }, async () => {
159
+ while (!failed && next < tasks.length) {
160
+ try {
161
+ checkAbort?.();
162
+ } catch (error) {
163
+ fail(error);
164
+ return;
165
+ }
166
+ const task = tasks[next++];
167
+ const part = task.direct ? task.bytes : task.bytes.slice(task.offset, task.offset + CHUNK_SIZE);
168
+ try {
169
+ const checksum = await chunkChecksum(part);
170
+ task.chunks[task.index] = { bytes: part, checksum };
171
+ } catch (error) {
172
+ fail(error);
173
+ return;
174
+ }
175
+ }
176
+ }));
177
+ if (failed)
178
+ throw failure;
179
+ checkAbort?.();
103
180
  return prepared;
104
181
  }
105
182
  export function copyLegacyChunks(data, key, prepared) {