@cbortech/cbor 0.25.2 → 0.25.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/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +80 -84
- package/dist/index.js.map +1 -1
- package/dist/{mapEntries-BMMPg2FB.js → mapEntries-C8HTvn5t.js} +456 -444
- package/dist/mapEntries-C8HTvn5t.js.map +1 -0
- package/dist/mapEntries-o_ePE8Io.cjs +39 -0
- package/dist/mapEntries-o_ePE8Io.cjs.map +1 -0
- package/dist/utils/hex.d.ts +19 -0
- package/package.json +2 -2
- package/dist/mapEntries-BMMPg2FB.js.map +0 -1
- package/dist/mapEntries-DZKHc3VY.cjs +0 -39
- package/dist/mapEntries-DZKHc3VY.cjs.map +0 -1
|
@@ -92,23 +92,45 @@ var c = class {
|
|
|
92
92
|
static get(t) {
|
|
93
93
|
return t instanceof e ? t.value : void 0;
|
|
94
94
|
}
|
|
95
|
-
};
|
|
95
|
+
}, d = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), f = new Int8Array(128).fill(-1);
|
|
96
|
+
for (let e = 0; e < 16; e++) f["0123456789abcdef".charCodeAt(e)] = e, f["0123456789ABCDEF".charCodeAt(e)] = e;
|
|
97
|
+
var p = typeof Uint8Array.prototype.toHex == "function", m = typeof Uint8Array.fromHex == "function", ee = 256;
|
|
98
|
+
function te(e) {
|
|
99
|
+
if (p) return e.toHex();
|
|
100
|
+
let t = "";
|
|
101
|
+
for (let n = 0; n < e.length; n++) t += d[e[n]];
|
|
102
|
+
return t;
|
|
103
|
+
}
|
|
104
|
+
function ne(e) {
|
|
105
|
+
if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
|
|
106
|
+
if (m && e.length >= ee) return Uint8Array.fromHex(e);
|
|
107
|
+
let t = new Uint8Array(e.length / 2);
|
|
108
|
+
for (let n = 0, r = 0; n < e.length; n += 2, r++) {
|
|
109
|
+
let i = e.charCodeAt(n), a = e.charCodeAt(n + 1), o = i < 128 ? f[i] : -1, s = a < 128 ? f[a] : -1;
|
|
110
|
+
if ((o | s) < 0) {
|
|
111
|
+
let t = o < 0 ? e[n] : e[n + 1];
|
|
112
|
+
throw SyntaxError(`invalid character ${JSON.stringify(t)} in hex string`);
|
|
113
|
+
}
|
|
114
|
+
t[r] = o << 4 | s;
|
|
115
|
+
}
|
|
116
|
+
return t;
|
|
117
|
+
}
|
|
96
118
|
//#endregion
|
|
97
119
|
//#region src/cdn/serialize-utils.ts
|
|
98
|
-
function
|
|
120
|
+
function re(e) {
|
|
99
121
|
let t = e?.indent;
|
|
100
122
|
return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
|
|
101
123
|
}
|
|
102
|
-
function
|
|
124
|
+
function h(e, t) {
|
|
103
125
|
return e.repeat(t);
|
|
104
126
|
}
|
|
105
|
-
function
|
|
127
|
+
function ie(e) {
|
|
106
128
|
return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
107
129
|
}
|
|
108
|
-
function
|
|
130
|
+
function ae(e) {
|
|
109
131
|
return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
|
|
110
132
|
}
|
|
111
|
-
function
|
|
133
|
+
function g(e, t) {
|
|
112
134
|
if (!t) return e.text;
|
|
113
135
|
let { marker: n, text: r } = e;
|
|
114
136
|
if (t === "c-style") return n === "#" ? "//" + r.slice(1) : n === "/" ? "/*" + r.slice(1, -1) + "*/" : r;
|
|
@@ -119,17 +141,17 @@ function m(e, t) {
|
|
|
119
141
|
}
|
|
120
142
|
return r;
|
|
121
143
|
}
|
|
122
|
-
function
|
|
123
|
-
return (e.comments?.leading ?? []).map((e) => t +
|
|
144
|
+
function oe(e, t, n) {
|
|
145
|
+
return (e.comments?.leading ?? []).map((e) => t + g(e, n));
|
|
124
146
|
}
|
|
125
|
-
function
|
|
147
|
+
function se(e, t) {
|
|
126
148
|
let n = e.comments?.trailing ?? [];
|
|
127
|
-
return n.length === 0 ? "" : " " + n.map((e) =>
|
|
149
|
+
return n.length === 0 ? "" : " " + n.map((e) => g(e, t)).join(" ");
|
|
128
150
|
}
|
|
129
|
-
function
|
|
130
|
-
return (e.comments?.dangling ?? []).map((e) => t +
|
|
151
|
+
function ce(e, t, n) {
|
|
152
|
+
return (e.comments?.dangling ?? []).map((e) => t + g(e, n));
|
|
131
153
|
}
|
|
132
|
-
function
|
|
154
|
+
function le(e, t = !1) {
|
|
133
155
|
let n = e?.commas ?? "comma", r = n !== "none";
|
|
134
156
|
return {
|
|
135
157
|
inlineSep: r ? t ? "," : ", " : " ",
|
|
@@ -138,18 +160,15 @@ function re(e, t = !1) {
|
|
|
138
160
|
colSep: t ? ":" : ": "
|
|
139
161
|
};
|
|
140
162
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
var g = typeof new Uint8Array().toBase64 == "function";
|
|
145
|
-
function ae(e) {
|
|
146
|
-
if (g) return e.toBase64({ omitPadding: !0 });
|
|
163
|
+
var ue = typeof new Uint8Array().toBase64 == "function";
|
|
164
|
+
function de(e) {
|
|
165
|
+
if (ue) return e.toBase64({ omitPadding: !0 });
|
|
147
166
|
let t = "";
|
|
148
167
|
for (let n of e) t += String.fromCharCode(n);
|
|
149
168
|
return btoa(t).replace(/=/g, "");
|
|
150
169
|
}
|
|
151
|
-
function
|
|
152
|
-
if (
|
|
170
|
+
function fe(e) {
|
|
171
|
+
if (ue) return e.toBase64({
|
|
153
172
|
alphabet: "base64url",
|
|
154
173
|
omitPadding: !0
|
|
155
174
|
});
|
|
@@ -157,54 +176,54 @@ function oe(e) {
|
|
|
157
176
|
for (let n of e) t += String.fromCharCode(n);
|
|
158
177
|
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
159
178
|
}
|
|
160
|
-
var
|
|
161
|
-
function
|
|
179
|
+
var pe = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", me = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
180
|
+
function he(e, t) {
|
|
162
181
|
let n = "", r = 0, i = 0;
|
|
163
182
|
for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
|
|
164
183
|
return i > 0 && (n += t[r << 5 - i & 31]), n;
|
|
165
184
|
}
|
|
166
|
-
function
|
|
185
|
+
function ge(e) {
|
|
167
186
|
for (let t of e) {
|
|
168
187
|
let e = t.codePointAt(0);
|
|
169
188
|
if (e < 32 || e === 127) return !0;
|
|
170
189
|
}
|
|
171
190
|
return !1;
|
|
172
191
|
}
|
|
173
|
-
function
|
|
192
|
+
function _e(e, t, n) {
|
|
174
193
|
if (n === "string") {
|
|
175
|
-
let t =
|
|
176
|
-
if (t != null) return
|
|
194
|
+
let t = ye(e);
|
|
195
|
+
if (t != null) return Se(t);
|
|
177
196
|
}
|
|
178
197
|
if (n === "printable-string" || n === void 0) {
|
|
179
|
-
let t =
|
|
180
|
-
if (t != null && !
|
|
198
|
+
let t = ye(e);
|
|
199
|
+
if (t != null && !ge(t)) return Se(t);
|
|
181
200
|
}
|
|
182
201
|
switch (t) {
|
|
183
|
-
case "base64": return `b64'${
|
|
184
|
-
case "base64url": return `b64'${
|
|
185
|
-
case "base32": return `b32'${
|
|
186
|
-
case "base32hex": return `h32'${
|
|
187
|
-
default: return `h'${
|
|
202
|
+
case "base64": return `b64'${de(e)}'`;
|
|
203
|
+
case "base64url": return `b64'${fe(e)}'`;
|
|
204
|
+
case "base32": return `b32'${he(e, pe)}'`;
|
|
205
|
+
case "base32hex": return `h32'${he(e, me)}'`;
|
|
206
|
+
default: return `h'${te(e)}'`;
|
|
188
207
|
}
|
|
189
208
|
}
|
|
190
|
-
var
|
|
191
|
-
function
|
|
209
|
+
var ve = new TextDecoder("utf-8", { fatal: !0 });
|
|
210
|
+
function ye(e) {
|
|
192
211
|
try {
|
|
193
|
-
return
|
|
212
|
+
return ve.decode(e);
|
|
194
213
|
} catch {
|
|
195
214
|
return null;
|
|
196
215
|
}
|
|
197
216
|
}
|
|
198
|
-
function
|
|
217
|
+
function be(e, t) {
|
|
199
218
|
for (let n = 0; n < e.length; n++) {
|
|
200
219
|
let r = e.charCodeAt(n);
|
|
201
220
|
if (r === t || r === 92 || r < 32 || r === 127 || r >= 8192 && (r === 8232 || r === 8233 || r >= 8203 && r <= 8205 || r === 65279)) return !0;
|
|
202
221
|
}
|
|
203
222
|
return !1;
|
|
204
223
|
}
|
|
205
|
-
function
|
|
224
|
+
function xe(e, t) {
|
|
206
225
|
let n = t.codePointAt(0);
|
|
207
|
-
if (!
|
|
226
|
+
if (!be(e, n)) return t + e + t;
|
|
208
227
|
let r = t;
|
|
209
228
|
for (let i of e) {
|
|
210
229
|
let e = i.codePointAt(0);
|
|
@@ -229,31 +248,31 @@ function he(e, t) {
|
|
|
229
248
|
}
|
|
230
249
|
return r + t;
|
|
231
250
|
}
|
|
232
|
-
function
|
|
233
|
-
return
|
|
251
|
+
function Se(e) {
|
|
252
|
+
return xe(e, "'");
|
|
234
253
|
}
|
|
235
|
-
function
|
|
236
|
-
return
|
|
254
|
+
function Ce(e) {
|
|
255
|
+
return xe(e, "'");
|
|
237
256
|
}
|
|
238
|
-
function
|
|
239
|
-
return
|
|
257
|
+
function we(e) {
|
|
258
|
+
return xe(e, "\"");
|
|
240
259
|
}
|
|
241
|
-
function
|
|
260
|
+
function Te(e) {
|
|
242
261
|
if (isNaN(e)) return "NaN";
|
|
243
262
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
244
263
|
if (Object.is(e, -0)) return "-0.0";
|
|
245
264
|
let t = e.toString();
|
|
246
265
|
return t.includes(".") || t.includes("e") ? t : t + ".0";
|
|
247
266
|
}
|
|
248
|
-
function
|
|
267
|
+
function Ee(e, t, n) {
|
|
249
268
|
return t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
|
|
250
269
|
}
|
|
251
270
|
//#endregion
|
|
252
271
|
//#region src/utils/float16.ts
|
|
253
|
-
var
|
|
254
|
-
function
|
|
255
|
-
|
|
256
|
-
let t =
|
|
272
|
+
var De = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Oe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
273
|
+
function ke(e) {
|
|
274
|
+
Oe.setFloat64(0, e, !1);
|
|
275
|
+
let t = Oe.getUint32(0, !1), n = Oe.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
257
276
|
if (i === 2047) {
|
|
258
277
|
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
259
278
|
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
@@ -274,15 +293,15 @@ function Ce(e) {
|
|
|
274
293
|
let u = o <= 0 ? 0 : o;
|
|
275
294
|
return r << 15 | u << 10 | s;
|
|
276
295
|
}
|
|
277
|
-
function
|
|
296
|
+
function Ae(e) {
|
|
278
297
|
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
279
298
|
return n === 31 ? r === 0 ? t ? -Infinity : Infinity : NaN : n === 0 ? r === 0 ? t ? -0 : 0 : (t ? -1 : 1) * 2 ** -14 * (r / 1024) : (t ? -1 : 1) * 2 ** (n - 15) * (1 + r / 1024);
|
|
280
299
|
}
|
|
281
|
-
var
|
|
300
|
+
var je = De ? (e, t, n, r) => {
|
|
282
301
|
e.setFloat16(t, n, r);
|
|
283
302
|
} : (e, t, n, r) => {
|
|
284
|
-
e.setUint16(t,
|
|
285
|
-
},
|
|
303
|
+
e.setUint16(t, ke(n), r);
|
|
304
|
+
}, _ = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), v = new Uint8Array(_.buffer), y = class {
|
|
286
305
|
buf;
|
|
287
306
|
len = 0;
|
|
288
307
|
constructor(e = 256) {
|
|
@@ -313,34 +332,34 @@ var we = xe ? (e, t, n, r) => {
|
|
|
313
332
|
t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
314
333
|
}
|
|
315
334
|
writeBigUint64(e) {
|
|
316
|
-
|
|
335
|
+
_.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(v, this.len), this.len += 8;
|
|
317
336
|
}
|
|
318
337
|
writeFloat16(e) {
|
|
319
|
-
|
|
338
|
+
je(_, 0, e, !1), this._ensure(2);
|
|
320
339
|
let t = this.buf;
|
|
321
|
-
t[this.len++] =
|
|
340
|
+
t[this.len++] = v[0], t[this.len++] = v[1];
|
|
322
341
|
}
|
|
323
342
|
writeFloat32(e) {
|
|
324
|
-
|
|
343
|
+
_.setFloat32(0, e, !1), this._ensure(4);
|
|
325
344
|
let t = this.buf;
|
|
326
|
-
t[this.len++] =
|
|
345
|
+
t[this.len++] = v[0], t[this.len++] = v[1], t[this.len++] = v[2], t[this.len++] = v[3];
|
|
327
346
|
}
|
|
328
347
|
writeFloat64(e) {
|
|
329
|
-
|
|
348
|
+
_.setFloat64(0, e, !1), this._ensure(8), this.buf.set(v, this.len), this.len += 8;
|
|
330
349
|
}
|
|
331
350
|
finish() {
|
|
332
351
|
return this.buf.slice(0, this.len);
|
|
333
352
|
}
|
|
334
|
-
},
|
|
353
|
+
}, Me = [
|
|
335
354
|
255n,
|
|
336
355
|
65535n,
|
|
337
356
|
4294967295n,
|
|
338
357
|
18446744073709551615n
|
|
339
358
|
];
|
|
340
|
-
function
|
|
341
|
-
return e === "i" ? 23n :
|
|
359
|
+
function Ne(e) {
|
|
360
|
+
return e === "i" ? 23n : Me[e];
|
|
342
361
|
}
|
|
343
|
-
function
|
|
362
|
+
function b(e, t, n, r) {
|
|
344
363
|
if (r === void 0 && typeof n == "number" && n < 4294967296) {
|
|
345
364
|
n <= 23 ? e.writeByte(t << 5 | n) : n <= 255 ? (e.writeByte(t << 5 | 24), e.writeByte(n)) : n <= 65535 ? (e.writeByte(t << 5 | 25), e.writeUint16(n)) : (e.writeByte(t << 5 | 26), e.writeUint32(n));
|
|
346
365
|
return;
|
|
@@ -352,26 +371,26 @@ function x(e, t, n, r) {
|
|
|
352
371
|
e.writeByte(t << 5 | Number(i));
|
|
353
372
|
return;
|
|
354
373
|
}
|
|
355
|
-
if (i >
|
|
374
|
+
if (i > Me[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${Me[r]})`);
|
|
356
375
|
let n = 24 + r;
|
|
357
376
|
e.writeByte(t << 5 | n), n === 24 ? e.writeByte(Number(i)) : n === 25 ? e.writeUint16(Number(i)) : n === 26 ? e.writeUint32(Number(i)) : e.writeBigUint64(i);
|
|
358
377
|
return;
|
|
359
378
|
}
|
|
360
379
|
i <= 23n ? e.writeByte(t << 5 | Number(i)) : i <= 255n ? (e.writeByte(t << 5 | 24), e.writeByte(Number(i))) : i <= 65535n ? (e.writeByte(t << 5 | 25), e.writeUint16(Number(i))) : i <= 4294967295n ? (e.writeByte(t << 5 | 26), e.writeUint32(Number(i))) : (e.writeByte(t << 5 | 27), e.writeBigUint64(i));
|
|
361
380
|
}
|
|
362
|
-
function
|
|
363
|
-
let r = new
|
|
364
|
-
return
|
|
381
|
+
function x(e, t, n) {
|
|
382
|
+
let r = new y(9);
|
|
383
|
+
return b(r, e, t, n), r.finish();
|
|
365
384
|
}
|
|
366
|
-
var
|
|
367
|
-
function
|
|
368
|
-
return Object.is(
|
|
385
|
+
var Pe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
386
|
+
function Fe(e) {
|
|
387
|
+
return Object.is(Ae(ke(e)), e);
|
|
369
388
|
}
|
|
370
|
-
function
|
|
371
|
-
return
|
|
389
|
+
function Ie(e) {
|
|
390
|
+
return Pe.setFloat32(0, e, !1), Object.is(Pe.getFloat32(0, !1), e);
|
|
372
391
|
}
|
|
373
|
-
function
|
|
374
|
-
return
|
|
392
|
+
function Le(e) {
|
|
393
|
+
return Fe(e) ? "half" : Ie(e) ? "single" : "double";
|
|
375
394
|
}
|
|
376
395
|
//#endregion
|
|
377
396
|
//#region src/ast/CborItem.ts
|
|
@@ -385,7 +404,7 @@ var S = class e {
|
|
|
385
404
|
let t = this._defaults ? {
|
|
386
405
|
...this._defaults,
|
|
387
406
|
...e
|
|
388
|
-
} : e, n = new
|
|
407
|
+
} : e, n = new y();
|
|
389
408
|
return this._encode(n, t), n.finish();
|
|
390
409
|
}
|
|
391
410
|
toCDN(e) {
|
|
@@ -394,7 +413,7 @@ var S = class e {
|
|
|
394
413
|
...e
|
|
395
414
|
} : e, n = this._toCDN(t, 0), r = t?.preserveComments;
|
|
396
415
|
if (!r) return n;
|
|
397
|
-
let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) =>
|
|
416
|
+
let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) => g(e, i)) ?? [], o = this.comments?.trailing ?? [], s = o.length === 0 ? n : `${n} ${o.map((e) => g(e, i).trimEnd()).join(" ")}`;
|
|
398
417
|
return [...a, s].join("\n");
|
|
399
418
|
}
|
|
400
419
|
toEDN(e) {
|
|
@@ -428,7 +447,7 @@ var S = class e {
|
|
|
428
447
|
t.writeBytes(this._toCBOR(n));
|
|
429
448
|
}
|
|
430
449
|
_toCBOR(e) {
|
|
431
|
-
let t = new
|
|
450
|
+
let t = new y();
|
|
432
451
|
return this._encodeTo(t, e), t.finish();
|
|
433
452
|
}
|
|
434
453
|
_toHexDump(e, t) {
|
|
@@ -447,7 +466,7 @@ var S = class e {
|
|
|
447
466
|
this.encodingWidth = t?.encodingWidth;
|
|
448
467
|
}
|
|
449
468
|
_encodeTo(e, t) {
|
|
450
|
-
|
|
469
|
+
b(e, 0, this.value, this.encodingWidth);
|
|
451
470
|
}
|
|
452
471
|
_toCDN(e, t) {
|
|
453
472
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.value;
|
|
@@ -476,7 +495,7 @@ var S = class e {
|
|
|
476
495
|
return -1n - this.argument;
|
|
477
496
|
}
|
|
478
497
|
_encodeTo(e, t) {
|
|
479
|
-
|
|
498
|
+
b(e, 1, this.argument, this.encodingWidth);
|
|
480
499
|
}
|
|
481
500
|
_toCDN(e, t) {
|
|
482
501
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.argument + 1n;
|
|
@@ -491,8 +510,8 @@ var S = class e {
|
|
|
491
510
|
let t = this.value, n = e?.integerAs ?? "auto";
|
|
492
511
|
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
493
512
|
}
|
|
494
|
-
},
|
|
495
|
-
function
|
|
513
|
+
}, Re = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
514
|
+
function ze(e) {
|
|
496
515
|
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
497
516
|
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
498
517
|
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
@@ -510,13 +529,13 @@ function Ne(e) {
|
|
|
510
529
|
let l = c * 2 ** o;
|
|
511
530
|
return t ? -l : l;
|
|
512
531
|
}
|
|
513
|
-
function
|
|
532
|
+
function Be(e) {
|
|
514
533
|
if (isNaN(e)) return "NaN";
|
|
515
534
|
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
516
535
|
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
517
536
|
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
518
|
-
|
|
519
|
-
let r =
|
|
537
|
+
Re.setFloat64(0, n, !1);
|
|
538
|
+
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;
|
|
520
539
|
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
521
540
|
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
522
541
|
return t ? `-${p}` : p;
|
|
@@ -531,13 +550,13 @@ var T = class extends S {
|
|
|
531
550
|
super(), this.value = e, this.precision = t?.precision;
|
|
532
551
|
}
|
|
533
552
|
_encodeTo(e, t) {
|
|
534
|
-
let n = this.precision ??
|
|
553
|
+
let n = this.precision ?? Le(this.value);
|
|
535
554
|
n === "half" ? (e.writeByte(249), e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), e.writeFloat32(this.value)) : (e.writeByte(251), e.writeFloat64(this.value));
|
|
536
555
|
}
|
|
537
556
|
_toCDN(e, t) {
|
|
538
557
|
if (e?.appStrings !== !1 && this.ednSource !== void 0) return this.ednSource;
|
|
539
|
-
let n =
|
|
540
|
-
return (e?.floatFormat === "hex" ?
|
|
558
|
+
let n = Le(this.value);
|
|
559
|
+
return (e?.floatFormat === "hex" ? Be(this.value) : Te(this.value)) + Ee(this.value, this.precision, n);
|
|
541
560
|
}
|
|
542
561
|
_toJS(e) {
|
|
543
562
|
return this.value;
|
|
@@ -551,7 +570,7 @@ var T = class extends S {
|
|
|
551
570
|
this.content = t, this.encodingWidth = n?.encodingWidth;
|
|
552
571
|
}
|
|
553
572
|
_encodeTo(e, t) {
|
|
554
|
-
|
|
573
|
+
b(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
555
574
|
}
|
|
556
575
|
_toCDN(e, t) {
|
|
557
576
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
@@ -560,7 +579,7 @@ var T = class extends S {
|
|
|
560
579
|
_toHexDump(e, t) {
|
|
561
580
|
let n = [{
|
|
562
581
|
depth: e,
|
|
563
|
-
hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(
|
|
582
|
+
hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(x(6, this.tag, this.encodingWidth)),
|
|
564
583
|
comment: `Tag ${this.tag}`
|
|
565
584
|
}];
|
|
566
585
|
return n.push(...this.content._toHexDump(e + 1, t)), n;
|
|
@@ -572,7 +591,7 @@ var T = class extends S {
|
|
|
572
591
|
};
|
|
573
592
|
//#endregion
|
|
574
593
|
//#region src/cdn/tokenizer.ts
|
|
575
|
-
function
|
|
594
|
+
function Ve(e, t) {
|
|
576
595
|
let n = 1, r = 1;
|
|
577
596
|
for (let i = 0; i < t; i++) e[i] === "\n" ? (n++, r = 1) : r++;
|
|
578
597
|
return {
|
|
@@ -583,7 +602,7 @@ function Fe(e, t) {
|
|
|
583
602
|
function D(e) {
|
|
584
603
|
return e >= 48 && e <= 57 || e >= 97 && e <= 102 || e >= 65 && e <= 70;
|
|
585
604
|
}
|
|
586
|
-
var
|
|
605
|
+
var He = new TextEncoder(), Ue = class {
|
|
587
606
|
input;
|
|
588
607
|
pos;
|
|
589
608
|
line;
|
|
@@ -596,7 +615,7 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
596
615
|
this.input = e;
|
|
597
616
|
let n = t?.offset ?? 0;
|
|
598
617
|
if (!Number.isInteger(n) || n < 0 || n > e.length) throw RangeError(`EDN parse offset must be an integer between 0 and ${e.length}`);
|
|
599
|
-
let r =
|
|
618
|
+
let r = Ve(e, n);
|
|
600
619
|
this.pos = n, this.line = r.line, this.col = r.col, this._lastConsumedEndOffset = n;
|
|
601
620
|
}
|
|
602
621
|
peek() {
|
|
@@ -1210,7 +1229,7 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
1210
1229
|
line: e,
|
|
1211
1230
|
col: t
|
|
1212
1231
|
};
|
|
1213
|
-
let n = this._readStringContent("'"), r =
|
|
1232
|
+
let n = this._readStringContent("'"), r = He.encode(n);
|
|
1214
1233
|
return {
|
|
1215
1234
|
type: "SQSTR",
|
|
1216
1235
|
value: Array.from(r, (e) => e.toString(16).padStart(2, "0")).join(""),
|
|
@@ -1549,13 +1568,13 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
1549
1568
|
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
1550
1569
|
}
|
|
1551
1570
|
_encodeTo(e, t) {
|
|
1552
|
-
|
|
1571
|
+
b(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
|
|
1553
1572
|
}
|
|
1554
1573
|
_toCDN(e, t) {
|
|
1555
1574
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
1556
1575
|
if (e?.preserveByteString && this.ednSource !== void 0) return this.ednSource + n;
|
|
1557
1576
|
let r = e?.bstrEncoding ?? this.ednEncoding;
|
|
1558
|
-
return e?.appStrings === !1 && r !== "hex" && (r = "hex"),
|
|
1577
|
+
return e?.appStrings === !1 && r !== "hex" && (r = "hex"), _e(this.value, r, e?.sqstr) + n;
|
|
1559
1578
|
}
|
|
1560
1579
|
_toJS(e) {
|
|
1561
1580
|
return this.value;
|
|
@@ -1636,25 +1655,25 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
1636
1655
|
e.writeByte(255);
|
|
1637
1656
|
return;
|
|
1638
1657
|
}
|
|
1639
|
-
|
|
1658
|
+
b(e, 4, this.items.length, this.encodingWidth);
|
|
1640
1659
|
for (let n of this.items) n._encode(e, t);
|
|
1641
1660
|
}
|
|
1642
1661
|
_toCDN(e, t) {
|
|
1643
|
-
let n =
|
|
1662
|
+
let n = re(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ae(this) || this.items.some(ie));
|
|
1644
1663
|
n === null && a && (n = " ");
|
|
1645
|
-
let { inlineSep: o, multilineSep: s, trailSep: c } =
|
|
1664
|
+
let { inlineSep: o, multilineSep: s, trailSep: c } = le(e, n === null), l = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "";
|
|
1646
1665
|
if (n === null || this.items.length === 0 && !a) {
|
|
1647
1666
|
let n = this.items.map((n) => n._toCDN(e, t + 1)).join(o);
|
|
1648
1667
|
return this.indefiniteLength ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${l}${n}]`;
|
|
1649
1668
|
}
|
|
1650
|
-
let u =
|
|
1669
|
+
let u = h(n, t + 1), d = h(n, t), f = this.indefiniteLength ? "[_ " : `[${l}`, p = [];
|
|
1651
1670
|
for (let n = 0; n < this.items.length; n++) {
|
|
1652
1671
|
let a = this.items[n];
|
|
1653
|
-
r &&
|
|
1672
|
+
r && p.push(...oe(a, u, i));
|
|
1654
1673
|
let o = n < this.items.length - 1 ? s : c;
|
|
1655
|
-
|
|
1674
|
+
p.push(`${u}${a._toCDN(e, t + 1)}${o}${r ? se(a, i) : ""}`);
|
|
1656
1675
|
}
|
|
1657
|
-
return r &&
|
|
1676
|
+
return r && p.push(...ce(this, u, i)), `${f}\n${p.join("\n")}\n${d}]`;
|
|
1658
1677
|
}
|
|
1659
1678
|
_toHexDump(e, t) {
|
|
1660
1679
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
@@ -1673,7 +1692,7 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
1673
1692
|
}
|
|
1674
1693
|
let i = [{
|
|
1675
1694
|
depth: e,
|
|
1676
|
-
hex: r(
|
|
1695
|
+
hex: r(x(4, BigInt(this.items.length), this.encodingWidth)),
|
|
1677
1696
|
comment: `Array of length ${this.items.length}`
|
|
1678
1697
|
}];
|
|
1679
1698
|
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
@@ -1706,29 +1725,29 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
1706
1725
|
e.writeByte(255);
|
|
1707
1726
|
return;
|
|
1708
1727
|
}
|
|
1709
|
-
|
|
1728
|
+
b(e, 5, this.entries.length, this.encodingWidth);
|
|
1710
1729
|
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
1711
1730
|
}
|
|
1712
1731
|
_toCDN(e, t) {
|
|
1713
|
-
let n =
|
|
1732
|
+
let n = re(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ae(this) || this.entries.some(([e, t]) => ie(e) || ie(t)));
|
|
1714
1733
|
n === null && a && (n = " ");
|
|
1715
|
-
let { inlineSep: o, multilineSep: s, trailSep: c, colSep: l } =
|
|
1734
|
+
let { inlineSep: o, multilineSep: s, trailSep: c, colSep: l } = le(e, n === null), u = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "", d = this.indefiniteLength ? "{_ " : `{${u}`;
|
|
1716
1735
|
if (n === null || this.entries.length === 0 && !a) {
|
|
1717
1736
|
let n = this.entries.map(([n, r]) => `${n._toCDN(e, t + 1)}${l}${r._toCDN(e, t + 1)}`).join(o);
|
|
1718
1737
|
return this.indefiniteLength ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${u}${n}}`;
|
|
1719
1738
|
}
|
|
1720
|
-
let
|
|
1739
|
+
let f = h(n, t + 1), p = h(n, t), m = [];
|
|
1721
1740
|
for (let n = 0; n < this.entries.length; n++) {
|
|
1722
1741
|
let [a, o] = this.entries[n];
|
|
1723
|
-
r &&
|
|
1724
|
-
let u = n < this.entries.length - 1 ? s : c, d = r ?
|
|
1742
|
+
r && m.push(...oe(a, f, i));
|
|
1743
|
+
let u = n < this.entries.length - 1 ? s : c, d = r ? We([
|
|
1725
1744
|
...a.comments?.trailing ?? [],
|
|
1726
1745
|
...o.comments?.leading ?? [],
|
|
1727
1746
|
...o.comments?.trailing ?? []
|
|
1728
1747
|
], i) : "";
|
|
1729
|
-
|
|
1748
|
+
m.push(`${f}${a._toCDN(e, t + 1)}${l}${o._toCDN(e, t + 1)}${u}${d}`);
|
|
1730
1749
|
}
|
|
1731
|
-
return r &&
|
|
1750
|
+
return r && m.push(...ce(this, f, i)), `${d}\n${m.join("\n")}\n${p}}`;
|
|
1732
1751
|
}
|
|
1733
1752
|
_toHexDump(e, t) {
|
|
1734
1753
|
let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
|
|
@@ -1747,7 +1766,7 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
1747
1766
|
}
|
|
1748
1767
|
let i = [{
|
|
1749
1768
|
depth: e,
|
|
1750
|
-
hex: r(
|
|
1769
|
+
hex: r(x(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
1751
1770
|
comment: `Map of length ${this.entries.length}`
|
|
1752
1771
|
}];
|
|
1753
1772
|
for (let [n, r] of this.entries) i.push(...n._toHexDump(e + 1, t)), i.push(...r._toHexDump(e + 1, t));
|
|
@@ -1764,13 +1783,13 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
1764
1783
|
}
|
|
1765
1784
|
return n;
|
|
1766
1785
|
};
|
|
1767
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof
|
|
1786
|
+
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof z) ? (() => {
|
|
1768
1787
|
let n = e ? {
|
|
1769
1788
|
...e,
|
|
1770
1789
|
reviver: void 0
|
|
1771
1790
|
} : void 0, r = {};
|
|
1772
1791
|
for (let [e, t] of this.entries) {
|
|
1773
|
-
let i = e instanceof
|
|
1792
|
+
let i = e instanceof z ? e.value : e.toCDN(), a = t._toJS(n);
|
|
1774
1793
|
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
1775
1794
|
value: a,
|
|
1776
1795
|
writable: !0,
|
|
@@ -1782,10 +1801,10 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
1782
1801
|
let i = /* @__PURE__ */ new Map();
|
|
1783
1802
|
for (let e = 0; e < this.entries.length; e++) {
|
|
1784
1803
|
let [t] = this.entries[e];
|
|
1785
|
-
i.set(t instanceof
|
|
1804
|
+
i.set(t instanceof z ? t.value : t.toCDN(), e);
|
|
1786
1805
|
}
|
|
1787
1806
|
for (let n = 0; n < this.entries.length; n++) {
|
|
1788
|
-
let [a, o] = this.entries[n], s = a instanceof
|
|
1807
|
+
let [a, o] = this.entries[n], s = a instanceof z ? a.value : a.toCDN();
|
|
1789
1808
|
if (i.get(s) !== n) continue;
|
|
1790
1809
|
let c = o._toJS(e), u = t.call(r, s, c);
|
|
1791
1810
|
u === l || e?.undefinedOmits && u === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
@@ -1799,8 +1818,8 @@ var Ie = new TextEncoder(), Le = class {
|
|
|
1799
1818
|
})() : n();
|
|
1800
1819
|
}
|
|
1801
1820
|
};
|
|
1802
|
-
function
|
|
1803
|
-
return e.length === 0 ? "" : " " + e.map((e) =>
|
|
1821
|
+
function We(e, t) {
|
|
1822
|
+
return e.length === 0 ? "" : " " + e.map((e) => g(e, t).trimEnd()).join(" ");
|
|
1804
1823
|
}
|
|
1805
1824
|
//#endregion
|
|
1806
1825
|
//#region src/ast/CborSimple.ts
|
|
@@ -1845,25 +1864,25 @@ var N = class e extends S {
|
|
|
1845
1864
|
super(), this.items = e;
|
|
1846
1865
|
}
|
|
1847
1866
|
_content(e) {
|
|
1848
|
-
let t = new
|
|
1867
|
+
let t = new y();
|
|
1849
1868
|
for (let n of this.items) n._encode(t, e);
|
|
1850
1869
|
return t.finish();
|
|
1851
1870
|
}
|
|
1852
1871
|
_encodeTo(e, t) {
|
|
1853
1872
|
let n = this._content(t);
|
|
1854
|
-
|
|
1873
|
+
b(e, 2, n.length), e.writeBytes(n);
|
|
1855
1874
|
}
|
|
1856
1875
|
_toCDN(e, t) {
|
|
1857
1876
|
if (this.items.length === 0) return "<<>>";
|
|
1858
|
-
let n =
|
|
1877
|
+
let n = re(e), { inlineSep: r, multilineSep: i, trailSep: a } = le(e, n === null);
|
|
1859
1878
|
if (n === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(r)}>>`;
|
|
1860
|
-
let o =
|
|
1879
|
+
let o = h(n, t + 1), s = h(n, t), c = this.items.map((n) => `${o}${n._toCDN(e, t + 1)}`), l = c.length - 1;
|
|
1861
1880
|
return `<<\n${c.map((e, t) => t < l ? `${e}${i}` : `${e}${a}`).join("\n")}\n${s}>>`;
|
|
1862
1881
|
}
|
|
1863
1882
|
_toHexDump(e, t) {
|
|
1864
1883
|
let n = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "), r = this._content().length, i = [{
|
|
1865
1884
|
depth: e,
|
|
1866
|
-
hex: n(
|
|
1885
|
+
hex: n(x(2, BigInt(r))),
|
|
1867
1886
|
comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
|
|
1868
1887
|
}];
|
|
1869
1888
|
for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
|
|
@@ -1872,17 +1891,17 @@ var N = class e extends S {
|
|
|
1872
1891
|
_toJS(e) {
|
|
1873
1892
|
return this._content();
|
|
1874
1893
|
}
|
|
1875
|
-
},
|
|
1894
|
+
}, Ge = 999n, F = class extends E {
|
|
1876
1895
|
constructor(e, t) {
|
|
1877
|
-
let n = t.length === 1 && t[0] instanceof
|
|
1878
|
-
super(
|
|
1896
|
+
let n = t.length === 1 && t[0] instanceof z ? t[0] : new j(t);
|
|
1897
|
+
super(Ge, new j([new z(e), n]));
|
|
1879
1898
|
}
|
|
1880
1899
|
_toCDN(e, t) {
|
|
1881
1900
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
1882
1901
|
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
1883
|
-
return i instanceof
|
|
1902
|
+
return i instanceof z ? `${r}${Ce(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
1884
1903
|
}
|
|
1885
|
-
},
|
|
1904
|
+
}, Ke = class extends S {
|
|
1886
1905
|
inner;
|
|
1887
1906
|
ednSource;
|
|
1888
1907
|
constructor(e, t) {
|
|
@@ -1897,15 +1916,15 @@ var N = class e extends S {
|
|
|
1897
1916
|
_toJS(e) {
|
|
1898
1917
|
return this.inner._toJS(e);
|
|
1899
1918
|
}
|
|
1900
|
-
},
|
|
1919
|
+
}, qe = 888n, I = class extends E {
|
|
1901
1920
|
constructor(e) {
|
|
1902
|
-
e === void 0 ? super(
|
|
1921
|
+
e === void 0 ? super(qe, N.NULL) : super(qe, new j(e));
|
|
1903
1922
|
}
|
|
1904
1923
|
_toCDN(e, t) {
|
|
1905
1924
|
return this.content instanceof N ? "..." : this.content instanceof j ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
|
|
1906
1925
|
}
|
|
1907
|
-
},
|
|
1908
|
-
function
|
|
1926
|
+
}, Je = 2n, Ye = 3n, Xe = 18446744073709551615n, Ze = -18446744073709551616n;
|
|
1927
|
+
function Qe(e) {
|
|
1909
1928
|
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
1910
1929
|
if (e === 0n) return new Uint8Array();
|
|
1911
1930
|
let t = e.toString(16);
|
|
@@ -1914,7 +1933,7 @@ function Ke(e) {
|
|
|
1914
1933
|
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
1915
1934
|
return n;
|
|
1916
1935
|
}
|
|
1917
|
-
function
|
|
1936
|
+
function $e(e) {
|
|
1918
1937
|
let t = 0n;
|
|
1919
1938
|
for (let n of e) t = t << 8n | BigInt(n);
|
|
1920
1939
|
return t;
|
|
@@ -1922,8 +1941,8 @@ function qe(e) {
|
|
|
1922
1941
|
var L = class extends E {
|
|
1923
1942
|
bigValue;
|
|
1924
1943
|
constructor(e) {
|
|
1925
|
-
if (e <=
|
|
1926
|
-
super(
|
|
1944
|
+
if (e <= Xe) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1945
|
+
super(Je, new O(Qe(e))), this.bigValue = e;
|
|
1927
1946
|
}
|
|
1928
1947
|
_toCDN(e, t) {
|
|
1929
1948
|
return this.bigValue.toString();
|
|
@@ -1934,8 +1953,8 @@ var L = class extends E {
|
|
|
1934
1953
|
}, R = class extends E {
|
|
1935
1954
|
bigValue;
|
|
1936
1955
|
constructor(e) {
|
|
1937
|
-
if (e >=
|
|
1938
|
-
super(
|
|
1956
|
+
if (e >= Ze) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1957
|
+
super(Ye, new O(Qe(-1n - e))), this.bigValue = e;
|
|
1939
1958
|
}
|
|
1940
1959
|
_toCDN(e, t) {
|
|
1941
1960
|
return this.bigValue.toString();
|
|
@@ -1943,22 +1962,22 @@ var L = class extends E {
|
|
|
1943
1962
|
_toJS(e) {
|
|
1944
1963
|
return this.bigValue;
|
|
1945
1964
|
}
|
|
1946
|
-
},
|
|
1947
|
-
function
|
|
1948
|
-
let n = new
|
|
1949
|
-
return t?.preserveComments &&
|
|
1965
|
+
}, et = new TextEncoder(), tt = new TextDecoder("utf-8", { fatal: !0 }), nt = new TextDecoder("utf-8", { fatal: !1 });
|
|
1966
|
+
function rt(e, t) {
|
|
1967
|
+
let n = new Ue(e, { offset: t?.offset }), r = new ht(n, t ?? {}).parse();
|
|
1968
|
+
return t?.preserveComments && ct(r, n.comments, e), r;
|
|
1950
1969
|
}
|
|
1951
|
-
function
|
|
1970
|
+
function it(e) {
|
|
1952
1971
|
let t = e, n;
|
|
1953
1972
|
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1954
1973
|
numStr: t,
|
|
1955
1974
|
rawSuffix: n
|
|
1956
1975
|
};
|
|
1957
1976
|
}
|
|
1958
|
-
function
|
|
1977
|
+
function at(e) {
|
|
1959
1978
|
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1960
1979
|
}
|
|
1961
|
-
function
|
|
1980
|
+
function ot(e, t) {
|
|
1962
1981
|
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1963
1982
|
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1964
1983
|
if (t) t(n), e = e.slice(0, -2);
|
|
@@ -1982,21 +2001,14 @@ function et(e, t) {
|
|
|
1982
2001
|
};
|
|
1983
2002
|
let n = e, r;
|
|
1984
2003
|
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) ? {
|
|
1985
|
-
value:
|
|
2004
|
+
value: ze(n),
|
|
1986
2005
|
precision: r
|
|
1987
2006
|
} : {
|
|
1988
2007
|
value: parseFloat(n),
|
|
1989
2008
|
precision: r
|
|
1990
2009
|
};
|
|
1991
2010
|
}
|
|
1992
|
-
function
|
|
1993
|
-
if (typeof Uint8Array.fromHex == "function") return Uint8Array.fromHex(e);
|
|
1994
|
-
if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
|
|
1995
|
-
let t = new Uint8Array(e.length / 2);
|
|
1996
|
-
for (let n = 0; n < e.length; n += 2) t[n / 2] = parseInt(e.slice(n, n + 2), 16);
|
|
1997
|
-
return t;
|
|
1998
|
-
}
|
|
1999
|
-
function nt(e, t) {
|
|
2011
|
+
function st(e, t) {
|
|
2000
2012
|
let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
|
|
2001
2013
|
if (/[^A-Za-z0-9+/\-_]/.test(r)) {
|
|
2002
2014
|
let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
|
|
@@ -2033,24 +2045,24 @@ function nt(e, t) {
|
|
|
2033
2045
|
for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
|
|
2034
2046
|
return l;
|
|
2035
2047
|
}
|
|
2036
|
-
function
|
|
2048
|
+
function ct(e, t, n) {
|
|
2037
2049
|
if (t.length === 0) return;
|
|
2038
|
-
let r =
|
|
2050
|
+
let r = lt(e), i = dt(n);
|
|
2039
2051
|
for (let a of t) {
|
|
2040
2052
|
let t = { ...a }, o = [...r].filter((e) => e.end <= a.start).sort((e, t) => t.end - e.end || t.start - e.start)[0], s = o ? n.slice(o.end, a.start) : "";
|
|
2041
2053
|
if (o && i(o.end) === a.line && !s.includes(":")) {
|
|
2042
|
-
|
|
2054
|
+
ut(o.node, "trailing", t);
|
|
2043
2055
|
continue;
|
|
2044
2056
|
}
|
|
2045
2057
|
let c = [...r].filter((e) => e.start < a.start && a.end < e.end).sort((e, t) => t.start - e.start || e.end - t.end)[0], l = [...r].filter((e) => e.start >= a.end).sort((e, t) => e.start - t.start || t.end - e.end)[0];
|
|
2046
2058
|
if ((!c || l && l.end <= c.end) && l) {
|
|
2047
|
-
|
|
2059
|
+
ut(l.node, "leading", t);
|
|
2048
2060
|
continue;
|
|
2049
2061
|
}
|
|
2050
|
-
|
|
2062
|
+
ut(c?.node ?? e, "dangling", t);
|
|
2051
2063
|
}
|
|
2052
2064
|
}
|
|
2053
|
-
function
|
|
2065
|
+
function lt(e) {
|
|
2054
2066
|
let t = [], n = (e) => {
|
|
2055
2067
|
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
2056
2068
|
node: e,
|
|
@@ -2072,10 +2084,10 @@ function it(e) {
|
|
|
2072
2084
|
};
|
|
2073
2085
|
return n(e), t;
|
|
2074
2086
|
}
|
|
2075
|
-
function
|
|
2087
|
+
function ut(e, t, n) {
|
|
2076
2088
|
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
2077
2089
|
}
|
|
2078
|
-
function
|
|
2090
|
+
function dt(e) {
|
|
2079
2091
|
let t = [0];
|
|
2080
2092
|
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
2081
2093
|
return (n) => {
|
|
@@ -2089,15 +2101,15 @@ function ot(e) {
|
|
|
2089
2101
|
return a + 1;
|
|
2090
2102
|
};
|
|
2091
2103
|
}
|
|
2092
|
-
var
|
|
2093
|
-
["b32",
|
|
2094
|
-
["h32",
|
|
2095
|
-
["float",
|
|
2096
|
-
["same",
|
|
2097
|
-
["hash",
|
|
2098
|
-
["uuid",
|
|
2099
|
-
["UUID",
|
|
2100
|
-
]),
|
|
2104
|
+
var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, pt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, mt = new Map([
|
|
2105
|
+
["b32", ft("b32")],
|
|
2106
|
+
["h32", ft("h32")],
|
|
2107
|
+
["float", ft("float")],
|
|
2108
|
+
["same", ft("same")],
|
|
2109
|
+
["hash", pt("hash", "@cbortech/hash-extension")],
|
|
2110
|
+
["uuid", pt("uuid", "@cbortech/uuid-extension")],
|
|
2111
|
+
["UUID", pt("uuid", "@cbortech/uuid-extension")]
|
|
2112
|
+
]), ht = class {
|
|
2101
2113
|
t;
|
|
2102
2114
|
_options;
|
|
2103
2115
|
extByPrefix;
|
|
@@ -2161,7 +2173,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2161
2173
|
this.t.consume();
|
|
2162
2174
|
let t = this.extByPrefix.get(e.appPrefix);
|
|
2163
2175
|
if (!t?.parseAppString) {
|
|
2164
|
-
if (t || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new F(e.appPrefix, [new
|
|
2176
|
+
if (t || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new F(e.appPrefix, [new z(e.value)]);
|
|
2165
2177
|
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
2166
2178
|
}
|
|
2167
2179
|
{
|
|
@@ -2175,7 +2187,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2175
2187
|
}) : (n instanceof T && n.ednSource === void 0 && (n.ednSource = e.raw), n);
|
|
2176
2188
|
} catch (t) {
|
|
2177
2189
|
if (this._options.strict !== !1) throw t;
|
|
2178
|
-
return this._pendingWarnings.length === n && this._warn(t instanceof Error ? t.message : String(t), e), new F(e.appPrefix, [new
|
|
2190
|
+
return this._pendingWarnings.length === n && this._warn(t instanceof Error ? t.message : String(t), e), new F(e.appPrefix, [new z(e.value)]);
|
|
2179
2191
|
}
|
|
2180
2192
|
}
|
|
2181
2193
|
}
|
|
@@ -2195,7 +2207,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2195
2207
|
try {
|
|
2196
2208
|
let r = n.parseAppSequence(e.appPrefix, t, this._extOnError(e)), i = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
2197
2209
|
if (r instanceof T) r.ednSource === void 0 && (r.ednSource = i);
|
|
2198
|
-
else if (n.preserveAppSeqSource) return new
|
|
2210
|
+
else if (n.preserveAppSeqSource) return new Ke(r, i);
|
|
2199
2211
|
return r;
|
|
2200
2212
|
} catch (n) {
|
|
2201
2213
|
if (this._options.strict !== !1) throw n;
|
|
@@ -2214,7 +2226,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2214
2226
|
}
|
|
2215
2227
|
}
|
|
2216
2228
|
parseIntegerOrTag() {
|
|
2217
|
-
let e = this.t.consume(), { numStr: t, rawSuffix: n } =
|
|
2229
|
+
let e = this.t.consume(), { numStr: t, rawSuffix: n } = it(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = at(t);
|
|
2218
2230
|
if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new L(i);
|
|
2219
2231
|
if (i < -18446744073709551616n) return new R(i);
|
|
2220
2232
|
if (r !== void 0) {
|
|
@@ -2237,9 +2249,9 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2237
2249
|
return a;
|
|
2238
2250
|
}
|
|
2239
2251
|
parseFloat() {
|
|
2240
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } =
|
|
2252
|
+
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = ot(e.value, t);
|
|
2241
2253
|
if (r === "half" || r === "single") {
|
|
2242
|
-
let e = r === "half" ?
|
|
2254
|
+
let e = r === "half" ? Ae(ke(n)) : Math.fround(n);
|
|
2243
2255
|
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`);
|
|
2244
2256
|
}
|
|
2245
2257
|
return new T(n, r === void 0 ? void 0 : { precision: r });
|
|
@@ -2247,8 +2259,8 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2247
2259
|
parseString() {
|
|
2248
2260
|
let e = this.t.consume();
|
|
2249
2261
|
if (this.t.peek().type !== "PLUS") {
|
|
2250
|
-
let t = this.consumeEncodingIndicator(() => BigInt(
|
|
2251
|
-
return new
|
|
2262
|
+
let t = this.consumeEncodingIndicator(() => BigInt(et.encode(e.value).length));
|
|
2263
|
+
return new z(e.value, t === void 0 ? void 0 : { encodingWidth: t });
|
|
2252
2264
|
}
|
|
2253
2265
|
let t = !1, n = [{ text: e.value }];
|
|
2254
2266
|
for (; this.t.peek().type === "PLUS";) {
|
|
@@ -2257,12 +2269,12 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2257
2269
|
e.type === "ELLIPSIS" ? (this.t.consume(), n.push({ ellipsis: !0 }), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push({ text: e.value })) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({ text: this._decodeUtf8(this._decodeBytesToken(e), e) })) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2258
2270
|
}
|
|
2259
2271
|
if (!t) {
|
|
2260
|
-
let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(
|
|
2261
|
-
return new
|
|
2272
|
+
let e = n.map((e) => "text" in e ? e.text : "").join(""), t = this.consumeEncodingIndicator(() => BigInt(et.encode(e).length));
|
|
2273
|
+
return new z(e, t === void 0 ? void 0 : { encodingWidth: t });
|
|
2262
2274
|
}
|
|
2263
2275
|
let r = [], i = "";
|
|
2264
|
-
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new
|
|
2265
|
-
return i !== "" && r.push(new
|
|
2276
|
+
for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new z(i)), i = ""), r.push(new I())) : i += e.text;
|
|
2277
|
+
return i !== "" && r.push(new z(i)), new I(r);
|
|
2266
2278
|
}
|
|
2267
2279
|
_isBytesToken(e) {
|
|
2268
2280
|
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
@@ -2271,17 +2283,17 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2271
2283
|
let t = (t) => this._warnOrFail(t, e);
|
|
2272
2284
|
switch (e.type) {
|
|
2273
2285
|
case "BYTES_HEX":
|
|
2274
|
-
case "SQSTR": return
|
|
2275
|
-
case "BYTES_B64": return
|
|
2286
|
+
case "SQSTR": return ne(e.value);
|
|
2287
|
+
case "BYTES_B64": return st(e.value, t);
|
|
2276
2288
|
default: this._fail("expected byte string token", e);
|
|
2277
2289
|
}
|
|
2278
2290
|
}
|
|
2279
2291
|
_decodeUtf8(e, t) {
|
|
2280
|
-
if (this._options.allowInvalidUtf8) return
|
|
2292
|
+
if (this._options.allowInvalidUtf8) return nt.decode(e);
|
|
2281
2293
|
try {
|
|
2282
|
-
return
|
|
2294
|
+
return tt.decode(e);
|
|
2283
2295
|
} catch {
|
|
2284
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t),
|
|
2296
|
+
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), nt.decode(e);
|
|
2285
2297
|
}
|
|
2286
2298
|
}
|
|
2287
2299
|
_tokenTypeToCdnEncoding(e) {
|
|
@@ -2305,7 +2317,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2305
2317
|
this.t.consume();
|
|
2306
2318
|
let t = this._buildBytesElidedItems(e.value);
|
|
2307
2319
|
for (let e of t) e instanceof I ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof O && i.push({ bytes: e.value });
|
|
2308
|
-
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes:
|
|
2320
|
+
} else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes: et.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
2309
2321
|
}
|
|
2310
2322
|
if (!r) {
|
|
2311
2323
|
let e = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(() => BigInt(t.length));
|
|
@@ -2337,7 +2349,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2337
2349
|
}
|
|
2338
2350
|
_buildBytesElidedItems(e) {
|
|
2339
2351
|
let t = e.split("..."), n = [];
|
|
2340
|
-
for (let e = 0; e < t.length; e++) e > 0 && n.push(new I()), t[e].length > 0 && n.push(new O(
|
|
2352
|
+
for (let e = 0; e < t.length; e++) e > 0 && n.push(new I()), t[e].length > 0 && n.push(new O(ne(t[e])));
|
|
2341
2353
|
return n;
|
|
2342
2354
|
}
|
|
2343
2355
|
_mergeFirstBytesItem(e, t) {
|
|
@@ -2354,7 +2366,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2354
2366
|
this.t.consume(), this.expect("LPAREN");
|
|
2355
2367
|
let e = this.t.peek();
|
|
2356
2368
|
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
2357
|
-
let { numStr: t } =
|
|
2369
|
+
let { numStr: t } = it(e.value), n = Number(at(t));
|
|
2358
2370
|
return this.expect("RPAREN"), new N(n);
|
|
2359
2371
|
}
|
|
2360
2372
|
parseEmbeddedCBOR() {
|
|
@@ -2414,9 +2426,9 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2414
2426
|
}));
|
|
2415
2427
|
return t.length > 0 && (e.warnings = t), e;
|
|
2416
2428
|
}
|
|
2417
|
-
if (r instanceof
|
|
2429
|
+
if (r instanceof z) {
|
|
2418
2430
|
let e = new A(n.map((e, t) => {
|
|
2419
|
-
if (e instanceof
|
|
2431
|
+
if (e instanceof z) return e;
|
|
2420
2432
|
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
2421
2433
|
}));
|
|
2422
2434
|
return t.length > 0 && (e.warnings = t), e;
|
|
@@ -2434,7 +2446,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2434
2446
|
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
2435
2447
|
}
|
|
2436
2448
|
_validateEncodingFit(e, t, n) {
|
|
2437
|
-
let r =
|
|
2449
|
+
let r = Ne(t);
|
|
2438
2450
|
if (e <= r) return t;
|
|
2439
2451
|
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
2440
2452
|
this._warnOrFail(i, n);
|
|
@@ -2458,7 +2470,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2458
2470
|
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
2459
2471
|
}
|
|
2460
2472
|
_hintMissingExtension(e, t) {
|
|
2461
|
-
let n =
|
|
2473
|
+
let n = mt.get(e);
|
|
2462
2474
|
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
2463
2475
|
this._hintedPrefixes.add(e);
|
|
2464
2476
|
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
@@ -2481,7 +2493,7 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2481
2493
|
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
2482
2494
|
throw SyntaxError(`EDN parse error${n}: ${e}`);
|
|
2483
2495
|
}
|
|
2484
|
-
},
|
|
2496
|
+
}, gt = new TextEncoder(), _t = !1, z = class extends S {
|
|
2485
2497
|
indefiniteLength = !1;
|
|
2486
2498
|
value;
|
|
2487
2499
|
encodingWidth;
|
|
@@ -2489,42 +2501,42 @@ var z = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exten
|
|
|
2489
2501
|
super(), this.value = e, this.encodingWidth = t?.encodingWidth;
|
|
2490
2502
|
}
|
|
2491
2503
|
_encodeTo(e, t) {
|
|
2492
|
-
let n =
|
|
2493
|
-
|
|
2504
|
+
let n = gt.encode(this.value);
|
|
2505
|
+
b(e, 3, n.length, this.encodingWidth), e.writeBytes(n);
|
|
2494
2506
|
}
|
|
2495
2507
|
_toCDN(e, t) {
|
|
2496
2508
|
let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
|
|
2497
|
-
return
|
|
2509
|
+
return vt(this.value, n, e, t);
|
|
2498
2510
|
}
|
|
2499
2511
|
_toJS(e) {
|
|
2500
2512
|
return this.value;
|
|
2501
2513
|
}
|
|
2502
2514
|
};
|
|
2503
|
-
function
|
|
2504
|
-
let i =
|
|
2505
|
-
if (i.length === 0 || a === null) return
|
|
2515
|
+
function vt(e, t, n, r) {
|
|
2516
|
+
let i = yt(n?.textStringFormat ?? []), a = re(n);
|
|
2517
|
+
if (i.length === 0 || a === null) return we(e) + t;
|
|
2506
2518
|
let o = /* @__PURE__ */ new Map(), s = null;
|
|
2507
|
-
if (i.includes("cdn") && (s =
|
|
2519
|
+
if (i.includes("cdn") && (s = xt(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
|
|
2508
2520
|
if (i.includes("newline")) {
|
|
2509
|
-
let t = s === null ?
|
|
2521
|
+
let t = s === null ? bt(e, 0) : St(e);
|
|
2510
2522
|
for (let { point: e, contentDepth: n } of t) o.has(e) || o.set(e, n);
|
|
2511
2523
|
}
|
|
2512
|
-
let c =
|
|
2513
|
-
if (c.length <= 1) return
|
|
2524
|
+
let c = kt(e, o);
|
|
2525
|
+
if (c.length <= 1) return we(e) + t;
|
|
2514
2526
|
let l = c.map(({ text: e }, n) => {
|
|
2515
|
-
let r =
|
|
2527
|
+
let r = we(e);
|
|
2516
2528
|
return n === c.length - 1 ? r + t : r;
|
|
2517
2529
|
}), u = l[0];
|
|
2518
2530
|
for (let e = 1; e < l.length; e++) {
|
|
2519
|
-
let t =
|
|
2531
|
+
let t = h(a, r + 1 + c[e].contentDepth);
|
|
2520
2532
|
u += ` +\n${t}${l[e]}`;
|
|
2521
2533
|
}
|
|
2522
2534
|
return u;
|
|
2523
2535
|
}
|
|
2524
|
-
function
|
|
2525
|
-
return e.map((e) => e === "cboredn" ? (
|
|
2536
|
+
function yt(e) {
|
|
2537
|
+
return e.map((e) => e === "cboredn" ? (_t || (_t = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
2526
2538
|
}
|
|
2527
|
-
function
|
|
2539
|
+
function bt(e, t) {
|
|
2528
2540
|
let n = [];
|
|
2529
2541
|
for (let r = 0; r < e.length; r++) {
|
|
2530
2542
|
let i = e[r];
|
|
@@ -2541,35 +2553,35 @@ function mt(e, t) {
|
|
|
2541
2553
|
}
|
|
2542
2554
|
return n;
|
|
2543
2555
|
}
|
|
2544
|
-
function
|
|
2556
|
+
function xt(e) {
|
|
2545
2557
|
try {
|
|
2546
|
-
|
|
2558
|
+
rt(e);
|
|
2547
2559
|
} catch {
|
|
2548
2560
|
return null;
|
|
2549
2561
|
}
|
|
2550
|
-
let t = [], n = new
|
|
2562
|
+
let t = [], n = new Ue(e), r = 0, i = null, a = !1, o = 0;
|
|
2551
2563
|
for (;;) {
|
|
2552
2564
|
let s = n.consume();
|
|
2553
2565
|
if (s.type === "EOF") break;
|
|
2554
2566
|
let c = !1;
|
|
2555
|
-
if (a || (a = !0, s.offset > 0 &&
|
|
2567
|
+
if (a || (a = !0, s.offset > 0 && Dt(n.comments, 0, s.offset) && t.push({
|
|
2556
2568
|
point: s.offset,
|
|
2557
2569
|
contentDepth: r
|
|
2558
2570
|
})), i !== null) {
|
|
2559
|
-
if (i.kind === "opener" &&
|
|
2571
|
+
if (i.kind === "opener" && wt.has(s.type)) {
|
|
2560
2572
|
i.point = s.endOffset, o = s.endOffset;
|
|
2561
2573
|
continue;
|
|
2562
|
-
} else i.kind === "opener" &&
|
|
2574
|
+
} else i.kind === "opener" && Et.has(s.type) && Ot(e, i.point, s.offset) ? c = !0 : t.push({
|
|
2563
2575
|
point: s.offset,
|
|
2564
2576
|
contentDepth: i.contentDepth
|
|
2565
2577
|
});
|
|
2566
2578
|
i = null;
|
|
2567
2579
|
}
|
|
2568
|
-
|
|
2580
|
+
Tt.has(s.type) ? (r++, i = {
|
|
2569
2581
|
point: s.endOffset,
|
|
2570
2582
|
contentDepth: r,
|
|
2571
2583
|
kind: "opener"
|
|
2572
|
-
}) :
|
|
2584
|
+
}) : Et.has(s.type) ? (r = Math.max(0, r - 1), c || t.push({
|
|
2573
2585
|
point: s.offset,
|
|
2574
2586
|
contentDepth: r
|
|
2575
2587
|
})) : s.type === "COMMA" && (i = {
|
|
@@ -2584,23 +2596,23 @@ function ht(e) {
|
|
|
2584
2596
|
contentDepth: r
|
|
2585
2597
|
}), t;
|
|
2586
2598
|
}
|
|
2587
|
-
function
|
|
2588
|
-
let t = [], n = new
|
|
2599
|
+
function St(e) {
|
|
2600
|
+
let t = [], n = new Ue(e), r = 0;
|
|
2589
2601
|
for (;;) {
|
|
2590
2602
|
let i = n.consume();
|
|
2591
2603
|
if (i.type === "EOF") break;
|
|
2592
|
-
if (
|
|
2593
|
-
else if (
|
|
2604
|
+
if (Tt.has(i.type)) r++;
|
|
2605
|
+
else if (Et.has(i.type)) r = Math.max(0, r - 1);
|
|
2594
2606
|
else if (i.type !== "COMMA") {
|
|
2595
2607
|
if (i.type === "TSTR") {
|
|
2596
2608
|
let n = e.slice(i.offset, i.endOffset);
|
|
2597
|
-
for (let e of
|
|
2609
|
+
for (let e of Ct(n)) t.push({
|
|
2598
2610
|
point: i.offset + e,
|
|
2599
2611
|
contentDepth: r + 1
|
|
2600
2612
|
});
|
|
2601
2613
|
} else if (i.type === "RAWSTRING") {
|
|
2602
2614
|
let n = e.slice(i.offset, i.endOffset);
|
|
2603
|
-
for (let { point: e } of
|
|
2615
|
+
for (let { point: e } of bt(n, 0)) t.push({
|
|
2604
2616
|
point: i.offset + e,
|
|
2605
2617
|
contentDepth: r + 1
|
|
2606
2618
|
});
|
|
@@ -2609,7 +2621,7 @@ function gt(e) {
|
|
|
2609
2621
|
}
|
|
2610
2622
|
return t;
|
|
2611
2623
|
}
|
|
2612
|
-
function
|
|
2624
|
+
function Ct(e) {
|
|
2613
2625
|
let t = [], n = 1, r = e.length - 1;
|
|
2614
2626
|
for (; n < r;) {
|
|
2615
2627
|
let r = e[n];
|
|
@@ -2625,24 +2637,24 @@ function _t(e) {
|
|
|
2625
2637
|
}
|
|
2626
2638
|
return t;
|
|
2627
2639
|
}
|
|
2628
|
-
var
|
|
2640
|
+
var wt = new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Tt = new Set([
|
|
2629
2641
|
"LBRACKET",
|
|
2630
2642
|
"LBRACE",
|
|
2631
2643
|
"LPAREN",
|
|
2632
2644
|
"LT_LT"
|
|
2633
|
-
]),
|
|
2645
|
+
]), Et = new Set([
|
|
2634
2646
|
"RBRACKET",
|
|
2635
2647
|
"RBRACE",
|
|
2636
2648
|
"RPAREN",
|
|
2637
2649
|
"GT_GT"
|
|
2638
2650
|
]);
|
|
2639
|
-
function
|
|
2651
|
+
function Dt(e, t, n) {
|
|
2640
2652
|
return e.some((e) => e.start >= t && e.end <= n);
|
|
2641
2653
|
}
|
|
2642
|
-
function
|
|
2654
|
+
function Ot(e, t, n) {
|
|
2643
2655
|
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
2644
2656
|
}
|
|
2645
|
-
function
|
|
2657
|
+
function kt(e, t) {
|
|
2646
2658
|
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
2647
2659
|
if (n.length === 0) return [{
|
|
2648
2660
|
text: e,
|
|
@@ -2660,7 +2672,7 @@ function Ct(e, t) {
|
|
|
2660
2672
|
}
|
|
2661
2673
|
//#endregion
|
|
2662
2674
|
//#region src/extensions/dt.ts
|
|
2663
|
-
function
|
|
2675
|
+
function B(e) {
|
|
2664
2676
|
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
2665
2677
|
let t = Math.round(e * 1e3);
|
|
2666
2678
|
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
@@ -2668,17 +2680,17 @@ function V(e) {
|
|
|
2668
2680
|
for (; s.length < 3;) s += "0";
|
|
2669
2681
|
return `${i}.${s}Z`;
|
|
2670
2682
|
}
|
|
2671
|
-
var
|
|
2672
|
-
function
|
|
2683
|
+
var At = new TextDecoder("utf-8", { fatal: !0 });
|
|
2684
|
+
function jt(e) {
|
|
2673
2685
|
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
2674
2686
|
let t = e[0];
|
|
2675
|
-
if (t instanceof
|
|
2676
|
-
if (t instanceof O) return
|
|
2687
|
+
if (t instanceof z) return t.value;
|
|
2688
|
+
if (t instanceof O) return At.decode(t.value);
|
|
2677
2689
|
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
2678
2690
|
}
|
|
2679
|
-
var
|
|
2680
|
-
function
|
|
2681
|
-
if (!
|
|
2691
|
+
var Mt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
2692
|
+
function Nt(e, t) {
|
|
2693
|
+
if (!Mt.test(e)) {
|
|
2682
2694
|
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
2683
2695
|
if (t) t(n);
|
|
2684
2696
|
else throw SyntaxError(n);
|
|
@@ -2689,41 +2701,41 @@ function Dt(e, t) {
|
|
|
2689
2701
|
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
2690
2702
|
if (i === void 0) {
|
|
2691
2703
|
let e = a / 1e3;
|
|
2692
|
-
return e >= 0 ? new
|
|
2704
|
+
return e >= 0 ? new Ft(BigInt(e)) : new It(BigInt(e));
|
|
2693
2705
|
}
|
|
2694
|
-
return new
|
|
2706
|
+
return new Lt(a / 1e3 + i);
|
|
2695
2707
|
}
|
|
2696
|
-
var
|
|
2708
|
+
var Pt = 1n, Ft = class extends C {
|
|
2697
2709
|
constructor(e, t) {
|
|
2698
2710
|
super(e, t);
|
|
2699
2711
|
}
|
|
2700
2712
|
_toCDN(e, t) {
|
|
2701
|
-
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${
|
|
2713
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${B(Number(this.value))}'`;
|
|
2702
2714
|
}
|
|
2703
|
-
},
|
|
2715
|
+
}, It = class extends w {
|
|
2704
2716
|
constructor(e, t) {
|
|
2705
2717
|
super(e, t);
|
|
2706
2718
|
}
|
|
2707
2719
|
_toCDN(e, t) {
|
|
2708
|
-
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${
|
|
2720
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${B(Number(this.value))}'`;
|
|
2709
2721
|
}
|
|
2710
|
-
},
|
|
2722
|
+
}, Lt = class extends T {
|
|
2711
2723
|
constructor(e, t) {
|
|
2712
2724
|
super(e, t);
|
|
2713
2725
|
}
|
|
2714
2726
|
_toCDN(e, t) {
|
|
2715
|
-
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${
|
|
2727
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${B(this.value)}'`;
|
|
2716
2728
|
}
|
|
2717
|
-
},
|
|
2729
|
+
}, Rt = class extends E {
|
|
2718
2730
|
constructor(e, t) {
|
|
2719
|
-
super(
|
|
2731
|
+
super(Pt, Nt(e), t);
|
|
2720
2732
|
}
|
|
2721
2733
|
_toCDN(e, t) {
|
|
2722
2734
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2723
2735
|
let n = this.content;
|
|
2724
|
-
return `DT'${
|
|
2736
|
+
return `DT'${B(n instanceof T ? n.value : Number(n.value))}'`;
|
|
2725
2737
|
}
|
|
2726
|
-
},
|
|
2738
|
+
}, zt = class extends Rt {
|
|
2727
2739
|
constructor(e, t) {
|
|
2728
2740
|
super(e, t);
|
|
2729
2741
|
}
|
|
@@ -2732,20 +2744,20 @@ var Ot = 1n, kt = class extends C {
|
|
|
2732
2744
|
return new Date(n);
|
|
2733
2745
|
}
|
|
2734
2746
|
};
|
|
2735
|
-
function
|
|
2747
|
+
function Bt(e) {
|
|
2736
2748
|
let t = e?.jsDate ?? !1;
|
|
2737
2749
|
function n(e) {
|
|
2738
|
-
return t ? new
|
|
2750
|
+
return t ? new zt(e) : new Rt(e);
|
|
2739
2751
|
}
|
|
2740
2752
|
let r = {
|
|
2741
2753
|
appStringPrefixes: ["dt", "DT"],
|
|
2742
|
-
tagNumbers: [
|
|
2754
|
+
tagNumbers: [Pt],
|
|
2743
2755
|
parseAppString(e, t, r) {
|
|
2744
|
-
return e === "DT" ? n(t) :
|
|
2756
|
+
return e === "DT" ? n(t) : Nt(t, r);
|
|
2745
2757
|
},
|
|
2746
2758
|
parseAppSequence(e, t, r) {
|
|
2747
|
-
let i =
|
|
2748
|
-
return e === "DT" ? n(i) :
|
|
2759
|
+
let i = jt(t);
|
|
2760
|
+
return e === "DT" ? n(i) : Nt(i, r);
|
|
2749
2761
|
},
|
|
2750
2762
|
parseTag(e, t) {
|
|
2751
2763
|
if (e !== 1n) return;
|
|
@@ -2754,17 +2766,17 @@ function Pt(e) {
|
|
|
2754
2766
|
else if (t instanceof w) r = Number(t.value);
|
|
2755
2767
|
else if (t instanceof T) r = t.value;
|
|
2756
2768
|
else return;
|
|
2757
|
-
return n(
|
|
2769
|
+
return n(B(r));
|
|
2758
2770
|
}
|
|
2759
2771
|
};
|
|
2760
2772
|
return t && (r.fromJS = (e, t) => {
|
|
2761
|
-
if (e instanceof Date) return new
|
|
2773
|
+
if (e instanceof Date) return new zt(B(e.getTime() / 1e3));
|
|
2762
2774
|
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2763
2775
|
}
|
|
2764
|
-
var
|
|
2776
|
+
var Vt = Bt(), Ht = Bt({ jsDate: !0 });
|
|
2765
2777
|
//#endregion
|
|
2766
2778
|
//#region src/utils/ip.ts
|
|
2767
|
-
function
|
|
2779
|
+
function Ut(e) {
|
|
2768
2780
|
let t = e.split(".");
|
|
2769
2781
|
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2770
2782
|
let n = new Uint8Array(4);
|
|
@@ -2777,11 +2789,11 @@ function Lt(e) {
|
|
|
2777
2789
|
}
|
|
2778
2790
|
return n;
|
|
2779
2791
|
}
|
|
2780
|
-
function
|
|
2792
|
+
function Wt(e) {
|
|
2781
2793
|
let t = new Uint8Array(16);
|
|
2782
2794
|
if (e === "::") return t;
|
|
2783
2795
|
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
2784
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r =
|
|
2796
|
+
i && (n = i[1], n.endsWith(":") && (n += ":"), r = Ut(i[2]));
|
|
2785
2797
|
let a = n.split("::");
|
|
2786
2798
|
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2787
2799
|
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
@@ -2798,11 +2810,11 @@ function Rt(e) {
|
|
|
2798
2810
|
}
|
|
2799
2811
|
return r && t.set(r, 12), t;
|
|
2800
2812
|
}
|
|
2801
|
-
function
|
|
2813
|
+
function Gt(e) {
|
|
2802
2814
|
return Array.from(e).join(".");
|
|
2803
2815
|
}
|
|
2804
|
-
function
|
|
2805
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ?
|
|
2816
|
+
function Kt(e) {
|
|
2817
|
+
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Gt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
2806
2818
|
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2807
2819
|
let i = -1, a = 0, o = 0;
|
|
2808
2820
|
for (; o < n;) if (r[o] === 0) {
|
|
@@ -2816,29 +2828,29 @@ function Bt(e) {
|
|
|
2816
2828
|
}
|
|
2817
2829
|
//#endregion
|
|
2818
2830
|
//#region src/extensions/ip.ts
|
|
2819
|
-
var
|
|
2820
|
-
function
|
|
2831
|
+
var qt = "ip", V = "IP", H = 52n, Jt = 54n, Yt = new TextDecoder("utf-8", { fatal: !0 });
|
|
2832
|
+
function Xt(e) {
|
|
2821
2833
|
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2822
2834
|
let t = e[0];
|
|
2823
|
-
if (t instanceof
|
|
2824
|
-
if (t instanceof O) return
|
|
2835
|
+
if (t instanceof z) return t.value;
|
|
2836
|
+
if (t instanceof O) return Yt.decode(t.value);
|
|
2825
2837
|
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2826
2838
|
}
|
|
2827
|
-
function
|
|
2839
|
+
function Zt(e) {
|
|
2828
2840
|
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2829
|
-
bytes:
|
|
2841
|
+
bytes: Ut(e),
|
|
2830
2842
|
isV4: !0
|
|
2831
2843
|
} : {
|
|
2832
|
-
bytes:
|
|
2844
|
+
bytes: Wt(e),
|
|
2833
2845
|
isV4: !1
|
|
2834
2846
|
};
|
|
2835
2847
|
}
|
|
2836
|
-
function
|
|
2837
|
-
if (e.length === 4) return
|
|
2838
|
-
if (e.length === 16) return
|
|
2848
|
+
function Qt(e) {
|
|
2849
|
+
if (e.length === 4) return Gt(e);
|
|
2850
|
+
if (e.length === 16) return Kt(e);
|
|
2839
2851
|
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2840
2852
|
}
|
|
2841
|
-
function
|
|
2853
|
+
function $t(e, t) {
|
|
2842
2854
|
let n = new Uint8Array(e.length);
|
|
2843
2855
|
n.set(e);
|
|
2844
2856
|
let r = Math.floor(t / 8), i = t % 8;
|
|
@@ -2848,15 +2860,15 @@ function qt(e, t) {
|
|
|
2848
2860
|
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2849
2861
|
return n.slice(0, a);
|
|
2850
2862
|
}
|
|
2851
|
-
function
|
|
2863
|
+
function en(e, t) {
|
|
2852
2864
|
let n = new Uint8Array(t);
|
|
2853
2865
|
return n.set(e), n;
|
|
2854
2866
|
}
|
|
2855
|
-
var
|
|
2867
|
+
var tn = class extends O {
|
|
2856
2868
|
_toCDN(e, t) {
|
|
2857
|
-
return e?.appStrings === !1 ? super._toCDN(e, t) : `${
|
|
2869
|
+
return e?.appStrings === !1 ? super._toCDN(e, t) : `${qt}'${Qt(this.value)}'`;
|
|
2858
2870
|
}
|
|
2859
|
-
},
|
|
2871
|
+
}, nn = class extends j {
|
|
2860
2872
|
_isV4;
|
|
2861
2873
|
constructor(e, t, n) {
|
|
2862
2874
|
super([new C(BigInt(e)), new O(t)]), this._isV4 = n;
|
|
@@ -2864,63 +2876,63 @@ var Yt = class extends O {
|
|
|
2864
2876
|
_toCDN(e, t) {
|
|
2865
2877
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2866
2878
|
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2867
|
-
return `${
|
|
2879
|
+
return `${qt}'${Qt(en(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2868
2880
|
}
|
|
2869
|
-
},
|
|
2881
|
+
}, rn = class extends E {
|
|
2870
2882
|
constructor(e, t) {
|
|
2871
2883
|
super(e, t);
|
|
2872
2884
|
}
|
|
2873
2885
|
_toCDN(e, t) {
|
|
2874
2886
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
2875
|
-
let n = this.tag ===
|
|
2876
|
-
if (r instanceof O) return `${
|
|
2887
|
+
let n = this.tag === H ? 4 : 16, r = this.content;
|
|
2888
|
+
if (r instanceof O) return `${V}'${Qt(r.value)}'`;
|
|
2877
2889
|
if (r instanceof j && r.items.length === 2 && r.items[0] instanceof C && r.items[1] instanceof O) {
|
|
2878
2890
|
let e = Number(r.items[0].value);
|
|
2879
|
-
return `${
|
|
2891
|
+
return `${V}'${Qt(en(r.items[1].value, n))}/${e}'`;
|
|
2880
2892
|
}
|
|
2881
2893
|
return super._toCDN(e, t);
|
|
2882
2894
|
}
|
|
2883
2895
|
};
|
|
2884
|
-
function
|
|
2896
|
+
function an(e, t) {
|
|
2885
2897
|
let n = t.indexOf("/");
|
|
2886
2898
|
if (n === -1) {
|
|
2887
|
-
let { bytes: n, isV4: r } =
|
|
2888
|
-
return e ===
|
|
2899
|
+
let { bytes: n, isV4: r } = Zt(t);
|
|
2900
|
+
return e === V ? new rn(r ? H : Jt, new O(n)) : new tn(n);
|
|
2889
2901
|
}
|
|
2890
2902
|
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2891
2903
|
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2892
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } =
|
|
2904
|
+
let a = parseInt(i, 10), { bytes: o, isV4: s } = Zt(r), c = s ? 32 : 128;
|
|
2893
2905
|
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2894
|
-
let l =
|
|
2895
|
-
return e ===
|
|
2906
|
+
let l = $t(o, a);
|
|
2907
|
+
return e === V ? new rn(s ? H : Jt, new j([new C(BigInt(a)), new O(l)])) : new nn(a, l, s);
|
|
2896
2908
|
}
|
|
2897
|
-
var
|
|
2898
|
-
appStringPrefixes: [
|
|
2899
|
-
tagNumbers: [
|
|
2909
|
+
var on = {
|
|
2910
|
+
appStringPrefixes: [qt, V],
|
|
2911
|
+
tagNumbers: [H, Jt],
|
|
2900
2912
|
parseAppString(e, t) {
|
|
2901
|
-
return
|
|
2913
|
+
return an(e, t);
|
|
2902
2914
|
},
|
|
2903
2915
|
parseAppSequence(e, t) {
|
|
2904
|
-
return
|
|
2916
|
+
return an(e, Xt(t));
|
|
2905
2917
|
},
|
|
2906
2918
|
parseTag(e, t) {
|
|
2907
|
-
if (!(e !==
|
|
2919
|
+
if (!(e !== H && e !== Jt) && (t instanceof O || t instanceof j)) return new rn(e, t);
|
|
2908
2920
|
}
|
|
2909
|
-
},
|
|
2910
|
-
tagNumbers: [
|
|
2921
|
+
}, sn = 18446744073709551615n, cn = -18446744073709551616n, ln = {
|
|
2922
|
+
tagNumbers: [Je, Ye],
|
|
2911
2923
|
parseTag(e, t) {
|
|
2912
2924
|
if (t instanceof O) {
|
|
2913
2925
|
if (e === 2n) {
|
|
2914
|
-
let e =
|
|
2915
|
-
return e >
|
|
2926
|
+
let e = $e(t.value);
|
|
2927
|
+
return e > sn ? new L(e) : void 0;
|
|
2916
2928
|
}
|
|
2917
2929
|
if (e === 3n) {
|
|
2918
|
-
let e = -1n -
|
|
2919
|
-
return e <
|
|
2930
|
+
let e = -1n - $e(t.value);
|
|
2931
|
+
return e < cn ? new R(e) : void 0;
|
|
2920
2932
|
}
|
|
2921
2933
|
}
|
|
2922
2934
|
}
|
|
2923
|
-
},
|
|
2935
|
+
}, un = "cri", dn = "CRI", fn = 99n, pn = new Map([
|
|
2924
2936
|
["coap", -1n],
|
|
2925
2937
|
["coaps", -2n],
|
|
2926
2938
|
["http", -3n],
|
|
@@ -2931,47 +2943,47 @@ var $t = {
|
|
|
2931
2943
|
["coaps+tcp", -8n],
|
|
2932
2944
|
["coap+ws", -25n],
|
|
2933
2945
|
["coaps+ws", -26n]
|
|
2934
|
-
]),
|
|
2935
|
-
function
|
|
2946
|
+
]), mn = new Map([...pn.entries()].map(([e, t]) => [t, e]));
|
|
2947
|
+
function U(e) {
|
|
2936
2948
|
try {
|
|
2937
2949
|
return decodeURIComponent(e);
|
|
2938
2950
|
} catch {
|
|
2939
2951
|
return e;
|
|
2940
2952
|
}
|
|
2941
2953
|
}
|
|
2942
|
-
var
|
|
2943
|
-
function
|
|
2944
|
-
return Array.from(
|
|
2954
|
+
var hn = new TextEncoder(), gn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2955
|
+
function _n(e) {
|
|
2956
|
+
return Array.from(hn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2945
2957
|
}
|
|
2946
|
-
function
|
|
2958
|
+
function W(e, t) {
|
|
2947
2959
|
let n = "";
|
|
2948
|
-
for (let r of e) n += t(r) ? r :
|
|
2960
|
+
for (let r of e) n += t(r) ? r : _n(r);
|
|
2949
2961
|
return n;
|
|
2950
2962
|
}
|
|
2951
|
-
function
|
|
2963
|
+
function vn(e) {
|
|
2952
2964
|
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2953
2965
|
}
|
|
2954
|
-
function
|
|
2966
|
+
function yn(e) {
|
|
2955
2967
|
return /[!$&'()*+,;=]/.test(e);
|
|
2956
2968
|
}
|
|
2957
|
-
function
|
|
2958
|
-
return
|
|
2969
|
+
function bn(e) {
|
|
2970
|
+
return vn(e) || yn(e) || e === ":" || e === "@";
|
|
2959
2971
|
}
|
|
2960
|
-
function
|
|
2961
|
-
return (
|
|
2972
|
+
function xn(e) {
|
|
2973
|
+
return (bn(e) || e === "/" || e === "?") && e !== "&";
|
|
2962
2974
|
}
|
|
2963
|
-
function
|
|
2964
|
-
return
|
|
2975
|
+
function Sn(e) {
|
|
2976
|
+
return bn(e) || e === "/" || e === "?";
|
|
2965
2977
|
}
|
|
2966
|
-
function
|
|
2967
|
-
return
|
|
2978
|
+
function Cn(e) {
|
|
2979
|
+
return vn(e) || yn(e) || e === ":";
|
|
2968
2980
|
}
|
|
2969
|
-
function
|
|
2970
|
-
return
|
|
2981
|
+
function wn(e) {
|
|
2982
|
+
return vn(e) || yn(e);
|
|
2971
2983
|
}
|
|
2972
|
-
function
|
|
2984
|
+
function Tn(e) {
|
|
2973
2985
|
let t = [], n = e, r = n.indexOf("@");
|
|
2974
|
-
r >= 0 && (t.push(N.FALSE), t.push(new
|
|
2986
|
+
r >= 0 && (t.push(N.FALSE), t.push(new z(U(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2975
2987
|
let i, a = null;
|
|
2976
2988
|
if (n.startsWith("[")) {
|
|
2977
2989
|
let e = n.indexOf("]");
|
|
@@ -2980,11 +2992,11 @@ function yn(e) {
|
|
|
2980
2992
|
let r = n.slice(e + 1);
|
|
2981
2993
|
if (r.startsWith(":")) a = r.slice(1);
|
|
2982
2994
|
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2983
|
-
t.push(new O(
|
|
2995
|
+
t.push(new O(Wt(i)));
|
|
2984
2996
|
} else {
|
|
2985
2997
|
let e = n.lastIndexOf(":");
|
|
2986
|
-
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new O(
|
|
2987
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new
|
|
2998
|
+
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new O(Ut(i)));
|
|
2999
|
+
else for (let e of i.toLowerCase().split(".")) t.push(new z(e));
|
|
2988
3000
|
}
|
|
2989
3001
|
if (a !== null && a !== "") {
|
|
2990
3002
|
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
@@ -2994,112 +3006,112 @@ function yn(e) {
|
|
|
2994
3006
|
}
|
|
2995
3007
|
return new j(t);
|
|
2996
3008
|
}
|
|
2997
|
-
function
|
|
3009
|
+
function En(e) {
|
|
2998
3010
|
let t = e.items, n = 0, r = "";
|
|
2999
3011
|
if (n < t.length && t[n] instanceof N && t[n].value === 20) {
|
|
3000
3012
|
n++;
|
|
3001
3013
|
let e = t[n++];
|
|
3002
|
-
r +=
|
|
3014
|
+
r += W(e.value, Cn) + "@";
|
|
3003
3015
|
}
|
|
3004
3016
|
if (n >= t.length) return r;
|
|
3005
3017
|
let i = t[n];
|
|
3006
3018
|
if (i instanceof O) {
|
|
3007
3019
|
n++;
|
|
3008
3020
|
let { length: e } = i.value;
|
|
3009
|
-
if (e === 4) r +=
|
|
3010
|
-
else if (e === 16) r += "[" +
|
|
3021
|
+
if (e === 4) r += Gt(i.value);
|
|
3022
|
+
else if (e === 16) r += "[" + Kt(i.value) + "]";
|
|
3011
3023
|
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
3012
|
-
n < t.length && t[n] instanceof
|
|
3024
|
+
n < t.length && t[n] instanceof z && (r += `%25${W(t[n++].value, wn)}`);
|
|
3013
3025
|
} else {
|
|
3014
3026
|
let e = [];
|
|
3015
|
-
for (; n < t.length && t[n] instanceof
|
|
3027
|
+
for (; n < t.length && t[n] instanceof z;) e.push(W(t[n++].value, wn));
|
|
3016
3028
|
r += e.join(".");
|
|
3017
3029
|
}
|
|
3018
3030
|
return n < t.length && t[n] instanceof C && (r += ":" + t[n].value.toString()), r;
|
|
3019
3031
|
}
|
|
3020
|
-
function
|
|
3032
|
+
function Dn(e) {
|
|
3021
3033
|
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
3022
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new
|
|
3023
|
-
authority:
|
|
3034
|
+
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new z(U(e)))) : (r = t, i = []), {
|
|
3035
|
+
authority: Tn(r),
|
|
3024
3036
|
pathSegments: i
|
|
3025
3037
|
};
|
|
3026
3038
|
}
|
|
3027
|
-
function
|
|
3039
|
+
function On(e) {
|
|
3028
3040
|
let t = e, n = null, r = t.indexOf("#");
|
|
3029
|
-
r >= 0 && (n =
|
|
3041
|
+
r >= 0 && (n = U(t.slice(r + 1)), t = t.slice(0, r));
|
|
3030
3042
|
let i = null, a = t.indexOf("?");
|
|
3031
3043
|
if (a >= 0) {
|
|
3032
3044
|
let e = t.slice(a + 1);
|
|
3033
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new
|
|
3045
|
+
t = t.slice(0, a), i = e.split("&").map((e) => new z(U(e)));
|
|
3034
3046
|
}
|
|
3035
3047
|
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
3036
3048
|
if (s) {
|
|
3037
|
-
let e = s[1].toLowerCase(), t = s[2], n =
|
|
3038
|
-
if (o.push(n === void 0 ? new
|
|
3039
|
-
let { authority: e, pathSegments: n } =
|
|
3049
|
+
let e = s[1].toLowerCase(), t = s[2], n = pn.get(e);
|
|
3050
|
+
if (o.push(n === void 0 ? new z(e) : new w(n)), t.startsWith("//")) {
|
|
3051
|
+
let { authority: e, pathSegments: n } = Dn(t);
|
|
3040
3052
|
o.push(e, new j(n));
|
|
3041
3053
|
} else if (t.startsWith("/")) {
|
|
3042
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
3054
|
+
let e = t.slice(1).split("/").map((e) => new z(U(e)));
|
|
3043
3055
|
o.push(N.NULL, new j(e));
|
|
3044
3056
|
} else {
|
|
3045
|
-
let e = t.split("/").map((e) => new
|
|
3057
|
+
let e = t.split("/").map((e) => new z(U(e)));
|
|
3046
3058
|
o.push(N.TRUE, new j(e));
|
|
3047
3059
|
}
|
|
3048
3060
|
} else if (t.startsWith("//")) {
|
|
3049
|
-
let { authority: e, pathSegments: n } =
|
|
3061
|
+
let { authority: e, pathSegments: n } = Dn(t);
|
|
3050
3062
|
o.push(N.FALSE, e, new j(n));
|
|
3051
3063
|
} else if (t.startsWith("/")) {
|
|
3052
|
-
let e = t.slice(1).split("/").map((e) => new
|
|
3064
|
+
let e = t.slice(1).split("/").map((e) => new z(U(e)));
|
|
3053
3065
|
o.push(N.TRUE, new j(e));
|
|
3054
3066
|
} else if (t === "") o.push(new C(0n));
|
|
3055
3067
|
else {
|
|
3056
3068
|
let n = 1n, r = t, i = !1;
|
|
3057
3069
|
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
3058
3070
|
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)}`);
|
|
3059
|
-
let a = r === "" ? [] : r.split("/").map((e) => new
|
|
3071
|
+
let a = r === "" ? [] : r.split("/").map((e) => new z(U(e)));
|
|
3060
3072
|
o.push(new C(n), new j(a));
|
|
3061
3073
|
}
|
|
3062
|
-
if (i !== null && o.push(new j(i)), n !== null && (i === null && o.push(N.NULL), o.push(new
|
|
3074
|
+
if (i !== null && o.push(new j(i)), n !== null && (i === null && o.push(N.NULL), o.push(new z(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
3063
3075
|
let e = o[o.length - 1];
|
|
3064
3076
|
e instanceof j && e.items.length === 0 && o.pop();
|
|
3065
3077
|
}
|
|
3066
3078
|
return o.length === 1 && o[0] instanceof C && o[0].value === 0n ? [] : o;
|
|
3067
3079
|
}
|
|
3068
|
-
function
|
|
3080
|
+
function G(e, t) {
|
|
3069
3081
|
let n = t, r = "";
|
|
3070
3082
|
if (n < e.length) {
|
|
3071
3083
|
let t = e[n];
|
|
3072
3084
|
if (t instanceof j) {
|
|
3073
3085
|
if (n++, t.items.length > 0) {
|
|
3074
3086
|
let e = t.items.map((e) => {
|
|
3075
|
-
if (!(e instanceof
|
|
3076
|
-
return
|
|
3087
|
+
if (!(e instanceof z)) throw Error("cri: query item must be a text string");
|
|
3088
|
+
return W(e.value, xn);
|
|
3077
3089
|
});
|
|
3078
3090
|
r += "?" + e.join("&");
|
|
3079
3091
|
}
|
|
3080
3092
|
} else t instanceof N && t.value === 22 && n++;
|
|
3081
3093
|
}
|
|
3082
|
-
return n < e.length && e[n] instanceof
|
|
3094
|
+
return n < e.length && e[n] instanceof z && (r += "#" + W(e[n].value, Sn)), r;
|
|
3083
3095
|
}
|
|
3084
|
-
function
|
|
3096
|
+
function K(e) {
|
|
3085
3097
|
return e.items.map((e) => {
|
|
3086
|
-
if (!(e instanceof
|
|
3087
|
-
return
|
|
3098
|
+
if (!(e instanceof z)) throw Error("cri: path segment must be a text string");
|
|
3099
|
+
return W(e.value, bn);
|
|
3088
3100
|
});
|
|
3089
3101
|
}
|
|
3090
|
-
function
|
|
3102
|
+
function kn(e) {
|
|
3091
3103
|
if (e.length === 0) return "";
|
|
3092
3104
|
let t = 0, n = e[t++];
|
|
3093
|
-
if (n instanceof w || n instanceof
|
|
3105
|
+
if (n instanceof w || n instanceof z) {
|
|
3094
3106
|
let r;
|
|
3095
3107
|
if (n instanceof w) {
|
|
3096
|
-
let e =
|
|
3108
|
+
let e = mn.get(n.value);
|
|
3097
3109
|
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
3098
3110
|
r = e + ":";
|
|
3099
3111
|
} else r = n.value + ":";
|
|
3100
3112
|
if (t >= e.length) return r;
|
|
3101
3113
|
let i = e[t++], a = "", o = !1;
|
|
3102
|
-
if (i instanceof j) a = "//" +
|
|
3114
|
+
if (i instanceof j) a = "//" + En(i), o = !0;
|
|
3103
3115
|
else if (i instanceof N) if (i.value === 22) o = !0;
|
|
3104
3116
|
else if (i.value === 21) o = !1;
|
|
3105
3117
|
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
@@ -3107,101 +3119,101 @@ function wn(e) {
|
|
|
3107
3119
|
let s = "";
|
|
3108
3120
|
if (t < e.length && e[t] instanceof j) {
|
|
3109
3121
|
let n = e[t++];
|
|
3110
|
-
n.items.length > 0 && (s = (o ? "/" : "") +
|
|
3122
|
+
n.items.length > 0 && (s = (o ? "/" : "") + K(n).join("/"));
|
|
3111
3123
|
}
|
|
3112
|
-
return r + a + s +
|
|
3124
|
+
return r + a + s + G(e, t);
|
|
3113
3125
|
}
|
|
3114
3126
|
if (n instanceof N && n.value === 20) {
|
|
3115
3127
|
if (t >= e.length || !(e[t] instanceof j)) throw Error("cri: network-path reference requires an authority array");
|
|
3116
|
-
let n =
|
|
3128
|
+
let n = En(e[t++]), r = "";
|
|
3117
3129
|
if (t < e.length && e[t] instanceof j) {
|
|
3118
3130
|
let n = e[t++];
|
|
3119
|
-
n.items.length > 0 && (r = "/" +
|
|
3131
|
+
n.items.length > 0 && (r = "/" + K(n).join("/"));
|
|
3120
3132
|
}
|
|
3121
|
-
return "//" + n + r +
|
|
3133
|
+
return "//" + n + r + G(e, t);
|
|
3122
3134
|
}
|
|
3123
3135
|
if (n instanceof N && n.value === 21) {
|
|
3124
3136
|
let n = "/";
|
|
3125
3137
|
if (t < e.length && e[t] instanceof j) {
|
|
3126
3138
|
let r = e[t++];
|
|
3127
|
-
n = "/" +
|
|
3139
|
+
n = "/" + K(r).join("/");
|
|
3128
3140
|
}
|
|
3129
|
-
return n +
|
|
3141
|
+
return n + G(e, t);
|
|
3130
3142
|
}
|
|
3131
3143
|
if (n instanceof C) {
|
|
3132
3144
|
let r = n.value;
|
|
3133
|
-
if (r === 0n) return
|
|
3145
|
+
if (r === 0n) return G(e, t);
|
|
3134
3146
|
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
3135
3147
|
if (t < e.length && e[t] instanceof j) {
|
|
3136
3148
|
let n = e[t++];
|
|
3137
3149
|
if (n.items.length > 0) {
|
|
3138
|
-
let e =
|
|
3150
|
+
let e = K(n);
|
|
3139
3151
|
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
3140
3152
|
} else a = i === "" ? "./" : i;
|
|
3141
3153
|
} else a = i === "" ? "./" : i;
|
|
3142
|
-
return a +
|
|
3154
|
+
return a + G(e, t);
|
|
3143
3155
|
}
|
|
3144
3156
|
throw Error("cri: unrecognised first element type in CRI array");
|
|
3145
3157
|
}
|
|
3146
|
-
var
|
|
3158
|
+
var An = class extends j {
|
|
3147
3159
|
_toCDN(e, t) {
|
|
3148
3160
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
3149
3161
|
try {
|
|
3150
|
-
return `${
|
|
3162
|
+
return `${un}'${kn(this.items)}'`;
|
|
3151
3163
|
} catch {
|
|
3152
3164
|
return super._toCDN(e, t);
|
|
3153
3165
|
}
|
|
3154
3166
|
}
|
|
3155
|
-
},
|
|
3167
|
+
}, jn = class extends E {
|
|
3156
3168
|
constructor(e) {
|
|
3157
|
-
super(
|
|
3169
|
+
super(fn, e);
|
|
3158
3170
|
}
|
|
3159
3171
|
_toCDN(e, t) {
|
|
3160
3172
|
if (e?.appStrings === !1) return super._toCDN(e, t);
|
|
3161
3173
|
try {
|
|
3162
|
-
return `${
|
|
3174
|
+
return `${dn}'${kn(this.content.items)}'`;
|
|
3163
3175
|
} catch {
|
|
3164
3176
|
return super._toCDN(e, t);
|
|
3165
3177
|
}
|
|
3166
3178
|
}
|
|
3167
3179
|
};
|
|
3168
|
-
function
|
|
3180
|
+
function Mn(e) {
|
|
3169
3181
|
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
3170
3182
|
let t = e[0];
|
|
3171
|
-
if (t instanceof
|
|
3172
|
-
if (t instanceof O) return
|
|
3183
|
+
if (t instanceof z) return t.value;
|
|
3184
|
+
if (t instanceof O) return gn.decode(t.value);
|
|
3173
3185
|
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
3174
3186
|
}
|
|
3175
|
-
function
|
|
3176
|
-
let n = new
|
|
3177
|
-
return e ===
|
|
3187
|
+
function Nn(e, t) {
|
|
3188
|
+
let n = new An(On(t));
|
|
3189
|
+
return e === dn ? new jn(n) : n;
|
|
3178
3190
|
}
|
|
3179
|
-
var
|
|
3180
|
-
appStringPrefixes: [
|
|
3181
|
-
tagNumbers: [
|
|
3191
|
+
var Pn = {
|
|
3192
|
+
appStringPrefixes: [un, dn],
|
|
3193
|
+
tagNumbers: [fn],
|
|
3182
3194
|
parseAppString(e, t) {
|
|
3183
|
-
return
|
|
3195
|
+
return Nn(e, t);
|
|
3184
3196
|
},
|
|
3185
3197
|
parseAppSequence(e, t) {
|
|
3186
|
-
return
|
|
3198
|
+
return Nn(e, Mn(t));
|
|
3187
3199
|
},
|
|
3188
3200
|
parseTag(e, t) {
|
|
3189
|
-
if (e === 99n && t instanceof j) return new
|
|
3201
|
+
if (e === 99n && t instanceof j) return new jn(new An(t.items, {
|
|
3190
3202
|
indefiniteLength: t.indefiniteLength,
|
|
3191
3203
|
encodingWidth: t.encodingWidth
|
|
3192
3204
|
}));
|
|
3193
3205
|
}
|
|
3194
|
-
},
|
|
3206
|
+
}, Fn = new TextDecoder("utf-8", {
|
|
3195
3207
|
fatal: !0,
|
|
3196
3208
|
ignoreBOM: !0
|
|
3197
|
-
}),
|
|
3209
|
+
}), In = new TextDecoder("utf-8", {
|
|
3198
3210
|
fatal: !1,
|
|
3199
3211
|
ignoreBOM: !0
|
|
3200
3212
|
});
|
|
3201
3213
|
function q(e) {
|
|
3202
3214
|
throw Error(`CBOR decode error: ${e}`);
|
|
3203
3215
|
}
|
|
3204
|
-
function
|
|
3216
|
+
function Ln(e, t, n) {
|
|
3205
3217
|
let r = {
|
|
3206
3218
|
message: e,
|
|
3207
3219
|
offset: t
|
|
@@ -3209,10 +3221,10 @@ function Mn(e, t, n) {
|
|
|
3209
3221
|
if (n?.onWarning ? n.onWarning(r) : n?.silent || console.warn(`CBOR strict violation at offset ${t}: ${e}`), n?.strict !== !1) throw Error(`CBOR decode error: ${e}`);
|
|
3210
3222
|
return r;
|
|
3211
3223
|
}
|
|
3212
|
-
function
|
|
3224
|
+
function Rn(e, t) {
|
|
3213
3225
|
e.warnings ??= [], e.warnings.push(t);
|
|
3214
3226
|
}
|
|
3215
|
-
function
|
|
3227
|
+
function zn(e) {
|
|
3216
3228
|
let t = "";
|
|
3217
3229
|
for (let n of e) t += n.toString(16).padStart(2, "0");
|
|
3218
3230
|
return t;
|
|
@@ -3220,12 +3232,12 @@ function Pn(e) {
|
|
|
3220
3232
|
function J(e) {
|
|
3221
3233
|
if (e instanceof C) return ["u", String(e.value)];
|
|
3222
3234
|
if (e instanceof w) return ["n", String(e.value)];
|
|
3223
|
-
if (e instanceof
|
|
3235
|
+
if (e instanceof z) return ["t", e.value];
|
|
3224
3236
|
if (e instanceof A) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
3225
|
-
if (e instanceof O) return ["b",
|
|
3237
|
+
if (e instanceof O) return ["b", zn(e.value)];
|
|
3226
3238
|
if (e instanceof k) {
|
|
3227
3239
|
let t = "";
|
|
3228
|
-
for (let n of e.chunks) t +=
|
|
3240
|
+
for (let n of e.chunks) t += zn(n.value);
|
|
3229
3241
|
return ["b", t];
|
|
3230
3242
|
}
|
|
3231
3243
|
if (e instanceof T) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
@@ -3246,19 +3258,19 @@ function J(e) {
|
|
|
3246
3258
|
for (let e of t) n += e.toString(16).padStart(2, "0");
|
|
3247
3259
|
return ["c", n];
|
|
3248
3260
|
}
|
|
3249
|
-
function
|
|
3261
|
+
function Bn(e) {
|
|
3250
3262
|
if (e instanceof C) return "u" + e.value;
|
|
3251
3263
|
if (e instanceof w) return "n" + e.value;
|
|
3252
|
-
if (e instanceof
|
|
3264
|
+
if (e instanceof z) return "t" + e.value;
|
|
3253
3265
|
if (e instanceof A) {
|
|
3254
3266
|
let t = "t";
|
|
3255
3267
|
for (let n of e.chunks) t += n.value;
|
|
3256
3268
|
return t;
|
|
3257
3269
|
}
|
|
3258
|
-
if (e instanceof O) return "b" +
|
|
3270
|
+
if (e instanceof O) return "b" + zn(e.value);
|
|
3259
3271
|
if (e instanceof k) {
|
|
3260
3272
|
let t = "b";
|
|
3261
|
-
for (let n of e.chunks) t +=
|
|
3273
|
+
for (let n of e.chunks) t += zn(n.value);
|
|
3262
3274
|
return t;
|
|
3263
3275
|
}
|
|
3264
3276
|
return e instanceof T ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof N ? "s" + e.value : JSON.stringify(J(e));
|
|
@@ -3288,7 +3300,7 @@ function Y(e, t, n) {
|
|
|
3288
3300
|
default: q(`reserved additional info value: ${n}`);
|
|
3289
3301
|
}
|
|
3290
3302
|
}
|
|
3291
|
-
function
|
|
3303
|
+
function Vn(e, t, n, r, i, a) {
|
|
3292
3304
|
let o = [], s = t;
|
|
3293
3305
|
for (;;) {
|
|
3294
3306
|
if (s >= e.byteLength && q(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
@@ -3303,15 +3315,15 @@ function In(e, t, n, r, i, a) {
|
|
|
3303
3315
|
nextOffset: s
|
|
3304
3316
|
};
|
|
3305
3317
|
}
|
|
3306
|
-
function
|
|
3307
|
-
let i =
|
|
3308
|
-
t.has(i) && n.push(
|
|
3318
|
+
function Hn(e, t, n, r) {
|
|
3319
|
+
let i = Bn(e);
|
|
3320
|
+
t.has(i) && n.push(Ln(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
3309
3321
|
}
|
|
3310
3322
|
function X(e, t, n, r) {
|
|
3311
|
-
let i = t, a =
|
|
3323
|
+
let i = t, a = Un(e, t, n, r);
|
|
3312
3324
|
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
3313
3325
|
}
|
|
3314
|
-
function
|
|
3326
|
+
function Un(e, t, n, r) {
|
|
3315
3327
|
t >= e.byteLength && q("unexpected end of input");
|
|
3316
3328
|
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
3317
3329
|
switch (a) {
|
|
@@ -3331,7 +3343,7 @@ function Rn(e, t, n, r) {
|
|
|
3331
3343
|
}
|
|
3332
3344
|
case 2: {
|
|
3333
3345
|
if (o === 31) {
|
|
3334
|
-
let { chunks: i, nextOffset: a } =
|
|
3346
|
+
let { chunks: i, nextOffset: a } = Vn(e, t, n, r, "byte string", (e) => e instanceof O);
|
|
3335
3347
|
return {
|
|
3336
3348
|
value: new k(i),
|
|
3337
3349
|
nextOffset: a
|
|
@@ -3345,7 +3357,7 @@ function Rn(e, t, n, r) {
|
|
|
3345
3357
|
}
|
|
3346
3358
|
case 3: {
|
|
3347
3359
|
if (o === 31) {
|
|
3348
|
-
let { chunks: i, nextOffset: a } =
|
|
3360
|
+
let { chunks: i, nextOffset: a } = Vn(e, t, n, r, "text string", (e) => e instanceof z);
|
|
3349
3361
|
return {
|
|
3350
3362
|
value: new A(i),
|
|
3351
3363
|
nextOffset: a
|
|
@@ -3355,12 +3367,12 @@ function Rn(e, t, n, r) {
|
|
|
3355
3367
|
a + s > e.byteLength && q("text string extends beyond input");
|
|
3356
3368
|
let c = new Uint8Array(e.buffer, e.byteOffset + a, s), l, u;
|
|
3357
3369
|
try {
|
|
3358
|
-
l =
|
|
3370
|
+
l = Fn.decode(c);
|
|
3359
3371
|
} catch {
|
|
3360
|
-
u =
|
|
3372
|
+
u = Ln("invalid UTF-8 sequence in text string", a, n), l = In.decode(c);
|
|
3361
3373
|
}
|
|
3362
|
-
let d = new
|
|
3363
|
-
return u &&
|
|
3374
|
+
let d = new z(l);
|
|
3375
|
+
return u && Rn(d, u), {
|
|
3364
3376
|
value: d,
|
|
3365
3377
|
nextOffset: a + s
|
|
3366
3378
|
};
|
|
@@ -3400,12 +3412,12 @@ function Rn(e, t, n, r) {
|
|
|
3400
3412
|
break;
|
|
3401
3413
|
}
|
|
3402
3414
|
let t = X(e, s, n, r);
|
|
3403
|
-
|
|
3415
|
+
Hn(t.value, a, o, n), s = t.nextOffset;
|
|
3404
3416
|
let c = X(e, s, n, r);
|
|
3405
3417
|
s = c.nextOffset, i.push([t.value, c.value]);
|
|
3406
3418
|
}
|
|
3407
3419
|
let c = new M(i, { indefiniteLength: !0 });
|
|
3408
|
-
for (let e of o)
|
|
3420
|
+
for (let e of o) Rn(c, e);
|
|
3409
3421
|
return {
|
|
3410
3422
|
value: c,
|
|
3411
3423
|
nextOffset: s
|
|
@@ -3414,12 +3426,12 @@ function Rn(e, t, n, r) {
|
|
|
3414
3426
|
let { value: i, nextOffset: a } = Y(e, t, o), s = Number(i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
|
|
3415
3427
|
for (let t = 0; t < s; t++) {
|
|
3416
3428
|
let t = X(e, d, n, r);
|
|
3417
|
-
|
|
3429
|
+
Hn(t.value, l, u, n), d = t.nextOffset;
|
|
3418
3430
|
let i = X(e, d, n, r);
|
|
3419
3431
|
d = i.nextOffset, c.push([t.value, i.value]);
|
|
3420
3432
|
}
|
|
3421
3433
|
let f = new M(c);
|
|
3422
|
-
for (let e of u)
|
|
3434
|
+
for (let e of u) Rn(f, e);
|
|
3423
3435
|
return {
|
|
3424
3436
|
value: f,
|
|
3425
3437
|
nextOffset: d
|
|
@@ -3465,8 +3477,8 @@ function Rn(e, t, n, r) {
|
|
|
3465
3477
|
t + 1 > e.byteLength && q("unexpected end of input");
|
|
3466
3478
|
let r = e.getUint8(t);
|
|
3467
3479
|
if (r < 32) {
|
|
3468
|
-
let e =
|
|
3469
|
-
return
|
|
3480
|
+
let e = Ln(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new N(r);
|
|
3481
|
+
return Rn(i, e), {
|
|
3470
3482
|
value: i,
|
|
3471
3483
|
nextOffset: t + 1
|
|
3472
3484
|
};
|
|
@@ -3477,7 +3489,7 @@ function Rn(e, t, n, r) {
|
|
|
3477
3489
|
};
|
|
3478
3490
|
}
|
|
3479
3491
|
return o === 25 ? (t + 2 > e.byteLength && q("unexpected end of input"), {
|
|
3480
|
-
value: new T(
|
|
3492
|
+
value: new T(Ae(e.getUint16(t, !1)), { precision: "half" }),
|
|
3481
3493
|
nextOffset: t + 2
|
|
3482
3494
|
}) : o === 26 ? (t + 4 > e.byteLength && q("unexpected end of input"), {
|
|
3483
3495
|
value: new T(e.getFloat32(t, !1), { precision: "single" }),
|
|
@@ -3489,26 +3501,26 @@ function Rn(e, t, n, r) {
|
|
|
3489
3501
|
}
|
|
3490
3502
|
return q(`unknown major type: ${a}`);
|
|
3491
3503
|
}
|
|
3492
|
-
function
|
|
3504
|
+
function Wn(e) {
|
|
3493
3505
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
3494
3506
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
3495
3507
|
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
3496
3508
|
}
|
|
3497
|
-
function
|
|
3498
|
-
let n =
|
|
3509
|
+
function Gn(e, t) {
|
|
3510
|
+
let n = Wn(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
3499
3511
|
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
3500
3512
|
let { value: a, nextOffset: o } = X(r, i, t, [...t?.extensions ?? [], ...Z].filter((e) => e.parseTag !== void 0));
|
|
3501
3513
|
return !t?.allowTrailing && o !== r.byteLength && q(`${r.byteLength - o} trailing byte(s) after end of CBOR item`), a;
|
|
3502
3514
|
}
|
|
3503
3515
|
//#endregion
|
|
3504
3516
|
//#region src/extensions/cbordata.ts
|
|
3505
|
-
var
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3517
|
+
var Kn = 24n, Z = [
|
|
3518
|
+
Vt,
|
|
3519
|
+
on,
|
|
3520
|
+
ln,
|
|
3521
|
+
Pn,
|
|
3510
3522
|
{
|
|
3511
|
-
tagNumbers: [
|
|
3523
|
+
tagNumbers: [Kn],
|
|
3512
3524
|
parseTag(e, t, n) {
|
|
3513
3525
|
if (e !== 24n || !(t instanceof O)) return;
|
|
3514
3526
|
let r = n ? {
|
|
@@ -3518,7 +3530,7 @@ var Vn = 24n, Z = [
|
|
|
3518
3530
|
silent: n.silent
|
|
3519
3531
|
} : void 0;
|
|
3520
3532
|
try {
|
|
3521
|
-
return new E(
|
|
3533
|
+
return new E(Kn, new P([Gn(t.value, r)]));
|
|
3522
3534
|
} catch (e) {
|
|
3523
3535
|
if (r?.strict !== !1) throw e;
|
|
3524
3536
|
return;
|
|
@@ -3530,18 +3542,18 @@ var Vn = 24n, Z = [
|
|
|
3530
3542
|
//#region src/js/fromJS.ts
|
|
3531
3543
|
function Q(e, t) {
|
|
3532
3544
|
if (t?.replacer) {
|
|
3533
|
-
let { replacer: n, ...r } = t, i =
|
|
3545
|
+
let { replacer: n, ...r } = t, i = Yn(e, n, r.extensions, r.undefinedOmits);
|
|
3534
3546
|
return i === l ? N.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
|
|
3535
3547
|
}
|
|
3536
|
-
return
|
|
3548
|
+
return qn(e, t, !0);
|
|
3537
3549
|
}
|
|
3538
|
-
function
|
|
3550
|
+
function qn(e, t, n) {
|
|
3539
3551
|
for (let n of [...t?.extensions ?? [], ...Z]) if (n.fromJS) {
|
|
3540
3552
|
let r = n.fromJS(e, t ?? {});
|
|
3541
3553
|
if (r !== void 0) return r;
|
|
3542
3554
|
}
|
|
3543
3555
|
if (n && typeof e == "object" && e && c.symbol in e) {
|
|
3544
|
-
let n = e[c.symbol], r =
|
|
3556
|
+
let n = e[c.symbol], r = qn(e, t, !1);
|
|
3545
3557
|
for (let e of [...t?.extensions ?? [], ...Z]) if (e.parseTag) {
|
|
3546
3558
|
let t = e.parseTag(n, r);
|
|
3547
3559
|
if (t !== void 0) return t;
|
|
@@ -3557,23 +3569,23 @@ function Hn(e, t, n) {
|
|
|
3557
3569
|
if (e === !1) return N.FALSE;
|
|
3558
3570
|
if (typeof e == "bigint") return e > 18446744073709551615n ? new L(e) : e < -18446744073709551616n ? new R(e) : e >= 0n ? new C(e) : new w(e);
|
|
3559
3571
|
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new C(BigInt(e)) : new w(BigInt(e)) : new T(e);
|
|
3560
|
-
if (typeof e == "string") return new
|
|
3561
|
-
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return
|
|
3572
|
+
if (typeof e == "string") return new z(e);
|
|
3573
|
+
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return qn(e.valueOf(), t, !1);
|
|
3562
3574
|
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new O(new Uint8Array(e));
|
|
3563
3575
|
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new j(Array.from(e, (e) => new C(BigInt(e)))) : new O(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
3564
3576
|
if (e instanceof $) return new M([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
|
|
3565
3577
|
if (Array.isArray(e)) return new j(e.map((e) => Q(e, t)));
|
|
3566
3578
|
if (typeof e == "object") {
|
|
3567
3579
|
let n = [];
|
|
3568
|
-
for (let [r, i] of Object.entries(e)) n.push([new
|
|
3580
|
+
for (let [r, i] of Object.entries(e)) n.push([new z(r), Q(i, t)]);
|
|
3569
3581
|
return new M(n);
|
|
3570
3582
|
}
|
|
3571
3583
|
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
3572
3584
|
}
|
|
3573
|
-
function
|
|
3585
|
+
function Jn(e) {
|
|
3574
3586
|
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]" || e instanceof c.Null || e instanceof c.Undefined || e instanceof u;
|
|
3575
3587
|
}
|
|
3576
|
-
function
|
|
3588
|
+
function Yn(e, t, n, r) {
|
|
3577
3589
|
let i = [...n ?? [], ...Z];
|
|
3578
3590
|
function a(e) {
|
|
3579
3591
|
return e === l || r === !0 && e === void 0;
|
|
@@ -3584,7 +3596,7 @@ function Wn(e, t, n, r) {
|
|
|
3584
3596
|
if (typeof e != "object" || !e) return e;
|
|
3585
3597
|
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
3586
3598
|
if (Array.isArray(e)) return e.map(r);
|
|
3587
|
-
if (c.symbol in e ||
|
|
3599
|
+
if (c.symbol in e || Jn(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
3588
3600
|
let t = Object.getPrototypeOf(e);
|
|
3589
3601
|
if (t === Object.prototype || t === null) {
|
|
3590
3602
|
let t = e.toJSON;
|
|
@@ -3619,7 +3631,7 @@ function Wn(e, t, n, r) {
|
|
|
3619
3631
|
let r = s(t, String(n), e);
|
|
3620
3632
|
return a(r) ? null : r;
|
|
3621
3633
|
});
|
|
3622
|
-
if (
|
|
3634
|
+
if (Jn(e) || i.some((t) => t.isJSType?.(e))) return e;
|
|
3623
3635
|
let t = {};
|
|
3624
3636
|
for (let n of Object.keys(e)) {
|
|
3625
3637
|
let r = s(e[n], n, e);
|
|
@@ -3649,6 +3661,6 @@ var $ = class extends Array {
|
|
|
3649
3661
|
}
|
|
3650
3662
|
};
|
|
3651
3663
|
//#endregion
|
|
3652
|
-
export {
|
|
3664
|
+
export { ne as C, t as D, e as E, c as O, Ae as S, l as T, E as _, Ht as a, C as b, R as c, N as d, M as f, O as g, k as h, Gn as i, n as k, L as l, A as m, Yn as n, z as o, j as p, Q as r, rt as s, $ as t, P as u, T as v, u as w, S as x, w as y };
|
|
3653
3665
|
|
|
3654
|
-
//# sourceMappingURL=mapEntries-
|
|
3666
|
+
//# sourceMappingURL=mapEntries-C8HTvn5t.js.map
|