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