@intlayer/chokidar 7.4.0 → 7.5.0-canary.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/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +14 -9
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +2 -2
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/formatDictionary.cjs +49 -0
- package/dist/cjs/formatDictionary.cjs.map +1 -0
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +12 -12
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/utils/getComponentTransformPattern.cjs +5 -5
- package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/index.cjs +1 -1
- package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +14 -9
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +2 -2
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
- package/dist/esm/formatDictionary.mjs +45 -0
- package/dist/esm/formatDictionary.mjs.map +1 -0
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +4 -4
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +12 -12
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs +1 -1
- package/dist/esm/utils/formatter.mjs.map +1 -1
- package/dist/esm/utils/getComponentTransformPattern.mjs +3 -3
- package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
- package/dist/esm/utils/runParallel/index.mjs +1 -1
- package/dist/esm/utils/runParallel/index.mjs.map +1 -1
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
- package/dist/types/formatDictionary.d.ts +54 -0
- package/dist/types/formatDictionary.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/listDictionariesPath.d.ts +2 -2
- package/dist/types/listDictionariesPath.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
- package/dist/types/utils/chunkJSON.d.ts.map +1 -1
- package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -12,8 +12,8 @@ let __intlayer_config = require("@intlayer/config");
|
|
|
12
12
|
let node_path = require("node:path");
|
|
13
13
|
|
|
14
14
|
//#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts
|
|
15
|
-
const writeDictionaryFiles = async (paths, fileName, functionName, format, configuration = (0, __intlayer_config.getConfiguration)()) => {
|
|
16
|
-
const content = require_createDictionaryEntryPoint_generateDictionaryListContent.generateDictionaryListContent(await paths, functionName, format, configuration);
|
|
15
|
+
const writeDictionaryFiles = async (paths, fileName, importType, functionName, format, configuration = (0, __intlayer_config.getConfiguration)()) => {
|
|
16
|
+
const content = require_createDictionaryEntryPoint_generateDictionaryListContent.generateDictionaryListContent(await paths, functionName, importType, format, configuration);
|
|
17
17
|
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
18
18
|
const { mainDir } = configuration.content;
|
|
19
19
|
await require_writeFileIfChanged.writeFileIfChanged((0, node_path.resolve)(mainDir, `${fileName}.${extension}`), content);
|
|
@@ -26,37 +26,42 @@ const createDictionaryEntryPoint = async (configuration = (0, __intlayer_config.
|
|
|
26
26
|
const { mainDir } = configuration.content;
|
|
27
27
|
await (0, node_fs_promises.mkdir)(mainDir, { recursive: true });
|
|
28
28
|
await require_utils_parallelize.parallelize([
|
|
29
|
-
...outputFormats.map((format) => ({
|
|
30
|
-
paths: require_createDictionaryEntryPoint_getBuiltRemoteDictionariesPath.getBuiltRemoteDictionariesPath(configuration),
|
|
31
|
-
functionName: "getRemoteDictionaries",
|
|
32
|
-
fileName: "remote_dictionaries",
|
|
33
|
-
format
|
|
34
|
-
})),
|
|
35
29
|
...outputFormats.map((format) => ({
|
|
36
30
|
paths: require_createDictionaryEntryPoint_getBuiltDictionariesPath.getBuiltDictionariesPath(configuration),
|
|
31
|
+
importType: "json",
|
|
37
32
|
functionName: "getDictionaries",
|
|
38
33
|
fileName: "dictionaries",
|
|
39
34
|
format
|
|
40
35
|
})),
|
|
41
36
|
...outputFormats.map((format) => ({
|
|
42
37
|
paths: require_createDictionaryEntryPoint_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath(configuration),
|
|
38
|
+
importType: "json",
|
|
43
39
|
functionName: "getUnmergedDictionaries",
|
|
44
40
|
fileName: "unmerged_dictionaries",
|
|
45
41
|
format
|
|
46
42
|
})),
|
|
47
43
|
...outputFormats.map((format) => ({
|
|
48
44
|
paths: require_createDictionaryEntryPoint_getBuiltDynamicDictionariesPath.getBuiltDynamicDictionariesPath(configuration, format),
|
|
45
|
+
importType: "javascript",
|
|
49
46
|
functionName: "getDynamicDictionaries",
|
|
50
47
|
fileName: "dynamic_dictionaries",
|
|
51
48
|
format
|
|
52
49
|
})),
|
|
53
50
|
...outputFormats.map((format) => ({
|
|
54
51
|
paths: require_createDictionaryEntryPoint_getBuiltFetchDictionariesPath.getBuiltFetchDictionariesPath(configuration, format),
|
|
52
|
+
importType: "javascript",
|
|
55
53
|
functionName: "getFetchDictionaries",
|
|
56
54
|
fileName: "fetch_dictionaries",
|
|
57
55
|
format
|
|
56
|
+
})),
|
|
57
|
+
...outputFormats.map((format) => ({
|
|
58
|
+
paths: require_createDictionaryEntryPoint_getBuiltRemoteDictionariesPath.getBuiltRemoteDictionariesPath(configuration),
|
|
59
|
+
importType: "json",
|
|
60
|
+
functionName: "getRemoteDictionaries",
|
|
61
|
+
fileName: "remote_dictionaries",
|
|
62
|
+
format
|
|
58
63
|
}))
|
|
59
|
-
], async ({ paths, fileName, format, functionName }) => writeDictionaryFiles(paths, fileName, functionName, format, configuration));
|
|
64
|
+
], async ({ paths, fileName, format, functionName, importType }) => writeDictionaryFiles(paths, fileName, importType, functionName, format, configuration));
|
|
60
65
|
};
|
|
61
66
|
|
|
62
67
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDictionaryEntryPoint.cjs","names":["generateDictionaryListContent","writeFileIfChanged","parallelize","
|
|
1
|
+
{"version":3,"file":"createDictionaryEntryPoint.cjs","names":["generateDictionaryListContent","writeFileIfChanged","parallelize","getBuiltDictionariesPath","getBuiltUnmergedDictionariesPath","getBuiltDynamicDictionariesPath","getBuiltFetchDictionariesPath","getBuiltRemoteDictionariesPath"],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\nimport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from './getBuiltDynamicDictionariesPath';\nimport { getBuiltFetchDictionariesPath } from './getBuiltFetchDictionariesPath';\nimport { getBuiltRemoteDictionariesPath } from './getBuiltRemoteDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\n\nconst writeDictionaryFiles = async (\n paths: Promise<string[]>,\n fileName: string,\n importType: 'json' | 'javascript',\n functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(\n await paths,\n functionName,\n importType,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n formats?: ('cjs' | 'esm')[]\n) => {\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.content;\n\n await mkdir(mainDir, { recursive: true });\n\n const writeOperations = [\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDictionariesPath(configuration),\n importType: 'json',\n functionName: 'getDictionaries',\n fileName: 'dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltUnmergedDictionariesPath(configuration),\n importType: 'json',\n functionName: 'getUnmergedDictionaries',\n fileName: 'unmerged_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDynamicDictionariesPath(configuration, format),\n importType: 'javascript',\n functionName: 'getDynamicDictionaries',\n fileName: 'dynamic_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltFetchDictionariesPath(configuration, format),\n importType: 'javascript',\n functionName: 'getFetchDictionaries',\n fileName: 'fetch_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltRemoteDictionariesPath(configuration),\n importType: 'json',\n functionName: 'getRemoteDictionaries',\n fileName: 'remote_dictionaries' as const,\n format,\n }) as const\n ),\n ];\n\n await parallelize(\n writeOperations,\n async ({ paths, fileName, format, functionName, importType }) =>\n writeDictionaryFiles(\n paths,\n fileName,\n importType,\n functionName,\n format,\n configuration\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,uBAAuB,OAC3B,OACA,UACA,YACA,cACA,QACA,yDAAkC,KAC/B;CACH,MAAM,UAAUA,+FACd,MAAM,OACN,cACA,YACA,QACA,cACD;CACD,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAE7C,MAAM,EAAE,YAAY,cAAc;AAElC,OAAMC,qEACI,SAAS,GAAG,SAAS,GAAG,YAAY,EAC5C,QACD;;;;;AAMH,MAAa,6BAA6B,OACxC,yDAAkC,EAClC,YACG;CACH,MAAM,gBAAgB,WAAW,cAAc,MAAM;CACrD,MAAM,EAAE,YAAY,cAAc;AAElC,mCAAY,SAAS,EAAE,WAAW,MAAM,CAAC;AAuDzC,OAAMC,sCArDkB;EACtB,GAAG,cAAc,KACd,YACE;GACC,OAAOC,qFAAyB,cAAc;GAC9C,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAOC,qGAAiC,cAAc;GACtD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAOC,mGAAgC,eAAe,OAAO;GAC7D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAOC,+FAA8B,eAAe,OAAO;GAC3D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAOC,iGAA+B,cAAc;GACpD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACF,EAIC,OAAO,EAAE,OAAO,UAAU,QAAQ,cAAc,iBAC9C,qBACE,OACA,UACA,YACA,cACA,QACA,cACD,CACJ"}
|
|
@@ -7,7 +7,7 @@ let node_path = require("node:path");
|
|
|
7
7
|
/**
|
|
8
8
|
* This function generates the content of the dictionary list file
|
|
9
9
|
*/
|
|
10
|
-
const generateDictionaryListContent = (dictionaries, functionName, format = "esm", configuration = (0, __intlayer_config.getConfiguration)()) => {
|
|
10
|
+
const generateDictionaryListContent = (dictionaries, functionName, importType, format = "esm", configuration = (0, __intlayer_config.getConfiguration)()) => {
|
|
11
11
|
const { mainDir } = configuration.content;
|
|
12
12
|
let content = "";
|
|
13
13
|
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
@@ -16,7 +16,7 @@ const generateDictionaryListContent = (dictionaries, functionName, format = "esm
|
|
|
16
16
|
hash: `_${require_utils_getFileHash.getFileHash(dictionaryPath)}`
|
|
17
17
|
}));
|
|
18
18
|
dictionariesRef.forEach((dictionary) => {
|
|
19
|
-
if (format === "esm") content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\n`;
|
|
19
|
+
if (format === "esm") content += `import ${dictionary.hash} from '${dictionary.relativePath}'${importType === "json" ? " with { type: 'json' }" : ""};\n`;
|
|
20
20
|
if (format === "cjs") content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\n`;
|
|
21
21
|
});
|
|
22
22
|
content += "\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateDictionaryListContent.cjs","names":["getFileHash","formattedDictionaryMap: string"],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":["import { basename, extname, relative } from 'node:path';\nimport { getConfiguration, normalizePath } from '@intlayer/config';\nimport { getFileHash } from '../utils/getFileHash';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n functionName: string,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n content += `const dictionaries = {\\n${formattedDictionaryMap}\\n};\\n`;\n content += `const ${functionName} = () => dictionaries;\\n`;\n\n if (format === 'esm') {\n content += `\\n`;\n content += `export { ${functionName} };\\n`;\n content += `export default dictionaries;\\n`;\n }\n\n if (format === 'cjs') {\n content += `\\n`;\n content += `module.exports.${functionName} = ${functionName};\\n`;\n content += `module.exports = dictionaries;\\n`;\n }\n\n return content;\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,iCACX,cACA,cACA,SAAwB,OACxB,yDAAkC,KACvB;CACX,MAAM,EAAE,YAAY,cAAc;CAElC,IAAI,UAAU;CAEd,MAAM,kBAAkB,aAAa,KAAK,oBAAoB;EAC5D,2EAAqC,SAAS,eAAe,CAAC;EAC9D,4BAAa,uCAAwB,eAAe,CAAC;EACrD,MAAM,IAAIA,sCAAY,eAAe;EACtC,EAAE;AAGH,iBAAgB,SAAS,eAAe;AACtC,MAAI,WAAW,MACb,YAAW,UAAU,WAAW,KAAK,SAAS,WAAW,aAAa;
|
|
1
|
+
{"version":3,"file":"generateDictionaryListContent.cjs","names":["getFileHash","formattedDictionaryMap: string"],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":["import { basename, extname, relative } from 'node:path';\nimport { getConfiguration, normalizePath } from '@intlayer/config';\nimport { getFileHash } from '../utils/getFileHash';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n functionName: string,\n importType: 'json' | 'javascript',\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}'${importType === 'json' ? \" with { type: 'json' }\" : ''};\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n content += `const dictionaries = {\\n${formattedDictionaryMap}\\n};\\n`;\n content += `const ${functionName} = () => dictionaries;\\n`;\n\n if (format === 'esm') {\n content += `\\n`;\n content += `export { ${functionName} };\\n`;\n content += `export default dictionaries;\\n`;\n }\n\n if (format === 'cjs') {\n content += `\\n`;\n content += `module.exports.${functionName} = ${functionName};\\n`;\n content += `module.exports = dictionaries;\\n`;\n }\n\n return content;\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,iCACX,cACA,cACA,YACA,SAAwB,OACxB,yDAAkC,KACvB;CACX,MAAM,EAAE,YAAY,cAAc;CAElC,IAAI,UAAU;CAEd,MAAM,kBAAkB,aAAa,KAAK,oBAAoB;EAC5D,2EAAqC,SAAS,eAAe,CAAC;EAC9D,4BAAa,uCAAwB,eAAe,CAAC;EACrD,MAAM,IAAIA,sCAAY,eAAe;EACtC,EAAE;AAGH,iBAAgB,SAAS,eAAe;AACtC,MAAI,WAAW,MACb,YAAW,UAAU,WAAW,KAAK,SAAS,WAAW,aAAa,GAAG,eAAe,SAAS,2BAA2B,GAAG;AACjI,MAAI,WAAW,MACb,YAAW,SAAS,WAAW,KAAK,cAAc,WAAW,aAAa;GAC5E;AAEF,YAAW;CAGX,MAAMC,yBAAiC,gBACpC,KAAK,eAAe,MAAM,WAAW,GAAG,KAAK,WAAW,OAAO,CAC/D,KAAK,MAAM;AAEd,YAAW,2BAA2B,uBAAuB;AAC7D,YAAW,SAAS,aAAa;AAEjC,KAAI,WAAW,OAAO;AACpB,aAAW;AACX,aAAW,YAAY,aAAa;AACpC,aAAW;;AAGb,KAAI,WAAW,OAAO;AACpB,aAAW;AACX,aAAW,kBAAkB,aAAa,KAAK,aAAa;AAC5D,aAAW;;AAGb,QAAO"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __intlayer_core_messageFormat = require("@intlayer/core/messageFormat");
|
|
3
|
+
|
|
4
|
+
//#region src/formatDictionary.ts
|
|
5
|
+
const formatDictionary = (dictionary) => {
|
|
6
|
+
if (dictionary.format === "icu") return {
|
|
7
|
+
...dictionary,
|
|
8
|
+
format: "intlayer",
|
|
9
|
+
content: (0, __intlayer_core_messageFormat.icuToIntlayerFormatter)(dictionary.content)
|
|
10
|
+
};
|
|
11
|
+
if (dictionary.format === "i18next") return {
|
|
12
|
+
...dictionary,
|
|
13
|
+
format: "intlayer",
|
|
14
|
+
content: (0, __intlayer_core_messageFormat.i18nextToIntlayerFormatter)(dictionary.content)
|
|
15
|
+
};
|
|
16
|
+
if (dictionary.format === "vue-i18n") return {
|
|
17
|
+
...dictionary,
|
|
18
|
+
format: "intlayer",
|
|
19
|
+
content: (0, __intlayer_core_messageFormat.vueI18nToIntlayerFormatter)(dictionary.content)
|
|
20
|
+
};
|
|
21
|
+
return dictionary;
|
|
22
|
+
};
|
|
23
|
+
const formatDictionaries = (dictionaries) => dictionaries.map(formatDictionary);
|
|
24
|
+
const formatDictionaryOutput = (dictionary) => {
|
|
25
|
+
if (dictionary.format === "icu") return {
|
|
26
|
+
...dictionary,
|
|
27
|
+
format: "icu",
|
|
28
|
+
content: (0, __intlayer_core_messageFormat.intlayerToICUFormatter)(dictionary.content)
|
|
29
|
+
};
|
|
30
|
+
if (dictionary.format === "i18next") return {
|
|
31
|
+
...dictionary,
|
|
32
|
+
format: "i18next",
|
|
33
|
+
content: (0, __intlayer_core_messageFormat.intlayerToI18nextFormatter)(dictionary.content)
|
|
34
|
+
};
|
|
35
|
+
if (dictionary.format === "vue-i18n") return {
|
|
36
|
+
...dictionary,
|
|
37
|
+
format: "vue-i18n",
|
|
38
|
+
content: (0, __intlayer_core_messageFormat.intlayerToVueI18nFormatter)(dictionary.content)
|
|
39
|
+
};
|
|
40
|
+
return dictionary;
|
|
41
|
+
};
|
|
42
|
+
const formatDictionariesOutput = (dictionaries) => dictionaries.map(formatDictionaryOutput);
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.formatDictionaries = formatDictionaries;
|
|
46
|
+
exports.formatDictionariesOutput = formatDictionariesOutput;
|
|
47
|
+
exports.formatDictionary = formatDictionary;
|
|
48
|
+
exports.formatDictionaryOutput = formatDictionaryOutput;
|
|
49
|
+
//# sourceMappingURL=formatDictionary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDictionary.cjs","names":[],"sources":["../../src/formatDictionary.ts"],"sourcesContent":["import {\n i18nextToIntlayerFormatter,\n icuToIntlayerFormatter,\n intlayerToI18nextFormatter,\n intlayerToICUFormatter,\n intlayerToVueI18nFormatter,\n vueI18nToIntlayerFormatter,\n} from '@intlayer/core/messageFormat';\nimport type { Dictionary } from '@intlayer/types';\n\nexport const formatDictionary = (dictionary: Dictionary): Dictionary => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: icuToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: i18nextToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: vueI18nToIntlayerFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionaries = (dictionaries: Dictionary[]): Dictionary[] =>\n dictionaries.map(formatDictionary);\n\nexport const formatDictionaryOutput = (dictionary: Dictionary) => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'icu',\n content: intlayerToICUFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'i18next',\n content: intlayerToI18nextFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'vue-i18n',\n content: intlayerToVueI18nFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionariesOutput = (dictionaries: Dictionary[]) =>\n dictionaries.map(formatDictionaryOutput);\n"],"mappings":";;;;AAUA,MAAa,oBAAoB,eAAuC;AACtE,KAAI,WAAW,WAAW,MACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,mEAAgC,WAAW,QAAQ;EACpD;AAGH,KAAI,WAAW,WAAW,UACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,uEAAoC,WAAW,QAAQ;EACxD;AAGH,KAAI,WAAW,WAAW,WACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,uEAAoC,WAAW,QAAQ;EACxD;AAGH,QAAO;;AAGT,MAAa,sBAAsB,iBACjC,aAAa,IAAI,iBAAiB;AAEpC,MAAa,0BAA0B,eAA2B;AAChE,KAAI,WAAW,WAAW,MACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,mEAAgC,WAAW,QAAQ;EACpD;AAGH,KAAI,WAAW,WAAW,UACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,uEAAoC,WAAW,QAAQ;EACxD;AAGH,KAAI,WAAW,WAAW,WACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,uEAAoC,WAAW,QAAQ;EACxD;AAGH,QAAO;;AAGT,MAAa,4BAA4B,iBACvC,aAAa,IAAI,uBAAuB"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ const require_utils_parallelize = require('./utils/parallelize.cjs');
|
|
|
4
4
|
const require_fetchDistantDictionaries = require('./fetchDistantDictionaries.cjs');
|
|
5
5
|
const require_utils_formatter = require('./utils/formatter.cjs');
|
|
6
6
|
const require_filterInvalidDictionaries = require('./filterInvalidDictionaries.cjs');
|
|
7
|
+
const require_formatDictionary = require('./formatDictionary.cjs');
|
|
7
8
|
const require_buildIntlayerDictionary_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
|
|
8
9
|
const require_utils_getFileHash = require('./utils/getFileHash.cjs');
|
|
9
10
|
const require_createDictionaryEntryPoint_generateDictionaryListContent = require('./createDictionaryEntryPoint/generateDictionaryListContent.cjs');
|
|
@@ -64,6 +65,10 @@ exports.detectFormatCommand = require_writeContentDeclaration_detectFormatComman
|
|
|
64
65
|
exports.extractDictionaryKey = require_transformFiles_extractDictionaryKey.extractDictionaryKey;
|
|
65
66
|
exports.extractIntlayer = require_transformFiles_transformFiles.extractIntlayer;
|
|
66
67
|
exports.fetchDistantDictionaries = require_fetchDistantDictionaries.fetchDistantDictionaries;
|
|
68
|
+
exports.formatDictionaries = require_formatDictionary.formatDictionaries;
|
|
69
|
+
exports.formatDictionariesOutput = require_formatDictionary.formatDictionariesOutput;
|
|
70
|
+
exports.formatDictionary = require_formatDictionary.formatDictionary;
|
|
71
|
+
exports.formatDictionaryOutput = require_formatDictionary.formatDictionaryOutput;
|
|
67
72
|
exports.formatLocale = require_utils_formatter.formatLocale;
|
|
68
73
|
exports.formatPath = require_utils_formatter.formatPath;
|
|
69
74
|
exports.generateDictionaryListContent = require_createDictionaryEntryPoint_generateDictionaryListContent.generateDictionaryListContent;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_filterInvalidDictionaries = require('../filterInvalidDictionaries.cjs');
|
|
3
|
+
const require_formatDictionary = require('../formatDictionary.cjs');
|
|
3
4
|
const require_loadDictionaries_loadContentDeclaration = require('./loadContentDeclaration.cjs');
|
|
4
5
|
const require_loadDictionaries_loadRemoteDictionaries = require('./loadRemoteDictionaries.cjs');
|
|
5
6
|
const require_loadDictionaries_log = require('./log.cjs');
|
|
@@ -41,11 +42,11 @@ const printSummary = (configuration) => {
|
|
|
41
42
|
if (configuration.log.mode !== "verbose") return;
|
|
42
43
|
const appLogger = (0, __intlayer_config_client.getAppLogger)(configuration);
|
|
43
44
|
const byKey = /* @__PURE__ */ new Map();
|
|
44
|
-
for (const
|
|
45
|
-
const rec = byKey.get(
|
|
46
|
-
if (
|
|
47
|
-
if (
|
|
48
|
-
byKey.set(
|
|
45
|
+
for (const status of loadDictionariesStatus) {
|
|
46
|
+
const rec = byKey.get(status.dictionaryKey) ?? {};
|
|
47
|
+
if (status.type === "local") rec.local = status.status;
|
|
48
|
+
if (status.type === "remote") rec.remote = status.status;
|
|
49
|
+
byKey.set(status.dictionaryKey, rec);
|
|
49
50
|
}
|
|
50
51
|
const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));
|
|
51
52
|
let maxLocalLabelLen = 0;
|
|
@@ -96,12 +97,11 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
96
97
|
return [];
|
|
97
98
|
}
|
|
98
99
|
});
|
|
99
|
-
const pluginDictionaries =
|
|
100
|
-
const localDictionaries = await require_loadDictionaries_loadContentDeclaration.loadContentDeclarations(Array.isArray(contentDeclarationsPaths) ? contentDeclarationsPaths : [contentDeclarationsPaths], configuration, setLoadDictionariesStatus);
|
|
100
|
+
const pluginDictionaries = await Promise.all(loadPluginDictionariesPromise).then((dictionaries) => dictionaries.flat()).then((dictionaries) => require_filterInvalidDictionaries.filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => require_formatDictionary.formatDictionaries(dictionaries));
|
|
101
|
+
const localDictionaries = await require_loadDictionaries_loadContentDeclaration.loadContentDeclarations(Array.isArray(contentDeclarationsPaths) ? contentDeclarationsPaths : [contentDeclarationsPaths], configuration, setLoadDictionariesStatus).then((dictionaries) => require_filterInvalidDictionaries.filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => require_formatDictionary.formatDictionaries(dictionaries));
|
|
101
102
|
const localDictionariesTime = Date.now();
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
dictionaryKey: dict.key,
|
|
103
|
+
setLoadDictionariesStatus(localDictionaries.map((dictionary) => ({
|
|
104
|
+
dictionaryKey: dictionary.key,
|
|
105
105
|
type: "local",
|
|
106
106
|
status: "built"
|
|
107
107
|
})));
|
|
@@ -112,13 +112,13 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
112
112
|
onStartRemoteCheck: () => logger.startRemoteCheck(),
|
|
113
113
|
onStopRemoteCheck: () => logger.stopRemoteCheck(),
|
|
114
114
|
onError: (e) => logger.setRemoteError(e)
|
|
115
|
-
});
|
|
115
|
+
}).then((dictionaries) => require_filterInvalidDictionaries.filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => require_formatDictionary.formatDictionaries(dictionaries));
|
|
116
116
|
const remoteDictionariesTime = Date.now();
|
|
117
117
|
const pluginDictionariesTime = Date.now();
|
|
118
118
|
logger.finish();
|
|
119
119
|
printSummary(configuration);
|
|
120
120
|
return {
|
|
121
|
-
localDictionaries
|
|
121
|
+
localDictionaries,
|
|
122
122
|
remoteDictionaries,
|
|
123
123
|
pluginDictionaries,
|
|
124
124
|
time: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDictionaries.cjs","names":["loadDictionariesStatus: DictionariesStatus[]","DictionariesLogger","updated: DictionariesStatus[]","ANSIColors","labels: string[]","pluginDictionaries: Dictionary[]","localDictionaries: Dictionary[]","loadContentDeclarations","filterInvalidDictionaries","remoteDictionaries: Dictionary[]","loadRemoteDictionaries"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n logger.setPluginTotal(pluginsWithLoadDictionaries.length);\n\n const completedPluginIndices = new Set<number>();\n const updatePluginProgress = () => {\n logger.setPluginDone(completedPluginIndices.size);\n };\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin, index) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n completedPluginIndices.add(index);\n updatePluginProgress();\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n completedPluginIndices.add(index);\n updatePluginProgress();\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = (\n await Promise.all(loadPluginDictionariesPromise)\n ).flat();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries = filterInvalidDictionaries(\n localDictionaries,\n configuration\n );\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n );\n }\n\n const remoteDictionariesTime = Date.now();\n\n const pluginDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - remoteDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;;AA4BA,IAAIA,yBAA+C,EAAE;AACrD,MAAM,SAAS,IAAIC,iDAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,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BAA4B,IAChE,OAAO,QAAQ,UAAU;AACvB,MAAI;GACF,MAAM,MAAM,MAAM,OAAO,mBAAmB,EAC1C,eACD,CAAC;AACF,0BAAuB,IAAI,MAAM;AACjC,yBAAsB;AACtB,UAAQ,OAAoC,EAAE;WACvC,OAAO;AACd,UAAO,eAAe,MAAe;AACrC,0BAAuB,IAAI,MAAM;AACjC,yBAAsB;AACtB,UAAO,EAAE;;GAGd;CAED,MAAME,sBACJ,MAAM,QAAQ,IAAI,8BAA8B,EAChD,MAAM;CAMR,MAAMC,oBAAkC,MAAMC,wEAJhC,MAAM,QAAQ,yBAAyB,GACjD,2BACA,CAAC,yBAAyB,EAI5B,eACA,0BACD;CAED,MAAM,wBAAwB,KAAK,KAAK;CAExC,MAAM,4BAA4BC,4DAChC,mBACA,cACD;AAWD,2BATgC,0BAA0B,KACvD,UACE;EACC,eAAe,KAAK;EACpB,MAAM;EACN,QAAQ;EACT,EACJ,CAEiD;CAElD,MAAM,wBAAwB,QAC5B,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAED,KAAI,sBAEF,QAAO,gBAAgB,KAAK;CAG9B,IAAIC,qBAAmC,EAAE;AACzC,KAAI,sBACF,sBAAqB,MAAMC,uEACzB,eACA,2BACA;EACE,0BAA0B,OAAO,kBAAkB;EACnD,yBAAyB,OAAO,iBAAiB;EACjD,UAAU,MAAM,OAAO,eAAe,EAAE;EACzC,CACF;CAGH,MAAM,yBAAyB,KAAK,KAAK;CAEzC,MAAM,yBAAyB,KAAK,KAAK;AAGzC,QAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL,mBAAmB;EACnB;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;GAC9C;EACF"}
|
|
1
|
+
{"version":3,"file":"loadDictionaries.cjs","names":["loadDictionariesStatus: DictionariesStatus[]","DictionariesLogger","updated: DictionariesStatus[]","ANSIColors","labels: string[]","pluginDictionaries: Dictionary[]","filterInvalidDictionaries","formatDictionaries","localDictionaries: Dictionary[]","loadContentDeclarations","remoteDictionaries: Dictionary[]","loadRemoteDictionaries"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n logger.setPluginTotal(pluginsWithLoadDictionaries.length);\n\n const completedPluginIndices = new Set<number>();\n const updatePluginProgress = () => {\n logger.setPluginDone(completedPluginIndices.size);\n };\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin, index) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n completedPluginIndices.add(index);\n updatePluginProgress();\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n completedPluginIndices.add(index);\n updatePluginProgress();\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n }\n\n const remoteDictionariesTime = Date.now();\n\n const pluginDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - remoteDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;AA6BA,IAAIA,yBAA+C,EAAE;AACrD,MAAM,SAAS,IAAIC,iDAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,UAAgC,CAAC,GAAG,uBAAuB;AAEjE,MAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,KACrE;AACD,MAAI,SAAS,EACX,SAAQ,SAAS;MAEjB,SAAQ,KAAK,SAAS;;AAI1B,0BAAyB;AACzB,QAAO,OAAO,SAAS;AAEvB,QAAO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d;CAED,MAAME,qBAAmC,MAAM,QAAQ,IACrD,8BACD,CACE,MAAM,iBAAiB,aAAa,MAAM,CAAC,CAC3C,MAAM,iBACLC,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAM3D,MAAMC,oBAAkC,MAAMC,wEAJhC,MAAM,QAAQ,yBAAyB,GACjD,2BACA,CAAC,yBAAyB,EAI5B,eACA,0BACD,CACE,MAAM,iBACLH,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAE3D,MAAM,wBAAwB,KAAK,KAAK;AAWxC,2BATgC,kBAAkB,KAC/C,gBACE;EACC,eAAe,WAAW;EAC1B,MAAM;EACN,QAAQ;EACT,EACJ,CAEiD;CAElD,MAAM,wBAAwB,QAC5B,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAED,KAAI,sBAEF,QAAO,gBAAgB,KAAK;CAG9B,IAAIG,qBAAmC,EAAE;AAEzC,KAAI,sBACF,sBAAqB,MAAMC,uEACzB,eACA,2BACA;EACE,0BAA0B,OAAO,kBAAkB;EACnD,yBAAyB,OAAO,iBAAiB;EACjD,UAAU,MAAM,OAAO,eAAe,EAAE;EACzC,CACF,CACE,MAAM,iBACLL,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAG7D,MAAM,yBAAyB,KAAK,KAAK;CAEzC,MAAM,yBAAyB,KAAK,KAAK;AAGzC,QAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL;EACA;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;GAC9C;EACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
2
4
|
let fast_glob = require("fast-glob");
|
|
3
5
|
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
4
|
-
let path = require("path");
|
|
5
|
-
path = require_rolldown_runtime.__toESM(path);
|
|
6
6
|
|
|
7
7
|
//#region src/utils/getComponentTransformPattern.ts
|
|
8
8
|
/**
|
|
@@ -11,12 +11,12 @@ path = require_rolldown_runtime.__toESM(path);
|
|
|
11
11
|
* This prevents scanning the same files twice.
|
|
12
12
|
*/
|
|
13
13
|
const getDistinctRootDirs = (dirs) => {
|
|
14
|
-
const uniqueDirs = Array.from(new Set(dirs.map((d) =>
|
|
14
|
+
const uniqueDirs = Array.from(new Set(dirs.map((d) => node_path.default.resolve(d))));
|
|
15
15
|
uniqueDirs.sort((a, b) => a.length - b.length);
|
|
16
16
|
return uniqueDirs.reduce((acc, dir) => {
|
|
17
17
|
if (!acc.some((parent) => {
|
|
18
|
-
const relative =
|
|
19
|
-
return !relative.startsWith("..") && !
|
|
18
|
+
const relative = node_path.default.relative(parent, dir);
|
|
19
|
+
return !relative.startsWith("..") && !node_path.default.isAbsolute(relative) && relative !== "";
|
|
20
20
|
})) acc.push(dir);
|
|
21
21
|
return acc;
|
|
22
22
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getComponentTransformPattern.cjs","names":["fg"],"sources":["../../../src/utils/getComponentTransformPattern.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\
|
|
1
|
+
{"version":3,"file":"getComponentTransformPattern.cjs","names":["path","fg"],"sources":["../../../src/utils/getComponentTransformPattern.ts"],"sourcesContent":["import path from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * Helper to remove directories that are subdirectories of others in the list.\n * Example: ['/root', '/root/src'] -> ['/root']\n * This prevents scanning the same files twice.\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n // 1. Resolve to absolute paths and remove exact duplicates\n const uniqueDirs = Array.from(new Set(dirs.map((d) => path.resolve(d))));\n\n // 2. Sort by length (shortest paths first) so parents appear before children\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n // 3. Filter out any directory that is inside a parent already in the accepted list\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const relative = path.relative(parent, dir);\n return (\n !relative.startsWith('..') && // It is inside the parent\n !path.isAbsolute(relative) && // It is not a different drive/root\n relative !== '' // It is not the parent itself (already handled by Set, but good for safety)\n );\n });\n\n if (!isNested) {\n acc.push(dir);\n }\n return acc;\n }, []);\n};\n\nexport const getComponentTransformPattern = async (\n intlayerConfig: IntlayerConfig\n): Promise<string[]> => {\n const { baseDir, contentDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out contentDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...contentDir]);\n\n const filesListPatternPromises = distinctRoots.map((cwd) =>\n fg(traversePattern, {\n cwd,\n absolute: true,\n })\n );\n\n const filesList = (await Promise.all(filesListPatternPromises)).flat();\n\n // Deduplicate files just in case of overlapping patterns or symlinks\n return Array.from(new Set(filesList));\n};\n\nexport const getComponentTransformPatternSync = (\n intlayerConfig: IntlayerConfig\n): string[] => {\n const { baseDir, contentDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out contentDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...contentDir]);\n\n const filesList = distinctRoots.flatMap((cwd) =>\n fg.sync(traversePattern, {\n cwd,\n absolute: true,\n })\n );\n\n return Array.from(new Set(filesList));\n};\n"],"mappings":";;;;;;;;;;;;AASA,MAAM,uBAAuB,SAA6B;CAExD,MAAM,aAAa,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,MAAMA,kBAAK,QAAQ,EAAE,CAAC,CAAC,CAAC;AAGxE,YAAW,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,OAAO;AAG9C,QAAO,WAAW,QAAQ,KAAe,QAAQ;AAU/C,MAAI,CATa,IAAI,MAAM,WAAW;GACpC,MAAM,WAAWA,kBAAK,SAAS,QAAQ,IAAI;AAC3C,UACE,CAAC,SAAS,WAAW,KAAK,IAC1B,CAACA,kBAAK,WAAW,SAAS,IAC1B,aAAa;IAEf,CAGA,KAAI,KAAK,IAAI;AAEf,SAAO;IACN,EAAE,CAAC;;AAGR,MAAa,+BAA+B,OAC1C,mBACsB;CACtB,MAAM,EAAE,SAAS,eAAe,eAAe;CAC/C,MAAM,EAAE,oBAAoB,eAAe;CAK3C,MAAM,2BAFgB,oBAAoB,CAAC,SAAS,GAAG,WAAW,CAAC,CAEpB,KAAK,+BAC/C,iBAAiB;EAClB;EACA,UAAU;EACX,CAAC,CACH;CAED,MAAM,aAAa,MAAM,QAAQ,IAAI,yBAAyB,EAAE,MAAM;AAGtE,QAAO,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC;;AAGvC,MAAa,oCACX,mBACa;CACb,MAAM,EAAE,SAAS,eAAe,eAAe;CAC/C,MAAM,EAAE,oBAAoB,eAAe;CAK3C,MAAM,YAFgB,oBAAoB,CAAC,SAAS,GAAG,WAAW,CAAC,CAEnC,SAAS,QACvCC,kBAAG,KAAK,iBAAiB;EACvB;EACA,UAAU;EACX,CAAC,CACH;AAED,QAAO,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC"}
|
|
@@ -27,7 +27,7 @@ const runParallel = (proc) => {
|
|
|
27
27
|
cwd: process.cwd(),
|
|
28
28
|
stdio: "inherit",
|
|
29
29
|
env: childEnv,
|
|
30
|
-
shell:
|
|
30
|
+
shell: isWin
|
|
31
31
|
};
|
|
32
32
|
const child = isArray ? args.length === 0 && /\s/.test(command) ? isWin ? spawnFunc(process.env.ComSpec ?? "cmd.exe", [
|
|
33
33
|
"/d",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["delimiter","spawnWin32","spawnPosix","signalHandlers: { event: string; handler: (...args: any[]) => void }[]"],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell:
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["delimiter","spawnWin32","spawnPosix","signalHandlers: { event: string; handler: (...args: any[]) => void }[]"],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n cleanupHandlers();\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n cleanupHandlers();\n\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n if (code === 0 || (signal && gracefulSignals.includes(signal))) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const cleanup = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n const signalHandlers: { event: string; handler: (...args: any[]) => void }[] =\n [\n { event: 'SIGINT', handler: cleanup },\n { event: 'SIGTERM', handler: cleanup },\n { event: 'SIGQUIT', handler: cleanup },\n { event: 'SIGHUP', handler: cleanup },\n ];\n\n // Register signal handlers\n signalHandlers.forEach(({ event, handler }) => {\n process.on(event as any, handler as any);\n });\n\n const cleanupHandlers = () => {\n signalHandlers.forEach(({ event, handler }) => {\n process.off(event as any, handler as any);\n });\n };\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n return { kill, result, commandText };\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAa,eAAe,SAA6C;AACvE,KAAI,CAAC,QAAS,MAAM,QAAQ,KAAK,IAAI,KAAK,WAAW,EACnD,OAAM,IAAI,MAAM,kBAAkB;CAEpC,MAAM,cAAc,MAAM,QAAQ,KAAK,GAAG,KAAK,KAAK,IAAI,GAAG;CAE3D,MAAM,UAAU,MAAM,QAAQ,KAAK;CACnC,MAAM,UAAU,UAAW,KAAkB,KAAK;CAClD,MAAM,OAAO,UAAW,KAAkB,MAAM,EAAE,GAAG,EAAE;CAGvD,MAAM,6BAAc,QAAQ,KAAK,EAAE,gBAAgB,OAAO;CAC1D,MAAM,WACJ,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,QAAQ,IAAI,aAAa,KAAK,OAAO,IACpE;CAEF,MAAM,eAAe,CAAC,QAAQ,QAAQ,IAAI,aAAa,GAAG,CACvD,OAAO,QAAQ,CACf,KAAKA,oBAAU;CAElB,MAAM,WAAW;EACf,GAAG,QAAQ;GACV,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C7C,UAAQ,GAAG,OAAc,QAAe;GACxC;CAEF,MAAM,wBAAwB;AAC5B,iBAAe,SAAS,EAAE,OAAO,cAAc;AAC7C,WAAQ,IAAI,OAAc,QAAe;IACzC;;CAGJ,MAAM,aAAa;AACjB,MAAI;AACF,SAAM,KAAK,UAAU;UACf;;AAKV,QAAO;EAAE;EAAM;EAAQ;EAAa"}
|
|
@@ -11,8 +11,8 @@ import { getConfiguration } from "@intlayer/config";
|
|
|
11
11
|
import { resolve } from "node:path";
|
|
12
12
|
|
|
13
13
|
//#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts
|
|
14
|
-
const writeDictionaryFiles = async (paths, fileName, functionName, format, configuration = getConfiguration()) => {
|
|
15
|
-
const content = generateDictionaryListContent(await paths, functionName, format, configuration);
|
|
14
|
+
const writeDictionaryFiles = async (paths, fileName, importType, functionName, format, configuration = getConfiguration()) => {
|
|
15
|
+
const content = generateDictionaryListContent(await paths, functionName, importType, format, configuration);
|
|
16
16
|
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
17
17
|
const { mainDir } = configuration.content;
|
|
18
18
|
await writeFileIfChanged(resolve(mainDir, `${fileName}.${extension}`), content);
|
|
@@ -25,37 +25,42 @@ const createDictionaryEntryPoint = async (configuration = getConfiguration(), fo
|
|
|
25
25
|
const { mainDir } = configuration.content;
|
|
26
26
|
await mkdir(mainDir, { recursive: true });
|
|
27
27
|
await parallelize([
|
|
28
|
-
...outputFormats.map((format) => ({
|
|
29
|
-
paths: getBuiltRemoteDictionariesPath(configuration),
|
|
30
|
-
functionName: "getRemoteDictionaries",
|
|
31
|
-
fileName: "remote_dictionaries",
|
|
32
|
-
format
|
|
33
|
-
})),
|
|
34
28
|
...outputFormats.map((format) => ({
|
|
35
29
|
paths: getBuiltDictionariesPath(configuration),
|
|
30
|
+
importType: "json",
|
|
36
31
|
functionName: "getDictionaries",
|
|
37
32
|
fileName: "dictionaries",
|
|
38
33
|
format
|
|
39
34
|
})),
|
|
40
35
|
...outputFormats.map((format) => ({
|
|
41
36
|
paths: getBuiltUnmergedDictionariesPath(configuration),
|
|
37
|
+
importType: "json",
|
|
42
38
|
functionName: "getUnmergedDictionaries",
|
|
43
39
|
fileName: "unmerged_dictionaries",
|
|
44
40
|
format
|
|
45
41
|
})),
|
|
46
42
|
...outputFormats.map((format) => ({
|
|
47
43
|
paths: getBuiltDynamicDictionariesPath(configuration, format),
|
|
44
|
+
importType: "javascript",
|
|
48
45
|
functionName: "getDynamicDictionaries",
|
|
49
46
|
fileName: "dynamic_dictionaries",
|
|
50
47
|
format
|
|
51
48
|
})),
|
|
52
49
|
...outputFormats.map((format) => ({
|
|
53
50
|
paths: getBuiltFetchDictionariesPath(configuration, format),
|
|
51
|
+
importType: "javascript",
|
|
54
52
|
functionName: "getFetchDictionaries",
|
|
55
53
|
fileName: "fetch_dictionaries",
|
|
56
54
|
format
|
|
55
|
+
})),
|
|
56
|
+
...outputFormats.map((format) => ({
|
|
57
|
+
paths: getBuiltRemoteDictionariesPath(configuration),
|
|
58
|
+
importType: "json",
|
|
59
|
+
functionName: "getRemoteDictionaries",
|
|
60
|
+
fileName: "remote_dictionaries",
|
|
61
|
+
format
|
|
57
62
|
}))
|
|
58
|
-
], async ({ paths, fileName, format, functionName }) => writeDictionaryFiles(paths, fileName, functionName, format, configuration));
|
|
63
|
+
], async ({ paths, fileName, format, functionName, importType }) => writeDictionaryFiles(paths, fileName, importType, functionName, format, configuration));
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDictionaryEntryPoint.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\nimport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from './getBuiltDynamicDictionariesPath';\nimport { getBuiltFetchDictionariesPath } from './getBuiltFetchDictionariesPath';\nimport { getBuiltRemoteDictionariesPath } from './getBuiltRemoteDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\n\nconst writeDictionaryFiles = async (\n paths: Promise<string[]>,\n fileName: string,\n functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(\n await paths,\n functionName,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n formats?: ('cjs' | 'esm')[]\n) => {\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.content;\n\n await mkdir(mainDir, { recursive: true });\n\n const writeOperations = [\n ...outputFormats.map((format)
|
|
1
|
+
{"version":3,"file":"createDictionaryEntryPoint.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\nimport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from './getBuiltDynamicDictionariesPath';\nimport { getBuiltFetchDictionariesPath } from './getBuiltFetchDictionariesPath';\nimport { getBuiltRemoteDictionariesPath } from './getBuiltRemoteDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\n\nconst writeDictionaryFiles = async (\n paths: Promise<string[]>,\n fileName: string,\n importType: 'json' | 'javascript',\n functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(\n await paths,\n functionName,\n importType,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n formats?: ('cjs' | 'esm')[]\n) => {\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.content;\n\n await mkdir(mainDir, { recursive: true });\n\n const writeOperations = [\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDictionariesPath(configuration),\n importType: 'json',\n functionName: 'getDictionaries',\n fileName: 'dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltUnmergedDictionariesPath(configuration),\n importType: 'json',\n functionName: 'getUnmergedDictionaries',\n fileName: 'unmerged_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDynamicDictionariesPath(configuration, format),\n importType: 'javascript',\n functionName: 'getDynamicDictionaries',\n fileName: 'dynamic_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltFetchDictionariesPath(configuration, format),\n importType: 'javascript',\n functionName: 'getFetchDictionaries',\n fileName: 'fetch_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltRemoteDictionariesPath(configuration),\n importType: 'json',\n functionName: 'getRemoteDictionaries',\n fileName: 'remote_dictionaries' as const,\n format,\n }) as const\n ),\n ];\n\n await parallelize(\n writeOperations,\n async ({ paths, fileName, format, functionName, importType }) =>\n writeDictionaryFiles(\n paths,\n fileName,\n importType,\n functionName,\n format,\n configuration\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,uBAAuB,OAC3B,OACA,UACA,YACA,cACA,QACA,gBAAgB,kBAAkB,KAC/B;CACH,MAAM,UAAU,8BACd,MAAM,OACN,cACA,YACA,QACA,cACD;CACD,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAE7C,MAAM,EAAE,YAAY,cAAc;AAElC,OAAM,mBACJ,QAAQ,SAAS,GAAG,SAAS,GAAG,YAAY,EAC5C,QACD;;;;;AAMH,MAAa,6BAA6B,OACxC,gBAAgB,kBAAkB,EAClC,YACG;CACH,MAAM,gBAAgB,WAAW,cAAc,MAAM;CACrD,MAAM,EAAE,YAAY,cAAc;AAElC,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;AAuDzC,OAAM,YArDkB;EACtB,GAAG,cAAc,KACd,YACE;GACC,OAAO,yBAAyB,cAAc;GAC9C,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,iCAAiC,cAAc;GACtD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,gCAAgC,eAAe,OAAO;GAC7D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,8BAA8B,eAAe,OAAO;GAC3D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,+BAA+B,cAAc;GACpD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACF,EAIC,OAAO,EAAE,OAAO,UAAU,QAAQ,cAAc,iBAC9C,qBACE,OACA,UACA,YACA,cACA,QACA,cACD,CACJ"}
|
|
@@ -6,7 +6,7 @@ import { basename, extname, relative } from "node:path";
|
|
|
6
6
|
/**
|
|
7
7
|
* This function generates the content of the dictionary list file
|
|
8
8
|
*/
|
|
9
|
-
const generateDictionaryListContent = (dictionaries, functionName, format = "esm", configuration = getConfiguration()) => {
|
|
9
|
+
const generateDictionaryListContent = (dictionaries, functionName, importType, format = "esm", configuration = getConfiguration()) => {
|
|
10
10
|
const { mainDir } = configuration.content;
|
|
11
11
|
let content = "";
|
|
12
12
|
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
@@ -15,7 +15,7 @@ const generateDictionaryListContent = (dictionaries, functionName, format = "esm
|
|
|
15
15
|
hash: `_${getFileHash(dictionaryPath)}`
|
|
16
16
|
}));
|
|
17
17
|
dictionariesRef.forEach((dictionary) => {
|
|
18
|
-
if (format === "esm") content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\n`;
|
|
18
|
+
if (format === "esm") content += `import ${dictionary.hash} from '${dictionary.relativePath}'${importType === "json" ? " with { type: 'json' }" : ""};\n`;
|
|
19
19
|
if (format === "cjs") content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\n`;
|
|
20
20
|
});
|
|
21
21
|
content += "\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateDictionaryListContent.mjs","names":["formattedDictionaryMap: string"],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":["import { basename, extname, relative } from 'node:path';\nimport { getConfiguration, normalizePath } from '@intlayer/config';\nimport { getFileHash } from '../utils/getFileHash';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n functionName: string,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n content += `const dictionaries = {\\n${formattedDictionaryMap}\\n};\\n`;\n content += `const ${functionName} = () => dictionaries;\\n`;\n\n if (format === 'esm') {\n content += `\\n`;\n content += `export { ${functionName} };\\n`;\n content += `export default dictionaries;\\n`;\n }\n\n if (format === 'cjs') {\n content += `\\n`;\n content += `module.exports.${functionName} = ${functionName};\\n`;\n content += `module.exports = dictionaries;\\n`;\n }\n\n return content;\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,iCACX,cACA,cACA,SAAwB,OACxB,gBAAgB,kBAAkB,KACvB;CACX,MAAM,EAAE,YAAY,cAAc;CAElC,IAAI,UAAU;CAEd,MAAM,kBAAkB,aAAa,KAAK,oBAAoB;EAC5D,cAAc,cAAc,SAAS,SAAS,eAAe,CAAC;EAC9D,IAAI,SAAS,gBAAgB,QAAQ,eAAe,CAAC;EACrD,MAAM,IAAI,YAAY,eAAe;EACtC,EAAE;AAGH,iBAAgB,SAAS,eAAe;AACtC,MAAI,WAAW,MACb,YAAW,UAAU,WAAW,KAAK,SAAS,WAAW,aAAa;
|
|
1
|
+
{"version":3,"file":"generateDictionaryListContent.mjs","names":["formattedDictionaryMap: string"],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":["import { basename, extname, relative } from 'node:path';\nimport { getConfiguration, normalizePath } from '@intlayer/config';\nimport { getFileHash } from '../utils/getFileHash';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n functionName: string,\n importType: 'json' | 'javascript',\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}'${importType === 'json' ? \" with { type: 'json' }\" : ''};\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n content += `const dictionaries = {\\n${formattedDictionaryMap}\\n};\\n`;\n content += `const ${functionName} = () => dictionaries;\\n`;\n\n if (format === 'esm') {\n content += `\\n`;\n content += `export { ${functionName} };\\n`;\n content += `export default dictionaries;\\n`;\n }\n\n if (format === 'cjs') {\n content += `\\n`;\n content += `module.exports.${functionName} = ${functionName};\\n`;\n content += `module.exports = dictionaries;\\n`;\n }\n\n return content;\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,iCACX,cACA,cACA,YACA,SAAwB,OACxB,gBAAgB,kBAAkB,KACvB;CACX,MAAM,EAAE,YAAY,cAAc;CAElC,IAAI,UAAU;CAEd,MAAM,kBAAkB,aAAa,KAAK,oBAAoB;EAC5D,cAAc,cAAc,SAAS,SAAS,eAAe,CAAC;EAC9D,IAAI,SAAS,gBAAgB,QAAQ,eAAe,CAAC;EACrD,MAAM,IAAI,YAAY,eAAe;EACtC,EAAE;AAGH,iBAAgB,SAAS,eAAe;AACtC,MAAI,WAAW,MACb,YAAW,UAAU,WAAW,KAAK,SAAS,WAAW,aAAa,GAAG,eAAe,SAAS,2BAA2B,GAAG;AACjI,MAAI,WAAW,MACb,YAAW,SAAS,WAAW,KAAK,cAAc,WAAW,aAAa;GAC5E;AAEF,YAAW;CAGX,MAAMA,yBAAiC,gBACpC,KAAK,eAAe,MAAM,WAAW,GAAG,KAAK,WAAW,OAAO,CAC/D,KAAK,MAAM;AAEd,YAAW,2BAA2B,uBAAuB;AAC7D,YAAW,SAAS,aAAa;AAEjC,KAAI,WAAW,OAAO;AACpB,aAAW;AACX,aAAW,YAAY,aAAa;AACpC,aAAW;;AAGb,KAAI,WAAW,OAAO;AACpB,aAAW;AACX,aAAW,kBAAkB,aAAa,KAAK,aAAa;AAC5D,aAAW;;AAGb,QAAO"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { i18nextToIntlayerFormatter, icuToIntlayerFormatter, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToVueI18nFormatter, vueI18nToIntlayerFormatter } from "@intlayer/core/messageFormat";
|
|
2
|
+
|
|
3
|
+
//#region src/formatDictionary.ts
|
|
4
|
+
const formatDictionary = (dictionary) => {
|
|
5
|
+
if (dictionary.format === "icu") return {
|
|
6
|
+
...dictionary,
|
|
7
|
+
format: "intlayer",
|
|
8
|
+
content: icuToIntlayerFormatter(dictionary.content)
|
|
9
|
+
};
|
|
10
|
+
if (dictionary.format === "i18next") return {
|
|
11
|
+
...dictionary,
|
|
12
|
+
format: "intlayer",
|
|
13
|
+
content: i18nextToIntlayerFormatter(dictionary.content)
|
|
14
|
+
};
|
|
15
|
+
if (dictionary.format === "vue-i18n") return {
|
|
16
|
+
...dictionary,
|
|
17
|
+
format: "intlayer",
|
|
18
|
+
content: vueI18nToIntlayerFormatter(dictionary.content)
|
|
19
|
+
};
|
|
20
|
+
return dictionary;
|
|
21
|
+
};
|
|
22
|
+
const formatDictionaries = (dictionaries) => dictionaries.map(formatDictionary);
|
|
23
|
+
const formatDictionaryOutput = (dictionary) => {
|
|
24
|
+
if (dictionary.format === "icu") return {
|
|
25
|
+
...dictionary,
|
|
26
|
+
format: "icu",
|
|
27
|
+
content: intlayerToICUFormatter(dictionary.content)
|
|
28
|
+
};
|
|
29
|
+
if (dictionary.format === "i18next") return {
|
|
30
|
+
...dictionary,
|
|
31
|
+
format: "i18next",
|
|
32
|
+
content: intlayerToI18nextFormatter(dictionary.content)
|
|
33
|
+
};
|
|
34
|
+
if (dictionary.format === "vue-i18n") return {
|
|
35
|
+
...dictionary,
|
|
36
|
+
format: "vue-i18n",
|
|
37
|
+
content: intlayerToVueI18nFormatter(dictionary.content)
|
|
38
|
+
};
|
|
39
|
+
return dictionary;
|
|
40
|
+
};
|
|
41
|
+
const formatDictionariesOutput = (dictionaries) => dictionaries.map(formatDictionaryOutput);
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput };
|
|
45
|
+
//# sourceMappingURL=formatDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDictionary.mjs","names":[],"sources":["../../src/formatDictionary.ts"],"sourcesContent":["import {\n i18nextToIntlayerFormatter,\n icuToIntlayerFormatter,\n intlayerToI18nextFormatter,\n intlayerToICUFormatter,\n intlayerToVueI18nFormatter,\n vueI18nToIntlayerFormatter,\n} from '@intlayer/core/messageFormat';\nimport type { Dictionary } from '@intlayer/types';\n\nexport const formatDictionary = (dictionary: Dictionary): Dictionary => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: icuToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: i18nextToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: vueI18nToIntlayerFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionaries = (dictionaries: Dictionary[]): Dictionary[] =>\n dictionaries.map(formatDictionary);\n\nexport const formatDictionaryOutput = (dictionary: Dictionary) => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'icu',\n content: intlayerToICUFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'i18next',\n content: intlayerToI18nextFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'vue-i18n',\n content: intlayerToVueI18nFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionariesOutput = (dictionaries: Dictionary[]) =>\n dictionaries.map(formatDictionaryOutput);\n"],"mappings":";;;AAUA,MAAa,oBAAoB,eAAuC;AACtE,KAAI,WAAW,WAAW,MACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,uBAAuB,WAAW,QAAQ;EACpD;AAGH,KAAI,WAAW,WAAW,UACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,KAAI,WAAW,WAAW,WACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,QAAO;;AAGT,MAAa,sBAAsB,iBACjC,aAAa,IAAI,iBAAiB;AAEpC,MAAa,0BAA0B,eAA2B;AAChE,KAAI,WAAW,WAAW,MACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,uBAAuB,WAAW,QAAQ;EACpD;AAGH,KAAI,WAAW,WAAW,UACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,KAAI,WAAW,WAAW,WACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,QAAO;;AAGT,MAAa,4BAA4B,iBACvC,aAAa,IAAI,uBAAuB"}
|