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