@cbortech/cbor 0.27.0 → 0.27.1

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 (48) hide show
  1. package/README.ja.md +73 -0
  2. package/README.md +75 -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 +297 -7
  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 +4 -4
  14. package/dist/ast/CborTextString.d.ts +2 -2
  15. package/dist/ast/CborUint.d.ts +1 -1
  16. package/dist/ast/index.cjs +1 -1
  17. package/dist/ast/index.js +1 -1
  18. package/dist/cddl/index.cjs +1 -1
  19. package/dist/cddl/index.js +1 -1
  20. package/dist/cdn/index.cjs +1 -1
  21. package/dist/cdn/index.js +1 -1
  22. package/dist/cdn/serialize-utils.d.ts +30 -2
  23. package/dist/extensions/cri.d.ts +2 -2
  24. package/dist/extensions/dt.d.ts +4 -4
  25. package/dist/extensions/ip.d.ts +3 -3
  26. package/dist/extensions/types.d.ts +40 -1
  27. package/dist/index.cjs +1 -1
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +3 -3
  30. package/dist/{mapEntries-CvLdiN0h.js → mapEntries-CCLaJSaJ.js} +1114 -933
  31. package/dist/mapEntries-CCLaJSaJ.js.map +1 -0
  32. package/dist/mapEntries-CZZJScaj.cjs +13 -0
  33. package/dist/mapEntries-CZZJScaj.cjs.map +1 -0
  34. package/dist/{schema-CNfrVRYp.js → schema-DN9inJny.js} +3 -3
  35. package/dist/{schema-CNfrVRYp.js.map → schema-DN9inJny.js.map} +1 -1
  36. package/dist/{schema-iXpYtKQl.cjs → schema-zsg5yCPK.cjs} +2 -2
  37. package/dist/{schema-iXpYtKQl.cjs.map → schema-zsg5yCPK.cjs.map} +1 -1
  38. package/dist/{serialize-utils-CjTqQivB.cjs → serialize-utils-DhlW61ZX.cjs} +6 -6
  39. package/dist/serialize-utils-DhlW61ZX.cjs.map +1 -0
  40. package/dist/{serialize-utils-BuIZPaUc.js → serialize-utils-h-CVB9rg.js} +57 -47
  41. package/dist/{serialize-utils-BuIZPaUc.js.map → serialize-utils-h-CVB9rg.js.map} +1 -1
  42. package/dist/types.d.ts +273 -0
  43. package/dist/utils/hexfloat.d.ts +10 -2
  44. package/package.json +7 -8
  45. package/dist/mapEntries-C1f7G0AM.cjs +0 -13
  46. package/dist/mapEntries-C1f7G0AM.cjs.map +0 -1
  47. package/dist/mapEntries-CvLdiN0h.js.map +0 -1
  48. package/dist/serialize-utils-CjTqQivB.cjs.map +0 -1
@@ -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,43 +1027,43 @@ 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-]*['`]/;
@@ -1408,6 +1418,6 @@ function Oe(e, t, n, r, i) {
1408
1418
  return a = Ee(a, n, i, o), a.replace(/_[0-3i]$/, "") + t;
1409
1419
  }
1410
1420
  //#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 };
1421
+ 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
1422
 
1413
- //# sourceMappingURL=serialize-utils-BuIZPaUc.js.map
1423
+ //# sourceMappingURL=serialize-utils-h-CVB9rg.js.map