@cbortech/cbor 0.25.6 → 0.25.7
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/dist/ast/CborIndefiniteTextString.d.ts +1 -1
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +1 -1
- package/dist/cdn/index.cjs +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/mapEntries-C5S6uTIO.cjs +12 -0
- package/dist/mapEntries-C5S6uTIO.cjs.map +1 -0
- package/dist/{mapEntries-DDh7IS2M.js → mapEntries-bvRWFfqX.js} +624 -606
- package/dist/mapEntries-bvRWFfqX.js.map +1 -0
- package/dist/{tokenizer-C597LW89.js → tokenizer-BuRSmdyM.js} +3 -3
- package/dist/{tokenizer-C597LW89.js.map → tokenizer-BuRSmdyM.js.map} +1 -1
- package/dist/{tokenizer-C8NLHT2B.cjs → tokenizer-M2pf9ud0.cjs} +2 -2
- package/dist/{tokenizer-C8NLHT2B.cjs.map → tokenizer-M2pf9ud0.cjs.map} +1 -1
- package/dist/types.d.ts +37 -7
- package/package.json +1 -1
- package/dist/mapEntries-DDh7IS2M.js.map +0 -1
- package/dist/mapEntries-DvugpzeP.cjs +0 -12
- package/dist/mapEntries-DvugpzeP.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, t } from "./tokenizer-
|
|
1
|
+
import { n as e, t } from "./tokenizer-BuRSmdyM.js";
|
|
2
2
|
//#region src/tag.ts
|
|
3
3
|
var n = Symbol.for("cbor.tag"), r = class {
|
|
4
4
|
valueOf() {
|
|
@@ -95,16 +95,16 @@ var u = class {
|
|
|
95
95
|
}
|
|
96
96
|
}, p = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), m = 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 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,15 +979,15 @@ 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
992
|
if (e === 0n) return new Uint8Array();
|
|
988
993
|
let t = e.toString(16);
|
|
@@ -991,16 +996,16 @@ function Ze(e) {
|
|
|
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,22 @@ 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, { offset: n?.offset }), i = new
|
|
1026
|
-
return n?.preserveComments &&
|
|
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, { offset: n?.offset }), i = new ht(r, n ?? {}).parse();
|
|
1031
|
+
return n?.preserveComments && ct(i, r.comments, e), i;
|
|
1027
1032
|
}
|
|
1028
|
-
function
|
|
1033
|
+
function it(e) {
|
|
1029
1034
|
let t = e, n;
|
|
1030
1035
|
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1031
1036
|
numStr: t,
|
|
1032
1037
|
rawSuffix: n
|
|
1033
1038
|
};
|
|
1034
1039
|
}
|
|
1035
|
-
function
|
|
1040
|
+
function at(e) {
|
|
1036
1041
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1037
1042
|
}
|
|
1038
|
-
function
|
|
1043
|
+
function ot(e, t) {
|
|
1039
1044
|
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1040
1045
|
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1041
1046
|
if (t) t(n), e = e.slice(0, -2);
|
|
@@ -1059,14 +1064,14 @@ function st(e, t) {
|
|
|
1059
1064
|
};
|
|
1060
1065
|
let n = e, r;
|
|
1061
1066
|
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:
|
|
1067
|
+
value: Re(n),
|
|
1063
1068
|
precision: r
|
|
1064
1069
|
} : {
|
|
1065
1070
|
value: parseFloat(n),
|
|
1066
1071
|
precision: r
|
|
1067
1072
|
};
|
|
1068
1073
|
}
|
|
1069
|
-
function
|
|
1074
|
+
function st(e, t) {
|
|
1070
1075
|
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
1071
1076
|
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
1072
1077
|
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
@@ -1103,49 +1108,49 @@ function ct(e, t) {
|
|
|
1103
1108
|
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
1104
1109
|
return l;
|
|
1105
1110
|
}
|
|
1106
|
-
function
|
|
1111
|
+
function ct(e, t, n) {
|
|
1107
1112
|
if (t.length === 0) return;
|
|
1108
|
-
let r =
|
|
1113
|
+
let r = lt(e), i = dt(n);
|
|
1109
1114
|
for (let a of t) {
|
|
1110
1115
|
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
1116
|
if (o && i(o.end) === a.line && !s.includes(":")) {
|
|
1112
|
-
|
|
1117
|
+
ut(o.node, "trailing", t);
|
|
1113
1118
|
continue;
|
|
1114
1119
|
}
|
|
1115
1120
|
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
1121
|
if ((!c || l && l.end <= c.end) && l) {
|
|
1117
|
-
|
|
1122
|
+
ut(l.node, "leading", t);
|
|
1118
1123
|
continue;
|
|
1119
1124
|
}
|
|
1120
|
-
|
|
1125
|
+
ut(c?.node ?? e, "dangling", t);
|
|
1121
1126
|
}
|
|
1122
1127
|
}
|
|
1123
|
-
function
|
|
1128
|
+
function lt(e) {
|
|
1124
1129
|
let t = [], n = (e) => {
|
|
1125
1130
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1126
1131
|
node: e,
|
|
1127
1132
|
start: e.start,
|
|
1128
1133
|
end: e.end
|
|
1129
|
-
}), e instanceof
|
|
1134
|
+
}), e instanceof F || e instanceof Ve) {
|
|
1130
1135
|
for (let t of e.items) n(t);
|
|
1131
1136
|
return;
|
|
1132
1137
|
}
|
|
1133
|
-
if (e instanceof
|
|
1138
|
+
if (e instanceof I) {
|
|
1134
1139
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1135
1140
|
return;
|
|
1136
1141
|
}
|
|
1137
|
-
if (e instanceof
|
|
1142
|
+
if (e instanceof N || e instanceof P) {
|
|
1138
1143
|
for (let t of e.chunks) n(t);
|
|
1139
1144
|
return;
|
|
1140
1145
|
}
|
|
1141
|
-
e instanceof
|
|
1146
|
+
e instanceof j && n(e.content);
|
|
1142
1147
|
};
|
|
1143
1148
|
return n(e), t;
|
|
1144
1149
|
}
|
|
1145
|
-
function
|
|
1150
|
+
function ut(e, t, n) {
|
|
1146
1151
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1147
1152
|
}
|
|
1148
|
-
function
|
|
1153
|
+
function dt(e) {
|
|
1149
1154
|
let t = [0];
|
|
1150
1155
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1151
1156
|
return (n) => {
|
|
@@ -1159,15 +1164,15 @@ function ft(e) {
|
|
|
1159
1164
|
return a + 1;
|
|
1160
1165
|
};
|
|
1161
1166
|
}
|
|
1162
|
-
var
|
|
1163
|
-
["b32",
|
|
1164
|
-
["h32",
|
|
1165
|
-
["float",
|
|
1166
|
-
["same",
|
|
1167
|
-
["hash",
|
|
1168
|
-
["uuid",
|
|
1169
|
-
["UUID",
|
|
1170
|
-
]),
|
|
1167
|
+
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 = new Map([
|
|
1168
|
+
["b32", ft("b32")],
|
|
1169
|
+
["h32", ft("h32")],
|
|
1170
|
+
["float", ft("float")],
|
|
1171
|
+
["same", ft("same")],
|
|
1172
|
+
["hash", pt("hash", "@cbortech/hash-extension")],
|
|
1173
|
+
["uuid", pt("uuid", "@cbortech/uuid-extension")],
|
|
1174
|
+
["UUID", pt("uuid", "@cbortech/uuid-extension")]
|
|
1175
|
+
]), ht = class {
|
|
1171
1176
|
t;
|
|
1172
1177
|
_options;
|
|
1173
1178
|
extByPrefix;
|
|
@@ -1177,7 +1182,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1177
1182
|
_hintedPrefixes = /* @__PURE__ */ new Set();
|
|
1178
1183
|
constructor(t, n) {
|
|
1179
1184
|
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 [...
|
|
1185
|
+
for (let e of [...qn, ...n.extensions ?? []]) {
|
|
1181
1186
|
for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
|
|
1182
1187
|
for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
|
|
1183
1188
|
}
|
|
@@ -1199,10 +1204,15 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1199
1204
|
let e = this.parseValue();
|
|
1200
1205
|
if (this._options.allowTrailing) return e;
|
|
1201
1206
|
let t = this.t.peek();
|
|
1202
|
-
|
|
1207
|
+
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();
|
|
1208
|
+
return e;
|
|
1203
1209
|
}
|
|
1204
1210
|
parseValue() {
|
|
1205
1211
|
let e = this.t.peek().offset, t = this._parseValueNode();
|
|
1212
|
+
if (this.t.peek().type === "UNDERSCORE") {
|
|
1213
|
+
let e = this.t.consume();
|
|
1214
|
+
this._warnOrFail("bare _ is not a valid encoding indicator; use _0, _1, _2, _3, or _i", e);
|
|
1215
|
+
}
|
|
1206
1216
|
if (this._pendingWarnings.length > 0) {
|
|
1207
1217
|
t.warnings ??= [];
|
|
1208
1218
|
for (let e of this._pendingWarnings) t.warnings.push(e);
|
|
@@ -1220,12 +1230,12 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1220
1230
|
case "BYTES_HEX":
|
|
1221
1231
|
case "SQSTR":
|
|
1222
1232
|
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
|
|
1233
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new N([]);
|
|
1234
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new P([]);
|
|
1235
|
+
case "TRUE": return this.t.consume(), new L(21);
|
|
1236
|
+
case "FALSE": return this.t.consume(), new L(20);
|
|
1237
|
+
case "NULL": return this.t.consume(), new L(22);
|
|
1238
|
+
case "UNDEFINED": return this.t.consume(), new L(23);
|
|
1229
1239
|
case "SIMPLE": return this.parseSimple();
|
|
1230
1240
|
case "LBRACKET": return this.parseArray();
|
|
1231
1241
|
case "LBRACE": return this.parseMap();
|
|
@@ -1240,21 +1250,21 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1240
1250
|
}
|
|
1241
1251
|
let r = this.extByPrefix.get(e.appPrefix);
|
|
1242
1252
|
if (!r?.parseAppString) {
|
|
1243
|
-
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1253
|
+
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ue(e.appPrefix, [new z(e.value)]);
|
|
1244
1254
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1245
1255
|
}
|
|
1246
1256
|
{
|
|
1247
1257
|
let i = this._pendingWarnings.length;
|
|
1248
1258
|
try {
|
|
1249
1259
|
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
|
|
1260
|
+
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
1261
|
ednEncoding: i.ednEncoding,
|
|
1252
1262
|
encodingWidth: i.encodingWidth,
|
|
1253
1263
|
ednSource: e.raw + n
|
|
1254
|
-
}) : (i instanceof
|
|
1264
|
+
}) : (i instanceof A && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1255
1265
|
} catch (t) {
|
|
1256
1266
|
if (this._options.strict !== !1) throw t;
|
|
1257
|
-
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new
|
|
1267
|
+
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Ue(e.appPrefix, [new z(e.value)]);
|
|
1258
1268
|
}
|
|
1259
1269
|
}
|
|
1260
1270
|
}
|
|
@@ -1267,7 +1277,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1267
1277
|
this.t.peek().type === "ENCODING_INDICATOR" && (r = this.t.consume(), n = this._resolveEncodingWidth(r.value, r));
|
|
1268
1278
|
let i = this.extByPrefix.get(e.appPrefix);
|
|
1269
1279
|
if (!i) {
|
|
1270
|
-
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1280
|
+
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ue(e.appPrefix, t);
|
|
1271
1281
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1272
1282
|
}
|
|
1273
1283
|
i.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
@@ -1277,61 +1287,61 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1277
1287
|
let a = i.parseAppSequence(e.appPrefix, t, this._extOnError(e));
|
|
1278
1288
|
n !== void 0 && this._applyEiToResult(a, n, r ?? e);
|
|
1279
1289
|
let o = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1280
|
-
if (a instanceof
|
|
1281
|
-
else if (i.preserveAppSeqSource) return new
|
|
1290
|
+
if (a instanceof A) a.ednSource === void 0 && (a.ednSource = o);
|
|
1291
|
+
else if (i.preserveAppSeqSource) return new We(a, o);
|
|
1282
1292
|
return a;
|
|
1283
1293
|
} catch (n) {
|
|
1284
1294
|
if (this._options.strict !== !1) throw n;
|
|
1285
|
-
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new
|
|
1295
|
+
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new Ue(e.appPrefix, t);
|
|
1286
1296
|
}
|
|
1287
1297
|
}
|
|
1288
1298
|
}
|
|
1289
1299
|
case "ELLIPSIS": {
|
|
1290
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
1291
|
-
let e = [new
|
|
1300
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new R();
|
|
1301
|
+
let e = [new R()];
|
|
1292
1302
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1293
|
-
return new
|
|
1303
|
+
return new R(e);
|
|
1294
1304
|
}
|
|
1295
1305
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1296
1306
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1297
1307
|
}
|
|
1298
1308
|
}
|
|
1299
1309
|
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
|
|
1310
|
+
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);
|
|
1311
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new Qe(i);
|
|
1312
|
+
if (i < -18446744073709551616n) return new $e(i);
|
|
1303
1313
|
if (r !== void 0) {
|
|
1304
1314
|
let t = i >= 0n ? i : -(i + 1n);
|
|
1305
1315
|
r = this._validateEncodingFit(t, r, e);
|
|
1306
1316
|
}
|
|
1307
|
-
let a = i >= 0n ? new
|
|
1317
|
+
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
1318
|
if (this.t.peek().type === "LPAREN") {
|
|
1309
|
-
a instanceof
|
|
1319
|
+
a instanceof O || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
1310
1320
|
let t = this._pendingWarnings.splice(0), n = this.parseValue();
|
|
1311
1321
|
this.expect("RPAREN");
|
|
1312
1322
|
let i = a.value, o = this.extByTag.get(i);
|
|
1313
1323
|
if (o?.parseTag) {
|
|
1314
1324
|
let e = o.parseTag(i, n);
|
|
1315
|
-
if (e !== void 0) return e instanceof
|
|
1325
|
+
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
1326
|
}
|
|
1317
|
-
let s = new
|
|
1327
|
+
let s = new j(i, n, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1318
1328
|
return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
|
|
1319
1329
|
}
|
|
1320
1330
|
return a;
|
|
1321
1331
|
}
|
|
1322
1332
|
parseFloat() {
|
|
1323
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } =
|
|
1333
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = ot(e.value, t);
|
|
1324
1334
|
if (r === "half" || r === "single") {
|
|
1325
|
-
let e = r === "half" ? x(
|
|
1335
|
+
let e = r === "half" ? S(x(n)) : Math.fround(n);
|
|
1326
1336
|
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
1337
|
}
|
|
1328
|
-
return new
|
|
1338
|
+
return new A(n, r === void 0 ? void 0 : { precision: r });
|
|
1329
1339
|
}
|
|
1330
1340
|
parseString() {
|
|
1331
1341
|
let e = this.t.consume();
|
|
1332
1342
|
if (this.t.peek().type !== "PLUS") {
|
|
1333
|
-
let t = this.consumeEncodingIndicator(() => BigInt(
|
|
1334
|
-
return new
|
|
1343
|
+
let t = this.consumeEncodingIndicator(() => BigInt(et.encode(e.value).length));
|
|
1344
|
+
return new z(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1335
1345
|
}
|
|
1336
1346
|
let t = !1, n = [{ text: e.value }];
|
|
1337
1347
|
for (; this.t.peek().type === "PLUS";) {
|
|
@@ -1340,12 +1350,12 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1340
1350
|
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
1351
|
}
|
|
1342
1352
|
if (!t) {
|
|
1343
|
-
let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(
|
|
1344
|
-
return new
|
|
1353
|
+
let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(et.encode(e).length));
|
|
1354
|
+
return new z(e, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1345
1355
|
}
|
|
1346
1356
|
let r = [], i = "";
|
|
1347
|
-
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new
|
|
1348
|
-
return i !== "" && r.push(new
|
|
1357
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new z(i)), i = ""), r.push(new R())) : i += e.text;
|
|
1358
|
+
return i !== "" && r.push(new z(i)), new R(r);
|
|
1349
1359
|
}
|
|
1350
1360
|
_isBytesToken(e) {
|
|
1351
1361
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
@@ -1354,9 +1364,9 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1354
1364
|
let n = (e) => this._warnOrFail(e, t);
|
|
1355
1365
|
switch (t.type) {
|
|
1356
1366
|
case "BYTES_HEX":
|
|
1357
|
-
case "SQSTR": return
|
|
1367
|
+
case "SQSTR": return ne(t.value);
|
|
1358
1368
|
case "BYTES_B64": try {
|
|
1359
|
-
return
|
|
1369
|
+
return st(t.value, n);
|
|
1360
1370
|
} catch (n) {
|
|
1361
1371
|
if (n instanceof e || !(n instanceof SyntaxError)) throw n;
|
|
1362
1372
|
this._fail(n.message, t);
|
|
@@ -1365,11 +1375,11 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1365
1375
|
}
|
|
1366
1376
|
}
|
|
1367
1377
|
_decodeUtf8(e, t) {
|
|
1368
|
-
if (this._options.allowInvalidUtf8) return
|
|
1378
|
+
if (this._options.allowInvalidUtf8) return nt.decode(e);
|
|
1369
1379
|
try {
|
|
1370
|
-
return
|
|
1380
|
+
return tt.decode(e);
|
|
1371
1381
|
} catch {
|
|
1372
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t),
|
|
1382
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), nt.decode(e);
|
|
1373
1383
|
}
|
|
1374
1384
|
}
|
|
1375
1385
|
_tokenTypeToCdnEncoding(e) {
|
|
@@ -1378,7 +1388,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1378
1388
|
_parseBytesConcat(e, t, n) {
|
|
1379
1389
|
if (this.t.peek().type !== "PLUS") {
|
|
1380
1390
|
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1381
|
-
return new
|
|
1391
|
+
return new M(e, {
|
|
1382
1392
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1383
1393
|
ednSource: n,
|
|
1384
1394
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
@@ -1392,25 +1402,25 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1392
1402
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1393
1403
|
this.t.consume();
|
|
1394
1404
|
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:
|
|
1405
|
+
for (let e of t) e instanceof R ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof M && i.push({ bytes: e.value });
|
|
1406
|
+
} 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
1407
|
}
|
|
1398
1408
|
if (!r) {
|
|
1399
1409
|
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
|
|
1410
|
+
return new M(t, n === void 0 ? void 0 : { encodingWidth: n });
|
|
1401
1411
|
}
|
|
1402
1412
|
let a = [], o = [], s = () => {
|
|
1403
|
-
o.length > 0 && (a.push(new
|
|
1413
|
+
o.length > 0 && (a.push(new M(this._concatBytes([...o]))), o.length = 0);
|
|
1404
1414
|
};
|
|
1405
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new
|
|
1406
|
-
return s(), new
|
|
1415
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new R())) : o.push(e.bytes);
|
|
1416
|
+
return s(), new R(a);
|
|
1407
1417
|
}
|
|
1408
1418
|
_parseHexElidedConcat(e) {
|
|
1409
1419
|
let t = this._buildBytesElidedItems(e.value);
|
|
1410
1420
|
for (; this.t.peek().type === "PLUS";) {
|
|
1411
1421
|
this.t.consume();
|
|
1412
1422
|
let e = this.t.peek();
|
|
1413
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new
|
|
1423
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new R());
|
|
1414
1424
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1415
1425
|
this.t.consume();
|
|
1416
1426
|
let n = this._buildBytesElidedItems(e.value);
|
|
@@ -1418,20 +1428,20 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1418
1428
|
} else if (this._isBytesToken(e.type)) {
|
|
1419
1429
|
this.t.consume();
|
|
1420
1430
|
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
1421
|
-
r instanceof
|
|
1431
|
+
r instanceof M ? t[t.length - 1] = new M(this._concatBytes([r.value, n])) : t.push(new M(n));
|
|
1422
1432
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1423
1433
|
}
|
|
1424
|
-
return new
|
|
1434
|
+
return new R(t);
|
|
1425
1435
|
}
|
|
1426
1436
|
_buildBytesElidedItems(e) {
|
|
1427
1437
|
let t = e.split("..."), n = [];
|
|
1428
|
-
for (let e = 0; e < t.length; e++) e > 0 && n.push(new
|
|
1438
|
+
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
1439
|
return n;
|
|
1430
1440
|
}
|
|
1431
1441
|
_mergeFirstBytesItem(e, t) {
|
|
1432
1442
|
if (t.length === 0) return;
|
|
1433
1443
|
let n = e[e.length - 1], r = t[0];
|
|
1434
|
-
n instanceof
|
|
1444
|
+
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
1445
|
}
|
|
1436
1446
|
_concatBytes(e) {
|
|
1437
1447
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -1442,8 +1452,8 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1442
1452
|
this.t.consume(), this.expect("LPAREN");
|
|
1443
1453
|
let e = this.t.peek();
|
|
1444
1454
|
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
|
|
1455
|
+
let { numStr: t } = it(e.value), n = Number(at(t));
|
|
1456
|
+
return this.expect("RPAREN"), new L(n);
|
|
1447
1457
|
}
|
|
1448
1458
|
parseEmbeddedCBOR() {
|
|
1449
1459
|
this.t.consume();
|
|
@@ -1455,7 +1465,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1455
1465
|
let e = this.t.consume();
|
|
1456
1466
|
t = this._resolveEncodingWidth(e.value, e);
|
|
1457
1467
|
}
|
|
1458
|
-
return new
|
|
1468
|
+
return new Ve(e, { encodingWidth: t });
|
|
1459
1469
|
}
|
|
1460
1470
|
parseArray() {
|
|
1461
1471
|
this.t.consume();
|
|
@@ -1464,7 +1474,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1464
1474
|
let r = this._pendingWarnings.splice(0), i = [];
|
|
1465
1475
|
for (; this.t.peek().type !== "RBRACKET" && !(i.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACKET"));) i.push(this.parseValue());
|
|
1466
1476
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1467
|
-
let a = new
|
|
1477
|
+
let a = new F(i, {
|
|
1468
1478
|
indefiniteLength: e,
|
|
1469
1479
|
encodingWidth: t
|
|
1470
1480
|
});
|
|
@@ -1482,7 +1492,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1482
1492
|
i.push([e, t]);
|
|
1483
1493
|
}
|
|
1484
1494
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1485
|
-
let a = new
|
|
1495
|
+
let a = new I(i, {
|
|
1486
1496
|
indefiniteLength: e,
|
|
1487
1497
|
encodingWidth: t
|
|
1488
1498
|
});
|
|
@@ -1501,16 +1511,16 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1501
1511
|
for (; this.t.peek().type !== "RPAREN" && !(n.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RPAREN"));) n.push(this.parseValue());
|
|
1502
1512
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1503
1513
|
let r = n[0];
|
|
1504
|
-
if (r instanceof
|
|
1505
|
-
let e = new
|
|
1506
|
-
if (e instanceof
|
|
1514
|
+
if (r instanceof M) {
|
|
1515
|
+
let e = new N(n.map((e, t) => {
|
|
1516
|
+
if (e instanceof M) return e;
|
|
1507
1517
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
1508
1518
|
}));
|
|
1509
1519
|
return t.length > 0 && (e.warnings = t), e;
|
|
1510
1520
|
}
|
|
1511
|
-
if (r instanceof
|
|
1512
|
-
let e = new
|
|
1513
|
-
if (e instanceof
|
|
1521
|
+
if (r instanceof z) {
|
|
1522
|
+
let e = new P(n.map((e, t) => {
|
|
1523
|
+
if (e instanceof z) return e;
|
|
1514
1524
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
1515
1525
|
}));
|
|
1516
1526
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -1528,47 +1538,47 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1528
1538
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
1529
1539
|
}
|
|
1530
1540
|
_applyEiToResult(e, t, n) {
|
|
1531
|
-
if (e instanceof
|
|
1541
|
+
if (e instanceof A) {
|
|
1532
1542
|
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
1533
1543
|
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
1534
1544
|
else if (e.precision !== r) {
|
|
1535
1545
|
if (r !== "double") {
|
|
1536
|
-
let t = r === "half" ? x(
|
|
1546
|
+
let t = r === "half" ? S(x(e.value)) : Math.fround(e.value);
|
|
1537
1547
|
!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
1548
|
}
|
|
1539
1549
|
e.precision = r;
|
|
1540
1550
|
}
|
|
1541
|
-
} else if (e instanceof
|
|
1551
|
+
} else if (e instanceof O) {
|
|
1542
1552
|
if (e.encodingWidth === void 0) {
|
|
1543
1553
|
let r = this._validateEncodingFit(e.value, t, n);
|
|
1544
1554
|
r !== void 0 && (e.encodingWidth = r);
|
|
1545
1555
|
}
|
|
1546
|
-
} else if (e instanceof
|
|
1556
|
+
} else if (e instanceof k) {
|
|
1547
1557
|
if (e.encodingWidth === void 0) {
|
|
1548
1558
|
let r = this._validateEncodingFit(e.argument, t, n);
|
|
1549
1559
|
r !== void 0 && (e.encodingWidth = r);
|
|
1550
1560
|
}
|
|
1551
|
-
} else if (e instanceof
|
|
1561
|
+
} else if (e instanceof M) {
|
|
1552
1562
|
if (e.encodingWidth === void 0) {
|
|
1553
1563
|
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
1554
1564
|
r !== void 0 && (e.encodingWidth = r);
|
|
1555
1565
|
}
|
|
1556
|
-
} else if (e instanceof
|
|
1566
|
+
} else if (e instanceof z) {
|
|
1557
1567
|
if (e.encodingWidth === void 0) {
|
|
1558
|
-
let r = this._validateEncodingFit(BigInt(
|
|
1568
|
+
let r = this._validateEncodingFit(BigInt(et.encode(e.value).length), t, n);
|
|
1559
1569
|
r !== void 0 && (e.encodingWidth = r);
|
|
1560
1570
|
}
|
|
1561
|
-
} else if (e instanceof
|
|
1571
|
+
} else if (e instanceof F) {
|
|
1562
1572
|
if (e.encodingWidth === void 0) {
|
|
1563
1573
|
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
1564
1574
|
r !== void 0 && (e.encodingWidth = r);
|
|
1565
1575
|
}
|
|
1566
|
-
} else if (e instanceof
|
|
1576
|
+
} else if (e instanceof I) {
|
|
1567
1577
|
if (e.encodingWidth === void 0) {
|
|
1568
1578
|
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
1569
1579
|
r !== void 0 && (e.encodingWidth = r);
|
|
1570
1580
|
}
|
|
1571
|
-
} else if (e instanceof
|
|
1581
|
+
} else if (e instanceof j) {
|
|
1572
1582
|
if (e.encodingWidth === void 0) {
|
|
1573
1583
|
let r = this._validateEncodingFit(e.tag, t, n);
|
|
1574
1584
|
r !== void 0 && (e.encodingWidth = r);
|
|
@@ -1576,7 +1586,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1576
1586
|
} else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
|
|
1577
1587
|
}
|
|
1578
1588
|
_validateEncodingFit(e, t, n) {
|
|
1579
|
-
let r =
|
|
1589
|
+
let r = Me(t);
|
|
1580
1590
|
if (e <= r) return t;
|
|
1581
1591
|
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
1582
1592
|
this._warnOrFail(i, n);
|
|
@@ -1600,7 +1610,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1600
1610
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
1601
1611
|
}
|
|
1602
1612
|
_hintMissingExtension(e, t) {
|
|
1603
|
-
let n =
|
|
1613
|
+
let n = mt.get(e);
|
|
1604
1614
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
1605
1615
|
this._hintedPrefixes.add(e);
|
|
1606
1616
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
@@ -1627,7 +1637,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1627
1637
|
endOffset: n.endOffset
|
|
1628
1638
|
} : void 0);
|
|
1629
1639
|
}
|
|
1630
|
-
},
|
|
1640
|
+
}, gt = new TextEncoder(), _t = !1, z = class extends D {
|
|
1631
1641
|
indefiniteLength = !1;
|
|
1632
1642
|
value;
|
|
1633
1643
|
encodingWidth;
|
|
@@ -1635,42 +1645,42 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1635
1645
|
super(), this.value = e, this.encodingWidth = t?.encodingWidth;
|
|
1636
1646
|
}
|
|
1637
1647
|
_encodeTo(e, t) {
|
|
1638
|
-
let n =
|
|
1639
|
-
|
|
1648
|
+
let n = gt.encode(this.value);
|
|
1649
|
+
T(e, 3, n.length, this.encodingWidth), e.writeBytes(n);
|
|
1640
1650
|
}
|
|
1641
1651
|
_toCDN(e, t) {
|
|
1642
|
-
let n =
|
|
1643
|
-
return
|
|
1652
|
+
let n = b(e, this.encodingWidth, () => y(BigInt(gt.encode(this.value).length)));
|
|
1653
|
+
return vt(this.value, n, e, t);
|
|
1644
1654
|
}
|
|
1645
1655
|
_toJS(e) {
|
|
1646
1656
|
return this.value;
|
|
1647
1657
|
}
|
|
1648
1658
|
};
|
|
1649
|
-
function
|
|
1650
|
-
let i =
|
|
1651
|
-
if (i.length === 0 || a === null) return
|
|
1659
|
+
function vt(e, t, n, r) {
|
|
1660
|
+
let i = yt(n?.textStringFormat ?? []), a = re(n);
|
|
1661
|
+
if (i.length === 0 || a === null) return we(e) + t;
|
|
1652
1662
|
let o = /* @__PURE__ */ new Map(), s = null;
|
|
1653
|
-
if (i.includes("cdn") && (s =
|
|
1663
|
+
if (i.includes("cdn") && (s = xt(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
|
|
1654
1664
|
if (i.includes("newline")) {
|
|
1655
|
-
let t = s === null ?
|
|
1665
|
+
let t = s === null ? bt(e, 0) : St(e);
|
|
1656
1666
|
for (let { point: e, contentDepth: n } of t) o.has(e) || o.set(e, n);
|
|
1657
1667
|
}
|
|
1658
|
-
let c =
|
|
1659
|
-
if (c.length <= 1) return
|
|
1668
|
+
let c = kt(e, o);
|
|
1669
|
+
if (c.length <= 1) return we(e) + t;
|
|
1660
1670
|
let l = c.map(({ text: e }, n) => {
|
|
1661
|
-
let r =
|
|
1671
|
+
let r = we(e);
|
|
1662
1672
|
return n === c.length - 1 ? r + t : r;
|
|
1663
1673
|
}), u = l[0];
|
|
1664
1674
|
for (let e = 1; e < l.length; e++) {
|
|
1665
|
-
let t =
|
|
1675
|
+
let t = _(a, r + 1 + c[e].contentDepth);
|
|
1666
1676
|
u += ` +\n${t}${l[e]}`;
|
|
1667
1677
|
}
|
|
1668
1678
|
return u;
|
|
1669
1679
|
}
|
|
1670
|
-
function
|
|
1671
|
-
return e.map((e) => e === "cboredn" ? (
|
|
1680
|
+
function yt(e) {
|
|
1681
|
+
return e.map((e) => e === "cboredn" ? (_t || (_t = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
1672
1682
|
}
|
|
1673
|
-
function
|
|
1683
|
+
function bt(e, t) {
|
|
1674
1684
|
let n = [];
|
|
1675
1685
|
for (let r = 0; r < e.length; r++) {
|
|
1676
1686
|
let i = e[r];
|
|
@@ -1687,9 +1697,9 @@ function xt(e, t) {
|
|
|
1687
1697
|
}
|
|
1688
1698
|
return n;
|
|
1689
1699
|
}
|
|
1690
|
-
function
|
|
1700
|
+
function xt(e) {
|
|
1691
1701
|
try {
|
|
1692
|
-
|
|
1702
|
+
rt(e);
|
|
1693
1703
|
} catch {
|
|
1694
1704
|
return null;
|
|
1695
1705
|
}
|
|
@@ -1698,24 +1708,24 @@ function St(e) {
|
|
|
1698
1708
|
let t = r.consume();
|
|
1699
1709
|
if (t.type === "EOF") break;
|
|
1700
1710
|
let c = !1;
|
|
1701
|
-
if (o || (o = !0, t.offset > 0 &&
|
|
1711
|
+
if (o || (o = !0, t.offset > 0 && Dt(r.comments, 0, t.offset) && n.push({
|
|
1702
1712
|
point: t.offset,
|
|
1703
1713
|
contentDepth: i
|
|
1704
1714
|
})), a !== null) {
|
|
1705
|
-
if (a.kind === "opener" &&
|
|
1715
|
+
if (a.kind === "opener" && wt.has(t.type)) {
|
|
1706
1716
|
a.point = t.endOffset, s = t.endOffset;
|
|
1707
1717
|
continue;
|
|
1708
|
-
} else a.kind === "opener" &&
|
|
1718
|
+
} else a.kind === "opener" && Et.has(t.type) && Ot(e, a.point, t.offset) ? c = !0 : n.push({
|
|
1709
1719
|
point: t.offset,
|
|
1710
1720
|
contentDepth: a.contentDepth
|
|
1711
1721
|
});
|
|
1712
1722
|
a = null;
|
|
1713
1723
|
}
|
|
1714
|
-
|
|
1724
|
+
Tt.has(t.type) ? (i++, a = {
|
|
1715
1725
|
point: t.endOffset,
|
|
1716
1726
|
contentDepth: i,
|
|
1717
1727
|
kind: "opener"
|
|
1718
|
-
}) :
|
|
1728
|
+
}) : Et.has(t.type) ? (i = Math.max(0, i - 1), c || n.push({
|
|
1719
1729
|
point: t.offset,
|
|
1720
1730
|
contentDepth: i
|
|
1721
1731
|
})) : t.type === "COMMA" && (a = {
|
|
@@ -1730,23 +1740,23 @@ function St(e) {
|
|
|
1730
1740
|
contentDepth: i
|
|
1731
1741
|
}), n;
|
|
1732
1742
|
}
|
|
1733
|
-
function
|
|
1743
|
+
function St(e) {
|
|
1734
1744
|
let n = [], r = new t(e), i = 0;
|
|
1735
1745
|
for (;;) {
|
|
1736
1746
|
let t = r.consume();
|
|
1737
1747
|
if (t.type === "EOF") break;
|
|
1738
|
-
if (
|
|
1739
|
-
else if (
|
|
1748
|
+
if (Tt.has(t.type)) i++;
|
|
1749
|
+
else if (Et.has(t.type)) i = Math.max(0, i - 1);
|
|
1740
1750
|
else if (t.type !== "COMMA") {
|
|
1741
1751
|
if (t.type === "TSTR") {
|
|
1742
1752
|
let r = e.slice(t.offset, t.endOffset);
|
|
1743
|
-
for (let e of
|
|
1753
|
+
for (let e of Ct(r)) n.push({
|
|
1744
1754
|
point: t.offset + e,
|
|
1745
1755
|
contentDepth: i + 1
|
|
1746
1756
|
});
|
|
1747
1757
|
} else if (t.type === "RAWSTRING") {
|
|
1748
1758
|
let r = e.slice(t.offset, t.endOffset);
|
|
1749
|
-
for (let { point: e } of
|
|
1759
|
+
for (let { point: e } of bt(r, 0)) n.push({
|
|
1750
1760
|
point: t.offset + e,
|
|
1751
1761
|
contentDepth: i + 1
|
|
1752
1762
|
});
|
|
@@ -1755,7 +1765,7 @@ function Ct(e) {
|
|
|
1755
1765
|
}
|
|
1756
1766
|
return n;
|
|
1757
1767
|
}
|
|
1758
|
-
function
|
|
1768
|
+
function Ct(e) {
|
|
1759
1769
|
let t = [], n = 1, r = e.length - 1;
|
|
1760
1770
|
for (; n < r;) {
|
|
1761
1771
|
let r = e[n];
|
|
@@ -1771,24 +1781,24 @@ function wt(e) {
|
|
|
1771
1781
|
}
|
|
1772
1782
|
return t;
|
|
1773
1783
|
}
|
|
1774
|
-
var
|
|
1784
|
+
var wt = new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Tt = new Set([
|
|
1775
1785
|
"LBRACKET",
|
|
1776
1786
|
"LBRACE",
|
|
1777
1787
|
"LPAREN",
|
|
1778
1788
|
"LT_LT"
|
|
1779
|
-
]),
|
|
1789
|
+
]), Et = new Set([
|
|
1780
1790
|
"RBRACKET",
|
|
1781
1791
|
"RBRACE",
|
|
1782
1792
|
"RPAREN",
|
|
1783
1793
|
"GT_GT"
|
|
1784
1794
|
]);
|
|
1785
|
-
function
|
|
1795
|
+
function Dt(e, t, n) {
|
|
1786
1796
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
1787
1797
|
}
|
|
1788
|
-
function
|
|
1798
|
+
function Ot(e, t, n) {
|
|
1789
1799
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
1790
1800
|
}
|
|
1791
|
-
function
|
|
1801
|
+
function kt(e, t) {
|
|
1792
1802
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
1793
1803
|
if (n.length === 0) return [{
|
|
1794
1804
|
text: e,
|
|
@@ -1806,7 +1816,7 @@ function At(e, t) {
|
|
|
1806
1816
|
}
|
|
1807
1817
|
//#endregion
|
|
1808
1818
|
//#region src/extensions/dt.ts
|
|
1809
|
-
function
|
|
1819
|
+
function B(e) {
|
|
1810
1820
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
1811
1821
|
let t = Math.round(e * 1e3);
|
|
1812
1822
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -1814,17 +1824,17 @@ function z(e) {
|
|
|
1814
1824
|
for (; s.length < 3;) s += "0";
|
|
1815
1825
|
return `${i}.${s}Z`;
|
|
1816
1826
|
}
|
|
1817
|
-
var
|
|
1818
|
-
function
|
|
1827
|
+
var At = new TextDecoder("utf-8", { fatal: !0 });
|
|
1828
|
+
function jt(e) {
|
|
1819
1829
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
1820
1830
|
let t = e[0];
|
|
1821
|
-
if (t instanceof
|
|
1822
|
-
if (t instanceof
|
|
1831
|
+
if (t instanceof z) return t.value;
|
|
1832
|
+
if (t instanceof M) return At.decode(t.value);
|
|
1823
1833
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
1824
1834
|
}
|
|
1825
|
-
var
|
|
1826
|
-
function
|
|
1827
|
-
if (!
|
|
1835
|
+
var Mt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
1836
|
+
function Nt(e, t) {
|
|
1837
|
+
if (!Mt.test(e)) {
|
|
1828
1838
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
1829
1839
|
if (t) t(n);
|
|
1830
1840
|
else throw SyntaxError(n);
|
|
@@ -1835,93 +1845,93 @@ function Pt(e, t) {
|
|
|
1835
1845
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
1836
1846
|
if (i === void 0) {
|
|
1837
1847
|
let e = a / 1e3;
|
|
1838
|
-
return e >= 0 ? new
|
|
1848
|
+
return e >= 0 ? new Ft(BigInt(e)) : new It(BigInt(e));
|
|
1839
1849
|
}
|
|
1840
|
-
return new
|
|
1850
|
+
return new Lt(a / 1e3 + i);
|
|
1841
1851
|
}
|
|
1842
|
-
var
|
|
1852
|
+
var Pt = 1n, Ft = class extends O {
|
|
1843
1853
|
constructor(e, t) {
|
|
1844
1854
|
super(e, t);
|
|
1845
1855
|
}
|
|
1846
1856
|
_toCDN(e, t) {
|
|
1847
1857
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1848
|
-
let n =
|
|
1849
|
-
return `dt'${
|
|
1858
|
+
let n = b(e, this.encodingWidth, () => y(this.value));
|
|
1859
|
+
return `dt'${B(Number(this.value))}'${n}`;
|
|
1850
1860
|
}
|
|
1851
|
-
},
|
|
1861
|
+
}, It = class extends k {
|
|
1852
1862
|
constructor(e, t) {
|
|
1853
1863
|
super(e, t);
|
|
1854
1864
|
}
|
|
1855
1865
|
_toCDN(e, t) {
|
|
1856
1866
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1857
|
-
let n =
|
|
1858
|
-
return `dt'${
|
|
1867
|
+
let n = b(e, this.encodingWidth, () => y(this.argument));
|
|
1868
|
+
return `dt'${B(Number(this.value))}'${n}`;
|
|
1859
1869
|
}
|
|
1860
|
-
},
|
|
1870
|
+
}, Lt = class extends A {
|
|
1861
1871
|
constructor(e, t) {
|
|
1862
1872
|
super(e, t);
|
|
1863
1873
|
}
|
|
1864
1874
|
_toCDN(e, t) {
|
|
1865
1875
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1866
|
-
let n =
|
|
1867
|
-
return `dt'${
|
|
1876
|
+
let n = E(this.value), r = Ee(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
1877
|
+
return `dt'${B(this.value)}'${r}`;
|
|
1868
1878
|
}
|
|
1869
|
-
},
|
|
1879
|
+
}, Rt = class extends j {
|
|
1870
1880
|
constructor(e, t) {
|
|
1871
|
-
super(
|
|
1881
|
+
super(Pt, typeof e == "string" ? Nt(e) : e, t);
|
|
1872
1882
|
}
|
|
1873
1883
|
_toCDN(e, t) {
|
|
1874
1884
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1875
1885
|
let n = this.content;
|
|
1876
|
-
if (n instanceof
|
|
1886
|
+
if (n instanceof A ? n.precision !== void 0 && n.precision !== E(n.value) : n.encodingWidth !== void 0) return super._toCDN({
|
|
1877
1887
|
...e,
|
|
1878
1888
|
appStrings: !1
|
|
1879
1889
|
}, t);
|
|
1880
|
-
let r = n instanceof
|
|
1881
|
-
return `DT'${
|
|
1890
|
+
let r = n instanceof A ? n.value : Number(n.value), i = b(e, this.encodingWidth, () => y(Pt));
|
|
1891
|
+
return `DT'${B(r)}'${i}`;
|
|
1882
1892
|
}
|
|
1883
|
-
},
|
|
1893
|
+
}, zt = class extends Rt {
|
|
1884
1894
|
constructor(e, t) {
|
|
1885
1895
|
super(e, t);
|
|
1886
1896
|
}
|
|
1887
1897
|
_toJS(e) {
|
|
1888
|
-
let t = this.content, n = t instanceof
|
|
1898
|
+
let t = this.content, n = t instanceof A ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
1889
1899
|
return new Date(n);
|
|
1890
1900
|
}
|
|
1891
1901
|
};
|
|
1892
|
-
function
|
|
1902
|
+
function Bt(e) {
|
|
1893
1903
|
let t = e?.jsDate ?? !1;
|
|
1894
1904
|
function n(e) {
|
|
1895
|
-
return t ? new
|
|
1905
|
+
return t ? new zt(e) : new Rt(e);
|
|
1896
1906
|
}
|
|
1897
1907
|
let r = {
|
|
1898
1908
|
appStringPrefixes: ["dt", "DT"],
|
|
1899
|
-
tagNumbers: [
|
|
1909
|
+
tagNumbers: [Pt],
|
|
1900
1910
|
parseAppString(e, t, r) {
|
|
1901
|
-
return e === "DT" ? n(t) :
|
|
1911
|
+
return e === "DT" ? n(t) : Nt(t, r);
|
|
1902
1912
|
},
|
|
1903
1913
|
parseAppSequence(e, t, r) {
|
|
1904
|
-
let i =
|
|
1905
|
-
return e === "DT" ? n(i) :
|
|
1914
|
+
let i = jt(t);
|
|
1915
|
+
return e === "DT" ? n(i) : Nt(i, r);
|
|
1906
1916
|
},
|
|
1907
1917
|
parseTag(e, n) {
|
|
1908
1918
|
if (e !== 1n) return;
|
|
1909
1919
|
let r;
|
|
1910
|
-
if (n instanceof
|
|
1911
|
-
else if (n instanceof
|
|
1912
|
-
else if (n instanceof
|
|
1920
|
+
if (n instanceof O) r = new Ft(n.value, { encodingWidth: n.encodingWidth });
|
|
1921
|
+
else if (n instanceof k) r = new It(n.value, { encodingWidth: n.encodingWidth });
|
|
1922
|
+
else if (n instanceof A) r = new Lt(n.value), n.precision !== void 0 && (r.precision = n.precision);
|
|
1913
1923
|
else return;
|
|
1914
|
-
return r.start = n.start, r.end = n.end, t ? new
|
|
1924
|
+
return r.start = n.start, r.end = n.end, t ? new zt(r) : new Rt(r);
|
|
1915
1925
|
}
|
|
1916
1926
|
};
|
|
1917
1927
|
return t && (r.fromJS = (e, t) => {
|
|
1918
|
-
if (e instanceof Date) return new
|
|
1928
|
+
if (e instanceof Date) return new zt(B(e.getTime() / 1e3));
|
|
1919
1929
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
1920
1930
|
}
|
|
1921
|
-
var
|
|
1931
|
+
var Vt = Bt(), Ht = Bt({ jsDate: !0 });
|
|
1922
1932
|
//#endregion
|
|
1923
1933
|
//#region src/utils/ip.ts
|
|
1924
|
-
function
|
|
1934
|
+
function Ut(e) {
|
|
1925
1935
|
let t = e.split(".");
|
|
1926
1936
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
1927
1937
|
let n = new Uint8Array(4);
|
|
@@ -1934,11 +1944,11 @@ function Wt(e) {
|
|
|
1934
1944
|
}
|
|
1935
1945
|
return n;
|
|
1936
1946
|
}
|
|
1937
|
-
function
|
|
1947
|
+
function Wt(e) {
|
|
1938
1948
|
let t = new Uint8Array(16);
|
|
1939
1949
|
if (e === "::") return t;
|
|
1940
1950
|
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 =
|
|
1951
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Ut(i[2]));
|
|
1942
1952
|
let a = n.split("::");
|
|
1943
1953
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
1944
1954
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -1955,11 +1965,11 @@ function Gt(e) {
|
|
|
1955
1965
|
}
|
|
1956
1966
|
return r && t.set(r, 12), t;
|
|
1957
1967
|
}
|
|
1958
|
-
function
|
|
1968
|
+
function Gt(e) {
|
|
1959
1969
|
return Array.from(e).join(".");
|
|
1960
1970
|
}
|
|
1961
|
-
function
|
|
1962
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
1971
|
+
function Kt(e) {
|
|
1972
|
+
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
1973
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
1964
1974
|
let i = -1, a = 0, o = 0;
|
|
1965
1975
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -1973,29 +1983,29 @@ function qt(e) {
|
|
|
1973
1983
|
}
|
|
1974
1984
|
//#endregion
|
|
1975
1985
|
//#region src/extensions/ip.ts
|
|
1976
|
-
var
|
|
1977
|
-
function
|
|
1986
|
+
var qt = "ip", V = "IP", H = 52n, Jt = 54n, Yt = new TextDecoder("utf-8", { fatal: !0 });
|
|
1987
|
+
function Xt(e) {
|
|
1978
1988
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
1979
1989
|
let t = e[0];
|
|
1980
|
-
if (t instanceof
|
|
1981
|
-
if (t instanceof
|
|
1990
|
+
if (t instanceof z) return t.value;
|
|
1991
|
+
if (t instanceof M) return Yt.decode(t.value);
|
|
1982
1992
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
1983
1993
|
}
|
|
1984
|
-
function
|
|
1994
|
+
function Zt(e) {
|
|
1985
1995
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
1986
|
-
bytes:
|
|
1996
|
+
bytes: Ut(e),
|
|
1987
1997
|
isV4: !0
|
|
1988
1998
|
} : {
|
|
1989
|
-
bytes:
|
|
1999
|
+
bytes: Wt(e),
|
|
1990
2000
|
isV4: !1
|
|
1991
2001
|
};
|
|
1992
2002
|
}
|
|
1993
|
-
function
|
|
1994
|
-
if (e.length === 4) return
|
|
1995
|
-
if (e.length === 16) return
|
|
2003
|
+
function Qt(e) {
|
|
2004
|
+
if (e.length === 4) return Gt(e);
|
|
2005
|
+
if (e.length === 16) return Kt(e);
|
|
1996
2006
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
1997
2007
|
}
|
|
1998
|
-
function
|
|
2008
|
+
function $t(e, t) {
|
|
1999
2009
|
let n = new Uint8Array(e.length);
|
|
2000
2010
|
n.set(e);
|
|
2001
2011
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2005,86 +2015,86 @@ function en(e, t) {
|
|
|
2005
2015
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2006
2016
|
return n.slice(0, a);
|
|
2007
2017
|
}
|
|
2008
|
-
function
|
|
2018
|
+
function en(e, t) {
|
|
2009
2019
|
let n = new Uint8Array(t);
|
|
2010
2020
|
return n.set(e), n;
|
|
2011
2021
|
}
|
|
2012
|
-
var
|
|
2022
|
+
var tn = class extends M {
|
|
2013
2023
|
_toCDN(e, t) {
|
|
2014
2024
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2015
|
-
let n =
|
|
2016
|
-
return `${
|
|
2025
|
+
let n = b(e, this.encodingWidth, () => y(BigInt(this.value.length)));
|
|
2026
|
+
return `${qt}'${Qt(this.value)}'${n}`;
|
|
2017
2027
|
}
|
|
2018
|
-
},
|
|
2028
|
+
}, nn = class extends F {
|
|
2019
2029
|
_isV4;
|
|
2020
2030
|
constructor(e, t, n) {
|
|
2021
|
-
super([new
|
|
2031
|
+
super([new O(BigInt(e)), new M(t)]), this._isV4 = n;
|
|
2022
2032
|
}
|
|
2023
2033
|
_toCDN(e, t) {
|
|
2024
2034
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2025
2035
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2026
|
-
return `${
|
|
2036
|
+
return `${qt}'${Qt(en(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2027
2037
|
}
|
|
2028
|
-
},
|
|
2038
|
+
}, rn = class extends j {
|
|
2029
2039
|
constructor(e, t) {
|
|
2030
2040
|
super(e, t);
|
|
2031
2041
|
}
|
|
2032
2042
|
_toCDN(e, t) {
|
|
2033
2043
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2034
|
-
let n = this.tag ===
|
|
2035
|
-
if (r instanceof
|
|
2044
|
+
let n = this.tag === H ? 4 : 16, r = this.content;
|
|
2045
|
+
if (r instanceof M) {
|
|
2036
2046
|
if (r.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2037
|
-
let n =
|
|
2038
|
-
return `${
|
|
2047
|
+
let n = b(e, this.encodingWidth, () => y(this.tag));
|
|
2048
|
+
return `${V}'${Qt(r.value)}'${n}`;
|
|
2039
2049
|
}
|
|
2040
|
-
if (r instanceof
|
|
2050
|
+
if (r instanceof F && r.items.length === 2 && r.items[0] instanceof O && r.items[1] instanceof M) {
|
|
2041
2051
|
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 `${
|
|
2052
|
+
let i = Number(r.items[0].value), a = en(r.items[1].value, n), o = b(e, this.encodingWidth, () => y(this.tag));
|
|
2053
|
+
return `${V}'${Qt(a)}/${i}'${o}`;
|
|
2044
2054
|
}
|
|
2045
2055
|
return super._toCDN(e, t);
|
|
2046
2056
|
}
|
|
2047
2057
|
};
|
|
2048
|
-
function
|
|
2058
|
+
function an(e, t) {
|
|
2049
2059
|
let n = t.indexOf("/");
|
|
2050
2060
|
if (n === -1) {
|
|
2051
|
-
let { bytes: n, isV4: r } =
|
|
2052
|
-
return e ===
|
|
2061
|
+
let { bytes: n, isV4: r } = Zt(t);
|
|
2062
|
+
return e === V ? new rn(r ? H : Jt, new M(n)) : new tn(n);
|
|
2053
2063
|
}
|
|
2054
2064
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2055
2065
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2056
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2066
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = Zt(r), c = s ? 32 : 128;
|
|
2057
2067
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2058
|
-
let l =
|
|
2059
|
-
return e ===
|
|
2068
|
+
let l = $t(o, a);
|
|
2069
|
+
return e === V ? new rn(s ? H : Jt, new F([new O(BigInt(a)), new M(l)])) : new nn(a, l, s);
|
|
2060
2070
|
}
|
|
2061
|
-
var
|
|
2062
|
-
appStringPrefixes: [
|
|
2063
|
-
tagNumbers: [
|
|
2071
|
+
var on = {
|
|
2072
|
+
appStringPrefixes: [qt, V],
|
|
2073
|
+
tagNumbers: [H, Jt],
|
|
2064
2074
|
parseAppString(e, t) {
|
|
2065
|
-
return
|
|
2075
|
+
return an(e, t);
|
|
2066
2076
|
},
|
|
2067
2077
|
parseAppSequence(e, t) {
|
|
2068
|
-
return
|
|
2078
|
+
return an(e, Xt(t));
|
|
2069
2079
|
},
|
|
2070
2080
|
parseTag(e, t) {
|
|
2071
|
-
if (!(e !==
|
|
2081
|
+
if (!(e !== H && e !== Jt) && (t instanceof M || t instanceof F)) return new rn(e, t);
|
|
2072
2082
|
}
|
|
2073
|
-
},
|
|
2074
|
-
tagNumbers: [
|
|
2083
|
+
}, sn = 18446744073709551615n, cn = -18446744073709551616n, ln = {
|
|
2084
|
+
tagNumbers: [Ke, qe],
|
|
2075
2085
|
parseTag(e, t) {
|
|
2076
|
-
if (t instanceof
|
|
2086
|
+
if (t instanceof M) {
|
|
2077
2087
|
if (e === 2n) {
|
|
2078
|
-
let e =
|
|
2079
|
-
return e >
|
|
2088
|
+
let e = Ze(t.value);
|
|
2089
|
+
return e > sn ? new Qe(e) : void 0;
|
|
2080
2090
|
}
|
|
2081
2091
|
if (e === 3n) {
|
|
2082
|
-
let e = -1n -
|
|
2083
|
-
return e <
|
|
2092
|
+
let e = -1n - Ze(t.value);
|
|
2093
|
+
return e < cn ? new $e(e) : void 0;
|
|
2084
2094
|
}
|
|
2085
2095
|
}
|
|
2086
2096
|
}
|
|
2087
|
-
},
|
|
2097
|
+
}, un = "cri", dn = "CRI", fn = 99n, pn = new Map([
|
|
2088
2098
|
["coap", -1n],
|
|
2089
2099
|
["coaps", -2n],
|
|
2090
2100
|
["http", -3n],
|
|
@@ -2095,47 +2105,47 @@ var sn = {
|
|
|
2095
2105
|
["coaps+tcp", -8n],
|
|
2096
2106
|
["coap+ws", -25n],
|
|
2097
2107
|
["coaps+ws", -26n]
|
|
2098
|
-
]),
|
|
2099
|
-
function
|
|
2108
|
+
]), mn = new Map([...pn.entries()].map(([e, t]) => [t, e]));
|
|
2109
|
+
function U(e) {
|
|
2100
2110
|
try {
|
|
2101
2111
|
return decodeURIComponent(e);
|
|
2102
2112
|
} catch {
|
|
2103
2113
|
return e;
|
|
2104
2114
|
}
|
|
2105
2115
|
}
|
|
2106
|
-
var
|
|
2107
|
-
function
|
|
2108
|
-
return Array.from(
|
|
2116
|
+
var hn = new TextEncoder(), gn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2117
|
+
function _n(e) {
|
|
2118
|
+
return Array.from(hn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2109
2119
|
}
|
|
2110
|
-
function
|
|
2120
|
+
function W(e, t) {
|
|
2111
2121
|
let n = "";
|
|
2112
|
-
for (let r of e) n += t(r) ? r :
|
|
2122
|
+
for (let r of e) n += t(r) ? r : _n(r);
|
|
2113
2123
|
return n;
|
|
2114
2124
|
}
|
|
2115
|
-
function
|
|
2125
|
+
function vn(e) {
|
|
2116
2126
|
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2117
2127
|
}
|
|
2118
|
-
function
|
|
2128
|
+
function yn(e) {
|
|
2119
2129
|
return /[!$&'()*+,;=]/.test(e);
|
|
2120
2130
|
}
|
|
2131
|
+
function bn(e) {
|
|
2132
|
+
return vn(e) || yn(e) || e === ":" || e === "@";
|
|
2133
|
+
}
|
|
2121
2134
|
function xn(e) {
|
|
2122
|
-
return
|
|
2135
|
+
return (bn(e) || e === "/" || e === "?") && e !== "&";
|
|
2123
2136
|
}
|
|
2124
2137
|
function Sn(e) {
|
|
2125
|
-
return (
|
|
2138
|
+
return bn(e) || e === "/" || e === "?";
|
|
2126
2139
|
}
|
|
2127
2140
|
function Cn(e) {
|
|
2128
|
-
return
|
|
2141
|
+
return vn(e) || yn(e) || e === ":";
|
|
2129
2142
|
}
|
|
2130
2143
|
function wn(e) {
|
|
2131
|
-
return
|
|
2144
|
+
return vn(e) || yn(e);
|
|
2132
2145
|
}
|
|
2133
2146
|
function Tn(e) {
|
|
2134
|
-
return yn(e) || bn(e);
|
|
2135
|
-
}
|
|
2136
|
-
function En(e) {
|
|
2137
2147
|
let t = [], n = e, r = n.indexOf("@");
|
|
2138
|
-
r >= 0 && (t.push(
|
|
2148
|
+
r >= 0 && (t.push(L.FALSE), t.push(new z(U(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2139
2149
|
let i, a = null;
|
|
2140
2150
|
if (n.startsWith("[")) {
|
|
2141
2151
|
let e = n.indexOf("]");
|
|
@@ -2144,190 +2154,190 @@ function En(e) {
|
|
|
2144
2154
|
let r = n.slice(e + 1);
|
|
2145
2155
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2146
2156
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2147
|
-
t.push(new
|
|
2157
|
+
t.push(new M(Wt(i)));
|
|
2148
2158
|
} else {
|
|
2149
2159
|
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
|
|
2160
|
+
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)));
|
|
2161
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new z(e));
|
|
2152
2162
|
}
|
|
2153
2163
|
if (a !== null && a !== "") {
|
|
2154
2164
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2155
2165
|
let e = parseInt(a, 10);
|
|
2156
2166
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2157
|
-
t.push(new
|
|
2167
|
+
t.push(new O(BigInt(e)));
|
|
2158
2168
|
}
|
|
2159
|
-
return new
|
|
2169
|
+
return new F(t);
|
|
2160
2170
|
}
|
|
2161
|
-
function
|
|
2171
|
+
function En(e) {
|
|
2162
2172
|
let t = e.items, n = 0, r = "";
|
|
2163
|
-
if (n < t.length && t[n] instanceof
|
|
2173
|
+
if (n < t.length && t[n] instanceof L && t[n].value === 20) {
|
|
2164
2174
|
n++;
|
|
2165
2175
|
let e = t[n++];
|
|
2166
|
-
r +=
|
|
2176
|
+
r += W(e.value, Cn) + "@";
|
|
2167
2177
|
}
|
|
2168
2178
|
if (n >= t.length) return r;
|
|
2169
2179
|
let i = t[n];
|
|
2170
|
-
if (i instanceof
|
|
2180
|
+
if (i instanceof M) {
|
|
2171
2181
|
n++;
|
|
2172
2182
|
let { length: e } = i.value;
|
|
2173
|
-
if (e === 4) r +=
|
|
2174
|
-
else if (e === 16) r += "[" +
|
|
2183
|
+
if (e === 4) r += Gt(i.value);
|
|
2184
|
+
else if (e === 16) r += "[" + Kt(i.value) + "]";
|
|
2175
2185
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2176
|
-
n < t.length && t[n] instanceof
|
|
2186
|
+
n < t.length && t[n] instanceof z && (r += `%25${W(t[n++].value, wn)}`);
|
|
2177
2187
|
} else {
|
|
2178
2188
|
let e = [];
|
|
2179
|
-
for (; n < t.length && t[n] instanceof
|
|
2189
|
+
for (; n < t.length && t[n] instanceof z;) e.push(W(t[n++].value, wn));
|
|
2180
2190
|
r += e.join(".");
|
|
2181
2191
|
}
|
|
2182
|
-
return n < t.length && t[n] instanceof
|
|
2192
|
+
return n < t.length && t[n] instanceof O && (r += ":" + t[n].value.toString()), r;
|
|
2183
2193
|
}
|
|
2184
|
-
function
|
|
2194
|
+
function Dn(e) {
|
|
2185
2195
|
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:
|
|
2196
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new z(U(e)))) : (r = t, i = []), {
|
|
2197
|
+
authority: Tn(r),
|
|
2188
2198
|
pathSegments: i
|
|
2189
2199
|
};
|
|
2190
2200
|
}
|
|
2191
|
-
function
|
|
2201
|
+
function On(e) {
|
|
2192
2202
|
let t = e, n = null, r = t.indexOf("#");
|
|
2193
|
-
r >= 0 && (n =
|
|
2203
|
+
r >= 0 && (n = U(t.slice(r + 1)), t = t.slice(0, r));
|
|
2194
2204
|
let i = null, a = t.indexOf("?");
|
|
2195
2205
|
if (a >= 0) {
|
|
2196
2206
|
let e = t.slice(a + 1);
|
|
2197
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2207
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new z(U(e)));
|
|
2198
2208
|
}
|
|
2199
2209
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2200
2210
|
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
|
|
2211
|
+
let e = s[1].toLowerCase(), t = s[2], n = pn.get(e);
|
|
2212
|
+
if (o.push(n === void 0 ? new z(e) : new k(n)), t.startsWith("//")) {
|
|
2213
|
+
let { authority: e, pathSegments: n } = Dn(t);
|
|
2214
|
+
o.push(e, new F(n));
|
|
2205
2215
|
} else if (t.startsWith("/")) {
|
|
2206
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2207
|
-
o.push(
|
|
2216
|
+
let e = t.slice(1).split("/").map((e) => new z(U(e)));
|
|
2217
|
+
o.push(L.NULL, new F(e));
|
|
2208
2218
|
} else {
|
|
2209
|
-
let e = t.split("/").map((e) => new
|
|
2210
|
-
o.push(
|
|
2219
|
+
let e = t.split("/").map((e) => new z(U(e)));
|
|
2220
|
+
o.push(L.TRUE, new F(e));
|
|
2211
2221
|
}
|
|
2212
2222
|
} else if (t.startsWith("//")) {
|
|
2213
|
-
let { authority: e, pathSegments: n } =
|
|
2214
|
-
o.push(
|
|
2223
|
+
let { authority: e, pathSegments: n } = Dn(t);
|
|
2224
|
+
o.push(L.FALSE, e, new F(n));
|
|
2215
2225
|
} else if (t.startsWith("/")) {
|
|
2216
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2217
|
-
o.push(
|
|
2218
|
-
} else if (t === "") o.push(new
|
|
2226
|
+
let e = t.slice(1).split("/").map((e) => new z(U(e)));
|
|
2227
|
+
o.push(L.TRUE, new F(e));
|
|
2228
|
+
} else if (t === "") o.push(new O(0n));
|
|
2219
2229
|
else {
|
|
2220
2230
|
let n = 1n, r = t, i = !1;
|
|
2221
2231
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2222
2232
|
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
|
|
2233
|
+
let a = r === "" ? [] : r.split("/").map((e) => new z(U(e)));
|
|
2234
|
+
o.push(new O(n), new F(a));
|
|
2225
2235
|
}
|
|
2226
|
-
if (i !== null && o.push(new
|
|
2236
|
+
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
2237
|
let e = o[o.length - 1];
|
|
2228
|
-
e instanceof
|
|
2238
|
+
e instanceof F && e.items.length === 0 && o.pop();
|
|
2229
2239
|
}
|
|
2230
|
-
return o.length === 1 && o[0] instanceof
|
|
2240
|
+
return o.length === 1 && o[0] instanceof O && o[0].value === 0n ? [] : o;
|
|
2231
2241
|
}
|
|
2232
|
-
function
|
|
2242
|
+
function G(e, t) {
|
|
2233
2243
|
let n = t, r = "";
|
|
2234
2244
|
if (n < e.length) {
|
|
2235
2245
|
let t = e[n];
|
|
2236
|
-
if (t instanceof
|
|
2246
|
+
if (t instanceof F) {
|
|
2237
2247
|
if (n++, t.items.length > 0) {
|
|
2238
2248
|
let e = t.items.map((e) => {
|
|
2239
|
-
if (!(e instanceof
|
|
2240
|
-
return
|
|
2249
|
+
if (!(e instanceof z)) throw Error("cri: query item must be a text string");
|
|
2250
|
+
return W(e.value, xn);
|
|
2241
2251
|
});
|
|
2242
2252
|
r += "?" + e.join("&");
|
|
2243
2253
|
}
|
|
2244
|
-
} else t instanceof
|
|
2254
|
+
} else t instanceof L && t.value === 22 && n++;
|
|
2245
2255
|
}
|
|
2246
|
-
return n < e.length && e[n] instanceof
|
|
2256
|
+
return n < e.length && e[n] instanceof z && (r += "#" + W(e[n].value, Sn)), r;
|
|
2247
2257
|
}
|
|
2248
|
-
function
|
|
2258
|
+
function kn(e) {
|
|
2249
2259
|
return e.items.map((e) => {
|
|
2250
|
-
if (!(e instanceof
|
|
2251
|
-
return
|
|
2260
|
+
if (!(e instanceof z)) throw Error("cri: path segment must be a text string");
|
|
2261
|
+
return W(e.value, bn);
|
|
2252
2262
|
});
|
|
2253
2263
|
}
|
|
2254
2264
|
function An(e) {
|
|
2255
2265
|
if (e.length === 0) return "";
|
|
2256
2266
|
let t = 0, n = e[t++];
|
|
2257
|
-
if (n instanceof
|
|
2267
|
+
if (n instanceof k || n instanceof z) {
|
|
2258
2268
|
let r;
|
|
2259
|
-
if (n instanceof
|
|
2260
|
-
let e =
|
|
2269
|
+
if (n instanceof k) {
|
|
2270
|
+
let e = mn.get(n.value);
|
|
2261
2271
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2262
2272
|
r = e + ":";
|
|
2263
2273
|
} else r = n.value + ":";
|
|
2264
2274
|
if (t >= e.length) return r;
|
|
2265
2275
|
let i = e[t++], a = "", o = !1;
|
|
2266
|
-
if (i instanceof
|
|
2267
|
-
else if (i instanceof
|
|
2276
|
+
if (i instanceof F) a = "//" + En(i), o = !0;
|
|
2277
|
+
else if (i instanceof L) if (i.value === 22) o = !0;
|
|
2268
2278
|
else if (i.value === 21) o = !1;
|
|
2269
2279
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2270
2280
|
else throw Error("cri: unexpected type for authority element");
|
|
2271
2281
|
let s = "";
|
|
2272
|
-
if (t < e.length && e[t] instanceof
|
|
2282
|
+
if (t < e.length && e[t] instanceof F) {
|
|
2273
2283
|
let n = e[t++];
|
|
2274
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
2284
|
+
n.items.length > 0 && (s = (o ? "/" : "") + kn(n).join("/"));
|
|
2275
2285
|
}
|
|
2276
|
-
return r + a + s +
|
|
2286
|
+
return r + a + s + G(e, t);
|
|
2277
2287
|
}
|
|
2278
|
-
if (n instanceof
|
|
2279
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2280
|
-
let n =
|
|
2281
|
-
if (t < e.length && e[t] instanceof
|
|
2288
|
+
if (n instanceof L && n.value === 20) {
|
|
2289
|
+
if (t >= e.length || !(e[t] instanceof F)) throw Error("cri: network-path reference requires an authority array");
|
|
2290
|
+
let n = En(e[t++]), r = "";
|
|
2291
|
+
if (t < e.length && e[t] instanceof F) {
|
|
2282
2292
|
let n = e[t++];
|
|
2283
|
-
n.items.length > 0 && (r = "/" +
|
|
2293
|
+
n.items.length > 0 && (r = "/" + kn(n).join("/"));
|
|
2284
2294
|
}
|
|
2285
|
-
return "//" + n + r +
|
|
2295
|
+
return "//" + n + r + G(e, t);
|
|
2286
2296
|
}
|
|
2287
|
-
if (n instanceof
|
|
2297
|
+
if (n instanceof L && n.value === 21) {
|
|
2288
2298
|
let n = "/";
|
|
2289
|
-
if (t < e.length && e[t] instanceof
|
|
2299
|
+
if (t < e.length && e[t] instanceof F) {
|
|
2290
2300
|
let r = e[t++];
|
|
2291
|
-
n = "/" +
|
|
2301
|
+
n = "/" + kn(r).join("/");
|
|
2292
2302
|
}
|
|
2293
|
-
return n +
|
|
2303
|
+
return n + G(e, t);
|
|
2294
2304
|
}
|
|
2295
|
-
if (n instanceof
|
|
2305
|
+
if (n instanceof O) {
|
|
2296
2306
|
let r = n.value;
|
|
2297
|
-
if (r === 0n) return
|
|
2307
|
+
if (r === 0n) return G(e, t);
|
|
2298
2308
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2299
|
-
if (t < e.length && e[t] instanceof
|
|
2309
|
+
if (t < e.length && e[t] instanceof F) {
|
|
2300
2310
|
let n = e[t++];
|
|
2301
2311
|
if (n.items.length > 0) {
|
|
2302
|
-
let e =
|
|
2312
|
+
let e = kn(n);
|
|
2303
2313
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2304
2314
|
} else a = i === "" ? "./" : i;
|
|
2305
2315
|
} else a = i === "" ? "./" : i;
|
|
2306
|
-
return a +
|
|
2316
|
+
return a + G(e, t);
|
|
2307
2317
|
}
|
|
2308
2318
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2309
2319
|
}
|
|
2310
|
-
var jn = class extends
|
|
2320
|
+
var jn = class extends F {
|
|
2311
2321
|
_toCDN(e, t) {
|
|
2312
2322
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2313
2323
|
try {
|
|
2314
|
-
let t =
|
|
2315
|
-
return `${
|
|
2324
|
+
let t = b(e, this.encodingWidth, () => y(BigInt(this.items.length)));
|
|
2325
|
+
return `${un}'${An(this.items)}'${t}`;
|
|
2316
2326
|
} catch {
|
|
2317
2327
|
return super._toCDN(e, t);
|
|
2318
2328
|
}
|
|
2319
2329
|
}
|
|
2320
|
-
}, Mn = class extends
|
|
2330
|
+
}, Mn = class extends j {
|
|
2321
2331
|
constructor(e) {
|
|
2322
|
-
super(
|
|
2332
|
+
super(fn, e);
|
|
2323
2333
|
}
|
|
2324
2334
|
_toCDN(e, t) {
|
|
2325
2335
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2326
2336
|
try {
|
|
2327
2337
|
let n = this.content;
|
|
2328
2338
|
if (n.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2329
|
-
let r =
|
|
2330
|
-
return `${
|
|
2339
|
+
let r = b(e, this.encodingWidth, () => y(fn));
|
|
2340
|
+
return `${dn}'${An(n.items)}'${r}`;
|
|
2331
2341
|
} catch {
|
|
2332
2342
|
return super._toCDN(e, t);
|
|
2333
2343
|
}
|
|
@@ -2336,17 +2346,17 @@ var jn = class extends P {
|
|
|
2336
2346
|
function Nn(e) {
|
|
2337
2347
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2338
2348
|
let t = e[0];
|
|
2339
|
-
if (t instanceof
|
|
2340
|
-
if (t instanceof
|
|
2349
|
+
if (t instanceof z) return t.value;
|
|
2350
|
+
if (t instanceof M) return gn.decode(t.value);
|
|
2341
2351
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2342
2352
|
}
|
|
2343
2353
|
function Pn(e, t) {
|
|
2344
|
-
let n = new jn(
|
|
2345
|
-
return e ===
|
|
2354
|
+
let n = new jn(On(t));
|
|
2355
|
+
return e === dn ? new Mn(n) : n;
|
|
2346
2356
|
}
|
|
2347
2357
|
var Fn = {
|
|
2348
|
-
appStringPrefixes: [
|
|
2349
|
-
tagNumbers: [
|
|
2358
|
+
appStringPrefixes: [un, dn],
|
|
2359
|
+
tagNumbers: [fn],
|
|
2350
2360
|
parseAppString(e, t) {
|
|
2351
2361
|
return Pn(e, t);
|
|
2352
2362
|
},
|
|
@@ -2354,7 +2364,7 @@ var Fn = {
|
|
|
2354
2364
|
return Pn(e, Nn(t));
|
|
2355
2365
|
},
|
|
2356
2366
|
parseTag(e, t) {
|
|
2357
|
-
if (e !== 99n || !(t instanceof
|
|
2367
|
+
if (e !== 99n || !(t instanceof F)) return;
|
|
2358
2368
|
let n = new jn(t.items, {
|
|
2359
2369
|
indefiniteLength: t.indefiniteLength,
|
|
2360
2370
|
encodingWidth: t.encodingWidth
|
|
@@ -2388,61 +2398,61 @@ function Rn(e, t, n) {
|
|
|
2388
2398
|
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
2399
|
return r;
|
|
2390
2400
|
}
|
|
2391
|
-
function
|
|
2401
|
+
function J(e, t) {
|
|
2392
2402
|
e.warnings ??= [], e.warnings.push(t);
|
|
2393
2403
|
}
|
|
2394
|
-
function
|
|
2404
|
+
function zn(e) {
|
|
2395
2405
|
let t = "";
|
|
2396
2406
|
for (let n of e) t += n.toString(16).padStart(2, "0");
|
|
2397
2407
|
return t;
|
|
2398
2408
|
}
|
|
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
|
|
2409
|
+
function Y(e) {
|
|
2410
|
+
if (e instanceof O) return ["u", String(e.value)];
|
|
2411
|
+
if (e instanceof k) return ["n", String(e.value)];
|
|
2412
|
+
if (e instanceof z) return ["t", e.value];
|
|
2413
|
+
if (e instanceof P) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2414
|
+
if (e instanceof M) return ["b", zn(e.value)];
|
|
2415
|
+
if (e instanceof N) {
|
|
2406
2416
|
let t = "";
|
|
2407
|
-
for (let n of e.chunks) t +=
|
|
2417
|
+
for (let n of e.chunks) t += zn(n.value);
|
|
2408
2418
|
return ["b", t];
|
|
2409
2419
|
}
|
|
2410
|
-
if (e instanceof
|
|
2411
|
-
if (e instanceof
|
|
2412
|
-
if (e instanceof
|
|
2413
|
-
if (e instanceof
|
|
2414
|
-
let t = e.entries.map(([e, t]) => [
|
|
2420
|
+
if (e instanceof A) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2421
|
+
if (e instanceof L) return ["s", e.value];
|
|
2422
|
+
if (e instanceof F) return ["A", e.items.map(Y)];
|
|
2423
|
+
if (e instanceof I) {
|
|
2424
|
+
let t = e.entries.map(([e, t]) => [Y(e), Y(t)]);
|
|
2415
2425
|
if (t.length <= 1) return ["M", t];
|
|
2416
2426
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2417
2427
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
2418
2428
|
}
|
|
2419
|
-
if (e instanceof
|
|
2429
|
+
if (e instanceof j) return [
|
|
2420
2430
|
"G",
|
|
2421
2431
|
String(e.tag),
|
|
2422
|
-
|
|
2432
|
+
Y(e.content)
|
|
2423
2433
|
];
|
|
2424
2434
|
let t = e.toCBOR(), n = "";
|
|
2425
2435
|
for (let e of t) n += e.toString(16).padStart(2, "0");
|
|
2426
2436
|
return ["c", n];
|
|
2427
2437
|
}
|
|
2428
|
-
function
|
|
2429
|
-
if (e instanceof
|
|
2430
|
-
if (e instanceof
|
|
2431
|
-
if (e instanceof
|
|
2432
|
-
if (e instanceof
|
|
2438
|
+
function Bn(e) {
|
|
2439
|
+
if (e instanceof O) return "u" + e.value;
|
|
2440
|
+
if (e instanceof k) return "n" + e.value;
|
|
2441
|
+
if (e instanceof z) return "t" + e.value;
|
|
2442
|
+
if (e instanceof P) {
|
|
2433
2443
|
let t = "t";
|
|
2434
2444
|
for (let n of e.chunks) t += n.value;
|
|
2435
2445
|
return t;
|
|
2436
2446
|
}
|
|
2437
|
-
if (e instanceof
|
|
2438
|
-
if (e instanceof
|
|
2447
|
+
if (e instanceof M) return "b" + zn(e.value);
|
|
2448
|
+
if (e instanceof N) {
|
|
2439
2449
|
let t = "b";
|
|
2440
|
-
for (let n of e.chunks) t +=
|
|
2450
|
+
for (let n of e.chunks) t += zn(n.value);
|
|
2441
2451
|
return t;
|
|
2442
2452
|
}
|
|
2443
|
-
return e instanceof
|
|
2453
|
+
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
2454
|
}
|
|
2445
|
-
function
|
|
2455
|
+
function X(e, t, n) {
|
|
2446
2456
|
if (n <= 23) return {
|
|
2447
2457
|
value: BigInt(n),
|
|
2448
2458
|
nextOffset: t
|
|
@@ -2467,14 +2477,14 @@ function Y(e, t, n) {
|
|
|
2467
2477
|
default: q(`reserved additional info value: ${n}`);
|
|
2468
2478
|
}
|
|
2469
2479
|
}
|
|
2470
|
-
function
|
|
2480
|
+
function Vn(e, t, n, r, i, a) {
|
|
2471
2481
|
let o = [], s = t;
|
|
2472
2482
|
for (;;) {
|
|
2473
2483
|
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
2474
2484
|
s++;
|
|
2475
2485
|
break;
|
|
2476
2486
|
}
|
|
2477
|
-
let t =
|
|
2487
|
+
let t = Z(e, s, n, r);
|
|
2478
2488
|
a(t.value) || q(`indefinite-length ${i} chunk must be a definite ${i}`), o.push(t.value), s = t.nextOffset;
|
|
2479
2489
|
}
|
|
2480
2490
|
return {
|
|
@@ -2482,55 +2492,55 @@ function Hn(e, t, n, r, i, a) {
|
|
|
2482
2492
|
nextOffset: s
|
|
2483
2493
|
};
|
|
2484
2494
|
}
|
|
2485
|
-
function
|
|
2486
|
-
let i =
|
|
2495
|
+
function Hn(e, t, n, r) {
|
|
2496
|
+
let i = Bn(e);
|
|
2487
2497
|
t.has(i) && n.push(Rn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
2488
2498
|
}
|
|
2489
|
-
function
|
|
2490
|
-
let i = t, a =
|
|
2499
|
+
function Z(e, t, n, r) {
|
|
2500
|
+
let i = t, a = Un(e, t, n, r);
|
|
2491
2501
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
2492
2502
|
}
|
|
2493
|
-
function
|
|
2503
|
+
function Un(e, t, n, r) {
|
|
2494
2504
|
t >= e.byteLength && q("unexpected end of input");
|
|
2495
2505
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
2496
2506
|
switch (a) {
|
|
2497
2507
|
case 0: {
|
|
2498
|
-
let { value: n, nextOffset: r } =
|
|
2508
|
+
let { value: n, nextOffset: r } = X(e, t, o);
|
|
2499
2509
|
return {
|
|
2500
|
-
value: new
|
|
2510
|
+
value: new O(n, { encodingWidth: K(o, n) }),
|
|
2501
2511
|
nextOffset: r
|
|
2502
2512
|
};
|
|
2503
2513
|
}
|
|
2504
2514
|
case 1: {
|
|
2505
|
-
let { value: n, nextOffset: r } =
|
|
2515
|
+
let { value: n, nextOffset: r } = X(e, t, o), i = K(o, n);
|
|
2506
2516
|
return {
|
|
2507
|
-
value: new
|
|
2517
|
+
value: new k(-1n - n, { encodingWidth: i }),
|
|
2508
2518
|
nextOffset: r
|
|
2509
2519
|
};
|
|
2510
2520
|
}
|
|
2511
2521
|
case 2: {
|
|
2512
2522
|
if (o === 31) {
|
|
2513
|
-
let { chunks: i, nextOffset: a } =
|
|
2523
|
+
let { chunks: i, nextOffset: a } = Vn(e, t, n, r, "byte string", (e) => e instanceof M);
|
|
2514
2524
|
return {
|
|
2515
|
-
value: new
|
|
2525
|
+
value: new N(i),
|
|
2516
2526
|
nextOffset: a
|
|
2517
2527
|
};
|
|
2518
2528
|
}
|
|
2519
|
-
let { value: i, nextOffset: a } =
|
|
2529
|
+
let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i);
|
|
2520
2530
|
return a + s > e.byteLength && q("byte string extends beyond input"), {
|
|
2521
|
-
value: new
|
|
2531
|
+
value: new M(new Uint8Array(e.buffer, e.byteOffset + a, s).slice(), { encodingWidth: c }),
|
|
2522
2532
|
nextOffset: a + s
|
|
2523
2533
|
};
|
|
2524
2534
|
}
|
|
2525
2535
|
case 3: {
|
|
2526
2536
|
if (o === 31) {
|
|
2527
|
-
let { chunks: i, nextOffset: a } =
|
|
2537
|
+
let { chunks: i, nextOffset: a } = Vn(e, t, n, r, "text string", (e) => e instanceof z);
|
|
2528
2538
|
return {
|
|
2529
|
-
value: new
|
|
2539
|
+
value: new P(i),
|
|
2530
2540
|
nextOffset: a
|
|
2531
2541
|
};
|
|
2532
2542
|
}
|
|
2533
|
-
let { value: i, nextOffset: a } =
|
|
2543
|
+
let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i);
|
|
2534
2544
|
a + s > e.byteLength && q("text string extends beyond input");
|
|
2535
2545
|
let l = new Uint8Array(e.buffer, e.byteOffset + a, s), u, d;
|
|
2536
2546
|
try {
|
|
@@ -2538,8 +2548,8 @@ function Wn(e, t, n, r) {
|
|
|
2538
2548
|
} catch {
|
|
2539
2549
|
d = Rn("invalid UTF-8 sequence in text string", a, n), u = Ln.decode(l);
|
|
2540
2550
|
}
|
|
2541
|
-
let f = new
|
|
2542
|
-
return d &&
|
|
2551
|
+
let f = new z(u, { encodingWidth: c });
|
|
2552
|
+
return d && J(f, d), {
|
|
2543
2553
|
value: f,
|
|
2544
2554
|
nextOffset: a + s
|
|
2545
2555
|
};
|
|
@@ -2552,21 +2562,21 @@ function Wn(e, t, n, r) {
|
|
|
2552
2562
|
a++;
|
|
2553
2563
|
break;
|
|
2554
2564
|
}
|
|
2555
|
-
let t =
|
|
2565
|
+
let t = Z(e, a, n, r);
|
|
2556
2566
|
i.push(t.value), a = t.nextOffset;
|
|
2557
2567
|
}
|
|
2558
2568
|
return {
|
|
2559
|
-
value: new
|
|
2569
|
+
value: new F(i, { indefiniteLength: !0 }),
|
|
2560
2570
|
nextOffset: a
|
|
2561
2571
|
};
|
|
2562
2572
|
}
|
|
2563
|
-
let { value: i, nextOffset: a } =
|
|
2573
|
+
let { value: i, nextOffset: a } = X(e, t, o), s = Number(i), c = K(o, i), l = [], u = a;
|
|
2564
2574
|
for (let t = 0; t < s; t++) {
|
|
2565
|
-
let t =
|
|
2575
|
+
let t = Z(e, u, n, r);
|
|
2566
2576
|
l.push(t.value), u = t.nextOffset;
|
|
2567
2577
|
}
|
|
2568
2578
|
return {
|
|
2569
|
-
value: new
|
|
2579
|
+
value: new F(l, { encodingWidth: c }),
|
|
2570
2580
|
nextOffset: u
|
|
2571
2581
|
};
|
|
2572
2582
|
}
|
|
@@ -2578,27 +2588,27 @@ function Wn(e, t, n, r) {
|
|
|
2578
2588
|
s++;
|
|
2579
2589
|
break;
|
|
2580
2590
|
}
|
|
2581
|
-
let t =
|
|
2582
|
-
|
|
2583
|
-
let c =
|
|
2591
|
+
let t = Z(e, s, n, r);
|
|
2592
|
+
Hn(t.value, a, o, n), s = t.nextOffset;
|
|
2593
|
+
let c = Z(e, s, n, r);
|
|
2584
2594
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2585
2595
|
}
|
|
2586
|
-
let c = new
|
|
2587
|
-
for (let e of o)
|
|
2596
|
+
let c = new I(i, { indefiniteLength: !0 });
|
|
2597
|
+
for (let e of o) J(c, e);
|
|
2588
2598
|
return {
|
|
2589
2599
|
value: c,
|
|
2590
2600
|
nextOffset: s
|
|
2591
2601
|
};
|
|
2592
2602
|
}
|
|
2593
|
-
let { value: i, nextOffset: a } =
|
|
2603
|
+
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
2604
|
for (let t = 0; t < s; t++) {
|
|
2595
|
-
let t =
|
|
2596
|
-
|
|
2597
|
-
let i =
|
|
2605
|
+
let t = Z(e, f, n, r);
|
|
2606
|
+
Hn(t.value, u, d, n), f = t.nextOffset;
|
|
2607
|
+
let i = Z(e, f, n, r);
|
|
2598
2608
|
f = i.nextOffset, l.push([t.value, i.value]);
|
|
2599
2609
|
}
|
|
2600
|
-
let p = new
|
|
2601
|
-
for (let e of d)
|
|
2610
|
+
let p = new I(l, { encodingWidth: c });
|
|
2611
|
+
for (let e of d) J(p, e);
|
|
2602
2612
|
return {
|
|
2603
2613
|
value: p,
|
|
2604
2614
|
nextOffset: f
|
|
@@ -2606,90 +2616,98 @@ function Wn(e, t, n, r) {
|
|
|
2606
2616
|
}
|
|
2607
2617
|
case 6: {
|
|
2608
2618
|
o === 31 && q("tags cannot use indefinite-length encoding");
|
|
2609
|
-
let { value: i, nextOffset: a } =
|
|
2619
|
+
let { value: i, nextOffset: a } = X(e, t, o), s = K(o, i), c = Z(e, a, n, r);
|
|
2610
2620
|
for (let e of r) {
|
|
2611
2621
|
let t = e.parseTag(i, c.value, n);
|
|
2612
|
-
if (t !== void 0) return t instanceof
|
|
2622
|
+
if (t !== void 0) return t instanceof j && s !== void 0 && (t.encodingWidth = s), {
|
|
2613
2623
|
value: t,
|
|
2614
2624
|
nextOffset: c.nextOffset
|
|
2615
2625
|
};
|
|
2616
2626
|
}
|
|
2617
2627
|
return {
|
|
2618
|
-
value: new
|
|
2628
|
+
value: new j(i, c.value, { encodingWidth: s }),
|
|
2619
2629
|
nextOffset: c.nextOffset
|
|
2620
2630
|
};
|
|
2621
2631
|
}
|
|
2622
2632
|
case 7:
|
|
2623
2633
|
if (o <= 19) return {
|
|
2624
|
-
value: new
|
|
2634
|
+
value: new L(o),
|
|
2625
2635
|
nextOffset: t
|
|
2626
2636
|
};
|
|
2627
2637
|
if (o === 20) return {
|
|
2628
|
-
value: new
|
|
2638
|
+
value: new L(20),
|
|
2629
2639
|
nextOffset: t
|
|
2630
2640
|
};
|
|
2631
2641
|
if (o === 21) return {
|
|
2632
|
-
value: new
|
|
2642
|
+
value: new L(21),
|
|
2633
2643
|
nextOffset: t
|
|
2634
2644
|
};
|
|
2635
2645
|
if (o === 22) return {
|
|
2636
|
-
value: new
|
|
2646
|
+
value: new L(22),
|
|
2637
2647
|
nextOffset: t
|
|
2638
2648
|
};
|
|
2639
2649
|
if (o === 23) return {
|
|
2640
|
-
value: new
|
|
2650
|
+
value: new L(23),
|
|
2641
2651
|
nextOffset: t
|
|
2642
2652
|
};
|
|
2643
2653
|
if (o === 24) {
|
|
2644
2654
|
t + 1 > e.byteLength && q("unexpected end of input");
|
|
2645
2655
|
let r = e.getUint8(t);
|
|
2646
2656
|
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
|
|
2657
|
+
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);
|
|
2658
|
+
return J(i, e), {
|
|
2649
2659
|
value: i,
|
|
2650
2660
|
nextOffset: t + 1
|
|
2651
2661
|
};
|
|
2652
2662
|
}
|
|
2653
2663
|
return {
|
|
2654
|
-
value: new
|
|
2664
|
+
value: new L(r),
|
|
2655
2665
|
nextOffset: t + 1
|
|
2656
2666
|
};
|
|
2657
2667
|
}
|
|
2658
2668
|
return o === 25 ? (t + 2 > e.byteLength && q("unexpected end of input"), {
|
|
2659
|
-
value: new
|
|
2669
|
+
value: new A(S(e.getUint16(t, !1)), { precision: "half" }),
|
|
2660
2670
|
nextOffset: t + 2
|
|
2661
2671
|
}) : o === 26 ? (t + 4 > e.byteLength && q("unexpected end of input"), {
|
|
2662
|
-
value: new
|
|
2672
|
+
value: new A(e.getFloat32(t, !1), { precision: "single" }),
|
|
2663
2673
|
nextOffset: t + 4
|
|
2664
2674
|
}) : o === 27 ? (t + 8 > e.byteLength && q("unexpected end of input"), {
|
|
2665
|
-
value: new
|
|
2675
|
+
value: new A(e.getFloat64(t, !1), { precision: "double" }),
|
|
2666
2676
|
nextOffset: t + 8
|
|
2667
2677
|
}) : (o < 31 && q(`reserved additional info value in major type 7: ${o}`), q("unexpected break code outside indefinite-length item"));
|
|
2668
2678
|
}
|
|
2669
2679
|
return q(`unknown major type: ${a}`);
|
|
2670
2680
|
}
|
|
2671
|
-
function
|
|
2681
|
+
function Wn(e) {
|
|
2672
2682
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
2673
2683
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
2674
2684
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
2675
2685
|
}
|
|
2676
|
-
function
|
|
2677
|
-
let n =
|
|
2686
|
+
function Gn(e, t) {
|
|
2687
|
+
let n = Wn(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
2678
2688
|
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
|
-
|
|
2689
|
+
let a = [...t?.extensions ?? [], ...qn].filter((e) => e.parseTag !== void 0), { value: o, nextOffset: s } = Z(r, i, t, a);
|
|
2690
|
+
if (!t?.allowTrailing && s !== r.byteLength) {
|
|
2691
|
+
J(o, Rn(`${r.byteLength - s} trailing byte(s) after end of CBOR item`, s, t));
|
|
2692
|
+
let e = {
|
|
2693
|
+
strict: !1,
|
|
2694
|
+
silent: !0
|
|
2695
|
+
}, n = s;
|
|
2696
|
+
for (; n < r.byteLength;) ({nextOffset: n} = Z(r, n, e, a));
|
|
2697
|
+
}
|
|
2698
|
+
return o;
|
|
2681
2699
|
}
|
|
2682
2700
|
//#endregion
|
|
2683
2701
|
//#region src/extensions/cbordata.ts
|
|
2684
|
-
var
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2702
|
+
var Kn = 24n, qn = [
|
|
2703
|
+
Vt,
|
|
2704
|
+
on,
|
|
2705
|
+
ln,
|
|
2688
2706
|
Fn,
|
|
2689
2707
|
{
|
|
2690
|
-
tagNumbers: [
|
|
2708
|
+
tagNumbers: [Kn],
|
|
2691
2709
|
parseTag(e, t, n) {
|
|
2692
|
-
if (e !== 24n || !(t instanceof
|
|
2710
|
+
if (e !== 24n || !(t instanceof M)) return;
|
|
2693
2711
|
let r = n ? {
|
|
2694
2712
|
extensions: n.extensions,
|
|
2695
2713
|
strict: n.strict,
|
|
@@ -2697,7 +2715,7 @@ var qn = 24n, Z = [
|
|
|
2697
2715
|
silent: n.silent
|
|
2698
2716
|
} : void 0;
|
|
2699
2717
|
try {
|
|
2700
|
-
return new
|
|
2718
|
+
return new j(Kn, new Ve([Gn(t.value, r)], { encodingWidth: t.encodingWidth }));
|
|
2701
2719
|
} catch (e) {
|
|
2702
2720
|
if (r?.strict !== !1) throw e;
|
|
2703
2721
|
return;
|
|
@@ -2710,42 +2728,42 @@ var qn = 24n, Z = [
|
|
|
2710
2728
|
function Q(e, t) {
|
|
2711
2729
|
if (t?.replacer) {
|
|
2712
2730
|
let { replacer: n, ...r } = t, i = Xn(e, n, r.extensions, r.undefinedOmits);
|
|
2713
|
-
return i === d ?
|
|
2731
|
+
return i === d ? L.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
|
|
2714
2732
|
}
|
|
2715
2733
|
return Jn(e, t, !0);
|
|
2716
2734
|
}
|
|
2717
2735
|
function Jn(e, t, n) {
|
|
2718
|
-
for (let n of [...t?.extensions ?? [], ...
|
|
2736
|
+
for (let n of [...t?.extensions ?? [], ...qn]) if (n.fromJS) {
|
|
2719
2737
|
let r = n.fromJS(e, t ?? {});
|
|
2720
2738
|
if (r !== void 0) return r;
|
|
2721
2739
|
}
|
|
2722
2740
|
if (n && typeof e == "object" && e && u.symbol in e) {
|
|
2723
2741
|
let n = e[u.symbol], r = Jn(e, t, !1);
|
|
2724
|
-
for (let e of [...t?.extensions ?? [], ...
|
|
2742
|
+
for (let e of [...t?.extensions ?? [], ...qn]) if (e.parseTag) {
|
|
2725
2743
|
let t = e.parseTag(n, r);
|
|
2726
2744
|
if (t !== void 0) return t;
|
|
2727
2745
|
}
|
|
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
|
|
2746
|
+
return new j(n, r);
|
|
2747
|
+
}
|
|
2748
|
+
if (e instanceof u.Null) return L.NULL;
|
|
2749
|
+
if (e instanceof u.Undefined) return L.UNDEFINED;
|
|
2750
|
+
if (e instanceof f) return new L(e.value);
|
|
2751
|
+
if (e === null) return L.NULL;
|
|
2752
|
+
if (e === void 0) return L.UNDEFINED;
|
|
2753
|
+
if (e === !0) return L.TRUE;
|
|
2754
|
+
if (e === !1) return L.FALSE;
|
|
2755
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new Qe(e) : e < -18446744073709551616n ? new $e(e) : e >= 0n ? new O(e) : new k(e);
|
|
2756
|
+
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);
|
|
2757
|
+
if (typeof e == "string") return new z(e);
|
|
2740
2758
|
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
|
|
2759
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new M(new Uint8Array(e));
|
|
2760
|
+
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));
|
|
2761
|
+
if (e instanceof $) return new I([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
|
|
2762
|
+
if (Array.isArray(e)) return new F(e.map((e) => Q(e, t)));
|
|
2745
2763
|
if (typeof e == "object") {
|
|
2746
2764
|
let n = [];
|
|
2747
|
-
for (let [r, i] of Object.entries(e)) n.push([new
|
|
2748
|
-
return new
|
|
2765
|
+
for (let [r, i] of Object.entries(e)) n.push([new z(r), Q(i, t)]);
|
|
2766
|
+
return new I(n);
|
|
2749
2767
|
}
|
|
2750
2768
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
2751
2769
|
}
|
|
@@ -2753,7 +2771,7 @@ function Yn(e) {
|
|
|
2753
2771
|
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
2772
|
}
|
|
2755
2773
|
function Xn(e, t, n, r) {
|
|
2756
|
-
let i = [...n ?? [], ...
|
|
2774
|
+
let i = [...n ?? [], ...qn];
|
|
2757
2775
|
function a(e) {
|
|
2758
2776
|
return e === d || r === !0 && e === void 0;
|
|
2759
2777
|
}
|
|
@@ -2828,6 +2846,6 @@ var $ = class extends Array {
|
|
|
2828
2846
|
}
|
|
2829
2847
|
};
|
|
2830
2848
|
//#endregion
|
|
2831
|
-
export { i as A,
|
|
2849
|
+
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
2850
|
|
|
2833
|
-
//# sourceMappingURL=mapEntries-
|
|
2851
|
+
//# sourceMappingURL=mapEntries-bvRWFfqX.js.map
|