@cbortech/cbor 0.26.8 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +120 -28
- package/README.md +121 -29
- package/dist/ast/CborAppSeqResult.d.ts +22 -0
- package/dist/ast/CborByteString.d.ts +16 -0
- package/dist/ast/CborEmbeddedCBOR.d.ts +1 -1
- package/dist/ast/CborFloat.d.ts +1 -1
- package/dist/ast/CborIndefiniteByteString.d.ts +24 -0
- package/dist/ast/CborIndefiniteTextString.d.ts +16 -0
- package/dist/ast/CborItem.d.ts +44 -4
- package/dist/ast/CborTag.d.ts +27 -0
- package/dist/ast/CborTextString.d.ts +2 -1
- package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +2 -2
- package/dist/cddl/index.cjs +1 -1
- package/dist/cddl/index.js +1 -1
- package/dist/cdn/index.cjs +2 -2
- package/dist/cdn/index.cjs.map +1 -1
- package/dist/cdn/index.js +18 -18
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/serialize-utils.d.ts +207 -8
- package/dist/cdn/tokenizer.d.ts +12 -11
- package/dist/extensions/builtins.d.ts +5 -5
- package/dist/extensions/cri.d.ts +2 -2
- package/dist/extensions/ip.d.ts +1 -1
- package/dist/extensions/types.d.ts +4 -4
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +158 -158
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-C1f7G0AM.cjs +13 -0
- package/dist/mapEntries-C1f7G0AM.cjs.map +1 -0
- package/dist/{mapEntries-Ci_dppP6.js → mapEntries-CvLdiN0h.js} +1362 -1219
- package/dist/mapEntries-CvLdiN0h.js.map +1 -0
- package/dist/{schema-y8G5mDIS.js → schema-CNfrVRYp.js} +294 -294
- package/dist/{schema-y8G5mDIS.js.map → schema-CNfrVRYp.js.map} +1 -1
- package/dist/schema-iXpYtKQl.cjs +63 -0
- package/dist/{schema-DgnkH0P6.cjs.map → schema-iXpYtKQl.cjs.map} +1 -1
- package/dist/{tokenizer-N-vAvRdj.js → serialize-utils-BuIZPaUc.js} +626 -358
- package/dist/serialize-utils-BuIZPaUc.js.map +1 -0
- package/dist/serialize-utils-CjTqQivB.cjs +37 -0
- package/dist/serialize-utils-CjTqQivB.cjs.map +1 -0
- package/dist/types.d.ts +235 -58
- package/dist/utils/base64.d.ts +1 -1
- package/dist/utils/hexfloat.d.ts +1 -1
- package/dist/utils/strip-comments.d.ts +1 -1
- package/package.json +8 -6
- package/dist/mapEntries-BJzyBUH5.cjs +0 -13
- package/dist/mapEntries-BJzyBUH5.cjs.map +0 -1
- package/dist/mapEntries-Ci_dppP6.js.map +0 -1
- package/dist/schema-DgnkH0P6.cjs +0 -63
- package/dist/tokenizer-BD08xbyd.cjs +0 -36
- package/dist/tokenizer-BD08xbyd.cjs.map +0 -1
- package/dist/tokenizer-N-vAvRdj.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as e, C as t, D as n, E as r, F as i, I as a, M as o, N as s, O as c, P as l, S as u, T as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as ee, k as x, l as S, m as C, n as w, o as T, p as te, r as E, s as ne, t as D, u as re, v as ie, w as O, x as ae, y as oe } from "./serialize-utils-BuIZPaUc.js";
|
|
2
2
|
//#region src/tag.ts
|
|
3
3
|
var se = Symbol.for("cbor.tag"), ce = class {
|
|
4
4
|
valueOf() {
|
|
@@ -58,7 +58,7 @@ function pe(e) {
|
|
|
58
58
|
function me(e) {
|
|
59
59
|
return typeof e == "object" && !!e;
|
|
60
60
|
}
|
|
61
|
-
var
|
|
61
|
+
var k = class {
|
|
62
62
|
constructor() {}
|
|
63
63
|
static symbol = se;
|
|
64
64
|
static Null = ce;
|
|
@@ -75,7 +75,7 @@ var b = class {
|
|
|
75
75
|
static getValue(e) {
|
|
76
76
|
return pe(e);
|
|
77
77
|
}
|
|
78
|
-
},
|
|
78
|
+
}, he = Symbol("cbor.omit"), ge = class e {
|
|
79
79
|
value;
|
|
80
80
|
constructor(e) {
|
|
81
81
|
if (!Number.isInteger(e) || e < 0 || e > 255) throw RangeError("Simple value must be an integer in 0–255");
|
|
@@ -93,10 +93,10 @@ var b = class {
|
|
|
93
93
|
static get(t) {
|
|
94
94
|
return t instanceof e ? t.value : void 0;
|
|
95
95
|
}
|
|
96
|
-
},
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
let t =
|
|
96
|
+
}, _e = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, ve = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
97
|
+
function ye(e) {
|
|
98
|
+
ve.setFloat64(0, e, !1);
|
|
99
|
+
let t = ve.getUint32(0, !1), n = ve.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
100
100
|
if (i === 2047) {
|
|
101
101
|
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
102
102
|
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
@@ -108,8 +108,8 @@ function S(e) {
|
|
|
108
108
|
if (o <= 0) {
|
|
109
109
|
if (o < -10) return r << 15;
|
|
110
110
|
let e = 1 << 20 | a, t = 11 - o;
|
|
111
|
-
t <= 20 ? (s = e >> t & 1023, c = e >> t - 1 & 1, l = (e & (1 << t - 1) - 1)
|
|
112
|
-
} else s = a >> 10, c = a >> 9 & 1, l = (a & 511)
|
|
111
|
+
t <= 20 ? (s = e >> t & 1023, c = e >> t - 1 & 1, l = !!(e & (1 << t - 1) - 1) || n !== 0) : (s = 0, c = 1, l = a !== 0 || n !== 0);
|
|
112
|
+
} else s = a >> 10, c = a >> 9 & 1, l = !!(a & 511) || n !== 0;
|
|
113
113
|
if (c !== 0 && (l || s & 1) && s++, s >= 1024) {
|
|
114
114
|
let e = o <= 0 ? 1 : o + 1;
|
|
115
115
|
return e >= 31 ? r << 15 | 31744 : r << 15 | e << 10;
|
|
@@ -117,19 +117,19 @@ function S(e) {
|
|
|
117
117
|
let u = o <= 0 ? 0 : o;
|
|
118
118
|
return r << 15 | u << 10 | s;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function A(e) {
|
|
121
121
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
122
122
|
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);
|
|
123
123
|
}
|
|
124
|
-
var
|
|
124
|
+
var be = _e ? (e, t, n, r) => {
|
|
125
125
|
e.setFloat16(t, n, r);
|
|
126
126
|
} : (e, t, n, r) => {
|
|
127
|
-
e.setUint16(t,
|
|
128
|
-
},
|
|
129
|
-
function
|
|
127
|
+
e.setUint16(t, ye(n), r);
|
|
128
|
+
}, xe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), j = new Uint8Array(xe.buffer), Se = new TextEncoder(), Ce = typeof Se.encodeInto == "function";
|
|
129
|
+
function we(e) {
|
|
130
130
|
return e <= 23 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function Te(e) {
|
|
133
133
|
return e === "i" ? 1 : [
|
|
134
134
|
2,
|
|
135
135
|
3,
|
|
@@ -137,7 +137,7 @@ function Se(e) {
|
|
|
137
137
|
9
|
|
138
138
|
][e];
|
|
139
139
|
}
|
|
140
|
-
var
|
|
140
|
+
var Ee = class {
|
|
141
141
|
buf;
|
|
142
142
|
len = 0;
|
|
143
143
|
constructor(e = 256) {
|
|
@@ -168,45 +168,45 @@ var Ce = class {
|
|
|
168
168
|
t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
169
169
|
}
|
|
170
170
|
writeBigUint64(e) {
|
|
171
|
-
|
|
171
|
+
xe.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(j, this.len), this.len += 8;
|
|
172
172
|
}
|
|
173
173
|
writeFloat16(e) {
|
|
174
|
-
|
|
174
|
+
be(xe, 0, e, !1), this._ensure(2);
|
|
175
175
|
let t = this.buf;
|
|
176
|
-
t[this.len++] =
|
|
176
|
+
t[this.len++] = j[0], t[this.len++] = j[1];
|
|
177
177
|
}
|
|
178
178
|
writeFloat32(e) {
|
|
179
|
-
|
|
179
|
+
xe.setFloat32(0, e, !1), this._ensure(4);
|
|
180
180
|
let t = this.buf;
|
|
181
|
-
t[this.len++] =
|
|
181
|
+
t[this.len++] = j[0], t[this.len++] = j[1], t[this.len++] = j[2], t[this.len++] = j[3];
|
|
182
182
|
}
|
|
183
183
|
writeFloat64(e) {
|
|
184
|
-
|
|
184
|
+
xe.setFloat64(0, e, !1), this._ensure(8), this.buf.set(j, this.len), this.len += 8;
|
|
185
185
|
}
|
|
186
186
|
writeTextString(e, t, n) {
|
|
187
|
-
if (!
|
|
188
|
-
let r =
|
|
189
|
-
|
|
187
|
+
if (!Ce) {
|
|
188
|
+
let r = Se.encode(t);
|
|
189
|
+
M(this, e, r.length, n), this.writeBytes(r);
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
|
-
let r = n === void 0 ?
|
|
192
|
+
let r = n === void 0 ? we(t.length) : Te(n);
|
|
193
193
|
this._ensure(9 + 3 * t.length);
|
|
194
|
-
let { written: i } =
|
|
195
|
-
a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i),
|
|
194
|
+
let { written: i } = Se.encodeInto(t, this.buf.subarray(this.len + r)), a = n === void 0 ? we(i) : r;
|
|
195
|
+
a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i), M(this, e, i, n), this.len += i;
|
|
196
196
|
}
|
|
197
197
|
finish() {
|
|
198
198
|
return this.buf.slice(0, this.len);
|
|
199
199
|
}
|
|
200
|
-
},
|
|
200
|
+
}, De = [
|
|
201
201
|
255n,
|
|
202
202
|
65535n,
|
|
203
203
|
4294967295n,
|
|
204
204
|
18446744073709551615n
|
|
205
205
|
];
|
|
206
|
-
function
|
|
207
|
-
return e === "i" ? 23n :
|
|
206
|
+
function Oe(e) {
|
|
207
|
+
return e === "i" ? 23n : De[e];
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function M(e, t, n, r) {
|
|
210
210
|
if (r === void 0 && typeof n == "number" && n < 4294967296) {
|
|
211
211
|
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));
|
|
212
212
|
return;
|
|
@@ -218,42 +218,49 @@ function E(e, t, n, r) {
|
|
|
218
218
|
e.writeByte(t << 5 | Number(i));
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
if (i >
|
|
221
|
+
if (i > De[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${De[r]})`);
|
|
222
222
|
let n = 24 + r;
|
|
223
223
|
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);
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
226
|
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));
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
let r = new
|
|
230
|
-
return
|
|
228
|
+
function ke(e, t, n) {
|
|
229
|
+
let r = new Ee(9);
|
|
230
|
+
return M(r, e, t, n), r.finish();
|
|
231
231
|
}
|
|
232
|
-
var
|
|
233
|
-
function
|
|
234
|
-
return Object.is(
|
|
232
|
+
var Ae = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
233
|
+
function je(e) {
|
|
234
|
+
return Object.is(A(ye(e)), e);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
237
|
-
return
|
|
236
|
+
function Me(e) {
|
|
237
|
+
return Ae.setFloat32(0, e, !1), Object.is(Ae.getFloat32(0, !1), e);
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
return
|
|
239
|
+
function N(e) {
|
|
240
|
+
return je(e) ? "half" : Me(e) ? "single" : "double";
|
|
241
241
|
}
|
|
242
242
|
//#endregion
|
|
243
243
|
//#region src/ast/CborItem.ts
|
|
244
|
-
function
|
|
244
|
+
function Ne(e) {
|
|
245
245
|
return {
|
|
246
246
|
...e,
|
|
247
|
-
preserveComments: e.preserveComments ?? !0,
|
|
247
|
+
preserveComments: e.comments === void 0 ? e.preserveComments ?? !0 : e.preserveComments,
|
|
248
248
|
preserveByteString: e.preserveByteString ?? !0,
|
|
249
249
|
preserveRawString: e.preserveRawString ?? !0,
|
|
250
250
|
preserveConcatenation: e.preserveConcatenation ?? !0,
|
|
251
251
|
preserveNumberFormat: e.preserveNumberFormat ?? !0,
|
|
252
|
-
|
|
252
|
+
preserveAppPrefix: e.preserveAppPrefix ?? !0,
|
|
253
253
|
preserveBlankLines: e.preserveBlankLines ?? !0
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
|
-
|
|
256
|
+
function Pe(e) {
|
|
257
|
+
return e.preserveAppSequence === void 0 && e.appStrings === void 0 ? e : {
|
|
258
|
+
...e,
|
|
259
|
+
preserveAppPrefix: e.preserveAppPrefix ?? e.preserveAppSequence,
|
|
260
|
+
appPrefix: e.appPrefix ?? e.appStrings
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
var P = class e {
|
|
257
264
|
start;
|
|
258
265
|
end;
|
|
259
266
|
comments;
|
|
@@ -269,11 +276,14 @@ var O = class e {
|
|
|
269
276
|
get _containsCdnContainer() {
|
|
270
277
|
return !1;
|
|
271
278
|
}
|
|
279
|
+
_isMultiWordText(e, t = !0) {
|
|
280
|
+
return !1;
|
|
281
|
+
}
|
|
272
282
|
toCBOR(e) {
|
|
273
283
|
let t = this._defaults ? {
|
|
274
284
|
...this._defaults,
|
|
275
285
|
...e
|
|
276
|
-
} : e, n = new
|
|
286
|
+
} : e, n = new Ee();
|
|
277
287
|
return this._encode(n, t), n.finish();
|
|
278
288
|
}
|
|
279
289
|
toCDN(e) {
|
|
@@ -281,11 +291,11 @@ var O = class e {
|
|
|
281
291
|
...this._defaults,
|
|
282
292
|
...e
|
|
283
293
|
} : e;
|
|
284
|
-
t?.preserveAll && (t =
|
|
285
|
-
let
|
|
286
|
-
if (!
|
|
287
|
-
let i =
|
|
288
|
-
return [...a, `${
|
|
294
|
+
t &&= Pe(t), t?.preserveAll && (t = Ne(t));
|
|
295
|
+
let r = this._toCDN(t, 0);
|
|
296
|
+
if (!n(t) || O(t) === null) return r;
|
|
297
|
+
let i = u(t), { ownLines: a, inlinePrefix: o } = c(this, "", i), s = this.comments?.trailing ?? [], l = s.length === 0 ? r : `${r} ${s.map((e) => b(e, i).trimEnd()).join(" ")}`;
|
|
298
|
+
return [...a, `${o}${l}`].join("\n");
|
|
289
299
|
}
|
|
290
300
|
toEDN(e) {
|
|
291
301
|
return this.toCDN(e);
|
|
@@ -297,13 +307,15 @@ var O = class e {
|
|
|
297
307
|
} : e, n = this._toJS(t);
|
|
298
308
|
if (!t?.reviver) return n;
|
|
299
309
|
let r = t.reviver.call({ "": n }, "", n);
|
|
300
|
-
return r ===
|
|
310
|
+
return r === he ? void 0 : r;
|
|
301
311
|
}
|
|
302
312
|
toHexDump(e) {
|
|
303
313
|
let t = this._defaults ? {
|
|
304
314
|
...this._defaults,
|
|
305
315
|
...e
|
|
306
|
-
} : e
|
|
316
|
+
} : e;
|
|
317
|
+
t &&= Pe(t);
|
|
318
|
+
let n = t?.indent ?? 3, r = typeof n == "string" ? n : " ".repeat(n), i = (t?.commentStyle ?? "--") + " ", a = this._toHexDump(0, t), o = 0;
|
|
307
319
|
for (let e of a) {
|
|
308
320
|
let t = e.depth * r.length + e.hex.length;
|
|
309
321
|
t > o && (o = t);
|
|
@@ -323,17 +335,17 @@ var O = class e {
|
|
|
323
335
|
t.writeBytes(this._toCBOR(n));
|
|
324
336
|
}
|
|
325
337
|
_toCBOR(e) {
|
|
326
|
-
let t = new
|
|
338
|
+
let t = new Ee();
|
|
327
339
|
return this._encodeTo(t, e), t.finish();
|
|
328
340
|
}
|
|
329
341
|
_toHexDump(e, t) {
|
|
330
342
|
return [{
|
|
331
343
|
depth: e,
|
|
332
|
-
hex:
|
|
344
|
+
hex: l(this._toCBOR()),
|
|
333
345
|
comment: this._toCDN(t, 0)
|
|
334
346
|
}];
|
|
335
347
|
}
|
|
336
|
-
},
|
|
348
|
+
}, F = class extends P {
|
|
337
349
|
value;
|
|
338
350
|
encodingWidth;
|
|
339
351
|
ednSource;
|
|
@@ -343,24 +355,24 @@ var O = class e {
|
|
|
343
355
|
this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
344
356
|
}
|
|
345
357
|
_encodeTo(e, t) {
|
|
346
|
-
|
|
358
|
+
M(e, 0, this.value, this.encodingWidth);
|
|
347
359
|
}
|
|
348
|
-
_toCDN(e,
|
|
349
|
-
let
|
|
350
|
-
if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource +
|
|
351
|
-
let
|
|
360
|
+
_toCDN(e, n) {
|
|
361
|
+
let r = t(e, this.encodingWidth, () => E(this.value));
|
|
362
|
+
if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource + r;
|
|
363
|
+
let i = this.value;
|
|
352
364
|
switch (e?.intFormat) {
|
|
353
|
-
case "hex": return `0x${
|
|
354
|
-
case "octal": return `0o${
|
|
355
|
-
case "binary": return `0b${
|
|
356
|
-
default: return
|
|
365
|
+
case "hex": return `0x${i.toString(16)}${r}`;
|
|
366
|
+
case "octal": return `0o${i.toString(8)}${r}`;
|
|
367
|
+
case "binary": return `0b${i.toString(2)}${r}`;
|
|
368
|
+
default: return i.toString() + r;
|
|
357
369
|
}
|
|
358
370
|
}
|
|
359
371
|
_toJS(e) {
|
|
360
372
|
let t = e?.integerAs ?? "auto";
|
|
361
373
|
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
362
374
|
}
|
|
363
|
-
},
|
|
375
|
+
}, I = class extends P {
|
|
364
376
|
argument;
|
|
365
377
|
encodingWidth;
|
|
366
378
|
ednSource;
|
|
@@ -375,25 +387,25 @@ var O = class e {
|
|
|
375
387
|
return -1n - this.argument;
|
|
376
388
|
}
|
|
377
389
|
_encodeTo(e, t) {
|
|
378
|
-
|
|
390
|
+
M(e, 1, this.argument, this.encodingWidth);
|
|
379
391
|
}
|
|
380
|
-
_toCDN(e,
|
|
381
|
-
let
|
|
382
|
-
if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource +
|
|
383
|
-
let
|
|
392
|
+
_toCDN(e, n) {
|
|
393
|
+
let r = t(e, this.encodingWidth, () => E(this.argument));
|
|
394
|
+
if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource + r;
|
|
395
|
+
let i = this.argument + 1n;
|
|
384
396
|
switch (e?.intFormat) {
|
|
385
|
-
case "hex": return `-0x${
|
|
386
|
-
case "octal": return `-0o${
|
|
387
|
-
case "binary": return `-0b${
|
|
388
|
-
default: return this.value.toString() +
|
|
397
|
+
case "hex": return `-0x${i.toString(16)}${r}`;
|
|
398
|
+
case "octal": return `-0o${i.toString(8)}${r}`;
|
|
399
|
+
case "binary": return `-0b${i.toString(2)}${r}`;
|
|
400
|
+
default: return this.value.toString() + r;
|
|
389
401
|
}
|
|
390
402
|
}
|
|
391
403
|
_toJS(e) {
|
|
392
404
|
let t = this.value, n = e?.integerAs ?? "auto";
|
|
393
405
|
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
394
406
|
}
|
|
395
|
-
},
|
|
396
|
-
function
|
|
407
|
+
}, Fe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
408
|
+
function Ie(e) {
|
|
397
409
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
398
410
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
399
411
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -411,20 +423,20 @@ function Me(e) {
|
|
|
411
423
|
let l = c * 2 ** o;
|
|
412
424
|
return t ? -l : l;
|
|
413
425
|
}
|
|
414
|
-
function
|
|
426
|
+
function Le(e) {
|
|
415
427
|
if (isNaN(e)) return "NaN";
|
|
416
428
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
417
429
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
418
430
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
419
|
-
|
|
420
|
-
let r =
|
|
431
|
+
Fe.setFloat64(0, n, !1);
|
|
432
|
+
let r = Fe.getUint32(0, !1), i = Fe.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;
|
|
421
433
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
422
434
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
423
435
|
return t ? `-${p}` : p;
|
|
424
436
|
}
|
|
425
437
|
//#endregion
|
|
426
438
|
//#region src/ast/CborFloat.ts
|
|
427
|
-
var
|
|
439
|
+
var L = class extends P {
|
|
428
440
|
value;
|
|
429
441
|
precision;
|
|
430
442
|
ednSource;
|
|
@@ -434,17 +446,17 @@ var j = class extends O {
|
|
|
434
446
|
super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits, this.literalSource = t?.literalSource;
|
|
435
447
|
}
|
|
436
448
|
_encodeTo(e, t) {
|
|
437
|
-
let n = this.precision ??
|
|
449
|
+
let n = this.precision ?? N(this.value), r = Number.isNaN(this.value) ? this.rawBits : void 0;
|
|
438
450
|
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));
|
|
439
451
|
}
|
|
440
452
|
_toCDN(e, t) {
|
|
441
453
|
let n = e?.encodingIndicators ?? "auto";
|
|
442
|
-
if (e?.
|
|
454
|
+
if (e?.appPrefix !== !1 && (e?.floatFormat === void 0 || e?.floatFormat === "app-extension") && this.ednSource !== void 0 && (O(e) !== null || !/[\r\n]/.test(this.ednSource))) {
|
|
443
455
|
let e = this.ednSource;
|
|
444
456
|
if (n === "never") return e.replace(/_[0-3i]$/, "");
|
|
445
457
|
if (n === "always") {
|
|
446
458
|
if (/_[0-3i]$/.test(e)) return e;
|
|
447
|
-
let t = this.precision ??
|
|
459
|
+
let t = this.precision ?? N(this.value);
|
|
448
460
|
return e + (t === "half" ? "_1" : t === "single" ? "_2" : "_3");
|
|
449
461
|
}
|
|
450
462
|
return e;
|
|
@@ -454,18 +466,22 @@ var j = class extends O {
|
|
|
454
466
|
if (n === "never") return e.replace(/_[0-7i]$/, "");
|
|
455
467
|
if (n === "always") {
|
|
456
468
|
if (/_[0-7i]$/.test(e)) return e;
|
|
457
|
-
let t =
|
|
458
|
-
return e +
|
|
469
|
+
let t = N(this.value);
|
|
470
|
+
return e + S(this.value, this.precision, t, "always");
|
|
459
471
|
}
|
|
460
472
|
return e;
|
|
461
473
|
}
|
|
462
|
-
let r =
|
|
463
|
-
|
|
474
|
+
let r = N(this.value);
|
|
475
|
+
if (e?.floatFormat === "app-extension" && e?.appPrefix !== !1) {
|
|
476
|
+
let e = this.toCBOR();
|
|
477
|
+
return `float'${s(e.subarray(1))}'` + S(this.value, this.precision, r, n);
|
|
478
|
+
}
|
|
479
|
+
return (e?.floatFormat === "hex" ? Le(this.value) : re(this.value)) + S(this.value, this.precision, r, n);
|
|
464
480
|
}
|
|
465
481
|
_toJS(e) {
|
|
466
482
|
return this.value;
|
|
467
483
|
}
|
|
468
|
-
},
|
|
484
|
+
}, R = class extends P {
|
|
469
485
|
tag;
|
|
470
486
|
content;
|
|
471
487
|
encodingWidth;
|
|
@@ -477,35 +493,38 @@ var j = class extends O {
|
|
|
477
493
|
get _containsCdnContainer() {
|
|
478
494
|
return this.content._containsCdnContainer;
|
|
479
495
|
}
|
|
496
|
+
_isMultiWordText(e, t = !0) {
|
|
497
|
+
return y(this._toCDN(e, 0), t);
|
|
498
|
+
}
|
|
480
499
|
_encodeTo(e, t) {
|
|
481
|
-
|
|
500
|
+
M(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
482
501
|
}
|
|
483
|
-
_toCDN(e,
|
|
484
|
-
let
|
|
485
|
-
return `${e?.preserveNumberFormat && this.ednSource !== void 0 ? this.ednSource : this.tag.toString()}${
|
|
502
|
+
_toCDN(e, n) {
|
|
503
|
+
let r = t(e, this.encodingWidth, () => E(this.tag));
|
|
504
|
+
return `${e?.preserveNumberFormat && this.ednSource !== void 0 ? this.ednSource : this.tag.toString()}${r}${ae(this.content, this, e, n, (t) => this.content._toCDN(e, t), "(", ")")}`;
|
|
486
505
|
}
|
|
487
506
|
_toHexDump(e, t) {
|
|
488
507
|
let n = [{
|
|
489
508
|
depth: e,
|
|
490
|
-
hex:
|
|
509
|
+
hex: l(ke(6, this.tag, this.encodingWidth)),
|
|
491
510
|
comment: `Tag ${this.tag}`
|
|
492
511
|
}];
|
|
493
|
-
return n
|
|
512
|
+
return m(n, this.content._toHexDump(e + 1, {
|
|
494
513
|
...t,
|
|
495
|
-
|
|
514
|
+
appPrefix: !1
|
|
496
515
|
})), n;
|
|
497
516
|
}
|
|
498
517
|
_toJS(e) {
|
|
499
518
|
let t = this.content._toJS(e);
|
|
500
|
-
return e?.stripTags ? t :
|
|
519
|
+
return e?.stripTags ? t : k.set(t, this.tag);
|
|
501
520
|
}
|
|
502
521
|
};
|
|
503
522
|
//#endregion
|
|
504
523
|
//#region src/ast/CborByteString.ts
|
|
505
|
-
function
|
|
506
|
-
if (e !== void 0) return t
|
|
524
|
+
function Re(e, t, r) {
|
|
525
|
+
if (e !== void 0) return n(t) || r === void 0 ? e : x(e, r);
|
|
507
526
|
}
|
|
508
|
-
var
|
|
527
|
+
var z = class extends P {
|
|
509
528
|
indefiniteLength = !1;
|
|
510
529
|
value;
|
|
511
530
|
ednEncoding;
|
|
@@ -516,29 +535,32 @@ var N = class extends O {
|
|
|
516
535
|
constructor(e, t) {
|
|
517
536
|
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource, this.ednCommentSyntax = t?.ednCommentSyntax, this.ednParts = t?.ednParts;
|
|
518
537
|
}
|
|
519
|
-
|
|
520
|
-
|
|
538
|
+
_isMultiWordText(e, t = !0) {
|
|
539
|
+
return C(this.value, e?.sqstr);
|
|
521
540
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
541
|
+
_encodeTo(e, t) {
|
|
542
|
+
M(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
|
|
543
|
+
}
|
|
544
|
+
_toCDN(e, r) {
|
|
545
|
+
let i = O(e);
|
|
546
|
+
if (e?.preserveConcatenation && i !== null && this.ednParts !== void 0 && this.ednParts.length > 1) {
|
|
547
|
+
let a = t(e, this.encodingWidth, () => E(BigInt(this.value.length))), o = e?.bstrEncoding ?? this.ednEncoding;
|
|
548
|
+
e?.appPrefix === !1 && o !== "hex" && (o = "hex");
|
|
549
|
+
let s = this.ednParts.map((t) => {
|
|
550
|
+
let n = e?.preserveByteString ? Re(t.source, e, t.commentSyntax) : void 0;
|
|
551
|
+
return n === void 0 ? d(t.bytes, o, e?.sqstr) : n;
|
|
552
|
+
}), c = n(e) ? p(this.comments?.dangling, this.ednParts, u(e)) : void 0;
|
|
553
|
+
return e?.modernConcat && e?.appPrefix !== !1 ? ie("b1", s, a, i, r, c) : (s[s.length - 1] += a, oe(s, i, r, c));
|
|
554
|
+
}
|
|
555
|
+
let a = e?.preserveByteString ? Re(this.ednSource, e, this.ednCommentSyntax) : void 0;
|
|
556
|
+
if (a !== void 0 && (i !== null || !/[\r\n]/.test(a))) return /_[0-3i]$/.test(a) ? (e?.encodingIndicators ?? "auto") === "never" ? a.replace(/_[0-3i]$/, "") : a : a + t(e, this.encodingWidth, () => E(BigInt(this.value.length)));
|
|
557
|
+
let o = t(e, this.encodingWidth, () => E(BigInt(this.value.length))), s = e?.bstrEncoding ?? this.ednEncoding;
|
|
558
|
+
return e?.appPrefix === !1 && s !== "hex" && (s = "hex"), d(this.value, s, e?.sqstr) + o;
|
|
537
559
|
}
|
|
538
560
|
_toJS(e) {
|
|
539
561
|
return this.value;
|
|
540
562
|
}
|
|
541
|
-
},
|
|
563
|
+
}, B = class extends P {
|
|
542
564
|
indefiniteLength = !0;
|
|
543
565
|
chunks;
|
|
544
566
|
constructor(e) {
|
|
@@ -549,46 +571,54 @@ var N = class extends O {
|
|
|
549
571
|
for (let n of this.chunks) n._encode(e, t);
|
|
550
572
|
e.writeByte(255);
|
|
551
573
|
}
|
|
574
|
+
_isMultiWordText(e, t = !0) {
|
|
575
|
+
return this.chunks.some((t) => t._isMultiWordText(e));
|
|
576
|
+
}
|
|
552
577
|
_toCDN(e, t) {
|
|
553
578
|
if ((e?.encodingIndicators ?? "auto") === "never") {
|
|
554
579
|
let n = this.chunks.reduce((e, t) => e + t.value.length, 0), r = new Uint8Array(n), i = 0;
|
|
555
580
|
for (let e of this.chunks) r.set(e.value, i), i += e.value.length;
|
|
556
|
-
return new
|
|
581
|
+
return new z(r)._toCDN(e, t);
|
|
557
582
|
}
|
|
558
|
-
|
|
583
|
+
let n = !!e?.modernStreamSyntax && e?.appPrefix !== !1;
|
|
584
|
+
return !n && this.chunks.length === 0 ? "''_" : r({
|
|
559
585
|
node: this,
|
|
560
586
|
options: e,
|
|
561
587
|
depth: t,
|
|
562
|
-
openChar: "(",
|
|
563
|
-
closeChar: ")",
|
|
588
|
+
openChar: n ? "ilbs<<" : "(",
|
|
589
|
+
closeChar: n ? ">>" : ")",
|
|
564
590
|
count: this.chunks.length,
|
|
565
591
|
indefiniteLength: !0,
|
|
592
|
+
indefiniteMarker: !n,
|
|
566
593
|
encodingWidth: void 0,
|
|
567
|
-
hasEntryComments: () => this.chunks.some(
|
|
594
|
+
hasEntryComments: () => this.chunks.some(_),
|
|
568
595
|
renderEntry: (n) => this.chunks[n]._toCDN(e, t + 1),
|
|
596
|
+
entryIsLeaf: n ? void 0 : () => !0,
|
|
597
|
+
alwaysInlineLeaf: n,
|
|
598
|
+
entryIsMultiWordText: (t) => this.chunks[t]._isMultiWordText(e, !n),
|
|
569
599
|
entryLeadingNode: (e) => this.chunks[e],
|
|
570
|
-
entryTrailing: (e, t) =>
|
|
600
|
+
entryTrailing: (e, t) => g(this.chunks[e], t)
|
|
571
601
|
});
|
|
572
602
|
}
|
|
573
|
-
_toHexDump(
|
|
574
|
-
let
|
|
575
|
-
depth:
|
|
576
|
-
hex:
|
|
603
|
+
_toHexDump(e, t) {
|
|
604
|
+
let n = [{
|
|
605
|
+
depth: e,
|
|
606
|
+
hex: o(95),
|
|
577
607
|
comment: "Start indefinite-length byte string"
|
|
578
608
|
}];
|
|
579
|
-
for (let
|
|
580
|
-
return
|
|
581
|
-
depth:
|
|
582
|
-
hex:
|
|
609
|
+
for (let r of this.chunks) m(n, r._toHexDump(e + 1, t));
|
|
610
|
+
return n.push({
|
|
611
|
+
depth: e,
|
|
612
|
+
hex: o(255),
|
|
583
613
|
comment: "\"break\""
|
|
584
|
-
}),
|
|
614
|
+
}), n;
|
|
585
615
|
}
|
|
586
616
|
_toJS(e) {
|
|
587
617
|
let t = this.chunks.reduce((e, t) => e + t.value.length, 0), n = new Uint8Array(t), r = 0;
|
|
588
618
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
589
619
|
return n;
|
|
590
620
|
}
|
|
591
|
-
},
|
|
621
|
+
}, V = class extends P {
|
|
592
622
|
indefiniteLength = !0;
|
|
593
623
|
chunks;
|
|
594
624
|
constructor(e) {
|
|
@@ -599,39 +629,48 @@ var N = class extends O {
|
|
|
599
629
|
for (let n of this.chunks) n._encode(e, t);
|
|
600
630
|
e.writeByte(255);
|
|
601
631
|
}
|
|
632
|
+
_isMultiWordText(e, t = !0) {
|
|
633
|
+
return this.chunks.some((t) => t._isMultiWordText(e));
|
|
634
|
+
}
|
|
602
635
|
_toCDN(e, t) {
|
|
603
|
-
|
|
636
|
+
if ((e?.encodingIndicators ?? "auto") === "never") return new Y(this.chunks.map((e) => e.value).join(""))._toCDN(e, t);
|
|
637
|
+
let n = !!e?.modernStreamSyntax && e?.appPrefix !== !1;
|
|
638
|
+
return !n && this.chunks.length === 0 ? "\"\"_" : r({
|
|
604
639
|
node: this,
|
|
605
640
|
options: e,
|
|
606
641
|
depth: t,
|
|
607
|
-
openChar: "(",
|
|
608
|
-
closeChar: ")",
|
|
642
|
+
openChar: n ? "ilts<<" : "(",
|
|
643
|
+
closeChar: n ? ">>" : ")",
|
|
609
644
|
count: this.chunks.length,
|
|
610
645
|
indefiniteLength: !0,
|
|
646
|
+
indefiniteMarker: !n,
|
|
611
647
|
encodingWidth: void 0,
|
|
612
|
-
hasEntryComments: () => this.chunks.some(
|
|
648
|
+
hasEntryComments: () => this.chunks.some(_),
|
|
613
649
|
renderEntry: (n) => this.chunks[n]._toCDN(e, t + 1),
|
|
650
|
+
entryIsLeaf: n ? void 0 : () => !0,
|
|
651
|
+
alwaysInlineLeaf: n,
|
|
652
|
+
entryIsMultiWordText: (t) => this.chunks[t]._isMultiWordText(e, !n),
|
|
614
653
|
entryLeadingNode: (e) => this.chunks[e],
|
|
615
|
-
entryTrailing: (e, t) =>
|
|
654
|
+
entryTrailing: (e, t) => g(this.chunks[e], t)
|
|
616
655
|
});
|
|
617
656
|
}
|
|
618
|
-
_toHexDump(
|
|
619
|
-
let
|
|
620
|
-
depth:
|
|
621
|
-
hex:
|
|
657
|
+
_toHexDump(e, t) {
|
|
658
|
+
let n = [{
|
|
659
|
+
depth: e,
|
|
660
|
+
hex: o(127),
|
|
622
661
|
comment: "Start indefinite-length text string"
|
|
623
662
|
}];
|
|
624
|
-
for (let
|
|
625
|
-
return
|
|
626
|
-
depth:
|
|
627
|
-
hex:
|
|
663
|
+
for (let r of this.chunks) m(n, r._toHexDump(e + 1, t));
|
|
664
|
+
return n.push({
|
|
665
|
+
depth: e,
|
|
666
|
+
hex: o(255),
|
|
628
667
|
comment: "\"break\""
|
|
629
|
-
}),
|
|
668
|
+
}), n;
|
|
630
669
|
}
|
|
631
670
|
_toJS(e) {
|
|
632
671
|
return this.chunks.map((e) => e.value).join("");
|
|
633
672
|
}
|
|
634
|
-
},
|
|
673
|
+
}, H = class extends P {
|
|
635
674
|
items;
|
|
636
675
|
indefiniteLength;
|
|
637
676
|
encodingWidth;
|
|
@@ -648,11 +687,11 @@ var N = class extends O {
|
|
|
648
687
|
e.writeByte(255);
|
|
649
688
|
return;
|
|
650
689
|
}
|
|
651
|
-
|
|
690
|
+
M(e, 4, this.items.length, this.encodingWidth);
|
|
652
691
|
for (let n of this.items) n._encode(e, t);
|
|
653
692
|
}
|
|
654
693
|
_toCDN(e, t) {
|
|
655
|
-
return
|
|
694
|
+
return r({
|
|
656
695
|
node: this,
|
|
657
696
|
options: e,
|
|
658
697
|
depth: t,
|
|
@@ -661,34 +700,35 @@ var N = class extends O {
|
|
|
661
700
|
count: this.items.length,
|
|
662
701
|
indefiniteLength: this.indefiniteLength,
|
|
663
702
|
encodingWidth: this.encodingWidth,
|
|
664
|
-
hasEntryComments: () => this.items.some(
|
|
703
|
+
hasEntryComments: () => this.items.some(_),
|
|
665
704
|
renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
|
|
666
705
|
entryIsLeaf: (e) => !this.items[e]._containsCdnContainer,
|
|
706
|
+
entryIsMultiWordText: (t) => this.items[t]._isMultiWordText(e),
|
|
667
707
|
entryLeadingNode: (e) => this.items[e],
|
|
668
|
-
entryTrailing: (e, t) =>
|
|
708
|
+
entryTrailing: (e, t) => g(this.items[e], t)
|
|
669
709
|
});
|
|
670
710
|
}
|
|
671
|
-
_toHexDump(
|
|
711
|
+
_toHexDump(e, t) {
|
|
672
712
|
if (this.indefiniteLength) {
|
|
673
|
-
let
|
|
674
|
-
depth:
|
|
675
|
-
hex:
|
|
713
|
+
let n = [{
|
|
714
|
+
depth: e,
|
|
715
|
+
hex: o(159),
|
|
676
716
|
comment: "Start indefinite-length array"
|
|
677
717
|
}];
|
|
678
|
-
for (let
|
|
679
|
-
return
|
|
680
|
-
depth:
|
|
681
|
-
hex:
|
|
718
|
+
for (let r of this.items) m(n, r._toHexDump(e + 1, t));
|
|
719
|
+
return n.push({
|
|
720
|
+
depth: e,
|
|
721
|
+
hex: o(255),
|
|
682
722
|
comment: "\"break\""
|
|
683
|
-
}),
|
|
723
|
+
}), n;
|
|
684
724
|
}
|
|
685
|
-
let
|
|
686
|
-
depth:
|
|
687
|
-
hex:
|
|
725
|
+
let n = [{
|
|
726
|
+
depth: e,
|
|
727
|
+
hex: l(ke(4, BigInt(this.items.length), this.encodingWidth)),
|
|
688
728
|
comment: `Array of length ${this.items.length}`
|
|
689
729
|
}];
|
|
690
|
-
for (let
|
|
691
|
-
return
|
|
730
|
+
for (let r of this.items) m(n, r._toHexDump(e + 1, t));
|
|
731
|
+
return n;
|
|
692
732
|
}
|
|
693
733
|
_toJS(e) {
|
|
694
734
|
let t = e?.reviver;
|
|
@@ -699,11 +739,11 @@ var N = class extends O {
|
|
|
699
739
|
} : void 0, r = this.items.map((e) => e._toJS(n)), i = 0;
|
|
700
740
|
for (let n = 0; n < this.items.length; n++) {
|
|
701
741
|
let a = n - i, o = this.items[n]._toJS(e), s = t.call(r, String(n), o);
|
|
702
|
-
s ===
|
|
742
|
+
s === he || e?.undefinedOmits && s === void 0 ? (r.splice(a, 1), i++) : r[a] = s;
|
|
703
743
|
}
|
|
704
744
|
return r;
|
|
705
745
|
}
|
|
706
|
-
},
|
|
746
|
+
}, U = class extends P {
|
|
707
747
|
entries;
|
|
708
748
|
indefiniteLength;
|
|
709
749
|
encodingWidth;
|
|
@@ -720,11 +760,19 @@ var N = class extends O {
|
|
|
720
760
|
e.writeByte(255);
|
|
721
761
|
return;
|
|
722
762
|
}
|
|
723
|
-
|
|
763
|
+
M(e, 5, this.entries.length, this.encodingWidth);
|
|
724
764
|
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
725
765
|
}
|
|
726
766
|
_toCDN(e, t) {
|
|
727
|
-
|
|
767
|
+
let n = [], i = (r) => {
|
|
768
|
+
let i = n[r];
|
|
769
|
+
if (!i) {
|
|
770
|
+
let [a, o] = this.entries[r];
|
|
771
|
+
i = [a._toCDN(e, t + 1), o._toCDN(e, t + 1)], n[r] = i;
|
|
772
|
+
}
|
|
773
|
+
return i;
|
|
774
|
+
};
|
|
775
|
+
return r({
|
|
728
776
|
node: this,
|
|
729
777
|
options: e,
|
|
730
778
|
depth: t,
|
|
@@ -733,19 +781,25 @@ var N = class extends O {
|
|
|
733
781
|
count: this.entries.length,
|
|
734
782
|
indefiniteLength: this.indefiniteLength,
|
|
735
783
|
encodingWidth: this.encodingWidth,
|
|
736
|
-
hasEntryComments: () => this.entries.some(([e, t]) =>
|
|
737
|
-
renderEntry: (
|
|
738
|
-
let [
|
|
739
|
-
return `${
|
|
784
|
+
hasEntryComments: () => this.entries.some(([e, t]) => _(e) || _(t)),
|
|
785
|
+
renderEntry: (e, t) => {
|
|
786
|
+
let [n, r] = i(e);
|
|
787
|
+
return `${n}${t}${r}`;
|
|
740
788
|
},
|
|
741
789
|
entryIsLeaf: (e) => {
|
|
742
790
|
let [t, n] = this.entries[e];
|
|
743
791
|
return !t._containsCdnContainer && !n._containsCdnContainer;
|
|
744
792
|
},
|
|
793
|
+
entryIsMultiWordText: (t) => {
|
|
794
|
+
let [n, r] = this.entries[t];
|
|
795
|
+
if (n._isMultiWordText(e) || r._isMultiWordText(e)) return !0;
|
|
796
|
+
let [a, o] = i(t);
|
|
797
|
+
return f(a) || f(o);
|
|
798
|
+
},
|
|
745
799
|
entryLeadingNode: (e) => this.entries[e][0],
|
|
746
800
|
entryTrailing: (e, t) => {
|
|
747
801
|
let [n, r] = this.entries[e];
|
|
748
|
-
return
|
|
802
|
+
return ze([
|
|
749
803
|
...n.comments?.trailing ?? [],
|
|
750
804
|
...r.comments?.leading ?? [],
|
|
751
805
|
...r.comments?.trailing ?? []
|
|
@@ -753,27 +807,27 @@ var N = class extends O {
|
|
|
753
807
|
}
|
|
754
808
|
});
|
|
755
809
|
}
|
|
756
|
-
_toHexDump(
|
|
810
|
+
_toHexDump(e, t) {
|
|
757
811
|
if (this.indefiniteLength) {
|
|
758
|
-
let
|
|
759
|
-
depth:
|
|
760
|
-
hex:
|
|
812
|
+
let n = [{
|
|
813
|
+
depth: e,
|
|
814
|
+
hex: o(191),
|
|
761
815
|
comment: "Start indefinite-length map"
|
|
762
816
|
}];
|
|
763
|
-
for (let [
|
|
764
|
-
return
|
|
765
|
-
depth:
|
|
766
|
-
hex:
|
|
817
|
+
for (let [r, i] of this.entries) m(n, r._toHexDump(e + 1, t)), m(n, i._toHexDump(e + 1, t));
|
|
818
|
+
return n.push({
|
|
819
|
+
depth: e,
|
|
820
|
+
hex: o(255),
|
|
767
821
|
comment: "\"break\""
|
|
768
|
-
}),
|
|
822
|
+
}), n;
|
|
769
823
|
}
|
|
770
|
-
let
|
|
771
|
-
depth:
|
|
772
|
-
hex:
|
|
824
|
+
let n = [{
|
|
825
|
+
depth: e,
|
|
826
|
+
hex: l(ke(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
773
827
|
comment: `Map of length ${this.entries.length}`
|
|
774
828
|
}];
|
|
775
|
-
for (let [
|
|
776
|
-
return
|
|
829
|
+
for (let [r, i] of this.entries) m(n, r._toHexDump(e + 1, t)), m(n, i._toHexDump(e + 1, t));
|
|
830
|
+
return n;
|
|
777
831
|
}
|
|
778
832
|
_toJS(e) {
|
|
779
833
|
let t = e?.reviver, n = () => {
|
|
@@ -782,17 +836,17 @@ var N = class extends O {
|
|
|
782
836
|
let r = e?.undefinedOmits;
|
|
783
837
|
for (let e = 0; e < n.length; e++) {
|
|
784
838
|
let [i, a] = n[e], o = t.call(n, i, a);
|
|
785
|
-
o ===
|
|
839
|
+
o === he || r && o === void 0 ? n.splice(e--, 1) : n[e] = [i, o];
|
|
786
840
|
}
|
|
787
841
|
return n;
|
|
788
842
|
};
|
|
789
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
843
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof Y) ? (() => {
|
|
790
844
|
let n = e ? {
|
|
791
845
|
...e,
|
|
792
846
|
reviver: void 0
|
|
793
847
|
} : void 0, r = {};
|
|
794
848
|
for (let [e, t] of this.entries) {
|
|
795
|
-
let i = e instanceof
|
|
849
|
+
let i = e instanceof Y ? e.value : e.toCDN(), a = t._toJS(n);
|
|
796
850
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
797
851
|
value: a,
|
|
798
852
|
writable: !0,
|
|
@@ -804,13 +858,13 @@ var N = class extends O {
|
|
|
804
858
|
let i = /* @__PURE__ */ new Map();
|
|
805
859
|
for (let e = 0; e < this.entries.length; e++) {
|
|
806
860
|
let [t] = this.entries[e];
|
|
807
|
-
i.set(t instanceof
|
|
861
|
+
i.set(t instanceof Y ? t.value : t.toCDN(), e);
|
|
808
862
|
}
|
|
809
863
|
for (let n = 0; n < this.entries.length; n++) {
|
|
810
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
864
|
+
let [a, o] = this.entries[n], s = a instanceof Y ? a.value : a.toCDN();
|
|
811
865
|
if (i.get(s) !== n) continue;
|
|
812
866
|
let c = o._toJS(e), l = t.call(r, s, c);
|
|
813
|
-
l ===
|
|
867
|
+
l === he || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
814
868
|
value: l,
|
|
815
869
|
writable: !0,
|
|
816
870
|
enumerable: !0,
|
|
@@ -821,12 +875,12 @@ var N = class extends O {
|
|
|
821
875
|
})() : n();
|
|
822
876
|
}
|
|
823
877
|
};
|
|
824
|
-
function
|
|
825
|
-
return e.length === 0 ? "" : " " + e.map((e) =>
|
|
878
|
+
function ze(e, t) {
|
|
879
|
+
return e.length === 0 ? "" : " " + e.map((e) => b(e, t).trimEnd()).join(" ");
|
|
826
880
|
}
|
|
827
881
|
//#endregion
|
|
828
882
|
//#region src/ast/CborSimple.ts
|
|
829
|
-
var
|
|
883
|
+
var W = class e extends P {
|
|
830
884
|
value;
|
|
831
885
|
ednSource;
|
|
832
886
|
constructor(e, t) {
|
|
@@ -860,10 +914,10 @@ var R = class e extends O {
|
|
|
860
914
|
case 21: return !0;
|
|
861
915
|
case 22: return null;
|
|
862
916
|
case 23: return;
|
|
863
|
-
default: return new
|
|
917
|
+
default: return new ge(this.value);
|
|
864
918
|
}
|
|
865
919
|
}
|
|
866
|
-
},
|
|
920
|
+
}, G = class extends P {
|
|
867
921
|
items;
|
|
868
922
|
encodingWidth;
|
|
869
923
|
constructor(e, t) {
|
|
@@ -873,16 +927,16 @@ var R = class e extends O {
|
|
|
873
927
|
return this.items.some((e) => e._containsCdnContainer);
|
|
874
928
|
}
|
|
875
929
|
_content(e) {
|
|
876
|
-
let t = new
|
|
930
|
+
let t = new Ee();
|
|
877
931
|
for (let n of this.items) n._encode(t, e);
|
|
878
932
|
return t.finish();
|
|
879
933
|
}
|
|
880
934
|
_encodeTo(e, t) {
|
|
881
935
|
let n = this._content(t);
|
|
882
|
-
|
|
936
|
+
M(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
|
|
883
937
|
}
|
|
884
938
|
_toCDN(e, t) {
|
|
885
|
-
return
|
|
939
|
+
return r({
|
|
886
940
|
node: this,
|
|
887
941
|
options: e,
|
|
888
942
|
depth: t,
|
|
@@ -893,19 +947,21 @@ var R = class e extends O {
|
|
|
893
947
|
encodingWidth: this.encodingWidth,
|
|
894
948
|
eiPosition: "close",
|
|
895
949
|
canonicalCount: () => BigInt(this._content(e).length),
|
|
896
|
-
hasEntryComments: () => this.items.some(
|
|
950
|
+
hasEntryComments: () => this.items.some(_),
|
|
897
951
|
renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
|
|
952
|
+
alwaysInlineLeaf: !0,
|
|
953
|
+
entryIsMultiWordText: (t) => this.items[t]._isMultiWordText(e, !1),
|
|
898
954
|
entryLeadingNode: (e) => this.items[e],
|
|
899
|
-
entryTrailing: (e, t) =>
|
|
955
|
+
entryTrailing: (e, t) => g(this.items[e], t)
|
|
900
956
|
});
|
|
901
957
|
}
|
|
902
958
|
_toHexDump(e, t) {
|
|
903
959
|
let n = this._content().length, r = [{
|
|
904
960
|
depth: e,
|
|
905
|
-
hex:
|
|
961
|
+
hex: l(ke(2, BigInt(n), this.encodingWidth)),
|
|
906
962
|
comment: `Embedded CBOR sequence, ${n} byte${n === 1 ? "" : "s"}`
|
|
907
963
|
}];
|
|
908
|
-
for (let n of this.items) r
|
|
964
|
+
for (let n of this.items) m(r, n._toHexDump(e + 1, t));
|
|
909
965
|
return r;
|
|
910
966
|
}
|
|
911
967
|
_toJS(e) {
|
|
@@ -914,7 +970,7 @@ var R = class e extends O {
|
|
|
914
970
|
};
|
|
915
971
|
//#endregion
|
|
916
972
|
//#region src/utils/strip-comments.ts
|
|
917
|
-
function
|
|
973
|
+
function Be(e) {
|
|
918
974
|
let t = "", n = 0;
|
|
919
975
|
for (; n < e.length;) {
|
|
920
976
|
let r = e[n];
|
|
@@ -933,7 +989,7 @@ function Ie(e) {
|
|
|
933
989
|
continue;
|
|
934
990
|
}
|
|
935
991
|
if (t === "*") {
|
|
936
|
-
for (n += 2; n < e.length &&
|
|
992
|
+
for (n += 2; n < e.length && (e[n] !== "*" || (e[n + 1] ?? "") !== "/");) n++;
|
|
937
993
|
if (n >= e.length) throw SyntaxError("unterminated block comment");
|
|
938
994
|
n += 2;
|
|
939
995
|
continue;
|
|
@@ -949,14 +1005,14 @@ function Ie(e) {
|
|
|
949
1005
|
}
|
|
950
1006
|
//#endregion
|
|
951
1007
|
//#region src/extensions/b32.ts
|
|
952
|
-
var
|
|
953
|
-
function
|
|
1008
|
+
var Ve = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", He = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
1009
|
+
function Ue(e) {
|
|
954
1010
|
let t = e.length;
|
|
955
1011
|
for (; t > 0 && e.charCodeAt(t - 1) === 61;) t--;
|
|
956
1012
|
return e.slice(0, t);
|
|
957
1013
|
}
|
|
958
|
-
function
|
|
959
|
-
let r =
|
|
1014
|
+
function We(e, t, n) {
|
|
1015
|
+
let r = Ue(e).toUpperCase(), i = r.length % 8;
|
|
960
1016
|
if (i === 1 || i === 3 || i === 6) throw SyntaxError(`invalid base32 length: ${r.length} characters`);
|
|
961
1017
|
let a = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
|
|
962
1018
|
for (let e = 0; e < t.length; e++) a[t.charCodeAt(e)] = e;
|
|
@@ -973,69 +1029,27 @@ function Be(e, t, n) {
|
|
|
973
1029
|
}
|
|
974
1030
|
return o;
|
|
975
1031
|
}
|
|
976
|
-
var
|
|
1032
|
+
var Ge = {
|
|
977
1033
|
appStringPrefixes: ["b32"],
|
|
978
1034
|
parseAppString(e, t, n) {
|
|
979
|
-
return new
|
|
1035
|
+
return new z(We(Be(t), Ve, n), { ednEncoding: "base32" });
|
|
980
1036
|
}
|
|
981
|
-
},
|
|
1037
|
+
}, Ke = {
|
|
982
1038
|
appStringPrefixes: ["h32"],
|
|
983
1039
|
parseAppString(e, t, n) {
|
|
984
|
-
return new
|
|
985
|
-
}
|
|
986
|
-
};
|
|
987
|
-
//#endregion
|
|
988
|
-
//#region src/utils/base64.ts
|
|
989
|
-
function Ue(e, t) {
|
|
990
|
-
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
991
|
-
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
992
|
-
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
993
|
-
throw SyntaxError(`invalid character ${JSON.stringify(e)} in base64 data`);
|
|
994
|
-
}
|
|
995
|
-
if (i && !/^=+$/.test(i)) throw SyntaxError("invalid character after base64 '=' padding");
|
|
996
|
-
let a = r.length % 4;
|
|
997
|
-
if (a === 1) throw SyntaxError(`invalid base64 length: ${r.length} data characters (length mod 4 = 1 is never valid)`);
|
|
998
|
-
let o = a === 0 ? 0 : 4 - a;
|
|
999
|
-
if (i.length > o) {
|
|
1000
|
-
let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but the data length (${r.length}) requires at most ${o}`;
|
|
1001
|
-
if (t) t(e);
|
|
1002
|
-
else throw SyntaxError(e);
|
|
1003
|
-
}
|
|
1004
|
-
if (i.length > 0 && i.length < o) {
|
|
1005
|
-
let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but needs exactly ${o} — use full padding or no padding at all`;
|
|
1006
|
-
if (t) t(e);
|
|
1007
|
-
else throw SyntaxError(e);
|
|
1008
|
-
}
|
|
1009
|
-
if (a !== 0 && r.length > 0) {
|
|
1010
|
-
let e = r[r.length - 1].replace("-", "+").replace("_", "/"), n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e);
|
|
1011
|
-
if (n >= 0 && n & (a === 2 ? 15 : 3)) {
|
|
1012
|
-
let e = "base64 has non-zero trailing bits in the final quantum (RFC 4648 §3.5)";
|
|
1013
|
-
if (t) t(e);
|
|
1014
|
-
else throw SyntaxError(e);
|
|
1015
|
-
}
|
|
1040
|
+
return new z(We(Be(t), He, n), { ednEncoding: "base32hex" });
|
|
1016
1041
|
}
|
|
1017
|
-
|
|
1018
|
-
if (typeof Uint8Array.fromBase64 == "function") return Uint8Array.fromBase64(s, {
|
|
1019
|
-
alphabet: "base64",
|
|
1020
|
-
lastChunkHandling: "loose"
|
|
1021
|
-
});
|
|
1022
|
-
let c = atob(s), l = new Uint8Array(c.length);
|
|
1023
|
-
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
1024
|
-
return l;
|
|
1025
|
-
}
|
|
1026
|
-
//#endregion
|
|
1027
|
-
//#region src/ast/CborUnresolvedAppExt.ts
|
|
1028
|
-
var We = 999n, Ge = class extends M {
|
|
1042
|
+
}, qe = 999n, Je = class extends R {
|
|
1029
1043
|
constructor(e, t) {
|
|
1030
|
-
let n = t.length === 1 && t[0] instanceof
|
|
1031
|
-
super(
|
|
1044
|
+
let n = t.length === 1 && t[0] instanceof Y ? t[0] : new H(t);
|
|
1045
|
+
super(qe, new H([new Y(e), n]));
|
|
1032
1046
|
}
|
|
1033
1047
|
_toCDN(e, t) {
|
|
1034
|
-
if (e?.
|
|
1048
|
+
if (e?.appPrefix === !1) return super._toCDN(e, t);
|
|
1035
1049
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
1036
|
-
return i instanceof
|
|
1050
|
+
return i instanceof Y ? `${r}${ne(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
1037
1051
|
}
|
|
1038
|
-
},
|
|
1052
|
+
}, Ye = class extends P {
|
|
1039
1053
|
inner;
|
|
1040
1054
|
ednSource;
|
|
1041
1055
|
constructor(e, t) {
|
|
@@ -1044,140 +1058,148 @@ var We = 999n, Ge = class extends M {
|
|
|
1044
1058
|
get _containsCdnContainer() {
|
|
1045
1059
|
return this.inner._containsCdnContainer;
|
|
1046
1060
|
}
|
|
1061
|
+
_isMultiWordText(e, t = !0) {
|
|
1062
|
+
return y(this._toCDN(e, 0), t);
|
|
1063
|
+
}
|
|
1047
1064
|
_encodeTo(e, t) {
|
|
1048
1065
|
this.inner._encode(e, t);
|
|
1049
1066
|
}
|
|
1050
1067
|
_toCDN(e, t) {
|
|
1051
1068
|
let n = e?.encodingIndicators ?? "auto";
|
|
1052
|
-
return e?.
|
|
1069
|
+
return e?.appPrefix !== !1 && n === "auto" && (O(e) !== null || !/[\r\n]/.test(this.ednSource)) ? this.ednSource : this.inner._toCDN(e, t);
|
|
1053
1070
|
}
|
|
1054
1071
|
_toJS(e) {
|
|
1055
1072
|
return this.inner._toJS(e);
|
|
1056
1073
|
}
|
|
1057
|
-
},
|
|
1058
|
-
function
|
|
1059
|
-
return n ? [...(e.comments?.trailing ?? []).map((e) =>
|
|
1074
|
+
}, Xe = 888n;
|
|
1075
|
+
function Ze(e, t, n, r) {
|
|
1076
|
+
return n ? [...(e.comments?.trailing ?? []).map((e) => b(e, r)), ...(t.comments?.leading ?? []).map((e) => b(e, r))] : [];
|
|
1060
1077
|
}
|
|
1061
|
-
function
|
|
1062
|
-
return n === null || !t.some((e) => e.length > 0) ? e.join(" + ") :
|
|
1078
|
+
function Qe(e, t, n, r) {
|
|
1079
|
+
return n === null || !t.some((e) => e.length > 0) ? e.join(" + ") : oe(e, n, r, t);
|
|
1063
1080
|
}
|
|
1064
|
-
function
|
|
1081
|
+
function $e(e, t, r, i) {
|
|
1065
1082
|
if (e === void 0) return;
|
|
1066
|
-
let a = t
|
|
1067
|
-
return
|
|
1083
|
+
let a = n(t) || i === void 0 ? e : x(e, i);
|
|
1084
|
+
return tt(a, r) ? a : void 0;
|
|
1068
1085
|
}
|
|
1069
|
-
function
|
|
1070
|
-
return e !== void 0 &&
|
|
1086
|
+
function et(e, t) {
|
|
1087
|
+
return e !== void 0 && tt(e, t);
|
|
1071
1088
|
}
|
|
1072
|
-
function
|
|
1089
|
+
function tt(e, t) {
|
|
1073
1090
|
return t !== null || !/[\r\n]/.test(e);
|
|
1074
1091
|
}
|
|
1075
|
-
var
|
|
1092
|
+
var K = class e extends R {
|
|
1076
1093
|
realBoundary;
|
|
1077
1094
|
fromByteLiteral;
|
|
1078
1095
|
literalSource;
|
|
1079
1096
|
constructor(e, t) {
|
|
1080
|
-
Array.isArray(e) ? (super(
|
|
1081
|
-
}
|
|
1082
|
-
_toCDN(
|
|
1083
|
-
if (
|
|
1084
|
-
if (this.content instanceof
|
|
1085
|
-
if (this.content instanceof
|
|
1086
|
-
let
|
|
1087
|
-
if (
|
|
1088
|
-
let
|
|
1089
|
-
if (
|
|
1097
|
+
Array.isArray(e) ? (super(Xe, new H(e)), this.fromByteLiteral = !1, this.literalSource = void 0, this.realBoundary = t) : (super(Xe, W.NULL), this.fromByteLiteral = e ?? !1, this.literalSource = t, this.realBoundary = void 0);
|
|
1098
|
+
}
|
|
1099
|
+
_toCDN(t, r) {
|
|
1100
|
+
if (t?.appPrefix === !1) return super._toCDN(t, r);
|
|
1101
|
+
if (this.content instanceof W) return "...";
|
|
1102
|
+
if (this.content instanceof H) {
|
|
1103
|
+
let i = !!t?.preserveConcatenation;
|
|
1104
|
+
if (i || t?.preserveByteString && !this._hasRealConcatenation()) {
|
|
1105
|
+
let e = this._renderPreservedBytesElision(t, r);
|
|
1106
|
+
if (e !== void 0) return e;
|
|
1090
1107
|
}
|
|
1091
|
-
if (!
|
|
1108
|
+
if (!i || this.realBoundary === void 0) {
|
|
1092
1109
|
let e = this._compactHexElided();
|
|
1093
1110
|
if (e !== void 0) return e;
|
|
1094
1111
|
}
|
|
1095
|
-
let
|
|
1096
|
-
|
|
1112
|
+
let a = this.content.items, o = a.map((e) => i ? this._renderFragment(e, t, r) : e._toCDN(t, r)), s = n(t), c = u(t), l = a.slice(1).map((e, t) => Ze(a[t], e, s, c));
|
|
1113
|
+
if (t?.modernConcat) {
|
|
1114
|
+
let n = a.every((t) => t instanceof z || t instanceof e && t.content instanceof W);
|
|
1115
|
+
return ie(n ? "b1" : "t1", o, "", O(t), r, l);
|
|
1116
|
+
}
|
|
1117
|
+
return Qe(o, l, O(t), r);
|
|
1097
1118
|
}
|
|
1098
|
-
return super._toCDN(
|
|
1119
|
+
return super._toCDN(t, r);
|
|
1099
1120
|
}
|
|
1100
1121
|
_hasRealConcatenation() {
|
|
1101
|
-
return this.realBoundary?.some((e, t) => t > 0 && e) ? !0 : this.content.items.some((e) => e instanceof
|
|
1102
|
-
}
|
|
1103
|
-
_renderFragment(e, t,
|
|
1104
|
-
let
|
|
1105
|
-
if (e instanceof
|
|
1106
|
-
let
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
}
|
|
1112
|
-
if (e instanceof
|
|
1113
|
-
let
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1119
|
-
return e._toCDN(t,
|
|
1122
|
+
return this.realBoundary?.some((e, t) => t > 0 && e) ? !0 : this.content.items.some((e) => e instanceof z && e.ednParts !== void 0 && e.ednParts.length > 1);
|
|
1123
|
+
}
|
|
1124
|
+
_renderFragment(e, t, r) {
|
|
1125
|
+
let i = O(t), a = n(t), o = u(t), s = !!t?.modernConcat;
|
|
1126
|
+
if (e instanceof z && e.ednParts !== void 0 && e.ednParts.length > 1) {
|
|
1127
|
+
let n = t?.appPrefix === !1 ? "hex" : t?.bstrEncoding ?? e.ednEncoding, c = e.ednParts.map((e) => {
|
|
1128
|
+
let r = t?.preserveByteString ? $e(e.source, t, i, e.commentSyntax) : void 0;
|
|
1129
|
+
return r === void 0 ? d(e.bytes, n, t?.sqstr) : r;
|
|
1130
|
+
}), l = a ? p(e.comments?.dangling, e.ednParts, o) ?? [] : [];
|
|
1131
|
+
return s ? ie("b1", c, "", i, r, l) : Qe(c, l, i, r);
|
|
1132
|
+
}
|
|
1133
|
+
if (e instanceof Y && e.ednParts !== void 0 && e.ednParts.length > 1) {
|
|
1134
|
+
let n = t?.preserveRawString ? e.ednPartSources : void 0, c = e.ednParts.map((e, t) => {
|
|
1135
|
+
let r = n?.[t];
|
|
1136
|
+
return et(r, i) ? r : h(e);
|
|
1137
|
+
}), l = a ? p(e.comments?.dangling, e.ednPartSpans, o) ?? [] : [];
|
|
1138
|
+
return s ? ie("t1", c, "", i, r, l) : Qe(c, l, i, r);
|
|
1139
|
+
}
|
|
1140
|
+
return e._toCDN(t, r);
|
|
1120
1141
|
}
|
|
1121
1142
|
_compactHexElided() {
|
|
1122
1143
|
let t = this.content.items, n = "", r = !1;
|
|
1123
|
-
for (let i of t) if (i instanceof
|
|
1124
|
-
else if (i instanceof e && i.content instanceof
|
|
1144
|
+
for (let i of t) if (i instanceof z) n += s(i.value), r = !0;
|
|
1145
|
+
else if (i instanceof e && i.content instanceof W) n += "...";
|
|
1125
1146
|
else return;
|
|
1126
1147
|
if (r) return `h'${n}'`;
|
|
1127
1148
|
}
|
|
1128
|
-
_renderPreservedBytesElision(t,
|
|
1149
|
+
_renderPreservedBytesElision(t, r) {
|
|
1129
1150
|
if (this.realBoundary === void 0) return;
|
|
1130
|
-
let
|
|
1131
|
-
|
|
1132
|
-
},
|
|
1133
|
-
for (let t = 0; t <
|
|
1134
|
-
let n =
|
|
1135
|
-
if (t > 0 &&
|
|
1151
|
+
let i = this.realBoundary, a = this.content.items, o = [], c = [], l = [], f = (e) => {
|
|
1152
|
+
l.length > 0 && (o.push(l), c.push(e ?? []), l = []);
|
|
1153
|
+
}, m = n(t), h = u(t);
|
|
1154
|
+
for (let t = 0; t < a.length; t++) {
|
|
1155
|
+
let n = a[t];
|
|
1156
|
+
if (t > 0 && i[t] && f(Ze(a[t - 1], n, m, h)), n instanceof e && n.content instanceof W) l.push({
|
|
1136
1157
|
ellipsis: !0,
|
|
1137
1158
|
fromByteLiteral: n.fromByteLiteral,
|
|
1138
1159
|
literalSource: n.literalSource
|
|
1139
1160
|
});
|
|
1140
|
-
else if (n instanceof
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
source: e.source,
|
|
1145
|
-
commentSyntax: e.commentSyntax
|
|
1146
|
-
});
|
|
1147
|
-
let r = l ? ne(n.comments?.dangling, n.ednParts, u) : void 0;
|
|
1148
|
-
t.forEach((e, t) => {
|
|
1149
|
-
c(r?.[t]), s.push({
|
|
1161
|
+
else if (n instanceof z) {
|
|
1162
|
+
if (n.ednParts !== void 0 && n.ednParts.length > 1) {
|
|
1163
|
+
let [e, ...t] = n.ednParts;
|
|
1164
|
+
l.push({
|
|
1150
1165
|
bytes: e.bytes,
|
|
1151
1166
|
source: e.source,
|
|
1152
1167
|
commentSyntax: e.commentSyntax
|
|
1153
1168
|
});
|
|
1169
|
+
let r = m ? p(n.comments?.dangling, n.ednParts, h) : void 0;
|
|
1170
|
+
t.forEach((e, t) => {
|
|
1171
|
+
f(r?.[t]), l.push({
|
|
1172
|
+
bytes: e.bytes,
|
|
1173
|
+
source: e.source,
|
|
1174
|
+
commentSyntax: e.commentSyntax
|
|
1175
|
+
});
|
|
1176
|
+
});
|
|
1177
|
+
} else l.push({
|
|
1178
|
+
bytes: n.value,
|
|
1179
|
+
source: n.ednSource,
|
|
1180
|
+
commentSyntax: n.ednCommentSyntax
|
|
1154
1181
|
});
|
|
1155
|
-
} else
|
|
1156
|
-
bytes: n.value,
|
|
1157
|
-
source: n.ednSource,
|
|
1158
|
-
commentSyntax: n.ednCommentSyntax
|
|
1159
|
-
});
|
|
1160
|
-
else return;
|
|
1182
|
+
} else return;
|
|
1161
1183
|
}
|
|
1162
|
-
if (
|
|
1163
|
-
let
|
|
1164
|
-
return Je(a.map((e) => {
|
|
1184
|
+
if (l.length > 0 && o.push(l), o.length === 0) return;
|
|
1185
|
+
let g = t?.appPrefix === !1 ? "hex" : t?.bstrEncoding ?? "hex", _ = O(t), v = o.map((e) => {
|
|
1165
1186
|
if (t?.preserveByteString) for (let n of e) {
|
|
1166
1187
|
if (!("ellipsis" in n)) continue;
|
|
1167
|
-
let e =
|
|
1188
|
+
let e = $e(n.literalSource, t, _, "full");
|
|
1168
1189
|
if (e !== void 0) return e;
|
|
1169
1190
|
}
|
|
1170
1191
|
let n = e.filter((e) => !("ellipsis" in e));
|
|
1171
1192
|
if (n.length === 0) return e.some((e) => "ellipsis" in e && e.fromByteLiteral) ? "h'...'" : "...";
|
|
1172
1193
|
if (e.length === 1) {
|
|
1173
|
-
let e = n[0], r = t?.preserveByteString ?
|
|
1174
|
-
return r === void 0 ?
|
|
1194
|
+
let e = n[0], r = t?.preserveByteString ? $e(e.source, t, _, e.commentSyntax) : void 0;
|
|
1195
|
+
return r === void 0 ? d(e.bytes, g, t?.sqstr) : r;
|
|
1175
1196
|
}
|
|
1176
|
-
return `h'${e.map((e) => "ellipsis" in e ? "..." :
|
|
1177
|
-
})
|
|
1197
|
+
return `h'${e.map((e) => "ellipsis" in e ? "..." : s(e.bytes)).join("")}'`;
|
|
1198
|
+
});
|
|
1199
|
+
return t?.preserveConcatenation && t?.modernConcat && v.length > 1 ? ie("b1", v, "", _, r, c) : Qe(v, c, _, r);
|
|
1178
1200
|
}
|
|
1179
|
-
},
|
|
1180
|
-
function
|
|
1201
|
+
}, nt = 2n, rt = 3n, it = 18446744073709551615n, at = -18446744073709551616n;
|
|
1202
|
+
function ot(e) {
|
|
1181
1203
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
1182
1204
|
if (e === 0n) return /* @__PURE__ */ new Uint8Array();
|
|
1183
1205
|
let t = e.toString(16);
|
|
@@ -1186,16 +1208,16 @@ function nt(e) {
|
|
|
1186
1208
|
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
1187
1209
|
return n;
|
|
1188
1210
|
}
|
|
1189
|
-
function
|
|
1211
|
+
function st(e) {
|
|
1190
1212
|
let t = 0n;
|
|
1191
1213
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
1192
1214
|
return t;
|
|
1193
1215
|
}
|
|
1194
|
-
var
|
|
1216
|
+
var ct = class extends R {
|
|
1195
1217
|
bigValue;
|
|
1196
1218
|
constructor(e) {
|
|
1197
|
-
if (e <=
|
|
1198
|
-
super(
|
|
1219
|
+
if (e <= it) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1220
|
+
super(nt, new z(ot(e))), this.bigValue = e;
|
|
1199
1221
|
}
|
|
1200
1222
|
_toCDN(e, t) {
|
|
1201
1223
|
return this.bigValue.toString();
|
|
@@ -1203,11 +1225,11 @@ var it = class extends M {
|
|
|
1203
1225
|
_toJS(e) {
|
|
1204
1226
|
return this.bigValue;
|
|
1205
1227
|
}
|
|
1206
|
-
},
|
|
1228
|
+
}, lt = class extends R {
|
|
1207
1229
|
bigValue;
|
|
1208
1230
|
constructor(e) {
|
|
1209
|
-
if (e >=
|
|
1210
|
-
super(
|
|
1231
|
+
if (e >= at) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1232
|
+
super(rt, new z(ot(-1n - e))), this.bigValue = e;
|
|
1211
1233
|
}
|
|
1212
1234
|
_toCDN(e, t) {
|
|
1213
1235
|
return this.bigValue.toString();
|
|
@@ -1215,33 +1237,33 @@ var it = class extends M {
|
|
|
1215
1237
|
_toJS(e) {
|
|
1216
1238
|
return this.bigValue;
|
|
1217
1239
|
}
|
|
1218
|
-
},
|
|
1219
|
-
function
|
|
1220
|
-
let
|
|
1221
|
-
offset:
|
|
1222
|
-
skipRS:
|
|
1223
|
-
}),
|
|
1224
|
-
return (
|
|
1240
|
+
}, ut = new TextEncoder(), dt = new TextDecoder("utf-8", { fatal: !0 }), ft = new TextDecoder("utf-8", { fatal: !1 });
|
|
1241
|
+
function pt(t, r) {
|
|
1242
|
+
let i = new e(t, {
|
|
1243
|
+
offset: r?.offset,
|
|
1244
|
+
skipRS: r?._skipRS
|
|
1245
|
+
}), a = new Mt(i, r ?? {}).parse();
|
|
1246
|
+
return (n(r) || r?.preserveAll) && (wt(a, i.comments, t), Dt(a)), a;
|
|
1225
1247
|
}
|
|
1226
|
-
function
|
|
1248
|
+
function mt(e) {
|
|
1227
1249
|
let t = e, n;
|
|
1228
1250
|
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1229
1251
|
numStr: t,
|
|
1230
1252
|
rawSuffix: n
|
|
1231
1253
|
};
|
|
1232
1254
|
}
|
|
1233
|
-
function
|
|
1255
|
+
function ht(e) {
|
|
1234
1256
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1235
1257
|
}
|
|
1236
|
-
function
|
|
1237
|
-
if (e !== void 0) return
|
|
1258
|
+
function q(e) {
|
|
1259
|
+
if (e !== void 0) return _t([e.appSeqSourceFeatures, gt(e)]);
|
|
1238
1260
|
}
|
|
1239
|
-
function
|
|
1240
|
-
if (e instanceof
|
|
1261
|
+
function gt(e) {
|
|
1262
|
+
if (e instanceof z) return {
|
|
1241
1263
|
byteString: !0,
|
|
1242
1264
|
concatenation: e.ednParts !== void 0 && e.ednParts.length > 1
|
|
1243
1265
|
};
|
|
1244
|
-
if (e instanceof
|
|
1266
|
+
if (e instanceof Y) {
|
|
1245
1267
|
let t = e.ednParts !== void 0, n = e.ednPartSources?.filter((e) => e !== void 0).length ?? 0, r = t ? e.ednParts.reduce((t, n, r) => {
|
|
1246
1268
|
let i = e.ednPartSources?.[r] !== void 0, a = e.ednPartIsByteString?.[r] ?? !1;
|
|
1247
1269
|
return i || !a ? t : t + 1;
|
|
@@ -1253,12 +1275,12 @@ function ft(e) {
|
|
|
1253
1275
|
concatenation: t && e.ednParts.length > 1
|
|
1254
1276
|
};
|
|
1255
1277
|
}
|
|
1256
|
-
if (e instanceof
|
|
1257
|
-
if (e instanceof
|
|
1258
|
-
if (e instanceof
|
|
1259
|
-
if (e instanceof
|
|
1278
|
+
if (e instanceof H) return _t(e.items.map(q));
|
|
1279
|
+
if (e instanceof U) return _t(e.entries.flatMap(([e, t]) => [q(e), q(t)]));
|
|
1280
|
+
if (e instanceof R) return q(e.content);
|
|
1281
|
+
if (e instanceof B || e instanceof V || e instanceof G) return _t((e instanceof G ? e.items : e.chunks).map(q));
|
|
1260
1282
|
}
|
|
1261
|
-
function
|
|
1283
|
+
function _t(e) {
|
|
1262
1284
|
let t = e.filter((e) => e !== void 0);
|
|
1263
1285
|
if (t.length !== 0) return {
|
|
1264
1286
|
byteString: t.some((e) => e.byteString),
|
|
@@ -1267,7 +1289,7 @@ function pt(e) {
|
|
|
1267
1289
|
concatenation: t.some((e) => e.concatenation)
|
|
1268
1290
|
};
|
|
1269
1291
|
}
|
|
1270
|
-
function
|
|
1292
|
+
function vt(e, t) {
|
|
1271
1293
|
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1272
1294
|
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1273
1295
|
if (t) t(n), e = e.slice(0, -2);
|
|
@@ -1291,18 +1313,18 @@ function mt(e, t) {
|
|
|
1291
1313
|
};
|
|
1292
1314
|
let n = e, r;
|
|
1293
1315
|
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) ? {
|
|
1294
|
-
value:
|
|
1316
|
+
value: Ie(n),
|
|
1295
1317
|
precision: r
|
|
1296
1318
|
} : {
|
|
1297
1319
|
value: parseFloat(n),
|
|
1298
1320
|
precision: r
|
|
1299
1321
|
};
|
|
1300
1322
|
}
|
|
1301
|
-
var
|
|
1302
|
-
function
|
|
1303
|
-
return
|
|
1323
|
+
var yt = /\r?\n[ \t]*\r?\n/;
|
|
1324
|
+
function bt(e, t, n) {
|
|
1325
|
+
return yt.test(e.slice(t, n));
|
|
1304
1326
|
}
|
|
1305
|
-
function
|
|
1327
|
+
function xt(e, t, n, r) {
|
|
1306
1328
|
let i = [];
|
|
1307
1329
|
for (let a = t; a < e.length; a++) {
|
|
1308
1330
|
let t = e[a];
|
|
@@ -1315,7 +1337,7 @@ function _t(e, t, n, r) {
|
|
|
1315
1337
|
}
|
|
1316
1338
|
return i;
|
|
1317
1339
|
}
|
|
1318
|
-
function
|
|
1340
|
+
function St(e, t, n, r) {
|
|
1319
1341
|
if (n.end !== void 0) return {
|
|
1320
1342
|
start: (/_[0-7i]$/.test(e.slice(Math.max(0, n.end - 2), n.end)) ? n.end - 2 : n.end) - t,
|
|
1321
1343
|
end: n.end - t,
|
|
@@ -1323,50 +1345,50 @@ function vt(e, t, n, r) {
|
|
|
1323
1345
|
never: ""
|
|
1324
1346
|
};
|
|
1325
1347
|
}
|
|
1326
|
-
function
|
|
1327
|
-
if (
|
|
1328
|
-
let
|
|
1329
|
-
return
|
|
1348
|
+
function Ct(t, n, r) {
|
|
1349
|
+
if (r instanceof F) {
|
|
1350
|
+
let e = St(t, n, r, `_${r.encodingWidth ?? E(r.value)}`);
|
|
1351
|
+
return e ? [e] : [];
|
|
1330
1352
|
}
|
|
1331
|
-
if (
|
|
1332
|
-
let
|
|
1333
|
-
return
|
|
1353
|
+
if (r instanceof I) {
|
|
1354
|
+
let e = St(t, n, r, `_${r.encodingWidth ?? E(r.argument)}`);
|
|
1355
|
+
return e ? [e] : [];
|
|
1334
1356
|
}
|
|
1335
|
-
if (
|
|
1336
|
-
let
|
|
1357
|
+
if (r instanceof L) {
|
|
1358
|
+
let e = r.precision ?? N(r.value), i = St(t, n, r, e === "half" ? "_1" : e === "single" ? "_2" : "_3");
|
|
1337
1359
|
return i ? [i] : [];
|
|
1338
1360
|
}
|
|
1339
|
-
if (
|
|
1340
|
-
let
|
|
1341
|
-
return
|
|
1342
|
-
}
|
|
1343
|
-
if (
|
|
1344
|
-
let
|
|
1345
|
-
return
|
|
1346
|
-
}
|
|
1347
|
-
if (
|
|
1348
|
-
let
|
|
1349
|
-
if (
|
|
1350
|
-
if (
|
|
1351
|
-
let
|
|
1352
|
-
|
|
1353
|
-
start: (
|
|
1354
|
-
end: (
|
|
1355
|
-
always:
|
|
1361
|
+
if (r instanceof z) {
|
|
1362
|
+
let e = St(t, n, r, `_${r.encodingWidth ?? E(BigInt(r.value.length))}`);
|
|
1363
|
+
return e ? [e] : [];
|
|
1364
|
+
}
|
|
1365
|
+
if (r instanceof Y) {
|
|
1366
|
+
let e = St(t, n, r, `_${r.encodingWidth ?? E(BigInt(ut.encode(r.value).length))}`);
|
|
1367
|
+
return e ? [e] : [];
|
|
1368
|
+
}
|
|
1369
|
+
if (r instanceof H) {
|
|
1370
|
+
let i = [];
|
|
1371
|
+
if (r.indefiniteLength) return;
|
|
1372
|
+
if (r.start !== void 0) {
|
|
1373
|
+
let a = new e(t, { offset: r.start }), o = a.consume(), s = a.peek(), c = s.type === "ENCODING_INDICATOR", l = `_${r.encodingWidth ?? E(BigInt(r.items.length))}`, u = t[o.endOffset] ?? "", d = !c && /[+\-.0-9A-Z_a-z]/.test(u) ? " " : "";
|
|
1374
|
+
i.push({
|
|
1375
|
+
start: (c ? s.offset : o.endOffset) - n,
|
|
1376
|
+
end: (c ? s.endOffset : o.endOffset) - n,
|
|
1377
|
+
always: l + d,
|
|
1356
1378
|
never: ""
|
|
1357
1379
|
});
|
|
1358
1380
|
}
|
|
1359
|
-
for (let
|
|
1360
|
-
let
|
|
1361
|
-
if (
|
|
1362
|
-
r
|
|
1381
|
+
for (let e of r.items) {
|
|
1382
|
+
let r = Ct(t, n, e);
|
|
1383
|
+
if (r === void 0) return;
|
|
1384
|
+
m(i, r);
|
|
1363
1385
|
}
|
|
1364
|
-
return
|
|
1386
|
+
return i;
|
|
1365
1387
|
}
|
|
1366
1388
|
}
|
|
1367
|
-
function
|
|
1389
|
+
function wt(e, t, n) {
|
|
1368
1390
|
if (t.length === 0) return;
|
|
1369
|
-
let r =
|
|
1391
|
+
let r = Tt(e), i = Ot(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;
|
|
1370
1392
|
for (let e of s) {
|
|
1371
1393
|
let t = { ...e }, r = 0, s = o.length;
|
|
1372
1394
|
for (; r < s;) {
|
|
@@ -1375,7 +1397,7 @@ function bt(e, t, n) {
|
|
|
1375
1397
|
}
|
|
1376
1398
|
let u = r > 0 ? o[r - 1] : void 0, d = u ? n.slice(u.end, e.start) : "";
|
|
1377
1399
|
if (u && i(u.end) === e.line && !d.includes(":")) {
|
|
1378
|
-
|
|
1400
|
+
Et(u.node, "trailing", t);
|
|
1379
1401
|
continue;
|
|
1380
1402
|
}
|
|
1381
1403
|
for (; l < a.length && a[l].start < e.start;) {
|
|
@@ -1391,62 +1413,62 @@ function bt(e, t, n) {
|
|
|
1391
1413
|
}
|
|
1392
1414
|
let p = r < a.length ? a[r] : void 0;
|
|
1393
1415
|
if ((!f || p && p.end <= f.end) && p) {
|
|
1394
|
-
t.sameLine = i(e.end) === i(p.start),
|
|
1416
|
+
t.sameLine = i(e.end) === i(p.start), Et(p.node, "leading", t);
|
|
1395
1417
|
continue;
|
|
1396
1418
|
}
|
|
1397
|
-
f &&
|
|
1419
|
+
f && Et(f.node, "dangling", t);
|
|
1398
1420
|
}
|
|
1399
1421
|
}
|
|
1400
|
-
function
|
|
1422
|
+
function Tt(e) {
|
|
1401
1423
|
let t = [], n = (e) => {
|
|
1402
1424
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1403
1425
|
node: e,
|
|
1404
1426
|
start: e.start,
|
|
1405
1427
|
end: e.end
|
|
1406
|
-
}), e instanceof
|
|
1428
|
+
}), e instanceof H || e instanceof G) {
|
|
1407
1429
|
for (let t of e.items) n(t);
|
|
1408
1430
|
return;
|
|
1409
1431
|
}
|
|
1410
|
-
if (e instanceof
|
|
1432
|
+
if (e instanceof U) {
|
|
1411
1433
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1412
1434
|
return;
|
|
1413
1435
|
}
|
|
1414
|
-
if (e instanceof
|
|
1436
|
+
if (e instanceof B || e instanceof V) {
|
|
1415
1437
|
for (let t of e.chunks) n(t);
|
|
1416
1438
|
return;
|
|
1417
1439
|
}
|
|
1418
|
-
e instanceof
|
|
1440
|
+
e instanceof R && n(e.content);
|
|
1419
1441
|
};
|
|
1420
1442
|
return n(e), t;
|
|
1421
1443
|
}
|
|
1422
|
-
function
|
|
1444
|
+
function Et(e, t, n) {
|
|
1423
1445
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1424
1446
|
}
|
|
1425
|
-
function
|
|
1426
|
-
if (e instanceof
|
|
1427
|
-
if (e.content instanceof
|
|
1447
|
+
function Dt(e) {
|
|
1448
|
+
if (e instanceof K) {
|
|
1449
|
+
if (e.content instanceof H) {
|
|
1428
1450
|
let t = e.content.items;
|
|
1429
|
-
for (let e of t)
|
|
1451
|
+
for (let e of t) Dt(e);
|
|
1430
1452
|
let n = t[t.length - 1], r = n?.comments?.trailing;
|
|
1431
1453
|
r !== void 0 && r.length > 0 && !e.comments?.trailing?.length && (e.comments ??= {}, e.comments.trailing = r, n.comments.trailing = void 0);
|
|
1432
1454
|
}
|
|
1433
1455
|
return;
|
|
1434
1456
|
}
|
|
1435
|
-
if (e instanceof
|
|
1436
|
-
for (let t of e.items)
|
|
1457
|
+
if (e instanceof H || e instanceof G) {
|
|
1458
|
+
for (let t of e.items) Dt(t);
|
|
1437
1459
|
return;
|
|
1438
1460
|
}
|
|
1439
|
-
if (e instanceof
|
|
1440
|
-
for (let [t, n] of e.entries)
|
|
1461
|
+
if (e instanceof U) {
|
|
1462
|
+
for (let [t, n] of e.entries) Dt(t), Dt(n);
|
|
1441
1463
|
return;
|
|
1442
1464
|
}
|
|
1443
|
-
if (e instanceof
|
|
1444
|
-
for (let t of e.chunks)
|
|
1465
|
+
if (e instanceof B || e instanceof V) {
|
|
1466
|
+
for (let t of e.chunks) Dt(t);
|
|
1445
1467
|
return;
|
|
1446
1468
|
}
|
|
1447
|
-
e instanceof
|
|
1469
|
+
e instanceof R && Dt(e.content);
|
|
1448
1470
|
}
|
|
1449
|
-
function
|
|
1471
|
+
function Ot(e) {
|
|
1450
1472
|
let t = [0];
|
|
1451
1473
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1452
1474
|
return (n) => {
|
|
@@ -1460,25 +1482,25 @@ function Ct(e) {
|
|
|
1460
1482
|
return a + 1;
|
|
1461
1483
|
};
|
|
1462
1484
|
}
|
|
1463
|
-
var
|
|
1464
|
-
["b32",
|
|
1465
|
-
["h32",
|
|
1466
|
-
["same",
|
|
1467
|
-
["hash",
|
|
1468
|
-
["uuid",
|
|
1469
|
-
["UUID",
|
|
1470
|
-
["dt",
|
|
1471
|
-
["DT",
|
|
1472
|
-
["ip",
|
|
1473
|
-
["IP",
|
|
1474
|
-
["cri",
|
|
1475
|
-
["CRI",
|
|
1476
|
-
["t1",
|
|
1477
|
-
["b1",
|
|
1478
|
-
["ilbs",
|
|
1479
|
-
["ilts",
|
|
1480
|
-
["float",
|
|
1481
|
-
]),
|
|
1485
|
+
var kt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, At = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, J = (e) => `'${e}' is a default built-in extension that was excluded via the 'builtinExtensions' option; add it back to that array (or omit 'builtinExtensions' to use the default set)`, jt = /* @__PURE__ */ new Map([
|
|
1486
|
+
["b32", kt("b32")],
|
|
1487
|
+
["h32", kt("h32")],
|
|
1488
|
+
["same", kt("same")],
|
|
1489
|
+
["hash", At("hash", "@cbortech/hash-extension")],
|
|
1490
|
+
["uuid", At("uuid", "@cbortech/uuid-extension")],
|
|
1491
|
+
["UUID", At("uuid", "@cbortech/uuid-extension")],
|
|
1492
|
+
["dt", J("dt")],
|
|
1493
|
+
["DT", J("dt")],
|
|
1494
|
+
["ip", J("ip")],
|
|
1495
|
+
["IP", J("ip")],
|
|
1496
|
+
["cri", J("cri")],
|
|
1497
|
+
["CRI", J("cri")],
|
|
1498
|
+
["t1", J("t1")],
|
|
1499
|
+
["b1", J("b1")],
|
|
1500
|
+
["ilbs", J("ilbs")],
|
|
1501
|
+
["ilts", J("ilts")],
|
|
1502
|
+
["float", J("float")]
|
|
1503
|
+
]), Mt = class {
|
|
1482
1504
|
t;
|
|
1483
1505
|
_options;
|
|
1484
1506
|
extByPrefix;
|
|
@@ -1486,26 +1508,26 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1486
1508
|
unresolvedExtension;
|
|
1487
1509
|
_pendingWarnings = [];
|
|
1488
1510
|
_hintedPrefixes = /* @__PURE__ */ new Set();
|
|
1489
|
-
constructor(e,
|
|
1490
|
-
this.t = e, this._options =
|
|
1491
|
-
let
|
|
1492
|
-
for (let e of [...
|
|
1511
|
+
constructor(e, t) {
|
|
1512
|
+
this.t = e, this._options = t, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = t.unresolvedExtension ?? "cpa999";
|
|
1513
|
+
let n = di(t.builtinExtensions);
|
|
1514
|
+
for (let e of [...n, ...t.extensions ?? []]) {
|
|
1493
1515
|
for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
|
|
1494
1516
|
for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
|
|
1495
1517
|
}
|
|
1496
|
-
this.t.onEscapeWarning = (e, n, r, i
|
|
1518
|
+
this.t.onEscapeWarning = (e, t, n, r, i) => {
|
|
1497
1519
|
let o = {
|
|
1498
1520
|
message: e,
|
|
1499
|
-
offset:
|
|
1500
|
-
line:
|
|
1501
|
-
column:
|
|
1502
|
-
endOffset:
|
|
1521
|
+
offset: t,
|
|
1522
|
+
line: n,
|
|
1523
|
+
column: r,
|
|
1524
|
+
endOffset: i
|
|
1503
1525
|
};
|
|
1504
|
-
if (this._pendingWarnings.push(o), this._options.onWarning ? this._options.onWarning(o) : this._options.silent || console.warn(`CDN strict violation at line ${
|
|
1505
|
-
offset:
|
|
1506
|
-
line:
|
|
1507
|
-
column:
|
|
1508
|
-
endOffset:
|
|
1526
|
+
if (this._pendingWarnings.push(o), this._options.onWarning ? this._options.onWarning(o) : this._options.silent || console.warn(`CDN strict violation at line ${n}, column ${r}: ${e}`), this._options.strict !== !1) throw new a(e, {
|
|
1527
|
+
offset: t,
|
|
1528
|
+
line: n,
|
|
1529
|
+
column: r,
|
|
1530
|
+
endOffset: i
|
|
1509
1531
|
});
|
|
1510
1532
|
};
|
|
1511
1533
|
}
|
|
@@ -1539,12 +1561,12 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1539
1561
|
case "BYTES_HEX":
|
|
1540
1562
|
case "SQSTR":
|
|
1541
1563
|
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw, e.offset, e.endOffset);
|
|
1542
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new
|
|
1543
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new
|
|
1544
|
-
case "TRUE": return this.t.consume(), new
|
|
1545
|
-
case "FALSE": return this.t.consume(), new
|
|
1546
|
-
case "NULL": return this.t.consume(), new
|
|
1547
|
-
case "UNDEFINED": return this.t.consume(), new
|
|
1564
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new B([]);
|
|
1565
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new V([]);
|
|
1566
|
+
case "TRUE": return this.t.consume(), new W(21);
|
|
1567
|
+
case "FALSE": return this.t.consume(), new W(20);
|
|
1568
|
+
case "NULL": return this.t.consume(), new W(22);
|
|
1569
|
+
case "UNDEFINED": return this.t.consume(), new W(23);
|
|
1548
1570
|
case "SIMPLE": return this.parseSimple();
|
|
1549
1571
|
case "LBRACKET": return this.parseArray();
|
|
1550
1572
|
case "LBRACE": return this.parseMap();
|
|
@@ -1559,22 +1581,22 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1559
1581
|
}
|
|
1560
1582
|
let r = this.extByPrefix.get(e.appPrefix);
|
|
1561
1583
|
if (!r?.parseAppString) {
|
|
1562
|
-
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1584
|
+
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Je(e.appPrefix, [new Y(e.value)]);
|
|
1563
1585
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1564
1586
|
}
|
|
1565
1587
|
{
|
|
1566
1588
|
let i = this._pendingWarnings.length;
|
|
1567
1589
|
try {
|
|
1568
1590
|
let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
|
|
1569
|
-
return t !== void 0 && this._applyEiToResult(i, t, e), r.preserveAppSeqSource === "optional" ? (i.appSeqSource = e.raw + n, i) : i instanceof
|
|
1591
|
+
return t !== void 0 && this._applyEiToResult(i, t, e), r.preserveAppSeqSource === "optional" ? (i.appSeqSource = e.raw + n, i) : i instanceof z && Object.getPrototypeOf(i) === z.prototype && i.ednSource === void 0 ? new z(i.value, {
|
|
1570
1592
|
ednEncoding: i.ednEncoding,
|
|
1571
1593
|
encodingWidth: i.encodingWidth,
|
|
1572
1594
|
ednSource: e.raw + n,
|
|
1573
|
-
ednCommentSyntax: r ===
|
|
1574
|
-
}) : (i instanceof
|
|
1595
|
+
ednCommentSyntax: r === Ge || r === Ke ? "full" : void 0
|
|
1596
|
+
}) : (i instanceof L && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1575
1597
|
} catch (t) {
|
|
1576
1598
|
if (this._options.strict !== !1) throw t;
|
|
1577
|
-
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new
|
|
1599
|
+
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Je(e.appPrefix, [new Y(e.value)]);
|
|
1578
1600
|
}
|
|
1579
1601
|
}
|
|
1580
1602
|
}
|
|
@@ -1583,9 +1605,11 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1583
1605
|
this.t.consume();
|
|
1584
1606
|
let n = [];
|
|
1585
1607
|
for (; this.t.peek().type !== "GT_GT";) {
|
|
1586
|
-
if (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), n.length > 0)
|
|
1587
|
-
if (this.t.
|
|
1588
|
-
|
|
1608
|
+
if (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), n.length > 0) {
|
|
1609
|
+
if (this.t.peek().type === "COMMA") {
|
|
1610
|
+
if (this.t.consume(), this.t.peek().type === "GT_GT") break;
|
|
1611
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
|
|
1612
|
+
}
|
|
1589
1613
|
n.push(this.parseValue());
|
|
1590
1614
|
}
|
|
1591
1615
|
this.expect("GT_GT");
|
|
@@ -1593,7 +1617,7 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1593
1617
|
this.t.peek().type === "ENCODING_INDICATOR" && (i = this.t.consume(), r = this._resolveEncodingWidth(i.value, i));
|
|
1594
1618
|
let a = this.extByPrefix.get(e.appPrefix);
|
|
1595
1619
|
if (!a) {
|
|
1596
|
-
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new
|
|
1620
|
+
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Je(e.appPrefix, n);
|
|
1597
1621
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1598
1622
|
}
|
|
1599
1623
|
a.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
@@ -1603,65 +1627,65 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1603
1627
|
let o = a.parseAppSequence(e.appPrefix, n, this._extOnError(e));
|
|
1604
1628
|
r !== void 0 && this._applyEiToResult(o, r, i ?? e);
|
|
1605
1629
|
let s = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1606
|
-
if (a.preserveAppSeqSource === "optional") o.appSeqSource = s, o.appSeqComments =
|
|
1607
|
-
else if (o instanceof
|
|
1608
|
-
else if (a.preserveAppSeqSource) return new
|
|
1630
|
+
if (a.preserveAppSeqSource === "optional") o.appSeqSource = s, o.appSeqComments = xt(this.t.comments, t, e.offset, this.t.lastEndOffset), n.length === 1 && (n[0].end !== void 0 && (o.appSeqInnerEnd = n[0].end - e.offset), o.appSeqSourceFeatures = q(n[0]));
|
|
1631
|
+
else if (o instanceof L) o.ednSource === void 0 && (o.ednSource = s);
|
|
1632
|
+
else if (a.preserveAppSeqSource) return new Ye(o, s);
|
|
1609
1633
|
return o;
|
|
1610
1634
|
} catch (t) {
|
|
1611
1635
|
if (this._options.strict !== !1) throw t;
|
|
1612
|
-
return this._pendingWarnings.length === o && this._warn(t instanceof Error ? t.message : String(t), e), new
|
|
1636
|
+
return this._pendingWarnings.length === o && this._warn(t instanceof Error ? t.message : String(t), e), new Je(e.appPrefix, n);
|
|
1613
1637
|
}
|
|
1614
1638
|
}
|
|
1615
1639
|
}
|
|
1616
1640
|
case "ELLIPSIS": {
|
|
1617
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
1618
|
-
let e = [new
|
|
1641
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new K();
|
|
1642
|
+
let e = [new K()];
|
|
1619
1643
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1620
|
-
return new
|
|
1644
|
+
return new K(e, e.map(() => !0));
|
|
1621
1645
|
}
|
|
1622
1646
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1623
1647
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1624
1648
|
}
|
|
1625
1649
|
}
|
|
1626
1650
|
parseIntegerOrTag() {
|
|
1627
|
-
let e = this.t.comments.length, t = this.t.consume(), { numStr: n, rawSuffix: r } =
|
|
1651
|
+
let e = this.t.comments.length, t = this.t.consume(), { numStr: n, rawSuffix: r } = mt(t.value), i = r === void 0 ? t.endOffset : t.endOffset - 2, a = t.endOffset, o = r === void 0 ? this.consumeEncodingIndicator(void 0, (e) => {
|
|
1628
1652
|
i = e.offset, a = e.endOffset;
|
|
1629
|
-
}) : this._resolveEncodingWidth(r, t), s =
|
|
1630
|
-
if (s > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", t), new
|
|
1631
|
-
if (s < -18446744073709551616n) return new
|
|
1653
|
+
}) : this._resolveEncodingWidth(r, t), s = ht(n), c = r === void 0 ? t.raw : t.raw.slice(0, -2);
|
|
1654
|
+
if (s > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", t), new ct(s);
|
|
1655
|
+
if (s < -18446744073709551616n) return new lt(s);
|
|
1632
1656
|
if (o !== void 0) {
|
|
1633
1657
|
let e = s >= 0n ? s : -(s + 1n);
|
|
1634
1658
|
o = this._validateEncodingFit(e, o, t);
|
|
1635
1659
|
}
|
|
1636
|
-
let l = s >= 0n ? new
|
|
1660
|
+
let l = s >= 0n ? new F(s, {
|
|
1637
1661
|
encodingWidth: o,
|
|
1638
1662
|
ednSource: c
|
|
1639
|
-
}) : new
|
|
1663
|
+
}) : new I(s, {
|
|
1640
1664
|
encodingWidth: o,
|
|
1641
1665
|
ednSource: c
|
|
1642
1666
|
});
|
|
1643
1667
|
if (this.t.peek().type === "LPAREN") {
|
|
1644
|
-
l instanceof
|
|
1668
|
+
l instanceof F || this._fail("tag number must be non-negative", t), this.t.consume();
|
|
1645
1669
|
let n = this._pendingWarnings.splice(0), r = this.parseValue();
|
|
1646
1670
|
this.expect("RPAREN");
|
|
1647
1671
|
let s = l.value, u = this.extByTag.get(s);
|
|
1648
1672
|
if (u?.parseTag) {
|
|
1649
1673
|
let l = u.parseTag(s, r);
|
|
1650
1674
|
if (l !== void 0) {
|
|
1651
|
-
if (l instanceof
|
|
1652
|
-
l.appSeqSource = this.t.source.slice(t.offset, this.t.lastEndOffset), l.appSeqComments =
|
|
1653
|
-
let n = l.encodingWidth ??
|
|
1675
|
+
if (l instanceof R && (o !== void 0 && l.encodingWidth === void 0 && (l.encodingWidth = o), l.ednSource === void 0 && (l.ednSource = c), u.preserveAppSeqSource === "optional" && l.appSeqSource === void 0)) {
|
|
1676
|
+
l.appSeqSource = this.t.source.slice(t.offset, this.t.lastEndOffset), l.appSeqComments = xt(this.t.comments, e, t.offset, this.t.lastEndOffset);
|
|
1677
|
+
let n = l.encodingWidth ?? E(l.tag), o = Ct(this.t.source, t.offset, l.content);
|
|
1654
1678
|
l.appSeqEncodingEdits = [{
|
|
1655
1679
|
start: i - t.offset,
|
|
1656
1680
|
end: a - t.offset,
|
|
1657
1681
|
always: `_${n}`,
|
|
1658
1682
|
never: ""
|
|
1659
|
-
}, ...o ?? []], o === void 0 && (l.appSeqEncodingEditsComplete = !1), l.appSeqSourceFeatures =
|
|
1683
|
+
}, ...o ?? []], o === void 0 && (l.appSeqEncodingEditsComplete = !1), l.appSeqSourceFeatures = q(r);
|
|
1660
1684
|
}
|
|
1661
1685
|
return n.length > 0 && (l.warnings ??= [], l.warnings.push(...n)), l;
|
|
1662
1686
|
}
|
|
1663
1687
|
}
|
|
1664
|
-
let d = new
|
|
1688
|
+
let d = new R(s, r, {
|
|
1665
1689
|
encodingWidth: o,
|
|
1666
1690
|
ednSource: c
|
|
1667
1691
|
});
|
|
@@ -1670,12 +1694,12 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1670
1694
|
return l;
|
|
1671
1695
|
}
|
|
1672
1696
|
parseFloat() {
|
|
1673
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } =
|
|
1697
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = vt(e.value, t);
|
|
1674
1698
|
if (r === "half" || r === "single") {
|
|
1675
|
-
let e = r === "half" ?
|
|
1699
|
+
let e = r === "half" ? A(ye(n)) : Math.fround(n);
|
|
1676
1700
|
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`);
|
|
1677
1701
|
}
|
|
1678
|
-
return new
|
|
1702
|
+
return new L(n, {
|
|
1679
1703
|
precision: r,
|
|
1680
1704
|
literalSource: e.raw
|
|
1681
1705
|
});
|
|
@@ -1683,11 +1707,11 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1683
1707
|
parseString() {
|
|
1684
1708
|
let e = this.t.consume();
|
|
1685
1709
|
if (this.t.peek().type !== "PLUS") {
|
|
1686
|
-
let t = this.consumeEncodingIndicator(() => BigInt(
|
|
1687
|
-
return e.type === "RAWSTRING" ? new
|
|
1710
|
+
let t = this.consumeEncodingIndicator(() => BigInt(ut.encode(e.value).length));
|
|
1711
|
+
return e.type === "RAWSTRING" ? new Y(e.value, {
|
|
1688
1712
|
ednSource: e.raw,
|
|
1689
1713
|
...t === void 0 ? {} : { encodingWidth: t }
|
|
1690
|
-
}) : new
|
|
1714
|
+
}) : new Y(e.value, {
|
|
1691
1715
|
quotedEdnSource: e.raw,
|
|
1692
1716
|
...t === void 0 ? {} : { encodingWidth: t }
|
|
1693
1717
|
});
|
|
@@ -1729,8 +1753,8 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1729
1753
|
let e = n.map((e) => "text" in e ? e.text : ""), t = n.map((e) => "text" in e ? e.source : void 0), r = n.map((e) => "text" in e ? e.isByteString ?? !1 : !1), i = n.map((e) => ({
|
|
1730
1754
|
start: e.start,
|
|
1731
1755
|
end: e.end
|
|
1732
|
-
})), a = e.join(""), o = this.consumeEncodingIndicator(() => BigInt(
|
|
1733
|
-
return new
|
|
1756
|
+
})), a = e.join(""), o = this.consumeEncodingIndicator(() => BigInt(ut.encode(a).length));
|
|
1757
|
+
return new Y(a, {
|
|
1734
1758
|
ednParts: e,
|
|
1735
1759
|
ednPartSpans: i,
|
|
1736
1760
|
...t.some((e) => e !== void 0) ? { ednPartSources: t } : {},
|
|
@@ -1741,7 +1765,7 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1741
1765
|
let r = [], i = [], a = () => {
|
|
1742
1766
|
let e = i.map((e) => e.text), t = e.join("");
|
|
1743
1767
|
if (t !== "") {
|
|
1744
|
-
let n = i.map((e) => e.source), a = i.map((e) => e.isByteString ?? !1), o = new
|
|
1768
|
+
let n = i.map((e) => e.source), a = i.map((e) => e.isByteString ?? !1), o = new Y(t, {
|
|
1745
1769
|
ednParts: e,
|
|
1746
1770
|
ednPartSpans: i.map((e) => ({
|
|
1747
1771
|
start: e.start,
|
|
@@ -1756,24 +1780,24 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1756
1780
|
};
|
|
1757
1781
|
for (let e of n) if ("ellipsis" in e) {
|
|
1758
1782
|
a();
|
|
1759
|
-
let t = new
|
|
1783
|
+
let t = new K();
|
|
1760
1784
|
t.start = e.start, t.end = e.end, r.push(t);
|
|
1761
1785
|
} else i.push(e);
|
|
1762
|
-
return a(), new
|
|
1786
|
+
return a(), new K(r);
|
|
1763
1787
|
}
|
|
1764
1788
|
_isBytesToken(e) {
|
|
1765
1789
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
1766
1790
|
}
|
|
1767
|
-
_hexToBytes(e,
|
|
1791
|
+
_hexToBytes(e, t) {
|
|
1768
1792
|
try {
|
|
1769
|
-
return
|
|
1793
|
+
return i(e);
|
|
1770
1794
|
} catch (e) {
|
|
1771
|
-
if (e instanceof
|
|
1772
|
-
this._fail(e.message,
|
|
1795
|
+
if (e instanceof a || !(e instanceof SyntaxError)) throw e;
|
|
1796
|
+
this._fail(e.message, t);
|
|
1773
1797
|
}
|
|
1774
1798
|
}
|
|
1775
1799
|
_decodeBytesToken(e) {
|
|
1776
|
-
let
|
|
1800
|
+
let t = (t) => this._warnOrFail(t, e);
|
|
1777
1801
|
switch (e.type) {
|
|
1778
1802
|
case "SQSTR": {
|
|
1779
1803
|
let t = e._sqstrBytes;
|
|
@@ -1781,20 +1805,20 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1781
1805
|
}
|
|
1782
1806
|
case "BYTES_HEX": return this._hexToBytes(e.value, e);
|
|
1783
1807
|
case "BYTES_B64": try {
|
|
1784
|
-
return
|
|
1785
|
-
} catch (
|
|
1786
|
-
if (
|
|
1787
|
-
this._fail(
|
|
1808
|
+
return ee(e.value, t);
|
|
1809
|
+
} catch (t) {
|
|
1810
|
+
if (t instanceof a || !(t instanceof SyntaxError)) throw t;
|
|
1811
|
+
this._fail(t.message, e);
|
|
1788
1812
|
}
|
|
1789
1813
|
default: this._fail("expected byte string token", e);
|
|
1790
1814
|
}
|
|
1791
1815
|
}
|
|
1792
1816
|
_decodeUtf8(e, t) {
|
|
1793
|
-
if (this._options.allowInvalidUtf8) return
|
|
1817
|
+
if (this._options.allowInvalidUtf8) return ft.decode(e);
|
|
1794
1818
|
try {
|
|
1795
|
-
return
|
|
1819
|
+
return dt.decode(e);
|
|
1796
1820
|
} catch {
|
|
1797
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t),
|
|
1821
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), ft.decode(e);
|
|
1798
1822
|
}
|
|
1799
1823
|
}
|
|
1800
1824
|
_tokenTypeToCdnEncoding(e) {
|
|
@@ -1807,7 +1831,7 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1807
1831
|
_parseBytesConcat(e, t, n, r, i) {
|
|
1808
1832
|
if (this.t.peek().type !== "PLUS") {
|
|
1809
1833
|
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1810
|
-
return new
|
|
1834
|
+
return new z(e, {
|
|
1811
1835
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1812
1836
|
ednSource: n,
|
|
1813
1837
|
ednCommentSyntax: this._tokenTypeToCommentSyntax(t),
|
|
@@ -1843,7 +1867,7 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1843
1867
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1844
1868
|
this.t.consume();
|
|
1845
1869
|
let n = this._elidedHexAtoms(e.value, e);
|
|
1846
|
-
n.length > 0 && (n[0].real = !0), t
|
|
1870
|
+
n.length > 0 && (n[0].real = !0), m(t, n);
|
|
1847
1871
|
} else this._isBytesToken(e.type) ? (this.t.consume(), t.push({
|
|
1848
1872
|
bytes: this._decodeBytesToken(e),
|
|
1849
1873
|
source: e.raw,
|
|
@@ -1852,7 +1876,7 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1852
1876
|
start: e.offset,
|
|
1853
1877
|
end: e.endOffset
|
|
1854
1878
|
})) : 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), t.push({
|
|
1855
|
-
bytes:
|
|
1879
|
+
bytes: ut.encode(e.value),
|
|
1856
1880
|
real: !0,
|
|
1857
1881
|
start: e.offset,
|
|
1858
1882
|
end: e.endOffset
|
|
@@ -1881,7 +1905,7 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1881
1905
|
_buildFromByteAtoms(e, t) {
|
|
1882
1906
|
if (!e.some((e) => "ellipsis" in e)) {
|
|
1883
1907
|
let n = e, r = this._concatBytes(n.map((e) => e.bytes)), i = this.consumeEncodingIndicator(() => BigInt(r.length));
|
|
1884
|
-
return new
|
|
1908
|
+
return new z(r, {
|
|
1885
1909
|
ednEncoding: t,
|
|
1886
1910
|
ednParts: n,
|
|
1887
1911
|
...i === void 0 ? {} : { encodingWidth: i }
|
|
@@ -1889,7 +1913,7 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1889
1913
|
}
|
|
1890
1914
|
let n = [], r = [], i = [], a = () => {
|
|
1891
1915
|
if (i.length > 0) {
|
|
1892
|
-
let e = new
|
|
1916
|
+
let e = new z(this._concatBytes(i.map((e) => e.bytes)), { ...i.length > 1 ? { ednParts: i.map(({ bytes: e, source: t, commentSyntax: n, start: r, end: i }) => ({
|
|
1893
1917
|
bytes: e,
|
|
1894
1918
|
source: t,
|
|
1895
1919
|
commentSyntax: n,
|
|
@@ -1904,10 +1928,10 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1904
1928
|
};
|
|
1905
1929
|
for (let t of e) if ("ellipsis" in t) {
|
|
1906
1930
|
a();
|
|
1907
|
-
let e = new
|
|
1931
|
+
let e = new K(t.fromByteLiteral, t.literalSource);
|
|
1908
1932
|
e.start = t.start, e.end = t.end, n.push(e), r.push(t.real);
|
|
1909
1933
|
} else i.push(t);
|
|
1910
|
-
return a(), new
|
|
1934
|
+
return a(), new K(n, r);
|
|
1911
1935
|
}
|
|
1912
1936
|
_concatBytes(e) {
|
|
1913
1937
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -1918,16 +1942,18 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1918
1942
|
this.t.consume(), this.expect("LPAREN");
|
|
1919
1943
|
let e = this.t.peek();
|
|
1920
1944
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
1921
|
-
let { numStr: t } =
|
|
1922
|
-
return this.expect("RPAREN"), new
|
|
1945
|
+
let { numStr: t } = mt(e.value), n = Number(ht(t));
|
|
1946
|
+
return this.expect("RPAREN"), new W(n, { ednSource: e.raw });
|
|
1923
1947
|
}
|
|
1924
1948
|
parseEmbeddedCBOR() {
|
|
1925
1949
|
this.t.consume();
|
|
1926
1950
|
let e = [];
|
|
1927
1951
|
for (; this.t.peek().type !== "GT_GT";) {
|
|
1928
|
-
if (e.length > 0)
|
|
1929
|
-
if (this.t.
|
|
1930
|
-
|
|
1952
|
+
if (e.length > 0) {
|
|
1953
|
+
if (this.t.peek().type === "COMMA") {
|
|
1954
|
+
if (this.t.consume(), this.t.peek().type === "GT_GT") break;
|
|
1955
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
|
|
1956
|
+
}
|
|
1931
1957
|
e.push(this.parseValue());
|
|
1932
1958
|
}
|
|
1933
1959
|
this.expect("GT_GT");
|
|
@@ -1936,7 +1962,7 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1936
1962
|
let e = this.t.consume();
|
|
1937
1963
|
t = this._resolveEncodingWidth(e.value, e);
|
|
1938
1964
|
}
|
|
1939
|
-
return new
|
|
1965
|
+
return new G(e, { encodingWidth: t });
|
|
1940
1966
|
}
|
|
1941
1967
|
parseArray() {
|
|
1942
1968
|
this.t.consume();
|
|
@@ -1944,14 +1970,16 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1944
1970
|
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1945
1971
|
let r = this._pendingWarnings.splice(0), i = [], a = this.t.lastEndOffset;
|
|
1946
1972
|
for (; this.t.peek().type !== "RBRACKET";) {
|
|
1947
|
-
if (i.length > 0)
|
|
1948
|
-
if (this.t.
|
|
1949
|
-
|
|
1973
|
+
if (i.length > 0) {
|
|
1974
|
+
if (this.t.peek().type === "COMMA") {
|
|
1975
|
+
if (this.t.consume(), this.t.peek().type === "RBRACKET") break;
|
|
1976
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("array items must be separated by \",\" or whitespace", this.t.peek());
|
|
1977
|
+
}
|
|
1950
1978
|
let e = this.parseValue();
|
|
1951
|
-
|
|
1979
|
+
bt(this.t.source, a, e.start) && (e.blankLineBefore = !0), a = e.end, i.push(e);
|
|
1952
1980
|
}
|
|
1953
1981
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1954
|
-
let o = new
|
|
1982
|
+
let o = new H(i, {
|
|
1955
1983
|
indefiniteLength: e,
|
|
1956
1984
|
encodingWidth: t
|
|
1957
1985
|
});
|
|
@@ -1963,16 +1991,18 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1963
1991
|
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1964
1992
|
let r = this._pendingWarnings.splice(0), i = [], a = this.t.lastEndOffset;
|
|
1965
1993
|
for (; this.t.peek().type !== "RBRACE";) {
|
|
1966
|
-
if (i.length > 0)
|
|
1967
|
-
if (this.t.
|
|
1968
|
-
|
|
1994
|
+
if (i.length > 0) {
|
|
1995
|
+
if (this.t.peek().type === "COMMA") {
|
|
1996
|
+
if (this.t.consume(), this.t.peek().type === "RBRACE") break;
|
|
1997
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("map entries must be separated by \",\" or whitespace", this.t.peek());
|
|
1998
|
+
}
|
|
1969
1999
|
let e = this.parseValue();
|
|
1970
|
-
|
|
2000
|
+
bt(this.t.source, a, e.start) && (e.blankLineBefore = !0), this.expect("COLON");
|
|
1971
2001
|
let t = this.parseValue();
|
|
1972
2002
|
a = t.end, i.push([e, t]);
|
|
1973
2003
|
}
|
|
1974
2004
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1975
|
-
let o = new
|
|
2005
|
+
let o = new U(i, {
|
|
1976
2006
|
indefiniteLength: e,
|
|
1977
2007
|
encodingWidth: t
|
|
1978
2008
|
});
|
|
@@ -1989,24 +2019,26 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
1989
2019
|
} else e.type !== "RPAREN" && this._warnOrFail("indefinite string group is missing _ after (; interpreting as (_ ...)", e);
|
|
1990
2020
|
let t = this._pendingWarnings.splice(0), n = [], r = this.t.lastEndOffset;
|
|
1991
2021
|
for (; this.t.peek().type !== "RPAREN";) {
|
|
1992
|
-
if (n.length > 0)
|
|
1993
|
-
if (this.t.
|
|
1994
|
-
|
|
2022
|
+
if (n.length > 0) {
|
|
2023
|
+
if (this.t.peek().type === "COMMA") {
|
|
2024
|
+
if (this.t.consume(), this.t.peek().type === "RPAREN") break;
|
|
2025
|
+
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("indefinite string chunks must be separated by \",\" or whitespace", this.t.peek());
|
|
2026
|
+
}
|
|
1995
2027
|
let e = this.parseValue();
|
|
1996
|
-
|
|
2028
|
+
bt(this.t.source, r, e.start) && (e.blankLineBefore = !0), r = e.end, n.push(e);
|
|
1997
2029
|
}
|
|
1998
2030
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
1999
2031
|
let i = n[0];
|
|
2000
|
-
if (i instanceof
|
|
2001
|
-
let e = new
|
|
2002
|
-
if (e instanceof
|
|
2032
|
+
if (i instanceof z) {
|
|
2033
|
+
let e = new B(n.map((e, t) => {
|
|
2034
|
+
if (e instanceof z) return e;
|
|
2003
2035
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
2004
2036
|
}));
|
|
2005
2037
|
return t.length > 0 && (e.warnings = t), e;
|
|
2006
2038
|
}
|
|
2007
|
-
if (i instanceof
|
|
2008
|
-
let e = new
|
|
2009
|
-
if (e instanceof
|
|
2039
|
+
if (i instanceof Y) {
|
|
2040
|
+
let e = new V(n.map((e, t) => {
|
|
2041
|
+
if (e instanceof Y) return e;
|
|
2010
2042
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
2011
2043
|
}));
|
|
2012
2044
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -2026,47 +2058,47 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
2026
2058
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
2027
2059
|
}
|
|
2028
2060
|
_applyEiToResult(e, t, n) {
|
|
2029
|
-
if (e instanceof
|
|
2061
|
+
if (e instanceof L) {
|
|
2030
2062
|
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
2031
2063
|
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
2032
2064
|
else if (e.precision !== r) {
|
|
2033
2065
|
if (r !== "double") {
|
|
2034
|
-
let t = r === "half" ?
|
|
2066
|
+
let t = r === "half" ? A(ye(e.value)) : Math.fround(e.value);
|
|
2035
2067
|
!Object.is(t, e.value) && !isNaN(e.value) && this._warnOrFail(`${e.value} cannot be exactly represented as ${r === "half" ? "float16 (_1)" : "float32 (_2)"}`, n);
|
|
2036
2068
|
}
|
|
2037
2069
|
e.precision = r;
|
|
2038
2070
|
}
|
|
2039
|
-
} else if (e instanceof
|
|
2071
|
+
} else if (e instanceof F) {
|
|
2040
2072
|
if (e.encodingWidth === void 0) {
|
|
2041
2073
|
let r = this._validateEncodingFit(e.value, t, n);
|
|
2042
2074
|
r !== void 0 && (e.encodingWidth = r);
|
|
2043
2075
|
}
|
|
2044
|
-
} else if (e instanceof
|
|
2076
|
+
} else if (e instanceof I) {
|
|
2045
2077
|
if (e.encodingWidth === void 0) {
|
|
2046
2078
|
let r = this._validateEncodingFit(e.argument, t, n);
|
|
2047
2079
|
r !== void 0 && (e.encodingWidth = r);
|
|
2048
2080
|
}
|
|
2049
|
-
} else if (e instanceof
|
|
2081
|
+
} else if (e instanceof z) {
|
|
2050
2082
|
if (e.encodingWidth === void 0) {
|
|
2051
2083
|
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
2052
2084
|
r !== void 0 && (e.encodingWidth = r);
|
|
2053
2085
|
}
|
|
2054
|
-
} else if (e instanceof
|
|
2086
|
+
} else if (e instanceof Y) {
|
|
2055
2087
|
if (e.encodingWidth === void 0) {
|
|
2056
|
-
let r = this._validateEncodingFit(BigInt(
|
|
2088
|
+
let r = this._validateEncodingFit(BigInt(ut.encode(e.value).length), t, n);
|
|
2057
2089
|
r !== void 0 && (e.encodingWidth = r);
|
|
2058
2090
|
}
|
|
2059
|
-
} else if (e instanceof
|
|
2091
|
+
} else if (e instanceof H) {
|
|
2060
2092
|
if (e.encodingWidth === void 0) {
|
|
2061
2093
|
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
2062
2094
|
r !== void 0 && (e.encodingWidth = r);
|
|
2063
2095
|
}
|
|
2064
|
-
} else if (e instanceof
|
|
2096
|
+
} else if (e instanceof U) {
|
|
2065
2097
|
if (e.encodingWidth === void 0) {
|
|
2066
2098
|
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
2067
2099
|
r !== void 0 && (e.encodingWidth = r);
|
|
2068
2100
|
}
|
|
2069
|
-
} else if (e instanceof
|
|
2101
|
+
} else if (e instanceof R) {
|
|
2070
2102
|
if (e.encodingWidth === void 0) {
|
|
2071
2103
|
let r = this._validateEncodingFit(e.tag, t, n);
|
|
2072
2104
|
r !== void 0 && (e.encodingWidth = r);
|
|
@@ -2074,7 +2106,7 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
2074
2106
|
} else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
|
|
2075
2107
|
}
|
|
2076
2108
|
_validateEncodingFit(e, t, n) {
|
|
2077
|
-
let r =
|
|
2109
|
+
let r = Oe(t);
|
|
2078
2110
|
if (e <= r) return t;
|
|
2079
2111
|
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
2080
2112
|
this._warnOrFail(i, n);
|
|
@@ -2098,29 +2130,29 @@ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
|
|
|
2098
2130
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
2099
2131
|
}
|
|
2100
2132
|
_hintMissingExtension(e, t) {
|
|
2101
|
-
let n =
|
|
2133
|
+
let n = jt.get(e);
|
|
2102
2134
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
2103
2135
|
this._hintedPrefixes.add(e);
|
|
2104
2136
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
2105
2137
|
this._options.onWarning ? this._options.onWarning({
|
|
2106
2138
|
message: r,
|
|
2107
|
-
...
|
|
2139
|
+
...Nt(t),
|
|
2108
2140
|
hint: !0
|
|
2109
2141
|
}) : this._options.silent || console.warn(`CDN: ${r}`);
|
|
2110
2142
|
}
|
|
2111
2143
|
_warn(e, t) {
|
|
2112
2144
|
let n = { message: e };
|
|
2113
|
-
if (t !== void 0 && Object.assign(n,
|
|
2145
|
+
if (t !== void 0 && Object.assign(n, Nt(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
|
|
2114
2146
|
else if (!this._options.silent) {
|
|
2115
2147
|
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
2116
2148
|
console.warn(`CDN strict violation${n}: ${e}`);
|
|
2117
2149
|
}
|
|
2118
2150
|
}
|
|
2119
|
-
_fail(e,
|
|
2120
|
-
throw new
|
|
2151
|
+
_fail(e, t) {
|
|
2152
|
+
throw new a(e, t ? Nt(t) : void 0);
|
|
2121
2153
|
}
|
|
2122
2154
|
};
|
|
2123
|
-
function
|
|
2155
|
+
function Nt(e) {
|
|
2124
2156
|
return {
|
|
2125
2157
|
offset: e.offset,
|
|
2126
2158
|
line: e.line,
|
|
@@ -2130,7 +2162,7 @@ function Ot(e) {
|
|
|
2130
2162
|
}
|
|
2131
2163
|
//#endregion
|
|
2132
2164
|
//#region src/ast/CborTextString.ts
|
|
2133
|
-
var
|
|
2165
|
+
var Pt = new TextEncoder(), Ft = new TextDecoder(), It = !1, Y = class extends P {
|
|
2134
2166
|
indefiniteLength = !1;
|
|
2135
2167
|
value;
|
|
2136
2168
|
encodingWidth;
|
|
@@ -2143,59 +2175,66 @@ var kt = new TextEncoder(), At = !1, G = class extends O {
|
|
|
2143
2175
|
constructor(e, t) {
|
|
2144
2176
|
super(), this.value = e, this.encodingWidth = t?.encodingWidth, this.ednParts = t?.ednParts, this.ednSource = t?.ednSource, this.quotedEdnSource = t?.quotedEdnSource, this.ednPartSources = t?.ednPartSources, this.ednPartIsByteString = t?.ednPartIsByteString, this.ednPartSpans = t?.ednPartSpans;
|
|
2145
2177
|
}
|
|
2178
|
+
_isMultiWordText(e, t = !0) {
|
|
2179
|
+
return v(this.value);
|
|
2180
|
+
}
|
|
2146
2181
|
_encodeTo(e, t) {
|
|
2147
2182
|
e.writeTextString(3, this.value, this.encodingWidth);
|
|
2148
2183
|
}
|
|
2149
|
-
_toCDN(e,
|
|
2150
|
-
let
|
|
2151
|
-
return
|
|
2184
|
+
_toCDN(e, n) {
|
|
2185
|
+
let r = t(e, this.encodingWidth, () => E(BigInt(Pt.encode(this.value).length)));
|
|
2186
|
+
return Lt(this.value, r, e, n, this.ednParts, this.ednSource, this.quotedEdnSource, this.ednPartSources, this.ednPartSpans, this.comments?.dangling);
|
|
2152
2187
|
}
|
|
2153
2188
|
_toJS(e) {
|
|
2154
2189
|
return this.value;
|
|
2155
2190
|
}
|
|
2156
2191
|
};
|
|
2157
|
-
function
|
|
2158
|
-
let
|
|
2159
|
-
if (
|
|
2160
|
-
if (
|
|
2161
|
-
if (
|
|
2162
|
-
let
|
|
2163
|
-
if (!
|
|
2164
|
-
let
|
|
2165
|
-
if (
|
|
2166
|
-
let e = n
|
|
2167
|
-
for (let [t, n] of
|
|
2168
|
-
let r =
|
|
2169
|
-
if (r !== void 0)
|
|
2192
|
+
function Lt(e, t, r, i, a, o, s, c, l, d) {
|
|
2193
|
+
let f = O(r);
|
|
2194
|
+
if (r?.preserveRawString && o !== void 0 && (f !== null || !/[\r\n]/.test(o))) return o + t;
|
|
2195
|
+
if (r?.preserveTextString && s !== void 0 && (f !== null || !/[\r\n]/.test(s))) return s + t;
|
|
2196
|
+
if (f === null) return h(e) + t;
|
|
2197
|
+
let g = r?.preserveRawString ? c : void 0, _ = g?.some((e) => e !== void 0) ?? !1, { cdn: v, newline: y } = zt(r), b = r?.preserveConcatenation && a !== void 0 && (a.length > 1 || _) ? a : void 0;
|
|
2198
|
+
if (!v && !y && b === void 0) return h(e) + t;
|
|
2199
|
+
let ee = v ? Ht(e, !!r?.inlineLeafContainers, y) : null;
|
|
2200
|
+
if (b !== void 0 && (ee === null || _)) {
|
|
2201
|
+
let e = n(r) ? p(d, l, u(r)) : void 0, a = [];
|
|
2202
|
+
for (let [t, n] of b.entries()) {
|
|
2203
|
+
let r = g?.[t];
|
|
2204
|
+
if (r !== void 0) a.push({
|
|
2170
2205
|
text: n,
|
|
2171
2206
|
contentDepth: 0,
|
|
2172
2207
|
source: r
|
|
2173
2208
|
});
|
|
2174
|
-
else if (
|
|
2209
|
+
else if (y) {
|
|
2175
2210
|
let e = /* @__PURE__ */ new Map();
|
|
2176
|
-
for (let { point: t, contentDepth: r } of
|
|
2177
|
-
|
|
2178
|
-
} else
|
|
2211
|
+
for (let { point: t, contentDepth: r } of Vt(n, 0)) e.set(t, r);
|
|
2212
|
+
m(a, Zt(n, e));
|
|
2213
|
+
} else a.push({
|
|
2179
2214
|
text: n,
|
|
2180
2215
|
contentDepth: 0
|
|
2181
2216
|
});
|
|
2182
|
-
let
|
|
2183
|
-
|
|
2217
|
+
let i = e?.[t];
|
|
2218
|
+
i && i.length > 0 && (a[a.length - 1].commentsAfter = i);
|
|
2184
2219
|
}
|
|
2185
|
-
|
|
2220
|
+
if (r?.modernConcat && r?.appPrefix !== !1) {
|
|
2221
|
+
let e = a.map(({ text: e, source: t }) => t ?? h(e)), n = a.map((e) => e.commentsAfter ?? []);
|
|
2222
|
+
return ie("t1", e, t, f, i, n);
|
|
2223
|
+
}
|
|
2224
|
+
return Rt(a, t, f, i);
|
|
2186
2225
|
}
|
|
2187
|
-
let
|
|
2188
|
-
if (
|
|
2189
|
-
if (
|
|
2190
|
-
let t =
|
|
2191
|
-
for (let { point: e, contentDepth: n } of t)
|
|
2226
|
+
let x = /* @__PURE__ */ new Map();
|
|
2227
|
+
if (ee !== null) for (let { point: e, contentDepth: t } of ee) x.set(e, t);
|
|
2228
|
+
if (y) {
|
|
2229
|
+
let t = ee === null ? Vt(e, 0) : Ut(e);
|
|
2230
|
+
for (let { point: e, contentDepth: n } of t) x.has(e) || x.set(e, n);
|
|
2192
2231
|
}
|
|
2193
|
-
let
|
|
2194
|
-
return
|
|
2232
|
+
let S = Zt(e, x);
|
|
2233
|
+
return S.length <= 1 ? h(e) + t : Rt(S, t, f, i);
|
|
2195
2234
|
}
|
|
2196
|
-
function
|
|
2235
|
+
function Rt(e, t, n, r) {
|
|
2197
2236
|
let i = e.map(({ text: n, source: r }, i) => {
|
|
2198
|
-
let a = r ??
|
|
2237
|
+
let a = r ?? h(n);
|
|
2199
2238
|
return i === e.length - 1 ? a + t : a;
|
|
2200
2239
|
}), a = i[0];
|
|
2201
2240
|
for (let t = 1; t < i.length; t++) {
|
|
@@ -2206,17 +2245,17 @@ function Mt(e, t, n, r) {
|
|
|
2206
2245
|
}
|
|
2207
2246
|
return a;
|
|
2208
2247
|
}
|
|
2209
|
-
function
|
|
2210
|
-
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ?
|
|
2248
|
+
function zt(e) {
|
|
2249
|
+
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ? Bt(e?.textStringFormat ?? []) : [];
|
|
2211
2250
|
return {
|
|
2212
2251
|
cdn: e?.splitCdn ?? t.includes("cdn"),
|
|
2213
2252
|
newline: e?.splitNewline ?? t.includes("newline")
|
|
2214
2253
|
};
|
|
2215
2254
|
}
|
|
2216
|
-
function
|
|
2217
|
-
return e.map((e) => e === "cboredn" ? (
|
|
2255
|
+
function Bt(e) {
|
|
2256
|
+
return e.map((e) => e === "cboredn" ? (It || (It = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
2218
2257
|
}
|
|
2219
|
-
function
|
|
2258
|
+
function Vt(e, t) {
|
|
2220
2259
|
let n = [];
|
|
2221
2260
|
for (let r = 0; r < e.length; r++) {
|
|
2222
2261
|
let i = e[r];
|
|
@@ -2233,108 +2272,209 @@ function Ft(e, t) {
|
|
|
2233
2272
|
}
|
|
2234
2273
|
return n;
|
|
2235
2274
|
}
|
|
2236
|
-
function
|
|
2275
|
+
function Ht(t, n, r) {
|
|
2237
2276
|
try {
|
|
2238
|
-
|
|
2277
|
+
pt(t);
|
|
2239
2278
|
} catch {
|
|
2240
2279
|
return null;
|
|
2241
2280
|
}
|
|
2242
|
-
let
|
|
2281
|
+
let a = [], o = new e(t), s = 0, c = null, l = !1, u = 0, d = null, f = [], p = (e, t) => {
|
|
2282
|
+
let n = f[f.length - 1];
|
|
2283
|
+
n ? n.ownCandidates.push({
|
|
2284
|
+
point: e,
|
|
2285
|
+
contentDepth: t
|
|
2286
|
+
}) : a.push({
|
|
2287
|
+
point: e,
|
|
2288
|
+
contentDepth: t
|
|
2289
|
+
});
|
|
2290
|
+
}, m = (e) => e.kind === "LT_LT" || e.kind === "APP_SEQUENCE", h = () => {
|
|
2291
|
+
for (let e = f.length - 1; e >= 0; e--) {
|
|
2292
|
+
let t = f[e];
|
|
2293
|
+
if (!(t.kind === "LPAREN" && t.isTagParen)) return t;
|
|
2294
|
+
}
|
|
2295
|
+
}, g = (e) => {
|
|
2296
|
+
let t = (m(e) || !e.entryHasContainer) && !e.entryForcedBreak;
|
|
2297
|
+
e.allOk = e.allOk && t, e.anyForcedBreak = e.anyForcedBreak || e.entryForcedBreak, e.anyForcedBreakStructural = e.anyForcedBreakStructural || e.entryForcedBreakStructural, e.entryHasContainer = !1, e.entryForcedBreak = !1, e.entryForcedBreakStructural = !1;
|
|
2298
|
+
}, _ = "none", y = [], b = !1, x = !1, S = !1, C = !1, w = [], T = !1, te = (e) => {
|
|
2299
|
+
w.push({
|
|
2300
|
+
depth: e,
|
|
2301
|
+
kind: _,
|
|
2302
|
+
texts: y,
|
|
2303
|
+
broken: b,
|
|
2304
|
+
hasEllipsis: x,
|
|
2305
|
+
sawPlus: S,
|
|
2306
|
+
awaitingTagCheck: C
|
|
2307
|
+
}), _ = "none", y = [], b = !1, x = !1, S = !1, C = !1, T = !0;
|
|
2308
|
+
}, E = () => {
|
|
2309
|
+
let e = w[w.length - 1];
|
|
2310
|
+
e !== void 0 && s === e.depth && (w.pop(), _ = e.kind, y = e.texts, b = e.broken, x = e.hasEllipsis, S = e.sawPlus, C = e.awaitingTagCheck);
|
|
2311
|
+
}, ne = () => {
|
|
2312
|
+
if (x && S) for (let e of f) e.entryHasContainer = !0;
|
|
2313
|
+
if (_ === "text" && !b && y.length > 0 && v(y.join(""))) {
|
|
2314
|
+
let e = f[f.length - 1];
|
|
2315
|
+
e && (e.entryForcedBreak = !0);
|
|
2316
|
+
}
|
|
2317
|
+
_ = "none", y = [], b = !1, x = !1, S = !1, C = !1;
|
|
2318
|
+
};
|
|
2243
2319
|
for (;;) {
|
|
2244
|
-
let
|
|
2245
|
-
if (
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2320
|
+
let e = o.consume();
|
|
2321
|
+
if (e.type === "EOF") {
|
|
2322
|
+
ne();
|
|
2323
|
+
break;
|
|
2324
|
+
}
|
|
2325
|
+
let v = !1, w = !1;
|
|
2326
|
+
if (C && (e.type === "ENCODING_INDICATOR" ? w = !0 : e.type === "LPAREN" ? (C = !1, te(s), w = !0) : C = !1), !w) {
|
|
2327
|
+
let t = e.type === "PLUS" || e.type === "ENCODING_INDICATOR" || d === "PLUS" && (Jt.has(e.type) || e.type === "ELLIPSIS");
|
|
2328
|
+
_ !== "none" && !t && (d === "PLUS" && x ? Kt.has(e.type) ? te(s) : e.type === "INTEGER" && (C = !0) : ne()), e.type === "PLUS" && _ !== "none" && (S = !0);
|
|
2329
|
+
}
|
|
2330
|
+
if (l || (l = !0, e.offset > 0 && Yt(o.comments, 0, e.offset) && p(e.offset, s)), c !== null) {
|
|
2331
|
+
if (c.kind === "opener" && Gt.has(e.type)) {
|
|
2332
|
+
c.point = e.endOffset, d = e.type, u = e.endOffset;
|
|
2253
2333
|
continue;
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2334
|
+
}
|
|
2335
|
+
c.kind === "opener" && qt.has(e.type) && Xt(t, c.point, e.offset) ? v = !0 : p(e.offset, c.contentDepth), c = null;
|
|
2336
|
+
}
|
|
2337
|
+
if (Kt.has(e.type)) {
|
|
2338
|
+
if (e.type === "LBRACKET" || e.type === "LBRACE") for (let e of f) e.entryHasContainer = !0;
|
|
2339
|
+
s++, c = {
|
|
2340
|
+
point: e.endOffset,
|
|
2341
|
+
contentDepth: s,
|
|
2342
|
+
kind: "opener"
|
|
2343
|
+
}, f.push({
|
|
2344
|
+
kind: e.type,
|
|
2345
|
+
isTagParen: e.type === "LPAREN" && d === "INTEGER",
|
|
2346
|
+
isChainContinuationRoot: T,
|
|
2347
|
+
openOffset: e.offset,
|
|
2348
|
+
ownCandidates: [],
|
|
2349
|
+
childCandidates: [],
|
|
2350
|
+
entryHasContainer: !1,
|
|
2351
|
+
entryForcedBreak: !1,
|
|
2352
|
+
anyForcedBreak: !1,
|
|
2353
|
+
entryForcedBreakStructural: !1,
|
|
2354
|
+
anyForcedBreakStructural: !1,
|
|
2355
|
+
allOk: !0
|
|
2356
|
+
}), T = !1;
|
|
2357
|
+
} else if (qt.has(e.type)) {
|
|
2358
|
+
s = Math.max(0, s - 1), E(), v || p(e.offset, s);
|
|
2359
|
+
let t = f.pop();
|
|
2360
|
+
if (t) {
|
|
2361
|
+
g(t);
|
|
2362
|
+
let r = t.kind === "LPAREN" && t.isTagParen, i = (m(t) || n && (t.kind === "LBRACKET" || t.kind === "LBRACE" || t.kind === "LPAREN")) && t.ownCandidates.length > 0 && (r || t.allOk) && !Yt(o.comments, t.openOffset, e.endOffset) ? t.childCandidates : [...t.ownCandidates, ...t.childCandidates], s = f[f.length - 1];
|
|
2363
|
+
if (s) {
|
|
2364
|
+
for (let e of i) s.childCandidates.push(e);
|
|
2365
|
+
let e = i.length > 0 || t.anyForcedBreakStructural;
|
|
2366
|
+
(t.isChainContinuationRoot && t.isTagParen ? e : i.length > 0 || t.anyForcedBreak) && (s.entryForcedBreak = !0), e && (s.entryForcedBreakStructural = !0);
|
|
2367
|
+
} else for (let e of i) a.push(e);
|
|
2368
|
+
}
|
|
2369
|
+
} else if (e.type === "COMMA") {
|
|
2370
|
+
let t = f[f.length - 1];
|
|
2371
|
+
t && g(t), c = {
|
|
2372
|
+
point: e.endOffset,
|
|
2373
|
+
contentDepth: s,
|
|
2374
|
+
kind: "comma"
|
|
2375
|
+
};
|
|
2376
|
+
} else if (e.type === "TSTR" || e.type === "RAWSTRING") {
|
|
2377
|
+
let n = t.slice(e.offset, e.endOffset);
|
|
2378
|
+
if (r && (e.type === "TSTR" ? Wt(n).length > 0 : Vt(n, 0).length > 0)) {
|
|
2379
|
+
let e = f[f.length - 1];
|
|
2380
|
+
e && (e.entryForcedBreak = !0, e.entryForcedBreakStructural = !0);
|
|
2381
|
+
}
|
|
2382
|
+
d === "PLUS" && _ === "text" ? y.push(e.value) : (_ = "text", y = [e.value], b = !1);
|
|
2383
|
+
} else if (e.type === "SQSTR") {
|
|
2384
|
+
if (d !== "PLUS" || _ !== "byte") {
|
|
2385
|
+
let t = e._sqstrBytes, n = t ? Ft.decode(t) : null;
|
|
2386
|
+
d === "PLUS" && _ === "text" ? n === null ? b = !0 : y.push(n) : (_ = "text", y = n === null ? [] : [n], b = n === null);
|
|
2387
|
+
}
|
|
2388
|
+
} else if (e.type === "BYTES_HEX" || e.type === "BYTES_HEX_ELIDED" || e.type === "BYTES_B64" || e.type === "APP_STRING") {
|
|
2389
|
+
if (d === "PLUS" && _ === "text") {
|
|
2390
|
+
let t = null;
|
|
2391
|
+
try {
|
|
2392
|
+
e.type === "BYTES_HEX" ? t = Ft.decode(i(e.value)) : e.type === "BYTES_B64" && (t = Ft.decode(ee(e.value)));
|
|
2393
|
+
} catch {
|
|
2394
|
+
t = null;
|
|
2395
|
+
}
|
|
2396
|
+
t === null ? b = !0 : y.push(t);
|
|
2397
|
+
} else {
|
|
2398
|
+
let e = f[f.length - 1], t = h();
|
|
2399
|
+
e && (!t || !m(t)) && (e.entryForcedBreak = !0), (d !== "PLUS" || _ === "none") && (_ = "byte");
|
|
2400
|
+
}
|
|
2401
|
+
} else e.type === "ELLIPSIS" && (x = !0, d === "PLUS" && _ === "text" ? b = !0 : (d !== "PLUS" || _ === "none") && (_ = "text", y = [], b = !0));
|
|
2402
|
+
d = e.type, u = e.endOffset;
|
|
2403
|
+
}
|
|
2404
|
+
let D = o.comments.find((e) => e.start >= u);
|
|
2405
|
+
return D !== void 0 && a.push({
|
|
2406
|
+
point: D.start,
|
|
2407
|
+
contentDepth: s
|
|
2408
|
+
}), a;
|
|
2409
|
+
}
|
|
2410
|
+
function Ut(t) {
|
|
2411
|
+
let n = [], r = new e(t), i = 0;
|
|
2281
2412
|
for (;;) {
|
|
2282
|
-
let
|
|
2283
|
-
if (
|
|
2284
|
-
if (
|
|
2285
|
-
else if (
|
|
2286
|
-
else if (
|
|
2287
|
-
if (
|
|
2288
|
-
let
|
|
2289
|
-
for (let
|
|
2290
|
-
point:
|
|
2291
|
-
contentDepth:
|
|
2413
|
+
let e = r.consume();
|
|
2414
|
+
if (e.type === "EOF") break;
|
|
2415
|
+
if (Kt.has(e.type)) i++;
|
|
2416
|
+
else if (qt.has(e.type)) i = Math.max(0, i - 1);
|
|
2417
|
+
else if (e.type !== "COMMA") {
|
|
2418
|
+
if (e.type === "TSTR") {
|
|
2419
|
+
let r = t.slice(e.offset, e.endOffset);
|
|
2420
|
+
for (let t of Wt(r)) n.push({
|
|
2421
|
+
point: e.offset + t,
|
|
2422
|
+
contentDepth: i + 1
|
|
2292
2423
|
});
|
|
2293
|
-
} else if (
|
|
2294
|
-
let
|
|
2295
|
-
for (let { point:
|
|
2296
|
-
point:
|
|
2297
|
-
contentDepth:
|
|
2424
|
+
} else if (e.type === "RAWSTRING") {
|
|
2425
|
+
let r = t.slice(e.offset, e.endOffset);
|
|
2426
|
+
for (let { point: t } of Vt(r, 0)) n.push({
|
|
2427
|
+
point: e.offset + t,
|
|
2428
|
+
contentDepth: i + 1
|
|
2298
2429
|
});
|
|
2299
2430
|
}
|
|
2300
2431
|
}
|
|
2301
2432
|
}
|
|
2302
|
-
return
|
|
2433
|
+
return n;
|
|
2303
2434
|
}
|
|
2304
|
-
function
|
|
2435
|
+
function Wt(e) {
|
|
2305
2436
|
let t = [], n = 1, r = e.length - 1;
|
|
2306
2437
|
for (; n < r;) {
|
|
2307
2438
|
let r = e[n];
|
|
2308
2439
|
if (r === "\\") {
|
|
2309
2440
|
let r = e[n + 1];
|
|
2310
2441
|
if (r === "n" || r === "r") t.push(n + 2), n += 2;
|
|
2311
|
-
else if (r === "u")
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2442
|
+
else if (r === "u") {
|
|
2443
|
+
if (e[n + 2] === "{") {
|
|
2444
|
+
let t = e.indexOf("}", n + 3);
|
|
2445
|
+
n = t >= 0 ? t + 1 : n + 2;
|
|
2446
|
+
} else n += 6;
|
|
2447
|
+
} else n += 2;
|
|
2316
2448
|
} else r === "\r" ? e[n + 1] === "\n" ? (t.push(n + 2), n += 2) : (t.push(n + 1), n++) : (r === "\n" && t.push(n + 1), n++);
|
|
2317
2449
|
}
|
|
2318
2450
|
return t;
|
|
2319
2451
|
}
|
|
2320
|
-
var
|
|
2452
|
+
var Gt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Kt = /* @__PURE__ */ new Set([
|
|
2321
2453
|
"LBRACKET",
|
|
2322
2454
|
"LBRACE",
|
|
2323
2455
|
"LPAREN",
|
|
2324
|
-
"LT_LT"
|
|
2325
|
-
|
|
2456
|
+
"LT_LT",
|
|
2457
|
+
"APP_SEQUENCE"
|
|
2458
|
+
]), qt = /* @__PURE__ */ new Set([
|
|
2326
2459
|
"RBRACKET",
|
|
2327
2460
|
"RBRACE",
|
|
2328
2461
|
"RPAREN",
|
|
2329
2462
|
"GT_GT"
|
|
2463
|
+
]), Jt = /* @__PURE__ */ new Set([
|
|
2464
|
+
"TSTR",
|
|
2465
|
+
"RAWSTRING",
|
|
2466
|
+
"SQSTR",
|
|
2467
|
+
"BYTES_HEX",
|
|
2468
|
+
"BYTES_HEX_ELIDED",
|
|
2469
|
+
"BYTES_B64"
|
|
2330
2470
|
]);
|
|
2331
|
-
function
|
|
2471
|
+
function Yt(e, t, n) {
|
|
2332
2472
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
2333
2473
|
}
|
|
2334
|
-
function
|
|
2474
|
+
function Xt(e, t, n) {
|
|
2335
2475
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
2336
2476
|
}
|
|
2337
|
-
function
|
|
2477
|
+
function Zt(e, t) {
|
|
2338
2478
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
2339
2479
|
if (n.length === 0) return [{
|
|
2340
2480
|
text: e,
|
|
@@ -2352,7 +2492,7 @@ function Wt(e, t) {
|
|
|
2352
2492
|
}
|
|
2353
2493
|
//#endregion
|
|
2354
2494
|
//#region src/extensions/dt.ts
|
|
2355
|
-
function
|
|
2495
|
+
function Qt(e) {
|
|
2356
2496
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
2357
2497
|
let t = Math.round(e * 1e3);
|
|
2358
2498
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -2360,17 +2500,17 @@ function Gt(e) {
|
|
|
2360
2500
|
for (; s.length < 3;) s += "0";
|
|
2361
2501
|
return `${i}.${s}Z`;
|
|
2362
2502
|
}
|
|
2363
|
-
var
|
|
2364
|
-
function
|
|
2503
|
+
var $t = new TextDecoder("utf-8", { fatal: !0 });
|
|
2504
|
+
function en(e) {
|
|
2365
2505
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
2366
2506
|
let t = e[0];
|
|
2367
|
-
if (t instanceof
|
|
2368
|
-
if (t instanceof
|
|
2507
|
+
if (t instanceof Y) return t.value;
|
|
2508
|
+
if (t instanceof z) return $t.decode(t.value);
|
|
2369
2509
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
2370
2510
|
}
|
|
2371
|
-
var
|
|
2372
|
-
function
|
|
2373
|
-
if (!
|
|
2511
|
+
var tn = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
2512
|
+
function nn(e, t) {
|
|
2513
|
+
if (!tn.test(e)) {
|
|
2374
2514
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
2375
2515
|
if (t) t(n);
|
|
2376
2516
|
else throw SyntaxError(n);
|
|
@@ -2381,110 +2521,110 @@ function Yt(e, t) {
|
|
|
2381
2521
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
2382
2522
|
if (i === void 0) {
|
|
2383
2523
|
let e = a / 1e3;
|
|
2384
|
-
return e >= 0 ? new
|
|
2524
|
+
return e >= 0 ? new an(BigInt(e)) : new on(BigInt(e));
|
|
2385
2525
|
}
|
|
2386
|
-
return new
|
|
2526
|
+
return new sn(a / 1e3 + i);
|
|
2387
2527
|
}
|
|
2388
|
-
var
|
|
2528
|
+
var rn = 1n, an = class extends F {
|
|
2389
2529
|
constructor(e, t) {
|
|
2390
2530
|
super(e, t);
|
|
2391
2531
|
}
|
|
2392
|
-
_toCDN(e,
|
|
2393
|
-
if (e?.
|
|
2394
|
-
let
|
|
2395
|
-
return
|
|
2532
|
+
_toCDN(e, n) {
|
|
2533
|
+
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2534
|
+
let r = t(e, this.encodingWidth, () => E(this.value));
|
|
2535
|
+
return T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Qt(Number(this.value))}'${r}`;
|
|
2396
2536
|
}
|
|
2397
|
-
},
|
|
2537
|
+
}, on = class extends I {
|
|
2398
2538
|
constructor(e, t) {
|
|
2399
2539
|
super(e, t);
|
|
2400
2540
|
}
|
|
2401
|
-
_toCDN(e,
|
|
2402
|
-
if (e?.
|
|
2403
|
-
let
|
|
2404
|
-
return
|
|
2541
|
+
_toCDN(e, n) {
|
|
2542
|
+
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2543
|
+
let r = t(e, this.encodingWidth, () => E(this.argument));
|
|
2544
|
+
return T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Qt(Number(this.value))}'${r}`;
|
|
2405
2545
|
}
|
|
2406
|
-
},
|
|
2546
|
+
}, sn = class extends L {
|
|
2407
2547
|
constructor(e, t) {
|
|
2408
2548
|
super(e, t);
|
|
2409
2549
|
}
|
|
2410
2550
|
_toCDN(e, t) {
|
|
2411
|
-
if (e?.
|
|
2412
|
-
let n =
|
|
2413
|
-
return
|
|
2551
|
+
if (e?.appPrefix === !1) return super._toCDN(e, t);
|
|
2552
|
+
let n = N(this.value), r = S(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
2553
|
+
return T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Qt(this.value)}'${r}`;
|
|
2414
2554
|
}
|
|
2415
|
-
},
|
|
2555
|
+
}, cn = class extends R {
|
|
2416
2556
|
constructor(e, t) {
|
|
2417
|
-
super(
|
|
2418
|
-
}
|
|
2419
|
-
_toCDN(e,
|
|
2420
|
-
if (e?.
|
|
2421
|
-
let
|
|
2422
|
-
if (
|
|
2423
|
-
if (
|
|
2424
|
-
if (
|
|
2557
|
+
super(rn, typeof e == "string" ? nn(e) : e, t);
|
|
2558
|
+
}
|
|
2559
|
+
_toCDN(e, n) {
|
|
2560
|
+
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2561
|
+
let r = T(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
|
|
2562
|
+
if (r === "verbatim") return this.appSeqSource;
|
|
2563
|
+
if (r === "source") return w(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
|
|
2564
|
+
if (r === "structural") return super._toCDN({
|
|
2425
2565
|
...e,
|
|
2426
|
-
|
|
2427
|
-
},
|
|
2428
|
-
let
|
|
2429
|
-
if (
|
|
2430
|
-
let
|
|
2431
|
-
return (
|
|
2566
|
+
appPrefix: !1
|
|
2567
|
+
}, n);
|
|
2568
|
+
let i = t(e, this.encodingWidth, () => E(rn));
|
|
2569
|
+
if (r === "adjusted") return D(this.appSeqSource, i, e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2570
|
+
let a = this.content;
|
|
2571
|
+
return (a instanceof L ? a.precision !== void 0 && a.precision !== N(a.value) : a.encodingWidth !== void 0) ? super._toCDN({
|
|
2432
2572
|
...e,
|
|
2433
|
-
|
|
2434
|
-
},
|
|
2573
|
+
appPrefix: !1
|
|
2574
|
+
}, n) : `DT'${Qt(a instanceof L ? a.value : Number(a.value))}'${i}`;
|
|
2435
2575
|
}
|
|
2436
|
-
},
|
|
2576
|
+
}, ln = class extends cn {
|
|
2437
2577
|
constructor(e, t) {
|
|
2438
2578
|
super(e, t);
|
|
2439
2579
|
}
|
|
2440
2580
|
_toJS(e) {
|
|
2441
|
-
let t = this.content, n = t instanceof
|
|
2581
|
+
let t = this.content, n = t instanceof L ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
2442
2582
|
return new Date(n);
|
|
2443
2583
|
}
|
|
2444
2584
|
};
|
|
2445
|
-
function
|
|
2585
|
+
function un(e) {
|
|
2446
2586
|
let t = e?.jsDate ?? !1;
|
|
2447
2587
|
function n(e) {
|
|
2448
|
-
return t ? new
|
|
2588
|
+
return t ? new ln(e) : new cn(e);
|
|
2449
2589
|
}
|
|
2450
2590
|
let r = {
|
|
2451
2591
|
appStringPrefixes: ["dt", "DT"],
|
|
2452
|
-
tagNumbers: [
|
|
2592
|
+
tagNumbers: [rn],
|
|
2453
2593
|
preserveAppSeqSource: "optional",
|
|
2454
2594
|
parseAppString(e, t, r) {
|
|
2455
|
-
return e === "DT" ? n(t) :
|
|
2595
|
+
return e === "DT" ? n(t) : nn(t, r);
|
|
2456
2596
|
},
|
|
2457
2597
|
parseAppSequence(e, t, r) {
|
|
2458
|
-
let i =
|
|
2459
|
-
return e === "DT" ? n(i) :
|
|
2598
|
+
let i = en(t);
|
|
2599
|
+
return e === "DT" ? n(i) : nn(i, r);
|
|
2460
2600
|
},
|
|
2461
2601
|
parseTag(e, n) {
|
|
2462
2602
|
if (e !== 1n) return;
|
|
2463
2603
|
let r;
|
|
2464
|
-
if (n instanceof
|
|
2604
|
+
if (n instanceof F) r = new an(n.value, {
|
|
2465
2605
|
encodingWidth: n.encodingWidth,
|
|
2466
2606
|
ednSource: n.ednSource
|
|
2467
2607
|
});
|
|
2468
|
-
else if (n instanceof
|
|
2608
|
+
else if (n instanceof I) r = new on(n.value, {
|
|
2469
2609
|
encodingWidth: n.encodingWidth,
|
|
2470
2610
|
ednSource: n.ednSource
|
|
2471
2611
|
});
|
|
2472
|
-
else if (n instanceof
|
|
2612
|
+
else if (n instanceof L) r = new sn(n.value, {
|
|
2473
2613
|
precision: n.precision,
|
|
2474
2614
|
literalSource: n.literalSource
|
|
2475
2615
|
});
|
|
2476
2616
|
else return;
|
|
2477
|
-
return r.start = n.start, r.end = n.end, t ? new
|
|
2617
|
+
return r.start = n.start, r.end = n.end, t ? new ln(r) : new cn(r);
|
|
2478
2618
|
}
|
|
2479
2619
|
};
|
|
2480
2620
|
return t && (r.fromJS = (e, t) => {
|
|
2481
|
-
if (e instanceof Date) return new
|
|
2621
|
+
if (e instanceof Date) return new ln(Qt(e.getTime() / 1e3));
|
|
2482
2622
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2483
2623
|
}
|
|
2484
|
-
var
|
|
2624
|
+
var dn = un(), fn = un({ jsDate: !0 });
|
|
2485
2625
|
//#endregion
|
|
2486
2626
|
//#region src/utils/ip.ts
|
|
2487
|
-
function
|
|
2627
|
+
function pn(e) {
|
|
2488
2628
|
let t = e.split(".");
|
|
2489
2629
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2490
2630
|
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
@@ -2497,11 +2637,11 @@ function on(e) {
|
|
|
2497
2637
|
}
|
|
2498
2638
|
return n;
|
|
2499
2639
|
}
|
|
2500
|
-
function
|
|
2640
|
+
function mn(e) {
|
|
2501
2641
|
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
2502
2642
|
if (e === "::") return t;
|
|
2503
2643
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
2504
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
2644
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = pn(i[2]));
|
|
2505
2645
|
let a = n.split("::");
|
|
2506
2646
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2507
2647
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -2518,11 +2658,11 @@ function sn(e) {
|
|
|
2518
2658
|
}
|
|
2519
2659
|
return r && t.set(r, 12), t;
|
|
2520
2660
|
}
|
|
2521
|
-
function
|
|
2661
|
+
function hn(e) {
|
|
2522
2662
|
return Array.from(e).join(".");
|
|
2523
2663
|
}
|
|
2524
|
-
function
|
|
2525
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2664
|
+
function gn(e) {
|
|
2665
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? hn(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
2526
2666
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2527
2667
|
let i = -1, a = 0, o = 0;
|
|
2528
2668
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2536,29 +2676,29 @@ function ln(e) {
|
|
|
2536
2676
|
}
|
|
2537
2677
|
//#endregion
|
|
2538
2678
|
//#region src/extensions/ip.ts
|
|
2539
|
-
var
|
|
2540
|
-
function
|
|
2679
|
+
var _n = "ip", vn = "IP", yn = 52n, bn = 54n, xn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2680
|
+
function Sn(e) {
|
|
2541
2681
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2542
2682
|
let t = e[0];
|
|
2543
|
-
if (t instanceof
|
|
2544
|
-
if (t instanceof
|
|
2683
|
+
if (t instanceof Y) return t.value;
|
|
2684
|
+
if (t instanceof z) return xn.decode(t.value);
|
|
2545
2685
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2546
2686
|
}
|
|
2547
|
-
function
|
|
2687
|
+
function Cn(e) {
|
|
2548
2688
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2549
|
-
bytes:
|
|
2689
|
+
bytes: pn(e),
|
|
2550
2690
|
isV4: !0
|
|
2551
2691
|
} : {
|
|
2552
|
-
bytes:
|
|
2692
|
+
bytes: mn(e),
|
|
2553
2693
|
isV4: !1
|
|
2554
2694
|
};
|
|
2555
2695
|
}
|
|
2556
|
-
function
|
|
2557
|
-
if (e.length === 4) return
|
|
2558
|
-
if (e.length === 16) return
|
|
2696
|
+
function wn(e) {
|
|
2697
|
+
if (e.length === 4) return hn(e);
|
|
2698
|
+
if (e.length === 16) return gn(e);
|
|
2559
2699
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2560
2700
|
}
|
|
2561
|
-
function
|
|
2701
|
+
function Tn(e, t) {
|
|
2562
2702
|
let n = new Uint8Array(e.length);
|
|
2563
2703
|
n.set(e);
|
|
2564
2704
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2568,82 +2708,82 @@ function vn(e, t) {
|
|
|
2568
2708
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2569
2709
|
return n.slice(0, a);
|
|
2570
2710
|
}
|
|
2571
|
-
function
|
|
2711
|
+
function En(e, t) {
|
|
2572
2712
|
let n = new Uint8Array(t);
|
|
2573
2713
|
return n.set(e), n;
|
|
2574
2714
|
}
|
|
2575
|
-
var
|
|
2576
|
-
_toCDN(e,
|
|
2577
|
-
if (e?.
|
|
2578
|
-
let
|
|
2579
|
-
return
|
|
2715
|
+
var Dn = class extends z {
|
|
2716
|
+
_toCDN(e, n) {
|
|
2717
|
+
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2718
|
+
let r = t(e, this.encodingWidth, () => E(BigInt(this.value.length)));
|
|
2719
|
+
return T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `${_n}'${wn(this.value)}'${r}`;
|
|
2580
2720
|
}
|
|
2581
|
-
},
|
|
2721
|
+
}, On = class extends H {
|
|
2582
2722
|
_isV4;
|
|
2583
2723
|
constructor(e, t, n) {
|
|
2584
|
-
super([new
|
|
2724
|
+
super([new F(BigInt(e)), new z(t)]), this._isV4 = n;
|
|
2585
2725
|
}
|
|
2586
2726
|
_toCDN(e, t) {
|
|
2587
|
-
if (e?.
|
|
2588
|
-
if (
|
|
2727
|
+
if (e?.appPrefix === !1) return super._toCDN(e, t);
|
|
2728
|
+
if (T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted") return D(this.appSeqSource, "", e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2589
2729
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2590
|
-
return `${
|
|
2730
|
+
return `${_n}'${wn(En(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2591
2731
|
}
|
|
2592
|
-
},
|
|
2732
|
+
}, kn = class extends R {
|
|
2593
2733
|
constructor(e, t) {
|
|
2594
2734
|
super(e, t);
|
|
2595
2735
|
}
|
|
2596
|
-
_toCDN(e,
|
|
2597
|
-
if (e?.
|
|
2598
|
-
let
|
|
2599
|
-
if (
|
|
2600
|
-
if (
|
|
2601
|
-
if (
|
|
2602
|
-
if (
|
|
2603
|
-
let
|
|
2604
|
-
return
|
|
2605
|
-
}
|
|
2606
|
-
let
|
|
2607
|
-
if (
|
|
2608
|
-
if (
|
|
2609
|
-
let
|
|
2610
|
-
return `${
|
|
2611
|
-
}
|
|
2612
|
-
if (
|
|
2613
|
-
if (
|
|
2614
|
-
let
|
|
2615
|
-
return `${
|
|
2616
|
-
}
|
|
2617
|
-
return super._toCDN(e,
|
|
2736
|
+
_toCDN(e, n) {
|
|
2737
|
+
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2738
|
+
let r = T(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
|
|
2739
|
+
if (r === "verbatim") return this.appSeqSource;
|
|
2740
|
+
if (r === "source") return w(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
|
|
2741
|
+
if (r === "structural") return super._toCDN(e, n);
|
|
2742
|
+
if (r === "adjusted") {
|
|
2743
|
+
let n = t(e, this.encodingWidth, () => E(this.tag));
|
|
2744
|
+
return D(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2745
|
+
}
|
|
2746
|
+
let i = this.tag === yn ? 4 : 16, a = this.content;
|
|
2747
|
+
if (a instanceof z) {
|
|
2748
|
+
if (a.encodingWidth !== void 0) return super._toCDN(e, n);
|
|
2749
|
+
let r = t(e, this.encodingWidth, () => E(this.tag));
|
|
2750
|
+
return `${vn}'${wn(a.value)}'${r}`;
|
|
2751
|
+
}
|
|
2752
|
+
if (a instanceof H && a.items.length === 2 && a.items[0] instanceof F && a.items[1] instanceof z) {
|
|
2753
|
+
if (a.encodingWidth !== void 0 || a.items[0].encodingWidth !== void 0 || a.items[1].encodingWidth !== void 0) return super._toCDN(e, n);
|
|
2754
|
+
let r = Number(a.items[0].value), o = En(a.items[1].value, i), s = t(e, this.encodingWidth, () => E(this.tag));
|
|
2755
|
+
return `${vn}'${wn(o)}/${r}'${s}`;
|
|
2756
|
+
}
|
|
2757
|
+
return super._toCDN(e, n);
|
|
2618
2758
|
}
|
|
2619
2759
|
};
|
|
2620
|
-
function
|
|
2760
|
+
function An(e, t) {
|
|
2621
2761
|
let n = t.indexOf("/");
|
|
2622
2762
|
if (n === -1) {
|
|
2623
|
-
let { bytes: n, isV4: r } =
|
|
2624
|
-
return e ===
|
|
2763
|
+
let { bytes: n, isV4: r } = Cn(t);
|
|
2764
|
+
return e === vn ? new kn(r ? yn : bn, new z(n)) : new Dn(n);
|
|
2625
2765
|
}
|
|
2626
2766
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2627
2767
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2628
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2768
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = Cn(r), c = s ? 32 : 128;
|
|
2629
2769
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2630
|
-
let l =
|
|
2631
|
-
return e ===
|
|
2770
|
+
let l = Tn(o, a);
|
|
2771
|
+
return e === vn ? new kn(s ? yn : bn, new H([new F(BigInt(a)), new z(l)])) : new On(a, l, s);
|
|
2632
2772
|
}
|
|
2633
|
-
var
|
|
2634
|
-
appStringPrefixes: [
|
|
2635
|
-
tagNumbers: [
|
|
2773
|
+
var jn = {
|
|
2774
|
+
appStringPrefixes: [_n, vn],
|
|
2775
|
+
tagNumbers: [yn, bn],
|
|
2636
2776
|
preserveAppSeqSource: "optional",
|
|
2637
2777
|
parseAppString(e, t) {
|
|
2638
|
-
return
|
|
2778
|
+
return An(e, t);
|
|
2639
2779
|
},
|
|
2640
2780
|
parseAppSequence(e, t) {
|
|
2641
|
-
return
|
|
2781
|
+
return An(e, Sn(t));
|
|
2642
2782
|
},
|
|
2643
2783
|
parseTag(e, t) {
|
|
2644
|
-
if (
|
|
2784
|
+
if ((e === yn || e === bn) && (t instanceof z || t instanceof H)) return new kn(e, t);
|
|
2645
2785
|
}
|
|
2646
|
-
},
|
|
2786
|
+
}, Mn = "cri", Nn = "CRI", Pn = 99n, Fn = /* @__PURE__ */ new Map([
|
|
2647
2787
|
["coap", -1n],
|
|
2648
2788
|
["coaps", -2n],
|
|
2649
2789
|
["http", -3n],
|
|
@@ -2654,47 +2794,47 @@ var wn = {
|
|
|
2654
2794
|
["coaps+tcp", -8n],
|
|
2655
2795
|
["coap+ws", -25n],
|
|
2656
2796
|
["coaps+ws", -26n]
|
|
2657
|
-
]),
|
|
2658
|
-
function
|
|
2797
|
+
]), In = new Map([...Fn.entries()].map(([e, t]) => [t, e]));
|
|
2798
|
+
function X(e) {
|
|
2659
2799
|
try {
|
|
2660
2800
|
return decodeURIComponent(e);
|
|
2661
2801
|
} catch {
|
|
2662
2802
|
return e;
|
|
2663
2803
|
}
|
|
2664
2804
|
}
|
|
2665
|
-
var
|
|
2666
|
-
function
|
|
2667
|
-
return Array.from(
|
|
2805
|
+
var Ln = new TextEncoder(), Rn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2806
|
+
function zn(e) {
|
|
2807
|
+
return Array.from(Ln.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2668
2808
|
}
|
|
2669
|
-
function
|
|
2809
|
+
function Bn(e, t) {
|
|
2670
2810
|
let n = "";
|
|
2671
|
-
for (let r of e) n += t(r) ? r :
|
|
2811
|
+
for (let r of e) n += t(r) ? r : zn(r);
|
|
2672
2812
|
return n;
|
|
2673
2813
|
}
|
|
2674
|
-
function
|
|
2814
|
+
function Vn(e) {
|
|
2675
2815
|
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2676
2816
|
}
|
|
2677
|
-
function
|
|
2817
|
+
function Hn(e) {
|
|
2678
2818
|
return /[!$&'()*+,;=]/.test(e);
|
|
2679
2819
|
}
|
|
2680
|
-
function
|
|
2681
|
-
return
|
|
2820
|
+
function Un(e) {
|
|
2821
|
+
return Vn(e) || Hn(e) || e === ":" || e === "@";
|
|
2682
2822
|
}
|
|
2683
|
-
function
|
|
2684
|
-
return (
|
|
2823
|
+
function Wn(e) {
|
|
2824
|
+
return (Un(e) || e === "/" || e === "?") && e !== "&";
|
|
2685
2825
|
}
|
|
2686
|
-
function
|
|
2687
|
-
return
|
|
2826
|
+
function Gn(e) {
|
|
2827
|
+
return Un(e) || e === "/" || e === "?";
|
|
2688
2828
|
}
|
|
2689
|
-
function
|
|
2690
|
-
return
|
|
2829
|
+
function Kn(e) {
|
|
2830
|
+
return Vn(e) || Hn(e) || e === ":";
|
|
2691
2831
|
}
|
|
2692
|
-
function
|
|
2693
|
-
return
|
|
2832
|
+
function qn(e) {
|
|
2833
|
+
return Vn(e) || Hn(e);
|
|
2694
2834
|
}
|
|
2695
|
-
function
|
|
2835
|
+
function Jn(e) {
|
|
2696
2836
|
let t = [], n = e, r = n.indexOf("@");
|
|
2697
|
-
r >= 0 && (t.push(
|
|
2837
|
+
r >= 0 && (t.push(W.FALSE), t.push(new Y(X(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2698
2838
|
let i, a = null;
|
|
2699
2839
|
if (n.startsWith("[")) {
|
|
2700
2840
|
let e = n.indexOf("]");
|
|
@@ -2703,272 +2843,275 @@ function Bn(e) {
|
|
|
2703
2843
|
let r = n.slice(e + 1);
|
|
2704
2844
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2705
2845
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2706
|
-
t.push(new
|
|
2846
|
+
t.push(new z(mn(i)));
|
|
2707
2847
|
} else {
|
|
2708
2848
|
let e = n.lastIndexOf(":");
|
|
2709
|
-
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "")
|
|
2710
|
-
|
|
2849
|
+
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") {
|
|
2850
|
+
if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new z(pn(i)));
|
|
2851
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new Y(e));
|
|
2852
|
+
}
|
|
2711
2853
|
}
|
|
2712
2854
|
if (a !== null && a !== "") {
|
|
2713
2855
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2714
2856
|
let e = parseInt(a, 10);
|
|
2715
2857
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2716
|
-
t.push(new
|
|
2858
|
+
t.push(new F(BigInt(e)));
|
|
2717
2859
|
}
|
|
2718
|
-
return new
|
|
2860
|
+
return new H(t);
|
|
2719
2861
|
}
|
|
2720
|
-
function
|
|
2862
|
+
function Yn(e) {
|
|
2721
2863
|
let t = e.items, n = 0, r = "";
|
|
2722
|
-
if (n < t.length && t[n] instanceof
|
|
2864
|
+
if (n < t.length && t[n] instanceof W && t[n].value === 20) {
|
|
2723
2865
|
n++;
|
|
2724
2866
|
let e = t[n++];
|
|
2725
|
-
r +=
|
|
2867
|
+
r += Bn(e.value, Kn) + "@";
|
|
2726
2868
|
}
|
|
2727
2869
|
if (n >= t.length) return r;
|
|
2728
2870
|
let i = t[n];
|
|
2729
|
-
if (i instanceof
|
|
2871
|
+
if (i instanceof z) {
|
|
2730
2872
|
n++;
|
|
2731
2873
|
let { length: e } = i.value;
|
|
2732
|
-
if (e === 4) r +=
|
|
2733
|
-
else if (e === 16) r += "[" +
|
|
2874
|
+
if (e === 4) r += hn(i.value);
|
|
2875
|
+
else if (e === 16) r += "[" + gn(i.value) + "]";
|
|
2734
2876
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2735
|
-
n < t.length && t[n] instanceof
|
|
2877
|
+
n < t.length && t[n] instanceof Y && (r += `%25${Bn(t[n++].value, qn)}`);
|
|
2736
2878
|
} else {
|
|
2737
2879
|
let e = [];
|
|
2738
|
-
for (; n < t.length && t[n] instanceof
|
|
2880
|
+
for (; n < t.length && t[n] instanceof Y;) e.push(Bn(t[n++].value, qn));
|
|
2739
2881
|
r += e.join(".");
|
|
2740
2882
|
}
|
|
2741
|
-
return n < t.length && t[n] instanceof
|
|
2883
|
+
return n < t.length && t[n] instanceof F && (r += ":" + t[n].value.toString()), r;
|
|
2742
2884
|
}
|
|
2743
|
-
function
|
|
2885
|
+
function Xn(e) {
|
|
2744
2886
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2745
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
2746
|
-
authority:
|
|
2887
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new Y(X(e)))) : (r = t, i = []), {
|
|
2888
|
+
authority: Jn(r),
|
|
2747
2889
|
pathSegments: i
|
|
2748
2890
|
};
|
|
2749
2891
|
}
|
|
2750
|
-
function
|
|
2892
|
+
function Zn(e) {
|
|
2751
2893
|
let t = e, n = null, r = t.indexOf("#");
|
|
2752
|
-
r >= 0 && (n =
|
|
2894
|
+
r >= 0 && (n = X(t.slice(r + 1)), t = t.slice(0, r));
|
|
2753
2895
|
let i = null, a = t.indexOf("?");
|
|
2754
2896
|
if (a >= 0) {
|
|
2755
2897
|
let e = t.slice(a + 1);
|
|
2756
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
2898
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new Y(X(e)));
|
|
2757
2899
|
}
|
|
2758
2900
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2759
2901
|
if (s) {
|
|
2760
|
-
let e = s[1].toLowerCase(), t = s[2], n =
|
|
2761
|
-
if (o.push(n === void 0 ? new
|
|
2762
|
-
let { authority: e, pathSegments: n } =
|
|
2763
|
-
o.push(e, new
|
|
2902
|
+
let e = s[1].toLowerCase(), t = s[2], n = Fn.get(e);
|
|
2903
|
+
if (o.push(n === void 0 ? new Y(e) : new I(n)), t.startsWith("//")) {
|
|
2904
|
+
let { authority: e, pathSegments: n } = Xn(t);
|
|
2905
|
+
o.push(e, new H(n));
|
|
2764
2906
|
} else if (t.startsWith("/")) {
|
|
2765
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2766
|
-
o.push(
|
|
2907
|
+
let e = t.slice(1).split("/").map((e) => new Y(X(e)));
|
|
2908
|
+
o.push(W.NULL, new H(e));
|
|
2767
2909
|
} else {
|
|
2768
|
-
let e = t.split("/").map((e) => new
|
|
2769
|
-
o.push(
|
|
2910
|
+
let e = t.split("/").map((e) => new Y(X(e)));
|
|
2911
|
+
o.push(W.TRUE, new H(e));
|
|
2770
2912
|
}
|
|
2771
2913
|
} else if (t.startsWith("//")) {
|
|
2772
|
-
let { authority: e, pathSegments: n } =
|
|
2773
|
-
o.push(
|
|
2914
|
+
let { authority: e, pathSegments: n } = Xn(t);
|
|
2915
|
+
o.push(W.FALSE, e, new H(n));
|
|
2774
2916
|
} else if (t.startsWith("/")) {
|
|
2775
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2776
|
-
o.push(
|
|
2777
|
-
} else if (t === "") o.push(new
|
|
2917
|
+
let e = t.slice(1).split("/").map((e) => new Y(X(e)));
|
|
2918
|
+
o.push(W.TRUE, new H(e));
|
|
2919
|
+
} else if (t === "") o.push(new F(0n));
|
|
2778
2920
|
else {
|
|
2779
2921
|
let n = 1n, r = t, i = !1;
|
|
2780
2922
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2781
2923
|
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)}`);
|
|
2782
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
2783
|
-
o.push(new
|
|
2924
|
+
let a = r === "" ? [] : r.split("/").map((e) => new Y(X(e)));
|
|
2925
|
+
o.push(new F(n), new H(a));
|
|
2784
2926
|
}
|
|
2785
|
-
if (i !== null && o.push(new
|
|
2927
|
+
if (i !== null && o.push(new H(i)), n !== null && (i === null && o.push(W.NULL), o.push(new Y(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2786
2928
|
let e = o[o.length - 1];
|
|
2787
|
-
e instanceof
|
|
2929
|
+
e instanceof H && e.items.length === 0 && o.pop();
|
|
2788
2930
|
}
|
|
2789
|
-
return o.length === 1 && o[0] instanceof
|
|
2931
|
+
return o.length === 1 && o[0] instanceof F && o[0].value === 0n ? [] : o;
|
|
2790
2932
|
}
|
|
2791
|
-
function
|
|
2933
|
+
function Qn(e, t) {
|
|
2792
2934
|
let n = t, r = "";
|
|
2793
2935
|
if (n < e.length) {
|
|
2794
2936
|
let t = e[n];
|
|
2795
|
-
if (t instanceof
|
|
2937
|
+
if (t instanceof H) {
|
|
2796
2938
|
if (n++, t.items.length > 0) {
|
|
2797
2939
|
let e = t.items.map((e) => {
|
|
2798
|
-
if (!(e instanceof
|
|
2799
|
-
return
|
|
2940
|
+
if (!(e instanceof Y)) throw Error("cri: query item must be a text string");
|
|
2941
|
+
return Bn(e.value, Wn);
|
|
2800
2942
|
});
|
|
2801
2943
|
r += "?" + e.join("&");
|
|
2802
2944
|
}
|
|
2803
|
-
} else t instanceof
|
|
2945
|
+
} else t instanceof W && t.value === 22 && n++;
|
|
2804
2946
|
}
|
|
2805
|
-
return n < e.length && e[n] instanceof
|
|
2947
|
+
return n < e.length && e[n] instanceof Y && (r += "#" + Bn(e[n].value, Gn)), r;
|
|
2806
2948
|
}
|
|
2807
|
-
function
|
|
2949
|
+
function $n(e) {
|
|
2808
2950
|
return e.items.map((e) => {
|
|
2809
|
-
if (!(e instanceof
|
|
2810
|
-
return
|
|
2951
|
+
if (!(e instanceof Y)) throw Error("cri: path segment must be a text string");
|
|
2952
|
+
return Bn(e.value, Un);
|
|
2811
2953
|
});
|
|
2812
2954
|
}
|
|
2813
|
-
function
|
|
2955
|
+
function er(e) {
|
|
2814
2956
|
if (e.length === 0) return "";
|
|
2815
2957
|
let t = 0, n = e[t++];
|
|
2816
|
-
if (n instanceof
|
|
2958
|
+
if (n instanceof I || n instanceof Y) {
|
|
2817
2959
|
let r;
|
|
2818
|
-
if (n instanceof
|
|
2819
|
-
let e =
|
|
2960
|
+
if (n instanceof I) {
|
|
2961
|
+
let e = In.get(n.value);
|
|
2820
2962
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2821
2963
|
r = e + ":";
|
|
2822
2964
|
} else r = n.value + ":";
|
|
2823
2965
|
if (t >= e.length) return r;
|
|
2824
2966
|
let i = e[t++], a = "", o = !1;
|
|
2825
|
-
if (i instanceof
|
|
2826
|
-
else if (i instanceof
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2967
|
+
if (i instanceof H) a = "//" + Yn(i), o = !0;
|
|
2968
|
+
else if (i instanceof W) {
|
|
2969
|
+
if (i.value === 22) o = !0;
|
|
2970
|
+
else if (i.value === 21) o = !1;
|
|
2971
|
+
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2972
|
+
} else throw Error("cri: unexpected type for authority element");
|
|
2830
2973
|
let s = "";
|
|
2831
|
-
if (t < e.length && e[t] instanceof
|
|
2974
|
+
if (t < e.length && e[t] instanceof H) {
|
|
2832
2975
|
let n = e[t++];
|
|
2833
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
2976
|
+
n.items.length > 0 && (s = (o ? "/" : "") + $n(n).join("/"));
|
|
2834
2977
|
}
|
|
2835
|
-
return r + a + s +
|
|
2978
|
+
return r + a + s + Qn(e, t);
|
|
2836
2979
|
}
|
|
2837
|
-
if (n instanceof
|
|
2838
|
-
if (t >= e.length || !(e[t] instanceof
|
|
2839
|
-
let n =
|
|
2840
|
-
if (t < e.length && e[t] instanceof
|
|
2980
|
+
if (n instanceof W && n.value === 20) {
|
|
2981
|
+
if (t >= e.length || !(e[t] instanceof H)) throw Error("cri: network-path reference requires an authority array");
|
|
2982
|
+
let n = Yn(e[t++]), r = "";
|
|
2983
|
+
if (t < e.length && e[t] instanceof H) {
|
|
2841
2984
|
let n = e[t++];
|
|
2842
|
-
n.items.length > 0 && (r = "/" +
|
|
2985
|
+
n.items.length > 0 && (r = "/" + $n(n).join("/"));
|
|
2843
2986
|
}
|
|
2844
|
-
return "//" + n + r +
|
|
2987
|
+
return "//" + n + r + Qn(e, t);
|
|
2845
2988
|
}
|
|
2846
|
-
if (n instanceof
|
|
2989
|
+
if (n instanceof W && n.value === 21) {
|
|
2847
2990
|
let n = "/";
|
|
2848
|
-
if (t < e.length && e[t] instanceof
|
|
2991
|
+
if (t < e.length && e[t] instanceof H) {
|
|
2849
2992
|
let r = e[t++];
|
|
2850
|
-
n = "/" +
|
|
2993
|
+
n = "/" + $n(r).join("/");
|
|
2851
2994
|
}
|
|
2852
|
-
return n +
|
|
2995
|
+
return n + Qn(e, t);
|
|
2853
2996
|
}
|
|
2854
|
-
if (n instanceof
|
|
2997
|
+
if (n instanceof F) {
|
|
2855
2998
|
let r = n.value;
|
|
2856
|
-
if (r === 0n) return
|
|
2999
|
+
if (r === 0n) return Qn(e, t);
|
|
2857
3000
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
2858
|
-
if (t < e.length && e[t] instanceof
|
|
3001
|
+
if (t < e.length && e[t] instanceof H) {
|
|
2859
3002
|
let n = e[t++];
|
|
2860
3003
|
if (n.items.length > 0) {
|
|
2861
|
-
let e =
|
|
3004
|
+
let e = $n(n);
|
|
2862
3005
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
2863
3006
|
} else a = i === "" ? "./" : i;
|
|
2864
3007
|
} else a = i === "" ? "./" : i;
|
|
2865
|
-
return a +
|
|
3008
|
+
return a + Qn(e, t);
|
|
2866
3009
|
}
|
|
2867
3010
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
2868
3011
|
}
|
|
2869
|
-
var
|
|
2870
|
-
_toCDN(e,
|
|
2871
|
-
if (e?.
|
|
2872
|
-
let
|
|
2873
|
-
if (
|
|
3012
|
+
var tr = class extends H {
|
|
3013
|
+
_toCDN(e, n) {
|
|
3014
|
+
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
3015
|
+
let r = t(e, this.encodingWidth, () => E(BigInt(this.items.length)));
|
|
3016
|
+
if (T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted") return D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2874
3017
|
try {
|
|
2875
|
-
return `${
|
|
3018
|
+
return `${Mn}'${er(this.items)}'${r}`;
|
|
2876
3019
|
} catch {
|
|
2877
|
-
return super._toCDN(e,
|
|
3020
|
+
return super._toCDN(e, n);
|
|
2878
3021
|
}
|
|
2879
3022
|
}
|
|
2880
|
-
},
|
|
3023
|
+
}, nr = class extends R {
|
|
2881
3024
|
constructor(e) {
|
|
2882
|
-
super(
|
|
2883
|
-
}
|
|
2884
|
-
_toCDN(e,
|
|
2885
|
-
if (e?.
|
|
2886
|
-
let
|
|
2887
|
-
if (
|
|
2888
|
-
if (
|
|
2889
|
-
if (
|
|
3025
|
+
super(Pn, e);
|
|
3026
|
+
}
|
|
3027
|
+
_toCDN(e, n) {
|
|
3028
|
+
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
3029
|
+
let r = T(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
|
|
3030
|
+
if (r === "verbatim") return this.appSeqSource;
|
|
3031
|
+
if (r === "source") return w(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
|
|
3032
|
+
if (r === "structural") return super._toCDN({
|
|
2890
3033
|
...e,
|
|
2891
|
-
|
|
2892
|
-
},
|
|
3034
|
+
appPrefix: !1
|
|
3035
|
+
}, n);
|
|
2893
3036
|
try {
|
|
2894
|
-
let
|
|
2895
|
-
if (
|
|
2896
|
-
let
|
|
2897
|
-
return
|
|
3037
|
+
let i = this.content;
|
|
3038
|
+
if (i.encodingWidth !== void 0) return super._toCDN(e, n);
|
|
3039
|
+
let a = t(e, this.encodingWidth, () => E(Pn));
|
|
3040
|
+
return r === "adjusted" ? D(this.appSeqSource, a, e, this.appSeqInnerEnd, this.appSeqComments) : `${Nn}'${er(i.items)}'${a}`;
|
|
2898
3041
|
} catch {
|
|
2899
|
-
return super._toCDN(e,
|
|
3042
|
+
return super._toCDN(e, n);
|
|
2900
3043
|
}
|
|
2901
3044
|
}
|
|
2902
3045
|
};
|
|
2903
|
-
function
|
|
3046
|
+
function rr(e) {
|
|
2904
3047
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
2905
3048
|
let t = e[0];
|
|
2906
|
-
if (t instanceof
|
|
2907
|
-
if (t instanceof
|
|
3049
|
+
if (t instanceof Y) return t.value;
|
|
3050
|
+
if (t instanceof z) return Rn.decode(t.value);
|
|
2908
3051
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
2909
3052
|
}
|
|
2910
|
-
function
|
|
2911
|
-
let n = new
|
|
2912
|
-
return e ===
|
|
3053
|
+
function ir(e, t) {
|
|
3054
|
+
let n = new tr(Zn(t));
|
|
3055
|
+
return e === Nn ? new nr(n) : n;
|
|
2913
3056
|
}
|
|
2914
|
-
var
|
|
2915
|
-
appStringPrefixes: [
|
|
2916
|
-
tagNumbers: [
|
|
3057
|
+
var ar = {
|
|
3058
|
+
appStringPrefixes: [Mn, Nn],
|
|
3059
|
+
tagNumbers: [Pn],
|
|
2917
3060
|
preserveAppSeqSource: "optional",
|
|
2918
3061
|
parseAppString(e, t) {
|
|
2919
|
-
return
|
|
3062
|
+
return ir(e, t);
|
|
2920
3063
|
},
|
|
2921
3064
|
parseAppSequence(e, t) {
|
|
2922
|
-
return
|
|
3065
|
+
return ir(e, rr(t));
|
|
2923
3066
|
},
|
|
2924
3067
|
parseTag(e, t) {
|
|
2925
|
-
if (e !== 99n || !(t instanceof
|
|
2926
|
-
let n = new
|
|
3068
|
+
if (e !== 99n || !(t instanceof H)) return;
|
|
3069
|
+
let n = new tr(t.items, {
|
|
2927
3070
|
indefiniteLength: t.indefiniteLength,
|
|
2928
3071
|
encodingWidth: t.encodingWidth
|
|
2929
3072
|
});
|
|
2930
|
-
return n.start = t.start, n.end = t.end, new
|
|
3073
|
+
return n.start = t.start, n.end = t.end, new nr(n);
|
|
2931
3074
|
}
|
|
2932
|
-
},
|
|
2933
|
-
tagNumbers: [
|
|
3075
|
+
}, or = 18446744073709551615n, sr = -18446744073709551616n, cr = {
|
|
3076
|
+
tagNumbers: [nt, rt],
|
|
2934
3077
|
parseTag(e, t) {
|
|
2935
|
-
if (t instanceof
|
|
3078
|
+
if (t instanceof z) {
|
|
2936
3079
|
if (e === 2n) {
|
|
2937
|
-
let e =
|
|
2938
|
-
return e >
|
|
3080
|
+
let e = st(t.value);
|
|
3081
|
+
return e > or ? new ct(e) : void 0;
|
|
2939
3082
|
}
|
|
2940
3083
|
if (e === 3n) {
|
|
2941
|
-
let e = -1n -
|
|
2942
|
-
return e <
|
|
3084
|
+
let e = -1n - st(t.value);
|
|
3085
|
+
return e < sr ? new lt(e) : void 0;
|
|
2943
3086
|
}
|
|
2944
3087
|
}
|
|
2945
3088
|
}
|
|
2946
3089
|
};
|
|
2947
3090
|
//#endregion
|
|
2948
3091
|
//#region src/cbor/decoder.ts
|
|
2949
|
-
function
|
|
3092
|
+
function lr(e, t) {
|
|
2950
3093
|
if (e === 24 && t <= 23n) return 0;
|
|
2951
3094
|
if (e === 25 && t <= 255n) return 1;
|
|
2952
3095
|
if (e === 26 && t <= 65535n) return 2;
|
|
2953
3096
|
if (e === 27 && t <= 4294967295n) return 3;
|
|
2954
3097
|
}
|
|
2955
|
-
function
|
|
3098
|
+
function ur(e, t) {
|
|
2956
3099
|
if (e === 24 && t <= 23) return 0;
|
|
2957
3100
|
if (e === 25 && t <= 255) return 1;
|
|
2958
3101
|
if (e === 26 && t <= 65535) return 2;
|
|
2959
3102
|
if (e === 27 && t <= 4294967295) return 3;
|
|
2960
3103
|
}
|
|
2961
|
-
var
|
|
3104
|
+
var dr = new TextDecoder("utf-8", {
|
|
2962
3105
|
fatal: !0,
|
|
2963
3106
|
ignoreBOM: !0
|
|
2964
|
-
}),
|
|
3107
|
+
}), fr = new TextDecoder("utf-8", {
|
|
2965
3108
|
fatal: !1,
|
|
2966
3109
|
ignoreBOM: !0
|
|
2967
3110
|
});
|
|
2968
|
-
function
|
|
3111
|
+
function Z(e) {
|
|
2969
3112
|
throw Error(`CBOR decode error: ${e}`);
|
|
2970
3113
|
}
|
|
2971
|
-
function
|
|
3114
|
+
function pr(e, t, n) {
|
|
2972
3115
|
let r = {
|
|
2973
3116
|
message: e,
|
|
2974
3117
|
offset: t
|
|
@@ -2976,191 +3119,191 @@ function ar(e, t, n) {
|
|
|
2976
3119
|
if (n?.onWarning ? n.onWarning(r) : n?.silent || console.warn(`CBOR strict violation at offset ${t}: ${e}`), n?.strict !== !1) throw Error(`CBOR decode error: ${e}`);
|
|
2977
3120
|
return r;
|
|
2978
3121
|
}
|
|
2979
|
-
function
|
|
3122
|
+
function mr(e, t) {
|
|
2980
3123
|
e.warnings ??= [], e.warnings.push(t);
|
|
2981
3124
|
}
|
|
2982
|
-
function
|
|
2983
|
-
if (e instanceof
|
|
2984
|
-
if (e instanceof
|
|
2985
|
-
if (e instanceof
|
|
2986
|
-
if (e instanceof
|
|
2987
|
-
if (e instanceof
|
|
2988
|
-
if (e instanceof
|
|
3125
|
+
function hr(e) {
|
|
3126
|
+
if (e instanceof F) return ["u", String(e.value)];
|
|
3127
|
+
if (e instanceof I) return ["n", String(e.value)];
|
|
3128
|
+
if (e instanceof Y) return ["t", e.value];
|
|
3129
|
+
if (e instanceof V) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
3130
|
+
if (e instanceof z) return ["b", s(e.value)];
|
|
3131
|
+
if (e instanceof B) {
|
|
2989
3132
|
let t = "";
|
|
2990
|
-
for (let n of e.chunks) t +=
|
|
3133
|
+
for (let n of e.chunks) t += s(n.value);
|
|
2991
3134
|
return ["b", t];
|
|
2992
3135
|
}
|
|
2993
|
-
if (e instanceof
|
|
2994
|
-
if (e instanceof
|
|
2995
|
-
if (e instanceof
|
|
2996
|
-
if (e instanceof
|
|
2997
|
-
let t = e.entries.map(([e, t]) => [
|
|
3136
|
+
if (e instanceof L) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
3137
|
+
if (e instanceof W) return ["s", e.value];
|
|
3138
|
+
if (e instanceof H) return ["A", e.items.map(hr)];
|
|
3139
|
+
if (e instanceof U) {
|
|
3140
|
+
let t = e.entries.map(([e, t]) => [hr(e), hr(t)]);
|
|
2998
3141
|
if (t.length <= 1) return ["M", t];
|
|
2999
3142
|
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
3000
3143
|
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
3001
3144
|
}
|
|
3002
|
-
return e instanceof
|
|
3145
|
+
return e instanceof R ? [
|
|
3003
3146
|
"G",
|
|
3004
3147
|
String(e.tag),
|
|
3005
|
-
|
|
3006
|
-
] : ["c",
|
|
3007
|
-
}
|
|
3008
|
-
function
|
|
3009
|
-
if (e instanceof
|
|
3010
|
-
if (e instanceof
|
|
3011
|
-
if (e instanceof
|
|
3012
|
-
if (e instanceof
|
|
3148
|
+
hr(e.content)
|
|
3149
|
+
] : ["c", s(e.toCBOR())];
|
|
3150
|
+
}
|
|
3151
|
+
function gr(e) {
|
|
3152
|
+
if (e instanceof F) return "u" + e.value;
|
|
3153
|
+
if (e instanceof I) return "n" + e.value;
|
|
3154
|
+
if (e instanceof Y) return "t" + e.value;
|
|
3155
|
+
if (e instanceof V) {
|
|
3013
3156
|
let t = "t";
|
|
3014
3157
|
for (let n of e.chunks) t += n.value;
|
|
3015
3158
|
return t;
|
|
3016
3159
|
}
|
|
3017
|
-
if (e instanceof
|
|
3018
|
-
if (e instanceof
|
|
3160
|
+
if (e instanceof z) return "b" + s(e.value);
|
|
3161
|
+
if (e instanceof B) {
|
|
3019
3162
|
let t = "b";
|
|
3020
|
-
for (let n of e.chunks) t +=
|
|
3163
|
+
for (let n of e.chunks) t += s(n.value);
|
|
3021
3164
|
return t;
|
|
3022
3165
|
}
|
|
3023
|
-
return e instanceof
|
|
3166
|
+
return e instanceof L ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof W ? "s" + e.value : JSON.stringify(hr(e));
|
|
3024
3167
|
}
|
|
3025
|
-
var
|
|
3026
|
-
function
|
|
3027
|
-
return e === void 0 ?
|
|
3168
|
+
var _r = Array.from({ length: 24 }, (e, t) => BigInt(t)), vr;
|
|
3169
|
+
function yr(e) {
|
|
3170
|
+
return e === void 0 ? vr ??= di(void 0).filter((e) => e.parseTag !== void 0) : di(e).filter((e) => e.parseTag !== void 0);
|
|
3028
3171
|
}
|
|
3029
|
-
function
|
|
3172
|
+
function br(e, t) {
|
|
3030
3173
|
for (let n = 0; n < t; n++) if (e[n] >= 128) return;
|
|
3031
3174
|
return String.fromCharCode.apply(null, e);
|
|
3032
3175
|
}
|
|
3033
|
-
function
|
|
3176
|
+
function xr(e, t, n) {
|
|
3034
3177
|
if (n <= 23) return {
|
|
3035
|
-
value:
|
|
3178
|
+
value: _r[n],
|
|
3036
3179
|
nextOffset: t
|
|
3037
3180
|
};
|
|
3038
3181
|
switch (n) {
|
|
3039
|
-
case 24: return t + 1 > e.byteLength &&
|
|
3182
|
+
case 24: return t + 1 > e.byteLength && Z("unexpected end of input"), {
|
|
3040
3183
|
value: BigInt(e.getUint8(t)),
|
|
3041
3184
|
nextOffset: t + 1
|
|
3042
3185
|
};
|
|
3043
|
-
case 25: return t + 2 > e.byteLength &&
|
|
3186
|
+
case 25: return t + 2 > e.byteLength && Z("unexpected end of input"), {
|
|
3044
3187
|
value: BigInt(e.getUint16(t, !1)),
|
|
3045
3188
|
nextOffset: t + 2
|
|
3046
3189
|
};
|
|
3047
|
-
case 26: return t + 4 > e.byteLength &&
|
|
3190
|
+
case 26: return t + 4 > e.byteLength && Z("unexpected end of input"), {
|
|
3048
3191
|
value: BigInt(e.getUint32(t, !1)),
|
|
3049
3192
|
nextOffset: t + 4
|
|
3050
3193
|
};
|
|
3051
|
-
case 27: return t + 8 > e.byteLength &&
|
|
3194
|
+
case 27: return t + 8 > e.byteLength && Z("unexpected end of input"), {
|
|
3052
3195
|
value: e.getBigUint64(t, !1),
|
|
3053
3196
|
nextOffset: t + 8
|
|
3054
3197
|
};
|
|
3055
|
-
default:
|
|
3198
|
+
default: Z(`reserved additional info value: ${n}`);
|
|
3056
3199
|
}
|
|
3057
3200
|
}
|
|
3058
|
-
function
|
|
3201
|
+
function Sr(e, t, n) {
|
|
3059
3202
|
if (n <= 23) return {
|
|
3060
3203
|
value: n,
|
|
3061
3204
|
nextOffset: t
|
|
3062
3205
|
};
|
|
3063
3206
|
switch (n) {
|
|
3064
|
-
case 24: return t + 1 > e.byteLength &&
|
|
3207
|
+
case 24: return t + 1 > e.byteLength && Z("unexpected end of input"), {
|
|
3065
3208
|
value: e.getUint8(t),
|
|
3066
3209
|
nextOffset: t + 1
|
|
3067
3210
|
};
|
|
3068
|
-
case 25: return t + 2 > e.byteLength &&
|
|
3211
|
+
case 25: return t + 2 > e.byteLength && Z("unexpected end of input"), {
|
|
3069
3212
|
value: e.getUint16(t, !1),
|
|
3070
3213
|
nextOffset: t + 2
|
|
3071
3214
|
};
|
|
3072
|
-
case 26: return t + 4 > e.byteLength &&
|
|
3215
|
+
case 26: return t + 4 > e.byteLength && Z("unexpected end of input"), {
|
|
3073
3216
|
value: e.getUint32(t, !1),
|
|
3074
3217
|
nextOffset: t + 4
|
|
3075
3218
|
};
|
|
3076
3219
|
case 27: {
|
|
3077
|
-
t + 8 > e.byteLength &&
|
|
3220
|
+
t + 8 > e.byteLength && Z("unexpected end of input");
|
|
3078
3221
|
let n = e.getUint32(t, !1), r = e.getUint32(t + 4, !1);
|
|
3079
3222
|
return {
|
|
3080
3223
|
value: n * 4294967296 + r,
|
|
3081
3224
|
nextOffset: t + 8
|
|
3082
3225
|
};
|
|
3083
3226
|
}
|
|
3084
|
-
default:
|
|
3227
|
+
default: Z(`reserved additional info value: ${n}`);
|
|
3085
3228
|
}
|
|
3086
3229
|
}
|
|
3087
|
-
function
|
|
3230
|
+
function Cr(e, t, n, r, i, a) {
|
|
3088
3231
|
let o = [], s = t;
|
|
3089
3232
|
for (;;) {
|
|
3090
|
-
if (s >= e.byteLength &&
|
|
3233
|
+
if (s >= e.byteLength && Z(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
3091
3234
|
s++;
|
|
3092
3235
|
break;
|
|
3093
3236
|
}
|
|
3094
|
-
let t =
|
|
3095
|
-
a(t.value) ||
|
|
3237
|
+
let t = Q(e, s, n, r);
|
|
3238
|
+
a(t.value) || Z(`indefinite-length ${i} chunk must be a definite ${i}`), o.push(t.value), s = t.nextOffset;
|
|
3096
3239
|
}
|
|
3097
3240
|
return {
|
|
3098
3241
|
chunks: o,
|
|
3099
3242
|
nextOffset: s
|
|
3100
3243
|
};
|
|
3101
3244
|
}
|
|
3102
|
-
function
|
|
3103
|
-
let i =
|
|
3104
|
-
t.has(i) && n.push(
|
|
3245
|
+
function wr(e, t, n, r) {
|
|
3246
|
+
let i = gr(e);
|
|
3247
|
+
t.has(i) && n.push(pr(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
3105
3248
|
}
|
|
3106
|
-
function
|
|
3107
|
-
let i = t, a =
|
|
3249
|
+
function Q(e, t, n, r) {
|
|
3250
|
+
let i = t, a = Er(e, t, n, r);
|
|
3108
3251
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
3109
3252
|
}
|
|
3110
|
-
function
|
|
3253
|
+
function Tr(e, t, n) {
|
|
3111
3254
|
return new Uint8Array(e.buffer, e.byteOffset + t, n).slice();
|
|
3112
3255
|
}
|
|
3113
|
-
function
|
|
3114
|
-
t >= e.byteLength &&
|
|
3256
|
+
function Er(e, t, n, r) {
|
|
3257
|
+
t >= e.byteLength && Z("unexpected end of input");
|
|
3115
3258
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
3116
3259
|
switch (a) {
|
|
3117
3260
|
case 0: {
|
|
3118
|
-
let { value: n, nextOffset: r } =
|
|
3261
|
+
let { value: n, nextOffset: r } = xr(e, t, o);
|
|
3119
3262
|
return {
|
|
3120
|
-
value: new
|
|
3263
|
+
value: new F(n, { encodingWidth: lr(o, n) }),
|
|
3121
3264
|
nextOffset: r
|
|
3122
3265
|
};
|
|
3123
3266
|
}
|
|
3124
3267
|
case 1: {
|
|
3125
|
-
let { value: n, nextOffset: r } =
|
|
3268
|
+
let { value: n, nextOffset: r } = xr(e, t, o), i = lr(o, n);
|
|
3126
3269
|
return {
|
|
3127
|
-
value: new
|
|
3270
|
+
value: new I(-1n - n, { encodingWidth: i }),
|
|
3128
3271
|
nextOffset: r
|
|
3129
3272
|
};
|
|
3130
3273
|
}
|
|
3131
3274
|
case 2: {
|
|
3132
3275
|
if (o === 31) {
|
|
3133
|
-
let { chunks: i, nextOffset: a } =
|
|
3276
|
+
let { chunks: i, nextOffset: a } = Cr(e, t, n, r, "byte string", (e) => e instanceof z);
|
|
3134
3277
|
return {
|
|
3135
|
-
value: new
|
|
3278
|
+
value: new B(i),
|
|
3136
3279
|
nextOffset: a
|
|
3137
3280
|
};
|
|
3138
3281
|
}
|
|
3139
|
-
let { value: i, nextOffset: a } =
|
|
3140
|
-
return a + i > e.byteLength &&
|
|
3141
|
-
value: new
|
|
3282
|
+
let { value: i, nextOffset: a } = Sr(e, t, o), s = ur(o, i);
|
|
3283
|
+
return a + i > e.byteLength && Z("byte string extends beyond input"), {
|
|
3284
|
+
value: new z(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
|
|
3142
3285
|
nextOffset: a + i
|
|
3143
3286
|
};
|
|
3144
3287
|
}
|
|
3145
3288
|
case 3: {
|
|
3146
3289
|
if (o === 31) {
|
|
3147
|
-
let { chunks: i, nextOffset: a } =
|
|
3290
|
+
let { chunks: i, nextOffset: a } = Cr(e, t, n, r, "text string", (e) => e instanceof Y);
|
|
3148
3291
|
return {
|
|
3149
|
-
value: new
|
|
3292
|
+
value: new V(i),
|
|
3150
3293
|
nextOffset: a
|
|
3151
3294
|
};
|
|
3152
3295
|
}
|
|
3153
|
-
let { value: i, nextOffset: a } =
|
|
3154
|
-
a + i > e.byteLength &&
|
|
3155
|
-
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ?
|
|
3296
|
+
let { value: i, nextOffset: a } = Sr(e, t, o), s = ur(o, i);
|
|
3297
|
+
a + i > e.byteLength && Z("text string extends beyond input");
|
|
3298
|
+
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? br(c, i) : void 0;
|
|
3156
3299
|
if (d !== void 0) l = d;
|
|
3157
3300
|
else try {
|
|
3158
|
-
l =
|
|
3301
|
+
l = dr.decode(c);
|
|
3159
3302
|
} catch {
|
|
3160
|
-
u =
|
|
3303
|
+
u = pr("invalid UTF-8 sequence in text string", a, n), l = fr.decode(c);
|
|
3161
3304
|
}
|
|
3162
|
-
let f = new
|
|
3163
|
-
return u &&
|
|
3305
|
+
let f = new Y(l, { encodingWidth: s });
|
|
3306
|
+
return u && mr(f, u), {
|
|
3164
3307
|
value: f,
|
|
3165
3308
|
nextOffset: a + i
|
|
3166
3309
|
};
|
|
@@ -3169,25 +3312,25 @@ function _r(e, t, n, r) {
|
|
|
3169
3312
|
if (o === 31) {
|
|
3170
3313
|
let i = [], a = t;
|
|
3171
3314
|
for (;;) {
|
|
3172
|
-
if (a >= e.byteLength &&
|
|
3315
|
+
if (a >= e.byteLength && Z("unexpected end of indefinite array"), e.getUint8(a) === 255) {
|
|
3173
3316
|
a++;
|
|
3174
3317
|
break;
|
|
3175
3318
|
}
|
|
3176
|
-
let t =
|
|
3319
|
+
let t = Q(e, a, n, r);
|
|
3177
3320
|
i.push(t.value), a = t.nextOffset;
|
|
3178
3321
|
}
|
|
3179
3322
|
return {
|
|
3180
|
-
value: new
|
|
3323
|
+
value: new H(i, { indefiniteLength: !0 }),
|
|
3181
3324
|
nextOffset: a
|
|
3182
3325
|
};
|
|
3183
3326
|
}
|
|
3184
|
-
let { value: i, nextOffset: a } =
|
|
3327
|
+
let { value: i, nextOffset: a } = Sr(e, t, o), s = ur(o, i), c = [], l = a;
|
|
3185
3328
|
for (let t = 0; t < i; t++) {
|
|
3186
|
-
let t =
|
|
3329
|
+
let t = Q(e, l, n, r);
|
|
3187
3330
|
c.push(t.value), l = t.nextOffset;
|
|
3188
3331
|
}
|
|
3189
3332
|
return {
|
|
3190
|
-
value: new
|
|
3333
|
+
value: new H(c, { encodingWidth: s }),
|
|
3191
3334
|
nextOffset: l
|
|
3192
3335
|
};
|
|
3193
3336
|
}
|
|
@@ -3195,149 +3338,149 @@ function _r(e, t, n, r) {
|
|
|
3195
3338
|
if (o === 31) {
|
|
3196
3339
|
let i = [], a = /* @__PURE__ */ new Set(), o = [], s = t;
|
|
3197
3340
|
for (;;) {
|
|
3198
|
-
if (s >= e.byteLength &&
|
|
3341
|
+
if (s >= e.byteLength && Z("unexpected end of indefinite map"), e.getUint8(s) === 255) {
|
|
3199
3342
|
s++;
|
|
3200
3343
|
break;
|
|
3201
3344
|
}
|
|
3202
|
-
let t =
|
|
3203
|
-
|
|
3204
|
-
let c =
|
|
3345
|
+
let t = Q(e, s, n, r);
|
|
3346
|
+
wr(t.value, a, o, n), s = t.nextOffset;
|
|
3347
|
+
let c = Q(e, s, n, r);
|
|
3205
3348
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
3206
3349
|
}
|
|
3207
|
-
let c = new
|
|
3208
|
-
for (let e of o)
|
|
3350
|
+
let c = new U(i, { indefiniteLength: !0 });
|
|
3351
|
+
for (let e of o) mr(c, e);
|
|
3209
3352
|
return {
|
|
3210
3353
|
value: c,
|
|
3211
3354
|
nextOffset: s
|
|
3212
3355
|
};
|
|
3213
3356
|
}
|
|
3214
|
-
let { value: i, nextOffset: a } =
|
|
3357
|
+
let { value: i, nextOffset: a } = Sr(e, t, o), s = ur(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
|
|
3215
3358
|
for (let t = 0; t < i; t++) {
|
|
3216
|
-
let t =
|
|
3217
|
-
|
|
3218
|
-
let i =
|
|
3359
|
+
let t = Q(e, d, n, r);
|
|
3360
|
+
wr(t.value, l, u, n), d = t.nextOffset;
|
|
3361
|
+
let i = Q(e, d, n, r);
|
|
3219
3362
|
d = i.nextOffset, c.push([t.value, i.value]);
|
|
3220
3363
|
}
|
|
3221
|
-
let f = new
|
|
3222
|
-
for (let e of u)
|
|
3364
|
+
let f = new U(c, { encodingWidth: s });
|
|
3365
|
+
for (let e of u) mr(f, e);
|
|
3223
3366
|
return {
|
|
3224
3367
|
value: f,
|
|
3225
3368
|
nextOffset: d
|
|
3226
3369
|
};
|
|
3227
3370
|
}
|
|
3228
3371
|
case 6: {
|
|
3229
|
-
o === 31 &&
|
|
3230
|
-
let { value: i, nextOffset: a } =
|
|
3372
|
+
o === 31 && Z("tags cannot use indefinite-length encoding");
|
|
3373
|
+
let { value: i, nextOffset: a } = xr(e, t, o), s = lr(o, i), c = Q(e, a, n, r);
|
|
3231
3374
|
for (let e of r) {
|
|
3232
3375
|
let t = e.parseTag(i, c.value, n);
|
|
3233
|
-
if (t !== void 0) return t instanceof
|
|
3376
|
+
if (t !== void 0) return t instanceof R && s !== void 0 && (t.encodingWidth = s), {
|
|
3234
3377
|
value: t,
|
|
3235
3378
|
nextOffset: c.nextOffset
|
|
3236
3379
|
};
|
|
3237
3380
|
}
|
|
3238
3381
|
return {
|
|
3239
|
-
value: new
|
|
3382
|
+
value: new R(i, c.value, { encodingWidth: s }),
|
|
3240
3383
|
nextOffset: c.nextOffset
|
|
3241
3384
|
};
|
|
3242
3385
|
}
|
|
3243
3386
|
case 7:
|
|
3244
3387
|
if (o <= 19) return {
|
|
3245
|
-
value: new
|
|
3388
|
+
value: new W(o),
|
|
3246
3389
|
nextOffset: t
|
|
3247
3390
|
};
|
|
3248
3391
|
if (o === 20) return {
|
|
3249
|
-
value: new
|
|
3392
|
+
value: new W(20),
|
|
3250
3393
|
nextOffset: t
|
|
3251
3394
|
};
|
|
3252
3395
|
if (o === 21) return {
|
|
3253
|
-
value: new
|
|
3396
|
+
value: new W(21),
|
|
3254
3397
|
nextOffset: t
|
|
3255
3398
|
};
|
|
3256
3399
|
if (o === 22) return {
|
|
3257
|
-
value: new
|
|
3400
|
+
value: new W(22),
|
|
3258
3401
|
nextOffset: t
|
|
3259
3402
|
};
|
|
3260
3403
|
if (o === 23) return {
|
|
3261
|
-
value: new
|
|
3404
|
+
value: new W(23),
|
|
3262
3405
|
nextOffset: t
|
|
3263
3406
|
};
|
|
3264
3407
|
if (o === 24) {
|
|
3265
|
-
t + 1 > e.byteLength &&
|
|
3408
|
+
t + 1 > e.byteLength && Z("unexpected end of input");
|
|
3266
3409
|
let r = e.getUint8(t);
|
|
3267
3410
|
if (r < 32) {
|
|
3268
|
-
let e =
|
|
3269
|
-
return
|
|
3411
|
+
let e = pr(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new W(r);
|
|
3412
|
+
return mr(i, e), {
|
|
3270
3413
|
value: i,
|
|
3271
3414
|
nextOffset: t + 1
|
|
3272
3415
|
};
|
|
3273
3416
|
}
|
|
3274
3417
|
return {
|
|
3275
|
-
value: new
|
|
3418
|
+
value: new W(r),
|
|
3276
3419
|
nextOffset: t + 1
|
|
3277
3420
|
};
|
|
3278
3421
|
}
|
|
3279
3422
|
if (o === 25) {
|
|
3280
|
-
t + 2 > e.byteLength &&
|
|
3281
|
-
let n =
|
|
3423
|
+
t + 2 > e.byteLength && Z("unexpected end of input");
|
|
3424
|
+
let n = A(e.getUint16(t, !1));
|
|
3282
3425
|
return {
|
|
3283
|
-
value: new
|
|
3426
|
+
value: new L(n, {
|
|
3284
3427
|
precision: "half",
|
|
3285
|
-
rawBits: Number.isNaN(n) ?
|
|
3428
|
+
rawBits: Number.isNaN(n) ? Tr(e, t, 2) : void 0
|
|
3286
3429
|
}),
|
|
3287
3430
|
nextOffset: t + 2
|
|
3288
3431
|
};
|
|
3289
3432
|
}
|
|
3290
3433
|
if (o === 26) {
|
|
3291
|
-
t + 4 > e.byteLength &&
|
|
3434
|
+
t + 4 > e.byteLength && Z("unexpected end of input");
|
|
3292
3435
|
let n = e.getFloat32(t, !1);
|
|
3293
3436
|
return {
|
|
3294
|
-
value: new
|
|
3437
|
+
value: new L(n, {
|
|
3295
3438
|
precision: "single",
|
|
3296
|
-
rawBits: Number.isNaN(n) ?
|
|
3439
|
+
rawBits: Number.isNaN(n) ? Tr(e, t, 4) : void 0
|
|
3297
3440
|
}),
|
|
3298
3441
|
nextOffset: t + 4
|
|
3299
3442
|
};
|
|
3300
3443
|
}
|
|
3301
3444
|
if (o === 27) {
|
|
3302
|
-
t + 8 > e.byteLength &&
|
|
3445
|
+
t + 8 > e.byteLength && Z("unexpected end of input");
|
|
3303
3446
|
let n = e.getFloat64(t, !1);
|
|
3304
3447
|
return {
|
|
3305
|
-
value: new
|
|
3448
|
+
value: new L(n, {
|
|
3306
3449
|
precision: "double",
|
|
3307
|
-
rawBits: Number.isNaN(n) ?
|
|
3450
|
+
rawBits: Number.isNaN(n) ? Tr(e, t, 8) : void 0
|
|
3308
3451
|
}),
|
|
3309
3452
|
nextOffset: t + 8
|
|
3310
3453
|
};
|
|
3311
3454
|
}
|
|
3312
|
-
return o < 31 &&
|
|
3455
|
+
return o < 31 && Z(`reserved additional info value in major type 7: ${o}`), Z("unexpected break code outside indefinite-length item");
|
|
3313
3456
|
}
|
|
3314
|
-
return
|
|
3457
|
+
return Z(`unknown major type: ${a}`);
|
|
3315
3458
|
}
|
|
3316
|
-
function
|
|
3459
|
+
function Dr(e) {
|
|
3317
3460
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
3318
3461
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
3319
3462
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
3320
3463
|
}
|
|
3321
|
-
function
|
|
3322
|
-
let n =
|
|
3464
|
+
function Or(e, t) {
|
|
3465
|
+
let n = Dr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
3323
3466
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
3324
|
-
let a =
|
|
3467
|
+
let a = yr(t?.builtinExtensions), o = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...a] : a, { value: s, nextOffset: c } = Q(r, i, t, o);
|
|
3325
3468
|
if (!t?.allowTrailing && c !== r.byteLength) {
|
|
3326
|
-
|
|
3469
|
+
mr(s, pr(`${r.byteLength - c} trailing byte(s) after end of CBOR item`, c, t));
|
|
3327
3470
|
let e = {
|
|
3328
3471
|
strict: !1,
|
|
3329
3472
|
silent: !0
|
|
3330
3473
|
}, n = c;
|
|
3331
|
-
for (; n < r.byteLength;) ({nextOffset: n} =
|
|
3474
|
+
for (; n < r.byteLength;) ({nextOffset: n} = Q(r, n, e, o));
|
|
3332
3475
|
}
|
|
3333
3476
|
return s;
|
|
3334
3477
|
}
|
|
3335
3478
|
//#endregion
|
|
3336
3479
|
//#region src/extensions/cbordata.ts
|
|
3337
|
-
var
|
|
3338
|
-
tagNumbers: [
|
|
3480
|
+
var kr = 24n, Ar = {
|
|
3481
|
+
tagNumbers: [kr],
|
|
3339
3482
|
parseTag(e, t, n) {
|
|
3340
|
-
if (e !== 24n || !(t instanceof
|
|
3483
|
+
if (e !== 24n || !(t instanceof z)) return;
|
|
3341
3484
|
let r = (t.end ?? t.value.length) - t.value.length, i = n ? {
|
|
3342
3485
|
extensions: n.extensions,
|
|
3343
3486
|
builtinExtensions: n.builtinExtensions,
|
|
@@ -3349,7 +3492,7 @@ var br = 24n, xr = {
|
|
|
3349
3492
|
silent: n.silent
|
|
3350
3493
|
} : void 0;
|
|
3351
3494
|
try {
|
|
3352
|
-
return new
|
|
3495
|
+
return new R(kr, new G([Or(t.value, i)], { encodingWidth: t.encodingWidth }));
|
|
3353
3496
|
} catch (e) {
|
|
3354
3497
|
if (i?.strict !== !1) throw e;
|
|
3355
3498
|
let t = `tag 24 content is not valid CBOR: ${e instanceof Error ? e.message : String(e)}`, a = {
|
|
@@ -3363,156 +3506,156 @@ var br = 24n, xr = {
|
|
|
3363
3506
|
};
|
|
3364
3507
|
//#endregion
|
|
3365
3508
|
//#region src/extensions/ellipsis.ts
|
|
3366
|
-
function
|
|
3367
|
-
return e instanceof
|
|
3509
|
+
function jr(e) {
|
|
3510
|
+
return e instanceof K && !(e.content instanceof H);
|
|
3368
3511
|
}
|
|
3369
|
-
function
|
|
3512
|
+
function Mr(e) {
|
|
3370
3513
|
let t = !1, n = !1, r = !1, i;
|
|
3371
3514
|
for (let a of e) {
|
|
3372
3515
|
let e;
|
|
3373
|
-
if (
|
|
3374
|
-
else if (a instanceof
|
|
3375
|
-
else if (a instanceof
|
|
3516
|
+
if (jr(a)) e = !0, r = !0;
|
|
3517
|
+
else if (a instanceof Y) e = !1, t = !0;
|
|
3518
|
+
else if (a instanceof z) e = !1, n = !0;
|
|
3376
3519
|
else return !1;
|
|
3377
3520
|
if (e === i) return !1;
|
|
3378
3521
|
i = e;
|
|
3379
3522
|
}
|
|
3380
3523
|
return r && !(t && n);
|
|
3381
3524
|
}
|
|
3382
|
-
var
|
|
3383
|
-
tagNumbers: [
|
|
3525
|
+
var Nr = {
|
|
3526
|
+
tagNumbers: [Xe],
|
|
3384
3527
|
parseTag(e, t) {
|
|
3385
3528
|
if (e === 888n) {
|
|
3386
|
-
if (t instanceof
|
|
3387
|
-
if (t instanceof
|
|
3529
|
+
if (t instanceof W && t.value === 22) return new K();
|
|
3530
|
+
if (t instanceof H && Mr(t.items)) return new K(t.items);
|
|
3388
3531
|
}
|
|
3389
3532
|
}
|
|
3390
|
-
},
|
|
3391
|
-
function
|
|
3533
|
+
}, Pr = new TextEncoder(), Fr = new TextDecoder("utf-8", { fatal: !0 }), Ir = new TextDecoder("utf-8", { fatal: !1 }), Lr = Symbol("ellipsis");
|
|
3534
|
+
function Rr(e) {
|
|
3392
3535
|
let t = 0;
|
|
3393
3536
|
for (let n of e) t += n.length;
|
|
3394
3537
|
let n = new Uint8Array(t), r = 0;
|
|
3395
3538
|
for (let t of e) n.set(t, r), r += t.length;
|
|
3396
3539
|
return n;
|
|
3397
3540
|
}
|
|
3398
|
-
function
|
|
3399
|
-
if (t instanceof
|
|
3400
|
-
|
|
3541
|
+
function zr(e, t, n) {
|
|
3542
|
+
if (t instanceof Ye) {
|
|
3543
|
+
zr(e, t.inner, n);
|
|
3401
3544
|
return;
|
|
3402
3545
|
}
|
|
3403
|
-
if (t instanceof
|
|
3404
|
-
if (t.content instanceof
|
|
3405
|
-
else n.push(
|
|
3546
|
+
if (t instanceof K) {
|
|
3547
|
+
if (t.content instanceof H) for (let r of t.content.items) zr(e, r, n);
|
|
3548
|
+
else n.push(Lr);
|
|
3406
3549
|
return;
|
|
3407
3550
|
}
|
|
3408
|
-
if (t instanceof
|
|
3409
|
-
n.push(
|
|
3551
|
+
if (t instanceof Y) {
|
|
3552
|
+
n.push(Pr.encode(t.value));
|
|
3410
3553
|
return;
|
|
3411
3554
|
}
|
|
3412
|
-
if (t instanceof
|
|
3555
|
+
if (t instanceof z) {
|
|
3413
3556
|
n.push(t.value);
|
|
3414
3557
|
return;
|
|
3415
3558
|
}
|
|
3416
|
-
if (t instanceof
|
|
3417
|
-
n.push(
|
|
3559
|
+
if (t instanceof V) {
|
|
3560
|
+
n.push(Pr.encode(t.chunks.map((e) => e.value).join("")));
|
|
3418
3561
|
return;
|
|
3419
3562
|
}
|
|
3420
|
-
if (t instanceof
|
|
3421
|
-
n.push(
|
|
3563
|
+
if (t instanceof B) {
|
|
3564
|
+
n.push(Rr(t.chunks.map((e) => e.value)));
|
|
3422
3565
|
return;
|
|
3423
3566
|
}
|
|
3424
3567
|
throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings or ellipses`);
|
|
3425
3568
|
}
|
|
3426
|
-
function
|
|
3569
|
+
function Br(e, t) {
|
|
3427
3570
|
try {
|
|
3428
|
-
return
|
|
3571
|
+
return Fr.decode(e);
|
|
3429
3572
|
} catch {
|
|
3430
3573
|
let n = "t1 concatenation result is not valid UTF-8";
|
|
3431
3574
|
if (t) t(n);
|
|
3432
3575
|
else throw SyntaxError(n);
|
|
3433
|
-
return
|
|
3576
|
+
return Ir.decode(e);
|
|
3434
3577
|
}
|
|
3435
3578
|
}
|
|
3436
|
-
function
|
|
3579
|
+
function Vr(e, t, n) {
|
|
3437
3580
|
let r = [];
|
|
3438
|
-
for (let n of t)
|
|
3581
|
+
for (let n of t) zr(e, n, r);
|
|
3439
3582
|
let i = e === "t1", a = [], o = !1, s = [], c = () => {
|
|
3440
3583
|
if (s.length === 0) return;
|
|
3441
|
-
let e =
|
|
3442
|
-
s.length = 0, e.length !== 0 && a.push(i ? new
|
|
3584
|
+
let e = Rr(s);
|
|
3585
|
+
s.length = 0, e.length !== 0 && a.push(i ? new Y(Br(e, n)) : new z(e));
|
|
3443
3586
|
};
|
|
3444
|
-
for (let e of r) e ===
|
|
3587
|
+
for (let e of r) e === Lr ? (c(), a[a.length - 1] instanceof K || (a.push(new K()), o = !0)) : s.push(e);
|
|
3445
3588
|
if (!o) {
|
|
3446
|
-
let e =
|
|
3447
|
-
return i ? new
|
|
3589
|
+
let e = Rr(s);
|
|
3590
|
+
return i ? new Y(Br(e, n)) : new z(e);
|
|
3448
3591
|
}
|
|
3449
|
-
return c(), a.length === 1 ? new
|
|
3592
|
+
return c(), a.length === 1 ? new K() : new K(a);
|
|
3450
3593
|
}
|
|
3451
|
-
function
|
|
3594
|
+
function Hr(e) {
|
|
3452
3595
|
return {
|
|
3453
3596
|
appStringPrefixes: [e],
|
|
3454
3597
|
preserveAppSeqSource: !0,
|
|
3455
3598
|
parseAppString(t, n, r) {
|
|
3456
|
-
return
|
|
3599
|
+
return Vr(e, [new Y(n)], r);
|
|
3457
3600
|
},
|
|
3458
3601
|
parseAppSequence(t, n, r) {
|
|
3459
|
-
return
|
|
3602
|
+
return Vr(e, n, r);
|
|
3460
3603
|
}
|
|
3461
3604
|
};
|
|
3462
3605
|
}
|
|
3463
|
-
var
|
|
3464
|
-
function
|
|
3606
|
+
var Ur = Hr("t1"), Wr = Hr("b1"), Gr = new TextEncoder(), Kr = new TextDecoder("utf-8", { fatal: !0 }), qr = new TextDecoder("utf-8", { fatal: !1 });
|
|
3607
|
+
function Jr(e) {
|
|
3465
3608
|
let t = 0;
|
|
3466
3609
|
for (let n of e) t += n.length;
|
|
3467
3610
|
let n = new Uint8Array(t), r = 0;
|
|
3468
3611
|
for (let t of e) n.set(t, r), r += t.length;
|
|
3469
3612
|
return n;
|
|
3470
3613
|
}
|
|
3471
|
-
function
|
|
3614
|
+
function Yr(e, t, n) {
|
|
3472
3615
|
let r = e === "ilts", i = [], a = [];
|
|
3473
3616
|
for (let o of t) {
|
|
3474
|
-
if (o instanceof
|
|
3617
|
+
if (o instanceof Ye && (o = o.inner), o instanceof K) throw SyntaxError(`${e}<<...>> cannot contain ellipses; there is no way to include an elision in an indefinite-length string`);
|
|
3475
3618
|
let t, s, c;
|
|
3476
|
-
if (o instanceof
|
|
3477
|
-
else if (o instanceof
|
|
3478
|
-
else if (o instanceof
|
|
3479
|
-
else if (o instanceof
|
|
3619
|
+
if (o instanceof Y) t = o.value, c = o.encodingWidth;
|
|
3620
|
+
else if (o instanceof z) s = o.value, c = o.encodingWidth;
|
|
3621
|
+
else if (o instanceof V) t = o.chunks.map((e) => e.value).join("");
|
|
3622
|
+
else if (o instanceof B) s = Jr(o.chunks.map((e) => e.value));
|
|
3480
3623
|
else throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings`);
|
|
3481
3624
|
if (r) {
|
|
3482
3625
|
let e;
|
|
3483
3626
|
if (t !== void 0) e = t;
|
|
3484
3627
|
else try {
|
|
3485
|
-
e =
|
|
3628
|
+
e = Kr.decode(s);
|
|
3486
3629
|
} catch {
|
|
3487
3630
|
let t = "ilts chunk is not valid UTF-8";
|
|
3488
3631
|
if (n) n(t);
|
|
3489
3632
|
else throw SyntaxError(t);
|
|
3490
|
-
e =
|
|
3633
|
+
e = qr.decode(s);
|
|
3491
3634
|
}
|
|
3492
|
-
a.push(new
|
|
3635
|
+
a.push(new Y(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
3493
3636
|
} else {
|
|
3494
|
-
let e = s ??
|
|
3495
|
-
i.push(new
|
|
3637
|
+
let e = s ?? Gr.encode(t);
|
|
3638
|
+
i.push(new z(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
3496
3639
|
}
|
|
3497
3640
|
}
|
|
3498
|
-
return r ? new
|
|
3641
|
+
return r ? new V(a) : new B(i);
|
|
3499
3642
|
}
|
|
3500
|
-
function
|
|
3643
|
+
function Xr(e) {
|
|
3501
3644
|
return {
|
|
3502
3645
|
appStringPrefixes: [e],
|
|
3503
3646
|
preserveAppSeqSource: !0,
|
|
3504
3647
|
parseAppString(t, n, r) {
|
|
3505
|
-
return new
|
|
3648
|
+
return new Ye(Yr(e, [new Y(n)], r), `${e}${ne(n)}`);
|
|
3506
3649
|
},
|
|
3507
3650
|
parseAppSequence(t, n, r) {
|
|
3508
|
-
return
|
|
3651
|
+
return Yr(e, n, r);
|
|
3509
3652
|
}
|
|
3510
3653
|
};
|
|
3511
3654
|
}
|
|
3512
|
-
var
|
|
3655
|
+
var Zr = Xr("ilbs"), Qr = Xr("ilts"), $r = class extends L {
|
|
3513
3656
|
_bits;
|
|
3514
3657
|
constructor(e) {
|
|
3515
|
-
super(
|
|
3658
|
+
super(A(e), { precision: "half" }), this._bits = e & 65535;
|
|
3516
3659
|
}
|
|
3517
3660
|
_toCBOR() {
|
|
3518
3661
|
return new Uint8Array([
|
|
@@ -3521,7 +3664,7 @@ var Hr = Vr("ilbs"), Ur = Vr("ilts"), Wr = class extends j {
|
|
|
3521
3664
|
this._bits & 255
|
|
3522
3665
|
]);
|
|
3523
3666
|
}
|
|
3524
|
-
},
|
|
3667
|
+
}, ei = class extends L {
|
|
3525
3668
|
_raw;
|
|
3526
3669
|
constructor(e) {
|
|
3527
3670
|
super(new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), { precision: "single" }), this._raw = e.slice();
|
|
@@ -3530,7 +3673,7 @@ var Hr = Vr("ilbs"), Ur = Vr("ilts"), Wr = class extends j {
|
|
|
3530
3673
|
let e = /* @__PURE__ */ new Uint8Array(5);
|
|
3531
3674
|
return e[0] = 250, e.set(this._raw, 1), e;
|
|
3532
3675
|
}
|
|
3533
|
-
},
|
|
3676
|
+
}, ti = class extends L {
|
|
3534
3677
|
_raw;
|
|
3535
3678
|
constructor(e) {
|
|
3536
3679
|
super(new DataView(e.buffer, e.byteOffset).getFloat64(0, !1), { precision: "double" }), this._raw = e.slice();
|
|
@@ -3540,13 +3683,13 @@ var Hr = Vr("ilbs"), Ur = Vr("ilts"), Wr = class extends j {
|
|
|
3540
3683
|
return e[0] = 251, e.set(this._raw, 1), e;
|
|
3541
3684
|
}
|
|
3542
3685
|
};
|
|
3543
|
-
function
|
|
3544
|
-
if (e.length === 2) return new
|
|
3545
|
-
if (e.length === 4) return new
|
|
3546
|
-
if (e.length === 8) return new
|
|
3686
|
+
function ni(e) {
|
|
3687
|
+
if (e.length === 2) return new $r(e[0] << 8 | e[1]);
|
|
3688
|
+
if (e.length === 4) return new ei(e);
|
|
3689
|
+
if (e.length === 8) return new ti(e);
|
|
3547
3690
|
throw SyntaxError(`float'...' requires 4, 8, or 16 hex digits (2, 4, or 8 bytes); got ${e.length} bytes`);
|
|
3548
3691
|
}
|
|
3549
|
-
function
|
|
3692
|
+
function ri(e) {
|
|
3550
3693
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i;
|
|
3551
3694
|
if (n === 31) i = t << 31 | 2139095040 | r << 13;
|
|
3552
3695
|
else if (n === 0 && r === 0) i = t << 31;
|
|
@@ -3558,7 +3701,7 @@ function Jr(e) {
|
|
|
3558
3701
|
let a = /* @__PURE__ */ new Uint8Array(4);
|
|
3559
3702
|
return new DataView(a.buffer).setUint32(0, i >>> 0, !1), a;
|
|
3560
3703
|
}
|
|
3561
|
-
function
|
|
3704
|
+
function ii(e) {
|
|
3562
3705
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i = /* @__PURE__ */ new Uint8Array(8), a = new DataView(i.buffer);
|
|
3563
3706
|
if (n === 31) a.setUint32(0, (t << 31 | 2146435072 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3564
3707
|
else if (n === 0 && r === 0) a.setUint32(0, t << 31 >>> 0, !1), a.setUint32(4, 0, !1);
|
|
@@ -3569,7 +3712,7 @@ function Yr(e) {
|
|
|
3569
3712
|
} else a.setUint32(0, (t << 31 | n + 1008 << 20 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3570
3713
|
return i;
|
|
3571
3714
|
}
|
|
3572
|
-
function
|
|
3715
|
+
function ai(e) {
|
|
3573
3716
|
let t = new DataView(e.buffer, e.byteOffset).getUint32(0, !1), n = t >>> 31 & 1, r = t >>> 23 & 255, i = t & 8388607, a = /* @__PURE__ */ new Uint8Array(8), o = new DataView(a.buffer);
|
|
3574
3717
|
if (r === 255) o.setUint32(0, (n << 31 | 2146435072 | i >>> 3) >>> 0, !1), o.setUint32(4, (i & 7) << 29, !1);
|
|
3575
3718
|
else if (r === 0 && i === 0) o.setUint32(0, n << 31 >>> 0, !1), o.setUint32(4, 0, !1);
|
|
@@ -3579,49 +3722,49 @@ function Xr(e) {
|
|
|
3579
3722
|
}
|
|
3580
3723
|
return a;
|
|
3581
3724
|
}
|
|
3582
|
-
function
|
|
3725
|
+
function oi(e, t, n) {
|
|
3583
3726
|
let r = e.length === 2 ? 1 : e.length === 4 ? 2 : 3;
|
|
3584
3727
|
if (r === 1) {
|
|
3585
3728
|
let n = e[0] << 8 | e[1];
|
|
3586
|
-
if (t === 2) return new
|
|
3587
|
-
if (t === 3) return new
|
|
3729
|
+
if (t === 2) return new ei(ri(n));
|
|
3730
|
+
if (t === 3) return new ti(ii(n));
|
|
3588
3731
|
}
|
|
3589
3732
|
if (r === 2) {
|
|
3590
|
-
if (t === 3) return new
|
|
3733
|
+
if (t === 3) return new ti(ai(e));
|
|
3591
3734
|
if (t === 1) {
|
|
3592
|
-
let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), r =
|
|
3593
|
-
return !Object.is(
|
|
3735
|
+
let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), r = ye(t);
|
|
3736
|
+
return !Object.is(A(r), t) && !isNaN(t) && n("float'...' value cannot be exactly represented as float16 (_1)"), new $r(r);
|
|
3594
3737
|
}
|
|
3595
3738
|
}
|
|
3596
3739
|
if (r === 3) {
|
|
3597
3740
|
let r = new DataView(e.buffer, e.byteOffset).getFloat64(0, !1);
|
|
3598
3741
|
if (t === 1) {
|
|
3599
|
-
let e =
|
|
3600
|
-
return !Object.is(
|
|
3742
|
+
let e = ye(r);
|
|
3743
|
+
return !Object.is(A(e), r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float16 (_1)"), new $r(e);
|
|
3601
3744
|
}
|
|
3602
3745
|
if (t === 2) {
|
|
3603
3746
|
let e = Math.fround(r);
|
|
3604
3747
|
!Object.is(e, r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float32 (_2)");
|
|
3605
3748
|
let t = /* @__PURE__ */ new Uint8Array(4);
|
|
3606
|
-
return new DataView(t.buffer).setFloat32(0, e, !1), new
|
|
3749
|
+
return new DataView(t.buffer).setFloat32(0, e, !1), new ei(t);
|
|
3607
3750
|
}
|
|
3608
3751
|
}
|
|
3609
|
-
return
|
|
3752
|
+
return ni(e);
|
|
3610
3753
|
}
|
|
3611
|
-
var
|
|
3754
|
+
var si = {
|
|
3612
3755
|
appStringPrefixes: ["float"],
|
|
3613
|
-
parseAppString(e, t,
|
|
3614
|
-
let a =
|
|
3756
|
+
parseAppString(e, t, n, r) {
|
|
3757
|
+
let a = Be(t);
|
|
3615
3758
|
if (!/^[0-9a-fA-F]*$/.test(a)) throw SyntaxError("float'...' contains non-hex characters");
|
|
3616
3759
|
if (a.length % 2 != 0) throw SyntaxError(`float'...' hex content has odd length (${a.length} digits)`);
|
|
3617
|
-
let o =
|
|
3618
|
-
if (s === void 0) return
|
|
3760
|
+
let o = i(a), s = r?.encodingWidth;
|
|
3761
|
+
if (s === void 0) return ni(o);
|
|
3619
3762
|
if (s !== 1 && s !== 2 && s !== 3) {
|
|
3620
3763
|
let e = `float'...' encoding indicator _${s} is not valid; use _1, _2, or _3`;
|
|
3621
|
-
if (
|
|
3764
|
+
if (n) return n(e), ni(o);
|
|
3622
3765
|
throw SyntaxError(e);
|
|
3623
3766
|
}
|
|
3624
|
-
return s === (o.length === 2 ? 1 : o.length === 4 ? 2 : 3) ?
|
|
3767
|
+
return s === (o.length === 2 ? 1 : o.length === 4 ? 2 : 3) ? ni(o) : oi(o, s, n ?? ((e) => {
|
|
3625
3768
|
throw SyntaxError(e);
|
|
3626
3769
|
}));
|
|
3627
3770
|
},
|
|
@@ -3632,100 +3775,100 @@ var Qr = {
|
|
|
3632
3775
|
if (n) n(e);
|
|
3633
3776
|
else throw SyntaxError(e);
|
|
3634
3777
|
}
|
|
3635
|
-
if (!(t[0] instanceof
|
|
3636
|
-
return
|
|
3637
|
-
}
|
|
3638
|
-
},
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
],
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
Pr,
|
|
3647
|
-
Fr,
|
|
3648
|
-
Hr,
|
|
3778
|
+
if (!(t[0] instanceof z)) throw SyntaxError("float<<...>> item must be a byte string");
|
|
3779
|
+
return ni(t[0].value);
|
|
3780
|
+
}
|
|
3781
|
+
}, ci = [
|
|
3782
|
+
cr,
|
|
3783
|
+
Ar,
|
|
3784
|
+
Nr
|
|
3785
|
+
], li = [
|
|
3786
|
+
dn,
|
|
3787
|
+
jn,
|
|
3788
|
+
ar,
|
|
3649
3789
|
Ur,
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3790
|
+
Wr,
|
|
3791
|
+
Zr,
|
|
3792
|
+
Qr,
|
|
3793
|
+
si
|
|
3794
|
+
], ui;
|
|
3795
|
+
function di(e) {
|
|
3796
|
+
return e === void 0 ? ui ??= [...ci, ...li] : e === !1 ? ci : [...ci, ...e];
|
|
3654
3797
|
}
|
|
3655
3798
|
//#endregion
|
|
3656
3799
|
//#region src/js/fromJS.ts
|
|
3657
|
-
var
|
|
3658
|
-
function
|
|
3800
|
+
var fi;
|
|
3801
|
+
function pi(e) {
|
|
3659
3802
|
if (e === void 0) {
|
|
3660
|
-
if (
|
|
3661
|
-
let e =
|
|
3662
|
-
return
|
|
3803
|
+
if (fi) return fi;
|
|
3804
|
+
let e = di(void 0);
|
|
3805
|
+
return fi = {
|
|
3663
3806
|
fromJS: e.filter((e) => e.fromJS !== void 0),
|
|
3664
3807
|
parseTag: e.filter((e) => e.parseTag !== void 0)
|
|
3665
3808
|
};
|
|
3666
3809
|
}
|
|
3667
|
-
let t =
|
|
3810
|
+
let t = di(e);
|
|
3668
3811
|
return {
|
|
3669
3812
|
fromJS: t.filter((e) => e.fromJS !== void 0),
|
|
3670
3813
|
parseTag: t.filter((e) => e.parseTag !== void 0)
|
|
3671
3814
|
};
|
|
3672
3815
|
}
|
|
3673
|
-
function
|
|
3674
|
-
let t = e?.extensions, n =
|
|
3816
|
+
function mi(e) {
|
|
3817
|
+
let t = e?.extensions, n = pi(e?.builtinExtensions);
|
|
3675
3818
|
return t?.length ? {
|
|
3676
3819
|
fromJS: [...t.filter((e) => e.fromJS !== void 0), ...n.fromJS],
|
|
3677
3820
|
parseTag: [...t.filter((e) => e.parseTag !== void 0), ...n.parseTag]
|
|
3678
3821
|
} : n;
|
|
3679
3822
|
}
|
|
3680
|
-
function
|
|
3823
|
+
function hi(e, t) {
|
|
3681
3824
|
if (t?.replacer) {
|
|
3682
|
-
let { replacer: n, ...r } = t, i =
|
|
3683
|
-
return i ===
|
|
3825
|
+
let { replacer: n, ...r } = t, i = vi(e, n, r.extensions, r.undefinedOmits, r.builtinExtensions);
|
|
3826
|
+
return i === he ? W.UNDEFINED : hi(i, Object.keys(r).length > 0 ? r : void 0);
|
|
3684
3827
|
}
|
|
3685
|
-
return
|
|
3828
|
+
return gi(e, t, !0, mi(t));
|
|
3686
3829
|
}
|
|
3687
|
-
function
|
|
3830
|
+
function gi(e, t, n, r) {
|
|
3688
3831
|
for (let n of r.fromJS) {
|
|
3689
3832
|
let r = n.fromJS(e, t ?? {});
|
|
3690
3833
|
if (r !== void 0) return r;
|
|
3691
3834
|
}
|
|
3692
|
-
if (n && typeof e == "object" && e &&
|
|
3693
|
-
let n = e[
|
|
3835
|
+
if (n && typeof e == "object" && e && k.symbol in e) {
|
|
3836
|
+
let n = e[k.symbol], i = gi(e, t, !1, r);
|
|
3694
3837
|
for (let e of r.parseTag) {
|
|
3695
3838
|
let t = e.parseTag(n, i);
|
|
3696
3839
|
if (t !== void 0) return t;
|
|
3697
3840
|
}
|
|
3698
|
-
return new
|
|
3699
|
-
}
|
|
3700
|
-
if (e instanceof
|
|
3701
|
-
if (e instanceof
|
|
3702
|
-
if (e instanceof
|
|
3703
|
-
if (e === null) return
|
|
3704
|
-
if (e === void 0) return
|
|
3705
|
-
if (e === !0) return
|
|
3706
|
-
if (e === !1) return
|
|
3707
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new
|
|
3708
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new
|
|
3709
|
-
if (typeof e == "string") return new
|
|
3710
|
-
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return
|
|
3711
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new
|
|
3712
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new
|
|
3713
|
-
if (e instanceof $) return new
|
|
3714
|
-
if (Array.isArray(e)) return new
|
|
3841
|
+
return new R(n, i);
|
|
3842
|
+
}
|
|
3843
|
+
if (e instanceof k.Null) return W.NULL;
|
|
3844
|
+
if (e instanceof k.Undefined) return W.UNDEFINED;
|
|
3845
|
+
if (e instanceof ge) return new W(e.value);
|
|
3846
|
+
if (e === null) return W.NULL;
|
|
3847
|
+
if (e === void 0) return W.UNDEFINED;
|
|
3848
|
+
if (e === !0) return W.TRUE;
|
|
3849
|
+
if (e === !1) return W.FALSE;
|
|
3850
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new ct(e) : e < -18446744073709551616n ? new lt(e) : e >= 0n ? new F(e) : new I(e);
|
|
3851
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new F(BigInt(e)) : new I(BigInt(e)) : new L(e);
|
|
3852
|
+
if (typeof e == "string") return new Y(e);
|
|
3853
|
+
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return gi(e.valueOf(), t, !1, r);
|
|
3854
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new z(new Uint8Array(e));
|
|
3855
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new H(Array.from(e, (e) => new F(BigInt(e)))) : new z(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
3856
|
+
if (e instanceof $) return new U([...e].map(([e, n]) => [gi(e, t, !0, r), gi(n, t, !0, r)]));
|
|
3857
|
+
if (Array.isArray(e)) return new H(e.map((e) => gi(e, t, !0, r)));
|
|
3715
3858
|
if (typeof e == "object") {
|
|
3716
3859
|
let n = [];
|
|
3717
|
-
for (let [i, a] of Object.entries(e)) n.push([new
|
|
3718
|
-
return new
|
|
3860
|
+
for (let [i, a] of Object.entries(e)) n.push([new Y(i), gi(a, t, !0, r)]);
|
|
3861
|
+
return new U(n);
|
|
3719
3862
|
}
|
|
3720
3863
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
3721
3864
|
}
|
|
3722
|
-
function
|
|
3723
|
-
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
|
|
3865
|
+
function _i(e) {
|
|
3866
|
+
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 k.Null || e instanceof k.Undefined || e instanceof ge;
|
|
3724
3867
|
}
|
|
3725
|
-
function
|
|
3726
|
-
let a = [...n ?? [], ...
|
|
3868
|
+
function vi(e, t, n, r, i) {
|
|
3869
|
+
let a = [...n ?? [], ...di(i)].filter((e) => e.isJSType !== void 0);
|
|
3727
3870
|
function o(e) {
|
|
3728
|
-
return e ===
|
|
3871
|
+
return e === he || r === !0 && e === void 0;
|
|
3729
3872
|
}
|
|
3730
3873
|
if (Array.isArray(t)) {
|
|
3731
3874
|
let n = t.map(String);
|
|
@@ -3733,7 +3876,7 @@ function si(e, t, n, r, i) {
|
|
|
3733
3876
|
if (typeof e != "object" || !e) return e;
|
|
3734
3877
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
3735
3878
|
if (Array.isArray(e)) return e.map(r);
|
|
3736
|
-
if (
|
|
3879
|
+
if (k.symbol in e || _i(e) || a.some((t) => t.isJSType(e))) return e;
|
|
3737
3880
|
let t = Object.getPrototypeOf(e);
|
|
3738
3881
|
if (t === Object.prototype || t === null) {
|
|
3739
3882
|
let t = e.toJSON;
|
|
@@ -3755,7 +3898,7 @@ function si(e, t, n, r, i) {
|
|
|
3755
3898
|
}
|
|
3756
3899
|
}
|
|
3757
3900
|
if (e = s.call(n, t, e), typeof e == "object" && e) {
|
|
3758
|
-
if (
|
|
3901
|
+
if (k.symbol in e) return e;
|
|
3759
3902
|
if (e instanceof $) {
|
|
3760
3903
|
let t = new $();
|
|
3761
3904
|
for (let [n, r] of e) {
|
|
@@ -3768,7 +3911,7 @@ function si(e, t, n, r, i) {
|
|
|
3768
3911
|
let r = c(t, String(n), e);
|
|
3769
3912
|
return o(r) ? null : r;
|
|
3770
3913
|
});
|
|
3771
|
-
if (
|
|
3914
|
+
if (_i(e) || a.some((t) => t.isJSType(e))) return e;
|
|
3772
3915
|
let t = {};
|
|
3773
3916
|
for (let n of Object.keys(e)) {
|
|
3774
3917
|
let r = c(e[n], n, e);
|
|
@@ -3786,7 +3929,7 @@ var $ = class extends Array {
|
|
|
3786
3929
|
toJSON() {
|
|
3787
3930
|
let e = {};
|
|
3788
3931
|
for (let [t, n] of this) {
|
|
3789
|
-
let r = typeof t == "string" ? t :
|
|
3932
|
+
let r = typeof t == "string" ? t : hi(t).toCDN();
|
|
3790
3933
|
r === "__proto__" ? Object.defineProperty(e, r, {
|
|
3791
3934
|
value: n,
|
|
3792
3935
|
writable: !0,
|
|
@@ -3798,6 +3941,6 @@ var $ = class extends Array {
|
|
|
3798
3941
|
}
|
|
3799
3942
|
};
|
|
3800
3943
|
//#endregion
|
|
3801
|
-
export {
|
|
3944
|
+
export { R as A, ce as B, G as C, V as D, H as E, P as F, le as H, N as I, ge as L, Ie as M, I as N, B as O, F as P, he as R, Ke as S, U as T, k as V, lt as _, si as a, Ye as b, Wr as c, ar as d, jn as f, pt as g, Y as h, li as i, L as j, z as k, Ur as l, fn as m, vi as n, Zr as o, dn as p, hi as r, Qr as s, $ as t, Or as u, ct as v, W as w, Ge as x, K as y, se as z };
|
|
3802
3945
|
|
|
3803
|
-
//# sourceMappingURL=mapEntries-
|
|
3946
|
+
//# sourceMappingURL=mapEntries-CvLdiN0h.js.map
|