@cbortech/cbor 0.25.10 → 0.25.11
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 +11 -6
- package/README.md +13 -6
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{mapEntries-B8riGPMD.js → mapEntries-CYvdsAfP.js} +663 -648
- package/dist/mapEntries-CYvdsAfP.js.map +1 -0
- package/dist/mapEntries-vOYb5Q1s.cjs +11 -0
- package/dist/mapEntries-vOYb5Q1s.cjs.map +1 -0
- package/dist/types.d.ts +29 -19
- package/package.json +1 -1
- 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
|
@@ -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);
|
|
422
419
|
}
|
|
423
|
-
function
|
|
424
|
-
return Ie(e)
|
|
420
|
+
function Re(e) {
|
|
421
|
+
return Ie.setFloat32(0, e, !1), Object.is(Ie.getFloat32(0, !1), e);
|
|
422
|
+
}
|
|
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,15 @@ function ft(e) {
|
|
|
1219
1219
|
return a + 1;
|
|
1220
1220
|
};
|
|
1221
1221
|
}
|
|
1222
|
-
var
|
|
1223
|
-
["b32",
|
|
1224
|
-
["h32",
|
|
1225
|
-
["float",
|
|
1226
|
-
["same",
|
|
1227
|
-
["hash",
|
|
1228
|
-
["uuid",
|
|
1229
|
-
["UUID",
|
|
1230
|
-
]),
|
|
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
|
+
["float", mt("float")],
|
|
1226
|
+
["same", mt("same")],
|
|
1227
|
+
["hash", ht("hash", "@cbortech/hash-extension")],
|
|
1228
|
+
["uuid", ht("uuid", "@cbortech/uuid-extension")],
|
|
1229
|
+
["UUID", ht("uuid", "@cbortech/uuid-extension")]
|
|
1230
|
+
]), _t = class {
|
|
1231
1231
|
t;
|
|
1232
1232
|
_options;
|
|
1233
1233
|
extByPrefix;
|
|
@@ -1287,12 +1287,12 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1287
1287
|
case "BYTES_HEX":
|
|
1288
1288
|
case "SQSTR":
|
|
1289
1289
|
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
|
|
1290
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new P([]);
|
|
1291
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new F([]);
|
|
1292
|
+
case "TRUE": return this.t.consume(), new R(21);
|
|
1293
|
+
case "FALSE": return this.t.consume(), new R(20);
|
|
1294
|
+
case "NULL": return this.t.consume(), new R(22);
|
|
1295
|
+
case "UNDEFINED": return this.t.consume(), new R(23);
|
|
1296
1296
|
case "SIMPLE": return this.parseSimple();
|
|
1297
1297
|
case "LBRACKET": return this.parseArray();
|
|
1298
1298
|
case "LBRACE": return this.parseMap();
|
|
@@ -1307,21 +1307,21 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1307
1307
|
}
|
|
1308
1308
|
let r = this.extByPrefix.get(e.appPrefix);
|
|
1309
1309
|
if (!r?.parseAppString) {
|
|
1310
|
-
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1310
|
+
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, [new B(e.value)]);
|
|
1311
1311
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1312
1312
|
}
|
|
1313
1313
|
{
|
|
1314
1314
|
let i = this._pendingWarnings.length;
|
|
1315
1315
|
try {
|
|
1316
1316
|
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
|
|
1317
|
+
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
1318
|
ednEncoding: i.ednEncoding,
|
|
1319
1319
|
encodingWidth: i.encodingWidth,
|
|
1320
1320
|
ednSource: e.raw + n
|
|
1321
|
-
}) : (i instanceof
|
|
1321
|
+
}) : (i instanceof j && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1322
1322
|
} catch (t) {
|
|
1323
1323
|
if (this._options.strict !== !1) throw t;
|
|
1324
|
-
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new
|
|
1324
|
+
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Ge(e.appPrefix, [new B(e.value)]);
|
|
1325
1325
|
}
|
|
1326
1326
|
}
|
|
1327
1327
|
}
|
|
@@ -1339,7 +1339,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1339
1339
|
this.t.peek().type === "ENCODING_INDICATOR" && (r = this.t.consume(), n = this._resolveEncodingWidth(r.value, r));
|
|
1340
1340
|
let i = this.extByPrefix.get(e.appPrefix);
|
|
1341
1341
|
if (!i) {
|
|
1342
|
-
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1342
|
+
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, t);
|
|
1343
1343
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1344
1344
|
}
|
|
1345
1345
|
i.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
@@ -1349,61 +1349,61 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1349
1349
|
let a = i.parseAppSequence(e.appPrefix, t, this._extOnError(e));
|
|
1350
1350
|
n !== void 0 && this._applyEiToResult(a, n, r ?? e);
|
|
1351
1351
|
let o = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1352
|
-
if (a instanceof
|
|
1353
|
-
else if (i.preserveAppSeqSource) return new
|
|
1352
|
+
if (a instanceof j) a.ednSource === void 0 && (a.ednSource = o);
|
|
1353
|
+
else if (i.preserveAppSeqSource) return new Ke(a, o);
|
|
1354
1354
|
return a;
|
|
1355
1355
|
} catch (n) {
|
|
1356
1356
|
if (this._options.strict !== !1) throw n;
|
|
1357
|
-
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new
|
|
1357
|
+
return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new Ge(e.appPrefix, t);
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
1360
1360
|
}
|
|
1361
1361
|
case "ELLIPSIS": {
|
|
1362
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
1363
|
-
let e = [new
|
|
1362
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new z();
|
|
1363
|
+
let e = [new z()];
|
|
1364
1364
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1365
|
-
return new
|
|
1365
|
+
return new z(e);
|
|
1366
1366
|
}
|
|
1367
1367
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1368
1368
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1369
1369
|
}
|
|
1370
1370
|
}
|
|
1371
1371
|
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
|
|
1372
|
+
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);
|
|
1373
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new et(i);
|
|
1374
|
+
if (i < -18446744073709551616n) return new tt(i);
|
|
1375
1375
|
if (r !== void 0) {
|
|
1376
1376
|
let t = i >= 0n ? i : -(i + 1n);
|
|
1377
1377
|
r = this._validateEncodingFit(t, r, e);
|
|
1378
1378
|
}
|
|
1379
|
-
let a = i >= 0n ? new
|
|
1379
|
+
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
1380
|
if (this.t.peek().type === "LPAREN") {
|
|
1381
|
-
a instanceof
|
|
1381
|
+
a instanceof k || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
1382
1382
|
let t = this._pendingWarnings.splice(0), n = this.parseValue();
|
|
1383
1383
|
this.expect("RPAREN");
|
|
1384
1384
|
let i = a.value, o = this.extByTag.get(i);
|
|
1385
1385
|
if (o?.parseTag) {
|
|
1386
1386
|
let e = o.parseTag(i, n);
|
|
1387
|
-
if (e !== void 0) return e instanceof
|
|
1387
|
+
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
1388
|
}
|
|
1389
|
-
let s = new
|
|
1389
|
+
let s = new M(i, n, r === void 0 ? void 0 : { encodingWidth: r });
|
|
1390
1390
|
return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
|
|
1391
1391
|
}
|
|
1392
1392
|
return a;
|
|
1393
1393
|
}
|
|
1394
1394
|
parseFloat() {
|
|
1395
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } =
|
|
1395
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = ct(e.value, t);
|
|
1396
1396
|
if (r === "half" || r === "single") {
|
|
1397
|
-
let e = r === "half" ?
|
|
1397
|
+
let e = r === "half" ? C(S(n)) : Math.fround(n);
|
|
1398
1398
|
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
1399
|
}
|
|
1400
|
-
return new
|
|
1400
|
+
return new j(n, r === void 0 ? void 0 : { precision: r });
|
|
1401
1401
|
}
|
|
1402
1402
|
parseString() {
|
|
1403
1403
|
let e = this.t.consume();
|
|
1404
1404
|
if (this.t.peek().type !== "PLUS") {
|
|
1405
|
-
let t = this.consumeEncodingIndicator(() => BigInt(
|
|
1406
|
-
return new
|
|
1405
|
+
let t = this.consumeEncodingIndicator(() => BigInt(nt.encode(e.value).length));
|
|
1406
|
+
return new B(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
1407
1407
|
}
|
|
1408
1408
|
let t = !1, n = [{ text: e.value }];
|
|
1409
1409
|
for (; this.t.peek().type === "PLUS";) {
|
|
@@ -1412,15 +1412,15 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1412
1412
|
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
1413
|
}
|
|
1414
1414
|
if (!t) {
|
|
1415
|
-
let e = n.map((e) => "text" in e ? e.text : ""), t = e.join(""), r = this.consumeEncodingIndicator(() => BigInt(
|
|
1416
|
-
return new
|
|
1415
|
+
let e = n.map((e) => "text" in e ? e.text : ""), t = e.join(""), r = this.consumeEncodingIndicator(() => BigInt(nt.encode(t).length));
|
|
1416
|
+
return new B(t, {
|
|
1417
1417
|
ednParts: e,
|
|
1418
1418
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
1419
1419
|
});
|
|
1420
1420
|
}
|
|
1421
1421
|
let r = [], i = "";
|
|
1422
|
-
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new
|
|
1423
|
-
return i !== "" && r.push(new
|
|
1422
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new B(i)), i = ""), r.push(new z())) : i += e.text;
|
|
1423
|
+
return i !== "" && r.push(new B(i)), new z(r);
|
|
1424
1424
|
}
|
|
1425
1425
|
_isBytesToken(e) {
|
|
1426
1426
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
@@ -1442,7 +1442,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1442
1442
|
}
|
|
1443
1443
|
case "BYTES_HEX": return this._hexToBytes(e.value, e);
|
|
1444
1444
|
case "BYTES_B64": try {
|
|
1445
|
-
return
|
|
1445
|
+
return lt(e.value, t);
|
|
1446
1446
|
} catch (t) {
|
|
1447
1447
|
if (t instanceof r || !(t instanceof SyntaxError)) throw t;
|
|
1448
1448
|
this._fail(t.message, e);
|
|
@@ -1451,11 +1451,11 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
1453
1453
|
_decodeUtf8(e, t) {
|
|
1454
|
-
if (this._options.allowInvalidUtf8) return
|
|
1454
|
+
if (this._options.allowInvalidUtf8) return it.decode(e);
|
|
1455
1455
|
try {
|
|
1456
|
-
return
|
|
1456
|
+
return rt.decode(e);
|
|
1457
1457
|
} catch {
|
|
1458
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t),
|
|
1458
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), it.decode(e);
|
|
1459
1459
|
}
|
|
1460
1460
|
}
|
|
1461
1461
|
_tokenTypeToCdnEncoding(e) {
|
|
@@ -1464,7 +1464,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1464
1464
|
_parseBytesConcat(e, t, n) {
|
|
1465
1465
|
if (this.t.peek().type !== "PLUS") {
|
|
1466
1466
|
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1467
|
-
return new
|
|
1467
|
+
return new N(e, {
|
|
1468
1468
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1469
1469
|
ednSource: n,
|
|
1470
1470
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
@@ -1481,32 +1481,32 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1481
1481
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1482
1482
|
this.t.consume();
|
|
1483
1483
|
let t = this._buildBytesElidedItems(e.value, e);
|
|
1484
|
-
for (let e of t) e instanceof
|
|
1484
|
+
for (let e of t) e instanceof z ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof N && i.push({ bytes: e.value });
|
|
1485
1485
|
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({
|
|
1486
1486
|
bytes: this._decodeBytesToken(e),
|
|
1487
1487
|
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:
|
|
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: nt.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1489
1489
|
}
|
|
1490
1490
|
if (!r) {
|
|
1491
1491
|
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
|
|
1492
|
+
return new N(n, {
|
|
1493
1493
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1494
1494
|
ednParts: e,
|
|
1495
1495
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
1496
1496
|
});
|
|
1497
1497
|
}
|
|
1498
1498
|
let a = [], o = [], s = () => {
|
|
1499
|
-
o.length > 0 && (a.push(new
|
|
1499
|
+
o.length > 0 && (a.push(new N(this._concatBytes([...o]))), o.length = 0);
|
|
1500
1500
|
};
|
|
1501
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new
|
|
1502
|
-
return s(), new
|
|
1501
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new z())) : o.push(e.bytes);
|
|
1502
|
+
return s(), new z(a);
|
|
1503
1503
|
}
|
|
1504
1504
|
_parseHexElidedConcat(e) {
|
|
1505
1505
|
let t = this._buildBytesElidedItems(e.value, e);
|
|
1506
1506
|
for (; this.t.peek().type === "PLUS";) {
|
|
1507
1507
|
this.t.consume();
|
|
1508
1508
|
let e = this.t.peek();
|
|
1509
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new
|
|
1509
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new z());
|
|
1510
1510
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1511
1511
|
this.t.consume();
|
|
1512
1512
|
let n = this._buildBytesElidedItems(e.value, e);
|
|
@@ -1514,20 +1514,20 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1514
1514
|
} else if (this._isBytesToken(e.type)) {
|
|
1515
1515
|
this.t.consume();
|
|
1516
1516
|
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
1517
|
-
r instanceof
|
|
1517
|
+
r instanceof N ? t[t.length - 1] = new N(this._concatBytes([r.value, n])) : t.push(new N(n));
|
|
1518
1518
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1519
1519
|
}
|
|
1520
|
-
return new
|
|
1520
|
+
return new z(t);
|
|
1521
1521
|
}
|
|
1522
1522
|
_buildBytesElidedItems(e, t) {
|
|
1523
1523
|
let n = e.split("..."), r = [];
|
|
1524
|
-
for (let e = 0; e < n.length; e++) e > 0 && r.push(new
|
|
1524
|
+
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
1525
|
return r;
|
|
1526
1526
|
}
|
|
1527
1527
|
_mergeFirstBytesItem(e, t) {
|
|
1528
1528
|
if (t.length === 0) return;
|
|
1529
1529
|
let n = e[e.length - 1], r = t[0];
|
|
1530
|
-
n instanceof
|
|
1530
|
+
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
1531
|
}
|
|
1532
1532
|
_concatBytes(e) {
|
|
1533
1533
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -1538,8 +1538,8 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1538
1538
|
this.t.consume(), this.expect("LPAREN");
|
|
1539
1539
|
let e = this.t.peek();
|
|
1540
1540
|
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
|
|
1541
|
+
let { numStr: t } = ot(e.value), n = Number(st(t));
|
|
1542
|
+
return this.expect("RPAREN"), new R(n);
|
|
1543
1543
|
}
|
|
1544
1544
|
parseEmbeddedCBOR() {
|
|
1545
1545
|
this.t.consume();
|
|
@@ -1556,7 +1556,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1556
1556
|
let e = this.t.consume();
|
|
1557
1557
|
t = this._resolveEncodingWidth(e.value, e);
|
|
1558
1558
|
}
|
|
1559
|
-
return new
|
|
1559
|
+
return new Ue(e, { encodingWidth: t });
|
|
1560
1560
|
}
|
|
1561
1561
|
parseArray() {
|
|
1562
1562
|
this.t.consume();
|
|
@@ -1570,7 +1570,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1570
1570
|
i.push(this.parseValue());
|
|
1571
1571
|
}
|
|
1572
1572
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1573
|
-
let a = new
|
|
1573
|
+
let a = new I(i, {
|
|
1574
1574
|
indefiniteLength: e,
|
|
1575
1575
|
encodingWidth: t
|
|
1576
1576
|
});
|
|
@@ -1591,7 +1591,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1591
1591
|
i.push([e, t]);
|
|
1592
1592
|
}
|
|
1593
1593
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1594
|
-
let a = new
|
|
1594
|
+
let a = new L(i, {
|
|
1595
1595
|
indefiniteLength: e,
|
|
1596
1596
|
encodingWidth: t
|
|
1597
1597
|
});
|
|
@@ -1615,16 +1615,16 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1615
1615
|
}
|
|
1616
1616
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1617
1617
|
let r = n[0];
|
|
1618
|
-
if (r instanceof
|
|
1619
|
-
let e = new
|
|
1620
|
-
if (e instanceof
|
|
1618
|
+
if (r instanceof N) {
|
|
1619
|
+
let e = new P(n.map((e, t) => {
|
|
1620
|
+
if (e instanceof N) return e;
|
|
1621
1621
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
1622
1622
|
}));
|
|
1623
1623
|
return t.length > 0 && (e.warnings = t), e;
|
|
1624
1624
|
}
|
|
1625
|
-
if (r instanceof
|
|
1626
|
-
let e = new
|
|
1627
|
-
if (e instanceof
|
|
1625
|
+
if (r instanceof B) {
|
|
1626
|
+
let e = new F(n.map((e, t) => {
|
|
1627
|
+
if (e instanceof B) return e;
|
|
1628
1628
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
1629
1629
|
}));
|
|
1630
1630
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -1642,47 +1642,47 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1642
1642
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
1643
1643
|
}
|
|
1644
1644
|
_applyEiToResult(e, t, n) {
|
|
1645
|
-
if (e instanceof
|
|
1645
|
+
if (e instanceof j) {
|
|
1646
1646
|
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
1647
1647
|
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
1648
1648
|
else if (e.precision !== r) {
|
|
1649
1649
|
if (r !== "double") {
|
|
1650
|
-
let t = r === "half" ?
|
|
1650
|
+
let t = r === "half" ? C(S(e.value)) : Math.fround(e.value);
|
|
1651
1651
|
!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
1652
|
}
|
|
1653
1653
|
e.precision = r;
|
|
1654
1654
|
}
|
|
1655
|
-
} else if (e instanceof
|
|
1655
|
+
} else if (e instanceof k) {
|
|
1656
1656
|
if (e.encodingWidth === void 0) {
|
|
1657
1657
|
let r = this._validateEncodingFit(e.value, t, n);
|
|
1658
1658
|
r !== void 0 && (e.encodingWidth = r);
|
|
1659
1659
|
}
|
|
1660
|
-
} else if (e instanceof
|
|
1660
|
+
} else if (e instanceof A) {
|
|
1661
1661
|
if (e.encodingWidth === void 0) {
|
|
1662
1662
|
let r = this._validateEncodingFit(e.argument, t, n);
|
|
1663
1663
|
r !== void 0 && (e.encodingWidth = r);
|
|
1664
1664
|
}
|
|
1665
|
-
} else if (e instanceof
|
|
1665
|
+
} else if (e instanceof N) {
|
|
1666
1666
|
if (e.encodingWidth === void 0) {
|
|
1667
1667
|
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
1668
1668
|
r !== void 0 && (e.encodingWidth = r);
|
|
1669
1669
|
}
|
|
1670
|
-
} else if (e instanceof
|
|
1670
|
+
} else if (e instanceof B) {
|
|
1671
1671
|
if (e.encodingWidth === void 0) {
|
|
1672
|
-
let r = this._validateEncodingFit(BigInt(
|
|
1672
|
+
let r = this._validateEncodingFit(BigInt(nt.encode(e.value).length), t, n);
|
|
1673
1673
|
r !== void 0 && (e.encodingWidth = r);
|
|
1674
1674
|
}
|
|
1675
|
-
} else if (e instanceof
|
|
1675
|
+
} else if (e instanceof I) {
|
|
1676
1676
|
if (e.encodingWidth === void 0) {
|
|
1677
1677
|
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
1678
1678
|
r !== void 0 && (e.encodingWidth = r);
|
|
1679
1679
|
}
|
|
1680
|
-
} else if (e instanceof
|
|
1680
|
+
} else if (e instanceof L) {
|
|
1681
1681
|
if (e.encodingWidth === void 0) {
|
|
1682
1682
|
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
1683
1683
|
r !== void 0 && (e.encodingWidth = r);
|
|
1684
1684
|
}
|
|
1685
|
-
} else if (e instanceof
|
|
1685
|
+
} else if (e instanceof M) {
|
|
1686
1686
|
if (e.encodingWidth === void 0) {
|
|
1687
1687
|
let r = this._validateEncodingFit(e.tag, t, n);
|
|
1688
1688
|
r !== void 0 && (e.encodingWidth = r);
|
|
@@ -1690,7 +1690,7 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1690
1690
|
} else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
|
|
1691
1691
|
}
|
|
1692
1692
|
_validateEncodingFit(e, t, n) {
|
|
1693
|
-
let r =
|
|
1693
|
+
let r = Pe(t);
|
|
1694
1694
|
if (e <= r) return t;
|
|
1695
1695
|
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
1696
1696
|
this._warnOrFail(i, n);
|
|
@@ -1714,28 +1714,28 @@ var pt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1714
1714
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
1715
1715
|
}
|
|
1716
1716
|
_hintMissingExtension(e, t) {
|
|
1717
|
-
let n =
|
|
1717
|
+
let n = gt.get(e);
|
|
1718
1718
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
1719
1719
|
this._hintedPrefixes.add(e);
|
|
1720
1720
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
1721
1721
|
this._options.onWarning ? this._options.onWarning({
|
|
1722
1722
|
message: r,
|
|
1723
|
-
...
|
|
1723
|
+
...vt(t)
|
|
1724
1724
|
}) : this._options.silent || console.warn(`CDN: ${r}`);
|
|
1725
1725
|
}
|
|
1726
1726
|
_warn(e, t) {
|
|
1727
1727
|
let n = { message: e };
|
|
1728
|
-
if (t !== void 0 && Object.assign(n,
|
|
1728
|
+
if (t !== void 0 && Object.assign(n, vt(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
|
|
1729
1729
|
else if (!this._options.silent) {
|
|
1730
1730
|
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
1731
1731
|
console.warn(`CDN strict violation${n}: ${e}`);
|
|
1732
1732
|
}
|
|
1733
1733
|
}
|
|
1734
1734
|
_fail(e, t) {
|
|
1735
|
-
throw new r(e, t ?
|
|
1735
|
+
throw new r(e, t ? vt(t) : void 0);
|
|
1736
1736
|
}
|
|
1737
1737
|
};
|
|
1738
|
-
function
|
|
1738
|
+
function vt(e) {
|
|
1739
1739
|
return {
|
|
1740
1740
|
offset: e.offset,
|
|
1741
1741
|
line: e.line,
|
|
@@ -1745,7 +1745,7 @@ function _t(e) {
|
|
|
1745
1745
|
}
|
|
1746
1746
|
//#endregion
|
|
1747
1747
|
//#region src/ast/CborTextString.ts
|
|
1748
|
-
var
|
|
1748
|
+
var yt = new TextEncoder(), bt = !1, B = class extends O {
|
|
1749
1749
|
indefiniteLength = !1;
|
|
1750
1750
|
value;
|
|
1751
1751
|
encodingWidth;
|
|
@@ -1757,51 +1757,66 @@ var vt = new TextEncoder(), yt = !1, V = class extends k {
|
|
|
1757
1757
|
e.writeTextString(3, this.value, this.encodingWidth);
|
|
1758
1758
|
}
|
|
1759
1759
|
_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);
|
|
1760
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(yt.encode(this.value).length)));
|
|
1761
|
+
return xt(this.value, n, e, t, this.ednParts);
|
|
1766
1762
|
}
|
|
1767
1763
|
_toJS(e) {
|
|
1768
1764
|
return this.value;
|
|
1769
1765
|
}
|
|
1770
1766
|
};
|
|
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
|
-
|
|
1767
|
+
function xt(e, t, n, r, i) {
|
|
1768
|
+
let { cdn: a, newline: o } = Ct(n), s = ee(n), c = n?.preserveConcatenation && i !== void 0 && i.length > 1 ? i : void 0;
|
|
1769
|
+
if (s === null) return c === void 0 ? Se(e) + t : St(c.map((e) => ({
|
|
1770
|
+
text: e,
|
|
1771
|
+
contentDepth: 0
|
|
1772
|
+
})), t, null, r);
|
|
1773
|
+
if (!a && !o && c === void 0) return Se(e) + t;
|
|
1774
|
+
let l = a ? Et(e) : null;
|
|
1775
|
+
if (l === null && c !== void 0) {
|
|
1776
|
+
let e = [];
|
|
1777
|
+
for (let t of c) if (o) {
|
|
1778
|
+
let n = /* @__PURE__ */ new Map();
|
|
1779
|
+
for (let { point: e, contentDepth: r } of Tt(t, 0)) n.set(e, r);
|
|
1780
|
+
e.push(...Pt(t, n));
|
|
1781
|
+
} else e.push({
|
|
1782
|
+
text: t,
|
|
1783
|
+
contentDepth: 0
|
|
1784
|
+
});
|
|
1785
|
+
return St(e, t, s, r);
|
|
1786
|
+
}
|
|
1787
|
+
let u = /* @__PURE__ */ new Map();
|
|
1788
|
+
if (l !== null) for (let { point: e, contentDepth: t } of l) u.set(e, t);
|
|
1789
|
+
if (o) {
|
|
1790
|
+
let t = l === null ? Tt(e, 0) : Dt(e);
|
|
1791
|
+
for (let { point: e, contentDepth: n } of t) u.has(e) || u.set(e, n);
|
|
1792
|
+
}
|
|
1793
|
+
let d = Pt(e, u);
|
|
1794
|
+
return d.length <= 1 ? Se(e) + t : St(d, t, s, r);
|
|
1795
|
+
}
|
|
1796
|
+
function St(e, t, n, r) {
|
|
1797
|
+
let i = e.map(({ text: n }, r) => {
|
|
1798
|
+
let i = Se(n);
|
|
1799
|
+
return r === e.length - 1 ? i + t : i;
|
|
1800
|
+
});
|
|
1801
|
+
if (n === null) return i.join(" + ");
|
|
1802
|
+
let a = i[0];
|
|
1803
|
+
for (let t = 1; t < i.length; t++) {
|
|
1804
|
+
let o = _(n, r + 1 + e[t].contentDepth);
|
|
1805
|
+
a += ` +\n${o}${i[t]}`;
|
|
1806
|
+
}
|
|
1807
|
+
return a;
|
|
1808
|
+
}
|
|
1809
|
+
function Ct(e) {
|
|
1810
|
+
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ? wt(e?.textStringFormat ?? []) : [];
|
|
1811
|
+
return {
|
|
1812
|
+
cdn: e?.splitCdn ?? t.includes("cdn"),
|
|
1813
|
+
newline: e?.splitNewline ?? t.includes("newline")
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
function wt(e) {
|
|
1817
|
+
return e.map((e) => e === "cboredn" ? (bt || (bt = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
1818
|
+
}
|
|
1819
|
+
function Tt(e, t) {
|
|
1805
1820
|
let n = [];
|
|
1806
1821
|
for (let r = 0; r < e.length; r++) {
|
|
1807
1822
|
let i = e[r];
|
|
@@ -1818,9 +1833,9 @@ function Ct(e, t) {
|
|
|
1818
1833
|
}
|
|
1819
1834
|
return n;
|
|
1820
1835
|
}
|
|
1821
|
-
function
|
|
1836
|
+
function Et(e) {
|
|
1822
1837
|
try {
|
|
1823
|
-
|
|
1838
|
+
at(e);
|
|
1824
1839
|
} catch {
|
|
1825
1840
|
return null;
|
|
1826
1841
|
}
|
|
@@ -1829,24 +1844,24 @@ function wt(e) {
|
|
|
1829
1844
|
let a = n.consume();
|
|
1830
1845
|
if (a.type === "EOF") break;
|
|
1831
1846
|
let c = !1;
|
|
1832
|
-
if (o || (o = !0, a.offset > 0 &&
|
|
1847
|
+
if (o || (o = !0, a.offset > 0 && Mt(n.comments, 0, a.offset) && t.push({
|
|
1833
1848
|
point: a.offset,
|
|
1834
1849
|
contentDepth: r
|
|
1835
1850
|
})), i !== null) {
|
|
1836
|
-
if (i.kind === "opener" &&
|
|
1851
|
+
if (i.kind === "opener" && kt.has(a.type)) {
|
|
1837
1852
|
i.point = a.endOffset, s = a.endOffset;
|
|
1838
1853
|
continue;
|
|
1839
|
-
} else i.kind === "opener" &&
|
|
1854
|
+
} else i.kind === "opener" && jt.has(a.type) && Nt(e, i.point, a.offset) ? c = !0 : t.push({
|
|
1840
1855
|
point: a.offset,
|
|
1841
1856
|
contentDepth: i.contentDepth
|
|
1842
1857
|
});
|
|
1843
1858
|
i = null;
|
|
1844
1859
|
}
|
|
1845
|
-
|
|
1860
|
+
At.has(a.type) ? (r++, i = {
|
|
1846
1861
|
point: a.endOffset,
|
|
1847
1862
|
contentDepth: r,
|
|
1848
1863
|
kind: "opener"
|
|
1849
|
-
}) :
|
|
1864
|
+
}) : jt.has(a.type) ? (r = Math.max(0, r - 1), c || t.push({
|
|
1850
1865
|
point: a.offset,
|
|
1851
1866
|
contentDepth: r
|
|
1852
1867
|
})) : a.type === "COMMA" && (i = {
|
|
@@ -1861,23 +1876,23 @@ function wt(e) {
|
|
|
1861
1876
|
contentDepth: r
|
|
1862
1877
|
}), t;
|
|
1863
1878
|
}
|
|
1864
|
-
function
|
|
1879
|
+
function Dt(e) {
|
|
1865
1880
|
let t = [], n = new a(e), r = 0;
|
|
1866
1881
|
for (;;) {
|
|
1867
1882
|
let i = n.consume();
|
|
1868
1883
|
if (i.type === "EOF") break;
|
|
1869
|
-
if (
|
|
1870
|
-
else if (
|
|
1884
|
+
if (At.has(i.type)) r++;
|
|
1885
|
+
else if (jt.has(i.type)) r = Math.max(0, r - 1);
|
|
1871
1886
|
else if (i.type !== "COMMA") {
|
|
1872
1887
|
if (i.type === "TSTR") {
|
|
1873
1888
|
let n = e.slice(i.offset, i.endOffset);
|
|
1874
|
-
for (let e of
|
|
1889
|
+
for (let e of Ot(n)) t.push({
|
|
1875
1890
|
point: i.offset + e,
|
|
1876
1891
|
contentDepth: r + 1
|
|
1877
1892
|
});
|
|
1878
1893
|
} else if (i.type === "RAWSTRING") {
|
|
1879
1894
|
let n = e.slice(i.offset, i.endOffset);
|
|
1880
|
-
for (let { point: e } of
|
|
1895
|
+
for (let { point: e } of Tt(n, 0)) t.push({
|
|
1881
1896
|
point: i.offset + e,
|
|
1882
1897
|
contentDepth: r + 1
|
|
1883
1898
|
});
|
|
@@ -1886,7 +1901,7 @@ function Tt(e) {
|
|
|
1886
1901
|
}
|
|
1887
1902
|
return t;
|
|
1888
1903
|
}
|
|
1889
|
-
function
|
|
1904
|
+
function Ot(e) {
|
|
1890
1905
|
let t = [], n = 1, r = e.length - 1;
|
|
1891
1906
|
for (; n < r;) {
|
|
1892
1907
|
let r = e[n];
|
|
@@ -1902,24 +1917,24 @@ function Et(e) {
|
|
|
1902
1917
|
}
|
|
1903
1918
|
return t;
|
|
1904
1919
|
}
|
|
1905
|
-
var
|
|
1920
|
+
var kt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), At = /* @__PURE__ */ new Set([
|
|
1906
1921
|
"LBRACKET",
|
|
1907
1922
|
"LBRACE",
|
|
1908
1923
|
"LPAREN",
|
|
1909
1924
|
"LT_LT"
|
|
1910
|
-
]),
|
|
1925
|
+
]), jt = /* @__PURE__ */ new Set([
|
|
1911
1926
|
"RBRACKET",
|
|
1912
1927
|
"RBRACE",
|
|
1913
1928
|
"RPAREN",
|
|
1914
1929
|
"GT_GT"
|
|
1915
1930
|
]);
|
|
1916
|
-
function
|
|
1931
|
+
function Mt(e, t, n) {
|
|
1917
1932
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
1918
1933
|
}
|
|
1919
|
-
function
|
|
1934
|
+
function Nt(e, t, n) {
|
|
1920
1935
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
1921
1936
|
}
|
|
1922
|
-
function
|
|
1937
|
+
function Pt(e, t) {
|
|
1923
1938
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
1924
1939
|
if (n.length === 0) return [{
|
|
1925
1940
|
text: e,
|
|
@@ -1937,7 +1952,7 @@ function Mt(e, t) {
|
|
|
1937
1952
|
}
|
|
1938
1953
|
//#endregion
|
|
1939
1954
|
//#region src/extensions/dt.ts
|
|
1940
|
-
function
|
|
1955
|
+
function V(e) {
|
|
1941
1956
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
1942
1957
|
let t = Math.round(e * 1e3);
|
|
1943
1958
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -1945,17 +1960,17 @@ function Nt(e) {
|
|
|
1945
1960
|
for (; s.length < 3;) s += "0";
|
|
1946
1961
|
return `${i}.${s}Z`;
|
|
1947
1962
|
}
|
|
1948
|
-
var
|
|
1949
|
-
function
|
|
1963
|
+
var Ft = new TextDecoder("utf-8", { fatal: !0 });
|
|
1964
|
+
function It(e) {
|
|
1950
1965
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
1951
1966
|
let t = e[0];
|
|
1952
|
-
if (t instanceof
|
|
1953
|
-
if (t instanceof
|
|
1967
|
+
if (t instanceof B) return t.value;
|
|
1968
|
+
if (t instanceof N) return Ft.decode(t.value);
|
|
1954
1969
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
1955
1970
|
}
|
|
1956
|
-
var
|
|
1957
|
-
function
|
|
1958
|
-
if (!
|
|
1971
|
+
var Lt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
1972
|
+
function Rt(e, t) {
|
|
1973
|
+
if (!Lt.test(e)) {
|
|
1959
1974
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
1960
1975
|
if (t) t(n);
|
|
1961
1976
|
else throw SyntaxError(n);
|
|
@@ -1966,93 +1981,93 @@ function Lt(e, t) {
|
|
|
1966
1981
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
1967
1982
|
if (i === void 0) {
|
|
1968
1983
|
let e = a / 1e3;
|
|
1969
|
-
return e >= 0 ? new
|
|
1984
|
+
return e >= 0 ? new Bt(BigInt(e)) : new Vt(BigInt(e));
|
|
1970
1985
|
}
|
|
1971
|
-
return new
|
|
1986
|
+
return new Ht(a / 1e3 + i);
|
|
1972
1987
|
}
|
|
1973
|
-
var
|
|
1988
|
+
var zt = 1n, Bt = class extends k {
|
|
1974
1989
|
constructor(e, t) {
|
|
1975
1990
|
super(e, t);
|
|
1976
1991
|
}
|
|
1977
1992
|
_toCDN(e, t) {
|
|
1978
1993
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1979
|
-
let n =
|
|
1980
|
-
return `dt'${
|
|
1994
|
+
let n = x(e, this.encodingWidth, () => b(this.value));
|
|
1995
|
+
return `dt'${V(Number(this.value))}'${n}`;
|
|
1981
1996
|
}
|
|
1982
|
-
},
|
|
1997
|
+
}, Vt = class extends A {
|
|
1983
1998
|
constructor(e, t) {
|
|
1984
1999
|
super(e, t);
|
|
1985
2000
|
}
|
|
1986
2001
|
_toCDN(e, t) {
|
|
1987
2002
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1988
|
-
let n =
|
|
1989
|
-
return `dt'${
|
|
2003
|
+
let n = x(e, this.encodingWidth, () => b(this.argument));
|
|
2004
|
+
return `dt'${V(Number(this.value))}'${n}`;
|
|
1990
2005
|
}
|
|
1991
|
-
},
|
|
2006
|
+
}, Ht = class extends j {
|
|
1992
2007
|
constructor(e, t) {
|
|
1993
2008
|
super(e, t);
|
|
1994
2009
|
}
|
|
1995
2010
|
_toCDN(e, t) {
|
|
1996
2011
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1997
|
-
let n =
|
|
1998
|
-
return `dt'${
|
|
2012
|
+
let n = D(this.value), r = we(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
2013
|
+
return `dt'${V(this.value)}'${r}`;
|
|
1999
2014
|
}
|
|
2000
|
-
},
|
|
2015
|
+
}, Ut = class extends M {
|
|
2001
2016
|
constructor(e, t) {
|
|
2002
|
-
super(
|
|
2017
|
+
super(zt, typeof e == "string" ? Rt(e) : e, t);
|
|
2003
2018
|
}
|
|
2004
2019
|
_toCDN(e, t) {
|
|
2005
2020
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2006
2021
|
let n = this.content;
|
|
2007
|
-
if (n instanceof
|
|
2022
|
+
if (n instanceof j ? n.precision !== void 0 && n.precision !== D(n.value) : n.encodingWidth !== void 0) return super._toCDN({
|
|
2008
2023
|
...e,
|
|
2009
2024
|
appStrings: !1
|
|
2010
2025
|
}, t);
|
|
2011
|
-
let r = n instanceof
|
|
2012
|
-
return `DT'${
|
|
2026
|
+
let r = n instanceof j ? n.value : Number(n.value), i = x(e, this.encodingWidth, () => b(zt));
|
|
2027
|
+
return `DT'${V(r)}'${i}`;
|
|
2013
2028
|
}
|
|
2014
|
-
},
|
|
2029
|
+
}, Wt = class extends Ut {
|
|
2015
2030
|
constructor(e, t) {
|
|
2016
2031
|
super(e, t);
|
|
2017
2032
|
}
|
|
2018
2033
|
_toJS(e) {
|
|
2019
|
-
let t = this.content, n = t instanceof
|
|
2034
|
+
let t = this.content, n = t instanceof j ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
2020
2035
|
return new Date(n);
|
|
2021
2036
|
}
|
|
2022
2037
|
};
|
|
2023
|
-
function
|
|
2038
|
+
function Gt(e) {
|
|
2024
2039
|
let t = e?.jsDate ?? !1;
|
|
2025
2040
|
function n(e) {
|
|
2026
|
-
return t ? new
|
|
2041
|
+
return t ? new Wt(e) : new Ut(e);
|
|
2027
2042
|
}
|
|
2028
2043
|
let r = {
|
|
2029
2044
|
appStringPrefixes: ["dt", "DT"],
|
|
2030
|
-
tagNumbers: [
|
|
2045
|
+
tagNumbers: [zt],
|
|
2031
2046
|
parseAppString(e, t, r) {
|
|
2032
|
-
return e === "DT" ? n(t) :
|
|
2047
|
+
return e === "DT" ? n(t) : Rt(t, r);
|
|
2033
2048
|
},
|
|
2034
2049
|
parseAppSequence(e, t, r) {
|
|
2035
|
-
let i =
|
|
2036
|
-
return e === "DT" ? n(i) :
|
|
2050
|
+
let i = It(t);
|
|
2051
|
+
return e === "DT" ? n(i) : Rt(i, r);
|
|
2037
2052
|
},
|
|
2038
2053
|
parseTag(e, n) {
|
|
2039
2054
|
if (e !== 1n) return;
|
|
2040
2055
|
let r;
|
|
2041
|
-
if (n instanceof
|
|
2042
|
-
else if (n instanceof
|
|
2043
|
-
else if (n instanceof
|
|
2056
|
+
if (n instanceof k) r = new Bt(n.value, { encodingWidth: n.encodingWidth });
|
|
2057
|
+
else if (n instanceof A) r = new Vt(n.value, { encodingWidth: n.encodingWidth });
|
|
2058
|
+
else if (n instanceof j) r = new Ht(n.value), n.precision !== void 0 && (r.precision = n.precision);
|
|
2044
2059
|
else return;
|
|
2045
|
-
return r.start = n.start, r.end = n.end, t ? new
|
|
2060
|
+
return r.start = n.start, r.end = n.end, t ? new Wt(r) : new Ut(r);
|
|
2046
2061
|
}
|
|
2047
2062
|
};
|
|
2048
2063
|
return t && (r.fromJS = (e, t) => {
|
|
2049
|
-
if (e instanceof Date) return new
|
|
2064
|
+
if (e instanceof Date) return new Wt(V(e.getTime() / 1e3));
|
|
2050
2065
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2051
2066
|
}
|
|
2052
|
-
var
|
|
2067
|
+
var Kt = Gt(), qt = Gt({ jsDate: !0 });
|
|
2053
2068
|
//#endregion
|
|
2054
2069
|
//#region src/utils/ip.ts
|
|
2055
|
-
function
|
|
2070
|
+
function Jt(e) {
|
|
2056
2071
|
let t = e.split(".");
|
|
2057
2072
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2058
2073
|
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
@@ -2065,11 +2080,11 @@ function qt(e) {
|
|
|
2065
2080
|
}
|
|
2066
2081
|
return n;
|
|
2067
2082
|
}
|
|
2068
|
-
function
|
|
2083
|
+
function Yt(e) {
|
|
2069
2084
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
2070
2085
|
if (e === "::") return t;
|
|
2071
2086
|
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 =
|
|
2087
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Jt(i[2]));
|
|
2073
2088
|
let a = n.split("::");
|
|
2074
2089
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2075
2090
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -2086,11 +2101,11 @@ function Jt(e) {
|
|
|
2086
2101
|
}
|
|
2087
2102
|
return r && t.set(r, 12), t;
|
|
2088
2103
|
}
|
|
2089
|
-
function
|
|
2104
|
+
function Xt(e) {
|
|
2090
2105
|
return Array.from(e).join(".");
|
|
2091
2106
|
}
|
|
2092
|
-
function
|
|
2093
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2107
|
+
function Zt(e) {
|
|
2108
|
+
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
2109
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2095
2110
|
let i = -1, a = 0, o = 0;
|
|
2096
2111
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2104,29 +2119,29 @@ function Xt(e) {
|
|
|
2104
2119
|
}
|
|
2105
2120
|
//#endregion
|
|
2106
2121
|
//#region src/extensions/ip.ts
|
|
2107
|
-
var
|
|
2108
|
-
function
|
|
2122
|
+
var Qt = "ip", H = "IP", U = 52n, $t = 54n, en = new TextDecoder("utf-8", { fatal: !0 });
|
|
2123
|
+
function tn(e) {
|
|
2109
2124
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2110
2125
|
let t = e[0];
|
|
2111
|
-
if (t instanceof
|
|
2112
|
-
if (t instanceof
|
|
2126
|
+
if (t instanceof B) return t.value;
|
|
2127
|
+
if (t instanceof N) return en.decode(t.value);
|
|
2113
2128
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2114
2129
|
}
|
|
2115
|
-
function
|
|
2130
|
+
function nn(e) {
|
|
2116
2131
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2117
|
-
bytes:
|
|
2132
|
+
bytes: Jt(e),
|
|
2118
2133
|
isV4: !0
|
|
2119
2134
|
} : {
|
|
2120
|
-
bytes:
|
|
2135
|
+
bytes: Yt(e),
|
|
2121
2136
|
isV4: !1
|
|
2122
2137
|
};
|
|
2123
2138
|
}
|
|
2124
|
-
function
|
|
2125
|
-
if (e.length === 4) return
|
|
2126
|
-
if (e.length === 16) return
|
|
2139
|
+
function rn(e) {
|
|
2140
|
+
if (e.length === 4) return Xt(e);
|
|
2141
|
+
if (e.length === 16) return Zt(e);
|
|
2127
2142
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2128
2143
|
}
|
|
2129
|
-
function
|
|
2144
|
+
function an(e, t) {
|
|
2130
2145
|
let n = new Uint8Array(e.length);
|
|
2131
2146
|
n.set(e);
|
|
2132
2147
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2136,86 +2151,86 @@ function rn(e, t) {
|
|
|
2136
2151
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2137
2152
|
return n.slice(0, a);
|
|
2138
2153
|
}
|
|
2139
|
-
function
|
|
2154
|
+
function on(e, t) {
|
|
2140
2155
|
let n = new Uint8Array(t);
|
|
2141
2156
|
return n.set(e), n;
|
|
2142
2157
|
}
|
|
2143
|
-
var
|
|
2158
|
+
var sn = class extends N {
|
|
2144
2159
|
_toCDN(e, t) {
|
|
2145
2160
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2146
|
-
let n =
|
|
2147
|
-
return `${
|
|
2161
|
+
let n = x(e, this.encodingWidth, () => b(BigInt(this.value.length)));
|
|
2162
|
+
return `${Qt}'${rn(this.value)}'${n}`;
|
|
2148
2163
|
}
|
|
2149
|
-
},
|
|
2164
|
+
}, cn = class extends I {
|
|
2150
2165
|
_isV4;
|
|
2151
2166
|
constructor(e, t, n) {
|
|
2152
|
-
super([new
|
|
2167
|
+
super([new k(BigInt(e)), new N(t)]), this._isV4 = n;
|
|
2153
2168
|
}
|
|
2154
2169
|
_toCDN(e, t) {
|
|
2155
2170
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2156
2171
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2157
|
-
return `${
|
|
2172
|
+
return `${Qt}'${rn(on(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2158
2173
|
}
|
|
2159
|
-
},
|
|
2174
|
+
}, ln = class extends M {
|
|
2160
2175
|
constructor(e, t) {
|
|
2161
2176
|
super(e, t);
|
|
2162
2177
|
}
|
|
2163
2178
|
_toCDN(e, t) {
|
|
2164
2179
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2165
2180
|
let n = this.tag === U ? 4 : 16, r = this.content;
|
|
2166
|
-
if (r instanceof
|
|
2181
|
+
if (r instanceof N) {
|
|
2167
2182
|
if (r.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2168
|
-
let n =
|
|
2169
|
-
return `${H}'${
|
|
2183
|
+
let n = x(e, this.encodingWidth, () => b(this.tag));
|
|
2184
|
+
return `${H}'${rn(r.value)}'${n}`;
|
|
2170
2185
|
}
|
|
2171
|
-
if (r instanceof
|
|
2186
|
+
if (r instanceof I && r.items.length === 2 && r.items[0] instanceof k && r.items[1] instanceof N) {
|
|
2172
2187
|
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}'${
|
|
2188
|
+
let i = Number(r.items[0].value), a = on(r.items[1].value, n), o = x(e, this.encodingWidth, () => b(this.tag));
|
|
2189
|
+
return `${H}'${rn(a)}/${i}'${o}`;
|
|
2175
2190
|
}
|
|
2176
2191
|
return super._toCDN(e, t);
|
|
2177
2192
|
}
|
|
2178
2193
|
};
|
|
2179
|
-
function
|
|
2194
|
+
function un(e, t) {
|
|
2180
2195
|
let n = t.indexOf("/");
|
|
2181
2196
|
if (n === -1) {
|
|
2182
|
-
let { bytes: n, isV4: r } =
|
|
2183
|
-
return e === H ? new
|
|
2197
|
+
let { bytes: n, isV4: r } = nn(t);
|
|
2198
|
+
return e === H ? new ln(r ? U : $t, new N(n)) : new sn(n);
|
|
2184
2199
|
}
|
|
2185
2200
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2186
2201
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2187
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2202
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = nn(r), c = s ? 32 : 128;
|
|
2188
2203
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2189
|
-
let l =
|
|
2190
|
-
return e === H ? new
|
|
2204
|
+
let l = an(o, a);
|
|
2205
|
+
return e === H ? new ln(s ? U : $t, new I([new k(BigInt(a)), new N(l)])) : new cn(a, l, s);
|
|
2191
2206
|
}
|
|
2192
|
-
var
|
|
2193
|
-
appStringPrefixes: [
|
|
2194
|
-
tagNumbers: [U,
|
|
2207
|
+
var dn = {
|
|
2208
|
+
appStringPrefixes: [Qt, H],
|
|
2209
|
+
tagNumbers: [U, $t],
|
|
2195
2210
|
parseAppString(e, t) {
|
|
2196
|
-
return
|
|
2211
|
+
return un(e, t);
|
|
2197
2212
|
},
|
|
2198
2213
|
parseAppSequence(e, t) {
|
|
2199
|
-
return
|
|
2214
|
+
return un(e, tn(t));
|
|
2200
2215
|
},
|
|
2201
2216
|
parseTag(e, t) {
|
|
2202
|
-
if (!(e !== U && e !==
|
|
2217
|
+
if (!(e !== U && e !== $t) && (t instanceof N || t instanceof I)) return new ln(e, t);
|
|
2203
2218
|
}
|
|
2204
|
-
},
|
|
2205
|
-
tagNumbers: [
|
|
2219
|
+
}, fn = 18446744073709551615n, pn = -18446744073709551616n, mn = {
|
|
2220
|
+
tagNumbers: [Je, Ye],
|
|
2206
2221
|
parseTag(e, t) {
|
|
2207
|
-
if (t instanceof
|
|
2222
|
+
if (t instanceof N) {
|
|
2208
2223
|
if (e === 2n) {
|
|
2209
|
-
let e =
|
|
2210
|
-
return e >
|
|
2224
|
+
let e = $e(t.value);
|
|
2225
|
+
return e > fn ? new et(e) : void 0;
|
|
2211
2226
|
}
|
|
2212
2227
|
if (e === 3n) {
|
|
2213
|
-
let e = -1n -
|
|
2214
|
-
return e <
|
|
2228
|
+
let e = -1n - $e(t.value);
|
|
2229
|
+
return e < pn ? new tt(e) : void 0;
|
|
2215
2230
|
}
|
|
2216
2231
|
}
|
|
2217
2232
|
}
|
|
2218
|
-
},
|
|
2233
|
+
}, hn = "cri", gn = "CRI", _n = 99n, vn = /* @__PURE__ */ new Map([
|
|
2219
2234
|
["coap", -1n],
|
|
2220
2235
|
["coaps", -2n],
|
|
2221
2236
|
["http", -3n],
|
|
@@ -2226,7 +2241,7 @@ var un = {
|
|
|
2226
2241
|
["coaps+tcp", -8n],
|
|
2227
2242
|
["coap+ws", -25n],
|
|
2228
2243
|
["coaps+ws", -26n]
|
|
2229
|
-
]),
|
|
2244
|
+
]), yn = new Map([...vn.entries()].map(([e, t]) => [t, e]));
|
|
2230
2245
|
function W(e) {
|
|
2231
2246
|
try {
|
|
2232
2247
|
return decodeURIComponent(e);
|
|
@@ -2234,39 +2249,39 @@ function W(e) {
|
|
|
2234
2249
|
return e;
|
|
2235
2250
|
}
|
|
2236
2251
|
}
|
|
2237
|
-
var
|
|
2238
|
-
function
|
|
2239
|
-
return Array.from(
|
|
2252
|
+
var bn = new TextEncoder(), xn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2253
|
+
function Sn(e) {
|
|
2254
|
+
return Array.from(bn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2240
2255
|
}
|
|
2241
2256
|
function G(e, t) {
|
|
2242
2257
|
let n = "";
|
|
2243
|
-
for (let r of e) n += t(r) ? r :
|
|
2258
|
+
for (let r of e) n += t(r) ? r : Sn(r);
|
|
2244
2259
|
return n;
|
|
2245
2260
|
}
|
|
2246
|
-
function Sn(e) {
|
|
2247
|
-
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2248
|
-
}
|
|
2249
2261
|
function Cn(e) {
|
|
2250
|
-
return /[
|
|
2262
|
+
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2251
2263
|
}
|
|
2252
2264
|
function wn(e) {
|
|
2253
|
-
return
|
|
2265
|
+
return /[!$&'()*+,;=]/.test(e);
|
|
2254
2266
|
}
|
|
2255
2267
|
function Tn(e) {
|
|
2256
|
-
return (wn(e) || e === "
|
|
2268
|
+
return Cn(e) || wn(e) || e === ":" || e === "@";
|
|
2257
2269
|
}
|
|
2258
2270
|
function En(e) {
|
|
2259
|
-
return
|
|
2271
|
+
return (Tn(e) || e === "/" || e === "?") && e !== "&";
|
|
2260
2272
|
}
|
|
2261
2273
|
function Dn(e) {
|
|
2262
|
-
return
|
|
2274
|
+
return Tn(e) || e === "/" || e === "?";
|
|
2263
2275
|
}
|
|
2264
2276
|
function On(e) {
|
|
2265
|
-
return
|
|
2277
|
+
return Cn(e) || wn(e) || e === ":";
|
|
2266
2278
|
}
|
|
2267
2279
|
function kn(e) {
|
|
2280
|
+
return Cn(e) || wn(e);
|
|
2281
|
+
}
|
|
2282
|
+
function An(e) {
|
|
2268
2283
|
let t = [], n = e, r = n.indexOf("@");
|
|
2269
|
-
r >= 0 && (t.push(
|
|
2284
|
+
r >= 0 && (t.push(R.FALSE), t.push(new B(W(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2270
2285
|
let i, a = null;
|
|
2271
2286
|
if (n.startsWith("[")) {
|
|
2272
2287
|
let e = n.indexOf("]");
|
|
@@ -2275,162 +2290,162 @@ function kn(e) {
|
|
|
2275
2290
|
let r = n.slice(e + 1);
|
|
2276
2291
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2277
2292
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2278
|
-
t.push(new
|
|
2293
|
+
t.push(new N(Yt(i)));
|
|
2279
2294
|
} else {
|
|
2280
2295
|
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
|
|
2296
|
+
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)));
|
|
2297
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new B(e));
|
|
2283
2298
|
}
|
|
2284
2299
|
if (a !== null && a !== "") {
|
|
2285
2300
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2286
2301
|
let e = parseInt(a, 10);
|
|
2287
2302
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2288
|
-
t.push(new
|
|
2303
|
+
t.push(new k(BigInt(e)));
|
|
2289
2304
|
}
|
|
2290
|
-
return new
|
|
2305
|
+
return new I(t);
|
|
2291
2306
|
}
|
|
2292
|
-
function
|
|
2307
|
+
function jn(e) {
|
|
2293
2308
|
let t = e.items, n = 0, r = "";
|
|
2294
|
-
if (n < t.length && t[n] instanceof
|
|
2309
|
+
if (n < t.length && t[n] instanceof R && t[n].value === 20) {
|
|
2295
2310
|
n++;
|
|
2296
2311
|
let e = t[n++];
|
|
2297
|
-
r += G(e.value,
|
|
2312
|
+
r += G(e.value, On) + "@";
|
|
2298
2313
|
}
|
|
2299
2314
|
if (n >= t.length) return r;
|
|
2300
2315
|
let i = t[n];
|
|
2301
|
-
if (i instanceof
|
|
2316
|
+
if (i instanceof N) {
|
|
2302
2317
|
n++;
|
|
2303
2318
|
let { length: e } = i.value;
|
|
2304
|
-
if (e === 4) r +=
|
|
2305
|
-
else if (e === 16) r += "[" +
|
|
2319
|
+
if (e === 4) r += Xt(i.value);
|
|
2320
|
+
else if (e === 16) r += "[" + Zt(i.value) + "]";
|
|
2306
2321
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2307
|
-
n < t.length && t[n] instanceof
|
|
2322
|
+
n < t.length && t[n] instanceof B && (r += `%25${G(t[n++].value, kn)}`);
|
|
2308
2323
|
} else {
|
|
2309
2324
|
let e = [];
|
|
2310
|
-
for (; n < t.length && t[n] instanceof
|
|
2325
|
+
for (; n < t.length && t[n] instanceof B;) e.push(G(t[n++].value, kn));
|
|
2311
2326
|
r += e.join(".");
|
|
2312
2327
|
}
|
|
2313
|
-
return n < t.length && t[n] instanceof
|
|
2328
|
+
return n < t.length && t[n] instanceof k && (r += ":" + t[n].value.toString()), r;
|
|
2314
2329
|
}
|
|
2315
|
-
function
|
|
2330
|
+
function Mn(e) {
|
|
2316
2331
|
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:
|
|
2332
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new B(W(e)))) : (r = t, i = []), {
|
|
2333
|
+
authority: An(r),
|
|
2319
2334
|
pathSegments: i
|
|
2320
2335
|
};
|
|
2321
2336
|
}
|
|
2322
|
-
function
|
|
2337
|
+
function Nn(e) {
|
|
2323
2338
|
let t = e, n = null, r = t.indexOf("#");
|
|
2324
2339
|
r >= 0 && (n = W(t.slice(r + 1)), t = t.slice(0, r));
|
|
2325
2340
|
let i = null, a = t.indexOf("?");
|
|
2326
2341
|
if (a >= 0) {
|
|
2327
2342
|
let e = t.slice(a + 1);
|
|
2328
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2343
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new B(W(e)));
|
|
2329
2344
|
}
|
|
2330
2345
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2331
2346
|
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
|
|
2347
|
+
let e = s[1].toLowerCase(), t = s[2], n = vn.get(e);
|
|
2348
|
+
if (o.push(n === void 0 ? new B(e) : new A(n)), t.startsWith("//")) {
|
|
2349
|
+
let { authority: e, pathSegments: n } = Mn(t);
|
|
2350
|
+
o.push(e, new I(n));
|
|
2336
2351
|
} else if (t.startsWith("/")) {
|
|
2337
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2338
|
-
o.push(
|
|
2352
|
+
let e = t.slice(1).split("/").map((e) => new B(W(e)));
|
|
2353
|
+
o.push(R.NULL, new I(e));
|
|
2339
2354
|
} else {
|
|
2340
|
-
let e = t.split("/").map((e) => new
|
|
2341
|
-
o.push(
|
|
2355
|
+
let e = t.split("/").map((e) => new B(W(e)));
|
|
2356
|
+
o.push(R.TRUE, new I(e));
|
|
2342
2357
|
}
|
|
2343
2358
|
} else if (t.startsWith("//")) {
|
|
2344
|
-
let { authority: e, pathSegments: n } =
|
|
2345
|
-
o.push(
|
|
2359
|
+
let { authority: e, pathSegments: n } = Mn(t);
|
|
2360
|
+
o.push(R.FALSE, e, new I(n));
|
|
2346
2361
|
} else if (t.startsWith("/")) {
|
|
2347
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2348
|
-
o.push(
|
|
2349
|
-
} else if (t === "") o.push(new
|
|
2362
|
+
let e = t.slice(1).split("/").map((e) => new B(W(e)));
|
|
2363
|
+
o.push(R.TRUE, new I(e));
|
|
2364
|
+
} else if (t === "") o.push(new k(0n));
|
|
2350
2365
|
else {
|
|
2351
2366
|
let n = 1n, r = t, i = !1;
|
|
2352
2367
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2353
2368
|
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
|
|
2369
|
+
let a = r === "" ? [] : r.split("/").map((e) => new B(W(e)));
|
|
2370
|
+
o.push(new k(n), new I(a));
|
|
2356
2371
|
}
|
|
2357
|
-
if (i !== null && o.push(new
|
|
2372
|
+
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
2373
|
let e = o[o.length - 1];
|
|
2359
|
-
e instanceof
|
|
2374
|
+
e instanceof I && e.items.length === 0 && o.pop();
|
|
2360
2375
|
}
|
|
2361
|
-
return o.length === 1 && o[0] instanceof
|
|
2376
|
+
return o.length === 1 && o[0] instanceof k && o[0].value === 0n ? [] : o;
|
|
2362
2377
|
}
|
|
2363
2378
|
function K(e, t) {
|
|
2364
2379
|
let n = t, r = "";
|
|
2365
2380
|
if (n < e.length) {
|
|
2366
2381
|
let t = e[n];
|
|
2367
|
-
if (t instanceof
|
|
2382
|
+
if (t instanceof I) {
|
|
2368
2383
|
if (n++, t.items.length > 0) {
|
|
2369
2384
|
let e = t.items.map((e) => {
|
|
2370
|
-
if (!(e instanceof
|
|
2371
|
-
return G(e.value,
|
|
2385
|
+
if (!(e instanceof B)) throw Error("cri: query item must be a text string");
|
|
2386
|
+
return G(e.value, En);
|
|
2372
2387
|
});
|
|
2373
2388
|
r += "?" + e.join("&");
|
|
2374
2389
|
}
|
|
2375
|
-
} else t instanceof
|
|
2390
|
+
} else t instanceof R && t.value === 22 && n++;
|
|
2376
2391
|
}
|
|
2377
|
-
return n < e.length && e[n] instanceof
|
|
2392
|
+
return n < e.length && e[n] instanceof B && (r += "#" + G(e[n].value, Dn)), r;
|
|
2378
2393
|
}
|
|
2379
|
-
function
|
|
2394
|
+
function Pn(e) {
|
|
2380
2395
|
return e.items.map((e) => {
|
|
2381
|
-
if (!(e instanceof
|
|
2382
|
-
return G(e.value,
|
|
2396
|
+
if (!(e instanceof B)) throw Error("cri: path segment must be a text string");
|
|
2397
|
+
return G(e.value, Tn);
|
|
2383
2398
|
});
|
|
2384
2399
|
}
|
|
2385
|
-
function
|
|
2400
|
+
function Fn(e) {
|
|
2386
2401
|
if (e.length === 0) return "";
|
|
2387
2402
|
let t = 0, n = e[t++];
|
|
2388
|
-
if (n instanceof
|
|
2403
|
+
if (n instanceof A || n instanceof B) {
|
|
2389
2404
|
let r;
|
|
2390
|
-
if (n instanceof
|
|
2391
|
-
let e =
|
|
2405
|
+
if (n instanceof A) {
|
|
2406
|
+
let e = yn.get(n.value);
|
|
2392
2407
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2393
2408
|
r = e + ":";
|
|
2394
2409
|
} else r = n.value + ":";
|
|
2395
2410
|
if (t >= e.length) return r;
|
|
2396
2411
|
let i = e[t++], a = "", o = !1;
|
|
2397
|
-
if (i instanceof
|
|
2398
|
-
else if (i instanceof
|
|
2412
|
+
if (i instanceof I) a = "//" + jn(i), o = !0;
|
|
2413
|
+
else if (i instanceof R) if (i.value === 22) o = !0;
|
|
2399
2414
|
else if (i.value === 21) o = !1;
|
|
2400
2415
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2401
2416
|
else throw Error("cri: unexpected type for authority element");
|
|
2402
2417
|
let s = "";
|
|
2403
|
-
if (t < e.length && e[t] instanceof
|
|
2418
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2404
2419
|
let n = e[t++];
|
|
2405
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
2420
|
+
n.items.length > 0 && (s = (o ? "/" : "") + Pn(n).join("/"));
|
|
2406
2421
|
}
|
|
2407
2422
|
return r + a + s + K(e, t);
|
|
2408
2423
|
}
|
|
2409
|
-
if (n instanceof
|
|
2410
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2411
|
-
let n =
|
|
2412
|
-
if (t < e.length && e[t] instanceof
|
|
2424
|
+
if (n instanceof R && n.value === 20) {
|
|
2425
|
+
if (t >= e.length || !(e[t] instanceof I)) throw Error("cri: network-path reference requires an authority array");
|
|
2426
|
+
let n = jn(e[t++]), r = "";
|
|
2427
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2413
2428
|
let n = e[t++];
|
|
2414
|
-
n.items.length > 0 && (r = "/" +
|
|
2429
|
+
n.items.length > 0 && (r = "/" + Pn(n).join("/"));
|
|
2415
2430
|
}
|
|
2416
2431
|
return "//" + n + r + K(e, t);
|
|
2417
2432
|
}
|
|
2418
|
-
if (n instanceof
|
|
2433
|
+
if (n instanceof R && n.value === 21) {
|
|
2419
2434
|
let n = "/";
|
|
2420
|
-
if (t < e.length && e[t] instanceof
|
|
2435
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2421
2436
|
let r = e[t++];
|
|
2422
|
-
n = "/" +
|
|
2437
|
+
n = "/" + Pn(r).join("/");
|
|
2423
2438
|
}
|
|
2424
2439
|
return n + K(e, t);
|
|
2425
2440
|
}
|
|
2426
|
-
if (n instanceof
|
|
2441
|
+
if (n instanceof k) {
|
|
2427
2442
|
let r = n.value;
|
|
2428
2443
|
if (r === 0n) return K(e, t);
|
|
2429
2444
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2430
|
-
if (t < e.length && e[t] instanceof
|
|
2445
|
+
if (t < e.length && e[t] instanceof I) {
|
|
2431
2446
|
let n = e[t++];
|
|
2432
2447
|
if (n.items.length > 0) {
|
|
2433
|
-
let e =
|
|
2448
|
+
let e = Pn(n);
|
|
2434
2449
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2435
2450
|
} else a = i === "" ? "./" : i;
|
|
2436
2451
|
} else a = i === "" ? "./" : i;
|
|
@@ -2438,86 +2453,86 @@ function Pn(e) {
|
|
|
2438
2453
|
}
|
|
2439
2454
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2440
2455
|
}
|
|
2441
|
-
var
|
|
2456
|
+
var In = class extends I {
|
|
2442
2457
|
_toCDN(e, t) {
|
|
2443
2458
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2444
2459
|
try {
|
|
2445
|
-
let t =
|
|
2446
|
-
return `${
|
|
2460
|
+
let t = x(e, this.encodingWidth, () => b(BigInt(this.items.length)));
|
|
2461
|
+
return `${hn}'${Fn(this.items)}'${t}`;
|
|
2447
2462
|
} catch {
|
|
2448
2463
|
return super._toCDN(e, t);
|
|
2449
2464
|
}
|
|
2450
2465
|
}
|
|
2451
|
-
},
|
|
2466
|
+
}, Ln = class extends M {
|
|
2452
2467
|
constructor(e) {
|
|
2453
|
-
super(
|
|
2468
|
+
super(_n, e);
|
|
2454
2469
|
}
|
|
2455
2470
|
_toCDN(e, t) {
|
|
2456
2471
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2457
2472
|
try {
|
|
2458
2473
|
let n = this.content;
|
|
2459
2474
|
if (n.encodingWidth !== void 0) return super._toCDN(e, t);
|
|
2460
|
-
let r =
|
|
2461
|
-
return `${
|
|
2475
|
+
let r = x(e, this.encodingWidth, () => b(_n));
|
|
2476
|
+
return `${gn}'${Fn(n.items)}'${r}`;
|
|
2462
2477
|
} catch {
|
|
2463
2478
|
return super._toCDN(e, t);
|
|
2464
2479
|
}
|
|
2465
2480
|
}
|
|
2466
2481
|
};
|
|
2467
|
-
function
|
|
2482
|
+
function Rn(e) {
|
|
2468
2483
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2469
2484
|
let t = e[0];
|
|
2470
|
-
if (t instanceof
|
|
2471
|
-
if (t instanceof
|
|
2485
|
+
if (t instanceof B) return t.value;
|
|
2486
|
+
if (t instanceof N) return xn.decode(t.value);
|
|
2472
2487
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2473
2488
|
}
|
|
2474
|
-
function
|
|
2475
|
-
let n = new
|
|
2476
|
-
return e ===
|
|
2489
|
+
function zn(e, t) {
|
|
2490
|
+
let n = new In(Nn(t));
|
|
2491
|
+
return e === gn ? new Ln(n) : n;
|
|
2477
2492
|
}
|
|
2478
|
-
var
|
|
2479
|
-
appStringPrefixes: [
|
|
2480
|
-
tagNumbers: [
|
|
2493
|
+
var Bn = {
|
|
2494
|
+
appStringPrefixes: [hn, gn],
|
|
2495
|
+
tagNumbers: [_n],
|
|
2481
2496
|
parseAppString(e, t) {
|
|
2482
|
-
return
|
|
2497
|
+
return zn(e, t);
|
|
2483
2498
|
},
|
|
2484
2499
|
parseAppSequence(e, t) {
|
|
2485
|
-
return
|
|
2500
|
+
return zn(e, Rn(t));
|
|
2486
2501
|
},
|
|
2487
2502
|
parseTag(e, t) {
|
|
2488
|
-
if (e !== 99n || !(t instanceof
|
|
2489
|
-
let n = new
|
|
2503
|
+
if (e !== 99n || !(t instanceof I)) return;
|
|
2504
|
+
let n = new In(t.items, {
|
|
2490
2505
|
indefiniteLength: t.indefiniteLength,
|
|
2491
2506
|
encodingWidth: t.encodingWidth
|
|
2492
2507
|
});
|
|
2493
|
-
return n.start = t.start, n.end = t.end, new
|
|
2508
|
+
return n.start = t.start, n.end = t.end, new Ln(n);
|
|
2494
2509
|
}
|
|
2495
2510
|
};
|
|
2496
2511
|
//#endregion
|
|
2497
2512
|
//#region src/cbor/decoder.ts
|
|
2498
|
-
function
|
|
2513
|
+
function Vn(e, t) {
|
|
2499
2514
|
if (e === 24 && t <= 23n) return 0;
|
|
2500
2515
|
if (e === 25 && t <= 255n) return 1;
|
|
2501
2516
|
if (e === 26 && t <= 65535n) return 2;
|
|
2502
2517
|
if (e === 27 && t <= 4294967295n) return 3;
|
|
2503
2518
|
}
|
|
2504
|
-
function
|
|
2519
|
+
function Hn(e, t) {
|
|
2505
2520
|
if (e === 24 && t <= 23) return 0;
|
|
2506
2521
|
if (e === 25 && t <= 255) return 1;
|
|
2507
2522
|
if (e === 26 && t <= 65535) return 2;
|
|
2508
2523
|
if (e === 27 && t <= 4294967295) return 3;
|
|
2509
2524
|
}
|
|
2510
|
-
var
|
|
2525
|
+
var Un = new TextDecoder("utf-8", {
|
|
2511
2526
|
fatal: !0,
|
|
2512
2527
|
ignoreBOM: !0
|
|
2513
|
-
}),
|
|
2528
|
+
}), Wn = new TextDecoder("utf-8", {
|
|
2514
2529
|
fatal: !1,
|
|
2515
2530
|
ignoreBOM: !0
|
|
2516
2531
|
});
|
|
2517
2532
|
function q(e) {
|
|
2518
2533
|
throw Error(`CBOR decode error: ${e}`);
|
|
2519
2534
|
}
|
|
2520
|
-
function
|
|
2535
|
+
function Gn(e, t, n) {
|
|
2521
2536
|
let r = {
|
|
2522
2537
|
message: e,
|
|
2523
2538
|
offset: t
|
|
@@ -2529,59 +2544,59 @@ function J(e, t) {
|
|
|
2529
2544
|
e.warnings ??= [], e.warnings.push(t);
|
|
2530
2545
|
}
|
|
2531
2546
|
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
|
|
2547
|
+
if (e instanceof k) return ["u", String(e.value)];
|
|
2548
|
+
if (e instanceof A) return ["n", String(e.value)];
|
|
2549
|
+
if (e instanceof B) return ["t", e.value];
|
|
2550
|
+
if (e instanceof F) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
2551
|
+
if (e instanceof N) return ["b", i(e.value)];
|
|
2552
|
+
if (e instanceof P) {
|
|
2538
2553
|
let t = "";
|
|
2539
2554
|
for (let n of e.chunks) t += i(n.value);
|
|
2540
2555
|
return ["b", t];
|
|
2541
2556
|
}
|
|
2542
|
-
if (e instanceof
|
|
2543
|
-
if (e instanceof
|
|
2544
|
-
if (e instanceof
|
|
2545
|
-
if (e instanceof
|
|
2557
|
+
if (e instanceof j) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
2558
|
+
if (e instanceof R) return ["s", e.value];
|
|
2559
|
+
if (e instanceof I) return ["A", e.items.map(Y)];
|
|
2560
|
+
if (e instanceof L) {
|
|
2546
2561
|
let t = e.entries.map(([e, t]) => [Y(e), Y(t)]);
|
|
2547
2562
|
if (t.length <= 1) return ["M", t];
|
|
2548
2563
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
2549
2564
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
2550
2565
|
}
|
|
2551
|
-
return e instanceof
|
|
2566
|
+
return e instanceof M ? [
|
|
2552
2567
|
"G",
|
|
2553
2568
|
String(e.tag),
|
|
2554
2569
|
Y(e.content)
|
|
2555
2570
|
] : ["c", i(e.toCBOR())];
|
|
2556
2571
|
}
|
|
2557
|
-
function
|
|
2558
|
-
if (e instanceof
|
|
2559
|
-
if (e instanceof
|
|
2560
|
-
if (e instanceof
|
|
2561
|
-
if (e instanceof
|
|
2572
|
+
function Kn(e) {
|
|
2573
|
+
if (e instanceof k) return "u" + e.value;
|
|
2574
|
+
if (e instanceof A) return "n" + e.value;
|
|
2575
|
+
if (e instanceof B) return "t" + e.value;
|
|
2576
|
+
if (e instanceof F) {
|
|
2562
2577
|
let t = "t";
|
|
2563
2578
|
for (let n of e.chunks) t += n.value;
|
|
2564
2579
|
return t;
|
|
2565
2580
|
}
|
|
2566
|
-
if (e instanceof
|
|
2567
|
-
if (e instanceof
|
|
2581
|
+
if (e instanceof N) return "b" + i(e.value);
|
|
2582
|
+
if (e instanceof P) {
|
|
2568
2583
|
let t = "b";
|
|
2569
2584
|
for (let n of e.chunks) t += i(n.value);
|
|
2570
2585
|
return t;
|
|
2571
2586
|
}
|
|
2572
|
-
return e instanceof
|
|
2587
|
+
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
2588
|
}
|
|
2574
|
-
var
|
|
2575
|
-
function
|
|
2576
|
-
return
|
|
2589
|
+
var qn = Array.from({ length: 24 }, (e, t) => BigInt(t)), Jn;
|
|
2590
|
+
function Yn() {
|
|
2591
|
+
return Jn ??= Z.filter((e) => e.parseTag !== void 0);
|
|
2577
2592
|
}
|
|
2578
|
-
function
|
|
2593
|
+
function Xn(e, t) {
|
|
2579
2594
|
for (let n = 0; n < t; n++) if (e[n] >= 128) return;
|
|
2580
2595
|
return String.fromCharCode.apply(null, e);
|
|
2581
2596
|
}
|
|
2582
|
-
function
|
|
2597
|
+
function Zn(e, t, n) {
|
|
2583
2598
|
if (n <= 23) return {
|
|
2584
|
-
value:
|
|
2599
|
+
value: qn[n],
|
|
2585
2600
|
nextOffset: t
|
|
2586
2601
|
};
|
|
2587
2602
|
switch (n) {
|
|
@@ -2604,7 +2619,7 @@ function Xn(e, t, n) {
|
|
|
2604
2619
|
default: q(`reserved additional info value: ${n}`);
|
|
2605
2620
|
}
|
|
2606
2621
|
}
|
|
2607
|
-
function
|
|
2622
|
+
function Qn(e, t, n) {
|
|
2608
2623
|
if (n <= 23) return {
|
|
2609
2624
|
value: n,
|
|
2610
2625
|
nextOffset: t
|
|
@@ -2633,7 +2648,7 @@ function Zn(e, t, n) {
|
|
|
2633
2648
|
default: q(`reserved additional info value: ${n}`);
|
|
2634
2649
|
}
|
|
2635
2650
|
}
|
|
2636
|
-
function
|
|
2651
|
+
function $n(e, t, n, r, i, a) {
|
|
2637
2652
|
let o = [], s = t;
|
|
2638
2653
|
for (;;) {
|
|
2639
2654
|
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
@@ -2648,67 +2663,67 @@ function Qn(e, t, n, r, i, a) {
|
|
|
2648
2663
|
nextOffset: s
|
|
2649
2664
|
};
|
|
2650
2665
|
}
|
|
2651
|
-
function
|
|
2652
|
-
let i =
|
|
2653
|
-
t.has(i) && n.push(
|
|
2666
|
+
function er(e, t, n, r) {
|
|
2667
|
+
let i = Kn(e);
|
|
2668
|
+
t.has(i) && n.push(Gn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
2654
2669
|
}
|
|
2655
2670
|
function X(e, t, n, r) {
|
|
2656
|
-
let i = t, a =
|
|
2671
|
+
let i = t, a = nr(e, t, n, r);
|
|
2657
2672
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
2658
2673
|
}
|
|
2659
|
-
function
|
|
2674
|
+
function tr(e, t, n) {
|
|
2660
2675
|
return new Uint8Array(e.buffer, e.byteOffset + t, n).slice();
|
|
2661
2676
|
}
|
|
2662
|
-
function
|
|
2677
|
+
function nr(e, t, n, r) {
|
|
2663
2678
|
t >= e.byteLength && q("unexpected end of input");
|
|
2664
2679
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
2665
2680
|
switch (a) {
|
|
2666
2681
|
case 0: {
|
|
2667
|
-
let { value: n, nextOffset: r } =
|
|
2682
|
+
let { value: n, nextOffset: r } = Zn(e, t, o);
|
|
2668
2683
|
return {
|
|
2669
|
-
value: new
|
|
2684
|
+
value: new k(n, { encodingWidth: Vn(o, n) }),
|
|
2670
2685
|
nextOffset: r
|
|
2671
2686
|
};
|
|
2672
2687
|
}
|
|
2673
2688
|
case 1: {
|
|
2674
|
-
let { value: n, nextOffset: r } =
|
|
2689
|
+
let { value: n, nextOffset: r } = Zn(e, t, o), i = Vn(o, n);
|
|
2675
2690
|
return {
|
|
2676
|
-
value: new
|
|
2691
|
+
value: new A(-1n - n, { encodingWidth: i }),
|
|
2677
2692
|
nextOffset: r
|
|
2678
2693
|
};
|
|
2679
2694
|
}
|
|
2680
2695
|
case 2: {
|
|
2681
2696
|
if (o === 31) {
|
|
2682
|
-
let { chunks: i, nextOffset: a } =
|
|
2697
|
+
let { chunks: i, nextOffset: a } = $n(e, t, n, r, "byte string", (e) => e instanceof N);
|
|
2683
2698
|
return {
|
|
2684
|
-
value: new
|
|
2699
|
+
value: new P(i),
|
|
2685
2700
|
nextOffset: a
|
|
2686
2701
|
};
|
|
2687
2702
|
}
|
|
2688
|
-
let { value: i, nextOffset: a } =
|
|
2703
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i);
|
|
2689
2704
|
return a + i > e.byteLength && q("byte string extends beyond input"), {
|
|
2690
|
-
value: new
|
|
2705
|
+
value: new N(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
|
|
2691
2706
|
nextOffset: a + i
|
|
2692
2707
|
};
|
|
2693
2708
|
}
|
|
2694
2709
|
case 3: {
|
|
2695
2710
|
if (o === 31) {
|
|
2696
|
-
let { chunks: i, nextOffset: a } =
|
|
2711
|
+
let { chunks: i, nextOffset: a } = $n(e, t, n, r, "text string", (e) => e instanceof B);
|
|
2697
2712
|
return {
|
|
2698
|
-
value: new
|
|
2713
|
+
value: new F(i),
|
|
2699
2714
|
nextOffset: a
|
|
2700
2715
|
};
|
|
2701
2716
|
}
|
|
2702
|
-
let { value: i, nextOffset: a } =
|
|
2717
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i);
|
|
2703
2718
|
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 ?
|
|
2719
|
+
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? Xn(c, i) : void 0;
|
|
2705
2720
|
if (d !== void 0) l = d;
|
|
2706
2721
|
else try {
|
|
2707
|
-
l =
|
|
2722
|
+
l = Un.decode(c);
|
|
2708
2723
|
} catch {
|
|
2709
|
-
u =
|
|
2724
|
+
u = Gn("invalid UTF-8 sequence in text string", a, n), l = Wn.decode(c);
|
|
2710
2725
|
}
|
|
2711
|
-
let f = new
|
|
2726
|
+
let f = new B(l, { encodingWidth: s });
|
|
2712
2727
|
return u && J(f, u), {
|
|
2713
2728
|
value: f,
|
|
2714
2729
|
nextOffset: a + i
|
|
@@ -2726,17 +2741,17 @@ function tr(e, t, n, r) {
|
|
|
2726
2741
|
i.push(t.value), a = t.nextOffset;
|
|
2727
2742
|
}
|
|
2728
2743
|
return {
|
|
2729
|
-
value: new
|
|
2744
|
+
value: new I(i, { indefiniteLength: !0 }),
|
|
2730
2745
|
nextOffset: a
|
|
2731
2746
|
};
|
|
2732
2747
|
}
|
|
2733
|
-
let { value: i, nextOffset: a } =
|
|
2748
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i), c = [], l = a;
|
|
2734
2749
|
for (let t = 0; t < i; t++) {
|
|
2735
2750
|
let t = X(e, l, n, r);
|
|
2736
2751
|
c.push(t.value), l = t.nextOffset;
|
|
2737
2752
|
}
|
|
2738
2753
|
return {
|
|
2739
|
-
value: new
|
|
2754
|
+
value: new I(c, { encodingWidth: s }),
|
|
2740
2755
|
nextOffset: l
|
|
2741
2756
|
};
|
|
2742
2757
|
}
|
|
@@ -2749,25 +2764,25 @@ function tr(e, t, n, r) {
|
|
|
2749
2764
|
break;
|
|
2750
2765
|
}
|
|
2751
2766
|
let t = X(e, s, n, r);
|
|
2752
|
-
|
|
2767
|
+
er(t.value, a, o, n), s = t.nextOffset;
|
|
2753
2768
|
let c = X(e, s, n, r);
|
|
2754
2769
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
2755
2770
|
}
|
|
2756
|
-
let c = new
|
|
2771
|
+
let c = new L(i, { indefiniteLength: !0 });
|
|
2757
2772
|
for (let e of o) J(c, e);
|
|
2758
2773
|
return {
|
|
2759
2774
|
value: c,
|
|
2760
2775
|
nextOffset: s
|
|
2761
2776
|
};
|
|
2762
2777
|
}
|
|
2763
|
-
let { value: i, nextOffset: a } =
|
|
2778
|
+
let { value: i, nextOffset: a } = Qn(e, t, o), s = Hn(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
|
|
2764
2779
|
for (let t = 0; t < i; t++) {
|
|
2765
2780
|
let t = X(e, d, n, r);
|
|
2766
|
-
|
|
2781
|
+
er(t.value, l, u, n), d = t.nextOffset;
|
|
2767
2782
|
let i = X(e, d, n, r);
|
|
2768
2783
|
d = i.nextOffset, c.push([t.value, i.value]);
|
|
2769
2784
|
}
|
|
2770
|
-
let f = new
|
|
2785
|
+
let f = new L(c, { encodingWidth: s });
|
|
2771
2786
|
for (let e of u) J(f, e);
|
|
2772
2787
|
return {
|
|
2773
2788
|
value: f,
|
|
@@ -2776,62 +2791,62 @@ function tr(e, t, n, r) {
|
|
|
2776
2791
|
}
|
|
2777
2792
|
case 6: {
|
|
2778
2793
|
o === 31 && q("tags cannot use indefinite-length encoding");
|
|
2779
|
-
let { value: i, nextOffset: a } =
|
|
2794
|
+
let { value: i, nextOffset: a } = Zn(e, t, o), s = Vn(o, i), c = X(e, a, n, r);
|
|
2780
2795
|
for (let e of r) {
|
|
2781
2796
|
let t = e.parseTag(i, c.value, n);
|
|
2782
|
-
if (t !== void 0) return t instanceof
|
|
2797
|
+
if (t !== void 0) return t instanceof M && s !== void 0 && (t.encodingWidth = s), {
|
|
2783
2798
|
value: t,
|
|
2784
2799
|
nextOffset: c.nextOffset
|
|
2785
2800
|
};
|
|
2786
2801
|
}
|
|
2787
2802
|
return {
|
|
2788
|
-
value: new
|
|
2803
|
+
value: new M(i, c.value, { encodingWidth: s }),
|
|
2789
2804
|
nextOffset: c.nextOffset
|
|
2790
2805
|
};
|
|
2791
2806
|
}
|
|
2792
2807
|
case 7:
|
|
2793
2808
|
if (o <= 19) return {
|
|
2794
|
-
value: new
|
|
2809
|
+
value: new R(o),
|
|
2795
2810
|
nextOffset: t
|
|
2796
2811
|
};
|
|
2797
2812
|
if (o === 20) return {
|
|
2798
|
-
value: new
|
|
2813
|
+
value: new R(20),
|
|
2799
2814
|
nextOffset: t
|
|
2800
2815
|
};
|
|
2801
2816
|
if (o === 21) return {
|
|
2802
|
-
value: new
|
|
2817
|
+
value: new R(21),
|
|
2803
2818
|
nextOffset: t
|
|
2804
2819
|
};
|
|
2805
2820
|
if (o === 22) return {
|
|
2806
|
-
value: new
|
|
2821
|
+
value: new R(22),
|
|
2807
2822
|
nextOffset: t
|
|
2808
2823
|
};
|
|
2809
2824
|
if (o === 23) return {
|
|
2810
|
-
value: new
|
|
2825
|
+
value: new R(23),
|
|
2811
2826
|
nextOffset: t
|
|
2812
2827
|
};
|
|
2813
2828
|
if (o === 24) {
|
|
2814
2829
|
t + 1 > e.byteLength && q("unexpected end of input");
|
|
2815
2830
|
let r = e.getUint8(t);
|
|
2816
2831
|
if (r < 32) {
|
|
2817
|
-
let e =
|
|
2832
|
+
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
2833
|
return J(i, e), {
|
|
2819
2834
|
value: i,
|
|
2820
2835
|
nextOffset: t + 1
|
|
2821
2836
|
};
|
|
2822
2837
|
}
|
|
2823
2838
|
return {
|
|
2824
|
-
value: new
|
|
2839
|
+
value: new R(r),
|
|
2825
2840
|
nextOffset: t + 1
|
|
2826
2841
|
};
|
|
2827
2842
|
}
|
|
2828
2843
|
if (o === 25) {
|
|
2829
2844
|
t + 2 > e.byteLength && q("unexpected end of input");
|
|
2830
|
-
let n =
|
|
2845
|
+
let n = C(e.getUint16(t, !1));
|
|
2831
2846
|
return {
|
|
2832
|
-
value: new
|
|
2847
|
+
value: new j(n, {
|
|
2833
2848
|
precision: "half",
|
|
2834
|
-
rawBits: Number.isNaN(n) ?
|
|
2849
|
+
rawBits: Number.isNaN(n) ? tr(e, t, 2) : void 0
|
|
2835
2850
|
}),
|
|
2836
2851
|
nextOffset: t + 2
|
|
2837
2852
|
};
|
|
@@ -2840,9 +2855,9 @@ function tr(e, t, n, r) {
|
|
|
2840
2855
|
t + 4 > e.byteLength && q("unexpected end of input");
|
|
2841
2856
|
let n = e.getFloat32(t, !1);
|
|
2842
2857
|
return {
|
|
2843
|
-
value: new
|
|
2858
|
+
value: new j(n, {
|
|
2844
2859
|
precision: "single",
|
|
2845
|
-
rawBits: Number.isNaN(n) ?
|
|
2860
|
+
rawBits: Number.isNaN(n) ? tr(e, t, 4) : void 0
|
|
2846
2861
|
}),
|
|
2847
2862
|
nextOffset: t + 4
|
|
2848
2863
|
};
|
|
@@ -2851,9 +2866,9 @@ function tr(e, t, n, r) {
|
|
|
2851
2866
|
t + 8 > e.byteLength && q("unexpected end of input");
|
|
2852
2867
|
let n = e.getFloat64(t, !1);
|
|
2853
2868
|
return {
|
|
2854
|
-
value: new
|
|
2869
|
+
value: new j(n, {
|
|
2855
2870
|
precision: "double",
|
|
2856
|
-
rawBits: Number.isNaN(n) ?
|
|
2871
|
+
rawBits: Number.isNaN(n) ? tr(e, t, 8) : void 0
|
|
2857
2872
|
}),
|
|
2858
2873
|
nextOffset: t + 8
|
|
2859
2874
|
};
|
|
@@ -2862,17 +2877,17 @@ function tr(e, t, n, r) {
|
|
|
2862
2877
|
}
|
|
2863
2878
|
return q(`unknown major type: ${a}`);
|
|
2864
2879
|
}
|
|
2865
|
-
function
|
|
2880
|
+
function rr(e) {
|
|
2866
2881
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
2867
2882
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
2868
2883
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
2869
2884
|
}
|
|
2870
|
-
function
|
|
2871
|
-
let n =
|
|
2885
|
+
function ir(e, t) {
|
|
2886
|
+
let n = rr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
2872
2887
|
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), ...
|
|
2888
|
+
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
2889
|
if (!t?.allowTrailing && s !== r.byteLength) {
|
|
2875
|
-
J(o,
|
|
2890
|
+
J(o, Gn(`${r.byteLength - s} trailing byte(s) after end of CBOR item`, s, t));
|
|
2876
2891
|
let e = {
|
|
2877
2892
|
strict: !1,
|
|
2878
2893
|
silent: !0
|
|
@@ -2883,15 +2898,15 @@ function rr(e, t) {
|
|
|
2883
2898
|
}
|
|
2884
2899
|
//#endregion
|
|
2885
2900
|
//#region src/extensions/cbordata.ts
|
|
2886
|
-
var
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2901
|
+
var ar = 24n, Z = [
|
|
2902
|
+
Kt,
|
|
2903
|
+
dn,
|
|
2904
|
+
mn,
|
|
2905
|
+
Bn,
|
|
2891
2906
|
{
|
|
2892
|
-
tagNumbers: [
|
|
2907
|
+
tagNumbers: [ar],
|
|
2893
2908
|
parseTag(e, t, n) {
|
|
2894
|
-
if (e !== 24n || !(t instanceof
|
|
2909
|
+
if (e !== 24n || !(t instanceof N)) return;
|
|
2895
2910
|
let r = n ? {
|
|
2896
2911
|
extensions: n.extensions,
|
|
2897
2912
|
strict: n.strict,
|
|
@@ -2899,33 +2914,33 @@ var ir = 24n, Z = [
|
|
|
2899
2914
|
silent: n.silent
|
|
2900
2915
|
} : void 0;
|
|
2901
2916
|
try {
|
|
2902
|
-
return new
|
|
2917
|
+
return new M(ar, new Ue([ir(t.value, r)], { encodingWidth: t.encodingWidth }));
|
|
2903
2918
|
} catch (e) {
|
|
2904
2919
|
if (r?.strict !== !1) throw e;
|
|
2905
2920
|
return;
|
|
2906
2921
|
}
|
|
2907
2922
|
}
|
|
2908
2923
|
}
|
|
2909
|
-
],
|
|
2910
|
-
function
|
|
2911
|
-
return
|
|
2924
|
+
], or;
|
|
2925
|
+
function sr() {
|
|
2926
|
+
return or ??= {
|
|
2912
2927
|
fromJS: Z.filter((e) => e.fromJS !== void 0),
|
|
2913
2928
|
parseTag: Z.filter((e) => e.parseTag !== void 0)
|
|
2914
2929
|
};
|
|
2915
2930
|
}
|
|
2916
|
-
function
|
|
2917
|
-
let t = e?.extensions, n =
|
|
2931
|
+
function cr(e) {
|
|
2932
|
+
let t = e?.extensions, n = sr();
|
|
2918
2933
|
return t?.length ? {
|
|
2919
2934
|
fromJS: [...t.filter((e) => e.fromJS !== void 0), ...n.fromJS],
|
|
2920
2935
|
parseTag: [...t.filter((e) => e.parseTag !== void 0), ...n.parseTag]
|
|
2921
2936
|
} : n;
|
|
2922
2937
|
}
|
|
2923
|
-
function
|
|
2938
|
+
function lr(e, t) {
|
|
2924
2939
|
if (t?.replacer) {
|
|
2925
|
-
let { replacer: n, ...r } = t, i =
|
|
2926
|
-
return i === h ?
|
|
2940
|
+
let { replacer: n, ...r } = t, i = dr(e, n, r.extensions, r.undefinedOmits);
|
|
2941
|
+
return i === h ? R.UNDEFINED : lr(i, Object.keys(r).length > 0 ? r : void 0);
|
|
2927
2942
|
}
|
|
2928
|
-
return Q(e, t, !0,
|
|
2943
|
+
return Q(e, t, !0, cr(t));
|
|
2929
2944
|
}
|
|
2930
2945
|
function Q(e, t, n, r) {
|
|
2931
2946
|
for (let n of r.fromJS) {
|
|
@@ -2938,34 +2953,34 @@ function Q(e, t, n, r) {
|
|
|
2938
2953
|
let t = e.parseTag(n, i);
|
|
2939
2954
|
if (t !== void 0) return t;
|
|
2940
2955
|
}
|
|
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
|
|
2956
|
+
return new M(n, i);
|
|
2957
|
+
}
|
|
2958
|
+
if (e instanceof m.Null) return R.NULL;
|
|
2959
|
+
if (e instanceof m.Undefined) return R.UNDEFINED;
|
|
2960
|
+
if (e instanceof g) return new R(e.value);
|
|
2961
|
+
if (e === null) return R.NULL;
|
|
2962
|
+
if (e === void 0) return R.UNDEFINED;
|
|
2963
|
+
if (e === !0) return R.TRUE;
|
|
2964
|
+
if (e === !1) return R.FALSE;
|
|
2965
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new et(e) : e < -18446744073709551616n ? new tt(e) : e >= 0n ? new k(e) : new A(e);
|
|
2966
|
+
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);
|
|
2967
|
+
if (typeof e == "string") return new B(e);
|
|
2953
2968
|
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
|
|
2969
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new N(new Uint8Array(e));
|
|
2970
|
+
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));
|
|
2971
|
+
if (e instanceof $) return new L([...e].map(([e, n]) => [Q(e, t, !0, r), Q(n, t, !0, r)]));
|
|
2972
|
+
if (Array.isArray(e)) return new I(e.map((e) => Q(e, t, !0, r)));
|
|
2958
2973
|
if (typeof e == "object") {
|
|
2959
2974
|
let n = [];
|
|
2960
|
-
for (let [i, a] of Object.entries(e)) n.push([new
|
|
2961
|
-
return new
|
|
2975
|
+
for (let [i, a] of Object.entries(e)) n.push([new B(i), Q(a, t, !0, r)]);
|
|
2976
|
+
return new L(n);
|
|
2962
2977
|
}
|
|
2963
2978
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
2964
2979
|
}
|
|
2965
|
-
function
|
|
2980
|
+
function ur(e) {
|
|
2966
2981
|
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
2982
|
}
|
|
2968
|
-
function
|
|
2983
|
+
function dr(e, t, n, r) {
|
|
2969
2984
|
let i = [...n ?? [], ...Z].filter((e) => e.isJSType !== void 0);
|
|
2970
2985
|
function a(e) {
|
|
2971
2986
|
return e === h || r === !0 && e === void 0;
|
|
@@ -2976,7 +2991,7 @@ function ur(e, t, n, r) {
|
|
|
2976
2991
|
if (typeof e != "object" || !e) return e;
|
|
2977
2992
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
2978
2993
|
if (Array.isArray(e)) return e.map(r);
|
|
2979
|
-
if (m.symbol in e ||
|
|
2994
|
+
if (m.symbol in e || ur(e) || i.some((t) => t.isJSType(e))) return e;
|
|
2980
2995
|
let t = Object.getPrototypeOf(e);
|
|
2981
2996
|
if (t === Object.prototype || t === null) {
|
|
2982
2997
|
let t = e.toJSON;
|
|
@@ -3011,7 +3026,7 @@ function ur(e, t, n, r) {
|
|
|
3011
3026
|
let r = s(t, String(n), e);
|
|
3012
3027
|
return a(r) ? null : r;
|
|
3013
3028
|
});
|
|
3014
|
-
if (
|
|
3029
|
+
if (ur(e) || i.some((t) => t.isJSType(e))) return e;
|
|
3015
3030
|
let t = {};
|
|
3016
3031
|
for (let n of Object.keys(e)) {
|
|
3017
3032
|
let r = s(e[n], n, e);
|
|
@@ -3029,7 +3044,7 @@ var $ = class extends Array {
|
|
|
3029
3044
|
toJSON() {
|
|
3030
3045
|
let e = {};
|
|
3031
3046
|
for (let [t, n] of this) {
|
|
3032
|
-
let r = typeof t == "string" ? t :
|
|
3047
|
+
let r = typeof t == "string" ? t : lr(t).toCDN();
|
|
3033
3048
|
r === "__proto__" ? Object.defineProperty(e, r, {
|
|
3034
3049
|
value: n,
|
|
3035
3050
|
writable: !0,
|
|
@@ -3041,6 +3056,6 @@ var $ = class extends Array {
|
|
|
3041
3056
|
}
|
|
3042
3057
|
};
|
|
3043
3058
|
//#endregion
|
|
3044
|
-
export { C, s as D, o as E, m as O,
|
|
3059
|
+
export { S as C, s as D, o as E, m as O, C as S, h as T, M as _, qt as a, k as b, tt as c, R as d, L as f, N as g, P as h, ir as i, c as k, et as l, F as m, dr as n, B as o, I as p, lr as r, at as s, $ as t, Ue as u, j as v, g as w, O as x, A as y };
|
|
3045
3060
|
|
|
3046
|
-
//# sourceMappingURL=mapEntries-
|
|
3061
|
+
//# sourceMappingURL=mapEntries-CYvdsAfP.js.map
|