@intlayer/chokidar 7.0.3-canary.0 → 7.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cleanOutputDir.cjs +3 -3
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/createType/createType.cjs +1 -1
- package/dist/cjs/createType/createType.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaries.cjs +2 -2
- package/dist/cjs/listDictionariesPath.cjs +1 -13
- package/dist/cjs/listDictionariesPath.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +12 -12
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +2 -2
- package/dist/cjs/loadDictionaries/log.cjs +14 -12
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +0 -1
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs +4 -3
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs.map +1 -1
- package/dist/esm/cleanOutputDir.mjs +1 -1
- package/dist/esm/cleanOutputDir.mjs.map +1 -1
- package/dist/esm/createType/createType.mjs +2 -2
- package/dist/esm/createType/createType.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaries.mjs +1 -1
- package/dist/esm/listDictionariesPath.mjs +1 -13
- package/dist/esm/listDictionariesPath.mjs.map +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +2 -2
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +2 -2
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +1 -1
- package/dist/esm/loadDictionaries/log.mjs +3 -2
- package/dist/esm/loadDictionaries/log.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +0 -1
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs +5 -4
- package/dist/esm/writeContentDeclaration/detectFormatCommand.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/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
- package/dist/types/loadDictionaries/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 +21 -21
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
3
|
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
4
|
-
let
|
|
5
|
-
|
|
4
|
+
let __intlayer_config_client = require("@intlayer/config/client");
|
|
5
|
+
__intlayer_config_client = require_rolldown_runtime.__toESM(__intlayer_config_client);
|
|
6
6
|
|
|
7
7
|
//#region src/cleanOutputDir.ts
|
|
8
8
|
const cleanOutputDir = (configuration) => {
|
|
9
9
|
const { dictionariesDir, unmergedDictionariesDir, dynamicDictionariesDir, mainDir, typesDir, configDir } = configuration.content;
|
|
10
|
-
const appLogger = (0,
|
|
10
|
+
const appLogger = (0, __intlayer_config_client.getAppLogger)(configuration);
|
|
11
11
|
if ((0, node_fs.existsSync)(dictionariesDir)) (0, node_fs.rmSync)(dictionariesDir, { recursive: true });
|
|
12
12
|
if ((0, node_fs.existsSync)(unmergedDictionariesDir)) (0, node_fs.rmSync)(unmergedDictionariesDir, { recursive: true });
|
|
13
13
|
if ((0, node_fs.existsSync)(dynamicDictionariesDir)) (0, node_fs.rmSync)(dynamicDictionariesDir, { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanOutputDir.cjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync, rmSync } from 'node:fs';\nimport { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const cleanOutputDir = (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n if (existsSync(dynamicDictionariesDir)) {\n // Delete the dynamic dictionaries directory\n rmSync(dynamicDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;AAIA,MAAa,kBAAkB,kBAAkC;CAC/D,MAAM,EACJ,iBACA,yBACA,wBACA,SACA,UACA,cACE,cAAc;CAElB,MAAM,
|
|
1
|
+
{"version":3,"file":"cleanOutputDir.cjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync, rmSync } from 'node:fs';\nimport { getAppLogger } from '@intlayer/config/client';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const cleanOutputDir = (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n if (existsSync(dynamicDictionariesDir)) {\n // Delete the dynamic dictionaries directory\n rmSync(dynamicDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;AAIA,MAAa,kBAAkB,kBAAkC;CAC/D,MAAM,EACJ,iBACA,yBACA,wBACA,SACA,UACA,cACE,cAAc;CAElB,MAAM,uDAAyB,cAAc;AAE7C,6BAAe,gBAAgB,CAE7B,qBAAO,iBAAiB,EAAE,WAAW,MAAM,CAAC;AAG9C,6BAAe,wBAAwB,CAErC,qBAAO,yBAAyB,EAAE,WAAW,MAAM,CAAC;AAGtD,6BAAe,uBAAuB,CAEpC,qBAAO,wBAAwB,EAAE,WAAW,MAAM,CAAC;AAIrD,6BAAe,QAAQ,CACrB,qBAAO,SAAS,EAAE,WAAW,MAAM,CAAC;AAItC,6BAAe,SAAS,CACtB,qBAAO,UAAU,EAAE,WAAW,MAAM,CAAC;AAIvC,6BAAe,UAAU,CACvB,qBAAO,WAAW,EAAE,WAAW,MAAM,CAAC;AAGxC,WAAU,4BAA4B,EACpC,WAAW,MACZ,CAAC"}
|
|
@@ -19,7 +19,7 @@ const createTypes = async (dictionariesPaths, configuration) => {
|
|
|
19
19
|
const { typesDir } = content;
|
|
20
20
|
await (0, node_fs_promises.mkdir)(typesDir, { recursive: true });
|
|
21
21
|
return (await require_utils_parallelize.parallelize(dictionariesPaths, async (dictionaryPath) => {
|
|
22
|
-
const requireFunction = build.require ?? __intlayer_config.
|
|
22
|
+
const requireFunction = build.require ?? (0, __intlayer_config.getProjectRequire)();
|
|
23
23
|
(0, __intlayer_config.clearModuleCache)(dictionaryPath);
|
|
24
24
|
const dictionary = requireFunction(dictionaryPath);
|
|
25
25
|
if (!dictionary.key) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createType.cjs","names":["parallelize","
|
|
1
|
+
{"version":3,"file":"createType.cjs","names":["parallelize","dictionary: Dictionary","typeDefinition: string","outputPath: string"],"sources":["../../../src/createType/createType.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { clearModuleCache, getProjectRequire } from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\n\nexport const generateTypeScriptType = (dictionary: Dictionary) => {\n const jsonString = JSON.stringify(dictionary, null, 2);\n\n return `/* eslint-disable */\\nexport default ${jsonString} as const;\\n`;\n};\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionariesPaths: string[],\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { build, content } = configuration;\n const { typesDir } = content;\n\n // Create type folders if they don't exist\n await mkdir(typesDir, { recursive: true });\n\n const results = await parallelize(\n dictionariesPaths,\n async (dictionaryPath): Promise<string | undefined> => {\n const requireFunction = build.require ?? getProjectRequire();\n clearModuleCache(dictionaryPath);\n\n const dictionary: Dictionary = requireFunction(dictionaryPath);\n\n if (!dictionary.key) {\n return undefined;\n }\n\n const typeDefinition: string = generateTypeScriptType(dictionary);\n\n const outputPath: string = resolve(typesDir, `${dictionary.key}.ts`);\n\n await writeFile(outputPath, typeDefinition);\n\n return outputPath;\n }\n );\n\n return results.filter(Boolean) as string[];\n};\n"],"mappings":";;;;;;;;;;AAMA,MAAa,0BAA0B,eAA2B;AAGhE,QAAO,wCAFY,KAAK,UAAU,YAAY,MAAM,EAAE,CAEI;;;;;AAK5D,MAAa,cAAc,OACzB,mBACA,kBACsB;CACtB,MAAM,EAAE,OAAO,YAAY;CAC3B,MAAM,EAAE,aAAa;AAGrB,mCAAY,UAAU,EAAE,WAAW,MAAM,CAAC;AAwB1C,SAtBgB,MAAMA,sCACpB,mBACA,OAAO,mBAAgD;EACrD,MAAM,kBAAkB,MAAM,qDAA8B;AAC5D,0CAAiB,eAAe;EAEhC,MAAMC,aAAyB,gBAAgB,eAAe;AAE9D,MAAI,CAAC,WAAW,IACd;EAGF,MAAMC,iBAAyB,uBAAuB,WAAW;EAEjE,MAAMC,oCAA6B,UAAU,GAAG,WAAW,IAAI,KAAK;AAEpE,wCAAgB,YAAY,eAAe;AAE3C,SAAO;GAEV,EAEc,OAAO,QAAQ"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_utils_parallelize = require('./utils/parallelize.cjs');
|
|
3
|
-
let __intlayer_config = require("@intlayer/config");
|
|
4
|
-
__intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
|
|
5
3
|
let __intlayer_api = require("@intlayer/api");
|
|
6
4
|
__intlayer_api = require_rolldown_runtime.__toESM(__intlayer_api);
|
|
5
|
+
let __intlayer_config = require("@intlayer/config");
|
|
6
|
+
__intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
|
|
7
7
|
|
|
8
8
|
//#region src/fetchDistantDictionaries.ts
|
|
9
9
|
/**
|
|
@@ -9,19 +9,7 @@ fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
|
9
9
|
* @returns An array of dictionary paths
|
|
10
10
|
*/
|
|
11
11
|
const listDictionaries = async (configuration) => {
|
|
12
|
-
return await (0, fast_glob.default)(configuration.content.watchedFilesPatternWithPath, { ignore:
|
|
13
|
-
"**/node_modules/**",
|
|
14
|
-
"**/.git/**",
|
|
15
|
-
"**/.github/**",
|
|
16
|
-
"**/.next/**",
|
|
17
|
-
"**/.expo/**",
|
|
18
|
-
"**/.expo-shared/**",
|
|
19
|
-
"**/.vercel/**",
|
|
20
|
-
"**/.cache/**",
|
|
21
|
-
"**/dist/**",
|
|
22
|
-
"**/build/**",
|
|
23
|
-
"**/.intlayer/**"
|
|
24
|
-
] });
|
|
12
|
+
return await (0, fast_glob.default)(configuration.content.watchedFilesPatternWithPath, { ignore: configuration.content.excludedPath });
|
|
25
13
|
};
|
|
26
14
|
|
|
27
15
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listDictionariesPath.cjs","names":[],"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * List all dictionaries absolute paths in the project\n * @param configuration - The configuration object\n * @returns An array of dictionary paths\n */\nexport const listDictionaries = async (\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const files: string[] = await fg(\n configuration.content.watchedFilesPatternWithPath,\n {\n ignore:
|
|
1
|
+
{"version":3,"file":"listDictionariesPath.cjs","names":[],"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * List all dictionaries absolute paths in the project\n * @param configuration - The configuration object\n * @returns An array of dictionary paths\n */\nexport const listDictionaries = async (\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const files: string[] = await fg(\n configuration.content.watchedFilesPatternWithPath,\n {\n ignore: configuration.content.excludedPath,\n }\n );\n\n return files;\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,mBAAmB,OAC9B,kBACsB;AAQtB,QAPwB,6BACtB,cAAc,QAAQ,6BACtB,EACE,QAAQ,cAAc,QAAQ,cAC/B,CACF"}
|
|
@@ -45,7 +45,7 @@ const rewritePathsPlugin = (replaceModules, excludeModules) => {
|
|
|
45
45
|
* Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.
|
|
46
46
|
*/
|
|
47
47
|
const getIntlayerBundle = async (configuration) => {
|
|
48
|
-
const rootRequire = __intlayer_config.
|
|
48
|
+
const rootRequire = (0, __intlayer_config.getProjectRequire)(configuration.content.baseDir);
|
|
49
49
|
const configPackageRequire = __intlayer_config.configESMxCJSRequire;
|
|
50
50
|
const localRequire = __intlayer_config.isESModule ? (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href) : require;
|
|
51
51
|
const configurationPath = (0, node_path.join)(configuration.content.configDir, `configuration.json`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayerBundle.cjs","names":["
|
|
1
|
+
{"version":3,"file":"getIntlayerBundle.cjs","names":["configESMxCJSRequire","isESModule","builtinModules"],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules, createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport type { ESBuildPlugin } from '@intlayer/config';\nimport {\n bundleFile,\n configESMxCJSRequire,\n getProjectRequire,\n isESModule,\n} from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\n/**\n * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,\n * using the provided localeRequire (either createRequire(import.meta.url) or require).\n *\n * Example:\n * rewritePathsPlugin([\"@intlayer/config\", \"@intlayer/core\"], localeRequire)\n * …will also rewrite \"@intlayer/core/file\" etc.\n */\nconst rewritePathsPlugin = (\n replaceModules: Record<string, string>,\n excludeModules?: string[]\n): ESBuildPlugin => {\n return {\n name: 'rewrite-paths',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const exact = replaceModules[args.path];\n\n if (excludeModules?.includes(args.path)) {\n return null;\n }\n\n if (exact) {\n return {\n path: exact,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n\n // Optional: support subpaths like \"@intlayer/core/xyz\"\n for (const key of Object.keys(replaceModules)) {\n if (args.path === key || args.path.startsWith(`${key}/`)) {\n const sub = args.path.slice(key.length); // '' or '/...'\n return {\n path: replaceModules[key] + sub,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n }\n });\n },\n };\n};\n\n/**\n * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.\n */\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.content.baseDir);\n const configPackageRequire = configESMxCJSRequire;\n const localRequire = isESModule ? createRequire(import.meta.url) : require;\n\n const configurationPath = join(\n configuration.content.configDir,\n `configuration.json`\n );\n\n const replaceModules = {\n deepmerge: localRequire.resolve('deepmerge'),\n esbuild: configPackageRequire.resolve('esbuild'),\n '@intlayer/config/built': configurationPath,\n '@intlayer/config': localRequire.resolve('@intlayer/config'),\n '@intlayer/config/client': localRequire.resolve('@intlayer/config/client'),\n '@intlayer/core/file': localRequire.resolve('@intlayer/core/file'),\n };\n\n const filePath = rootRequire.resolve('intlayer');\n const code = await readFile(filePath, 'utf-8');\n\n const output = await bundleFile(code, filePath, {\n external: [\n ...builtinModules,\n ...builtinModules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,CAAC;EAC9C,CAAC,IAEe"}
|
|
@@ -30,7 +30,7 @@ const loadContentDeclarations = async (contentDeclarationFilePath, configuration
|
|
|
30
30
|
return {
|
|
31
31
|
relativePath: (0, node_path.relative)(configuration.content.baseDir, path),
|
|
32
32
|
dictionary: await (0, __intlayer_config.loadExternalFile)(path, {
|
|
33
|
-
projectRequire: build.require,
|
|
33
|
+
projectRequire: build.require ?? (0, __intlayer_config.getProjectRequire)(),
|
|
34
34
|
buildOptions: { banner: { js: [`globalThis.INTLAYER_FILE_PATH = '${path}';`, `globalThis.INTLAYER_BASE_DIR = '${configuration.content.baseDir}';`].join("\n") } },
|
|
35
35
|
aliases: { intlayer: filePath }
|
|
36
36
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadContentDeclaration.cjs","names":["isInvalidDictionary","getIntlayerBundle","contentDeclarations: Dictionary[]","filterInvalidDictionaries","parallelize","processContentDeclaration"],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"loadContentDeclaration.cjs","names":["isInvalidDictionary","getIntlayerBundle","contentDeclarations: Dictionary[]","filterInvalidDictionaries","parallelize","processContentDeclaration"],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport {\n getProjectRequire,\n loadExternalFile,\n localCache,\n} from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport {\n filterInvalidDictionaries,\n isInvalidDictionary,\n} from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord)\n .filter(([_relativePath, dict]) => isInvalidDictionary(dict, configuration))\n .map(([relativePath, dict]) => ({\n ...dict,\n localId: `${dict.key}::local::${relativePath}`,\n location: 'local' as const,\n filePath: relativePath,\n }));\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const { build, content } = configuration;\n\n const { set, isValid } = localCache(configuration, ['intlayer-bundle'], {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n });\n\n const filePath = join(content.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n // If cache is invalid, write the intlayer bundle to the cache\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(configuration.content.baseDir, path);\n\n const dictionary = await loadExternalFile(path, {\n projectRequire: build.require ?? getProjectRequire(),\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.content.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: filePath,\n },\n });\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n acc[relativePath] = dictionary;\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n );\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration);\n } finally {\n // await rm(tempFilePath, { recursive: true });\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAa,2BACX,oBACA,kBAEA,OAAO,QAAQ,mBAAmB,CAC/B,QAAQ,CAAC,eAAe,UAAUA,sDAAoB,MAAM,cAAc,CAAC,CAC3E,KAAK,CAAC,cAAc,WAAW;CAC9B,GAAG;CACH,SAAS,GAAG,KAAK,IAAI,WAAW;CAChC,UAAU;CACV,UAAU;CACX,EAAE;AAEP,MAAa,0BAA0B,OACrC,4BACA,eACA,mBAC0B;CAC1B,MAAM,EAAE,OAAO,YAAY;CAE3B,MAAM,EAAE,KAAK,8CAAuB,eAAe,CAAC,kBAAkB,EAAE,EACtE,OAAO,MAAO,KAAK,KAAK,KAAK,GAC9B,CAAC;CAEF,MAAM,+BAAgB,QAAQ,UAAU,sBAAsB;AAI9D,KAAI,CAHsB,MAAM,SAAS,EAGjB;AAEtB,wCAAgB,UADO,MAAMC,6DAAkB,cAAc,CACpB;AACzC,QAAM,IAAI,KAAK;;AAGjB,KAAI;EACF,MAAM,uBAAuB,2BAA2B,IACtD,OAAO,SAAS;AAkBd,UAAO;IAAE,sCAjBqB,cAAc,QAAQ,SAAS,KAAK;IAiB3C,YAfJ,8CAAuB,MAAM;KAC9C,gBAAgB,MAAM,qDAA8B;KACpD,cAAc,EACZ,QAAQ,EACN,IAAI,CACF,oCAAoC,KAAK,KACzC,mCAAmC,cAAc,QAAQ,QAAQ,IAClE,CAAC,KAAK,KAAK,EACb,EACF;KACD,SAAS,EACP,UAAU,UACX;KACF,CAAC;IAEiC;IAEtC;EAWD,MAAMC,sBAAoC,yBAThB,MAAM,QAAQ,IAAI,qBAAqB,EACpB,QAC1C,KAAK,EAAE,cAAc,iBAAiB;AACrC,OAAI,gBAAgB;AACpB,UAAO;KAET,EAAE,CACH,EAIC,cACD;EAED,MAAM,wBAAwB,oBAAoB,KAAK,iBAAiB;GACtE,eAAe,YAAY;GAC3B,MAAM;GACN,QAAQ;GACT,EAAE;AAEH,mBAAiB,sBAAsB;AAqCvC,SAAOC,4DAnCuB,MAAMC,sCAClC,qBACA,OAAO,uBAAwD;AAC7D,OAAI,CAAC,mBACH;AAGF,oBAAiB,CACf;IACE,eAAe,mBAAmB;IAClC,MAAM;IACN,QAAQ;IACT,CACF,CAAC;GAEF,MAAM,8BAA8B,MAAMC,oFACxC,mBACD;AAED,OAAI,CAAC,4BACH;AAGF,oBAAiB,CACf;IACE,eAAe,4BAA4B;IAC3C,MAAM;IACN,QAAQ;IACT,CACF,CAAC;AAEF,UAAO;IAEV,EAEuD,cAAc;WAC9D"}
|
|
@@ -3,8 +3,8 @@ const require_filterInvalidDictionaries = require('../filterInvalidDictionaries.
|
|
|
3
3
|
const require_loadDictionaries_loadContentDeclaration = require('./loadContentDeclaration.cjs');
|
|
4
4
|
const require_loadDictionaries_loadRemoteDictionaries = require('./loadRemoteDictionaries.cjs');
|
|
5
5
|
const require_loadDictionaries_log = require('./log.cjs');
|
|
6
|
-
let
|
|
7
|
-
|
|
6
|
+
let __intlayer_config_client = require("@intlayer/config/client");
|
|
7
|
+
__intlayer_config_client = require_rolldown_runtime.__toESM(__intlayer_config_client);
|
|
8
8
|
|
|
9
9
|
//#region src/loadDictionaries/loadDictionaries.ts
|
|
10
10
|
let loadDictionariesStatus = [];
|
|
@@ -33,14 +33,14 @@ const colorFor = (status) => {
|
|
|
33
33
|
switch (status) {
|
|
34
34
|
case "built":
|
|
35
35
|
case "imported":
|
|
36
|
-
case "fetched": return
|
|
37
|
-
case "error": return
|
|
38
|
-
default: return
|
|
36
|
+
case "fetched": return __intlayer_config_client.ANSIColors.GREEN;
|
|
37
|
+
case "error": return __intlayer_config_client.ANSIColors.RED;
|
|
38
|
+
default: return __intlayer_config_client.ANSIColors.BLUE;
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
const printSummary = (configuration) => {
|
|
42
42
|
if (configuration.log.mode !== "verbose") return;
|
|
43
|
-
const appLogger = (0,
|
|
43
|
+
const appLogger = (0, __intlayer_config_client.getAppLogger)(configuration);
|
|
44
44
|
const byKey = /* @__PURE__ */ new Map();
|
|
45
45
|
for (const s of loadDictionariesStatus) {
|
|
46
46
|
const rec = byKey.get(s.dictionaryKey) ?? {};
|
|
@@ -61,23 +61,23 @@ const printSummary = (configuration) => {
|
|
|
61
61
|
const rec = byKey.get(key);
|
|
62
62
|
const labels = [];
|
|
63
63
|
if (rec.local) {
|
|
64
|
-
const inner = (0,
|
|
65
|
-
const coloredLocal = `${
|
|
64
|
+
const inner = (0, __intlayer_config_client.colorize)(`${iconFor(rec.local)} ${rec.local}`, colorFor(rec.local));
|
|
65
|
+
const coloredLocal = `${__intlayer_config_client.ANSIColors.GREY}[` + (0, __intlayer_config_client.colorize)("local: ", __intlayer_config_client.ANSIColors.GREY) + inner + `${__intlayer_config_client.ANSIColors.GREY}]${__intlayer_config_client.ANSIColors.RESET}`;
|
|
66
66
|
const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
|
|
67
67
|
const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);
|
|
68
68
|
labels.push(coloredLocal + " ".repeat(pad));
|
|
69
69
|
} else labels.push(" ".repeat(maxLocalLabelLen));
|
|
70
70
|
if (rec.remote) {
|
|
71
|
-
const inner = (0,
|
|
72
|
-
labels.push(`${
|
|
71
|
+
const inner = (0, __intlayer_config_client.colorize)(`${iconFor(rec.remote)} ${rec.remote}`, colorFor(rec.remote));
|
|
72
|
+
labels.push(`${__intlayer_config_client.ANSIColors.GREY}[` + (0, __intlayer_config_client.colorize)("distant: ", __intlayer_config_client.ANSIColors.GREY) + inner + `${__intlayer_config_client.ANSIColors.GREY}]${__intlayer_config_client.ANSIColors.RESET}`);
|
|
73
73
|
}
|
|
74
|
-
appLogger(` - ${(0,
|
|
74
|
+
appLogger(` - ${(0, __intlayer_config_client.colon)((0, __intlayer_config_client.colorizeKey)(key), { colSize: keys })} ${labels.join(" ")}`);
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
78
78
|
const { plugins } = configuration;
|
|
79
79
|
const loadDictionariesStartTime = Date.now();
|
|
80
|
-
(0,
|
|
80
|
+
(0, __intlayer_config_client.getAppLogger)(configuration)("Dictionaries:", { isVerbose: true });
|
|
81
81
|
const loadPluginDictionariesPromise = (plugins ?? []).map(async (plugin) => {
|
|
82
82
|
try {
|
|
83
83
|
return await plugin.loadDictionaries?.({ configuration }) ?? [];
|
|
@@ -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":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config';\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":";;;;;;;;;AA6BA,IAAIA,yBAA+C,EAAE;AACrD,MAAM,SAAS,IAAIC,iDAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,UAAgC,CAAC,GAAG,uBAAu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MC,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;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 };\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;AA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BAAkC,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;AAGzC,QAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL,mBAAmB;EACnB;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC9C;EACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_fetchDistantDictionaries = require('../fetchDistantDictionaries.cjs');
|
|
3
3
|
const require_utils_sortAlphabetically = require('../utils/sortAlphabetically.cjs');
|
|
4
|
-
let __intlayer_config = require("@intlayer/config");
|
|
5
|
-
__intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
|
|
6
4
|
let __intlayer_api = require("@intlayer/api");
|
|
7
5
|
__intlayer_api = require_rolldown_runtime.__toESM(__intlayer_api);
|
|
6
|
+
let __intlayer_config = require("@intlayer/config");
|
|
7
|
+
__intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
|
|
8
8
|
let __intlayer_remote_dictionaries_entry = require("@intlayer/remote-dictionaries-entry");
|
|
9
9
|
__intlayer_remote_dictionaries_entry = require_rolldown_runtime.__toESM(__intlayer_remote_dictionaries_entry);
|
|
10
10
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
3
|
-
|
|
2
|
+
let __intlayer_config_client = require("@intlayer/config/client");
|
|
3
|
+
__intlayer_config_client = require_rolldown_runtime.__toESM(__intlayer_config_client);
|
|
4
|
+
let __intlayer_config_built = require("@intlayer/config/built");
|
|
5
|
+
__intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
|
|
4
6
|
|
|
5
7
|
//#region src/loadDictionaries/log.ts
|
|
6
8
|
var DictionariesLogger = class {
|
|
@@ -8,7 +10,7 @@ var DictionariesLogger = class {
|
|
|
8
10
|
spinnerTimer = null;
|
|
9
11
|
spinnerIndex = 0;
|
|
10
12
|
renderedLines = 0;
|
|
11
|
-
spinnerFrames =
|
|
13
|
+
spinnerFrames = __intlayer_config_client.spinnerFrames;
|
|
12
14
|
isFinished = false;
|
|
13
15
|
prefix;
|
|
14
16
|
lastRenderedState = "";
|
|
@@ -16,7 +18,7 @@ var DictionariesLogger = class {
|
|
|
16
18
|
expectRemote = false;
|
|
17
19
|
remoteError;
|
|
18
20
|
constructor() {
|
|
19
|
-
this.prefix =
|
|
21
|
+
this.prefix = __intlayer_config_built.default?.log?.prefix ?? "";
|
|
20
22
|
}
|
|
21
23
|
setExpectRemote(expect) {
|
|
22
24
|
this.expectRemote = expect;
|
|
@@ -60,23 +62,23 @@ var DictionariesLogger = class {
|
|
|
60
62
|
this.spinnerTimer = null;
|
|
61
63
|
}
|
|
62
64
|
setRemoteError = (error) => {
|
|
63
|
-
this.remoteError = (0,
|
|
65
|
+
this.remoteError = (0, __intlayer_config_client.extractErrorMessage)(error);
|
|
64
66
|
this.stopRemoteCheck();
|
|
65
67
|
this.render();
|
|
66
68
|
};
|
|
67
69
|
render() {
|
|
68
70
|
const { localTotal, localDone, remoteTotal, remoteDone } = this.computeProgress();
|
|
69
71
|
const frame = this.spinnerFrames[this.spinnerIndex];
|
|
70
|
-
const clock = (0,
|
|
72
|
+
const clock = (0, __intlayer_config_client.colorize)(frame, __intlayer_config_client.ANSIColors.BLUE);
|
|
71
73
|
const lines = [];
|
|
72
74
|
const isLocalDone = localDone === localTotal;
|
|
73
75
|
const isRemoteDone = remoteDone === remoteTotal;
|
|
74
|
-
if (!(this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0)) if (isLocalDone) lines.push(`${this.prefix} ${
|
|
75
|
-
else lines.push(`${this.prefix} ${clock} Local content: ${(0,
|
|
76
|
-
if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) if (this.remoteError) lines.push(`${this.prefix} ${
|
|
77
|
-
else if (remoteTotal === 0) lines.push(`${this.prefix} ${clock} Remote content: ${(0,
|
|
78
|
-
else if (isRemoteDone) lines.push(`${this.prefix} ${
|
|
79
|
-
else lines.push(`${this.prefix} ${clock} Remote content: ${(0,
|
|
76
|
+
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
|
+
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
|
+
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
|
+
else if (remoteTotal === 0) lines.push(`${this.prefix} ${clock} Remote content: ${(0, __intlayer_config_client.colorize)("Check server", __intlayer_config_client.ANSIColors.BLUE)}`);
|
|
80
|
+
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
|
+
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)}`);
|
|
80
82
|
const currentState = lines.join("\n");
|
|
81
83
|
if (currentState === this.lastRenderedState) return;
|
|
82
84
|
this.lastRenderedState = currentState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.cjs","names":["spinnerFrames","ANSIColors","lines: string[]","v","x"],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n extractErrorMessage,\n
|
|
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,AAAQ,WAAiC,EAAE;CAC3C,AAAQ,eAAsC;CAC9C,AAAQ,eAAe;CACvB,AAAQ,gBAAgB;CACxB,AAAiB,gBAAgBA;CACjC,AAAQ,aAAa;CACrB,AAAiB;CACjB,AAAQ,oBAA4B;CACpC,AAAQ,wBAAwB;CAChC,AAAQ,eAAe;CACvB,AAAQ;CAER,cAAc;AACZ,OAAK,SAASC,iCAAe,KAAK,UAAU;;CAG9C,gBAAgB,QAAiB;AAC/B,OAAK,eAAe;;CAGtB,mBAAmB;AACjB,MAAI,KAAK,WAAY;AACrB,OAAK,wBAAwB;AAC7B,OAAK,cAAc;AACnB,OAAK,QAAQ;;CAGf,kBAAkB;AAChB,OAAK,wBAAwB;;CAG/B,OAAO,aAAmC;AACxC,MAAI,KAAK,WAAY;AACrB,OAAK,MAAM,UAAU,aAAa;GAChC,MAAM,QAAQ,KAAK,SAAS,WACzB,MACC,EAAE,kBAAkB,OAAO,iBAAiB,EAAE,SAAS,OAAO,KACjE;AACD,OAAI,SAAS,EACX,MAAK,SAAS,SAAS;OAEvB,MAAK,SAAS,KAAK,OAAO;;EAK9B,MAAM,EAAE,gBAAgB,KAAK,iBAAiB;AAC9C,MAAI,KAAK,gBAAgB,CAAC,KAAK,yBAAyB,gBAAgB,EAEtE;AAGF,OAAK,cAAc;AACnB,OAAK,QAAQ;;CAGf,SAAS;AACP,OAAK,aAAa;AAClB,OAAK,aAAa;AAElB,OAAK,QAAQ;;CAGf,A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eAAe;GAC5B"}
|
|
@@ -23,7 +23,6 @@ const DEFAULT_PREPARE_INTLAYER_OPTIONS = {
|
|
|
23
23
|
forceRun: false
|
|
24
24
|
};
|
|
25
25
|
const prepareIntlayer = async (configuration, options) => {
|
|
26
|
-
console.log("prepareIntlayer", configuration);
|
|
27
26
|
const { clean, format, forceRun, onIsCached } = {
|
|
28
27
|
...DEFAULT_PREPARE_INTLAYER_OPTIONS,
|
|
29
28
|
...options ?? {}
|
|
@@ -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
|
|
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 > 0\n ? ` (Total: ${dictionariesLoadedTime - configurationWrittenTime}ms - Local: ${dictionaries.time.localDictionaries}ms - Remote: ${dictionaries.time.remoteDictionaries}ms)`\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,gDAAyB,cAAc;AAQ7C,OAAMA,kDALJ,cAAc,QAAQ,UACtB,yBACD,EAKC,YAAY;EACV,MAAM,EAAE,YAAY;EAEpB,MAAM,qBAAqB,KAAK,KAAK;AAErC,YAAU,CACR,sDACS,KAAKC,uCAAY,QAAQ,IAAIC,6BAAW,UAAU,CAC5D,CAAC;AAEF,MAAI,MACF,uCAAe,cAAc;AAG/B,QAAMC,oDAAmB,cAAc;EAEvC,MAAM,2BAA2B,KAAK,KAAK;AAE3C,YACE,CACE,yDAEE,IAAI,2BAA2B,mBAAmB,MAClDD,6BAAW,UACZ,CACF,EACD,EACE,WAAW,MACZ,CACF;EAID,MAAM,eAAe,MAAME,2DAFH,MAAMC,8CAAiB,cAAc,EAEV,cAAc;EAEjE,MAAM,yBAAyB,KAAK,KAAK;AAEzC,YACE,CACE,kDAEE,CACE,aAAa,mBAAmB,SAAS,IACrC,YAAY,yBAAyB,yBAAyB,cAAc,aAAa,KAAK,kBAAkB,eAAe,aAAa,KAAK,mBAAmB,OACpK,IAAI,yBAAyB,yBAAyB,KAC3D,CAAC,KAAK,GAAG,EACVH,6BAAW,UACZ,CACF,EACD,EACE,WAAW,MACZ,CACF;EAGD,MAAM,qBAAqB,MAAMI,wEAC/B;GACE,GAAG,aAAa;GAChB,GAAG,aAAa;GAChB,GAAG,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"}
|
|
@@ -5,17 +5,18 @@ __intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
|
|
|
5
5
|
//#region src/writeContentDeclaration/detectFormatCommand.ts
|
|
6
6
|
const detectFormatCommand = (configuration) => {
|
|
7
7
|
const { formatCommand } = configuration.content;
|
|
8
|
+
const projectRequire = (0, __intlayer_config.getProjectRequire)();
|
|
8
9
|
if (formatCommand) return formatCommand;
|
|
9
10
|
try {
|
|
10
|
-
|
|
11
|
+
projectRequire.resolve("prettier");
|
|
11
12
|
return "prettier --write \"{{file}}\" --log-level silent";
|
|
12
13
|
} catch (_error) {}
|
|
13
14
|
try {
|
|
14
|
-
|
|
15
|
+
projectRequire.resolve("biome");
|
|
15
16
|
return "biome format \"{{file}}\" --write --log-level none";
|
|
16
17
|
} catch (_error) {}
|
|
17
18
|
try {
|
|
18
|
-
|
|
19
|
+
projectRequire.resolve("eslint");
|
|
19
20
|
return "eslint --fix \"{{file}}\" --quiet";
|
|
20
21
|
} catch (_error) {}
|
|
21
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectFormatCommand.cjs","names":[],"sources":["../../../src/writeContentDeclaration/detectFormatCommand.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"detectFormatCommand.cjs","names":[],"sources":["../../../src/writeContentDeclaration/detectFormatCommand.ts"],"sourcesContent":["import { getProjectRequire } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const detectFormatCommand = (configuration: IntlayerConfig) => {\n const { formatCommand } = configuration.content;\n const projectRequire = getProjectRequire();\n\n if (formatCommand) {\n return formatCommand;\n }\n\n // Try Prettier\n try {\n projectRequire.resolve('prettier');\n\n return 'prettier --write \"{{file}}\" --log-level silent';\n } catch (_error) {\n // Prettier not found, continue to next option\n }\n\n // Try Biome\n try {\n projectRequire.resolve('biome');\n\n return 'biome format \"{{file}}\" --write --log-level none';\n } catch (_error) {\n // Biome not found, continue to next option\n }\n\n // Try ESLint\n try {\n projectRequire.resolve('eslint');\n\n return 'eslint --fix \"{{file}}\" --quiet';\n } catch (_error) {\n // ESLint not found, no formatter available\n }\n\n // No formatter found\n return undefined;\n};\n"],"mappings":";;;;;AAGA,MAAa,uBAAuB,kBAAkC;CACpE,MAAM,EAAE,kBAAkB,cAAc;CACxC,MAAM,2DAAoC;AAE1C,KAAI,cACF,QAAO;AAIT,KAAI;AACF,iBAAe,QAAQ,WAAW;AAElC,SAAO;UACA,QAAQ;AAKjB,KAAI;AACF,iBAAe,QAAQ,QAAQ;AAE/B,SAAO;UACA,QAAQ;AAKjB,KAAI;AACF,iBAAe,QAAQ,SAAS;AAEhC,SAAO;UACA,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanOutputDir.mjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync, rmSync } from 'node:fs';\nimport { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const cleanOutputDir = (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n if (existsSync(dynamicDictionariesDir)) {\n // Delete the dynamic dictionaries directory\n rmSync(dynamicDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;AAIA,MAAa,kBAAkB,kBAAkC;CAC/D,MAAM,EACJ,iBACA,yBACA,wBACA,SACA,UACA,cACE,cAAc;CAElB,MAAM,YAAY,aAAa,cAAc;AAE7C,KAAI,WAAW,gBAAgB,CAE7B,QAAO,iBAAiB,EAAE,WAAW,MAAM,CAAC;AAG9C,KAAI,WAAW,wBAAwB,CAErC,QAAO,yBAAyB,EAAE,WAAW,MAAM,CAAC;AAGtD,KAAI,WAAW,uBAAuB,CAEpC,QAAO,wBAAwB,EAAE,WAAW,MAAM,CAAC;AAIrD,KAAI,WAAW,QAAQ,CACrB,QAAO,SAAS,EAAE,WAAW,MAAM,CAAC;AAItC,KAAI,WAAW,SAAS,CACtB,QAAO,UAAU,EAAE,WAAW,MAAM,CAAC;AAIvC,KAAI,WAAW,UAAU,CACvB,QAAO,WAAW,EAAE,WAAW,MAAM,CAAC;AAGxC,WAAU,4BAA4B,EACpC,WAAW,MACZ,CAAC"}
|
|
1
|
+
{"version":3,"file":"cleanOutputDir.mjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync, rmSync } from 'node:fs';\nimport { getAppLogger } from '@intlayer/config/client';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const cleanOutputDir = (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n if (existsSync(dynamicDictionariesDir)) {\n // Delete the dynamic dictionaries directory\n rmSync(dynamicDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;AAIA,MAAa,kBAAkB,kBAAkC;CAC/D,MAAM,EACJ,iBACA,yBACA,wBACA,SACA,UACA,cACE,cAAc;CAElB,MAAM,YAAY,aAAa,cAAc;AAE7C,KAAI,WAAW,gBAAgB,CAE7B,QAAO,iBAAiB,EAAE,WAAW,MAAM,CAAC;AAG9C,KAAI,WAAW,wBAAwB,CAErC,QAAO,yBAAyB,EAAE,WAAW,MAAM,CAAC;AAGtD,KAAI,WAAW,uBAAuB,CAEpC,QAAO,wBAAwB,EAAE,WAAW,MAAM,CAAC;AAIrD,KAAI,WAAW,QAAQ,CACrB,QAAO,SAAS,EAAE,WAAW,MAAM,CAAC;AAItC,KAAI,WAAW,SAAS,CACtB,QAAO,UAAU,EAAE,WAAW,MAAM,CAAC;AAIvC,KAAI,WAAW,UAAU,CACvB,QAAO,WAAW,EAAE,WAAW,MAAM,CAAC;AAGxC,WAAU,4BAA4B,EACpC,WAAW,MACZ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parallelize } from "../utils/parallelize.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { clearModuleCache, getProjectRequire } from "@intlayer/config";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ const createTypes = async (dictionariesPaths, configuration) => {
|
|
|
15
15
|
const { typesDir } = content;
|
|
16
16
|
await mkdir(typesDir, { recursive: true });
|
|
17
17
|
return (await parallelize(dictionariesPaths, async (dictionaryPath) => {
|
|
18
|
-
const requireFunction = build.require ??
|
|
18
|
+
const requireFunction = build.require ?? getProjectRequire();
|
|
19
19
|
clearModuleCache(dictionaryPath);
|
|
20
20
|
const dictionary = requireFunction(dictionaryPath);
|
|
21
21
|
if (!dictionary.key) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createType.mjs","names":["dictionary: Dictionary","typeDefinition: string","outputPath: string"],"sources":["../../../src/createType/createType.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { clearModuleCache,
|
|
1
|
+
{"version":3,"file":"createType.mjs","names":["dictionary: Dictionary","typeDefinition: string","outputPath: string"],"sources":["../../../src/createType/createType.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { clearModuleCache, getProjectRequire } from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\n\nexport const generateTypeScriptType = (dictionary: Dictionary) => {\n const jsonString = JSON.stringify(dictionary, null, 2);\n\n return `/* eslint-disable */\\nexport default ${jsonString} as const;\\n`;\n};\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionariesPaths: string[],\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { build, content } = configuration;\n const { typesDir } = content;\n\n // Create type folders if they don't exist\n await mkdir(typesDir, { recursive: true });\n\n const results = await parallelize(\n dictionariesPaths,\n async (dictionaryPath): Promise<string | undefined> => {\n const requireFunction = build.require ?? getProjectRequire();\n clearModuleCache(dictionaryPath);\n\n const dictionary: Dictionary = requireFunction(dictionaryPath);\n\n if (!dictionary.key) {\n return undefined;\n }\n\n const typeDefinition: string = generateTypeScriptType(dictionary);\n\n const outputPath: string = resolve(typesDir, `${dictionary.key}.ts`);\n\n await writeFile(outputPath, typeDefinition);\n\n return outputPath;\n }\n );\n\n return results.filter(Boolean) as string[];\n};\n"],"mappings":";;;;;;AAMA,MAAa,0BAA0B,eAA2B;AAGhE,QAAO,wCAFY,KAAK,UAAU,YAAY,MAAM,EAAE,CAEI;;;;;AAK5D,MAAa,cAAc,OACzB,mBACA,kBACsB;CACtB,MAAM,EAAE,OAAO,YAAY;CAC3B,MAAM,EAAE,aAAa;AAGrB,OAAM,MAAM,UAAU,EAAE,WAAW,MAAM,CAAC;AAwB1C,SAtBgB,MAAM,YACpB,mBACA,OAAO,mBAAgD;EACrD,MAAM,kBAAkB,MAAM,WAAW,mBAAmB;AAC5D,mBAAiB,eAAe;EAEhC,MAAMA,aAAyB,gBAAgB,eAAe;AAE9D,MAAI,CAAC,WAAW,IACd;EAGF,MAAMC,iBAAyB,uBAAuB,WAAW;EAEjE,MAAMC,aAAqB,QAAQ,UAAU,GAAG,WAAW,IAAI,KAAK;AAEpE,QAAM,UAAU,YAAY,eAAe;AAE3C,SAAO;GAEV,EAEc,OAAO,QAAQ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parallelize } from "./utils/parallelize.mjs";
|
|
2
|
-
import { getAppLogger, getConfiguration, x } from "@intlayer/config";
|
|
3
2
|
import { getIntlayerAPIProxy } from "@intlayer/api";
|
|
3
|
+
import { getAppLogger, getConfiguration, x } from "@intlayer/config";
|
|
4
4
|
|
|
5
5
|
//#region src/fetchDistantDictionaries.ts
|
|
6
6
|
/**
|
|
@@ -7,19 +7,7 @@ import fg from "fast-glob";
|
|
|
7
7
|
* @returns An array of dictionary paths
|
|
8
8
|
*/
|
|
9
9
|
const listDictionaries = async (configuration) => {
|
|
10
|
-
return await fg(configuration.content.watchedFilesPatternWithPath, { ignore:
|
|
11
|
-
"**/node_modules/**",
|
|
12
|
-
"**/.git/**",
|
|
13
|
-
"**/.github/**",
|
|
14
|
-
"**/.next/**",
|
|
15
|
-
"**/.expo/**",
|
|
16
|
-
"**/.expo-shared/**",
|
|
17
|
-
"**/.vercel/**",
|
|
18
|
-
"**/.cache/**",
|
|
19
|
-
"**/dist/**",
|
|
20
|
-
"**/build/**",
|
|
21
|
-
"**/.intlayer/**"
|
|
22
|
-
] });
|
|
10
|
+
return await fg(configuration.content.watchedFilesPatternWithPath, { ignore: configuration.content.excludedPath });
|
|
23
11
|
};
|
|
24
12
|
|
|
25
13
|
//#endregion
|