@intlayer/core 1.2.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +6 -2
- package/dist/cjs/transpiler/content_transformers/enumeration/enumeration.cjs +0 -4
- package/dist/cjs/transpiler/content_transformers/enumeration/enumeration.cjs.map +1 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/enumeration.d.ts +2 -3
- package/dist/cjs/transpiler/content_transformers/enumeration/findMatchingCondition.cjs +42 -0
- package/dist/cjs/transpiler/content_transformers/enumeration/findMatchingCondition.cjs.map +1 -0
- package/dist/cjs/transpiler/content_transformers/enumeration/findMatchingCondition.d.ts +33 -0
- package/dist/cjs/transpiler/content_transformers/enumeration/getEnumerationContent.cjs +3 -12
- package/dist/cjs/transpiler/content_transformers/enumeration/getEnumerationContent.cjs.map +1 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/getEnumerationContent.d.ts +0 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/index.cjs +3 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/index.cjs.map +1 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/index.d.ts +2 -2
- package/dist/cjs/transpiler/content_transformers/index.d.ts +3 -3
- package/dist/cjs/transpiler/content_transformers/translation/getTranslationContent.d.ts +0 -1
- package/dist/cjs/transpiler/content_transformers/translation/index.d.ts +1 -2
- package/dist/cjs/transpiler/content_transformers/translation/translation.cjs +0 -4
- package/dist/cjs/transpiler/content_transformers/translation/translation.cjs.map +1 -1
- package/dist/cjs/transpiler/content_transformers/translation/translation.d.ts +2 -3
- package/dist/cjs/transpiler/content_transformers/translation/types.cjs.map +1 -1
- package/dist/cjs/transpiler/content_transformers/translation/types.d.ts +3 -5
- package/dist/cjs/transpiler/index.d.ts +3 -3
- package/dist/cjs/types/declarationContent.cjs +17 -0
- package/dist/cjs/types/declarationContent.cjs.map +1 -0
- package/dist/cjs/types/declarationContent.d.ts +27 -0
- package/dist/cjs/types/{contentModule.cjs → dictionary.cjs} +3 -3
- package/dist/cjs/types/dictionary.cjs.map +1 -0
- package/dist/cjs/types/dictionary.d.ts +17 -0
- package/dist/cjs/types/index.cjs.map +1 -1
- package/dist/cjs/types/index.d.ts +4 -2
- package/dist/cjs/types/keyPath.cjs +17 -0
- package/dist/cjs/types/keyPath.cjs.map +1 -0
- package/dist/cjs/types/keyPath.d.ts +17 -0
- package/dist/cjs/utils/{getStackTraceInfo.cjs → isSameKeyPath.cjs} +9 -23
- package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -0
- package/dist/cjs/utils/isSameKeyPath.d.ts +6 -0
- package/dist/esm/index.d.mts +6 -2
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/transpiler/content_transformers/enumeration/enumeration.d.mts +2 -3
- package/dist/esm/transpiler/content_transformers/enumeration/enumeration.mjs +0 -6
- package/dist/esm/transpiler/content_transformers/enumeration/enumeration.mjs.map +1 -1
- package/dist/esm/transpiler/content_transformers/enumeration/findMatchingCondition.d.mts +33 -0
- package/dist/esm/transpiler/content_transformers/enumeration/findMatchingCondition.mjs +18 -0
- package/dist/esm/transpiler/content_transformers/enumeration/findMatchingCondition.mjs.map +1 -0
- package/dist/esm/transpiler/content_transformers/enumeration/getEnumerationContent.d.mts +0 -1
- package/dist/esm/transpiler/content_transformers/enumeration/getEnumerationContent.mjs +3 -12
- package/dist/esm/transpiler/content_transformers/enumeration/getEnumerationContent.mjs.map +1 -1
- package/dist/esm/transpiler/content_transformers/enumeration/index.d.mts +2 -2
- package/dist/esm/transpiler/content_transformers/enumeration/index.mjs +1 -0
- package/dist/esm/transpiler/content_transformers/enumeration/index.mjs.map +1 -1
- package/dist/esm/transpiler/content_transformers/index.d.mts +3 -3
- package/dist/esm/transpiler/content_transformers/translation/getTranslationContent.d.mts +0 -1
- package/dist/esm/transpiler/content_transformers/translation/index.d.mts +1 -2
- package/dist/esm/transpiler/content_transformers/translation/translation.d.mts +2 -3
- package/dist/esm/transpiler/content_transformers/translation/translation.mjs +0 -4
- package/dist/esm/transpiler/content_transformers/translation/translation.mjs.map +1 -1
- package/dist/esm/transpiler/content_transformers/translation/types.d.mts +3 -5
- package/dist/esm/transpiler/index.d.mts +3 -3
- package/dist/esm/types/declarationContent.d.mts +27 -0
- package/dist/esm/types/declarationContent.mjs +1 -0
- package/dist/esm/types/dictionary.d.mts +17 -0
- package/dist/esm/types/dictionary.mjs +1 -0
- package/dist/esm/types/dictionary.mjs.map +1 -0
- package/dist/esm/types/index.d.mts +4 -2
- package/dist/esm/types/index.mjs.map +1 -1
- package/dist/esm/types/keyPath.d.mts +17 -0
- package/dist/esm/types/keyPath.mjs +1 -0
- package/dist/esm/types/keyPath.mjs.map +1 -0
- package/dist/esm/utils/isSameKeyPath.d.mts +6 -0
- package/dist/esm/utils/isSameKeyPath.mjs +7 -0
- package/dist/esm/utils/isSameKeyPath.mjs.map +1 -0
- package/package.json +2 -4
- package/src/index.ts +10 -1
- package/dist/cjs/types/contentModule.cjs.map +0 -1
- package/dist/cjs/types/contentModule.d.ts +0 -21
- package/dist/cjs/utils/getStackTraceInfo.cjs.map +0 -1
- package/dist/cjs/utils/getStackTraceInfo.d.ts +0 -12
- package/dist/esm/types/contentModule.d.mts +0 -21
- package/dist/esm/types/contentModule.mjs +0 -1
- package/dist/esm/utils/getStackTraceInfo.d.mts +0 -12
- package/dist/esm/utils/getStackTraceInfo.mjs +0 -21
- package/dist/esm/utils/getStackTraceInfo.mjs.map +0 -1
- package/src/getLocaleName.ts +0 -463
- package/src/localeList.ts +0 -229
- package/src/transpiler/content_transformers/enumeration/enumeration.ts +0 -75
- package/src/transpiler/content_transformers/enumeration/getEnumerationContent.ts +0 -66
- package/src/transpiler/content_transformers/enumeration/index.ts +0 -2
- package/src/transpiler/content_transformers/index.ts +0 -2
- package/src/transpiler/content_transformers/translation/getTranslationContent.ts +0 -33
- package/src/transpiler/content_transformers/translation/index.ts +0 -3
- package/src/transpiler/content_transformers/translation/translation.ts +0 -54
- package/src/transpiler/content_transformers/translation/types.ts +0 -72
- package/src/transpiler/index.ts +0 -1
- package/src/types/contentModule.ts +0 -32
- package/src/types/index.ts +0 -9
- package/src/types/nodeType.ts +0 -4
- package/src/utils/getStackTraceInfo.ts +0 -39
- /package/dist/esm/types/{contentModule.mjs.map → declarationContent.mjs.map} +0 -0
|
@@ -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":[]}
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -3,10 +3,14 @@ export { getTranslationContent } from './transpiler/content_transformers/transla
|
|
|
3
3
|
export { CustomizableLanguageContent, LanguageContent, CustomLocales as Locales, TranslationContent } from './transpiler/content_transformers/translation/types.mjs';
|
|
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
|
-
export {
|
|
6
|
+
export { findMatchingCondition } from './transpiler/content_transformers/enumeration/findMatchingCondition.mjs';
|
|
7
|
+
export { Content, ContentValue, ContentValueArray, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './types/declarationContent.mjs';
|
|
7
8
|
export { NodeType } from './types/nodeType.mjs';
|
|
9
|
+
export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './types/keyPath.mjs';
|
|
10
|
+
export { Dictionary, DictionaryValue } from './types/dictionary.mjs';
|
|
8
11
|
export { getLocaleName } from './getLocaleName.mjs';
|
|
9
12
|
export { localeList } from './localeList.mjs';
|
|
13
|
+
export { isSameKeyPath } from './utils/isSameKeyPath.mjs';
|
|
10
14
|
import '@intlayer/config/client';
|
|
11
15
|
import 'intlayer';
|
|
12
|
-
import '
|
|
16
|
+
import 'react';
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2,17 +2,21 @@ import {
|
|
|
2
2
|
t,
|
|
3
3
|
enu,
|
|
4
4
|
getTranslationContent,
|
|
5
|
+
findMatchingCondition,
|
|
5
6
|
getEnumerationContent
|
|
6
7
|
} from './transpiler/content_transformers/index.mjs';
|
|
7
8
|
import { NodeType } from './types/index.mjs';
|
|
8
9
|
import { getLocaleName } from './getLocaleName.mjs';
|
|
9
10
|
import { localeList } from './localeList.mjs';
|
|
11
|
+
import { isSameKeyPath } from './utils/isSameKeyPath.mjs';
|
|
10
12
|
export {
|
|
11
13
|
NodeType,
|
|
12
14
|
enu,
|
|
15
|
+
findMatchingCondition,
|
|
13
16
|
getEnumerationContent,
|
|
14
17
|
getLocaleName,
|
|
15
18
|
getTranslationContent,
|
|
19
|
+
isSameKeyPath,
|
|
16
20
|
localeList,
|
|
17
21
|
t
|
|
18
22
|
};
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -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 getEnumerationContent,\n} from './transpiler/content_transformers/index';\nexport type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n
|
|
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 ContentValueArray,\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;AAgBP,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;","names":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NoteStackTraceInfo } from '../../../utils/getStackTraceInfo.mjs';
|
|
2
1
|
import { NodeType } from '../../../types/nodeType.mjs';
|
|
3
2
|
|
|
4
3
|
type Positif = number | `${number}`;
|
|
@@ -12,7 +11,7 @@ type Inferior = `<${Numbers}`;
|
|
|
12
11
|
type InferiorOrEqual = `<=${Numbers}`;
|
|
13
12
|
type EnterFormat = Equal | EqualString | Superior | SuperiorOrEqual | Inferior | InferiorOrEqual;
|
|
14
13
|
type QuantityContent<Content> = Record<EnterFormat, Content>;
|
|
15
|
-
type EnumerationContent<Content> = Partial<QuantityContent<Content>> &
|
|
14
|
+
type EnumerationContent<Content> = Partial<QuantityContent<Content>> & {
|
|
16
15
|
nodeType: NodeType.Enumeration;
|
|
17
16
|
};
|
|
18
17
|
/**
|
|
@@ -36,4 +35,4 @@ type EnumerationContent<Content> = Partial<QuantityContent<Content>> & NoteStack
|
|
|
36
35
|
*/
|
|
37
36
|
declare const enumeration: <Content>(content?: Partial<QuantityContent<Content>>) => EnumerationContent<Content>;
|
|
38
37
|
|
|
39
|
-
export { type EnumerationContent, type QuantityContent, enumeration as enu };
|
|
38
|
+
export { type EnterFormat, type EnumerationContent, type QuantityContent, enumeration as enu };
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { NodeType } from '../../../types/index.mjs';
|
|
2
|
-
import {
|
|
3
|
-
getStackTraceInfo
|
|
4
|
-
} from '../../../utils/getStackTraceInfo.mjs';
|
|
5
2
|
const enumeration = (content) => {
|
|
6
|
-
const stackTraceInfo = getStackTraceInfo();
|
|
7
3
|
if (typeof content === "string") {
|
|
8
4
|
const result2 = {
|
|
9
5
|
nodeType: NodeType.Enumeration,
|
|
10
|
-
...stackTraceInfo,
|
|
11
6
|
1: content
|
|
12
7
|
};
|
|
13
8
|
return result2;
|
|
14
9
|
}
|
|
15
10
|
const result = {
|
|
16
11
|
nodeType: NodeType.Enumeration,
|
|
17
|
-
...stackTraceInfo,
|
|
18
12
|
...content
|
|
19
13
|
};
|
|
20
14
|
return result;
|
|
@@ -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';\
|
|
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"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { QuantityContent, EnterFormat } from './enumeration.mjs';
|
|
2
|
+
import '../../../types/nodeType.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Find the matching condition for a quantity.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const key = findMatchingCondition({
|
|
11
|
+
* '<=-2.3': 'You have less than -2.3',
|
|
12
|
+
* '<1': 'You have less than one',
|
|
13
|
+
* '2': 'You have two',
|
|
14
|
+
* '>=3': 'You have three or more',
|
|
15
|
+
* }, 2);
|
|
16
|
+
* // '2'
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* The order of the keys will define the priority of the content.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const key = findMatchingCondition({
|
|
23
|
+
* '<4': 'You have less than four',
|
|
24
|
+
* '2': 'You have two',
|
|
25
|
+
* }, 2);
|
|
26
|
+
* // '<4'
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* If no keys match, the default key is '1'.
|
|
30
|
+
*/
|
|
31
|
+
declare const findMatchingCondition: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => EnterFormat;
|
|
32
|
+
|
|
33
|
+
export { findMatchingCondition };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const findMatchingCondition = (enumerationContent, quantity) => {
|
|
2
|
+
const numericKeys = Object.keys(enumerationContent);
|
|
3
|
+
for (const key of numericKeys) {
|
|
4
|
+
const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity;
|
|
5
|
+
const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1));
|
|
6
|
+
const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
|
|
7
|
+
const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1));
|
|
8
|
+
const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
|
|
9
|
+
if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) {
|
|
10
|
+
return key;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return "1";
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
findMatchingCondition
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=findMatchingCondition.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/findMatchingCondition.ts"],"sourcesContent":["import type { EnterFormat, QuantityContent } from './enumeration';\n\n/**\n * Find the matching condition for a quantity.\n *\n * Usage:\n *\n * ```ts\n * const key = findMatchingCondition({\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 * }, 2);\n * // '2'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // '<4'\n * ```\n *\n * If no keys match, the default key is '1'.\n */\nexport const findMatchingCondition = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): EnterFormat => {\n const numericKeys = Object.keys(enumerationContent);\n\n for (const key of numericKeys) {\n const isEqual =\n (!key.startsWith('>') &&\n !key.startsWith('<') &&\n !key.startsWith('=') &&\n parseFloat(key) === quantity) ||\n (key.startsWith('=') && parseFloat(key.slice(1)) === quantity);\n const isSuperior =\n key.startsWith('>') && quantity > parseFloat(key.slice(1));\n const isSuperiorOrEqual =\n key.startsWith('>=') && quantity >= parseFloat(key.slice(2));\n const isInferior =\n key.startsWith('<') && quantity < parseFloat(key.slice(1));\n const isInferiorOrEqual =\n key.startsWith('<=') && quantity <= parseFloat(key.slice(2));\n\n if (\n isEqual ||\n isSuperior ||\n isSuperiorOrEqual ||\n isInferior ||\n isInferiorOrEqual\n ) {\n return key as EnterFormat;\n }\n }\n\n return '1';\n};\n"],"mappings":"AA6BO,MAAM,wBAAwB,CACnC,oBACA,aACgB;AAChB,QAAM,cAAc,OAAO,KAAK,kBAAkB;AAElD,aAAW,OAAO,aAAa;AAC7B,UAAM,UACH,CAAC,IAAI,WAAW,GAAG,KAClB,CAAC,IAAI,WAAW,GAAG,KACnB,CAAC,IAAI,WAAW,GAAG,KACnB,WAAW,GAAG,MAAM,YACrB,IAAI,WAAW,GAAG,KAAK,WAAW,IAAI,MAAM,CAAC,CAAC,MAAM;AACvD,UAAM,aACJ,IAAI,WAAW,GAAG,KAAK,WAAW,WAAW,IAAI,MAAM,CAAC,CAAC;AAC3D,UAAM,oBACJ,IAAI,WAAW,IAAI,KAAK,YAAY,WAAW,IAAI,MAAM,CAAC,CAAC;AAC7D,UAAM,aACJ,IAAI,WAAW,GAAG,KAAK,WAAW,WAAW,IAAI,MAAM,CAAC,CAAC;AAC3D,UAAM,oBACJ,IAAI,WAAW,IAAI,KAAK,YAAY,WAAW,IAAI,MAAM,CAAC,CAAC;AAE7D,QACE,WACA,cACA,qBACA,cACA,mBACA;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
+
import { findMatchingCondition } from '../../index.mjs';
|
|
1
2
|
const getEnumerationContent = (enumerationContent, quantity) => {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity;
|
|
5
|
-
const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1));
|
|
6
|
-
const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
|
|
7
|
-
const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1));
|
|
8
|
-
const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
|
|
9
|
-
if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) {
|
|
10
|
-
return enumerationContent[key];
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return enumerationContent["1"];
|
|
3
|
+
const key = findMatchingCondition(enumerationContent, quantity);
|
|
4
|
+
return enumerationContent[key];
|
|
14
5
|
};
|
|
15
6
|
export {
|
|
16
7
|
getEnumerationContent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/getEnumerationContent.ts"],"sourcesContent":["import type { QuantityContent } from './enumeration';\n\
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/getEnumerationContent.ts"],"sourcesContent":["import { findMatchingCondition } from '../..';\nimport type { QuantityContent } from './enumeration';\n\n/**\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * const content = getEnumerationContent({\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 * }, 2);\n * // 'You have two'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const content = getEnumerationContent({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // 'You have less than four'\n * ```\n *\n */\nexport const getEnumerationContent = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): Content => {\n const key = findMatchingCondition<Content>(enumerationContent, quantity);\n\n // Default or error handling if no keys match\n return enumerationContent[key];\n};\n"],"mappings":"AAAA,SAAS,6BAA6B;AA6B/B,MAAM,wBAAwB,CACnC,oBACA,aACY;AACZ,QAAM,MAAM,sBAA+B,oBAAoB,QAAQ;AAGvE,SAAO,mBAAmB,GAAG;AAC/B;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { EnumerationContent, QuantityContent, enu } from './enumeration.mjs';
|
|
1
|
+
export { EnterFormat, EnumerationContent, QuantityContent, enu } from './enumeration.mjs';
|
|
2
2
|
export { getEnumerationContent } from './getEnumerationContent.mjs';
|
|
3
|
-
|
|
3
|
+
export { findMatchingCondition } from './findMatchingCondition.mjs';
|
|
4
4
|
import '../../../types/nodeType.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/index.ts"],"sourcesContent":["export * from './enumeration';\nexport * from './getEnumerationContent';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/index.ts"],"sourcesContent":["export * from './enumeration';\nexport * from './getEnumerationContent';\nexport * from './findMatchingCondition';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { t } from './translation/translation.mjs';
|
|
2
2
|
export { getTranslationContent } from './translation/getTranslationContent.mjs';
|
|
3
|
-
export {
|
|
4
|
-
export { EnumerationContent, QuantityContent, enu } from './enumeration/enumeration.mjs';
|
|
3
|
+
export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './translation/types.mjs';
|
|
4
|
+
export { EnterFormat, EnumerationContent, QuantityContent, enu } from './enumeration/enumeration.mjs';
|
|
5
5
|
export { getEnumerationContent } from './enumeration/getEnumerationContent.mjs';
|
|
6
|
+
export { findMatchingCondition } from './enumeration/findMatchingCondition.mjs';
|
|
6
7
|
import '@intlayer/config/client';
|
|
7
8
|
import 'intlayer';
|
|
8
|
-
import '../../utils/getStackTraceInfo.mjs';
|
|
9
9
|
import '../../types/nodeType.mjs';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Locales } from '@intlayer/config/client';
|
|
2
2
|
import { CustomizableLanguageContent } from './types.mjs';
|
|
3
3
|
import 'intlayer';
|
|
4
|
-
import '../../../utils/getStackTraceInfo.mjs';
|
|
5
4
|
import '../../../types/nodeType.mjs';
|
|
6
5
|
|
|
7
6
|
type GetTranslationContent = <Content = string>(languageContent: CustomizableLanguageContent<Content>, locale: Locales) => Content;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { t } from './translation.mjs';
|
|
2
2
|
export { getTranslationContent } from './getTranslationContent.mjs';
|
|
3
|
-
export {
|
|
3
|
+
export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './types.mjs';
|
|
4
4
|
import '@intlayer/config/client';
|
|
5
5
|
import 'intlayer';
|
|
6
|
-
import '../../../utils/getStackTraceInfo.mjs';
|
|
7
6
|
import '../../../types/nodeType.mjs';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TranslationContent } from './types.mjs';
|
|
2
2
|
import '@intlayer/config/client';
|
|
3
3
|
import 'intlayer';
|
|
4
|
-
import '../../../utils/getStackTraceInfo.mjs';
|
|
5
4
|
import '../../../types/nodeType.mjs';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -24,6 +23,6 @@ import '../../../types/nodeType.mjs';
|
|
|
24
23
|
* - this function require each locale to be defined if defined in the project configuration.
|
|
25
24
|
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
26
25
|
*/
|
|
27
|
-
declare const translation: <Content = string>(content?:
|
|
26
|
+
declare const translation: <Content = string>(content?: any) => TranslationContent<Content>;
|
|
28
27
|
|
|
29
28
|
export { translation as t };
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { getConfiguration } from "@intlayer/config/client";
|
|
2
2
|
import { NodeType } from '../../../types/index.mjs';
|
|
3
|
-
import { getStackTraceInfo } from '../../../utils/getStackTraceInfo.mjs';
|
|
4
3
|
const translation = (content) => {
|
|
5
4
|
const {
|
|
6
5
|
internationalization: { defaultLocale }
|
|
7
6
|
} = getConfiguration();
|
|
8
|
-
const stackTraceInfo = getStackTraceInfo();
|
|
9
7
|
if (typeof content === "string") {
|
|
10
8
|
const result2 = {
|
|
11
9
|
nodeType: NodeType.Translation,
|
|
12
|
-
...stackTraceInfo,
|
|
13
10
|
[defaultLocale]: content
|
|
14
11
|
};
|
|
15
12
|
return result2;
|
|
16
13
|
}
|
|
17
14
|
const result = {
|
|
18
15
|
nodeType: NodeType.Translation,
|
|
19
|
-
...stackTraceInfo,
|
|
20
16
|
...content
|
|
21
17
|
};
|
|
22
18
|
return result;
|
|
@@ -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
|
|
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,6 +1,5 @@
|
|
|
1
1
|
import { LocalesValues } from '@intlayer/config/client';
|
|
2
2
|
import { IConfigLocales } from 'intlayer';
|
|
3
|
-
import { NoteStackTraceInfo } from '../../../utils/getStackTraceInfo.mjs';
|
|
4
3
|
import { NodeType } from '../../../types/nodeType.mjs';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -27,7 +26,6 @@ type CustomLocales = ConfigLocales extends never ? LocalesValues : ConfigLocales
|
|
|
27
26
|
* }
|
|
28
27
|
*/
|
|
29
28
|
type LanguageContent<Content> = Partial<Record<LocalesValues, Content>>;
|
|
30
|
-
type ConfigLanguageContent<Content> = Record<ConfigLocales, Content>;
|
|
31
29
|
/**
|
|
32
30
|
* Valid
|
|
33
31
|
* const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {
|
|
@@ -55,9 +53,9 @@ type ConfigLanguageContent<Content> = Record<ConfigLocales, Content>;
|
|
|
55
53
|
* }
|
|
56
54
|
*
|
|
57
55
|
*/
|
|
58
|
-
type CustomizableLanguageContent<Content = string> = ConfigLocales extends never ? LanguageContent<Content> :
|
|
59
|
-
type TranslationContent<Content> = LanguageContent<Content> &
|
|
56
|
+
type CustomizableLanguageContent<Content = string> = ConfigLocales extends never ? LanguageContent<Content> : IConfigLocales<Content>;
|
|
57
|
+
type TranslationContent<Content> = LanguageContent<Content> & {
|
|
60
58
|
nodeType: NodeType.Translation;
|
|
61
59
|
};
|
|
62
60
|
|
|
63
|
-
export type {
|
|
61
|
+
export type { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { t } from './content_transformers/translation/translation.mjs';
|
|
2
2
|
export { getTranslationContent } from './content_transformers/translation/getTranslationContent.mjs';
|
|
3
|
-
export {
|
|
4
|
-
export { EnumerationContent, QuantityContent, enu } from './content_transformers/enumeration/enumeration.mjs';
|
|
3
|
+
export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './content_transformers/translation/types.mjs';
|
|
4
|
+
export { EnterFormat, EnumerationContent, QuantityContent, enu } from './content_transformers/enumeration/enumeration.mjs';
|
|
5
5
|
export { getEnumerationContent } from './content_transformers/enumeration/getEnumerationContent.mjs';
|
|
6
|
+
export { findMatchingCondition } from './content_transformers/enumeration/findMatchingCondition.mjs';
|
|
6
7
|
import '@intlayer/config/client';
|
|
7
8
|
import 'intlayer';
|
|
8
|
-
import '../utils/getStackTraceInfo.mjs';
|
|
9
9
|
import '../types/nodeType.mjs';
|
|
@@ -0,0 +1,27 @@
|
|
|
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 ArrayOfSameType<T> = T extends (infer U)[] ? U extends T[number] ? T : never : never;
|
|
10
|
+
type ContentValueArray = ArrayOfSameType<ContentValue[]>;
|
|
11
|
+
type ContentValue = string | {
|
|
12
|
+
[key: string]: ContentValue;
|
|
13
|
+
} | (() => ContentValue) | Promise<ContentValue> | TypedNode;
|
|
14
|
+
type Content = Record<string, ContentValue | ContentValueArray | undefined>;
|
|
15
|
+
type FlatContentValue = string | {
|
|
16
|
+
[key: string]: FlatContentValue;
|
|
17
|
+
} | TypedNode;
|
|
18
|
+
type FlatContent = Record<string, FlatContentValue | undefined>;
|
|
19
|
+
type ReplaceContentValue<T> = {
|
|
20
|
+
[P in keyof T]: T[P] extends string | number | boolean | null | ReactNode ? ContentValue : T[P] extends object ? ReplaceContentValue<T[P]> : T[P];
|
|
21
|
+
};
|
|
22
|
+
type DeclarationContent<T = undefined> = (T extends undefined ? Content : ReplaceContentValue<T>) & {
|
|
23
|
+
id: string;
|
|
24
|
+
filePath?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type { Content, ContentValue, ContentValueArray, 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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export { Content,
|
|
1
|
+
export { Content, ContentValue, ContentValueArray, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './declarationContent.mjs';
|
|
2
2
|
export { NodeType } from './nodeType.mjs';
|
|
3
|
+
export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './keyPath.mjs';
|
|
4
|
+
export { Dictionary, DictionaryValue } from './dictionary.mjs';
|
|
5
|
+
import 'react';
|
|
3
6
|
import '../transpiler/content_transformers/translation/types.mjs';
|
|
4
7
|
import '@intlayer/config/client';
|
|
5
8
|
import 'intlayer';
|
|
6
|
-
import '../utils/getStackTraceInfo.mjs';
|
|
7
9
|
import '../transpiler/content_transformers/enumeration/enumeration.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["export type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["export type {\n ContentValue,\n ContentValueArray,\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":"AASA,SAAS,gBAAgB;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NodeType } from './nodeType.mjs';
|
|
2
|
+
|
|
3
|
+
type ObjectExpressionNode = {
|
|
4
|
+
type: 'ObjectExpression';
|
|
5
|
+
key: string;
|
|
6
|
+
};
|
|
7
|
+
type ArrayExpressionNode = {
|
|
8
|
+
type: 'ArrayExpression';
|
|
9
|
+
key: number;
|
|
10
|
+
};
|
|
11
|
+
type TranslationOrEnumerationNode = {
|
|
12
|
+
type: NodeType;
|
|
13
|
+
key: string;
|
|
14
|
+
};
|
|
15
|
+
type KeyPath = ObjectExpressionNode | ArrayExpressionNode | TranslationOrEnumerationNode;
|
|
16
|
+
|
|
17
|
+
export type { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=keyPath.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -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":"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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "IntLayer - Layer of abstraction between the business logic and the data access layer. Manage internationalization in a simple way, through TypeScript, JavaScript or JSON declaration file.",
|
|
6
6
|
"keywords": [
|
|
@@ -46,12 +46,11 @@
|
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"./dist",
|
|
49
|
-
"./src",
|
|
50
49
|
"./package.json"
|
|
51
50
|
],
|
|
52
51
|
"dependencies": {
|
|
53
52
|
"chokidar": "^3.6.0",
|
|
54
|
-
"@intlayer/config": "^
|
|
53
|
+
"@intlayer/config": "^2.0.1"
|
|
55
54
|
},
|
|
56
55
|
"devDependencies": {
|
|
57
56
|
"@types/node": "^20.12.7",
|
|
@@ -64,7 +63,6 @@
|
|
|
64
63
|
"@utils/ts-config": "^1.0.1"
|
|
65
64
|
},
|
|
66
65
|
"peerDependencies": {
|
|
67
|
-
"@types/react": "^18.2.78",
|
|
68
66
|
"react": "^18.2.0"
|
|
69
67
|
},
|
|
70
68
|
"engines": {
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export {
|
|
|
10
10
|
t,
|
|
11
11
|
enu,
|
|
12
12
|
getTranslationContent,
|
|
13
|
+
findMatchingCondition,
|
|
13
14
|
getEnumerationContent,
|
|
14
15
|
} from './transpiler/content_transformers/index';
|
|
15
16
|
export type {
|
|
@@ -18,8 +19,16 @@ export type {
|
|
|
18
19
|
FlatContentValue,
|
|
19
20
|
FlatContent,
|
|
20
21
|
TypedNode,
|
|
21
|
-
|
|
22
|
+
DeclarationContent,
|
|
23
|
+
ContentValueArray,
|
|
24
|
+
KeyPath,
|
|
25
|
+
ObjectExpressionNode,
|
|
26
|
+
ArrayExpressionNode,
|
|
27
|
+
TranslationOrEnumerationNode,
|
|
28
|
+
DictionaryValue,
|
|
29
|
+
Dictionary,
|
|
22
30
|
} from './types/index';
|
|
23
31
|
export { NodeType } from './types/index';
|
|
24
32
|
export { getLocaleName } from './getLocaleName';
|
|
25
33
|
export { localeList } from './localeList';
|
|
34
|
+
export { isSameKeyPath } from './utils/isSameKeyPath';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/contentModule.ts"],"sourcesContent":["import 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 | {\n [key: string]: ContentValue;\n }\n | (() => ContentValue)\n | Promise<ContentValue>\n | TypedNode;\n\nexport type Content = Record<string, 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\nexport type ContentModule = Content & {\n id: string;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { TranslationContent } from '../transpiler/content_transformers/translation/types.js';
|
|
2
|
-
import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.js';
|
|
3
|
-
import './nodeType.js';
|
|
4
|
-
import '@intlayer/config/client';
|
|
5
|
-
import 'intlayer';
|
|
6
|
-
import '../utils/getStackTraceInfo.js';
|
|
7
|
-
|
|
8
|
-
type TypedNode = TranslationContent<unknown> | EnumerationContent<unknown>;
|
|
9
|
-
type ContentValue = string | {
|
|
10
|
-
[key: string]: ContentValue;
|
|
11
|
-
} | (() => ContentValue) | Promise<ContentValue> | TypedNode;
|
|
12
|
-
type Content = Record<string, ContentValue | undefined>;
|
|
13
|
-
type FlatContentValue = string | {
|
|
14
|
-
[key: string]: FlatContentValue;
|
|
15
|
-
} | TypedNode;
|
|
16
|
-
type FlatContent = Record<string, FlatContentValue | undefined>;
|
|
17
|
-
type ContentModule = Content & {
|
|
18
|
-
id: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type { Content, ContentModule, ContentValue, FlatContent, FlatContentValue, TypedNode };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/getStackTraceInfo.ts"],"sourcesContent":["export type NoteStackTraceInfo = {\n file?: string;\n line?: string;\n column?: string;\n};\n\n/**\n * Get the file path, line number, and column number of the caller of this function\n * Return an object containing file, line, and column numbers\n */\nexport const getStackTraceInfo = (): NoteStackTraceInfo => {\n // Create a new Error object to capture the stack trace\n const err = new Error();\n const stack = err.stack ?? '';\n\n // Split the stack trace into lines and find the line where this function was called\n // Adjust the line index as necessary based on how your environment's stack trace format\n const stackLines = stack.split('\\n');\n const callerLine = stackLines[2] ?? ''; // Adjust the index 2 if needed\n\n // Extract file path, line number, and column number using a regular expression\n // This regex pattern might need adjustments based on your environment\n const match = callerLine.match(/at\\s[^(:]+\\([^:]+:(\\d+):(\\d+)\\)?/);\n\n // const file = match?.[1];\n const line = match?.[1];\n const column = match?.[2];\n\n if (match) {\n return {\n // file,\n line,\n column,\n };\n }\n\n // Return empty object if parsing fails\n return {};\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,oBAAoB,MAA0B;AAEzD,QAAM,MAAM,IAAI,MAAM;AACtB,QAAM,QAAQ,IAAI,SAAS;AAI3B,QAAM,aAAa,MAAM,MAAM,IAAI;AACnC,QAAM,aAAa,WAAW,CAAC,KAAK;AAIpC,QAAM,QAAQ,WAAW,MAAM,kCAAkC;AAGjE,QAAM,OAAO,QAAQ,CAAC;AACtB,QAAM,SAAS,QAAQ,CAAC;AAExB,MAAI,OAAO;AACT,WAAO;AAAA;AAAA,MAEL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,SAAO,CAAC;AACV;","names":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type NoteStackTraceInfo = {
|
|
2
|
-
file?: string;
|
|
3
|
-
line?: string;
|
|
4
|
-
column?: string;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Get the file path, line number, and column number of the caller of this function
|
|
8
|
-
* Return an object containing file, line, and column numbers
|
|
9
|
-
*/
|
|
10
|
-
declare const getStackTraceInfo: () => NoteStackTraceInfo;
|
|
11
|
-
|
|
12
|
-
export { type NoteStackTraceInfo, getStackTraceInfo };
|