@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
package/dist/cjs/index.cjs
CHANGED
|
@@ -20,9 +20,11 @@ var src_exports = {};
|
|
|
20
20
|
__export(src_exports, {
|
|
21
21
|
NodeType: () => import_types.NodeType,
|
|
22
22
|
enu: () => import_content_transformers.enu,
|
|
23
|
+
findMatchingCondition: () => import_content_transformers.findMatchingCondition,
|
|
23
24
|
getEnumerationContent: () => import_content_transformers.getEnumerationContent,
|
|
24
25
|
getLocaleName: () => import_getLocaleName.getLocaleName,
|
|
25
26
|
getTranslationContent: () => import_content_transformers.getTranslationContent,
|
|
27
|
+
isSameKeyPath: () => import_isSameKeyPath.isSameKeyPath,
|
|
26
28
|
localeList: () => import_localeList.localeList,
|
|
27
29
|
t: () => import_content_transformers.t
|
|
28
30
|
});
|
|
@@ -31,13 +33,16 @@ var import_content_transformers = require('./transpiler/content_transformers/ind
|
|
|
31
33
|
var import_types = require('./types/index.cjs');
|
|
32
34
|
var import_getLocaleName = require('./getLocaleName.cjs');
|
|
33
35
|
var import_localeList = require('./localeList.cjs');
|
|
36
|
+
var import_isSameKeyPath = require('./utils/isSameKeyPath.cjs');
|
|
34
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
38
|
0 && (module.exports = {
|
|
36
39
|
NodeType,
|
|
37
40
|
enu,
|
|
41
|
+
findMatchingCondition,
|
|
38
42
|
getEnumerationContent,
|
|
39
43
|
getLocaleName,
|
|
40
44
|
getTranslationContent,
|
|
45
|
+
isSameKeyPath,
|
|
41
46
|
localeList,
|
|
42
47
|
t
|
|
43
48
|
});
|
package/dist/cjs/index.cjs.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,kCAMO;AAgBP,mBAAyB;AACzB,2BAA8B;AAC9B,wBAA2B;AAC3B,2BAA8B;","names":[]}
|
package/dist/cjs/index.d.ts
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.js';
|
|
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
|
-
export {
|
|
6
|
+
export { findMatchingCondition } from './transpiler/content_transformers/enumeration/findMatchingCondition.js';
|
|
7
|
+
export { Content, ContentValue, ContentValueArray, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './types/declarationContent.js';
|
|
7
8
|
export { NodeType } from './types/nodeType.js';
|
|
9
|
+
export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './types/keyPath.js';
|
|
10
|
+
export { Dictionary, DictionaryValue } from './types/dictionary.js';
|
|
8
11
|
export { getLocaleName } from './getLocaleName.js';
|
|
9
12
|
export { localeList } from './localeList.js';
|
|
13
|
+
export { isSameKeyPath } from './utils/isSameKeyPath.js';
|
|
10
14
|
import '@intlayer/config/client';
|
|
11
15
|
import 'intlayer';
|
|
12
|
-
import '
|
|
16
|
+
import 'react';
|
|
@@ -22,20 +22,16 @@ __export(enumeration_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(enumeration_exports);
|
|
24
24
|
var import_types = require('../../../types/index.cjs');
|
|
25
|
-
var import_getStackTraceInfo = require('../../../utils/getStackTraceInfo.cjs');
|
|
26
25
|
const enumeration = (content) => {
|
|
27
|
-
const stackTraceInfo = (0, import_getStackTraceInfo.getStackTraceInfo)();
|
|
28
26
|
if (typeof content === "string") {
|
|
29
27
|
const result2 = {
|
|
30
28
|
nodeType: import_types.NodeType.Enumeration,
|
|
31
|
-
...stackTraceInfo,
|
|
32
29
|
1: content
|
|
33
30
|
};
|
|
34
31
|
return result2;
|
|
35
32
|
}
|
|
36
33
|
const result = {
|
|
37
34
|
nodeType: import_types.NodeType.Enumeration,
|
|
38
|
-
...stackTraceInfo,
|
|
39
35
|
...content
|
|
40
36
|
};
|
|
41
37
|
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":";;;;;;;;;;;;;;;;;;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,4 +1,3 @@
|
|
|
1
|
-
import { NoteStackTraceInfo } from '../../../utils/getStackTraceInfo.js';
|
|
2
1
|
import { NodeType } from '../../../types/nodeType.js';
|
|
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 };
|
|
@@ -0,0 +1,42 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var findMatchingCondition_exports = {};
|
|
20
|
+
__export(findMatchingCondition_exports, {
|
|
21
|
+
findMatchingCondition: () => findMatchingCondition
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(findMatchingCondition_exports);
|
|
24
|
+
const findMatchingCondition = (enumerationContent, quantity) => {
|
|
25
|
+
const numericKeys = Object.keys(enumerationContent);
|
|
26
|
+
for (const key of numericKeys) {
|
|
27
|
+
const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity;
|
|
28
|
+
const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1));
|
|
29
|
+
const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
|
|
30
|
+
const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1));
|
|
31
|
+
const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
|
|
32
|
+
if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) {
|
|
33
|
+
return key;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return "1";
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
findMatchingCondition
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=findMatchingCondition.cjs.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { QuantityContent, EnterFormat } from './enumeration.js';
|
|
2
|
+
import '../../../types/nodeType.js';
|
|
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 };
|
|
@@ -21,19 +21,10 @@ __export(getEnumerationContent_exports, {
|
|
|
21
21
|
getEnumerationContent: () => getEnumerationContent
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(getEnumerationContent_exports);
|
|
24
|
+
var import__ = require('../../index.cjs');
|
|
24
25
|
const getEnumerationContent = (enumerationContent, quantity) => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity;
|
|
28
|
-
const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1));
|
|
29
|
-
const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
|
|
30
|
-
const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1));
|
|
31
|
-
const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
|
|
32
|
-
if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) {
|
|
33
|
-
return enumerationContent[key];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return enumerationContent["1"];
|
|
26
|
+
const key = (0, import__.findMatchingCondition)(enumerationContent, quantity);
|
|
27
|
+
return enumerationContent[key];
|
|
37
28
|
};
|
|
38
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
30
|
0 && (module.exports = {
|
|
@@ -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;AAAA;AAAA;AAAA;AAAA;AAAA,eAAsC;AA6B/B,MAAM,wBAAwB,CACnC,oBACA,aACY;AACZ,QAAM,UAAM,gCAA+B,oBAAoB,QAAQ;AAGvE,SAAO,mBAAmB,GAAG;AAC/B;","names":[]}
|
|
@@ -17,9 +17,11 @@ var enumeration_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(enumeration_exports);
|
|
18
18
|
__reExport(enumeration_exports, require('./enumeration.cjs'), module.exports);
|
|
19
19
|
__reExport(enumeration_exports, require('./getEnumerationContent.cjs'), module.exports);
|
|
20
|
+
__reExport(enumeration_exports, require('./findMatchingCondition.cjs'), module.exports);
|
|
20
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
22
|
0 && (module.exports = {
|
|
22
23
|
...require('./enumeration.cjs'),
|
|
23
|
-
...require('./getEnumerationContent.cjs')
|
|
24
|
+
...require('./getEnumerationContent.cjs'),
|
|
25
|
+
...require('./findMatchingCondition.cjs')
|
|
24
26
|
});
|
|
25
27
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/enumeration/index.ts"],"sourcesContent":["export * from './enumeration';\nexport * from './getEnumerationContent';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,0BAAd;AACA,gCAAc,oCADd;","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;AAAA;AAAA,gCAAc,0BAAd;AACA,gCAAc,oCADd;AAEA,gCAAc,oCAFd;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { EnumerationContent, QuantityContent, enu } from './enumeration.js';
|
|
1
|
+
export { EnterFormat, EnumerationContent, QuantityContent, enu } from './enumeration.js';
|
|
2
2
|
export { getEnumerationContent } from './getEnumerationContent.js';
|
|
3
|
-
|
|
3
|
+
export { findMatchingCondition } from './findMatchingCondition.js';
|
|
4
4
|
import '../../../types/nodeType.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { t } from './translation/translation.js';
|
|
2
2
|
export { getTranslationContent } from './translation/getTranslationContent.js';
|
|
3
|
-
export {
|
|
4
|
-
export { EnumerationContent, QuantityContent, enu } from './enumeration/enumeration.js';
|
|
3
|
+
export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './translation/types.js';
|
|
4
|
+
export { EnterFormat, EnumerationContent, QuantityContent, enu } from './enumeration/enumeration.js';
|
|
5
5
|
export { getEnumerationContent } from './enumeration/getEnumerationContent.js';
|
|
6
|
+
export { findMatchingCondition } from './enumeration/findMatchingCondition.js';
|
|
6
7
|
import '@intlayer/config/client';
|
|
7
8
|
import 'intlayer';
|
|
8
|
-
import '../../utils/getStackTraceInfo.js';
|
|
9
9
|
import '../../types/nodeType.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Locales } from '@intlayer/config/client';
|
|
2
2
|
import { CustomizableLanguageContent } from './types.js';
|
|
3
3
|
import 'intlayer';
|
|
4
|
-
import '../../../utils/getStackTraceInfo.js';
|
|
5
4
|
import '../../../types/nodeType.js';
|
|
6
5
|
|
|
7
6
|
type GetTranslationContent = <Content = string>(languageContent: CustomizableLanguageContent<Content>, locale: Locales) => Content;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { t } from './translation.js';
|
|
2
2
|
export { getTranslationContent } from './getTranslationContent.js';
|
|
3
|
-
export {
|
|
3
|
+
export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './types.js';
|
|
4
4
|
import '@intlayer/config/client';
|
|
5
5
|
import 'intlayer';
|
|
6
|
-
import '../../../utils/getStackTraceInfo.js';
|
|
7
6
|
import '../../../types/nodeType.js';
|
|
@@ -23,23 +23,19 @@ __export(translation_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(translation_exports);
|
|
24
24
|
var import_client = require("@intlayer/config/client");
|
|
25
25
|
var import_types = require('../../../types/index.cjs');
|
|
26
|
-
var import_getStackTraceInfo = require('../../../utils/getStackTraceInfo.cjs');
|
|
27
26
|
const translation = (content) => {
|
|
28
27
|
const {
|
|
29
28
|
internationalization: { defaultLocale }
|
|
30
29
|
} = (0, import_client.getConfiguration)();
|
|
31
|
-
const stackTraceInfo = (0, import_getStackTraceInfo.getStackTraceInfo)();
|
|
32
30
|
if (typeof content === "string") {
|
|
33
31
|
const result2 = {
|
|
34
32
|
nodeType: import_types.NodeType.Translation,
|
|
35
|
-
...stackTraceInfo,
|
|
36
33
|
[defaultLocale]: content
|
|
37
34
|
};
|
|
38
35
|
return result2;
|
|
39
36
|
}
|
|
40
37
|
const result = {
|
|
41
38
|
nodeType: import_types.NodeType.Translation,
|
|
42
|
-
...stackTraceInfo,
|
|
43
39
|
...content
|
|
44
40
|
};
|
|
45
41
|
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;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,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TranslationContent } from './types.js';
|
|
2
2
|
import '@intlayer/config/client';
|
|
3
3
|
import 'intlayer';
|
|
4
|
-
import '../../../utils/getStackTraceInfo.js';
|
|
5
4
|
import '../../../types/nodeType.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -24,6 +23,6 @@ import '../../../types/nodeType.js';
|
|
|
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 +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';\
|
|
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> = LanguageContent<Content> & {\n nodeType: NodeType.Translation;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LocalesValues } from '@intlayer/config/client';
|
|
2
2
|
import { IConfigLocales } from 'intlayer';
|
|
3
|
-
import { NoteStackTraceInfo } from '../../../utils/getStackTraceInfo.js';
|
|
4
3
|
import { NodeType } from '../../../types/nodeType.js';
|
|
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.js';
|
|
2
2
|
export { getTranslationContent } from './content_transformers/translation/getTranslationContent.js';
|
|
3
|
-
export {
|
|
4
|
-
export { EnumerationContent, QuantityContent, enu } from './content_transformers/enumeration/enumeration.js';
|
|
3
|
+
export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './content_transformers/translation/types.js';
|
|
4
|
+
export { EnterFormat, EnumerationContent, QuantityContent, enu } from './content_transformers/enumeration/enumeration.js';
|
|
5
5
|
export { getEnumerationContent } from './content_transformers/enumeration/getEnumerationContent.js';
|
|
6
|
+
export { findMatchingCondition } from './content_transformers/enumeration/findMatchingCondition.js';
|
|
6
7
|
import '@intlayer/config/client';
|
|
7
8
|
import 'intlayer';
|
|
8
|
-
import '../utils/getStackTraceInfo.js';
|
|
9
9
|
import '../types/nodeType.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\ntype ArrayOfSameType<T> = T extends (infer U)[]\n ? U extends T[number]\n ? T\n : never\n : never;\n\nexport type ContentValueArray = ArrayOfSameType<ContentValue[]>;\n\nexport type ContentValue =\n | string\n | {\n [key: string]: ContentValue;\n }\n | (() => ContentValue)\n | Promise<ContentValue>\n | TypedNode;\n\nexport type Content = Record<\n string,\n ContentValue | ContentValueArray | undefined\n>;\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 : T[P];\n};\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,27 @@
|
|
|
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 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 };
|
|
@@ -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
|
|
16
|
-
module.exports = __toCommonJS(
|
|
17
|
-
//# sourceMappingURL=
|
|
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
|
|
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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,sBAAyB;","names":[]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export { Content,
|
|
1
|
+
export { Content, ContentValue, ContentValueArray, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './declarationContent.js';
|
|
2
2
|
export { NodeType } from './nodeType.js';
|
|
3
|
+
export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './keyPath.js';
|
|
4
|
+
export { Dictionary, DictionaryValue } from './dictionary.js';
|
|
5
|
+
import 'react';
|
|
3
6
|
import '../transpiler/content_transformers/translation/types.js';
|
|
4
7
|
import '@intlayer/config/client';
|
|
5
8
|
import 'intlayer';
|
|
6
|
-
import '../utils/getStackTraceInfo.js';
|
|
7
9
|
import '../transpiler/content_transformers/enumeration/enumeration.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 keyPath_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(keyPath_exports);
|
|
17
|
+
//# sourceMappingURL=keyPath.cjs.map
|
|
@@ -0,0 +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 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":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NodeType } from './nodeType.js';
|
|
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 };
|
|
@@ -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
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var isSameKeyPath_exports = {};
|
|
20
|
+
__export(isSameKeyPath_exports, {
|
|
21
|
+
isSameKeyPath: () => isSameKeyPath
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
29
|
+
isSameKeyPath
|
|
44
30
|
});
|
|
45
|
-
//# sourceMappingURL=
|
|
31
|
+
//# sourceMappingURL=isSameKeyPath.cjs.map
|