@happyvertical/smrt-content 0.37.0 → 0.37.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.
package/dist/index.js CHANGED
@@ -7017,7 +7017,6 @@ const CURRENCY = {
7017
7017
  yen: "¥",
7018
7018
  euro: "€",
7019
7019
  dollar: "$",
7020
- euro: "€",
7021
7020
  fnof: "ƒ",
7022
7021
  inr: "₹",
7023
7022
  af: "؋",
@@ -7232,6 +7231,7 @@ class EntityDecoder {
7232
7231
  */
7233
7232
  decode(str) {
7234
7233
  if (typeof str !== "string" || str.length === 0) return str;
7234
+ if (str.indexOf("&") === -1) return str;
7235
7235
  const original = str;
7236
7236
  const chunks = [];
7237
7237
  const len = str.length;
@@ -7862,17 +7862,244 @@ function validateEntityName(name) {
7862
7862
  else
7863
7863
  throw new Error(`Invalid entity name ${name}`);
7864
7864
  }
7865
+ const SCRIPT_ZEROS = [
7866
+ // Basic Latin (ASCII) — included for completeness / pass-through
7867
+ 48,
7868
+ // 0-9
7869
+ // Arabic scripts
7870
+ 1632,
7871
+ // Arabic-Indic ٠١٢٣٤٥٦٧٨٩
7872
+ 1776,
7873
+ // Extended Arabic-Indic (Urdu/Persian/Sindhi) ۰۱۲۳
7874
+ // Indic scripts
7875
+ 2406,
7876
+ // Devanagari ०१२३४५६७८९
7877
+ 2534,
7878
+ // Bengali ০১২৩৪৫৬৭৮৯
7879
+ 2662,
7880
+ // Gurmukhi ੦੧੨੩੪੫੬੭੮੯
7881
+ 2790,
7882
+ // Gujarati ૦૧૨૩૪૫૬૭૮૯
7883
+ 2918,
7884
+ // Odia ୦୧୨୩୪୫୬୭୮୯
7885
+ 3046,
7886
+ // Tamil ௦௧௨௩௪௫௬௭௮௯
7887
+ 3174,
7888
+ // Telugu ౦౧౨౩౪౫౬౭౮౯
7889
+ 3302,
7890
+ // Kannada ೦೧೨೩೪೫೬೭೮೯
7891
+ 3430,
7892
+ // Malayalam ൦൧൨൩൪൫൬൭൮൯
7893
+ 3558,
7894
+ // Sinhala Archaic ෦෧෨෩෪෫෬෭෮෯
7895
+ // Southeast Asian scripts
7896
+ 3664,
7897
+ // Thai ๐๑๒๓๔๕๖๗๘๙
7898
+ 3792,
7899
+ // Lao ໐໑໒໓໔໕໖໗໘໙
7900
+ 3872,
7901
+ // Tibetan ༠༡༢༣༤༥༦༧༨༩
7902
+ 4160,
7903
+ // Myanmar ၀၁၂၃၄၅၆၇၈၉
7904
+ 4240,
7905
+ // Myanmar Shan ႐႑႒႓႔႕႖႗႘႙
7906
+ 6112,
7907
+ // Khmer ០១២៣៤៥៦៧៨៩
7908
+ 6160,
7909
+ // Mongolian ᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙
7910
+ 6470,
7911
+ // Limbu ᥆᥇᥈᥉᥊᥋᥌᥍᥎᥏
7912
+ 6608,
7913
+ // New Tai Lue ᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙
7914
+ 6784,
7915
+ // Tai Tham Hora ᪀᪁᪂᪃᪄᪅᪆᪇᪈᪉
7916
+ 6800,
7917
+ // Tai Tham Tham ᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙
7918
+ 6992,
7919
+ // Balinese ᭐᭑᭒᭓᭔᭕᭖᭗᭘᭙
7920
+ 7088,
7921
+ // Sundanese ᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹
7922
+ 7232,
7923
+ // Lepcha ᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉
7924
+ 7248,
7925
+ // Ol Chiki ᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙
7926
+ // Fullwidth (CJK context)
7927
+ 65296,
7928
+ // Fullwidth 0123456789
7929
+ // Mathematical digit variants (Unicode math block)
7930
+ 120782,
7931
+ // Mathematical Bold
7932
+ 120792,
7933
+ // Mathematical Double-Struck
7934
+ 120802,
7935
+ // Mathematical Sans-Serif
7936
+ 120812,
7937
+ // Mathematical Sans-Serif Bold
7938
+ 120822,
7939
+ // Mathematical Monospace
7940
+ // Other scripts
7941
+ 66720,
7942
+ // Osmanya 𐒠𐒡𐒢𐒣𐒤𐒥𐒦𐒧𐒨𐒩
7943
+ 68912,
7944
+ // Hanifi Rohingya 𐴰𐴱𐴲𐴳𐴴𐴵𐴶𐴷𐴸𐴹
7945
+ 69734,
7946
+ // Brahmi 𑁦𑁧𑁨𑁩𑁪𑁫𑁬𑁭𑁮𑁯
7947
+ 69872,
7948
+ // Sora Sompeng 𑃰𑃱𑃲𑃳𑃴𑃵𑃶𑃷𑃸𑃹
7949
+ 69942,
7950
+ // Chakma 𑄶𑄷𑄸𑄹𑄺𑄻𑄼𑄽𑄾𑄿
7951
+ 70096,
7952
+ // Sharada 𑇐𑇑𑇒𑇓𑇔𑇕𑇖𑇗𑇘𑇙
7953
+ 70384,
7954
+ // Khudawadi 𑋰𑋱𑋲𑋳𑋴𑋵𑋶𑋷𑋸𑋹
7955
+ 70736,
7956
+ // Newa 𑑐𑑑𑑒𑑓𑑔𑑕𑑖𑑗𑑘𑑙
7957
+ 70864,
7958
+ // Tirhuta 𑓐𑓑𑓒𑓓𑓔𑓕𑓖𑓗𑓘𑓙
7959
+ 71248,
7960
+ // Modi 𑙐𑙑𑙒𑙓𑙔𑙕𑙖𑙗𑙘𑙙
7961
+ 71360,
7962
+ // Takri 𑛀𑛁𑛂𑛃𑛄𑛅𑛆𑛇𑛈𑛉
7963
+ 71472,
7964
+ // Ahom 𑜰𑜱𑜲𑜳𑜴𑜵𑜶𑜷𑜸𑜹
7965
+ 71904,
7966
+ // Warang Citi 𑣠𑣡𑣢𑣣𑣤𑣥𑣦𑣧𑣨𑣩
7967
+ 72016,
7968
+ // Dives Akuru 𑥐𑥑𑥒𑥓𑥔𑥕𑥖𑥗𑥘𑥙
7969
+ 72688,
7970
+ // Khitan Small Script 𑯰𑯱𑯲𑯳𑯴𑯵𑯶𑯷𑯸𑯹
7971
+ 72784,
7972
+ // Bhaiksuki 𑱐𑱑𑱒𑱓𑱔𑱕𑱖𑱗𑱘𑱙
7973
+ 73040,
7974
+ // Masaram Gondi 𑵐𑵑𑵒𑵓𑵔𑵕𑵖𑵗𑵘𑵙
7975
+ 73120,
7976
+ // Gunjala Gondi 𑶠𑶡𑶢𑶣𑶤𑶥𑶦𑶧𑶨𑶩
7977
+ 73552,
7978
+ // Kawi 𑽐𑽑𑽒𑽓𑽔𑽕𑽖𑽗𑽘𑽙
7979
+ 92768,
7980
+ // Mro 𖩠𖩡𖩢𖩣𖩤𖩥𖩦𖩧𖩨𖩩
7981
+ 92864,
7982
+ // Tangsa 𖫀𖫁𖫂𖫃𖫄𖫅𖫆𖫇𖫈𖫉
7983
+ 93008,
7984
+ // Pahawh Hmong 𖭐𖭑𖭒𖭓𖭔𖭕𖭖𖭗𖭘𖭙
7985
+ 123200,
7986
+ // Nyiakeng Puachue Hmong 𞅀𞅁𞅂𞅃𞅄𞅅𞅆𞅇𞅈𞅉
7987
+ 123632,
7988
+ // Wancho 𞋰𞋱𞋲𞋳𞋴𞋵𞋶𞋷𞋸𞋹
7989
+ 124144,
7990
+ // Nag Mundari 𞓰𞓱𞓲𞓳𞓴𞓵𞓶𞓷𞓸𞓹
7991
+ 125264,
7992
+ // Adlam 𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙
7993
+ 130032
7994
+ // Segmented digit symbols 🯰🯱🯲🯳🯴🯵🯶🯷🯸🯹
7995
+ ];
7996
+ const NOT_DIGIT = 255;
7997
+ const HIGH_MAP = /* @__PURE__ */ new Map();
7998
+ const LOW_MAX = 65535;
7999
+ const LOW_MIN = 1632;
8000
+ const TABLE_OFFSET = LOW_MIN;
8001
+ const TABLE_SIZE = LOW_MAX - LOW_MIN + 1;
8002
+ const TABLE = new Uint8Array(TABLE_SIZE).fill(NOT_DIGIT);
8003
+ for (const zero of SCRIPT_ZEROS) {
8004
+ for (let d = 0; d < 10; d++) {
8005
+ const cp = zero + d;
8006
+ if (cp <= LOW_MAX) {
8007
+ TABLE[cp - TABLE_OFFSET] = d;
8008
+ } else {
8009
+ HIGH_MAP.set(cp, d);
8010
+ }
8011
+ }
8012
+ }
8013
+ const CHAR_0 = 48;
8014
+ const CHAR_9 = 57;
8015
+ const CHAR_MINUS = 45;
8016
+ const MINUS_SET = /* @__PURE__ */ new Set([8722, 65293, 65123]);
8017
+ function anynum(str) {
8018
+ if (typeof str !== "string") return str;
8019
+ const len = str.length;
8020
+ if (len === 0) return str;
8021
+ let firstHit = -1;
8022
+ for (let i = 0; i < len; i++) {
8023
+ const cc = str.charCodeAt(i);
8024
+ if (cc >= CHAR_0 && cc <= CHAR_9 || cc === CHAR_MINUS) continue;
8025
+ if (cc < TABLE_OFFSET) {
8026
+ if (MINUS_SET.has(cc)) {
8027
+ firstHit = i;
8028
+ break;
8029
+ }
8030
+ continue;
8031
+ }
8032
+ if (cc >= 55296 && cc <= 56319) {
8033
+ if (i + 1 < len) {
8034
+ const low = str.charCodeAt(i + 1);
8035
+ if (low >= 56320 && low <= 57343) {
8036
+ const cp = 65536 + (cc - 55296 << 10) + (low - 56320);
8037
+ if (HIGH_MAP.has(cp)) {
8038
+ firstHit = i;
8039
+ break;
8040
+ }
8041
+ }
8042
+ }
8043
+ continue;
8044
+ }
8045
+ if (TABLE[cc - TABLE_OFFSET] !== NOT_DIGIT || MINUS_SET.has(cc)) {
8046
+ firstHit = i;
8047
+ break;
8048
+ }
8049
+ }
8050
+ if (firstHit === -1) return str;
8051
+ const chars = [];
8052
+ if (firstHit > 0) chars.push(str.slice(0, firstHit));
8053
+ for (let i = firstHit; i < len; i++) {
8054
+ const cc = str.charCodeAt(i);
8055
+ if (cc >= CHAR_0 && cc <= CHAR_9 || cc === CHAR_MINUS) {
8056
+ chars.push(str[i]);
8057
+ continue;
8058
+ }
8059
+ if (cc < TABLE_OFFSET) {
8060
+ chars.push(MINUS_SET.has(cc) ? "-" : str[i]);
8061
+ continue;
8062
+ }
8063
+ if (cc >= 55296 && cc <= 56319) {
8064
+ if (i + 1 < len) {
8065
+ const low = str.charCodeAt(i + 1);
8066
+ if (low >= 56320 && low <= 57343) {
8067
+ const cp = 65536 + (cc - 55296 << 10) + (low - 56320);
8068
+ const d2 = HIGH_MAP.get(cp);
8069
+ if (d2 !== void 0) {
8070
+ chars.push(String.fromCharCode(d2 + 48));
8071
+ i++;
8072
+ continue;
8073
+ }
8074
+ }
8075
+ }
8076
+ chars.push(str[i]);
8077
+ continue;
8078
+ }
8079
+ if (MINUS_SET.has(cc)) {
8080
+ chars.push("-");
8081
+ continue;
8082
+ }
8083
+ const d = TABLE[cc - TABLE_OFFSET];
8084
+ chars.push(d !== NOT_DIGIT ? String.fromCharCode(d + 48) : str[i]);
8085
+ }
8086
+ return chars.join("");
8087
+ }
7865
8088
  const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
8089
+ const binRegex = /^0b[01]+$/;
8090
+ const octRegex = /^0o[0-7]+$/;
7866
8091
  const numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
7867
8092
  const consider = {
7868
8093
  hex: true,
7869
- // oct: false,
8094
+ binary: false,
8095
+ octal: false,
7870
8096
  leadingZeros: true,
7871
8097
  decimalPoint: ".",
7872
8098
  eNotation: true,
7873
8099
  //skipLike: /regex/,
7874
- infinity: "original"
8100
+ infinity: "original",
7875
8101
  // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
8102
+ unicode: false
7876
8103
  };
7877
8104
  function toNumber(str, options = {}) {
7878
8105
  options = Object.assign({}, consider, options);
@@ -7881,8 +8108,16 @@ function toNumber(str, options = {}) {
7881
8108
  if (trimmedStr.length === 0) return str;
7882
8109
  else if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
7883
8110
  else if (trimmedStr === "0") return 0;
7884
- else if (options.hex && hexRegex.test(trimmedStr)) {
8111
+ if (options.unicode) {
8112
+ trimmedStr = anynum(trimmedStr);
8113
+ if (trimmedStr === "0") return 0;
8114
+ }
8115
+ if (options.hex && hexRegex.test(trimmedStr)) {
7885
8116
  return parse_int(trimmedStr, 16);
8117
+ } else if (options.binary && binRegex.test(trimmedStr)) {
8118
+ return parse_int(trimmedStr, 2);
8119
+ } else if (options.octal && octRegex.test(trimmedStr)) {
8120
+ return parse_int(trimmedStr, 8);
7886
8121
  } else if (!isFinite(trimmedStr)) {
7887
8122
  return handleInfinity(str, Number(trimmedStr), options);
7888
8123
  } else if (trimmedStr.includes("e") || trimmedStr.includes("E")) {
@@ -7962,6 +8197,8 @@ function trimZeros(numStr) {
7962
8197
  return numStr;
7963
8198
  }
7964
8199
  function parse_int(numStr, base) {
8200
+ const str = numStr.trim();
8201
+ if (base === 2 || base === 8) numStr = str.substring(2);
7965
8202
  if (parseInt) return parseInt(numStr, base);
7966
8203
  else if (Number.parseInt) return Number.parseInt(numStr, base);
7967
8204
  else if (window && window.parseInt) return window.parseInt(numStr, base);
@@ -9294,7 +9531,7 @@ function readStopNodeData(xmlData, tagName, i) {
9294
9531
  const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
9295
9532
  i = closeIndex;
9296
9533
  } else {
9297
- const tagData = readTagExp(xmlData, i, ">");
9534
+ const tagData = readTagExp(xmlData, i, false);
9298
9535
  if (tagData) {
9299
9536
  const openTagName = tagData && tagData.tagName;
9300
9537
  if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
@@ -9378,6 +9615,9 @@ function compress(arr, options, matcher, readonlyMatcher) {
9378
9615
  } else if (tagObj[property]) {
9379
9616
  let val = compress(tagObj[property], options, matcher, readonlyMatcher);
9380
9617
  const isLeaf = isLeafTag(val, options);
9618
+ if (Object.keys(val).length === 0 && options.alwaysCreateTextNode) {
9619
+ val[options.textNodeName] = "";
9620
+ }
9381
9621
  if (tagObj[":@"]) {
9382
9622
  assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
9383
9623
  } else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {