@pkcprotocol/pkc-js 0.0.142 → 0.0.144

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 (128) hide show
  1. package/README.md +1 -0
  2. package/dist/browser/clients/base-client-manager.d.ts +7 -1
  3. package/dist/browser/clients/base-client-manager.js +106 -28
  4. package/dist/browser/clients/base-client-manager.js.map +1 -1
  5. package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +2 -0
  6. package/dist/browser/clients/rpc-client/schema.d.ts +2 -0
  7. package/dist/browser/community/community-client-manager.js +40 -24
  8. package/dist/browser/community/community-client-manager.js.map +1 -1
  9. package/dist/browser/community/schema.d.ts +19 -0
  10. package/dist/browser/community/schema.js +7 -3
  11. package/dist/browser/community/schema.js.map +1 -1
  12. package/dist/browser/generated-version.d.ts +1 -1
  13. package/dist/browser/generated-version.js +1 -1
  14. package/dist/browser/index-with-compile-cache.d.ts +2 -0
  15. package/dist/browser/index.d.ts +4 -0
  16. package/dist/browser/object-key-util.js +5 -1
  17. package/dist/browser/object-key-util.js.map +1 -1
  18. package/dist/browser/pages/pkc-js-page-sorts/top.js +2 -1
  19. package/dist/browser/pages/pkc-js-page-sorts/top.js.map +1 -1
  20. package/dist/browser/pages/schema.js +3 -1
  21. package/dist/browser/pages/schema.js.map +1 -1
  22. package/dist/browser/pkc/pkc.d.ts +2 -1
  23. package/dist/browser/pkc/pkc.js +12 -2
  24. package/dist/browser/pkc/pkc.js.map +1 -1
  25. package/dist/browser/publications/comment/comment-client-manager.js +5 -2
  26. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
  27. package/dist/browser/publications/comment/comment.js +4 -1
  28. package/dist/browser/publications/comment/comment.js.map +1 -1
  29. package/dist/browser/publications/community-edit/schema.d.ts +8 -0
  30. package/dist/browser/pubsub-messages/schema.d.ts +4 -0
  31. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +2 -0
  32. package/dist/browser/rpc/src/schema.d.ts +12 -0
  33. package/dist/browser/runtime/node/community/db-handler.d.ts +3 -0
  34. package/dist/browser/runtime/node/community/db-handler.js +17 -2
  35. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  36. package/dist/browser/runtime/node/community/local-community/comment-updates.d.ts +1 -0
  37. package/dist/browser/runtime/node/community/local-community/comment-updates.js +70 -19
  38. package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
  39. package/dist/browser/runtime/node/community/local-community/post-updates-bucket.d.ts +14 -0
  40. package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js +206 -0
  41. package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js.map +1 -0
  42. package/dist/browser/runtime/node/community/local-community.d.ts +1 -0
  43. package/dist/browser/runtime/node/community/local-community.js +4 -0
  44. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  45. package/dist/browser/runtime/node/community/page-sorts/index.js +10 -10
  46. package/dist/browser/runtime/node/community/page-sorts/index.js.map +1 -1
  47. package/dist/browser/schema/schema-util.d.ts +8 -0
  48. package/dist/browser/schema.d.ts +16 -0
  49. package/dist/browser/util/inflight-fetch-manager.d.ts +7 -2
  50. package/dist/browser/util/inflight-fetch-manager.js +49 -7
  51. package/dist/browser/util/inflight-fetch-manager.js.map +1 -1
  52. package/dist/browser/util.d.ts +1 -0
  53. package/dist/browser/util.js +23 -5
  54. package/dist/browser/util.js.map +1 -1
  55. package/dist/bundled/bundle-manifest.json +165 -123
  56. package/dist/bundled/challenges.js +1 -1
  57. package/dist/bundled/chunks/{helia-for-pkc-pBsoz9YH.js → helia-for-pkc--Xw7hTTu.js} +33 -33
  58. package/dist/bundled/chunks/{local-community-B9D4Iu_Q.js → local-community-CH8vMgTr.js} +1 -1
  59. package/dist/bundled/chunks/{local-community-B4rXLDqy.js → local-community-DCVtQSci.js} +282 -45
  60. package/dist/bundled/chunks/{node-CsvN3ADZ.js → node-Coyk7lC6.js} +13 -10
  61. package/dist/bundled/chunks/{page-sort-scoring-2Q6exRbl.js → page-sort-scoring-DaW6urZ2.js} +1 -1
  62. package/dist/bundled/chunks/{rpc-local-community-D3V1Sto-.js → rpc-local-community-KgRrTYjv.js} +154 -58
  63. package/dist/bundled/chunks/src-ABfmT8J2.js +2323 -0
  64. package/dist/bundled/chunks/src-BC60-Q7v.js +2 -0
  65. package/dist/bundled/chunks/src-BHqirG63.js +2 -0
  66. package/dist/bundled/chunks/{src-BggJ_InF.js → src-Bj5iE3qB.js} +2 -1999
  67. package/dist/bundled/chunks/src-CNab3O7M.js +2001 -0
  68. package/dist/bundled/chunks/{src-BsiPSkhv.js → src-ltPxiZKf.js} +1312 -3632
  69. package/dist/bundled/chunks/{util-DVrZupXz.js → util-BYT-7zVn.js} +24 -9
  70. package/dist/bundled/chunks/{util-LhCb7940.js → util-DN7FMpHT.js} +1 -1
  71. package/dist/bundled/chunks/{validate-package-factories-Bl2AyT4N.js → validate-package-factories-CPVyODKw.js} +2 -2
  72. package/dist/bundled/index.js +1 -1
  73. package/dist/bundled/page-sorts.js +1 -1
  74. package/dist/bundled/rpc/src/index.js +4 -4
  75. package/dist/node/clients/base-client-manager.d.ts +7 -1
  76. package/dist/node/clients/base-client-manager.js +106 -28
  77. package/dist/node/clients/base-client-manager.js.map +1 -1
  78. package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +2 -0
  79. package/dist/node/clients/rpc-client/schema.d.ts +2 -0
  80. package/dist/node/community/community-client-manager.js +40 -24
  81. package/dist/node/community/community-client-manager.js.map +1 -1
  82. package/dist/node/community/schema.d.ts +19 -0
  83. package/dist/node/community/schema.js +7 -3
  84. package/dist/node/community/schema.js.map +1 -1
  85. package/dist/node/generated-version.d.ts +1 -1
  86. package/dist/node/generated-version.js +1 -1
  87. package/dist/node/index-with-compile-cache.d.ts +2 -0
  88. package/dist/node/index.d.ts +4 -0
  89. package/dist/node/object-key-util.js +5 -1
  90. package/dist/node/object-key-util.js.map +1 -1
  91. package/dist/node/pages/pkc-js-page-sorts/top.js +2 -1
  92. package/dist/node/pages/pkc-js-page-sorts/top.js.map +1 -1
  93. package/dist/node/pages/schema.js +3 -1
  94. package/dist/node/pages/schema.js.map +1 -1
  95. package/dist/node/pkc/pkc.d.ts +2 -1
  96. package/dist/node/pkc/pkc.js +12 -2
  97. package/dist/node/pkc/pkc.js.map +1 -1
  98. package/dist/node/publications/comment/comment-client-manager.js +5 -2
  99. package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
  100. package/dist/node/publications/comment/comment.js +4 -1
  101. package/dist/node/publications/comment/comment.js.map +1 -1
  102. package/dist/node/publications/community-edit/schema.d.ts +8 -0
  103. package/dist/node/pubsub-messages/schema.d.ts +4 -0
  104. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +2 -0
  105. package/dist/node/rpc/src/schema.d.ts +12 -0
  106. package/dist/node/runtime/node/community/db-handler.d.ts +3 -0
  107. package/dist/node/runtime/node/community/db-handler.js +17 -2
  108. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  109. package/dist/node/runtime/node/community/local-community/comment-updates.d.ts +1 -0
  110. package/dist/node/runtime/node/community/local-community/comment-updates.js +70 -19
  111. package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
  112. package/dist/node/runtime/node/community/local-community/post-updates-bucket.d.ts +14 -0
  113. package/dist/node/runtime/node/community/local-community/post-updates-bucket.js +206 -0
  114. package/dist/node/runtime/node/community/local-community/post-updates-bucket.js.map +1 -0
  115. package/dist/node/runtime/node/community/local-community.d.ts +1 -0
  116. package/dist/node/runtime/node/community/local-community.js +4 -0
  117. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  118. package/dist/node/runtime/node/community/page-sorts/index.js +10 -10
  119. package/dist/node/runtime/node/community/page-sorts/index.js.map +1 -1
  120. package/dist/node/schema/schema-util.d.ts +8 -0
  121. package/dist/node/schema.d.ts +16 -0
  122. package/dist/node/util/inflight-fetch-manager.d.ts +7 -2
  123. package/dist/node/util/inflight-fetch-manager.js +49 -7
  124. package/dist/node/util/inflight-fetch-manager.js.map +1 -1
  125. package/dist/node/util.d.ts +1 -0
  126. package/dist/node/util.js +23 -5
  127. package/dist/node/util.js.map +1 -1
  128. package/package.json +4 -1
@@ -1,6 +1,7 @@
1
1
  import { i as __toESM, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
2
  import { n as batch, t as parallelBatch } from "./src-DKntVmyX.js";
3
3
  import { i as first, n as src_exports, r as prepare, t as encode } from "./src-evzEHW9W.js";
4
+ import { t as UnixFS } from "./src-CNab3O7M.js";
4
5
  import { CID } from "multiformats/cid";
5
6
  import { fromString } from "uint8arrays/from-string";
6
7
  import { equals } from "uint8arrays/equals";
@@ -8,7 +9,6 @@ import { concat } from "uint8arrays/concat";
8
9
  import { sha256 } from "multiformats/hashes/sha2";
9
10
  import * as raw from "multiformats/codecs/raw";
10
11
  import { alloc, allocUnsafe } from "uint8arrays/alloc";
11
- import { withArrayBuffer } from "uint8arrays/with-array-buffer";
12
12
  import { murmur3128 } from "@multiformats/murmur3";
13
13
  import { BlackHoleBlockstore } from "blockstore-core/black-hole";
14
14
  //#region node_modules/ipfs-unixfs-importer/node_modules/uint8arraylist/dist/src/index.js
@@ -485,2003 +485,6 @@ const fixedSize = (options = {}) => {
485
485
  };
486
486
  };
487
487
  //#endregion
488
- //#region node_modules/ipfs-unixfs/dist/src/errors.js
489
- var InvalidTypeError = class InvalidTypeError extends Error {
490
- static name = "InvalidTypeError";
491
- static code = "ERR_INVALID_TYPE";
492
- name = InvalidTypeError.name;
493
- code = InvalidTypeError.code;
494
- constructor(message = "Invalid type") {
495
- super(message);
496
- }
497
- };
498
- //#endregion
499
- //#region node_modules/ipfs-unixfs/node_modules/uint8-varint/dist/src/index.js
500
- const N1 = Math.pow(2, 7);
501
- const N2 = Math.pow(2, 14);
502
- const N3 = Math.pow(2, 21);
503
- const N4 = Math.pow(2, 28);
504
- const N5 = Math.pow(2, 35);
505
- const N6 = Math.pow(2, 42);
506
- const N7 = Math.pow(2, 49);
507
- /** Most significant bit of a byte */
508
- const MSB = 128;
509
- /** Rest of the bits in a byte */
510
- const REST = 127;
511
- function encodingLength(value) {
512
- if (value < N1) return 1;
513
- if (value < N2) return 2;
514
- if (value < N3) return 3;
515
- if (value < N4) return 4;
516
- if (value < N5) return 5;
517
- if (value < N6) return 6;
518
- if (value < N7) return 7;
519
- if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) throw new RangeError("Could not encode varint");
520
- return 8;
521
- }
522
- function encodeUint8Array(value, buf, offset = 0) {
523
- switch (encodingLength(value)) {
524
- case 8:
525
- buf[offset++] = value & 255 | MSB;
526
- value /= 128;
527
- case 7:
528
- buf[offset++] = value & 255 | MSB;
529
- value /= 128;
530
- case 6:
531
- buf[offset++] = value & 255 | MSB;
532
- value /= 128;
533
- case 5:
534
- buf[offset++] = value & 255 | MSB;
535
- value /= 128;
536
- case 4:
537
- buf[offset++] = value & 255 | MSB;
538
- value >>>= 7;
539
- case 3:
540
- buf[offset++] = value & 255 | MSB;
541
- value >>>= 7;
542
- case 2:
543
- buf[offset++] = value & 255 | MSB;
544
- value >>>= 7;
545
- case 1:
546
- buf[offset++] = value & 255;
547
- value >>>= 7;
548
- break;
549
- default: throw new Error("unreachable");
550
- }
551
- return buf;
552
- }
553
- function decodeUint8Array(buf, offset) {
554
- let b = buf[offset];
555
- let res = 0;
556
- res += b & REST;
557
- if (b < MSB) return res;
558
- b = buf[offset + 1];
559
- res += (b & REST) << 7;
560
- if (b < MSB) return res;
561
- b = buf[offset + 2];
562
- res += (b & REST) << 14;
563
- if (b < MSB) return res;
564
- b = buf[offset + 3];
565
- res += (b & REST) << 21;
566
- if (b < MSB) return res;
567
- b = buf[offset + 4];
568
- res += (b & REST) * N4;
569
- if (b < MSB) return res;
570
- b = buf[offset + 5];
571
- res += (b & REST) * N5;
572
- if (b < MSB) return res;
573
- b = buf[offset + 6];
574
- res += (b & REST) * N6;
575
- if (b < MSB) return res;
576
- b = buf[offset + 7];
577
- res += (b & REST) * N7;
578
- if (b < MSB) return res;
579
- throw new RangeError("Could not decode varint");
580
- }
581
- //#endregion
582
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/utils/float.js
583
- const f32 = new Float32Array([-0]);
584
- const f8b = new Uint8Array(f32.buffer);
585
- /**
586
- * Writes a 32 bit float to a buffer using little endian byte order
587
- */
588
- function writeFloatLE(val, buf, pos) {
589
- f32[0] = val;
590
- buf[pos] = f8b[0];
591
- buf[pos + 1] = f8b[1];
592
- buf[pos + 2] = f8b[2];
593
- buf[pos + 3] = f8b[3];
594
- }
595
- /**
596
- * Reads a 32 bit float from a buffer using little endian byte order
597
- */
598
- function readFloatLE(buf, pos) {
599
- f8b[0] = buf[pos];
600
- f8b[1] = buf[pos + 1];
601
- f8b[2] = buf[pos + 2];
602
- f8b[3] = buf[pos + 3];
603
- return f32[0];
604
- }
605
- const f64 = new Float64Array([-0]);
606
- const d8b = new Uint8Array(f64.buffer);
607
- /**
608
- * Writes a 64 bit double to a buffer using little endian byte order
609
- */
610
- function writeDoubleLE(val, buf, pos) {
611
- f64[0] = val;
612
- buf[pos] = d8b[0];
613
- buf[pos + 1] = d8b[1];
614
- buf[pos + 2] = d8b[2];
615
- buf[pos + 3] = d8b[3];
616
- buf[pos + 4] = d8b[4];
617
- buf[pos + 5] = d8b[5];
618
- buf[pos + 6] = d8b[6];
619
- buf[pos + 7] = d8b[7];
620
- }
621
- /**
622
- * Reads a 64 bit double from a buffer using little endian byte order
623
- */
624
- function readDoubleLE(buf, pos) {
625
- d8b[0] = buf[pos];
626
- d8b[1] = buf[pos + 1];
627
- d8b[2] = buf[pos + 2];
628
- d8b[3] = buf[pos + 3];
629
- d8b[4] = buf[pos + 4];
630
- d8b[5] = buf[pos + 5];
631
- d8b[6] = buf[pos + 6];
632
- d8b[7] = buf[pos + 7];
633
- return f64[0];
634
- }
635
- //#endregion
636
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/utils/longbits.js
637
- const MAX_SAFE_NUMBER_INTEGER = BigInt(Number.MAX_SAFE_INTEGER);
638
- const MIN_SAFE_NUMBER_INTEGER = BigInt(Number.MIN_SAFE_INTEGER);
639
- /**
640
- * Constructs new long bits.
641
- *
642
- * @classdesc Helper class for working with the low and high bits of a 64 bit value.
643
- * @memberof util
644
- * @function Object() { [native code] }
645
- * @param {number} lo - Low 32 bits, unsigned
646
- * @param {number} hi - High 32 bits, unsigned
647
- */
648
- var LongBits = class LongBits {
649
- lo;
650
- hi;
651
- constructor(lo, hi) {
652
- /**
653
- * Low bits
654
- */
655
- this.lo = lo >>> 0;
656
- /**
657
- * High bits
658
- */
659
- this.hi = hi >>> 0;
660
- }
661
- /**
662
- * Converts this long bits to a possibly unsafe JavaScript number
663
- */
664
- toNumber(unsigned = false) {
665
- if (!unsigned && this.hi >>> 31 > 0) {
666
- const lo = ~this.lo + 1 >>> 0;
667
- let hi = ~this.hi >>> 0;
668
- if (lo === 0) hi = hi + 1 >>> 0;
669
- return -(lo + hi * 4294967296);
670
- }
671
- return this.lo + this.hi * 4294967296;
672
- }
673
- /**
674
- * Converts this long bits to a bigint
675
- */
676
- toBigInt(unsigned = false) {
677
- if (unsigned) return BigInt(this.lo >>> 0) + (BigInt(this.hi >>> 0) << 32n);
678
- if (this.hi >>> 31 !== 0) {
679
- const lo = ~this.lo + 1 >>> 0;
680
- let hi = ~this.hi >>> 0;
681
- if (lo === 0) hi = hi + 1 >>> 0;
682
- return -(BigInt(lo) + (BigInt(hi) << 32n));
683
- }
684
- return BigInt(this.lo >>> 0) + (BigInt(this.hi >>> 0) << 32n);
685
- }
686
- /**
687
- * Converts this long bits to a string
688
- */
689
- toString(unsigned = false) {
690
- return this.toBigInt(unsigned).toString();
691
- }
692
- /**
693
- * Zig-zag encodes this long bits
694
- */
695
- zzEncode() {
696
- const mask = this.hi >> 31;
697
- this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
698
- this.lo = (this.lo << 1 ^ mask) >>> 0;
699
- return this;
700
- }
701
- /**
702
- * Zig-zag decodes this long bits
703
- */
704
- zzDecode() {
705
- const mask = -(this.lo & 1);
706
- this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
707
- this.hi = (this.hi >>> 1 ^ mask) >>> 0;
708
- return this;
709
- }
710
- /**
711
- * Calculates the length of this longbits when encoded as a varint.
712
- */
713
- length() {
714
- const part0 = this.lo;
715
- const part1 = (this.lo >>> 28 | this.hi << 4) >>> 0;
716
- const part2 = this.hi >>> 24;
717
- return part2 === 0 ? part1 === 0 ? part0 < 16384 ? part0 < 128 ? 1 : 2 : part0 < 2097152 ? 3 : 4 : part1 < 16384 ? part1 < 128 ? 5 : 6 : part1 < 2097152 ? 7 : 8 : part2 < 128 ? 9 : 10;
718
- }
719
- /**
720
- * Constructs new long bits from the specified number
721
- */
722
- static fromBigInt(value) {
723
- if (value === 0n) return zero;
724
- if (value < MAX_SAFE_NUMBER_INTEGER && value > MIN_SAFE_NUMBER_INTEGER) return this.fromNumber(Number(value));
725
- const negative = value < 0n;
726
- if (negative) value = -value;
727
- let hi = value >> 32n;
728
- let lo = value - (hi << 32n);
729
- if (negative) {
730
- hi = ~hi | 0n;
731
- lo = ~lo | 0n;
732
- if (++lo > TWO_32) {
733
- lo = 0n;
734
- if (++hi > TWO_32) hi = 0n;
735
- }
736
- }
737
- return new LongBits(Number(lo), Number(hi));
738
- }
739
- /**
740
- * Constructs new long bits from the specified number
741
- */
742
- static fromNumber(value) {
743
- if (value === 0) return zero;
744
- const sign = value < 0;
745
- if (sign) value = -value;
746
- let lo = value >>> 0;
747
- let hi = (value - lo) / 4294967296 >>> 0;
748
- if (sign) {
749
- hi = ~hi >>> 0;
750
- lo = ~lo >>> 0;
751
- if (++lo > 4294967295) {
752
- lo = 0;
753
- if (++hi > 4294967295) hi = 0;
754
- }
755
- }
756
- return new LongBits(lo, hi);
757
- }
758
- /**
759
- * Constructs new long bits from a number, long or string
760
- */
761
- static from(value) {
762
- if (typeof value === "number") return LongBits.fromNumber(value);
763
- if (typeof value === "bigint") return LongBits.fromBigInt(value);
764
- if (typeof value === "string") return LongBits.fromBigInt(BigInt(value));
765
- return value.low != null || value.high != null ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
766
- }
767
- };
768
- const zero = new LongBits(0, 0);
769
- zero.toBigInt = function() {
770
- return 0n;
771
- };
772
- zero.zzEncode = zero.zzDecode = function() {
773
- return this;
774
- };
775
- zero.length = function() {
776
- return 1;
777
- };
778
- const TWO_32 = 4294967296n;
779
- //#endregion
780
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/utils/utf8.js
781
- /**
782
- * Calculates the UTF8 byte length of a string
783
- */
784
- function length(string) {
785
- let len = 0;
786
- let c = 0;
787
- for (let i = 0; i < string.length; ++i) {
788
- c = string.charCodeAt(i);
789
- if (c < 128) len += 1;
790
- else if (c < 2048) len += 2;
791
- else if ((c & 64512) === 55296 && (string.charCodeAt(i + 1) & 64512) === 56320) {
792
- ++i;
793
- len += 4;
794
- } else len += 3;
795
- }
796
- return len;
797
- }
798
- /**
799
- * Reads UTF8 bytes as a string
800
- */
801
- function read(buffer, start, end) {
802
- if (end - start < 1) return "";
803
- let parts;
804
- const chunk = [];
805
- let i = 0;
806
- let t;
807
- while (start < end) {
808
- t = buffer[start++];
809
- if (t < 128) chunk[i++] = t;
810
- else if (t > 191 && t < 224) chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
811
- else if (t > 239 && t < 365) {
812
- t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 65536;
813
- chunk[i++] = 55296 + (t >> 10);
814
- chunk[i++] = 56320 + (t & 1023);
815
- } else chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
816
- if (i > 8191) {
817
- (parts ?? (parts = [])).push(String.fromCharCode.apply(String, chunk));
818
- i = 0;
819
- }
820
- }
821
- if (parts != null) {
822
- if (i > 0) parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
823
- return parts.join("");
824
- }
825
- return String.fromCharCode.apply(String, chunk.slice(0, i));
826
- }
827
- /**
828
- * Writes a string as UTF8 bytes
829
- */
830
- function write(string, buffer, offset) {
831
- const start = offset;
832
- let c1;
833
- let c2;
834
- for (let i = 0; i < string.length; ++i) {
835
- c1 = string.charCodeAt(i);
836
- if (c1 < 128) buffer[offset++] = c1;
837
- else if (c1 < 2048) {
838
- buffer[offset++] = c1 >> 6 | 192;
839
- buffer[offset++] = c1 & 63 | 128;
840
- } else if ((c1 & 64512) === 55296 && ((c2 = string.charCodeAt(i + 1)) & 64512) === 56320) {
841
- c1 = 65536 + ((c1 & 1023) << 10) + (c2 & 1023);
842
- ++i;
843
- buffer[offset++] = c1 >> 18 | 240;
844
- buffer[offset++] = c1 >> 12 & 63 | 128;
845
- buffer[offset++] = c1 >> 6 & 63 | 128;
846
- buffer[offset++] = c1 & 63 | 128;
847
- } else {
848
- buffer[offset++] = c1 >> 12 | 224;
849
- buffer[offset++] = c1 >> 6 & 63 | 128;
850
- buffer[offset++] = c1 & 63 | 128;
851
- }
852
- }
853
- return offset - start;
854
- }
855
- //#endregion
856
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/utils/reader.js
857
- /* istanbul ignore next */
858
- function indexOutOfRange(reader, writeLength) {
859
- return RangeError(`index out of range: ${reader.pos} + ${writeLength ?? 1} > ${reader.len}`);
860
- }
861
- function readFixed32End(buf, end) {
862
- return (buf[end - 4] | buf[end - 3] << 8 | buf[end - 2] << 16 | buf[end - 1] << 24) >>> 0;
863
- }
864
- /**
865
- * Constructs a new reader instance using the specified buffer.
866
- */
867
- var Uint8ArrayReader = class {
868
- buf;
869
- pos;
870
- len;
871
- _slice = Uint8Array.prototype.subarray;
872
- constructor(buffer) {
873
- /**
874
- * Read buffer
875
- */
876
- this.buf = withArrayBuffer(buffer);
877
- /**
878
- * Read buffer position
879
- */
880
- this.pos = 0;
881
- /**
882
- * Read buffer length
883
- */
884
- this.len = buffer.length;
885
- }
886
- /**
887
- * Reads a varint as an unsigned 32 bit value
888
- */
889
- uint32() {
890
- let value = 4294967295;
891
- value = (this.buf[this.pos] & 127) >>> 0;
892
- if (this.buf[this.pos++] < 128) return value;
893
- value = (value | (this.buf[this.pos] & 127) << 7) >>> 0;
894
- if (this.buf[this.pos++] < 128) return value;
895
- value = (value | (this.buf[this.pos] & 127) << 14) >>> 0;
896
- if (this.buf[this.pos++] < 128) return value;
897
- value = (value | (this.buf[this.pos] & 127) << 21) >>> 0;
898
- if (this.buf[this.pos++] < 128) return value;
899
- value = (value | (this.buf[this.pos] & 15) << 28) >>> 0;
900
- if (this.buf[this.pos++] < 128) return value;
901
- if ((this.pos += 5) > this.len) {
902
- this.pos = this.len;
903
- throw indexOutOfRange(this, 10);
904
- }
905
- return value;
906
- }
907
- /**
908
- * Reads a varint as a signed 32 bit value
909
- */
910
- int32() {
911
- return this.uint32() | 0;
912
- }
913
- /**
914
- * Reads a zig-zag encoded varint as a signed 32 bit value
915
- */
916
- sint32() {
917
- const value = this.uint32();
918
- return value >>> 1 ^ -(value & 1) | 0;
919
- }
920
- /**
921
- * Reads a varint as a boolean
922
- */
923
- bool() {
924
- return this.uint32() !== 0;
925
- }
926
- /**
927
- * Reads fixed 32 bits as an unsigned 32 bit integer
928
- */
929
- fixed32() {
930
- if (this.pos + 4 > this.len) throw indexOutOfRange(this, 4);
931
- return readFixed32End(this.buf, this.pos += 4);
932
- }
933
- /**
934
- * Reads fixed 32 bits as a signed 32 bit integer
935
- */
936
- sfixed32() {
937
- if (this.pos + 4 > this.len) throw indexOutOfRange(this, 4);
938
- return readFixed32End(this.buf, this.pos += 4) | 0;
939
- }
940
- /**
941
- * Reads a float (32 bit) as a number
942
- */
943
- float() {
944
- if (this.pos + 4 > this.len) throw indexOutOfRange(this, 4);
945
- const value = readFloatLE(this.buf, this.pos);
946
- this.pos += 4;
947
- return value;
948
- }
949
- /**
950
- * Reads a double (64 bit float) as a number
951
- */
952
- double() {
953
- /* istanbul ignore if */
954
- if (this.pos + 8 > this.len) throw indexOutOfRange(this, 4);
955
- const value = readDoubleLE(this.buf, this.pos);
956
- this.pos += 8;
957
- return value;
958
- }
959
- /**
960
- * Reads a sequence of bytes preceded by its length as a varint
961
- */
962
- bytes() {
963
- const length = this.uint32();
964
- const start = this.pos;
965
- const end = this.pos + length;
966
- /* istanbul ignore if */
967
- if (end > this.len) throw indexOutOfRange(this, length);
968
- this.pos += length;
969
- return start === end ? new Uint8Array(0) : this.buf.subarray(start, end);
970
- }
971
- /**
972
- * Reads a string preceded by its byte length as a varint
973
- */
974
- string() {
975
- const bytes = this.bytes();
976
- return read(bytes, 0, bytes.length);
977
- }
978
- /**
979
- * Skips the specified number of bytes if specified, otherwise skips a varint
980
- */
981
- skip(length) {
982
- if (typeof length === "number") {
983
- /* istanbul ignore if */
984
- if (this.pos + length > this.len) throw indexOutOfRange(this, length);
985
- this.pos += length;
986
- } else do
987
- /* istanbul ignore if */
988
- if (this.pos >= this.len) throw indexOutOfRange(this);
989
- while ((this.buf[this.pos++] & 128) !== 0);
990
- return this;
991
- }
992
- /**
993
- * Skips the next element of the specified wire type
994
- */
995
- skipType(wireType) {
996
- switch (wireType) {
997
- case 0:
998
- this.skip();
999
- break;
1000
- case 1:
1001
- this.skip(8);
1002
- break;
1003
- case 2:
1004
- this.skip(this.uint32());
1005
- break;
1006
- case 3:
1007
- while ((wireType = this.uint32() & 7) !== 4) this.skipType(wireType);
1008
- break;
1009
- case 5:
1010
- this.skip(4);
1011
- break;
1012
- /* istanbul ignore next */
1013
- default: throw Error(`invalid wire type ${wireType} at offset ${this.pos}`);
1014
- }
1015
- return this;
1016
- }
1017
- readLongVarint() {
1018
- const bits = new LongBits(0, 0);
1019
- let i = 0;
1020
- if (this.len - this.pos > 4) {
1021
- for (; i < 4; ++i) {
1022
- bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
1023
- if (this.buf[this.pos++] < 128) return bits;
1024
- }
1025
- bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;
1026
- bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;
1027
- if (this.buf[this.pos++] < 128) return bits;
1028
- i = 0;
1029
- } else {
1030
- for (; i < 3; ++i) {
1031
- /* istanbul ignore if */
1032
- if (this.pos >= this.len) throw indexOutOfRange(this);
1033
- bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
1034
- if (this.buf[this.pos++] < 128) return bits;
1035
- }
1036
- bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
1037
- return bits;
1038
- }
1039
- if (this.len - this.pos > 4) for (; i < 5; ++i) {
1040
- bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
1041
- if (this.buf[this.pos++] < 128) return bits;
1042
- }
1043
- else for (; i < 5; ++i) {
1044
- if (this.pos >= this.len) throw indexOutOfRange(this);
1045
- bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
1046
- if (this.buf[this.pos++] < 128) return bits;
1047
- }
1048
- throw Error("invalid varint encoding");
1049
- }
1050
- readFixed64() {
1051
- if (this.pos + 8 > this.len) throw indexOutOfRange(this, 8);
1052
- return new LongBits(readFixed32End(this.buf, this.pos += 4), readFixed32End(this.buf, this.pos += 4));
1053
- }
1054
- /**
1055
- * Reads a varint as a signed 64 bit value
1056
- */
1057
- int64() {
1058
- return this.readLongVarint().toBigInt();
1059
- }
1060
- /**
1061
- * Reads a varint as a signed 64 bit value returned as a possibly unsafe
1062
- * JavaScript number
1063
- */
1064
- int64Number() {
1065
- return this.readLongVarint().toNumber();
1066
- }
1067
- /**
1068
- * Reads a varint as a signed 64 bit value returned as a string
1069
- */
1070
- int64String() {
1071
- return this.readLongVarint().toString();
1072
- }
1073
- /**
1074
- * Reads a varint as an unsigned 64 bit value
1075
- */
1076
- uint64() {
1077
- return this.readLongVarint().toBigInt(true);
1078
- }
1079
- /**
1080
- * Reads a varint as an unsigned 64 bit value returned as a possibly unsafe
1081
- * JavaScript number
1082
- */
1083
- uint64Number() {
1084
- const value = decodeUint8Array(this.buf, this.pos);
1085
- this.pos += encodingLength(value);
1086
- return value;
1087
- }
1088
- /**
1089
- * Reads a varint as an unsigned 64 bit value returned as a string
1090
- */
1091
- uint64String() {
1092
- return this.readLongVarint().toString(true);
1093
- }
1094
- /**
1095
- * Reads a zig-zag encoded varint as a signed 64 bit value
1096
- */
1097
- sint64() {
1098
- return this.readLongVarint().zzDecode().toBigInt();
1099
- }
1100
- /**
1101
- * Reads a zig-zag encoded varint as a signed 64 bit value returned as a
1102
- * possibly unsafe JavaScript number
1103
- */
1104
- sint64Number() {
1105
- return this.readLongVarint().zzDecode().toNumber();
1106
- }
1107
- /**
1108
- * Reads a zig-zag encoded varint as a signed 64 bit value returned as a
1109
- * string
1110
- */
1111
- sint64String() {
1112
- return this.readLongVarint().zzDecode().toString();
1113
- }
1114
- /**
1115
- * Reads fixed 64 bits
1116
- */
1117
- fixed64() {
1118
- return this.readFixed64().toBigInt();
1119
- }
1120
- /**
1121
- * Reads fixed 64 bits returned as a possibly unsafe JavaScript number
1122
- */
1123
- fixed64Number() {
1124
- return this.readFixed64().toNumber();
1125
- }
1126
- /**
1127
- * Reads fixed 64 bits returned as a string
1128
- */
1129
- fixed64String() {
1130
- return this.readFixed64().toString();
1131
- }
1132
- /**
1133
- * Reads zig-zag encoded fixed 64 bits
1134
- */
1135
- sfixed64() {
1136
- return this.readFixed64().toBigInt();
1137
- }
1138
- /**
1139
- * Reads zig-zag encoded fixed 64 bits returned as a possibly unsafe
1140
- * JavaScript number
1141
- */
1142
- sfixed64Number() {
1143
- return this.readFixed64().toNumber();
1144
- }
1145
- /**
1146
- * Reads zig-zag encoded fixed 64 bits returned as a string
1147
- */
1148
- sfixed64String() {
1149
- return this.readFixed64().toString();
1150
- }
1151
- };
1152
- function createReader(buf) {
1153
- return new Uint8ArrayReader(buf instanceof Uint8Array ? buf : buf.subarray());
1154
- }
1155
- //#endregion
1156
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/decode.js
1157
- function decodeMessage(buf, codec, opts) {
1158
- const reader = createReader(buf);
1159
- return codec.decode(reader, void 0, opts);
1160
- }
1161
- //#endregion
1162
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/utils/pool.js
1163
- /**
1164
- * A general purpose buffer pool
1165
- */
1166
- function pool(size) {
1167
- const SIZE = size ?? 8192;
1168
- const MAX = SIZE >>> 1;
1169
- let slab;
1170
- let offset = SIZE;
1171
- return function poolAlloc(size) {
1172
- if (size < 1 || size > MAX) return allocUnsafe(size);
1173
- if (offset + size > SIZE) {
1174
- slab = allocUnsafe(SIZE);
1175
- offset = 0;
1176
- }
1177
- const buf = slab.subarray(offset, offset += size);
1178
- if ((offset & 7) !== 0) offset = (offset | 7) + 1;
1179
- return buf;
1180
- };
1181
- }
1182
- //#endregion
1183
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/utils/writer.js
1184
- /**
1185
- * Constructs a new writer operation instance.
1186
- *
1187
- * @classdesc Scheduled writer operation
1188
- */
1189
- var Op = class {
1190
- /**
1191
- * Function to call
1192
- */
1193
- fn;
1194
- /**
1195
- * Value byte length
1196
- */
1197
- len;
1198
- /**
1199
- * Next operation
1200
- */
1201
- next;
1202
- /**
1203
- * Value to write
1204
- */
1205
- val;
1206
- constructor(fn, len, val) {
1207
- this.fn = fn;
1208
- this.len = len;
1209
- this.next = void 0;
1210
- this.val = val;
1211
- }
1212
- };
1213
- /* istanbul ignore next */
1214
- function noop() {}
1215
- /**
1216
- * Constructs a new writer state instance
1217
- */
1218
- var State = class {
1219
- /**
1220
- * Current head
1221
- */
1222
- head;
1223
- /**
1224
- * Current tail
1225
- */
1226
- tail;
1227
- /**
1228
- * Current buffer length
1229
- */
1230
- len;
1231
- /**
1232
- * Next state
1233
- */
1234
- next;
1235
- constructor(writer) {
1236
- this.head = writer.head;
1237
- this.tail = writer.tail;
1238
- this.len = writer.len;
1239
- this.next = writer.states;
1240
- }
1241
- };
1242
- const bufferPool = pool();
1243
- /**
1244
- * Allocates a buffer of the specified size
1245
- */
1246
- function alloc$1(size) {
1247
- if (globalThis.Buffer != null) return allocUnsafe(size);
1248
- return bufferPool(size);
1249
- }
1250
- /**
1251
- * When a value is written, the writer calculates its byte length and puts it into a linked
1252
- * list of operations to perform when finish() is called. This both allows us to allocate
1253
- * buffers of the exact required size and reduces the amount of work we have to do compared
1254
- * to first calculating over objects and then encoding over objects. In our case, the encoding
1255
- * part is just a linked list walk calling operations with already prepared values.
1256
- */
1257
- var Uint8ArrayWriter = class {
1258
- /**
1259
- * Current length
1260
- */
1261
- len;
1262
- /**
1263
- * Operations head
1264
- */
1265
- head;
1266
- /**
1267
- * Operations tail
1268
- */
1269
- tail;
1270
- /**
1271
- * Linked forked states
1272
- */
1273
- states;
1274
- constructor() {
1275
- this.len = 0;
1276
- this.head = new Op(noop, 0, 0);
1277
- this.tail = this.head;
1278
- this.states = null;
1279
- }
1280
- /**
1281
- * Pushes a new operation to the queue
1282
- */
1283
- _push(fn, len, val) {
1284
- this.tail = this.tail.next = new Op(fn, len, val);
1285
- this.len += len;
1286
- return this;
1287
- }
1288
- /**
1289
- * Writes an unsigned 32 bit value as a varint
1290
- */
1291
- uint32(value) {
1292
- this.len += (this.tail = this.tail.next = new VarintOp((value = value >>> 0) < 128 ? 1 : value < 16384 ? 2 : value < 2097152 ? 3 : value < 268435456 ? 4 : 5, value)).len;
1293
- return this;
1294
- }
1295
- /**
1296
- * Writes a signed 32 bit value as a varint`
1297
- */
1298
- int32(value) {
1299
- return value < 0 ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) : this.uint32(value);
1300
- }
1301
- /**
1302
- * Writes a 32 bit value as a varint, zig-zag encoded
1303
- */
1304
- sint32(value) {
1305
- return this.uint32((value << 1 ^ value >> 31) >>> 0);
1306
- }
1307
- /**
1308
- * Writes an unsigned 64 bit value as a varint
1309
- */
1310
- uint64(value) {
1311
- const bits = LongBits.fromBigInt(value);
1312
- return this._push(writeVarint64, bits.length(), bits);
1313
- }
1314
- /**
1315
- * Writes an unsigned 64 bit value as a varint
1316
- */
1317
- uint64Number(value) {
1318
- return this._push(encodeUint8Array, encodingLength(value), value);
1319
- }
1320
- /**
1321
- * Writes an unsigned 64 bit value as a varint
1322
- */
1323
- uint64String(value) {
1324
- return this.uint64(BigInt(value));
1325
- }
1326
- /**
1327
- * Writes a signed 64 bit value as a varint
1328
- */
1329
- int64(value) {
1330
- return this.uint64(value);
1331
- }
1332
- /**
1333
- * Writes a signed 64 bit value as a varint
1334
- */
1335
- int64Number(value) {
1336
- return this.uint64Number(value);
1337
- }
1338
- /**
1339
- * Writes a signed 64 bit value as a varint
1340
- */
1341
- int64String(value) {
1342
- return this.uint64String(value);
1343
- }
1344
- /**
1345
- * Writes a signed 64 bit value as a varint, zig-zag encoded
1346
- */
1347
- sint64(value) {
1348
- const bits = LongBits.fromBigInt(value).zzEncode();
1349
- return this._push(writeVarint64, bits.length(), bits);
1350
- }
1351
- /**
1352
- * Writes a signed 64 bit value as a varint, zig-zag encoded
1353
- */
1354
- sint64Number(value) {
1355
- const bits = LongBits.fromNumber(value).zzEncode();
1356
- return this._push(writeVarint64, bits.length(), bits);
1357
- }
1358
- /**
1359
- * Writes a signed 64 bit value as a varint, zig-zag encoded
1360
- */
1361
- sint64String(value) {
1362
- return this.sint64(BigInt(value));
1363
- }
1364
- /**
1365
- * Writes a boolish value as a varint
1366
- */
1367
- bool(value) {
1368
- return this._push(writeByte, 1, value ? 1 : 0);
1369
- }
1370
- /**
1371
- * Writes an unsigned 32 bit value as fixed 32 bits
1372
- */
1373
- fixed32(value) {
1374
- return this._push(writeFixed32, 4, value >>> 0);
1375
- }
1376
- /**
1377
- * Writes a signed 32 bit value as fixed 32 bits
1378
- */
1379
- sfixed32(value) {
1380
- return this.fixed32(value);
1381
- }
1382
- /**
1383
- * Writes an unsigned 64 bit value as fixed 64 bits
1384
- */
1385
- fixed64(value) {
1386
- const bits = LongBits.fromBigInt(value);
1387
- return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
1388
- }
1389
- /**
1390
- * Writes an unsigned 64 bit value as fixed 64 bits
1391
- */
1392
- fixed64Number(value) {
1393
- const bits = LongBits.fromNumber(value);
1394
- return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
1395
- }
1396
- /**
1397
- * Writes an unsigned 64 bit value as fixed 64 bits
1398
- */
1399
- fixed64String(value) {
1400
- return this.fixed64(BigInt(value));
1401
- }
1402
- /**
1403
- * Writes a signed 64 bit value as fixed 64 bits
1404
- */
1405
- sfixed64(value) {
1406
- return this.fixed64(value);
1407
- }
1408
- /**
1409
- * Writes a signed 64 bit value as fixed 64 bits
1410
- */
1411
- sfixed64Number(value) {
1412
- return this.fixed64Number(value);
1413
- }
1414
- /**
1415
- * Writes a signed 64 bit value as fixed 64 bits
1416
- */
1417
- sfixed64String(value) {
1418
- return this.fixed64String(value);
1419
- }
1420
- /**
1421
- * Writes a float (32 bit)
1422
- */
1423
- float(value) {
1424
- return this._push(writeFloatLE, 4, value);
1425
- }
1426
- /**
1427
- * Writes a double (64 bit float).
1428
- *
1429
- * @function
1430
- * @param {number} value - Value to write
1431
- * @returns {Writer} `this`
1432
- */
1433
- double(value) {
1434
- return this._push(writeDoubleLE, 8, value);
1435
- }
1436
- /**
1437
- * Writes a sequence of bytes
1438
- */
1439
- bytes(value) {
1440
- const len = value.length >>> 0;
1441
- if (len === 0) return this._push(writeByte, 1, 0);
1442
- return this.uint32(len)._push(writeBytes, len, value);
1443
- }
1444
- /**
1445
- * Writes a string
1446
- */
1447
- string(value) {
1448
- const len = length(value);
1449
- return len !== 0 ? this.uint32(len)._push(write, len, value) : this._push(writeByte, 1, 0);
1450
- }
1451
- /**
1452
- * Forks this writer's state by pushing it to a stack.
1453
- * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.
1454
- */
1455
- fork() {
1456
- this.states = new State(this);
1457
- this.head = this.tail = new Op(noop, 0, 0);
1458
- this.len = 0;
1459
- return this;
1460
- }
1461
- /**
1462
- * Resets this instance to the last state
1463
- */
1464
- reset() {
1465
- if (this.states != null) {
1466
- this.head = this.states.head;
1467
- this.tail = this.states.tail;
1468
- this.len = this.states.len;
1469
- this.states = this.states.next;
1470
- } else {
1471
- this.head = this.tail = new Op(noop, 0, 0);
1472
- this.len = 0;
1473
- }
1474
- return this;
1475
- }
1476
- /**
1477
- * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
1478
- */
1479
- ldelim() {
1480
- const head = this.head;
1481
- const tail = this.tail;
1482
- const len = this.len;
1483
- this.reset().uint32(len);
1484
- if (len !== 0) {
1485
- this.tail.next = head.next;
1486
- this.tail = tail;
1487
- this.len += len;
1488
- }
1489
- return this;
1490
- }
1491
- /**
1492
- * Finishes the write operation
1493
- */
1494
- finish() {
1495
- let head = this.head.next;
1496
- const buf = alloc$1(this.len);
1497
- let pos = 0;
1498
- while (head != null) {
1499
- head.fn(head.val, buf, pos);
1500
- pos += head.len;
1501
- head = head.next;
1502
- }
1503
- return buf;
1504
- }
1505
- };
1506
- function writeByte(val, buf, pos) {
1507
- buf[pos] = val & 255;
1508
- }
1509
- function writeVarint32(val, buf, pos) {
1510
- while (val > 127) {
1511
- buf[pos++] = val & 127 | 128;
1512
- val >>>= 7;
1513
- }
1514
- buf[pos] = val;
1515
- }
1516
- /**
1517
- * Constructs a new varint writer operation instance.
1518
- *
1519
- * @classdesc Scheduled varint writer operation
1520
- */
1521
- var VarintOp = class extends Op {
1522
- next;
1523
- constructor(len, val) {
1524
- super(writeVarint32, len, val);
1525
- this.next = void 0;
1526
- }
1527
- };
1528
- function writeVarint64(val, buf, pos) {
1529
- while (val.hi !== 0) {
1530
- buf[pos++] = val.lo & 127 | 128;
1531
- val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
1532
- val.hi >>>= 7;
1533
- }
1534
- while (val.lo > 127) {
1535
- buf[pos++] = val.lo & 127 | 128;
1536
- val.lo = val.lo >>> 7;
1537
- }
1538
- buf[pos++] = val.lo;
1539
- }
1540
- function writeFixed32(val, buf, pos) {
1541
- buf[pos] = val & 255;
1542
- buf[pos + 1] = val >>> 8 & 255;
1543
- buf[pos + 2] = val >>> 16 & 255;
1544
- buf[pos + 3] = val >>> 24;
1545
- }
1546
- function writeBytes(val, buf, pos) {
1547
- buf.set(val, pos);
1548
- }
1549
- if (globalThis.Buffer != null) {
1550
- Uint8ArrayWriter.prototype.bytes = function(value) {
1551
- const len = value.length >>> 0;
1552
- this.uint32(len);
1553
- if (len > 0) this._push(writeBytesBuffer, len, value);
1554
- return this;
1555
- };
1556
- Uint8ArrayWriter.prototype.string = function(value) {
1557
- const len = globalThis.Buffer.byteLength(value);
1558
- this.uint32(len);
1559
- if (len > 0) this._push(writeStringBuffer, len, value);
1560
- return this;
1561
- };
1562
- }
1563
- function writeBytesBuffer(val, buf, pos) {
1564
- buf.set(val, pos);
1565
- }
1566
- function writeStringBuffer(val, buf, pos) {
1567
- if (val.length < 40) write(val, buf, pos);
1568
- else if (buf.utf8Write != null) buf.utf8Write(val, pos);
1569
- else buf.set(fromString(val), pos);
1570
- }
1571
- /**
1572
- * Creates a new writer
1573
- */
1574
- function createWriter() {
1575
- return new Uint8ArrayWriter();
1576
- }
1577
- //#endregion
1578
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/encode.js
1579
- function encodeMessage(message, codec) {
1580
- const w = createWriter();
1581
- codec.encode(message, w, { lengthDelimited: false });
1582
- return w.finish();
1583
- }
1584
- //#endregion
1585
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/stream.js
1586
- function* streamMessage(buf, codec, opts) {
1587
- const reader = createReader(buf);
1588
- yield* codec.stream(reader, void 0, ".", opts);
1589
- }
1590
- //#endregion
1591
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/codec.js
1592
- const CODEC_TYPES = {
1593
- VARINT: 0,
1594
- BIT64: 1,
1595
- LENGTH_DELIMITED: 2,
1596
- START_GROUP: 3,
1597
- END_GROUP: 4,
1598
- BIT32: 5
1599
- };
1600
- function createCodec(name, type, encode, decode, stream) {
1601
- return {
1602
- name,
1603
- type,
1604
- encode,
1605
- decode,
1606
- stream
1607
- };
1608
- }
1609
- //#endregion
1610
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/codecs/enum.js
1611
- function enumeration(v) {
1612
- function findValue(val) {
1613
- if (v[val.toString()] == null) throw new Error("Invalid enum value");
1614
- return v[val];
1615
- }
1616
- return createCodec("enum", CODEC_TYPES.VARINT, function enumEncode(val, writer) {
1617
- const enumValue = findValue(val);
1618
- writer.int32(enumValue);
1619
- }, function enumDecode(reader) {
1620
- return findValue(reader.int32());
1621
- }, function* enumStream(reader, prefix) {});
1622
- }
1623
- //#endregion
1624
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/codecs/message.js
1625
- function message(encode, decode, stream) {
1626
- return createCodec("message", CODEC_TYPES.LENGTH_DELIMITED, encode, decode, stream);
1627
- }
1628
- //#endregion
1629
- //#region node_modules/ipfs-unixfs/node_modules/protons-runtime/dist/src/index.js
1630
- /**
1631
- * Thrown when a repeated field has too many elements
1632
- */
1633
- var MaxLengthError = class extends Error {
1634
- /**
1635
- * This will be removed in a future release
1636
- *
1637
- * @deprecated use the `.name` property instead
1638
- */
1639
- code = "ERR_MAX_LENGTH";
1640
- name = "MaxLengthError";
1641
- };
1642
- //#endregion
1643
- //#region node_modules/ipfs-unixfs/dist/src/unixfs.js
1644
- var UnixFS$1;
1645
- (function(UnixFS) {
1646
- (function(Type) {
1647
- Type["RAW"] = "RAW";
1648
- Type["DIRECTORY"] = "DIRECTORY";
1649
- Type["FILE"] = "FILE";
1650
- Type["METADATA"] = "METADATA";
1651
- Type["SYMLINK"] = "SYMLINK";
1652
- Type["HAMT_SHARD"] = "HAMT_SHARD";
1653
- })(UnixFS.Type || (UnixFS.Type = {}));
1654
- let __TypeValues;
1655
- (function(__TypeValues) {
1656
- __TypeValues[__TypeValues["RAW"] = 0] = "RAW";
1657
- __TypeValues[__TypeValues["DIRECTORY"] = 1] = "DIRECTORY";
1658
- __TypeValues[__TypeValues["FILE"] = 2] = "FILE";
1659
- __TypeValues[__TypeValues["METADATA"] = 3] = "METADATA";
1660
- __TypeValues[__TypeValues["SYMLINK"] = 4] = "SYMLINK";
1661
- __TypeValues[__TypeValues["HAMT_SHARD"] = 5] = "HAMT_SHARD";
1662
- })(__TypeValues || (__TypeValues = {}));
1663
- (function(Type) {
1664
- Type.codec = () => {
1665
- return enumeration(__TypeValues);
1666
- };
1667
- })(UnixFS.Type || (UnixFS.Type = {}));
1668
- let _codec;
1669
- UnixFS.codec = () => {
1670
- if (_codec == null) _codec = message((obj, w, opts = {}) => {
1671
- if (opts.lengthDelimited !== false) w.fork();
1672
- if (obj.type != null) {
1673
- w.uint32(8);
1674
- UnixFS.Type.codec().encode(obj.type, w);
1675
- }
1676
- if (obj.data != null) {
1677
- w.uint32(18);
1678
- w.bytes(obj.data);
1679
- }
1680
- if (obj.fileSize != null) {
1681
- w.uint32(24);
1682
- w.uint64(obj.fileSize);
1683
- }
1684
- if (obj.blockSizes != null && obj.blockSizes.length > 0) for (const value of obj.blockSizes) {
1685
- w.uint32(32);
1686
- w.uint64(value);
1687
- }
1688
- if (obj.hashType != null) {
1689
- w.uint32(40);
1690
- w.uint64(obj.hashType);
1691
- }
1692
- if (obj.fanOut != null) {
1693
- w.uint32(48);
1694
- w.uint64(obj.fanOut);
1695
- }
1696
- if (obj.mode != null) {
1697
- w.uint32(56);
1698
- w.uint32(obj.mode);
1699
- }
1700
- if (obj.mtime != null) {
1701
- w.uint32(66);
1702
- UnixTime.codec().encode(obj.mtime, w);
1703
- }
1704
- if (opts.lengthDelimited !== false) w.ldelim();
1705
- }, (r, length, opts = {}) => {
1706
- const obj = { blockSizes: [] };
1707
- const end = length == null ? r.len : r.pos + length;
1708
- while (r.pos < end) {
1709
- const tag = r.uint32();
1710
- switch (tag >>> 3) {
1711
- case 1:
1712
- obj.type = UnixFS.Type.codec().decode(r);
1713
- break;
1714
- case 2:
1715
- obj.data = r.bytes();
1716
- break;
1717
- case 3:
1718
- obj.fileSize = r.uint64();
1719
- break;
1720
- case 4:
1721
- if (opts.limits?.blockSizes != null && obj.blockSizes.length === opts.limits.blockSizes) throw new MaxLengthError("Decode error - repeated field \"blockSizes\" had too many elements");
1722
- obj.blockSizes.push(r.uint64());
1723
- break;
1724
- case 5:
1725
- obj.hashType = r.uint64();
1726
- break;
1727
- case 6:
1728
- obj.fanOut = r.uint64();
1729
- break;
1730
- case 7:
1731
- obj.mode = r.uint32();
1732
- break;
1733
- case 8:
1734
- obj.mtime = UnixTime.codec().decode(r, r.uint32(), { limits: opts.limits?.mtime });
1735
- break;
1736
- default:
1737
- r.skipType(tag & 7);
1738
- break;
1739
- }
1740
- }
1741
- return obj;
1742
- }, function* (r, length, prefix, opts = {}) {
1743
- const obj = { blockSizes: 0 };
1744
- const end = length == null ? r.len : r.pos + length;
1745
- if (prefix !== ".") yield {
1746
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
1747
- type: "start",
1748
- message: "UnixFS"
1749
- };
1750
- while (r.pos < end) {
1751
- const tag = r.uint32();
1752
- switch (tag >>> 3) {
1753
- case 1:
1754
- yield {
1755
- field: `${prefix}type`,
1756
- value: UnixFS.Type.codec().decode(r)
1757
- };
1758
- break;
1759
- case 2:
1760
- yield {
1761
- field: `${prefix}data`,
1762
- value: r.bytes()
1763
- };
1764
- break;
1765
- case 3:
1766
- yield {
1767
- field: `${prefix}fileSize`,
1768
- value: r.uint64()
1769
- };
1770
- break;
1771
- case 4:
1772
- if (opts.limits?.blockSizes != null && obj.blockSizes === opts.limits.blockSizes) throw new MaxLengthError("Streaming decode error - repeated field \"blockSizes\" had too many elements");
1773
- yield {
1774
- field: `${prefix}blockSizes[]`,
1775
- index: obj.blockSizes,
1776
- value: r.uint64()
1777
- };
1778
- obj.blockSizes++;
1779
- break;
1780
- case 5:
1781
- yield {
1782
- field: `${prefix}hashType`,
1783
- value: r.uint64()
1784
- };
1785
- break;
1786
- case 6:
1787
- yield {
1788
- field: `${prefix}fanOut`,
1789
- value: r.uint64()
1790
- };
1791
- break;
1792
- case 7:
1793
- yield {
1794
- field: `${prefix}mode`,
1795
- value: r.uint32()
1796
- };
1797
- break;
1798
- case 8:
1799
- yield* UnixTime.codec().stream(r, r.uint32(), `${prefix}mtime.`, { limits: opts.limits?.mtime });
1800
- break;
1801
- default:
1802
- r.skipType(tag & 7);
1803
- break;
1804
- }
1805
- }
1806
- if (prefix !== ".") yield {
1807
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
1808
- type: "end",
1809
- message: "UnixFS"
1810
- };
1811
- });
1812
- return _codec;
1813
- };
1814
- function encode(obj) {
1815
- return encodeMessage(obj, UnixFS.codec());
1816
- }
1817
- UnixFS.encode = encode;
1818
- function decode(buf, opts) {
1819
- return decodeMessage(buf, UnixFS.codec(), opts);
1820
- }
1821
- UnixFS.decode = decode;
1822
- function stream(buf, opts) {
1823
- return streamMessage(buf, UnixFS.codec(), opts);
1824
- }
1825
- UnixFS.stream = stream;
1826
- })(UnixFS$1 || (UnixFS$1 = {}));
1827
- var UnixTime;
1828
- (function(UnixTime) {
1829
- let _codec;
1830
- UnixTime.codec = () => {
1831
- if (_codec == null) _codec = message((obj, w, opts = {}) => {
1832
- if (opts.lengthDelimited !== false) w.fork();
1833
- if (obj.seconds != null) {
1834
- w.uint32(8);
1835
- w.int64(obj.seconds);
1836
- }
1837
- if (obj.fractionalNanoseconds != null) {
1838
- w.uint32(21);
1839
- w.fixed32(obj.fractionalNanoseconds);
1840
- }
1841
- if (opts.lengthDelimited !== false) w.ldelim();
1842
- }, (r, length) => {
1843
- const obj = {};
1844
- const end = length == null ? r.len : r.pos + length;
1845
- while (r.pos < end) {
1846
- const tag = r.uint32();
1847
- switch (tag >>> 3) {
1848
- case 1:
1849
- obj.seconds = r.int64();
1850
- break;
1851
- case 2:
1852
- obj.fractionalNanoseconds = r.fixed32();
1853
- break;
1854
- default:
1855
- r.skipType(tag & 7);
1856
- break;
1857
- }
1858
- }
1859
- return obj;
1860
- }, function* (r, length, prefix) {
1861
- const end = length == null ? r.len : r.pos + length;
1862
- if (prefix !== ".") yield {
1863
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
1864
- type: "start",
1865
- message: "UnixTime"
1866
- };
1867
- while (r.pos < end) {
1868
- const tag = r.uint32();
1869
- switch (tag >>> 3) {
1870
- case 1:
1871
- yield {
1872
- field: `${prefix}seconds`,
1873
- value: r.int64()
1874
- };
1875
- break;
1876
- case 2:
1877
- yield {
1878
- field: `${prefix}fractionalNanoseconds`,
1879
- value: r.fixed32()
1880
- };
1881
- break;
1882
- default:
1883
- r.skipType(tag & 7);
1884
- break;
1885
- }
1886
- }
1887
- if (prefix !== ".") yield {
1888
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
1889
- type: "end",
1890
- message: "UnixTime"
1891
- };
1892
- });
1893
- return _codec;
1894
- };
1895
- function encode(obj) {
1896
- return encodeMessage(obj, UnixTime.codec());
1897
- }
1898
- UnixTime.encode = encode;
1899
- function decode(buf, opts) {
1900
- return decodeMessage(buf, UnixTime.codec(), opts);
1901
- }
1902
- UnixTime.decode = decode;
1903
- function stream(buf, opts) {
1904
- return streamMessage(buf, UnixTime.codec(), opts);
1905
- }
1906
- UnixTime.stream = stream;
1907
- })(UnixTime || (UnixTime = {}));
1908
- var Metadata;
1909
- (function(Metadata) {
1910
- let _codec;
1911
- Metadata.codec = () => {
1912
- if (_codec == null) _codec = message((obj, w, opts = {}) => {
1913
- if (opts.lengthDelimited !== false) w.fork();
1914
- if (obj.mimeType != null) {
1915
- w.uint32(10);
1916
- w.string(obj.mimeType);
1917
- }
1918
- if (opts.lengthDelimited !== false) w.ldelim();
1919
- }, (r, length) => {
1920
- const obj = {};
1921
- const end = length == null ? r.len : r.pos + length;
1922
- while (r.pos < end) {
1923
- const tag = r.uint32();
1924
- switch (tag >>> 3) {
1925
- case 1:
1926
- obj.mimeType = r.string();
1927
- break;
1928
- default:
1929
- r.skipType(tag & 7);
1930
- break;
1931
- }
1932
- }
1933
- return obj;
1934
- }, function* (r, length, prefix) {
1935
- const end = length == null ? r.len : r.pos + length;
1936
- if (prefix !== ".") yield {
1937
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
1938
- type: "start",
1939
- message: "Metadata"
1940
- };
1941
- while (r.pos < end) {
1942
- const tag = r.uint32();
1943
- switch (tag >>> 3) {
1944
- case 1:
1945
- yield {
1946
- field: `${prefix}mimeType`,
1947
- value: r.string()
1948
- };
1949
- break;
1950
- default:
1951
- r.skipType(tag & 7);
1952
- break;
1953
- }
1954
- }
1955
- if (prefix !== ".") yield {
1956
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
1957
- type: "end",
1958
- message: "Metadata"
1959
- };
1960
- });
1961
- return _codec;
1962
- };
1963
- function encode(obj) {
1964
- return encodeMessage(obj, Metadata.codec());
1965
- }
1966
- Metadata.encode = encode;
1967
- function decode(buf, opts) {
1968
- return decodeMessage(buf, Metadata.codec(), opts);
1969
- }
1970
- Metadata.decode = decode;
1971
- function stream(buf, opts) {
1972
- return streamMessage(buf, Metadata.codec(), opts);
1973
- }
1974
- Metadata.stream = stream;
1975
- })(Metadata || (Metadata = {}));
1976
- var Link;
1977
- (function(Link) {
1978
- let _codec;
1979
- Link.codec = () => {
1980
- if (_codec == null) _codec = message((obj, w, opts = {}) => {
1981
- if (opts.lengthDelimited !== false) w.fork();
1982
- if (obj.hash != null) {
1983
- w.uint32(10);
1984
- w.bytes(obj.hash);
1985
- }
1986
- if (obj.name != null) {
1987
- w.uint32(18);
1988
- w.string(obj.name);
1989
- }
1990
- if (obj.tSize != null) {
1991
- w.uint32(24);
1992
- w.uint64(obj.tSize);
1993
- }
1994
- if (opts.lengthDelimited !== false) w.ldelim();
1995
- }, (r, length) => {
1996
- const obj = {};
1997
- const end = length == null ? r.len : r.pos + length;
1998
- while (r.pos < end) {
1999
- const tag = r.uint32();
2000
- switch (tag >>> 3) {
2001
- case 1:
2002
- obj.hash = r.bytes();
2003
- break;
2004
- case 2:
2005
- obj.name = r.string();
2006
- break;
2007
- case 3:
2008
- obj.tSize = r.uint64();
2009
- break;
2010
- default:
2011
- r.skipType(tag & 7);
2012
- break;
2013
- }
2014
- }
2015
- return obj;
2016
- }, function* (r, length, prefix) {
2017
- const end = length == null ? r.len : r.pos + length;
2018
- if (prefix !== ".") yield {
2019
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
2020
- type: "start",
2021
- message: "Link"
2022
- };
2023
- while (r.pos < end) {
2024
- const tag = r.uint32();
2025
- switch (tag >>> 3) {
2026
- case 1:
2027
- yield {
2028
- field: `${prefix}hash`,
2029
- value: r.bytes()
2030
- };
2031
- break;
2032
- case 2:
2033
- yield {
2034
- field: `${prefix}name`,
2035
- value: r.string()
2036
- };
2037
- break;
2038
- case 3:
2039
- yield {
2040
- field: `${prefix}tSize`,
2041
- value: r.uint64()
2042
- };
2043
- break;
2044
- default:
2045
- r.skipType(tag & 7);
2046
- break;
2047
- }
2048
- }
2049
- if (prefix !== ".") yield {
2050
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
2051
- type: "end",
2052
- message: "Link"
2053
- };
2054
- });
2055
- return _codec;
2056
- };
2057
- function encode(obj) {
2058
- return encodeMessage(obj, Link.codec());
2059
- }
2060
- Link.encode = encode;
2061
- function decode(buf, opts) {
2062
- return decodeMessage(buf, Link.codec(), opts);
2063
- }
2064
- Link.decode = decode;
2065
- function stream(buf, opts) {
2066
- return streamMessage(buf, Link.codec(), opts);
2067
- }
2068
- Link.stream = stream;
2069
- })(Link || (Link = {}));
2070
- var Node;
2071
- (function(Node) {
2072
- let _codec;
2073
- Node.codec = () => {
2074
- if (_codec == null) _codec = message((obj, w, opts = {}) => {
2075
- if (opts.lengthDelimited !== false) w.fork();
2076
- if (obj.data != null) {
2077
- w.uint32(10);
2078
- UnixFS$1.codec().encode(obj.data, w);
2079
- }
2080
- if (obj.links != null && obj.links.length > 0) for (const value of obj.links) {
2081
- w.uint32(18);
2082
- Link.codec().encode(value, w);
2083
- }
2084
- if (opts.lengthDelimited !== false) w.ldelim();
2085
- }, (r, length, opts = {}) => {
2086
- const obj = { links: [] };
2087
- const end = length == null ? r.len : r.pos + length;
2088
- while (r.pos < end) {
2089
- const tag = r.uint32();
2090
- switch (tag >>> 3) {
2091
- case 1:
2092
- obj.data = UnixFS$1.codec().decode(r, r.uint32(), { limits: opts.limits?.data });
2093
- break;
2094
- case 2:
2095
- if (opts.limits?.links != null && obj.links.length === opts.limits.links) throw new MaxLengthError("Decode error - repeated field \"links\" had too many elements");
2096
- obj.links.push(Link.codec().decode(r, r.uint32(), { limits: opts.limits?.links$ }));
2097
- break;
2098
- default:
2099
- r.skipType(tag & 7);
2100
- break;
2101
- }
2102
- }
2103
- return obj;
2104
- }, function* (r, length, prefix, opts = {}) {
2105
- const obj = { links: 0 };
2106
- const end = length == null ? r.len : r.pos + length;
2107
- if (prefix !== ".") yield {
2108
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
2109
- type: "start",
2110
- message: "Node"
2111
- };
2112
- while (r.pos < end) {
2113
- const tag = r.uint32();
2114
- switch (tag >>> 3) {
2115
- case 1:
2116
- yield* UnixFS$1.codec().stream(r, r.uint32(), `${prefix}data.`, { limits: opts.limits?.data });
2117
- break;
2118
- case 2:
2119
- if (opts.limits?.links != null && obj.links === opts.limits.links) throw new MaxLengthError("Streaming decode error - repeated field \"links\" had too many elements");
2120
- for (const evt of Link.codec().stream(r, r.uint32(), `${prefix}links[].`, { limits: opts.limits?.links$ })) yield {
2121
- ...evt,
2122
- index: obj.links
2123
- };
2124
- obj.links++;
2125
- break;
2126
- default:
2127
- r.skipType(tag & 7);
2128
- break;
2129
- }
2130
- }
2131
- if (prefix !== ".") yield {
2132
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
2133
- type: "end",
2134
- message: "Node"
2135
- };
2136
- });
2137
- return _codec;
2138
- };
2139
- function encode(obj) {
2140
- return encodeMessage(obj, Node.codec());
2141
- }
2142
- Node.encode = encode;
2143
- function decode(buf, opts) {
2144
- return decodeMessage(buf, Node.codec(), opts);
2145
- }
2146
- Node.decode = decode;
2147
- function stream(buf, opts) {
2148
- return streamMessage(buf, Node.codec(), opts);
2149
- }
2150
- Node.stream = stream;
2151
- })(Node || (Node = {}));
2152
- var LegacyNode;
2153
- (function(LegacyNode) {
2154
- let _codec;
2155
- LegacyNode.codec = () => {
2156
- if (_codec == null) _codec = message((obj, w, opts = {}) => {
2157
- if (opts.lengthDelimited !== false) w.fork();
2158
- if (obj.links != null && obj.links.length > 0) for (const value of obj.links) {
2159
- w.uint32(18);
2160
- Link.codec().encode(value, w);
2161
- }
2162
- if (obj.data != null) {
2163
- w.uint32(10);
2164
- UnixFS$1.codec().encode(obj.data, w);
2165
- }
2166
- if (opts.lengthDelimited !== false) w.ldelim();
2167
- }, (r, length, opts = {}) => {
2168
- const obj = { links: [] };
2169
- const end = length == null ? r.len : r.pos + length;
2170
- while (r.pos < end) {
2171
- const tag = r.uint32();
2172
- switch (tag >>> 3) {
2173
- case 2:
2174
- if (opts.limits?.links != null && obj.links.length === opts.limits.links) throw new MaxLengthError("Decode error - repeated field \"links\" had too many elements");
2175
- obj.links.push(Link.codec().decode(r, r.uint32(), { limits: opts.limits?.links$ }));
2176
- break;
2177
- case 1:
2178
- obj.data = UnixFS$1.codec().decode(r, r.uint32(), { limits: opts.limits?.data });
2179
- break;
2180
- default:
2181
- r.skipType(tag & 7);
2182
- break;
2183
- }
2184
- }
2185
- return obj;
2186
- }, function* (r, length, prefix, opts = {}) {
2187
- const obj = { links: 0 };
2188
- const end = length == null ? r.len : r.pos + length;
2189
- if (prefix !== ".") yield {
2190
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
2191
- type: "start",
2192
- message: "LegacyNode"
2193
- };
2194
- while (r.pos < end) {
2195
- const tag = r.uint32();
2196
- switch (tag >>> 3) {
2197
- case 2:
2198
- if (opts.limits?.links != null && obj.links === opts.limits.links) throw new MaxLengthError("Streaming decode error - repeated field \"links\" had too many elements");
2199
- for (const evt of Link.codec().stream(r, r.uint32(), `${prefix}links[].`, { limits: opts.limits?.links$ })) yield {
2200
- ...evt,
2201
- index: obj.links
2202
- };
2203
- obj.links++;
2204
- break;
2205
- case 1:
2206
- yield* UnixFS$1.codec().stream(r, r.uint32(), `${prefix}data.`, { limits: opts.limits?.data });
2207
- break;
2208
- default:
2209
- r.skipType(tag & 7);
2210
- break;
2211
- }
2212
- }
2213
- if (prefix !== ".") yield {
2214
- field: prefix.endsWith(".") ? prefix.substring(0, prefix.length - 1) : prefix,
2215
- type: "end",
2216
- message: "LegacyNode"
2217
- };
2218
- });
2219
- return _codec;
2220
- };
2221
- function encode(obj) {
2222
- return encodeMessage(obj, LegacyNode.codec());
2223
- }
2224
- LegacyNode.encode = encode;
2225
- function decode(buf, opts) {
2226
- return decodeMessage(buf, LegacyNode.codec(), opts);
2227
- }
2228
- LegacyNode.decode = decode;
2229
- function stream(buf, opts) {
2230
- return streamMessage(buf, LegacyNode.codec(), opts);
2231
- }
2232
- LegacyNode.stream = stream;
2233
- })(LegacyNode || (LegacyNode = {}));
2234
- //#endregion
2235
- //#region node_modules/ipfs-unixfs/dist/src/index.js
2236
- /**
2237
- * @packageDocumentation
2238
- *
2239
- * This module contains the protobuf definition of the UnixFS data structure found at the root of all UnixFS DAGs.
2240
- *
2241
- * The UnixFS spec can be found in the [ipfs/specs repository](http://github.com/ipfs/specs)
2242
- *
2243
- * @example Create a file composed of several blocks
2244
- *
2245
- * ```TypeScript
2246
- * import { UnixFS } from 'ipfs-unixfs'
2247
- *
2248
- * const data = new UnixFS({ type: 'file' })
2249
- * data.addBlockSize(256n) // add the size of each block
2250
- * data.addBlockSize(256n)
2251
- * // ...
2252
- * ```
2253
- *
2254
- * @example Create a directory that contains several files
2255
- *
2256
- * Creating a directory that contains several files is achieve by creating a unixfs element that identifies a MerkleDAG node as a directory. The links of that MerkleDAG node are the files that are contained in this directory.
2257
- *
2258
- * ```TypeScript
2259
- * import { UnixFS } from 'ipfs-unixfs'
2260
- *
2261
- * const data = new UnixFS({ type: 'directory' })
2262
- * ```
2263
- *
2264
- * @example Create an unixfs Data element
2265
- *
2266
- * ```TypeScript
2267
- * import { UnixFS } from 'ipfs-unixfs'
2268
- *
2269
- * const data = new UnixFS({
2270
- * // ...options
2271
- * })
2272
- * ```
2273
- *
2274
- * `options` is an optional object argument that might include the following keys:
2275
- *
2276
- * - type (string, default `file`): The type of UnixFS entry. Can be:
2277
- * - `raw`
2278
- * - `directory`
2279
- * - `file`
2280
- * - `metadata`
2281
- * - `symlink`
2282
- * - `hamt-sharded-directory`
2283
- * - data (Uint8Array): The optional data field for this node
2284
- * - blockSizes (Array, default: `[]`): If this is a `file` node that is made up of multiple blocks, `blockSizes` is a list numbers that represent the size of the file chunks stored in each child node. It is used to calculate the total file size.
2285
- * - mode (Number, default `0644` for files, `0755` for directories/hamt-sharded-directories) file mode
2286
- * - mtime (`Date`, `{ secs, nsecs }`, `{ Seconds, FractionalNanoseconds }`, `[ secs, nsecs ]`): The modification time of this node
2287
- *
2288
- * @example Add and remove a block size to the block size list
2289
- *
2290
- * ```TypeScript
2291
- * import { UnixFS } from 'ipfs-unixfs'
2292
- *
2293
- * const data = new UnixFS({ type: 'file' })
2294
- * const sizeInBytes = 100n
2295
- * data.addBlockSize(sizeInBytes)
2296
- * ```
2297
- *
2298
- * ```TypeScript
2299
- * import { UnixFS } from 'ipfs-unixfs'
2300
- *
2301
- * const data = new UnixFS({ type: 'file' })
2302
- *
2303
- * const index = 0
2304
- * data.removeBlockSize(index)
2305
- * ```
2306
- *
2307
- * @example Get total fileSize
2308
- *
2309
- * ```TypeScript
2310
- * import { UnixFS } from 'ipfs-unixfs'
2311
- *
2312
- * const data = new UnixFS({ type: 'file' })
2313
- * data.fileSize() // => size in bytes
2314
- * ```
2315
- *
2316
- * @example Marshal and unmarshal
2317
- *
2318
- * ```TypeScript
2319
- * import { UnixFS } from 'ipfs-unixfs'
2320
- *
2321
- * const data = new UnixFS({ type: 'file' })
2322
- * const marshaled = data.marshal()
2323
- * const unmarshaled = UnixFS.unmarshal(marshaled)
2324
- * ```
2325
- *
2326
- * @example Is this UnixFS entry a directory?
2327
- *
2328
- * ```TypeScript
2329
- * import { UnixFS } from 'ipfs-unixfs'
2330
- *
2331
- * const dir = new UnixFS({ type: 'directory' })
2332
- * dir.isDirectory() // true
2333
- *
2334
- * const file = new UnixFS({ type: 'file' })
2335
- * file.isDirectory() // false
2336
- * ```
2337
- *
2338
- * @example Has an mtime been set?
2339
- *
2340
- * If no modification time has been set, no `mtime` property will be present on the `Data` instance:
2341
- *
2342
- * ```TypeScript
2343
- * import { UnixFS } from 'ipfs-unixfs'
2344
- *
2345
- * const file = new UnixFS({ type: 'file' })
2346
- * file.mtime // undefined
2347
- *
2348
- * Object.prototype.hasOwnProperty.call(file, 'mtime') // false
2349
- *
2350
- * const dir = new UnixFS({ type: 'directory', mtime: { secs: 5n } })
2351
- * dir.mtime // { secs: Number, nsecs: Number }
2352
- * ```
2353
- */
2354
- const types = {
2355
- RAW: "raw",
2356
- DIRECTORY: "directory",
2357
- FILE: "file",
2358
- METADATA: "metadata",
2359
- SYMLINK: "symlink",
2360
- HAMT_SHARD: "hamt-sharded-directory"
2361
- };
2362
- const dirTypes = ["directory", "hamt-sharded-directory"];
2363
- const DEFAULT_FILE_MODE = parseInt("0644", 8);
2364
- const DEFAULT_DIRECTORY_MODE = parseInt("0755", 8);
2365
- var UnixFS = class UnixFS {
2366
- /**
2367
- * Decode from protobuf https://github.com/ipfs/specs/blob/master/UNIXFS.md
2368
- */
2369
- static unmarshal(marshaled) {
2370
- const message = UnixFS$1.decode(marshaled);
2371
- const data = new UnixFS({
2372
- type: types[message.type != null ? message.type.toString() : "FILE"],
2373
- data: message.data,
2374
- blockSizes: message.blockSizes,
2375
- mode: message.mode,
2376
- mtime: message.mtime != null ? {
2377
- secs: message.mtime.seconds ?? 0n,
2378
- nsecs: message.mtime.fractionalNanoseconds
2379
- } : void 0,
2380
- fanout: message.fanOut
2381
- });
2382
- data._originalMode = message.mode ?? 0;
2383
- return data;
2384
- }
2385
- type;
2386
- data;
2387
- blockSizes;
2388
- hashType;
2389
- fanout;
2390
- mtime;
2391
- _mode;
2392
- _originalMode;
2393
- constructor(options = { type: "file" }) {
2394
- const { type, data, blockSizes, hashType, fanout, mtime, mode } = options;
2395
- if (type != null && !Object.values(types).includes(type)) throw new InvalidTypeError("Type: " + type + " is not valid");
2396
- this.type = type ?? "file";
2397
- this.hashType = hashType;
2398
- this.fanout = fanout;
2399
- this.blockSizes = blockSizes ?? [];
2400
- this._originalMode = 0;
2401
- this.mode = mode;
2402
- this.mtime = mtime;
2403
- if (data != null) this.data = withArrayBuffer(data);
2404
- }
2405
- set mode(mode) {
2406
- if (mode == null) this._mode = this.isDirectory() ? DEFAULT_DIRECTORY_MODE : DEFAULT_FILE_MODE;
2407
- else this._mode = mode & 4095;
2408
- }
2409
- get mode() {
2410
- return this._mode;
2411
- }
2412
- isDirectory() {
2413
- return dirTypes.includes(this.type);
2414
- }
2415
- addBlockSize(size) {
2416
- this.blockSizes.push(size);
2417
- }
2418
- removeBlockSize(index) {
2419
- this.blockSizes.splice(index, 1);
2420
- }
2421
- /**
2422
- * Returns `0n` for directories or `data.length + sum(blockSizes)` for everything else
2423
- */
2424
- fileSize() {
2425
- if (this.isDirectory()) return 0n;
2426
- let sum = 0n;
2427
- this.blockSizes.forEach((size) => {
2428
- sum += size;
2429
- });
2430
- if (this.data != null) sum += BigInt(this.data.length);
2431
- return sum;
2432
- }
2433
- /**
2434
- * encode to protobuf Uint8Array
2435
- */
2436
- marshal() {
2437
- let type;
2438
- switch (this.type) {
2439
- case "raw":
2440
- type = UnixFS$1.Type.RAW;
2441
- break;
2442
- case "directory":
2443
- type = UnixFS$1.Type.DIRECTORY;
2444
- break;
2445
- case "file":
2446
- type = UnixFS$1.Type.FILE;
2447
- break;
2448
- case "metadata":
2449
- type = UnixFS$1.Type.METADATA;
2450
- break;
2451
- case "symlink":
2452
- type = UnixFS$1.Type.SYMLINK;
2453
- break;
2454
- case "hamt-sharded-directory":
2455
- type = UnixFS$1.Type.HAMT_SHARD;
2456
- break;
2457
- default: throw new InvalidTypeError(`Type: ${type} is not valid`);
2458
- }
2459
- let data = this.data;
2460
- if (this.data == null || this.data.length === 0) data = void 0;
2461
- let mode;
2462
- if (this.mode != null) {
2463
- mode = this._originalMode & 4294963200 | (this.mode ?? 0);
2464
- if (mode === DEFAULT_FILE_MODE && !this.isDirectory()) mode = void 0;
2465
- if (mode === DEFAULT_DIRECTORY_MODE && this.isDirectory()) mode = void 0;
2466
- }
2467
- let mtime;
2468
- if (this.mtime != null) mtime = {
2469
- seconds: this.mtime.secs,
2470
- fractionalNanoseconds: this.mtime.nsecs
2471
- };
2472
- return UnixFS$1.encode({
2473
- type,
2474
- data,
2475
- fileSize: this.type === "file" || this.type === "raw" ? this.fileSize() : void 0,
2476
- blockSizes: this.blockSizes,
2477
- hashType: this.hashType,
2478
- fanOut: this.fanout,
2479
- mode,
2480
- mtime
2481
- });
2482
- }
2483
- };
2484
- //#endregion
2485
488
  //#region node_modules/progress-events/dist/src/index.js
2486
489
  /**
2487
490
  * An implementation of the ProgressEvent interface, this is essentially
@@ -4290,4 +2293,4 @@ async function importFile(content, blockstore, options = {}) {
4290
2293
  return result;
4291
2294
  }
4292
2295
  //#endregion
4293
- export { importFile };
2296
+ export { importFile, importer };