@intlayer/core 9.0.2 → 9.1.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 (96) hide show
  1. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +5 -5
  2. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  3. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -1
  4. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  5. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +15 -0
  6. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  7. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -1
  8. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  9. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -1
  10. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  11. package/dist/cjs/dictionaryManipulator/getNodeType.cjs +30 -22
  12. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  13. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -1
  14. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  15. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -1
  16. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  17. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -1
  18. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  19. package/dist/cjs/index.cjs +7 -0
  20. package/dist/cjs/interpreter/getContent/getContent.cjs +2 -1
  21. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  22. package/dist/cjs/interpreter/getContent/index.cjs +1 -0
  23. package/dist/cjs/interpreter/getContent/plugins.cjs +28 -0
  24. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  25. package/dist/cjs/interpreter/getSelect.cjs +36 -0
  26. package/dist/cjs/interpreter/getSelect.cjs.map +1 -0
  27. package/dist/cjs/interpreter/index.cjs +5 -0
  28. package/dist/cjs/messageFormat/ICU.cjs +23 -6
  29. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  30. package/dist/cjs/messageFormat/i18next.cjs +24 -6
  31. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  32. package/dist/cjs/messageFormat/resolveMessage.cjs +8 -0
  33. package/dist/cjs/messageFormat/resolveMessage.cjs.map +1 -1
  34. package/dist/cjs/messageFormat/vue-i18n.cjs +11 -2
  35. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  36. package/dist/cjs/transpiler/index.cjs +2 -0
  37. package/dist/cjs/transpiler/select/index.cjs +4 -0
  38. package/dist/cjs/transpiler/select/select.cjs +42 -0
  39. package/dist/cjs/transpiler/select/select.cjs.map +1 -0
  40. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +5 -5
  41. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  42. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -1
  43. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  44. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +15 -0
  45. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  46. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -1
  47. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  48. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -1
  49. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  50. package/dist/esm/dictionaryManipulator/getNodeType.mjs +30 -22
  51. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  52. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -1
  53. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  54. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -1
  55. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  56. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +1 -1
  57. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  58. package/dist/esm/index.mjs +5 -2
  59. package/dist/esm/interpreter/getContent/getContent.mjs +3 -2
  60. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  61. package/dist/esm/interpreter/getContent/index.mjs +2 -2
  62. package/dist/esm/interpreter/getContent/plugins.mjs +28 -1
  63. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  64. package/dist/esm/interpreter/getSelect.mjs +34 -0
  65. package/dist/esm/interpreter/getSelect.mjs.map +1 -0
  66. package/dist/esm/interpreter/index.mjs +4 -2
  67. package/dist/esm/messageFormat/ICU.mjs +23 -6
  68. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  69. package/dist/esm/messageFormat/i18next.mjs +24 -6
  70. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  71. package/dist/esm/messageFormat/resolveMessage.mjs +8 -0
  72. package/dist/esm/messageFormat/resolveMessage.mjs.map +1 -1
  73. package/dist/esm/messageFormat/vue-i18n.mjs +11 -2
  74. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  75. package/dist/esm/transpiler/index.mjs +2 -1
  76. package/dist/esm/transpiler/select/index.mjs +3 -0
  77. package/dist/esm/transpiler/select/select.mjs +41 -0
  78. package/dist/esm/transpiler/select/select.mjs.map +1 -0
  79. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -1
  80. package/dist/types/index.d.ts +5 -2
  81. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  82. package/dist/types/interpreter/getContent/index.d.ts +2 -2
  83. package/dist/types/interpreter/getContent/plugins.d.ts +22 -1
  84. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  85. package/dist/types/interpreter/getSelect.d.ts +31 -0
  86. package/dist/types/interpreter/getSelect.d.ts.map +1 -0
  87. package/dist/types/interpreter/index.d.ts +4 -2
  88. package/dist/types/messageFormat/ICU.d.ts.map +1 -1
  89. package/dist/types/messageFormat/i18next.d.ts.map +1 -1
  90. package/dist/types/messageFormat/resolveMessage.d.ts.map +1 -1
  91. package/dist/types/messageFormat/vue-i18n.d.ts.map +1 -1
  92. package/dist/types/transpiler/index.d.ts +3 -1
  93. package/dist/types/transpiler/select/index.d.ts +2 -0
  94. package/dist/types/transpiler/select/select.d.ts +62 -0
  95. package/dist/types/transpiler/select/select.d.ts.map +1 -0
  96. package/package.json +7 -7
@@ -13,29 +13,29 @@ const editDictionaryByKeyPath = (dictionaryContent, keyPath, newValue) => {
13
13
  for (let i = 0; i < keyPath.length; i++) {
14
14
  const keyObj = keyPath[i];
15
15
  parentValue = currentValue;
16
- if (keyObj.type === _intlayer_types_nodeType.OBJECT || keyObj.type === _intlayer_types_nodeType.ARRAY) {
16
+ if (keyObj?.type === _intlayer_types_nodeType.OBJECT || keyObj?.type === _intlayer_types_nodeType.ARRAY) {
17
17
  lastKeys = [keyObj.key];
18
18
  if (!currentValue[keyObj.key] || typeof currentValue[keyObj.key] !== "object") currentValue[keyObj.key] = {};
19
19
  currentValue = currentValue[keyObj.key];
20
20
  }
21
- if (keyObj.type === _intlayer_types_nodeType.TRANSLATION || keyObj.type === _intlayer_types_nodeType.ENUMERATION || keyObj.type === _intlayer_types_nodeType.PLURAL) {
21
+ if (keyObj?.type === _intlayer_types_nodeType.TRANSLATION || keyObj?.type === _intlayer_types_nodeType.ENUMERATION || keyObj?.type === _intlayer_types_nodeType.PLURAL || keyObj?.type === _intlayer_types_nodeType.GENDER || keyObj?.type === _intlayer_types_nodeType.SELECT) {
22
22
  lastKeys = [keyObj.type, keyObj.key];
23
23
  if (!currentValue[keyObj.type] || typeof currentValue[keyObj.type] !== "object") currentValue[keyObj.type] = {};
24
24
  if (!currentValue[keyObj.type][keyObj.key] || typeof currentValue[keyObj.type][keyObj.key] !== "object") currentValue[keyObj.type][keyObj.key] = {};
25
25
  currentValue = currentValue[keyObj.type][keyObj.key];
26
26
  }
27
- if (keyObj.type === _intlayer_types_nodeType.ENUMERATION || keyObj.type === _intlayer_types_nodeType.PLURAL || keyObj.type === _intlayer_types_nodeType.CONDITION) {
27
+ if (keyObj?.type === _intlayer_types_nodeType.ENUMERATION || keyObj?.type === _intlayer_types_nodeType.PLURAL || keyObj?.type === _intlayer_types_nodeType.CONDITION) {
28
28
  if (keyObj.type !== _intlayer_types_nodeType.ENUMERATION && keyObj.type !== _intlayer_types_nodeType.PLURAL) {
29
29
  lastKeys = [keyObj.type, keyObj.key];
30
30
  currentValue = currentValue[keyObj.type][keyObj.key];
31
31
  }
32
32
  }
33
- if (keyObj.type === _intlayer_types_nodeType.MARKDOWN || keyObj.type === _intlayer_types_nodeType.HTML || keyObj.type === _intlayer_types_nodeType.INSERTION) {
33
+ if (keyObj?.type === _intlayer_types_nodeType.MARKDOWN || keyObj?.type === _intlayer_types_nodeType.HTML || keyObj?.type === _intlayer_types_nodeType.INSERTION) {
34
34
  lastKeys = [keyObj.type];
35
35
  if (currentValue[keyObj.type] == null) currentValue[keyObj.type] = "";
36
36
  currentValue = currentValue[keyObj.type];
37
37
  }
38
- if (keyObj.type === _intlayer_types_nodeType.FILE) {
38
+ if (keyObj?.type === _intlayer_types_nodeType.FILE) {
39
39
  lastKeys = ["content"];
40
40
  currentValue = currentValue.content;
41
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"editDictionaryByKeyPath.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\ntype LastKeyType = string | number;\n\nexport const editDictionaryByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n newValue: ContentNode\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKeys: LastKeyType[] = [];\n\n if (keyPath.length === 0) {\n return newValue;\n }\n\n try {\n for (let i = 0; i < keyPath.length; i++) {\n const keyObj = keyPath[i];\n parentValue = currentValue;\n\n if (keyObj.type === NodeTypes.OBJECT || keyObj.type === NodeTypes.ARRAY) {\n lastKeys = [keyObj.key];\n\n if (\n !currentValue[keyObj.key] ||\n typeof currentValue[keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.TRANSLATION ||\n keyObj.type === NodeTypes.ENUMERATION ||\n keyObj.type === NodeTypes.PLURAL\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.ENUMERATION ||\n keyObj.type === NodeTypes.PLURAL ||\n keyObj.type === NodeTypes.CONDITION\n ) {\n // Note: Logic above already handles Enumeration/Plural, ensure no duplication in your actual file\n // or keep the specific block if your logic differs.\n // The important part is below in the final update block.\n\n // Assuming this block runs for Condition/Gender/etc:\n\n if (\n keyObj.type !== NodeTypes.ENUMERATION &&\n keyObj.type !== NodeTypes.PLURAL\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n }\n\n if (\n keyObj.type === NodeTypes.MARKDOWN ||\n keyObj.type === NodeTypes.HTML ||\n keyObj.type === NodeTypes.INSERTION\n ) {\n lastKeys = [keyObj.type];\n\n if (currentValue[keyObj.type] == null) {\n currentValue[keyObj.type] = '';\n }\n currentValue = currentValue[keyObj.type];\n }\n\n if (keyObj.type === NodeTypes.FILE) {\n lastKeys = ['content'];\n currentValue = currentValue.content;\n }\n\n // Only update the value when processing the last key in the keyPath.\n\n if (i === keyPath.length - 1 && parentValue && lastKeys.length > 0) {\n let target = parentValue;\n\n // Drill down to the container holding the value to be changed\n for (const key of lastKeys.slice(0, -1)) {\n target = target[key];\n }\n\n const finalKey = lastKeys[lastKeys.length - 1];\n\n if (typeof newValue === 'undefined') {\n // Use splice for arrays to re-index the list, use delete for objects\n\n if (Array.isArray(target)) {\n const index = Number(finalKey);\n\n if (!Number.isNaN(index) && index >= 0 && index < target.length) {\n target.splice(index, 1);\n }\n } else {\n delete target[finalKey];\n }\n } else {\n target[finalKey] = newValue;\n }\n }\n }\n\n return dictionaryContent;\n } catch (error) {\n console.error(\n 'Cannot edit dictionary by key path',\n { dictionaryContent, keyPath, newValue },\n error\n );\n return dictionaryContent;\n }\n};\n"],"mappings":";;;;;;AAMA,MAAa,2BACX,mBACA,SACA,aACgB;CAChB,IAAI,eAAoB;CACxB,IAAI,cAAmB;CACvB,IAAI,WAA0B,CAAC;CAE/B,IAAI,QAAQ,WAAW,GACrB,OAAO;CAGT,IAAI;EACF,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,SAAS,QAAQ;GACvB,cAAc;GAEd,IAAI,OAAO,SAASA,yBAAU,UAAU,OAAO,SAASA,yBAAU,OAAO;IACvE,WAAW,CAAC,OAAO,GAAG;IAEtB,IACE,CAAC,aAAa,OAAO,QACrB,OAAO,aAAa,OAAO,SAAS,UAEpC,aAAa,OAAO,OAAO,CAAC;IAE9B,eAAe,aAAa,OAAO;GACrC;GAEA,IACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,QAC1B;IACA,WAAW,CAAC,OAAO,MAAM,OAAO,GAAG;IAEnC,IACE,CAAC,aAAa,OAAO,SACrB,OAAO,aAAa,OAAO,UAAU,UAErC,aAAa,OAAO,QAAQ,CAAC;IAG/B,IACE,CAAC,aAAa,OAAO,KAAK,CAAC,OAAO,QAClC,OAAO,aAAa,OAAO,KAAK,CAAC,OAAO,SAAS,UAEjD,aAAa,OAAO,KAAK,CAAC,OAAO,OAAO,CAAC;IAE3C,eAAe,aAAa,OAAO,KAAK,CAAC,OAAO;GAClD;GAEA,IACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,UAC1B,OAAO,SAASA,yBAAU,WAQ1B;QACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,QAC1B;KACA,WAAW,CAAC,OAAO,MAAM,OAAO,GAAG;KACnC,eAAe,aAAa,OAAO,KAAK,CAAC,OAAO;IAClD;;GAGF,IACE,OAAO,SAASA,yBAAU,YAC1B,OAAO,SAASA,yBAAU,QAC1B,OAAO,SAASA,yBAAU,WAC1B;IACA,WAAW,CAAC,OAAO,IAAI;IAEvB,IAAI,aAAa,OAAO,SAAS,MAC/B,aAAa,OAAO,QAAQ;IAE9B,eAAe,aAAa,OAAO;GACrC;GAEA,IAAI,OAAO,SAASA,yBAAU,MAAM;IAClC,WAAW,CAAC,SAAS;IACrB,eAAe,aAAa;GAC9B;GAIA,IAAI,MAAM,QAAQ,SAAS,KAAK,eAAe,SAAS,SAAS,GAAG;IAClE,IAAI,SAAS;IAGb,KAAK,MAAM,OAAO,SAAS,MAAM,GAAG,EAAE,GACpC,SAAS,OAAO;IAGlB,MAAM,WAAW,SAAS,SAAS,SAAS;IAE5C,IAAI,OAAO,aAAa,aAGtB,IAAI,MAAM,QAAQ,MAAM,GAAG;KACzB,MAAM,QAAQ,OAAO,QAAQ;KAE7B,IAAI,CAAC,OAAO,MAAM,KAAK,KAAK,SAAS,KAAK,QAAQ,OAAO,QACvD,OAAO,OAAO,OAAO,CAAC;IAE1B,OACE,OAAO,OAAO;SAGhB,OAAO,YAAY;GAEvB;EACF;EAEA,OAAO;CACT,SAAS,OAAO;EACd,QAAQ,MACN,sCACA;GAAE;GAAmB;GAAS;EAAS,GACvC,KACF;EACA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"editDictionaryByKeyPath.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\ntype LastKeyType = string | number;\n\nexport const editDictionaryByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n newValue: ContentNode\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKeys: LastKeyType[] = [];\n\n if (keyPath.length === 0) {\n return newValue;\n }\n\n try {\n for (let i = 0; i < keyPath.length; i++) {\n const keyObj = keyPath[i];\n parentValue = currentValue;\n\n if (\n keyObj?.type === NodeTypes.OBJECT ||\n keyObj?.type === NodeTypes.ARRAY\n ) {\n lastKeys = [keyObj.key];\n\n if (\n !currentValue[keyObj.key] ||\n typeof currentValue[keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj?.type === NodeTypes.TRANSLATION ||\n keyObj?.type === NodeTypes.ENUMERATION ||\n keyObj?.type === NodeTypes.PLURAL ||\n keyObj?.type === NodeTypes.GENDER ||\n keyObj?.type === NodeTypes.SELECT\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj?.type === NodeTypes.ENUMERATION ||\n keyObj?.type === NodeTypes.PLURAL ||\n keyObj?.type === NodeTypes.CONDITION\n ) {\n // Note: Logic above already handles Enumeration/Plural, ensure no duplication in your actual file\n // or keep the specific block if your logic differs.\n // The important part is below in the final update block.\n\n // Assuming this block runs for Condition/Gender/etc:\n\n if (\n keyObj.type !== NodeTypes.ENUMERATION &&\n keyObj.type !== NodeTypes.PLURAL\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n }\n\n if (\n keyObj?.type === NodeTypes.MARKDOWN ||\n keyObj?.type === NodeTypes.HTML ||\n keyObj?.type === NodeTypes.INSERTION\n ) {\n lastKeys = [keyObj.type];\n\n if (currentValue[keyObj.type] == null) {\n currentValue[keyObj.type] = '';\n }\n currentValue = currentValue[keyObj.type];\n }\n\n if (keyObj?.type === NodeTypes.FILE) {\n lastKeys = ['content'];\n currentValue = currentValue.content;\n }\n\n // Only update the value when processing the last key in the keyPath.\n\n if (i === keyPath.length - 1 && parentValue && lastKeys.length > 0) {\n let target = parentValue;\n\n // Drill down to the container holding the value to be changed\n for (const key of lastKeys.slice(0, -1)) {\n target = target[key];\n }\n\n const finalKey = lastKeys[lastKeys.length - 1];\n\n if (typeof newValue === 'undefined') {\n // Use splice for arrays to re-index the list, use delete for objects\n\n if (Array.isArray(target)) {\n const index = Number(finalKey);\n\n if (!Number.isNaN(index) && index >= 0 && index < target.length) {\n target.splice(index, 1);\n }\n } else {\n delete target[finalKey];\n }\n } else {\n target[finalKey] = newValue;\n }\n }\n }\n\n return dictionaryContent;\n } catch (error) {\n console.error(\n 'Cannot edit dictionary by key path',\n { dictionaryContent, keyPath, newValue },\n error\n );\n return dictionaryContent;\n }\n};\n"],"mappings":";;;;;;AAMA,MAAa,2BACX,mBACA,SACA,aACgB;CAChB,IAAI,eAAoB;CACxB,IAAI,cAAmB;CACvB,IAAI,WAA0B,CAAC;CAE/B,IAAI,QAAQ,WAAW,GACrB,OAAO;CAGT,IAAI;EACF,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,SAAS,QAAQ;GACvB,cAAc;GAEd,IACE,QAAQ,SAASA,yBAAU,UAC3B,QAAQ,SAASA,yBAAU,OAC3B;IACA,WAAW,CAAC,OAAO,GAAG;IAEtB,IACE,CAAC,aAAa,OAAO,QACrB,OAAO,aAAa,OAAO,SAAS,UAEpC,aAAa,OAAO,OAAO,CAAC;IAE9B,eAAe,aAAa,OAAO;GACrC;GAEA,IACE,QAAQ,SAASA,yBAAU,eAC3B,QAAQ,SAASA,yBAAU,eAC3B,QAAQ,SAASA,yBAAU,UAC3B,QAAQ,SAASA,yBAAU,UAC3B,QAAQ,SAASA,yBAAU,QAC3B;IACA,WAAW,CAAC,OAAO,MAAM,OAAO,GAAG;IAEnC,IACE,CAAC,aAAa,OAAO,SACrB,OAAO,aAAa,OAAO,UAAU,UAErC,aAAa,OAAO,QAAQ,CAAC;IAG/B,IACE,CAAC,aAAa,OAAO,KAAK,CAAC,OAAO,QAClC,OAAO,aAAa,OAAO,KAAK,CAAC,OAAO,SAAS,UAEjD,aAAa,OAAO,KAAK,CAAC,OAAO,OAAO,CAAC;IAE3C,eAAe,aAAa,OAAO,KAAK,CAAC,OAAO;GAClD;GAEA,IACE,QAAQ,SAASA,yBAAU,eAC3B,QAAQ,SAASA,yBAAU,UAC3B,QAAQ,SAASA,yBAAU,WAQ3B;QACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,QAC1B;KACA,WAAW,CAAC,OAAO,MAAM,OAAO,GAAG;KACnC,eAAe,aAAa,OAAO,KAAK,CAAC,OAAO;IAClD;;GAGF,IACE,QAAQ,SAASA,yBAAU,YAC3B,QAAQ,SAASA,yBAAU,QAC3B,QAAQ,SAASA,yBAAU,WAC3B;IACA,WAAW,CAAC,OAAO,IAAI;IAEvB,IAAI,aAAa,OAAO,SAAS,MAC/B,aAAa,OAAO,QAAQ;IAE9B,eAAe,aAAa,OAAO;GACrC;GAEA,IAAI,QAAQ,SAASA,yBAAU,MAAM;IACnC,WAAW,CAAC,SAAS;IACrB,eAAe,aAAa;GAC9B;GAIA,IAAI,MAAM,QAAQ,SAAS,KAAK,eAAe,SAAS,SAAS,GAAG;IAClE,IAAI,SAAS;IAGb,KAAK,MAAM,OAAO,SAAS,MAAM,GAAG,EAAE,GACpC,SAAS,OAAO;IAGlB,MAAM,WAAW,SAAS,SAAS,SAAS;IAE5C,IAAI,OAAO,aAAa,aAGtB,IAAI,MAAM,QAAQ,MAAM,GAAG;KACzB,MAAM,QAAQ,OAAO,QAAQ;KAE7B,IAAI,CAAC,OAAO,MAAM,KAAK,KAAK,SAAS,KAAK,QAAQ,OAAO,QACvD,OAAO,OAAO,OAAO,CAAC;IAE1B,OACE,OAAO,OAAO;SAGhB,OAAO,YAAY;GAEvB;EACF;EAEA,OAAO;CACT,SAAS,OAAO;EACd,QAAQ,MACN,sCACA;GAAE;GAAmB;GAAS;EAAS,GACvC,KACF;EACA,OAAO;CACT;AACF"}
@@ -9,7 +9,7 @@ const getContentNodeByKeyPath = (dictionaryContent, keyPath, fallbackLocale) =>
9
9
  for (const keyObj of keyPath) {
10
10
  if (fallbackLocale && currentValue?.nodeType === _intlayer_types_nodeType.TRANSLATION) currentValue = currentValue?.[_intlayer_types_nodeType.TRANSLATION]?.[fallbackLocale];
11
11
  if (keyObj.type === _intlayer_types_nodeType.OBJECT || keyObj.type === _intlayer_types_nodeType.ARRAY) currentValue = currentValue?.[keyObj.key];
12
- if (keyObj.type === _intlayer_types_nodeType.TRANSLATION || keyObj.type === _intlayer_types_nodeType.CONDITION || keyObj.type === _intlayer_types_nodeType.ENUMERATION || keyObj.type === _intlayer_types_nodeType.PLURAL) currentValue = currentValue?.[keyObj.type]?.[keyObj.key];
12
+ if (keyObj.type === _intlayer_types_nodeType.TRANSLATION || keyObj.type === _intlayer_types_nodeType.CONDITION || keyObj.type === _intlayer_types_nodeType.ENUMERATION || keyObj.type === _intlayer_types_nodeType.PLURAL || keyObj.type === _intlayer_types_nodeType.GENDER || keyObj.type === _intlayer_types_nodeType.SELECT) currentValue = currentValue?.[keyObj.type]?.[keyObj.key];
13
13
  if (keyObj.type === _intlayer_types_nodeType.MARKDOWN || keyObj.type === _intlayer_types_nodeType.HTML || keyObj.type === _intlayer_types_nodeType.INSERTION || keyObj.type === _intlayer_types_nodeType.FILE) currentValue = currentValue?.[keyObj.type];
14
14
  }
15
15
  return currentValue;
@@ -1 +1 @@
1
- {"version":3,"file":"getContentNodeByKeyPath.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n fallbackLocale?: LocalesValues\n): ContentNode => {\n let currentValue: any = structuredClone(dictionaryContent);\n\n for (const keyObj of keyPath) {\n // Auto-resolve translation nodes when fallbackLocale is provided\n if (fallbackLocale && currentValue?.nodeType === NodeTypes.TRANSLATION) {\n currentValue = currentValue?.[NodeTypes.TRANSLATION]?.[fallbackLocale];\n }\n\n if (keyObj.type === NodeTypes.OBJECT || keyObj.type === NodeTypes.ARRAY) {\n currentValue = currentValue?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.TRANSLATION ||\n keyObj.type === NodeTypes.CONDITION ||\n keyObj.type === NodeTypes.ENUMERATION ||\n keyObj.type === NodeTypes.PLURAL\n ) {\n currentValue = currentValue?.[keyObj.type]?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.MARKDOWN ||\n keyObj.type === NodeTypes.HTML ||\n keyObj.type === NodeTypes.INSERTION ||\n keyObj.type === NodeTypes.FILE\n ) {\n currentValue = currentValue?.[keyObj.type];\n }\n }\n\n return currentValue as ContentNode;\n};\n"],"mappings":";;;;;;AAKA,MAAa,2BACX,mBACA,SACA,mBACgB;CAChB,IAAI,eAAoB,gBAAgB,iBAAiB;CAEzD,KAAK,MAAM,UAAU,SAAS;EAE5B,IAAI,kBAAkB,cAAc,aAAaA,yBAAU,aACzD,eAAe,eAAeA,yBAAU,YAAY,GAAG;EAGzD,IAAI,OAAO,SAASA,yBAAU,UAAU,OAAO,SAASA,yBAAU,OAChE,eAAe,eAAe,OAAO;EAGvC,IACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,QAE1B,eAAe,eAAe,OAAO,KAAK,GAAG,OAAO;EAGtD,IACE,OAAO,SAASA,yBAAU,YAC1B,OAAO,SAASA,yBAAU,QAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,MAE1B,eAAe,eAAe,OAAO;CAEzC;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"getContentNodeByKeyPath.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n fallbackLocale?: LocalesValues\n): ContentNode => {\n let currentValue: any = structuredClone(dictionaryContent);\n\n for (const keyObj of keyPath) {\n // Auto-resolve translation nodes when fallbackLocale is provided\n if (fallbackLocale && currentValue?.nodeType === NodeTypes.TRANSLATION) {\n currentValue = currentValue?.[NodeTypes.TRANSLATION]?.[fallbackLocale];\n }\n\n if (keyObj.type === NodeTypes.OBJECT || keyObj.type === NodeTypes.ARRAY) {\n currentValue = currentValue?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.TRANSLATION ||\n keyObj.type === NodeTypes.CONDITION ||\n keyObj.type === NodeTypes.ENUMERATION ||\n keyObj.type === NodeTypes.PLURAL ||\n keyObj.type === NodeTypes.GENDER ||\n keyObj.type === NodeTypes.SELECT\n ) {\n currentValue = currentValue?.[keyObj.type]?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.MARKDOWN ||\n keyObj.type === NodeTypes.HTML ||\n keyObj.type === NodeTypes.INSERTION ||\n keyObj.type === NodeTypes.FILE\n ) {\n currentValue = currentValue?.[keyObj.type];\n }\n }\n\n return currentValue as ContentNode;\n};\n"],"mappings":";;;;;;AAKA,MAAa,2BACX,mBACA,SACA,mBACgB;CAChB,IAAI,eAAoB,gBAAgB,iBAAiB;CAEzD,KAAK,MAAM,UAAU,SAAS;EAE5B,IAAI,kBAAkB,cAAc,aAAaA,yBAAU,aACzD,eAAe,eAAeA,yBAAU,YAAY,GAAG;EAGzD,IAAI,OAAO,SAASA,yBAAU,UAAU,OAAO,SAASA,yBAAU,OAChE,eAAe,eAAe,OAAO;EAGvC,IACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,UAC1B,OAAO,SAASA,yBAAU,UAC1B,OAAO,SAASA,yBAAU,QAE1B,eAAe,eAAe,OAAO,KAAK,GAAG,OAAO;EAGtD,IACE,OAAO,SAASA,yBAAU,YAC1B,OAAO,SAASA,yBAAU,QAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,MAE1B,eAAe,eAAe,OAAO;CAEzC;CAEA,OAAO;AACT"}
@@ -29,6 +29,21 @@ const getDefaultNode = (nodeType, locales, content) => {
29
29
  false: clonedContent ?? ""
30
30
  }
31
31
  };
32
+ case _intlayer_types_nodeType.GENDER: return {
33
+ nodeType: _intlayer_types_nodeType.GENDER,
34
+ [_intlayer_types_nodeType.GENDER]: {
35
+ male: clonedContent ?? "",
36
+ female: clonedContent ?? "",
37
+ fallback: clonedContent ?? ""
38
+ }
39
+ };
40
+ case _intlayer_types_nodeType.SELECT: return {
41
+ nodeType: _intlayer_types_nodeType.SELECT,
42
+ [_intlayer_types_nodeType.SELECT]: {
43
+ case1: clonedContent ?? "",
44
+ fallback: clonedContent ?? ""
45
+ }
46
+ };
32
47
  case _intlayer_types_nodeType.INSERTION: return {
33
48
  nodeType: _intlayer_types_nodeType.INSERTION,
34
49
  [_intlayer_types_nodeType.INSERTION]: { insertion: clonedContent ?? "" }
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultNode.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getDefaultNode = (\n nodeType: NodeType,\n locales: LocalesValues[],\n content?: ContentNode\n): ContentNode => {\n const clonedContent = structuredClone(content);\n switch (nodeType) {\n case NodeTypes.TRANSLATION:\n return {\n nodeType: NodeTypes.TRANSLATION,\n [NodeTypes.TRANSLATION]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: structuredClone(clonedContent) ?? '',\n }))\n ),\n } as ContentNode;\n\n case NodeTypes.ENUMERATION:\n return {\n nodeType: NodeTypes.ENUMERATION,\n [NodeTypes.ENUMERATION]: {\n '1': clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeTypes.PLURAL:\n return {\n nodeType: NodeTypes.PLURAL,\n [NodeTypes.PLURAL]: {\n one: clonedContent ?? '',\n other: clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeTypes.CONDITION:\n return {\n nodeType: NodeTypes.CONDITION,\n [NodeTypes.CONDITION]: {\n true: clonedContent ?? '',\n false: clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeTypes.INSERTION:\n return {\n nodeType: NodeTypes.INSERTION,\n [NodeTypes.INSERTION]: {\n insertion: clonedContent ?? '',\n },\n } as unknown as ContentNode;\n\n case NodeTypes.NESTED:\n return {\n nodeType: NodeTypes.NESTED,\n [NodeTypes.NESTED]: {\n dictionaryKey: '',\n },\n } as ContentNode;\n\n case NodeTypes.MARKDOWN:\n return {\n nodeType: NodeTypes.MARKDOWN,\n [NodeTypes.MARKDOWN]: clonedContent ?? '',\n } as ContentNode;\n\n case NodeTypes.HTML:\n return {\n nodeType: NodeTypes.HTML,\n [NodeTypes.HTML]: clonedContent ?? '',\n customComponents: [],\n } as ContentNode;\n\n case NodeTypes.FILE:\n return {\n nodeType: NodeTypes.FILE,\n [NodeTypes.FILE]: clonedContent ?? '',\n } as ContentNode;\n\n case NodeTypes.OBJECT:\n return {\n newKey: clonedContent ?? '',\n } as unknown as ContentNode;\n\n case NodeTypes.ARRAY:\n return [clonedContent ?? ''] as unknown as ContentNode;\n\n case NodeTypes.TEXT:\n return clonedContent ?? '';\n\n case NodeTypes.NUMBER:\n return clonedContent ?? 0;\n\n case NodeTypes.BOOLEAN:\n return clonedContent ?? true;\n\n default:\n return clonedContent ?? '';\n }\n};\n"],"mappings":";;;;;;AAMA,MAAa,kBACX,UACA,SACA,YACgB;CAChB,MAAM,gBAAgB,gBAAgB,OAAO;CAC7C,QAAQ,UAAR;EACE,KAAKA,yBAAU,aACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,cAAc,OAAO,OAC9B,CAAC,GACD,GAAG,QAAQ,KAAK,YAAY,GACzB,SAAS,gBAAgB,aAAa,KAAK,GAC9C,EAAE,CACJ;EACF;EAEF,KAAKA,yBAAU,aACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,cAAc,EACvB,KAAK,iBAAiB,GACxB;EACF;EAEF,KAAKA,yBAAU,QACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,SAAS;IAClB,KAAK,iBAAiB;IACtB,OAAO,iBAAiB;GAC1B;EACF;EAEF,KAAKA,yBAAU,WACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,YAAY;IACrB,MAAM,iBAAiB;IACvB,OAAO,iBAAiB;GAC1B;EACF;EAEF,KAAKA,yBAAU,WACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,YAAY,EACrB,WAAW,iBAAiB,GAC9B;EACF;EAEF,KAAKA,yBAAU,QACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,SAAS,EAClB,eAAe,GACjB;EACF;EAEF,KAAKA,yBAAU,UACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,WAAW,iBAAiB;EACzC;EAEF,KAAKA,yBAAU,MACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,OAAO,iBAAiB;GACnC,kBAAkB,CAAC;EACrB;EAEF,KAAKA,yBAAU,MACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,OAAO,iBAAiB;EACrC;EAEF,KAAKA,yBAAU,QACb,OAAO,EACL,QAAQ,iBAAiB,GAC3B;EAEF,KAAKA,yBAAU,OACb,OAAO,CAAC,iBAAiB,EAAE;EAE7B,KAAKA,yBAAU,MACb,OAAO,iBAAiB;EAE1B,KAAKA,yBAAU,QACb,OAAO,iBAAiB;EAE1B,KAAKA,yBAAU,SACb,OAAO,iBAAiB;EAE1B,SACE,OAAO,iBAAiB;CAC5B;AACF"}
1
+ {"version":3,"file":"getDefaultNode.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getDefaultNode = (\n nodeType: NodeType,\n locales: LocalesValues[],\n content?: ContentNode\n): ContentNode => {\n const clonedContent = structuredClone(content);\n switch (nodeType) {\n case NodeTypes.TRANSLATION:\n return {\n nodeType: NodeTypes.TRANSLATION,\n [NodeTypes.TRANSLATION]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: structuredClone(clonedContent) ?? '',\n }))\n ),\n } as ContentNode;\n\n case NodeTypes.ENUMERATION:\n return {\n nodeType: NodeTypes.ENUMERATION,\n [NodeTypes.ENUMERATION]: {\n '1': clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeTypes.PLURAL:\n return {\n nodeType: NodeTypes.PLURAL,\n [NodeTypes.PLURAL]: {\n one: clonedContent ?? '',\n other: clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeTypes.CONDITION:\n return {\n nodeType: NodeTypes.CONDITION,\n [NodeTypes.CONDITION]: {\n true: clonedContent ?? '',\n false: clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeTypes.GENDER:\n return {\n nodeType: NodeTypes.GENDER,\n [NodeTypes.GENDER]: {\n male: clonedContent ?? '',\n female: clonedContent ?? '',\n fallback: clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeTypes.SELECT:\n return {\n nodeType: NodeTypes.SELECT,\n [NodeTypes.SELECT]: {\n case1: clonedContent ?? '',\n fallback: clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeTypes.INSERTION:\n return {\n nodeType: NodeTypes.INSERTION,\n [NodeTypes.INSERTION]: {\n insertion: clonedContent ?? '',\n },\n } as unknown as ContentNode;\n\n case NodeTypes.NESTED:\n return {\n nodeType: NodeTypes.NESTED,\n [NodeTypes.NESTED]: {\n dictionaryKey: '',\n },\n } as ContentNode;\n\n case NodeTypes.MARKDOWN:\n return {\n nodeType: NodeTypes.MARKDOWN,\n [NodeTypes.MARKDOWN]: clonedContent ?? '',\n } as ContentNode;\n\n case NodeTypes.HTML:\n return {\n nodeType: NodeTypes.HTML,\n [NodeTypes.HTML]: clonedContent ?? '',\n customComponents: [],\n } as ContentNode;\n\n case NodeTypes.FILE:\n return {\n nodeType: NodeTypes.FILE,\n [NodeTypes.FILE]: clonedContent ?? '',\n } as ContentNode;\n\n case NodeTypes.OBJECT:\n return {\n newKey: clonedContent ?? '',\n } as unknown as ContentNode;\n\n case NodeTypes.ARRAY:\n return [clonedContent ?? ''] as unknown as ContentNode;\n\n case NodeTypes.TEXT:\n return clonedContent ?? '';\n\n case NodeTypes.NUMBER:\n return clonedContent ?? 0;\n\n case NodeTypes.BOOLEAN:\n return clonedContent ?? true;\n\n default:\n return clonedContent ?? '';\n }\n};\n"],"mappings":";;;;;;AAMA,MAAa,kBACX,UACA,SACA,YACgB;CAChB,MAAM,gBAAgB,gBAAgB,OAAO;CAC7C,QAAQ,UAAR;EACE,KAAKA,yBAAU,aACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,cAAc,OAAO,OAC9B,CAAC,GACD,GAAG,QAAQ,KAAK,YAAY,GACzB,SAAS,gBAAgB,aAAa,KAAK,GAC9C,EAAE,CACJ;EACF;EAEF,KAAKA,yBAAU,aACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,cAAc,EACvB,KAAK,iBAAiB,GACxB;EACF;EAEF,KAAKA,yBAAU,QACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,SAAS;IAClB,KAAK,iBAAiB;IACtB,OAAO,iBAAiB;GAC1B;EACF;EAEF,KAAKA,yBAAU,WACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,YAAY;IACrB,MAAM,iBAAiB;IACvB,OAAO,iBAAiB;GAC1B;EACF;EAEF,KAAKA,yBAAU,QACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,SAAS;IAClB,MAAM,iBAAiB;IACvB,QAAQ,iBAAiB;IACzB,UAAU,iBAAiB;GAC7B;EACF;EAEF,KAAKA,yBAAU,QACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,SAAS;IAClB,OAAO,iBAAiB;IACxB,UAAU,iBAAiB;GAC7B;EACF;EAEF,KAAKA,yBAAU,WACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,YAAY,EACrB,WAAW,iBAAiB,GAC9B;EACF;EAEF,KAAKA,yBAAU,QACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,SAAS,EAClB,eAAe,GACjB;EACF;EAEF,KAAKA,yBAAU,UACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,WAAW,iBAAiB;EACzC;EAEF,KAAKA,yBAAU,MACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,OAAO,iBAAiB;GACnC,kBAAkB,CAAC;EACrB;EAEF,KAAKA,yBAAU,MACb,OAAO;GACL,UAAUA,yBAAU;IACnBA,yBAAU,OAAO,iBAAiB;EACrC;EAEF,KAAKA,yBAAU,QACb,OAAO,EACL,QAAQ,iBAAiB,GAC3B;EAEF,KAAKA,yBAAU,OACb,OAAO,CAAC,iBAAiB,EAAE;EAE7B,KAAKA,yBAAU,MACb,OAAO,iBAAiB;EAE1B,KAAKA,yBAAU,QACb,OAAO,iBAAiB;EAE1B,KAAKA,yBAAU,SACb,OAAO,iBAAiB;EAE1B,SACE,OAAO,iBAAiB;CAC5B;AACF"}
@@ -11,7 +11,7 @@ const getEmptyNode = (section) => {
11
11
  if (typeof section?.nodeType === "string") {
12
12
  const typedNode = section;
13
13
  const content = typedNode[typedNode.nodeType];
14
- if (typedNode.nodeType === _intlayer_types_nodeType.TRANSLATION || typedNode.nodeType === _intlayer_types_nodeType.ENUMERATION || typedNode.nodeType === _intlayer_types_nodeType.PLURAL || typedNode.nodeType === _intlayer_types_nodeType.CONDITION || typedNode.nodeType === _intlayer_types_nodeType.INSERTION || typedNode.nodeType === _intlayer_types_nodeType.HTML) return getEmptyNode(content);
14
+ if (typedNode.nodeType === _intlayer_types_nodeType.TRANSLATION || typedNode.nodeType === _intlayer_types_nodeType.ENUMERATION || typedNode.nodeType === _intlayer_types_nodeType.PLURAL || typedNode.nodeType === _intlayer_types_nodeType.CONDITION || typedNode.nodeType === _intlayer_types_nodeType.INSERTION || typedNode.nodeType === _intlayer_types_nodeType.GENDER || typedNode.nodeType === _intlayer_types_nodeType.SELECT || typedNode.nodeType === _intlayer_types_nodeType.HTML) return getEmptyNode(content);
15
15
  if (typedNode.nodeType === _intlayer_types_nodeType.NESTED) return "dictionary-key";
16
16
  if (typedNode.nodeType === _intlayer_types_nodeType.FILE) return "file/path";
17
17
  if (typedNode.nodeType === _intlayer_types_nodeType.MARKDOWN) return getEmptyNode(content);
@@ -1 +1 @@
1
- {"version":3,"file":"getEmptyNode.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/getEmptyNode.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getEmptyNode = (section: ContentNode): ContentNode => {\n if (typeof section === 'string') {\n return '';\n }\n if (typeof section === 'number') {\n return 0;\n }\n if (typeof section === 'boolean') {\n return true;\n }\n if (typeof (section as TypedNode)?.nodeType === 'string') {\n const typedNode = section as TypedNode;\n const content =\n typedNode[typedNode.nodeType as unknown as keyof typeof typedNode];\n\n if (\n typedNode.nodeType === NodeTypes.TRANSLATION ||\n typedNode.nodeType === NodeTypes.ENUMERATION ||\n typedNode.nodeType === NodeTypes.PLURAL ||\n typedNode.nodeType === NodeTypes.CONDITION ||\n typedNode.nodeType === NodeTypes.INSERTION ||\n typedNode.nodeType === NodeTypes.HTML\n ) {\n return getEmptyNode(content as ContentNode);\n }\n\n if (typedNode.nodeType === NodeTypes.NESTED) {\n return 'dictionary-key';\n }\n\n if (typedNode.nodeType === NodeTypes.FILE) {\n return 'file/path';\n }\n\n if (typedNode.nodeType === NodeTypes.MARKDOWN) {\n return getEmptyNode(content as ContentNode);\n }\n\n return content;\n }\n\n if (!section || typeof section !== 'object') {\n return section;\n }\n\n if (Array.isArray(section)) {\n return (section as ContentNode[]).map(\n getEmptyNode\n ) as unknown as ContentNode;\n }\n\n const mappedSectionObject = Object.entries(section).map(([key, value]) => [\n key,\n getEmptyNode(value as ContentNode),\n ]);\n\n const mappedSectionArray = Object.fromEntries(mappedSectionObject);\n\n return mappedSectionArray;\n};\n"],"mappings":";;;;;;AAIA,MAAa,gBAAgB,YAAsC;CACjE,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,WACrB,OAAO;CAET,IAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;EAEtB,IACE,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,aACjC,UAAU,aAAaA,yBAAU,aACjC,UAAU,aAAaA,yBAAU,MAEjC,OAAO,aAAa,OAAsB;EAG5C,IAAI,UAAU,aAAaA,yBAAU,QACnC,OAAO;EAGT,IAAI,UAAU,aAAaA,yBAAU,MACnC,OAAO;EAGT,IAAI,UAAU,aAAaA,yBAAU,UACnC,OAAO,aAAa,OAAsB;EAG5C,OAAO;CACT;CAEA,IAAI,CAAC,WAAW,OAAO,YAAY,UACjC,OAAO;CAGT,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAQ,QAA0B,IAChC,YACF;CAGF,MAAM,sBAAsB,OAAO,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CACxE,KACA,aAAa,KAAoB,CACnC,CAAC;CAID,OAF2B,OAAO,YAAY,mBAEtB;AAC1B"}
1
+ {"version":3,"file":"getEmptyNode.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/getEmptyNode.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getEmptyNode = (section: ContentNode): ContentNode => {\n if (typeof section === 'string') {\n return '';\n }\n if (typeof section === 'number') {\n return 0;\n }\n if (typeof section === 'boolean') {\n return true;\n }\n if (typeof (section as TypedNode)?.nodeType === 'string') {\n const typedNode = section as TypedNode;\n const content =\n typedNode[typedNode.nodeType as unknown as keyof typeof typedNode];\n\n if (\n typedNode.nodeType === NodeTypes.TRANSLATION ||\n typedNode.nodeType === NodeTypes.ENUMERATION ||\n typedNode.nodeType === NodeTypes.PLURAL ||\n typedNode.nodeType === NodeTypes.CONDITION ||\n typedNode.nodeType === NodeTypes.INSERTION ||\n typedNode.nodeType === NodeTypes.GENDER ||\n typedNode.nodeType === NodeTypes.SELECT ||\n typedNode.nodeType === NodeTypes.HTML\n ) {\n return getEmptyNode(content as ContentNode);\n }\n\n if (typedNode.nodeType === NodeTypes.NESTED) {\n return 'dictionary-key';\n }\n\n if (typedNode.nodeType === NodeTypes.FILE) {\n return 'file/path';\n }\n\n if (typedNode.nodeType === NodeTypes.MARKDOWN) {\n return getEmptyNode(content as ContentNode);\n }\n\n return content;\n }\n\n if (!section || typeof section !== 'object') {\n return section;\n }\n\n if (Array.isArray(section)) {\n return (section as ContentNode[]).map(\n getEmptyNode\n ) as unknown as ContentNode;\n }\n\n const mappedSectionObject = Object.entries(section).map(([key, value]) => [\n key,\n getEmptyNode(value as ContentNode),\n ]);\n\n const mappedSectionArray = Object.fromEntries(mappedSectionObject);\n\n return mappedSectionArray;\n};\n"],"mappings":";;;;;;AAIA,MAAa,gBAAgB,YAAsC;CACjE,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,WACrB,OAAO;CAET,IAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;EAEtB,IACE,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,aACjC,UAAU,aAAaA,yBAAU,aACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,MAEjC,OAAO,aAAa,OAAsB;EAG5C,IAAI,UAAU,aAAaA,yBAAU,QACnC,OAAO;EAGT,IAAI,UAAU,aAAaA,yBAAU,MACnC,OAAO;EAGT,IAAI,UAAU,aAAaA,yBAAU,UACnC,OAAO,aAAa,OAAsB;EAG5C,OAAO;CACT;CAEA,IAAI,CAAC,WAAW,OAAO,YAAY,UACjC,OAAO;CAGT,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAQ,QAA0B,IAChC,YACF;CAGF,MAAM,sBAAsB,OAAO,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CACxE,KACA,aAAa,KAAoB,CACnC,CAAC;CAID,OAF2B,OAAO,YAAY,mBAEtB;AAC1B"}
@@ -12,7 +12,7 @@ const getNodeChildren = (section) => {
12
12
  const typedNode = section;
13
13
  const content = typedNode[typedNode.nodeType];
14
14
  if (typedNode.nodeType === _intlayer_types_nodeType.MARKDOWN || typedNode.nodeType === _intlayer_types_nodeType.HTML) return content;
15
- if (typedNode.nodeType === _intlayer_types_nodeType.TRANSLATION || typedNode.nodeType === _intlayer_types_nodeType.ENUMERATION || typedNode.nodeType === _intlayer_types_nodeType.PLURAL || typedNode.nodeType === _intlayer_types_nodeType.CONDITION || typedNode.nodeType === _intlayer_types_nodeType.INSERTION || typedNode.nodeType === _intlayer_types_nodeType.GENDER || typedNode.nodeType === _intlayer_types_nodeType.FILE) return content[Object.keys(content)[0]];
15
+ if (typedNode.nodeType === _intlayer_types_nodeType.TRANSLATION || typedNode.nodeType === _intlayer_types_nodeType.ENUMERATION || typedNode.nodeType === _intlayer_types_nodeType.PLURAL || typedNode.nodeType === _intlayer_types_nodeType.CONDITION || typedNode.nodeType === _intlayer_types_nodeType.INSERTION || typedNode.nodeType === _intlayer_types_nodeType.GENDER || typedNode.nodeType === _intlayer_types_nodeType.SELECT || typedNode.nodeType === _intlayer_types_nodeType.FILE) return content[Object.keys(content)[0]];
16
16
  if (typedNode.nodeType === _intlayer_types_nodeType.NESTED) return;
17
17
  return content;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getNodeChildren.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/getNodeChildren.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getNodeChildren = (section: ContentNode): ContentNode => {\n if (typeof section === 'string') {\n return section;\n }\n if (typeof section === 'number') {\n return section;\n }\n if (typeof section === 'boolean') {\n return section;\n }\n if (typeof (section as TypedNode)?.nodeType === 'string') {\n const typedNode = section as TypedNode;\n const content =\n typedNode[typedNode.nodeType as unknown as keyof typeof typedNode];\n\n if (\n typedNode.nodeType === NodeTypes.MARKDOWN ||\n typedNode.nodeType === NodeTypes.HTML\n ) {\n return content as ContentNode;\n }\n\n if (\n typedNode.nodeType === NodeTypes.TRANSLATION ||\n typedNode.nodeType === NodeTypes.ENUMERATION ||\n typedNode.nodeType === NodeTypes.PLURAL ||\n typedNode.nodeType === NodeTypes.CONDITION ||\n typedNode.nodeType === NodeTypes.INSERTION ||\n typedNode.nodeType === NodeTypes.GENDER ||\n typedNode.nodeType === NodeTypes.FILE\n ) {\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n return content[firstKey] as ContentNode;\n }\n\n if (typedNode.nodeType === NodeTypes.NESTED) {\n return undefined;\n }\n\n return content;\n }\n\n if (!section || typeof section !== 'object') {\n return section;\n }\n\n if (Array.isArray(section)) {\n return (section as ContentNode[])[0];\n }\n\n return section;\n};\n"],"mappings":";;;;;;AAIA,MAAa,mBAAmB,YAAsC;CACpE,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,WACrB,OAAO;CAET,IAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;EAEtB,IACE,UAAU,aAAaA,yBAAU,YACjC,UAAU,aAAaA,yBAAU,MAEjC,OAAO;EAGT,IACE,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,aACjC,UAAU,aAAaA,yBAAU,aACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,MAGjC,OAAO,QADU,OAAO,KAAK,OAAO,CAAC,CAAC;EAIxC,IAAI,UAAU,aAAaA,yBAAU,QACnC;EAGF,OAAO;CACT;CAEA,IAAI,CAAC,WAAW,OAAO,YAAY,UACjC,OAAO;CAGT,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAQ,QAA0B;CAGpC,OAAO;AACT"}
1
+ {"version":3,"file":"getNodeChildren.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/getNodeChildren.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const getNodeChildren = (section: ContentNode): ContentNode => {\n if (typeof section === 'string') {\n return section;\n }\n if (typeof section === 'number') {\n return section;\n }\n if (typeof section === 'boolean') {\n return section;\n }\n if (typeof (section as TypedNode)?.nodeType === 'string') {\n const typedNode = section as TypedNode;\n const content =\n typedNode[typedNode.nodeType as unknown as keyof typeof typedNode];\n\n if (\n typedNode.nodeType === NodeTypes.MARKDOWN ||\n typedNode.nodeType === NodeTypes.HTML\n ) {\n return content as ContentNode;\n }\n\n if (\n typedNode.nodeType === NodeTypes.TRANSLATION ||\n typedNode.nodeType === NodeTypes.ENUMERATION ||\n typedNode.nodeType === NodeTypes.PLURAL ||\n typedNode.nodeType === NodeTypes.CONDITION ||\n typedNode.nodeType === NodeTypes.INSERTION ||\n typedNode.nodeType === NodeTypes.GENDER ||\n typedNode.nodeType === NodeTypes.SELECT ||\n typedNode.nodeType === NodeTypes.FILE\n ) {\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n return content[firstKey] as ContentNode;\n }\n\n if (typedNode.nodeType === NodeTypes.NESTED) {\n return undefined;\n }\n\n return content;\n }\n\n if (!section || typeof section !== 'object') {\n return section;\n }\n\n if (Array.isArray(section)) {\n return (section as ContentNode[])[0];\n }\n\n return section;\n};\n"],"mappings":";;;;;;AAIA,MAAa,mBAAmB,YAAsC;CACpE,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,WACrB,OAAO;CAET,IAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;EAEtB,IACE,UAAU,aAAaA,yBAAU,YACjC,UAAU,aAAaA,yBAAU,MAEjC,OAAO;EAGT,IACE,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,aACjC,UAAU,aAAaA,yBAAU,aACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,MAGjC,OAAO,QADU,OAAO,KAAK,OAAO,CAAC,CAAC;EAIxC,IAAI,UAAU,aAAaA,yBAAU,QACnC;EAGF,OAAO;CACT;CAEA,IAAI,CAAC,WAAW,OAAO,YAAY,UACjC,OAAO;CAGT,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAQ,QAA0B;CAGpC,OAAO;AACT"}
@@ -12,30 +12,38 @@ const isTypedNode = (content) => {
12
12
  return typeof content === "object" && content !== null && "nodeType" in content && typeof content.nodeType === "string";
13
13
  };
14
14
  /**
15
- * Type guard to check if content is a valid NodeType
15
+ * Every known {@link NodeType}, as a lookup record.
16
+ *
17
+ * Typed as `Record<NodeType, true>` so that adding a node type to
18
+ * `@intlayer/types` without registering it here becomes a compile-time error.
16
19
  */
17
- const isValidNodeType = (nodeType) => {
18
- return [
19
- _intlayer_types_nodeType.TRANSLATION,
20
- _intlayer_types_nodeType.ENUMERATION,
21
- _intlayer_types_nodeType.PLURAL,
22
- _intlayer_types_nodeType.CONDITION,
23
- _intlayer_types_nodeType.INSERTION,
24
- _intlayer_types_nodeType.FILE,
25
- _intlayer_types_nodeType.OBJECT,
26
- _intlayer_types_nodeType.ARRAY,
27
- _intlayer_types_nodeType.NESTED,
28
- _intlayer_types_nodeType.REACT_NODE,
29
- _intlayer_types_nodeType.MARKDOWN,
30
- _intlayer_types_nodeType.HTML,
31
- _intlayer_types_nodeType.TEXT,
32
- _intlayer_types_nodeType.NUMBER,
33
- _intlayer_types_nodeType.BOOLEAN,
34
- _intlayer_types_nodeType.GENDER,
35
- _intlayer_types_nodeType.NULL,
36
- _intlayer_types_nodeType.UNKNOWN
37
- ].includes(nodeType);
20
+ const validNodeTypes = {
21
+ [_intlayer_types_nodeType.TRANSLATION]: true,
22
+ [_intlayer_types_nodeType.ENUMERATION]: true,
23
+ [_intlayer_types_nodeType.PLURAL]: true,
24
+ [_intlayer_types_nodeType.CONDITION]: true,
25
+ [_intlayer_types_nodeType.INSERTION]: true,
26
+ [_intlayer_types_nodeType.FILE]: true,
27
+ [_intlayer_types_nodeType.OBJECT]: true,
28
+ [_intlayer_types_nodeType.ARRAY]: true,
29
+ [_intlayer_types_nodeType.NESTED]: true,
30
+ [_intlayer_types_nodeType.REACT_NODE]: true,
31
+ [_intlayer_types_nodeType.PREACT_NODE]: true,
32
+ [_intlayer_types_nodeType.SOLID_NODE]: true,
33
+ [_intlayer_types_nodeType.MARKDOWN]: true,
34
+ [_intlayer_types_nodeType.HTML]: true,
35
+ [_intlayer_types_nodeType.TEXT]: true,
36
+ [_intlayer_types_nodeType.NUMBER]: true,
37
+ [_intlayer_types_nodeType.BOOLEAN]: true,
38
+ [_intlayer_types_nodeType.GENDER]: true,
39
+ [_intlayer_types_nodeType.SELECT]: true,
40
+ [_intlayer_types_nodeType.NULL]: true,
41
+ [_intlayer_types_nodeType.UNKNOWN]: true
38
42
  };
43
+ /**
44
+ * Type guard to check if a raw string is a valid {@link NodeType}
45
+ */
46
+ const isValidNodeType = (nodeType) => Object.hasOwn(validNodeTypes, nodeType);
39
47
  const getNodeType = (content) => {
40
48
  if (typeof content === "string") return _intlayer_types_nodeType.TEXT;
41
49
  if (isTypedNode(content)) {
@@ -1 +1 @@
1
- {"version":3,"file":"getNodeType.cjs","names":["NodeTypes","isValidElement"],"sources":["../../../src/dictionaryManipulator/getNodeType.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { isValidElement } from '../utils/isValidReactElement';\n\n/**\n * Type guard to check if content is a TypedNode\n */\nconst isTypedNode = (content: unknown): content is TypedNode => {\n return (\n typeof content === 'object' &&\n content !== null &&\n 'nodeType' in content &&\n typeof (content as TypedNode).nodeType === 'string'\n );\n};\n\n/**\n * Type guard to check if content is a valid NodeType\n */\nconst isValidNodeType = (nodeType: string): nodeType is NodeType => {\n return [\n NodeTypes.TRANSLATION,\n NodeTypes.ENUMERATION,\n NodeTypes.PLURAL,\n NodeTypes.CONDITION,\n NodeTypes.INSERTION,\n NodeTypes.FILE,\n NodeTypes.OBJECT,\n NodeTypes.ARRAY,\n NodeTypes.NESTED,\n NodeTypes.REACT_NODE,\n NodeTypes.MARKDOWN,\n NodeTypes.HTML,\n NodeTypes.TEXT,\n NodeTypes.NUMBER,\n NodeTypes.BOOLEAN,\n NodeTypes.GENDER,\n NodeTypes.NULL,\n NodeTypes.UNKNOWN,\n ].includes(nodeType as NodeType);\n};\n\nexport const getNodeType = (content: ContentNode): NodeType => {\n if (typeof content === 'string') {\n return NodeTypes.TEXT;\n }\n\n if (isTypedNode(content)) {\n const nodeType = content.nodeType;\n if (isValidNodeType(nodeType)) {\n return nodeType;\n }\n // Fallback for unknown node types\n return NodeTypes.UNKNOWN;\n }\n\n if (Array.isArray(content)) {\n return NodeTypes.ARRAY;\n }\n\n if (isValidElement(content)) {\n return NodeTypes.REACT_NODE;\n }\n\n if (typeof content === 'number') {\n return NodeTypes.NUMBER;\n }\n\n if (typeof content === 'boolean') {\n return NodeTypes.BOOLEAN;\n }\n\n if (content && typeof content === 'object') {\n return NodeTypes.OBJECT;\n }\n\n if (content === null) {\n return NodeTypes.NULL;\n }\n\n return NodeTypes.UNKNOWN;\n};\n"],"mappings":";;;;;;;;;;AASA,MAAM,eAAe,YAA2C;CAC9D,OACE,OAAO,YAAY,YACnB,YAAY,QACZ,cAAc,WACd,OAAQ,QAAsB,aAAa;AAE/C;;;;AAKA,MAAM,mBAAmB,aAA2C;CAClE,OAAO;EACLA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;CACZ,CAAC,CAAC,SAAS,QAAoB;AACjC;AAEA,MAAa,eAAe,YAAmC;CAC7D,IAAI,OAAO,YAAY,UACrB,OAAOA,yBAAU;CAGnB,IAAI,YAAY,OAAO,GAAG;EACxB,MAAM,WAAW,QAAQ;EACzB,IAAI,gBAAgB,QAAQ,GAC1B,OAAO;EAGT,OAAOA,yBAAU;CACnB;CAEA,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAOA,yBAAU;CAGnB,IAAIC,iDAAe,OAAO,GACxB,OAAOD,yBAAU;CAGnB,IAAI,OAAO,YAAY,UACrB,OAAOA,yBAAU;CAGnB,IAAI,OAAO,YAAY,WACrB,OAAOA,yBAAU;CAGnB,IAAI,WAAW,OAAO,YAAY,UAChC,OAAOA,yBAAU;CAGnB,IAAI,YAAY,MACd,OAAOA,yBAAU;CAGnB,OAAOA,yBAAU;AACnB"}
1
+ {"version":3,"file":"getNodeType.cjs","names":["NodeTypes","isValidElement"],"sources":["../../../src/dictionaryManipulator/getNodeType.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { isValidElement } from '../utils/isValidReactElement';\n\n/**\n * Type guard to check if content is a TypedNode\n */\nconst isTypedNode = (content: unknown): content is TypedNode => {\n return (\n typeof content === 'object' &&\n content !== null &&\n 'nodeType' in content &&\n typeof (content as TypedNode).nodeType === 'string'\n );\n};\n\n/**\n * Every known {@link NodeType}, as a lookup record.\n *\n * Typed as `Record<NodeType, true>` so that adding a node type to\n * `@intlayer/types` without registering it here becomes a compile-time error.\n */\nconst validNodeTypes: Record<NodeType, true> = {\n [NodeTypes.TRANSLATION]: true,\n [NodeTypes.ENUMERATION]: true,\n [NodeTypes.PLURAL]: true,\n [NodeTypes.CONDITION]: true,\n [NodeTypes.INSERTION]: true,\n [NodeTypes.FILE]: true,\n [NodeTypes.OBJECT]: true,\n [NodeTypes.ARRAY]: true,\n [NodeTypes.NESTED]: true,\n [NodeTypes.REACT_NODE]: true,\n [NodeTypes.PREACT_NODE]: true,\n [NodeTypes.SOLID_NODE]: true,\n [NodeTypes.MARKDOWN]: true,\n [NodeTypes.HTML]: true,\n [NodeTypes.TEXT]: true,\n [NodeTypes.NUMBER]: true,\n [NodeTypes.BOOLEAN]: true,\n [NodeTypes.GENDER]: true,\n [NodeTypes.SELECT]: true,\n [NodeTypes.NULL]: true,\n [NodeTypes.UNKNOWN]: true,\n};\n\n/**\n * Type guard to check if a raw string is a valid {@link NodeType}\n */\nconst isValidNodeType = (nodeType: string): nodeType is NodeType =>\n Object.hasOwn(validNodeTypes, nodeType);\n\nexport const getNodeType = (content: ContentNode): NodeType => {\n if (typeof content === 'string') {\n return NodeTypes.TEXT;\n }\n\n if (isTypedNode(content)) {\n const nodeType = content.nodeType;\n if (isValidNodeType(nodeType)) {\n return nodeType;\n }\n // Fallback for unknown node types\n return NodeTypes.UNKNOWN;\n }\n\n if (Array.isArray(content)) {\n return NodeTypes.ARRAY;\n }\n\n if (isValidElement(content)) {\n return NodeTypes.REACT_NODE;\n }\n\n if (typeof content === 'number') {\n return NodeTypes.NUMBER;\n }\n\n if (typeof content === 'boolean') {\n return NodeTypes.BOOLEAN;\n }\n\n if (content && typeof content === 'object') {\n return NodeTypes.OBJECT;\n }\n\n if (content === null) {\n return NodeTypes.NULL;\n }\n\n return NodeTypes.UNKNOWN;\n};\n"],"mappings":";;;;;;;;;;AASA,MAAM,eAAe,YAA2C;CAC9D,OACE,OAAO,YAAY,YACnB,YAAY,QACZ,cAAc,WACd,OAAQ,QAAsB,aAAa;AAE/C;;;;;;;AAQA,MAAM,iBAAyC;EAC5CA,yBAAU,cAAc;EACxBA,yBAAU,cAAc;EACxBA,yBAAU,SAAS;EACnBA,yBAAU,YAAY;EACtBA,yBAAU,YAAY;EACtBA,yBAAU,OAAO;EACjBA,yBAAU,SAAS;EACnBA,yBAAU,QAAQ;EAClBA,yBAAU,SAAS;EACnBA,yBAAU,aAAa;EACvBA,yBAAU,cAAc;EACxBA,yBAAU,aAAa;EACvBA,yBAAU,WAAW;EACrBA,yBAAU,OAAO;EACjBA,yBAAU,OAAO;EACjBA,yBAAU,SAAS;EACnBA,yBAAU,UAAU;EACpBA,yBAAU,SAAS;EACnBA,yBAAU,SAAS;EACnBA,yBAAU,OAAO;EACjBA,yBAAU,UAAU;AACvB;;;;AAKA,MAAM,mBAAmB,aACvB,OAAO,OAAO,gBAAgB,QAAQ;AAExC,MAAa,eAAe,YAAmC;CAC7D,IAAI,OAAO,YAAY,UACrB,OAAOA,yBAAU;CAGnB,IAAI,YAAY,OAAO,GAAG;EACxB,MAAM,WAAW,QAAQ;EACzB,IAAI,gBAAgB,QAAQ,GAC1B,OAAO;EAGT,OAAOA,yBAAU;CACnB;CAEA,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAOA,yBAAU;CAGnB,IAAIC,iDAAe,OAAO,GACxB,OAAOD,yBAAU;CAGnB,IAAI,OAAO,YAAY,UACrB,OAAOA,yBAAU;CAGnB,IAAI,OAAO,YAAY,WACrB,OAAOA,yBAAU;CAGnB,IAAI,WAAW,OAAO,YAAY,UAChC,OAAOA,yBAAU;CAGnB,IAAI,YAAY,MACd,OAAOA,yBAAU;CAGnB,OAAOA,yBAAU;AACnB"}
@@ -14,7 +14,7 @@ const removeContentNodeByKeyPath = (dictionaryContent, keyPath) => {
14
14
  lastKey = keyObj.key;
15
15
  currentValue = currentValue[keyObj.key];
16
16
  }
17
- if (keyObj.type === _intlayer_types_nodeType.TRANSLATION || keyObj.type === _intlayer_types_nodeType.ENUMERATION || keyObj.type === _intlayer_types_nodeType.PLURAL || keyObj.type === _intlayer_types_nodeType.CONDITION) {
17
+ if (keyObj.type === _intlayer_types_nodeType.TRANSLATION || keyObj.type === _intlayer_types_nodeType.ENUMERATION || keyObj.type === _intlayer_types_nodeType.PLURAL || keyObj.type === _intlayer_types_nodeType.CONDITION || keyObj.type === _intlayer_types_nodeType.GENDER || keyObj.type === _intlayer_types_nodeType.SELECT) {
18
18
  lastKey = keyObj.type;
19
19
  currentValue = currentValue[keyObj.type][keyObj.key];
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"removeContentNodeByKeyPath.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/removeContentNodeByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const removeContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeTypes.OBJECT || keyObj.type === NodeTypes.ARRAY) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.TRANSLATION ||\n keyObj.type === NodeTypes.ENUMERATION ||\n keyObj.type === NodeTypes.PLURAL ||\n keyObj.type === NodeTypes.CONDITION\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.MARKDOWN ||\n keyObj.type === NodeTypes.REACT_NODE ||\n keyObj.type === NodeTypes.HTML ||\n keyObj.type === NodeTypes.INSERTION ||\n keyObj.type === NodeTypes.FILE\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type];\n }\n }\n\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue.splice(lastKey as unknown as number, 1);\n } else {\n delete parentValue[lastKey];\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":";;;;;;AAKA,MAAa,8BACX,mBACA,YACgB;CAChB,IAAI,eAAoB;CACxB,IAAI,cAAmB;CACvB,IAAI,UAAkC;CAEtC,KAAK,MAAM,UAAU,SAAS;EAC5B,cAAc;EAEd,IAAI,OAAO,SAASA,yBAAU,UAAU,OAAO,SAASA,yBAAU,OAAO;GACvE,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO;EACrC;EAEA,IACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,UAC1B,OAAO,SAASA,yBAAU,WAC1B;GACA,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO,KAAK,CAAC,OAAO;EAClD;EAEA,IACE,OAAO,SAASA,yBAAU,YAC1B,OAAO,SAASA,yBAAU,cAC1B,OAAO,SAASA,yBAAU,QAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,MAC1B;GACA,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO;EACrC;CACF;CAEA,IAAI,eAAe,YAAY,MAC7B,IAAI,MAAM,QAAQ,WAAW,GAC3B,YAAY,OAAO,SAA8B,CAAC;MAElD,OAAO,YAAY;CAIvB,OAAO;AACT"}
1
+ {"version":3,"file":"removeContentNodeByKeyPath.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/removeContentNodeByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const removeContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeTypes.OBJECT || keyObj.type === NodeTypes.ARRAY) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.TRANSLATION ||\n keyObj.type === NodeTypes.ENUMERATION ||\n keyObj.type === NodeTypes.PLURAL ||\n keyObj.type === NodeTypes.CONDITION ||\n keyObj.type === NodeTypes.GENDER ||\n keyObj.type === NodeTypes.SELECT\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.MARKDOWN ||\n keyObj.type === NodeTypes.REACT_NODE ||\n keyObj.type === NodeTypes.HTML ||\n keyObj.type === NodeTypes.INSERTION ||\n keyObj.type === NodeTypes.FILE\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type];\n }\n }\n\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue.splice(lastKey as unknown as number, 1);\n } else {\n delete parentValue[lastKey];\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":";;;;;;AAKA,MAAa,8BACX,mBACA,YACgB;CAChB,IAAI,eAAoB;CACxB,IAAI,cAAmB;CACvB,IAAI,UAAkC;CAEtC,KAAK,MAAM,UAAU,SAAS;EAC5B,cAAc;EAEd,IAAI,OAAO,SAASA,yBAAU,UAAU,OAAO,SAASA,yBAAU,OAAO;GACvE,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO;EACrC;EAEA,IACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,UAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,UAC1B,OAAO,SAASA,yBAAU,QAC1B;GACA,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO,KAAK,CAAC,OAAO;EAClD;EAEA,IACE,OAAO,SAASA,yBAAU,YAC1B,OAAO,SAASA,yBAAU,cAC1B,OAAO,SAASA,yBAAU,QAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,MAC1B;GACA,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO;EACrC;CACF;CAEA,IAAI,eAAe,YAAY,MAC7B,IAAI,MAAM,QAAQ,WAAW,GAC3B,YAAY,OAAO,SAA8B,CAAC;MAElD,OAAO,YAAY;CAIvB,OAAO;AACT"}
@@ -14,7 +14,7 @@ const renameContentNodeByKeyPath = (dictionaryContent, newKey, keyPath) => {
14
14
  lastKey = keyObj.key;
15
15
  currentValue = currentValue[keyObj.key];
16
16
  }
17
- if (keyObj.type === _intlayer_types_nodeType.TRANSLATION || keyObj.type === _intlayer_types_nodeType.ENUMERATION || keyObj.type === _intlayer_types_nodeType.PLURAL || keyObj.type === _intlayer_types_nodeType.CONDITION) {
17
+ if (keyObj.type === _intlayer_types_nodeType.TRANSLATION || keyObj.type === _intlayer_types_nodeType.ENUMERATION || keyObj.type === _intlayer_types_nodeType.PLURAL || keyObj.type === _intlayer_types_nodeType.CONDITION || keyObj.type === _intlayer_types_nodeType.GENDER || keyObj.type === _intlayer_types_nodeType.SELECT) {
18
18
  lastKey = keyObj.type;
19
19
  currentValue = currentValue[keyObj.type][keyObj.key];
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renameContentNodeByKeyPath.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/renameContentNodeByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const renameContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n newKey: KeyPath['key'],\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeTypes.OBJECT || keyObj.type === NodeTypes.ARRAY) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.TRANSLATION ||\n keyObj.type === NodeTypes.ENUMERATION ||\n keyObj.type === NodeTypes.PLURAL ||\n keyObj.type === NodeTypes.CONDITION\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.MARKDOWN ||\n keyObj.type === NodeTypes.REACT_NODE ||\n keyObj.type === NodeTypes.HTML ||\n keyObj.type === NodeTypes.INSERTION ||\n keyObj.type === NodeTypes.FILE\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type];\n }\n }\n\n // Assign the new value to the last key of the parent while preserving the order\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue[lastKey as number] = currentValue;\n } else {\n const newParentValue: any = {};\n for (const key of Object.keys(parentValue)) {\n if (key === lastKey && typeof newKey !== 'undefined') {\n newParentValue[newKey] = currentValue;\n } else {\n newParentValue[key] = parentValue[key];\n }\n }\n // Replace the contents of parentValue with newParentValue\n Object.keys(parentValue).forEach((key) => {\n delete parentValue[key];\n });\n Object.assign(parentValue, newParentValue);\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":";;;;;;AAKA,MAAa,8BACX,mBACA,QACA,YACgB;CAChB,IAAI,eAAoB;CACxB,IAAI,cAAmB;CACvB,IAAI,UAAkC;CAEtC,KAAK,MAAM,UAAU,SAAS;EAC5B,cAAc;EAEd,IAAI,OAAO,SAASA,yBAAU,UAAU,OAAO,SAASA,yBAAU,OAAO;GACvE,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO;EACrC;EAEA,IACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,UAC1B,OAAO,SAASA,yBAAU,WAC1B;GACA,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO,KAAK,CAAC,OAAO;EAClD;EAEA,IACE,OAAO,SAASA,yBAAU,YAC1B,OAAO,SAASA,yBAAU,cAC1B,OAAO,SAASA,yBAAU,QAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,MAC1B;GACA,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO;EACrC;CACF;CAGA,IAAI,eAAe,YAAY,MAC7B,IAAI,MAAM,QAAQ,WAAW,GAC3B,YAAY,WAAqB;MAC5B;EACL,MAAM,iBAAsB,CAAC;EAC7B,KAAK,MAAM,OAAO,OAAO,KAAK,WAAW,GACvC,IAAI,QAAQ,WAAW,OAAO,WAAW,aACvC,eAAe,UAAU;OAEzB,eAAe,OAAO,YAAY;EAItC,OAAO,KAAK,WAAW,CAAC,CAAC,SAAS,QAAQ;GACxC,OAAO,YAAY;EACrB,CAAC;EACD,OAAO,OAAO,aAAa,cAAc;CAC3C;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"renameContentNodeByKeyPath.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/renameContentNodeByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const renameContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n newKey: KeyPath['key'],\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeTypes.OBJECT || keyObj.type === NodeTypes.ARRAY) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.TRANSLATION ||\n keyObj.type === NodeTypes.ENUMERATION ||\n keyObj.type === NodeTypes.PLURAL ||\n keyObj.type === NodeTypes.CONDITION ||\n keyObj.type === NodeTypes.GENDER ||\n keyObj.type === NodeTypes.SELECT\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeTypes.MARKDOWN ||\n keyObj.type === NodeTypes.REACT_NODE ||\n keyObj.type === NodeTypes.HTML ||\n keyObj.type === NodeTypes.INSERTION ||\n keyObj.type === NodeTypes.FILE\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type];\n }\n }\n\n // Assign the new value to the last key of the parent while preserving the order\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue[lastKey as number] = currentValue;\n } else {\n const newParentValue: any = {};\n for (const key of Object.keys(parentValue)) {\n if (key === lastKey && typeof newKey !== 'undefined') {\n newParentValue[newKey] = currentValue;\n } else {\n newParentValue[key] = parentValue[key];\n }\n }\n // Replace the contents of parentValue with newParentValue\n Object.keys(parentValue).forEach((key) => {\n delete parentValue[key];\n });\n Object.assign(parentValue, newParentValue);\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":";;;;;;AAKA,MAAa,8BACX,mBACA,QACA,YACgB;CAChB,IAAI,eAAoB;CACxB,IAAI,cAAmB;CACvB,IAAI,UAAkC;CAEtC,KAAK,MAAM,UAAU,SAAS;EAC5B,cAAc;EAEd,IAAI,OAAO,SAASA,yBAAU,UAAU,OAAO,SAASA,yBAAU,OAAO;GACvE,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO;EACrC;EAEA,IACE,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,eAC1B,OAAO,SAASA,yBAAU,UAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,UAC1B,OAAO,SAASA,yBAAU,QAC1B;GACA,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO,KAAK,CAAC,OAAO;EAClD;EAEA,IACE,OAAO,SAASA,yBAAU,YAC1B,OAAO,SAASA,yBAAU,cAC1B,OAAO,SAASA,yBAAU,QAC1B,OAAO,SAASA,yBAAU,aAC1B,OAAO,SAASA,yBAAU,MAC1B;GACA,UAAU,OAAO;GACjB,eAAe,aAAa,OAAO;EACrC;CACF;CAGA,IAAI,eAAe,YAAY,MAC7B,IAAI,MAAM,QAAQ,WAAW,GAC3B,YAAY,WAAqB;MAC5B;EACL,MAAM,iBAAsB,CAAC;EAC7B,KAAK,MAAM,OAAO,OAAO,KAAK,WAAW,GACvC,IAAI,QAAQ,WAAW,OAAO,WAAW,aACvC,eAAe,UAAU;OAEzB,eAAe,OAAO,YAAY;EAItC,OAAO,KAAK,WAAW,CAAC,CAAC,SAAS,QAAQ;GACxC,OAAO,YAAY;EACrB,CAAC;EACD,OAAO,OAAO,aAAa,cAAc;CAC3C;CAGF,OAAO;AACT"}
@@ -11,7 +11,7 @@ const updateNodeChildren = (section, newChildren) => {
11
11
  if (typeof section?.nodeType === "string") {
12
12
  const typedNode = section;
13
13
  const content = typedNode[typedNode.nodeType];
14
- if (typedNode.nodeType === _intlayer_types_nodeType.TRANSLATION || typedNode.nodeType === _intlayer_types_nodeType.ENUMERATION || typedNode.nodeType === _intlayer_types_nodeType.PLURAL || typedNode.nodeType === _intlayer_types_nodeType.CONDITION) {
14
+ if (typedNode.nodeType === _intlayer_types_nodeType.TRANSLATION || typedNode.nodeType === _intlayer_types_nodeType.ENUMERATION || typedNode.nodeType === _intlayer_types_nodeType.PLURAL || typedNode.nodeType === _intlayer_types_nodeType.CONDITION || typedNode.nodeType === _intlayer_types_nodeType.GENDER || typedNode.nodeType === _intlayer_types_nodeType.SELECT) {
15
15
  const newContent = Object.entries(content).reduce((acc, [key]) => {
16
16
  acc[key] = newChildren;
17
17
  return acc;
@@ -1 +1 @@
1
- {"version":3,"file":"updateNodeChildren.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/updateNodeChildren.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const updateNodeChildren = <\n T extends ContentNode,\n U extends ContentNode,\n>(\n section: T,\n newChildren: U\n): ContentNode => {\n if (typeof section === 'string') {\n return newChildren;\n }\n if (typeof section === 'number') {\n return newChildren;\n }\n if (typeof section === 'boolean') {\n return newChildren;\n }\n if (typeof (section as TypedNode)?.nodeType === 'string') {\n const typedNode = section as TypedNode;\n const content =\n typedNode[typedNode.nodeType as unknown as keyof typeof typedNode];\n\n if (\n typedNode.nodeType === NodeTypes.TRANSLATION ||\n typedNode.nodeType === NodeTypes.ENUMERATION ||\n typedNode.nodeType === NodeTypes.PLURAL ||\n typedNode.nodeType === NodeTypes.CONDITION\n ) {\n const newContent = Object.entries(content).reduce(\n (acc, [key]) => {\n acc[key] = newChildren;\n return acc;\n },\n {} as Record<string, ContentNode>\n );\n\n return {\n ...typedNode,\n [typedNode.nodeType]: newContent,\n };\n }\n\n if (typedNode.nodeType === NodeTypes.NESTED) {\n return typedNode;\n }\n\n return {\n ...typedNode,\n [typedNode.nodeType]: newChildren,\n };\n }\n\n if (!section || typeof section !== 'object') {\n return newChildren;\n }\n\n if (Array.isArray(section)) {\n return section.map(() => newChildren) as unknown as ContentNode;\n }\n\n return Object.entries(\n section as unknown as Record<string, ContentNode>\n ).reduce(\n (acc, [key]) => ({\n ...acc,\n [key]: newChildren,\n }),\n {} as Record<string, ContentNode>\n ) as unknown as ContentNode;\n};\n"],"mappings":";;;;;;AAIA,MAAa,sBAIX,SACA,gBACgB;CAChB,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,WACrB,OAAO;CAET,IAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;EAEtB,IACE,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,WACjC;GACA,MAAM,aAAa,OAAO,QAAQ,OAAO,CAAC,CAAC,QACxC,KAAK,CAAC,SAAS;IACd,IAAI,OAAO;IACX,OAAO;GACT,GACA,CAAC,CACH;GAEA,OAAO;IACL,GAAG;KACF,UAAU,WAAW;GACxB;EACF;EAEA,IAAI,UAAU,aAAaA,yBAAU,QACnC,OAAO;EAGT,OAAO;GACL,GAAG;IACF,UAAU,WAAW;EACxB;CACF;CAEA,IAAI,CAAC,WAAW,OAAO,YAAY,UACjC,OAAO;CAGT,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAO,QAAQ,UAAU,WAAW;CAGtC,OAAO,OAAO,QACZ,OACF,CAAC,CAAC,QACC,KAAK,CAAC,UAAU;EACf,GAAG;GACF,MAAM;CACT,IACA,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"updateNodeChildren.cjs","names":["NodeTypes"],"sources":["../../../src/dictionaryManipulator/updateNodeChildren.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\nexport const updateNodeChildren = <\n T extends ContentNode,\n U extends ContentNode,\n>(\n section: T,\n newChildren: U\n): ContentNode => {\n if (typeof section === 'string') {\n return newChildren;\n }\n if (typeof section === 'number') {\n return newChildren;\n }\n if (typeof section === 'boolean') {\n return newChildren;\n }\n if (typeof (section as TypedNode)?.nodeType === 'string') {\n const typedNode = section as TypedNode;\n const content =\n typedNode[typedNode.nodeType as unknown as keyof typeof typedNode];\n\n if (\n typedNode.nodeType === NodeTypes.TRANSLATION ||\n typedNode.nodeType === NodeTypes.ENUMERATION ||\n typedNode.nodeType === NodeTypes.PLURAL ||\n typedNode.nodeType === NodeTypes.CONDITION ||\n typedNode.nodeType === NodeTypes.GENDER ||\n typedNode.nodeType === NodeTypes.SELECT\n ) {\n const newContent = Object.entries(content).reduce(\n (acc, [key]) => {\n acc[key] = newChildren;\n return acc;\n },\n {} as Record<string, ContentNode>\n );\n\n return {\n ...typedNode,\n [typedNode.nodeType]: newContent,\n };\n }\n\n if (typedNode.nodeType === NodeTypes.NESTED) {\n return typedNode;\n }\n\n return {\n ...typedNode,\n [typedNode.nodeType]: newChildren,\n };\n }\n\n if (!section || typeof section !== 'object') {\n return newChildren;\n }\n\n if (Array.isArray(section)) {\n return section.map(() => newChildren) as unknown as ContentNode;\n }\n\n return Object.entries(\n section as unknown as Record<string, ContentNode>\n ).reduce(\n (acc, [key]) => ({\n ...acc,\n [key]: newChildren,\n }),\n {} as Record<string, ContentNode>\n ) as unknown as ContentNode;\n};\n"],"mappings":";;;;;;AAIA,MAAa,sBAIX,SACA,gBACgB;CAChB,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,OAAO,YAAY,WACrB,OAAO;CAET,IAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;EAEtB,IACE,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,eACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,aACjC,UAAU,aAAaA,yBAAU,UACjC,UAAU,aAAaA,yBAAU,QACjC;GACA,MAAM,aAAa,OAAO,QAAQ,OAAO,CAAC,CAAC,QACxC,KAAK,CAAC,SAAS;IACd,IAAI,OAAO;IACX,OAAO;GACT,GACA,CAAC,CACH;GAEA,OAAO;IACL,GAAG;KACF,UAAU,WAAW;GACxB;EACF;EAEA,IAAI,UAAU,aAAaA,yBAAU,QACnC,OAAO;EAGT,OAAO;GACL,GAAG;IACF,UAAU,WAAW;EACxB;CACF;CAEA,IAAI,CAAC,WAAW,OAAO,YAAY,UACjC,OAAO;CAGT,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAO,QAAQ,UAAU,WAAW;CAGtC,OAAO,OAAO,QACZ,OACF,CAAC,CAAC,QACC,KAAK,CAAC,UAAU;EACf,GAAG;GACF,MAAM;CACT,IACA,CAAC,CACH;AACF"}
@@ -3,6 +3,7 @@ const require_deepTransformPlugins_getEditedContent = require('./deepTransformPl
3
3
  const require_interpreter_getCondition = require('./interpreter/getCondition.cjs');
4
4
  const require_interpreter_getContent_deepTransform = require('./interpreter/getContent/deepTransform.cjs');
5
5
  const require_interpreter_getEnumeration = require('./interpreter/getEnumeration.cjs');
6
+ const require_interpreter_getGender = require('./interpreter/getGender.cjs');
6
7
  const require_interpreter_getInsertion = require('./interpreter/getInsertion.cjs');
7
8
  const require_dictionaryManipulator_qualifiedDictionary = require('./dictionaryManipulator/qualifiedDictionary.cjs');
8
9
  const require_interpreter_getDictionary = require('./interpreter/getDictionary.cjs');
@@ -18,6 +19,7 @@ const require_formatters_percentage = require('./formatters/percentage.cjs');
18
19
  const require_formatters_relativeTime = require('./formatters/relativeTime.cjs');
19
20
  const require_formatters_units = require('./formatters/units.cjs');
20
21
  const require_interpreter_getPlural = require('./interpreter/getPlural.cjs');
22
+ const require_interpreter_getSelect = require('./interpreter/getSelect.cjs');
21
23
  const require_interpreter_getTranslation = require('./interpreter/getTranslation.cjs');
22
24
  const require_interpreter_interpolableNode = require('./interpreter/interpolableNode.cjs');
23
25
  const require_interpreter_getContent_plugins = require('./interpreter/getContent/plugins.cjs');
@@ -39,6 +41,7 @@ const require_transpiler_markdown_validateMarkdown = require('./transpiler/markd
39
41
  const require_transpiler_markdown_markdown = require('./transpiler/markdown/markdown.cjs');
40
42
  const require_transpiler_nesting_nesting = require('./transpiler/nesting/nesting.cjs');
41
43
  const require_transpiler_plural_plural = require('./transpiler/plural/plural.cjs');
44
+ const require_transpiler_select_select = require('./transpiler/select/select.cjs');
42
45
  const require_transpiler_translation_translation = require('./transpiler/translation/translation.cjs');
43
46
  const require_deepTransformPlugins_getFilterMissingTranslationsContent = require('./deepTransformPlugins/getFilterMissingTranslationsContent.cjs');
44
47
  const require_deepTransformPlugins_getFilterTranslationsOnlyContent = require('./deepTransformPlugins/getFilterTranslationsOnlyContent.cjs');
@@ -245,6 +248,7 @@ exports.getFilterTranslationsOnlyContent = require_deepTransformPlugins_getFilte
245
248
  exports.getFilterTranslationsOnlyDictionary = require_deepTransformPlugins_getFilterTranslationsOnlyContent.getFilterTranslationsOnlyDictionary;
246
249
  exports.getFilteredLocalesContent = require_deepTransformPlugins_getFilteredLocalesContent.getFilteredLocalesContent;
247
250
  exports.getFilteredLocalesDictionary = require_deepTransformPlugins_getFilteredLocalesContent.getFilteredLocalesDictionary;
251
+ exports.getGender = require_interpreter_getGender.getGender;
248
252
  exports.getHTML = require_interpreter_getHTML.getHTML;
249
253
  exports.getHTMLTextDir = require_localization_getHTMLTextDir.getHTMLTextDir;
250
254
  exports.getInsertion = require_interpreter_getInsertion.getInsertion;
@@ -279,6 +283,7 @@ exports.getPrefix = require_localization_getPrefix.getPrefix;
279
283
  exports.getReplacedValuesContent = require_deepTransformPlugins_getReplacedValuesContent.getReplacedValuesContent;
280
284
  exports.getRewritePath = require_localization_rewriteUtils.getRewritePath;
281
285
  exports.getRewriteRules = require_localization_rewriteUtils.getRewriteRules;
286
+ exports.getSelect = require_interpreter_getSelect.getSelect;
282
287
  exports.getSplittedContent = require_deepTransformPlugins_getSplittedContent.getSplittedContent;
283
288
  exports.getSplittedDictionaryContent = require_deepTransformPlugins_getSplittedContent.getSplittedDictionaryContent;
284
289
  exports.getTranslation = require_interpreter_getTranslation.getTranslation;
@@ -355,6 +360,8 @@ exports.resolveQualifiedDictionary = require_dictionaryManipulator_qualifiedDict
355
360
  exports.resolveQualifiedDynamicContent = require_dictionaryManipulator_qualifiedDictionary.resolveQualifiedDynamicContent;
356
361
  exports.resolveQualifiedDynamicContentAsync = require_dictionaryManipulator_qualifiedDictionary.resolveQualifiedDynamicContentAsync;
357
362
  exports.sanitizer = require_markdown_utils.sanitizer;
363
+ exports.select = require_transpiler_select_select.select;
364
+ exports.selectPlugin = require_interpreter_getContent_plugins.selectPlugin;
358
365
  exports.serializeVariant = require_dictionaryManipulator_qualifiedDictionary.serializeVariant;
359
366
  exports.setLocaleInStorage = require_utils_localeStorage.setLocaleInStorage;
360
367
  exports.setLocaleInStorageClient = require_utils_localeStorage.setLocaleInStorageClient;
@@ -11,7 +11,8 @@ const getBasePlugins = (locale, fallback = true) => [
11
11
  require_interpreter_getContent_plugins.insertionPlugin,
12
12
  require_interpreter_getContent_plugins.nestedPlugin(locale ?? _intlayer_config_built.internationalization.defaultLocale),
13
13
  require_interpreter_getContent_plugins.filePlugin,
14
- require_interpreter_getContent_plugins.genderPlugin
14
+ require_interpreter_getContent_plugins.genderPlugin,
15
+ require_interpreter_getContent_plugins.selectPlugin
15
16
  ];
16
17
  /**
17
18
  * Transforms a node in a single pass, applying each plugin as needed.
@@ -1 +1 @@
1
- {"version":3,"file":"getContent.cjs","names":["translationPlugin","internationalization","enumerationPlugin","conditionPlugin","insertionPlugin","nestedPlugin","filePlugin","genderPlugin","deepTransformNode"],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { deepTransformNode } from './deepTransform';\nimport {\n conditionPlugin,\n type DeepTransformContent,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState,\n insertionPlugin,\n type NodeProps,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from './plugins';\n\nexport const getBasePlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] =>\n [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n insertionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n ] as Plugins[];\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getContent = <\n const T extends ContentNode,\n const L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n nodeProps: NodeProps,\n plugins: Plugins[] = []\n) =>\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T, IInterpreterPluginState, L>;\n"],"mappings":";;;;;;AAqBA,MAAa,kBACX,QACA,WAAoB,SAEpB;CACEA,yDACE,UAAUC,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,MAClD;CACAC;CACAC;CACAC;CACAC,oDAAa,UAAUJ,4CAAqB,aAAa;CACzDK;CACAC;AACF;;;;;;;AAQF,MAAa,cAIX,MACA,WACA,UAAqB,CAAC,MAEtBC,+DAAkB,MAAM;CACtB,GAAG;CACH;AACF,CAAC"}
1
+ {"version":3,"file":"getContent.cjs","names":["translationPlugin","internationalization","enumerationPlugin","conditionPlugin","insertionPlugin","nestedPlugin","filePlugin","genderPlugin","selectPlugin","deepTransformNode"],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { deepTransformNode } from './deepTransform';\nimport {\n conditionPlugin,\n type DeepTransformContent,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState,\n insertionPlugin,\n type NodeProps,\n nestedPlugin,\n type Plugins,\n selectPlugin,\n translationPlugin,\n} from './plugins';\n\nexport const getBasePlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] =>\n [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n insertionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\n ] as Plugins[];\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getContent = <\n const T extends ContentNode,\n const L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n nodeProps: NodeProps,\n plugins: Plugins[] = []\n) =>\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T, IInterpreterPluginState, L>;\n"],"mappings":";;;;;;AAsBA,MAAa,kBACX,QACA,WAAoB,SAEpB;CACEA,yDACE,UAAUC,4CAAqB,eAC/B,WAAWA,4CAAqB,gBAAgB,MAClD;CACAC;CACAC;CACAC;CACAC,oDAAa,UAAUJ,4CAAqB,aAAa;CACzDK;CACAC;CACAC;AACF;;;;;;;AAQF,MAAa,cAIX,MACA,WACA,UAAqB,CAAC,MAEtBC,+DAAkB,MAAM;CACtB,GAAG;CACH;AACF,CAAC"}
@@ -14,4 +14,5 @@ exports.getContent = require_interpreter_getContent_getContent.getContent;
14
14
  exports.insertionPlugin = require_interpreter_getContent_plugins.insertionPlugin;
15
15
  exports.nestedPlugin = require_interpreter_getContent_plugins.nestedPlugin;
16
16
  exports.pluralPlugin = require_interpreter_getContent_plugins.pluralPlugin;
17
+ exports.selectPlugin = require_interpreter_getContent_plugins.selectPlugin;
17
18
  exports.translationPlugin = require_interpreter_getContent_plugins.translationPlugin;
@@ -6,6 +6,7 @@ const require_interpreter_getGender = require('../getGender.cjs');
6
6
  const require_interpreter_getInsertion = require('../getInsertion.cjs');
7
7
  const require_interpreter_getNesting = require('../getNesting.cjs');
8
8
  const require_interpreter_getPlural = require('../getPlural.cjs');
9
+ const require_interpreter_getSelect = require('../getSelect.cjs');
9
10
  const require_interpreter_getTranslation = require('../getTranslation.cjs');
10
11
  const require_interpreter_interpolableNode = require('../interpolableNode.cjs');
11
12
  let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
@@ -206,6 +207,32 @@ const genderPlugin = process.env.INTLAYER_NODE_TYPE_GENDER === "false" ? fallbac
206
207
  return (value) => require_interpreter_getGender.getGender(result, value);
207
208
  }
208
209
  };
210
+ /** Select plugin. Replaces node with a function that takes a string => content. */
211
+ const selectPlugin = process.env.INTLAYER_NODE_TYPE_SELECT === "false" ? fallbackPlugin : {
212
+ id: "select-plugin",
213
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.SELECT,
214
+ transform: (node, props, deepTransformNode) => {
215
+ const original = node[_intlayer_types_nodeType.SELECT];
216
+ const result = {};
217
+ for (const key in original) {
218
+ const child = original[key];
219
+ result[key] = deepTransformNode(child, {
220
+ ...props,
221
+ children: child,
222
+ keyPath: [...props.keyPath, {
223
+ type: _intlayer_types_nodeType.SELECT,
224
+ key
225
+ }]
226
+ });
227
+ }
228
+ return (arg) => {
229
+ const value = typeof arg === "string" ? arg : arg?.value;
230
+ const subResult = require_interpreter_getSelect.getSelect(result, value);
231
+ if (typeof subResult === "function" && typeof arg === "object") return subResult(arg);
232
+ return subResult;
233
+ };
234
+ }
235
+ };
209
236
  /** Nested plugin. Replaces node with the result of `getNesting`. */
210
237
  const nestedPlugin = (locale) => process.env.INTLAYER_NODE_TYPE_NESTED === "false" ? fallbackPlugin : {
211
238
  id: "nested-plugin",
@@ -234,5 +261,6 @@ exports.genderPlugin = genderPlugin;
234
261
  exports.insertionPlugin = insertionPlugin;
235
262
  exports.nestedPlugin = nestedPlugin;
236
263
  exports.pluralPlugin = pluralPlugin;
264
+ exports.selectPlugin = selectPlugin;
237
265
  exports.translationPlugin = translationPlugin;
238
266
  //# sourceMappingURL=plugins.cjs.map