@cbortech/cbor 0.25.1 → 0.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ast/CborAppSeqResult.d.ts +2 -1
- package/dist/ast/CborArray.d.ts +2 -2
- package/dist/ast/CborByteString.d.ts +2 -2
- package/dist/ast/CborEmbeddedCBOR.d.ts +2 -1
- package/dist/ast/CborFloat.d.ts +2 -1
- package/dist/ast/CborIndefiniteByteString.d.ts +2 -1
- package/dist/ast/CborIndefiniteTextString.d.ts +2 -1
- package/dist/ast/CborItem.d.ts +29 -2
- package/dist/ast/CborMap.d.ts +2 -2
- package/dist/ast/CborNint.d.ts +2 -2
- package/dist/ast/CborSimple.d.ts +2 -1
- package/dist/ast/CborTag.d.ts +2 -2
- package/dist/ast/CborTextString.d.ts +2 -2
- package/dist/ast/CborUint.d.ts +2 -2
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +2 -2
- package/dist/cbor/encode.d.ts +38 -4
- package/dist/cdn/tokenizer.d.ts +24 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +24 -24
- package/dist/{mapEntries-ZR8QJ0Yj.js → mapEntries-BMMPg2FB.js} +1042 -937
- package/dist/mapEntries-BMMPg2FB.js.map +1 -0
- package/dist/mapEntries-DZKHc3VY.cjs +39 -0
- package/dist/mapEntries-DZKHc3VY.cjs.map +1 -0
- package/package.json +3 -2
- package/dist/mapEntries-BccT62HT.cjs +0 -36
- package/dist/mapEntries-BccT62HT.cjs.map +0 -1
- package/dist/mapEntries-ZR8QJ0Yj.js.map +0 -1
|
@@ -172,12 +172,12 @@ function ue(e) {
|
|
|
172
172
|
}
|
|
173
173
|
function de(e, t, n) {
|
|
174
174
|
if (n === "string") {
|
|
175
|
-
let t =
|
|
176
|
-
if (t != null) return
|
|
175
|
+
let t = pe(e);
|
|
176
|
+
if (t != null) return ge(t);
|
|
177
177
|
}
|
|
178
178
|
if (n === "printable-string" || n === void 0) {
|
|
179
|
-
let t =
|
|
180
|
-
if (t != null && !ue(t)) return
|
|
179
|
+
let t = pe(e);
|
|
180
|
+
if (t != null && !ue(t)) return ge(t);
|
|
181
181
|
}
|
|
182
182
|
switch (t) {
|
|
183
183
|
case "base64": return `b64'${ae(e)}'`;
|
|
@@ -187,15 +187,25 @@ function de(e, t, n) {
|
|
|
187
187
|
default: return `h'${ie(e)}'`;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
|
|
190
|
+
var fe = new TextDecoder("utf-8", { fatal: !0 });
|
|
191
|
+
function pe(e) {
|
|
191
192
|
try {
|
|
192
|
-
return
|
|
193
|
+
return fe.decode(e);
|
|
193
194
|
} catch {
|
|
194
195
|
return null;
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
|
-
function
|
|
198
|
-
let n =
|
|
198
|
+
function me(e, t) {
|
|
199
|
+
for (let n = 0; n < e.length; n++) {
|
|
200
|
+
let r = e.charCodeAt(n);
|
|
201
|
+
if (r === t || r === 92 || r < 32 || r === 127 || r >= 8192 && (r === 8232 || r === 8233 || r >= 8203 && r <= 8205 || r === 65279)) return !0;
|
|
202
|
+
}
|
|
203
|
+
return !1;
|
|
204
|
+
}
|
|
205
|
+
function he(e, t) {
|
|
206
|
+
let n = t.codePointAt(0);
|
|
207
|
+
if (!me(e, n)) return t + e + t;
|
|
208
|
+
let r = t;
|
|
199
209
|
for (let i of e) {
|
|
200
210
|
let e = i.codePointAt(0);
|
|
201
211
|
switch (e) {
|
|
@@ -219,28 +229,153 @@ function pe(e, t) {
|
|
|
219
229
|
}
|
|
220
230
|
return r + t;
|
|
221
231
|
}
|
|
222
|
-
function me(e) {
|
|
223
|
-
return pe(e, "'");
|
|
224
|
-
}
|
|
225
|
-
function he(e) {
|
|
226
|
-
return pe(e, "'");
|
|
227
|
-
}
|
|
228
232
|
function ge(e) {
|
|
229
|
-
return
|
|
233
|
+
return he(e, "'");
|
|
230
234
|
}
|
|
231
235
|
function _e(e) {
|
|
236
|
+
return he(e, "'");
|
|
237
|
+
}
|
|
238
|
+
function ve(e) {
|
|
239
|
+
return he(e, "\"");
|
|
240
|
+
}
|
|
241
|
+
function ye(e) {
|
|
232
242
|
if (isNaN(e)) return "NaN";
|
|
233
243
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
234
244
|
if (Object.is(e, -0)) return "-0.0";
|
|
235
245
|
let t = e.toString();
|
|
236
246
|
return t.includes(".") || t.includes("e") ? t : t + ".0";
|
|
237
247
|
}
|
|
238
|
-
function
|
|
248
|
+
function be(e, t, n) {
|
|
239
249
|
return t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
|
|
240
250
|
}
|
|
241
251
|
//#endregion
|
|
252
|
+
//#region src/utils/float16.ts
|
|
253
|
+
var xe = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Se = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
254
|
+
function Ce(e) {
|
|
255
|
+
Se.setFloat64(0, e, !1);
|
|
256
|
+
let t = Se.getUint32(0, !1), n = Se.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
257
|
+
if (i === 2047) {
|
|
258
|
+
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
259
|
+
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
260
|
+
return r << 15 | 31744 | e & 1023;
|
|
261
|
+
}
|
|
262
|
+
let o = i - 1023 + 15;
|
|
263
|
+
if (o >= 31) return r << 15 | 31744;
|
|
264
|
+
let s, c, l;
|
|
265
|
+
if (o <= 0) {
|
|
266
|
+
if (o < -10) return r << 15;
|
|
267
|
+
let e = 1 << 20 | a, t = 11 - o;
|
|
268
|
+
t <= 20 ? (s = e >> t & 1023, c = e >> t - 1 & 1, l = (e & (1 << t - 1) - 1) != 0 || n !== 0) : (s = 0, c = 1, l = a !== 0 || n !== 0);
|
|
269
|
+
} else s = a >> 10, c = a >> 9 & 1, l = (a & 511) != 0 || n !== 0;
|
|
270
|
+
if (c !== 0 && (l || s & 1) && s++, s >= 1024) {
|
|
271
|
+
let e = o <= 0 ? 1 : o + 1;
|
|
272
|
+
return e >= 31 ? r << 15 | 31744 : r << 15 | e << 10;
|
|
273
|
+
}
|
|
274
|
+
let u = o <= 0 ? 0 : o;
|
|
275
|
+
return r << 15 | u << 10 | s;
|
|
276
|
+
}
|
|
277
|
+
function _(e) {
|
|
278
|
+
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
279
|
+
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);
|
|
280
|
+
}
|
|
281
|
+
var we = xe ? (e, t, n, r) => {
|
|
282
|
+
e.setFloat16(t, n, r);
|
|
283
|
+
} : (e, t, n, r) => {
|
|
284
|
+
e.setUint16(t, Ce(n), r);
|
|
285
|
+
}, v = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), y = new Uint8Array(v.buffer), b = class {
|
|
286
|
+
buf;
|
|
287
|
+
len = 0;
|
|
288
|
+
constructor(e = 256) {
|
|
289
|
+
this.buf = new Uint8Array(e);
|
|
290
|
+
}
|
|
291
|
+
_ensure(e) {
|
|
292
|
+
let t = this.len + e;
|
|
293
|
+
if (t <= this.buf.length) return;
|
|
294
|
+
let n = this.buf.length * 2;
|
|
295
|
+
for (; n < t;) n *= 2;
|
|
296
|
+
let r = new Uint8Array(n);
|
|
297
|
+
r.set(this.buf), this.buf = r;
|
|
298
|
+
}
|
|
299
|
+
writeByte(e) {
|
|
300
|
+
this._ensure(1), this.buf[this.len++] = e;
|
|
301
|
+
}
|
|
302
|
+
writeBytes(e) {
|
|
303
|
+
this._ensure(e.length), this.buf.set(e, this.len), this.len += e.length;
|
|
304
|
+
}
|
|
305
|
+
writeUint16(e) {
|
|
306
|
+
this._ensure(2);
|
|
307
|
+
let t = this.buf;
|
|
308
|
+
t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
309
|
+
}
|
|
310
|
+
writeUint32(e) {
|
|
311
|
+
this._ensure(4);
|
|
312
|
+
let t = this.buf;
|
|
313
|
+
t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
314
|
+
}
|
|
315
|
+
writeBigUint64(e) {
|
|
316
|
+
v.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(y, this.len), this.len += 8;
|
|
317
|
+
}
|
|
318
|
+
writeFloat16(e) {
|
|
319
|
+
we(v, 0, e, !1), this._ensure(2);
|
|
320
|
+
let t = this.buf;
|
|
321
|
+
t[this.len++] = y[0], t[this.len++] = y[1];
|
|
322
|
+
}
|
|
323
|
+
writeFloat32(e) {
|
|
324
|
+
v.setFloat32(0, e, !1), this._ensure(4);
|
|
325
|
+
let t = this.buf;
|
|
326
|
+
t[this.len++] = y[0], t[this.len++] = y[1], t[this.len++] = y[2], t[this.len++] = y[3];
|
|
327
|
+
}
|
|
328
|
+
writeFloat64(e) {
|
|
329
|
+
v.setFloat64(0, e, !1), this._ensure(8), this.buf.set(y, this.len), this.len += 8;
|
|
330
|
+
}
|
|
331
|
+
finish() {
|
|
332
|
+
return this.buf.slice(0, this.len);
|
|
333
|
+
}
|
|
334
|
+
}, Te = [
|
|
335
|
+
255n,
|
|
336
|
+
65535n,
|
|
337
|
+
4294967295n,
|
|
338
|
+
18446744073709551615n
|
|
339
|
+
];
|
|
340
|
+
function Ee(e) {
|
|
341
|
+
return e === "i" ? 23n : Te[e];
|
|
342
|
+
}
|
|
343
|
+
function x(e, t, n, r) {
|
|
344
|
+
if (r === void 0 && typeof n == "number" && n < 4294967296) {
|
|
345
|
+
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));
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
let i = typeof n == "number" ? BigInt(n) : n;
|
|
349
|
+
if (r !== void 0) {
|
|
350
|
+
if (r === "i") {
|
|
351
|
+
if (i > 23n) throw RangeError(`value ${i} does not fit in immediate encoding _i (max 23)`);
|
|
352
|
+
e.writeByte(t << 5 | Number(i));
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (i > Te[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${Te[r]})`);
|
|
356
|
+
let n = 24 + r;
|
|
357
|
+
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);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
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));
|
|
361
|
+
}
|
|
362
|
+
function De(e, t, n) {
|
|
363
|
+
let r = new b(9);
|
|
364
|
+
return x(r, e, t, n), r.finish();
|
|
365
|
+
}
|
|
366
|
+
var Oe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
367
|
+
function ke(e) {
|
|
368
|
+
return Object.is(_(Ce(e)), e);
|
|
369
|
+
}
|
|
370
|
+
function Ae(e) {
|
|
371
|
+
return Oe.setFloat32(0, e, !1), Object.is(Oe.getFloat32(0, !1), e);
|
|
372
|
+
}
|
|
373
|
+
function je(e) {
|
|
374
|
+
return ke(e) ? "half" : Ae(e) ? "single" : "double";
|
|
375
|
+
}
|
|
376
|
+
//#endregion
|
|
242
377
|
//#region src/ast/CborItem.ts
|
|
243
|
-
var
|
|
378
|
+
var S = class e {
|
|
244
379
|
start;
|
|
245
380
|
end;
|
|
246
381
|
comments;
|
|
@@ -250,8 +385,8 @@ var _ = class {
|
|
|
250
385
|
let t = this._defaults ? {
|
|
251
386
|
...this._defaults,
|
|
252
387
|
...e
|
|
253
|
-
} : e;
|
|
254
|
-
return this.
|
|
388
|
+
} : e, n = new b();
|
|
389
|
+
return this._encode(n, t), n.finish();
|
|
255
390
|
}
|
|
256
391
|
toCDN(e) {
|
|
257
392
|
let t = this._defaults ? {
|
|
@@ -281,6 +416,21 @@ var _ = class {
|
|
|
281
416
|
} : e, n = t?.indent ?? 3, r = typeof n == "string" ? n : " ".repeat(n), i = (t?.commentStyle ?? "--") + " ", a = this._toHexDump(0, t), o = Math.max(...a.map((e) => e.depth * r.length + e.hex.length)) + 2;
|
|
282
417
|
return a.map((e) => (r.repeat(e.depth) + e.hex).padEnd(o) + i + e.comment).join("\n");
|
|
283
418
|
}
|
|
419
|
+
_encode(t, n) {
|
|
420
|
+
if (this._toCBOR !== e.prototype._toCBOR) {
|
|
421
|
+
t.writeBytes(this._toCBOR(n));
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
this._encodeTo(t, n);
|
|
425
|
+
}
|
|
426
|
+
_encodeTo(t, n) {
|
|
427
|
+
if (this._toCBOR === e.prototype._toCBOR) throw TypeError("CborItem subclass must implement _encodeTo() or _toCBOR()");
|
|
428
|
+
t.writeBytes(this._toCBOR(n));
|
|
429
|
+
}
|
|
430
|
+
_toCBOR(e) {
|
|
431
|
+
let t = new b();
|
|
432
|
+
return this._encodeTo(t, e), t.finish();
|
|
433
|
+
}
|
|
284
434
|
_toHexDump(e, t) {
|
|
285
435
|
return [{
|
|
286
436
|
depth: e,
|
|
@@ -288,98 +438,7 @@ var _ = class {
|
|
|
288
438
|
comment: this._toCDN(t, 0)
|
|
289
439
|
}];
|
|
290
440
|
}
|
|
291
|
-
},
|
|
292
|
-
function xe(e) {
|
|
293
|
-
be.setFloat64(0, e, !1);
|
|
294
|
-
let t = be.getUint32(0, !1), n = be.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
295
|
-
if (i === 2047) {
|
|
296
|
-
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
297
|
-
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
298
|
-
return r << 15 | 31744 | e & 1023;
|
|
299
|
-
}
|
|
300
|
-
let o = i - 1023 + 15;
|
|
301
|
-
if (o >= 31) return r << 15 | 31744;
|
|
302
|
-
let s, c, l;
|
|
303
|
-
if (o <= 0) {
|
|
304
|
-
if (o < -10) return r << 15;
|
|
305
|
-
let e = 1 << 20 | a, t = 11 - o;
|
|
306
|
-
t <= 20 ? (s = e >> t & 1023, c = e >> t - 1 & 1, l = (e & (1 << t - 1) - 1) != 0 || n !== 0) : (s = 0, c = 1, l = a !== 0 || n !== 0);
|
|
307
|
-
} else s = a >> 10, c = a >> 9 & 1, l = (a & 511) != 0 || n !== 0;
|
|
308
|
-
if (c !== 0 && (l || s & 1) && s++, s >= 1024) {
|
|
309
|
-
let e = o <= 0 ? 1 : o + 1;
|
|
310
|
-
return e >= 31 ? r << 15 | 31744 : r << 15 | e << 10;
|
|
311
|
-
}
|
|
312
|
-
let u = o <= 0 ? 0 : o;
|
|
313
|
-
return r << 15 | u << 10 | s;
|
|
314
|
-
}
|
|
315
|
-
function v(e) {
|
|
316
|
-
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
317
|
-
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);
|
|
318
|
-
}
|
|
319
|
-
var Se = ye ? (e, t, n, r) => {
|
|
320
|
-
e.setFloat16(t, n, r);
|
|
321
|
-
} : (e, t, n, r) => {
|
|
322
|
-
e.setUint16(t, xe(n), r);
|
|
323
|
-
};
|
|
324
|
-
//#endregion
|
|
325
|
-
//#region src/cbor/encode.ts
|
|
326
|
-
function y(e, t, n) {
|
|
327
|
-
if (n !== void 0) {
|
|
328
|
-
if (n === "i") {
|
|
329
|
-
if (t > 23n) throw RangeError(`value ${t} does not fit in immediate encoding _i (max 23)`);
|
|
330
|
-
return new Uint8Array([e << 5 | Number(t)]);
|
|
331
|
-
}
|
|
332
|
-
let r = [
|
|
333
|
-
255n,
|
|
334
|
-
65535n,
|
|
335
|
-
4294967295n,
|
|
336
|
-
18446744073709551615n
|
|
337
|
-
];
|
|
338
|
-
if (t > r[n]) throw RangeError(`value ${t} does not fit in encodingWidth _${n} (max ${r[n]})`);
|
|
339
|
-
let i = 24 + n;
|
|
340
|
-
if (i === 24) return new Uint8Array([e << 5 | 24, Number(t)]);
|
|
341
|
-
if (i === 25) {
|
|
342
|
-
let n = new Uint8Array(3);
|
|
343
|
-
return n[0] = e << 5 | 25, n[1] = Number(t >> 8n), n[2] = Number(t & 255n), n;
|
|
344
|
-
}
|
|
345
|
-
if (i === 26) {
|
|
346
|
-
let n = new Uint8Array(5);
|
|
347
|
-
return n[0] = e << 5 | 26, new DataView(n.buffer).setUint32(1, Number(t), !1), n;
|
|
348
|
-
}
|
|
349
|
-
let a = new Uint8Array(9);
|
|
350
|
-
return a[0] = e << 5 | 27, new DataView(a.buffer).setBigUint64(1, t, !1), a;
|
|
351
|
-
}
|
|
352
|
-
if (t <= 23n) return new Uint8Array([e << 5 | Number(t)]);
|
|
353
|
-
if (t <= 255n) return new Uint8Array([e << 5 | 24, Number(t)]);
|
|
354
|
-
if (t <= 65535n) {
|
|
355
|
-
let n = new Uint8Array(3);
|
|
356
|
-
return n[0] = e << 5 | 25, n[1] = Number(t >> 8n), n[2] = Number(t & 255n), n;
|
|
357
|
-
}
|
|
358
|
-
if (t <= 4294967295n) {
|
|
359
|
-
let n = new Uint8Array(5);
|
|
360
|
-
return n[0] = e << 5 | 26, new DataView(n.buffer).setUint32(1, Number(t), !1), n;
|
|
361
|
-
}
|
|
362
|
-
let r = new Uint8Array(9);
|
|
363
|
-
return r[0] = e << 5 | 27, new DataView(r.buffer).setBigUint64(1, t, !1), r;
|
|
364
|
-
}
|
|
365
|
-
function b(e) {
|
|
366
|
-
let t = e.reduce((e, t) => e + t.length, 0), n = new Uint8Array(t), r = 0;
|
|
367
|
-
for (let t of e) n.set(t, r), r += t.length;
|
|
368
|
-
return n;
|
|
369
|
-
}
|
|
370
|
-
var Ce = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
371
|
-
function we(e) {
|
|
372
|
-
return Object.is(v(xe(e)), e);
|
|
373
|
-
}
|
|
374
|
-
function Te(e) {
|
|
375
|
-
return Ce.setFloat32(0, e, !1), Object.is(Ce.getFloat32(0, !1), e);
|
|
376
|
-
}
|
|
377
|
-
function Ee(e) {
|
|
378
|
-
return we(e) ? "half" : Te(e) ? "single" : "double";
|
|
379
|
-
}
|
|
380
|
-
//#endregion
|
|
381
|
-
//#region src/ast/CborUint.ts
|
|
382
|
-
var x = class extends _ {
|
|
441
|
+
}, C = class extends S {
|
|
383
442
|
value;
|
|
384
443
|
encodingWidth;
|
|
385
444
|
constructor(e, t) {
|
|
@@ -387,8 +446,8 @@ var x = class extends _ {
|
|
|
387
446
|
if (this.value > 18446744073709551615n) throw RangeError("CborUint value exceeds maximum uint64");
|
|
388
447
|
this.encodingWidth = t?.encodingWidth;
|
|
389
448
|
}
|
|
390
|
-
|
|
391
|
-
|
|
449
|
+
_encodeTo(e, t) {
|
|
450
|
+
x(e, 0, this.value, this.encodingWidth);
|
|
392
451
|
}
|
|
393
452
|
_toCDN(e, t) {
|
|
394
453
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.value;
|
|
@@ -403,7 +462,7 @@ var x = class extends _ {
|
|
|
403
462
|
let t = e?.integerAs ?? "auto";
|
|
404
463
|
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
405
464
|
}
|
|
406
|
-
},
|
|
465
|
+
}, w = class extends S {
|
|
407
466
|
argument;
|
|
408
467
|
encodingWidth;
|
|
409
468
|
constructor(e, t) {
|
|
@@ -416,8 +475,8 @@ var x = class extends _ {
|
|
|
416
475
|
get value() {
|
|
417
476
|
return -1n - this.argument;
|
|
418
477
|
}
|
|
419
|
-
|
|
420
|
-
|
|
478
|
+
_encodeTo(e, t) {
|
|
479
|
+
x(e, 1, this.argument, this.encodingWidth);
|
|
421
480
|
}
|
|
422
481
|
_toCDN(e, t) {
|
|
423
482
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.argument + 1n;
|
|
@@ -432,8 +491,8 @@ var x = class extends _ {
|
|
|
432
491
|
let t = this.value, n = e?.integerAs ?? "auto";
|
|
433
492
|
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
434
493
|
}
|
|
435
|
-
},
|
|
436
|
-
function
|
|
494
|
+
}, Me = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
495
|
+
function Ne(e) {
|
|
437
496
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
438
497
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
439
498
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -451,48 +510,39 @@ function Oe(e) {
|
|
|
451
510
|
let l = c * 2 ** o;
|
|
452
511
|
return t ? -l : l;
|
|
453
512
|
}
|
|
454
|
-
function
|
|
513
|
+
function Pe(e) {
|
|
455
514
|
if (isNaN(e)) return "NaN";
|
|
456
515
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
457
516
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
458
517
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
459
|
-
|
|
460
|
-
let r =
|
|
518
|
+
Me.setFloat64(0, n, !1);
|
|
519
|
+
let r = Me.getUint32(0, !1), i = Me.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;
|
|
461
520
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
462
521
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
463
522
|
return t ? `-${p}` : p;
|
|
464
523
|
}
|
|
465
524
|
//#endregion
|
|
466
525
|
//#region src/ast/CborFloat.ts
|
|
467
|
-
var
|
|
526
|
+
var T = class extends S {
|
|
468
527
|
value;
|
|
469
528
|
precision;
|
|
470
529
|
ednSource;
|
|
471
530
|
constructor(e, t) {
|
|
472
531
|
super(), this.value = e, this.precision = t?.precision;
|
|
473
532
|
}
|
|
474
|
-
|
|
475
|
-
let
|
|
476
|
-
|
|
477
|
-
let e = new Uint8Array(3);
|
|
478
|
-
return e[0] = 249, Se(new DataView(e.buffer), 1, this.value, !1), e;
|
|
479
|
-
}
|
|
480
|
-
if (t === "single") {
|
|
481
|
-
let e = new Uint8Array(5);
|
|
482
|
-
return e[0] = 250, new DataView(e.buffer).setFloat32(1, this.value, !1), e;
|
|
483
|
-
}
|
|
484
|
-
let n = new Uint8Array(9);
|
|
485
|
-
return n[0] = 251, new DataView(n.buffer).setFloat64(1, this.value, !1), n;
|
|
533
|
+
_encodeTo(e, t) {
|
|
534
|
+
let n = this.precision ?? je(this.value);
|
|
535
|
+
n === "half" ? (e.writeByte(249), e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), e.writeFloat32(this.value)) : (e.writeByte(251), e.writeFloat64(this.value));
|
|
486
536
|
}
|
|
487
537
|
_toCDN(e, t) {
|
|
488
538
|
if (e?.appStrings !== !1 && this.ednSource !== void 0) return this.ednSource;
|
|
489
|
-
let n =
|
|
490
|
-
return (e?.floatFormat === "hex" ?
|
|
539
|
+
let n = je(this.value);
|
|
540
|
+
return (e?.floatFormat === "hex" ? Pe(this.value) : ye(this.value)) + be(this.value, this.precision, n);
|
|
491
541
|
}
|
|
492
542
|
_toJS(e) {
|
|
493
543
|
return this.value;
|
|
494
544
|
}
|
|
495
|
-
},
|
|
545
|
+
}, E = class extends S {
|
|
496
546
|
tag;
|
|
497
547
|
content;
|
|
498
548
|
encodingWidth;
|
|
@@ -500,8 +550,8 @@ var C = class extends _ {
|
|
|
500
550
|
if (super(), this.tag = BigInt(e), this.tag < 0n) throw RangeError("CborTag tag number must be non-negative");
|
|
501
551
|
this.content = t, this.encodingWidth = n?.encodingWidth;
|
|
502
552
|
}
|
|
503
|
-
|
|
504
|
-
|
|
553
|
+
_encodeTo(e, t) {
|
|
554
|
+
x(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
505
555
|
}
|
|
506
556
|
_toCDN(e, t) {
|
|
507
557
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
@@ -510,7 +560,7 @@ var C = class extends _ {
|
|
|
510
560
|
_toHexDump(e, t) {
|
|
511
561
|
let n = [{
|
|
512
562
|
depth: e,
|
|
513
|
-
hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(
|
|
563
|
+
hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(De(6, this.tag, this.encodingWidth)),
|
|
514
564
|
comment: `Tag ${this.tag}`
|
|
515
565
|
}];
|
|
516
566
|
return n.push(...this.content._toHexDump(e + 1, t)), n;
|
|
@@ -522,7 +572,7 @@ var C = class extends _ {
|
|
|
522
572
|
};
|
|
523
573
|
//#endregion
|
|
524
574
|
//#region src/cdn/tokenizer.ts
|
|
525
|
-
function
|
|
575
|
+
function Fe(e, t) {
|
|
526
576
|
let n = 1, r = 1;
|
|
527
577
|
for (let i = 0; i < t; i++) e[i] === "\n" ? (n++, r = 1) : r++;
|
|
528
578
|
return {
|
|
@@ -530,7 +580,10 @@ function Ae(e, t) {
|
|
|
530
580
|
col: r
|
|
531
581
|
};
|
|
532
582
|
}
|
|
533
|
-
|
|
583
|
+
function D(e) {
|
|
584
|
+
return e >= 48 && e <= 57 || e >= 97 && e <= 102 || e >= 65 && e <= 70;
|
|
585
|
+
}
|
|
586
|
+
var Ie = new TextEncoder(), Le = class {
|
|
534
587
|
input;
|
|
535
588
|
pos;
|
|
536
589
|
line;
|
|
@@ -543,7 +596,7 @@ var je = class {
|
|
|
543
596
|
this.input = e;
|
|
544
597
|
let n = t?.offset ?? 0;
|
|
545
598
|
if (!Number.isInteger(n) || n < 0 || n > e.length) throw RangeError(`EDN parse offset must be an integer between 0 and ${e.length}`);
|
|
546
|
-
let r =
|
|
599
|
+
let r = Fe(e, n);
|
|
547
600
|
this.pos = n, this.line = r.line, this.col = r.col, this._lastConsumedEndOffset = n;
|
|
548
601
|
}
|
|
549
602
|
peek() {
|
|
@@ -574,8 +627,20 @@ var je = class {
|
|
|
574
627
|
}
|
|
575
628
|
_skipWS() {
|
|
576
629
|
for (;;) {
|
|
577
|
-
for (
|
|
578
|
-
|
|
630
|
+
for (;;) {
|
|
631
|
+
let e = this.input[this.pos];
|
|
632
|
+
if (e === void 0) return;
|
|
633
|
+
if (e === " " || e === "\n" || e === " " || e === "\r") {
|
|
634
|
+
this._advance();
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
if (e > " " && e <= "~") break;
|
|
638
|
+
if (/\s/.test(e)) {
|
|
639
|
+
this._advance();
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
579
644
|
let e = this._ch();
|
|
580
645
|
if (e === "#") {
|
|
581
646
|
let e = this.pos, t = this.line, n = this.col;
|
|
@@ -740,81 +805,95 @@ var je = class {
|
|
|
740
805
|
}
|
|
741
806
|
_readStringContent(e) {
|
|
742
807
|
this._advance();
|
|
743
|
-
let t = "";
|
|
808
|
+
let t = e.charCodeAt(0), n = this.input.length, r = "";
|
|
744
809
|
for (; !this._eof() && this._ch() !== e;) {
|
|
745
|
-
let
|
|
746
|
-
|
|
810
|
+
let i = this.pos, a = 0, o = -1;
|
|
811
|
+
for (; i < n;) {
|
|
812
|
+
let e = this.input.charCodeAt(i);
|
|
813
|
+
if (e === t || e === 92 || e === 127) break;
|
|
814
|
+
if (e < 32) {
|
|
815
|
+
if (e !== 10) break;
|
|
816
|
+
a++, o = i;
|
|
817
|
+
}
|
|
818
|
+
i++;
|
|
819
|
+
}
|
|
820
|
+
if (i > this.pos) {
|
|
821
|
+
r += this.input.slice(this.pos, i), a > 0 ? (this.line += a, this.col = i - o) : this.col += i - this.pos, this.pos = i;
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
let s = this._ch();
|
|
825
|
+
if (s === "\r") {
|
|
747
826
|
this._advance();
|
|
748
827
|
continue;
|
|
749
828
|
}
|
|
750
|
-
let
|
|
751
|
-
if ((
|
|
752
|
-
let
|
|
829
|
+
let c = s.codePointAt(0);
|
|
830
|
+
if ((c < 32 && c !== 10 || c === 127) && this._fail(`unescaped control character U+${c.toString(16).padStart(4, "0")} is not allowed in string literals`), s === "\\") {
|
|
831
|
+
let t = this.pos, n = this.line, i = this.col;
|
|
753
832
|
this._advance();
|
|
754
833
|
let a = this._advance();
|
|
755
834
|
switch (a) {
|
|
756
835
|
case "n":
|
|
757
|
-
|
|
836
|
+
r += "\n";
|
|
758
837
|
break;
|
|
759
838
|
case "r":
|
|
760
|
-
|
|
839
|
+
r += "\r";
|
|
761
840
|
break;
|
|
762
841
|
case "t":
|
|
763
|
-
|
|
842
|
+
r += " ";
|
|
764
843
|
break;
|
|
765
844
|
case "b":
|
|
766
|
-
|
|
845
|
+
r += "\b";
|
|
767
846
|
break;
|
|
768
847
|
case "f":
|
|
769
|
-
|
|
848
|
+
r += "\f";
|
|
770
849
|
break;
|
|
771
850
|
case "\\":
|
|
772
|
-
|
|
851
|
+
r += "\\";
|
|
773
852
|
break;
|
|
774
853
|
case "u":
|
|
775
|
-
|
|
854
|
+
r += this._readUnicodeEscape(e, t, n, i);
|
|
776
855
|
break;
|
|
777
856
|
default:
|
|
778
857
|
if (a === e) {
|
|
779
|
-
|
|
858
|
+
r += a;
|
|
780
859
|
break;
|
|
781
860
|
}
|
|
782
861
|
if (a === "/") {
|
|
783
|
-
e === "'" && this._fail("\\/ is not a valid escape in single-quoted byte strings (§5.1)",
|
|
862
|
+
e === "'" && this._fail("\\/ is not a valid escape in single-quoted byte strings (§5.1)", n, i), r += "/";
|
|
784
863
|
break;
|
|
785
864
|
}
|
|
786
865
|
if (this.onEscapeWarning) {
|
|
787
866
|
if (a === "0") {
|
|
788
|
-
this.onEscapeWarning("\\0 is a non-standard escape sequence; use \\u0000 instead",
|
|
867
|
+
this.onEscapeWarning("\\0 is a non-standard escape sequence; use \\u0000 instead", t, n, i), r += "\0";
|
|
789
868
|
break;
|
|
790
869
|
}
|
|
791
870
|
if (a === "v") {
|
|
792
|
-
this.onEscapeWarning("\\v is a non-standard escape sequence; use \\u000b instead",
|
|
871
|
+
this.onEscapeWarning("\\v is a non-standard escape sequence; use \\u000b instead", t, n, i), r += "\v";
|
|
793
872
|
break;
|
|
794
873
|
}
|
|
795
874
|
if (a === "x") {
|
|
796
875
|
let e = this._ch(), a = this.input[this.pos + 1] ?? "";
|
|
797
|
-
(!/[0-9a-fA-F]/.test(e) || !/[0-9a-fA-F]/.test(a)) && this._fail("\\x escape requires exactly two hex digits",
|
|
876
|
+
(!/[0-9a-fA-F]/.test(e) || !/[0-9a-fA-F]/.test(a)) && this._fail("\\x escape requires exactly two hex digits", n, i), this._advance(), this._advance();
|
|
798
877
|
let o = parseInt(e + a, 16);
|
|
799
|
-
this.onEscapeWarning(`\\x${e}${a} is a non-standard escape sequence; use \\u00${e}${a} instead`,
|
|
878
|
+
this.onEscapeWarning(`\\x${e}${a} is a non-standard escape sequence; use \\u00${e}${a} instead`, t, n, i), r += String.fromCharCode(o);
|
|
800
879
|
break;
|
|
801
880
|
}
|
|
802
881
|
if (a === "\"" || a === "'") {
|
|
803
|
-
this.onEscapeWarning(`\\${a} inside ${e === "\"" ? "double" : "single"}-quoted string is non-standard`,
|
|
882
|
+
this.onEscapeWarning(`\\${a} inside ${e === "\"" ? "double" : "single"}-quoted string is non-standard`, t, n, i), r += a;
|
|
804
883
|
break;
|
|
805
884
|
}
|
|
806
885
|
if (a === "\n" || a === "\r") {
|
|
807
|
-
a === "\r" && this._ch() === "\n" && this._advance(), this.onEscapeWarning("line continuation (\\<newline>) is non-standard; the newline is ignored",
|
|
886
|
+
a === "\r" && this._ch() === "\n" && this._advance(), this.onEscapeWarning("line continuation (\\<newline>) is non-standard; the newline is ignored", t, n, i);
|
|
808
887
|
break;
|
|
809
888
|
}
|
|
810
|
-
this.onEscapeWarning(`\\${a} is an unknown escape sequence; interpreted as '${a}'`,
|
|
889
|
+
this.onEscapeWarning(`\\${a} is an unknown escape sequence; interpreted as '${a}'`, t, n, i), r += a;
|
|
811
890
|
break;
|
|
812
891
|
}
|
|
813
|
-
this._fail(`invalid escape sequence \\${a} in ${e === "\"" ? "double" : "single"}-quoted string`,
|
|
892
|
+
this._fail(`invalid escape sequence \\${a} in ${e === "\"" ? "double" : "single"}-quoted string`, n, i);
|
|
814
893
|
}
|
|
815
|
-
} else
|
|
894
|
+
} else r += this._advance();
|
|
816
895
|
}
|
|
817
|
-
return this._eof() && this._fail("unterminated string literal"), this._advance(),
|
|
896
|
+
return this._eof() && this._fail("unterminated string literal"), this._advance(), r;
|
|
818
897
|
}
|
|
819
898
|
_readUnicodeEscape(e, t, n, r) {
|
|
820
899
|
let i = this.line, a = this.col, o = (o) => {
|
|
@@ -858,21 +937,35 @@ var je = class {
|
|
|
858
937
|
let e = this.line, t = this.col, n = 0;
|
|
859
938
|
for (; !this._eof() && this._ch() === "`";) this._advance(), n++;
|
|
860
939
|
!this._eof() && this._ch() === "\r" && this._advance(), !this._eof() && this._ch() === "\n" && this._advance();
|
|
861
|
-
let r = "";
|
|
940
|
+
let r = this.input.length, i = "";
|
|
862
941
|
for (; !this._eof();) {
|
|
863
|
-
let
|
|
864
|
-
|
|
942
|
+
let a = this.pos, o = 0, s = -1;
|
|
943
|
+
for (; a < r;) {
|
|
944
|
+
let e = this.input.charCodeAt(a);
|
|
945
|
+
if (e === 96 || e === 127) break;
|
|
946
|
+
if (e < 32) {
|
|
947
|
+
if (e !== 10) break;
|
|
948
|
+
o++, s = a;
|
|
949
|
+
}
|
|
950
|
+
a++;
|
|
951
|
+
}
|
|
952
|
+
if (a > this.pos) {
|
|
953
|
+
i += this.input.slice(this.pos, a), o > 0 ? (this.line += o, this.col = a - s) : this.col += a - this.pos, this.pos = a;
|
|
954
|
+
continue;
|
|
955
|
+
}
|
|
956
|
+
let c = this._ch();
|
|
957
|
+
if (c === "\r") {
|
|
865
958
|
this._advance();
|
|
866
959
|
continue;
|
|
867
960
|
}
|
|
868
|
-
if (
|
|
869
|
-
let
|
|
870
|
-
for (; !this._eof() && this._ch() === "`";) this._advance(),
|
|
871
|
-
if (
|
|
872
|
-
|
|
961
|
+
if (c === "`") {
|
|
962
|
+
let r = 0;
|
|
963
|
+
for (; !this._eof() && this._ch() === "`";) this._advance(), r++;
|
|
964
|
+
if (r >= n) return i += "`".repeat(r - n), i === "" && this._fail("raw string must not be empty (§2.5.3)", e, t), i;
|
|
965
|
+
i += "`".repeat(r);
|
|
873
966
|
} else {
|
|
874
|
-
let e =
|
|
875
|
-
e < 32 && e !== 10 && e !== 13 && this._fail(`raw string content must not contain control character U+${e.toString(16).toUpperCase().padStart(4, "0")} (§2.5.3)`, this.line, this.col), e === 127 && this._fail("raw string content must not contain DEL (U+007F) (§2.5.3)", this.line, this.col),
|
|
967
|
+
let e = c.codePointAt(0);
|
|
968
|
+
e < 32 && e !== 10 && e !== 13 && this._fail(`raw string content must not contain control character U+${e.toString(16).toUpperCase().padStart(4, "0")} (§2.5.3)`, this.line, this.col), e === 127 && this._fail("raw string content must not contain DEL (U+007F) (§2.5.3)", this.line, this.col), i += this._advance();
|
|
876
969
|
}
|
|
877
970
|
}
|
|
878
971
|
this._fail("unterminated raw string literal", e, t);
|
|
@@ -896,8 +989,10 @@ var je = class {
|
|
|
896
989
|
r += "...", i = !0;
|
|
897
990
|
continue;
|
|
898
991
|
}
|
|
899
|
-
if (
|
|
900
|
-
|
|
992
|
+
if (D(e.charCodeAt(a))) {
|
|
993
|
+
let t = a;
|
|
994
|
+
for (; a < e.length && D(e.charCodeAt(a));) a++;
|
|
995
|
+
r += e.slice(t, a);
|
|
901
996
|
continue;
|
|
902
997
|
}
|
|
903
998
|
throw SyntaxError(`EDN parse error at line ${t}, column ${n}: unexpected character ${JSON.stringify(o)} in h\`\` raw byte string`);
|
|
@@ -920,7 +1015,13 @@ var je = class {
|
|
|
920
1015
|
for (; i < e.length && e[i] !== "\n";) i++;
|
|
921
1016
|
continue;
|
|
922
1017
|
}
|
|
923
|
-
|
|
1018
|
+
let o = i;
|
|
1019
|
+
for (; i < e.length;) {
|
|
1020
|
+
let t = e[i];
|
|
1021
|
+
if (t === "\n" || t === " " || t === "\r" || t === " " || t === "#") break;
|
|
1022
|
+
i++;
|
|
1023
|
+
}
|
|
1024
|
+
r += e.slice(o, i);
|
|
924
1025
|
}
|
|
925
1026
|
return r;
|
|
926
1027
|
}
|
|
@@ -948,7 +1049,13 @@ var je = class {
|
|
|
948
1049
|
}
|
|
949
1050
|
continue;
|
|
950
1051
|
}
|
|
951
|
-
|
|
1052
|
+
let r = this.pos, i = this.pos, a = this.input.length;
|
|
1053
|
+
for (; i < a;) {
|
|
1054
|
+
let t = this.input[i];
|
|
1055
|
+
if (t === e || t === "\n" || t === " " || t === "\r" || t === " " || t === "#") break;
|
|
1056
|
+
i++;
|
|
1057
|
+
}
|
|
1058
|
+
this.col += i - r, this.pos = i, t += this.input.slice(r, i);
|
|
952
1059
|
}
|
|
953
1060
|
return this._eof() && this._fail("unterminated byte string literal"), this._advance(), t;
|
|
954
1061
|
}
|
|
@@ -967,8 +1074,10 @@ var je = class {
|
|
|
967
1074
|
t.endsWith("...") || (t += "..."), n = !0;
|
|
968
1075
|
continue;
|
|
969
1076
|
}
|
|
970
|
-
if (
|
|
971
|
-
|
|
1077
|
+
if (D(r.charCodeAt(0))) {
|
|
1078
|
+
let e = this.pos, n = this.pos, r = this.input.length;
|
|
1079
|
+
for (; n < r && D(this.input.charCodeAt(n));) n++;
|
|
1080
|
+
this.col += n - e, this.pos = n, t += this.input.slice(e, n);
|
|
972
1081
|
continue;
|
|
973
1082
|
}
|
|
974
1083
|
this._fail(`unexpected character ${JSON.stringify(r)} in hex byte string`);
|
|
@@ -1064,22 +1173,9 @@ var je = class {
|
|
|
1064
1173
|
};
|
|
1065
1174
|
this._fail("unexpected character '>'", e, t);
|
|
1066
1175
|
case "+": {
|
|
1067
|
-
let n = this.
|
|
1068
|
-
if (n
|
|
1069
|
-
|
|
1070
|
-
if (!/[a-zA-Z0-9_]/.test(r) || i) {
|
|
1071
|
-
this._advance();
|
|
1072
|
-
for (let e = 0; e < 8; e++) this._advance();
|
|
1073
|
-
let n = "Infinity";
|
|
1074
|
-
return i && (n += this._advance() + this._advance()), {
|
|
1075
|
-
type: "FLOAT",
|
|
1076
|
-
value: n,
|
|
1077
|
-
line: e,
|
|
1078
|
-
col: t
|
|
1079
|
-
};
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
let r = n[0] ?? "";
|
|
1176
|
+
let n = this._readSignedInfinity("+", e, t);
|
|
1177
|
+
if (n !== null) return n;
|
|
1178
|
+
let r = this.input[this.pos + 1] ?? "";
|
|
1083
1179
|
return r >= "0" && r <= "9" || r === "." ? (this._advance(), this._readNumber(e, t)) : (this._advance(), {
|
|
1084
1180
|
type: "PLUS",
|
|
1085
1181
|
value: "+",
|
|
@@ -1114,7 +1210,7 @@ var je = class {
|
|
|
1114
1210
|
line: e,
|
|
1115
1211
|
col: t
|
|
1116
1212
|
};
|
|
1117
|
-
let n = this._readStringContent("'"), r =
|
|
1213
|
+
let n = this._readStringContent("'"), r = Ie.encode(n);
|
|
1118
1214
|
return {
|
|
1119
1215
|
type: "SQSTR",
|
|
1120
1216
|
value: Array.from(r, (e) => e.toString(16).padStart(2, "0")).join(""),
|
|
@@ -1124,40 +1220,8 @@ var je = class {
|
|
|
1124
1220
|
}
|
|
1125
1221
|
}
|
|
1126
1222
|
if (n === "-") {
|
|
1127
|
-
let n = this.
|
|
1128
|
-
|
|
1129
|
-
let r = n[8] ?? "", i = r === "_" && /[0-7i]/.test(n[9] ?? "") && !/[a-zA-Z0-9_]/.test(n[10] ?? "");
|
|
1130
|
-
if (!/[a-zA-Z0-9_]/.test(r) || i) {
|
|
1131
|
-
this._advance();
|
|
1132
|
-
for (let e = 0; e < 8; e++) this._advance();
|
|
1133
|
-
let n = "-Infinity";
|
|
1134
|
-
return i && (n += this._advance() + this._advance()), {
|
|
1135
|
-
type: "FLOAT",
|
|
1136
|
-
value: n,
|
|
1137
|
-
line: e,
|
|
1138
|
-
col: t
|
|
1139
|
-
};
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
return this._readNumber(e, t);
|
|
1143
|
-
}
|
|
1144
|
-
if (n === "+") {
|
|
1145
|
-
let n = this.input.slice(this.pos + 1);
|
|
1146
|
-
if (n.startsWith("Infinity")) {
|
|
1147
|
-
let r = n[8] ?? "", i = r === "_" && /[0-7i]/.test(n[9] ?? "") && !/[a-zA-Z0-9_]/.test(n[10] ?? "");
|
|
1148
|
-
if (!/[a-zA-Z0-9_]/.test(r) || i) {
|
|
1149
|
-
this._advance();
|
|
1150
|
-
for (let e = 0; e < 8; e++) this._advance();
|
|
1151
|
-
let n = "Infinity";
|
|
1152
|
-
return i && (n += this._advance() + this._advance()), {
|
|
1153
|
-
type: "FLOAT",
|
|
1154
|
-
value: n,
|
|
1155
|
-
line: e,
|
|
1156
|
-
col: t
|
|
1157
|
-
};
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
return this._advance(), this._readNumber(e, t);
|
|
1223
|
+
let n = this._readSignedInfinity("-", e, t);
|
|
1224
|
+
return n === null ? this._readNumber(e, t) : n;
|
|
1161
1225
|
}
|
|
1162
1226
|
if (n >= "0" && n <= "9" || n === "." && /[0-9]/.test(this.input[this.pos + 1] ?? "")) return this._readNumber(e, t);
|
|
1163
1227
|
if (/[a-zA-Z_]/.test(n)) return this._readIdent(e, t);
|
|
@@ -1175,110 +1239,137 @@ var je = class {
|
|
|
1175
1239
|
}
|
|
1176
1240
|
this._fail(`unexpected character ${JSON.stringify(n)}`, e, t);
|
|
1177
1241
|
}
|
|
1242
|
+
_readSignedInfinity(e, t, n) {
|
|
1243
|
+
if (!this.input.startsWith("Infinity", this.pos + 1)) return null;
|
|
1244
|
+
let r = this.input[this.pos + 9] ?? "", i = r === "_" && /[0-7i]/.test(this.input[this.pos + 10] ?? "") && !/[a-zA-Z0-9_]/.test(this.input[this.pos + 11] ?? "");
|
|
1245
|
+
if (/[a-zA-Z0-9_]/.test(r) && !i) return null;
|
|
1246
|
+
this._advance();
|
|
1247
|
+
for (let e = 0; e < 8; e++) this._advance();
|
|
1248
|
+
let a = e === "-" ? "-Infinity" : "Infinity";
|
|
1249
|
+
return i && (a += this._advance() + this._advance()), {
|
|
1250
|
+
type: "FLOAT",
|
|
1251
|
+
value: a,
|
|
1252
|
+
line: t,
|
|
1253
|
+
col: n
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
_skipHexDigits() {
|
|
1257
|
+
let e = this.pos, t = this.input.length;
|
|
1258
|
+
for (; e < t && D(this.input.charCodeAt(e));) e++;
|
|
1259
|
+
this.col += e - this.pos, this.pos = e;
|
|
1260
|
+
}
|
|
1261
|
+
_skipDecimalDigits() {
|
|
1262
|
+
let e = this.pos, t = this.input.length;
|
|
1263
|
+
for (; e < t;) {
|
|
1264
|
+
let t = this.input.charCodeAt(e);
|
|
1265
|
+
if (t < 48 || t > 57) break;
|
|
1266
|
+
e++;
|
|
1267
|
+
}
|
|
1268
|
+
this.col += e - this.pos, this.pos = e;
|
|
1269
|
+
}
|
|
1270
|
+
_tryConsumeEncodingSuffix() {
|
|
1271
|
+
if (this._ch() !== "_") return;
|
|
1272
|
+
let e = this.input[this.pos + 1] ?? "", t = this.input[this.pos + 2] ?? "";
|
|
1273
|
+
(e >= "0" && e <= "7" || e === "i") && !/[0-9a-zA-Z_]/.test(t) && (this._advance(), this._advance());
|
|
1274
|
+
}
|
|
1178
1275
|
_readNumber(e, t) {
|
|
1179
|
-
let n =
|
|
1180
|
-
if (this._ch() === "-" &&
|
|
1181
|
-
let
|
|
1182
|
-
if (
|
|
1183
|
-
|
|
1184
|
-
let
|
|
1185
|
-
|
|
1186
|
-
let i =
|
|
1276
|
+
let n = this.pos, r = () => this.input.slice(n, this.pos);
|
|
1277
|
+
if (this._ch() === "-" && this._advance(), this._ch() === "0") {
|
|
1278
|
+
let n = this.input[this.pos + 1] ?? "";
|
|
1279
|
+
if (n === "x" || n === "X") {
|
|
1280
|
+
this._advance(), this._advance();
|
|
1281
|
+
let n = this.pos;
|
|
1282
|
+
this._skipHexDigits();
|
|
1283
|
+
let i = this.pos > n, a = !1, o = !1;
|
|
1187
1284
|
if (!this._eof() && this._ch() === ".") {
|
|
1188
|
-
a = !0,
|
|
1189
|
-
let e =
|
|
1190
|
-
|
|
1191
|
-
o = n.length > e;
|
|
1285
|
+
a = !0, this._advance();
|
|
1286
|
+
let e = this.pos;
|
|
1287
|
+
this._skipHexDigits(), o = this.pos > e;
|
|
1192
1288
|
}
|
|
1193
1289
|
if (!this._eof() && (this._ch() === "p" || this._ch() === "P")) {
|
|
1194
|
-
a = !0, !i && !o && this._fail(`hex float has no mantissa digits: ${
|
|
1195
|
-
let
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
return {
|
|
1205
|
-
type: "FLOAT",
|
|
1206
|
-
value: n,
|
|
1207
|
-
line: e,
|
|
1208
|
-
col: t
|
|
1209
|
-
};
|
|
1210
|
-
}
|
|
1211
|
-
return {
|
|
1290
|
+
a = !0, !i && !o && this._fail(`hex float has no mantissa digits: ${r()}`, e, t), this._advance(), !this._eof() && (this._ch() === "+" || this._ch() === "-") && this._advance();
|
|
1291
|
+
let n = this.pos;
|
|
1292
|
+
this._skipDecimalDigits(), this.pos === n && this._fail(`hex float missing exponent digits: ${r()}`, e, t);
|
|
1293
|
+
} else a && this._fail(`hex float missing 'p' exponent: ${r()}`, e, t);
|
|
1294
|
+
return a ? (this._tryConsumeEncodingSuffix(), {
|
|
1295
|
+
type: "FLOAT",
|
|
1296
|
+
value: r(),
|
|
1297
|
+
line: e,
|
|
1298
|
+
col: t
|
|
1299
|
+
}) : {
|
|
1212
1300
|
type: "INTEGER",
|
|
1213
|
-
value:
|
|
1301
|
+
value: r(),
|
|
1214
1302
|
line: e,
|
|
1215
1303
|
col: t
|
|
1216
1304
|
};
|
|
1217
1305
|
}
|
|
1218
|
-
if (
|
|
1219
|
-
for (
|
|
1306
|
+
if (n === "o" || n === "O") {
|
|
1307
|
+
for (this._advance(), this._advance(); !this._eof() && this._ch() >= "0" && this._ch() <= "7";) this._advance();
|
|
1220
1308
|
return {
|
|
1221
1309
|
type: "INTEGER",
|
|
1222
|
-
value:
|
|
1310
|
+
value: r(),
|
|
1223
1311
|
line: e,
|
|
1224
1312
|
col: t
|
|
1225
1313
|
};
|
|
1226
1314
|
}
|
|
1227
|
-
if (
|
|
1228
|
-
for (
|
|
1315
|
+
if (n === "b" || n === "B") {
|
|
1316
|
+
for (this._advance(), this._advance(); !this._eof() && (this._ch() === "0" || this._ch() === "1");) this._advance();
|
|
1229
1317
|
return {
|
|
1230
1318
|
type: "INTEGER",
|
|
1231
|
-
value:
|
|
1319
|
+
value: r(),
|
|
1232
1320
|
line: e,
|
|
1233
1321
|
col: t
|
|
1234
1322
|
};
|
|
1235
1323
|
}
|
|
1236
1324
|
}
|
|
1237
|
-
|
|
1238
|
-
let
|
|
1239
|
-
if (!this._eof() && this._ch() === "."
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
for (; !this._eof() && this._ch() >= "0" && this._ch() <= "9";) n += this._advance();
|
|
1244
|
-
n.length === i && this._fail(`float exponent has no digits: ${JSON.stringify(n)}`, e, t);
|
|
1325
|
+
this._skipDecimalDigits();
|
|
1326
|
+
let i = !1;
|
|
1327
|
+
if (!this._eof() && this._ch() === "." && (i = !0, this._advance(), this._skipDecimalDigits()), !this._eof() && (this._ch() === "e" || this._ch() === "E")) {
|
|
1328
|
+
i = !0, this._advance(), !this._eof() && (this._ch() === "+" || this._ch() === "-") && this._advance();
|
|
1329
|
+
let n = this.pos;
|
|
1330
|
+
this._skipDecimalDigits(), this.pos === n && this._fail(`float exponent has no digits: ${JSON.stringify(r())}`, e, t);
|
|
1245
1331
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
}
|
|
1250
|
-
return {
|
|
1251
|
-
type: r ? "FLOAT" : "INTEGER",
|
|
1252
|
-
value: n,
|
|
1332
|
+
return this._tryConsumeEncodingSuffix(), {
|
|
1333
|
+
type: i ? "FLOAT" : "INTEGER",
|
|
1334
|
+
value: r(),
|
|
1253
1335
|
line: e,
|
|
1254
1336
|
col: t
|
|
1255
1337
|
};
|
|
1256
1338
|
}
|
|
1257
1339
|
_readIdent(e, t) {
|
|
1258
|
-
let n =
|
|
1259
|
-
|
|
1260
|
-
|
|
1340
|
+
let n = this.pos;
|
|
1341
|
+
{
|
|
1342
|
+
let e = this.pos, t = this.input.length;
|
|
1343
|
+
for (; e < t;) {
|
|
1344
|
+
let t = this.input.charCodeAt(e);
|
|
1345
|
+
if (!(t >= 97 && t <= 122 || t >= 65 && t <= 90 || t >= 48 && t <= 57 || t === 95)) break;
|
|
1346
|
+
e++;
|
|
1347
|
+
}
|
|
1348
|
+
this.col += e - this.pos, this.pos = e;
|
|
1349
|
+
}
|
|
1350
|
+
let r = this.input.slice(n, this.pos);
|
|
1351
|
+
switch (r) {
|
|
1261
1352
|
case "true": return {
|
|
1262
1353
|
type: "TRUE",
|
|
1263
|
-
value:
|
|
1354
|
+
value: r,
|
|
1264
1355
|
line: e,
|
|
1265
1356
|
col: t
|
|
1266
1357
|
};
|
|
1267
1358
|
case "false": return {
|
|
1268
1359
|
type: "FALSE",
|
|
1269
|
-
value:
|
|
1360
|
+
value: r,
|
|
1270
1361
|
line: e,
|
|
1271
1362
|
col: t
|
|
1272
1363
|
};
|
|
1273
1364
|
case "null": return {
|
|
1274
1365
|
type: "NULL",
|
|
1275
|
-
value:
|
|
1366
|
+
value: r,
|
|
1276
1367
|
line: e,
|
|
1277
1368
|
col: t
|
|
1278
1369
|
};
|
|
1279
1370
|
case "undefined": return {
|
|
1280
1371
|
type: "UNDEFINED",
|
|
1281
|
-
value:
|
|
1372
|
+
value: r,
|
|
1282
1373
|
line: e,
|
|
1283
1374
|
col: t
|
|
1284
1375
|
};
|
|
@@ -1303,13 +1394,13 @@ var je = class {
|
|
|
1303
1394
|
case "Infinity_7":
|
|
1304
1395
|
case "Infinity_i": return {
|
|
1305
1396
|
type: "FLOAT",
|
|
1306
|
-
value:
|
|
1397
|
+
value: r,
|
|
1307
1398
|
line: e,
|
|
1308
1399
|
col: t
|
|
1309
1400
|
};
|
|
1310
1401
|
case "simple": return {
|
|
1311
1402
|
type: "SIMPLE",
|
|
1312
|
-
value:
|
|
1403
|
+
value: r,
|
|
1313
1404
|
line: e,
|
|
1314
1405
|
col: t
|
|
1315
1406
|
};
|
|
@@ -1374,21 +1465,23 @@ var je = class {
|
|
|
1374
1465
|
col: t
|
|
1375
1466
|
};
|
|
1376
1467
|
}
|
|
1377
|
-
let
|
|
1378
|
-
if (
|
|
1379
|
-
let
|
|
1380
|
-
if (
|
|
1468
|
+
let i = r[0] ?? "", a = i >= "a" && i <= "z";
|
|
1469
|
+
if (a || i >= "A" && i <= "Z") {
|
|
1470
|
+
let n = r.slice(1);
|
|
1471
|
+
if (a ? /^[a-z0-9]*$/.test(n) : /^[A-Z0-9]*$/.test(n)) {
|
|
1472
|
+
let n = this.pos;
|
|
1381
1473
|
for (; !this._eof();) {
|
|
1382
1474
|
let e = this._ch();
|
|
1383
|
-
if (!(
|
|
1384
|
-
|
|
1475
|
+
if (!(a ? e >= "a" && e <= "z" || e >= "0" && e <= "9" || e === "-" : e >= "A" && e <= "Z" || e >= "0" && e <= "9" || e === "-")) break;
|
|
1476
|
+
this.pos++;
|
|
1385
1477
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1478
|
+
this.pos > n && (this.col += this.pos - n, r += this.input.slice(n, this.pos));
|
|
1479
|
+
let i = this._ch();
|
|
1480
|
+
if (i === "\"" && this._fail(`"${r}" prefix requires single quotes or backticks, not double quotes`, e, t), i === "'") switch (r) {
|
|
1388
1481
|
case "h": {
|
|
1389
|
-
let { value: n, elided:
|
|
1482
|
+
let { value: n, elided: r } = this._readHexByteContentElisionAware(i);
|
|
1390
1483
|
return {
|
|
1391
|
-
type:
|
|
1484
|
+
type: r ? "BYTES_HEX_ELIDED" : "BYTES_HEX",
|
|
1392
1485
|
value: n,
|
|
1393
1486
|
line: e,
|
|
1394
1487
|
col: t
|
|
@@ -1396,57 +1489,57 @@ var je = class {
|
|
|
1396
1489
|
}
|
|
1397
1490
|
case "b64": return {
|
|
1398
1491
|
type: "BYTES_B64",
|
|
1399
|
-
value: this._readByteContent(
|
|
1492
|
+
value: this._readByteContent(i),
|
|
1400
1493
|
line: e,
|
|
1401
1494
|
col: t
|
|
1402
1495
|
};
|
|
1403
1496
|
default: return {
|
|
1404
1497
|
type: "APP_STRING",
|
|
1405
|
-
appPrefix:
|
|
1406
|
-
value: this._readStringContent(
|
|
1498
|
+
appPrefix: r,
|
|
1499
|
+
value: this._readStringContent(i),
|
|
1407
1500
|
line: e,
|
|
1408
1501
|
col: t
|
|
1409
1502
|
};
|
|
1410
1503
|
}
|
|
1411
|
-
if (
|
|
1412
|
-
let
|
|
1413
|
-
switch (
|
|
1504
|
+
if (i === "`") {
|
|
1505
|
+
let n = this._readRawStringContent();
|
|
1506
|
+
switch (r) {
|
|
1414
1507
|
case "h": {
|
|
1415
|
-
let { value:
|
|
1508
|
+
let { value: r, elided: i } = this._processRawHexContent(n, e, t);
|
|
1416
1509
|
return {
|
|
1417
1510
|
type: i ? "BYTES_HEX_ELIDED" : "BYTES_HEX",
|
|
1418
|
-
value:
|
|
1511
|
+
value: r,
|
|
1419
1512
|
line: e,
|
|
1420
1513
|
col: t
|
|
1421
1514
|
};
|
|
1422
1515
|
}
|
|
1423
1516
|
case "b64": return {
|
|
1424
1517
|
type: "BYTES_B64",
|
|
1425
|
-
value: this._processRawB64Content(
|
|
1518
|
+
value: this._processRawB64Content(n, e, t),
|
|
1426
1519
|
line: e,
|
|
1427
1520
|
col: t
|
|
1428
1521
|
};
|
|
1429
1522
|
default: return {
|
|
1430
1523
|
type: "APP_STRING",
|
|
1431
|
-
appPrefix:
|
|
1432
|
-
value:
|
|
1524
|
+
appPrefix: r,
|
|
1525
|
+
value: n,
|
|
1433
1526
|
line: e,
|
|
1434
1527
|
col: t
|
|
1435
1528
|
};
|
|
1436
1529
|
}
|
|
1437
1530
|
}
|
|
1438
|
-
if (
|
|
1531
|
+
if (i === "<" && (this.input[this.pos + 1] ?? "") === "<") return this._advance(), this._advance(), {
|
|
1439
1532
|
type: "APP_SEQUENCE",
|
|
1440
|
-
appPrefix:
|
|
1533
|
+
appPrefix: r,
|
|
1441
1534
|
value: "",
|
|
1442
1535
|
line: e,
|
|
1443
1536
|
col: t
|
|
1444
1537
|
};
|
|
1445
1538
|
}
|
|
1446
1539
|
}
|
|
1447
|
-
this._fail(`unknown identifier ${JSON.stringify(
|
|
1540
|
+
this._fail(`unknown identifier ${JSON.stringify(r)}`, e, t);
|
|
1448
1541
|
}
|
|
1449
|
-
},
|
|
1542
|
+
}, O = class extends S {
|
|
1450
1543
|
indefiniteLength = !1;
|
|
1451
1544
|
value;
|
|
1452
1545
|
ednEncoding;
|
|
@@ -1455,8 +1548,8 @@ var je = class {
|
|
|
1455
1548
|
constructor(e, t) {
|
|
1456
1549
|
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
1457
1550
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1551
|
+
_encodeTo(e, t) {
|
|
1552
|
+
x(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
|
|
1460
1553
|
}
|
|
1461
1554
|
_toCDN(e, t) {
|
|
1462
1555
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
@@ -1467,16 +1560,16 @@ var je = class {
|
|
|
1467
1560
|
_toJS(e) {
|
|
1468
1561
|
return this.value;
|
|
1469
1562
|
}
|
|
1470
|
-
},
|
|
1563
|
+
}, k = class extends S {
|
|
1471
1564
|
indefiniteLength = !0;
|
|
1472
1565
|
chunks;
|
|
1473
1566
|
constructor(e) {
|
|
1474
1567
|
super(), this.chunks = e;
|
|
1475
1568
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
for (let n of this.chunks)
|
|
1479
|
-
|
|
1569
|
+
_encodeTo(e, t) {
|
|
1570
|
+
e.writeByte(95);
|
|
1571
|
+
for (let n of this.chunks) n._encode(e, t);
|
|
1572
|
+
e.writeByte(255);
|
|
1480
1573
|
}
|
|
1481
1574
|
_toCDN(e, t) {
|
|
1482
1575
|
return this.chunks.length === 0 ? "''_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
@@ -1499,16 +1592,16 @@ var je = class {
|
|
|
1499
1592
|
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
1500
1593
|
return n;
|
|
1501
1594
|
}
|
|
1502
|
-
},
|
|
1595
|
+
}, A = class extends S {
|
|
1503
1596
|
indefiniteLength = !0;
|
|
1504
1597
|
chunks;
|
|
1505
1598
|
constructor(e) {
|
|
1506
1599
|
super(), this.chunks = e;
|
|
1507
1600
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
for (let n of this.chunks)
|
|
1511
|
-
|
|
1601
|
+
_encodeTo(e, t) {
|
|
1602
|
+
e.writeByte(127);
|
|
1603
|
+
for (let n of this.chunks) n._encode(e, t);
|
|
1604
|
+
e.writeByte(255);
|
|
1512
1605
|
}
|
|
1513
1606
|
_toCDN(e, t) {
|
|
1514
1607
|
return this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
|
|
@@ -1529,22 +1622,22 @@ var je = class {
|
|
|
1529
1622
|
_toJS(e) {
|
|
1530
1623
|
return this.chunks.map((e) => e.value).join("");
|
|
1531
1624
|
}
|
|
1532
|
-
},
|
|
1625
|
+
}, j = class extends S {
|
|
1533
1626
|
items;
|
|
1534
1627
|
indefiniteLength;
|
|
1535
1628
|
encodingWidth;
|
|
1536
1629
|
constructor(e, t) {
|
|
1537
1630
|
super(), this.items = e, this.indefiniteLength = t?.indefiniteLength ?? !1, this.encodingWidth = t?.encodingWidth;
|
|
1538
1631
|
}
|
|
1539
|
-
|
|
1632
|
+
_encodeTo(e, t) {
|
|
1540
1633
|
if (this.indefiniteLength) {
|
|
1541
|
-
|
|
1542
|
-
for (let n of this.items)
|
|
1543
|
-
|
|
1634
|
+
e.writeByte(159);
|
|
1635
|
+
for (let n of this.items) n._encode(e, t);
|
|
1636
|
+
e.writeByte(255);
|
|
1637
|
+
return;
|
|
1544
1638
|
}
|
|
1545
|
-
|
|
1546
|
-
for (let n of this.items)
|
|
1547
|
-
return b(t);
|
|
1639
|
+
x(e, 4, this.items.length, this.encodingWidth);
|
|
1640
|
+
for (let n of this.items) n._encode(e, t);
|
|
1548
1641
|
}
|
|
1549
1642
|
_toCDN(e, t) {
|
|
1550
1643
|
let n = d(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ee(this) || this.items.some(p));
|
|
@@ -1580,7 +1673,7 @@ var je = class {
|
|
|
1580
1673
|
}
|
|
1581
1674
|
let i = [{
|
|
1582
1675
|
depth: e,
|
|
1583
|
-
hex: r(
|
|
1676
|
+
hex: r(De(4, BigInt(this.items.length), this.encodingWidth)),
|
|
1584
1677
|
comment: `Array of length ${this.items.length}`
|
|
1585
1678
|
}];
|
|
1586
1679
|
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
@@ -1599,22 +1692,22 @@ var je = class {
|
|
|
1599
1692
|
}
|
|
1600
1693
|
return r;
|
|
1601
1694
|
}
|
|
1602
|
-
},
|
|
1695
|
+
}, M = class extends S {
|
|
1603
1696
|
entries;
|
|
1604
1697
|
indefiniteLength;
|
|
1605
1698
|
encodingWidth;
|
|
1606
1699
|
constructor(e, t) {
|
|
1607
1700
|
super(), this.entries = e, this.indefiniteLength = t?.indefiniteLength ?? !1, this.encodingWidth = t?.encodingWidth;
|
|
1608
1701
|
}
|
|
1609
|
-
|
|
1702
|
+
_encodeTo(e, t) {
|
|
1610
1703
|
if (this.indefiniteLength) {
|
|
1611
|
-
|
|
1612
|
-
for (let [n, r] of this.entries)
|
|
1613
|
-
|
|
1704
|
+
e.writeByte(191);
|
|
1705
|
+
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
1706
|
+
e.writeByte(255);
|
|
1707
|
+
return;
|
|
1614
1708
|
}
|
|
1615
|
-
|
|
1616
|
-
for (let [n, r] of this.entries)
|
|
1617
|
-
return b(t);
|
|
1709
|
+
x(e, 5, this.entries.length, this.encodingWidth);
|
|
1710
|
+
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
1618
1711
|
}
|
|
1619
1712
|
_toCDN(e, t) {
|
|
1620
1713
|
let n = d(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ee(this) || this.entries.some(([e, t]) => p(e) || p(t)));
|
|
@@ -1628,7 +1721,7 @@ var je = class {
|
|
|
1628
1721
|
for (let n = 0; n < this.entries.length; n++) {
|
|
1629
1722
|
let [a, o] = this.entries[n];
|
|
1630
1723
|
r && g.push(...te(a, h, i));
|
|
1631
|
-
let u = n < this.entries.length - 1 ? s : c, d = r ?
|
|
1724
|
+
let u = n < this.entries.length - 1 ? s : c, d = r ? Re([
|
|
1632
1725
|
...a.comments?.trailing ?? [],
|
|
1633
1726
|
...o.comments?.leading ?? [],
|
|
1634
1727
|
...o.comments?.trailing ?? []
|
|
@@ -1654,7 +1747,7 @@ var je = class {
|
|
|
1654
1747
|
}
|
|
1655
1748
|
let i = [{
|
|
1656
1749
|
depth: e,
|
|
1657
|
-
hex: r(
|
|
1750
|
+
hex: r(De(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
1658
1751
|
comment: `Map of length ${this.entries.length}`
|
|
1659
1752
|
}];
|
|
1660
1753
|
for (let [n, r] of this.entries) i.push(...n._toHexDump(e + 1, t)), i.push(...r._toHexDump(e + 1, t));
|
|
@@ -1671,13 +1764,13 @@ var je = class {
|
|
|
1671
1764
|
}
|
|
1672
1765
|
return n;
|
|
1673
1766
|
};
|
|
1674
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
1767
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof B) ? (() => {
|
|
1675
1768
|
let n = e ? {
|
|
1676
1769
|
...e,
|
|
1677
1770
|
reviver: void 0
|
|
1678
1771
|
} : void 0, r = {};
|
|
1679
1772
|
for (let [e, t] of this.entries) {
|
|
1680
|
-
let i = e instanceof
|
|
1773
|
+
let i = e instanceof B ? e.value : e.toCDN(), a = t._toJS(n);
|
|
1681
1774
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
1682
1775
|
value: a,
|
|
1683
1776
|
writable: !0,
|
|
@@ -1689,10 +1782,10 @@ var je = class {
|
|
|
1689
1782
|
let i = /* @__PURE__ */ new Map();
|
|
1690
1783
|
for (let e = 0; e < this.entries.length; e++) {
|
|
1691
1784
|
let [t] = this.entries[e];
|
|
1692
|
-
i.set(t instanceof
|
|
1785
|
+
i.set(t instanceof B ? t.value : t.toCDN(), e);
|
|
1693
1786
|
}
|
|
1694
1787
|
for (let n = 0; n < this.entries.length; n++) {
|
|
1695
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
1788
|
+
let [a, o] = this.entries[n], s = a instanceof B ? a.value : a.toCDN();
|
|
1696
1789
|
if (i.get(s) !== n) continue;
|
|
1697
1790
|
let c = o._toJS(e), u = t.call(r, s, c);
|
|
1698
1791
|
u === l || e?.undefinedOmits && u === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
@@ -1706,12 +1799,12 @@ var je = class {
|
|
|
1706
1799
|
})() : n();
|
|
1707
1800
|
}
|
|
1708
1801
|
};
|
|
1709
|
-
function
|
|
1802
|
+
function Re(e, t) {
|
|
1710
1803
|
return e.length === 0 ? "" : " " + e.map((e) => m(e, t).trimEnd()).join(" ");
|
|
1711
1804
|
}
|
|
1712
1805
|
//#endregion
|
|
1713
1806
|
//#region src/ast/CborSimple.ts
|
|
1714
|
-
var
|
|
1807
|
+
var N = class e extends S {
|
|
1715
1808
|
value;
|
|
1716
1809
|
constructor(e) {
|
|
1717
1810
|
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
@@ -1721,8 +1814,12 @@ var A = class e extends _ {
|
|
|
1721
1814
|
static TRUE = new e(21);
|
|
1722
1815
|
static NULL = new e(22);
|
|
1723
1816
|
static UNDEFINED = new e(23);
|
|
1724
|
-
|
|
1725
|
-
|
|
1817
|
+
_encodeTo(e, t) {
|
|
1818
|
+
if (this.value <= 23) {
|
|
1819
|
+
e.writeByte(224 | this.value);
|
|
1820
|
+
return;
|
|
1821
|
+
}
|
|
1822
|
+
e.writeByte(248), e.writeByte(this.value);
|
|
1726
1823
|
}
|
|
1727
1824
|
_toCDN(e, t) {
|
|
1728
1825
|
switch (this.value) {
|
|
@@ -1742,17 +1839,19 @@ var A = class e extends _ {
|
|
|
1742
1839
|
default: return new u(this.value);
|
|
1743
1840
|
}
|
|
1744
1841
|
}
|
|
1745
|
-
},
|
|
1842
|
+
}, P = class extends S {
|
|
1746
1843
|
items;
|
|
1747
1844
|
constructor(e) {
|
|
1748
1845
|
super(), this.items = e;
|
|
1749
1846
|
}
|
|
1750
1847
|
_content(e) {
|
|
1751
|
-
|
|
1848
|
+
let t = new b();
|
|
1849
|
+
for (let n of this.items) n._encode(t, e);
|
|
1850
|
+
return t.finish();
|
|
1752
1851
|
}
|
|
1753
|
-
|
|
1754
|
-
let
|
|
1755
|
-
|
|
1852
|
+
_encodeTo(e, t) {
|
|
1853
|
+
let n = this._content(t);
|
|
1854
|
+
x(e, 2, n.length), e.writeBytes(n);
|
|
1756
1855
|
}
|
|
1757
1856
|
_toCDN(e, t) {
|
|
1758
1857
|
if (this.items.length === 0) return "<<>>";
|
|
@@ -1764,7 +1863,7 @@ var A = class e extends _ {
|
|
|
1764
1863
|
_toHexDump(e, t) {
|
|
1765
1864
|
let n = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "), r = this._content().length, i = [{
|
|
1766
1865
|
depth: e,
|
|
1767
|
-
hex: n(
|
|
1866
|
+
hex: n(De(2, BigInt(r))),
|
|
1768
1867
|
comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
|
|
1769
1868
|
}];
|
|
1770
1869
|
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
@@ -1773,24 +1872,24 @@ var A = class e extends _ {
|
|
|
1773
1872
|
_toJS(e) {
|
|
1774
1873
|
return this._content();
|
|
1775
1874
|
}
|
|
1776
|
-
},
|
|
1875
|
+
}, ze = 999n, F = class extends E {
|
|
1777
1876
|
constructor(e, t) {
|
|
1778
|
-
let n = t.length === 1 && t[0] instanceof
|
|
1779
|
-
super(
|
|
1877
|
+
let n = t.length === 1 && t[0] instanceof B ? t[0] : new j(t);
|
|
1878
|
+
super(ze, new j([new B(e), n]));
|
|
1780
1879
|
}
|
|
1781
1880
|
_toCDN(e, t) {
|
|
1782
1881
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1783
1882
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
1784
|
-
return i instanceof
|
|
1883
|
+
return i instanceof B ? `${r}${_e(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
1785
1884
|
}
|
|
1786
|
-
},
|
|
1885
|
+
}, Be = class extends S {
|
|
1787
1886
|
inner;
|
|
1788
1887
|
ednSource;
|
|
1789
1888
|
constructor(e, t) {
|
|
1790
1889
|
super(), this.inner = e, this.ednSource = t;
|
|
1791
1890
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1891
|
+
_encodeTo(e, t) {
|
|
1892
|
+
this.inner._encode(e, t);
|
|
1794
1893
|
}
|
|
1795
1894
|
_toCDN(e, t) {
|
|
1796
1895
|
return e?.appStrings === !1 ? this.inner._toCDN(e, t) : this.ednSource;
|
|
@@ -1798,15 +1897,15 @@ var A = class e extends _ {
|
|
|
1798
1897
|
_toJS(e) {
|
|
1799
1898
|
return this.inner._toJS(e);
|
|
1800
1899
|
}
|
|
1801
|
-
},
|
|
1900
|
+
}, Ve = 888n, I = class extends E {
|
|
1802
1901
|
constructor(e) {
|
|
1803
|
-
e === void 0 ? super(
|
|
1902
|
+
e === void 0 ? super(Ve, N.NULL) : super(Ve, new j(e));
|
|
1804
1903
|
}
|
|
1805
1904
|
_toCDN(e, t) {
|
|
1806
|
-
return this.content instanceof
|
|
1905
|
+
return this.content instanceof N ? "..." : this.content instanceof j ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
|
|
1807
1906
|
}
|
|
1808
|
-
},
|
|
1809
|
-
function
|
|
1907
|
+
}, He = 2n, Ue = 3n, We = 18446744073709551615n, Ge = -18446744073709551616n;
|
|
1908
|
+
function Ke(e) {
|
|
1810
1909
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
1811
1910
|
if (e === 0n) return new Uint8Array();
|
|
1812
1911
|
let t = e.toString(16);
|
|
@@ -1815,16 +1914,16 @@ function Be(e) {
|
|
|
1815
1914
|
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
1816
1915
|
return n;
|
|
1817
1916
|
}
|
|
1818
|
-
function
|
|
1917
|
+
function qe(e) {
|
|
1819
1918
|
let t = 0n;
|
|
1820
1919
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
1821
1920
|
return t;
|
|
1822
1921
|
}
|
|
1823
|
-
var
|
|
1922
|
+
var L = class extends E {
|
|
1824
1923
|
bigValue;
|
|
1825
1924
|
constructor(e) {
|
|
1826
|
-
if (e <=
|
|
1827
|
-
super(
|
|
1925
|
+
if (e <= We) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1926
|
+
super(He, new O(Ke(e))), this.bigValue = e;
|
|
1828
1927
|
}
|
|
1829
1928
|
_toCDN(e, t) {
|
|
1830
1929
|
return this.bigValue.toString();
|
|
@@ -1832,11 +1931,11 @@ var P = class extends w {
|
|
|
1832
1931
|
_toJS(e) {
|
|
1833
1932
|
return this.bigValue;
|
|
1834
1933
|
}
|
|
1835
|
-
},
|
|
1934
|
+
}, R = class extends E {
|
|
1836
1935
|
bigValue;
|
|
1837
1936
|
constructor(e) {
|
|
1838
|
-
if (e >=
|
|
1839
|
-
super(
|
|
1937
|
+
if (e >= Ge) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1938
|
+
super(Ue, new O(Ke(-1n - e))), this.bigValue = e;
|
|
1840
1939
|
}
|
|
1841
1940
|
_toCDN(e, t) {
|
|
1842
1941
|
return this.bigValue.toString();
|
|
@@ -1844,24 +1943,22 @@ var P = class extends w {
|
|
|
1844
1943
|
_toJS(e) {
|
|
1845
1944
|
return this.bigValue;
|
|
1846
1945
|
}
|
|
1847
|
-
};
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
let n = new je(e, { offset: t?.offset }), r = new Qe(n, t ?? {}).parse();
|
|
1852
|
-
return t?.preserveComments && Je(r, n.comments, e), r;
|
|
1946
|
+
}, Je = new TextEncoder(), Ye = new TextDecoder("utf-8", { fatal: !0 }), Xe = new TextDecoder("utf-8", { fatal: !1 });
|
|
1947
|
+
function Ze(e, t) {
|
|
1948
|
+
let n = new Le(e, { offset: t?.offset }), r = new lt(n, t ?? {}).parse();
|
|
1949
|
+
return t?.preserveComments && rt(r, n.comments, e), r;
|
|
1853
1950
|
}
|
|
1854
|
-
function
|
|
1951
|
+
function Qe(e) {
|
|
1855
1952
|
let t = e, n;
|
|
1856
1953
|
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1857
1954
|
numStr: t,
|
|
1858
1955
|
rawSuffix: n
|
|
1859
1956
|
};
|
|
1860
1957
|
}
|
|
1861
|
-
function
|
|
1958
|
+
function $e(e) {
|
|
1862
1959
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1863
1960
|
}
|
|
1864
|
-
function
|
|
1961
|
+
function et(e, t) {
|
|
1865
1962
|
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1866
1963
|
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1867
1964
|
if (t) t(n), e = e.slice(0, -2);
|
|
@@ -1885,21 +1982,21 @@ function Ge(e, t) {
|
|
|
1885
1982
|
};
|
|
1886
1983
|
let n = e, r;
|
|
1887
1984
|
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) ? {
|
|
1888
|
-
value:
|
|
1985
|
+
value: Ne(n),
|
|
1889
1986
|
precision: r
|
|
1890
1987
|
} : {
|
|
1891
1988
|
value: parseFloat(n),
|
|
1892
1989
|
precision: r
|
|
1893
1990
|
};
|
|
1894
1991
|
}
|
|
1895
|
-
function
|
|
1992
|
+
function tt(e) {
|
|
1896
1993
|
if (typeof Uint8Array.fromHex == "function") return Uint8Array.fromHex(e);
|
|
1897
1994
|
if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
|
|
1898
1995
|
let t = new Uint8Array(e.length / 2);
|
|
1899
1996
|
for (let n = 0; n < e.length; n += 2) t[n / 2] = parseInt(e.slice(n, n + 2), 16);
|
|
1900
1997
|
return t;
|
|
1901
1998
|
}
|
|
1902
|
-
function
|
|
1999
|
+
function nt(e, t) {
|
|
1903
2000
|
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
1904
2001
|
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
1905
2002
|
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
@@ -1936,49 +2033,49 @@ function qe(e, t) {
|
|
|
1936
2033
|
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
1937
2034
|
return l;
|
|
1938
2035
|
}
|
|
1939
|
-
function
|
|
2036
|
+
function rt(e, t, n) {
|
|
1940
2037
|
if (t.length === 0) return;
|
|
1941
|
-
let r =
|
|
2038
|
+
let r = it(e), i = ot(n);
|
|
1942
2039
|
for (let a of t) {
|
|
1943
2040
|
let t = { ...a }, o = [...r].filter((e) => e.end <= a.start).sort((e, t) => t.end - e.end || t.start - e.start)[0], s = o ? n.slice(o.end, a.start) : "";
|
|
1944
2041
|
if (o && i(o.end) === a.line && !s.includes(":")) {
|
|
1945
|
-
|
|
2042
|
+
at(o.node, "trailing", t);
|
|
1946
2043
|
continue;
|
|
1947
2044
|
}
|
|
1948
2045
|
let c = [...r].filter((e) => e.start < a.start && a.end < e.end).sort((e, t) => t.start - e.start || e.end - t.end)[0], l = [...r].filter((e) => e.start >= a.end).sort((e, t) => e.start - t.start || t.end - e.end)[0];
|
|
1949
2046
|
if ((!c || l && l.end <= c.end) && l) {
|
|
1950
|
-
|
|
2047
|
+
at(l.node, "leading", t);
|
|
1951
2048
|
continue;
|
|
1952
2049
|
}
|
|
1953
|
-
|
|
2050
|
+
at(c?.node ?? e, "dangling", t);
|
|
1954
2051
|
}
|
|
1955
2052
|
}
|
|
1956
|
-
function
|
|
2053
|
+
function it(e) {
|
|
1957
2054
|
let t = [], n = (e) => {
|
|
1958
2055
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1959
2056
|
node: e,
|
|
1960
2057
|
start: e.start,
|
|
1961
2058
|
end: e.end
|
|
1962
|
-
}), e instanceof
|
|
2059
|
+
}), e instanceof j || e instanceof P) {
|
|
1963
2060
|
for (let t of e.items) n(t);
|
|
1964
2061
|
return;
|
|
1965
2062
|
}
|
|
1966
|
-
if (e instanceof
|
|
2063
|
+
if (e instanceof M) {
|
|
1967
2064
|
for (let [t, r] of e.entries) n(t), n(r);
|
|
1968
2065
|
return;
|
|
1969
2066
|
}
|
|
1970
|
-
if (e instanceof
|
|
2067
|
+
if (e instanceof k || e instanceof A) {
|
|
1971
2068
|
for (let t of e.chunks) n(t);
|
|
1972
2069
|
return;
|
|
1973
2070
|
}
|
|
1974
|
-
e instanceof
|
|
2071
|
+
e instanceof E && n(e.content);
|
|
1975
2072
|
};
|
|
1976
2073
|
return n(e), t;
|
|
1977
2074
|
}
|
|
1978
|
-
function
|
|
2075
|
+
function at(e, t, n) {
|
|
1979
2076
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1980
2077
|
}
|
|
1981
|
-
function
|
|
2078
|
+
function ot(e) {
|
|
1982
2079
|
let t = [0];
|
|
1983
2080
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1984
2081
|
return (n) => {
|
|
@@ -1992,13 +2089,22 @@ function Ze(e) {
|
|
|
1992
2089
|
return a + 1;
|
|
1993
2090
|
};
|
|
1994
2091
|
}
|
|
1995
|
-
var
|
|
2092
|
+
var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, st = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, ct = new Map([
|
|
2093
|
+
["b32", z("b32")],
|
|
2094
|
+
["h32", z("h32")],
|
|
2095
|
+
["float", z("float")],
|
|
2096
|
+
["same", z("same")],
|
|
2097
|
+
["hash", st("hash", "@cbortech/hash-extension")],
|
|
2098
|
+
["uuid", st("uuid", "@cbortech/uuid-extension")],
|
|
2099
|
+
["UUID", st("uuid", "@cbortech/uuid-extension")]
|
|
2100
|
+
]), lt = class {
|
|
1996
2101
|
t;
|
|
1997
2102
|
_options;
|
|
1998
2103
|
extByPrefix;
|
|
1999
2104
|
extByTag;
|
|
2000
2105
|
unresolvedExtension;
|
|
2001
2106
|
_pendingWarnings = [];
|
|
2107
|
+
_hintedPrefixes = /* @__PURE__ */ new Set();
|
|
2002
2108
|
constructor(e, t) {
|
|
2003
2109
|
this.t = e, this._options = t, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = t.unresolvedExtension ?? "cpa999";
|
|
2004
2110
|
for (let e of [...Z, ...t.extensions ?? []]) {
|
|
@@ -2040,12 +2146,12 @@ var Qe = class {
|
|
|
2040
2146
|
case "BYTES_HEX":
|
|
2041
2147
|
case "SQSTR":
|
|
2042
2148
|
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
|
|
2043
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new
|
|
2044
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new
|
|
2045
|
-
case "TRUE": return this.t.consume(),
|
|
2046
|
-
case "FALSE": return this.t.consume(),
|
|
2047
|
-
case "NULL": return this.t.consume(),
|
|
2048
|
-
case "UNDEFINED": return this.t.consume(),
|
|
2149
|
+
case "EMPTY_INDEF_BYTES": return this.t.consume(), new k([]);
|
|
2150
|
+
case "EMPTY_INDEF_TEXT": return this.t.consume(), new A([]);
|
|
2151
|
+
case "TRUE": return this.t.consume(), N.TRUE;
|
|
2152
|
+
case "FALSE": return this.t.consume(), N.FALSE;
|
|
2153
|
+
case "NULL": return this.t.consume(), N.NULL;
|
|
2154
|
+
case "UNDEFINED": return this.t.consume(), N.UNDEFINED;
|
|
2049
2155
|
case "SIMPLE": return this.parseSimple();
|
|
2050
2156
|
case "LBRACKET": return this.parseArray();
|
|
2051
2157
|
case "LBRACE": return this.parseMap();
|
|
@@ -2055,21 +2161,21 @@ var Qe = class {
|
|
|
2055
2161
|
this.t.consume();
|
|
2056
2162
|
let t = this.extByPrefix.get(e.appPrefix);
|
|
2057
2163
|
if (!t?.parseAppString) {
|
|
2058
|
-
if (this.unresolvedExtension === "cpa999") return new
|
|
2164
|
+
if (t || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new F(e.appPrefix, [new B(e.value)]);
|
|
2059
2165
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
2060
2166
|
}
|
|
2061
2167
|
{
|
|
2062
2168
|
let n = this._pendingWarnings.length;
|
|
2063
2169
|
try {
|
|
2064
2170
|
let n = t.parseAppString(e.appPrefix, e.value, this._extOnError(e));
|
|
2065
|
-
return n instanceof
|
|
2171
|
+
return n instanceof O && Object.getPrototypeOf(n) === O.prototype && n.ednSource === void 0 ? new O(n.value, {
|
|
2066
2172
|
ednEncoding: n.ednEncoding,
|
|
2067
2173
|
encodingWidth: n.encodingWidth,
|
|
2068
2174
|
ednSource: e.raw
|
|
2069
|
-
}) : (n instanceof
|
|
2175
|
+
}) : (n instanceof T && n.ednSource === void 0 && (n.ednSource = e.raw), n);
|
|
2070
2176
|
} catch (t) {
|
|
2071
2177
|
if (this._options.strict !== !1) throw t;
|
|
2072
|
-
return this._pendingWarnings.length === n && this._warn(t instanceof Error ? t.message : String(t), e), new
|
|
2178
|
+
return this._pendingWarnings.length === n && this._warn(t instanceof Error ? t.message : String(t), e), new F(e.appPrefix, [new B(e.value)]);
|
|
2073
2179
|
}
|
|
2074
2180
|
}
|
|
2075
2181
|
}
|
|
@@ -2080,7 +2186,7 @@ var Qe = class {
|
|
|
2080
2186
|
this.expect("GT_GT");
|
|
2081
2187
|
let n = this.extByPrefix.get(e.appPrefix);
|
|
2082
2188
|
if (!n) {
|
|
2083
|
-
if (this.unresolvedExtension === "cpa999") return new
|
|
2189
|
+
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new F(e.appPrefix, t);
|
|
2084
2190
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
2085
2191
|
}
|
|
2086
2192
|
n.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
@@ -2088,36 +2194,36 @@ var Qe = class {
|
|
|
2088
2194
|
let r = this._pendingWarnings.length;
|
|
2089
2195
|
try {
|
|
2090
2196
|
let r = n.parseAppSequence(e.appPrefix, t, this._extOnError(e)), i = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
2091
|
-
if (r instanceof
|
|
2092
|
-
else if (n.preserveAppSeqSource) return new
|
|
2197
|
+
if (r instanceof T) r.ednSource === void 0 && (r.ednSource = i);
|
|
2198
|
+
else if (n.preserveAppSeqSource) return new Be(r, i);
|
|
2093
2199
|
return r;
|
|
2094
2200
|
} catch (n) {
|
|
2095
2201
|
if (this._options.strict !== !1) throw n;
|
|
2096
|
-
return this._pendingWarnings.length === r && this._warn(n instanceof Error ? n.message : String(n), e), new
|
|
2202
|
+
return this._pendingWarnings.length === r && this._warn(n instanceof Error ? n.message : String(n), e), new F(e.appPrefix, t);
|
|
2097
2203
|
}
|
|
2098
2204
|
}
|
|
2099
2205
|
}
|
|
2100
2206
|
case "ELLIPSIS": {
|
|
2101
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new
|
|
2102
|
-
let e = [new
|
|
2207
|
+
if (this.t.consume(), this.t.peek().type !== "PLUS") return new I();
|
|
2208
|
+
let e = [new I()];
|
|
2103
2209
|
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
2104
|
-
return new
|
|
2210
|
+
return new I(e);
|
|
2105
2211
|
}
|
|
2106
2212
|
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
2107
2213
|
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
2108
2214
|
}
|
|
2109
2215
|
}
|
|
2110
2216
|
parseIntegerOrTag() {
|
|
2111
|
-
let e = this.t.consume(), { numStr: t, rawSuffix: n } =
|
|
2112
|
-
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new
|
|
2113
|
-
if (i < -18446744073709551616n) return new
|
|
2217
|
+
let e = this.t.consume(), { numStr: t, rawSuffix: n } = Qe(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = $e(t);
|
|
2218
|
+
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new L(i);
|
|
2219
|
+
if (i < -18446744073709551616n) return new R(i);
|
|
2114
2220
|
if (r !== void 0) {
|
|
2115
2221
|
let t = i >= 0n ? i : -(i + 1n);
|
|
2116
2222
|
r = this._validateEncodingFit(t, r, e);
|
|
2117
2223
|
}
|
|
2118
|
-
let a = i >= 0n ? new
|
|
2224
|
+
let a = i >= 0n ? new C(i, r === void 0 ? void 0 : { encodingWidth: r }) : new w(i, r === void 0 ? void 0 : { encodingWidth: r });
|
|
2119
2225
|
if (this.t.peek().type === "LPAREN") {
|
|
2120
|
-
a instanceof
|
|
2226
|
+
a instanceof C || this._fail("tag number must be non-negative", e), this.t.consume();
|
|
2121
2227
|
let t = this._pendingWarnings.splice(0), n = this.parseValue();
|
|
2122
2228
|
this.expect("RPAREN");
|
|
2123
2229
|
let i = a.value, o = this.extByTag.get(i);
|
|
@@ -2125,26 +2231,24 @@ var Qe = class {
|
|
|
2125
2231
|
let e = o.parseTag(i, n);
|
|
2126
2232
|
if (e !== void 0) return t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
|
|
2127
2233
|
}
|
|
2128
|
-
let s = new
|
|
2234
|
+
let s = new E(i, n, r === void 0 ? void 0 : { encodingWidth: r });
|
|
2129
2235
|
return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
|
|
2130
2236
|
}
|
|
2131
2237
|
return a;
|
|
2132
2238
|
}
|
|
2133
2239
|
parseFloat() {
|
|
2134
|
-
let e = this.t.consume(), t = (t) => {
|
|
2135
|
-
this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
|
|
2136
|
-
}, { value: n, precision: r } = Ge(e.value, t);
|
|
2240
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = et(e.value, t);
|
|
2137
2241
|
if (r === "half" || r === "single") {
|
|
2138
|
-
let e = r === "half" ?
|
|
2242
|
+
let e = r === "half" ? _(Ce(n)) : Math.fround(n);
|
|
2139
2243
|
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`);
|
|
2140
2244
|
}
|
|
2141
|
-
return new
|
|
2245
|
+
return new T(n, r === void 0 ? void 0 : { precision: r });
|
|
2142
2246
|
}
|
|
2143
2247
|
parseString() {
|
|
2144
2248
|
let e = this.t.consume();
|
|
2145
2249
|
if (this.t.peek().type !== "PLUS") {
|
|
2146
|
-
let t =
|
|
2147
|
-
return new
|
|
2250
|
+
let t = this.consumeEncodingIndicator(() => BigInt(Je.encode(e.value).length));
|
|
2251
|
+
return new B(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
2148
2252
|
}
|
|
2149
2253
|
let t = !1, n = [{ text: e.value }];
|
|
2150
2254
|
for (; this.t.peek().type === "PLUS";) {
|
|
@@ -2153,34 +2257,31 @@ var Qe = class {
|
|
|
2153
2257
|
e.type === "ELLIPSIS" ? (this.t.consume(), n.push({ ellipsis: !0 }), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push({ text: e.value })) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({ text: this._decodeUtf8(this._decodeBytesToken(e), e) })) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2154
2258
|
}
|
|
2155
2259
|
if (!t) {
|
|
2156
|
-
let e = n.map((e) => "text" in e ? e.text : "").join(""), t =
|
|
2157
|
-
return new
|
|
2260
|
+
let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(Je.encode(e).length));
|
|
2261
|
+
return new B(e, t === void 0 ? void 0 : { encodingWidth: t });
|
|
2158
2262
|
}
|
|
2159
2263
|
let r = [], i = "";
|
|
2160
|
-
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new
|
|
2161
|
-
return i !== "" && r.push(new
|
|
2264
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new B(i)), i = ""), r.push(new I())) : i += e.text;
|
|
2265
|
+
return i !== "" && r.push(new B(i)), new I(r);
|
|
2162
2266
|
}
|
|
2163
2267
|
_isBytesToken(e) {
|
|
2164
2268
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
2165
2269
|
}
|
|
2166
2270
|
_decodeBytesToken(e) {
|
|
2167
|
-
let t = (t) =>
|
|
2168
|
-
this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
|
|
2169
|
-
};
|
|
2271
|
+
let t = (t) => this._warnOrFail(t, e);
|
|
2170
2272
|
switch (e.type) {
|
|
2171
2273
|
case "BYTES_HEX":
|
|
2172
|
-
case "SQSTR": return
|
|
2173
|
-
case "BYTES_B64": return
|
|
2274
|
+
case "SQSTR": return tt(e.value);
|
|
2275
|
+
case "BYTES_B64": return nt(e.value, t);
|
|
2174
2276
|
default: this._fail("expected byte string token", e);
|
|
2175
2277
|
}
|
|
2176
2278
|
}
|
|
2177
2279
|
_decodeUtf8(e, t) {
|
|
2178
|
-
if (this._options.allowInvalidUtf8) return
|
|
2280
|
+
if (this._options.allowInvalidUtf8) return Xe.decode(e);
|
|
2179
2281
|
try {
|
|
2180
|
-
return
|
|
2282
|
+
return Ye.decode(e);
|
|
2181
2283
|
} catch {
|
|
2182
|
-
|
|
2183
|
-
return this._warn(n, t), this._options.strict !== !1 && this._fail(n, t), new TextDecoder("utf-8", { fatal: !1 }).decode(e);
|
|
2284
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), Xe.decode(e);
|
|
2184
2285
|
}
|
|
2185
2286
|
}
|
|
2186
2287
|
_tokenTypeToCdnEncoding(e) {
|
|
@@ -2188,8 +2289,8 @@ var Qe = class {
|
|
|
2188
2289
|
}
|
|
2189
2290
|
_parseBytesConcat(e, t, n) {
|
|
2190
2291
|
if (this.t.peek().type !== "PLUS") {
|
|
2191
|
-
let r = this.consumeEncodingIndicator(BigInt(e.length));
|
|
2192
|
-
return new
|
|
2292
|
+
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
2293
|
+
return new O(e, {
|
|
2193
2294
|
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
2194
2295
|
ednSource: n,
|
|
2195
2296
|
...r === void 0 ? {} : { encodingWidth: r }
|
|
@@ -2203,30 +2304,25 @@ var Qe = class {
|
|
|
2203
2304
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
2204
2305
|
this.t.consume();
|
|
2205
2306
|
let t = this._buildBytesElidedItems(e.value);
|
|
2206
|
-
for (let e of t) e instanceof
|
|
2207
|
-
} else
|
|
2208
|
-
else if (e.type === "TSTR" || e.type === "RAWSTRING") {
|
|
2209
|
-
this.t.consume();
|
|
2210
|
-
let t = "text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead";
|
|
2211
|
-
this._warn(t, e), this._options.strict !== !1 && this._fail(t, e), i.push({ bytes: new TextEncoder().encode(e.value) });
|
|
2212
|
-
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2307
|
+
for (let e of t) e instanceof I ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof O && i.push({ bytes: e.value });
|
|
2308
|
+
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes: Je.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2213
2309
|
}
|
|
2214
2310
|
if (!r) {
|
|
2215
|
-
let e = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(BigInt(t.length));
|
|
2216
|
-
return new
|
|
2311
|
+
let e = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(() => BigInt(t.length));
|
|
2312
|
+
return new O(t, n === void 0 ? void 0 : { encodingWidth: n });
|
|
2217
2313
|
}
|
|
2218
2314
|
let a = [], o = [], s = () => {
|
|
2219
|
-
o.length > 0 && (a.push(new
|
|
2315
|
+
o.length > 0 && (a.push(new O(this._concatBytes([...o]))), o.length = 0);
|
|
2220
2316
|
};
|
|
2221
|
-
for (let e of i) "ellipsis" in e ? (s(), a.push(new
|
|
2222
|
-
return s(), new
|
|
2317
|
+
for (let e of i) "ellipsis" in e ? (s(), a.push(new I())) : o.push(e.bytes);
|
|
2318
|
+
return s(), new I(a);
|
|
2223
2319
|
}
|
|
2224
2320
|
_parseHexElidedConcat(e) {
|
|
2225
2321
|
let t = this._buildBytesElidedItems(e.value);
|
|
2226
2322
|
for (; this.t.peek().type === "PLUS";) {
|
|
2227
2323
|
this.t.consume();
|
|
2228
2324
|
let e = this.t.peek();
|
|
2229
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new
|
|
2325
|
+
if (e.type === "ELLIPSIS") this.t.consume(), t.push(new I());
|
|
2230
2326
|
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
2231
2327
|
this.t.consume();
|
|
2232
2328
|
let n = this._buildBytesElidedItems(e.value);
|
|
@@ -2234,20 +2330,20 @@ var Qe = class {
|
|
|
2234
2330
|
} else if (this._isBytesToken(e.type)) {
|
|
2235
2331
|
this.t.consume();
|
|
2236
2332
|
let n = this._decodeBytesToken(e), r = t[t.length - 1];
|
|
2237
|
-
r instanceof
|
|
2333
|
+
r instanceof O ? t[t.length - 1] = new O(this._concatBytes([r.value, n])) : t.push(new O(n));
|
|
2238
2334
|
} else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2239
2335
|
}
|
|
2240
|
-
return new
|
|
2336
|
+
return new I(t);
|
|
2241
2337
|
}
|
|
2242
2338
|
_buildBytesElidedItems(e) {
|
|
2243
2339
|
let t = e.split("..."), n = [];
|
|
2244
|
-
for (let e = 0; e < t.length; e++) e > 0 && n.push(new
|
|
2340
|
+
for (let e = 0; e < t.length; e++) e > 0 && n.push(new I()), t[e].length > 0 && n.push(new O(tt(t[e])));
|
|
2245
2341
|
return n;
|
|
2246
2342
|
}
|
|
2247
2343
|
_mergeFirstBytesItem(e, t) {
|
|
2248
2344
|
if (t.length === 0) return;
|
|
2249
2345
|
let n = e[e.length - 1], r = t[0];
|
|
2250
|
-
n instanceof
|
|
2346
|
+
n instanceof O && r instanceof O ? (e[e.length - 1] = new O(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
|
|
2251
2347
|
}
|
|
2252
2348
|
_concatBytes(e) {
|
|
2253
2349
|
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
@@ -2258,28 +2354,23 @@ var Qe = class {
|
|
|
2258
2354
|
this.t.consume(), this.expect("LPAREN");
|
|
2259
2355
|
let e = this.t.peek();
|
|
2260
2356
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
2261
|
-
let { numStr: t } =
|
|
2262
|
-
return this.expect("RPAREN"), new
|
|
2357
|
+
let { numStr: t } = Qe(e.value), n = Number($e(t));
|
|
2358
|
+
return this.expect("RPAREN"), new N(n);
|
|
2263
2359
|
}
|
|
2264
2360
|
parseEmbeddedCBOR() {
|
|
2265
2361
|
this.t.consume();
|
|
2266
2362
|
let e = [];
|
|
2267
2363
|
for (; this.t.peek().type !== "GT_GT" && !(e.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "GT_GT"));) e.push(this.parseValue());
|
|
2268
|
-
return this.expect("GT_GT"), new
|
|
2364
|
+
return this.expect("GT_GT"), new P(e);
|
|
2269
2365
|
}
|
|
2270
2366
|
parseArray() {
|
|
2271
2367
|
this.t.consume();
|
|
2272
2368
|
let e = !1, t, n;
|
|
2273
|
-
|
|
2274
|
-
else if (this.t.peek().type === "ENCODING_INDICATOR") if (n = this.t.consume(), n.value === "7") {
|
|
2275
|
-
e = !0;
|
|
2276
|
-
let t = "encoding indicator _7 is non-standard; use _ to indicate indefinite length";
|
|
2277
|
-
this._warn(t, n), this._options.strict !== !1 && this._fail(t, n), n = void 0;
|
|
2278
|
-
} else t = this._resolveEncodingWidth(n.value, n);
|
|
2369
|
+
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));
|
|
2279
2370
|
let r = this._pendingWarnings.splice(0), i = [];
|
|
2280
2371
|
for (; this.t.peek().type !== "RBRACKET" && !(i.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACKET"));) i.push(this.parseValue());
|
|
2281
2372
|
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
2282
|
-
let a = new
|
|
2373
|
+
let a = new j(i, {
|
|
2283
2374
|
indefiniteLength: e,
|
|
2284
2375
|
encodingWidth: t
|
|
2285
2376
|
});
|
|
@@ -2288,12 +2379,7 @@ var Qe = class {
|
|
|
2288
2379
|
parseMap() {
|
|
2289
2380
|
this.t.consume();
|
|
2290
2381
|
let e = !1, t, n;
|
|
2291
|
-
|
|
2292
|
-
else if (this.t.peek().type === "ENCODING_INDICATOR") if (n = this.t.consume(), n.value === "7") {
|
|
2293
|
-
e = !0;
|
|
2294
|
-
let t = "encoding indicator _7 is non-standard; use _ to indicate indefinite length";
|
|
2295
|
-
this._warn(t, n), this._options.strict !== !1 && this._fail(t, n), n = void 0;
|
|
2296
|
-
} else t = this._resolveEncodingWidth(n.value, n);
|
|
2382
|
+
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));
|
|
2297
2383
|
let r = this._pendingWarnings.splice(0), i = [];
|
|
2298
2384
|
for (; this.t.peek().type !== "RBRACE" && !(i.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACE"));) {
|
|
2299
2385
|
let e = this.parseValue();
|
|
@@ -2302,7 +2388,7 @@ var Qe = class {
|
|
|
2302
2388
|
i.push([e, t]);
|
|
2303
2389
|
}
|
|
2304
2390
|
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
2305
|
-
let a = new
|
|
2391
|
+
let a = new M(i, {
|
|
2306
2392
|
indefiniteLength: e,
|
|
2307
2393
|
encodingWidth: t
|
|
2308
2394
|
});
|
|
@@ -2312,31 +2398,25 @@ var Qe = class {
|
|
|
2312
2398
|
this.t.consume();
|
|
2313
2399
|
let e = this.t.peek();
|
|
2314
2400
|
if (e.type === "UNDERSCORE") this.t.consume();
|
|
2315
|
-
else if (e.type === "ENCODING_INDICATOR" && e.value === "7")
|
|
2316
|
-
|
|
2317
|
-
let t = "encoding indicator _7 is non-standard; use _ to indicate indefinite length";
|
|
2318
|
-
this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
|
|
2319
|
-
} else if (e.type === "ENCODING_INDICATOR") {
|
|
2401
|
+
else if (e.type === "ENCODING_INDICATOR" && e.value === "7") this.t.consume(), this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", e);
|
|
2402
|
+
else if (e.type === "ENCODING_INDICATOR") {
|
|
2320
2403
|
let e = this.t.consume(), t = `encoding indicator _${e.value} is not valid in an indefinite string group; use _`;
|
|
2321
|
-
this.
|
|
2322
|
-
} else
|
|
2323
|
-
let t = "indefinite string group is missing _ after (; interpreting as (_ ...)";
|
|
2324
|
-
this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
|
|
2325
|
-
}
|
|
2404
|
+
this._warnOrFail(t, e);
|
|
2405
|
+
} else e.type !== "RPAREN" && this._warnOrFail("indefinite string group is missing _ after (; interpreting as (_ ...)", e);
|
|
2326
2406
|
let t = this._pendingWarnings.splice(0), n = [];
|
|
2327
2407
|
for (; this.t.peek().type !== "RPAREN" && !(n.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RPAREN"));) n.push(this.parseValue());
|
|
2328
2408
|
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
2329
2409
|
let r = n[0];
|
|
2330
|
-
if (r instanceof
|
|
2331
|
-
let e = new
|
|
2332
|
-
if (e instanceof
|
|
2410
|
+
if (r instanceof O) {
|
|
2411
|
+
let e = new k(n.map((e, t) => {
|
|
2412
|
+
if (e instanceof O) return e;
|
|
2333
2413
|
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
2334
2414
|
}));
|
|
2335
2415
|
return t.length > 0 && (e.warnings = t), e;
|
|
2336
2416
|
}
|
|
2337
|
-
if (r instanceof
|
|
2338
|
-
let e = new
|
|
2339
|
-
if (e instanceof
|
|
2417
|
+
if (r instanceof B) {
|
|
2418
|
+
let e = new A(n.map((e, t) => {
|
|
2419
|
+
if (e instanceof B) return e;
|
|
2340
2420
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
2341
2421
|
}));
|
|
2342
2422
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -2346,7 +2426,7 @@ var Qe = class {
|
|
|
2346
2426
|
consumeEncodingIndicator(e) {
|
|
2347
2427
|
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
2348
2428
|
let t = this.t.consume(), n = this._resolveEncodingWidth(t.value, t);
|
|
2349
|
-
return n !== void 0 && e !== void 0 && (n = this._validateEncodingFit(e, n, t)), n;
|
|
2429
|
+
return n !== void 0 && e !== void 0 && (n = this._validateEncodingFit(e(), n, t)), n;
|
|
2350
2430
|
}
|
|
2351
2431
|
}
|
|
2352
2432
|
expect(e) {
|
|
@@ -2354,34 +2434,40 @@ var Qe = class {
|
|
|
2354
2434
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
2355
2435
|
}
|
|
2356
2436
|
_validateEncodingFit(e, t, n) {
|
|
2357
|
-
let r =
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
2: 4294967295n,
|
|
2362
|
-
3: 18446744073709551615n
|
|
2363
|
-
};
|
|
2364
|
-
if (e <= r[t]) return t;
|
|
2365
|
-
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r[t]})`}`;
|
|
2366
|
-
this._warn(i, n), this._options.strict !== !1 && this._fail(i, n);
|
|
2437
|
+
let r = Ee(t);
|
|
2438
|
+
if (e <= r) return t;
|
|
2439
|
+
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
2440
|
+
this._warnOrFail(i, n);
|
|
2367
2441
|
}
|
|
2368
2442
|
_resolveEncodingWidth(e, t) {
|
|
2369
2443
|
if (e === "4" || e === "5" || e === "6") {
|
|
2370
2444
|
let n = `encoding indicator _${e} (AI ${Number(e) + 24}) is reserved and not valid`;
|
|
2371
|
-
this.
|
|
2445
|
+
this._warnOrFail(n, t);
|
|
2372
2446
|
return;
|
|
2373
2447
|
}
|
|
2374
2448
|
if (e === "7") {
|
|
2375
|
-
|
|
2376
|
-
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
2449
|
+
this._warnOrFail("indefinite-length encoding (_7) is not valid here; use [_ ...] or {_ ...} for indefinite collections", t);
|
|
2377
2450
|
return;
|
|
2378
2451
|
}
|
|
2379
2452
|
return e === "i" ? "i" : Number(e);
|
|
2380
2453
|
}
|
|
2381
2454
|
_extOnError(e) {
|
|
2382
|
-
return (t) =>
|
|
2383
|
-
|
|
2384
|
-
|
|
2455
|
+
return (t) => this._warnOrFail(t, e);
|
|
2456
|
+
}
|
|
2457
|
+
_warnOrFail(e, t) {
|
|
2458
|
+
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
2459
|
+
}
|
|
2460
|
+
_hintMissingExtension(e, t) {
|
|
2461
|
+
let n = ct.get(e);
|
|
2462
|
+
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
2463
|
+
this._hintedPrefixes.add(e);
|
|
2464
|
+
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
2465
|
+
this._options.onWarning ? this._options.onWarning({
|
|
2466
|
+
message: r,
|
|
2467
|
+
offset: t.offset,
|
|
2468
|
+
line: t.line,
|
|
2469
|
+
column: t.col
|
|
2470
|
+
}) : this._options.silent || console.warn(`CDN: ${r}`);
|
|
2385
2471
|
}
|
|
2386
2472
|
_warn(e, t) {
|
|
2387
2473
|
let n = { message: e };
|
|
@@ -2395,38 +2481,38 @@ var Qe = class {
|
|
|
2395
2481
|
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
2396
2482
|
throw SyntaxError(`EDN parse error${n}: ${e}`);
|
|
2397
2483
|
}
|
|
2398
|
-
},
|
|
2484
|
+
}, ut = new TextEncoder(), dt = !1, B = class extends S {
|
|
2399
2485
|
indefiniteLength = !1;
|
|
2400
2486
|
value;
|
|
2401
2487
|
encodingWidth;
|
|
2402
2488
|
constructor(e, t) {
|
|
2403
2489
|
super(), this.value = e, this.encodingWidth = t?.encodingWidth;
|
|
2404
2490
|
}
|
|
2405
|
-
|
|
2406
|
-
let
|
|
2407
|
-
|
|
2491
|
+
_encodeTo(e, t) {
|
|
2492
|
+
let n = ut.encode(this.value);
|
|
2493
|
+
x(e, 3, n.length, this.encodingWidth), e.writeBytes(n);
|
|
2408
2494
|
}
|
|
2409
2495
|
_toCDN(e, t) {
|
|
2410
2496
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
2411
|
-
return
|
|
2497
|
+
return ft(this.value, n, e, t);
|
|
2412
2498
|
}
|
|
2413
2499
|
_toJS(e) {
|
|
2414
2500
|
return this.value;
|
|
2415
2501
|
}
|
|
2416
2502
|
};
|
|
2417
|
-
function
|
|
2418
|
-
let i =
|
|
2419
|
-
if (i.length === 0 || a === null) return
|
|
2503
|
+
function ft(e, t, n, r) {
|
|
2504
|
+
let i = pt(n?.textStringFormat ?? []), a = d(n);
|
|
2505
|
+
if (i.length === 0 || a === null) return ve(e) + t;
|
|
2420
2506
|
let o = /* @__PURE__ */ new Map(), s = null;
|
|
2421
|
-
if (i.includes("cdn") && (s =
|
|
2507
|
+
if (i.includes("cdn") && (s = ht(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
|
|
2422
2508
|
if (i.includes("newline")) {
|
|
2423
|
-
let t = s === null ?
|
|
2509
|
+
let t = s === null ? mt(e, 0) : gt(e);
|
|
2424
2510
|
for (let { point: e, contentDepth: n } of t) o.has(e) || o.set(e, n);
|
|
2425
2511
|
}
|
|
2426
|
-
let c =
|
|
2427
|
-
if (c.length <= 1) return
|
|
2512
|
+
let c = Ct(e, o);
|
|
2513
|
+
if (c.length <= 1) return ve(e) + t;
|
|
2428
2514
|
let l = c.map(({ text: e }, n) => {
|
|
2429
|
-
let r =
|
|
2515
|
+
let r = ve(e);
|
|
2430
2516
|
return n === c.length - 1 ? r + t : r;
|
|
2431
2517
|
}), u = l[0];
|
|
2432
2518
|
for (let e = 1; e < l.length; e++) {
|
|
@@ -2435,10 +2521,10 @@ function tt(e, t, n, r) {
|
|
|
2435
2521
|
}
|
|
2436
2522
|
return u;
|
|
2437
2523
|
}
|
|
2438
|
-
function
|
|
2439
|
-
return e.map((e) => e === "cboredn" ? (
|
|
2524
|
+
function pt(e) {
|
|
2525
|
+
return e.map((e) => e === "cboredn" ? (dt || (dt = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
2440
2526
|
}
|
|
2441
|
-
function
|
|
2527
|
+
function mt(e, t) {
|
|
2442
2528
|
let n = [];
|
|
2443
2529
|
for (let r = 0; r < e.length; r++) {
|
|
2444
2530
|
let i = e[r];
|
|
@@ -2455,35 +2541,35 @@ function rt(e, t) {
|
|
|
2455
2541
|
}
|
|
2456
2542
|
return n;
|
|
2457
2543
|
}
|
|
2458
|
-
function
|
|
2544
|
+
function ht(e) {
|
|
2459
2545
|
try {
|
|
2460
|
-
|
|
2546
|
+
Ze(e);
|
|
2461
2547
|
} catch {
|
|
2462
2548
|
return null;
|
|
2463
2549
|
}
|
|
2464
|
-
let t = [], n = new
|
|
2550
|
+
let t = [], n = new Le(e), r = 0, i = null, a = !1, o = 0;
|
|
2465
2551
|
for (;;) {
|
|
2466
2552
|
let s = n.consume();
|
|
2467
2553
|
if (s.type === "EOF") break;
|
|
2468
2554
|
let c = !1;
|
|
2469
|
-
if (a || (a = !0, s.offset > 0 &&
|
|
2555
|
+
if (a || (a = !0, s.offset > 0 && xt(n.comments, 0, s.offset) && t.push({
|
|
2470
2556
|
point: s.offset,
|
|
2471
2557
|
contentDepth: r
|
|
2472
2558
|
})), i !== null) {
|
|
2473
|
-
if (i.kind === "opener" &&
|
|
2559
|
+
if (i.kind === "opener" && vt.has(s.type)) {
|
|
2474
2560
|
i.point = s.endOffset, o = s.endOffset;
|
|
2475
2561
|
continue;
|
|
2476
|
-
} else i.kind === "opener" &&
|
|
2562
|
+
} else i.kind === "opener" && bt.has(s.type) && St(e, i.point, s.offset) ? c = !0 : t.push({
|
|
2477
2563
|
point: s.offset,
|
|
2478
2564
|
contentDepth: i.contentDepth
|
|
2479
2565
|
});
|
|
2480
2566
|
i = null;
|
|
2481
2567
|
}
|
|
2482
|
-
|
|
2568
|
+
yt.has(s.type) ? (r++, i = {
|
|
2483
2569
|
point: s.endOffset,
|
|
2484
2570
|
contentDepth: r,
|
|
2485
2571
|
kind: "opener"
|
|
2486
|
-
}) :
|
|
2572
|
+
}) : bt.has(s.type) ? (r = Math.max(0, r - 1), c || t.push({
|
|
2487
2573
|
point: s.offset,
|
|
2488
2574
|
contentDepth: r
|
|
2489
2575
|
})) : s.type === "COMMA" && (i = {
|
|
@@ -2498,23 +2584,23 @@ function it(e) {
|
|
|
2498
2584
|
contentDepth: r
|
|
2499
2585
|
}), t;
|
|
2500
2586
|
}
|
|
2501
|
-
function
|
|
2502
|
-
let t = [], n = new
|
|
2587
|
+
function gt(e) {
|
|
2588
|
+
let t = [], n = new Le(e), r = 0;
|
|
2503
2589
|
for (;;) {
|
|
2504
2590
|
let i = n.consume();
|
|
2505
2591
|
if (i.type === "EOF") break;
|
|
2506
|
-
if (
|
|
2507
|
-
else if (
|
|
2592
|
+
if (yt.has(i.type)) r++;
|
|
2593
|
+
else if (bt.has(i.type)) r = Math.max(0, r - 1);
|
|
2508
2594
|
else if (i.type !== "COMMA") {
|
|
2509
2595
|
if (i.type === "TSTR") {
|
|
2510
2596
|
let n = e.slice(i.offset, i.endOffset);
|
|
2511
|
-
for (let e of
|
|
2597
|
+
for (let e of _t(n)) t.push({
|
|
2512
2598
|
point: i.offset + e,
|
|
2513
2599
|
contentDepth: r + 1
|
|
2514
2600
|
});
|
|
2515
2601
|
} else if (i.type === "RAWSTRING") {
|
|
2516
2602
|
let n = e.slice(i.offset, i.endOffset);
|
|
2517
|
-
for (let { point: e } of
|
|
2603
|
+
for (let { point: e } of mt(n, 0)) t.push({
|
|
2518
2604
|
point: i.offset + e,
|
|
2519
2605
|
contentDepth: r + 1
|
|
2520
2606
|
});
|
|
@@ -2523,7 +2609,7 @@ function at(e) {
|
|
|
2523
2609
|
}
|
|
2524
2610
|
return t;
|
|
2525
2611
|
}
|
|
2526
|
-
function
|
|
2612
|
+
function _t(e) {
|
|
2527
2613
|
let t = [], n = 1, r = e.length - 1;
|
|
2528
2614
|
for (; n < r;) {
|
|
2529
2615
|
let r = e[n];
|
|
@@ -2539,24 +2625,24 @@ function ot(e) {
|
|
|
2539
2625
|
}
|
|
2540
2626
|
return t;
|
|
2541
2627
|
}
|
|
2542
|
-
var
|
|
2628
|
+
var vt = new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), yt = new Set([
|
|
2543
2629
|
"LBRACKET",
|
|
2544
2630
|
"LBRACE",
|
|
2545
2631
|
"LPAREN",
|
|
2546
2632
|
"LT_LT"
|
|
2547
|
-
]),
|
|
2633
|
+
]), bt = new Set([
|
|
2548
2634
|
"RBRACKET",
|
|
2549
2635
|
"RBRACE",
|
|
2550
2636
|
"RPAREN",
|
|
2551
2637
|
"GT_GT"
|
|
2552
2638
|
]);
|
|
2553
|
-
function
|
|
2639
|
+
function xt(e, t, n) {
|
|
2554
2640
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
2555
2641
|
}
|
|
2556
|
-
function
|
|
2642
|
+
function St(e, t, n) {
|
|
2557
2643
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
2558
2644
|
}
|
|
2559
|
-
function
|
|
2645
|
+
function Ct(e, t) {
|
|
2560
2646
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
2561
2647
|
if (n.length === 0) return [{
|
|
2562
2648
|
text: e,
|
|
@@ -2574,7 +2660,7 @@ function ft(e, t) {
|
|
|
2574
2660
|
}
|
|
2575
2661
|
//#endregion
|
|
2576
2662
|
//#region src/extensions/dt.ts
|
|
2577
|
-
function
|
|
2663
|
+
function V(e) {
|
|
2578
2664
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
2579
2665
|
let t = Math.round(e * 1e3);
|
|
2580
2666
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -2582,16 +2668,17 @@ function L(e) {
|
|
|
2582
2668
|
for (; s.length < 3;) s += "0";
|
|
2583
2669
|
return `${i}.${s}Z`;
|
|
2584
2670
|
}
|
|
2585
|
-
|
|
2671
|
+
var wt = new TextDecoder("utf-8", { fatal: !0 });
|
|
2672
|
+
function Tt(e) {
|
|
2586
2673
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
2587
2674
|
let t = e[0];
|
|
2588
|
-
if (t instanceof
|
|
2589
|
-
if (t instanceof
|
|
2675
|
+
if (t instanceof B) return t.value;
|
|
2676
|
+
if (t instanceof O) return wt.decode(t.value);
|
|
2590
2677
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
2591
2678
|
}
|
|
2592
|
-
var
|
|
2593
|
-
function
|
|
2594
|
-
if (!
|
|
2679
|
+
var Et = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
2680
|
+
function Dt(e, t) {
|
|
2681
|
+
if (!Et.test(e)) {
|
|
2595
2682
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
2596
2683
|
if (t) t(n);
|
|
2597
2684
|
else throw SyntaxError(n);
|
|
@@ -2602,82 +2689,82 @@ function ht(e, t) {
|
|
|
2602
2689
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
2603
2690
|
if (i === void 0) {
|
|
2604
2691
|
let e = a / 1e3;
|
|
2605
|
-
return e >= 0 ? new
|
|
2692
|
+
return e >= 0 ? new kt(BigInt(e)) : new At(BigInt(e));
|
|
2606
2693
|
}
|
|
2607
|
-
return new
|
|
2694
|
+
return new jt(a / 1e3 + i);
|
|
2608
2695
|
}
|
|
2609
|
-
var
|
|
2696
|
+
var Ot = 1n, kt = class extends C {
|
|
2610
2697
|
constructor(e, t) {
|
|
2611
2698
|
super(e, t);
|
|
2612
2699
|
}
|
|
2613
2700
|
_toCDN(e, t) {
|
|
2614
|
-
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${
|
|
2701
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${V(Number(this.value))}'`;
|
|
2615
2702
|
}
|
|
2616
|
-
},
|
|
2703
|
+
}, At = class extends w {
|
|
2617
2704
|
constructor(e, t) {
|
|
2618
2705
|
super(e, t);
|
|
2619
2706
|
}
|
|
2620
2707
|
_toCDN(e, t) {
|
|
2621
|
-
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${
|
|
2708
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${V(Number(this.value))}'`;
|
|
2622
2709
|
}
|
|
2623
|
-
},
|
|
2710
|
+
}, jt = class extends T {
|
|
2624
2711
|
constructor(e, t) {
|
|
2625
2712
|
super(e, t);
|
|
2626
2713
|
}
|
|
2627
2714
|
_toCDN(e, t) {
|
|
2628
|
-
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${
|
|
2715
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${V(this.value)}'`;
|
|
2629
2716
|
}
|
|
2630
|
-
},
|
|
2717
|
+
}, Mt = class extends E {
|
|
2631
2718
|
constructor(e, t) {
|
|
2632
|
-
super(
|
|
2719
|
+
super(Ot, Dt(e), t);
|
|
2633
2720
|
}
|
|
2634
2721
|
_toCDN(e, t) {
|
|
2635
2722
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2636
2723
|
let n = this.content;
|
|
2637
|
-
return `DT'${
|
|
2724
|
+
return `DT'${V(n instanceof T ? n.value : Number(n.value))}'`;
|
|
2638
2725
|
}
|
|
2639
|
-
},
|
|
2726
|
+
}, Nt = class extends Mt {
|
|
2640
2727
|
constructor(e, t) {
|
|
2641
2728
|
super(e, t);
|
|
2642
2729
|
}
|
|
2643
2730
|
_toJS(e) {
|
|
2644
|
-
let t = this.content, n = t instanceof
|
|
2731
|
+
let t = this.content, n = t instanceof T ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
2645
2732
|
return new Date(n);
|
|
2646
2733
|
}
|
|
2647
2734
|
};
|
|
2648
|
-
function
|
|
2735
|
+
function Pt(e) {
|
|
2649
2736
|
let t = e?.jsDate ?? !1;
|
|
2650
2737
|
function n(e) {
|
|
2651
|
-
return t ? new
|
|
2738
|
+
return t ? new Nt(e) : new Mt(e);
|
|
2652
2739
|
}
|
|
2653
2740
|
let r = {
|
|
2654
2741
|
appStringPrefixes: ["dt", "DT"],
|
|
2655
|
-
tagNumbers: [
|
|
2742
|
+
tagNumbers: [Ot],
|
|
2656
2743
|
parseAppString(e, t, r) {
|
|
2657
|
-
return e === "DT" ? n(t) :
|
|
2744
|
+
return e === "DT" ? n(t) : Dt(t, r);
|
|
2658
2745
|
},
|
|
2659
2746
|
parseAppSequence(e, t, r) {
|
|
2660
|
-
let i =
|
|
2661
|
-
return e === "DT" ? n(i) :
|
|
2747
|
+
let i = Tt(t);
|
|
2748
|
+
return e === "DT" ? n(i) : Dt(i, r);
|
|
2662
2749
|
},
|
|
2663
2750
|
parseTag(e, t) {
|
|
2664
2751
|
if (e !== 1n) return;
|
|
2665
2752
|
let r;
|
|
2666
|
-
if (t instanceof
|
|
2667
|
-
else if (t instanceof
|
|
2668
|
-
else if (t instanceof
|
|
2753
|
+
if (t instanceof C) r = Number(t.value);
|
|
2754
|
+
else if (t instanceof w) r = Number(t.value);
|
|
2755
|
+
else if (t instanceof T) r = t.value;
|
|
2669
2756
|
else return;
|
|
2670
|
-
return n(
|
|
2757
|
+
return n(V(r));
|
|
2671
2758
|
}
|
|
2672
2759
|
};
|
|
2673
2760
|
return t && (r.fromJS = (e, t) => {
|
|
2674
|
-
if (e instanceof Date) return new
|
|
2761
|
+
if (e instanceof Date) return new Nt(V(e.getTime() / 1e3));
|
|
2675
2762
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2676
2763
|
}
|
|
2677
|
-
var
|
|
2764
|
+
var Ft = Pt(), It = Pt({ jsDate: !0 });
|
|
2678
2765
|
//#endregion
|
|
2679
2766
|
//#region src/utils/ip.ts
|
|
2680
|
-
function
|
|
2767
|
+
function Lt(e) {
|
|
2681
2768
|
let t = e.split(".");
|
|
2682
2769
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2683
2770
|
let n = new Uint8Array(4);
|
|
@@ -2690,11 +2777,11 @@ function Tt(e) {
|
|
|
2690
2777
|
}
|
|
2691
2778
|
return n;
|
|
2692
2779
|
}
|
|
2693
|
-
function
|
|
2780
|
+
function Rt(e) {
|
|
2694
2781
|
let t = new Uint8Array(16);
|
|
2695
2782
|
if (e === "::") return t;
|
|
2696
2783
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
2697
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
2784
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Lt(i[2]));
|
|
2698
2785
|
let a = n.split("::");
|
|
2699
2786
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2700
2787
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -2711,11 +2798,11 @@ function Et(e) {
|
|
|
2711
2798
|
}
|
|
2712
2799
|
return r && t.set(r, 12), t;
|
|
2713
2800
|
}
|
|
2714
|
-
function
|
|
2801
|
+
function zt(e) {
|
|
2715
2802
|
return Array.from(e).join(".");
|
|
2716
2803
|
}
|
|
2717
|
-
function
|
|
2718
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2804
|
+
function Bt(e) {
|
|
2805
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? zt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
2719
2806
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2720
2807
|
let i = -1, a = 0, o = 0;
|
|
2721
2808
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2729,29 +2816,29 @@ function Ot(e) {
|
|
|
2729
2816
|
}
|
|
2730
2817
|
//#endregion
|
|
2731
2818
|
//#region src/extensions/ip.ts
|
|
2732
|
-
var
|
|
2733
|
-
function
|
|
2819
|
+
var Vt = "ip", H = "IP", U = 52n, Ht = 54n, Ut = new TextDecoder("utf-8", { fatal: !0 });
|
|
2820
|
+
function Wt(e) {
|
|
2734
2821
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2735
2822
|
let t = e[0];
|
|
2736
|
-
if (t instanceof
|
|
2737
|
-
if (t instanceof
|
|
2823
|
+
if (t instanceof B) return t.value;
|
|
2824
|
+
if (t instanceof O) return Ut.decode(t.value);
|
|
2738
2825
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2739
2826
|
}
|
|
2740
|
-
function
|
|
2827
|
+
function Gt(e) {
|
|
2741
2828
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2742
|
-
bytes:
|
|
2829
|
+
bytes: Lt(e),
|
|
2743
2830
|
isV4: !0
|
|
2744
2831
|
} : {
|
|
2745
|
-
bytes:
|
|
2832
|
+
bytes: Rt(e),
|
|
2746
2833
|
isV4: !1
|
|
2747
2834
|
};
|
|
2748
2835
|
}
|
|
2749
|
-
function
|
|
2750
|
-
if (e.length === 4) return
|
|
2751
|
-
if (e.length === 16) return
|
|
2836
|
+
function Kt(e) {
|
|
2837
|
+
if (e.length === 4) return zt(e);
|
|
2838
|
+
if (e.length === 16) return Bt(e);
|
|
2752
2839
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2753
2840
|
}
|
|
2754
|
-
function
|
|
2841
|
+
function qt(e, t) {
|
|
2755
2842
|
let n = new Uint8Array(e.length);
|
|
2756
2843
|
n.set(e);
|
|
2757
2844
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2761,79 +2848,79 @@ function Mt(e, t) {
|
|
|
2761
2848
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2762
2849
|
return n.slice(0, a);
|
|
2763
2850
|
}
|
|
2764
|
-
function
|
|
2851
|
+
function Jt(e, t) {
|
|
2765
2852
|
let n = new Uint8Array(t);
|
|
2766
2853
|
return n.set(e), n;
|
|
2767
2854
|
}
|
|
2768
|
-
var
|
|
2855
|
+
var Yt = class extends O {
|
|
2769
2856
|
_toCDN(e, t) {
|
|
2770
|
-
return e?.appStrings === !1 ? super._toCDN(e, t) : `${
|
|
2857
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `${Vt}'${Kt(this.value)}'`;
|
|
2771
2858
|
}
|
|
2772
|
-
},
|
|
2859
|
+
}, Xt = class extends j {
|
|
2773
2860
|
_isV4;
|
|
2774
2861
|
constructor(e, t, n) {
|
|
2775
|
-
super([new
|
|
2862
|
+
super([new C(BigInt(e)), new O(t)]), this._isV4 = n;
|
|
2776
2863
|
}
|
|
2777
2864
|
_toCDN(e, t) {
|
|
2778
2865
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2779
2866
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2780
|
-
return `${
|
|
2867
|
+
return `${Vt}'${Kt(Jt(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2781
2868
|
}
|
|
2782
|
-
},
|
|
2869
|
+
}, Zt = class extends E {
|
|
2783
2870
|
constructor(e, t) {
|
|
2784
2871
|
super(e, t);
|
|
2785
2872
|
}
|
|
2786
2873
|
_toCDN(e, t) {
|
|
2787
2874
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2788
|
-
let n = this.tag ===
|
|
2789
|
-
if (r instanceof
|
|
2790
|
-
if (r instanceof
|
|
2875
|
+
let n = this.tag === U ? 4 : 16, r = this.content;
|
|
2876
|
+
if (r instanceof O) return `${H}'${Kt(r.value)}'`;
|
|
2877
|
+
if (r instanceof j && r.items.length === 2 && r.items[0] instanceof C && r.items[1] instanceof O) {
|
|
2791
2878
|
let e = Number(r.items[0].value);
|
|
2792
|
-
return `${
|
|
2879
|
+
return `${H}'${Kt(Jt(r.items[1].value, n))}/${e}'`;
|
|
2793
2880
|
}
|
|
2794
2881
|
return super._toCDN(e, t);
|
|
2795
2882
|
}
|
|
2796
2883
|
};
|
|
2797
|
-
function
|
|
2884
|
+
function Qt(e, t) {
|
|
2798
2885
|
let n = t.indexOf("/");
|
|
2799
2886
|
if (n === -1) {
|
|
2800
|
-
let { bytes: n, isV4: r } =
|
|
2801
|
-
return e ===
|
|
2887
|
+
let { bytes: n, isV4: r } = Gt(t);
|
|
2888
|
+
return e === H ? new Zt(r ? U : Ht, new O(n)) : new Yt(n);
|
|
2802
2889
|
}
|
|
2803
2890
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2804
2891
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2805
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2892
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = Gt(r), c = s ? 32 : 128;
|
|
2806
2893
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2807
|
-
let l =
|
|
2808
|
-
return e ===
|
|
2894
|
+
let l = qt(o, a);
|
|
2895
|
+
return e === H ? new Zt(s ? U : Ht, new j([new C(BigInt(a)), new O(l)])) : new Xt(a, l, s);
|
|
2809
2896
|
}
|
|
2810
|
-
var
|
|
2811
|
-
appStringPrefixes: [
|
|
2812
|
-
tagNumbers: [
|
|
2897
|
+
var $t = {
|
|
2898
|
+
appStringPrefixes: [Vt, H],
|
|
2899
|
+
tagNumbers: [U, Ht],
|
|
2813
2900
|
parseAppString(e, t) {
|
|
2814
|
-
return
|
|
2901
|
+
return Qt(e, t);
|
|
2815
2902
|
},
|
|
2816
2903
|
parseAppSequence(e, t) {
|
|
2817
|
-
return
|
|
2904
|
+
return Qt(e, Wt(t));
|
|
2818
2905
|
},
|
|
2819
2906
|
parseTag(e, t) {
|
|
2820
|
-
if (!(e !==
|
|
2907
|
+
if (!(e !== U && e !== Ht) && (t instanceof O || t instanceof j)) return new Zt(e, t);
|
|
2821
2908
|
}
|
|
2822
|
-
},
|
|
2823
|
-
tagNumbers: [
|
|
2909
|
+
}, en = 18446744073709551615n, tn = -18446744073709551616n, nn = {
|
|
2910
|
+
tagNumbers: [He, Ue],
|
|
2824
2911
|
parseTag(e, t) {
|
|
2825
|
-
if (t instanceof
|
|
2912
|
+
if (t instanceof O) {
|
|
2826
2913
|
if (e === 2n) {
|
|
2827
|
-
let e =
|
|
2828
|
-
return e >
|
|
2914
|
+
let e = qe(t.value);
|
|
2915
|
+
return e > en ? new L(e) : void 0;
|
|
2829
2916
|
}
|
|
2830
2917
|
if (e === 3n) {
|
|
2831
|
-
let e = -1n -
|
|
2832
|
-
return e <
|
|
2918
|
+
let e = -1n - qe(t.value);
|
|
2919
|
+
return e < tn ? new R(e) : void 0;
|
|
2833
2920
|
}
|
|
2834
2921
|
}
|
|
2835
2922
|
}
|
|
2836
|
-
},
|
|
2923
|
+
}, rn = "cri", an = "CRI", on = 99n, sn = new Map([
|
|
2837
2924
|
["coap", -1n],
|
|
2838
2925
|
["coaps", -2n],
|
|
2839
2926
|
["http", -3n],
|
|
@@ -2844,46 +2931,47 @@ var Rt = {
|
|
|
2844
2931
|
["coaps+tcp", -8n],
|
|
2845
2932
|
["coap+ws", -25n],
|
|
2846
2933
|
["coaps+ws", -26n]
|
|
2847
|
-
]),
|
|
2848
|
-
function
|
|
2934
|
+
]), cn = new Map([...sn.entries()].map(([e, t]) => [t, e]));
|
|
2935
|
+
function W(e) {
|
|
2849
2936
|
try {
|
|
2850
2937
|
return decodeURIComponent(e);
|
|
2851
2938
|
} catch {
|
|
2852
2939
|
return e;
|
|
2853
2940
|
}
|
|
2854
2941
|
}
|
|
2855
|
-
|
|
2856
|
-
|
|
2942
|
+
var ln = new TextEncoder(), un = new TextDecoder("utf-8", { fatal: !0 });
|
|
2943
|
+
function dn(e) {
|
|
2944
|
+
return Array.from(ln.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2857
2945
|
}
|
|
2858
|
-
function
|
|
2946
|
+
function G(e, t) {
|
|
2859
2947
|
let n = "";
|
|
2860
|
-
for (let r of e) n += t(r) ? r :
|
|
2948
|
+
for (let r of e) n += t(r) ? r : dn(r);
|
|
2861
2949
|
return n;
|
|
2862
2950
|
}
|
|
2863
|
-
function
|
|
2951
|
+
function fn(e) {
|
|
2864
2952
|
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2865
2953
|
}
|
|
2866
|
-
function
|
|
2954
|
+
function pn(e) {
|
|
2867
2955
|
return /[!$&'()*+,;=]/.test(e);
|
|
2868
2956
|
}
|
|
2869
|
-
function
|
|
2870
|
-
return
|
|
2957
|
+
function mn(e) {
|
|
2958
|
+
return fn(e) || pn(e) || e === ":" || e === "@";
|
|
2871
2959
|
}
|
|
2872
|
-
function
|
|
2873
|
-
return (
|
|
2960
|
+
function hn(e) {
|
|
2961
|
+
return (mn(e) || e === "/" || e === "?") && e !== "&";
|
|
2874
2962
|
}
|
|
2875
|
-
function
|
|
2876
|
-
return
|
|
2963
|
+
function gn(e) {
|
|
2964
|
+
return mn(e) || e === "/" || e === "?";
|
|
2877
2965
|
}
|
|
2878
|
-
function
|
|
2879
|
-
return
|
|
2966
|
+
function _n(e) {
|
|
2967
|
+
return fn(e) || pn(e) || e === ":";
|
|
2880
2968
|
}
|
|
2881
|
-
function
|
|
2882
|
-
return
|
|
2969
|
+
function vn(e) {
|
|
2970
|
+
return fn(e) || pn(e);
|
|
2883
2971
|
}
|
|
2884
|
-
function
|
|
2972
|
+
function yn(e) {
|
|
2885
2973
|
let t = [], n = e, r = n.indexOf("@");
|
|
2886
|
-
r >= 0 && (t.push(
|
|
2974
|
+
r >= 0 && (t.push(N.FALSE), t.push(new B(W(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2887
2975
|
let i, a = null;
|
|
2888
2976
|
if (n.startsWith("[")) {
|
|
2889
2977
|
let e = n.indexOf("]");
|
|
@@ -2892,228 +2980,228 @@ function tn(e) {
|
|
|
2892
2980
|
let r = n.slice(e + 1);
|
|
2893
2981
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2894
2982
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2895
|
-
t.push(new
|
|
2983
|
+
t.push(new O(Rt(i)));
|
|
2896
2984
|
} else {
|
|
2897
2985
|
let e = n.lastIndexOf(":");
|
|
2898
|
-
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new
|
|
2899
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new
|
|
2986
|
+
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new O(Lt(i)));
|
|
2987
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new B(e));
|
|
2900
2988
|
}
|
|
2901
2989
|
if (a !== null && a !== "") {
|
|
2902
2990
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2903
2991
|
let e = parseInt(a, 10);
|
|
2904
2992
|
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2905
|
-
t.push(new
|
|
2993
|
+
t.push(new C(BigInt(e)));
|
|
2906
2994
|
}
|
|
2907
|
-
return new
|
|
2995
|
+
return new j(t);
|
|
2908
2996
|
}
|
|
2909
|
-
function
|
|
2997
|
+
function bn(e) {
|
|
2910
2998
|
let t = e.items, n = 0, r = "";
|
|
2911
|
-
if (n < t.length && t[n] instanceof
|
|
2999
|
+
if (n < t.length && t[n] instanceof N && t[n].value === 20) {
|
|
2912
3000
|
n++;
|
|
2913
3001
|
let e = t[n++];
|
|
2914
|
-
r +=
|
|
3002
|
+
r += G(e.value, _n) + "@";
|
|
2915
3003
|
}
|
|
2916
3004
|
if (n >= t.length) return r;
|
|
2917
3005
|
let i = t[n];
|
|
2918
|
-
if (i instanceof
|
|
3006
|
+
if (i instanceof O) {
|
|
2919
3007
|
n++;
|
|
2920
3008
|
let { length: e } = i.value;
|
|
2921
|
-
if (e === 4) r +=
|
|
2922
|
-
else if (e === 16) r += "[" +
|
|
3009
|
+
if (e === 4) r += zt(i.value);
|
|
3010
|
+
else if (e === 16) r += "[" + Bt(i.value) + "]";
|
|
2923
3011
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2924
|
-
n < t.length && t[n] instanceof
|
|
3012
|
+
n < t.length && t[n] instanceof B && (r += `%25${G(t[n++].value, vn)}`);
|
|
2925
3013
|
} else {
|
|
2926
3014
|
let e = [];
|
|
2927
|
-
for (; n < t.length && t[n] instanceof
|
|
3015
|
+
for (; n < t.length && t[n] instanceof B;) e.push(G(t[n++].value, vn));
|
|
2928
3016
|
r += e.join(".");
|
|
2929
3017
|
}
|
|
2930
|
-
return n < t.length && t[n] instanceof
|
|
3018
|
+
return n < t.length && t[n] instanceof C && (r += ":" + t[n].value.toString()), r;
|
|
2931
3019
|
}
|
|
2932
|
-
function
|
|
3020
|
+
function xn(e) {
|
|
2933
3021
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2934
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
2935
|
-
authority:
|
|
3022
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new B(W(e)))) : (r = t, i = []), {
|
|
3023
|
+
authority: yn(r),
|
|
2936
3024
|
pathSegments: i
|
|
2937
3025
|
};
|
|
2938
3026
|
}
|
|
2939
|
-
function
|
|
3027
|
+
function Sn(e) {
|
|
2940
3028
|
let t = e, n = null, r = t.indexOf("#");
|
|
2941
|
-
r >= 0 && (n =
|
|
3029
|
+
r >= 0 && (n = W(t.slice(r + 1)), t = t.slice(0, r));
|
|
2942
3030
|
let i = null, a = t.indexOf("?");
|
|
2943
3031
|
if (a >= 0) {
|
|
2944
3032
|
let e = t.slice(a + 1);
|
|
2945
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
3033
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new B(W(e)));
|
|
2946
3034
|
}
|
|
2947
3035
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2948
3036
|
if (s) {
|
|
2949
|
-
let e = s[1].toLowerCase(), t = s[2], n =
|
|
2950
|
-
if (o.push(n === void 0 ? new
|
|
2951
|
-
let { authority: e, pathSegments: n } =
|
|
2952
|
-
o.push(e, new
|
|
3037
|
+
let e = s[1].toLowerCase(), t = s[2], n = sn.get(e);
|
|
3038
|
+
if (o.push(n === void 0 ? new B(e) : new w(n)), t.startsWith("//")) {
|
|
3039
|
+
let { authority: e, pathSegments: n } = xn(t);
|
|
3040
|
+
o.push(e, new j(n));
|
|
2953
3041
|
} else if (t.startsWith("/")) {
|
|
2954
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2955
|
-
o.push(
|
|
3042
|
+
let e = t.slice(1).split("/").map((e) => new B(W(e)));
|
|
3043
|
+
o.push(N.NULL, new j(e));
|
|
2956
3044
|
} else {
|
|
2957
|
-
let e = t.split("/").map((e) => new
|
|
2958
|
-
o.push(
|
|
3045
|
+
let e = t.split("/").map((e) => new B(W(e)));
|
|
3046
|
+
o.push(N.TRUE, new j(e));
|
|
2959
3047
|
}
|
|
2960
3048
|
} else if (t.startsWith("//")) {
|
|
2961
|
-
let { authority: e, pathSegments: n } =
|
|
2962
|
-
o.push(
|
|
3049
|
+
let { authority: e, pathSegments: n } = xn(t);
|
|
3050
|
+
o.push(N.FALSE, e, new j(n));
|
|
2963
3051
|
} else if (t.startsWith("/")) {
|
|
2964
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
2965
|
-
o.push(
|
|
2966
|
-
} else if (t === "") o.push(new
|
|
3052
|
+
let e = t.slice(1).split("/").map((e) => new B(W(e)));
|
|
3053
|
+
o.push(N.TRUE, new j(e));
|
|
3054
|
+
} else if (t === "") o.push(new C(0n));
|
|
2967
3055
|
else {
|
|
2968
3056
|
let n = 1n, r = t, i = !1;
|
|
2969
3057
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2970
3058
|
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)}`);
|
|
2971
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
2972
|
-
o.push(new
|
|
3059
|
+
let a = r === "" ? [] : r.split("/").map((e) => new B(W(e)));
|
|
3060
|
+
o.push(new C(n), new j(a));
|
|
2973
3061
|
}
|
|
2974
|
-
if (i !== null && o.push(new
|
|
3062
|
+
if (i !== null && o.push(new j(i)), n !== null && (i === null && o.push(N.NULL), o.push(new B(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2975
3063
|
let e = o[o.length - 1];
|
|
2976
|
-
e instanceof
|
|
3064
|
+
e instanceof j && e.items.length === 0 && o.pop();
|
|
2977
3065
|
}
|
|
2978
|
-
return o.length === 1 && o[0] instanceof
|
|
3066
|
+
return o.length === 1 && o[0] instanceof C && o[0].value === 0n ? [] : o;
|
|
2979
3067
|
}
|
|
2980
|
-
function
|
|
3068
|
+
function K(e, t) {
|
|
2981
3069
|
let n = t, r = "";
|
|
2982
3070
|
if (n < e.length) {
|
|
2983
3071
|
let t = e[n];
|
|
2984
|
-
if (t instanceof
|
|
3072
|
+
if (t instanceof j) {
|
|
2985
3073
|
if (n++, t.items.length > 0) {
|
|
2986
3074
|
let e = t.items.map((e) => {
|
|
2987
|
-
if (!(e instanceof
|
|
2988
|
-
return
|
|
3075
|
+
if (!(e instanceof B)) throw Error("cri: query item must be a text string");
|
|
3076
|
+
return G(e.value, hn);
|
|
2989
3077
|
});
|
|
2990
3078
|
r += "?" + e.join("&");
|
|
2991
3079
|
}
|
|
2992
|
-
} else t instanceof
|
|
3080
|
+
} else t instanceof N && t.value === 22 && n++;
|
|
2993
3081
|
}
|
|
2994
|
-
return n < e.length && e[n] instanceof
|
|
3082
|
+
return n < e.length && e[n] instanceof B && (r += "#" + G(e[n].value, gn)), r;
|
|
2995
3083
|
}
|
|
2996
|
-
function
|
|
3084
|
+
function Cn(e) {
|
|
2997
3085
|
return e.items.map((e) => {
|
|
2998
|
-
if (!(e instanceof
|
|
2999
|
-
return
|
|
3086
|
+
if (!(e instanceof B)) throw Error("cri: path segment must be a text string");
|
|
3087
|
+
return G(e.value, mn);
|
|
3000
3088
|
});
|
|
3001
3089
|
}
|
|
3002
|
-
function
|
|
3090
|
+
function wn(e) {
|
|
3003
3091
|
if (e.length === 0) return "";
|
|
3004
3092
|
let t = 0, n = e[t++];
|
|
3005
|
-
if (n instanceof
|
|
3093
|
+
if (n instanceof w || n instanceof B) {
|
|
3006
3094
|
let r;
|
|
3007
|
-
if (n instanceof
|
|
3008
|
-
let e =
|
|
3095
|
+
if (n instanceof w) {
|
|
3096
|
+
let e = cn.get(n.value);
|
|
3009
3097
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
3010
3098
|
r = e + ":";
|
|
3011
3099
|
} else r = n.value + ":";
|
|
3012
3100
|
if (t >= e.length) return r;
|
|
3013
3101
|
let i = e[t++], a = "", o = !1;
|
|
3014
|
-
if (i instanceof
|
|
3015
|
-
else if (i instanceof
|
|
3102
|
+
if (i instanceof j) a = "//" + bn(i), o = !0;
|
|
3103
|
+
else if (i instanceof N) if (i.value === 22) o = !0;
|
|
3016
3104
|
else if (i.value === 21) o = !1;
|
|
3017
3105
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
3018
3106
|
else throw Error("cri: unexpected type for authority element");
|
|
3019
3107
|
let s = "";
|
|
3020
|
-
if (t < e.length && e[t] instanceof
|
|
3108
|
+
if (t < e.length && e[t] instanceof j) {
|
|
3021
3109
|
let n = e[t++];
|
|
3022
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
3110
|
+
n.items.length > 0 && (s = (o ? "/" : "") + Cn(n).join("/"));
|
|
3023
3111
|
}
|
|
3024
|
-
return r + a + s +
|
|
3112
|
+
return r + a + s + K(e, t);
|
|
3025
3113
|
}
|
|
3026
|
-
if (n instanceof
|
|
3027
|
-
if (t >= e.length || !(e[t] instanceof
|
|
3028
|
-
let n =
|
|
3029
|
-
if (t < e.length && e[t] instanceof
|
|
3114
|
+
if (n instanceof N && n.value === 20) {
|
|
3115
|
+
if (t >= e.length || !(e[t] instanceof j)) throw Error("cri: network-path reference requires an authority array");
|
|
3116
|
+
let n = bn(e[t++]), r = "";
|
|
3117
|
+
if (t < e.length && e[t] instanceof j) {
|
|
3030
3118
|
let n = e[t++];
|
|
3031
|
-
n.items.length > 0 && (r = "/" +
|
|
3119
|
+
n.items.length > 0 && (r = "/" + Cn(n).join("/"));
|
|
3032
3120
|
}
|
|
3033
|
-
return "//" + n + r +
|
|
3121
|
+
return "//" + n + r + K(e, t);
|
|
3034
3122
|
}
|
|
3035
|
-
if (n instanceof
|
|
3123
|
+
if (n instanceof N && n.value === 21) {
|
|
3036
3124
|
let n = "/";
|
|
3037
|
-
if (t < e.length && e[t] instanceof
|
|
3125
|
+
if (t < e.length && e[t] instanceof j) {
|
|
3038
3126
|
let r = e[t++];
|
|
3039
|
-
n = "/" +
|
|
3127
|
+
n = "/" + Cn(r).join("/");
|
|
3040
3128
|
}
|
|
3041
|
-
return n +
|
|
3129
|
+
return n + K(e, t);
|
|
3042
3130
|
}
|
|
3043
|
-
if (n instanceof
|
|
3131
|
+
if (n instanceof C) {
|
|
3044
3132
|
let r = n.value;
|
|
3045
|
-
if (r === 0n) return
|
|
3133
|
+
if (r === 0n) return K(e, t);
|
|
3046
3134
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
3047
|
-
if (t < e.length && e[t] instanceof
|
|
3135
|
+
if (t < e.length && e[t] instanceof j) {
|
|
3048
3136
|
let n = e[t++];
|
|
3049
3137
|
if (n.items.length > 0) {
|
|
3050
|
-
let e =
|
|
3138
|
+
let e = Cn(n);
|
|
3051
3139
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
3052
3140
|
} else a = i === "" ? "./" : i;
|
|
3053
3141
|
} else a = i === "" ? "./" : i;
|
|
3054
|
-
return a +
|
|
3142
|
+
return a + K(e, t);
|
|
3055
3143
|
}
|
|
3056
3144
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
3057
3145
|
}
|
|
3058
|
-
var
|
|
3146
|
+
var Tn = class extends j {
|
|
3059
3147
|
_toCDN(e, t) {
|
|
3060
3148
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
3061
3149
|
try {
|
|
3062
|
-
return `${
|
|
3150
|
+
return `${rn}'${wn(this.items)}'`;
|
|
3063
3151
|
} catch {
|
|
3064
3152
|
return super._toCDN(e, t);
|
|
3065
3153
|
}
|
|
3066
3154
|
}
|
|
3067
|
-
},
|
|
3155
|
+
}, En = class extends E {
|
|
3068
3156
|
constructor(e) {
|
|
3069
|
-
super(
|
|
3157
|
+
super(on, e);
|
|
3070
3158
|
}
|
|
3071
3159
|
_toCDN(e, t) {
|
|
3072
3160
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
3073
3161
|
try {
|
|
3074
|
-
return `${
|
|
3162
|
+
return `${an}'${wn(this.content.items)}'`;
|
|
3075
3163
|
} catch {
|
|
3076
3164
|
return super._toCDN(e, t);
|
|
3077
3165
|
}
|
|
3078
3166
|
}
|
|
3079
3167
|
};
|
|
3080
|
-
function
|
|
3168
|
+
function Dn(e) {
|
|
3081
3169
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
3082
3170
|
let t = e[0];
|
|
3083
|
-
if (t instanceof
|
|
3084
|
-
if (t instanceof
|
|
3171
|
+
if (t instanceof B) return t.value;
|
|
3172
|
+
if (t instanceof O) return un.decode(t.value);
|
|
3085
3173
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
3086
3174
|
}
|
|
3087
|
-
function
|
|
3088
|
-
let n = new
|
|
3089
|
-
return e ===
|
|
3175
|
+
function On(e, t) {
|
|
3176
|
+
let n = new Tn(Sn(t));
|
|
3177
|
+
return e === an ? new En(n) : n;
|
|
3090
3178
|
}
|
|
3091
|
-
var
|
|
3092
|
-
appStringPrefixes: [
|
|
3093
|
-
tagNumbers: [
|
|
3179
|
+
var kn = {
|
|
3180
|
+
appStringPrefixes: [rn, an],
|
|
3181
|
+
tagNumbers: [on],
|
|
3094
3182
|
parseAppString(e, t) {
|
|
3095
|
-
return
|
|
3183
|
+
return On(e, t);
|
|
3096
3184
|
},
|
|
3097
3185
|
parseAppSequence(e, t) {
|
|
3098
|
-
return
|
|
3186
|
+
return On(e, Dn(t));
|
|
3099
3187
|
},
|
|
3100
3188
|
parseTag(e, t) {
|
|
3101
|
-
if (e === 99n && t instanceof
|
|
3189
|
+
if (e === 99n && t instanceof j) return new En(new Tn(t.items, {
|
|
3102
3190
|
indefiniteLength: t.indefiniteLength,
|
|
3103
3191
|
encodingWidth: t.encodingWidth
|
|
3104
3192
|
}));
|
|
3105
3193
|
}
|
|
3106
|
-
},
|
|
3194
|
+
}, An = new TextDecoder("utf-8", {
|
|
3107
3195
|
fatal: !0,
|
|
3108
3196
|
ignoreBOM: !0
|
|
3109
|
-
}),
|
|
3197
|
+
}), jn = new TextDecoder("utf-8", {
|
|
3110
3198
|
fatal: !1,
|
|
3111
3199
|
ignoreBOM: !0
|
|
3112
3200
|
});
|
|
3113
|
-
function
|
|
3201
|
+
function q(e) {
|
|
3114
3202
|
throw Error(`CBOR decode error: ${e}`);
|
|
3115
3203
|
}
|
|
3116
|
-
function
|
|
3204
|
+
function Mn(e, t, n) {
|
|
3117
3205
|
let r = {
|
|
3118
3206
|
message: e,
|
|
3119
3207
|
offset: t
|
|
@@ -3121,35 +3209,35 @@ function q(e, t, n) {
|
|
|
3121
3209
|
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}`);
|
|
3122
3210
|
return r;
|
|
3123
3211
|
}
|
|
3124
|
-
function
|
|
3212
|
+
function Nn(e, t) {
|
|
3125
3213
|
e.warnings ??= [], e.warnings.push(t);
|
|
3126
3214
|
}
|
|
3215
|
+
function Pn(e) {
|
|
3216
|
+
let t = "";
|
|
3217
|
+
for (let n of e) t += n.toString(16).padStart(2, "0");
|
|
3218
|
+
return t;
|
|
3219
|
+
}
|
|
3127
3220
|
function J(e) {
|
|
3128
|
-
if (e instanceof
|
|
3129
|
-
if (e instanceof
|
|
3130
|
-
if (e instanceof
|
|
3131
|
-
if (e instanceof
|
|
3132
|
-
if (e instanceof
|
|
3133
|
-
|
|
3134
|
-
for (let n of e.value) t += n.toString(16).padStart(2, "0");
|
|
3135
|
-
return ["b", t];
|
|
3136
|
-
}
|
|
3137
|
-
if (e instanceof E) {
|
|
3221
|
+
if (e instanceof C) return ["u", String(e.value)];
|
|
3222
|
+
if (e instanceof w) return ["n", String(e.value)];
|
|
3223
|
+
if (e instanceof B) return ["t", e.value];
|
|
3224
|
+
if (e instanceof A) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
3225
|
+
if (e instanceof O) return ["b", Pn(e.value)];
|
|
3226
|
+
if (e instanceof k) {
|
|
3138
3227
|
let t = "";
|
|
3139
|
-
for (let n of e.chunks)
|
|
3228
|
+
for (let n of e.chunks) t += Pn(n.value);
|
|
3140
3229
|
return ["b", t];
|
|
3141
3230
|
}
|
|
3142
|
-
if (e instanceof
|
|
3143
|
-
if (e instanceof
|
|
3144
|
-
if (e instanceof
|
|
3145
|
-
if (e instanceof
|
|
3231
|
+
if (e instanceof T) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
3232
|
+
if (e instanceof N) return ["s", e.value];
|
|
3233
|
+
if (e instanceof j) return ["A", e.items.map(J)];
|
|
3234
|
+
if (e instanceof M) {
|
|
3146
3235
|
let t = e.entries.map(([e, t]) => [J(e), J(t)]);
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
}), ["M", t];
|
|
3236
|
+
if (t.length <= 1) return ["M", t];
|
|
3237
|
+
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
3238
|
+
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
3151
3239
|
}
|
|
3152
|
-
if (e instanceof
|
|
3240
|
+
if (e instanceof E) return [
|
|
3153
3241
|
"G",
|
|
3154
3242
|
String(e.tag),
|
|
3155
3243
|
J(e.content)
|
|
@@ -3158,8 +3246,22 @@ function J(e) {
|
|
|
3158
3246
|
for (let e of t) n += e.toString(16).padStart(2, "0");
|
|
3159
3247
|
return ["c", n];
|
|
3160
3248
|
}
|
|
3161
|
-
function
|
|
3162
|
-
|
|
3249
|
+
function Fn(e) {
|
|
3250
|
+
if (e instanceof C) return "u" + e.value;
|
|
3251
|
+
if (e instanceof w) return "n" + e.value;
|
|
3252
|
+
if (e instanceof B) return "t" + e.value;
|
|
3253
|
+
if (e instanceof A) {
|
|
3254
|
+
let t = "t";
|
|
3255
|
+
for (let n of e.chunks) t += n.value;
|
|
3256
|
+
return t;
|
|
3257
|
+
}
|
|
3258
|
+
if (e instanceof O) return "b" + Pn(e.value);
|
|
3259
|
+
if (e instanceof k) {
|
|
3260
|
+
let t = "b";
|
|
3261
|
+
for (let n of e.chunks) t += Pn(n.value);
|
|
3262
|
+
return t;
|
|
3263
|
+
}
|
|
3264
|
+
return e instanceof T ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof N ? "s" + e.value : JSON.stringify(J(e));
|
|
3163
3265
|
}
|
|
3164
3266
|
function Y(e, t, n) {
|
|
3165
3267
|
if (n <= 23) return {
|
|
@@ -3167,245 +3269,248 @@ function Y(e, t, n) {
|
|
|
3167
3269
|
nextOffset: t
|
|
3168
3270
|
};
|
|
3169
3271
|
switch (n) {
|
|
3170
|
-
case 24: return t + 1 > e.byteLength &&
|
|
3272
|
+
case 24: return t + 1 > e.byteLength && q("unexpected end of input"), {
|
|
3171
3273
|
value: BigInt(e.getUint8(t)),
|
|
3172
3274
|
nextOffset: t + 1
|
|
3173
3275
|
};
|
|
3174
|
-
case 25: return t + 2 > e.byteLength &&
|
|
3276
|
+
case 25: return t + 2 > e.byteLength && q("unexpected end of input"), {
|
|
3175
3277
|
value: BigInt(e.getUint16(t, !1)),
|
|
3176
3278
|
nextOffset: t + 2
|
|
3177
3279
|
};
|
|
3178
|
-
case 26: return t + 4 > e.byteLength &&
|
|
3280
|
+
case 26: return t + 4 > e.byteLength && q("unexpected end of input"), {
|
|
3179
3281
|
value: BigInt(e.getUint32(t, !1)),
|
|
3180
3282
|
nextOffset: t + 4
|
|
3181
3283
|
};
|
|
3182
|
-
case 27: return t + 8 > e.byteLength &&
|
|
3284
|
+
case 27: return t + 8 > e.byteLength && q("unexpected end of input"), {
|
|
3183
3285
|
value: e.getBigUint64(t, !1),
|
|
3184
3286
|
nextOffset: t + 8
|
|
3185
3287
|
};
|
|
3186
|
-
default:
|
|
3288
|
+
default: q(`reserved additional info value: ${n}`);
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
function In(e, t, n, r, i, a) {
|
|
3292
|
+
let o = [], s = t;
|
|
3293
|
+
for (;;) {
|
|
3294
|
+
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
3295
|
+
s++;
|
|
3296
|
+
break;
|
|
3297
|
+
}
|
|
3298
|
+
let t = X(e, s, n, r);
|
|
3299
|
+
a(t.value) || q(`indefinite-length ${i} chunk must be a definite ${i}`), o.push(t.value), s = t.nextOffset;
|
|
3187
3300
|
}
|
|
3301
|
+
return {
|
|
3302
|
+
chunks: o,
|
|
3303
|
+
nextOffset: s
|
|
3304
|
+
};
|
|
3188
3305
|
}
|
|
3189
|
-
function
|
|
3190
|
-
let
|
|
3191
|
-
|
|
3306
|
+
function Ln(e, t, n, r) {
|
|
3307
|
+
let i = Fn(e);
|
|
3308
|
+
t.has(i) && n.push(Mn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
3192
3309
|
}
|
|
3193
|
-
function
|
|
3194
|
-
t
|
|
3195
|
-
|
|
3196
|
-
|
|
3310
|
+
function X(e, t, n, r) {
|
|
3311
|
+
let i = t, a = Rn(e, t, n, r);
|
|
3312
|
+
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
3313
|
+
}
|
|
3314
|
+
function Rn(e, t, n, r) {
|
|
3315
|
+
t >= e.byteLength && q("unexpected end of input");
|
|
3316
|
+
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
3317
|
+
switch (a) {
|
|
3197
3318
|
case 0: {
|
|
3198
|
-
let { value: n, nextOffset: r } = Y(e, t,
|
|
3319
|
+
let { value: n, nextOffset: r } = Y(e, t, o);
|
|
3199
3320
|
return {
|
|
3200
|
-
value: new
|
|
3321
|
+
value: new C(n),
|
|
3201
3322
|
nextOffset: r
|
|
3202
3323
|
};
|
|
3203
3324
|
}
|
|
3204
3325
|
case 1: {
|
|
3205
|
-
let { value: n, nextOffset: r } = Y(e, t,
|
|
3326
|
+
let { value: n, nextOffset: r } = Y(e, t, o);
|
|
3206
3327
|
return {
|
|
3207
|
-
value: new
|
|
3328
|
+
value: new w(-1n - n),
|
|
3208
3329
|
nextOffset: r
|
|
3209
3330
|
};
|
|
3210
3331
|
}
|
|
3211
3332
|
case 2: {
|
|
3212
|
-
if (
|
|
3213
|
-
let
|
|
3214
|
-
for (;;) {
|
|
3215
|
-
if (i >= e.byteLength && K("unexpected end of indefinite byte string"), e.getUint8(i) === 255) {
|
|
3216
|
-
i++;
|
|
3217
|
-
break;
|
|
3218
|
-
}
|
|
3219
|
-
let t = X(e, i, n);
|
|
3220
|
-
t.value instanceof T || K("indefinite-length byte string chunk must be a definite byte string"), r.push(t.value), i = t.nextOffset;
|
|
3221
|
-
}
|
|
3333
|
+
if (o === 31) {
|
|
3334
|
+
let { chunks: i, nextOffset: a } = In(e, t, n, r, "byte string", (e) => e instanceof O);
|
|
3222
3335
|
return {
|
|
3223
|
-
value: new
|
|
3224
|
-
nextOffset:
|
|
3336
|
+
value: new k(i),
|
|
3337
|
+
nextOffset: a
|
|
3225
3338
|
};
|
|
3226
3339
|
}
|
|
3227
|
-
let { value:
|
|
3228
|
-
return
|
|
3229
|
-
value: new
|
|
3230
|
-
nextOffset:
|
|
3340
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i);
|
|
3341
|
+
return a + s > e.byteLength && q("byte string extends beyond input"), {
|
|
3342
|
+
value: new O(new Uint8Array(e.buffer, e.byteOffset + a, s).slice()),
|
|
3343
|
+
nextOffset: a + s
|
|
3231
3344
|
};
|
|
3232
3345
|
}
|
|
3233
3346
|
case 3: {
|
|
3234
|
-
if (
|
|
3235
|
-
let
|
|
3236
|
-
for (;;) {
|
|
3237
|
-
if (i >= e.byteLength && K("unexpected end of indefinite text string"), e.getUint8(i) === 255) {
|
|
3238
|
-
i++;
|
|
3239
|
-
break;
|
|
3240
|
-
}
|
|
3241
|
-
let t = X(e, i, n);
|
|
3242
|
-
t.value instanceof I || K("indefinite-length text string chunk must be a definite text string"), r.push(t.value), i = t.nextOffset;
|
|
3243
|
-
}
|
|
3347
|
+
if (o === 31) {
|
|
3348
|
+
let { chunks: i, nextOffset: a } = In(e, t, n, r, "text string", (e) => e instanceof B);
|
|
3244
3349
|
return {
|
|
3245
|
-
value: new
|
|
3246
|
-
nextOffset:
|
|
3350
|
+
value: new A(i),
|
|
3351
|
+
nextOffset: a
|
|
3247
3352
|
};
|
|
3248
3353
|
}
|
|
3249
|
-
let { value:
|
|
3250
|
-
|
|
3251
|
-
let
|
|
3354
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i);
|
|
3355
|
+
a + s > e.byteLength && q("text string extends beyond input");
|
|
3356
|
+
let c = new Uint8Array(e.buffer, e.byteOffset + a, s), l, u;
|
|
3252
3357
|
try {
|
|
3253
|
-
|
|
3358
|
+
l = An.decode(c);
|
|
3254
3359
|
} catch {
|
|
3255
|
-
|
|
3360
|
+
u = Mn("invalid UTF-8 sequence in text string", a, n), l = jn.decode(c);
|
|
3256
3361
|
}
|
|
3257
|
-
let
|
|
3258
|
-
return
|
|
3259
|
-
value:
|
|
3260
|
-
nextOffset:
|
|
3362
|
+
let d = new B(l);
|
|
3363
|
+
return u && Nn(d, u), {
|
|
3364
|
+
value: d,
|
|
3365
|
+
nextOffset: a + s
|
|
3261
3366
|
};
|
|
3262
3367
|
}
|
|
3263
3368
|
case 4: {
|
|
3264
|
-
if (
|
|
3265
|
-
let
|
|
3369
|
+
if (o === 31) {
|
|
3370
|
+
let i = [], a = t;
|
|
3266
3371
|
for (;;) {
|
|
3267
|
-
if (
|
|
3268
|
-
|
|
3372
|
+
if (a >= e.byteLength && q("unexpected end of indefinite array"), e.getUint8(a) === 255) {
|
|
3373
|
+
a++;
|
|
3269
3374
|
break;
|
|
3270
3375
|
}
|
|
3271
|
-
let t = X(e,
|
|
3272
|
-
|
|
3376
|
+
let t = X(e, a, n, r);
|
|
3377
|
+
i.push(t.value), a = t.nextOffset;
|
|
3273
3378
|
}
|
|
3274
3379
|
return {
|
|
3275
|
-
value: new
|
|
3276
|
-
nextOffset:
|
|
3380
|
+
value: new j(i, { indefiniteLength: !0 }),
|
|
3381
|
+
nextOffset: a
|
|
3277
3382
|
};
|
|
3278
3383
|
}
|
|
3279
|
-
let { value:
|
|
3280
|
-
for (let t = 0; t <
|
|
3281
|
-
let t = X(e,
|
|
3282
|
-
|
|
3384
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = [], l = a;
|
|
3385
|
+
for (let t = 0; t < s; t++) {
|
|
3386
|
+
let t = X(e, l, n, r);
|
|
3387
|
+
c.push(t.value), l = t.nextOffset;
|
|
3283
3388
|
}
|
|
3284
3389
|
return {
|
|
3285
|
-
value: new
|
|
3286
|
-
nextOffset:
|
|
3390
|
+
value: new j(c),
|
|
3391
|
+
nextOffset: l
|
|
3287
3392
|
};
|
|
3288
3393
|
}
|
|
3289
3394
|
case 5: {
|
|
3290
|
-
if (
|
|
3291
|
-
let
|
|
3395
|
+
if (o === 31) {
|
|
3396
|
+
let i = [], a = /* @__PURE__ */ new Set(), o = [], s = t;
|
|
3292
3397
|
for (;;) {
|
|
3293
|
-
if (
|
|
3294
|
-
|
|
3398
|
+
if (s >= e.byteLength && q("unexpected end of indefinite map"), e.getUint8(s) === 255) {
|
|
3399
|
+
s++;
|
|
3295
3400
|
break;
|
|
3296
3401
|
}
|
|
3297
|
-
let t = X(e,
|
|
3298
|
-
|
|
3299
|
-
let c = X(e,
|
|
3300
|
-
|
|
3402
|
+
let t = X(e, s, n, r);
|
|
3403
|
+
Ln(t.value, a, o, n), s = t.nextOffset;
|
|
3404
|
+
let c = X(e, s, n, r);
|
|
3405
|
+
s = c.nextOffset, i.push([t.value, c.value]);
|
|
3301
3406
|
}
|
|
3302
|
-
let
|
|
3303
|
-
for (let e of
|
|
3407
|
+
let c = new M(i, { indefiniteLength: !0 });
|
|
3408
|
+
for (let e of o) Nn(c, e);
|
|
3304
3409
|
return {
|
|
3305
|
-
value:
|
|
3306
|
-
nextOffset:
|
|
3410
|
+
value: c,
|
|
3411
|
+
nextOffset: s
|
|
3307
3412
|
};
|
|
3308
3413
|
}
|
|
3309
|
-
let { value:
|
|
3310
|
-
for (let t = 0; t <
|
|
3311
|
-
let t = X(e,
|
|
3312
|
-
|
|
3313
|
-
let i = X(e,
|
|
3314
|
-
|
|
3414
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
|
|
3415
|
+
for (let t = 0; t < s; t++) {
|
|
3416
|
+
let t = X(e, d, n, r);
|
|
3417
|
+
Ln(t.value, l, u, n), d = t.nextOffset;
|
|
3418
|
+
let i = X(e, d, n, r);
|
|
3419
|
+
d = i.nextOffset, c.push([t.value, i.value]);
|
|
3315
3420
|
}
|
|
3316
|
-
let
|
|
3317
|
-
for (let e of
|
|
3421
|
+
let f = new M(c);
|
|
3422
|
+
for (let e of u) Nn(f, e);
|
|
3318
3423
|
return {
|
|
3319
|
-
value:
|
|
3320
|
-
nextOffset:
|
|
3424
|
+
value: f,
|
|
3425
|
+
nextOffset: d
|
|
3321
3426
|
};
|
|
3322
3427
|
}
|
|
3323
3428
|
case 6: {
|
|
3324
|
-
|
|
3325
|
-
let { value:
|
|
3326
|
-
for (let e of
|
|
3327
|
-
let t = e.parseTag(
|
|
3429
|
+
o === 31 && q("tags cannot use indefinite-length encoding");
|
|
3430
|
+
let { value: i, nextOffset: a } = Y(e, t, o), s = X(e, a, n, r);
|
|
3431
|
+
for (let e of r) {
|
|
3432
|
+
let t = e.parseTag(i, s.value, n);
|
|
3328
3433
|
if (t !== void 0) return {
|
|
3329
3434
|
value: t,
|
|
3330
|
-
nextOffset:
|
|
3435
|
+
nextOffset: s.nextOffset
|
|
3331
3436
|
};
|
|
3332
3437
|
}
|
|
3333
3438
|
return {
|
|
3334
|
-
value: new
|
|
3335
|
-
nextOffset:
|
|
3439
|
+
value: new E(i, s.value),
|
|
3440
|
+
nextOffset: s.nextOffset
|
|
3336
3441
|
};
|
|
3337
3442
|
}
|
|
3338
3443
|
case 7:
|
|
3339
|
-
if (
|
|
3340
|
-
value: new
|
|
3444
|
+
if (o <= 19) return {
|
|
3445
|
+
value: new N(o),
|
|
3341
3446
|
nextOffset: t
|
|
3342
3447
|
};
|
|
3343
|
-
if (
|
|
3344
|
-
value:
|
|
3448
|
+
if (o === 20) return {
|
|
3449
|
+
value: N.FALSE,
|
|
3345
3450
|
nextOffset: t
|
|
3346
3451
|
};
|
|
3347
|
-
if (
|
|
3348
|
-
value:
|
|
3452
|
+
if (o === 21) return {
|
|
3453
|
+
value: N.TRUE,
|
|
3349
3454
|
nextOffset: t
|
|
3350
3455
|
};
|
|
3351
|
-
if (
|
|
3352
|
-
value:
|
|
3456
|
+
if (o === 22) return {
|
|
3457
|
+
value: N.NULL,
|
|
3353
3458
|
nextOffset: t
|
|
3354
3459
|
};
|
|
3355
|
-
if (
|
|
3356
|
-
value:
|
|
3460
|
+
if (o === 23) return {
|
|
3461
|
+
value: N.UNDEFINED,
|
|
3357
3462
|
nextOffset: t
|
|
3358
3463
|
};
|
|
3359
|
-
if (
|
|
3360
|
-
t + 1 > e.byteLength &&
|
|
3464
|
+
if (o === 24) {
|
|
3465
|
+
t + 1 > e.byteLength && q("unexpected end of input");
|
|
3361
3466
|
let r = e.getUint8(t);
|
|
3362
3467
|
if (r < 32) {
|
|
3363
|
-
let e =
|
|
3364
|
-
return
|
|
3468
|
+
let e = Mn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new N(r);
|
|
3469
|
+
return Nn(i, e), {
|
|
3365
3470
|
value: i,
|
|
3366
3471
|
nextOffset: t + 1
|
|
3367
3472
|
};
|
|
3368
3473
|
}
|
|
3369
3474
|
return {
|
|
3370
|
-
value: new
|
|
3475
|
+
value: new N(r),
|
|
3371
3476
|
nextOffset: t + 1
|
|
3372
3477
|
};
|
|
3373
3478
|
}
|
|
3374
|
-
return
|
|
3375
|
-
value: new
|
|
3479
|
+
return o === 25 ? (t + 2 > e.byteLength && q("unexpected end of input"), {
|
|
3480
|
+
value: new T(_(e.getUint16(t, !1)), { precision: "half" }),
|
|
3376
3481
|
nextOffset: t + 2
|
|
3377
|
-
}) :
|
|
3378
|
-
value: new
|
|
3482
|
+
}) : o === 26 ? (t + 4 > e.byteLength && q("unexpected end of input"), {
|
|
3483
|
+
value: new T(e.getFloat32(t, !1), { precision: "single" }),
|
|
3379
3484
|
nextOffset: t + 4
|
|
3380
|
-
}) :
|
|
3381
|
-
value: new
|
|
3485
|
+
}) : o === 27 ? (t + 8 > e.byteLength && q("unexpected end of input"), {
|
|
3486
|
+
value: new T(e.getFloat64(t, !1), { precision: "double" }),
|
|
3382
3487
|
nextOffset: t + 8
|
|
3383
|
-
}) : (
|
|
3488
|
+
}) : (o < 31 && q(`reserved additional info value in major type 7: ${o}`), q("unexpected break code outside indefinite-length item"));
|
|
3384
3489
|
}
|
|
3385
|
-
return
|
|
3490
|
+
return q(`unknown major type: ${a}`);
|
|
3386
3491
|
}
|
|
3387
|
-
function
|
|
3492
|
+
function zn(e) {
|
|
3388
3493
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
3389
3494
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
3390
3495
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
3391
3496
|
}
|
|
3392
|
-
function
|
|
3393
|
-
let n =
|
|
3497
|
+
function Bn(e, t) {
|
|
3498
|
+
let n = zn(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
3394
3499
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
3395
|
-
let { value: a, nextOffset: o } = X(r, i, t);
|
|
3396
|
-
return !t?.allowTrailing && o !== r.byteLength &&
|
|
3500
|
+
let { value: a, nextOffset: o } = X(r, i, t, [...t?.extensions ?? [], ...Z].filter((e) => e.parseTag !== void 0));
|
|
3501
|
+
return !t?.allowTrailing && o !== r.byteLength && q(`${r.byteLength - o} trailing byte(s) after end of CBOR item`), a;
|
|
3397
3502
|
}
|
|
3398
3503
|
//#endregion
|
|
3399
3504
|
//#region src/extensions/cbordata.ts
|
|
3400
|
-
var
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3505
|
+
var Vn = 24n, Z = [
|
|
3506
|
+
Ft,
|
|
3507
|
+
$t,
|
|
3508
|
+
nn,
|
|
3509
|
+
kn,
|
|
3405
3510
|
{
|
|
3406
|
-
tagNumbers: [
|
|
3511
|
+
tagNumbers: [Vn],
|
|
3407
3512
|
parseTag(e, t, n) {
|
|
3408
|
-
if (e !== 24n || !(t instanceof
|
|
3513
|
+
if (e !== 24n || !(t instanceof O)) return;
|
|
3409
3514
|
let r = n ? {
|
|
3410
3515
|
extensions: n.extensions,
|
|
3411
3516
|
strict: n.strict,
|
|
@@ -3413,7 +3518,7 @@ var yn = 24n, Z = [
|
|
|
3413
3518
|
silent: n.silent
|
|
3414
3519
|
} : void 0;
|
|
3415
3520
|
try {
|
|
3416
|
-
return new
|
|
3521
|
+
return new E(Vn, new P([Bn(t.value, r)]));
|
|
3417
3522
|
} catch (e) {
|
|
3418
3523
|
if (r?.strict !== !1) throw e;
|
|
3419
3524
|
return;
|
|
@@ -3425,50 +3530,50 @@ var yn = 24n, Z = [
|
|
|
3425
3530
|
//#region src/js/fromJS.ts
|
|
3426
3531
|
function Q(e, t) {
|
|
3427
3532
|
if (t?.replacer) {
|
|
3428
|
-
let { replacer: n, ...r } = t, i =
|
|
3429
|
-
return i === l ?
|
|
3533
|
+
let { replacer: n, ...r } = t, i = Wn(e, n, r.extensions, r.undefinedOmits);
|
|
3534
|
+
return i === l ? N.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
|
|
3430
3535
|
}
|
|
3431
|
-
return
|
|
3536
|
+
return Hn(e, t, !0);
|
|
3432
3537
|
}
|
|
3433
|
-
function
|
|
3538
|
+
function Hn(e, t, n) {
|
|
3434
3539
|
for (let n of [...t?.extensions ?? [], ...Z]) if (n.fromJS) {
|
|
3435
3540
|
let r = n.fromJS(e, t ?? {});
|
|
3436
3541
|
if (r !== void 0) return r;
|
|
3437
3542
|
}
|
|
3438
3543
|
if (n && typeof e == "object" && e && c.symbol in e) {
|
|
3439
|
-
let n = e[c.symbol], r =
|
|
3544
|
+
let n = e[c.symbol], r = Hn(e, t, !1);
|
|
3440
3545
|
for (let e of [...t?.extensions ?? [], ...Z]) if (e.parseTag) {
|
|
3441
3546
|
let t = e.parseTag(n, r);
|
|
3442
3547
|
if (t !== void 0) return t;
|
|
3443
3548
|
}
|
|
3444
|
-
return new
|
|
3445
|
-
}
|
|
3446
|
-
if (e instanceof c.Null) return
|
|
3447
|
-
if (e instanceof c.Undefined) return
|
|
3448
|
-
if (e instanceof u) return new
|
|
3449
|
-
if (e === null) return
|
|
3450
|
-
if (e === void 0) return
|
|
3451
|
-
if (e === !0) return
|
|
3452
|
-
if (e === !1) return
|
|
3453
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new
|
|
3454
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new
|
|
3455
|
-
if (typeof e == "string") return new
|
|
3456
|
-
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return
|
|
3457
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new
|
|
3458
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new
|
|
3459
|
-
if (e instanceof $) return new
|
|
3460
|
-
if (Array.isArray(e)) return new
|
|
3549
|
+
return new E(n, r);
|
|
3550
|
+
}
|
|
3551
|
+
if (e instanceof c.Null) return N.NULL;
|
|
3552
|
+
if (e instanceof c.Undefined) return N.UNDEFINED;
|
|
3553
|
+
if (e instanceof u) return new N(e.value);
|
|
3554
|
+
if (e === null) return N.NULL;
|
|
3555
|
+
if (e === void 0) return N.UNDEFINED;
|
|
3556
|
+
if (e === !0) return N.TRUE;
|
|
3557
|
+
if (e === !1) return N.FALSE;
|
|
3558
|
+
if (typeof e == "bigint") return e > 18446744073709551615n ? new L(e) : e < -18446744073709551616n ? new R(e) : e >= 0n ? new C(e) : new w(e);
|
|
3559
|
+
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new C(BigInt(e)) : new w(BigInt(e)) : new T(e);
|
|
3560
|
+
if (typeof e == "string") return new B(e);
|
|
3561
|
+
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Hn(e.valueOf(), t, !1);
|
|
3562
|
+
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new O(new Uint8Array(e));
|
|
3563
|
+
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new j(Array.from(e, (e) => new C(BigInt(e)))) : new O(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
3564
|
+
if (e instanceof $) return new M([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
|
|
3565
|
+
if (Array.isArray(e)) return new j(e.map((e) => Q(e, t)));
|
|
3461
3566
|
if (typeof e == "object") {
|
|
3462
3567
|
let n = [];
|
|
3463
|
-
for (let [r, i] of Object.entries(e)) n.push([new
|
|
3464
|
-
return new
|
|
3568
|
+
for (let [r, i] of Object.entries(e)) n.push([new B(r), Q(i, t)]);
|
|
3569
|
+
return new M(n);
|
|
3465
3570
|
}
|
|
3466
3571
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
3467
3572
|
}
|
|
3468
|
-
function
|
|
3573
|
+
function Un(e) {
|
|
3469
3574
|
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 c.Null || e instanceof c.Undefined || e instanceof u;
|
|
3470
3575
|
}
|
|
3471
|
-
function
|
|
3576
|
+
function Wn(e, t, n, r) {
|
|
3472
3577
|
let i = [...n ?? [], ...Z];
|
|
3473
3578
|
function a(e) {
|
|
3474
3579
|
return e === l || r === !0 && e === void 0;
|
|
@@ -3479,7 +3584,7 @@ function Sn(e, t, n, r) {
|
|
|
3479
3584
|
if (typeof e != "object" || !e) return e;
|
|
3480
3585
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
3481
3586
|
if (Array.isArray(e)) return e.map(r);
|
|
3482
|
-
if (c.symbol in e ||
|
|
3587
|
+
if (c.symbol in e || Un(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
3483
3588
|
let t = Object.getPrototypeOf(e);
|
|
3484
3589
|
if (t === Object.prototype || t === null) {
|
|
3485
3590
|
let t = e.toJSON;
|
|
@@ -3514,7 +3619,7 @@ function Sn(e, t, n, r) {
|
|
|
3514
3619
|
let r = s(t, String(n), e);
|
|
3515
3620
|
return a(r) ? null : r;
|
|
3516
3621
|
});
|
|
3517
|
-
if (
|
|
3622
|
+
if (Un(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
3518
3623
|
let t = {};
|
|
3519
3624
|
for (let n of Object.keys(e)) {
|
|
3520
3625
|
let r = s(e[n], n, e);
|
|
@@ -3544,6 +3649,6 @@ var $ = class extends Array {
|
|
|
3544
3649
|
}
|
|
3545
3650
|
};
|
|
3546
3651
|
//#endregion
|
|
3547
|
-
export { u as C, c as D, t as E, n as O, _ as S, e as T,
|
|
3652
|
+
export { u as C, c as D, t as E, n as O, _ as S, e as T, E as _, It as a, C as b, R as c, N as d, M as f, O as g, k as h, Bn as i, L as l, A as m, Wn as n, B as o, j as p, Q as r, Ze as s, $ as t, P as u, T as v, l as w, S as x, w as y };
|
|
3548
3653
|
|
|
3549
|
-
//# sourceMappingURL=mapEntries-
|
|
3654
|
+
//# sourceMappingURL=mapEntries-BMMPg2FB.js.map
|