@intlayer/chokidar 7.5.6 → 7.5.8

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.
Files changed (67) hide show
  1. package/dist/assets/initConfig/templates/cjs.txt +18 -0
  2. package/dist/assets/initConfig/templates/js.txt +18 -0
  3. package/dist/assets/initConfig/templates/json.txt +7 -0
  4. package/dist/assets/initConfig/templates/mjs.txt +18 -0
  5. package/dist/assets/initConfig/templates/ts.txt +16 -0
  6. package/dist/cjs/createType/createType.cjs +3 -7
  7. package/dist/cjs/createType/createType.cjs.map +1 -1
  8. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +1 -1
  9. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  10. package/dist/cjs/handleContentDeclarationFileChange.cjs +6 -3
  11. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  12. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +1 -1
  13. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  14. package/dist/cjs/index.cjs +2 -0
  15. package/dist/cjs/init/index.cjs +131 -0
  16. package/dist/cjs/init/index.cjs.map +1 -0
  17. package/dist/cjs/initConfig/index.cjs +42 -0
  18. package/dist/cjs/initConfig/index.cjs.map +1 -0
  19. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +3 -3
  20. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  21. package/dist/cjs/prepareIntlayer.cjs +1 -1
  22. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  23. package/dist/cjs/transformFiles/transformFiles.cjs.map +1 -1
  24. package/dist/esm/createType/createType.mjs +3 -7
  25. package/dist/esm/createType/createType.mjs.map +1 -1
  26. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +1 -1
  27. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  28. package/dist/esm/handleContentDeclarationFileChange.mjs +6 -3
  29. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  30. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +1 -1
  31. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  32. package/dist/esm/index.mjs +2 -1
  33. package/dist/esm/init/index.mjs +130 -0
  34. package/dist/esm/init/index.mjs.map +1 -0
  35. package/dist/esm/initConfig/index.mjs +40 -0
  36. package/dist/esm/initConfig/index.mjs.map +1 -0
  37. package/dist/esm/loadDictionaries/loadDictionaries.mjs +3 -3
  38. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  39. package/dist/esm/prepareIntlayer.mjs +1 -1
  40. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  41. package/dist/esm/transformFiles/transformFiles.mjs +2 -2
  42. package/dist/esm/transformFiles/transformFiles.mjs.map +1 -1
  43. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -2
  44. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  45. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
  46. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  47. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
  48. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  49. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
  50. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  51. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
  52. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  53. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
  54. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
  55. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
  56. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
  57. package/dist/types/createType/createType.d.ts +1 -1
  58. package/dist/types/createType/createType.d.ts.map +1 -1
  59. package/dist/types/formatDictionary.d.ts +15 -15
  60. package/dist/types/index.d.ts +2 -1
  61. package/dist/types/init/index.d.ts +8 -0
  62. package/dist/types/init/index.d.ts.map +1 -0
  63. package/dist/types/initConfig/index.d.ts +11 -0
  64. package/dist/types/initConfig/index.d.ts.map +1 -0
  65. package/dist/types/transformFiles/transformFiles.d.ts.map +1 -1
  66. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
  67. package/package.json +10 -10
@@ -0,0 +1,18 @@
1
+ const { Locales } = require('intlayer');
2
+
3
+ /** @type {import('intlayer').IntlayerConfig} */
4
+ const getIntlayerConfig = () => {
5
+ /** @type {import('intlayer').IntlayerConfig} */
6
+ const config = {
7
+ internationalization: {
8
+ locales: [Locales.ENGLISH],
9
+ defaultLocale: Locales.ENGLISH,
10
+ },
11
+ };
12
+
13
+ return config;
14
+ };
15
+
16
+ const config = getIntlayerConfig();
17
+
18
+ module.exports = config;
@@ -0,0 +1,18 @@
1
+ import { Locales } from 'intlayer';
2
+
3
+ /** @type {import('intlayer').IntlayerConfig} */
4
+ const getIntlayerConfig = () => {
5
+ /** @type {import('intlayer').IntlayerConfig} */
6
+ const config = {
7
+ internationalization: {
8
+ locales: [Locales.ENGLISH],
9
+ defaultLocale: Locales.ENGLISH,
10
+ },
11
+ };
12
+
13
+ return config;
14
+ };
15
+
16
+ const config = getIntlayerConfig();
17
+
18
+ export default config;
@@ -0,0 +1,7 @@
1
+ {
2
+ "internationalization": {
3
+ "locales": ["en"],
4
+ "defaultLocale": "en"
5
+ }
6
+ }
7
+
@@ -0,0 +1,18 @@
1
+ import { Locales } from 'intlayer';
2
+
3
+ /** @type {import('intlayer').IntlayerConfig} */
4
+ const getIntlayerConfig = () => {
5
+ /** @type {import('intlayer').IntlayerConfig} */
6
+ const config = {
7
+ internationalization: {
8
+ locales: [Locales.ENGLISH],
9
+ defaultLocale: Locales.ENGLISH,
10
+ },
11
+ };
12
+
13
+ return config;
14
+ };
15
+
16
+ const config = getIntlayerConfig();
17
+
18
+ export default config;
@@ -0,0 +1,16 @@
1
+ import { type IntlayerConfig, Locales } from 'intlayer';
2
+
3
+ const getIntlayerConfig = (): IntlayerConfig => {
4
+ const config: IntlayerConfig = {
5
+ internationalization: {
6
+ locales: [Locales.ENGLISH],
7
+ defaultLocale: Locales.ENGLISH,
8
+ },
9
+ };
10
+
11
+ return config;
12
+ };
13
+
14
+ const config = getIntlayerConfig();
15
+
16
+ export default config;
@@ -2,7 +2,6 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_utils_parallelize = require('../utils/parallelize.cjs');
3
3
  let node_fs_promises = require("node:fs/promises");
4
4
  let node_path = require("node:path");
5
- let _intlayer_config = require("@intlayer/config");
6
5
 
7
6
  //#region src/createType/createType.ts
8
7
  const generateTypeScriptType = (dictionary) => {
@@ -11,14 +10,11 @@ const generateTypeScriptType = (dictionary) => {
11
10
  /**
12
11
  * This function generates a TypeScript type definition from a JSON object
13
12
  */
14
- const createTypes = async (dictionariesPaths, configuration) => {
15
- const { build, content } = configuration;
13
+ const createTypes = async (dictionaries, configuration) => {
14
+ const { content } = configuration;
16
15
  const { typesDir } = content;
17
16
  await (0, node_fs_promises.mkdir)(typesDir, { recursive: true });
18
- return (await require_utils_parallelize.parallelize(dictionariesPaths, async (dictionaryPath) => {
19
- const requireFunction = build.require ?? (0, _intlayer_config.getProjectRequire)();
20
- (0, _intlayer_config.clearModuleCache)(dictionaryPath);
21
- const dictionary = requireFunction(dictionaryPath);
17
+ return (await require_utils_parallelize.parallelize(dictionaries, async (dictionary) => {
22
18
  if (!dictionary.key) return;
23
19
  const typeDefinition = generateTypeScriptType(dictionary);
24
20
  const outputPath = (0, node_path.resolve)(typesDir, `${dictionary.key}.ts`);
@@ -1 +1 @@
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,oDAA8B;AAC5D,yCAAiB,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
+ {"version":3,"file":"createType.cjs","names":["parallelize","typeDefinition: string","outputPath: string"],"sources":["../../../src/createType/createType.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\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 dictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { 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 dictionaries,\n async (dictionary): Promise<string | undefined> => {\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":";;;;;;AAKA,MAAa,0BAA0B,eAA2B;AAGhE,QAAO,wCAFY,KAAK,UAAU,YAAY,MAAM,EAAE,CAEI;;;;;AAK5D,MAAa,cAAc,OACzB,cACA,kBACsB;CACtB,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,aAAa;AAGrB,mCAAY,UAAU,EAAE,WAAW,MAAM,CAAC;AAmB1C,SAjBgB,MAAMA,sCACpB,cACA,OAAO,eAA4C;AACjD,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"}
@@ -12,7 +12,7 @@ const handleAdditionalContentDeclarationFile = async (filePath, config) => {
12
12
  const appLogger = (0, _intlayer_config.getAppLogger)(config);
13
13
  appLogger(`Additional file detected: ${require_utils_formatter.formatPath(filePath)}`, { isVerbose: true });
14
14
  const dictionariesOutput = await require_buildIntlayerDictionary_buildIntlayerDictionary.buildDictionary(await require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries(filePath, config), config);
15
- await require_createType_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath), config);
15
+ await require_createType_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionary), config);
16
16
  await require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint(config);
17
17
  appLogger("Dictionaries built", { isVerbose: true });
18
18
  require_createType_createModuleAugmentation.createModuleAugmentation(config);
@@ -1 +1 @@
1
- {"version":3,"file":"handleAdditionalContentDeclarationFile.cjs","names":["formatPath","buildDictionary","loadLocalDictionaries","createTypes","createDictionaryEntryPoint"],"sources":["../../src/handleAdditionalContentDeclarationFile.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Additional file detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths, config);\n\n await createDictionaryEntryPoint(config);\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\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 config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,yCAAyC,OACpD,UACA,WACG;CACH,MAAM,+CAAyB,OAAO;AAGtC,WAAU,6BAA6BA,mCAAW,SAAS,IAAI,EAC7D,WAAW,MACZ,CAAC;CAIF,MAAM,qBAAqB,MAAMC,wEAFN,MAAMC,qEAAsB,UAAU,OAAO,EAEH,OAAO;AAM5E,OAAMC,0CAJoB,OAAO,OAC/B,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe,EAEX,OAAO;AAE5C,OAAMC,yFAA2B,OAAO;AAExC,WAAU,sBAAsB,EAC9B,WAAW,MACZ,CAAC;AAEF,sEAAyB,OAAO;AAEhC,WAAU,6BAA6B,EACrC,WAAW,MACZ,CAAC;AAIF,YAAW,MAAM,UAAU,OAAO,WAAW,EAAE,EAAE;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,QAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;IACD;GACD,eAAe;GAChB,CAAC"}
1
+ {"version":3,"file":"handleAdditionalContentDeclarationFile.cjs","names":["formatPath","buildDictionary","loadLocalDictionaries","createTypes","createDictionaryEntryPoint"],"sources":["../../src/handleAdditionalContentDeclarationFile.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { createModuleAugmentation, createTypes } from './createType/index';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Additional file detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, config);\n\n await createDictionaryEntryPoint(config);\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\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 config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,yCAAyC,OACpD,UACA,WACG;CACH,MAAM,+CAAyB,OAAO;AAGtC,WAAU,6BAA6BA,mCAAW,SAAS,IAAI,EAC7D,WAAW,MACZ,CAAC;CAIF,MAAM,qBAAqB,MAAMC,wEAFN,MAAMC,qEAAsB,UAAU,OAAO,EAEH,OAAO;AAM5E,OAAMC,0CAJsB,OAAO,OACjC,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,WAAW,EAEL,OAAO;AAE9C,OAAMC,yFAA2B,OAAO;AAExC,WAAU,sBAAsB,EAC9B,WAAW,MACZ,CAAC;AAEF,sEAAyB,OAAO;AAEhC,WAAU,6BAA6B,EACrC,WAAW,MACZ,CAAC;AAIF,YAAW,MAAM,UAAU,OAAO,WAAW,EAAE,EAAE;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,QAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;IACD;GACD,eAAe;GAChB,CAAC"}
@@ -16,7 +16,8 @@ const handleContentDeclarationFileChange = async (filePath, config) => {
16
16
  const allDictionariesPaths = await require_createDictionaryEntryPoint_getBuiltDictionariesPath.getBuiltDictionariesPath(config);
17
17
  const localeDictionaries = await require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries(filePath, config);
18
18
  const dictionariesOutput = await require_buildIntlayerDictionary_buildIntlayerDictionary.buildDictionary(localeDictionaries, config);
19
- const updatedDictionariesPaths = Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath);
19
+ const updatedDictionaries = Object.values(dictionariesOutput?.mergedDictionaries ?? {});
20
+ const updatedDictionariesPaths = updatedDictionaries.map((dictionary) => dictionary.dictionaryPath);
20
21
  const { excludeKeys, hasRebuilt } = await require_cleanRemovedContentDeclaration.cleanRemovedContentDeclaration(filePath, localeDictionaries.map((dictionary) => dictionary.key), config);
21
22
  const hasNewDictionaries = updatedDictionariesPaths.some((updatedDictionaryPath) => !allDictionariesPaths.includes(updatedDictionaryPath));
22
23
  if (hasRebuilt || hasNewDictionaries) {
@@ -24,8 +25,10 @@ const handleContentDeclarationFileChange = async (filePath, config) => {
24
25
  await require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint(config, { excludeKeys });
25
26
  appLogger("Dictionary list built", { isVerbose: true });
26
27
  }
27
- await require_createType_createType.createTypes(updatedDictionariesPaths, config);
28
- appLogger("TypeScript types built", { isVerbose: true });
28
+ }
29
+ await require_createType_createType.createTypes(updatedDictionaries.map((dictionary) => dictionary.dictionary), config);
30
+ appLogger("TypeScript types built", { isVerbose: true });
31
+ if (hasNewDictionaries) {
29
32
  await require_createType_createModuleAugmentation.createModuleAugmentation(config);
30
33
  appLogger("Module augmentation built", { isVerbose: true });
31
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handleContentDeclarationFileChange.cjs","names":["formatPath","allDictionariesPaths: string[]","getBuiltDictionariesPath","loadLocalDictionaries","buildDictionary","cleanRemovedContentDeclaration","createDictionaryEntryPoint","createTypes","createModuleAugmentation"],"sources":["../../src/handleContentDeclarationFileChange.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { getBuiltDictionariesPath } from './createDictionaryEntryPoint/getBuiltDictionariesPath';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const allDictionariesPaths: string[] = await getBuiltDictionariesPath(config);\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n const updatedDictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n const { excludeKeys, hasRebuilt } = await cleanRemovedContentDeclaration(\n filePath,\n localeDictionaries.map((dictionary) => dictionary.key),\n config\n );\n\n const hasNewDictionaries = updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n );\n\n // Rebuild artifacts if we cleaned up old files (hasRebuilt) OR if new files were added (hasNewDictionaries)\n if (hasRebuilt || hasNewDictionaries) {\n // If hasRebuilt is true, cleanRemovedContentDeclaration has already updated the entry point\n // to remove the old keys (and it likely included the new ones if they were already on disk).\n // If NOT hasRebuilt, we explicitly need to update the entry point to include the new dictionaries.\n if (!hasRebuilt) {\n await createDictionaryEntryPoint(config, { excludeKeys });\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n }\n\n // Always regenerate types and module augmentation when keys change (rename or add)\n await createTypes(updatedDictionariesPaths, config);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n await createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\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 config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,qCAAqC,OAChD,UACA,WACG;CACH,MAAM,+CAAyB,OAAO;AAGtC,WAAU,oBAAoBA,mCAAW,SAAS,IAAI,EACpD,WAAW,MACZ,CAAC;CAEF,MAAMC,uBAAiC,MAAMC,qFAAyB,OAAO;CAE7E,MAAM,qBAAqB,MAAMC,qEAAsB,UAAU,OAAO;CAExE,MAAM,qBAAqB,MAAMC,wEAAgB,oBAAoB,OAAO;CAC5E,MAAM,2BAA2B,OAAO,OACtC,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe;CAEhD,MAAM,EAAE,aAAa,eAAe,MAAMC,sEACxC,UACA,mBAAmB,KAAK,eAAe,WAAW,IAAI,EACtD,OACD;CAED,MAAM,qBAAqB,yBAAyB,MACjD,0BACC,CAAC,qBAAqB,SAAS,sBAAsB,CACxD;AAGD,KAAI,cAAc,oBAAoB;AAIpC,MAAI,CAAC,YAAY;AACf,SAAMC,yFAA2B,QAAQ,EAAE,aAAa,CAAC;AACzD,aAAU,yBAAyB,EACjC,WAAW,MACZ,CAAC;;AAIJ,QAAMC,0CAAY,0BAA0B,OAAO;AACnD,YAAU,0BAA0B,EAClC,WAAW,MACZ,CAAC;AAEF,QAAMC,qEAAyB,OAAO;AAEtC,YAAU,6BAA6B,EACrC,WAAW,MACZ,CAAC;;AAKJ,YAAW,MAAM,UAAU,OAAO,WAAW,EAAE,EAAE;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,QAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;IACD;GACD,eAAe;GAChB,CAAC"}
1
+ {"version":3,"file":"handleContentDeclarationFileChange.cjs","names":["formatPath","allDictionariesPaths: string[]","getBuiltDictionariesPath","loadLocalDictionaries","buildDictionary","cleanRemovedContentDeclaration","createDictionaryEntryPoint","createTypes","createModuleAugmentation"],"sources":["../../src/handleContentDeclarationFileChange.ts"],"sourcesContent":["import { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint';\nimport { getBuiltDictionariesPath } from './createDictionaryEntryPoint/getBuiltDictionariesPath';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const allDictionariesPaths: string[] = await getBuiltDictionariesPath(config);\n\n const localeDictionaries = await loadLocalDictionaries(filePath, config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n const updatedDictionaries = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n );\n const updatedDictionariesPaths = updatedDictionaries.map(\n (dictionary) => dictionary.dictionaryPath\n );\n\n const { excludeKeys, hasRebuilt } = await cleanRemovedContentDeclaration(\n filePath,\n localeDictionaries.map((dictionary) => dictionary.key),\n config\n );\n\n const hasNewDictionaries = updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n );\n\n // Rebuild Entry Point & Module Augmentation\n // These only need to be updated if the *list* of dictionaries changed (Add/Remove/Rename)\n if (hasRebuilt || hasNewDictionaries) {\n // If hasRebuilt is true, cleanRemovedContentDeclaration has already updated the entry point\n // to remove the old keys (and it likely included the new ones if they were already on disk).\n // If NOT hasRebuilt, we explicitly need to update the entry point to include the new dictionaries.\n if (!hasRebuilt) {\n await createDictionaryEntryPoint(config, { excludeKeys });\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n }\n }\n\n // Rebuild Types\n // Always regenerate types when a file changes, as the content structure (interface) might have changed\n // even if the key is the same.\n const dictionariesToBuild = updatedDictionaries.map(\n (dictionary) => dictionary.dictionary\n );\n\n await createTypes(dictionariesToBuild, config);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (hasNewDictionaries) {\n await createModuleAugmentation(config);\n appLogger('Module augmentation built', {\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 config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,qCAAqC,OAChD,UACA,WACG;CACH,MAAM,+CAAyB,OAAO;AAGtC,WAAU,oBAAoBA,mCAAW,SAAS,IAAI,EACpD,WAAW,MACZ,CAAC;CAEF,MAAMC,uBAAiC,MAAMC,qFAAyB,OAAO;CAE7E,MAAM,qBAAqB,MAAMC,qEAAsB,UAAU,OAAO;CAExE,MAAM,qBAAqB,MAAMC,wEAAgB,oBAAoB,OAAO;CAC5E,MAAM,sBAAsB,OAAO,OACjC,oBAAoB,sBAAsB,EAAE,CAC7C;CACD,MAAM,2BAA2B,oBAAoB,KAClD,eAAe,WAAW,eAC5B;CAED,MAAM,EAAE,aAAa,eAAe,MAAMC,sEACxC,UACA,mBAAmB,KAAK,eAAe,WAAW,IAAI,EACtD,OACD;CAED,MAAM,qBAAqB,yBAAyB,MACjD,0BACC,CAAC,qBAAqB,SAAS,sBAAsB,CACxD;AAID,KAAI,cAAc,oBAIhB;MAAI,CAAC,YAAY;AACf,SAAMC,yFAA2B,QAAQ,EAAE,aAAa,CAAC;AACzD,aAAU,yBAAyB,EACjC,WAAW,MACZ,CAAC;;;AAWN,OAAMC,0CAJsB,oBAAoB,KAC7C,eAAe,WAAW,WAC5B,EAEsC,OAAO;AAC9C,WAAU,0BAA0B,EAClC,WAAW,MACZ,CAAC;AAEF,KAAI,oBAAoB;AACtB,QAAMC,qEAAyB,OAAO;AACtC,YAAU,6BAA6B,EACrC,WAAW,MACZ,CAAC;;AAKJ,YAAW,MAAM,UAAU,OAAO,WAAW,EAAE,EAAE;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,QAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;IACD;GACD,eAAe;GAChB,CAAC"}
@@ -16,7 +16,7 @@ const handleUnlinkedContentDeclarationFile = async (filePath, config) => {
16
16
  const localeDictionaries = await require_loadDictionaries_loadLocalDictionaries.loadLocalDictionaries((await require_listDictionariesPath.listDictionaries(config)).filter((file) => (0, node_path.normalize)(file) !== (0, node_path.normalize)(filePath)), config);
17
17
  await require_cleanRemovedContentDeclaration.cleanRemovedContentDeclaration(filePath, [], config);
18
18
  const dictionariesOutput = await require_buildIntlayerDictionary_buildIntlayerDictionary.buildDictionary(localeDictionaries, config);
19
- await require_createType_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath), config);
19
+ await require_createType_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionary), config);
20
20
  appLogger("Dictionaries rebuilt", { isVerbose: true });
21
21
  await require_createType_createModuleAugmentation.createModuleAugmentation(config);
22
22
  appLogger("Module augmentation built", { isVerbose: true });
@@ -1 +1 @@
1
- {"version":3,"file":"handleUnlinkedContentDeclarationFile.cjs","names":["formatPath","loadLocalDictionaries","listDictionaries","cleanRemovedContentDeclaration","buildDictionary","createTypes","createModuleAugmentation"],"sources":["../../src/handleUnlinkedContentDeclarationFile.ts"],"sourcesContent":["import { normalize } from 'node:path';\nimport { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleUnlinkedContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const files: string[] = await listDictionaries(config);\n\n const existingFiles = files.filter(\n (file) => normalize(file) !== normalize(filePath)\n );\n\n const localeDictionaries = await loadLocalDictionaries(existingFiles, config);\n\n await cleanRemovedContentDeclaration(filePath, [], config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesPaths = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionaryPath);\n\n await createTypes(dictionariesPaths, config);\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n await createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\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 config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,uCAAuC,OAClD,UACA,WACG;CACH,MAAM,+CAAyB,OAAO;AAGtC,WAAU,sBAAsBA,mCAAW,SAAS,IAAI,EACtD,WAAW,MACZ,CAAC;CAQF,MAAM,qBAAqB,MAAMC,sEANT,MAAMC,8CAAiB,OAAO,EAE1B,QACzB,kCAAmB,KAAK,8BAAe,SAAS,CAClD,EAEqE,OAAO;AAE7E,OAAMC,sEAA+B,UAAU,EAAE,EAAE,OAAO;CAE1D,MAAM,qBAAqB,MAAMC,wEAAgB,oBAAoB,OAAO;AAM5E,OAAMC,0CAJoB,OAAO,OAC/B,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,eAAe,EAEX,OAAO;AAE5C,WAAU,wBAAwB,EAChC,WAAW,MACZ,CAAC;AAEF,OAAMC,qEAAyB,OAAO;AAEtC,WAAU,6BAA6B,EACrC,WAAW,MACZ,CAAC;AAIF,YAAW,MAAM,UAAU,OAAO,WAAW,EAAE,EAAE;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,QAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;IACD;GACD,eAAe;GAChB,CAAC"}
1
+ {"version":3,"file":"handleUnlinkedContentDeclarationFile.cjs","names":["formatPath","loadLocalDictionaries","listDictionaries","cleanRemovedContentDeclaration","buildDictionary","createTypes","createModuleAugmentation"],"sources":["../../src/handleUnlinkedContentDeclarationFile.ts"],"sourcesContent":["import { normalize } from 'node:path';\nimport { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleUnlinkedContentDeclarationFile = async (\n filePath: string,\n config: IntlayerConfig\n) => {\n const appLogger = getAppLogger(config);\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${formatPath(filePath)}`, {\n isVerbose: true,\n });\n\n const files: string[] = await listDictionaries(config);\n\n const existingFiles = files.filter(\n (file) => normalize(file) !== normalize(filePath)\n );\n\n const localeDictionaries = await loadLocalDictionaries(existingFiles, config);\n\n await cleanRemovedContentDeclaration(filePath, [], config);\n\n const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n const dictionariesToBuild = Object.values(\n dictionariesOutput?.mergedDictionaries ?? {}\n ).map((dictionary) => dictionary.dictionary);\n\n await createTypes(dictionariesToBuild, config);\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n await createModuleAugmentation(config);\n\n appLogger('Module augmentation built', {\n isVerbose: true,\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 config.plugins ?? []) {\n const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n await plugin.afterBuild?.({\n dictionaries: {\n unmergedDictionaries,\n mergedDictionaries,\n },\n configuration: config,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,uCAAuC,OAClD,UACA,WACG;CACH,MAAM,+CAAyB,OAAO;AAGtC,WAAU,sBAAsBA,mCAAW,SAAS,IAAI,EACtD,WAAW,MACZ,CAAC;CAQF,MAAM,qBAAqB,MAAMC,sEANT,MAAMC,8CAAiB,OAAO,EAE1B,QACzB,kCAAmB,KAAK,8BAAe,SAAS,CAClD,EAEqE,OAAO;AAE7E,OAAMC,sEAA+B,UAAU,EAAE,EAAE,OAAO;CAE1D,MAAM,qBAAqB,MAAMC,wEAAgB,oBAAoB,OAAO;AAM5E,OAAMC,0CAJsB,OAAO,OACjC,oBAAoB,sBAAsB,EAAE,CAC7C,CAAC,KAAK,eAAe,WAAW,WAAW,EAEL,OAAO;AAE9C,WAAU,wBAAwB,EAChC,WAAW,MACZ,CAAC;AAEF,OAAMC,qEAAyB,OAAO;AAEtC,WAAU,6BAA6B,EACrC,WAAW,MACZ,CAAC;AAIF,YAAW,MAAM,UAAU,OAAO,WAAW,EAAE,EAAE;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;AAErD,QAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;IACD;GACD,eAAe;GAChB,CAAC"}
@@ -24,6 +24,7 @@ const require_handleContentDeclarationFileChange = require('./handleContentDecla
24
24
  const require_listDictionariesPath = require('./listDictionariesPath.cjs');
25
25
  const require_handleUnlinkedContentDeclarationFile = require('./handleUnlinkedContentDeclarationFile.cjs');
26
26
  const require_getContentDeclarationFileTemplate_getContentDeclarationFileTemplate = require('./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs');
27
+ const require_init_index = require('./init/index.cjs');
27
28
  const require_listGitFiles = require('./listGitFiles.cjs');
28
29
  const require_utils_sortAlphabetically = require('./utils/sortAlphabetically.cjs');
29
30
  const require_loadDictionaries_loadRemoteDictionaries = require('./loadDictionaries/loadRemoteDictionaries.cjs');
@@ -90,6 +91,7 @@ exports.getTaskLimiter = require_utils_parallelizeGlobal.getTaskLimiter;
90
91
  exports.handleAdditionalContentDeclarationFile = require_handleAdditionalContentDeclarationFile.handleAdditionalContentDeclarationFile;
91
92
  exports.handleContentDeclarationFileChange = require_handleContentDeclarationFileChange.handleContentDeclarationFileChange;
92
93
  exports.handleUnlinkedContentDeclarationFile = require_handleUnlinkedContentDeclarationFile.handleUnlinkedContentDeclarationFile;
94
+ exports.initIntlayer = require_init_index.initIntlayer;
93
95
  exports.isInvalidDictionary = require_filterInvalidDictionaries.isInvalidDictionary;
94
96
  exports.listDictionaries = require_listDictionariesPath.listDictionaries;
95
97
  exports.listDictionariesWithStats = require_listDictionariesPath.listDictionariesWithStats;
@@ -0,0 +1,131 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_initConfig_index = require('../initConfig/index.cjs');
3
+ let node_fs_promises = require("node:fs/promises");
4
+ let node_path = require("node:path");
5
+ let _intlayer_config = require("@intlayer/config");
6
+
7
+ //#region src/init/index.ts
8
+ /**
9
+ * UTILITIES
10
+ */
11
+ const rootDir = process.cwd();
12
+ const exists = async (filePath) => {
13
+ try {
14
+ await (0, node_fs_promises.access)((0, node_path.join)(rootDir, filePath));
15
+ return true;
16
+ } catch {
17
+ return false;
18
+ }
19
+ };
20
+ const readFileFromRoot = async (filePath) => await (0, node_fs_promises.readFile)((0, node_path.join)(rootDir, filePath), "utf8");
21
+ const writeFileToRoot = async (filePath, content) => await (0, node_fs_promises.writeFile)((0, node_path.join)(rootDir, filePath), content, "utf8");
22
+ const parseJSONWithComments = (jsonString) => {
23
+ try {
24
+ return JSON.parse(jsonString);
25
+ } catch {}
26
+ const cleanedLines = jsonString.split("\n").map((line) => {
27
+ let inString = false;
28
+ let result = "";
29
+ for (let i = 0; i < line.length; i++) {
30
+ const char = line[i];
31
+ const nextChar = line[i + 1];
32
+ if (char === "\"" && (i === 0 || line[i - 1] !== "\\")) {
33
+ inString = !inString;
34
+ result += char;
35
+ continue;
36
+ }
37
+ if (inString) {
38
+ result += char;
39
+ continue;
40
+ }
41
+ if (char === "/" && nextChar === "/") break;
42
+ if (char === "/" && nextChar === "*") {
43
+ const endIndex = line.indexOf("*/", i + 2);
44
+ if (endIndex !== -1) {
45
+ i = endIndex + 1;
46
+ continue;
47
+ }
48
+ }
49
+ result += char;
50
+ }
51
+ return result;
52
+ });
53
+ return JSON.parse(cleanedLines.join("\n"));
54
+ };
55
+ const findTsConfigFiles = async () => {
56
+ try {
57
+ return (await (0, node_fs_promises.readdir)(rootDir)).filter((file) => file === "tsconfig.json" || /^tsconfig\..+\.json$/.test(file));
58
+ } catch {
59
+ return [];
60
+ }
61
+ };
62
+ /**
63
+ * MAIN LOGIC
64
+ */
65
+ const initIntlayer = async () => {
66
+ (0, _intlayer_config.logger)((0, _intlayer_config.colorize)("Checking Intlayer configuration...", _intlayer_config.ANSIColors.CYAN));
67
+ if (!await exists("package.json")) {
68
+ (0, _intlayer_config.logger)(`${_intlayer_config.x} No ${(0, _intlayer_config.colorizePath)("package.json")} found. Please run this script from the project root.`, { level: "error" });
69
+ process.exit(1);
70
+ }
71
+ const gitignorePath = ".gitignore";
72
+ if (await exists(gitignorePath)) {
73
+ const gitignoreContent = await readFileFromRoot(gitignorePath);
74
+ if (!gitignoreContent.includes("intlayer")) {
75
+ await writeFileToRoot(gitignorePath, `${gitignoreContent}\n\n# Intlayer\n.intlayer\n`);
76
+ (0, _intlayer_config.logger)(`${_intlayer_config.v} Added ${(0, _intlayer_config.colorizePath)(".intlayer")} to ${(0, _intlayer_config.colorizePath)(gitignorePath)}`);
77
+ } else (0, _intlayer_config.logger)(`${_intlayer_config.v} ${(0, _intlayer_config.colorizePath)(gitignorePath)} already includes .intlayer`);
78
+ }
79
+ const tsConfigFiles = await findTsConfigFiles();
80
+ let hasTsConfig = false;
81
+ for (const fileName of tsConfigFiles) if (await exists(fileName)) {
82
+ hasTsConfig = true;
83
+ try {
84
+ const config = parseJSONWithComments(await readFileFromRoot(fileName));
85
+ const typeDefinition = ".intlayer/**/*.ts";
86
+ let updated = false;
87
+ if (!config.include) {} else if (Array.isArray(config.include) && !config.include.some((patten) => patten.includes(".intlayer"))) {
88
+ config.include.push(typeDefinition);
89
+ updated = true;
90
+ } else if (config.include.includes(typeDefinition)) (0, _intlayer_config.logger)(`${_intlayer_config.v} ${(0, _intlayer_config.colorizePath)(fileName)} already includes intlayer types`);
91
+ if (updated) {
92
+ await writeFileToRoot(fileName, JSON.stringify(config, null, 2));
93
+ (0, _intlayer_config.logger)(`${_intlayer_config.v} Updated ${(0, _intlayer_config.colorizePath)(fileName)} to include intlayer types`);
94
+ }
95
+ } catch {
96
+ (0, _intlayer_config.logger)(`${_intlayer_config.x} Could not parse or update ${(0, _intlayer_config.colorizePath)(fileName)}. You may need to add ${(0, _intlayer_config.colorizePath)(".intlayer/types/**/*.ts")} manually.`, { level: "warn" });
97
+ }
98
+ }
99
+ await require_initConfig_index.initConfig(hasTsConfig ? "intlayer.config.ts" : "intlayer.config.mjs", rootDir);
100
+ for (const file of [
101
+ "vite.config.ts",
102
+ "vite.config.js",
103
+ "vite.config.mjs"
104
+ ]) if (await exists(file)) {
105
+ let content = await readFileFromRoot(file);
106
+ if (!content.includes("vite-intlayer")) {
107
+ content = `import { intlayer } from 'vite-intlayer'; // Add the plugin to the Vite plugin list\n${content}`;
108
+ await writeFileToRoot(file, content);
109
+ (0, _intlayer_config.logger)(`${_intlayer_config.v} Injected import into ${(0, _intlayer_config.colorizePath)(file)}`);
110
+ }
111
+ break;
112
+ }
113
+ for (const file of [
114
+ "next.config.js",
115
+ "next.config.mjs",
116
+ "next.config.ts"
117
+ ]) if (await exists(file)) {
118
+ let content = await readFileFromRoot(file);
119
+ if (!content.includes("next-intlayer")) {
120
+ content = `import { withIntlayer } from 'next-intlayer'; // Add the plugin to the Next.js configuration\n${content}`;
121
+ await writeFileToRoot(file, content);
122
+ (0, _intlayer_config.logger)(`${_intlayer_config.v} Injected import into ${(0, _intlayer_config.colorizePath)(file)}`);
123
+ }
124
+ break;
125
+ }
126
+ (0, _intlayer_config.logger)(`${_intlayer_config.v} ${(0, _intlayer_config.colorize)("Intlayer init setup complete.", _intlayer_config.ANSIColors.GREEN)}`);
127
+ };
128
+
129
+ //#endregion
130
+ exports.initIntlayer = initIntlayer;
131
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["ANSIColors","x","v","initConfig"],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { access, readdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n logger,\n v,\n x,\n} from '@intlayer/config';\nimport { initConfig } from '../initConfig';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\n\n// Helper to check if a file exists\nconst exists = async (filePath: string) => {\n try {\n await access(join(rootDir, filePath));\n return true;\n } catch {\n return false;\n }\n};\n\n// Helper to read a file\nconst readFileFromRoot = async (filePath: string) =>\n await readFile(join(rootDir, filePath), 'utf8');\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\n// Helper to parse JSON that may contain comments (tsconfig allows comments)\nconst parseJSONWithComments = (jsonString: string) => {\n // First, try parsing as-is (most tsconfig files don't have comments)\n try {\n return JSON.parse(jsonString);\n } catch {\n // If that fails, try stripping comments\n // Note: This simple approach removes comments line by line to avoid\n // matching glob patterns like /* and */ that appear in paths\n }\n\n // Process line by line to safely remove comments\n const lines = jsonString.split('\\n');\n const cleanedLines = lines.map((line) => {\n // Track if we're inside a string\n let inString = false;\n let result = '';\n\n for (let i = 0; i < line.length; i++) {\n const char = line[i];\n const nextChar = line[i + 1];\n\n // Handle string boundaries (accounting for escaped quotes)\n if (char === '\"' && (i === 0 || line[i - 1] !== '\\\\')) {\n inString = !inString;\n result += char;\n continue;\n }\n\n // If we're inside a string, keep the character\n if (inString) {\n result += char;\n continue;\n }\n\n // Check for single-line comment outside of strings\n if (char === '/' && nextChar === '/') {\n // Rest of line is a comment, stop here\n break;\n }\n\n // Check for multi-line comment start (/* ... */)\n // For simplicity, we only handle single-line /* */ comments here\n if (char === '/' && nextChar === '*') {\n const endIndex = line.indexOf('*/', i + 2);\n if (endIndex !== -1) {\n // Skip the comment\n i = endIndex + 1;\n continue;\n }\n }\n\n result += char;\n }\n\n return result;\n });\n\n return JSON.parse(cleanedLines.join('\\n'));\n};\n\n// Helper to find all tsconfig files (tsconfig.json, tsconfig.*.json)\nconst findTsConfigFiles = async (): Promise<string[]> => {\n try {\n const files = await readdir(rootDir);\n\n return files.filter(\n (file) => file === 'tsconfig.json' || /^tsconfig\\..+\\.json$/.test(file)\n );\n } catch {\n return [];\n }\n};\n\n/**\n * MAIN LOGIC\n */\n\nexport const initIntlayer = async () => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // Check for package.json to ensure we are in a project root\n if (!(await exists('package.json'))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n // Check .gitignore\n const gitignorePath = '.gitignore';\n if (await exists(gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // Check TSConfigs\n // Find all tsconfig files (tsconfig.json, tsconfig.*.json)\n const tsConfigFiles = await findTsConfigFiles();\n\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n // Check if include array exists - if not, skip (likely a solution-style tsconfig with references)\n let updated = false;\n if (!config.include) {\n // Skip tsconfig files without include array (e.g. solution-style configs with references)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((patten: string) =>\n patten.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n // We write back using standard JSON stringify (comments will be lost, sadly)\n // If preserving comments is critical, a more complex parser/printer is needed.\n await writeFileToRoot(fileName, JSON.stringify(config, null, 2));\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // Initialize Intlayer configuration file\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n await initConfig(format, rootDir);\n\n // Check Vite Config\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n\n for (const file of viteConfigs) {\n if (await exists(file)) {\n let content = await readFileFromRoot(file);\n\n if (!content.includes('vite-intlayer')) {\n const viteImport =\n \"import { intlayer } from 'vite-intlayer'; // Add the plugin to the Vite plugin list\";\n\n // Prepend the import\n content = `${viteImport}\\n${content}`;\n await writeFileToRoot(file, content);\n logger(`${v} Injected import into ${colorizePath(file)}`);\n }\n break; // Stop after finding one vite config\n }\n }\n\n // Check Next Config\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n\n for (const file of nextConfigs) {\n if (await exists(file)) {\n let content = await readFileFromRoot(file);\n\n if (!content.includes('next-intlayer')) {\n const nextImport =\n \"import { withIntlayer } from 'next-intlayer'; // Add the plugin to the Next.js configuration\";\n\n // Prepend the import\n content = `${nextImport}\\n${content}`;\n await writeFileToRoot(file, content);\n logger(`${v} Injected import into ${colorizePath(file)}`);\n }\n break; // Stop after finding one next config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AME,oCADS,cAAc,uBAAuB,uBAC3B,QAAQ;AAKjC,MAAK,MAAM,QAFS;EAAC;EAAkB;EAAkB;EAAkB,CAGzE,KAAI,MAAM,OAAO,KAAK,EAAE;EACtB,IAAI,UAAU,MAAM,iBAAiB,KAAK;AAE1C,MAAI,CAAC,QAAQ,SAAS,gBAAgB,EAAE;AAKtC,aAAU,wFAAkB;AAC5B,SAAM,gBAAgB,MAAM,QAAQ;AACpC,gCAAO,GAAGD,mBAAE,2DAAqC,KAAK,GAAG;;AAE3D;;AAOJ,MAAK,MAAM,QAFS;EAAC;EAAkB;EAAmB;EAAiB,CAGzE,KAAI,MAAM,OAAO,KAAK,EAAE;EACtB,IAAI,UAAU,MAAM,iBAAiB,KAAK;AAE1C,MAAI,CAAC,QAAQ,SAAS,gBAAgB,EAAE;AAKtC,aAAU,iGAAkB;AAC5B,SAAM,gBAAgB,MAAM,QAAQ;AACpC,gCAAO,GAAGA,mBAAE,2DAAqC,KAAK,GAAG;;AAE3D;;AAIJ,8BAAO,GAAGA,mBAAE,kCAAY,iCAAiCF,4BAAW,MAAM,GAAG"}
@@ -0,0 +1,42 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let node_fs_promises = require("node:fs/promises");
3
+ let node_path = require("node:path");
4
+ let _intlayer_config = require("@intlayer/config");
5
+ let node_url = require("node:url");
6
+
7
+ //#region src/initConfig/index.ts
8
+ /**
9
+ * UTILITIES
10
+ */
11
+ const rootDir = process.cwd();
12
+ const isESModule = typeof require("url").pathToFileURL(__filename).href === "string";
13
+ const currentFileDir = isESModule ? (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)) : __dirname;
14
+ const writeFileToRoot = async (filePath, content) => await (0, node_fs_promises.writeFile)((0, node_path.join)(rootDir, filePath), content, "utf8");
15
+ const readTemplate = async (templatePath) => await (0, node_fs_promises.readFile)((0, node_path.join)(currentFileDir, "templates", templatePath), "utf8");
16
+ const getTemplatePath = (format) => {
17
+ switch (format) {
18
+ case "ts": return "ts.txt";
19
+ case "cjs": return "cjs.txt";
20
+ case "mjs": return "mjs.txt";
21
+ case "js": return "js.txt";
22
+ case "json": return "json.txt";
23
+ default: return "ts.txt";
24
+ }
25
+ };
26
+ /**
27
+ * Initialize the Intlayer configuration file
28
+ */
29
+ const initConfig = async (format, baseDir) => {
30
+ const { configurationFilePath } = (0, _intlayer_config.searchConfigurationFile)(baseDir);
31
+ if (configurationFilePath) {
32
+ (0, _intlayer_config.logger)(`${_intlayer_config.v} ${(0, _intlayer_config.colorizePath)((0, node_path.relative)(baseDir, configurationFilePath))} already exists`);
33
+ return;
34
+ }
35
+ await writeFileToRoot(format, await readTemplate(getTemplatePath(format.split(".").pop())));
36
+ (0, _intlayer_config.logger)(`Created ${format}`);
37
+ };
38
+
39
+ //#endregion
40
+ exports.initConfig = initConfig;
41
+ exports.isESModule = isESModule;
42
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["v"],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n colorizePath,\n type configurationFilesCandidates,\n logger,\n searchConfigurationFile,\n v,\n} from '@intlayer/config';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\nexport const isESModule = typeof import.meta.url === 'string';\n\nconst currentFileDir = isESModule\n ? dirname(fileURLToPath(import.meta.url))\n : __dirname;\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\n// Helper to read a template file\nconst readTemplate = async (templatePath: string) =>\n await readFile(join(currentFileDir, 'templates', templatePath), 'utf8');\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return 'ts.txt';\n case 'cjs':\n return 'cjs.txt';\n case 'mjs':\n return 'mjs.txt';\n case 'js':\n return 'js.txt';\n case 'json':\n return 'json.txt';\n default:\n return 'ts.txt';\n }\n};\n\n/**\n * Initialize the Intlayer configuration file\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n const configContent = await readTemplate(templatePath);\n\n await writeFileToRoot(format, configContent);\n logger(`Created ${format}`);\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAM,UAAU,QAAQ,KAAK;AAC7B,MAAa,aAAa,yDAA2B;AAErD,MAAM,iBAAiB,8GACmB,CAAC,GACvC;AAGJ,MAAM,kBAAkB,OAAO,UAAkB,YAC/C,0DAAqB,SAAS,SAAS,EAAE,SAAS,OAAO;AAG3D,MAAM,eAAe,OAAO,iBAC1B,yDAAoB,gBAAgB,aAAa,aAAa,EAAE,OAAO;AAIzE,MAAM,mBAAmB,WAAyB;AAChD,SAAQ,QAAR;EACE,KAAK,KACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,QACE,QAAO;;;;;;AAOb,MAAa,aAAa,OACxB,QACA,YACG;CAEH,MAAM,EAAE,wEAAkD,QAAQ;AAGlE,KAAI,uBAAuB;AAEzB,+BAAO,GAAGA,mBAAE,8DADkB,SAAS,sBAAsB,CACpB,CAAC,iBAAiB;AAC3D;;AASF,OAAM,gBAAgB,QAFA,MAAM,aADP,gBAFH,OAAO,MAAM,IAAI,CAAC,KAAK,CAEM,CACO,CAEV;AAC5C,8BAAO,WAAW,SAAS"}
@@ -98,6 +98,7 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
98
98
  }
99
99
  });
100
100
  const pluginDictionaries = await Promise.all(loadPluginDictionariesPromise).then((dictionaries) => dictionaries.flat()).then((dictionaries) => require_filterInvalidDictionaries.filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => require_formatDictionary.formatDictionaries(dictionaries));
101
+ const pluginDictionariesTime = Date.now();
101
102
  const localDictionaries = await require_loadDictionaries_loadContentDeclaration.loadContentDeclarations(Array.isArray(contentDeclarationsPaths) ? contentDeclarationsPaths : [contentDeclarationsPaths], configuration, setLoadDictionariesStatus).then((dictionaries) => require_filterInvalidDictionaries.filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => require_formatDictionary.formatDictionaries(dictionaries));
102
103
  const localDictionariesTime = Date.now();
103
104
  setLoadDictionariesStatus(localDictionaries.map((dictionary) => ({
@@ -114,7 +115,6 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
114
115
  onError: (e) => logger.setRemoteError(e)
115
116
  }).then((dictionaries) => require_filterInvalidDictionaries.filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => require_formatDictionary.formatDictionaries(dictionaries));
116
117
  const remoteDictionariesTime = Date.now();
117
- const pluginDictionariesTime = Date.now();
118
118
  logger.finish();
119
119
  printSummary(configuration);
120
120
  return {
@@ -122,9 +122,9 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
122
122
  remoteDictionaries,
123
123
  pluginDictionaries,
124
124
  time: {
125
- localDictionaries: localDictionariesTime - loadDictionariesStartTime,
125
+ localDictionaries: localDictionariesTime - pluginDictionariesTime,
126
126
  remoteDictionaries: remoteDictionariesTime - localDictionariesTime,
127
- pluginDictionaries: pluginDictionariesTime - remoteDictionariesTime
127
+ pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime
128
128
  }
129
129
  };
130
130
  };
@@ -1 +1 @@
1
- {"version":3,"file":"loadDictionaries.cjs","names":["loadDictionariesStatus: DictionariesStatus[]","DictionariesLogger","updated: DictionariesStatus[]","ANSIColors","labels: string[]","pluginDictionaries: Dictionary[]","filterInvalidDictionaries","formatDictionaries","localDictionaries: Dictionary[]","loadContentDeclarations","remoteDictionaries: Dictionary[]","loadRemoteDictionaries"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n logger.setPluginTotal(pluginsWithLoadDictionaries.length);\n\n const completedPluginIndices = new Set<number>();\n const updatePluginProgress = () => {\n logger.setPluginDone(completedPluginIndices.size);\n };\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin, index) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n completedPluginIndices.add(index);\n updatePluginProgress();\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n completedPluginIndices.add(index);\n updatePluginProgress();\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n }\n\n const remoteDictionariesTime = Date.now();\n\n const pluginDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - remoteDictionariesTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;AA6BA,IAAIA,yBAA+C,EAAE;AACrD,MAAM,SAAS,IAAIC,iDAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,UAAgC,CAAC,GAAG,uBAAuB;AAEjE,MAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,KACrE;AACD,MAAI,SAAS,EACX,SAAQ,SA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Status[]","DictionariesLogger","updated: DictionariesStatus[]","ANSIColors","labels: string[]","pluginDictionaries: Dictionary[]","filterInvalidDictionaries","formatDictionaries","localDictionaries: Dictionary[]","loadContentDeclarations","remoteDictionaries: Dictionary[]","loadRemoteDictionaries"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/client';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const pluginsWithLoadDictionaries = (plugins ?? []).filter(\n (plugin) => plugin.loadDictionaries\n );\n\n logger.setPluginTotal(pluginsWithLoadDictionaries.length);\n\n const completedPluginIndices = new Set<number>();\n const updatePluginProgress = () => {\n logger.setPluginDone(completedPluginIndices.size);\n };\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin, index) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n completedPluginIndices.add(index);\n updatePluginProgress();\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error);\n completedPluginIndices.add(index);\n updatePluginProgress();\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const pluginDictionariesTime = Date.now();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n }\n\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - pluginDictionariesTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;AA6BA,IAAIA,yBAA+C,EAAE;AACrD,MAAM,SAAS,IAAIC,iDAAoB;AAEvC,MAAM,6BAA6B,aAAmC;CACpE,MAAMC,UAAgC,CAAC,GAAG,uBAAuB;AAEjE,MAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,KACrE;AACD,MAAI,SAAS,EACX,SAAQ,SAAS;MAEjB,SAAQ,KAAK,SAA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AAuB,IAAI,MAAM;AACjC,yBAAsB;AACtB,UAAO,EAAE;;GAGd;CAED,MAAME,qBAAmC,MAAM,QAAQ,IACrD,8BACD,CACE,MAAM,iBAAiB,aAAa,MAAM,CAAC,CAC3C,MAAM,iBACLC,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAE3D,MAAM,yBAAyB,KAAK,KAAK;CAMzC,MAAMC,oBAAkC,MAAMC,wEAJhC,MAAM,QAAQ,yBAAyB,GACjD,2BACA,CAAC,yBAAyB,EAI5B,eACA,0BACD,CACE,MAAM,iBACLH,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAE3D,MAAM,wBAAwB,KAAK,KAAK;AAWxC,2BATgC,kBAAkB,KAC/C,gBACE;EACC,eAAe,WAAW;EAC1B,MAAM;EACN,QAAQ;EACT,EACJ,CAEiD;CAElD,MAAM,wBAAwB,QAC5B,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAED,KAAI,sBAEF,QAAO,gBAAgB,KAAK;CAG9B,IAAIG,qBAAmC,EAAE;AAEzC,KAAI,sBACF,sBAAqB,MAAMC,uEACzB,eACA,2BACA;EACE,0BAA0B,OAAO,kBAAkB;EACnD,yBAAyB,OAAO,iBAAiB;EACjD,UAAU,MAAM,OAAO,eAAe,EAAE;EACzC,CACF,CACE,MAAM,iBACLL,4DAA0B,cAAc,cAAc,CACvD,CACA,MAAM,iBAAiBC,4CAAmB,aAAa,CAAC;CAG7D,MAAM,yBAAyB,KAAK,KAAK;AAGzC,QAAO,QAAQ;AAEf,cAAa,cAAc;AAE3B,QAAO;EACL;EACA;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;GAC9C;EACF"}
@@ -63,7 +63,7 @@ const prepareIntlayer = async (configuration, options) => {
63
63
  ...dictionaries.pluginDictionaries
64
64
  ], configuration, format, false);
65
65
  await require_buildIntlayerDictionary_writeRemoteDictionary.writeRemoteDictionary(dictionaries.remoteDictionaries, configuration);
66
- await require_createType_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath), configuration);
66
+ await require_createType_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionary), configuration);
67
67
  await require_createDictionaryEntryPoint_createDictionaryEntryPoint.createDictionaryEntryPoint(configuration);
68
68
  const dictionariesBuiltTime = Date.now();
69
69
  appLogger(["Dictionaries built", (0, _intlayer_config.colorize)(`(${dictionariesBuiltTime - preparationStartMs}ms)`, _intlayer_config.ANSIColors.GREY_DARK)]);