@intlayer/chokidar 8.4.3 → 8.4.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 (497) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/cjs/_virtual/_utils_asset.cjs +98 -0
  3. package/dist/cjs/build.cjs +58 -1
  4. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +62 -1
  5. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  6. package/dist/cjs/buildIntlayerDictionary/index.cjs +6 -1
  7. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +26 -1
  8. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  9. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +107 -4
  10. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  11. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +81 -5
  12. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  13. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +46 -1
  14. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  15. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +50 -1
  16. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  17. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +59 -1
  18. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  19. package/dist/cjs/cleanOutputDir.cjs +30 -1
  20. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  21. package/dist/cjs/cleanRemovedContentDeclaration.cjs +97 -1
  22. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  23. package/dist/cjs/cli.cjs +35 -1
  24. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +70 -1
  25. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  26. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +42 -7
  27. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  28. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +23 -1
  29. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  30. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +24 -1
  31. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  32. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +24 -1
  33. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  34. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +23 -1
  35. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  36. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +23 -1
  37. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  38. package/dist/cjs/createDictionaryEntryPoint/index.cjs +16 -1
  39. package/dist/cjs/createType/createModuleAugmentation.cjs +112 -9
  40. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  41. package/dist/cjs/createType/createType.cjs +29 -1
  42. package/dist/cjs/createType/createType.cjs.map +1 -1
  43. package/dist/cjs/createType/index.cjs +8 -1
  44. package/dist/cjs/detectFormatCommand.cjs +32 -1
  45. package/dist/cjs/detectFormatCommand.cjs.map +1 -1
  46. package/dist/cjs/fetchDistantDictionaries.cjs +51 -1
  47. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  48. package/dist/cjs/filterInvalidDictionaries.cjs +52 -1
  49. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  50. package/dist/cjs/formatDictionary.cjs +49 -1
  51. package/dist/cjs/formatDictionary.cjs.map +1 -1
  52. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +61 -7
  53. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  54. package/dist/cjs/getContentDeclarationFileTemplate/index.cjs +4 -1
  55. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +34 -1
  56. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  57. package/dist/cjs/handleContentDeclarationFileChange.cjs +49 -1
  58. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  59. package/dist/cjs/handleContentDeclarationFileMoved.cjs +24 -1
  60. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
  61. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +37 -1
  62. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  63. package/dist/cjs/init/index.cjs +284 -1
  64. package/dist/cjs/init/index.cjs.map +1 -1
  65. package/dist/cjs/init/utils/configManipulation.cjs +111 -1
  66. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  67. package/dist/cjs/init/utils/fileSystem.cjs +39 -1
  68. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  69. package/dist/cjs/init/utils/index.cjs +14 -1
  70. package/dist/cjs/init/utils/jsonParser.cjs +42 -3
  71. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
  72. package/dist/cjs/init/utils/tsConfig.cjs +18 -1
  73. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
  74. package/dist/cjs/initConfig/index.cjs +39 -1
  75. package/dist/cjs/initConfig/index.cjs.map +1 -1
  76. package/dist/cjs/installMCP/installMCP.cjs +50 -1
  77. package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
  78. package/dist/cjs/installSkills/index.cjs +303 -1
  79. package/dist/cjs/installSkills/index.cjs.map +1 -1
  80. package/dist/cjs/listDictionariesPath.cjs +42 -1
  81. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  82. package/dist/cjs/listGitFiles.cjs +105 -5
  83. package/dist/cjs/listGitFiles.cjs.map +1 -1
  84. package/dist/cjs/listProjects.cjs +47 -1
  85. package/dist/cjs/listProjects.cjs.map +1 -1
  86. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +68 -1
  87. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
  88. package/dist/cjs/loadDictionaries/index.cjs +14 -1
  89. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +93 -2
  90. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  91. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +127 -1
  92. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  93. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +27 -1
  94. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  95. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +61 -1
  96. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  97. package/dist/cjs/loadDictionaries/log.cjs +138 -3
  98. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  99. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs +63 -2
  100. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  101. package/dist/cjs/logConfigDetails.cjs +39 -2
  102. package/dist/cjs/logConfigDetails.cjs.map +1 -1
  103. package/dist/cjs/prepareIntlayer.cjs +103 -1
  104. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  105. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +30 -1
  106. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  107. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +12 -1
  108. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  109. package/dist/cjs/utils/autoDecorateContent.cjs +89 -1
  110. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
  111. package/dist/cjs/utils/buildComponentFilesList.cjs +67 -1
  112. package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -1
  113. package/dist/cjs/utils/buildFilesList.cjs +83 -1
  114. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  115. package/dist/cjs/utils/chunkJSON.cjs +336 -1
  116. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  117. package/dist/cjs/utils/formatter.cjs +18 -1
  118. package/dist/cjs/utils/formatter.cjs.map +1 -1
  119. package/dist/cjs/utils/getChunk.cjs +34 -1
  120. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  121. package/dist/cjs/utils/getContentExtension.cjs +29 -1
  122. package/dist/cjs/utils/getContentExtension.cjs.map +1 -1
  123. package/dist/cjs/utils/getFormatFromExtension.cjs +34 -1
  124. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  125. package/dist/cjs/utils/getPathHash.cjs +10 -1
  126. package/dist/cjs/utils/getPathHash.cjs.map +1 -1
  127. package/dist/cjs/utils/index.cjs +49 -1
  128. package/dist/cjs/utils/mergeChunks.cjs +28 -1
  129. package/dist/cjs/utils/mergeChunks.cjs.map +1 -1
  130. package/dist/cjs/utils/pLimit.cjs +128 -1
  131. package/dist/cjs/utils/pLimit.cjs.map +1 -1
  132. package/dist/cjs/utils/parallelize.cjs +11 -1
  133. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  134. package/dist/cjs/utils/parallelizeGlobal.cjs +29 -1
  135. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
  136. package/dist/cjs/utils/reduceObjectFormat.cjs +31 -1
  137. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
  138. package/dist/cjs/utils/resolveObjectPromises.cjs +21 -1
  139. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  140. package/dist/cjs/utils/resolveRelativePath.cjs +21 -1
  141. package/dist/cjs/utils/resolveRelativePath.cjs.map +1 -1
  142. package/dist/cjs/utils/runOnce.cjs +95 -1
  143. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  144. package/dist/cjs/utils/runParallel/bin.cjs +54 -1
  145. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
  146. package/dist/cjs/utils/runParallel/bootstrap.cjs +24 -1
  147. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
  148. package/dist/cjs/utils/runParallel/index.cjs +115 -1
  149. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  150. package/dist/cjs/utils/runParallel/pidTree.cjs +145 -1
  151. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  152. package/dist/cjs/utils/runParallel/ps.cjs +49 -1
  153. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  154. package/dist/cjs/utils/runParallel/runTask.cjs +154 -1
  155. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  156. package/dist/cjs/utils/runParallel/spawnPosix.cjs +59 -1
  157. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
  158. package/dist/cjs/utils/runParallel/spawnWin32.cjs +43 -1
  159. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
  160. package/dist/cjs/utils/runParallel/wmic.cjs +52 -1
  161. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  162. package/dist/cjs/utils/sortAlphabetically.cjs +7 -1
  163. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  164. package/dist/cjs/utils/splitTextByLine.cjs +11 -1
  165. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
  166. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +60 -1
  167. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
  168. package/dist/cjs/watcher.cjs +120 -1
  169. package/dist/cjs/watcher.cjs.map +1 -1
  170. package/dist/cjs/writeConfiguration/index.cjs +42 -1
  171. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  172. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +28 -1
  173. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  174. package/dist/cjs/writeContentDeclaration/index.cjs +10 -1
  175. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +94 -1
  176. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  177. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +412 -3
  178. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  179. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +127 -2
  180. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
  181. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +148 -1
  182. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  183. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +92 -1
  184. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  185. package/dist/cjs/writeFileIfChanged.cjs +50 -1
  186. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  187. package/dist/cjs/writeJsonIfChanged.cjs +17 -1
  188. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  189. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  190. package/dist/esm/_virtual/_utils_asset.mjs +97 -0
  191. package/dist/esm/build.mjs +25 -1
  192. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +60 -1
  193. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  194. package/dist/esm/buildIntlayerDictionary/index.mjs +4 -1
  195. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +24 -1
  196. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
  197. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +102 -4
  198. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  199. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +77 -5
  200. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  201. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +44 -1
  202. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  203. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +48 -1
  204. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  205. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +56 -1
  206. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  207. package/dist/esm/cleanOutputDir.mjs +28 -1
  208. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  209. package/dist/esm/cleanRemovedContentDeclaration.mjs +94 -1
  210. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
  211. package/dist/esm/cli.mjs +15 -1
  212. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +68 -1
  213. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  214. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +40 -7
  215. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
  216. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +20 -1
  217. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  218. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +21 -1
  219. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  220. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +21 -1
  221. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  222. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +20 -1
  223. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  224. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +20 -1
  225. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  226. package/dist/esm/createDictionaryEntryPoint/index.mjs +9 -1
  227. package/dist/esm/createType/createModuleAugmentation.mjs +108 -9
  228. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  229. package/dist/esm/createType/createType.mjs +26 -1
  230. package/dist/esm/createType/createType.mjs.map +1 -1
  231. package/dist/esm/createType/index.mjs +4 -1
  232. package/dist/esm/detectFormatCommand.mjs +30 -1
  233. package/dist/esm/detectFormatCommand.mjs.map +1 -1
  234. package/dist/esm/fetchDistantDictionaries.mjs +49 -1
  235. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  236. package/dist/esm/filterInvalidDictionaries.mjs +48 -1
  237. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
  238. package/dist/esm/formatDictionary.mjs +44 -1
  239. package/dist/esm/formatDictionary.mjs.map +1 -1
  240. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +59 -7
  241. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  242. package/dist/esm/getContentDeclarationFileTemplate/index.mjs +3 -1
  243. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +32 -1
  244. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  245. package/dist/esm/handleContentDeclarationFileChange.mjs +47 -1
  246. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  247. package/dist/esm/handleContentDeclarationFileMoved.mjs +22 -1
  248. package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
  249. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +35 -1
  250. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  251. package/dist/esm/init/index.mjs +281 -1
  252. package/dist/esm/init/index.mjs.map +1 -1
  253. package/dist/esm/init/utils/configManipulation.mjs +108 -1
  254. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  255. package/dist/esm/init/utils/fileSystem.mjs +34 -1
  256. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  257. package/dist/esm/init/utils/index.mjs +6 -1
  258. package/dist/esm/init/utils/jsonParser.mjs +40 -3
  259. package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
  260. package/dist/esm/init/utils/tsConfig.mjs +16 -1
  261. package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
  262. package/dist/esm/initConfig/index.mjs +37 -1
  263. package/dist/esm/initConfig/index.mjs.map +1 -1
  264. package/dist/esm/installMCP/installMCP.mjs +46 -1
  265. package/dist/esm/installMCP/installMCP.mjs.map +1 -1
  266. package/dist/esm/installSkills/index.mjs +295 -1
  267. package/dist/esm/installSkills/index.mjs.map +1 -1
  268. package/dist/esm/listDictionariesPath.mjs +38 -1
  269. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  270. package/dist/esm/listGitFiles.mjs +100 -5
  271. package/dist/esm/listGitFiles.mjs.map +1 -1
  272. package/dist/esm/listProjects.mjs +43 -1
  273. package/dist/esm/listProjects.mjs.map +1 -1
  274. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +67 -1
  275. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
  276. package/dist/esm/loadDictionaries/index.mjs +6 -1
  277. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +88 -2
  278. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  279. package/dist/esm/loadDictionaries/loadDictionaries.mjs +124 -1
  280. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  281. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +25 -1
  282. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  283. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +58 -1
  284. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  285. package/dist/esm/loadDictionaries/log.mjs +134 -3
  286. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  287. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs +61 -2
  288. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
  289. package/dist/esm/logConfigDetails.mjs +36 -2
  290. package/dist/esm/logConfigDetails.mjs.map +1 -1
  291. package/dist/esm/prepareIntlayer.mjs +99 -1
  292. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  293. package/dist/esm/reduceDictionaryContent/applyMask.mjs +28 -1
  294. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  295. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +10 -1
  296. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  297. package/dist/esm/utils/autoDecorateContent.mjs +86 -1
  298. package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
  299. package/dist/esm/utils/buildComponentFilesList.mjs +64 -1
  300. package/dist/esm/utils/buildComponentFilesList.mjs.map +1 -1
  301. package/dist/esm/utils/buildFilesList.mjs +79 -1
  302. package/dist/esm/utils/buildFilesList.mjs.map +1 -1
  303. package/dist/esm/utils/chunkJSON.mjs +333 -1
  304. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  305. package/dist/esm/utils/formatter.mjs +13 -1
  306. package/dist/esm/utils/formatter.mjs.map +1 -1
  307. package/dist/esm/utils/getChunk.mjs +33 -1
  308. package/dist/esm/utils/getChunk.mjs.map +1 -1
  309. package/dist/esm/utils/getContentExtension.mjs +27 -1
  310. package/dist/esm/utils/getContentExtension.mjs.map +1 -1
  311. package/dist/esm/utils/getFormatFromExtension.mjs +31 -1
  312. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  313. package/dist/esm/utils/getPathHash.mjs +7 -1
  314. package/dist/esm/utils/getPathHash.mjs.map +1 -1
  315. package/dist/esm/utils/index.mjs +22 -1
  316. package/dist/esm/utils/mergeChunks.mjs +26 -1
  317. package/dist/esm/utils/mergeChunks.mjs.map +1 -1
  318. package/dist/esm/utils/pLimit.mjs +125 -1
  319. package/dist/esm/utils/pLimit.mjs.map +1 -1
  320. package/dist/esm/utils/parallelize.mjs +10 -1
  321. package/dist/esm/utils/parallelize.mjs.map +1 -1
  322. package/dist/esm/utils/parallelizeGlobal.mjs +26 -1
  323. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
  324. package/dist/esm/utils/reduceObjectFormat.mjs +29 -1
  325. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
  326. package/dist/esm/utils/resolveObjectPromises.mjs +19 -1
  327. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
  328. package/dist/esm/utils/resolveRelativePath.mjs +19 -1
  329. package/dist/esm/utils/resolveRelativePath.mjs.map +1 -1
  330. package/dist/esm/utils/runOnce.mjs +92 -1
  331. package/dist/esm/utils/runOnce.mjs.map +1 -1
  332. package/dist/esm/utils/runParallel/bin.mjs +52 -1
  333. package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
  334. package/dist/esm/utils/runParallel/bootstrap.mjs +22 -1
  335. package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
  336. package/dist/esm/utils/runParallel/index.mjs +113 -1
  337. package/dist/esm/utils/runParallel/index.mjs.map +1 -1
  338. package/dist/esm/utils/runParallel/pidTree.mjs +142 -1
  339. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  340. package/dist/esm/utils/runParallel/ps.mjs +46 -1
  341. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  342. package/dist/esm/utils/runParallel/runTask.mjs +152 -1
  343. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
  344. package/dist/esm/utils/runParallel/spawnPosix.mjs +57 -1
  345. package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
  346. package/dist/esm/utils/runParallel/spawnWin32.mjs +41 -1
  347. package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
  348. package/dist/esm/utils/runParallel/wmic.mjs +49 -1
  349. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  350. package/dist/esm/utils/sortAlphabetically.mjs +5 -1
  351. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
  352. package/dist/esm/utils/splitTextByLine.mjs +9 -1
  353. package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
  354. package/dist/esm/utils/verifyIdenticObjectFormat.mjs +58 -1
  355. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
  356. package/dist/esm/watcher.mjs +117 -1
  357. package/dist/esm/watcher.mjs.map +1 -1
  358. package/dist/esm/writeConfiguration/index.mjs +39 -1
  359. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  360. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +26 -1
  361. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  362. package/dist/esm/writeContentDeclaration/index.mjs +6 -1
  363. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +91 -1
  364. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
  365. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +407 -3
  366. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  367. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +124 -2
  368. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
  369. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +146 -1
  370. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  371. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +90 -1
  372. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  373. package/dist/esm/writeFileIfChanged.mjs +48 -1
  374. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  375. package/dist/esm/writeJsonIfChanged.mjs +16 -1
  376. package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
  377. package/dist/types/build.d.ts +20 -20
  378. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +25 -2
  379. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -0
  380. package/dist/types/buildIntlayerDictionary/index.d.ts +2 -2
  381. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +11 -2
  382. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -0
  383. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +49 -2
  384. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -0
  385. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +7 -7
  386. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  387. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +30 -2
  388. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -0
  389. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +34 -2
  390. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -0
  391. package/dist/types/cli.d.ts +6 -6
  392. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +14 -2
  393. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -0
  394. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +10 -2
  395. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -0
  396. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +10 -2
  397. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -0
  398. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +10 -2
  399. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -0
  400. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +10 -2
  401. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -0
  402. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +10 -2
  403. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -0
  404. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +10 -2
  405. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -0
  406. package/dist/types/createDictionaryEntryPoint/index.d.ts +7 -7
  407. package/dist/types/createType/createModuleAugmentation.d.ts +9 -2
  408. package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -0
  409. package/dist/types/createType/createType.d.ts +12 -2
  410. package/dist/types/createType/createType.d.ts.map +1 -0
  411. package/dist/types/createType/index.d.ts +2 -2
  412. package/dist/types/fetchDistantDictionaries.d.ts +1 -1
  413. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  414. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +7 -2
  415. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -0
  416. package/dist/types/getContentDeclarationFileTemplate/index.d.ts +1 -1
  417. package/dist/types/loadDictionaries/index.d.ts +4 -4
  418. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +12 -2
  419. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -0
  420. package/dist/types/loadDictionaries/loadDictionaries.d.ts +23 -2
  421. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -0
  422. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +8 -2
  423. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -0
  424. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +15 -2
  425. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -0
  426. package/dist/types/loadDictionaries/log.d.ts +1 -1
  427. package/dist/types/utils/getFormatFromExtension.d.ts +8 -2
  428. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -0
  429. package/dist/types/utils/index.d.ts +1 -1
  430. package/dist/types/writeConfiguration/index.d.ts.map +1 -1
  431. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +12 -2
  432. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -0
  433. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +5 -2
  434. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -0
  435. package/dist/types/writeContentDeclaration/index.d.ts +5 -5
  436. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
  437. package/dist/types/writeContentDeclaration/transformJSFile.d.ts +11 -2
  438. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -0
  439. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +19 -2
  440. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -0
  441. package/dist/types/writeContentDeclaration/writeJSFile.d.ts +14 -2
  442. package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -0
  443. package/package.json +8 -8
  444. package/dist/cjs/_utils_asset-SJVy1xMD.cjs +0 -2
  445. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  446. package/dist/esm/_utils_asset-4w8dPH9r.mjs +0 -2
  447. package/dist/esm/chunk-DDgYwkfe.mjs +0 -1
  448. package/dist/types/buildIntlayerDictionary-_xrGjSmw.d.ts +0 -25
  449. package/dist/types/buildIntlayerDictionary-_xrGjSmw.d.ts.map +0 -1
  450. package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts +0 -14
  451. package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts.map +0 -1
  452. package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts +0 -9
  453. package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts.map +0 -1
  454. package/dist/types/createType--rDwdg2t.d.ts +0 -12
  455. package/dist/types/createType--rDwdg2t.d.ts.map +0 -1
  456. package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts +0 -12
  457. package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts.map +0 -1
  458. package/dist/types/dictionaryStatus-DPVO37qe.d.ts +0 -5
  459. package/dist/types/dictionaryStatus-DPVO37qe.d.ts.map +0 -1
  460. package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts +0 -10
  461. package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts.map +0 -1
  462. package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts +0 -10
  463. package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts.map +0 -1
  464. package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts +0 -10
  465. package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts.map +0 -1
  466. package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts +0 -10
  467. package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts.map +0 -1
  468. package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts +0 -10
  469. package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts.map +0 -1
  470. package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts +0 -10
  471. package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts.map +0 -1
  472. package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts +0 -7
  473. package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts.map +0 -1
  474. package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts +0 -8
  475. package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts.map +0 -1
  476. package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts +0 -12
  477. package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts.map +0 -1
  478. package/dist/types/loadDictionaries-BIqHwtYE.d.ts +0 -23
  479. package/dist/types/loadDictionaries-BIqHwtYE.d.ts.map +0 -1
  480. package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts +0 -8
  481. package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts.map +0 -1
  482. package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts +0 -15
  483. package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts.map +0 -1
  484. package/dist/types/processContentDeclaration-CAvrHaIT.d.ts +0 -11
  485. package/dist/types/processContentDeclaration-CAvrHaIT.d.ts.map +0 -1
  486. package/dist/types/transformJSFile-Cg0LkeLb.d.ts +0 -11
  487. package/dist/types/transformJSFile-Cg0LkeLb.d.ts.map +0 -1
  488. package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts +0 -19
  489. package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts.map +0 -1
  490. package/dist/types/writeDynamicDictionary-DO8f3FYl.d.ts +0 -48
  491. package/dist/types/writeDynamicDictionary-DO8f3FYl.d.ts.map +0 -1
  492. package/dist/types/writeJSFile-kK95jzg_.d.ts +0 -14
  493. package/dist/types/writeJSFile-kK95jzg_.d.ts.map +0 -1
  494. package/dist/types/writeMergedDictionary-CMeghcRI.d.ts +0 -30
  495. package/dist/types/writeMergedDictionary-CMeghcRI.d.ts.map +0 -1
  496. package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts +0 -34
  497. package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport {\n buildEntryPointContent,\n type LocalizedDictionaryOutput,\n type LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\nconst DICTIONARIES_SUBDIR = 'json'; // Necessary to add a static first dir for Turbopack\nconst LOAD_CONTENT_MODULE = 'utils/loadContent';\n\n/**\n * Generates the content of the shared `_loadContent` module for fetch dictionaries,\n * written once per output directory. liveSyncURL and relativePrefix are baked in\n * as string literals since they are config-level constants for the whole build.\n */\nexport const generateFetchLoadContentModule = (\n format: 'cjs' | 'esm',\n liveSyncURL: string,\n relativePrefix: string\n): string => {\n if (format === 'esm') {\n return (\n `export const loadContent = async (key, locale) => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`${liveSyncURL}/dictionaries/\\${key}/\\${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch (_error) {\\n` +\n ` const m = await import(\\`${relativePrefix}/${DICTIONARIES_SUBDIR}/\\${key}_\\${locale}.json\\`, { with: { type: 'json' } });\\n` +\n ` return m.default || m;\\n` +\n ` }\\n` +\n `};\\n`\n );\n }\n return (\n `const loadContent = async (key, locale) => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`${liveSyncURL}/dictionaries/\\${key}/\\${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch (_error) {\\n` +\n ` return Promise.resolve(require(\\`${relativePrefix}/dictionaries/\\${locale}_\\${key}.json\\`));\\n` +\n ` }\\n` +\n `};\\n` +\n `module.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a fetch dictionary entry point file.\n * `loadContent` is imported from the shared `_loadContent` module.\n */\nexport const generateDictionaryEntryPoint = (\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const preamble =\n format === 'esm'\n ? `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n`\n : `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n`;\n\n return buildEntryPointContent(\n preamble,\n localizedDictionariesPathsRecord,\n key,\n format\n );\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { liveSyncURL } = configuration.editor;\n\n // Compute relative path from the utils/ subdir (where loadContent lives) to dynamic dir\n let relativePrefix = normalizePath(\n relative(resolve(fetchDictionariesDir, 'utils'), dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n // Write the shared loadContent module once per format\n const utilsDir = resolve(fetchDictionariesDir, 'utils');\n await mkdir(utilsDir, { recursive: true });\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateFetchLoadContentModule(format, liveSyncURL, relativePrefix)\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(\n Object.entries(dynamicDictionaries),\n async ([key, localizedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localizedDictionariesPathsRecord,\n key,\n format\n );\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"ocAcA,MACM,EAAsB,oBAOf,GACX,EACA,EACA,IAEI,IAAW,MAEX;;gCAEiC,EAAY,yHAGb,EAAe,sGAOjD;;gCAEiC,EAAY,iIAGL,EAAe,0FAW9C,GACX,EACA,EACA,EAAwB,QACb,CACX,IAAM,EAAY,IAAW,MAAQ,MAAQ,MAM7C,OAAO,EAJL,IAAW,MACP,kCAAkC,EAAoB,GAAG,EAAU,QACnE,sCAAsC,EAAoB,GAAG,EAAU,SAI3E,EACA,EACA,EACD,EAmBU,EAAuB,MAClC,EACA,EACA,EAA6B,IACU,CACvC,GAAM,CAAE,uBAAsB,0BAA2B,EAAc,OACjE,CAAE,eAAgB,EAAc,OAGlC,EAAiB,EACnB,EAAS,EAAQ,EAAsB,QAAQ,CAAE,EAAuB,CACzE,CAqDD,OApDK,EAAe,WAAW,IAAI,GACjC,EAAiB,KAAK,KAIxB,MAAM,EAAM,EAAQ,EAAqB,CAAE,CAAE,UAAW,GAAM,CAAC,CAI/D,MAAM,EADW,EAAQ,EAAsB,QAAQ,CACjC,CAAE,UAAW,GAAM,CAAC,CAC1C,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MAC7C,MAAM,EACJ,EAAQ,EAAsB,GAAG,EAAoB,GAAG,IAAY,CACpE,EAA+B,EAAQ,EAAa,EAAe,CACpE,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,wBAAwB,EAAa,EAAQ,EAAsB,GAAG,EAAoB,GAAG,IAAY,CAAC,CAAC,GAC3G,EACD,EACD,EACF,CAKF,MAAM,EACJ,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAsC,CAC7C,IAAQ,aAEZ,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EACd,EACA,EACA,EACD,CAED,MAAM,EACJ,EAAQ,EAAsB,GAAG,EAAI,GAAG,IAAY,CACpD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,wBAAwB,EAAa,EAAQ,EAAsB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC3F,EACD,EACD,EACF,EAEL,CA3B0D,EAAE"}
1
+ {"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type { LocalizedDictionaryOutput } from './writeDynamicDictionary';\n\nconst LOAD_CONTENT_MODULE = '_loadjson';\n\n/**\n * Generates the content of the shared `loadContent` module for fetch dictionaries.\n * - `configuration` is imported at runtime from \"intlayer\" (liveSyncURL not baked in).\n * - Fallback delegates to the dynamic dictionary's `_loadjson` module.\n * - Locales are baked in so each entry is a static function referencing one locale.\n */\nexport const generateFetchLoadContentModule = (\n format: 'cjs' | 'esm',\n relativePrefix: string,\n locales: string[]\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const localeEntries = sortedLocales\n .map(\n (locale) =>\n ` '${locale}': async () => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`\\${configuration.editor.liveSyncURL}/dictionaries/\\${key}/${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch {\\n` +\n ` return dynContent['${locale}']();\\n` +\n ` }\\n` +\n ` }`\n )\n .join(',\\n');\n\n const body =\n `const loadContent = (key) => {\\n` +\n ` const dynContent = loadContentDyn(key);\\n` +\n ` return {\\n${localeEntries}\\n };\\n` +\n `};\\n`;\n\n if (format === 'esm') {\n return (\n `import { configuration } from 'intlayer';\\n` +\n `import { loadContent as loadContentDyn } from '${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `${body}\\nexport { loadContent };\\n`\n );\n }\n return (\n `const { configuration } = require('intlayer');\\n` +\n `const { loadContent: loadContentDyn } = require('${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `${body}\\nmodule.exports = { loadContent };\\n`\n );\n};\n\n/**\n * Generates the content of a fetch dictionary entry point file.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n if (format === 'esm') {\n return (\n `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\\n\\n` +\n `const content = loadContent('${key}');\\n\\n` +\n `export default content;\\n`\n );\n }\n return (\n `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\\n\\n` +\n `module.exports = loadContent('${key}');\\n`\n );\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { locales } = configuration.internationalization;\n\n // Compute relative path from fetch dir (where _loadjson lives) to dynamic dir\n let relativePrefix = normalizePath(\n relative(fetchDictionariesDir, dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n // Write the shared loadContent module once per format\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateFetchLoadContentModule(format, relativePrefix, locales)\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(Object.entries(dynamicDictionaries), async ([key]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(key, format);\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n });\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;AAUA,MAAM,sBAAsB;;;;;;;AAQ5B,MAAa,kCACX,QACA,gBACA,YACW;CACX,MAAM,gBAAgB,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,MAC1C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC;CACD,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAgB7C,MAAM,OACJ;;cAfoB,cACnB,KACE,WACC,MAAM,OAAO,yHAEgF,OAAO,gFAGxE,OAAO,mBAGtC,CACA,KAAK,MAAM,CAKiB;AAG/B,KAAI,WAAW,MACb,QACE,6FACkD,eAAe,GAAG,oBAAoB,GAAG,UAAU,QAClG,KAAK;AAGZ,QACE,oGACoD,eAAe,GAAG,oBAAoB,GAAG,UAAU,SACpG,KAAK;;;;;AAOZ,MAAa,gCACX,KACA,SAAwB,UACb;CACX,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,KAAI,WAAW,MACb,QACE,kCAAkC,oBAAoB,GAAG,UAAU,qCACnC,IAAI;AAIxC,QACE,sCAAsC,oBAAoB,GAAG,UAAU,uCACtC,IAAI;;;;;;;;;;;;;;;;;;AAoBzC,MAAa,uBAAuB,OAClC,qBACA,eACA,UAA6B,kBACU;CACvC,MAAM,EAAE,sBAAsB,2BAA2B,cAAc;CACvE,MAAM,EAAE,YAAY,cAAc;CAGlC,IAAI,iBAAiB,cACnB,SAAS,sBAAsB,uBAAuB,CACvD;AACD,KAAI,CAAC,eAAe,WAAW,IAAI,CACjC,kBAAiB,KAAK;AAGxB,OAAM,MAAM,QAAQ,qBAAqB,EAAE,EAAE,WAAW,MAAM,CAAC;AAG/D,OAAM,YAAY,SAAS,OAAO,WAAW;EAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,QAAM,mBACJ,QAAQ,sBAAsB,GAAG,oBAAoB,GAAG,YAAY,EACpE,+BAA+B,QAAQ,gBAAgB,QAAQ,CAChE,CAAC,OAAO,QAAQ;AACf,WAAQ,MACN,wBAAwB,aAAa,QAAQ,sBAAsB,GAAG,oBAAoB,GAAG,YAAY,CAAC,CAAC,IAC3G,IACD;IACD;GACF;CAEF,MAAM,0BAAqD,EAAE;AAG7D,OAAM,YAAY,OAAO,QAAQ,oBAAoB,EAAE,OAAO,CAAC,SAAS;AACtE,MAAI,QAAQ,YAAa;AAEzB,QAAM,YAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BAA6B,KAAK,OAAO;AAEzD,SAAM,mBACJ,QAAQ,sBAAsB,GAAG,IAAI,GAAG,YAAY,EACpD,QACD,CAAC,OAAO,QAAQ;AACf,YAAQ,MACN,wBAAwB,aAAa,QAAQ,sBAAsB,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,IAC3F,IACD;KACD;IACF;GACF;AAEF,QAAO"}
@@ -1,2 +1,45 @@
1
- import{parallelize as e}from"../utils/parallelize.mjs";import{writeJsonIfChanged as t}from"../writeJsonIfChanged.mjs";import{mkdir as n}from"node:fs/promises";import{resolve as r}from"node:path";import{colorizePath as i}from"@intlayer/config/logger";import{mergeDictionaries as a,normalizeDictionaries as o}from"@intlayer/core/dictionaryManipulator";const s=async(s,c)=>{let{dictionariesDir:l}=c.system;await n(r(l),{recursive:!0});let u=await e(Object.entries(s),async([e,n])=>{if(e===`undefined`)return;let s=a(o(n.dictionaries,c)),u=r(l,`${e}.json`);return await t(u,s).catch(e=>{console.error(`Error creating merged ${i(u)}:`,e)}),[e,{dictionaryPath:u,dictionary:s}]});return Object.fromEntries(u.filter(Boolean))};export{s as writeMergedDictionaries};
1
+ import { parallelize } from "../utils/parallelize.mjs";
2
+ import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
3
+ import { mkdir } from "node:fs/promises";
4
+ import { resolve } from "node:path";
5
+ import { colorizePath } from "@intlayer/config/logger";
6
+ import { mergeDictionaries, normalizeDictionaries } from "@intlayer/core/dictionaryManipulator";
7
+
8
+ //#region src/buildIntlayerDictionary/writeMergedDictionary.ts
9
+ /**
10
+ * Write the merged dictionaries to the dictionariesDir
11
+ * @param groupedDictionaries - The grouped dictionaries
12
+ * @param configuration - The configuration
13
+ * @returns The merged dictionaries
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
18
+ * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
19
+ * console.log(finalDictionaries);
20
+ *
21
+ * // .intlayer/dictionary/home.json
22
+ * // { key: 'home', content: { ... } },
23
+ * ```
24
+ */
25
+ const writeMergedDictionaries = async (groupedDictionaries, configuration) => {
26
+ const { dictionariesDir } = configuration.system;
27
+ await mkdir(resolve(dictionariesDir), { recursive: true });
28
+ const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionariesEntry]) => {
29
+ if (key === "undefined") return;
30
+ const mergedDictionary = mergeDictionaries(normalizeDictionaries(dictionariesEntry.dictionaries, configuration));
31
+ const resultFilePath = resolve(dictionariesDir, `${key}.json`);
32
+ await writeJsonIfChanged(resultFilePath, mergedDictionary).catch((err) => {
33
+ console.error(`Error creating merged ${colorizePath(resultFilePath)}:`, err);
34
+ });
35
+ return [key, {
36
+ dictionaryPath: resultFilePath,
37
+ dictionary: mergedDictionary
38
+ }];
39
+ });
40
+ return Object.fromEntries(results.filter(Boolean));
41
+ };
42
+
43
+ //#endregion
44
+ export { writeMergedDictionaries };
2
45
  //# sourceMappingURL=writeMergedDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeMergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport {\n mergeDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration: IntlayerConfig\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":"8VAoCA,MAAa,EAA0B,MACrC,EACA,IACoC,CACpC,GAAM,CAAE,mBAAoB,EAAc,OAG1C,MAAM,EAAM,EAAQ,EAAgB,CAAE,CAAE,UAAW,GAAM,CAAC,CAE1D,IAAM,EAAU,MAAM,EACpB,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAuB,CAClC,GAAI,IAAQ,YACV,OAWF,IAAM,EAAmB,EALM,EAC7B,EAAkB,aAClB,EACD,CAEiE,CAG5D,EAAiB,EAAQ,EADR,GAAG,EAAI,OACiC,CAY/D,OATA,MAAM,EAAmB,EAAgB,EAAiB,CAAC,MACxD,GAAQ,CACP,QAAQ,MACN,yBAAyB,EAAa,EAAe,CAAC,GACtD,EACD,EAEJ,CAEM,CACL,EACA,CACE,eAAgB,EAChB,WAAY,EACb,CACF,EAEJ,CAED,OAAO,OAAO,YACZ,EAAQ,OAAO,QAAQ,CACxB"}
1
+ {"version":3,"file":"writeMergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport {\n mergeDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration: IntlayerConfig\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,0BAA0B,OACrC,qBACA,kBACoC;CACpC,MAAM,EAAE,oBAAoB,cAAc;AAG1C,OAAM,MAAM,QAAQ,gBAAgB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE1D,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,uBAAuB;AAClC,MAAI,QAAQ,YACV;EAWF,MAAM,mBAAmB,kBALM,sBAC7B,kBAAkB,cAClB,cACD,CAEiE;EAGlE,MAAM,iBAAiB,QAAQ,iBADR,GAAG,IAAI,OACiC;AAG/D,QAAM,mBAAmB,gBAAgB,iBAAiB,CAAC,OACxD,QAAQ;AACP,WAAQ,MACN,yBAAyB,aAAa,eAAe,CAAC,IACtD,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB,YAAY;GACb,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CACxB"}
@@ -1,2 +1,49 @@
1
- import{parallelize as e}from"../utils/parallelize.mjs";import{writeJsonIfChanged as t}from"../writeJsonIfChanged.mjs";import{filterInvalidDictionaries as n}from"../filterInvalidDictionaries.mjs";import{groupDictionariesByKey as r}from"./writeUnmergedDictionary.mjs";import{formatDistantDictionaries as i}from"../loadDictionaries/loadRemoteDictionaries.mjs";import{mkdir as a}from"node:fs/promises";import{resolve as o}from"node:path";import{colorizePath as s,x as c}from"@intlayer/config/logger";import{orderDictionaries as l}from"@intlayer/core/dictionaryManipulator";const u=async(u,d)=>{let{remoteDictionariesDir:f}=d.system;await a(o(f),{recursive:!0});let p=r(n(u,d)),m=await e(Object.entries(p),async([e,n])=>{if(e===`undefined`)return;let r=l(i(n),d),a=o(f,`${e}.json`);return await t(a,r).catch(e=>{console.error(`${c} Error creating unmerged ${s(a)}:`,e)}),[e,{dictionaryPath:a,dictionaries:n}]});return Object.fromEntries(m.filter(Boolean))};export{u as writeRemoteDictionary};
1
+ import { parallelize } from "../utils/parallelize.mjs";
2
+ import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
3
+ import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
4
+ import { groupDictionariesByKey } from "./writeUnmergedDictionary.mjs";
5
+ import { formatDistantDictionaries } from "../loadDictionaries/loadRemoteDictionaries.mjs";
6
+ import { mkdir } from "node:fs/promises";
7
+ import { resolve } from "node:path";
8
+ import { colorizePath, x } from "@intlayer/config/logger";
9
+ import { orderDictionaries } from "@intlayer/core/dictionaryManipulator";
10
+
11
+ //#region src/buildIntlayerDictionary/writeRemoteDictionary.ts
12
+ /**
13
+ * Write the localized dictionaries to the dictionariesDir
14
+ * @param mergedDictionaries - The merged dictionaries
15
+ * @param configuration - The configuration
16
+ * @returns The final dictionaries
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
21
+ * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
22
+ * console.log(finalDictionaries);
23
+ *
24
+ * // .intlayer/fetch_dictionaries/home.json
25
+ * // { key: 'home', content: { ... } },
26
+ * ```
27
+ */
28
+ const writeRemoteDictionary = async (remoteDictionaries, configuration) => {
29
+ const { remoteDictionariesDir } = configuration.system;
30
+ await mkdir(resolve(remoteDictionariesDir), { recursive: true });
31
+ const groupedDictionaries = groupDictionariesByKey(filterInvalidDictionaries(remoteDictionaries, configuration));
32
+ const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionaries]) => {
33
+ if (key === "undefined") return;
34
+ const orderedDictionaries = orderDictionaries(formatDistantDictionaries(dictionaries), configuration);
35
+ const unmergedFilePath = resolve(remoteDictionariesDir, `${key}.json`);
36
+ await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch((err) => {
37
+ console.error(`${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`, err);
38
+ });
39
+ return [key, {
40
+ dictionaryPath: unmergedFilePath,
41
+ dictionaries
42
+ }];
43
+ });
44
+ return Object.fromEntries(results.filter(Boolean));
45
+ };
46
+
47
+ //#endregion
48
+ export { writeRemoteDictionary };
2
49
  //# sourceMappingURL=writeRemoteDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeRemoteDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport {\n groupDictionariesByKey,\n type UnmergedDictionaryResult,\n} from './writeUnmergedDictionary';\n\nexport type RemoteDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeRemoteDictionary = async (\n remoteDictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<RemoteDictionaryOutput> => {\n const { remoteDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(remoteDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n remoteDictionaries,\n configuration\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n // Merge dictionaries with the same key and write to dictionariesDir\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const formattedDictionaries = formatDistantDictionaries(dictionaries);\n\n const orderedDictionaries = orderDictionaries(\n formattedDictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":"yjBAsCA,MAAa,EAAwB,MACnC,EACA,IACoC,CACpC,GAAM,CAAE,yBAA0B,EAAc,OAGhD,MAAM,EAAM,EAAQ,EAAsB,CAAE,CAAE,UAAW,GAAM,CAAC,CAQhE,IAAM,EAAsB,EANC,EAC3B,EACA,EACD,CAGuE,CAGlE,EAAU,MAAM,EACpB,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAkB,CAC7B,GAAI,IAAQ,YACV,OAQF,IAAM,EAAsB,EAFE,EAA0B,EAAa,CAInE,EACD,CAGK,EAAmB,EAAQ,EADV,GAAG,EAAI,OACyC,CAYvE,OATA,MAAM,EAAmB,EAAkB,EAAoB,CAAC,MAC7D,GAAQ,CACP,QAAQ,MACN,GAAG,EAAE,2BAA2B,EAAa,EAAiB,CAAC,GAC/D,EACD,EAEJ,CAEM,CACL,EACA,CACE,eAAgB,EAChB,eACD,CACF,EAEJ,CAED,OAAO,OAAO,YACZ,EAAQ,OAAO,QAAQ,CAGxB"}
1
+ {"version":3,"file":"writeRemoteDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport {\n groupDictionariesByKey,\n type UnmergedDictionaryResult,\n} from './writeUnmergedDictionary';\n\nexport type RemoteDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeRemoteDictionary = async (\n remoteDictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<RemoteDictionaryOutput> => {\n const { remoteDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(remoteDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n remoteDictionaries,\n configuration\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n // Merge dictionaries with the same key and write to dictionariesDir\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const formattedDictionaries = formatDistantDictionaries(dictionaries);\n\n const orderedDictionaries = orderDictionaries(\n formattedDictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,wBAAwB,OACnC,oBACA,kBACoC;CACpC,MAAM,EAAE,0BAA0B,cAAc;AAGhD,OAAM,MAAM,QAAQ,sBAAsB,EAAE,EAAE,WAAW,MAAM,CAAC;CAQhE,MAAM,sBAAsB,uBANC,0BAC3B,oBACA,cACD,CAGuE;CAGxE,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,kBAAkB;AAC7B,MAAI,QAAQ,YACV;EAQF,MAAM,sBAAsB,kBAFE,0BAA0B,aAAa,EAInE,cACD;EAGD,MAAM,mBAAmB,QAAQ,uBADV,GAAG,IAAI,OACyC;AAGvE,QAAM,mBAAmB,kBAAkB,oBAAoB,CAAC,OAC7D,QAAQ;AACP,WAAQ,MACN,GAAG,EAAE,2BAA2B,aAAa,iBAAiB,CAAC,IAC/D,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB;GACD,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CAGxB"}
@@ -1,2 +1,57 @@
1
- import{parallelize as e}from"../utils/parallelize.mjs";import{writeJsonIfChanged as t}from"../writeJsonIfChanged.mjs";import{filterInvalidDictionaries as n}from"../filterInvalidDictionaries.mjs";import{mkdir as r}from"node:fs/promises";import{resolve as i}from"node:path";import{colorizePath as a,x as o}from"@intlayer/config/logger";import{orderDictionaries as s}from"@intlayer/core/dictionaryManipulator";const c=e=>e.reduce((e,t)=>{let n=t.key;return e[n]||(e[n]=[]),e[n].push(t),e},{}),l=async(l,u,d)=>{let{unmergedDictionariesDir:f}=u.system;await r(i(f),{recursive:!0});let p=c(n(l,u,{checkSchema:!0})),m=await e(Object.entries(p),async([e,n])=>{if(e===`undefined`)return;let r=s(n,u),c=i(f,`${e}.json`);return(u.editor.enabled||d===`dev`)&&await t(c,r).catch(e=>{console.error(`${o} Error creating unmerged ${a(c)}:`,e)}),[e,{dictionaryPath:c,dictionaries:n}]});return Object.fromEntries(m.filter(Boolean))};export{c as groupDictionariesByKey,l as writeUnmergedDictionaries};
1
+ import { parallelize } from "../utils/parallelize.mjs";
2
+ import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
3
+ import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
4
+ import { mkdir } from "node:fs/promises";
5
+ import { resolve } from "node:path";
6
+ import { colorizePath, x } from "@intlayer/config/logger";
7
+ import { orderDictionaries } from "@intlayer/core/dictionaryManipulator";
8
+
9
+ //#region src/buildIntlayerDictionary/writeUnmergedDictionary.ts
10
+ const groupDictionariesByKey = (dictionaries) => dictionaries.reduce((acc, dictionary) => {
11
+ const key = dictionary.key;
12
+ if (!acc[key]) acc[key] = [];
13
+ acc[key].push(dictionary);
14
+ return acc;
15
+ }, {});
16
+ /**
17
+ * Write the unmerged dictionaries to the unmergedDictionariesDir
18
+ * @param dictionaries - The dictionaries to write
19
+ * @param configuration - The configuration
20
+ * @returns The grouped dictionaries
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
25
+ * console.log(unmergedDictionaries);
26
+ *
27
+ * // .intlayer/unmerged_dictionaries/home.json
28
+ * // {
29
+ * // [
30
+ * // { key: 'home', content: { ... } },
31
+ * // { key: 'home', content: { ... } },
32
+ * // ],
33
+ * // }
34
+ * ```
35
+ */
36
+ const writeUnmergedDictionaries = async (dictionaries, configuration, env) => {
37
+ const { unmergedDictionariesDir } = configuration.system;
38
+ await mkdir(resolve(unmergedDictionariesDir), { recursive: true });
39
+ const groupedDictionaries = groupDictionariesByKey(filterInvalidDictionaries(dictionaries, configuration, { checkSchema: true }));
40
+ const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionaries]) => {
41
+ if (key === "undefined") return;
42
+ const orderedDictionaries = orderDictionaries(dictionaries, configuration);
43
+ const unmergedFilePath = resolve(unmergedDictionariesDir, `${key}.json`);
44
+ if (configuration.editor.enabled || env === "dev") await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch((err) => {
45
+ console.error(`${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`, err);
46
+ });
47
+ return [key, {
48
+ dictionaryPath: unmergedFilePath,
49
+ dictionaries
50
+ }];
51
+ });
52
+ return Object.fromEntries(results.filter(Boolean));
53
+ };
54
+
55
+ //#endregion
56
+ export { groupDictionariesByKey, writeUnmergedDictionaries };
2
57
  //# sourceMappingURL=writeUnmergedDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeUnmergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, DictionaryKey } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nexport const groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> =>\n dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n\nexport type UnmergedDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type UnmergedDictionaryOutput = Record<\n DictionaryKey,\n UnmergedDictionaryResult\n>;\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig,\n env: 'prod' | 'dev'\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n dictionaries,\n configuration,\n { checkSchema: true }\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const orderedDictionaries = orderDictionaries(\n dictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries in disk if the editor is enabled\n // To make work the visual editor on the server\n // No need them if the editor is disabled\n // But in local env (env: 'dev') we write them for the vscode extension\n if (configuration.editor.enabled || env === 'dev') {\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n }\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries: dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":"uZAUA,MAAa,EACX,GAEA,EAAa,QACV,EAAK,IAAe,CACnB,IAAM,EAAM,EAAW,IAKvB,OAJK,EAAI,KACP,EAAI,GAAO,EAAE,EAEf,EAAI,GAAK,KAAK,EAAW,CAClB,GAET,EAAE,CACH,CAgCU,EAA4B,MACvC,EACA,EACA,IACsC,CACtC,GAAM,CAAE,2BAA4B,EAAc,OAGlD,MAAM,EAAM,EAAQ,EAAwB,CAAE,CAAE,UAAW,GAAM,CAAC,CASlE,IAAM,EAAsB,EAPC,EAC3B,EACA,EACA,CAAE,YAAa,GAAM,CACtB,CAGuE,CAElE,EAAU,MAAM,EACpB,OAAO,QAAQ,EAAoB,CACnC,MAAO,CAAC,EAAK,KAAkB,CAC7B,GAAI,IAAQ,YACV,OAMF,IAAM,EAAsB,EAC1B,EACA,EACD,CAGK,EAAmB,EAAQ,EADV,GAAG,EAAI,OAC2C,CAiBzE,OAXI,EAAc,OAAO,SAAW,IAAQ,QAC1C,MAAM,EAAmB,EAAkB,EAAoB,CAAC,MAC7D,GAAQ,CACP,QAAQ,MACN,GAAG,EAAE,2BAA2B,EAAa,EAAiB,CAAC,GAC/D,EACD,EAEJ,CAGI,CACL,EACA,CACE,eAAgB,EACF,eACf,CACF,EAEJ,CAED,OAAO,OAAO,YACZ,EAAQ,OAAO,QAAQ,CAGxB"}
1
+ {"version":3,"file":"writeUnmergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, DictionaryKey } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nexport const groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> =>\n dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n\nexport type UnmergedDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type UnmergedDictionaryOutput = Record<\n DictionaryKey,\n UnmergedDictionaryResult\n>;\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig,\n env: 'prod' | 'dev'\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n dictionaries,\n configuration,\n { checkSchema: true }\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const orderedDictionaries = orderDictionaries(\n dictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries in disk if the editor is enabled\n // To make work the visual editor on the server\n // No need them if the editor is disabled\n // But in local env (env: 'dev') we write them for the vscode extension\n if (configuration.editor.enabled || env === 'dev') {\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n }\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries: dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":";;;;;;;;;AAUA,MAAa,0BACX,iBAEA,aAAa,QACV,KAAK,eAAe;CACnB,MAAM,MAAM,WAAW;AACvB,KAAI,CAAC,IAAI,KACP,KAAI,OAAO,EAAE;AAEf,KAAI,KAAK,KAAK,WAAW;AACzB,QAAO;GAET,EAAE,CACH;;;;;;;;;;;;;;;;;;;;;AAgCH,MAAa,4BAA4B,OACvC,cACA,eACA,QACsC;CACtC,MAAM,EAAE,4BAA4B,cAAc;AAGlD,OAAM,MAAM,QAAQ,wBAAwB,EAAE,EAAE,WAAW,MAAM,CAAC;CASlE,MAAM,sBAAsB,uBAPC,0BAC3B,cACA,eACA,EAAE,aAAa,MAAM,CACtB,CAGuE;CAExE,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,kBAAkB;AAC7B,MAAI,QAAQ,YACV;EAMF,MAAM,sBAAsB,kBAC1B,cACA,cACD;EAGD,MAAM,mBAAmB,QAAQ,yBADV,GAAG,IAAI,OAC2C;AAMzE,MAAI,cAAc,OAAO,WAAW,QAAQ,MAC1C,OAAM,mBAAmB,kBAAkB,oBAAoB,CAAC,OAC7D,QAAQ;AACP,WAAQ,MACN,GAAG,EAAE,2BAA2B,aAAa,iBAAiB,CAAC,IAC/D,IACD;IAEJ;AAGH,SAAO,CACL,KACA;GACE,gBAAgB;GACF;GACf,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CAGxB"}
@@ -1,2 +1,29 @@
1
- import{rm as e}from"node:fs/promises";import{getAppLogger as t}from"@intlayer/config/logger";import{existsSync as n}from"node:fs";const r=async r=>{let{dictionariesDir:i,unmergedDictionariesDir:a,dynamicDictionariesDir:o,remoteDictionariesDir:s,fetchDictionariesDir:c,mainDir:l,typesDir:u,configDir:d,cacheDir:f}=r.system,p=t(r),m=[i,a,o,s,c,l,u,d,f];await Promise.all(m.filter(e=>n(e)).map(t=>e(t,{recursive:!0,force:!0}))),p(`Output directory cleaned`,{isVerbose:!0})};export{r as cleanOutputDir};
1
+ import { rm } from "node:fs/promises";
2
+ import { getAppLogger } from "@intlayer/config/logger";
3
+ import { existsSync } from "node:fs";
4
+
5
+ //#region src/cleanOutputDir.ts
6
+ const cleanOutputDir = async (configuration) => {
7
+ const { dictionariesDir, unmergedDictionariesDir, dynamicDictionariesDir, remoteDictionariesDir, fetchDictionariesDir, mainDir, typesDir, configDir, cacheDir } = configuration.system;
8
+ const appLogger = getAppLogger(configuration);
9
+ const directoriesToClean = [
10
+ dictionariesDir,
11
+ unmergedDictionariesDir,
12
+ dynamicDictionariesDir,
13
+ remoteDictionariesDir,
14
+ fetchDictionariesDir,
15
+ mainDir,
16
+ typesDir,
17
+ configDir,
18
+ cacheDir
19
+ ];
20
+ await Promise.all(directoriesToClean.filter((dir) => existsSync(dir)).map((dir) => rm(dir, {
21
+ recursive: true,
22
+ force: true
23
+ })));
24
+ appLogger("Output directory cleaned", { isVerbose: true });
25
+ };
26
+
27
+ //#endregion
28
+ export { cleanOutputDir };
2
29
  //# sourceMappingURL=cleanOutputDir.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleanOutputDir.mjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const cleanOutputDir = async (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n remoteDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n cacheDir,\n } = configuration.system;\n\n const appLogger = getAppLogger(configuration);\n\n const directoriesToClean: string[] = [\n dictionariesDir, // Merged dictionaries\n unmergedDictionariesDir, // Unmerged dictionaries\n dynamicDictionariesDir, // Dynamic dictionaries\n remoteDictionariesDir, // Remote dictionaries\n fetchDictionariesDir, // Fetch dictionaries\n mainDir, // Main files\n typesDir, // Types\n configDir, // Configuration\n cacheDir, // Cache\n ];\n\n // Execute all deletions in parallel\n await Promise.all(\n directoriesToClean\n .filter((dir) => existsSync(dir))\n .map((dir) => rm(dir, { recursive: true, force: true }))\n );\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":"kIAKA,MAAa,EAAiB,KAAO,IAAkC,CACrE,GAAM,CACJ,kBACA,0BACA,yBACA,wBACA,uBACA,UACA,WACA,YACA,YACE,EAAc,OAEZ,EAAY,EAAa,EAAc,CAEvC,EAA+B,CACnC,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CAGD,MAAM,QAAQ,IACZ,EACG,OAAQ,GAAQ,EAAW,EAAI,CAAC,CAChC,IAAK,GAAQ,EAAG,EAAK,CAAE,UAAW,GAAM,MAAO,GAAM,CAAC,CAAC,CAC3D,CAED,EAAU,2BAA4B,CACpC,UAAW,GACZ,CAAC"}
1
+ {"version":3,"file":"cleanOutputDir.mjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const cleanOutputDir = async (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n remoteDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n cacheDir,\n } = configuration.system;\n\n const appLogger = getAppLogger(configuration);\n\n const directoriesToClean: string[] = [\n dictionariesDir, // Merged dictionaries\n unmergedDictionariesDir, // Unmerged dictionaries\n dynamicDictionariesDir, // Dynamic dictionaries\n remoteDictionariesDir, // Remote dictionaries\n fetchDictionariesDir, // Fetch dictionaries\n mainDir, // Main files\n typesDir, // Types\n configDir, // Configuration\n cacheDir, // Cache\n ];\n\n // Execute all deletions in parallel\n await Promise.all(\n directoriesToClean\n .filter((dir) => existsSync(dir))\n .map((dir) => rm(dir, { recursive: true, force: true }))\n );\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;AAKA,MAAa,iBAAiB,OAAO,kBAAkC;CACrE,MAAM,EACJ,iBACA,yBACA,wBACA,uBACA,sBACA,SACA,UACA,WACA,aACE,cAAc;CAElB,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,qBAA+B;EACnC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;AAGD,OAAM,QAAQ,IACZ,mBACG,QAAQ,QAAQ,WAAW,IAAI,CAAC,CAChC,KAAK,QAAQ,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC,CAAC,CAC3D;AAED,WAAU,4BAA4B,EACpC,WAAW,MACZ,CAAC"}
@@ -1,2 +1,95 @@
1
- import{createDictionaryEntryPoint as e}from"./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";import{writeJsonIfChanged as t}from"./writeJsonIfChanged.mjs";import{readFile as n,rm as r}from"node:fs/promises";import{join as i,normalize as a,relative as o}from"node:path";import{normalizePath as s}from"@intlayer/config/client";import{colorizeKey as c,colorizePath as l,getAppLogger as u}from"@intlayer/config/logger";import{getDictionaries as d}from"@intlayer/dictionaries-entry";import{getUnmergedDictionaries as f}from"@intlayer/unmerged-dictionaries-entry";import p from"fast-glob";const m=async(m,h,g)=>{let _=u(g),v=f(g),y=g.system.baseDir,b=o(y,m),x=Object.values(v).flat().filter(e=>e.filePath===b&&!h.includes(e.key)).filter((e,t,n)=>t===n.findIndex(t=>t.key===e.key)),S=[],C=[],w=[];await Promise.all(x.map(async e=>{let r=a(i(g.system.unmergedDictionariesDir,`${e.key}.json`));try{let i=await n(r,`utf8`),a=JSON.parse(i);a.length===1?a[0].filePath===b&&(_(`Removing outdated dictionary ${c(e.key)}`,{isVerbose:!0}),C.push(r),w.push(e.key)):(await t(r,a.filter(e=>e.filePath!==b)),S.push(e.localId))}catch(t){t.code===`ENOENT`&&(w.includes(e.key)||w.push(e.key))}}));let T=d(g),E=(Object.values(T)?.filter(e=>!h.includes(e.key)&&e.localIds?.length===1&&e.localIds[0].endsWith(`::local::${b}`))).filter((e,t,n)=>t===n.findIndex(t=>t.key===e.key));return await Promise.all(E.map(async e=>{let r=a(i(g.system.dictionariesDir,`${e.key}.json`));try{let o=await n(r,`utf8`),l=JSON.parse(o);if(l.localIds?.length===1){if(l.localIds[0].endsWith(`::local::${b}`)){_(`Removing outdated unmerged dictionary ${c(e.key)}`,{isVerbose:!0}),C.push(r);let t=a(i(g.system.typesDir,`${e.key}.ts`));C.push(t);let n=await p(s(i(g.system.dynamicDictionariesDir,`${e.key}.*`)),{absolute:!0});C.push(...n),w.includes(e.key)||w.push(e.key)}}else{let e=l.localIds?.filter(e=>!e.endsWith(`::local::${b}`));await t(r,{...l,localIds:e})}}catch(t){if(t.code===`ENOENT`){w.includes(e.key)||w.push(e.key);let t=a(i(g.system.typesDir,`${e.key}.ts`));C.push(t)}}})),(C.length>0||w.length>0)&&(await e(g,{excludeKeys:w}),C.length>0&&await Promise.all(C.map(async e=>{let t=o(y,e);try{await r(e,{force:!0}),_(`Deleted artifact: ${l(t)}`,{isVerbose:!0})}catch{_(`Error while removing file ${l(t)}`,{isVerbose:!0})}}))),{changedDictionariesLocalIds:S,excludeKeys:w,hasRebuilt:C.length>0||w.length>0}};export{m as cleanRemovedContentDeclaration};
1
+ import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
2
+ import { writeJsonIfChanged } from "./writeJsonIfChanged.mjs";
3
+ import { readFile, rm } from "node:fs/promises";
4
+ import { join, normalize, relative } from "node:path";
5
+ import { normalizePath } from "@intlayer/config/client";
6
+ import { colorizeKey, colorizePath, getAppLogger } from "@intlayer/config/logger";
7
+ import { getDictionaries } from "@intlayer/dictionaries-entry";
8
+ import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
9
+ import fg from "fast-glob";
10
+
11
+ //#region src/cleanRemovedContentDeclaration.ts
12
+ const cleanRemovedContentDeclaration = async (filePath, keysToKeep, configuration) => {
13
+ const appLogger = getAppLogger(configuration);
14
+ const unmergedDictionaries = getUnmergedDictionaries(configuration);
15
+ const baseDir = configuration.system.baseDir;
16
+ const relativeFilePath = relative(baseDir, filePath);
17
+ const uniqueUnmergedDictionaries = Object.values(unmergedDictionaries).flat().filter((dictionary) => dictionary.filePath === relativeFilePath && !keysToKeep.includes(dictionary.key)).filter((dictionary, index, self) => index === self.findIndex((t) => t.key === dictionary.key));
18
+ const changedDictionariesLocalIds = [];
19
+ const filesToRemove = [];
20
+ const excludeKeys = [];
21
+ await Promise.all(uniqueUnmergedDictionaries.map(async (dictionary) => {
22
+ const unmergedFilePath = normalize(join(configuration.system.unmergedDictionariesDir, `${dictionary.key}.json`));
23
+ try {
24
+ const jsonContent = await readFile(unmergedFilePath, "utf8");
25
+ const parsedContent = JSON.parse(jsonContent);
26
+ if (parsedContent.length === 1) {
27
+ if (parsedContent[0].filePath === relativeFilePath) {
28
+ appLogger(`Removing outdated dictionary ${colorizeKey(dictionary.key)}`, { isVerbose: true });
29
+ filesToRemove.push(unmergedFilePath);
30
+ excludeKeys.push(dictionary.key);
31
+ }
32
+ } else {
33
+ await writeJsonIfChanged(unmergedFilePath, parsedContent.filter((content) => content.filePath !== relativeFilePath));
34
+ changedDictionariesLocalIds.push(dictionary.localId);
35
+ }
36
+ } catch (error) {
37
+ if (error.code === "ENOENT") {
38
+ if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
39
+ }
40
+ }
41
+ }));
42
+ const dictionaries = getDictionaries(configuration);
43
+ const uniqueMergedDictionaries = (Object.values(dictionaries)?.filter((dictionary) => !keysToKeep.includes(dictionary.key) && dictionary.localIds?.length === 1 && dictionary.localIds[0].endsWith(`::local::${relativeFilePath}`))).filter((dictionary, index, self) => index === self.findIndex((t) => t.key === dictionary.key));
44
+ await Promise.all(uniqueMergedDictionaries.map(async (dictionary) => {
45
+ const mergedFilePath = normalize(join(configuration.system.dictionariesDir, `${dictionary.key}.json`));
46
+ try {
47
+ const fileContent = await readFile(mergedFilePath, "utf8");
48
+ const parsedContent = JSON.parse(fileContent);
49
+ if (parsedContent.localIds?.length === 1) {
50
+ if (parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)) {
51
+ appLogger(`Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`, { isVerbose: true });
52
+ filesToRemove.push(mergedFilePath);
53
+ const typesFilePath = normalize(join(configuration.system.typesDir, `${dictionary.key}.ts`));
54
+ filesToRemove.push(typesFilePath);
55
+ const dynamicFiles = await fg(normalizePath(join(configuration.system.dynamicDictionariesDir, `${dictionary.key}.*`)), { absolute: true });
56
+ filesToRemove.push(...dynamicFiles);
57
+ if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
58
+ }
59
+ } else {
60
+ const localIds = parsedContent.localIds?.filter((localeId) => !localeId.endsWith(`::local::${relativeFilePath}`));
61
+ await writeJsonIfChanged(mergedFilePath, {
62
+ ...parsedContent,
63
+ localIds
64
+ });
65
+ }
66
+ } catch (error) {
67
+ if (error.code === "ENOENT") {
68
+ if (!excludeKeys.includes(dictionary.key)) excludeKeys.push(dictionary.key);
69
+ const typesFilePath = normalize(join(configuration.system.typesDir, `${dictionary.key}.ts`));
70
+ filesToRemove.push(typesFilePath);
71
+ }
72
+ }
73
+ }));
74
+ if (filesToRemove.length > 0 || excludeKeys.length > 0) {
75
+ await createDictionaryEntryPoint(configuration, { excludeKeys });
76
+ if (filesToRemove.length > 0) await Promise.all(filesToRemove.map(async (path) => {
77
+ const relativePath = relative(baseDir, path);
78
+ try {
79
+ await rm(path, { force: true });
80
+ appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, { isVerbose: true });
81
+ } catch {
82
+ appLogger(`Error while removing file ${colorizePath(relativePath)}`, { isVerbose: true });
83
+ }
84
+ }));
85
+ }
86
+ return {
87
+ changedDictionariesLocalIds,
88
+ excludeKeys,
89
+ hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0
90
+ };
91
+ };
92
+
93
+ //#endregion
94
+ export { cleanRemovedContentDeclaration };
2
95
  //# sourceMappingURL=cleanRemovedContentDeclaration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleanRemovedContentDeclaration.mjs","names":[],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config/client';\nimport {\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport fg from 'fast-glob';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint';\nimport { writeJsonIfChanged } from './writeJsonIfChanged';\n\nexport const cleanRemovedContentDeclaration = async (\n filePath: string,\n keysToKeep: string[],\n configuration: IntlayerConfig\n): Promise<{\n changedDictionariesLocalIds: string[];\n excludeKeys: string[];\n hasRebuilt: boolean;\n}> => {\n const appLogger = getAppLogger(configuration);\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const baseDir = configuration.system.baseDir;\n\n const relativeFilePath = relative(baseDir, filePath);\n const flatUnmergedDictionaries = Object.values(unmergedDictionaries).flat();\n\n const filteredUnmergedDictionaries = flatUnmergedDictionaries.filter(\n (dictionary) =>\n dictionary.filePath === relativeFilePath &&\n !keysToKeep.includes(dictionary.key)\n );\n\n // Deduplicate dictionaries by key\n const uniqueUnmergedDictionaries = filteredUnmergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n const changedDictionariesLocalIds: string[] = [];\n const filesToRemove: string[] = [];\n const excludeKeys: string[] = [];\n\n // Identify Unmerged Dictionaries to remove or clean\n await Promise.all(\n uniqueUnmergedDictionaries.map(async (dictionary) => {\n const unmergedFilePath = normalize(\n join(\n configuration.system.unmergedDictionariesDir,\n `${dictionary.key}.json`\n )\n );\n\n try {\n const jsonContent = await readFile(unmergedFilePath, 'utf8');\n const parsedContent = JSON.parse(jsonContent);\n\n if (parsedContent.length === 1) {\n if (parsedContent[0].filePath === relativeFilePath) {\n appLogger(\n `Removing outdated dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n filesToRemove.push(unmergedFilePath);\n excludeKeys.push(dictionary.key);\n }\n } else {\n const filteredContent = parsedContent.filter(\n (content: any) => content.filePath !== relativeFilePath\n );\n await writeJsonIfChanged(unmergedFilePath, filteredContent);\n changedDictionariesLocalIds.push(dictionary.localId!);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n }\n })\n );\n\n const dictionaries = getDictionaries(configuration);\n const flatDictionaries = Object.values(dictionaries) as Dictionary[];\n\n const filteredMergedDictionaries = flatDictionaries?.filter(\n (dictionary) =>\n !keysToKeep.includes(dictionary.key) &&\n dictionary.localIds?.length === 1 &&\n (dictionary.localIds[0] as string).endsWith(\n `::local::${relativeFilePath}`\n )\n );\n\n const uniqueMergedDictionaries = filteredMergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n // Identify Merged Dictionaries, Types, and Dynamic Dictionaries to remove\n await Promise.all(\n uniqueMergedDictionaries.map(async (dictionary) => {\n const mergedFilePath = normalize(\n join(configuration.system.dictionariesDir, `${dictionary.key}.json`)\n );\n\n try {\n const fileContent = await readFile(mergedFilePath, 'utf8');\n const parsedContent = JSON.parse(fileContent) as Dictionary;\n\n if (parsedContent.localIds?.length === 1) {\n if (\n parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)\n ) {\n appLogger(\n `Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n\n // Mark JSON for removal\n filesToRemove.push(mergedFilePath);\n\n // Mark TS Types for removal\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n\n // Mark Dynamic Dictionaries for removal\n // We use glob to catch the loader files (.cjs, .mjs) AND the split locale files (.en.json, etc.)\n const dynamicFilesGlob = join(\n configuration.system.dynamicDictionariesDir,\n `${dictionary.key}.*`\n );\n const dynamicFiles = await fg(normalizePath(dynamicFilesGlob), {\n absolute: true,\n });\n filesToRemove.push(...dynamicFiles);\n\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n } else {\n const localIds = parsedContent.localIds?.filter(\n (localeId) => !localeId.endsWith(`::local::${relativeFilePath}`)\n ) as string[];\n const newContent = { ...parsedContent, localIds };\n await writeJsonIfChanged(mergedFilePath, newContent);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n }\n }\n })\n );\n\n // Execute Cleanup\n if (filesToRemove.length > 0 || excludeKeys.length > 0) {\n // Update entry points (indexes) first so the app doesn't import dead files\n await createDictionaryEntryPoint(configuration, { excludeKeys });\n\n // Remove the files synchronously (awaited) immediately after.\n if (filesToRemove.length > 0) {\n await Promise.all(\n filesToRemove.map(async (path) => {\n const relativePath = relative(baseDir, path);\n try {\n await rm(path, { force: true });\n\n appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, {\n isVerbose: true,\n });\n } catch {\n appLogger(\n `Error while removing file ${colorizePath(relativePath)}`,\n {\n isVerbose: true,\n }\n );\n }\n })\n );\n }\n }\n\n return {\n changedDictionariesLocalIds,\n excludeKeys,\n hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0,\n };\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"cleanRemovedContentDeclaration.mjs","names":[],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config/client';\nimport {\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport fg from 'fast-glob';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint';\nimport { writeJsonIfChanged } from './writeJsonIfChanged';\n\nexport const cleanRemovedContentDeclaration = async (\n filePath: string,\n keysToKeep: string[],\n configuration: IntlayerConfig\n): Promise<{\n changedDictionariesLocalIds: string[];\n excludeKeys: string[];\n hasRebuilt: boolean;\n}> => {\n const appLogger = getAppLogger(configuration);\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const baseDir = configuration.system.baseDir;\n\n const relativeFilePath = relative(baseDir, filePath);\n const flatUnmergedDictionaries = Object.values(unmergedDictionaries).flat();\n\n const filteredUnmergedDictionaries = flatUnmergedDictionaries.filter(\n (dictionary) =>\n dictionary.filePath === relativeFilePath &&\n !keysToKeep.includes(dictionary.key)\n );\n\n // Deduplicate dictionaries by key\n const uniqueUnmergedDictionaries = filteredUnmergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n const changedDictionariesLocalIds: string[] = [];\n const filesToRemove: string[] = [];\n const excludeKeys: string[] = [];\n\n // Identify Unmerged Dictionaries to remove or clean\n await Promise.all(\n uniqueUnmergedDictionaries.map(async (dictionary) => {\n const unmergedFilePath = normalize(\n join(\n configuration.system.unmergedDictionariesDir,\n `${dictionary.key}.json`\n )\n );\n\n try {\n const jsonContent = await readFile(unmergedFilePath, 'utf8');\n const parsedContent = JSON.parse(jsonContent);\n\n if (parsedContent.length === 1) {\n if (parsedContent[0].filePath === relativeFilePath) {\n appLogger(\n `Removing outdated dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n filesToRemove.push(unmergedFilePath);\n excludeKeys.push(dictionary.key);\n }\n } else {\n const filteredContent = parsedContent.filter(\n (content: any) => content.filePath !== relativeFilePath\n );\n await writeJsonIfChanged(unmergedFilePath, filteredContent);\n changedDictionariesLocalIds.push(dictionary.localId!);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n }\n })\n );\n\n const dictionaries = getDictionaries(configuration);\n const flatDictionaries = Object.values(dictionaries) as Dictionary[];\n\n const filteredMergedDictionaries = flatDictionaries?.filter(\n (dictionary) =>\n !keysToKeep.includes(dictionary.key) &&\n dictionary.localIds?.length === 1 &&\n (dictionary.localIds[0] as string).endsWith(\n `::local::${relativeFilePath}`\n )\n );\n\n const uniqueMergedDictionaries = filteredMergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n // Identify Merged Dictionaries, Types, and Dynamic Dictionaries to remove\n await Promise.all(\n uniqueMergedDictionaries.map(async (dictionary) => {\n const mergedFilePath = normalize(\n join(configuration.system.dictionariesDir, `${dictionary.key}.json`)\n );\n\n try {\n const fileContent = await readFile(mergedFilePath, 'utf8');\n const parsedContent = JSON.parse(fileContent) as Dictionary;\n\n if (parsedContent.localIds?.length === 1) {\n if (\n parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)\n ) {\n appLogger(\n `Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n\n // Mark JSON for removal\n filesToRemove.push(mergedFilePath);\n\n // Mark TS Types for removal\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n\n // Mark Dynamic Dictionaries for removal\n // We use glob to catch the loader files (.cjs, .mjs) AND the split locale files (.en.json, etc.)\n const dynamicFilesGlob = join(\n configuration.system.dynamicDictionariesDir,\n `${dictionary.key}.*`\n );\n const dynamicFiles = await fg(normalizePath(dynamicFilesGlob), {\n absolute: true,\n });\n filesToRemove.push(...dynamicFiles);\n\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n } else {\n const localIds = parsedContent.localIds?.filter(\n (localeId) => !localeId.endsWith(`::local::${relativeFilePath}`)\n ) as string[];\n const newContent = { ...parsedContent, localIds };\n await writeJsonIfChanged(mergedFilePath, newContent);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n }\n }\n })\n );\n\n // Execute Cleanup\n if (filesToRemove.length > 0 || excludeKeys.length > 0) {\n // Update entry points (indexes) first so the app doesn't import dead files\n await createDictionaryEntryPoint(configuration, { excludeKeys });\n\n // Remove the files synchronously (awaited) immediately after.\n if (filesToRemove.length > 0) {\n await Promise.all(\n filesToRemove.map(async (path) => {\n const relativePath = relative(baseDir, path);\n try {\n await rm(path, { force: true });\n\n appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, {\n isVerbose: true,\n });\n } catch {\n appLogger(\n `Error while removing file ${colorizePath(relativePath)}`,\n {\n isVerbose: true,\n }\n );\n }\n })\n );\n }\n }\n\n return {\n changedDictionariesLocalIds,\n excludeKeys,\n hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0,\n };\n};\n"],"mappings":"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"}
package/dist/esm/cli.mjs CHANGED
@@ -1 +1,15 @@
1
- import{listProjects as e}from"./listProjects.mjs";import{listDictionaries as t,listDictionariesWithStats as n}from"./listDictionariesPath.mjs";import{detectExportedComponentName as r}from"./writeContentDeclaration/detectExportedComponentName.mjs";import{transformJSFile as i}from"./writeContentDeclaration/transformJSFile.mjs";import{detectFormatCommand as a}from"./detectFormatCommand.mjs";import{getContentDeclarationFileTemplate as o}from"./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";import{writeJSFile as s}from"./writeContentDeclaration/writeJSFile.mjs";import{writeContentDeclaration as c}from"./writeContentDeclaration/writeContentDeclaration.mjs";import"./writeContentDeclaration/index.mjs";import"./getContentDeclarationFileTemplate/index.mjs";import"./_utils_asset-4w8dPH9r.mjs";import{initIntlayer as l}from"./init/index.mjs";import{PLATFORMS as u,PLATFORMS_METADATA as d,SKILLS as f,SKILLS_METADATA as p,getInitialSkills as m,installSkills as h}from"./installSkills/index.mjs";import{installMCP as g}from"./installMCP/installMCP.mjs";import{listGitFiles as _,listGitLines as v}from"./listGitFiles.mjs";import{logConfigDetails as y}from"./logConfigDetails.mjs";export{u as PLATFORMS,d as PLATFORMS_METADATA,f as SKILLS,p as SKILLS_METADATA,r as detectExportedComponentName,a as detectFormatCommand,o as getContentDeclarationFileTemplate,m as getInitialSkills,l as initIntlayer,g as installMCP,h as installSkills,t as listDictionaries,n as listDictionariesWithStats,_ as listGitFiles,v as listGitLines,e as listProjects,y as logConfigDetails,i as transformJSFile,c as writeContentDeclaration,s as writeJSFile};
1
+ import { listProjects } from "./listProjects.mjs";
2
+ import { listDictionaries, listDictionariesWithStats } from "./listDictionariesPath.mjs";
3
+ import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.mjs";
4
+ import { transformJSFile } from "./writeContentDeclaration/transformJSFile.mjs";
5
+ import { detectFormatCommand } from "./detectFormatCommand.mjs";
6
+ import { getContentDeclarationFileTemplate } from "./getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs";
7
+ import { writeJSFile } from "./writeContentDeclaration/writeJSFile.mjs";
8
+ import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
9
+ import { initIntlayer } from "./init/index.mjs";
10
+ import { PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, getInitialSkills, installSkills } from "./installSkills/index.mjs";
11
+ import { installMCP } from "./installMCP/installMCP.mjs";
12
+ import { listGitFiles, listGitLines } from "./listGitFiles.mjs";
13
+ import { logConfigDetails } from "./logConfigDetails.mjs";
14
+
15
+ export { PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, detectExportedComponentName, detectFormatCommand, getContentDeclarationFileTemplate, getInitialSkills, initIntlayer, installMCP, installSkills, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, logConfigDetails, transformJSFile, writeContentDeclaration, writeJSFile };
@@ -1,2 +1,69 @@
1
- import{parallelize as e}from"../utils/parallelize.mjs";import{writeFileIfChanged as t}from"../writeFileIfChanged.mjs";import{generateDictionaryListContent as n}from"./generateDictionaryListContent.mjs";import{getBuiltDictionariesPath as r}from"./getBuiltDictionariesPath.mjs";import{getBuiltDynamicDictionariesPath as i}from"./getBuiltDynamicDictionariesPath.mjs";import{getBuiltFetchDictionariesPath as a}from"./getBuiltFetchDictionariesPath.mjs";import{getBuiltRemoteDictionariesPath as o}from"./getBuiltRemoteDictionariesPath.mjs";import{getBuiltUnmergedDictionariesPath as s}from"./getBuiltUnmergedDictionariesPath.mjs";import{mkdir as c}from"node:fs/promises";import{resolve as l}from"node:path";import{getConfiguration as u}from"@intlayer/config/node";const d=async(e,r,i,a,o,s=u())=>{let c=n(await e,a,i,o,s),d=o===`cjs`?`cjs`:`mjs`,{mainDir:f}=s.system;await t(l(f,`${r}.${d}`),c)},f=async(t=u(),n={})=>{let{formats:l,excludeKeys:f=[]}=n,p=l??t.build.outputFormat,{mainDir:m}=t.system;await c(m,{recursive:!0}),await e([...p.map(e=>({paths:r(t,f),importType:`json`,functionName:`getDictionaries`,fileName:`dictionaries`,format:e})),...p.map(e=>({paths:s(t,f),importType:`json`,functionName:`getUnmergedDictionaries`,fileName:`unmerged_dictionaries`,format:e})),...p.map(e=>({paths:i(t,e,f),importType:`javascript`,functionName:`getDynamicDictionaries`,fileName:`dynamic_dictionaries`,format:e})),...p.map(e=>({paths:a(t,e,f),importType:`javascript`,functionName:`getFetchDictionaries`,fileName:`fetch_dictionaries`,format:e})),...p.map(e=>({paths:o(t,f),importType:`json`,functionName:`getRemoteDictionaries`,fileName:`remote_dictionaries`,format:e}))],async({paths:e,fileName:n,format:r,functionName:i,importType:a})=>d(e,n,a,i,r,t))};export{f as createDictionaryEntryPoint};
1
+ import { parallelize } from "../utils/parallelize.mjs";
2
+ import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
3
+ import { generateDictionaryListContent } from "./generateDictionaryListContent.mjs";
4
+ import { getBuiltDictionariesPath } from "./getBuiltDictionariesPath.mjs";
5
+ import { getBuiltDynamicDictionariesPath } from "./getBuiltDynamicDictionariesPath.mjs";
6
+ import { getBuiltFetchDictionariesPath } from "./getBuiltFetchDictionariesPath.mjs";
7
+ import { getBuiltRemoteDictionariesPath } from "./getBuiltRemoteDictionariesPath.mjs";
8
+ import { getBuiltUnmergedDictionariesPath } from "./getBuiltUnmergedDictionariesPath.mjs";
9
+ import { mkdir } from "node:fs/promises";
10
+ import { resolve } from "node:path";
11
+ import { getConfiguration } from "@intlayer/config/node";
12
+
13
+ //#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts
14
+ const writeDictionaryFiles = async (paths, fileName, importType, functionName, format, configuration = getConfiguration()) => {
15
+ const content = generateDictionaryListContent(await paths, functionName, importType, format, configuration);
16
+ const extension = format === "cjs" ? "cjs" : "mjs";
17
+ const { mainDir } = configuration.system;
18
+ await writeFileIfChanged(resolve(mainDir, `${fileName}.${extension}`), content);
19
+ };
20
+ /**
21
+ * This function generates a list of dictionaries in the main directory
22
+ */
23
+ const createDictionaryEntryPoint = async (configuration = getConfiguration(), options = {}) => {
24
+ const { formats, excludeKeys = [] } = options;
25
+ const outputFormats = formats ?? configuration.build.outputFormat;
26
+ const { mainDir } = configuration.system;
27
+ await mkdir(mainDir, { recursive: true });
28
+ await parallelize([
29
+ ...outputFormats.map((format) => ({
30
+ paths: getBuiltDictionariesPath(configuration, excludeKeys),
31
+ importType: "json",
32
+ functionName: "getDictionaries",
33
+ fileName: "dictionaries",
34
+ format
35
+ })),
36
+ ...outputFormats.map((format) => ({
37
+ paths: getBuiltUnmergedDictionariesPath(configuration, excludeKeys),
38
+ importType: "json",
39
+ functionName: "getUnmergedDictionaries",
40
+ fileName: "unmerged_dictionaries",
41
+ format
42
+ })),
43
+ ...outputFormats.map((format) => ({
44
+ paths: getBuiltDynamicDictionariesPath(configuration, format, excludeKeys),
45
+ importType: "javascript",
46
+ functionName: "getDynamicDictionaries",
47
+ fileName: "dynamic_dictionaries",
48
+ format
49
+ })),
50
+ ...outputFormats.map((format) => ({
51
+ paths: getBuiltFetchDictionariesPath(configuration, format, excludeKeys),
52
+ importType: "javascript",
53
+ functionName: "getFetchDictionaries",
54
+ fileName: "fetch_dictionaries",
55
+ format
56
+ })),
57
+ ...outputFormats.map((format) => ({
58
+ paths: getBuiltRemoteDictionariesPath(configuration, excludeKeys),
59
+ importType: "json",
60
+ functionName: "getRemoteDictionaries",
61
+ fileName: "remote_dictionaries",
62
+ format
63
+ }))
64
+ ], async ({ paths, fileName, format, functionName, importType }) => writeDictionaryFiles(paths, fileName, importType, functionName, format, configuration));
65
+ };
66
+
67
+ //#endregion
68
+ export { createDictionaryEntryPoint };
2
69
  //# sourceMappingURL=createDictionaryEntryPoint.mjs.map