@intlayer/chokidar 8.4.4 → 8.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 -5
  10. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  11. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +80 -3
  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 -5
  198. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  199. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +76 -3
  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 +1 -1
  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-C-LWgPIL.d.ts +0 -25
  449. package/dist/types/buildIntlayerDictionary-C-LWgPIL.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-BE0mF2zZ.d.ts +0 -49
  491. package/dist/types/writeDynamicDictionary-BE0mF2zZ.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,2 +1,18 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./writeFileIfChanged.cjs`),t=async(t,n,{pretty:r=process.env.NODE_ENV===`development`}={})=>{let i=r?2:void 0,a=`{}`;try{a=JSON.stringify(n,null,i)}catch(e){console.error(`Error while parsing data to JSON for ${t}:`,e)}return await e.writeFileIfChanged(t,a)};exports.writeJsonIfChanged=t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_writeFileIfChanged = require('./writeFileIfChanged.cjs');
3
+
4
+ //#region src/writeJsonIfChanged.ts
5
+ const writeJsonIfChanged = async (path, data, { pretty = process.env.NODE_ENV === "development" } = {}) => {
6
+ const space = pretty ? 2 : void 0;
7
+ let json = "{}";
8
+ try {
9
+ json = JSON.stringify(data, null, space);
10
+ } catch (error) {
11
+ console.error(`Error while parsing data to JSON for ${path}:`, error);
12
+ }
13
+ return await require_writeFileIfChanged.writeFileIfChanged(path, json);
14
+ };
15
+
16
+ //#endregion
17
+ exports.writeJsonIfChanged = writeJsonIfChanged;
2
18
  //# sourceMappingURL=writeJsonIfChanged.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeJsonIfChanged.cjs","names":["writeFileIfChanged"],"sources":["../../src/writeJsonIfChanged.ts"],"sourcesContent":["import { writeFileIfChanged } from './writeFileIfChanged';\n\nexport const writeJsonIfChanged = async <T>(\n path: string,\n data: T,\n { pretty = process.env.NODE_ENV === 'development' } = {}\n): Promise<boolean> => {\n const space = pretty ? 2 : undefined;\n\n let json = '{}';\n\n try {\n json = JSON.stringify(data, null, space);\n } catch (error) {\n console.error(`Error while parsing data to JSON for ${path}:`, error);\n }\n\n return await writeFileIfChanged(path, json);\n};\n"],"mappings":"+GAEa,EAAqB,MAChC,EACA,EACA,CAAE,SAAS,QAAQ,IAAI,WAAa,eAAkB,EAAE,GACnC,CACrB,IAAM,EAAQ,EAAS,EAAI,IAAA,GAEvB,EAAO,KAEX,GAAI,CACF,EAAO,KAAK,UAAU,EAAM,KAAM,EAAM,OACjC,EAAO,CACd,QAAQ,MAAM,wCAAwC,EAAK,GAAI,EAAM,CAGvE,OAAO,MAAMA,EAAAA,mBAAmB,EAAM,EAAK"}
1
+ {"version":3,"file":"writeJsonIfChanged.cjs","names":["writeFileIfChanged"],"sources":["../../src/writeJsonIfChanged.ts"],"sourcesContent":["import { writeFileIfChanged } from './writeFileIfChanged';\n\nexport const writeJsonIfChanged = async <T>(\n path: string,\n data: T,\n { pretty = process.env.NODE_ENV === 'development' } = {}\n): Promise<boolean> => {\n const space = pretty ? 2 : undefined;\n\n let json = '{}';\n\n try {\n json = JSON.stringify(data, null, space);\n } catch (error) {\n console.error(`Error while parsing data to JSON for ${path}:`, error);\n }\n\n return await writeFileIfChanged(path, json);\n};\n"],"mappings":";;;;AAEA,MAAa,qBAAqB,OAChC,MACA,MACA,EAAE,SAAS,QAAQ,IAAI,aAAa,kBAAkB,EAAE,KACnC;CACrB,MAAM,QAAQ,SAAS,IAAI;CAE3B,IAAI,OAAO;AAEX,KAAI;AACF,SAAO,KAAK,UAAU,MAAM,MAAM,MAAM;UACjC,OAAO;AACd,UAAQ,MAAM,wCAAwC,KAAK,IAAI,MAAM;;AAGvE,QAAO,MAAMA,8CAAmB,MAAM,KAAK"}
@@ -0,0 +1,8 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
3
+ if (typeof require !== "undefined") return require.apply(this, arguments);
4
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
5
+ });
6
+
7
+ //#endregion
8
+ export { __require };
@@ -0,0 +1,97 @@
1
+ import { basename, dirname, join, relative, resolve, sep } from "node:path";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ //#region \0utils:asset
6
+ const hereDirname = () => {
7
+ try {
8
+ return dirname(fileURLToPath(import.meta.url));
9
+ } catch {
10
+ return typeof __dirname !== "undefined" ? __dirname : process.cwd();
11
+ }
12
+ };
13
+ const findDistRoot = (startDir) => {
14
+ let dir = startDir;
15
+ for (let i = 0; i < 12; i++) {
16
+ if (basename(dir) === "dist") return dir;
17
+ const parent = resolve(dir, "..");
18
+ if (parent === dir) break;
19
+ dir = parent;
20
+ }
21
+ return null;
22
+ };
23
+ const normalizeFrameFile = (file) => {
24
+ if (!file) return null;
25
+ try {
26
+ if (file.startsWith("file://")) return fileURLToPath(file);
27
+ } catch {}
28
+ return file;
29
+ };
30
+ /**
31
+ * Returns the directory of the *caller* module that invoked readAsset.
32
+ * Prefers non-virtual frames; falls back to the first real frame.
33
+ */
34
+ const getCallerDir = () => {
35
+ const prev = Error.prepareStackTrace;
36
+ try {
37
+ Error.prepareStackTrace = (_, structured) => structured;
38
+ const err = /* @__PURE__ */ new Error();
39
+ Error.captureStackTrace(err, getCallerDir);
40
+ /** @type {import('node:vm').CallSite[]} */
41
+ const frames = err.stack || [];
42
+ const isVirtualPath = (p) => p.includes(`${sep}_virtual${sep}`) || p.includes("/_virtual/");
43
+ for (const frame of frames) {
44
+ const file = normalizeFrameFile(typeof frame.getFileName === "function" ? frame.getFileName() : null);
45
+ if (!file) continue;
46
+ if (file.includes("node:internal") || file.includes(`${sep}internal${sep}modules${sep}`)) continue;
47
+ if (!isVirtualPath(file)) return dirname(file);
48
+ }
49
+ for (const frame of frames) {
50
+ const file = normalizeFrameFile(typeof frame.getFileName === "function" ? frame.getFileName() : null);
51
+ if (file) return dirname(file);
52
+ }
53
+ } catch {} finally {
54
+ Error.prepareStackTrace = prev;
55
+ }
56
+ return hereDirname();
57
+ };
58
+ /**
59
+ * Read an asset copied from src/** to dist/assets/**.
60
+ * - './' or '../' is resolved relative to the *caller module's* emitted directory.
61
+ * - otherwise, treat as src-relative.
62
+ *
63
+ * @param {string} relPath - e.g. './PROMPT.md' or 'utils/AI/askDocQuestion/embeddings/<fileKey>.json'
64
+ * @param {BufferEncoding} [encoding='utf8']
65
+ */
66
+ const readAsset = (relPath, encoding = "utf8") => {
67
+ const here = hereDirname();
68
+ const distRoot = findDistRoot(here) ?? resolve(here, "..", "..", "dist");
69
+ const assetsRoot = join(distRoot, "assets");
70
+ const tried = [];
71
+ /**
72
+ * Transform dist/(esm|cjs)/... and _virtual/ prefix to clean subpath (Windows-safe)
73
+ */
74
+ const callerSubpath = relative(distRoot, getCallerDir()).split("\\").join("/").replace(/^(?:dist\/)?(?:esm|cjs)\//, "").replace(/^_virtual\//, "");
75
+ if (relPath.startsWith("./") || relPath.startsWith("../")) {
76
+ const fromCallerAbs = resolve(assetsRoot, callerSubpath, relPath);
77
+ tried.push(fromCallerAbs);
78
+ if (existsSync(fromCallerAbs)) return readFileSync(fromCallerAbs, encoding);
79
+ }
80
+ const directPath = join(assetsRoot, relPath);
81
+ tried.push(directPath);
82
+ if (existsSync(directPath)) return readFileSync(directPath, encoding);
83
+ if (callerSubpath) {
84
+ const nested = join(assetsRoot, callerSubpath, relPath);
85
+ tried.push(nested);
86
+ if (existsSync(nested)) return readFileSync(nested, encoding);
87
+ }
88
+ const msg = [
89
+ "readAsset: file not found.",
90
+ "Searched:",
91
+ ...tried.map((p) => `- ${p}`)
92
+ ].join("\n");
93
+ throw new Error(msg);
94
+ };
95
+
96
+ //#endregion
97
+ export { readAsset };
@@ -1 +1,25 @@
1
- import{generateDictionaryListContent as e}from"./createDictionaryEntryPoint/generateDictionaryListContent.mjs";import{getBuiltDictionariesPath as t}from"./createDictionaryEntryPoint/getBuiltDictionariesPath.mjs";import{getBuiltDynamicDictionariesPath as n}from"./createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs";import{getBuiltFetchDictionariesPath as r}from"./createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs";import{getBuiltRemoteDictionariesPath as i}from"./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs";import{getBuiltUnmergedDictionariesPath as a}from"./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs";import{createDictionaryEntryPoint as o}from"./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";import{buildDictionary as s}from"./buildIntlayerDictionary/buildIntlayerDictionary.mjs";import{createModuleAugmentation as c,getTypeName as l}from"./createType/createModuleAugmentation.mjs";import{createTypes as u,generateTypeScriptType as d}from"./createType/createType.mjs";import{processContentDeclaration as f}from"./buildIntlayerDictionary/processContentDeclaration.mjs";import{ensureIntlayerBundle as p,formatLocalDictionaries as m,loadContentDeclaration as h,loadContentDeclarations as g}from"./loadDictionaries/loadContentDeclaration.mjs";import{loadLocalDictionaries as _}from"./loadDictionaries/loadLocalDictionaries.mjs";import{formatDictionaries as v,formatDictionariesOutput as y,formatDictionary as b,formatDictionaryOutput as x}from"./formatDictionary.mjs";import{formatDistantDictionaries as S,loadRemoteDictionaries as C}from"./loadDictionaries/loadRemoteDictionaries.mjs";import{loadDictionaries as w}from"./loadDictionaries/loadDictionaries.mjs";import{cleanOutputDir as T}from"./cleanOutputDir.mjs";import{isCachedConfigurationUpToDate as E,writeConfiguration as D}from"./writeConfiguration/index.mjs";import{prepareIntlayer as O}from"./prepareIntlayer.mjs";import{detectExportedComponentName as k}from"./writeContentDeclaration/detectExportedComponentName.mjs";import{transformJSFile as A}from"./writeContentDeclaration/transformJSFile.mjs";import{writeJSFile as j}from"./writeContentDeclaration/writeJSFile.mjs";import{writeContentDeclaration as M}from"./writeContentDeclaration/writeContentDeclaration.mjs";import"./writeContentDeclaration/index.mjs";import"./buildIntlayerDictionary/index.mjs";export{s as buildDictionary,T as cleanOutputDir,o as createDictionaryEntryPoint,c as createModuleAugmentation,u as createTypes,k as detectExportedComponentName,p as ensureIntlayerBundle,v as formatDictionaries,y as formatDictionariesOutput,b as formatDictionary,x as formatDictionaryOutput,S as formatDistantDictionaries,m as formatLocalDictionaries,e as generateDictionaryListContent,d as generateTypeScriptType,t as getBuiltDictionariesPath,n as getBuiltDynamicDictionariesPath,r as getBuiltFetchDictionariesPath,i as getBuiltRemoteDictionariesPath,a as getBuiltUnmergedDictionariesPath,l as getTypeName,E as isCachedConfigurationUpToDate,h as loadContentDeclaration,g as loadContentDeclarations,w as loadDictionaries,_ as loadLocalDictionaries,C as loadRemoteDictionaries,O as prepareIntlayer,f as processContentDeclaration,A as transformJSFile,D as writeConfiguration,M as writeContentDeclaration,j as writeJSFile};
1
+ import { generateDictionaryListContent } from "./createDictionaryEntryPoint/generateDictionaryListContent.mjs";
2
+ import { getBuiltDictionariesPath } from "./createDictionaryEntryPoint/getBuiltDictionariesPath.mjs";
3
+ import { getBuiltDynamicDictionariesPath } from "./createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs";
4
+ import { getBuiltFetchDictionariesPath } from "./createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs";
5
+ import { getBuiltRemoteDictionariesPath } from "./createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs";
6
+ import { getBuiltUnmergedDictionariesPath } from "./createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs";
7
+ import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint/createDictionaryEntryPoint.mjs";
8
+ import { buildDictionary } from "./buildIntlayerDictionary/buildIntlayerDictionary.mjs";
9
+ import { createModuleAugmentation, getTypeName } from "./createType/createModuleAugmentation.mjs";
10
+ import { createTypes, generateTypeScriptType } from "./createType/createType.mjs";
11
+ import { processContentDeclaration } from "./buildIntlayerDictionary/processContentDeclaration.mjs";
12
+ import { ensureIntlayerBundle, formatLocalDictionaries, loadContentDeclaration, loadContentDeclarations } from "./loadDictionaries/loadContentDeclaration.mjs";
13
+ import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
14
+ import { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput } from "./formatDictionary.mjs";
15
+ import { formatDistantDictionaries, loadRemoteDictionaries } from "./loadDictionaries/loadRemoteDictionaries.mjs";
16
+ import { loadDictionaries } from "./loadDictionaries/loadDictionaries.mjs";
17
+ import { cleanOutputDir } from "./cleanOutputDir.mjs";
18
+ import { isCachedConfigurationUpToDate, writeConfiguration } from "./writeConfiguration/index.mjs";
19
+ import { prepareIntlayer } from "./prepareIntlayer.mjs";
20
+ import { detectExportedComponentName } from "./writeContentDeclaration/detectExportedComponentName.mjs";
21
+ import { transformJSFile } from "./writeContentDeclaration/transformJSFile.mjs";
22
+ import { writeJSFile } from "./writeContentDeclaration/writeJSFile.mjs";
23
+ import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.mjs";
24
+
25
+ export { buildDictionary, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, ensureIntlayerBundle, formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput, formatDistantDictionaries, formatLocalDictionaries, generateDictionaryListContent, generateTypeScriptType, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getTypeName, isCachedConfigurationUpToDate, loadContentDeclaration, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, prepareIntlayer, processContentDeclaration, transformJSFile, writeConfiguration, writeContentDeclaration, writeJSFile };
@@ -1,2 +1,61 @@
1
- import{writeDynamicDictionary as e}from"./writeDynamicDictionary.mjs";import{writeFetchDictionary as t}from"./writeFetchDictionary.mjs";import{writeMergedDictionaries as n}from"./writeMergedDictionary.mjs";import{writeUnmergedDictionaries as r}from"./writeUnmergedDictionary.mjs";import{getUnmergedDictionaries as i}from"@intlayer/unmerged-dictionaries-entry";import{IMPORT_MODE as a,OUTPUT_FORMAT as o}from"@intlayer/config/defaultValues";const s={formats:o,importOtherDictionaries:!0,env:`dev`},c=async(o,c,l)=>{let u=c?.build?.importMode??c?.dictionary?.importMode??a,{importOtherDictionaries:d,env:f,formats:p}={...s,...l},m=[...o];if(d){let e=i(c);for(let t of o){let n=e[t.key];if(n?.length>0){let e=n.filter(e=>e.localId!==t.localId);m.push(...e)}}}let h=await r(m,c,f),g=await n(h,c),_={},v=new Set;for(let[e,t]of Object.entries(g)){let n=t.dictionary.importMode??u;(n===`dynamic`||n===`fetch`)&&(_[e]=t),n===`fetch`&&v.add(e)}let y=null;Object.keys(_).length>0&&(y=await e(_,c,p));let b=null;if(y&&v.size>0){let e={};for(let t of v)y[t]&&(e[t]=y[t]);Object.keys(e).length>0&&(b=await t(e,c,p))}return{unmergedDictionaries:h,mergedDictionaries:g,dynamicDictionaries:y,fetchDictionaries:b}};export{c as buildDictionary};
1
+ import { writeDynamicDictionary } from "./writeDynamicDictionary.mjs";
2
+ import { writeFetchDictionary } from "./writeFetchDictionary.mjs";
3
+ import { writeMergedDictionaries } from "./writeMergedDictionary.mjs";
4
+ import { writeUnmergedDictionaries } from "./writeUnmergedDictionary.mjs";
5
+ import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
6
+ import { IMPORT_MODE, OUTPUT_FORMAT } from "@intlayer/config/defaultValues";
7
+
8
+ //#region src/buildIntlayerDictionary/buildIntlayerDictionary.ts
9
+ const defaultOptions = {
10
+ formats: OUTPUT_FORMAT,
11
+ importOtherDictionaries: true,
12
+ env: "dev"
13
+ };
14
+ /**
15
+ * This function transpile the bundled code to to make dictionaries as JSON files
16
+ */
17
+ const buildDictionary = async (localDictionariesEntries, configuration, options) => {
18
+ const importMode = configuration?.build?.importMode ?? configuration?.dictionary?.importMode ?? IMPORT_MODE;
19
+ const { importOtherDictionaries, env, formats } = {
20
+ ...defaultOptions,
21
+ ...options
22
+ };
23
+ const unmergedDictionariesToUpdate = [...localDictionariesEntries];
24
+ if (importOtherDictionaries) {
25
+ const prevUnmergedDictionaries = getUnmergedDictionaries(configuration);
26
+ for (const dictionaryToWrite of localDictionariesEntries) {
27
+ const allPrebuiltUnmergedDictionaries = prevUnmergedDictionaries[dictionaryToWrite.key];
28
+ if (allPrebuiltUnmergedDictionaries?.length > 0) {
29
+ const otherUnmergedDictionaries = allPrebuiltUnmergedDictionaries.filter((unmergedDictionary) => unmergedDictionary.localId !== dictionaryToWrite.localId);
30
+ unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries);
31
+ }
32
+ }
33
+ }
34
+ const unmergedDictionaries = await writeUnmergedDictionaries(unmergedDictionariesToUpdate, configuration, env);
35
+ const mergedDictionaries = await writeMergedDictionaries(unmergedDictionaries, configuration);
36
+ const dictionariesToBuildDynamic = {};
37
+ const keysToBuildFetch = /* @__PURE__ */ new Set();
38
+ for (const [key, mergedResult] of Object.entries(mergedDictionaries)) {
39
+ const mode = mergedResult.dictionary.importMode ?? importMode;
40
+ if (mode === "dynamic" || mode === "fetch") dictionariesToBuildDynamic[key] = mergedResult;
41
+ if (mode === "fetch") keysToBuildFetch.add(key);
42
+ }
43
+ let dynamicDictionaries = null;
44
+ if (Object.keys(dictionariesToBuildDynamic).length > 0) dynamicDictionaries = await writeDynamicDictionary(dictionariesToBuildDynamic, configuration, formats);
45
+ let fetchDictionaries = null;
46
+ if (dynamicDictionaries && keysToBuildFetch.size > 0) {
47
+ const dictionariesToBuildFetch = {};
48
+ for (const key of keysToBuildFetch) if (dynamicDictionaries[key]) dictionariesToBuildFetch[key] = dynamicDictionaries[key];
49
+ if (Object.keys(dictionariesToBuildFetch).length > 0) fetchDictionaries = await writeFetchDictionary(dictionariesToBuildFetch, configuration, formats);
50
+ }
51
+ return {
52
+ unmergedDictionaries,
53
+ mergedDictionaries,
54
+ dynamicDictionaries,
55
+ fetchDictionaries
56
+ };
57
+ };
58
+
59
+ //#endregion
60
+ export { buildDictionary };
2
61
  //# sourceMappingURL=buildIntlayerDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildIntlayerDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { IMPORT_MODE, OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type LocalizedDictionaryOutput,\n writeDynamicDictionary,\n} from './writeDynamicDictionary';\nimport { writeFetchDictionary } from './writeFetchDictionary';\nimport { writeMergedDictionaries } from './writeMergedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\nexport type BuildDictionariesOptions = Partial<{\n formats: typeof OUTPUT_FORMAT;\n importOtherDictionaries: boolean;\n env: 'prod' | 'dev';\n}>;\n\nconst defaultOptions = {\n formats: OUTPUT_FORMAT,\n importOtherDictionaries: true,\n env: 'dev',\n} as const satisfies BuildDictionariesOptions;\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildDictionary = async (\n localDictionariesEntries: Dictionary[],\n configuration: IntlayerConfig,\n options?: BuildDictionariesOptions\n) => {\n const importMode =\n configuration?.build?.importMode ??\n configuration?.dictionary?.importMode ??\n IMPORT_MODE;\n\n const { importOtherDictionaries, env, formats } = {\n ...defaultOptions,\n ...options,\n };\n\n const unmergedDictionariesToUpdate: Dictionary[] = [\n ...localDictionariesEntries,\n ];\n\n if (importOtherDictionaries) {\n const prevUnmergedDictionaries: Record<string, Dictionary[]> =\n getUnmergedDictionaries(configuration);\n\n // Reinsert other dictionaries with the same key to avoid merging errors\n for (const dictionaryToWrite of localDictionariesEntries) {\n const allPrebuiltUnmergedDictionaries =\n prevUnmergedDictionaries[dictionaryToWrite.key];\n\n if (allPrebuiltUnmergedDictionaries?.length > 0) {\n // Do not add the same dictionary again by filtering out the one with the same localId\n const otherUnmergedDictionaries =\n allPrebuiltUnmergedDictionaries.filter(\n (unmergedDictionary) =>\n unmergedDictionary.localId !== dictionaryToWrite.localId\n );\n\n unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries);\n }\n }\n }\n\n const unmergedDictionaries = await writeUnmergedDictionaries(\n unmergedDictionariesToUpdate,\n configuration,\n env\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n const dictionariesToBuildDynamic: typeof mergedDictionaries = {};\n const keysToBuildFetch = new Set<string>();\n\n for (const [key, mergedResult] of Object.entries(mergedDictionaries)) {\n const dictionary = mergedResult.dictionary;\n const mode = dictionary.importMode ?? importMode;\n\n if (mode === 'dynamic' || mode === 'fetch') {\n dictionariesToBuildDynamic[key] = mergedResult;\n }\n\n if (mode === 'fetch') {\n keysToBuildFetch.add(key);\n }\n }\n\n let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (Object.keys(dictionariesToBuildDynamic).length > 0) {\n dynamicDictionaries = await writeDynamicDictionary(\n dictionariesToBuildDynamic,\n configuration,\n formats\n );\n }\n\n let fetchDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (dynamicDictionaries && keysToBuildFetch.size > 0) {\n const dictionariesToBuildFetch: LocalizedDictionaryOutput = {};\n\n for (const key of keysToBuildFetch) {\n if (dynamicDictionaries[key]) {\n dictionariesToBuildFetch[key] = dynamicDictionaries[key];\n }\n }\n\n if (Object.keys(dictionariesToBuildFetch).length > 0) {\n fetchDictionaries = await writeFetchDictionary(\n dictionariesToBuildFetch,\n configuration,\n formats\n );\n }\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":"wbAkBA,MAAM,EAAiB,CACrB,QAAS,EACT,wBAAyB,GACzB,IAAK,MACN,CAKY,EAAkB,MAC7B,EACA,EACA,IACG,CACH,IAAM,EACJ,GAAe,OAAO,YACtB,GAAe,YAAY,YAC3B,EAEI,CAAE,0BAAyB,MAAK,WAAY,CAChD,GAAG,EACH,GAAG,EACJ,CAEK,EAA6C,CACjD,GAAG,EACJ,CAED,GAAI,EAAyB,CAC3B,IAAM,EACJ,EAAwB,EAAc,CAGxC,IAAK,IAAM,KAAqB,EAA0B,CACxD,IAAM,EACJ,EAAyB,EAAkB,KAE7C,GAAI,GAAiC,OAAS,EAAG,CAE/C,IAAM,EACJ,EAAgC,OAC7B,GACC,EAAmB,UAAY,EAAkB,QACpD,CAEH,EAA6B,KAAK,GAAG,EAA0B,GAKrE,IAAM,EAAuB,MAAM,EACjC,EACA,EACA,EACD,CAEK,EAAqB,MAAM,EAC/B,EACA,EACD,CAEK,EAAwD,EAAE,CAC1D,EAAmB,IAAI,IAE7B,IAAK,GAAM,CAAC,EAAK,KAAiB,OAAO,QAAQ,EAAmB,CAAE,CAEpE,IAAM,EADa,EAAa,WACR,YAAc,GAElC,IAAS,WAAa,IAAS,WACjC,EAA2B,GAAO,GAGhC,IAAS,SACX,EAAiB,IAAI,EAAI,CAI7B,IAAI,EAAwD,KAExD,OAAO,KAAK,EAA2B,CAAC,OAAS,IACnD,EAAsB,MAAM,EAC1B,EACA,EACA,EACD,EAGH,IAAI,EAAsD,KAE1D,GAAI,GAAuB,EAAiB,KAAO,EAAG,CACpD,IAAM,EAAsD,EAAE,CAE9D,IAAK,IAAM,KAAO,EACZ,EAAoB,KACtB,EAAyB,GAAO,EAAoB,IAIpD,OAAO,KAAK,EAAyB,CAAC,OAAS,IACjD,EAAoB,MAAM,EACxB,EACA,EACA,EACD,EAIL,MAAO,CACL,uBACA,qBACA,sBACA,oBACD"}
1
+ {"version":3,"file":"buildIntlayerDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { IMPORT_MODE, OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n type LocalizedDictionaryOutput,\n writeDynamicDictionary,\n} from './writeDynamicDictionary';\nimport { writeFetchDictionary } from './writeFetchDictionary';\nimport { writeMergedDictionaries } from './writeMergedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\nexport type BuildDictionariesOptions = Partial<{\n formats: typeof OUTPUT_FORMAT;\n importOtherDictionaries: boolean;\n env: 'prod' | 'dev';\n}>;\n\nconst defaultOptions = {\n formats: OUTPUT_FORMAT,\n importOtherDictionaries: true,\n env: 'dev',\n} as const satisfies BuildDictionariesOptions;\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildDictionary = async (\n localDictionariesEntries: Dictionary[],\n configuration: IntlayerConfig,\n options?: BuildDictionariesOptions\n) => {\n const importMode =\n configuration?.build?.importMode ??\n configuration?.dictionary?.importMode ??\n IMPORT_MODE;\n\n const { importOtherDictionaries, env, formats } = {\n ...defaultOptions,\n ...options,\n };\n\n const unmergedDictionariesToUpdate: Dictionary[] = [\n ...localDictionariesEntries,\n ];\n\n if (importOtherDictionaries) {\n const prevUnmergedDictionaries: Record<string, Dictionary[]> =\n getUnmergedDictionaries(configuration);\n\n // Reinsert other dictionaries with the same key to avoid merging errors\n for (const dictionaryToWrite of localDictionariesEntries) {\n const allPrebuiltUnmergedDictionaries =\n prevUnmergedDictionaries[dictionaryToWrite.key];\n\n if (allPrebuiltUnmergedDictionaries?.length > 0) {\n // Do not add the same dictionary again by filtering out the one with the same localId\n const otherUnmergedDictionaries =\n allPrebuiltUnmergedDictionaries.filter(\n (unmergedDictionary) =>\n unmergedDictionary.localId !== dictionaryToWrite.localId\n );\n\n unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries);\n }\n }\n }\n\n const unmergedDictionaries = await writeUnmergedDictionaries(\n unmergedDictionariesToUpdate,\n configuration,\n env\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n const dictionariesToBuildDynamic: typeof mergedDictionaries = {};\n const keysToBuildFetch = new Set<string>();\n\n for (const [key, mergedResult] of Object.entries(mergedDictionaries)) {\n const dictionary = mergedResult.dictionary;\n const mode = dictionary.importMode ?? importMode;\n\n if (mode === 'dynamic' || mode === 'fetch') {\n dictionariesToBuildDynamic[key] = mergedResult;\n }\n\n if (mode === 'fetch') {\n keysToBuildFetch.add(key);\n }\n }\n\n let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (Object.keys(dictionariesToBuildDynamic).length > 0) {\n dynamicDictionaries = await writeDynamicDictionary(\n dictionariesToBuildDynamic,\n configuration,\n formats\n );\n }\n\n let fetchDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (dynamicDictionaries && keysToBuildFetch.size > 0) {\n const dictionariesToBuildFetch: LocalizedDictionaryOutput = {};\n\n for (const key of keysToBuildFetch) {\n if (dynamicDictionaries[key]) {\n dictionariesToBuildFetch[key] = dynamicDictionaries[key];\n }\n }\n\n if (Object.keys(dictionariesToBuildFetch).length > 0) {\n fetchDictionaries = await writeFetchDictionary(\n dictionariesToBuildFetch,\n configuration,\n formats\n );\n }\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":";;;;;;;;AAkBA,MAAM,iBAAiB;CACrB,SAAS;CACT,yBAAyB;CACzB,KAAK;CACN;;;;AAKD,MAAa,kBAAkB,OAC7B,0BACA,eACA,YACG;CACH,MAAM,aACJ,eAAe,OAAO,cACtB,eAAe,YAAY,cAC3B;CAEF,MAAM,EAAE,yBAAyB,KAAK,YAAY;EAChD,GAAG;EACH,GAAG;EACJ;CAED,MAAM,+BAA6C,CACjD,GAAG,yBACJ;AAED,KAAI,yBAAyB;EAC3B,MAAM,2BACJ,wBAAwB,cAAc;AAGxC,OAAK,MAAM,qBAAqB,0BAA0B;GACxD,MAAM,kCACJ,yBAAyB,kBAAkB;AAE7C,OAAI,iCAAiC,SAAS,GAAG;IAE/C,MAAM,4BACJ,gCAAgC,QAC7B,uBACC,mBAAmB,YAAY,kBAAkB,QACpD;AAEH,iCAA6B,KAAK,GAAG,0BAA0B;;;;CAKrE,MAAM,uBAAuB,MAAM,0BACjC,8BACA,eACA,IACD;CAED,MAAM,qBAAqB,MAAM,wBAC/B,sBACA,cACD;CAED,MAAM,6BAAwD,EAAE;CAChE,MAAM,mCAAmB,IAAI,KAAa;AAE1C,MAAK,MAAM,CAAC,KAAK,iBAAiB,OAAO,QAAQ,mBAAmB,EAAE;EAEpE,MAAM,OADa,aAAa,WACR,cAAc;AAEtC,MAAI,SAAS,aAAa,SAAS,QACjC,4BAA2B,OAAO;AAGpC,MAAI,SAAS,QACX,kBAAiB,IAAI,IAAI;;CAI7B,IAAI,sBAAwD;AAE5D,KAAI,OAAO,KAAK,2BAA2B,CAAC,SAAS,EACnD,uBAAsB,MAAM,uBAC1B,4BACA,eACA,QACD;CAGH,IAAI,oBAAsD;AAE1D,KAAI,uBAAuB,iBAAiB,OAAO,GAAG;EACpD,MAAM,2BAAsD,EAAE;AAE9D,OAAK,MAAM,OAAO,iBAChB,KAAI,oBAAoB,KACtB,0BAAyB,OAAO,oBAAoB;AAIxD,MAAI,OAAO,KAAK,yBAAyB,CAAC,SAAS,EACjD,qBAAoB,MAAM,qBACxB,0BACA,eACA,QACD;;AAIL,QAAO;EACL;EACA;EACA;EACA;EACD"}
@@ -1 +1,4 @@
1
- import{buildDictionary as e}from"./buildIntlayerDictionary.mjs";import{processContentDeclaration as t}from"./processContentDeclaration.mjs";export{e as buildDictionary,t as processContentDeclaration};
1
+ import { buildDictionary } from "./buildIntlayerDictionary.mjs";
2
+ import { processContentDeclaration } from "./processContentDeclaration.mjs";
3
+
4
+ export { buildDictionary, processContentDeclaration };
@@ -1,2 +1,25 @@
1
- import{autoDecorateContent as e}from"../utils/autoDecorateContent.mjs";import{resolveObjectPromises as t}from"../utils/resolveObjectPromises.mjs";import{logger as n}from"@intlayer/config/logger";const r=async(r,i)=>{try{let n=await t(r.content),a=r.contentAutoTransformation??i.dictionary?.contentAutoTransformation??!1,o=a?e(n,a):n;return{...r,content:o}}catch(e){n(e,{level:`error`})}};export{r as processContentDeclaration};
1
+ import { autoDecorateContent } from "../utils/autoDecorateContent.mjs";
2
+ import { resolveObjectPromises } from "../utils/resolveObjectPromises.mjs";
3
+ import { logger } from "@intlayer/config/logger";
4
+
5
+ //#region src/buildIntlayerDictionary/processContentDeclaration.ts
6
+ /**
7
+ * Function to load, process the module and return the Intlayer Dictionary from the module file
8
+ */
9
+ const processContentDeclaration = async (contentDeclaration, configuration) => {
10
+ try {
11
+ const resolvedContent = await resolveObjectPromises(contentDeclaration.content);
12
+ const isAutoDecorateContentEnabled = contentDeclaration.contentAutoTransformation ?? configuration.dictionary?.contentAutoTransformation ?? false;
13
+ const decoratedContent = isAutoDecorateContentEnabled ? autoDecorateContent(resolvedContent, isAutoDecorateContentEnabled) : resolvedContent;
14
+ return {
15
+ ...contentDeclaration,
16
+ content: decoratedContent
17
+ };
18
+ } catch (error) {
19
+ logger(error, { level: "error" });
20
+ }
21
+ };
22
+
23
+ //#endregion
24
+ export { processContentDeclaration };
2
25
  //# sourceMappingURL=processContentDeclaration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"processContentDeclaration.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/logger';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { autoDecorateContent } from '../utils/autoDecorateContent';\nimport { resolveObjectPromises } from '../utils/resolveObjectPromises';\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary,\n configuration: IntlayerConfig\n): Promise<Dictionary | undefined> => {\n try {\n const resolvedContent = (await resolveObjectPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n const isAutoDecorateContentEnabled =\n contentDeclaration.contentAutoTransformation ??\n configuration.dictionary?.contentAutoTransformation ??\n false;\n\n const decoratedContent = isAutoDecorateContentEnabled\n ? autoDecorateContent(resolvedContent, isAutoDecorateContentEnabled)\n : resolvedContent;\n\n return {\n ...contentDeclaration,\n content: decoratedContent,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":"mMASA,MAAa,EAA4B,MACvC,EACA,IACoC,CACpC,GAAI,CACF,IAAM,EAAmB,MAAM,EAC7B,EAAmB,QACpB,CAEK,EACJ,EAAmB,2BACnB,EAAc,YAAY,2BAC1B,GAEI,EAAmB,EACrB,EAAoB,EAAiB,EAA6B,CAClE,EAEJ,MAAO,CACL,GAAG,EACH,QAAS,EACV,OACM,EAAO,CACd,EAAO,EAAO,CACZ,MAAO,QACR,CAAC"}
1
+ {"version":3,"file":"processContentDeclaration.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/logger';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { autoDecorateContent } from '../utils/autoDecorateContent';\nimport { resolveObjectPromises } from '../utils/resolveObjectPromises';\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary,\n configuration: IntlayerConfig\n): Promise<Dictionary | undefined> => {\n try {\n const resolvedContent = (await resolveObjectPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n const isAutoDecorateContentEnabled =\n contentDeclaration.contentAutoTransformation ??\n configuration.dictionary?.contentAutoTransformation ??\n false;\n\n const decoratedContent = isAutoDecorateContentEnabled\n ? autoDecorateContent(resolvedContent, isAutoDecorateContentEnabled)\n : resolvedContent;\n\n return {\n ...contentDeclaration,\n content: decoratedContent,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;AASA,MAAa,4BAA4B,OACvC,oBACA,kBACoC;AACpC,KAAI;EACF,MAAM,kBAAmB,MAAM,sBAC7B,mBAAmB,QACpB;EAED,MAAM,+BACJ,mBAAmB,6BACnB,cAAc,YAAY,6BAC1B;EAEF,MAAM,mBAAmB,+BACrB,oBAAoB,iBAAiB,6BAA6B,GAClE;AAEJ,SAAO;GACL,GAAG;GACH,SAAS;GACV;UACM,OAAO;AACd,SAAO,OAAO,EACZ,OAAO,SACR,CAAC"}
@@ -1,6 +1,103 @@
1
- import{parallelize as e}from"../utils/parallelize.mjs";import{writeFileIfChanged as t}from"../writeFileIfChanged.mjs";import{writeJsonIfChanged as n}from"../writeJsonIfChanged.mjs";import{mkdir as r}from"node:fs/promises";import{resolve as i}from"node:path";import{colorizePath as a}from"@intlayer/config/logger";import{OUTPUT_FORMAT as o}from"@intlayer/config/defaultValues";import{getPerLocaleDictionary as s}from"@intlayer/core/plugins";const c=`json`,l=`_loadjson`,u=(e,t,n,r=`esm`)=>{let i=Object.keys(t).sort((e,t)=>String(e).localeCompare(String(t))).map(e=>` '${e}': () => loadContent('${n}', '${e}')`).join(`,
2
- `),a=e;return a+=`const content = {\n${i}\n};\n\n`,r===`esm`&&(a+=`export default content;
3
- `),r===`cjs`&&(a+=`module.exports = content;
4
- `),a},d=(e,t)=>{let n=`const loadContent = (key) => ({\n${[...t].sort((e,t)=>String(e).localeCompare(String(t))).map(t=>e===`esm`?` '${t}': () => import(\`./${c}/\${key}/${t}.json\`).then(m => m.default)`:` '${t}': () => Promise.resolve(require(\`./${c}/\${key}/${t}.json\`))`).join(`,
5
- `)}\n});\n`;return e===`esm`?`${n}\nexport { loadContent };\n`:`${n}\nmodule.exports = { loadContent };\n`},f=(e,t=`esm`)=>{let n=t===`cjs`?`cjs`:`mjs`;return t===`esm`?`import { loadContent } from './${l}.${n}';\n\nconst content = loadContent('${e}');\n\nexport default content;\n`:`const { loadContent } = require('./${l}.${n}');\n\nmodule.exports = loadContent('${e}');\n`},p=async(u,p,m=o)=>{let{locales:h,defaultLocale:g}=p.internationalization,{dynamicDictionariesDir:_}=p.system,v=i(_,c);await r(v,{recursive:!0}),await e(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t(i(_,`${l}.${n}`),d(e,h)).catch(e=>{console.error(`Error creating dynamic ${a(i(_,`${l}.${n}`))}:`,e)})});let y={};return await e(Object.entries(u).sort(([e],[t])=>String(e).localeCompare(String(t))),async([o,c])=>{if(o===`undefined`)return;let l={},u=i(v,o);await r(u,{recursive:!0}),await e(h,async e=>{let t=s(c.dictionary,e,g),r=i(u,`${e}.json`);await n(r,t).catch(t=>{console.error(`Error creating localized ${o}/${e}.json:`,t)}),l[e]={dictionaryPath:r,dictionary:t}}),y[o]=l,await e(m,async e=>{let n=e===`cjs`?`cjs`:`mjs`,r=f(o,e);await t(i(_,`${o}.${n}`),r).catch(e=>{console.error(`Error creating dynamic ${a(i(_,`${o}.${n}`))}:`,e)})})}),y};export{u as buildEntryPointContent,f as generateDictionaryEntryPoint,d as generateDynamicLoadContentModule,p as writeDynamicDictionary};
1
+ import { parallelize } from "../utils/parallelize.mjs";
2
+ import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
3
+ import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
4
+ import { mkdir } from "node:fs/promises";
5
+ import { resolve } from "node:path";
6
+ import { colorizePath } from "@intlayer/config/logger";
7
+ import { OUTPUT_FORMAT } from "@intlayer/config/defaultValues";
8
+ import { getPerLocaleDictionary } from "@intlayer/core/plugins";
9
+
10
+ //#region src/buildIntlayerDictionary/writeDynamicDictionary.ts
11
+ const DICTIONARIES_SUBDIR = "json";
12
+ const LOAD_CONTENT_MODULE = "_loadjson";
13
+ /**
14
+ * Assembles the entry point file content from a pre-built preamble (import/require line),
15
+ * the locale→path record, the dictionary key, and the output format.
16
+ * Shared by all dictionary entry point generators.
17
+ */
18
+ const buildEntryPointContent = (preamble, localizedDictionariesPathsRecord, key, format = "esm") => {
19
+ const formattedDictionaryMap = Object.keys(localizedDictionariesPathsRecord).sort((a, b) => String(a).localeCompare(String(b))).map((locale) => ` '${locale}': () => loadContent('${key}', '${locale}')`).join(",\n");
20
+ let content = preamble;
21
+ content += `const content = {\n${formattedDictionaryMap}\n};\n\n`;
22
+ if (format === "esm") content += `export default content;\n`;
23
+ if (format === "cjs") content += `module.exports = content;\n`;
24
+ return content;
25
+ };
26
+ /**
27
+ * Generates the content of the shared `loadContent` module written once per
28
+ * output directory. Locales are baked in so each dynamic import has only one
29
+ * variable (`key`), making it statically analyzable by Vite/Rollup.
30
+ */
31
+ const generateDynamicLoadContentModule = (format, locales) => {
32
+ const body = `const loadContent = (key) => ({\n${[...locales].sort((a, b) => String(a).localeCompare(String(b))).map((locale) => format === "esm" ? ` '${locale}': () => import(\`./${DICTIONARIES_SUBDIR}/\${key}/${locale}.json\`).then(m => m.default)` : ` '${locale}': () => Promise.resolve(require(\`./${DICTIONARIES_SUBDIR}/\${key}/${locale}.json\`))`).join(",\n")}\n});\n`;
33
+ if (format === "esm") return `${body}\nexport { loadContent };\n`;
34
+ return `${body}\nmodule.exports = { loadContent };\n`;
35
+ };
36
+ /**
37
+ * Generates the content of a dictionary entry point file.
38
+ * `loadContent` is imported from the shared module and called with the key.
39
+ */
40
+ const generateDictionaryEntryPoint = (key, format = "esm") => {
41
+ const extension = format === "cjs" ? "cjs" : "mjs";
42
+ if (format === "esm") return `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\n\nconst content = loadContent('${key}');\n\nexport default content;\n`;
43
+ return `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\n\nmodule.exports = loadContent('${key}');\n`;
44
+ };
45
+ /**
46
+ * Write the localized dictionaries to the dictionariesDir
47
+ * @param mergedDictionaries - The merged dictionaries
48
+ * @param configuration - The configuration
49
+ * @returns The final dictionaries
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
54
+ * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
55
+ * console.log(finalDictionaries);
56
+ *
57
+ * // .intlayer/dynamic_dictionary/dictionaries/en_home.json
58
+ * // .intlayer/dynamic_dictionary/dictionaries/fr_home.json
59
+ * ```
60
+ */
61
+ const writeDynamicDictionary = async (mergedDictionaries, configuration, formats = OUTPUT_FORMAT) => {
62
+ const { locales, defaultLocale } = configuration.internationalization;
63
+ const { dynamicDictionariesDir } = configuration.system;
64
+ const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);
65
+ await mkdir(dictDir, { recursive: true });
66
+ await parallelize(formats, async (format) => {
67
+ const extension = format === "cjs" ? "cjs" : "mjs";
68
+ await writeFileIfChanged(resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`), generateDynamicLoadContentModule(format, locales)).catch((err) => {
69
+ console.error(`Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`, err);
70
+ });
71
+ });
72
+ const resultDictionariesPaths = {};
73
+ await parallelize(Object.entries(mergedDictionaries).sort(([a], [b]) => String(a).localeCompare(String(b))), async ([key, dictionaryEntry]) => {
74
+ if (key === "undefined") return;
75
+ const localizedDictionariesPathsRecord = {};
76
+ const keyDir = resolve(dictDir, key);
77
+ await mkdir(keyDir, { recursive: true });
78
+ await parallelize(locales, async (locale) => {
79
+ const localizedDictionary = getPerLocaleDictionary(dictionaryEntry.dictionary, locale, defaultLocale);
80
+ const resultFilePath = resolve(keyDir, `${locale}.json`);
81
+ await writeJsonIfChanged(resultFilePath, localizedDictionary).catch((err) => {
82
+ console.error(`Error creating localized ${key}/${locale}.json:`, err);
83
+ });
84
+ localizedDictionariesPathsRecord[locale] = {
85
+ dictionaryPath: resultFilePath,
86
+ dictionary: localizedDictionary
87
+ };
88
+ });
89
+ resultDictionariesPaths[key] = localizedDictionariesPathsRecord;
90
+ await parallelize(formats, async (format) => {
91
+ const extension = format === "cjs" ? "cjs" : "mjs";
92
+ const content = generateDictionaryEntryPoint(key, format);
93
+ await writeFileIfChanged(resolve(dynamicDictionariesDir, `${key}.${extension}`), content).catch((err) => {
94
+ console.error(`Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`, err);
95
+ });
96
+ });
97
+ });
98
+ return resultDictionariesPaths;
99
+ };
100
+
101
+ //#endregion
102
+ export { buildEntryPointContent, generateDictionaryEntryPoint, generateDynamicLoadContentModule, writeDynamicDictionary };
6
103
  //# sourceMappingURL=writeDynamicDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeDynamicDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locale, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\nconst DICTIONARIES_SUBDIR = 'json'; // Necessary to add a static first dir for Turbopack\nconst LOAD_CONTENT_MODULE = '_loadjson';\n\n/**\n * Assembles the entry point file content from a pre-built preamble (import/require line),\n * the locale→path record, the dictionary key, and the output format.\n * Shared by all dictionary entry point generators.\n */\nexport const buildEntryPointContent = (\n preamble: string,\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const formattedDictionaryMap: string = Object.keys(\n localizedDictionariesPathsRecord\n )\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map((locale) => ` '${locale}': () => loadContent('${key}', '${locale}')`)\n .join(',\\n');\n\n let content = preamble;\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n\\n`;\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Generates the content of the shared `loadContent` module written once per\n * output directory. Locales are baked in so each dynamic import has only one\n * variable (`key`), making it statically analyzable by Vite/Rollup.\n */\nexport const generateDynamicLoadContentModule = (\n format: 'cjs' | 'esm',\n locales: string[]\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n\n const localeEntries = sortedLocales\n .map((locale) =>\n format === 'esm'\n ? ` '${locale}': () => import(\\`./${DICTIONARIES_SUBDIR}/\\${key}/${locale}.json\\`).then(m => m.default)`\n : ` '${locale}': () => Promise.resolve(require(\\`./${DICTIONARIES_SUBDIR}/\\${key}/${locale}.json\\`))`\n )\n .join(',\\n');\n\n const body = `const loadContent = (key) => ({\\n${localeEntries}\\n});\\n`;\n\n if (format === 'esm') return `${body}\\nexport { loadContent };\\n`;\n return `${body}\\nmodule.exports = { loadContent };\\n`;\n};\n\n/**\n * Generates the content of a dictionary entry point file.\n * `loadContent` is imported from the shared module and called with the key.\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/dynamic_dictionary/dictionaries/en_home.json\n * // .intlayer/dynamic_dictionary/dictionaries/fr_home.json\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: MergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n await mkdir(dictDir, { recursive: true });\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateDynamicLoadContentModule(format, locales)\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n Object.entries(mergedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, dictionaryEntry]) => {\n if (key === 'undefined') return;\n\n const localizedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n const keyDir = resolve(dictDir, key);\n await mkdir(keyDir, { recursive: true });\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n // Directory structure: json/key/locale.json\n const resultFilePath = resolve(keyDir, `${locale}.json`);\n\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(\n `Error creating localized ${key}/${locale}.json:`,\n err\n );\n }\n );\n\n localizedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n });\n\n resultDictionariesPaths[key] = localizedDictionariesPathsRecord;\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(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"wbA2BA,MAAM,EAAsB,OACtB,EAAsB,YAOf,GACX,EACA,EACA,EACA,EAAwB,QACb,CACX,IAAM,EAAiC,OAAO,KAC5C,EACD,CACE,MAAM,EAAG,IAAM,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CAClD,IAAK,GAAW,MAAM,EAAO,wBAAwB,EAAI,MAAM,EAAO,IAAI,CAC1E,KAAK;EAAM,CAEV,EAAU,EAKd,MAJA,IAAW,sBAAsB,EAAuB,UACpD,IAAW,QAAO,GAAW;GAC7B,IAAW,QAAO,GAAW;GAE1B,GAQI,GACX,EACA,IACW,CAaX,IAAM,EAAO,oCAZS,CAAC,GAAG,EAAQ,CAAC,MAAM,EAAG,IAC1C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,CAGE,IAAK,GACJ,IAAW,MACP,MAAM,EAAO,sBAAsB,EAAoB,WAAW,EAAO,+BACzE,MAAM,EAAO,uCAAuC,EAAoB,WAAW,EAAO,WAC/F,CACA,KAAK;EAAM,CAEiD,SAG/D,OADI,IAAW,MAAc,GAAG,EAAK,6BAC9B,GAAG,EAAK,wCAOJ,GACX,EACA,EAAwB,QACb,CACX,IAAM,EAAY,IAAW,MAAQ,MAAQ,MAQ7C,OAPI,IAAW,MAEX,kCAAkC,EAAoB,GAAG,EAAU,qCACnC,EAAI,kCAKtC,sCAAsC,EAAoB,GAAG,EAAU,uCACtC,EAAI,QAoB5B,EAAyB,MACpC,EACA,EACA,EAA6B,IACU,CACvC,GAAM,CAAE,UAAS,iBAAkB,EAAc,qBAC3C,CAAE,0BAA2B,EAAc,OAE3C,EAAU,EAAQ,EAAwB,EAAoB,CACpE,MAAM,EAAM,EAAS,CAAE,UAAW,GAAM,CAAC,CACzC,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MAC7C,MAAM,EACJ,EAAQ,EAAwB,GAAG,EAAoB,GAAG,IAAY,CACtE,EAAiC,EAAQ,EAAQ,CAClD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,0BAA0B,EAAa,EAAQ,EAAwB,GAAG,EAAoB,GAAG,IAAY,CAAC,CAAC,GAC/G,EACD,EACD,EACF,CAEF,IAAM,EAAqD,EAAE,CA2D7D,OAxDA,MAAM,EACJ,OAAO,QAAQ,EAAmB,CAAC,MAAM,CAAC,GAAI,CAAC,KAC7C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,CACD,MAAO,CAAC,EAAK,KAAqB,CAChC,GAAI,IAAQ,YAAa,OAEzB,IAAM,EAA8D,EAAE,CAEhE,EAAS,EAAQ,EAAS,EAAI,CACpC,MAAM,EAAM,EAAQ,CAAE,UAAW,GAAM,CAAC,CAExC,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAsB,EAC1B,EAAgB,WAChB,EACA,EACD,CAGK,EAAiB,EAAQ,EAAQ,GAAG,EAAO,OAAO,CAExD,MAAM,EAAmB,EAAgB,EAAoB,CAAC,MAC3D,GAAQ,CACP,QAAQ,MACN,4BAA4B,EAAI,GAAG,EAAO,QAC1C,EACD,EAEJ,CAED,EAAiC,GAAU,CACzC,eAAgB,EAChB,WAAY,EACb,EACD,CAEF,EAAwB,GAAO,EAE/B,MAAM,EAAY,EAAS,KAAO,IAAW,CAC3C,IAAM,EAAY,IAAW,MAAQ,MAAQ,MACvC,EAAU,EAA6B,EAAK,EAAO,CAEzD,MAAM,EACJ,EAAQ,EAAwB,GAAG,EAAI,GAAG,IAAY,CACtD,EACD,CAAC,MAAO,GAAQ,CACf,QAAQ,MACN,0BAA0B,EAAa,EAAQ,EAAwB,GAAG,EAAI,GAAG,IAAY,CAAC,CAAC,GAC/F,EACD,EACD,EACF,EAEL,CAEM"}
1
+ {"version":3,"file":"writeDynamicDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { getPerLocaleDictionary } from '@intlayer/core/plugins';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { MergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locale, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\nconst DICTIONARIES_SUBDIR = 'json'; // Necessary to add a static first dir for Turbopack\nconst LOAD_CONTENT_MODULE = '_loadjson';\n\n/**\n * Assembles the entry point file content from a pre-built preamble (import/require line),\n * the locale→path record, the dictionary key, and the output format.\n * Shared by all dictionary entry point generators.\n */\nexport const buildEntryPointContent = (\n preamble: string,\n localizedDictionariesPathsRecord: LocalizedDictionaryResult,\n key: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const formattedDictionaryMap: string = Object.keys(\n localizedDictionariesPathsRecord\n )\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map((locale) => ` '${locale}': () => loadContent('${key}', '${locale}')`)\n .join(',\\n');\n\n let content = preamble;\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n\\n`;\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Generates the content of the shared `loadContent` module written once per\n * output directory. Locales are baked in so each dynamic import has only one\n * variable (`key`), making it statically analyzable by Vite/Rollup.\n */\nexport const generateDynamicLoadContentModule = (\n format: 'cjs' | 'esm',\n locales: string[]\n): string => {\n const sortedLocales = [...locales].sort((a, b) =>\n String(a).localeCompare(String(b))\n );\n\n const localeEntries = sortedLocales\n .map((locale) =>\n format === 'esm'\n ? ` '${locale}': () => import(\\`./${DICTIONARIES_SUBDIR}/\\${key}/${locale}.json\\`).then(m => m.default)`\n : ` '${locale}': () => Promise.resolve(require(\\`./${DICTIONARIES_SUBDIR}/\\${key}/${locale}.json\\`))`\n )\n .join(',\\n');\n\n const body = `const loadContent = (key) => ({\\n${localeEntries}\\n});\\n`;\n\n if (format === 'esm') return `${body}\\nexport { loadContent };\\n`;\n return `${body}\\nmodule.exports = { loadContent };\\n`;\n};\n\n/**\n * Generates the content of a dictionary entry point file.\n * `loadContent` is imported from the shared module and called with the key.\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/dynamic_dictionary/dictionaries/en_home.json\n * // .intlayer/dynamic_dictionary/dictionaries/fr_home.json\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: MergedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.system;\n\n const dictDir = resolve(dynamicDictionariesDir, DICTIONARIES_SUBDIR);\n await mkdir(dictDir, { recursive: true });\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`),\n generateDynamicLoadContentModule(format, locales)\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`,\n err\n );\n });\n });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n Object.entries(mergedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, dictionaryEntry]) => {\n if (key === 'undefined') return;\n\n const localizedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n const keyDir = resolve(dictDir, key);\n await mkdir(keyDir, { recursive: true });\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = getPerLocaleDictionary(\n dictionaryEntry.dictionary,\n locale,\n defaultLocale\n );\n\n // Directory structure: json/key/locale.json\n const resultFilePath = resolve(keyDir, `${locale}.json`);\n\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(\n `Error creating localized ${key}/${locale}.json:`,\n err\n );\n }\n );\n\n localizedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n });\n\n resultDictionariesPaths[key] = localizedDictionariesPathsRecord;\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(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;;;;;;AAO5B,MAAa,0BACX,UACA,kCACA,KACA,SAAwB,UACb;CACX,MAAM,yBAAiC,OAAO,KAC5C,iCACD,CACE,MAAM,GAAG,MAAM,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CAClD,KAAK,WAAW,MAAM,OAAO,wBAAwB,IAAI,MAAM,OAAO,IAAI,CAC1E,KAAK,MAAM;CAEd,IAAI,UAAU;AACd,YAAW,sBAAsB,uBAAuB;AACxD,KAAI,WAAW,MAAO,YAAW;AACjC,KAAI,WAAW,MAAO,YAAW;AAEjC,QAAO;;;;;;;AAQT,MAAa,oCACX,QACA,YACW;CAaX,MAAM,OAAO,oCAZS,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,MAC1C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,CAGE,KAAK,WACJ,WAAW,QACP,MAAM,OAAO,sBAAsB,oBAAoB,WAAW,OAAO,iCACzE,MAAM,OAAO,uCAAuC,oBAAoB,WAAW,OAAO,WAC/F,CACA,KAAK,MAAM,CAEiD;AAE/D,KAAI,WAAW,MAAO,QAAO,GAAG,KAAK;AACrC,QAAO,GAAG,KAAK;;;;;;AAOjB,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,yBAAyB,OACpC,oBACA,eACA,UAA6B,kBACU;CACvC,MAAM,EAAE,SAAS,kBAAkB,cAAc;CACjD,MAAM,EAAE,2BAA2B,cAAc;CAEjD,MAAM,UAAU,QAAQ,wBAAwB,oBAAoB;AACpE,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;AACzC,OAAM,YAAY,SAAS,OAAO,WAAW;EAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,QAAM,mBACJ,QAAQ,wBAAwB,GAAG,oBAAoB,GAAG,YAAY,EACtE,iCAAiC,QAAQ,QAAQ,CAClD,CAAC,OAAO,QAAQ;AACf,WAAQ,MACN,0BAA0B,aAAa,QAAQ,wBAAwB,GAAG,oBAAoB,GAAG,YAAY,CAAC,CAAC,IAC/G,IACD;IACD;GACF;CAEF,MAAM,0BAAqD,EAAE;AAG7D,OAAM,YACJ,OAAO,QAAQ,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,OAC7C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CACnC,EACD,OAAO,CAAC,KAAK,qBAAqB;AAChC,MAAI,QAAQ,YAAa;EAEzB,MAAM,mCAA8D,EAAE;EAEtE,MAAM,SAAS,QAAQ,SAAS,IAAI;AACpC,QAAM,MAAM,QAAQ,EAAE,WAAW,MAAM,CAAC;AAExC,QAAM,YAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,sBAAsB,uBAC1B,gBAAgB,YAChB,QACA,cACD;GAGD,MAAM,iBAAiB,QAAQ,QAAQ,GAAG,OAAO,OAAO;AAExD,SAAM,mBAAmB,gBAAgB,oBAAoB,CAAC,OAC3D,QAAQ;AACP,YAAQ,MACN,4BAA4B,IAAI,GAAG,OAAO,SAC1C,IACD;KAEJ;AAED,oCAAiC,UAAU;IACzC,gBAAgB;IAChB,YAAY;IACb;IACD;AAEF,0BAAwB,OAAO;AAE/B,QAAM,YAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BAA6B,KAAK,OAAO;AAEzD,SAAM,mBACJ,QAAQ,wBAAwB,GAAG,IAAI,GAAG,YAAY,EACtD,QACD,CAAC,OAAO,QAAQ;AACf,YAAQ,MACN,0BAA0B,aAAa,QAAQ,wBAAwB,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,IAC/F,IACD;KACD;IACF;GAEL;AAED,QAAO"}
@@ -1,5 +1,78 @@
1
- import{parallelize as e}from"../utils/parallelize.mjs";import{writeFileIfChanged as t}from"../writeFileIfChanged.mjs";import{mkdir as n}from"node:fs/promises";import{relative as r,resolve as i}from"node:path";import{colorizePath as a}from"@intlayer/config/logger";import{normalizePath as o}from"@intlayer/config/utils";import{OUTPUT_FORMAT as s}from"@intlayer/config/defaultValues";const c=`_loadjson`,l=(e,t,n)=>{let r=[...n].sort((e,t)=>String(e).localeCompare(String(t))),i=e===`cjs`?`cjs`:`mjs`,a=`const loadContent = (key) => {
1
+ import { parallelize } from "../utils/parallelize.mjs";
2
+ import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
3
+ import { mkdir } from "node:fs/promises";
4
+ import { relative, resolve } from "node:path";
5
+ import { colorizePath } from "@intlayer/config/logger";
6
+ import { normalizePath } from "@intlayer/config/utils";
7
+ import { OUTPUT_FORMAT } from "@intlayer/config/defaultValues";
8
+
9
+ //#region src/buildIntlayerDictionary/writeFetchDictionary.ts
10
+ const LOAD_CONTENT_MODULE = "_loadjson";
11
+ /**
12
+ * Generates the content of the shared `loadContent` module for fetch dictionaries.
13
+ * - `configuration` is imported at runtime from "intlayer" (liveSyncURL not baked in).
14
+ * - Fallback delegates to the dynamic dictionary's `_loadjson` module.
15
+ * - Locales are baked in so each entry is a static function referencing one locale.
16
+ */
17
+ const generateFetchLoadContentModule = (format, relativePrefix, locales) => {
18
+ const sortedLocales = [...locales].sort((a, b) => String(a).localeCompare(String(b)));
19
+ const extension = format === "cjs" ? "cjs" : "mjs";
20
+ const body = `const loadContent = (key) => {
2
21
  const dynContent = loadContentDyn(key);
3
- return {\n${r.map(e=>` '${e}': async () => {\n try {\n const res = await fetch(\`\${configuration.editor.liveSyncURL}/dictionaries/\${key}/${e}\`);\n return await res.json();\n } catch {\n return dynContent['${e}']();\n }\n }`).join(`,
4
- `)}\n };\n};\n`;return e===`esm`?`import { configuration } from 'intlayer';\nimport { loadContent as loadContentDyn } from '${t}/${c}.${i}';\n\n${a}\nexport { loadContent };\n`:`const { configuration } = require('intlayer');\nconst { loadContent: loadContentDyn } = require('${t}/${c}.${i}');\n\n${a}\nmodule.exports = { loadContent };\n`},u=(e,t=`esm`)=>{let n=t===`cjs`?`cjs`:`mjs`;return t===`esm`?`import { loadContent } from './${c}.${n}';\n\nconst content = loadContent('${e}');\n\nexport default content;\n`:`const { loadContent } = require('./${c}.${n}');\n\nmodule.exports = loadContent('${e}');\n`},d=async(d,f,p=s)=>{let{fetchDictionariesDir:m,dynamicDictionariesDir:h}=f.system,{locales:g}=f.internationalization,_=o(r(m,h));return _.startsWith(`.`)||(_=`./${_}`),await n(i(m),{recursive:!0}),await e(p,async e=>{let n=e===`cjs`?`cjs`:`mjs`;await t(i(m,`${c}.${n}`),l(e,_,g)).catch(e=>{console.error(`Error creating fetch ${a(i(m,`${c}.${n}`))}:`,e)})}),await e(Object.entries(d),async([n])=>{n!==`undefined`&&await e(p,async e=>{let r=e===`cjs`?`cjs`:`mjs`,o=u(n,e);await t(i(m,`${n}.${r}`),o).catch(e=>{console.error(`Error creating fetch ${a(i(m,`${n}.${r}`))}:`,e)})})}),{}};export{u as generateDictionaryEntryPoint,l as generateFetchLoadContentModule,d as writeFetchDictionary};
22
+ return {\n${sortedLocales.map((locale) => ` '${locale}': async () => {\n try {\n const res = await fetch(\`\${configuration.editor.liveSyncURL}/dictionaries/\${key}/${locale}\`);\n return await res.json();\n } catch {\n return dynContent['${locale}']();\n }\n }`).join(",\n")}\n };\n};\n`;
23
+ if (format === "esm") return `import { configuration } from 'intlayer';\nimport { loadContent as loadContentDyn } from '${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}';\n\n${body}\nexport { loadContent };\n`;
24
+ return `const { configuration } = require('intlayer');\nconst { loadContent: loadContentDyn } = require('${relativePrefix}/${LOAD_CONTENT_MODULE}.${extension}');\n\n${body}\nmodule.exports = { loadContent };\n`;
25
+ };
26
+ /**
27
+ * Generates the content of a fetch dictionary entry point file.
28
+ */
29
+ const generateDictionaryEntryPoint = (key, format = "esm") => {
30
+ const extension = format === "cjs" ? "cjs" : "mjs";
31
+ if (format === "esm") return `import { loadContent } from './${LOAD_CONTENT_MODULE}.${extension}';\n\nconst content = loadContent('${key}');\n\nexport default content;\n`;
32
+ return `const { loadContent } = require('./${LOAD_CONTENT_MODULE}.${extension}');\n\nmodule.exports = loadContent('${key}');\n`;
33
+ };
34
+ /**
35
+ * Write the localized dictionaries to the dictionariesDir
36
+ * @param mergedDictionaries - The merged dictionaries
37
+ * @param configuration - The configuration
38
+ * @returns The final dictionaries
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
43
+ * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
44
+ * console.log(finalDictionaries);
45
+ *
46
+ * // .intlayer/fetch_dictionary/home.mjs
47
+ * // .intlayer/fetch_dictionary/home.cjs
48
+ * ```
49
+ */
50
+ const writeFetchDictionary = async (dynamicDictionaries, configuration, formats = OUTPUT_FORMAT) => {
51
+ const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;
52
+ const { locales } = configuration.internationalization;
53
+ let relativePrefix = normalizePath(relative(fetchDictionariesDir, dynamicDictionariesDir));
54
+ if (!relativePrefix.startsWith(".")) relativePrefix = `./${relativePrefix}`;
55
+ await mkdir(resolve(fetchDictionariesDir), { recursive: true });
56
+ await parallelize(formats, async (format) => {
57
+ const extension = format === "cjs" ? "cjs" : "mjs";
58
+ await writeFileIfChanged(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`), generateFetchLoadContentModule(format, relativePrefix, locales)).catch((err) => {
59
+ console.error(`Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${LOAD_CONTENT_MODULE}.${extension}`))}:`, err);
60
+ });
61
+ });
62
+ const resultDictionariesPaths = {};
63
+ await parallelize(Object.entries(dynamicDictionaries), async ([key]) => {
64
+ if (key === "undefined") return;
65
+ await parallelize(formats, async (format) => {
66
+ const extension = format === "cjs" ? "cjs" : "mjs";
67
+ const content = generateDictionaryEntryPoint(key, format);
68
+ await writeFileIfChanged(resolve(fetchDictionariesDir, `${key}.${extension}`), content).catch((err) => {
69
+ console.error(`Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`, err);
70
+ });
71
+ });
72
+ });
73
+ return resultDictionariesPaths;
74
+ };
75
+
76
+ //#endregion
77
+ export { generateDictionaryEntryPoint, generateFetchLoadContentModule, writeFetchDictionary };
5
78
  //# sourceMappingURL=writeFetchDictionary.mjs.map