@cbortech/cbor 0.25.6 → 0.25.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +83 -5
- package/README.md +83 -5
- package/dist/ast/CborIndefiniteTextString.d.ts +1 -1
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +1 -1
- package/dist/cbor.d.ts +48 -15
- package/dist/cdn/index.cjs +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/tokenizer.d.ts +3 -0
- package/dist/index.cjs +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +176 -16
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-BQYXoTz7.cjs +12 -0
- package/dist/mapEntries-BQYXoTz7.cjs.map +1 -0
- package/dist/{mapEntries-DDh7IS2M.js → mapEntries-Cc4If3gy.js} +660 -616
- package/dist/mapEntries-Cc4If3gy.js.map +1 -0
- package/dist/{tokenizer-C8NLHT2B.cjs → tokenizer-Cg5EIl83.cjs} +4 -4
- package/dist/tokenizer-Cg5EIl83.cjs.map +1 -0
- package/dist/{tokenizer-C597LW89.js → tokenizer-IDqJN0Dw.js} +6 -5
- package/dist/tokenizer-IDqJN0Dw.js.map +1 -0
- package/dist/types.d.ts +41 -7
- package/package.json +3 -3
- package/dist/mapEntries-DDh7IS2M.js.map +0 -1
- package/dist/mapEntries-DvugpzeP.cjs +0 -12
- package/dist/mapEntries-DvugpzeP.cjs.map +0 -1
- package/dist/tokenizer-C597LW89.js.map +0 -1
- package/dist/tokenizer-C8NLHT2B.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, t } from "./tokenizer-
|
|
1
|
+
import { n as e, t } from "./tokenizer-IDqJN0Dw.js";
|
|
2
2
|
//#region src/tag.ts
|
|
3
3
|
var n = Symbol.for("cbor.tag"), r = class {
|
|
4
4
|
valueOf() {
|
|
@@ -93,18 +93,18 @@ var u = class {
|
|
|
93
93
|
static get(t) {
|
|
94
94
|
return t instanceof e ? t.value : void 0;
|
|
95
95
|
}
|
|
96
|
-
}, p = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), m = new Int8Array(128).fill(-1);
|
|
96
|
+
}, p = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), m = (/* @__PURE__ */ new Int8Array(128)).fill(-1);
|
|
97
97
|
for (let e = 0; e < 16; e++) m["0123456789abcdef".charCodeAt(e)] = e, m["0123456789ABCDEF".charCodeAt(e)] = e;
|
|
98
|
-
var h = typeof Uint8Array.prototype.toHex == "function",
|
|
99
|
-
function
|
|
98
|
+
var h = typeof Uint8Array.prototype.toHex == "function", g = typeof Uint8Array.fromHex == "function", ee = 256;
|
|
99
|
+
function te(e) {
|
|
100
100
|
if (h) return e.toHex();
|
|
101
101
|
let t = "";
|
|
102
102
|
for (let n = 0; n < e.length; n++) t += p[e[n]];
|
|
103
103
|
return t;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function ne(e) {
|
|
106
106
|
if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
|
|
107
|
-
if (
|
|
107
|
+
if (g && e.length >= ee) return Uint8Array.fromHex(e);
|
|
108
108
|
let t = new Uint8Array(e.length / 2);
|
|
109
109
|
for (let n = 0, r = 0; n < e.length; n += 2, r++) {
|
|
110
110
|
let i = e.charCodeAt(n), a = e.charCodeAt(n + 1), o = i < 128 ? m[i] : -1, s = a < 128 ? m[a] : -1;
|
|
@@ -118,20 +118,20 @@ function re(e) {
|
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/cdn/serialize-utils.ts
|
|
121
|
-
function
|
|
121
|
+
function re(e) {
|
|
122
122
|
let t = e?.indent;
|
|
123
123
|
return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function _(e, t) {
|
|
126
126
|
return e.repeat(t);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function ie(e) {
|
|
129
129
|
return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function ae(e) {
|
|
132
132
|
return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function v(e, t) {
|
|
135
135
|
if (!t) return e.text;
|
|
136
136
|
let { marker: n, text: r } = e;
|
|
137
137
|
if (t === "c-style") return n === "#" ? "//" + r.slice(1) : n === "/" ? "/*" + r.slice(1, -1) + "*/" : r;
|
|
@@ -142,17 +142,17 @@ function _(e, t) {
|
|
|
142
142
|
}
|
|
143
143
|
return r;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
return (e.comments?.leading ?? []).map((e) => t +
|
|
145
|
+
function oe(e, t, n) {
|
|
146
|
+
return (e.comments?.leading ?? []).map((e) => t + v(e, n));
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function se(e, t) {
|
|
149
149
|
let n = e.comments?.trailing ?? [];
|
|
150
|
-
return n.length === 0 ? "" : " " + n.map((e) =>
|
|
150
|
+
return n.length === 0 ? "" : " " + n.map((e) => v(e, t)).join(" ");
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
return (e.comments?.dangling ?? []).map((e) => t +
|
|
152
|
+
function ce(e, t, n) {
|
|
153
|
+
return (e.comments?.dangling ?? []).map((e) => t + v(e, n));
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function le(e, t = !1) {
|
|
156
156
|
let n = e?.commas ?? "comma", r = n !== "none";
|
|
157
157
|
return {
|
|
158
158
|
inlineSep: r ? t ? "," : ", " : " ",
|
|
@@ -161,15 +161,15 @@ function ue(e, t = !1) {
|
|
|
161
161
|
colSep: t ? ":" : ": "
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
-
var
|
|
165
|
-
function
|
|
166
|
-
if (
|
|
164
|
+
var ue = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
|
|
165
|
+
function de(e) {
|
|
166
|
+
if (ue) return e.toBase64({ omitPadding: !0 });
|
|
167
167
|
let t = "";
|
|
168
168
|
for (let n of e) t += String.fromCharCode(n);
|
|
169
169
|
return btoa(t).replace(/=/g, "");
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
if (
|
|
171
|
+
function fe(e) {
|
|
172
|
+
if (ue) return e.toBase64({
|
|
173
173
|
alphabet: "base64url",
|
|
174
174
|
omitPadding: !0
|
|
175
175
|
});
|
|
@@ -177,54 +177,54 @@ function pe(e) {
|
|
|
177
177
|
for (let n of e) t += String.fromCharCode(n);
|
|
178
178
|
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
179
179
|
}
|
|
180
|
-
var
|
|
181
|
-
function
|
|
180
|
+
var pe = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", me = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
181
|
+
function he(e, t) {
|
|
182
182
|
let n = "", r = 0, i = 0;
|
|
183
183
|
for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
|
|
184
184
|
return i > 0 && (n += t[r << 5 - i & 31]), n;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function ge(e) {
|
|
187
187
|
for (let t of e) {
|
|
188
188
|
let e = t.codePointAt(0);
|
|
189
189
|
if (e < 32 || e === 127) return !0;
|
|
190
190
|
}
|
|
191
191
|
return !1;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function _e(e, t, n) {
|
|
194
194
|
if (n === "string") {
|
|
195
|
-
let t =
|
|
196
|
-
if (t != null) return
|
|
195
|
+
let t = ye(e);
|
|
196
|
+
if (t != null) return Se(t);
|
|
197
197
|
}
|
|
198
198
|
if (n === "printable-string" || n === void 0) {
|
|
199
|
-
let t =
|
|
200
|
-
if (t != null && !
|
|
199
|
+
let t = ye(e);
|
|
200
|
+
if (t != null && !ge(t)) return Se(t);
|
|
201
201
|
}
|
|
202
202
|
switch (t) {
|
|
203
|
-
case "base64": return `b64'${
|
|
204
|
-
case "base64url": return `b64'${
|
|
205
|
-
case "base32": return `b32'${
|
|
206
|
-
case "base32hex": return `h32'${
|
|
207
|
-
default: return `h'${
|
|
203
|
+
case "base64": return `b64'${de(e)}'`;
|
|
204
|
+
case "base64url": return `b64'${fe(e)}'`;
|
|
205
|
+
case "base32": return `b32'${he(e, pe)}'`;
|
|
206
|
+
case "base32hex": return `h32'${he(e, me)}'`;
|
|
207
|
+
default: return `h'${te(e)}'`;
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
var
|
|
211
|
-
function
|
|
210
|
+
var ve = new TextDecoder("utf-8", { fatal: !0 });
|
|
211
|
+
function ye(e) {
|
|
212
212
|
try {
|
|
213
|
-
return
|
|
213
|
+
return ve.decode(e);
|
|
214
214
|
} catch {
|
|
215
215
|
return null;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function be(e, t) {
|
|
219
219
|
for (let n = 0; n < e.length; n++) {
|
|
220
220
|
let r = e.charCodeAt(n);
|
|
221
221
|
if (r === t || r === 92 || r < 32 || r === 127 || r >= 8192 && (r === 8232 || r === 8233 || r >= 8203 && r <= 8205 || r === 65279)) return !0;
|
|
222
222
|
}
|
|
223
223
|
return !1;
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function xe(e, t) {
|
|
226
226
|
let n = t.codePointAt(0);
|
|
227
|
-
if (!
|
|
227
|
+
if (!be(e, n)) return t + e + t;
|
|
228
228
|
let r = t;
|
|
229
229
|
for (let i of e) {
|
|
230
230
|
let e = i.codePointAt(0);
|
|
@@ -249,40 +249,40 @@ function Se(e, t) {
|
|
|
249
249
|
}
|
|
250
250
|
return r + t;
|
|
251
251
|
}
|
|
252
|
+
function Se(e) {
|
|
253
|
+
return xe(e, "'");
|
|
254
|
+
}
|
|
252
255
|
function Ce(e) {
|
|
253
|
-
return
|
|
256
|
+
return xe(e, "'");
|
|
254
257
|
}
|
|
255
258
|
function we(e) {
|
|
256
|
-
return
|
|
259
|
+
return xe(e, "\"");
|
|
257
260
|
}
|
|
258
261
|
function Te(e) {
|
|
259
|
-
return Se(e, "\"");
|
|
260
|
-
}
|
|
261
|
-
function Ee(e) {
|
|
262
262
|
if (isNaN(e)) return "NaN";
|
|
263
263
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
264
264
|
if (Object.is(e, -0)) return "-0.0";
|
|
265
265
|
let t = e.toString();
|
|
266
266
|
return t.includes(".") || t.includes("e") ? t : t + ".0";
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function Ee(e, t, n, r) {
|
|
269
269
|
if (r === "never") return "";
|
|
270
270
|
let i = t ?? n;
|
|
271
271
|
return r === "always" ? i === "half" ? "_1" : i === "single" ? "_2" : "_3" : t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
|
|
272
272
|
}
|
|
273
|
-
function
|
|
273
|
+
function y(e) {
|
|
274
274
|
return e <= 23n ? "i" : e <= 255n ? 0 : e <= 65535n ? 1 : e <= 4294967295n ? 2 : 3;
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function b(e, t, n) {
|
|
277
277
|
let r = e?.encodingIndicators ?? "auto";
|
|
278
278
|
return r === "never" ? "" : r === "always" ? `_${t ?? n()}` : t === void 0 ? "" : `_${t}`;
|
|
279
279
|
}
|
|
280
280
|
//#endregion
|
|
281
281
|
//#region src/utils/float16.ts
|
|
282
|
-
var
|
|
283
|
-
function
|
|
284
|
-
|
|
285
|
-
let t =
|
|
282
|
+
var De = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Oe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
283
|
+
function x(e) {
|
|
284
|
+
Oe.setFloat64(0, e, !1);
|
|
285
|
+
let t = Oe.getUint32(0, !1), n = Oe.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
286
286
|
if (i === 2047) {
|
|
287
287
|
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
288
288
|
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
@@ -303,15 +303,15 @@ function b(e) {
|
|
|
303
303
|
let u = o <= 0 ? 0 : o;
|
|
304
304
|
return r << 15 | u << 10 | s;
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function S(e) {
|
|
307
307
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
308
308
|
return n === 31 ? r === 0 ? t ? -Infinity : Infinity : NaN : n === 0 ? r === 0 ? t ? -0 : 0 : (t ? -1 : 1) * 2 ** -14 * (r / 1024) : (t ? -1 : 1) * 2 ** (n - 15) * (1 + r / 1024);
|
|
309
309
|
}
|
|
310
|
-
var
|
|
310
|
+
var ke = De ? (e, t, n, r) => {
|
|
311
311
|
e.setFloat16(t, n, r);
|
|
312
312
|
} : (e, t, n, r) => {
|
|
313
|
-
e.setUint16(t,
|
|
314
|
-
},
|
|
313
|
+
e.setUint16(t, x(n), r);
|
|
314
|
+
}, C = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), w = new Uint8Array(C.buffer), Ae = class {
|
|
315
315
|
buf;
|
|
316
316
|
len = 0;
|
|
317
317
|
constructor(e = 256) {
|
|
@@ -342,34 +342,34 @@ var Ae = Oe ? (e, t, n, r) => {
|
|
|
342
342
|
t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
343
343
|
}
|
|
344
344
|
writeBigUint64(e) {
|
|
345
|
-
|
|
345
|
+
C.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(w, this.len), this.len += 8;
|
|
346
346
|
}
|
|
347
347
|
writeFloat16(e) {
|
|
348
|
-
|
|
348
|
+
ke(C, 0, e, !1), this._ensure(2);
|
|
349
349
|
let t = this.buf;
|
|
350
|
-
t[this.len++] =
|
|
350
|
+
t[this.len++] = w[0], t[this.len++] = w[1];
|
|
351
351
|
}
|
|
352
352
|
writeFloat32(e) {
|
|
353
|
-
|
|
353
|
+
C.setFloat32(0, e, !1), this._ensure(4);
|
|
354
354
|
let t = this.buf;
|
|
355
|
-
t[this.len++] =
|
|
355
|
+
t[this.len++] = w[0], t[this.len++] = w[1], t[this.len++] = w[2], t[this.len++] = w[3];
|
|
356
356
|
}
|
|
357
357
|
writeFloat64(e) {
|
|
358
|
-
|
|
358
|
+
C.setFloat64(0, e, !1), this._ensure(8), this.buf.set(w, this.len), this.len += 8;
|
|
359
359
|
}
|
|
360
360
|
finish() {
|
|
361
361
|
return this.buf.slice(0, this.len);
|
|
362
362
|
}
|
|
363
|
-
},
|
|
363
|
+
}, je = [
|
|
364
364
|
255n,
|
|
365
365
|
65535n,
|
|
366
366
|
4294967295n,
|
|
367
367
|
18446744073709551615n
|
|
368
368
|
];
|
|
369
|
-
function
|
|
370
|
-
return e === "i" ? 23n :
|
|
369
|
+
function Me(e) {
|
|
370
|
+
return e === "i" ? 23n : je[e];
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function T(e, t, n, r) {
|
|
373
373
|
if (r === void 0 && typeof n == "number" && n < 4294967296) {
|
|
374
374
|
n <= 23 ? e.writeByte(t << 5 | n) : n <= 255 ? (e.writeByte(t << 5 | 24), e.writeByte(n)) : n <= 65535 ? (e.writeByte(t << 5 | 25), e.writeUint16(n)) : (e.writeByte(t << 5 | 26), e.writeUint32(n));
|
|
375
375
|
return;
|
|
@@ -381,30 +381,30 @@ function w(e, t, n, r) {
|
|
|
381
381
|
e.writeByte(t << 5 | Number(i));
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
|
-
if (i >
|
|
384
|
+
if (i > je[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${je[r]})`);
|
|
385
385
|
let n = 24 + r;
|
|
386
386
|
e.writeByte(t << 5 | n), n === 24 ? e.writeByte(Number(i)) : n === 25 ? e.writeUint16(Number(i)) : n === 26 ? e.writeUint32(Number(i)) : e.writeBigUint64(i);
|
|
387
387
|
return;
|
|
388
388
|
}
|
|
389
389
|
i <= 23n ? e.writeByte(t << 5 | Number(i)) : i <= 255n ? (e.writeByte(t << 5 | 24), e.writeByte(Number(i))) : i <= 65535n ? (e.writeByte(t << 5 | 25), e.writeUint16(Number(i))) : i <= 4294967295n ? (e.writeByte(t << 5 | 26), e.writeUint32(Number(i))) : (e.writeByte(t << 5 | 27), e.writeBigUint64(i));
|
|
390
390
|
}
|
|
391
|
-
function
|
|
392
|
-
let r = new
|
|
393
|
-
return
|
|
391
|
+
function Ne(e, t, n) {
|
|
392
|
+
let r = new Ae(9);
|
|
393
|
+
return T(r, e, t, n), r.finish();
|
|
394
394
|
}
|
|
395
|
-
var
|
|
396
|
-
function
|
|
397
|
-
return Object.is(x(
|
|
395
|
+
var Pe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
396
|
+
function Fe(e) {
|
|
397
|
+
return Object.is(S(x(e)), e);
|
|
398
398
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
399
|
+
function Ie(e) {
|
|
400
|
+
return Pe.setFloat32(0, e, !1), Object.is(Pe.getFloat32(0, !1), e);
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
402
|
+
function E(e) {
|
|
403
|
+
return Fe(e) ? "half" : Ie(e) ? "single" : "double";
|
|
404
404
|
}
|
|
405
405
|
//#endregion
|
|
406
406
|
//#region src/ast/CborItem.ts
|
|
407
|
-
var
|
|
407
|
+
var D = class e {
|
|
408
408
|
start;
|
|
409
409
|
end;
|
|
410
410
|
comments;
|
|
@@ -414,7 +414,7 @@ var E = class e {
|
|
|
414
414
|
let t = this._defaults ? {
|
|
415
415
|
...this._defaults,
|
|
416
416
|
...e
|
|
417
|
-
} : e, n = new
|
|
417
|
+
} : e, n = new Ae();
|
|
418
418
|
return this._encode(n, t), n.finish();
|
|
419
419
|
}
|
|
420
420
|
toCDN(e) {
|
|
@@ -423,7 +423,7 @@ var E = class e {
|
|
|
423
423
|
...e
|
|
424
424
|
} : e, n = this._toCDN(t, 0), r = t?.preserveComments;
|
|
425
425
|
if (!r) return n;
|
|
426
|
-
let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) =>
|
|
426
|
+
let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) => v(e, i)) ?? [], o = this.comments?.trailing ?? [], s = o.length === 0 ? n : `${n} ${o.map((e) => v(e, i).trimEnd()).join(" ")}`;
|
|
427
427
|
return [...a, s].join("\n");
|
|
428
428
|
}
|
|
429
429
|
toEDN(e) {
|
|
@@ -457,7 +457,7 @@ var E = class e {
|
|
|
457
457
|
t.writeBytes(this._toCBOR(n));
|
|
458
458
|
}
|
|
459
459
|
_toCBOR(e) {
|
|
460
|
-
let t = new
|
|
460
|
+
let t = new Ae();
|
|
461
461
|
return this._encodeTo(t, e), t.finish();
|
|
462
462
|
}
|
|
463
463
|
_toHexDump(e, t) {
|
|
@@ -467,7 +467,7 @@ var E = class e {
|
|
|
467
467
|
comment: this._toCDN(t, 0)
|
|
468
468
|
}];
|
|
469
469
|
}
|
|
470
|
-
},
|
|
470
|
+
}, O = class extends D {
|
|
471
471
|
value;
|
|
472
472
|
encodingWidth;
|
|
473
473
|
constructor(e, t) {
|
|
@@ -476,10 +476,10 @@ var E = class e {
|
|
|
476
476
|
this.encodingWidth = t?.encodingWidth;
|
|
477
477
|
}
|
|
478
478
|
_encodeTo(e, t) {
|
|
479
|
-
|
|
479
|
+
T(e, 0, this.value, this.encodingWidth);
|
|
480
480
|
}
|
|
481
481
|
_toCDN(e, t) {
|
|
482
|
-
let n =
|
|
482
|
+
let n = b(e, this.encodingWidth, () => y(this.value)), r = this.value;
|
|
483
483
|
switch (e?.intFormat) {
|
|
484
484
|
case "hex": return `0x${r.toString(16)}${n}`;
|
|
485
485
|
case "octal": return `0o${r.toString(8)}${n}`;
|
|
@@ -491,7 +491,7 @@ var E = class e {
|
|
|
491
491
|
let t = e?.integerAs ?? "auto";
|
|
492
492
|
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
493
493
|
}
|
|
494
|
-
},
|
|
494
|
+
}, k = class extends D {
|
|
495
495
|
argument;
|
|
496
496
|
encodingWidth;
|
|
497
497
|
constructor(e, t) {
|
|
@@ -505,10 +505,10 @@ var E = class e {
|
|
|
505
505
|
return -1n - this.argument;
|
|
506
506
|
}
|
|
507
507
|
_encodeTo(e, t) {
|
|
508
|
-
|
|
508
|
+
T(e, 1, this.argument, this.encodingWidth);
|
|
509
509
|
}
|
|
510
510
|
_toCDN(e, t) {
|
|
511
|
-
let n =
|
|
511
|
+
let n = b(e, this.encodingWidth, () => y(this.argument)), r = this.argument + 1n;
|
|
512
512
|
switch (e?.intFormat) {
|
|
513
513
|
case "hex": return `-0x${r.toString(16)}${n}`;
|
|
514
514
|
case "octal": return `-0o${r.toString(8)}${n}`;
|
|
@@ -520,8 +520,8 @@ var E = class e {
|
|
|
520
520
|
let t = this.value, n = e?.integerAs ?? "auto";
|
|
521
521
|
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
522
522
|
}
|
|
523
|
-
},
|
|
524
|
-
function
|
|
523
|
+
}, Le = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
524
|
+
function Re(e) {
|
|
525
525
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
526
526
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
527
527
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -539,20 +539,20 @@ function ze(e) {
|
|
|
539
539
|
let l = c * 2 ** o;
|
|
540
540
|
return t ? -l : l;
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function ze(e) {
|
|
543
543
|
if (isNaN(e)) return "NaN";
|
|
544
544
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
545
545
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
546
546
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
547
|
-
|
|
548
|
-
let r =
|
|
547
|
+
Le.setFloat64(0, n, !1);
|
|
548
|
+
let r = Le.getUint32(0, !1), i = Le.getUint32(4, !1), a = r >>> 20 & 2047, o = r & 1048575, s = i, c = (o.toString(16).padStart(5, "0") + s.toString(16).padStart(8, "0")).replace(/0+$/, ""), l = c === "" ? "" : `.${c}`, u, d;
|
|
549
549
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
550
550
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
551
551
|
return t ? `-${p}` : p;
|
|
552
552
|
}
|
|
553
553
|
//#endregion
|
|
554
554
|
//#region src/ast/CborFloat.ts
|
|
555
|
-
var
|
|
555
|
+
var A = class extends D {
|
|
556
556
|
value;
|
|
557
557
|
precision;
|
|
558
558
|
ednSource;
|
|
@@ -560,7 +560,7 @@ var k = class extends E {
|
|
|
560
560
|
super(), this.value = e, this.precision = t?.precision;
|
|
561
561
|
}
|
|
562
562
|
_encodeTo(e, t) {
|
|
563
|
-
let n = this.precision ??
|
|
563
|
+
let n = this.precision ?? E(this.value);
|
|
564
564
|
n === "half" ? (e.writeByte(249), e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), e.writeFloat32(this.value)) : (e.writeByte(251), e.writeFloat64(this.value));
|
|
565
565
|
}
|
|
566
566
|
_toCDN(e, t) {
|
|
@@ -569,18 +569,18 @@ var k = class extends E {
|
|
|
569
569
|
if (n === "never") return this.ednSource.replace(/_[0-3i]$/, "");
|
|
570
570
|
if (n === "always") {
|
|
571
571
|
if (/_[0-3i]$/.test(this.ednSource)) return this.ednSource;
|
|
572
|
-
let e = this.precision ??
|
|
572
|
+
let e = this.precision ?? E(this.value), t = e === "half" ? "_1" : e === "single" ? "_2" : "_3";
|
|
573
573
|
return this.ednSource + t;
|
|
574
574
|
}
|
|
575
575
|
return this.ednSource;
|
|
576
576
|
}
|
|
577
|
-
let r =
|
|
578
|
-
return (e?.floatFormat === "hex" ?
|
|
577
|
+
let r = E(this.value);
|
|
578
|
+
return (e?.floatFormat === "hex" ? ze(this.value) : Te(this.value)) + Ee(this.value, this.precision, r, n);
|
|
579
579
|
}
|
|
580
580
|
_toJS(e) {
|
|
581
581
|
return this.value;
|
|
582
582
|
}
|
|
583
|
-
},
|
|
583
|
+
}, j = class extends D {
|
|
584
584
|
tag;
|
|
585
585
|
content;
|
|
586
586
|
encodingWidth;
|
|
@@ -589,16 +589,16 @@ var k = class extends E {
|
|
|
589
589
|
this.content = t, this.encodingWidth = n?.encodingWidth;
|
|
590
590
|
}
|
|
591
591
|
_encodeTo(e, t) {
|
|
592
|
-
|
|
592
|
+
T(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
593
593
|
}
|
|
594
594
|
_toCDN(e, t) {
|
|
595
|
-
let n =
|
|
595
|
+
let n = b(e, this.encodingWidth, () => y(this.tag));
|
|
596
596
|
return `${this.tag}${n}(${this.content._toCDN(e, t)})`;
|
|
597
597
|
}
|
|
598
598
|
_toHexDump(e, t) {
|
|
599
599
|
let n = [{
|
|
600
600
|
depth: e,
|
|
601
|
-
hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(
|
|
601
|
+
hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(Ne(6, this.tag, this.encodingWidth)),
|
|
602
602
|
comment: `Tag ${this.tag}`
|
|
603
603
|
}];
|
|
604
604
|
return n.push(...this.content._toHexDump(e + 1, {
|
|
@@ -610,7 +610,7 @@ var k = class extends E {
|
|
|
610
610
|
let t = this.content._toJS(e);
|
|
611
611
|
return e?.stripTags ? t : u.set(t, this.tag);
|
|
612
612
|
}
|
|
613
|
-
},
|
|
613
|
+
}, M = class extends D {
|
|
614
614
|
indefiniteLength = !1;
|
|
615
615
|
value;
|
|
616
616
|
ednEncoding;
|
|
@@ -620,21 +620,21 @@ var k = class extends E {
|
|
|
620
620
|
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
621
621
|
}
|
|
622
622
|
_encodeTo(e, t) {
|
|
623
|
-
|
|
623
|
+
T(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
|
|
624
624
|
}
|
|
625
625
|
_toCDN(e, t) {
|
|
626
626
|
if (e?.preserveByteString && this.ednSource !== void 0) {
|
|
627
627
|
if (/_[0-3i]$/.test(this.ednSource)) return (e?.encodingIndicators ?? "auto") === "never" ? this.ednSource.replace(/_[0-3i]$/, "") : this.ednSource;
|
|
628
|
-
let t =
|
|
628
|
+
let t = b(e, this.encodingWidth, () => y(BigInt(this.value.length)));
|
|
629
629
|
return this.ednSource + t;
|
|
630
630
|
}
|
|
631
|
-
let n =
|
|
632
|
-
return e?.appStrings === !1 && r !== "hex" && (r = "hex"),
|
|
631
|
+
let n = b(e, this.encodingWidth, () => y(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
|
|
632
|
+
return e?.appStrings === !1 && r !== "hex" && (r = "hex"), _e(this.value, r, e?.sqstr) + n;
|
|
633
633
|
}
|
|
634
634
|
_toJS(e) {
|
|
635
635
|
return this.value;
|
|
636
636
|
}
|
|
637
|
-
},
|
|
637
|
+
}, N = class extends D {
|
|
638
638
|
indefiniteLength = !0;
|
|
639
639
|
chunks;
|
|
640
640
|
constructor(e) {
|
|
@@ -646,6 +646,11 @@ var k = class extends E {
|
|
|
646
646
|
e.writeByte(255);
|
|
647
647
|
}
|
|
648
648
|
_toCDN(e, t) {
|
|
649
|
+
if ((e?.encodingIndicators ?? "auto") === "never") {
|
|
650
|
+
let t = this.chunks.reduce((e, t) => e + t.value.length, 0), n = new Uint8Array(t), r = 0;
|
|
651
|
+
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
652
|
+
return new M(n)._toCDN(e, 0);
|
|
653
|
+
}
|
|
649
654
|
return this.chunks.length === 0 ? "''_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
650
655
|
}
|
|
651
656
|
_toHexDump(e, t) {
|
|
@@ -666,7 +671,7 @@ var k = class extends E {
|
|
|
666
671
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
667
672
|
return n;
|
|
668
673
|
}
|
|
669
|
-
},
|
|
674
|
+
}, P = class extends D {
|
|
670
675
|
indefiniteLength = !0;
|
|
671
676
|
chunks;
|
|
672
677
|
constructor(e) {
|
|
@@ -678,7 +683,7 @@ var k = class extends E {
|
|
|
678
683
|
e.writeByte(255);
|
|
679
684
|
}
|
|
680
685
|
_toCDN(e, t) {
|
|
681
|
-
return this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
686
|
+
return (e?.encodingIndicators ?? "auto") === "never" ? new z(this.chunks.map((e) => e.value).join(""))._toCDN(e, t) : this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
682
687
|
}
|
|
683
688
|
_toHexDump(e, t) {
|
|
684
689
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = [{
|
|
@@ -696,7 +701,7 @@ var k = class extends E {
|
|
|
696
701
|
_toJS(e) {
|
|
697
702
|
return this.chunks.map((e) => e.value).join("");
|
|
698
703
|
}
|
|
699
|
-
},
|
|
704
|
+
}, F = class extends D {
|
|
700
705
|
items;
|
|
701
706
|
indefiniteLength;
|
|
702
707
|
encodingWidth;
|
|
@@ -710,25 +715,25 @@ var k = class extends E {
|
|
|
710
715
|
e.writeByte(255);
|
|
711
716
|
return;
|
|
712
717
|
}
|
|
713
|
-
|
|
718
|
+
T(e, 4, this.items.length, this.encodingWidth);
|
|
714
719
|
for (let n of this.items) n._encode(e, t);
|
|
715
720
|
}
|
|
716
721
|
_toCDN(e, t) {
|
|
717
|
-
let n =
|
|
722
|
+
let n = re(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ae(this) || this.items.some(ie));
|
|
718
723
|
n === null && a && (n = " ");
|
|
719
|
-
let { inlineSep: o, multilineSep: s, trailSep: c } =
|
|
724
|
+
let { inlineSep: o, multilineSep: s, trailSep: c } = le(e, n === null), l = this.indefiniteLength ? "" : b(e, this.encodingWidth, () => y(BigInt(this.items.length))), u = l ? l + " " : "", d = this.indefiniteLength && (e?.encodingIndicators ?? "auto") !== "never";
|
|
720
725
|
if (n === null || this.items.length === 0 && !a) {
|
|
721
726
|
let n = this.items.map((n) => n._toCDN(e, t + 1)).join(o);
|
|
722
|
-
return this.indefiniteLength ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${u}${n}]`;
|
|
727
|
+
return this.indefiniteLength ? d ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${n}]` : `[${u}${n}]`;
|
|
723
728
|
}
|
|
724
|
-
let
|
|
729
|
+
let f = _(n, t + 1), p = _(n, t), m = this.indefiniteLength ? d ? "[_ " : "[" : `[${u}`, h = [];
|
|
725
730
|
for (let n = 0; n < this.items.length; n++) {
|
|
726
731
|
let a = this.items[n];
|
|
727
|
-
r &&
|
|
732
|
+
r && h.push(...oe(a, f, i));
|
|
728
733
|
let o = n < this.items.length - 1 ? s : c;
|
|
729
|
-
|
|
734
|
+
h.push(`${f}${a._toCDN(e, t + 1)}${o}${r ? se(a, i) : ""}`);
|
|
730
735
|
}
|
|
731
|
-
return r &&
|
|
736
|
+
return r && h.push(...ce(this, f, i)), `${m}\n${h.join("\n")}\n${p}]`;
|
|
732
737
|
}
|
|
733
738
|
_toHexDump(e, t) {
|
|
734
739
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
@@ -747,7 +752,7 @@ var k = class extends E {
|
|
|
747
752
|
}
|
|
748
753
|
let i = [{
|
|
749
754
|
depth: e,
|
|
750
|
-
hex: r(
|
|
755
|
+
hex: r(Ne(4, BigInt(this.items.length), this.encodingWidth)),
|
|
751
756
|
comment: `Array of length ${this.items.length}`
|
|
752
757
|
}];
|
|
753
758
|
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
@@ -766,7 +771,7 @@ var k = class extends E {
|
|
|
766
771
|
}
|
|
767
772
|
return r;
|
|
768
773
|
}
|
|
769
|
-
},
|
|
774
|
+
}, I = class extends D {
|
|
770
775
|
entries;
|
|
771
776
|
indefiniteLength;
|
|
772
777
|
encodingWidth;
|
|
@@ -780,29 +785,29 @@ var k = class extends E {
|
|
|
780
785
|
e.writeByte(255);
|
|
781
786
|
return;
|
|
782
787
|
}
|
|
783
|
-
|
|
788
|
+
T(e, 5, this.entries.length, this.encodingWidth);
|
|
784
789
|
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
785
790
|
}
|
|
786
791
|
_toCDN(e, t) {
|
|
787
|
-
let n =
|
|
792
|
+
let n = re(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ae(this) || this.entries.some(([e, t]) => ie(e) || ie(t)));
|
|
788
793
|
n === null && a && (n = " ");
|
|
789
|
-
let { inlineSep: o, multilineSep: s, trailSep: c, colSep: l } =
|
|
794
|
+
let { inlineSep: o, multilineSep: s, trailSep: c, colSep: l } = le(e, n === null), u = this.indefiniteLength ? "" : b(e, this.encodingWidth, () => y(BigInt(this.entries.length))), d = u ? u + " " : "", f = this.indefiniteLength && (e?.encodingIndicators ?? "auto") !== "never", p = this.indefiniteLength ? f ? "{_ " : "{" : `{${d}`;
|
|
790
795
|
if (n === null || this.entries.length === 0 && !a) {
|
|
791
796
|
let n = this.entries.map(([n, r]) => `${n._toCDN(e, t + 1)}${l}${r._toCDN(e, t + 1)}`).join(o);
|
|
792
|
-
return this.indefiniteLength ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${d}${n}}`;
|
|
797
|
+
return this.indefiniteLength ? f ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${n}}` : `{${d}${n}}`;
|
|
793
798
|
}
|
|
794
|
-
let
|
|
799
|
+
let m = _(n, t + 1), h = _(n, t), g = [];
|
|
795
800
|
for (let n = 0; n < this.entries.length; n++) {
|
|
796
801
|
let [a, o] = this.entries[n];
|
|
797
|
-
r &&
|
|
798
|
-
let u = n < this.entries.length - 1 ? s : c, d = r ?
|
|
802
|
+
r && g.push(...oe(a, m, i));
|
|
803
|
+
let u = n < this.entries.length - 1 ? s : c, d = r ? Be([
|
|
799
804
|
...a.comments?.trailing ?? [],
|
|
800
805
|
...o.comments?.leading ?? [],
|
|
801
806
|
...o.comments?.trailing ?? []
|
|
802
807
|
], i) : "";
|
|
803
|
-
|
|
808
|
+
g.push(`${m}${a._toCDN(e, t + 1)}${l}${o._toCDN(e, t + 1)}${u}${d}`);
|
|
804
809
|
}
|
|
805
|
-
return r &&
|
|
810
|
+
return r && g.push(...ce(this, m, i)), `${p}\n${g.join("\n")}\n${h}}`;
|
|
806
811
|
}
|
|
807
812
|
_toHexDump(e, t) {
|
|
808
813
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
@@ -821,7 +826,7 @@ var k = class extends E {
|
|
|
821
826
|
}
|
|
822
827
|
let i = [{
|
|
823
828
|
depth: e,
|
|
824
|
-
hex: r(
|
|
829
|
+
hex: r(Ne(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
825
830
|
comment: `Map of length ${this.entries.length}`
|
|
826
831
|
}];
|
|
827
832
|
for (let [n, r] of this.entries) i.push(...n._toHexDump(e + 1, t)), i.push(...r._toHexDump(e + 1, t));
|
|
@@ -838,13 +843,13 @@ var k = class extends E {
|
|
|
838
843
|
}
|
|
839
844
|
return n;
|
|
840
845
|
};
|
|
841
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
846
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof z) ? (() => {
|
|
842
847
|
let n = e ? {
|
|
843
848
|
...e,
|
|
844
849
|
reviver: void 0
|
|
845
850
|
} : void 0, r = {};
|
|
846
851
|
for (let [e, t] of this.entries) {
|
|
847
|
-
let i = e instanceof
|
|
852
|
+
let i = e instanceof z ? e.value : e.toCDN(), a = t._toJS(n);
|
|
848
853
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
849
854
|
value: a,
|
|
850
855
|
writable: !0,
|
|
@@ -856,10 +861,10 @@ var k = class extends E {
|
|
|
856
861
|
let i = /* @__PURE__ */ new Map();
|
|
857
862
|
for (let e = 0; e < this.entries.length; e++) {
|
|
858
863
|
let [t] = this.entries[e];
|
|
859
|
-
i.set(t instanceof
|
|
864
|
+
i.set(t instanceof z ? t.value : t.toCDN(), e);
|
|
860
865
|
}
|
|
861
866
|
for (let n = 0; n < this.entries.length; n++) {
|
|
862
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
867
|
+
let [a, o] = this.entries[n], s = a instanceof z ? a.value : a.toCDN();
|
|
863
868
|
if (i.get(s) !== n) continue;
|
|
864
869
|
let c = o._toJS(e), l = t.call(r, s, c);
|
|
865
870
|
l === d || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
@@ -873,12 +878,12 @@ var k = class extends E {
|
|
|
873
878
|
})() : n();
|
|
874
879
|
}
|
|
875
880
|
};
|
|
876
|
-
function
|
|
877
|
-
return e.length === 0 ? "" : " " + e.map((e) =>
|
|
881
|
+
function Be(e, t) {
|
|
882
|
+
return e.length === 0 ? "" : " " + e.map((e) => v(e, t).trimEnd()).join(" ");
|
|
878
883
|
}
|
|
879
884
|
//#endregion
|
|
880
885
|
//#region src/ast/CborSimple.ts
|
|
881
|
-
var
|
|
886
|
+
var L = class e extends D {
|
|
882
887
|
value;
|
|
883
888
|
constructor(e) {
|
|
884
889
|
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
@@ -913,33 +918,33 @@ var I = class e extends E {
|
|
|
913
918
|
default: return new f(this.value);
|
|
914
919
|
}
|
|
915
920
|
}
|
|
916
|
-
},
|
|
921
|
+
}, Ve = class extends D {
|
|
917
922
|
items;
|
|
918
923
|
encodingWidth;
|
|
919
924
|
constructor(e, t) {
|
|
920
925
|
super(), this.items = e, this.encodingWidth = t?.encodingWidth;
|
|
921
926
|
}
|
|
922
927
|
_content(e) {
|
|
923
|
-
let t = new
|
|
928
|
+
let t = new Ae();
|
|
924
929
|
for (let n of this.items) n._encode(t, e);
|
|
925
930
|
return t.finish();
|
|
926
931
|
}
|
|
927
932
|
_encodeTo(e, t) {
|
|
928
933
|
let n = this._content(t);
|
|
929
|
-
|
|
934
|
+
T(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
|
|
930
935
|
}
|
|
931
936
|
_toCDN(e, t) {
|
|
932
|
-
let n =
|
|
937
|
+
let n = b(e, this.encodingWidth, () => y(BigInt(this._content(e).length)));
|
|
933
938
|
if (this.items.length === 0) return `<<>>${n}`;
|
|
934
|
-
let r =
|
|
939
|
+
let r = re(e), { inlineSep: i, multilineSep: a, trailSep: o } = le(e, r === null);
|
|
935
940
|
if (r === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(i)}>>${n}`;
|
|
936
|
-
let s =
|
|
941
|
+
let s = _(r, t + 1), c = _(r, t), l = this.items.map((n) => `${s}${n._toCDN(e, t + 1)}`), u = l.length - 1;
|
|
937
942
|
return `<<\n${l.map((e, t) => t < u ? `${e}${a}` : `${e}${o}`).join("\n")}\n${c}>>${n}`;
|
|
938
943
|
}
|
|
939
944
|
_toHexDump(e, t) {
|
|
940
945
|
let n = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "), r = this._content().length, i = [{
|
|
941
946
|
depth: e,
|
|
942
|
-
hex: n(
|
|
947
|
+
hex: n(Ne(2, BigInt(r), this.encodingWidth)),
|
|
943
948
|
comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
|
|
944
949
|
}];
|
|
945
950
|
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
@@ -948,17 +953,17 @@ var I = class e extends E {
|
|
|
948
953
|
_toJS(e) {
|
|
949
954
|
return this._content();
|
|
950
955
|
}
|
|
951
|
-
},
|
|
956
|
+
}, He = 999n, Ue = class extends j {
|
|
952
957
|
constructor(e, t) {
|
|
953
|
-
let n = t.length === 1 && t[0] instanceof
|
|
954
|
-
super(
|
|
958
|
+
let n = t.length === 1 && t[0] instanceof z ? t[0] : new F(t);
|
|
959
|
+
super(He, new F([new z(e), n]));
|
|
955
960
|
}
|
|
956
961
|
_toCDN(e, t) {
|
|
957
962
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
958
963
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
959
|
-
return i instanceof
|
|
964
|
+
return i instanceof z ? `${r}${Ce(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
960
965
|
}
|
|
961
|
-
},
|
|
966
|
+
}, We = class extends D {
|
|
962
967
|
inner;
|
|
963
968
|
ednSource;
|
|
964
969
|
constructor(e, t) {
|
|
@@ -974,33 +979,33 @@ var I = class e extends E {
|
|
|
974
979
|
_toJS(e) {
|
|
975
980
|
return this.inner._toJS(e);
|
|
976
981
|
}
|
|
977
|
-
},
|
|
982
|
+
}, Ge = 888n, R = class extends j {
|
|
978
983
|
constructor(e) {
|
|
979
|
-
e === void 0 ? super(
|
|
984
|
+
e === void 0 ? super(Ge, L.NULL) : super(Ge, new F(e));
|
|
980
985
|
}
|
|
981
986
|
_toCDN(e, t) {
|
|
982
|
-
return this.content instanceof
|
|
987
|
+
return this.content instanceof L ? "..." : this.content instanceof F ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
|
|
983
988
|
}
|
|
984
|
-
},
|
|
985
|
-
function
|
|
989
|
+
}, Ke = 2n, qe = 3n, Je = 18446744073709551615n, Ye = -18446744073709551616n;
|
|
990
|
+
function Xe(e) {
|
|
986
991
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
987
|
-
if (e === 0n) return new Uint8Array();
|
|
992
|
+
if (e === 0n) return /* @__PURE__ */ new Uint8Array();
|
|
988
993
|
let t = e.toString(16);
|
|
989
994
|
t.length % 2 != 0 && (t = "0" + t);
|
|
990
995
|
let n = new Uint8Array(t.length / 2);
|
|
991
996
|
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
992
997
|
return n;
|
|
993
998
|
}
|
|
994
|
-
function
|
|
999
|
+
function Ze(e) {
|
|
995
1000
|
let t = 0n;
|
|
996
1001
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
997
1002
|
return t;
|
|
998
1003
|
}
|
|
999
|
-
var
|
|
1004
|
+
var Qe = class extends j {
|
|
1000
1005
|
bigValue;
|
|
1001
1006
|
constructor(e) {
|
|
1002
|
-
if (e <=
|
|
1003
|
-
super(
|
|
1007
|
+
if (e <= Je) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1008
|
+
super(Ke, new M(Xe(e))), this.bigValue = e;
|
|
1004
1009
|
}
|
|
1005
1010
|
_toCDN(e, t) {
|
|
1006
1011
|
return this.bigValue.toString();
|
|
@@ -1008,11 +1013,11 @@ var $e = class extends A {
|
|
|
1008
1013
|
_toJS(e) {
|
|
1009
1014
|
return this.bigValue;
|
|
1010
1015
|
}
|
|
1011
|
-
},
|
|
1016
|
+
}, $e = class extends j {
|
|
1012
1017
|
bigValue;
|
|
1013
1018
|
constructor(e) {
|
|
1014
|
-
if (e >=
|
|
1015
|
-
super(
|
|
1019
|
+
if (e >= Ye) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1020
|
+
super(qe, new M(Xe(-1n - e))), this.bigValue = e;
|
|
1016
1021
|
}
|
|
1017
1022
|
_toCDN(e, t) {
|
|
1018
1023
|
return this.bigValue.toString();
|
|
@@ -1020,22 +1025,25 @@ var $e = class extends A {
|
|
|
1020
1025
|
_toJS(e) {
|
|
1021
1026
|
return this.bigValue;
|
|
1022
1027
|
}
|
|
1023
|
-
},
|
|
1024
|
-
function
|
|
1025
|
-
let r = new t(e, {
|
|
1026
|
-
|
|
1028
|
+
}, et = new TextEncoder(), tt = new TextDecoder("utf-8", { fatal: !0 }), nt = new TextDecoder("utf-8", { fatal: !1 });
|
|
1029
|
+
function rt(e, n) {
|
|
1030
|
+
let r = new t(e, {
|
|
1031
|
+
offset: n?.offset,
|
|
1032
|
+
skipRS: n?._skipRS
|
|
1033
|
+
}), i = new ht(r, n ?? {}).parse();
|
|
1034
|
+
return n?.preserveComments && ct(i, r.comments, e), i;
|
|
1027
1035
|
}
|
|
1028
|
-
function
|
|
1036
|
+
function it(e) {
|
|
1029
1037
|
let t = e, n;
|
|
1030
1038
|
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1031
1039
|
numStr: t,
|
|
1032
1040
|
rawSuffix: n
|
|
1033
1041
|
};
|
|
1034
1042
|
}
|
|
1035
|
-
function
|
|
1043
|
+
function at(e) {
|
|
1036
1044
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1037
1045
|
}
|
|
1038
|
-
function
|
|
1046
|
+
function ot(e, t) {
|
|
1039
1047
|
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1040
1048
|
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1041
1049
|
if (t) t(n), e = e.slice(0, -2);
|
|
@@ -1059,14 +1067,14 @@ function st(e, t) {
|
|
|
1059
1067
|
};
|
|
1060
1068
|
let n = e, r;
|
|
1061
1069
|
return e.endsWith("_1") ? (r = "half", n = e.slice(0, -2)) : e.endsWith("_2") ? (r = "single", n = e.slice(0, -2)) : e.endsWith("_3") && (r = "double", n = e.slice(0, -2)), /^-?0[xX]/.test(n) ? {
|
|
1062
|
-
value:
|
|
1070
|
+
value: Re(n),
|
|
1063
1071
|
precision: r
|
|
1064
1072
|
} : {
|
|
1065
1073
|
value: parseFloat(n),
|
|
1066
1074
|
precision: r
|
|
1067
1075
|
};
|
|
1068
1076
|
}
|
|
1069
|
-
function
|
|
1077
|
+
function st(e, t) {
|
|
1070
1078
|
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
1071
1079
|
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
1072
1080
|
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
@@ -1103,49 +1111,49 @@ function ct(e, t) {
|
|
|
1103
1111
|
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
1104
1112
|
return l;
|
|
1105
1113
|
}
|
|
1106
|
-
function
|
|
1114
|
+
function ct(e, t, n) {
|
|
1107
1115
|
if (t.length === 0) return;
|
|
1108
|
-
let r =
|
|
1116
|
+
let r = lt(e), i = dt(n);
|
|
1109
1117
|
for (let a of t) {
|
|
1110
1118
|
let t = { ...a }, o = [...r].filter((e) => e.end <= a.start).sort((e, t) => t.end - e.end || t.start - e.start)[0], s = o ? n.slice(o.end, a.start) : "";
|
|
1111
1119
|
if (o && i(o.end) === a.line && !s.includes(":")) {
|
|
1112
|
-
|
|
1120
|
+
ut(o.node, "trailing", t);
|
|
1113
1121
|
continue;
|
|
1114
1122
|
}
|
|
1115
1123
|
let c = [...r].filter((e) => e.start < a.start && a.end < e.end).sort((e, t) => t.start - e.start || e.end - t.end)[0], l = [...r].filter((e) => e.start >= a.end).sort((e, t) => e.start - t.start || t.end - e.end)[0];
|
|
1116
1124
|
if ((!c || l && l.end <= c.end) && l) {
|
|
1117
|
-
|
|
1125
|
+
ut(l.node, "leading", t);
|
|
1118
1126
|
continue;
|
|
1119
1127
|
}
|
|
1120
|
-
|
|
1128
|
+
ut(c?.node ?? e, "dangling", t);
|
|
1121
1129
|
}
|
|
1122
1130
|
}
|
|
1123
|
-
function
|
|
1131
|
+
function lt(e) {
|
|
1124
1132
|
let t = [], n = (e) => {
|
|
1125
1133
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1126
1134
|
node: e,
|
|
1127
1135
|
start: e.start,
|
|
1128
1136
|
end: e.end
|
|
1129
|
-
}), e instanceof
|
|
1137
|
+
}), e instanceof F || e instanceof Ve) {
|
|
1130
1138
|
for (let t of e.items) n(t);
|
|
1131
1139
|
return;
|
|
1132
1140
|
}
|
|
1133
|
-
if (e instanceof
|
|
1141
|
+
if (e instanceof I) {
|
|
1134
1142
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1135
1143
|
return;
|
|
1136
1144
|
}
|
|
1137
|
-
if (e instanceof
|
|
1145
|
+
if (e instanceof N || e instanceof P) {
|
|
1138
1146
|
for (let t of e.chunks) n(t);
|
|
1139
1147
|
return;
|
|
1140
1148
|
}
|
|
1141
|
-
e instanceof
|
|
1149
|
+
e instanceof j && n(e.content);
|
|
1142
1150
|
};
|
|
1143
1151
|
return n(e), t;
|
|
1144
1152
|
}
|
|
1145
|
-
function
|
|
1153
|
+
function ut(e, t, n) {
|
|
1146
1154
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1147
1155
|
}
|
|
1148
|
-
function
|
|
1156
|
+
function dt(e) {
|
|
1149
1157
|
let t = [0];
|
|
1150
1158
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1151
1159
|
return (n) => {
|
|
@@ -1159,15 +1167,15 @@ function ft(e) {
|
|
|
1159
1167
|
return a + 1;
|
|
1160
1168
|
};
|
|
1161
1169
|
}
|
|
1162
|
-
var
|
|
1163
|
-
["b32",
|
|
1164
|
-
["h32",
|
|
1165
|
-
["float",
|
|
1166
|
-
["same",
|
|
1167
|
-
["hash",
|
|
1168
|
-
["uuid",
|
|
1169
|
-
["UUID",
|
|
1170
|
-
]),
|
|
1170
|
+
var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, pt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, mt = /* @__PURE__ */ new Map([
|
|
1171
|
+
["b32", ft("b32")],
|
|
1172
|
+
["h32", ft("h32")],
|
|
1173
|
+
["float", ft("float")],
|
|
1174
|
+
["same", ft("same")],
|
|
1175
|
+
["hash", pt("hash", "@cbortech/hash-extension")],
|
|
1176
|
+
["uuid", pt("uuid", "@cbortech/uuid-extension")],
|
|
1177
|
+
["UUID", pt("uuid", "@cbortech/uuid-extension")]
|
|
1178
|
+
]), ht = class {
|
|
1171
1179
|
t;
|
|
1172
1180
|
_options;
|
|
1173
1181
|
extByPrefix;
|
|
@@ -1177,7 +1185,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1177
1185
|
_hintedPrefixes = /* @__PURE__ */ new Set();
|
|
1178
1186
|
constructor(t, n) {
|
|
1179
1187
|
this.t = t, this._options = n, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = n.unresolvedExtension ?? "cpa999";
|
|
1180
|
-
for (let e of [...
|
|
1188
|
+
for (let e of [...qn, ...n.extensions ?? []]) {
|
|
1181
1189
|
for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
|
|
1182
1190
|
for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
|
|
1183
1191
|
}
|
|
@@ -1199,10 +1207,15 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1199
1207
|
let e = this.parseValue();
|
|
1200
1208
|
if (this._options.allowTrailing) return e;
|
|
1201
1209
|
let t = this.t.peek();
|
|
1202
|
-
|
|
1210
|
+
if (t.type !== "EOF") for (this._warnOrFail(`unexpected token after value: ${JSON.stringify(t.value)}`, t), this._pendingWarnings.length > 0 && (e.warnings ??= [], e.warnings.push(...this._pendingWarnings), this._pendingWarnings = []); this.t.peek().type !== "EOF";) this.t.consume();
|
|
1211
|
+
return e;
|
|
1203
1212
|
}
|
|
1204
1213
|
parseValue() {
|
|
1205
1214
|
let e = this.t.peek().offset, t = this._parseValueNode();
|
|
1215
|
+
if (this.t.peek().type === "UNDERSCORE") {
|
|
1216
|
+
let e = this.t.consume();
|
|
1217
|
+
this._warnOrFail("bare _ is not a valid encoding indicator; use _0, _1, _2, _3, or _i", e);
|
|
1218
|
+
}
|
|
1206
1219
|
if (this._pendingWarnings.length > 0) {
|
|
1207
1220
|
t.warnings ??= [];
|
|
1208
1221
|
for (let e of this._pendingWarnings) t.warnings.push(e);
|
|
@@ -1220,12 +1233,12 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1220
1233
|
case "BYTES_HEX":
|
|
1221
1234
|
case "SQSTR":
|
|
1222
1235
|
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
|
|
1223
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new
|
|
1224
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new
|
|
1225
|
-
case "TRUE": return this.t.consume(), new
|
|
1226
|
-
case "FALSE": return this.t.consume(), new
|
|
1227
|
-
case "NULL": return this.t.consume(), new
|
|
1228
|
-
case "UNDEFINED": return this.t.consume(), new
|
|
1236
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new N([]);
|
|
1237
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new P([]);
|
|
1238
|
+
case "TRUE": return this.t.consume(), new L(21);
|
|
1239
|
+
case "FALSE": return this.t.consume(), new L(20);
|
|
1240
|
+
case "NULL": return this.t.consume(), new L(22);
|
|
1241
|
+
case "UNDEFINED": return this.t.consume(), new L(23);
|
|
1229
1242
|
case "SIMPLE": return this.parseSimple();
|
|
1230
1243
|
case "LBRACKET": return this.parseArray();
|
|
1231
1244
|
case "LBRACE": return this.parseMap();
|
|
@@ -1240,34 +1253,39 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1240
1253
|
}
|
|
1241
1254
|
let r = this.extByPrefix.get(e.appPrefix);
|
|
1242
1255
|
if (!r?.parseAppString) {
|
|
1243
|
-
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1256
|
+
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ue(e.appPrefix, [new z(e.value)]);
|
|
1244
1257
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1245
1258
|
}
|
|
1246
1259
|
{
|
|
1247
1260
|
let i = this._pendingWarnings.length;
|
|
1248
1261
|
try {
|
|
1249
1262
|
let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
|
|
1250
|
-
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof
|
|
1263
|
+
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof M && Object.getPrototypeOf(i) === M.prototype && i.ednSource === void 0 ? new M(i.value, {
|
|
1251
1264
|
ednEncoding: i.ednEncoding,
|
|
1252
1265
|
encodingWidth: i.encodingWidth,
|
|
1253
1266
|
ednSource: e.raw + n
|
|
1254
|
-
}) : (i instanceof
|
|
1267
|
+
}) : (i instanceof A && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1255
1268
|
} catch (t) {
|
|
1256
1269
|
if (this._options.strict !== !1) throw t;
|
|
1257
|
-
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new
|
|
1270
|
+
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Ue(e.appPrefix, [new z(e.value)]);
|
|
1258
1271
|
}
|
|
1259
1272
|
}
|
|
1260
1273
|
}
|
|
1261
1274
|
case "APP_SEQUENCE": {
|
|
1262
1275
|
this.t.consume();
|
|
1263
1276
|
let t = [];
|
|
1264
|
-
for (; this.t.peek().type !== "GT_GT"
|
|
1277
|
+
for (; this.t.peek().type !== "GT_GT";) {
|
|
1278
|
+
if (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), t.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1279
|
+
if (this.t.consume(), this.t.peek().type === "GT_GT") break;
|
|
1280
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
|
|
1281
|
+
t.push(this.parseValue());
|
|
1282
|
+
}
|
|
1265
1283
|
this.expect("GT_GT");
|
|
1266
1284
|
let n, r;
|
|
1267
1285
|
this.t.peek().type === "ENCODING_INDICATOR" && (r = this.t.consume(), n = this._resolveEncodingWidth(r.value, r));
|
|
1268
1286
|
let i = this.extByPrefix.get(e.appPrefix);
|
|
1269
1287
|
if (!i) {
|
|
1270
|
-
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1288
|
+
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ue(e.appPrefix, t);
|
|
1271
1289
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1272
1290
|
}
|
|
1273
1291
|
i.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
@@ -1277,61 +1295,61 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1277
1295
|
let a = i.parseAppSequence(e.appPrefix, t, this._extOnError(e));
|
|
1278
1296
|
n !== void 0 && this._applyEiToResult(a, n, r ?? e);
|
|
1279
1297
|
let o = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1280
|
-
if (a instanceof
|
|
1281
|
-
else if (i.preserveAppSeqSource) return new
|
|
1298
|
+
if (a instanceof A) a.ednSource === void 0 && (a.ednSource = o);
|
|
1299
|
+
else if (i.preserveAppSeqSource) return new We(a, o);
|
|
1282
1300
|
return a;
|
|
1283
1301
|
} catch (n) {
|
|
1284
1302
|
if (this._options.strict !== !1) throw n;
|
|
1285
|
-
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new
|
|
1303
|
+
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new Ue(e.appPrefix, t);
|
|
1286
1304
|
}
|
|
1287
1305
|
}
|
|
1288
1306
|
}
|
|
1289
1307
|
case "ELLIPSIS": {
|
|
1290
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
1291
|
-
let e = [new
|
|
1308
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new R();
|
|
1309
|
+
let e = [new R()];
|
|
1292
1310
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1293
|
-
return new
|
|
1311
|
+
return new R(e);
|
|
1294
1312
|
}
|
|
1295
1313
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1296
1314
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1297
1315
|
}
|
|
1298
1316
|
}
|
|
1299
1317
|
parseIntegerOrTag() {
|
|
1300
|
-
let e = this.t.consume(), { numStr: t, rawSuffix: n } =
|
|
1301
|
-
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new
|
|
1302
|
-
if (i < -18446744073709551616n) return new
|
|
1318
|
+
let e = this.t.consume(), { numStr: t, rawSuffix: n } = it(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = at(t);
|
|
1319
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new Qe(i);
|
|
1320
|
+
if (i < -18446744073709551616n) return new $e(i);
|
|
1303
1321
|
if (r !== void 0) {
|
|
1304
1322
|
let t = i >= 0n ? i : -(i + 1n);
|
|
1305
1323
|
r = this._validateEncodingFit(t, r, e);
|
|
1306
1324
|
}
|
|
1307
|
-
let a = i >= 0n ? new
|
|
1325
|
+
let a = i >= 0n ? new O(i, r === void 0 ? void 0 : { encodingWidth: r }) : new k(i, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1308
1326
|
if (this.t.peek().type === "LPAREN") {
|
|
1309
|
-
a instanceof
|
|
1327
|
+
a instanceof O || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
1310
1328
|
let t = this._pendingWarnings.splice(0), n = this.parseValue();
|
|
1311
1329
|
this.expect("RPAREN");
|
|
1312
1330
|
let i = a.value, o = this.extByTag.get(i);
|
|
1313
1331
|
if (o?.parseTag) {
|
|
1314
1332
|
let e = o.parseTag(i, n);
|
|
1315
|
-
if (e !== void 0) return e instanceof
|
|
1333
|
+
if (e !== void 0) return e instanceof j && r !== void 0 && e.encodingWidth === void 0 && (e.encodingWidth = r), t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
|
|
1316
1334
|
}
|
|
1317
|
-
let s = new
|
|
1335
|
+
let s = new j(i, n, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1318
1336
|
return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
|
|
1319
1337
|
}
|
|
1320
1338
|
return a;
|
|
1321
1339
|
}
|
|
1322
1340
|
parseFloat() {
|
|
1323
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } =
|
|
1341
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = ot(e.value, t);
|
|
1324
1342
|
if (r === "half" || r === "single") {
|
|
1325
|
-
let e = r === "half" ? x(
|
|
1343
|
+
let e = r === "half" ? S(x(n)) : Math.fround(n);
|
|
1326
1344
|
Object.is(n, e) || isNaN(n) && isNaN(e) || t(`${n} cannot be exactly represented as ${r === "half" ? "f16 (_1)" : "f32 (_2)"}; use _3 or remove the indicator`);
|
|
1327
1345
|
}
|
|
1328
|
-
return new
|
|
1346
|
+
return new A(n, r === void 0 ? void 0 : { precision: r });
|
|
1329
1347
|
}
|
|
1330
1348
|
parseString() {
|
|
1331
1349
|
let e = this.t.consume();
|
|
1332
1350
|
if (this.t.peek().type !== "PLUS") {
|
|
1333
|
-
let t = this.consumeEncodingIndicator(() => BigInt(
|
|
1334
|
-
return new
|
|
1351
|
+
let t = this.consumeEncodingIndicator(() => BigInt(et.encode(e.value).length));
|
|
1352
|
+
return new z(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1335
1353
|
}
|
|
1336
1354
|
let t = !1, n = [{ text: e.value }];
|
|
1337
1355
|
for (; this.t.peek().type === "PLUS";) {
|
|
@@ -1340,12 +1358,12 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1340
1358
|
e.type === "ELLIPSIS" ? (this.t.consume(), n.push({ ellipsis: !0 }), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push({ text: e.value })) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({ text: this._decodeUtf8(this._decodeBytesToken(e), e) })) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1341
1359
|
}
|
|
1342
1360
|
if (!t) {
|
|
1343
|
-
let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(
|
|
1344
|
-
return new
|
|
1361
|
+
let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(et.encode(e).length));
|
|
1362
|
+
return new z(e, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1345
1363
|
}
|
|
1346
1364
|
let r = [], i = "";
|
|
1347
|
-
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new
|
|
1348
|
-
return i !== "" && r.push(new
|
|
1365
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new z(i)), i = ""), r.push(new R())) : i += e.text;
|
|
1366
|
+
return i !== "" && r.push(new z(i)), new R(r);
|
|
1349
1367
|
}
|
|
1350
1368
|
_isBytesToken(e) {
|
|
1351
1369
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
@@ -1354,9 +1372,9 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1354
1372
|
let n = (e) => this._warnOrFail(e, t);
|
|
1355
1373
|
switch (t.type) {
|
|
1356
1374
|
case "BYTES_HEX":
|
|
1357
|
-
case "SQSTR": return
|
|
1375
|
+
case "SQSTR": return ne(t.value);
|
|
1358
1376
|
case "BYTES_B64": try {
|
|
1359
|
-
return
|
|
1377
|
+
return st(t.value, n);
|
|
1360
1378
|
} catch (n) {
|
|
1361
1379
|
if (n instanceof e || !(n instanceof SyntaxError)) throw n;
|
|
1362
1380
|
this._fail(n.message, t);
|
|
@@ -1365,11 +1383,11 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1365
1383
|
}
|
|
1366
1384
|
}
|
|
1367
1385
|
_decodeUtf8(e, t) {
|
|
1368
|
-
if (this._options.allowInvalidUtf8) return
|
|
1386
|
+
if (this._options.allowInvalidUtf8) return nt.decode(e);
|
|
1369
1387
|
try {
|
|
1370
|
-
return
|
|
1388
|
+
return tt.decode(e);
|
|
1371
1389
|
} catch {
|
|
1372
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t),
|
|
1390
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), nt.decode(e);
|
|
1373
1391
|
}
|
|
1374
1392
|
}
|
|
1375
1393
|
_tokenTypeToCdnEncoding(e) {
|
|
@@ -1378,7 +1396,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1378
1396
|
_parseBytesConcat(e, t, n) {
|
|
1379
1397
|
if (this.t.peek().type !== "PLUS") {
|
|
1380
1398
|
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1381
|
-
return new
|
|
1399
|
+
return new M(e, {
|
|
1382
1400
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1383
1401
|
ednSource: n,
|
|
1384
1402
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
@@ -1392,25 +1410,25 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1392
1410
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1393
1411
|
this.t.consume();
|
|
1394
1412
|
let t = this._buildBytesElidedItems(e.value);
|
|
1395
|
-
for (let e of t) e instanceof
|
|
1396
|
-
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes:
|
|
1413
|
+
for (let e of t) e instanceof R ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof M && i.push({ bytes: e.value });
|
|
1414
|
+
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes: et.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1397
1415
|
}
|
|
1398
1416
|
if (!r) {
|
|
1399
|
-
let e = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(() => BigInt(t.length));
|
|
1400
|
-
return new
|
|
1417
|
+
let e = i.map((e) => "bytes" in e ? e.bytes : /* @__PURE__ */ new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(() => BigInt(t.length));
|
|
1418
|
+
return new M(t, n === void 0 ? void 0 : { encodingWidth: n });
|
|
1401
1419
|
}
|
|
1402
1420
|
let a = [], o = [], s = () => {
|
|
1403
|
-
o.length > 0 && (a.push(new
|
|
1421
|
+
o.length > 0 && (a.push(new M(this._concatBytes([...o]))), o.length = 0);
|
|
1404
1422
|
};
|
|
1405
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new
|
|
1406
|
-
return s(), new
|
|
1423
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new R())) : o.push(e.bytes);
|
|
1424
|
+
return s(), new R(a);
|
|
1407
1425
|
}
|
|
1408
1426
|
_parseHexElidedConcat(e) {
|
|
1409
1427
|
let t = this._buildBytesElidedItems(e.value);
|
|
1410
1428
|
for (; this.t.peek().type === "PLUS";) {
|
|
1411
1429
|
this.t.consume();
|
|
1412
1430
|
let e = this.t.peek();
|
|
1413
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new
|
|
1431
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new R());
|
|
1414
1432
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1415
1433
|
this.t.consume();
|
|
1416
1434
|
let n = this._buildBytesElidedItems(e.value);
|
|
@@ -1418,20 +1436,20 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1418
1436
|
} else if (this._isBytesToken(e.type)) {
|
|
1419
1437
|
this.t.consume();
|
|
1420
1438
|
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
1421
|
-
r instanceof
|
|
1439
|
+
r instanceof M ? t[t.length - 1] = new M(this._concatBytes([r.value, n])) : t.push(new M(n));
|
|
1422
1440
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1423
1441
|
}
|
|
1424
|
-
return new
|
|
1442
|
+
return new R(t);
|
|
1425
1443
|
}
|
|
1426
1444
|
_buildBytesElidedItems(e) {
|
|
1427
1445
|
let t = e.split("..."), n = [];
|
|
1428
|
-
for (let e = 0; e < t.length; e++) e > 0 && n.push(new
|
|
1446
|
+
for (let e = 0; e < t.length; e++) e > 0 && n.push(new R()), t[e].length > 0 && n.push(new M(ne(t[e])));
|
|
1429
1447
|
return n;
|
|
1430
1448
|
}
|
|
1431
1449
|
_mergeFirstBytesItem(e, t) {
|
|
1432
1450
|
if (t.length === 0) return;
|
|
1433
1451
|
let n = e[e.length - 1], r = t[0];
|
|
1434
|
-
n instanceof
|
|
1452
|
+
n instanceof M && r instanceof M ? (e[e.length - 1] = new M(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
|
|
1435
1453
|
}
|
|
1436
1454
|
_concatBytes(e) {
|
|
1437
1455
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -1442,29 +1460,39 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1442
1460
|
this.t.consume(), this.expect("LPAREN");
|
|
1443
1461
|
let e = this.t.peek();
|
|
1444
1462
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
1445
|
-
let { numStr: t } =
|
|
1446
|
-
return this.expect("RPAREN"), new
|
|
1463
|
+
let { numStr: t } = it(e.value), n = Number(at(t));
|
|
1464
|
+
return this.expect("RPAREN"), new L(n);
|
|
1447
1465
|
}
|
|
1448
1466
|
parseEmbeddedCBOR() {
|
|
1449
1467
|
this.t.consume();
|
|
1450
1468
|
let e = [];
|
|
1451
|
-
for (; this.t.peek().type !== "GT_GT"
|
|
1469
|
+
for (; this.t.peek().type !== "GT_GT";) {
|
|
1470
|
+
if (e.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1471
|
+
if (this.t.consume(), this.t.peek().type === "GT_GT") break;
|
|
1472
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
|
|
1473
|
+
e.push(this.parseValue());
|
|
1474
|
+
}
|
|
1452
1475
|
this.expect("GT_GT");
|
|
1453
1476
|
let t;
|
|
1454
1477
|
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
1455
1478
|
let e = this.t.consume();
|
|
1456
1479
|
t = this._resolveEncodingWidth(e.value, e);
|
|
1457
1480
|
}
|
|
1458
|
-
return new
|
|
1481
|
+
return new Ve(e, { encodingWidth: t });
|
|
1459
1482
|
}
|
|
1460
1483
|
parseArray() {
|
|
1461
1484
|
this.t.consume();
|
|
1462
1485
|
let e = !1, t, n;
|
|
1463
1486
|
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1464
1487
|
let r = this._pendingWarnings.splice(0), i = [];
|
|
1465
|
-
for (; this.t.peek().type !== "RBRACKET"
|
|
1488
|
+
for (; this.t.peek().type !== "RBRACKET";) {
|
|
1489
|
+
if (i.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1490
|
+
if (this.t.consume(), this.t.peek().type === "RBRACKET") break;
|
|
1491
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("array items must be separated by \",\" or whitespace", this.t.peek());
|
|
1492
|
+
i.push(this.parseValue());
|
|
1493
|
+
}
|
|
1466
1494
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1467
|
-
let a = new
|
|
1495
|
+
let a = new F(i, {
|
|
1468
1496
|
indefiniteLength: e,
|
|
1469
1497
|
encodingWidth: t
|
|
1470
1498
|
});
|
|
@@ -1475,14 +1503,17 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1475
1503
|
let e = !1, t, n;
|
|
1476
1504
|
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1477
1505
|
let r = this._pendingWarnings.splice(0), i = [];
|
|
1478
|
-
for (; this.t.peek().type !== "RBRACE"
|
|
1506
|
+
for (; this.t.peek().type !== "RBRACE";) {
|
|
1507
|
+
if (i.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1508
|
+
if (this.t.consume(), this.t.peek().type === "RBRACE") break;
|
|
1509
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("map entries must be separated by \",\" or whitespace", this.t.peek());
|
|
1479
1510
|
let e = this.parseValue();
|
|
1480
1511
|
this.expect("COLON");
|
|
1481
1512
|
let t = this.parseValue();
|
|
1482
1513
|
i.push([e, t]);
|
|
1483
1514
|
}
|
|
1484
1515
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1485
|
-
let a = new
|
|
1516
|
+
let a = new I(i, {
|
|
1486
1517
|
indefiniteLength: e,
|
|
1487
1518
|
encodingWidth: t
|
|
1488
1519
|
});
|
|
@@ -1498,19 +1529,24 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1498
1529
|
this._warnOrFail(t, e);
|
|
1499
1530
|
} else e.type !== "RPAREN" && this._warnOrFail("indefinite string group is missing _ after (; interpreting as (_ ...)", e);
|
|
1500
1531
|
let t = this._pendingWarnings.splice(0), n = [];
|
|
1501
|
-
for (; this.t.peek().type !== "RPAREN"
|
|
1532
|
+
for (; this.t.peek().type !== "RPAREN";) {
|
|
1533
|
+
if (n.length > 0) if (this.t.peek().type === "COMMA") {
|
|
1534
|
+
if (this.t.consume(), this.t.peek().type === "RPAREN") break;
|
|
1535
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("indefinite string chunks must be separated by \",\" or whitespace", this.t.peek());
|
|
1536
|
+
n.push(this.parseValue());
|
|
1537
|
+
}
|
|
1502
1538
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1503
1539
|
let r = n[0];
|
|
1504
|
-
if (r instanceof
|
|
1505
|
-
let e = new
|
|
1506
|
-
if (e instanceof
|
|
1540
|
+
if (r instanceof M) {
|
|
1541
|
+
let e = new N(n.map((e, t) => {
|
|
1542
|
+
if (e instanceof M) return e;
|
|
1507
1543
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
1508
1544
|
}));
|
|
1509
1545
|
return t.length > 0 && (e.warnings = t), e;
|
|
1510
1546
|
}
|
|
1511
|
-
if (r instanceof
|
|
1512
|
-
let e = new
|
|
1513
|
-
if (e instanceof
|
|
1547
|
+
if (r instanceof z) {
|
|
1548
|
+
let e = new P(n.map((e, t) => {
|
|
1549
|
+
if (e instanceof z) return e;
|
|
1514
1550
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
1515
1551
|
}));
|
|
1516
1552
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -1528,47 +1564,47 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1528
1564
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
1529
1565
|
}
|
|
1530
1566
|
_applyEiToResult(e, t, n) {
|
|
1531
|
-
if (e instanceof
|
|
1567
|
+
if (e instanceof A) {
|
|
1532
1568
|
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
1533
1569
|
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
1534
1570
|
else if (e.precision !== r) {
|
|
1535
1571
|
if (r !== "double") {
|
|
1536
|
-
let t = r === "half" ? x(
|
|
1572
|
+
let t = r === "half" ? S(x(e.value)) : Math.fround(e.value);
|
|
1537
1573
|
!Object.is(t, e.value) && !isNaN(e.value) && this._warnOrFail(`${e.value} cannot be exactly represented as ${r === "half" ? "float16 (_1)" : "float32 (_2)"}`, n);
|
|
1538
1574
|
}
|
|
1539
1575
|
e.precision = r;
|
|
1540
1576
|
}
|
|
1541
|
-
} else if (e instanceof
|
|
1577
|
+
} else if (e instanceof O) {
|
|
1542
1578
|
if (e.encodingWidth === void 0) {
|
|
1543
1579
|
let r = this._validateEncodingFit(e.value, t, n);
|
|
1544
1580
|
r !== void 0 && (e.encodingWidth = r);
|
|
1545
1581
|
}
|
|
1546
|
-
} else if (e instanceof
|
|
1582
|
+
} else if (e instanceof k) {
|
|
1547
1583
|
if (e.encodingWidth === void 0) {
|
|
1548
1584
|
let r = this._validateEncodingFit(e.argument, t, n);
|
|
1549
1585
|
r !== void 0 && (e.encodingWidth = r);
|
|
1550
1586
|
}
|
|
1551
|
-
} else if (e instanceof
|
|
1587
|
+
} else if (e instanceof M) {
|
|
1552
1588
|
if (e.encodingWidth === void 0) {
|
|
1553
1589
|
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
1554
1590
|
r !== void 0 && (e.encodingWidth = r);
|
|
1555
1591
|
}
|
|
1556
|
-
} else if (e instanceof
|
|
1592
|
+
} else if (e instanceof z) {
|
|
1557
1593
|
if (e.encodingWidth === void 0) {
|
|
1558
|
-
let r = this._validateEncodingFit(BigInt(
|
|
1594
|
+
let r = this._validateEncodingFit(BigInt(et.encode(e.value).length), t, n);
|
|
1559
1595
|
r !== void 0 && (e.encodingWidth = r);
|
|
1560
1596
|
}
|
|
1561
|
-
} else if (e instanceof
|
|
1597
|
+
} else if (e instanceof F) {
|
|
1562
1598
|
if (e.encodingWidth === void 0) {
|
|
1563
1599
|
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
1564
1600
|
r !== void 0 && (e.encodingWidth = r);
|
|
1565
1601
|
}
|
|
1566
|
-
} else if (e instanceof
|
|
1602
|
+
} else if (e instanceof I) {
|
|
1567
1603
|
if (e.encodingWidth === void 0) {
|
|
1568
1604
|
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
1569
1605
|
r !== void 0 && (e.encodingWidth = r);
|
|
1570
1606
|
}
|
|
1571
|
-
} else if (e instanceof
|
|
1607
|
+
} else if (e instanceof j) {
|
|
1572
1608
|
if (e.encodingWidth === void 0) {
|
|
1573
1609
|
let r = this._validateEncodingFit(e.tag, t, n);
|
|
1574
1610
|
r !== void 0 && (e.encodingWidth = r);
|
|
@@ -1576,7 +1612,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1576
1612
|
} else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
|
|
1577
1613
|
}
|
|
1578
1614
|
_validateEncodingFit(e, t, n) {
|
|
1579
|
-
let r =
|
|
1615
|
+
let r = Me(t);
|
|
1580
1616
|
if (e <= r) return t;
|
|
1581
1617
|
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
1582
1618
|
this._warnOrFail(i, n);
|
|
@@ -1600,7 +1636,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1600
1636
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
1601
1637
|
}
|
|
1602
1638
|
_hintMissingExtension(e, t) {
|
|
1603
|
-
let n =
|
|
1639
|
+
let n = mt.get(e);
|
|
1604
1640
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
1605
1641
|
this._hintedPrefixes.add(e);
|
|
1606
1642
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
@@ -1627,7 +1663,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1627
1663
|
endOffset: n.endOffset
|
|
1628
1664
|
} : void 0);
|
|
1629
1665
|
}
|
|
1630
|
-
},
|
|
1666
|
+
}, gt = new TextEncoder(), _t = !1, z = class extends D {
|
|
1631
1667
|
indefiniteLength = !1;
|
|
1632
1668
|
value;
|
|
1633
1669
|
encodingWidth;
|
|
@@ -1635,42 +1671,42 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1635
1671
|
super(), this.value = e, this.encodingWidth = t?.encodingWidth;
|
|
1636
1672
|
}
|
|
1637
1673
|
_encodeTo(e, t) {
|
|
1638
|
-
let n =
|
|
1639
|
-
|
|
1674
|
+
let n = gt.encode(this.value);
|
|
1675
|
+
T(e, 3, n.length, this.encodingWidth), e.writeBytes(n);
|
|
1640
1676
|
}
|
|
1641
1677
|
_toCDN(e, t) {
|
|
1642
|
-
let n =
|
|
1643
|
-
return
|
|
1678
|
+
let n = b(e, this.encodingWidth, () => y(BigInt(gt.encode(this.value).length)));
|
|
1679
|
+
return vt(this.value, n, e, t);
|
|
1644
1680
|
}
|
|
1645
1681
|
_toJS(e) {
|
|
1646
1682
|
return this.value;
|
|
1647
1683
|
}
|
|
1648
1684
|
};
|
|
1649
|
-
function
|
|
1650
|
-
let i =
|
|
1651
|
-
if (i.length === 0 || a === null) return
|
|
1685
|
+
function vt(e, t, n, r) {
|
|
1686
|
+
let i = yt(n?.textStringFormat ?? []), a = re(n);
|
|
1687
|
+
if (i.length === 0 || a === null) return we(e) + t;
|
|
1652
1688
|
let o = /* @__PURE__ */ new Map(), s = null;
|
|
1653
|
-
if (i.includes("cdn") && (s =
|
|
1689
|
+
if (i.includes("cdn") && (s = xt(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
|
|
1654
1690
|
if (i.includes("newline")) {
|
|
1655
|
-
let t = s === null ?
|
|
1691
|
+
let t = s === null ? bt(e, 0) : St(e);
|
|
1656
1692
|
for (let { point: e, contentDepth: n } of t) o.has(e) || o.set(e, n);
|
|
1657
1693
|
}
|
|
1658
|
-
let c =
|
|
1659
|
-
if (c.length <= 1) return
|
|
1694
|
+
let c = kt(e, o);
|
|
1695
|
+
if (c.length <= 1) return we(e) + t;
|
|
1660
1696
|
let l = c.map(({ text: e }, n) => {
|
|
1661
|
-
let r =
|
|
1697
|
+
let r = we(e);
|
|
1662
1698
|
return n === c.length - 1 ? r + t : r;
|
|
1663
1699
|
}), u = l[0];
|
|
1664
1700
|
for (let e = 1; e < l.length; e++) {
|
|
1665
|
-
let t =
|
|
1701
|
+
let t = _(a, r + 1 + c[e].contentDepth);
|
|
1666
1702
|
u += ` +\n${t}${l[e]}`;
|
|
1667
1703
|
}
|
|
1668
1704
|
return u;
|
|
1669
1705
|
}
|
|
1670
|
-
function
|
|
1671
|
-
return e.map((e) => e === "cboredn" ? (
|
|
1706
|
+
function yt(e) {
|
|
1707
|
+
return e.map((e) => e === "cboredn" ? (_t || (_t = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
1672
1708
|
}
|
|
1673
|
-
function
|
|
1709
|
+
function bt(e, t) {
|
|
1674
1710
|
let n = [];
|
|
1675
1711
|
for (let r = 0; r < e.length; r++) {
|
|
1676
1712
|
let i = e[r];
|
|
@@ -1687,9 +1723,9 @@ function xt(e, t) {
|
|
|
1687
1723
|
}
|
|
1688
1724
|
return n;
|
|
1689
1725
|
}
|
|
1690
|
-
function
|
|
1726
|
+
function xt(e) {
|
|
1691
1727
|
try {
|
|
1692
|
-
|
|
1728
|
+
rt(e);
|
|
1693
1729
|
} catch {
|
|
1694
1730
|
return null;
|
|
1695
1731
|
}
|
|
@@ -1698,24 +1734,24 @@ function St(e) {
|
|
|
1698
1734
|
let t = r.consume();
|
|
1699
1735
|
if (t.type === "EOF") break;
|
|
1700
1736
|
let c = !1;
|
|
1701
|
-
if (o || (o = !0, t.offset > 0 &&
|
|
1737
|
+
if (o || (o = !0, t.offset > 0 && Dt(r.comments, 0, t.offset) && n.push({
|
|
1702
1738
|
point: t.offset,
|
|
1703
1739
|
contentDepth: i
|
|
1704
1740
|
})), a !== null) {
|
|
1705
|
-
if (a.kind === "opener" &&
|
|
1741
|
+
if (a.kind === "opener" && wt.has(t.type)) {
|
|
1706
1742
|
a.point = t.endOffset, s = t.endOffset;
|
|
1707
1743
|
continue;
|
|
1708
|
-
} else a.kind === "opener" &&
|
|
1744
|
+
} else a.kind === "opener" && Et.has(t.type) && Ot(e, a.point, t.offset) ? c = !0 : n.push({
|
|
1709
1745
|
point: t.offset,
|
|
1710
1746
|
contentDepth: a.contentDepth
|
|
1711
1747
|
});
|
|
1712
1748
|
a = null;
|
|
1713
1749
|
}
|
|
1714
|
-
|
|
1750
|
+
Tt.has(t.type) ? (i++, a = {
|
|
1715
1751
|
point: t.endOffset,
|
|
1716
1752
|
contentDepth: i,
|
|
1717
1753
|
kind: "opener"
|
|
1718
|
-
}) :
|
|
1754
|
+
}) : Et.has(t.type) ? (i = Math.max(0, i - 1), c || n.push({
|
|
1719
1755
|
point: t.offset,
|
|
1720
1756
|
contentDepth: i
|
|
1721
1757
|
})) : t.type === "COMMA" && (a = {
|
|
@@ -1730,23 +1766,23 @@ function St(e) {
|
|
|
1730
1766
|
contentDepth: i
|
|
1731
1767
|
}), n;
|
|
1732
1768
|
}
|
|
1733
|
-
function
|
|
1769
|
+
function St(e) {
|
|
1734
1770
|
let n = [], r = new t(e), i = 0;
|
|
1735
1771
|
for (;;) {
|
|
1736
1772
|
let t = r.consume();
|
|
1737
1773
|
if (t.type === "EOF") break;
|
|
1738
|
-
if (
|
|
1739
|
-
else if (
|
|
1774
|
+
if (Tt.has(t.type)) i++;
|
|
1775
|
+
else if (Et.has(t.type)) i = Math.max(0, i - 1);
|
|
1740
1776
|
else if (t.type !== "COMMA") {
|
|
1741
1777
|
if (t.type === "TSTR") {
|
|
1742
1778
|
let r = e.slice(t.offset, t.endOffset);
|
|
1743
|
-
for (let e of
|
|
1779
|
+
for (let e of Ct(r)) n.push({
|
|
1744
1780
|
point: t.offset + e,
|
|
1745
1781
|
contentDepth: i + 1
|
|
1746
1782
|
});
|
|
1747
1783
|
} else if (t.type === "RAWSTRING") {
|
|
1748
1784
|
let r = e.slice(t.offset, t.endOffset);
|
|
1749
|
-
for (let { point: e } of
|
|
1785
|
+
for (let { point: e } of bt(r, 0)) n.push({
|
|
1750
1786
|
point: t.offset + e,
|
|
1751
1787
|
contentDepth: i + 1
|
|
1752
1788
|
});
|
|
@@ -1755,7 +1791,7 @@ function Ct(e) {
|
|
|
1755
1791
|
}
|
|
1756
1792
|
return n;
|
|
1757
1793
|
}
|
|
1758
|
-
function
|
|
1794
|
+
function Ct(e) {
|
|
1759
1795
|
let t = [], n = 1, r = e.length - 1;
|
|
1760
1796
|
for (; n < r;) {
|
|
1761
1797
|
let r = e[n];
|
|
@@ -1771,24 +1807,24 @@ function wt(e) {
|
|
|
1771
1807
|
}
|
|
1772
1808
|
return t;
|
|
1773
1809
|
}
|
|
1774
|
-
var
|
|
1810
|
+
var wt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Tt = /* @__PURE__ */ new Set([
|
|
1775
1811
|
"LBRACKET",
|
|
1776
1812
|
"LBRACE",
|
|
1777
1813
|
"LPAREN",
|
|
1778
1814
|
"LT_LT"
|
|
1779
|
-
]),
|
|
1815
|
+
]), Et = /* @__PURE__ */ new Set([
|
|
1780
1816
|
"RBRACKET",
|
|
1781
1817
|
"RBRACE",
|
|
1782
1818
|
"RPAREN",
|
|
1783
1819
|
"GT_GT"
|
|
1784
1820
|
]);
|
|
1785
|
-
function
|
|
1821
|
+
function Dt(e, t, n) {
|
|
1786
1822
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
1787
1823
|
}
|
|
1788
|
-
function
|
|
1824
|
+
function Ot(e, t, n) {
|
|
1789
1825
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
1790
1826
|
}
|
|
1791
|
-
function
|
|
1827
|
+
function kt(e, t) {
|
|
1792
1828
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
1793
1829
|
if (n.length === 0) return [{
|
|
1794
1830
|
text: e,
|
|
@@ -1806,7 +1842,7 @@ function At(e, t) {
|
|
|
1806
1842
|
}
|
|
1807
1843
|
//#endregion
|
|
1808
1844
|
//#region src/extensions/dt.ts
|
|
1809
|
-
function
|
|
1845
|
+
function B(e) {
|
|
1810
1846
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
1811
1847
|
let t = Math.round(e * 1e3);
|
|
1812
1848
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -1814,17 +1850,17 @@ function z(e) {
|
|
|
1814
1850
|
for (; s.length < 3;) s += "0";
|
|
1815
1851
|
return `${i}.${s}Z`;
|
|
1816
1852
|
}
|
|
1817
|
-
var
|
|
1818
|
-
function
|
|
1853
|
+
var At = new TextDecoder("utf-8", { fatal: !0 });
|
|
1854
|
+
function jt(e) {
|
|
1819
1855
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
1820
1856
|
let t = e[0];
|
|
1821
|
-
if (t instanceof
|
|
1822
|
-
if (t instanceof
|
|
1857
|
+
if (t instanceof z) return t.value;
|
|
1858
|
+
if (t instanceof M) return At.decode(t.value);
|
|
1823
1859
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
1824
1860
|
}
|
|
1825
|
-
var
|
|
1826
|
-
function
|
|
1827
|
-
if (!
|
|
1861
|
+
var Mt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
1862
|
+
function Nt(e, t) {
|
|
1863
|
+
if (!Mt.test(e)) {
|
|
1828
1864
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
1829
1865
|
if (t) t(n);
|
|
1830
1866
|
else throw SyntaxError(n);
|
|
@@ -1835,96 +1871,96 @@ function Pt(e, t) {
|
|
|
1835
1871
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
1836
1872
|
if (i === void 0) {
|
|
1837
1873
|
let e = a / 1e3;
|
|
1838
|
-
return e >= 0 ? new
|
|
1874
|
+
return e >= 0 ? new Ft(BigInt(e)) : new It(BigInt(e));
|
|
1839
1875
|
}
|
|
1840
|
-
return new
|
|
1876
|
+
return new Lt(a / 1e3 + i);
|
|
1841
1877
|
}
|
|
1842
|
-
var
|
|
1878
|
+
var Pt = 1n, Ft = class extends O {
|
|
1843
1879
|
constructor(e, t) {
|
|
1844
1880
|
super(e, t);
|
|
1845
1881
|
}
|
|
1846
1882
|
_toCDN(e, t) {
|
|
1847
1883
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1848
|
-
let n =
|
|
1849
|
-
return `dt'${
|
|
1884
|
+
let n = b(e, this.encodingWidth, () => y(this.value));
|
|
1885
|
+
return `dt'${B(Number(this.value))}'${n}`;
|
|
1850
1886
|
}
|
|
1851
|
-
},
|
|
1887
|
+
}, It = class extends k {
|
|
1852
1888
|
constructor(e, t) {
|
|
1853
1889
|
super(e, t);
|
|
1854
1890
|
}
|
|
1855
1891
|
_toCDN(e, t) {
|
|
1856
1892
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1857
|
-
let n =
|
|
1858
|
-
return `dt'${
|
|
1893
|
+
let n = b(e, this.encodingWidth, () => y(this.argument));
|
|
1894
|
+
return `dt'${B(Number(this.value))}'${n}`;
|
|
1859
1895
|
}
|
|
1860
|
-
},
|
|
1896
|
+
}, Lt = class extends A {
|
|
1861
1897
|
constructor(e, t) {
|
|
1862
1898
|
super(e, t);
|
|
1863
1899
|
}
|
|
1864
1900
|
_toCDN(e, t) {
|
|
1865
1901
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1866
|
-
let n =
|
|
1867
|
-
return `dt'${
|
|
1902
|
+
let n = E(this.value), r = Ee(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
1903
|
+
return `dt'${B(this.value)}'${r}`;
|
|
1868
1904
|
}
|
|
1869
|
-
},
|
|
1905
|
+
}, Rt = class extends j {
|
|
1870
1906
|
constructor(e, t) {
|
|
1871
|
-
super(
|
|
1907
|
+
super(Pt, typeof e == "string" ? Nt(e) : e, t);
|
|
1872
1908
|
}
|
|
1873
1909
|
_toCDN(e, t) {
|
|
1874
1910
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1875
1911
|
let n = this.content;
|
|
1876
|
-
if (n instanceof
|
|
1912
|
+
if (n instanceof A ? n.precision !== void 0 && n.precision !== E(n.value) : n.encodingWidth !== void 0) return super._toCDN({
|
|
1877
1913
|
...e,
|
|
1878
1914
|
appStrings: !1
|
|
1879
1915
|
}, t);
|
|
1880
|
-
let r = n instanceof
|
|
1881
|
-
return `DT'${
|
|
1916
|
+
let r = n instanceof A ? n.value : Number(n.value), i = b(e, this.encodingWidth, () => y(Pt));
|
|
1917
|
+
return `DT'${B(r)}'${i}`;
|
|
1882
1918
|
}
|
|
1883
|
-
},
|
|
1919
|
+
}, zt = class extends Rt {
|
|
1884
1920
|
constructor(e, t) {
|
|
1885
1921
|
super(e, t);
|
|
1886
1922
|
}
|
|
1887
1923
|
_toJS(e) {
|
|
1888
|
-
let t = this.content, n = t instanceof
|
|
1924
|
+
let t = this.content, n = t instanceof A ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
1889
1925
|
return new Date(n);
|
|
1890
1926
|
}
|
|
1891
1927
|
};
|
|
1892
|
-
function
|
|
1928
|
+
function Bt(e) {
|
|
1893
1929
|
let t = e?.jsDate ?? !1;
|
|
1894
1930
|
function n(e) {
|
|
1895
|
-
return t ? new
|
|
1931
|
+
return t ? new zt(e) : new Rt(e);
|
|
1896
1932
|
}
|
|
1897
1933
|
let r = {
|
|
1898
1934
|
appStringPrefixes: ["dt", "DT"],
|
|
1899
|
-
tagNumbers: [
|
|
1935
|
+
tagNumbers: [Pt],
|
|
1900
1936
|
parseAppString(e, t, r) {
|
|
1901
|
-
return e === "DT" ? n(t) :
|
|
1937
|
+
return e === "DT" ? n(t) : Nt(t, r);
|
|
1902
1938
|
},
|
|
1903
1939
|
parseAppSequence(e, t, r) {
|
|
1904
|
-
let i =
|
|
1905
|
-
return e === "DT" ? n(i) :
|
|
1940
|
+
let i = jt(t);
|
|
1941
|
+
return e === "DT" ? n(i) : Nt(i, r);
|
|
1906
1942
|
},
|
|
1907
1943
|
parseTag(e, n) {
|
|
1908
1944
|
if (e !== 1n) return;
|
|
1909
1945
|
let r;
|
|
1910
|
-
if (n instanceof
|
|
1911
|
-
else if (n instanceof
|
|
1912
|
-
else if (n instanceof
|
|
1946
|
+
if (n instanceof O) r = new Ft(n.value, { encodingWidth: n.encodingWidth });
|
|
1947
|
+
else if (n instanceof k) r = new It(n.value, { encodingWidth: n.encodingWidth });
|
|
1948
|
+
else if (n instanceof A) r = new Lt(n.value), n.precision !== void 0 && (r.precision = n.precision);
|
|
1913
1949
|
else return;
|
|
1914
|
-
return r.start = n.start, r.end = n.end, t ? new
|
|
1950
|
+
return r.start = n.start, r.end = n.end, t ? new zt(r) : new Rt(r);
|
|
1915
1951
|
}
|
|
1916
1952
|
};
|
|
1917
1953
|
return t && (r.fromJS = (e, t) => {
|
|
1918
|
-
if (e instanceof Date) return new
|
|
1954
|
+
if (e instanceof Date) return new zt(B(e.getTime() / 1e3));
|
|
1919
1955
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
1920
1956
|
}
|
|
1921
|
-
var
|
|
1957
|
+
var Vt = Bt(), Ht = Bt({ jsDate: !0 });
|
|
1922
1958
|
//#endregion
|
|
1923
1959
|
//#region src/utils/ip.ts
|
|
1924
|
-
function
|
|
1960
|
+
function Ut(e) {
|
|
1925
1961
|
let t = e.split(".");
|
|
1926
1962
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
1927
|
-
let n = new Uint8Array(4);
|
|
1963
|
+
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
1928
1964
|
for (let e = 0; e < 4; e++) {
|
|
1929
1965
|
let r = t[e];
|
|
1930
1966
|
if (!/^\d+$/.test(r) || r.length > 1 && r[0] === "0") throw SyntaxError(`ip: invalid IPv4 octet: ${JSON.stringify(r)}`);
|
|
@@ -1934,11 +1970,11 @@ function Wt(e) {
|
|
|
1934
1970
|
}
|
|
1935
1971
|
return n;
|
|
1936
1972
|
}
|
|
1937
|
-
function
|
|
1938
|
-
let t = new Uint8Array(16);
|
|
1973
|
+
function Wt(e) {
|
|
1974
|
+
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
1939
1975
|
if (e === "::") return t;
|
|
1940
1976
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
1941
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
1977
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Ut(i[2]));
|
|
1942
1978
|
let a = n.split("::");
|
|
1943
1979
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
1944
1980
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -1955,11 +1991,11 @@ function Gt(e) {
|
|
|
1955
1991
|
}
|
|
1956
1992
|
return r && t.set(r, 12), t;
|
|
1957
1993
|
}
|
|
1958
|
-
function
|
|
1994
|
+
function Gt(e) {
|
|
1959
1995
|
return Array.from(e).join(".");
|
|
1960
1996
|
}
|
|
1961
|
-
function
|
|
1962
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
1997
|
+
function Kt(e) {
|
|
1998
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Gt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
1963
1999
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
1964
2000
|
let i = -1, a = 0, o = 0;
|
|
1965
2001
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -1973,29 +2009,29 @@ function qt(e) {
|
|
|
1973
2009
|
}
|
|
1974
2010
|
//#endregion
|
|
1975
2011
|
//#region src/extensions/ip.ts
|
|
1976
|
-
var
|
|
1977
|
-
function
|
|
2012
|
+
var qt = "ip", V = "IP", H = 52n, Jt = 54n, Yt = new TextDecoder("utf-8", { fatal: !0 });
|
|
2013
|
+
function Xt(e) {
|
|
1978
2014
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
1979
2015
|
let t = e[0];
|
|
1980
|
-
if (t instanceof
|
|
1981
|
-
if (t instanceof
|
|
2016
|
+
if (t instanceof z) return t.value;
|
|
2017
|
+
if (t instanceof M) return Yt.decode(t.value);
|
|
1982
2018
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
1983
2019
|
}
|
|
1984
|
-
function
|
|
2020
|
+
function Zt(e) {
|
|
1985
2021
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
1986
|
-
bytes:
|
|
2022
|
+
bytes: Ut(e),
|
|
1987
2023
|
isV4: !0
|
|
1988
2024
|
} : {
|
|
1989
|
-
bytes:
|
|
2025
|
+
bytes: Wt(e),
|
|
1990
2026
|
isV4: !1
|
|
1991
2027
|
};
|
|
1992
2028
|
}
|
|
1993
|
-
function
|
|
1994
|
-
if (e.length === 4) return
|
|
1995
|
-
if (e.length === 16) return
|
|
2029
|
+
function Qt(e) {
|
|
2030
|
+
if (e.length === 4) return Gt(e);
|
|
2031
|
+
if (e.length === 16) return Kt(e);
|
|
1996
2032
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
1997
2033
|
}
|
|
1998
|
-
function
|
|
2034
|
+
function $t(e, t) {
|
|
1999
2035
|
let n = new Uint8Array(e.length);
|
|
2000
2036
|
n.set(e);
|
|
2001
2037
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2005,86 +2041,86 @@ function en(e, t) {
|
|
|
2005
2041
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2006
2042
|
return n.slice(0, a);
|
|
2007
2043
|
}
|
|
2008
|
-
function
|
|
2044
|
+
function en(e, t) {
|
|
2009
2045
|
let n = new Uint8Array(t);
|
|
2010
2046
|
return n.set(e), n;
|
|
2011
2047
|
}
|
|
2012
|
-
var
|
|
2048
|
+
var tn = class extends M {
|
|
2013
2049
|
_toCDN(e, t) {
|
|
2014
2050
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2015
|
-
let n =
|
|
2016
|
-
return `${
|
|
2051
|
+
let n = b(e, this.encodingWidth, () => y(BigInt(this.value.length)));
|
|
2052
|
+
return `${qt}'${Qt(this.value)}'${n}`;
|
|
2017
2053
|
}
|
|
2018
|
-
},
|
|
2054
|
+
}, nn = class extends F {
|
|
2019
2055
|
_isV4;
|
|
2020
2056
|
constructor(e, t, n) {
|
|
2021
|
-
super([new
|
|
2057
|
+
super([new O(BigInt(e)), new M(t)]), this._isV4 = n;
|
|
2022
2058
|
}
|
|
2023
2059
|
_toCDN(e, t) {
|
|
2024
2060
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2025
2061
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2026
|
-
return `${
|
|
2062
|
+
return `${qt}'${Qt(en(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2027
2063
|
}
|
|
2028
|
-
},
|
|
2064
|
+
}, rn = class extends j {
|
|
2029
2065
|
constructor(e, t) {
|
|
2030
2066
|
super(e, t);
|
|
2031
2067
|
}
|
|
2032
2068
|
_toCDN(e, t) {
|
|
2033
2069
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2034
|
-
let n = this.tag ===
|
|
2035
|
-
if (r instanceof
|
|
2070
|
+
let n = this.tag === H ? 4 : 16, r = this.content;
|
|
2071
|
+
if (r instanceof M) {
|
|
2036
2072
|
if (r.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2037
|
-
let n =
|
|
2038
|
-
return `${
|
|
2073
|
+
let n = b(e, this.encodingWidth, () => y(this.tag));
|
|
2074
|
+
return `${V}'${Qt(r.value)}'${n}`;
|
|
2039
2075
|
}
|
|
2040
|
-
if (r instanceof
|
|
2076
|
+
if (r instanceof F && r.items.length === 2 && r.items[0] instanceof O && r.items[1] instanceof M) {
|
|
2041
2077
|
if (r.encodingWidth !== void 0 || r.items[0].encodingWidth !== void 0 || r.items[1].encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2042
|
-
let i = Number(r.items[0].value), a =
|
|
2043
|
-
return `${
|
|
2078
|
+
let i = Number(r.items[0].value), a = en(r.items[1].value, n), o = b(e, this.encodingWidth, () => y(this.tag));
|
|
2079
|
+
return `${V}'${Qt(a)}/${i}'${o}`;
|
|
2044
2080
|
}
|
|
2045
2081
|
return super._toCDN(e, t);
|
|
2046
2082
|
}
|
|
2047
2083
|
};
|
|
2048
|
-
function
|
|
2084
|
+
function an(e, t) {
|
|
2049
2085
|
let n = t.indexOf("/");
|
|
2050
2086
|
if (n === -1) {
|
|
2051
|
-
let { bytes: n, isV4: r } =
|
|
2052
|
-
return e ===
|
|
2087
|
+
let { bytes: n, isV4: r } = Zt(t);
|
|
2088
|
+
return e === V ? new rn(r ? H : Jt, new M(n)) : new tn(n);
|
|
2053
2089
|
}
|
|
2054
2090
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2055
2091
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2056
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2092
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = Zt(r), c = s ? 32 : 128;
|
|
2057
2093
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2058
|
-
let l =
|
|
2059
|
-
return e ===
|
|
2094
|
+
let l = $t(o, a);
|
|
2095
|
+
return e === V ? new rn(s ? H : Jt, new F([new O(BigInt(a)), new M(l)])) : new nn(a, l, s);
|
|
2060
2096
|
}
|
|
2061
|
-
var
|
|
2062
|
-
appStringPrefixes: [
|
|
2063
|
-
tagNumbers: [
|
|
2097
|
+
var on = {
|
|
2098
|
+
appStringPrefixes: [qt, V],
|
|
2099
|
+
tagNumbers: [H, Jt],
|
|
2064
2100
|
parseAppString(e, t) {
|
|
2065
|
-
return
|
|
2101
|
+
return an(e, t);
|
|
2066
2102
|
},
|
|
2067
2103
|
parseAppSequence(e, t) {
|
|
2068
|
-
return
|
|
2104
|
+
return an(e, Xt(t));
|
|
2069
2105
|
},
|
|
2070
2106
|
parseTag(e, t) {
|
|
2071
|
-
if (!(e !==
|
|
2107
|
+
if (!(e !== H && e !== Jt) && (t instanceof M || t instanceof F)) return new rn(e, t);
|
|
2072
2108
|
}
|
|
2073
|
-
},
|
|
2074
|
-
tagNumbers: [
|
|
2109
|
+
}, sn = 18446744073709551615n, cn = -18446744073709551616n, ln = {
|
|
2110
|
+
tagNumbers: [Ke, qe],
|
|
2075
2111
|
parseTag(e, t) {
|
|
2076
|
-
if (t instanceof
|
|
2112
|
+
if (t instanceof M) {
|
|
2077
2113
|
if (e === 2n) {
|
|
2078
|
-
let e =
|
|
2079
|
-
return e >
|
|
2114
|
+
let e = Ze(t.value);
|
|
2115
|
+
return e > sn ? new Qe(e) : void 0;
|
|
2080
2116
|
}
|
|
2081
2117
|
if (e === 3n) {
|
|
2082
|
-
let e = -1n -
|
|
2083
|
-
return e <
|
|
2118
|
+
let e = -1n - Ze(t.value);
|
|
2119
|
+
return e < cn ? new $e(e) : void 0;
|
|
2084
2120
|
}
|
|
2085
2121
|
}
|
|
2086
2122
|
}
|
|
2087
|
-
},
|
|
2123
|
+
}, un = "cri", dn = "CRI", fn = 99n, pn = /* @__PURE__ */ new Map([
|
|
2088
2124
|
["coap", -1n],
|
|
2089
2125
|
["coaps", -2n],
|
|
2090
2126
|
["http", -3n],
|
|
@@ -2095,47 +2131,47 @@ var sn = {
|
|
|
2095
2131
|
["coaps+tcp", -8n],
|
|
2096
2132
|
["coap+ws", -25n],
|
|
2097
2133
|
["coaps+ws", -26n]
|
|
2098
|
-
]),
|
|
2099
|
-
function
|
|
2134
|
+
]), mn = new Map([...pn.entries()].map(([e, t]) => [t, e]));
|
|
2135
|
+
function U(e) {
|
|
2100
2136
|
try {
|
|
2101
2137
|
return decodeURIComponent(e);
|
|
2102
2138
|
} catch {
|
|
2103
2139
|
return e;
|
|
2104
2140
|
}
|
|
2105
2141
|
}
|
|
2106
|
-
var
|
|
2107
|
-
function
|
|
2108
|
-
return Array.from(
|
|
2142
|
+
var hn = new TextEncoder(), gn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2143
|
+
function _n(e) {
|
|
2144
|
+
return Array.from(hn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2109
2145
|
}
|
|
2110
|
-
function
|
|
2146
|
+
function W(e, t) {
|
|
2111
2147
|
let n = "";
|
|
2112
|
-
for (let r of e) n += t(r) ? r :
|
|
2148
|
+
for (let r of e) n += t(r) ? r : _n(r);
|
|
2113
2149
|
return n;
|
|
2114
2150
|
}
|
|
2115
|
-
function
|
|
2151
|
+
function vn(e) {
|
|
2116
2152
|
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2117
2153
|
}
|
|
2118
|
-
function
|
|
2154
|
+
function yn(e) {
|
|
2119
2155
|
return /[!$&'()*+,;=]/.test(e);
|
|
2120
2156
|
}
|
|
2157
|
+
function bn(e) {
|
|
2158
|
+
return vn(e) || yn(e) || e === ":" || e === "@";
|
|
2159
|
+
}
|
|
2121
2160
|
function xn(e) {
|
|
2122
|
-
return
|
|
2161
|
+
return (bn(e) || e === "/" || e === "?") && e !== "&";
|
|
2123
2162
|
}
|
|
2124
2163
|
function Sn(e) {
|
|
2125
|
-
return (
|
|
2164
|
+
return bn(e) || e === "/" || e === "?";
|
|
2126
2165
|
}
|
|
2127
2166
|
function Cn(e) {
|
|
2128
|
-
return
|
|
2167
|
+
return vn(e) || yn(e) || e === ":";
|
|
2129
2168
|
}
|
|
2130
2169
|
function wn(e) {
|
|
2131
|
-
return
|
|
2170
|
+
return vn(e) || yn(e);
|
|
2132
2171
|
}
|
|
2133
2172
|
function Tn(e) {
|
|
2134
|
-
return yn(e) || bn(e);
|
|
2135
|
-
}
|
|
2136
|
-
function En(e) {
|
|
2137
2173
|
let t = [], n = e, r = n.indexOf("@");
|
|
2138
|
-
r >= 0 && (t.push(
|
|
2174
|
+
r >= 0 && (t.push(L.FALSE), t.push(new z(U(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2139
2175
|
let i, a = null;
|
|
2140
2176
|
if (n.startsWith("[")) {
|
|
2141
2177
|
let e = n.indexOf("]");
|
|
@@ -2144,190 +2180,190 @@ function En(e) {
|
|
|
2144
2180
|
let r = n.slice(e + 1);
|
|
2145
2181
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2146
2182
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2147
|
-
t.push(new
|
|
2183
|
+
t.push(new M(Wt(i)));
|
|
2148
2184
|
} else {
|
|
2149
2185
|
let e = n.lastIndexOf(":");
|
|
2150
|
-
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new
|
|
2151
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new
|
|
2186
|
+
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new M(Ut(i)));
|
|
2187
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new z(e));
|
|
2152
2188
|
}
|
|
2153
2189
|
if (a !== null && a !== "") {
|
|
2154
2190
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2155
2191
|
let e = parseInt(a, 10);
|
|
2156
2192
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2157
|
-
t.push(new
|
|
2193
|
+
t.push(new O(BigInt(e)));
|
|
2158
2194
|
}
|
|
2159
|
-
return new
|
|
2195
|
+
return new F(t);
|
|
2160
2196
|
}
|
|
2161
|
-
function
|
|
2197
|
+
function En(e) {
|
|
2162
2198
|
let t = e.items, n = 0, r = "";
|
|
2163
|
-
if (n < t.length && t[n] instanceof
|
|
2199
|
+
if (n < t.length && t[n] instanceof L && t[n].value === 20) {
|
|
2164
2200
|
n++;
|
|
2165
2201
|
let e = t[n++];
|
|
2166
|
-
r +=
|
|
2202
|
+
r += W(e.value, Cn) + "@";
|
|
2167
2203
|
}
|
|
2168
2204
|
if (n >= t.length) return r;
|
|
2169
2205
|
let i = t[n];
|
|
2170
|
-
if (i instanceof
|
|
2206
|
+
if (i instanceof M) {
|
|
2171
2207
|
n++;
|
|
2172
2208
|
let { length: e } = i.value;
|
|
2173
|
-
if (e === 4) r +=
|
|
2174
|
-
else if (e === 16) r += "[" +
|
|
2209
|
+
if (e === 4) r += Gt(i.value);
|
|
2210
|
+
else if (e === 16) r += "[" + Kt(i.value) + "]";
|
|
2175
2211
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2176
|
-
n < t.length && t[n] instanceof
|
|
2212
|
+
n < t.length && t[n] instanceof z && (r += `%25${W(t[n++].value, wn)}`);
|
|
2177
2213
|
} else {
|
|
2178
2214
|
let e = [];
|
|
2179
|
-
for (; n < t.length && t[n] instanceof
|
|
2215
|
+
for (; n < t.length && t[n] instanceof z;) e.push(W(t[n++].value, wn));
|
|
2180
2216
|
r += e.join(".");
|
|
2181
2217
|
}
|
|
2182
|
-
return n < t.length && t[n] instanceof
|
|
2218
|
+
return n < t.length && t[n] instanceof O && (r += ":" + t[n].value.toString()), r;
|
|
2183
2219
|
}
|
|
2184
|
-
function
|
|
2220
|
+
function Dn(e) {
|
|
2185
2221
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2186
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
2187
|
-
authority:
|
|
2222
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new z(U(e)))) : (r = t, i = []), {
|
|
2223
|
+
authority: Tn(r),
|
|
2188
2224
|
pathSegments: i
|
|
2189
2225
|
};
|
|
2190
2226
|
}
|
|
2191
|
-
function
|
|
2227
|
+
function On(e) {
|
|
2192
2228
|
let t = e, n = null, r = t.indexOf("#");
|
|
2193
|
-
r >= 0 && (n =
|
|
2229
|
+
r >= 0 && (n = U(t.slice(r + 1)), t = t.slice(0, r));
|
|
2194
2230
|
let i = null, a = t.indexOf("?");
|
|
2195
2231
|
if (a >= 0) {
|
|
2196
2232
|
let e = t.slice(a + 1);
|
|
2197
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2233
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new z(U(e)));
|
|
2198
2234
|
}
|
|
2199
2235
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2200
2236
|
if (s) {
|
|
2201
|
-
let e = s[1].toLowerCase(), t = s[2], n =
|
|
2202
|
-
if (o.push(n === void 0 ? new
|
|
2203
|
-
let { authority: e, pathSegments: n } =
|
|
2204
|
-
o.push(e, new
|
|
2237
|
+
let e = s[1].toLowerCase(), t = s[2], n = pn.get(e);
|
|
2238
|
+
if (o.push(n === void 0 ? new z(e) : new k(n)), t.startsWith("//")) {
|
|
2239
|
+
let { authority: e, pathSegments: n } = Dn(t);
|
|
2240
|
+
o.push(e, new F(n));
|
|
2205
2241
|
} else if (t.startsWith("/")) {
|
|
2206
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2207
|
-
o.push(
|
|
2242
|
+
let e = t.slice(1).split("/").map((e) => new z(U(e)));
|
|
2243
|
+
o.push(L.NULL, new F(e));
|
|
2208
2244
|
} else {
|
|
2209
|
-
let e = t.split("/").map((e) => new
|
|
2210
|
-
o.push(
|
|
2245
|
+
let e = t.split("/").map((e) => new z(U(e)));
|
|
2246
|
+
o.push(L.TRUE, new F(e));
|
|
2211
2247
|
}
|
|
2212
2248
|
} else if (t.startsWith("//")) {
|
|
2213
|
-
let { authority: e, pathSegments: n } =
|
|
2214
|
-
o.push(
|
|
2249
|
+
let { authority: e, pathSegments: n } = Dn(t);
|
|
2250
|
+
o.push(L.FALSE, e, new F(n));
|
|
2215
2251
|
} else if (t.startsWith("/")) {
|
|
2216
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2217
|
-
o.push(
|
|
2218
|
-
} else if (t === "") o.push(new
|
|
2252
|
+
let e = t.slice(1).split("/").map((e) => new z(U(e)));
|
|
2253
|
+
o.push(L.TRUE, new F(e));
|
|
2254
|
+
} else if (t === "") o.push(new O(0n));
|
|
2219
2255
|
else {
|
|
2220
2256
|
let n = 1n, r = t, i = !1;
|
|
2221
2257
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2222
2258
|
if (r === ".." ? (n++, r = "") : r === "." && (r = ""), n === 1n && !i && r !== "" && r.split("/")[0].includes(":")) throw SyntaxError(`cri: invalid relative-path reference — first segment must not contain ':' without a './' prefix (RFC 3986 §3.3): ${JSON.stringify(e)}`);
|
|
2223
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
2224
|
-
o.push(new
|
|
2259
|
+
let a = r === "" ? [] : r.split("/").map((e) => new z(U(e)));
|
|
2260
|
+
o.push(new O(n), new F(a));
|
|
2225
2261
|
}
|
|
2226
|
-
if (i !== null && o.push(new
|
|
2262
|
+
if (i !== null && o.push(new F(i)), n !== null && (i === null && o.push(L.NULL), o.push(new z(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2227
2263
|
let e = o[o.length - 1];
|
|
2228
|
-
e instanceof
|
|
2264
|
+
e instanceof F && e.items.length === 0 && o.pop();
|
|
2229
2265
|
}
|
|
2230
|
-
return o.length === 1 && o[0] instanceof
|
|
2266
|
+
return o.length === 1 && o[0] instanceof O && o[0].value === 0n ? [] : o;
|
|
2231
2267
|
}
|
|
2232
|
-
function
|
|
2268
|
+
function G(e, t) {
|
|
2233
2269
|
let n = t, r = "";
|
|
2234
2270
|
if (n < e.length) {
|
|
2235
2271
|
let t = e[n];
|
|
2236
|
-
if (t instanceof
|
|
2272
|
+
if (t instanceof F) {
|
|
2237
2273
|
if (n++, t.items.length > 0) {
|
|
2238
2274
|
let e = t.items.map((e) => {
|
|
2239
|
-
if (!(e instanceof
|
|
2240
|
-
return
|
|
2275
|
+
if (!(e instanceof z)) throw Error("cri: query item must be a text string");
|
|
2276
|
+
return W(e.value, xn);
|
|
2241
2277
|
});
|
|
2242
2278
|
r += "?" + e.join("&");
|
|
2243
2279
|
}
|
|
2244
|
-
} else t instanceof
|
|
2280
|
+
} else t instanceof L && t.value === 22 && n++;
|
|
2245
2281
|
}
|
|
2246
|
-
return n < e.length && e[n] instanceof
|
|
2282
|
+
return n < e.length && e[n] instanceof z && (r += "#" + W(e[n].value, Sn)), r;
|
|
2247
2283
|
}
|
|
2248
|
-
function
|
|
2284
|
+
function kn(e) {
|
|
2249
2285
|
return e.items.map((e) => {
|
|
2250
|
-
if (!(e instanceof
|
|
2251
|
-
return
|
|
2286
|
+
if (!(e instanceof z)) throw Error("cri: path segment must be a text string");
|
|
2287
|
+
return W(e.value, bn);
|
|
2252
2288
|
});
|
|
2253
2289
|
}
|
|
2254
2290
|
function An(e) {
|
|
2255
2291
|
if (e.length === 0) return "";
|
|
2256
2292
|
let t = 0, n = e[t++];
|
|
2257
|
-
if (n instanceof
|
|
2293
|
+
if (n instanceof k || n instanceof z) {
|
|
2258
2294
|
let r;
|
|
2259
|
-
if (n instanceof
|
|
2260
|
-
let e =
|
|
2295
|
+
if (n instanceof k) {
|
|
2296
|
+
let e = mn.get(n.value);
|
|
2261
2297
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2262
2298
|
r = e + ":";
|
|
2263
2299
|
} else r = n.value + ":";
|
|
2264
2300
|
if (t >= e.length) return r;
|
|
2265
2301
|
let i = e[t++], a = "", o = !1;
|
|
2266
|
-
if (i instanceof
|
|
2267
|
-
else if (i instanceof
|
|
2302
|
+
if (i instanceof F) a = "//" + En(i), o = !0;
|
|
2303
|
+
else if (i instanceof L) if (i.value === 22) o = !0;
|
|
2268
2304
|
else if (i.value === 21) o = !1;
|
|
2269
2305
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2270
2306
|
else throw Error("cri: unexpected type for authority element");
|
|
2271
2307
|
let s = "";
|
|
2272
|
-
if (t < e.length && e[t] instanceof
|
|
2308
|
+
if (t < e.length && e[t] instanceof F) {
|
|
2273
2309
|
let n = e[t++];
|
|
2274
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
2310
|
+
n.items.length > 0 && (s = (o ? "/" : "") + kn(n).join("/"));
|
|
2275
2311
|
}
|
|
2276
|
-
return r + a + s +
|
|
2312
|
+
return r + a + s + G(e, t);
|
|
2277
2313
|
}
|
|
2278
|
-
if (n instanceof
|
|
2279
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2280
|
-
let n =
|
|
2281
|
-
if (t < e.length && e[t] instanceof
|
|
2314
|
+
if (n instanceof L && n.value === 20) {
|
|
2315
|
+
if (t >= e.length || !(e[t] instanceof F)) throw Error("cri: network-path reference requires an authority array");
|
|
2316
|
+
let n = En(e[t++]), r = "";
|
|
2317
|
+
if (t < e.length && e[t] instanceof F) {
|
|
2282
2318
|
let n = e[t++];
|
|
2283
|
-
n.items.length > 0 && (r = "/" +
|
|
2319
|
+
n.items.length > 0 && (r = "/" + kn(n).join("/"));
|
|
2284
2320
|
}
|
|
2285
|
-
return "//" + n + r +
|
|
2321
|
+
return "//" + n + r + G(e, t);
|
|
2286
2322
|
}
|
|
2287
|
-
if (n instanceof
|
|
2323
|
+
if (n instanceof L && n.value === 21) {
|
|
2288
2324
|
let n = "/";
|
|
2289
|
-
if (t < e.length && e[t] instanceof
|
|
2325
|
+
if (t < e.length && e[t] instanceof F) {
|
|
2290
2326
|
let r = e[t++];
|
|
2291
|
-
n = "/" +
|
|
2327
|
+
n = "/" + kn(r).join("/");
|
|
2292
2328
|
}
|
|
2293
|
-
return n +
|
|
2329
|
+
return n + G(e, t);
|
|
2294
2330
|
}
|
|
2295
|
-
if (n instanceof
|
|
2331
|
+
if (n instanceof O) {
|
|
2296
2332
|
let r = n.value;
|
|
2297
|
-
if (r === 0n) return
|
|
2333
|
+
if (r === 0n) return G(e, t);
|
|
2298
2334
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2299
|
-
if (t < e.length && e[t] instanceof
|
|
2335
|
+
if (t < e.length && e[t] instanceof F) {
|
|
2300
2336
|
let n = e[t++];
|
|
2301
2337
|
if (n.items.length > 0) {
|
|
2302
|
-
let e =
|
|
2338
|
+
let e = kn(n);
|
|
2303
2339
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2304
2340
|
} else a = i === "" ? "./" : i;
|
|
2305
2341
|
} else a = i === "" ? "./" : i;
|
|
2306
|
-
return a +
|
|
2342
|
+
return a + G(e, t);
|
|
2307
2343
|
}
|
|
2308
2344
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2309
2345
|
}
|
|
2310
|
-
var jn = class extends
|
|
2346
|
+
var jn = class extends F {
|
|
2311
2347
|
_toCDN(e, t) {
|
|
2312
2348
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2313
2349
|
try {
|
|
2314
|
-
let t =
|
|
2315
|
-
return `${
|
|
2350
|
+
let t = b(e, this.encodingWidth, () => y(BigInt(this.items.length)));
|
|
2351
|
+
return `${un}'${An(this.items)}'${t}`;
|
|
2316
2352
|
} catch {
|
|
2317
2353
|
return super._toCDN(e, t);
|
|
2318
2354
|
}
|
|
2319
2355
|
}
|
|
2320
|
-
}, Mn = class extends
|
|
2356
|
+
}, Mn = class extends j {
|
|
2321
2357
|
constructor(e) {
|
|
2322
|
-
super(
|
|
2358
|
+
super(fn, e);
|
|
2323
2359
|
}
|
|
2324
2360
|
_toCDN(e, t) {
|
|
2325
2361
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2326
2362
|
try {
|
|
2327
2363
|
let n = this.content;
|
|
2328
2364
|
if (n.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2329
|
-
let r =
|
|
2330
|
-
return `${
|
|
2365
|
+
let r = b(e, this.encodingWidth, () => y(fn));
|
|
2366
|
+
return `${dn}'${An(n.items)}'${r}`;
|
|
2331
2367
|
} catch {
|
|
2332
2368
|
return super._toCDN(e, t);
|
|
2333
2369
|
}
|
|
@@ -2336,17 +2372,17 @@ var jn = class extends P {
|
|
|
2336
2372
|
function Nn(e) {
|
|
2337
2373
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2338
2374
|
let t = e[0];
|
|
2339
|
-
if (t instanceof
|
|
2340
|
-
if (t instanceof
|
|
2375
|
+
if (t instanceof z) return t.value;
|
|
2376
|
+
if (t instanceof M) return gn.decode(t.value);
|
|
2341
2377
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2342
2378
|
}
|
|
2343
2379
|
function Pn(e, t) {
|
|
2344
|
-
let n = new jn(
|
|
2345
|
-
return e ===
|
|
2380
|
+
let n = new jn(On(t));
|
|
2381
|
+
return e === dn ? new Mn(n) : n;
|
|
2346
2382
|
}
|
|
2347
2383
|
var Fn = {
|
|
2348
|
-
appStringPrefixes: [
|
|
2349
|
-
tagNumbers: [
|
|
2384
|
+
appStringPrefixes: [un, dn],
|
|
2385
|
+
tagNumbers: [fn],
|
|
2350
2386
|
parseAppString(e, t) {
|
|
2351
2387
|
return Pn(e, t);
|
|
2352
2388
|
},
|
|
@@ -2354,7 +2390,7 @@ var Fn = {
|
|
|
2354
2390
|
return Pn(e, Nn(t));
|
|
2355
2391
|
},
|
|
2356
2392
|
parseTag(e, t) {
|
|
2357
|
-
if (e !== 99n || !(t instanceof
|
|
2393
|
+
if (e !== 99n || !(t instanceof F)) return;
|
|
2358
2394
|
let n = new jn(t.items, {
|
|
2359
2395
|
indefiniteLength: t.indefiniteLength,
|
|
2360
2396
|
encodingWidth: t.encodingWidth
|
|
@@ -2388,61 +2424,61 @@ function Rn(e, t, n) {
|
|
|
2388
2424
|
if (n?.onWarning ? n.onWarning(r) : n?.silent || console.warn(`CBOR strict violation at offset ${t}: ${e}`), n?.strict !== !1) throw Error(`CBOR decode error: ${e}`);
|
|
2389
2425
|
return r;
|
|
2390
2426
|
}
|
|
2391
|
-
function
|
|
2427
|
+
function J(e, t) {
|
|
2392
2428
|
e.warnings ??= [], e.warnings.push(t);
|
|
2393
2429
|
}
|
|
2394
|
-
function
|
|
2430
|
+
function zn(e) {
|
|
2395
2431
|
let t = "";
|
|
2396
2432
|
for (let n of e) t += n.toString(16).padStart(2, "0");
|
|
2397
2433
|
return t;
|
|
2398
2434
|
}
|
|
2399
|
-
function
|
|
2400
|
-
if (e instanceof
|
|
2401
|
-
if (e instanceof
|
|
2402
|
-
if (e instanceof
|
|
2403
|
-
if (e instanceof
|
|
2404
|
-
if (e instanceof
|
|
2405
|
-
if (e instanceof
|
|
2435
|
+
function Y(e) {
|
|
2436
|
+
if (e instanceof O) return ["u", String(e.value)];
|
|
2437
|
+
if (e instanceof k) return ["n", String(e.value)];
|
|
2438
|
+
if (e instanceof z) return ["t", e.value];
|
|
2439
|
+
if (e instanceof P) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2440
|
+
if (e instanceof M) return ["b", zn(e.value)];
|
|
2441
|
+
if (e instanceof N) {
|
|
2406
2442
|
let t = "";
|
|
2407
|
-
for (let n of e.chunks) t +=
|
|
2443
|
+
for (let n of e.chunks) t += zn(n.value);
|
|
2408
2444
|
return ["b", t];
|
|
2409
2445
|
}
|
|
2410
|
-
if (e instanceof
|
|
2411
|
-
if (e instanceof
|
|
2412
|
-
if (e instanceof
|
|
2413
|
-
if (e instanceof
|
|
2414
|
-
let t = e.entries.map(([e, t]) => [
|
|
2446
|
+
if (e instanceof A) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2447
|
+
if (e instanceof L) return ["s", e.value];
|
|
2448
|
+
if (e instanceof F) return ["A", e.items.map(Y)];
|
|
2449
|
+
if (e instanceof I) {
|
|
2450
|
+
let t = e.entries.map(([e, t]) => [Y(e), Y(t)]);
|
|
2415
2451
|
if (t.length <= 1) return ["M", t];
|
|
2416
2452
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2417
2453
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
2418
2454
|
}
|
|
2419
|
-
if (e instanceof
|
|
2455
|
+
if (e instanceof j) return [
|
|
2420
2456
|
"G",
|
|
2421
2457
|
String(e.tag),
|
|
2422
|
-
|
|
2458
|
+
Y(e.content)
|
|
2423
2459
|
];
|
|
2424
2460
|
let t = e.toCBOR(), n = "";
|
|
2425
2461
|
for (let e of t) n += e.toString(16).padStart(2, "0");
|
|
2426
2462
|
return ["c", n];
|
|
2427
2463
|
}
|
|
2428
|
-
function
|
|
2429
|
-
if (e instanceof
|
|
2430
|
-
if (e instanceof
|
|
2431
|
-
if (e instanceof
|
|
2432
|
-
if (e instanceof
|
|
2464
|
+
function Bn(e) {
|
|
2465
|
+
if (e instanceof O) return "u" + e.value;
|
|
2466
|
+
if (e instanceof k) return "n" + e.value;
|
|
2467
|
+
if (e instanceof z) return "t" + e.value;
|
|
2468
|
+
if (e instanceof P) {
|
|
2433
2469
|
let t = "t";
|
|
2434
2470
|
for (let n of e.chunks) t += n.value;
|
|
2435
2471
|
return t;
|
|
2436
2472
|
}
|
|
2437
|
-
if (e instanceof
|
|
2438
|
-
if (e instanceof
|
|
2473
|
+
if (e instanceof M) return "b" + zn(e.value);
|
|
2474
|
+
if (e instanceof N) {
|
|
2439
2475
|
let t = "b";
|
|
2440
|
-
for (let n of e.chunks) t +=
|
|
2476
|
+
for (let n of e.chunks) t += zn(n.value);
|
|
2441
2477
|
return t;
|
|
2442
2478
|
}
|
|
2443
|
-
return e instanceof
|
|
2479
|
+
return e instanceof A ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof L ? "s" + e.value : JSON.stringify(Y(e));
|
|
2444
2480
|
}
|
|
2445
|
-
function
|
|
2481
|
+
function X(e, t, n) {
|
|
2446
2482
|
if (n <= 23) return {
|
|
2447
2483
|
value: BigInt(n),
|
|
2448
2484
|
nextOffset: t
|
|
@@ -2467,14 +2503,14 @@ function Y(e, t, n) {
|
|
|
2467
2503
|
default: q(`reserved additional info value: ${n}`);
|
|
2468
2504
|
}
|
|
2469
2505
|
}
|
|
2470
|
-
function
|
|
2506
|
+
function Vn(e, t, n, r, i, a) {
|
|
2471
2507
|
let o = [], s = t;
|
|
2472
2508
|
for (;;) {
|
|
2473
2509
|
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
2474
2510
|
s++;
|
|
2475
2511
|
break;
|
|
2476
2512
|
}
|
|
2477
|
-
let t =
|
|
2513
|
+
let t = Z(e, s, n, r);
|
|
2478
2514
|
a(t.value) || q(`indefinite-length ${i} chunk must be a definite ${i}`), o.push(t.value), s = t.nextOffset;
|
|
2479
2515
|
}
|
|
2480
2516
|
return {
|
|
@@ -2482,55 +2518,55 @@ function Hn(e, t, n, r, i, a) {
|
|
|
2482
2518
|
nextOffset: s
|
|
2483
2519
|
};
|
|
2484
2520
|
}
|
|
2485
|
-
function
|
|
2486
|
-
let i =
|
|
2521
|
+
function Hn(e, t, n, r) {
|
|
2522
|
+
let i = Bn(e);
|
|
2487
2523
|
t.has(i) && n.push(Rn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
2488
2524
|
}
|
|
2489
|
-
function
|
|
2490
|
-
let i = t, a =
|
|
2525
|
+
function Z(e, t, n, r) {
|
|
2526
|
+
let i = t, a = Un(e, t, n, r);
|
|
2491
2527
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
2492
2528
|
}
|
|
2493
|
-
function
|
|
2529
|
+
function Un(e, t, n, r) {
|
|
2494
2530
|
t >= e.byteLength && q("unexpected end of input");
|
|
2495
2531
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
2496
2532
|
switch (a) {
|
|
2497
2533
|
case 0: {
|
|
2498
|
-
let { value: n, nextOffset: r } =
|
|
2534
|
+
let { value: n, nextOffset: r } = X(e, t, o);
|
|
2499
2535
|
return {
|
|
2500
|
-
value: new
|
|
2536
|
+
value: new O(n, { encodingWidth: K(o, n) }),
|
|
2501
2537
|
nextOffset: r
|
|
2502
2538
|
};
|
|
2503
2539
|
}
|
|
2504
2540
|
case 1: {
|
|
2505
|
-
let { value: n, nextOffset: r } =
|
|
2541
|
+
let { value: n, nextOffset: r } = X(e, t, o), i = K(o, n);
|
|
2506
2542
|
return {
|
|
2507
|
-
value: new
|
|
2543
|
+
value: new k(-1n - n, { encodingWidth: i }),
|
|
2508
2544
|
nextOffset: r
|
|
2509
2545
|
};
|
|
2510
2546
|
}
|
|
2511
2547
|
case 2: {
|
|
2512
2548
|
if (o === 31) {
|
|
2513
|
-
let { chunks: i, nextOffset: a } =
|
|
2549
|
+
let { chunks: i, nextOffset: a } = Vn(e, t, n, r, "byte string", (e) => e instanceof M);
|
|
2514
2550
|
return {
|
|
2515
|
-
value: new
|
|
2551
|
+
value: new N(i),
|
|
2516
2552
|
nextOffset: a
|
|
2517
2553
|
};
|
|
2518
2554
|
}
|
|
2519
|
-
let { value: i, nextOffset: a } =
|
|
2555
|
+
let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i);
|
|
2520
2556
|
return a + s > e.byteLength && q("byte string extends beyond input"), {
|
|
2521
|
-
value: new
|
|
2557
|
+
value: new M(new Uint8Array(e.buffer, e.byteOffset + a, s).slice(), { encodingWidth: c }),
|
|
2522
2558
|
nextOffset: a + s
|
|
2523
2559
|
};
|
|
2524
2560
|
}
|
|
2525
2561
|
case 3: {
|
|
2526
2562
|
if (o === 31) {
|
|
2527
|
-
let { chunks: i, nextOffset: a } =
|
|
2563
|
+
let { chunks: i, nextOffset: a } = Vn(e, t, n, r, "text string", (e) => e instanceof z);
|
|
2528
2564
|
return {
|
|
2529
|
-
value: new
|
|
2565
|
+
value: new P(i),
|
|
2530
2566
|
nextOffset: a
|
|
2531
2567
|
};
|
|
2532
2568
|
}
|
|
2533
|
-
let { value: i, nextOffset: a } =
|
|
2569
|
+
let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i);
|
|
2534
2570
|
a + s > e.byteLength && q("text string extends beyond input");
|
|
2535
2571
|
let l = new Uint8Array(e.buffer, e.byteOffset + a, s), u, d;
|
|
2536
2572
|
try {
|
|
@@ -2538,8 +2574,8 @@ function Wn(e, t, n, r) {
|
|
|
2538
2574
|
} catch {
|
|
2539
2575
|
d = Rn("invalid UTF-8 sequence in text string", a, n), u = Ln.decode(l);
|
|
2540
2576
|
}
|
|
2541
|
-
let f = new
|
|
2542
|
-
return d &&
|
|
2577
|
+
let f = new z(u, { encodingWidth: c });
|
|
2578
|
+
return d && J(f, d), {
|
|
2543
2579
|
value: f,
|
|
2544
2580
|
nextOffset: a + s
|
|
2545
2581
|
};
|
|
@@ -2552,21 +2588,21 @@ function Wn(e, t, n, r) {
|
|
|
2552
2588
|
a++;
|
|
2553
2589
|
break;
|
|
2554
2590
|
}
|
|
2555
|
-
let t =
|
|
2591
|
+
let t = Z(e, a, n, r);
|
|
2556
2592
|
i.push(t.value), a = t.nextOffset;
|
|
2557
2593
|
}
|
|
2558
2594
|
return {
|
|
2559
|
-
value: new
|
|
2595
|
+
value: new F(i, { indefiniteLength: !0 }),
|
|
2560
2596
|
nextOffset: a
|
|
2561
2597
|
};
|
|
2562
2598
|
}
|
|
2563
|
-
let { value: i, nextOffset: a } =
|
|
2599
|
+
let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i), l = [], u = a;
|
|
2564
2600
|
for (let t = 0; t < s; t++) {
|
|
2565
|
-
let t =
|
|
2601
|
+
let t = Z(e, u, n, r);
|
|
2566
2602
|
l.push(t.value), u = t.nextOffset;
|
|
2567
2603
|
}
|
|
2568
2604
|
return {
|
|
2569
|
-
value: new
|
|
2605
|
+
value: new F(l, { encodingWidth: c }),
|
|
2570
2606
|
nextOffset: u
|
|
2571
2607
|
};
|
|
2572
2608
|
}
|
|
@@ -2578,27 +2614,27 @@ function Wn(e, t, n, r) {
|
|
|
2578
2614
|
s++;
|
|
2579
2615
|
break;
|
|
2580
2616
|
}
|
|
2581
|
-
let t =
|
|
2582
|
-
|
|
2583
|
-
let c =
|
|
2617
|
+
let t = Z(e, s, n, r);
|
|
2618
|
+
Hn(t.value, a, o, n), s = t.nextOffset;
|
|
2619
|
+
let c = Z(e, s, n, r);
|
|
2584
2620
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2585
2621
|
}
|
|
2586
|
-
let c = new
|
|
2587
|
-
for (let e of o)
|
|
2622
|
+
let c = new I(i, { indefiniteLength: !0 });
|
|
2623
|
+
for (let e of o) J(c, e);
|
|
2588
2624
|
return {
|
|
2589
2625
|
value: c,
|
|
2590
2626
|
nextOffset: s
|
|
2591
2627
|
};
|
|
2592
2628
|
}
|
|
2593
|
-
let { value: i, nextOffset: a } =
|
|
2629
|
+
let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i), l = [], u = /* @__PURE__ */ new Set(), d = [], f = a;
|
|
2594
2630
|
for (let t = 0; t < s; t++) {
|
|
2595
|
-
let t =
|
|
2596
|
-
|
|
2597
|
-
let i =
|
|
2631
|
+
let t = Z(e, f, n, r);
|
|
2632
|
+
Hn(t.value, u, d, n), f = t.nextOffset;
|
|
2633
|
+
let i = Z(e, f, n, r);
|
|
2598
2634
|
f = i.nextOffset, l.push([t.value, i.value]);
|
|
2599
2635
|
}
|
|
2600
|
-
let p = new
|
|
2601
|
-
for (let e of d)
|
|
2636
|
+
let p = new I(l, { encodingWidth: c });
|
|
2637
|
+
for (let e of d) J(p, e);
|
|
2602
2638
|
return {
|
|
2603
2639
|
value: p,
|
|
2604
2640
|
nextOffset: f
|
|
@@ -2606,90 +2642,98 @@ function Wn(e, t, n, r) {
|
|
|
2606
2642
|
}
|
|
2607
2643
|
case 6: {
|
|
2608
2644
|
o === 31 && q("tags cannot use indefinite-length encoding");
|
|
2609
|
-
let { value: i, nextOffset: a } =
|
|
2645
|
+
let { value: i, nextOffset: a } = X(e, t, o), s = K(o, i), c = Z(e, a, n, r);
|
|
2610
2646
|
for (let e of r) {
|
|
2611
2647
|
let t = e.parseTag(i, c.value, n);
|
|
2612
|
-
if (t !== void 0) return t instanceof
|
|
2648
|
+
if (t !== void 0) return t instanceof j && s !== void 0 && (t.encodingWidth = s), {
|
|
2613
2649
|
value: t,
|
|
2614
2650
|
nextOffset: c.nextOffset
|
|
2615
2651
|
};
|
|
2616
2652
|
}
|
|
2617
2653
|
return {
|
|
2618
|
-
value: new
|
|
2654
|
+
value: new j(i, c.value, { encodingWidth: s }),
|
|
2619
2655
|
nextOffset: c.nextOffset
|
|
2620
2656
|
};
|
|
2621
2657
|
}
|
|
2622
2658
|
case 7:
|
|
2623
2659
|
if (o <= 19) return {
|
|
2624
|
-
value: new
|
|
2660
|
+
value: new L(o),
|
|
2625
2661
|
nextOffset: t
|
|
2626
2662
|
};
|
|
2627
2663
|
if (o === 20) return {
|
|
2628
|
-
value: new
|
|
2664
|
+
value: new L(20),
|
|
2629
2665
|
nextOffset: t
|
|
2630
2666
|
};
|
|
2631
2667
|
if (o === 21) return {
|
|
2632
|
-
value: new
|
|
2668
|
+
value: new L(21),
|
|
2633
2669
|
nextOffset: t
|
|
2634
2670
|
};
|
|
2635
2671
|
if (o === 22) return {
|
|
2636
|
-
value: new
|
|
2672
|
+
value: new L(22),
|
|
2637
2673
|
nextOffset: t
|
|
2638
2674
|
};
|
|
2639
2675
|
if (o === 23) return {
|
|
2640
|
-
value: new
|
|
2676
|
+
value: new L(23),
|
|
2641
2677
|
nextOffset: t
|
|
2642
2678
|
};
|
|
2643
2679
|
if (o === 24) {
|
|
2644
2680
|
t + 1 > e.byteLength && q("unexpected end of input");
|
|
2645
2681
|
let r = e.getUint8(t);
|
|
2646
2682
|
if (r < 32) {
|
|
2647
|
-
let e = Rn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new
|
|
2648
|
-
return
|
|
2683
|
+
let e = Rn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new L(r);
|
|
2684
|
+
return J(i, e), {
|
|
2649
2685
|
value: i,
|
|
2650
2686
|
nextOffset: t + 1
|
|
2651
2687
|
};
|
|
2652
2688
|
}
|
|
2653
2689
|
return {
|
|
2654
|
-
value: new
|
|
2690
|
+
value: new L(r),
|
|
2655
2691
|
nextOffset: t + 1
|
|
2656
2692
|
};
|
|
2657
2693
|
}
|
|
2658
2694
|
return o === 25 ? (t + 2 > e.byteLength && q("unexpected end of input"), {
|
|
2659
|
-
value: new
|
|
2695
|
+
value: new A(S(e.getUint16(t, !1)), { precision: "half" }),
|
|
2660
2696
|
nextOffset: t + 2
|
|
2661
2697
|
}) : o === 26 ? (t + 4 > e.byteLength && q("unexpected end of input"), {
|
|
2662
|
-
value: new
|
|
2698
|
+
value: new A(e.getFloat32(t, !1), { precision: "single" }),
|
|
2663
2699
|
nextOffset: t + 4
|
|
2664
2700
|
}) : o === 27 ? (t + 8 > e.byteLength && q("unexpected end of input"), {
|
|
2665
|
-
value: new
|
|
2701
|
+
value: new A(e.getFloat64(t, !1), { precision: "double" }),
|
|
2666
2702
|
nextOffset: t + 8
|
|
2667
2703
|
}) : (o < 31 && q(`reserved additional info value in major type 7: ${o}`), q("unexpected break code outside indefinite-length item"));
|
|
2668
2704
|
}
|
|
2669
2705
|
return q(`unknown major type: ${a}`);
|
|
2670
2706
|
}
|
|
2671
|
-
function
|
|
2707
|
+
function Wn(e) {
|
|
2672
2708
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
2673
2709
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
2674
2710
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
2675
2711
|
}
|
|
2676
|
-
function
|
|
2677
|
-
let n =
|
|
2712
|
+
function Gn(e, t) {
|
|
2713
|
+
let n = Wn(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
2678
2714
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
2679
|
-
let
|
|
2680
|
-
|
|
2715
|
+
let a = [...t?.extensions ?? [], ...qn].filter((e) => e.parseTag !== void 0), { value: o, nextOffset: s } = Z(r, i, t, a);
|
|
2716
|
+
if (!t?.allowTrailing && s !== r.byteLength) {
|
|
2717
|
+
J(o, Rn(`${r.byteLength - s} trailing byte(s) after end of CBOR item`, s, t));
|
|
2718
|
+
let e = {
|
|
2719
|
+
strict: !1,
|
|
2720
|
+
silent: !0
|
|
2721
|
+
}, n = s;
|
|
2722
|
+
for (; n < r.byteLength;) ({nextOffset: n} = Z(r, n, e, a));
|
|
2723
|
+
}
|
|
2724
|
+
return o;
|
|
2681
2725
|
}
|
|
2682
2726
|
//#endregion
|
|
2683
2727
|
//#region src/extensions/cbordata.ts
|
|
2684
|
-
var
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2728
|
+
var Kn = 24n, qn = [
|
|
2729
|
+
Vt,
|
|
2730
|
+
on,
|
|
2731
|
+
ln,
|
|
2688
2732
|
Fn,
|
|
2689
2733
|
{
|
|
2690
|
-
tagNumbers: [
|
|
2734
|
+
tagNumbers: [Kn],
|
|
2691
2735
|
parseTag(e, t, n) {
|
|
2692
|
-
if (e !== 24n || !(t instanceof
|
|
2736
|
+
if (e !== 24n || !(t instanceof M)) return;
|
|
2693
2737
|
let r = n ? {
|
|
2694
2738
|
extensions: n.extensions,
|
|
2695
2739
|
strict: n.strict,
|
|
@@ -2697,7 +2741,7 @@ var qn = 24n, Z = [
|
|
|
2697
2741
|
silent: n.silent
|
|
2698
2742
|
} : void 0;
|
|
2699
2743
|
try {
|
|
2700
|
-
return new
|
|
2744
|
+
return new j(Kn, new Ve([Gn(t.value, r)], { encodingWidth: t.encodingWidth }));
|
|
2701
2745
|
} catch (e) {
|
|
2702
2746
|
if (r?.strict !== !1) throw e;
|
|
2703
2747
|
return;
|
|
@@ -2710,42 +2754,42 @@ var qn = 24n, Z = [
|
|
|
2710
2754
|
function Q(e, t) {
|
|
2711
2755
|
if (t?.replacer) {
|
|
2712
2756
|
let { replacer: n, ...r } = t, i = Xn(e, n, r.extensions, r.undefinedOmits);
|
|
2713
|
-
return i === d ?
|
|
2757
|
+
return i === d ? L.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
|
|
2714
2758
|
}
|
|
2715
2759
|
return Jn(e, t, !0);
|
|
2716
2760
|
}
|
|
2717
2761
|
function Jn(e, t, n) {
|
|
2718
|
-
for (let n of [...t?.extensions ?? [], ...
|
|
2762
|
+
for (let n of [...t?.extensions ?? [], ...qn]) if (n.fromJS) {
|
|
2719
2763
|
let r = n.fromJS(e, t ?? {});
|
|
2720
2764
|
if (r !== void 0) return r;
|
|
2721
2765
|
}
|
|
2722
2766
|
if (n && typeof e == "object" && e && u.symbol in e) {
|
|
2723
2767
|
let n = e[u.symbol], r = Jn(e, t, !1);
|
|
2724
|
-
for (let e of [...t?.extensions ?? [], ...
|
|
2768
|
+
for (let e of [...t?.extensions ?? [], ...qn]) if (e.parseTag) {
|
|
2725
2769
|
let t = e.parseTag(n, r);
|
|
2726
2770
|
if (t !== void 0) return t;
|
|
2727
2771
|
}
|
|
2728
|
-
return new
|
|
2729
|
-
}
|
|
2730
|
-
if (e instanceof u.Null) return
|
|
2731
|
-
if (e instanceof u.Undefined) return
|
|
2732
|
-
if (e instanceof f) return new
|
|
2733
|
-
if (e === null) return
|
|
2734
|
-
if (e === void 0) return
|
|
2735
|
-
if (e === !0) return
|
|
2736
|
-
if (e === !1) return
|
|
2737
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new
|
|
2738
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new
|
|
2739
|
-
if (typeof e == "string") return new
|
|
2772
|
+
return new j(n, r);
|
|
2773
|
+
}
|
|
2774
|
+
if (e instanceof u.Null) return L.NULL;
|
|
2775
|
+
if (e instanceof u.Undefined) return L.UNDEFINED;
|
|
2776
|
+
if (e instanceof f) return new L(e.value);
|
|
2777
|
+
if (e === null) return L.NULL;
|
|
2778
|
+
if (e === void 0) return L.UNDEFINED;
|
|
2779
|
+
if (e === !0) return L.TRUE;
|
|
2780
|
+
if (e === !1) return L.FALSE;
|
|
2781
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new Qe(e) : e < -18446744073709551616n ? new $e(e) : e >= 0n ? new O(e) : new k(e);
|
|
2782
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new O(BigInt(e)) : new k(BigInt(e)) : new A(e);
|
|
2783
|
+
if (typeof e == "string") return new z(e);
|
|
2740
2784
|
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Jn(e.valueOf(), t, !1);
|
|
2741
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new
|
|
2742
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new
|
|
2743
|
-
if (e instanceof $) return new
|
|
2744
|
-
if (Array.isArray(e)) return new
|
|
2785
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new M(new Uint8Array(e));
|
|
2786
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new F(Array.from(e, (e) => new O(BigInt(e)))) : new M(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
2787
|
+
if (e instanceof $) return new I([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
|
|
2788
|
+
if (Array.isArray(e)) return new F(e.map((e) => Q(e, t)));
|
|
2745
2789
|
if (typeof e == "object") {
|
|
2746
2790
|
let n = [];
|
|
2747
|
-
for (let [r, i] of Object.entries(e)) n.push([new
|
|
2748
|
-
return new
|
|
2791
|
+
for (let [r, i] of Object.entries(e)) n.push([new z(r), Q(i, t)]);
|
|
2792
|
+
return new I(n);
|
|
2749
2793
|
}
|
|
2750
2794
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
2751
2795
|
}
|
|
@@ -2753,7 +2797,7 @@ function Yn(e) {
|
|
|
2753
2797
|
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]" || e instanceof u.Null || e instanceof u.Undefined || e instanceof f;
|
|
2754
2798
|
}
|
|
2755
2799
|
function Xn(e, t, n, r) {
|
|
2756
|
-
let i = [...n ?? [], ...
|
|
2800
|
+
let i = [...n ?? [], ...qn];
|
|
2757
2801
|
function a(e) {
|
|
2758
2802
|
return e === d || r === !0 && e === void 0;
|
|
2759
2803
|
}
|
|
@@ -2828,6 +2872,6 @@ var $ = class extends Array {
|
|
|
2828
2872
|
}
|
|
2829
2873
|
};
|
|
2830
2874
|
//#endregion
|
|
2831
|
-
export { i as A,
|
|
2875
|
+
export { i as A, x as C, n as D, d as E, r as O, S, f as T, j as _, Ht as a, O as b, $e as c, L as d, I as f, M as g, N as h, Gn as i, u as k, Qe as l, P as m, Xn as n, z as o, F as p, Q as r, rt as s, $ as t, Ve as u, A as v, ne as w, D as x, k as y };
|
|
2832
2876
|
|
|
2833
|
-
//# sourceMappingURL=mapEntries-
|
|
2877
|
+
//# sourceMappingURL=mapEntries-Cc4If3gy.js.map
|