@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,75 +1,66 @@
1
- import {
2
- ESMxCJSRequire,
3
- getConfiguration,
4
- loadExternalFile
5
- } from "@intlayer/config";
6
- import { relative } from "path";
7
- import { processContentDeclaration } from "../buildIntlayerDictionary/processContentDeclaration.mjs";
8
- import {
9
- filterInvalidDictionaries,
10
- isInvalidDictionary
11
- } from "../filterInvalidDictionaries.mjs";
12
1
  import { parallelize } from "../utils/parallelize.mjs";
2
+ import { filterInvalidDictionaries, isInvalidDictionary } from "../filterInvalidDictionaries.mjs";
3
+ import { processContentDeclaration } from "../buildIntlayerDictionary/processContentDeclaration.mjs";
4
+ import { getIntlayerBundle } from "./getIntlayerBundle.mjs";
5
+ import { loadExternalFile, localCache } from "@intlayer/config";
6
+ import { join, relative } from "node:path";
7
+ import { writeFile } from "node:fs/promises";
8
+
9
+ //#region src/loadDictionaries/loadContentDeclaration.ts
13
10
  const formatLocalDictionaries = (dictionariesRecord, configuration) => Object.entries(dictionariesRecord).filter(([_relativePath, dict]) => isInvalidDictionary(dict, configuration)).map(([relativePath, dict]) => ({
14
- ...dict,
15
- localId: `${dict.key}::local::${relativePath}`,
16
- location: "locale",
17
- filePath: relativePath
11
+ ...dict,
12
+ localId: `${dict.key}::local::${relativePath}`,
13
+ location: "local",
14
+ filePath: relativePath
18
15
  }));
19
- const loadContentDeclarations = async (contentDeclarationFilePath, configuration = getConfiguration(), projectRequire = ESMxCJSRequire, onStatusUpdate) => {
20
- const dictionariesRecord = contentDeclarationFilePath.reduce(
21
- (acc, path) => {
22
- const relativePath = relative(configuration.content.baseDir, path);
23
- return {
24
- ...acc,
25
- [relativePath]: loadExternalFile(path, void 0, projectRequire)
26
- };
27
- },
28
- {}
29
- );
30
- const contentDeclarations = formatLocalDictionaries(
31
- dictionariesRecord,
32
- configuration
33
- );
34
- const listFoundDictionaries = contentDeclarations.map((declaration) => ({
35
- dictionaryKey: declaration.key,
36
- type: "local",
37
- status: "found"
38
- }));
39
- onStatusUpdate?.(listFoundDictionaries);
40
- const processedDictionaries = await parallelize(
41
- contentDeclarations,
42
- async (contentDeclaration) => {
43
- if (!contentDeclaration) {
44
- return void 0;
45
- }
46
- onStatusUpdate?.([
47
- {
48
- dictionaryKey: contentDeclaration.key,
49
- type: "local",
50
- status: "building"
51
- }
52
- ]);
53
- const processedContentDeclaration = await processContentDeclaration(
54
- contentDeclaration
55
- );
56
- if (!processedContentDeclaration) {
57
- return void 0;
58
- }
59
- onStatusUpdate?.([
60
- {
61
- dictionaryKey: processedContentDeclaration.key,
62
- type: "local",
63
- status: "built"
64
- }
65
- ]);
66
- return processedContentDeclaration;
67
- }
68
- );
69
- return filterInvalidDictionaries(processedDictionaries);
70
- };
71
- export {
72
- formatLocalDictionaries,
73
- loadContentDeclarations
16
+ const loadContentDeclarations = async (contentDeclarationFilePath, configuration, onStatusUpdate) => {
17
+ const { build, content } = configuration;
18
+ const { set, isValid } = localCache(configuration, ["intlayer-bundle"], { ttlMs: 1e3 * 60 * 60 * 24 * 5 });
19
+ const filePath = join(content.cacheDir, "intlayer-bundle.cjs");
20
+ if (!await isValid()) {
21
+ await writeFile(filePath, await getIntlayerBundle(configuration));
22
+ await set("ok");
23
+ }
24
+ try {
25
+ const dictionariesPromises = contentDeclarationFilePath.map(async (path) => {
26
+ return {
27
+ relativePath: relative(configuration.content.baseDir, path),
28
+ dictionary: await loadExternalFile(path, {
29
+ projectRequire: build.require,
30
+ buildOptions: { banner: { js: [`globalThis.INTLAYER_FILE_PATH = '${path}';`, `globalThis.INTLAYER_BASE_DIR = '${configuration.content.baseDir}';`].join("\n") } },
31
+ aliases: { intlayer: filePath }
32
+ })
33
+ };
34
+ });
35
+ const contentDeclarations = formatLocalDictionaries((await Promise.all(dictionariesPromises)).reduce((acc, { relativePath, dictionary }) => {
36
+ acc[relativePath] = dictionary;
37
+ return acc;
38
+ }, {}), configuration);
39
+ const listFoundDictionaries = contentDeclarations.map((declaration) => ({
40
+ dictionaryKey: declaration.key,
41
+ type: "local",
42
+ status: "found"
43
+ }));
44
+ onStatusUpdate?.(listFoundDictionaries);
45
+ return filterInvalidDictionaries(await parallelize(contentDeclarations, async (contentDeclaration) => {
46
+ if (!contentDeclaration) return;
47
+ onStatusUpdate?.([{
48
+ dictionaryKey: contentDeclaration.key,
49
+ type: "local",
50
+ status: "building"
51
+ }]);
52
+ const processedContentDeclaration = await processContentDeclaration(contentDeclaration);
53
+ if (!processedContentDeclaration) return;
54
+ onStatusUpdate?.([{
55
+ dictionaryKey: processedContentDeclaration.key,
56
+ type: "local",
57
+ status: "built"
58
+ }]);
59
+ return processedContentDeclaration;
60
+ }), configuration);
61
+ } finally {}
74
62
  };
63
+
64
+ //#endregion
65
+ export { formatLocalDictionaries, loadContentDeclarations };
75
66
  //# sourceMappingURL=loadContentDeclaration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n getConfiguration,\n IntlayerConfig,\n loadExternalFile,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'path';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport {\n filterInvalidDictionaries,\n isInvalidDictionary,\n} from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { DictionariesStatus } from './loadDictionaries';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration?: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord)\n .filter(([_relativePath, dict]) => isInvalidDictionary(dict, configuration))\n .map(([relativePath, dict]) => ({\n ...dict,\n localId: `${dict.key}::local::${relativePath}`,\n location: 'locale' as const,\n filePath: relativePath,\n }));\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const dictionariesRecord = contentDeclarationFilePath.reduce(\n (acc, path) => {\n const relativePath = relative(configuration.content.baseDir, path);\n return {\n ...acc,\n [relativePath]: loadExternalFile(path, undefined, projectRequire),\n };\n },\n {} as Record<string, Dictionary>\n );\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n );\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries);\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP,SAAS,gBAAgB;AACzB,SAAS,iCAAiC;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAGrB,MAAM,0BAA0B,CACrC,oBACA,kBAEA,OAAO,QAAQ,kBAAkB,EAC9B,OAAO,CAAC,CAAC,eAAe,IAAI,MAAM,oBAAoB,MAAM,aAAa,CAAC,EAC1E,IAAI,CAAC,CAAC,cAAc,IAAI,OAAO;AAAA,EAC9B,GAAG;AAAA,EACH,SAAS,GAAG,KAAK,GAAG,YAAY,YAAY;AAAA,EAC5C,UAAU;AAAA,EACV,UAAU;AACZ,EAAE;AAEC,MAAM,0BAA0B,OACrC,4BACA,gBAAgC,iBAAiB,GACjD,iBAAiB,gBACjB,mBAC0B;AAC1B,QAAM,qBAAqB,2BAA2B;AAAA,IACpD,CAAC,KAAK,SAAS;AACb,YAAM,eAAe,SAAS,cAAc,QAAQ,SAAS,IAAI;AACjE,aAAO;AAAA,QACL,GAAG;AAAA,QACH,CAAC,YAAY,GAAG,iBAAiB,MAAM,QAAW,cAAc;AAAA,MAClE;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACA,QAAM,sBAAoC;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,wBAAwB,oBAAoB,IAAI,CAAC,iBAAiB;AAAA,IACtE,eAAe,YAAY;AAAA,IAC3B,MAAM;AAAA,IACN,QAAQ;AAAA,EACV,EAAE;AAEF,mBAAiB,qBAAqB;AAEtC,QAAM,wBAAwB,MAAM;AAAA,IAClC;AAAA,IACA,OAAO,uBAAwD;AAC7D,UAAI,CAAC,oBAAoB;AACvB,eAAO;AAAA,MACT;AAEA,uBAAiB;AAAA,QACf;AAAA,UACE,eAAe,mBAAmB;AAAA,UAClC,MAAM;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAED,YAAM,8BAA8B,MAAM;AAAA,QACxC;AAAA,MACF;AAEA,UAAI,CAAC,6BAA6B;AAChC,eAAO;AAAA,MACT;AAEA,uBAAiB;AAAA,QACf;AAAA,UACE,eAAe,4BAA4B;AAAA,UAC3C,MAAM;AAAA,UACN,QAAQ;AAAA,QACV;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,0BAA0B,qBAAqB;AACxD;","names":[]}
1
+ {"version":3,"file":"loadContentDeclaration.mjs","names":["contentDeclarations: Dictionary[]"],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile, localCache } from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport {\n filterInvalidDictionaries,\n isInvalidDictionary,\n} from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord)\n .filter(([_relativePath, dict]) => isInvalidDictionary(dict, configuration))\n .map(([relativePath, dict]) => ({\n ...dict,\n localId: `${dict.key}::local::${relativePath}`,\n location: 'local' as const,\n filePath: relativePath,\n }));\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const { build, content } = configuration;\n\n const { set, isValid } = localCache(configuration, ['intlayer-bundle'], {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n });\n\n const filePath = join(content.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n // If cache is invalid, write the intlayer bundle to the cache\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(configuration.content.baseDir, path);\n\n const dictionary = await loadExternalFile(path, {\n projectRequire: build.require,\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.content.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: filePath,\n },\n });\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n acc[relativePath] = dictionary;\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n );\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration);\n } finally {\n // await rm(tempFilePath, { recursive: true });\n }\n};\n"],"mappings":";;;;;;;;;AAaA,MAAa,2BACX,oBACA,kBAEA,OAAO,QAAQ,mBAAmB,CAC/B,QAAQ,CAAC,eAAe,UAAU,oBAAoB,MAAM,cAAc,CAAC,CAC3E,KAAK,CAAC,cAAc,WAAW;CAC9B,GAAG;CACH,SAAS,GAAG,KAAK,IAAI,WAAW;CAChC,UAAU;CACV,UAAU;CACX,EAAE;AAEP,MAAa,0BAA0B,OACrC,4BACA,eACA,mBAC0B;CAC1B,MAAM,EAAE,OAAO,YAAY;CAE3B,MAAM,EAAE,KAAK,YAAY,WAAW,eAAe,CAAC,kBAAkB,EAAE,EACtE,OAAO,MAAO,KAAK,KAAK,KAAK,GAC9B,CAAC;CAEF,MAAM,WAAW,KAAK,QAAQ,UAAU,sBAAsB;AAI9D,KAAI,CAHsB,MAAM,SAAS,EAGjB;AAEtB,QAAM,UAAU,UADO,MAAM,kBAAkB,cAAc,CACpB;AACzC,QAAM,IAAI,KAAK;;AAGjB,KAAI;EACF,MAAM,uBAAuB,2BAA2B,IACtD,OAAO,SAAS;AAkBd,UAAO;IAAE,cAjBY,SAAS,cAAc,QAAQ,SAAS,KAAK;IAiB3C,YAfJ,MAAM,iBAAiB,MAAM;KAC9C,gBAAgB,MAAM;KACtB,cAAc,EACZ,QAAQ,EACN,IAAI,CACF,oCAAoC,KAAK,KACzC,mCAAmC,cAAc,QAAQ,QAAQ,IAClE,CAAC,KAAK,KAAK,EACb,EACF;KACD,SAAS,EACP,UAAU,UACX;KACF,CAAC;IAEiC;IAEtC;EAWD,MAAMA,sBAAoC,yBAThB,MAAM,QAAQ,IAAI,qBAAqB,EACpB,QAC1C,KAAK,EAAE,cAAc,iBAAiB;AACrC,OAAI,gBAAgB;AACpB,UAAO;KAET,EAAE,CACH,EAIC,cACD;EAED,MAAM,wBAAwB,oBAAoB,KAAK,iBAAiB;GACtE,eAAe,YAAY;GAC3B,MAAM;GACN,QAAQ;GACT,EAAE;AAEH,mBAAiB,sBAAsB;AAqCvC,SAAO,0BAnCuB,MAAM,YAClC,qBACA,OAAO,uBAAwD;AAC7D,OAAI,CAAC,mBACH;AAGF,oBAAiB,CACf;IACE,eAAe,mBAAmB;IAClC,MAAM;IACN,QAAQ;IACT,CACF,CAAC;GAEF,MAAM,8BAA8B,MAAM,0BACxC,mBACD;AAED,OAAI,CAAC,4BACH;AAGF,oBAAiB,CACf;IACE,eAAe,4BAA4B;IAC3C,MAAM;IACN,QAAQ;IACT,CACF,CAAC;AAEF,UAAO;IAEV,EAEuD,cAAc;WAC9D"}
@@ -1,160 +1,119 @@
1
- import {
2
- ANSIColors,
3
- colon,
4
- colorize,
5
- colorizeKey,
6
- ESMxCJSRequire,
7
- getAppLogger,
8
- getConfiguration
9
- } from "@intlayer/config";
10
1
  import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
11
2
  import { loadContentDeclarations } from "./loadContentDeclaration.mjs";
12
3
  import { loadRemoteDictionaries } from "./loadRemoteDictionaries.mjs";
13
4
  import { DictionariesLogger } from "./log.mjs";
5
+ import { ANSIColors, colon, colorize, colorizeKey, getAppLogger } from "@intlayer/config";
6
+
7
+ //#region src/loadDictionaries/loadDictionaries.ts
14
8
  let loadDictionariesStatus = [];
15
- const logger = new DictionariesLogger();
9
+ const logger$1 = new DictionariesLogger();
16
10
  const setLoadDictionariesStatus = (statuses) => {
17
- let updated = [...loadDictionariesStatus];
18
- for (const incoming of statuses) {
19
- const idx = updated.findIndex(
20
- (s) => s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type
21
- );
22
- if (idx >= 0) {
23
- updated[idx] = incoming;
24
- } else {
25
- updated.push(incoming);
26
- }
27
- }
28
- loadDictionariesStatus = updated;
29
- logger.update(statuses);
30
- return updated;
11
+ const updated = [...loadDictionariesStatus];
12
+ for (const incoming of statuses) {
13
+ const index = updated.findIndex((s) => s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type);
14
+ if (index >= 0) updated[index] = incoming;
15
+ else updated.push(incoming);
16
+ }
17
+ loadDictionariesStatus = updated;
18
+ logger$1.update(statuses);
19
+ return updated;
31
20
  };
32
21
  const iconFor = (status) => {
33
- switch (status) {
34
- case "built":
35
- case "imported":
36
- case "fetched":
37
- return "\u2714";
38
- case "error":
39
- return "\u2716";
40
- default:
41
- return "\u23F2";
42
- }
22
+ switch (status) {
23
+ case "built":
24
+ case "imported":
25
+ case "fetched": return "✔";
26
+ case "error": return "";
27
+ default: return "";
28
+ }
43
29
  };
44
30
  const colorFor = (status) => {
45
- switch (status) {
46
- case "built":
47
- case "imported":
48
- case "fetched":
49
- return ANSIColors.GREEN;
50
- case "error":
51
- return ANSIColors.RED;
52
- default:
53
- return ANSIColors.BLUE;
54
- }
31
+ switch (status) {
32
+ case "built":
33
+ case "imported":
34
+ case "fetched": return ANSIColors.GREEN;
35
+ case "error": return ANSIColors.RED;
36
+ default: return ANSIColors.BLUE;
37
+ }
55
38
  };
56
- const printSummary = (configuration = getConfiguration()) => {
57
- if (configuration.log.mode !== "verbose") return;
58
- const appLogger = getAppLogger(configuration);
59
- const byKey = /* @__PURE__ */ new Map();
60
- for (const s of loadDictionariesStatus) {
61
- const rec = byKey.get(s.dictionaryKey) ?? {};
62
- if (s.type === "local") rec.local = s.status;
63
- if (s.type === "remote") rec.remote = s.status;
64
- byKey.set(s.dictionaryKey, rec);
65
- }
66
- const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));
67
- let maxLocalLabelLen = 0;
68
- for (const key of keys) {
69
- const rec = byKey.get(key);
70
- if (rec.local) {
71
- const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
72
- if (visibleLocal.length > maxLocalLabelLen) {
73
- maxLocalLabelLen = visibleLocal.length;
74
- }
75
- }
76
- }
77
- for (const key of keys) {
78
- const rec = byKey.get(key);
79
- const labels = [];
80
- if (rec.local) {
81
- const inner = colorize(
82
- `${iconFor(rec.local)} ${rec.local}`,
83
- colorFor(rec.local)
84
- );
85
- const coloredLocal = `${ANSIColors.GREY}[` + colorize("local: ", ANSIColors.GREY) + inner + `${ANSIColors.GREY}]${ANSIColors.RESET}`;
86
- const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
87
- const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);
88
- labels.push(coloredLocal + " ".repeat(pad));
89
- } else {
90
- labels.push(" ".repeat(maxLocalLabelLen));
91
- }
92
- if (rec.remote) {
93
- const inner = colorize(
94
- `${iconFor(rec.remote)} ${rec.remote}`,
95
- colorFor(rec.remote)
96
- );
97
- labels.push(
98
- `${ANSIColors.GREY}[` + colorize("distant: ", ANSIColors.GREY) + inner + `${ANSIColors.GREY}]${ANSIColors.RESET}`
99
- );
100
- }
101
- appLogger(
102
- ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(" ")}`
103
- );
104
- }
39
+ const printSummary = (configuration) => {
40
+ if (configuration.log.mode !== "verbose") return;
41
+ const appLogger = getAppLogger(configuration);
42
+ const byKey = /* @__PURE__ */ new Map();
43
+ for (const s of loadDictionariesStatus) {
44
+ const rec = byKey.get(s.dictionaryKey) ?? {};
45
+ if (s.type === "local") rec.local = s.status;
46
+ if (s.type === "remote") rec.remote = s.status;
47
+ byKey.set(s.dictionaryKey, rec);
48
+ }
49
+ const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));
50
+ let maxLocalLabelLen = 0;
51
+ for (const key of keys) {
52
+ const rec = byKey.get(key);
53
+ if (rec.local) {
54
+ const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
55
+ if (visibleLocal.length > maxLocalLabelLen) maxLocalLabelLen = visibleLocal.length;
56
+ }
57
+ }
58
+ for (const key of keys) {
59
+ const rec = byKey.get(key);
60
+ const labels = [];
61
+ if (rec.local) {
62
+ const inner = colorize(`${iconFor(rec.local)} ${rec.local}`, colorFor(rec.local));
63
+ const coloredLocal = `${ANSIColors.GREY}[` + colorize("local: ", ANSIColors.GREY) + inner + `${ANSIColors.GREY}]${ANSIColors.RESET}`;
64
+ const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
65
+ const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);
66
+ labels.push(coloredLocal + " ".repeat(pad));
67
+ } else labels.push(" ".repeat(maxLocalLabelLen));
68
+ if (rec.remote) {
69
+ const inner = colorize(`${iconFor(rec.remote)} ${rec.remote}`, colorFor(rec.remote));
70
+ labels.push(`${ANSIColors.GREY}[` + colorize("distant: ", ANSIColors.GREY) + inner + `${ANSIColors.GREY}]${ANSIColors.RESET}`);
71
+ }
72
+ appLogger(` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(" ")}`);
73
+ }
105
74
  };
106
- const loadDictionaries = async (contentDeclarationsPaths, configuration = getConfiguration(), projectRequire = ESMxCJSRequire) => {
107
- const loadDictionariesStartTime = Date.now();
108
- const appLogger = getAppLogger(configuration);
109
- appLogger("Dictionaries:", { isVerbose: true });
110
- const files = Array.isArray(contentDeclarationsPaths) ? contentDeclarationsPaths : [contentDeclarationsPaths];
111
- const localDictionaries = await loadContentDeclarations(
112
- files,
113
- configuration,
114
- projectRequire,
115
- setLoadDictionariesStatus
116
- );
117
- const localDictionariesTime = Date.now();
118
- const filteredLocalDictionaries = filterInvalidDictionaries(localDictionaries);
119
- const localDictionariesStatus = filteredLocalDictionaries.map(
120
- (dict) => ({
121
- dictionaryKey: dict.key,
122
- type: "local",
123
- status: "built"
124
- })
125
- );
126
- setLoadDictionariesStatus(localDictionariesStatus);
127
- const hasRemoteDictionaries = Boolean(
128
- configuration.editor.clientId && configuration.editor.clientSecret
129
- );
130
- if (hasRemoteDictionaries) {
131
- logger.setExpectRemote(true);
132
- }
133
- let remoteDictionaries = [];
134
- if (hasRemoteDictionaries) {
135
- remoteDictionaries = await loadRemoteDictionaries(
136
- configuration,
137
- setLoadDictionariesStatus,
138
- {
139
- onStartRemoteCheck: () => logger.startRemoteCheck(),
140
- onStopRemoteCheck: () => logger.stopRemoteCheck(),
141
- onError: (e) => logger.setRemoteError(e)
142
- }
143
- );
144
- }
145
- const remoteDictionariesTime = Date.now();
146
- logger.finish();
147
- printSummary(configuration);
148
- return {
149
- localDictionaries: filteredLocalDictionaries,
150
- remoteDictionaries,
151
- time: {
152
- localDictionaries: localDictionariesTime - loadDictionariesStartTime,
153
- remoteDictionaries: remoteDictionariesTime - localDictionariesTime
154
- }
155
- };
156
- };
157
- export {
158
- loadDictionaries
75
+ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
76
+ const { plugins } = configuration;
77
+ const loadDictionariesStartTime = Date.now();
78
+ getAppLogger(configuration)("Dictionaries:", { isVerbose: true });
79
+ const loadPluginDictionariesPromise = (plugins ?? []).map(async (plugin) => {
80
+ try {
81
+ return await plugin.loadDictionaries?.({ configuration }) ?? [];
82
+ } catch {
83
+ return [];
84
+ }
85
+ });
86
+ const pluginDictionaries = (await Promise.all(loadPluginDictionariesPromise)).flat();
87
+ const localDictionaries = await loadContentDeclarations(Array.isArray(contentDeclarationsPaths) ? contentDeclarationsPaths : [contentDeclarationsPaths], configuration, setLoadDictionariesStatus);
88
+ const localDictionariesTime = Date.now();
89
+ const filteredLocalDictionaries = filterInvalidDictionaries(localDictionaries, configuration);
90
+ setLoadDictionariesStatus(filteredLocalDictionaries.map((dict) => ({
91
+ dictionaryKey: dict.key,
92
+ type: "local",
93
+ status: "built"
94
+ })));
95
+ const hasRemoteDictionaries = Boolean(configuration.editor.clientId && configuration.editor.clientSecret);
96
+ if (hasRemoteDictionaries) logger$1.setExpectRemote(true);
97
+ let remoteDictionaries = [];
98
+ if (hasRemoteDictionaries) remoteDictionaries = await loadRemoteDictionaries(configuration, setLoadDictionariesStatus, {
99
+ onStartRemoteCheck: () => logger$1.startRemoteCheck(),
100
+ onStopRemoteCheck: () => logger$1.stopRemoteCheck(),
101
+ onError: (e) => logger$1.setRemoteError(e)
102
+ });
103
+ const remoteDictionariesTime = Date.now();
104
+ logger$1.finish();
105
+ printSummary(configuration);
106
+ return {
107
+ localDictionaries: filteredLocalDictionaries,
108
+ remoteDictionaries,
109
+ pluginDictionaries,
110
+ time: {
111
+ localDictionaries: localDictionariesTime - loadDictionariesStartTime,
112
+ remoteDictionaries: remoteDictionariesTime - localDictionariesTime
113
+ }
114
+ };
159
115
  };
116
+
117
+ //#endregion
118
+ export { loadDictionaries };
160
119
  //# sourceMappingURL=loadDictionaries.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n };\n}> => {\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries =\n filterInvalidDictionaries(localDictionaries);\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n },\n };\n};\n"],"mappings":"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","names":[]}
1
+ {"version":3,"file":"loadDictionaries.mjs","names":["loadDictionariesStatus: DictionariesStatus[]","logger","updated: DictionariesStatus[]","labels: string[]","pluginDictionaries: Dictionary[]","localDictionaries: Dictionary[]","remoteDictionaries: Dictionary[]"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const loadPluginDictionariesPromise = (plugins ?? []).map(async (plugin) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n return (res as Dictionary[] | undefined) ?? [];\n } catch {\n return [];\n }\n });\n\n const pluginDictionaries: Dictionary[] = (\n await Promise.all(loadPluginDictionariesPromise)\n ).flat();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n );\n\n const localDictionariesTime = Date.now();\n\n const filteredLocalDictionaries = filterInvalidDictionaries(\n localDictionaries,\n configuration\n );\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n );\n }\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - loadDictionariesStartTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n },\n };\n};\n"],"mappings":"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"}
@@ -1,34 +1,26 @@
1
- import {
2
- ESMxCJSRequire,
3
- getConfiguration
4
- } from "@intlayer/config";
5
- import { mkdir } from "fs/promises";
6
- import { relative, resolve } from "path";
7
1
  import { loadContentDeclarations } from "./loadContentDeclaration.mjs";
8
- const loadLocalDictionaries = async (contentDeclarationsPaths, configuration = getConfiguration(), projectRequire = ESMxCJSRequire) => {
9
- const { content } = configuration;
10
- const { dictionariesDir, baseDir } = content;
11
- if (typeof contentDeclarationsPaths === "string") {
12
- contentDeclarationsPaths = [contentDeclarationsPaths];
13
- }
14
- await mkdir(resolve(dictionariesDir), { recursive: true });
15
- const result = [];
16
- for await (const contentDeclarationPath of contentDeclarationsPaths) {
17
- const dictionary = await loadContentDeclarations(
18
- [contentDeclarationPath],
19
- configuration,
20
- projectRequire
21
- );
22
- const relativeFilePath = relative(baseDir, contentDeclarationPath);
23
- const dictionaryWithPath = {
24
- ...dictionary[0],
25
- filePath: relativeFilePath
26
- };
27
- result.push(dictionaryWithPath);
28
- }
29
- return result;
30
- };
31
- export {
32
- loadLocalDictionaries
2
+ import { relative, resolve } from "node:path";
3
+ import { mkdir } from "node:fs/promises";
4
+
5
+ //#region src/loadDictionaries/loadLocalDictionaries.ts
6
+ const loadLocalDictionaries = async (contentDeclarationsPaths, configuration) => {
7
+ const { content } = configuration;
8
+ const { dictionariesDir, baseDir } = content;
9
+ if (typeof contentDeclarationsPaths === "string") contentDeclarationsPaths = [contentDeclarationsPaths];
10
+ await mkdir(resolve(dictionariesDir), { recursive: true });
11
+ const result = [];
12
+ for await (const contentDeclarationPath of contentDeclarationsPaths) {
13
+ const dictionary = await loadContentDeclarations([contentDeclarationPath], configuration);
14
+ const relativeFilePath = relative(baseDir, contentDeclarationPath);
15
+ const dictionaryWithPath = {
16
+ ...dictionary[0],
17
+ filePath: relativeFilePath
18
+ };
19
+ result.push(dictionaryWithPath);
20
+ }
21
+ return result;
33
22
  };
23
+
24
+ //#endregion
25
+ export { loadLocalDictionaries };
34
26
  //# sourceMappingURL=loadLocalDictionaries.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import {\n ESMxCJSRequire,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir } from 'fs/promises';\nimport { relative, resolve } from 'path';\nimport { loadContentDeclarations } from './loadContentDeclaration';\n\nexport const loadLocalDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<Dictionary[]> => {\n const { content } = configuration;\n const { dictionariesDir, baseDir } = content;\n\n if (typeof contentDeclarationsPaths === 'string') {\n contentDeclarationsPaths = [contentDeclarationsPaths];\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const result: Dictionary[] = [];\n\n for await (const contentDeclarationPath of contentDeclarationsPaths) {\n const dictionary = await loadContentDeclarations(\n [contentDeclarationPath],\n configuration,\n projectRequire\n );\n\n const relativeFilePath = relative(baseDir, contentDeclarationPath);\n\n const dictionaryWithPath: Dictionary = {\n ...dictionary[0],\n filePath: relativeFilePath,\n };\n\n result.push(dictionaryWithPath);\n }\n\n return result;\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,aAAa;AACtB,SAAS,UAAU,eAAe;AAClC,SAAS,+BAA+B;AAEjC,MAAM,wBAAwB,OACnC,0BACA,gBAAgC,iBAAiB,GACjD,iBAAiB,mBACS;AAC1B,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,EAAE,iBAAiB,QAAQ,IAAI;AAErC,MAAI,OAAO,6BAA6B,UAAU;AAChD,+BAA2B,CAAC,wBAAwB;AAAA,EACtD;AAGA,QAAM,MAAM,QAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;AAEzD,QAAM,SAAuB,CAAC;AAE9B,mBAAiB,0BAA0B,0BAA0B;AACnE,UAAM,aAAa,MAAM;AAAA,MACvB,CAAC,sBAAsB;AAAA,MACvB;AAAA,MACA;AAAA,IACF;AAEA,UAAM,mBAAmB,SAAS,SAAS,sBAAsB;AAEjE,UAAM,qBAAiC;AAAA,MACrC,GAAG,WAAW,CAAC;AAAA,MACf,UAAU;AAAA,IACZ;AAEA,WAAO,KAAK,kBAAkB;AAAA,EAChC;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"loadLocalDictionaries.mjs","names":["result: Dictionary[]","dictionaryWithPath: Dictionary"],"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { loadContentDeclarations } from './loadContentDeclaration';\n\nexport const loadLocalDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<Dictionary[]> => {\n const { content } = configuration;\n const { dictionariesDir, baseDir } = content;\n\n if (typeof contentDeclarationsPaths === 'string') {\n contentDeclarationsPaths = [contentDeclarationsPaths];\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const result: Dictionary[] = [];\n\n for await (const contentDeclarationPath of contentDeclarationsPaths) {\n const dictionary = await loadContentDeclarations(\n [contentDeclarationPath],\n configuration\n );\n\n const relativeFilePath = relative(baseDir, contentDeclarationPath);\n\n const dictionaryWithPath: Dictionary = {\n ...dictionary[0],\n filePath: relativeFilePath,\n };\n\n result.push(dictionaryWithPath);\n }\n\n return result;\n};\n"],"mappings":";;;;;AAKA,MAAa,wBAAwB,OACnC,0BACA,kBAC0B;CAC1B,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,iBAAiB,YAAY;AAErC,KAAI,OAAO,6BAA6B,SACtC,4BAA2B,CAAC,yBAAyB;AAIvD,OAAM,MAAM,QAAQ,gBAAgB,EAAE,EAAE,WAAW,MAAM,CAAC;CAE1D,MAAMA,SAAuB,EAAE;AAE/B,YAAW,MAAM,0BAA0B,0BAA0B;EACnE,MAAM,aAAa,MAAM,wBACvB,CAAC,uBAAuB,EACxB,cACD;EAED,MAAM,mBAAmB,SAAS,SAAS,uBAAuB;EAElE,MAAMC,qBAAiC;GACrC,GAAG,WAAW;GACd,UAAU;GACX;AAED,SAAO,KAAK,mBAAmB;;AAGjC,QAAO"}