@cbortech/cbor 0.26.8 → 0.27.0

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.
Files changed (54) hide show
  1. package/README.ja.md +120 -28
  2. package/README.md +121 -29
  3. package/dist/ast/CborAppSeqResult.d.ts +22 -0
  4. package/dist/ast/CborByteString.d.ts +16 -0
  5. package/dist/ast/CborEmbeddedCBOR.d.ts +1 -1
  6. package/dist/ast/CborFloat.d.ts +1 -1
  7. package/dist/ast/CborIndefiniteByteString.d.ts +24 -0
  8. package/dist/ast/CborIndefiniteTextString.d.ts +16 -0
  9. package/dist/ast/CborItem.d.ts +44 -4
  10. package/dist/ast/CborTag.d.ts +27 -0
  11. package/dist/ast/CborTextString.d.ts +2 -1
  12. package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
  13. package/dist/ast/index.cjs +1 -1
  14. package/dist/ast/index.js +2 -2
  15. package/dist/cddl/index.cjs +1 -1
  16. package/dist/cddl/index.js +1 -1
  17. package/dist/cdn/index.cjs +2 -2
  18. package/dist/cdn/index.cjs.map +1 -1
  19. package/dist/cdn/index.js +18 -18
  20. package/dist/cdn/index.js.map +1 -1
  21. package/dist/cdn/serialize-utils.d.ts +207 -8
  22. package/dist/cdn/tokenizer.d.ts +12 -11
  23. package/dist/extensions/builtins.d.ts +5 -5
  24. package/dist/extensions/cri.d.ts +2 -2
  25. package/dist/extensions/ip.d.ts +1 -1
  26. package/dist/extensions/types.d.ts +4 -4
  27. package/dist/index.cjs +3 -3
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.js +158 -158
  30. package/dist/index.js.map +1 -1
  31. package/dist/mapEntries-C1f7G0AM.cjs +13 -0
  32. package/dist/mapEntries-C1f7G0AM.cjs.map +1 -0
  33. package/dist/{mapEntries-Ci_dppP6.js → mapEntries-CvLdiN0h.js} +1362 -1219
  34. package/dist/mapEntries-CvLdiN0h.js.map +1 -0
  35. package/dist/{schema-y8G5mDIS.js → schema-CNfrVRYp.js} +294 -294
  36. package/dist/{schema-y8G5mDIS.js.map → schema-CNfrVRYp.js.map} +1 -1
  37. package/dist/schema-iXpYtKQl.cjs +63 -0
  38. package/dist/{schema-DgnkH0P6.cjs.map → schema-iXpYtKQl.cjs.map} +1 -1
  39. package/dist/{tokenizer-N-vAvRdj.js → serialize-utils-BuIZPaUc.js} +626 -358
  40. package/dist/serialize-utils-BuIZPaUc.js.map +1 -0
  41. package/dist/serialize-utils-CjTqQivB.cjs +37 -0
  42. package/dist/serialize-utils-CjTqQivB.cjs.map +1 -0
  43. package/dist/types.d.ts +235 -58
  44. package/dist/utils/base64.d.ts +1 -1
  45. package/dist/utils/hexfloat.d.ts +1 -1
  46. package/dist/utils/strip-comments.d.ts +1 -1
  47. package/package.json +8 -6
  48. package/dist/mapEntries-BJzyBUH5.cjs +0 -13
  49. package/dist/mapEntries-BJzyBUH5.cjs.map +0 -1
  50. package/dist/mapEntries-Ci_dppP6.js.map +0 -1
  51. package/dist/schema-DgnkH0P6.cjs +0 -63
  52. package/dist/tokenizer-BD08xbyd.cjs +0 -36
  53. package/dist/tokenizer-BD08xbyd.cjs.map +0 -1
  54. package/dist/tokenizer-N-vAvRdj.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,45 +1,45 @@
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";
1
+ import { D as e, I as t } from "./serialize-utils-BuIZPaUc.js";
2
+ import { n, s as r } from "./schema-CNfrVRYp.js";
3
+ import { B as i, H as a, L as o, R as s, S 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, x as T, z as E } from "./mapEntries-CvLdiN0h.js";
4
4
  //#region src/extensions/same.ts
5
- function E(e, t) {
5
+ function D(e, t) {
6
6
  if (e.length !== t.length) return !1;
7
7
  for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
8
8
  return !0;
9
9
  }
10
- var D = {
10
+ var O = {
11
11
  appStringPrefixes: ["same"],
12
12
  preserveAppSeqSource: !0,
13
13
  parseAppSequence(e, t, n) {
14
14
  if (t.length === 0) throw SyntaxError("same<<...>> requires at least one item");
15
15
  let r = t[0], i = r.toCBOR();
16
- for (let e = 1; e < t.length; e++) if (!E(i, t[e].toCBOR())) {
16
+ for (let e = 1; e < t.length; e++) if (!D(i, t[e].toCBOR())) {
17
17
  let t = `same<<...>>: item ${e} produces different CBOR bytes than item 0`;
18
18
  if (n) n(t);
19
19
  else throw SyntaxError(t);
20
20
  }
21
21
  return r;
22
22
  }
23
- }, O = /* @__PURE__ */ new Map(), k = 64;
24
- function A(e) {
23
+ }, k = /* @__PURE__ */ new Map(), A = 64;
24
+ function j(e) {
25
25
  if (typeof e != "string") return 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;
26
+ let t = k.get(e);
27
+ return t || (t = n(e), k.size >= A && k.delete(k.keys().next().value), k.set(e, t)), t;
28
28
  }
29
- function j(e, t, r) {
29
+ function M(e, t, n) {
30
30
  if (t) {
31
- let i = t.validate(e, r);
32
- if (!i.valid) throw new n(i.errors, i.warnings);
31
+ let i = t.validate(e, n);
32
+ if (!i.valid) throw new r(i.errors, i.warnings);
33
33
  }
34
34
  return e;
35
35
  }
36
- function M(e, t) {
37
- return j(e, A(t?.cddl), t?.cddlValidationOptions);
36
+ function N(e, t) {
37
+ return M(e, j(t?.cddl), t?.cddlValidationOptions);
38
38
  }
39
- var N = class t {
40
- static OMIT = T;
41
- static TAG = r;
42
- static Tag = a;
39
+ var P = class n {
40
+ static OMIT = s;
41
+ static TAG = E;
42
+ static Tag = l;
43
43
  static Simple = o;
44
44
  static MapEntries = C;
45
45
  static dt_as_Date = _;
@@ -53,191 +53,191 @@ var N = class t {
53
53
  ...e ?? {}
54
54
  };
55
55
  }
56
- fromCBOR(e, n) {
57
- let r = t.fromCBOR(e, this.#t(n));
56
+ fromCBOR(e, t) {
57
+ let r = n.fromCBOR(e, this.#t(t));
58
58
  return r._defaults = this.#e, r;
59
59
  }
60
- fromCDN(e, n) {
61
- let r = t.fromCDN(e, this.#t(n));
60
+ fromCDN(e, t) {
61
+ let r = n.fromCDN(e, this.#t(t));
62
62
  return r._defaults = this.#e, r;
63
63
  }
64
64
  fromEDN(e, t) {
65
65
  return this.fromCDN(e, t);
66
66
  }
67
- fromJS(e, n) {
68
- let r = t.fromJS(e, this.#t(n));
67
+ fromJS(e, t) {
68
+ let r = n.fromJS(e, this.#t(t));
69
69
  return r._defaults = this.#e, r;
70
70
  }
71
- fromHexDump(e, n) {
72
- let r = t.fromHexDump(e, this.#t(n));
71
+ fromHexDump(e, t) {
72
+ let r = n.fromHexDump(e, this.#t(t));
73
73
  return r._defaults = this.#e, r;
74
74
  }
75
- *fromCBORSeq(e, n) {
76
- for (let r of t.fromCBORSeq(e, this.#t(n))) r._defaults = this.#e, yield r;
75
+ *fromCBORSeq(e, t) {
76
+ for (let r of n.fromCBORSeq(e, this.#t(t))) r._defaults = this.#e, yield r;
77
77
  }
78
- *fromCDNSeq(e, n) {
79
- for (let r of t.fromCDNSeq(e, this.#t(n))) r._defaults = this.#e, yield r;
78
+ *fromCDNSeq(e, t) {
79
+ for (let r of n.fromCDNSeq(e, this.#t(t))) r._defaults = this.#e, yield r;
80
80
  }
81
- *fromHexDumpSeq(e, n) {
82
- for (let r of t.fromHexDumpSeq(e, this.#t(n))) r._defaults = this.#e, yield r;
81
+ *fromHexDumpSeq(e, t) {
82
+ for (let r of n.fromHexDumpSeq(e, this.#t(t))) r._defaults = this.#e, yield r;
83
83
  }
84
- decode(e, n) {
85
- return t.decode(e, this.#t(n));
84
+ decode(e, t) {
85
+ return n.decode(e, this.#t(t));
86
86
  }
87
- *decodeSeq(e, n) {
88
- yield* t.decodeSeq(e, this.#t(n));
87
+ *decodeSeq(e, t) {
88
+ yield* n.decodeSeq(e, this.#t(t));
89
89
  }
90
- *parseSeq(e, n) {
91
- yield* t.parseSeq(e, this.#t(n));
90
+ *parseSeq(e, t) {
91
+ yield* n.parseSeq(e, this.#t(t));
92
92
  }
93
- encode(e, n) {
94
- return t.encode(e, this.#t(n));
93
+ encode(e, t) {
94
+ return n.encode(e, this.#t(t));
95
95
  }
96
- compile(e, n) {
97
- return t.compile(e, this.#t(n));
96
+ compile(e, t) {
97
+ return n.compile(e, this.#t(t));
98
98
  }
99
- decompile(e, n) {
100
- return t.decompile(e, this.#t(n));
99
+ decompile(e, t) {
100
+ return n.decompile(e, this.#t(t));
101
101
  }
102
- toHex(e, n) {
103
- return t.toHex(e, this.#t(n));
102
+ toHex(e, t) {
103
+ return n.toHex(e, this.#t(t));
104
104
  }
105
- fromHex(e, n) {
106
- return t.fromHex(e, this.#t(n));
105
+ fromHex(e, t) {
106
+ return n.fromHex(e, this.#t(t));
107
107
  }
108
- validate(e, n) {
109
- return t.validate(e, this.#t(n));
108
+ validate(e, t) {
109
+ return n.validate(e, this.#t(t));
110
110
  }
111
111
  cborToCborEdn(e, t) {
112
112
  return this.cborToCdn(e, t);
113
113
  }
114
- cborToCdn(e, n) {
115
- let r = this.#t(n), i = t.fromCBOR(e, r);
114
+ cborToCdn(e, t) {
115
+ let r = this.#t(t), i = n.fromCBOR(e, r);
116
116
  return i._defaults = this.#e, i.toCDN(r);
117
117
  }
118
118
  cborEdnToCbor(e, t) {
119
119
  return this.cdnToCbor(e, t);
120
120
  }
121
- cdnToCbor(e, n) {
122
- let r = this.#t(n);
123
- return t.fromCDN(e, r).toCBOR(r);
121
+ cdnToCbor(e, t) {
122
+ let r = this.#t(t);
123
+ return n.fromCDN(e, r).toCBOR(r);
124
124
  }
125
- parse(e, n) {
126
- if (typeof n == "function") {
127
- let r = this.#t({ reviver: n });
128
- return t.fromCDN(e, r).toJS(r);
125
+ parse(e, t) {
126
+ if (typeof t == "function") {
127
+ let r = this.#t({ reviver: t });
128
+ return n.fromCDN(e, r).toJS(r);
129
129
  }
130
- let r = this.#t(n);
131
- return t.fromCDN(e, r).toJS(r);
130
+ let r = this.#t(t);
131
+ return n.fromCDN(e, r).toJS(r);
132
132
  }
133
- stringify(e, n, r) {
134
- if (typeof n == "function" || Array.isArray(n) || n === null || n === void 0 && r !== void 0) {
133
+ stringify(e, t, r) {
134
+ if (typeof t == "function" || Array.isArray(t) || t === null || t === void 0 && r !== void 0) {
135
135
  let i = { ...this.#e };
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);
136
+ return t === null ? i.replacer = void 0 : (typeof t == "function" || Array.isArray(t)) && (i.replacer = t), r !== void 0 && (i.indent = V(r)), n.stringify(e, i);
137
137
  }
138
- return t.stringify(e, this.#t(n ?? void 0));
138
+ return n.stringify(e, this.#t(t ?? void 0));
139
139
  }
140
- format(e, n) {
141
- return t.format(e, this.#t(n));
140
+ format(e, t) {
141
+ return n.format(e, this.#t(t));
142
142
  }
143
143
  static fromCBOR(e, t) {
144
- return M(w(e, t), t);
144
+ return N(w(e, t), t);
145
145
  }
146
146
  static fromCDN(e, t) {
147
- return M(m(e, t), t);
147
+ return N(m(e, t), t);
148
148
  }
149
- static fromEDN(e, n) {
150
- return t.fromCDN(e, n);
149
+ static fromEDN(e, t) {
150
+ return n.fromCDN(e, t);
151
151
  }
152
- static *fromHexDumpSeq(e, n) {
153
- let r = [], i = P(e).trim().split(/\s+/).filter(Boolean);
152
+ static *fromHexDumpSeq(e, t) {
153
+ let r = [], i = F(e).trim().split(/\s+/).filter(Boolean);
154
154
  for (let e of i) if (/^[0-9A-Fa-f]{2}$/.test(e)) r.push(parseInt(e, 16));
155
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));
156
156
  else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
157
- yield* t.fromCBORSeq(new Uint8Array(r), n);
157
+ yield* n.fromCBORSeq(new Uint8Array(r), t);
158
158
  }
159
159
  static *fromCBORSeq(e, t) {
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;
160
+ let n = j(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;
161
161
  for (; i < r.byteLength;) {
162
162
  let e = w(r, {
163
163
  ...t,
164
164
  offset: i,
165
165
  allowTrailing: !0
166
166
  });
167
- yield j(e, n, t?.cddlValidationOptions), i = e.end;
167
+ yield M(e, n, t?.cddlValidationOptions), i = e.end;
168
168
  }
169
169
  }
170
- static *fromCDNSeq(t, n) {
171
- let r = A(n?.cddl), i = !!n?.preserveComments, a = 0, o = !0;
170
+ static *fromCDNSeq(n, r) {
171
+ let i = j(r?.cddl), a = e(r) || !!r?.preserveAll, o = 0, s = !0;
172
172
  for (;;) {
173
- let { offset: s, hadSeparator: c, commaOffset: l } = z(t, a, n, i ? o ? "all" : "after-newline" : "none");
174
- if (o && l >= 0) {
173
+ let { offset: e, hadSeparator: c, commaOffset: l } = B(n, o, r, a ? s ? "all" : "after-newline" : "none");
174
+ if (s && l >= 0) {
175
175
  let e = "leading comma in CDN sequence";
176
- if (n?.strict !== !1) throw SyntaxError(e);
177
- L(e, l, n);
176
+ if (r?.strict !== !1) throw SyntaxError(e);
177
+ R(e, l, r);
178
178
  }
179
- if (s >= t.length || i && R(t, s) && z(t, s, n).offset >= t.length) break;
180
- if (!o && !c) {
181
- let e = "CDN sequence items must be separated by whitespace, comma, or comment";
182
- if (n?.strict !== !1) throw SyntaxError(e);
183
- L(e, s, n);
179
+ if (e >= n.length || a && z(n, e) && B(n, e, r).offset >= n.length) break;
180
+ if (!s && !c) {
181
+ let t = "CDN sequence items must be separated by whitespace, comma, or comment";
182
+ if (r?.strict !== !1) throw SyntaxError(t);
183
+ R(t, e, r);
184
184
  }
185
- a = s;
185
+ o = e;
186
186
  let u;
187
187
  try {
188
- u = m(t, {
189
- ...n,
190
- offset: a,
188
+ u = m(n, {
189
+ ...r,
190
+ offset: o,
191
191
  allowTrailing: !0,
192
192
  _skipRS: !0
193
193
  });
194
- } catch (t) {
195
- if (n?.strict !== !1) throw t;
196
- L(t instanceof Error ? t.message : String(t), a, n, !0, t instanceof e ? t : void 0);
194
+ } catch (e) {
195
+ if (r?.strict !== !1) throw e;
196
+ R(e instanceof Error ? e.message : String(e), o, r, !0, e instanceof t ? e : void 0);
197
197
  break;
198
198
  }
199
- yield j(u, r, n?.cddlValidationOptions), a = u.end, o = !1;
199
+ yield M(u, i, r?.cddlValidationOptions), o = u.end, s = !1;
200
200
  }
201
201
  }
202
202
  static fromJS(e, t) {
203
- return M(x(e, t), t);
203
+ return N(x(e, t), t);
204
204
  }
205
205
  static fromHexDump(e, t) {
206
- let n = [], r = P(e).trim().split(/\s+/).filter(Boolean);
206
+ let n = [], r = F(e).trim().split(/\s+/).filter(Boolean);
207
207
  for (let e of r) if (/^[0-9A-Fa-f]{2}$/.test(e)) n.push(parseInt(e, 16));
208
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));
209
209
  else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);
210
- return M(w(new Uint8Array(n), t), t);
210
+ return N(w(new Uint8Array(n), t), t);
211
211
  }
212
- static decode(e, n) {
213
- return t.fromCBOR(e, n).toJS(n);
212
+ static decode(e, t) {
213
+ return n.fromCBOR(e, t).toJS(t);
214
214
  }
215
- static *decodeSeq(e, n) {
216
- for (let r of t.fromCBORSeq(e, n)) yield r.toJS(n);
215
+ static *decodeSeq(e, t) {
216
+ for (let r of n.fromCBORSeq(e, t)) yield r.toJS(t);
217
217
  }
218
- static *parseSeq(e, n) {
219
- for (let r of t.fromCDNSeq(e, n)) yield r.toJS(n);
218
+ static *parseSeq(e, t) {
219
+ for (let r of n.fromCDNSeq(e, t)) yield r.toJS(t);
220
220
  }
221
- static encode(e, n) {
222
- return t.fromJS(e, n).toCBOR(n);
221
+ static encode(e, t) {
222
+ return n.fromJS(e, t).toCBOR(t);
223
223
  }
224
- static compile(e, n) {
225
- let r = [...t.fromCDNSeq(e, n)].map((e) => e.toCBOR(n)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
224
+ static compile(e, t) {
225
+ let r = [...n.fromCDNSeq(e, t)].map((e) => e.toCBOR(t)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
226
226
  for (let e of r) a.set(e, o), o += e.length;
227
227
  return a;
228
228
  }
229
- static decompile(e, n) {
230
- return [...t.fromCBORSeq(e, n)].map((e) => e.toCDN(n)).join("\n");
229
+ static decompile(e, t) {
230
+ return [...n.fromCBORSeq(e, t)].map((e) => e.toCDN(t)).join("\n");
231
231
  }
232
- static toHex(e, n) {
233
- return [...t.fromCBORSeq(e, n)].map((e) => e.toHexDump(n)).join("\n");
232
+ static toHex(e, t) {
233
+ return [...n.fromCBORSeq(e, t)].map((e) => e.toHexDump(t)).join("\n");
234
234
  }
235
- static fromHex(e, n) {
236
- let r = [...t.fromHexDumpSeq(e, n)].map((e) => e.toCBOR(n)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
235
+ static fromHex(e, t) {
236
+ let r = [...n.fromHexDumpSeq(e, t)].map((e) => e.toCBOR(t)), i = r.reduce((e, t) => e + t.length, 0), a = new Uint8Array(i), o = 0;
237
237
  for (let e of r) a.set(e, o), o += e.length;
238
238
  return a;
239
239
  }
240
- static validate(n, r) {
240
+ static validate(e, r) {
241
241
  let i = [], a = [], o, s = {
242
242
  strict: !1,
243
243
  extensions: r?.extensions,
@@ -253,7 +253,7 @@ var N = class t {
253
253
  }
254
254
  i.push(e);
255
255
  }
256
- }, c = A(r?.cddl), l = [], u = [], d = (e) => {
256
+ }, c = j(r?.cddl), l = [], u = [], d = (e) => {
257
257
  if (!c) return;
258
258
  let t = c.validate(e, r?.cddlValidationOptions);
259
259
  l.push(...t.errors), t.warnings && u.push(...t.warnings);
@@ -262,15 +262,15 @@ var N = class t {
262
262
  cddlWarnings: u
263
263
  } : {}, p = 0;
264
264
  try {
265
- let e = r?.type ?? "cbor";
266
- if (e === "cdn") {
267
- let e = {
265
+ let t = r?.type ?? "cbor";
266
+ if (t === "cdn") {
267
+ let t = {
268
268
  ...s,
269
269
  unresolvedExtension: r?.unresolvedExtension
270
270
  };
271
- for (let r of t.fromCDNSeq(n, e)) p++, d(r);
272
- } else if (e === "hex") for (let e of t.fromHexDumpSeq(n, s)) p++, d(e);
273
- else for (let e of t.fromCBORSeq(n, s)) p++, d(e);
271
+ for (let r of n.fromCDNSeq(e, t)) p++, d(r);
272
+ } else if (t === "hex") for (let t of n.fromHexDumpSeq(e, s)) p++, d(t);
273
+ else for (let t of n.fromCBORSeq(e, s)) p++, d(t);
274
274
  } catch (e) {
275
275
  return {
276
276
  valid: !1,
@@ -282,13 +282,13 @@ var N = class t {
282
282
  };
283
283
  }
284
284
  if (o) {
285
- let t = o.cause instanceof Error ? o.cause : new e(o.message, { offset: o.offset });
285
+ let e = o.cause instanceof Error ? o.cause : new t(o.message, { offset: o.offset });
286
286
  return {
287
287
  valid: !1,
288
288
  count: p,
289
289
  warnings: i,
290
290
  hints: a,
291
- error: t,
291
+ error: e,
292
292
  ...f
293
293
  };
294
294
  }
@@ -300,98 +300,98 @@ var N = class t {
300
300
  ...f
301
301
  };
302
302
  }
303
- static cborToCdn(e, n) {
304
- return t.fromCBOR(e, n).toCDN(n);
303
+ static cborToCdn(e, t) {
304
+ return n.fromCBOR(e, t).toCDN(t);
305
305
  }
306
- static cborToCborEdn(e, n) {
307
- return t.fromCBOR(e, n).toCDN(n);
306
+ static cborToCborEdn(e, t) {
307
+ return n.fromCBOR(e, t).toCDN(t);
308
308
  }
309
- static cdnToCbor(e, n) {
310
- return t.fromCDN(e, n).toCBOR(n);
309
+ static cdnToCbor(e, t) {
310
+ return n.fromCDN(e, t).toCBOR(t);
311
311
  }
312
- static cborEdnToCbor(e, n) {
313
- return t.fromCDN(e, n).toCBOR(n);
312
+ static cborEdnToCbor(e, t) {
313
+ return n.fromCDN(e, t).toCBOR(t);
314
314
  }
315
- static parse(e, n) {
316
- return typeof n == "function" ? t.fromCDN(e).toJS({ reviver: n }) : t.fromCDN(e, n).toJS(n);
315
+ static parse(e, t) {
316
+ return typeof t == "function" ? n.fromCDN(e).toJS({ reviver: t }) : n.fromCDN(e, t).toJS(t);
317
317
  }
318
318
  static stringify(e, t, n) {
319
319
  if (typeof t == "function" || Array.isArray(t) || t === null || t === void 0 && n !== void 0) {
320
- let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i = B(n);
320
+ let r = typeof t == "function" || Array.isArray(t) ? t : void 0, i = V(n);
321
321
  if (r) {
322
322
  let t = v(e, r);
323
- return t === void 0 || t === T ? void 0 : x(t).toCDN(i === void 0 ? void 0 : { indent: i });
323
+ return t === void 0 || t === s ? void 0 : x(t).toCDN(i === void 0 ? void 0 : { indent: i });
324
324
  }
325
325
  return x(e).toCDN(i === void 0 ? void 0 : { indent: i });
326
326
  }
327
327
  let r = t;
328
328
  if (r?.replacer) {
329
329
  let t = v(e, r.replacer, r.extensions, r.undefinedOmits, r.builtinExtensions);
330
- if (t === void 0 || t === T) return;
330
+ if (t === void 0 || t === s) return;
331
331
  let { replacer: n, ...i } = r;
332
- return M(x(t, Object.keys(i).length > 0 ? i : void 0), r).toCDN(r);
332
+ return N(x(t, Object.keys(i).length > 0 ? i : void 0), r).toCDN(r);
333
333
  }
334
- return M(x(e, r), r).toCDN(r);
334
+ return N(x(e, r), r).toCDN(r);
335
335
  }
336
- static format(e, n) {
337
- return t.fromCDN(e, n).toCDN(n);
336
+ static format(e, t) {
337
+ return n.fromCDN(e, t).toCDN(t);
338
338
  }
339
339
  };
340
- function P(e) {
340
+ function F(e) {
341
341
  let t = "", n = 0;
342
342
  for (; n < e.length;) {
343
343
  let r = e[n], i = e[n + 1] ?? "";
344
344
  if (r === "-" && i === "-") {
345
- n = F(e, n + 2), t += " ";
345
+ n = I(e, n + 2), t += " ";
346
346
  continue;
347
347
  }
348
348
  if (r === "—") {
349
- n = F(e, n + 1), t += " ";
349
+ n = I(e, n + 1), t += " ";
350
350
  continue;
351
351
  }
352
352
  if (r === "#") {
353
- n = F(e, n + 1), t += " ";
353
+ n = I(e, n + 1), t += " ";
354
354
  continue;
355
355
  }
356
356
  if (r === "/" && i === "/") {
357
- n = F(e, n + 2), t += " ";
357
+ n = I(e, n + 2), t += " ";
358
358
  continue;
359
359
  }
360
360
  if (r === "/" && i === "*") {
361
361
  let r = e.indexOf("*/", n + 2);
362
362
  if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
363
- t += I(e.slice(n, r + 2)), n = r + 2;
363
+ t += L(e.slice(n, r + 2)), n = r + 2;
364
364
  continue;
365
365
  }
366
366
  if (r === "/") {
367
367
  let r = e.indexOf("/", n + 1);
368
368
  if (r < 0) throw SyntaxError("Unterminated comment in hex dump");
369
- t += I(e.slice(n, r + 1)), n = r + 1;
369
+ t += L(e.slice(n, r + 1)), n = r + 1;
370
370
  continue;
371
371
  }
372
372
  t += r, n++;
373
373
  }
374
374
  return t;
375
375
  }
376
- function F(e, t) {
376
+ function I(e, t) {
377
377
  let n = e.indexOf("\n", t);
378
378
  return n < 0 ? e.length : n;
379
379
  }
380
- function I(e) {
380
+ function L(e) {
381
381
  return e.replace(/[^\r\n]/g, " ");
382
382
  }
383
- function L(e, t, n, r, i) {
383
+ function R(e, t, n, r, i) {
384
384
  let a = i?.offset ?? t, o = {
385
385
  message: e,
386
386
  offset: a
387
387
  };
388
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}`);
389
389
  }
390
- function R(e, t) {
390
+ function z(e, t) {
391
391
  let n = e[t];
392
392
  return n === "#" || n === "/";
393
393
  }
394
- function z(e, t, n, r = "none") {
394
+ function B(e, t, n, r = "none") {
395
395
  let i = t, a = !1, o = !1, s = !1, c = -1, l = () => r === "all" || r === "after-newline" && s;
396
396
  for (; i < e.length;) {
397
397
  let t = e[i];
@@ -421,7 +421,7 @@ function z(e, t, n, r = "none") {
421
421
  if (t < 0) {
422
422
  let t = "unterminated /* comment in CDN sequence";
423
423
  if (n?.strict !== !1) throw SyntaxError(t);
424
- L(t, i, n, !0), i = e.length;
424
+ R(t, i, n, !0), i = e.length;
425
425
  } else e.slice(i, t).includes("\n") && (s = !0), i = t + 2;
426
426
  continue;
427
427
  }
@@ -431,7 +431,7 @@ function z(e, t, n, r = "none") {
431
431
  if (t < 0) {
432
432
  let t = "unterminated / comment in CDN sequence";
433
433
  if (n?.strict !== !1) throw SyntaxError(t);
434
- L(t, i, n, !0), i = e.length;
434
+ R(t, i, n, !0), i = e.length;
435
435
  } else e.slice(i, t).includes("\n") && (s = !0), i = t + 1;
436
436
  continue;
437
437
  }
@@ -447,7 +447,7 @@ function z(e, t, n, r = "none") {
447
447
  commaOffset: c
448
448
  };
449
449
  }
450
- function B(e) {
450
+ function V(e) {
451
451
  if (typeof e == "number") {
452
452
  let t = Math.floor(Math.min(10, Math.max(0, e)));
453
453
  return t === 0 ? void 0 : t;
@@ -455,6 +455,6 @@ function B(e) {
455
455
  if (typeof e == "string") return e.slice(0, 10) || void 0;
456
456
  }
457
457
  //#endregion
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 };
458
+ export { h as BUILTIN_EXTENSIONS, P as CBOR, P as default, s as CBOR_OMIT, E as CBOR_TAG, r as CddlMismatchError, t as CdnSyntaxError, C as MapEntries, i as Null, o as Simple, l as Tag, a as Undefined, d as b1, T as b32, f as cri, b as dt, _ as dt_as_Date, u as float, c as h32, y as ilbs, S as ilts, p as ip, O as same, g as t1 };
459
459
 
460
460
  //# sourceMappingURL=index.js.map