@cbortech/cbor 0.26.0 → 0.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +42 -0
- package/README.md +42 -0
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +2 -2
- package/dist/extensions/builtins.d.ts +24 -1
- package/dist/extensions/ellipsis.d.ts +3 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +149 -149
- package/dist/index.js.map +1 -1
- package/dist/js/fromJS.d.ts +1 -1
- package/dist/mapEntries-CZLpI8fS.cjs +14 -0
- package/dist/mapEntries-CZLpI8fS.cjs.map +1 -0
- package/dist/{mapEntries-BdzS6bFp.js → mapEntries-KwZz9nq2.js} +627 -570
- package/dist/mapEntries-KwZz9nq2.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/package.json +7 -7
- package/dist/mapEntries-BdzS6bFp.js.map +0 -1
- package/dist/mapEntries-DJtvWpWq.cjs +0 -14
- package/dist/mapEntries-DJtvWpWq.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { o as e } from "./tokenizer-CeuixxXi.js";
|
|
2
|
-
import {
|
|
2
|
+
import { E as t, F as n, I as r, L as i, M as a, N as o, P as s, _ as c, a as l, c as u, d, f, h as p, i as m, l as h, m as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "./mapEntries-KwZz9nq2.js";
|
|
3
3
|
//#region src/extensions/b32.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var w = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", T = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
5
|
+
function E(e) {
|
|
6
6
|
let t = e.length;
|
|
7
7
|
for (; t > 0 && e.charCodeAt(t - 1) === 61;) t--;
|
|
8
8
|
return e.slice(0, t);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
let r =
|
|
10
|
+
function D(e, t, n) {
|
|
11
|
+
let r = E(e).toUpperCase(), i = r.length % 8;
|
|
12
12
|
if (i === 1 || i === 3 || i === 6) throw SyntaxError(`invalid base32 length: ${r.length} characters`);
|
|
13
13
|
let a = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
|
|
14
14
|
for (let e = 0; e < t.length; e++) a[t.charCodeAt(e)] = e;
|
|
@@ -25,44 +25,44 @@ function C(e, t, n) {
|
|
|
25
25
|
}
|
|
26
26
|
return o;
|
|
27
27
|
}
|
|
28
|
-
var
|
|
28
|
+
var O = {
|
|
29
29
|
appStringPrefixes: ["b32"],
|
|
30
|
-
parseAppString(e,
|
|
31
|
-
return new
|
|
30
|
+
parseAppString(e, n, r) {
|
|
31
|
+
return new t(D(v(n), w, r), { ednEncoding: "base32" });
|
|
32
32
|
}
|
|
33
|
-
},
|
|
33
|
+
}, k = {
|
|
34
34
|
appStringPrefixes: ["h32"],
|
|
35
|
-
parseAppString(e,
|
|
36
|
-
return new
|
|
35
|
+
parseAppString(e, n, r) {
|
|
36
|
+
return new t(D(v(n), T, r), { ednEncoding: "base32hex" });
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/extensions/same.ts
|
|
41
|
-
function
|
|
41
|
+
function A(e, t) {
|
|
42
42
|
if (e.length !== t.length) return !1;
|
|
43
43
|
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
44
44
|
return !0;
|
|
45
45
|
}
|
|
46
|
-
var
|
|
46
|
+
var j = {
|
|
47
47
|
appStringPrefixes: ["same"],
|
|
48
48
|
preserveAppSeqSource: !0,
|
|
49
49
|
parseAppSequence(e, t, n) {
|
|
50
50
|
if (t.length === 0) throw SyntaxError("same<<...>> requires at least one item");
|
|
51
51
|
let r = t[0], i = r.toCBOR();
|
|
52
|
-
for (let e = 1; e < t.length; e++) if (!
|
|
52
|
+
for (let e = 1; e < t.length; e++) if (!A(i, t[e].toCBOR())) {
|
|
53
53
|
let t = `same<<...>>: item ${e} produces different CBOR bytes than item 0`;
|
|
54
54
|
if (n) n(t);
|
|
55
55
|
else throw SyntaxError(t);
|
|
56
56
|
}
|
|
57
57
|
return r;
|
|
58
58
|
}
|
|
59
|
-
},
|
|
60
|
-
static OMIT =
|
|
61
|
-
static TAG =
|
|
62
|
-
static Tag =
|
|
63
|
-
static Simple =
|
|
64
|
-
static MapEntries =
|
|
65
|
-
static dt_as_Date =
|
|
59
|
+
}, M = class t {
|
|
60
|
+
static OMIT = o;
|
|
61
|
+
static TAG = s;
|
|
62
|
+
static Tag = r;
|
|
63
|
+
static Simple = a;
|
|
64
|
+
static MapEntries = S;
|
|
65
|
+
static dt_as_Date = p;
|
|
66
66
|
#e;
|
|
67
67
|
constructor(e) {
|
|
68
68
|
this.#e = e ?? {};
|
|
@@ -73,110 +73,110 @@ var D = {
|
|
|
73
73
|
...e ?? {}
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
fromCBOR(e,
|
|
77
|
-
let
|
|
78
|
-
return
|
|
76
|
+
fromCBOR(e, n) {
|
|
77
|
+
let r = t.fromCBOR(e, this.#t(n));
|
|
78
|
+
return r._defaults = this.#e, r;
|
|
79
79
|
}
|
|
80
|
-
fromCDN(e,
|
|
81
|
-
let
|
|
82
|
-
return
|
|
80
|
+
fromCDN(e, n) {
|
|
81
|
+
let r = t.fromCDN(e, this.#t(n));
|
|
82
|
+
return r._defaults = this.#e, r;
|
|
83
83
|
}
|
|
84
84
|
fromEDN(e, t) {
|
|
85
85
|
return this.fromCDN(e, t);
|
|
86
86
|
}
|
|
87
|
-
fromJS(e,
|
|
88
|
-
let
|
|
89
|
-
return
|
|
87
|
+
fromJS(e, n) {
|
|
88
|
+
let r = t.fromJS(e, this.#t(n));
|
|
89
|
+
return r._defaults = this.#e, r;
|
|
90
90
|
}
|
|
91
|
-
fromHexDump(e,
|
|
92
|
-
let
|
|
93
|
-
return
|
|
91
|
+
fromHexDump(e, n) {
|
|
92
|
+
let r = t.fromHexDump(e, this.#t(n));
|
|
93
|
+
return r._defaults = this.#e, r;
|
|
94
94
|
}
|
|
95
|
-
*fromCBORSeq(e,
|
|
96
|
-
for (let
|
|
95
|
+
*fromCBORSeq(e, n) {
|
|
96
|
+
for (let r of t.fromCBORSeq(e, this.#t(n))) r._defaults = this.#e, yield r;
|
|
97
97
|
}
|
|
98
|
-
*fromCDNSeq(e,
|
|
99
|
-
for (let
|
|
98
|
+
*fromCDNSeq(e, n) {
|
|
99
|
+
for (let r of t.fromCDNSeq(e, this.#t(n))) r._defaults = this.#e, yield r;
|
|
100
100
|
}
|
|
101
|
-
*fromHexDumpSeq(e,
|
|
102
|
-
for (let
|
|
101
|
+
*fromHexDumpSeq(e, n) {
|
|
102
|
+
for (let r of t.fromHexDumpSeq(e, this.#t(n))) r._defaults = this.#e, yield r;
|
|
103
103
|
}
|
|
104
|
-
decode(e,
|
|
105
|
-
return
|
|
104
|
+
decode(e, n) {
|
|
105
|
+
return t.decode(e, this.#t(n));
|
|
106
106
|
}
|
|
107
|
-
*decodeSeq(e,
|
|
108
|
-
yield*
|
|
107
|
+
*decodeSeq(e, n) {
|
|
108
|
+
yield* t.decodeSeq(e, this.#t(n));
|
|
109
109
|
}
|
|
110
|
-
*parseSeq(e,
|
|
111
|
-
yield*
|
|
110
|
+
*parseSeq(e, n) {
|
|
111
|
+
yield* t.parseSeq(e, this.#t(n));
|
|
112
112
|
}
|
|
113
|
-
encode(e,
|
|
114
|
-
return
|
|
113
|
+
encode(e, n) {
|
|
114
|
+
return t.encode(e, this.#t(n));
|
|
115
115
|
}
|
|
116
|
-
compile(e,
|
|
117
|
-
return
|
|
116
|
+
compile(e, n) {
|
|
117
|
+
return t.compile(e, this.#t(n));
|
|
118
118
|
}
|
|
119
|
-
decompile(e,
|
|
120
|
-
return
|
|
119
|
+
decompile(e, n) {
|
|
120
|
+
return t.decompile(e, this.#t(n));
|
|
121
121
|
}
|
|
122
|
-
toHex(e,
|
|
123
|
-
return
|
|
122
|
+
toHex(e, n) {
|
|
123
|
+
return t.toHex(e, this.#t(n));
|
|
124
124
|
}
|
|
125
|
-
fromHex(e,
|
|
126
|
-
return
|
|
125
|
+
fromHex(e, n) {
|
|
126
|
+
return t.fromHex(e, this.#t(n));
|
|
127
127
|
}
|
|
128
128
|
cborToCborEdn(e, t) {
|
|
129
129
|
return this.cborToCdn(e, t);
|
|
130
130
|
}
|
|
131
|
-
cborToCdn(e,
|
|
132
|
-
let
|
|
133
|
-
return i._defaults = this.#e, i.toCDN(
|
|
131
|
+
cborToCdn(e, n) {
|
|
132
|
+
let r = this.#t(n), i = t.fromCBOR(e, r);
|
|
133
|
+
return i._defaults = this.#e, i.toCDN(r);
|
|
134
134
|
}
|
|
135
135
|
cborEdnToCbor(e, t) {
|
|
136
136
|
return this.cdnToCbor(e, t);
|
|
137
137
|
}
|
|
138
|
-
cdnToCbor(e,
|
|
139
|
-
let
|
|
140
|
-
return
|
|
138
|
+
cdnToCbor(e, n) {
|
|
139
|
+
let r = this.#t(n);
|
|
140
|
+
return t.fromCDN(e, r).toCBOR(r);
|
|
141
141
|
}
|
|
142
|
-
parse(e,
|
|
143
|
-
if (typeof
|
|
144
|
-
let
|
|
145
|
-
return
|
|
142
|
+
parse(e, n) {
|
|
143
|
+
if (typeof n == "function") {
|
|
144
|
+
let r = this.#t({ reviver: n });
|
|
145
|
+
return t.fromCDN(e, r).toJS(r);
|
|
146
146
|
}
|
|
147
|
-
let
|
|
148
|
-
return
|
|
147
|
+
let r = this.#t(n);
|
|
148
|
+
return t.fromCDN(e, r).toJS(r);
|
|
149
149
|
}
|
|
150
|
-
stringify(e,
|
|
151
|
-
if (typeof
|
|
150
|
+
stringify(e, n, r) {
|
|
151
|
+
if (typeof n == "function" || Array.isArray(n) || n === null || n === void 0 && r !== void 0) {
|
|
152
152
|
let i = { ...this.#e };
|
|
153
|
-
return
|
|
153
|
+
return n === null ? i.replacer = void 0 : (typeof n == "function" || Array.isArray(n)) && (i.replacer = n), r !== void 0 && (i.indent = z(r)), t.stringify(e, i);
|
|
154
154
|
}
|
|
155
|
-
return
|
|
155
|
+
return t.stringify(e, this.#t(n ?? void 0));
|
|
156
156
|
}
|
|
157
|
-
format(e,
|
|
158
|
-
return
|
|
157
|
+
format(e, n) {
|
|
158
|
+
return t.format(e, this.#t(n));
|
|
159
159
|
}
|
|
160
160
|
static fromCBOR(e, t) {
|
|
161
|
-
return
|
|
161
|
+
return d(e, t);
|
|
162
162
|
}
|
|
163
163
|
static fromCDN(e, t) {
|
|
164
|
-
return
|
|
164
|
+
return c(e, t);
|
|
165
165
|
}
|
|
166
|
-
static fromEDN(e,
|
|
167
|
-
return
|
|
166
|
+
static fromEDN(e, n) {
|
|
167
|
+
return t.fromCDN(e, n);
|
|
168
168
|
}
|
|
169
|
-
static *fromHexDumpSeq(e,
|
|
170
|
-
let
|
|
171
|
-
for (let e of i) if (/^[0-9A-Fa-f]{2}$/.test(e))
|
|
172
|
-
else if (/^[0-9A-Fa-f]+$/.test(e) && e.length % 2 == 0) for (let t = 0; t < e.length; t += 2)
|
|
169
|
+
static *fromHexDumpSeq(e, n) {
|
|
170
|
+
let r = [], i = N(e).trim().split(/\s+/).filter(Boolean);
|
|
171
|
+
for (let e of i) if (/^[0-9A-Fa-f]{2}$/.test(e)) r.push(parseInt(e, 16));
|
|
172
|
+
else if (/^[0-9A-Fa-f]+$/.test(e) && e.length % 2 == 0) for (let t = 0; t < e.length; t += 2) r.push(parseInt(e.slice(t, t + 2), 16));
|
|
173
173
|
else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
|
|
174
|
-
yield*
|
|
174
|
+
yield* t.fromCBORSeq(new Uint8Array(r), n);
|
|
175
175
|
}
|
|
176
176
|
static *fromCBORSeq(e, t) {
|
|
177
177
|
let n = e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength), r = 0;
|
|
178
178
|
for (; r < n.byteLength;) {
|
|
179
|
-
let e =
|
|
179
|
+
let e = d(n, {
|
|
180
180
|
...t,
|
|
181
181
|
offset: r,
|
|
182
182
|
allowTrailing: !0
|
|
@@ -187,22 +187,22 @@ var D = {
|
|
|
187
187
|
static *fromCDNSeq(t, n) {
|
|
188
188
|
let r = !!n?.preserveComments, i = 0, a = !0;
|
|
189
189
|
for (;;) {
|
|
190
|
-
let { offset: o, hadSeparator: s, commaOffset:
|
|
191
|
-
if (a &&
|
|
190
|
+
let { offset: o, hadSeparator: s, commaOffset: l } = R(t, i, n, r ? a ? "all" : "after-newline" : "none");
|
|
191
|
+
if (a && l >= 0) {
|
|
192
192
|
let e = "leading comma in CDN sequence";
|
|
193
193
|
if (n?.strict !== !1) throw SyntaxError(e);
|
|
194
|
-
|
|
194
|
+
I(e, l, n);
|
|
195
195
|
}
|
|
196
|
-
if (o >= t.length || r &&
|
|
196
|
+
if (o >= t.length || r && L(t, o) && R(t, o, n).offset >= t.length) break;
|
|
197
197
|
if (!a && !s) {
|
|
198
198
|
let e = "CDN sequence items must be separated by whitespace, comma, or comment";
|
|
199
199
|
if (n?.strict !== !1) throw SyntaxError(e);
|
|
200
|
-
|
|
200
|
+
I(e, o, n);
|
|
201
201
|
}
|
|
202
202
|
i = o;
|
|
203
|
-
let
|
|
203
|
+
let u;
|
|
204
204
|
try {
|
|
205
|
-
|
|
205
|
+
u = c(t, {
|
|
206
206
|
...n,
|
|
207
207
|
offset: i,
|
|
208
208
|
allowTrailing: !0,
|
|
@@ -210,142 +210,142 @@ var D = {
|
|
|
210
210
|
});
|
|
211
211
|
} catch (t) {
|
|
212
212
|
if (n?.strict !== !1) throw t;
|
|
213
|
-
|
|
213
|
+
I(t instanceof Error ? t.message : String(t), i, n, !0, t instanceof e ? t : void 0);
|
|
214
214
|
break;
|
|
215
215
|
}
|
|
216
|
-
yield
|
|
216
|
+
yield u, i = u.end, a = !1;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
static fromJS(e, t) {
|
|
220
|
-
return
|
|
220
|
+
return b(e, t);
|
|
221
221
|
}
|
|
222
222
|
static fromHexDump(e, t) {
|
|
223
|
-
let n = [], r =
|
|
223
|
+
let n = [], r = N(e).trim().split(/\s+/).filter(Boolean);
|
|
224
224
|
for (let e of r) if (/^[0-9A-Fa-f]{2}$/.test(e)) n.push(parseInt(e, 16));
|
|
225
225
|
else if (/^[0-9A-Fa-f]+$/.test(e) && e.length % 2 == 0) for (let t = 0; t < e.length; t += 2) n.push(parseInt(e.slice(t, t + 2), 16));
|
|
226
226
|
else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
|
|
227
|
-
return
|
|
227
|
+
return d(new Uint8Array(n), t);
|
|
228
228
|
}
|
|
229
|
-
static decode(e,
|
|
230
|
-
return
|
|
229
|
+
static decode(e, n) {
|
|
230
|
+
return t.fromCBOR(e, n).toJS(n);
|
|
231
231
|
}
|
|
232
|
-
static *decodeSeq(e,
|
|
233
|
-
for (let
|
|
232
|
+
static *decodeSeq(e, n) {
|
|
233
|
+
for (let r of t.fromCBORSeq(e, n)) yield r.toJS(n);
|
|
234
234
|
}
|
|
235
|
-
static *parseSeq(e,
|
|
236
|
-
for (let
|
|
235
|
+
static *parseSeq(e, n) {
|
|
236
|
+
for (let r of t.fromCDNSeq(e, n)) yield r.toJS(n);
|
|
237
237
|
}
|
|
238
|
-
static encode(e,
|
|
239
|
-
return
|
|
238
|
+
static encode(e, n) {
|
|
239
|
+
return t.fromJS(e, n).toCBOR(n);
|
|
240
240
|
}
|
|
241
|
-
static compile(e,
|
|
242
|
-
let
|
|
243
|
-
for (let e of
|
|
241
|
+
static compile(e, n) {
|
|
242
|
+
let r = [...t.fromCDNSeq(e, n)].map((e) => e.toCBOR(n)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
|
|
243
|
+
for (let e of r) a.set(e, o), o += e.length;
|
|
244
244
|
return a;
|
|
245
245
|
}
|
|
246
|
-
static decompile(e,
|
|
247
|
-
return [...
|
|
246
|
+
static decompile(e, n) {
|
|
247
|
+
return [...t.fromCBORSeq(e, n)].map((e) => e.toCDN(n)).join("\n");
|
|
248
248
|
}
|
|
249
|
-
static toHex(e,
|
|
250
|
-
return [...
|
|
249
|
+
static toHex(e, n) {
|
|
250
|
+
return [...t.fromCBORSeq(e, n)].map((e) => e.toHexDump(n)).join("\n");
|
|
251
251
|
}
|
|
252
|
-
static fromHex(e,
|
|
253
|
-
let
|
|
254
|
-
for (let e of
|
|
252
|
+
static fromHex(e, n) {
|
|
253
|
+
let r = [...t.fromHexDumpSeq(e, n)].map((e) => e.toCBOR(n)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
|
|
254
|
+
for (let e of r) a.set(e, o), o += e.length;
|
|
255
255
|
return a;
|
|
256
256
|
}
|
|
257
|
-
static cborToCdn(e,
|
|
258
|
-
return
|
|
257
|
+
static cborToCdn(e, n) {
|
|
258
|
+
return t.fromCBOR(e, n).toCDN(n);
|
|
259
259
|
}
|
|
260
|
-
static cborToCborEdn(e,
|
|
261
|
-
return
|
|
260
|
+
static cborToCborEdn(e, n) {
|
|
261
|
+
return t.fromCBOR(e, n).toCDN(n);
|
|
262
262
|
}
|
|
263
|
-
static cdnToCbor(e,
|
|
264
|
-
return
|
|
263
|
+
static cdnToCbor(e, n) {
|
|
264
|
+
return t.fromCDN(e, n).toCBOR(n);
|
|
265
265
|
}
|
|
266
|
-
static cborEdnToCbor(e,
|
|
267
|
-
return
|
|
266
|
+
static cborEdnToCbor(e, n) {
|
|
267
|
+
return t.fromCDN(e, n).toCBOR(n);
|
|
268
268
|
}
|
|
269
|
-
static parse(e,
|
|
270
|
-
return typeof
|
|
269
|
+
static parse(e, n) {
|
|
270
|
+
return typeof n == "function" ? t.fromCDN(e).toJS({ reviver: n }) : t.fromCDN(e, n).toJS(n);
|
|
271
271
|
}
|
|
272
272
|
static stringify(e, t, n) {
|
|
273
273
|
if (typeof t == "function" || Array.isArray(t) || t === null || t === void 0 && n !== void 0) {
|
|
274
|
-
let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i =
|
|
274
|
+
let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i = z(n);
|
|
275
275
|
if (r) {
|
|
276
|
-
let t =
|
|
277
|
-
return t === void 0 || t ===
|
|
276
|
+
let t = _(e, r);
|
|
277
|
+
return t === void 0 || t === o ? void 0 : b(t).toCDN(i === void 0 ? void 0 : { indent: i });
|
|
278
278
|
}
|
|
279
|
-
return
|
|
279
|
+
return b(e).toCDN(i === void 0 ? void 0 : { indent: i });
|
|
280
280
|
}
|
|
281
281
|
let r = t;
|
|
282
282
|
if (r?.replacer) {
|
|
283
|
-
let t =
|
|
284
|
-
if (t === void 0 || t ===
|
|
283
|
+
let t = _(e, r.replacer, r.extensions, r.undefinedOmits, r.builtinExtensions);
|
|
284
|
+
if (t === void 0 || t === o) return;
|
|
285
285
|
let { replacer: n, ...i } = r;
|
|
286
|
-
return
|
|
286
|
+
return b(t, Object.keys(i).length > 0 ? i : void 0).toCDN(r);
|
|
287
287
|
}
|
|
288
|
-
return
|
|
288
|
+
return b(e, r).toCDN(r);
|
|
289
289
|
}
|
|
290
|
-
static format(e,
|
|
291
|
-
return
|
|
290
|
+
static format(e, n) {
|
|
291
|
+
return t.fromCDN(e, n).toCDN(n);
|
|
292
292
|
}
|
|
293
293
|
};
|
|
294
|
-
function
|
|
294
|
+
function N(e) {
|
|
295
295
|
let t = "", n = 0;
|
|
296
296
|
for (; n < e.length;) {
|
|
297
297
|
let r = e[n], i = e[n + 1] ?? "";
|
|
298
298
|
if (r === "-" && i === "-") {
|
|
299
|
-
n =
|
|
299
|
+
n = P(e, n + 2), t += " ";
|
|
300
300
|
continue;
|
|
301
301
|
}
|
|
302
302
|
if (r === "—") {
|
|
303
|
-
n =
|
|
303
|
+
n = P(e, n + 1), t += " ";
|
|
304
304
|
continue;
|
|
305
305
|
}
|
|
306
306
|
if (r === "#") {
|
|
307
|
-
n =
|
|
307
|
+
n = P(e, n + 1), t += " ";
|
|
308
308
|
continue;
|
|
309
309
|
}
|
|
310
310
|
if (r === "/" && i === "/") {
|
|
311
|
-
n =
|
|
311
|
+
n = P(e, n + 2), t += " ";
|
|
312
312
|
continue;
|
|
313
313
|
}
|
|
314
314
|
if (r === "/" && i === "*") {
|
|
315
315
|
let r = e.indexOf("*/", n + 2);
|
|
316
316
|
if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
|
|
317
|
-
t +=
|
|
317
|
+
t += F(e.slice(n, r + 2)), n = r + 2;
|
|
318
318
|
continue;
|
|
319
319
|
}
|
|
320
320
|
if (r === "/") {
|
|
321
321
|
let r = e.indexOf("/", n + 1);
|
|
322
322
|
if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
|
|
323
|
-
t +=
|
|
323
|
+
t += F(e.slice(n, r + 1)), n = r + 1;
|
|
324
324
|
continue;
|
|
325
325
|
}
|
|
326
326
|
t += r, n++;
|
|
327
327
|
}
|
|
328
328
|
return t;
|
|
329
329
|
}
|
|
330
|
-
function
|
|
330
|
+
function P(e, t) {
|
|
331
331
|
let n = e.indexOf("\n", t);
|
|
332
332
|
return n < 0 ? e.length : n;
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function F(e) {
|
|
335
335
|
return e.replace(/[^\r\n]/g, " ");
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function I(e, t, n, r, i) {
|
|
338
338
|
let a = i?.offset ?? t, o = {
|
|
339
339
|
message: e,
|
|
340
340
|
offset: a
|
|
341
341
|
};
|
|
342
342
|
r && (o.fatal = !0), i?.offset !== void 0 && (o.line = i.line, o.column = i.column, o.endOffset = i.endOffset), n?.onWarning ? n.onWarning(o) : n?.silent || console.warn(`CDN sequence warning at offset ${a}: ${e}`);
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function L(e, t) {
|
|
345
345
|
let n = e[t];
|
|
346
346
|
return n === "#" || n === "/";
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function R(e, t, n, r = "none") {
|
|
349
349
|
let i = t, a = !1, o = !1, s = !1, c = -1, l = () => r === "all" || r === "after-newline" && s;
|
|
350
350
|
for (; i < e.length;) {
|
|
351
351
|
let t = e[i];
|
|
@@ -375,7 +375,7 @@ function P(e, t, n, r = "none") {
|
|
|
375
375
|
if (t < 0) {
|
|
376
376
|
let t = "unterminated /* comment in CDN sequence";
|
|
377
377
|
if (n?.strict !== !1) throw SyntaxError(t);
|
|
378
|
-
|
|
378
|
+
I(t, i, n, !0), i = e.length;
|
|
379
379
|
} else e.slice(i, t).includes("\n") && (s = !0), i = t + 2;
|
|
380
380
|
continue;
|
|
381
381
|
}
|
|
@@ -385,7 +385,7 @@ function P(e, t, n, r = "none") {
|
|
|
385
385
|
if (t < 0) {
|
|
386
386
|
let t = "unterminated / comment in CDN sequence";
|
|
387
387
|
if (n?.strict !== !1) throw SyntaxError(t);
|
|
388
|
-
|
|
388
|
+
I(t, i, n, !0), i = e.length;
|
|
389
389
|
} else e.slice(i, t).includes("\n") && (s = !0), i = t + 1;
|
|
390
390
|
continue;
|
|
391
391
|
}
|
|
@@ -401,7 +401,7 @@ function P(e, t, n, r = "none") {
|
|
|
401
401
|
commaOffset: c
|
|
402
402
|
};
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function z(e) {
|
|
405
405
|
if (typeof e == "number") {
|
|
406
406
|
let t = Math.floor(Math.min(10, Math.max(0, e)));
|
|
407
407
|
return t === 0 ? void 0 : t;
|
|
@@ -409,6 +409,6 @@ function F(e) {
|
|
|
409
409
|
if (typeof e == "string") return e.slice(0, 10) || void 0;
|
|
410
410
|
}
|
|
411
411
|
//#endregion
|
|
412
|
-
export {
|
|
412
|
+
export { m as BUILTIN_EXTENSIONS, M as CBOR, M as default, o as CBOR_OMIT, s as CBOR_TAG, e as CdnSyntaxError, S as MapEntries, n as Null, a as Simple, r as Tag, i as Undefined, h as b1, O as b32, f as cri, g as dt, p as dt_as_Date, l as float, k as h32, x as ilbs, u as ilts, y as ip, j as same, C as t1 };
|
|
413
413
|
|
|
414
414
|
//# sourceMappingURL=index.js.map
|