@cbortech/cbor 0.26.6 → 0.26.8
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 +125 -0
- package/README.md +124 -0
- package/dist/ast/CborByteString.d.ts +25 -0
- package/dist/ast/CborEllipsis.d.ts +94 -2
- package/dist/ast/CborFloat.d.ts +10 -0
- package/dist/ast/CborItem.d.ts +93 -4
- package/dist/ast/CborNint.d.ts +9 -0
- package/dist/ast/CborSimple.d.ts +11 -2
- package/dist/ast/CborTag.d.ts +8 -0
- package/dist/ast/CborTextString.d.ts +36 -0
- package/dist/ast/CborUint.d.ts +8 -0
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.d.ts +1 -0
- package/dist/ast/index.js +2 -2
- package/dist/cddl/index.cjs +1 -1
- package/dist/cddl/index.js +1 -1
- package/dist/cdn/index.cjs +2 -2
- package/dist/cdn/index.cjs.map +1 -1
- package/dist/cdn/index.d.ts +2 -0
- package/dist/cdn/index.js +26 -26
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/serialize-utils.d.ts +208 -9
- package/dist/extensions/dt.d.ts +3 -0
- package/dist/extensions/types.d.ts +31 -9
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +62 -99
- package/dist/index.js.map +1 -1
- package/dist/mapEntries-BJzyBUH5.cjs +13 -0
- package/dist/mapEntries-BJzyBUH5.cjs.map +1 -0
- package/dist/{mapEntries-Czxt-cmd.js → mapEntries-Ci_dppP6.js} +1499 -1219
- package/dist/mapEntries-Ci_dppP6.js.map +1 -0
- package/dist/{schema-BmGsaEaW.cjs → schema-DgnkH0P6.cjs} +5 -5
- package/dist/{schema-BmGsaEaW.cjs.map → schema-DgnkH0P6.cjs.map} +1 -1
- package/dist/{schema-BxkgvUY6.js → schema-y8G5mDIS.js} +248 -248
- package/dist/{schema-BxkgvUY6.js.map → schema-y8G5mDIS.js.map} +1 -1
- package/dist/tokenizer-BD08xbyd.cjs +36 -0
- package/dist/tokenizer-BD08xbyd.cjs.map +1 -0
- package/dist/{tokenizer-CeuixxXi.js → tokenizer-N-vAvRdj.js} +350 -14
- package/dist/tokenizer-N-vAvRdj.js.map +1 -0
- package/dist/types.d.ts +176 -7
- package/package.json +2 -3
- package/dist/mapEntries-BhMlCwYo.cjs +0 -15
- package/dist/mapEntries-BhMlCwYo.cjs.map +0 -1
- package/dist/mapEntries-Czxt-cmd.js.map +0 -1
- package/dist/tokenizer-CeuixxXi.js.map +0 -1
- package/dist/tokenizer-EciPlN0n.cjs +0 -30
- package/dist/tokenizer-EciPlN0n.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,85 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as t, s as n } from "./schema-
|
|
3
|
-
import { B as r,
|
|
4
|
-
//#region src/extensions/b32.ts
|
|
5
|
-
var E = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", D = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
6
|
-
function O(e) {
|
|
7
|
-
let t = e.length;
|
|
8
|
-
for (; t > 0 && e.charCodeAt(t - 1) === 61;) t--;
|
|
9
|
-
return e.slice(0, t);
|
|
10
|
-
}
|
|
11
|
-
function k(e, t, n) {
|
|
12
|
-
let r = O(e).toUpperCase(), i = r.length % 8;
|
|
13
|
-
if (i === 1 || i === 3 || i === 6) throw SyntaxError(`invalid base32 length: ${r.length} characters`);
|
|
14
|
-
let a = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
|
|
15
|
-
for (let e = 0; e < t.length; e++) a[t.charCodeAt(e)] = e;
|
|
16
|
-
let o = new Uint8Array(Math.floor(r.length * 5 / 8)), s = 0, c = 0, l = 0;
|
|
17
|
-
for (let e of r) {
|
|
18
|
-
let t = e.charCodeAt(0), n = t < 128 ? a[t] : 255;
|
|
19
|
-
if (n === 255) throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);
|
|
20
|
-
s = s << 5 | n, c += 5, c >= 8 && (c -= 8, o[l++] = s >> c & 255);
|
|
21
|
-
}
|
|
22
|
-
if (c > 0 && s & (1 << c) - 1) {
|
|
23
|
-
let e = "non-zero trailing bits in base32 input";
|
|
24
|
-
if (n) n(e);
|
|
25
|
-
else throw SyntaxError(e);
|
|
26
|
-
}
|
|
27
|
-
return o;
|
|
28
|
-
}
|
|
29
|
-
var A = {
|
|
30
|
-
appStringPrefixes: ["b32"],
|
|
31
|
-
parseAppString(e, t, n) {
|
|
32
|
-
return new h(k(y(t), E, n), { ednEncoding: "base32" });
|
|
33
|
-
}
|
|
34
|
-
}, j = {
|
|
35
|
-
appStringPrefixes: ["h32"],
|
|
36
|
-
parseAppString(e, t, n) {
|
|
37
|
-
return new h(k(y(t), D, n), { ednEncoding: "base32hex" });
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
1
|
+
import { D as e } from "./tokenizer-N-vAvRdj.js";
|
|
2
|
+
import { n as t, s as n } from "./schema-y8G5mDIS.js";
|
|
3
|
+
import { B as r, C as i, H as a, R as o, S as s, U as c, V as l, a as u, c as d, d as f, f as p, g as m, i as h, l as g, m as _, n as v, o as y, p as b, r as x, s as S, t as C, u as w, z as T } from "./mapEntries-Ci_dppP6.js";
|
|
41
4
|
//#region src/extensions/same.ts
|
|
42
|
-
function
|
|
5
|
+
function E(e, t) {
|
|
43
6
|
if (e.length !== t.length) return !1;
|
|
44
7
|
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
45
8
|
return !0;
|
|
46
9
|
}
|
|
47
|
-
var
|
|
10
|
+
var D = {
|
|
48
11
|
appStringPrefixes: ["same"],
|
|
49
12
|
preserveAppSeqSource: !0,
|
|
50
13
|
parseAppSequence(e, t, n) {
|
|
51
14
|
if (t.length === 0) throw SyntaxError("same<<...>> requires at least one item");
|
|
52
15
|
let r = t[0], i = r.toCBOR();
|
|
53
|
-
for (let e = 1; e < t.length; e++) if (!
|
|
16
|
+
for (let e = 1; e < t.length; e++) if (!E(i, t[e].toCBOR())) {
|
|
54
17
|
let t = `same<<...>>: item ${e} produces different CBOR bytes than item 0`;
|
|
55
18
|
if (n) n(t);
|
|
56
19
|
else throw SyntaxError(t);
|
|
57
20
|
}
|
|
58
21
|
return r;
|
|
59
22
|
}
|
|
60
|
-
},
|
|
61
|
-
function
|
|
23
|
+
}, O = /* @__PURE__ */ new Map(), k = 64;
|
|
24
|
+
function A(e) {
|
|
62
25
|
if (typeof e != "string") return e;
|
|
63
|
-
let n =
|
|
64
|
-
return n || (n = t(e),
|
|
26
|
+
let n = O.get(e);
|
|
27
|
+
return n || (n = t(e), O.size >= k && O.delete(O.keys().next().value), O.set(e, n)), n;
|
|
65
28
|
}
|
|
66
|
-
function
|
|
29
|
+
function j(e, t, r) {
|
|
67
30
|
if (t) {
|
|
68
31
|
let i = t.validate(e, r);
|
|
69
32
|
if (!i.valid) throw new n(i.errors, i.warnings);
|
|
70
33
|
}
|
|
71
34
|
return e;
|
|
72
35
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
36
|
+
function M(e, t) {
|
|
37
|
+
return j(e, A(t?.cddl), t?.cddlValidationOptions);
|
|
75
38
|
}
|
|
76
|
-
var
|
|
77
|
-
static OMIT =
|
|
78
|
-
static TAG =
|
|
79
|
-
static Tag =
|
|
80
|
-
static Simple =
|
|
39
|
+
var N = class t {
|
|
40
|
+
static OMIT = T;
|
|
41
|
+
static TAG = r;
|
|
42
|
+
static Tag = a;
|
|
43
|
+
static Simple = o;
|
|
81
44
|
static MapEntries = C;
|
|
82
|
-
static dt_as_Date =
|
|
45
|
+
static dt_as_Date = _;
|
|
83
46
|
#e;
|
|
84
47
|
constructor(e) {
|
|
85
48
|
this.#e = e ?? {};
|
|
@@ -170,7 +133,7 @@ var z = class t {
|
|
|
170
133
|
stringify(e, n, r) {
|
|
171
134
|
if (typeof n == "function" || Array.isArray(n) || n === null || n === void 0 && r !== void 0) {
|
|
172
135
|
let i = { ...this.#e };
|
|
173
|
-
return n === null ? i.replacer = void 0 : (typeof n == "function" || Array.isArray(n)) && (i.replacer = n), r !== void 0 && (i.indent =
|
|
136
|
+
return n === null ? i.replacer = void 0 : (typeof n == "function" || Array.isArray(n)) && (i.replacer = n), r !== void 0 && (i.indent = B(r)), t.stringify(e, i);
|
|
174
137
|
}
|
|
175
138
|
return t.stringify(e, this.#t(n ?? void 0));
|
|
176
139
|
}
|
|
@@ -178,51 +141,51 @@ var z = class t {
|
|
|
178
141
|
return t.format(e, this.#t(n));
|
|
179
142
|
}
|
|
180
143
|
static fromCBOR(e, t) {
|
|
181
|
-
return
|
|
144
|
+
return M(w(e, t), t);
|
|
182
145
|
}
|
|
183
146
|
static fromCDN(e, t) {
|
|
184
|
-
return
|
|
147
|
+
return M(m(e, t), t);
|
|
185
148
|
}
|
|
186
149
|
static fromEDN(e, n) {
|
|
187
150
|
return t.fromCDN(e, n);
|
|
188
151
|
}
|
|
189
152
|
static *fromHexDumpSeq(e, n) {
|
|
190
|
-
let r = [], i =
|
|
153
|
+
let r = [], i = P(e).trim().split(/\s+/).filter(Boolean);
|
|
191
154
|
for (let e of i) if (/^[0-9A-Fa-f]{2}$/.test(e)) r.push(parseInt(e, 16));
|
|
192
155
|
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));
|
|
193
156
|
else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
|
|
194
157
|
yield* t.fromCBORSeq(new Uint8Array(r), n);
|
|
195
158
|
}
|
|
196
159
|
static *fromCBORSeq(e, t) {
|
|
197
|
-
let n =
|
|
160
|
+
let n = A(t?.cddl), r = e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength), i = 0;
|
|
198
161
|
for (; i < r.byteLength;) {
|
|
199
|
-
let e =
|
|
162
|
+
let e = w(r, {
|
|
200
163
|
...t,
|
|
201
164
|
offset: i,
|
|
202
165
|
allowTrailing: !0
|
|
203
166
|
});
|
|
204
|
-
yield
|
|
167
|
+
yield j(e, n, t?.cddlValidationOptions), i = e.end;
|
|
205
168
|
}
|
|
206
169
|
}
|
|
207
170
|
static *fromCDNSeq(t, n) {
|
|
208
|
-
let r =
|
|
171
|
+
let r = A(n?.cddl), i = !!n?.preserveComments, a = 0, o = !0;
|
|
209
172
|
for (;;) {
|
|
210
|
-
let { offset: s, hadSeparator:
|
|
211
|
-
if (o &&
|
|
173
|
+
let { offset: s, hadSeparator: c, commaOffset: l } = z(t, a, n, i ? o ? "all" : "after-newline" : "none");
|
|
174
|
+
if (o && l >= 0) {
|
|
212
175
|
let e = "leading comma in CDN sequence";
|
|
213
176
|
if (n?.strict !== !1) throw SyntaxError(e);
|
|
214
|
-
|
|
177
|
+
L(e, l, n);
|
|
215
178
|
}
|
|
216
|
-
if (s >= t.length || i &&
|
|
217
|
-
if (!o && !
|
|
179
|
+
if (s >= t.length || i && R(t, s) && z(t, s, n).offset >= t.length) break;
|
|
180
|
+
if (!o && !c) {
|
|
218
181
|
let e = "CDN sequence items must be separated by whitespace, comma, or comment";
|
|
219
182
|
if (n?.strict !== !1) throw SyntaxError(e);
|
|
220
|
-
|
|
183
|
+
L(e, s, n);
|
|
221
184
|
}
|
|
222
185
|
a = s;
|
|
223
|
-
let
|
|
186
|
+
let u;
|
|
224
187
|
try {
|
|
225
|
-
|
|
188
|
+
u = m(t, {
|
|
226
189
|
...n,
|
|
227
190
|
offset: a,
|
|
228
191
|
allowTrailing: !0,
|
|
@@ -230,21 +193,21 @@ var z = class t {
|
|
|
230
193
|
});
|
|
231
194
|
} catch (t) {
|
|
232
195
|
if (n?.strict !== !1) throw t;
|
|
233
|
-
|
|
196
|
+
L(t instanceof Error ? t.message : String(t), a, n, !0, t instanceof e ? t : void 0);
|
|
234
197
|
break;
|
|
235
198
|
}
|
|
236
|
-
yield
|
|
199
|
+
yield j(u, r, n?.cddlValidationOptions), a = u.end, o = !1;
|
|
237
200
|
}
|
|
238
201
|
}
|
|
239
202
|
static fromJS(e, t) {
|
|
240
|
-
return
|
|
203
|
+
return M(x(e, t), t);
|
|
241
204
|
}
|
|
242
205
|
static fromHexDump(e, t) {
|
|
243
|
-
let n = [], r =
|
|
206
|
+
let n = [], r = P(e).trim().split(/\s+/).filter(Boolean);
|
|
244
207
|
for (let e of r) if (/^[0-9A-Fa-f]{2}$/.test(e)) n.push(parseInt(e, 16));
|
|
245
208
|
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));
|
|
246
209
|
else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
|
|
247
|
-
return
|
|
210
|
+
return M(w(new Uint8Array(n), t), t);
|
|
248
211
|
}
|
|
249
212
|
static decode(e, n) {
|
|
250
213
|
return t.fromCBOR(e, n).toJS(n);
|
|
@@ -290,7 +253,7 @@ var z = class t {
|
|
|
290
253
|
}
|
|
291
254
|
i.push(e);
|
|
292
255
|
}
|
|
293
|
-
}, c =
|
|
256
|
+
}, c = A(r?.cddl), l = [], u = [], d = (e) => {
|
|
294
257
|
if (!c) return;
|
|
295
258
|
let t = c.validate(e, r?.cddlValidationOptions);
|
|
296
259
|
l.push(...t.errors), t.warnings && u.push(...t.warnings);
|
|
@@ -354,81 +317,81 @@ var z = class t {
|
|
|
354
317
|
}
|
|
355
318
|
static stringify(e, t, n) {
|
|
356
319
|
if (typeof t == "function" || Array.isArray(t) || t === null || t === void 0 && n !== void 0) {
|
|
357
|
-
let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i =
|
|
320
|
+
let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i = B(n);
|
|
358
321
|
if (r) {
|
|
359
322
|
let t = v(e, r);
|
|
360
|
-
return t === void 0 || t ===
|
|
323
|
+
return t === void 0 || t === T ? void 0 : x(t).toCDN(i === void 0 ? void 0 : { indent: i });
|
|
361
324
|
}
|
|
362
325
|
return x(e).toCDN(i === void 0 ? void 0 : { indent: i });
|
|
363
326
|
}
|
|
364
327
|
let r = t;
|
|
365
328
|
if (r?.replacer) {
|
|
366
329
|
let t = v(e, r.replacer, r.extensions, r.undefinedOmits, r.builtinExtensions);
|
|
367
|
-
if (t === void 0 || t ===
|
|
330
|
+
if (t === void 0 || t === T) return;
|
|
368
331
|
let { replacer: n, ...i } = r;
|
|
369
|
-
return
|
|
332
|
+
return M(x(t, Object.keys(i).length > 0 ? i : void 0), r).toCDN(r);
|
|
370
333
|
}
|
|
371
|
-
return
|
|
334
|
+
return M(x(e, r), r).toCDN(r);
|
|
372
335
|
}
|
|
373
336
|
static format(e, n) {
|
|
374
337
|
return t.fromCDN(e, n).toCDN(n);
|
|
375
338
|
}
|
|
376
339
|
};
|
|
377
|
-
function
|
|
340
|
+
function P(e) {
|
|
378
341
|
let t = "", n = 0;
|
|
379
342
|
for (; n < e.length;) {
|
|
380
343
|
let r = e[n], i = e[n + 1] ?? "";
|
|
381
344
|
if (r === "-" && i === "-") {
|
|
382
|
-
n =
|
|
345
|
+
n = F(e, n + 2), t += " ";
|
|
383
346
|
continue;
|
|
384
347
|
}
|
|
385
348
|
if (r === "—") {
|
|
386
|
-
n =
|
|
349
|
+
n = F(e, n + 1), t += " ";
|
|
387
350
|
continue;
|
|
388
351
|
}
|
|
389
352
|
if (r === "#") {
|
|
390
|
-
n =
|
|
353
|
+
n = F(e, n + 1), t += " ";
|
|
391
354
|
continue;
|
|
392
355
|
}
|
|
393
356
|
if (r === "/" && i === "/") {
|
|
394
|
-
n =
|
|
357
|
+
n = F(e, n + 2), t += " ";
|
|
395
358
|
continue;
|
|
396
359
|
}
|
|
397
360
|
if (r === "/" && i === "*") {
|
|
398
361
|
let r = e.indexOf("*/", n + 2);
|
|
399
362
|
if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
|
|
400
|
-
t +=
|
|
363
|
+
t += I(e.slice(n, r + 2)), n = r + 2;
|
|
401
364
|
continue;
|
|
402
365
|
}
|
|
403
366
|
if (r === "/") {
|
|
404
367
|
let r = e.indexOf("/", n + 1);
|
|
405
368
|
if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
|
|
406
|
-
t +=
|
|
369
|
+
t += I(e.slice(n, r + 1)), n = r + 1;
|
|
407
370
|
continue;
|
|
408
371
|
}
|
|
409
372
|
t += r, n++;
|
|
410
373
|
}
|
|
411
374
|
return t;
|
|
412
375
|
}
|
|
413
|
-
function
|
|
376
|
+
function F(e, t) {
|
|
414
377
|
let n = e.indexOf("\n", t);
|
|
415
378
|
return n < 0 ? e.length : n;
|
|
416
379
|
}
|
|
417
|
-
function
|
|
380
|
+
function I(e) {
|
|
418
381
|
return e.replace(/[^\r\n]/g, " ");
|
|
419
382
|
}
|
|
420
|
-
function
|
|
383
|
+
function L(e, t, n, r, i) {
|
|
421
384
|
let a = i?.offset ?? t, o = {
|
|
422
385
|
message: e,
|
|
423
386
|
offset: a
|
|
424
387
|
};
|
|
425
388
|
r && (o.fatal = !0), i && (o.cause = i), 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}`);
|
|
426
389
|
}
|
|
427
|
-
function
|
|
390
|
+
function R(e, t) {
|
|
428
391
|
let n = e[t];
|
|
429
392
|
return n === "#" || n === "/";
|
|
430
393
|
}
|
|
431
|
-
function
|
|
394
|
+
function z(e, t, n, r = "none") {
|
|
432
395
|
let i = t, a = !1, o = !1, s = !1, c = -1, l = () => r === "all" || r === "after-newline" && s;
|
|
433
396
|
for (; i < e.length;) {
|
|
434
397
|
let t = e[i];
|
|
@@ -458,7 +421,7 @@ function G(e, t, n, r = "none") {
|
|
|
458
421
|
if (t < 0) {
|
|
459
422
|
let t = "unterminated /* comment in CDN sequence";
|
|
460
423
|
if (n?.strict !== !1) throw SyntaxError(t);
|
|
461
|
-
|
|
424
|
+
L(t, i, n, !0), i = e.length;
|
|
462
425
|
} else e.slice(i, t).includes("\n") && (s = !0), i = t + 2;
|
|
463
426
|
continue;
|
|
464
427
|
}
|
|
@@ -468,7 +431,7 @@ function G(e, t, n, r = "none") {
|
|
|
468
431
|
if (t < 0) {
|
|
469
432
|
let t = "unterminated / comment in CDN sequence";
|
|
470
433
|
if (n?.strict !== !1) throw SyntaxError(t);
|
|
471
|
-
|
|
434
|
+
L(t, i, n, !0), i = e.length;
|
|
472
435
|
} else e.slice(i, t).includes("\n") && (s = !0), i = t + 1;
|
|
473
436
|
continue;
|
|
474
437
|
}
|
|
@@ -484,7 +447,7 @@ function G(e, t, n, r = "none") {
|
|
|
484
447
|
commaOffset: c
|
|
485
448
|
};
|
|
486
449
|
}
|
|
487
|
-
function
|
|
450
|
+
function B(e) {
|
|
488
451
|
if (typeof e == "number") {
|
|
489
452
|
let t = Math.floor(Math.min(10, Math.max(0, e)));
|
|
490
453
|
return t === 0 ? void 0 : t;
|
|
@@ -492,6 +455,6 @@ function K(e) {
|
|
|
492
455
|
if (typeof e == "string") return e.slice(0, 10) || void 0;
|
|
493
456
|
}
|
|
494
457
|
//#endregion
|
|
495
|
-
export {
|
|
458
|
+
export { h as BUILTIN_EXTENSIONS, N as CBOR, N as default, T as CBOR_OMIT, r as CBOR_TAG, n as CddlMismatchError, e as CdnSyntaxError, C as MapEntries, l as Null, o as Simple, a as Tag, c as Undefined, d as b1, s as b32, f as cri, b as dt, _ as dt_as_Date, u as float, i as h32, y as ilbs, S as ilts, p as ip, D as same, g as t1 };
|
|
496
459
|
|
|
497
460
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#defaults","#merge"],"sources":["../src/extensions/b32.ts","../src/extensions/same.ts","../src/cbor.ts"],"sourcesContent":["import type { CborExtension } from './types';\nimport { CborByteString } from '../ast/CborByteString';\nimport { stripComments } from '../utils/strip-comments';\n\nconst B32_ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\nconst H32_ALPHA = '0123456789ABCDEFGHIJKLMNOPQRSTUV';\n\nfunction stripBase32Padding(str: string): string {\n let end = str.length;\n while (end > 0 && str.charCodeAt(end - 1) === 0x3d) end--;\n return str.slice(0, end);\n}\n\nfunction base32Decode(\n str: string,\n alpha: string,\n onError?: (msg: string) => void\n): Uint8Array {\n // Padding is optional; strip it before decoding.\n const s = stripBase32Padding(str).toUpperCase();\n // RFC 4648 §6: valid unpadded lengths mod 8 are 0, 2, 4, 5, 7.\n // Lengths 1, 3, 6 can never result from any valid byte sequence.\n const rem = s.length % 8;\n if (rem === 1 || rem === 3 || rem === 6)\n throw new SyntaxError(`invalid base32 length: ${s.length} characters`);\n const lookup = new Uint8Array(128).fill(0xff);\n for (let i = 0; i < alpha.length; i++) lookup[alpha.charCodeAt(i)] = i;\n const out = new Uint8Array(Math.floor((s.length * 5) / 8));\n let buf = 0,\n bufBits = 0,\n outIdx = 0;\n for (const ch of s) {\n const code = ch.charCodeAt(0);\n const val = code < 128 ? lookup[code] : 0xff;\n if (val === 0xff)\n throw new SyntaxError(\n `invalid character in byte string: ${JSON.stringify(ch)}`\n );\n buf = (buf << 5) | val;\n bufBits += 5;\n if (bufBits >= 8) {\n bufBits -= 8;\n out[outIdx++] = (buf >> bufBits) & 0xff;\n }\n }\n // RFC 4648 §3.5: trailing bits in the final quantum must be zero.\n if (bufBits > 0 && (buf & ((1 << bufBits) - 1)) !== 0) {\n const msg = 'non-zero trailing bits in base32 input';\n if (onError) onError(msg);\n else throw new SyntaxError(msg);\n }\n return out;\n}\n\n/** RFC 4648 §6 Base32 (A–Z 2–7) app-string extension. */\nexport const b32: CborExtension = {\n appStringPrefixes: ['b32'],\n parseAppString(_prefix, content, onError) {\n return new CborByteString(\n base32Decode(stripComments(content), B32_ALPHA, onError),\n {\n ednEncoding: 'base32',\n }\n );\n },\n};\n\n/** RFC 4648 §7 Base32Hex (0–9 A–V) app-string extension. */\nexport const h32: CborExtension = {\n appStringPrefixes: ['h32'],\n parseAppString(_prefix, content, onError) {\n return new CborByteString(\n base32Decode(stripComments(content), H32_ALPHA, onError),\n {\n ednEncoding: 'base32hex',\n }\n );\n },\n};\n","/**\n * `same<<expr, expr, ...>>` app-sequence extension.\n *\n * Evaluates every item in the sequence to CBOR bytes and asserts that all\n * produce identical bytes. Returns the first item if all match.\n *\n * In strict mode a mismatch throws a `SyntaxError`. In lenient mode\n * (`strict: false`) a mismatch emits a `ParseWarning` and returns the first\n * item so parsing can continue.\n *\n * `same<<x>>` (single item) is a no-op assertion that always passes.\n *\n * The parsed result is wrapped in `CborAppSeqResult` so that `toCDN()` round-trips\n * the original `same<<...>>` notation. `toCBOR()` and `toJS()` delegate\n * transparently to the inner item; `appStrings: false` produces the resolved value.\n * The result is not directly `instanceof` the inner item's class.\n *\n * This extension is a testing/validation construct from the cabo/edn-abnf\n * corpus and is NOT part of draft-ietf-cbor-edn-literals. It is not included\n * in the default extension set. Add it explicitly:\n *\n * @example\n * import { same } from '@cbortech/cbor';\n * parseCDN(\"same<<b64'AA',h'00'>>\", { extensions: [same] }); // h'00'\n */\n\nimport type { CborExtension } from './types';\nimport type { CborItem } from '../ast/CborItem';\n\nfunction bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\n\n/**\n * Extension object for `same<<...>>`.\n * Pass to `parseCDN(..., { extensions: [same] })`.\n */\nexport const same: CborExtension = {\n appStringPrefixes: ['same'],\n preserveAppSeqSource: true,\n\n parseAppSequence(\n _prefix: string,\n items: CborItem[],\n onError?: (msg: string) => void\n ): CborItem {\n if (items.length === 0)\n throw new SyntaxError(`same<<...>> requires at least one item`);\n const first = items[0]!;\n const firstCbor = first.toCBOR();\n for (let i = 1; i < items.length; i++) {\n const otherCbor = items[i]!.toCBOR();\n if (!bytesEqual(firstCbor, otherCbor)) {\n const msg = `same<<...>>: item ${i} produces different CBOR bytes than item 0`;\n if (onError)\n onError(msg); // lenient: warn + return first item\n else throw new SyntaxError(msg);\n }\n }\n return first;\n },\n};\n\nexport default same;\n","import type { CborItem } from './ast/CborItem';\nimport type {\n CBOROptions,\n DecodeWarning,\n FromCBOROptions,\n FromCBORSeqOptions,\n FromCDNOptions,\n FromCDNSeqOptions,\n FromHexDumpOptions,\n FromJSOptions,\n ParseWarning,\n ToCBOROptions,\n ToCDNOptions,\n ToHexDumpOptions,\n ToJSOptions,\n ValidateOptions,\n ValidateResult,\n} from './types';\nimport { CBOR_OMIT } from './types';\nimport { decodeCBOR } from './cbor/decoder';\nimport { parseCDN } from './cdn/parser';\nimport { CdnSyntaxError } from './cdn/errors';\nimport { CddlMismatchError } from './cddl/errors';\nimport { compile as compileCDDL, CddlSchema } from './cddl/schema';\nimport type { ValidateOptions as CddlValidateOptions } from './cddl/validator';\nimport type { CddlValidationError, CddlValidationWarning } from './cddl/errors';\nimport { dt_as_Date as _dt_as_Date } from './extensions/dt';\nimport { fromJS as _fromJS, _applyReplacer } from './js/fromJS';\nimport { MapEntries as _MapEntries } from './mapEntries';\nimport { Simple as _Simple } from './simple';\nimport { CBOR_TAG, Tag as _Tag } from './tag';\n\n/**\n * Cache for schemas compiled from CDDL source text passed as the `cddl`\n * option, so repeated per-call use of the same string does not recompile.\n * Bounded: the oldest entry is evicted once the cap is reached.\n */\nconst compiledCddlCache = new Map<string, CddlSchema>();\nconst COMPILED_CDDL_CACHE_MAX = 64;\n\n/**\n * Resolve the `cddl` option to a compiled schema: pass compiled schemas\n * through, compile (and cache) CDDL source text.\n */\nfunction resolveCddl(\n cddl: CddlSchema | string | undefined\n): CddlSchema | undefined {\n if (typeof cddl !== 'string') return cddl;\n let schema = compiledCddlCache.get(cddl);\n if (!schema) {\n schema = compileCDDL(cddl);\n if (compiledCddlCache.size >= COMPILED_CDDL_CACHE_MAX) {\n compiledCddlCache.delete(compiledCddlCache.keys().next().value!);\n }\n compiledCddlCache.set(cddl, schema);\n }\n return schema;\n}\n\n/**\n * Validate an item against a resolved schema (if any) and throw\n * {@link CddlMismatchError} on mismatch.\n */\nfunction assertCddl(\n item: CborItem,\n schema: CddlSchema | undefined,\n validationOptions?: CddlValidateOptions\n): CborItem {\n if (schema) {\n const result = schema.validate(item, validationOptions);\n if (!result.valid) {\n throw new CddlMismatchError(result.errors, result.warnings);\n }\n }\n return item;\n}\n\n/**\n * When a CDDL schema is supplied via the `cddl` option, validate the item\n * against it and throw {@link CddlMismatchError} on mismatch.\n */\nfunction checkCddl(\n item: CborItem,\n options?: {\n cddl?: CddlSchema | string;\n cddlValidationOptions?: CddlValidateOptions;\n }\n): CborItem {\n return assertCddl(\n item,\n resolveCddl(options?.cddl),\n options?.cddlValidationOptions\n );\n}\n\n/**\n * Main facade class.\n *\n * Provides factory methods for constructing AST nodes from the three\n * supported input formats, and shortcut methods that mirror the\n * `JSON.parse` / `JSON.stringify` API.\n *\n * @example\n * // CBOR binary → AST → CBOR binary\n * const ast = CBOR.fromCBOR(bytes);\n * const reencoded = ast.toCBOR();\n *\n * @example\n * // JS value → CBOR binary (shortcut)\n * const bytes = CBOR.encode({ hello: 'world' });\n *\n * @example\n * // CBOR binary → JS value (shortcut)\n * const value = CBOR.decode(bytes);\n */\nexport class CBOR {\n /**\n * Sentinel returned from a replacer or reviver to omit the key/element from\n * the output. Use this instead of `undefined` when `undefinedOmits` is\n * `false` (the default) and you need to drop a specific entry.\n */\n static readonly OMIT: typeof CBOR_OMIT = CBOR_OMIT;\n\n /** Unique symbol used to attach a CBOR tag number to a JS value. */\n static readonly TAG: typeof CBOR_TAG = CBOR_TAG;\n\n /** Namespace for CBOR tag annotation utilities. */\n static readonly Tag: typeof _Tag = _Tag;\n\n /** Wrapper for CBOR simple values other than false/true/null/undefined. */\n static readonly Simple: typeof _Simple = _Simple;\n\n /** Array subclass used to preserve CBOR map entries, including duplicates. */\n static readonly MapEntries: typeof _MapEntries = _MapEntries;\n\n /** Extension that maps CDN dt/DT values to JavaScript Date objects. */\n static readonly dt_as_Date: typeof _dt_as_Date = _dt_as_Date;\n\n // ─── Instance API ───────────────────────────────────────────────────────────\n\n readonly #defaults: CBOROptions;\n\n /**\n * Create a reusable instance with default options applied to every method call.\n * Per-call options always override these defaults.\n *\n * @example\n * const cbor = new CBOR({ extensions: [CBOR.dt_as_Date] });\n * const obj = cbor.parse('{ \"dt\": DT\\'2024-01-01T00:00:00Z\\' }');\n * const text = cbor.stringify(obj);\n */\n constructor(defaults?: CBOROptions) {\n this.#defaults = defaults ?? {};\n }\n\n #merge<T extends object>(perCall?: T): CBOROptions & T {\n return { ...this.#defaults, ...(perCall ?? {}) } as CBOROptions & T;\n }\n\n fromCBOR(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions\n ): CborItem {\n const node = CBOR.fromCBOR(input, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n fromCDN(text: string, options?: FromCDNOptions): CborItem {\n const node = CBOR.fromCDN(text, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n /** @deprecated Use `fromCDN()` instead. */\n fromEDN(text: string, options?: FromCDNOptions): CborItem {\n return this.fromCDN(text, options);\n }\n\n fromJS(value: unknown, options?: FromJSOptions): CborItem {\n const node = CBOR.fromJS(value, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n fromHexDump(text: string, options?: FromHexDumpOptions): CborItem {\n const node = CBOR.fromHexDump(text, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n *fromCBORSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions\n ): Generator<CborItem> {\n for (const item of CBOR.fromCBORSeq(input, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n *fromCDNSeq(text: string, options?: FromCDNSeqOptions): Generator<CborItem> {\n for (const item of CBOR.fromCDNSeq(text, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n *fromHexDumpSeq(\n text: string,\n options?: FromHexDumpOptions\n ): Generator<CborItem> {\n for (const item of CBOR.fromHexDumpSeq(text, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n decode(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToJSOptions\n ): unknown {\n return CBOR.decode(input, this.#merge(options));\n }\n\n *decodeSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToJSOptions\n ): Generator<unknown> {\n yield* CBOR.decodeSeq(input, this.#merge(options));\n }\n\n *parseSeq(\n text: string,\n options?: FromCDNSeqOptions & ToJSOptions\n ): Generator<unknown> {\n yield* CBOR.parseSeq(text, this.#merge(options));\n }\n\n encode(value: unknown, options?: FromJSOptions & ToCBOROptions): Uint8Array {\n return CBOR.encode(value, this.#merge(options));\n }\n\n compile(\n text: string,\n options?: FromCDNSeqOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.compile(text, this.#merge(options));\n }\n\n decompile(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToCDNOptions\n ): string {\n return CBOR.decompile(input, this.#merge(options));\n }\n\n toHex(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToHexDumpOptions\n ): string {\n return CBOR.toHex(input, this.#merge(options));\n }\n\n fromHex(\n text: string,\n options?: FromHexDumpOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromHex(text, this.#merge(options));\n }\n\n /**\n * Check CBOR / CDN / hex dump input for well-formedness and validity,\n * without throwing.\n */\n validate(\n input: ArrayBufferView | ArrayBufferLike | string,\n options?: ValidateOptions\n ): ValidateResult {\n return CBOR.validate(input, this.#merge(options));\n }\n\n /** @deprecated Use `decompile()` instead. */\n cborToCborEdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return this.cborToCdn(input, options);\n }\n\n /** @deprecated Use `decompile()` instead. */\n cborToCdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n const merged = this.#merge(options);\n const node = CBOR.fromCBOR(input, merged);\n node._defaults = this.#defaults;\n return node.toCDN(merged);\n }\n\n /** @deprecated Use `compile()` instead. */\n cborEdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return this.cdnToCbor(text, options);\n }\n\n /** @deprecated Use `compile()` instead. */\n cdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n const merged = this.#merge(options);\n return CBOR.fromCDN(text, merged).toCBOR(merged);\n }\n\n parse(text: string): unknown;\n parse(\n text: string,\n reviver: (this: unknown, key: unknown, value: unknown) => unknown\n ): unknown;\n parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;\n parse(\n text: string,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (FromCDNOptions & ToJSOptions)\n ): unknown {\n if (typeof arg2 === 'function') {\n const merged = this.#merge<ToJSOptions>({ reviver: arg2 });\n return CBOR.fromCDN(text, merged).toJS(merged);\n }\n const merged = this.#merge(arg2);\n return CBOR.fromCDN(text, merged).toJS(merged);\n }\n\n stringify(value: unknown): string;\n stringify(\n value: unknown,\n replacer:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null,\n space?: string | number\n ): string;\n stringify(value: unknown, options: FromJSOptions & ToCDNOptions): string;\n stringify(\n value: unknown,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null\n | (FromJSOptions & ToCDNOptions),\n arg3?: string | number\n ): string {\n if (\n typeof arg2 === 'function' ||\n Array.isArray(arg2) ||\n arg2 === null ||\n (arg2 === undefined && arg3 !== undefined)\n ) {\n const opts: FromJSOptions & ToCDNOptions = {\n ...(this.#defaults as FromJSOptions & ToCDNOptions),\n };\n if (arg2 === null) {\n opts.replacer = undefined;\n } else if (typeof arg2 === 'function' || Array.isArray(arg2)) {\n opts.replacer = arg2;\n }\n if (arg3 !== undefined) opts.indent = resolveSpace(arg3);\n return CBOR.stringify(value, opts);\n }\n return CBOR.stringify(value, this.#merge(arg2 ?? undefined));\n }\n\n format(text: string, options?: FromCDNOptions & ToCDNOptions): string {\n return CBOR.format(text, this.#merge(options));\n }\n\n // ─── Factory methods ────────────────────────────────────────────────────────\n\n /** Decode CBOR binary data into an AST node. */\n static fromCBOR(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions\n ): CborItem {\n return checkCddl(decodeCBOR(input, options), options);\n }\n\n /** Parse a CDN text string into an AST node. */\n static fromCDN(text: string, options?: FromCDNOptions): CborItem {\n return checkCddl(parseCDN(text, options), options);\n }\n\n /**\n * Parse a CDN text string into an AST node.\n *\n * @deprecated Use `fromCDN()` instead.\n */\n static fromEDN(text: string, options?: FromCDNOptions): CborItem {\n return CBOR.fromCDN(text, options);\n }\n\n /** アノテーション付き hex dump テキストから CBOR Sequence を item ごとにデコードするジェネレータ。 */\n static *fromHexDumpSeq(\n text: string,\n options?: FromHexDumpOptions\n ): Generator<CborItem> {\n const bytes: number[] = [];\n const uncommented = stripHexDumpComments(text);\n const tokens = uncommented.trim().split(/\\s+/).filter(Boolean);\n for (const token of tokens) {\n if (/^[0-9A-Fa-f]{2}$/.test(token)) {\n bytes.push(parseInt(token, 16));\n } else if (/^[0-9A-Fa-f]+$/.test(token) && token.length % 2 === 0) {\n for (let i = 0; i < token.length; i += 2)\n bytes.push(parseInt(token.slice(i, i + 2), 16));\n } else {\n throw new SyntaxError(\n `Invalid hex token in dump: ${JSON.stringify(token)}`\n );\n }\n }\n yield* CBOR.fromCBORSeq(new Uint8Array(bytes), options);\n }\n\n /** CBOR Sequence (RFC 8742) を item ごとにデコードするジェネレータ。 */\n static *fromCBORSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions\n ): Generator<CborItem> {\n // Resolve up front so invalid CDDL source text throws even when the\n // sequence turns out to be empty.\n const cddlSchema = resolveCddl(options?.cddl);\n const bytes =\n input instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== 'undefined' &&\n input instanceof SharedArrayBuffer)\n ? new Uint8Array(input)\n : new Uint8Array(\n (input as ArrayBufferView).buffer,\n (input as ArrayBufferView).byteOffset,\n (input as ArrayBufferView).byteLength\n );\n let offset = 0;\n while (offset < bytes.byteLength) {\n const item = decodeCBOR(bytes, {\n ...options,\n offset,\n allowTrailing: true,\n });\n yield assertCddl(item, cddlSchema, options?.cddlValidationOptions);\n offset = item.end!;\n }\n }\n\n /**\n * CDN テキストの複数 item を 1 つずつパースするジェネレータ。\n *\n * `preserveComments` が有効な場合、item 間のコメントは次の item の\n * leading コメントとして、item と同じ行にあるコメントはその item の\n * trailing コメントとして付与される。最後の item の後の行にだけ\n * コメントが残る場合、そのコメントはどの item にも属さず破棄される。\n */\n static *fromCDNSeq(\n text: string,\n options?: FromCDNSeqOptions\n ): Generator<CborItem> {\n // Resolve up front so invalid CDDL source text throws even when the\n // sequence turns out to be empty.\n const cddlSchema = resolveCddl(options?.cddl);\n const preserve = !!options?.preserveComments;\n let offset = 0;\n let isFirst = true;\n while (true) {\n const {\n offset: next,\n hadSeparator,\n commaOffset,\n } = skipCDNSeparator(\n text,\n offset,\n options,\n preserve ? (isFirst ? 'all' : 'after-newline') : 'none'\n );\n // Leading comma: comma before the first item (including comma-only input).\n // Checked before the EOF break so that \",\" alone is also caught.\n // Trailing comma is valid per ABNF SOC = S [\",\" S] and is silently accepted.\n if (isFirst && commaOffset >= 0) {\n const msg = 'leading comma in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, commaOffset, options);\n }\n if (next >= text.length) break;\n // Stopped at a comment that should lead the next item: make sure an\n // item actually follows. If only comments remain, we are done (the\n // remaining comments belong to no item and are dropped, matching the\n // behaviour of `preserveComments: false`).\n if (preserve && isCDNCommentStart(text, next)) {\n const lookahead = skipCDNSeparator(text, next, options);\n if (lookahead.offset >= text.length) break;\n }\n if (!isFirst && !hadSeparator) {\n const msg =\n 'CDN sequence items must be separated by whitespace, comma, or comment';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, next, options);\n }\n offset = next;\n let item: CborItem;\n try {\n // _skipRS: true causes the tokenizer to treat RS (U+001E, RFC 7464) as\n // whitespace, preventing it from corrupting string-literal contents via\n // a global text replacement.\n item = parseCDN(text, {\n ...options,\n offset,\n allowTrailing: true,\n _skipRS: true,\n } as FromCDNOptions);\n } catch (e) {\n if (options?.strict !== false) throw e;\n emitCDNSeqWarning(\n e instanceof Error ? e.message : String(e),\n offset,\n options,\n true,\n e instanceof CdnSyntaxError ? e : undefined\n );\n break;\n }\n yield assertCddl(item, cddlSchema, options?.cddlValidationOptions);\n offset = item.end!;\n isFirst = false;\n }\n }\n\n /** Convert a JavaScript value into an AST node. */\n static fromJS(value: unknown, options?: FromJSOptions): CborItem {\n return checkCddl(_fromJS(value, options), options);\n }\n\n /**\n * Parse an annotated hex dump (as produced by {@link CborItem#toHexDump})\n * into an AST node.\n *\n * Each line is expected to have the form:\n * `[whitespace] HH [HH …] -- comment`\n * `[whitespace] HH [HH …] # comment`\n * `[whitespace] HH [HH …] // comment`\n * Block comments may also be written as `/ comment /` or `/* comment *\\/`.\n * Lines with no hex content before the comment marker are ignored.\n */\n static fromHexDump(text: string, options?: FromHexDumpOptions): CborItem {\n const bytes: number[] = [];\n const uncommented = stripHexDumpComments(text);\n const tokens = uncommented.trim().split(/\\s+/).filter(Boolean);\n for (const token of tokens) {\n if (/^[0-9A-Fa-f]{2}$/.test(token)) {\n bytes.push(parseInt(token, 16));\n } else if (/^[0-9A-Fa-f]+$/.test(token) && token.length % 2 === 0) {\n for (let i = 0; i < token.length; i += 2)\n bytes.push(parseInt(token.slice(i, i + 2), 16));\n } else {\n throw new SyntaxError(\n `Invalid hex token in dump: ${JSON.stringify(token)}`\n );\n }\n }\n return checkCddl(decodeCBOR(new Uint8Array(bytes), options), options);\n }\n\n // ─── Shortcut API ───────────────────────────────────────────────────────────\n\n /** Decode CBOR binary data directly to a JavaScript value. */\n static decode(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToJSOptions\n ): unknown {\n return CBOR.fromCBOR(input, options).toJS(options);\n }\n\n /** Decode a CBOR Sequence (RFC 8742), yielding each item as a JavaScript value. */\n static *decodeSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToJSOptions\n ): Generator<unknown> {\n for (const item of CBOR.fromCBORSeq(input, options)) {\n yield item.toJS(options);\n }\n }\n\n /** Parse a CDN Sequence text string, yielding each item as a JavaScript value. */\n static *parseSeq(\n text: string,\n options?: FromCDNSeqOptions & ToJSOptions\n ): Generator<unknown> {\n for (const item of CBOR.fromCDNSeq(text, options)) {\n yield item.toJS(options);\n }\n }\n\n /** Encode a JavaScript value directly to CBOR binary data. */\n static encode(\n value: unknown,\n options?: FromJSOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromJS(value, options).toCBOR(options);\n }\n\n /**\n * Compile a CDN text string to CBOR binary data.\n * Multi-item CDN Sequences produce a CBOR Sequence (RFC 8742): concatenated items.\n */\n static compile(\n text: string,\n options?: FromCDNSeqOptions & ToCBOROptions\n ): Uint8Array {\n const byteArrays = [...CBOR.fromCDNSeq(text, options)].map((item) =>\n item.toCBOR(options)\n );\n const total = byteArrays.reduce((s, b) => s + b.length, 0);\n const result = new Uint8Array(total);\n let off = 0;\n for (const b of byteArrays) {\n result.set(b, off);\n off += b.length;\n }\n return result;\n }\n\n /**\n * Decompile CBOR binary data to a CDN text string.\n * CBOR Sequences (RFC 8742) produce multi-item CDN output, with items separated by newlines.\n */\n static decompile(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToCDNOptions\n ): string {\n return [...CBOR.fromCBORSeq(input, options)]\n .map((item) => item.toCDN(options))\n .join('\\n');\n }\n\n /**\n * Convert CBOR binary data to an annotated hex dump string.\n * CBOR Sequences (RFC 8742) produce one dump per item, separated by newlines.\n */\n static toHex(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToHexDumpOptions\n ): string {\n return [...CBOR.fromCBORSeq(input, options)]\n .map((item) => item.toHexDump(options))\n .join('\\n');\n }\n\n /**\n * Parse an annotated hex dump string to CBOR binary data.\n * Multi-item dumps produce a CBOR Sequence (RFC 8742): concatenated items.\n */\n static fromHex(\n text: string,\n options?: FromHexDumpOptions & ToCBOROptions\n ): Uint8Array {\n const byteArrays = [...CBOR.fromHexDumpSeq(text, options)].map((item) =>\n item.toCBOR(options)\n );\n const total = byteArrays.reduce((s, b) => s + b.length, 0);\n const result = new Uint8Array(total);\n let off = 0;\n for (const b of byteArrays) {\n result.set(b, off);\n off += b.length;\n }\n return result;\n }\n\n /**\n * Check CBOR / CDN / hex dump input for well-formedness and validity,\n * without throwing.\n *\n * Decodes/parses the input as a sequence (CBOR Sequence per RFC 8742, or a\n * CDN Sequence) in non-strict mode: recoverable violations are collected\n * into `warnings` instead of stopping decoding, while malformed input\n * (e.g. truncated data, hard syntax errors — including a CDN Sequence\n * abandoned after a hard syntax error) is reported via `error`.\n * Informational hints about optional extensions that aren't registered\n * (`ParseWarning.hint`) are not treated as violations; they are collected\n * separately into `hints`.\n *\n * @example\n * const result = CBOR.validate(bytes);\n * if (!result.valid) {\n * if (result.error) console.error(`invalid: ${result.error.message}`);\n * for (const w of result.warnings) console.warn(w.message);\n * }\n *\n * @example\n * // CDN text input\n * CBOR.validate('{\"a\": 1}', { type: 'cdn' });\n *\n * @example\n * // Schema validation with a compiled CDDL schema\n * import { CDDL } from '@cbortech/cbor/cddl';\n * const schema = CDDL.compile('person = { name: tstr, ? age: uint }');\n * const result = CBOR.validate('{\"name\": \"kudo\"}', { type: 'cdn', cddl: schema });\n * result.valid; // true\n * result.cddlErrors; // []\n */\n static validate(\n input: ArrayBufferView | ArrayBufferLike | string,\n options?: ValidateOptions\n ): ValidateResult {\n const warnings: (DecodeWarning | ParseWarning)[] = [];\n const hints: ParseWarning[] = [];\n let fatal: ParseWarning | undefined;\n // `cddl` is deliberately not forwarded to the Seq generators: a mismatch\n // must be collected below, not thrown from inside the generator.\n const seqOptions = {\n strict: false,\n extensions: options?.extensions,\n builtinExtensions: options?.builtinExtensions,\n onWarning: (w: DecodeWarning | ParseWarning) => {\n if ('hint' in w && w.hint) {\n hints.push(w);\n return;\n }\n if ('fatal' in w && w.fatal) {\n fatal = w;\n return;\n }\n warnings.push(w);\n },\n };\n const schema = resolveCddl(options?.cddl);\n const cddlErrors: CddlValidationError[] = [];\n const cddlWarnings: CddlValidationWarning[] = [];\n const checkItem = (item: CborItem) => {\n if (!schema) return;\n const result = schema.validate(item, options?.cddlValidationOptions);\n cddlErrors.push(...result.errors);\n if (result.warnings) cddlWarnings.push(...result.warnings);\n };\n const cddlFields = schema ? { cddlErrors, cddlWarnings } : {};\n let count = 0;\n try {\n const type = options?.type ?? 'cbor';\n if (type === 'cdn') {\n const cdnOptions: FromCDNSeqOptions = {\n ...seqOptions,\n unresolvedExtension: options?.unresolvedExtension,\n };\n for (const item of CBOR.fromCDNSeq(input as string, cdnOptions)) {\n count++;\n checkItem(item);\n }\n } else if (type === 'hex') {\n for (const item of CBOR.fromHexDumpSeq(input as string, seqOptions)) {\n count++;\n checkItem(item);\n }\n } else {\n for (const item of CBOR.fromCBORSeq(\n input as ArrayBufferView | ArrayBufferLike,\n seqOptions\n )) {\n count++;\n checkItem(item);\n }\n }\n } catch (err) {\n return {\n valid: false,\n count,\n warnings,\n hints,\n error: err instanceof Error ? err : new Error(String(err)),\n ...cddlFields,\n };\n }\n if (fatal) {\n // Prefer the original syntax error (position fields intact); the\n // unterminated-comment fatals are emitted without one, so rebuild a\n // CdnSyntaxError carrying at least the warning's offset.\n const error =\n fatal.cause instanceof Error\n ? fatal.cause\n : new CdnSyntaxError(fatal.message, { offset: fatal.offset });\n return { valid: false, count, warnings, hints, error, ...cddlFields };\n }\n return {\n valid: warnings.length === 0 && cddlErrors.length === 0,\n count,\n warnings,\n hints,\n ...cddlFields,\n };\n }\n\n /**\n * Convert CBOR binary data directly to a CDN text string.\n *\n * @deprecated Use `CBOR.decompile()` instead.\n */\n static cborToCdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return CBOR.fromCBOR(input, options).toCDN(options);\n }\n\n /** @deprecated Use `CBOR.decompile()` instead. */\n static cborToCborEdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return CBOR.fromCBOR(input, options).toCDN(options);\n }\n\n /**\n * Convert a CDN text string directly to CBOR binary data.\n *\n * @deprecated Use `CBOR.compile()` instead.\n */\n static cdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromCDN(text, options).toCBOR(options);\n }\n\n /** @deprecated Use `CBOR.compile()` instead. */\n static cborEdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromCDN(text, options).toCBOR(options);\n }\n\n /**\n * Parse a CDN text string directly to a JavaScript value.\n *\n * Accepts either a JSON-compatible `reviver` function as the second argument,\n * or a plain options object (existing API).\n *\n * When a `reviver` is supplied it is applied bottom-up after the CDN text has\n * been parsed and converted to a JS value, matching the semantics of\n * `JSON.parse(text, reviver)`.\n *\n * Note: CBOR-specific value types such as `bigint` are passed to the reviver\n * as-is; the reviver is responsible for handling them.\n */\n static parse(text: string): unknown;\n static parse(\n text: string,\n reviver: (this: unknown, key: unknown, value: unknown) => unknown\n ): unknown;\n static parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;\n static parse(\n text: string,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (FromCDNOptions & ToJSOptions)\n ): unknown {\n if (typeof arg2 === 'function') {\n return CBOR.fromCDN(text).toJS({ reviver: arg2 });\n }\n return CBOR.fromCDN(text, arg2).toJS(arg2);\n }\n\n /**\n * Serialize a JavaScript value directly to a CDN text string.\n *\n * Accepts either JSON-compatible `replacer` + `space` arguments, or a plain\n * options object (existing API).\n *\n * - `replacer` may be a function (transforms each key/value before encoding)\n * or an array of strings/numbers (allowlist of object keys to include).\n * Pass `null` to skip filtering.\n * - `space` controls indentation, mapping to `ToCDNOptions.indent`.\n * Numbers are clamped to `[0, 10]`; strings are truncated to 10 characters.\n */\n static stringify(value: unknown): string;\n static stringify(\n value: unknown,\n replacer:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null,\n space?: string | number\n ): string;\n static stringify(\n value: unknown,\n options: FromJSOptions & ToCDNOptions\n ): string;\n static stringify(\n value: unknown,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null\n | (FromJSOptions & ToCDNOptions),\n arg3?: string | number\n ): string {\n if (\n typeof arg2 === 'function' ||\n Array.isArray(arg2) ||\n arg2 === null ||\n (arg2 === undefined && arg3 !== undefined)\n ) {\n const replacer =\n typeof arg2 === 'function' || Array.isArray(arg2) ? arg2 : undefined;\n const indent = resolveSpace(arg3);\n if (replacer) {\n // Mirror JSON.stringify: if the replacer drops the root, return undefined.\n const replaced = _applyReplacer(value, replacer);\n if (replaced === undefined || replaced === CBOR_OMIT)\n return undefined as unknown as string;\n return _fromJS(replaced).toCDN(\n indent !== undefined ? { indent } : undefined\n );\n }\n return _fromJS(value).toCDN(\n indent !== undefined ? { indent } : undefined\n );\n }\n // Options form: also mirror JSON.stringify root-drop semantics.\n const opts = arg2 as (FromJSOptions & ToCDNOptions) | undefined;\n if (opts?.replacer) {\n const replaced = _applyReplacer(\n value,\n opts.replacer,\n opts.extensions,\n opts.undefinedOmits,\n opts.builtinExtensions\n );\n if (replaced === undefined || replaced === CBOR_OMIT)\n return undefined as unknown as string;\n const { replacer: _r, ...restFromJS } = opts;\n return checkCddl(\n _fromJS(\n replaced,\n Object.keys(restFromJS).length > 0\n ? (restFromJS as FromJSOptions)\n : undefined\n ),\n opts\n ).toCDN(opts);\n }\n return checkCddl(\n _fromJS(value, opts as FromJSOptions | undefined),\n opts\n ).toCDN(opts);\n }\n\n /** Normalize a CDN text string by parsing and re-serializing it. */\n static format(text: string, options?: FromCDNOptions & ToCDNOptions): string {\n return CBOR.fromCDN(text, options).toCDN(options);\n }\n}\n\nfunction stripHexDumpComments(text: string): string {\n let out = '';\n let i = 0;\n\n while (i < text.length) {\n const ch = text[i];\n const next = text[i + 1] ?? '';\n\n if (ch === '-' && next === '-') {\n i = skipLineComment(text, i + 2);\n out += ' ';\n continue;\n }\n\n if (ch === '—') {\n i = skipLineComment(text, i + 1);\n out += ' ';\n continue;\n }\n\n if (ch === '#') {\n i = skipLineComment(text, i + 1);\n out += ' ';\n continue;\n }\n\n if (ch === '/' && next === '/') {\n i = skipLineComment(text, i + 2);\n out += ' ';\n continue;\n }\n\n if (ch === '/' && next === '*') {\n const end = text.indexOf('*/', i + 2);\n if (end < 0) throw new SyntaxError('Unterminated comment in hex dump');\n out += whitespaceLike(text.slice(i, end + 2));\n i = end + 2;\n continue;\n }\n\n if (ch === '/') {\n const end = text.indexOf('/', i + 1);\n if (end < 0) throw new SyntaxError('Unterminated comment in hex dump');\n out += whitespaceLike(text.slice(i, end + 1));\n i = end + 1;\n continue;\n }\n\n out += ch;\n i++;\n }\n\n return out;\n}\n\nfunction skipLineComment(text: string, start: number): number {\n const end = text.indexOf('\\n', start);\n return end < 0 ? text.length : end;\n}\n\nfunction whitespaceLike(text: string): string {\n return text.replace(/[^\\r\\n]/g, ' ');\n}\n\n// ─── Module-scope helper ─────────────────────────────────────────────────────\n\nfunction emitCDNSeqWarning(\n msg: string,\n fallbackOffset: number,\n options: FromCDNSeqOptions | undefined,\n fatal?: boolean,\n cause?: CdnSyntaxError\n): void {\n const offset = cause?.offset ?? fallbackOffset;\n const w: ParseWarning = { message: msg, offset };\n if (fatal) w.fatal = true;\n if (cause) w.cause = cause;\n if (cause?.offset !== undefined) {\n w.line = cause.line;\n w.column = cause.column;\n w.endOffset = cause.endOffset;\n }\n if (options?.onWarning) options.onWarning(w);\n else if (!options?.silent)\n console.warn(`CDN sequence warning at offset ${offset}: ${msg}`);\n}\n\n/** Whether `text[i]` starts a CDN comment (`#`, `//`, `/* … *\\/`, or `/ … /`). */\nfunction isCDNCommentStart(text: string, i: number): boolean {\n const ch = text[i];\n return ch === '#' || ch === '/';\n}\n\n/**\n * CDN sequence の item 間にある空白・コメント・省略可能なカンマを読み飛ばし、\n * 次の item が始まる文字位置と、何らかの separator が存在したかどうかを返す。\n * 未終端のブロックコメントは strict モードでは throw し、\n * strict: false の場合は警告を emit して末尾まで読み飛ばす。\n *\n * `stopAtComments` は `preserveComments` 有効時にコメントを次の item の\n * leading コメントとして残すためのモード:\n * - `'none'`: コメントも読み飛ばす(従来動作)\n * - `'all'`: 最初のコメントで停止する(先頭 item 用)\n * - `'after-newline'`: 改行より後のコメントで停止する。直前 item と同じ行の\n * コメントはその item の trailing コメントとして既に付与されているため読み飛ばす。\n */\nfunction skipCDNSeparator(\n text: string,\n from: number,\n options: FromCDNSeqOptions | undefined,\n stopAtComments: 'none' | 'after-newline' | 'all' = 'none'\n): { offset: number; hadSeparator: boolean; commaOffset: number } {\n let i = from;\n let hadSeparator = false;\n let seenComma = false;\n let seenNewline = false;\n let commaOffset = -1;\n const stopHere = (): boolean =>\n stopAtComments === 'all' ||\n (stopAtComments === 'after-newline' && seenNewline);\n while (i < text.length) {\n const ch = text[i];\n if (ch === ' ' || ch === '\\t' || ch === '\\r' || ch === '\\x1e') {\n hadSeparator = true;\n i++;\n continue;\n }\n if (ch === '\\n') {\n hadSeparator = true;\n seenNewline = true;\n i++;\n continue;\n }\n if (ch === '#') {\n hadSeparator = true;\n if (stopHere()) break;\n const nl = text.indexOf('\\n', i + 1);\n i = nl < 0 ? text.length : nl + 1;\n seenNewline = true;\n continue;\n }\n if (ch === '/' && text[i + 1] === '/') {\n hadSeparator = true;\n if (stopHere()) break;\n const nl = text.indexOf('\\n', i + 2);\n i = nl < 0 ? text.length : nl + 1;\n seenNewline = true;\n continue;\n }\n if (ch === '/' && text[i + 1] === '*') {\n hadSeparator = true;\n if (stopHere()) break;\n const end = text.indexOf('*/', i + 2);\n if (end < 0) {\n const msg = 'unterminated /* comment in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, i, options, true);\n i = text.length;\n } else {\n if (text.slice(i, end).includes('\\n')) seenNewline = true;\n i = end + 2;\n }\n continue;\n }\n if (ch === '/' && text[i + 1] !== '/') {\n hadSeparator = true;\n if (stopHere()) break;\n const end = text.indexOf('/', i + 1);\n if (end < 0) {\n const msg = 'unterminated / comment in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, i, options, true);\n i = text.length;\n } else {\n if (text.slice(i, end).includes('\\n')) seenNewline = true;\n i = end + 1;\n }\n continue;\n }\n if (ch === ',' && !seenComma) {\n hadSeparator = true;\n seenComma = true;\n commaOffset = i;\n i++;\n continue;\n }\n break;\n }\n return { offset: i, hadSeparator, commaOffset };\n}\n\n/** Map JSON.stringify `space` argument to ToCDNOptions.indent. */\nfunction resolveSpace(\n space: string | number | undefined\n): string | number | undefined {\n if (typeof space === 'number') {\n const n = Math.floor(Math.min(10, Math.max(0, space)));\n return n === 0 ? undefined : n;\n }\n if (typeof space === 'string') {\n const s = space.slice(0, 10);\n return s || undefined;\n }\n return undefined;\n}\n"],"mappings":";;;;AAIA,IAAM,IAAY,oCACZ,IAAY;AAElB,SAAS,EAAmB,GAAqB;CAC/C,IAAI,IAAM,EAAI;CACd,OAAO,IAAM,KAAK,EAAI,WAAW,IAAM,CAAC,MAAM,KAAM;CACpD,OAAO,EAAI,MAAM,GAAG,CAAG;AACzB;AAEA,SAAS,EACP,GACA,GACA,GACY;CAEZ,IAAM,IAAI,EAAmB,CAAG,CAAC,CAAC,YAAY,GAGxC,IAAM,EAAE,SAAS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,IACf,IAAY,IACZ,IAAc,GACd;GACA;EACF;EACA;CACF;CACA,OAAO;EAAE,QAAQ;EAAG;EAAc;CAAY;AAChD;AAGA,SAAS,EACP,GAC6B;CAC7B,IAAI,OAAO,KAAU,UAAU;EAC7B,IAAM,IAAI,KAAK,MAAM,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,CAAK,CAAC,CAAC;EACrD,OAAO,MAAM,IAAI,KAAA,IAAY;CAC/B;CACA,IAAI,OAAO,KAAU,UAEnB,OADU,EAAM,MAAM,GAAG,EAClB,KAAK,KAAA;AAGhB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["#defaults","#merge"],"sources":["../src/extensions/same.ts","../src/cbor.ts"],"sourcesContent":["/**\n * `same<<expr, expr, ...>>` app-sequence extension.\n *\n * Evaluates every item in the sequence to CBOR bytes and asserts that all\n * produce identical bytes. Returns the first item if all match.\n *\n * In strict mode a mismatch throws a `SyntaxError`. In lenient mode\n * (`strict: false`) a mismatch emits a `ParseWarning` and returns the first\n * item so parsing can continue.\n *\n * `same<<x>>` (single item) is a no-op assertion that always passes.\n *\n * The parsed result is wrapped in `CborAppSeqResult` so that `toCDN()` round-trips\n * the original `same<<...>>` notation. `toCBOR()` and `toJS()` delegate\n * transparently to the inner item; `appStrings: false` produces the resolved value.\n * The result is not directly `instanceof` the inner item's class.\n *\n * This extension is a testing/validation construct from the cabo/edn-abnf\n * corpus and is NOT part of draft-ietf-cbor-edn-literals. It is not included\n * in the default extension set. Add it explicitly:\n *\n * @example\n * import { same } from '@cbortech/cbor';\n * parseCDN(\"same<<b64'AA',h'00'>>\", { extensions: [same] }); // h'00'\n */\n\nimport type { CborExtension } from './types';\nimport type { CborItem } from '../ast/CborItem';\n\nfunction bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\n\n/**\n * Extension object for `same<<...>>`.\n * Pass to `parseCDN(..., { extensions: [same] })`.\n */\nexport const same: CborExtension = {\n appStringPrefixes: ['same'],\n preserveAppSeqSource: true,\n\n parseAppSequence(\n _prefix: string,\n items: CborItem[],\n onError?: (msg: string) => void\n ): CborItem {\n if (items.length === 0)\n throw new SyntaxError(`same<<...>> requires at least one item`);\n const first = items[0]!;\n const firstCbor = first.toCBOR();\n for (let i = 1; i < items.length; i++) {\n const otherCbor = items[i]!.toCBOR();\n if (!bytesEqual(firstCbor, otherCbor)) {\n const msg = `same<<...>>: item ${i} produces different CBOR bytes than item 0`;\n if (onError)\n onError(msg); // lenient: warn + return first item\n else throw new SyntaxError(msg);\n }\n }\n return first;\n },\n};\n\nexport default same;\n","import type { CborItem } from './ast/CborItem';\nimport type {\n CBOROptions,\n DecodeWarning,\n FromCBOROptions,\n FromCBORSeqOptions,\n FromCDNOptions,\n FromCDNSeqOptions,\n FromHexDumpOptions,\n FromJSOptions,\n ParseWarning,\n ToCBOROptions,\n ToCDNOptions,\n ToHexDumpOptions,\n ToJSOptions,\n ValidateOptions,\n ValidateResult,\n} from './types';\nimport { CBOR_OMIT } from './types';\nimport { decodeCBOR } from './cbor/decoder';\nimport { parseCDN } from './cdn/parser';\nimport { CdnSyntaxError } from './cdn/errors';\nimport { CddlMismatchError } from './cddl/errors';\nimport { compile as compileCDDL, CddlSchema } from './cddl/schema';\nimport type { ValidateOptions as CddlValidateOptions } from './cddl/validator';\nimport type { CddlValidationError, CddlValidationWarning } from './cddl/errors';\nimport { dt_as_Date as _dt_as_Date } from './extensions/dt';\nimport { fromJS as _fromJS, _applyReplacer } from './js/fromJS';\nimport { MapEntries as _MapEntries } from './mapEntries';\nimport { Simple as _Simple } from './simple';\nimport { CBOR_TAG, Tag as _Tag } from './tag';\n\n/**\n * Cache for schemas compiled from CDDL source text passed as the `cddl`\n * option, so repeated per-call use of the same string does not recompile.\n * Bounded: the oldest entry is evicted once the cap is reached.\n */\nconst compiledCddlCache = new Map<string, CddlSchema>();\nconst COMPILED_CDDL_CACHE_MAX = 64;\n\n/**\n * Resolve the `cddl` option to a compiled schema: pass compiled schemas\n * through, compile (and cache) CDDL source text.\n */\nfunction resolveCddl(\n cddl: CddlSchema | string | undefined\n): CddlSchema | undefined {\n if (typeof cddl !== 'string') return cddl;\n let schema = compiledCddlCache.get(cddl);\n if (!schema) {\n schema = compileCDDL(cddl);\n if (compiledCddlCache.size >= COMPILED_CDDL_CACHE_MAX) {\n compiledCddlCache.delete(compiledCddlCache.keys().next().value!);\n }\n compiledCddlCache.set(cddl, schema);\n }\n return schema;\n}\n\n/**\n * Validate an item against a resolved schema (if any) and throw\n * {@link CddlMismatchError} on mismatch.\n */\nfunction assertCddl(\n item: CborItem,\n schema: CddlSchema | undefined,\n validationOptions?: CddlValidateOptions\n): CborItem {\n if (schema) {\n const result = schema.validate(item, validationOptions);\n if (!result.valid) {\n throw new CddlMismatchError(result.errors, result.warnings);\n }\n }\n return item;\n}\n\n/**\n * When a CDDL schema is supplied via the `cddl` option, validate the item\n * against it and throw {@link CddlMismatchError} on mismatch.\n */\nfunction checkCddl(\n item: CborItem,\n options?: {\n cddl?: CddlSchema | string;\n cddlValidationOptions?: CddlValidateOptions;\n }\n): CborItem {\n return assertCddl(\n item,\n resolveCddl(options?.cddl),\n options?.cddlValidationOptions\n );\n}\n\n/**\n * Main facade class.\n *\n * Provides factory methods for constructing AST nodes from the three\n * supported input formats, and shortcut methods that mirror the\n * `JSON.parse` / `JSON.stringify` API.\n *\n * @example\n * // CBOR binary → AST → CBOR binary\n * const ast = CBOR.fromCBOR(bytes);\n * const reencoded = ast.toCBOR();\n *\n * @example\n * // JS value → CBOR binary (shortcut)\n * const bytes = CBOR.encode({ hello: 'world' });\n *\n * @example\n * // CBOR binary → JS value (shortcut)\n * const value = CBOR.decode(bytes);\n */\nexport class CBOR {\n /**\n * Sentinel returned from a replacer or reviver to omit the key/element from\n * the output. Use this instead of `undefined` when `undefinedOmits` is\n * `false` (the default) and you need to drop a specific entry.\n */\n static readonly OMIT: typeof CBOR_OMIT = CBOR_OMIT;\n\n /** Unique symbol used to attach a CBOR tag number to a JS value. */\n static readonly TAG: typeof CBOR_TAG = CBOR_TAG;\n\n /** Namespace for CBOR tag annotation utilities. */\n static readonly Tag: typeof _Tag = _Tag;\n\n /** Wrapper for CBOR simple values other than false/true/null/undefined. */\n static readonly Simple: typeof _Simple = _Simple;\n\n /** Array subclass used to preserve CBOR map entries, including duplicates. */\n static readonly MapEntries: typeof _MapEntries = _MapEntries;\n\n /** Extension that maps CDN dt/DT values to JavaScript Date objects. */\n static readonly dt_as_Date: typeof _dt_as_Date = _dt_as_Date;\n\n // ─── Instance API ───────────────────────────────────────────────────────────\n\n readonly #defaults: CBOROptions;\n\n /**\n * Create a reusable instance with default options applied to every method call.\n * Per-call options always override these defaults.\n *\n * @example\n * const cbor = new CBOR({ extensions: [CBOR.dt_as_Date] });\n * const obj = cbor.parse('{ \"dt\": DT\\'2024-01-01T00:00:00Z\\' }');\n * const text = cbor.stringify(obj);\n */\n constructor(defaults?: CBOROptions) {\n this.#defaults = defaults ?? {};\n }\n\n #merge<T extends object>(perCall?: T): CBOROptions & T {\n return { ...this.#defaults, ...(perCall ?? {}) } as CBOROptions & T;\n }\n\n fromCBOR(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions\n ): CborItem {\n const node = CBOR.fromCBOR(input, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n fromCDN(text: string, options?: FromCDNOptions): CborItem {\n const node = CBOR.fromCDN(text, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n /** @deprecated Use `fromCDN()` instead. */\n fromEDN(text: string, options?: FromCDNOptions): CborItem {\n return this.fromCDN(text, options);\n }\n\n fromJS(value: unknown, options?: FromJSOptions): CborItem {\n const node = CBOR.fromJS(value, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n fromHexDump(text: string, options?: FromHexDumpOptions): CborItem {\n const node = CBOR.fromHexDump(text, this.#merge(options));\n node._defaults = this.#defaults;\n return node;\n }\n\n *fromCBORSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions\n ): Generator<CborItem> {\n for (const item of CBOR.fromCBORSeq(input, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n *fromCDNSeq(text: string, options?: FromCDNSeqOptions): Generator<CborItem> {\n for (const item of CBOR.fromCDNSeq(text, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n *fromHexDumpSeq(\n text: string,\n options?: FromHexDumpOptions\n ): Generator<CborItem> {\n for (const item of CBOR.fromHexDumpSeq(text, this.#merge(options))) {\n item._defaults = this.#defaults;\n yield item;\n }\n }\n\n decode(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToJSOptions\n ): unknown {\n return CBOR.decode(input, this.#merge(options));\n }\n\n *decodeSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToJSOptions\n ): Generator<unknown> {\n yield* CBOR.decodeSeq(input, this.#merge(options));\n }\n\n *parseSeq(\n text: string,\n options?: FromCDNSeqOptions & ToJSOptions\n ): Generator<unknown> {\n yield* CBOR.parseSeq(text, this.#merge(options));\n }\n\n encode(value: unknown, options?: FromJSOptions & ToCBOROptions): Uint8Array {\n return CBOR.encode(value, this.#merge(options));\n }\n\n compile(\n text: string,\n options?: FromCDNSeqOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.compile(text, this.#merge(options));\n }\n\n decompile(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToCDNOptions\n ): string {\n return CBOR.decompile(input, this.#merge(options));\n }\n\n toHex(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToHexDumpOptions\n ): string {\n return CBOR.toHex(input, this.#merge(options));\n }\n\n fromHex(\n text: string,\n options?: FromHexDumpOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromHex(text, this.#merge(options));\n }\n\n /**\n * Check CBOR / CDN / hex dump input for well-formedness and validity,\n * without throwing.\n */\n validate(\n input: ArrayBufferView | ArrayBufferLike | string,\n options?: ValidateOptions\n ): ValidateResult {\n return CBOR.validate(input, this.#merge(options));\n }\n\n /** @deprecated Use `decompile()` instead. */\n cborToCborEdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return this.cborToCdn(input, options);\n }\n\n /** @deprecated Use `decompile()` instead. */\n cborToCdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n const merged = this.#merge(options);\n const node = CBOR.fromCBOR(input, merged);\n node._defaults = this.#defaults;\n return node.toCDN(merged);\n }\n\n /** @deprecated Use `compile()` instead. */\n cborEdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return this.cdnToCbor(text, options);\n }\n\n /** @deprecated Use `compile()` instead. */\n cdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n const merged = this.#merge(options);\n return CBOR.fromCDN(text, merged).toCBOR(merged);\n }\n\n parse(text: string): unknown;\n parse(\n text: string,\n reviver: (this: unknown, key: unknown, value: unknown) => unknown\n ): unknown;\n parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;\n parse(\n text: string,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (FromCDNOptions & ToJSOptions)\n ): unknown {\n if (typeof arg2 === 'function') {\n const merged = this.#merge<ToJSOptions>({ reviver: arg2 });\n return CBOR.fromCDN(text, merged).toJS(merged);\n }\n const merged = this.#merge(arg2);\n return CBOR.fromCDN(text, merged).toJS(merged);\n }\n\n stringify(value: unknown): string;\n stringify(\n value: unknown,\n replacer:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null,\n space?: string | number\n ): string;\n stringify(value: unknown, options: FromJSOptions & ToCDNOptions): string;\n stringify(\n value: unknown,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null\n | (FromJSOptions & ToCDNOptions),\n arg3?: string | number\n ): string {\n if (\n typeof arg2 === 'function' ||\n Array.isArray(arg2) ||\n arg2 === null ||\n (arg2 === undefined && arg3 !== undefined)\n ) {\n const opts: FromJSOptions & ToCDNOptions = {\n ...(this.#defaults as FromJSOptions & ToCDNOptions),\n };\n if (arg2 === null) {\n opts.replacer = undefined;\n } else if (typeof arg2 === 'function' || Array.isArray(arg2)) {\n opts.replacer = arg2;\n }\n if (arg3 !== undefined) opts.indent = resolveSpace(arg3);\n return CBOR.stringify(value, opts);\n }\n return CBOR.stringify(value, this.#merge(arg2 ?? undefined));\n }\n\n format(text: string, options?: FromCDNOptions & ToCDNOptions): string {\n return CBOR.format(text, this.#merge(options));\n }\n\n // ─── Factory methods ────────────────────────────────────────────────────────\n\n /** Decode CBOR binary data into an AST node. */\n static fromCBOR(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions\n ): CborItem {\n return checkCddl(decodeCBOR(input, options), options);\n }\n\n /** Parse a CDN text string into an AST node. */\n static fromCDN(text: string, options?: FromCDNOptions): CborItem {\n return checkCddl(parseCDN(text, options), options);\n }\n\n /**\n * Parse a CDN text string into an AST node.\n *\n * @deprecated Use `fromCDN()` instead.\n */\n static fromEDN(text: string, options?: FromCDNOptions): CborItem {\n return CBOR.fromCDN(text, options);\n }\n\n /** アノテーション付き hex dump テキストから CBOR Sequence を item ごとにデコードするジェネレータ。 */\n static *fromHexDumpSeq(\n text: string,\n options?: FromHexDumpOptions\n ): Generator<CborItem> {\n const bytes: number[] = [];\n const uncommented = stripHexDumpComments(text);\n const tokens = uncommented.trim().split(/\\s+/).filter(Boolean);\n for (const token of tokens) {\n if (/^[0-9A-Fa-f]{2}$/.test(token)) {\n bytes.push(parseInt(token, 16));\n } else if (/^[0-9A-Fa-f]+$/.test(token) && token.length % 2 === 0) {\n for (let i = 0; i < token.length; i += 2)\n bytes.push(parseInt(token.slice(i, i + 2), 16));\n } else {\n throw new SyntaxError(\n `Invalid hex token in dump: ${JSON.stringify(token)}`\n );\n }\n }\n yield* CBOR.fromCBORSeq(new Uint8Array(bytes), options);\n }\n\n /** CBOR Sequence (RFC 8742) を item ごとにデコードするジェネレータ。 */\n static *fromCBORSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions\n ): Generator<CborItem> {\n // Resolve up front so invalid CDDL source text throws even when the\n // sequence turns out to be empty.\n const cddlSchema = resolveCddl(options?.cddl);\n const bytes =\n input instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== 'undefined' &&\n input instanceof SharedArrayBuffer)\n ? new Uint8Array(input)\n : new Uint8Array(\n (input as ArrayBufferView).buffer,\n (input as ArrayBufferView).byteOffset,\n (input as ArrayBufferView).byteLength\n );\n let offset = 0;\n while (offset < bytes.byteLength) {\n const item = decodeCBOR(bytes, {\n ...options,\n offset,\n allowTrailing: true,\n });\n yield assertCddl(item, cddlSchema, options?.cddlValidationOptions);\n offset = item.end!;\n }\n }\n\n /**\n * CDN テキストの複数 item を 1 つずつパースするジェネレータ。\n *\n * `preserveComments` が有効な場合、item 間のコメントは次の item の\n * leading コメントとして、item と同じ行にあるコメントはその item の\n * trailing コメントとして付与される。最後の item の後の行にだけ\n * コメントが残る場合、そのコメントはどの item にも属さず破棄される。\n */\n static *fromCDNSeq(\n text: string,\n options?: FromCDNSeqOptions\n ): Generator<CborItem> {\n // Resolve up front so invalid CDDL source text throws even when the\n // sequence turns out to be empty.\n const cddlSchema = resolveCddl(options?.cddl);\n const preserve = !!options?.preserveComments;\n let offset = 0;\n let isFirst = true;\n while (true) {\n const {\n offset: next,\n hadSeparator,\n commaOffset,\n } = skipCDNSeparator(\n text,\n offset,\n options,\n preserve ? (isFirst ? 'all' : 'after-newline') : 'none'\n );\n // Leading comma: comma before the first item (including comma-only input).\n // Checked before the EOF break so that \",\" alone is also caught.\n // Trailing comma is valid per ABNF SOC = S [\",\" S] and is silently accepted.\n if (isFirst && commaOffset >= 0) {\n const msg = 'leading comma in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, commaOffset, options);\n }\n if (next >= text.length) break;\n // Stopped at a comment that should lead the next item: make sure an\n // item actually follows. If only comments remain, we are done (the\n // remaining comments belong to no item and are dropped, matching the\n // behaviour of `preserveComments: false`).\n if (preserve && isCDNCommentStart(text, next)) {\n const lookahead = skipCDNSeparator(text, next, options);\n if (lookahead.offset >= text.length) break;\n }\n if (!isFirst && !hadSeparator) {\n const msg =\n 'CDN sequence items must be separated by whitespace, comma, or comment';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, next, options);\n }\n offset = next;\n let item: CborItem;\n try {\n // _skipRS: true causes the tokenizer to treat RS (U+001E, RFC 7464) as\n // whitespace, preventing it from corrupting string-literal contents via\n // a global text replacement.\n item = parseCDN(text, {\n ...options,\n offset,\n allowTrailing: true,\n _skipRS: true,\n } as FromCDNOptions);\n } catch (e) {\n if (options?.strict !== false) throw e;\n emitCDNSeqWarning(\n e instanceof Error ? e.message : String(e),\n offset,\n options,\n true,\n e instanceof CdnSyntaxError ? e : undefined\n );\n break;\n }\n yield assertCddl(item, cddlSchema, options?.cddlValidationOptions);\n offset = item.end!;\n isFirst = false;\n }\n }\n\n /** Convert a JavaScript value into an AST node. */\n static fromJS(value: unknown, options?: FromJSOptions): CborItem {\n return checkCddl(_fromJS(value, options), options);\n }\n\n /**\n * Parse an annotated hex dump (as produced by {@link CborItem#toHexDump})\n * into an AST node.\n *\n * Each line is expected to have the form:\n * `[whitespace] HH [HH …] -- comment`\n * `[whitespace] HH [HH …] # comment`\n * `[whitespace] HH [HH …] // comment`\n * Block comments may also be written as `/ comment /` or `/* comment *\\/`.\n * Lines with no hex content before the comment marker are ignored.\n */\n static fromHexDump(text: string, options?: FromHexDumpOptions): CborItem {\n const bytes: number[] = [];\n const uncommented = stripHexDumpComments(text);\n const tokens = uncommented.trim().split(/\\s+/).filter(Boolean);\n for (const token of tokens) {\n if (/^[0-9A-Fa-f]{2}$/.test(token)) {\n bytes.push(parseInt(token, 16));\n } else if (/^[0-9A-Fa-f]+$/.test(token) && token.length % 2 === 0) {\n for (let i = 0; i < token.length; i += 2)\n bytes.push(parseInt(token.slice(i, i + 2), 16));\n } else {\n throw new SyntaxError(\n `Invalid hex token in dump: ${JSON.stringify(token)}`\n );\n }\n }\n return checkCddl(decodeCBOR(new Uint8Array(bytes), options), options);\n }\n\n // ─── Shortcut API ───────────────────────────────────────────────────────────\n\n /** Decode CBOR binary data directly to a JavaScript value. */\n static decode(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToJSOptions\n ): unknown {\n return CBOR.fromCBOR(input, options).toJS(options);\n }\n\n /** Decode a CBOR Sequence (RFC 8742), yielding each item as a JavaScript value. */\n static *decodeSeq(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToJSOptions\n ): Generator<unknown> {\n for (const item of CBOR.fromCBORSeq(input, options)) {\n yield item.toJS(options);\n }\n }\n\n /** Parse a CDN Sequence text string, yielding each item as a JavaScript value. */\n static *parseSeq(\n text: string,\n options?: FromCDNSeqOptions & ToJSOptions\n ): Generator<unknown> {\n for (const item of CBOR.fromCDNSeq(text, options)) {\n yield item.toJS(options);\n }\n }\n\n /** Encode a JavaScript value directly to CBOR binary data. */\n static encode(\n value: unknown,\n options?: FromJSOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromJS(value, options).toCBOR(options);\n }\n\n /**\n * Compile a CDN text string to CBOR binary data.\n * Multi-item CDN Sequences produce a CBOR Sequence (RFC 8742): concatenated items.\n */\n static compile(\n text: string,\n options?: FromCDNSeqOptions & ToCBOROptions\n ): Uint8Array {\n const byteArrays = [...CBOR.fromCDNSeq(text, options)].map((item) =>\n item.toCBOR(options)\n );\n const total = byteArrays.reduce((s, b) => s + b.length, 0);\n const result = new Uint8Array(total);\n let off = 0;\n for (const b of byteArrays) {\n result.set(b, off);\n off += b.length;\n }\n return result;\n }\n\n /**\n * Decompile CBOR binary data to a CDN text string.\n * CBOR Sequences (RFC 8742) produce multi-item CDN output, with items separated by newlines.\n */\n static decompile(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToCDNOptions\n ): string {\n return [...CBOR.fromCBORSeq(input, options)]\n .map((item) => item.toCDN(options))\n .join('\\n');\n }\n\n /**\n * Convert CBOR binary data to an annotated hex dump string.\n * CBOR Sequences (RFC 8742) produce one dump per item, separated by newlines.\n */\n static toHex(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBORSeqOptions & ToHexDumpOptions\n ): string {\n return [...CBOR.fromCBORSeq(input, options)]\n .map((item) => item.toHexDump(options))\n .join('\\n');\n }\n\n /**\n * Parse an annotated hex dump string to CBOR binary data.\n * Multi-item dumps produce a CBOR Sequence (RFC 8742): concatenated items.\n */\n static fromHex(\n text: string,\n options?: FromHexDumpOptions & ToCBOROptions\n ): Uint8Array {\n const byteArrays = [...CBOR.fromHexDumpSeq(text, options)].map((item) =>\n item.toCBOR(options)\n );\n const total = byteArrays.reduce((s, b) => s + b.length, 0);\n const result = new Uint8Array(total);\n let off = 0;\n for (const b of byteArrays) {\n result.set(b, off);\n off += b.length;\n }\n return result;\n }\n\n /**\n * Check CBOR / CDN / hex dump input for well-formedness and validity,\n * without throwing.\n *\n * Decodes/parses the input as a sequence (CBOR Sequence per RFC 8742, or a\n * CDN Sequence) in non-strict mode: recoverable violations are collected\n * into `warnings` instead of stopping decoding, while malformed input\n * (e.g. truncated data, hard syntax errors — including a CDN Sequence\n * abandoned after a hard syntax error) is reported via `error`.\n * Informational hints about optional extensions that aren't registered\n * (`ParseWarning.hint`) are not treated as violations; they are collected\n * separately into `hints`.\n *\n * @example\n * const result = CBOR.validate(bytes);\n * if (!result.valid) {\n * if (result.error) console.error(`invalid: ${result.error.message}`);\n * for (const w of result.warnings) console.warn(w.message);\n * }\n *\n * @example\n * // CDN text input\n * CBOR.validate('{\"a\": 1}', { type: 'cdn' });\n *\n * @example\n * // Schema validation with a compiled CDDL schema\n * import { CDDL } from '@cbortech/cbor/cddl';\n * const schema = CDDL.compile('person = { name: tstr, ? age: uint }');\n * const result = CBOR.validate('{\"name\": \"kudo\"}', { type: 'cdn', cddl: schema });\n * result.valid; // true\n * result.cddlErrors; // []\n */\n static validate(\n input: ArrayBufferView | ArrayBufferLike | string,\n options?: ValidateOptions\n ): ValidateResult {\n const warnings: (DecodeWarning | ParseWarning)[] = [];\n const hints: ParseWarning[] = [];\n let fatal: ParseWarning | undefined;\n // `cddl` is deliberately not forwarded to the Seq generators: a mismatch\n // must be collected below, not thrown from inside the generator.\n const seqOptions = {\n strict: false,\n extensions: options?.extensions,\n builtinExtensions: options?.builtinExtensions,\n onWarning: (w: DecodeWarning | ParseWarning) => {\n if ('hint' in w && w.hint) {\n hints.push(w);\n return;\n }\n if ('fatal' in w && w.fatal) {\n fatal = w;\n return;\n }\n warnings.push(w);\n },\n };\n const schema = resolveCddl(options?.cddl);\n const cddlErrors: CddlValidationError[] = [];\n const cddlWarnings: CddlValidationWarning[] = [];\n const checkItem = (item: CborItem) => {\n if (!schema) return;\n const result = schema.validate(item, options?.cddlValidationOptions);\n cddlErrors.push(...result.errors);\n if (result.warnings) cddlWarnings.push(...result.warnings);\n };\n const cddlFields = schema ? { cddlErrors, cddlWarnings } : {};\n let count = 0;\n try {\n const type = options?.type ?? 'cbor';\n if (type === 'cdn') {\n const cdnOptions: FromCDNSeqOptions = {\n ...seqOptions,\n unresolvedExtension: options?.unresolvedExtension,\n };\n for (const item of CBOR.fromCDNSeq(input as string, cdnOptions)) {\n count++;\n checkItem(item);\n }\n } else if (type === 'hex') {\n for (const item of CBOR.fromHexDumpSeq(input as string, seqOptions)) {\n count++;\n checkItem(item);\n }\n } else {\n for (const item of CBOR.fromCBORSeq(\n input as ArrayBufferView | ArrayBufferLike,\n seqOptions\n )) {\n count++;\n checkItem(item);\n }\n }\n } catch (err) {\n return {\n valid: false,\n count,\n warnings,\n hints,\n error: err instanceof Error ? err : new Error(String(err)),\n ...cddlFields,\n };\n }\n if (fatal) {\n // Prefer the original syntax error (position fields intact); the\n // unterminated-comment fatals are emitted without one, so rebuild a\n // CdnSyntaxError carrying at least the warning's offset.\n const error =\n fatal.cause instanceof Error\n ? fatal.cause\n : new CdnSyntaxError(fatal.message, { offset: fatal.offset });\n return { valid: false, count, warnings, hints, error, ...cddlFields };\n }\n return {\n valid: warnings.length === 0 && cddlErrors.length === 0,\n count,\n warnings,\n hints,\n ...cddlFields,\n };\n }\n\n /**\n * Convert CBOR binary data directly to a CDN text string.\n *\n * @deprecated Use `CBOR.decompile()` instead.\n */\n static cborToCdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return CBOR.fromCBOR(input, options).toCDN(options);\n }\n\n /** @deprecated Use `CBOR.decompile()` instead. */\n static cborToCborEdn(\n input: ArrayBufferView | ArrayBufferLike,\n options?: FromCBOROptions & ToCDNOptions\n ): string {\n return CBOR.fromCBOR(input, options).toCDN(options);\n }\n\n /**\n * Convert a CDN text string directly to CBOR binary data.\n *\n * @deprecated Use `CBOR.compile()` instead.\n */\n static cdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromCDN(text, options).toCBOR(options);\n }\n\n /** @deprecated Use `CBOR.compile()` instead. */\n static cborEdnToCbor(\n text: string,\n options?: FromCDNOptions & ToCBOROptions\n ): Uint8Array {\n return CBOR.fromCDN(text, options).toCBOR(options);\n }\n\n /**\n * Parse a CDN text string directly to a JavaScript value.\n *\n * Accepts either a JSON-compatible `reviver` function as the second argument,\n * or a plain options object (existing API).\n *\n * When a `reviver` is supplied it is applied bottom-up after the CDN text has\n * been parsed and converted to a JS value, matching the semantics of\n * `JSON.parse(text, reviver)`.\n *\n * Note: CBOR-specific value types such as `bigint` are passed to the reviver\n * as-is; the reviver is responsible for handling them.\n */\n static parse(text: string): unknown;\n static parse(\n text: string,\n reviver: (this: unknown, key: unknown, value: unknown) => unknown\n ): unknown;\n static parse(text: string, options: FromCDNOptions & ToJSOptions): unknown;\n static parse(\n text: string,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (FromCDNOptions & ToJSOptions)\n ): unknown {\n if (typeof arg2 === 'function') {\n return CBOR.fromCDN(text).toJS({ reviver: arg2 });\n }\n return CBOR.fromCDN(text, arg2).toJS(arg2);\n }\n\n /**\n * Serialize a JavaScript value directly to a CDN text string.\n *\n * Accepts either JSON-compatible `replacer` + `space` arguments, or a plain\n * options object (existing API).\n *\n * - `replacer` may be a function (transforms each key/value before encoding)\n * or an array of strings/numbers (allowlist of object keys to include).\n * Pass `null` to skip filtering.\n * - `space` controls indentation, mapping to `ToCDNOptions.indent`.\n * Numbers are clamped to `[0, 10]`; strings are truncated to 10 characters.\n */\n static stringify(value: unknown): string;\n static stringify(\n value: unknown,\n replacer:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null,\n space?: string | number\n ): string;\n static stringify(\n value: unknown,\n options: FromJSOptions & ToCDNOptions\n ): string;\n static stringify(\n value: unknown,\n arg2?:\n | ((this: unknown, key: unknown, value: unknown) => unknown)\n | (string | number)[]\n | null\n | (FromJSOptions & ToCDNOptions),\n arg3?: string | number\n ): string {\n if (\n typeof arg2 === 'function' ||\n Array.isArray(arg2) ||\n arg2 === null ||\n (arg2 === undefined && arg3 !== undefined)\n ) {\n const replacer =\n typeof arg2 === 'function' || Array.isArray(arg2) ? arg2 : undefined;\n const indent = resolveSpace(arg3);\n if (replacer) {\n // Mirror JSON.stringify: if the replacer drops the root, return undefined.\n const replaced = _applyReplacer(value, replacer);\n if (replaced === undefined || replaced === CBOR_OMIT)\n return undefined as unknown as string;\n return _fromJS(replaced).toCDN(\n indent !== undefined ? { indent } : undefined\n );\n }\n return _fromJS(value).toCDN(\n indent !== undefined ? { indent } : undefined\n );\n }\n // Options form: also mirror JSON.stringify root-drop semantics.\n const opts = arg2 as (FromJSOptions & ToCDNOptions) | undefined;\n if (opts?.replacer) {\n const replaced = _applyReplacer(\n value,\n opts.replacer,\n opts.extensions,\n opts.undefinedOmits,\n opts.builtinExtensions\n );\n if (replaced === undefined || replaced === CBOR_OMIT)\n return undefined as unknown as string;\n const { replacer: _r, ...restFromJS } = opts;\n return checkCddl(\n _fromJS(\n replaced,\n Object.keys(restFromJS).length > 0\n ? (restFromJS as FromJSOptions)\n : undefined\n ),\n opts\n ).toCDN(opts);\n }\n return checkCddl(\n _fromJS(value, opts as FromJSOptions | undefined),\n opts\n ).toCDN(opts);\n }\n\n /** Normalize a CDN text string by parsing and re-serializing it. */\n static format(text: string, options?: FromCDNOptions & ToCDNOptions): string {\n return CBOR.fromCDN(text, options).toCDN(options);\n }\n}\n\nfunction stripHexDumpComments(text: string): string {\n let out = '';\n let i = 0;\n\n while (i < text.length) {\n const ch = text[i];\n const next = text[i + 1] ?? '';\n\n if (ch === '-' && next === '-') {\n i = skipLineComment(text, i + 2);\n out += ' ';\n continue;\n }\n\n if (ch === '—') {\n i = skipLineComment(text, i + 1);\n out += ' ';\n continue;\n }\n\n if (ch === '#') {\n i = skipLineComment(text, i + 1);\n out += ' ';\n continue;\n }\n\n if (ch === '/' && next === '/') {\n i = skipLineComment(text, i + 2);\n out += ' ';\n continue;\n }\n\n if (ch === '/' && next === '*') {\n const end = text.indexOf('*/', i + 2);\n if (end < 0) throw new SyntaxError('Unterminated comment in hex dump');\n out += whitespaceLike(text.slice(i, end + 2));\n i = end + 2;\n continue;\n }\n\n if (ch === '/') {\n const end = text.indexOf('/', i + 1);\n if (end < 0) throw new SyntaxError('Unterminated comment in hex dump');\n out += whitespaceLike(text.slice(i, end + 1));\n i = end + 1;\n continue;\n }\n\n out += ch;\n i++;\n }\n\n return out;\n}\n\nfunction skipLineComment(text: string, start: number): number {\n const end = text.indexOf('\\n', start);\n return end < 0 ? text.length : end;\n}\n\nfunction whitespaceLike(text: string): string {\n return text.replace(/[^\\r\\n]/g, ' ');\n}\n\n// ─── Module-scope helper ─────────────────────────────────────────────────────\n\nfunction emitCDNSeqWarning(\n msg: string,\n fallbackOffset: number,\n options: FromCDNSeqOptions | undefined,\n fatal?: boolean,\n cause?: CdnSyntaxError\n): void {\n const offset = cause?.offset ?? fallbackOffset;\n const w: ParseWarning = { message: msg, offset };\n if (fatal) w.fatal = true;\n if (cause) w.cause = cause;\n if (cause?.offset !== undefined) {\n w.line = cause.line;\n w.column = cause.column;\n w.endOffset = cause.endOffset;\n }\n if (options?.onWarning) options.onWarning(w);\n else if (!options?.silent)\n console.warn(`CDN sequence warning at offset ${offset}: ${msg}`);\n}\n\n/** Whether `text[i]` starts a CDN comment (`#`, `//`, `/* … *\\/`, or `/ … /`). */\nfunction isCDNCommentStart(text: string, i: number): boolean {\n const ch = text[i];\n return ch === '#' || ch === '/';\n}\n\n/**\n * CDN sequence の item 間にある空白・コメント・省略可能なカンマを読み飛ばし、\n * 次の item が始まる文字位置と、何らかの separator が存在したかどうかを返す。\n * 未終端のブロックコメントは strict モードでは throw し、\n * strict: false の場合は警告を emit して末尾まで読み飛ばす。\n *\n * `stopAtComments` は `preserveComments` 有効時にコメントを次の item の\n * leading コメントとして残すためのモード:\n * - `'none'`: コメントも読み飛ばす(従来動作)\n * - `'all'`: 最初のコメントで停止する(先頭 item 用)\n * - `'after-newline'`: 改行より後のコメントで停止する。直前 item と同じ行の\n * コメントはその item の trailing コメントとして既に付与されているため読み飛ばす。\n */\nfunction skipCDNSeparator(\n text: string,\n from: number,\n options: FromCDNSeqOptions | undefined,\n stopAtComments: 'none' | 'after-newline' | 'all' = 'none'\n): { offset: number; hadSeparator: boolean; commaOffset: number } {\n let i = from;\n let hadSeparator = false;\n let seenComma = false;\n let seenNewline = false;\n let commaOffset = -1;\n const stopHere = (): boolean =>\n stopAtComments === 'all' ||\n (stopAtComments === 'after-newline' && seenNewline);\n while (i < text.length) {\n const ch = text[i];\n if (ch === ' ' || ch === '\\t' || ch === '\\r' || ch === '\\x1e') {\n hadSeparator = true;\n i++;\n continue;\n }\n if (ch === '\\n') {\n hadSeparator = true;\n seenNewline = true;\n i++;\n continue;\n }\n if (ch === '#') {\n hadSeparator = true;\n if (stopHere()) break;\n const nl = text.indexOf('\\n', i + 1);\n i = nl < 0 ? text.length : nl + 1;\n seenNewline = true;\n continue;\n }\n if (ch === '/' && text[i + 1] === '/') {\n hadSeparator = true;\n if (stopHere()) break;\n const nl = text.indexOf('\\n', i + 2);\n i = nl < 0 ? text.length : nl + 1;\n seenNewline = true;\n continue;\n }\n if (ch === '/' && text[i + 1] === '*') {\n hadSeparator = true;\n if (stopHere()) break;\n const end = text.indexOf('*/', i + 2);\n if (end < 0) {\n const msg = 'unterminated /* comment in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, i, options, true);\n i = text.length;\n } else {\n if (text.slice(i, end).includes('\\n')) seenNewline = true;\n i = end + 2;\n }\n continue;\n }\n if (ch === '/' && text[i + 1] !== '/') {\n hadSeparator = true;\n if (stopHere()) break;\n const end = text.indexOf('/', i + 1);\n if (end < 0) {\n const msg = 'unterminated / comment in CDN sequence';\n if (options?.strict !== false) throw new SyntaxError(msg);\n emitCDNSeqWarning(msg, i, options, true);\n i = text.length;\n } else {\n if (text.slice(i, end).includes('\\n')) seenNewline = true;\n i = end + 1;\n }\n continue;\n }\n if (ch === ',' && !seenComma) {\n hadSeparator = true;\n seenComma = true;\n commaOffset = i;\n i++;\n continue;\n }\n break;\n }\n return { offset: i, hadSeparator, commaOffset };\n}\n\n/** Map JSON.stringify `space` argument to ToCDNOptions.indent. */\nfunction resolveSpace(\n space: string | number | undefined\n): string | number | undefined {\n if (typeof space === 'number') {\n const n = Math.floor(Math.min(10, Math.max(0, space)));\n return n === 0 ? undefined : n;\n }\n if (typeof space === 'string') {\n const s = space.slice(0, 10);\n return s || undefined;\n }\n return undefined;\n}\n"],"mappings":";;;;AA6BA,SAAS,EAAW,GAAe,GAAw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