@intlayer/chokidar 5.3.3 → 5.3.5

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 (66) hide show
  1. package/dist/cjs/chokidar/watcher.cjs +46 -15
  2. package/dist/cjs/chokidar/watcher.cjs.map +1 -1
  3. package/dist/cjs/{getDictionariesPath.cjs → getBuiltDictionariesPath.cjs} +7 -7
  4. package/dist/cjs/getBuiltDictionariesPath.cjs.map +1 -0
  5. package/dist/cjs/index.cjs +14 -2
  6. package/dist/cjs/index.cjs.map +1 -1
  7. package/dist/cjs/listDictionariesPath.cjs +61 -0
  8. package/dist/cjs/listDictionariesPath.cjs.map +1 -0
  9. package/dist/cjs/prepareContentDeclaration.cjs +90 -0
  10. package/dist/cjs/prepareContentDeclaration.cjs.map +1 -0
  11. package/dist/cjs/prepareIntlayer.cjs +2 -29
  12. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  13. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs +2 -4
  14. package/dist/cjs/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.cjs.map +1 -1
  15. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs +2 -2
  16. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +1 -1
  17. package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs +17 -0
  18. package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs.map +1 -0
  19. package/dist/cjs/writeContentDeclaration/index.cjs +25 -0
  20. package/dist/cjs/writeContentDeclaration/index.cjs.map +1 -0
  21. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +125 -0
  22. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -0
  23. package/dist/esm/chokidar/watcher.mjs +46 -16
  24. package/dist/esm/chokidar/watcher.mjs.map +1 -1
  25. package/dist/esm/{getDictionariesPath.mjs → getBuiltDictionariesPath.mjs} +3 -3
  26. package/dist/esm/getBuiltDictionariesPath.mjs.map +1 -0
  27. package/dist/esm/index.mjs +11 -1
  28. package/dist/esm/index.mjs.map +1 -1
  29. package/dist/esm/listDictionariesPath.mjs +27 -0
  30. package/dist/esm/listDictionariesPath.mjs.map +1 -0
  31. package/dist/esm/prepareContentDeclaration.mjs +69 -0
  32. package/dist/esm/prepareContentDeclaration.mjs.map +1 -0
  33. package/dist/esm/prepareIntlayer.mjs +2 -19
  34. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  35. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs +2 -4
  36. package/dist/esm/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.mjs.map +1 -1
  37. package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs +2 -2
  38. package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +1 -1
  39. package/dist/esm/writeContentDeclaration/dictionaryStatus.mjs +1 -0
  40. package/dist/esm/writeContentDeclaration/dictionaryStatus.mjs.map +1 -0
  41. package/dist/esm/writeContentDeclaration/index.mjs +3 -0
  42. package/dist/esm/writeContentDeclaration/index.mjs.map +1 -0
  43. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +91 -0
  44. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -0
  45. package/dist/types/chokidar/watcher.d.ts +1 -0
  46. package/dist/types/chokidar/watcher.d.ts.map +1 -1
  47. package/dist/types/getBuiltDictionariesPath.d.ts +5 -0
  48. package/dist/types/getBuiltDictionariesPath.d.ts.map +1 -0
  49. package/dist/types/index.d.ts +4 -0
  50. package/dist/types/index.d.ts.map +1 -1
  51. package/dist/types/listDictionariesPath.d.ts +3 -0
  52. package/dist/types/listDictionariesPath.d.ts.map +1 -0
  53. package/dist/types/prepareContentDeclaration.d.ts +3 -0
  54. package/dist/types/prepareContentDeclaration.d.ts.map +1 -0
  55. package/dist/types/prepareIntlayer.d.ts.map +1 -1
  56. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +2 -0
  57. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -0
  58. package/dist/types/writeContentDeclaration/index.d.ts +3 -0
  59. package/dist/types/writeContentDeclaration/index.d.ts.map +1 -0
  60. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +8 -0
  61. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -0
  62. package/package.json +18 -14
  63. package/dist/cjs/getDictionariesPath.cjs.map +0 -1
  64. package/dist/esm/getDictionariesPath.mjs.map +0 -1
  65. package/dist/types/getDictionariesPath.d.ts +0 -5
  66. package/dist/types/getDictionariesPath.d.ts.map +0 -1
@@ -21,18 +21,21 @@ __export(watcher_exports, {
21
21
  buildAndWatchIntlayer: () => buildAndWatchIntlayer,
22
22
  handleAdditionalContentDeclarationFile: () => handleAdditionalContentDeclarationFile,
23
23
  handleContentDeclarationFileChange: () => handleContentDeclarationFileChange,
24
+ handleUnlikedContentDeclarationFile: () => handleUnlikedContentDeclarationFile,
24
25
  watch: () => watch
25
26
  });
26
27
  module.exports = __toCommonJS(watcher_exports);
27
28
  var import_path = require("path");
28
29
  var import_config = require("@intlayer/config");
29
30
  var import_chokidar = require("chokidar");
30
- var import_getDictionariesPath = require('../getDictionariesPath.cjs');
31
+ var import_getBuiltDictionariesPath = require('../getBuiltDictionariesPath.cjs');
31
32
  var import_loadLocalDictionaries = require('../loadDictionaries/loadLocalDictionaries.cjs');
32
33
  var import_declaration_file_to_dictionary = require('../transpiler/declaration_file_to_dictionary/index.cjs');
33
34
  var import_createDictionaryEntryPoint = require('../transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
34
35
  var import_dictionary_to_type = require('../transpiler/dictionary_to_type/index.cjs');
35
36
  var import_prepareIntlayer = require('../prepareIntlayer.cjs');
37
+ var import_listDictionariesPath = require('../listDictionariesPath.cjs');
38
+ const recentlyAddedFiles = /* @__PURE__ */ new Set();
36
39
  const handleAdditionalContentDeclarationFile = async (filePath, configuration) => {
37
40
  const { content } = configuration ?? (0, import_config.getConfiguration)({
38
41
  verbose: true
@@ -55,6 +58,26 @@ const handleAdditionalContentDeclarationFile = async (filePath, configuration) =
55
58
  isVerbose: true
56
59
  });
57
60
  };
61
+ const handleUnlikedContentDeclarationFile = async (filePath, configuration) => {
62
+ const { content } = configuration ?? (0, import_config.getConfiguration)({
63
+ verbose: true
64
+ });
65
+ (0, import_config.appLogger)(`Unlinked detected: ${(0, import_path.relative)(content.baseDir, filePath)}`, {
66
+ isVerbose: true
67
+ });
68
+ const files = (0, import_listDictionariesPath.listDictionaries)(configuration);
69
+ const localeDictionaries = await (0, import_loadLocalDictionaries.loadLocalDictionaries)(files);
70
+ const dictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(localeDictionaries);
71
+ (0, import_dictionary_to_type.createTypes)(dictionariesPaths);
72
+ (0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)();
73
+ (0, import_config.appLogger)("Dictionaries rebuilt", {
74
+ isVerbose: true
75
+ });
76
+ (0, import_dictionary_to_type.createModuleAugmentation)();
77
+ (0, import_config.appLogger)("Module augmentation built", {
78
+ isVerbose: true
79
+ });
80
+ };
58
81
  const handleContentDeclarationFileChange = async (filePath, configuration) => {
59
82
  const { content } = configuration ?? (0, import_config.getConfiguration)({
60
83
  verbose: true
@@ -64,22 +87,18 @@ const handleContentDeclarationFileChange = async (filePath, configuration) => {
64
87
  });
65
88
  const localeDictionaries = await (0, import_loadLocalDictionaries.loadLocalDictionaries)(filePath);
66
89
  const updatedDictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(localeDictionaries);
67
- const allDictionariesPaths = (0, import_getDictionariesPath.getDictionariesPath)();
90
+ const allDictionariesPaths = (0, import_getBuiltDictionariesPath.getBuiltDictionariesPath)();
68
91
  (0, import_dictionary_to_type.createTypes)(updatedDictionariesPaths);
69
92
  (0, import_config.appLogger)("TypeScript types built", {
70
93
  isVerbose: true
71
94
  });
72
95
  if (updatedDictionariesPaths.some(
73
- (updatedDictionaryPath) => allDictionariesPaths.includes(updatedDictionaryPath)
96
+ (updatedDictionaryPath) => !allDictionariesPaths.includes(updatedDictionaryPath)
74
97
  )) {
75
98
  (0, import_createDictionaryEntryPoint.createDictionaryEntryPoint)();
76
99
  (0, import_config.appLogger)("Dictionary list built", {
77
100
  isVerbose: true
78
101
  });
79
- (0, import_dictionary_to_type.createModuleAugmentation)();
80
- (0, import_config.appLogger)("Module augmentation built", {
81
- isVerbose: true
82
- });
83
102
  }
84
103
  };
85
104
  const watch = (options) => {
@@ -93,18 +112,29 @@ const watch = (options) => {
93
112
  ignoreInitial: true,
94
113
  // Process existing files
95
114
  ...options
115
+ }).on("add", async (filePath) => {
116
+ const fileName = (0, import_path.basename)(filePath);
117
+ recentlyAddedFiles.add(fileName);
118
+ await handleAdditionalContentDeclarationFile(filePath, configuration);
119
+ setTimeout(() => recentlyAddedFiles.delete(fileName), 1e3);
96
120
  }).on(
97
- "add",
98
- async (filePath) => await handleAdditionalContentDeclarationFile(filePath, configuration)
99
- ).on(
100
121
  "change",
101
122
  async (filePath) => await handleContentDeclarationFileChange(filePath, configuration)
102
- ).on(
103
- "error",
104
- (error) => (0, import_config.appLogger)("Watcher error: " + error, {
123
+ ).on("unlink", async (filePath) => {
124
+ setTimeout(async () => {
125
+ const fileName = (0, import_path.basename)(filePath);
126
+ if (recentlyAddedFiles.has(fileName)) {
127
+ return;
128
+ }
129
+ await handleUnlikedContentDeclarationFile(filePath, configuration);
130
+ }, 300);
131
+ }).on("error", async (error) => {
132
+ (0, import_config.appLogger)("Watcher error: " + error, {
105
133
  level: "error"
106
- })
107
- );
134
+ });
135
+ (0, import_config.appLogger)("Restarting watcher");
136
+ await (0, import_prepareIntlayer.prepareIntlayer)(configuration);
137
+ });
108
138
  };
109
139
  const buildAndWatchIntlayer = async (options) => {
110
140
  const configuration = options?.configuration ?? (0, import_config.getConfiguration)();
@@ -118,6 +148,7 @@ const buildAndWatchIntlayer = async (options) => {
118
148
  buildAndWatchIntlayer,
119
149
  handleAdditionalContentDeclarationFile,
120
150
  handleContentDeclarationFileChange,
151
+ handleUnlikedContentDeclarationFile,
121
152
  watch
122
153
  });
123
154
  //# sourceMappingURL=watcher.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getDictionariesPath } from '../getDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\nimport { prepareIntlayer } from '../prepareIntlayer';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(\n `Additional file detected: ${relative(content.baseDir, filePath)}`,\n {\n isVerbose: true,\n }\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\n const allDictionariesPaths: string[] = getDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some((updatedDictionaryPath) =>\n allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ??\n getConfiguration({\n verbose: true,\n });\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on(\n 'add',\n async (filePath) =>\n await handleAdditionalContentDeclarationFile(filePath, configuration)\n )\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('error', (error) =>\n appLogger('Watcher error: ' + error, {\n level: 'error',\n })\n );\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch || options.persistent) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AACzB,oBAIO;AAEP,sBAA6D;AAC7D,iCAAoC;AACpC,mCAAsC;AACtC,4CAAgC;A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ACT,gCAAiB;AAAA,IACf,SAAS;AAAA,EACX,CAAC;AAEH,QAAM,EAAE,OAAO,aAAa,4BAA4B,IACtD,cAAc;AAGhB,aAAO,gBAAAA,OAAc,6BAA6B;AAAA,IAChD,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACE;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,uCAAuC,UAAU,aAAa;AAAA,EACxE,EACC;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,mCAAmC,UAAU,aAAa;AAAA,EACpE,EACC;AAAA,IAAG;AAAA,IAAS,CAAC,cACZ,yBAAU,oBAAoB,OAAO;AAAA,MACnC,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACJ;AAEO,MAAM,wBAAwB,OAAO,YAA2B;AACrE,QAAM,gBAAgB,SAAS,qBAAiB,gCAAiB;AAEjE,YAAM,wCAAgB,aAAa;AAEnC,MAAI,cAAc,QAAQ,SAAS,QAAQ,YAAY;AAErD,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":["chokidarWatch"]}
1
+ {"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { basename, relative } from 'path';\nimport {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getBuiltDictionariesPath } from '../getBuiltDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\nimport { prepareIntlayer } from '../prepareIntlayer';\nimport { listDictionaries } from '../listDictionariesPath';\n\nconst recentlyAddedFiles = new Set<string>();\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(\n `Additional file detected: ${relative(content.baseDir, filePath)}`,\n {\n isVerbose: true,\n }\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleUnlikedContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(`Unlinked detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const files: string[] = listDictionaries(configuration);\n\n const localeDictionaries = await loadLocalDictionaries(files);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries rebuilt', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\n const allDictionariesPaths: string[] = getBuiltDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some(\n (updatedDictionaryPath) =>\n !allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ??\n getConfiguration({\n verbose: true,\n });\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('add', async (filePath) => {\n const fileName = basename(filePath);\n recentlyAddedFiles.add(fileName);\n\n await handleAdditionalContentDeclarationFile(filePath, configuration);\n\n setTimeout(() => recentlyAddedFiles.delete(fileName), 1000); // Allow time for unlink to trigger if it's a move\n })\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('unlink', async (filePath) => {\n setTimeout(async () => {\n const fileName = basename(filePath);\n\n if (recentlyAddedFiles.has(fileName)) {\n // The file was moved, so ignore unlink\n return;\n }\n\n await handleUnlikedContentDeclarationFile(filePath, configuration);\n }, 300); // Allow time for unlink to trigger if it's a move\n })\n .on('error', async (error) => {\n appLogger('Watcher error: ' + error, {\n level: 'error',\n });\n\n appLogger('Restarting watcher');\n\n await prepareIntlayer(configuration);\n });\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch || options.persistent) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmC;AACnC,oBAIO;AAEP,sBAA6D;AAC7D,s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,OAAO,UAAU;AAC5B,iCAAU,oBAAoB,OAAO;AAAA,MACnC,OAAO;AAAA,IACT,CAAC;AAED,iCAAU,oBAAoB;AAE9B,cAAM,wCAAgB,aAAa;AAAA,EACrC,CAAC;AACL;AAEO,MAAM,wBAAwB,OAAO,YAA2B;AACrE,QAAM,gBAAgB,SAAS,qBAAiB,gCAAiB;AAEjE,YAAM,wCAAgB,aAAa;AAEnC,MAAI,cAAc,QAAQ,SAAS,QAAQ,YAAY;AAErD,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":["chokidarWatch"]}
@@ -26,17 +26,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var getDictionariesPath_exports = {};
30
- __export(getDictionariesPath_exports, {
31
- getDictionariesPath: () => getDictionariesPath
29
+ var getBuiltDictionariesPath_exports = {};
30
+ __export(getBuiltDictionariesPath_exports, {
31
+ getBuiltDictionariesPath: () => getBuiltDictionariesPath
32
32
  });
33
- module.exports = __toCommonJS(getDictionariesPath_exports);
33
+ module.exports = __toCommonJS(getBuiltDictionariesPath_exports);
34
34
  var import_fs = require("fs");
35
35
  var import_config = require("@intlayer/config");
36
36
  var import_fast_glob = __toESM(require("fast-glob"));
37
37
  const { content } = (0, import_config.getConfiguration)();
38
38
  const { dictionariesDir, mainDir } = content;
39
- const getDictionariesPath = () => {
39
+ const getBuiltDictionariesPath = () => {
40
40
  if (!(0, import_fs.existsSync)(mainDir)) {
41
41
  (0, import_fs.mkdirSync)(mainDir, { recursive: true });
42
42
  }
@@ -45,6 +45,6 @@ const getDictionariesPath = () => {
45
45
  };
46
46
  // Annotate the CommonJS export names for ESM import in node:
47
47
  0 && (module.exports = {
48
- getDictionariesPath
48
+ getBuiltDictionariesPath
49
49
  });
50
- //# sourceMappingURL=getDictionariesPath.cjs.map
50
+ //# sourceMappingURL=getBuiltDictionariesPath.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getBuiltDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'fs';\nimport { getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\n\nconst { content } = getConfiguration();\nconst { dictionariesDir, mainDir } = content;\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDictionariesPath = () => {\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = fg.sync(`${dictionariesDir}/**/*.json`);\n\n return dictionariesPath;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAsC;AACtC,oBAAiC;AACjC,uBAAe;AAEf,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,iBAAiB,QAAQ,IAAI;AAK9B,MAAM,2BAA2B,MAAM;AAE5C,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAA6B,iBAAAA,QAAG,KAAK,GAAG,eAAe,YAAY;AAEzE,SAAO;AACT;","names":["fg"]}
@@ -24,13 +24,17 @@ __export(index_exports, {
24
24
  createDictionaryEntryPoint: () => import_createDictionaryEntryPoint.createDictionaryEntryPoint,
25
25
  createModuleAugmentation: () => import_createModuleAugmentation.createModuleAugmentation,
26
26
  fetchDistantDictionaries: () => import_fetchDistantDictionaries.fetchDistantDictionaries,
27
+ fetchDistantDictionaryKeys: () => import_fetchDistantDictionaryKeys.fetchDistantDictionaryKeys,
27
28
  handleAdditionalContentDeclarationFile: () => import_watcher.handleAdditionalContentDeclarationFile,
28
29
  handleContentDeclarationFileChange: () => import_watcher.handleContentDeclarationFileChange,
30
+ listDictionaries: () => import_listDictionariesPath.listDictionaries,
29
31
  loadDictionaries: () => import_loadDictionaries.loadDictionaries,
30
32
  loadDistantDictionaries: () => import_loadDictionaries.loadDistantDictionaries,
31
33
  loadLocalDictionaries: () => import_loadDictionaries.loadLocalDictionaries,
34
+ prepareContentDeclaration: () => import_prepareContentDeclaration.prepareContentDeclaration,
32
35
  prepareIntlayer: () => import_prepareIntlayer.prepareIntlayer,
33
- watch: () => import_watcher.watch
36
+ watch: () => import_watcher.watch,
37
+ writeContentDeclaration: () => import_writeContentDeclaration.writeContentDeclaration
34
38
  });
35
39
  module.exports = __toCommonJS(index_exports);
36
40
  var import_watcher = require('./chokidar/watcher.cjs');
@@ -39,8 +43,12 @@ var import_declaration_file_to_dictionary = require('./transpiler/declaration_fi
39
43
  var import_createDictionaryEntryPoint = require('./transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
40
44
  var import_createModuleAugmentation = require('./transpiler/dictionary_to_type/createModuleAugmentation.cjs');
41
45
  var import_fetchDistantDictionaries = require('./fetchDistantDictionaries.cjs');
46
+ var import_fetchDistantDictionaryKeys = require('./fetchDistantDictionaryKeys.cjs');
42
47
  var import_loadDictionaries = require('./loadDictionaries/index.cjs');
43
48
  var import_checkDictionaryChanges = require('./checkDictionaryChanges.cjs');
49
+ var import_listDictionariesPath = require('./listDictionariesPath.cjs');
50
+ var import_prepareContentDeclaration = require('./prepareContentDeclaration.cjs');
51
+ var import_writeContentDeclaration = require('./writeContentDeclaration/index.cjs');
44
52
  // Annotate the CommonJS export names for ESM import in node:
45
53
  0 && (module.exports = {
46
54
  buildAndWatchIntlayer,
@@ -49,12 +57,16 @@ var import_checkDictionaryChanges = require('./checkDictionaryChanges.cjs');
49
57
  createDictionaryEntryPoint,
50
58
  createModuleAugmentation,
51
59
  fetchDistantDictionaries,
60
+ fetchDistantDictionaryKeys,
52
61
  handleAdditionalContentDeclarationFile,
53
62
  handleContentDeclarationFileChange,
63
+ listDictionaries,
54
64
  loadDictionaries,
55
65
  loadDistantDictionaries,
56
66
  loadLocalDictionaries,
67
+ prepareContentDeclaration,
57
68
  prepareIntlayer,
58
- watch
69
+ watch,
70
+ writeContentDeclaration
59
71
  });
60
72
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n watch,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n buildAndWatchIntlayer,\n} from './chokidar/watcher';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport {\n loadDistantDictionaries,\n loadDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { checkDictionaryChanges } from './checkDictionaryChanges';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAKO;AACP,6BAAgC;AAChC,4CAAgC;AAChC,wCAA2C;AAC3C,sCAAyC;AACzC,sCAAyC;AACzC,8BAIO;AACP,oCAAuC;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n watch,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n buildAndWatchIntlayer,\n} from './chokidar/watcher';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport {\n loadDistantDictionaries,\n loadDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { checkDictionaryChanges } from './checkDictionaryChanges';\nexport { listDictionaries } from './listDictionariesPath';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAKO;AACP,6BAAgC;AAChC,4CAAgC;AAChC,wCAA2C;AAC3C,sCAAyC;AACzC,sCAAyC;AACzC,wCAA2C;AAC3C,8BAIO;AACP,oCAAuC;AACvC,kCAAiC;AACjC,uCAA0C;AAC1C,qCAGO;","names":[]}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var listDictionariesPath_exports = {};
30
+ __export(listDictionariesPath_exports, {
31
+ listDictionaries: () => listDictionaries
32
+ });
33
+ module.exports = __toCommonJS(listDictionariesPath_exports);
34
+ var import_config = require("@intlayer/config");
35
+ var import_fast_glob = __toESM(require("fast-glob"));
36
+ const listDictionaries = (configuration = (0, import_config.getConfiguration)()) => {
37
+ const files = import_fast_glob.default.sync(
38
+ configuration.content.watchedFilesPatternWithPath,
39
+ {
40
+ ignore: [
41
+ "**/node_modules/**",
42
+ "**/.git/**",
43
+ "**/.github/**",
44
+ "**/.next/**",
45
+ "**/.expo/**",
46
+ "**/.expo-shared/**",
47
+ "**/.vercel/**",
48
+ "**/.cache/**",
49
+ "**/dist/**",
50
+ "**/build/**",
51
+ "**/.intlayer/**"
52
+ ]
53
+ }
54
+ );
55
+ return files;
56
+ };
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ listDictionaries
60
+ });
61
+ //# sourceMappingURL=listDictionariesPath.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import { type IntlayerConfig, getConfiguration } from '@intlayer/config';\nimport fg from 'fast-glob';\n\nexport const listDictionaries = (\n configuration: IntlayerConfig = getConfiguration()\n) => {\n const files: string[] = fg.sync(\n configuration.content.watchedFilesPatternWithPath,\n {\n ignore: [\n '**/node_modules/**',\n '**/.git/**',\n '**/.github/**',\n '**/.next/**',\n '**/.expo/**',\n '**/.expo-shared/**',\n '**/.vercel/**',\n '**/.cache/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n }\n );\n\n return files;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsD;AACtD,uBAAe;AAER,MAAM,mBAAmB,CAC9B,oBAAgC,gCAAiB,MAC9C;AACH,QAAM,QAAkB,iBAAAA,QAAG;AAAA,IACzB,cAAc,QAAQ;AAAA,IACtB;AAAA,MACE,QAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":["fg"]}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var prepareContentDeclaration_exports = {};
20
+ __export(prepareContentDeclaration_exports, {
21
+ prepareContentDeclaration: () => prepareContentDeclaration
22
+ });
23
+ module.exports = __toCommonJS(prepareContentDeclaration_exports);
24
+ var import_core = require("@intlayer/core");
25
+ var import_fs = require("fs");
26
+ var import_path = require("path");
27
+ const writeFilePlugin = {
28
+ id: "write-file-plugin",
29
+ canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.File,
30
+ transform: (node) => {
31
+ const fileContent = node.content;
32
+ const filePath = node.fixedPath;
33
+ if (typeof fileContent !== "string") {
34
+ throw new Error("File content must be a string");
35
+ }
36
+ if (typeof filePath !== "string") {
37
+ throw new Error("File path must be a string");
38
+ }
39
+ try {
40
+ const abolsuteFilePath = (0, import_path.join)(process.cwd(), filePath);
41
+ const fileDirectory = (0, import_path.join)(process.cwd(), filePath);
42
+ if (!fileDirectory.startsWith(process.cwd())) {
43
+ throw new Error("File directory not found");
44
+ }
45
+ if (!(0, import_fs.existsSync)(fileDirectory)) {
46
+ (0, import_fs.mkdirSync)(fileDirectory, { recursive: true });
47
+ }
48
+ (0, import_fs.writeFileSync)(abolsuteFilePath, fileContent);
49
+ } catch (error) {
50
+ throw new Error(`Error writing file to ${filePath}: ${error}`);
51
+ }
52
+ const transformedFileContent = {
53
+ nodeType: import_core.NodeType.File,
54
+ [import_core.NodeType.File]: node.file
55
+ };
56
+ return transformedFileContent;
57
+ }
58
+ };
59
+ const mardownFilePlugin = {
60
+ id: "markdown-file-plugin",
61
+ canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.Markdown,
62
+ transform: (node, props, deepTransformNode2) => {
63
+ const simplifiedMarkdownNode = {
64
+ nodeType: import_core.NodeType.Markdown,
65
+ [import_core.NodeType.Markdown]: deepTransformNode2(node.markdown, props)
66
+ };
67
+ return simplifiedMarkdownNode;
68
+ }
69
+ };
70
+ const insertionFilePlugin = {
71
+ id: "insertion-file-plugin",
72
+ canHandle: (node) => typeof node === "object" && node?.nodeType === import_core.NodeType.Insertion,
73
+ transform: (node, props, deepTransformNode2) => {
74
+ const simplifiedInsertionNode = {
75
+ nodeType: import_core.NodeType.Insertion,
76
+ [import_core.NodeType.Insertion]: deepTransformNode2(node.insertion, props)
77
+ };
78
+ return simplifiedInsertionNode;
79
+ }
80
+ };
81
+ const prepareContentDeclaration = async (dictionary) => (0, import_core.deepTransformNode)(dictionary, {
82
+ dictionaryKey: dictionary.key,
83
+ keyPath: [],
84
+ plugins: [writeFilePlugin, mardownFilePlugin, insertionFilePlugin]
85
+ });
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ prepareContentDeclaration
89
+ });
90
+ //# sourceMappingURL=prepareContentDeclaration.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/prepareContentDeclaration.ts"],"sourcesContent":["import {\n deepTransformNode,\n type Plugins,\n type Dictionary,\n NodeType,\n type FileContent,\n type FileContentConstructer,\n type MarkdownContent,\n type InsertionContent,\n type MarkdownContentConstructer,\n type InsertionContentConstructer,\n} from '@intlayer/core';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\n/**\n * Write file plugin\n */\n\nconst writeFilePlugin: Plugins = {\n id: 'write-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent) => {\n const fileContent = node.content;\n const filePath = node.fixedPath;\n\n if (typeof fileContent !== 'string') {\n throw new Error('File content must be a string');\n }\n\n if (typeof filePath !== 'string') {\n throw new Error('File path must be a string');\n }\n\n // Write the file to the file system\n try {\n const abolsuteFilePath = join(process.cwd(), filePath);\n\n // Create the file directory if it doesn't exist\n const fileDirectory = join(process.cwd(), filePath);\n if (!fileDirectory.startsWith(process.cwd())) {\n throw new Error('File directory not found');\n }\n\n if (!existsSync(fileDirectory)) {\n mkdirSync(fileDirectory, { recursive: true });\n }\n\n // Write the file\n writeFileSync(abolsuteFilePath, fileContent);\n } catch (error) {\n throw new Error(`Error writing file to ${filePath}: ${error}`);\n }\n\n const transformedFileContent: FileContentConstructer = {\n nodeType: NodeType.File,\n [NodeType.File]: node.file,\n };\n\n return transformedFileContent;\n },\n};\n\n/**\n * Markdown file plugin\n */\n\nconst mardownFilePlugin: Plugins = {\n id: 'markdown-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const simplifiedMarkdownNode: MarkdownContentConstructer = {\n nodeType: NodeType.Markdown,\n [NodeType.Markdown]: deepTransformNode(node.markdown, props),\n };\n\n return simplifiedMarkdownNode;\n },\n};\n\n/**\n * Injection file plugin\n */\n\nconst insertionFilePlugin: Plugins = {\n id: 'insertion-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const simplifiedInsertionNode: InsertionContentConstructer = {\n nodeType: NodeType.Insertion,\n [NodeType.Insertion]: deepTransformNode(node.insertion, props),\n };\n\n return simplifiedInsertionNode;\n },\n};\n\nexport const prepareContentDeclaration = async (dictionary: Dictionary) =>\n deepTransformNode(dictionary, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [writeFilePlugin, mardownFilePlugin, insertionFilePlugin],\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAWO;AACP,gBAAqD;AACrD,kBAAqB;AAMrB,MAAM,kBAA2B;AAAA,EAC/B,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,SAAsB;AAChC,UAAM,cAAc,KAAK;AACzB,UAAM,WAAW,KAAK;AAEtB,QAAI,OAAO,gBAAgB,UAAU;AACnC,YAAM,IAAI,MAAM,+BAA+B;AAAA,IACjD;AAEA,QAAI,OAAO,aAAa,UAAU;AAChC,YAAM,IAAI,MAAM,4BAA4B;AAAA,IAC9C;AAGA,QAAI;AACF,YAAM,uBAAmB,kBAAK,QAAQ,IAAI,GAAG,QAAQ;AAGrD,YAAM,oBAAgB,kBAAK,QAAQ,IAAI,GAAG,QAAQ;AAClD,UAAI,CAAC,cAAc,WAAW,QAAQ,IAAI,CAAC,GAAG;AAC5C,cAAM,IAAI,MAAM,0BAA0B;AAAA,MAC5C;AAEA,UAAI,KAAC,sBAAW,aAAa,GAAG;AAC9B,iCAAU,eAAe,EAAE,WAAW,KAAK,CAAC;AAAA,MAC9C;AAGA,mCAAc,kBAAkB,WAAW;AAAA,IAC7C,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,yBAAyB,QAAQ,KAAK,KAAK,EAAE;AAAA,IAC/D;AAEA,UAAM,yBAAiD;AAAA,MACrD,UAAU,qBAAS;AAAA,MACnB,CAAC,qBAAS,IAAI,GAAG,KAAK;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AACF;AAMA,MAAM,oBAA6B;AAAA,EACjC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAuB,OAAOA,uBAAsB;AAC9D,UAAM,yBAAqD;AAAA,MACzD,UAAU,qBAAS;AAAA,MACnB,CAAC,qBAAS,QAAQ,GAAGA,mBAAkB,KAAK,UAAU,KAAK;AAAA,IAC7D;AAEA,WAAO;AAAA,EACT;AACF;AAMA,MAAM,sBAA+B;AAAA,EACnC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,qBAAS;AAAA,EAC1D,WAAW,CAAC,MAAwB,OAAOA,uBAAsB;AAC/D,UAAM,0BAAuD;AAAA,MAC3D,UAAU,qBAAS;AAAA,MACnB,CAAC,qBAAS,SAAS,GAAGA,mBAAkB,KAAK,WAAW,KAAK;AAAA,IAC/D;AAEA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,4BAA4B,OAAO,mBAC9C,+BAAkB,YAAY;AAAA,EAC5B,eAAe,WAAW;AAAA,EAC1B,SAAS,CAAC;AAAA,EACV,SAAS,CAAC,iBAAiB,mBAAmB,mBAAmB;AACnE,CAAC;","names":["deepTransformNode"]}
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var prepareIntlayer_exports = {};
30
20
  __export(prepareIntlayer_exports, {
@@ -32,36 +22,19 @@ __export(prepareIntlayer_exports, {
32
22
  });
33
23
  module.exports = __toCommonJS(prepareIntlayer_exports);
34
24
  var import_config = require("@intlayer/config");
35
- var import_fast_glob = __toESM(require("fast-glob"));
36
25
  var import_cleanOutputDir = require('./cleanOutputDir.cjs');
37
26
  var import_loadDictionaries = require('./loadDictionaries/loadDictionaries.cjs');
38
27
  var import_declaration_file_to_dictionary = require('./transpiler/declaration_file_to_dictionary/index.cjs');
39
28
  var import_createDictionaryEntryPoint = require('./transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs');
40
29
  var import_dictionary_to_type = require('./transpiler/dictionary_to_type/index.cjs');
41
30
  var import_writeConfiguration = require('./writeConfiguration/index.cjs');
31
+ var import_listDictionariesPath = require('./listDictionariesPath.cjs');
42
32
  const prepareIntlayer = async (configuration = (0, import_config.getConfiguration)()) => {
43
33
  (0, import_cleanOutputDir.cleanOutputDir)();
44
34
  (0, import_config.appLogger)("Output directory cleaned", {
45
35
  isVerbose: true
46
36
  });
47
- const files = import_fast_glob.default.sync(
48
- configuration.content.watchedFilesPatternWithPath,
49
- {
50
- ignore: [
51
- "**/node_modules/**",
52
- "**/.git/**",
53
- "**/.github/**",
54
- "**/.next/**",
55
- "**/.expo/**",
56
- "**/.expo-shared/**",
57
- "**/.vercel/**",
58
- "**/.cache/**",
59
- "**/dist/**",
60
- "**/build/**",
61
- "**/.intlayer/**"
62
- ]
63
- }
64
- );
37
+ const files = (0, import_listDictionariesPath.listDictionaries)(configuration);
65
38
  const dictionaries = await (0, import_loadDictionaries.loadDictionaries)(files);
66
39
  const dictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(dictionaries);
67
40
  (0, import_dictionary_to_type.createTypes)(dictionariesPaths);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration()\n) => {\n cleanOutputDir();\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n\n const files: string[] = fg.sync(\n configuration.content.watchedFilesPatternWithPath,\n {\n ignore: [\n '**/node_modules/**',\n '**/.git/**',\n '**/.github/**',\n '**/.next/**',\n '**/.expo/**',\n '**/.expo-shared/**',\n '**/.vercel/**',\n '**/.cache/**',\n '**/dist/**',\n '**/build/**',\n '**/.intlayer/**',\n ],\n }\n );\n\n const dictionaries = await loadDictionaries(files);\n\n // Build locale dictionaries\n const dictionariesPaths = await buildDictionary(dictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n writeConfiguration(configuration);\n\n appLogger('Configuration written', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAIO;AACP,uBAAe;AACf,4BAA+B;AAC/B,8BAAiC;AACjC,4CAAgC;AAChC,wCAA2C;AAC3C,gCAGO;AACP,gCAAmC;AAE5B,MAAM,kBAAkB,OAC7B,oBAAgC,gCAAiB,MAC9C;AACH,4CAAe;AAEf,+BAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AAED,QAAM,QAAkB,iBAAAA,QAAG;AAAA,IACzB,cAAc,QAAQ;AAAA,IACtB;AAAA,MACE,QAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,UAAM,0CAAiB,KAAK;AAGjD,QAAM,oBAAoB,UAAM,uDAAgB,YAAY;AAE5D,6CAAY,iBAAiB;AAE7B,oEAA2B;AAE3B,+BAAU,oBAAoB;AAE9B,0DAAyB;AAEzB,+BAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AAED,oDAAmB,aAAa;AAEhC,+BAAU,yBAAyB;AAAA,IACjC,WAAW;AAAA,EACb,CAAC;AACH;","names":["fg"]}
1
+ {"version":3,"sources":["../../src/prepareIntlayer.ts"],"sourcesContent":["import {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { cleanOutputDir } from './cleanOutputDir';\nimport { loadDictionaries } from './loadDictionaries/loadDictionaries';\nimport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from './transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from './transpiler/dictionary_to_type/index';\nimport { writeConfiguration } from './writeConfiguration';\nimport { listDictionaries } from './listDictionariesPath';\n\nexport const prepareIntlayer = async (\n configuration: IntlayerConfig = getConfiguration()\n) => {\n cleanOutputDir();\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n\n const files: string[] = listDictionaries(configuration);\n\n const dictionaries = await loadDictionaries(files);\n\n // Build locale dictionaries\n const dictionariesPaths = await buildDictionary(dictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built');\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n\n writeConfiguration(configuration);\n\n appLogger('Configuration written', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAIO;AACP,4BAA+B;AAC/B,8BAAiC;AACjC,4CAAgC;AAChC,wCAA2C;AAC3C,gCAGO;AACP,gCAAmC;AACnC,kCAAiC;AAE1B,MAAM,kBAAkB,OAC7B,oBAAgC,gCAAiB,MAC9C;AACH,4CAAe;AAEf,+BAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AAED,QAAM,YAAkB,8CAAiB,aAAa;AAEtD,QAAM,eAAe,UAAM,0CAAiB,KAAK;AAGjD,QAAM,oBAAoB,UAAM,uDAAgB,YAAY;AAE5D,6CAAY,iBAAiB;AAE7B,oEAA2B;AAE3B,+BAAU,oBAAoB;AAE9B,0DAAyB;AAEzB,+BAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AAED,oDAAmB,aAAa;AAEhC,+BAAU,yBAAyB;AAAA,IACjC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
@@ -28,10 +28,8 @@ const { dictionariesDir } = (0, import_config.getConfiguration)().content;
28
28
  const writeDictionary = async (dictionaries) => {
29
29
  const resultDictionariesPaths = [];
30
30
  for await (const dictionaryContent of dictionaries) {
31
- const contentString = JSON.stringify({
32
- $schema: "https://intlayer.org/schema.json",
33
- ...dictionaryContent
34
- });
31
+ const isDevelopement = process.env.NODE_ENV === "development";
32
+ const contentString = isDevelopement ? JSON.stringify(dictionaryContent, null, 2) : JSON.stringify(dictionaryContent);
35
33
  const key = dictionaryContent.key;
36
34
  const outputFileName = `${key}.json`;
37
35
  const resultFilePath = (0, import_path.resolve)(dictionariesDir, outputFileName);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"sourcesContent":["import { writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n\nconst { dictionariesDir } = getConfiguration().content;\n\nexport const writeDictionary = async (dictionaries: Dictionary[]) => {\n const resultDictionariesPaths: string[] = [];\n\n for await (const dictionaryContent of dictionaries) {\n const contentString = JSON.stringify({\n $schema: 'https://intlayer.org/schema.json',\n ...dictionaryContent,\n });\n\n const key = dictionaryContent.key;\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAC1B,kBAAwB;AACxB,oBAAiC;AAGjC,MAAM,EAAE,gBAAgB,QAAI,gCAAiB,EAAE;AAExC,MAAM,kBAAkB,OAAO,iBAA+B;AACnE,QAAM,0BAAoC,CAAC;AAE3C,mBAAiB,qBAAqB,cAAc;AAClD,UAAM,gBAAgB,KAAK,UAAU;AAAA,MACnC,SAAS;AAAA,MACT,GAAG;AAAA,IACL,CAAC;AAED,UAAM,MAAM,kBAAkB;AAC9B,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,qBAAiB,qBAAQ,iBAAiB,cAAc;AAG9D,cAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,IACxD,CAAC;AAED,4BAAwB,KAAK,cAAc;AAAA,EAC7C;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/writeDictionary.ts"],"sourcesContent":["import { writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n\nconst { dictionariesDir } = getConfiguration().content;\n\nexport const writeDictionary = async (dictionaries: Dictionary[]) => {\n const resultDictionariesPaths: string[] = [];\n\n for await (const dictionaryContent of dictionaries) {\n const isDevelopement = process.env.NODE_ENV === 'development';\n const contentString = isDevelopement\n ? JSON.stringify(dictionaryContent, null, 2)\n : JSON.stringify(dictionaryContent);\n\n const key = dictionaryContent.key;\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAC1B,kBAAwB;AACxB,oBAAiC;AAGjC,MAAM,EAAE,gBAAgB,QAAI,gCAAiB,EAAE;AAExC,MAAM,kBAAkB,OAAO,iBAA+B;AACnE,QAAM,0BAAoC,CAAC;AAE3C,mBAAiB,qBAAqB,cAAc;AAClD,UAAM,iBAAiB,QAAQ,IAAI,aAAa;AAChD,UAAM,gBAAgB,iBAClB,KAAK,UAAU,mBAAmB,MAAM,CAAC,IACzC,KAAK,UAAU,iBAAiB;AAEpC,UAAM,MAAM,kBAAkB;AAC9B,UAAM,iBAAiB,GAAG,GAAG;AAC7B,UAAM,qBAAiB,qBAAQ,iBAAiB,cAAc;AAG9D,cAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,IACxD,CAAC;AAED,4BAAwB,KAAK,cAAc;AAAA,EAC7C;AAEA,SAAO;AACT;","names":[]}
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(createDictionaryEntryPoint_exports);
24
24
  var import_fs = require("fs");
25
25
  var import_path = require("path");
26
26
  var import_config = require("@intlayer/config");
27
- var import_getDictionariesPath = require('../../getDictionariesPath.cjs');
27
+ var import_getBuiltDictionariesPath = require('../../getBuiltDictionariesPath.cjs');
28
28
  var import_utils = require('../../utils.cjs');
29
29
  const { content } = (0, import_config.getConfiguration)();
30
30
  const { mainDir } = content;
@@ -63,7 +63,7 @@ const createDictionaryEntryPoint = () => {
63
63
  if (!(0, import_fs.existsSync)(mainDir)) {
64
64
  (0, import_fs.mkdirSync)(mainDir, { recursive: true });
65
65
  }
66
- const dictionariesPath = (0, import_getDictionariesPath.getDictionariesPath)();
66
+ const dictionariesPath = (0, import_getBuiltDictionariesPath.getBuiltDictionariesPath)();
67
67
  const cjsContent = generateDictionaryListContent(dictionariesPath, "cjs");
68
68
  (0, import_fs.writeFileSync)((0, import_path.resolve)(mainDir, "dictionaries.cjs"), cjsContent);
69
69
  const esmContent = generateDictionaryListContent(dictionariesPath, "esm");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, relative, resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { getDictionariesPath } from '../../getDictionariesPath';\nimport { getFileHash } from '../../utils';\n\nconst { content } = getConfiguration();\nconst { mainDir } = content;\n\n/**\n * This function generates the content of the dictionary list file\n */\nconst generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: relative(mainDir, dictionaryPath),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = () => {\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = getDictionariesPath();\n\n // Create the dictionary list file\n const cjsContent = generateDictionaryListContent(dictionariesPath, 'cjs');\n writeFileSync(resolve(mainDir, 'dictionaries.cjs'), cjsContent);\n\n const esmContent = generateDictionaryListContent(dictionariesPath, 'esm');\n writeFileSync(resolve(mainDir, 'dictionaries.mjs'), esmContent);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,kBAAqD;AACrD,oBAAiC;AACjC,iCAAoC;AACpC,mBAA4B;AAE5B,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,QAAQ,IAAI;AAKpB,MAAM,gCAAgC,CACpC,cACA,SAAwB,UACb;AACX,MAAIA,WAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,kBAAc,sBAAS,SAAS,cAAc;AAAA,IAC9C,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,MAAAA,YAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,MAAAA,YAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,EAAAA,YAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,IAAAA,YAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,IAAAA,YAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAOA;AACT;AAKO,MAAM,6BAA6B,MAAM;AAE9C,MAAI,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,uBAA6B,gDAAoB;AAGvD,QAAM,aAAa,8BAA8B,kBAAkB,KAAK;AACxE,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAE9D,QAAM,aAAa,8BAA8B,kBAAkB,KAAK;AACxE,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAChE;","names":["content"]}
1
+ {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryEntryPoint.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, relative, resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { getBuiltDictionariesPath } from '../../getBuiltDictionariesPath';\nimport { getFileHash } from '../../utils';\n\nconst { content } = getConfiguration();\nconst { mainDir } = content;\n\n/**\n * This function generates the content of the dictionary list file\n */\nconst generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: relative(mainDir, dictionaryPath),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = () => {\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = getBuiltDictionariesPath();\n\n // Create the dictionary list file\n const cjsContent = generateDictionaryListContent(dictionariesPath, 'cjs');\n writeFileSync(resolve(mainDir, 'dictionaries.cjs'), cjsContent);\n\n const esmContent = generateDictionaryListContent(dictionariesPath, 'esm');\n writeFileSync(resolve(mainDir, 'dictionaries.mjs'), esmContent);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;A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GAAG,UAAU;AAChE;","names":["content"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var dictionaryStatus_exports = {};
16
+ module.exports = __toCommonJS(dictionaryStatus_exports);
17
+ //# sourceMappingURL=dictionaryStatus.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/writeContentDeclaration/dictionaryStatus.ts"],"sourcesContent":["export type DictionaryStatus =\n | 'pending'\n | 'fetching'\n | 'up-to-date'\n | 'replaced'\n | 'updated'\n | 'fetched'\n | 'unknown'\n | 'error'\n | 'imported'\n | 'reimported in JSON'\n | 'reimported in new location';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var writeContentDeclaration_exports = {};
17
+ module.exports = __toCommonJS(writeContentDeclaration_exports);
18
+ __reExport(writeContentDeclaration_exports, require('./writeContentDeclaration.cjs'), module.exports);
19
+ __reExport(writeContentDeclaration_exports, require('./dictionaryStatus.cjs'), module.exports);
20
+ // Annotate the CommonJS export names for ESM import in node:
21
+ 0 && (module.exports = {
22
+ ...require('./writeContentDeclaration.cjs'),
23
+ ...require('./dictionaryStatus.cjs')
24
+ });
25
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/writeContentDeclaration/index.ts"],"sourcesContent":["export * from './writeContentDeclaration';\nexport * from './dictionaryStatus';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4CAAc,sCAAd;AACA,4CAAc,+BADd;","names":[]}