@wovin/core 0.0.4 → 0.0.6

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 (73) hide show
  1. package/dist/applog/applog-helpers.d.ts +4 -4
  2. package/dist/applog/applog-helpers.d.ts.map +1 -1
  3. package/dist/applog.min.js +1 -1
  4. package/dist/chunk-5Q6PAAMY.min.js +2 -0
  5. package/dist/chunk-5Q6PAAMY.min.js.map +1 -0
  6. package/dist/chunk-BR5DELY4.min.js +2 -0
  7. package/dist/chunk-BR5DELY4.min.js.map +1 -0
  8. package/dist/chunk-D6REGRIL.min.js +2 -0
  9. package/dist/chunk-D6REGRIL.min.js.map +1 -0
  10. package/dist/{chunk-WNS2N7XB.min.js → chunk-IVEP7DZW.min.js} +21 -21
  11. package/dist/{chunk-WNS2N7XB.min.js.map → chunk-IVEP7DZW.min.js.map} +1 -1
  12. package/dist/{chunk-UZUBJLQD.min.js → chunk-J5PGGKKW.min.js} +2 -2
  13. package/dist/{chunk-UZUBJLQD.min.js.map → chunk-J5PGGKKW.min.js.map} +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.min.js +1 -1
  16. package/dist/index.min.js.map +1 -1
  17. package/dist/ipfs/car.d.ts.map +1 -1
  18. package/dist/ipfs.min.js +1 -1
  19. package/dist/mobx/mobx-utils.d.ts +6 -6
  20. package/dist/mobx/mobx-utils.d.ts.map +1 -1
  21. package/dist/pubsub/publication.d.ts +2 -2
  22. package/dist/pubsub/publication.d.ts.map +1 -1
  23. package/dist/pubsub.min.js +1 -1
  24. package/dist/query/basic.d.ts +19 -19
  25. package/dist/query/basic.d.ts.map +1 -1
  26. package/dist/query/divergences.d.ts +5 -5
  27. package/dist/query/divergences.d.ts.map +1 -1
  28. package/dist/query.min.js +1 -1
  29. package/dist/thread/basic.d.ts +36 -0
  30. package/dist/thread/basic.d.ts.map +1 -0
  31. package/dist/thread/filters.d.ts +38 -0
  32. package/dist/thread/filters.d.ts.map +1 -0
  33. package/dist/thread/mapped.d.ts +19 -0
  34. package/dist/thread/mapped.d.ts.map +1 -0
  35. package/dist/thread/writeable.d.ts +17 -0
  36. package/dist/thread/writeable.d.ts.map +1 -0
  37. package/dist/thread.d.ts +5 -0
  38. package/dist/thread.d.ts.map +1 -0
  39. package/dist/thread.min.js +2 -0
  40. package/dist/types/typescript-utils.d.ts +2 -2
  41. package/dist/types/typescript-utils.d.ts.map +1 -1
  42. package/dist/types.min.js +1 -1
  43. package/package.json +4 -4
  44. package/dist/chunk-2UCPKUQK.min.js +0 -1256
  45. package/dist/chunk-2UCPKUQK.min.js.map +0 -1
  46. package/dist/chunk-3HUXODLY.min.js +0 -11940
  47. package/dist/chunk-3HUXODLY.min.js.map +0 -1
  48. package/dist/chunk-KBXBNPCO.min.js +0 -2
  49. package/dist/chunk-KBXBNPCO.min.js.map +0 -1
  50. package/dist/chunk-N7GKIL5T.min.js +0 -120
  51. package/dist/chunk-N7GKIL5T.min.js.map +0 -1
  52. package/dist/chunk-PVULNVU2.min.js +0 -49
  53. package/dist/chunk-PVULNVU2.min.js.map +0 -1
  54. package/dist/chunk-VTXN7J7O.min.js +0 -66
  55. package/dist/chunk-VTXN7J7O.min.js.map +0 -1
  56. package/dist/chunk-W7B2PDHK.min.js +0 -2
  57. package/dist/chunk-W7B2PDHK.min.js.map +0 -1
  58. package/dist/chunk-WCOT2GIF.min.js +0 -2
  59. package/dist/chunk-WCOT2GIF.min.js.map +0 -1
  60. package/dist/chunk-WOD425XV.min.js +0 -4401
  61. package/dist/chunk-WOD425XV.min.js.map +0 -1
  62. package/dist/stream/basic.d.ts +0 -36
  63. package/dist/stream/basic.d.ts.map +0 -1
  64. package/dist/stream/filters.d.ts +0 -38
  65. package/dist/stream/filters.d.ts.map +0 -1
  66. package/dist/stream/mapped.d.ts +0 -19
  67. package/dist/stream/mapped.d.ts.map +0 -1
  68. package/dist/stream/writeable.d.ts +0 -17
  69. package/dist/stream/writeable.d.ts.map +0 -1
  70. package/dist/stream.d.ts +0 -5
  71. package/dist/stream.d.ts.map +0 -1
  72. package/dist/stream.min.js +0 -2
  73. /package/dist/{stream.min.js.map → thread.min.js.map} +0 -0
@@ -1,1256 +0,0 @@
1
- import {
2
- CID,
3
- Logger,
4
- Token,
5
- Type,
6
- __commonJS,
7
- __toESM,
8
- decode,
9
- decode2,
10
- decode3,
11
- encode,
12
- makeCborEncoders
13
- } from "./chunk-WOD425XV.min.js";
14
-
15
- // ../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/encode.js
16
- var require_encode = __commonJS({
17
- "../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/encode.js"(exports, module) {
18
- "use strict";
19
- module.exports = encode3;
20
- var MSB = 128;
21
- var REST = 127;
22
- var MSBALL = ~REST;
23
- var INT = Math.pow(2, 31);
24
- function encode3(num, out, offset) {
25
- if (Number.MAX_SAFE_INTEGER && num > Number.MAX_SAFE_INTEGER) {
26
- encode3.bytes = 0;
27
- throw new RangeError("Could not encode varint");
28
- }
29
- out = out || [];
30
- offset = offset || 0;
31
- var oldOffset = offset;
32
- while (num >= INT) {
33
- out[offset++] = num & 255 | MSB;
34
- num /= 128;
35
- }
36
- while (num & MSBALL) {
37
- out[offset++] = num & 255 | MSB;
38
- num >>>= 7;
39
- }
40
- out[offset] = num | 0;
41
- encode3.bytes = offset - oldOffset + 1;
42
- return out;
43
- }
44
- }
45
- });
46
-
47
- // ../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/decode.js
48
- var require_decode = __commonJS({
49
- "../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/decode.js"(exports, module) {
50
- "use strict";
51
- module.exports = read;
52
- var MSB = 128;
53
- var REST = 127;
54
- function read(buf, offset) {
55
- var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
56
- do {
57
- if (counter >= l || shift > 49) {
58
- read.bytes = 0;
59
- throw new RangeError("Could not decode varint");
60
- }
61
- b = buf[counter++];
62
- res += shift < 28 ? (b & REST) << shift : (b & REST) * Math.pow(2, shift);
63
- shift += 7;
64
- } while (b >= MSB);
65
- read.bytes = counter - offset;
66
- return res;
67
- }
68
- }
69
- });
70
-
71
- // ../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/length.js
72
- var require_length = __commonJS({
73
- "../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/length.js"(exports, module) {
74
- "use strict";
75
- var N1 = Math.pow(2, 7);
76
- var N2 = Math.pow(2, 14);
77
- var N3 = Math.pow(2, 21);
78
- var N4 = Math.pow(2, 28);
79
- var N5 = Math.pow(2, 35);
80
- var N6 = Math.pow(2, 42);
81
- var N7 = Math.pow(2, 49);
82
- var N8 = Math.pow(2, 56);
83
- var N9 = Math.pow(2, 63);
84
- module.exports = function(value) {
85
- return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
86
- };
87
- }
88
- });
89
-
90
- // ../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/index.js
91
- var require_varint = __commonJS({
92
- "../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/index.js"(exports, module) {
93
- "use strict";
94
- module.exports = {
95
- encode: require_encode(),
96
- decode: require_decode(),
97
- encodingLength: require_length()
98
- };
99
- }
100
- });
101
-
102
- // ../../../node_modules/.pnpm/@ipld+dag-cbor@9.0.6/node_modules/@ipld/dag-cbor/src/index.js
103
- var CID_CBOR_TAG = 42;
104
- function cidEncoder(obj) {
105
- if (obj.asCID !== obj && obj["/"] !== obj.bytes) {
106
- return null;
107
- }
108
- const cid = CID.asCID(obj);
109
- if (!cid) {
110
- return null;
111
- }
112
- const bytes = new Uint8Array(cid.bytes.byteLength + 1);
113
- bytes.set(cid.bytes, 1);
114
- return [
115
- new Token(Type.tag, CID_CBOR_TAG),
116
- new Token(Type.bytes, bytes)
117
- ];
118
- }
119
- function undefinedEncoder() {
120
- throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded");
121
- }
122
- function numberEncoder(num) {
123
- if (Number.isNaN(num)) {
124
- throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");
125
- }
126
- if (num === Infinity || num === -Infinity) {
127
- throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");
128
- }
129
- return null;
130
- }
131
- var encodeOptions = {
132
- float64: true,
133
- typeEncoders: {
134
- Object: cidEncoder,
135
- undefined: undefinedEncoder,
136
- number: numberEncoder
137
- }
138
- };
139
- function cidDecoder(bytes) {
140
- if (bytes[0] !== 0) {
141
- throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");
142
- }
143
- return CID.decode(bytes.subarray(1));
144
- }
145
- var decodeOptions = {
146
- allowIndefinite: false,
147
- coerceUndefinedToNull: true,
148
- allowNaN: false,
149
- allowInfinity: false,
150
- allowBigInt: true,
151
- // this will lead to BigInt for ints outside of
152
- // safe-integer range, which may surprise users
153
- strict: true,
154
- useMaps: false,
155
- rejectDuplicateMapKeys: true,
156
- /** @type {import('cborg').TagDecoder[]} */
157
- tags: []
158
- };
159
- decodeOptions.tags[CID_CBOR_TAG] = cidDecoder;
160
- var encode2 = (node) => encode(node, encodeOptions);
161
- var decode4 = (data) => decode(data, decodeOptions);
162
-
163
- // ../../../node_modules/.pnpm/@ipld+car@5.2.4/node_modules/@ipld/car/src/decoder-common.js
164
- var import_varint = __toESM(require_varint(), 1);
165
- var CIDV0_BYTES = {
166
- SHA2_256: 18,
167
- LENGTH: 32,
168
- DAG_PB: 112
169
- };
170
- var V2_HEADER_LENGTH = (
171
- /* characteristics */
172
- 16 + 8 + 8 + 8
173
- );
174
- function decodeVarint(bytes, seeker) {
175
- if (!bytes.length) {
176
- throw new Error("Unexpected end of data");
177
- }
178
- const i = import_varint.default.decode(bytes);
179
- seeker.seek(
180
- /** @type {number} */
181
- import_varint.default.decode.bytes
182
- );
183
- return i;
184
- }
185
- function decodeV2Header(bytes) {
186
- const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
187
- let offset = 0;
188
- const header = {
189
- version: 2,
190
- /** @type {[bigint, bigint]} */
191
- characteristics: [
192
- dv.getBigUint64(offset, true),
193
- dv.getBigUint64(offset += 8, true)
194
- ],
195
- dataOffset: Number(dv.getBigUint64(offset += 8, true)),
196
- dataSize: Number(dv.getBigUint64(offset += 8, true)),
197
- indexOffset: Number(dv.getBigUint64(offset += 8, true))
198
- };
199
- return header;
200
- }
201
- function getMultihashLength(bytes) {
202
- import_varint.default.decode(bytes);
203
- const codeLength = (
204
- /** @type {number} */
205
- import_varint.default.decode.bytes
206
- );
207
- const length = import_varint.default.decode(bytes.subarray(import_varint.default.decode.bytes));
208
- const lengthLength = (
209
- /** @type {number} */
210
- import_varint.default.decode.bytes
211
- );
212
- const mhLength = codeLength + lengthLength + length;
213
- return mhLength;
214
- }
215
-
216
- // ../../../node_modules/.pnpm/@ipld+car@5.2.4/node_modules/@ipld/car/src/header-validator.js
217
- var Kinds = {
218
- Null: (
219
- /** @returns {undefined|null} */
220
- (obj) => obj === null ? obj : void 0
221
- ),
222
- Int: (
223
- /** @returns {undefined|number} */
224
- (obj) => Number.isInteger(obj) ? obj : void 0
225
- ),
226
- Float: (
227
- /** @returns {undefined|number} */
228
- (obj) => typeof obj === "number" && Number.isFinite(obj) ? obj : void 0
229
- ),
230
- String: (
231
- /** @returns {undefined|string} */
232
- (obj) => typeof obj === "string" ? obj : void 0
233
- ),
234
- Bool: (
235
- /** @returns {undefined|boolean} */
236
- (obj) => typeof obj === "boolean" ? obj : void 0
237
- ),
238
- Bytes: (
239
- /** @returns {undefined|Uint8Array} */
240
- (obj) => obj instanceof Uint8Array ? obj : void 0
241
- ),
242
- Link: (
243
- /** @returns {undefined|object} */
244
- (obj) => obj !== null && typeof obj === "object" && obj.asCID === obj ? obj : void 0
245
- ),
246
- List: (
247
- /** @returns {undefined|Array<any>} */
248
- (obj) => Array.isArray(obj) ? obj : void 0
249
- ),
250
- Map: (
251
- /** @returns {undefined|object} */
252
- (obj) => obj !== null && typeof obj === "object" && obj.asCID !== obj && !Array.isArray(obj) && !(obj instanceof Uint8Array) ? obj : void 0
253
- )
254
- };
255
- var Types = {
256
- "CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)": Kinds.Link,
257
- "CarV1HeaderOrV2Pragma > roots (anon)": (
258
- /** @returns {undefined|any} */
259
- (obj) => {
260
- if (Kinds.List(obj) === void 0) {
261
- return void 0;
262
- }
263
- for (let i = 0; i < obj.length; i++) {
264
- let v = obj[i];
265
- v = Types["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](v);
266
- if (v === void 0) {
267
- return void 0;
268
- }
269
- if (v !== obj[i]) {
270
- const ret = obj.slice(0, i);
271
- for (let j = i; j < obj.length; j++) {
272
- let v2 = obj[j];
273
- v2 = Types["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](v2);
274
- if (v2 === void 0) {
275
- return void 0;
276
- }
277
- ret.push(v2);
278
- }
279
- return ret;
280
- }
281
- }
282
- return obj;
283
- }
284
- ),
285
- Int: Kinds.Int,
286
- CarV1HeaderOrV2Pragma: (
287
- /** @returns {undefined|any} */
288
- (obj) => {
289
- if (Kinds.Map(obj) === void 0) {
290
- return void 0;
291
- }
292
- const entries = Object.entries(obj);
293
- let ret = obj;
294
- let requiredCount = 1;
295
- for (let i = 0; i < entries.length; i++) {
296
- const [key, value] = entries[i];
297
- switch (key) {
298
- case "roots":
299
- {
300
- const v = Types["CarV1HeaderOrV2Pragma > roots (anon)"](obj[key]);
301
- if (v === void 0) {
302
- return void 0;
303
- }
304
- if (v !== value || ret !== obj) {
305
- if (ret === obj) {
306
- ret = {};
307
- for (let j = 0; j < i; j++) {
308
- ret[entries[j][0]] = entries[j][1];
309
- }
310
- }
311
- ret.roots = v;
312
- }
313
- }
314
- break;
315
- case "version":
316
- {
317
- requiredCount--;
318
- const v = Types.Int(obj[key]);
319
- if (v === void 0) {
320
- return void 0;
321
- }
322
- if (v !== value || ret !== obj) {
323
- if (ret === obj) {
324
- ret = {};
325
- for (let j = 0; j < i; j++) {
326
- ret[entries[j][0]] = entries[j][1];
327
- }
328
- }
329
- ret.version = v;
330
- }
331
- }
332
- break;
333
- default:
334
- return void 0;
335
- }
336
- }
337
- if (requiredCount > 0) {
338
- return void 0;
339
- }
340
- return ret;
341
- }
342
- )
343
- };
344
- var Reprs = {
345
- "CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)": Kinds.Link,
346
- "CarV1HeaderOrV2Pragma > roots (anon)": (
347
- /** @returns {undefined|any} */
348
- (obj) => {
349
- if (Kinds.List(obj) === void 0) {
350
- return void 0;
351
- }
352
- for (let i = 0; i < obj.length; i++) {
353
- let v = obj[i];
354
- v = Reprs["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](v);
355
- if (v === void 0) {
356
- return void 0;
357
- }
358
- if (v !== obj[i]) {
359
- const ret = obj.slice(0, i);
360
- for (let j = i; j < obj.length; j++) {
361
- let v2 = obj[j];
362
- v2 = Reprs["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](v2);
363
- if (v2 === void 0) {
364
- return void 0;
365
- }
366
- ret.push(v2);
367
- }
368
- return ret;
369
- }
370
- }
371
- return obj;
372
- }
373
- ),
374
- Int: Kinds.Int,
375
- CarV1HeaderOrV2Pragma: (
376
- /** @returns {undefined|any} */
377
- (obj) => {
378
- if (Kinds.Map(obj) === void 0) {
379
- return void 0;
380
- }
381
- const entries = Object.entries(obj);
382
- let ret = obj;
383
- let requiredCount = 1;
384
- for (let i = 0; i < entries.length; i++) {
385
- const [key, value] = entries[i];
386
- switch (key) {
387
- case "roots":
388
- {
389
- const v = Reprs["CarV1HeaderOrV2Pragma > roots (anon)"](value);
390
- if (v === void 0) {
391
- return void 0;
392
- }
393
- if (v !== value || ret !== obj) {
394
- if (ret === obj) {
395
- ret = {};
396
- for (let j = 0; j < i; j++) {
397
- ret[entries[j][0]] = entries[j][1];
398
- }
399
- }
400
- ret.roots = v;
401
- }
402
- }
403
- break;
404
- case "version":
405
- {
406
- requiredCount--;
407
- const v = Reprs.Int(value);
408
- if (v === void 0) {
409
- return void 0;
410
- }
411
- if (v !== value || ret !== obj) {
412
- if (ret === obj) {
413
- ret = {};
414
- for (let j = 0; j < i; j++) {
415
- ret[entries[j][0]] = entries[j][1];
416
- }
417
- }
418
- ret.version = v;
419
- }
420
- }
421
- break;
422
- default:
423
- return void 0;
424
- }
425
- }
426
- if (requiredCount > 0) {
427
- return void 0;
428
- }
429
- return ret;
430
- }
431
- )
432
- };
433
- var CarV1HeaderOrV2Pragma = {
434
- toTyped: Types.CarV1HeaderOrV2Pragma,
435
- toRepresentation: Reprs.CarV1HeaderOrV2Pragma
436
- };
437
-
438
- // ../../../node_modules/.pnpm/cborg@4.0.3/node_modules/cborg/lib/length.js
439
- var cborEncoders = makeCborEncoders();
440
-
441
- // ../../../node_modules/.pnpm/@ipld+car@5.2.4/node_modules/@ipld/car/src/buffer-writer.js
442
- var import_varint2 = __toESM(require_varint(), 1);
443
- var headerPreludeTokens = [
444
- new Token(Type.map, 2),
445
- new Token(Type.string, "version"),
446
- new Token(Type.uint, 1),
447
- new Token(Type.string, "roots")
448
- ];
449
- var CID_TAG = new Token(Type.tag, 42);
450
-
451
- // ../../../node_modules/.pnpm/@ipld+car@5.2.4/node_modules/@ipld/car/src/decoder.js
452
- async function readHeader(reader, strictVersion) {
453
- const length = decodeVarint(await reader.upTo(8), reader);
454
- if (length === 0) {
455
- throw new Error("Invalid CAR header (zero length)");
456
- }
457
- const header = await reader.exactly(length, true);
458
- const block = decode4(header);
459
- if (CarV1HeaderOrV2Pragma.toTyped(block) === void 0) {
460
- throw new Error("Invalid CAR header format");
461
- }
462
- if (block.version !== 1 && block.version !== 2 || strictVersion !== void 0 && block.version !== strictVersion) {
463
- throw new Error(`Invalid CAR version: ${block.version}${strictVersion !== void 0 ? ` (expected ${strictVersion})` : ""}`);
464
- }
465
- if (block.version === 1) {
466
- if (!Array.isArray(block.roots)) {
467
- throw new Error("Invalid CAR header format");
468
- }
469
- return block;
470
- }
471
- if (block.roots !== void 0) {
472
- throw new Error("Invalid CAR header format");
473
- }
474
- const v2Header = decodeV2Header(await reader.exactly(V2_HEADER_LENGTH, true));
475
- reader.seek(v2Header.dataOffset - reader.pos);
476
- const v1Header = await readHeader(reader, 1);
477
- return Object.assign(v1Header, v2Header);
478
- }
479
- async function readCid(reader) {
480
- const first = await reader.exactly(2, false);
481
- if (first[0] === CIDV0_BYTES.SHA2_256 && first[1] === CIDV0_BYTES.LENGTH) {
482
- const bytes2 = await reader.exactly(34, true);
483
- const multihash2 = decode2(bytes2);
484
- return CID.create(0, CIDV0_BYTES.DAG_PB, multihash2);
485
- }
486
- const version = decodeVarint(await reader.upTo(8), reader);
487
- if (version !== 1) {
488
- throw new Error(`Unexpected CID version (${version})`);
489
- }
490
- const codec = decodeVarint(await reader.upTo(8), reader);
491
- const bytes = await reader.exactly(getMultihashLength(await reader.upTo(8)), true);
492
- const multihash = decode2(bytes);
493
- return CID.create(version, codec, multihash);
494
- }
495
- async function readBlockHead(reader) {
496
- const start = reader.pos;
497
- let length = decodeVarint(await reader.upTo(8), reader);
498
- if (length === 0) {
499
- throw new Error("Invalid CAR section (zero length)");
500
- }
501
- length += reader.pos - start;
502
- const cid = await readCid(reader);
503
- const blockLength = length - Number(reader.pos - start);
504
- return { cid, length, blockLength };
505
- }
506
- async function readBlock(reader) {
507
- const { cid, blockLength } = await readBlockHead(reader);
508
- const bytes = await reader.exactly(blockLength, true);
509
- return { bytes, cid };
510
- }
511
- async function readBlockIndex(reader) {
512
- const offset = reader.pos;
513
- const { cid, length, blockLength } = await readBlockHead(reader);
514
- const index = { cid, length, blockLength, offset, blockOffset: reader.pos };
515
- reader.seek(index.blockLength);
516
- return index;
517
- }
518
- function createDecoder(reader) {
519
- const headerPromise = (async () => {
520
- const header = await readHeader(reader);
521
- if (header.version === 2) {
522
- const v1length = reader.pos - header.dataOffset;
523
- reader = limitReader(reader, header.dataSize - v1length);
524
- }
525
- return header;
526
- })();
527
- return {
528
- header: () => headerPromise,
529
- async *blocks() {
530
- await headerPromise;
531
- while ((await reader.upTo(8)).length > 0) {
532
- yield await readBlock(reader);
533
- }
534
- },
535
- async *blocksIndex() {
536
- await headerPromise;
537
- while ((await reader.upTo(8)).length > 0) {
538
- yield await readBlockIndex(reader);
539
- }
540
- }
541
- };
542
- }
543
- function bytesReader(bytes) {
544
- let pos = 0;
545
- return {
546
- async upTo(length) {
547
- const out = bytes.subarray(pos, pos + Math.min(length, bytes.length - pos));
548
- return out;
549
- },
550
- async exactly(length, seek = false) {
551
- if (length > bytes.length - pos) {
552
- throw new Error("Unexpected end of data");
553
- }
554
- const out = bytes.subarray(pos, pos + length);
555
- if (seek) {
556
- pos += length;
557
- }
558
- return out;
559
- },
560
- seek(length) {
561
- pos += length;
562
- },
563
- get pos() {
564
- return pos;
565
- }
566
- };
567
- }
568
- function chunkReader(readChunk) {
569
- let pos = 0;
570
- let have = 0;
571
- let offset = 0;
572
- let currentChunk = new Uint8Array(0);
573
- const read = async (length) => {
574
- have = currentChunk.length - offset;
575
- const bufa = [currentChunk.subarray(offset)];
576
- while (have < length) {
577
- const chunk = await readChunk();
578
- if (chunk == null) {
579
- break;
580
- }
581
- if (have < 0) {
582
- if (chunk.length > have) {
583
- bufa.push(chunk.subarray(-have));
584
- }
585
- } else {
586
- bufa.push(chunk);
587
- }
588
- have += chunk.length;
589
- }
590
- currentChunk = new Uint8Array(bufa.reduce((p, c) => p + c.length, 0));
591
- let off = 0;
592
- for (const b of bufa) {
593
- currentChunk.set(b, off);
594
- off += b.length;
595
- }
596
- offset = 0;
597
- };
598
- return {
599
- async upTo(length) {
600
- if (currentChunk.length - offset < length) {
601
- await read(length);
602
- }
603
- return currentChunk.subarray(offset, offset + Math.min(currentChunk.length - offset, length));
604
- },
605
- async exactly(length, seek = false) {
606
- if (currentChunk.length - offset < length) {
607
- await read(length);
608
- }
609
- if (currentChunk.length - offset < length) {
610
- throw new Error("Unexpected end of data");
611
- }
612
- const out = currentChunk.subarray(offset, offset + length);
613
- if (seek) {
614
- pos += length;
615
- offset += length;
616
- }
617
- return out;
618
- },
619
- seek(length) {
620
- pos += length;
621
- offset += length;
622
- },
623
- get pos() {
624
- return pos;
625
- }
626
- };
627
- }
628
- function asyncIterableReader(asyncIterable) {
629
- const iterator = asyncIterable[Symbol.asyncIterator]();
630
- async function readChunk() {
631
- const next = await iterator.next();
632
- if (next.done) {
633
- return null;
634
- }
635
- return next.value;
636
- }
637
- return chunkReader(readChunk);
638
- }
639
- function limitReader(reader, byteLimit) {
640
- let bytesRead = 0;
641
- return {
642
- async upTo(length) {
643
- let bytes = await reader.upTo(length);
644
- if (bytes.length + bytesRead > byteLimit) {
645
- bytes = bytes.subarray(0, byteLimit - bytesRead);
646
- }
647
- return bytes;
648
- },
649
- async exactly(length, seek = false) {
650
- const bytes = await reader.exactly(length, seek);
651
- if (bytes.length + bytesRead > byteLimit) {
652
- throw new Error("Unexpected end of data");
653
- }
654
- if (seek) {
655
- bytesRead += length;
656
- }
657
- return bytes;
658
- },
659
- seek(length) {
660
- bytesRead += length;
661
- reader.seek(length);
662
- },
663
- get pos() {
664
- return reader.pos;
665
- }
666
- };
667
- }
668
-
669
- // ../../../node_modules/.pnpm/@ipld+car@5.2.4/node_modules/@ipld/car/src/indexer.js
670
- var CarIndexer = class {
671
- /**
672
- * @param {number} version
673
- * @param {CID[]} roots
674
- * @param {AsyncGenerator<BlockIndex>} iterator
675
- */
676
- constructor(version, roots, iterator) {
677
- this._version = version;
678
- this._roots = roots;
679
- this._iterator = iterator;
680
- }
681
- get version() {
682
- return this._version;
683
- }
684
- /**
685
- * Get the list of roots defined by the CAR referenced by this indexer. May be
686
- * zero or more `CID`s.
687
- *
688
- * @function
689
- * @memberof CarIndexer
690
- * @instance
691
- * @async
692
- * @returns {Promise<CID[]>}
693
- */
694
- async getRoots() {
695
- return this._roots;
696
- }
697
- /**
698
- * @returns {AsyncIterator<BlockIndex>}
699
- */
700
- [Symbol.asyncIterator]() {
701
- return this._iterator;
702
- }
703
- /**
704
- * Instantiate a {@link CarIndexer} from a `Uint8Array` blob. Only the header
705
- * is decoded initially, the remainder is processed and emitted via the
706
- * iterator as it is consumed.
707
- *
708
- * @async
709
- * @static
710
- * @memberof CarIndexer
711
- * @param {Uint8Array} bytes
712
- * @returns {Promise<CarIndexer>}
713
- */
714
- static async fromBytes(bytes) {
715
- if (!(bytes instanceof Uint8Array)) {
716
- throw new TypeError("fromBytes() requires a Uint8Array");
717
- }
718
- return decodeIndexerComplete(bytesReader(bytes));
719
- }
720
- /**
721
- * Instantiate a {@link CarIndexer} from a `AsyncIterable<Uint8Array>`,
722
- * such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
723
- * is decoded initially, the remainder is processed and emitted via the
724
- * iterator as it is consumed.
725
- *
726
- * @async
727
- * @static
728
- * @memberof CarIndexer
729
- * @param {AsyncIterable<Uint8Array>} asyncIterable
730
- * @returns {Promise<CarIndexer>}
731
- */
732
- static async fromIterable(asyncIterable) {
733
- if (!asyncIterable || !(typeof asyncIterable[Symbol.asyncIterator] === "function")) {
734
- throw new TypeError("fromIterable() requires an async iterable");
735
- }
736
- return decodeIndexerComplete(asyncIterableReader(asyncIterable));
737
- }
738
- };
739
- async function decodeIndexerComplete(reader) {
740
- const decoder = createDecoder(reader);
741
- const { version, roots } = await decoder.header();
742
- return new CarIndexer(version, roots, decoder.blocksIndex());
743
- }
744
-
745
- // ../../../node_modules/.pnpm/@ipld+car@5.2.4/node_modules/@ipld/car/src/iterator.js
746
- var CarIteratorBase = class {
747
- /**
748
- * @param {number} version
749
- * @param {CID[]} roots
750
- * @param {AsyncIterable<Block>|void} iterable
751
- */
752
- constructor(version, roots, iterable) {
753
- this._version = version;
754
- this._roots = roots;
755
- this._iterable = iterable;
756
- this._decoded = false;
757
- }
758
- get version() {
759
- return this._version;
760
- }
761
- /**
762
- * @returns {Promise<CID[]>}
763
- */
764
- async getRoots() {
765
- return this._roots;
766
- }
767
- };
768
- var CarBlockIterator = class _CarBlockIterator extends CarIteratorBase {
769
- // inherited method
770
- /**
771
- * Get the list of roots defined by the CAR referenced by this iterator. May be
772
- * zero or more `CID`s.
773
- *
774
- * @function getRoots
775
- * @memberof CarBlockIterator
776
- * @instance
777
- * @async
778
- * @returns {Promise<CID[]>}
779
- */
780
- /**
781
- * @returns {AsyncIterator<Block>}
782
- */
783
- [Symbol.asyncIterator]() {
784
- if (this._decoded) {
785
- throw new Error("Cannot decode more than once");
786
- }
787
- if (!this._iterable) {
788
- throw new Error("Block iterable not found");
789
- }
790
- this._decoded = true;
791
- return this._iterable[Symbol.asyncIterator]();
792
- }
793
- /**
794
- * Instantiate a {@link CarBlockIterator} from a `Uint8Array` blob. Rather
795
- * than decoding the entire byte array prior to returning the iterator, as in
796
- * {@link CarReader.fromBytes}, only the header is decoded and the remainder
797
- * of the CAR is parsed as the `Block`s as yielded.
798
- *
799
- * @async
800
- * @static
801
- * @memberof CarBlockIterator
802
- * @param {Uint8Array} bytes
803
- * @returns {Promise<CarBlockIterator>}
804
- */
805
- static async fromBytes(bytes) {
806
- const { version, roots, iterator } = await fromBytes2(bytes);
807
- return new _CarBlockIterator(version, roots, iterator);
808
- }
809
- /**
810
- * Instantiate a {@link CarBlockIterator} from a `AsyncIterable<Uint8Array>`,
811
- * such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
812
- * Rather than decoding the entire byte array prior to returning the iterator,
813
- * as in {@link CarReader.fromIterable}, only the header is decoded and the
814
- * remainder of the CAR is parsed as the `Block`s as yielded.
815
- *
816
- * @async
817
- * @static
818
- * @param {AsyncIterable<Uint8Array>} asyncIterable
819
- * @returns {Promise<CarBlockIterator>}
820
- */
821
- static async fromIterable(asyncIterable) {
822
- const { version, roots, iterator } = await fromIterable(asyncIterable);
823
- return new _CarBlockIterator(version, roots, iterator);
824
- }
825
- };
826
- var CarCIDIterator = class _CarCIDIterator extends CarIteratorBase {
827
- // inherited method
828
- /**
829
- * Get the list of roots defined by the CAR referenced by this iterator. May be
830
- * zero or more `CID`s.
831
- *
832
- * @function getRoots
833
- * @memberof CarCIDIterator
834
- * @instance
835
- * @async
836
- * @returns {Promise<CID[]>}
837
- */
838
- /**
839
- * @returns {AsyncIterator<CID>}
840
- */
841
- [Symbol.asyncIterator]() {
842
- if (this._decoded) {
843
- throw new Error("Cannot decode more than once");
844
- }
845
- if (!this._iterable) {
846
- throw new Error("Block iterable not found");
847
- }
848
- this._decoded = true;
849
- const iterable = this._iterable[Symbol.asyncIterator]();
850
- return {
851
- async next() {
852
- const next = await iterable.next();
853
- if (next.done) {
854
- return next;
855
- }
856
- return { done: false, value: next.value.cid };
857
- }
858
- };
859
- }
860
- /**
861
- * Instantiate a {@link CarCIDIterator} from a `Uint8Array` blob. Rather
862
- * than decoding the entire byte array prior to returning the iterator, as in
863
- * {@link CarReader.fromBytes}, only the header is decoded and the remainder
864
- * of the CAR is parsed as the `CID`s as yielded.
865
- *
866
- * @async
867
- * @static
868
- * @memberof CarCIDIterator
869
- * @param {Uint8Array} bytes
870
- * @returns {Promise<CarCIDIterator>}
871
- */
872
- static async fromBytes(bytes) {
873
- const { version, roots, iterator } = await fromBytes2(bytes);
874
- return new _CarCIDIterator(version, roots, iterator);
875
- }
876
- /**
877
- * Instantiate a {@link CarCIDIterator} from a `AsyncIterable<Uint8Array>`,
878
- * such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
879
- * Rather than decoding the entire byte array prior to returning the iterator,
880
- * as in {@link CarReader.fromIterable}, only the header is decoded and the
881
- * remainder of the CAR is parsed as the `CID`s as yielded.
882
- *
883
- * @async
884
- * @static
885
- * @memberof CarCIDIterator
886
- * @param {AsyncIterable<Uint8Array>} asyncIterable
887
- * @returns {Promise<CarCIDIterator>}
888
- */
889
- static async fromIterable(asyncIterable) {
890
- const { version, roots, iterator } = await fromIterable(asyncIterable);
891
- return new _CarCIDIterator(version, roots, iterator);
892
- }
893
- };
894
- async function fromBytes2(bytes) {
895
- if (!(bytes instanceof Uint8Array)) {
896
- throw new TypeError("fromBytes() requires a Uint8Array");
897
- }
898
- return decodeIterator(bytesReader(bytes));
899
- }
900
- async function fromIterable(asyncIterable) {
901
- if (!asyncIterable || !(typeof asyncIterable[Symbol.asyncIterator] === "function")) {
902
- throw new TypeError("fromIterable() requires an async iterable");
903
- }
904
- return decodeIterator(asyncIterableReader(asyncIterable));
905
- }
906
- async function decodeIterator(reader) {
907
- const decoder = createDecoder(reader);
908
- const { version, roots } = await decoder.header();
909
- return { version, roots, iterator: decoder.blocks() };
910
- }
911
-
912
- // ../../../node_modules/.pnpm/@ipld+car@5.2.4/node_modules/@ipld/car/src/encoder.js
913
- var import_varint3 = __toESM(require_varint(), 1);
914
- function createHeader(roots) {
915
- const headerBytes = encode2({ version: 1, roots });
916
- const varintBytes = import_varint3.default.encode(headerBytes.length);
917
- const header = new Uint8Array(varintBytes.length + headerBytes.length);
918
- header.set(varintBytes, 0);
919
- header.set(headerBytes, varintBytes.length);
920
- return header;
921
- }
922
- function createEncoder(writer) {
923
- return {
924
- /**
925
- * @param {CID[]} roots
926
- * @returns {Promise<void>}
927
- */
928
- async setRoots(roots) {
929
- const bytes = createHeader(roots);
930
- await writer.write(bytes);
931
- },
932
- /**
933
- * @param {Block} block
934
- * @returns {Promise<void>}
935
- */
936
- async writeBlock(block) {
937
- const { cid, bytes } = block;
938
- await writer.write(new Uint8Array(import_varint3.default.encode(cid.bytes.length + bytes.length)));
939
- await writer.write(cid.bytes);
940
- if (bytes.length) {
941
- await writer.write(bytes);
942
- }
943
- },
944
- /**
945
- * @returns {Promise<void>}
946
- */
947
- async close() {
948
- await writer.end();
949
- }
950
- };
951
- }
952
-
953
- // ../../../node_modules/.pnpm/@ipld+car@5.2.4/node_modules/@ipld/car/src/iterator-channel.js
954
- function noop() {
955
- }
956
- function create() {
957
- const chunkQueue = [];
958
- let drainer = null;
959
- let drainerResolver = noop;
960
- let ended = false;
961
- let outWait = null;
962
- let outWaitResolver = noop;
963
- const makeDrainer = () => {
964
- if (!drainer) {
965
- drainer = new Promise((resolve) => {
966
- drainerResolver = () => {
967
- drainer = null;
968
- drainerResolver = noop;
969
- resolve();
970
- };
971
- });
972
- }
973
- return drainer;
974
- };
975
- const writer = {
976
- /**
977
- * @param {T} chunk
978
- * @returns {Promise<void>}
979
- */
980
- write(chunk) {
981
- chunkQueue.push(chunk);
982
- const drainer2 = makeDrainer();
983
- outWaitResolver();
984
- return drainer2;
985
- },
986
- async end() {
987
- ended = true;
988
- const drainer2 = makeDrainer();
989
- outWaitResolver();
990
- await drainer2;
991
- }
992
- };
993
- const iterator = {
994
- /** @returns {Promise<IteratorResult<T>>} */
995
- async next() {
996
- const chunk = chunkQueue.shift();
997
- if (chunk) {
998
- if (chunkQueue.length === 0) {
999
- drainerResolver();
1000
- }
1001
- return { done: false, value: chunk };
1002
- }
1003
- if (ended) {
1004
- drainerResolver();
1005
- return { done: true, value: void 0 };
1006
- }
1007
- if (!outWait) {
1008
- outWait = new Promise((resolve) => {
1009
- outWaitResolver = () => {
1010
- outWait = null;
1011
- outWaitResolver = noop;
1012
- return resolve(iterator.next());
1013
- };
1014
- });
1015
- }
1016
- return outWait;
1017
- }
1018
- };
1019
- return { writer, iterator };
1020
- }
1021
-
1022
- // ../../../node_modules/.pnpm/@ipld+car@5.2.4/node_modules/@ipld/car/src/writer-browser.js
1023
- var CarWriter = class _CarWriter {
1024
- /**
1025
- * @param {CID[]} roots
1026
- * @param {CarEncoder} encoder
1027
- */
1028
- constructor(roots, encoder) {
1029
- this._encoder = encoder;
1030
- this._mutex = encoder.setRoots(roots);
1031
- this._ended = false;
1032
- }
1033
- /**
1034
- * Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
1035
- *
1036
- * @function
1037
- * @memberof CarWriter
1038
- * @instance
1039
- * @async
1040
- * @param {Block} block - A `{ cid:CID, bytes:Uint8Array }` pair.
1041
- * @returns {Promise<void>} The returned promise will only resolve once the
1042
- * bytes this block generates are written to the `out` iterable.
1043
- */
1044
- async put(block) {
1045
- if (!(block.bytes instanceof Uint8Array) || !block.cid) {
1046
- throw new TypeError("Can only write {cid, bytes} objects");
1047
- }
1048
- if (this._ended) {
1049
- throw new Error("Already closed");
1050
- }
1051
- const cid = CID.asCID(block.cid);
1052
- if (!cid) {
1053
- throw new TypeError("Can only write {cid, bytes} objects");
1054
- }
1055
- this._mutex = this._mutex.then(() => this._encoder.writeBlock({ cid, bytes: block.bytes }));
1056
- return this._mutex;
1057
- }
1058
- /**
1059
- * Finalise the CAR archive and signal that the `out` iterable should end once
1060
- * any remaining bytes are written.
1061
- *
1062
- * @function
1063
- * @memberof CarWriter
1064
- * @instance
1065
- * @async
1066
- * @returns {Promise<void>}
1067
- */
1068
- async close() {
1069
- if (this._ended) {
1070
- throw new Error("Already closed");
1071
- }
1072
- await this._mutex;
1073
- this._ended = true;
1074
- return this._encoder.close();
1075
- }
1076
- /**
1077
- * Create a new CAR writer "channel" which consists of a
1078
- * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair.
1079
- *
1080
- * @async
1081
- * @static
1082
- * @memberof CarWriter
1083
- * @param {CID[] | CID | void} roots
1084
- * @returns {WriterChannel} The channel takes the form of
1085
- * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
1086
- */
1087
- static create(roots) {
1088
- roots = toRoots(roots);
1089
- const { encoder, iterator } = encodeWriter();
1090
- const writer = new _CarWriter(roots, encoder);
1091
- const out = new CarWriterOut(iterator);
1092
- return { writer, out };
1093
- }
1094
- /**
1095
- * Create a new CAR appender "channel" which consists of a
1096
- * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair.
1097
- * This appender does not consider roots and does not produce a CAR header.
1098
- * It is designed to append blocks to an _existing_ CAR archive. It is
1099
- * expected that `out` will be concatenated onto the end of an existing
1100
- * archive that already has a properly formatted header.
1101
- *
1102
- * @async
1103
- * @static
1104
- * @memberof CarWriter
1105
- * @returns {WriterChannel} The channel takes the form of
1106
- * `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
1107
- */
1108
- static createAppender() {
1109
- const { encoder, iterator } = encodeWriter();
1110
- encoder.setRoots = () => Promise.resolve();
1111
- const writer = new _CarWriter([], encoder);
1112
- const out = new CarWriterOut(iterator);
1113
- return { writer, out };
1114
- }
1115
- /**
1116
- * Update the list of roots in the header of an existing CAR as represented
1117
- * in a Uint8Array.
1118
- *
1119
- * This operation is an _overwrite_, the total length of the CAR will not be
1120
- * modified. A rejection will occur if the new header will not be the same
1121
- * length as the existing header, in which case the CAR will not be modified.
1122
- * It is the responsibility of the user to ensure that the roots being
1123
- * replaced encode as the same length as the new roots.
1124
- *
1125
- * The byte array passed in an argument will be modified and also returned
1126
- * upon successful modification.
1127
- *
1128
- * @async
1129
- * @static
1130
- * @memberof CarWriter
1131
- * @param {Uint8Array} bytes
1132
- * @param {CID[]} roots - A new list of roots to replace the existing list in
1133
- * the CAR header. The new header must take up the same number of bytes as the
1134
- * existing header, so the roots should collectively be the same byte length
1135
- * as the existing roots.
1136
- * @returns {Promise<Uint8Array>}
1137
- */
1138
- static async updateRootsInBytes(bytes, roots) {
1139
- const reader = bytesReader(bytes);
1140
- await readHeader(reader);
1141
- const newHeader = createHeader(roots);
1142
- if (Number(reader.pos) !== newHeader.length) {
1143
- throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${reader.pos} bytes, new header is ${newHeader.length} bytes)`);
1144
- }
1145
- bytes.set(newHeader, 0);
1146
- return bytes;
1147
- }
1148
- };
1149
- var CarWriterOut = class {
1150
- /**
1151
- * @param {AsyncIterator<Uint8Array>} iterator
1152
- */
1153
- constructor(iterator) {
1154
- this._iterator = iterator;
1155
- }
1156
- [Symbol.asyncIterator]() {
1157
- if (this._iterating) {
1158
- throw new Error("Multiple iterator not supported");
1159
- }
1160
- this._iterating = true;
1161
- return this._iterator;
1162
- }
1163
- };
1164
- function encodeWriter() {
1165
- const iw = create();
1166
- const { writer, iterator } = iw;
1167
- const encoder = createEncoder(writer);
1168
- return { encoder, iterator };
1169
- }
1170
- function toRoots(roots) {
1171
- if (roots === void 0) {
1172
- return [];
1173
- }
1174
- if (!Array.isArray(roots)) {
1175
- const cid = CID.asCID(roots);
1176
- if (!cid) {
1177
- throw new TypeError("roots must be a single CID or an array of CIDs");
1178
- }
1179
- return [cid];
1180
- }
1181
- const _roots = [];
1182
- for (const root of roots) {
1183
- const _root = CID.asCID(root);
1184
- if (!_root) {
1185
- throw new TypeError("roots must be a single CID or an array of CIDs");
1186
- }
1187
- _roots.push(_root);
1188
- }
1189
- return _roots;
1190
- }
1191
-
1192
- // src/ipfs/car.ts
1193
- var { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO);
1194
- async function decodeCarToApplogs(car) {
1195
- const { roots, blocks } = await decodeCar(car);
1196
- if (!roots || !blocks) {
1197
- throw ERROR("decodeCar is funky", { roots, blocks });
1198
- }
1199
- if (roots.length !== 1) {
1200
- WARN("Unexpected roots count:", roots);
1201
- }
1202
- const root = blocks.get(roots[0]);
1203
- let applogArr;
1204
- DEBUG(`root:`, root, { blocks });
1205
- if (root.info) {
1206
- applogArr = blocks.get(root.applogs.toString()).logs;
1207
- DEBUG(`new format - infoLogs`, blocks.get(root.info.toString()));
1208
- } else {
1209
- applogArr = root.applogs;
1210
- }
1211
- let applogs;
1212
- applogs = applogArr.map((cidOrLink) => {
1213
- const cid = cidOrLink.toV1 ? cidOrLink.toV1().toString() : cidOrLink["/"];
1214
- const applog = blocks.get(cid);
1215
- if (!applog)
1216
- throw ERROR(`Could not find applog CID in Car file:`, cid, { root, blocks });
1217
- return {
1218
- ...applog,
1219
- cid
1220
- };
1221
- });
1222
- DEBUG("Decoded car logs:", root, { roots, blocks, applogs });
1223
- return { applogs };
1224
- }
1225
- async function decodeCar(car) {
1226
- const roots = (await car.getRoots()).map((c) => c.toV1().toString());
1227
- const blocks = /* @__PURE__ */ new Map();
1228
- for await (const { cid, bytes } of car.blocks()) {
1229
- blocks.set(cid.toV1().toString(), decode3(bytes));
1230
- }
1231
- return { roots, blocks };
1232
- }
1233
- async function makeCarOut(roots, blocks) {
1234
- const { writer, out } = CarWriter.create(Array.isArray(roots) ? roots : [roots]);
1235
- VERBOSE(`Writing ${blocks.length} blocks to CAR`, { roots, blocks });
1236
- blocks.forEach((b) => writer.put(b));
1237
- writer.close();
1238
- return out;
1239
- }
1240
- async function makeCarBlob(roots, blocks) {
1241
- const carOut = await makeCarOut(roots, blocks);
1242
- const chunks = [];
1243
- for await (const chunk of carOut) {
1244
- chunks.push(chunk);
1245
- }
1246
- const blob = new Blob(chunks);
1247
- return blob;
1248
- }
1249
-
1250
- export {
1251
- decodeCarToApplogs,
1252
- decodeCar,
1253
- makeCarOut,
1254
- makeCarBlob
1255
- };
1256
- //# sourceMappingURL=chunk-2UCPKUQK.min.js.map