@intlayer/chokidar 8.6.0 → 8.6.2
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/cli.cjs +2 -0
- package/dist/cjs/formatDictionary.cjs +6 -6
- package/dist/cjs/formatDictionary.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +4 -3
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/utils/formatter.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +0 -5
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +7 -2
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
- package/dist/esm/cli.mjs +2 -1
- package/dist/esm/formatDictionary.mjs +6 -6
- package/dist/esm/formatDictionary.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +4 -3
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/utils/formatter.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -2
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs +7 -2
- package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
- package/dist/types/cli.d.ts +2 -1
- package/dist/types/formatDictionary.d.ts +3 -3
- package/dist/types/formatDictionary.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +5 -2
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
- package/dist/types/utils/formatter.d.ts +3 -2
- package/dist/types/utils/formatter.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -2
- package/package.json +9 -10
- package/dist/cjs/utils/getUsedNodeTypes.cjs +0 -88
- package/dist/cjs/utils/getUsedNodeTypes.cjs.map +0 -1
- package/dist/esm/utils/getUsedNodeTypes.mjs +0 -83
- package/dist/esm/utils/getUsedNodeTypes.mjs.map +0 -1
- package/dist/types/utils/getUsedNodeTypes.d.ts +0 -54
- package/dist/types/utils/getUsedNodeTypes.d.ts.map +0 -1
package/dist/cjs/cli.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_listProjects = require('./listProjects.cjs');
|
|
3
3
|
const require_listDictionariesPath = require('./listDictionariesPath.cjs');
|
|
4
|
+
const require_prepareIntlayer = require('./prepareIntlayer.cjs');
|
|
4
5
|
const require_writeContentDeclaration_detectExportedComponentName = require('./writeContentDeclaration/detectExportedComponentName.cjs');
|
|
5
6
|
const require_writeContentDeclaration_transformJSFile = require('./writeContentDeclaration/transformJSFile.cjs');
|
|
6
7
|
const require_detectFormatCommand = require('./detectFormatCommand.cjs');
|
|
@@ -30,6 +31,7 @@ exports.listGitFiles = require_listGitFiles.listGitFiles;
|
|
|
30
31
|
exports.listGitLines = require_listGitFiles.listGitLines;
|
|
31
32
|
exports.listProjects = require_listProjects.listProjects;
|
|
32
33
|
exports.logConfigDetails = require_logConfigDetails.logConfigDetails;
|
|
34
|
+
exports.prepareIntlayer = require_prepareIntlayer.prepareIntlayer;
|
|
33
35
|
exports.transformJSFile = require_writeContentDeclaration_transformJSFile.transformJSFile;
|
|
34
36
|
exports.writeContentDeclaration = require_writeContentDeclaration_writeContentDeclaration.writeContentDeclaration;
|
|
35
37
|
exports.writeJSFile = require_writeContentDeclaration_writeJSFile.writeJSFile;
|
|
@@ -21,26 +21,26 @@ const formatDictionary = (dictionary) => {
|
|
|
21
21
|
};
|
|
22
22
|
return dictionary;
|
|
23
23
|
};
|
|
24
|
-
const formatDictionaries = (dictionaries) => dictionaries.map(formatDictionary);
|
|
25
|
-
const formatDictionaryOutput = (dictionary) => {
|
|
26
|
-
if (
|
|
24
|
+
const formatDictionaries = async (dictionaries) => Promise.all(dictionaries.map(formatDictionary));
|
|
25
|
+
const formatDictionaryOutput = (dictionary, format) => {
|
|
26
|
+
if (format === "icu") return {
|
|
27
27
|
...dictionary,
|
|
28
28
|
format: "icu",
|
|
29
29
|
content: (0, _intlayer_core_messageFormat.intlayerToICUFormatter)(dictionary.content)
|
|
30
30
|
};
|
|
31
|
-
if (
|
|
31
|
+
if (format === "i18next") return {
|
|
32
32
|
...dictionary,
|
|
33
33
|
format: "i18next",
|
|
34
34
|
content: (0, _intlayer_core_messageFormat.intlayerToI18nextFormatter)(dictionary.content)
|
|
35
35
|
};
|
|
36
|
-
if (
|
|
36
|
+
if (format === "vue-i18n") return {
|
|
37
37
|
...dictionary,
|
|
38
38
|
format: "vue-i18n",
|
|
39
39
|
content: (0, _intlayer_core_messageFormat.intlayerToVueI18nFormatter)(dictionary.content)
|
|
40
40
|
};
|
|
41
41
|
return dictionary;
|
|
42
42
|
};
|
|
43
|
-
const formatDictionariesOutput = (dictionaries) => dictionaries.map(formatDictionaryOutput);
|
|
43
|
+
const formatDictionariesOutput = (dictionaries, format) => dictionaries.map((dictionary) => formatDictionaryOutput(dictionary, format));
|
|
44
44
|
|
|
45
45
|
//#endregion
|
|
46
46
|
exports.formatDictionaries = formatDictionaries;
|
|
@@ -1 +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/dictionary';\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[]
|
|
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/dictionary';\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 = async (\n dictionaries: Dictionary[]\n): Promise<Dictionary[]> => Promise.all(dictionaries.map(formatDictionary));\n\nexport const formatDictionaryOutput = (\n dictionary: Dictionary,\n format: Dictionary['format']\n) => {\n if (format === 'icu') {\n return {\n ...dictionary,\n format: 'icu',\n content: intlayerToICUFormatter(dictionary.content),\n };\n }\n\n if (format === 'i18next') {\n return {\n ...dictionary,\n format: 'i18next',\n content: intlayerToI18nextFormatter(dictionary.content),\n };\n }\n\n if (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 = (\n dictionaries: Dictionary[],\n format: Dictionary['format']\n) =>\n dictionaries.map((dictionary) => formatDictionaryOutput(dictionary, format));\n"],"mappings":";;;;;AAUA,MAAa,oBAAoB,eAAuC;AACtE,KAAI,WAAW,WAAW,MACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,kEAAgC,WAAW,QAAQ;EACpD;AAGH,KAAI,WAAW,WAAW,UACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,sEAAoC,WAAW,QAAQ;EACxD;AAGH,KAAI,WAAW,WAAW,WACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,sEAAoC,WAAW,QAAQ;EACxD;AAGH,QAAO;;AAGT,MAAa,qBAAqB,OAChC,iBAC0B,QAAQ,IAAI,aAAa,IAAI,iBAAiB,CAAC;AAE3E,MAAa,0BACX,YACA,WACG;AACH,KAAI,WAAW,MACb,QAAO;EACL,GAAG;EACH,QAAQ;EACR,kEAAgC,WAAW,QAAQ;EACpD;AAGH,KAAI,WAAW,UACb,QAAO;EACL,GAAG;EACH,QAAQ;EACR,sEAAoC,WAAW,QAAQ;EACxD;AAGH,KAAI,WAAW,WACb,QAAO;EACL,GAAG;EACH,QAAQ;EACR,sEAAoC,WAAW,QAAQ;EACxD;AAGH,QAAO;;AAGT,MAAa,4BACX,cACA,WAEA,aAAa,KAAK,eAAe,uBAAuB,YAAY,OAAO,CAAC"}
|
|
@@ -27,11 +27,12 @@ const ensureIntlayerBundle = async (configuration) => {
|
|
|
27
27
|
}
|
|
28
28
|
return filePath;
|
|
29
29
|
};
|
|
30
|
-
const loadContentDeclaration = async (path, configuration, bundleFilePath) => {
|
|
30
|
+
const loadContentDeclaration = async (path, configuration, bundleFilePath, options) => {
|
|
31
31
|
const { build } = configuration;
|
|
32
32
|
const resolvedBundleFilePath = bundleFilePath ?? await ensureIntlayerBundle(configuration);
|
|
33
33
|
try {
|
|
34
34
|
return await (0, _intlayer_config_file.loadExternalFile)(path, {
|
|
35
|
+
logError: options?.logError,
|
|
35
36
|
projectRequire: build.require ?? (0, _intlayer_config_utils.getProjectRequire)(),
|
|
36
37
|
buildOptions: { banner: { js: [`globalThis.INTLAYER_FILE_PATH = '${path}';`, `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`].join("\n") } },
|
|
37
38
|
aliases: { intlayer: resolvedBundleFilePath }
|
|
@@ -41,7 +42,7 @@ const loadContentDeclaration = async (path, configuration, bundleFilePath) => {
|
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
|
-
const loadContentDeclarations = async (contentDeclarationFilePath, configuration, onStatusUpdate) => {
|
|
45
|
+
const loadContentDeclarations = async (contentDeclarationFilePath, configuration, onStatusUpdate, options) => {
|
|
45
46
|
const { build, system } = configuration;
|
|
46
47
|
if (build.checkTypes) require_loadDictionaries_logTypeScriptErrors.logTypeScriptErrors(contentDeclarationFilePath, configuration).catch((e) => {
|
|
47
48
|
console.error("Error during TypeScript validation:", e);
|
|
@@ -51,7 +52,7 @@ const loadContentDeclarations = async (contentDeclarationFilePath, configuration
|
|
|
51
52
|
const dictionariesPromises = contentDeclarationFilePath.map(async (path) => {
|
|
52
53
|
return {
|
|
53
54
|
relativePath: (0, node_path.relative)(system.baseDir, path),
|
|
54
|
-
dictionary: await loadContentDeclaration(path, configuration, bundleFilePath)
|
|
55
|
+
dictionary: await loadContentDeclaration(path, configuration, bundleFilePath, options)
|
|
55
56
|
};
|
|
56
57
|
});
|
|
57
58
|
const contentDeclarations = formatLocalDictionaries((await Promise.all(dictionariesPromises)).reduce((acc, { relativePath, dictionary }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadContentDeclaration.cjs","names":["getIntlayerBundle","filterInvalidDictionaries","parallelize","processContentDeclaration"],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile } from '@intlayer/config/file';\nimport { cacheDisk, getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { logTypeScriptErrors } from './logTypeScriptErrors';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n location: dict.location ?? configuration.dictionary?.location ?? 'local',\n localId: `${dict.key}::local::${relativePath}`,\n filePath: relativePath,\n }));\n\nexport const ensureIntlayerBundle = async (\n configuration: IntlayerConfig\n): Promise<string> => {\n const { system } = configuration;\n\n const { set, isValid } = cacheDisk(configuration, ['intlayer-bundle'], {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n });\n\n const filePath = join(system.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n return filePath;\n};\n\nexport const loadContentDeclaration = async (\n path: string,\n configuration: IntlayerConfig,\n bundleFilePath?: string\n): Promise<Dictionary | undefined> => {\n const { build } = configuration;\n\n const resolvedBundleFilePath =\n bundleFilePath ?? (await ensureIntlayerBundle(configuration));\n\n try {\n const dictionary = await loadExternalFile(path, {\n projectRequire: build.require ?? getProjectRequire(),\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: resolvedBundleFilePath,\n },\n });\n\n return dictionary;\n } catch (error) {\n console.error(`Error loading content declaration at ${path}:`, error);\n return undefined;\n }\n};\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const { build, system } = configuration;\n\n // Check for TypeScript warnings before we build\n if (build.checkTypes) {\n logTypeScriptErrors(contentDeclarationFilePath, configuration).catch(\n (e) => {\n console.error('Error during TypeScript validation:', e);\n }\n );\n }\n\n const bundleFilePath = await ensureIntlayerBundle(configuration);\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(system.baseDir, path);\n\n const dictionary = await loadContentDeclaration(\n path,\n configuration,\n bundleFilePath\n );\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n if (dictionary) {\n acc[relativePath] = dictionary;\n }\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n ).filter((dictionary) => dictionary.location !== 'remote');\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary,\n configuration\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration, {\n checkSchema: false,\n });\n } catch {\n console.error('Error loading content declarations');\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,2BACX,oBACA,kBAEA,OAAO,QAAQ,mBAAmB,CAAC,KAAK,CAAC,cAAc,WAAW;CAChE,GAAG;CACH,UAAU,KAAK,YAAY,cAAc,YAAY,YAAY;CACjE,SAAS,GAAG,KAAK,IAAI,WAAW;CAChC,UAAU;CACX,EAAE;AAEL,MAAa,uBAAuB,OAClC,kBACoB;CACpB,MAAM,EAAE,WAAW;CAEnB,MAAM,EAAE,KAAK,kDAAsB,eAAe,CAAC,kBAAkB,EAAE,EACrE,OAAO,MAAO,KAAK,KAAK,KAAK,GAC9B,CAAC;CAEF,MAAM,+BAAgB,OAAO,UAAU,sBAAsB;AAG7D,KAAI,CAFsB,MAAM,SAAS,EAEjB;AAEtB,wCAAgB,UADO,MAAMA,6DAAkB,cAAc,CACpB;AACzC,QAAM,IAAI,KAAK;;AAGjB,QAAO;;
|
|
1
|
+
{"version":3,"file":"loadContentDeclaration.cjs","names":["getIntlayerBundle","filterInvalidDictionaries","parallelize","processContentDeclaration"],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile } from '@intlayer/config/file';\nimport { cacheDisk, getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { logTypeScriptErrors } from './logTypeScriptErrors';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n location: dict.location ?? configuration.dictionary?.location ?? 'local',\n localId: `${dict.key}::local::${relativePath}`,\n filePath: relativePath,\n }));\n\nexport const ensureIntlayerBundle = async (\n configuration: IntlayerConfig\n): Promise<string> => {\n const { system } = configuration;\n\n const { set, isValid } = cacheDisk(configuration, ['intlayer-bundle'], {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n });\n\n const filePath = join(system.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n return filePath;\n};\n\ntype LoadContentDeclarationOptions = {\n logError?: boolean;\n};\n\nexport const loadContentDeclaration = async (\n path: string,\n configuration: IntlayerConfig,\n bundleFilePath?: string,\n options?: LoadContentDeclarationOptions\n): Promise<Dictionary | undefined> => {\n const { build } = configuration;\n\n const resolvedBundleFilePath =\n bundleFilePath ?? (await ensureIntlayerBundle(configuration));\n\n try {\n const dictionary = await loadExternalFile(path, {\n logError: options?.logError,\n projectRequire: build.require ?? getProjectRequire(),\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: resolvedBundleFilePath,\n },\n });\n\n return dictionary;\n } catch (error) {\n console.error(`Error loading content declaration at ${path}:`, error);\n return undefined;\n }\n};\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void,\n options?: LoadContentDeclarationOptions\n): Promise<Dictionary[]> => {\n const { build, system } = configuration;\n\n // Check for TypeScript warnings before we build\n if (build.checkTypes) {\n logTypeScriptErrors(contentDeclarationFilePath, configuration).catch(\n (e) => {\n console.error('Error during TypeScript validation:', e);\n }\n );\n }\n\n const bundleFilePath = await ensureIntlayerBundle(configuration);\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(system.baseDir, path);\n\n const dictionary = await loadContentDeclaration(\n path,\n configuration,\n bundleFilePath,\n options\n );\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n if (dictionary) {\n acc[relativePath] = dictionary;\n }\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n ).filter((dictionary) => dictionary.location !== 'remote');\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary,\n configuration\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration, {\n checkSchema: false,\n });\n } catch {\n console.error('Error loading content declarations');\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,2BACX,oBACA,kBAEA,OAAO,QAAQ,mBAAmB,CAAC,KAAK,CAAC,cAAc,WAAW;CAChE,GAAG;CACH,UAAU,KAAK,YAAY,cAAc,YAAY,YAAY;CACjE,SAAS,GAAG,KAAK,IAAI,WAAW;CAChC,UAAU;CACX,EAAE;AAEL,MAAa,uBAAuB,OAClC,kBACoB;CACpB,MAAM,EAAE,WAAW;CAEnB,MAAM,EAAE,KAAK,kDAAsB,eAAe,CAAC,kBAAkB,EAAE,EACrE,OAAO,MAAO,KAAK,KAAK,KAAK,GAC9B,CAAC;CAEF,MAAM,+BAAgB,OAAO,UAAU,sBAAsB;AAG7D,KAAI,CAFsB,MAAM,SAAS,EAEjB;AAEtB,wCAAgB,UADO,MAAMA,6DAAkB,cAAc,CACpB;AACzC,QAAM,IAAI,KAAK;;AAGjB,QAAO;;AAOT,MAAa,yBAAyB,OACpC,MACA,eACA,gBACA,YACoC;CACpC,MAAM,EAAE,UAAU;CAElB,MAAM,yBACJ,kBAAmB,MAAM,qBAAqB,cAAc;AAE9D,KAAI;AAiBF,SAhBmB,kDAAuB,MAAM;GAC9C,UAAU,SAAS;GACnB,gBAAgB,MAAM,0DAA8B;GACpD,cAAc,EACZ,QAAQ,EACN,IAAI,CACF,oCAAoC,KAAK,KACzC,mCAAmC,cAAc,OAAO,QAAQ,IACjE,CAAC,KAAK,KAAK,EACb,EACF;GACD,SAAS,EACP,UAAU,wBACX;GACF,CAAC;UAGK,OAAO;AACd,UAAQ,MAAM,wCAAwC,KAAK,IAAI,MAAM;AACrE;;;AAIJ,MAAa,0BAA0B,OACrC,4BACA,eACA,gBACA,YAC0B;CAC1B,MAAM,EAAE,OAAO,WAAW;AAG1B,KAAI,MAAM,WACR,kEAAoB,4BAA4B,cAAc,CAAC,OAC5D,MAAM;AACL,UAAQ,MAAM,uCAAuC,EAAE;GAE1D;CAGH,MAAM,iBAAiB,MAAM,qBAAqB,cAAc;AAEhE,KAAI;EACF,MAAM,uBAAuB,2BAA2B,IACtD,OAAO,SAAS;AAUd,UAAO;IAAE,sCATqB,OAAO,SAAS,KAAK;IAS5B,YAPJ,MAAM,uBACvB,MACA,eACA,gBACA,QACD;IAEkC;IAEtC;EAaD,MAAM,sBAAoC,yBAXhB,MAAM,QAAQ,IAAI,qBAAqB,EACpB,QAC1C,KAAK,EAAE,cAAc,iBAAiB;AACrC,OAAI,WACF,KAAI,gBAAgB;AAEtB,UAAO;KAET,EAAE,CACH,EAIC,cACD,CAAC,QAAQ,eAAe,WAAW,aAAa,SAAS;EAE1D,MAAM,wBAAwB,oBAAoB,KAAK,iBAAiB;GACtE,eAAe,YAAY;GAC3B,MAAM;GACN,QAAQ;GACT,EAAE;AAEH,mBAAiB,sBAAsB;AAsCvC,SAAOC,4DApCuB,MAAMC,sCAClC,qBACA,OAAO,uBAAwD;AAC7D,OAAI,CAAC,mBACH;AAGF,oBAAiB,CACf;IACE,eAAe,mBAAmB;IAClC,MAAM;IACN,QAAQ;IACT,CACF,CAAC;GAEF,MAAM,8BAA8B,MAAMC,oFACxC,oBACA,cACD;AAED,OAAI,CAAC,4BACH;AAGF,oBAAiB,CACf;IACE,eAAe,4BAA4B;IAC3C,MAAM;IACN,QAAQ;IACT,CACF,CAAC;AAEF,UAAO;IAEV,EAEuD,eAAe,EACrE,aAAa,OACd,CAAC;SACI;AACN,UAAQ,MAAM,qCAAqC;;AAGrD,QAAO,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.cjs","names":["configuration","ANSIColors","ENGLISH"],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize
|
|
1
|
+
{"version":3,"file":"formatter.cjs","names":["configuration","ANSIColors","ENGLISH"],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n type ANSIColorsType,\n colorize,\n colorizePath,\n} from '@intlayer/config/logger';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport { ENGLISH } from '@intlayer/types/locales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport const formatPath = (\n path: string | string[],\n color?: ANSIColorsType | false\n) =>\n [path]\n .flat()\n .map((path) =>\n path.startsWith('/') ? relative(configuration.system.baseDir, path) : path\n )\n .map((relativePath) =>\n color === false ? relativePath : colorizePath(relativePath, color)\n )\n .join(`, `);\n\nexport const formatLocale = (\n locale: LocalesValues | LocalesValues[],\n color: ANSIColorsType | false = ANSIColors.GREEN\n) =>\n [locale]\n .flat()\n .map((locale) => `${getLocaleName(locale, ENGLISH)} (${locale})`)\n .map((text) => (color === false ? text : colorize(text, color)))\n .join(`, `);\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,cACX,MACA,UAEA,CAAC,KAAK,CACH,MAAM,CACN,KAAK,SACJ,KAAK,WAAW,IAAI,2BAAYA,+BAAc,OAAO,SAAS,KAAK,GAAG,KACvE,CACA,KAAK,iBACJ,UAAU,QAAQ,yDAA4B,cAAc,MAAM,CACnE,CACA,KAAK,KAAK;AAEf,MAAa,gBACX,QACA,QAAgCC,wBAAW,UAE3C,CAAC,OAAO,CACL,MAAM,CACN,KAAK,WAAW,kDAAiB,QAAQC,gCAAQ,CAAC,IAAI,OAAO,GAAG,CAChE,KAAK,SAAU,UAAU,QAAQ,6CAAgB,MAAM,MAAM,CAAE,CAC/D,KAAK,KAAK"}
|
package/dist/cjs/utils/index.cjs
CHANGED
|
@@ -10,7 +10,6 @@ const require_utils_getChunk = require('./getChunk.cjs');
|
|
|
10
10
|
const require_utils_chunkJSON = require('./chunkJSON.cjs');
|
|
11
11
|
const require_utils_getContentExtension = require('./getContentExtension.cjs');
|
|
12
12
|
const require_utils_getFormatFromExtension = require('./getFormatFromExtension.cjs');
|
|
13
|
-
const require_utils_getUsedNodeTypes = require('./getUsedNodeTypes.cjs');
|
|
14
13
|
const require_utils_mergeChunks = require('./mergeChunks.cjs');
|
|
15
14
|
const require_utils_parallelizeGlobal = require('./parallelizeGlobal.cjs');
|
|
16
15
|
const require_utils_reduceObjectFormat = require('./reduceObjectFormat.cjs');
|
|
@@ -21,7 +20,6 @@ const require_utils_runParallel_index = require('./runParallel/index.cjs');
|
|
|
21
20
|
const require_utils_sortAlphabetically = require('./sortAlphabetically.cjs');
|
|
22
21
|
const require_utils_verifyIdenticObjectFormat = require('./verifyIdenticObjectFormat.cjs');
|
|
23
22
|
|
|
24
|
-
exports.PLUGIN_NODE_TYPES = require_utils_getUsedNodeTypes.PLUGIN_NODE_TYPES;
|
|
25
23
|
exports.Queue = require_utils_pLimit.Queue;
|
|
26
24
|
exports.assembleJSON = require_utils_chunkJSON.assembleJSON;
|
|
27
25
|
exports.autoDecorateContent = require_utils_autoDecorateContent.autoDecorateContent;
|
|
@@ -34,12 +32,9 @@ exports.getContentExtension = require_utils_getContentExtension.getContentExtens
|
|
|
34
32
|
exports.getExtensionFromFormat = require_utils_getFormatFromExtension.getExtensionFromFormat;
|
|
35
33
|
exports.getFormatFromExtension = require_utils_getFormatFromExtension.getFormatFromExtension;
|
|
36
34
|
exports.getGlobalLimiter = require_utils_parallelizeGlobal.getGlobalLimiter;
|
|
37
|
-
exports.getNodeTypeDefineVars = require_utils_getUsedNodeTypes.getNodeTypeDefineVars;
|
|
38
35
|
exports.getPathHash = require_utils_getPathHash.getPathHash;
|
|
39
36
|
exports.getTaskLimiter = require_utils_parallelizeGlobal.getTaskLimiter;
|
|
40
|
-
exports.getUsedNodeTypes = require_utils_getUsedNodeTypes.getUsedNodeTypes;
|
|
41
37
|
exports.mergeChunks = require_utils_mergeChunks.mergeChunks;
|
|
42
|
-
exports.nodeTypeToEnvVar = require_utils_getUsedNodeTypes.nodeTypeToEnvVar;
|
|
43
38
|
exports.pLimit = require_utils_pLimit.pLimit;
|
|
44
39
|
exports.parallelize = require_utils_parallelize.parallelize;
|
|
45
40
|
exports.parallelizeGlobal = require_utils_parallelizeGlobal.parallelizeGlobal;
|
|
@@ -19,6 +19,7 @@ const verifyIdenticObjectFormat = (object, expectedFormat, path = "root") => {
|
|
|
19
19
|
};
|
|
20
20
|
return { isIdentic: true };
|
|
21
21
|
}
|
|
22
|
+
if ((object === null || object === void 0) && typeof expectedFormat !== "object" && !Array.isArray(expectedFormat)) return { isIdentic: true };
|
|
22
23
|
const expectedType = Array.isArray(expectedFormat) ? "array" : typeof expectedFormat;
|
|
23
24
|
const objectType = Array.isArray(object) ? "array" : typeof object;
|
|
24
25
|
if (expectedType !== objectType) return {
|
|
@@ -43,9 +44,13 @@ const verifyIdenticObjectFormat = (object, expectedFormat, path = "root") => {
|
|
|
43
44
|
isIdentic: false,
|
|
44
45
|
error: `Object keys count mismatch at ${path}: expected ${expectedKeys.length} keys, got ${objectKeys.length}`
|
|
45
46
|
};
|
|
46
|
-
for (
|
|
47
|
+
for (const key of expectedKeys) if (!objectKeys.includes(key)) return {
|
|
47
48
|
isIdentic: false,
|
|
48
|
-
error: `
|
|
49
|
+
error: `Missing key at ${path}: expected key "${key}" not found`
|
|
50
|
+
};
|
|
51
|
+
for (const key of objectKeys) if (!expectedKeys.includes(key)) return {
|
|
52
|
+
isIdentic: false,
|
|
53
|
+
error: `Unexpected key at ${path}: key "${key}" was found but not expected`
|
|
49
54
|
};
|
|
50
55
|
for (const key of expectedKeys) {
|
|
51
56
|
const result = verifyIdenticObjectFormat(object[key], expectedFormat[key], `${path}.${key}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyIdenticObjectFormat.cjs","names":[],"sources":["../../../src/utils/verifyIdenticObjectFormat.ts"],"sourcesContent":["type FlatType = string | number | boolean | object | null | undefined;\n\ntype RecursiveType =\n | FlatType\n | { [key: string]: RecursiveType }\n | Array<RecursiveType>;\n\ntype VerifyIdenticObjectFormatResult = {\n isIdentic: boolean;\n error?: string;\n};\n\n/**\n * Verifies that two objects have identical structure (same keys, array lengths, and types)\n * but not necessarily the same values.\n * Useful for validating translations maintain the same format as the original.\n *\n * @param object - The object to verify\n * @param expectedFormat - The expected format to compare against\n * @param path - Current path in the object tree (for error messages)\n * @returns true if structures match, throws error with details if they don't\n */\nexport const verifyIdenticObjectFormat = (\n object: RecursiveType,\n expectedFormat: RecursiveType,\n path: string = 'root'\n): VerifyIdenticObjectFormatResult => {\n // Check if both are null or undefined\n if (expectedFormat === null || expectedFormat === undefined) {\n if (expectedFormat !== object) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedFormat === null ? 'null' : 'undefined'}, got ${object === null ? 'null' : typeof object}`,\n };\n }\n return {\n isIdentic: true,\n };\n }\n\n // Get the type of both values\n const expectedType = Array.isArray(expectedFormat)\n ? 'array'\n : typeof expectedFormat;\n const objectType = Array.isArray(object) ? 'array' : typeof object;\n\n // Check if types match\n if (expectedType !== objectType) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedType}, got ${objectType}`,\n };\n }\n\n // Handle arrays\n if (Array.isArray(expectedFormat) && Array.isArray(object)) {\n if (expectedFormat.length !== object.length) {\n return {\n isIdentic: false,\n error: `Array length mismatch at ${path}: expected ${expectedFormat.length} elements, got ${object.length}`,\n };\n }\n\n // Recursively check each element\n for (let i = 0; i < expectedFormat.length; i++) {\n const result = verifyIdenticObjectFormat(\n object[i],\n expectedFormat[i],\n `${path}[${i}]`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // Handle objects (excluding null and arrays)\n if (\n typeof expectedFormat === 'object' &&\n typeof object === 'object' &&\n expectedFormat !== null &&\n object !== null\n ) {\n const expectedKeys = Object.keys(expectedFormat);\n const objectKeys = Object.keys(object);\n\n // Check if number of keys match\n if (expectedKeys.length !== objectKeys.length) {\n return {\n isIdentic: false,\n error: `Object keys count mismatch at ${path}: expected ${expectedKeys.length} keys, got ${objectKeys.length}`,\n };\n }\n\n // Check if
|
|
1
|
+
{"version":3,"file":"verifyIdenticObjectFormat.cjs","names":[],"sources":["../../../src/utils/verifyIdenticObjectFormat.ts"],"sourcesContent":["type FlatType = string | number | boolean | object | null | undefined;\n\ntype RecursiveType =\n | FlatType\n | { [key: string]: RecursiveType }\n | Array<RecursiveType>;\n\ntype VerifyIdenticObjectFormatResult = {\n isIdentic: boolean;\n error?: string;\n};\n\n/**\n * Verifies that two objects have identical structure (same keys, array lengths, and types)\n * but not necessarily the same values.\n * Useful for validating translations maintain the same format as the original.\n *\n * @param object - The object to verify\n * @param expectedFormat - The expected format to compare against\n * @param path - Current path in the object tree (for error messages)\n * @returns true if structures match, throws error with details if they don't\n */\nexport const verifyIdenticObjectFormat = (\n object: RecursiveType,\n expectedFormat: RecursiveType,\n path: string = 'root'\n): VerifyIdenticObjectFormatResult => {\n // Check if both are null or undefined\n if (expectedFormat === null || expectedFormat === undefined) {\n if (expectedFormat !== object) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedFormat === null ? 'null' : 'undefined'}, got ${object === null ? 'null' : typeof object}`,\n };\n }\n return {\n isIdentic: true,\n };\n }\n\n // Allow null/undefined returns from AI for any expected primitive type\n // (AI may return null for content it cannot translate)\n if (\n (object === null || object === undefined) &&\n typeof expectedFormat !== 'object' &&\n !Array.isArray(expectedFormat)\n ) {\n return { isIdentic: true };\n }\n\n // Get the type of both values\n const expectedType = Array.isArray(expectedFormat)\n ? 'array'\n : typeof expectedFormat;\n const objectType = Array.isArray(object) ? 'array' : typeof object;\n\n // Check if types match\n if (expectedType !== objectType) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedType}, got ${objectType}`,\n };\n }\n\n // Handle arrays\n if (Array.isArray(expectedFormat) && Array.isArray(object)) {\n if (expectedFormat.length !== object.length) {\n return {\n isIdentic: false,\n error: `Array length mismatch at ${path}: expected ${expectedFormat.length} elements, got ${object.length}`,\n };\n }\n\n // Recursively check each element\n for (let i = 0; i < expectedFormat.length; i++) {\n const result = verifyIdenticObjectFormat(\n object[i],\n expectedFormat[i],\n `${path}[${i}]`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // Handle objects (excluding null and arrays)\n if (\n typeof expectedFormat === 'object' &&\n typeof object === 'object' &&\n expectedFormat !== null &&\n object !== null\n ) {\n const expectedKeys = Object.keys(expectedFormat);\n const objectKeys = Object.keys(object);\n\n // Check if number of keys match\n if (expectedKeys.length !== objectKeys.length) {\n return {\n isIdentic: false,\n error: `Object keys count mismatch at ${path}: expected ${expectedKeys.length} keys, got ${objectKeys.length}`,\n };\n }\n\n // Check if each expected key is present in the object\n for (const key of expectedKeys) {\n if (!objectKeys.includes(key)) {\n return {\n isIdentic: false,\n error: `Missing key at ${path}: expected key \"${key}\" not found`,\n };\n }\n }\n\n // Check if there are any unexpected keys in the object\n for (const key of objectKeys) {\n if (!expectedKeys.includes(key)) {\n return {\n isIdentic: false,\n error: `Unexpected key at ${path}: key \"${key}\" was found but not expected`,\n };\n }\n }\n\n // Recursively check each property\n for (const key of expectedKeys) {\n const result = verifyIdenticObjectFormat(\n (object as Record<string, RecursiveType>)[key],\n (expectedFormat as Record<string, RecursiveType>)[key],\n `${path}.${key}`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // For primitive types (string, number, boolean), just verify they're the same type\n // We don't check the actual values as per requirements\n return {\n isIdentic: true,\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,6BACX,QACA,gBACA,OAAe,WACqB;AAEpC,KAAI,mBAAmB,QAAQ,mBAAmB,QAAW;AAC3D,MAAI,mBAAmB,OACrB,QAAO;GACL,WAAW;GACX,OAAO,oBAAoB,KAAK,aAAa,mBAAmB,OAAO,SAAS,YAAY,QAAQ,WAAW,OAAO,SAAS,OAAO;GACvI;AAEH,SAAO,EACL,WAAW,MACZ;;AAKH,MACG,WAAW,QAAQ,WAAW,WAC/B,OAAO,mBAAmB,YAC1B,CAAC,MAAM,QAAQ,eAAe,CAE9B,QAAO,EAAE,WAAW,MAAM;CAI5B,MAAM,eAAe,MAAM,QAAQ,eAAe,GAC9C,UACA,OAAO;CACX,MAAM,aAAa,MAAM,QAAQ,OAAO,GAAG,UAAU,OAAO;AAG5D,KAAI,iBAAiB,WACnB,QAAO;EACL,WAAW;EACX,OAAO,oBAAoB,KAAK,aAAa,aAAa,QAAQ;EACnE;AAIH,KAAI,MAAM,QAAQ,eAAe,IAAI,MAAM,QAAQ,OAAO,EAAE;AAC1D,MAAI,eAAe,WAAW,OAAO,OACnC,QAAO;GACL,WAAW;GACX,OAAO,4BAA4B,KAAK,aAAa,eAAe,OAAO,iBAAiB,OAAO;GACpG;AAIH,OAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;GAC9C,MAAM,SAAS,0BACb,OAAO,IACP,eAAe,IACf,GAAG,KAAK,GAAG,EAAE,GACd;AACD,OAAI,CAAC,OAAO,UACV,QAAO;;AAIX,SAAO,EACL,WAAW,MACZ;;AAIH,KACE,OAAO,mBAAmB,YAC1B,OAAO,WAAW,YAClB,mBAAmB,QACnB,WAAW,MACX;EACA,MAAM,eAAe,OAAO,KAAK,eAAe;EAChD,MAAM,aAAa,OAAO,KAAK,OAAO;AAGtC,MAAI,aAAa,WAAW,WAAW,OACrC,QAAO;GACL,WAAW;GACX,OAAO,iCAAiC,KAAK,aAAa,aAAa,OAAO,aAAa,WAAW;GACvG;AAIH,OAAK,MAAM,OAAO,aAChB,KAAI,CAAC,WAAW,SAAS,IAAI,CAC3B,QAAO;GACL,WAAW;GACX,OAAO,kBAAkB,KAAK,kBAAkB,IAAI;GACrD;AAKL,OAAK,MAAM,OAAO,WAChB,KAAI,CAAC,aAAa,SAAS,IAAI,CAC7B,QAAO;GACL,WAAW;GACX,OAAO,qBAAqB,KAAK,SAAS,IAAI;GAC/C;AAKL,OAAK,MAAM,OAAO,cAAc;GAC9B,MAAM,SAAS,0BACZ,OAAyC,MACzC,eAAiD,MAClD,GAAG,KAAK,GAAG,MACZ;AACD,OAAI,CAAC,OAAO,UACV,QAAO;;AAIX,SAAO,EACL,WAAW,MACZ;;AAKH,QAAO,EACL,WAAW,MACZ"}
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { listProjects } from "./listProjects.mjs";
|
|
2
2
|
import { listDictionaries, listDictionariesWithStats } from "./listDictionariesPath.mjs";
|
|
3
|
+
import { prepareIntlayer } from "./prepareIntlayer.mjs";
|
|
3
4
|
import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.mjs";
|
|
4
5
|
import { transformJSFile } from "./writeContentDeclaration/transformJSFile.mjs";
|
|
5
6
|
import { detectFormatCommand } from "./detectFormatCommand.mjs";
|
|
@@ -12,4 +13,4 @@ import { installMCP } from "./installMCP/installMCP.mjs";
|
|
|
12
13
|
import { listGitFiles, listGitLines } from "./listGitFiles.mjs";
|
|
13
14
|
import { logConfigDetails } from "./logConfigDetails.mjs";
|
|
14
15
|
|
|
15
|
-
export { PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, detectExportedComponentName, detectFormatCommand, getContentDeclarationFileTemplate, getInitialSkills, initIntlayer, installMCP, installSkills, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, transformJSFile, writeContentDeclaration, writeJSFile };
|
|
16
|
+
export { PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, detectExportedComponentName, detectFormatCommand, getContentDeclarationFileTemplate, getInitialSkills, initIntlayer, installMCP, installSkills, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, prepareIntlayer, transformJSFile, writeContentDeclaration, writeJSFile };
|
|
@@ -19,26 +19,26 @@ const formatDictionary = (dictionary) => {
|
|
|
19
19
|
};
|
|
20
20
|
return dictionary;
|
|
21
21
|
};
|
|
22
|
-
const formatDictionaries = (dictionaries) => dictionaries.map(formatDictionary);
|
|
23
|
-
const formatDictionaryOutput = (dictionary) => {
|
|
24
|
-
if (
|
|
22
|
+
const formatDictionaries = async (dictionaries) => Promise.all(dictionaries.map(formatDictionary));
|
|
23
|
+
const formatDictionaryOutput = (dictionary, format) => {
|
|
24
|
+
if (format === "icu") return {
|
|
25
25
|
...dictionary,
|
|
26
26
|
format: "icu",
|
|
27
27
|
content: intlayerToICUFormatter(dictionary.content)
|
|
28
28
|
};
|
|
29
|
-
if (
|
|
29
|
+
if (format === "i18next") return {
|
|
30
30
|
...dictionary,
|
|
31
31
|
format: "i18next",
|
|
32
32
|
content: intlayerToI18nextFormatter(dictionary.content)
|
|
33
33
|
};
|
|
34
|
-
if (
|
|
34
|
+
if (format === "vue-i18n") return {
|
|
35
35
|
...dictionary,
|
|
36
36
|
format: "vue-i18n",
|
|
37
37
|
content: intlayerToVueI18nFormatter(dictionary.content)
|
|
38
38
|
};
|
|
39
39
|
return dictionary;
|
|
40
40
|
};
|
|
41
|
-
const formatDictionariesOutput = (dictionaries) => dictionaries.map(formatDictionaryOutput);
|
|
41
|
+
const formatDictionariesOutput = (dictionaries, format) => dictionaries.map((dictionary) => formatDictionaryOutput(dictionary, format));
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
44
|
export { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput };
|
|
@@ -1 +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/dictionary';\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[]
|
|
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/dictionary';\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 = async (\n dictionaries: Dictionary[]\n): Promise<Dictionary[]> => Promise.all(dictionaries.map(formatDictionary));\n\nexport const formatDictionaryOutput = (\n dictionary: Dictionary,\n format: Dictionary['format']\n) => {\n if (format === 'icu') {\n return {\n ...dictionary,\n format: 'icu',\n content: intlayerToICUFormatter(dictionary.content),\n };\n }\n\n if (format === 'i18next') {\n return {\n ...dictionary,\n format: 'i18next',\n content: intlayerToI18nextFormatter(dictionary.content),\n };\n }\n\n if (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 = (\n dictionaries: Dictionary[],\n format: Dictionary['format']\n) =>\n dictionaries.map((dictionary) => formatDictionaryOutput(dictionary, format));\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,qBAAqB,OAChC,iBAC0B,QAAQ,IAAI,aAAa,IAAI,iBAAiB,CAAC;AAE3E,MAAa,0BACX,YACA,WACG;AACH,KAAI,WAAW,MACb,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,uBAAuB,WAAW,QAAQ;EACpD;AAGH,KAAI,WAAW,UACb,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,KAAI,WAAW,WACb,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,QAAO;;AAGT,MAAa,4BACX,cACA,WAEA,aAAa,KAAK,eAAe,uBAAuB,YAAY,OAAO,CAAC"}
|
|
@@ -25,11 +25,12 @@ const ensureIntlayerBundle = async (configuration) => {
|
|
|
25
25
|
}
|
|
26
26
|
return filePath;
|
|
27
27
|
};
|
|
28
|
-
const loadContentDeclaration = async (path, configuration, bundleFilePath) => {
|
|
28
|
+
const loadContentDeclaration = async (path, configuration, bundleFilePath, options) => {
|
|
29
29
|
const { build } = configuration;
|
|
30
30
|
const resolvedBundleFilePath = bundleFilePath ?? await ensureIntlayerBundle(configuration);
|
|
31
31
|
try {
|
|
32
32
|
return await loadExternalFile(path, {
|
|
33
|
+
logError: options?.logError,
|
|
33
34
|
projectRequire: build.require ?? getProjectRequire(),
|
|
34
35
|
buildOptions: { banner: { js: [`globalThis.INTLAYER_FILE_PATH = '${path}';`, `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`].join("\n") } },
|
|
35
36
|
aliases: { intlayer: resolvedBundleFilePath }
|
|
@@ -39,7 +40,7 @@ const loadContentDeclaration = async (path, configuration, bundleFilePath) => {
|
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
42
|
};
|
|
42
|
-
const loadContentDeclarations = async (contentDeclarationFilePath, configuration, onStatusUpdate) => {
|
|
43
|
+
const loadContentDeclarations = async (contentDeclarationFilePath, configuration, onStatusUpdate, options) => {
|
|
43
44
|
const { build, system } = configuration;
|
|
44
45
|
if (build.checkTypes) logTypeScriptErrors(contentDeclarationFilePath, configuration).catch((e) => {
|
|
45
46
|
console.error("Error during TypeScript validation:", e);
|
|
@@ -49,7 +50,7 @@ const loadContentDeclarations = async (contentDeclarationFilePath, configuration
|
|
|
49
50
|
const dictionariesPromises = contentDeclarationFilePath.map(async (path) => {
|
|
50
51
|
return {
|
|
51
52
|
relativePath: relative(system.baseDir, path),
|
|
52
|
-
dictionary: await loadContentDeclaration(path, configuration, bundleFilePath)
|
|
53
|
+
dictionary: await loadContentDeclaration(path, configuration, bundleFilePath, options)
|
|
53
54
|
};
|
|
54
55
|
});
|
|
55
56
|
const contentDeclarations = formatLocalDictionaries((await Promise.all(dictionariesPromises)).reduce((acc, { relativePath, dictionary }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadContentDeclaration.mjs","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile } from '@intlayer/config/file';\nimport { cacheDisk, getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { logTypeScriptErrors } from './logTypeScriptErrors';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n location: dict.location ?? configuration.dictionary?.location ?? 'local',\n localId: `${dict.key}::local::${relativePath}`,\n filePath: relativePath,\n }));\n\nexport const ensureIntlayerBundle = async (\n configuration: IntlayerConfig\n): Promise<string> => {\n const { system } = configuration;\n\n const { set, isValid } = cacheDisk(configuration, ['intlayer-bundle'], {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n });\n\n const filePath = join(system.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n return filePath;\n};\n\nexport const loadContentDeclaration = async (\n path: string,\n configuration: IntlayerConfig,\n bundleFilePath?: string\n): Promise<Dictionary | undefined> => {\n const { build } = configuration;\n\n const resolvedBundleFilePath =\n bundleFilePath ?? (await ensureIntlayerBundle(configuration));\n\n try {\n const dictionary = await loadExternalFile(path, {\n projectRequire: build.require ?? getProjectRequire(),\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: resolvedBundleFilePath,\n },\n });\n\n return dictionary;\n } catch (error) {\n console.error(`Error loading content declaration at ${path}:`, error);\n return undefined;\n }\n};\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const { build, system } = configuration;\n\n // Check for TypeScript warnings before we build\n if (build.checkTypes) {\n logTypeScriptErrors(contentDeclarationFilePath, configuration).catch(\n (e) => {\n console.error('Error during TypeScript validation:', e);\n }\n );\n }\n\n const bundleFilePath = await ensureIntlayerBundle(configuration);\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(system.baseDir, path);\n\n const dictionary = await loadContentDeclaration(\n path,\n configuration,\n bundleFilePath\n );\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n if (dictionary) {\n acc[relativePath] = dictionary;\n }\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n ).filter((dictionary) => dictionary.location !== 'remote');\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary,\n configuration\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration, {\n checkSchema: false,\n });\n } catch {\n console.error('Error loading content declarations');\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,2BACX,oBACA,kBAEA,OAAO,QAAQ,mBAAmB,CAAC,KAAK,CAAC,cAAc,WAAW;CAChE,GAAG;CACH,UAAU,KAAK,YAAY,cAAc,YAAY,YAAY;CACjE,SAAS,GAAG,KAAK,IAAI,WAAW;CAChC,UAAU;CACX,EAAE;AAEL,MAAa,uBAAuB,OAClC,kBACoB;CACpB,MAAM,EAAE,WAAW;CAEnB,MAAM,EAAE,KAAK,YAAY,UAAU,eAAe,CAAC,kBAAkB,EAAE,EACrE,OAAO,MAAO,KAAK,KAAK,KAAK,GAC9B,CAAC;CAEF,MAAM,WAAW,KAAK,OAAO,UAAU,sBAAsB;AAG7D,KAAI,CAFsB,MAAM,SAAS,EAEjB;AAEtB,QAAM,UAAU,UADO,MAAM,kBAAkB,cAAc,CACpB;AACzC,QAAM,IAAI,KAAK;;AAGjB,QAAO;;
|
|
1
|
+
{"version":3,"file":"loadContentDeclaration.mjs","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile } from '@intlayer/config/file';\nimport { cacheDisk, getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { logTypeScriptErrors } from './logTypeScriptErrors';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n location: dict.location ?? configuration.dictionary?.location ?? 'local',\n localId: `${dict.key}::local::${relativePath}`,\n filePath: relativePath,\n }));\n\nexport const ensureIntlayerBundle = async (\n configuration: IntlayerConfig\n): Promise<string> => {\n const { system } = configuration;\n\n const { set, isValid } = cacheDisk(configuration, ['intlayer-bundle'], {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n });\n\n const filePath = join(system.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n return filePath;\n};\n\ntype LoadContentDeclarationOptions = {\n logError?: boolean;\n};\n\nexport const loadContentDeclaration = async (\n path: string,\n configuration: IntlayerConfig,\n bundleFilePath?: string,\n options?: LoadContentDeclarationOptions\n): Promise<Dictionary | undefined> => {\n const { build } = configuration;\n\n const resolvedBundleFilePath =\n bundleFilePath ?? (await ensureIntlayerBundle(configuration));\n\n try {\n const dictionary = await loadExternalFile(path, {\n logError: options?.logError,\n projectRequire: build.require ?? getProjectRequire(),\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: resolvedBundleFilePath,\n },\n });\n\n return dictionary;\n } catch (error) {\n console.error(`Error loading content declaration at ${path}:`, error);\n return undefined;\n }\n};\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void,\n options?: LoadContentDeclarationOptions\n): Promise<Dictionary[]> => {\n const { build, system } = configuration;\n\n // Check for TypeScript warnings before we build\n if (build.checkTypes) {\n logTypeScriptErrors(contentDeclarationFilePath, configuration).catch(\n (e) => {\n console.error('Error during TypeScript validation:', e);\n }\n );\n }\n\n const bundleFilePath = await ensureIntlayerBundle(configuration);\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(system.baseDir, path);\n\n const dictionary = await loadContentDeclaration(\n path,\n configuration,\n bundleFilePath,\n options\n );\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n if (dictionary) {\n acc[relativePath] = dictionary;\n }\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n ).filter((dictionary) => dictionary.location !== 'remote');\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary,\n configuration\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration, {\n checkSchema: false,\n });\n } catch {\n console.error('Error loading content declarations');\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,2BACX,oBACA,kBAEA,OAAO,QAAQ,mBAAmB,CAAC,KAAK,CAAC,cAAc,WAAW;CAChE,GAAG;CACH,UAAU,KAAK,YAAY,cAAc,YAAY,YAAY;CACjE,SAAS,GAAG,KAAK,IAAI,WAAW;CAChC,UAAU;CACX,EAAE;AAEL,MAAa,uBAAuB,OAClC,kBACoB;CACpB,MAAM,EAAE,WAAW;CAEnB,MAAM,EAAE,KAAK,YAAY,UAAU,eAAe,CAAC,kBAAkB,EAAE,EACrE,OAAO,MAAO,KAAK,KAAK,KAAK,GAC9B,CAAC;CAEF,MAAM,WAAW,KAAK,OAAO,UAAU,sBAAsB;AAG7D,KAAI,CAFsB,MAAM,SAAS,EAEjB;AAEtB,QAAM,UAAU,UADO,MAAM,kBAAkB,cAAc,CACpB;AACzC,QAAM,IAAI,KAAK;;AAGjB,QAAO;;AAOT,MAAa,yBAAyB,OACpC,MACA,eACA,gBACA,YACoC;CACpC,MAAM,EAAE,UAAU;CAElB,MAAM,yBACJ,kBAAmB,MAAM,qBAAqB,cAAc;AAE9D,KAAI;AAiBF,SAhBmB,MAAM,iBAAiB,MAAM;GAC9C,UAAU,SAAS;GACnB,gBAAgB,MAAM,WAAW,mBAAmB;GACpD,cAAc,EACZ,QAAQ,EACN,IAAI,CACF,oCAAoC,KAAK,KACzC,mCAAmC,cAAc,OAAO,QAAQ,IACjE,CAAC,KAAK,KAAK,EACb,EACF;GACD,SAAS,EACP,UAAU,wBACX;GACF,CAAC;UAGK,OAAO;AACd,UAAQ,MAAM,wCAAwC,KAAK,IAAI,MAAM;AACrE;;;AAIJ,MAAa,0BAA0B,OACrC,4BACA,eACA,gBACA,YAC0B;CAC1B,MAAM,EAAE,OAAO,WAAW;AAG1B,KAAI,MAAM,WACR,qBAAoB,4BAA4B,cAAc,CAAC,OAC5D,MAAM;AACL,UAAQ,MAAM,uCAAuC,EAAE;GAE1D;CAGH,MAAM,iBAAiB,MAAM,qBAAqB,cAAc;AAEhE,KAAI;EACF,MAAM,uBAAuB,2BAA2B,IACtD,OAAO,SAAS;AAUd,UAAO;IAAE,cATY,SAAS,OAAO,SAAS,KAAK;IAS5B,YAPJ,MAAM,uBACvB,MACA,eACA,gBACA,QACD;IAEkC;IAEtC;EAaD,MAAM,sBAAoC,yBAXhB,MAAM,QAAQ,IAAI,qBAAqB,EACpB,QAC1C,KAAK,EAAE,cAAc,iBAAiB;AACrC,OAAI,WACF,KAAI,gBAAgB;AAEtB,UAAO;KAET,EAAE,CACH,EAIC,cACD,CAAC,QAAQ,eAAe,WAAW,aAAa,SAAS;EAE1D,MAAM,wBAAwB,oBAAoB,KAAK,iBAAiB;GACtE,eAAe,YAAY;GAC3B,MAAM;GACN,QAAQ;GACT,EAAE;AAEH,mBAAiB,sBAAsB;AAsCvC,SAAO,0BApCuB,MAAM,YAClC,qBACA,OAAO,uBAAwD;AAC7D,OAAI,CAAC,mBACH;AAGF,oBAAiB,CACf;IACE,eAAe,mBAAmB;IAClC,MAAM;IACN,QAAQ;IACT,CACF,CAAC;GAEF,MAAM,8BAA8B,MAAM,0BACxC,oBACA,cACD;AAED,OAAI,CAAC,4BACH;AAGF,oBAAiB,CACf;IACE,eAAe,4BAA4B;IAC3C,MAAM;IACN,QAAQ;IACT,CACF,CAAC;AAEF,UAAO;IAEV,EAEuD,eAAe,EACrE,aAAa,OACd,CAAC;SACI;AACN,UAAQ,MAAM,qCAAqC;;AAGrD,QAAO,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.mjs","names":[],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize
|
|
1
|
+
{"version":3,"file":"formatter.mjs","names":[],"sources":["../../../src/utils/formatter.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n type ANSIColorsType,\n colorize,\n colorizePath,\n} from '@intlayer/config/logger';\nimport { getLocaleName } from '@intlayer/core/localization';\nimport { ENGLISH } from '@intlayer/types/locales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport const formatPath = (\n path: string | string[],\n color?: ANSIColorsType | false\n) =>\n [path]\n .flat()\n .map((path) =>\n path.startsWith('/') ? relative(configuration.system.baseDir, path) : path\n )\n .map((relativePath) =>\n color === false ? relativePath : colorizePath(relativePath, color)\n )\n .join(`, `);\n\nexport const formatLocale = (\n locale: LocalesValues | LocalesValues[],\n color: ANSIColorsType | false = ANSIColors.GREEN\n) =>\n [locale]\n .flat()\n .map((locale) => `${getLocaleName(locale, ENGLISH)} (${locale})`)\n .map((text) => (color === false ? text : colorize(text, color)))\n .join(`, `);\n"],"mappings":";;;;;;;;AAYA,MAAa,cACX,MACA,UAEA,CAAC,KAAK,CACH,MAAM,CACN,KAAK,SACJ,KAAK,WAAW,IAAI,GAAG,SAAS,cAAc,OAAO,SAAS,KAAK,GAAG,KACvE,CACA,KAAK,iBACJ,UAAU,QAAQ,eAAe,aAAa,cAAc,MAAM,CACnE,CACA,KAAK,KAAK;AAEf,MAAa,gBACX,QACA,QAAgC,WAAW,UAE3C,CAAC,OAAO,CACL,MAAM,CACN,KAAK,WAAW,GAAG,cAAc,QAAQ,QAAQ,CAAC,IAAI,OAAO,GAAG,CAChE,KAAK,SAAU,UAAU,QAAQ,OAAO,SAAS,MAAM,MAAM,CAAE,CAC/D,KAAK,KAAK"}
|
package/dist/esm/utils/index.mjs
CHANGED
|
@@ -9,7 +9,6 @@ import { getChunk } from "./getChunk.mjs";
|
|
|
9
9
|
import { assembleJSON, chunkJSON, reconstructFromSingleChunk } from "./chunkJSON.mjs";
|
|
10
10
|
import { getContentExtension } from "./getContentExtension.mjs";
|
|
11
11
|
import { getExtensionFromFormat, getFormatFromExtension } from "./getFormatFromExtension.mjs";
|
|
12
|
-
import { PLUGIN_NODE_TYPES, getNodeTypeDefineVars, getUsedNodeTypes, nodeTypeToEnvVar } from "./getUsedNodeTypes.mjs";
|
|
13
12
|
import { mergeChunks } from "./mergeChunks.mjs";
|
|
14
13
|
import { getGlobalLimiter, getTaskLimiter, parallelizeGlobal } from "./parallelizeGlobal.mjs";
|
|
15
14
|
import { reduceObjectFormat } from "./reduceObjectFormat.mjs";
|
|
@@ -20,4 +19,4 @@ import { runParallel } from "./runParallel/index.mjs";
|
|
|
20
19
|
import { sortAlphabetically } from "./sortAlphabetically.mjs";
|
|
21
20
|
import { verifyIdenticObjectFormat } from "./verifyIdenticObjectFormat.mjs";
|
|
22
21
|
|
|
23
|
-
export {
|
|
22
|
+
export { Queue, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, formatLocale, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, mergeChunks, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, resolveRelativePath, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
|
|
@@ -17,6 +17,7 @@ const verifyIdenticObjectFormat = (object, expectedFormat, path = "root") => {
|
|
|
17
17
|
};
|
|
18
18
|
return { isIdentic: true };
|
|
19
19
|
}
|
|
20
|
+
if ((object === null || object === void 0) && typeof expectedFormat !== "object" && !Array.isArray(expectedFormat)) return { isIdentic: true };
|
|
20
21
|
const expectedType = Array.isArray(expectedFormat) ? "array" : typeof expectedFormat;
|
|
21
22
|
const objectType = Array.isArray(object) ? "array" : typeof object;
|
|
22
23
|
if (expectedType !== objectType) return {
|
|
@@ -41,9 +42,13 @@ const verifyIdenticObjectFormat = (object, expectedFormat, path = "root") => {
|
|
|
41
42
|
isIdentic: false,
|
|
42
43
|
error: `Object keys count mismatch at ${path}: expected ${expectedKeys.length} keys, got ${objectKeys.length}`
|
|
43
44
|
};
|
|
44
|
-
for (
|
|
45
|
+
for (const key of expectedKeys) if (!objectKeys.includes(key)) return {
|
|
45
46
|
isIdentic: false,
|
|
46
|
-
error: `
|
|
47
|
+
error: `Missing key at ${path}: expected key "${key}" not found`
|
|
48
|
+
};
|
|
49
|
+
for (const key of objectKeys) if (!expectedKeys.includes(key)) return {
|
|
50
|
+
isIdentic: false,
|
|
51
|
+
error: `Unexpected key at ${path}: key "${key}" was found but not expected`
|
|
47
52
|
};
|
|
48
53
|
for (const key of expectedKeys) {
|
|
49
54
|
const result = verifyIdenticObjectFormat(object[key], expectedFormat[key], `${path}.${key}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyIdenticObjectFormat.mjs","names":[],"sources":["../../../src/utils/verifyIdenticObjectFormat.ts"],"sourcesContent":["type FlatType = string | number | boolean | object | null | undefined;\n\ntype RecursiveType =\n | FlatType\n | { [key: string]: RecursiveType }\n | Array<RecursiveType>;\n\ntype VerifyIdenticObjectFormatResult = {\n isIdentic: boolean;\n error?: string;\n};\n\n/**\n * Verifies that two objects have identical structure (same keys, array lengths, and types)\n * but not necessarily the same values.\n * Useful for validating translations maintain the same format as the original.\n *\n * @param object - The object to verify\n * @param expectedFormat - The expected format to compare against\n * @param path - Current path in the object tree (for error messages)\n * @returns true if structures match, throws error with details if they don't\n */\nexport const verifyIdenticObjectFormat = (\n object: RecursiveType,\n expectedFormat: RecursiveType,\n path: string = 'root'\n): VerifyIdenticObjectFormatResult => {\n // Check if both are null or undefined\n if (expectedFormat === null || expectedFormat === undefined) {\n if (expectedFormat !== object) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedFormat === null ? 'null' : 'undefined'}, got ${object === null ? 'null' : typeof object}`,\n };\n }\n return {\n isIdentic: true,\n };\n }\n\n // Get the type of both values\n const expectedType = Array.isArray(expectedFormat)\n ? 'array'\n : typeof expectedFormat;\n const objectType = Array.isArray(object) ? 'array' : typeof object;\n\n // Check if types match\n if (expectedType !== objectType) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedType}, got ${objectType}`,\n };\n }\n\n // Handle arrays\n if (Array.isArray(expectedFormat) && Array.isArray(object)) {\n if (expectedFormat.length !== object.length) {\n return {\n isIdentic: false,\n error: `Array length mismatch at ${path}: expected ${expectedFormat.length} elements, got ${object.length}`,\n };\n }\n\n // Recursively check each element\n for (let i = 0; i < expectedFormat.length; i++) {\n const result = verifyIdenticObjectFormat(\n object[i],\n expectedFormat[i],\n `${path}[${i}]`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // Handle objects (excluding null and arrays)\n if (\n typeof expectedFormat === 'object' &&\n typeof object === 'object' &&\n expectedFormat !== null &&\n object !== null\n ) {\n const expectedKeys = Object.keys(expectedFormat);\n const objectKeys = Object.keys(object);\n\n // Check if number of keys match\n if (expectedKeys.length !== objectKeys.length) {\n return {\n isIdentic: false,\n error: `Object keys count mismatch at ${path}: expected ${expectedKeys.length} keys, got ${objectKeys.length}`,\n };\n }\n\n // Check if
|
|
1
|
+
{"version":3,"file":"verifyIdenticObjectFormat.mjs","names":[],"sources":["../../../src/utils/verifyIdenticObjectFormat.ts"],"sourcesContent":["type FlatType = string | number | boolean | object | null | undefined;\n\ntype RecursiveType =\n | FlatType\n | { [key: string]: RecursiveType }\n | Array<RecursiveType>;\n\ntype VerifyIdenticObjectFormatResult = {\n isIdentic: boolean;\n error?: string;\n};\n\n/**\n * Verifies that two objects have identical structure (same keys, array lengths, and types)\n * but not necessarily the same values.\n * Useful for validating translations maintain the same format as the original.\n *\n * @param object - The object to verify\n * @param expectedFormat - The expected format to compare against\n * @param path - Current path in the object tree (for error messages)\n * @returns true if structures match, throws error with details if they don't\n */\nexport const verifyIdenticObjectFormat = (\n object: RecursiveType,\n expectedFormat: RecursiveType,\n path: string = 'root'\n): VerifyIdenticObjectFormatResult => {\n // Check if both are null or undefined\n if (expectedFormat === null || expectedFormat === undefined) {\n if (expectedFormat !== object) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedFormat === null ? 'null' : 'undefined'}, got ${object === null ? 'null' : typeof object}`,\n };\n }\n return {\n isIdentic: true,\n };\n }\n\n // Allow null/undefined returns from AI for any expected primitive type\n // (AI may return null for content it cannot translate)\n if (\n (object === null || object === undefined) &&\n typeof expectedFormat !== 'object' &&\n !Array.isArray(expectedFormat)\n ) {\n return { isIdentic: true };\n }\n\n // Get the type of both values\n const expectedType = Array.isArray(expectedFormat)\n ? 'array'\n : typeof expectedFormat;\n const objectType = Array.isArray(object) ? 'array' : typeof object;\n\n // Check if types match\n if (expectedType !== objectType) {\n return {\n isIdentic: false,\n error: `Type mismatch at ${path}: expected ${expectedType}, got ${objectType}`,\n };\n }\n\n // Handle arrays\n if (Array.isArray(expectedFormat) && Array.isArray(object)) {\n if (expectedFormat.length !== object.length) {\n return {\n isIdentic: false,\n error: `Array length mismatch at ${path}: expected ${expectedFormat.length} elements, got ${object.length}`,\n };\n }\n\n // Recursively check each element\n for (let i = 0; i < expectedFormat.length; i++) {\n const result = verifyIdenticObjectFormat(\n object[i],\n expectedFormat[i],\n `${path}[${i}]`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // Handle objects (excluding null and arrays)\n if (\n typeof expectedFormat === 'object' &&\n typeof object === 'object' &&\n expectedFormat !== null &&\n object !== null\n ) {\n const expectedKeys = Object.keys(expectedFormat);\n const objectKeys = Object.keys(object);\n\n // Check if number of keys match\n if (expectedKeys.length !== objectKeys.length) {\n return {\n isIdentic: false,\n error: `Object keys count mismatch at ${path}: expected ${expectedKeys.length} keys, got ${objectKeys.length}`,\n };\n }\n\n // Check if each expected key is present in the object\n for (const key of expectedKeys) {\n if (!objectKeys.includes(key)) {\n return {\n isIdentic: false,\n error: `Missing key at ${path}: expected key \"${key}\" not found`,\n };\n }\n }\n\n // Check if there are any unexpected keys in the object\n for (const key of objectKeys) {\n if (!expectedKeys.includes(key)) {\n return {\n isIdentic: false,\n error: `Unexpected key at ${path}: key \"${key}\" was found but not expected`,\n };\n }\n }\n\n // Recursively check each property\n for (const key of expectedKeys) {\n const result = verifyIdenticObjectFormat(\n (object as Record<string, RecursiveType>)[key],\n (expectedFormat as Record<string, RecursiveType>)[key],\n `${path}.${key}`\n );\n if (!result.isIdentic) {\n return result;\n }\n }\n\n return {\n isIdentic: true,\n };\n }\n\n // For primitive types (string, number, boolean), just verify they're the same type\n // We don't check the actual values as per requirements\n return {\n isIdentic: true,\n };\n};\n"],"mappings":";;;;;;;;;;;AAsBA,MAAa,6BACX,QACA,gBACA,OAAe,WACqB;AAEpC,KAAI,mBAAmB,QAAQ,mBAAmB,QAAW;AAC3D,MAAI,mBAAmB,OACrB,QAAO;GACL,WAAW;GACX,OAAO,oBAAoB,KAAK,aAAa,mBAAmB,OAAO,SAAS,YAAY,QAAQ,WAAW,OAAO,SAAS,OAAO;GACvI;AAEH,SAAO,EACL,WAAW,MACZ;;AAKH,MACG,WAAW,QAAQ,WAAW,WAC/B,OAAO,mBAAmB,YAC1B,CAAC,MAAM,QAAQ,eAAe,CAE9B,QAAO,EAAE,WAAW,MAAM;CAI5B,MAAM,eAAe,MAAM,QAAQ,eAAe,GAC9C,UACA,OAAO;CACX,MAAM,aAAa,MAAM,QAAQ,OAAO,GAAG,UAAU,OAAO;AAG5D,KAAI,iBAAiB,WACnB,QAAO;EACL,WAAW;EACX,OAAO,oBAAoB,KAAK,aAAa,aAAa,QAAQ;EACnE;AAIH,KAAI,MAAM,QAAQ,eAAe,IAAI,MAAM,QAAQ,OAAO,EAAE;AAC1D,MAAI,eAAe,WAAW,OAAO,OACnC,QAAO;GACL,WAAW;GACX,OAAO,4BAA4B,KAAK,aAAa,eAAe,OAAO,iBAAiB,OAAO;GACpG;AAIH,OAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;GAC9C,MAAM,SAAS,0BACb,OAAO,IACP,eAAe,IACf,GAAG,KAAK,GAAG,EAAE,GACd;AACD,OAAI,CAAC,OAAO,UACV,QAAO;;AAIX,SAAO,EACL,WAAW,MACZ;;AAIH,KACE,OAAO,mBAAmB,YAC1B,OAAO,WAAW,YAClB,mBAAmB,QACnB,WAAW,MACX;EACA,MAAM,eAAe,OAAO,KAAK,eAAe;EAChD,MAAM,aAAa,OAAO,KAAK,OAAO;AAGtC,MAAI,aAAa,WAAW,WAAW,OACrC,QAAO;GACL,WAAW;GACX,OAAO,iCAAiC,KAAK,aAAa,aAAa,OAAO,aAAa,WAAW;GACvG;AAIH,OAAK,MAAM,OAAO,aAChB,KAAI,CAAC,WAAW,SAAS,IAAI,CAC3B,QAAO;GACL,WAAW;GACX,OAAO,kBAAkB,KAAK,kBAAkB,IAAI;GACrD;AAKL,OAAK,MAAM,OAAO,WAChB,KAAI,CAAC,aAAa,SAAS,IAAI,CAC7B,QAAO;GACL,WAAW;GACX,OAAO,qBAAqB,KAAK,SAAS,IAAI;GAC/C;AAKL,OAAK,MAAM,OAAO,cAAc;GAC9B,MAAM,SAAS,0BACZ,OAAyC,MACzC,eAAiD,MAClD,GAAG,KAAK,GAAG,MACZ;AACD,OAAI,CAAC,OAAO,UACV,QAAO;;AAIX,SAAO,EACL,WAAW,MACZ;;AAKH,QAAO,EACL,WAAW,MACZ"}
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { prepareIntlayer } from "./prepareIntlayer.js";
|
|
1
2
|
import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.js";
|
|
2
3
|
import { DictionaryStatus } from "./writeContentDeclaration/dictionaryStatus.js";
|
|
3
4
|
import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
|
|
@@ -12,4 +13,4 @@ import { listDictionaries, listDictionariesWithStats } from "./listDictionariesP
|
|
|
12
13
|
import { DiffMode, ListGitFilesOptions, ListGitLinesOptions, listGitFiles, listGitLines } from "./listGitFiles.js";
|
|
13
14
|
import { ListProjectsOptions, listProjects } from "./listProjects.js";
|
|
14
15
|
import { logConfigDetails } from "./logConfigDetails.js";
|
|
15
|
-
export { DictionaryStatus, DiffMode, ListGitFilesOptions, ListGitLinesOptions, ListProjectsOptions, MCPTransport, PLATFORMS, PLATFORMS_METADATA, Platform, PlatformMetadata, SKILLS, SKILLS_METADATA, Skill, detectExportedComponentName, detectFormatCommand, getContentDeclarationFileTemplate, getInitialSkills, initIntlayer, installMCP, installSkills, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, transformJSFile, writeContentDeclaration, writeJSFile };
|
|
16
|
+
export { DictionaryStatus, DiffMode, ListGitFilesOptions, ListGitLinesOptions, ListProjectsOptions, MCPTransport, PLATFORMS, PLATFORMS_METADATA, Platform, PlatformMetadata, SKILLS, SKILLS_METADATA, Skill, detectExportedComponentName, detectFormatCommand, getContentDeclarationFileTemplate, getInitialSkills, initIntlayer, installMCP, installSkills, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, prepareIntlayer, transformJSFile, writeContentDeclaration, writeJSFile };
|
|
@@ -5,8 +5,8 @@ import * as _$_intlayer_types_module_augmentation0 from "@intlayer/types/module_
|
|
|
5
5
|
|
|
6
6
|
//#region src/formatDictionary.d.ts
|
|
7
7
|
declare const formatDictionary: (dictionary: Dictionary) => Dictionary;
|
|
8
|
-
declare const formatDictionaries: (dictionaries: Dictionary[]) => Dictionary[]
|
|
9
|
-
declare const formatDictionaryOutput: (dictionary: Dictionary) => Dictionary | {
|
|
8
|
+
declare const formatDictionaries: (dictionaries: Dictionary[]) => Promise<Dictionary[]>;
|
|
9
|
+
declare const formatDictionaryOutput: (dictionary: Dictionary, format: Dictionary["format"]) => Dictionary | {
|
|
10
10
|
format: string;
|
|
11
11
|
content: _$_intlayer_core_messageFormat0.JsonValue;
|
|
12
12
|
$schema?: "https://intlayer.org/schema.json";
|
|
@@ -30,7 +30,7 @@ declare const formatDictionaryOutput: (dictionary: Dictionary) => Dictionary | {
|
|
|
30
30
|
location?: _$_intlayer_types_dictionary0.DictionaryLocation;
|
|
31
31
|
schema: undefined;
|
|
32
32
|
};
|
|
33
|
-
declare const formatDictionariesOutput: (dictionaries: Dictionary[]) => (Dictionary | {
|
|
33
|
+
declare const formatDictionariesOutput: (dictionaries: Dictionary[], format: Dictionary["format"]) => (Dictionary | {
|
|
34
34
|
format: string;
|
|
35
35
|
content: _$_intlayer_core_messageFormat0.JsonValue;
|
|
36
36
|
$schema?: "https://intlayer.org/schema.json";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatDictionary.d.ts","names":[],"sources":["../../src/formatDictionary.ts"],"mappings":";;;;;;cAUa,gBAAA,GAAoB,UAAA,EAAY,UAAA,KAAa,UAAA;AAAA,cA4B7C,kBAAA,
|
|
1
|
+
{"version":3,"file":"formatDictionary.d.ts","names":[],"sources":["../../src/formatDictionary.ts"],"mappings":";;;;;;cAUa,gBAAA,GAAoB,UAAA,EAAY,UAAA,KAAa,UAAA;AAAA,cA4B7C,kBAAA,GACX,YAAA,EAAc,UAAA,OACb,OAAA,CAAQ,UAAA;AAAA,cAEE,sBAAA,GACX,UAAA,EAAY,UAAA,EACZ,MAAA,EAAQ,UAAA,eAAoB,UAAA;;WAAA,+BAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;cA6BjB,wBAAA,GACX,YAAA,EAAc,UAAA,IACd,MAAA,EAAQ,UAAA,gBAAoB,UAAA;;WAAA,+BAAA,CAAA,SAAA"}
|
|
@@ -5,8 +5,11 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
5
5
|
//#region src/loadDictionaries/loadContentDeclaration.d.ts
|
|
6
6
|
declare const formatLocalDictionaries: (dictionariesRecord: Record<string, Dictionary>, configuration: IntlayerConfig) => Dictionary[];
|
|
7
7
|
declare const ensureIntlayerBundle: (configuration: IntlayerConfig) => Promise<string>;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type LoadContentDeclarationOptions = {
|
|
9
|
+
logError?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const loadContentDeclaration: (path: string, configuration: IntlayerConfig, bundleFilePath?: string, options?: LoadContentDeclarationOptions) => Promise<Dictionary | undefined>;
|
|
12
|
+
declare const loadContentDeclarations: (contentDeclarationFilePath: string[], configuration: IntlayerConfig, onStatusUpdate?: (status: DictionariesStatus[]) => void, options?: LoadContentDeclarationOptions) => Promise<Dictionary[]>;
|
|
10
13
|
//#endregion
|
|
11
14
|
export { ensureIntlayerBundle, formatLocalDictionaries, loadContentDeclaration, loadContentDeclarations };
|
|
12
15
|
//# sourceMappingURL=loadContentDeclaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadContentDeclaration.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"mappings":";;;;;cAaa,uBAAA,GACX,kBAAA,EAAoB,MAAA,SAAe,UAAA,GACnC,aAAA,EAAe,cAAA,KACd,UAAA;AAAA,cAQU,oBAAA,GACX,aAAA,EAAe,cAAA,KACd,OAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"loadContentDeclaration.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"mappings":";;;;;cAaa,uBAAA,GACX,kBAAA,EAAoB,MAAA,SAAe,UAAA,GACnC,aAAA,EAAe,cAAA,KACd,UAAA;AAAA,cAQU,oBAAA,GACX,aAAA,EAAe,cAAA,KACd,OAAA;AAAA,KAmBE,6BAAA;EACH,QAAA;AAAA;AAAA,cAGW,sBAAA,GACX,IAAA,UACA,aAAA,EAAe,cAAA,EACf,cAAA,WACA,OAAA,GAAU,6BAAA,KACT,OAAA,CAAQ,UAAA;AAAA,cA8BE,uBAAA,GACX,0BAAA,YACA,aAAA,EAAe,cAAA,EACf,cAAA,IAAkB,MAAA,EAAQ,kBAAA,aAC1B,OAAA,GAAU,6BAAA,KACT,OAAA,CAAQ,UAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { ANSIColorsType } from "@intlayer/config/logger";
|
|
2
3
|
|
|
3
4
|
//#region src/utils/formatter.d.ts
|
|
4
|
-
declare const formatPath: (path: string | string[], color?:
|
|
5
|
-
declare const formatLocale: (locale: LocalesValues | LocalesValues[], color?:
|
|
5
|
+
declare const formatPath: (path: string | string[], color?: ANSIColorsType | false) => string;
|
|
6
|
+
declare const formatLocale: (locale: LocalesValues | LocalesValues[], color?: ANSIColorsType | false) => string;
|
|
6
7
|
//#endregion
|
|
7
8
|
export { formatLocale, formatPath };
|
|
8
9
|
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../../../src/utils/formatter.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","names":[],"sources":["../../../src/utils/formatter.ts"],"mappings":";;;;cAYa,UAAA,GACX,IAAA,qBACA,KAAA,GAAQ,cAAA;AAAA,cAYG,YAAA,GACX,MAAA,EAAQ,aAAA,GAAgB,aAAA,IACxB,KAAA,GAAO,cAAA"}
|
|
@@ -6,7 +6,6 @@ import { formatLocale, formatPath } from "./formatter.js";
|
|
|
6
6
|
import { getChunk } from "./getChunk.js";
|
|
7
7
|
import { getContentExtension } from "./getContentExtension.js";
|
|
8
8
|
import { getPathHash } from "./getPathHash.js";
|
|
9
|
-
import { PLUGIN_NODE_TYPES, PluginNodeType, getNodeTypeDefineVars, getUsedNodeTypes, nodeTypeToEnvVar } from "./getUsedNodeTypes.js";
|
|
10
9
|
import { mergeChunks } from "./mergeChunks.js";
|
|
11
10
|
import { parallelize } from "./parallelize.js";
|
|
12
11
|
import { Queue, pLimit } from "./pLimit.js";
|
|
@@ -19,4 +18,4 @@ import { ParallelHandle, runParallel } from "./runParallel/index.js";
|
|
|
19
18
|
import { sortAlphabetically } from "./sortAlphabetically.js";
|
|
20
19
|
import { splitTextByLines } from "./splitTextByLine.js";
|
|
21
20
|
import { verifyIdenticObjectFormat } from "./verifyIdenticObjectFormat.js";
|
|
22
|
-
export { Extension, Format, JSONObject, JsonChunk,
|
|
21
|
+
export { Extension, Format, JSONObject, JsonChunk, ParallelHandle, Queue, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, formatLocale, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, mergeChunks, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, resolveRelativePath, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -109,19 +109,18 @@
|
|
|
109
109
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@
|
|
113
|
-
"@intlayer/
|
|
114
|
-
"@intlayer/
|
|
115
|
-
"@intlayer/
|
|
116
|
-
"@intlayer/dictionaries-entry": "8.6.
|
|
117
|
-
"@intlayer/
|
|
118
|
-
"@intlayer/
|
|
119
|
-
"@intlayer/unmerged-dictionaries-entry": "8.6.0",
|
|
112
|
+
"@intlayer/api": "8.6.2",
|
|
113
|
+
"@intlayer/config": "8.6.2",
|
|
114
|
+
"@intlayer/core": "8.6.2",
|
|
115
|
+
"@intlayer/dictionaries-entry": "8.6.2",
|
|
116
|
+
"@intlayer/remote-dictionaries-entry": "8.6.2",
|
|
117
|
+
"@intlayer/types": "8.6.2",
|
|
118
|
+
"@intlayer/unmerged-dictionaries-entry": "8.6.2",
|
|
120
119
|
"chokidar": "3.6.0",
|
|
121
120
|
"defu": "6.1.4",
|
|
122
121
|
"fast-glob": "3.3.3",
|
|
123
122
|
"recast": "^0.23.11",
|
|
124
|
-
"simple-git": "3.
|
|
123
|
+
"simple-git": "3.33.0",
|
|
125
124
|
"zod-to-ts": "2.0.0"
|
|
126
125
|
},
|
|
127
126
|
"devDependencies": {
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
//#region src/utils/getUsedNodeTypes.ts
|
|
4
|
-
/**
|
|
5
|
-
* NodeType strings that correspond to plugins that can be conditionally
|
|
6
|
-
* removed from the bundle when unused.
|
|
7
|
-
*/
|
|
8
|
-
const PLUGIN_NODE_TYPES = [
|
|
9
|
-
"translation",
|
|
10
|
-
"enumeration",
|
|
11
|
-
"condition",
|
|
12
|
-
"insertion",
|
|
13
|
-
"gender",
|
|
14
|
-
"nested",
|
|
15
|
-
"file",
|
|
16
|
-
"markdown",
|
|
17
|
-
"html"
|
|
18
|
-
];
|
|
19
|
-
/** Recursively collect every `nodeType` string found in a value. */
|
|
20
|
-
const collectNodeTypes = (value, result) => {
|
|
21
|
-
if (!value || typeof value !== "object") return;
|
|
22
|
-
if (Array.isArray(value)) {
|
|
23
|
-
for (const item of value) collectNodeTypes(item, result);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const obj = value;
|
|
27
|
-
if (typeof obj.nodeType === "string") result.add(obj.nodeType);
|
|
28
|
-
for (const key of Object.keys(obj)) collectNodeTypes(obj[key], result);
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Returns the set of NodeType strings actually used across the given
|
|
32
|
-
* built dictionaries.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* const used = getUsedNodeTypes(getDictionaries(config));
|
|
36
|
-
* // Set { 'translation', 'enumeration' }
|
|
37
|
-
*/
|
|
38
|
-
const getUsedNodeTypes = (dictionaries) => {
|
|
39
|
-
const result = /* @__PURE__ */ new Set();
|
|
40
|
-
const dicts = Array.isArray(dictionaries) ? dictionaries : Object.values(dictionaries);
|
|
41
|
-
for (const dict of dicts) collectNodeTypes(dict.content, result);
|
|
42
|
-
return result;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Converts a NodeType key to its corresponding env-var name.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'
|
|
49
|
-
*/
|
|
50
|
-
const nodeTypeToEnvVar = (nodeType) => `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`;
|
|
51
|
-
/**
|
|
52
|
-
* Returns a record mapping each **unused** NodeType to `'false'` so build
|
|
53
|
-
* plugins can dead-code-eliminate the corresponding plugin from the bundle.
|
|
54
|
-
*
|
|
55
|
-
* Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).
|
|
56
|
-
* Build plugins that need `process.env.*` keys (Vite `define`, webpack
|
|
57
|
-
* `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values
|
|
58
|
-
* with `JSON.stringify`; Next.js `env:` can use the record directly.
|
|
59
|
-
*
|
|
60
|
-
* Only NodeTypes that are confirmed absent from all dictionaries get the
|
|
61
|
-
* `'false'` value; used (or unknown) types are omitted so they default to
|
|
62
|
-
* `true` inside `getPlugins` / `getBasePlugins`.
|
|
63
|
-
*
|
|
64
|
-
* @param usedNodeTypes - Set returned by `getUsedNodeTypes`.
|
|
65
|
-
* @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* // When only 'translation' is used:
|
|
69
|
-
* getNodeTypeDefineVars(new Set(['translation']))
|
|
70
|
-
* // {
|
|
71
|
-
* // INTLAYER_NODE_TYPE_ENUMERATION: 'false',
|
|
72
|
-
* // INTLAYER_NODE_TYPE_CONDITION: 'false',
|
|
73
|
-
* // ...
|
|
74
|
-
* // }
|
|
75
|
-
*/
|
|
76
|
-
const getNodeTypeDefineVars = (usedNodeTypes) => {
|
|
77
|
-
if (usedNodeTypes.size === 0) return {};
|
|
78
|
-
const result = {};
|
|
79
|
-
for (const nodeType of PLUGIN_NODE_TYPES) if (!usedNodeTypes.has(nodeType)) result[nodeTypeToEnvVar(nodeType)] = "false";
|
|
80
|
-
return result;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
exports.PLUGIN_NODE_TYPES = PLUGIN_NODE_TYPES;
|
|
85
|
-
exports.getNodeTypeDefineVars = getNodeTypeDefineVars;
|
|
86
|
-
exports.getUsedNodeTypes = getUsedNodeTypes;
|
|
87
|
-
exports.nodeTypeToEnvVar = nodeTypeToEnvVar;
|
|
88
|
-
//# sourceMappingURL=getUsedNodeTypes.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getUsedNodeTypes.cjs","names":[],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * NodeType strings that correspond to plugins that can be conditionally\n * removed from the bundle when unused.\n */\nexport const PLUGIN_NODE_TYPES = [\n 'translation',\n 'enumeration',\n 'condition',\n 'insertion',\n 'gender',\n 'nested',\n 'file',\n 'markdown',\n 'html',\n] as const;\n\nexport type PluginNodeType = (typeof PLUGIN_NODE_TYPES)[number];\n\n/** Recursively collect every `nodeType` string found in a value. */\nconst collectNodeTypes = (value: unknown, result: Set<string>): void => {\n if (!value || typeof value !== 'object') return;\n\n if (Array.isArray(value)) {\n for (const item of value) collectNodeTypes(item, result);\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n if (typeof obj.nodeType === 'string') {\n result.add(obj.nodeType);\n }\n\n for (const key of Object.keys(obj)) {\n collectNodeTypes(obj[key], result);\n }\n};\n\n/**\n * Returns the set of NodeType strings actually used across the given\n * built dictionaries.\n *\n * @example\n * const used = getUsedNodeTypes(getDictionaries(config));\n * // Set { 'translation', 'enumeration' }\n */\nexport const getUsedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Set<string> => {\n const result = new Set<string>();\n const dicts = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n for (const dict of dicts) {\n collectNodeTypes(dict.content, result);\n }\n\n return result;\n};\n\n/**\n * Converts a NodeType key to its corresponding env-var name.\n *\n * @example\n * nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'\n */\nexport const nodeTypeToEnvVar = (nodeType: string): string =>\n `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`;\n\n/**\n * Returns a record mapping each **unused** NodeType to `'false'` so build\n * plugins can dead-code-eliminate the corresponding plugin from the bundle.\n *\n * Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).\n * Build plugins that need `process.env.*` keys (Vite `define`, webpack\n * `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values\n * with `JSON.stringify`; Next.js `env:` can use the record directly.\n *\n * Only NodeTypes that are confirmed absent from all dictionaries get the\n * `'false'` value; used (or unknown) types are omitted so they default to\n * `true` inside `getPlugins` / `getBasePlugins`.\n *\n * @param usedNodeTypes - Set returned by `getUsedNodeTypes`.\n * @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.\n *\n * @example\n * // When only 'translation' is used:\n * getNodeTypeDefineVars(new Set(['translation']))\n * // {\n * // INTLAYER_NODE_TYPE_ENUMERATION: 'false',\n * // INTLAYER_NODE_TYPE_CONDITION: 'false',\n * // ...\n * // }\n */\nexport const getNodeTypeDefineVars = (\n usedNodeTypes: Set<string>\n): Record<string, string> => {\n // No dictionaries found yet → safe default: keep all plugins\n if (usedNodeTypes.size === 0) return {};\n\n const result: Record<string, string> = {};\n\n for (const nodeType of PLUGIN_NODE_TYPES) {\n if (!usedNodeTypes.has(nodeType)) {\n result[nodeTypeToEnvVar(nodeType)] = 'false';\n }\n }\n\n return result;\n};\n"],"mappings":";;;;;;;AAMA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;AAKD,MAAM,oBAAoB,OAAgB,WAA8B;AACtE,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AAEzC,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,OAAK,MAAM,QAAQ,MAAO,kBAAiB,MAAM,OAAO;AACxD;;CAGF,MAAM,MAAM;AAEZ,KAAI,OAAO,IAAI,aAAa,SAC1B,QAAO,IAAI,IAAI,SAAS;AAG1B,MAAK,MAAM,OAAO,OAAO,KAAK,IAAI,CAChC,kBAAiB,IAAI,MAAM,OAAO;;;;;;;;;;AAYtC,MAAa,oBACX,iBACgB;CAChB,MAAM,yBAAS,IAAI,KAAa;CAChC,MAAM,QAAQ,MAAM,QAAQ,aAAa,GACrC,eACA,OAAO,OAAO,aAAa;AAE/B,MAAK,MAAM,QAAQ,MACjB,kBAAiB,KAAK,SAAS,OAAO;AAGxC,QAAO;;;;;;;;AAST,MAAa,oBAAoB,aAC/B,sBAAsB,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2B9C,MAAa,yBACX,kBAC2B;AAE3B,KAAI,cAAc,SAAS,EAAG,QAAO,EAAE;CAEvC,MAAM,SAAiC,EAAE;AAEzC,MAAK,MAAM,YAAY,kBACrB,KAAI,CAAC,cAAc,IAAI,SAAS,CAC9B,QAAO,iBAAiB,SAAS,IAAI;AAIzC,QAAO"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
//#region src/utils/getUsedNodeTypes.ts
|
|
2
|
-
/**
|
|
3
|
-
* NodeType strings that correspond to plugins that can be conditionally
|
|
4
|
-
* removed from the bundle when unused.
|
|
5
|
-
*/
|
|
6
|
-
const PLUGIN_NODE_TYPES = [
|
|
7
|
-
"translation",
|
|
8
|
-
"enumeration",
|
|
9
|
-
"condition",
|
|
10
|
-
"insertion",
|
|
11
|
-
"gender",
|
|
12
|
-
"nested",
|
|
13
|
-
"file",
|
|
14
|
-
"markdown",
|
|
15
|
-
"html"
|
|
16
|
-
];
|
|
17
|
-
/** Recursively collect every `nodeType` string found in a value. */
|
|
18
|
-
const collectNodeTypes = (value, result) => {
|
|
19
|
-
if (!value || typeof value !== "object") return;
|
|
20
|
-
if (Array.isArray(value)) {
|
|
21
|
-
for (const item of value) collectNodeTypes(item, result);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const obj = value;
|
|
25
|
-
if (typeof obj.nodeType === "string") result.add(obj.nodeType);
|
|
26
|
-
for (const key of Object.keys(obj)) collectNodeTypes(obj[key], result);
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Returns the set of NodeType strings actually used across the given
|
|
30
|
-
* built dictionaries.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* const used = getUsedNodeTypes(getDictionaries(config));
|
|
34
|
-
* // Set { 'translation', 'enumeration' }
|
|
35
|
-
*/
|
|
36
|
-
const getUsedNodeTypes = (dictionaries) => {
|
|
37
|
-
const result = /* @__PURE__ */ new Set();
|
|
38
|
-
const dicts = Array.isArray(dictionaries) ? dictionaries : Object.values(dictionaries);
|
|
39
|
-
for (const dict of dicts) collectNodeTypes(dict.content, result);
|
|
40
|
-
return result;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Converts a NodeType key to its corresponding env-var name.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'
|
|
47
|
-
*/
|
|
48
|
-
const nodeTypeToEnvVar = (nodeType) => `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`;
|
|
49
|
-
/**
|
|
50
|
-
* Returns a record mapping each **unused** NodeType to `'false'` so build
|
|
51
|
-
* plugins can dead-code-eliminate the corresponding plugin from the bundle.
|
|
52
|
-
*
|
|
53
|
-
* Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).
|
|
54
|
-
* Build plugins that need `process.env.*` keys (Vite `define`, webpack
|
|
55
|
-
* `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values
|
|
56
|
-
* with `JSON.stringify`; Next.js `env:` can use the record directly.
|
|
57
|
-
*
|
|
58
|
-
* Only NodeTypes that are confirmed absent from all dictionaries get the
|
|
59
|
-
* `'false'` value; used (or unknown) types are omitted so they default to
|
|
60
|
-
* `true` inside `getPlugins` / `getBasePlugins`.
|
|
61
|
-
*
|
|
62
|
-
* @param usedNodeTypes - Set returned by `getUsedNodeTypes`.
|
|
63
|
-
* @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* // When only 'translation' is used:
|
|
67
|
-
* getNodeTypeDefineVars(new Set(['translation']))
|
|
68
|
-
* // {
|
|
69
|
-
* // INTLAYER_NODE_TYPE_ENUMERATION: 'false',
|
|
70
|
-
* // INTLAYER_NODE_TYPE_CONDITION: 'false',
|
|
71
|
-
* // ...
|
|
72
|
-
* // }
|
|
73
|
-
*/
|
|
74
|
-
const getNodeTypeDefineVars = (usedNodeTypes) => {
|
|
75
|
-
if (usedNodeTypes.size === 0) return {};
|
|
76
|
-
const result = {};
|
|
77
|
-
for (const nodeType of PLUGIN_NODE_TYPES) if (!usedNodeTypes.has(nodeType)) result[nodeTypeToEnvVar(nodeType)] = "false";
|
|
78
|
-
return result;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
//#endregion
|
|
82
|
-
export { PLUGIN_NODE_TYPES, getNodeTypeDefineVars, getUsedNodeTypes, nodeTypeToEnvVar };
|
|
83
|
-
//# sourceMappingURL=getUsedNodeTypes.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getUsedNodeTypes.mjs","names":[],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * NodeType strings that correspond to plugins that can be conditionally\n * removed from the bundle when unused.\n */\nexport const PLUGIN_NODE_TYPES = [\n 'translation',\n 'enumeration',\n 'condition',\n 'insertion',\n 'gender',\n 'nested',\n 'file',\n 'markdown',\n 'html',\n] as const;\n\nexport type PluginNodeType = (typeof PLUGIN_NODE_TYPES)[number];\n\n/** Recursively collect every `nodeType` string found in a value. */\nconst collectNodeTypes = (value: unknown, result: Set<string>): void => {\n if (!value || typeof value !== 'object') return;\n\n if (Array.isArray(value)) {\n for (const item of value) collectNodeTypes(item, result);\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n if (typeof obj.nodeType === 'string') {\n result.add(obj.nodeType);\n }\n\n for (const key of Object.keys(obj)) {\n collectNodeTypes(obj[key], result);\n }\n};\n\n/**\n * Returns the set of NodeType strings actually used across the given\n * built dictionaries.\n *\n * @example\n * const used = getUsedNodeTypes(getDictionaries(config));\n * // Set { 'translation', 'enumeration' }\n */\nexport const getUsedNodeTypes = (\n dictionaries: Record<string, Dictionary> | Dictionary[]\n): Set<string> => {\n const result = new Set<string>();\n const dicts = Array.isArray(dictionaries)\n ? dictionaries\n : Object.values(dictionaries);\n\n for (const dict of dicts) {\n collectNodeTypes(dict.content, result);\n }\n\n return result;\n};\n\n/**\n * Converts a NodeType key to its corresponding env-var name.\n *\n * @example\n * nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'\n */\nexport const nodeTypeToEnvVar = (nodeType: string): string =>\n `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`;\n\n/**\n * Returns a record mapping each **unused** NodeType to `'false'` so build\n * plugins can dead-code-eliminate the corresponding plugin from the bundle.\n *\n * Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).\n * Build plugins that need `process.env.*` keys (Vite `define`, webpack\n * `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values\n * with `JSON.stringify`; Next.js `env:` can use the record directly.\n *\n * Only NodeTypes that are confirmed absent from all dictionaries get the\n * `'false'` value; used (or unknown) types are omitted so they default to\n * `true` inside `getPlugins` / `getBasePlugins`.\n *\n * @param usedNodeTypes - Set returned by `getUsedNodeTypes`.\n * @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.\n *\n * @example\n * // When only 'translation' is used:\n * getNodeTypeDefineVars(new Set(['translation']))\n * // {\n * // INTLAYER_NODE_TYPE_ENUMERATION: 'false',\n * // INTLAYER_NODE_TYPE_CONDITION: 'false',\n * // ...\n * // }\n */\nexport const getNodeTypeDefineVars = (\n usedNodeTypes: Set<string>\n): Record<string, string> => {\n // No dictionaries found yet → safe default: keep all plugins\n if (usedNodeTypes.size === 0) return {};\n\n const result: Record<string, string> = {};\n\n for (const nodeType of PLUGIN_NODE_TYPES) {\n if (!usedNodeTypes.has(nodeType)) {\n result[nodeTypeToEnvVar(nodeType)] = 'false';\n }\n }\n\n return result;\n};\n"],"mappings":";;;;;AAMA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;AAKD,MAAM,oBAAoB,OAAgB,WAA8B;AACtE,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AAEzC,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,OAAK,MAAM,QAAQ,MAAO,kBAAiB,MAAM,OAAO;AACxD;;CAGF,MAAM,MAAM;AAEZ,KAAI,OAAO,IAAI,aAAa,SAC1B,QAAO,IAAI,IAAI,SAAS;AAG1B,MAAK,MAAM,OAAO,OAAO,KAAK,IAAI,CAChC,kBAAiB,IAAI,MAAM,OAAO;;;;;;;;;;AAYtC,MAAa,oBACX,iBACgB;CAChB,MAAM,yBAAS,IAAI,KAAa;CAChC,MAAM,QAAQ,MAAM,QAAQ,aAAa,GACrC,eACA,OAAO,OAAO,aAAa;AAE/B,MAAK,MAAM,QAAQ,MACjB,kBAAiB,KAAK,SAAS,OAAO;AAGxC,QAAO;;;;;;;;AAST,MAAa,oBAAoB,aAC/B,sBAAsB,SAAS,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2B9C,MAAa,yBACX,kBAC2B;AAE3B,KAAI,cAAc,SAAS,EAAG,QAAO,EAAE;CAEvC,MAAM,SAAiC,EAAE;AAEzC,MAAK,MAAM,YAAY,kBACrB,KAAI,CAAC,cAAc,IAAI,SAAS,CAC9B,QAAO,iBAAiB,SAAS,IAAI;AAIzC,QAAO"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Dictionary } from "@intlayer/types/dictionary";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/getUsedNodeTypes.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* NodeType strings that correspond to plugins that can be conditionally
|
|
6
|
-
* removed from the bundle when unused.
|
|
7
|
-
*/
|
|
8
|
-
declare const PLUGIN_NODE_TYPES: readonly ["translation", "enumeration", "condition", "insertion", "gender", "nested", "file", "markdown", "html"];
|
|
9
|
-
type PluginNodeType = (typeof PLUGIN_NODE_TYPES)[number];
|
|
10
|
-
/**
|
|
11
|
-
* Returns the set of NodeType strings actually used across the given
|
|
12
|
-
* built dictionaries.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const used = getUsedNodeTypes(getDictionaries(config));
|
|
16
|
-
* // Set { 'translation', 'enumeration' }
|
|
17
|
-
*/
|
|
18
|
-
declare const getUsedNodeTypes: (dictionaries: Record<string, Dictionary> | Dictionary[]) => Set<string>;
|
|
19
|
-
/**
|
|
20
|
-
* Converts a NodeType key to its corresponding env-var name.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* nodeTypeToEnvVar('enumeration') // 'INTLAYER_NODE_TYPE_ENUMERATION'
|
|
24
|
-
*/
|
|
25
|
-
declare const nodeTypeToEnvVar: (nodeType: string) => string;
|
|
26
|
-
/**
|
|
27
|
-
* Returns a record mapping each **unused** NodeType to `'false'` so build
|
|
28
|
-
* plugins can dead-code-eliminate the corresponding plugin from the bundle.
|
|
29
|
-
*
|
|
30
|
-
* Keys are bare env-var names (`INTLAYER_NODE_TYPE_*`).
|
|
31
|
-
* Build plugins that need `process.env.*` keys (Vite `define`, webpack
|
|
32
|
-
* `DefinePlugin`, Lynx `source.define`) should prefix them and wrap values
|
|
33
|
-
* with `JSON.stringify`; Next.js `env:` can use the record directly.
|
|
34
|
-
*
|
|
35
|
-
* Only NodeTypes that are confirmed absent from all dictionaries get the
|
|
36
|
-
* `'false'` value; used (or unknown) types are omitted so they default to
|
|
37
|
-
* `true` inside `getPlugins` / `getBasePlugins`.
|
|
38
|
-
*
|
|
39
|
-
* @param usedNodeTypes - Set returned by `getUsedNodeTypes`.
|
|
40
|
-
* @returns Record keyed by `INTLAYER_NODE_TYPE_*` → `'false'`.
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* // When only 'translation' is used:
|
|
44
|
-
* getNodeTypeDefineVars(new Set(['translation']))
|
|
45
|
-
* // {
|
|
46
|
-
* // INTLAYER_NODE_TYPE_ENUMERATION: 'false',
|
|
47
|
-
* // INTLAYER_NODE_TYPE_CONDITION: 'false',
|
|
48
|
-
* // ...
|
|
49
|
-
* // }
|
|
50
|
-
*/
|
|
51
|
-
declare const getNodeTypeDefineVars: (usedNodeTypes: Set<string>) => Record<string, string>;
|
|
52
|
-
//#endregion
|
|
53
|
-
export { PLUGIN_NODE_TYPES, PluginNodeType, getNodeTypeDefineVars, getUsedNodeTypes, nodeTypeToEnvVar };
|
|
54
|
-
//# sourceMappingURL=getUsedNodeTypes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getUsedNodeTypes.d.ts","names":[],"sources":["../../../src/utils/getUsedNodeTypes.ts"],"mappings":";;;;;AAMA;;cAAa,iBAAA;AAAA,KAYD,cAAA,WAAyB,iBAAA;;AAArC;;;;;AA8BA;;cAAa,gBAAA,GACX,YAAA,EAAc,MAAA,SAAe,UAAA,IAAc,UAAA,OAC1C,GAAA;;;;;;;cAmBU,gBAAA,GAAoB,QAAA;;;;;;;AAAjC;;;;;AA4BA;;;;;;;;;;;;;;cAAa,qBAAA,GACX,aAAA,EAAe,GAAA,aACd,MAAA"}
|