@intlayer/cli 8.4.4 → 8.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/dist/cjs/IntlayerEventListener.cjs +186 -1
  2. package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
  3. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  4. package/dist/cjs/_virtual/_utils_asset.cjs +98 -0
  5. package/dist/cjs/auth/login.cjs +90 -2
  6. package/dist/cjs/auth/login.cjs.map +1 -1
  7. package/dist/cjs/build.cjs +30 -1
  8. package/dist/cjs/build.cjs.map +1 -1
  9. package/dist/cjs/ci.cjs +76 -1
  10. package/dist/cjs/ci.cjs.map +1 -1
  11. package/dist/cjs/cli.cjs +485 -1
  12. package/dist/cjs/cli.cjs.map +1 -1
  13. package/dist/cjs/config.cjs +15 -1
  14. package/dist/cjs/config.cjs.map +1 -1
  15. package/dist/cjs/editor.cjs +50 -1
  16. package/dist/cjs/editor.cjs.map +1 -1
  17. package/dist/cjs/extract.cjs +108 -1
  18. package/dist/cjs/extract.cjs.map +1 -1
  19. package/dist/cjs/fill/deepMergeContent.cjs +27 -1
  20. package/dist/cjs/fill/deepMergeContent.cjs.map +1 -1
  21. package/dist/cjs/fill/fill.cjs +89 -1
  22. package/dist/cjs/fill/fill.cjs.map +1 -1
  23. package/dist/cjs/fill/formatAutoFilledFilePath.cjs +32 -1
  24. package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
  25. package/dist/cjs/fill/formatFillData.cjs +91 -1
  26. package/dist/cjs/fill/formatFillData.cjs.map +1 -1
  27. package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs +26 -1
  28. package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs.map +1 -1
  29. package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs +51 -1
  30. package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs.map +1 -1
  31. package/dist/cjs/fill/index.cjs +6 -1
  32. package/dist/cjs/fill/listTranslationsTasks.cjs +72 -1
  33. package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
  34. package/dist/cjs/fill/translateDictionary.cjs +241 -1
  35. package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
  36. package/dist/cjs/fill/writeFill.cjs +53 -1
  37. package/dist/cjs/fill/writeFill.cjs.map +1 -1
  38. package/dist/cjs/getTargetDictionary.cjs +36 -1
  39. package/dist/cjs/getTargetDictionary.cjs.map +1 -1
  40. package/dist/cjs/index.cjs +44 -1
  41. package/dist/cjs/init.cjs +22 -1
  42. package/dist/cjs/init.cjs.map +1 -1
  43. package/dist/cjs/initMCP.cjs +69 -1
  44. package/dist/cjs/initMCP.cjs.map +1 -1
  45. package/dist/cjs/initSkills.cjs +93 -1
  46. package/dist/cjs/initSkills.cjs.map +1 -1
  47. package/dist/cjs/listContentDeclaration.cjs +42 -1
  48. package/dist/cjs/listContentDeclaration.cjs.map +1 -1
  49. package/dist/cjs/listProjects.cjs +28 -1
  50. package/dist/cjs/listProjects.cjs.map +1 -1
  51. package/dist/cjs/liveSync.cjs +153 -8
  52. package/dist/cjs/liveSync.cjs.map +1 -1
  53. package/dist/cjs/pull.cjs +153 -1
  54. package/dist/cjs/pull.cjs.map +1 -1
  55. package/dist/cjs/push/pullLog.cjs +105 -3
  56. package/dist/cjs/push/pullLog.cjs.map +1 -1
  57. package/dist/cjs/push/push.cjs +212 -1
  58. package/dist/cjs/push/push.cjs.map +1 -1
  59. package/dist/cjs/pushConfig.cjs +22 -1
  60. package/dist/cjs/pushConfig.cjs.map +1 -1
  61. package/dist/cjs/pushLog.cjs +86 -3
  62. package/dist/cjs/pushLog.cjs.map +1 -1
  63. package/dist/cjs/reviewDoc/reviewDoc.cjs +73 -1
  64. package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
  65. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +98 -1
  66. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
  67. package/dist/cjs/searchDoc.cjs +41 -1
  68. package/dist/cjs/searchDoc.cjs.map +1 -1
  69. package/dist/cjs/test/index.cjs +7 -1
  70. package/dist/cjs/test/listMissingTranslations.cjs +66 -1
  71. package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
  72. package/dist/cjs/test/test.cjs +56 -1
  73. package/dist/cjs/test/test.cjs.map +1 -1
  74. package/dist/cjs/translateDoc/index.cjs +9 -1
  75. package/dist/cjs/translateDoc/translateDoc.cjs +79 -1
  76. package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
  77. package/dist/cjs/translateDoc/translateFile.cjs +106 -2
  78. package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
  79. package/dist/cjs/translateDoc/validation.cjs +49 -5
  80. package/dist/cjs/translateDoc/validation.cjs.map +1 -1
  81. package/dist/cjs/translation-alignment/alignBlocks.cjs +67 -1
  82. package/dist/cjs/translation-alignment/alignBlocks.cjs.map +1 -1
  83. package/dist/cjs/translation-alignment/computeSimilarity.cjs +25 -1
  84. package/dist/cjs/translation-alignment/computeSimilarity.cjs.map +1 -1
  85. package/dist/cjs/translation-alignment/fingerprintBlock.cjs +23 -1
  86. package/dist/cjs/translation-alignment/fingerprintBlock.cjs.map +1 -1
  87. package/dist/cjs/translation-alignment/index.cjs +22 -1
  88. package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs +18 -1
  89. package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs.map +1 -1
  90. package/dist/cjs/translation-alignment/normalizeBlock.cjs +22 -1
  91. package/dist/cjs/translation-alignment/normalizeBlock.cjs.map +1 -1
  92. package/dist/cjs/translation-alignment/pipeline.cjs +37 -1
  93. package/dist/cjs/translation-alignment/pipeline.cjs.map +1 -1
  94. package/dist/cjs/translation-alignment/planActions.cjs +46 -1
  95. package/dist/cjs/translation-alignment/planActions.cjs.map +1 -1
  96. package/dist/cjs/translation-alignment/rebuildDocument.cjs +49 -2
  97. package/dist/cjs/translation-alignment/rebuildDocument.cjs.map +1 -1
  98. package/dist/cjs/translation-alignment/segmentDocument.cjs +66 -5
  99. package/dist/cjs/translation-alignment/segmentDocument.cjs.map +1 -1
  100. package/dist/cjs/utils/calculateChunks.cjs +89 -2
  101. package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
  102. package/dist/cjs/utils/checkAccess.cjs +83 -1
  103. package/dist/cjs/utils/checkAccess.cjs.map +1 -1
  104. package/dist/cjs/utils/checkConfigConsistency.cjs +16 -1
  105. package/dist/cjs/utils/checkConfigConsistency.cjs.map +1 -1
  106. package/dist/cjs/utils/checkFileModifiedRange.cjs +81 -1
  107. package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
  108. package/dist/cjs/utils/checkLastUpdateTime.cjs +19 -1
  109. package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
  110. package/dist/cjs/utils/chunkInference.cjs +45 -1
  111. package/dist/cjs/utils/chunkInference.cjs.map +1 -1
  112. package/dist/cjs/utils/fixChunkStartEndChars.cjs +27 -3
  113. package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
  114. package/dist/cjs/utils/formatTimeDiff.cjs +20 -1
  115. package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
  116. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +16 -1
  117. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
  118. package/dist/cjs/utils/getOutputFilePath.cjs +108 -1
  119. package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
  120. package/dist/cjs/utils/getParentPackageJSON.cjs +20 -1
  121. package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
  122. package/dist/cjs/utils/listSpecialChars.cjs +54 -2
  123. package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
  124. package/dist/cjs/utils/mapChunksBetweenFiles.cjs +102 -1
  125. package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
  126. package/dist/cjs/utils/openBrowser.cjs +19 -1
  127. package/dist/cjs/utils/openBrowser.cjs.map +1 -1
  128. package/dist/cjs/utils/reorderParagraphs.cjs +91 -3
  129. package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
  130. package/dist/cjs/utils/setupAI.cjs +66 -1
  131. package/dist/cjs/utils/setupAI.cjs.map +1 -1
  132. package/dist/cjs/watch.cjs +47 -1
  133. package/dist/cjs/watch.cjs.map +1 -1
  134. package/dist/esm/IntlayerEventListener.mjs +183 -1
  135. package/dist/esm/IntlayerEventListener.mjs.map +1 -1
  136. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  137. package/dist/esm/_virtual/_utils_asset.mjs +97 -0
  138. package/dist/esm/auth/login.mjs +86 -2
  139. package/dist/esm/auth/login.mjs.map +1 -1
  140. package/dist/esm/build.mjs +28 -1
  141. package/dist/esm/build.mjs.map +1 -1
  142. package/dist/esm/ci.mjs +74 -1
  143. package/dist/esm/ci.mjs.map +1 -1
  144. package/dist/esm/cli.mjs +482 -1
  145. package/dist/esm/cli.mjs.map +1 -1
  146. package/dist/esm/config.mjs +13 -1
  147. package/dist/esm/config.mjs.map +1 -1
  148. package/dist/esm/editor.mjs +50 -1
  149. package/dist/esm/editor.mjs.map +1 -0
  150. package/dist/esm/extract.mjs +104 -1
  151. package/dist/esm/extract.mjs.map +1 -1
  152. package/dist/esm/fill/deepMergeContent.mjs +25 -1
  153. package/dist/esm/fill/deepMergeContent.mjs.map +1 -1
  154. package/dist/esm/fill/fill.mjs +86 -1
  155. package/dist/esm/fill/fill.mjs.map +1 -1
  156. package/dist/esm/fill/formatAutoFilledFilePath.mjs +30 -1
  157. package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
  158. package/dist/esm/fill/formatFillData.mjs +89 -1
  159. package/dist/esm/fill/formatFillData.mjs.map +1 -1
  160. package/dist/esm/fill/getAvailableLocalesInDictionary.mjs +24 -1
  161. package/dist/esm/fill/getAvailableLocalesInDictionary.mjs.map +1 -1
  162. package/dist/esm/fill/getFilterMissingContentPerLocale.mjs +49 -1
  163. package/dist/esm/fill/getFilterMissingContentPerLocale.mjs.map +1 -1
  164. package/dist/esm/fill/index.mjs +4 -1
  165. package/dist/esm/fill/listTranslationsTasks.mjs +69 -1
  166. package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
  167. package/dist/esm/fill/translateDictionary.mjs +238 -1
  168. package/dist/esm/fill/translateDictionary.mjs.map +1 -1
  169. package/dist/esm/fill/writeFill.mjs +51 -1
  170. package/dist/esm/fill/writeFill.mjs.map +1 -1
  171. package/dist/esm/getTargetDictionary.mjs +33 -1
  172. package/dist/esm/getTargetDictionary.mjs.map +1 -1
  173. package/dist/esm/index.mjs +20 -1
  174. package/dist/esm/init.mjs +19 -1
  175. package/dist/esm/init.mjs.map +1 -1
  176. package/dist/esm/initMCP.mjs +65 -1
  177. package/dist/esm/initMCP.mjs.map +1 -1
  178. package/dist/esm/initSkills.mjs +87 -1
  179. package/dist/esm/initSkills.mjs.map +1 -1
  180. package/dist/esm/listContentDeclaration.mjs +39 -1
  181. package/dist/esm/listContentDeclaration.mjs.map +1 -1
  182. package/dist/esm/listProjects.mjs +26 -1
  183. package/dist/esm/listProjects.mjs.map +1 -1
  184. package/dist/esm/liveSync.mjs +150 -8
  185. package/dist/esm/liveSync.mjs.map +1 -1
  186. package/dist/esm/pull.mjs +150 -1
  187. package/dist/esm/pull.mjs.map +1 -1
  188. package/dist/esm/push/pullLog.mjs +102 -3
  189. package/dist/esm/push/pullLog.mjs.map +1 -1
  190. package/dist/esm/push/push.mjs +208 -1
  191. package/dist/esm/push/push.mjs.map +1 -1
  192. package/dist/esm/pushConfig.mjs +20 -1
  193. package/dist/esm/pushConfig.mjs.map +1 -1
  194. package/dist/esm/pushLog.mjs +83 -3
  195. package/dist/esm/pushLog.mjs.map +1 -1
  196. package/dist/esm/reviewDoc/reviewDoc.mjs +69 -1
  197. package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
  198. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +95 -1
  199. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
  200. package/dist/esm/searchDoc.mjs +39 -1
  201. package/dist/esm/searchDoc.mjs.map +1 -1
  202. package/dist/esm/test/index.mjs +4 -1
  203. package/dist/esm/test/listMissingTranslations.mjs +63 -1
  204. package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
  205. package/dist/esm/test/test.mjs +53 -1
  206. package/dist/esm/test/test.mjs.map +1 -1
  207. package/dist/esm/translateDoc/index.mjs +5 -1
  208. package/dist/esm/translateDoc/translateDoc.mjs +75 -1
  209. package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
  210. package/dist/esm/translateDoc/translateFile.mjs +103 -2
  211. package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
  212. package/dist/esm/translateDoc/validation.mjs +46 -5
  213. package/dist/esm/translateDoc/validation.mjs.map +1 -1
  214. package/dist/esm/translation-alignment/alignBlocks.mjs +66 -1
  215. package/dist/esm/translation-alignment/alignBlocks.mjs.map +1 -1
  216. package/dist/esm/translation-alignment/computeSimilarity.mjs +22 -1
  217. package/dist/esm/translation-alignment/computeSimilarity.mjs.map +1 -1
  218. package/dist/esm/translation-alignment/fingerprintBlock.mjs +20 -1
  219. package/dist/esm/translation-alignment/fingerprintBlock.mjs.map +1 -1
  220. package/dist/esm/translation-alignment/index.mjs +11 -1
  221. package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs +16 -1
  222. package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs.map +1 -1
  223. package/dist/esm/translation-alignment/normalizeBlock.mjs +20 -1
  224. package/dist/esm/translation-alignment/normalizeBlock.mjs.map +1 -1
  225. package/dist/esm/translation-alignment/pipeline.mjs +35 -1
  226. package/dist/esm/translation-alignment/pipeline.mjs.map +1 -1
  227. package/dist/esm/translation-alignment/planActions.mjs +44 -1
  228. package/dist/esm/translation-alignment/planActions.mjs.map +1 -1
  229. package/dist/esm/translation-alignment/rebuildDocument.mjs +46 -2
  230. package/dist/esm/translation-alignment/rebuildDocument.mjs.map +1 -1
  231. package/dist/esm/translation-alignment/segmentDocument.mjs +64 -5
  232. package/dist/esm/translation-alignment/segmentDocument.mjs.map +1 -1
  233. package/dist/esm/utils/calculateChunks.mjs +87 -2
  234. package/dist/esm/utils/calculateChunks.mjs.map +1 -1
  235. package/dist/esm/utils/checkAccess.mjs +79 -1
  236. package/dist/esm/utils/checkAccess.mjs.map +1 -1
  237. package/dist/esm/utils/checkConfigConsistency.mjs +14 -1
  238. package/dist/esm/utils/checkConfigConsistency.mjs.map +1 -1
  239. package/dist/esm/utils/checkFileModifiedRange.mjs +80 -1
  240. package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
  241. package/dist/esm/utils/checkLastUpdateTime.mjs +17 -1
  242. package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
  243. package/dist/esm/utils/chunkInference.mjs +43 -1
  244. package/dist/esm/utils/chunkInference.mjs.map +1 -1
  245. package/dist/esm/utils/fixChunkStartEndChars.mjs +25 -3
  246. package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
  247. package/dist/esm/utils/formatTimeDiff.mjs +18 -1
  248. package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
  249. package/dist/esm/utils/getIsFileUpdatedRecently.mjs +14 -1
  250. package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
  251. package/dist/esm/utils/getOutputFilePath.mjs +104 -1
  252. package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
  253. package/dist/esm/utils/getParentPackageJSON.mjs +18 -1
  254. package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
  255. package/dist/esm/utils/listSpecialChars.mjs +52 -2
  256. package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
  257. package/dist/esm/utils/mapChunksBetweenFiles.mjs +100 -1
  258. package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
  259. package/dist/esm/utils/openBrowser.mjs +17 -1
  260. package/dist/esm/utils/openBrowser.mjs.map +1 -1
  261. package/dist/esm/utils/reorderParagraphs.mjs +90 -3
  262. package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
  263. package/dist/esm/utils/setupAI.mjs +63 -1
  264. package/dist/esm/utils/setupAI.mjs.map +1 -1
  265. package/dist/esm/watch.mjs +45 -1
  266. package/dist/esm/watch.mjs.map +1 -1
  267. package/dist/types/fill/fill.d.ts +1 -1
  268. package/dist/types/fill/fill.d.ts.map +1 -1
  269. package/dist/types/fill/formatFillData.d.ts.map +1 -1
  270. package/dist/types/fill/translateDictionary.d.ts +1 -1
  271. package/dist/types/getTargetDictionary.d.ts +19 -2
  272. package/dist/types/getTargetDictionary.d.ts.map +1 -0
  273. package/dist/types/index.d.ts +2 -2
  274. package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +1 -1
  275. package/dist/types/test/index.d.ts +2 -2
  276. package/dist/types/test/listMissingTranslations.d.ts +28 -2
  277. package/dist/types/test/listMissingTranslations.d.ts.map +1 -0
  278. package/dist/types/test/test.d.ts +11 -2
  279. package/dist/types/test/test.d.ts.map +1 -0
  280. package/dist/types/translateDoc/index.d.ts +1 -1
  281. package/dist/types/translateDoc/translateDoc.d.ts +1 -1
  282. package/dist/types/translateDoc/translateFile.d.ts +1 -1
  283. package/dist/types/translateDoc/types.d.ts +48 -2
  284. package/dist/types/translateDoc/types.d.ts.map +1 -0
  285. package/dist/types/utils/chunkInference.d.ts +1 -1
  286. package/dist/types/utils/getOutputFilePath.d.ts +18 -1
  287. package/dist/types/utils/getOutputFilePath.d.ts.map +1 -1
  288. package/dist/types/utils/setupAI.d.ts +21 -2
  289. package/dist/types/utils/setupAI.d.ts.map +1 -0
  290. package/package.json +12 -12
  291. package/dist/cjs/_utils_asset-ghp_Cjwk.cjs +0 -2
  292. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  293. package/dist/esm/_utils_asset-B187VPMw.mjs +0 -2
  294. package/dist/esm/editor-D8BGlLzF.mjs +0 -2
  295. package/dist/esm/editor-D8BGlLzF.mjs.map +0 -1
  296. package/dist/types/getTargetDictionary-RBSRtaQj.d.ts +0 -19
  297. package/dist/types/getTargetDictionary-RBSRtaQj.d.ts.map +0 -1
  298. package/dist/types/listMissingTranslations-DxKw7nqI.d.ts +0 -28
  299. package/dist/types/listMissingTranslations-DxKw7nqI.d.ts.map +0 -1
  300. package/dist/types/setupAI-Bosjx7ah.d.ts +0 -21
  301. package/dist/types/setupAI-Bosjx7ah.d.ts.map +0 -1
  302. package/dist/types/test-DUTiJR5_.d.ts +0 -11
  303. package/dist/types/test-DUTiJR5_.d.ts.map +0 -1
  304. package/dist/types/types-BKvc3FmV.d.ts +0 -48
  305. package/dist/types/types-BKvc3FmV.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fill.cjs","names":["ensureArray","setupAI","getTargetUnmergedDictionaries","ANSIColors","listTranslationsTasks","translateDictionary","writeFill"],"sources":["../../../src/fill/fill.ts"],"sourcesContent":["import { basename, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/chokidar/build';\nimport {\n type ListGitFilesOptions,\n logConfigDetails,\n} from '@intlayer/chokidar/cli';\nimport {\n formatPath,\n getGlobalLimiter,\n getTaskLimiter,\n} from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport {\n ensureArray,\n type GetTargetDictionaryOptions,\n getTargetUnmergedDictionaries,\n} from '../getTargetDictionary';\nimport { setupAI } from '../utils/setupAI';\nimport {\n listTranslationsTasks,\n type TranslationTask,\n} from './listTranslationsTasks';\nimport { translateDictionary } from './translateDictionary';\nimport { writeFill } from './writeFill';\n\nconst NB_CONCURRENT_TRANSLATIONS = 7;\n\n// Arguments for the fill function\nexport type FillOptions = {\n sourceLocale?: Locale;\n outputLocales?: Locale | Locale[];\n mode?: 'complete' | 'review';\n gitOptions?: ListGitFilesOptions;\n aiOptions?: AIOptions; // Added aiOptions to be passed to translateJSON\n verbose?: boolean;\n nbConcurrentTranslations?: number;\n nbConcurrentTasks?: number; // NEW: number of tasks that may run at once\n build?: boolean;\n skipMetadata?: boolean;\n} & GetTargetDictionaryOptions;\n\n/**\n * Fill translations based on the provided options.\n */\nexport const fill = async (options?: FillOptions): Promise<void> => {\n const configuration = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n if (options?.build === true) {\n await prepareIntlayer(configuration, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(configuration);\n }\n\n const { defaultLocale, locales } = configuration.internationalization;\n const mode = options?.mode ?? 'complete';\n const baseLocale = options?.sourceLocale ?? defaultLocale;\n\n const outputLocales = options?.outputLocales\n ? ensureArray(options.outputLocales)\n : locales;\n\n const aiResult = await setupAI(configuration, options?.aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n const targetUnmergedDictionaries =\n await getTargetUnmergedDictionaries(options);\n\n const affectedDictionaryKeys = new Set<string>();\n targetUnmergedDictionaries.forEach((dict) => {\n affectedDictionaryKeys.add(dict.key);\n });\n\n const keysToProcess = Array.from(affectedDictionaryKeys);\n\n appLogger([\n 'Affected dictionary keys for processing:',\n keysToProcess.length > 0\n ? keysToProcess.map((key) => colorizeKey(key)).join(', ')\n : colorize('No keys found', ANSIColors.YELLOW),\n ]);\n\n if (keysToProcess.length === 0) return;\n\n /**\n * List the translations tasks\n *\n * Create a list of per-locale dictionaries to translate\n *\n * In 'complete' mode, filter only the missing locales to translate\n */\n const translationTasks: TranslationTask[] = listTranslationsTasks(\n targetUnmergedDictionaries.map((dictionary) => dictionary.localId!),\n outputLocales,\n mode,\n baseLocale,\n configuration\n );\n\n // AI calls in flight at once (translateJSON + metadata audit)\n const nbConcurrentTranslations =\n options?.nbConcurrentTranslations ?? NB_CONCURRENT_TRANSLATIONS;\n const globalLimiter = getGlobalLimiter(nbConcurrentTranslations);\n\n // NEW: number of *tasks* that may run at once (start/prepare/log/write)\n const nbConcurrentTasks = Math.max(\n 1,\n Math.min(\n options?.nbConcurrentTasks ?? nbConcurrentTranslations,\n translationTasks.length\n )\n );\n\n const taskLimiter = getTaskLimiter(nbConcurrentTasks);\n\n const runners = translationTasks.map((task) =>\n taskLimiter(async () => {\n const relativePath = relative(\n configuration?.content?.baseDir ?? process.cwd(),\n task?.dictionaryFilePath ?? ''\n );\n\n // log AFTER acquiring a task slot\n appLogger(\n `${task.dictionaryPreset} Processing ${colorizePath(basename(relativePath))}`,\n { level: 'info' }\n );\n\n const translationTaskResult = await translateDictionary(\n task,\n configuration,\n {\n mode,\n aiOptions: options?.aiOptions,\n fillMetadata: !options?.skipMetadata,\n onHandle: globalLimiter, // <= AI calls go through here\n aiClient,\n aiConfig,\n }\n );\n\n if (!translationTaskResult?.dictionaryOutput) return;\n\n const { dictionaryOutput, sourceLocale } = translationTaskResult;\n\n // Determine if we should write to separate files\n // - If dictionary has explicit fill setting (string or object), use it\n // - If dictionary is per-locale AND has no explicit fill=false, use global fill config\n // - If dictionary is multilingual (no locale property), always write to same file\n const hasDictionaryLevelFill =\n typeof dictionaryOutput.fill === 'string' ||\n typeof dictionaryOutput.fill === 'object';\n\n const isPerLocale = typeof dictionaryOutput.locale === 'string';\n\n const effectiveFill = hasDictionaryLevelFill\n ? dictionaryOutput.fill\n : isPerLocale\n ? (configuration.dictionary?.fill ?? true)\n : false; // Multilingual dictionaries don't use fill by default\n\n const isFillOtherFile =\n typeof effectiveFill === 'string' || typeof effectiveFill === 'object';\n\n if (isFillOtherFile) {\n await writeFill(\n {\n ...dictionaryOutput,\n // Ensure fill is set on the dictionary for writeFill to use\n fill: effectiveFill,\n },\n outputLocales,\n [sourceLocale],\n configuration\n );\n } else {\n await writeContentDeclaration(dictionaryOutput, configuration);\n\n if (dictionaryOutput.filePath) {\n appLogger(\n `${task.dictionaryPreset} Content declaration written to ${formatPath(basename(dictionaryOutput.filePath))}`,\n { level: 'info' }\n );\n }\n }\n })\n );\n\n await Promise.all(runners);\n await (globalLimiter as any).onIdle();\n};\n"],"mappings":"wiBAqCA,MAmBa,EAAO,KAAO,IAAyC,CAClE,IAAM,GAAA,EAAA,EAAA,kBAAiC,GAAS,cAAc,EAC9D,EAAA,EAAA,kBAAiB,GAAS,cAAc,CAExC,IAAM,GAAA,EAAA,EAAA,cAAyB,EAAc,CAEzC,GAAS,QAAU,GACrB,MAAA,EAAA,EAAA,iBAAsB,EAAe,CAAE,SAAU,GAAM,CAAC,CACxC,GAAS,QAAU,QACnC,MAAA,EAAA,EAAA,iBAAsB,EAAc,CAGtC,GAAM,CAAE,gBAAe,WAAY,EAAc,qBAC3C,EAAO,GAAS,MAAQ,WACxB,EAAa,GAAS,cAAgB,EAEtC,EAAgB,GAAS,cAC3BA,EAAAA,YAAY,EAAQ,cAAc,CAClC,EAEE,EAAW,MAAMC,EAAAA,QAAQ,EAAe,GAAS,UAAU,CAEjE,GAAI,CAAC,GAAU,YAAa,OAE5B,GAAM,CAAE,WAAU,YAAa,EAEzB,EACJ,MAAMC,EAAAA,8BAA8B,EAAQ,CAExC,EAAyB,IAAI,IACnC,EAA2B,QAAS,GAAS,CAC3C,EAAuB,IAAI,EAAK,IAAI,EACpC,CAEF,IAAM,EAAgB,MAAM,KAAK,EAAuB,CASxD,GAPA,EAAU,CACR,2CACA,EAAc,OAAS,EACnB,EAAc,IAAK,IAAA,EAAA,EAAA,aAAoB,EAAI,CAAC,CAAC,KAAK,KAAK,EAAA,EAAA,EAAA,UAC9C,gBAAiBC,EAAW,OAAO,CACjD,CAAC,CAEE,EAAc,SAAW,EAAG,OAShC,IAAM,EAAsCC,EAAAA,sBAC1C,EAA2B,IAAK,GAAe,EAAW,QAAS,CACnE,EACA,EACA,EACA,EACD,CAGK,EACJ,GAAS,0BAA4B,EACjC,GAAA,EAAA,EAAA,kBAAiC,EAAyB,CAW1D,GAAA,EAAA,EAAA,gBARoB,KAAK,IAC7B,EACA,KAAK,IACH,GAAS,mBAAqB,EAC9B,EAAiB,OAClB,CACF,CAEoD,CAE/C,EAAU,EAAiB,IAAK,GACpC,EAAY,SAAY,CACtB,IAAM,GAAA,EAAA,EAAA,UACJ,GAAe,SAAS,SAAW,QAAQ,KAAK,CAChD,GAAM,oBAAsB,GAC7B,CAGD,EACE,GAAG,EAAK,iBAAiB,eAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UAAoC,EAAa,CAAC,GAC3E,CAAE,MAAO,OAAQ,CAClB,CAED,IAAM,EAAwB,MAAMC,EAAAA,oBAClC,EACA,EACA,CACE,OACA,UAAW,GAAS,UACpB,aAAc,CAAC,GAAS,aACxB,SAAU,EACV,WACA,WACD,CACF,CAED,GAAI,CAAC,GAAuB,iBAAkB,OAE9C,GAAM,CAAE,mBAAkB,gBAAiB,EAMrC,EACJ,OAAO,EAAiB,MAAS,UACjC,OAAO,EAAiB,MAAS,SAE7B,EAAc,OAAO,EAAiB,QAAW,SAEjD,EAAgB,EAClB,EAAiB,KACjB,EACG,EAAc,YAAY,MAAQ,GACnC,GAGJ,OAAO,GAAkB,UAAY,OAAO,GAAkB,SAG9D,MAAMC,EAAAA,UACJ,CACE,GAAG,EAEH,KAAM,EACP,CACD,EACA,CAAC,EAAa,CACd,EACD,EAED,MAAA,EAAA,EAAA,yBAA8B,EAAkB,EAAc,CAE1D,EAAiB,UACnB,EACE,GAAG,EAAK,iBAAiB,mCAAA,EAAA,EAAA,aAAA,EAAA,EAAA,UAAsD,EAAiB,SAAS,CAAC,GAC1G,CAAE,MAAO,OAAQ,CAClB,GAGL,CACH,CAED,MAAM,QAAQ,IAAI,EAAQ,CAC1B,MAAO,EAAsB,QAAQ"}
1
+ {"version":3,"file":"fill.cjs","names":["ensureArray","setupAI","getTargetUnmergedDictionaries","ANSIColors","listTranslationsTasks","translateDictionary","writeFill"],"sources":["../../../src/fill/fill.ts"],"sourcesContent":["import { basename, join, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n loadContentDeclarations,\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/chokidar/build';\nimport {\n type ListGitFilesOptions,\n logConfigDetails,\n} from '@intlayer/chokidar/cli';\nimport {\n formatPath,\n getGlobalLimiter,\n getTaskLimiter,\n} from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { Fill } from '@intlayer/types/dictionary';\nimport {\n ensureArray,\n type GetTargetDictionaryOptions,\n getTargetUnmergedDictionaries,\n} from '../getTargetDictionary';\nimport { setupAI } from '../utils/setupAI';\nimport {\n listTranslationsTasks,\n type TranslationTask,\n} from './listTranslationsTasks';\nimport { translateDictionary } from './translateDictionary';\nimport { writeFill } from './writeFill';\n\nconst NB_CONCURRENT_TRANSLATIONS = 7;\n\n// Arguments for the fill function\nexport type FillOptions = {\n sourceLocale?: Locale;\n outputLocales?: Locale | Locale[];\n mode?: 'complete' | 'review';\n gitOptions?: ListGitFilesOptions;\n aiOptions?: AIOptions; // Added aiOptions to be passed to translateJSON\n verbose?: boolean;\n nbConcurrentTranslations?: number;\n nbConcurrentTasks?: number; // NEW: number of tasks that may run at once\n build?: boolean;\n skipMetadata?: boolean;\n} & GetTargetDictionaryOptions;\n\n/**\n * Fill translations based on the provided options.\n */\nexport const fill = async (options?: FillOptions): Promise<void> => {\n const configuration = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n if (options?.build === true) {\n await prepareIntlayer(configuration, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(configuration);\n }\n\n const { defaultLocale, locales } = configuration.internationalization;\n const mode = options?.mode ?? 'complete';\n const baseLocale = options?.sourceLocale ?? defaultLocale;\n\n const outputLocales = options?.outputLocales\n ? ensureArray(options.outputLocales)\n : locales;\n\n const aiResult = await setupAI(configuration, options?.aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n const targetUnmergedDictionaries =\n await getTargetUnmergedDictionaries(options);\n\n // Load the original source content declaration files to recover function-type\n // `fill` values that are lost when dictionaries are JSON-serialised into\n // unmerged_dictionaries.cjs. Dictionary-level fill takes priority over the\n // config-level fill, but we can only know that by reading the source files.\n const uniqueSourcePaths = [\n ...new Set(\n targetUnmergedDictionaries\n .map((unmergedDictionary) => unmergedDictionary.filePath)\n .filter(Boolean) as string[]\n ),\n ];\n const sourceDictionaries = await loadContentDeclarations(\n uniqueSourcePaths.map((sourcePath) =>\n join(configuration.system.baseDir, sourcePath)\n ),\n configuration\n );\n // Map relative filePath → original fill value from the source file\n const originalFillByPath = new Map<string, Fill | undefined>();\n\n for (const dict of sourceDictionaries) {\n if (dict.filePath) {\n originalFillByPath.set(dict.filePath, dict.fill as Fill | undefined);\n }\n }\n\n const affectedDictionaryKeys = new Set<string>();\n targetUnmergedDictionaries.forEach((dict) => {\n affectedDictionaryKeys.add(dict.key);\n });\n\n const keysToProcess = Array.from(affectedDictionaryKeys);\n\n appLogger([\n 'Affected dictionary keys for processing:',\n keysToProcess.length > 0\n ? keysToProcess.map((key) => colorizeKey(key)).join(', ')\n : colorize('No keys found', ANSIColors.YELLOW),\n ]);\n\n if (keysToProcess.length === 0) return;\n\n /**\n * List the translations tasks\n *\n * Create a list of per-locale dictionaries to translate\n *\n * In 'complete' mode, filter only the missing locales to translate\n */\n const translationTasks: TranslationTask[] = listTranslationsTasks(\n targetUnmergedDictionaries.map((dictionary) => dictionary.localId!),\n outputLocales,\n mode,\n baseLocale,\n configuration\n );\n\n // AI calls in flight at once (translateJSON + metadata audit)\n const nbConcurrentTranslations =\n options?.nbConcurrentTranslations ?? NB_CONCURRENT_TRANSLATIONS;\n const globalLimiter = getGlobalLimiter(nbConcurrentTranslations);\n\n // NEW: number of *tasks* that may run at once (start/prepare/log/write)\n const nbConcurrentTasks = Math.max(\n 1,\n Math.min(\n options?.nbConcurrentTasks ?? nbConcurrentTranslations,\n translationTasks.length\n )\n );\n\n const taskLimiter = getTaskLimiter(nbConcurrentTasks);\n\n const runners = translationTasks.map((task) =>\n taskLimiter(async () => {\n const relativePath = relative(\n configuration?.system?.baseDir ?? process.cwd(),\n task?.dictionaryFilePath ?? ''\n );\n\n // log AFTER acquiring a task slot\n appLogger(\n `${task.dictionaryPreset} Processing ${colorizePath(basename(relativePath))}`,\n { level: 'info' }\n );\n\n const translationTaskResult = await translateDictionary(\n task,\n configuration,\n {\n mode,\n aiOptions: options?.aiOptions,\n fillMetadata: !options?.skipMetadata,\n onHandle: globalLimiter,\n aiClient,\n aiConfig,\n }\n );\n\n if (!translationTaskResult?.dictionaryOutput) return;\n\n const { dictionaryOutput, sourceLocale } = translationTaskResult;\n\n // Determine if we should write to separate files\n // - If dictionary has explicit fill setting (string, function, or object), use it\n // - If dictionary is per-locale AND has no explicit fill=false, use global fill config\n // - If dictionary is multilingual (no locale property), always write to same file\n //\n // NOTE: function-type fill values are lost during JSON serialisation of\n // unmerged_dictionaries.cjs. We recover them by checking the original\n // source file that was loaded above (originalFillByPath). Dictionary-level\n // fill always takes priority over config-level fill.\n const originalFill = originalFillByPath.get(\n dictionaryOutput.filePath ?? ''\n );\n\n // originalFill is undefined when the source file had no fill property; use\n // the (possibly JSON-preserved) dictionaryOutput.fill as a fallback so that\n // string/boolean fill values set directly on the dict still work.\n const dictFill: Fill | undefined =\n originalFill !== undefined ? originalFill : dictionaryOutput.fill;\n\n const hasDictionaryLevelFill =\n typeof dictFill === 'string' ||\n typeof dictFill === 'function' ||\n (typeof dictFill === 'object' && dictFill !== null);\n\n const isPerLocale = typeof dictionaryOutput.locale === 'string';\n\n const effectiveFill = hasDictionaryLevelFill\n ? dictFill\n : isPerLocale\n ? (configuration.dictionary?.fill ?? true)\n : (configuration.dictionary?.fill ?? false); // Multilingual dictionaries use config-level fill if set\n\n const isFillOtherFile =\n typeof effectiveFill === 'string' ||\n typeof effectiveFill === 'function' ||\n (typeof effectiveFill === 'object' && effectiveFill !== null);\n\n if (isFillOtherFile) {\n await writeFill(\n {\n ...dictionaryOutput,\n // Ensure fill is set on the dictionary for writeFill to use\n fill: effectiveFill,\n },\n outputLocales,\n [sourceLocale],\n configuration\n );\n } else {\n await writeContentDeclaration(dictionaryOutput, configuration);\n\n if (dictionaryOutput.filePath) {\n appLogger(\n `${task.dictionaryPreset} Content declaration written to ${formatPath(basename(dictionaryOutput.filePath))}`,\n { level: 'info' }\n );\n }\n }\n })\n );\n\n await Promise.all(runners);\n await (globalLimiter as any).onIdle();\n};\n"],"mappings":"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"}
@@ -1,2 +1,33 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`node:path`),t=require(`@intlayer/config/utils`);const n=async(n,r,i,a,o)=>{if(!n)throw Error(`autoFillField must be provided`);if(!r||typeof r!=`string`)throw Error(`dictionaryKey must be a non-empty string`);if(!i||typeof i!=`string`)throw Error(`dictionaryFilePath must be a non-empty string`);if(!a||typeof a!=`string`)throw Error(`baseDir must be a non-empty string`);let s=await(0,t.parseFilePathPattern)(n,{key:r,fileName:(0,e.basename)(i).split(`.`).slice(0,-2).join(`.`),locale:o}),c=(0,e.isAbsolute)(i)?i:(0,e.resolve)(a,i);if(s.startsWith(`./`)||s.startsWith(`../`))return(0,e.resolve)((0,e.dirname)(c),s);if((0,e.isAbsolute)(s)){let t=(0,e.normalize)(s),n=(0,e.normalize)(a);if(s.startsWith(`/`)&&!t.startsWith(n)){let t=(0,e.resolve)(a,s.substring(1));if(!s.startsWith(`/usr/`)&&!s.startsWith(`/etc/`)&&!s.startsWith(`/var/`)&&!s.startsWith(`/home/`)&&!s.startsWith(`/Users/`))return t}return t}return(0,e.normalize)(s)};exports.formatAutoFilledFilePath=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let node_path = require("node:path");
4
+ let _intlayer_config_utils = require("@intlayer/config/utils");
5
+
6
+ //#region src/fill/formatAutoFilledFilePath.ts
7
+ const formatAutoFilledFilePath = async (autoFillField, dictionaryKey, dictionaryFilePath, baseDir, locale) => {
8
+ if (!autoFillField) throw new Error("autoFillField must be provided");
9
+ if (!dictionaryKey || typeof dictionaryKey !== "string") throw new Error("dictionaryKey must be a non-empty string");
10
+ if (!dictionaryFilePath || typeof dictionaryFilePath !== "string") throw new Error("dictionaryFilePath must be a non-empty string");
11
+ if (!baseDir || typeof baseDir !== "string") throw new Error("baseDir must be a non-empty string");
12
+ const result = await (0, _intlayer_config_utils.parseFilePathPattern)(autoFillField, {
13
+ key: dictionaryKey,
14
+ fileName: (0, node_path.basename)(dictionaryFilePath).split(".").slice(0, -2).join("."),
15
+ locale
16
+ });
17
+ const absoluteDictionaryPath = (0, node_path.isAbsolute)(dictionaryFilePath) ? dictionaryFilePath : (0, node_path.resolve)(baseDir, dictionaryFilePath);
18
+ if (result.startsWith("./") || result.startsWith("../")) return (0, node_path.resolve)((0, node_path.dirname)(absoluteDictionaryPath), result);
19
+ if ((0, node_path.isAbsolute)(result)) {
20
+ const normalizedResult = (0, node_path.normalize)(result);
21
+ const normalizedBaseDir = (0, node_path.normalize)(baseDir);
22
+ if (result.startsWith("/") && !normalizedResult.startsWith(normalizedBaseDir)) {
23
+ const relativeToBase = (0, node_path.resolve)(baseDir, result.substring(1));
24
+ if (!result.startsWith("/usr/") && !result.startsWith("/etc/") && !result.startsWith("/var/") && !result.startsWith("/home/") && !result.startsWith("/Users/")) return relativeToBase;
25
+ }
26
+ return normalizedResult;
27
+ }
28
+ return (0, node_path.normalize)(result);
29
+ };
30
+
31
+ //#endregion
32
+ exports.formatAutoFilledFilePath = formatAutoFilledFilePath;
2
33
  //# sourceMappingURL=formatAutoFilledFilePath.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatAutoFilledFilePath.cjs","names":[],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":["import { basename, dirname, isAbsolute, normalize, resolve } from 'node:path';\nimport { parseFilePathPattern } from '@intlayer/config/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\n\nexport const formatAutoFilledFilePath = async (\n autoFillField: FilePathPattern,\n dictionaryKey: string,\n dictionaryFilePath: string,\n baseDir: string,\n locale?: Locale\n): Promise<string> => {\n // Validate inputs\n if (!autoFillField) {\n throw new Error('autoFillField must be provided');\n }\n if (!dictionaryKey || typeof dictionaryKey !== 'string') {\n throw new Error('dictionaryKey must be a non-empty string');\n }\n if (!dictionaryFilePath || typeof dictionaryFilePath !== 'string') {\n throw new Error('dictionaryFilePath must be a non-empty string');\n }\n if (!baseDir || typeof baseDir !== 'string') {\n throw new Error('baseDir must be a non-empty string');\n }\n\n // Extract the original filename without extensions (.content.ts -> dictionaryFieldEditor)\n const originalFileName = basename(dictionaryFilePath)\n .split('.')\n .slice(0, -2) // Remove last 2 extensions (.content.tsx)\n .join('.');\n\n // Replace placeholders in autoFillField\n const result: string = await parseFilePathPattern(autoFillField, {\n key: dictionaryKey,\n fileName: originalFileName,\n locale,\n });\n\n // Normalize the dictionary file path - if it's relative, make it absolute relative to baseDir\n const absoluteDictionaryPath = isAbsolute(dictionaryFilePath)\n ? dictionaryFilePath\n : resolve(baseDir, dictionaryFilePath);\n\n // Handle relative paths (starting with ./ or ../)\n if (result.startsWith('./') || result.startsWith('../')) {\n const fileDir = dirname(absoluteDictionaryPath);\n const resolvedPath = resolve(fileDir, result);\n\n return resolvedPath;\n }\n\n // Handle absolute paths\n if (isAbsolute(result)) {\n const normalizedResult = normalize(result);\n const normalizedBaseDir = normalize(baseDir);\n\n // Check if it's relative to baseDir (starts with /)\n // but not a system path (like /usr/local)\n if (\n result.startsWith('/') &&\n !normalizedResult.startsWith(normalizedBaseDir)\n ) {\n // Try to resolve it relative to baseDir first\n const relativeToBase = resolve(baseDir, result.substring(1));\n\n // If the path doesn't exist in common system directories, treat as relative to baseDir\n if (\n !result.startsWith('/usr/') &&\n !result.startsWith('/etc/') &&\n !result.startsWith('/var/') &&\n !result.startsWith('/home/') &&\n !result.startsWith('/Users/')\n ) {\n return relativeToBase;\n }\n }\n\n // It's a true system absolute path\n return normalizedResult;\n }\n\n // Default case: treat as relative to baseDir\n return normalize(result);\n};\n"],"mappings":"mKAKA,MAAa,EAA2B,MACtC,EACA,EACA,EACA,EACA,IACoB,CAEpB,GAAI,CAAC,EACH,MAAU,MAAM,iCAAiC,CAEnD,GAAI,CAAC,GAAiB,OAAO,GAAkB,SAC7C,MAAU,MAAM,2CAA2C,CAE7D,GAAI,CAAC,GAAsB,OAAO,GAAuB,SACvD,MAAU,MAAM,gDAAgD,CAElE,GAAI,CAAC,GAAW,OAAO,GAAY,SACjC,MAAU,MAAM,qCAAqC,CAUvD,IAAM,EAAiB,MAAA,EAAA,EAAA,sBAA2B,EAAe,CAC/D,IAAK,EACL,UAAA,EAAA,EAAA,UARgC,EAAmB,CAClD,MAAM,IAAI,CACV,MAAM,EAAG,GAAG,CACZ,KAAK,IAAI,CAMV,SACD,CAAC,CAGI,GAAA,EAAA,EAAA,YAAoC,EAAmB,CACzD,GAAA,EAAA,EAAA,SACQ,EAAS,EAAmB,CAGxC,GAAI,EAAO,WAAW,KAAK,EAAI,EAAO,WAAW,MAAM,CAIrD,OAAA,EAAA,EAAA,UAAA,EAAA,EAAA,SAHwB,EAAuB,CACT,EAAO,CAM/C,IAAA,EAAA,EAAA,YAAe,EAAO,CAAE,CACtB,IAAM,GAAA,EAAA,EAAA,WAA6B,EAAO,CACpC,GAAA,EAAA,EAAA,WAA8B,EAAQ,CAI5C,GACE,EAAO,WAAW,IAAI,EACtB,CAAC,EAAiB,WAAW,EAAkB,CAC/C,CAEA,IAAM,GAAA,EAAA,EAAA,SAAyB,EAAS,EAAO,UAAU,EAAE,CAAC,CAG5D,GACE,CAAC,EAAO,WAAW,QAAQ,EAC3B,CAAC,EAAO,WAAW,QAAQ,EAC3B,CAAC,EAAO,WAAW,QAAQ,EAC3B,CAAC,EAAO,WAAW,SAAS,EAC5B,CAAC,EAAO,WAAW,UAAU,CAE7B,OAAO,EAKX,OAAO,EAIT,OAAA,EAAA,EAAA,WAAiB,EAAO"}
1
+ {"version":3,"file":"formatAutoFilledFilePath.cjs","names":[],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":["import { basename, dirname, isAbsolute, normalize, resolve } from 'node:path';\nimport { parseFilePathPattern } from '@intlayer/config/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\n\nexport const formatAutoFilledFilePath = async (\n autoFillField: FilePathPattern,\n dictionaryKey: string,\n dictionaryFilePath: string,\n baseDir: string,\n locale?: Locale\n): Promise<string> => {\n // Validate inputs\n if (!autoFillField) {\n throw new Error('autoFillField must be provided');\n }\n if (!dictionaryKey || typeof dictionaryKey !== 'string') {\n throw new Error('dictionaryKey must be a non-empty string');\n }\n if (!dictionaryFilePath || typeof dictionaryFilePath !== 'string') {\n throw new Error('dictionaryFilePath must be a non-empty string');\n }\n if (!baseDir || typeof baseDir !== 'string') {\n throw new Error('baseDir must be a non-empty string');\n }\n\n // Extract the original filename without extensions (.content.ts -> dictionaryFieldEditor)\n const originalFileName = basename(dictionaryFilePath)\n .split('.')\n .slice(0, -2) // Remove last 2 extensions (.content.tsx)\n .join('.');\n\n // Replace placeholders in autoFillField\n const result: string = await parseFilePathPattern(autoFillField, {\n key: dictionaryKey,\n fileName: originalFileName,\n locale,\n });\n\n // Normalize the dictionary file path - if it's relative, make it absolute relative to baseDir\n const absoluteDictionaryPath = isAbsolute(dictionaryFilePath)\n ? dictionaryFilePath\n : resolve(baseDir, dictionaryFilePath);\n\n // Handle relative paths (starting with ./ or ../)\n if (result.startsWith('./') || result.startsWith('../')) {\n const fileDir = dirname(absoluteDictionaryPath);\n const resolvedPath = resolve(fileDir, result);\n\n return resolvedPath;\n }\n\n // Handle absolute paths\n if (isAbsolute(result)) {\n const normalizedResult = normalize(result);\n const normalizedBaseDir = normalize(baseDir);\n\n // Check if it's relative to baseDir (starts with /)\n // but not a system path (like /usr/local)\n if (\n result.startsWith('/') &&\n !normalizedResult.startsWith(normalizedBaseDir)\n ) {\n // Try to resolve it relative to baseDir first\n const relativeToBase = resolve(baseDir, result.substring(1));\n\n // If the path doesn't exist in common system directories, treat as relative to baseDir\n if (\n !result.startsWith('/usr/') &&\n !result.startsWith('/etc/') &&\n !result.startsWith('/var/') &&\n !result.startsWith('/home/') &&\n !result.startsWith('/Users/')\n ) {\n return relativeToBase;\n }\n }\n\n // It's a true system absolute path\n return normalizedResult;\n }\n\n // Default case: treat as relative to baseDir\n return normalize(result);\n};\n"],"mappings":";;;;;;AAKA,MAAa,2BAA2B,OACtC,eACA,eACA,oBACA,SACA,WACoB;AAEpB,KAAI,CAAC,cACH,OAAM,IAAI,MAAM,iCAAiC;AAEnD,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,sBAAsB,OAAO,uBAAuB,SACvD,OAAM,IAAI,MAAM,gDAAgD;AAElE,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,OAAM,IAAI,MAAM,qCAAqC;CAUvD,MAAM,SAAiB,uDAA2B,eAAe;EAC/D,KAAK;EACL,kCARgC,mBAAmB,CAClD,MAAM,IAAI,CACV,MAAM,GAAG,GAAG,CACZ,KAAK,IAAI;EAMV;EACD,CAAC;CAGF,MAAM,mDAAoC,mBAAmB,GACzD,4CACQ,SAAS,mBAAmB;AAGxC,KAAI,OAAO,WAAW,KAAK,IAAI,OAAO,WAAW,MAAM,CAIrD,sDAHwB,uBAAuB,EACT,OAAO;AAM/C,+BAAe,OAAO,EAAE;EACtB,MAAM,4CAA6B,OAAO;EAC1C,MAAM,6CAA8B,QAAQ;AAI5C,MACE,OAAO,WAAW,IAAI,IACtB,CAAC,iBAAiB,WAAW,kBAAkB,EAC/C;GAEA,MAAM,wCAAyB,SAAS,OAAO,UAAU,EAAE,CAAC;AAG5D,OACE,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,SAAS,IAC5B,CAAC,OAAO,WAAW,UAAU,CAE7B,QAAO;;AAKX,SAAO;;AAIT,iCAAiB,OAAO"}
@@ -1,2 +1,92 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`node:path`),t=require(`@intlayer/chokidar/utils`),n=require(`@intlayer/config/utils`);const r=async(r,i,a,o,s)=>{if(!r||typeof r==`boolean`)return[];let{baseDir:c}=s.system,{defaultLocale:l}=s.internationalization,u=(0,e.extname)(a),d=(0,e.basename)(a),f=d.includes(`.content.`)?d.split(`.content.`)[0]:d.split(`.`)[0],p=f.charAt(0).toLowerCase()+f.slice(1),m=(0,t.getFormatFromExtension)(u),h=(n,r)=>{let i=`json`;if(typeof r==`string`){let n=(0,t.getFormatFromExtension)((0,e.extname)(r));n&&(i=n)}return{key:o,componentDirPath:(0,e.relative)(c,(0,e.dirname)(a)),componentFileName:f,fileName:p,componentFormat:m,componentExtension:u,format:i,locale:n,extension:s.content.fileExtensions[0]}},g=async(e,r)=>{let i=`###########locale###########`,o=!1;if(typeof e==`string`?o=e.includes(`{{locale}}`):typeof e==`function`&&(o=(await e(h(i,e))).includes(i)),o){let i=[];for(let o of r){let r=(0,t.resolveRelativePath)(typeof e==`string`?(0,n.parseStringPattern)(e,h(o,e)):await e(h(o,e)),a,c);i.push({filePath:r,localeList:[o],isPerLocale:!0})}return i.reduce((e,t)=>{let n=e.find(e=>e.filePath===t.filePath);return n?(n.localeList.includes(t.localeList[0])||n.localeList.push(...t.localeList),n.isPerLocale=!1):e.push(t),e},[])}else return[{filePath:(0,t.resolveRelativePath)(typeof e==`string`?(0,n.parseStringPattern)(e,h(l,e)):await e(h(l,e)),a,c),localeList:r,isPerLocale:!1}]};if(typeof r==`object`&&r){let e=[];for(let t of i){let n=r[t];if(n&&typeof n!=`boolean`){let r=await g(n,[t]);e.push(...r)}}return e.reduce((e,t)=>{let n=e.find(e=>e.filePath===t.filePath);if(n){for(let e of t.localeList)n.localeList.includes(e)||n.localeList.push(e);n.isPerLocale=!1}else e.push(t);return e},[])}return typeof r==`string`||typeof r==`function`?g(r,i):[]};exports.formatFillData=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_utils_getOutputFilePath = require('../utils/getOutputFilePath.cjs');
4
+ let node_path = require("node:path");
5
+ let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
6
+
7
+ //#region src/fill/formatFillData.ts
8
+ /** Merge FillData entries that resolve to the same file path. */
9
+ const groupByFilePath = (entries) => entries.reduce((acc, curr) => {
10
+ const existing = acc.find((item) => item.filePath === curr.filePath);
11
+ if (existing) {
12
+ for (const loc of curr.localeList) if (!existing.localeList.includes(loc)) existing.localeList.push(loc);
13
+ existing.isPerLocale = false;
14
+ } else acc.push(curr);
15
+ return acc;
16
+ }, []);
17
+ const formatFillData = async (fillField, localeList, filePath, dictionaryKey, configuration) => {
18
+ if (!fillField || typeof fillField === "boolean") return [];
19
+ const { baseDir } = configuration.system;
20
+ const { defaultLocale } = configuration.internationalization;
21
+ const extension = (0, node_path.extname)(filePath);
22
+ const base = (0, node_path.basename)(filePath);
23
+ const cleanComponentFileName = base.includes(".content.") ? base.split(".content.")[0] : base.split(".")[0];
24
+ const uncapitalizedName = cleanComponentFileName.charAt(0).toLowerCase() + cleanComponentFileName.slice(1);
25
+ const componentFormat = (0, _intlayer_chokidar_utils.getFormatFromExtension)(extension);
26
+ const getContext = (locale, patternString) => {
27
+ let format = "json";
28
+ if (patternString) {
29
+ const extFormat = (0, _intlayer_chokidar_utils.getFormatFromExtension)((0, node_path.extname)(patternString));
30
+ if (extFormat) format = extFormat;
31
+ }
32
+ return {
33
+ key: dictionaryKey,
34
+ componentDirPath: (0, node_path.relative)(baseDir, (0, node_path.dirname)(filePath)),
35
+ componentFileName: cleanComponentFileName,
36
+ fileName: uncapitalizedName,
37
+ componentFormat,
38
+ componentExtension: extension,
39
+ format,
40
+ locale,
41
+ extension: configuration.content.fileExtensions[0]
42
+ };
43
+ };
44
+ /**
45
+ * Evaluate a scalar Fill pattern (string or function) for a list of locales.
46
+ *
47
+ * - Uses a dummy locale probe to detect whether the pattern varies per locale.
48
+ * - `forcePerLocale` overrides the probe for object-fill entries where each
49
+ * locale always maps to its own dedicated file regardless of whether the
50
+ * path itself contains the locale string.
51
+ */
52
+ const processPattern = async (pattern, locales, forcePerLocale = false) => {
53
+ const dummyLocale = "###########locale###########";
54
+ const patternString = typeof pattern === "string" ? pattern : void 0;
55
+ const dummyPath = await require_utils_getOutputFilePath.resolveOutputPattern(pattern, dummyLocale, getContext(dummyLocale, patternString), filePath, baseDir);
56
+ if (forcePerLocale || typeof dummyPath === "string" && dummyPath.includes(dummyLocale)) {
57
+ const resolvedPaths = [];
58
+ for (const locale of locales) {
59
+ const absolutePath = await require_utils_getOutputFilePath.resolveOutputPattern(pattern, locale, getContext(locale, patternString), filePath, baseDir);
60
+ if (absolutePath !== false) resolvedPaths.push({
61
+ filePath: absolutePath,
62
+ localeList: [locale],
63
+ isPerLocale: true
64
+ });
65
+ }
66
+ return groupByFilePath(resolvedPaths);
67
+ }
68
+ const absolutePath = await require_utils_getOutputFilePath.resolveOutputPattern(pattern, defaultLocale, getContext(defaultLocale, patternString), filePath, baseDir);
69
+ if (absolutePath === false) return [];
70
+ return [{
71
+ filePath: absolutePath,
72
+ localeList: locales,
73
+ isPerLocale: false
74
+ }];
75
+ };
76
+ if (typeof fillField === "object" && fillField !== null) {
77
+ const results = [];
78
+ for (const locale of localeList) {
79
+ const pattern = require_utils_getOutputFilePath.getPatternForLocale(fillField, locale);
80
+ if (pattern) {
81
+ const res = await processPattern(pattern, [locale], true);
82
+ results.push(...res);
83
+ }
84
+ }
85
+ return groupByFilePath(results);
86
+ }
87
+ return processPattern(fillField, localeList);
88
+ };
89
+
90
+ //#endregion
91
+ exports.formatFillData = formatFillData;
2
92
  //# sourceMappingURL=formatFillData.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatFillData.cjs","names":[],"sources":["../../../src/fill/formatFillData.ts"],"sourcesContent":["import { basename, dirname, extname, relative } from 'node:path';\nimport {\n getFormatFromExtension,\n resolveRelativePath,\n} from '@intlayer/chokidar/utils';\nimport { parseStringPattern } from '@intlayer/config/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { DictionaryKey, Fill } from '@intlayer/types/dictionary';\nimport type {\n FilePathPattern,\n FilePathPatternContext,\n} from '@intlayer/types/filePathPattern';\n\nexport type FillData = {\n localeList: Locale[];\n filePath: string;\n isPerLocale: boolean;\n};\n\nexport const formatFillData = async (\n fillField: Fill,\n localeList: Locale[],\n filePath: string,\n dictionaryKey: DictionaryKey,\n configuration: IntlayerConfig\n): Promise<FillData[]> => {\n if (!fillField || typeof fillField === 'boolean') return [];\n\n const { baseDir } = configuration.system;\n const { defaultLocale } = configuration.internationalization;\n\n const extension = extname(filePath);\n const base = basename(filePath);\n\n // Extract the original filename without extensions\n const cleanComponentFileName = base.includes('.content.')\n ? base.split('.content.')[0]\n : base.split('.')[0];\n\n const uncapitalizedName =\n cleanComponentFileName.charAt(0).toLowerCase() +\n cleanComponentFileName.slice(1);\n\n const componentFormat = getFormatFromExtension(extension);\n\n const getContext = (\n locale: Locale,\n patternType?: FilePathPattern\n ): FilePathPatternContext => {\n let format: FilePathPatternContext['format'] = 'json';\n if (typeof patternType === 'string') {\n const extFormat = getFormatFromExtension(extname(patternType) as any);\n if (extFormat) {\n format = extFormat as any;\n }\n }\n\n return {\n key: dictionaryKey,\n componentDirPath: relative(baseDir, dirname(filePath)),\n componentFileName: cleanComponentFileName,\n fileName: uncapitalizedName,\n componentFormat:\n componentFormat as FilePathPatternContext['componentFormat'],\n componentExtension:\n extension as FilePathPatternContext['componentExtension'],\n format,\n locale,\n extension: configuration.content.fileExtensions[0],\n };\n };\n\n const processPattern = async (\n pattern: FilePathPattern,\n locales: Locale[]\n ): Promise<FillData[]> => {\n const dummyLocale = '###########locale###########' as Locale;\n let isPatternPerLocale = false;\n\n if (typeof pattern === 'string') {\n isPatternPerLocale = pattern.includes('{{locale}}');\n } else if (typeof pattern === 'function') {\n const pathWithDummy = await pattern(getContext(dummyLocale, pattern));\n isPatternPerLocale = pathWithDummy.includes(dummyLocale);\n }\n\n if (isPatternPerLocale) {\n const resolvedPaths: FillData[] = [];\n\n // Generate one path per locale\n for (const locale of locales) {\n const rawPath =\n typeof pattern === 'string'\n ? parseStringPattern(pattern, getContext(locale, pattern))\n : await pattern(getContext(locale, pattern));\n\n const absolutePath = resolveRelativePath(rawPath, filePath, baseDir);\n\n resolvedPaths.push({\n filePath: absolutePath,\n localeList: [locale],\n isPerLocale: true,\n });\n }\n\n // Group by filePath in case multiple locales resolve to the same path\n const groupedByFilePath = resolvedPaths.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n if (!existing.localeList.includes(curr.localeList[0])) {\n existing.localeList.push(...curr.localeList);\n }\n // If multiple locales share a path, it's no longer strictly per-locale\n existing.isPerLocale = false;\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as FillData[]);\n\n return groupedByFilePath;\n } else {\n // Single multi-lingual path using default locale for pattern resolution\n const rawPath =\n typeof pattern === 'string'\n ? parseStringPattern(pattern, getContext(defaultLocale, pattern))\n : await pattern(getContext(defaultLocale, pattern));\n\n const absolutePath = resolveRelativePath(rawPath, filePath, baseDir);\n\n return [\n {\n filePath: absolutePath,\n localeList: locales,\n isPerLocale: false,\n },\n ];\n }\n };\n\n // Handle Record of Locales\n if (typeof fillField === 'object' && fillField !== null) {\n const results: FillData[] = [];\n\n for (const locale of localeList) {\n const pattern = (fillField as Record<string, any>)[locale];\n if (pattern && typeof pattern !== 'boolean') {\n const res = await processPattern(pattern as FilePathPattern, [locale]);\n results.push(...res);\n }\n }\n\n // Merge identical file paths if they stem from different locales having the same output path\n const grouped = results.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n for (const loc of curr.localeList) {\n if (!existing.localeList.includes(loc)) {\n existing.localeList.push(loc);\n }\n }\n existing.isPerLocale = false;\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as FillData[]);\n\n return grouped;\n }\n\n // Handle static string or function patterns\n if (typeof fillField === 'string' || typeof fillField === 'function') {\n return processPattern(fillField as FilePathPattern, localeList);\n }\n\n return [];\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"formatFillData.cjs","names":["resolveOutputPattern","getPatternForLocale"],"sources":["../../../src/fill/formatFillData.ts"],"sourcesContent":["import { basename, dirname, extname, relative } from 'node:path';\nimport { getFormatFromExtension } from '@intlayer/chokidar/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { DictionaryKey, Fill } from '@intlayer/types/dictionary';\nimport type { FilePathPatternContext } from '@intlayer/types/filePathPattern';\nimport {\n getPatternForLocale,\n resolveOutputPattern,\n} from '../utils/getOutputFilePath';\n\nexport type FillData = {\n localeList: Locale[];\n filePath: string;\n isPerLocale: boolean;\n};\n\n/** Merge FillData entries that resolve to the same file path. */\nconst groupByFilePath = (entries: FillData[]): FillData[] =>\n entries.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n for (const loc of curr.localeList) {\n if (!existing.localeList.includes(loc)) existing.localeList.push(loc);\n }\n // Multiple locales sharing one path → multilingual file\n existing.isPerLocale = false;\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as FillData[]);\n\nexport const formatFillData = async (\n fillField: Fill,\n localeList: Locale[],\n filePath: string,\n dictionaryKey: DictionaryKey,\n configuration: IntlayerConfig\n): Promise<FillData[]> => {\n if (!fillField || typeof fillField === 'boolean') return [];\n\n const { baseDir } = configuration.system;\n const { defaultLocale } = configuration.internationalization;\n\n const extension = extname(filePath);\n const base = basename(filePath);\n const cleanComponentFileName = base.includes('.content.')\n ? base.split('.content.')[0]\n : base.split('.')[0];\n const uncapitalizedName =\n cleanComponentFileName.charAt(0).toLowerCase() +\n cleanComponentFileName.slice(1);\n const componentFormat = getFormatFromExtension(extension);\n\n const getContext = (\n locale: Locale,\n patternString?: string\n ): FilePathPatternContext => {\n let format: FilePathPatternContext['format'] = 'json';\n if (patternString) {\n const extFormat = getFormatFromExtension(extname(patternString) as any);\n if (extFormat) format = extFormat as any;\n }\n return {\n key: dictionaryKey,\n componentDirPath: relative(baseDir, dirname(filePath)),\n componentFileName: cleanComponentFileName,\n fileName: uncapitalizedName,\n componentFormat:\n componentFormat as FilePathPatternContext['componentFormat'],\n componentExtension:\n extension as FilePathPatternContext['componentExtension'],\n format,\n locale,\n extension: configuration.content.fileExtensions[0],\n };\n };\n\n /**\n * Evaluate a scalar Fill pattern (string or function) for a list of locales.\n *\n * - Uses a dummy locale probe to detect whether the pattern varies per locale.\n * - `forcePerLocale` overrides the probe for object-fill entries where each\n * locale always maps to its own dedicated file regardless of whether the\n * path itself contains the locale string.\n */\n const processPattern = async (\n pattern: Fill,\n locales: Locale[],\n forcePerLocale = false\n ): Promise<FillData[]> => {\n const dummyLocale = '###########locale###########' as Locale;\n const patternString = typeof pattern === 'string' ? pattern : undefined;\n\n const dummyPath = await resolveOutputPattern(\n pattern,\n dummyLocale,\n getContext(dummyLocale, patternString),\n filePath,\n baseDir\n );\n const isPatternPerLocale =\n forcePerLocale ||\n (typeof dummyPath === 'string' && dummyPath.includes(dummyLocale));\n\n if (isPatternPerLocale) {\n const resolvedPaths: FillData[] = [];\n for (const locale of locales) {\n const absolutePath = await resolveOutputPattern(\n pattern,\n locale,\n getContext(locale, patternString),\n filePath,\n baseDir\n );\n if (absolutePath !== false) {\n resolvedPaths.push({\n filePath: absolutePath,\n localeList: [locale],\n isPerLocale: true,\n });\n }\n }\n return groupByFilePath(resolvedPaths);\n }\n\n // Single multilingual path resolve using the default locale for context\n const absolutePath = await resolveOutputPattern(\n pattern,\n defaultLocale as Locale,\n getContext(defaultLocale as Locale, patternString),\n filePath,\n baseDir\n );\n if (absolutePath === false) return [];\n return [\n { filePath: absolutePath, localeList: locales, isPerLocale: false },\n ];\n };\n\n // Object fill: each locale key maps to its own pattern.\n // Object fill entries are always per-locale in intent (each locale → its own file).\n if (typeof fillField === 'object' && fillField !== null) {\n const results: FillData[] = [];\n for (const locale of localeList) {\n const pattern = getPatternForLocale(fillField, locale);\n if (pattern) {\n const res = await processPattern(pattern, [locale], true);\n results.push(...res);\n }\n }\n return groupByFilePath(results);\n }\n\n // Scalar string or function pattern\n return processPattern(fillField, localeList);\n};\n"],"mappings":";;;;;;;;AAkBA,MAAM,mBAAmB,YACvB,QAAQ,QAAQ,KAAK,SAAS;CAC5B,MAAM,WAAW,IAAI,MAAM,SAAS,KAAK,aAAa,KAAK,SAAS;AACpE,KAAI,UAAU;AACZ,OAAK,MAAM,OAAO,KAAK,WACrB,KAAI,CAAC,SAAS,WAAW,SAAS,IAAI,CAAE,UAAS,WAAW,KAAK,IAAI;AAGvE,WAAS,cAAc;OAEvB,KAAI,KAAK,KAAK;AAEhB,QAAO;GACN,EAAE,CAAe;AAEtB,MAAa,iBAAiB,OAC5B,WACA,YACA,UACA,eACA,kBACwB;AACxB,KAAI,CAAC,aAAa,OAAO,cAAc,UAAW,QAAO,EAAE;CAE3D,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,kBAAkB,cAAc;CAExC,MAAM,mCAAoB,SAAS;CACnC,MAAM,+BAAgB,SAAS;CAC/B,MAAM,yBAAyB,KAAK,SAAS,YAAY,GACrD,KAAK,MAAM,YAAY,CAAC,KACxB,KAAK,MAAM,IAAI,CAAC;CACpB,MAAM,oBACJ,uBAAuB,OAAO,EAAE,CAAC,aAAa,GAC9C,uBAAuB,MAAM,EAAE;CACjC,MAAM,uEAAyC,UAAU;CAEzD,MAAM,cACJ,QACA,kBAC2B;EAC3B,IAAI,SAA2C;AAC/C,MAAI,eAAe;GACjB,MAAM,wFAA2C,cAAc,CAAQ;AACvE,OAAI,UAAW,UAAS;;AAE1B,SAAO;GACL,KAAK;GACL,0CAA2B,gCAAiB,SAAS,CAAC;GACtD,mBAAmB;GACnB,UAAU;GAER;GACF,oBACE;GACF;GACA;GACA,WAAW,cAAc,QAAQ,eAAe;GACjD;;;;;;;;;;CAWH,MAAM,iBAAiB,OACrB,SACA,SACA,iBAAiB,UACO;EACxB,MAAM,cAAc;EACpB,MAAM,gBAAgB,OAAO,YAAY,WAAW,UAAU;EAE9D,MAAM,YAAY,MAAMA,qDACtB,SACA,aACA,WAAW,aAAa,cAAc,EACtC,UACA,QACD;AAKD,MAHE,kBACC,OAAO,cAAc,YAAY,UAAU,SAAS,YAAY,EAE3C;GACtB,MAAM,gBAA4B,EAAE;AACpC,QAAK,MAAM,UAAU,SAAS;IAC5B,MAAM,eAAe,MAAMA,qDACzB,SACA,QACA,WAAW,QAAQ,cAAc,EACjC,UACA,QACD;AACD,QAAI,iBAAiB,MACnB,eAAc,KAAK;KACjB,UAAU;KACV,YAAY,CAAC,OAAO;KACpB,aAAa;KACd,CAAC;;AAGN,UAAO,gBAAgB,cAAc;;EAIvC,MAAM,eAAe,MAAMA,qDACzB,SACA,eACA,WAAW,eAAyB,cAAc,EAClD,UACA,QACD;AACD,MAAI,iBAAiB,MAAO,QAAO,EAAE;AACrC,SAAO,CACL;GAAE,UAAU;GAAc,YAAY;GAAS,aAAa;GAAO,CACpE;;AAKH,KAAI,OAAO,cAAc,YAAY,cAAc,MAAM;EACvD,MAAM,UAAsB,EAAE;AAC9B,OAAK,MAAM,UAAU,YAAY;GAC/B,MAAM,UAAUC,oDAAoB,WAAW,OAAO;AACtD,OAAI,SAAS;IACX,MAAM,MAAM,MAAM,eAAe,SAAS,CAAC,OAAO,EAAE,KAAK;AACzD,YAAQ,KAAK,GAAG,IAAI;;;AAGxB,SAAO,gBAAgB,QAAQ;;AAIjC,QAAO,eAAe,WAAW,WAAW"}
@@ -1,2 +1,27 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=(t,n=new Set)=>{if(!t||typeof t!=`object`)return n;t.nodeType===`translation`&&t.translation&&Object.keys(t.translation).forEach(e=>{n.add(e)});for(let r of Object.values(t))r&&typeof r==`object`&&e(r,n);return n},t=t=>{let n=e(t.content);return Array.from(n)};exports.getAvailableLocalesInDictionary=t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/fill/getAvailableLocalesInDictionary.ts
4
+ /**
5
+ * Recursively traverses dictionary content to find all locales that have actual translations.
6
+ * Returns a Set of locale strings that are present in the translation nodes.
7
+ */
8
+ const extractLocalesFromContent = (content, locales = /* @__PURE__ */ new Set()) => {
9
+ if (!content || typeof content !== "object") return locales;
10
+ if (content.nodeType === "translation" && content.translation) Object.keys(content.translation).forEach((locale) => {
11
+ locales.add(locale);
12
+ });
13
+ for (const value of Object.values(content)) if (value && typeof value === "object") extractLocalesFromContent(value, locales);
14
+ return locales;
15
+ };
16
+ /**
17
+ * Gets all locales that have actual translations in the dictionary content.
18
+ * Only returns locales that are present in at least one translation node.
19
+ */
20
+ const getAvailableLocalesInDictionary = (dictionary) => {
21
+ const localesSet = extractLocalesFromContent(dictionary.content);
22
+ return Array.from(localesSet);
23
+ };
24
+
25
+ //#endregion
26
+ exports.getAvailableLocalesInDictionary = getAvailableLocalesInDictionary;
2
27
  //# sourceMappingURL=getAvailableLocalesInDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getAvailableLocalesInDictionary.cjs","names":[],"sources":["../../../src/fill/getAvailableLocalesInDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type { Locale } from '@intlayer/types/allLocales';\n\n/**\n * Recursively traverses dictionary content to find all locales that have actual translations.\n * Returns a Set of locale strings that are present in the translation nodes.\n */\nconst extractLocalesFromContent = (\n content: any,\n locales: Set<Locale> = new Set()\n): Set<Locale> => {\n if (!content || typeof content !== 'object') {\n return locales;\n }\n\n // Check if this is a translation node\n if (content.nodeType === 'translation' && content.translation) {\n // Add all locale keys from the translation map\n Object.keys(content.translation).forEach((locale) => {\n locales.add(locale as Locale);\n });\n }\n\n // Recursively check nested objects\n for (const value of Object.values(content)) {\n if (value && typeof value === 'object') {\n extractLocalesFromContent(value, locales);\n }\n }\n\n return locales;\n};\n\n/**\n * Gets all locales that have actual translations in the dictionary content.\n * Only returns locales that are present in at least one translation node.\n */\nexport const getAvailableLocalesInDictionary = (\n dictionary: Dictionary\n): Locale[] => {\n const localesSet = extractLocalesFromContent(dictionary.content);\n return Array.from(localesSet);\n};\n"],"mappings":"mEAOA,MAAM,GACJ,EACA,EAAuB,IAAI,MACX,CAChB,GAAI,CAAC,GAAW,OAAO,GAAY,SACjC,OAAO,EAIL,EAAQ,WAAa,eAAiB,EAAQ,aAEhD,OAAO,KAAK,EAAQ,YAAY,CAAC,QAAS,GAAW,CACnD,EAAQ,IAAI,EAAiB,EAC7B,CAIJ,IAAK,IAAM,KAAS,OAAO,OAAO,EAAQ,CACpC,GAAS,OAAO,GAAU,UAC5B,EAA0B,EAAO,EAAQ,CAI7C,OAAO,GAOI,EACX,GACa,CACb,IAAM,EAAa,EAA0B,EAAW,QAAQ,CAChE,OAAO,MAAM,KAAK,EAAW"}
1
+ {"version":3,"file":"getAvailableLocalesInDictionary.cjs","names":[],"sources":["../../../src/fill/getAvailableLocalesInDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type { Locale } from '@intlayer/types/allLocales';\n\n/**\n * Recursively traverses dictionary content to find all locales that have actual translations.\n * Returns a Set of locale strings that are present in the translation nodes.\n */\nconst extractLocalesFromContent = (\n content: any,\n locales: Set<Locale> = new Set()\n): Set<Locale> => {\n if (!content || typeof content !== 'object') {\n return locales;\n }\n\n // Check if this is a translation node\n if (content.nodeType === 'translation' && content.translation) {\n // Add all locale keys from the translation map\n Object.keys(content.translation).forEach((locale) => {\n locales.add(locale as Locale);\n });\n }\n\n // Recursively check nested objects\n for (const value of Object.values(content)) {\n if (value && typeof value === 'object') {\n extractLocalesFromContent(value, locales);\n }\n }\n\n return locales;\n};\n\n/**\n * Gets all locales that have actual translations in the dictionary content.\n * Only returns locales that are present in at least one translation node.\n */\nexport const getAvailableLocalesInDictionary = (\n dictionary: Dictionary\n): Locale[] => {\n const localesSet = extractLocalesFromContent(dictionary.content);\n return Array.from(localesSet);\n};\n"],"mappings":";;;;;;;AAOA,MAAM,6BACJ,SACA,0BAAuB,IAAI,KAAK,KAChB;AAChB,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,QAAO;AAIT,KAAI,QAAQ,aAAa,iBAAiB,QAAQ,YAEhD,QAAO,KAAK,QAAQ,YAAY,CAAC,SAAS,WAAW;AACnD,UAAQ,IAAI,OAAiB;GAC7B;AAIJ,MAAK,MAAM,SAAS,OAAO,OAAO,QAAQ,CACxC,KAAI,SAAS,OAAO,UAAU,SAC5B,2BAA0B,OAAO,QAAQ;AAI7C,QAAO;;;;;;AAOT,MAAa,mCACX,eACa;CACb,MAAM,aAAa,0BAA0B,WAAW,QAAQ;AAChE,QAAO,MAAM,KAAK,WAAW"}
@@ -1,2 +1,52 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=(t,n)=>{if(t===null)return n===null?void 0:null;if(n==null)return t;if(typeof t!=`object`)return;if(Array.isArray(t)){if(!Array.isArray(n))return t;let r=t.map((t,r)=>e(t,n[r])).filter(e=>e!==void 0);return r.length>0?r:void 0}let r={},i=!1;for(let[a,o]of Object.entries(t)){let t=n?.[a],s=e(o,t);s!==void 0&&(r[a]=s,i=!0)}return i?r:void 0},t=(t,n)=>{if(!n||!n.content)return t;let r=e(t.content,n.content);return{...t,content:r??{}}};exports.getFilterMissingContentPerLocale=t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/fill/getFilterMissingContentPerLocale.ts
4
+ /**
5
+ * Recursively compares source content with target content and returns only the missing parts.
6
+ * For per-locale files where content is simple JSON (not translation nodes).
7
+ *
8
+ * @param sourceContent - The source content to check
9
+ * @param targetContent - The existing target content
10
+ * @returns Only the content that's missing in the target
11
+ */
12
+ const filterMissingContent = (sourceContent, targetContent) => {
13
+ if (sourceContent === null) return targetContent === null ? void 0 : null;
14
+ if (targetContent === void 0 || targetContent === null) return sourceContent;
15
+ if (typeof sourceContent !== "object") return;
16
+ if (Array.isArray(sourceContent)) {
17
+ if (!Array.isArray(targetContent)) return sourceContent;
18
+ const missingItems = sourceContent.map((item, index) => filterMissingContent(item, targetContent[index])).filter((item) => item !== void 0);
19
+ return missingItems.length > 0 ? missingItems : void 0;
20
+ }
21
+ const result = {};
22
+ let hasMissingContent = false;
23
+ for (const [key, value] of Object.entries(sourceContent)) {
24
+ const targetValue = targetContent?.[key];
25
+ const missingValue = filterMissingContent(value, targetValue);
26
+ if (missingValue !== void 0) {
27
+ result[key] = missingValue;
28
+ hasMissingContent = true;
29
+ }
30
+ }
31
+ return hasMissingContent ? result : void 0;
32
+ };
33
+ /**
34
+ * Filters a dictionary to only include content that's missing in the target dictionary.
35
+ * Used for per-locale content declarations in 'complete' mode.
36
+ *
37
+ * @param sourceDictionary - The source dictionary with content to translate
38
+ * @param targetDictionary - The existing target dictionary
39
+ * @returns A dictionary with only the missing content
40
+ */
41
+ const getFilterMissingContentPerLocale = (sourceDictionary, targetDictionary) => {
42
+ if (!targetDictionary || !targetDictionary.content) return sourceDictionary;
43
+ const missingContent = filterMissingContent(sourceDictionary.content, targetDictionary.content);
44
+ return {
45
+ ...sourceDictionary,
46
+ content: missingContent ?? {}
47
+ };
48
+ };
49
+
50
+ //#endregion
51
+ exports.getFilterMissingContentPerLocale = getFilterMissingContentPerLocale;
2
52
  //# sourceMappingURL=getFilterMissingContentPerLocale.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getFilterMissingContentPerLocale.cjs","names":[],"sources":["../../../src/fill/getFilterMissingContentPerLocale.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * Recursively compares source content with target content and returns only the missing parts.\n * For per-locale files where content is simple JSON (not translation nodes).\n *\n * @param sourceContent - The source content to check\n * @param targetContent - The existing target content\n * @returns Only the content that's missing in the target\n */\nconst filterMissingContent = (sourceContent: any, targetContent: any): any => {\n // Source is null - only missing if target doesn't already have null\n if (sourceContent === null) {\n return targetContent === null ? undefined : null;\n }\n\n // If target doesn't exist or is null, all source content is missing\n if (targetContent === undefined || targetContent === null) {\n return sourceContent;\n }\n\n // Primitive values: if target exists (even if empty string), consider it translated\n if (typeof sourceContent !== 'object') {\n return undefined;\n }\n\n // Handle arrays\n if (Array.isArray(sourceContent)) {\n if (!Array.isArray(targetContent)) {\n return sourceContent;\n }\n\n const missingItems = sourceContent\n .map((item, index) => filterMissingContent(item, targetContent[index]))\n .filter((item) => item !== undefined);\n\n return missingItems.length > 0 ? missingItems : undefined;\n }\n\n // Handle objects\n const result: any = {};\n let hasMissingContent = false;\n\n for (const [key, value] of Object.entries(sourceContent)) {\n const targetValue = targetContent?.[key];\n const missingValue = filterMissingContent(value, targetValue);\n\n if (missingValue !== undefined) {\n result[key] = missingValue;\n hasMissingContent = true;\n }\n }\n\n return hasMissingContent ? result : undefined;\n};\n\n/**\n * Filters a dictionary to only include content that's missing in the target dictionary.\n * Used for per-locale content declarations in 'complete' mode.\n *\n * @param sourceDictionary - The source dictionary with content to translate\n * @param targetDictionary - The existing target dictionary\n * @returns A dictionary with only the missing content\n */\nexport const getFilterMissingContentPerLocale = (\n sourceDictionary: Dictionary,\n targetDictionary: Dictionary | undefined\n): Dictionary => {\n if (!targetDictionary || !targetDictionary.content) {\n // If no target exists, all source content is missing\n return sourceDictionary;\n }\n\n const missingContent = filterMissingContent(\n sourceDictionary.content,\n targetDictionary.content\n );\n\n return {\n ...sourceDictionary,\n content: missingContent ?? {},\n };\n};\n"],"mappings":"mEAUA,MAAM,GAAwB,EAAoB,IAA4B,CAE5E,GAAI,IAAkB,KACpB,OAAO,IAAkB,KAAO,IAAA,GAAY,KAI9C,GAAI,GAAiD,KACnD,OAAO,EAIT,GAAI,OAAO,GAAkB,SAC3B,OAIF,GAAI,MAAM,QAAQ,EAAc,CAAE,CAChC,GAAI,CAAC,MAAM,QAAQ,EAAc,CAC/B,OAAO,EAGT,IAAM,EAAe,EAClB,KAAK,EAAM,IAAU,EAAqB,EAAM,EAAc,GAAO,CAAC,CACtE,OAAQ,GAAS,IAAS,IAAA,GAAU,CAEvC,OAAO,EAAa,OAAS,EAAI,EAAe,IAAA,GAIlD,IAAM,EAAc,EAAE,CAClB,EAAoB,GAExB,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAc,CAAE,CACxD,IAAM,EAAc,IAAgB,GAC9B,EAAe,EAAqB,EAAO,EAAY,CAEzD,IAAiB,IAAA,KACnB,EAAO,GAAO,EACd,EAAoB,IAIxB,OAAO,EAAoB,EAAS,IAAA,IAWzB,GACX,EACA,IACe,CACf,GAAI,CAAC,GAAoB,CAAC,EAAiB,QAEzC,OAAO,EAGT,IAAM,EAAiB,EACrB,EAAiB,QACjB,EAAiB,QAClB,CAED,MAAO,CACL,GAAG,EACH,QAAS,GAAkB,EAAE,CAC9B"}
1
+ {"version":3,"file":"getFilterMissingContentPerLocale.cjs","names":[],"sources":["../../../src/fill/getFilterMissingContentPerLocale.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * Recursively compares source content with target content and returns only the missing parts.\n * For per-locale files where content is simple JSON (not translation nodes).\n *\n * @param sourceContent - The source content to check\n * @param targetContent - The existing target content\n * @returns Only the content that's missing in the target\n */\nconst filterMissingContent = (sourceContent: any, targetContent: any): any => {\n // Source is null - only missing if target doesn't already have null\n if (sourceContent === null) {\n return targetContent === null ? undefined : null;\n }\n\n // If target doesn't exist or is null, all source content is missing\n if (targetContent === undefined || targetContent === null) {\n return sourceContent;\n }\n\n // Primitive values: if target exists (even if empty string), consider it translated\n if (typeof sourceContent !== 'object') {\n return undefined;\n }\n\n // Handle arrays\n if (Array.isArray(sourceContent)) {\n if (!Array.isArray(targetContent)) {\n return sourceContent;\n }\n\n const missingItems = sourceContent\n .map((item, index) => filterMissingContent(item, targetContent[index]))\n .filter((item) => item !== undefined);\n\n return missingItems.length > 0 ? missingItems : undefined;\n }\n\n // Handle objects\n const result: any = {};\n let hasMissingContent = false;\n\n for (const [key, value] of Object.entries(sourceContent)) {\n const targetValue = targetContent?.[key];\n const missingValue = filterMissingContent(value, targetValue);\n\n if (missingValue !== undefined) {\n result[key] = missingValue;\n hasMissingContent = true;\n }\n }\n\n return hasMissingContent ? result : undefined;\n};\n\n/**\n * Filters a dictionary to only include content that's missing in the target dictionary.\n * Used for per-locale content declarations in 'complete' mode.\n *\n * @param sourceDictionary - The source dictionary with content to translate\n * @param targetDictionary - The existing target dictionary\n * @returns A dictionary with only the missing content\n */\nexport const getFilterMissingContentPerLocale = (\n sourceDictionary: Dictionary,\n targetDictionary: Dictionary | undefined\n): Dictionary => {\n if (!targetDictionary || !targetDictionary.content) {\n // If no target exists, all source content is missing\n return sourceDictionary;\n }\n\n const missingContent = filterMissingContent(\n sourceDictionary.content,\n targetDictionary.content\n );\n\n return {\n ...sourceDictionary,\n content: missingContent ?? {},\n };\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,wBAAwB,eAAoB,kBAA4B;AAE5E,KAAI,kBAAkB,KACpB,QAAO,kBAAkB,OAAO,SAAY;AAI9C,KAAI,kBAAkB,UAAa,kBAAkB,KACnD,QAAO;AAIT,KAAI,OAAO,kBAAkB,SAC3B;AAIF,KAAI,MAAM,QAAQ,cAAc,EAAE;AAChC,MAAI,CAAC,MAAM,QAAQ,cAAc,CAC/B,QAAO;EAGT,MAAM,eAAe,cAClB,KAAK,MAAM,UAAU,qBAAqB,MAAM,cAAc,OAAO,CAAC,CACtE,QAAQ,SAAS,SAAS,OAAU;AAEvC,SAAO,aAAa,SAAS,IAAI,eAAe;;CAIlD,MAAM,SAAc,EAAE;CACtB,IAAI,oBAAoB;AAExB,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,cAAc,EAAE;EACxD,MAAM,cAAc,gBAAgB;EACpC,MAAM,eAAe,qBAAqB,OAAO,YAAY;AAE7D,MAAI,iBAAiB,QAAW;AAC9B,UAAO,OAAO;AACd,uBAAoB;;;AAIxB,QAAO,oBAAoB,SAAS;;;;;;;;;;AAWtC,MAAa,oCACX,kBACA,qBACe;AACf,KAAI,CAAC,oBAAoB,CAAC,iBAAiB,QAEzC,QAAO;CAGT,MAAM,iBAAiB,qBACrB,iBAAiB,SACjB,iBAAiB,QAClB;AAED,QAAO;EACL,GAAG;EACH,SAAS,kBAAkB,EAAE;EAC9B"}
@@ -1 +1,6 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./writeFill.cjs`),t=require(`./fill.cjs`);exports.fill=t.fill,exports.writeFill=e.writeFill;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_fill_writeFill = require('./writeFill.cjs');
3
+ const require_fill_fill = require('./fill.cjs');
4
+
5
+ exports.fill = require_fill_fill.fill;
6
+ exports.writeFill = require_fill_writeFill.writeFill;
@@ -1,2 +1,73 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`../test/listMissingTranslations.cjs`);let n=require(`node:path`),r=require(`@intlayer/chokidar/utils`),i=require(`@intlayer/config/colors`);i=e.t(i);let a=require(`@intlayer/config/logger`),o=require(`@intlayer/unmerged-dictionaries-entry`),s=require(`@intlayer/core/plugins`),c=require(`@intlayer/dictionaries-entry`);const l=(e,l,u,d,f)=>{let p=(0,a.getAppLogger)(f),m=(0,c.getDictionaries)(f),h=(0,o.getUnmergedDictionaries)(f),g=Object.values(h).flat().filter(t=>e.includes(t.localId)),{missingTranslations:_}=t.listMissingTranslationsWithConfig(f),v=Math.max(...g.map(e=>e.key.length)),y=[];for(let e of g){let t=(0,a.colon)([` - `,(0,a.colorize)(`[`,i.GREY_DARK),(0,a.colorizeKey)(e.key),(0,a.colorize)(`]`,i.GREY_DARK)].join(``),{colSize:v+6}),o=e.key,c=e.localId,h=m[o];if((e.filled??!1)===!0||(e.fill??f.dictionary?.fill??!1)===!1)continue;let g=e.locale??d;if(!h){p(`${t} Dictionary not found in dictionariesRecord. Skipping.`,{level:`warn`});continue}if(!e.filePath){p(`${t} Dictionary has no file path. Skipping.`,{level:`warn`});continue}let b=(0,s.getFilterTranslationsOnlyDictionary)(h,g);if(Object.keys(b).length===0){p(`${t} No content found for dictionary in source locale ${(0,r.formatLocale)(g)}. Skipping translation for this dictionary.`,{level:`warn`});continue}let x=l;if(u===`complete`&&(x=_.find(e=>e.key===o)?.locales.filter(e=>l.includes(e))??[]),x.length===0){p(`${t} ${(0,a.colorize)(`No locales to fill, Skipping`,i.GREY_DARK)} ${(0,a.colorizePath)((0,n.basename)(e.filePath))}`,{level:`warn`});continue}y.push({dictionaryKey:o,dictionaryLocalId:c,sourceLocale:g,targetLocales:x,dictionaryPreset:t,dictionaryFilePath:e.filePath})}return y};exports.listTranslationsTasks=l;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_test_listMissingTranslations = require('../test/listMissingTranslations.cjs');
4
+ let node_path = require("node:path");
5
+ let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
6
+ let _intlayer_config_colors = require("@intlayer/config/colors");
7
+ _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
8
+ let _intlayer_config_logger = require("@intlayer/config/logger");
9
+ let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
10
+ let _intlayer_core_plugins = require("@intlayer/core/plugins");
11
+ let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
12
+
13
+ //#region src/fill/listTranslationsTasks.ts
14
+ const listTranslationsTasks = (localIds, outputLocales, mode, baseLocale, configuration) => {
15
+ const appLogger = (0, _intlayer_config_logger.getAppLogger)(configuration);
16
+ const mergedDictionariesRecord = (0, _intlayer_dictionaries_entry.getDictionaries)(configuration);
17
+ const unmergedDictionariesRecord = (0, _intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration);
18
+ const dictionariesToProcess = Object.values(unmergedDictionariesRecord).flat().filter((dictionary) => localIds.includes(dictionary.localId));
19
+ const { missingTranslations } = require_test_listMissingTranslations.listMissingTranslationsWithConfig(configuration);
20
+ const maxKeyLength = Math.max(...dictionariesToProcess.map((dictionary) => dictionary.key.length));
21
+ const translationTasks = [];
22
+ for (const targetUnmergedDictionary of dictionariesToProcess) {
23
+ const dictionaryPreset = (0, _intlayer_config_logger.colon)([
24
+ " - ",
25
+ (0, _intlayer_config_logger.colorize)("[", _intlayer_config_colors.GREY_DARK),
26
+ (0, _intlayer_config_logger.colorizeKey)(targetUnmergedDictionary.key),
27
+ (0, _intlayer_config_logger.colorize)("]", _intlayer_config_colors.GREY_DARK)
28
+ ].join(""), { colSize: maxKeyLength + 6 });
29
+ const dictionaryKey = targetUnmergedDictionary.key;
30
+ const dictionaryLocalId = targetUnmergedDictionary.localId;
31
+ const mainDictionaryToProcess = mergedDictionariesRecord[dictionaryKey];
32
+ if ((targetUnmergedDictionary.filled ?? false) === true) continue;
33
+ if ((targetUnmergedDictionary.fill ?? configuration.dictionary?.fill ?? false) === false) continue;
34
+ const sourceLocale = targetUnmergedDictionary.locale ?? baseLocale;
35
+ if (!mainDictionaryToProcess) {
36
+ appLogger(`${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`, { level: "warn" });
37
+ continue;
38
+ }
39
+ if (!targetUnmergedDictionary.filePath) {
40
+ appLogger(`${dictionaryPreset} Dictionary has no file path. Skipping.`, { level: "warn" });
41
+ continue;
42
+ }
43
+ const sourceLocaleContent = (0, _intlayer_core_plugins.getFilterTranslationsOnlyDictionary)(mainDictionaryToProcess, sourceLocale);
44
+ if (Object.keys(sourceLocaleContent).length === 0) {
45
+ appLogger(`${dictionaryPreset} No content found for dictionary in source locale ${(0, _intlayer_chokidar_utils.formatLocale)(sourceLocale)}. Skipping translation for this dictionary.`, { level: "warn" });
46
+ continue;
47
+ }
48
+ /**
49
+ * In 'complete' mode, filter only the missing locales to translate
50
+ *
51
+ * Skip the dictionary if there are no missing locales to translate
52
+ */
53
+ let outputLocalesList = outputLocales;
54
+ if (mode === "complete") outputLocalesList = missingTranslations.find((missingTranslation) => missingTranslation.key === dictionaryKey)?.locales.filter((locale) => outputLocales.includes(locale)) ?? [];
55
+ if (outputLocalesList.length === 0) {
56
+ appLogger(`${dictionaryPreset} ${(0, _intlayer_config_logger.colorize)("No locales to fill, Skipping", _intlayer_config_colors.GREY_DARK)} ${(0, _intlayer_config_logger.colorizePath)((0, node_path.basename)(targetUnmergedDictionary.filePath))}`, { level: "warn" });
57
+ continue;
58
+ }
59
+ translationTasks.push({
60
+ dictionaryKey,
61
+ dictionaryLocalId,
62
+ sourceLocale,
63
+ targetLocales: outputLocalesList,
64
+ dictionaryPreset,
65
+ dictionaryFilePath: targetUnmergedDictionary.filePath
66
+ });
67
+ }
68
+ return translationTasks;
69
+ };
70
+
71
+ //#endregion
72
+ exports.listTranslationsTasks = listTranslationsTasks;
2
73
  //# sourceMappingURL=listTranslationsTasks.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"listTranslationsTasks.cjs","names":["listMissingTranslationsWithConfig","ANSIColors"],"sources":["../../../src/fill/listTranslationsTasks.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { formatLocale } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getFilterTranslationsOnlyDictionary } from '@intlayer/core/plugins';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { listMissingTranslationsWithConfig } from '../test';\n\nexport type TranslationTask = {\n dictionaryKey: string;\n dictionaryLocalId: LocalDictionaryId;\n sourceLocale: Locale;\n targetLocales: Locale[];\n dictionaryPreset: string;\n dictionaryFilePath: string;\n};\n\nexport const listTranslationsTasks = (\n localIds: LocalDictionaryId[],\n outputLocales: Locale[],\n mode: 'complete' | 'review',\n baseLocale: Locale,\n configuration: IntlayerConfig\n): TranslationTask[] => {\n const appLogger = getAppLogger(configuration);\n\n const mergedDictionariesRecord = getDictionaries(configuration);\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const allFlatDictionaries = Object.values(unmergedDictionariesRecord).flat();\n const dictionariesToProcess = allFlatDictionaries.filter((dictionary) =>\n localIds.includes(dictionary.localId!)\n );\n\n const { missingTranslations } =\n listMissingTranslationsWithConfig(configuration);\n\n const maxKeyLength = Math.max(\n ...dictionariesToProcess.map((dictionary) => dictionary.key.length)\n );\n\n const translationTasks: TranslationTask[] = [];\n\n for (const targetUnmergedDictionary of dictionariesToProcess) {\n const dictionaryPreset = colon(\n [\n ' - ',\n colorize('[', ANSIColors.GREY_DARK),\n colorizeKey(targetUnmergedDictionary.key),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: maxKeyLength + 6 }\n );\n\n const dictionaryKey = targetUnmergedDictionary.key;\n const dictionaryLocalId = targetUnmergedDictionary.localId!;\n const mainDictionaryToProcess: Dictionary =\n mergedDictionariesRecord[dictionaryKey];\n const dictionaryFilled = targetUnmergedDictionary.filled ?? false;\n\n if (dictionaryFilled === true) {\n continue;\n }\n\n const dictionaryFill =\n targetUnmergedDictionary.fill ?? configuration.dictionary?.fill ?? false;\n\n if (dictionaryFill === false) continue;\n\n const sourceLocale: Locale = (targetUnmergedDictionary.locale ??\n baseLocale) as Locale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n if (!targetUnmergedDictionary.filePath) {\n appLogger(`${dictionaryPreset} Dictionary has no file path. Skipping.`, {\n level: 'warn',\n });\n continue;\n }\n\n const sourceLocaleContent = getFilterTranslationsOnlyDictionary(\n mainDictionaryToProcess,\n sourceLocale\n );\n\n if (\n Object.keys(sourceLocaleContent as Record<string, unknown>).length === 0\n ) {\n appLogger(\n `${dictionaryPreset} No content found for dictionary in source locale ${formatLocale(sourceLocale)}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n /**\n * In 'complete' mode, filter only the missing locales to translate\n *\n * Skip the dictionary if there are no missing locales to translate\n */\n let outputLocalesList: Locale[] = outputLocales as Locale[];\n\n if (mode === 'complete') {\n outputLocalesList =\n missingTranslations\n .find(\n (missingTranslation) => missingTranslation.key === dictionaryKey\n )\n ?.locales.filter((locale) => outputLocales.includes(locale)) ?? [];\n }\n\n if (outputLocalesList.length === 0) {\n appLogger(\n `${dictionaryPreset} ${colorize('No locales to fill, Skipping', ANSIColors.GREY_DARK)} ${colorizePath(basename(targetUnmergedDictionary.filePath))}`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n translationTasks.push({\n dictionaryKey,\n dictionaryLocalId,\n sourceLocale,\n targetLocales: outputLocalesList,\n dictionaryPreset,\n dictionaryFilePath: targetUnmergedDictionary.filePath,\n });\n }\n\n // Return the list of tasks to execute\n return translationTasks;\n};\n"],"mappings":"sbA2BA,MAAa,GACX,EACA,EACA,EACA,EACA,IACsB,CACtB,IAAM,GAAA,EAAA,EAAA,cAAyB,EAAc,CAEvC,GAAA,EAAA,EAAA,iBAA2C,EAAc,CACzD,GAAA,EAAA,EAAA,yBAAqD,EAAc,CAGnE,EADsB,OAAO,OAAO,EAA2B,CAAC,MAAM,CAC1B,OAAQ,GACxD,EAAS,SAAS,EAAW,QAAS,CACvC,CAEK,CAAE,uBACNA,EAAAA,kCAAkC,EAAc,CAE5C,EAAe,KAAK,IACxB,GAAG,EAAsB,IAAK,GAAe,EAAW,IAAI,OAAO,CACpE,CAEK,EAAsC,EAAE,CAE9C,IAAK,IAAM,KAA4B,EAAuB,CAC5D,IAAM,GAAA,EAAA,EAAA,OACJ,CACE,qBACS,IAAKC,EAAW,UAAU,mBACvB,EAAyB,IAAI,gBAChC,IAAKA,EAAW,UAAU,CACpC,CAAC,KAAK,GAAG,CACV,CAAE,QAAS,EAAe,EAAG,CAC9B,CAEK,EAAgB,EAAyB,IACzC,EAAoB,EAAyB,QAC7C,EACJ,EAAyB,GAU3B,IATyB,EAAyB,QAAU,MAEnC,KAKvB,EAAyB,MAAQ,EAAc,YAAY,MAAQ,MAE9C,GAAO,SAE9B,IAAM,EAAwB,EAAyB,QACrD,EAEF,GAAI,CAAC,EAAyB,CAC5B,EACE,GAAG,EAAiB,wDACpB,CACE,MAAO,OACR,CACF,CACD,SAGF,GAAI,CAAC,EAAyB,SAAU,CACtC,EAAU,GAAG,EAAiB,yCAA0C,CACtE,MAAO,OACR,CAAC,CACF,SAGF,IAAM,GAAA,EAAA,EAAA,qCACJ,EACA,EACD,CAED,GACE,OAAO,KAAK,EAA+C,CAAC,SAAW,EACvE,CACA,EACE,GAAG,EAAiB,qDAAA,EAAA,EAAA,cAAiE,EAAa,CAAC,6CACnG,CACE,MAAO,OACR,CACF,CACD,SAQF,IAAI,EAA8B,EAWlC,GATI,IAAS,aACX,EACE,EACG,KACE,GAAuB,EAAmB,MAAQ,EACpD,EACC,QAAQ,OAAQ,GAAW,EAAc,SAAS,EAAO,CAAC,EAAI,EAAE,EAGpE,EAAkB,SAAW,EAAG,CAClC,EACE,GAAG,EAAiB,IAAA,EAAA,EAAA,UAAY,+BAAgCA,EAAW,UAAU,CAAC,IAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UAAyB,EAAyB,SAAS,CAAC,GAClJ,CACE,MAAO,OACR,CACF,CACD,SAGF,EAAiB,KAAK,CACpB,gBACA,oBACA,eACA,cAAe,EACf,mBACA,mBAAoB,EAAyB,SAC9C,CAAC,CAIJ,OAAO"}
1
+ {"version":3,"file":"listTranslationsTasks.cjs","names":["listMissingTranslationsWithConfig","ANSIColors"],"sources":["../../../src/fill/listTranslationsTasks.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { formatLocale } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { getFilterTranslationsOnlyDictionary } from '@intlayer/core/plugins';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { listMissingTranslationsWithConfig } from '../test';\n\nexport type TranslationTask = {\n dictionaryKey: string;\n dictionaryLocalId: LocalDictionaryId;\n sourceLocale: Locale;\n targetLocales: Locale[];\n dictionaryPreset: string;\n dictionaryFilePath: string;\n};\n\nexport const listTranslationsTasks = (\n localIds: LocalDictionaryId[],\n outputLocales: Locale[],\n mode: 'complete' | 'review',\n baseLocale: Locale,\n configuration: IntlayerConfig\n): TranslationTask[] => {\n const appLogger = getAppLogger(configuration);\n\n const mergedDictionariesRecord = getDictionaries(configuration);\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const allFlatDictionaries = Object.values(unmergedDictionariesRecord).flat();\n const dictionariesToProcess = allFlatDictionaries.filter((dictionary) =>\n localIds.includes(dictionary.localId!)\n );\n\n const { missingTranslations } =\n listMissingTranslationsWithConfig(configuration);\n\n const maxKeyLength = Math.max(\n ...dictionariesToProcess.map((dictionary) => dictionary.key.length)\n );\n\n const translationTasks: TranslationTask[] = [];\n\n for (const targetUnmergedDictionary of dictionariesToProcess) {\n const dictionaryPreset = colon(\n [\n ' - ',\n colorize('[', ANSIColors.GREY_DARK),\n colorizeKey(targetUnmergedDictionary.key),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: maxKeyLength + 6 }\n );\n\n const dictionaryKey = targetUnmergedDictionary.key;\n const dictionaryLocalId = targetUnmergedDictionary.localId!;\n const mainDictionaryToProcess: Dictionary =\n mergedDictionariesRecord[dictionaryKey];\n const dictionaryFilled = targetUnmergedDictionary.filled ?? false;\n\n if (dictionaryFilled === true) {\n continue;\n }\n\n const dictionaryFill =\n targetUnmergedDictionary.fill ?? configuration.dictionary?.fill ?? false;\n\n if (dictionaryFill === false) continue;\n\n const sourceLocale: Locale = (targetUnmergedDictionary.locale ??\n baseLocale) as Locale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n if (!targetUnmergedDictionary.filePath) {\n appLogger(`${dictionaryPreset} Dictionary has no file path. Skipping.`, {\n level: 'warn',\n });\n continue;\n }\n\n const sourceLocaleContent = getFilterTranslationsOnlyDictionary(\n mainDictionaryToProcess,\n sourceLocale\n );\n\n if (\n Object.keys(sourceLocaleContent as Record<string, unknown>).length === 0\n ) {\n appLogger(\n `${dictionaryPreset} No content found for dictionary in source locale ${formatLocale(sourceLocale)}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n /**\n * In 'complete' mode, filter only the missing locales to translate\n *\n * Skip the dictionary if there are no missing locales to translate\n */\n let outputLocalesList: Locale[] = outputLocales as Locale[];\n\n if (mode === 'complete') {\n outputLocalesList =\n missingTranslations\n .find(\n (missingTranslation) => missingTranslation.key === dictionaryKey\n )\n ?.locales.filter((locale) => outputLocales.includes(locale)) ?? [];\n }\n\n if (outputLocalesList.length === 0) {\n appLogger(\n `${dictionaryPreset} ${colorize('No locales to fill, Skipping', ANSIColors.GREY_DARK)} ${colorizePath(basename(targetUnmergedDictionary.filePath))}`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n translationTasks.push({\n dictionaryKey,\n dictionaryLocalId,\n sourceLocale,\n targetLocales: outputLocalesList,\n dictionaryPreset,\n dictionaryFilePath: targetUnmergedDictionary.filePath,\n });\n }\n\n // Return the list of tasks to execute\n return translationTasks;\n};\n"],"mappings":";;;;;;;;;;;;;AA2BA,MAAa,yBACX,UACA,eACA,MACA,YACA,kBACsB;CACtB,MAAM,sDAAyB,cAAc;CAE7C,MAAM,6EAA2C,cAAc;CAC/D,MAAM,gGAAqD,cAAc;CAGzE,MAAM,wBADsB,OAAO,OAAO,2BAA2B,CAAC,MAAM,CAC1B,QAAQ,eACxD,SAAS,SAAS,WAAW,QAAS,CACvC;CAED,MAAM,EAAE,wBACNA,uEAAkC,cAAc;CAElD,MAAM,eAAe,KAAK,IACxB,GAAG,sBAAsB,KAAK,eAAe,WAAW,IAAI,OAAO,CACpE;CAED,MAAM,mBAAsC,EAAE;AAE9C,MAAK,MAAM,4BAA4B,uBAAuB;EAC5D,MAAM,sDACJ;GACE;yCACS,KAAKC,wBAAW,UAAU;4CACvB,yBAAyB,IAAI;yCAChC,KAAKA,wBAAW,UAAU;GACpC,CAAC,KAAK,GAAG,EACV,EAAE,SAAS,eAAe,GAAG,CAC9B;EAED,MAAM,gBAAgB,yBAAyB;EAC/C,MAAM,oBAAoB,yBAAyB;EACnD,MAAM,0BACJ,yBAAyB;AAG3B,OAFyB,yBAAyB,UAAU,WAEnC,KACvB;AAMF,OAFE,yBAAyB,QAAQ,cAAc,YAAY,QAAQ,WAE9C,MAAO;EAE9B,MAAM,eAAwB,yBAAyB,UACrD;AAEF,MAAI,CAAC,yBAAyB;AAC5B,aACE,GAAG,iBAAiB,yDACpB,EACE,OAAO,QACR,CACF;AACD;;AAGF,MAAI,CAAC,yBAAyB,UAAU;AACtC,aAAU,GAAG,iBAAiB,0CAA0C,EACtE,OAAO,QACR,CAAC;AACF;;EAGF,MAAM,sFACJ,yBACA,aACD;AAED,MACE,OAAO,KAAK,oBAA+C,CAAC,WAAW,GACvE;AACA,aACE,GAAG,iBAAiB,+FAAiE,aAAa,CAAC,8CACnG,EACE,OAAO,QACR,CACF;AACD;;;;;;;EAQF,IAAI,oBAA8B;AAElC,MAAI,SAAS,WACX,qBACE,oBACG,MACE,uBAAuB,mBAAmB,QAAQ,cACpD,EACC,QAAQ,QAAQ,WAAW,cAAc,SAAS,OAAO,CAAC,IAAI,EAAE;AAGxE,MAAI,kBAAkB,WAAW,GAAG;AAClC,aACE,GAAG,iBAAiB,yCAAY,gCAAgCA,wBAAW,UAAU,CAAC,qEAAyB,yBAAyB,SAAS,CAAC,IAClJ,EACE,OAAO,QACR,CACF;AACD;;AAGF,mBAAiB,KAAK;GACpB;GACA;GACA;GACA,eAAe;GACf;GACA,oBAAoB,yBAAyB;GAC9C,CAAC;;AAIJ,QAAO"}