@intlayer/core 5.0.6 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +34 -29
  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 +84 -0
  6. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -0
  7. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +59 -0
  8. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -0
  9. package/dist/cjs/dictionaryManipulator/{getSectionType.cjs → getNodeType.cjs} +25 -16
  10. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -0
  11. package/dist/cjs/dictionaryManipulator/index.cjs +9 -3
  12. package/dist/cjs/dictionaryManipulator/index.cjs.map +1 -1
  13. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +79 -0
  14. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -0
  15. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  16. package/dist/cjs/interpreter/getContent/index.cjs +0 -2
  17. package/dist/cjs/interpreter/getContent/index.cjs.map +1 -1
  18. package/dist/cjs/interpreter/getContent/plugins.cjs +3 -6
  19. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  20. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  21. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  22. package/dist/cjs/interpreter/getIntlayerAsync.cjs.map +1 -1
  23. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  24. package/dist/cjs/interpreter/index.cjs +0 -2
  25. package/dist/cjs/interpreter/index.cjs.map +1 -1
  26. package/dist/cjs/localization/getMultilingualUrls.cjs +1 -1
  27. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  28. package/dist/cjs/localization/getPathWithoutLocale.cjs +5 -1
  29. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  30. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  31. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  32. package/dist/cjs/transpiler/translation/types.cjs.map +1 -1
  33. package/dist/cjs/types/dictionary.cjs.map +1 -1
  34. package/dist/cjs/types/nodeType.cjs +4 -1
  35. package/dist/cjs/types/nodeType.cjs.map +1 -1
  36. package/dist/cjs/utils/isValidReactElement.cjs +1 -2
  37. package/dist/cjs/utils/isValidReactElement.cjs.map +1 -1
  38. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +34 -29
  39. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  40. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -1
  41. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  42. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +60 -0
  43. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -0
  44. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +35 -0
  45. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -0
  46. package/dist/esm/dictionaryManipulator/getNodeType.mjs +42 -0
  47. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -0
  48. package/dist/esm/dictionaryManipulator/index.mjs +4 -1
  49. package/dist/esm/dictionaryManipulator/index.mjs.map +1 -1
  50. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +55 -0
  51. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -0
  52. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  53. package/dist/esm/interpreter/getContent/index.mjs +0 -1
  54. package/dist/esm/interpreter/getContent/index.mjs.map +1 -1
  55. package/dist/esm/interpreter/getContent/plugins.mjs +3 -6
  56. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  57. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  58. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  59. package/dist/esm/interpreter/getIntlayerAsync.mjs.map +1 -1
  60. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  61. package/dist/esm/interpreter/index.mjs +0 -1
  62. package/dist/esm/interpreter/index.mjs.map +1 -1
  63. package/dist/esm/localization/getMultilingualUrls.mjs +1 -1
  64. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  65. package/dist/esm/localization/getPathWithoutLocale.mjs +5 -1
  66. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  67. package/dist/esm/transpiler/enumeration/enumeration.mjs +4 -1
  68. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  69. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  70. package/dist/esm/types/nodeType.mjs +4 -1
  71. package/dist/esm/types/nodeType.mjs.map +1 -1
  72. package/dist/esm/utils/isValidReactElement.mjs +1 -2
  73. package/dist/esm/utils/isValidReactElement.mjs.map +1 -1
  74. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +1 -1
  75. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +5 -0
  76. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +1 -0
  77. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts +3 -0
  78. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +1 -0
  79. package/dist/types/dictionaryManipulator/getNodeType.d.ts +4 -0
  80. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -0
  81. package/dist/types/dictionaryManipulator/index.d.ts +4 -1
  82. package/dist/types/dictionaryManipulator/index.d.ts.map +1 -1
  83. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts +3 -0
  84. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +1 -0
  85. package/dist/types/interpreter/getContent/deepTransform.d.ts +1 -1
  86. package/dist/types/interpreter/getContent/deepTransform.d.ts.map +1 -1
  87. package/dist/types/interpreter/getContent/index.d.ts +0 -1
  88. package/dist/types/interpreter/getContent/index.d.ts.map +1 -1
  89. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  90. package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
  91. package/dist/types/interpreter/getIntlayer.d.ts +1 -1
  92. package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
  93. package/dist/types/interpreter/getIntlayerAsync.d.ts.map +1 -1
  94. package/dist/types/interpreter/getNesting.d.ts +1 -1
  95. package/dist/types/interpreter/getNesting.d.ts.map +1 -1
  96. package/dist/types/interpreter/index.d.ts +0 -1
  97. package/dist/types/interpreter/index.d.ts.map +1 -1
  98. package/dist/types/localization/getPathWithoutLocale.d.ts.map +1 -1
  99. package/dist/types/transpiler/enumeration/enumeration.d.ts +1 -1
  100. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
  101. package/dist/types/transpiler/nesting/nesting.d.ts +1 -1
  102. package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -1
  103. package/dist/types/transpiler/translation/types.d.ts +1 -1
  104. package/dist/types/transpiler/translation/types.d.ts.map +1 -1
  105. package/dist/types/types/dictionary.d.ts +3 -2
  106. package/dist/types/types/dictionary.d.ts.map +1 -1
  107. package/dist/types/types/nodeType.d.ts +5 -2
  108. package/dist/types/types/nodeType.d.ts.map +1 -1
  109. package/dist/types/utils/isValidReactElement.d.ts.map +1 -1
  110. package/package.json +14 -14
  111. package/dist/cjs/dictionaryManipulator/getSectionType.cjs.map +0 -1
  112. package/dist/esm/dictionaryManipulator/getSectionType.mjs +0 -33
  113. package/dist/esm/dictionaryManipulator/getSectionType.mjs.map +0 -1
  114. package/dist/types/dictionaryManipulator/getSectionType.d.ts +0 -4
  115. package/dist/types/dictionaryManipulator/getSectionType.d.ts.map +0 -1
@@ -0,0 +1,55 @@
1
+ import { NodeType } from "../types/index.mjs";
2
+ const updateNodeChildren = (section, newChildren) => {
3
+ if (typeof section === "string") {
4
+ return newChildren;
5
+ }
6
+ if (typeof section === "number") {
7
+ return newChildren;
8
+ }
9
+ if (typeof section === "boolean") {
10
+ return newChildren;
11
+ }
12
+ if (typeof section?.nodeType === "string") {
13
+ const typedNode = section;
14
+ const content = typedNode[typedNode.nodeType];
15
+ if (typedNode.nodeType === NodeType.Translation || typedNode.nodeType === NodeType.Enumeration || typedNode.nodeType === NodeType.Condition) {
16
+ const newContent = Object.entries(content).reduce(
17
+ (acc, [key]) => ({
18
+ ...acc,
19
+ [key]: newChildren
20
+ }),
21
+ {}
22
+ );
23
+ return {
24
+ ...typedNode,
25
+ [typedNode.nodeType]: newContent
26
+ };
27
+ }
28
+ if (typedNode.nodeType === NodeType.Nested) {
29
+ return typedNode;
30
+ }
31
+ return {
32
+ ...typedNode,
33
+ [typedNode.nodeType]: newChildren
34
+ };
35
+ }
36
+ if (!section || typeof section !== "object") {
37
+ return newChildren;
38
+ }
39
+ if (Array.isArray(section)) {
40
+ return section.map(() => newChildren);
41
+ }
42
+ return Object.entries(
43
+ section
44
+ ).reduce(
45
+ (acc, [key]) => ({
46
+ ...acc,
47
+ [key]: newChildren
48
+ }),
49
+ {}
50
+ );
51
+ };
52
+ export {
53
+ updateNodeChildren
54
+ };
55
+ //# sourceMappingURL=updateNodeChildren.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/dictionaryManipulator/updateNodeChildren.ts"],"sourcesContent":["import { type ContentNode, type TypedNode, NodeType } from '../types';\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 = typedNode[typedNode.nodeType as keyof TypedNode];\n\n if (\n typedNode.nodeType === NodeType.Translation ||\n typedNode.nodeType === NodeType.Enumeration ||\n typedNode.nodeType === NodeType.Condition\n ) {\n const newContent = Object.entries(content).reduce(\n (acc, [key]) => ({\n ...acc,\n [key]: newChildren,\n }),\n {} as Record<string, ContentNode>\n );\n\n return {\n ...typedNode,\n [typedNode.nodeType]: newContent,\n };\n }\n\n if (typedNode.nodeType === NodeType.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 ContentNode;\n};\n"],"mappings":"AAAA,SAA2C,gBAAgB;AAEpD,MAAM,qBAAqB,CAIhC,SACA,gBACgB;AAChB,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,EACT;AACA,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO;AAAA,EACT;AACA,MAAI,OAAO,YAAY,WAAW;AAChC,WAAO;AAAA,EACT;AACA,MAAI,OAAQ,SAAuB,aAAa,UAAU;AACxD,UAAM,YAAY;AAClB,UAAM,UAAU,UAAU,UAAU,QAA2B;AAE/D,QACE,UAAU,aAAa,SAAS,eAChC,UAAU,aAAa,SAAS,eAChC,UAAU,aAAa,SAAS,WAChC;AACA,YAAM,aAAa,OAAO,QAAQ,OAAO,EAAE;AAAA,QACzC,CAAC,KAAK,CAAC,GAAG,OAAO;AAAA,UACf,GAAG;AAAA,UACH,CAAC,GAAG,GAAG;AAAA,QACT;AAAA,QACA,CAAC;AAAA,MACH;AAEA,aAAO;AAAA,QACL,GAAG;AAAA,QACH,CAAC,UAAU,QAAQ,GAAG;AAAA,MACxB;AAAA,IACF;AAEA,QAAI,UAAU,aAAa,SAAS,QAAQ;AAC1C,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH,CAAC,UAAU,QAAQ,GAAG;AAAA,IACxB;AAAA,EACF;AAEA,MAAI,CAAC,WAAW,OAAO,YAAY,UAAU;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,WAAO,QAAQ,IAAI,MAAM,WAAW;AAAA,EACtC;AAEA,SAAO,OAAO;AAAA,IACZ;AAAA,EACF,EAAE;AAAA,IACA,CAAC,KAAK,CAAC,GAAG,OAAO;AAAA,MACf,GAAG;AAAA,MACH,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type KeyPath, NodeType } from '../../types/index';\nimport { NodeProps } from './plugins';\n\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 */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n content: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Array, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n // If no plugin transforms it, we keep traversing its properties.\n const result: Record<string, any> = {};\n for (const key in node) {\n const childProps = {\n ...props,\n content: node[key],\n keyPath: [...props.keyPath, { type: NodeType.Object, key } as KeyPath],\n };\n result[key] = deepTransformNode(node[key], childProps);\n }\n\n return result;\n};\n"],"mappings":"AACA,SAAuB,gBAAgB;AAQhC,MAAM,oBAAoB,CAAC,MAAW,UAA0B;AAErE,aAAW,UAAU,MAAM,WAAW,CAAC,GAAG;AACxC,QAAI,OAAO,UAAU,IAAI,GAAG;AAE1B,aAAO,OAAO;AAAA,QAAU;AAAA,QAAM;AAAA,QAAO,CAACA,OAAWC,WAC/C,kBAAkBD,OAAMC,MAAK;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAGA,MAAI,SAAS,QAAQ,OAAO,SAAS,UAAU;AAC7C,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,WAAO,KAAK,IAAI,CAAC,OAAO,UAAU;AAChC,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,OAAO,KAAK,MAAM;AAAA,QACrC;AAAA,MACF;AACA,aAAO,kBAAkB,OAAO,UAAU;AAAA,IAC5C,CAAC;AAAA,EACH;AAGA,QAAM,SAA8B,CAAC;AACrC,aAAW,OAAO,MAAM;AACtB,UAAM,aAAa;AAAA,MACjB,GAAG;AAAA,MACH,SAAS,KAAK,GAAG;AAAA,MACjB,SAAS,CAAC,GAAG,MAAM,SAAS,EAAE,MAAM,SAAS,QAAQ,IAAI,CAAY;AAAA,IACvE;AACA,WAAO,GAAG,IAAI,kBAAkB,KAAK,GAAG,GAAG,UAAU;AAAA,EACvD;AAEA,SAAO;AACT;","names":["node","props"]}
1
+ {"version":3,"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../../types/index';\nimport type { NodeProps } from './plugins';\n\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 */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n content: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Array, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n // If no plugin transforms it, we keep traversing its properties.\n const result: Record<string, any> = {};\n for (const key in node) {\n const childProps = {\n ...props,\n content: node[key],\n keyPath: [...props.keyPath, { type: NodeType.Object, key } as KeyPath],\n };\n result[key] = deepTransformNode(node[key], childProps);\n }\n\n return result;\n};\n"],"mappings":"AAAA,SAAuB,gBAAgB;AAQhC,MAAM,oBAAoB,CAAC,MAAW,UAA0B;AAErE,aAAW,UAAU,MAAM,WAAW,CAAC,GAAG;AACxC,QAAI,OAAO,UAAU,IAAI,GAAG;AAE1B,aAAO,OAAO;AAAA,QAAU;AAAA,QAAM;AAAA,QAAO,CAACA,OAAWC,WAC/C,kBAAkBD,OAAMC,MAAK;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAGA,MAAI,SAAS,QAAQ,OAAO,SAAS,UAAU;AAC7C,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,WAAO,KAAK,IAAI,CAAC,OAAO,UAAU;AAChC,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,OAAO,KAAK,MAAM;AAAA,QACrC;AAAA,MACF;AACA,aAAO,kBAAkB,OAAO,UAAU;AAAA,IAC5C,CAAC;AAAA,EACH;AAGA,QAAM,SAA8B,CAAC;AACrC,aAAW,OAAO,MAAM;AACtB,UAAM,aAAa;AAAA,MACjB,GAAG;AAAA,MACH,SAAS,KAAK,GAAG;AAAA,MACjB,SAAS,CAAC,GAAG,MAAM,SAAS,EAAE,MAAM,SAAS,QAAQ,IAAI,CAAY;AAAA,IACvE;AACA,WAAO,GAAG,IAAI,kBAAkB,KAAK,GAAG,GAAG,UAAU;AAAA,EACvD;AAEA,SAAO;AACT;","names":["node","props"]}
@@ -1,4 +1,3 @@
1
- export * from "../getDictionary.mjs";
2
1
  export * from "./deepTransform.mjs";
3
2
  export * from "./plugins.mjs";
4
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/interpreter/getContent/index.ts"],"sourcesContent":["export * from '../getDictionary';\nexport * from './deepTransform';\nexport * from './plugins';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../../src/interpreter/getContent/index.ts"],"sourcesContent":["export * from './deepTransform';\nexport * from './plugins';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -1,8 +1,8 @@
1
1
  import { NodeType } from "../../types/index.mjs";
2
- import { getTranslation } from "../getTranslation.mjs";
3
- import { getEnumeration } from "../getEnumeration.mjs";
4
2
  import { getCondition } from "../getCondition.mjs";
3
+ import { getEnumeration } from "../getEnumeration.mjs";
5
4
  import { getNesting } from "../getNesting.mjs";
5
+ import { getTranslation } from "../getTranslation.mjs";
6
6
  const translationPlugin = (locale) => ({
7
7
  canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Translation,
8
8
  transform: (node, props, deepTransformNode) => {
@@ -70,10 +70,7 @@ const conditionPlugin = {
70
70
  };
71
71
  const nestedPlugin = {
72
72
  canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Nested,
73
- transform: (node, props) => (
74
- // @ts-ignore
75
- getNesting(node.nested.dictionaryKey, node.nested.path, props)
76
- )
73
+ transform: (node, props) => getNesting(node.nested.dictionaryKey, node.nested.path, props)
77
74
  };
78
75
  export {
79
76
  conditionPlugin,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\n\nimport { type DictionaryKeys, type KeyPath, NodeType } from '../../types/index';\nimport type {\n ConditionContent,\n EnumerationContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { getTranslation } from '../getTranslation';\nimport { getEnumeration } from '../getEnumeration';\nimport { getCondition } from '../getCondition';\nimport { type GetNestingResult, getNesting } from '../getNesting';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type TranslationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: object;\n}\n ? DeepTransformContent<\n T[NodeType.Translation][keyof T[NodeType.Translation]],\n S\n >\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (locale: LocalesValues): Plugins => ({\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = structuredClone(node.translation);\n\n for (const key in result) {\n const childProps = {\n ...props,\n content: result[key as unknown as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Translation, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n return getTranslation(result, locale);\n },\n});\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Enumeration]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[NodeType.Enumeration][keyof T[NodeType.Enumeration]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Enumeration,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const result = structuredClone(node.enumeration);\n\n for (const key in result) {\n const child = result[key as unknown as keyof typeof result];\n const childProps = {\n ...props,\n content: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Enumeration, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (quantity: number) => getEnumeration(result, quantity);\n },\n};\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Condition]: object;\n}\n ? (\n value: boolean\n ) => DeepTransformContent<\n T[NodeType.Condition][keyof T[NodeType.Condition]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Condition,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const result = structuredClone(node.condition);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n content: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Condition, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (value: boolean) => getCondition(result, value);\n },\n};\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Nested]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Nested,\n transform: (node: NestedContent, props) =>\n // @ts-ignore\n getNesting(node.nested.dictionaryKey, node.nested.path, props),\n};\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locales;\n dictionaryPath?: string;\n content?: any;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S> {\n translation: TranslationCond<T, S>;\n enumeration: EnumerationCond<T, S>;\n condition: ConditionCond<T, S>;\n nested: NestedCond<T, S>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n condition: true;\n nested: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<T, K extends keyof IInterpreterPlugin<T, S>, S> =\n // Test if the key is a key of S.\n K extends keyof S\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S> =\n // Turn any read-only array into a plain mutable array\n T extends ReadonlyArray<infer U>\n ? Array<DeepTransformContent<U, S>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S> }\n : T;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<T, S = IInterpreterPluginState> =\n // Check if there is a plugin for T:\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S>, S> extends never\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S>\n : // A plugin was found – use the plugin’s transformation.\n IInterpreterPlugin<T, S>[keyof IInterpreterPlugin<T, S>];\n"],"mappings":"AAIA,SAA4C,gBAAgB;AAO5D,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAgC,kBAAkB;AAqC3C,MAAM,oBAAoB,CAAC,YAAoC;AAAA,EACpE,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAA0B,OAAO,sBAAsB;AACjE,UAAM,SAAS,gBAAgB,KAAK,WAAW;AAE/C,eAAW,OAAO,QAAQ;AACxB,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,SAAS,OAAO,GAAqC;AAAA,QACrD,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,aAAa,IAAI;AAAA,QACpC;AAAA,MACF;AACA,aAAO,GAAqC,IAAI;AAAA,QAC9C,OAAO,GAAqC;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AACA,WAAO,eAAe,QAAQ,MAAM;AAAA,EACtC;AACF;AAmBO,MAAM,oBAA6B;AAAA,EACxC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAA0B,OAAO,sBAAsB;AACjE,UAAM,SAAS,gBAAgB,KAAK,WAAW;AAE/C,eAAW,OAAO,QAAQ;AACxB,YAAM,QAAQ,OAAO,GAAqC;AAC1D,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,aAAa,IAAI;AAAA,QACpC;AAAA,MACF;AACA,aAAO,GAAqC,IAAI;AAAA,QAC9C;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,CAAC,aAAqB,eAAe,QAAQ,QAAQ;AAAA,EAC9D;AACF;AAmBO,MAAM,kBAA2B;AAAA,EACtC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAwB,OAAO,sBAAsB;AAC/D,UAAM,SAAS,gBAAgB,KAAK,SAAS;AAE7C,eAAW,OAAO,QAAQ;AACxB,YAAM,QAAQ,OAAO,GAA0B;AAC/C,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,WAAW,IAAI;AAAA,QAClC;AAAA,MACF;AACA,aAAO,GAAqC,IAAI;AAAA,QAC9C;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,CAAC,UAAmB,aAAa,QAAQ,KAAK;AAAA,EACvD;AACF;AAmBO,MAAM,eAAwB;AAAA,EACnC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAqB;AAAA;AAAA,IAE/B,WAAW,KAAK,OAAO,eAAe,KAAK,OAAO,MAAM,KAAK;AAAA;AACjE;","names":[]}
1
+ {"version":3,"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config/client';\n\nimport type {\n ConditionContent,\n EnumerationContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { type DictionaryKeys, type KeyPath, NodeType } from '../../types/index';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type TranslationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: object;\n}\n ? DeepTransformContent<\n T[NodeType.Translation][keyof T[NodeType.Translation]],\n S\n >\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (locale: LocalesValues): Plugins => ({\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = structuredClone(node.translation);\n\n for (const key in result) {\n const childProps = {\n ...props,\n content: result[key as unknown as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Translation, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n return getTranslation(result, locale);\n },\n});\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Enumeration]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[NodeType.Enumeration][keyof T[NodeType.Enumeration]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Enumeration,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const result = structuredClone(node.enumeration);\n\n for (const key in result) {\n const child = result[key as unknown as keyof typeof result];\n const childProps = {\n ...props,\n content: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Enumeration, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (quantity: number) => getEnumeration(result, quantity);\n },\n};\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Condition]: object;\n}\n ? (\n value: boolean\n ) => DeepTransformContent<\n T[NodeType.Condition][keyof T[NodeType.Condition]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Condition,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const result = structuredClone(node.condition);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n content: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Condition, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (value: boolean) => getCondition(result, value);\n },\n};\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S> = T extends {\n nodeType: NodeType | string;\n [NodeType.Nested]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin: Plugins = {\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Nested,\n transform: (node: NestedContent, props) =>\n getNesting(node.nested.dictionaryKey, node.nested.path, props),\n};\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locales;\n dictionaryPath?: string;\n content?: any;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S> {\n translation: TranslationCond<T, S>;\n enumeration: EnumerationCond<T, S>;\n condition: ConditionCond<T, S>;\n nested: NestedCond<T, S>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n condition: true;\n nested: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<T, K extends keyof IInterpreterPlugin<T, S>, S> =\n // Test if the key is a key of S.\n K extends keyof S\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S> =\n // Turn any read-only array into a plain mutable array\n T extends ReadonlyArray<infer U>\n ? Array<DeepTransformContent<U, S>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S> }\n : T;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<T, S = IInterpreterPluginState> =\n // Check if there is a plugin for T:\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S>, S> extends never\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S>\n : // A plugin was found – use the plugin’s transformation.\n IInterpreterPlugin<T, S>[keyof IInterpreterPlugin<T, S>];\n"],"mappings":"AAQA,SAA4C,gBAAgB;AAC5D,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAgC,kBAAkB;AAClD,SAAS,sBAAsB;AAqCxB,MAAM,oBAAoB,CAAC,YAAoC;AAAA,EACpE,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAA0B,OAAO,sBAAsB;AACjE,UAAM,SAAS,gBAAgB,KAAK,WAAW;AAE/C,eAAW,OAAO,QAAQ;AACxB,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,SAAS,OAAO,GAAqC;AAAA,QACrD,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,aAAa,IAAI;AAAA,QACpC;AAAA,MACF;AACA,aAAO,GAAqC,IAAI;AAAA,QAC9C,OAAO,GAAqC;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AACA,WAAO,eAAe,QAAQ,MAAM;AAAA,EACtC;AACF;AAmBO,MAAM,oBAA6B;AAAA,EACxC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAA0B,OAAO,sBAAsB;AACjE,UAAM,SAAS,gBAAgB,KAAK,WAAW;AAE/C,eAAW,OAAO,QAAQ;AACxB,YAAM,QAAQ,OAAO,GAAqC;AAC1D,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,aAAa,IAAI;AAAA,QACpC;AAAA,MACF;AACA,aAAO,GAAqC,IAAI;AAAA,QAC9C;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,CAAC,aAAqB,eAAe,QAAQ,QAAQ;AAAA,EAC9D;AACF;AAmBO,MAAM,kBAA2B;AAAA,EACtC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAwB,OAAO,sBAAsB;AAC/D,UAAM,SAAS,gBAAgB,KAAK,SAAS;AAE7C,eAAW,OAAO,QAAQ;AACxB,YAAM,QAAQ,OAAO,GAA0B;AAC/C,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,WAAW,IAAI;AAAA,QAClC;AAAA,MACF;AACA,aAAO,GAAqC,IAAI;AAAA,QAC9C;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,CAAC,UAAmB,aAAa,QAAQ,KAAK;AAAA,EACvD;AACF;AAmBO,MAAM,eAAwB;AAAA,EACnC,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;AAAA,EAC1D,WAAW,CAAC,MAAqB,UAC/B,WAAW,KAAK,OAAO,eAAe,KAAK,OAAO,MAAM,KAAK;AACjE;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '../types';\nimport { getContent } from './getContent/getContent';\nimport type { Plugins, NodeProps, DeepTransformContent } from './getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = Locales,\n>(\n dictionary: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const props: NodeProps = {\n dictionaryKey: dictionary.key,\n dictionaryPath: dictionary.filePath,\n keyPath: [],\n plugins,\n };\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getContent(\n dictionary.content,\n props,\n locale\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":"AAGA,SAAS,kBAAkB;AAWpB,MAAM,gBAAgB,CAI3B,YACA,QACA,YACG;AACH,QAAM,QAAmB;AAAA,IACvB,eAAe,WAAW;AAAA,IAC1B,gBAAgB,WAAW;AAAA,IAC3B,SAAS,CAAC;AAAA,IACV;AAAA,EACF;AAGA,SAAO;AAAA,IACL,WAAW;AAAA,IACX;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config/client';\nimport type { Dictionary } from '../types';\nimport type { Plugins, NodeProps, DeepTransformContent } from './getContent';\nimport { getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = Locales,\n>(\n dictionary: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const props: NodeProps = {\n dictionaryKey: dictionary.key,\n dictionaryPath: dictionary.filePath,\n keyPath: [],\n plugins,\n };\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getContent(\n dictionary.content,\n props,\n locale\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":"AAGA,SAAS,kBAAkB;AAUpB,MAAM,gBAAgB,CAI3B,YACA,QACA,YACG;AACH,QAAM,QAAmB;AAAA,IACvB,eAAe,WAAW;AAAA,IAC1B,gBAAgB,WAAW;AAAA,IAC3B,SAAS,CAAC;AAAA,IACV;AAAA,EACF;AAGA,SAAO;AAAA,IACL,WAAW;AAAA,IACX;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/import/no-cycle */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { LocalesValues } from '@intlayer/config';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { Dictionary, DictionaryKeys } from '../types';\nimport { getDictionary } from './getDictionary';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DeepTransformContent, Plugins } from './getContent/plugins';\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const dictionary = dictionaries[key as T];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key as string} not found`, dictionaries);\n }\n\n return getDictionary(\n dictionary as Dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n};\n"],"mappings":"AAQA,OAAO,kBAAkB;AAEzB,SAAS,qBAAqB;AAKvB,MAAM,cAAc,CACzB,KACA,QACA,YACG;AACH,QAAM,aAAa,aAAa,GAAQ;AAExC,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,cAAc,GAAa,cAAc,YAAY;AAAA,EACvE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGF;","names":[]}
1
+ {"version":3,"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { Dictionary, DictionaryKeys } from '../types';\nimport type { DeepTransformContent, Plugins } from './getContent/plugins';\nimport { getDictionary } from './getDictionary';\n\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const dictionary = dictionaries[key as T];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key as string} not found`, dictionaries);\n }\n\n return getDictionary(\n dictionary as Dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n};\n"],"mappings":"AAMA,OAAO,kBAAkB;AAKzB,SAAS,qBAAqB;AAEvB,MAAM,cAAc,CACzB,KACA,QACA,YACG;AACH,QAAM,aAAa,aAAa,GAAQ;AAExC,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,cAAc,GAAa,cAAc,YAAY;AAAA,EACvE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/interpreter/getIntlayerAsync.ts"],"sourcesContent":["import { fetchDistantDictionary } from '@intlayer/api';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport { getDictionary } from './getDictionary';\nimport type { DictionaryKeys } from '../types';\nimport type { Plugins } from './getContent';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getIntlayerAsync = async <\n T extends DictionaryKeys,\n L extends LocalesValues,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const jsonDistantDictionary = await fetchDistantDictionary(key as string);\n\n if (jsonDistantDictionary) {\n return getDictionary(jsonDistantDictionary, locale, plugins);\n }\n\n return null;\n};\n"],"mappings":"AAAA,SAAS,8BAA8B;AAEvC,SAAS,qBAAqB;AAYvB,MAAM,mBAAmB,OAI9B,KACA,QACA,YACG;AACH,QAAM,wBAAwB,MAAM,uBAAuB,GAAa;AAExE,MAAI,uBAAuB;AACzB,WAAO,cAAc,uBAAuB,QAAQ,OAAO;AAAA,EAC7D;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/interpreter/getIntlayerAsync.ts"],"sourcesContent":["import { fetchDistantDictionary } from '@intlayer/api';\nimport type { LocalesValues } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '../types';\nimport type { Plugins } from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getIntlayerAsync = async <\n T extends DictionaryKeys,\n L extends LocalesValues,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n) => {\n const jsonDistantDictionary = await fetchDistantDictionary(key as string);\n\n if (jsonDistantDictionary) {\n return getDictionary(jsonDistantDictionary, locale, plugins);\n }\n\n return null;\n};\n"],"mappings":"AAAA,SAAS,8BAA8B;AAIvC,SAAS,qBAAqB;AAUvB,MAAM,mBAAmB,OAI9B,KACA,QACA,YACG;AACH,QAAM,wBAAwB,MAAM,uBAAuB,GAAa;AAExE,MAAI,uBAAuB;AACzB,WAAO,cAAc,uBAAuB,QAAQ,OAAO;AAAA,EAC7D;AAEA,SAAO;AACT;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/import/no-cycle */\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type { DictionaryKeys } from '../types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\n\ntype GetSubPath<T, P> = P extends `${infer K}.${infer Rest}`\n ? K extends keyof T\n ? GetSubPath<T[K], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : T;\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content'], S>,\n P\n>;\n\n/**\n * Allow to extract the content of another dictionary.\n *\n * Usage:\n * ```ts\n * const content = getNesting(\"dictionaryKey\", \"path.to.content\");\n * // 'Example content'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":"AASA,SAAS,mBAAmB;AA8BrB,MAAM,aAAa,CACxB,eACA,MACA,UAC2B;AAC3B,QAAM,aAAa,YAAY,eAAe,OAAO,QAAQ,OAAO,OAAO;AAE3E,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,YAAa,KAAgB,MAAM,GAAG;AAC5C,QAAI,UAAe;AAEnB,eAAW,OAAO,WAAW;AAE3B,gBAAU,UAAU,GAAG;AAEvB,UAAI,YAAY,QAAW;AACzB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type { DictionaryKeys } from '../types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\ntype GetSubPath<T, P> = P extends `${infer K}.${infer Rest}`\n ? K extends keyof T\n ? GetSubPath<T[K], Rest>\n : never\n : P extends keyof T\n ? T[P]\n : T;\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content'], S>,\n P\n>;\n\n/**\n * Allow to extract the content of another dictionary.\n *\n * Usage:\n * ```ts\n * const content = getNesting(\"dictionaryKey\", \"path.to.content\");\n * // 'Example content'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":"AASA,SAAS,mBAAmB;AA4BrB,MAAM,aAAa,CACxB,eACA,MACA,UAC2B;AAC3B,QAAM,aAAa,YAAY,eAAe,OAAO,QAAQ,OAAO,OAAO;AAE3E,MAAI,OAAO,SAAS,UAAU;AAC5B,UAAM,YAAa,KAAgB,MAAM,GAAG;AAC5C,QAAI,UAAe;AAEnB,eAAW,OAAO,WAAW;AAE3B,gBAAU,UAAU,GAAG;AAEvB,UAAI,YAAY,QAAW;AACzB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;","names":[]}
@@ -1,7 +1,6 @@
1
1
  export * from "./getContent/index.mjs";
2
2
  export * from "./getNesting.mjs";
3
3
  export * from "./getEnumeration.mjs";
4
- export * from "./getEnumeration.mjs";
5
4
  export * from "./getIntlayer.mjs";
6
5
  export * from "./getDictionary.mjs";
7
6
  export * from "./getIntlayerAsync.mjs";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/interpreter/index.ts"],"sourcesContent":["export * from './getContent/index';\nexport * from './getNesting';\nexport * from './getEnumeration';\nexport * from './getEnumeration';\nexport * from './getIntlayer';\nexport * from './getDictionary';\nexport * from './getIntlayerAsync';\nexport * from './getTranslation';\nexport * from './getCondition';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/interpreter/index.ts"],"sourcesContent":["export * from './getContent/index';\nexport * from './getNesting';\nexport * from './getEnumeration';\nexport * from './getIntlayer';\nexport * from './getDictionary';\nexport * from './getIntlayerAsync';\nexport * from './getTranslation';\nexport * from './getCondition';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import { getConfiguration } from "@intlayer/config/client";
2
- import { getPathWithoutLocale } from "./getPathWithoutLocale.mjs";
3
2
  import { checkIsURLAbsolute } from "../utils/checkIsURLAbsolute.mjs";
3
+ import { getPathWithoutLocale } from "./getPathWithoutLocale.mjs";
4
4
  const { internationalization, middleware } = getConfiguration();
5
5
  const { locales: localesDefault, defaultLocale: defaultLocaleDefault } = internationalization;
6
6
  const { prefixDefault: prefixDefaultDefault } = middleware;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":["import { getConfiguration, type LocalesValues } from '@intlayer/config/client';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IConfigLocales } from 'intlayer';\nimport { getPathWithoutLocale } from './getPathWithoutLocale';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\n\n// Destructure necessary configurations\nconst { internationalization, middleware } = getConfiguration();\nconst { locales: localesDefault, defaultLocale: defaultLocaleDefault } =\n internationalization;\nconst { prefixDefault: prefixDefaultDefault } = middleware;\n\n/**\n * Generates multilingual URLs by prefixing the given URL with each supported locale.\n * Handles both absolute and relative URLs appropriately.\n *\n * This function get the locales, default locale, and prefix default from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', false)\n * // Returns { en: '/dashboard', fr: '/fr/dashboard' }\n * getMultilingualUrls('https://example.com/dashboard', ['en', 'fr'], 'en', true)\n * // Returns { en: 'https://example.com/en/dashboard', fr: 'https://example.com/fr/dashboard' }\n * ```\n *\n * @param url - The original URL string to be prefixed with locales.\n * @param locales - Optional array of supported locales. Defaults to `localesDefault`.\n * @param defaultLocale - The default locale. Defaults to `defaultLocaleDefault`.\n * @param prefixDefault - Whether to prefix the default locale. Defaults to `prefixDefaultDefault`.\n * @returns An object mapping each locale to its corresponding multilingual URL.\n */\nexport const getMultilingualUrls = (\n url: string,\n locales: LocalesValues[] = localesDefault,\n defaultLocale: LocalesValues = defaultLocaleDefault,\n prefixDefault: boolean = prefixDefaultDefault\n): IConfigLocales<string> => {\n // Remove any existing locale segment from the URL\n const urlWithoutLocale = getPathWithoutLocale(url, locales);\n\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const parsedUrl = isAbsoluteUrl\n ? new URL(urlWithoutLocale)\n : new URL(urlWithoutLocale, 'http://example.com');\n\n // Extract the pathname from the parsed URL\n let pathname = parsedUrl.pathname;\n\n // Ensure the pathname starts with a '/'\n if (!pathname.startsWith('/')) {\n pathname = `/${pathname}`;\n }\n\n // Prepare the base URL (protocol + host) if it's absolute\n const baseUrl = isAbsoluteUrl\n ? `${parsedUrl.protocol}//${parsedUrl.host}`\n : '';\n\n // Generate multilingual URLs by iterating over each locale\n const multilingualUrls = locales.reduce<IConfigLocales<string>>(\n (acc, locale) => {\n // Determine if the current locale is the default locale\n const isDefaultLocale = locale.toString() === defaultLocale.toString();\n\n // Decide whether to prefix the default locale based on `prefixDefault`\n const shouldPrefix = prefixDefault || !isDefaultLocale;\n\n // Construct the new pathname with or without the locale prefix\n let localizedPath = shouldPrefix ? `/${locale}${pathname}` : pathname;\n\n if (localizedPath.length > 1 && localizedPath.endsWith('/')) {\n localizedPath = localizedPath.slice(0, -1);\n }\n\n // Combine with the base URL if the original URL was absolute\n const localizedUrl = isAbsoluteUrl\n ? `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`\n : `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;\n\n // Assign the constructed URL to the corresponding locale key\n acc[locale as unknown as keyof typeof acc] = localizedUrl;\n\n return acc;\n },\n {} as IConfigLocales<string> // Initialize an empty object\n );\n\n return multilingualUrls;\n};\n"],"mappings":"AAAA,SAAS,wBAA4C;AAGrD,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AAGnC,MAAM,EAAE,sBAAsB,WAAW,IAAI,iBAAiB;AAC9D,MAAM,EAAE,SAAS,gBAAgB,eAAe,qBAAqB,IACnE;AACF,MAAM,EAAE,eAAe,qBAAqB,IAAI;AAuBzC,MAAM,sBAAsB,CACjC,KACA,UAA2B,gBAC3B,gBAA+B,sBAC/B,gBAAyB,yBACE;AAE3B,QAAM,mBAAmB,qBAAqB,KAAK,OAAO;AAG1D,QAAM,gBAAgB,mBAAmB,gBAAgB;AAIzD,QAAM,YAAY,gBACd,IAAI,IAAI,gBAAgB,IACxB,IAAI,IAAI,kBAAkB,oBAAoB;AAGlD,MAAI,WAAW,UAAU;AAGzB,MAAI,CAAC,SAAS,WAAW,GAAG,GAAG;AAC7B,eAAW,IAAI,QAAQ;AAAA,EACzB;AAGA,QAAM,UAAU,gBACZ,GAAG,UAAU,QAAQ,KAAK,UAAU,IAAI,KACxC;AAGJ,QAAM,mBAAmB,QAAQ;AAAA,IAC/B,CAAC,KAAK,WAAW;AAEf,YAAM,kBAAkB,OAAO,SAAS,MAAM,cAAc,SAAS;AAGrE,YAAM,eAAe,iBAAiB,CAAC;AAGvC,UAAI,gBAAgB,eAAe,IAAI,MAAM,GAAG,QAAQ,KAAK;AAE7D,UAAI,cAAc,SAAS,KAAK,cAAc,SAAS,GAAG,GAAG;AAC3D,wBAAgB,cAAc,MAAM,GAAG,EAAE;AAAA,MAC3C;AAGA,YAAM,eAAe,gBACjB,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,MAAM,GAAG,UAAU,IAAI,KAC9D,GAAG,aAAa,GAAG,UAAU,MAAM,GAAG,UAAU,IAAI;AAGxD,UAAI,MAAqC,IAAI;AAE7C,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":["import { getConfiguration, type LocalesValues } from '@intlayer/config/client';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IConfigLocales } from 'intlayer';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\nimport { getPathWithoutLocale } from './getPathWithoutLocale';\n\n// Destructure necessary configurations\nconst { internationalization, middleware } = getConfiguration();\nconst { locales: localesDefault, defaultLocale: defaultLocaleDefault } =\n internationalization;\nconst { prefixDefault: prefixDefaultDefault } = middleware;\n\n/**\n * Generates multilingual URLs by prefixing the given URL with each supported locale.\n * Handles both absolute and relative URLs appropriately.\n *\n * This function get the locales, default locale, and prefix default from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * getMultilingualUrls('/dashboard', ['en', 'fr'], 'en', false)\n * // Returns { en: '/dashboard', fr: '/fr/dashboard' }\n * getMultilingualUrls('https://example.com/dashboard', ['en', 'fr'], 'en', true)\n * // Returns { en: 'https://example.com/en/dashboard', fr: 'https://example.com/fr/dashboard' }\n * ```\n *\n * @param url - The original URL string to be prefixed with locales.\n * @param locales - Optional array of supported locales. Defaults to `localesDefault`.\n * @param defaultLocale - The default locale. Defaults to `defaultLocaleDefault`.\n * @param prefixDefault - Whether to prefix the default locale. Defaults to `prefixDefaultDefault`.\n * @returns An object mapping each locale to its corresponding multilingual URL.\n */\nexport const getMultilingualUrls = (\n url: string,\n locales: LocalesValues[] = localesDefault,\n defaultLocale: LocalesValues = defaultLocaleDefault,\n prefixDefault: boolean = prefixDefaultDefault\n): IConfigLocales<string> => {\n // Remove any existing locale segment from the URL\n const urlWithoutLocale = getPathWithoutLocale(url, locales);\n\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const parsedUrl = isAbsoluteUrl\n ? new URL(urlWithoutLocale)\n : new URL(urlWithoutLocale, 'http://example.com');\n\n // Extract the pathname from the parsed URL\n let pathname = parsedUrl.pathname;\n\n // Ensure the pathname starts with a '/'\n if (!pathname.startsWith('/')) {\n pathname = `/${pathname}`;\n }\n\n // Prepare the base URL (protocol + host) if it's absolute\n const baseUrl = isAbsoluteUrl\n ? `${parsedUrl.protocol}//${parsedUrl.host}`\n : '';\n\n // Generate multilingual URLs by iterating over each locale\n const multilingualUrls = locales.reduce<IConfigLocales<string>>(\n (acc, locale) => {\n // Determine if the current locale is the default locale\n const isDefaultLocale = locale.toString() === defaultLocale.toString();\n\n // Decide whether to prefix the default locale based on `prefixDefault`\n const shouldPrefix = prefixDefault || !isDefaultLocale;\n\n // Construct the new pathname with or without the locale prefix\n let localizedPath = shouldPrefix ? `/${locale}${pathname}` : pathname;\n\n if (localizedPath.length > 1 && localizedPath.endsWith('/')) {\n localizedPath = localizedPath.slice(0, -1);\n }\n\n // Combine with the base URL if the original URL was absolute\n const localizedUrl = isAbsoluteUrl\n ? `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`\n : `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;\n\n // Assign the constructed URL to the corresponding locale key\n acc[locale as unknown as keyof typeof acc] = localizedUrl;\n\n return acc;\n },\n {} as IConfigLocales<string> // Initialize an empty object\n );\n\n return multilingualUrls;\n};\n"],"mappings":"AAAA,SAAS,wBAA4C;AAGrD,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AAGrC,MAAM,EAAE,sBAAsB,WAAW,IAAI,iBAAiB;AAC9D,MAAM,EAAE,SAAS,gBAAgB,eAAe,qBAAqB,IACnE;AACF,MAAM,EAAE,eAAe,qBAAqB,IAAI;AAuBzC,MAAM,sBAAsB,CACjC,KACA,UAA2B,gBAC3B,gBAA+B,sBAC/B,gBAAyB,yBACE;AAE3B,QAAM,mBAAmB,qBAAqB,KAAK,OAAO;AAG1D,QAAM,gBAAgB,mBAAmB,gBAAgB;AAIzD,QAAM,YAAY,gBACd,IAAI,IAAI,gBAAgB,IACxB,IAAI,IAAI,kBAAkB,oBAAoB;AAGlD,MAAI,WAAW,UAAU;AAGzB,MAAI,CAAC,SAAS,WAAW,GAAG,GAAG;AAC7B,eAAW,IAAI,QAAQ;AAAA,EACzB;AAGA,QAAM,UAAU,gBACZ,GAAG,UAAU,QAAQ,KAAK,UAAU,IAAI,KACxC;AAGJ,QAAM,mBAAmB,QAAQ;AAAA,IAC/B,CAAC,KAAK,WAAW;AAEf,YAAM,kBAAkB,OAAO,SAAS,MAAM,cAAc,SAAS;AAGrE,YAAM,eAAe,iBAAiB,CAAC;AAGvC,UAAI,gBAAgB,eAAe,IAAI,MAAM,GAAG,QAAQ,KAAK;AAE7D,UAAI,cAAc,SAAS,KAAK,cAAc,SAAS,GAAG,GAAG;AAC3D,wBAAgB,cAAc,MAAM,GAAG,EAAE;AAAA,MAC3C;AAGA,YAAM,eAAe,gBACjB,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,MAAM,GAAG,UAAU,IAAI,KAC9D,GAAG,aAAa,GAAG,UAAU,MAAM,GAAG,UAAU,IAAI;AAGxD,UAAI,MAAqC,IAAI;AAE7C,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
@@ -6,7 +6,11 @@ const { internationalization } = getConfiguration();
6
6
  const { locales: localesDefault } = internationalization;
7
7
  const getPathWithoutLocale = (inputUrl, locales = localesDefault) => {
8
8
  const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);
9
- const url = isAbsoluteUrl ? new URL(inputUrl) : new URL(inputUrl, "http://example.com");
9
+ let fixedInputUrl = inputUrl;
10
+ if (inputUrl.endsWith("/")) {
11
+ fixedInputUrl = inputUrl.slice(0, -1);
12
+ }
13
+ const url = isAbsoluteUrl ? new URL(fixedInputUrl) : new URL(fixedInputUrl, "http://example.com");
10
14
  const pathname = url.pathname;
11
15
  if (!pathname.startsWith("/")) {
12
16
  url.pathname = `/${pathname}`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/localization/getPathWithoutLocale.ts"],"sourcesContent":["import {\n getConfiguration,\n type Locales,\n type LocalesValues,\n} from '@intlayer/config/client';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\n\nconst { internationalization } = getConfiguration();\nconst { locales: localesDefault } = internationalization;\n\n/**\n * Removes the locale segment from the given URL or pathname if present.\n *\n * This function get the locales from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * getPathWithoutLocale('/en/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/fr/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('dashboard') // Returns 'dashboard'\n * getPathWithoutLocale('https://example.com/en/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/fr/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard') // Returns 'https://example.com/dashboard'\n * ```\n *\n * @param inputUrl - The complete URL string or pathname to process.\n * @param locales - Optional array of supported locales. Defaults to `localesDefault`.\n * @returns The URL string or pathname without the locale segment.\n */\nexport const getPathWithoutLocale = (\n inputUrl: string,\n locales: LocalesValues[] = localesDefault\n): string => {\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const url = isAbsoluteUrl\n ? new URL(inputUrl)\n : new URL(inputUrl, 'http://example.com');\n\n const pathname = url.pathname;\n\n // Ensure the pathname starts with '/'\n if (!pathname.startsWith('/')) {\n // If not, return the URL as is\n url.pathname = `/${pathname}`;\n }\n\n // Split the pathname to extract the first segment\n const pathSegments = pathname.split('/');\n const firstSegment = pathSegments[1]; // The segment after the first '/'\n\n // Check if the first segment is a supported locale\n if (locales.includes(firstSegment as Locales)) {\n // Remove the locale segment from the pathname\n pathSegments.splice(1, 1); // Remove the first segment\n\n // Reconstruct the pathname\n const newPathname = pathSegments.join('/') ?? '/';\n url.pathname = newPathname;\n }\n\n if (isAbsoluteUrl) {\n // Return the modified URL as a string\n return url.toString();\n }\n\n // Return the modified URL as a string\n return url.toString().replace('http://example.com', '');\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,0BAA0B;AAEnC,MAAM,EAAE,qBAAqB,IAAI,iBAAiB;AAClD,MAAM,EAAE,SAAS,eAAe,IAAI;AAuB7B,MAAM,uBAAuB,CAClC,UACA,UAA2B,mBAChB;AAEX,QAAM,gBAAgB,mBAAmB,QAAQ;AAIjD,QAAM,MAAM,gBACR,IAAI,IAAI,QAAQ,IAChB,IAAI,IAAI,UAAU,oBAAoB;AAE1C,QAAM,WAAW,IAAI;AAGrB,MAAI,CAAC,SAAS,WAAW,GAAG,GAAG;AAE7B,QAAI,WAAW,IAAI,QAAQ;AAAA,EAC7B;AAGA,QAAM,eAAe,SAAS,MAAM,GAAG;AACvC,QAAM,eAAe,aAAa,CAAC;AAGnC,MAAI,QAAQ,SAAS,YAAuB,GAAG;AAE7C,iBAAa,OAAO,GAAG,CAAC;AAGxB,UAAM,cAAc,aAAa,KAAK,GAAG,KAAK;AAC9C,QAAI,WAAW;AAAA,EACjB;AAEA,MAAI,eAAe;AAEjB,WAAO,IAAI,SAAS;AAAA,EACtB;AAGA,SAAO,IAAI,SAAS,EAAE,QAAQ,sBAAsB,EAAE;AACxD;","names":[]}
1
+ {"version":3,"sources":["../../../src/localization/getPathWithoutLocale.ts"],"sourcesContent":["import {\n getConfiguration,\n type Locales,\n type LocalesValues,\n} from '@intlayer/config/client';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\n\nconst { internationalization } = getConfiguration();\nconst { locales: localesDefault } = internationalization;\n\n/**\n * Removes the locale segment from the given URL or pathname if present.\n *\n * This function get the locales from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * getPathWithoutLocale('/en/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/fr/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('dashboard') // Returns 'dashboard'\n * getPathWithoutLocale('https://example.com/en/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/fr/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard') // Returns 'https://example.com/dashboard'\n * ```\n *\n * @param inputUrl - The complete URL string or pathname to process.\n * @param locales - Optional array of supported locales. Defaults to `localesDefault`.\n * @returns The URL string or pathname without the locale segment.\n */\nexport const getPathWithoutLocale = (\n inputUrl: string,\n locales: LocalesValues[] = localesDefault\n): string => {\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);\n\n let fixedInputUrl = inputUrl;\n\n if (inputUrl.endsWith('/')) {\n fixedInputUrl = inputUrl.slice(0, -1);\n }\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const url = isAbsoluteUrl\n ? new URL(fixedInputUrl)\n : new URL(fixedInputUrl, 'http://example.com');\n\n const pathname = url.pathname;\n\n // Ensure the pathname starts with '/'\n if (!pathname.startsWith('/')) {\n // If not, return the URL as is\n url.pathname = `/${pathname}`;\n }\n\n // Split the pathname to extract the first segment\n const pathSegments = pathname.split('/');\n const firstSegment = pathSegments[1]; // The segment after the first '/'\n\n // Check if the first segment is a supported locale\n if (locales.includes(firstSegment as Locales)) {\n // Remove the locale segment from the pathname\n pathSegments.splice(1, 1); // Remove the first segment\n\n // Reconstruct the pathname\n const newPathname = pathSegments.join('/') ?? '/';\n url.pathname = newPathname;\n }\n\n if (isAbsoluteUrl) {\n // Return the modified URL as a string\n return url.toString();\n }\n\n // Return the modified URL as a string\n return url.toString().replace('http://example.com', '');\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,0BAA0B;AAEnC,MAAM,EAAE,qBAAqB,IAAI,iBAAiB;AAClD,MAAM,EAAE,SAAS,eAAe,IAAI;AAuB7B,MAAM,uBAAuB,CAClC,UACA,UAA2B,mBAChB;AAEX,QAAM,gBAAgB,mBAAmB,QAAQ;AAEjD,MAAI,gBAAgB;AAEpB,MAAI,SAAS,SAAS,GAAG,GAAG;AAC1B,oBAAgB,SAAS,MAAM,GAAG,EAAE;AAAA,EACtC;AAIA,QAAM,MAAM,gBACR,IAAI,IAAI,aAAa,IACrB,IAAI,IAAI,eAAe,oBAAoB;AAE/C,QAAM,WAAW,IAAI;AAGrB,MAAI,CAAC,SAAS,WAAW,GAAG,GAAG;AAE7B,QAAI,WAAW,IAAI,QAAQ;AAAA,EAC7B;AAGA,QAAM,eAAe,SAAS,MAAM,GAAG;AACvC,QAAM,eAAe,aAAa,CAAC;AAGnC,MAAI,QAAQ,SAAS,YAAuB,GAAG;AAE7C,iBAAa,OAAO,GAAG,CAAC;AAGxB,UAAM,cAAc,aAAa,KAAK,GAAG,KAAK;AAC9C,QAAI,WAAW;AAAA,EACjB;AAEA,MAAI,eAAe;AAEjB,WAAO,IAAI,SAAS;AAAA,EACtB;AAGA,SAAO,IAAI,SAAS,EAAE,QAAQ,sBAAsB,EAAE;AACxD;","names":[]}
@@ -1,4 +1,7 @@
1
- import { formatNodeType, NodeType } from "../../types/index.mjs";
1
+ import {
2
+ formatNodeType,
3
+ NodeType
4
+ } from "../../types/index.mjs";
2
5
  const enumeration = (content) => formatNodeType(NodeType.Enumeration, content);
3
6
  export {
4
7
  enumeration as enu
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import { formatNodeType, NodeType, TypedNodeModel } from '../../types/index';\n\ntype Positif = number | `${number}`;\ntype Negatif = `-${number}`;\ntype Numbers = Positif | Negatif;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n NodeType.Enumeration,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content>(content?: EnumerationContentState<Content>) =>\n formatNodeType(NodeType.Enumeration, content);\n\nexport { enumeration as enu };\n"],"mappings":"AAAA,SAAS,gBAAgB,gBAAgC;AAmDzD,MAAM,cAAc,CAAU,YAC5B,eAAe,SAAS,aAAa,OAAO;","names":[]}
1
+ {"version":3,"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import {\n type TypedNodeModel,\n formatNodeType,\n NodeType,\n} from '../../types/index';\n\ntype Positif = number | `${number}`;\ntype Negatif = `-${number}`;\ntype Numbers = Positif | Negatif;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n NodeType.Enumeration,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content>(content?: EnumerationContentState<Content>) =>\n formatNodeType(NodeType.Enumeration, content);\n\nexport { enumeration as enu };\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAmDP,MAAM,cAAc,CAAU,YAC5B,eAAe,SAAS,aAAa,OAAO;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DictionaryKeys } from '../../types/dictionary';\nimport {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\nimport type { DeepTransformContent } from '../../interpreter';\n\n/**\n * Recursively builds dot-notation strings for all valid paths in T.\n * Example:\n * type X = { a: { b: { c: string }}, d: number };\n * DotPath<X> = \"a\" | \"a.b\" | \"a.b.c\" | \"d\"\n */\nexport type DotPath<T> = T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object\n ? // Either just K, or K + '.' + deeper path\n `${K}` | `${K}.${DotPath<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\ntype DeepReplace<T, From, To> = T extends From\n ? To\n : T extends object\n ? { [K in keyof T]: DeepReplace<T[K], From, To> }\n : T;\n\n/** Build all valid dot-notation strings for a dictionary entry. */\nexport type ValidDotPathsFor<K extends DictionaryKeys> = DotPath<\n DeepReplace<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content']>,\n // Replace ReactElement type with string\n {\n type: any;\n props: any;\n key: any;\n },\n string\n >\n>;\n\nexport type NestedContentState<K extends DictionaryKeys> = {\n dictionaryKey: K;\n\n /**\n * Path must match existing keys in IntlayerDictionaryTypesConnector[K].\n * Can be either:\n * - \"dot.dot.dot\" format\n */\n path?: ValidDotPathsFor<K>;\n};\n\nexport type NestedContent<K extends DictionaryKeys = never> = TypedNodeModel<\n NodeType.Nested,\n NestedContentState<K>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to extract the content of another dictionary and nest it in the current dictionary.\n *\n * Usage:\n *\n * ```ts\n * nest(\"dictionaryKey\");\n * nest(\"dictionaryKey\", \"path.to.content\");\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n */\nconst nesting = <K extends DictionaryKeys>(\n dictionaryKey: K,\n path?: ValidDotPathsFor<K>\n): NestedContent<K> =>\n formatNodeType(NodeType.Nested, {\n dictionaryKey,\n path,\n });\n\nexport { nesting as nest };\n"],"mappings":"AAGA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAqEP,MAAM,UAAU,CACd,eACA,SAEA,eAAe,SAAS,QAAQ;AAAA,EAC9B;AAAA,EACA;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DeepTransformContent } from '../../interpreter';\nimport type { DictionaryKeys } from '../../types/dictionary';\nimport {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\n\n/**\n * Recursively builds dot-notation strings for all valid paths in T.\n * Example:\n * type X = { a: { b: { c: string }}, d: number };\n * DotPath<X> = \"a\" | \"a.b\" | \"a.b.c\" | \"d\"\n */\nexport type DotPath<T> = T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object\n ? // Either just K, or K + '.' + deeper path\n `${K}` | `${K}.${DotPath<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\ntype DeepReplace<T, From, To> = T extends From\n ? To\n : T extends object\n ? { [K in keyof T]: DeepReplace<T[K], From, To> }\n : T;\n\n/** Build all valid dot-notation strings for a dictionary entry. */\nexport type ValidDotPathsFor<K extends DictionaryKeys> = DotPath<\n DeepReplace<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content']>,\n // Replace ReactElement type with string\n {\n type: any;\n props: any;\n key: any;\n },\n string\n >\n>;\n\nexport type NestedContentState<K extends DictionaryKeys> = {\n dictionaryKey: K;\n\n /**\n * Path must match existing keys in IntlayerDictionaryTypesConnector[K].\n * Can be either:\n * - \"dot.dot.dot\" format\n */\n path?: ValidDotPathsFor<K>;\n};\n\nexport type NestedContent<K extends DictionaryKeys = never> = TypedNodeModel<\n NodeType.Nested,\n NestedContentState<K>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to extract the content of another dictionary and nest it in the current dictionary.\n *\n * Usage:\n *\n * ```ts\n * nest(\"dictionaryKey\");\n * nest(\"dictionaryKey\", \"path.to.content\");\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n */\nconst nesting = <K extends DictionaryKeys>(\n dictionaryKey: K,\n path?: ValidDotPathsFor<K>\n): NestedContent<K> =>\n formatNodeType(NodeType.Nested, {\n dictionaryKey,\n path,\n });\n\nexport { nesting as nest };\n"],"mappings":"AAIA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAoEP,MAAM,UAAU,CACd,eACA,SAEA,eAAe,SAAS,QAAQ;AAAA,EAC9B;AAAA,EACA;AACF,CAAC;","names":[]}
@@ -4,10 +4,13 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
4
4
  NodeType2["Condition"] = "condition";
5
5
  NodeType2["Object"] = "object";
6
6
  NodeType2["Array"] = "array";
7
- NodeType2["Text"] = "text";
8
7
  NodeType2["Nested"] = "nested";
9
8
  NodeType2["ReactNode"] = "reactNode";
10
9
  NodeType2["Markdown"] = "markdown";
10
+ NodeType2["Text"] = "text";
11
+ NodeType2["Number"] = "number";
12
+ NodeType2["Boolean"] = "boolean";
13
+ NodeType2["Unknown"] = "unknown";
11
14
  return NodeType2;
12
15
  })(NodeType || {});
13
16
  const formatNodeType = (nodeType, content) => ({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Condition = 'condition',\n Object = 'object',\n Array = 'array',\n Text = 'text',\n Nested = 'nested',\n ReactNode = 'reactNode',\n Markdown = 'markdown',\n}\n\nexport type TypedNodeModel<T extends NodeType, Content> = {\n nodeType: T | `${T}`;\n} & {\n [K in T]: Content;\n};\n\nexport const formatNodeType = <T extends NodeType, Content = any>(\n nodeType: T | `${T}`,\n content: Content\n) =>\n ({\n nodeType,\n [nodeType]: content,\n }) as TypedNodeModel<T, Content>;\n"],"mappings":"AACO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,cAAW;AATD,SAAAA;AAAA,GAAA;AAkBL,MAAM,iBAAiB,CAC5B,UACA,aAEC;AAAA,EACC;AAAA,EACA,CAAC,QAAQ,GAAG;AACd;","names":["NodeType"]}
1
+ {"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["export enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Condition = 'condition',\n Object = 'object',\n Array = 'array',\n Nested = 'nested',\n ReactNode = 'reactNode',\n Markdown = 'markdown',\n Text = 'text',\n Number = 'number',\n Boolean = 'boolean',\n Unknown = 'unknown',\n}\n\nexport type TypedNodeModel<T extends NodeType, Content> = {\n nodeType: T | `${T}`;\n} & {\n [K in T]: Content;\n};\n\nexport const formatNodeType = <T extends NodeType, Content = any>(\n nodeType: T | `${T}`,\n content: Content\n) =>\n ({\n nodeType,\n [nodeType]: content,\n }) as TypedNodeModel<T, Content>;\n"],"mappings":"AAAO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,cAAW;AACX,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,aAAU;AACV,EAAAA,UAAA,aAAU;AAZA,SAAAA;AAAA,GAAA;AAqBL,MAAM,iBAAiB,CAC5B,UACA,aAEC;AAAA,EACC;AAAA,EACA,CAAC,QAAQ,GAAG;AACd;","names":["NodeType"]}
@@ -1,5 +1,4 @@
1
- const REACT_ELEMENT_TYPE = Symbol.for("react.element");
2
- const isValidElement = (object) => typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1
+ const isValidElement = (object) => typeof object === "object" && typeof object?.key !== "undefined" && typeof object?.props !== "undefined";
3
2
  export {
4
3
  isValidElement
5
4
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/isValidReactElement.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nconst REACT_ELEMENT_TYPE = Symbol.for('react.element');\n\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param object\n * @return True if `object` is a ReactElement.\n * @final\n */\n\nexport const isValidElement = (object: any): boolean =>\n typeof object === 'object' &&\n object !== null &&\n object.$$typeof === REACT_ELEMENT_TYPE;\n"],"mappings":"AACA,MAAM,qBAAqB,OAAO,IAAI,eAAe;AAU9C,MAAM,iBAAiB,CAAC,WAC7B,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,aAAa;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/isValidReactElement.ts"],"sourcesContent":["/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param object\n * @return True if `object` is a ReactElement.\n * @final\n */\n\nexport const isValidElement = (object: any): boolean =>\n typeof object === 'object' &&\n typeof object?.key !== 'undefined' &&\n typeof object?.props !== 'undefined';\n"],"mappings":"AAQO,MAAM,iBAAiB,CAAC,WAC7B,OAAO,WAAW,YAClB,OAAO,QAAQ,QAAQ,eACvB,OAAO,QAAQ,UAAU;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"editDictionaryByKeyPath.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAY,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,eAAO,MAAM,uBAAuB,sBACf,WAAW,WACrB,OAAO,EAAE,YACR,WAAW,KACpB,WA2EF,CAAC"}
1
+ {"version":3,"file":"editDictionaryByKeyPath.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAY,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,eAAO,MAAM,uBAAuB,sBACf,WAAW,WACrB,OAAO,EAAE,YACR,WAAW,KACpB,WA2GF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import type { TranslationContent, EnumerationContent, ConditionContent, NestedContent, MarkdownContent } from '../transpiler';
3
+ import { type ContentNode, NodeType } from '../types';
4
+ export declare const getDefaultNode: (nodeType: NodeType, locales: LocalesValues[], content?: ContentNode) => string | number | boolean | MarkdownContent | NestedContent<never> | ((args?: any) => ContentNode<string | number | boolean, false, string | number | boolean>) | TranslationContent<ContentNode> | EnumerationContent<ContentNode> | ConditionContent<ContentNode> | Record<number, ContentNode>;
5
+ //# sourceMappingURL=getDefaultNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDefaultNode.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,eAAe,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEtD,eAAO,MAAM,cAAc,aACf,QAAQ,WACT,aAAa,EAAE,YACd,WAAW,sSAiEtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ContentNode } from '../types';
2
+ export declare const getNodeChildren: (section: ContentNode) => ContentNode;
3
+ //# sourceMappingURL=getNodeChildren.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNodeChildren.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/getNodeChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAA4B,MAAM,UAAU,CAAC;AAEtE,eAAO,MAAM,eAAe,YAAa,WAAW,KAAG,WAuCtD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { NodeType } from '../types';
2
+ import type { ContentNode } from '../types/dictionary';
3
+ export declare const getNodeType: (content: ContentNode) => NodeType;
4
+ //# sourceMappingURL=getNodeType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNodeType.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/getNodeType.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAuB,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,eAAO,MAAM,WAAW,YAAa,WAAW,KAAG,QAgDlD,CAAC"}
@@ -1,6 +1,9 @@
1
1
  export * from './editDictionaryByKeyPath';
2
2
  export * from './getContentNodeByKeyPath';
3
- export * from './getSectionType';
3
+ export * from './getNodeChildren';
4
4
  export * from './removeContentNodeByKeyPath';
5
5
  export * from './renameContentNodeByKeyPath';
6
+ export * from './getNodeType';
7
+ export * from './updateNodeChildren';
8
+ export * from './getDefaultNode';
6
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ContentNode } from '../types';
2
+ export declare const updateNodeChildren: <T extends ContentNode, U extends ContentNode>(section: T, newChildren: U) => ContentNode;
3
+ //# sourceMappingURL=updateNodeChildren.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateNodeChildren.d.ts","sourceRoot":"","sources":["../../../src/dictionaryManipulator/updateNodeChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAA4B,MAAM,UAAU,CAAC;AAEtE,eAAO,MAAM,kBAAkB,GAC7B,CAAC,SAAS,WAAW,EACrB,CAAC,SAAS,WAAW,WAEZ,CAAC,eACG,CAAC,KACb,WA4DF,CAAC"}
@@ -1,4 +1,4 @@
1
- import { NodeProps } from './plugins';
1
+ import type { NodeProps } from './plugins';
2
2
  /**
3
3
  * Recursively traverses a node (object/array/primitive).
4
4
  * Applies the *first* plugin that can transform a node, then stops descending further.
@@ -1 +1 @@
1
- {"version":3,"file":"deepTransform.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,SAAU,GAAG,SAAS,SAAS,KAAG,GA2C/D,CAAC"}
1
+ {"version":3,"file":"deepTransform.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,SAAU,GAAG,SAAS,SAAS,KAAG,GA2C/D,CAAC"}
@@ -1,4 +1,3 @@
1
- export * from '../getDictionary';
2
1
  export * from './deepTransform';
3
2
  export * from './plugins';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/getContent/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/getContent/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../../src/interpreter/getContent/plugins.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAUhF,OAAO,EAAE,KAAK,gBAAgB,EAAc,MAAM,eAAe,CAAC;AAElE;;oDAEoD;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IAClC,SAAS,EAAE,CACT,IAAI,EAAE,GAAG,EACT,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,KAAK,GAAG,KAC9C,GAAG,CAAC;CACV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AAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,KAAK,GAEhE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAEd,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAa,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE7E;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,aAAa,wBAEX,CAAC,WACJ,CAAC,YACA,OAAO,EAAE,KAcP,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9C,CAAC"}
1
+ {"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAa,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAG7E;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,aAAa,wBAEX,CAAC,WACJ,CAAC,YACA,OAAO,EAAE,KAcP,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAC9C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { LocalesValues } from '@intlayer/config';
2
+ import type { IntlayerDictionaryTypesConnector } from 'intlayer';
2
3
  import type { DictionaryKeys } from '../types';
3
- import { IntlayerDictionaryTypesConnector } from 'intlayer';
4
4
  import type { DeepTransformContent, Plugins } from './getContent/plugins';
5
5
  export declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues>(key: T, locale?: L, plugins?: Plugins[]) => DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>;
6
6
  //# sourceMappingURL=getIntlayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getIntlayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOtD,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,UAAU,CAAC;AAG3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE1E,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,OACtE,CAAC,WACG,CAAC,YACA,OAAO,EAAE,KAYP,oBAAoB,CAC9B,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAEjD,CAAC"}
1
+ {"version":3,"file":"getIntlayer.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQtD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG1E,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,OACtE,CAAC,WACG,CAAC,YACA,OAAO,EAAE,KAYP,oBAAoB,CAC9B,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAEjD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayerAsync.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getIntlayerAsync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,aAAa,OAElB,CAAC,WACG,CAAC,YACA,OAAO,EAAE,iBASpB,CAAC"}
1
+ {"version":3,"file":"getIntlayerAsync.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getIntlayerAsync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,aAAa,OAElB,CAAC,WACG,CAAC,YACA,OAAO,EAAE,iBASpB,CAAC"}
@@ -1,7 +1,7 @@
1
+ import type { IntlayerDictionaryTypesConnector } from 'intlayer';
1
2
  import type { ValidDotPathsFor } from '../transpiler';
2
3
  import type { DictionaryKeys } from '../types';
3
4
  import type { DeepTransformContent, IInterpreterPluginState, NodeProps } from './getContent';
4
- import { IntlayerDictionaryTypesConnector } from 'intlayer';
5
5
  type GetSubPath<T, P> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? GetSubPath<T[K], Rest> : never : P extends keyof T ? T[P] : T;
6
6
  export type GetNestingResult<K extends DictionaryKeys, P = undefined, S = IInterpreterPluginState> = GetSubPath<DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content'], S>, P>;
7
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"getNesting.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getNesting.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACvB,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAE5D,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,IAAI,EAAE,GACxD,CAAC,SAAS,MAAM,CAAC,GACf,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GACtB,KAAK,GACP,CAAC,SAAS,MAAM,CAAC,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC;AAER,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,cAAc,EACxB,CAAC,GAAG,SAAS,EACb,CAAC,GAAG,uBAAuB,IACzB,UAAU,CACZ,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,EACvE,CAAC,CACF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,iBACrC,CAAC,SACT,CAAC,SAAS,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,UACxC,SAAS,KAChB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAqBvB,CAAC"}
1
+ {"version":3,"file":"getNesting.d.ts","sourceRoot":"","sources":["../../../src/interpreter/getNesting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACvB,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,IAAI,EAAE,GACxD,CAAC,SAAS,MAAM,CAAC,GACf,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GACtB,KAAK,GACP,CAAC,SAAS,MAAM,CAAC,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC;AAER,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,cAAc,EACxB,CAAC,GAAG,SAAS,EACb,CAAC,GAAG,uBAAuB,IACzB,UAAU,CACZ,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,EACvE,CAAC,CACF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,iBACrC,CAAC,SACT,CAAC,SAAS,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,UACxC,SAAS,KAChB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAqBvB,CAAC"}
@@ -1,7 +1,6 @@
1
1
  export * from './getContent/index';
2
2
  export * from './getNesting';
3
3
  export * from './getEnumeration';
4
- export * from './getEnumeration';
5
4
  export * from './getIntlayer';
6
5
  export * from './getDictionary';
7
6
  export * from './getIntlayerAsync';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interpreter/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interpreter/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPathWithoutLocale.d.ts","sourceRoot":"","sources":["../../../src/localization/getPathWithoutLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AAMjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,aACrB,MAAM,YACP,aAAa,EAAE,KACvB,MAuCF,CAAC"}
1
+ {"version":3,"file":"getPathWithoutLocale.d.ts","sourceRoot":"","sources":["../../../src/localization/getPathWithoutLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAC;AAMjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,aACrB,MAAM,YACP,aAAa,EAAE,KACvB,MA6CF,CAAC"}
@@ -1,4 +1,4 @@
1
- import { NodeType, TypedNodeModel } from '../../types/index';
1
+ import { type TypedNodeModel, NodeType } from '../../types/index';
2
2
  type Positif = number | `${number}`;
3
3
  type Negatif = `-${number}`;
4
4
  type Numbers = Positif | Negatif;