@intlayer/chokidar 6.1.6 → 7.0.0-canary.1

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 (464) hide show
  1. package/dist/{cjs → assets}/getContentDeclarationFileTemplate/cjsTemplate.txt +3 -2
  2. package/dist/{cjs → assets}/getContentDeclarationFileTemplate/esmTemplate.txt +2 -1
  3. package/dist/{cjs → assets}/getContentDeclarationFileTemplate/jsonTemplate.txt +2 -1
  4. package/dist/{cjs → assets}/getContentDeclarationFileTemplate/tsTemplate.txt +2 -1
  5. package/dist/cjs/_virtual/_utils_asset.cjs +104 -0
  6. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  7. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +42 -80
  8. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  9. package/dist/cjs/buildIntlayerDictionary/index.cjs +5 -25
  10. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +21 -42
  11. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  12. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +79 -116
  13. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  14. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +62 -86
  15. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  16. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +48 -69
  17. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  18. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +42 -52
  19. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  20. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +60 -82
  21. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  22. package/dist/cjs/cleanOutputDir.cjs +20 -60
  23. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  24. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +64 -103
  25. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  26. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +41 -73
  27. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  28. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +19 -49
  29. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  30. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +20 -50
  31. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  32. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +20 -50
  33. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  34. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +19 -49
  35. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  36. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +19 -49
  37. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  38. package/dist/cjs/createDictionaryEntryPoint/index.cjs +15 -35
  39. package/dist/cjs/createType/createModuleAugmentation.cjs +56 -108
  40. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  41. package/dist/cjs/createType/createType.cjs +29 -58
  42. package/dist/cjs/createType/createType.cjs.map +1 -1
  43. package/dist/cjs/createType/index.cjs +7 -25
  44. package/dist/cjs/fetchDistantDictionaries.cjs +49 -77
  45. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  46. package/dist/cjs/filterInvalidDictionaries.cjs +26 -59
  47. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  48. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +32 -68
  49. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  50. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +32 -51
  51. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  52. package/dist/cjs/handleContentDeclarationFileChange.cjs +35 -56
  53. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  54. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +36 -0
  55. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -0
  56. package/dist/cjs/index.cjs +103 -156
  57. package/dist/cjs/listDictionariesPath.cjs +27 -59
  58. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  59. package/dist/cjs/listGitFiles.cjs +93 -162
  60. package/dist/cjs/listGitFiles.cjs.map +1 -1
  61. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +70 -0
  62. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -0
  63. package/dist/cjs/loadDictionaries/index.cjs +11 -29
  64. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +68 -90
  65. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  66. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +111 -166
  67. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  68. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +27 -53
  69. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  70. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +60 -102
  71. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  72. package/dist/cjs/loadDictionaries/log.cjs +107 -182
  73. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  74. package/dist/cjs/prepareIntlayer.cjs +73 -130
  75. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  76. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +27 -61
  77. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  78. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +10 -32
  79. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  80. package/dist/cjs/utils/chunkJSON.cjs +329 -0
  81. package/dist/cjs/utils/chunkJSON.cjs.map +1 -0
  82. package/dist/cjs/utils/extractErrorMessage.cjs +92 -135
  83. package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
  84. package/dist/cjs/utils/formatter.cjs +19 -49
  85. package/dist/cjs/utils/formatter.cjs.map +1 -1
  86. package/dist/cjs/utils/getChunk.cjs +34 -0
  87. package/dist/cjs/utils/getChunk.cjs.map +1 -0
  88. package/dist/cjs/utils/getFileHash.cjs +9 -40
  89. package/dist/cjs/utils/getFileHash.cjs.map +1 -1
  90. package/dist/cjs/utils/getFormatFromExtension.cjs +23 -54
  91. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  92. package/dist/cjs/utils/kebabCaseToCamelCase.cjs +11 -36
  93. package/dist/cjs/utils/kebabCaseToCamelCase.cjs.map +1 -1
  94. package/dist/cjs/utils/pLimit.cjs +128 -0
  95. package/dist/cjs/utils/pLimit.cjs.map +1 -0
  96. package/dist/cjs/utils/parallelize.cjs +10 -169
  97. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  98. package/dist/cjs/utils/parallelizeGlobal.cjs +29 -0
  99. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -0
  100. package/dist/cjs/utils/reduceObjectFormat.cjs +31 -0
  101. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -0
  102. package/dist/cjs/utils/resolveObjectPromises.cjs +18 -48
  103. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  104. package/dist/cjs/utils/runOnce.cjs +80 -57
  105. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  106. package/dist/cjs/utils/runParallel.cjs +163 -74
  107. package/dist/cjs/utils/runParallel.cjs.map +1 -1
  108. package/dist/cjs/utils/sortAlphabetically.cjs +5 -27
  109. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  110. package/dist/cjs/utils/splitTextByLine.cjs +11 -0
  111. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -0
  112. package/dist/cjs/utils/verifyIdenticObjectFormat copy.cjs +54 -0
  113. package/dist/cjs/utils/verifyIdenticObjectFormat copy.cjs.map +1 -0
  114. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +60 -0
  115. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -0
  116. package/dist/cjs/watcher.cjs +61 -83
  117. package/dist/cjs/watcher.cjs.map +1 -1
  118. package/dist/cjs/writeConfiguration/index.cjs +15 -35
  119. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  120. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +25 -51
  121. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  122. package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs +0 -17
  123. package/dist/cjs/writeContentDeclaration/index.cjs +9 -33
  124. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +77 -0
  125. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -0
  126. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +1731 -755
  127. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  128. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +113 -112
  129. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  130. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +56 -66
  131. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  132. package/dist/cjs/writeFileIfChanged.cjs +10 -43
  133. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  134. package/dist/cjs/writeJsonIfChanged.cjs +14 -31
  135. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  136. package/dist/esm/_virtual/_utils_asset.mjs +100 -0
  137. package/dist/esm/_virtual/rolldown_runtime.mjs +8 -0
  138. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +35 -54
  139. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  140. package/dist/esm/buildIntlayerDictionary/index.mjs +4 -3
  141. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +18 -17
  142. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
  143. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +69 -91
  144. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  145. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +53 -61
  146. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  147. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +40 -42
  148. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  149. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +35 -25
  150. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  151. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +53 -56
  152. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  153. package/dist/esm/cleanOutputDir.mjs +17 -36
  154. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  155. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +51 -70
  156. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  157. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +36 -47
  158. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
  159. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +14 -14
  160. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  161. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +15 -15
  162. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  163. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +15 -15
  164. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  165. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +14 -14
  166. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  167. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +14 -14
  168. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  169. package/dist/esm/createDictionaryEntryPoint/index.mjs +9 -8
  170. package/dist/esm/createType/createModuleAugmentation.mjs +48 -71
  171. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  172. package/dist/esm/createType/createType.mjs +24 -35
  173. package/dist/esm/createType/createType.mjs.map +1 -1
  174. package/dist/esm/createType/index.mjs +4 -3
  175. package/dist/esm/fetchDistantDictionaries.mjs +45 -52
  176. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  177. package/dist/esm/filterInvalidDictionaries.mjs +22 -37
  178. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
  179. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +31 -42
  180. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  181. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +27 -24
  182. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  183. package/dist/esm/handleContentDeclarationFileChange.mjs +30 -29
  184. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  185. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +34 -0
  186. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -0
  187. package/dist/esm/index.mjs +39 -99
  188. package/dist/esm/listDictionariesPath.mjs +24 -24
  189. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  190. package/dist/esm/listGitFiles.mjs +83 -124
  191. package/dist/esm/listGitFiles.mjs.map +1 -1
  192. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +66 -0
  193. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -0
  194. package/dist/esm/loadDictionaries/index.mjs +6 -5
  195. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +61 -70
  196. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  197. package/dist/esm/loadDictionaries/loadDictionaries.mjs +105 -146
  198. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  199. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +23 -31
  200. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  201. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +52 -74
  202. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  203. package/dist/esm/loadDictionaries/log.mjs +105 -165
  204. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  205. package/dist/esm/prepareIntlayer.mjs +64 -97
  206. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  207. package/dist/esm/reduceDictionaryContent/applyMask.mjs +26 -37
  208. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  209. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +7 -7
  210. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  211. package/dist/esm/utils/chunkJSON.mjs +327 -0
  212. package/dist/esm/utils/chunkJSON.mjs.map +1 -0
  213. package/dist/esm/utils/extractErrorMessage.mjs +91 -111
  214. package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
  215. package/dist/esm/utils/formatter.mjs +10 -12
  216. package/dist/esm/utils/formatter.mjs.map +1 -1
  217. package/dist/esm/utils/getChunk.mjs +34 -0
  218. package/dist/esm/utils/getChunk.mjs.map +1 -0
  219. package/dist/esm/utils/getFileHash.mjs +6 -5
  220. package/dist/esm/utils/getFileHash.mjs.map +1 -1
  221. package/dist/esm/utils/getFormatFromExtension.mjs +21 -29
  222. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  223. package/dist/esm/utils/kebabCaseToCamelCase.mjs +10 -12
  224. package/dist/esm/utils/kebabCaseToCamelCase.mjs.map +1 -1
  225. package/dist/esm/utils/pLimit.mjs +126 -0
  226. package/dist/esm/utils/pLimit.mjs.map +1 -0
  227. package/dist/esm/utils/parallelize.mjs +10 -144
  228. package/dist/esm/utils/parallelize.mjs.map +1 -1
  229. package/dist/esm/utils/parallelizeGlobal.mjs +27 -0
  230. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -0
  231. package/dist/esm/utils/reduceObjectFormat.mjs +30 -0
  232. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -0
  233. package/dist/esm/utils/resolveObjectPromises.mjs +17 -24
  234. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
  235. package/dist/esm/utils/runOnce.mjs +76 -33
  236. package/dist/esm/utils/runOnce.mjs.map +1 -1
  237. package/dist/esm/utils/runParallel.mjs +160 -40
  238. package/dist/esm/utils/runParallel.mjs.map +1 -1
  239. package/dist/esm/utils/sortAlphabetically.mjs +4 -3
  240. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
  241. package/dist/esm/utils/splitTextByLine.mjs +10 -0
  242. package/dist/esm/utils/splitTextByLine.mjs.map +1 -0
  243. package/dist/esm/utils/verifyIdenticObjectFormat copy.mjs +53 -0
  244. package/dist/esm/utils/verifyIdenticObjectFormat copy.mjs.map +1 -0
  245. package/dist/esm/utils/verifyIdenticObjectFormat.mjs +59 -0
  246. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -0
  247. package/dist/esm/watcher.mjs +53 -58
  248. package/dist/esm/watcher.mjs.map +1 -1
  249. package/dist/esm/writeConfiguration/index.mjs +11 -10
  250. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  251. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +24 -27
  252. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  253. package/dist/esm/writeContentDeclaration/dictionaryStatus.mjs +0 -1
  254. package/dist/esm/writeContentDeclaration/index.mjs +6 -7
  255. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +71 -0
  256. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -0
  257. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +1726 -735
  258. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  259. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +105 -76
  260. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  261. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +48 -46
  262. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  263. package/dist/esm/writeFileIfChanged.mjs +7 -18
  264. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  265. package/dist/esm/writeJsonIfChanged.mjs +14 -7
  266. package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
  267. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +14 -7
  268. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  269. package/dist/types/buildIntlayerDictionary/index.d.ts +3 -3
  270. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +7 -2
  271. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -1
  272. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +14 -10
  273. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  274. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +8 -3
  275. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  276. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +12 -7
  277. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  278. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +8 -2
  279. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  280. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +10 -6
  281. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -1
  282. package/dist/types/cleanOutputDir.d.ts +6 -1
  283. package/dist/types/cleanOutputDir.d.ts.map +1 -1
  284. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +6 -1
  285. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
  286. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +6 -1
  287. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
  288. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +7 -1
  289. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -1
  290. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +7 -1
  291. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -1
  292. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +7 -1
  293. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -1
  294. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +7 -1
  295. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -1
  296. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +7 -1
  297. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -1
  298. package/dist/types/createDictionaryEntryPoint/index.d.ts +8 -8
  299. package/dist/types/createType/createModuleAugmentation.d.ts +8 -5
  300. package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -1
  301. package/dist/types/createType/createType.d.ts +7 -4
  302. package/dist/types/createType/createType.d.ts.map +1 -1
  303. package/dist/types/createType/index.d.ts +3 -3
  304. package/dist/types/fetchDistantDictionaries.d.ts +10 -7
  305. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  306. package/dist/types/filterInvalidDictionaries.d.ts +7 -4
  307. package/dist/types/filterInvalidDictionaries.d.ts.map +1 -1
  308. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +6 -2
  309. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -1
  310. package/dist/types/handleAdditionalContentDeclarationFile.d.ts +6 -2
  311. package/dist/types/handleAdditionalContentDeclarationFile.d.ts.map +1 -1
  312. package/dist/types/handleContentDeclarationFileChange.d.ts +6 -2
  313. package/dist/types/handleContentDeclarationFileChange.d.ts.map +1 -1
  314. package/dist/types/handleUnlinkedContentDeclarationFile.d.ts +7 -0
  315. package/dist/types/handleUnlinkedContentDeclarationFile.d.ts.map +1 -0
  316. package/dist/types/index.d.ts +49 -33
  317. package/dist/types/listDictionariesPath.d.ts +7 -2
  318. package/dist/types/listDictionariesPath.d.ts.map +1 -1
  319. package/dist/types/listGitFiles.d.ts +24 -12
  320. package/dist/types/listGitFiles.d.ts.map +1 -1
  321. package/dist/types/loadDictionaries/getIntlayerBundle.d.ts +11 -0
  322. package/dist/types/loadDictionaries/getIntlayerBundle.d.ts.map +1 -0
  323. package/dist/types/loadDictionaries/index.d.ts +5 -5
  324. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +8 -5
  325. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
  326. package/dist/types/loadDictionaries/loadDictionaries.d.ts +18 -14
  327. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
  328. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +6 -3
  329. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -1
  330. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +13 -8
  331. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
  332. package/dist/types/loadDictionaries/log.d.ts +28 -24
  333. package/dist/types/loadDictionaries/log.d.ts.map +1 -1
  334. package/dist/types/prepareIntlayer.d.ts +12 -2
  335. package/dist/types/prepareIntlayer.d.ts.map +1 -1
  336. package/dist/types/reduceDictionaryContent/applyMask.d.ts +6 -2
  337. package/dist/types/reduceDictionaryContent/applyMask.d.ts.map +1 -1
  338. package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts +6 -2
  339. package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts.map +1 -1
  340. package/dist/types/utils/chunkJSON.d.ts +56 -0
  341. package/dist/types/utils/chunkJSON.d.ts.map +1 -0
  342. package/dist/types/utils/extractErrorMessage.d.ts +4 -1
  343. package/dist/types/utils/extractErrorMessage.d.ts.map +1 -1
  344. package/dist/types/utils/formatter.d.ts +8 -3
  345. package/dist/types/utils/formatter.d.ts.map +1 -1
  346. package/dist/types/utils/getChunk.d.ts +11 -0
  347. package/dist/types/utils/getChunk.d.ts.map +1 -0
  348. package/dist/types/utils/getFileHash.d.ts +4 -1
  349. package/dist/types/utils/getFileHash.d.ts.map +1 -1
  350. package/dist/types/utils/getFormatFromExtension.d.ts +7 -4
  351. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
  352. package/dist/types/utils/kebabCaseToCamelCase.d.ts +4 -1
  353. package/dist/types/utils/kebabCaseToCamelCase.d.ts.map +1 -1
  354. package/dist/types/utils/pLimit.d.ts +16 -0
  355. package/dist/types/utils/pLimit.d.ts.map +1 -0
  356. package/dist/types/utils/parallelize.d.ts +4 -13
  357. package/dist/types/utils/parallelize.d.ts.map +1 -1
  358. package/dist/types/utils/parallelizeGlobal.d.ts +22 -0
  359. package/dist/types/utils/parallelizeGlobal.d.ts.map +1 -0
  360. package/dist/types/utils/reduceObjectFormat.d.ts +17 -0
  361. package/dist/types/utils/reduceObjectFormat.d.ts.map +1 -0
  362. package/dist/types/utils/resolveObjectPromises.d.ts +4 -1
  363. package/dist/types/utils/resolveObjectPromises.d.ts.map +1 -1
  364. package/dist/types/utils/runOnce.d.ts +23 -2
  365. package/dist/types/utils/runOnce.d.ts.map +1 -1
  366. package/dist/types/utils/runParallel.d.ts +9 -6
  367. package/dist/types/utils/runParallel.d.ts.map +1 -1
  368. package/dist/types/utils/sortAlphabetically.d.ts +4 -1
  369. package/dist/types/utils/sortAlphabetically.d.ts.map +1 -1
  370. package/dist/types/utils/splitTextByLine.d.ts +5 -0
  371. package/dist/types/utils/splitTextByLine.d.ts.map +1 -0
  372. package/dist/types/utils/verifyIdenticObjectFormat copy.d.ts +23 -0
  373. package/dist/types/utils/verifyIdenticObjectFormat copy.d.ts.map +1 -0
  374. package/dist/types/utils/verifyIdenticObjectFormat.d.ts +23 -0
  375. package/dist/types/utils/verifyIdenticObjectFormat.d.ts.map +1 -0
  376. package/dist/types/watcher.d.ts +13 -9
  377. package/dist/types/watcher.d.ts.map +1 -1
  378. package/dist/types/writeConfiguration/index.d.ts +6 -2
  379. package/dist/types/writeConfiguration/index.d.ts.map +1 -1
  380. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +4 -1
  381. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -1
  382. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +4 -1
  383. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -1
  384. package/dist/types/writeContentDeclaration/index.d.ts +6 -7
  385. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts +7 -0
  386. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -0
  387. package/dist/types/writeContentDeclaration/transformJSFile.d.ts +33 -6
  388. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
  389. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +14 -6
  390. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
  391. package/dist/types/writeContentDeclaration/writeJSFile.d.ts +7 -3
  392. package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -1
  393. package/dist/types/writeFileIfChanged.d.ts +7 -2
  394. package/dist/types/writeFileIfChanged.d.ts.map +1 -1
  395. package/dist/types/writeJsonIfChanged.d.ts +7 -2
  396. package/dist/types/writeJsonIfChanged.d.ts.map +1 -1
  397. package/package.json +48 -54
  398. package/LICENSE +0 -202
  399. package/dist/cjs/buildIntlayerDictionary/index.cjs.map +0 -1
  400. package/dist/cjs/createDictionaryEntryPoint/index.cjs.map +0 -1
  401. package/dist/cjs/createType/index.cjs.map +0 -1
  402. package/dist/cjs/handleUnlikedContentDeclarationFile.cjs +0 -57
  403. package/dist/cjs/handleUnlikedContentDeclarationFile.cjs.map +0 -1
  404. package/dist/cjs/index.cjs.map +0 -1
  405. package/dist/cjs/loadDictionaries/index.cjs.map +0 -1
  406. package/dist/cjs/mergeDictionaries.cjs +0 -143
  407. package/dist/cjs/mergeDictionaries.cjs.map +0 -1
  408. package/dist/cjs/orderDictionaries.cjs +0 -71
  409. package/dist/cjs/orderDictionaries.cjs.map +0 -1
  410. package/dist/cjs/prepareContentDeclaration.cjs +0 -93
  411. package/dist/cjs/prepareContentDeclaration.cjs.map +0 -1
  412. package/dist/cjs/processPerLocaleDictionary.cjs +0 -49
  413. package/dist/cjs/processPerLocaleDictionary.cjs.map +0 -1
  414. package/dist/cjs/utils/getExtention.cjs +0 -37
  415. package/dist/cjs/utils/getExtention.cjs.map +0 -1
  416. package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs.map +0 -1
  417. package/dist/cjs/writeContentDeclaration/formatCode.cjs +0 -78
  418. package/dist/cjs/writeContentDeclaration/formatCode.cjs.map +0 -1
  419. package/dist/cjs/writeContentDeclaration/index.cjs.map +0 -1
  420. package/dist/esm/buildIntlayerDictionary/index.mjs.map +0 -1
  421. package/dist/esm/createDictionaryEntryPoint/index.mjs.map +0 -1
  422. package/dist/esm/createType/index.mjs.map +0 -1
  423. package/dist/esm/getContentDeclarationFileTemplate/cjsTemplate.txt +0 -9
  424. package/dist/esm/getContentDeclarationFileTemplate/esmTemplate.txt +0 -9
  425. package/dist/esm/getContentDeclarationFileTemplate/jsonTemplate.txt +0 -5
  426. package/dist/esm/getContentDeclarationFileTemplate/tsTemplate.txt +0 -8
  427. package/dist/esm/handleUnlikedContentDeclarationFile.mjs +0 -33
  428. package/dist/esm/handleUnlikedContentDeclarationFile.mjs.map +0 -1
  429. package/dist/esm/index.mjs.map +0 -1
  430. package/dist/esm/loadDictionaries/index.mjs.map +0 -1
  431. package/dist/esm/mergeDictionaries.mjs +0 -109
  432. package/dist/esm/mergeDictionaries.mjs.map +0 -1
  433. package/dist/esm/orderDictionaries.mjs +0 -37
  434. package/dist/esm/orderDictionaries.mjs.map +0 -1
  435. package/dist/esm/prepareContentDeclaration.mjs +0 -72
  436. package/dist/esm/prepareContentDeclaration.mjs.map +0 -1
  437. package/dist/esm/processPerLocaleDictionary.mjs +0 -25
  438. package/dist/esm/processPerLocaleDictionary.mjs.map +0 -1
  439. package/dist/esm/utils/getExtention.mjs +0 -13
  440. package/dist/esm/utils/getExtention.mjs.map +0 -1
  441. package/dist/esm/writeContentDeclaration/dictionaryStatus.mjs.map +0 -1
  442. package/dist/esm/writeContentDeclaration/formatCode.mjs +0 -44
  443. package/dist/esm/writeContentDeclaration/formatCode.mjs.map +0 -1
  444. package/dist/esm/writeContentDeclaration/index.mjs.map +0 -1
  445. package/dist/types/buildIntlayerDictionary/index.d.ts.map +0 -1
  446. package/dist/types/createDictionaryEntryPoint/index.d.ts.map +0 -1
  447. package/dist/types/createType/index.d.ts.map +0 -1
  448. package/dist/types/handleUnlikedContentDeclarationFile.d.ts +0 -3
  449. package/dist/types/handleUnlikedContentDeclarationFile.d.ts.map +0 -1
  450. package/dist/types/index.d.ts.map +0 -1
  451. package/dist/types/loadDictionaries/index.d.ts.map +0 -1
  452. package/dist/types/mergeDictionaries.d.ts +0 -3
  453. package/dist/types/mergeDictionaries.d.ts.map +0 -1
  454. package/dist/types/orderDictionaries.d.ts +0 -10
  455. package/dist/types/orderDictionaries.d.ts.map +0 -1
  456. package/dist/types/prepareContentDeclaration.d.ts +0 -3
  457. package/dist/types/prepareContentDeclaration.d.ts.map +0 -1
  458. package/dist/types/processPerLocaleDictionary.d.ts +0 -32
  459. package/dist/types/processPerLocaleDictionary.d.ts.map +0 -1
  460. package/dist/types/utils/getExtention.d.ts +0 -3
  461. package/dist/types/utils/getExtention.d.ts.map +0 -1
  462. package/dist/types/writeContentDeclaration/formatCode.d.ts +0 -2
  463. package/dist/types/writeContentDeclaration/formatCode.d.ts.map +0 -1
  464. package/dist/types/writeContentDeclaration/index.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import {\n colorizePath,\n getConfiguration,\n normalizePath,\n} from '@intlayer/config';\nimport { mkdir } from 'fs/promises';\nimport { relative, resolve } from 'path';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type {\n LocalizedDictionaryOutput,\n LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { fetchDictionariesDir } = configuration.content;\n const { liveSyncURL } = configuration.editor;\n\n let content = '';\n\n const formattedDictionaryMap: string = Object.entries(\n localedDictionariesPathsRecord\n )\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(fetchDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return await import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`;\n }\n\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${relativePath}'))}})()`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * 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 writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n let resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(\n Object.entries(dynamicDictionaries),\n async ([key, localedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AACtB,SAAS,UAAU,eAAe;AAClC,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAS5B,MAAM,+BAA+B,CAC1C,gCACA,SAAwB,OACxB,gBAAgB,iBAAiB,MACtB;AACX,QAAM,EAAE,qBAAqB,IAAI,cAAc;AAC/C,QAAM,EAAE,YAAY,IAAI,cAAc;AAEtC,MAAI,UAAU;AAEd,QAAM,yBAAiC,OAAO;AAAA,IAC5C;AAAA,EACF,EACG,IAAI,CAAC,CAAC,QAAQ,UAAU,MAAM;AAC7B,UAAM,eAAe;AAAA,MACnB,SAAS,sBAAsB,WAAW,cAAc;AAAA,IAC1D;AAEA,QAAI,WAAW,OAAO;AACpB,aAAO,MAAM,MAAM,oDAAoD,WAAW,iBAAiB,WAAW,WAAW,GAAG,IAAI,MAAM,sEAAsE,YAAY;AAAA,IAC1N;AAEA,WAAO,MAAM,MAAM,oDAAoD,WAAW,iBAAiB,WAAW,WAAW,GAAG,IAAI,MAAM,iFAAiF,YAAY;AAAA,EACrO,CAAC,EACA,KAAK,KAAK;AAEb,aAAW;AAAA,EAAsB,sBAAsB;AAAA;AAAA;AAEvD,MAAI,WAAW,MAAO,YAAW;AAAA;AACjC,MAAI,WAAW,MAAO,YAAW;AAAA;AAEjC,SAAO;AACT;AAkBO,MAAM,uBAAuB,OAClC,qBACA,gBAAgB,iBAAiB,GACjC,UAA6B,CAAC,OAAO,KAAK,MACH;AACvC,QAAM,EAAE,qBAAqB,IAAI,cAAc;AAG/C,QAAM,MAAM,QAAQ,oBAAoB,GAAG,EAAE,WAAW,KAAK,CAAC;AAE9D,MAAI,0BAAqD,CAAC;AAG1D,QAAM;AAAA,IACJ,OAAO,QAAQ,mBAAmB;AAAA,IAClC,OAAO,CAAC,KAAK,8BAA8B,MAAM;AAC/C,UAAI,QAAQ,YAAa;AAEzB,YAAM,YAAY,SAAS,OAAO,WAAW;AAC3C,cAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,cAAM,UAAU;AAAA,UACd;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAEA,cAAM;AAAA,UACJ,QAAQ,sBAAsB,GAAG,GAAG,IAAI,SAAS,EAAE;AAAA,UACnD;AAAA,QACF,EAAE,MAAM,CAAC,QAAQ;AACf,kBAAQ;AAAA,YACN,wBAAwB,aAAa,QAAQ,sBAAsB,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,CAAC;AAAA,YAC1F;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"writeFetchDictionary.mjs","names":["formattedDictionaryMap: string","resultDictionariesPaths: LocalizedDictionaryOutput"],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport {\n colorizePath,\n getConfiguration,\n normalizePath,\n} from '@intlayer/config';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type {\n LocalizedDictionaryOutput,\n LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { fetchDictionariesDir } = configuration.content;\n const { liveSyncURL } = configuration.editor;\n\n let content = '';\n\n const formattedDictionaryMap: string = Object.entries(\n localedDictionariesPathsRecord\n )\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(fetchDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return await import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`;\n }\n\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${relativePath}'))}})()`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * 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 writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\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(\n Object.entries(dynamicDictionaries),\n async ([key, localedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;AAiBA,MAAa,gCACX,gCACA,SAAwB,OACxB,gBAAgB,kBAAkB,KACvB;CACX,MAAM,EAAE,yBAAyB,cAAc;CAC/C,MAAM,EAAE,gBAAgB,cAAc;CAEtC,IAAI,UAAU;CAEd,MAAMA,yBAAiC,OAAO,QAC5C,+BACD,CACE,KAAK,CAAC,QAAQ,gBAAgB;EAC7B,MAAM,eAAe,cACnB,SAAS,sBAAsB,WAAW,eAAe,CAC1D;AAED,MAAI,WAAW,MACb,QAAO,MAAM,OAAO,mDAAmD,YAAY,gBAAgB,WAAW,WAAW,IAAI,GAAG,OAAO,qEAAqE,aAAa;AAG3N,SAAO,MAAM,OAAO,mDAAmD,YAAY,gBAAgB,WAAW,WAAW,IAAI,GAAG,OAAO,gFAAgF,aAAa;GACpO,CACD,KAAK,MAAM;AAEd,YAAW,sBAAsB,uBAAuB;AAExD,KAAI,WAAW,MAAO,YAAW;AACjC,KAAI,WAAW,MAAO,YAAW;AAEjC,QAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,uBAAuB,OAClC,qBACA,gBAAgB,kBAAkB,EAClC,UAA6B,CAAC,OAAO,MAAM,KACJ;CACvC,MAAM,EAAE,yBAAyB,cAAc;AAG/C,OAAM,MAAM,QAAQ,qBAAqB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE/D,MAAMC,0BAAqD,EAAE;AAG7D,OAAM,YACJ,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,oCAAoC;AAC/C,MAAI,QAAQ,YAAa;AAEzB,QAAM,YAAY,SAAS,OAAO,WAAW;GAC3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;GAC7C,MAAM,UAAU,6BACd,gCACA,QACA,cACD;AAED,SAAM,mBACJ,QAAQ,sBAAsB,GAAG,IAAI,GAAG,YAAY,EACpD,QACD,CAAC,OAAO,QAAQ;AACf,YAAQ,MACN,wBAAwB,aAAa,QAAQ,sBAAsB,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,IAC3F,IACD;KACD;IACF;GAEL;AAED,QAAO"}
@@ -1,47 +1,45 @@
1
- import { colorizePath, getConfiguration } from "@intlayer/config";
2
- import { mkdir } from "fs/promises";
3
- import { resolve } from "path";
4
- import { mergeDictionaries } from "../mergeDictionaries.mjs";
5
- import { processPerLocaleDictionary } from "../processPerLocaleDictionary.mjs";
6
1
  import { parallelize } from "../utils/parallelize.mjs";
7
2
  import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
3
+ import { colorizePath, getConfiguration } from "@intlayer/config";
4
+ import { resolve } from "node:path";
5
+ import { mergeDictionaries, normalizeDictionaries } from "@intlayer/core";
6
+ import { mkdir } from "node:fs/promises";
7
+
8
+ //#region src/buildIntlayerDictionary/writeMergedDictionary.ts
9
+ /**
10
+ * Write the merged dictionaries to the dictionariesDir
11
+ * @param groupedDictionaries - The grouped dictionaries
12
+ * @param configuration - The configuration
13
+ * @returns The merged dictionaries
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
18
+ * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
19
+ * console.log(finalDictionaries);
20
+ *
21
+ * // .intlayer/dictionary/home.json
22
+ * // { key: 'home', content: { ... } },
23
+ * ```
24
+ */
8
25
  const writeMergedDictionaries = async (groupedDictionaries, configuration = getConfiguration()) => {
9
- const { dictionariesDir } = configuration.content;
10
- await mkdir(resolve(dictionariesDir), { recursive: true });
11
- const results = await parallelize(
12
- Object.entries(groupedDictionaries),
13
- async ([key, dictionariesEntry]) => {
14
- if (key === "undefined") {
15
- return void 0;
16
- }
17
- const multiLocaleDictionaries = dictionariesEntry.dictionaries.map(
18
- (dictionary) => processPerLocaleDictionary(dictionary)
19
- );
20
- const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);
21
- const outputFileName = `${key}.json`;
22
- const resultFilePath = resolve(dictionariesDir, outputFileName);
23
- await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(
24
- (err) => {
25
- console.error(
26
- `Error creating merged ${colorizePath(resultFilePath)}:`,
27
- err
28
- );
29
- }
30
- );
31
- return [
32
- key,
33
- {
34
- dictionaryPath: resultFilePath,
35
- dictionary: mergedDictionary
36
- }
37
- ];
38
- }
39
- );
40
- return Object.fromEntries(
41
- results.filter(Boolean)
42
- );
43
- };
44
- export {
45
- writeMergedDictionaries
26
+ const { dictionariesDir } = configuration.content;
27
+ await mkdir(resolve(dictionariesDir), { recursive: true });
28
+ const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionariesEntry]) => {
29
+ if (key === "undefined") return;
30
+ const mergedDictionary = mergeDictionaries(normalizeDictionaries(dictionariesEntry.dictionaries, configuration));
31
+ const resultFilePath = resolve(dictionariesDir, `${key}.json`);
32
+ await writeJsonIfChanged(resultFilePath, mergedDictionary).catch((err) => {
33
+ console.error(`Error creating merged ${colorizePath(resultFilePath)}:`, err);
34
+ });
35
+ return [key, {
36
+ dictionaryPath: resultFilePath,
37
+ dictionary: mergedDictionary
38
+ }];
39
+ });
40
+ return Object.fromEntries(results.filter(Boolean));
46
41
  };
42
+
43
+ //#endregion
44
+ export { writeMergedDictionaries };
47
45
  //# sourceMappingURL=writeMergedDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { colorizePath, getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\nimport { mergeDictionaries } from '../mergeDictionaries';\nimport { processPerLocaleDictionary } from '../processPerLocaleDictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport { 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 = getConfiguration()\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.content;\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 multiLocaleDictionaries = dictionariesEntry.dictionaries.map(\n (dictionary) => processPerLocaleDictionary(dictionary)\n );\n\n const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":"AAAA,SAAS,cAAc,wBAAwB;AAE/C,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,kCAAkC;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AA0B5B,MAAM,0BAA0B,OACrC,qBACA,gBAAgB,iBAAiB,MACG;AACpC,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAG1C,QAAM,MAAM,QAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;AAEzD,QAAM,UAAU,MAAM;AAAA,IACpB,OAAO,QAAQ,mBAAmB;AAAA,IAClC,OAAO,CAAC,KAAK,iBAAiB,MAAM;AAClC,UAAI,QAAQ,aAAa;AACvB,eAAO;AAAA,MAIT;AAEA,YAAM,0BAA0B,kBAAkB,aAAa;AAAA,QAC7D,CAAC,eAAe,2BAA2B,UAAU;AAAA,MACvD;AAEA,YAAM,mBAAmB,kBAAkB,uBAAuB;AAElE,YAAM,iBAAiB,GAAG,GAAG;AAC7B,YAAM,iBAAiB,QAAQ,iBAAiB,cAAc;AAG9D,YAAM,mBAAmB,gBAAgB,gBAAgB,EAAE;AAAA,QACzD,CAAC,QAAQ;AACP,kBAAQ;AAAA,YACN,yBAAyB,aAAa,cAAc,CAAC;AAAA,YACrD;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,UACE,gBAAgB;AAAA,UAChB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO;AAAA,IACZ,QAAQ,OAAO,OAAO;AAAA,EACxB;AACF;","names":[]}
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, getConfiguration } from '@intlayer/config';\nimport { mergeDictionaries, normalizeDictionaries } from '@intlayer/core';\nimport type { Dictionary } from '@intlayer/types';\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 = getConfiguration()\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const normalizedDictionaries = normalizeDictionaries(\n dictionariesEntry.dictionaries,\n configuration\n );\n\n const mergedDictionary = mergeDictionaries(normalizedDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,0BAA0B,OACrC,qBACA,gBAAgB,kBAAkB,KACE;CACpC,MAAM,EAAE,oBAAoB,cAAc;AAG1C,OAAM,MAAM,QAAQ,gBAAgB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE1D,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAK,uBAAuB;AAClC,MAAI,QAAQ,YACV;EAWF,MAAM,mBAAmB,kBALM,sBAC7B,kBAAkB,cAClB,cACD,CAEiE;EAGlE,MAAM,iBAAiB,QAAQ,iBADR,GAAG,IAAI,OACiC;AAG/D,QAAM,mBAAmB,gBAAgB,iBAAiB,CAAC,OACxD,QAAQ;AACP,WAAQ,MACN,yBAAyB,aAAa,eAAe,CAAC,IACtD,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB,YAAY;GACb,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CACxB"}
@@ -1,30 +1,40 @@
1
- import { colorizePath, getConfiguration } from "@intlayer/config";
2
- import { mkdir } from "fs/promises";
3
- import { resolve } from "path";
4
- import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
5
- import { formatDistantDictionaries } from "../loadDictionaries/index.mjs";
6
1
  import { parallelize } from "../utils/parallelize.mjs";
2
+ import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
7
3
  import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
4
+ import { formatDistantDictionaries } from "../loadDictionaries/loadRemoteDictionaries.mjs";
5
+ import { colorizePath, getConfiguration } from "@intlayer/config";
6
+ import { resolve } from "node:path";
7
+ import { mkdir } from "node:fs/promises";
8
+
9
+ //#region src/buildIntlayerDictionary/writeRemoteDictionary.ts
10
+ /**
11
+ * Write the localized dictionaries to the dictionariesDir
12
+ * @param mergedDictionaries - The merged dictionaries
13
+ * @param configuration - The configuration
14
+ * @returns The final dictionaries
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
19
+ * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);
20
+ * console.log(finalDictionaries);
21
+ *
22
+ * // .intlayer/fetch_dictionaries/home.json
23
+ * // { key: 'home', content: { ... } },
24
+ * ```
25
+ */
8
26
  const writeRemoteDictionary = async (remoteDictionaries, configuration = getConfiguration()) => {
9
- const { remoteDictionariesDir } = configuration.content;
10
- await mkdir(resolve(remoteDictionariesDir), { recursive: true });
11
- const filteredDictionaries = filterInvalidDictionaries(remoteDictionaries);
12
- await parallelize(
13
- filteredDictionaries.filter((dictionary) => dictionary.key !== "undefined"),
14
- async (dictionary) => {
15
- const outputFileName = `${dictionary.key}.json`;
16
- const resultFilePath = resolve(remoteDictionariesDir, outputFileName);
17
- await writeJsonIfChanged(resultFilePath, dictionary).catch((err) => {
18
- console.error(
19
- `Error creating merged ${colorizePath(resultFilePath)}:`,
20
- err
21
- );
22
- });
23
- }
24
- );
25
- return formatDistantDictionaries(remoteDictionaries);
26
- };
27
- export {
28
- writeRemoteDictionary
27
+ const { remoteDictionariesDir } = configuration.content;
28
+ await mkdir(resolve(remoteDictionariesDir), { recursive: true });
29
+ await parallelize(filterInvalidDictionaries(remoteDictionaries, configuration).filter((dictionary) => dictionary.key !== "undefined"), async (dictionary) => {
30
+ const resultFilePath = resolve(remoteDictionariesDir, `${dictionary.key}.json`);
31
+ await writeJsonIfChanged(resultFilePath, dictionary).catch((err) => {
32
+ console.error(`Error creating merged ${colorizePath(resultFilePath)}:`, err);
33
+ });
34
+ });
35
+ return formatDistantDictionaries(remoteDictionaries);
29
36
  };
37
+
38
+ //#endregion
39
+ export { writeRemoteDictionary };
30
40
  //# sourceMappingURL=writeRemoteDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { colorizePath, getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\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 = getConfiguration()\n): Promise<Dictionary[]> => {\n const { remoteDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(remoteDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(remoteDictionaries);\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n filteredDictionaries.filter((dictionary) => dictionary.key !== 'undefined'),\n async (dictionary) => {\n const outputFileName = `${dictionary.key}.json`;\n const resultFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, dictionary).catch((err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n });\n }\n );\n\n return formatDistantDictionaries(remoteDictionaries);\n};\n"],"mappings":"AAAA,SAAS,cAAc,wBAAwB;AAE/C,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAkB5B,MAAM,wBAAwB,OACnC,oBACA,gBAAgB,iBAAiB,MACP;AAC1B,QAAM,EAAE,sBAAsB,IAAI,cAAc;AAGhD,QAAM,MAAM,QAAQ,qBAAqB,GAAG,EAAE,WAAW,KAAK,CAAC;AAE/D,QAAM,uBAAuB,0BAA0B,kBAAkB;AAGzE,QAAM;AAAA,IACJ,qBAAqB,OAAO,CAAC,eAAe,WAAW,QAAQ,WAAW;AAAA,IAC1E,OAAO,eAAe;AACpB,YAAM,iBAAiB,GAAG,WAAW,GAAG;AACxC,YAAM,iBAAiB,QAAQ,uBAAuB,cAAc;AAGpE,YAAM,mBAAmB,gBAAgB,UAAU,EAAE,MAAM,CAAC,QAAQ;AAClE,gBAAQ;AAAA,UACN,yBAAyB,aAAa,cAAc,CAAC;AAAA,UACrD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,0BAA0B,kBAAkB;AACrD;","names":[]}
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, getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\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 = getConfiguration()\n): Promise<Dictionary[]> => {\n const { remoteDictionariesDir } = configuration.content;\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 // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n filteredDictionaries.filter((dictionary) => dictionary.key !== 'undefined'),\n async (dictionary) => {\n const outputFileName = `${dictionary.key}.json`;\n const resultFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, dictionary).catch((err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n });\n }\n );\n\n return formatDistantDictionaries(remoteDictionaries);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,wBAAwB,OACnC,oBACA,gBAAgB,kBAAkB,KACR;CAC1B,MAAM,EAAE,0BAA0B,cAAc;AAGhD,OAAM,MAAM,QAAQ,sBAAsB,EAAE,EAAE,WAAW,MAAM,CAAC;AAQhE,OAAM,YANuB,0BAC3B,oBACA,cACD,CAIsB,QAAQ,eAAe,WAAW,QAAQ,YAAY,EAC3E,OAAO,eAAe;EAEpB,MAAM,iBAAiB,QAAQ,uBADR,GAAG,WAAW,IAAI,OAC4B;AAGrE,QAAM,mBAAmB,gBAAgB,WAAW,CAAC,OAAO,QAAQ;AAClE,WAAQ,MACN,yBAAyB,aAAa,eAAe,CAAC,IACtD,IACD;IACD;GAEL;AAED,QAAO,0BAA0B,mBAAmB"}
@@ -1,60 +1,57 @@
1
- import { colorizePath, getConfiguration, x } from "@intlayer/config";
2
- import { mkdir } from "fs/promises";
3
- import { resolve } from "path";
4
- import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
5
- import { orderDictionaries } from "../orderDictionaries.mjs";
6
1
  import { parallelize } from "../utils/parallelize.mjs";
2
+ import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
7
3
  import { writeJsonIfChanged } from "../writeJsonIfChanged.mjs";
8
- const groupDictionariesByKey = (dictionaries) => dictionaries.reduce(
9
- (acc, dictionary) => {
10
- const key = dictionary.key;
11
- if (!acc[key]) {
12
- acc[key] = [];
13
- }
14
- acc[key].push(dictionary);
15
- return acc;
16
- },
17
- {}
18
- );
19
- const writeUnmergedDictionaries = async (dictionaries, configuration = getConfiguration()) => {
20
- const { unmergedDictionariesDir } = configuration.content;
21
- await mkdir(resolve(unmergedDictionariesDir), { recursive: true });
22
- const filteredDictionaries = filterInvalidDictionaries(dictionaries);
23
- const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);
24
- const results = await parallelize(
25
- Object.entries(groupedDictionaries),
26
- async ([key, dictionaries2]) => {
27
- if (key === "undefined") {
28
- return void 0;
29
- }
30
- const orderedDictionaries = orderDictionaries(
31
- dictionaries2,
32
- configuration
33
- );
34
- const outputFileName = `${key}.json`;
35
- const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);
36
- await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(
37
- (err) => {
38
- console.error(
39
- `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,
40
- err
41
- );
42
- }
43
- );
44
- return [
45
- key,
46
- {
47
- dictionaryPath: unmergedFilePath,
48
- dictionaries: dictionaries2
49
- }
50
- ];
51
- }
52
- );
53
- return Object.fromEntries(
54
- results.filter(Boolean)
55
- );
56
- };
57
- export {
58
- writeUnmergedDictionaries
4
+ import { colorizePath, x } from "@intlayer/config";
5
+ import { resolve } from "node:path";
6
+ import { orderDictionaries } from "@intlayer/core";
7
+ import { mkdir } from "node:fs/promises";
8
+
9
+ //#region src/buildIntlayerDictionary/writeUnmergedDictionary.ts
10
+ const groupDictionariesByKey = (dictionaries) => dictionaries.reduce((acc, dictionary) => {
11
+ const key = dictionary.key;
12
+ if (!acc[key]) acc[key] = [];
13
+ acc[key].push(dictionary);
14
+ return acc;
15
+ }, {});
16
+ /**
17
+ * Write the unmerged dictionaries to the unmergedDictionariesDir
18
+ * @param dictionaries - The dictionaries to write
19
+ * @param configuration - The configuration
20
+ * @returns The grouped dictionaries
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);
25
+ * console.log(unmergedDictionaries);
26
+ *
27
+ * // .intlayer/unmerged_dictionaries/home.json
28
+ * // {
29
+ * // [
30
+ * // { key: 'home', content: { ... } },
31
+ * // { key: 'home', content: { ... } },
32
+ * // ],
33
+ * // }
34
+ * ```
35
+ */
36
+ const writeUnmergedDictionaries = async (dictionaries, configuration) => {
37
+ const { unmergedDictionariesDir } = configuration.content;
38
+ await mkdir(resolve(unmergedDictionariesDir), { recursive: true });
39
+ const groupedDictionaries = groupDictionariesByKey(filterInvalidDictionaries(dictionaries, configuration));
40
+ const results = await parallelize(Object.entries(groupedDictionaries), async ([key, dictionaries$1]) => {
41
+ if (key === "undefined") return;
42
+ const orderedDictionaries = orderDictionaries(dictionaries$1, configuration);
43
+ const unmergedFilePath = resolve(unmergedDictionariesDir, `${key}.json`);
44
+ await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch((err) => {
45
+ console.error(`${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`, err);
46
+ });
47
+ return [key, {
48
+ dictionaryPath: unmergedFilePath,
49
+ dictionaries: dictionaries$1
50
+ }];
51
+ });
52
+ return Object.fromEntries(results.filter(Boolean));
59
53
  };
54
+
55
+ //#endregion
56
+ export { writeUnmergedDictionaries };
60
57
  //# sourceMappingURL=writeUnmergedDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { colorizePath, getConfiguration, x } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { orderDictionaries } from '../orderDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nconst 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<string, UnmergedDictionaryResult>;\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 = getConfiguration()\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(dictionaries);\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const orderedDictionaries = orderDictionaries(\n dictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\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: 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":"AAAA,SAAS,cAAc,kBAAkB,SAAS;AAElD,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAEnC,MAAM,yBAAyB,CAC7B,iBAEA,aAAa;AAAA,EACX,CAAC,KAAK,eAAe;AACnB,UAAM,MAAM,WAAW;AACvB,QAAI,CAAC,IAAI,GAAG,GAAG;AACb,UAAI,GAAG,IAAI,CAAC;AAAA,IACd;AACA,QAAI,GAAG,EAAE,KAAK,UAAU;AACxB,WAAO;AAAA,EACT;AAAA,EACA,CAAC;AACH;AA6BK,MAAM,4BAA4B,OACvC,cACA,gBAAgB,iBAAiB,MACK;AACtC,QAAM,EAAE,wBAAwB,IAAI,cAAc;AAGlD,QAAM,MAAM,QAAQ,uBAAuB,GAAG,EAAE,WAAW,KAAK,CAAC;AAEjE,QAAM,uBAAuB,0BAA0B,YAAY;AAGnE,QAAM,sBAAsB,uBAAuB,oBAAoB;AAEvE,QAAM,UAAU,MAAM;AAAA,IACpB,OAAO,QAAQ,mBAAmB;AAAA,IAClC,OAAO,CAAC,KAAKA,aAAY,MAAM;AAC7B,UAAI,QAAQ,aAAa;AACvB,eAAO;AAAA,MAIT;AAEA,YAAM,sBAAsB;AAAA,QAC1BA;AAAA,QACA;AAAA,MACF;AAEA,YAAM,iBAAiB,GAAG,GAAG;AAC7B,YAAM,mBAAmB,QAAQ,yBAAyB,cAAc;AAGxE,YAAM,mBAAmB,kBAAkB,mBAAmB,EAAE;AAAA,QAC9D,CAAC,QAAQ;AACP,kBAAQ;AAAA,YACN,GAAG,CAAC,4BAA4B,aAAa,gBAAgB,CAAC;AAAA,YAC9D;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,UACE,gBAAgB;AAAA,UAChB,cAAcA;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO;AAAA,IACZ,QAAQ,OAAO,OAAO;AAAA,EAGxB;AACF;","names":["dictionaries"]}
1
+ {"version":3,"file":"writeUnmergedDictionary.mjs","names":["dictionaries"],"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config';\nimport { orderDictionaries } from '@intlayer/core';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nconst 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<string, UnmergedDictionaryResult>;\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): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.content;\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 );\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const orderedDictionaries = orderDictionaries(\n dictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\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: 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":";;;;;;;;;AASA,MAAM,0BACJ,iBAEA,aAAa,QACV,KAAK,eAAe;CACnB,MAAM,MAAM,WAAW;AACvB,KAAI,CAAC,IAAI,KACP,KAAI,OAAO,EAAE;AAEf,KAAI,KAAK,KAAK,WAAW;AACzB,QAAO;GAET,EAAE,CACH;;;;;;;;;;;;;;;;;;;;;AA6BH,MAAa,4BAA4B,OACvC,cACA,kBACsC;CACtC,MAAM,EAAE,4BAA4B,cAAc;AAGlD,OAAM,MAAM,QAAQ,wBAAwB,EAAE,EAAE,WAAW,MAAM,CAAC;CAQlE,MAAM,sBAAsB,uBANC,0BAC3B,cACA,cACD,CAGuE;CAExE,MAAM,UAAU,MAAM,YACpB,OAAO,QAAQ,oBAAoB,EACnC,OAAO,CAAC,KAAKA,oBAAkB;AAC7B,MAAI,QAAQ,YACV;EAMF,MAAM,sBAAsB,kBAC1BA,gBACA,cACD;EAGD,MAAM,mBAAmB,QAAQ,yBADV,GAAG,IAAI,OAC2C;AAGzE,QAAM,mBAAmB,kBAAkB,oBAAoB,CAAC,OAC7D,QAAQ;AACP,WAAQ,MACN,GAAG,EAAE,2BAA2B,aAAa,iBAAiB,CAAC,IAC/D,IACD;IAEJ;AAED,SAAO,CACL,KACA;GACE,gBAAgB;GAChB,cAAcA;GACf,CACF;GAEJ;AAED,QAAO,OAAO,YACZ,QAAQ,OAAO,QAAQ,CAGxB"}
@@ -1,38 +1,19 @@
1
- import { getAppLogger, getConfiguration } from "@intlayer/config";
2
- import { existsSync, rmSync } from "fs";
3
- const cleanOutputDir = (configuration = getConfiguration()) => {
4
- const {
5
- dictionariesDir,
6
- unmergedDictionariesDir,
7
- dynamicDictionariesDir,
8
- mainDir,
9
- typesDir,
10
- configDir
11
- } = configuration.content;
12
- const appLogger = getAppLogger(configuration);
13
- if (existsSync(dictionariesDir)) {
14
- rmSync(dictionariesDir, { recursive: true });
15
- }
16
- if (existsSync(unmergedDictionariesDir)) {
17
- rmSync(unmergedDictionariesDir, { recursive: true });
18
- }
19
- if (existsSync(dynamicDictionariesDir)) {
20
- rmSync(dynamicDictionariesDir, { recursive: true });
21
- }
22
- if (existsSync(mainDir)) {
23
- rmSync(mainDir, { recursive: true });
24
- }
25
- if (existsSync(typesDir)) {
26
- rmSync(typesDir, { recursive: true });
27
- }
28
- if (existsSync(configDir)) {
29
- rmSync(configDir, { recursive: true });
30
- }
31
- appLogger("Output directory cleaned", {
32
- isVerbose: true
33
- });
34
- };
35
- export {
36
- cleanOutputDir
1
+ import { existsSync, rmSync } from "node:fs";
2
+ import { getAppLogger } from "@intlayer/config";
3
+
4
+ //#region src/cleanOutputDir.ts
5
+ const cleanOutputDir = (configuration) => {
6
+ const { dictionariesDir, unmergedDictionariesDir, dynamicDictionariesDir, mainDir, typesDir, configDir } = configuration.content;
7
+ const appLogger = getAppLogger(configuration);
8
+ if (existsSync(dictionariesDir)) rmSync(dictionariesDir, { recursive: true });
9
+ if (existsSync(unmergedDictionariesDir)) rmSync(unmergedDictionariesDir, { recursive: true });
10
+ if (existsSync(dynamicDictionariesDir)) rmSync(dynamicDictionariesDir, { recursive: true });
11
+ if (existsSync(mainDir)) rmSync(mainDir, { recursive: true });
12
+ if (existsSync(typesDir)) rmSync(typesDir, { recursive: true });
13
+ if (existsSync(configDir)) rmSync(configDir, { recursive: true });
14
+ appLogger("Output directory cleaned", { isVerbose: true });
37
15
  };
16
+
17
+ //#endregion
18
+ export { cleanOutputDir };
38
19
  //# sourceMappingURL=cleanOutputDir.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { getAppLogger, getConfiguration } from '@intlayer/config';\nimport { existsSync, rmSync } from 'fs';\n\nexport const cleanOutputDir = (configuration = getConfiguration()) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n if (existsSync(dynamicDictionariesDir)) {\n // Delete the dynamic dictionaries directory\n rmSync(dynamicDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":"AAAA,SAAS,cAAc,wBAAwB;AAC/C,SAAS,YAAY,cAAc;AAE5B,MAAM,iBAAiB,CAAC,gBAAgB,iBAAiB,MAAM;AACpE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc;AAElB,QAAM,YAAY,aAAa,aAAa;AAE5C,MAAI,WAAW,eAAe,GAAG;AAE/B,WAAO,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAAA,EAC7C;AAEA,MAAI,WAAW,uBAAuB,GAAG;AAEvC,WAAO,yBAAyB,EAAE,WAAW,KAAK,CAAC;AAAA,EACrD;AAEA,MAAI,WAAW,sBAAsB,GAAG;AAEtC,WAAO,wBAAwB,EAAE,WAAW,KAAK,CAAC;AAAA,EACpD;AAGA,MAAI,WAAW,OAAO,GAAG;AACvB,WAAO,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACrC;AAGA,MAAI,WAAW,QAAQ,GAAG;AACxB,WAAO,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACtC;AAGA,MAAI,WAAW,SAAS,GAAG;AACzB,WAAO,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC;AAEA,YAAU,4BAA4B;AAAA,IACpC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
1
+ {"version":3,"file":"cleanOutputDir.mjs","names":[],"sources":["../../src/cleanOutputDir.ts"],"sourcesContent":["import { existsSync, rmSync } from 'node:fs';\nimport { getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const cleanOutputDir = (configuration: IntlayerConfig) => {\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n mainDir,\n typesDir,\n configDir,\n } = configuration.content;\n\n const appLogger = getAppLogger(configuration);\n\n if (existsSync(dictionariesDir)) {\n // Delete the dictionary directory\n rmSync(dictionariesDir, { recursive: true });\n }\n\n if (existsSync(unmergedDictionariesDir)) {\n // Delete the unmerged dictionaries directory\n rmSync(unmergedDictionariesDir, { recursive: true });\n }\n\n if (existsSync(dynamicDictionariesDir)) {\n // Delete the dynamic dictionaries directory\n rmSync(dynamicDictionariesDir, { recursive: true });\n }\n\n // Delete the main directory\n if (existsSync(mainDir)) {\n rmSync(mainDir, { recursive: true });\n }\n\n // Delete the types directory\n if (existsSync(typesDir)) {\n rmSync(typesDir, { recursive: true });\n }\n\n // Delete the config directory\n if (existsSync(configDir)) {\n rmSync(configDir, { recursive: true });\n }\n\n appLogger('Output directory cleaned', {\n isVerbose: true,\n });\n};\n"],"mappings":";;;;AAIA,MAAa,kBAAkB,kBAAkC;CAC/D,MAAM,EACJ,iBACA,yBACA,wBACA,SACA,UACA,cACE,cAAc;CAElB,MAAM,YAAY,aAAa,cAAc;AAE7C,KAAI,WAAW,gBAAgB,CAE7B,QAAO,iBAAiB,EAAE,WAAW,MAAM,CAAC;AAG9C,KAAI,WAAW,wBAAwB,CAErC,QAAO,yBAAyB,EAAE,WAAW,MAAM,CAAC;AAGtD,KAAI,WAAW,uBAAuB,CAEpC,QAAO,wBAAwB,EAAE,WAAW,MAAM,CAAC;AAIrD,KAAI,WAAW,QAAQ,CACrB,QAAO,SAAS,EAAE,WAAW,MAAM,CAAC;AAItC,KAAI,WAAW,SAAS,CACtB,QAAO,UAAU,EAAE,WAAW,MAAM,CAAC;AAIvC,KAAI,WAAW,UAAU,CACvB,QAAO,WAAW,EAAE,WAAW,MAAM,CAAC;AAGxC,WAAU,4BAA4B,EACpC,WAAW,MACZ,CAAC"}
@@ -1,6 +1,3 @@
1
- import { getConfiguration } from "@intlayer/config";
2
- import { mkdir } from "fs/promises";
3
- import { resolve } from "path";
4
1
  import { parallelize } from "../utils/parallelize.mjs";
5
2
  import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
6
3
  import { generateDictionaryListContent } from "./generateDictionaryListContent.mjs";
@@ -9,74 +6,58 @@ import { getBuiltDynamicDictionariesPath } from "./getBuiltDynamicDictionariesPa
9
6
  import { getBuiltFetchDictionariesPath } from "./getBuiltFetchDictionariesPath.mjs";
10
7
  import { getBuiltRemoteDictionariesPath } from "./getBuiltRemoteDictionariesPath.mjs";
11
8
  import { getBuiltUnmergedDictionariesPath } from "./getBuiltUnmergedDictionariesPath.mjs";
12
- const filterDictionaries = (paths, keys) => {
13
- if (!keys) return paths;
14
- return paths.filter(
15
- (path) => keys.some((key) => path.endsWith(`${key}.json`))
16
- );
17
- };
9
+ import { getConfiguration } from "@intlayer/config";
10
+ import { resolve } from "node:path";
11
+ import { mkdir } from "node:fs/promises";
12
+
13
+ //#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts
18
14
  const writeDictionaryFiles = async (paths, fileName, functionName, format, configuration = getConfiguration()) => {
19
- const content = generateDictionaryListContent(
20
- paths,
21
- functionName,
22
- format,
23
- configuration
24
- );
25
- const extension = format === "cjs" ? "cjs" : "mjs";
26
- const { mainDir } = configuration.content;
27
- await writeFileIfChanged(
28
- resolve(mainDir, `${fileName}.${extension}`),
29
- content
30
- );
31
- };
32
- const createDictionaryEntryPoint = async (configuration = getConfiguration(), dictionariesKeys, formats) => {
33
- const outputFormats = formats ?? configuration.build.outputFormat;
34
- const { mainDir } = configuration.content;
35
- await mkdir(mainDir, { recursive: true });
36
- const remoteDictionariesPath = getBuiltRemoteDictionariesPath(configuration);
37
- const dictionariesPath = filterDictionaries(
38
- getBuiltDictionariesPath(configuration),
39
- dictionariesKeys
40
- );
41
- const unmergedDictionariesPath = getBuiltUnmergedDictionariesPath(configuration);
42
- const writeOperations = [
43
- ...outputFormats.map((format) => ({
44
- paths: remoteDictionariesPath,
45
- functionName: "getRemoteDictionaries",
46
- fileName: "remote_dictionaries",
47
- format
48
- })),
49
- ...outputFormats.map((format) => ({
50
- paths: dictionariesPath,
51
- functionName: "getDictionaries",
52
- fileName: "dictionaries",
53
- format
54
- })),
55
- ...outputFormats.map((format) => ({
56
- paths: unmergedDictionariesPath,
57
- functionName: "getUnmergedDictionaries",
58
- fileName: "unmerged_dictionaries",
59
- format
60
- })),
61
- ...outputFormats.map((format) => ({
62
- paths: getBuiltDynamicDictionariesPath(configuration, format),
63
- functionName: "getDynamicDictionaries",
64
- fileName: "dynamic_dictionaries",
65
- format
66
- })),
67
- ...outputFormats.map((format) => ({
68
- paths: getBuiltFetchDictionariesPath(configuration, format),
69
- functionName: "getFetchDictionaries",
70
- fileName: "fetch_dictionaries",
71
- format
72
- }))
73
- ];
74
- await parallelize(
75
- writeOperations,
76
- async ({ paths, fileName, format, functionName }) => writeDictionaryFiles(paths, fileName, functionName, format, configuration)
77
- );
15
+ const content = generateDictionaryListContent(await paths, functionName, format, configuration);
16
+ const extension = format === "cjs" ? "cjs" : "mjs";
17
+ const { mainDir } = configuration.content;
18
+ await writeFileIfChanged(resolve(mainDir, `${fileName}.${extension}`), content);
78
19
  };
79
- export {
80
- createDictionaryEntryPoint
20
+ /**
21
+ * This function generates a list of dictionaries in the main directory
22
+ */
23
+ const createDictionaryEntryPoint = async (configuration = getConfiguration(), formats) => {
24
+ const outputFormats = formats ?? configuration.build.outputFormat;
25
+ const { mainDir } = configuration.content;
26
+ await mkdir(mainDir, { recursive: true });
27
+ await parallelize([
28
+ ...outputFormats.map((format) => ({
29
+ paths: getBuiltRemoteDictionariesPath(configuration),
30
+ functionName: "getRemoteDictionaries",
31
+ fileName: "remote_dictionaries",
32
+ format
33
+ })),
34
+ ...outputFormats.map((format) => ({
35
+ paths: getBuiltDictionariesPath(configuration),
36
+ functionName: "getDictionaries",
37
+ fileName: "dictionaries",
38
+ format
39
+ })),
40
+ ...outputFormats.map((format) => ({
41
+ paths: getBuiltUnmergedDictionariesPath(configuration),
42
+ functionName: "getUnmergedDictionaries",
43
+ fileName: "unmerged_dictionaries",
44
+ format
45
+ })),
46
+ ...outputFormats.map((format) => ({
47
+ paths: getBuiltDynamicDictionariesPath(configuration, format),
48
+ functionName: "getDynamicDictionaries",
49
+ fileName: "dynamic_dictionaries",
50
+ format
51
+ })),
52
+ ...outputFormats.map((format) => ({
53
+ paths: getBuiltFetchDictionariesPath(configuration, format),
54
+ functionName: "getFetchDictionaries",
55
+ fileName: "fetch_dictionaries",
56
+ format
57
+ }))
58
+ ], async ({ paths, fileName, format, functionName }) => writeDictionaryFiles(paths, fileName, functionName, format, configuration));
81
59
  };
60
+
61
+ //#endregion
62
+ export { createDictionaryEntryPoint };
82
63
  //# sourceMappingURL=createDictionaryEntryPoint.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\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 filterDictionaries = (paths: string[], keys?: string[]) => {\n if (!keys) return paths;\n return paths.filter((path) =>\n keys.some((key) => path.endsWith(`${key}.json`))\n );\n};\n\nconst writeDictionaryFiles = async (\n paths: string[],\n fileName: string,\n functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(\n paths,\n functionName,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n dictionariesKeys?: string[],\n formats?: ('cjs' | 'esm')[]\n) => {\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.content;\n\n await mkdir(mainDir, { recursive: true });\n\n const remoteDictionariesPath = getBuiltRemoteDictionariesPath(configuration);\n const dictionariesPath = filterDictionaries(\n getBuiltDictionariesPath(configuration),\n dictionariesKeys\n );\n const unmergedDictionariesPath =\n getBuiltUnmergedDictionariesPath(configuration);\n\n const writeOperations = [\n ...outputFormats.map((format) => ({\n paths: remoteDictionariesPath,\n functionName: 'getRemoteDictionaries',\n fileName: 'remote_dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: dictionariesPath,\n functionName: 'getDictionaries',\n fileName: 'dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: unmergedDictionariesPath,\n functionName: 'getUnmergedDictionaries',\n fileName: 'unmerged_dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: getBuiltDynamicDictionariesPath(configuration, format),\n functionName: 'getDynamicDictionaries',\n fileName: 'dynamic_dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: getBuiltFetchDictionariesPath(configuration, format),\n functionName: 'getFetchDictionaries',\n fileName: 'fetch_dictionaries' as const,\n format,\n })),\n ];\n\n await parallelize(\n writeOperations,\n async ({ paths, fileName, format, functionName }) =>\n writeDictionaryFiles(paths, fileName, functionName, format, configuration)\n );\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AACjC,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AACnC,SAAS,qCAAqC;AAC9C,SAAS,gCAAgC;AACzC,SAAS,uCAAuC;AAChD,SAAS,qCAAqC;AAC9C,SAAS,sCAAsC;AAC/C,SAAS,wCAAwC;AAEjD,MAAM,qBAAqB,CAAC,OAAiB,SAAoB;AAC/D,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,MAAM;AAAA,IAAO,CAAC,SACnB,KAAK,KAAK,CAAC,QAAQ,KAAK,SAAS,GAAG,GAAG,OAAO,CAAC;AAAA,EACjD;AACF;AAEA,MAAM,uBAAuB,OAC3B,OACA,UACA,cACA,QACA,gBAAgB,iBAAiB,MAC9B;AACH,QAAM,UAAU;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,YAAY,WAAW,QAAQ,QAAQ;AAE7C,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,QAAM;AAAA,IACJ,QAAQ,SAAS,GAAG,QAAQ,IAAI,SAAS,EAAE;AAAA,IAC3C;AAAA,EACF;AACF;AAKO,MAAM,6BAA6B,OACxC,gBAAgB,iBAAiB,GACjC,kBACA,YACG;AACH,QAAM,gBAAgB,WAAW,cAAc,MAAM;AACrD,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,QAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;AAExC,QAAM,yBAAyB,+BAA+B,aAAa;AAC3E,QAAM,mBAAmB;AAAA,IACvB,yBAAyB,aAAa;AAAA,IACtC;AAAA,EACF;AACA,QAAM,2BACJ,iCAAiC,aAAa;AAEhD,QAAM,kBAAkB;AAAA,IACtB,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,OAAO;AAAA,MACP,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,IACF,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,OAAO;AAAA,MACP,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,IACF,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,OAAO;AAAA,MACP,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,IACF,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,OAAO,gCAAgC,eAAe,MAAM;AAAA,MAC5D,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,IACF,GAAG,cAAc,IAAI,CAAC,YAAY;AAAA,MAChC,OAAO,8BAA8B,eAAe,MAAM;AAAA,MAC1D,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,IACF,EAAE;AAAA,EACJ;AAEA,QAAM;AAAA,IACJ;AAAA,IACA,OAAO,EAAE,OAAO,UAAU,QAAQ,aAAa,MAC7C,qBAAqB,OAAO,UAAU,cAAc,QAAQ,aAAa;AAAA,EAC7E;AACF;","names":[]}
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';\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 functionName: string,\n format: 'cjs' | 'esm',\n configuration = getConfiguration()\n) => {\n const content = generateDictionaryListContent(\n await paths,\n functionName,\n format,\n configuration\n );\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n const { mainDir } = configuration.content;\n\n await writeFileIfChanged(\n resolve(mainDir, `${fileName}.${extension}`),\n content\n );\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryEntryPoint = async (\n configuration = getConfiguration(),\n formats?: ('cjs' | 'esm')[]\n) => {\n const outputFormats = formats ?? configuration.build.outputFormat;\n const { mainDir } = configuration.content;\n\n await mkdir(mainDir, { recursive: true });\n\n const writeOperations = [\n ...outputFormats.map((format) => ({\n paths: getBuiltRemoteDictionariesPath(configuration),\n functionName: 'getRemoteDictionaries',\n fileName: 'remote_dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: getBuiltDictionariesPath(configuration),\n functionName: 'getDictionaries',\n fileName: 'dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: getBuiltUnmergedDictionariesPath(configuration),\n functionName: 'getUnmergedDictionaries',\n fileName: 'unmerged_dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: getBuiltDynamicDictionariesPath(configuration, format),\n functionName: 'getDynamicDictionaries',\n fileName: 'dynamic_dictionaries' as const,\n format,\n })),\n ...outputFormats.map((format) => ({\n paths: getBuiltFetchDictionariesPath(configuration, format),\n functionName: 'getFetchDictionaries',\n fileName: 'fetch_dictionaries' as const,\n format,\n })),\n ];\n\n await parallelize(\n writeOperations,\n async ({ paths, fileName, format, functionName }) =>\n writeDictionaryFiles(paths, fileName, functionName, format, configuration)\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAM,uBAAuB,OAC3B,OACA,UACA,cACA,QACA,gBAAgB,kBAAkB,KAC/B;CACH,MAAM,UAAU,8BACd,MAAM,OACN,cACA,QACA,cACD;CACD,MAAM,YAAY,WAAW,QAAQ,QAAQ;CAE7C,MAAM,EAAE,YAAY,cAAc;AAElC,OAAM,mBACJ,QAAQ,SAAS,GAAG,SAAS,GAAG,YAAY,EAC5C,QACD;;;;;AAMH,MAAa,6BAA6B,OACxC,gBAAgB,kBAAkB,EAClC,YACG;CACH,MAAM,gBAAgB,WAAW,cAAc,MAAM;CACrD,MAAM,EAAE,YAAY,cAAc;AAElC,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;AAmCzC,OAAM,YAjCkB;EACtB,GAAG,cAAc,KAAK,YAAY;GAChC,OAAO,+BAA+B,cAAc;GACpD,cAAc;GACd,UAAU;GACV;GACD,EAAE;EACH,GAAG,cAAc,KAAK,YAAY;GAChC,OAAO,yBAAyB,cAAc;GAC9C,cAAc;GACd,UAAU;GACV;GACD,EAAE;EACH,GAAG,cAAc,KAAK,YAAY;GAChC,OAAO,iCAAiC,cAAc;GACtD,cAAc;GACd,UAAU;GACV;GACD,EAAE;EACH,GAAG,cAAc,KAAK,YAAY;GAChC,OAAO,gCAAgC,eAAe,OAAO;GAC7D,cAAc;GACd,UAAU;GACV;GACD,EAAE;EACH,GAAG,cAAc,KAAK,YAAY;GAChC,OAAO,8BAA8B,eAAe,OAAO;GAC3D,cAAc;GACd,UAAU;GACV;GACD,EAAE;EACJ,EAIC,OAAO,EAAE,OAAO,UAAU,QAAQ,mBAChC,qBAAqB,OAAO,UAAU,cAAc,QAAQ,cAAc,CAC7E"}