@intlayer/chokidar 5.5.2 → 5.5.4
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/chokidar/watcher.cjs +12 -3
- package/dist/cjs/chokidar/watcher.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs +20 -3
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/getBuiltDynamicDictionariesPath.cjs +52 -0
- package/dist/cjs/getBuiltDynamicDictionariesPath.cjs.map +1 -0
- package/dist/cjs/{filterDictionaryLocales.cjs → getFilteredLocalesContent.cjs} +24 -12
- package/dist/cjs/getFilteredLocalesContent.cjs.map +1 -0
- package/dist/cjs/index.cjs +9 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +5 -5
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs +19 -8
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.cjs +30 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.cjs +107 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.cjs +59 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.cjs +65 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +44 -35
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs +1 -1
- package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs.map +1 -1
- package/dist/esm/chokidar/watcher.mjs +12 -3
- package/dist/esm/chokidar/watcher.mjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +21 -4
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/getBuiltDynamicDictionariesPath.mjs +18 -0
- package/dist/esm/getBuiltDynamicDictionariesPath.mjs.map +1 -0
- package/dist/esm/getFilteredLocalesContent.mjs +49 -0
- package/dist/esm/getFilteredLocalesContent.mjs.map +1 -0
- package/dist/esm/index.mjs +6 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +5 -5
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs +19 -8
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.mjs +6 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.mjs +82 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.mjs +35 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.mjs +41 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +44 -35
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs +1 -1
- package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs.map +1 -1
- package/dist/types/chokidar/watcher.d.ts.map +1 -1
- package/dist/types/cleanOutputDir.d.ts.map +1 -1
- package/dist/types/getBuiltDynamicDictionariesPath.d.ts +5 -0
- package/dist/types/getBuiltDynamicDictionariesPath.d.ts.map +1 -0
- package/dist/types/getFilteredLocalesContent.d.ts +4 -0
- package/dist/types/getFilteredLocalesContent.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts +5 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/index.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts +5 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.d.ts.map +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.d.ts +2 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.d.ts +31 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.d.ts +25 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.d.ts +28 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts +1 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +1 -1
- package/package.json +14 -14
- package/dist/cjs/filterDictionaryLocales.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs +0 -95
- package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs.map +0 -1
- package/dist/esm/filterDictionaryLocales.mjs +0 -37
- package/dist/esm/filterDictionaryLocales.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs +0 -69
- package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs.map +0 -1
- package/dist/types/filterDictionaryLocales.d.ts +0 -4
- package/dist/types/filterDictionaryLocales.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts +0 -41
- package/dist/types/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.d.ts.map +0 -1
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import { mkdir } from "fs/promises";
|
|
2
|
-
import { resolve } from "path";
|
|
3
1
|
import { getConfiguration } from "@intlayer/config";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
2
|
+
import { writeDynamicDictionary } from "./writeDynamicDictionary.mjs";
|
|
3
|
+
import { writeMergedDictionaries } from "./writeMergedDictionary.mjs";
|
|
4
|
+
import { writeUnmergedDictionaries } from "./writeUnmergedDictionary.mjs";
|
|
5
|
+
const buildIntlayerDictionary = async (contentDeclarations, configuration = getConfiguration(), formats = ["cjs", "esm"]) => {
|
|
6
|
+
const unmergedDictionaries = await writeUnmergedDictionaries(
|
|
9
7
|
contentDeclarations,
|
|
10
8
|
configuration
|
|
11
9
|
);
|
|
12
|
-
|
|
10
|
+
const mergedDictionaries = await writeMergedDictionaries(
|
|
11
|
+
unmergedDictionaries,
|
|
12
|
+
configuration
|
|
13
|
+
);
|
|
14
|
+
const dynamicDictionaries = await writeDynamicDictionary(
|
|
15
|
+
mergedDictionaries,
|
|
16
|
+
configuration,
|
|
17
|
+
formats
|
|
18
|
+
);
|
|
19
|
+
return {
|
|
20
|
+
unmergedDictionaries,
|
|
21
|
+
mergedDictionaries,
|
|
22
|
+
dynamicDictionaries
|
|
23
|
+
};
|
|
13
24
|
};
|
|
14
25
|
export {
|
|
15
26
|
buildIntlayerDictionary
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"sourcesContent":["// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { writeDynamicDictionary } from './writeDynamicDictionary';\nimport { writeMergedDictionaries } from './writeMergedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildIntlayerDictionary = async (\n contentDeclarations: (DictionaryAPI | Dictionary)[],\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n) => {\n const unmergedDictionaries = await writeUnmergedDictionaries(\n contentDeclarations,\n configuration\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n const dynamicDictionaries = await writeDynamicDictionary(\n mergedDictionaries,\n configuration,\n formats\n );\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n };\n};\n"],"mappings":"AAEA,SAAS,wBAAwB;AAEjC,SAAS,8BAA8B;AACvC,SAAS,+BAA+B;AACxC,SAAS,iCAAiC;AAKnC,MAAM,0BAA0B,OACrC,qBACA,gBAAgB,iBAAiB,GACjC,UAA6B,CAAC,OAAO,KAAK,MACvC;AACH,QAAM,uBAAuB,MAAM;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,qBAAqB,MAAM;AAAA,IAC/B;AAAA,IACA;AAAA,EACF;AAEA,QAAM,sBAAsB,MAAM;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const isDevelopment = process.env.NODE_ENV === "development";
|
|
2
|
+
const formatDictionaryText = (dictionary) => isDevelopment ? JSON.stringify(dictionary, null, 2) : JSON.stringify(dictionary);
|
|
3
|
+
export {
|
|
4
|
+
formatDictionaryText
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=formatDictionaryText.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.ts"],"sourcesContent":["const isDevelopment = process.env.NODE_ENV === 'development';\n\nexport const formatDictionaryText = (dictionary: object) =>\n isDevelopment\n ? JSON.stringify(dictionary, null, 2)\n : JSON.stringify(dictionary);\n"],"mappings":"AAAA,MAAM,gBAAgB,QAAQ,IAAI,aAAa;AAExC,MAAM,uBAAuB,CAAC,eACnC,gBACI,KAAK,UAAU,YAAY,MAAM,CAAC,IAClC,KAAK,UAAU,UAAU;","names":[]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { getConfiguration } from "@intlayer/config";
|
|
2
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
3
|
+
import { relative, resolve } from "path";
|
|
4
|
+
import { getFilteredLocalesContent } from "../../../getFilteredLocalesContent.mjs";
|
|
5
|
+
import { formatDictionaryText } from "./formatDictionaryText.mjs";
|
|
6
|
+
const generateDictionaryEntryPoint = (localedDictionariesPathsRecord, format = "esm", configuration = getConfiguration()) => {
|
|
7
|
+
const { dynamicDictionariesDir } = configuration.content;
|
|
8
|
+
let content = "";
|
|
9
|
+
const formattedDictionaryMap = Object.entries(
|
|
10
|
+
localedDictionariesPathsRecord
|
|
11
|
+
).map(([locale, dictionary]) => {
|
|
12
|
+
const relativePath = relative(
|
|
13
|
+
dynamicDictionariesDir,
|
|
14
|
+
dictionary.dictionaryPath
|
|
15
|
+
);
|
|
16
|
+
if (format === "esm") {
|
|
17
|
+
return ` '${locale}': () => import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)`;
|
|
18
|
+
}
|
|
19
|
+
return ` '${locale}': () => Promise.resolve(require('./${relativePath}'))`;
|
|
20
|
+
}).join(",\n");
|
|
21
|
+
content += `const content = {
|
|
22
|
+
${formattedDictionaryMap}
|
|
23
|
+
};
|
|
24
|
+
`;
|
|
25
|
+
if (format === "esm") content += `export default content;
|
|
26
|
+
`;
|
|
27
|
+
if (format === "cjs") content += `module.exports = content;
|
|
28
|
+
`;
|
|
29
|
+
return content;
|
|
30
|
+
};
|
|
31
|
+
const writeDynamicDictionary = async (mergedDictionaries, configuration = getConfiguration(), formats = ["cjs", "esm"]) => {
|
|
32
|
+
const { locales } = configuration.internationalization;
|
|
33
|
+
const { dynamicDictionariesDir } = configuration.content;
|
|
34
|
+
await mkdir(resolve(dynamicDictionariesDir), { recursive: true });
|
|
35
|
+
let resultDictionariesPaths = {};
|
|
36
|
+
for await (const [key, dictionaryEntry] of Object.entries(
|
|
37
|
+
mergedDictionaries
|
|
38
|
+
)) {
|
|
39
|
+
if (key === "undefined") continue;
|
|
40
|
+
let localedDictionariesPathsRecord = {};
|
|
41
|
+
for await (const locale of locales) {
|
|
42
|
+
const localizedDictionary = {
|
|
43
|
+
...dictionaryEntry.dictionary,
|
|
44
|
+
locale,
|
|
45
|
+
// @ts-expect-error - Fix Type instantiation is excessively deep and possibly infinite
|
|
46
|
+
content: getFilteredLocalesContent(
|
|
47
|
+
dictionaryEntry.dictionary.content,
|
|
48
|
+
locale
|
|
49
|
+
)
|
|
50
|
+
};
|
|
51
|
+
const contentString = formatDictionaryText(localizedDictionary);
|
|
52
|
+
const outputFileName = `${key}.${locale}.json`;
|
|
53
|
+
const resultFilePath = resolve(dynamicDictionariesDir, outputFileName);
|
|
54
|
+
await writeFile(resultFilePath, contentString, "utf8").catch((err) => {
|
|
55
|
+
console.error(`Error creating localized ${outputFileName}:`, err);
|
|
56
|
+
});
|
|
57
|
+
localedDictionariesPathsRecord[locale] = {
|
|
58
|
+
dictionaryPath: resultFilePath,
|
|
59
|
+
dictionary: localizedDictionary
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
resultDictionariesPaths[key] = localedDictionariesPathsRecord;
|
|
63
|
+
for await (const format of formats) {
|
|
64
|
+
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
65
|
+
const content = generateDictionaryEntryPoint(
|
|
66
|
+
localedDictionariesPathsRecord,
|
|
67
|
+
format,
|
|
68
|
+
configuration
|
|
69
|
+
);
|
|
70
|
+
await writeFile(
|
|
71
|
+
resolve(dynamicDictionariesDir, `${key}.${extension}`),
|
|
72
|
+
content
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return resultDictionariesPaths;
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
generateDictionaryEntryPoint,
|
|
80
|
+
writeDynamicDictionary
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=writeDynamicDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { getConfiguration, Locales } from '@intlayer/config';\nimport { type Dictionary } from '@intlayer/core';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { relative, resolve } from 'path';\nimport { getFilteredLocalesContent } from '../../../getFilteredLocalesContent';\nimport { formatDictionaryText } from './formatDictionaryText';\nimport { MergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locales, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { dynamicDictionariesDir } = configuration.content;\n\n let content = '';\n\n // Format Dictionary Map - map locales to functions\n const formattedDictionaryMap: string = Object.entries(\n localedDictionariesPathsRecord\n )\n .map(([locale, dictionary]) => {\n const relativePath = relative(\n dynamicDictionariesDir,\n dictionary.dictionaryPath\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)`;\n }\n\n return ` '${locale}': () => Promise.resolve(require('./${relativePath}'))`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: MergedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { locales } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dynamicDictionariesDir), { recursive: true });\n\n let resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n for await (const [key, dictionaryEntry] of Object.entries(\n mergedDictionaries\n )) {\n if (key === 'undefined') continue;\n\n let localedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n for await (const locale of locales) {\n const localizedDictionary = {\n ...dictionaryEntry.dictionary,\n locale,\n // @ts-expect-error - Fix Type instantiation is excessively deep and possibly infinite\n content: getFilteredLocalesContent(\n dictionaryEntry.dictionary.content as any,\n locale\n ),\n };\n\n const contentString = formatDictionaryText(localizedDictionary);\n\n const outputFileName = `${key}.${locale}.json`;\n const resultFilePath = resolve(dynamicDictionariesDir, outputFileName);\n\n // Write the localized dictionary\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating localized ${outputFileName}:`, err);\n });\n\n localedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n }\n\n resultDictionariesPaths[key] = localedDictionariesPathsRecord;\n\n for await (const format of formats) {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFile(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n );\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,wBAAiC;AAE1C,SAAS,OAAO,iBAAiB;AACjC,SAAS,UAAU,eAAe;AAClC,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AAoB9B,MAAM,+BAA+B,CAC1C,gCACA,SAAwB,OACxB,gBAAgB,iBAAiB,MACtB;AACX,QAAM,EAAE,uBAAuB,IAAI,cAAc;AAEjD,MAAI,UAAU;AAGd,QAAM,yBAAiC,OAAO;AAAA,IAC5C;AAAA,EACF,EACG,IAAI,CAAC,CAAC,QAAQ,UAAU,MAAM;AAC7B,UAAM,eAAe;AAAA,MACnB;AAAA,MACA,WAAW;AAAA,IACb;AAEA,QAAI,WAAW,OAAO;AACpB,aAAO,MAAM,MAAM,sBAAsB,YAAY;AAAA,IACvD;AAEA,WAAO,MAAM,MAAM,uCAAuC,YAAY;AAAA,EACxE,CAAC,EACA,KAAK,KAAK;AAEb,aAAW;AAAA,EAAsB,sBAAsB;AAAA;AAAA;AAEvD,MAAI,WAAW,MAAO,YAAW;AAAA;AACjC,MAAI,WAAW,MAAO,YAAW;AAAA;AAEjC,SAAO;AACT;AAkBO,MAAM,yBAAyB,OACpC,oBACA,gBAAgB,iBAAiB,GACjC,UAA6B,CAAC,OAAO,KAAK,MACH;AACvC,QAAM,EAAE,QAAQ,IAAI,cAAc;AAClC,QAAM,EAAE,uBAAuB,IAAI,cAAc;AAGjD,QAAM,MAAM,QAAQ,sBAAsB,GAAG,EAAE,WAAW,KAAK,CAAC;AAEhE,MAAI,0BAAqD,CAAC;AAG1D,mBAAiB,CAAC,KAAK,eAAe,KAAK,OAAO;AAAA,IAChD;AAAA,EACF,GAAG;AACD,QAAI,QAAQ,YAAa;AAEzB,QAAI,iCAA4D,CAAC;AAEjE,qBAAiB,UAAU,SAAS;AAClC,YAAM,sBAAsB;AAAA,QAC1B,GAAG,gBAAgB;AAAA,QACnB;AAAA;AAAA,QAEA,SAAS;AAAA,UACP,gBAAgB,WAAW;AAAA,UAC3B;AAAA,QACF;AAAA,MACF;AAEA,YAAM,gBAAgB,qBAAqB,mBAAmB;AAE9D,YAAM,iBAAiB,GAAG,GAAG,IAAI,MAAM;AACvC,YAAM,iBAAiB,QAAQ,wBAAwB,cAAc;AAGrE,YAAM,UAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,4BAA4B,cAAc,KAAK,GAAG;AAAA,MAClE,CAAC;AAED,qCAA+B,MAAM,IAAI;AAAA,QACvC,gBAAgB;AAAA,QAChB,YAAY;AAAA,MACd;AAAA,IACF;AAEA,4BAAwB,GAAG,IAAI;AAE/B,qBAAiB,UAAU,SAAS;AAClC,YAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,YAAM,UAAU;AAAA,QACd;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,YAAM;AAAA,QACJ,QAAQ,wBAAwB,GAAG,GAAG,IAAI,SAAS,EAAE;AAAA,QACrD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getConfiguration } from "@intlayer/config";
|
|
2
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
3
|
+
import { resolve } from "path";
|
|
4
|
+
import { mergeDictionaries } from "../../../mergeDictionaries.mjs";
|
|
5
|
+
import { processPerLocaleDictionary } from "../../../processPerLocaleDictionary.mjs";
|
|
6
|
+
import { formatDictionaryText } from "./formatDictionaryText.mjs";
|
|
7
|
+
const writeMergedDictionaries = async (groupedDictionaries, configuration = getConfiguration()) => {
|
|
8
|
+
const { dictionariesDir } = configuration.content;
|
|
9
|
+
await mkdir(resolve(dictionariesDir), { recursive: true });
|
|
10
|
+
let resultDictionariesPaths = {};
|
|
11
|
+
for await (const [key, dictionariesEntry] of Object.entries(
|
|
12
|
+
groupedDictionaries
|
|
13
|
+
)) {
|
|
14
|
+
if (key === "undefined") continue;
|
|
15
|
+
const multiLocaleDictionaries = dictionariesEntry.dictionaries.map(
|
|
16
|
+
(dictionary) => processPerLocaleDictionary(dictionary)
|
|
17
|
+
);
|
|
18
|
+
const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);
|
|
19
|
+
const contentString = formatDictionaryText(mergedDictionary);
|
|
20
|
+
const outputFileName = `${key}.json`;
|
|
21
|
+
const resultFilePath = resolve(dictionariesDir, outputFileName);
|
|
22
|
+
await writeFile(resultFilePath, contentString, "utf8").catch((err) => {
|
|
23
|
+
console.error(`Error creating merged ${outputFileName}:`, err);
|
|
24
|
+
});
|
|
25
|
+
resultDictionariesPaths[key] = {
|
|
26
|
+
dictionaryPath: resultFilePath,
|
|
27
|
+
dictionary: mergedDictionary
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return resultDictionariesPaths;
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
writeMergedDictionaries
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=writeMergedDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { mergeDictionaries } from '../../../mergeDictionaries';\nimport { processPerLocaleDictionary } from '../../../processPerLocaleDictionary';\nimport { formatDictionaryText } from './formatDictionaryText';\nimport { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration = getConfiguration()\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n let resultDictionariesPaths: MergedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n for await (const [key, dictionariesEntry] of Object.entries(\n groupedDictionaries\n )) {\n if (key === 'undefined') continue;\n\n const multiLocaleDictionaries = dictionariesEntry.dictionaries.map(\n (dictionary) => processPerLocaleDictionary(dictionary)\n );\n\n const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);\n\n const contentString = formatDictionaryText(mergedDictionary);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating merged ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths[key] = {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n };\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,OAAO,iBAAiB;AACjC,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,kCAAkC;AAC3C,SAAS,4BAA4B;AA0B9B,MAAM,0BAA0B,OACrC,qBACA,gBAAgB,iBAAiB,MACG;AACpC,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAG1C,QAAM,MAAM,QAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;AAEzD,MAAI,0BAAkD,CAAC;AAGvD,mBAAiB,CAAC,KAAK,iBAAiB,KAAK,OAAO;AAAA,IAClD;AAAA,EACF,GAAG;AACD,QAAI,QAAQ,YAAa;AAEzB,UAAM,0BAA0B,kBAAkB,aAAa;AAAA,MAC7D,CAAC,eAAe,2BAA2B,UAAU;AAAA,IACvD;AAEA,UAAM,mBAAmB,kBAAkB,uBAAuB;AAElE,UAAM,gBAAgB,qBAAqB,gBAAgB;AAE3D,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,iBAAiB,QAAQ,iBAAiB,cAAc;AAG9D,UAAM,UAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,yBAAyB,cAAc,KAAK,GAAG;AAAA,IAC/D,CAAC;AAED,4BAAwB,GAAG,IAAI;AAAA,MAC7B,gBAAgB;AAAA,MAChB,YAAY;AAAA,IACd;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getConfiguration } from "@intlayer/config";
|
|
2
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
3
|
+
import { resolve } from "path";
|
|
4
|
+
import { formatDictionaryText } from "./formatDictionaryText.mjs";
|
|
5
|
+
const groupDictionariesByKey = (dictionaries) => {
|
|
6
|
+
return dictionaries.reduce(
|
|
7
|
+
(acc, dictionary) => {
|
|
8
|
+
const key = dictionary.key;
|
|
9
|
+
if (!acc[key]) {
|
|
10
|
+
acc[key] = [];
|
|
11
|
+
}
|
|
12
|
+
acc[key].push(dictionary);
|
|
13
|
+
return acc;
|
|
14
|
+
},
|
|
15
|
+
{}
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
const writeUnmergedDictionaries = async (dictionaries, configuration = getConfiguration()) => {
|
|
19
|
+
const { unmergedDictionariesDir } = configuration.content;
|
|
20
|
+
await mkdir(resolve(unmergedDictionariesDir), { recursive: true });
|
|
21
|
+
const groupedDictionaries = groupDictionariesByKey(dictionaries);
|
|
22
|
+
let resultDictionariesPaths = {};
|
|
23
|
+
for await (const [key, dictionaries2] of Object.entries(groupedDictionaries)) {
|
|
24
|
+
if (key === "undefined") continue;
|
|
25
|
+
const contentString = formatDictionaryText(dictionaries2);
|
|
26
|
+
const outputFileName = `${key}.json`;
|
|
27
|
+
const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);
|
|
28
|
+
await writeFile(unmergedFilePath, contentString, "utf8").catch((err) => {
|
|
29
|
+
console.error(`Error creating unmerged ${outputFileName}:`, err);
|
|
30
|
+
});
|
|
31
|
+
resultDictionariesPaths[key] = {
|
|
32
|
+
dictionaryPath: unmergedFilePath,
|
|
33
|
+
dictionaries: dictionaries2
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return resultDictionariesPaths;
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
writeUnmergedDictionaries
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=writeUnmergedDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { formatDictionaryText } from './formatDictionaryText';\n\nconst groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> => {\n return dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n};\n\nexport type UnmergedDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type UnmergedDictionaryOutput = Record<string, UnmergedDictionaryResult>;\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(dictionaries);\n\n let resultDictionariesPaths: UnmergedDictionaryOutput = {};\n\n for await (const [key, dictionaries] of Object.entries(groupedDictionaries)) {\n if (key === 'undefined') continue;\n\n const contentString = formatDictionaryText(dictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeFile(unmergedFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating unmerged ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths[key] = {\n dictionaryPath: unmergedFilePath,\n dictionaries: dictionaries,\n };\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,OAAO,iBAAiB;AACjC,SAAS,eAAe;AACxB,SAAS,4BAA4B;AAErC,MAAM,yBAAyB,CAC7B,iBACiC;AACjC,SAAO,aAAa;AAAA,IAClB,CAAC,KAAK,eAAe;AACnB,YAAM,MAAM,WAAW;AACvB,UAAI,CAAC,IAAI,GAAG,GAAG;AACb,YAAI,GAAG,IAAI,CAAC;AAAA,MACd;AACA,UAAI,GAAG,EAAE,KAAK,UAAU;AACxB,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;AA6BO,MAAM,4BAA4B,OACvC,cACA,gBAAgB,iBAAiB,MACK;AACtC,QAAM,EAAE,wBAAwB,IAAI,cAAc;AAGlD,QAAM,MAAM,QAAQ,uBAAuB,GAAG,EAAE,WAAW,KAAK,CAAC;AAGjE,QAAM,sBAAsB,uBAAuB,YAAY;AAE/D,MAAI,0BAAoD,CAAC;AAEzD,mBAAiB,CAAC,KAAKA,aAAY,KAAK,OAAO,QAAQ,mBAAmB,GAAG;AAC3E,QAAI,QAAQ,YAAa;AAEzB,UAAM,gBAAgB,qBAAqBA,aAAY;AAEvD,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,mBAAmB,QAAQ,yBAAyB,cAAc;AAGxE,UAAM,UAAU,kBAAkB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACtE,cAAQ,MAAM,2BAA2B,cAAc,KAAK,GAAG;AAAA,IACjE,CAAC;AAED,4BAAwB,GAAG,IAAI;AAAA,MAC7B,gBAAgB;AAAA,MAChB,cAAcA;AAAA,IAChB;AAAA,EACF;AAEA,SAAO;AACT;","names":["dictionaries"]}
|
|
@@ -2,50 +2,59 @@ import { getConfiguration } from "@intlayer/config";
|
|
|
2
2
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
3
3
|
import { resolve } from "path";
|
|
4
4
|
import { getBuiltDictionariesPath } from "../../getBuiltDictionariesPath.mjs";
|
|
5
|
+
import { getBuiltDynamicDictionariesPath } from "../../getBuiltDynamicDictionariesPath.mjs";
|
|
5
6
|
import { getBuiltUnmergedDictionariesPath } from "../../getBuiltUnmergedDictionariesPath.mjs";
|
|
6
7
|
import { generateDictionaryListContent } from "./generateDictionaryListContent.mjs";
|
|
7
|
-
const
|
|
8
|
+
const filterDictionaries = (paths, keys) => {
|
|
9
|
+
if (!keys) return paths;
|
|
10
|
+
return paths.filter(
|
|
11
|
+
(path) => keys.some((key) => path.endsWith(`${key}.json`))
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
const writeDictionaryFiles = (paths, fileName, format, configuration = getConfiguration()) => {
|
|
15
|
+
const content = generateDictionaryListContent(paths, format, configuration);
|
|
16
|
+
const extension = format === "cjs" ? "cjs" : "mjs";
|
|
17
|
+
const { mainDir } = configuration.content;
|
|
18
|
+
writeFileSync(resolve(mainDir, `${fileName}.${extension}`), content);
|
|
19
|
+
};
|
|
20
|
+
const createDictionaryEntryPoint = (configuration = getConfiguration(), dictionariesKeys, formats = ["cjs", "esm"]) => {
|
|
8
21
|
const { mainDir } = configuration.content;
|
|
9
22
|
if (!existsSync(mainDir)) {
|
|
10
23
|
mkdirSync(mainDir, { recursive: true });
|
|
11
24
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
const dictionariesPath = filterDictionaries(
|
|
26
|
+
getBuiltDictionariesPath(configuration),
|
|
27
|
+
dictionariesKeys
|
|
28
|
+
);
|
|
29
|
+
for (const format of formats) {
|
|
30
|
+
writeDictionaryFiles(
|
|
31
|
+
dictionariesPath,
|
|
32
|
+
"dictionaries",
|
|
33
|
+
format,
|
|
34
|
+
configuration
|
|
16
35
|
);
|
|
17
36
|
}
|
|
18
|
-
const cjsContent = generateDictionaryListContent(
|
|
19
|
-
dictionariesPath,
|
|
20
|
-
"cjs",
|
|
21
|
-
configuration
|
|
22
|
-
);
|
|
23
|
-
writeFileSync(resolve(mainDir, "dictionaries.cjs"), cjsContent);
|
|
24
|
-
const esmContent = generateDictionaryListContent(
|
|
25
|
-
dictionariesPath,
|
|
26
|
-
"esm",
|
|
27
|
-
configuration
|
|
28
|
-
);
|
|
29
|
-
writeFileSync(resolve(mainDir, "dictionaries.mjs"), esmContent);
|
|
30
37
|
const unmergedDictionariesPath = getBuiltUnmergedDictionariesPath(configuration);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
for (const format of formats) {
|
|
39
|
+
writeDictionaryFiles(
|
|
40
|
+
unmergedDictionariesPath,
|
|
41
|
+
"unmerged_dictionaries",
|
|
42
|
+
format,
|
|
43
|
+
configuration
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
for (const format of formats) {
|
|
47
|
+
const dynamicDictionariesPathCJS = getBuiltDynamicDictionariesPath(
|
|
48
|
+
configuration,
|
|
49
|
+
format
|
|
50
|
+
);
|
|
51
|
+
writeDictionaryFiles(
|
|
52
|
+
dynamicDictionariesPathCJS,
|
|
53
|
+
"dynamic_dictionaries",
|
|
54
|
+
format,
|
|
55
|
+
configuration
|
|
56
|
+
);
|
|
57
|
+
}
|
|
49
58
|
};
|
|
50
59
|
export {
|
|
51
60
|
createDictionaryEntryPoint
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from '../../getBuiltUnmergedDictionariesPath';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = (\n configuration = getConfiguration(),\n dictionariesKeys?: string[]\n) => {\n const { mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from '../../getBuiltDynamicDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from '../../getBuiltUnmergedDictionariesPath';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\n\nconst filterDictionaries = (paths: string[], keys?: string[]) => {\n if (!keys) return paths;\n return paths.filter((path) =>\n keys.some((key) => path.endsWith(`${key}.json`))\n );\n};\n\nconst writeDictionaryFiles = (\n paths: string[],\n fileName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(paths, format, configuration);\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n writeFileSync(resolve(mainDir, `${fileName}.${extension}`), content);\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = (\n configuration = getConfiguration(),\n dictionariesKeys?: string[],\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n) => {\n const { mainDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath = filterDictionaries(\n getBuiltDictionariesPath(configuration),\n dictionariesKeys\n );\n\n for (const format of formats) {\n writeDictionaryFiles(\n dictionariesPath,\n 'dictionaries',\n format,\n configuration\n );\n }\n\n const unmergedDictionariesPath =\n getBuiltUnmergedDictionariesPath(configuration);\n\n for (const format of formats) {\n writeDictionaryFiles(\n unmergedDictionariesPath,\n 'unmerged_dictionaries',\n format,\n configuration\n );\n }\n\n for (const format of formats) {\n const dynamicDictionariesPathCJS = getBuiltDynamicDictionariesPath(\n configuration,\n format\n );\n\n writeDictionaryFiles(\n dynamicDictionariesPathCJS,\n 'dynamic_dictionaries',\n format,\n configuration\n );\n }\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,eAAe;AACxB,SAAS,gCAAgC;AACzC,SAAS,uCAAuC;AAChD,SAAS,wCAAwC;AACjD,SAAS,qCAAqC;AAE9C,MAAM,qBAAqB,CAAC,OAAiB,SAAoB;AAC/D,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,MAAM;AAAA,IAAO,CAAC,SACnB,KAAK,KAAK,CAAC,QAAQ,KAAK,SAAS,GAAG,GAAG,OAAO,CAAC;AAAA,EACjD;AACF;AAEA,MAAM,uBAAuB,CAC3B,OACA,UACA,QACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,UAAU,8BAA8B,OAAO,QAAQ,aAAa;AAC1E,QAAM,YAAY,WAAW,QAAQ,QAAQ;AAE7C,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,gBAAc,QAAQ,SAAS,GAAG,QAAQ,IAAI,SAAS,EAAE,GAAG,OAAO;AACrE;AAKO,MAAM,6BAA6B,CACxC,gBAAgB,iBAAiB,GACjC,kBACA,UAA6B,CAAC,OAAO,KAAK,MACvC;AACH,QAAM,EAAE,QAAQ,IAAI,cAAc;AAGlC,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,cAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAAmB;AAAA,IACvB,yBAAyB,aAAa;AAAA,IACtC;AAAA,EACF;AAEA,aAAW,UAAU,SAAS;AAC5B;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,2BACJ,iCAAiC,aAAa;AAEhD,aAAW,UAAU,SAAS;AAC5B;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,aAAW,UAAU,SAAS;AAC5B,UAAM,6BAA6B;AAAA,MACjC;AAAA,MACA;AAAA,IACF;AAEA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -13,7 +13,7 @@ const generateDictionaryListContent = (dictionaries, format = "esm", configurati
|
|
|
13
13
|
}));
|
|
14
14
|
dictionariesRef.forEach((dictionary) => {
|
|
15
15
|
if (format === "esm")
|
|
16
|
-
content += `import ${dictionary.hash} from '${dictionary.relativePath}';
|
|
16
|
+
content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };
|
|
17
17
|
`;
|
|
18
18
|
if (format === "cjs")
|
|
19
19
|
content += `const ${dictionary.hash} = require('${dictionary.relativePath}');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: 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: 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}';\\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 if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,UAAU,SAAS,gBAAgB;AAC5C,SAAS,mBAAmB;AAKrB,MAAM,gCAAgC,CAC3C,cACA,SAAwB,OACxB,gBAAgB,iBAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,cAAc,SAAS,SAAS,cAAc;AAAA,IAC9C,IAAI,SAAS,gBAAgB,QAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,IAAI,YAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,iBAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,iBAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,aAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,eAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,eAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: 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: 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 if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,UAAU,SAAS,gBAAgB;AAC5C,SAAS,mBAAmB;AAKrB,MAAM,gCAAgC,CAC3C,cACA,SAAwB,OACxB,gBAAgB,iBAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,cAAc,SAAS,SAAS,cAAc;AAAA,IAC9C,IAAI,SAAS,gBAAgB,QAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,IAAI,YAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,iBAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,iBAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,aAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,eAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,eAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../../src/chokidar/watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,KAAK,cAAc,EAGpB,MAAM,kBAAkB,CAAC;AAE1B,2FAA2F;AAC3F,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,UAAU,CAAC;AAcxE,eAAO,MAAM,sCAAsC,GACjD,UAAU,MAAM,EAChB,gBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../../src/chokidar/watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,KAAK,cAAc,EAGpB,MAAM,kBAAkB,CAAC;AAE1B,2FAA2F;AAC3F,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,UAAU,CAAC;AAcxE,eAAO,MAAM,sCAAsC,GACjD,UAAU,MAAM,EAChB,gBAAgB,cAAc,kBAmC/B,CAAC;AAEF,eAAO,MAAM,mCAAmC,GAC9C,UAAU,MAAM,EAChB,gBAAgB,cAAc,kBAkC/B,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,UAAU,MAAM,EAChB,gBAAgB,cAAc,kBAqC/B,CAAC;AAEF,KAAK,YAAY,GAAG,eAAe,GAAG;IACpC,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAGF,eAAO,MAAM,KAAK,GAAI,UAAU,YAAY,QA+C3C,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAU,UAAU,YAAY,kBAUjE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanOutputDir.d.ts","sourceRoot":"","sources":["../../src/cleanOutputDir.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cleanOutputDir.d.ts","sourceRoot":"","sources":["../../src/cleanOutputDir.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,GAAI,yDAAkC,SAuChE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function generates a list of dictionaries in the main directory
|
|
3
|
+
*/
|
|
4
|
+
export declare const getBuiltDynamicDictionariesPath: (configuration?: import("@intlayer/config").IntlayerConfig, format?: "cjs" | "esm") => string[];
|
|
5
|
+
//# sourceMappingURL=getBuiltDynamicDictionariesPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBuiltDynamicDictionariesPath.d.ts","sourceRoot":"","sources":["../../src/getBuiltDynamicDictionariesPath.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,+BAA+B,GAC1C,yDAAkC,EAClC,SAAQ,KAAK,GAAG,KAAa,aAgB9B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
import { ContentNode, type NodeProps } from '@intlayer/core';
|
|
3
|
+
export declare const getFilteredLocalesContent: (node: ContentNode, locale: LocalesValues | LocalesValues[], nodeProps: NodeProps, fallback?: LocalesValues) => any;
|
|
4
|
+
//# sourceMappingURL=getFilteredLocalesContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFilteredLocalesContent.d.ts","sourceRoot":"","sources":["../../src/getFilteredLocalesContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,WAAW,EAGX,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAC;AA4CxB,eAAO,MAAM,yBAAyB,GACpC,MAAM,WAAW,EACjB,QAAQ,aAAa,GAAG,aAAa,EAAE,EACvC,WAAW,SAAS,EACpB,WAAW,aAAa,QAWzB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { checkDictionaryChanges } from './checkDictionaryChanges';
|
|
2
2
|
export { buildAndWatchIntlayer, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, watch, } from './chokidar/watcher';
|
|
3
|
+
export { cleanOutputDir } from './cleanOutputDir';
|
|
3
4
|
export { fetchDistantDictionaries } from './fetchDistantDictionaries';
|
|
4
5
|
export { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';
|
|
5
|
-
export { filterDictionaryLocales } from './filterDictionaryLocales';
|
|
6
6
|
export { getBuiltDictionariesPath } from './getBuiltDictionariesPath';
|
|
7
7
|
export { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';
|
|
8
|
+
export { getFilteredLocalesContent } from './getFilteredLocalesContent';
|
|
8
9
|
export { listDictionaries } from './listDictionariesPath';
|
|
9
10
|
export { listGitFiles, type DiffMode, type ListGitFilesOptions, } from './listGitFiles';
|
|
10
11
|
export { loadDictionaries, loadDistantDictionaries, loadLocalDictionaries, } from './loadDictionaries/index';
|
|
@@ -16,5 +17,6 @@ export { reduceDictionaryContent } from './reduceDictionaryContent/reduceDiction
|
|
|
16
17
|
export { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';
|
|
17
18
|
export { createDictionaryEntryPoint, generateDictionaryListContent, } from './transpiler/dictionary_to_main';
|
|
18
19
|
export { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';
|
|
20
|
+
export { getFileHash } from './utils';
|
|
19
21
|
export { writeContentDeclaration, type DictionaryStatus, } from './writeContentDeclaration';
|
|
20
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,qBAAqB,EACrB,sCAAsC,EACtC,kCAAkC,EAClC,KAAK,GACN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,qBAAqB,EACrB,sCAAsC,EACtC,kCAAkC,EAClC,KAAK,GACN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { Dictionary } from '@intlayer/core';
|
|
2
|
-
export declare const buildDictionary: (dictionaries: Dictionary[], configuration?: import("@intlayer/config").IntlayerConfig) => Promise<
|
|
2
|
+
export declare const buildDictionary: (dictionaries: Dictionary[], configuration?: import("@intlayer/config").IntlayerConfig) => Promise<{
|
|
3
|
+
unmergedDictionaries: import("./intlayer_dictionary/writeUnmergedDictionary").UnmergedDictionaryOutput;
|
|
4
|
+
mergedDictionaries: import("./intlayer_dictionary/writeMergedDictionary").MergedDictionaryOutput;
|
|
5
|
+
dynamicDictionaries: import("./intlayer_dictionary/writeDynamicDictionary").LocalizedDictionaryOutput;
|
|
6
|
+
}>;
|
|
3
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,eAAe,GAC1B,cAAc,UAAU,EAAE,EAC1B,yDAAkC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,eAAe,GAC1B,cAAc,UAAU,EAAE,EAC1B,yDAAkC;;;;EAWnC,CAAC"}
|
|
@@ -3,5 +3,9 @@ import type { Dictionary } from '@intlayer/core';
|
|
|
3
3
|
/**
|
|
4
4
|
* This function transpile the bundled code to to make dictionaries as JSON files
|
|
5
5
|
*/
|
|
6
|
-
export declare const buildIntlayerDictionary: (contentDeclarations: (DictionaryAPI | Dictionary)[], configuration?: import("@intlayer/config").IntlayerConfig) => Promise<
|
|
6
|
+
export declare const buildIntlayerDictionary: (contentDeclarations: (DictionaryAPI | Dictionary)[], configuration?: import("@intlayer/config").IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<{
|
|
7
|
+
unmergedDictionaries: import("./writeUnmergedDictionary").UnmergedDictionaryOutput;
|
|
8
|
+
mergedDictionaries: import("./writeMergedDictionary").MergedDictionaryOutput;
|
|
9
|
+
dynamicDictionaries: import("./writeDynamicDictionary").LocalizedDictionaryOutput;
|
|
10
|
+
}>;
|
|
7
11
|
//# sourceMappingURL=buildIntlayerDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildIntlayerDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildIntlayerDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAClC,qBAAqB,CAAC,aAAa,GAAG,UAAU,CAAC,EAAE,EACnD,yDAAkC,EAClC,UAAS,CAAC,KAAK,GAAG,KAAK,CAAC,EAAmB;;;;EAuB5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDictionaryText.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/formatDictionaryText.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,GAAI,YAAY,MAAM,WAGvB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Locales } from '@intlayer/config';
|
|
2
|
+
import { type Dictionary } from '@intlayer/core';
|
|
3
|
+
import { MergedDictionaryOutput } from './writeMergedDictionary';
|
|
4
|
+
export type DictionaryResult = {
|
|
5
|
+
dictionaryPath: string;
|
|
6
|
+
dictionary: Dictionary;
|
|
7
|
+
};
|
|
8
|
+
export type LocalizedDictionaryResult = Partial<Record<Locales, DictionaryResult>>;
|
|
9
|
+
export type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
|
|
10
|
+
/**
|
|
11
|
+
* This function generates the content of the dictionary list file
|
|
12
|
+
*/
|
|
13
|
+
export declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: import("@intlayer/config").IntlayerConfig) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Write the localized dictionaries to the dictionariesDir
|
|
16
|
+
* @param mergedDictionaries - The merged dictionaries
|
|
17
|
+
* @param configuration - The configuration
|
|
18
|
+
* @returns The final dictionaries
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
23
|
+
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
24
|
+
* console.log(finalDictionaries);
|
|
25
|
+
*
|
|
26
|
+
* // .intlayer/dictionaries/home.json
|
|
27
|
+
* // { key: 'home', content: { ... } },
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?: import("@intlayer/config").IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
31
|
+
//# sourceMappingURL=writeDynamicDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeDynamicDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDynamicDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAC7C,MAAM,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAClC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAC5C,MAAM,EACN,yBAAyB,CAC1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACvC,gCAAgC,yBAAyB,EACzD,SAAQ,KAAK,GAAG,KAAa,EAC7B,yDAAkC,KACjC,MA6BF,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GACjC,oBAAoB,sBAAsB,EAC1C,yDAAkC,EAClC,UAAS,CAAC,KAAK,GAAG,KAAK,CAAC,EAAmB,KAC1C,OAAO,CAAC,yBAAyB,CA8DnC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Dictionary } from '@intlayer/core';
|
|
2
|
+
import { UnmergedDictionaryOutput } from './writeUnmergedDictionary';
|
|
3
|
+
export type MergedDictionaryResult = {
|
|
4
|
+
dictionaryPath: string;
|
|
5
|
+
dictionary: Dictionary;
|
|
6
|
+
};
|
|
7
|
+
export type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;
|
|
8
|
+
/**
|
|
9
|
+
* Write the merged dictionaries to the dictionariesDir
|
|
10
|
+
* @param groupedDictionaries - The grouped dictionaries
|
|
11
|
+
* @param configuration - The configuration
|
|
12
|
+
* @returns The merged dictionaries
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
17
|
+
* const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
|
|
18
|
+
* console.log(finalDictionaries);
|
|
19
|
+
*
|
|
20
|
+
* // .intlayer/dictionaries/home.json
|
|
21
|
+
* // { key: 'home', content: { ... } },
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?: import("@intlayer/config").IntlayerConfig) => Promise<MergedDictionaryOutput>;
|
|
25
|
+
//# sourceMappingURL=writeMergedDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeMergedDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeMergedDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,sBAAsB,GAAG;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,uBAAuB,GAClC,qBAAqB,wBAAwB,EAC7C,yDAAkC,KACjC,OAAO,CAAC,sBAAsB,CAqChC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Dictionary } from '@intlayer/core';
|
|
2
|
+
export type UnmergedDictionaryResult = {
|
|
3
|
+
dictionaryPath: string;
|
|
4
|
+
dictionaries: Dictionary[];
|
|
5
|
+
};
|
|
6
|
+
export type UnmergedDictionaryOutput = Record<string, UnmergedDictionaryResult>;
|
|
7
|
+
/**
|
|
8
|
+
* Write the unmerged dictionaries to the unmergedDictionariesDir
|
|
9
|
+
* @param dictionaries - The dictionaries to write
|
|
10
|
+
* @param configuration - The configuration
|
|
11
|
+
* @returns The grouped dictionaries
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
|
|
16
|
+
* console.log(unmergedDictionaries);
|
|
17
|
+
*
|
|
18
|
+
* // .intlayer/unmerged_dictionaries/home.json
|
|
19
|
+
* // {
|
|
20
|
+
* // [
|
|
21
|
+
* // { key: 'home', content: { ... } },
|
|
22
|
+
* // { key: 'home', content: { ... } },
|
|
23
|
+
* // ],
|
|
24
|
+
* // }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const writeUnmergedDictionaries: (dictionaries: Dictionary[], configuration?: import("@intlayer/config").IntlayerConfig) => Promise<UnmergedDictionaryOutput>;
|
|
28
|
+
//# sourceMappingURL=writeUnmergedDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeUnmergedDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeUnmergedDictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAqBjD,MAAM,MAAM,wBAAwB,GAAG;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,UAAU,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB,GACpC,cAAc,UAAU,EAAE,EAC1B,yDAAkC,KACjC,OAAO,CAAC,wBAAwB,CA+BlC,CAAC"}
|