intlayer-editor 8.12.2 → 8.12.3

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 (158) hide show
  1. package/client/dist/assets/{CodeBlockClient-b-yeqFuz.js → CodeBlockClient-BQMC5gqu.js} +3 -3
  2. package/client/dist/assets/{CodeBlockShiki-CKm7rixD.js → CodeBlockShiki-DB7ndrOR.js} +2 -2
  3. package/client/dist/assets/{MarkDownRender-EQEw6Grf.js → MarkDownRender-BQwPctN-.js} +3 -3
  4. package/client/dist/assets/{bundle-web-DofprJDj.js → bundle-web-C4HpQhJS.js} +1 -1
  5. package/client/dist/assets/{dist-BFhKwA67.js → dist-GH_AdANR.js} +1 -1
  6. package/client/dist/assets/index-DIJj_-IN.css +2 -0
  7. package/client/dist/assets/index-DJVEpj0g.js +189 -0
  8. package/client/dist/assets/purify.es-6-uFcs4-.js +3 -0
  9. package/client/dist/index.html +2 -2
  10. package/package.json +15 -15
  11. package/server/dist/@intlayer/chokidar/dist/types/build.d.ts +1 -0
  12. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -0
  13. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +2 -0
  14. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +2 -0
  15. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -0
  16. package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +2 -0
  17. package/server/dist/@intlayer/chokidar/dist/types/cleanOutputDir.d.ts +1 -0
  18. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +1 -0
  19. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +1 -0
  20. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +1 -0
  21. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +1 -0
  22. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +1 -0
  23. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +1 -0
  24. package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +1 -0
  25. package/server/dist/@intlayer/chokidar/dist/types/createType/createModuleAugmentation.d.ts +1 -0
  26. package/server/dist/@intlayer/chokidar/dist/types/createType/createType.d.ts +2 -0
  27. package/server/dist/@intlayer/chokidar/dist/types/formatDictionary.d.ts +1 -0
  28. package/server/dist/@intlayer/chokidar/dist/types/intlayer/dist/types/index.d.ts +1 -0
  29. package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadContentDeclaration.d.ts +2 -0
  30. package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadDictionaries.d.ts +2 -0
  31. package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +2 -0
  32. package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -0
  33. package/server/dist/@intlayer/chokidar/dist/types/prepareIntlayer.d.ts +1 -0
  34. package/server/dist/@intlayer/chokidar/dist/types/writeConfiguration/index.d.ts +1 -0
  35. package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +6 -0
  36. package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/transformJSFile.d.ts +1 -0
  37. package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +2 -0
  38. package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/writeJSFile.d.ts +2 -0
  39. package/server/dist/@intlayer/core/dist/types/messageFormat/ICU.d.ts +1 -0
  40. package/server/dist/@intlayer/core/dist/types/messageFormat/i18next.d.ts +1 -0
  41. package/server/dist/@intlayer/core/dist/types/messageFormat/index.d.ts +1 -0
  42. package/server/dist/@intlayer/core/dist/types/messageFormat/po.d.ts +1 -0
  43. package/server/dist/@intlayer/core/dist/types/messageFormat/vue-i18n.d.ts +1 -0
  44. package/server/dist/controllers/configuration.controller.cjs +1 -0
  45. package/server/dist/controllers/configuration.controller.cjs.map +1 -1
  46. package/server/dist/controllers/configuration.controller.mjs.map +1 -1
  47. package/server/dist/controllers/dictionary.controller.cjs +1 -0
  48. package/server/dist/controllers/dictionary.controller.cjs.map +1 -1
  49. package/server/dist/controllers/dictionary.controller.mjs.map +1 -1
  50. package/server/dist/index.cjs.map +1 -1
  51. package/server/dist/index.mjs.map +1 -1
  52. package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.cjs +32 -0
  53. package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.cjs.map +1 -0
  54. package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.mjs +31 -0
  55. package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.mjs.map +1 -0
  56. package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +82 -0
  57. package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -0
  58. package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +81 -0
  59. package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -0
  60. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.cjs +26 -0
  61. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.cjs.map +1 -0
  62. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs +25 -0
  63. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs.map +1 -0
  64. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.cjs +24 -0
  65. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.cjs.map +1 -0
  66. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs +23 -0
  67. package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs.map +1 -0
  68. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.cjs +94 -0
  69. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -0
  70. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +92 -0
  71. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -0
  72. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.cjs +416 -0
  73. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.cjs.map +1 -0
  74. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.mjs +412 -0
  75. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -0
  76. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.cjs +127 -0
  77. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.cjs.map +1 -0
  78. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs +125 -0
  79. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -0
  80. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.cjs +164 -0
  81. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -0
  82. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +163 -0
  83. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -0
  84. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.cjs +92 -0
  85. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.cjs.map +1 -0
  86. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs +91 -0
  87. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -0
  88. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.cjs +65 -0
  89. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -0
  90. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +64 -0
  91. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -0
  92. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.cjs +43 -0
  93. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.cjs.map +1 -0
  94. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs +42 -0
  95. package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs.map +1 -0
  96. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.cjs +45 -0
  97. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -0
  98. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +43 -0
  99. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -0
  100. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.cjs +32 -0
  101. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.cjs.map +1 -0
  102. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +32 -0
  103. package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -0
  104. package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.cjs +56 -0
  105. package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.cjs.map +1 -0
  106. package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs +54 -0
  107. package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -0
  108. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.cjs +27 -0
  109. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.cjs.map +1 -0
  110. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.mjs +26 -0
  111. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.mjs.map +1 -0
  112. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.cjs +58 -0
  113. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.cjs.map +1 -0
  114. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs +56 -0
  115. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -0
  116. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.cjs +160 -0
  117. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.cjs.map +1 -0
  118. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs +158 -0
  119. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs.map +1 -0
  120. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.cjs +71 -0
  121. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.cjs.map +1 -0
  122. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.mjs +70 -0
  123. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.mjs.map +1 -0
  124. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.cjs +38 -0
  125. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.cjs.map +1 -0
  126. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.mjs +37 -0
  127. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.mjs.map +1 -0
  128. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.cjs +22 -0
  129. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.cjs.map +1 -0
  130. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.mjs +21 -0
  131. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.mjs.map +1 -0
  132. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.cjs +87 -0
  133. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.cjs.map +1 -0
  134. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.mjs +86 -0
  135. package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.mjs.map +1 -0
  136. package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.cjs +14 -0
  137. package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.cjs.map +1 -0
  138. package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.mjs +13 -0
  139. package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.mjs.map +1 -0
  140. package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.cjs +58 -0
  141. package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.cjs.map +1 -0
  142. package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.mjs +57 -0
  143. package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.mjs.map +1 -0
  144. package/server/dist/routes/config.routes.cjs +1 -0
  145. package/server/dist/routes/config.routes.cjs.map +1 -1
  146. package/server/dist/routes/config.routes.mjs.map +1 -1
  147. package/server/dist/routes/dictionary.routes.cjs +1 -0
  148. package/server/dist/routes/dictionary.routes.cjs.map +1 -1
  149. package/server/dist/routes/dictionary.routes.mjs.map +1 -1
  150. package/server/dist/utils/checkPortAvailability.cjs.map +1 -1
  151. package/server/dist/utils/checkPortAvailability.mjs.map +1 -1
  152. package/server/dist/utils/httpStatusCodes.cjs.map +1 -1
  153. package/server/dist/utils/httpStatusCodes.mjs.map +1 -1
  154. package/server/dist/utils/responseData.cjs.map +1 -1
  155. package/server/dist/utils/responseData.mjs.map +1 -1
  156. package/client/dist/assets/index-CTSrsWZb.css +0 -2
  157. package/client/dist/assets/index-bVSusa0N.js +0 -185
  158. package/client/dist/assets/purify.es-Dt2VzQ8a.js +0 -3
@@ -0,0 +1,54 @@
1
+ import { isValidElement } from "../utils/isValidReactElement.mjs";
2
+ import * as NodeTypes from "@intlayer/types/nodeType";
3
+
4
+ //#region ../../@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs
5
+ /**
6
+ * Type guard to check if content is a TypedNode
7
+ */
8
+ const isTypedNode = (content) => {
9
+ return typeof content === "object" && content !== null && "nodeType" in content && typeof content.nodeType === "string";
10
+ };
11
+ /**
12
+ * Type guard to check if content is a valid NodeType
13
+ */
14
+ const isValidNodeType = (nodeType) => {
15
+ return [
16
+ NodeTypes.TRANSLATION,
17
+ NodeTypes.ENUMERATION,
18
+ NodeTypes.PLURAL,
19
+ NodeTypes.CONDITION,
20
+ NodeTypes.INSERTION,
21
+ NodeTypes.FILE,
22
+ NodeTypes.OBJECT,
23
+ NodeTypes.ARRAY,
24
+ NodeTypes.NESTED,
25
+ NodeTypes.REACT_NODE,
26
+ NodeTypes.MARKDOWN,
27
+ NodeTypes.HTML,
28
+ NodeTypes.TEXT,
29
+ NodeTypes.NUMBER,
30
+ NodeTypes.BOOLEAN,
31
+ NodeTypes.GENDER,
32
+ NodeTypes.NULL,
33
+ NodeTypes.UNKNOWN
34
+ ].includes(nodeType);
35
+ };
36
+ const getNodeType = (content) => {
37
+ if (typeof content === "string") return NodeTypes.TEXT;
38
+ if (isTypedNode(content)) {
39
+ const nodeType = content.nodeType;
40
+ if (isValidNodeType(nodeType)) return nodeType;
41
+ return NodeTypes.UNKNOWN;
42
+ }
43
+ if (Array.isArray(content)) return NodeTypes.ARRAY;
44
+ if (isValidElement(content)) return NodeTypes.REACT_NODE;
45
+ if (typeof content === "number") return NodeTypes.NUMBER;
46
+ if (typeof content === "boolean") return NodeTypes.BOOLEAN;
47
+ if (content && typeof content === "object") return NodeTypes.OBJECT;
48
+ if (content === null) return NodeTypes.NULL;
49
+ return NodeTypes.UNKNOWN;
50
+ };
51
+
52
+ //#endregion
53
+ export { getNodeType };
54
+ //# sourceMappingURL=getNodeType.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNodeType.mjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs"],"sourcesContent":["import { isValidElement } from \"../utils/isValidReactElement.mjs\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/dictionaryManipulator/getNodeType.ts\n/**\n* Type guard to check if content is a TypedNode\n*/\nconst isTypedNode = (content) => {\n\treturn typeof content === \"object\" && content !== null && \"nodeType\" in content && typeof content.nodeType === \"string\";\n};\n/**\n* Type guard to check if content is a valid NodeType\n*/\nconst isValidNodeType = (nodeType) => {\n\treturn [\n\t\tNodeTypes.TRANSLATION,\n\t\tNodeTypes.ENUMERATION,\n\t\tNodeTypes.PLURAL,\n\t\tNodeTypes.CONDITION,\n\t\tNodeTypes.INSERTION,\n\t\tNodeTypes.FILE,\n\t\tNodeTypes.OBJECT,\n\t\tNodeTypes.ARRAY,\n\t\tNodeTypes.NESTED,\n\t\tNodeTypes.REACT_NODE,\n\t\tNodeTypes.MARKDOWN,\n\t\tNodeTypes.HTML,\n\t\tNodeTypes.TEXT,\n\t\tNodeTypes.NUMBER,\n\t\tNodeTypes.BOOLEAN,\n\t\tNodeTypes.GENDER,\n\t\tNodeTypes.NULL,\n\t\tNodeTypes.UNKNOWN\n\t].includes(nodeType);\n};\nconst getNodeType = (content) => {\n\tif (typeof content === \"string\") return NodeTypes.TEXT;\n\tif (isTypedNode(content)) {\n\t\tconst nodeType = content.nodeType;\n\t\tif (isValidNodeType(nodeType)) return nodeType;\n\t\treturn NodeTypes.UNKNOWN;\n\t}\n\tif (Array.isArray(content)) return NodeTypes.ARRAY;\n\tif (isValidElement(content)) return NodeTypes.REACT_NODE;\n\tif (typeof content === \"number\") return NodeTypes.NUMBER;\n\tif (typeof content === \"boolean\") return NodeTypes.BOOLEAN;\n\tif (content && typeof content === \"object\") return NodeTypes.OBJECT;\n\tif (content === null) return NodeTypes.NULL;\n\treturn NodeTypes.UNKNOWN;\n};\n\n//#endregion\nexport { getNodeType };\n//# sourceMappingURL=getNodeType.mjs.map"],"mappings":";;;;;;;AAOA,MAAM,eAAe,YAAY;AAChC,QAAO,OAAO,YAAY,YAAY,YAAY,QAAQ,cAAc,WAAW,OAAO,QAAQ,aAAa;;;;;AAKhH,MAAM,mBAAmB,aAAa;AACrC,QAAO;EACN,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,UAAU;EACV,CAAC,SAAS,SAAS;;AAErB,MAAM,eAAe,YAAY;AAChC,KAAI,OAAO,YAAY,SAAU,QAAO,UAAU;AAClD,KAAI,YAAY,QAAQ,EAAE;EACzB,MAAM,WAAW,QAAQ;AACzB,MAAI,gBAAgB,SAAS,CAAE,QAAO;AACtC,SAAO,UAAU;;AAElB,KAAI,MAAM,QAAQ,QAAQ,CAAE,QAAO,UAAU;AAC7C,KAAI,eAAe,QAAQ,CAAE,QAAO,UAAU;AAC9C,KAAI,OAAO,YAAY,SAAU,QAAO,UAAU;AAClD,KAAI,OAAO,YAAY,UAAW,QAAO,UAAU;AACnD,KAAI,WAAW,OAAO,YAAY,SAAU,QAAO,UAAU;AAC7D,KAAI,YAAY,KAAM,QAAO,UAAU;AACvC,QAAO,UAAU"}
@@ -0,0 +1,27 @@
1
+
2
+ //#region ../../@intlayer/core/dist/esm/interpreter/getCondition.mjs
3
+ /**
4
+ * Picks content based on a boolean condition.
5
+ *
6
+ * @param conditionContent - A map with 'true', 'false', and optionally 'fallback' keys.
7
+ * @param state - The boolean state to match.
8
+ * @returns The matching content.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const content = getCondition({
13
+ * 'true': 'The condition is validated',
14
+ * 'false': 'The condition is not validated',
15
+ * }, true);
16
+ * // 'The condition is validated'
17
+ * ```
18
+ */
19
+ const getCondition = (conditionContent, state) => {
20
+ const stateList = Object.keys(conditionContent);
21
+ const fallbackState = stateList[stateList.length - 1];
22
+ return conditionContent[`${state}`] ?? conditionContent.fallback ?? conditionContent[fallbackState];
23
+ };
24
+
25
+ //#endregion
26
+ exports.getCondition = getCondition;
27
+ //# sourceMappingURL=getCondition.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCondition.cjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getCondition.mjs"],"sourcesContent":["//#region src/interpreter/getCondition.ts\n/**\n* Picks content based on a boolean condition.\n*\n* @param conditionContent - A map with 'true', 'false', and optionally 'fallback' keys.\n* @param state - The boolean state to match.\n* @returns The matching content.\n*\n* @example\n* ```ts\n* const content = getCondition({\n* 'true': 'The condition is validated',\n* 'false': 'The condition is not validated',\n* }, true);\n* // 'The condition is validated'\n* ```\n*/\nconst getCondition = (conditionContent, state) => {\n\tconst stateList = Object.keys(conditionContent);\n\tconst fallbackState = stateList[stateList.length - 1];\n\treturn conditionContent[`${state}`] ?? conditionContent.fallback ?? conditionContent[fallbackState];\n};\n\n//#endregion\nexport { getCondition };\n//# sourceMappingURL=getCondition.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAM,gBAAgB,kBAAkB,UAAU;CACjD,MAAM,YAAY,OAAO,KAAK,iBAAiB;CAC/C,MAAM,gBAAgB,UAAU,UAAU,SAAS;AACnD,QAAO,iBAAiB,GAAG,YAAY,iBAAiB,YAAY,iBAAiB"}
@@ -0,0 +1,26 @@
1
+ //#region ../../@intlayer/core/dist/esm/interpreter/getCondition.mjs
2
+ /**
3
+ * Picks content based on a boolean condition.
4
+ *
5
+ * @param conditionContent - A map with 'true', 'false', and optionally 'fallback' keys.
6
+ * @param state - The boolean state to match.
7
+ * @returns The matching content.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const content = getCondition({
12
+ * 'true': 'The condition is validated',
13
+ * 'false': 'The condition is not validated',
14
+ * }, true);
15
+ * // 'The condition is validated'
16
+ * ```
17
+ */
18
+ const getCondition = (conditionContent, state) => {
19
+ const stateList = Object.keys(conditionContent);
20
+ const fallbackState = stateList[stateList.length - 1];
21
+ return conditionContent[`${state}`] ?? conditionContent.fallback ?? conditionContent[fallbackState];
22
+ };
23
+
24
+ //#endregion
25
+ export { getCondition };
26
+ //# sourceMappingURL=getCondition.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCondition.mjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getCondition.mjs"],"sourcesContent":["//#region src/interpreter/getCondition.ts\n/**\n* Picks content based on a boolean condition.\n*\n* @param conditionContent - A map with 'true', 'false', and optionally 'fallback' keys.\n* @param state - The boolean state to match.\n* @returns The matching content.\n*\n* @example\n* ```ts\n* const content = getCondition({\n* 'true': 'The condition is validated',\n* 'false': 'The condition is not validated',\n* }, true);\n* // 'The condition is validated'\n* ```\n*/\nconst getCondition = (conditionContent, state) => {\n\tconst stateList = Object.keys(conditionContent);\n\tconst fallbackState = stateList[stateList.length - 1];\n\treturn conditionContent[`${state}`] ?? conditionContent.fallback ?? conditionContent[fallbackState];\n};\n\n//#endregion\nexport { getCondition };\n//# sourceMappingURL=getCondition.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,gBAAgB,kBAAkB,UAAU;CACjD,MAAM,YAAY,OAAO,KAAK,iBAAiB;CAC/C,MAAM,gBAAgB,UAAU,UAAU,SAAS;AACnD,QAAO,iBAAiB,GAAG,YAAY,iBAAiB,YAAY,iBAAiB"}
@@ -0,0 +1,58 @@
1
+ const require_runtime = require('../../../../../../../_virtual/_rolldown/runtime.cjs');
2
+ let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
3
+ _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType, 1);
4
+
5
+ //#region ../../@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs
6
+ /**
7
+ * Recursively traverses a node (object/array/primitive).
8
+ * Applies the *first* plugin that can transform a node, then stops descending further.
9
+ * If no plugin transforms it, it recurses into its children.
10
+ */
11
+ const deepTransformNode = (node, props) => {
12
+ for (const plugin of props.plugins ?? []) if (plugin.canHandle(node)) return plugin.transform(node, props, (node, props) => deepTransformNode(node, props));
13
+ if (node === null || typeof node !== "object") return node;
14
+ if (node.$$typeof !== void 0 || node.__v_isVNode !== void 0 || node._isVNode !== void 0 || node.isJSX !== void 0 || typeof node === "function") return node;
15
+ if (Array.isArray(node)) return node.map((child, index) => {
16
+ return deepTransformNode(child, {
17
+ ...props,
18
+ children: child,
19
+ keyPath: [...props.keyPath, {
20
+ type: _intlayer_types_nodeType.ARRAY,
21
+ key: index
22
+ }]
23
+ });
24
+ });
25
+ const result = {};
26
+ for (const key in node) {
27
+ const childProps = {
28
+ ...props,
29
+ children: node[key],
30
+ keyPath: [...props.keyPath, {
31
+ type: _intlayer_types_nodeType.OBJECT,
32
+ key
33
+ }]
34
+ };
35
+ if (props.eager) {
36
+ result[key] = deepTransformNode(node[key], childProps);
37
+ continue;
38
+ }
39
+ Object.defineProperty(result, key, {
40
+ enumerable: true,
41
+ configurable: true,
42
+ get: function() {
43
+ const transformed = deepTransformNode(node[key], childProps);
44
+ Object.defineProperty(this, key, {
45
+ value: transformed,
46
+ enumerable: true,
47
+ configurable: true
48
+ });
49
+ return transformed;
50
+ }
51
+ });
52
+ }
53
+ return result;
54
+ };
55
+
56
+ //#endregion
57
+ exports.deepTransformNode = deepTransformNode;
58
+ //# sourceMappingURL=deepTransform.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepTransform.cjs","names":["NodeTypes"],"sources":["../../../../../../../../../../@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs"],"sourcesContent":["import * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/interpreter/getContent/deepTransform.ts\n/**\n* Recursively traverses a node (object/array/primitive).\n* Applies the *first* plugin that can transform a node, then stops descending further.\n* If no plugin transforms it, it recurses into its children.\n*/\nconst deepTransformNode = (node, props) => {\n\tfor (const plugin of props.plugins ?? []) if (plugin.canHandle(node)) return plugin.transform(node, props, (node, props) => deepTransformNode(node, props));\n\tif (node === null || typeof node !== \"object\") return node;\n\tif (node.$$typeof !== void 0 || node.__v_isVNode !== void 0 || node._isVNode !== void 0 || node.isJSX !== void 0 || typeof node === \"function\") return node;\n\tif (Array.isArray(node)) return node.map((child, index) => {\n\t\treturn deepTransformNode(child, {\n\t\t\t...props,\n\t\t\tchildren: child,\n\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\ttype: NodeTypes.ARRAY,\n\t\t\t\tkey: index\n\t\t\t}]\n\t\t});\n\t});\n\tconst result = {};\n\tfor (const key in node) {\n\t\tconst childProps = {\n\t\t\t...props,\n\t\t\tchildren: node[key],\n\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\ttype: NodeTypes.OBJECT,\n\t\t\t\tkey\n\t\t\t}]\n\t\t};\n\t\tif (props.eager) {\n\t\t\tresult[key] = deepTransformNode(node[key], childProps);\n\t\t\tcontinue;\n\t\t}\n\t\tObject.defineProperty(result, key, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\tget: function() {\n\t\t\t\tconst transformed = deepTransformNode(node[key], childProps);\n\t\t\t\tObject.defineProperty(this, key, {\n\t\t\t\t\tvalue: transformed,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true\n\t\t\t\t});\n\t\t\t\treturn transformed;\n\t\t\t}\n\t\t});\n\t}\n\treturn result;\n};\n\n//#endregion\nexport { deepTransformNode };\n//# sourceMappingURL=deepTransform.mjs.map"],"mappings":";;;;;;;;;;AAQA,MAAM,qBAAqB,MAAM,UAAU;AAC1C,MAAK,MAAM,UAAU,MAAM,WAAW,EAAE,CAAE,KAAI,OAAO,UAAU,KAAK,CAAE,QAAO,OAAO,UAAU,MAAM,QAAQ,MAAM,UAAU,kBAAkB,MAAM,MAAM,CAAC;AAC3J,KAAI,SAAS,QAAQ,OAAO,SAAS,SAAU,QAAO;AACtD,KAAI,KAAK,aAAa,KAAK,KAAK,KAAK,gBAAgB,KAAK,KAAK,KAAK,aAAa,KAAK,KAAK,KAAK,UAAU,KAAK,KAAK,OAAO,SAAS,WAAY,QAAO;AACvJ,KAAI,MAAM,QAAQ,KAAK,CAAE,QAAO,KAAK,KAAK,OAAO,UAAU;AAC1D,SAAO,kBAAkB,OAAO;GAC/B,GAAG;GACH,UAAU;GACV,SAAS,CAAC,GAAG,MAAM,SAAS;IAC3B,MAAMA,yBAAU;IAChB,KAAK;IACL,CAAC;GACF,CAAC;GACD;CACF,MAAM,SAAS,EAAE;AACjB,MAAK,MAAM,OAAO,MAAM;EACvB,MAAM,aAAa;GAClB,GAAG;GACH,UAAU,KAAK;GACf,SAAS,CAAC,GAAG,MAAM,SAAS;IAC3B,MAAMA,yBAAU;IAChB;IACA,CAAC;GACF;AACD,MAAI,MAAM,OAAO;AAChB,UAAO,OAAO,kBAAkB,KAAK,MAAM,WAAW;AACtD;;AAED,SAAO,eAAe,QAAQ,KAAK;GAClC,YAAY;GACZ,cAAc;GACd,KAAK,WAAW;IACf,MAAM,cAAc,kBAAkB,KAAK,MAAM,WAAW;AAC5D,WAAO,eAAe,MAAM,KAAK;KAChC,OAAO;KACP,YAAY;KACZ,cAAc;KACd,CAAC;AACF,WAAO;;GAER,CAAC;;AAEH,QAAO"}
@@ -0,0 +1,56 @@
1
+ import * as NodeTypes from "@intlayer/types/nodeType";
2
+
3
+ //#region ../../@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs
4
+ /**
5
+ * Recursively traverses a node (object/array/primitive).
6
+ * Applies the *first* plugin that can transform a node, then stops descending further.
7
+ * If no plugin transforms it, it recurses into its children.
8
+ */
9
+ const deepTransformNode = (node, props) => {
10
+ for (const plugin of props.plugins ?? []) if (plugin.canHandle(node)) return plugin.transform(node, props, (node, props) => deepTransformNode(node, props));
11
+ if (node === null || typeof node !== "object") return node;
12
+ if (node.$$typeof !== void 0 || node.__v_isVNode !== void 0 || node._isVNode !== void 0 || node.isJSX !== void 0 || typeof node === "function") return node;
13
+ if (Array.isArray(node)) return node.map((child, index) => {
14
+ return deepTransformNode(child, {
15
+ ...props,
16
+ children: child,
17
+ keyPath: [...props.keyPath, {
18
+ type: NodeTypes.ARRAY,
19
+ key: index
20
+ }]
21
+ });
22
+ });
23
+ const result = {};
24
+ for (const key in node) {
25
+ const childProps = {
26
+ ...props,
27
+ children: node[key],
28
+ keyPath: [...props.keyPath, {
29
+ type: NodeTypes.OBJECT,
30
+ key
31
+ }]
32
+ };
33
+ if (props.eager) {
34
+ result[key] = deepTransformNode(node[key], childProps);
35
+ continue;
36
+ }
37
+ Object.defineProperty(result, key, {
38
+ enumerable: true,
39
+ configurable: true,
40
+ get: function() {
41
+ const transformed = deepTransformNode(node[key], childProps);
42
+ Object.defineProperty(this, key, {
43
+ value: transformed,
44
+ enumerable: true,
45
+ configurable: true
46
+ });
47
+ return transformed;
48
+ }
49
+ });
50
+ }
51
+ return result;
52
+ };
53
+
54
+ //#endregion
55
+ export { deepTransformNode };
56
+ //# sourceMappingURL=deepTransform.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepTransform.mjs","names":[],"sources":["../../../../../../../../../../@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs"],"sourcesContent":["import * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/interpreter/getContent/deepTransform.ts\n/**\n* Recursively traverses a node (object/array/primitive).\n* Applies the *first* plugin that can transform a node, then stops descending further.\n* If no plugin transforms it, it recurses into its children.\n*/\nconst deepTransformNode = (node, props) => {\n\tfor (const plugin of props.plugins ?? []) if (plugin.canHandle(node)) return plugin.transform(node, props, (node, props) => deepTransformNode(node, props));\n\tif (node === null || typeof node !== \"object\") return node;\n\tif (node.$$typeof !== void 0 || node.__v_isVNode !== void 0 || node._isVNode !== void 0 || node.isJSX !== void 0 || typeof node === \"function\") return node;\n\tif (Array.isArray(node)) return node.map((child, index) => {\n\t\treturn deepTransformNode(child, {\n\t\t\t...props,\n\t\t\tchildren: child,\n\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\ttype: NodeTypes.ARRAY,\n\t\t\t\tkey: index\n\t\t\t}]\n\t\t});\n\t});\n\tconst result = {};\n\tfor (const key in node) {\n\t\tconst childProps = {\n\t\t\t...props,\n\t\t\tchildren: node[key],\n\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\ttype: NodeTypes.OBJECT,\n\t\t\t\tkey\n\t\t\t}]\n\t\t};\n\t\tif (props.eager) {\n\t\t\tresult[key] = deepTransformNode(node[key], childProps);\n\t\t\tcontinue;\n\t\t}\n\t\tObject.defineProperty(result, key, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\tget: function() {\n\t\t\t\tconst transformed = deepTransformNode(node[key], childProps);\n\t\t\t\tObject.defineProperty(this, key, {\n\t\t\t\t\tvalue: transformed,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true\n\t\t\t\t});\n\t\t\t\treturn transformed;\n\t\t\t}\n\t\t});\n\t}\n\treturn result;\n};\n\n//#endregion\nexport { deepTransformNode };\n//# sourceMappingURL=deepTransform.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,qBAAqB,MAAM,UAAU;AAC1C,MAAK,MAAM,UAAU,MAAM,WAAW,EAAE,CAAE,KAAI,OAAO,UAAU,KAAK,CAAE,QAAO,OAAO,UAAU,MAAM,QAAQ,MAAM,UAAU,kBAAkB,MAAM,MAAM,CAAC;AAC3J,KAAI,SAAS,QAAQ,OAAO,SAAS,SAAU,QAAO;AACtD,KAAI,KAAK,aAAa,KAAK,KAAK,KAAK,gBAAgB,KAAK,KAAK,KAAK,aAAa,KAAK,KAAK,KAAK,UAAU,KAAK,KAAK,OAAO,SAAS,WAAY,QAAO;AACvJ,KAAI,MAAM,QAAQ,KAAK,CAAE,QAAO,KAAK,KAAK,OAAO,UAAU;AAC1D,SAAO,kBAAkB,OAAO;GAC/B,GAAG;GACH,UAAU;GACV,SAAS,CAAC,GAAG,MAAM,SAAS;IAC3B,MAAM,UAAU;IAChB,KAAK;IACL,CAAC;GACF,CAAC;GACD;CACF,MAAM,SAAS,EAAE;AACjB,MAAK,MAAM,OAAO,MAAM;EACvB,MAAM,aAAa;GAClB,GAAG;GACH,UAAU,KAAK;GACf,SAAS,CAAC,GAAG,MAAM,SAAS;IAC3B,MAAM,UAAU;IAChB;IACA,CAAC;GACF;AACD,MAAI,MAAM,OAAO;AAChB,UAAO,OAAO,kBAAkB,KAAK,MAAM,WAAW;AACtD;;AAED,SAAO,eAAe,QAAQ,KAAK;GAClC,YAAY;GACZ,cAAc;GACd,KAAK,WAAW;IACf,MAAM,cAAc,kBAAkB,KAAK,MAAM,WAAW;AAC5D,WAAO,eAAe,MAAM,KAAK;KAChC,OAAO;KACP,YAAY;KACZ,cAAc;KACd,CAAC;AACF,WAAO;;GAER,CAAC;;AAEH,QAAO"}
@@ -0,0 +1,160 @@
1
+ const require_runtime = require('../../../../../../../_virtual/_rolldown/runtime.cjs');
2
+ const require_getTranslation = require('../getTranslation.cjs');
3
+ const require_getCondition = require('../getCondition.cjs');
4
+ const require_getEnumeration = require('../getEnumeration.cjs');
5
+ const require_getGender = require('../getGender.cjs');
6
+ const require_getInsertion = require('../getInsertion.cjs');
7
+ let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
8
+ _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType, 1);
9
+
10
+ //#region ../../@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs
11
+ /** ---------------------------------------------
12
+ * FALLBACK PLUGIN
13
+ *
14
+ * Used to fallback a tree-shaken plugin
15
+ * --------------------------------------------- */
16
+ const fallbackPlugin = {
17
+ id: "fallback-plugin",
18
+ canHandle: () => false,
19
+ transform: (node) => node
20
+ };
21
+ /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
22
+ const translationPlugin = (locale, fallback) => process.env["INTLAYER_NODE_TYPE_TRANSLATION"] === "false" ? fallbackPlugin : {
23
+ id: "translation-plugin",
24
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.TRANSLATION,
25
+ transform: (node, props, deepTransformNode) => {
26
+ const original = node[_intlayer_types_nodeType.TRANSLATION] ?? {};
27
+ const result = {};
28
+ for (const key in original) {
29
+ const childProps = {
30
+ ...props,
31
+ children: original[key],
32
+ keyPath: [...props.keyPath, {
33
+ type: _intlayer_types_nodeType.TRANSLATION,
34
+ key
35
+ }]
36
+ };
37
+ result[key] = deepTransformNode(original[key], childProps);
38
+ }
39
+ return require_getTranslation.getTranslation(result, locale, fallback);
40
+ }
41
+ };
42
+ /** Enumeration plugin. Replaces node with a function that takes quantity => string. */
43
+ const enumerationPlugin = process.env["INTLAYER_NODE_TYPE_ENUMERATION"] === "false" ? fallbackPlugin : {
44
+ id: "enumeration-plugin",
45
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.ENUMERATION,
46
+ transform: (node, props, deepTransformNode) => {
47
+ const original = node[_intlayer_types_nodeType.ENUMERATION];
48
+ const result = {};
49
+ for (const key in original) {
50
+ const child = original[key];
51
+ result[key] = deepTransformNode(child, {
52
+ ...props,
53
+ children: child,
54
+ keyPath: [...props.keyPath, {
55
+ type: _intlayer_types_nodeType.ENUMERATION,
56
+ key
57
+ }]
58
+ });
59
+ }
60
+ return (arg) => {
61
+ const subResult = require_getEnumeration.getEnumeration(result, typeof arg === "number" ? arg : arg.count);
62
+ if (typeof subResult === "function" && typeof arg === "object") return subResult(arg);
63
+ return subResult;
64
+ };
65
+ }
66
+ };
67
+ /** Condition plugin. Replaces node with a function that takes boolean => string. */
68
+ const conditionPlugin = process.env["INTLAYER_NODE_TYPE_CONDITION"] === "false" ? fallbackPlugin : {
69
+ id: "condition-plugin",
70
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.CONDITION,
71
+ transform: (node, props, deepTransformNode) => {
72
+ const original = node[_intlayer_types_nodeType.CONDITION];
73
+ const result = {};
74
+ for (const key in original) {
75
+ const child = original[key];
76
+ result[key] = deepTransformNode(child, {
77
+ ...props,
78
+ children: child,
79
+ keyPath: [...props.keyPath, {
80
+ type: _intlayer_types_nodeType.CONDITION,
81
+ key
82
+ }]
83
+ });
84
+ }
85
+ return (arg) => {
86
+ const subResult = require_getCondition.getCondition(result, typeof arg === "boolean" ? arg : arg.value);
87
+ if (typeof subResult === "function" && typeof arg === "object") return subResult(arg);
88
+ return subResult;
89
+ };
90
+ }
91
+ };
92
+ /** Insertion plugin. Replaces node with a function that takes quantity => string. */
93
+ const insertionPlugin = process.env["INTLAYER_NODE_TYPE_INSERTION"] === "false" ? fallbackPlugin : {
94
+ id: "insertion-plugin",
95
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.INSERTION,
96
+ transform: (node, props, deepTransformNode) => {
97
+ const newKeyPath = [...props.keyPath, { type: _intlayer_types_nodeType.INSERTION }];
98
+ const children = node[_intlayer_types_nodeType.INSERTION];
99
+ /** Insertion string plugin. Replaces string node with a component that render the insertion. */
100
+ const insertionStringPlugin = {
101
+ id: "insertion-string-plugin",
102
+ canHandle: (node) => typeof node === "string",
103
+ transform: (node, subProps, deepTransformNode) => {
104
+ const transformedResult = deepTransformNode(node, {
105
+ ...subProps,
106
+ children: node,
107
+ plugins: [...(props.plugins ?? []).filter((plugin) => plugin.id !== "intlayer-node-plugin")]
108
+ });
109
+ return (values) => {
110
+ const children = require_getInsertion.getInsertion(transformedResult, values);
111
+ return deepTransformNode(children, {
112
+ ...subProps,
113
+ plugins: props.plugins,
114
+ children
115
+ });
116
+ };
117
+ }
118
+ };
119
+ return deepTransformNode(children, {
120
+ ...props,
121
+ children,
122
+ keyPath: newKeyPath,
123
+ plugins: [insertionStringPlugin, ...props.plugins ?? []]
124
+ });
125
+ }
126
+ };
127
+ /** Gender plugin. Replaces node with a function that takes gender => string. */
128
+ const genderPlugin = process.env["INTLAYER_NODE_TYPE_GENDER"] === "false" ? fallbackPlugin : {
129
+ id: "gender-plugin",
130
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.GENDER,
131
+ transform: (node, props, deepTransformNode) => {
132
+ const original = node[_intlayer_types_nodeType.GENDER];
133
+ const result = {};
134
+ for (const key in original) {
135
+ const child = original[key];
136
+ result[key] = deepTransformNode(child, {
137
+ ...props,
138
+ children: child,
139
+ keyPath: [...props.keyPath, {
140
+ type: _intlayer_types_nodeType.GENDER,
141
+ key
142
+ }]
143
+ });
144
+ }
145
+ return (value) => require_getGender.getGender(result, value);
146
+ }
147
+ };
148
+ /** File plugin. Replaces node with the result of `getNesting`. */
149
+ const filePlugin = process.env["INTLAYER_NODE_TYPE_FILE"] === "false" ? fallbackPlugin : {
150
+ id: "file-plugin",
151
+ canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types_nodeType.FILE,
152
+ transform: (node, props, deepTransform) => deepTransform(node.content, {
153
+ ...props,
154
+ children: node.content
155
+ })
156
+ };
157
+
158
+ //#endregion
159
+ exports.translationPlugin = translationPlugin;
160
+ //# sourceMappingURL=plugins.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.cjs","names":["NodeTypes","getTranslation","getEnumeration","getCondition","getInsertion","getGender"],"sources":["../../../../../../../../../../@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs"],"sourcesContent":["import { getCondition } from \"../getCondition.mjs\";\nimport { getEnumeration } from \"../getEnumeration.mjs\";\nimport { getGender } from \"../getGender.mjs\";\nimport { getInsertion } from \"../getInsertion.mjs\";\nimport { getNesting } from \"../getNesting.mjs\";\nimport { getPlural } from \"../getPlural.mjs\";\nimport { getTranslation } from \"../getTranslation.mjs\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/interpreter/getContent/plugins.ts\n/** ---------------------------------------------\n* FALLBACK PLUGIN\n*\n* Used to fallback a tree-shaken plugin\n* --------------------------------------------- */\nconst fallbackPlugin = {\n\tid: \"fallback-plugin\",\n\tcanHandle: () => false,\n\ttransform: (node) => node\n};\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nconst translationPlugin = (locale, fallback) => process.env[\"INTLAYER_NODE_TYPE_TRANSLATION\"] === \"false\" ? fallbackPlugin : {\n\tid: \"translation-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.TRANSLATION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.TRANSLATION] ?? {};\n\t\tconst result = {};\n\t\tfor (const key in original) {\n\t\t\tconst childProps = {\n\t\t\t\t...props,\n\t\t\t\tchildren: original[key],\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.TRANSLATION,\n\t\t\t\t\tkey\n\t\t\t\t}]\n\t\t\t};\n\t\t\tresult[key] = deepTransformNode(original[key], childProps);\n\t\t}\n\t\treturn getTranslation(result, locale, fallback);\n\t}\n};\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nconst enumerationPlugin = process.env[\"INTLAYER_NODE_TYPE_ENUMERATION\"] === \"false\" ? fallbackPlugin : {\n\tid: \"enumeration-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.ENUMERATION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.ENUMERATION];\n\t\tconst result = {};\n\t\tfor (const key in original) {\n\t\t\tconst child = original[key];\n\t\t\tresult[key] = deepTransformNode(child, {\n\t\t\t\t...props,\n\t\t\t\tchildren: child,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.ENUMERATION,\n\t\t\t\t\tkey\n\t\t\t\t}]\n\t\t\t});\n\t\t}\n\t\treturn (arg) => {\n\t\t\tconst subResult = getEnumeration(result, typeof arg === \"number\" ? arg : arg.count);\n\t\t\tif (typeof subResult === \"function\" && typeof arg === \"object\") return subResult(arg);\n\t\t\treturn subResult;\n\t\t};\n\t}\n};\n/**\n* Plural plugin. Replaces node with a function that takes a count (or\n* `{ count, ...values }`) => string, picking the matching CLDR plural form\n* for the active locale and interpolating `{{count}}` (and other values).\n*/\nconst pluralPlugin = (locale) => process.env[\"INTLAYER_NODE_TYPE_PLURAL\"] === \"false\" ? fallbackPlugin : {\n\tid: \"plural-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.PLURAL,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.PLURAL];\n\t\tconst result = {};\n\t\t/** String plugin for plural. Replaces string node with a component that renders the insertion. */\n\t\tconst pluralStringPlugin = {\n\t\t\tid: \"plural-string-plugin\",\n\t\t\tcanHandle: (node) => typeof node === \"string\",\n\t\t\ttransform: (node, subProps, deepTransformNode) => {\n\t\t\t\tconst transformedResult = deepTransformNode(node, {\n\t\t\t\t\t...subProps,\n\t\t\t\t\tchildren: node,\n\t\t\t\t\tplugins: [...(props.plugins ?? []).filter((plugin) => plugin.id !== \"intlayer-node-plugin\")]\n\t\t\t\t});\n\t\t\t\treturn (values) => {\n\t\t\t\t\tconst children = getInsertion(transformedResult, values);\n\t\t\t\t\treturn deepTransformNode(children, {\n\t\t\t\t\t\t...subProps,\n\t\t\t\t\t\tplugins: props.plugins,\n\t\t\t\t\t\tchildren\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tfor (const key in original) {\n\t\t\tconst child = original[key];\n\t\t\tresult[key] = deepTransformNode(child, {\n\t\t\t\t...props,\n\t\t\t\tchildren: child,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.PLURAL,\n\t\t\t\t\tkey\n\t\t\t\t}],\n\t\t\t\tplugins: [pluralStringPlugin, ...props.plugins ?? []]\n\t\t\t});\n\t\t}\n\t\tconst effectiveLocale = String(locale ?? props.locale ?? \"en\");\n\t\treturn (arg) => {\n\t\t\tconst count = typeof arg === \"number\" ? arg : arg.count;\n\t\t\tconst values = typeof arg === \"number\" ? { count: arg } : arg;\n\t\t\tconst subResult = getPlural(result, count, effectiveLocale);\n\t\t\tif (typeof subResult === \"function\") return subResult(values);\n\t\t\treturn subResult;\n\t\t};\n\t}\n};\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nconst conditionPlugin = process.env[\"INTLAYER_NODE_TYPE_CONDITION\"] === \"false\" ? fallbackPlugin : {\n\tid: \"condition-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.CONDITION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.CONDITION];\n\t\tconst result = {};\n\t\tfor (const key in original) {\n\t\t\tconst child = original[key];\n\t\t\tresult[key] = deepTransformNode(child, {\n\t\t\t\t...props,\n\t\t\t\tchildren: child,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.CONDITION,\n\t\t\t\t\tkey\n\t\t\t\t}]\n\t\t\t});\n\t\t}\n\t\treturn (arg) => {\n\t\t\tconst subResult = getCondition(result, typeof arg === \"boolean\" ? arg : arg.value);\n\t\t\tif (typeof subResult === \"function\" && typeof arg === \"object\") return subResult(arg);\n\t\t\treturn subResult;\n\t\t};\n\t}\n};\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nconst insertionPlugin = process.env[\"INTLAYER_NODE_TYPE_INSERTION\"] === \"false\" ? fallbackPlugin : {\n\tid: \"insertion-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.INSERTION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst newKeyPath = [...props.keyPath, { type: NodeTypes.INSERTION }];\n\t\tconst children = node[NodeTypes.INSERTION];\n\t\t/** Insertion string plugin. Replaces string node with a component that render the insertion. */\n\t\tconst insertionStringPlugin = {\n\t\t\tid: \"insertion-string-plugin\",\n\t\t\tcanHandle: (node) => typeof node === \"string\",\n\t\t\ttransform: (node, subProps, deepTransformNode) => {\n\t\t\t\tconst transformedResult = deepTransformNode(node, {\n\t\t\t\t\t...subProps,\n\t\t\t\t\tchildren: node,\n\t\t\t\t\tplugins: [...(props.plugins ?? []).filter((plugin) => plugin.id !== \"intlayer-node-plugin\")]\n\t\t\t\t});\n\t\t\t\treturn (values) => {\n\t\t\t\t\tconst children = getInsertion(transformedResult, values);\n\t\t\t\t\treturn deepTransformNode(children, {\n\t\t\t\t\t\t...subProps,\n\t\t\t\t\t\tplugins: props.plugins,\n\t\t\t\t\t\tchildren\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\treturn deepTransformNode(children, {\n\t\t\t...props,\n\t\t\tchildren,\n\t\t\tkeyPath: newKeyPath,\n\t\t\tplugins: [insertionStringPlugin, ...props.plugins ?? []]\n\t\t});\n\t}\n};\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nconst genderPlugin = process.env[\"INTLAYER_NODE_TYPE_GENDER\"] === \"false\" ? fallbackPlugin : {\n\tid: \"gender-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.GENDER,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.GENDER];\n\t\tconst result = {};\n\t\tfor (const key in original) {\n\t\t\tconst child = original[key];\n\t\t\tresult[key] = deepTransformNode(child, {\n\t\t\t\t...props,\n\t\t\t\tchildren: child,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.GENDER,\n\t\t\t\t\tkey\n\t\t\t\t}]\n\t\t\t});\n\t\t}\n\t\treturn (value) => getGender(result, value);\n\t}\n};\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nconst nestedPlugin = (locale) => process.env[\"INTLAYER_NODE_TYPE_NESTED\"] === \"false\" ? fallbackPlugin : {\n\tid: \"nested-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && (node?.nodeType === NodeTypes.NESTED || node?.nodeType === \"n\"),\n\ttransform: (node, props) => getNesting(node[NodeTypes.NESTED].dictionaryKey, node[NodeTypes.NESTED].path, {\n\t\t...props,\n\t\tlocale: locale ?? props.locale\n\t})\n};\n/** File plugin. Replaces node with the result of `getNesting`. */\nconst filePlugin = process.env[\"INTLAYER_NODE_TYPE_FILE\"] === \"false\" ? fallbackPlugin : {\n\tid: \"file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.FILE,\n\ttransform: (node, props, deepTransform) => deepTransform(node.content, {\n\t\t...props,\n\t\tchildren: node.content\n\t})\n};\n\n//#endregion\nexport { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, pluralPlugin, translationPlugin };\n//# sourceMappingURL=plugins.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,iBAAiB;CACtB,IAAI;CACJ,iBAAiB;CACjB,YAAY,SAAS;CACrB;;AAED,MAAM,qBAAqB,QAAQ,aAAa,QAAQ,IAAI,sCAAsC,UAAU,iBAAiB;CAC5H,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaA,yBAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,WAAW,KAAKA,yBAAU,gBAAgB,EAAE;EAClD,MAAM,SAAS,EAAE;AACjB,OAAK,MAAM,OAAO,UAAU;GAC3B,MAAM,aAAa;IAClB,GAAG;IACH,UAAU,SAAS;IACnB,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAMA,yBAAU;KAChB;KACA,CAAC;IACF;AACD,UAAO,OAAO,kBAAkB,SAAS,MAAM,WAAW;;AAE3D,SAAOC,sCAAe,QAAQ,QAAQ,SAAS;;CAEhD;;AAED,MAAM,oBAAoB,QAAQ,IAAI,sCAAsC,UAAU,iBAAiB;CACtG,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaD,yBAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,WAAW,KAAKA,yBAAU;EAChC,MAAM,SAAS,EAAE;AACjB,OAAK,MAAM,OAAO,UAAU;GAC3B,MAAM,QAAQ,SAAS;AACvB,UAAO,OAAO,kBAAkB,OAAO;IACtC,GAAG;IACH,UAAU;IACV,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAMA,yBAAU;KAChB;KACA,CAAC;IACF,CAAC;;AAEH,UAAQ,QAAQ;GACf,MAAM,YAAYE,sCAAe,QAAQ,OAAO,QAAQ,WAAW,MAAM,IAAI,MAAM;AACnF,OAAI,OAAO,cAAc,cAAc,OAAO,QAAQ,SAAU,QAAO,UAAU,IAAI;AACrF,UAAO;;;CAGT;;AAuDD,MAAM,kBAAkB,QAAQ,IAAI,oCAAoC,UAAU,iBAAiB;CAClG,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaF,yBAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,WAAW,KAAKA,yBAAU;EAChC,MAAM,SAAS,EAAE;AACjB,OAAK,MAAM,OAAO,UAAU;GAC3B,MAAM,QAAQ,SAAS;AACvB,UAAO,OAAO,kBAAkB,OAAO;IACtC,GAAG;IACH,UAAU;IACV,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAMA,yBAAU;KAChB;KACA,CAAC;IACF,CAAC;;AAEH,UAAQ,QAAQ;GACf,MAAM,YAAYG,kCAAa,QAAQ,OAAO,QAAQ,YAAY,MAAM,IAAI,MAAM;AAClF,OAAI,OAAO,cAAc,cAAc,OAAO,QAAQ,SAAU,QAAO,UAAU,IAAI;AACrF,UAAO;;;CAGT;;AAED,MAAM,kBAAkB,QAAQ,IAAI,oCAAoC,UAAU,iBAAiB;CAClG,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaH,yBAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,aAAa,CAAC,GAAG,MAAM,SAAS,EAAE,MAAMA,yBAAU,WAAW,CAAC;EACpE,MAAM,WAAW,KAAKA,yBAAU;;EAEhC,MAAM,wBAAwB;GAC7B,IAAI;GACJ,YAAY,SAAS,OAAO,SAAS;GACrC,YAAY,MAAM,UAAU,sBAAsB;IACjD,MAAM,oBAAoB,kBAAkB,MAAM;KACjD,GAAG;KACH,UAAU;KACV,SAAS,CAAC,IAAI,MAAM,WAAW,EAAE,EAAE,QAAQ,WAAW,OAAO,OAAO,uBAAuB,CAAC;KAC5F,CAAC;AACF,YAAQ,WAAW;KAClB,MAAM,WAAWI,kCAAa,mBAAmB,OAAO;AACxD,YAAO,kBAAkB,UAAU;MAClC,GAAG;MACH,SAAS,MAAM;MACf;MACA,CAAC;;;GAGJ;AACD,SAAO,kBAAkB,UAAU;GAClC,GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,uBAAuB,GAAG,MAAM,WAAW,EAAE,CAAC;GACxD,CAAC;;CAEH;;AAED,MAAM,eAAe,QAAQ,IAAI,iCAAiC,UAAU,iBAAiB;CAC5F,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaJ,yBAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,WAAW,KAAKA,yBAAU;EAChC,MAAM,SAAS,EAAE;AACjB,OAAK,MAAM,OAAO,UAAU;GAC3B,MAAM,QAAQ,SAAS;AACvB,UAAO,OAAO,kBAAkB,OAAO;IACtC,GAAG;IACH,UAAU;IACV,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAMA,yBAAU;KAChB;KACA,CAAC;IACF,CAAC;;AAEH,UAAQ,UAAUK,4BAAU,QAAQ,MAAM;;CAE3C;;AAWD,MAAM,aAAa,QAAQ,IAAI,+BAA+B,UAAU,iBAAiB;CACxF,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAaL,yBAAU;CAC9E,YAAY,MAAM,OAAO,kBAAkB,cAAc,KAAK,SAAS;EACtE,GAAG;EACH,UAAU,KAAK;EACf,CAAC;CACF"}
@@ -0,0 +1,158 @@
1
+ import { getTranslation } from "../getTranslation.mjs";
2
+ import { getCondition } from "../getCondition.mjs";
3
+ import { getEnumeration } from "../getEnumeration.mjs";
4
+ import { getGender } from "../getGender.mjs";
5
+ import { getInsertion } from "../getInsertion.mjs";
6
+ import * as NodeTypes from "@intlayer/types/nodeType";
7
+
8
+ //#region ../../@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs
9
+ /** ---------------------------------------------
10
+ * FALLBACK PLUGIN
11
+ *
12
+ * Used to fallback a tree-shaken plugin
13
+ * --------------------------------------------- */
14
+ const fallbackPlugin = {
15
+ id: "fallback-plugin",
16
+ canHandle: () => false,
17
+ transform: (node) => node
18
+ };
19
+ /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
20
+ const translationPlugin = (locale, fallback) => process.env["INTLAYER_NODE_TYPE_TRANSLATION"] === "false" ? fallbackPlugin : {
21
+ id: "translation-plugin",
22
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.TRANSLATION,
23
+ transform: (node, props, deepTransformNode) => {
24
+ const original = node[NodeTypes.TRANSLATION] ?? {};
25
+ const result = {};
26
+ for (const key in original) {
27
+ const childProps = {
28
+ ...props,
29
+ children: original[key],
30
+ keyPath: [...props.keyPath, {
31
+ type: NodeTypes.TRANSLATION,
32
+ key
33
+ }]
34
+ };
35
+ result[key] = deepTransformNode(original[key], childProps);
36
+ }
37
+ return getTranslation(result, locale, fallback);
38
+ }
39
+ };
40
+ /** Enumeration plugin. Replaces node with a function that takes quantity => string. */
41
+ const enumerationPlugin = process.env["INTLAYER_NODE_TYPE_ENUMERATION"] === "false" ? fallbackPlugin : {
42
+ id: "enumeration-plugin",
43
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.ENUMERATION,
44
+ transform: (node, props, deepTransformNode) => {
45
+ const original = node[NodeTypes.ENUMERATION];
46
+ const result = {};
47
+ for (const key in original) {
48
+ const child = original[key];
49
+ result[key] = deepTransformNode(child, {
50
+ ...props,
51
+ children: child,
52
+ keyPath: [...props.keyPath, {
53
+ type: NodeTypes.ENUMERATION,
54
+ key
55
+ }]
56
+ });
57
+ }
58
+ return (arg) => {
59
+ const subResult = getEnumeration(result, typeof arg === "number" ? arg : arg.count);
60
+ if (typeof subResult === "function" && typeof arg === "object") return subResult(arg);
61
+ return subResult;
62
+ };
63
+ }
64
+ };
65
+ /** Condition plugin. Replaces node with a function that takes boolean => string. */
66
+ const conditionPlugin = process.env["INTLAYER_NODE_TYPE_CONDITION"] === "false" ? fallbackPlugin : {
67
+ id: "condition-plugin",
68
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.CONDITION,
69
+ transform: (node, props, deepTransformNode) => {
70
+ const original = node[NodeTypes.CONDITION];
71
+ const result = {};
72
+ for (const key in original) {
73
+ const child = original[key];
74
+ result[key] = deepTransformNode(child, {
75
+ ...props,
76
+ children: child,
77
+ keyPath: [...props.keyPath, {
78
+ type: NodeTypes.CONDITION,
79
+ key
80
+ }]
81
+ });
82
+ }
83
+ return (arg) => {
84
+ const subResult = getCondition(result, typeof arg === "boolean" ? arg : arg.value);
85
+ if (typeof subResult === "function" && typeof arg === "object") return subResult(arg);
86
+ return subResult;
87
+ };
88
+ }
89
+ };
90
+ /** Insertion plugin. Replaces node with a function that takes quantity => string. */
91
+ const insertionPlugin = process.env["INTLAYER_NODE_TYPE_INSERTION"] === "false" ? fallbackPlugin : {
92
+ id: "insertion-plugin",
93
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.INSERTION,
94
+ transform: (node, props, deepTransformNode) => {
95
+ const newKeyPath = [...props.keyPath, { type: NodeTypes.INSERTION }];
96
+ const children = node[NodeTypes.INSERTION];
97
+ /** Insertion string plugin. Replaces string node with a component that render the insertion. */
98
+ const insertionStringPlugin = {
99
+ id: "insertion-string-plugin",
100
+ canHandle: (node) => typeof node === "string",
101
+ transform: (node, subProps, deepTransformNode) => {
102
+ const transformedResult = deepTransformNode(node, {
103
+ ...subProps,
104
+ children: node,
105
+ plugins: [...(props.plugins ?? []).filter((plugin) => plugin.id !== "intlayer-node-plugin")]
106
+ });
107
+ return (values) => {
108
+ const children = getInsertion(transformedResult, values);
109
+ return deepTransformNode(children, {
110
+ ...subProps,
111
+ plugins: props.plugins,
112
+ children
113
+ });
114
+ };
115
+ }
116
+ };
117
+ return deepTransformNode(children, {
118
+ ...props,
119
+ children,
120
+ keyPath: newKeyPath,
121
+ plugins: [insertionStringPlugin, ...props.plugins ?? []]
122
+ });
123
+ }
124
+ };
125
+ /** Gender plugin. Replaces node with a function that takes gender => string. */
126
+ const genderPlugin = process.env["INTLAYER_NODE_TYPE_GENDER"] === "false" ? fallbackPlugin : {
127
+ id: "gender-plugin",
128
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.GENDER,
129
+ transform: (node, props, deepTransformNode) => {
130
+ const original = node[NodeTypes.GENDER];
131
+ const result = {};
132
+ for (const key in original) {
133
+ const child = original[key];
134
+ result[key] = deepTransformNode(child, {
135
+ ...props,
136
+ children: child,
137
+ keyPath: [...props.keyPath, {
138
+ type: NodeTypes.GENDER,
139
+ key
140
+ }]
141
+ });
142
+ }
143
+ return (value) => getGender(result, value);
144
+ }
145
+ };
146
+ /** File plugin. Replaces node with the result of `getNesting`. */
147
+ const filePlugin = process.env["INTLAYER_NODE_TYPE_FILE"] === "false" ? fallbackPlugin : {
148
+ id: "file-plugin",
149
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.FILE,
150
+ transform: (node, props, deepTransform) => deepTransform(node.content, {
151
+ ...props,
152
+ children: node.content
153
+ })
154
+ };
155
+
156
+ //#endregion
157
+ export { translationPlugin };
158
+ //# sourceMappingURL=plugins.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.mjs","names":[],"sources":["../../../../../../../../../../@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs"],"sourcesContent":["import { getCondition } from \"../getCondition.mjs\";\nimport { getEnumeration } from \"../getEnumeration.mjs\";\nimport { getGender } from \"../getGender.mjs\";\nimport { getInsertion } from \"../getInsertion.mjs\";\nimport { getNesting } from \"../getNesting.mjs\";\nimport { getPlural } from \"../getPlural.mjs\";\nimport { getTranslation } from \"../getTranslation.mjs\";\nimport * as NodeTypes from \"@intlayer/types/nodeType\";\n\n//#region src/interpreter/getContent/plugins.ts\n/** ---------------------------------------------\n* FALLBACK PLUGIN\n*\n* Used to fallback a tree-shaken plugin\n* --------------------------------------------- */\nconst fallbackPlugin = {\n\tid: \"fallback-plugin\",\n\tcanHandle: () => false,\n\ttransform: (node) => node\n};\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nconst translationPlugin = (locale, fallback) => process.env[\"INTLAYER_NODE_TYPE_TRANSLATION\"] === \"false\" ? fallbackPlugin : {\n\tid: \"translation-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.TRANSLATION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.TRANSLATION] ?? {};\n\t\tconst result = {};\n\t\tfor (const key in original) {\n\t\t\tconst childProps = {\n\t\t\t\t...props,\n\t\t\t\tchildren: original[key],\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.TRANSLATION,\n\t\t\t\t\tkey\n\t\t\t\t}]\n\t\t\t};\n\t\t\tresult[key] = deepTransformNode(original[key], childProps);\n\t\t}\n\t\treturn getTranslation(result, locale, fallback);\n\t}\n};\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nconst enumerationPlugin = process.env[\"INTLAYER_NODE_TYPE_ENUMERATION\"] === \"false\" ? fallbackPlugin : {\n\tid: \"enumeration-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.ENUMERATION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.ENUMERATION];\n\t\tconst result = {};\n\t\tfor (const key in original) {\n\t\t\tconst child = original[key];\n\t\t\tresult[key] = deepTransformNode(child, {\n\t\t\t\t...props,\n\t\t\t\tchildren: child,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.ENUMERATION,\n\t\t\t\t\tkey\n\t\t\t\t}]\n\t\t\t});\n\t\t}\n\t\treturn (arg) => {\n\t\t\tconst subResult = getEnumeration(result, typeof arg === \"number\" ? arg : arg.count);\n\t\t\tif (typeof subResult === \"function\" && typeof arg === \"object\") return subResult(arg);\n\t\t\treturn subResult;\n\t\t};\n\t}\n};\n/**\n* Plural plugin. Replaces node with a function that takes a count (or\n* `{ count, ...values }`) => string, picking the matching CLDR plural form\n* for the active locale and interpolating `{{count}}` (and other values).\n*/\nconst pluralPlugin = (locale) => process.env[\"INTLAYER_NODE_TYPE_PLURAL\"] === \"false\" ? fallbackPlugin : {\n\tid: \"plural-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.PLURAL,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.PLURAL];\n\t\tconst result = {};\n\t\t/** String plugin for plural. Replaces string node with a component that renders the insertion. */\n\t\tconst pluralStringPlugin = {\n\t\t\tid: \"plural-string-plugin\",\n\t\t\tcanHandle: (node) => typeof node === \"string\",\n\t\t\ttransform: (node, subProps, deepTransformNode) => {\n\t\t\t\tconst transformedResult = deepTransformNode(node, {\n\t\t\t\t\t...subProps,\n\t\t\t\t\tchildren: node,\n\t\t\t\t\tplugins: [...(props.plugins ?? []).filter((plugin) => plugin.id !== \"intlayer-node-plugin\")]\n\t\t\t\t});\n\t\t\t\treturn (values) => {\n\t\t\t\t\tconst children = getInsertion(transformedResult, values);\n\t\t\t\t\treturn deepTransformNode(children, {\n\t\t\t\t\t\t...subProps,\n\t\t\t\t\t\tplugins: props.plugins,\n\t\t\t\t\t\tchildren\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tfor (const key in original) {\n\t\t\tconst child = original[key];\n\t\t\tresult[key] = deepTransformNode(child, {\n\t\t\t\t...props,\n\t\t\t\tchildren: child,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.PLURAL,\n\t\t\t\t\tkey\n\t\t\t\t}],\n\t\t\t\tplugins: [pluralStringPlugin, ...props.plugins ?? []]\n\t\t\t});\n\t\t}\n\t\tconst effectiveLocale = String(locale ?? props.locale ?? \"en\");\n\t\treturn (arg) => {\n\t\t\tconst count = typeof arg === \"number\" ? arg : arg.count;\n\t\t\tconst values = typeof arg === \"number\" ? { count: arg } : arg;\n\t\t\tconst subResult = getPlural(result, count, effectiveLocale);\n\t\t\tif (typeof subResult === \"function\") return subResult(values);\n\t\t\treturn subResult;\n\t\t};\n\t}\n};\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nconst conditionPlugin = process.env[\"INTLAYER_NODE_TYPE_CONDITION\"] === \"false\" ? fallbackPlugin : {\n\tid: \"condition-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.CONDITION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.CONDITION];\n\t\tconst result = {};\n\t\tfor (const key in original) {\n\t\t\tconst child = original[key];\n\t\t\tresult[key] = deepTransformNode(child, {\n\t\t\t\t...props,\n\t\t\t\tchildren: child,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.CONDITION,\n\t\t\t\t\tkey\n\t\t\t\t}]\n\t\t\t});\n\t\t}\n\t\treturn (arg) => {\n\t\t\tconst subResult = getCondition(result, typeof arg === \"boolean\" ? arg : arg.value);\n\t\t\tif (typeof subResult === \"function\" && typeof arg === \"object\") return subResult(arg);\n\t\t\treturn subResult;\n\t\t};\n\t}\n};\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nconst insertionPlugin = process.env[\"INTLAYER_NODE_TYPE_INSERTION\"] === \"false\" ? fallbackPlugin : {\n\tid: \"insertion-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.INSERTION,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst newKeyPath = [...props.keyPath, { type: NodeTypes.INSERTION }];\n\t\tconst children = node[NodeTypes.INSERTION];\n\t\t/** Insertion string plugin. Replaces string node with a component that render the insertion. */\n\t\tconst insertionStringPlugin = {\n\t\t\tid: \"insertion-string-plugin\",\n\t\t\tcanHandle: (node) => typeof node === \"string\",\n\t\t\ttransform: (node, subProps, deepTransformNode) => {\n\t\t\t\tconst transformedResult = deepTransformNode(node, {\n\t\t\t\t\t...subProps,\n\t\t\t\t\tchildren: node,\n\t\t\t\t\tplugins: [...(props.plugins ?? []).filter((plugin) => plugin.id !== \"intlayer-node-plugin\")]\n\t\t\t\t});\n\t\t\t\treturn (values) => {\n\t\t\t\t\tconst children = getInsertion(transformedResult, values);\n\t\t\t\t\treturn deepTransformNode(children, {\n\t\t\t\t\t\t...subProps,\n\t\t\t\t\t\tplugins: props.plugins,\n\t\t\t\t\t\tchildren\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\treturn deepTransformNode(children, {\n\t\t\t...props,\n\t\t\tchildren,\n\t\t\tkeyPath: newKeyPath,\n\t\t\tplugins: [insertionStringPlugin, ...props.plugins ?? []]\n\t\t});\n\t}\n};\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nconst genderPlugin = process.env[\"INTLAYER_NODE_TYPE_GENDER\"] === \"false\" ? fallbackPlugin : {\n\tid: \"gender-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.GENDER,\n\ttransform: (node, props, deepTransformNode) => {\n\t\tconst original = node[NodeTypes.GENDER];\n\t\tconst result = {};\n\t\tfor (const key in original) {\n\t\t\tconst child = original[key];\n\t\t\tresult[key] = deepTransformNode(child, {\n\t\t\t\t...props,\n\t\t\t\tchildren: child,\n\t\t\t\tkeyPath: [...props.keyPath, {\n\t\t\t\t\ttype: NodeTypes.GENDER,\n\t\t\t\t\tkey\n\t\t\t\t}]\n\t\t\t});\n\t\t}\n\t\treturn (value) => getGender(result, value);\n\t}\n};\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nconst nestedPlugin = (locale) => process.env[\"INTLAYER_NODE_TYPE_NESTED\"] === \"false\" ? fallbackPlugin : {\n\tid: \"nested-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && (node?.nodeType === NodeTypes.NESTED || node?.nodeType === \"n\"),\n\ttransform: (node, props) => getNesting(node[NodeTypes.NESTED].dictionaryKey, node[NodeTypes.NESTED].path, {\n\t\t...props,\n\t\tlocale: locale ?? props.locale\n\t})\n};\n/** File plugin. Replaces node with the result of `getNesting`. */\nconst filePlugin = process.env[\"INTLAYER_NODE_TYPE_FILE\"] === \"false\" ? fallbackPlugin : {\n\tid: \"file-plugin\",\n\tcanHandle: (node) => typeof node === \"object\" && node?.nodeType === NodeTypes.FILE,\n\ttransform: (node, props, deepTransform) => deepTransform(node.content, {\n\t\t...props,\n\t\tchildren: node.content\n\t})\n};\n\n//#endregion\nexport { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, pluralPlugin, translationPlugin };\n//# sourceMappingURL=plugins.mjs.map"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,iBAAiB;CACtB,IAAI;CACJ,iBAAiB;CACjB,YAAY,SAAS;CACrB;;AAED,MAAM,qBAAqB,QAAQ,aAAa,QAAQ,IAAI,sCAAsC,UAAU,iBAAiB;CAC5H,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,WAAW,KAAK,UAAU,gBAAgB,EAAE;EAClD,MAAM,SAAS,EAAE;AACjB,OAAK,MAAM,OAAO,UAAU;GAC3B,MAAM,aAAa;IAClB,GAAG;IACH,UAAU,SAAS;IACnB,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAM,UAAU;KAChB;KACA,CAAC;IACF;AACD,UAAO,OAAO,kBAAkB,SAAS,MAAM,WAAW;;AAE3D,SAAO,eAAe,QAAQ,QAAQ,SAAS;;CAEhD;;AAED,MAAM,oBAAoB,QAAQ,IAAI,sCAAsC,UAAU,iBAAiB;CACtG,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,WAAW,KAAK,UAAU;EAChC,MAAM,SAAS,EAAE;AACjB,OAAK,MAAM,OAAO,UAAU;GAC3B,MAAM,QAAQ,SAAS;AACvB,UAAO,OAAO,kBAAkB,OAAO;IACtC,GAAG;IACH,UAAU;IACV,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAM,UAAU;KAChB;KACA,CAAC;IACF,CAAC;;AAEH,UAAQ,QAAQ;GACf,MAAM,YAAY,eAAe,QAAQ,OAAO,QAAQ,WAAW,MAAM,IAAI,MAAM;AACnF,OAAI,OAAO,cAAc,cAAc,OAAO,QAAQ,SAAU,QAAO,UAAU,IAAI;AACrF,UAAO;;;CAGT;;AAuDD,MAAM,kBAAkB,QAAQ,IAAI,oCAAoC,UAAU,iBAAiB;CAClG,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,WAAW,KAAK,UAAU;EAChC,MAAM,SAAS,EAAE;AACjB,OAAK,MAAM,OAAO,UAAU;GAC3B,MAAM,QAAQ,SAAS;AACvB,UAAO,OAAO,kBAAkB,OAAO;IACtC,GAAG;IACH,UAAU;IACV,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAM,UAAU;KAChB;KACA,CAAC;IACF,CAAC;;AAEH,UAAQ,QAAQ;GACf,MAAM,YAAY,aAAa,QAAQ,OAAO,QAAQ,YAAY,MAAM,IAAI,MAAM;AAClF,OAAI,OAAO,cAAc,cAAc,OAAO,QAAQ,SAAU,QAAO,UAAU,IAAI;AACrF,UAAO;;;CAGT;;AAED,MAAM,kBAAkB,QAAQ,IAAI,oCAAoC,UAAU,iBAAiB;CAClG,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,aAAa,CAAC,GAAG,MAAM,SAAS,EAAE,MAAM,UAAU,WAAW,CAAC;EACpE,MAAM,WAAW,KAAK,UAAU;;EAEhC,MAAM,wBAAwB;GAC7B,IAAI;GACJ,YAAY,SAAS,OAAO,SAAS;GACrC,YAAY,MAAM,UAAU,sBAAsB;IACjD,MAAM,oBAAoB,kBAAkB,MAAM;KACjD,GAAG;KACH,UAAU;KACV,SAAS,CAAC,IAAI,MAAM,WAAW,EAAE,EAAE,QAAQ,WAAW,OAAO,OAAO,uBAAuB,CAAC;KAC5F,CAAC;AACF,YAAQ,WAAW;KAClB,MAAM,WAAW,aAAa,mBAAmB,OAAO;AACxD,YAAO,kBAAkB,UAAU;MAClC,GAAG;MACH,SAAS,MAAM;MACf;MACA,CAAC;;;GAGJ;AACD,SAAO,kBAAkB,UAAU;GAClC,GAAG;GACH;GACA,SAAS;GACT,SAAS,CAAC,uBAAuB,GAAG,MAAM,WAAW,EAAE,CAAC;GACxD,CAAC;;CAEH;;AAED,MAAM,eAAe,QAAQ,IAAI,iCAAiC,UAAU,iBAAiB;CAC5F,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,sBAAsB;EAC9C,MAAM,WAAW,KAAK,UAAU;EAChC,MAAM,SAAS,EAAE;AACjB,OAAK,MAAM,OAAO,UAAU;GAC3B,MAAM,QAAQ,SAAS;AACvB,UAAO,OAAO,kBAAkB,OAAO;IACtC,GAAG;IACH,UAAU;IACV,SAAS,CAAC,GAAG,MAAM,SAAS;KAC3B,MAAM,UAAU;KAChB;KACA,CAAC;IACF,CAAC;;AAEH,UAAQ,UAAU,UAAU,QAAQ,MAAM;;CAE3C;;AAWD,MAAM,aAAa,QAAQ,IAAI,+BAA+B,UAAU,iBAAiB;CACxF,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC9E,YAAY,MAAM,OAAO,kBAAkB,cAAc,KAAK,SAAS;EACtE,GAAG;EACH,UAAU,KAAK;EACf,CAAC;CACF"}