@cbortech/cbor 0.25.10 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +86 -27
- package/README.md +87 -28
- package/assets/cbor-cdn-js.png +0 -0
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +2 -2
- package/dist/cdn/index.cjs +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/tokenizer.d.ts +8 -5
- package/dist/extensions/concat.d.ts +5 -0
- package/dist/extensions/ilstrings.d.ts +5 -0
- package/dist/index.cjs +6 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +147 -308
- package/dist/index.js.map +1 -1
- package/dist/{mapEntries-B8riGPMD.js → mapEntries-BdzS6bFp.js} +970 -665
- package/dist/mapEntries-BdzS6bFp.js.map +1 -0
- package/dist/mapEntries-DJtvWpWq.cjs +14 -0
- package/dist/mapEntries-DJtvWpWq.cjs.map +1 -0
- package/dist/{tokenizer-DkLlZ1gc.js → tokenizer-CeuixxXi.js} +20 -19
- package/dist/tokenizer-CeuixxXi.js.map +1 -0
- package/dist/{tokenizer-CVcIyZZa.cjs → tokenizer-EciPlN0n.cjs} +3 -3
- package/dist/tokenizer-EciPlN0n.cjs.map +1 -0
- package/dist/types.d.ts +29 -19
- package/package.json +3 -2
- package/dist/mapEntries-B-INYL6l.cjs +0 -11
- package/dist/mapEntries-B-INYL6l.cjs.map +0 -1
- package/dist/mapEntries-B8riGPMD.js.map +0 -1
- package/dist/tokenizer-CVcIyZZa.cjs.map +0 -1
- package/dist/tokenizer-DkLlZ1gc.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "./tokenizer-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "./tokenizer-CeuixxXi.js";
|
|
2
2
|
//#region src/tag.ts
|
|
3
3
|
var o = Symbol.for("cbor.tag"), s = class {
|
|
4
4
|
valueOf() {
|
|
@@ -96,23 +96,23 @@ var m = class {
|
|
|
96
96
|
};
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/cdn/serialize-utils.ts
|
|
99
|
-
function
|
|
99
|
+
function ee(e) {
|
|
100
100
|
let t = e?.indent;
|
|
101
101
|
return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function _(e, t) {
|
|
104
104
|
return e.repeat(t);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
return t === null ? e.join(" + ") : e.join(` +\n${
|
|
106
|
+
function te(e, t, n) {
|
|
107
|
+
return t === null ? e.join(" + ") : e.join(` +\n${_(t, n + 1)}`);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function ne(e) {
|
|
110
110
|
return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function re(e) {
|
|
113
113
|
return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function v(e, t) {
|
|
116
116
|
if (!t) return e.text;
|
|
117
117
|
let { marker: n, text: r } = e;
|
|
118
118
|
if (t === "c-style") return n === "#" ? "//" + r.slice(1) : n === "/" ? "/*" + r.slice(1, -1) + "*/" : r;
|
|
@@ -123,17 +123,17 @@ function y(e, t) {
|
|
|
123
123
|
}
|
|
124
124
|
return r;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
return (e.comments?.leading ?? []).map((e) => t +
|
|
126
|
+
function ie(e, t, n) {
|
|
127
|
+
return (e.comments?.leading ?? []).map((e) => t + v(e, n));
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function y(e, t) {
|
|
130
130
|
let n = e.comments?.trailing ?? [];
|
|
131
|
-
return n.length === 0 ? "" : " " + n.map((e) =>
|
|
131
|
+
return n.length === 0 ? "" : " " + n.map((e) => v(e, t)).join(" ");
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
return (e.comments?.dangling ?? []).map((e) => t +
|
|
133
|
+
function ae(e, t, n) {
|
|
134
|
+
return (e.comments?.dangling ?? []).map((e) => t + v(e, n));
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function oe(e, t = !1) {
|
|
137
137
|
let n = e?.commas ?? "comma", r = n !== "none";
|
|
138
138
|
return {
|
|
139
139
|
inlineSep: r ? t ? "," : ", " : " ",
|
|
@@ -142,32 +142,32 @@ function ae(e, t = !1) {
|
|
|
142
142
|
colSep: t ? ":" : ": "
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
let { options: t, depth: n, openChar: r, closeChar: i, count: a } = e, o =
|
|
145
|
+
function se(e) {
|
|
146
|
+
let { options: t, depth: n, openChar: r, closeChar: i, count: a } = e, o = ee(t), s = t?.preserveComments, c = typeof s == "string" ? s : void 0, l = s && (re(e.node) || e.hasEntryComments());
|
|
147
147
|
o === null && l && (o = " ");
|
|
148
|
-
let { inlineSep: u, multilineSep: d, trailSep: f, colSep: p } =
|
|
148
|
+
let { inlineSep: u, multilineSep: d, trailSep: f, colSep: p } = oe(t, o === null), m = e.indefiniteLength ? "" : x(t, e.encodingWidth, () => b(BigInt(a))), h = m ? m + " " : "", g = e.indefiniteLength && (t?.encodingIndicators ?? "auto") !== "never";
|
|
149
149
|
if (o === null || a === 0 && !l) {
|
|
150
150
|
let t = "";
|
|
151
151
|
for (let n = 0; n < a; n++) n > 0 && (t += u), t += e.renderEntry(n, p);
|
|
152
152
|
return e.indefiniteLength ? g ? a === 0 ? `${r}_ ${i}` : `${r}_ ${t}${i}` : `${r}${t}${i}` : `${r}${h}${t}${i}`;
|
|
153
153
|
}
|
|
154
|
-
let
|
|
154
|
+
let te = _(o, n + 1), ne = _(o, n), v = e.indefiniteLength ? g ? `${r}_ ` : r : `${r}${h}`, y = [];
|
|
155
155
|
for (let t = 0; t < a; t++) {
|
|
156
|
-
s &&
|
|
156
|
+
s && y.push(...ie(e.entryLeadingNode(t), te, c));
|
|
157
157
|
let n = t < a - 1 ? d : f;
|
|
158
|
-
|
|
158
|
+
y.push(`${te}${e.renderEntry(t, p)}${n}${s ? e.entryTrailing(t, c) : ""}`);
|
|
159
159
|
}
|
|
160
|
-
return s &&
|
|
160
|
+
return s && y.push(...ae(e.node, te, c)), `${v}\n${y.join("\n")}\n${ne}${i}`;
|
|
161
161
|
}
|
|
162
|
-
var
|
|
163
|
-
function
|
|
164
|
-
if (
|
|
162
|
+
var ce = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
|
|
163
|
+
function le(e) {
|
|
164
|
+
if (ce) return e.toBase64({ omitPadding: !0 });
|
|
165
165
|
let t = "";
|
|
166
166
|
for (let n of e) t += String.fromCharCode(n);
|
|
167
167
|
return btoa(t).replace(/=/g, "");
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
if (
|
|
169
|
+
function ue(e) {
|
|
170
|
+
if (ce) return e.toBase64({
|
|
171
171
|
alphabet: "base64url",
|
|
172
172
|
omitPadding: !0
|
|
173
173
|
});
|
|
@@ -175,54 +175,54 @@ function le(e) {
|
|
|
175
175
|
for (let n of e) t += String.fromCharCode(n);
|
|
176
176
|
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
177
177
|
}
|
|
178
|
-
var
|
|
179
|
-
function
|
|
178
|
+
var de = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", fe = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
179
|
+
function pe(e, t) {
|
|
180
180
|
let n = "", r = 0, i = 0;
|
|
181
181
|
for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
|
|
182
182
|
return i > 0 && (n += t[r << 5 - i & 31]), n;
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function me(e) {
|
|
185
185
|
for (let t of e) {
|
|
186
186
|
let e = t.codePointAt(0);
|
|
187
187
|
if (e < 32 || e === 127) return !0;
|
|
188
188
|
}
|
|
189
189
|
return !1;
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function he(e, t, n) {
|
|
192
192
|
if (n === "string") {
|
|
193
|
-
let t =
|
|
194
|
-
if (t != null) return
|
|
193
|
+
let t = _e(e);
|
|
194
|
+
if (t != null) return be(t);
|
|
195
195
|
}
|
|
196
196
|
if (n === "printable-string" || n === void 0) {
|
|
197
|
-
let t =
|
|
198
|
-
if (t != null && !
|
|
197
|
+
let t = _e(e);
|
|
198
|
+
if (t != null && !me(t)) return be(t);
|
|
199
199
|
}
|
|
200
200
|
switch (t) {
|
|
201
|
-
case "base64": return `b64'${
|
|
202
|
-
case "base64url": return `b64'${
|
|
203
|
-
case "base32": return `b32'${
|
|
204
|
-
case "base32hex": return `h32'${
|
|
201
|
+
case "base64": return `b64'${le(e)}'`;
|
|
202
|
+
case "base64url": return `b64'${ue(e)}'`;
|
|
203
|
+
case "base32": return `b32'${pe(e, de)}'`;
|
|
204
|
+
case "base32hex": return `h32'${pe(e, fe)}'`;
|
|
205
205
|
default: return `h'${i(e)}'`;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
var
|
|
209
|
-
function
|
|
208
|
+
var ge = new TextDecoder("utf-8", { fatal: !0 });
|
|
209
|
+
function _e(e) {
|
|
210
210
|
try {
|
|
211
|
-
return
|
|
211
|
+
return ge.decode(e);
|
|
212
212
|
} catch {
|
|
213
213
|
return null;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function ve(e, t) {
|
|
217
217
|
for (let n = 0; n < e.length; n++) {
|
|
218
218
|
let r = e.charCodeAt(n);
|
|
219
219
|
if (r === t || r === 92 || r < 32 || r === 127 || r >= 8192 && (r === 8232 || r === 8233 || r >= 8203 && r <= 8205 || r === 65279)) return !0;
|
|
220
220
|
}
|
|
221
221
|
return !1;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function ye(e, t) {
|
|
224
224
|
let n = t.codePointAt(0);
|
|
225
|
-
if (!
|
|
225
|
+
if (!ve(e, n)) return t + e + t;
|
|
226
226
|
let r = t;
|
|
227
227
|
for (let i of e) {
|
|
228
228
|
let e = i.codePointAt(0);
|
|
@@ -247,40 +247,40 @@ function ve(e, t) {
|
|
|
247
247
|
}
|
|
248
248
|
return r + t;
|
|
249
249
|
}
|
|
250
|
-
function ye(e) {
|
|
251
|
-
return ve(e, "'");
|
|
252
|
-
}
|
|
253
250
|
function be(e) {
|
|
254
|
-
return
|
|
251
|
+
return ye(e, "'");
|
|
255
252
|
}
|
|
256
253
|
function xe(e) {
|
|
257
|
-
return
|
|
254
|
+
return ye(e, "'");
|
|
258
255
|
}
|
|
259
256
|
function Se(e) {
|
|
257
|
+
return ye(e, "\"");
|
|
258
|
+
}
|
|
259
|
+
function Ce(e) {
|
|
260
260
|
if (isNaN(e)) return "NaN";
|
|
261
261
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
262
262
|
if (Object.is(e, -0)) return "-0.0";
|
|
263
263
|
let t = e.toString();
|
|
264
264
|
return t.includes(".") || t.includes("e") ? t : t + ".0";
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function we(e, t, n, r) {
|
|
267
267
|
if (r === "never") return "";
|
|
268
268
|
let i = t ?? n;
|
|
269
269
|
return r === "always" ? i === "half" ? "_1" : i === "single" ? "_2" : "_3" : t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function b(e) {
|
|
272
272
|
return e <= 23n ? "i" : e <= 255n ? 0 : e <= 65535n ? 1 : e <= 4294967295n ? 2 : 3;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function x(e, t, n) {
|
|
275
275
|
let r = e?.encodingIndicators ?? "auto";
|
|
276
276
|
return r === "never" ? "" : r === "always" ? `_${t ?? n()}` : t === void 0 ? "" : `_${t}`;
|
|
277
277
|
}
|
|
278
278
|
//#endregion
|
|
279
279
|
//#region src/utils/float16.ts
|
|
280
|
-
var
|
|
281
|
-
function
|
|
282
|
-
|
|
283
|
-
let t =
|
|
280
|
+
var Te = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Ee = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
281
|
+
function S(e) {
|
|
282
|
+
Ee.setFloat64(0, e, !1);
|
|
283
|
+
let t = Ee.getUint32(0, !1), n = Ee.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
284
284
|
if (i === 2047) {
|
|
285
285
|
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
286
286
|
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
@@ -301,19 +301,19 @@ function C(e) {
|
|
|
301
301
|
let u = o <= 0 ? 0 : o;
|
|
302
302
|
return r << 15 | u << 10 | s;
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function C(e) {
|
|
305
305
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
306
306
|
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);
|
|
307
307
|
}
|
|
308
|
-
var
|
|
308
|
+
var De = Te ? (e, t, n, r) => {
|
|
309
309
|
e.setFloat16(t, n, r);
|
|
310
310
|
} : (e, t, n, r) => {
|
|
311
|
-
e.setUint16(t,
|
|
312
|
-
},
|
|
313
|
-
function
|
|
311
|
+
e.setUint16(t, S(n), r);
|
|
312
|
+
}, w = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), T = new Uint8Array(w.buffer), Oe = new TextEncoder(), ke = typeof Oe.encodeInto == "function";
|
|
313
|
+
function Ae(e) {
|
|
314
314
|
return e <= 23 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function je(e) {
|
|
317
317
|
return e === "i" ? 1 : [
|
|
318
318
|
2,
|
|
319
319
|
3,
|
|
@@ -321,7 +321,7 @@ function Ae(e) {
|
|
|
321
321
|
9
|
|
322
322
|
][e];
|
|
323
323
|
}
|
|
324
|
-
var
|
|
324
|
+
var Me = class {
|
|
325
325
|
buf;
|
|
326
326
|
len = 0;
|
|
327
327
|
constructor(e = 256) {
|
|
@@ -352,45 +352,45 @@ var je = class {
|
|
|
352
352
|
t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
353
353
|
}
|
|
354
354
|
writeBigUint64(e) {
|
|
355
|
-
|
|
355
|
+
w.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(T, this.len), this.len += 8;
|
|
356
356
|
}
|
|
357
357
|
writeFloat16(e) {
|
|
358
|
-
|
|
358
|
+
De(w, 0, e, !1), this._ensure(2);
|
|
359
359
|
let t = this.buf;
|
|
360
|
-
t[this.len++] =
|
|
360
|
+
t[this.len++] = T[0], t[this.len++] = T[1];
|
|
361
361
|
}
|
|
362
362
|
writeFloat32(e) {
|
|
363
|
-
|
|
363
|
+
w.setFloat32(0, e, !1), this._ensure(4);
|
|
364
364
|
let t = this.buf;
|
|
365
|
-
t[this.len++] =
|
|
365
|
+
t[this.len++] = T[0], t[this.len++] = T[1], t[this.len++] = T[2], t[this.len++] = T[3];
|
|
366
366
|
}
|
|
367
367
|
writeFloat64(e) {
|
|
368
|
-
|
|
368
|
+
w.setFloat64(0, e, !1), this._ensure(8), this.buf.set(T, this.len), this.len += 8;
|
|
369
369
|
}
|
|
370
370
|
writeTextString(e, t, n) {
|
|
371
|
-
if (!
|
|
372
|
-
let r =
|
|
373
|
-
|
|
371
|
+
if (!ke) {
|
|
372
|
+
let r = Oe.encode(t);
|
|
373
|
+
E(this, e, r.length, n), this.writeBytes(r);
|
|
374
374
|
return;
|
|
375
375
|
}
|
|
376
|
-
let r = n === void 0 ?
|
|
376
|
+
let r = n === void 0 ? Ae(t.length) : je(n);
|
|
377
377
|
this._ensure(9 + 3 * t.length);
|
|
378
|
-
let { written: i } =
|
|
379
|
-
a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i),
|
|
378
|
+
let { written: i } = Oe.encodeInto(t, this.buf.subarray(this.len + r)), a = n === void 0 ? Ae(i) : r;
|
|
379
|
+
a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i), E(this, e, i, n), this.len += i;
|
|
380
380
|
}
|
|
381
381
|
finish() {
|
|
382
382
|
return this.buf.slice(0, this.len);
|
|
383
383
|
}
|
|
384
|
-
},
|
|
384
|
+
}, Ne = [
|
|
385
385
|
255n,
|
|
386
386
|
65535n,
|
|
387
387
|
4294967295n,
|
|
388
388
|
18446744073709551615n
|
|
389
389
|
];
|
|
390
|
-
function
|
|
391
|
-
return e === "i" ? 23n :
|
|
390
|
+
function Pe(e) {
|
|
391
|
+
return e === "i" ? 23n : Ne[e];
|
|
392
392
|
}
|
|
393
|
-
function
|
|
393
|
+
function E(e, t, n, r) {
|
|
394
394
|
if (r === void 0 && typeof n == "number" && n < 4294967296) {
|
|
395
395
|
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));
|
|
396
396
|
return;
|
|
@@ -402,30 +402,30 @@ function D(e, t, n, r) {
|
|
|
402
402
|
e.writeByte(t << 5 | Number(i));
|
|
403
403
|
return;
|
|
404
404
|
}
|
|
405
|
-
if (i >
|
|
405
|
+
if (i > Ne[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${Ne[r]})`);
|
|
406
406
|
let n = 24 + r;
|
|
407
407
|
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);
|
|
408
408
|
return;
|
|
409
409
|
}
|
|
410
410
|
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));
|
|
411
411
|
}
|
|
412
|
-
function
|
|
413
|
-
let r = new
|
|
414
|
-
return
|
|
415
|
-
}
|
|
416
|
-
var Fe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
417
|
-
function Ie(e) {
|
|
418
|
-
return Object.is(w(C(e)), e);
|
|
412
|
+
function Fe(e, t, n) {
|
|
413
|
+
let r = new Me(9);
|
|
414
|
+
return E(r, e, t, n), r.finish();
|
|
419
415
|
}
|
|
416
|
+
var Ie = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
420
417
|
function Le(e) {
|
|
421
|
-
return
|
|
418
|
+
return Object.is(C(S(e)), e);
|
|
419
|
+
}
|
|
420
|
+
function Re(e) {
|
|
421
|
+
return Ie.setFloat32(0, e, !1), Object.is(Ie.getFloat32(0, !1), e);
|
|
422
422
|
}
|
|
423
|
-
function
|
|
424
|
-
return
|
|
423
|
+
function D(e) {
|
|
424
|
+
return Le(e) ? "half" : Re(e) ? "single" : "double";
|
|
425
425
|
}
|
|
426
426
|
//#endregion
|
|
427
427
|
//#region src/ast/CborItem.ts
|
|
428
|
-
var
|
|
428
|
+
var O = class e {
|
|
429
429
|
start;
|
|
430
430
|
end;
|
|
431
431
|
comments;
|
|
@@ -435,7 +435,7 @@ var k = class e {
|
|
|
435
435
|
let t = this._defaults ? {
|
|
436
436
|
...this._defaults,
|
|
437
437
|
...e
|
|
438
|
-
} : e, n = new
|
|
438
|
+
} : e, n = new Me();
|
|
439
439
|
return this._encode(n, t), n.finish();
|
|
440
440
|
}
|
|
441
441
|
toCDN(e) {
|
|
@@ -444,7 +444,7 @@ var k = class e {
|
|
|
444
444
|
...e
|
|
445
445
|
} : e, n = this._toCDN(t, 0), r = t?.preserveComments;
|
|
446
446
|
if (!r) return n;
|
|
447
|
-
let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) =>
|
|
447
|
+
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(" ")}`;
|
|
448
448
|
return [...a, s].join("\n");
|
|
449
449
|
}
|
|
450
450
|
toEDN(e) {
|
|
@@ -483,7 +483,7 @@ var k = class e {
|
|
|
483
483
|
t.writeBytes(this._toCBOR(n));
|
|
484
484
|
}
|
|
485
485
|
_toCBOR(e) {
|
|
486
|
-
let t = new
|
|
486
|
+
let t = new Me();
|
|
487
487
|
return this._encodeTo(t, e), t.finish();
|
|
488
488
|
}
|
|
489
489
|
_toHexDump(e, n) {
|
|
@@ -493,7 +493,7 @@ var k = class e {
|
|
|
493
493
|
comment: this._toCDN(n, 0)
|
|
494
494
|
}];
|
|
495
495
|
}
|
|
496
|
-
},
|
|
496
|
+
}, k = class extends O {
|
|
497
497
|
value;
|
|
498
498
|
encodingWidth;
|
|
499
499
|
constructor(e, t) {
|
|
@@ -502,10 +502,10 @@ var k = class e {
|
|
|
502
502
|
this.encodingWidth = t?.encodingWidth;
|
|
503
503
|
}
|
|
504
504
|
_encodeTo(e, t) {
|
|
505
|
-
|
|
505
|
+
E(e, 0, this.value, this.encodingWidth);
|
|
506
506
|
}
|
|
507
507
|
_toCDN(e, t) {
|
|
508
|
-
let n =
|
|
508
|
+
let n = x(e, this.encodingWidth, () => b(this.value)), r = this.value;
|
|
509
509
|
switch (e?.intFormat) {
|
|
510
510
|
case "hex": return `0x${r.toString(16)}${n}`;
|
|
511
511
|
case "octal": return `0o${r.toString(8)}${n}`;
|
|
@@ -517,7 +517,7 @@ var k = class e {
|
|
|
517
517
|
let t = e?.integerAs ?? "auto";
|
|
518
518
|
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
519
519
|
}
|
|
520
|
-
},
|
|
520
|
+
}, A = class extends O {
|
|
521
521
|
argument;
|
|
522
522
|
encodingWidth;
|
|
523
523
|
constructor(e, t) {
|
|
@@ -531,10 +531,10 @@ var k = class e {
|
|
|
531
531
|
return -1n - this.argument;
|
|
532
532
|
}
|
|
533
533
|
_encodeTo(e, t) {
|
|
534
|
-
|
|
534
|
+
E(e, 1, this.argument, this.encodingWidth);
|
|
535
535
|
}
|
|
536
536
|
_toCDN(e, t) {
|
|
537
|
-
let n =
|
|
537
|
+
let n = x(e, this.encodingWidth, () => b(this.argument)), r = this.argument + 1n;
|
|
538
538
|
switch (e?.intFormat) {
|
|
539
539
|
case "hex": return `-0x${r.toString(16)}${n}`;
|
|
540
540
|
case "octal": return `-0o${r.toString(8)}${n}`;
|
|
@@ -546,8 +546,8 @@ var k = class e {
|
|
|
546
546
|
let t = this.value, n = e?.integerAs ?? "auto";
|
|
547
547
|
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
548
548
|
}
|
|
549
|
-
},
|
|
550
|
-
function
|
|
549
|
+
}, ze = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
550
|
+
function Be(e) {
|
|
551
551
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
552
552
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
553
553
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -565,20 +565,20 @@ function ze(e) {
|
|
|
565
565
|
let l = c * 2 ** o;
|
|
566
566
|
return t ? -l : l;
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function Ve(e) {
|
|
569
569
|
if (isNaN(e)) return "NaN";
|
|
570
570
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
571
571
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
572
572
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
573
|
-
|
|
574
|
-
let r =
|
|
573
|
+
ze.setFloat64(0, n, !1);
|
|
574
|
+
let r = ze.getUint32(0, !1), i = ze.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;
|
|
575
575
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
576
576
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
577
577
|
return t ? `-${p}` : p;
|
|
578
578
|
}
|
|
579
579
|
//#endregion
|
|
580
580
|
//#region src/ast/CborFloat.ts
|
|
581
|
-
var
|
|
581
|
+
var j = class extends O {
|
|
582
582
|
value;
|
|
583
583
|
precision;
|
|
584
584
|
ednSource;
|
|
@@ -587,7 +587,7 @@ var M = class extends k {
|
|
|
587
587
|
super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits;
|
|
588
588
|
}
|
|
589
589
|
_encodeTo(e, t) {
|
|
590
|
-
let n = this.precision ??
|
|
590
|
+
let n = this.precision ?? D(this.value), r = Number.isNaN(this.value) ? this.rawBits : void 0;
|
|
591
591
|
n === "half" ? (e.writeByte(249), r?.length === 2 ? e.writeBytes(r) : e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), r?.length === 4 ? e.writeBytes(r) : e.writeFloat32(this.value)) : (e.writeByte(251), r?.length === 8 ? e.writeBytes(r) : e.writeFloat64(this.value));
|
|
592
592
|
}
|
|
593
593
|
_toCDN(e, t) {
|
|
@@ -596,18 +596,18 @@ var M = class extends k {
|
|
|
596
596
|
if (n === "never") return this.ednSource.replace(/_[0-3i]$/, "");
|
|
597
597
|
if (n === "always") {
|
|
598
598
|
if (/_[0-3i]$/.test(this.ednSource)) return this.ednSource;
|
|
599
|
-
let e = this.precision ??
|
|
599
|
+
let e = this.precision ?? D(this.value), t = e === "half" ? "_1" : e === "single" ? "_2" : "_3";
|
|
600
600
|
return this.ednSource + t;
|
|
601
601
|
}
|
|
602
602
|
return this.ednSource;
|
|
603
603
|
}
|
|
604
|
-
let r =
|
|
605
|
-
return (e?.floatFormat === "hex" ?
|
|
604
|
+
let r = D(this.value);
|
|
605
|
+
return (e?.floatFormat === "hex" ? Ve(this.value) : Ce(this.value)) + we(this.value, this.precision, r, n);
|
|
606
606
|
}
|
|
607
607
|
_toJS(e) {
|
|
608
608
|
return this.value;
|
|
609
609
|
}
|
|
610
|
-
},
|
|
610
|
+
}, M = class extends O {
|
|
611
611
|
tag;
|
|
612
612
|
content;
|
|
613
613
|
encodingWidth;
|
|
@@ -616,16 +616,16 @@ var M = class extends k {
|
|
|
616
616
|
this.content = t, this.encodingWidth = n?.encodingWidth;
|
|
617
617
|
}
|
|
618
618
|
_encodeTo(e, t) {
|
|
619
|
-
|
|
619
|
+
E(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
620
620
|
}
|
|
621
621
|
_toCDN(e, t) {
|
|
622
|
-
let n =
|
|
622
|
+
let n = x(e, this.encodingWidth, () => b(this.tag));
|
|
623
623
|
return `${this.tag}${n}(${this.content._toCDN(e, t)})`;
|
|
624
624
|
}
|
|
625
625
|
_toHexDump(e, n) {
|
|
626
626
|
let r = [{
|
|
627
627
|
depth: e,
|
|
628
|
-
hex: t(
|
|
628
|
+
hex: t(Fe(6, this.tag, this.encodingWidth)),
|
|
629
629
|
comment: `Tag ${this.tag}`
|
|
630
630
|
}];
|
|
631
631
|
return r.push(...this.content._toHexDump(e + 1, {
|
|
@@ -637,7 +637,7 @@ var M = class extends k {
|
|
|
637
637
|
let t = this.content._toJS(e);
|
|
638
638
|
return e?.stripTags ? t : m.set(t, this.tag);
|
|
639
639
|
}
|
|
640
|
-
},
|
|
640
|
+
}, N = class extends O {
|
|
641
641
|
indefiniteLength = !1;
|
|
642
642
|
value;
|
|
643
643
|
ednEncoding;
|
|
@@ -648,27 +648,27 @@ var M = class extends k {
|
|
|
648
648
|
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource, this.ednParts = t?.ednParts;
|
|
649
649
|
}
|
|
650
650
|
_encodeTo(e, t) {
|
|
651
|
-
|
|
651
|
+
E(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
|
|
652
652
|
}
|
|
653
653
|
_toCDN(e, t) {
|
|
654
654
|
if (e?.preserveConcatenation && this.ednParts !== void 0 && this.ednParts.length > 1) {
|
|
655
|
-
let n =
|
|
655
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
|
|
656
656
|
e?.appStrings === !1 && r !== "hex" && (r = "hex");
|
|
657
|
-
let i = this.ednParts.map((t) => e?.preserveByteString && t.source !== void 0 ? t.source :
|
|
658
|
-
return i[i.length - 1] += n,
|
|
657
|
+
let i = this.ednParts.map((t) => e?.preserveByteString && t.source !== void 0 ? t.source : he(t.bytes, r, e?.sqstr));
|
|
658
|
+
return i[i.length - 1] += n, te(i, ee(e), t);
|
|
659
659
|
}
|
|
660
660
|
if (e?.preserveByteString && this.ednSource !== void 0) {
|
|
661
661
|
if (/_[0-3i]$/.test(this.ednSource)) return (e?.encodingIndicators ?? "auto") === "never" ? this.ednSource.replace(/_[0-3i]$/, "") : this.ednSource;
|
|
662
|
-
let t =
|
|
662
|
+
let t = x(e, this.encodingWidth, () => b(BigInt(this.value.length)));
|
|
663
663
|
return this.ednSource + t;
|
|
664
664
|
}
|
|
665
|
-
let n =
|
|
666
|
-
return e?.appStrings === !1 && r !== "hex" && (r = "hex"),
|
|
665
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(this.value.length))), r = e?.bstrEncoding ?? this.ednEncoding;
|
|
666
|
+
return e?.appStrings === !1 && r !== "hex" && (r = "hex"), he(this.value, r, e?.sqstr) + n;
|
|
667
667
|
}
|
|
668
668
|
_toJS(e) {
|
|
669
669
|
return this.value;
|
|
670
670
|
}
|
|
671
|
-
},
|
|
671
|
+
}, P = class extends O {
|
|
672
672
|
indefiniteLength = !0;
|
|
673
673
|
chunks;
|
|
674
674
|
constructor(e) {
|
|
@@ -683,7 +683,7 @@ var M = class extends k {
|
|
|
683
683
|
if ((e?.encodingIndicators ?? "auto") === "never") {
|
|
684
684
|
let t = this.chunks.reduce((e, t) => e + t.value.length, 0), n = new Uint8Array(t), r = 0;
|
|
685
685
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
686
|
-
return new
|
|
686
|
+
return new N(n)._toCDN(e, 0);
|
|
687
687
|
}
|
|
688
688
|
return this.chunks.length === 0 ? "''_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
689
689
|
}
|
|
@@ -705,7 +705,7 @@ var M = class extends k {
|
|
|
705
705
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
706
706
|
return n;
|
|
707
707
|
}
|
|
708
|
-
},
|
|
708
|
+
}, F = class extends O {
|
|
709
709
|
indefiniteLength = !0;
|
|
710
710
|
chunks;
|
|
711
711
|
constructor(e) {
|
|
@@ -717,7 +717,7 @@ var M = class extends k {
|
|
|
717
717
|
e.writeByte(255);
|
|
718
718
|
}
|
|
719
719
|
_toCDN(e, t) {
|
|
720
|
-
return (e?.encodingIndicators ?? "auto") === "never" ? new
|
|
720
|
+
return (e?.encodingIndicators ?? "auto") === "never" ? new B(this.chunks.map((e) => e.value).join(""))._toCDN(e, t) : this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
721
721
|
}
|
|
722
722
|
_toHexDump(e, t) {
|
|
723
723
|
let r = [{
|
|
@@ -735,7 +735,7 @@ var M = class extends k {
|
|
|
735
735
|
_toJS(e) {
|
|
736
736
|
return this.chunks.map((e) => e.value).join("");
|
|
737
737
|
}
|
|
738
|
-
},
|
|
738
|
+
}, I = class extends O {
|
|
739
739
|
items;
|
|
740
740
|
indefiniteLength;
|
|
741
741
|
encodingWidth;
|
|
@@ -749,11 +749,11 @@ var M = class extends k {
|
|
|
749
749
|
e.writeByte(255);
|
|
750
750
|
return;
|
|
751
751
|
}
|
|
752
|
-
|
|
752
|
+
E(e, 4, this.items.length, this.encodingWidth);
|
|
753
753
|
for (let n of this.items) n._encode(e, t);
|
|
754
754
|
}
|
|
755
755
|
_toCDN(e, t) {
|
|
756
|
-
return
|
|
756
|
+
return se({
|
|
757
757
|
node: this,
|
|
758
758
|
options: e,
|
|
759
759
|
depth: t,
|
|
@@ -762,10 +762,10 @@ var M = class extends k {
|
|
|
762
762
|
count: this.items.length,
|
|
763
763
|
indefiniteLength: this.indefiniteLength,
|
|
764
764
|
encodingWidth: this.encodingWidth,
|
|
765
|
-
hasEntryComments: () => this.items.some(
|
|
765
|
+
hasEntryComments: () => this.items.some(ne),
|
|
766
766
|
renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
|
|
767
767
|
entryLeadingNode: (e) => this.items[e],
|
|
768
|
-
entryTrailing: (e, t) =>
|
|
768
|
+
entryTrailing: (e, t) => y(this.items[e], t)
|
|
769
769
|
});
|
|
770
770
|
}
|
|
771
771
|
_toHexDump(e, r) {
|
|
@@ -784,7 +784,7 @@ var M = class extends k {
|
|
|
784
784
|
}
|
|
785
785
|
let i = [{
|
|
786
786
|
depth: e,
|
|
787
|
-
hex: t(
|
|
787
|
+
hex: t(Fe(4, BigInt(this.items.length), this.encodingWidth)),
|
|
788
788
|
comment: `Array of length ${this.items.length}`
|
|
789
789
|
}];
|
|
790
790
|
for (let t of this.items) i.push(...t._toHexDump(e + 1, r));
|
|
@@ -803,7 +803,7 @@ var M = class extends k {
|
|
|
803
803
|
}
|
|
804
804
|
return r;
|
|
805
805
|
}
|
|
806
|
-
},
|
|
806
|
+
}, L = class extends O {
|
|
807
807
|
entries;
|
|
808
808
|
indefiniteLength;
|
|
809
809
|
encodingWidth;
|
|
@@ -817,11 +817,11 @@ var M = class extends k {
|
|
|
817
817
|
e.writeByte(255);
|
|
818
818
|
return;
|
|
819
819
|
}
|
|
820
|
-
|
|
820
|
+
E(e, 5, this.entries.length, this.encodingWidth);
|
|
821
821
|
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
822
822
|
}
|
|
823
823
|
_toCDN(e, t) {
|
|
824
|
-
return
|
|
824
|
+
return se({
|
|
825
825
|
node: this,
|
|
826
826
|
options: e,
|
|
827
827
|
depth: t,
|
|
@@ -830,7 +830,7 @@ var M = class extends k {
|
|
|
830
830
|
count: this.entries.length,
|
|
831
831
|
indefiniteLength: this.indefiniteLength,
|
|
832
832
|
encodingWidth: this.encodingWidth,
|
|
833
|
-
hasEntryComments: () => this.entries.some(([e, t]) =>
|
|
833
|
+
hasEntryComments: () => this.entries.some(([e, t]) => ne(e) || ne(t)),
|
|
834
834
|
renderEntry: (n, r) => {
|
|
835
835
|
let [i, a] = this.entries[n];
|
|
836
836
|
return `${i._toCDN(e, t + 1)}${r}${a._toCDN(e, t + 1)}`;
|
|
@@ -838,7 +838,7 @@ var M = class extends k {
|
|
|
838
838
|
entryLeadingNode: (e) => this.entries[e][0],
|
|
839
839
|
entryTrailing: (e, t) => {
|
|
840
840
|
let [n, r] = this.entries[e];
|
|
841
|
-
return
|
|
841
|
+
return He([
|
|
842
842
|
...n.comments?.trailing ?? [],
|
|
843
843
|
...r.comments?.leading ?? [],
|
|
844
844
|
...r.comments?.trailing ?? []
|
|
@@ -862,7 +862,7 @@ var M = class extends k {
|
|
|
862
862
|
}
|
|
863
863
|
let i = [{
|
|
864
864
|
depth: e,
|
|
865
|
-
hex: t(
|
|
865
|
+
hex: t(Fe(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
866
866
|
comment: `Map of length ${this.entries.length}`
|
|
867
867
|
}];
|
|
868
868
|
for (let [t, n] of this.entries) i.push(...t._toHexDump(e + 1, r)), i.push(...n._toHexDump(e + 1, r));
|
|
@@ -879,13 +879,13 @@ var M = class extends k {
|
|
|
879
879
|
}
|
|
880
880
|
return n;
|
|
881
881
|
};
|
|
882
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
882
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof B) ? (() => {
|
|
883
883
|
let n = e ? {
|
|
884
884
|
...e,
|
|
885
885
|
reviver: void 0
|
|
886
886
|
} : void 0, r = {};
|
|
887
887
|
for (let [e, t] of this.entries) {
|
|
888
|
-
let i = e instanceof
|
|
888
|
+
let i = e instanceof B ? e.value : e.toCDN(), a = t._toJS(n);
|
|
889
889
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
890
890
|
value: a,
|
|
891
891
|
writable: !0,
|
|
@@ -897,10 +897,10 @@ var M = class extends k {
|
|
|
897
897
|
let i = /* @__PURE__ */ new Map();
|
|
898
898
|
for (let e = 0; e < this.entries.length; e++) {
|
|
899
899
|
let [t] = this.entries[e];
|
|
900
|
-
i.set(t instanceof
|
|
900
|
+
i.set(t instanceof B ? t.value : t.toCDN(), e);
|
|
901
901
|
}
|
|
902
902
|
for (let n = 0; n < this.entries.length; n++) {
|
|
903
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
903
|
+
let [a, o] = this.entries[n], s = a instanceof B ? a.value : a.toCDN();
|
|
904
904
|
if (i.get(s) !== n) continue;
|
|
905
905
|
let c = o._toJS(e), l = t.call(r, s, c);
|
|
906
906
|
l === h || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
@@ -914,12 +914,12 @@ var M = class extends k {
|
|
|
914
914
|
})() : n();
|
|
915
915
|
}
|
|
916
916
|
};
|
|
917
|
-
function
|
|
918
|
-
return e.length === 0 ? "" : " " + e.map((e) =>
|
|
917
|
+
function He(e, t) {
|
|
918
|
+
return e.length === 0 ? "" : " " + e.map((e) => v(e, t).trimEnd()).join(" ");
|
|
919
919
|
}
|
|
920
920
|
//#endregion
|
|
921
921
|
//#region src/ast/CborSimple.ts
|
|
922
|
-
var
|
|
922
|
+
var R = class e extends O {
|
|
923
923
|
value;
|
|
924
924
|
constructor(e) {
|
|
925
925
|
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
@@ -954,33 +954,33 @@ var z = class e extends k {
|
|
|
954
954
|
default: return new g(this.value);
|
|
955
955
|
}
|
|
956
956
|
}
|
|
957
|
-
},
|
|
957
|
+
}, Ue = class extends O {
|
|
958
958
|
items;
|
|
959
959
|
encodingWidth;
|
|
960
960
|
constructor(e, t) {
|
|
961
961
|
super(), this.items = e, this.encodingWidth = t?.encodingWidth;
|
|
962
962
|
}
|
|
963
963
|
_content(e) {
|
|
964
|
-
let t = new
|
|
964
|
+
let t = new Me();
|
|
965
965
|
for (let n of this.items) n._encode(t, e);
|
|
966
966
|
return t.finish();
|
|
967
967
|
}
|
|
968
968
|
_encodeTo(e, t) {
|
|
969
969
|
let n = this._content(t);
|
|
970
|
-
|
|
970
|
+
E(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
|
|
971
971
|
}
|
|
972
972
|
_toCDN(e, t) {
|
|
973
|
-
let n =
|
|
973
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(this._content(e).length)));
|
|
974
974
|
if (this.items.length === 0) return `<<>>${n}`;
|
|
975
|
-
let r =
|
|
975
|
+
let r = ee(e), { inlineSep: i, multilineSep: a, trailSep: o } = oe(e, r === null);
|
|
976
976
|
if (r === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(i)}>>${n}`;
|
|
977
|
-
let s =
|
|
977
|
+
let s = _(r, t + 1), c = _(r, t), l = this.items.map((n) => `${s}${n._toCDN(e, t + 1)}`), u = l.length - 1;
|
|
978
978
|
return `<<\n${l.map((e, t) => t < u ? `${e}${a}` : `${e}${o}`).join("\n")}\n${c}>>${n}`;
|
|
979
979
|
}
|
|
980
980
|
_toHexDump(e, n) {
|
|
981
981
|
let r = this._content().length, i = [{
|
|
982
982
|
depth: e,
|
|
983
|
-
hex: t(
|
|
983
|
+
hex: t(Fe(2, BigInt(r), this.encodingWidth)),
|
|
984
984
|
comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
|
|
985
985
|
}];
|
|
986
986
|
for (let t of this.items) i.push(...t._toHexDump(e + 1, n));
|
|
@@ -989,17 +989,17 @@ var z = class e extends k {
|
|
|
989
989
|
_toJS(e) {
|
|
990
990
|
return this._content();
|
|
991
991
|
}
|
|
992
|
-
},
|
|
992
|
+
}, We = 999n, Ge = class extends M {
|
|
993
993
|
constructor(e, t) {
|
|
994
|
-
let n = t.length === 1 && t[0] instanceof
|
|
995
|
-
super(
|
|
994
|
+
let n = t.length === 1 && t[0] instanceof B ? t[0] : new I(t);
|
|
995
|
+
super(We, new I([new B(e), n]));
|
|
996
996
|
}
|
|
997
997
|
_toCDN(e, t) {
|
|
998
998
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
999
999
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
1000
|
-
return i instanceof
|
|
1000
|
+
return i instanceof B ? `${r}${xe(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
1001
1001
|
}
|
|
1002
|
-
},
|
|
1002
|
+
}, Ke = class extends O {
|
|
1003
1003
|
inner;
|
|
1004
1004
|
ednSource;
|
|
1005
1005
|
constructor(e, t) {
|
|
@@ -1015,15 +1015,15 @@ var z = class e extends k {
|
|
|
1015
1015
|
_toJS(e) {
|
|
1016
1016
|
return this.inner._toJS(e);
|
|
1017
1017
|
}
|
|
1018
|
-
},
|
|
1018
|
+
}, qe = 888n, z = class extends M {
|
|
1019
1019
|
constructor(e) {
|
|
1020
|
-
e === void 0 ? super(
|
|
1020
|
+
e === void 0 ? super(qe, R.NULL) : super(qe, new I(e));
|
|
1021
1021
|
}
|
|
1022
1022
|
_toCDN(e, t) {
|
|
1023
|
-
return this.content instanceof
|
|
1023
|
+
return this.content instanceof R ? "..." : this.content instanceof I ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
|
|
1024
1024
|
}
|
|
1025
|
-
},
|
|
1026
|
-
function
|
|
1025
|
+
}, Je = 2n, Ye = 3n, Xe = 18446744073709551615n, Ze = -18446744073709551616n;
|
|
1026
|
+
function Qe(e) {
|
|
1027
1027
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
1028
1028
|
if (e === 0n) return /* @__PURE__ */ new Uint8Array();
|
|
1029
1029
|
let t = e.toString(16);
|
|
@@ -1032,16 +1032,16 @@ function Ze(e) {
|
|
|
1032
1032
|
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
1033
1033
|
return n;
|
|
1034
1034
|
}
|
|
1035
|
-
function
|
|
1035
|
+
function $e(e) {
|
|
1036
1036
|
let t = 0n;
|
|
1037
1037
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
1038
1038
|
return t;
|
|
1039
1039
|
}
|
|
1040
|
-
var
|
|
1040
|
+
var et = class extends M {
|
|
1041
1041
|
bigValue;
|
|
1042
1042
|
constructor(e) {
|
|
1043
|
-
if (e <=
|
|
1044
|
-
super(
|
|
1043
|
+
if (e <= Xe) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1044
|
+
super(Je, new N(Qe(e))), this.bigValue = e;
|
|
1045
1045
|
}
|
|
1046
1046
|
_toCDN(e, t) {
|
|
1047
1047
|
return this.bigValue.toString();
|
|
@@ -1049,11 +1049,11 @@ var $e = class extends N {
|
|
|
1049
1049
|
_toJS(e) {
|
|
1050
1050
|
return this.bigValue;
|
|
1051
1051
|
}
|
|
1052
|
-
},
|
|
1052
|
+
}, tt = class extends M {
|
|
1053
1053
|
bigValue;
|
|
1054
1054
|
constructor(e) {
|
|
1055
|
-
if (e >=
|
|
1056
|
-
super(
|
|
1055
|
+
if (e >= Ze) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1056
|
+
super(Ye, new N(Qe(-1n - e))), this.bigValue = e;
|
|
1057
1057
|
}
|
|
1058
1058
|
_toCDN(e, t) {
|
|
1059
1059
|
return this.bigValue.toString();
|
|
@@ -1061,25 +1061,25 @@ var $e = class extends N {
|
|
|
1061
1061
|
_toJS(e) {
|
|
1062
1062
|
return this.bigValue;
|
|
1063
1063
|
}
|
|
1064
|
-
},
|
|
1065
|
-
function
|
|
1064
|
+
}, nt = new TextEncoder(), rt = new TextDecoder("utf-8", { fatal: !0 }), it = new TextDecoder("utf-8", { fatal: !1 });
|
|
1065
|
+
function at(e, t) {
|
|
1066
1066
|
let n = new a(e, {
|
|
1067
1067
|
offset: t?.offset,
|
|
1068
1068
|
skipRS: t?._skipRS
|
|
1069
|
-
}), r = new
|
|
1070
|
-
return t?.preserveComments &&
|
|
1069
|
+
}), r = new _t(n, t ?? {}).parse();
|
|
1070
|
+
return t?.preserveComments && ut(r, n.comments, e), r;
|
|
1071
1071
|
}
|
|
1072
|
-
function
|
|
1072
|
+
function ot(e) {
|
|
1073
1073
|
let t = e, n;
|
|
1074
1074
|
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1075
1075
|
numStr: t,
|
|
1076
1076
|
rawSuffix: n
|
|
1077
1077
|
};
|
|
1078
1078
|
}
|
|
1079
|
-
function
|
|
1079
|
+
function st(e) {
|
|
1080
1080
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1081
1081
|
}
|
|
1082
|
-
function
|
|
1082
|
+
function ct(e, t) {
|
|
1083
1083
|
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1084
1084
|
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1085
1085
|
if (t) t(n), e = e.slice(0, -2);
|
|
@@ -1103,14 +1103,14 @@ function st(e, t) {
|
|
|
1103
1103
|
};
|
|
1104
1104
|
let n = e, r;
|
|
1105
1105
|
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) ? {
|
|
1106
|
-
value:
|
|
1106
|
+
value: Be(n),
|
|
1107
1107
|
precision: r
|
|
1108
1108
|
} : {
|
|
1109
1109
|
value: parseFloat(n),
|
|
1110
1110
|
precision: r
|
|
1111
1111
|
};
|
|
1112
1112
|
}
|
|
1113
|
-
function
|
|
1113
|
+
function lt(e, t) {
|
|
1114
1114
|
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
1115
1115
|
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
1116
1116
|
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
@@ -1147,9 +1147,9 @@ function ct(e, t) {
|
|
|
1147
1147
|
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
1148
1148
|
return l;
|
|
1149
1149
|
}
|
|
1150
|
-
function
|
|
1150
|
+
function ut(e, t, n) {
|
|
1151
1151
|
if (t.length === 0) return;
|
|
1152
|
-
let r =
|
|
1152
|
+
let r = dt(e), i = pt(n), a = [...r].sort((e, t) => e.start - t.start || t.end - e.end), o = [...r].sort((e, t) => e.end - t.end || e.start - t.start), s = [...t].sort((e, t) => e.start - t.start), c = [], l = 0;
|
|
1153
1153
|
for (let t of s) {
|
|
1154
1154
|
let r = { ...t }, s = 0, u = o.length;
|
|
1155
1155
|
for (; s < u;) {
|
|
@@ -1158,7 +1158,7 @@ function lt(e, t, n) {
|
|
|
1158
1158
|
}
|
|
1159
1159
|
let d = s > 0 ? o[s - 1] : void 0, f = d ? n.slice(d.end, t.start) : "";
|
|
1160
1160
|
if (d && i(d.end) === t.line && !f.includes(":")) {
|
|
1161
|
-
|
|
1161
|
+
ft(d.node, "trailing", r);
|
|
1162
1162
|
continue;
|
|
1163
1163
|
}
|
|
1164
1164
|
for (; l < a.length && a[l].start < t.start;) {
|
|
@@ -1174,38 +1174,38 @@ function lt(e, t, n) {
|
|
|
1174
1174
|
}
|
|
1175
1175
|
let m = s < a.length ? a[s] : void 0;
|
|
1176
1176
|
if ((!p || m && m.end <= p.end) && m) {
|
|
1177
|
-
|
|
1177
|
+
ft(m.node, "leading", r);
|
|
1178
1178
|
continue;
|
|
1179
1179
|
}
|
|
1180
|
-
|
|
1180
|
+
ft(p?.node ?? e, "dangling", r);
|
|
1181
1181
|
}
|
|
1182
1182
|
}
|
|
1183
|
-
function
|
|
1183
|
+
function dt(e) {
|
|
1184
1184
|
let t = [], n = (e) => {
|
|
1185
1185
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1186
1186
|
node: e,
|
|
1187
1187
|
start: e.start,
|
|
1188
1188
|
end: e.end
|
|
1189
|
-
}), e instanceof
|
|
1189
|
+
}), e instanceof I || e instanceof Ue) {
|
|
1190
1190
|
for (let t of e.items) n(t);
|
|
1191
1191
|
return;
|
|
1192
1192
|
}
|
|
1193
|
-
if (e instanceof
|
|
1193
|
+
if (e instanceof L) {
|
|
1194
1194
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1195
1195
|
return;
|
|
1196
1196
|
}
|
|
1197
|
-
if (e instanceof
|
|
1197
|
+
if (e instanceof P || e instanceof F) {
|
|
1198
1198
|
for (let t of e.chunks) n(t);
|
|
1199
1199
|
return;
|
|
1200
1200
|
}
|
|
1201
|
-
e instanceof
|
|
1201
|
+
e instanceof M && n(e.content);
|
|
1202
1202
|
};
|
|
1203
1203
|
return n(e), t;
|
|
1204
1204
|
}
|
|
1205
|
-
function
|
|
1205
|
+
function ft(e, t, n) {
|
|
1206
1206
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1207
1207
|
}
|
|
1208
|
-
function
|
|
1208
|
+
function pt(e) {
|
|
1209
1209
|
let t = [0];
|
|
1210
1210
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1211
1211
|
return (n) => {
|
|
@@ -1219,15 +1219,14 @@ function ft(e) {
|
|
|
1219
1219
|
return a + 1;
|
|
1220
1220
|
};
|
|
1221
1221
|
}
|
|
1222
|
-
var
|
|
1223
|
-
["b32",
|
|
1224
|
-
["h32",
|
|
1225
|
-
["
|
|
1226
|
-
["
|
|
1227
|
-
["
|
|
1228
|
-
["
|
|
1229
|
-
|
|
1230
|
-
]), gt = class {
|
|
1222
|
+
var mt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, ht = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, gt = /* @__PURE__ */ new Map([
|
|
1223
|
+
["b32", mt("b32")],
|
|
1224
|
+
["h32", mt("h32")],
|
|
1225
|
+
["same", mt("same")],
|
|
1226
|
+
["hash", ht("hash", "@cbortech/hash-extension")],
|
|
1227
|
+
["uuid", ht("uuid", "@cbortech/uuid-extension")],
|
|
1228
|
+
["UUID", ht("uuid", "@cbortech/uuid-extension")]
|
|
1229
|
+
]), _t = class {
|
|
1231
1230
|
t;
|
|
1232
1231
|
_options;
|
|
1233
1232
|
extByPrefix;
|
|
@@ -1237,7 +1236,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1237
1236
|
_hintedPrefixes = /* @__PURE__ */ new Set();
|
|
1238
1237
|
constructor(e, t) {
|
|
1239
1238
|
this.t = e, this._options = t, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = t.unresolvedExtension ?? "cpa999";
|
|
1240
|
-
for (let e of [...
|
|
1239
|
+
for (let e of [...Fr, ...t.extensions ?? []]) {
|
|
1241
1240
|
for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
|
|
1242
1241
|
for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
|
|
1243
1242
|
}
|
|
@@ -1287,12 +1286,12 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1287
1286
|
case "BYTES_HEX":
|
|
1288
1287
|
case "SQSTR":
|
|
1289
1288
|
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
|
|
1290
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new
|
|
1291
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new
|
|
1292
|
-
case "TRUE": return this.t.consume(), new
|
|
1293
|
-
case "FALSE": return this.t.consume(), new
|
|
1294
|
-
case "NULL": return this.t.consume(), new
|
|
1295
|
-
case "UNDEFINED": return this.t.consume(), new
|
|
1289
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new P([]);
|
|
1290
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new F([]);
|
|
1291
|
+
case "TRUE": return this.t.consume(), new R(21);
|
|
1292
|
+
case "FALSE": return this.t.consume(), new R(20);
|
|
1293
|
+
case "NULL": return this.t.consume(), new R(22);
|
|
1294
|
+
case "UNDEFINED": return this.t.consume(), new R(23);
|
|
1296
1295
|
case "SIMPLE": return this.parseSimple();
|
|
1297
1296
|
case "LBRACKET": return this.parseArray();
|
|
1298
1297
|
case "LBRACE": return this.parseMap();
|
|
@@ -1307,21 +1306,21 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1307
1306
|
}
|
|
1308
1307
|
let r = this.extByPrefix.get(e.appPrefix);
|
|
1309
1308
|
if (!r?.parseAppString) {
|
|
1310
|
-
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1309
|
+
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, [new B(e.value)]);
|
|
1311
1310
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1312
1311
|
}
|
|
1313
1312
|
{
|
|
1314
1313
|
let i = this._pendingWarnings.length;
|
|
1315
1314
|
try {
|
|
1316
1315
|
let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
|
|
1317
|
-
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof
|
|
1316
|
+
return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof N && Object.getPrototypeOf(i) === N.prototype && i.ednSource === void 0 ? new N(i.value, {
|
|
1318
1317
|
ednEncoding: i.ednEncoding,
|
|
1319
1318
|
encodingWidth: i.encodingWidth,
|
|
1320
1319
|
ednSource: e.raw + n
|
|
1321
|
-
}) : (i instanceof
|
|
1320
|
+
}) : (i instanceof j && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1322
1321
|
} catch (t) {
|
|
1323
1322
|
if (this._options.strict !== !1) throw t;
|
|
1324
|
-
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new
|
|
1323
|
+
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Ge(e.appPrefix, [new B(e.value)]);
|
|
1325
1324
|
}
|
|
1326
1325
|
}
|
|
1327
1326
|
}
|
|
@@ -1339,7 +1338,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1339
1338
|
this.t.peek().type === "ENCODING_INDICATOR" && (r = this.t.consume(), n = this._resolveEncodingWidth(r.value, r));
|
|
1340
1339
|
let i = this.extByPrefix.get(e.appPrefix);
|
|
1341
1340
|
if (!i) {
|
|
1342
|
-
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1341
|
+
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, t);
|
|
1343
1342
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1344
1343
|
}
|
|
1345
1344
|
i.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
@@ -1349,61 +1348,61 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1349
1348
|
let a = i.parseAppSequence(e.appPrefix, t, this._extOnError(e));
|
|
1350
1349
|
n !== void 0 && this._applyEiToResult(a, n, r ?? e);
|
|
1351
1350
|
let o = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1352
|
-
if (a instanceof
|
|
1353
|
-
else if (i.preserveAppSeqSource) return new
|
|
1351
|
+
if (a instanceof j) a.ednSource === void 0 && (a.ednSource = o);
|
|
1352
|
+
else if (i.preserveAppSeqSource) return new Ke(a, o);
|
|
1354
1353
|
return a;
|
|
1355
1354
|
} catch (n) {
|
|
1356
1355
|
if (this._options.strict !== !1) throw n;
|
|
1357
|
-
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new
|
|
1356
|
+
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new Ge(e.appPrefix, t);
|
|
1358
1357
|
}
|
|
1359
1358
|
}
|
|
1360
1359
|
}
|
|
1361
1360
|
case "ELLIPSIS": {
|
|
1362
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
1363
|
-
let e = [new
|
|
1361
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new z();
|
|
1362
|
+
let e = [new z()];
|
|
1364
1363
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1365
|
-
return new
|
|
1364
|
+
return new z(e);
|
|
1366
1365
|
}
|
|
1367
1366
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1368
1367
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1369
1368
|
}
|
|
1370
1369
|
}
|
|
1371
1370
|
parseIntegerOrTag() {
|
|
1372
|
-
let e = this.t.consume(), { numStr: t, rawSuffix: n } =
|
|
1373
|
-
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new
|
|
1374
|
-
if (i < -18446744073709551616n) return new
|
|
1371
|
+
let e = this.t.consume(), { numStr: t, rawSuffix: n } = ot(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = st(t);
|
|
1372
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new et(i);
|
|
1373
|
+
if (i < -18446744073709551616n) return new tt(i);
|
|
1375
1374
|
if (r !== void 0) {
|
|
1376
1375
|
let t = i >= 0n ? i : -(i + 1n);
|
|
1377
1376
|
r = this._validateEncodingFit(t, r, e);
|
|
1378
1377
|
}
|
|
1379
|
-
let a = i >= 0n ? new
|
|
1378
|
+
let a = i >= 0n ? new k(i, r === void 0 ? void 0 : { encodingWidth: r }) : new A(i, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1380
1379
|
if (this.t.peek().type === "LPAREN") {
|
|
1381
|
-
a instanceof
|
|
1380
|
+
a instanceof k || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
1382
1381
|
let t = this._pendingWarnings.splice(0), n = this.parseValue();
|
|
1383
1382
|
this.expect("RPAREN");
|
|
1384
1383
|
let i = a.value, o = this.extByTag.get(i);
|
|
1385
1384
|
if (o?.parseTag) {
|
|
1386
1385
|
let e = o.parseTag(i, n);
|
|
1387
|
-
if (e !== void 0) return e instanceof
|
|
1386
|
+
if (e !== void 0) return e instanceof M && r !== void 0 && e.encodingWidth === void 0 && (e.encodingWidth = r), t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
|
|
1388
1387
|
}
|
|
1389
|
-
let s = new
|
|
1388
|
+
let s = new M(i, n, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1390
1389
|
return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
|
|
1391
1390
|
}
|
|
1392
1391
|
return a;
|
|
1393
1392
|
}
|
|
1394
1393
|
parseFloat() {
|
|
1395
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } =
|
|
1394
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = ct(e.value, t);
|
|
1396
1395
|
if (r === "half" || r === "single") {
|
|
1397
|
-
let e = r === "half" ?
|
|
1396
|
+
let e = r === "half" ? C(S(n)) : Math.fround(n);
|
|
1398
1397
|
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`);
|
|
1399
1398
|
}
|
|
1400
|
-
return new
|
|
1399
|
+
return new j(n, r === void 0 ? void 0 : { precision: r });
|
|
1401
1400
|
}
|
|
1402
1401
|
parseString() {
|
|
1403
1402
|
let e = this.t.consume();
|
|
1404
1403
|
if (this.t.peek().type !== "PLUS") {
|
|
1405
|
-
let t = this.consumeEncodingIndicator(() => BigInt(
|
|
1406
|
-
return new
|
|
1404
|
+
let t = this.consumeEncodingIndicator(() => BigInt(nt.encode(e.value).length));
|
|
1405
|
+
return new B(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1407
1406
|
}
|
|
1408
1407
|
let t = !1, n = [{ text: e.value }];
|
|
1409
1408
|
for (; this.t.peek().type === "PLUS";) {
|
|
@@ -1412,15 +1411,15 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1412
1411
|
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);
|
|
1413
1412
|
}
|
|
1414
1413
|
if (!t) {
|
|
1415
|
-
let e = n.map((e) => "text" in e ? e.text : ""), t = e.join(""), r = this.consumeEncodingIndicator(() => BigInt(
|
|
1416
|
-
return new
|
|
1414
|
+
let e = n.map((e) => "text" in e ? e.text : ""), t = e.join(""), r = this.consumeEncodingIndicator(() => BigInt(nt.encode(t).length));
|
|
1415
|
+
return new B(t, {
|
|
1417
1416
|
ednParts: e,
|
|
1418
1417
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
1419
1418
|
});
|
|
1420
1419
|
}
|
|
1421
1420
|
let r = [], i = "";
|
|
1422
|
-
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new
|
|
1423
|
-
return i !== "" && r.push(new
|
|
1421
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new B(i)), i = ""), r.push(new z())) : i += e.text;
|
|
1422
|
+
return i !== "" && r.push(new B(i)), new z(r);
|
|
1424
1423
|
}
|
|
1425
1424
|
_isBytesToken(e) {
|
|
1426
1425
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
@@ -1442,7 +1441,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1442
1441
|
}
|
|
1443
1442
|
case "BYTES_HEX": return this._hexToBytes(e.value, e);
|
|
1444
1443
|
case "BYTES_B64": try {
|
|
1445
|
-
return
|
|
1444
|
+
return lt(e.value, t);
|
|
1446
1445
|
} catch (t) {
|
|
1447
1446
|
if (t instanceof r || !(t instanceof SyntaxError)) throw t;
|
|
1448
1447
|
this._fail(t.message, e);
|
|
@@ -1451,11 +1450,11 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1451
1450
|
}
|
|
1452
1451
|
}
|
|
1453
1452
|
_decodeUtf8(e, t) {
|
|
1454
|
-
if (this._options.allowInvalidUtf8) return
|
|
1453
|
+
if (this._options.allowInvalidUtf8) return it.decode(e);
|
|
1455
1454
|
try {
|
|
1456
|
-
return
|
|
1455
|
+
return rt.decode(e);
|
|
1457
1456
|
} catch {
|
|
1458
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t),
|
|
1457
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), it.decode(e);
|
|
1459
1458
|
}
|
|
1460
1459
|
}
|
|
1461
1460
|
_tokenTypeToCdnEncoding(e) {
|
|
@@ -1464,7 +1463,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1464
1463
|
_parseBytesConcat(e, t, n) {
|
|
1465
1464
|
if (this.t.peek().type !== "PLUS") {
|
|
1466
1465
|
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1467
|
-
return new
|
|
1466
|
+
return new N(e, {
|
|
1468
1467
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1469
1468
|
ednSource: n,
|
|
1470
1469
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
@@ -1481,32 +1480,32 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1481
1480
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1482
1481
|
this.t.consume();
|
|
1483
1482
|
let t = this._buildBytesElidedItems(e.value, e);
|
|
1484
|
-
for (let e of t) e instanceof
|
|
1483
|
+
for (let e of t) e instanceof z ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof N && i.push({ bytes: e.value });
|
|
1485
1484
|
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({
|
|
1486
1485
|
bytes: this._decodeBytesToken(e),
|
|
1487
1486
|
source: e.raw
|
|
1488
|
-
})) : 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:
|
|
1487
|
+
})) : 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: nt.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1489
1488
|
}
|
|
1490
1489
|
if (!r) {
|
|
1491
1490
|
let e = i.map((e) => "bytes" in e ? e : { bytes: /* @__PURE__ */ new Uint8Array() }), n = this._concatBytes(e.map((e) => e.bytes)), r = this.consumeEncodingIndicator(() => BigInt(n.length));
|
|
1492
|
-
return new
|
|
1491
|
+
return new N(n, {
|
|
1493
1492
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1494
1493
|
ednParts: e,
|
|
1495
1494
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
1496
1495
|
});
|
|
1497
1496
|
}
|
|
1498
1497
|
let a = [], o = [], s = () => {
|
|
1499
|
-
o.length > 0 && (a.push(new
|
|
1498
|
+
o.length > 0 && (a.push(new N(this._concatBytes([...o]))), o.length = 0);
|
|
1500
1499
|
};
|
|
1501
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new
|
|
1502
|
-
return s(), new
|
|
1500
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new z())) : o.push(e.bytes);
|
|
1501
|
+
return s(), new z(a);
|
|
1503
1502
|
}
|
|
1504
1503
|
_parseHexElidedConcat(e) {
|
|
1505
1504
|
let t = this._buildBytesElidedItems(e.value, e);
|
|
1506
1505
|
for (; this.t.peek().type === "PLUS";) {
|
|
1507
1506
|
this.t.consume();
|
|
1508
1507
|
let e = this.t.peek();
|
|
1509
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new
|
|
1508
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new z());
|
|
1510
1509
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1511
1510
|
this.t.consume();
|
|
1512
1511
|
let n = this._buildBytesElidedItems(e.value, e);
|
|
@@ -1514,20 +1513,20 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1514
1513
|
} else if (this._isBytesToken(e.type)) {
|
|
1515
1514
|
this.t.consume();
|
|
1516
1515
|
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
1517
|
-
r instanceof
|
|
1516
|
+
r instanceof N ? t[t.length - 1] = new N(this._concatBytes([r.value, n])) : t.push(new N(n));
|
|
1518
1517
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1519
1518
|
}
|
|
1520
|
-
return new
|
|
1519
|
+
return new z(t);
|
|
1521
1520
|
}
|
|
1522
1521
|
_buildBytesElidedItems(e, t) {
|
|
1523
1522
|
let n = e.split("..."), r = [];
|
|
1524
|
-
for (let e = 0; e < n.length; e++) e > 0 && r.push(new
|
|
1523
|
+
for (let e = 0; e < n.length; e++) e > 0 && r.push(new z()), n[e].length > 0 && r.push(new N(this._hexToBytes(n[e], t)));
|
|
1525
1524
|
return r;
|
|
1526
1525
|
}
|
|
1527
1526
|
_mergeFirstBytesItem(e, t) {
|
|
1528
1527
|
if (t.length === 0) return;
|
|
1529
1528
|
let n = e[e.length - 1], r = t[0];
|
|
1530
|
-
n instanceof
|
|
1529
|
+
n instanceof N && r instanceof N ? (e[e.length - 1] = new N(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
|
|
1531
1530
|
}
|
|
1532
1531
|
_concatBytes(e) {
|
|
1533
1532
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -1538,8 +1537,8 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1538
1537
|
this.t.consume(), this.expect("LPAREN");
|
|
1539
1538
|
let e = this.t.peek();
|
|
1540
1539
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
1541
|
-
let { numStr: t } =
|
|
1542
|
-
return this.expect("RPAREN"), new
|
|
1540
|
+
let { numStr: t } = ot(e.value), n = Number(st(t));
|
|
1541
|
+
return this.expect("RPAREN"), new R(n);
|
|
1543
1542
|
}
|
|
1544
1543
|
parseEmbeddedCBOR() {
|
|
1545
1544
|
this.t.consume();
|
|
@@ -1556,7 +1555,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1556
1555
|
let e = this.t.consume();
|
|
1557
1556
|
t = this._resolveEncodingWidth(e.value, e);
|
|
1558
1557
|
}
|
|
1559
|
-
return new
|
|
1558
|
+
return new Ue(e, { encodingWidth: t });
|
|
1560
1559
|
}
|
|
1561
1560
|
parseArray() {
|
|
1562
1561
|
this.t.consume();
|
|
@@ -1570,7 +1569,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1570
1569
|
i.push(this.parseValue());
|
|
1571
1570
|
}
|
|
1572
1571
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1573
|
-
let a = new
|
|
1572
|
+
let a = new I(i, {
|
|
1574
1573
|
indefiniteLength: e,
|
|
1575
1574
|
encodingWidth: t
|
|
1576
1575
|
});
|
|
@@ -1591,7 +1590,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1591
1590
|
i.push([e, t]);
|
|
1592
1591
|
}
|
|
1593
1592
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1594
|
-
let a = new
|
|
1593
|
+
let a = new L(i, {
|
|
1595
1594
|
indefiniteLength: e,
|
|
1596
1595
|
encodingWidth: t
|
|
1597
1596
|
});
|
|
@@ -1615,16 +1614,16 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1615
1614
|
}
|
|
1616
1615
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1617
1616
|
let r = n[0];
|
|
1618
|
-
if (r instanceof
|
|
1619
|
-
let e = new
|
|
1620
|
-
if (e instanceof
|
|
1617
|
+
if (r instanceof N) {
|
|
1618
|
+
let e = new P(n.map((e, t) => {
|
|
1619
|
+
if (e instanceof N) return e;
|
|
1621
1620
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
1622
1621
|
}));
|
|
1623
1622
|
return t.length > 0 && (e.warnings = t), e;
|
|
1624
1623
|
}
|
|
1625
|
-
if (r instanceof
|
|
1626
|
-
let e = new
|
|
1627
|
-
if (e instanceof
|
|
1624
|
+
if (r instanceof B) {
|
|
1625
|
+
let e = new F(n.map((e, t) => {
|
|
1626
|
+
if (e instanceof B) return e;
|
|
1628
1627
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
1629
1628
|
}));
|
|
1630
1629
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -1642,47 +1641,47 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1642
1641
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
1643
1642
|
}
|
|
1644
1643
|
_applyEiToResult(e, t, n) {
|
|
1645
|
-
if (e instanceof
|
|
1644
|
+
if (e instanceof j) {
|
|
1646
1645
|
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
1647
1646
|
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
1648
1647
|
else if (e.precision !== r) {
|
|
1649
1648
|
if (r !== "double") {
|
|
1650
|
-
let t = r === "half" ?
|
|
1649
|
+
let t = r === "half" ? C(S(e.value)) : Math.fround(e.value);
|
|
1651
1650
|
!Object.is(t, e.value) && !isNaN(e.value) && this._warnOrFail(`${e.value} cannot be exactly represented as ${r === "half" ? "float16 (_1)" : "float32 (_2)"}`, n);
|
|
1652
1651
|
}
|
|
1653
1652
|
e.precision = r;
|
|
1654
1653
|
}
|
|
1655
|
-
} else if (e instanceof
|
|
1654
|
+
} else if (e instanceof k) {
|
|
1656
1655
|
if (e.encodingWidth === void 0) {
|
|
1657
1656
|
let r = this._validateEncodingFit(e.value, t, n);
|
|
1658
1657
|
r !== void 0 && (e.encodingWidth = r);
|
|
1659
1658
|
}
|
|
1660
|
-
} else if (e instanceof
|
|
1659
|
+
} else if (e instanceof A) {
|
|
1661
1660
|
if (e.encodingWidth === void 0) {
|
|
1662
1661
|
let r = this._validateEncodingFit(e.argument, t, n);
|
|
1663
1662
|
r !== void 0 && (e.encodingWidth = r);
|
|
1664
1663
|
}
|
|
1665
|
-
} else if (e instanceof
|
|
1664
|
+
} else if (e instanceof N) {
|
|
1666
1665
|
if (e.encodingWidth === void 0) {
|
|
1667
1666
|
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
1668
1667
|
r !== void 0 && (e.encodingWidth = r);
|
|
1669
1668
|
}
|
|
1670
|
-
} else if (e instanceof
|
|
1669
|
+
} else if (e instanceof B) {
|
|
1671
1670
|
if (e.encodingWidth === void 0) {
|
|
1672
|
-
let r = this._validateEncodingFit(BigInt(
|
|
1671
|
+
let r = this._validateEncodingFit(BigInt(nt.encode(e.value).length), t, n);
|
|
1673
1672
|
r !== void 0 && (e.encodingWidth = r);
|
|
1674
1673
|
}
|
|
1675
|
-
} else if (e instanceof
|
|
1674
|
+
} else if (e instanceof I) {
|
|
1676
1675
|
if (e.encodingWidth === void 0) {
|
|
1677
1676
|
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
1678
1677
|
r !== void 0 && (e.encodingWidth = r);
|
|
1679
1678
|
}
|
|
1680
|
-
} else if (e instanceof
|
|
1679
|
+
} else if (e instanceof L) {
|
|
1681
1680
|
if (e.encodingWidth === void 0) {
|
|
1682
1681
|
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
1683
1682
|
r !== void 0 && (e.encodingWidth = r);
|
|
1684
1683
|
}
|
|
1685
|
-
} else if (e instanceof
|
|
1684
|
+
} else if (e instanceof M) {
|
|
1686
1685
|
if (e.encodingWidth === void 0) {
|
|
1687
1686
|
let r = this._validateEncodingFit(e.tag, t, n);
|
|
1688
1687
|
r !== void 0 && (e.encodingWidth = r);
|
|
@@ -1690,7 +1689,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1690
1689
|
} else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
|
|
1691
1690
|
}
|
|
1692
1691
|
_validateEncodingFit(e, t, n) {
|
|
1693
|
-
let r =
|
|
1692
|
+
let r = Pe(t);
|
|
1694
1693
|
if (e <= r) return t;
|
|
1695
1694
|
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
1696
1695
|
this._warnOrFail(i, n);
|
|
@@ -1714,28 +1713,28 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1714
1713
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
1715
1714
|
}
|
|
1716
1715
|
_hintMissingExtension(e, t) {
|
|
1717
|
-
let n =
|
|
1716
|
+
let n = gt.get(e);
|
|
1718
1717
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
1719
1718
|
this._hintedPrefixes.add(e);
|
|
1720
1719
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
1721
1720
|
this._options.onWarning ? this._options.onWarning({
|
|
1722
1721
|
message: r,
|
|
1723
|
-
...
|
|
1722
|
+
...vt(t)
|
|
1724
1723
|
}) : this._options.silent || console.warn(`CDN: ${r}`);
|
|
1725
1724
|
}
|
|
1726
1725
|
_warn(e, t) {
|
|
1727
1726
|
let n = { message: e };
|
|
1728
|
-
if (t !== void 0 && Object.assign(n,
|
|
1727
|
+
if (t !== void 0 && Object.assign(n, vt(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
|
|
1729
1728
|
else if (!this._options.silent) {
|
|
1730
1729
|
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
1731
1730
|
console.warn(`CDN strict violation${n}: ${e}`);
|
|
1732
1731
|
}
|
|
1733
1732
|
}
|
|
1734
1733
|
_fail(e, t) {
|
|
1735
|
-
throw new r(e, t ?
|
|
1734
|
+
throw new r(e, t ? vt(t) : void 0);
|
|
1736
1735
|
}
|
|
1737
1736
|
};
|
|
1738
|
-
function
|
|
1737
|
+
function vt(e) {
|
|
1739
1738
|
return {
|
|
1740
1739
|
offset: e.offset,
|
|
1741
1740
|
line: e.line,
|
|
@@ -1745,7 +1744,7 @@ function _t(e) {
|
|
|
1745
1744
|
}
|
|
1746
1745
|
//#endregion
|
|
1747
1746
|
//#region src/ast/CborTextString.ts
|
|
1748
|
-
var
|
|
1747
|
+
var yt = new TextEncoder(), bt = !1, B = class extends O {
|
|
1749
1748
|
indefiniteLength = !1;
|
|
1750
1749
|
value;
|
|
1751
1750
|
encodingWidth;
|
|
@@ -1757,51 +1756,66 @@ var vt = new TextEncoder(), yt = !1, V = class extends k {
|
|
|
1757
1756
|
e.writeTextString(3, this.value, this.encodingWidth);
|
|
1758
1757
|
}
|
|
1759
1758
|
_toCDN(e, t) {
|
|
1760
|
-
let n =
|
|
1761
|
-
|
|
1762
|
-
let r = this.ednParts.map((e) => xe(e));
|
|
1763
|
-
return r[r.length - 1] += n, ee(r, _(e), t);
|
|
1764
|
-
}
|
|
1765
|
-
return bt(this.value, n, e, t);
|
|
1759
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(yt.encode(this.value).length)));
|
|
1760
|
+
return xt(this.value, n, e, t, this.ednParts);
|
|
1766
1761
|
}
|
|
1767
1762
|
_toJS(e) {
|
|
1768
1763
|
return this.value;
|
|
1769
1764
|
}
|
|
1770
1765
|
};
|
|
1771
|
-
function
|
|
1772
|
-
let
|
|
1773
|
-
if (
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1766
|
+
function xt(e, t, n, r, i) {
|
|
1767
|
+
let { cdn: a, newline: o } = Ct(n), s = ee(n), c = n?.preserveConcatenation && i !== void 0 && i.length > 1 ? i : void 0;
|
|
1768
|
+
if (s === null) return c === void 0 ? Se(e) + t : St(c.map((e) => ({
|
|
1769
|
+
text: e,
|
|
1770
|
+
contentDepth: 0
|
|
1771
|
+
})), t, null, r);
|
|
1772
|
+
if (!a && !o && c === void 0) return Se(e) + t;
|
|
1773
|
+
let l = a ? Et(e) : null;
|
|
1774
|
+
if (l === null && c !== void 0) {
|
|
1775
|
+
let e = [];
|
|
1776
|
+
for (let t of c) if (o) {
|
|
1777
|
+
let n = /* @__PURE__ */ new Map();
|
|
1778
|
+
for (let { point: e, contentDepth: r } of Tt(t, 0)) n.set(e, r);
|
|
1779
|
+
e.push(...Pt(t, n));
|
|
1780
|
+
} else e.push({
|
|
1781
|
+
text: t,
|
|
1782
|
+
contentDepth: 0
|
|
1783
|
+
});
|
|
1784
|
+
return St(e, t, s, r);
|
|
1785
|
+
}
|
|
1786
|
+
let u = /* @__PURE__ */ new Map();
|
|
1787
|
+
if (l !== null) for (let { point: e, contentDepth: t } of l) u.set(e, t);
|
|
1788
|
+
if (o) {
|
|
1789
|
+
let t = l === null ? Tt(e, 0) : Dt(e);
|
|
1790
|
+
for (let { point: e, contentDepth: n } of t) u.has(e) || u.set(e, n);
|
|
1791
|
+
}
|
|
1792
|
+
let d = Pt(e, u);
|
|
1793
|
+
return d.length <= 1 ? Se(e) + t : St(d, t, s, r);
|
|
1794
|
+
}
|
|
1795
|
+
function St(e, t, n, r) {
|
|
1796
|
+
let i = e.map(({ text: n }, r) => {
|
|
1797
|
+
let i = Se(n);
|
|
1798
|
+
return r === e.length - 1 ? i + t : i;
|
|
1799
|
+
});
|
|
1800
|
+
if (n === null) return i.join(" + ");
|
|
1801
|
+
let a = i[0];
|
|
1802
|
+
for (let t = 1; t < i.length; t++) {
|
|
1803
|
+
let o = _(n, r + 1 + e[t].contentDepth);
|
|
1804
|
+
a += ` +\n${o}${i[t]}`;
|
|
1805
|
+
}
|
|
1806
|
+
return a;
|
|
1807
|
+
}
|
|
1808
|
+
function Ct(e) {
|
|
1809
|
+
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ? wt(e?.textStringFormat ?? []) : [];
|
|
1810
|
+
return {
|
|
1811
|
+
cdn: e?.splitCdn ?? t.includes("cdn"),
|
|
1812
|
+
newline: e?.splitNewline ?? t.includes("newline")
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
function wt(e) {
|
|
1816
|
+
return e.map((e) => e === "cboredn" ? (bt || (bt = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
1817
|
+
}
|
|
1818
|
+
function Tt(e, t) {
|
|
1805
1819
|
let n = [];
|
|
1806
1820
|
for (let r = 0; r < e.length; r++) {
|
|
1807
1821
|
let i = e[r];
|
|
@@ -1818,9 +1832,9 @@ function Ct(e, t) {
|
|
|
1818
1832
|
}
|
|
1819
1833
|
return n;
|
|
1820
1834
|
}
|
|
1821
|
-
function
|
|
1835
|
+
function Et(e) {
|
|
1822
1836
|
try {
|
|
1823
|
-
|
|
1837
|
+
at(e);
|
|
1824
1838
|
} catch {
|
|
1825
1839
|
return null;
|
|
1826
1840
|
}
|
|
@@ -1829,24 +1843,24 @@ function wt(e) {
|
|
|
1829
1843
|
let a = n.consume();
|
|
1830
1844
|
if (a.type === "EOF") break;
|
|
1831
1845
|
let c = !1;
|
|
1832
|
-
if (o || (o = !0, a.offset > 0 &&
|
|
1846
|
+
if (o || (o = !0, a.offset > 0 && Mt(n.comments, 0, a.offset) && t.push({
|
|
1833
1847
|
point: a.offset,
|
|
1834
1848
|
contentDepth: r
|
|
1835
1849
|
})), i !== null) {
|
|
1836
|
-
if (i.kind === "opener" &&
|
|
1850
|
+
if (i.kind === "opener" && kt.has(a.type)) {
|
|
1837
1851
|
i.point = a.endOffset, s = a.endOffset;
|
|
1838
1852
|
continue;
|
|
1839
|
-
} else i.kind === "opener" &&
|
|
1853
|
+
} else i.kind === "opener" && jt.has(a.type) && Nt(e, i.point, a.offset) ? c = !0 : t.push({
|
|
1840
1854
|
point: a.offset,
|
|
1841
1855
|
contentDepth: i.contentDepth
|
|
1842
1856
|
});
|
|
1843
1857
|
i = null;
|
|
1844
1858
|
}
|
|
1845
|
-
|
|
1859
|
+
At.has(a.type) ? (r++, i = {
|
|
1846
1860
|
point: a.endOffset,
|
|
1847
1861
|
contentDepth: r,
|
|
1848
1862
|
kind: "opener"
|
|
1849
|
-
}) :
|
|
1863
|
+
}) : jt.has(a.type) ? (r = Math.max(0, r - 1), c || t.push({
|
|
1850
1864
|
point: a.offset,
|
|
1851
1865
|
contentDepth: r
|
|
1852
1866
|
})) : a.type === "COMMA" && (i = {
|
|
@@ -1861,23 +1875,23 @@ function wt(e) {
|
|
|
1861
1875
|
contentDepth: r
|
|
1862
1876
|
}), t;
|
|
1863
1877
|
}
|
|
1864
|
-
function
|
|
1878
|
+
function Dt(e) {
|
|
1865
1879
|
let t = [], n = new a(e), r = 0;
|
|
1866
1880
|
for (;;) {
|
|
1867
1881
|
let i = n.consume();
|
|
1868
1882
|
if (i.type === "EOF") break;
|
|
1869
|
-
if (
|
|
1870
|
-
else if (
|
|
1883
|
+
if (At.has(i.type)) r++;
|
|
1884
|
+
else if (jt.has(i.type)) r = Math.max(0, r - 1);
|
|
1871
1885
|
else if (i.type !== "COMMA") {
|
|
1872
1886
|
if (i.type === "TSTR") {
|
|
1873
1887
|
let n = e.slice(i.offset, i.endOffset);
|
|
1874
|
-
for (let e of
|
|
1888
|
+
for (let e of Ot(n)) t.push({
|
|
1875
1889
|
point: i.offset + e,
|
|
1876
1890
|
contentDepth: r + 1
|
|
1877
1891
|
});
|
|
1878
1892
|
} else if (i.type === "RAWSTRING") {
|
|
1879
1893
|
let n = e.slice(i.offset, i.endOffset);
|
|
1880
|
-
for (let { point: e } of
|
|
1894
|
+
for (let { point: e } of Tt(n, 0)) t.push({
|
|
1881
1895
|
point: i.offset + e,
|
|
1882
1896
|
contentDepth: r + 1
|
|
1883
1897
|
});
|
|
@@ -1886,7 +1900,7 @@ function Tt(e) {
|
|
|
1886
1900
|
}
|
|
1887
1901
|
return t;
|
|
1888
1902
|
}
|
|
1889
|
-
function
|
|
1903
|
+
function Ot(e) {
|
|
1890
1904
|
let t = [], n = 1, r = e.length - 1;
|
|
1891
1905
|
for (; n < r;) {
|
|
1892
1906
|
let r = e[n];
|
|
@@ -1902,24 +1916,24 @@ function Et(e) {
|
|
|
1902
1916
|
}
|
|
1903
1917
|
return t;
|
|
1904
1918
|
}
|
|
1905
|
-
var
|
|
1919
|
+
var kt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), At = /* @__PURE__ */ new Set([
|
|
1906
1920
|
"LBRACKET",
|
|
1907
1921
|
"LBRACE",
|
|
1908
1922
|
"LPAREN",
|
|
1909
1923
|
"LT_LT"
|
|
1910
|
-
]),
|
|
1924
|
+
]), jt = /* @__PURE__ */ new Set([
|
|
1911
1925
|
"RBRACKET",
|
|
1912
1926
|
"RBRACE",
|
|
1913
1927
|
"RPAREN",
|
|
1914
1928
|
"GT_GT"
|
|
1915
1929
|
]);
|
|
1916
|
-
function
|
|
1930
|
+
function Mt(e, t, n) {
|
|
1917
1931
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
1918
1932
|
}
|
|
1919
|
-
function
|
|
1933
|
+
function Nt(e, t, n) {
|
|
1920
1934
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
1921
1935
|
}
|
|
1922
|
-
function
|
|
1936
|
+
function Pt(e, t) {
|
|
1923
1937
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
1924
1938
|
if (n.length === 0) return [{
|
|
1925
1939
|
text: e,
|
|
@@ -1937,7 +1951,7 @@ function Mt(e, t) {
|
|
|
1937
1951
|
}
|
|
1938
1952
|
//#endregion
|
|
1939
1953
|
//#region src/extensions/dt.ts
|
|
1940
|
-
function
|
|
1954
|
+
function V(e) {
|
|
1941
1955
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
1942
1956
|
let t = Math.round(e * 1e3);
|
|
1943
1957
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -1945,17 +1959,17 @@ function Nt(e) {
|
|
|
1945
1959
|
for (; s.length < 3;) s += "0";
|
|
1946
1960
|
return `${i}.${s}Z`;
|
|
1947
1961
|
}
|
|
1948
|
-
var
|
|
1949
|
-
function
|
|
1962
|
+
var Ft = new TextDecoder("utf-8", { fatal: !0 });
|
|
1963
|
+
function It(e) {
|
|
1950
1964
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
1951
1965
|
let t = e[0];
|
|
1952
|
-
if (t instanceof
|
|
1953
|
-
if (t instanceof
|
|
1966
|
+
if (t instanceof B) return t.value;
|
|
1967
|
+
if (t instanceof N) return Ft.decode(t.value);
|
|
1954
1968
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
1955
1969
|
}
|
|
1956
|
-
var
|
|
1957
|
-
function
|
|
1958
|
-
if (!
|
|
1970
|
+
var Lt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
1971
|
+
function Rt(e, t) {
|
|
1972
|
+
if (!Lt.test(e)) {
|
|
1959
1973
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
1960
1974
|
if (t) t(n);
|
|
1961
1975
|
else throw SyntaxError(n);
|
|
@@ -1966,93 +1980,93 @@ function Lt(e, t) {
|
|
|
1966
1980
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
1967
1981
|
if (i === void 0) {
|
|
1968
1982
|
let e = a / 1e3;
|
|
1969
|
-
return e >= 0 ? new
|
|
1983
|
+
return e >= 0 ? new Bt(BigInt(e)) : new Vt(BigInt(e));
|
|
1970
1984
|
}
|
|
1971
|
-
return new
|
|
1985
|
+
return new Ht(a / 1e3 + i);
|
|
1972
1986
|
}
|
|
1973
|
-
var
|
|
1987
|
+
var zt = 1n, Bt = class extends k {
|
|
1974
1988
|
constructor(e, t) {
|
|
1975
1989
|
super(e, t);
|
|
1976
1990
|
}
|
|
1977
1991
|
_toCDN(e, t) {
|
|
1978
1992
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1979
|
-
let n =
|
|
1980
|
-
return `dt'${
|
|
1993
|
+
let n = x(e, this.encodingWidth, () => b(this.value));
|
|
1994
|
+
return `dt'${V(Number(this.value))}'${n}`;
|
|
1981
1995
|
}
|
|
1982
|
-
},
|
|
1996
|
+
}, Vt = class extends A {
|
|
1983
1997
|
constructor(e, t) {
|
|
1984
1998
|
super(e, t);
|
|
1985
1999
|
}
|
|
1986
2000
|
_toCDN(e, t) {
|
|
1987
2001
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1988
|
-
let n =
|
|
1989
|
-
return `dt'${
|
|
2002
|
+
let n = x(e, this.encodingWidth, () => b(this.argument));
|
|
2003
|
+
return `dt'${V(Number(this.value))}'${n}`;
|
|
1990
2004
|
}
|
|
1991
|
-
},
|
|
2005
|
+
}, Ht = class extends j {
|
|
1992
2006
|
constructor(e, t) {
|
|
1993
2007
|
super(e, t);
|
|
1994
2008
|
}
|
|
1995
2009
|
_toCDN(e, t) {
|
|
1996
2010
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1997
|
-
let n =
|
|
1998
|
-
return `dt'${
|
|
2011
|
+
let n = D(this.value), r = we(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
2012
|
+
return `dt'${V(this.value)}'${r}`;
|
|
1999
2013
|
}
|
|
2000
|
-
},
|
|
2014
|
+
}, Ut = class extends M {
|
|
2001
2015
|
constructor(e, t) {
|
|
2002
|
-
super(
|
|
2016
|
+
super(zt, typeof e == "string" ? Rt(e) : e, t);
|
|
2003
2017
|
}
|
|
2004
2018
|
_toCDN(e, t) {
|
|
2005
2019
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2006
2020
|
let n = this.content;
|
|
2007
|
-
if (n instanceof
|
|
2021
|
+
if (n instanceof j ? n.precision !== void 0 && n.precision !== D(n.value) : n.encodingWidth !== void 0) return super._toCDN({
|
|
2008
2022
|
...e,
|
|
2009
2023
|
appStrings: !1
|
|
2010
2024
|
}, t);
|
|
2011
|
-
let r = n instanceof
|
|
2012
|
-
return `DT'${
|
|
2025
|
+
let r = n instanceof j ? n.value : Number(n.value), i = x(e, this.encodingWidth, () => b(zt));
|
|
2026
|
+
return `DT'${V(r)}'${i}`;
|
|
2013
2027
|
}
|
|
2014
|
-
},
|
|
2028
|
+
}, Wt = class extends Ut {
|
|
2015
2029
|
constructor(e, t) {
|
|
2016
2030
|
super(e, t);
|
|
2017
2031
|
}
|
|
2018
2032
|
_toJS(e) {
|
|
2019
|
-
let t = this.content, n = t instanceof
|
|
2033
|
+
let t = this.content, n = t instanceof j ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
2020
2034
|
return new Date(n);
|
|
2021
2035
|
}
|
|
2022
2036
|
};
|
|
2023
|
-
function
|
|
2037
|
+
function Gt(e) {
|
|
2024
2038
|
let t = e?.jsDate ?? !1;
|
|
2025
2039
|
function n(e) {
|
|
2026
|
-
return t ? new
|
|
2040
|
+
return t ? new Wt(e) : new Ut(e);
|
|
2027
2041
|
}
|
|
2028
2042
|
let r = {
|
|
2029
2043
|
appStringPrefixes: ["dt", "DT"],
|
|
2030
|
-
tagNumbers: [
|
|
2044
|
+
tagNumbers: [zt],
|
|
2031
2045
|
parseAppString(e, t, r) {
|
|
2032
|
-
return e === "DT" ? n(t) :
|
|
2046
|
+
return e === "DT" ? n(t) : Rt(t, r);
|
|
2033
2047
|
},
|
|
2034
2048
|
parseAppSequence(e, t, r) {
|
|
2035
|
-
let i =
|
|
2036
|
-
return e === "DT" ? n(i) :
|
|
2049
|
+
let i = It(t);
|
|
2050
|
+
return e === "DT" ? n(i) : Rt(i, r);
|
|
2037
2051
|
},
|
|
2038
2052
|
parseTag(e, n) {
|
|
2039
2053
|
if (e !== 1n) return;
|
|
2040
2054
|
let r;
|
|
2041
|
-
if (n instanceof
|
|
2042
|
-
else if (n instanceof
|
|
2043
|
-
else if (n instanceof
|
|
2055
|
+
if (n instanceof k) r = new Bt(n.value, { encodingWidth: n.encodingWidth });
|
|
2056
|
+
else if (n instanceof A) r = new Vt(n.value, { encodingWidth: n.encodingWidth });
|
|
2057
|
+
else if (n instanceof j) r = new Ht(n.value), n.precision !== void 0 && (r.precision = n.precision);
|
|
2044
2058
|
else return;
|
|
2045
|
-
return r.start = n.start, r.end = n.end, t ? new
|
|
2059
|
+
return r.start = n.start, r.end = n.end, t ? new Wt(r) : new Ut(r);
|
|
2046
2060
|
}
|
|
2047
2061
|
};
|
|
2048
2062
|
return t && (r.fromJS = (e, t) => {
|
|
2049
|
-
if (e instanceof Date) return new
|
|
2063
|
+
if (e instanceof Date) return new Wt(V(e.getTime() / 1e3));
|
|
2050
2064
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2051
2065
|
}
|
|
2052
|
-
var
|
|
2066
|
+
var Kt = Gt(), qt = Gt({ jsDate: !0 });
|
|
2053
2067
|
//#endregion
|
|
2054
2068
|
//#region src/utils/ip.ts
|
|
2055
|
-
function
|
|
2069
|
+
function Jt(e) {
|
|
2056
2070
|
let t = e.split(".");
|
|
2057
2071
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2058
2072
|
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
@@ -2065,11 +2079,11 @@ function qt(e) {
|
|
|
2065
2079
|
}
|
|
2066
2080
|
return n;
|
|
2067
2081
|
}
|
|
2068
|
-
function
|
|
2082
|
+
function Yt(e) {
|
|
2069
2083
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
2070
2084
|
if (e === "::") return t;
|
|
2071
2085
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
2072
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
2086
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Jt(i[2]));
|
|
2073
2087
|
let a = n.split("::");
|
|
2074
2088
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2075
2089
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -2086,11 +2100,11 @@ function Jt(e) {
|
|
|
2086
2100
|
}
|
|
2087
2101
|
return r && t.set(r, 12), t;
|
|
2088
2102
|
}
|
|
2089
|
-
function
|
|
2103
|
+
function Xt(e) {
|
|
2090
2104
|
return Array.from(e).join(".");
|
|
2091
2105
|
}
|
|
2092
|
-
function
|
|
2093
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2106
|
+
function Zt(e) {
|
|
2107
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Xt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
2094
2108
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2095
2109
|
let i = -1, a = 0, o = 0;
|
|
2096
2110
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2104,29 +2118,29 @@ function Xt(e) {
|
|
|
2104
2118
|
}
|
|
2105
2119
|
//#endregion
|
|
2106
2120
|
//#region src/extensions/ip.ts
|
|
2107
|
-
var
|
|
2108
|
-
function
|
|
2121
|
+
var Qt = "ip", H = "IP", U = 52n, $t = 54n, en = new TextDecoder("utf-8", { fatal: !0 });
|
|
2122
|
+
function tn(e) {
|
|
2109
2123
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2110
2124
|
let t = e[0];
|
|
2111
|
-
if (t instanceof
|
|
2112
|
-
if (t instanceof
|
|
2125
|
+
if (t instanceof B) return t.value;
|
|
2126
|
+
if (t instanceof N) return en.decode(t.value);
|
|
2113
2127
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2114
2128
|
}
|
|
2115
|
-
function
|
|
2129
|
+
function nn(e) {
|
|
2116
2130
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2117
|
-
bytes:
|
|
2131
|
+
bytes: Jt(e),
|
|
2118
2132
|
isV4: !0
|
|
2119
2133
|
} : {
|
|
2120
|
-
bytes:
|
|
2134
|
+
bytes: Yt(e),
|
|
2121
2135
|
isV4: !1
|
|
2122
2136
|
};
|
|
2123
2137
|
}
|
|
2124
|
-
function
|
|
2125
|
-
if (e.length === 4) return
|
|
2126
|
-
if (e.length === 16) return
|
|
2138
|
+
function rn(e) {
|
|
2139
|
+
if (e.length === 4) return Xt(e);
|
|
2140
|
+
if (e.length === 16) return Zt(e);
|
|
2127
2141
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2128
2142
|
}
|
|
2129
|
-
function
|
|
2143
|
+
function an(e, t) {
|
|
2130
2144
|
let n = new Uint8Array(e.length);
|
|
2131
2145
|
n.set(e);
|
|
2132
2146
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2136,86 +2150,86 @@ function rn(e, t) {
|
|
|
2136
2150
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2137
2151
|
return n.slice(0, a);
|
|
2138
2152
|
}
|
|
2139
|
-
function
|
|
2153
|
+
function on(e, t) {
|
|
2140
2154
|
let n = new Uint8Array(t);
|
|
2141
2155
|
return n.set(e), n;
|
|
2142
2156
|
}
|
|
2143
|
-
var
|
|
2157
|
+
var sn = class extends N {
|
|
2144
2158
|
_toCDN(e, t) {
|
|
2145
2159
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2146
|
-
let n =
|
|
2147
|
-
return `${
|
|
2160
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(this.value.length)));
|
|
2161
|
+
return `${Qt}'${rn(this.value)}'${n}`;
|
|
2148
2162
|
}
|
|
2149
|
-
},
|
|
2163
|
+
}, cn = class extends I {
|
|
2150
2164
|
_isV4;
|
|
2151
2165
|
constructor(e, t, n) {
|
|
2152
|
-
super([new
|
|
2166
|
+
super([new k(BigInt(e)), new N(t)]), this._isV4 = n;
|
|
2153
2167
|
}
|
|
2154
2168
|
_toCDN(e, t) {
|
|
2155
2169
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2156
2170
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2157
|
-
return `${
|
|
2171
|
+
return `${Qt}'${rn(on(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2158
2172
|
}
|
|
2159
|
-
},
|
|
2173
|
+
}, ln = class extends M {
|
|
2160
2174
|
constructor(e, t) {
|
|
2161
2175
|
super(e, t);
|
|
2162
2176
|
}
|
|
2163
2177
|
_toCDN(e, t) {
|
|
2164
2178
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2165
2179
|
let n = this.tag === U ? 4 : 16, r = this.content;
|
|
2166
|
-
if (r instanceof
|
|
2180
|
+
if (r instanceof N) {
|
|
2167
2181
|
if (r.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2168
|
-
let n =
|
|
2169
|
-
return `${H}'${
|
|
2182
|
+
let n = x(e, this.encodingWidth, () => b(this.tag));
|
|
2183
|
+
return `${H}'${rn(r.value)}'${n}`;
|
|
2170
2184
|
}
|
|
2171
|
-
if (r instanceof
|
|
2185
|
+
if (r instanceof I && r.items.length === 2 && r.items[0] instanceof k && r.items[1] instanceof N) {
|
|
2172
2186
|
if (r.encodingWidth !== void 0 || r.items[0].encodingWidth !== void 0 || r.items[1].encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2173
|
-
let i = Number(r.items[0].value), a =
|
|
2174
|
-
return `${H}'${
|
|
2187
|
+
let i = Number(r.items[0].value), a = on(r.items[1].value, n), o = x(e, this.encodingWidth, () => b(this.tag));
|
|
2188
|
+
return `${H}'${rn(a)}/${i}'${o}`;
|
|
2175
2189
|
}
|
|
2176
2190
|
return super._toCDN(e, t);
|
|
2177
2191
|
}
|
|
2178
2192
|
};
|
|
2179
|
-
function
|
|
2193
|
+
function un(e, t) {
|
|
2180
2194
|
let n = t.indexOf("/");
|
|
2181
2195
|
if (n === -1) {
|
|
2182
|
-
let { bytes: n, isV4: r } =
|
|
2183
|
-
return e === H ? new
|
|
2196
|
+
let { bytes: n, isV4: r } = nn(t);
|
|
2197
|
+
return e === H ? new ln(r ? U : $t, new N(n)) : new sn(n);
|
|
2184
2198
|
}
|
|
2185
2199
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2186
2200
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2187
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2201
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = nn(r), c = s ? 32 : 128;
|
|
2188
2202
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2189
|
-
let l =
|
|
2190
|
-
return e === H ? new
|
|
2203
|
+
let l = an(o, a);
|
|
2204
|
+
return e === H ? new ln(s ? U : $t, new I([new k(BigInt(a)), new N(l)])) : new cn(a, l, s);
|
|
2191
2205
|
}
|
|
2192
|
-
var
|
|
2193
|
-
appStringPrefixes: [
|
|
2194
|
-
tagNumbers: [U,
|
|
2206
|
+
var dn = {
|
|
2207
|
+
appStringPrefixes: [Qt, H],
|
|
2208
|
+
tagNumbers: [U, $t],
|
|
2195
2209
|
parseAppString(e, t) {
|
|
2196
|
-
return
|
|
2210
|
+
return un(e, t);
|
|
2197
2211
|
},
|
|
2198
2212
|
parseAppSequence(e, t) {
|
|
2199
|
-
return
|
|
2213
|
+
return un(e, tn(t));
|
|
2200
2214
|
},
|
|
2201
2215
|
parseTag(e, t) {
|
|
2202
|
-
if (!(e !== U && e !==
|
|
2216
|
+
if (!(e !== U && e !== $t) && (t instanceof N || t instanceof I)) return new ln(e, t);
|
|
2203
2217
|
}
|
|
2204
|
-
},
|
|
2205
|
-
tagNumbers: [
|
|
2218
|
+
}, fn = 18446744073709551615n, pn = -18446744073709551616n, mn = {
|
|
2219
|
+
tagNumbers: [Je, Ye],
|
|
2206
2220
|
parseTag(e, t) {
|
|
2207
|
-
if (t instanceof
|
|
2221
|
+
if (t instanceof N) {
|
|
2208
2222
|
if (e === 2n) {
|
|
2209
|
-
let e =
|
|
2210
|
-
return e >
|
|
2223
|
+
let e = $e(t.value);
|
|
2224
|
+
return e > fn ? new et(e) : void 0;
|
|
2211
2225
|
}
|
|
2212
2226
|
if (e === 3n) {
|
|
2213
|
-
let e = -1n -
|
|
2214
|
-
return e <
|
|
2227
|
+
let e = -1n - $e(t.value);
|
|
2228
|
+
return e < pn ? new tt(e) : void 0;
|
|
2215
2229
|
}
|
|
2216
2230
|
}
|
|
2217
2231
|
}
|
|
2218
|
-
},
|
|
2232
|
+
}, hn = "cri", gn = "CRI", _n = 99n, vn = /* @__PURE__ */ new Map([
|
|
2219
2233
|
["coap", -1n],
|
|
2220
2234
|
["coaps", -2n],
|
|
2221
2235
|
["http", -3n],
|
|
@@ -2226,7 +2240,7 @@ var un = {
|
|
|
2226
2240
|
["coaps+tcp", -8n],
|
|
2227
2241
|
["coap+ws", -25n],
|
|
2228
2242
|
["coaps+ws", -26n]
|
|
2229
|
-
]),
|
|
2243
|
+
]), yn = new Map([...vn.entries()].map(([e, t]) => [t, e]));
|
|
2230
2244
|
function W(e) {
|
|
2231
2245
|
try {
|
|
2232
2246
|
return decodeURIComponent(e);
|
|
@@ -2234,39 +2248,39 @@ function W(e) {
|
|
|
2234
2248
|
return e;
|
|
2235
2249
|
}
|
|
2236
2250
|
}
|
|
2237
|
-
var
|
|
2238
|
-
function
|
|
2239
|
-
return Array.from(
|
|
2251
|
+
var bn = new TextEncoder(), xn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2252
|
+
function Sn(e) {
|
|
2253
|
+
return Array.from(bn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2240
2254
|
}
|
|
2241
2255
|
function G(e, t) {
|
|
2242
2256
|
let n = "";
|
|
2243
|
-
for (let r of e) n += t(r) ? r :
|
|
2257
|
+
for (let r of e) n += t(r) ? r : Sn(r);
|
|
2244
2258
|
return n;
|
|
2245
2259
|
}
|
|
2246
|
-
function Sn(e) {
|
|
2247
|
-
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2248
|
-
}
|
|
2249
2260
|
function Cn(e) {
|
|
2250
|
-
return /[
|
|
2261
|
+
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2251
2262
|
}
|
|
2252
2263
|
function wn(e) {
|
|
2253
|
-
return
|
|
2264
|
+
return /[!$&'()*+,;=]/.test(e);
|
|
2254
2265
|
}
|
|
2255
2266
|
function Tn(e) {
|
|
2256
|
-
return (wn(e) || e === "
|
|
2267
|
+
return Cn(e) || wn(e) || e === ":" || e === "@";
|
|
2257
2268
|
}
|
|
2258
2269
|
function En(e) {
|
|
2259
|
-
return
|
|
2270
|
+
return (Tn(e) || e === "/" || e === "?") && e !== "&";
|
|
2260
2271
|
}
|
|
2261
2272
|
function Dn(e) {
|
|
2262
|
-
return
|
|
2273
|
+
return Tn(e) || e === "/" || e === "?";
|
|
2263
2274
|
}
|
|
2264
2275
|
function On(e) {
|
|
2265
|
-
return
|
|
2276
|
+
return Cn(e) || wn(e) || e === ":";
|
|
2266
2277
|
}
|
|
2267
2278
|
function kn(e) {
|
|
2279
|
+
return Cn(e) || wn(e);
|
|
2280
|
+
}
|
|
2281
|
+
function An(e) {
|
|
2268
2282
|
let t = [], n = e, r = n.indexOf("@");
|
|
2269
|
-
r >= 0 && (t.push(
|
|
2283
|
+
r >= 0 && (t.push(R.FALSE), t.push(new B(W(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2270
2284
|
let i, a = null;
|
|
2271
2285
|
if (n.startsWith("[")) {
|
|
2272
2286
|
let e = n.indexOf("]");
|
|
@@ -2275,162 +2289,162 @@ function kn(e) {
|
|
|
2275
2289
|
let r = n.slice(e + 1);
|
|
2276
2290
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2277
2291
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2278
|
-
t.push(new
|
|
2292
|
+
t.push(new N(Yt(i)));
|
|
2279
2293
|
} else {
|
|
2280
2294
|
let e = n.lastIndexOf(":");
|
|
2281
|
-
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
|
|
2282
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new
|
|
2295
|
+
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 N(Jt(i)));
|
|
2296
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new B(e));
|
|
2283
2297
|
}
|
|
2284
2298
|
if (a !== null && a !== "") {
|
|
2285
2299
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2286
2300
|
let e = parseInt(a, 10);
|
|
2287
2301
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2288
|
-
t.push(new
|
|
2302
|
+
t.push(new k(BigInt(e)));
|
|
2289
2303
|
}
|
|
2290
|
-
return new
|
|
2304
|
+
return new I(t);
|
|
2291
2305
|
}
|
|
2292
|
-
function
|
|
2306
|
+
function jn(e) {
|
|
2293
2307
|
let t = e.items, n = 0, r = "";
|
|
2294
|
-
if (n < t.length && t[n] instanceof
|
|
2308
|
+
if (n < t.length && t[n] instanceof R && t[n].value === 20) {
|
|
2295
2309
|
n++;
|
|
2296
2310
|
let e = t[n++];
|
|
2297
|
-
r += G(e.value,
|
|
2311
|
+
r += G(e.value, On) + "@";
|
|
2298
2312
|
}
|
|
2299
2313
|
if (n >= t.length) return r;
|
|
2300
2314
|
let i = t[n];
|
|
2301
|
-
if (i instanceof
|
|
2315
|
+
if (i instanceof N) {
|
|
2302
2316
|
n++;
|
|
2303
2317
|
let { length: e } = i.value;
|
|
2304
|
-
if (e === 4) r +=
|
|
2305
|
-
else if (e === 16) r += "[" +
|
|
2318
|
+
if (e === 4) r += Xt(i.value);
|
|
2319
|
+
else if (e === 16) r += "[" + Zt(i.value) + "]";
|
|
2306
2320
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2307
|
-
n < t.length && t[n] instanceof
|
|
2321
|
+
n < t.length && t[n] instanceof B && (r += `%25${G(t[n++].value, kn)}`);
|
|
2308
2322
|
} else {
|
|
2309
2323
|
let e = [];
|
|
2310
|
-
for (; n < t.length && t[n] instanceof
|
|
2324
|
+
for (; n < t.length && t[n] instanceof B;) e.push(G(t[n++].value, kn));
|
|
2311
2325
|
r += e.join(".");
|
|
2312
2326
|
}
|
|
2313
|
-
return n < t.length && t[n] instanceof
|
|
2327
|
+
return n < t.length && t[n] instanceof k && (r += ":" + t[n].value.toString()), r;
|
|
2314
2328
|
}
|
|
2315
|
-
function
|
|
2329
|
+
function Mn(e) {
|
|
2316
2330
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2317
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
2318
|
-
authority:
|
|
2331
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new B(W(e)))) : (r = t, i = []), {
|
|
2332
|
+
authority: An(r),
|
|
2319
2333
|
pathSegments: i
|
|
2320
2334
|
};
|
|
2321
2335
|
}
|
|
2322
|
-
function
|
|
2336
|
+
function Nn(e) {
|
|
2323
2337
|
let t = e, n = null, r = t.indexOf("#");
|
|
2324
2338
|
r >= 0 && (n = W(t.slice(r + 1)), t = t.slice(0, r));
|
|
2325
2339
|
let i = null, a = t.indexOf("?");
|
|
2326
2340
|
if (a >= 0) {
|
|
2327
2341
|
let e = t.slice(a + 1);
|
|
2328
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2342
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new B(W(e)));
|
|
2329
2343
|
}
|
|
2330
2344
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2331
2345
|
if (s) {
|
|
2332
|
-
let e = s[1].toLowerCase(), t = s[2], n =
|
|
2333
|
-
if (o.push(n === void 0 ? new
|
|
2334
|
-
let { authority: e, pathSegments: n } =
|
|
2335
|
-
o.push(e, new
|
|
2346
|
+
let e = s[1].toLowerCase(), t = s[2], n = vn.get(e);
|
|
2347
|
+
if (o.push(n === void 0 ? new B(e) : new A(n)), t.startsWith("//")) {
|
|
2348
|
+
let { authority: e, pathSegments: n } = Mn(t);
|
|
2349
|
+
o.push(e, new I(n));
|
|
2336
2350
|
} else if (t.startsWith("/")) {
|
|
2337
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2338
|
-
o.push(
|
|
2351
|
+
let e = t.slice(1).split("/").map((e) => new B(W(e)));
|
|
2352
|
+
o.push(R.NULL, new I(e));
|
|
2339
2353
|
} else {
|
|
2340
|
-
let e = t.split("/").map((e) => new
|
|
2341
|
-
o.push(
|
|
2354
|
+
let e = t.split("/").map((e) => new B(W(e)));
|
|
2355
|
+
o.push(R.TRUE, new I(e));
|
|
2342
2356
|
}
|
|
2343
2357
|
} else if (t.startsWith("//")) {
|
|
2344
|
-
let { authority: e, pathSegments: n } =
|
|
2345
|
-
o.push(
|
|
2358
|
+
let { authority: e, pathSegments: n } = Mn(t);
|
|
2359
|
+
o.push(R.FALSE, e, new I(n));
|
|
2346
2360
|
} else if (t.startsWith("/")) {
|
|
2347
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2348
|
-
o.push(
|
|
2349
|
-
} else if (t === "") o.push(new
|
|
2361
|
+
let e = t.slice(1).split("/").map((e) => new B(W(e)));
|
|
2362
|
+
o.push(R.TRUE, new I(e));
|
|
2363
|
+
} else if (t === "") o.push(new k(0n));
|
|
2350
2364
|
else {
|
|
2351
2365
|
let n = 1n, r = t, i = !1;
|
|
2352
2366
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2353
2367
|
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)}`);
|
|
2354
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
2355
|
-
o.push(new
|
|
2368
|
+
let a = r === "" ? [] : r.split("/").map((e) => new B(W(e)));
|
|
2369
|
+
o.push(new k(n), new I(a));
|
|
2356
2370
|
}
|
|
2357
|
-
if (i !== null && o.push(new
|
|
2371
|
+
if (i !== null && o.push(new I(i)), n !== null && (i === null && o.push(R.NULL), o.push(new B(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2358
2372
|
let e = o[o.length - 1];
|
|
2359
|
-
e instanceof
|
|
2373
|
+
e instanceof I && e.items.length === 0 && o.pop();
|
|
2360
2374
|
}
|
|
2361
|
-
return o.length === 1 && o[0] instanceof
|
|
2375
|
+
return o.length === 1 && o[0] instanceof k && o[0].value === 0n ? [] : o;
|
|
2362
2376
|
}
|
|
2363
2377
|
function K(e, t) {
|
|
2364
2378
|
let n = t, r = "";
|
|
2365
2379
|
if (n < e.length) {
|
|
2366
2380
|
let t = e[n];
|
|
2367
|
-
if (t instanceof
|
|
2381
|
+
if (t instanceof I) {
|
|
2368
2382
|
if (n++, t.items.length > 0) {
|
|
2369
2383
|
let e = t.items.map((e) => {
|
|
2370
|
-
if (!(e instanceof
|
|
2371
|
-
return G(e.value,
|
|
2384
|
+
if (!(e instanceof B)) throw Error("cri: query item must be a text string");
|
|
2385
|
+
return G(e.value, En);
|
|
2372
2386
|
});
|
|
2373
2387
|
r += "?" + e.join("&");
|
|
2374
2388
|
}
|
|
2375
|
-
} else t instanceof
|
|
2389
|
+
} else t instanceof R && t.value === 22 && n++;
|
|
2376
2390
|
}
|
|
2377
|
-
return n < e.length && e[n] instanceof
|
|
2391
|
+
return n < e.length && e[n] instanceof B && (r += "#" + G(e[n].value, Dn)), r;
|
|
2378
2392
|
}
|
|
2379
|
-
function
|
|
2393
|
+
function Pn(e) {
|
|
2380
2394
|
return e.items.map((e) => {
|
|
2381
|
-
if (!(e instanceof
|
|
2382
|
-
return G(e.value,
|
|
2395
|
+
if (!(e instanceof B)) throw Error("cri: path segment must be a text string");
|
|
2396
|
+
return G(e.value, Tn);
|
|
2383
2397
|
});
|
|
2384
2398
|
}
|
|
2385
|
-
function
|
|
2399
|
+
function Fn(e) {
|
|
2386
2400
|
if (e.length === 0) return "";
|
|
2387
2401
|
let t = 0, n = e[t++];
|
|
2388
|
-
if (n instanceof
|
|
2402
|
+
if (n instanceof A || n instanceof B) {
|
|
2389
2403
|
let r;
|
|
2390
|
-
if (n instanceof
|
|
2391
|
-
let e =
|
|
2404
|
+
if (n instanceof A) {
|
|
2405
|
+
let e = yn.get(n.value);
|
|
2392
2406
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2393
2407
|
r = e + ":";
|
|
2394
2408
|
} else r = n.value + ":";
|
|
2395
2409
|
if (t >= e.length) return r;
|
|
2396
2410
|
let i = e[t++], a = "", o = !1;
|
|
2397
|
-
if (i instanceof
|
|
2398
|
-
else if (i instanceof
|
|
2411
|
+
if (i instanceof I) a = "//" + jn(i), o = !0;
|
|
2412
|
+
else if (i instanceof R) if (i.value === 22) o = !0;
|
|
2399
2413
|
else if (i.value === 21) o = !1;
|
|
2400
2414
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2401
2415
|
else throw Error("cri: unexpected type for authority element");
|
|
2402
2416
|
let s = "";
|
|
2403
|
-
if (t < e.length && e[t] instanceof
|
|
2417
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2404
2418
|
let n = e[t++];
|
|
2405
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
2419
|
+
n.items.length > 0 && (s = (o ? "/" : "") + Pn(n).join("/"));
|
|
2406
2420
|
}
|
|
2407
2421
|
return r + a + s + K(e, t);
|
|
2408
2422
|
}
|
|
2409
|
-
if (n instanceof
|
|
2410
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2411
|
-
let n =
|
|
2412
|
-
if (t < e.length && e[t] instanceof
|
|
2423
|
+
if (n instanceof R && n.value === 20) {
|
|
2424
|
+
if (t >= e.length || !(e[t] instanceof I)) throw Error("cri: network-path reference requires an authority array");
|
|
2425
|
+
let n = jn(e[t++]), r = "";
|
|
2426
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2413
2427
|
let n = e[t++];
|
|
2414
|
-
n.items.length > 0 && (r = "/" +
|
|
2428
|
+
n.items.length > 0 && (r = "/" + Pn(n).join("/"));
|
|
2415
2429
|
}
|
|
2416
2430
|
return "//" + n + r + K(e, t);
|
|
2417
2431
|
}
|
|
2418
|
-
if (n instanceof
|
|
2432
|
+
if (n instanceof R && n.value === 21) {
|
|
2419
2433
|
let n = "/";
|
|
2420
|
-
if (t < e.length && e[t] instanceof
|
|
2434
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2421
2435
|
let r = e[t++];
|
|
2422
|
-
n = "/" +
|
|
2436
|
+
n = "/" + Pn(r).join("/");
|
|
2423
2437
|
}
|
|
2424
2438
|
return n + K(e, t);
|
|
2425
2439
|
}
|
|
2426
|
-
if (n instanceof
|
|
2440
|
+
if (n instanceof k) {
|
|
2427
2441
|
let r = n.value;
|
|
2428
2442
|
if (r === 0n) return K(e, t);
|
|
2429
2443
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2430
|
-
if (t < e.length && e[t] instanceof
|
|
2444
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2431
2445
|
let n = e[t++];
|
|
2432
2446
|
if (n.items.length > 0) {
|
|
2433
|
-
let e =
|
|
2447
|
+
let e = Pn(n);
|
|
2434
2448
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2435
2449
|
} else a = i === "" ? "./" : i;
|
|
2436
2450
|
} else a = i === "" ? "./" : i;
|
|
@@ -2438,86 +2452,86 @@ function Pn(e) {
|
|
|
2438
2452
|
}
|
|
2439
2453
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2440
2454
|
}
|
|
2441
|
-
var
|
|
2455
|
+
var In = class extends I {
|
|
2442
2456
|
_toCDN(e, t) {
|
|
2443
2457
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2444
2458
|
try {
|
|
2445
|
-
let t =
|
|
2446
|
-
return `${
|
|
2459
|
+
let t = x(e, this.encodingWidth, () => b(BigInt(this.items.length)));
|
|
2460
|
+
return `${hn}'${Fn(this.items)}'${t}`;
|
|
2447
2461
|
} catch {
|
|
2448
2462
|
return super._toCDN(e, t);
|
|
2449
2463
|
}
|
|
2450
2464
|
}
|
|
2451
|
-
},
|
|
2465
|
+
}, Ln = class extends M {
|
|
2452
2466
|
constructor(e) {
|
|
2453
|
-
super(
|
|
2467
|
+
super(_n, e);
|
|
2454
2468
|
}
|
|
2455
2469
|
_toCDN(e, t) {
|
|
2456
2470
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2457
2471
|
try {
|
|
2458
2472
|
let n = this.content;
|
|
2459
2473
|
if (n.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2460
|
-
let r =
|
|
2461
|
-
return `${
|
|
2474
|
+
let r = x(e, this.encodingWidth, () => b(_n));
|
|
2475
|
+
return `${gn}'${Fn(n.items)}'${r}`;
|
|
2462
2476
|
} catch {
|
|
2463
2477
|
return super._toCDN(e, t);
|
|
2464
2478
|
}
|
|
2465
2479
|
}
|
|
2466
2480
|
};
|
|
2467
|
-
function
|
|
2481
|
+
function Rn(e) {
|
|
2468
2482
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2469
2483
|
let t = e[0];
|
|
2470
|
-
if (t instanceof
|
|
2471
|
-
if (t instanceof
|
|
2484
|
+
if (t instanceof B) return t.value;
|
|
2485
|
+
if (t instanceof N) return xn.decode(t.value);
|
|
2472
2486
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2473
2487
|
}
|
|
2474
|
-
function
|
|
2475
|
-
let n = new
|
|
2476
|
-
return e ===
|
|
2488
|
+
function zn(e, t) {
|
|
2489
|
+
let n = new In(Nn(t));
|
|
2490
|
+
return e === gn ? new Ln(n) : n;
|
|
2477
2491
|
}
|
|
2478
|
-
var
|
|
2479
|
-
appStringPrefixes: [
|
|
2480
|
-
tagNumbers: [
|
|
2492
|
+
var Bn = {
|
|
2493
|
+
appStringPrefixes: [hn, gn],
|
|
2494
|
+
tagNumbers: [_n],
|
|
2481
2495
|
parseAppString(e, t) {
|
|
2482
|
-
return
|
|
2496
|
+
return zn(e, t);
|
|
2483
2497
|
},
|
|
2484
2498
|
parseAppSequence(e, t) {
|
|
2485
|
-
return
|
|
2499
|
+
return zn(e, Rn(t));
|
|
2486
2500
|
},
|
|
2487
2501
|
parseTag(e, t) {
|
|
2488
|
-
if (e !== 99n || !(t instanceof
|
|
2489
|
-
let n = new
|
|
2502
|
+
if (e !== 99n || !(t instanceof I)) return;
|
|
2503
|
+
let n = new In(t.items, {
|
|
2490
2504
|
indefiniteLength: t.indefiniteLength,
|
|
2491
2505
|
encodingWidth: t.encodingWidth
|
|
2492
2506
|
});
|
|
2493
|
-
return n.start = t.start, n.end = t.end, new
|
|
2507
|
+
return n.start = t.start, n.end = t.end, new Ln(n);
|
|
2494
2508
|
}
|
|
2495
2509
|
};
|
|
2496
2510
|
//#endregion
|
|
2497
2511
|
//#region src/cbor/decoder.ts
|
|
2498
|
-
function
|
|
2512
|
+
function Vn(e, t) {
|
|
2499
2513
|
if (e === 24 && t <= 23n) return 0;
|
|
2500
2514
|
if (e === 25 && t <= 255n) return 1;
|
|
2501
2515
|
if (e === 26 && t <= 65535n) return 2;
|
|
2502
2516
|
if (e === 27 && t <= 4294967295n) return 3;
|
|
2503
2517
|
}
|
|
2504
|
-
function
|
|
2518
|
+
function Hn(e, t) {
|
|
2505
2519
|
if (e === 24 && t <= 23) return 0;
|
|
2506
2520
|
if (e === 25 && t <= 255) return 1;
|
|
2507
2521
|
if (e === 26 && t <= 65535) return 2;
|
|
2508
2522
|
if (e === 27 && t <= 4294967295) return 3;
|
|
2509
2523
|
}
|
|
2510
|
-
var
|
|
2524
|
+
var Un = new TextDecoder("utf-8", {
|
|
2511
2525
|
fatal: !0,
|
|
2512
2526
|
ignoreBOM: !0
|
|
2513
|
-
}),
|
|
2527
|
+
}), Wn = new TextDecoder("utf-8", {
|
|
2514
2528
|
fatal: !1,
|
|
2515
2529
|
ignoreBOM: !0
|
|
2516
2530
|
});
|
|
2517
2531
|
function q(e) {
|
|
2518
2532
|
throw Error(`CBOR decode error: ${e}`);
|
|
2519
2533
|
}
|
|
2520
|
-
function
|
|
2534
|
+
function Gn(e, t, n) {
|
|
2521
2535
|
let r = {
|
|
2522
2536
|
message: e,
|
|
2523
2537
|
offset: t
|
|
@@ -2529,59 +2543,59 @@ function J(e, t) {
|
|
|
2529
2543
|
e.warnings ??= [], e.warnings.push(t);
|
|
2530
2544
|
}
|
|
2531
2545
|
function Y(e) {
|
|
2532
|
-
if (e instanceof
|
|
2533
|
-
if (e instanceof
|
|
2534
|
-
if (e instanceof
|
|
2535
|
-
if (e instanceof
|
|
2536
|
-
if (e instanceof
|
|
2537
|
-
if (e instanceof
|
|
2546
|
+
if (e instanceof k) return ["u", String(e.value)];
|
|
2547
|
+
if (e instanceof A) return ["n", String(e.value)];
|
|
2548
|
+
if (e instanceof B) return ["t", e.value];
|
|
2549
|
+
if (e instanceof F) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2550
|
+
if (e instanceof N) return ["b", i(e.value)];
|
|
2551
|
+
if (e instanceof P) {
|
|
2538
2552
|
let t = "";
|
|
2539
2553
|
for (let n of e.chunks) t += i(n.value);
|
|
2540
2554
|
return ["b", t];
|
|
2541
2555
|
}
|
|
2542
|
-
if (e instanceof
|
|
2543
|
-
if (e instanceof
|
|
2544
|
-
if (e instanceof
|
|
2545
|
-
if (e instanceof
|
|
2556
|
+
if (e instanceof j) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2557
|
+
if (e instanceof R) return ["s", e.value];
|
|
2558
|
+
if (e instanceof I) return ["A", e.items.map(Y)];
|
|
2559
|
+
if (e instanceof L) {
|
|
2546
2560
|
let t = e.entries.map(([e, t]) => [Y(e), Y(t)]);
|
|
2547
2561
|
if (t.length <= 1) return ["M", t];
|
|
2548
2562
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2549
2563
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
2550
2564
|
}
|
|
2551
|
-
return e instanceof
|
|
2565
|
+
return e instanceof M ? [
|
|
2552
2566
|
"G",
|
|
2553
2567
|
String(e.tag),
|
|
2554
2568
|
Y(e.content)
|
|
2555
2569
|
] : ["c", i(e.toCBOR())];
|
|
2556
2570
|
}
|
|
2557
|
-
function
|
|
2558
|
-
if (e instanceof
|
|
2559
|
-
if (e instanceof
|
|
2560
|
-
if (e instanceof
|
|
2561
|
-
if (e instanceof
|
|
2571
|
+
function Kn(e) {
|
|
2572
|
+
if (e instanceof k) return "u" + e.value;
|
|
2573
|
+
if (e instanceof A) return "n" + e.value;
|
|
2574
|
+
if (e instanceof B) return "t" + e.value;
|
|
2575
|
+
if (e instanceof F) {
|
|
2562
2576
|
let t = "t";
|
|
2563
2577
|
for (let n of e.chunks) t += n.value;
|
|
2564
2578
|
return t;
|
|
2565
2579
|
}
|
|
2566
|
-
if (e instanceof
|
|
2567
|
-
if (e instanceof
|
|
2580
|
+
if (e instanceof N) return "b" + i(e.value);
|
|
2581
|
+
if (e instanceof P) {
|
|
2568
2582
|
let t = "b";
|
|
2569
2583
|
for (let n of e.chunks) t += i(n.value);
|
|
2570
2584
|
return t;
|
|
2571
2585
|
}
|
|
2572
|
-
return e instanceof
|
|
2586
|
+
return e instanceof j ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof R ? "s" + e.value : JSON.stringify(Y(e));
|
|
2573
2587
|
}
|
|
2574
|
-
var
|
|
2575
|
-
function
|
|
2576
|
-
return
|
|
2588
|
+
var qn = Array.from({ length: 24 }, (e, t) => BigInt(t)), Jn;
|
|
2589
|
+
function Yn() {
|
|
2590
|
+
return Jn ??= Fr.filter((e) => e.parseTag !== void 0);
|
|
2577
2591
|
}
|
|
2578
|
-
function
|
|
2592
|
+
function Xn(e, t) {
|
|
2579
2593
|
for (let n = 0; n < t; n++) if (e[n] >= 128) return;
|
|
2580
2594
|
return String.fromCharCode.apply(null, e);
|
|
2581
2595
|
}
|
|
2582
|
-
function
|
|
2596
|
+
function Zn(e, t, n) {
|
|
2583
2597
|
if (n <= 23) return {
|
|
2584
|
-
value:
|
|
2598
|
+
value: qn[n],
|
|
2585
2599
|
nextOffset: t
|
|
2586
2600
|
};
|
|
2587
2601
|
switch (n) {
|
|
@@ -2604,7 +2618,7 @@ function Xn(e, t, n) {
|
|
|
2604
2618
|
default: q(`reserved additional info value: ${n}`);
|
|
2605
2619
|
}
|
|
2606
2620
|
}
|
|
2607
|
-
function
|
|
2621
|
+
function Qn(e, t, n) {
|
|
2608
2622
|
if (n <= 23) return {
|
|
2609
2623
|
value: n,
|
|
2610
2624
|
nextOffset: t
|
|
@@ -2633,7 +2647,7 @@ function Zn(e, t, n) {
|
|
|
2633
2647
|
default: q(`reserved additional info value: ${n}`);
|
|
2634
2648
|
}
|
|
2635
2649
|
}
|
|
2636
|
-
function
|
|
2650
|
+
function $n(e, t, n, r, i, a) {
|
|
2637
2651
|
let o = [], s = t;
|
|
2638
2652
|
for (;;) {
|
|
2639
2653
|
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
@@ -2648,67 +2662,67 @@ function Qn(e, t, n, r, i, a) {
|
|
|
2648
2662
|
nextOffset: s
|
|
2649
2663
|
};
|
|
2650
2664
|
}
|
|
2651
|
-
function
|
|
2652
|
-
let i =
|
|
2653
|
-
t.has(i) && n.push(
|
|
2665
|
+
function er(e, t, n, r) {
|
|
2666
|
+
let i = Kn(e);
|
|
2667
|
+
t.has(i) && n.push(Gn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
2654
2668
|
}
|
|
2655
2669
|
function X(e, t, n, r) {
|
|
2656
|
-
let i = t, a =
|
|
2670
|
+
let i = t, a = nr(e, t, n, r);
|
|
2657
2671
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
2658
2672
|
}
|
|
2659
|
-
function
|
|
2673
|
+
function tr(e, t, n) {
|
|
2660
2674
|
return new Uint8Array(e.buffer, e.byteOffset + t, n).slice();
|
|
2661
2675
|
}
|
|
2662
|
-
function
|
|
2676
|
+
function nr(e, t, n, r) {
|
|
2663
2677
|
t >= e.byteLength && q("unexpected end of input");
|
|
2664
2678
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
2665
2679
|
switch (a) {
|
|
2666
2680
|
case 0: {
|
|
2667
|
-
let { value: n, nextOffset: r } =
|
|
2681
|
+
let { value: n, nextOffset: r } = Zn(e, t, o);
|
|
2668
2682
|
return {
|
|
2669
|
-
value: new
|
|
2683
|
+
value: new k(n, { encodingWidth: Vn(o, n) }),
|
|
2670
2684
|
nextOffset: r
|
|
2671
2685
|
};
|
|
2672
2686
|
}
|
|
2673
2687
|
case 1: {
|
|
2674
|
-
let { value: n, nextOffset: r } =
|
|
2688
|
+
let { value: n, nextOffset: r } = Zn(e, t, o), i = Vn(o, n);
|
|
2675
2689
|
return {
|
|
2676
|
-
value: new
|
|
2690
|
+
value: new A(-1n - n, { encodingWidth: i }),
|
|
2677
2691
|
nextOffset: r
|
|
2678
2692
|
};
|
|
2679
2693
|
}
|
|
2680
2694
|
case 2: {
|
|
2681
2695
|
if (o === 31) {
|
|
2682
|
-
let { chunks: i, nextOffset: a } =
|
|
2696
|
+
let { chunks: i, nextOffset: a } = $n(e, t, n, r, "byte string", (e) => e instanceof N);
|
|
2683
2697
|
return {
|
|
2684
|
-
value: new
|
|
2698
|
+
value: new P(i),
|
|
2685
2699
|
nextOffset: a
|
|
2686
2700
|
};
|
|
2687
2701
|
}
|
|
2688
|
-
let { value: i, nextOffset: a } =
|
|
2702
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i);
|
|
2689
2703
|
return a + i > e.byteLength && q("byte string extends beyond input"), {
|
|
2690
|
-
value: new
|
|
2704
|
+
value: new N(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
|
|
2691
2705
|
nextOffset: a + i
|
|
2692
2706
|
};
|
|
2693
2707
|
}
|
|
2694
2708
|
case 3: {
|
|
2695
2709
|
if (o === 31) {
|
|
2696
|
-
let { chunks: i, nextOffset: a } =
|
|
2710
|
+
let { chunks: i, nextOffset: a } = $n(e, t, n, r, "text string", (e) => e instanceof B);
|
|
2697
2711
|
return {
|
|
2698
|
-
value: new
|
|
2712
|
+
value: new F(i),
|
|
2699
2713
|
nextOffset: a
|
|
2700
2714
|
};
|
|
2701
2715
|
}
|
|
2702
|
-
let { value: i, nextOffset: a } =
|
|
2716
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i);
|
|
2703
2717
|
a + i > e.byteLength && q("text string extends beyond input");
|
|
2704
|
-
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ?
|
|
2718
|
+
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? Xn(c, i) : void 0;
|
|
2705
2719
|
if (d !== void 0) l = d;
|
|
2706
2720
|
else try {
|
|
2707
|
-
l =
|
|
2721
|
+
l = Un.decode(c);
|
|
2708
2722
|
} catch {
|
|
2709
|
-
u =
|
|
2723
|
+
u = Gn("invalid UTF-8 sequence in text string", a, n), l = Wn.decode(c);
|
|
2710
2724
|
}
|
|
2711
|
-
let f = new
|
|
2725
|
+
let f = new B(l, { encodingWidth: s });
|
|
2712
2726
|
return u && J(f, u), {
|
|
2713
2727
|
value: f,
|
|
2714
2728
|
nextOffset: a + i
|
|
@@ -2726,17 +2740,17 @@ function tr(e, t, n, r) {
|
|
|
2726
2740
|
i.push(t.value), a = t.nextOffset;
|
|
2727
2741
|
}
|
|
2728
2742
|
return {
|
|
2729
|
-
value: new
|
|
2743
|
+
value: new I(i, { indefiniteLength: !0 }),
|
|
2730
2744
|
nextOffset: a
|
|
2731
2745
|
};
|
|
2732
2746
|
}
|
|
2733
|
-
let { value: i, nextOffset: a } =
|
|
2747
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i), c = [], l = a;
|
|
2734
2748
|
for (let t = 0; t < i; t++) {
|
|
2735
2749
|
let t = X(e, l, n, r);
|
|
2736
2750
|
c.push(t.value), l = t.nextOffset;
|
|
2737
2751
|
}
|
|
2738
2752
|
return {
|
|
2739
|
-
value: new
|
|
2753
|
+
value: new I(c, { encodingWidth: s }),
|
|
2740
2754
|
nextOffset: l
|
|
2741
2755
|
};
|
|
2742
2756
|
}
|
|
@@ -2749,25 +2763,25 @@ function tr(e, t, n, r) {
|
|
|
2749
2763
|
break;
|
|
2750
2764
|
}
|
|
2751
2765
|
let t = X(e, s, n, r);
|
|
2752
|
-
|
|
2766
|
+
er(t.value, a, o, n), s = t.nextOffset;
|
|
2753
2767
|
let c = X(e, s, n, r);
|
|
2754
2768
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2755
2769
|
}
|
|
2756
|
-
let c = new
|
|
2770
|
+
let c = new L(i, { indefiniteLength: !0 });
|
|
2757
2771
|
for (let e of o) J(c, e);
|
|
2758
2772
|
return {
|
|
2759
2773
|
value: c,
|
|
2760
2774
|
nextOffset: s
|
|
2761
2775
|
};
|
|
2762
2776
|
}
|
|
2763
|
-
let { value: i, nextOffset: a } =
|
|
2777
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
|
|
2764
2778
|
for (let t = 0; t < i; t++) {
|
|
2765
2779
|
let t = X(e, d, n, r);
|
|
2766
|
-
|
|
2780
|
+
er(t.value, l, u, n), d = t.nextOffset;
|
|
2767
2781
|
let i = X(e, d, n, r);
|
|
2768
2782
|
d = i.nextOffset, c.push([t.value, i.value]);
|
|
2769
2783
|
}
|
|
2770
|
-
let f = new
|
|
2784
|
+
let f = new L(c, { encodingWidth: s });
|
|
2771
2785
|
for (let e of u) J(f, e);
|
|
2772
2786
|
return {
|
|
2773
2787
|
value: f,
|
|
@@ -2776,62 +2790,62 @@ function tr(e, t, n, r) {
|
|
|
2776
2790
|
}
|
|
2777
2791
|
case 6: {
|
|
2778
2792
|
o === 31 && q("tags cannot use indefinite-length encoding");
|
|
2779
|
-
let { value: i, nextOffset: a } =
|
|
2793
|
+
let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i), c = X(e, a, n, r);
|
|
2780
2794
|
for (let e of r) {
|
|
2781
2795
|
let t = e.parseTag(i, c.value, n);
|
|
2782
|
-
if (t !== void 0) return t instanceof
|
|
2796
|
+
if (t !== void 0) return t instanceof M && s !== void 0 && (t.encodingWidth = s), {
|
|
2783
2797
|
value: t,
|
|
2784
2798
|
nextOffset: c.nextOffset
|
|
2785
2799
|
};
|
|
2786
2800
|
}
|
|
2787
2801
|
return {
|
|
2788
|
-
value: new
|
|
2802
|
+
value: new M(i, c.value, { encodingWidth: s }),
|
|
2789
2803
|
nextOffset: c.nextOffset
|
|
2790
2804
|
};
|
|
2791
2805
|
}
|
|
2792
2806
|
case 7:
|
|
2793
2807
|
if (o <= 19) return {
|
|
2794
|
-
value: new
|
|
2808
|
+
value: new R(o),
|
|
2795
2809
|
nextOffset: t
|
|
2796
2810
|
};
|
|
2797
2811
|
if (o === 20) return {
|
|
2798
|
-
value: new
|
|
2812
|
+
value: new R(20),
|
|
2799
2813
|
nextOffset: t
|
|
2800
2814
|
};
|
|
2801
2815
|
if (o === 21) return {
|
|
2802
|
-
value: new
|
|
2816
|
+
value: new R(21),
|
|
2803
2817
|
nextOffset: t
|
|
2804
2818
|
};
|
|
2805
2819
|
if (o === 22) return {
|
|
2806
|
-
value: new
|
|
2820
|
+
value: new R(22),
|
|
2807
2821
|
nextOffset: t
|
|
2808
2822
|
};
|
|
2809
2823
|
if (o === 23) return {
|
|
2810
|
-
value: new
|
|
2824
|
+
value: new R(23),
|
|
2811
2825
|
nextOffset: t
|
|
2812
2826
|
};
|
|
2813
2827
|
if (o === 24) {
|
|
2814
2828
|
t + 1 > e.byteLength && q("unexpected end of input");
|
|
2815
2829
|
let r = e.getUint8(t);
|
|
2816
2830
|
if (r < 32) {
|
|
2817
|
-
let e =
|
|
2831
|
+
let e = Gn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new R(r);
|
|
2818
2832
|
return J(i, e), {
|
|
2819
2833
|
value: i,
|
|
2820
2834
|
nextOffset: t + 1
|
|
2821
2835
|
};
|
|
2822
2836
|
}
|
|
2823
2837
|
return {
|
|
2824
|
-
value: new
|
|
2838
|
+
value: new R(r),
|
|
2825
2839
|
nextOffset: t + 1
|
|
2826
2840
|
};
|
|
2827
2841
|
}
|
|
2828
2842
|
if (o === 25) {
|
|
2829
2843
|
t + 2 > e.byteLength && q("unexpected end of input");
|
|
2830
|
-
let n =
|
|
2844
|
+
let n = C(e.getUint16(t, !1));
|
|
2831
2845
|
return {
|
|
2832
|
-
value: new
|
|
2846
|
+
value: new j(n, {
|
|
2833
2847
|
precision: "half",
|
|
2834
|
-
rawBits: Number.isNaN(n) ?
|
|
2848
|
+
rawBits: Number.isNaN(n) ? tr(e, t, 2) : void 0
|
|
2835
2849
|
}),
|
|
2836
2850
|
nextOffset: t + 2
|
|
2837
2851
|
};
|
|
@@ -2840,9 +2854,9 @@ function tr(e, t, n, r) {
|
|
|
2840
2854
|
t + 4 > e.byteLength && q("unexpected end of input");
|
|
2841
2855
|
let n = e.getFloat32(t, !1);
|
|
2842
2856
|
return {
|
|
2843
|
-
value: new
|
|
2857
|
+
value: new j(n, {
|
|
2844
2858
|
precision: "single",
|
|
2845
|
-
rawBits: Number.isNaN(n) ?
|
|
2859
|
+
rawBits: Number.isNaN(n) ? tr(e, t, 4) : void 0
|
|
2846
2860
|
}),
|
|
2847
2861
|
nextOffset: t + 4
|
|
2848
2862
|
};
|
|
@@ -2851,9 +2865,9 @@ function tr(e, t, n, r) {
|
|
|
2851
2865
|
t + 8 > e.byteLength && q("unexpected end of input");
|
|
2852
2866
|
let n = e.getFloat64(t, !1);
|
|
2853
2867
|
return {
|
|
2854
|
-
value: new
|
|
2868
|
+
value: new j(n, {
|
|
2855
2869
|
precision: "double",
|
|
2856
|
-
rawBits: Number.isNaN(n) ?
|
|
2870
|
+
rawBits: Number.isNaN(n) ? tr(e, t, 8) : void 0
|
|
2857
2871
|
}),
|
|
2858
2872
|
nextOffset: t + 8
|
|
2859
2873
|
};
|
|
@@ -2862,17 +2876,17 @@ function tr(e, t, n, r) {
|
|
|
2862
2876
|
}
|
|
2863
2877
|
return q(`unknown major type: ${a}`);
|
|
2864
2878
|
}
|
|
2865
|
-
function
|
|
2879
|
+
function rr(e) {
|
|
2866
2880
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
2867
2881
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
2868
2882
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
2869
2883
|
}
|
|
2870
|
-
function
|
|
2871
|
-
let n =
|
|
2884
|
+
function ir(e, t) {
|
|
2885
|
+
let n = rr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
2872
2886
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
2873
|
-
let a = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...
|
|
2887
|
+
let a = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...Yn()] : Yn(), { value: o, nextOffset: s } = X(r, i, t, a);
|
|
2874
2888
|
if (!t?.allowTrailing && s !== r.byteLength) {
|
|
2875
|
-
J(o,
|
|
2889
|
+
J(o, Gn(`${r.byteLength - s} trailing byte(s) after end of CBOR item`, s, t));
|
|
2876
2890
|
let e = {
|
|
2877
2891
|
strict: !1,
|
|
2878
2892
|
silent: !0
|
|
@@ -2883,49 +2897,340 @@ function rr(e, t) {
|
|
|
2883
2897
|
}
|
|
2884
2898
|
//#endregion
|
|
2885
2899
|
//#region src/extensions/cbordata.ts
|
|
2886
|
-
var
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2900
|
+
var ar = 24n, or = {
|
|
2901
|
+
tagNumbers: [ar],
|
|
2902
|
+
parseTag(e, t, n) {
|
|
2903
|
+
if (e !== 24n || !(t instanceof N)) return;
|
|
2904
|
+
let r = n ? {
|
|
2905
|
+
extensions: n.extensions,
|
|
2906
|
+
strict: n.strict,
|
|
2907
|
+
onWarning: n.onWarning,
|
|
2908
|
+
silent: n.silent
|
|
2909
|
+
} : void 0;
|
|
2910
|
+
try {
|
|
2911
|
+
return new M(ar, new Ue([ir(t.value, r)], { encodingWidth: t.encodingWidth }));
|
|
2912
|
+
} catch (e) {
|
|
2913
|
+
if (r?.strict !== !1) throw e;
|
|
2914
|
+
return;
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
}, sr = new TextEncoder(), cr = new TextDecoder("utf-8", { fatal: !0 }), lr = new TextDecoder("utf-8", { fatal: !1 }), ur = Symbol("ellipsis");
|
|
2918
|
+
function dr(e) {
|
|
2919
|
+
let t = 0;
|
|
2920
|
+
for (let n of e) t += n.length;
|
|
2921
|
+
let n = new Uint8Array(t), r = 0;
|
|
2922
|
+
for (let t of e) n.set(t, r), r += t.length;
|
|
2923
|
+
return n;
|
|
2924
|
+
}
|
|
2925
|
+
function fr(e, t, n) {
|
|
2926
|
+
if (t instanceof Ke) {
|
|
2927
|
+
fr(e, t.inner, n);
|
|
2928
|
+
return;
|
|
2929
|
+
}
|
|
2930
|
+
if (t instanceof z) {
|
|
2931
|
+
if (t.content instanceof I) for (let r of t.content.items) fr(e, r, n);
|
|
2932
|
+
else n.push(ur);
|
|
2933
|
+
return;
|
|
2934
|
+
}
|
|
2935
|
+
if (t instanceof B) {
|
|
2936
|
+
n.push(sr.encode(t.value));
|
|
2937
|
+
return;
|
|
2938
|
+
}
|
|
2939
|
+
if (t instanceof N) {
|
|
2940
|
+
n.push(t.value);
|
|
2941
|
+
return;
|
|
2942
|
+
}
|
|
2943
|
+
if (t instanceof F) {
|
|
2944
|
+
n.push(sr.encode(t.chunks.map((e) => e.value).join("")));
|
|
2945
|
+
return;
|
|
2946
|
+
}
|
|
2947
|
+
if (t instanceof P) {
|
|
2948
|
+
n.push(dr(t.chunks.map((e) => e.value)));
|
|
2949
|
+
return;
|
|
2950
|
+
}
|
|
2951
|
+
throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings or ellipses`);
|
|
2952
|
+
}
|
|
2953
|
+
function pr(e, t) {
|
|
2954
|
+
try {
|
|
2955
|
+
return cr.decode(e);
|
|
2956
|
+
} catch {
|
|
2957
|
+
let n = "t1 concatenation result is not valid UTF-8";
|
|
2958
|
+
if (t) t(n);
|
|
2959
|
+
else throw SyntaxError(n);
|
|
2960
|
+
return lr.decode(e);
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
function mr(e, t, n) {
|
|
2964
|
+
let r = [];
|
|
2965
|
+
for (let n of t) fr(e, n, r);
|
|
2966
|
+
let i = e === "t1", a = [], o = !1, s = [], c = () => {
|
|
2967
|
+
if (s.length === 0) return;
|
|
2968
|
+
let e = dr(s);
|
|
2969
|
+
s.length = 0, e.length !== 0 && a.push(i ? new B(pr(e, n)) : new N(e));
|
|
2970
|
+
};
|
|
2971
|
+
for (let e of r) e === ur ? (c(), a[a.length - 1] instanceof z || (a.push(new z()), o = !0)) : s.push(e);
|
|
2972
|
+
if (!o) {
|
|
2973
|
+
let e = dr(s);
|
|
2974
|
+
return i ? new B(pr(e, n)) : new N(e);
|
|
2975
|
+
}
|
|
2976
|
+
return c(), a.length === 1 ? new z() : new z(a);
|
|
2977
|
+
}
|
|
2978
|
+
function hr(e) {
|
|
2979
|
+
return {
|
|
2980
|
+
appStringPrefixes: [e],
|
|
2981
|
+
preserveAppSeqSource: !0,
|
|
2982
|
+
parseAppString(t, n, r) {
|
|
2983
|
+
return mr(e, [new B(n)], r);
|
|
2984
|
+
},
|
|
2985
|
+
parseAppSequence(t, n, r) {
|
|
2986
|
+
return mr(e, n, r);
|
|
2987
|
+
}
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
var gr = hr("t1"), _r = hr("b1"), vr = new TextEncoder(), yr = new TextDecoder("utf-8", { fatal: !0 }), br = new TextDecoder("utf-8", { fatal: !1 });
|
|
2991
|
+
function xr(e) {
|
|
2992
|
+
let t = 0;
|
|
2993
|
+
for (let n of e) t += n.length;
|
|
2994
|
+
let n = new Uint8Array(t), r = 0;
|
|
2995
|
+
for (let t of e) n.set(t, r), r += t.length;
|
|
2996
|
+
return n;
|
|
2997
|
+
}
|
|
2998
|
+
function Sr(e, t, n) {
|
|
2999
|
+
let r = e === "ilts", i = [], a = [];
|
|
3000
|
+
for (let o of t) {
|
|
3001
|
+
if (o instanceof Ke && (o = o.inner), o instanceof z) throw SyntaxError(`${e}<<...>> cannot contain ellipses; there is no way to include an elision in an indefinite-length string`);
|
|
3002
|
+
let t, s, c;
|
|
3003
|
+
if (o instanceof B) t = o.value, c = o.encodingWidth;
|
|
3004
|
+
else if (o instanceof N) s = o.value, c = o.encodingWidth;
|
|
3005
|
+
else if (o instanceof F) t = o.chunks.map((e) => e.value).join("");
|
|
3006
|
+
else if (o instanceof P) s = xr(o.chunks.map((e) => e.value));
|
|
3007
|
+
else throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings`);
|
|
3008
|
+
if (r) {
|
|
3009
|
+
let e;
|
|
3010
|
+
if (t !== void 0) e = t;
|
|
3011
|
+
else try {
|
|
3012
|
+
e = yr.decode(s);
|
|
3013
|
+
} catch {
|
|
3014
|
+
let t = "ilts chunk is not valid UTF-8";
|
|
3015
|
+
if (n) n(t);
|
|
3016
|
+
else throw SyntaxError(t);
|
|
3017
|
+
e = br.decode(s);
|
|
2906
3018
|
}
|
|
3019
|
+
a.push(new B(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
3020
|
+
} else {
|
|
3021
|
+
let e = s ?? vr.encode(t);
|
|
3022
|
+
i.push(new N(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
2907
3023
|
}
|
|
2908
3024
|
}
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
3025
|
+
return r ? new F(a) : new P(i);
|
|
3026
|
+
}
|
|
3027
|
+
function Cr(e) {
|
|
3028
|
+
return {
|
|
3029
|
+
appStringPrefixes: [e],
|
|
3030
|
+
preserveAppSeqSource: !0,
|
|
3031
|
+
parseAppString(t, n, r) {
|
|
3032
|
+
return new Ke(Sr(e, [new B(n)], r), `${e}${xe(n)}`);
|
|
3033
|
+
},
|
|
3034
|
+
parseAppSequence(t, n, r) {
|
|
3035
|
+
return Sr(e, n, r);
|
|
3036
|
+
}
|
|
3037
|
+
};
|
|
3038
|
+
}
|
|
3039
|
+
var wr = Cr("ilbs"), Tr = Cr("ilts");
|
|
3040
|
+
//#endregion
|
|
3041
|
+
//#region src/utils/strip-comments.ts
|
|
3042
|
+
function Er(e) {
|
|
3043
|
+
let t = "", n = 0;
|
|
3044
|
+
for (; n < e.length;) {
|
|
3045
|
+
let r = e[n];
|
|
3046
|
+
if (r === " " || r === "\n" || r === "\r") {
|
|
3047
|
+
n++;
|
|
3048
|
+
continue;
|
|
3049
|
+
}
|
|
3050
|
+
if (r === "#") {
|
|
3051
|
+
for (; n < e.length && e[n] !== "\n";) n++;
|
|
3052
|
+
continue;
|
|
3053
|
+
}
|
|
3054
|
+
if (r === "/") {
|
|
3055
|
+
let t = e[n + 1] ?? "";
|
|
3056
|
+
if (t === "/") {
|
|
3057
|
+
for (; n < e.length && e[n] !== "\n";) n++;
|
|
3058
|
+
continue;
|
|
3059
|
+
}
|
|
3060
|
+
if (t === "*") {
|
|
3061
|
+
for (n += 2; n < e.length && !(e[n] === "*" && (e[n + 1] ?? "") === "/");) n++;
|
|
3062
|
+
if (n >= e.length) throw SyntaxError("unterminated block comment");
|
|
3063
|
+
n += 2;
|
|
3064
|
+
continue;
|
|
3065
|
+
}
|
|
3066
|
+
for (n++; n < e.length && e[n] !== "/";) n++;
|
|
3067
|
+
if (n >= e.length) throw SyntaxError("unterminated block comment");
|
|
3068
|
+
n++;
|
|
3069
|
+
continue;
|
|
3070
|
+
}
|
|
3071
|
+
t += r, n++;
|
|
3072
|
+
}
|
|
3073
|
+
return t;
|
|
3074
|
+
}
|
|
3075
|
+
//#endregion
|
|
3076
|
+
//#region src/extensions/float.ts
|
|
3077
|
+
var Dr = class extends j {
|
|
3078
|
+
_bits;
|
|
3079
|
+
constructor(e) {
|
|
3080
|
+
super(C(e), { precision: "half" }), this._bits = e & 65535;
|
|
3081
|
+
}
|
|
3082
|
+
_toCBOR() {
|
|
3083
|
+
return new Uint8Array([
|
|
3084
|
+
249,
|
|
3085
|
+
this._bits >> 8 & 255,
|
|
3086
|
+
this._bits & 255
|
|
3087
|
+
]);
|
|
3088
|
+
}
|
|
3089
|
+
}, Or = class extends j {
|
|
3090
|
+
_raw;
|
|
3091
|
+
constructor(e) {
|
|
3092
|
+
super(new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), { precision: "single" }), this._raw = e.slice();
|
|
3093
|
+
}
|
|
3094
|
+
_toCBOR() {
|
|
3095
|
+
let e = /* @__PURE__ */ new Uint8Array(5);
|
|
3096
|
+
return e[0] = 250, e.set(this._raw, 1), e;
|
|
3097
|
+
}
|
|
3098
|
+
}, kr = class extends j {
|
|
3099
|
+
_raw;
|
|
3100
|
+
constructor(e) {
|
|
3101
|
+
super(new DataView(e.buffer, e.byteOffset).getFloat64(0, !1), { precision: "double" }), this._raw = e.slice();
|
|
3102
|
+
}
|
|
3103
|
+
_toCBOR() {
|
|
3104
|
+
let e = /* @__PURE__ */ new Uint8Array(9);
|
|
3105
|
+
return e[0] = 251, e.set(this._raw, 1), e;
|
|
3106
|
+
}
|
|
3107
|
+
};
|
|
3108
|
+
function Z(e) {
|
|
3109
|
+
if (e.length === 2) return new Dr(e[0] << 8 | e[1]);
|
|
3110
|
+
if (e.length === 4) return new Or(e);
|
|
3111
|
+
if (e.length === 8) return new kr(e);
|
|
3112
|
+
throw SyntaxError(`float'...' requires 4, 8, or 16 hex digits (2, 4, or 8 bytes); got ${e.length} bytes`);
|
|
3113
|
+
}
|
|
3114
|
+
function Ar(e) {
|
|
3115
|
+
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i;
|
|
3116
|
+
if (n === 31) i = t << 31 | 2139095040 | r << 13;
|
|
3117
|
+
else if (n === 0 && r === 0) i = t << 31;
|
|
3118
|
+
else if (n === 0) {
|
|
3119
|
+
let e = r, n = 0;
|
|
3120
|
+
for (; !(e & 512);) e <<= 1, n++;
|
|
3121
|
+
i = t << 31 | 112 - n << 23 | (e & 511) << 14;
|
|
3122
|
+
} else i = t << 31 | n + 112 << 23 | r << 13;
|
|
3123
|
+
let a = /* @__PURE__ */ new Uint8Array(4);
|
|
3124
|
+
return new DataView(a.buffer).setUint32(0, i >>> 0, !1), a;
|
|
3125
|
+
}
|
|
3126
|
+
function jr(e) {
|
|
3127
|
+
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i = /* @__PURE__ */ new Uint8Array(8), a = new DataView(i.buffer);
|
|
3128
|
+
if (n === 31) a.setUint32(0, (t << 31 | 2146435072 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3129
|
+
else if (n === 0 && r === 0) a.setUint32(0, t << 31 >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3130
|
+
else if (n === 0) {
|
|
3131
|
+
let e = r, n = 0;
|
|
3132
|
+
for (; !(e & 512);) e <<= 1, n++;
|
|
3133
|
+
a.setUint32(0, (t << 31 | 1008 - n << 20 | (e & 511) << 11) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3134
|
+
} else a.setUint32(0, (t << 31 | n + 1008 << 20 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3135
|
+
return i;
|
|
3136
|
+
}
|
|
3137
|
+
function Mr(e) {
|
|
3138
|
+
let t = new DataView(e.buffer, e.byteOffset).getUint32(0, !1), n = t >>> 31 & 1, r = t >>> 23 & 255, i = t & 8388607, a = /* @__PURE__ */ new Uint8Array(8), o = new DataView(a.buffer);
|
|
3139
|
+
if (r === 255) o.setUint32(0, (n << 31 | 2146435072 | i >>> 3) >>> 0, !1), o.setUint32(4, (i & 7) << 29, !1);
|
|
3140
|
+
else if (r === 0 && i === 0) o.setUint32(0, n << 31 >>> 0, !1), o.setUint32(4, 0, !1);
|
|
3141
|
+
else {
|
|
3142
|
+
let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1);
|
|
3143
|
+
o.setFloat64(0, t, !1);
|
|
3144
|
+
}
|
|
3145
|
+
return a;
|
|
3146
|
+
}
|
|
3147
|
+
function Nr(e, t, n) {
|
|
3148
|
+
let r = e.length === 2 ? 1 : e.length === 4 ? 2 : 3;
|
|
3149
|
+
if (r === 1) {
|
|
3150
|
+
let n = e[0] << 8 | e[1];
|
|
3151
|
+
if (t === 2) return new Or(Ar(n));
|
|
3152
|
+
if (t === 3) return new kr(jr(n));
|
|
3153
|
+
}
|
|
3154
|
+
if (r === 2) {
|
|
3155
|
+
if (t === 3) return new kr(Mr(e));
|
|
3156
|
+
if (t === 1) {
|
|
3157
|
+
let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), r = S(t);
|
|
3158
|
+
return !Object.is(C(r), t) && !isNaN(t) && n("float'...' value cannot be exactly represented as float16 (_1)"), new Dr(r);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
if (r === 3) {
|
|
3162
|
+
let r = new DataView(e.buffer, e.byteOffset).getFloat64(0, !1);
|
|
3163
|
+
if (t === 1) {
|
|
3164
|
+
let e = S(r);
|
|
3165
|
+
return !Object.is(C(e), r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float16 (_1)"), new Dr(e);
|
|
3166
|
+
}
|
|
3167
|
+
if (t === 2) {
|
|
3168
|
+
let e = Math.fround(r);
|
|
3169
|
+
!Object.is(e, r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float32 (_2)");
|
|
3170
|
+
let t = /* @__PURE__ */ new Uint8Array(4);
|
|
3171
|
+
return new DataView(t.buffer).setFloat32(0, e, !1), new Or(t);
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
return Z(e);
|
|
3175
|
+
}
|
|
3176
|
+
var Pr = {
|
|
3177
|
+
appStringPrefixes: ["float"],
|
|
3178
|
+
parseAppString(t, n, r, i) {
|
|
3179
|
+
let a = Er(n);
|
|
3180
|
+
if (!/^[0-9a-fA-F]*$/.test(a)) throw SyntaxError("float'...' contains non-hex characters");
|
|
3181
|
+
if (a.length % 2 != 0) throw SyntaxError(`float'...' hex content has odd length (${a.length} digits)`);
|
|
3182
|
+
let o = e(a), s = i?.encodingWidth;
|
|
3183
|
+
if (s === void 0) return Z(o);
|
|
3184
|
+
if (s !== 1 && s !== 2 && s !== 3) {
|
|
3185
|
+
let e = `float'...' encoding indicator _${s} is not valid; use _1, _2, or _3`;
|
|
3186
|
+
if (r) return r(e), Z(o);
|
|
3187
|
+
throw SyntaxError(e);
|
|
3188
|
+
}
|
|
3189
|
+
return s === (o.length === 2 ? 1 : o.length === 4 ? 2 : 3) ? Z(o) : Nr(o, s, r ?? ((e) => {
|
|
3190
|
+
throw SyntaxError(e);
|
|
3191
|
+
}));
|
|
3192
|
+
},
|
|
3193
|
+
parseAppSequence(e, t, n) {
|
|
3194
|
+
if (t.length === 0) throw SyntaxError("float<<...>> requires exactly one byte-string item");
|
|
3195
|
+
if (t.length > 1) {
|
|
3196
|
+
let e = `float<<...>> expects 1 item; got ${t.length} — using first`;
|
|
3197
|
+
if (n) n(e);
|
|
3198
|
+
else throw SyntaxError(e);
|
|
3199
|
+
}
|
|
3200
|
+
if (!(t[0] instanceof N)) throw SyntaxError("float<<...>> item must be a byte string");
|
|
3201
|
+
return Z(t[0].value);
|
|
3202
|
+
}
|
|
3203
|
+
}, Fr = [
|
|
3204
|
+
Kt,
|
|
3205
|
+
dn,
|
|
3206
|
+
mn,
|
|
3207
|
+
Bn,
|
|
3208
|
+
or,
|
|
3209
|
+
gr,
|
|
3210
|
+
_r,
|
|
3211
|
+
wr,
|
|
3212
|
+
Tr,
|
|
3213
|
+
Pr
|
|
3214
|
+
], Ir;
|
|
3215
|
+
function Lr() {
|
|
3216
|
+
return Ir ??= {
|
|
3217
|
+
fromJS: Fr.filter((e) => e.fromJS !== void 0),
|
|
3218
|
+
parseTag: Fr.filter((e) => e.parseTag !== void 0)
|
|
2914
3219
|
};
|
|
2915
3220
|
}
|
|
2916
|
-
function
|
|
2917
|
-
let t = e?.extensions, n =
|
|
3221
|
+
function Rr(e) {
|
|
3222
|
+
let t = e?.extensions, n = Lr();
|
|
2918
3223
|
return t?.length ? {
|
|
2919
3224
|
fromJS: [...t.filter((e) => e.fromJS !== void 0), ...n.fromJS],
|
|
2920
3225
|
parseTag: [...t.filter((e) => e.parseTag !== void 0), ...n.parseTag]
|
|
2921
3226
|
} : n;
|
|
2922
3227
|
}
|
|
2923
|
-
function
|
|
3228
|
+
function zr(e, t) {
|
|
2924
3229
|
if (t?.replacer) {
|
|
2925
|
-
let { replacer: n, ...r } = t, i =
|
|
2926
|
-
return i === h ?
|
|
3230
|
+
let { replacer: n, ...r } = t, i = Vr(e, n, r.extensions, r.undefinedOmits);
|
|
3231
|
+
return i === h ? R.UNDEFINED : zr(i, Object.keys(r).length > 0 ? r : void 0);
|
|
2927
3232
|
}
|
|
2928
|
-
return Q(e, t, !0,
|
|
3233
|
+
return Q(e, t, !0, Rr(t));
|
|
2929
3234
|
}
|
|
2930
3235
|
function Q(e, t, n, r) {
|
|
2931
3236
|
for (let n of r.fromJS) {
|
|
@@ -2938,35 +3243,35 @@ function Q(e, t, n, r) {
|
|
|
2938
3243
|
let t = e.parseTag(n, i);
|
|
2939
3244
|
if (t !== void 0) return t;
|
|
2940
3245
|
}
|
|
2941
|
-
return new
|
|
2942
|
-
}
|
|
2943
|
-
if (e instanceof m.Null) return
|
|
2944
|
-
if (e instanceof m.Undefined) return
|
|
2945
|
-
if (e instanceof g) return new
|
|
2946
|
-
if (e === null) return
|
|
2947
|
-
if (e === void 0) return
|
|
2948
|
-
if (e === !0) return
|
|
2949
|
-
if (e === !1) return
|
|
2950
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new
|
|
2951
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new
|
|
2952
|
-
if (typeof e == "string") return new
|
|
3246
|
+
return new M(n, i);
|
|
3247
|
+
}
|
|
3248
|
+
if (e instanceof m.Null) return R.NULL;
|
|
3249
|
+
if (e instanceof m.Undefined) return R.UNDEFINED;
|
|
3250
|
+
if (e instanceof g) return new R(e.value);
|
|
3251
|
+
if (e === null) return R.NULL;
|
|
3252
|
+
if (e === void 0) return R.UNDEFINED;
|
|
3253
|
+
if (e === !0) return R.TRUE;
|
|
3254
|
+
if (e === !1) return R.FALSE;
|
|
3255
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new et(e) : e < -18446744073709551616n ? new tt(e) : e >= 0n ? new k(e) : new A(e);
|
|
3256
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new k(BigInt(e)) : new A(BigInt(e)) : new j(e);
|
|
3257
|
+
if (typeof e == "string") return new B(e);
|
|
2953
3258
|
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Q(e.valueOf(), t, !1, r);
|
|
2954
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new
|
|
2955
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new
|
|
2956
|
-
if (e instanceof $) return new
|
|
2957
|
-
if (Array.isArray(e)) return new
|
|
3259
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new N(new Uint8Array(e));
|
|
3260
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new I(Array.from(e, (e) => new k(BigInt(e)))) : new N(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
3261
|
+
if (e instanceof $) return new L([...e].map(([e, n]) => [Q(e, t, !0, r), Q(n, t, !0, r)]));
|
|
3262
|
+
if (Array.isArray(e)) return new I(e.map((e) => Q(e, t, !0, r)));
|
|
2958
3263
|
if (typeof e == "object") {
|
|
2959
3264
|
let n = [];
|
|
2960
|
-
for (let [i, a] of Object.entries(e)) n.push([new
|
|
2961
|
-
return new
|
|
3265
|
+
for (let [i, a] of Object.entries(e)) n.push([new B(i), Q(a, t, !0, r)]);
|
|
3266
|
+
return new L(n);
|
|
2962
3267
|
}
|
|
2963
3268
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
2964
3269
|
}
|
|
2965
|
-
function
|
|
3270
|
+
function Br(e) {
|
|
2966
3271
|
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 m.Null || e instanceof m.Undefined || e instanceof g;
|
|
2967
3272
|
}
|
|
2968
|
-
function
|
|
2969
|
-
let i = [...n ?? [], ...
|
|
3273
|
+
function Vr(e, t, n, r) {
|
|
3274
|
+
let i = [...n ?? [], ...Fr].filter((e) => e.isJSType !== void 0);
|
|
2970
3275
|
function a(e) {
|
|
2971
3276
|
return e === h || r === !0 && e === void 0;
|
|
2972
3277
|
}
|
|
@@ -2976,7 +3281,7 @@ function ur(e, t, n, r) {
|
|
|
2976
3281
|
if (typeof e != "object" || !e) return e;
|
|
2977
3282
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
2978
3283
|
if (Array.isArray(e)) return e.map(r);
|
|
2979
|
-
if (m.symbol in e ||
|
|
3284
|
+
if (m.symbol in e || Br(e) || i.some((t) => t.isJSType(e))) return e;
|
|
2980
3285
|
let t = Object.getPrototypeOf(e);
|
|
2981
3286
|
if (t === Object.prototype || t === null) {
|
|
2982
3287
|
let t = e.toJSON;
|
|
@@ -3011,7 +3316,7 @@ function ur(e, t, n, r) {
|
|
|
3011
3316
|
let r = s(t, String(n), e);
|
|
3012
3317
|
return a(r) ? null : r;
|
|
3013
3318
|
});
|
|
3014
|
-
if (
|
|
3319
|
+
if (Br(e) || i.some((t) => t.isJSType(e))) return e;
|
|
3015
3320
|
let t = {};
|
|
3016
3321
|
for (let n of Object.keys(e)) {
|
|
3017
3322
|
let r = s(e[n], n, e);
|
|
@@ -3029,7 +3334,7 @@ var $ = class extends Array {
|
|
|
3029
3334
|
toJSON() {
|
|
3030
3335
|
let e = {};
|
|
3031
3336
|
for (let [t, n] of this) {
|
|
3032
|
-
let r = typeof t == "string" ? t :
|
|
3337
|
+
let r = typeof t == "string" ? t : zr(t).toCDN();
|
|
3033
3338
|
r === "__proto__" ? Object.defineProperty(e, r, {
|
|
3034
3339
|
value: n,
|
|
3035
3340
|
writable: !0,
|
|
@@ -3041,6 +3346,6 @@ var $ = class extends Array {
|
|
|
3041
3346
|
}
|
|
3042
3347
|
};
|
|
3043
3348
|
//#endregion
|
|
3044
|
-
export { C,
|
|
3349
|
+
export { o as A, M as C, O as D, k as E, m as M, c as N, g as O, N as S, A as T, R as _, Er as a, F as b, _r as c, qt as d, B as f, Ue as g, et as h, Pr as i, s as j, h as k, gr as l, tt as m, Vr as n, wr as o, at as p, zr as r, Tr as s, $ as t, ir as u, L as v, j as w, P as x, I as y };
|
|
3045
3350
|
|
|
3046
|
-
//# sourceMappingURL=mapEntries-
|
|
3351
|
+
//# sourceMappingURL=mapEntries-BdzS6bFp.js.map
|