@cbortech/cbor 0.27.0 → 0.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.ja.md +100 -0
  2. package/README.md +103 -0
  3. package/dist/ast/CborAppSeqResult.d.ts +37 -4
  4. package/dist/ast/CborArray.d.ts +2 -2
  5. package/dist/ast/CborByteString.d.ts +2 -2
  6. package/dist/ast/CborEmbeddedCBOR.d.ts +1 -1
  7. package/dist/ast/CborFloat.d.ts +1 -1
  8. package/dist/ast/CborIndefiniteByteString.d.ts +1 -1
  9. package/dist/ast/CborIndefiniteTextString.d.ts +1 -1
  10. package/dist/ast/CborItem.d.ts +314 -9
  11. package/dist/ast/CborMap.d.ts +2 -2
  12. package/dist/ast/CborNint.d.ts +1 -1
  13. package/dist/ast/CborTag.d.ts +26 -4
  14. package/dist/ast/CborTextString.d.ts +2 -2
  15. package/dist/ast/CborUint.d.ts +1 -1
  16. package/dist/ast/CborUnresolvedAppExt.d.ts +9 -0
  17. package/dist/ast/index.cjs +1 -1
  18. package/dist/ast/index.js +2 -2
  19. package/dist/cbor/tagLabels.d.ts +26 -0
  20. package/dist/cddl/eRefScope.d.ts +241 -0
  21. package/dist/cddl/eref.d.ts +64 -0
  22. package/dist/cddl/implicitTags.d.ts +28 -0
  23. package/dist/cddl/index.cjs +2 -2
  24. package/dist/cddl/index.cjs.map +1 -1
  25. package/dist/cddl/index.d.ts +2 -0
  26. package/dist/cddl/index.js +26 -25
  27. package/dist/cddl/index.js.map +1 -1
  28. package/dist/cddl/validator.d.ts +98 -2
  29. package/dist/cdn/index.cjs +1 -1
  30. package/dist/cdn/index.js +1 -1
  31. package/dist/cdn/serialize-utils.d.ts +50 -15
  32. package/dist/extensions/cri.d.ts +2 -2
  33. package/dist/extensions/dt.d.ts +4 -4
  34. package/dist/extensions/eref.d.ts +135 -0
  35. package/dist/extensions/ip.d.ts +3 -3
  36. package/dist/extensions/types.d.ts +40 -1
  37. package/dist/index.cjs +7 -7
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.ts +2 -1
  40. package/dist/index.js +190 -81
  41. package/dist/index.js.map +1 -1
  42. package/dist/js/fromJS.d.ts +23 -1
  43. package/dist/mapEntries-8zshEr-t.js +7085 -0
  44. package/dist/mapEntries-8zshEr-t.js.map +1 -0
  45. package/dist/mapEntries-DwHPAzCN.cjs +68 -0
  46. package/dist/mapEntries-DwHPAzCN.cjs.map +1 -0
  47. package/dist/schema-7r2xjpMK.js +345 -0
  48. package/dist/schema-7r2xjpMK.js.map +1 -0
  49. package/dist/schema-YiigSWjR.cjs +8 -0
  50. package/dist/schema-YiigSWjR.cjs.map +1 -0
  51. package/dist/{serialize-utils-BuIZPaUc.js → serialize-utils-BQtutOo6.js} +70 -52
  52. package/dist/serialize-utils-BQtutOo6.js.map +1 -0
  53. package/dist/{serialize-utils-CjTqQivB.cjs → serialize-utils-DQ8T3Mzw.cjs} +9 -9
  54. package/dist/serialize-utils-DQ8T3Mzw.cjs.map +1 -0
  55. package/dist/types.d.ts +426 -4
  56. package/dist/utils/hexfloat.d.ts +10 -2
  57. package/package.json +13 -14
  58. package/dist/mapEntries-C1f7G0AM.cjs +0 -13
  59. package/dist/mapEntries-C1f7G0AM.cjs.map +0 -1
  60. package/dist/mapEntries-CvLdiN0h.js +0 -3946
  61. package/dist/mapEntries-CvLdiN0h.js.map +0 -1
  62. package/dist/schema-CNfrVRYp.js +0 -1977
  63. package/dist/schema-CNfrVRYp.js.map +0 -1
  64. package/dist/schema-iXpYtKQl.cjs +0 -63
  65. package/dist/schema-iXpYtKQl.cjs.map +0 -1
  66. package/dist/serialize-utils-BuIZPaUc.js.map +0 -1
  67. package/dist/serialize-utils-CjTqQivB.cjs.map +0 -1
@@ -267,13 +267,13 @@ var h = new TextEncoder(), g = class {
267
267
  return;
268
268
  }
269
269
  let n = "";
270
- for (let e = 0; e < 4 && !(this._eof() || this._ch() === "\n" || !/[0-9a-fA-F]/.test(this._ch())); e++) n += this._advance();
270
+ for (let e = 0; e < 4 && !this._eof() && this._ch() !== "\n" && /[0-9a-fA-F]/.test(this._ch()); e++) n += this._advance();
271
271
  if (n.length < 4) return;
272
272
  let r = parseInt(n, 16);
273
273
  if (r >= 55296 && r <= 56319) {
274
274
  (this._ch() !== "\\" || (this.input[this.pos + 1] ?? "") !== "u") && this._fail(`lone high surrogate \\u${n} in hex string comment`, e, t), this._advance(), this._advance();
275
275
  let r = "";
276
- for (let e = 0; e < 4 && !(this._eof() || this._ch() === "\n" || !/[0-9a-fA-F]/.test(this._ch())); e++) r += this._advance();
276
+ for (let e = 0; e < 4 && !this._eof() && this._ch() !== "\n" && /[0-9a-fA-F]/.test(this._ch()); e++) r += this._advance();
277
277
  let i = parseInt(r || "0", 16);
278
278
  (i < 56320 || i > 57343) && this._fail(`\\u${n} (high surrogate) not followed by valid low surrogate in hex string comment`, e, t);
279
279
  return;
@@ -940,21 +940,28 @@ function ee(e, t = !1) {
940
940
  };
941
941
  }
942
942
  function j(e) {
943
- let { options: t, depth: n, openChar: r, closeChar: i, count: a } = e, o = v(t), s = w(t), c = T(t), l = o !== null && s && (C(e.node) || e.hasEntryComments()), u = o !== null && !!t?.preserveBlankLines, d = !1;
944
- if (u) {
943
+ let { options: t, depth: n, openChar: r, closeChar: i, count: a } = e, o = v(t), s = w(t), c = T(t), l = !1;
944
+ if (o !== null) {
945
+ for (let n = 0; n < a; n++) if (e.hasEntryComments(n) && w(e.entryOptions ? e.entryOptions(n) : t)) {
946
+ l = !0;
947
+ break;
948
+ }
949
+ }
950
+ let u = o !== null && (s && C(e.node) || l), d = o !== null && !!t?.preserveBlankLines, f = !1;
951
+ if (d) {
945
952
  for (let t = 0; t < a; t++) if (e.entryLeadingNode(t).blankLineBefore) {
946
- d = !0;
953
+ f = !0;
947
954
  break;
948
955
  }
949
956
  }
950
- let { inlineSep: f, multilineSep: p, trailSep: m, colSep: h } = ee(t, o === null), g = e.eiPosition ?? "open", b = e.indefiniteLength ? "" : Y(t, e.encodingWidth, () => J(e.canonicalCount ? e.canonicalCount() : BigInt(a))), x = g === "open" && b ? b + " " : "", S = g === "close" ? b : "", E = e.indefiniteLength && (e.indefiniteMarker ?? !0) && (t?.encodingIndicators ?? "auto") !== "never", D = (t) => e.indefiniteLength ? E ? a === 0 ? `${r}_ ${i}` : `${r}_ ${t}${i}` : `${r}${t}${i}` : `${r}${x}${t}${i}${S}`;
951
- if (o === null || a === 0 && !l) {
957
+ let { inlineSep: p, multilineSep: m, trailSep: h, colSep: g } = ee(t, o === null), b = e.eiPosition ?? "open", x = e.indefiniteLength ? "" : Y(t, e.encodingWidth, () => J(e.canonicalCount ? e.canonicalCount() : BigInt(a))), S = b === "open" && x ? x + " " : "", E = b === "close" ? x : "", D = e.indefiniteLength && (e.indefiniteMarker ?? !0) && (t?.encodingIndicators ?? "auto") !== "never", k = (t) => e.indefiniteLength ? D ? a === 0 ? `${r}_ ${i}` : `${r}_ ${t}${i}` : `${r}${t}${i}` : `${r}${S}${t}${i}${E}`;
958
+ if (o === null || a === 0 && !u) {
952
959
  let t = "";
953
- for (let n = 0; n < a; n++) n > 0 && (t += f), t += e.renderEntry(n, h);
954
- return D(t);
960
+ for (let n = 0; n < a; n++) n > 0 && (t += p), t += e.renderEntry(n, g);
961
+ return k(t);
955
962
  }
956
- let k = null;
957
- if ((t?.inlineLeafContainers || e.alwaysInlineLeaf) && a > 0 && !l && !d) {
963
+ let j = null;
964
+ if ((t?.inlineLeafContainers || e.alwaysInlineLeaf) && a > 0 && !u && !f) {
958
965
  let t = !!e.entryIsLeaf, n = [], r = !0;
959
966
  for (let i = 0; i < a; i++) {
960
967
  if (e.entryIsLeaf && !e.entryIsLeaf(i)) {
@@ -965,7 +972,7 @@ function j(e) {
965
972
  r = !1;
966
973
  break;
967
974
  }
968
- let a = e.renderEntry(i, h);
975
+ let a = e.renderEntry(i, g);
969
976
  if (n.push(a), a.includes("\n")) {
970
977
  r = !1;
971
978
  break;
@@ -975,31 +982,34 @@ function j(e) {
975
982
  break;
976
983
  }
977
984
  }
978
- if (r) return D(n.join(f));
979
- k = n;
980
- }
981
- let j = y(o, n + 1), M = y(o, n), N = e.indefiniteLength ? E ? `${r}_ ` : r : `${r}${x}`, P = [];
982
- for (let t = 0; t < a; t++) {
983
- u && e.entryLeadingNode(t).blankLineBefore && P.push("");
984
- let n = "";
985
- if (s) {
986
- let { ownLines: r, inlinePrefix: i } = O(e.entryLeadingNode(t), j, c);
987
- _(P, r), n = i;
985
+ if (r) return k(n.join(p));
986
+ j = n;
987
+ }
988
+ let M = y(o, n + 1), N = y(o, n), P = e.indefiniteLength ? D ? `${r}_ ` : r : `${r}${S}`, F = [];
989
+ for (let n = 0; n < a; n++) {
990
+ d && e.entryLeadingNode(n).blankLineBefore && F.push("");
991
+ let r = w(e.entryOptions ? e.entryOptions(n) : t), i = T(e.entryOptions ? e.entryOptions(n) : t), o = "";
992
+ if (r) {
993
+ let { ownLines: t, inlinePrefix: r } = O(e.entryLeadingNode(n), M, i);
994
+ _(F, t), o = r;
988
995
  }
989
- let r = t < a - 1 ? p : m, i = k?.[t] ?? e.renderEntry(t, h);
990
- P.push(`${j}${n}${i}${r}${s ? e.entryTrailing(t, c) : ""}`);
996
+ let s = n < a - 1 ? m : h, c = j?.[n] ?? e.renderEntry(n, g);
997
+ F.push(`${M}${o}${c}${s}${r ? e.entryTrailing(n, i) : ""}`);
991
998
  }
992
- return s && _(P, A(e.node, j, c)), `${N}\n${P.join("\n")}\n${M}${i}${S}`;
999
+ return s && _(F, A(e.node, M, c)), `${P}\n${F.join("\n")}\n${N}${i}${E}`;
993
1000
  }
994
- function M(e, t, n, r, i, a, o) {
995
- let s = v(n);
996
- if (!(s !== null && w(n) && (S(e) || C(t)))) return `${a}${i(r)}${o}`;
997
- let c = T(n), l = y(s, r + 1), u = y(s, r), { ownLines: d, inlinePrefix: f } = O(e, l, c);
998
- return `${a}\n${[
999
- ...d,
1000
- `${l}${f}${i(r + 1)}${k(e, c)}`,
1001
- ...A(t, l, c)
1002
- ].join("\n")}\n${u}${o}`;
1001
+ function M(e, t, n, r, i, a, o, s) {
1002
+ let c = v(n), l = w(n), u = w(r);
1003
+ if (!(c !== null && (u && S(e) || l && C(t)))) return `${o}${a(i)}${s}`;
1004
+ let d = T(n), f = T(r), p = y(c, i + 1), m = y(c, i), { ownLines: h, inlinePrefix: g } = u ? O(e, p, f) : {
1005
+ ownLines: [],
1006
+ inlinePrefix: ""
1007
+ };
1008
+ return `${o}\n${[
1009
+ ...h,
1010
+ `${p}${g}${a(i + 1)}${u ? k(e, f) : ""}`,
1011
+ ...l ? A(t, p, d) : []
1012
+ ].join("\n")}\n${m}${s}`;
1003
1013
  }
1004
1014
  var N = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
1005
1015
  function P(e) {
@@ -1008,7 +1018,7 @@ function P(e) {
1008
1018
  for (let n of e) t += String.fromCharCode(n);
1009
1019
  return btoa(t).replace(/=/g, "");
1010
1020
  }
1011
- function te(e) {
1021
+ function F(e) {
1012
1022
  if (N) return e.toBase64({
1013
1023
  alphabet: "base64url",
1014
1024
  omitPadding: !0
@@ -1017,48 +1027,55 @@ function te(e) {
1017
1027
  for (let n of e) t += String.fromCharCode(n);
1018
1028
  return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
1019
1029
  }
1020
- var ne = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", re = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
1021
- function F(e, t) {
1030
+ var te = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", ne = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
1031
+ function I(e, t) {
1022
1032
  let n = "", r = 0, i = 0;
1023
1033
  for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
1024
1034
  return i > 0 && (n += t[r << 5 - i & 31]), n;
1025
1035
  }
1026
- function ie(e) {
1036
+ function re(e) {
1027
1037
  for (let t of e) {
1028
1038
  let e = t.codePointAt(0);
1029
1039
  if (e < 32 || e === 127) return !0;
1030
1040
  }
1031
1041
  return !1;
1032
1042
  }
1033
- function I(e, t) {
1043
+ function L(e, t) {
1034
1044
  if (t === "string") {
1035
1045
  let t = G(e);
1036
1046
  if (t != null) return t;
1037
1047
  }
1038
1048
  if (t === "printable-string" || t === void 0) {
1039
1049
  let t = G(e);
1040
- if (t != null && !ie(t)) return t;
1050
+ if (t != null && !re(t)) return t;
1041
1051
  }
1042
1052
  return null;
1043
1053
  }
1044
- function ae(e, t, n) {
1045
- let r = I(e, n);
1054
+ function ie(e, t, n) {
1055
+ let r = L(e, n);
1046
1056
  if (r !== null) return ye(r);
1047
1057
  switch (t) {
1048
1058
  case "base64": return `b64'${P(e)}'`;
1049
- case "base64url": return `b64'${te(e)}'`;
1050
- case "base32": return `b32'${F(e, ne)}'`;
1051
- case "base32hex": return `h32'${F(e, re)}'`;
1059
+ case "base64url": return `b64'${F(e)}'`;
1060
+ case "base32": return `b32'${I(e, te)}'`;
1061
+ case "base32hex": return `h32'${I(e, ne)}'`;
1052
1062
  default: return `h'${o(e)}'`;
1053
1063
  }
1054
1064
  }
1055
- function L(e, t) {
1056
- let n = I(e, t);
1065
+ function ae(e, t) {
1066
+ let n = L(e, t);
1057
1067
  return n !== null && q(n);
1058
1068
  }
1059
1069
  var oe = /^[A-Za-z][A-Za-z0-9-]*['`]/;
1060
1070
  function R(e) {
1061
- return oe.test(e);
1071
+ if (!oe.test(e)) return !1;
1072
+ let t;
1073
+ try {
1074
+ t = new g(e).consume();
1075
+ } catch {
1076
+ return !0;
1077
+ }
1078
+ return t.type !== "APP_STRING" || q(t.value);
1062
1079
  }
1063
1080
  var z = new TextDecoder();
1064
1081
  function se(e, t) {
@@ -1159,6 +1176,7 @@ function W(e, t, n, r) {
1159
1176
  if (t !== null && t + 1 === i) return W(e, n + 1, t, r);
1160
1177
  }
1161
1178
  }
1179
+ if (r && (e[t].type === "LBRACKET" || e[t].type === "LBRACE") && H(e, t, i) === i - 1) return !0;
1162
1180
  if (e[t].type === "APP_SEQUENCE") {
1163
1181
  let n = H(e, t, i);
1164
1182
  if (n !== null && n + 1 === i) {
@@ -1184,8 +1202,8 @@ function W(e, t, n, r) {
1184
1202
  }
1185
1203
  case "BYTES_HEX":
1186
1204
  case "BYTES_HEX_ELIDED":
1187
- case "BYTES_B64":
1188
- case "APP_STRING": return r;
1205
+ case "BYTES_B64": return r;
1206
+ case "APP_STRING": return r && q(a.value);
1189
1207
  default: return !1;
1190
1208
  }
1191
1209
  }
@@ -1408,6 +1426,6 @@ function Oe(e, t, n, r, i) {
1408
1426
  return a = Ee(a, n, i, o), a.replace(/_[0-3i]$/, "") + t;
1409
1427
  }
1410
1428
  //#endregion
1411
- export { g as A, Y as C, w as D, j as E, u as F, e as I, c as M, o as N, O, l as P, T as S, ae as T, R as _, D as a, _ as b, xe as c, k as d, S as f, q as g, se as h, E as i, d as j, me as k, we as l, L as m, De as n, Te as o, y as p, J as r, be as s, Oe as t, Ce as u, x as v, v as w, M as x, b as y };
1429
+ export { g as A, Y as C, w as D, j as E, u as F, e as I, c as M, o as N, O, l as P, T as S, ie as T, R as _, D as a, _ as b, xe as c, k as d, S as f, q as g, se as h, E as i, d as j, me as k, we as l, ae as m, De as n, Te as o, y as p, J as r, be as s, Oe as t, Ce as u, x as v, v as w, M as x, b as y };
1412
1430
 
1413
- //# sourceMappingURL=serialize-utils-BuIZPaUc.js.map
1431
+ //# sourceMappingURL=serialize-utils-BQtutOo6.js.map