@gardenfi/utils 2.0.5 → 2.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 (103) hide show
  1. package/dist/index100.cjs +1 -1
  2. package/dist/index100.js +127 -6
  3. package/dist/index101.cjs +1 -2
  4. package/dist/index101.js +113 -3
  5. package/dist/index102.cjs +1 -1
  6. package/dist/index102.js +75 -109
  7. package/dist/index103.cjs +1 -1
  8. package/dist/index103.js +2 -79
  9. package/dist/index104.cjs +1 -1
  10. package/dist/index104.js +18 -2
  11. package/dist/index105.cjs +1 -1
  12. package/dist/index105.js +15 -14
  13. package/dist/index106.cjs +1 -1
  14. package/dist/index106.js +16 -18
  15. package/dist/index107.cjs +1 -1
  16. package/dist/index107.js +220 -13
  17. package/dist/index108.cjs +2 -1
  18. package/dist/index108.js +3 -224
  19. package/dist/index115.cjs +1 -1
  20. package/dist/index115.js +1 -1
  21. package/dist/index117.cjs +1 -1
  22. package/dist/index117.js +1 -1
  23. package/dist/index18.cjs +1 -1
  24. package/dist/index18.js +8 -8
  25. package/dist/index19.cjs +1 -1
  26. package/dist/index19.js +1 -1
  27. package/dist/index21.cjs +1 -1
  28. package/dist/index21.js +1 -1
  29. package/dist/index37.cjs +1 -1
  30. package/dist/index37.js +1 -1
  31. package/dist/index40.cjs +1 -1
  32. package/dist/index40.js +1 -1
  33. package/dist/index42.cjs +1 -1
  34. package/dist/index42.js +1 -1
  35. package/dist/index47.cjs +1 -1
  36. package/dist/index47.js +1 -1
  37. package/dist/index50.cjs +2 -1
  38. package/dist/index50.js +34 -3
  39. package/dist/index51.cjs +1 -2
  40. package/dist/index51.js +5 -34
  41. package/dist/index52.cjs +1 -1
  42. package/dist/index52.js +3 -5
  43. package/dist/index55.cjs +1 -1
  44. package/dist/index55.js +1 -1
  45. package/dist/index56.cjs +1 -1
  46. package/dist/index56.js +2 -2
  47. package/dist/index62.cjs +1 -1
  48. package/dist/index62.js +1 -1
  49. package/dist/index64.cjs +1 -1
  50. package/dist/index64.js +3 -3
  51. package/dist/index69.cjs +1 -1
  52. package/dist/index69.js +3 -5
  53. package/dist/index70.cjs +1 -1
  54. package/dist/index70.js +13 -8
  55. package/dist/index71.cjs +1 -1
  56. package/dist/index71.js +41 -3
  57. package/dist/index72.cjs +1 -1
  58. package/dist/index72.js +5 -13
  59. package/dist/index73.cjs +1 -1
  60. package/dist/index73.js +8 -41
  61. package/dist/index75.cjs +1 -1
  62. package/dist/index75.js +1 -1
  63. package/dist/index79.cjs +1 -1
  64. package/dist/index79.js +11 -24
  65. package/dist/index80.cjs +1 -1
  66. package/dist/index80.js +25 -6
  67. package/dist/index81.cjs +1 -1
  68. package/dist/index81.js +6 -13
  69. package/dist/index82.cjs +1 -1
  70. package/dist/index82.js +13 -15
  71. package/dist/index83.cjs +1 -1
  72. package/dist/index83.js +15 -5
  73. package/dist/index84.cjs +1 -1
  74. package/dist/index84.js +5 -13
  75. package/dist/index85.cjs +1 -1
  76. package/dist/index85.js +12 -9
  77. package/dist/index86.cjs +1 -1
  78. package/dist/index86.js +10 -16
  79. package/dist/index87.cjs +1 -1
  80. package/dist/index87.js +15 -170
  81. package/dist/index88.cjs +1 -1
  82. package/dist/index88.js +171 -8
  83. package/dist/index89.cjs +1 -1
  84. package/dist/index89.js +37 -11
  85. package/dist/index90.cjs +1 -1
  86. package/dist/index90.js +8 -104
  87. package/dist/index91.cjs +1 -1
  88. package/dist/index91.js +5 -39
  89. package/dist/index92.cjs +1 -1
  90. package/dist/index92.js +11 -2
  91. package/dist/index93.cjs +1 -1
  92. package/dist/index93.js +2 -5
  93. package/dist/index94.cjs +1 -1
  94. package/dist/index94.js +104 -10
  95. package/dist/index95.cjs +1 -1
  96. package/dist/index95.js +1 -1
  97. package/dist/index97.cjs +1 -1
  98. package/dist/index97.js +7 -5
  99. package/dist/index98.cjs +1 -1
  100. package/dist/index98.js +5 -38
  101. package/dist/index99.cjs +1 -1
  102. package/dist/index99.js +36 -126
  103. package/package.json +1 -1
package/dist/index99.js CHANGED
@@ -1,130 +1,40 @@
1
- import { RecursiveReadLimitExceededError as e, PositionOutOfBoundsError as n, NegativeOffsetError as o } from "./index96.js";
2
- const h = {
3
- bytes: new Uint8Array(),
4
- dataView: new DataView(new ArrayBuffer(0)),
5
- position: 0,
6
- positionReadCount: /* @__PURE__ */ new Map(),
7
- recursiveReadCount: 0,
8
- recursiveReadLimit: Number.POSITIVE_INFINITY,
9
- assertReadLimit() {
10
- if (this.recursiveReadCount >= this.recursiveReadLimit)
11
- throw new e({
12
- count: this.recursiveReadCount + 1,
13
- limit: this.recursiveReadLimit
14
- });
15
- },
16
- assertPosition(t) {
17
- if (t < 0 || t > this.bytes.length - 1)
18
- throw new n({
19
- length: this.bytes.length,
20
- position: t
21
- });
22
- },
23
- decrementPosition(t) {
24
- if (t < 0)
25
- throw new o({ offset: t });
26
- const i = this.position - t;
27
- this.assertPosition(i), this.position = i;
28
- },
29
- getReadCount(t) {
30
- return this.positionReadCount.get(t || this.position) || 0;
31
- },
32
- incrementPosition(t) {
33
- if (t < 0)
34
- throw new o({ offset: t });
35
- const i = this.position + t;
36
- this.assertPosition(i), this.position = i;
37
- },
38
- inspectByte(t) {
39
- const i = t ?? this.position;
40
- return this.assertPosition(i), this.bytes[i];
41
- },
42
- inspectBytes(t, i) {
43
- const s = i ?? this.position;
44
- return this.assertPosition(s + t - 1), this.bytes.subarray(s, s + t);
45
- },
46
- inspectUint8(t) {
47
- const i = t ?? this.position;
48
- return this.assertPosition(i), this.bytes[i];
49
- },
50
- inspectUint16(t) {
51
- const i = t ?? this.position;
52
- return this.assertPosition(i + 1), this.dataView.getUint16(i);
53
- },
54
- inspectUint24(t) {
55
- const i = t ?? this.position;
56
- return this.assertPosition(i + 2), (this.dataView.getUint16(i) << 8) + this.dataView.getUint8(i + 2);
57
- },
58
- inspectUint32(t) {
59
- const i = t ?? this.position;
60
- return this.assertPosition(i + 3), this.dataView.getUint32(i);
61
- },
62
- pushByte(t) {
63
- this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
64
- },
65
- pushBytes(t) {
66
- this.assertPosition(this.position + t.length - 1), this.bytes.set(t, this.position), this.position += t.length;
67
- },
68
- pushUint8(t) {
69
- this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
70
- },
71
- pushUint16(t) {
72
- this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, t), this.position += 2;
73
- },
74
- pushUint24(t) {
75
- this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, t >> 8), this.dataView.setUint8(this.position + 2, t & 255), this.position += 3;
76
- },
77
- pushUint32(t) {
78
- this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, t), this.position += 4;
79
- },
80
- readByte() {
81
- this.assertReadLimit(), this._touch();
82
- const t = this.inspectByte();
83
- return this.position++, t;
84
- },
85
- readBytes(t, i) {
86
- this.assertReadLimit(), this._touch();
87
- const s = this.inspectBytes(t);
88
- return this.position += i ?? t, s;
89
- },
90
- readUint8() {
91
- this.assertReadLimit(), this._touch();
92
- const t = this.inspectUint8();
93
- return this.position += 1, t;
94
- },
95
- readUint16() {
96
- this.assertReadLimit(), this._touch();
97
- const t = this.inspectUint16();
98
- return this.position += 2, t;
99
- },
100
- readUint24() {
101
- this.assertReadLimit(), this._touch();
102
- const t = this.inspectUint24();
103
- return this.position += 3, t;
104
- },
105
- readUint32() {
106
- this.assertReadLimit(), this._touch();
107
- const t = this.inspectUint32();
108
- return this.position += 4, t;
109
- },
110
- get remaining() {
111
- return this.bytes.length - this.position;
112
- },
113
- setPosition(t) {
114
- const i = this.position;
115
- return this.assertPosition(t), this.position = t, () => this.position = i;
116
- },
117
- _touch() {
118
- if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
119
- return;
120
- const t = this.getReadCount();
121
- this.positionReadCount.set(this.position, t + 1), t > 0 && this.recursiveReadCount++;
1
+ import { versionedHashVersionKzg as a } from "./index103.js";
2
+ import { BaseError as s } from "./index43.js";
3
+ class t extends s {
4
+ constructor({ maxSize: e, size: r }) {
5
+ super("Blob size is too large.", {
6
+ metaMessages: [`Max: ${e} bytes`, `Given: ${r} bytes`],
7
+ name: "BlobSizeTooLargeError"
8
+ });
9
+ }
10
+ }
11
+ class d extends s {
12
+ constructor() {
13
+ super("Blob data must not be empty.", { name: "EmptyBlobError" });
14
+ }
15
+ }
16
+ class l extends s {
17
+ constructor({ hash: e, size: r }) {
18
+ super(`Versioned hash "${e}" size is invalid.`, {
19
+ metaMessages: ["Expected: 32", `Received: ${r}`],
20
+ name: "InvalidVersionedHashSizeError"
21
+ });
22
+ }
23
+ }
24
+ class c extends s {
25
+ constructor({ hash: e, version: r }) {
26
+ super(`Versioned hash "${e}" version is invalid.`, {
27
+ metaMessages: [
28
+ `Expected: ${a}`,
29
+ `Received: ${r}`
30
+ ],
31
+ name: "InvalidVersionedHashVersionError"
32
+ });
122
33
  }
123
- };
124
- function a(t, { recursiveReadLimit: i = 8192 } = {}) {
125
- const s = Object.create(h);
126
- return s.bytes = t, s.dataView = new DataView(t.buffer, t.byteOffset, t.byteLength), s.positionReadCount = /* @__PURE__ */ new Map(), s.recursiveReadLimit = i, s;
127
34
  }
128
35
  export {
129
- a as createCursor
36
+ t as BlobSizeTooLargeError,
37
+ d as EmptyBlobError,
38
+ l as InvalidVersionedHashSizeError,
39
+ c as InvalidVersionedHashVersionError
130
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",