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