@intlayer/chokidar 7.0.4 → 7.0.6
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/_virtual/_utils_asset.cjs +3 -6
- package/dist/cjs/createType/createModuleAugmentation.cjs +1 -1
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +18 -4
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +27 -2
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +7 -1
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/esm/_virtual/_utils_asset.mjs +4 -7
- package/dist/esm/createType/createModuleAugmentation.mjs +1 -1
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +18 -4
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/log.mjs +27 -2
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +7 -1
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts +1 -0
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/log.d.ts +6 -0
- package/dist/types/loadDictionaries/log.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
- package/package.json +18 -18
|
@@ -17,7 +17,7 @@ const hereDirname = () => {
|
|
|
17
17
|
const findDistRoot = (startDir) => {
|
|
18
18
|
let dir = startDir;
|
|
19
19
|
for (let i = 0; i < 12; i++) {
|
|
20
|
-
if ((
|
|
20
|
+
if ((0, node_path.basename)(dir) === "dist") return dir;
|
|
21
21
|
const parent = (0, node_path.resolve)(dir, "..");
|
|
22
22
|
if (parent === dir) break;
|
|
23
23
|
dir = parent;
|
|
@@ -73,14 +73,11 @@ const readAsset = (relPath, encoding = "utf8") => {
|
|
|
73
73
|
const assetsRoot = (0, node_path.join)(distRoot, "assets");
|
|
74
74
|
const tried = [];
|
|
75
75
|
/**
|
|
76
|
-
* Transform
|
|
76
|
+
* Transform dist/(esm|cjs)/... and _virtual/ prefix to clean subpath (Windows-safe)
|
|
77
77
|
*/
|
|
78
|
-
const callerSubpath = (0, node_path.relative)(distRoot, getCallerDir()).split("\\").join("/").replace(/^
|
|
78
|
+
const callerSubpath = (0, node_path.relative)(distRoot, getCallerDir()).split("\\").join("/").replace(/^(?:dist\/)?(?:esm|cjs)\//, "").replace(/^_virtual\//, "");
|
|
79
79
|
if (relPath.startsWith("./") || relPath.startsWith("../")) {
|
|
80
80
|
const fromCallerAbs = (0, node_path.resolve)(assetsRoot, callerSubpath, relPath);
|
|
81
|
-
const fromCallerAbsToVirtual = fromCallerAbs.replace(/^dist\/esm\//, "/dist/assets/").replace(/^dist\/cjs\//, "/dist/assets/");
|
|
82
|
-
tried.push(fromCallerAbsToVirtual);
|
|
83
|
-
if ((0, node_fs.existsSync)(fromCallerAbsToVirtual)) return (0, node_fs.readFileSync)(fromCallerAbsToVirtual, encoding);
|
|
84
81
|
tried.push(fromCallerAbs);
|
|
85
82
|
if ((0, node_fs.existsSync)(fromCallerAbs)) return (0, node_fs.readFileSync)(fromCallerAbs, encoding);
|
|
86
83
|
}
|
|
@@ -20,7 +20,7 @@ const generateTypeIndexContent = (typeFiles, configuration) => {
|
|
|
20
20
|
const { content, internationalization } = configuration;
|
|
21
21
|
const { moduleAugmentationDir } = content;
|
|
22
22
|
const { locales, requiredLocales, strictMode } = internationalization;
|
|
23
|
-
let fileContent = "";
|
|
23
|
+
let fileContent = "import type \"intlayer\";\n";
|
|
24
24
|
const dictionariesRef = typeFiles.map((dictionaryPath) => ({
|
|
25
25
|
relativePath: `./${(0, node_path.relative)(moduleAugmentationDir, dictionaryPath)}`,
|
|
26
26
|
id: (0, node_path.basename)(dictionaryPath, (0, node_path.extname)(dictionaryPath)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createModuleAugmentation.cjs","names":["kebabCaseToCamelCase","getFileHash","formattedDictionaryMap: string","requiredLocales","writeFileIfChanged"],"sources":["../../../src/createType/createModuleAugmentation.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { basename, extname, join, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { getFileHash } from '../utils/getFileHash';\nimport { kebabCaseToCamelCase } from '../utils/kebabCaseToCamelCase';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/** Returns lines like: [Locales.FRENCH]: 1; */\nconst formatLocales = (locales: Locale[]) =>\n locales.map((locale) => ` \"${locale}\": 1;`).join('\\n');\n\n/** Generate the content of the module augmentation file */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration: IntlayerConfig\n): string => {\n const { content, internationalization } = configuration;\n const { moduleAugmentationDir } = content;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent = '';\n\n // Build dictionary refs\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)),\n hash: `_${getFileHash(dictionaryPath)}`,\n }));\n\n // Import all dictionaries\n for (const dictionary of dictionariesRef) {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n }\n fileContent += '\\n';\n\n // Dictionary map entries (id: typeof <hash>)\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n // Ensure required ⊆ declared; if empty, default required = declared\n const declared = locales;\n const requiredSanitized = requiredLocales?.length\n ? requiredLocales.filter((requiredLocales) =>\n declared.includes(requiredLocales)\n )\n : declared;\n\n const formattedDeclaredLocales = formatLocales(declared);\n const formattedRequiredLocales = formatLocales(requiredSanitized);\n\n // Choose strict mode registry key\n const strictKey =\n strictMode === 'strict'\n ? 'strict'\n : strictMode === 'inclusive'\n ? 'inclusive'\n : 'loose';\n\n /**\n * Module augmentation that ONLY adds keys to registries.\n * No types/aliases redefined here—avoids merge conflicts.\n */\n fileContent += `declare module 'intlayer' {\\n`;\n // Dictionaries registry\n fileContent += ` interface __DictionaryRegistry {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n // Locales registries\n fileContent += ` interface __DeclaredLocalesRegistry {\\n${formattedDeclaredLocales}\\n }\\n\\n`;\n fileContent += ` interface __RequiredLocalesRegistry {\\n${formattedRequiredLocales}\\n }\\n\\n`;\n // Resolved strict mode (narrow the literal at build time)\n fileContent += ` interface __StrictModeRegistry { mode: '${strictKey}' }\\n`;\n fileContent += `}\\n`;\n\n return fileContent;\n};\n\n/** Generate the index file merging all the types */\nexport const createModuleAugmentation = async (\n configuration: IntlayerConfig\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.content;\n\n await mkdir(moduleAugmentationDir, { recursive: true });\n\n const dictionariesTypesDefinitions: string[] = await fg(\n normalizePath(`${typesDir}/*.ts`),\n { ignore: ['**/*.d.ts'] }\n );\n\n const tsContent = generateTypeIndexContent(\n dictionariesTypesDefinitions,\n configuration\n );\n\n const tsFilePath = join(moduleAugmentationDir, 'intlayer.d.ts');\n await writeFileIfChanged(tsFilePath, tsContent);\n};\n"],"mappings":";;;;;;;;;;;;;;AASA,MAAa,eAAe,QAC1B,GAAGA,wDAAqB,IAAI,CAAC;;AAG/B,MAAM,iBAAiB,YACrB,QAAQ,KAAK,WAAW,QAAQ,OAAO,OAAO,CAAC,KAAK,KAAK;;AAG3D,MAAM,4BACJ,WACA,kBACW;CACX,MAAM,EAAE,SAAS,yBAAyB;CAC1C,MAAM,EAAE,0BAA0B;CAClC,MAAM,EAAE,SAAS,iBAAiB,eAAe;CAEjD,IAAI,cAAc;CAGlB,MAAM,kBAAkB,UAAU,KAAK,oBAAoB;EACzD,cAAc,6BAAc,uBAAuB,eAAe;EAClE,4BAAa,uCAAwB,eAAe,CAAC;EACrD,MAAM,IAAIC,sCAAY,eAAe;EACtC,EAAE;AAGH,MAAK,MAAM,cAAc,gBACvB,gBAAe,UAAU,WAAW,KAAK,SAAS,WAAW,aAAa;AAE5E,gBAAe;CAGf,MAAMC,yBAAiC,gBACpC,KAAK,eAAe,QAAQ,WAAW,GAAG,YAAY,WAAW,KAAK,GAAG,CACzE,KAAK,KAAK;CAGb,MAAM,WAAW;CACjB,MAAM,oBAAoB,iBAAiB,SACvC,gBAAgB,QAAQ,sBACtB,SAAS,SAASC,kBAAgB,CACnC,GACD;CAEJ,MAAM,2BAA2B,cAAc,SAAS;CACxD,MAAM,2BAA2B,cAAc,kBAAkB;CAGjE,MAAM,YACJ,eAAe,WACX,WACA,eAAe,cACb,cACA;;;;;AAMR,gBAAe;AAEf,gBAAe,uCAAuC,uBAAuB;AAE7E,gBAAe,4CAA4C,yBAAyB;AACpF,gBAAe,4CAA4C,yBAAyB;AAEpF,gBAAe,6CAA6C,UAAU;AACtE,gBAAe;AAEf,QAAO;;;AAIT,MAAa,2BAA2B,OACtC,kBACG;CACH,MAAM,EAAE,uBAAuB,aAAa,cAAc;AAE1D,mCAAY,uBAAuB,EAAE,WAAW,MAAM,CAAC;CAOvD,MAAM,YAAY,yBAL6B,kEAC/B,GAAG,SAAS,OAAO,EACjC,EAAE,QAAQ,CAAC,YAAY,EAAE,CAC1B,EAIC,cACD;AAGD,OAAMC,kEADkB,uBAAuB,gBAAgB,EAC1B,UAAU"}
|
|
1
|
+
{"version":3,"file":"createModuleAugmentation.cjs","names":["kebabCaseToCamelCase","getFileHash","formattedDictionaryMap: string","requiredLocales","writeFileIfChanged"],"sources":["../../../src/createType/createModuleAugmentation.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { basename, extname, join, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { getFileHash } from '../utils/getFileHash';\nimport { kebabCaseToCamelCase } from '../utils/kebabCaseToCamelCase';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/** Returns lines like: [Locales.FRENCH]: 1; */\nconst formatLocales = (locales: Locale[]) =>\n locales.map((locale) => ` \"${locale}\": 1;`).join('\\n');\n\n/** Generate the content of the module augmentation file */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration: IntlayerConfig\n): string => {\n const { content, internationalization } = configuration;\n const { moduleAugmentationDir } = content;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent = 'import type \"intlayer\";\\n';\n\n // Build dictionary refs\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)),\n hash: `_${getFileHash(dictionaryPath)}`,\n }));\n\n // Import all dictionaries\n for (const dictionary of dictionariesRef) {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n }\n fileContent += '\\n';\n\n // Dictionary map entries (id: typeof <hash>)\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n // Ensure required ⊆ declared; if empty, default required = declared\n const declared = locales;\n const requiredSanitized = requiredLocales?.length\n ? requiredLocales.filter((requiredLocales) =>\n declared.includes(requiredLocales)\n )\n : declared;\n\n const formattedDeclaredLocales = formatLocales(declared);\n const formattedRequiredLocales = formatLocales(requiredSanitized);\n\n // Choose strict mode registry key\n const strictKey =\n strictMode === 'strict'\n ? 'strict'\n : strictMode === 'inclusive'\n ? 'inclusive'\n : 'loose';\n\n /**\n * Module augmentation that ONLY adds keys to registries.\n * No types/aliases redefined here—avoids merge conflicts.\n */\n fileContent += `declare module 'intlayer' {\\n`;\n // Dictionaries registry\n fileContent += ` interface __DictionaryRegistry {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n // Locales registries\n fileContent += ` interface __DeclaredLocalesRegistry {\\n${formattedDeclaredLocales}\\n }\\n\\n`;\n fileContent += ` interface __RequiredLocalesRegistry {\\n${formattedRequiredLocales}\\n }\\n\\n`;\n // Resolved strict mode (narrow the literal at build time)\n fileContent += ` interface __StrictModeRegistry { mode: '${strictKey}' }\\n`;\n fileContent += `}\\n`;\n\n return fileContent;\n};\n\n/** Generate the index file merging all the types */\nexport const createModuleAugmentation = async (\n configuration: IntlayerConfig\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.content;\n\n await mkdir(moduleAugmentationDir, { recursive: true });\n\n const dictionariesTypesDefinitions: string[] = await fg(\n normalizePath(`${typesDir}/*.ts`),\n { ignore: ['**/*.d.ts'] }\n );\n\n const tsContent = generateTypeIndexContent(\n dictionariesTypesDefinitions,\n configuration\n );\n\n const tsFilePath = join(moduleAugmentationDir, 'intlayer.d.ts');\n await writeFileIfChanged(tsFilePath, tsContent);\n};\n"],"mappings":";;;;;;;;;;;;;;AASA,M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,EAIC,cACD;AAGD,OAAMC,kEADkB,uBAAuB,gBAAgB,EAC1B,UAAU"}
|
|
@@ -78,10 +78,22 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
78
78
|
const { plugins } = configuration;
|
|
79
79
|
const loadDictionariesStartTime = Date.now();
|
|
80
80
|
(0, __intlayer_config_client.getAppLogger)(configuration)("Dictionaries:", { isVerbose: true });
|
|
81
|
-
const
|
|
81
|
+
const pluginsWithLoadDictionaries = (plugins ?? []).filter((plugin) => plugin.loadDictionaries);
|
|
82
|
+
logger.setPluginTotal(pluginsWithLoadDictionaries.length);
|
|
83
|
+
const completedPluginIndices = /* @__PURE__ */ new Set();
|
|
84
|
+
const updatePluginProgress = () => {
|
|
85
|
+
logger.setPluginDone(completedPluginIndices.size);
|
|
86
|
+
};
|
|
87
|
+
const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(async (plugin, index) => {
|
|
82
88
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
const res = await plugin.loadDictionaries?.({ configuration });
|
|
90
|
+
completedPluginIndices.add(index);
|
|
91
|
+
updatePluginProgress();
|
|
92
|
+
return res ?? [];
|
|
93
|
+
} catch (error) {
|
|
94
|
+
logger.setPluginError(error);
|
|
95
|
+
completedPluginIndices.add(index);
|
|
96
|
+
updatePluginProgress();
|
|
85
97
|
return [];
|
|
86
98
|
}
|
|
87
99
|
});
|
|
@@ -103,6 +115,7 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
103
115
|
onError: (e) => logger.setRemoteError(e)
|
|
104
116
|
});
|
|
105
117
|
const remoteDictionariesTime = Date.now();
|
|
118
|
+
const pluginDictionariesTime = Date.now();
|
|
106
119
|
logger.finish();
|
|
107
120
|
printSummary(configuration);
|
|
108
121
|
return {
|
|
@@ -111,7 +124,8 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
111
124
|
pluginDictionaries,
|
|
112
125
|
time: {
|
|
113
126
|
localDictionaries: localDictionariesTime - loadDictionariesStartTime,
|
|
114
|
-
remoteDictionaries: remoteDictionariesTime - localDictionariesTime
|
|
127
|
+
remoteDictionaries: remoteDictionariesTime - localDictionariesTime,
|
|
128
|
+
pluginDictionaries: pluginDictionariesTime - remoteDictionariesTime
|
|
115
129
|
}
|
|
116
130
|
};
|
|
117
131
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDictionaries.cjs","names":["loadDictionariesStatus: DictionariesStatus[]","DictionariesLogger","updated: DictionariesStatus[]","ANSIColors","labels: string[]","pluginDictionaries: Dictionary[]","localDictionaries: Dictionary[]","loadContentDeclarations","filterInvalidDictionaries","remoteDictionaries: Dictionary[]","loadRemoteDictionaries"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const loadPluginDictionariesPromise = (plugins ?? []).map(async (plugin) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n return (res as Dictionary[] | undefined) ?? [];\n } catch {\n return [];\n }\n });\n\n const pluginDictionaries: Dictionary[] = (\n await Promise.all(loadPluginDictionariesPromise)\n ).flat();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries = filterInvalidDictionaries(\n localDictionaries,\n configuration\n );\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;AA4BA,IAAIA,yBAA+C,EAAE;AACrD,MAAM,SAAS,IAAIC,iDAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,UAAgC,CAAC,GAAG,uBAAuB;AAEjE,MAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,KACrE;AACD,MAAI,SAAS,EACX,SAAQ,SAAS;MAEjB,SAAQ,KAAK,SAAS;;AAI1B,0BAAyB;AACzB,QAAO,OAAO,SAAS;AAEvB,QAAO;;AAQT,MAAM,WAAW,WAAyC;AACxD,SAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,QACE,QAAO;;;AAIb,MAAM,YAAY,WAAyC;AACzD,SAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAOC,oCAAW;EACpB,KAAK,QACH,QAA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,iBAAiB;EACjD,UAAU,MAAM,OAAO,eAAe,EAAE;EACzC,CACF;CAEH,MAAM,yBAAyB,KAAK,KAAK;AAGzC,QAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL,mBAAmB;EACnB;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC9C;EACF"}
|
|
1
|
+
{"version":3,"file":"loadDictionaries.cjs","names":["loadDictionariesStatus: DictionariesStatus[]","DictionariesLogger","updated: DictionariesStatus[]","ANSIColors","labels: string[]","pluginDictionaries: Dictionary[]","localDictionaries: Dictionary[]","loadContentDeclarations","filterInvalidDictionaries","remoteDictionaries: Dictionary[]","loadRemoteDictionaries"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n logger.setPluginTotal(pluginsWithLoadDictionaries.length);\n\n const completedPluginIndices = new Set<number>();\n const updatePluginProgress = () => {\n logger.setPluginDone(completedPluginIndices.size);\n };\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin, index) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n completedPluginIndices.add(index);\n updatePluginProgress();\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n completedPluginIndices.add(index);\n updatePluginProgress();\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = (\n await Promise.all(loadPluginDictionariesPromise)\n ).flat();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries = filterInvalidDictionaries(\n localDictionaries,\n configuration\n );\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n const pluginDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - remoteDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;AA4BA,IAAIA,yBAA+C,EAAE;AACrD,MAAM,SAAS,IAAIC,iDAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,UAAgC,CAAC,GAAG,uBAAuB;AAEjE,MAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,KACrE;AACD,M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oC,EAAE;WACvC,OAAO;AACd,UAAO,eAAe,MAAe;AACrC,0BAAuB,IAAI,MAAM;AACjC,yBAAsB;AACtB,UAAO,EAAE;;GAGd;CAED,MAAME,sBACJ,MAAM,QAAQ,IAAI,8BAA8B,EAChD,MAAM;CAMR,MAAMC,oBAAkC,MAAMC,wEAJhC,MAAM,QAAQ,yBAAyB,GACjD,2BACA,CAAC,yBAAyB,EAI5B,eACA,0BACD;CAED,MAAM,wBAAwB,KAAK,KAAK;CAExC,MAAM,4BAA4BC,4DAChC,mBACA,cACD;AAWD,2BATgC,0BAA0B,KACvD,UACE;EACC,eAAe,KAAK;EACpB,MAAM;EACN,QAAQ;EACT,EACJ,CAEiD;CAElD,MAAM,wBAAwB,QAC5B,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAED,KAAI,sBAEF,QAAO,gBAAgB,KAAK;CAG9B,IAAIC,qBAAmC,EAAE;AACzC,KAAI,sBACF,sBAAqB,MAAMC,uEACzB,eACA,2BACA;EACE,0BAA0B,OAAO,kBAAkB;EACnD,yBAAyB,OAAO,iBAAiB;EACjD,UAAU,MAAM,OAAO,eAAe,EAAE;EACzC,CACF;CAEH,MAAM,yBAAyB,KAAK,KAAK;CAEzC,MAAM,yBAAyB,KAAK,KAAK;AAGzC,QAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL,mBAAmB;EACnB;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;GAC9C;EACF"}
|
|
@@ -17,6 +17,9 @@ var DictionariesLogger = class {
|
|
|
17
17
|
remoteCheckInProgress = false;
|
|
18
18
|
expectRemote = false;
|
|
19
19
|
remoteError;
|
|
20
|
+
pluginTotal = 0;
|
|
21
|
+
pluginDone = 0;
|
|
22
|
+
pluginError;
|
|
20
23
|
constructor() {
|
|
21
24
|
this.prefix = __intlayer_config_built.default?.log?.prefix ?? "";
|
|
22
25
|
}
|
|
@@ -66,19 +69,39 @@ var DictionariesLogger = class {
|
|
|
66
69
|
this.stopRemoteCheck();
|
|
67
70
|
this.render();
|
|
68
71
|
};
|
|
72
|
+
setPluginTotal(total) {
|
|
73
|
+
if (this.isFinished) return;
|
|
74
|
+
this.pluginTotal = total;
|
|
75
|
+
if (total > 0) this.startSpinner();
|
|
76
|
+
this.render();
|
|
77
|
+
}
|
|
78
|
+
setPluginDone(done) {
|
|
79
|
+
if (this.isFinished) return;
|
|
80
|
+
this.pluginDone = done;
|
|
81
|
+
this.render();
|
|
82
|
+
}
|
|
83
|
+
setPluginError(error) {
|
|
84
|
+
if (this.isFinished) return;
|
|
85
|
+
this.pluginError = (0, __intlayer_config_client.extractErrorMessage)(error);
|
|
86
|
+
this.render();
|
|
87
|
+
}
|
|
69
88
|
render() {
|
|
70
|
-
const { localTotal, localDone, remoteTotal, remoteDone } = this.computeProgress();
|
|
89
|
+
const { localTotal, localDone, remoteTotal, remoteDone, pluginTotal, pluginDone } = this.computeProgress();
|
|
71
90
|
const frame = this.spinnerFrames[this.spinnerIndex];
|
|
72
91
|
const clock = (0, __intlayer_config_client.colorize)(frame, __intlayer_config_client.ANSIColors.BLUE);
|
|
73
92
|
const lines = [];
|
|
74
93
|
const isLocalDone = localDone === localTotal;
|
|
75
94
|
const isRemoteDone = remoteDone === remoteTotal;
|
|
95
|
+
const isPluginDone = pluginDone === pluginTotal;
|
|
76
96
|
if (!(this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0)) if (isLocalDone) lines.push(`${this.prefix} ${__intlayer_config_client.v} Local content: ${(0, __intlayer_config_client.colorize)(`${localDone}`, __intlayer_config_client.ANSIColors.GREEN)}${(0, __intlayer_config_client.colorize)(`/${localTotal}`, __intlayer_config_client.ANSIColors.GREY)}`);
|
|
77
97
|
else lines.push(`${this.prefix} ${clock} Local content: ${(0, __intlayer_config_client.colorize)(`${localDone}`, __intlayer_config_client.ANSIColors.BLUE)}${(0, __intlayer_config_client.colorize)(`/${localTotal}`, __intlayer_config_client.ANSIColors.GREY)}`);
|
|
78
98
|
if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) if (this.remoteError) lines.push(`${this.prefix} ${__intlayer_config_client.x} Remote content: ${(0, __intlayer_config_client.colorize)(this.remoteError, __intlayer_config_client.ANSIColors.RED)}`);
|
|
79
99
|
else if (remoteTotal === 0) lines.push(`${this.prefix} ${clock} Remote content: ${(0, __intlayer_config_client.colorize)("Check server", __intlayer_config_client.ANSIColors.BLUE)}`);
|
|
80
100
|
else if (isRemoteDone) lines.push(`${this.prefix} ${__intlayer_config_client.v} Remote content: ${(0, __intlayer_config_client.colorize)(`${remoteDone}`, __intlayer_config_client.ANSIColors.GREEN)}${(0, __intlayer_config_client.colorize)(`/${remoteTotal}`, __intlayer_config_client.ANSIColors.GREY)}`);
|
|
81
101
|
else lines.push(`${this.prefix} ${clock} Remote content: ${(0, __intlayer_config_client.colorize)(`${remoteDone}`, __intlayer_config_client.ANSIColors.BLUE)}${(0, __intlayer_config_client.colorize)(`/${remoteTotal}`, __intlayer_config_client.ANSIColors.GREY)}`);
|
|
102
|
+
if (pluginTotal > 0 || this.pluginError) if (this.pluginError) lines.push(`${this.prefix} ${__intlayer_config_client.x} Plugin content: ${(0, __intlayer_config_client.colorize)(this.pluginError, __intlayer_config_client.ANSIColors.RED)}`);
|
|
103
|
+
else if (isPluginDone) lines.push(`${this.prefix} ${__intlayer_config_client.v} Plugin content: ${(0, __intlayer_config_client.colorize)(`${pluginDone}`, __intlayer_config_client.ANSIColors.GREEN)}${(0, __intlayer_config_client.colorize)(`/${pluginTotal}`, __intlayer_config_client.ANSIColors.GREY)}`);
|
|
104
|
+
else lines.push(`${this.prefix} ${clock} Plugin content: ${(0, __intlayer_config_client.colorize)(`${pluginDone}`, __intlayer_config_client.ANSIColors.BLUE)}${(0, __intlayer_config_client.colorize)(`/${pluginTotal}`, __intlayer_config_client.ANSIColors.GREY)}`);
|
|
82
105
|
const currentState = lines.join("\n");
|
|
83
106
|
if (currentState === this.lastRenderedState) return;
|
|
84
107
|
this.lastRenderedState = currentState;
|
|
@@ -101,7 +124,9 @@ var DictionariesLogger = class {
|
|
|
101
124
|
localTotal: localKeys.size,
|
|
102
125
|
localDone: localDoneKeys.size,
|
|
103
126
|
remoteTotal: remoteKeys.size,
|
|
104
|
-
remoteDone: remoteDoneKeys.size
|
|
127
|
+
remoteDone: remoteDoneKeys.size,
|
|
128
|
+
pluginTotal: this.pluginTotal,
|
|
129
|
+
pluginDone: this.pluginDone
|
|
105
130
|
};
|
|
106
131
|
}
|
|
107
132
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.cjs","names":["spinnerFrames","configuration","ANSIColors","lines: string[]","v","x"],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n ANSIColors,\n colorize,\n extractErrorMessage,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config/client';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError: string | undefined;\n\n constructor() {\n this.prefix = configuration?.log?.prefix ?? '';\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (error?: Error) => {\n this.remoteError = extractErrorMessage(error);\n // Avoid rendering a transient remote-only line while the remote check flag is still true\n // Ensure local + remote are rendered together after a failure\n this.stopRemoteCheck();\n this.render();\n };\n\n private render() {\n const { localTotal, localDone, remoteTotal, remoteDone } =\n this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote content: ${colorize(\n this.remoteError,\n ANSIColors.RED\n )}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n } as const;\n }\n}\n"],"mappings":";;;;;;;AAWA,IAAa,qBAAb,MAAgC;CAC9B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AAc,GAAG;EAGrD,MAAM,oBAAoB,KAAK,IAAI,KAAK,eAAe,MAAM,OAAO;AACpE,OAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,WAAQ,OAAO,MAAM,UAAU;GAC/B,MAAM,OAAO,MAAM;AACnB,OAAI,SAAS,OACX,SAAQ,OAAO,MAAM,KAAK;AAE5B,WAAQ,OAAO,MAAM,KAAK;;AAG5B,OAAK,gBAAgB,MAAM;;CAG7B,AAAQ,kBAAkB;EACxB,MAAM,YAAY,IAAI,IACpB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,QAAQ,CACjC,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,gBAAgB,IAAI,IACxB,KAAK,SACF,QACE,MACC,EAAE,SAAS,YAAY,EAAE,WAAW,WAAW,EAAE,WAAW,SAC/D,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,aAAa,IAAI,IACrB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,SAAS,CAClC,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,iBAAiB,IAAI,IACzB,KAAK,SACF,QACE,MACC,EAAE,SAAS,aACV,EAAE,WAAW,aACZ,EAAE,WAAW,cACb,EAAE,WAAW,SAClB,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;AAED,SAAO;GACL,YAAY,UAAU;GACtB,WAAW,cAAc;GACzB,aAAa,WAAW;GACxB,YAAY,eAAe;GAC5B"}
|
|
1
|
+
{"version":3,"file":"log.cjs","names":["spinnerFrames","configuration","ANSIColors","lines: string[]","v","x"],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n ANSIColors,\n colorize,\n extractErrorMessage,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config/client';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError: string | undefined;\n private pluginTotal = 0;\n private pluginDone = 0;\n private pluginError: string | undefined;\n\n constructor() {\n this.prefix = configuration?.log?.prefix ?? '';\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (error?: Error) => {\n this.remoteError = extractErrorMessage(error);\n // Avoid rendering a transient remote-only line while the remote check flag is still true\n // Ensure local + remote are rendered together after a failure\n this.stopRemoteCheck();\n this.render();\n };\n\n setPluginTotal(total: number) {\n if (this.isFinished) return;\n this.pluginTotal = total;\n if (total > 0) {\n this.startSpinner();\n }\n this.render();\n }\n\n setPluginDone(done: number) {\n if (this.isFinished) return;\n this.pluginDone = done;\n this.render();\n }\n\n setPluginError(error?: Error) {\n if (this.isFinished) return;\n this.pluginError = extractErrorMessage(error);\n this.render();\n }\n\n private render() {\n const {\n localTotal,\n localDone,\n remoteTotal,\n remoteDone,\n pluginTotal,\n pluginDone,\n } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n const isPluginDone = pluginDone === pluginTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote content: ${colorize(\n this.remoteError,\n ANSIColors.RED\n )}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Plugin line: show error or progress counts\n if (pluginTotal > 0 || this.pluginError) {\n if (this.pluginError) {\n lines.push(\n `${this.prefix} ${x} Plugin content: ${colorize(\n this.pluginError,\n ANSIColors.RED\n )}`\n );\n } else if (isPluginDone) {\n lines.push(\n `${this.prefix} ${v} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.GREEN)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.BLUE)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n pluginTotal: this.pluginTotal,\n pluginDone: this.pluginDone,\n }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c,CAC/B;EAED,MAAM,gBAAgB,IAAI,IACxB,KAAK,SACF,QACE,MACC,EAAE,SAAS,YAAY,EAAE,WAAW,WAAW,EAAE,WAAW,SAC/D,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,aAAa,IAAI,IACrB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,SAAS,CAClC,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,iBAAiB,IAAI,IACzB,KAAK,SACF,QACE,MACC,EAAE,SAAS,aACV,EAAE,WAAW,aACZ,EAAE,WAAW,cACb,EAAE,WAAW,SAClB,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;AAED,SAAO;GACL,YAAY,UAAU;GACtB,WAAW,cAAc;GACzB,aAAa,WAAW;GACxB,YAAY,eAAe;GAC3B,aAAa,KAAK;GAClB,YAAY,KAAK;GAClB"}
|
|
@@ -38,7 +38,13 @@ const prepareIntlayer = async (configuration, options) => {
|
|
|
38
38
|
appLogger(["Configuration written", (0, __intlayer_config.colorize)(`(${configurationWrittenTime - preparationStartMs}ms)`, __intlayer_config.ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
39
39
|
const dictionaries = await require_loadDictionaries_loadDictionaries.loadDictionaries(await require_listDictionariesPath.listDictionaries(configuration), configuration);
|
|
40
40
|
const dictionariesLoadedTime = Date.now();
|
|
41
|
-
appLogger(["Content loaded", (0, __intlayer_config.colorize)([dictionaries.remoteDictionaries.length
|
|
41
|
+
appLogger(["Content loaded", (0, __intlayer_config.colorize)([dictionaries.remoteDictionaries.length + dictionaries.pluginDictionaries.length > 0 ? [
|
|
42
|
+
`(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,
|
|
43
|
+
dictionaries.localDictionaries.length > 0 ? `- Local: ${dictionaries.time.localDictionaries}ms` : "",
|
|
44
|
+
dictionaries.remoteDictionaries.length > 0 ? `- Remote: ${dictionaries.time.remoteDictionaries}ms` : "",
|
|
45
|
+
dictionaries.pluginDictionaries.length > 0 ? `- Plugin: ${dictionaries.time.pluginDictionaries}ms` : "",
|
|
46
|
+
`)`
|
|
47
|
+
].join("") : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`].join(""), __intlayer_config.ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
42
48
|
const dictionariesOutput = await require_buildIntlayerDictionary_buildIntlayerDictionary.buildDictionary([
|
|
43
49
|
...dictionaries.localDictionaries,
|
|
44
50
|
...dictionaries.remoteDictionaries,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareIntlayer.cjs","names":["runOnce","packageJson","ANSIColors","writeConfiguration","loadDictionaries","listDictionaries","buildDictionary","writeRemoteDictionary","createTypes","createDictionaryEntryPoint","createModuleAugmentation"],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport { writeConfiguration } from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n format: ['cjs', 'esm'],\n forceRun: false,\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const { clean, format, forceRun, onIsCached } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n ...(options ?? {}),\n };\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n const { plugins } = configuration;\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const files: string[] = await listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(files, configuration);\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length
|
|
1
|
+
{"version":3,"file":"prepareIntlayer.cjs","names":["runOnce","packageJson","ANSIColors","writeConfiguration","loadDictionaries","listDictionaries","buildDictionary","writeRemoteDictionary","createTypes","createDictionaryEntryPoint","createModuleAugmentation"],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport { writeConfiguration } from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n format: ['cjs', 'esm'],\n forceRun: false,\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const { clean, format, forceRun, onIsCached } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n ...(options ?? {}),\n };\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n const { plugins } = configuration;\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const files: string[] = await listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(files, configuration);\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? `- Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? `- Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? `- Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths, configuration);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\n {\n level: 'info',\n isVerbose: true,\n }\n );\n },\n {\n forceRun,\n onIsCached,\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n};\n"],"mappings":";;;;;;;;;;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AG,aAAa;GACjB,EACD,eACA,QACA,MACD;AAID,QAAMC,4EACJ,aAAa,oBACb,cACD;AAMD,QAAMC,0CAJoB,OAAO,OAC/B,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe,EAEX,cAAc;AAEnD,QAAMC,yFAA2B,cAAc;EAE/C,MAAM,wBAAwB,KAAK,KAAK;AAExC,YAAU,CACR,sDAEE,IAAI,wBAAwB,mBAAmB,MAC/CP,6BAAW,UACZ,CACF,CAAC;AAEF,QAAMQ,qEAAyB,cAAc;AAI7C,YACE,CACE,6DAEE,IAN8B,KAAK,KAAK,GAMN,sBAAsB,MACxDR,6BAAW,UACZ,CACF,EACD,EACE,WAAW,MACZ,CACF;AAID,aAAW,MAAM,UAAU,WAAW,EAAE,EAAE;GACxC,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,SAAM,OAAO,aAAa;IACxB,cAAc;KACZ;KACA;KACD;IACD;IACD,CAAC;;AAIJ,YACE,CAAC,wCAAiB,GAFS,KAAK,KAAK,GAAG,mBAEE,KAAKA,6BAAW,MAAM,CAAC,EACjE;GACE,OAAO;GACP,WAAW;GACZ,CACF;IAEH;EACE;EACA;EACA,gBAAgB,MAAO,KAAK;EAC7B,CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
2
|
+
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
|
|
5
5
|
//#region \0utils:asset
|
|
@@ -13,7 +13,7 @@ const hereDirname = () => {
|
|
|
13
13
|
const findDistRoot = (startDir) => {
|
|
14
14
|
let dir = startDir;
|
|
15
15
|
for (let i = 0; i < 12; i++) {
|
|
16
|
-
if ((dir
|
|
16
|
+
if (basename(dir) === "dist") return dir;
|
|
17
17
|
const parent = resolve(dir, "..");
|
|
18
18
|
if (parent === dir) break;
|
|
19
19
|
dir = parent;
|
|
@@ -69,14 +69,11 @@ const readAsset = (relPath, encoding = "utf8") => {
|
|
|
69
69
|
const assetsRoot = join(distRoot, "assets");
|
|
70
70
|
const tried = [];
|
|
71
71
|
/**
|
|
72
|
-
* Transform
|
|
72
|
+
* Transform dist/(esm|cjs)/... and _virtual/ prefix to clean subpath (Windows-safe)
|
|
73
73
|
*/
|
|
74
|
-
const callerSubpath = relative(distRoot, getCallerDir()).split("\\").join("/").replace(/^
|
|
74
|
+
const callerSubpath = relative(distRoot, getCallerDir()).split("\\").join("/").replace(/^(?:dist\/)?(?:esm|cjs)\//, "").replace(/^_virtual\//, "");
|
|
75
75
|
if (relPath.startsWith("./") || relPath.startsWith("../")) {
|
|
76
76
|
const fromCallerAbs = resolve(assetsRoot, callerSubpath, relPath);
|
|
77
|
-
const fromCallerAbsToVirtual = fromCallerAbs.replace(/^dist\/esm\//, "/dist/assets/").replace(/^dist\/cjs\//, "/dist/assets/");
|
|
78
|
-
tried.push(fromCallerAbsToVirtual);
|
|
79
|
-
if (existsSync(fromCallerAbsToVirtual)) return readFileSync(fromCallerAbsToVirtual, encoding);
|
|
80
77
|
tried.push(fromCallerAbs);
|
|
81
78
|
if (existsSync(fromCallerAbs)) return readFileSync(fromCallerAbs, encoding);
|
|
82
79
|
}
|
|
@@ -15,7 +15,7 @@ const generateTypeIndexContent = (typeFiles, configuration) => {
|
|
|
15
15
|
const { content, internationalization } = configuration;
|
|
16
16
|
const { moduleAugmentationDir } = content;
|
|
17
17
|
const { locales, requiredLocales, strictMode } = internationalization;
|
|
18
|
-
let fileContent = "";
|
|
18
|
+
let fileContent = "import type \"intlayer\";\n";
|
|
19
19
|
const dictionariesRef = typeFiles.map((dictionaryPath) => ({
|
|
20
20
|
relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,
|
|
21
21
|
id: basename(dictionaryPath, extname(dictionaryPath)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createModuleAugmentation.mjs","names":["formattedDictionaryMap: string","requiredLocales"],"sources":["../../../src/createType/createModuleAugmentation.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { basename, extname, join, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { getFileHash } from '../utils/getFileHash';\nimport { kebabCaseToCamelCase } from '../utils/kebabCaseToCamelCase';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/** Returns lines like: [Locales.FRENCH]: 1; */\nconst formatLocales = (locales: Locale[]) =>\n locales.map((locale) => ` \"${locale}\": 1;`).join('\\n');\n\n/** Generate the content of the module augmentation file */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration: IntlayerConfig\n): string => {\n const { content, internationalization } = configuration;\n const { moduleAugmentationDir } = content;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent = '';\n\n // Build dictionary refs\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)),\n hash: `_${getFileHash(dictionaryPath)}`,\n }));\n\n // Import all dictionaries\n for (const dictionary of dictionariesRef) {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n }\n fileContent += '\\n';\n\n // Dictionary map entries (id: typeof <hash>)\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n // Ensure required ⊆ declared; if empty, default required = declared\n const declared = locales;\n const requiredSanitized = requiredLocales?.length\n ? requiredLocales.filter((requiredLocales) =>\n declared.includes(requiredLocales)\n )\n : declared;\n\n const formattedDeclaredLocales = formatLocales(declared);\n const formattedRequiredLocales = formatLocales(requiredSanitized);\n\n // Choose strict mode registry key\n const strictKey =\n strictMode === 'strict'\n ? 'strict'\n : strictMode === 'inclusive'\n ? 'inclusive'\n : 'loose';\n\n /**\n * Module augmentation that ONLY adds keys to registries.\n * No types/aliases redefined here—avoids merge conflicts.\n */\n fileContent += `declare module 'intlayer' {\\n`;\n // Dictionaries registry\n fileContent += ` interface __DictionaryRegistry {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n // Locales registries\n fileContent += ` interface __DeclaredLocalesRegistry {\\n${formattedDeclaredLocales}\\n }\\n\\n`;\n fileContent += ` interface __RequiredLocalesRegistry {\\n${formattedRequiredLocales}\\n }\\n\\n`;\n // Resolved strict mode (narrow the literal at build time)\n fileContent += ` interface __StrictModeRegistry { mode: '${strictKey}' }\\n`;\n fileContent += `}\\n`;\n\n return fileContent;\n};\n\n/** Generate the index file merging all the types */\nexport const createModuleAugmentation = async (\n configuration: IntlayerConfig\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.content;\n\n await mkdir(moduleAugmentationDir, { recursive: true });\n\n const dictionariesTypesDefinitions: string[] = await fg(\n normalizePath(`${typesDir}/*.ts`),\n { ignore: ['**/*.d.ts'] }\n );\n\n const tsContent = generateTypeIndexContent(\n dictionariesTypesDefinitions,\n configuration\n );\n\n const tsFilePath = join(moduleAugmentationDir, 'intlayer.d.ts');\n await writeFileIfChanged(tsFilePath, tsContent);\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,eAAe,QAC1B,GAAG,qBAAqB,IAAI,CAAC;;AAG/B,MAAM,iBAAiB,YACrB,QAAQ,KAAK,WAAW,QAAQ,OAAO,OAAO,CAAC,KAAK,KAAK;;AAG3D,MAAM,4BACJ,WACA,kBACW;CACX,MAAM,EAAE,SAAS,yBAAyB;CAC1C,MAAM,EAAE,0BAA0B;CAClC,MAAM,EAAE,SAAS,iBAAiB,eAAe;CAEjD,IAAI,cAAc;CAGlB,MAAM,kBAAkB,UAAU,KAAK,oBAAoB;EACzD,cAAc,KAAK,SAAS,uBAAuB,eAAe;EAClE,IAAI,SAAS,gBAAgB,QAAQ,eAAe,CAAC;EACrD,MAAM,IAAI,YAAY,eAAe;EACtC,EAAE;AAGH,MAAK,MAAM,cAAc,gBACvB,gBAAe,UAAU,WAAW,KAAK,SAAS,WAAW,aAAa;AAE5E,gBAAe;CAGf,MAAMA,yBAAiC,gBACpC,KAAK,eAAe,QAAQ,WAAW,GAAG,YAAY,WAAW,KAAK,GAAG,CACzE,KAAK,KAAK;CAGb,MAAM,WAAW;CACjB,MAAM,oBAAoB,iBAAiB,SACvC,gBAAgB,QAAQ,sBACtB,SAAS,SAASC,kBAAgB,CACnC,GACD;CAEJ,MAAM,2BAA2B,cAAc,SAAS;CACxD,MAAM,2BAA2B,cAAc,kBAAkB;CAGjE,MAAM,YACJ,eAAe,WACX,WACA,eAAe,cACb,cACA;;;;;AAMR,gBAAe;AAEf,gBAAe,uCAAuC,uBAAuB;AAE7E,gBAAe,4CAA4C,yBAAyB;AACpF,gBAAe,4CAA4C,yBAAyB;AAEpF,gBAAe,6CAA6C,UAAU;AACtE,gBAAe;AAEf,QAAO;;;AAIT,MAAa,2BAA2B,OACtC,kBACG;CACH,MAAM,EAAE,uBAAuB,aAAa,cAAc;AAE1D,OAAM,MAAM,uBAAuB,EAAE,WAAW,MAAM,CAAC;CAOvD,MAAM,YAAY,yBAL6B,MAAM,GACnD,cAAc,GAAG,SAAS,OAAO,EACjC,EAAE,QAAQ,CAAC,YAAY,EAAE,CAC1B,EAIC,cACD;AAGD,OAAM,mBADa,KAAK,uBAAuB,gBAAgB,EAC1B,UAAU"}
|
|
1
|
+
{"version":3,"file":"createModuleAugmentation.mjs","names":["formattedDictionaryMap: string","requiredLocales"],"sources":["../../../src/createType/createModuleAugmentation.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { basename, extname, join, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { getFileHash } from '../utils/getFileHash';\nimport { kebabCaseToCamelCase } from '../utils/kebabCaseToCamelCase';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/** Returns lines like: [Locales.FRENCH]: 1; */\nconst formatLocales = (locales: Locale[]) =>\n locales.map((locale) => ` \"${locale}\": 1;`).join('\\n');\n\n/** Generate the content of the module augmentation file */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration: IntlayerConfig\n): string => {\n const { content, internationalization } = configuration;\n const { moduleAugmentationDir } = content;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent = 'import type \"intlayer\";\\n';\n\n // Build dictionary refs\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)),\n hash: `_${getFileHash(dictionaryPath)}`,\n }));\n\n // Import all dictionaries\n for (const dictionary of dictionariesRef) {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n }\n fileContent += '\\n';\n\n // Dictionary map entries (id: typeof <hash>)\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n // Ensure required ⊆ declared; if empty, default required = declared\n const declared = locales;\n const requiredSanitized = requiredLocales?.length\n ? requiredLocales.filter((requiredLocales) =>\n declared.includes(requiredLocales)\n )\n : declared;\n\n const formattedDeclaredLocales = formatLocales(declared);\n const formattedRequiredLocales = formatLocales(requiredSanitized);\n\n // Choose strict mode registry key\n const strictKey =\n strictMode === 'strict'\n ? 'strict'\n : strictMode === 'inclusive'\n ? 'inclusive'\n : 'loose';\n\n /**\n * Module augmentation that ONLY adds keys to registries.\n * No types/aliases redefined here—avoids merge conflicts.\n */\n fileContent += `declare module 'intlayer' {\\n`;\n // Dictionaries registry\n fileContent += ` interface __DictionaryRegistry {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n // Locales registries\n fileContent += ` interface __DeclaredLocalesRegistry {\\n${formattedDeclaredLocales}\\n }\\n\\n`;\n fileContent += ` interface __RequiredLocalesRegistry {\\n${formattedRequiredLocales}\\n }\\n\\n`;\n // Resolved strict mode (narrow the literal at build time)\n fileContent += ` interface __StrictModeRegistry { mode: '${strictKey}' }\\n`;\n fileContent += `}\\n`;\n\n return fileContent;\n};\n\n/** Generate the index file merging all the types */\nexport const createModuleAugmentation = async (\n configuration: IntlayerConfig\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.content;\n\n await mkdir(moduleAugmentationDir, { recursive: true });\n\n const dictionariesTypesDefinitions: string[] = await fg(\n normalizePath(`${typesDir}/*.ts`),\n { ignore: ['**/*.d.ts'] }\n );\n\n const tsContent = generateTypeIndexContent(\n dictionariesTypesDefinitions,\n configuration\n );\n\n const tsFilePath = join(moduleAugmentationDir, 'intlayer.d.ts');\n await writeFileIfChanged(tsFilePath, tsContent);\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,eAAe,QAC1B,GAAG,qBAAqB,IAAI,CAAC;;AAG/B,MAAM,iBAAiB,YACrB,QAAQ,KAAK,WAAW,QAAQ,OAAO,OAAO,CAAC,KAAK,KAAK;;AAG3D,MAAM,4BACJ,WACA,kBACW;CACX,MAAM,EAAE,SAAS,yBAAyB;CAC1C,MAAM,EAAE,0BAA0B;CAClC,MAAM,EAAE,SAAS,iBAAiB,eAAe;CAEjD,IAAI,cAAc;CAGlB,MAAM,kBAAkB,UAAU,KAAK,oBAAoB;EACzD,cAAc,KAAK,SAAS,uBAAuB,eAAe;EAClE,IAAI,SAAS,gBAAgB,QAAQ,eAAe,CAAC;EACrD,MAAM,IAAI,YAAY,eAAe;EACtC,EAAE;AAGH,MAAK,MAAM,cAAc,gBACvB,gBAAe,UAAU,WAAW,KAAK,SAAS,WAAW,aAAa;AAE5E,gBAAe;CAGf,MAAMA,yBAAiC,gBACpC,KAAK,eAAe,QAAQ,WAAW,GAAG,YAAY,WAAW,KAAK,GAAG,CACzE,KAAK,KAAK;CAGb,MAAM,WAAW;CACjB,MAAM,oBAAoB,iBAAiB,SACvC,gBAAgB,QAAQ,sBACtB,SAAS,SAASC,kBAAgB,CACnC,GACD;CAEJ,MAAM,2BAA2B,cAAc,SAAS;CACxD,MAAM,2BAA2B,cAAc,kBAAkB;CAGjE,MAAM,YACJ,eAAe,WACX,WACA,eAAe,cACb,cACA;;;;;AAMR,gBAAe;AAEf,gBAAe,uCAAuC,uBAAuB;AAE7E,gBAAe,4CAA4C,yBAAyB;AACpF,gBAAe,4CAA4C,yBAAyB;AAEpF,gBAAe,6CAA6C,UAAU;AACtE,gBAAe;AAEf,QAAO;;;AAIT,MAAa,2BAA2B,OACtC,kBACG;CACH,MAAM,EAAE,uBAAuB,aAAa,cAAc;AAE1D,OAAM,MAAM,uBAAuB,EAAE,WAAW,MAAM,CAAC;CAOvD,MAAM,YAAY,yBAL6B,MAAM,GACnD,cAAc,GAAG,SAAS,OAAO,EACjC,EAAE,QAAQ,CAAC,YAAY,EAAE,CAC1B,EAIC,cACD;AAGD,OAAM,mBADa,KAAK,uBAAuB,gBAAgB,EAC1B,UAAU"}
|
|
@@ -76,10 +76,22 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
76
76
|
const { plugins } = configuration;
|
|
77
77
|
const loadDictionariesStartTime = Date.now();
|
|
78
78
|
getAppLogger(configuration)("Dictionaries:", { isVerbose: true });
|
|
79
|
-
const
|
|
79
|
+
const pluginsWithLoadDictionaries = (plugins ?? []).filter((plugin) => plugin.loadDictionaries);
|
|
80
|
+
logger$1.setPluginTotal(pluginsWithLoadDictionaries.length);
|
|
81
|
+
const completedPluginIndices = /* @__PURE__ */ new Set();
|
|
82
|
+
const updatePluginProgress = () => {
|
|
83
|
+
logger$1.setPluginDone(completedPluginIndices.size);
|
|
84
|
+
};
|
|
85
|
+
const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(async (plugin, index) => {
|
|
80
86
|
try {
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
const res = await plugin.loadDictionaries?.({ configuration });
|
|
88
|
+
completedPluginIndices.add(index);
|
|
89
|
+
updatePluginProgress();
|
|
90
|
+
return res ?? [];
|
|
91
|
+
} catch (error) {
|
|
92
|
+
logger$1.setPluginError(error);
|
|
93
|
+
completedPluginIndices.add(index);
|
|
94
|
+
updatePluginProgress();
|
|
83
95
|
return [];
|
|
84
96
|
}
|
|
85
97
|
});
|
|
@@ -101,6 +113,7 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
101
113
|
onError: (e) => logger$1.setRemoteError(e)
|
|
102
114
|
});
|
|
103
115
|
const remoteDictionariesTime = Date.now();
|
|
116
|
+
const pluginDictionariesTime = Date.now();
|
|
104
117
|
logger$1.finish();
|
|
105
118
|
printSummary(configuration);
|
|
106
119
|
return {
|
|
@@ -109,7 +122,8 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
109
122
|
pluginDictionaries,
|
|
110
123
|
time: {
|
|
111
124
|
localDictionaries: localDictionariesTime - loadDictionariesStartTime,
|
|
112
|
-
remoteDictionaries: remoteDictionariesTime - localDictionariesTime
|
|
125
|
+
remoteDictionaries: remoteDictionariesTime - localDictionariesTime,
|
|
126
|
+
pluginDictionaries: pluginDictionariesTime - remoteDictionariesTime
|
|
113
127
|
}
|
|
114
128
|
};
|
|
115
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDictionaries.mjs","names":["loadDictionariesStatus: DictionariesStatus[]","logger","updated: DictionariesStatus[]","labels: string[]","pluginDictionaries: Dictionary[]","localDictionaries: Dictionary[]","remoteDictionaries: Dictionary[]"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const loadPluginDictionariesPromise = (plugins ?? []).map(async (plugin) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n return (res as Dictionary[] | undefined) ?? [];\n } catch {\n return [];\n }\n });\n\n const pluginDictionaries: Dictionary[] = (\n await Promise.all(loadPluginDictionariesPromise)\n ).flat();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries = filterInvalidDictionaries(\n localDictionaries,\n configuration\n );\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;AA4BA,IAAIA,yBAA+C,EAAE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CAAC,IAC0C,EAAE;UACxC;AACN,UAAO,EAAE;;GAEX;CAEF,MAAMC,sBACJ,MAAM,QAAQ,IAAI,8BAA8B,EAChD,MAAM;CAMR,MAAMC,oBAAkC,MAAM,wBAJhC,MAAM,QAAQ,yBAAyB,GACjD,2BACA,CAAC,yBAAyB,EAI5B,eACA,0BACD;CAED,MAAM,wBAAwB,KAAK,KAAK;CAExC,MAAM,4BAA4B,0BAChC,mBACA,cACD;AAWD,2BATgC,0BAA0B,KACvD,UACE;EACC,eAAe,KAAK;EACpB,MAAM;EACN,QAAQ;EACT,EACJ,CAEiD;CAElD,MAAM,wBAAwB,QAC5B,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAED,KAAI,sBAEF,UAAO,gBAAgB,KAAK;CAG9B,IAAIC,qBAAmC,EAAE;AACzC,KAAI,sBACF,sBAAqB,MAAM,uBACzB,eACA,2BACA;EACE,0BAA0BL,SAAO,kBAAkB;EACnD,yBAAyBA,SAAO,iBAAiB;EACjD,UAAU,MAAMA,SAAO,eAAe,EAAE;EACzC,CACF;CAEH,MAAM,yBAAyB,KAAK,KAAK;AAGzC,UAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL,mBAAmB;EACnB;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC9C;EACF"}
|
|
1
|
+
{"version":3,"file":"loadDictionaries.mjs","names":["loadDictionariesStatus: DictionariesStatus[]","logger","updated: DictionariesStatus[]","labels: string[]","pluginDictionaries: Dictionary[]","localDictionaries: Dictionary[]","remoteDictionaries: Dictionary[]"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n logger.setPluginTotal(pluginsWithLoadDictionaries.length);\n\n const completedPluginIndices = new Set<number>();\n const updatePluginProgress = () => {\n logger.setPluginDone(completedPluginIndices.size);\n };\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin, index) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n completedPluginIndices.add(index);\n updatePluginProgress();\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n completedPluginIndices.add(index);\n updatePluginProgress();\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = (\n await Promise.all(loadPluginDictionariesPromise)\n ).flat();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries = filterInvalidDictionaries(\n localDictionaries,\n configuration\n );\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n const pluginDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - remoteDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;AA4BA,IAAIA,yBAA+C,EAAE;AACrD,MAAMC,WAAS,IAAI,oBAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,UAAgC,CAAC,GAAG,uBAAuB;AAEjE,MAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,KACrE;AACD,MAAI,SAAS,EACX,SAAQ,SAAS;MAEjB,SAAQ,KAAK,SAAS;;AAI1B,0BAAyB;AACzB,UAAO,OAAO,SAAS;AAEvB,QAAO;;AAQT,MAAM,WAAW,WAAyC;AACxD,SAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,QACE,QAAO;;;AAIb,MAAM,YAAY,WAAyC;AACzD,SAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,UACH,QAAO,WAAW;EACpB,KAAK,QACH,QAAO,WAAW;EACpB,QACE,QAAO,WAAW;;;AAIxB,MAAM,gBAAgB,kBAAkC;AACtD,KAAI,cAAc,IAAI,SAAS,UAAW;CAE1C,MAAM,YAAY,aAAa,cAAc;CAG7C,MAAM,wBAAQ,IAAI,KAA2B;AAC7C,MAAK,MAAM,KAAK,wBAAwB;EACtC,MAAM,MAAM,MAAM,IAAI,EAAE,cAAc,IAAI,EAAE;AAC5C,MAAI,EAAE,SAAS,QAAS,KAAI,QAAQ,EAAE;AACtC,MAAI,EAAE,SAAS,SAAU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iB;EACjD,UAAU,MAAMA,SAAO,eAAe,EAAE;EACzC,CACF;CAEH,MAAM,yBAAyB,KAAK,KAAK;CAEzC,MAAM,yBAAyB,KAAK,KAAK;AAGzC,UAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL,mBAAmB;EACnB;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;GAC9C;EACF"}
|
|
@@ -14,6 +14,9 @@ var DictionariesLogger = class {
|
|
|
14
14
|
remoteCheckInProgress = false;
|
|
15
15
|
expectRemote = false;
|
|
16
16
|
remoteError;
|
|
17
|
+
pluginTotal = 0;
|
|
18
|
+
pluginDone = 0;
|
|
19
|
+
pluginError;
|
|
17
20
|
constructor() {
|
|
18
21
|
this.prefix = configuration?.log?.prefix ?? "";
|
|
19
22
|
}
|
|
@@ -63,19 +66,39 @@ var DictionariesLogger = class {
|
|
|
63
66
|
this.stopRemoteCheck();
|
|
64
67
|
this.render();
|
|
65
68
|
};
|
|
69
|
+
setPluginTotal(total) {
|
|
70
|
+
if (this.isFinished) return;
|
|
71
|
+
this.pluginTotal = total;
|
|
72
|
+
if (total > 0) this.startSpinner();
|
|
73
|
+
this.render();
|
|
74
|
+
}
|
|
75
|
+
setPluginDone(done) {
|
|
76
|
+
if (this.isFinished) return;
|
|
77
|
+
this.pluginDone = done;
|
|
78
|
+
this.render();
|
|
79
|
+
}
|
|
80
|
+
setPluginError(error) {
|
|
81
|
+
if (this.isFinished) return;
|
|
82
|
+
this.pluginError = extractErrorMessage(error);
|
|
83
|
+
this.render();
|
|
84
|
+
}
|
|
66
85
|
render() {
|
|
67
|
-
const { localTotal, localDone, remoteTotal, remoteDone } = this.computeProgress();
|
|
86
|
+
const { localTotal, localDone, remoteTotal, remoteDone, pluginTotal, pluginDone } = this.computeProgress();
|
|
68
87
|
const frame = this.spinnerFrames[this.spinnerIndex];
|
|
69
88
|
const clock = colorize(frame, ANSIColors.BLUE);
|
|
70
89
|
const lines = [];
|
|
71
90
|
const isLocalDone = localDone === localTotal;
|
|
72
91
|
const isRemoteDone = remoteDone === remoteTotal;
|
|
92
|
+
const isPluginDone = pluginDone === pluginTotal;
|
|
73
93
|
if (!(this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0)) if (isLocalDone) lines.push(`${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`);
|
|
74
94
|
else lines.push(`${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`);
|
|
75
95
|
if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) if (this.remoteError) lines.push(`${this.prefix} ${x} Remote content: ${colorize(this.remoteError, ANSIColors.RED)}`);
|
|
76
96
|
else if (remoteTotal === 0) lines.push(`${this.prefix} ${clock} Remote content: ${colorize("Check server", ANSIColors.BLUE)}`);
|
|
77
97
|
else if (isRemoteDone) lines.push(`${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`);
|
|
78
98
|
else lines.push(`${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`);
|
|
99
|
+
if (pluginTotal > 0 || this.pluginError) if (this.pluginError) lines.push(`${this.prefix} ${x} Plugin content: ${colorize(this.pluginError, ANSIColors.RED)}`);
|
|
100
|
+
else if (isPluginDone) lines.push(`${this.prefix} ${v} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.GREEN)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`);
|
|
101
|
+
else lines.push(`${this.prefix} ${clock} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.BLUE)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`);
|
|
79
102
|
const currentState = lines.join("\n");
|
|
80
103
|
if (currentState === this.lastRenderedState) return;
|
|
81
104
|
this.lastRenderedState = currentState;
|
|
@@ -98,7 +121,9 @@ var DictionariesLogger = class {
|
|
|
98
121
|
localTotal: localKeys.size,
|
|
99
122
|
localDone: localDoneKeys.size,
|
|
100
123
|
remoteTotal: remoteKeys.size,
|
|
101
|
-
remoteDone: remoteDoneKeys.size
|
|
124
|
+
remoteDone: remoteDoneKeys.size,
|
|
125
|
+
pluginTotal: this.pluginTotal,
|
|
126
|
+
pluginDone: this.pluginDone
|
|
102
127
|
};
|
|
103
128
|
}
|
|
104
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.mjs","names":["lines: string[]"],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n ANSIColors,\n colorize,\n extractErrorMessage,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config/client';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError: string | undefined;\n\n constructor() {\n this.prefix = configuration?.log?.prefix ?? '';\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (error?: Error) => {\n this.remoteError = extractErrorMessage(error);\n // Avoid rendering a transient remote-only line while the remote check flag is still true\n // Ensure local + remote are rendered together after a failure\n this.stopRemoteCheck();\n this.render();\n };\n\n private render() {\n const { localTotal, localDone, remoteTotal, remoteDone } =\n this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote content: ${colorize(\n this.remoteError,\n ANSIColors.RED\n )}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n } as const;\n }\n}\n"],"mappings":";;;;AAWA,IAAa,qBAAb,MAAgC;CAC9B,AAAQ,WAAiC,E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QAAQ,KAAK,cAAc,GAAG;EAGrD,MAAM,oBAAoB,KAAK,IAAI,KAAK,eAAe,MAAM,OAAO;AACpE,OAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,WAAQ,OAAO,MAAM,UAAU;GAC/B,MAAM,OAAO,MAAM;AACnB,OAAI,SAAS,OACX,SAAQ,OAAO,MAAM,KAAK;AAE5B,WAAQ,OAAO,MAAM,KAAK;;AAG5B,OAAK,gBAAgB,MAAM;;CAG7B,AAAQ,kBAAkB;EACxB,MAAM,YAAY,IAAI,IACpB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,QAAQ,CACjC,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,gBAAgB,IAAI,IACxB,KAAK,SACF,QACE,MACC,EAAE,SAAS,YAAY,EAAE,WAAW,WAAW,EAAE,WAAW,SAC/D,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,aAAa,IAAI,IACrB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,SAAS,CAClC,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,iBAAiB,IAAI,IACzB,KAAK,SACF,QACE,MACC,EAAE,SAAS,aACV,EAAE,WAAW,aACZ,EAAE,WAAW,cACb,EAAE,WAAW,SAClB,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;AAED,SAAO;GACL,YAAY,UAAU;GACtB,WAAW,cAAc;GACzB,aAAa,WAAW;GACxB,YAAY,eAAe;GAC5B"}
|
|
1
|
+
{"version":3,"file":"log.mjs","names":["lines: string[]"],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n ANSIColors,\n colorize,\n extractErrorMessage,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config/client';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError: string | undefined;\n private pluginTotal = 0;\n private pluginDone = 0;\n private pluginError: string | undefined;\n\n constructor() {\n this.prefix = configuration?.log?.prefix ?? '';\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (error?: Error) => {\n this.remoteError = extractErrorMessage(error);\n // Avoid rendering a transient remote-only line while the remote check flag is still true\n // Ensure local + remote are rendered together after a failure\n this.stopRemoteCheck();\n this.render();\n };\n\n setPluginTotal(total: number) {\n if (this.isFinished) return;\n this.pluginTotal = total;\n if (total > 0) {\n this.startSpinner();\n }\n this.render();\n }\n\n setPluginDone(done: number) {\n if (this.isFinished) return;\n this.pluginDone = done;\n this.render();\n }\n\n setPluginError(error?: Error) {\n if (this.isFinished) return;\n this.pluginError = extractErrorMessage(error);\n this.render();\n }\n\n private render() {\n const {\n localTotal,\n localDone,\n remoteTotal,\n remoteDone,\n pluginTotal,\n pluginDone,\n } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n const isPluginDone = pluginDone === pluginTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote content: ${colorize(\n this.remoteError,\n ANSIColors.RED\n )}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Plugin line: show error or progress counts\n if (pluginTotal > 0 || this.pluginError) {\n if (this.pluginError) {\n lines.push(\n `${this.prefix} ${x} Plugin content: ${colorize(\n this.pluginError,\n ANSIColors.RED\n )}`\n );\n } else if (isPluginDone) {\n lines.push(\n `${this.prefix} ${v} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.GREEN)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.BLUE)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n pluginTotal: this.pluginTotal,\n pluginDone: this.pluginDone,\n } as const;\n }\n}\n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AQ,CACjC,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,gBAAgB,IAAI,IACxB,KAAK,SACF,QACE,MACC,EAAE,SAAS,YAAY,EAAE,WAAW,WAAW,EAAE,WAAW,SAC/D,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,aAAa,IAAI,IACrB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,SAAS,CAClC,KAAK,MAAM,EAAE,cAAc,CAC/B;EAED,MAAM,iBAAiB,IAAI,IACzB,KAAK,SACF,QACE,MACC,EAAE,SAAS,aACV,EAAE,WAAW,aACZ,EAAE,WAAW,cACb,EAAE,WAAW,SAClB,CACA,KAAK,MAAM,EAAE,cAAc,CAC/B;AAED,SAAO;GACL,YAAY,UAAU;GACtB,WAAW,cAAc;GACzB,aAAa,WAAW;GACxB,YAAY,eAAe;GAC3B,aAAa,KAAK;GAClB,YAAY,KAAK;GAClB"}
|
|
@@ -34,7 +34,13 @@ const prepareIntlayer = async (configuration, options) => {
|
|
|
34
34
|
appLogger(["Configuration written", colorize(`(${configurationWrittenTime - preparationStartMs}ms)`, ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
35
35
|
const dictionaries = await loadDictionaries(await listDictionaries(configuration), configuration);
|
|
36
36
|
const dictionariesLoadedTime = Date.now();
|
|
37
|
-
appLogger(["Content loaded", colorize([dictionaries.remoteDictionaries.length
|
|
37
|
+
appLogger(["Content loaded", colorize([dictionaries.remoteDictionaries.length + dictionaries.pluginDictionaries.length > 0 ? [
|
|
38
|
+
`(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,
|
|
39
|
+
dictionaries.localDictionaries.length > 0 ? `- Local: ${dictionaries.time.localDictionaries}ms` : "",
|
|
40
|
+
dictionaries.remoteDictionaries.length > 0 ? `- Remote: ${dictionaries.time.remoteDictionaries}ms` : "",
|
|
41
|
+
dictionaries.pluginDictionaries.length > 0 ? `- Plugin: ${dictionaries.time.pluginDictionaries}ms` : "",
|
|
42
|
+
`)`
|
|
43
|
+
].join("") : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`].join(""), ANSIColors.GREY_DARK)], { isVerbose: true });
|
|
38
44
|
const dictionariesOutput = await buildDictionary([
|
|
39
45
|
...dictionaries.localDictionaries,
|
|
40
46
|
...dictionaries.remoteDictionaries,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport { writeConfiguration } from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n format: ['cjs', 'esm'],\n forceRun: false,\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const { clean, format, forceRun, onIsCached } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n ...(options ?? {}),\n };\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n const { plugins } = configuration;\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const files: string[] = await listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(files, configuration);\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length
|
|
1
|
+
{"version":3,"file":"prepareIntlayer.mjs","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDictionary';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { runOnce } from './utils/runOnce';\nimport { writeConfiguration } from './writeConfiguration';\n\ntype PrepareIntlayerOptions = {\n clean?: boolean;\n format?: ('cjs' | 'esm')[];\n forceRun?: boolean;\n onIsCached?: () => void | Promise<void>;\n};\n\nconst DEFAULT_PREPARE_INTLAYER_OPTIONS = {\n clean: false,\n format: ['cjs', 'esm'],\n forceRun: false,\n} satisfies PrepareIntlayerOptions;\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig,\n options?: PrepareIntlayerOptions\n) => {\n const { clean, format, forceRun, onIsCached } = {\n ...DEFAULT_PREPARE_INTLAYER_OPTIONS,\n ...(options ?? {}),\n };\n const appLogger = getAppLogger(configuration);\n\n const sentinelPath = join(\n configuration.content.cacheDir,\n 'intlayer-prepared.lock'\n );\n\n // Skip preparation if it has already been done recently\n await runOnce(\n sentinelPath,\n async () => {\n const { plugins } = configuration;\n\n const preparationStartMs = Date.now();\n\n appLogger([\n 'Preparing Intlayer',\n colorize(`(v${packageJson.version})`, ANSIColors.GREY_DARK),\n ]);\n\n if (clean) {\n cleanOutputDir(configuration);\n }\n\n await writeConfiguration(configuration);\n\n const configurationWrittenTime = Date.now();\n\n appLogger(\n [\n 'Configuration written',\n colorize(\n `(${configurationWrittenTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n const files: string[] = await listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(files, configuration);\n\n const dictionariesLoadedTime = Date.now();\n\n appLogger(\n [\n 'Content loaded',\n colorize(\n [\n dictionaries.remoteDictionaries.length +\n dictionaries.pluginDictionaries.length >\n 0\n ? [\n `(Total: ${dictionariesLoadedTime - configurationWrittenTime}ms`,\n dictionaries.localDictionaries.length > 0\n ? `- Local: ${dictionaries.time.localDictionaries}ms`\n : '',\n dictionaries.remoteDictionaries.length > 0\n ? `- Remote: ${dictionaries.time.remoteDictionaries}ms`\n : '',\n dictionaries.pluginDictionaries.length > 0\n ? `- Plugin: ${dictionaries.time.pluginDictionaries}ms`\n : '',\n `)`,\n ].join('')\n : `(${dictionariesLoadedTime - configurationWrittenTime}ms)`,\n ].join(''),\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Build local dictionaries\n const dictionariesOutput = await buildDictionary(\n [\n ...dictionaries.localDictionaries,\n ...dictionaries.remoteDictionaries,\n ...dictionaries.pluginDictionaries,\n ],\n configuration,\n format,\n false\n );\n\n // Write remote dictionaries\n // Used as cache for next fetch\n await writeRemoteDictionary(\n dictionaries.remoteDictionaries,\n configuration\n );\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths, configuration);\n\n await createDictionaryEntryPoint(configuration);\n\n const dictionariesBuiltTime = Date.now();\n\n appLogger([\n 'Dictionaries built',\n colorize(\n `(${dictionariesBuiltTime - preparationStartMs}ms)`,\n ANSIColors.GREY_DARK\n ),\n ]);\n\n await createModuleAugmentation(configuration);\n\n const moduleAugmentationBuiltTime = Date.now();\n\n appLogger(\n [\n 'Module augmentation built',\n colorize(\n `(${moduleAugmentationBuiltTime - dictionariesBuiltTime}ms)`,\n ANSIColors.GREY_DARK\n ),\n ],\n {\n isVerbose: true,\n }\n );\n\n // Plugin transformation\n // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n for await (const plugin of plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration,\n });\n }\n\n const preparationElapsedMs = Date.now() - preparationStartMs;\n appLogger(\n [`Done`, colorize(`${preparationElapsedMs}ms`, ANSIColors.GREEN)],\n {\n level: 'info',\n isVerbose: true,\n }\n );\n },\n {\n forceRun,\n onIsCached,\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAM,mCAAmC;CACvC,OAAO;CACP,QAAQ,CAAC,OAAO,MAAM;CACtB,UAAU;CACX;AAED,MAAa,kBAAkB,OAC7B,eACA,YACG;CACH,MAAM,EAAE,OAAO,QAAQ,UAAU,eAAe;EAC9C,GAAG;EACH,GAAI,WAAW,EAAE;EAClB;CACD,MAAM,YAAY,aAAa,cAAc;AAQ7C,OAAM,QANe,KACnB,cAAc,QAAQ,UACtB,yBACD,EAKC,YAAY;EACV,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Z,CACF,CAAC;AAEF,QAAM,yBAAyB,cAAc;AAI7C,YACE,CACE,6BACA,SACE,IAN8B,KAAK,KAAK,GAMN,sBAAsB,MACxD,WAAW,UACZ,CACF,EACD,EACE,WAAW,MACZ,CACF;AAID,aAAW,MAAM,UAAU,WAAW,EAAE,EAAE;GACxC,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,SAAM,OAAO,aAAa;IACxB,cAAc;KACZ;KACA;KACD;IACD;IACD,CAAC;;AAIJ,YACE,CAAC,QAAQ,SAAS,GAFS,KAAK,KAAK,GAAG,mBAEE,KAAK,WAAW,MAAM,CAAC,EACjE;GACE,OAAO;GACP,WAAW;GACZ,CACF;IAEH;EACE;EACA;EACA,gBAAgB,MAAO,KAAK;EAC7B,CACF"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
|
|
2
2
|
import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
|
|
3
3
|
import { LocalizedDictionaryOutput } from "./writeDynamicDictionary.js";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _intlayer_types3 from "@intlayer/types";
|
|
5
5
|
import { Dictionary } from "@intlayer/types";
|
|
6
6
|
|
|
7
7
|
//#region src/buildIntlayerDictionary/buildIntlayerDictionary.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* This function transpile the bundled code to to make dictionaries as JSON files
|
|
10
10
|
*/
|
|
11
|
-
declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration?:
|
|
11
|
+
declare const buildDictionary: (localDictionariesEntries: Dictionary[], configuration?: _intlayer_types3.IntlayerConfig, formats?: ("cjs" | "esm")[], importOtherDictionaries?: boolean) => Promise<{
|
|
12
12
|
unmergedDictionaries: UnmergedDictionaryOutput;
|
|
13
13
|
mergedDictionaries: MergedDictionaryOutput;
|
|
14
14
|
dynamicDictionaries: LocalizedDictionaryOutput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types1 from "@intlayer/types";
|
|
3
3
|
import { Dictionary, Locale } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/buildIntlayerDictionary/writeDynamicDictionary.d.ts
|
|
@@ -12,7 +12,7 @@ type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
|
|
|
12
12
|
/**
|
|
13
13
|
* This function generates the content of the dictionary list file
|
|
14
14
|
*/
|
|
15
|
-
declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?:
|
|
15
|
+
declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types1.IntlayerConfig) => string;
|
|
16
16
|
/**
|
|
17
17
|
* Write the localized dictionaries to the dictionariesDir
|
|
18
18
|
* @param mergedDictionaries - The merged dictionaries
|
|
@@ -29,7 +29,7 @@ declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: L
|
|
|
29
29
|
* // { key: 'home', content: { ... } },
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?:
|
|
32
|
+
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?: _intlayer_types1.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
33
33
|
//#endregion
|
|
34
34
|
export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, generateDictionaryEntryPoint, writeDynamicDictionary };
|
|
35
35
|
//# sourceMappingURL=writeDynamicDictionary.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { LocalizedDictionaryOutput, LocalizedDictionaryResult } from "./writeDynamicDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/buildIntlayerDictionary/writeFetchDictionary.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* This function generates the content of the dictionary list file
|
|
7
7
|
*/
|
|
8
|
-
declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?:
|
|
8
|
+
declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types0.IntlayerConfig) => string;
|
|
9
9
|
/**
|
|
10
10
|
* Write the localized dictionaries to the dictionariesDir
|
|
11
11
|
* @param mergedDictionaries - The merged dictionaries
|
|
@@ -22,7 +22,7 @@ declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: Loc
|
|
|
22
22
|
* // { key: 'home', content: { ... } },
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration?:
|
|
25
|
+
declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration?: _intlayer_types0.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { generateDictionaryEntryPoint, writeFetchDictionary };
|
|
28
28
|
//# sourceMappingURL=writeFetchDictionary.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types6 from "@intlayer/types";
|
|
3
3
|
import { Dictionary } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/buildIntlayerDictionary/writeMergedDictionary.d.ts
|
|
@@ -24,7 +24,7 @@ type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;
|
|
|
24
24
|
* // { key: 'home', content: { ... } },
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?:
|
|
27
|
+
declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?: _intlayer_types6.IntlayerConfig) => Promise<MergedDictionaryOutput>;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { MergedDictionaryOutput, MergedDictionaryResult, writeMergedDictionaries };
|
|
30
30
|
//# sourceMappingURL=writeMergedDictionary.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types4 from "@intlayer/types";
|
|
2
2
|
import { Dictionary } from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/buildIntlayerDictionary/writeRemoteDictionary.d.ts
|
|
@@ -19,7 +19,7 @@ import { Dictionary } from "@intlayer/types";
|
|
|
19
19
|
* // { key: 'home', content: { ... } },
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?:
|
|
22
|
+
declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?: _intlayer_types4.IntlayerConfig) => Promise<Dictionary[]>;
|
|
23
23
|
//#endregion
|
|
24
24
|
export { writeRemoteDictionary };
|
|
25
25
|
//# sourceMappingURL=writeRemoteDictionary.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types5 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* This function generates a list of dictionaries in the main directory
|
|
6
6
|
*/
|
|
7
|
-
declare const createDictionaryEntryPoint: (configuration?:
|
|
7
|
+
declare const createDictionaryEntryPoint: (configuration?: _intlayer_types5.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<void>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { createDictionaryEntryPoint };
|
|
10
10
|
//# sourceMappingURL=createDictionaryEntryPoint.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types8 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/createDictionaryEntryPoint/generateDictionaryListContent.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* This function generates the content of the dictionary list file
|
|
6
6
|
*/
|
|
7
|
-
declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, format?: "cjs" | "esm", configuration?:
|
|
7
|
+
declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, format?: "cjs" | "esm", configuration?: _intlayer_types8.IntlayerConfig) => string;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { generateDictionaryListContent };
|
|
10
10
|
//# sourceMappingURL=generateDictionaryListContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":[],"mappings":";;;;;;AAOa,cAAA,6BA+CZ,EAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":[],"mappings":";;;;;;AAOa,cAAA,6BA+CZ,EAAA,CAAA,YAAA,EA3CC,MAAA,EAAA,EAAA,YAAkC,EAAA,MAAA,EAAA,MAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,aAAA,CAAA,EA2CnC,gBAAA,CA3CC,cAAkC,EAAA,GAAA,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDictionaries.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":[],"mappings":";;;KAaY,kBAAA;;EAAA,IAAA,EAAA,OAAA,GAAA,QAAkB;EA6IjB,MAAA,EAAA,SAAA,
|
|
1
|
+
{"version":3,"file":"loadDictionaries.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":[],"mappings":";;;KAaY,kBAAA;;EAAA,IAAA,EAAA,OAAA,GAAA,QAAkB;EA6IjB,MAAA,EAAA,SAAA,GAyHZ,UAAA,GAAA,SAAA,GAAA,OAAA,GAAA,UAAA,GAAA,OAAA,GAAA,UAAA,GAAA,OAAA;EAvHgB,KAAA,CAAA,EAAA,MAAA;CAEI;AACC,cALT,gBAKS,EAAA,CAAA,wBAAA,EAAA,MAAA,EAAA,GAAA,MAAA,EAAA,aAAA,EAHL,cAGK,EAAA,GAFnB,OAEmB,CAAA;EACA,iBAAA,EAFD,UAEC,EAAA;EAHnB,kBAAA,EAEmB,UAFnB,EAAA;EAAO,kBAAA,EAGY,UAHZ,EAAA"}
|
|
@@ -13,6 +13,9 @@ declare class DictionariesLogger {
|
|
|
13
13
|
private remoteCheckInProgress;
|
|
14
14
|
private expectRemote;
|
|
15
15
|
private remoteError;
|
|
16
|
+
private pluginTotal;
|
|
17
|
+
private pluginDone;
|
|
18
|
+
private pluginError;
|
|
16
19
|
constructor();
|
|
17
20
|
setExpectRemote(expect: boolean): void;
|
|
18
21
|
startRemoteCheck(): void;
|
|
@@ -22,6 +25,9 @@ declare class DictionariesLogger {
|
|
|
22
25
|
private startSpinner;
|
|
23
26
|
private stopSpinner;
|
|
24
27
|
setRemoteError: (error?: Error) => void;
|
|
28
|
+
setPluginTotal(total: number): void;
|
|
29
|
+
setPluginDone(done: number): void;
|
|
30
|
+
setPluginError(error?: Error): void;
|
|
25
31
|
private render;
|
|
26
32
|
private computeProgress;
|
|
27
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":[],"mappings":";;;cAWa,kBAAA;;EAAA,QAAA,YAAA
|
|
1
|
+
{"version":3,"file":"log.d.ts","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":[],"mappings":";;;cAWa,kBAAA;;EAAA,QAAA,YAAA;EAmCS,QAAA,YAAA;EA8Ca,QAAA,aAAA;EAuBV,iBAAA,aAAA;EAAK,QAAA,UAAA;;;;;;;;;;;;;sBArER;;;;2BA8Ca;;;yBAuBV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareIntlayer.d.ts","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":[],"mappings":";;;KAcK,sBAAA;;EAAA,MAAA,CAAA,EAAA,CAAA,KAAA,GAAA,KAAA,CAAA,EAAsB;EAad,QAAA,CAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"prepareIntlayer.d.ts","names":[],"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":[],"mappings":";;;KAcK,sBAAA;;EAAA,MAAA,CAAA,EAAA,CAAA,KAAA,GAAA,KAAA,CAAA,EAAsB;EAad,QAAA,CAAA,EAAA,OAyKZ;EAxKgB,UAAA,CAAA,EAAA,GAAA,GAAA,IAAA,GAVW,OAUX,CAAA,IAAA,CAAA;CACL;AAAsB,cAFrB,eAEqB,EAAA,CAAA,aAAA,EADjB,cACiB,EAAA,OAAA,CAAA,EAAtB,sBAAsB,EAAA,GAAA,OAAA,CAAA,IAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFormatFromExtension.d.ts","names":[],"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":[],"mappings":";KAAY,MAAA;AAAA,KACA,SAAA,GADM,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,MAAA,GAAA,OAAA,GAAA,OAAA,GAAA,QAAA;AACN,cAYC,sBAZQ,EAAA,CAAA,SAAA,EAY6B,SAZ7B,EAAA,GAYyC,MAZzC;AAYR,cAkBA,sBAlBqC,EAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"getFormatFromExtension.d.ts","names":[],"sources":["../../../src/utils/getFormatFromExtension.ts"],"sourcesContent":[],"mappings":";KAAY,MAAA;AAAA,KACA,SAAA,GADM,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,MAAA,GAAA,OAAA,GAAA,OAAA,GAAA,QAAA;AACN,cAYC,sBAZQ,EAAA,CAAA,SAAA,EAY6B,SAZ7B,EAAA,GAYyC,MAZzC;AAYR,cAkBA,sBAlBqC,EAAA,CAAA,MAAY,EAkBf,MAF9C,EAAA,GAEuD,SAFvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.6",
|
|
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": [
|
|
@@ -71,13 +71,13 @@
|
|
|
71
71
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@intlayer/api": "7.0.
|
|
75
|
-
"@intlayer/config": "7.0.
|
|
76
|
-
"@intlayer/core": "7.0.
|
|
77
|
-
"@intlayer/dictionaries-entry": "7.0.
|
|
78
|
-
"@intlayer/remote-dictionaries-entry": "7.0.
|
|
79
|
-
"@intlayer/types": "7.0.
|
|
80
|
-
"@intlayer/unmerged-dictionaries-entry": "7.0.
|
|
74
|
+
"@intlayer/api": "7.0.6",
|
|
75
|
+
"@intlayer/config": "7.0.6",
|
|
76
|
+
"@intlayer/core": "7.0.6",
|
|
77
|
+
"@intlayer/dictionaries-entry": "7.0.6",
|
|
78
|
+
"@intlayer/remote-dictionaries-entry": "7.0.6",
|
|
79
|
+
"@intlayer/types": "7.0.6",
|
|
80
|
+
"@intlayer/unmerged-dictionaries-entry": "7.0.6",
|
|
81
81
|
"chokidar": "3.6.0",
|
|
82
82
|
"crypto-js": "4.2.0",
|
|
83
83
|
"deep-equal": "2.2.3",
|
|
@@ -90,22 +90,22 @@
|
|
|
90
90
|
"@types/crypto-js": "4.2.2",
|
|
91
91
|
"@types/deep-equal": "1.0.4",
|
|
92
92
|
"@types/node": "24.9.2",
|
|
93
|
-
"@utils/ts-config": "7.0.
|
|
94
|
-
"@utils/ts-config-types": "7.0.
|
|
95
|
-
"@utils/tsdown-config": "7.0.
|
|
93
|
+
"@utils/ts-config": "7.0.6",
|
|
94
|
+
"@utils/ts-config-types": "7.0.6",
|
|
95
|
+
"@utils/tsdown-config": "7.0.6",
|
|
96
96
|
"rimraf": "6.0.1",
|
|
97
97
|
"tsdown": "0.15.11",
|
|
98
98
|
"typescript": "5.9.3",
|
|
99
99
|
"vitest": "4.0.5"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
|
-
"@intlayer/api": "7.0.
|
|
103
|
-
"@intlayer/config": "7.0.
|
|
104
|
-
"@intlayer/core": "7.0.
|
|
105
|
-
"@intlayer/dictionaries-entry": "7.0.
|
|
106
|
-
"@intlayer/remote-dictionaries-entry": "7.0.
|
|
107
|
-
"@intlayer/types": "7.0.
|
|
108
|
-
"@intlayer/unmerged-dictionaries-entry": "7.0.
|
|
102
|
+
"@intlayer/api": "7.0.6",
|
|
103
|
+
"@intlayer/config": "7.0.6",
|
|
104
|
+
"@intlayer/core": "7.0.6",
|
|
105
|
+
"@intlayer/dictionaries-entry": "7.0.6",
|
|
106
|
+
"@intlayer/remote-dictionaries-entry": "7.0.6",
|
|
107
|
+
"@intlayer/types": "7.0.6",
|
|
108
|
+
"@intlayer/unmerged-dictionaries-entry": "7.0.6",
|
|
109
109
|
"fast-glob": "3.3.3"
|
|
110
110
|
},
|
|
111
111
|
"engines": {
|