@intlayer/chokidar 8.1.2 → 8.1.3

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 (396) hide show
  1. package/dist/assets/installSkills/skills/angular.md +3 -0
  2. package/dist/assets/installSkills/skills/astro.md +3 -0
  3. package/dist/assets/installSkills/skills/cli.md +7 -4
  4. package/dist/assets/installSkills/skills/config.md +3 -0
  5. package/dist/assets/installSkills/skills/content.md +3 -0
  6. package/dist/assets/installSkills/skills/next_js.md +3 -0
  7. package/dist/assets/installSkills/skills/preact.md +3 -2
  8. package/dist/assets/installSkills/skills/react.md +3 -0
  9. package/dist/assets/installSkills/skills/solid.md +3 -0
  10. package/dist/assets/installSkills/skills/svelte.md +3 -0
  11. package/dist/assets/installSkills/skills/usage.md +2 -0
  12. package/dist/assets/installSkills/skills/vue.md +3 -0
  13. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  14. package/dist/cjs/_virtual/_utils_asset.cjs +2 -98
  15. package/dist/cjs/build.cjs +1 -51
  16. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +1 -53
  17. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  18. package/dist/cjs/buildIntlayerDictionary/index.cjs +1 -6
  19. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +1 -26
  20. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  21. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +4 -78
  22. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  23. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +4 -62
  24. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  25. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -46
  26. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  27. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +1 -50
  28. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  29. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +1 -59
  30. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  31. package/dist/cjs/cleanOutputDir.cjs +1 -30
  32. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  33. package/dist/cjs/cleanRemovedContentDeclaration.cjs +1 -96
  34. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  35. package/dist/cjs/cli.cjs +1 -21
  36. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -70
  37. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  38. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +7 -41
  39. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  40. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +1 -23
  41. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  42. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +1 -24
  43. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  44. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +1 -24
  45. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  46. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +1 -23
  47. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  48. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +1 -23
  49. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  50. package/dist/cjs/createDictionaryEntryPoint/index.cjs +1 -16
  51. package/dist/cjs/createType/createModuleAugmentation.cjs +9 -110
  52. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  53. package/dist/cjs/createType/createType.cjs +1 -29
  54. package/dist/cjs/createType/createType.cjs.map +1 -1
  55. package/dist/cjs/createType/index.cjs +1 -8
  56. package/dist/cjs/fetchDistantDictionaries.cjs +1 -50
  57. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  58. package/dist/cjs/filterInvalidDictionaries.cjs +1 -49
  59. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  60. package/dist/cjs/formatDictionary.cjs +1 -49
  61. package/dist/cjs/formatDictionary.cjs.map +1 -1
  62. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +1 -39
  63. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  64. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +1 -34
  65. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  66. package/dist/cjs/handleContentDeclarationFileChange.cjs +1 -49
  67. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  68. package/dist/cjs/handleContentDeclarationFileMoved.cjs +1 -24
  69. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
  70. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +1 -37
  71. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  72. package/dist/cjs/index.cjs +1 -131
  73. package/dist/cjs/init/index.cjs +1 -242
  74. package/dist/cjs/init/index.cjs.map +1 -1
  75. package/dist/cjs/init/utils/configManipulation.cjs +1 -164
  76. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  77. package/dist/cjs/init/utils/fileSystem.cjs +1 -30
  78. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  79. package/dist/cjs/init/utils/index.cjs +1 -13
  80. package/dist/cjs/init/utils/jsonParser.cjs +3 -42
  81. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
  82. package/dist/cjs/init/utils/tsConfig.cjs +1 -18
  83. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
  84. package/dist/cjs/initConfig/index.cjs +1 -38
  85. package/dist/cjs/initConfig/index.cjs.map +1 -1
  86. package/dist/cjs/installSkills/index.cjs +1 -172
  87. package/dist/cjs/installSkills/index.cjs.map +1 -1
  88. package/dist/cjs/listDictionariesPath.cjs +1 -41
  89. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  90. package/dist/cjs/listGitFiles.cjs +5 -95
  91. package/dist/cjs/listGitFiles.cjs.map +1 -1
  92. package/dist/cjs/listProjects.cjs +1 -47
  93. package/dist/cjs/listProjects.cjs.map +1 -1
  94. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -66
  95. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
  96. package/dist/cjs/loadDictionaries/index.cjs +1 -12
  97. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -72
  98. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  99. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -125
  100. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  101. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +1 -28
  102. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  103. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +1 -61
  104. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  105. package/dist/cjs/loadDictionaries/log.cjs +3 -135
  106. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  107. package/dist/cjs/prepareIntlayer.cjs +1 -95
  108. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  109. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +1 -30
  110. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  111. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +1 -12
  112. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  113. package/dist/cjs/transformFiles/extractDictionaryKey.cjs +1 -16
  114. package/dist/cjs/transformFiles/extractDictionaryKey.cjs.map +1 -1
  115. package/dist/cjs/transformFiles/index.cjs +1 -10
  116. package/dist/cjs/transformFiles/transformFiles.cjs +1 -251
  117. package/dist/cjs/transformFiles/transformFiles.cjs.map +1 -1
  118. package/dist/cjs/utils/autoDecorateContent.cjs +1 -87
  119. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
  120. package/dist/cjs/utils/buildFilesList.cjs +1 -50
  121. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  122. package/dist/cjs/utils/chunkJSON.cjs +1 -336
  123. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  124. package/dist/cjs/utils/formatter.cjs +1 -16
  125. package/dist/cjs/utils/formatter.cjs.map +1 -1
  126. package/dist/cjs/utils/getChunk.cjs +1 -34
  127. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  128. package/dist/cjs/utils/getComponentTransformPattern.cjs +1 -48
  129. package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
  130. package/dist/cjs/utils/getFileHash.cjs +1 -12
  131. package/dist/cjs/utils/getFileHash.cjs.map +1 -1
  132. package/dist/cjs/utils/getFormatFromExtension.cjs +1 -31
  133. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  134. package/dist/cjs/utils/index.cjs +1 -46
  135. package/dist/cjs/utils/pLimit.cjs +1 -128
  136. package/dist/cjs/utils/pLimit.cjs.map +1 -1
  137. package/dist/cjs/utils/parallelize.cjs +1 -11
  138. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  139. package/dist/cjs/utils/parallelizeGlobal.cjs +1 -29
  140. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
  141. package/dist/cjs/utils/reduceObjectFormat.cjs +1 -31
  142. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
  143. package/dist/cjs/utils/resolveObjectPromises.cjs +1 -21
  144. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  145. package/dist/cjs/utils/runOnce.cjs +1 -95
  146. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  147. package/dist/cjs/utils/runParallel/bin.cjs +1 -54
  148. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
  149. package/dist/cjs/utils/runParallel/bootstrap.cjs +1 -24
  150. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
  151. package/dist/cjs/utils/runParallel/index.cjs +1 -110
  152. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  153. package/dist/cjs/utils/runParallel/pidTree.cjs +1 -145
  154. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  155. package/dist/cjs/utils/runParallel/ps.cjs +1 -49
  156. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  157. package/dist/cjs/utils/runParallel/runTask.cjs +1 -154
  158. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  159. package/dist/cjs/utils/runParallel/spawnPosix.cjs +1 -59
  160. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
  161. package/dist/cjs/utils/runParallel/spawnWin32.cjs +1 -43
  162. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
  163. package/dist/cjs/utils/runParallel/wmic.cjs +1 -52
  164. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  165. package/dist/cjs/utils/sortAlphabetically.cjs +1 -7
  166. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  167. package/dist/cjs/utils/splitTextByLine.cjs +1 -11
  168. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
  169. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +1 -60
  170. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
  171. package/dist/cjs/watcher.cjs +1 -95
  172. package/dist/cjs/watcher.cjs.map +1 -1
  173. package/dist/cjs/writeConfiguration/index.cjs +1 -34
  174. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  175. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +1 -28
  176. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  177. package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs +1 -31
  178. package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs.map +1 -1
  179. package/dist/cjs/writeContentDeclaration/index.cjs +1 -12
  180. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +1 -93
  181. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  182. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +2 -1775
  183. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  184. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +1 -77
  185. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
  186. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -123
  187. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  188. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +1 -71
  189. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  190. package/dist/cjs/writeFileIfChanged.cjs +1 -12
  191. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  192. package/dist/cjs/writeJsonIfChanged.cjs +1 -17
  193. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  194. package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -8
  195. package/dist/esm/_virtual/_utils_asset.mjs +2 -97
  196. package/dist/esm/build.mjs +1 -24
  197. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +1 -51
  198. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  199. package/dist/esm/buildIntlayerDictionary/index.mjs +1 -4
  200. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +1 -24
  201. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
  202. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +4 -75
  203. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  204. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +4 -59
  205. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  206. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +1 -44
  207. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  208. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +1 -48
  209. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  210. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +1 -56
  211. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  212. package/dist/esm/cleanOutputDir.mjs +1 -28
  213. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  214. package/dist/esm/cleanRemovedContentDeclaration.mjs +1 -93
  215. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
  216. package/dist/esm/cli.mjs +1 -8
  217. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -68
  218. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  219. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +7 -39
  220. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
  221. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +1 -20
  222. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  223. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +1 -21
  224. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  225. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +1 -21
  226. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  227. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +1 -20
  228. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  229. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +1 -20
  230. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  231. package/dist/esm/createDictionaryEntryPoint/index.mjs +1 -9
  232. package/dist/esm/createType/createModuleAugmentation.mjs +9 -106
  233. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  234. package/dist/esm/createType/createType.mjs +1 -26
  235. package/dist/esm/createType/createType.mjs.map +1 -1
  236. package/dist/esm/createType/index.mjs +1 -4
  237. package/dist/esm/fetchDistantDictionaries.mjs +1 -48
  238. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  239. package/dist/esm/filterInvalidDictionaries.mjs +1 -46
  240. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
  241. package/dist/esm/formatDictionary.mjs +1 -44
  242. package/dist/esm/formatDictionary.mjs.map +1 -1
  243. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +1 -37
  244. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  245. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +1 -32
  246. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  247. package/dist/esm/handleContentDeclarationFileChange.mjs +1 -47
  248. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  249. package/dist/esm/handleContentDeclarationFileMoved.mjs +1 -22
  250. package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
  251. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +1 -35
  252. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  253. package/dist/esm/index.mjs +1 -57
  254. package/dist/esm/init/index.mjs +1 -240
  255. package/dist/esm/init/index.mjs.map +1 -1
  256. package/dist/esm/init/utils/configManipulation.mjs +1 -161
  257. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  258. package/dist/esm/init/utils/fileSystem.mjs +1 -26
  259. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  260. package/dist/esm/init/utils/index.mjs +1 -6
  261. package/dist/esm/init/utils/jsonParser.mjs +3 -40
  262. package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
  263. package/dist/esm/init/utils/tsConfig.mjs +1 -16
  264. package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
  265. package/dist/esm/initConfig/index.mjs +1 -36
  266. package/dist/esm/initConfig/index.mjs.map +1 -1
  267. package/dist/esm/installSkills/index.mjs +1 -167
  268. package/dist/esm/installSkills/index.mjs.map +1 -1
  269. package/dist/esm/listDictionariesPath.mjs +1 -37
  270. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  271. package/dist/esm/listGitFiles.mjs +5 -90
  272. package/dist/esm/listGitFiles.mjs.map +1 -1
  273. package/dist/esm/listProjects.mjs +1 -43
  274. package/dist/esm/listProjects.mjs.map +1 -1
  275. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -65
  276. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
  277. package/dist/esm/loadDictionaries/index.mjs +1 -6
  278. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +2 -69
  279. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  280. package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -123
  281. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  282. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +1 -26
  283. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  284. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +1 -58
  285. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  286. package/dist/esm/loadDictionaries/log.mjs +3 -132
  287. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  288. package/dist/esm/prepareIntlayer.mjs +1 -92
  289. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  290. package/dist/esm/reduceDictionaryContent/applyMask.mjs +1 -28
  291. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  292. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +1 -10
  293. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  294. package/dist/esm/transformFiles/extractDictionaryKey.mjs +1 -14
  295. package/dist/esm/transformFiles/extractDictionaryKey.mjs.map +1 -1
  296. package/dist/esm/transformFiles/index.mjs +1 -4
  297. package/dist/esm/transformFiles/transformFiles.mjs +1 -244
  298. package/dist/esm/transformFiles/transformFiles.mjs.map +1 -1
  299. package/dist/esm/utils/autoDecorateContent.mjs +1 -85
  300. package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
  301. package/dist/esm/utils/buildFilesList.mjs +1 -47
  302. package/dist/esm/utils/buildFilesList.mjs.map +1 -1
  303. package/dist/esm/utils/chunkJSON.mjs +1 -333
  304. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  305. package/dist/esm/utils/formatter.mjs +1 -12
  306. package/dist/esm/utils/formatter.mjs.map +1 -1
  307. package/dist/esm/utils/getChunk.mjs +1 -33
  308. package/dist/esm/utils/getChunk.mjs.map +1 -1
  309. package/dist/esm/utils/getComponentTransformPattern.mjs +1 -44
  310. package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
  311. package/dist/esm/utils/getFileHash.mjs +1 -9
  312. package/dist/esm/utils/getFileHash.mjs.map +1 -1
  313. package/dist/esm/utils/getFormatFromExtension.mjs +1 -28
  314. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  315. package/dist/esm/utils/index.mjs +1 -20
  316. package/dist/esm/utils/pLimit.mjs +1 -125
  317. package/dist/esm/utils/pLimit.mjs.map +1 -1
  318. package/dist/esm/utils/parallelize.mjs +1 -10
  319. package/dist/esm/utils/parallelize.mjs.map +1 -1
  320. package/dist/esm/utils/parallelizeGlobal.mjs +1 -26
  321. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
  322. package/dist/esm/utils/reduceObjectFormat.mjs +1 -29
  323. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
  324. package/dist/esm/utils/resolveObjectPromises.mjs +1 -19
  325. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
  326. package/dist/esm/utils/runOnce.mjs +1 -92
  327. package/dist/esm/utils/runOnce.mjs.map +1 -1
  328. package/dist/esm/utils/runParallel/bin.mjs +1 -52
  329. package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
  330. package/dist/esm/utils/runParallel/bootstrap.mjs +1 -22
  331. package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
  332. package/dist/esm/utils/runParallel/index.mjs +1 -108
  333. package/dist/esm/utils/runParallel/index.mjs.map +1 -1
  334. package/dist/esm/utils/runParallel/pidTree.mjs +1 -142
  335. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  336. package/dist/esm/utils/runParallel/ps.mjs +1 -46
  337. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  338. package/dist/esm/utils/runParallel/runTask.mjs +1 -152
  339. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
  340. package/dist/esm/utils/runParallel/spawnPosix.mjs +1 -57
  341. package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
  342. package/dist/esm/utils/runParallel/spawnWin32.mjs +1 -41
  343. package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
  344. package/dist/esm/utils/runParallel/wmic.mjs +1 -49
  345. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  346. package/dist/esm/utils/sortAlphabetically.mjs +1 -5
  347. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
  348. package/dist/esm/utils/splitTextByLine.mjs +1 -9
  349. package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
  350. package/dist/esm/utils/verifyIdenticObjectFormat.mjs +1 -58
  351. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
  352. package/dist/esm/watcher.mjs +1 -92
  353. package/dist/esm/watcher.mjs.map +1 -1
  354. package/dist/esm/writeConfiguration/index.mjs +1 -31
  355. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  356. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +1 -26
  357. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  358. package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs +1 -29
  359. package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs.map +1 -1
  360. package/dist/esm/writeContentDeclaration/index.mjs +1 -7
  361. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +1 -91
  362. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
  363. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +2 -1773
  364. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  365. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +1 -75
  366. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
  367. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -121
  368. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  369. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +1 -69
  370. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  371. package/dist/esm/writeFileIfChanged.mjs +1 -10
  372. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  373. package/dist/esm/writeJsonIfChanged.mjs +1 -16
  374. package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
  375. package/dist/types/build.d.ts +3 -1
  376. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  377. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  378. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  379. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  380. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  381. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
  382. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  383. package/dist/types/index.d.ts +16 -24
  384. package/dist/types/initConfig/index.d.ts +1 -1
  385. package/dist/types/initConfig/index.d.ts.map +1 -1
  386. package/dist/types/listGitFiles.d.ts.map +1 -1
  387. package/dist/types/loadDictionaries/getIntlayerBundle.d.ts.map +1 -1
  388. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
  389. package/dist/types/prepareIntlayer.d.ts.map +1 -1
  390. package/dist/types/transformFiles/transformFiles.d.ts +1 -1
  391. package/dist/types/transformFiles/transformFiles.d.ts.map +1 -1
  392. package/dist/types/utils/formatter.d.ts +1 -1
  393. package/dist/types/watcher.d.ts +1 -1
  394. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
  395. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
  396. package/package.json +10 -15
@@ -1,21 +1,2 @@
1
- import { normalizePath } from "@intlayer/config";
2
- import { basename } from "node:path";
3
- import { existsSync, mkdirSync } from "node:fs";
4
- import fg from "fast-glob";
5
-
6
- //#region src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts
7
- /**
8
- * This function generates a list of dictionaries in the main directory
9
- */
10
- const getBuiltRemoteDictionariesPath = async (configuration, excludeKeys = []) => {
11
- const { remoteDictionariesDir, mainDir } = configuration.system;
12
- if (!existsSync(mainDir)) mkdirSync(mainDir, { recursive: true });
13
- return fg.sync(`${normalizePath(remoteDictionariesDir)}/**/*.json`).filter((path) => {
14
- const key = basename(path, ".json");
15
- return !excludeKeys.includes(key);
16
- });
17
- };
18
-
19
- //#endregion
20
- export { getBuiltRemoteDictionariesPath };
1
+ import{basename as e}from"node:path";import{normalizePath as t}from"@intlayer/config/utils";import{existsSync as n,mkdirSync as r}from"node:fs";import i from"fast-glob";const a=async(a,o=[])=>{let{remoteDictionariesDir:s,mainDir:c}=a.system;return n(c)||r(c,{recursive:!0}),i.sync(`${t(s)}/**/*.json`).filter(t=>{let n=e(t,`.json`);return!o.includes(n)})};export{a as getBuiltRemoteDictionariesPath};
21
2
  //# sourceMappingURL=getBuiltRemoteDictionariesPath.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltRemoteDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltRemoteDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { remoteDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = fg.sync(\n `${normalizePath(remoteDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,iCAAiC,OAC5C,eACA,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,uBAAuB,YAAY,cAAc;AAGzD,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,QAJmC,GAAG,KACpC,GAAG,cAAc,sBAAsB,CAAC,YACzC,CAEuB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,QAAQ;AACnC,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
1
+ {"version":3,"file":"getBuiltRemoteDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltRemoteDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { remoteDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = fg.sync(\n `${normalizePath(remoteDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":"yKASA,MAAa,EAAiC,MAC5C,EACA,EAAwB,EAAE,GACvB,CACH,GAAM,CAAE,wBAAuB,WAAY,EAAc,OAWzD,OARK,EAAW,EAAQ,EACtB,EAAU,EAAS,CAAE,UAAW,GAAM,CAAC,CAGN,EAAG,KACpC,GAAG,EAAc,EAAsB,CAAC,YACzC,CAEuB,OAAQ,GAAS,CACvC,IAAM,EAAM,EAAS,EAAM,QAAQ,CACnC,MAAO,CAAC,EAAY,SAAS,EAAI,EACjC"}
@@ -1,21 +1,2 @@
1
- import { normalizePath } from "@intlayer/config";
2
- import { basename } from "node:path";
3
- import { existsSync, mkdirSync } from "node:fs";
4
- import fg from "fast-glob";
5
-
6
- //#region src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.ts
7
- /**
8
- * This function generates a list of dictionaries in the main directory
9
- */
10
- const getBuiltUnmergedDictionariesPath = async (configuration, excludeKeys = []) => {
11
- const { unmergedDictionariesDir, mainDir } = configuration.system;
12
- if (!existsSync(mainDir)) mkdirSync(mainDir, { recursive: true });
13
- return (await fg(`${normalizePath(unmergedDictionariesDir)}/**/*.json`)).filter((path) => {
14
- const key = basename(path, ".json");
15
- return !excludeKeys.includes(key);
16
- });
17
- };
18
-
19
- //#endregion
20
- export { getBuiltUnmergedDictionariesPath };
1
+ import{basename as e}from"node:path";import{normalizePath as t}from"@intlayer/config/utils";import{existsSync as n,mkdirSync as r}from"node:fs";import i from"fast-glob";const a=async(a,o=[])=>{let{unmergedDictionariesDir:s,mainDir:c}=a.system;return n(c)||r(c,{recursive:!0}),(await i(`${t(s)}/**/*.json`)).filter(t=>{let n=e(t,`.json`);return!o.includes(n)})};export{a as getBuiltUnmergedDictionariesPath};
21
2
  //# sourceMappingURL=getBuiltUnmergedDictionariesPath.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getBuiltUnmergedDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltUnmergedDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { unmergedDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(unmergedDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,mCAAmC,OAC9C,eACA,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,yBAAyB,YAAY,cAAc;AAG3D,KAAI,CAAC,WAAW,QAAQ,CACtB,WAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAOzC,SAJmC,MAAM,GACvC,GAAG,cAAc,wBAAwB,CAAC,YAC3C,EAEuB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,QAAQ;AACnC,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}
1
+ {"version":3,"file":"getBuiltUnmergedDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.ts"],"sourcesContent":["import { existsSync, mkdirSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltUnmergedDictionariesPath = async (\n configuration: IntlayerConfig,\n excludeKeys: string[] = []\n) => {\n const { unmergedDictionariesDir, mainDir } = configuration.system;\n\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionariesPath: string[] = await fg(\n `${normalizePath(unmergedDictionariesDir)}/**/*.json`\n );\n\n return dictionariesPath.filter((path) => {\n const key = basename(path, '.json');\n return !excludeKeys.includes(key);\n });\n};\n"],"mappings":"yKASA,MAAa,EAAmC,MAC9C,EACA,EAAwB,EAAE,GACvB,CACH,GAAM,CAAE,0BAAyB,WAAY,EAAc,OAW3D,OARK,EAAW,EAAQ,EACtB,EAAU,EAAS,CAAE,UAAW,GAAM,CAAC,EAGN,MAAM,EACvC,GAAG,EAAc,EAAwB,CAAC,YAC3C,EAEuB,OAAQ,GAAS,CACvC,IAAM,EAAM,EAAS,EAAM,QAAQ,CACnC,MAAO,CAAC,EAAY,SAAS,EAAI,EACjC"}
@@ -1,9 +1 @@
1
- import { generateDictionaryListContent } from "./generateDictionaryListContent.mjs";
2
- import { getBuiltDictionariesPath } from "./getBuiltDictionariesPath.mjs";
3
- import { getBuiltDynamicDictionariesPath } from "./getBuiltDynamicDictionariesPath.mjs";
4
- import { getBuiltFetchDictionariesPath } from "./getBuiltFetchDictionariesPath.mjs";
5
- import { getBuiltRemoteDictionariesPath } from "./getBuiltRemoteDictionariesPath.mjs";
6
- import { getBuiltUnmergedDictionariesPath } from "./getBuiltUnmergedDictionariesPath.mjs";
7
- import { createDictionaryEntryPoint } from "./createDictionaryEntryPoint.mjs";
8
-
9
- export { createDictionaryEntryPoint, generateDictionaryListContent, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath };
1
+ import{generateDictionaryListContent as e}from"./generateDictionaryListContent.mjs";import{getBuiltDictionariesPath as t}from"./getBuiltDictionariesPath.mjs";import{getBuiltDynamicDictionariesPath as n}from"./getBuiltDynamicDictionariesPath.mjs";import{getBuiltFetchDictionariesPath as r}from"./getBuiltFetchDictionariesPath.mjs";import{getBuiltRemoteDictionariesPath as i}from"./getBuiltRemoteDictionariesPath.mjs";import{getBuiltUnmergedDictionariesPath as a}from"./getBuiltUnmergedDictionariesPath.mjs";import{createDictionaryEntryPoint as o}from"./createDictionaryEntryPoint.mjs";export{o as createDictionaryEntryPoint,e as generateDictionaryListContent,t as getBuiltDictionariesPath,n as getBuiltDynamicDictionariesPath,r as getBuiltFetchDictionariesPath,i as getBuiltRemoteDictionariesPath,a as getBuiltUnmergedDictionariesPath};
@@ -1,107 +1,10 @@
1
- import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
2
- import { getFileHash } from "../utils/getFileHash.mjs";
3
- import { kebabCaseToCamelCase, normalizePath } from "@intlayer/config";
4
- import { mkdir } from "node:fs/promises";
5
- import { basename, extname, join, relative } from "node:path";
6
- import fg from "fast-glob";
7
- import { printNode, zodToTs } from "zod-to-ts";
8
-
9
- //#region src/createType/createModuleAugmentation.ts
10
- const getTypeName = (key) => `${kebabCaseToCamelCase(key)}Content`;
11
- /** Returns lines like: [Locales.FRENCH]: 1; */
12
- const formatLocales = (locales) => locales.map((locale) => ` "${locale}": 1;`).join("\n");
13
- const zodToTsString = (schema) => {
14
- if (!schema) return "any";
15
- const def = schema._def ?? schema.def ?? schema;
16
- switch (def.typeName ?? def.type) {
17
- case "ZodString":
18
- case "string": return "string";
19
- case "ZodNumber":
20
- case "number": return "number";
21
- case "ZodBoolean":
22
- case "boolean": return "boolean";
23
- case "ZodNull":
24
- case "null": return "null";
25
- case "ZodUndefined":
26
- case "undefined": return "undefined";
27
- case "ZodArray":
28
- case "array": return `${zodToTsString(def.type ?? def.element)}[]`;
29
- case "ZodObject":
30
- case "object": {
31
- const shape = typeof def.shape === "function" ? def.shape() : def.shape;
32
- if (!shape) return "Record<string, any>";
33
- return `{\n${Object.entries(shape).map(([k, v]) => ` "${k}": ${zodToTsString(v)};`).join("\n")}\n }`;
34
- }
35
- case "ZodOptional":
36
- case "optional": return `${zodToTsString(def.innerType ?? def.wrapped)} | undefined`;
37
- case "ZodNullable":
38
- case "nullable": return `${zodToTsString(def.innerType ?? def.wrapped)} | null`;
39
- case "ZodUnion":
40
- case "union": return (def.options ?? []).map(zodToTsString).join(" | ");
41
- case "ZodIntersection":
42
- case "intersection": return `${zodToTsString(def.left)} & ${zodToTsString(def.right)}`;
43
- case "ZodEnum":
44
- case "enum": return (def.values ?? []).map((v) => `"${v}"`).join(" | ");
45
- case "ZodLiteral":
46
- case "literal": {
47
- const value = def.value;
48
- return typeof value === "string" ? `"${value}"` : String(value);
49
- }
50
- default: return "any";
51
- }
52
- };
53
- /** Generate the content of the module augmentation file */
54
- const generateTypeIndexContent = (typeFiles, configuration) => {
55
- const { internationalization, system } = configuration;
56
- const { moduleAugmentationDir } = system;
57
- const { locales, requiredLocales, strictMode } = internationalization;
58
- let fileContent = "import \"intlayer\";\n";
59
- const dictionariesRef = typeFiles.map((dictionaryPath) => ({
60
- relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,
61
- id: basename(dictionaryPath, extname(dictionaryPath)),
62
- hash: `_${getFileHash(dictionaryPath)}`
63
- }));
64
- for (const dictionary of dictionariesRef) fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\n`;
65
- fileContent += "\n";
66
- const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": typeof ${dictionary.hash};`).join("\n");
67
- const declared = locales;
68
- const requiredSanitized = requiredLocales?.length ? requiredLocales.filter((requiredLocales) => declared.includes(requiredLocales)) : declared;
69
- const formattedDeclaredLocales = formatLocales(declared);
70
- const formattedRequiredLocales = formatLocales(requiredSanitized);
71
- const schemas = configuration.schemas ?? {};
72
- const formattedSchemas = Object.entries(schemas).map(([key, schema]) => {
73
- let typeStr = "any";
74
- if (schema) try {
75
- const { node } = zodToTs(schema, key);
76
- if (node.kind !== 133) typeStr = printNode(node);
77
- else typeStr = zodToTsString(schema);
78
- } catch (_e) {
79
- typeStr = zodToTsString(schema);
80
- }
81
- return ` "${key}": ${typeStr};`;
82
- }).join("\n");
83
- const strictKey = strictMode === "strict" ? "strict" : strictMode === "inclusive" ? "inclusive" : "loose";
84
- /**
85
- * Module augmentation that ONLY adds keys to registries.
86
- * No types/aliases redefined here—avoids merge conflicts.
87
- */
88
- fileContent += `declare module 'intlayer' {\n`;
89
- fileContent += ` interface __DictionaryRegistry {\n${formattedDictionaryMap}\n }\n\n`;
90
- fileContent += ` interface __DeclaredLocalesRegistry {\n${formattedDeclaredLocales}\n }\n\n`;
91
- fileContent += ` interface __RequiredLocalesRegistry {\n${formattedRequiredLocales}\n }\n\n`;
92
- fileContent += ` interface __SchemaRegistry {\n${formattedSchemas}\n }\n\n`;
93
- fileContent += ` interface __StrictModeRegistry { mode: '${strictKey}' }\n`;
94
- fileContent += `}\n`;
95
- return fileContent;
96
- };
97
- /** Generate the index file merging all the types */
98
- const createModuleAugmentation = async (configuration) => {
99
- const { moduleAugmentationDir, typesDir } = configuration.system;
100
- await mkdir(moduleAugmentationDir, { recursive: true });
101
- const tsContent = generateTypeIndexContent(await fg(normalizePath(`${typesDir}/*.ts`), { ignore: ["**/*.d.ts"] }), configuration);
102
- await writeFileIfChanged(join(moduleAugmentationDir, "intlayer.d.ts"), tsContent);
103
- };
104
-
105
- //#endregion
106
- export { createModuleAugmentation, getTypeName };
1
+ import{writeFileIfChanged as e}from"../writeFileIfChanged.mjs";import{getFileHash as t}from"../utils/getFileHash.mjs";import{mkdir as n}from"node:fs/promises";import{basename as r,extname as i,join as a,relative as o}from"node:path";import{kebabCaseToCamelCase as s,normalizePath as c}from"@intlayer/config/utils";import l from"fast-glob";import{printNode as u,zodToTs as d}from"zod-to-ts";const f=e=>`${s(e)}Content`,p=e=>e.map(e=>` "${e}": 1;`).join(`
2
+ `),m=e=>{if(!e)return`any`;let t=e._def??e.def??e;switch(t.typeName??t.type){case`ZodString`:case`string`:return`string`;case`ZodNumber`:case`number`:return`number`;case`ZodBoolean`:case`boolean`:return`boolean`;case`ZodNull`:case`null`:return`null`;case`ZodUndefined`:case`undefined`:return`undefined`;case`ZodArray`:case`array`:return`${m(t.type??t.element)}[]`;case`ZodObject`:case`object`:{let e=typeof t.shape==`function`?t.shape():t.shape;return e?`{\n${Object.entries(e).map(([e,t])=>` "${e}": ${m(t)};`).join(`
3
+ `)}\n }`:`Record<string, any>`}case`ZodOptional`:case`optional`:return`${m(t.innerType??t.wrapped)} | undefined`;case`ZodNullable`:case`nullable`:return`${m(t.innerType??t.wrapped)} | null`;case`ZodUnion`:case`union`:return(t.options??[]).map(m).join(` | `);case`ZodIntersection`:case`intersection`:return`${m(t.left)} & ${m(t.right)}`;case`ZodEnum`:case`enum`:return(t.values??[]).map(e=>`"${e}"`).join(` | `);case`ZodLiteral`:case`literal`:{let e=t.value;return typeof e==`string`?`"${e}"`:String(e)}default:return`any`}},h=(e,n)=>{let{internationalization:a,system:s}=n,{moduleAugmentationDir:c}=s,{locales:l,requiredLocales:f,strictMode:h}=a,g=`import "intlayer";
4
+ `,_=e.map(e=>({relativePath:`./${o(c,e)}`,id:r(e,i(e)),hash:`_${t(e)}`}));for(let e of _)g+=`import ${e.hash} from '${e.relativePath}';\n`;g+=`
5
+ `;let v=_.map(e=>` "${e.id}": typeof ${e.hash};`).join(`
6
+ `),y=l,b=f?.length?f.filter(e=>y.includes(e)):y,x=p(y),S=p(b),C=n.schemas??{},w=Object.entries(C).map(([e,t])=>{let n=`any`;if(t)try{let{node:r}=d(t,e);n=r.kind===133?m(t):u(r)}catch{n=m(t)}return` "${e}": ${n};`}).join(`
7
+ `),T=h===`strict`?`strict`:h===`inclusive`?`inclusive`:`loose`;return g+=`declare module 'intlayer' {
8
+ `,g+=` interface __DictionaryRegistry {\n${v}\n }\n\n`,g+=` interface __DeclaredLocalesRegistry {\n${x}\n }\n\n`,g+=` interface __RequiredLocalesRegistry {\n${S}\n }\n\n`,g+=` interface __SchemaRegistry {\n${w}\n }\n\n`,g+=` interface __StrictModeRegistry { mode: '${T}' }\n`,g+=`}
9
+ `,g},g=async t=>{let{moduleAugmentationDir:r,typesDir:i}=t.system;await n(r,{recursive:!0});let o=h(await l(c(`${i}/*.ts`),{ignore:[`**/*.d.ts`]}),t);await e(a(r,`intlayer.d.ts`),o)};export{g as createModuleAugmentation,f as getTypeName};
107
10
  //# sourceMappingURL=createModuleAugmentation.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"createModuleAugmentation.mjs","names":[],"sources":["../../../src/createType/createModuleAugmentation.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { basename, extname, join, relative } from 'node:path';\nimport { kebabCaseToCamelCase, normalizePath } from '@intlayer/config';\nimport type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { printNode, zodToTs } from 'zod-to-ts';\nimport { getFileHash } from '../utils/getFileHash';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/** Returns lines like: [Locales.FRENCH]: 1; */\nconst formatLocales = (locales: Locale[]) =>\n locales.map((locale) => ` \"${locale}\": 1;`).join('\\n');\n\nconst zodToTsString = (schema: any): string => {\n if (!schema) return 'any';\n\n // Support both real Zod objects (_def) and serialized versions (def or nested)\n const def = schema._def ?? schema.def ?? schema;\n\n // Handle serialized type names (sometimes 'type' instead of 'typeName')\n const typeName = def.typeName ?? def.type;\n\n switch (typeName) {\n case 'ZodString':\n case 'string':\n return 'string';\n case 'ZodNumber':\n case 'number':\n return 'number';\n case 'ZodBoolean':\n case 'boolean':\n return 'boolean';\n case 'ZodNull':\n case 'null':\n return 'null';\n case 'ZodUndefined':\n case 'undefined':\n return 'undefined';\n case 'ZodArray':\n case 'array':\n return `${zodToTsString(def.type ?? def.element)}[]`;\n case 'ZodObject':\n case 'object': {\n const shape = typeof def.shape === 'function' ? def.shape() : def.shape;\n if (!shape) return 'Record<string, any>';\n\n const entries = Object.entries(shape)\n .map(([k, v]) => ` \"${k}\": ${zodToTsString(v)};`)\n .join('\\n');\n return `{\\n${entries}\\n }`;\n }\n case 'ZodOptional':\n case 'optional':\n return `${zodToTsString(def.innerType ?? def.wrapped)} | undefined`;\n case 'ZodNullable':\n case 'nullable':\n return `${zodToTsString(def.innerType ?? def.wrapped)} | null`;\n case 'ZodUnion':\n case 'union': {\n const options = def.options ?? [];\n return options.map(zodToTsString).join(' | ');\n }\n case 'ZodIntersection':\n case 'intersection':\n return `${zodToTsString(def.left)} & ${zodToTsString(def.right)}`;\n case 'ZodEnum':\n case 'enum': {\n const values = def.values ?? [];\n return values.map((v: string) => `\"${v}\"`).join(' | ');\n }\n case 'ZodLiteral':\n case 'literal': {\n const value = def.value;\n return typeof value === 'string' ? `\"${value}\"` : String(value);\n }\n default:\n return 'any';\n }\n};\n\n/** Generate the content of the module augmentation file */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration: IntlayerConfig\n): string => {\n const { internationalization, system } = configuration;\n const { moduleAugmentationDir } = system;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent = 'import \"intlayer\";\\n';\n\n // Build dictionary refs\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)),\n hash: `_${getFileHash(dictionaryPath)}`,\n }));\n\n // Import all dictionaries\n for (const dictionary of dictionariesRef) {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n }\n fileContent += '\\n';\n\n // Dictionary map entries (id: typeof <hash>)\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n // Ensure required ⊆ declared; if empty, default required = declared\n const declared = locales;\n const requiredSanitized = requiredLocales?.length\n ? requiredLocales.filter((requiredLocales) =>\n declared.includes(requiredLocales)\n )\n : declared;\n\n const formattedDeclaredLocales = formatLocales(declared);\n const formattedRequiredLocales = formatLocales(requiredSanitized);\n\n // Build schema registry\n const schemas = configuration.schemas ?? {};\n const formattedSchemas = Object.entries(schemas)\n .map(([key, schema]) => {\n let typeStr = 'any';\n\n if (schema) {\n try {\n const { node } = zodToTs(schema as any, key);\n // 133 is the kind for AnyKeyword in TypeScript\n if ((node as any).kind !== 133) {\n typeStr = printNode(node);\n } else {\n // Fallback to custom string generator if zodToTs returns any\n typeStr = zodToTsString(schema);\n }\n } catch (_e) {\n // Fallback to custom string generator\n typeStr = zodToTsString(schema);\n }\n }\n return ` \"${key}\": ${typeStr};`;\n })\n .join('\\n');\n\n // Choose strict mode registry key\n const strictKey =\n strictMode === 'strict'\n ? 'strict'\n : strictMode === 'inclusive'\n ? 'inclusive'\n : 'loose';\n\n /**\n * Module augmentation that ONLY adds keys to registries.\n * No types/aliases redefined here—avoids merge conflicts.\n */\n fileContent += `declare module 'intlayer' {\\n`;\n // Dictionaries registry\n fileContent += ` interface __DictionaryRegistry {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n // Locales registries\n fileContent += ` interface __DeclaredLocalesRegistry {\\n${formattedDeclaredLocales}\\n }\\n\\n`;\n fileContent += ` interface __RequiredLocalesRegistry {\\n${formattedRequiredLocales}\\n }\\n\\n`;\n // Schema registry\n fileContent += ` interface __SchemaRegistry {\\n${formattedSchemas}\\n }\\n\\n`;\n // Resolved strict mode (narrow the literal at build time)\n fileContent += ` interface __StrictModeRegistry { mode: '${strictKey}' }\\n`;\n fileContent += `}\\n`;\n\n return fileContent;\n};\n\n/** Generate the index file merging all the types */\nexport const createModuleAugmentation = async (\n configuration: IntlayerConfig\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.system;\n\n await mkdir(moduleAugmentationDir, { recursive: true });\n\n const dictionariesTypesDefinitions: string[] = await fg(\n normalizePath(`${typesDir}/*.ts`),\n { ignore: ['**/*.d.ts'] }\n );\n\n const tsContent = generateTypeIndexContent(\n dictionariesTypesDefinitions,\n configuration\n );\n\n const tsFilePath = join(moduleAugmentationDir, 'intlayer.d.ts');\n await writeFileIfChanged(tsFilePath, tsContent);\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"createModuleAugmentation.mjs","names":[],"sources":["../../../src/createType/createModuleAugmentation.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { basename, extname, join, relative } from 'node:path';\nimport { kebabCaseToCamelCase, normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { printNode, zodToTs } from 'zod-to-ts';\nimport { getFileHash } from '../utils/getFileHash';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\n/** Returns lines like: [Locales.FRENCH]: 1; */\nconst formatLocales = (locales: Locale[]) =>\n locales.map((locale) => ` \"${locale}\": 1;`).join('\\n');\n\nconst zodToTsString = (schema: any): string => {\n if (!schema) return 'any';\n\n // Support both real Zod objects (_def) and serialized versions (def or nested)\n const def = schema._def ?? schema.def ?? schema;\n\n // Handle serialized type names (sometimes 'type' instead of 'typeName')\n const typeName = def.typeName ?? def.type;\n\n switch (typeName) {\n case 'ZodString':\n case 'string':\n return 'string';\n case 'ZodNumber':\n case 'number':\n return 'number';\n case 'ZodBoolean':\n case 'boolean':\n return 'boolean';\n case 'ZodNull':\n case 'null':\n return 'null';\n case 'ZodUndefined':\n case 'undefined':\n return 'undefined';\n case 'ZodArray':\n case 'array':\n return `${zodToTsString(def.type ?? def.element)}[]`;\n case 'ZodObject':\n case 'object': {\n const shape = typeof def.shape === 'function' ? def.shape() : def.shape;\n if (!shape) return 'Record<string, any>';\n\n const entries = Object.entries(shape)\n .map(([k, v]) => ` \"${k}\": ${zodToTsString(v)};`)\n .join('\\n');\n return `{\\n${entries}\\n }`;\n }\n case 'ZodOptional':\n case 'optional':\n return `${zodToTsString(def.innerType ?? def.wrapped)} | undefined`;\n case 'ZodNullable':\n case 'nullable':\n return `${zodToTsString(def.innerType ?? def.wrapped)} | null`;\n case 'ZodUnion':\n case 'union': {\n const options = def.options ?? [];\n return options.map(zodToTsString).join(' | ');\n }\n case 'ZodIntersection':\n case 'intersection':\n return `${zodToTsString(def.left)} & ${zodToTsString(def.right)}`;\n case 'ZodEnum':\n case 'enum': {\n const values = def.values ?? [];\n return values.map((v: string) => `\"${v}\"`).join(' | ');\n }\n case 'ZodLiteral':\n case 'literal': {\n const value = def.value;\n return typeof value === 'string' ? `\"${value}\"` : String(value);\n }\n default:\n return 'any';\n }\n};\n\n/** Generate the content of the module augmentation file */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration: IntlayerConfig\n): string => {\n const { internationalization, system } = configuration;\n const { moduleAugmentationDir } = system;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent = 'import \"intlayer\";\\n';\n\n // Build dictionary refs\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)),\n hash: `_${getFileHash(dictionaryPath)}`,\n }));\n\n // Import all dictionaries\n for (const dictionary of dictionariesRef) {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n }\n fileContent += '\\n';\n\n // Dictionary map entries (id: typeof <hash>)\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n // Ensure required ⊆ declared; if empty, default required = declared\n const declared = locales;\n const requiredSanitized = requiredLocales?.length\n ? requiredLocales.filter((requiredLocales) =>\n declared.includes(requiredLocales)\n )\n : declared;\n\n const formattedDeclaredLocales = formatLocales(declared);\n const formattedRequiredLocales = formatLocales(requiredSanitized);\n\n // Build schema registry\n const schemas = configuration.schemas ?? {};\n const formattedSchemas = Object.entries(schemas)\n .map(([key, schema]) => {\n let typeStr = 'any';\n\n if (schema) {\n try {\n const { node } = zodToTs(schema as any, key);\n // 133 is the kind for AnyKeyword in TypeScript\n if ((node as any).kind !== 133) {\n typeStr = printNode(node);\n } else {\n // Fallback to custom string generator if zodToTs returns any\n typeStr = zodToTsString(schema);\n }\n } catch (_e) {\n // Fallback to custom string generator\n typeStr = zodToTsString(schema);\n }\n }\n return ` \"${key}\": ${typeStr};`;\n })\n .join('\\n');\n\n // Choose strict mode registry key\n const strictKey =\n strictMode === 'strict'\n ? 'strict'\n : strictMode === 'inclusive'\n ? 'inclusive'\n : 'loose';\n\n /**\n * Module augmentation that ONLY adds keys to registries.\n * No types/aliases redefined here—avoids merge conflicts.\n */\n fileContent += `declare module 'intlayer' {\\n`;\n // Dictionaries registry\n fileContent += ` interface __DictionaryRegistry {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n // Locales registries\n fileContent += ` interface __DeclaredLocalesRegistry {\\n${formattedDeclaredLocales}\\n }\\n\\n`;\n fileContent += ` interface __RequiredLocalesRegistry {\\n${formattedRequiredLocales}\\n }\\n\\n`;\n // Schema registry\n fileContent += ` interface __SchemaRegistry {\\n${formattedSchemas}\\n }\\n\\n`;\n // Resolved strict mode (narrow the literal at build time)\n fileContent += ` interface __StrictModeRegistry { mode: '${strictKey}' }\\n`;\n fileContent += `}\\n`;\n\n return fileContent;\n};\n\n/** Generate the index file merging all the types */\nexport const createModuleAugmentation = async (\n configuration: IntlayerConfig\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.system;\n\n await mkdir(moduleAugmentationDir, { recursive: true });\n\n const dictionariesTypesDefinitions: string[] = await fg(\n normalizePath(`${typesDir}/*.ts`),\n { ignore: ['**/*.d.ts'] }\n );\n\n const tsContent = generateTypeIndexContent(\n dictionariesTypesDefinitions,\n configuration\n );\n\n const tsFilePath = join(moduleAugmentationDir, 'intlayer.d.ts');\n await writeFileIfChanged(tsFilePath, tsContent);\n};\n"],"mappings":"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"}
@@ -1,27 +1,2 @@
1
- import { parallelize } from "../utils/parallelize.mjs";
2
- import { mkdir, writeFile } from "node:fs/promises";
3
- import { resolve } from "node:path";
4
-
5
- //#region src/createType/createType.ts
6
- const generateTypeScriptType = (dictionary) => {
7
- return `/* eslint-disable */\nexport default ${JSON.stringify(dictionary, null, 2)} as const;\n`;
8
- };
9
- /**
10
- * This function generates a TypeScript type definition from a JSON object
11
- */
12
- const createTypes = async (dictionaries, configuration) => {
13
- const { system } = configuration;
14
- const { typesDir } = system;
15
- await mkdir(typesDir, { recursive: true });
16
- return (await parallelize(dictionaries, async (dictionary) => {
17
- if (!dictionary.key) return;
18
- const typeDefinition = generateTypeScriptType(dictionary);
19
- const outputPath = resolve(typesDir, `${dictionary.key}.ts`);
20
- await writeFile(outputPath, typeDefinition);
21
- return outputPath;
22
- })).filter(Boolean);
23
- };
24
-
25
- //#endregion
26
- export { createTypes, generateTypeScriptType };
1
+ import{parallelize as e}from"../utils/parallelize.mjs";import{mkdir as t,writeFile as n}from"node:fs/promises";import{resolve as r}from"node:path";const i=e=>`/* eslint-disable */\nexport default ${JSON.stringify(e,null,2)} as const;\n`,a=async(a,o)=>{let{system:s}=o,{typesDir:c}=s;return await t(c,{recursive:!0}),(await e(a,async e=>{if(!e.key)return;let t=i(e),a=r(c,`${e.key}.ts`);return await n(a,t),a})).filter(Boolean)};export{a as createTypes,i as generateTypeScriptType};
27
2
  //# sourceMappingURL=createType.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"createType.mjs","names":[],"sources":["../../../src/createType/createType.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\n\nexport const generateTypeScriptType = (dictionary: Dictionary) => {\n const jsonString = JSON.stringify(dictionary, null, 2);\n\n return `/* eslint-disable */\\nexport default ${jsonString} as const;\\n`;\n};\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { system } = configuration;\n const { typesDir } = system;\n\n // Create type folders if they don't exist\n await mkdir(typesDir, { recursive: true });\n\n const results = await parallelize(\n dictionaries,\n async (dictionary): Promise<string | undefined> => {\n if (!dictionary.key) {\n return undefined;\n }\n\n const typeDefinition: string = generateTypeScriptType(dictionary);\n\n const outputPath: string = resolve(typesDir, `${dictionary.key}.ts`);\n\n await writeFile(outputPath, typeDefinition);\n\n return outputPath;\n }\n );\n\n return results.filter(Boolean) as string[];\n};\n"],"mappings":";;;;;AAKA,MAAa,0BAA0B,eAA2B;AAGhE,QAAO,wCAFY,KAAK,UAAU,YAAY,MAAM,EAAE,CAEI;;;;;AAK5D,MAAa,cAAc,OACzB,cACA,kBACsB;CACtB,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,aAAa;AAGrB,OAAM,MAAM,UAAU,EAAE,WAAW,MAAM,CAAC;AAmB1C,SAjBgB,MAAM,YACpB,cACA,OAAO,eAA4C;AACjD,MAAI,CAAC,WAAW,IACd;EAGF,MAAM,iBAAyB,uBAAuB,WAAW;EAEjE,MAAM,aAAqB,QAAQ,UAAU,GAAG,WAAW,IAAI,KAAK;AAEpE,QAAM,UAAU,YAAY,eAAe;AAE3C,SAAO;GAEV,EAEc,OAAO,QAAQ"}
1
+ {"version":3,"file":"createType.mjs","names":[],"sources":["../../../src/createType/createType.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { parallelize } from '../utils/parallelize';\n\nexport const generateTypeScriptType = (dictionary: Dictionary) => {\n const jsonString = JSON.stringify(dictionary, null, 2);\n\n return `/* eslint-disable */\\nexport default ${jsonString} as const;\\n`;\n};\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { system } = configuration;\n const { typesDir } = system;\n\n // Create type folders if they don't exist\n await mkdir(typesDir, { recursive: true });\n\n const results = await parallelize(\n dictionaries,\n async (dictionary): Promise<string | undefined> => {\n if (!dictionary.key) {\n return undefined;\n }\n\n const typeDefinition: string = generateTypeScriptType(dictionary);\n\n const outputPath: string = resolve(typesDir, `${dictionary.key}.ts`);\n\n await writeFile(outputPath, typeDefinition);\n\n return outputPath;\n }\n );\n\n return results.filter(Boolean) as string[];\n};\n"],"mappings":"mJAKA,MAAa,EAA0B,GAG9B,wCAFY,KAAK,UAAU,EAAY,KAAM,EAAE,CAEI,cAK/C,EAAc,MACzB,EACA,IACsB,CACtB,GAAM,CAAE,UAAW,EACb,CAAE,YAAa,EAsBrB,OAnBA,MAAM,EAAM,EAAU,CAAE,UAAW,GAAM,CAAC,EAE1B,MAAM,EACpB,EACA,KAAO,IAA4C,CACjD,GAAI,CAAC,EAAW,IACd,OAGF,IAAM,EAAyB,EAAuB,EAAW,CAE3D,EAAqB,EAAQ,EAAU,GAAG,EAAW,IAAI,KAAK,CAIpE,OAFA,MAAM,EAAU,EAAY,EAAe,CAEpC,GAEV,EAEc,OAAO,QAAQ"}
@@ -1,4 +1 @@
1
- import { createModuleAugmentation, getTypeName } from "./createModuleAugmentation.mjs";
2
- import { createTypes, generateTypeScriptType } from "./createType.mjs";
3
-
4
- export { createModuleAugmentation, createTypes, generateTypeScriptType, getTypeName };
1
+ import{createModuleAugmentation as e,getTypeName as t}from"./createModuleAugmentation.mjs";import{createTypes as n,generateTypeScriptType as r}from"./createType.mjs";export{e as createModuleAugmentation,n as createTypes,r as generateTypeScriptType,t as getTypeName};
@@ -1,49 +1,2 @@
1
- import { parallelize } from "./utils/parallelize.mjs";
2
- import { getAppLogger, getConfiguration, x } from "@intlayer/config";
3
- import { getIntlayerAPIProxy } from "@intlayer/api";
4
-
5
- //#region src/fetchDistantDictionaries.ts
6
- /**
7
- * Fetch distant dictionaries and update the logger with their statuses.
8
- */
9
- const fetchDistantDictionaries = async (options, onStatusUpdate) => {
10
- const config = getConfiguration();
11
- const appLogger = getAppLogger(config);
12
- try {
13
- const intlayerAPI = getIntlayerAPIProxy(void 0, config);
14
- const distantDictionariesKeys = options.dictionaryKeys;
15
- const processDictionary = async (dictionaryKey) => {
16
- onStatusUpdate?.([{
17
- dictionaryKey,
18
- type: "remote",
19
- status: "fetching"
20
- }]);
21
- try {
22
- const distantDictionary = (await intlayerAPI.dictionary.getDictionary(dictionaryKey)).data;
23
- if (!distantDictionary) throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
24
- onStatusUpdate?.([{
25
- dictionaryKey,
26
- type: "remote",
27
- status: "fetched"
28
- }]);
29
- return distantDictionary;
30
- } catch (error) {
31
- onStatusUpdate?.([{
32
- dictionaryKey,
33
- type: "remote",
34
- status: "error",
35
- error: `Error fetching dictionary ${dictionaryKey}: ${error}`
36
- }]);
37
- return;
38
- }
39
- };
40
- return (await parallelize(distantDictionariesKeys, async (dictionaryKey) => await processDictionary(dictionaryKey))).filter((dict) => dict !== void 0);
41
- } catch (_error) {
42
- appLogger(`${x} Failed to fetch distant dictionaries`, { level: "error" });
43
- return [];
44
- }
45
- };
46
-
47
- //#endregion
48
- export { fetchDistantDictionaries };
1
+ import{parallelize as e}from"./utils/parallelize.mjs";import{getConfiguration as t}from"@intlayer/config/node";import{getAppLogger as n,x as r}from"@intlayer/config/logger";import{getIntlayerAPIProxy as i}from"@intlayer/api";const a=async(a,o)=>{let s=t(),c=n(s);try{let t=i(void 0,s),n=a.dictionaryKeys,r=async e=>{o?.([{dictionaryKey:e,type:`remote`,status:`fetching`}]);try{let n=(await t.dictionary.getDictionary(e)).data;if(!n)throw Error(`Dictionary ${e} not found on remote`);return o?.([{dictionaryKey:e,type:`remote`,status:`fetched`}]),n}catch(t){o?.([{dictionaryKey:e,type:`remote`,status:`error`,error:`Error fetching dictionary ${e}: ${t}`}]);return}};return(await e(n,async e=>await r(e))).filter(e=>e!==void 0)}catch{return c(`${r} Failed to fetch distant dictionaries`,{level:`error`}),[]}};export{a as fetchDistantDictionaries};
49
2
  //# sourceMappingURL=fetchDistantDictionaries.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration, x } from '@intlayer/config';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { parallelize } from './utils/parallelize';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const distantDictionariesKeys = options.dictionaryKeys;\n // Process dictionaries in parallel with a concurrency limit\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult =\n await intlayerAPI.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n onStatusUpdate?.([\n { dictionaryKey, type: 'remote', status: 'fetched' },\n ]);\n\n return distantDictionary;\n } catch (error) {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n ]);\n return undefined;\n }\n };\n\n const result = await parallelize(\n distantDictionariesKeys,\n async (dictionaryKey) => await processDictionary(dictionaryKey)\n );\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict: DictionaryAPI | undefined): dict is DictionaryAPI =>\n dict !== undefined\n );\n\n return filteredResult;\n } catch (_error) {\n appLogger(`${x} Failed to fetch distant dictionaries`, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;AAgBA,MAAa,2BAA2B,OACtC,SACA,mBAC6B;CAC7B,MAAM,SAAS,kBAAkB;CACjC,MAAM,YAAY,aAAa,OAAO;AACtC,KAAI;EACF,MAAM,cAAc,oBAAoB,QAAW,OAAO;EAE1D,MAAM,0BAA0B,QAAQ;EAExC,MAAM,oBAAoB,OACxB,kBACuC;AACvC,oBAAiB,CACf;IACE;IACA,MAAM;IACN,QAAQ;IACT,CACF,CAAC;AAEF,OAAI;IAKF,MAAM,qBAFJ,MAAM,YAAY,WAAW,cAAc,cAAc,EAEb;AAE9C,QAAI,CAAC,kBACH,OAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;AAGpE,qBAAiB,CACf;KAAE;KAAe,MAAM;KAAU,QAAQ;KAAW,CACrD,CAAC;AAEF,WAAO;YACA,OAAO;AACd,qBAAiB,CACf;KACE;KACA,MAAM;KACN,QAAQ;KACR,OAAO,6BAA6B,cAAc,IAAI;KACvD,CACF,CAAC;AACF;;;AAeJ,UAXe,MAAM,YACnB,yBACA,OAAO,kBAAkB,MAAM,kBAAkB,cAAc,CAChE,EAG6B,QAC3B,SACC,SAAS,OACZ;UAGM,QAAQ;AACf,YAAU,GAAG,EAAE,wCAAwC,EAAE,OAAO,SAAS,CAAC;AAC1E,SAAO,EAAE"}
1
+ {"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { parallelize } from './utils/parallelize';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const distantDictionariesKeys = options.dictionaryKeys;\n // Process dictionaries in parallel with a concurrency limit\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'fetching',\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult =\n await intlayerAPI.dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n onStatusUpdate?.([\n { dictionaryKey, type: 'remote', status: 'fetched' },\n ]);\n\n return distantDictionary;\n } catch (error) {\n onStatusUpdate?.([\n {\n dictionaryKey,\n type: 'remote',\n status: 'error',\n error: `Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n ]);\n return undefined;\n }\n };\n\n const result = await parallelize(\n distantDictionariesKeys,\n async (dictionaryKey) => await processDictionary(dictionaryKey)\n );\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict: DictionaryAPI | undefined): dict is DictionaryAPI =>\n dict !== undefined\n );\n\n return filteredResult;\n } catch (_error) {\n appLogger(`${x} Failed to fetch distant dictionaries`, { level: 'error' });\n return [];\n }\n};\n"],"mappings":"iOAiBA,MAAa,EAA2B,MACtC,EACA,IAC6B,CAC7B,IAAM,EAAS,GAAkB,CAC3B,EAAY,EAAa,EAAO,CACtC,GAAI,CACF,IAAM,EAAc,EAAoB,IAAA,GAAW,EAAO,CAEpD,EAA0B,EAAQ,eAElC,EAAoB,KACxB,IACuC,CACvC,IAAiB,CACf,CACE,gBACA,KAAM,SACN,OAAQ,WACT,CACF,CAAC,CAEF,GAAI,CAKF,IAAM,GAFJ,MAAM,EAAY,WAAW,cAAc,EAAc,EAEb,KAE9C,GAAI,CAAC,EACH,MAAU,MAAM,cAAc,EAAc,sBAAsB,CAOpE,OAJA,IAAiB,CACf,CAAE,gBAAe,KAAM,SAAU,OAAQ,UAAW,CACrD,CAAC,CAEK,QACA,EAAO,CACd,IAAiB,CACf,CACE,gBACA,KAAM,SACN,OAAQ,QACR,MAAO,6BAA6B,EAAc,IAAI,IACvD,CACF,CAAC,CACF,SAeJ,OAXe,MAAM,EACnB,EACA,KAAO,IAAkB,MAAM,EAAkB,EAAc,CAChE,EAG6B,OAC3B,GACC,IAAS,IAAA,GACZ,MAGc,CAEf,OADA,EAAU,GAAG,EAAE,uCAAwC,CAAE,MAAO,QAAS,CAAC,CACnE,EAAE"}
@@ -1,47 +1,2 @@
1
- import { formatLocale, formatPath } from "./utils/formatter.mjs";
2
- import { getContent } from "@intlayer/core";
3
- import { ANSIColors, colorize, colorizeKey, colorizePath, getAppLogger, x } from "@intlayer/config/client";
4
-
5
- //#region src/filterInvalidDictionaries.ts
6
- const isInvalidDictionary = (dictionary, configuration, options) => {
7
- const appLogger = getAppLogger(configuration);
8
- if (!dictionary) return false;
9
- const location = Boolean(dictionary.location === "local" || typeof dictionary.filePath === "string") ? "Local" : "Remote";
10
- const hasKey = Boolean(dictionary.key);
11
- const hasContent = Boolean(dictionary.content);
12
- if (!hasKey) {
13
- appLogger(`${location} dictionary has no key`, { level: "error" });
14
- return false;
15
- }
16
- if (!hasContent) {
17
- appLogger(`${location} dictionary ${colorizeKey(dictionary.key)} has no content - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath("Remote")}`, { level: "error" });
18
- return false;
19
- }
20
- if (dictionary.schema && options?.checkSchema) {
21
- if (!(typeof dictionary.content === "function" || typeof dictionary.content === "object" && dictionary.content !== null && typeof dictionary.content.then === "function")) {
22
- const locales = configuration?.internationalization?.locales ?? [];
23
- const isStrict = configuration?.internationalization.strictMode === "strict";
24
- const schema = typeof dictionary.schema === "string" ? configuration?.schemas?.[dictionary.schema] : void 0;
25
- if (schema && typeof schema.safeParse === "function") for (const locale of locales) {
26
- const resolvedContent = getContent(dictionary.content, {
27
- dictionaryKey: dictionary.key,
28
- keyPath: []
29
- }, locale, !isStrict);
30
- const result = schema.safeParse(resolvedContent);
31
- if (!result.success) {
32
- appLogger(`${location} dictionary ${colorizeKey(dictionary.key)} has invalid content according to schema ${colorize(dictionary.schema, ANSIColors.ORANGE)} for locale ${formatLocale(locale)} - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath("Remote")}`, { level: "error" });
33
- result.error.issues.forEach((issue) => {
34
- appLogger(`${x} Error: ${colorizeKey(dictionary.key)} - ${formatLocale(locale)} - ${colorize(`${issue.path.join(".")}:`, ANSIColors.BLUE)} ${colorize(issue.message, ANSIColors.GREY)}`, { level: "error" });
35
- });
36
- return false;
37
- }
38
- }
39
- }
40
- }
41
- return true;
42
- };
43
- const filterInvalidDictionaries = (dictionaries, configuration, options) => (dictionaries ?? [])?.filter((dictionary) => isInvalidDictionary(dictionary, configuration, options));
44
-
45
- //#endregion
46
- export { filterInvalidDictionaries, isInvalidDictionary };
1
+ import{formatLocale as e,formatPath as t}from"./utils/formatter.mjs";import{ANSIColors as n,colorize as r,colorizeKey as i,colorizePath as a,getAppLogger as o,x as s}from"@intlayer/config/client";import{getContent as c}from"@intlayer/core/interpreter";const l=(l,u,d)=>{let f=o(u);if(!l)return!1;let p=l.location===`local`||typeof l.filePath==`string`?`Local`:`Remote`,m=!!l.key,h=!!l.content;if(!m)return f(`${p} dictionary has no key`,{level:`error`}),!1;if(!h)return f(`${p} dictionary ${i(l.key)} has no content - ${l.filePath?t(l.filePath):a(`Remote`)}`,{level:`error`}),!1;if(l.schema&&d?.checkSchema&&!(typeof l.content==`function`||typeof l.content==`object`&&l.content!==null&&typeof l.content.then==`function`)){let o=u?.internationalization?.locales??[],d=u?.internationalization.strictMode===`strict`,m=typeof l.schema==`string`?u?.schemas?.[l.schema]:void 0;if(m&&typeof m.safeParse==`function`)for(let u of o){let o=c(l.content,{dictionaryKey:l.key,keyPath:[]},u,!d),h=m.safeParse(o);if(!h.success)return f(`${p} dictionary ${i(l.key)} has invalid content according to schema ${r(l.schema,n.ORANGE)} for locale ${e(u)} - ${l.filePath?t(l.filePath):a(`Remote`)}`,{level:`error`}),h.error.issues.forEach(t=>{f(`${s} Error: ${i(l.key)} - ${e(u)} - ${r(`${t.path.join(`.`)}:`,n.BLUE)} ${r(t.message,n.GREY)}`,{level:`error`})}),!1}}return!0},u=(e,t,n)=>(e??[])?.filter(e=>l(e,t,n));export{u as filterInvalidDictionaries,l as isInvalidDictionary};
47
2
  //# sourceMappingURL=filterInvalidDictionaries.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"filterInvalidDictionaries.mjs","names":[],"sources":["../../src/filterInvalidDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/client';\nimport { getContent } from '@intlayer/core';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { formatLocale, formatPath } from './utils/formatter';\n\ntype IsInvalidDictionaryOptions = { checkSchema: boolean };\n\nexport const isInvalidDictionary = (\n dictionary: Dictionary | undefined,\n configuration?: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): boolean => {\n const appLogger = getAppLogger(configuration);\n\n if (!dictionary) return false;\n\n const isLocal = Boolean(\n dictionary.location === 'local' || typeof dictionary.filePath === 'string'\n );\n const location = isLocal ? 'Local' : 'Remote';\n const hasKey = Boolean(dictionary.key);\n const hasContent = Boolean(dictionary.content);\n\n if (!hasKey) {\n appLogger(`${location} dictionary has no key`, {\n level: 'error',\n });\n\n return false;\n }\n\n if (!hasContent) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has no content - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n return false;\n }\n\n if (dictionary.schema && options?.checkSchema) {\n const isAsync =\n typeof dictionary.content === 'function' ||\n (typeof dictionary.content === 'object' &&\n dictionary.content !== null &&\n typeof (dictionary.content as any).then === 'function');\n\n if (!isAsync) {\n const locales = configuration?.internationalization?.locales ?? [];\n const isStrict =\n configuration?.internationalization.strictMode === 'strict';\n\n const schema =\n typeof dictionary.schema === 'string'\n ? configuration?.schemas?.[dictionary.schema]\n : undefined;\n\n if (schema && typeof schema.safeParse === 'function') {\n for (const locale of locales) {\n const resolvedContent = getContent(\n dictionary.content,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n },\n locale,\n !isStrict\n );\n const result = (schema as any).safeParse(resolvedContent);\n\n if (!result.success) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has invalid content according to schema ${colorize(dictionary.schema as string, ANSIColors.ORANGE)} for locale ${formatLocale(locale)} - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n\n result.error.issues.forEach((issue: any) => {\n appLogger(\n `${x} Error: ${colorizeKey(dictionary.key)} - ${formatLocale(locale)} - ${colorize(`${issue.path.join('.')}:`, ANSIColors.BLUE)} ${colorize(issue.message, ANSIColors.GREY)}`,\n {\n level: 'error',\n }\n );\n });\n\n return false;\n }\n }\n }\n }\n }\n\n return true;\n};\n\nexport const filterInvalidDictionaries = (\n dictionaries: (Dictionary | undefined)[] | undefined,\n configuration: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): Dictionary[] =>\n (dictionaries ?? [])?.filter((dictionary) =>\n isInvalidDictionary(dictionary, configuration, options)\n ) as Dictionary[];\n"],"mappings":";;;;;AAcA,MAAa,uBACX,YACA,eACA,YACY;CACZ,MAAM,YAAY,aAAa,cAAc;AAE7C,KAAI,CAAC,WAAY,QAAO;CAKxB,MAAM,WAHU,QACd,WAAW,aAAa,WAAW,OAAO,WAAW,aAAa,SACnE,GAC0B,UAAU;CACrC,MAAM,SAAS,QAAQ,WAAW,IAAI;CACtC,MAAM,aAAa,QAAQ,WAAW,QAAQ;AAE9C,KAAI,CAAC,QAAQ;AACX,YAAU,GAAG,SAAS,yBAAyB,EAC7C,OAAO,SACR,CAAC;AAEF,SAAO;;AAGT,KAAI,CAAC,YAAY;AACf,YACE,GAAG,SAAS,cAAc,YAAY,WAAW,IAAI,CAAC,oBAAoB,WAAW,WAAW,WAAW,WAAW,SAAS,GAAG,aAAa,SAAS,IACxJ,EACE,OAAO,SACR,CACF;AACD,SAAO;;AAGT,KAAI,WAAW,UAAU,SAAS,aAOhC;MAAI,EALF,OAAO,WAAW,YAAY,cAC7B,OAAO,WAAW,YAAY,YAC7B,WAAW,YAAY,QACvB,OAAQ,WAAW,QAAgB,SAAS,aAElC;GACZ,MAAM,UAAU,eAAe,sBAAsB,WAAW,EAAE;GAClE,MAAM,WACJ,eAAe,qBAAqB,eAAe;GAErD,MAAM,SACJ,OAAO,WAAW,WAAW,WACzB,eAAe,UAAU,WAAW,UACpC;AAEN,OAAI,UAAU,OAAO,OAAO,cAAc,WACxC,MAAK,MAAM,UAAU,SAAS;IAC5B,MAAM,kBAAkB,WACtB,WAAW,SACX;KACE,eAAe,WAAW;KAC1B,SAAS,EAAE;KACZ,EACD,QACA,CAAC,SACF;IACD,MAAM,SAAU,OAAe,UAAU,gBAAgB;AAEzD,QAAI,CAAC,OAAO,SAAS;AACnB,eACE,GAAG,SAAS,cAAc,YAAY,WAAW,IAAI,CAAC,2CAA2C,SAAS,WAAW,QAAkB,WAAW,OAAO,CAAC,cAAc,aAAa,OAAO,CAAC,KAAK,WAAW,WAAW,WAAW,WAAW,SAAS,GAAG,aAAa,SAAS,IAChR,EACE,OAAO,SACR,CACF;AAED,YAAO,MAAM,OAAO,SAAS,UAAe;AAC1C,gBACE,GAAG,EAAE,UAAU,YAAY,WAAW,IAAI,CAAC,KAAK,aAAa,OAAO,CAAC,KAAK,SAAS,GAAG,MAAM,KAAK,KAAK,IAAI,CAAC,IAAI,WAAW,KAAK,CAAC,GAAG,SAAS,MAAM,SAAS,WAAW,KAAK,IAC3K,EACE,OAAO,SACR,CACF;OACD;AAEF,YAAO;;;;;AAOjB,QAAO;;AAGT,MAAa,6BACX,cACA,eACA,aAEC,gBAAgB,EAAE,GAAG,QAAQ,eAC5B,oBAAoB,YAAY,eAAe,QAAQ,CACxD"}
1
+ {"version":3,"file":"filterInvalidDictionaries.mjs","names":[],"sources":["../../src/filterInvalidDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/client';\nimport { getContent } from '@intlayer/core/interpreter';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { formatLocale, formatPath } from './utils/formatter';\n\ntype IsInvalidDictionaryOptions = { checkSchema: boolean };\n\nexport const isInvalidDictionary = (\n dictionary: Dictionary | undefined,\n configuration?: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): boolean => {\n const appLogger = getAppLogger(configuration);\n\n if (!dictionary) return false;\n\n const isLocal = Boolean(\n dictionary.location === 'local' || typeof dictionary.filePath === 'string'\n );\n const location = isLocal ? 'Local' : 'Remote';\n const hasKey = Boolean(dictionary.key);\n const hasContent = Boolean(dictionary.content);\n\n if (!hasKey) {\n appLogger(`${location} dictionary has no key`, {\n level: 'error',\n });\n\n return false;\n }\n\n if (!hasContent) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has no content - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n return false;\n }\n\n if (dictionary.schema && options?.checkSchema) {\n const isAsync =\n typeof dictionary.content === 'function' ||\n (typeof dictionary.content === 'object' &&\n dictionary.content !== null &&\n typeof (dictionary.content as any).then === 'function');\n\n if (!isAsync) {\n const locales = configuration?.internationalization?.locales ?? [];\n const isStrict =\n configuration?.internationalization.strictMode === 'strict';\n\n const schema =\n typeof dictionary.schema === 'string'\n ? configuration?.schemas?.[dictionary.schema]\n : undefined;\n\n if (schema && typeof schema.safeParse === 'function') {\n for (const locale of locales) {\n const resolvedContent = getContent(\n dictionary.content,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n },\n locale,\n !isStrict\n );\n const result = (schema as any).safeParse(resolvedContent);\n\n if (!result.success) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has invalid content according to schema ${colorize(dictionary.schema as string, ANSIColors.ORANGE)} for locale ${formatLocale(locale)} - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n\n result.error.issues.forEach((issue: any) => {\n appLogger(\n `${x} Error: ${colorizeKey(dictionary.key)} - ${formatLocale(locale)} - ${colorize(`${issue.path.join('.')}:`, ANSIColors.BLUE)} ${colorize(issue.message, ANSIColors.GREY)}`,\n {\n level: 'error',\n }\n );\n });\n\n return false;\n }\n }\n }\n }\n }\n\n return true;\n};\n\nexport const filterInvalidDictionaries = (\n dictionaries: (Dictionary | undefined)[] | undefined,\n configuration: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): Dictionary[] =>\n (dictionaries ?? [])?.filter((dictionary) =>\n isInvalidDictionary(dictionary, configuration, options)\n ) as Dictionary[];\n"],"mappings":"4PAcA,MAAa,GACX,EACA,EACA,IACY,CACZ,IAAM,EAAY,EAAa,EAAc,CAE7C,GAAI,CAAC,EAAY,MAAO,GAKxB,IAAM,EAFJ,EAAW,WAAa,SAAW,OAAO,EAAW,UAAa,SAEzC,QAAU,SAC/B,EAAS,EAAQ,EAAW,IAC5B,EAAa,EAAQ,EAAW,QAEtC,GAAI,CAAC,EAKH,OAJA,EAAU,GAAG,EAAS,wBAAyB,CAC7C,MAAO,QACR,CAAC,CAEK,GAGT,GAAI,CAAC,EAOH,OANA,EACE,GAAG,EAAS,cAAc,EAAY,EAAW,IAAI,CAAC,oBAAoB,EAAW,SAAW,EAAW,EAAW,SAAS,CAAG,EAAa,SAAS,GACxJ,CACE,MAAO,QACR,CACF,CACM,GAGT,GAAI,EAAW,QAAU,GAAS,aAO5B,EALF,OAAO,EAAW,SAAY,YAC7B,OAAO,EAAW,SAAY,UAC7B,EAAW,UAAY,MACvB,OAAQ,EAAW,QAAgB,MAAS,YAElC,CACZ,IAAM,EAAU,GAAe,sBAAsB,SAAW,EAAE,CAC5D,EACJ,GAAe,qBAAqB,aAAe,SAE/C,EACJ,OAAO,EAAW,QAAW,SACzB,GAAe,UAAU,EAAW,QACpC,IAAA,GAEN,GAAI,GAAU,OAAO,EAAO,WAAc,WACxC,IAAK,IAAM,KAAU,EAAS,CAC5B,IAAM,EAAkB,EACtB,EAAW,QACX,CACE,cAAe,EAAW,IAC1B,QAAS,EAAE,CACZ,CACD,EACA,CAAC,EACF,CACK,EAAU,EAAe,UAAU,EAAgB,CAEzD,GAAI,CAAC,EAAO,QAiBV,OAhBA,EACE,GAAG,EAAS,cAAc,EAAY,EAAW,IAAI,CAAC,2CAA2C,EAAS,EAAW,OAAkB,EAAW,OAAO,CAAC,cAAc,EAAa,EAAO,CAAC,KAAK,EAAW,SAAW,EAAW,EAAW,SAAS,CAAG,EAAa,SAAS,GAChR,CACE,MAAO,QACR,CACF,CAED,EAAO,MAAM,OAAO,QAAS,GAAe,CAC1C,EACE,GAAG,EAAE,UAAU,EAAY,EAAW,IAAI,CAAC,KAAK,EAAa,EAAO,CAAC,KAAK,EAAS,GAAG,EAAM,KAAK,KAAK,IAAI,CAAC,GAAI,EAAW,KAAK,CAAC,GAAG,EAAS,EAAM,QAAS,EAAW,KAAK,GAC3K,CACE,MAAO,QACR,CACF,EACD,CAEK,IAOjB,MAAO,IAGI,GACX,EACA,EACA,KAEC,GAAgB,EAAE,GAAG,OAAQ,GAC5B,EAAoB,EAAY,EAAe,EAAQ,CACxD"}
@@ -1,45 +1,2 @@
1
- import { i18nextToIntlayerFormatter, icuToIntlayerFormatter, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToVueI18nFormatter, vueI18nToIntlayerFormatter } from "@intlayer/core/messageFormat";
2
-
3
- //#region src/formatDictionary.ts
4
- const formatDictionary = (dictionary) => {
5
- if (dictionary.format === "icu") return {
6
- ...dictionary,
7
- format: "intlayer",
8
- content: icuToIntlayerFormatter(dictionary.content)
9
- };
10
- if (dictionary.format === "i18next") return {
11
- ...dictionary,
12
- format: "intlayer",
13
- content: i18nextToIntlayerFormatter(dictionary.content)
14
- };
15
- if (dictionary.format === "vue-i18n") return {
16
- ...dictionary,
17
- format: "intlayer",
18
- content: vueI18nToIntlayerFormatter(dictionary.content)
19
- };
20
- return dictionary;
21
- };
22
- const formatDictionaries = (dictionaries) => dictionaries.map(formatDictionary);
23
- const formatDictionaryOutput = (dictionary) => {
24
- if (dictionary.format === "icu") return {
25
- ...dictionary,
26
- format: "icu",
27
- content: intlayerToICUFormatter(dictionary.content)
28
- };
29
- if (dictionary.format === "i18next") return {
30
- ...dictionary,
31
- format: "i18next",
32
- content: intlayerToI18nextFormatter(dictionary.content)
33
- };
34
- if (dictionary.format === "vue-i18n") return {
35
- ...dictionary,
36
- format: "vue-i18n",
37
- content: intlayerToVueI18nFormatter(dictionary.content)
38
- };
39
- return dictionary;
40
- };
41
- const formatDictionariesOutput = (dictionaries) => dictionaries.map(formatDictionaryOutput);
42
-
43
- //#endregion
44
- export { formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput };
1
+ import{i18nextToIntlayerFormatter as e,icuToIntlayerFormatter as t,intlayerToI18nextFormatter as n,intlayerToICUFormatter as r,intlayerToVueI18nFormatter as i,vueI18nToIntlayerFormatter as a}from"@intlayer/core/messageFormat";const o=n=>n.format===`icu`?{...n,format:`intlayer`,content:t(n.content)}:n.format===`i18next`?{...n,format:`intlayer`,content:e(n.content)}:n.format===`vue-i18n`?{...n,format:`intlayer`,content:a(n.content)}:n,s=e=>e.map(o),c=e=>e.format===`icu`?{...e,format:`icu`,content:r(e.content)}:e.format===`i18next`?{...e,format:`i18next`,content:n(e.content)}:e.format===`vue-i18n`?{...e,format:`vue-i18n`,content:i(e.content)}:e,l=e=>e.map(c);export{s as formatDictionaries,l as formatDictionariesOutput,o as formatDictionary,c as formatDictionaryOutput};
45
2
  //# sourceMappingURL=formatDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatDictionary.mjs","names":[],"sources":["../../src/formatDictionary.ts"],"sourcesContent":["import {\n i18nextToIntlayerFormatter,\n icuToIntlayerFormatter,\n intlayerToI18nextFormatter,\n intlayerToICUFormatter,\n intlayerToVueI18nFormatter,\n vueI18nToIntlayerFormatter,\n} from '@intlayer/core/messageFormat';\nimport type { Dictionary } from '@intlayer/types';\n\nexport const formatDictionary = (dictionary: Dictionary): Dictionary => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: icuToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: i18nextToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: vueI18nToIntlayerFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionaries = (dictionaries: Dictionary[]): Dictionary[] =>\n dictionaries.map(formatDictionary);\n\nexport const formatDictionaryOutput = (dictionary: Dictionary) => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'icu',\n content: intlayerToICUFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'i18next',\n content: intlayerToI18nextFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'vue-i18n',\n content: intlayerToVueI18nFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionariesOutput = (dictionaries: Dictionary[]) =>\n dictionaries.map(formatDictionaryOutput);\n"],"mappings":";;;AAUA,MAAa,oBAAoB,eAAuC;AACtE,KAAI,WAAW,WAAW,MACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,uBAAuB,WAAW,QAAQ;EACpD;AAGH,KAAI,WAAW,WAAW,UACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,KAAI,WAAW,WAAW,WACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,QAAO;;AAGT,MAAa,sBAAsB,iBACjC,aAAa,IAAI,iBAAiB;AAEpC,MAAa,0BAA0B,eAA2B;AAChE,KAAI,WAAW,WAAW,MACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,uBAAuB,WAAW,QAAQ;EACpD;AAGH,KAAI,WAAW,WAAW,UACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,KAAI,WAAW,WAAW,WACxB,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAAS,2BAA2B,WAAW,QAAQ;EACxD;AAGH,QAAO;;AAGT,MAAa,4BAA4B,iBACvC,aAAa,IAAI,uBAAuB"}
1
+ {"version":3,"file":"formatDictionary.mjs","names":[],"sources":["../../src/formatDictionary.ts"],"sourcesContent":["import {\n i18nextToIntlayerFormatter,\n icuToIntlayerFormatter,\n intlayerToI18nextFormatter,\n intlayerToICUFormatter,\n intlayerToVueI18nFormatter,\n vueI18nToIntlayerFormatter,\n} from '@intlayer/core/messageFormat';\nimport type { Dictionary } from '@intlayer/types';\n\nexport const formatDictionary = (dictionary: Dictionary): Dictionary => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: icuToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: i18nextToIntlayerFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'intlayer',\n content: vueI18nToIntlayerFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionaries = (dictionaries: Dictionary[]): Dictionary[] =>\n dictionaries.map(formatDictionary);\n\nexport const formatDictionaryOutput = (dictionary: Dictionary) => {\n if (dictionary.format === 'icu') {\n return {\n ...dictionary,\n format: 'icu',\n content: intlayerToICUFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'i18next') {\n return {\n ...dictionary,\n format: 'i18next',\n content: intlayerToI18nextFormatter(dictionary.content),\n };\n }\n\n if (dictionary.format === 'vue-i18n') {\n return {\n ...dictionary,\n format: 'vue-i18n',\n content: intlayerToVueI18nFormatter(dictionary.content),\n };\n }\n\n return dictionary;\n};\n\nexport const formatDictionariesOutput = (dictionaries: Dictionary[]) =>\n dictionaries.map(formatDictionaryOutput);\n"],"mappings":"kOAUA,MAAa,EAAoB,GAC3B,EAAW,SAAW,MACjB,CACL,GAAG,EACH,OAAQ,WACR,QAAS,EAAuB,EAAW,QAAQ,CACpD,CAGC,EAAW,SAAW,UACjB,CACL,GAAG,EACH,OAAQ,WACR,QAAS,EAA2B,EAAW,QAAQ,CACxD,CAGC,EAAW,SAAW,WACjB,CACL,GAAG,EACH,OAAQ,WACR,QAAS,EAA2B,EAAW,QAAQ,CACxD,CAGI,EAGI,EAAsB,GACjC,EAAa,IAAI,EAAiB,CAEvB,EAA0B,GACjC,EAAW,SAAW,MACjB,CACL,GAAG,EACH,OAAQ,MACR,QAAS,EAAuB,EAAW,QAAQ,CACpD,CAGC,EAAW,SAAW,UACjB,CACL,GAAG,EACH,OAAQ,UACR,QAAS,EAA2B,EAAW,QAAQ,CACxD,CAGC,EAAW,SAAW,WACjB,CACL,GAAG,EACH,OAAQ,WACR,QAAS,EAA2B,EAAW,QAAQ,CACxD,CAGI,EAGI,EAA4B,GACvC,EAAa,IAAI,EAAuB"}
@@ -1,38 +1,2 @@
1
- import { readAsset } from "../_virtual/_utils_asset.mjs";
2
- import { kebabCaseToCamelCase } from "@intlayer/config";
3
-
4
- //#region src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts
5
- const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) => {
6
- let fileTemplate;
7
- switch (format) {
8
- case "ts":
9
- fileTemplate = "./tsTemplate.txt";
10
- break;
11
- case "cjs":
12
- fileTemplate = "./cjsTemplate.txt";
13
- break;
14
- case "json":
15
- case "jsonc":
16
- case "json5":
17
- fileTemplate = "./jsonTemplate.txt";
18
- break;
19
- default:
20
- fileTemplate = "./esmTemplate.txt";
21
- break;
22
- }
23
- const fileContent = readAsset(fileTemplate);
24
- const camelCaseKey = kebabCaseToCamelCase(key);
25
- const nonCapitalizedCamelCaseKey = camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);
26
- const fileParamsString = Object.entries(fileParams).filter(([, value]) => value !== void 0).map(([key, value]) => {
27
- const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
28
- if (typeof value === "object") return `\n ${formattedKey}: ${JSON.stringify(value)},`;
29
- if (typeof value === "boolean" || typeof value === "number") return `\n ${formattedKey}: ${value},`;
30
- if (typeof value === "string") return `\n ${formattedKey}: ${JSON.stringify(value)},`;
31
- return `\n ${formattedKey}: ${value},`;
32
- }).join("");
33
- return fileContent.replace("{{key}}", key).replaceAll("{{name}}", nonCapitalizedCamelCaseKey).replace("{{fileParams}}", fileParamsString);
34
- };
35
-
36
- //#endregion
37
- export { getContentDeclarationFileTemplate };
1
+ import{readAsset as e}from"../_virtual/_utils_asset.mjs";import{kebabCaseToCamelCase as t}from"@intlayer/config/utils";const n=async(n,r,i={})=>{let a;switch(r){case`ts`:a=`./tsTemplate.txt`;break;case`cjs`:a=`./cjsTemplate.txt`;break;case`json`:case`jsonc`:case`json5`:a=`./jsonTemplate.txt`;break;default:a=`./esmTemplate.txt`;break}let o=e(a),s=t(n),c=s.charAt(0).toLowerCase()+s.slice(1),l=Object.entries(i).filter(([,e])=>e!==void 0).map(([e,t])=>{let n=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)?e:JSON.stringify(e);return typeof t==`object`?`\n ${n}: ${JSON.stringify(t)},`:typeof t==`boolean`||typeof t==`number`?`\n ${n}: ${t},`:typeof t==`string`?`\n ${n}: ${JSON.stringify(t)},`:`\n ${n}: ${t},`}).join(``);return o.replace(`{{key}}`,n).replaceAll(`{{name}}`,c).replace(`{{fileParams}}`,l)};export{n as getContentDeclarationFileTemplate};
38
2
  //# sourceMappingURL=getContentDeclarationFileTemplate.mjs.map