@intlayer/chokidar 8.9.7 → 8.10.0-canary.0

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 (285) hide show
  1. package/README.md +14 -0
  2. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  3. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  4. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  5. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  6. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  7. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  8. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  9. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  10. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  11. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  12. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  13. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  14. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  15. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  16. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  17. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  18. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  19. package/dist/cjs/createType/createType.cjs.map +1 -1
  20. package/dist/cjs/detectFormatCommand.cjs.map +1 -1
  21. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  22. package/dist/cjs/filterInvalidDictionaries.cjs +4 -0
  23. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  24. package/dist/cjs/formatDictionary.cjs.map +1 -1
  25. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +21 -0
  26. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  27. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  28. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  29. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
  30. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  31. package/dist/cjs/init/index.cjs.map +1 -1
  32. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  33. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  34. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
  35. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
  36. package/dist/cjs/initConfig/index.cjs.map +1 -1
  37. package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
  38. package/dist/cjs/installSkills/index.cjs.map +1 -1
  39. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  40. package/dist/cjs/listGitFiles.cjs.map +1 -1
  41. package/dist/cjs/listProjects.cjs.map +1 -1
  42. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
  43. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +4 -0
  44. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  45. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  46. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  47. package/dist/cjs/loadDictionaries/loadMarkdownContentDeclaration.cjs +44 -0
  48. package/dist/cjs/loadDictionaries/loadMarkdownContentDeclaration.cjs.map +1 -0
  49. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  50. package/dist/cjs/loadDictionaries/loadYamlContentDeclaration.cjs +27 -0
  51. package/dist/cjs/loadDictionaries/loadYamlContentDeclaration.cjs.map +1 -0
  52. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  53. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  54. package/dist/cjs/logConfigDetails.cjs.map +1 -1
  55. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  56. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  57. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  58. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
  59. package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -1
  60. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  61. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  62. package/dist/cjs/utils/formatter.cjs.map +1 -1
  63. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  64. package/dist/cjs/utils/getContentExtension.cjs.map +1 -1
  65. package/dist/cjs/utils/getFormatFromExtension.cjs +6 -0
  66. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  67. package/dist/cjs/utils/getPathHash.cjs.map +1 -1
  68. package/dist/cjs/utils/mergeChunks.cjs.map +1 -1
  69. package/dist/cjs/utils/pLimit.cjs.map +1 -1
  70. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  71. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
  72. package/dist/cjs/utils/readDictionariesFromDisk.cjs.map +1 -1
  73. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
  74. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  75. package/dist/cjs/utils/resolveRelativePath.cjs.map +1 -1
  76. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  77. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
  78. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
  79. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  80. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  81. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  82. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  83. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
  84. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
  85. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  86. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  87. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
  88. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
  89. package/dist/cjs/watcher.cjs.map +1 -1
  90. package/dist/cjs/writeConfiguration/generateConfigurationContent.cjs.map +1 -1
  91. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  92. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  93. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  94. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  95. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
  96. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +10 -0
  97. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  98. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  99. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +64 -0
  100. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -0
  101. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs +44 -0
  102. package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs.map +1 -0
  103. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  104. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  105. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  106. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
  107. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  108. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  109. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  110. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  111. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  112. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  113. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
  114. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  115. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
  116. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  117. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  118. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  119. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  120. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  121. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  122. package/dist/esm/createType/createType.mjs.map +1 -1
  123. package/dist/esm/detectFormatCommand.mjs.map +1 -1
  124. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  125. package/dist/esm/filterInvalidDictionaries.mjs +4 -0
  126. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
  127. package/dist/esm/formatDictionary.mjs.map +1 -1
  128. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +21 -0
  129. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  130. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  131. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  132. package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
  133. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  134. package/dist/esm/init/index.mjs.map +1 -1
  135. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  136. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  137. package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
  138. package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
  139. package/dist/esm/initConfig/index.mjs.map +1 -1
  140. package/dist/esm/installMCP/installMCP.mjs.map +1 -1
  141. package/dist/esm/installSkills/index.mjs.map +1 -1
  142. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  143. package/dist/esm/listGitFiles.mjs.map +1 -1
  144. package/dist/esm/listProjects.mjs.map +1 -1
  145. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
  146. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +5 -1
  147. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  148. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  149. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  150. package/dist/esm/loadDictionaries/loadMarkdownContentDeclaration.mjs +42 -0
  151. package/dist/esm/loadDictionaries/loadMarkdownContentDeclaration.mjs.map +1 -0
  152. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  153. package/dist/esm/loadDictionaries/loadYamlContentDeclaration.mjs +25 -0
  154. package/dist/esm/loadDictionaries/loadYamlContentDeclaration.mjs.map +1 -0
  155. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  156. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
  157. package/dist/esm/logConfigDetails.mjs.map +1 -1
  158. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  159. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  160. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  161. package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
  162. package/dist/esm/utils/buildComponentFilesList.mjs.map +1 -1
  163. package/dist/esm/utils/buildFilesList.mjs.map +1 -1
  164. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  165. package/dist/esm/utils/formatter.mjs.map +1 -1
  166. package/dist/esm/utils/getChunk.mjs.map +1 -1
  167. package/dist/esm/utils/getContentExtension.mjs.map +1 -1
  168. package/dist/esm/utils/getFormatFromExtension.mjs +6 -0
  169. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  170. package/dist/esm/utils/getPathHash.mjs.map +1 -1
  171. package/dist/esm/utils/mergeChunks.mjs.map +1 -1
  172. package/dist/esm/utils/pLimit.mjs.map +1 -1
  173. package/dist/esm/utils/parallelize.mjs.map +1 -1
  174. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
  175. package/dist/esm/utils/readDictionariesFromDisk.mjs.map +1 -1
  176. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
  177. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
  178. package/dist/esm/utils/resolveRelativePath.mjs.map +1 -1
  179. package/dist/esm/utils/runOnce.mjs.map +1 -1
  180. package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
  181. package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
  182. package/dist/esm/utils/runParallel/index.mjs.map +1 -1
  183. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  184. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  185. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
  186. package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
  187. package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
  188. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  189. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
  190. package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
  191. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
  192. package/dist/esm/watcher.mjs.map +1 -1
  193. package/dist/esm/writeConfiguration/generateConfigurationContent.mjs.map +1 -1
  194. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  195. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  196. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
  197. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  198. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
  199. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +10 -0
  200. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  201. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  202. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +62 -0
  203. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -0
  204. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs +42 -0
  205. package/dist/esm/writeContentDeclaration/writeYamlFile.mjs.map +1 -0
  206. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  207. package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
  208. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  209. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  210. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  211. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  212. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  213. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -1
  214. package/dist/types/cleanRemovedContentDeclaration.d.ts.map +1 -1
  215. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +1 -3
  216. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
  217. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +1 -3
  218. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
  219. package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -1
  220. package/dist/types/createType/createType.d.ts.map +1 -1
  221. package/dist/types/detectFormatCommand.d.ts.map +1 -1
  222. package/dist/types/filterInvalidDictionaries.d.ts.map +1 -1
  223. package/dist/types/formatDictionary.d.ts +20 -22
  224. package/dist/types/formatDictionary.d.ts.map +1 -1
  225. package/dist/types/init/index.d.ts.map +1 -1
  226. package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
  227. package/dist/types/init/utils/fileSystem.d.ts.map +1 -1
  228. package/dist/types/init/utils/jsonParser.d.ts.map +1 -1
  229. package/dist/types/init/utils/tsConfig.d.ts.map +1 -1
  230. package/dist/types/installSkills/index.d.ts.map +1 -1
  231. package/dist/types/listDictionariesPath.d.ts +1 -2
  232. package/dist/types/listDictionariesPath.d.ts.map +1 -1
  233. package/dist/types/listGitFiles.d.ts.map +1 -1
  234. package/dist/types/listProjects.d.ts.map +1 -1
  235. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
  236. package/dist/types/loadDictionaries/loadMarkdownContentDeclaration.d.ts +7 -0
  237. package/dist/types/loadDictionaries/loadMarkdownContentDeclaration.d.ts.map +1 -0
  238. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -2
  239. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
  240. package/dist/types/loadDictionaries/loadYamlContentDeclaration.d.ts +7 -0
  241. package/dist/types/loadDictionaries/loadYamlContentDeclaration.d.ts.map +1 -0
  242. package/dist/types/logConfigDetails.d.ts.map +1 -1
  243. package/dist/types/prepareIntlayer.d.ts.map +1 -1
  244. package/dist/types/reduceDictionaryContent/applyMask.d.ts.map +1 -1
  245. package/dist/types/utils/autoDecorateContent.d.ts.map +1 -1
  246. package/dist/types/utils/buildComponentFilesList.d.ts.map +1 -1
  247. package/dist/types/utils/buildFilesList.d.ts.map +1 -1
  248. package/dist/types/utils/chunkJSON.d.ts.map +1 -1
  249. package/dist/types/utils/formatter.d.ts.map +1 -1
  250. package/dist/types/utils/getChunk.d.ts.map +1 -1
  251. package/dist/types/utils/getContentExtension.d.ts.map +1 -1
  252. package/dist/types/utils/getFormatFromExtension.d.ts +2 -2
  253. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
  254. package/dist/types/utils/getPathHash.d.ts.map +1 -1
  255. package/dist/types/utils/mergeChunks.d.ts.map +1 -1
  256. package/dist/types/utils/pLimit.d.ts.map +1 -1
  257. package/dist/types/utils/parallelizeGlobal.d.ts.map +1 -1
  258. package/dist/types/utils/readDictionariesFromDisk.d.ts.map +1 -1
  259. package/dist/types/utils/reduceObjectFormat.d.ts.map +1 -1
  260. package/dist/types/utils/resolveObjectPromises.d.ts.map +1 -1
  261. package/dist/types/utils/runOnce.d.ts.map +1 -1
  262. package/dist/types/utils/runParallel/bin.d.ts.map +1 -1
  263. package/dist/types/utils/runParallel/bootstrap.d.ts.map +1 -1
  264. package/dist/types/utils/runParallel/index.d.ts.map +1 -1
  265. package/dist/types/utils/runParallel/pidTree.d.ts.map +1 -1
  266. package/dist/types/utils/runParallel/ps.d.ts.map +1 -1
  267. package/dist/types/utils/runParallel/runTask.d.ts.map +1 -1
  268. package/dist/types/utils/runParallel/spawnPosix.d.ts.map +1 -1
  269. package/dist/types/utils/runParallel/spawnWin32.d.ts.map +1 -1
  270. package/dist/types/utils/runParallel/wmic.d.ts.map +1 -1
  271. package/dist/types/utils/sortAlphabetically.d.ts.map +1 -1
  272. package/dist/types/utils/splitTextByLine.d.ts.map +1 -1
  273. package/dist/types/utils/verifyIdenticObjectFormat.d.ts.map +1 -1
  274. package/dist/types/watcher.d.ts +1 -2
  275. package/dist/types/watcher.d.ts.map +1 -1
  276. package/dist/types/writeConfiguration/generateConfigurationContent.d.ts.map +1 -1
  277. package/dist/types/writeConfiguration/index.d.ts.map +1 -1
  278. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -1
  279. package/dist/types/writeContentDeclaration/transformJSONFile.d.ts.map +1 -1
  280. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
  281. package/dist/types/writeContentDeclaration/writeMarkdownFile.d.ts +8 -0
  282. package/dist/types/writeContentDeclaration/writeMarkdownFile.d.ts.map +1 -0
  283. package/dist/types/writeContentDeclaration/writeYamlFile.d.ts +8 -0
  284. package/dist/types/writeContentDeclaration/writeYamlFile.d.ts.map +1 -0
  285. package/package.json +9 -9
@@ -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 { assertPathWithin } from '@intlayer/config/utils';\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\n\n/**\n * Generates the content of a dictionary entry point file.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n locales: string[],\n format: 'cjs' | 'esm' = 'esm'\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 if (format === 'esm') {\n return (\n `const content = {\\n${localeEntries}\\n};\\n\\n` +\n `export default content;\\n`\n );\n }\n return `module.exports = {\\n${localeEntries}\\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\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 assertPathWithin(keyDir, dictDir);\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, locales, format);\n\n const dynEntryPath = resolve(\n dynamicDictionariesDir,\n `${key}.${extension}`\n );\n assertPathWithin(dynEntryPath, dynamicDictionariesDir);\n\n await writeFileIfChanged(dynEntryPath, content).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(dynEntryPath)}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;AA4BA,MAAM,sBAAsB;;;;AAK5B,MAAa,gCACX,KACA,SACA,SAAwB,UACb;CAKX,MAAM,gBAJgB,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,MAC1C,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAGD,CAChC,KAAK,WACJ,WAAW,QACP,MAAM,OAAO,qBAAqB,oBAAoB,GAAG,IAAI,GAAG,OAAO,gCACvE,MAAM,OAAO,sCAAsC,oBAAoB,GAAG,IAAI,GAAG,OAAO,UAC7F,CACA,KAAK,MAAM;CAEd,IAAI,WAAW,OACb,OACE,sBAAsB,cAAc;CAIxC,OAAO,uBAAuB,cAAc;;;;;;;;;;;;;;;;;;AAmB9C,MAAa,yBAAyB,OACpC,oBACA,eACA,UAA6B,kBACU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js","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 { assertPathWithin } from '@intlayer/config/utils';\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\n\n/**\n * Generates the content of a dictionary entry point file.\n */\nexport const generateDictionaryEntryPoint = (\n key: string,\n locales: string[],\n format: 'cjs' | 'esm' = 'esm'\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 if (format === 'esm') {\n return (\n `const content = {\\n${localeEntries}\\n};\\n\\n` +\n `export default content;\\n`\n );\n }\n return `module.exports = {\\n${localeEntries}\\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\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 assertPathWithin(keyDir, dictDir);\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, locales, format);\n\n const dynEntryPath = resolve(\n dynamicDictionariesDir,\n `${key}.${extension}`\n );\n assertPathWithin(dynEntryPath, dynamicDictionariesDir);\n\n await writeFileIfChanged(dynEntryPath, content).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(dynEntryPath)}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;AA4BA,MAAM,sBAAsB;;;;AAK5B,MAAa,gCACX,KACA,SACA,SAAwB,UACb;CAKX,MAAM,gBAJgB,CAAC,GAAG,OAAO,EAAE,MAAM,GAAG,MAC1C,OAAO,CAAC,EAAE,cAAc,OAAO,CAAC,CAAC,CAGD,EAC/B,KAAK,WACJ,WAAW,QACP,MAAM,OAAO,qBAAqB,oBAAoB,GAAG,IAAI,GAAG,OAAO,gCACvE,MAAM,OAAO,sCAAsC,oBAAoB,GAAG,IAAI,GAAG,OAAO,SAC9F,EACC,KAAK,KAAK;CAEb,IAAI,WAAW,OACb,OACE,sBAAsB,cAAc;CAIxC,OAAO,uBAAuB,cAAc;AAC9C;;;;;;;;;;;;;;;;;AAkBA,MAAa,yBAAyB,OACpC,oBACA,eACA,UAA6B,kBACU;CACvC,MAAM,EAAE,SAAS,kBAAkB,cAAc;CACjD,MAAM,EAAE,2BAA2B,cAAc;CAEjD,MAAM,UAAU,QAAQ,wBAAwB,mBAAmB;CACnE,MAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;CAExC,MAAM,0BAAqD,CAAC;CAG5D,MAAM,YACJ,OAAO,QAAQ,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,OAC7C,OAAO,CAAC,EAAE,cAAc,OAAO,CAAC,CAAC,CACnC,GACA,OAAO,CAAC,KAAK,qBAAqB;EAChC,IAAI,QAAQ,aAAa;EAEzB,MAAM,mCAA8D,CAAC;EAErE,MAAM,SAAS,QAAQ,SAAS,GAAG;EACnC,iBAAiB,QAAQ,OAAO;EAChC,MAAM,MAAM,QAAQ,EAAE,WAAW,KAAK,CAAC;EAEvC,MAAM,YAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,sBAAsB,uBAC1B,gBAAgB,YAChB,QACA,aACF;GAGA,MAAM,iBAAiB,QAAQ,QAAQ,GAAG,OAAO,MAAM;GAEvD,MAAM,mBAAmB,gBAAgB,mBAAmB,EAAE,OAC3D,QAAQ;IACP,QAAQ,MACN,4BAA4B,IAAI,GAAG,OAAO,SAC1C,GACF;GACF,CACF;GAEA,iCAAiC,UAAU;IACzC,gBAAgB;IAChB,YAAY;GACd;EACF,CAAC;EAED,wBAAwB,OAAO;EAE/B,MAAM,YAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BAA6B,KAAK,SAAS,MAAM;GAEjE,MAAM,eAAe,QACnB,wBACA,GAAG,IAAI,GAAG,WACZ;GACA,iBAAiB,cAAc,sBAAsB;GAErD,MAAM,mBAAmB,cAAc,OAAO,EAAE,OAAO,QAAQ;IAC7D,QAAQ,MACN,0BAA0B,aAAa,YAAY,EAAE,IACrD,GACF;GACF,CAAC;EACH,CAAC;CACH,CACF;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { assertPathWithin, normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type { LocalizedDictionaryOutput } from './writeDynamicDictionary';\n\nexport const generateDictionaryEntryPoint = (\n key: string,\n locales: string[],\n relativePrefix: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const localeEntries = locales\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map(\n (locale) =>\n ` '${locale}': async () => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`\\${editor.liveSyncURL}/dictionaries/${key}/${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch {\\n` +\n ` return dynContent['${locale}']();\\n` +\n ` }\\n` +\n ` }`\n )\n .join(',\\n');\n\n if (format === 'esm') {\n return (\n `import { editor } from 'intlayer';\\n` +\n `import dynContent from '${relativePrefix}/${key}.${extension}';\\n\\n` +\n `const content = {\\n${localeEntries}\\n};\\n\\n` +\n `export default content;\\n`\n );\n }\n return (\n `const { editor } = require('intlayer');\\n` +\n `const dynContent = require('${relativePrefix}/${key}.${extension}');\\n\\n` +\n `module.exports = {\\n${localeEntries}\\n};\\n`\n );\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { locales } = configuration.internationalization;\n\n // Compute relative path from fetch dir to dynamic dir\n let relativePrefix = normalizePath(\n relative(fetchDictionariesDir, dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(Object.entries(dynamicDictionaries), async ([key]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n key,\n locales,\n relativePrefix,\n format\n );\n\n const fetchEntryPath = resolve(\n fetchDictionariesDir,\n `${key}.${extension}`\n );\n assertPathWithin(fetchEntryPath, fetchDictionariesDir);\n\n await writeFileIfChanged(fetchEntryPath, content).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(fetchEntryPath)}:`,\n err\n );\n });\n });\n });\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;AAUA,MAAa,gCACX,KACA,SACA,gBACA,SAAwB,UACb;CACX,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAE7C,MAAM,gBAAgB,QACnB,MAAM,GAAG,MAAM,OAAO,EAAE,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CAClD,KACE,WACC,MAAM,OAAO,mGAE0D,IAAI,GAAG,OAAO,gFAGzD,OAAO,mBAGtC,CACA,KAAK,MAAM;CAEd,IAAI,WAAW,OACb,OACE,+DAC2B,eAAe,GAAG,IAAI,GAAG,UAAU,2BACxC,cAAc;CAIxC,OACE,wEAC+B,eAAe,GAAG,IAAI,GAAG,UAAU,6BAC3C,cAAc;;;;;;;;;;;;;;;;;;AAoBzC,MAAa,uBAAuB,OAClC,qBACA,eACA,UAA6B,kBACU;CACvC,MAAM,EAAE,sBAAsB,2BAA2B,cAAc;CACvE,MAAM,EAAE,YAAY,cAAc;CAGlC,IAAI,iBAAiB,cACnB,SAAS,sBAAsB,uBAAuB,CACvD;CACD,IAAI,CAAC,eAAe,WAAW,IAAI,EACjC,iBAAiB,KAAK;CAGxB,MAAM,MAAM,QAAQ,qBAAqB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE/D,MAAM,0BAAqD,EAAE;CAG7D,MAAM,YAAY,OAAO,QAAQ,oBAAoB,EAAE,OAAO,CAAC,SAAS;EACtE,IAAI,QAAQ,aAAa;EAEzB,MAAM,YAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BACd,KACA,SACA,gBACA,OACD;GAED,MAAM,iBAAiB,QACrB,sBACA,GAAG,IAAI,GAAG,YACX;GACD,iBAAiB,gBAAgB,qBAAqB;GAEtD,MAAM,mBAAmB,gBAAgB,QAAQ,CAAC,OAAO,QAAQ;IAC/D,QAAQ,MACN,wBAAwB,aAAa,eAAe,CAAC,IACrD,IACD;KACD;IACF;GACF;CAEF,OAAO"}
1
+ {"version":3,"file":"writeFetchDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { OUTPUT_FORMAT } from '@intlayer/config/defaultValues';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { assertPathWithin, normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type { LocalizedDictionaryOutput } from './writeDynamicDictionary';\n\nexport const generateDictionaryEntryPoint = (\n key: string,\n locales: string[],\n relativePrefix: string,\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const localeEntries = locales\n .sort((a, b) => String(a).localeCompare(String(b)))\n .map(\n (locale) =>\n ` '${locale}': async () => {\\n` +\n ` try {\\n` +\n ` const res = await fetch(\\`\\${editor.liveSyncURL}/dictionaries/${key}/${locale}\\`);\\n` +\n ` return await res.json();\\n` +\n ` } catch {\\n` +\n ` return dynContent['${locale}']();\\n` +\n ` }\\n` +\n ` }`\n )\n .join(',\\n');\n\n if (format === 'esm') {\n return (\n `import { editor } from 'intlayer';\\n` +\n `import dynContent from '${relativePrefix}/${key}.${extension}';\\n\\n` +\n `const content = {\\n${localeEntries}\\n};\\n\\n` +\n `export default content;\\n`\n );\n }\n return (\n `const { editor } = require('intlayer');\\n` +\n `const dynContent = require('${relativePrefix}/${key}.${extension}');\\n\\n` +\n `module.exports = {\\n${localeEntries}\\n};\\n`\n );\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionary/home.mjs\n * // .intlayer/fetch_dictionary/home.cjs\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration: IntlayerConfig,\n formats: ('cjs' | 'esm')[] = OUTPUT_FORMAT\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir, dynamicDictionariesDir } = configuration.system;\n const { locales } = configuration.internationalization;\n\n // Compute relative path from fetch dir to dynamic dir\n let relativePrefix = normalizePath(\n relative(fetchDictionariesDir, dynamicDictionariesDir)\n );\n if (!relativePrefix.startsWith('.')) {\n relativePrefix = `./${relativePrefix}`;\n }\n\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n const resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(Object.entries(dynamicDictionaries), async ([key]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n key,\n locales,\n relativePrefix,\n format\n );\n\n const fetchEntryPath = resolve(\n fetchDictionariesDir,\n `${key}.${extension}`\n );\n assertPathWithin(fetchEntryPath, fetchDictionariesDir);\n\n await writeFileIfChanged(fetchEntryPath, content).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(fetchEntryPath)}:`,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ACrD,GACF;GACF,CAAC;EACH,CAAC;CACH,CAAC;CAED,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeMergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { assertPathWithin } from '@intlayer/config/utils';\nimport {\n mergeDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration: IntlayerConfig\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n assertPathWithin(resultFilePath, dictionariesDir);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,0BAA0B,OACrC,qBACA,kBACoC;CACpC,MAAM,EAAE,oBAAoB,cAAc;CAG1C,MAAM,MAAM,QAAQ,gBAAgB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE1D,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,uBAAuB;EAClC,IAAI,QAAQ,aACV;EAWF,MAAM,mBAAmB,kBALM,sBAC7B,kBAAkB,cAClB,cAG+D,CAAC;EAGlE,MAAM,iBAAiB,QAAQ,iBAAiB,GADtB,IAAI,OACiC;EAE/D,iBAAiB,gBAAgB,gBAAgB;EAGjD,MAAM,mBAAmB,gBAAgB,iBAAiB,CAAC,OACxD,QAAQ;GACP,QAAQ,MACN,yBAAyB,aAAa,eAAe,CAAC,IACtD,IACD;IAEJ;EAED,OAAO,CACL,KACA;GACE,gBAAgB;GAChB,YAAY;GACb,CACF;GAEJ;CAED,OAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CACxB"}
1
+ {"version":3,"file":"writeMergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath } from '@intlayer/config/logger';\nimport { assertPathWithin } from '@intlayer/config/utils';\nimport {\n mergeDictionaries,\n normalizeDictionaries,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport type { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration: IntlayerConfig\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n assertPathWithin(resultFilePath, dictionariesDir);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,0BAA0B,OACrC,qBACA,kBACoC;CACpC,MAAM,EAAE,oBAAoB,cAAc;CAG1C,MAAM,MAAM,QAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;CAEzD,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,mBAAmB,GAClC,OAAO,CAAC,KAAK,uBAAuB;EAClC,IAAI,QAAQ,aACV;EAWF,MAAM,mBAAmB,kBALM,sBAC7B,kBAAkB,cAClB,aAG8D,CAAC;EAGjE,MAAM,iBAAiB,QAAQ,iBAAiB,GADtB,IAAI,MACgC;EAE9D,iBAAiB,gBAAgB,eAAe;EAGhD,MAAM,mBAAmB,gBAAgB,gBAAgB,EAAE,OACxD,QAAQ;GACP,QAAQ,MACN,yBAAyB,aAAa,cAAc,EAAE,IACtD,GACF;EACF,CACF;EAEA,OAAO,CACL,KACA;GACE,gBAAgB;GAChB,YAAY;EACd,CACF;CACF,CACF;CAEA,OAAO,OAAO,YACZ,QAAQ,OAAO,OAAO,CACxB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeRemoteDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport {\n groupDictionariesByKey,\n type UnmergedDictionaryResult,\n} from './writeUnmergedDictionary';\n\nexport type RemoteDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeRemoteDictionary = async (\n remoteDictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<RemoteDictionaryOutput> => {\n const { remoteDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(remoteDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n remoteDictionaries,\n configuration\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n // Merge dictionaries with the same key and write to dictionariesDir\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const formattedDictionaries = formatDistantDictionaries(dictionaries);\n\n const orderedDictionaries = orderDictionaries(formattedDictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,wBAAwB,OACnC,oBACA,kBACoC;CACpC,MAAM,EAAE,0BAA0B,cAAc;CAGhD,MAAM,MAAM,QAAQ,sBAAsB,EAAE,EAAE,WAAW,MAAM,CAAC;CAQhE,MAAM,sBAAsB,uBANC,0BAC3B,oBACA,cAIqE,CAAC;CAGxE,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,kBAAkB;EAC7B,IAAI,QAAQ,aACV;EAQF,MAAM,sBAAsB,kBAFE,0BAA0B,aAEW,CAAC;EAGpE,MAAM,mBAAmB,QAAQ,uBAAuB,GAD9B,IAAI,OACyC;EAGvE,MAAM,mBAAmB,kBAAkB,oBAAoB,CAAC,OAC7D,QAAQ;GACP,QAAQ,MACN,GAAG,EAAE,2BAA2B,aAAa,iBAAiB,CAAC,IAC/D,IACD;IAEJ;EAED,OAAO,CACL,KACA;GACE,gBAAgB;GAChB;GACD,CACF;GAEJ;CAED,OAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CAGxB"}
1
+ {"version":3,"file":"writeRemoteDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport {\n groupDictionariesByKey,\n type UnmergedDictionaryResult,\n} from './writeUnmergedDictionary';\n\nexport type RemoteDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeRemoteDictionary = async (\n remoteDictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<RemoteDictionaryOutput> => {\n const { remoteDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(remoteDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n remoteDictionaries,\n configuration\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n // Merge dictionaries with the same key and write to dictionariesDir\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const formattedDictionaries = formatDistantDictionaries(dictionaries);\n\n const orderedDictionaries = orderDictionaries(formattedDictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,wBAAwB,OACnC,oBACA,kBACoC;CACpC,MAAM,EAAE,0BAA0B,cAAc;CAGhD,MAAM,MAAM,QAAQ,qBAAqB,GAAG,EAAE,WAAW,KAAK,CAAC;CAQ/D,MAAM,sBAAsB,uBANC,0BAC3B,oBACA,aAIoE,CAAC;CAGvE,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,mBAAmB,GAClC,OAAO,CAAC,KAAK,kBAAkB;EAC7B,IAAI,QAAQ,aACV;EAQF,MAAM,sBAAsB,kBAFE,0BAA0B,YAEU,CAAC;EAGnE,MAAM,mBAAmB,QAAQ,uBAAuB,GAD9B,IAAI,MACwC;EAGtE,MAAM,mBAAmB,kBAAkB,mBAAmB,EAAE,OAC7D,QAAQ;GACP,QAAQ,MACN,GAAG,EAAE,2BAA2B,aAAa,gBAAgB,EAAE,IAC/D,GACF;EACF,CACF;EAEA,OAAO,CACL,KACA;GACE,gBAAgB;GAChB;EACF,CACF;CACF,CACF;CAEA,OAAO,OAAO,YACZ,QAAQ,OAAO,OAAO,CAGxB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeUnmergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { assertPathWithin } from '@intlayer/config/utils';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, DictionaryKey } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nexport const groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> =>\n dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n\nexport type UnmergedDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type UnmergedDictionaryOutput = Record<\n DictionaryKey,\n UnmergedDictionaryResult\n>;\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig,\n env: 'prod' | 'dev'\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n dictionaries,\n configuration,\n { checkSchema: true }\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const orderedDictionaries = orderDictionaries(dictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n assertPathWithin(unmergedFilePath, unmergedDictionariesDir);\n\n // Write the grouped dictionaries in disk if the editor is enabled\n // To make work the visual editor on the server\n // No need them if the editor is disabled\n // But in local env (env: 'dev') we write them for the vscode extension\n if (configuration.editor.enabled || env === 'dev') {\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n }\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries: dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,0BACX,iBAEA,aAAa,QACV,KAAK,eAAe;CACnB,MAAM,MAAM,WAAW;CACvB,IAAI,CAAC,IAAI,MACP,IAAI,OAAO,EAAE;CAEf,IAAI,KAAK,KAAK,WAAW;CACzB,OAAO;GAET,EAAE,CACH;;;;;;;;;;;;;;;;;;;;;AAgCH,MAAa,4BAA4B,OACvC,cACA,eACA,QACsC;CACtC,MAAM,EAAE,4BAA4B,cAAc;CAGlD,MAAM,MAAM,QAAQ,wBAAwB,EAAE,EAAE,WAAW,MAAM,CAAC;CASlE,MAAM,sBAAsB,uBAPC,0BAC3B,cACA,eACA,EAAE,aAAa,MAAM,CAIgD,CAAC;CAExE,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,kBAAkB;EAC7B,IAAI,QAAQ,aACV;EAMF,MAAM,sBAAsB,kBAAkB,aAAa;EAG3D,MAAM,mBAAmB,QAAQ,yBAAyB,GADhC,IAAI,OAC2C;EAEzE,iBAAiB,kBAAkB,wBAAwB;EAM3D,IAAI,cAAc,OAAO,WAAW,QAAQ,OAC1C,MAAM,mBAAmB,kBAAkB,oBAAoB,CAAC,OAC7D,QAAQ;GACP,QAAQ,MACN,GAAG,EAAE,2BAA2B,aAAa,iBAAiB,CAAC,IAC/D,IACD;IAEJ;EAGH,OAAO,CACL,KACA;GACE,gBAAgB;GACF;GACf,CACF;GAEJ;CAED,OAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CAGxB"}
1
+ {"version":3,"file":"writeUnmergedDictionary.mjs","names":[],"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config/logger';\nimport { assertPathWithin } from '@intlayer/config/utils';\nimport { orderDictionaries } from '@intlayer/core/dictionaryManipulator';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, DictionaryKey } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nexport const groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> =>\n dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n\nexport type UnmergedDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type UnmergedDictionaryOutput = Record<\n DictionaryKey,\n UnmergedDictionaryResult\n>;\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig,\n env: 'prod' | 'dev'\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.system;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(\n dictionaries,\n configuration,\n { checkSchema: true }\n );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const orderedDictionaries = orderDictionaries(dictionaries);\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n assertPathWithin(unmergedFilePath, unmergedDictionariesDir);\n\n // Write the grouped dictionaries in disk if the editor is enabled\n // To make work the visual editor on the server\n // No need them if the editor is disabled\n // But in local env (env: 'dev') we write them for the vscode extension\n if (configuration.editor.enabled || env === 'dev') {\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n }\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries: dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,0BACX,iBAEA,aAAa,QACV,KAAK,eAAe;CACnB,MAAM,MAAM,WAAW;CACvB,IAAI,CAAC,IAAI,MACP,IAAI,OAAO,CAAC;CAEd,IAAI,KAAK,KAAK,UAAU;CACxB,OAAO;AACT,GACA,CAAC,CACH;;;;;;;;;;;;;;;;;;;;;AAgCF,MAAa,4BAA4B,OACvC,cACA,eACA,QACsC;CACtC,MAAM,EAAE,4BAA4B,cAAc;CAGlD,MAAM,MAAM,QAAQ,uBAAuB,GAAG,EAAE,WAAW,KAAK,CAAC;CASjE,MAAM,sBAAsB,uBAPC,0BAC3B,cACA,eACA,EAAE,aAAa,KAAK,CAIgD,CAAC;CAEvE,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,mBAAmB,GAClC,OAAO,CAAC,KAAK,kBAAkB;EAC7B,IAAI,QAAQ,aACV;EAMF,MAAM,sBAAsB,kBAAkB,YAAY;EAG1D,MAAM,mBAAmB,QAAQ,yBAAyB,GADhC,IAAI,MAC0C;EAExE,iBAAiB,kBAAkB,uBAAuB;EAM1D,IAAI,cAAc,OAAO,WAAW,QAAQ,OAC1C,MAAM,mBAAmB,kBAAkB,mBAAmB,EAAE,OAC7D,QAAQ;GACP,QAAQ,MACN,GAAG,EAAE,2BAA2B,aAAa,gBAAgB,EAAE,IAC/D,GACF;EACF,CACF;EAGF,OAAO,CACL,KACA;GACE,gBAAgB;GACF;EAChB,CACF;CACF,CACF;CAEA,OAAO,OAAO,YACZ,QAAQ,OAAO,OAAO,CAGxB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"cleanOutputDir.mjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const cleanOutputDir = async (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n remoteDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n cacheDir,\n } = configuration.system;\n\n const appLogger = getAppLogger(configuration);\n\n const directoriesToClean: string[] = [\n dictionariesDir, // Merged dictionaries\n unmergedDictionariesDir, // Unmerged dictionaries\n dynamicDictionariesDir, // Dynamic dictionaries\n remoteDictionariesDir, // Remote dictionaries\n fetchDictionariesDir, // Fetch dictionaries\n mainDir, // Main files\n typesDir, // Types\n configDir, // Configuration\n cacheDir, // Cache\n ];\n\n // Execute all deletions in parallel\n await Promise.all(\n directoriesToClean\n .filter((dir) => existsSync(dir))\n .map((dir) => rm(dir, { recursive: true, force: true }))\n );\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;AAKA,MAAa,iBAAiB,OAAO,kBAAkC;CACrE,MAAM,EACJ,iBACA,yBACA,wBACA,uBACA,sBACA,SACA,UACA,WACA,aACE,cAAc;CAElB,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,qBAA+B;EACnC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CAGD,MAAM,QAAQ,IACZ,mBACG,QAAQ,QAAQ,WAAW,IAAI,CAAC,CAChC,KAAK,QAAQ,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC,CAAC,CAC3D;CAED,UAAU,4BAA4B,EACpC,WAAW,MACZ,CAAC"}
1
+ {"version":3,"file":"cleanOutputDir.mjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const cleanOutputDir = async (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n remoteDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n cacheDir,\n } = configuration.system;\n\n const appLogger = getAppLogger(configuration);\n\n const directoriesToClean: string[] = [\n dictionariesDir, // Merged dictionaries\n unmergedDictionariesDir, // Unmerged dictionaries\n dynamicDictionariesDir, // Dynamic dictionaries\n remoteDictionariesDir, // Remote dictionaries\n fetchDictionariesDir, // Fetch dictionaries\n mainDir, // Main files\n typesDir, // Types\n configDir, // Configuration\n cacheDir, // Cache\n ];\n\n // Execute all deletions in parallel\n await Promise.all(\n directoriesToClean\n .filter((dir) => existsSync(dir))\n .map((dir) => rm(dir, { recursive: true, force: true }))\n );\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;;AAKA,MAAa,iBAAiB,OAAO,kBAAkC;CACrE,MAAM,EACJ,iBACA,yBACA,wBACA,uBACA,sBACA,SACA,UACA,WACA,aACE,cAAc;CAElB,MAAM,YAAY,aAAa,aAAa;CAE5C,MAAM,qBAA+B;EACnC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAGA,MAAM,QAAQ,IACZ,mBACG,QAAQ,QAAQ,WAAW,GAAG,CAAC,EAC/B,KAAK,QAAQ,GAAG,KAAK;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC,CAAC,CAC3D;CAEA,UAAU,4BAA4B,EACpC,WAAW,KACb,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"cleanRemovedContentDeclaration.mjs","names":[],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config/client';\nimport {\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport fg from 'fast-glob';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint';\nimport { readDictionariesFromDisk } from './utils/readDictionariesFromDisk';\nimport { writeJsonIfChanged } from './writeJsonIfChanged';\n\nexport const cleanRemovedContentDeclaration = async (\n filePath: string,\n keysToKeep: string[],\n configuration: IntlayerConfig\n): Promise<{\n changedDictionariesLocalIds: string[];\n excludeKeys: string[];\n hasRebuilt: boolean;\n}> => {\n const appLogger = getAppLogger(configuration);\n\n const unmergedDictionaries = readDictionariesFromDisk<\n Record<string, Dictionary[]>\n >(configuration.system.unmergedDictionariesDir);\n\n const baseDir = configuration.system.baseDir;\n\n const relativeFilePath = relative(baseDir, filePath);\n const flatUnmergedDictionaries = Object.values(unmergedDictionaries).flat();\n\n const filteredUnmergedDictionaries = flatUnmergedDictionaries.filter(\n (dictionary) =>\n dictionary.filePath === relativeFilePath &&\n !keysToKeep.includes(dictionary.key)\n );\n\n // Deduplicate dictionaries by key\n const uniqueUnmergedDictionaries = filteredUnmergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n const changedDictionariesLocalIds: string[] = [];\n const filesToRemove: string[] = [];\n const excludeKeys: string[] = [];\n\n // Identify Unmerged Dictionaries to remove or clean\n await Promise.all(\n uniqueUnmergedDictionaries.map(async (dictionary) => {\n const unmergedFilePath = normalize(\n join(\n configuration.system.unmergedDictionariesDir,\n `${dictionary.key}.json`\n )\n );\n\n try {\n const jsonContent = await readFile(unmergedFilePath, 'utf8');\n const parsedContent = JSON.parse(jsonContent);\n\n if (parsedContent.length === 1) {\n if (parsedContent[0].filePath === relativeFilePath) {\n appLogger(\n `Removing outdated dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n filesToRemove.push(unmergedFilePath);\n excludeKeys.push(dictionary.key);\n }\n } else {\n const filteredContent = parsedContent.filter(\n (content: any) => content.filePath !== relativeFilePath\n );\n await writeJsonIfChanged(unmergedFilePath, filteredContent);\n changedDictionariesLocalIds.push(dictionary.localId!);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n }\n })\n );\n\n const dictionaries = readDictionariesFromDisk<Record<string, Dictionary>>(\n configuration.system.dictionariesDir\n );\n const flatDictionaries = Object.values(dictionaries) as Dictionary[];\n\n const filteredMergedDictionaries = flatDictionaries?.filter(\n (dictionary) =>\n !keysToKeep.includes(dictionary.key) &&\n dictionary.localIds?.length === 1 &&\n (dictionary.localIds[0] as string).endsWith(\n `::local::${relativeFilePath}`\n )\n );\n\n const uniqueMergedDictionaries = filteredMergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n // Identify Merged Dictionaries, Types, and Dynamic Dictionaries to remove\n await Promise.all(\n uniqueMergedDictionaries.map(async (dictionary) => {\n const mergedFilePath = normalize(\n join(configuration.system.dictionariesDir, `${dictionary.key}.json`)\n );\n\n try {\n const fileContent = await readFile(mergedFilePath, 'utf8');\n const parsedContent = JSON.parse(fileContent) as Dictionary;\n\n if (parsedContent.localIds?.length === 1) {\n if (\n parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)\n ) {\n appLogger(\n `Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n\n // Mark JSON for removal\n filesToRemove.push(mergedFilePath);\n\n // Mark TS Types for removal\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n\n // Mark Dynamic Dictionaries for removal\n // We use glob to catch the loader files (.cjs, .mjs) AND the split locale files (.en.json, etc.)\n const dynamicFilesGlob = join(\n configuration.system.dynamicDictionariesDir,\n `${dictionary.key}.*`\n );\n const dynamicFiles = await fg(normalizePath(dynamicFilesGlob), {\n absolute: true,\n });\n filesToRemove.push(...dynamicFiles);\n\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n } else {\n const localIds = parsedContent.localIds?.filter(\n (localeId) => !localeId.endsWith(`::local::${relativeFilePath}`)\n ) as string[];\n const newContent = { ...parsedContent, localIds };\n await writeJsonIfChanged(mergedFilePath, newContent);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n }\n }\n })\n );\n\n // Execute Cleanup\n if (filesToRemove.length > 0 || excludeKeys.length > 0) {\n // Update entry points (indexes) first so the app doesn't import dead files\n await createDictionaryEntryPoint(configuration, { excludeKeys });\n\n // Remove the files synchronously (awaited) immediately after.\n if (filesToRemove.length > 0) {\n setTimeout(\n async () =>\n await Promise.all(\n filesToRemove.map(async (path) => {\n const relativePath = relative(baseDir, path);\n try {\n await rm(path, { force: true });\n\n appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, {\n isVerbose: true,\n });\n } catch {\n appLogger(\n `Error while removing file ${colorizePath(relativePath)}`,\n {\n isVerbose: true,\n }\n );\n }\n })\n ),\n 3000\n );\n }\n }\n\n return {\n changedDictionariesLocalIds,\n excludeKeys,\n hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0,\n };\n};\n"],"mappings":";;;;;;;;;;AAeA,MAAa,iCAAiC,OAC5C,UACA,YACA,kBAKI;CACJ,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,uBAAuB,yBAE3B,cAAc,OAAO,wBAAwB;CAE/C,MAAM,UAAU,cAAc,OAAO;CAErC,MAAM,mBAAmB,SAAS,SAAS,SAAS;CAUpD,MAAM,6BAT2B,OAAO,OAAO,qBAAqB,CAAC,MAER,CAAC,QAC3D,eACC,WAAW,aAAa,oBACxB,CAAC,WAAW,SAAS,WAAW,IAAI,CAIuB,CAAC,QAC7D,YAAY,OAAO,SAClB,UAAU,KAAK,WAAW,MAAM,EAAE,QAAQ,WAAW,IAAI,CAC5D;CAED,MAAM,8BAAwC,EAAE;CAChD,MAAM,gBAA0B,EAAE;CAClC,MAAM,cAAwB,EAAE;CAGhC,MAAM,QAAQ,IACZ,2BAA2B,IAAI,OAAO,eAAe;EACnD,MAAM,mBAAmB,UACvB,KACE,cAAc,OAAO,yBACrB,GAAG,WAAW,IAAI,OACnB,CACF;EAED,IAAI;GACF,MAAM,cAAc,MAAM,SAAS,kBAAkB,OAAO;GAC5D,MAAM,gBAAgB,KAAK,MAAM,YAAY;GAE7C,IAAI,cAAc,WAAW,GAC3B;QAAI,cAAc,GAAG,aAAa,kBAAkB;KAClD,UACE,gCAAgC,YAAY,WAAW,IAAI,IAC3D,EAAE,WAAW,MAAM,CACpB;KACD,cAAc,KAAK,iBAAiB;KACpC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,CAAC,YAAY,SAAS,WAAW,IAAI,EACvC,YAAY,KAAK,WAAW,IAAI;;UAG/B;IACL,MAAM,WAAW,cAAc,UAAU,QACtC,aAAa,CAAC,SAAS,SAAS,YAAY,mBAAmB,CACjE;IAED,MAAM,mBAAmB,gBAAgB;KADpB,GAAG;KAAe;KACY,CAAC;;WAE/C,OAAY;GACnB,IAAI,MAAM,SAAS,UAAU;IAC3B,IAAI,CAAC,YAAY,SAAS,WAAW,IAAI,EACvC,YAAY,KAAK,WAAW,IAAI;IAElC,MAAM,gBAAgB,UACpB,KAAK,cAAc,OAAO,UAAU,GAAG,WAAW,IAAI,KAAK,CAC5D;IACD,cAAc,KAAK,cAAc;;;GAGrC,CACH;CAGD,IAAI,cAAc,SAAS,KAAK,YAAY,SAAS,GAAG;EAEtD,MAAM,2BAA2B,eAAe,EAAE,aAAa,CAAC;EAGhE,IAAI,cAAc,SAAS,GACzB,WACE,YACE,MAAM,QAAQ,IACZ,cAAc,IAAI,OAAO,SAAS;GAChC,MAAM,eAAe,SAAS,SAAS,KAAK;GAC5C,IAAI;IACF,MAAM,GAAG,MAAM,EAAE,OAAO,MAAM,CAAC;IAE/B,UAAU,qBAAqB,aAAa,aAAa,IAAI,EAC3D,WAAW,MACZ,CAAC;WACI;IACN,UACE,6BAA6B,aAAa,aAAa,IACvD,EACE,WAAW,MACZ,CACF;;IAEH,CACH,EACH,IACD;;CAIL,OAAO;EACL;EACA;EACA,YAAY,cAAc,SAAS,KAAK,YAAY,SAAS;EAC9D"}
1
+ {"version":3,"file":"cleanRemovedContentDeclaration.mjs","names":[],"sources":["../../src/cleanRemovedContentDeclaration.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { join, normalize, relative } from 'node:path';\nimport { normalizePath } from '@intlayer/config/client';\nimport {\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport fg from 'fast-glob';\nimport { createDictionaryEntryPoint } from './createDictionaryEntryPoint';\nimport { readDictionariesFromDisk } from './utils/readDictionariesFromDisk';\nimport { writeJsonIfChanged } from './writeJsonIfChanged';\n\nexport const cleanRemovedContentDeclaration = async (\n filePath: string,\n keysToKeep: string[],\n configuration: IntlayerConfig\n): Promise<{\n changedDictionariesLocalIds: string[];\n excludeKeys: string[];\n hasRebuilt: boolean;\n}> => {\n const appLogger = getAppLogger(configuration);\n\n const unmergedDictionaries = readDictionariesFromDisk<\n Record<string, Dictionary[]>\n >(configuration.system.unmergedDictionariesDir);\n\n const baseDir = configuration.system.baseDir;\n\n const relativeFilePath = relative(baseDir, filePath);\n const flatUnmergedDictionaries = Object.values(unmergedDictionaries).flat();\n\n const filteredUnmergedDictionaries = flatUnmergedDictionaries.filter(\n (dictionary) =>\n dictionary.filePath === relativeFilePath &&\n !keysToKeep.includes(dictionary.key)\n );\n\n // Deduplicate dictionaries by key\n const uniqueUnmergedDictionaries = filteredUnmergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n const changedDictionariesLocalIds: string[] = [];\n const filesToRemove: string[] = [];\n const excludeKeys: string[] = [];\n\n // Identify Unmerged Dictionaries to remove or clean\n await Promise.all(\n uniqueUnmergedDictionaries.map(async (dictionary) => {\n const unmergedFilePath = normalize(\n join(\n configuration.system.unmergedDictionariesDir,\n `${dictionary.key}.json`\n )\n );\n\n try {\n const jsonContent = await readFile(unmergedFilePath, 'utf8');\n const parsedContent = JSON.parse(jsonContent);\n\n if (parsedContent.length === 1) {\n if (parsedContent[0].filePath === relativeFilePath) {\n appLogger(\n `Removing outdated dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n filesToRemove.push(unmergedFilePath);\n excludeKeys.push(dictionary.key);\n }\n } else {\n const filteredContent = parsedContent.filter(\n (content: any) => content.filePath !== relativeFilePath\n );\n await writeJsonIfChanged(unmergedFilePath, filteredContent);\n changedDictionariesLocalIds.push(dictionary.localId!);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n }\n })\n );\n\n const dictionaries = readDictionariesFromDisk<Record<string, Dictionary>>(\n configuration.system.dictionariesDir\n );\n const flatDictionaries = Object.values(dictionaries) as Dictionary[];\n\n const filteredMergedDictionaries = flatDictionaries?.filter(\n (dictionary) =>\n !keysToKeep.includes(dictionary.key) &&\n dictionary.localIds?.length === 1 &&\n (dictionary.localIds[0] as string).endsWith(\n `::local::${relativeFilePath}`\n )\n );\n\n const uniqueMergedDictionaries = filteredMergedDictionaries.filter(\n (dictionary, index, self) =>\n index === self.findIndex((t) => t.key === dictionary.key)\n );\n\n // Identify Merged Dictionaries, Types, and Dynamic Dictionaries to remove\n await Promise.all(\n uniqueMergedDictionaries.map(async (dictionary) => {\n const mergedFilePath = normalize(\n join(configuration.system.dictionariesDir, `${dictionary.key}.json`)\n );\n\n try {\n const fileContent = await readFile(mergedFilePath, 'utf8');\n const parsedContent = JSON.parse(fileContent) as Dictionary;\n\n if (parsedContent.localIds?.length === 1) {\n if (\n parsedContent.localIds[0].endsWith(`::local::${relativeFilePath}`)\n ) {\n appLogger(\n `Removing outdated unmerged dictionary ${colorizeKey(dictionary.key)}`,\n { isVerbose: true }\n );\n\n // Mark JSON for removal\n filesToRemove.push(mergedFilePath);\n\n // Mark TS Types for removal\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n\n // Mark Dynamic Dictionaries for removal\n // We use glob to catch the loader files (.cjs, .mjs) AND the split locale files (.en.json, etc.)\n const dynamicFilesGlob = join(\n configuration.system.dynamicDictionariesDir,\n `${dictionary.key}.*`\n );\n const dynamicFiles = await fg(normalizePath(dynamicFilesGlob), {\n absolute: true,\n });\n filesToRemove.push(...dynamicFiles);\n\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n }\n } else {\n const localIds = parsedContent.localIds?.filter(\n (localeId) => !localeId.endsWith(`::local::${relativeFilePath}`)\n ) as string[];\n const newContent = { ...parsedContent, localIds };\n await writeJsonIfChanged(mergedFilePath, newContent);\n }\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n if (!excludeKeys.includes(dictionary.key)) {\n excludeKeys.push(dictionary.key);\n }\n const typesFilePath = normalize(\n join(configuration.system.typesDir, `${dictionary.key}.ts`)\n );\n filesToRemove.push(typesFilePath);\n }\n }\n })\n );\n\n // Execute Cleanup\n if (filesToRemove.length > 0 || excludeKeys.length > 0) {\n // Update entry points (indexes) first so the app doesn't import dead files\n await createDictionaryEntryPoint(configuration, { excludeKeys });\n\n // Remove the files synchronously (awaited) immediately after.\n if (filesToRemove.length > 0) {\n setTimeout(\n async () =>\n await Promise.all(\n filesToRemove.map(async (path) => {\n const relativePath = relative(baseDir, path);\n try {\n await rm(path, { force: true });\n\n appLogger(`Deleted artifact: ${colorizePath(relativePath)}`, {\n isVerbose: true,\n });\n } catch {\n appLogger(\n `Error while removing file ${colorizePath(relativePath)}`,\n {\n isVerbose: true,\n }\n );\n }\n })\n ),\n 3000\n );\n }\n }\n\n return {\n changedDictionariesLocalIds,\n excludeKeys,\n hasRebuilt: filesToRemove.length > 0 || excludeKeys.length > 0,\n };\n};\n"],"mappings":";;;;;;;;;;AAeA,MAAa,iCAAiC,OAC5C,UACA,YACA,kBAKI;CACJ,MAAM,YAAY,aAAa,aAAa;CAE5C,MAAM,uBAAuB,yBAE3B,cAAc,OAAO,uBAAuB;CAE9C,MAAM,UAAU,cAAc,OAAO;CAErC,MAAM,mBAAmB,SAAS,SAAS,QAAQ;CAUnD,MAAM,6BAT2B,OAAO,OAAO,oBAAoB,EAAE,KAET,EAAE,QAC3D,eACC,WAAW,aAAa,oBACxB,CAAC,WAAW,SAAS,WAAW,GAAG,CAIuB,EAAE,QAC7D,YAAY,OAAO,SAClB,UAAU,KAAK,WAAW,MAAM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,MAAM,GAAG,MAAM,EAAE,OAAO,KAAK,CAAC;IAE9B,UAAU,qBAAqB,aAAa,YAAY,KAAK,EAC3D,WAAW,KACb,CAAC;GACH,QAAQ;IACN,UACE,6BAA6B,aAAa,YAAY,KACtD,EACE,WAAW,KACb,CACF;GACF;EACF,CAAC,CACH,GACF,GACF;CAEJ;CAEA,OAAO;EACL;EACA;EACA,YAAY,cAAc,SAAS,KAAK,YAAY,SAAS;CAC/D;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"createDictionaryEntryPoint.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\nimport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from './getBuiltDynamicDictionariesPath';\nimport { getBuiltFetchDictionariesPath } from './getBuiltFetchDictionariesPath';\nimport { getBuiltRemoteDictionariesPath } from './getBuiltRemoteDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\n\nconst writeDictionaryFiles = async (\n paths: Promise<string[]>,\n fileName: string,\n importType: 'json' | 'javascript',\n functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const resolvedPath = await paths;\n\n const content = generateDictionaryListContent(\n resolvedPath,\n functionName,\n importType,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.system;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\nexport type CreateDictionaryEntryPointOptions = {\n formats?: ('cjs' | 'esm')[];\n excludeKeys?: string[];\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n options: CreateDictionaryEntryPointOptions = {}\n) => {\n const { formats, excludeKeys = [] } = options;\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.system;\n\n await mkdir(mainDir, { recursive: true });\n\n const writeOperations = [\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDictionariesPath(configuration, excludeKeys),\n importType: 'json',\n functionName: 'getDictionaries',\n fileName: 'dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltUnmergedDictionariesPath(configuration, excludeKeys),\n importType: 'json',\n functionName: 'getUnmergedDictionaries',\n fileName: 'unmerged_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDynamicDictionariesPath(\n configuration,\n format,\n excludeKeys\n ),\n importType: 'javascript',\n functionName: 'getDynamicDictionaries',\n fileName: 'dynamic_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltFetchDictionariesPath(\n configuration,\n format,\n excludeKeys\n ),\n importType: 'javascript',\n functionName: 'getFetchDictionaries',\n fileName: 'fetch_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltRemoteDictionariesPath(configuration, excludeKeys),\n importType: 'json',\n functionName: 'getRemoteDictionaries',\n fileName: 'remote_dictionaries' as const,\n format,\n }) as const\n ),\n ];\n\n await parallelize(\n writeOperations,\n async ({ paths, fileName, format, functionName, importType }) =>\n await writeDictionaryFiles(\n paths,\n fileName,\n importType,\n functionName,\n format,\n configuration\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,uBAAuB,OAC3B,OACA,UACA,YACA,cACA,QACA,gBAAgB,kBAAkB,KAC/B;CAGH,MAAM,UAAU,8BACd,MAHyB,OAIzB,cACA,YACA,QACA,cACD;CACD,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAE7C,MAAM,EAAE,YAAY,cAAc;CAElC,MAAM,mBACJ,QAAQ,SAAS,GAAG,SAAS,GAAG,YAAY,EAC5C,QACD;;;;;AAWH,MAAa,6BAA6B,OACxC,gBAAgB,kBAAkB,EAClC,UAA6C,EAAE,KAC5C;CACH,MAAM,EAAE,SAAS,cAAc,EAAE,KAAK;CACtC,MAAM,gBAAgB,WAAW,cAAc,MAAM;CACrD,MAAM,EAAE,YAAY,cAAc;CAElC,MAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CA+DzC,MAAM,YACJ;EA7DA,GAAG,cAAc,KACd,YACE;GACC,OAAO,yBAAyB,eAAe,YAAY;GAC3D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,iCAAiC,eAAe,YAAY;GACnE,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,gCACL,eACA,QACA,YACD;GACD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,8BACL,eACA,QACA,YACD;GACD,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EACD,GAAG,cAAc,KACd,YACE;GACC,OAAO,+BAA+B,eAAe,YAAY;GACjE,YAAY;GACZ,cAAc;GACd,UAAU;GACV;GACD,EACJ;EAIc,EACf,OAAO,EAAE,OAAO,UAAU,QAAQ,cAAc,iBAC9C,MAAM,qBACJ,OACA,UACA,YACA,cACA,QACA,cACD,CACJ"}
1
+ {"version":3,"file":"createDictionaryEntryPoint.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { generateDictionaryListContent } from './generateDictionaryListContent';\nimport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nimport { getBuiltDynamicDictionariesPath } from './getBuiltDynamicDictionariesPath';\nimport { getBuiltFetchDictionariesPath } from './getBuiltFetchDictionariesPath';\nimport { getBuiltRemoteDictionariesPath } from './getBuiltRemoteDictionariesPath';\nimport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\n\nconst writeDictionaryFiles = async (\n paths: Promise<string[]>,\n fileName: string,\n importType: 'json' | 'javascript',\n functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const resolvedPath = await paths;\n\n const content = generateDictionaryListContent(\n resolvedPath,\n functionName,\n importType,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.system;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\nexport type CreateDictionaryEntryPointOptions = {\n formats?: ('cjs' | 'esm')[];\n excludeKeys?: string[];\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n options: CreateDictionaryEntryPointOptions = {}\n) => {\n const { formats, excludeKeys = [] } = options;\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.system;\n\n await mkdir(mainDir, { recursive: true });\n\n const writeOperations = [\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDictionariesPath(configuration, excludeKeys),\n importType: 'json',\n functionName: 'getDictionaries',\n fileName: 'dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltUnmergedDictionariesPath(configuration, excludeKeys),\n importType: 'json',\n functionName: 'getUnmergedDictionaries',\n fileName: 'unmerged_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltDynamicDictionariesPath(\n configuration,\n format,\n excludeKeys\n ),\n importType: 'javascript',\n functionName: 'getDynamicDictionaries',\n fileName: 'dynamic_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltFetchDictionariesPath(\n configuration,\n format,\n excludeKeys\n ),\n importType: 'javascript',\n functionName: 'getFetchDictionaries',\n fileName: 'fetch_dictionaries' as const,\n format,\n }) as const\n ),\n ...outputFormats.map(\n (format) =>\n ({\n paths: getBuiltRemoteDictionariesPath(configuration, excludeKeys),\n importType: 'json',\n functionName: 'getRemoteDictionaries',\n fileName: 'remote_dictionaries' as const,\n format,\n }) as const\n ),\n ];\n\n await parallelize(\n writeOperations,\n async ({ paths, fileName, format, functionName, importType }) =>\n await writeDictionaryFiles(\n paths,\n fileName,\n importType,\n functionName,\n format,\n configuration\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,uBAAuB,OAC3B,OACA,UACA,YACA,cACA,QACA,gBAAgB,iBAAiB,MAC9B;CAGH,MAAM,UAAU,8BACd,MAHyB,OAIzB,cACA,YACA,QACA,aACF;CACA,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAE7C,MAAM,EAAE,YAAY,cAAc;CAElC,MAAM,mBACJ,QAAQ,SAAS,GAAG,SAAS,GAAG,WAAW,GAC3C,OACF;AACF;;;;AAUA,MAAa,6BAA6B,OACxC,gBAAgB,iBAAiB,GACjC,UAA6C,CAAC,MAC3C;CACH,MAAM,EAAE,SAAS,cAAc,CAAC,MAAM;CACtC,MAAM,gBAAgB,WAAW,cAAc,MAAM;CACrD,MAAM,EAAE,YAAY,cAAc;CAElC,MAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;CA+DxC,MAAM,YACJ;EA7DA,GAAG,cAAc,KACd,YACE;GACC,OAAO,yBAAyB,eAAe,WAAW;GAC1D,YAAY;GACZ,cAAc;GACd,UAAU;GACV;EACF,EACJ;EACA,GAAG,cAAc,KACd,YACE;GACC,OAAO,iCAAiC,eAAe,WAAW;GAClE,YAAY;GACZ,cAAc;GACd,UAAU;GACV;EACF,EACJ;EACA,GAAG,cAAc,KACd,YACE;GACC,OAAO,gCACL,eACA,QACA,WACF;GACA,YAAY;GACZ,cAAc;GACd,UAAU;GACV;EACF,EACJ;EACA,GAAG,cAAc,KACd,YACE;GACC,OAAO,8BACL,eACA,QACA,WACF;GACA,YAAY;GACZ,cAAc;GACd,UAAU;GACV;EACF,EACJ;EACA,GAAG,cAAc,KACd,YACE;GACC,OAAO,+BAA+B,eAAe,WAAW;GAChE,YAAY;GACZ,cAAc;GACd,UAAU;GACV;EACF,EACJ;CAIc,GACd,OAAO,EAAE,OAAO,UAAU,QAAQ,cAAc,iBAC9C,MAAM,qBACJ,OACA,UACA,YACA,cACA,QACA,aACF,CACJ;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateDictionaryListContent.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":["import { basename, extname, relative } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { normalizePath } from '@intlayer/config/utils';\nimport { getPathHash } from '../utils/getPathHash';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n functionName: string,\n importType: 'json' | 'javascript',\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.system;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getPathHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}'${importType === 'json' ? \" with { type: 'json' }\" : ''};\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n content += `const dictionaries = {\\n${formattedDictionaryMap}\\n};\\n`;\n content += `const ${functionName} = () => dictionaries;\\n`;\n\n if (format === 'esm') {\n content += `\\n`;\n content += `export { ${functionName} };\\n`;\n content += `export default dictionaries;\\n`;\n }\n\n if (format === 'cjs') {\n content += `\\n`;\n content += `module.exports.${functionName} = ${functionName};\\n`;\n content += `module.exports = dictionaries;\\n`;\n }\n\n return content;\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,iCACX,cACA,cACA,YACA,SAAwB,OACxB,gBAAgB,kBAAkB,KACvB;CACX,MAAM,EAAE,YAAY,cAAc;CAElC,IAAI,UAAU;CAEd,MAAM,kBAAkB,aAAa,KAAK,oBAAoB;EAC5D,cAAc,cAAc,SAAS,SAAS,eAAe,CAAC;EAC9D,IAAI,SAAS,gBAAgB,QAAQ,eAAe,CAAC;EACrD,MAAM,IAAI,YAAY,eAAe;EACtC,EAAE;CAEH,gBAAgB,SAAS,eAAe;EACtC,IAAI,WAAW,OACb,WAAW,UAAU,WAAW,KAAK,SAAS,WAAW,aAAa,GAAG,eAAe,SAAS,2BAA2B,GAAG;EACjI,IAAI,WAAW,OACb,WAAW,SAAS,WAAW,KAAK,cAAc,WAAW,aAAa;GAC5E;CAEF,WAAW;CAGX,MAAM,yBAAiC,gBACpC,KAAK,eAAe,MAAM,WAAW,GAAG,KAAK,WAAW,OAAO,CAC/D,KAAK,MAAM;CAEd,WAAW,2BAA2B,uBAAuB;CAC7D,WAAW,SAAS,aAAa;CAEjC,IAAI,WAAW,OAAO;EACpB,WAAW;EACX,WAAW,YAAY,aAAa;EACpC,WAAW;;CAGb,IAAI,WAAW,OAAO;EACpB,WAAW;EACX,WAAW,kBAAkB,aAAa,KAAK,aAAa;EAC5D,WAAW;;CAGb,OAAO"}
1
+ {"version":3,"file":"generateDictionaryListContent.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"sourcesContent":["import { basename, extname, relative } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { normalizePath } from '@intlayer/config/utils';\nimport { getPathHash } from '../utils/getPathHash';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n functionName: string,\n importType: 'json' | 'javascript',\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.system;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getPathHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}'${importType === 'json' ? \" with { type: 'json' }\" : ''};\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n content += `const dictionaries = {\\n${formattedDictionaryMap}\\n};\\n`;\n content += `const ${functionName} = () => dictionaries;\\n`;\n\n if (format === 'esm') {\n content += `\\n`;\n content += `export { ${functionName} };\\n`;\n content += `export default dictionaries;\\n`;\n }\n\n if (format === 'cjs') {\n content += `\\n`;\n content += `module.exports.${functionName} = ${functionName};\\n`;\n content += `module.exports = dictionaries;\\n`;\n }\n\n return content;\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,iCACX,cACA,cACA,YACA,SAAwB,OACxB,gBAAgB,iBAAiB,MACtB;CACX,MAAM,EAAE,YAAY,cAAc;CAElC,IAAI,UAAU;CAEd,MAAM,kBAAkB,aAAa,KAAK,oBAAoB;EAC5D,cAAc,cAAc,SAAS,SAAS,cAAc,CAAC;EAC7D,IAAI,SAAS,gBAAgB,QAAQ,cAAc,CAAC;EACpD,MAAM,IAAI,YAAY,cAAc;CACtC,EAAE;CAEF,gBAAgB,SAAS,eAAe;EACtC,IAAI,WAAW,OACb,WAAW,UAAU,WAAW,KAAK,SAAS,WAAW,aAAa,GAAG,eAAe,SAAS,2BAA2B,GAAG;EACjI,IAAI,WAAW,OACb,WAAW,SAAS,WAAW,KAAK,cAAc,WAAW,aAAa;CAC9E,CAAC;CAED,WAAW;CAGX,MAAM,yBAAiC,gBACpC,KAAK,eAAe,MAAM,WAAW,GAAG,KAAK,WAAW,MAAM,EAC9D,KAAK,KAAK;CAEb,WAAW,2BAA2B,uBAAuB;CAC7D,WAAW,SAAS,aAAa;CAEjC,IAAI,WAAW,OAAO;EACpB,WAAW;EACX,WAAW,YAAY,aAAa;EACpC,WAAW;CACb;CAEA,IAAI,WAAW,OAAO;EACpB,WAAW;EACX,WAAW,kBAAkB,aAAa,KAAK,aAAa;EAC5D,WAAW;CACb;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { dictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(dictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,2BAA2B,OACtC,eACA,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,iBAAiB,YAAY,cAAc;CAGnD,IAAI,CAAC,WAAW,QAAQ,EACtB,MAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CAO3C,QAAO,MAJkC,GACvC,GAAG,cAAc,gBAAgB,CAAC,YACnC,EAEuB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,QAAQ;EACnC,OAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
1
+ {"version":3,"file":"getBuiltDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { dictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(dictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,2BAA2B,OACtC,eACA,cAAwB,CAAC,MACtB;CACH,MAAM,EAAE,iBAAiB,YAAY,cAAc;CAGnD,IAAI,CAAC,WAAW,OAAO,GACrB,MAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;CAO1C,QAAO,MAJkC,GACvC,GAAG,cAAc,eAAe,EAAE,WACpC,GAEwB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,OAAO;EAClC,OAAO,CAAC,YAAY,SAAS,GAAG;CAClC,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltDynamicDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDynamicDictionariesPath = async (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm' = 'esm',\n excludeKeys: string[] = []\n) => {\n const { dynamicDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(dynamicDictionariesDir)}/*.${extension}`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, `.${extension}`);\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,kCAAkC,OAC7C,eACA,SAAwB,OACxB,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,wBAAwB,YAAY,cAAc;CAG1D,IAAI,CAAC,WAAW,QAAQ,EACtB,MAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CAG3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAM7C,QAAO,MAJkC,GACvC,GAAG,cAAc,uBAAuB,CAAC,KAAK,YAC/C,EAEuB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,IAAI,YAAY;EAC3C,OAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
1
+ {"version":3,"file":"getBuiltDynamicDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltDynamicDictionariesPath = async (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm' = 'esm',\n excludeKeys: string[] = []\n) => {\n const { dynamicDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(dynamicDictionariesDir)}/*.${extension}`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, `.${extension}`);\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,kCAAkC,OAC7C,eACA,SAAwB,OACxB,cAAwB,CAAC,MACtB;CACH,MAAM,EAAE,wBAAwB,YAAY,cAAc;CAG1D,IAAI,CAAC,WAAW,OAAO,GACrB,MAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;CAG1C,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAM7C,QAAO,MAJkC,GACvC,GAAG,cAAc,sBAAsB,EAAE,KAAK,WAChD,GAEwB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,IAAI,WAAW;EAC1C,OAAO,CAAC,YAAY,SAAS,GAAG;CAClC,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltFetchDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltFetchDictionariesPath = async (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm' = 'esm',\n excludeKeys: string[] = []\n) => {\n const { fetchDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(fetchDictionariesDir)}/*.${extension}`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, `.${extension}`);\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,gCAAgC,OAC3C,eACA,SAAwB,OACxB,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,sBAAsB,YAAY,cAAc;CAGxD,IAAI,CAAC,WAAW,QAAQ,EACtB,MAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CAG3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAM7C,QAAO,MAJkC,GACvC,GAAG,cAAc,qBAAqB,CAAC,KAAK,YAC7C,EAEuB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,IAAI,YAAY;EAC3C,OAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
1
+ {"version":3,"file":"getBuiltFetchDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltFetchDictionariesPath = async (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm' = 'esm',\n excludeKeys: string[] = []\n) => {\n const { fetchDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(fetchDictionariesDir)}/*.${extension}`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, `.${extension}`);\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,gCAAgC,OAC3C,eACA,SAAwB,OACxB,cAAwB,CAAC,MACtB;CACH,MAAM,EAAE,sBAAsB,YAAY,cAAc;CAGxD,IAAI,CAAC,WAAW,OAAO,GACrB,MAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;CAG1C,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAM7C,QAAO,MAJkC,GACvC,GAAG,cAAc,oBAAoB,EAAE,KAAK,WAC9C,GAEwB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,IAAI,WAAW;EAC1C,OAAO,CAAC,YAAY,SAAS,GAAG;CAClC,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltRemoteDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltRemoteDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { remoteDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = fg.sync(\n `${normalizePath(remoteDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,iCAAiC,OAC5C,eACA,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,uBAAuB,YAAY,cAAc;CAGzD,IAAI,CAAC,WAAW,QAAQ,EACtB,MAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CAO3C,OAJmC,GAAG,KACpC,GAAG,cAAc,sBAAsB,CAAC,YAGnB,CAAC,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,QAAQ;EACnC,OAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
1
+ {"version":3,"file":"getBuiltRemoteDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltRemoteDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { remoteDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = fg.sync(\n `${normalizePath(remoteDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,iCAAiC,OAC5C,eACA,cAAwB,CAAC,MACtB;CACH,MAAM,EAAE,uBAAuB,YAAY,cAAc;CAGzD,IAAI,CAAC,WAAW,OAAO,GACrB,MAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;CAO1C,OAJmC,GAAG,KACpC,GAAG,cAAc,qBAAqB,EAAE,WAGpB,EAAE,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,OAAO;EAClC,OAAO,CAAC,YAAY,SAAS,GAAG;CAClC,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltUnmergedDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltUnmergedDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { unmergedDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(unmergedDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,mCAAmC,OAC9C,eACA,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,yBAAyB,YAAY,cAAc;CAG3D,IAAI,CAAC,WAAW,QAAQ,EACtB,MAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CAO3C,QAAO,MAJkC,GACvC,GAAG,cAAc,wBAAwB,CAAC,YAC3C,EAEuB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,QAAQ;EACnC,OAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
1
+ {"version":3,"file":"getBuiltUnmergedDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltUnmergedDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { unmergedDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n await mkdir(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(unmergedDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,mCAAmC,OAC9C,eACA,cAAwB,CAAC,MACtB;CACH,MAAM,EAAE,yBAAyB,YAAY,cAAc;CAG3D,IAAI,CAAC,WAAW,OAAO,GACrB,MAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;CAO1C,QAAO,MAJkC,GACvC,GAAG,cAAc,uBAAuB,EAAE,WAC5C,GAEwB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,OAAO;EAClC,OAAO,CAAC,YAAY,SAAS,GAAG;CAClC,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"createModuleAugmentation.mjs","names":[],"sources":["../../../src/createType/createModuleAugmentation.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { basename, extname, join, relative } from 'node:path';\nimport { kebabCaseToCamelCase, normalizePath } from '@intlayer/config/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\nimport { getPathHash } from '../utils';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/** Returns lines like: [Locales.FRENCH]: 1; */\nconst formatLocales = (locales: Locale[]) =>\n locales.map((locale) => ` \"${locale}\": 1;`).join('\\n');\n\nconst zodToTsString = (schema: any): string => {\n if (!schema) return 'any';\n\n // Support both real Zod objects (_def) and serialized versions (def or nested)\n const def = schema._def ?? schema.def ?? schema;\n\n // Handle serialized type names (sometimes 'type' instead of 'typeName')\n const typeName = def.typeName ?? def.type;\n\n switch (typeName) {\n case 'ZodString':\n case 'string':\n return 'string';\n case 'ZodNumber':\n case 'number':\n return 'number';\n case 'ZodBoolean':\n case 'boolean':\n return 'boolean';\n case 'ZodNull':\n case 'null':\n return 'null';\n case 'ZodUndefined':\n case 'undefined':\n return 'undefined';\n case 'ZodArray':\n case 'array':\n return `${zodToTsString(def.type ?? def.element)}[]`;\n case 'ZodObject':\n case 'object': {\n const shape = typeof def.shape === 'function' ? def.shape() : def.shape;\n if (!shape) return 'Record<string, any>';\n\n const entries = Object.entries(shape)\n .map(([k, v]) => ` \"${k}\": ${zodToTsString(v)};`)\n .join('\\n');\n return `{\\n${entries}\\n }`;\n }\n case 'ZodOptional':\n case 'optional':\n return `${zodToTsString(def.innerType ?? def.wrapped)} | undefined`;\n case 'ZodNullable':\n case 'nullable':\n return `${zodToTsString(def.innerType ?? def.wrapped)} | null`;\n case 'ZodUnion':\n case 'union': {\n const options = def.options ?? [];\n return options.map(zodToTsString).join(' | ');\n }\n case 'ZodIntersection':\n case 'intersection':\n return `${zodToTsString(def.left)} & ${zodToTsString(def.right)}`;\n case 'ZodEnum':\n case 'enum': {\n const values = def.values ?? [];\n return values.map((v: string) => `\"${v}\"`).join(' | ');\n }\n case 'ZodLiteral':\n case 'literal': {\n const value = def.value;\n return typeof value === 'string' ? `\"${value}\"` : String(value);\n }\n default:\n return 'any';\n }\n};\n\ntype ZodToTsFns = {\n zodToTs: (schema: any, opts?: any) => { node: any };\n printNode: (node: any) => string;\n createAuxiliaryTypeStore: () => any;\n};\n\n/** Generate the content of the module augmentation file */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration: IntlayerConfig,\n zodToTsFns: ZodToTsFns | null\n): string => {\n const { internationalization, system, editor } = configuration;\n const { moduleAugmentationDir } = system;\n const { enabled } = editor;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent = 'import \"intlayer\";\\n';\n\n // Build dictionary refs\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)),\n hash: `_${getPathHash(dictionaryPath)}`,\n }));\n\n // Import all dictionaries\n for (const dictionary of dictionariesRef) {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n }\n fileContent += '\\n';\n\n // Dictionary map entries (id: typeof <hash>)\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n // Ensure required ⊆ declared; if empty, default required = declared\n const declared = locales;\n const requiredSanitized = requiredLocales?.length\n ? requiredLocales.filter((requiredLocales) =>\n declared.includes(requiredLocales)\n )\n : declared;\n\n const formattedDeclaredLocales = formatLocales(declared);\n const formattedRequiredLocales = formatLocales(requiredSanitized);\n\n // Build schema registry\n const schemas = configuration.schemas ?? {};\n const formattedSchemas = Object.entries(schemas)\n .map(([key, schema]) => {\n let typeStr = 'any';\n\n if (schema) {\n try {\n if (zodToTsFns) {\n const { node } = zodToTsFns.zodToTs(schema, {\n auxiliaryTypeStore: zodToTsFns.createAuxiliaryTypeStore(),\n });\n // 133 is the kind for AnyKeyword in TypeScript\n if ((node as any).kind !== 133) {\n typeStr = zodToTsFns.printNode(node);\n } else {\n typeStr = zodToTsString(schema);\n }\n } else {\n typeStr = zodToTsString(schema);\n }\n } catch (_e) {\n // Fallback to custom string generator\n typeStr = zodToTsString(schema);\n }\n }\n return ` \"${key}\": ${typeStr};`;\n })\n .join('\\n');\n\n // Choose strict mode registry key\n const strictKey =\n strictMode === 'strict'\n ? 'strict'\n : strictMode === 'inclusive'\n ? 'inclusive'\n : 'loose';\n\n /**\n * Module augmentation that ONLY adds keys to registries.\n * No types/aliases redefined here—avoids merge conflicts.\n */\n fileContent += `declare module 'intlayer' {\\n`;\n // Dictionaries registry\n fileContent += ` interface __DictionaryRegistry {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n // Locales registries\n fileContent += ` interface __DeclaredLocalesRegistry {\\n${formattedDeclaredLocales}\\n }\\n\\n`;\n fileContent += ` interface __RequiredLocalesRegistry {\\n${formattedRequiredLocales}\\n }\\n\\n`;\n // Schema registry\n fileContent += ` interface __SchemaRegistry {\\n${formattedSchemas}\\n }\\n\\n`;\n // Resolved strict mode (narrow the literal at build time)\n fileContent += ` interface __StrictModeRegistry { mode: '${strictKey}' }\\n\\n`;\n // Editor registry\n fileContent += ` interface __EditorRegistry { enabled : ${enabled} } \\n`;\n fileContent += `}\\n`;\n\n return fileContent;\n};\n\n/** Generate the index file merging all the types */\nexport const createModuleAugmentation = async (\n configuration: IntlayerConfig\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.system;\n\n await mkdir(moduleAugmentationDir, { recursive: true });\n\n const dictionariesTypesDefinitions: string[] = await fg(\n normalizePath(`${typesDir}/*.ts`),\n { ignore: ['**/*.d.ts'] }\n );\n\n let zodToTsFns: ZodToTsFns | null = null;\n try {\n const mod = await import('zod-to-ts');\n zodToTsFns = {\n zodToTs: mod.zodToTs,\n printNode: mod.printNode,\n createAuxiliaryTypeStore: mod.createAuxiliaryTypeStore,\n };\n } catch {\n // typescript peer dep not installed (plain JS project), use fallback\n }\n\n const tsContent = generateTypeIndexContent(\n dictionariesTypesDefinitions,\n configuration,\n zodToTsFns\n );\n\n const tsFilePath = join(moduleAugmentationDir, 'intlayer.d.ts');\n await writeFileIfChanged(tsFilePath, tsContent);\n};\n"],"mappings":";;;;;;;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O;;EAGnC,OAAO,QAAQ,IAAI,KAAK,QAAQ;GAChC,CACD,KAAK,KAAK;CAGb,MAAM,YACJ,eAAe,WACX,WACA,eAAe,cACb,cACA;;;;;CAMR,eAAe;CAEf,eAAe,uCAAuC,uBAAuB;CAE7E,eAAe,4CAA4C,yBAAyB;CACpF,eAAe,4CAA4C,yBAAyB;CAEpF,eAAe,mCAAmC,iBAAiB;CAEnE,eAAe,6CAA6C,UAAU;CAEtE,eAAe,4CAA4C,QAAQ;CACnE,eAAe;CAEf,OAAO;;;AAIT,MAAa,2BAA2B,OACtC,kBACG;CACH,MAAM,EAAE,uBAAuB,aAAa,cAAc;CAE1D,MAAM,MAAM,uBAAuB,EAAE,WAAW,MAAM,CAAC;CAEvD,MAAM,+BAAyC,MAAM,GACnD,cAAc,GAAG,SAAS,OAAO,EACjC,EAAE,QAAQ,CAAC,YAAY,EAAE,CAC1B;CAED,IAAI,aAAgC;CACpC,IAAI;EACF,MAAM,MAAM,MAAM,OAAO;EACzB,aAAa;GACX,SAAS,IAAI;GACb,WAAW,IAAI;GACf,0BAA0B,IAAI;GAC/B;SACK;CAIR,MAAM,YAAY,yBAChB,8BACA,eACA,WACD;CAGD,MAAM,mBADa,KAAK,uBAAuB,gBACZ,EAAE,UAAU"}
1
+ {"version":3,"file":"createModuleAugmentation.mjs","names":[],"sources":["../../../src/createType/createModuleAugmentation.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { basename, extname, join, relative } from 'node:path';\nimport { kebabCaseToCamelCase, normalizePath } from '@intlayer/config/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\nimport { getPathHash } from '../utils';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/** Returns lines like: [Locales.FRENCH]: 1; */\nconst formatLocales = (locales: Locale[]) =>\n locales.map((locale) => ` \"${locale}\": 1;`).join('\\n');\n\nconst zodToTsString = (schema: any): string => {\n if (!schema) return 'any';\n\n // Support both real Zod objects (_def) and serialized versions (def or nested)\n const def = schema._def ?? schema.def ?? schema;\n\n // Handle serialized type names (sometimes 'type' instead of 'typeName')\n const typeName = def.typeName ?? def.type;\n\n switch (typeName) {\n case 'ZodString':\n case 'string':\n return 'string';\n case 'ZodNumber':\n case 'number':\n return 'number';\n case 'ZodBoolean':\n case 'boolean':\n return 'boolean';\n case 'ZodNull':\n case 'null':\n return 'null';\n case 'ZodUndefined':\n case 'undefined':\n return 'undefined';\n case 'ZodArray':\n case 'array':\n return `${zodToTsString(def.type ?? def.element)}[]`;\n case 'ZodObject':\n case 'object': {\n const shape = typeof def.shape === 'function' ? def.shape() : def.shape;\n if (!shape) return 'Record<string, any>';\n\n const entries = Object.entries(shape)\n .map(([k, v]) => ` \"${k}\": ${zodToTsString(v)};`)\n .join('\\n');\n return `{\\n${entries}\\n }`;\n }\n case 'ZodOptional':\n case 'optional':\n return `${zodToTsString(def.innerType ?? def.wrapped)} | undefined`;\n case 'ZodNullable':\n case 'nullable':\n return `${zodToTsString(def.innerType ?? def.wrapped)} | null`;\n case 'ZodUnion':\n case 'union': {\n const options = def.options ?? [];\n return options.map(zodToTsString).join(' | ');\n }\n case 'ZodIntersection':\n case 'intersection':\n return `${zodToTsString(def.left)} & ${zodToTsString(def.right)}`;\n case 'ZodEnum':\n case 'enum': {\n const values = def.values ?? [];\n return values.map((v: string) => `\"${v}\"`).join(' | ');\n }\n case 'ZodLiteral':\n case 'literal': {\n const value = def.value;\n return typeof value === 'string' ? `\"${value}\"` : String(value);\n }\n default:\n return 'any';\n }\n};\n\ntype ZodToTsFns = {\n zodToTs: (schema: any, opts?: any) => { node: any };\n printNode: (node: any) => string;\n createAuxiliaryTypeStore: () => any;\n};\n\n/** Generate the content of the module augmentation file */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration: IntlayerConfig,\n zodToTsFns: ZodToTsFns | null\n): string => {\n const { internationalization, system, editor } = configuration;\n const { moduleAugmentationDir } = system;\n const { enabled } = editor;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent = 'import \"intlayer\";\\n';\n\n // Build dictionary refs\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)),\n hash: `_${getPathHash(dictionaryPath)}`,\n }));\n\n // Import all dictionaries\n for (const dictionary of dictionariesRef) {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n }\n fileContent += '\\n';\n\n // Dictionary map entries (id: typeof <hash>)\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n // Ensure required ⊆ declared; if empty, default required = declared\n const declared = locales;\n const requiredSanitized = requiredLocales?.length\n ? requiredLocales.filter((requiredLocales) =>\n declared.includes(requiredLocales)\n )\n : declared;\n\n const formattedDeclaredLocales = formatLocales(declared);\n const formattedRequiredLocales = formatLocales(requiredSanitized);\n\n // Build schema registry\n const schemas = configuration.schemas ?? {};\n const formattedSchemas = Object.entries(schemas)\n .map(([key, schema]) => {\n let typeStr = 'any';\n\n if (schema) {\n try {\n if (zodToTsFns) {\n const { node } = zodToTsFns.zodToTs(schema, {\n auxiliaryTypeStore: zodToTsFns.createAuxiliaryTypeStore(),\n });\n // 133 is the kind for AnyKeyword in TypeScript\n if ((node as any).kind !== 133) {\n typeStr = zodToTsFns.printNode(node);\n } else {\n typeStr = zodToTsString(schema);\n }\n } else {\n typeStr = zodToTsString(schema);\n }\n } catch (_e) {\n // Fallback to custom string generator\n typeStr = zodToTsString(schema);\n }\n }\n return ` \"${key}\": ${typeStr};`;\n })\n .join('\\n');\n\n // Choose strict mode registry key\n const strictKey =\n strictMode === 'strict'\n ? 'strict'\n : strictMode === 'inclusive'\n ? 'inclusive'\n : 'loose';\n\n /**\n * Module augmentation that ONLY adds keys to registries.\n * No types/aliases redefined here—avoids merge conflicts.\n */\n fileContent += `declare module 'intlayer' {\\n`;\n // Dictionaries registry\n fileContent += ` interface __DictionaryRegistry {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n // Locales registries\n fileContent += ` interface __DeclaredLocalesRegistry {\\n${formattedDeclaredLocales}\\n }\\n\\n`;\n fileContent += ` interface __RequiredLocalesRegistry {\\n${formattedRequiredLocales}\\n }\\n\\n`;\n // Schema registry\n fileContent += ` interface __SchemaRegistry {\\n${formattedSchemas}\\n }\\n\\n`;\n // Resolved strict mode (narrow the literal at build time)\n fileContent += ` interface __StrictModeRegistry { mode: '${strictKey}' }\\n\\n`;\n // Editor registry\n fileContent += ` interface __EditorRegistry { enabled : ${enabled} } \\n`;\n fileContent += `}\\n`;\n\n return fileContent;\n};\n\n/** Generate the index file merging all the types */\nexport const createModuleAugmentation = async (\n configuration: IntlayerConfig\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.system;\n\n await mkdir(moduleAugmentationDir, { recursive: true });\n\n const dictionariesTypesDefinitions: string[] = await fg(\n normalizePath(`${typesDir}/*.ts`),\n { ignore: ['**/*.d.ts'] }\n );\n\n let zodToTsFns: ZodToTsFns | null = null;\n try {\n const mod = await import('zod-to-ts');\n zodToTsFns = {\n zodToTs: mod.zodToTs,\n printNode: mod.printNode,\n createAuxiliaryTypeStore: mod.createAuxiliaryTypeStore,\n };\n } catch {\n // typescript peer dep not installed (plain JS project), use fallback\n }\n\n const tsContent = generateTypeIndexContent(\n dictionariesTypesDefinitions,\n configuration,\n zodToTsFns\n );\n\n const tsFilePath = join(moduleAugmentationDir, 'intlayer.d.ts');\n await writeFileIfChanged(tsFilePath, tsContent);\n};\n"],"mappings":";;;;;;;;AASA,MAAa,eAAe,QAC1B,GAAG,qBAAqB,GAAG,EAAE;;AAG/B,MAAM,iBAAiB,YACrB,QAAQ,KAAK,WAAW,QAAQ,OAAO,MAAM,EAAE,KAAK,IAAI;AAE1D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;;CAMR,eAAe;CAEf,eAAe,uCAAuC,uBAAuB;CAE7E,eAAe,4CAA4C,yBAAyB;CACpF,eAAe,4CAA4C,yBAAyB;CAEpF,eAAe,mCAAmC,iBAAiB;CAEnE,eAAe,6CAA6C,UAAU;CAEtE,eAAe,4CAA4C,QAAQ;CACnE,eAAe;CAEf,OAAO;AACT;;AAGA,MAAa,2BAA2B,OACtC,kBACG;CACH,MAAM,EAAE,uBAAuB,aAAa,cAAc;CAE1D,MAAM,MAAM,uBAAuB,EAAE,WAAW,KAAK,CAAC;CAEtD,MAAM,+BAAyC,MAAM,GACnD,cAAc,GAAG,SAAS,MAAM,GAChC,EAAE,QAAQ,CAAC,WAAW,EAAE,CAC1B;CAEA,IAAI,aAAgC;CACpC,IAAI;EACF,MAAM,MAAM,MAAM,OAAO;EACzB,aAAa;GACX,SAAS,IAAI;GACb,WAAW,IAAI;GACf,0BAA0B,IAAI;EAChC;CACF,QAAQ,CAER;CAEA,MAAM,YAAY,yBAChB,8BACA,eACA,UACF;CAGA,MAAM,mBADa,KAAK,uBAAuB,eACb,GAAG,SAAS;AAChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"createType.mjs","names":[],"sources":["../../../src/createType/createType.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { parallelize } from '../utils/parallelize';\n\nexport const generateTypeScriptType = (dictionary: Dictionary) => {\n const jsonString = JSON.stringify(dictionary, null, 2);\n\n return `/* eslint-disable */\\nexport default ${jsonString} as const;\\n`;\n};\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { system } = configuration;\n const { typesDir } = system;\n\n // Create type folders if they don't exist\n await mkdir(typesDir, { recursive: true });\n\n const results = await parallelize(\n dictionaries,\n async (dictionary): Promise<string | undefined> => {\n if (!dictionary.key) {\n return undefined;\n }\n\n const typeDefinition: string = generateTypeScriptType(dictionary);\n\n const outputPath: string = resolve(typesDir, `${dictionary.key}.ts`);\n\n await writeFile(outputPath, typeDefinition);\n\n return outputPath;\n }\n );\n\n return results.filter(Boolean) as string[];\n};\n"],"mappings":";;;;;AAMA,MAAa,0BAA0B,eAA2B;CAGhE,OAAO,wCAFY,KAAK,UAAU,YAAY,MAAM,EAEK,CAAC;;;;;AAK5D,MAAa,cAAc,OACzB,cACA,kBACsB;CACtB,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,aAAa;CAGrB,MAAM,MAAM,UAAU,EAAE,WAAW,MAAM,CAAC;CAmB1C,QAAO,MAjBe,YACpB,cACA,OAAO,eAA4C;EACjD,IAAI,CAAC,WAAW,KACd;EAGF,MAAM,iBAAyB,uBAAuB,WAAW;EAEjE,MAAM,aAAqB,QAAQ,UAAU,GAAG,WAAW,IAAI,KAAK;EAEpE,MAAM,UAAU,YAAY,eAAe;EAE3C,OAAO;GAEV,EAEc,OAAO,QAAQ"}
1
+ {"version":3,"file":"createType.mjs","names":[],"sources":["../../../src/createType/createType.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { parallelize } from '../utils/parallelize';\n\nexport const generateTypeScriptType = (dictionary: Dictionary) => {\n const jsonString = JSON.stringify(dictionary, null, 2);\n\n return `/* eslint-disable */\\nexport default ${jsonString} as const;\\n`;\n};\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { system } = configuration;\n const { typesDir } = system;\n\n // Create type folders if they don't exist\n await mkdir(typesDir, { recursive: true });\n\n const results = await parallelize(\n dictionaries,\n async (dictionary): Promise<string | undefined> => {\n if (!dictionary.key) {\n return undefined;\n }\n\n const typeDefinition: string = generateTypeScriptType(dictionary);\n\n const outputPath: string = resolve(typesDir, `${dictionary.key}.ts`);\n\n await writeFile(outputPath, typeDefinition);\n\n return outputPath;\n }\n );\n\n return results.filter(Boolean) as string[];\n};\n"],"mappings":";;;;;AAMA,MAAa,0BAA0B,eAA2B;CAGhE,OAAO,wCAFY,KAAK,UAAU,YAAY,MAAM,CAEI,EAAE;AAC5D;;;;AAIA,MAAa,cAAc,OACzB,cACA,kBACsB;CACtB,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,aAAa;CAGrB,MAAM,MAAM,UAAU,EAAE,WAAW,KAAK,CAAC;CAmBzC,QAAO,MAjBe,YACpB,cACA,OAAO,eAA4C;EACjD,IAAI,CAAC,WAAW,KACd;EAGF,MAAM,iBAAyB,uBAAuB,UAAU;EAEhE,MAAM,aAAqB,QAAQ,UAAU,GAAG,WAAW,IAAI,IAAI;EAEnE,MAAM,UAAU,YAAY,cAAc;EAE1C,OAAO;CACT,CACF,GAEe,OAAO,OAAO;AAC/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"detectFormatCommand.mjs","names":[],"sources":["../../src/detectFormatCommand.ts"],"sourcesContent":["import { getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nlet cachedFormatCommand: string | undefined | null = null;\n\nexport const detectFormatCommand = (\n configuration: IntlayerConfig,\n projectRequireProp?: NodeJS.Require\n) => {\n const { baseDir } = configuration.system;\n const { formatCommand } = configuration.content;\n const projectRequire = projectRequireProp ?? getProjectRequire(baseDir);\n\n // Priority: Explicit configuration\n // We do not cache this because the user might change their config file active-session.\n if (formatCommand) {\n return formatCommand;\n }\n\n // Priority: Cached detection\n // If not null, we have already performed the expensive checks.\n if (cachedFormatCommand !== null) {\n return cachedFormatCommand;\n }\n\n // Perform Detection\n\n // Try Prettier\n try {\n projectRequire.resolve('prettier');\n cachedFormatCommand = 'prettier --write \"{{file}}\" --log-level silent';\n return cachedFormatCommand;\n } catch (_error) {\n // Prettier not found, continue\n }\n\n // Try Biome\n try {\n projectRequire.resolve('biome');\n cachedFormatCommand = 'biome format \"{{file}}\" --write --log-level none';\n return cachedFormatCommand;\n } catch (_error) {\n // Biome not found, continue\n }\n\n // Try ESLint\n try {\n projectRequire.resolve('eslint');\n cachedFormatCommand =\n 'eslint --fix \"{{file}}\" --quiet || node -e \"process.exit(0)\"';\n return cachedFormatCommand;\n } catch (_error) {\n // ESLint not found\n }\n\n // No formatter found\n // Set to undefined (not null) so we know we checked and found nothing.\n cachedFormatCommand = undefined;\n return undefined;\n};\n"],"mappings":";;;AAGA,IAAI,sBAAiD;AAErD,MAAa,uBACX,eACA,uBACG;CACH,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,kBAAkB,cAAc;CACxC,MAAM,iBAAiB,sBAAsB,kBAAkB,QAAQ;CAIvE,IAAI,eACF,OAAO;CAKT,IAAI,wBAAwB,MAC1B,OAAO;CAMT,IAAI;EACF,eAAe,QAAQ,WAAW;EAClC,sBAAsB;EACtB,OAAO;UACA,QAAQ;CAKjB,IAAI;EACF,eAAe,QAAQ,QAAQ;EAC/B,sBAAsB;EACtB,OAAO;UACA,QAAQ;CAKjB,IAAI;EACF,eAAe,QAAQ,SAAS;EAChC,sBACE;EACF,OAAO;UACA,QAAQ;CAMjB,sBAAsB"}
1
+ {"version":3,"file":"detectFormatCommand.mjs","names":[],"sources":["../../src/detectFormatCommand.ts"],"sourcesContent":["import { getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nlet cachedFormatCommand: string | undefined | null = null;\n\nexport const detectFormatCommand = (\n configuration: IntlayerConfig,\n projectRequireProp?: NodeJS.Require\n) => {\n const { baseDir } = configuration.system;\n const { formatCommand } = configuration.content;\n const projectRequire = projectRequireProp ?? getProjectRequire(baseDir);\n\n // Priority: Explicit configuration\n // We do not cache this because the user might change their config file active-session.\n if (formatCommand) {\n return formatCommand;\n }\n\n // Priority: Cached detection\n // If not null, we have already performed the expensive checks.\n if (cachedFormatCommand !== null) {\n return cachedFormatCommand;\n }\n\n // Perform Detection\n\n // Try Prettier\n try {\n projectRequire.resolve('prettier');\n cachedFormatCommand = 'prettier --write \"{{file}}\" --log-level silent';\n return cachedFormatCommand;\n } catch (_error) {\n // Prettier not found, continue\n }\n\n // Try Biome\n try {\n projectRequire.resolve('biome');\n cachedFormatCommand = 'biome format \"{{file}}\" --write --log-level none';\n return cachedFormatCommand;\n } catch (_error) {\n // Biome not found, continue\n }\n\n // Try ESLint\n try {\n projectRequire.resolve('eslint');\n cachedFormatCommand =\n 'eslint --fix \"{{file}}\" --quiet || node -e \"process.exit(0)\"';\n return cachedFormatCommand;\n } catch (_error) {\n // ESLint not found\n }\n\n // No formatter found\n // Set to undefined (not null) so we know we checked and found nothing.\n cachedFormatCommand = undefined;\n return undefined;\n};\n"],"mappings":";;;AAGA,IAAI,sBAAiD;AAErD,MAAa,uBACX,eACA,uBACG;CACH,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,kBAAkB,cAAc;CACxC,MAAM,iBAAiB,sBAAsB,kBAAkB,OAAO;CAItE,IAAI,eACF,OAAO;CAKT,IAAI,wBAAwB,MAC1B,OAAO;CAMT,IAAI;EACF,eAAe,QAAQ,UAAU;EACjC,sBAAsB;EACtB,OAAO;CACT,SAAS,QAAQ,CAEjB;CAGA,IAAI;EACF,eAAe,QAAQ,OAAO;EAC9B,sBAAsB;EACtB,OAAO;CACT,SAAS,QAAQ,CAEjB;CAGA,IAAI;EACF,eAAe,QAAQ,QAAQ;EAC/B,sBACE;EACF,OAAO;CACT,SAAS,QAAQ,CAEjB;CAIA,sBAAsB;AAExB"}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { parallelize } from './utils/parallelize';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const distantDictionariesKeys = options.dictionaryKeys;\n // Process dictionaries in parallel with a concurrency limit\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult =\n await intlayerAPI.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n onStatusUpdate?.([\n { dictionaryKey, type: 'remote', status: 'fetched' },\n ]);\n\n return distantDictionary;\n } catch (error) {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n ]);\n return undefined;\n }\n };\n\n const result = await parallelize(\n distantDictionariesKeys,\n async (dictionaryKey) => await processDictionary(dictionaryKey)\n );\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict: DictionaryAPI | undefined): dict is DictionaryAPI =>\n dict !== undefined\n );\n\n return filteredResult;\n } catch (_error) {\n appLogger(`${x} Failed to fetch distant dictionaries`, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;AAiBA,MAAa,2BAA2B,OACtC,SACA,mBAC6B;CAC7B,MAAM,SAAS,kBAAkB;CACjC,MAAM,YAAY,aAAa,OAAO;CACtC,IAAI;EACF,MAAM,cAAc,oBAAoB,QAAW,OAAO;EAE1D,MAAM,0BAA0B,QAAQ;EAExC,MAAM,oBAAoB,OACxB,kBACuC;GACvC,iBAAiB,CACf;IACE;IACA,MAAM;IACN,QAAQ;IACT,CACF,CAAC;GAEF,IAAI;IAKF,MAAM,qBAAoB,MAFlB,YAAY,WAAW,cAAc,cAAc,EAEb;IAE9C,IAAI,CAAC,mBACH,MAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;IAGpE,iBAAiB,CACf;KAAE;KAAe,MAAM;KAAU,QAAQ;KAAW,CACrD,CAAC;IAEF,OAAO;YACA,OAAO;IACd,iBAAiB,CACf;KACE;KACA,MAAM;KACN,QAAQ;KACR,OAAO,6BAA6B,cAAc,IAAI;KACvD,CACF,CAAC;IACF;;;EAeJ,QALuB,MANF,YACnB,yBACA,OAAO,kBAAkB,MAAM,kBAAkB,cAAc,CAChE,EAG6B,QAC3B,SACC,SAAS,OAGQ;UACd,QAAQ;EACf,UAAU,GAAG,EAAE,wCAAwC,EAAE,OAAO,SAAS,CAAC;EAC1E,OAAO,EAAE"}
1
+ {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { parallelize } from './utils/parallelize';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const distantDictionariesKeys = options.dictionaryKeys;\n // Process dictionaries in parallel with a concurrency limit\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult =\n await intlayerAPI.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n onStatusUpdate?.([\n { dictionaryKey, type: 'remote', status: 'fetched' },\n ]);\n\n return distantDictionary;\n } catch (error) {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n ]);\n return undefined;\n }\n };\n\n const result = await parallelize(\n distantDictionariesKeys,\n async (dictionaryKey) => await processDictionary(dictionaryKey)\n );\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict: DictionaryAPI | undefined): dict is DictionaryAPI =>\n dict !== undefined\n );\n\n return filteredResult;\n } catch (_error) {\n appLogger(`${x} Failed to fetch distant dictionaries`, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;AAiBA,MAAa,2BAA2B,OACtC,SACA,mBAC6B;CAC7B,MAAM,SAAS,iBAAiB;CAChC,MAAM,YAAY,aAAa,MAAM;CACrC,IAAI;EACF,MAAM,cAAc,oBAAoB,QAAW,MAAM;EAEzD,MAAM,0BAA0B,QAAQ;EAExC,MAAM,oBAAoB,OACxB,kBACuC;GACvC,iBAAiB,CACf;IACE;IACA,MAAM;IACN,QAAQ;GACV,CACF,CAAC;GAED,IAAI;IAKF,MAAM,qBAAoB,MAFlB,YAAY,WAAW,cAAc,aAAa,GAEZ;IAE9C,IAAI,CAAC,mBACH,MAAM,IAAI,MAAM,cAAc,cAAc,qBAAqB;IAGnE,iBAAiB,CACf;KAAE;KAAe,MAAM;KAAU,QAAQ;IAAU,CACrD,CAAC;IAED,OAAO;GACT,SAAS,OAAO;IACd,iBAAiB,CACf;KACE;KACA,MAAM;KACN,QAAQ;KACR,OAAO,6BAA6B,cAAc,IAAI;IACxD,CACF,CAAC;IACD;GACF;EACF;EAaA,QALuB,MANF,YACnB,yBACA,OAAO,kBAAkB,MAAM,kBAAkB,aAAa,CAChE,GAG8B,QAC3B,SACC,SAAS,MAGO;CACtB,SAAS,QAAQ;EACf,UAAU,GAAG,EAAE,wCAAwC,EAAE,OAAO,QAAQ,CAAC;EACzE,OAAO,CAAC;CACV;AACF"}
@@ -14,6 +14,10 @@ const isInvalidDictionary = (dictionary, configuration, options) => {
14
14
  appLogger(`${location} dictionary has no key`, { level: "error" });
15
15
  return false;
16
16
  }
17
+ if (!/^[\p{L}\p{N}]+([._-][\p{L}\p{N}]+)*$/u.test(dictionary.key)) {
18
+ appLogger(`Insecure key ${colorizeKey(dictionary.key)} at ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath("Remote")} - dictionary filtered out`, { level: "error" });
19
+ return false;
20
+ }
17
21
  if (!hasContent) {
18
22
  appLogger(`${location} dictionary ${colorizeKey(dictionary.key)} has no content - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath("Remote")}`, { level: "error" });
19
23
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"filterInvalidDictionaries.mjs","names":[],"sources":["../../src/filterInvalidDictionaries.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getBasePlugins, getContent } from '@intlayer/core/interpreter';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { formatLocale, formatPath } from './utils/formatter';\n\ntype IsInvalidDictionaryOptions = { checkSchema: boolean };\n\nexport const isInvalidDictionary = (\n dictionary: Dictionary | undefined,\n configuration?: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): boolean => {\n const appLogger = getAppLogger(configuration);\n\n if (!dictionary) return false;\n\n const isLocal = Boolean(\n dictionary.location === 'local' || typeof dictionary.filePath === 'string'\n );\n const location = isLocal ? 'Local' : 'Remote';\n const hasKey = Boolean(dictionary.key);\n const hasContent = Boolean(dictionary.content);\n\n if (!hasKey) {\n appLogger(`${location} dictionary has no key`, {\n level: 'error',\n });\n\n return false;\n }\n\n if (!hasContent) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has no content - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n return false;\n }\n\n if (dictionary.schema && options?.checkSchema) {\n const isAsync =\n typeof dictionary.content === 'function' ||\n (typeof dictionary.content === 'object' &&\n dictionary.content !== null &&\n typeof (dictionary.content as any).then === 'function');\n\n if (!isAsync) {\n const locales = configuration?.internationalization?.locales ?? [];\n const isStrict =\n configuration?.internationalization.strictMode === 'strict';\n\n const schema =\n typeof dictionary.schema === 'string'\n ? configuration?.schemas?.[dictionary.schema]\n : undefined;\n\n if (schema && typeof schema.safeParse === 'function') {\n for (const locale of locales) {\n const resolvedContent = getContent(\n dictionary.content,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n locale,\n },\n getBasePlugins(locale, !isStrict)\n );\n const result = (schema as any).safeParse(resolvedContent);\n\n if (!result.success) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has invalid content according to schema ${colorize(dictionary.schema as string, ANSIColors.ORANGE)} for locale ${formatLocale(locale)} - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n\n result.error.issues.forEach((issue: any) => {\n appLogger(\n `${x} Error: ${colorizeKey(dictionary.key)} - ${formatLocale(locale)} - ${colorize(`${issue.path.join('.')}:`, ANSIColors.BLUE)} ${colorize(issue.message, ANSIColors.GREY)}`,\n {\n level: 'error',\n }\n );\n });\n\n return false;\n }\n }\n }\n }\n }\n\n return true;\n};\n\nexport const filterInvalidDictionaries = (\n dictionaries: (Dictionary | undefined)[] | undefined,\n configuration: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): Dictionary[] =>\n (dictionaries ?? [])?.filter((dictionary) =>\n isInvalidDictionary(dictionary, configuration, options)\n ) as Dictionary[];\n"],"mappings":";;;;;;AAeA,MAAa,uBACX,YACA,eACA,YACY;CACZ,MAAM,YAAY,aAAa,cAAc;CAE7C,IAAI,CAAC,YAAY,OAAO;CAKxB,MAAM,WAHU,QACd,WAAW,aAAa,WAAW,OAAO,WAAW,aAAa,SAE5C,GAAG,UAAU;CACrC,MAAM,SAAS,QAAQ,WAAW,IAAI;CACtC,MAAM,aAAa,QAAQ,WAAW,QAAQ;CAE9C,IAAI,CAAC,QAAQ;EACX,UAAU,GAAG,SAAS,yBAAyB,EAC7C,OAAO,SACR,CAAC;EAEF,OAAO;;CAGT,IAAI,CAAC,YAAY;EACf,UACE,GAAG,SAAS,cAAc,YAAY,WAAW,IAAI,CAAC,oBAAoB,WAAW,WAAW,WAAW,WAAW,SAAS,GAAG,aAAa,SAAS,IACxJ,EACE,OAAO,SACR,CACF;EACD,OAAO;;CAGT,IAAI,WAAW,UAAU,SAAS,aAOhC;MAAI,EALF,OAAO,WAAW,YAAY,cAC7B,OAAO,WAAW,YAAY,YAC7B,WAAW,YAAY,QACvB,OAAQ,WAAW,QAAgB,SAAS,aAElC;GACZ,MAAM,UAAU,eAAe,sBAAsB,WAAW,EAAE;GAClE,MAAM,WACJ,eAAe,qBAAqB,eAAe;GAErD,MAAM,SACJ,OAAO,WAAW,WAAW,WACzB,eAAe,UAAU,WAAW,UACpC;GAEN,IAAI,UAAU,OAAO,OAAO,cAAc,YACxC,KAAK,MAAM,UAAU,SAAS;IAC5B,MAAM,kBAAkB,WACtB,WAAW,SACX;KACE,eAAe,WAAW;KAC1B,SAAS,EAAE;KACX;KACD,EACD,eAAe,QAAQ,CAAC,SAAS,CAClC;IACD,MAAM,SAAU,OAAe,UAAU,gBAAgB;IAEzD,IAAI,CAAC,OAAO,SAAS;KACnB,UACE,GAAG,SAAS,cAAc,YAAY,WAAW,IAAI,CAAC,2CAA2C,SAAS,WAAW,QAAkB,WAAW,OAAO,CAAC,cAAc,aAAa,OAAO,CAAC,KAAK,WAAW,WAAW,WAAW,WAAW,SAAS,GAAG,aAAa,SAAS,IAChR,EACE,OAAO,SACR,CACF;KAED,OAAO,MAAM,OAAO,SAAS,UAAe;MAC1C,UACE,GAAG,EAAE,UAAU,YAAY,WAAW,IAAI,CAAC,KAAK,aAAa,OAAO,CAAC,KAAK,SAAS,GAAG,MAAM,KAAK,KAAK,IAAI,CAAC,IAAI,WAAW,KAAK,CAAC,GAAG,SAAS,MAAM,SAAS,WAAW,KAAK,IAC3K,EACE,OAAO,SACR,CACF;OACD;KAEF,OAAO;;;;;CAOjB,OAAO;;AAGT,MAAa,6BACX,cACA,eACA,aAEC,gBAAgB,EAAE,GAAG,QAAQ,eAC5B,oBAAoB,YAAY,eAAe,QAAQ,CACxD"}
1
+ {"version":3,"file":"filterInvalidDictionaries.mjs","names":[],"sources":["../../src/filterInvalidDictionaries.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getBasePlugins, getContent } from '@intlayer/core/interpreter';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { formatLocale, formatPath } from './utils/formatter';\n\ntype IsInvalidDictionaryOptions = { checkSchema: boolean };\n\nexport const isInvalidDictionary = (\n dictionary: Dictionary | undefined,\n configuration?: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): boolean => {\n const appLogger = getAppLogger(configuration);\n\n if (!dictionary) return false;\n\n const isLocal = Boolean(\n dictionary.location === 'local' || typeof dictionary.filePath === 'string'\n );\n const location = isLocal ? 'Local' : 'Remote';\n const hasKey = Boolean(dictionary.key);\n const hasContent = Boolean(dictionary.content);\n\n if (!hasKey) {\n appLogger(`${location} dictionary has no key`, {\n level: 'error',\n });\n\n return false;\n }\n\n // Reject keys that contain path-unsafe characters.\n // A key is used as a filename component ({key}.json), so slashes, backslashes,\n // null bytes, or pure dot-segments can escape the output directory or break\n // dictionary resolution.\n // Allows alphanumeric characters, dashes, and underscores.\n // Allows dots, but not as the first or last character, and no consecutive dots.\n // Allows chinese or russian characters e.g. 你好\n const isInsecureKey = !/^[\\p{L}\\p{N}]+([._-][\\p{L}\\p{N}]+)*$/u.test(\n dictionary.key\n );\n\n if (isInsecureKey) {\n appLogger(\n `Insecure key ${colorizeKey(dictionary.key)} at ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')} - dictionary filtered out`,\n { level: 'error' }\n );\n return false;\n }\n\n if (!hasContent) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has no content - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n return false;\n }\n\n if (dictionary.schema && options?.checkSchema) {\n const isAsync =\n typeof dictionary.content === 'function' ||\n (typeof dictionary.content === 'object' &&\n dictionary.content !== null &&\n typeof (dictionary.content as any).then === 'function');\n\n if (!isAsync) {\n const locales = configuration?.internationalization?.locales ?? [];\n const isStrict =\n configuration?.internationalization.strictMode === 'strict';\n\n const schema =\n typeof dictionary.schema === 'string'\n ? configuration?.schemas?.[dictionary.schema]\n : undefined;\n\n if (schema && typeof schema.safeParse === 'function') {\n for (const locale of locales) {\n const resolvedContent = getContent(\n dictionary.content,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n locale,\n },\n getBasePlugins(locale, !isStrict)\n );\n const result = (schema as any).safeParse(resolvedContent);\n\n if (!result.success) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has invalid content according to schema ${colorize(dictionary.schema as string, ANSIColors.ORANGE)} for locale ${formatLocale(locale)} - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n\n result.error.issues.forEach((issue: any) => {\n appLogger(\n `${x} Error: ${colorizeKey(dictionary.key)} - ${formatLocale(locale)} - ${colorize(`${issue.path.join('.')}:`, ANSIColors.BLUE)} ${colorize(issue.message, ANSIColors.GREY)}`,\n {\n level: 'error',\n }\n );\n });\n\n return false;\n }\n }\n }\n }\n }\n\n return true;\n};\n\nexport const filterInvalidDictionaries = (\n dictionaries: (Dictionary | undefined)[] | undefined,\n configuration: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): Dictionary[] =>\n (dictionaries ?? [])?.filter((dictionary) =>\n isInvalidDictionary(dictionary, configuration, options)\n ) as Dictionary[];\n"],"mappings":";;;;;;AAeA,MAAa,uBACX,YACA,eACA,YACY;CACZ,MAAM,YAAY,aAAa,aAAa;CAE5C,IAAI,CAAC,YAAY,OAAO;CAKxB,MAAM,WAHU,QACd,WAAW,aAAa,WAAW,OAAO,WAAW,aAAa,QAE7C,IAAI,UAAU;CACrC,MAAM,SAAS,QAAQ,WAAW,GAAG;CACrC,MAAM,aAAa,QAAQ,WAAW,OAAO;CAE7C,IAAI,CAAC,QAAQ;EACX,UAAU,GAAG,SAAS,yBAAyB,EAC7C,OAAO,QACT,CAAC;EAED,OAAO;CACT;CAaA,IAAI,CAJmB,wCAAwC,KAC7D,WAAW,GACb,GAEmB;EACjB,UACE,gBAAgB,YAAY,WAAW,GAAG,EAAE,MAAM,WAAW,WAAW,WAAW,WAAW,QAAQ,IAAI,aAAa,QAAQ,EAAE,6BACjI,EAAE,OAAO,QAAQ,CACnB;EACA,OAAO;CACT;CAEA,IAAI,CAAC,YAAY;EACf,UACE,GAAG,SAAS,cAAc,YAAY,WAAW,GAAG,EAAE,oBAAoB,W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oB,YAAY,eAAe,OAAO,CACxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatDictionary.mjs","names":[],"sources":["../../src/formatDictionary.ts"],"sourcesContent":["import {\n i18nextToIntlayerFormatter,\n icuToIntlayerFormatter,\n intlayerToI18nextFormatter,\n intlayerToICUFormatter,\n intlayerToPortableObjectFormatter,\n intlayerToVueI18nFormatter,\n portableObjectToIntlayerFormatter,\n vueI18nToIntlayerFormatter,\n} from '@intlayer/core/messageFormat';\nimport type { Dictionary } from '@intlayer/types/dictionary';\n\nexport const formatDictionary = (dictionary: Dictionary): Dictionary => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: icuToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: i18nextToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: vueI18nToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'po') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: portableObjectToIntlayerFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionaries = async (\n dictionaries: Dictionary[]\n): Promise<Dictionary[]> => Promise.all(dictionaries.map(formatDictionary));\n\nexport const formatDictionaryOutput = (\n dictionary: Dictionary,\n format: Dictionary['format']\n) => {\n if (format === 'icu') {\n return {\n ...dictionary,\n format: 'icu',\n content: intlayerToICUFormatter(dictionary.content),\n };\n }\n\n if (format === 'i18next') {\n return {\n ...dictionary,\n format: 'i18next',\n content: intlayerToI18nextFormatter(dictionary.content),\n };\n }\n\n if (format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'vue-i18n',\n content: intlayerToVueI18nFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'po') {\n return {\n ...dictionary,\n format: 'po',\n content: intlayerToPortableObjectFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionariesOutput = (\n dictionaries: Dictionary[],\n format: Dictionary['format']\n) =>\n dictionaries.map((dictionary) => formatDictionaryOutput(dictionary, format));\n"],"mappings":";;;AAYA,MAAa,oBAAoB,eAAuC;CACtE,IAAI,WAAW,WAAW,OACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,uBAAuB,WAAW,QAAQ;EACpD;CAGH,IAAI,WAAW,WAAW,WACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;CAGH,IAAI,WAAW,WAAW,YACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;CAGH,IAAI,WAAW,WAAW,MACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,kCAAkC,WAAW,QAAQ;EAC/D;CAGH,OAAO;;AAGT,MAAa,qBAAqB,OAChC,iBAC0B,QAAQ,IAAI,aAAa,IAAI,iBAAiB,CAAC;AAE3E,MAAa,0BACX,YACA,WACG;CACH,IAAI,WAAW,OACb,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,uBAAuB,WAAW,QAAQ;EACpD;CAGH,IAAI,WAAW,WACb,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;CAGH,IAAI,WAAW,YACb,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;CAGH,IAAI,WAAW,WAAW,MACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,kCAAkC,WAAW,QAAQ;EAC/D;CAGH,OAAO;;AAGT,MAAa,4BACX,cACA,WAEA,aAAa,KAAK,eAAe,uBAAuB,YAAY,OAAO,CAAC"}
1
+ {"version":3,"file":"formatDictionary.mjs","names":[],"sources":["../../src/formatDictionary.ts"],"sourcesContent":["import {\n i18nextToIntlayerFormatter,\n icuToIntlayerFormatter,\n intlayerToI18nextFormatter,\n intlayerToICUFormatter,\n intlayerToPortableObjectFormatter,\n intlayerToVueI18nFormatter,\n portableObjectToIntlayerFormatter,\n vueI18nToIntlayerFormatter,\n} from '@intlayer/core/messageFormat';\nimport type { Dictionary } from '@intlayer/types/dictionary';\n\nexport const formatDictionary = (dictionary: Dictionary): Dictionary => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: icuToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: i18nextToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: vueI18nToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'po') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: portableObjectToIntlayerFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionaries = async (\n dictionaries: Dictionary[]\n): Promise<Dictionary[]> => Promise.all(dictionaries.map(formatDictionary));\n\nexport const formatDictionaryOutput = (\n dictionary: Dictionary,\n format: Dictionary['format']\n) => {\n if (format === 'icu') {\n return {\n ...dictionary,\n format: 'icu',\n content: intlayerToICUFormatter(dictionary.content),\n };\n }\n\n if (format === 'i18next') {\n return {\n ...dictionary,\n format: 'i18next',\n content: intlayerToI18nextFormatter(dictionary.content),\n };\n }\n\n if (format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'vue-i18n',\n content: intlayerToVueI18nFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'po') {\n return {\n ...dictionary,\n format: 'po',\n content: intlayerToPortableObjectFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionariesOutput = (\n dictionaries: Dictionary[],\n format: Dictionary['format']\n) =>\n dictionaries.map((dictionary) => formatDictionaryOutput(dictionary, format));\n"],"mappings":";;;AAYA,MAAa,oBAAoB,eAAuC;CACtE,IAAI,WAAW,WAAW,OACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,uBAAuB,WAAW,OAAO;CACpD;CAGF,IAAI,WAAW,WAAW,WACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,OAAO;CACxD;CAGF,IAAI,WAAW,WAAW,YACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,OAAO;CACxD;CAGF,IAAI,WAAW,WAAW,MACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,kCAAkC,WAAW,OAAO;CAC/D;CAGF,OAAO;AACT;AAEA,MAAa,qBAAqB,OAChC,iBAC0B,QAAQ,IAAI,aAAa,IAAI,gBAAgB,CAAC;AAE1E,MAAa,0BACX,YACA,WACG;CACH,IAAI,WAAW,OACb,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,uBAAuB,WAAW,OAAO;CACpD;CAGF,IAAI,WAAW,WACb,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,OAAO;CACxD;CAGF,IAAI,WAAW,YACb,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,OAAO;CACxD;CAGF,IAAI,WAAW,WAAW,MACxB,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,kCAAkC,WAAW,OAAO;CAC/D;CAGF,OAAO;AACT;AAEA,MAAa,4BACX,cACA,WAEA,aAAa,KAAK,eAAe,uBAAuB,YAAY,MAAM,CAAC"}
@@ -27,6 +27,27 @@ const getContentDeclarationFileTemplate = async (key, format, fileParams = {}, n
27
27
  const jsdoc = `/** @type {import('intlayer').Dictionary${noMetadata ? "['content']" : ""}} **/`;
28
28
  const satisfiesType = noMetadata ? "Dictionary['content']" : "Dictionary";
29
29
  switch (format) {
30
+ case "yaml": return `${[
31
+ `key: ${key}`,
32
+ ...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],
33
+ ...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],
34
+ ...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],
35
+ ...fileParams.tags?.length ? ["tags:", ...fileParams.tags.map((tag) => ` - ${JSON.stringify(tag)}`)] : [],
36
+ "content: {}"
37
+ ].join("\n")}\n`;
38
+ case "md": return [
39
+ "---",
40
+ ...[
41
+ `key: ${key}`,
42
+ ...fileParams.locale ? [`locale: ${fileParams.locale}`] : [],
43
+ ...fileParams.title ? [`title: ${JSON.stringify(fileParams.title)}`] : [],
44
+ ...fileParams.description ? [`description: ${JSON.stringify(fileParams.description)}`] : [],
45
+ ...fileParams.tags?.length ? ["tags:", ...fileParams.tags.map((t) => ` - ${JSON.stringify(t)}`)] : []
46
+ ],
47
+ "---",
48
+ "",
49
+ ""
50
+ ].join("\n");
30
51
  case "ts": return [
31
52
  "import { type Dictionary } from 'intlayer';",
32
53
  "",
@@ -1 +1 @@
1
- {"version":3,"file":"getContentDeclarationFileTemplate.mjs","names":[],"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { kebabCaseToCamelCase } from '@intlayer/config/utils';\nimport type { Format } from '../utils/getFormatFromExtension';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: Format,\n fileParams: Record<string, any> = {},\n noMetadata?: boolean\n) => {\n const camelCaseKey = kebabCaseToCamelCase(key);\n const name = camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParamsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([paramKey, value]) => {\n const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(paramKey)\n ? paramKey\n : JSON.stringify(paramKey);\n\n const formattedValue =\n typeof value === 'object' || typeof value === 'string'\n ? JSON.stringify(value)\n : value;\n\n return `\\n ${formattedKey}: ${formattedValue},`;\n })\n .join('');\n\n let content: string;\n\n if (noMetadata) {\n content = '{}';\n } else if (format === 'json' || format === 'jsonc' || format === 'json5') {\n content = [\n '{',\n ' \"$schema\": \"https://intlayer.org/schema.json\",',\n ` \"key\": \"${key}\",${fileParamsString}`,\n ' \"content\": {',\n ' }',\n '}',\n ].join('\\n');\n } else {\n content = [\n '{',\n ` key: '${key}',${fileParamsString}`,\n ' content: {',\n ' },',\n '}',\n ].join('\\n');\n }\n\n const jsdoc = `/** @type {import('intlayer').Dictionary${noMetadata ? \"['content']\" : ''}} **/`;\n const satisfiesType = noMetadata ? \"Dictionary['content']\" : 'Dictionary';\n\n switch (format) {\n case 'ts':\n return [\n \"import { type Dictionary } from 'intlayer';\",\n '',\n `const ${name}Content = ${content} satisfies ${satisfiesType};`,\n '',\n `export default ${name}Content;`,\n '',\n ].join('\\n');\n\n case 'cjs':\n return [\n jsdoc,\n `const ${name}Content = ${content};`,\n '',\n `module.exports = ${name}Content;`,\n '',\n ].join('\\n');\n\n case 'json':\n case 'jsonc':\n case 'json5':\n return [content, ''].join('\\n');\n\n default: // esm\n return [\n jsdoc,\n `const ${name}Content = ${content};`,\n '',\n `export default ${name}Content;`,\n '',\n ].join('\\n');\n }\n};\n"],"mappings":";;;AAGA,MAAa,oCAAoC,OAC/C,KACA,QACA,aAAkC,EAAE,EACpC,eACG;CACH,MAAM,eAAe,qBAAqB,IAAI;CAC9C,MAAM,OAAO,aAAa,OAAO,EAAE,CAAC,aAAa,GAAG,aAAa,MAAM,EAAE;CAEzE,MAAM,mBAAmB,OAAO,QAAQ,WAAW,CAChD,QAAQ,GAAG,WAAW,UAAU,OAAU,CAC1C,KAAK,CAAC,UAAU,WAAW;EAU1B,OAAO,OATc,6BAA6B,KAAK,SAAS,GAC5D,WACA,KAAK,UAAU,SAAS,CAOD,IAJzB,OAAO,UAAU,YAAY,OAAO,UAAU,WAC1C,KAAK,UAAU,MAAM,GACrB,MAEwC;GAC9C,CACD,KAAK,GAAG;CAEX,IAAI;CAEJ,IAAI,YACF,UAAU;MACL,IAAI,WAAW,UAAU,WAAW,WAAW,WAAW,SAC/D,UAAU;EACR;EACA;EACA,aAAa,IAAI,IAAI;EACrB;EACA;EACA;EACD,CAAC,KAAK,KAAK;MAEZ,UAAU;EACR;EACA,WAAW,IAAI,IAAI;EACnB;EACA;EACA;EACD,CAAC,KAAK,KAAK;CAGd,MAAM,QAAQ,2CAA2C,aAAa,gBAAgB,GAAG;CACzF,MAAM,gBAAgB,aAAa,0BAA0B;CAE7D,QAAQ,QAAR;EACE,KAAK,MACH,OAAO;GACL;GACA;GACA,SAAS,KAAK,YAAY,QAAQ,aAAa,cAAc;GAC7D;GACA,kBAAkB,KAAK;GACvB;GACD,CAAC,KAAK,KAAK;EAEd,KAAK,OACH,OAAO;GACL;GACA,SAAS,KAAK,YAAY,QAAQ;GAClC;GACA,oBAAoB,KAAK;GACzB;GACD,CAAC,KAAK,KAAK;EAEd,KAAK;EACL,KAAK;EACL,KAAK,SACH,OAAO,CAAC,SAAS,GAAG,CAAC,KAAK,KAAK;EAEjC,SACE,OAAO;GACL;GACA,SAAS,KAAK,YAAY,QAAQ;GAClC;GACA,kBAAkB,KAAK;GACvB;GACD,CAAC,KAAK,KAAK"}
1
+ {"version":3,"file":"getContentDeclarationFileTemplate.mjs","names":[],"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { kebabCaseToCamelCase } from '@intlayer/config/utils';\nimport type { Format } from '../utils/getFormatFromExtension';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: Format,\n fileParams: Record<string, any> = {},\n noMetadata?: boolean\n) => {\n const camelCaseKey = kebabCaseToCamelCase(key);\n const name = camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParamsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([paramKey, value]) => {\n const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(paramKey)\n ? paramKey\n : JSON.stringify(paramKey);\n\n const formattedValue =\n typeof value === 'object' || typeof value === 'string'\n ? JSON.stringify(value)\n : value;\n\n return `\\n ${formattedKey}: ${formattedValue},`;\n })\n .join('');\n\n let content: string;\n\n if (noMetadata) {\n content = '{}';\n } else if (format === 'json' || format === 'jsonc' || format === 'json5') {\n content = [\n '{',\n ' \"$schema\": \"https://intlayer.org/schema.json\",',\n ` \"key\": \"${key}\",${fileParamsString}`,\n ' \"content\": {',\n ' }',\n '}',\n ].join('\\n');\n } else {\n content = [\n '{',\n ` key: '${key}',${fileParamsString}`,\n ' content: {',\n ' },',\n '}',\n ].join('\\n');\n }\n\n const jsdoc = `/** @type {import('intlayer').Dictionary${noMetadata ? \"['content']\" : ''}} **/`;\n const satisfiesType = noMetadata ? \"Dictionary['content']\" : 'Dictionary';\n\n switch (format) {\n case 'yaml': {\n const yamlLines = [\n `key: ${key}`,\n ...(fileParams.locale ? [`locale: ${fileParams.locale}`] : []),\n ...(fileParams.title\n ? [`title: ${JSON.stringify(fileParams.title)}`]\n : []),\n ...(fileParams.description\n ? [`description: ${JSON.stringify(fileParams.description)}`]\n : []),\n ...(fileParams.tags?.length\n ? [\n 'tags:',\n ...(fileParams.tags as string[]).map(\n (tag) => ` - ${JSON.stringify(tag)}`\n ),\n ]\n : []),\n 'content: {}',\n ];\n return `${yamlLines.join('\\n')}\\n`;\n }\n\n case 'md': {\n const mdFrontmatterLines = [\n `key: ${key}`,\n ...(fileParams.locale ? [`locale: ${fileParams.locale}`] : []),\n ...(fileParams.title\n ? [`title: ${JSON.stringify(fileParams.title)}`]\n : []),\n ...(fileParams.description\n ? [`description: ${JSON.stringify(fileParams.description)}`]\n : []),\n ...(fileParams.tags?.length\n ? [\n 'tags:',\n ...(fileParams.tags as string[]).map(\n (t) => ` - ${JSON.stringify(t)}`\n ),\n ]\n : []),\n ];\n return ['---', ...mdFrontmatterLines, '---', '', ''].join('\\n');\n }\n\n case 'ts':\n return [\n \"import { type Dictionary } from 'intlayer';\",\n '',\n `const ${name}Content = ${content} satisfies ${satisfiesType};`,\n '',\n `export default ${name}Content;`,\n '',\n ].join('\\n');\n\n case 'cjs':\n return [\n jsdoc,\n `const ${name}Content = ${content};`,\n '',\n `module.exports = ${name}Content;`,\n '',\n ].join('\\n');\n\n case 'json':\n case 'jsonc':\n case 'json5':\n return [content, ''].join('\\n');\n\n default: // esm\n return [\n jsdoc,\n `const ${name}Content = ${content};`,\n '',\n `export default ${name}Content;`,\n '',\n ].join('\\n');\n }\n};\n"],"mappings":";;;AAGA,MAAa,oCAAoC,OAC/C,KACA,QACA,aAAkC,CAAC,GACnC,eACG;CACH,MAAM,eAAe,qBAAqB,GAAG;CAC7C,MAAM,OAAO,aAAa,OAAO,CAAC,EAAE,YAAY,IAAI,aAAa,MAAM,CAAC;CAExE,MAAM,mBAAmB,OAAO,QAAQ,UAAU,EAC/C,QAAQ,GAAG,WAAW,UAAU,MAAS,EACzC,KAAK,CAAC,UAAU,WAAW;EAU1B,OAAO,OATc,6BAA6B,KAAK,QAAQ,IAC3D,WACA,KAAK,UAAU,QAAQ,EAOA,IAJzB,OAAO,UAAU,YAAY,OAAO,UAAU,WAC1C,KAAK,UAAU,KAAK,IACpB,MAEwC;CAChD,CAAC,EACA,KAAK,EAAE;CAEV,IAAI;CAEJ,IAAI,YACF,UAAU;MACL,IAAI,WAAW,UAAU,WAAW,WAAW,WAAW,SAC/D,UAAU;EACR;EACA;EACA,aAAa,IAAI,IAAI;EACrB;EACA;EACA;CACF,EAAE,KAAK,IAAI;MAEX,UAAU;EACR;EACA,WAAW,IAAI,IAAI;EACnB;EACA;EACA;CACF,EAAE,KAAK,IAAI;CAGb,MAAM,QAAQ,2CAA2C,aAAa,gBAAgB,GAAG;CACzF,MAAM,gBAAgB,aAAa,0BAA0B;CAE7D,QAAQ,QAAR;EACE,KAAK,QAoBH,OAAO,GAAG;GAlBR,QAAQ;GACR,GAAI,WAAW,SAAS,CAAC,WAAW,WAAW,QAAQ,IAAI,CAAC;GAC5D,GAAI,WAAW,QACX,CAAC,UAAU,KAAK,UAAU,W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