intlayer-editor 8.12.1 → 8.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{CodeBlockClient-DPTR7zkl.js → CodeBlockClient-BQMC5gqu.js} +3 -3
- package/client/dist/assets/{CodeBlockShiki-D1gLOqNZ.js → CodeBlockShiki-DB7ndrOR.js} +2 -2
- package/client/dist/assets/{MarkDownRender-Dieny2mT.js → MarkDownRender-BQwPctN-.js} +3 -3
- package/client/dist/assets/{bundle-web-C6qOstkL.js → bundle-web-C4HpQhJS.js} +1 -1
- package/client/dist/assets/{dist-Uia0doeb.js → dist-GH_AdANR.js} +1 -1
- package/client/dist/assets/index-DIJj_-IN.css +2 -0
- package/client/dist/assets/index-DJVEpj0g.js +189 -0
- package/client/dist/assets/purify.es-6-uFcs4-.js +3 -0
- package/client/dist/index.html +2 -2
- package/package.json +18 -18
- package/server/dist/@intlayer/chokidar/dist/types/build.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/cleanOutputDir.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createType/createModuleAugmentation.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/createType/createType.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/formatDictionary.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/intlayer/dist/types/index.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadContentDeclaration.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadDictionaries.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/prepareIntlayer.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeConfiguration/index.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +6 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/transformJSFile.d.ts +1 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +2 -0
- package/server/dist/@intlayer/chokidar/dist/types/writeContentDeclaration/writeJSFile.d.ts +2 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/ICU.d.ts +1 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/i18next.d.ts +1 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/index.d.ts +1 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/po.d.ts +1 -0
- package/server/dist/@intlayer/core/dist/types/messageFormat/vue-i18n.d.ts +1 -0
- package/server/dist/controllers/configuration.controller.cjs +1 -0
- package/server/dist/controllers/configuration.controller.cjs.map +1 -1
- package/server/dist/controllers/configuration.controller.mjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.cjs +1 -0
- package/server/dist/controllers/dictionary.controller.cjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.mjs.map +1 -1
- package/server/dist/index.cjs.map +1 -1
- package/server/dist/index.mjs.map +1 -1
- package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.cjs +32 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.mjs +31 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/detectFormatCommand.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +82 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +81 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.cjs +26 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs +25 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/getFormatFromExtension.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.cjs +24 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs +23 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/utils/readDictionariesFromDisk.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.cjs +94 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +92 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.cjs +416 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.mjs +412 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.cjs +127 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs +125 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.cjs +164 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +163 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.cjs +92 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs +91 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.cjs +65 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +64 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.cjs +43 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.cjs.map +1 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs +42 -0
- package/server/dist/packages/@intlayer/chokidar/dist/esm/writeContentDeclaration/writeYamlFile.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.cjs +45 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +43 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.cjs +32 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +32 -0
- package/server/dist/packages/@intlayer/core/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.cjs +56 -0
- package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs +54 -0
- package/server/dist/packages/@intlayer/core/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.cjs +27 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.mjs +26 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getCondition.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.cjs +58 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs +56 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.cjs +160 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs +158 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getContent/plugins.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.cjs +71 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.mjs +70 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getEnumeration.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.cjs +38 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.mjs +37 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getGender.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.cjs +22 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.mjs +21 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getInsertion.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.cjs +87 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.mjs +86 -0
- package/server/dist/packages/@intlayer/core/dist/esm/interpreter/getTranslation.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.cjs +14 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.mjs +13 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/isValidReactElement.mjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.cjs +58 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.cjs.map +1 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.mjs +57 -0
- package/server/dist/packages/@intlayer/core/dist/esm/utils/stringifyYaml.mjs.map +1 -0
- package/server/dist/routes/config.routes.cjs +1 -0
- package/server/dist/routes/config.routes.cjs.map +1 -1
- package/server/dist/routes/config.routes.mjs.map +1 -1
- package/server/dist/routes/dictionary.routes.cjs +1 -0
- package/server/dist/routes/dictionary.routes.cjs.map +1 -1
- package/server/dist/routes/dictionary.routes.mjs.map +1 -1
- package/server/dist/utils/checkPortAvailability.cjs.map +1 -1
- package/server/dist/utils/checkPortAvailability.mjs.map +1 -1
- package/server/dist/utils/httpStatusCodes.cjs.map +1 -1
- package/server/dist/utils/httpStatusCodes.mjs.map +1 -1
- package/server/dist/utils/responseData.cjs.map +1 -1
- package/server/dist/utils/responseData.mjs.map +1 -1
- package/client/dist/assets/index-CTSrsWZb.css +0 -2
- package/client/dist/assets/index-sNIxTlYK.js +0 -185
- package/client/dist/assets/purify.es-Dt2VzQ8a.js +0 -3
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../@intlayer/core/dist/esm/interpreter/getEnumeration.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Find the matching condition for a quantity.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const key = findMatchingCondition({
|
|
10
|
+
* '<=-2.3': 'You have less than -2.3',
|
|
11
|
+
* '<1': 'You have less than one',
|
|
12
|
+
* '2': 'You have two',
|
|
13
|
+
* '>=3': 'You have three or more',
|
|
14
|
+
* }, 2);
|
|
15
|
+
* // '2'
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The order of the keys will define the priority of the content.
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const key = findMatchingCondition({
|
|
22
|
+
* '<4': 'You have less than four',
|
|
23
|
+
* '2': 'You have two',
|
|
24
|
+
* }, 2);
|
|
25
|
+
* // '<4'
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* If no keys match, the default key is '1'.
|
|
29
|
+
*/
|
|
30
|
+
const findMatchingCondition = (enumerationContent, quantity) => {
|
|
31
|
+
const numericKeys = Object.keys(enumerationContent);
|
|
32
|
+
for (const key of numericKeys) {
|
|
33
|
+
const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity;
|
|
34
|
+
const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1));
|
|
35
|
+
const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
|
|
36
|
+
const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1));
|
|
37
|
+
const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
|
|
38
|
+
if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) return key;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Picks content from an enumeration map based on a provided quantity.
|
|
43
|
+
*
|
|
44
|
+
* Supported keys in the enumeration map:
|
|
45
|
+
* - Specific numbers: '0', '1', '2'
|
|
46
|
+
* - Comparison operators: '<5', '>=10', '<=2'
|
|
47
|
+
* - Fallback: 'fallback'
|
|
48
|
+
*
|
|
49
|
+
* The first matching key in the object's iteration order will be selected.
|
|
50
|
+
*
|
|
51
|
+
* @param enumerationContent - A map of conditions/quantities to content.
|
|
52
|
+
* @param quantity - The number to match against the conditions.
|
|
53
|
+
* @returns The matching content.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const content = getEnumeration({
|
|
58
|
+
* '0': 'No items',
|
|
59
|
+
* '1': 'One item',
|
|
60
|
+
* '>1': 'Many items',
|
|
61
|
+
* }, 5);
|
|
62
|
+
* // 'Many items'
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
const getEnumeration = (enumerationContent, quantity) => {
|
|
66
|
+
return enumerationContent[findMatchingCondition(enumerationContent, quantity) ?? "fallback"];
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.getEnumeration = getEnumeration;
|
|
71
|
+
//# sourceMappingURL=getEnumeration.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEnumeration.cjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getEnumeration.mjs"],"sourcesContent":["//#region src/interpreter/getEnumeration.ts\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*/\nconst findMatchingCondition = (enumerationContent, quantity) => {\n\tconst numericKeys = Object.keys(enumerationContent);\n\tfor (const key of numericKeys) {\n\t\tconst isEqual = !key.startsWith(\">\") && !key.startsWith(\"<\") && !key.startsWith(\"=\") && parseFloat(key) === quantity || key.startsWith(\"=\") && parseFloat(key.slice(1)) === quantity;\n\t\tconst isSuperior = key.startsWith(\">\") && quantity > parseFloat(key.slice(1));\n\t\tconst isSuperiorOrEqual = key.startsWith(\">=\") && quantity >= parseFloat(key.slice(2));\n\t\tconst isInferior = key.startsWith(\"<\") && quantity < parseFloat(key.slice(1));\n\t\tconst isInferiorOrEqual = key.startsWith(\"<=\") && quantity <= parseFloat(key.slice(2));\n\t\tif (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) return key;\n\t}\n};\n/**\n* Picks content from an enumeration map based on a provided quantity.\n*\n* Supported keys in the enumeration map:\n* - Specific numbers: '0', '1', '2'\n* - Comparison operators: '<5', '>=10', '<=2'\n* - Fallback: 'fallback'\n*\n* The first matching key in the object's iteration order will be selected.\n*\n* @param enumerationContent - A map of conditions/quantities to content.\n* @param quantity - The number to match against the conditions.\n* @returns The matching content.\n*\n* @example\n* ```ts\n* const content = getEnumeration({\n* '0': 'No items',\n* '1': 'One item',\n* '>1': 'Many items',\n* }, 5);\n* // 'Many items'\n* ```\n*/\nconst getEnumeration = (enumerationContent, quantity) => {\n\treturn enumerationContent[findMatchingCondition(enumerationContent, quantity) ?? \"fallback\"];\n};\n\n//#endregion\nexport { findMatchingCondition, getEnumeration };\n//# sourceMappingURL=getEnumeration.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,yBAAyB,oBAAoB,aAAa;CAC/D,MAAM,cAAc,OAAO,KAAK,mBAAmB;AACnD,MAAK,MAAM,OAAO,aAAa;EAC9B,MAAM,UAAU,CAAC,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,WAAW,IAAI,IAAI,WAAW,IAAI,KAAK,YAAY,IAAI,WAAW,IAAI,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC,KAAK;EAC5K,MAAM,aAAa,IAAI,WAAW,IAAI,IAAI,WAAW,WAAW,IAAI,MAAM,EAAE,CAAC;EAC7E,MAAM,oBAAoB,IAAI,WAAW,KAAK,IAAI,YAAY,WAAW,IAAI,MAAM,EAAE,CAAC;EACtF,MAAM,aAAa,IAAI,WAAW,IAAI,IAAI,WAAW,WAAW,IAAI,MAAM,EAAE,CAAC;EAC7E,MAAM,oBAAoB,IAAI,WAAW,KAAK,IAAI,YAAY,WAAW,IAAI,MAAM,EAAE,CAAC;AACtF,MAAI,WAAW,cAAc,qBAAqB,cAAc,kBAAmB,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2B5F,MAAM,kBAAkB,oBAAoB,aAAa;AACxD,QAAO,mBAAmB,sBAAsB,oBAAoB,SAAS,IAAI"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region ../../@intlayer/core/dist/esm/interpreter/getEnumeration.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Find the matching condition for a quantity.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const key = findMatchingCondition({
|
|
9
|
+
* '<=-2.3': 'You have less than -2.3',
|
|
10
|
+
* '<1': 'You have less than one',
|
|
11
|
+
* '2': 'You have two',
|
|
12
|
+
* '>=3': 'You have three or more',
|
|
13
|
+
* }, 2);
|
|
14
|
+
* // '2'
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The order of the keys will define the priority of the content.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const key = findMatchingCondition({
|
|
21
|
+
* '<4': 'You have less than four',
|
|
22
|
+
* '2': 'You have two',
|
|
23
|
+
* }, 2);
|
|
24
|
+
* // '<4'
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* If no keys match, the default key is '1'.
|
|
28
|
+
*/
|
|
29
|
+
const findMatchingCondition = (enumerationContent, quantity) => {
|
|
30
|
+
const numericKeys = Object.keys(enumerationContent);
|
|
31
|
+
for (const key of numericKeys) {
|
|
32
|
+
const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity;
|
|
33
|
+
const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1));
|
|
34
|
+
const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
|
|
35
|
+
const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1));
|
|
36
|
+
const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
|
|
37
|
+
if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) return key;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Picks content from an enumeration map based on a provided quantity.
|
|
42
|
+
*
|
|
43
|
+
* Supported keys in the enumeration map:
|
|
44
|
+
* - Specific numbers: '0', '1', '2'
|
|
45
|
+
* - Comparison operators: '<5', '>=10', '<=2'
|
|
46
|
+
* - Fallback: 'fallback'
|
|
47
|
+
*
|
|
48
|
+
* The first matching key in the object's iteration order will be selected.
|
|
49
|
+
*
|
|
50
|
+
* @param enumerationContent - A map of conditions/quantities to content.
|
|
51
|
+
* @param quantity - The number to match against the conditions.
|
|
52
|
+
* @returns The matching content.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const content = getEnumeration({
|
|
57
|
+
* '0': 'No items',
|
|
58
|
+
* '1': 'One item',
|
|
59
|
+
* '>1': 'Many items',
|
|
60
|
+
* }, 5);
|
|
61
|
+
* // 'Many items'
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
const getEnumeration = (enumerationContent, quantity) => {
|
|
65
|
+
return enumerationContent[findMatchingCondition(enumerationContent, quantity) ?? "fallback"];
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
export { getEnumeration };
|
|
70
|
+
//# sourceMappingURL=getEnumeration.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEnumeration.mjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getEnumeration.mjs"],"sourcesContent":["//#region src/interpreter/getEnumeration.ts\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*/\nconst findMatchingCondition = (enumerationContent, quantity) => {\n\tconst numericKeys = Object.keys(enumerationContent);\n\tfor (const key of numericKeys) {\n\t\tconst isEqual = !key.startsWith(\">\") && !key.startsWith(\"<\") && !key.startsWith(\"=\") && parseFloat(key) === quantity || key.startsWith(\"=\") && parseFloat(key.slice(1)) === quantity;\n\t\tconst isSuperior = key.startsWith(\">\") && quantity > parseFloat(key.slice(1));\n\t\tconst isSuperiorOrEqual = key.startsWith(\">=\") && quantity >= parseFloat(key.slice(2));\n\t\tconst isInferior = key.startsWith(\"<\") && quantity < parseFloat(key.slice(1));\n\t\tconst isInferiorOrEqual = key.startsWith(\"<=\") && quantity <= parseFloat(key.slice(2));\n\t\tif (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) return key;\n\t}\n};\n/**\n* Picks content from an enumeration map based on a provided quantity.\n*\n* Supported keys in the enumeration map:\n* - Specific numbers: '0', '1', '2'\n* - Comparison operators: '<5', '>=10', '<=2'\n* - Fallback: 'fallback'\n*\n* The first matching key in the object's iteration order will be selected.\n*\n* @param enumerationContent - A map of conditions/quantities to content.\n* @param quantity - The number to match against the conditions.\n* @returns The matching content.\n*\n* @example\n* ```ts\n* const content = getEnumeration({\n* '0': 'No items',\n* '1': 'One item',\n* '>1': 'Many items',\n* }, 5);\n* // 'Many items'\n* ```\n*/\nconst getEnumeration = (enumerationContent, quantity) => {\n\treturn enumerationContent[findMatchingCondition(enumerationContent, quantity) ?? \"fallback\"];\n};\n\n//#endregion\nexport { findMatchingCondition, getEnumeration };\n//# sourceMappingURL=getEnumeration.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,yBAAyB,oBAAoB,aAAa;CAC/D,MAAM,cAAc,OAAO,KAAK,mBAAmB;AACnD,MAAK,MAAM,OAAO,aAAa;EAC9B,MAAM,UAAU,CAAC,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,WAAW,IAAI,IAAI,WAAW,IAAI,KAAK,YAAY,IAAI,WAAW,IAAI,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC,KAAK;EAC5K,MAAM,aAAa,IAAI,WAAW,IAAI,IAAI,WAAW,WAAW,IAAI,MAAM,EAAE,CAAC;EAC7E,MAAM,oBAAoB,IAAI,WAAW,KAAK,IAAI,YAAY,WAAW,IAAI,MAAM,EAAE,CAAC;EACtF,MAAM,aAAa,IAAI,WAAW,IAAI,IAAI,WAAW,WAAW,IAAI,MAAM,EAAE,CAAC;EAC7E,MAAM,oBAAoB,IAAI,WAAW,KAAK,IAAI,YAAY,WAAW,IAAI,MAAM,EAAE,CAAC;AACtF,MAAI,WAAW,cAAc,qBAAqB,cAAc,kBAAmB,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2B5F,MAAM,kBAAkB,oBAAoB,aAAa;AACxD,QAAO,mBAAmB,sBAAsB,oBAAoB,SAAS,IAAI"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../@intlayer/core/dist/esm/interpreter/getGender.mjs
|
|
3
|
+
const getGenderEntry = (gender) => {
|
|
4
|
+
if (gender === "m" || gender === "male") return "male";
|
|
5
|
+
if (gender === "f" || gender === "female") return "female";
|
|
6
|
+
return "fallback";
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Allow to pick a content based on a gender.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const content = getGender({
|
|
15
|
+
* 'true': 'The gender is validated',
|
|
16
|
+
* 'false': 'The gender is not validated',
|
|
17
|
+
* }, true);
|
|
18
|
+
* // 'The gender is validated'
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* The last key provided will be used as the fallback value.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* const content = getGender({
|
|
25
|
+
* 'false': 'The gender is not validated',
|
|
26
|
+
* 'true': 'The gender is validated',
|
|
27
|
+
* }, undefined);
|
|
28
|
+
* // 'The gender is validated'
|
|
29
|
+
*/
|
|
30
|
+
const getGender = (genderContent, gender) => {
|
|
31
|
+
const stateList = Object.keys(genderContent);
|
|
32
|
+
const fallbackState = stateList[stateList.length - 1];
|
|
33
|
+
return genderContent[getGenderEntry(gender)] ?? genderContent.fallback ?? genderContent[fallbackState];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.getGender = getGender;
|
|
38
|
+
//# sourceMappingURL=getGender.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGender.cjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getGender.mjs"],"sourcesContent":["//#region src/interpreter/getGender.ts\nconst getGenderEntry = (gender) => {\n\tif (gender === \"m\" || gender === \"male\") return \"male\";\n\tif (gender === \"f\" || gender === \"female\") return \"female\";\n\treturn \"fallback\";\n};\n/**\n* Allow to pick a content based on a gender.\n*\n* Usage:\n*\n* ```ts\n* const content = getGender({\n* 'true': 'The gender is validated',\n* 'false': 'The gender is not validated',\n* }, true);\n* // 'The gender is validated'\n* ```\n*\n* The last key provided will be used as the fallback value.\n*\n* ```ts\n* const content = getGender({\n* 'false': 'The gender is not validated',\n* 'true': 'The gender is validated',\n* }, undefined);\n* // 'The gender is validated'\n*/\nconst getGender = (genderContent, gender) => {\n\tconst stateList = Object.keys(genderContent);\n\tconst fallbackState = stateList[stateList.length - 1];\n\treturn genderContent[getGenderEntry(gender)] ?? genderContent.fallback ?? genderContent[fallbackState];\n};\n\n//#endregion\nexport { getGender };\n//# sourceMappingURL=getGender.mjs.map"],"mappings":";;AACA,MAAM,kBAAkB,WAAW;AAClC,KAAI,WAAW,OAAO,WAAW,OAAQ,QAAO;AAChD,KAAI,WAAW,OAAO,WAAW,SAAU,QAAO;AAClD,QAAO;;;;;;;;;;;;;;;;;;;;;;;;AAwBR,MAAM,aAAa,eAAe,WAAW;CAC5C,MAAM,YAAY,OAAO,KAAK,cAAc;CAC5C,MAAM,gBAAgB,UAAU,UAAU,SAAS;AACnD,QAAO,cAAc,eAAe,OAAO,KAAK,cAAc,YAAY,cAAc"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region ../../@intlayer/core/dist/esm/interpreter/getGender.mjs
|
|
2
|
+
const getGenderEntry = (gender) => {
|
|
3
|
+
if (gender === "m" || gender === "male") return "male";
|
|
4
|
+
if (gender === "f" || gender === "female") return "female";
|
|
5
|
+
return "fallback";
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Allow to pick a content based on a gender.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const content = getGender({
|
|
14
|
+
* 'true': 'The gender is validated',
|
|
15
|
+
* 'false': 'The gender is not validated',
|
|
16
|
+
* }, true);
|
|
17
|
+
* // 'The gender is validated'
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* The last key provided will be used as the fallback value.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* const content = getGender({
|
|
24
|
+
* 'false': 'The gender is not validated',
|
|
25
|
+
* 'true': 'The gender is validated',
|
|
26
|
+
* }, undefined);
|
|
27
|
+
* // 'The gender is validated'
|
|
28
|
+
*/
|
|
29
|
+
const getGender = (genderContent, gender) => {
|
|
30
|
+
const stateList = Object.keys(genderContent);
|
|
31
|
+
const fallbackState = stateList[stateList.length - 1];
|
|
32
|
+
return genderContent[getGenderEntry(gender)] ?? genderContent.fallback ?? genderContent[fallbackState];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { getGender };
|
|
37
|
+
//# sourceMappingURL=getGender.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGender.mjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getGender.mjs"],"sourcesContent":["//#region src/interpreter/getGender.ts\nconst getGenderEntry = (gender) => {\n\tif (gender === \"m\" || gender === \"male\") return \"male\";\n\tif (gender === \"f\" || gender === \"female\") return \"female\";\n\treturn \"fallback\";\n};\n/**\n* Allow to pick a content based on a gender.\n*\n* Usage:\n*\n* ```ts\n* const content = getGender({\n* 'true': 'The gender is validated',\n* 'false': 'The gender is not validated',\n* }, true);\n* // 'The gender is validated'\n* ```\n*\n* The last key provided will be used as the fallback value.\n*\n* ```ts\n* const content = getGender({\n* 'false': 'The gender is not validated',\n* 'true': 'The gender is validated',\n* }, undefined);\n* // 'The gender is validated'\n*/\nconst getGender = (genderContent, gender) => {\n\tconst stateList = Object.keys(genderContent);\n\tconst fallbackState = stateList[stateList.length - 1];\n\treturn genderContent[getGenderEntry(gender)] ?? genderContent.fallback ?? genderContent[fallbackState];\n};\n\n//#endregion\nexport { getGender };\n//# sourceMappingURL=getGender.mjs.map"],"mappings":";AACA,MAAM,kBAAkB,WAAW;AAClC,KAAI,WAAW,OAAO,WAAW,OAAQ,QAAO;AAChD,KAAI,WAAW,OAAO,WAAW,SAAU,QAAO;AAClD,QAAO;;;;;;;;;;;;;;;;;;;;;;;;AAwBR,MAAM,aAAa,eAAe,WAAW;CAC5C,MAAM,YAAY,OAAO,KAAK,cAAc;CAC5C,MAAM,gBAAgB,UAAU,UAAU,SAAS;AACnD,QAAO,cAAc,eAAe,OAAO,KAAK,cAAc,YAAY,cAAc"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../@intlayer/core/dist/esm/interpreter/getInsertion.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Allow to insert values in a string.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const content = getInsertion('Hello {{name}}!', {
|
|
10
|
+
* name: 'John',
|
|
11
|
+
* });
|
|
12
|
+
* // 'Hello John!'
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
const getInsertion = (content, values) => content.replace(/\{\{\s*(.*?)\s*\}\}/g, (_, key) => {
|
|
17
|
+
return (values[key.trim()] ?? "").toString();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.getInsertion = getInsertion;
|
|
22
|
+
//# sourceMappingURL=getInsertion.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getInsertion.cjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getInsertion.mjs"],"sourcesContent":["//#region src/interpreter/getInsertion.ts\n/**\n* Allow to insert values in a string.\n*\n* Usage:\n*\n* ```ts\n* const content = getInsertion('Hello {{name}}!', {\n* name: 'John',\n* });\n* // 'Hello John!'\n* ```\n*\n*/\nconst getInsertion = (content, values) => content.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n\treturn (values[key.trim()] ?? \"\").toString();\n});\n\n//#endregion\nexport { getInsertion };\n//# sourceMappingURL=getInsertion.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAM,gBAAgB,SAAS,WAAW,QAAQ,QAAQ,yBAAyB,GAAG,QAAQ;AAC7F,SAAQ,OAAO,IAAI,MAAM,KAAK,IAAI,UAAU;EAC3C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region ../../@intlayer/core/dist/esm/interpreter/getInsertion.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Allow to insert values in a string.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const content = getInsertion('Hello {{name}}!', {
|
|
9
|
+
* name: 'John',
|
|
10
|
+
* });
|
|
11
|
+
* // 'Hello John!'
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
const getInsertion = (content, values) => content.replace(/\{\{\s*(.*?)\s*\}\}/g, (_, key) => {
|
|
16
|
+
return (values[key.trim()] ?? "").toString();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getInsertion };
|
|
21
|
+
//# sourceMappingURL=getInsertion.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getInsertion.mjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getInsertion.mjs"],"sourcesContent":["//#region src/interpreter/getInsertion.ts\n/**\n* Allow to insert values in a string.\n*\n* Usage:\n*\n* ```ts\n* const content = getInsertion('Hello {{name}}!', {\n* name: 'John',\n* });\n* // 'Hello John!'\n* ```\n*\n*/\nconst getInsertion = (content, values) => content.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n\treturn (values[key.trim()] ?? \"\").toString();\n});\n\n//#endregion\nexport { getInsertion };\n//# sourceMappingURL=getInsertion.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,gBAAgB,SAAS,WAAW,QAAQ,QAAQ,yBAAyB,GAAG,QAAQ;AAC7F,SAAQ,OAAO,IAAI,MAAM,KAAK,IAAI,UAAU;EAC3C"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../@intlayer/core/dist/esm/interpreter/getTranslation.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Check if a value is a plain object that can be safely merged.
|
|
5
|
+
* Returns false for Promises, React elements, class instances, etc.
|
|
6
|
+
*/
|
|
7
|
+
const isPlainObject = (value) => {
|
|
8
|
+
if (value === null || typeof value !== "object") return false;
|
|
9
|
+
if (typeof value.then === "function") return false;
|
|
10
|
+
if (value.$$typeof !== void 0 || value.__v_isVNode !== void 0 || value._isVNode !== void 0 || value.isJSX !== void 0) return false;
|
|
11
|
+
const proto = Object.getPrototypeOf(value);
|
|
12
|
+
return proto === Object.prototype || proto === null || Array.isArray(value);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Recursively merges two objects, skipping undefined source values.
|
|
16
|
+
* First argument takes precedence. Arrays replace rather than merge.
|
|
17
|
+
*/
|
|
18
|
+
const deepMerge = (target, source) => {
|
|
19
|
+
if (target === void 0) return source;
|
|
20
|
+
if (source === void 0) return target;
|
|
21
|
+
if (Array.isArray(target)) return target;
|
|
22
|
+
if (isPlainObject(target) && isPlainObject(source)) {
|
|
23
|
+
const result = { ...target };
|
|
24
|
+
for (const key of Object.keys(source)) {
|
|
25
|
+
if (key === "__proto__" || key === "constructor" || source[key] === void 0) continue;
|
|
26
|
+
result[key] = target[key] !== void 0 ? deepMerge(target[key], source[key]) : source[key];
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Picks the appropriate content from a locale map based on the provided locale.
|
|
34
|
+
*
|
|
35
|
+
* It handles:
|
|
36
|
+
* 1. Exact locale match (e.g., 'en-US').
|
|
37
|
+
* 2. Generic locale fallback (e.g., 'en' if 'en-US' is not found).
|
|
38
|
+
* 3. Explicit fallback locale.
|
|
39
|
+
* 4. Deep merging of objects to ensure partial translations are complemented by fallbacks.
|
|
40
|
+
*
|
|
41
|
+
* @param languageContent - A map of locales to content.
|
|
42
|
+
* @param locale - The target locale to retrieve.
|
|
43
|
+
* @param fallback - Optional fallback locale if the target is not found.
|
|
44
|
+
* @returns The translated content.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const content = getTranslation({
|
|
49
|
+
* en: 'Hello',
|
|
50
|
+
* fr: 'Bonjour',
|
|
51
|
+
* }, 'fr');
|
|
52
|
+
* // 'Bonjour'
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
const getTranslation = (languageContent, locale, fallback) => {
|
|
56
|
+
const get = (loc) => languageContent[loc];
|
|
57
|
+
const seen = /* @__PURE__ */ new Set();
|
|
58
|
+
const locales = [];
|
|
59
|
+
const addLocale = (loc) => {
|
|
60
|
+
if (loc && !seen.has(loc)) {
|
|
61
|
+
seen.add(loc);
|
|
62
|
+
locales.push(loc);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
addLocale(locale);
|
|
66
|
+
if (locale.includes("-")) addLocale(locale.split("-")[0]);
|
|
67
|
+
addLocale(fallback);
|
|
68
|
+
if (fallback?.includes("-")) addLocale(fallback.split("-")[0]);
|
|
69
|
+
const results = [];
|
|
70
|
+
for (const loc of locales) {
|
|
71
|
+
const val = get(loc);
|
|
72
|
+
if (val === void 0) continue;
|
|
73
|
+
if (typeof val === "string") {
|
|
74
|
+
if (results.length === 0) return val;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
results.push(val);
|
|
78
|
+
}
|
|
79
|
+
if (results.length === 0) return void 0;
|
|
80
|
+
if (results.length === 1) return results[0];
|
|
81
|
+
if (Array.isArray(results[0])) return results[0];
|
|
82
|
+
return results.reduce((acc, curr) => deepMerge(acc, curr));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
exports.getTranslation = getTranslation;
|
|
87
|
+
//# sourceMappingURL=getTranslation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTranslation.cjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getTranslation.mjs"],"sourcesContent":["//#region src/interpreter/getTranslation.ts\n/**\n* Check if a value is a plain object that can be safely merged.\n* Returns false for Promises, React elements, class instances, etc.\n*/\nconst isPlainObject = (value) => {\n\tif (value === null || typeof value !== \"object\") return false;\n\tif (typeof value.then === \"function\") return false;\n\tif (value.$$typeof !== void 0 || value.__v_isVNode !== void 0 || value._isVNode !== void 0 || value.isJSX !== void 0) return false;\n\tconst proto = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null || Array.isArray(value);\n};\n/**\n* Recursively merges two objects, skipping undefined source values.\n* First argument takes precedence. Arrays replace rather than merge.\n*/\nconst deepMerge = (target, source) => {\n\tif (target === void 0) return source;\n\tif (source === void 0) return target;\n\tif (Array.isArray(target)) return target;\n\tif (isPlainObject(target) && isPlainObject(source)) {\n\t\tconst result = { ...target };\n\t\tfor (const key of Object.keys(source)) {\n\t\t\tif (key === \"__proto__\" || key === \"constructor\" || source[key] === void 0) continue;\n\t\t\tresult[key] = target[key] !== void 0 ? deepMerge(target[key], source[key]) : source[key];\n\t\t}\n\t\treturn result;\n\t}\n\treturn target;\n};\n/**\n* Picks the appropriate content from a locale map based on the provided locale.\n*\n* It handles:\n* 1. Exact locale match (e.g., 'en-US').\n* 2. Generic locale fallback (e.g., 'en' if 'en-US' is not found).\n* 3. Explicit fallback locale.\n* 4. Deep merging of objects to ensure partial translations are complemented by fallbacks.\n*\n* @param languageContent - A map of locales to content.\n* @param locale - The target locale to retrieve.\n* @param fallback - Optional fallback locale if the target is not found.\n* @returns The translated content.\n*\n* @example\n* ```ts\n* const content = getTranslation({\n* en: 'Hello',\n* fr: 'Bonjour',\n* }, 'fr');\n* // 'Bonjour'\n* ```\n*/\nconst getTranslation = (languageContent, locale, fallback) => {\n\tconst get = (loc) => languageContent[loc];\n\tconst seen = /* @__PURE__ */ new Set();\n\tconst locales = [];\n\tconst addLocale = (loc) => {\n\t\tif (loc && !seen.has(loc)) {\n\t\t\tseen.add(loc);\n\t\t\tlocales.push(loc);\n\t\t}\n\t};\n\taddLocale(locale);\n\tif (locale.includes(\"-\")) addLocale(locale.split(\"-\")[0]);\n\taddLocale(fallback);\n\tif (fallback?.includes(\"-\")) addLocale(fallback.split(\"-\")[0]);\n\tconst results = [];\n\tfor (const loc of locales) {\n\t\tconst val = get(loc);\n\t\tif (val === void 0) continue;\n\t\tif (typeof val === \"string\") {\n\t\t\tif (results.length === 0) return val;\n\t\t\tcontinue;\n\t\t}\n\t\tresults.push(val);\n\t}\n\tif (results.length === 0) return void 0;\n\tif (results.length === 1) return results[0];\n\tif (Array.isArray(results[0])) return results[0];\n\treturn results.reduce((acc, curr) => deepMerge(acc, curr));\n};\n\n//#endregion\nexport { getTranslation };\n//# sourceMappingURL=getTranslation.mjs.map"],"mappings":";;;;;;AAKA,MAAM,iBAAiB,UAAU;AAChC,KAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,KAAI,OAAO,MAAM,SAAS,WAAY,QAAO;AAC7C,KAAI,MAAM,aAAa,KAAK,KAAK,MAAM,gBAAgB,KAAK,KAAK,MAAM,aAAa,KAAK,KAAK,MAAM,UAAU,KAAK,EAAG,QAAO;CAC7H,MAAM,QAAQ,OAAO,eAAe,MAAM;AAC1C,QAAO,UAAU,OAAO,aAAa,UAAU,QAAQ,MAAM,QAAQ,MAAM;;;;;;AAM5E,MAAM,aAAa,QAAQ,WAAW;AACrC,KAAI,WAAW,KAAK,EAAG,QAAO;AAC9B,KAAI,WAAW,KAAK,EAAG,QAAO;AAC9B,KAAI,MAAM,QAAQ,OAAO,CAAE,QAAO;AAClC,KAAI,cAAc,OAAO,IAAI,cAAc,OAAO,EAAE;EACnD,MAAM,SAAS,EAAE,GAAG,QAAQ;AAC5B,OAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;AACtC,OAAI,QAAQ,eAAe,QAAQ,iBAAiB,OAAO,SAAS,KAAK,EAAG;AAC5E,UAAO,OAAO,OAAO,SAAS,KAAK,IAAI,UAAU,OAAO,MAAM,OAAO,KAAK,GAAG,OAAO;;AAErF,SAAO;;AAER,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AAyBR,MAAM,kBAAkB,iBAAiB,QAAQ,aAAa;CAC7D,MAAM,OAAO,QAAQ,gBAAgB;CACrC,MAAM,uBAAuB,IAAI,KAAK;CACtC,MAAM,UAAU,EAAE;CAClB,MAAM,aAAa,QAAQ;AAC1B,MAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;AAC1B,QAAK,IAAI,IAAI;AACb,WAAQ,KAAK,IAAI;;;AAGnB,WAAU,OAAO;AACjB,KAAI,OAAO,SAAS,IAAI,CAAE,WAAU,OAAO,MAAM,IAAI,CAAC,GAAG;AACzD,WAAU,SAAS;AACnB,KAAI,UAAU,SAAS,IAAI,CAAE,WAAU,SAAS,MAAM,IAAI,CAAC,GAAG;CAC9D,MAAM,UAAU,EAAE;AAClB,MAAK,MAAM,OAAO,SAAS;EAC1B,MAAM,MAAM,IAAI,IAAI;AACpB,MAAI,QAAQ,KAAK,EAAG;AACpB,MAAI,OAAO,QAAQ,UAAU;AAC5B,OAAI,QAAQ,WAAW,EAAG,QAAO;AACjC;;AAED,UAAQ,KAAK,IAAI;;AAElB,KAAI,QAAQ,WAAW,EAAG,QAAO,KAAK;AACtC,KAAI,QAAQ,WAAW,EAAG,QAAO,QAAQ;AACzC,KAAI,MAAM,QAAQ,QAAQ,GAAG,CAAE,QAAO,QAAQ;AAC9C,QAAO,QAAQ,QAAQ,KAAK,SAAS,UAAU,KAAK,KAAK,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//#region ../../@intlayer/core/dist/esm/interpreter/getTranslation.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Check if a value is a plain object that can be safely merged.
|
|
4
|
+
* Returns false for Promises, React elements, class instances, etc.
|
|
5
|
+
*/
|
|
6
|
+
const isPlainObject = (value) => {
|
|
7
|
+
if (value === null || typeof value !== "object") return false;
|
|
8
|
+
if (typeof value.then === "function") return false;
|
|
9
|
+
if (value.$$typeof !== void 0 || value.__v_isVNode !== void 0 || value._isVNode !== void 0 || value.isJSX !== void 0) return false;
|
|
10
|
+
const proto = Object.getPrototypeOf(value);
|
|
11
|
+
return proto === Object.prototype || proto === null || Array.isArray(value);
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Recursively merges two objects, skipping undefined source values.
|
|
15
|
+
* First argument takes precedence. Arrays replace rather than merge.
|
|
16
|
+
*/
|
|
17
|
+
const deepMerge = (target, source) => {
|
|
18
|
+
if (target === void 0) return source;
|
|
19
|
+
if (source === void 0) return target;
|
|
20
|
+
if (Array.isArray(target)) return target;
|
|
21
|
+
if (isPlainObject(target) && isPlainObject(source)) {
|
|
22
|
+
const result = { ...target };
|
|
23
|
+
for (const key of Object.keys(source)) {
|
|
24
|
+
if (key === "__proto__" || key === "constructor" || source[key] === void 0) continue;
|
|
25
|
+
result[key] = target[key] !== void 0 ? deepMerge(target[key], source[key]) : source[key];
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Picks the appropriate content from a locale map based on the provided locale.
|
|
33
|
+
*
|
|
34
|
+
* It handles:
|
|
35
|
+
* 1. Exact locale match (e.g., 'en-US').
|
|
36
|
+
* 2. Generic locale fallback (e.g., 'en' if 'en-US' is not found).
|
|
37
|
+
* 3. Explicit fallback locale.
|
|
38
|
+
* 4. Deep merging of objects to ensure partial translations are complemented by fallbacks.
|
|
39
|
+
*
|
|
40
|
+
* @param languageContent - A map of locales to content.
|
|
41
|
+
* @param locale - The target locale to retrieve.
|
|
42
|
+
* @param fallback - Optional fallback locale if the target is not found.
|
|
43
|
+
* @returns The translated content.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const content = getTranslation({
|
|
48
|
+
* en: 'Hello',
|
|
49
|
+
* fr: 'Bonjour',
|
|
50
|
+
* }, 'fr');
|
|
51
|
+
* // 'Bonjour'
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
const getTranslation = (languageContent, locale, fallback) => {
|
|
55
|
+
const get = (loc) => languageContent[loc];
|
|
56
|
+
const seen = /* @__PURE__ */ new Set();
|
|
57
|
+
const locales = [];
|
|
58
|
+
const addLocale = (loc) => {
|
|
59
|
+
if (loc && !seen.has(loc)) {
|
|
60
|
+
seen.add(loc);
|
|
61
|
+
locales.push(loc);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
addLocale(locale);
|
|
65
|
+
if (locale.includes("-")) addLocale(locale.split("-")[0]);
|
|
66
|
+
addLocale(fallback);
|
|
67
|
+
if (fallback?.includes("-")) addLocale(fallback.split("-")[0]);
|
|
68
|
+
const results = [];
|
|
69
|
+
for (const loc of locales) {
|
|
70
|
+
const val = get(loc);
|
|
71
|
+
if (val === void 0) continue;
|
|
72
|
+
if (typeof val === "string") {
|
|
73
|
+
if (results.length === 0) return val;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
results.push(val);
|
|
77
|
+
}
|
|
78
|
+
if (results.length === 0) return void 0;
|
|
79
|
+
if (results.length === 1) return results[0];
|
|
80
|
+
if (Array.isArray(results[0])) return results[0];
|
|
81
|
+
return results.reduce((acc, curr) => deepMerge(acc, curr));
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { getTranslation };
|
|
86
|
+
//# sourceMappingURL=getTranslation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTranslation.mjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/interpreter/getTranslation.mjs"],"sourcesContent":["//#region src/interpreter/getTranslation.ts\n/**\n* Check if a value is a plain object that can be safely merged.\n* Returns false for Promises, React elements, class instances, etc.\n*/\nconst isPlainObject = (value) => {\n\tif (value === null || typeof value !== \"object\") return false;\n\tif (typeof value.then === \"function\") return false;\n\tif (value.$$typeof !== void 0 || value.__v_isVNode !== void 0 || value._isVNode !== void 0 || value.isJSX !== void 0) return false;\n\tconst proto = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null || Array.isArray(value);\n};\n/**\n* Recursively merges two objects, skipping undefined source values.\n* First argument takes precedence. Arrays replace rather than merge.\n*/\nconst deepMerge = (target, source) => {\n\tif (target === void 0) return source;\n\tif (source === void 0) return target;\n\tif (Array.isArray(target)) return target;\n\tif (isPlainObject(target) && isPlainObject(source)) {\n\t\tconst result = { ...target };\n\t\tfor (const key of Object.keys(source)) {\n\t\t\tif (key === \"__proto__\" || key === \"constructor\" || source[key] === void 0) continue;\n\t\t\tresult[key] = target[key] !== void 0 ? deepMerge(target[key], source[key]) : source[key];\n\t\t}\n\t\treturn result;\n\t}\n\treturn target;\n};\n/**\n* Picks the appropriate content from a locale map based on the provided locale.\n*\n* It handles:\n* 1. Exact locale match (e.g., 'en-US').\n* 2. Generic locale fallback (e.g., 'en' if 'en-US' is not found).\n* 3. Explicit fallback locale.\n* 4. Deep merging of objects to ensure partial translations are complemented by fallbacks.\n*\n* @param languageContent - A map of locales to content.\n* @param locale - The target locale to retrieve.\n* @param fallback - Optional fallback locale if the target is not found.\n* @returns The translated content.\n*\n* @example\n* ```ts\n* const content = getTranslation({\n* en: 'Hello',\n* fr: 'Bonjour',\n* }, 'fr');\n* // 'Bonjour'\n* ```\n*/\nconst getTranslation = (languageContent, locale, fallback) => {\n\tconst get = (loc) => languageContent[loc];\n\tconst seen = /* @__PURE__ */ new Set();\n\tconst locales = [];\n\tconst addLocale = (loc) => {\n\t\tif (loc && !seen.has(loc)) {\n\t\t\tseen.add(loc);\n\t\t\tlocales.push(loc);\n\t\t}\n\t};\n\taddLocale(locale);\n\tif (locale.includes(\"-\")) addLocale(locale.split(\"-\")[0]);\n\taddLocale(fallback);\n\tif (fallback?.includes(\"-\")) addLocale(fallback.split(\"-\")[0]);\n\tconst results = [];\n\tfor (const loc of locales) {\n\t\tconst val = get(loc);\n\t\tif (val === void 0) continue;\n\t\tif (typeof val === \"string\") {\n\t\t\tif (results.length === 0) return val;\n\t\t\tcontinue;\n\t\t}\n\t\tresults.push(val);\n\t}\n\tif (results.length === 0) return void 0;\n\tif (results.length === 1) return results[0];\n\tif (Array.isArray(results[0])) return results[0];\n\treturn results.reduce((acc, curr) => deepMerge(acc, curr));\n};\n\n//#endregion\nexport { getTranslation };\n//# sourceMappingURL=getTranslation.mjs.map"],"mappings":";;;;;AAKA,MAAM,iBAAiB,UAAU;AAChC,KAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,KAAI,OAAO,MAAM,SAAS,WAAY,QAAO;AAC7C,KAAI,MAAM,aAAa,KAAK,KAAK,MAAM,gBAAgB,KAAK,KAAK,MAAM,aAAa,KAAK,KAAK,MAAM,UAAU,KAAK,EAAG,QAAO;CAC7H,MAAM,QAAQ,OAAO,eAAe,MAAM;AAC1C,QAAO,UAAU,OAAO,aAAa,UAAU,QAAQ,MAAM,QAAQ,MAAM;;;;;;AAM5E,MAAM,aAAa,QAAQ,WAAW;AACrC,KAAI,WAAW,KAAK,EAAG,QAAO;AAC9B,KAAI,WAAW,KAAK,EAAG,QAAO;AAC9B,KAAI,MAAM,QAAQ,OAAO,CAAE,QAAO;AAClC,KAAI,cAAc,OAAO,IAAI,cAAc,OAAO,EAAE;EACnD,MAAM,SAAS,EAAE,GAAG,QAAQ;AAC5B,OAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;AACtC,OAAI,QAAQ,eAAe,QAAQ,iBAAiB,OAAO,SAAS,KAAK,EAAG;AAC5E,UAAO,OAAO,OAAO,SAAS,KAAK,IAAI,UAAU,OAAO,MAAM,OAAO,KAAK,GAAG,OAAO;;AAErF,SAAO;;AAER,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AAyBR,MAAM,kBAAkB,iBAAiB,QAAQ,aAAa;CAC7D,MAAM,OAAO,QAAQ,gBAAgB;CACrC,MAAM,uBAAuB,IAAI,KAAK;CACtC,MAAM,UAAU,EAAE;CAClB,MAAM,aAAa,QAAQ;AAC1B,MAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;AAC1B,QAAK,IAAI,IAAI;AACb,WAAQ,KAAK,IAAI;;;AAGnB,WAAU,OAAO;AACjB,KAAI,OAAO,SAAS,IAAI,CAAE,WAAU,OAAO,MAAM,IAAI,CAAC,GAAG;AACzD,WAAU,SAAS;AACnB,KAAI,UAAU,SAAS,IAAI,CAAE,WAAU,SAAS,MAAM,IAAI,CAAC,GAAG;CAC9D,MAAM,UAAU,EAAE;AAClB,MAAK,MAAM,OAAO,SAAS;EAC1B,MAAM,MAAM,IAAI,IAAI;AACpB,MAAI,QAAQ,KAAK,EAAG;AACpB,MAAI,OAAO,QAAQ,UAAU;AAC5B,OAAI,QAAQ,WAAW,EAAG,QAAO;AACjC;;AAED,UAAQ,KAAK,IAAI;;AAElB,KAAI,QAAQ,WAAW,EAAG,QAAO,KAAK;AACtC,KAAI,QAAQ,WAAW,EAAG,QAAO,QAAQ;AACzC,KAAI,MAAM,QAAQ,QAAQ,GAAG,CAAE,QAAO,QAAQ;AAC9C,QAAO,QAAQ,QAAQ,KAAK,SAAS,UAAU,KAAK,KAAK,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../@intlayer/core/dist/esm/utils/isValidReactElement.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Verifies the object is a ReactElement.
|
|
5
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
6
|
+
* @param object
|
|
7
|
+
* @return True if `object` is a ReactElement.
|
|
8
|
+
* @final
|
|
9
|
+
*/
|
|
10
|
+
const isValidElement = (object) => typeof object === "object" && typeof object?.key !== "undefined" && typeof object?.props !== "undefined";
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.isValidElement = isValidElement;
|
|
14
|
+
//# sourceMappingURL=isValidReactElement.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidReactElement.cjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/utils/isValidReactElement.mjs"],"sourcesContent":["//#region src/utils/isValidReactElement.ts\n/**\n* Verifies the object is a ReactElement.\n* See https://reactjs.org/docs/react-api.html#isvalidelement\n* @param object\n* @return True if `object` is a ReactElement.\n* @final\n*/\nconst isValidElement = (object) => typeof object === \"object\" && typeof object?.key !== \"undefined\" && typeof object?.props !== \"undefined\";\n\n//#endregion\nexport { isValidElement };\n//# sourceMappingURL=isValidReactElement.mjs.map"],"mappings":";;;;;;;;;AAQA,MAAM,kBAAkB,WAAW,OAAO,WAAW,YAAY,OAAO,QAAQ,QAAQ,eAAe,OAAO,QAAQ,UAAU"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region ../../@intlayer/core/dist/esm/utils/isValidReactElement.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Verifies the object is a ReactElement.
|
|
4
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
5
|
+
* @param object
|
|
6
|
+
* @return True if `object` is a ReactElement.
|
|
7
|
+
* @final
|
|
8
|
+
*/
|
|
9
|
+
const isValidElement = (object) => typeof object === "object" && typeof object?.key !== "undefined" && typeof object?.props !== "undefined";
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isValidElement };
|
|
13
|
+
//# sourceMappingURL=isValidReactElement.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isValidReactElement.mjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/utils/isValidReactElement.mjs"],"sourcesContent":["//#region src/utils/isValidReactElement.ts\n/**\n* Verifies the object is a ReactElement.\n* See https://reactjs.org/docs/react-api.html#isvalidelement\n* @param object\n* @return True if `object` is a ReactElement.\n* @final\n*/\nconst isValidElement = (object) => typeof object === \"object\" && typeof object?.key !== \"undefined\" && typeof object?.props !== \"undefined\";\n\n//#endregion\nexport { isValidElement };\n//# sourceMappingURL=isValidReactElement.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,kBAAkB,WAAW,OAAO,WAAW,YAAY,OAAO,QAAQ,QAAQ,eAAe,OAAO,QAAQ,UAAU"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../@intlayer/core/dist/esm/utils/stringifyYaml.mjs
|
|
3
|
+
const NEEDS_QUOTING = /[\n\r\t#:{}[\],&*?|<>=!%@`'"\\]|^[-?!]|\s$|^\s|^[>|]|^[.]{2,}/;
|
|
4
|
+
const PRESERVED_LITERALS = new Set([
|
|
5
|
+
"true",
|
|
6
|
+
"false",
|
|
7
|
+
"null",
|
|
8
|
+
"undefined",
|
|
9
|
+
"yes",
|
|
10
|
+
"no",
|
|
11
|
+
"on",
|
|
12
|
+
"off",
|
|
13
|
+
"NaN",
|
|
14
|
+
"Infinity",
|
|
15
|
+
"-Infinity"
|
|
16
|
+
]);
|
|
17
|
+
const serializeString = (value, indent) => {
|
|
18
|
+
if (value.includes("\n")) return `|\n${value.split("\n").map((l) => `${indent} ${l}`).join("\n")}`;
|
|
19
|
+
if (NEEDS_QUOTING.test(value) || PRESERVED_LITERALS.has(value) || /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i.test(value)) return JSON.stringify(value);
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
22
|
+
const serializeValue = (value, indent) => {
|
|
23
|
+
if (value === null || value === void 0) return "null";
|
|
24
|
+
if (typeof value === "boolean" || typeof value === "number") return String(value);
|
|
25
|
+
if (typeof value === "string") return serializeString(value, indent);
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
if (value.length === 0) return "[]";
|
|
28
|
+
return value.map((item) => {
|
|
29
|
+
const serialized = serializeValue(item, `${indent} `);
|
|
30
|
+
if (typeof item === "object" && item !== null && !Array.isArray(item) && !serialized.startsWith("'") && !serialized.startsWith("\"")) {
|
|
31
|
+
const lines = serialized.split("\n");
|
|
32
|
+
return `${indent}- ${lines[0]}\n${lines.slice(1).map((l) => `${indent} ${l}`).join("\n")}`.trimEnd();
|
|
33
|
+
}
|
|
34
|
+
return `${indent}- ${serialized}`;
|
|
35
|
+
}).join("\n");
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === "object") {
|
|
38
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0);
|
|
39
|
+
if (entries.length === 0) return "{}";
|
|
40
|
+
return entries.map(([k, value]) => {
|
|
41
|
+
const key = /[\s:{}[\]]/.test(k) ? JSON.stringify(k) : k;
|
|
42
|
+
const childIndent = `${indent} `;
|
|
43
|
+
if (value === null || value === void 0) return `${indent}${key}: null`;
|
|
44
|
+
if (typeof value === "object" && !Array.isArray(value)) return `${indent}${key}:\n${serializeValue(value, childIndent)}`;
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
if (value.length === 0) return `${indent}${key}: []`;
|
|
47
|
+
return `${indent}${key}:\n${serializeValue(value, childIndent)}`;
|
|
48
|
+
}
|
|
49
|
+
return `${indent}${key}: ${serializeValue(value, indent)}`;
|
|
50
|
+
}).join("\n");
|
|
51
|
+
}
|
|
52
|
+
return String(value);
|
|
53
|
+
};
|
|
54
|
+
const stringifyYaml = (value) => `${serializeValue(value, "")}\n`;
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
exports.stringifyYaml = stringifyYaml;
|
|
58
|
+
//# sourceMappingURL=stringifyYaml.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyYaml.cjs","names":[],"sources":["../../../../../../../../../@intlayer/core/dist/esm/utils/stringifyYaml.mjs"],"sourcesContent":["//#region src/utils/stringifyYaml.ts\nconst NEEDS_QUOTING = /[\\n\\r\\t#:{}[\\],&*?|<>=!%@`'\"\\\\]|^[-?!]|\\s$|^\\s|^[>|]|^[.]{2,}/;\nconst PRESERVED_LITERALS = new Set([\n\t\"true\",\n\t\"false\",\n\t\"null\",\n\t\"undefined\",\n\t\"yes\",\n\t\"no\",\n\t\"on\",\n\t\"off\",\n\t\"NaN\",\n\t\"Infinity\",\n\t\"-Infinity\"\n]);\nconst serializeString = (value, indent) => {\n\tif (value.includes(\"\\n\")) return `|\\n${value.split(\"\\n\").map((l) => `${indent} ${l}`).join(\"\\n\")}`;\n\tif (NEEDS_QUOTING.test(value) || PRESERVED_LITERALS.has(value) || /^-?\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?$/i.test(value)) return JSON.stringify(value);\n\treturn value;\n};\nconst serializeValue = (value, indent) => {\n\tif (value === null || value === void 0) return \"null\";\n\tif (typeof value === \"boolean\" || typeof value === \"number\") return String(value);\n\tif (typeof value === \"string\") return serializeString(value, indent);\n\tif (Array.isArray(value)) {\n\t\tif (value.length === 0) return \"[]\";\n\t\treturn value.map((item) => {\n\t\t\tconst serialized = serializeValue(item, `${indent} `);\n\t\t\tif (typeof item === \"object\" && item !== null && !Array.isArray(item) && !serialized.startsWith(\"'\") && !serialized.startsWith(\"\\\"\")) {\n\t\t\t\tconst lines = serialized.split(\"\\n\");\n\t\t\t\treturn `${indent}- ${lines[0]}\\n${lines.slice(1).map((l) => `${indent} ${l}`).join(\"\\n\")}`.trimEnd();\n\t\t\t}\n\t\t\treturn `${indent}- ${serialized}`;\n\t\t}).join(\"\\n\");\n\t}\n\tif (typeof value === \"object\") {\n\t\tconst entries = Object.entries(value).filter(([, v]) => v !== void 0);\n\t\tif (entries.length === 0) return \"{}\";\n\t\treturn entries.map(([k, value]) => {\n\t\t\tconst key = /[\\s:{}[\\]]/.test(k) ? JSON.stringify(k) : k;\n\t\t\tconst childIndent = `${indent} `;\n\t\t\tif (value === null || value === void 0) return `${indent}${key}: null`;\n\t\t\tif (typeof value === \"object\" && !Array.isArray(value)) return `${indent}${key}:\\n${serializeValue(value, childIndent)}`;\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tif (value.length === 0) return `${indent}${key}: []`;\n\t\t\t\treturn `${indent}${key}:\\n${serializeValue(value, childIndent)}`;\n\t\t\t}\n\t\t\treturn `${indent}${key}: ${serializeValue(value, indent)}`;\n\t\t}).join(\"\\n\");\n\t}\n\treturn String(value);\n};\nconst stringifyYaml = (value) => `${serializeValue(value, \"\")}\\n`;\n\n//#endregion\nexport { stringifyYaml };\n//# sourceMappingURL=stringifyYaml.mjs.map"],"mappings":";;AACA,MAAM,gBAAgB;AACtB,MAAM,qBAAqB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,CAAC;AACF,MAAM,mBAAmB,OAAO,WAAW;AAC1C,KAAI,MAAM,SAAS,KAAK,CAAE,QAAO,MAAM,MAAM,MAAM,KAAK,CAAC,KAAK,MAAM,GAAG,OAAO,IAAI,IAAI,CAAC,KAAK,KAAK;AACjG,KAAI,cAAc,KAAK,MAAM,IAAI,mBAAmB,IAAI,MAAM,IAAI,mCAAmC,KAAK,MAAM,CAAE,QAAO,KAAK,UAAU,MAAM;AAC9I,QAAO;;AAER,MAAM,kBAAkB,OAAO,WAAW;AACzC,KAAI,UAAU,QAAQ,UAAU,KAAK,EAAG,QAAO;AAC/C,KAAI,OAAO,UAAU,aAAa,OAAO,UAAU,SAAU,QAAO,OAAO,MAAM;AACjF,KAAI,OAAO,UAAU,SAAU,QAAO,gBAAgB,OAAO,OAAO;AACpE,KAAI,MAAM,QAAQ,MAAM,EAAE;AACzB,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SAAO,MAAM,KAAK,SAAS;GAC1B,MAAM,aAAa,eAAe,MAAM,GAAG,OAAO,IAAI;AACtD,OAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,CAAC,MAAM,QAAQ,KAAK,IAAI,CAAC,WAAW,WAAW,IAAI,IAAI,CAAC,WAAW,WAAW,KAAK,EAAE;IACrI,MAAM,QAAQ,WAAW,MAAM,KAAK;AACpC,WAAO,GAAG,OAAO,IAAI,MAAM,GAAG,IAAI,MAAM,MAAM,EAAE,CAAC,KAAK,MAAM,GAAG,OAAO,IAAI,IAAI,CAAC,KAAK,KAAK,GAAG,SAAS;;AAEtG,UAAO,GAAG,OAAO,IAAI;IACpB,CAAC,KAAK,KAAK;;AAEd,KAAI,OAAO,UAAU,UAAU;EAC9B,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,QAAQ,GAAG,OAAO,MAAM,KAAK,EAAE;AACrE,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,SAAO,QAAQ,KAAK,CAAC,GAAG,WAAW;GAClC,MAAM,MAAM,aAAa,KAAK,EAAE,GAAG,KAAK,UAAU,EAAE,GAAG;GACvD,MAAM,cAAc,GAAG,OAAO;AAC9B,OAAI,UAAU,QAAQ,UAAU,KAAK,EAAG,QAAO,GAAG,SAAS,IAAI;AAC/D,OAAI,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,CAAE,QAAO,GAAG,SAAS,IAAI,KAAK,eAAe,OAAO,YAAY;AACtH,OAAI,MAAM,QAAQ,MAAM,EAAE;AACzB,QAAI,MAAM,WAAW,EAAG,QAAO,GAAG,SAAS,IAAI;AAC/C,WAAO,GAAG,SAAS,IAAI,KAAK,eAAe,OAAO,YAAY;;AAE/D,UAAO,GAAG,SAAS,IAAI,IAAI,eAAe,OAAO,OAAO;IACvD,CAAC,KAAK,KAAK;;AAEd,QAAO,OAAO,MAAM;;AAErB,MAAM,iBAAiB,UAAU,GAAG,eAAe,OAAO,GAAG,CAAC"}
|