@intlayer/core 2.0.0 → 2.0.2

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 (82) hide show
  1. package/dist/cjs/index.cjs +3 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/index.d.ts +5 -3
  4. package/dist/cjs/transpiler/content_transformers/enumeration/enumeration.cjs +2 -2
  5. package/dist/cjs/transpiler/content_transformers/enumeration/enumeration.cjs.map +1 -1
  6. package/dist/cjs/transpiler/content_transformers/enumeration/enumeration.d.ts +2 -1
  7. package/dist/cjs/transpiler/content_transformers/index.d.ts +0 -1
  8. package/dist/cjs/transpiler/content_transformers/translation/getTranslationContent.d.ts +0 -1
  9. package/dist/cjs/transpiler/content_transformers/translation/index.d.ts +0 -1
  10. package/dist/cjs/transpiler/content_transformers/translation/translation.cjs +2 -2
  11. package/dist/cjs/transpiler/content_transformers/translation/translation.cjs.map +1 -1
  12. package/dist/cjs/transpiler/content_transformers/translation/translation.d.ts +0 -1
  13. package/dist/cjs/transpiler/content_transformers/translation/types.cjs.map +1 -1
  14. package/dist/cjs/transpiler/content_transformers/translation/types.d.ts +2 -2
  15. package/dist/cjs/transpiler/index.d.ts +0 -1
  16. package/dist/cjs/types/declarationContent.cjs +17 -0
  17. package/dist/cjs/types/declarationContent.cjs.map +1 -0
  18. package/dist/cjs/types/declarationContent.d.ts +26 -0
  19. package/dist/cjs/types/{contentModule.cjs → dictionary.cjs} +3 -3
  20. package/dist/cjs/types/dictionary.cjs.map +1 -0
  21. package/dist/cjs/types/dictionary.d.ts +17 -0
  22. package/dist/cjs/types/index.cjs.map +1 -1
  23. package/dist/cjs/types/index.d.ts +4 -3
  24. package/dist/cjs/types/keyPath.cjs.map +1 -1
  25. package/dist/cjs/types/keyPath.d.ts +6 -2
  26. package/dist/cjs/utils/{getStackTraceInfo.cjs → isSameKeyPath.cjs} +9 -23
  27. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -0
  28. package/dist/cjs/utils/isSameKeyPath.d.ts +6 -0
  29. package/dist/esm/index.d.mts +5 -3
  30. package/dist/esm/index.mjs +2 -0
  31. package/dist/esm/index.mjs.map +1 -1
  32. package/dist/esm/transpiler/content_transformers/enumeration/enumeration.d.mts +2 -1
  33. package/dist/esm/transpiler/content_transformers/enumeration/enumeration.mjs +2 -2
  34. package/dist/esm/transpiler/content_transformers/enumeration/enumeration.mjs.map +1 -1
  35. package/dist/esm/transpiler/content_transformers/index.d.mts +0 -1
  36. package/dist/esm/transpiler/content_transformers/translation/getTranslationContent.d.mts +0 -1
  37. package/dist/esm/transpiler/content_transformers/translation/index.d.mts +0 -1
  38. package/dist/esm/transpiler/content_transformers/translation/translation.d.mts +0 -1
  39. package/dist/esm/transpiler/content_transformers/translation/translation.mjs +2 -2
  40. package/dist/esm/transpiler/content_transformers/translation/translation.mjs.map +1 -1
  41. package/dist/esm/transpiler/content_transformers/translation/types.d.mts +2 -2
  42. package/dist/esm/transpiler/index.d.mts +0 -1
  43. package/dist/esm/types/declarationContent.d.mts +26 -0
  44. package/dist/esm/types/declarationContent.mjs +1 -0
  45. package/dist/esm/types/dictionary.d.mts +17 -0
  46. package/dist/esm/types/dictionary.mjs +1 -0
  47. package/dist/esm/types/dictionary.mjs.map +1 -0
  48. package/dist/esm/types/index.d.mts +4 -3
  49. package/dist/esm/types/index.mjs.map +1 -1
  50. package/dist/esm/types/keyPath.d.mts +6 -2
  51. package/dist/esm/utils/isSameKeyPath.d.mts +6 -0
  52. package/dist/esm/utils/isSameKeyPath.mjs +7 -0
  53. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -0
  54. package/package.json +9 -10
  55. package/src/index.ts +5 -1
  56. package/dist/cjs/types/contentModule.cjs.map +0 -1
  57. package/dist/cjs/types/contentModule.d.ts +0 -22
  58. package/dist/cjs/utils/getStackTraceInfo.cjs.map +0 -1
  59. package/dist/cjs/utils/getStackTraceInfo.d.ts +0 -12
  60. package/dist/esm/types/contentModule.d.mts +0 -22
  61. package/dist/esm/types/contentModule.mjs +0 -1
  62. package/dist/esm/utils/getStackTraceInfo.d.mts +0 -12
  63. package/dist/esm/utils/getStackTraceInfo.mjs +0 -21
  64. package/dist/esm/utils/getStackTraceInfo.mjs.map +0 -1
  65. package/src/getLocaleName.ts +0 -463
  66. package/src/localeList.ts +0 -229
  67. package/src/transpiler/content_transformers/enumeration/enumeration.ts +0 -66
  68. package/src/transpiler/content_transformers/enumeration/findMatchingCondition.ts +0 -64
  69. package/src/transpiler/content_transformers/enumeration/getEnumerationContent.ts +0 -38
  70. package/src/transpiler/content_transformers/enumeration/index.ts +0 -3
  71. package/src/transpiler/content_transformers/index.ts +0 -2
  72. package/src/transpiler/content_transformers/translation/getTranslationContent.ts +0 -33
  73. package/src/transpiler/content_transformers/translation/index.ts +0 -3
  74. package/src/transpiler/content_transformers/translation/translation.ts +0 -49
  75. package/src/transpiler/content_transformers/translation/types.ts +0 -71
  76. package/src/transpiler/index.ts +0 -1
  77. package/src/types/contentModule.ts +0 -33
  78. package/src/types/index.ts +0 -14
  79. package/src/types/keyPath.ts +0 -13
  80. package/src/types/nodeType.ts +0 -4
  81. package/src/utils/getStackTraceInfo.ts +0 -39
  82. /package/dist/esm/types/{contentModule.mjs.map → declarationContent.mjs.map} +0 -0
@@ -24,6 +24,7 @@ __export(src_exports, {
24
24
  getEnumerationContent: () => import_content_transformers.getEnumerationContent,
25
25
  getLocaleName: () => import_getLocaleName.getLocaleName,
26
26
  getTranslationContent: () => import_content_transformers.getTranslationContent,
27
+ isSameKeyPath: () => import_isSameKeyPath.isSameKeyPath,
27
28
  localeList: () => import_localeList.localeList,
28
29
  t: () => import_content_transformers.t
29
30
  });
@@ -32,6 +33,7 @@ var import_content_transformers = require('./transpiler/content_transformers/ind
32
33
  var import_types = require('./types/index.cjs');
33
34
  var import_getLocaleName = require('./getLocaleName.cjs');
34
35
  var import_localeList = require('./localeList.cjs');
36
+ var import_isSameKeyPath = require('./utils/isSameKeyPath.cjs');
35
37
  // Annotate the CommonJS export names for ESM import in node:
36
38
  0 && (module.exports = {
37
39
  NodeType,
@@ -40,6 +42,7 @@ var import_localeList = require('./localeList.cjs');
40
42
  getEnumerationContent,
41
43
  getLocaleName,
42
44
  getTranslationContent,
45
+ isSameKeyPath,
43
46
  localeList,
44
47
  t
45
48
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n CustomizableLanguageContent,\n LanguageContent,\n TranslationContent,\n EnumerationContent,\n QuantityContent,\n CustomLocales as Locales,\n} from './transpiler/content_transformers/index';\nexport {\n t,\n enu,\n getTranslationContent,\n findMatchingCondition,\n getEnumerationContent,\n} from './transpiler/content_transformers/index';\nexport type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n ContentModule,\n KeyPath,\n ObjectExpressionNode,\n TranslationOrEnumerationNode,\n} from './types/index';\nexport { NodeType } from './types/index';\nexport { getLocaleName } from './getLocaleName';\nexport { localeList } from './localeList';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,kCAMO;AAYP,mBAAyB;AACzB,2BAA8B;AAC9B,wBAA2B;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n CustomizableLanguageContent,\n LanguageContent,\n TranslationContent,\n EnumerationContent,\n QuantityContent,\n CustomLocales as Locales,\n} from './transpiler/content_transformers/index';\nexport {\n t,\n enu,\n getTranslationContent,\n findMatchingCondition,\n getEnumerationContent,\n} from './transpiler/content_transformers/index';\nexport type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n DeclarationContent,\n KeyPath,\n ObjectExpressionNode,\n ArrayExpressionNode,\n TranslationOrEnumerationNode,\n DictionaryValue,\n Dictionary,\n} from './types/index';\nexport { NodeType } from './types/index';\nexport { getLocaleName } from './getLocaleName';\nexport { localeList } from './localeList';\nexport { isSameKeyPath } from './utils/isSameKeyPath';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,kCAMO;AAeP,mBAAyB;AACzB,2BAA8B;AAC9B,wBAA2B;AAC3B,2BAA8B;","names":[]}
@@ -4,11 +4,13 @@ export { CustomizableLanguageContent, LanguageContent, CustomLocales as Locales,
4
4
  export { EnumerationContent, QuantityContent, enu } from './transpiler/content_transformers/enumeration/enumeration.js';
5
5
  export { getEnumerationContent } from './transpiler/content_transformers/enumeration/getEnumerationContent.js';
6
6
  export { findMatchingCondition } from './transpiler/content_transformers/enumeration/findMatchingCondition.js';
7
- export { Content, ContentModule, ContentValue, FlatContent, FlatContentValue, TypedNode } from './types/contentModule.js';
7
+ export { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './types/declarationContent.js';
8
8
  export { NodeType } from './types/nodeType.js';
9
- export { KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './types/keyPath.js';
9
+ export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './types/keyPath.js';
10
+ export { Dictionary, DictionaryValue } from './types/dictionary.js';
10
11
  export { getLocaleName } from './getLocaleName.js';
11
12
  export { localeList } from './localeList.js';
13
+ export { isSameKeyPath } from './utils/isSameKeyPath.js';
12
14
  import '@intlayer/config/client';
13
15
  import 'intlayer';
14
- import './utils/getStackTraceInfo.js';
16
+ import 'react';
@@ -26,13 +26,13 @@ const enumeration = (content) => {
26
26
  if (typeof content === "string") {
27
27
  const result2 = {
28
28
  nodeType: import_types.NodeType.Enumeration,
29
- 1: content
29
+ [import_types.NodeType.Enumeration]: { 1: content }
30
30
  };
31
31
  return result2;
32
32
  }
33
33
  const result = {
34
34
  nodeType: import_types.NodeType.Enumeration,
35
- ...content
35
+ [import_types.NodeType.Enumeration]: { ...content }
36
36
  };
37
37
  return result;
38
38
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/enumeration.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { NodeType } 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 QuantityContent<Content> = Record<EnterFormat, Content>;\n\nexport type EnumerationContent<Content> = Partial<QuantityContent<Content>> & {\n nodeType: NodeType.Enumeration;\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 * const content = 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?: Partial<QuantityContent<Content>>) => {\n if (typeof content === 'string') {\n const result: EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration,\n 1: content,\n };\n\n return result;\n }\n\n const result: EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration,\n ...content,\n };\n\n return result;\n};\n\nexport { enumeration as enu };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAyB;AA8CzB,MAAM,cAAc,CAAU,YAAgD;AAC5E,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,UAAsC;AAAA,MAC1C,UAAU,sBAAS;AAAA,MACnB,GAAG;AAAA,IACL;AAEA,WAAOA;AAAA,EACT;AAEA,QAAM,SAAsC;AAAA,IAC1C,UAAU,sBAAS;AAAA,IACnB,GAAG;AAAA,EACL;AAEA,SAAO;AACT;","names":["result"]}
1
+ {"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/enumeration.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { NodeType } 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 QuantityContent<Content> = Record<EnterFormat, Content>;\n\nexport type EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration;\n [NodeType.Enumeration]: Partial<QuantityContent<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 * const content = 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?: Partial<QuantityContent<Content>>) => {\n if (typeof content === 'string') {\n const result: EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: { 1: content },\n };\n\n return result;\n }\n\n const result: EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: { ...content },\n };\n\n return result;\n};\n\nexport { enumeration as enu };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAyB;AA+CzB,MAAM,cAAc,CAAU,YAAgD;AAC5E,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,UAAsC;AAAA,MAC1C,UAAU,sBAAS;AAAA,MACnB,CAAC,sBAAS,WAAW,GAAG,EAAE,GAAG,QAAQ;AAAA,IACvC;AAEA,WAAOA;AAAA,EACT;AAEA,QAAM,SAAsC;AAAA,IAC1C,UAAU,sBAAS;AAAA,IACnB,CAAC,sBAAS,WAAW,GAAG,EAAE,GAAG,QAAQ;AAAA,EACvC;AAEA,SAAO;AACT;","names":["result"]}
@@ -11,8 +11,9 @@ type Inferior = `<${Numbers}`;
11
11
  type InferiorOrEqual = `<=${Numbers}`;
12
12
  type EnterFormat = Equal | EqualString | Superior | SuperiorOrEqual | Inferior | InferiorOrEqual;
13
13
  type QuantityContent<Content> = Record<EnterFormat, Content>;
14
- type EnumerationContent<Content> = Partial<QuantityContent<Content>> & {
14
+ type EnumerationContent<Content> = {
15
15
  nodeType: NodeType.Enumeration;
16
+ [NodeType.Enumeration]: Partial<QuantityContent<Content>>;
16
17
  };
17
18
  /**
18
19
  * Function intended to be used to build intlayer dictionaries.
@@ -7,4 +7,3 @@ export { findMatchingCondition } from './enumeration/findMatchingCondition.js';
7
7
  import '@intlayer/config/client';
8
8
  import 'intlayer';
9
9
  import '../../types/nodeType.js';
10
- import '../../utils/getStackTraceInfo.js';
@@ -2,7 +2,6 @@ import { Locales } from '@intlayer/config/client';
2
2
  import { CustomizableLanguageContent } from './types.js';
3
3
  import 'intlayer';
4
4
  import '../../../types/nodeType.js';
5
- import '../../../utils/getStackTraceInfo.js';
6
5
 
7
6
  type GetTranslationContent = <Content = string>(languageContent: CustomizableLanguageContent<Content>, locale: Locales) => Content;
8
7
  /**
@@ -4,4 +4,3 @@ export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageCont
4
4
  import '@intlayer/config/client';
5
5
  import 'intlayer';
6
6
  import '../../../types/nodeType.js';
7
- import '../../../utils/getStackTraceInfo.js';
@@ -30,13 +30,13 @@ const translation = (content) => {
30
30
  if (typeof content === "string") {
31
31
  const result2 = {
32
32
  nodeType: import_types.NodeType.Translation,
33
- [defaultLocale]: content
33
+ [import_types.NodeType.Translation]: { [defaultLocale]: content }
34
34
  };
35
35
  return result2;
36
36
  }
37
37
  const result = {
38
38
  nodeType: import_types.NodeType.Translation,
39
- ...content
39
+ [import_types.NodeType.Translation]: content
40
40
  };
41
41
  return result;
42
42
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/translation.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { NodeType } from '../../../types/index';\nimport type { CustomizableLanguageContent, TranslationContent } from './types';\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <Content = string>(\n content?: CustomizableLanguageContent<Content>\n) => {\n const {\n internationalization: { defaultLocale },\n } = getConfiguration();\n\n if (typeof content === 'string') {\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n [defaultLocale]: content,\n } as TranslationContent<Content>;\n\n return result;\n }\n\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n ...(content as unknown as object),\n } as TranslationContent<Content>;\n\n return result;\n};\n\nexport { translation as t };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,mBAAyB;AAuBzB,MAAM,cAAc,CAClB,YACG;AACH,QAAM;AAAA,IACJ,sBAAsB,EAAE,cAAc;AAAA,EACxC,QAAI,gCAAiB;AAErB,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,UAAsC;AAAA,MAC1C,UAAU,sBAAS;AAAA,MACnB,CAAC,aAAa,GAAG;AAAA,IACnB;AAEA,WAAOA;AAAA,EACT;AAEA,QAAM,SAAsC;AAAA,IAC1C,UAAU,sBAAS;AAAA,IACnB,GAAI;AAAA,EACN;AAEA,SAAO;AACT;","names":["result"]}
1
+ {"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/translation.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { NodeType } from '../../../types/index';\nimport type { CustomizableLanguageContent, TranslationContent } from './types';\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <Content = string>(\n content?: CustomizableLanguageContent<Content>\n) => {\n const {\n internationalization: { defaultLocale },\n } = getConfiguration();\n\n if (typeof content === 'string') {\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: { [defaultLocale]: content },\n } as TranslationContent<Content>;\n\n return result;\n }\n\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: content,\n } as TranslationContent<Content>;\n\n return result;\n};\n\nexport { translation as t };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,mBAAyB;AAuBzB,MAAM,cAAc,CAClB,YACG;AACH,QAAM;AAAA,IACJ,sBAAsB,EAAE,cAAc;AAAA,EACxC,QAAI,gCAAiB;AAErB,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,UAAsC;AAAA,MAC1C,UAAU,sBAAS;AAAA,MACnB,CAAC,sBAAS,WAAW,GAAG,EAAE,CAAC,aAAa,GAAG,QAAQ;AAAA,IACrD;AAEA,WAAOA;AAAA,EACT;AAEA,QAAM,SAAsC;AAAA,IAC1C,UAAU,sBAAS;AAAA,IACnB,CAAC,sBAAS,WAAW,GAAG;AAAA,EAC1B;AAEA,SAAO;AACT;","names":["result"]}
@@ -2,7 +2,6 @@ import { TranslationContent } from './types.js';
2
2
  import '@intlayer/config/client';
3
3
  import 'intlayer';
4
4
  import '../../../types/nodeType.js';
5
- import '../../../utils/getStackTraceInfo.js';
6
5
 
7
6
  /**
8
7
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/types.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\n// @ts-expect-error intlayer declared for module augmentation\nimport type { IConfigLocales } from 'intlayer';\nimport type { NodeType } from '../../../types';\nimport type { NoteStackTraceInfo } from '../../../utils/getStackTraceInfo';\n\n/**\n * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n * If not, it will return never\n */\nexport type ConfigLocales = keyof IConfigLocales<unknown>;\n\n/**\n * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n * If not, it will return all available locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n */\nexport type CustomLocales = ConfigLocales extends never\n ? LocalesValues\n : ConfigLocales;\n\n/**\n * Record of locales and content\n *\n * const myVar1: LanguageContent<string> = {\n * \"en\": \"\",\n * \"fr\": \"\"\n * }\n *\n * const myVar2: LanguageContent<{age: number, name: string}> = {\n * \"en\": {age: 1, name: \"test\"},\n * \"fr\": {age: 1, name: \"test\"}\n * }\n */\nexport type LanguageContent<Content> = Partial<Record<LocalesValues, Content>>;\n\n/**\n * Valid\n * const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {\n * \"en\": \"test\",\n * \"fr\": \"test\"\n * }\n *\n * const test: CustomizableLanguageContent<number> = {\n * \"fr\": 1,\n * \"en\": 1,\n * ... any other available locale\n * }\n *\n * Invalid\n *\n * const test: CustomizableLanguageContent<string> = {\n * \"en\": \"test\",\n * \"fr\": \"test\",\n * \"sss\": \"test\" // Does not exist in Locales\n * }\n *\n * const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {\n * \"fr\": \"test\"\n * // Locales.ENGLISH is missing\n * }\n *\n */\nexport type CustomizableLanguageContent<Content = string> =\n ConfigLocales extends never\n ? LanguageContent<Content>\n : IConfigLocales<Content>;\n\nexport type TranslationContent<Content> = LanguageContent<Content> &\n NoteStackTraceInfo & {\n nodeType: NodeType.Translation;\n };\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/types.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\n// @ts-expect-error intlayer declared for module augmentation\nimport type { IConfigLocales } from 'intlayer';\nimport type { NodeType } from '../../../types';\n\n/**\n * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n * If not, it will return never\n */\nexport type ConfigLocales = keyof IConfigLocales<unknown>;\n\n/**\n * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n * If not, it will return all available locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n */\nexport type CustomLocales = ConfigLocales extends never\n ? LocalesValues\n : ConfigLocales;\n\n/**\n * Record of locales and content\n *\n * const myVar1: LanguageContent<string> = {\n * \"en\": \"\",\n * \"fr\": \"\"\n * }\n *\n * const myVar2: LanguageContent<{age: number, name: string}> = {\n * \"en\": {age: 1, name: \"test\"},\n * \"fr\": {age: 1, name: \"test\"}\n * }\n */\nexport type LanguageContent<Content> = Partial<Record<LocalesValues, Content>>;\n\n/**\n * Valid\n * const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {\n * \"en\": \"test\",\n * \"fr\": \"test\"\n * }\n *\n * const test: CustomizableLanguageContent<number> = {\n * \"fr\": 1,\n * \"en\": 1,\n * ... any other available locale\n * }\n *\n * Invalid\n *\n * const test: CustomizableLanguageContent<string> = {\n * \"en\": \"test\",\n * \"fr\": \"test\",\n * \"sss\": \"test\" // Does not exist in Locales\n * }\n *\n * const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {\n * \"fr\": \"test\"\n * // Locales.ENGLISH is missing\n * }\n *\n */\nexport type CustomizableLanguageContent<Content = string> =\n ConfigLocales extends never\n ? LanguageContent<Content>\n : IConfigLocales<Content>;\n\nexport type TranslationContent<Content> = {\n nodeType: NodeType.Translation;\n [NodeType.Translation]: LanguageContent<Content>;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,7 +1,6 @@
1
1
  import { LocalesValues } from '@intlayer/config/client';
2
2
  import { IConfigLocales } from 'intlayer';
3
3
  import { NodeType } from '../../../types/nodeType.js';
4
- import { NoteStackTraceInfo } from '../../../utils/getStackTraceInfo.js';
5
4
 
6
5
  /**
7
6
  * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
@@ -55,8 +54,9 @@ type LanguageContent<Content> = Partial<Record<LocalesValues, Content>>;
55
54
  *
56
55
  */
57
56
  type CustomizableLanguageContent<Content = string> = ConfigLocales extends never ? LanguageContent<Content> : IConfigLocales<Content>;
58
- type TranslationContent<Content> = LanguageContent<Content> & NoteStackTraceInfo & {
57
+ type TranslationContent<Content> = {
59
58
  nodeType: NodeType.Translation;
59
+ [NodeType.Translation]: LanguageContent<Content>;
60
60
  };
61
61
 
62
62
  export type { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent };
@@ -7,4 +7,3 @@ export { findMatchingCondition } from './content_transformers/enumeration/findMa
7
7
  import '@intlayer/config/client';
8
8
  import 'intlayer';
9
9
  import '../types/nodeType.js';
10
- import '../utils/getStackTraceInfo.js';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var declarationContent_exports = {};
16
+ module.exports = __toCommonJS(declarationContent_exports);
17
+ //# sourceMappingURL=declarationContent.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/declarationContent.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type {\n EnumerationContent,\n TranslationContent,\n} from '../transpiler/index';\n\nexport type TypedNode =\n | TranslationContent<unknown>\n | EnumerationContent<unknown>;\n\nexport type ContentValue =\n | string\n | string[]\n | number\n | number[]\n | {\n [key: string]: ContentValue;\n }\n | (() => ContentValue)\n | Promise<ContentValue>\n | TypedNode;\n\nexport type Content = Record<string, ContentValue | ContentValue[] | undefined>;\n\nexport type FlatContentValue =\n | string\n | {\n [key: string]: FlatContentValue;\n }\n | TypedNode;\n\nexport type FlatContent = Record<string, FlatContentValue | undefined>;\n\n// Utility type that performs recursive replacement\ntype ReplaceContentValue<T> = {\n [P in keyof T]: T[P] extends string | number | boolean | null | ReactNode\n ? ContentValue\n : T[P] extends object\n ? ReplaceContentValue<T[P]>\n : ReplaceContentValueArray<T[P]>;\n};\n\ntype ReplaceContentValueArray<T> = T extends (infer U)[]\n ? ReplaceContentValue<U>[]\n : ReplaceContentValue<T>;\n\nexport type DeclarationContent<T = undefined> = (T extends undefined // Applying the generic to replace ContentValue with Replacement\n ? Content\n : ReplaceContentValue<T>) & {\n id: string;\n filePath?: string;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,26 @@
1
+ import { ReactNode } from 'react';
2
+ import { TranslationContent } from '../transpiler/content_transformers/translation/types.js';
3
+ import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.js';
4
+ import '@intlayer/config/client';
5
+ import 'intlayer';
6
+ import './nodeType.js';
7
+
8
+ type TypedNode = TranslationContent<unknown> | EnumerationContent<unknown>;
9
+ type ContentValue = string | string[] | number | number[] | {
10
+ [key: string]: ContentValue;
11
+ } | (() => ContentValue) | Promise<ContentValue> | TypedNode;
12
+ type Content = Record<string, ContentValue | ContentValue[] | undefined>;
13
+ type FlatContentValue = string | {
14
+ [key: string]: FlatContentValue;
15
+ } | TypedNode;
16
+ type FlatContent = Record<string, FlatContentValue | undefined>;
17
+ type ReplaceContentValue<T> = {
18
+ [P in keyof T]: T[P] extends string | number | boolean | null | ReactNode ? ContentValue : T[P] extends object ? ReplaceContentValue<T[P]> : ReplaceContentValueArray<T[P]>;
19
+ };
20
+ type ReplaceContentValueArray<T> = T extends (infer U)[] ? ReplaceContentValue<U>[] : ReplaceContentValue<T>;
21
+ type DeclarationContent<T = undefined> = (T extends undefined ? Content : ReplaceContentValue<T>) & {
22
+ id: string;
23
+ filePath?: string;
24
+ };
25
+
26
+ export type { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode };
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
12
12
  return to;
13
13
  };
14
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var contentModule_exports = {};
16
- module.exports = __toCommonJS(contentModule_exports);
17
- //# sourceMappingURL=contentModule.cjs.map
15
+ var dictionary_exports = {};
16
+ module.exports = __toCommonJS(dictionary_exports);
17
+ //# sourceMappingURL=dictionary.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/dictionary.ts"],"sourcesContent":["import type {\n EnumerationContent,\n TranslationContent,\n} from '../transpiler/index';\n\nexport type RecursiveDictionaryValue =\n | number\n | string\n | { [paramKey: string]: RecursiveDictionaryValue }\n | RecursiveDictionaryValue[];\n\nexport type DictionaryValue =\n | RecursiveDictionaryValue\n | TranslationContent<RecursiveDictionaryValue>\n | EnumerationContent<RecursiveDictionaryValue>;\n\nexport type Dictionary = {\n id: string;\n filePath: string;\n [key: string]: DictionaryValue;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,17 @@
1
+ import { TranslationContent } from '../transpiler/content_transformers/translation/types.js';
2
+ import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.js';
3
+ import '@intlayer/config/client';
4
+ import 'intlayer';
5
+ import './nodeType.js';
6
+
7
+ type RecursiveDictionaryValue = number | string | {
8
+ [paramKey: string]: RecursiveDictionaryValue;
9
+ } | RecursiveDictionaryValue[];
10
+ type DictionaryValue = RecursiveDictionaryValue | TranslationContent<RecursiveDictionaryValue> | EnumerationContent<RecursiveDictionaryValue>;
11
+ type Dictionary = {
12
+ id: string;
13
+ filePath: string;
14
+ [key: string]: DictionaryValue;
15
+ };
16
+
17
+ export type { Dictionary, DictionaryValue, RecursiveDictionaryValue };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["export type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n ContentModule,\n} from './contentModule';\nexport { NodeType } from './nodeType';\nexport type {\n KeyPath,\n ObjectExpressionNode,\n TranslationOrEnumerationNode,\n} from './keyPath';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,sBAAyB;","names":[]}
1
+ {"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["export type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n DeclarationContent,\n} from './declarationContent';\nexport { NodeType } from './nodeType';\nexport type {\n KeyPath,\n ObjectExpressionNode,\n ArrayExpressionNode,\n TranslationOrEnumerationNode,\n} from './keyPath';\nexport type { DictionaryValue, Dictionary } from './dictionary';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,sBAAyB;","names":[]}
@@ -1,8 +1,9 @@
1
- export { Content, ContentModule, ContentValue, FlatContent, FlatContentValue, TypedNode } from './contentModule.js';
1
+ export { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './declarationContent.js';
2
2
  export { NodeType } from './nodeType.js';
3
- export { KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './keyPath.js';
3
+ export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './keyPath.js';
4
+ export { Dictionary, DictionaryValue } from './dictionary.js';
5
+ import 'react';
4
6
  import '../transpiler/content_transformers/translation/types.js';
5
7
  import '@intlayer/config/client';
6
8
  import 'intlayer';
7
- import '../utils/getStackTraceInfo.js';
8
9
  import '../transpiler/content_transformers/enumeration/enumeration.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/keyPath.ts"],"sourcesContent":["import type { NodeType } from './nodeType';\n\nexport type ObjectExpressionNode = {\n type: 'ObjectExpression';\n key: string;\n};\n\nexport type TranslationOrEnumerationNode = {\n type: NodeType;\n key: string;\n};\n\nexport type KeyPath = ObjectExpressionNode | TranslationOrEnumerationNode;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/types/keyPath.ts"],"sourcesContent":["import type { NodeType } from './nodeType';\n\nexport type ObjectExpressionNode = {\n type: 'ObjectExpression';\n key: string;\n};\n\nexport type ArrayExpressionNode = {\n type: 'ArrayExpression';\n key: number;\n};\n\nexport type TranslationOrEnumerationNode = {\n type: NodeType;\n key: string;\n};\n\nexport type KeyPath =\n | ObjectExpressionNode\n | ArrayExpressionNode\n | TranslationOrEnumerationNode;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -4,10 +4,14 @@ type ObjectExpressionNode = {
4
4
  type: 'ObjectExpression';
5
5
  key: string;
6
6
  };
7
+ type ArrayExpressionNode = {
8
+ type: 'ArrayExpression';
9
+ key: number;
10
+ };
7
11
  type TranslationOrEnumerationNode = {
8
12
  type: NodeType;
9
13
  key: string;
10
14
  };
11
- type KeyPath = ObjectExpressionNode | TranslationOrEnumerationNode;
15
+ type KeyPath = ObjectExpressionNode | ArrayExpressionNode | TranslationOrEnumerationNode;
12
16
 
13
- export type { KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode };
17
+ export type { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode };
@@ -16,30 +16,16 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var getStackTraceInfo_exports = {};
20
- __export(getStackTraceInfo_exports, {
21
- getStackTraceInfo: () => getStackTraceInfo
19
+ var isSameKeyPath_exports = {};
20
+ __export(isSameKeyPath_exports, {
21
+ isSameKeyPath: () => isSameKeyPath
22
22
  });
23
- module.exports = __toCommonJS(getStackTraceInfo_exports);
24
- const getStackTraceInfo = () => {
25
- const err = new Error();
26
- const stack = err.stack ?? "";
27
- const stackLines = stack.split("\n");
28
- const callerLine = stackLines[2] ?? "";
29
- const match = callerLine.match(/at\s[^(:]+\([^:]+:(\d+):(\d+)\)?/);
30
- const line = match?.[1];
31
- const column = match?.[2];
32
- if (match) {
33
- return {
34
- // file,
35
- line,
36
- column
37
- };
38
- }
39
- return {};
40
- };
23
+ module.exports = __toCommonJS(isSameKeyPath_exports);
24
+ const isSameKeyPath = (keyPath1, keyPath2) => keyPath1.every(
25
+ (element, index) => keyPath2[index] && keyPath2[index].key === element.key && keyPath2[index].type === element.type
26
+ );
41
27
  // Annotate the CommonJS export names for ESM import in node:
42
28
  0 && (module.exports = {
43
- getStackTraceInfo
29
+ isSameKeyPath
44
30
  });
45
- //# sourceMappingURL=getStackTraceInfo.cjs.map
31
+ //# sourceMappingURL=isSameKeyPath.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/isSameKeyPath.ts"],"sourcesContent":["import type { KeyPath } from '../types';\n\nexport const isSameKeyPath = (keyPath1: KeyPath[], keyPath2: KeyPath[]) =>\n keyPath1.every(\n (element, index) =>\n keyPath2[index] &&\n keyPath2[index].key === element.key &&\n keyPath2[index].type === element.type\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,gBAAgB,CAAC,UAAqB,aACjD,SAAS;AAAA,EACP,CAAC,SAAS,UACR,SAAS,KAAK,KACd,SAAS,KAAK,EAAE,QAAQ,QAAQ,OAChC,SAAS,KAAK,EAAE,SAAS,QAAQ;AACrC;","names":[]}
@@ -0,0 +1,6 @@
1
+ import { KeyPath } from '../types/keyPath.js';
2
+ import '../types/nodeType.js';
3
+
4
+ declare const isSameKeyPath: (keyPath1: KeyPath[], keyPath2: KeyPath[]) => boolean;
5
+
6
+ export { isSameKeyPath };
@@ -4,11 +4,13 @@ export { CustomizableLanguageContent, LanguageContent, CustomLocales as Locales,
4
4
  export { EnumerationContent, QuantityContent, enu } from './transpiler/content_transformers/enumeration/enumeration.mjs';
5
5
  export { getEnumerationContent } from './transpiler/content_transformers/enumeration/getEnumerationContent.mjs';
6
6
  export { findMatchingCondition } from './transpiler/content_transformers/enumeration/findMatchingCondition.mjs';
7
- export { Content, ContentModule, ContentValue, FlatContent, FlatContentValue, TypedNode } from './types/contentModule.mjs';
7
+ export { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './types/declarationContent.mjs';
8
8
  export { NodeType } from './types/nodeType.mjs';
9
- export { KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './types/keyPath.mjs';
9
+ export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './types/keyPath.mjs';
10
+ export { Dictionary, DictionaryValue } from './types/dictionary.mjs';
10
11
  export { getLocaleName } from './getLocaleName.mjs';
11
12
  export { localeList } from './localeList.mjs';
13
+ export { isSameKeyPath } from './utils/isSameKeyPath.mjs';
12
14
  import '@intlayer/config/client';
13
15
  import 'intlayer';
14
- import './utils/getStackTraceInfo.mjs';
16
+ import 'react';
@@ -8,6 +8,7 @@ import {
8
8
  import { NodeType } from './types/index.mjs';
9
9
  import { getLocaleName } from './getLocaleName.mjs';
10
10
  import { localeList } from './localeList.mjs';
11
+ import { isSameKeyPath } from './utils/isSameKeyPath.mjs';
11
12
  export {
12
13
  NodeType,
13
14
  enu,
@@ -15,6 +16,7 @@ export {
15
16
  getEnumerationContent,
16
17
  getLocaleName,
17
18
  getTranslationContent,
19
+ isSameKeyPath,
18
20
  localeList,
19
21
  t
20
22
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n CustomizableLanguageContent,\n LanguageContent,\n TranslationContent,\n EnumerationContent,\n QuantityContent,\n CustomLocales as Locales,\n} from './transpiler/content_transformers/index';\nexport {\n t,\n enu,\n getTranslationContent,\n findMatchingCondition,\n getEnumerationContent,\n} from './transpiler/content_transformers/index';\nexport type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n ContentModule,\n KeyPath,\n ObjectExpressionNode,\n TranslationOrEnumerationNode,\n} from './types/index';\nexport { NodeType } from './types/index';\nexport { getLocaleName } from './getLocaleName';\nexport { localeList } from './localeList';\n"],"mappings":"AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAYP,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n CustomizableLanguageContent,\n LanguageContent,\n TranslationContent,\n EnumerationContent,\n QuantityContent,\n CustomLocales as Locales,\n} from './transpiler/content_transformers/index';\nexport {\n t,\n enu,\n getTranslationContent,\n findMatchingCondition,\n getEnumerationContent,\n} from './transpiler/content_transformers/index';\nexport type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n DeclarationContent,\n KeyPath,\n ObjectExpressionNode,\n ArrayExpressionNode,\n TranslationOrEnumerationNode,\n DictionaryValue,\n Dictionary,\n} from './types/index';\nexport { NodeType } from './types/index';\nexport { getLocaleName } from './getLocaleName';\nexport { localeList } from './localeList';\nexport { isSameKeyPath } from './utils/isSameKeyPath';\n"],"mappings":"AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAeP,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;","names":[]}
@@ -11,8 +11,9 @@ type Inferior = `<${Numbers}`;
11
11
  type InferiorOrEqual = `<=${Numbers}`;
12
12
  type EnterFormat = Equal | EqualString | Superior | SuperiorOrEqual | Inferior | InferiorOrEqual;
13
13
  type QuantityContent<Content> = Record<EnterFormat, Content>;
14
- type EnumerationContent<Content> = Partial<QuantityContent<Content>> & {
14
+ type EnumerationContent<Content> = {
15
15
  nodeType: NodeType.Enumeration;
16
+ [NodeType.Enumeration]: Partial<QuantityContent<Content>>;
16
17
  };
17
18
  /**
18
19
  * Function intended to be used to build intlayer dictionaries.
@@ -3,13 +3,13 @@ const enumeration = (content) => {
3
3
  if (typeof content === "string") {
4
4
  const result2 = {
5
5
  nodeType: NodeType.Enumeration,
6
- 1: content
6
+ [NodeType.Enumeration]: { 1: content }
7
7
  };
8
8
  return result2;
9
9
  }
10
10
  const result = {
11
11
  nodeType: NodeType.Enumeration,
12
- ...content
12
+ [NodeType.Enumeration]: { ...content }
13
13
  };
14
14
  return result;
15
15
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/enumeration.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { NodeType } 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 QuantityContent<Content> = Record<EnterFormat, Content>;\n\nexport type EnumerationContent<Content> = Partial<QuantityContent<Content>> & {\n nodeType: NodeType.Enumeration;\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 * const content = 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?: Partial<QuantityContent<Content>>) => {\n if (typeof content === 'string') {\n const result: EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration,\n 1: content,\n };\n\n return result;\n }\n\n const result: EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration,\n ...content,\n };\n\n return result;\n};\n\nexport { enumeration as enu };\n"],"mappings":"AACA,SAAS,gBAAgB;AA8CzB,MAAM,cAAc,CAAU,YAAgD;AAC5E,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,UAAsC;AAAA,MAC1C,UAAU,SAAS;AAAA,MACnB,GAAG;AAAA,IACL;AAEA,WAAOA;AAAA,EACT;AAEA,QAAM,SAAsC;AAAA,IAC1C,UAAU,SAAS;AAAA,IACnB,GAAG;AAAA,EACL;AAEA,SAAO;AACT;","names":["result"]}
1
+ {"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/enumeration.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { NodeType } 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 QuantityContent<Content> = Record<EnterFormat, Content>;\n\nexport type EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration;\n [NodeType.Enumeration]: Partial<QuantityContent<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 * const content = 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?: Partial<QuantityContent<Content>>) => {\n if (typeof content === 'string') {\n const result: EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: { 1: content },\n };\n\n return result;\n }\n\n const result: EnumerationContent<Content> = {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: { ...content },\n };\n\n return result;\n};\n\nexport { enumeration as enu };\n"],"mappings":"AACA,SAAS,gBAAgB;AA+CzB,MAAM,cAAc,CAAU,YAAgD;AAC5E,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,UAAsC;AAAA,MAC1C,UAAU,SAAS;AAAA,MACnB,CAAC,SAAS,WAAW,GAAG,EAAE,GAAG,QAAQ;AAAA,IACvC;AAEA,WAAOA;AAAA,EACT;AAEA,QAAM,SAAsC;AAAA,IAC1C,UAAU,SAAS;AAAA,IACnB,CAAC,SAAS,WAAW,GAAG,EAAE,GAAG,QAAQ;AAAA,EACvC;AAEA,SAAO;AACT;","names":["result"]}
@@ -7,4 +7,3 @@ export { findMatchingCondition } from './enumeration/findMatchingCondition.mjs';
7
7
  import '@intlayer/config/client';
8
8
  import 'intlayer';
9
9
  import '../../types/nodeType.mjs';
10
- import '../../utils/getStackTraceInfo.mjs';
@@ -2,7 +2,6 @@ import { Locales } from '@intlayer/config/client';
2
2
  import { CustomizableLanguageContent } from './types.mjs';
3
3
  import 'intlayer';
4
4
  import '../../../types/nodeType.mjs';
5
- import '../../../utils/getStackTraceInfo.mjs';
6
5
 
7
6
  type GetTranslationContent = <Content = string>(languageContent: CustomizableLanguageContent<Content>, locale: Locales) => Content;
8
7
  /**
@@ -4,4 +4,3 @@ export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageCont
4
4
  import '@intlayer/config/client';
5
5
  import 'intlayer';
6
6
  import '../../../types/nodeType.mjs';
7
- import '../../../utils/getStackTraceInfo.mjs';
@@ -2,7 +2,6 @@ import { TranslationContent } from './types.mjs';
2
2
  import '@intlayer/config/client';
3
3
  import 'intlayer';
4
4
  import '../../../types/nodeType.mjs';
5
- import '../../../utils/getStackTraceInfo.mjs';
6
5
 
7
6
  /**
8
7
  *
@@ -7,13 +7,13 @@ const translation = (content) => {
7
7
  if (typeof content === "string") {
8
8
  const result2 = {
9
9
  nodeType: NodeType.Translation,
10
- [defaultLocale]: content
10
+ [NodeType.Translation]: { [defaultLocale]: content }
11
11
  };
12
12
  return result2;
13
13
  }
14
14
  const result = {
15
15
  nodeType: NodeType.Translation,
16
- ...content
16
+ [NodeType.Translation]: content
17
17
  };
18
18
  return result;
19
19
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/translation.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { NodeType } from '../../../types/index';\nimport type { CustomizableLanguageContent, TranslationContent } from './types';\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <Content = string>(\n content?: CustomizableLanguageContent<Content>\n) => {\n const {\n internationalization: { defaultLocale },\n } = getConfiguration();\n\n if (typeof content === 'string') {\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n [defaultLocale]: content,\n } as TranslationContent<Content>;\n\n return result;\n }\n\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n ...(content as unknown as object),\n } as TranslationContent<Content>;\n\n return result;\n};\n\nexport { translation as t };\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AAuBzB,MAAM,cAAc,CAClB,YACG;AACH,QAAM;AAAA,IACJ,sBAAsB,EAAE,cAAc;AAAA,EACxC,IAAI,iBAAiB;AAErB,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,UAAsC;AAAA,MAC1C,UAAU,SAAS;AAAA,MACnB,CAAC,aAAa,GAAG;AAAA,IACnB;AAEA,WAAOA;AAAA,EACT;AAEA,QAAM,SAAsC;AAAA,IAC1C,UAAU,SAAS;AAAA,IACnB,GAAI;AAAA,EACN;AAEA,SAAO;AACT;","names":["result"]}
1
+ {"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/translation.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { NodeType } from '../../../types/index';\nimport type { CustomizableLanguageContent, TranslationContent } from './types';\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <Content = string>(\n content?: CustomizableLanguageContent<Content>\n) => {\n const {\n internationalization: { defaultLocale },\n } = getConfiguration();\n\n if (typeof content === 'string') {\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: { [defaultLocale]: content },\n } as TranslationContent<Content>;\n\n return result;\n }\n\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: content,\n } as TranslationContent<Content>;\n\n return result;\n};\n\nexport { translation as t };\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AAuBzB,MAAM,cAAc,CAClB,YACG;AACH,QAAM;AAAA,IACJ,sBAAsB,EAAE,cAAc;AAAA,EACxC,IAAI,iBAAiB;AAErB,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,UAAsC;AAAA,MAC1C,UAAU,SAAS;AAAA,MACnB,CAAC,SAAS,WAAW,GAAG,EAAE,CAAC,aAAa,GAAG,QAAQ;AAAA,IACrD;AAEA,WAAOA;AAAA,EACT;AAEA,QAAM,SAAsC;AAAA,IAC1C,UAAU,SAAS;AAAA,IACnB,CAAC,SAAS,WAAW,GAAG;AAAA,EAC1B;AAEA,SAAO;AACT;","names":["result"]}
@@ -1,7 +1,6 @@
1
1
  import { LocalesValues } from '@intlayer/config/client';
2
2
  import { IConfigLocales } from 'intlayer';
3
3
  import { NodeType } from '../../../types/nodeType.mjs';
4
- import { NoteStackTraceInfo } from '../../../utils/getStackTraceInfo.mjs';
5
4
 
6
5
  /**
7
6
  * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
@@ -55,8 +54,9 @@ type LanguageContent<Content> = Partial<Record<LocalesValues, Content>>;
55
54
  *
56
55
  */
57
56
  type CustomizableLanguageContent<Content = string> = ConfigLocales extends never ? LanguageContent<Content> : IConfigLocales<Content>;
58
- type TranslationContent<Content> = LanguageContent<Content> & NoteStackTraceInfo & {
57
+ type TranslationContent<Content> = {
59
58
  nodeType: NodeType.Translation;
59
+ [NodeType.Translation]: LanguageContent<Content>;
60
60
  };
61
61
 
62
62
  export type { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent };
@@ -7,4 +7,3 @@ export { findMatchingCondition } from './content_transformers/enumeration/findMa
7
7
  import '@intlayer/config/client';
8
8
  import 'intlayer';
9
9
  import '../types/nodeType.mjs';
10
- import '../utils/getStackTraceInfo.mjs';
@@ -0,0 +1,26 @@
1
+ import { ReactNode } from 'react';
2
+ import { TranslationContent } from '../transpiler/content_transformers/translation/types.mjs';
3
+ import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.mjs';
4
+ import '@intlayer/config/client';
5
+ import 'intlayer';
6
+ import './nodeType.mjs';
7
+
8
+ type TypedNode = TranslationContent<unknown> | EnumerationContent<unknown>;
9
+ type ContentValue = string | string[] | number | number[] | {
10
+ [key: string]: ContentValue;
11
+ } | (() => ContentValue) | Promise<ContentValue> | TypedNode;
12
+ type Content = Record<string, ContentValue | ContentValue[] | undefined>;
13
+ type FlatContentValue = string | {
14
+ [key: string]: FlatContentValue;
15
+ } | TypedNode;
16
+ type FlatContent = Record<string, FlatContentValue | undefined>;
17
+ type ReplaceContentValue<T> = {
18
+ [P in keyof T]: T[P] extends string | number | boolean | null | ReactNode ? ContentValue : T[P] extends object ? ReplaceContentValue<T[P]> : ReplaceContentValueArray<T[P]>;
19
+ };
20
+ type ReplaceContentValueArray<T> = T extends (infer U)[] ? ReplaceContentValue<U>[] : ReplaceContentValue<T>;
21
+ type DeclarationContent<T = undefined> = (T extends undefined ? Content : ReplaceContentValue<T>) & {
22
+ id: string;
23
+ filePath?: string;
24
+ };
25
+
26
+ export type { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=declarationContent.mjs.map
@@ -0,0 +1,17 @@
1
+ import { TranslationContent } from '../transpiler/content_transformers/translation/types.mjs';
2
+ import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.mjs';
3
+ import '@intlayer/config/client';
4
+ import 'intlayer';
5
+ import './nodeType.mjs';
6
+
7
+ type RecursiveDictionaryValue = number | string | {
8
+ [paramKey: string]: RecursiveDictionaryValue;
9
+ } | RecursiveDictionaryValue[];
10
+ type DictionaryValue = RecursiveDictionaryValue | TranslationContent<RecursiveDictionaryValue> | EnumerationContent<RecursiveDictionaryValue>;
11
+ type Dictionary = {
12
+ id: string;
13
+ filePath: string;
14
+ [key: string]: DictionaryValue;
15
+ };
16
+
17
+ export type { Dictionary, DictionaryValue, RecursiveDictionaryValue };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=dictionary.mjs.map