@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,2 +1,21 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>{let t=e.getTime(),n=1e3,r=60*n,i=60*r,a=24*i,o=Math.floor(t/a),s=Math.floor(t%a/i),c=Math.floor(t%i/r),l=Math.floor(t%r/n);return o>0?`${o}d ${s}h ${c}m ${l}s`:s>0?`${s}h ${c}m ${l}s`:`${c}m ${l}s`};exports.formatTimeDiff=e;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/utils/formatTimeDiff.ts
4
+ const formatTimeDiff = (realtiveTime) => {
5
+ const diff = realtiveTime.getTime();
6
+ const MS_IN_SECOND = 1e3;
7
+ const MS_IN_MINUTE = 60 * MS_IN_SECOND;
8
+ const MS_IN_HOUR = 60 * MS_IN_MINUTE;
9
+ const MS_IN_DAY = 24 * MS_IN_HOUR;
10
+ const days = Math.floor(diff / MS_IN_DAY);
11
+ const hours = Math.floor(diff % MS_IN_DAY / MS_IN_HOUR);
12
+ const minutes = Math.floor(diff % MS_IN_HOUR / MS_IN_MINUTE);
13
+ const seconds = Math.floor(diff % MS_IN_MINUTE / MS_IN_SECOND);
14
+ if (days > 0) return `${days}d ${hours}h ${minutes}m ${seconds}s`;
15
+ if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
16
+ return `${minutes}m ${seconds}s`;
17
+ };
18
+
19
+ //#endregion
20
+ exports.formatTimeDiff = formatTimeDiff;
2
21
  //# sourceMappingURL=formatTimeDiff.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatTimeDiff.cjs","names":[],"sources":["../../../src/utils/formatTimeDiff.ts"],"sourcesContent":["export const formatTimeDiff = (realtiveTime: Date): string => {\n const diff = realtiveTime.getTime();\n\n const MS_IN_SECOND = 1000;\n const MS_IN_MINUTE = 60 * MS_IN_SECOND;\n const MS_IN_HOUR = 60 * MS_IN_MINUTE;\n const MS_IN_DAY = 24 * MS_IN_HOUR;\n\n const days = Math.floor(diff / MS_IN_DAY);\n const hours = Math.floor((diff % MS_IN_DAY) / MS_IN_HOUR);\n const minutes = Math.floor((diff % MS_IN_HOUR) / MS_IN_MINUTE);\n const seconds = Math.floor((diff % MS_IN_MINUTE) / MS_IN_SECOND);\n\n if (days > 0) {\n return `${days}d ${hours}h ${minutes}m ${seconds}s`;\n }\n if (hours > 0) {\n return `${hours}h ${minutes}m ${seconds}s`;\n }\n\n return `${minutes}m ${seconds}s`;\n};\n"],"mappings":"mEAAA,MAAa,EAAkB,GAA+B,CAC5D,IAAM,EAAO,EAAa,SAAS,CAE7B,EAAe,IACf,EAAe,GAAK,EACpB,EAAa,GAAK,EAClB,EAAY,GAAK,EAEjB,EAAO,KAAK,MAAM,EAAO,EAAU,CACnC,EAAQ,KAAK,MAAO,EAAO,EAAa,EAAW,CACnD,EAAU,KAAK,MAAO,EAAO,EAAc,EAAa,CACxD,EAAU,KAAK,MAAO,EAAO,EAAgB,EAAa,CAShE,OAPI,EAAO,EACF,GAAG,EAAK,IAAI,EAAM,IAAI,EAAQ,IAAI,EAAQ,GAE/C,EAAQ,EACH,GAAG,EAAM,IAAI,EAAQ,IAAI,EAAQ,GAGnC,GAAG,EAAQ,IAAI,EAAQ"}
1
+ {"version":3,"file":"formatTimeDiff.cjs","names":[],"sources":["../../../src/utils/formatTimeDiff.ts"],"sourcesContent":["export const formatTimeDiff = (realtiveTime: Date): string => {\n const diff = realtiveTime.getTime();\n\n const MS_IN_SECOND = 1000;\n const MS_IN_MINUTE = 60 * MS_IN_SECOND;\n const MS_IN_HOUR = 60 * MS_IN_MINUTE;\n const MS_IN_DAY = 24 * MS_IN_HOUR;\n\n const days = Math.floor(diff / MS_IN_DAY);\n const hours = Math.floor((diff % MS_IN_DAY) / MS_IN_HOUR);\n const minutes = Math.floor((diff % MS_IN_HOUR) / MS_IN_MINUTE);\n const seconds = Math.floor((diff % MS_IN_MINUTE) / MS_IN_SECOND);\n\n if (days > 0) {\n return `${days}d ${hours}h ${minutes}m ${seconds}s`;\n }\n if (hours > 0) {\n return `${hours}h ${minutes}m ${seconds}s`;\n }\n\n return `${minutes}m ${seconds}s`;\n};\n"],"mappings":";;;AAAA,MAAa,kBAAkB,iBAA+B;CAC5D,MAAM,OAAO,aAAa,SAAS;CAEnC,MAAM,eAAe;CACrB,MAAM,eAAe,KAAK;CAC1B,MAAM,aAAa,KAAK;CACxB,MAAM,YAAY,KAAK;CAEvB,MAAM,OAAO,KAAK,MAAM,OAAO,UAAU;CACzC,MAAM,QAAQ,KAAK,MAAO,OAAO,YAAa,WAAW;CACzD,MAAM,UAAU,KAAK,MAAO,OAAO,aAAc,aAAa;CAC9D,MAAM,UAAU,KAAK,MAAO,OAAO,eAAgB,aAAa;AAEhE,KAAI,OAAO,EACT,QAAO,GAAG,KAAK,IAAI,MAAM,IAAI,QAAQ,IAAI,QAAQ;AAEnD,KAAI,QAAQ,EACV,QAAO,GAAG,MAAM,IAAI,QAAQ,IAAI,QAAQ;AAG1C,QAAO,GAAG,QAAQ,IAAI,QAAQ"}
@@ -1,2 +1,17 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`node:fs`);const t=t=>{let n=(0,e.statSync)(t);return new Date(n.mtime)>new Date(Date.now()-0)};exports.getIsFileUpdatedRecently=t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let node_fs = require("node:fs");
4
+
5
+ //#region src/utils/getIsFileUpdatedRecently.ts
6
+ const SKIP_RANGE_OF_LAST_UPDATE_TIME = 0;
7
+ /**
8
+ * Check if file was updated recently, to skip re-translation
9
+ */
10
+ const getIsFileUpdatedRecently = (localeFilePath) => {
11
+ const stats = (0, node_fs.statSync)(localeFilePath);
12
+ return new Date(stats.mtime) > new Date(Date.now() - SKIP_RANGE_OF_LAST_UPDATE_TIME);
13
+ };
14
+
15
+ //#endregion
16
+ exports.getIsFileUpdatedRecently = getIsFileUpdatedRecently;
2
17
  //# sourceMappingURL=getIsFileUpdatedRecently.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIsFileUpdatedRecently.cjs","names":[],"sources":["../../../src/utils/getIsFileUpdatedRecently.ts"],"sourcesContent":["import { statSync } from 'node:fs';\n\nconst SKIP_RANGE_OF_LAST_UPDATE_TIME: number = 0; //2 * 60 * 60 * 1000; // 2 hours\n\n/**\n * Check if file was updated recently, to skip re-translation\n */\nexport const getIsFileUpdatedRecently = (localeFilePath: string): boolean => {\n const stats = statSync(localeFilePath);\n const lastModified = new Date(stats.mtime);\n const threshold = new Date(Date.now() - SKIP_RANGE_OF_LAST_UPDATE_TIME);\n\n return lastModified > threshold;\n};\n"],"mappings":"6HAEA,MAKa,EAA4B,GAAoC,CAC3E,IAAM,GAAA,EAAA,EAAA,UAAiB,EAAe,CAItC,OAHqB,IAAI,KAAK,EAAM,MAAM,CACxB,IAAI,KAAK,KAAK,KAAK,CAAG,EAA+B"}
1
+ {"version":3,"file":"getIsFileUpdatedRecently.cjs","names":[],"sources":["../../../src/utils/getIsFileUpdatedRecently.ts"],"sourcesContent":["import { statSync } from 'node:fs';\n\nconst SKIP_RANGE_OF_LAST_UPDATE_TIME: number = 0; //2 * 60 * 60 * 1000; // 2 hours\n\n/**\n * Check if file was updated recently, to skip re-translation\n */\nexport const getIsFileUpdatedRecently = (localeFilePath: string): boolean => {\n const stats = statSync(localeFilePath);\n const lastModified = new Date(stats.mtime);\n const threshold = new Date(Date.now() - SKIP_RANGE_OF_LAST_UPDATE_TIME);\n\n return lastModified > threshold;\n};\n"],"mappings":";;;;;AAEA,MAAM,iCAAyC;;;;AAK/C,MAAa,4BAA4B,mBAAoC;CAC3E,MAAM,8BAAiB,eAAe;AAItC,QAHqB,IAAI,KAAK,MAAM,MAAM,GACxB,IAAI,KAAK,KAAK,KAAK,GAAG,+BAA+B"}
@@ -1,2 +1,109 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=(e,t,n)=>{if(!e||!t||!n)throw Error(`filePath, locale, and baseLocale are required`);let r=e,i=[{pattern:/\{\{baseLocale\}\}/g,replacement:`{{locale}}`},{pattern:/\{\{baseLocaleName\}\}/g,replacement:`{{localeName}}`},{pattern:RegExp(`/${n}/`,`g`),replacement:`/${t}/`},{pattern:RegExp(`\\\\${n}\\\\`,`g`),replacement:`\\${t}\\`},{pattern:RegExp(`_${n}\\.`,`g`),replacement:`_${t}.`},{pattern:RegExp(`/${n}_`,`g`),replacement:`/${t}_`},{pattern:RegExp(`(^|[\\/])${n}_`,`g`),replacement:`$1${t}_`},{pattern:RegExp(`\\.${n}\\.`,`g`),replacement:`.${t}.`}];for(let{pattern:e,replacement:t}of i)r=r.replace(e,t);if(r===e){let n=e.lastIndexOf(`.`);return n>0?`${e.slice(0,n)}.${t}${e.slice(n)}`:`${e}.${t}`}return r};exports.getOutputFilePath=e;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
4
+ let _intlayer_config_utils = require("@intlayer/config/utils");
5
+
6
+ //#region src/utils/getOutputFilePath.ts
7
+ /**
8
+ * Get the output file path by replacing the base locale with the target locale
9
+ *
10
+ * This function handles two types of replacements:
11
+ * 1. Actual locale values (e.g., `/en/` → `/fr/`)
12
+ * 2. Template placeholders (e.g., `{{baseLocale}}` → `{{locale}}`, `{{baseLocaleName}}` → `{{localeName}}`)
13
+ *
14
+ * Replacement patterns:
15
+ * - `/baseLocale/` → `/locale/`
16
+ * - `\baseLocale\` → `\locale\`
17
+ * - `_baseLocale.` → `_locale.`
18
+ * - `baseLocale_` → `locale_`
19
+ * - `.baseLocaleName.` → `.localeName.`
20
+ * - `{{baseLocale}}` → `{{locale}}`
21
+ * - `{{baseLocaleName}}` → `{{localeName}}`
22
+ *
23
+ * If no patterns match, appends `.locale` to the file extension.
24
+ *
25
+ * @param filePath - The input file path
26
+ * @param locale - The target locale
27
+ * @param baseLocale - The base locale to replace
28
+ * @returns The output file path with locale replacements
29
+ */
30
+ const getOutputFilePath = (filePath, locale, baseLocale) => {
31
+ if (!filePath || !locale || !baseLocale) throw new Error("filePath, locale, and baseLocale are required");
32
+ let outputFilePath = filePath;
33
+ const replacements = [
34
+ {
35
+ pattern: /\{\{baseLocale\}\}/g,
36
+ replacement: "{{locale}}"
37
+ },
38
+ {
39
+ pattern: /\{\{baseLocaleName\}\}/g,
40
+ replacement: "{{localeName}}"
41
+ },
42
+ {
43
+ pattern: new RegExp(`/${baseLocale}/`, "g"),
44
+ replacement: `/${locale}/`
45
+ },
46
+ {
47
+ pattern: new RegExp(`\\\\${baseLocale}\\\\`, "g"),
48
+ replacement: `\\${locale}\\`
49
+ },
50
+ {
51
+ pattern: new RegExp(`_${baseLocale}\\.`, "g"),
52
+ replacement: `_${locale}.`
53
+ },
54
+ {
55
+ pattern: new RegExp(`/${baseLocale}_`, "g"),
56
+ replacement: `/${locale}_`
57
+ },
58
+ {
59
+ pattern: new RegExp(`(^|[\\/])${baseLocale}_`, "g"),
60
+ replacement: `$1${locale}_`
61
+ },
62
+ {
63
+ pattern: new RegExp(`\\.${baseLocale}\\.`, "g"),
64
+ replacement: `.${locale}.`
65
+ }
66
+ ];
67
+ for (const { pattern, replacement } of replacements) outputFilePath = outputFilePath.replace(pattern, replacement);
68
+ if (outputFilePath === filePath) {
69
+ const lastDotIndex = filePath.lastIndexOf(".");
70
+ if (lastDotIndex > 0) return `${filePath.slice(0, lastDotIndex)}.${locale}${filePath.slice(lastDotIndex)}`;
71
+ else return `${filePath}.${locale}`;
72
+ }
73
+ return outputFilePath;
74
+ };
75
+ /**
76
+ * Get the effective FilePathPattern for a given locale from a Fill/CompilerOutput value.
77
+ *
78
+ * - If Fill is an object, returns the pattern for that locale (or `false` if disabled/missing).
79
+ * - If Fill is a string/function, returns it as-is (applies to all locales).
80
+ * - If Fill is `false`, returns `false` (disabled for all locales).
81
+ * - If Fill is `true` or a locale entry is `true`, returns `undefined` (use default).
82
+ */
83
+ const getPatternForLocale = (output, locale) => {
84
+ if (output === false) return false;
85
+ if (output === true) return void 0;
86
+ if (typeof output === "string" || typeof output === "function") return output;
87
+ if (typeof output === "object" && output !== null) {
88
+ const entry = output[locale];
89
+ if (entry === void 0 || entry === false) return false;
90
+ if (entry === true) return void 0;
91
+ return entry;
92
+ }
93
+ return false;
94
+ };
95
+ /**
96
+ * Resolve a Fill/CompilerOutput pattern to an absolute file path for a given locale.
97
+ * Returns `false` if the locale is disabled or no pattern is configured.
98
+ */
99
+ const resolveOutputPattern = async (output, locale, context, sourceFilePath, baseDir) => {
100
+ const pattern = getPatternForLocale(output, locale);
101
+ if (pattern === false || pattern === void 0) return false;
102
+ return (0, _intlayer_chokidar_utils.resolveRelativePath)(typeof pattern === "function" ? await pattern(context) : (0, _intlayer_config_utils.parseStringPattern)(pattern, context), sourceFilePath, baseDir);
103
+ };
104
+
105
+ //#endregion
106
+ exports.getOutputFilePath = getOutputFilePath;
107
+ exports.getPatternForLocale = getPatternForLocale;
108
+ exports.resolveOutputPattern = resolveOutputPattern;
2
109
  //# sourceMappingURL=getOutputFilePath.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getOutputFilePath.cjs","names":[],"sources":["../../../src/utils/getOutputFilePath.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the output file path by replacing the base locale with the target locale\n *\n * This function handles two types of replacements:\n * 1. Actual locale values (e.g., `/en/` → `/fr/`)\n * 2. Template placeholders (e.g., `{{baseLocale}}` → `{{locale}}`, `{{baseLocaleName}}` → `{{localeName}}`)\n *\n * Replacement patterns:\n * - `/baseLocale/` → `/locale/`\n * - `\\baseLocale\\` → `\\locale\\`\n * - `_baseLocale.` → `_locale.`\n * - `baseLocale_` → `locale_`\n * - `.baseLocaleName.` → `.localeName.`\n * - `{{baseLocale}}` → `{{locale}}`\n * - `{{baseLocaleName}}` → `{{localeName}}`\n *\n * If no patterns match, appends `.locale` to the file extension.\n *\n * @param filePath - The input file path\n * @param locale - The target locale\n * @param baseLocale - The base locale to replace\n * @returns The output file path with locale replacements\n */\nexport const getOutputFilePath = (\n filePath: string,\n locale: LocalesValues,\n baseLocale: LocalesValues\n): string => {\n if (!filePath || !locale || !baseLocale) {\n throw new Error('filePath, locale, and baseLocale are required');\n }\n\n let outputFilePath = filePath;\n\n // Define replacement patterns with global flag to replace all occurrences\n const replacements = [\n // Template placeholders (processed first)\n {\n pattern: /\\{\\{baseLocale\\}\\}/g,\n replacement: '{{locale}}',\n },\n {\n pattern: /\\{\\{baseLocaleName\\}\\}/g,\n replacement: '{{localeName}}',\n },\n\n // Path separators (most specific first)\n {\n // Unix path separators\n pattern: new RegExp(`/${baseLocale}/`, 'g'),\n replacement: `/${locale}/`,\n },\n {\n // Windows path separators\n pattern: new RegExp(`\\\\\\\\${baseLocale}\\\\\\\\`, 'g'),\n replacement: `\\\\${locale}\\\\`,\n },\n\n // File naming patterns\n {\n // file_en.md → file_fr.md\n pattern: new RegExp(`_${baseLocale}\\\\.`, 'g'),\n replacement: `_${locale}.`,\n },\n {\n // /file_en.md → /file_fr.md\n pattern: new RegExp(`/${baseLocale}_`, 'g'),\n replacement: `/${locale}_`,\n },\n {\n // Start of filename pattern en_guide.md → fr_guide.md (or after path separator)\n pattern: new RegExp(`(^|[\\\\/])${baseLocale}_`, 'g'),\n replacement: `$1${locale}_`,\n },\n {\n // Dot delimited pattern guide.en.md → guide.fr.md\n pattern: new RegExp(`\\\\.${baseLocale}\\\\.`, 'g'),\n replacement: `.${locale}.`,\n },\n ];\n\n // Apply all replacements\n for (const { pattern, replacement } of replacements) {\n outputFilePath = outputFilePath.replace(pattern, replacement);\n }\n\n // If no changes were made, append locale as extension\n if (outputFilePath === filePath) {\n const lastDotIndex = filePath.lastIndexOf('.');\n if (lastDotIndex > 0) {\n // Insert locale before the file extension\n return `${filePath.slice(0, lastDotIndex)}.${locale}${filePath.slice(lastDotIndex)}`;\n } else {\n // No extension found, just append\n return `${filePath}.${locale}`;\n }\n }\n\n return outputFilePath;\n};\n"],"mappings":"mEAyBA,MAAa,GACX,EACA,EACA,IACW,CACX,GAAI,CAAC,GAAY,CAAC,GAAU,CAAC,EAC3B,MAAU,MAAM,gDAAgD,CAGlE,IAAI,EAAiB,EAGf,EAAe,CAEnB,CACE,QAAS,sBACT,YAAa,aACd,CACD,CACE,QAAS,0BACT,YAAa,iBACd,CAGD,CAEE,QAAa,OAAO,IAAI,EAAW,GAAI,IAAI,CAC3C,YAAa,IAAI,EAAO,GACzB,CACD,CAEE,QAAa,OAAO,OAAO,EAAW,MAAO,IAAI,CACjD,YAAa,KAAK,EAAO,IAC1B,CAGD,CAEE,QAAa,OAAO,IAAI,EAAW,KAAM,IAAI,CAC7C,YAAa,IAAI,EAAO,GACzB,CACD,CAEE,QAAa,OAAO,IAAI,EAAW,GAAI,IAAI,CAC3C,YAAa,IAAI,EAAO,GACzB,CACD,CAEE,QAAa,OAAO,YAAY,EAAW,GAAI,IAAI,CACnD,YAAa,KAAK,EAAO,GAC1B,CACD,CAEE,QAAa,OAAO,MAAM,EAAW,KAAM,IAAI,CAC/C,YAAa,IAAI,EAAO,GACzB,CACF,CAGD,IAAK,GAAM,CAAE,UAAS,iBAAiB,EACrC,EAAiB,EAAe,QAAQ,EAAS,EAAY,CAI/D,GAAI,IAAmB,EAAU,CAC/B,IAAM,EAAe,EAAS,YAAY,IAAI,CAM5C,OALE,EAAe,EAEV,GAAG,EAAS,MAAM,EAAG,EAAa,CAAC,GAAG,IAAS,EAAS,MAAM,EAAa,GAG3E,GAAG,EAAS,GAAG,IAI1B,OAAO"}
1
+ {"version":3,"file":"getOutputFilePath.cjs","names":[],"sources":["../../../src/utils/getOutputFilePath.ts"],"sourcesContent":["import { resolveRelativePath } from '@intlayer/chokidar/utils';\nimport { parseStringPattern } from '@intlayer/config/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { Fill } from '@intlayer/types/dictionary';\nimport type {\n FilePathPattern,\n FilePathPatternContext,\n} from '@intlayer/types/filePathPattern';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the output file path by replacing the base locale with the target locale\n *\n * This function handles two types of replacements:\n * 1. Actual locale values (e.g., `/en/` → `/fr/`)\n * 2. Template placeholders (e.g., `{{baseLocale}}` → `{{locale}}`, `{{baseLocaleName}}` → `{{localeName}}`)\n *\n * Replacement patterns:\n * - `/baseLocale/` → `/locale/`\n * - `\\baseLocale\\` → `\\locale\\`\n * - `_baseLocale.` → `_locale.`\n * - `baseLocale_` → `locale_`\n * - `.baseLocaleName.` → `.localeName.`\n * - `{{baseLocale}}` → `{{locale}}`\n * - `{{baseLocaleName}}` → `{{localeName}}`\n *\n * If no patterns match, appends `.locale` to the file extension.\n *\n * @param filePath - The input file path\n * @param locale - The target locale\n * @param baseLocale - The base locale to replace\n * @returns The output file path with locale replacements\n */\nexport const getOutputFilePath = (\n filePath: string,\n locale: LocalesValues,\n baseLocale: LocalesValues\n): string => {\n if (!filePath || !locale || !baseLocale) {\n throw new Error('filePath, locale, and baseLocale are required');\n }\n\n let outputFilePath = filePath;\n\n // Define replacement patterns with global flag to replace all occurrences\n const replacements = [\n // Template placeholders (processed first)\n {\n pattern: /\\{\\{baseLocale\\}\\}/g,\n replacement: '{{locale}}',\n },\n {\n pattern: /\\{\\{baseLocaleName\\}\\}/g,\n replacement: '{{localeName}}',\n },\n\n // Path separators (most specific first)\n {\n // Unix path separators\n pattern: new RegExp(`/${baseLocale}/`, 'g'),\n replacement: `/${locale}/`,\n },\n {\n // Windows path separators\n pattern: new RegExp(`\\\\\\\\${baseLocale}\\\\\\\\`, 'g'),\n replacement: `\\\\${locale}\\\\`,\n },\n\n // File naming patterns\n {\n // file_en.md → file_fr.md\n pattern: new RegExp(`_${baseLocale}\\\\.`, 'g'),\n replacement: `_${locale}.`,\n },\n {\n // /file_en.md → /file_fr.md\n pattern: new RegExp(`/${baseLocale}_`, 'g'),\n replacement: `/${locale}_`,\n },\n {\n // Start of filename pattern en_guide.md → fr_guide.md (or after path separator)\n pattern: new RegExp(`(^|[\\\\/])${baseLocale}_`, 'g'),\n replacement: `$1${locale}_`,\n },\n {\n // Dot delimited pattern guide.en.md → guide.fr.md\n pattern: new RegExp(`\\\\.${baseLocale}\\\\.`, 'g'),\n replacement: `.${locale}.`,\n },\n ];\n\n // Apply all replacements\n for (const { pattern, replacement } of replacements) {\n outputFilePath = outputFilePath.replace(pattern, replacement);\n }\n\n // If no changes were made, append locale as extension\n if (outputFilePath === filePath) {\n const lastDotIndex = filePath.lastIndexOf('.');\n if (lastDotIndex > 0) {\n // Insert locale before the file extension\n return `${filePath.slice(0, lastDotIndex)}.${locale}${filePath.slice(lastDotIndex)}`;\n } else {\n // No extension found, just append\n return `${filePath}.${locale}`;\n }\n }\n\n return outputFilePath;\n};\n\n/**\n * Get the effective FilePathPattern for a given locale from a Fill/CompilerOutput value.\n *\n * - If Fill is an object, returns the pattern for that locale (or `false` if disabled/missing).\n * - If Fill is a string/function, returns it as-is (applies to all locales).\n * - If Fill is `false`, returns `false` (disabled for all locales).\n * - If Fill is `true` or a locale entry is `true`, returns `undefined` (use default).\n */\nexport const getPatternForLocale = (\n output: Fill,\n locale: Locale\n): FilePathPattern | false | undefined => {\n if (output === false) return false;\n if (output === true) return undefined;\n if (typeof output === 'string' || typeof output === 'function')\n return output as FilePathPattern;\n if (typeof output === 'object' && output !== null) {\n const entry = (output as Record<string, boolean | FilePathPattern>)[locale];\n if (entry === undefined || entry === false) return false;\n if (entry === true) return undefined;\n return entry as FilePathPattern;\n }\n return false;\n};\n\n/**\n * Resolve a Fill/CompilerOutput pattern to an absolute file path for a given locale.\n * Returns `false` if the locale is disabled or no pattern is configured.\n */\nexport const resolveOutputPattern = async (\n output: Fill,\n locale: Locale,\n context: FilePathPatternContext,\n sourceFilePath: string,\n baseDir: string\n): Promise<string | false> => {\n const pattern = getPatternForLocale(output, locale);\n if (pattern === false || pattern === undefined) return false;\n\n const rawPath =\n typeof pattern === 'function'\n ? await pattern(context)\n : parseStringPattern(pattern, context);\n\n return resolveRelativePath(rawPath, sourceFilePath, baseDir);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,qBACX,UACA,QACA,eACW;AACX,KAAI,CAAC,YAAY,CAAC,UAAU,CAAC,WAC3B,OAAM,IAAI,MAAM,gDAAgD;CAGlE,IAAI,iBAAiB;CAGrB,MAAM,eAAe;EAEnB;GACE,SAAS;GACT,aAAa;GACd;EACD;GACE,SAAS;GACT,aAAa;GACd;EAGD;GAEE,SAAS,IAAI,OAAO,IAAI,WAAW,IAAI,IAAI;GAC3C,aAAa,IAAI,OAAO;GACzB;EACD;GAEE,SAAS,IAAI,OAAO,OAAO,WAAW,OAAO,IAAI;GACjD,aAAa,KAAK,OAAO;GAC1B;EAGD;GAEE,SAAS,IAAI,OAAO,IAAI,WAAW,MAAM,IAAI;GAC7C,aAAa,IAAI,OAAO;GACzB;EACD;GAEE,SAAS,IAAI,OAAO,IAAI,WAAW,IAAI,IAAI;GAC3C,aAAa,IAAI,OAAO;GACzB;EACD;GAEE,SAAS,IAAI,OAAO,YAAY,WAAW,IAAI,IAAI;GACnD,aAAa,KAAK,OAAO;GAC1B;EACD;GAEE,SAAS,IAAI,OAAO,MAAM,WAAW,MAAM,IAAI;GAC/C,aAAa,IAAI,OAAO;GACzB;EACF;AAGD,MAAK,MAAM,EAAE,SAAS,iBAAiB,aACrC,kBAAiB,eAAe,QAAQ,SAAS,YAAY;AAI/D,KAAI,mBAAmB,UAAU;EAC/B,MAAM,eAAe,SAAS,YAAY,IAAI;AAC9C,MAAI,eAAe,EAEjB,QAAO,GAAG,SAAS,MAAM,GAAG,aAAa,CAAC,GAAG,SAAS,SAAS,MAAM,aAAa;MAGlF,QAAO,GAAG,SAAS,GAAG;;AAI1B,QAAO;;;;;;;;;;AAWT,MAAa,uBACX,QACA,WACwC;AACxC,KAAI,WAAW,MAAO,QAAO;AAC7B,KAAI,WAAW,KAAM,QAAO;AAC5B,KAAI,OAAO,WAAW,YAAY,OAAO,WAAW,WAClD,QAAO;AACT,KAAI,OAAO,WAAW,YAAY,WAAW,MAAM;EACjD,MAAM,QAAS,OAAqD;AACpE,MAAI,UAAU,UAAa,UAAU,MAAO,QAAO;AACnD,MAAI,UAAU,KAAM,QAAO;AAC3B,SAAO;;AAET,QAAO;;;;;;AAOT,MAAa,uBAAuB,OAClC,QACA,QACA,SACA,gBACA,YAC4B;CAC5B,MAAM,UAAU,oBAAoB,QAAQ,OAAO;AACnD,KAAI,YAAY,SAAS,YAAY,OAAW,QAAO;AAOvD,0DAJE,OAAO,YAAY,aACf,MAAM,QAAQ,QAAQ,kDACH,SAAS,QAAQ,EAEN,gBAAgB,QAAQ"}
@@ -1,2 +1,21 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`node:fs`),t=require(`node:path`);const n=n=>{let r=n;for(;r!==(0,t.dirname)(r);){let n=(0,t.resolve)(r,`package.json`);if((0,e.existsSync)(n))return JSON.parse((0,e.readFileSync)(n,`utf8`));r=(0,t.dirname)(r)}let i=(0,t.resolve)(r,`package.json`);if((0,e.existsSync)(i))return JSON.parse((0,e.readFileSync)(i,`utf8`));throw Error(`No package.json found in any parent directory of ${n}`)};exports.getParentPackageJSON=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let node_fs = require("node:fs");
4
+ let node_path = require("node:path");
5
+
6
+ //#region src/utils/getParentPackageJSON.ts
7
+ const getParentPackageJSON = (startDir) => {
8
+ let currentDir = startDir;
9
+ while (currentDir !== (0, node_path.dirname)(currentDir)) {
10
+ const packageJsonPath = (0, node_path.resolve)(currentDir, "package.json");
11
+ if ((0, node_fs.existsSync)(packageJsonPath)) return JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf8"));
12
+ currentDir = (0, node_path.dirname)(currentDir);
13
+ }
14
+ const rootPackageJsonPath = (0, node_path.resolve)(currentDir, "package.json");
15
+ if ((0, node_fs.existsSync)(rootPackageJsonPath)) return JSON.parse((0, node_fs.readFileSync)(rootPackageJsonPath, "utf8"));
16
+ throw new Error(`No package.json found in any parent directory of ${startDir}`);
17
+ };
18
+
19
+ //#endregion
20
+ exports.getParentPackageJSON = getParentPackageJSON;
2
21
  //# sourceMappingURL=getParentPackageJSON.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getParentPackageJSON.cjs","names":[],"sources":["../../../src/utils/getParentPackageJSON.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\n\ntype PackageJSON = {\n name?: string;\n version?: string;\n private: boolean;\n description?: string;\n homepage?: string;\n bugs: {\n url?: string;\n };\n repository: {\n type?: string;\n url?: string;\n };\n license?: string;\n author: {\n name?: string;\n url?: string;\n };\n contributors?: {\n name?: string;\n email?: string;\n url?: string;\n }[];\n type?: string;\n scripts: Record<string, string>;\n devDependencies: Record<string, string>;\n packageManager?: string;\n engines: Record<string, string>;\n};\n\nexport const getParentPackageJSON = (startDir: string): PackageJSON => {\n let currentDir = startDir;\n\n while (currentDir !== dirname(currentDir)) {\n // Stop when we reach the root\n const packageJsonPath = resolve(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n return JSON.parse(readFileSync(packageJsonPath, 'utf8'));\n }\n\n // Move up one directory level\n currentDir = dirname(currentDir);\n }\n\n // Check the root directory as well\n const rootPackageJsonPath = resolve(currentDir, 'package.json');\n if (existsSync(rootPackageJsonPath)) {\n return JSON.parse(readFileSync(rootPackageJsonPath, 'utf8'));\n }\n\n // If no package.json is found in any parent directory\n throw new Error(\n `No package.json found in any parent directory of ${startDir}`\n );\n};\n"],"mappings":"oJAiCA,MAAa,EAAwB,GAAkC,CACrE,IAAI,EAAa,EAEjB,KAAO,KAAA,EAAA,EAAA,SAAuB,EAAW,EAAE,CAEzC,IAAM,GAAA,EAAA,EAAA,SAA0B,EAAY,eAAe,CAE3D,IAAA,EAAA,EAAA,YAAe,EAAgB,CAC7B,OAAO,KAAK,OAAA,EAAA,EAAA,cAAmB,EAAiB,OAAO,CAAC,CAI1D,GAAA,EAAA,EAAA,SAAqB,EAAW,CAIlC,IAAM,GAAA,EAAA,EAAA,SAA8B,EAAY,eAAe,CAC/D,IAAA,EAAA,EAAA,YAAe,EAAoB,CACjC,OAAO,KAAK,OAAA,EAAA,EAAA,cAAmB,EAAqB,OAAO,CAAC,CAI9D,MAAU,MACR,oDAAoD,IACrD"}
1
+ {"version":3,"file":"getParentPackageJSON.cjs","names":[],"sources":["../../../src/utils/getParentPackageJSON.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\n\ntype PackageJSON = {\n name?: string;\n version?: string;\n private: boolean;\n description?: string;\n homepage?: string;\n bugs: {\n url?: string;\n };\n repository: {\n type?: string;\n url?: string;\n };\n license?: string;\n author: {\n name?: string;\n url?: string;\n };\n contributors?: {\n name?: string;\n email?: string;\n url?: string;\n }[];\n type?: string;\n scripts: Record<string, string>;\n devDependencies: Record<string, string>;\n packageManager?: string;\n engines: Record<string, string>;\n};\n\nexport const getParentPackageJSON = (startDir: string): PackageJSON => {\n let currentDir = startDir;\n\n while (currentDir !== dirname(currentDir)) {\n // Stop when we reach the root\n const packageJsonPath = resolve(currentDir, 'package.json');\n\n if (existsSync(packageJsonPath)) {\n return JSON.parse(readFileSync(packageJsonPath, 'utf8'));\n }\n\n // Move up one directory level\n currentDir = dirname(currentDir);\n }\n\n // Check the root directory as well\n const rootPackageJsonPath = resolve(currentDir, 'package.json');\n if (existsSync(rootPackageJsonPath)) {\n return JSON.parse(readFileSync(rootPackageJsonPath, 'utf8'));\n }\n\n // If no package.json is found in any parent directory\n throw new Error(\n `No package.json found in any parent directory of ${startDir}`\n );\n};\n"],"mappings":";;;;;;AAiCA,MAAa,wBAAwB,aAAkC;CACrE,IAAI,aAAa;AAEjB,QAAO,sCAAuB,WAAW,EAAE;EAEzC,MAAM,yCAA0B,YAAY,eAAe;AAE3D,8BAAe,gBAAgB,CAC7B,QAAO,KAAK,gCAAmB,iBAAiB,OAAO,CAAC;AAI1D,sCAAqB,WAAW;;CAIlC,MAAM,6CAA8B,YAAY,eAAe;AAC/D,6BAAe,oBAAoB,CACjC,QAAO,KAAK,gCAAmB,qBAAqB,OAAO,CAAC;AAI9D,OAAM,IAAI,MACR,oDAAoD,WACrD"}
@@ -1,3 +1,55 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=[` `,`\\`,`|`,`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`"`,`=`,`+`,`*`,`&`,`#`,`%`,`$`,`!`,`?`,`:`,`;`,`~`],t=t=>{let n=[],r=0;for(let i=0;i<t.length;i++){let a=t[i];if(a===`
2
- `){n.push({char:`\\`,lineStart:r,charStart:i}),r++;continue}e.includes(a)&&n.push({char:a,lineStart:r,charStart:i})}return n};exports.listSpecialChars=t;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/utils/listSpecialChars.ts
4
+ const SPECIAL_CHARS = [
5
+ " ",
6
+ "\\",
7
+ "|",
8
+ "(",
9
+ ")",
10
+ "{",
11
+ "}",
12
+ "[",
13
+ "]",
14
+ "<",
15
+ ">",
16
+ "\"",
17
+ "=",
18
+ "+",
19
+ "*",
20
+ "&",
21
+ "#",
22
+ "%",
23
+ "$",
24
+ "!",
25
+ "?",
26
+ ":",
27
+ ";",
28
+ "~"
29
+ ];
30
+ const listSpecialChars = (text) => {
31
+ const results = [];
32
+ let lineIndex = 0;
33
+ for (let i = 0; i < text.length; i++) {
34
+ const currentChar = text[i];
35
+ if (currentChar === "\n") {
36
+ results.push({
37
+ char: "\\",
38
+ lineStart: lineIndex,
39
+ charStart: i
40
+ });
41
+ lineIndex++;
42
+ continue;
43
+ }
44
+ if (SPECIAL_CHARS.includes(currentChar)) results.push({
45
+ char: currentChar,
46
+ lineStart: lineIndex,
47
+ charStart: i
48
+ });
49
+ }
50
+ return results;
51
+ };
52
+
53
+ //#endregion
54
+ exports.listSpecialChars = listSpecialChars;
3
55
  //# sourceMappingURL=listSpecialChars.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"listSpecialChars.cjs","names":[],"sources":["../../../src/utils/listSpecialChars.ts"],"sourcesContent":["type ListCharResult = {\n char: string;\n /** First line index contained in this chunk (0-based) */\n lineStart: number;\n /** Start character index in the original text (0-based, inclusive)*/\n charStart: number;\n}[];\n\nconst SPECIAL_CHARS = [\n ' ',\n '\\\\',\n '|',\n '(',\n ')',\n '{',\n '}',\n '[',\n ']',\n '<',\n '>',\n '\"',\n '=',\n '+',\n '*',\n '&',\n '#',\n '%',\n '$',\n '!',\n '?',\n ':',\n ';',\n '~',\n];\n\nexport const listSpecialChars = (text: string): ListCharResult => {\n const results: ListCharResult = [];\n\n let lineIndex = 0;\n\n for (let i = 0; i < text.length; i++) {\n const currentChar = text[i];\n\n // Handle newline characters (\"\\n\"): treat them as a \"\\\\\" special char\n if (currentChar === '\\n') {\n results.push({\n char: '\\\\',\n lineStart: lineIndex,\n charStart: i,\n });\n\n // Move to the next line after recording the special char\n lineIndex++;\n continue;\n }\n\n // Check if the current character is one of the special characters\n if (SPECIAL_CHARS.includes(currentChar)) {\n results.push({\n char: currentChar,\n lineStart: lineIndex,\n charStart: i,\n });\n }\n }\n\n return results;\n};\n"],"mappings":"mEAQA,MAAM,EAAgB,CACpB,KACA,KACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACD,CAEY,EAAoB,GAAiC,CAChE,IAAM,EAA0B,EAAE,CAE9B,EAAY,EAEhB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,IAAK,CACpC,IAAM,EAAc,EAAK,GAGzB,GAAI,IAAgB;EAAM,CACxB,EAAQ,KAAK,CACX,KAAM,KACN,UAAW,EACX,UAAW,EACZ,CAAC,CAGF,IACA,SAIE,EAAc,SAAS,EAAY,EACrC,EAAQ,KAAK,CACX,KAAM,EACN,UAAW,EACX,UAAW,EACZ,CAAC,CAIN,OAAO"}
1
+ {"version":3,"file":"listSpecialChars.cjs","names":[],"sources":["../../../src/utils/listSpecialChars.ts"],"sourcesContent":["type ListCharResult = {\n char: string;\n /** First line index contained in this chunk (0-based) */\n lineStart: number;\n /** Start character index in the original text (0-based, inclusive)*/\n charStart: number;\n}[];\n\nconst SPECIAL_CHARS = [\n ' ',\n '\\\\',\n '|',\n '(',\n ')',\n '{',\n '}',\n '[',\n ']',\n '<',\n '>',\n '\"',\n '=',\n '+',\n '*',\n '&',\n '#',\n '%',\n '$',\n '!',\n '?',\n ':',\n ';',\n '~',\n];\n\nexport const listSpecialChars = (text: string): ListCharResult => {\n const results: ListCharResult = [];\n\n let lineIndex = 0;\n\n for (let i = 0; i < text.length; i++) {\n const currentChar = text[i];\n\n // Handle newline characters (\"\\n\"): treat them as a \"\\\\\" special char\n if (currentChar === '\\n') {\n results.push({\n char: '\\\\',\n lineStart: lineIndex,\n charStart: i,\n });\n\n // Move to the next line after recording the special char\n lineIndex++;\n continue;\n }\n\n // Check if the current character is one of the special characters\n if (SPECIAL_CHARS.includes(currentChar)) {\n results.push({\n char: currentChar,\n lineStart: lineIndex,\n charStart: i,\n });\n }\n }\n\n return results;\n};\n"],"mappings":";;;AAQA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,oBAAoB,SAAiC;CAChE,MAAM,UAA0B,EAAE;CAElC,IAAI,YAAY;AAEhB,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,cAAc,KAAK;AAGzB,MAAI,gBAAgB,MAAM;AACxB,WAAQ,KAAK;IACX,MAAM;IACN,WAAW;IACX,WAAW;IACZ,CAAC;AAGF;AACA;;AAIF,MAAI,cAAc,SAAS,YAAY,CACrC,SAAQ,KAAK;GACX,MAAM;GACN,WAAW;GACX,WAAW;GACZ,CAAC;;AAIN,QAAO"}
@@ -1,2 +1,103 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`./calculateChunks.cjs`);let t=require(`@intlayer/chokidar/utils`);const n=(n,c,l=800,u)=>{let d=e.chunkText(n,l,0),f=(0,t.splitTextByLines)(n),p=(0,t.splitTextByLines)(c),m=r(f,p);return d.map(e=>{let t=i(e.lineStart,e.lineLength,m);if(!t)return{baseChunk:e,updatedChunk:null,hasChanges:!0};let n={lineStart:t.start,lineLength:t.length,charStart:0,charLength:0,content:a(p,t.start,t.length)};return n.charStart=o(c,n.lineStart),n.charLength=n.content.length,{baseChunk:e,updatedChunk:n,hasChanges:s(e,n,u)}})},r=(e,t)=>{let n=new Map,r=Array(e.length+1).fill(null).map(()=>Array(t.length+1).fill(0));for(let n=1;n<=e.length;n++)for(let i=1;i<=t.length;i++)e[n-1]===t[i-1]?r[n][i]=r[n-1][i-1]+1:r[n][i]=Math.max(r[n-1][i],r[n][i-1]);let i=e.length,a=t.length;for(;i>0||a>0;)i>0&&a>0&&e[i-1]===t[a-1]?(n.set(i-1,a-1),i--,a--):i>0&&(a===0||r[i-1][a]>=r[i][a-1])?(n.set(i-1,null),i--):a--;return n},i=(e,t,n)=>{let r=[];for(let i=e;i<e+t;i++){let e=n.get(i);e!=null&&r.push(e)}if(r.length===0)return null;r.sort((e,t)=>e-t);let i=r[0];return{start:i,length:r[r.length-1]-i+1}},a=(e,t,n)=>{let r=Math.min(t+n,e.length);return e.slice(t,r).join(``)},o=(e,n)=>{let r=(0,t.splitTextByLines)(e),i=0;for(let e=0;e<Math.min(n,r.length);e++)i+=r[e].length;return i},s=(e,t,n)=>n&&n.length>0?n.some(e=>e>=t.lineStart&&e<t.lineStart+t.lineLength):e.content!==t.content;exports.mapChunksBetweenFiles=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_utils_calculateChunks = require('./calculateChunks.cjs');
4
+ let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
5
+
6
+ //#region src/utils/mapChunksBetweenFiles.ts
7
+ /**
8
+ * Maps chunks from base file to corresponding chunks in updated file,
9
+ * handling insertions, deletions, and modifications properly.
10
+ */
11
+ const mapChunksBetweenFiles = (baseFileContent, updatedFileContent, maxCharsPerChunk = 800, changedLines) => {
12
+ const baseChunks = require_utils_calculateChunks.chunkText(baseFileContent, maxCharsPerChunk, 0);
13
+ const baseLines = (0, _intlayer_chokidar_utils.splitTextByLines)(baseFileContent);
14
+ const updatedLines = (0, _intlayer_chokidar_utils.splitTextByLines)(updatedFileContent);
15
+ const lineMapping = createLineMapping(baseLines, updatedLines);
16
+ return baseChunks.map((baseChunk) => {
17
+ const mappedRange = mapLineRange(baseChunk.lineStart, baseChunk.lineLength, lineMapping);
18
+ if (!mappedRange) return {
19
+ baseChunk,
20
+ updatedChunk: null,
21
+ hasChanges: true
22
+ };
23
+ const updatedChunk = {
24
+ lineStart: mappedRange.start,
25
+ lineLength: mappedRange.length,
26
+ charStart: 0,
27
+ charLength: 0,
28
+ content: extractLinesFromRange(updatedLines, mappedRange.start, mappedRange.length)
29
+ };
30
+ updatedChunk.charStart = getCharStartForLine(updatedFileContent, updatedChunk.lineStart);
31
+ updatedChunk.charLength = updatedChunk.content.length;
32
+ return {
33
+ baseChunk,
34
+ updatedChunk,
35
+ hasChanges: determineIfChunkHasChanges(baseChunk, updatedChunk, changedLines)
36
+ };
37
+ });
38
+ };
39
+ /**
40
+ * Creates a mapping between line numbers in base file and updated file
41
+ * Returns a map where key = base line number, value = updated line number (or null if deleted)
42
+ */
43
+ const createLineMapping = (baseLines, updatedLines) => {
44
+ const mapping = /* @__PURE__ */ new Map();
45
+ const dp = Array(baseLines.length + 1).fill(null).map(() => Array(updatedLines.length + 1).fill(0));
46
+ for (let i = 1; i <= baseLines.length; i++) for (let j = 1; j <= updatedLines.length; j++) if (baseLines[i - 1] === updatedLines[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
47
+ else dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
48
+ let i = baseLines.length;
49
+ let j = updatedLines.length;
50
+ while (i > 0 || j > 0) if (i > 0 && j > 0 && baseLines[i - 1] === updatedLines[j - 1]) {
51
+ mapping.set(i - 1, j - 1);
52
+ i--;
53
+ j--;
54
+ } else if (i > 0 && (j === 0 || dp[i - 1][j] >= dp[i][j - 1])) {
55
+ mapping.set(i - 1, null);
56
+ i--;
57
+ } else j--;
58
+ return mapping;
59
+ };
60
+ /**
61
+ * Maps a line range from base file to updated file using the line mapping
62
+ */
63
+ const mapLineRange = (baseStart, baseLength, lineMapping) => {
64
+ const mappedLines = [];
65
+ for (let i = baseStart; i < baseStart + baseLength; i++) {
66
+ const mappedLine = lineMapping.get(i);
67
+ if (mappedLine !== null && mappedLine !== void 0) mappedLines.push(mappedLine);
68
+ }
69
+ if (mappedLines.length === 0) return null;
70
+ mappedLines.sort((a, b) => a - b);
71
+ const start = mappedLines[0];
72
+ return {
73
+ start,
74
+ length: mappedLines[mappedLines.length - 1] - start + 1
75
+ };
76
+ };
77
+ /**
78
+ * Extracts lines from a range in the lines array
79
+ */
80
+ const extractLinesFromRange = (lines, start, length) => {
81
+ const endIndex = Math.min(start + length, lines.length);
82
+ return lines.slice(start, endIndex).join("");
83
+ };
84
+ /**
85
+ * Gets the character position where a line starts in the text
86
+ */
87
+ const getCharStartForLine = (text, lineNumber) => {
88
+ const lines = (0, _intlayer_chokidar_utils.splitTextByLines)(text);
89
+ let charStart = 0;
90
+ for (let i = 0; i < Math.min(lineNumber, lines.length); i++) charStart += lines[i].length;
91
+ return charStart;
92
+ };
93
+ /**
94
+ * Determines if a chunk has changes based on git changed lines or content comparison
95
+ */
96
+ const determineIfChunkHasChanges = (baseChunk, updatedChunk, changedLines) => {
97
+ if (changedLines && changedLines.length > 0) return changedLines.some((line) => line >= updatedChunk.lineStart && line < updatedChunk.lineStart + updatedChunk.lineLength);
98
+ return baseChunk.content !== updatedChunk.content;
99
+ };
100
+
101
+ //#endregion
102
+ exports.mapChunksBetweenFiles = mapChunksBetweenFiles;
2
103
  //# sourceMappingURL=mapChunksBetweenFiles.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mapChunksBetweenFiles.cjs","names":["chunkText"],"sources":["../../../src/utils/mapChunksBetweenFiles.ts"],"sourcesContent":["import { splitTextByLines } from '@intlayer/chokidar/utils';\nimport { type ChunkLineResult, chunkText } from './calculateChunks';\n\nexport interface ChunkMapping {\n baseChunk: ChunkLineResult;\n updatedChunk: ChunkLineResult | null; // null if the chunk was deleted\n hasChanges: boolean;\n}\n\n/**\n * Maps chunks from base file to corresponding chunks in updated file,\n * handling insertions, deletions, and modifications properly.\n */\nexport const mapChunksBetweenFiles = (\n baseFileContent: string,\n updatedFileContent: string,\n maxCharsPerChunk: number = 800,\n changedLines?: number[]\n): ChunkMapping[] => {\n const baseChunks = chunkText(baseFileContent, maxCharsPerChunk, 0);\n const baseLines = splitTextByLines(baseFileContent);\n const updatedLines = splitTextByLines(updatedFileContent);\n\n // Create a simple line mapping using LCS (Longest Common Subsequence) approach\n const lineMapping = createLineMapping(baseLines, updatedLines);\n\n return baseChunks.map((baseChunk): ChunkMapping => {\n // Map the base chunk's line range to the updated file\n const mappedRange = mapLineRange(\n baseChunk.lineStart,\n baseChunk.lineLength,\n lineMapping\n );\n\n if (!mappedRange) {\n // This chunk was completely deleted\n return {\n baseChunk,\n updatedChunk: null,\n hasChanges: true,\n };\n }\n\n // Create the corresponding chunk in the updated file\n const updatedChunk: ChunkLineResult = {\n lineStart: mappedRange.start,\n lineLength: mappedRange.length,\n charStart: 0, // Will be calculated when needed\n charLength: 0, // Will be calculated when needed\n content: extractLinesFromRange(\n updatedLines,\n mappedRange.start,\n mappedRange.length\n ),\n };\n\n // Calculate character positions\n updatedChunk.charStart = getCharStartForLine(\n updatedFileContent,\n updatedChunk.lineStart\n );\n updatedChunk.charLength = updatedChunk.content.length;\n\n // Determine if this chunk has changes\n const hasChanges = determineIfChunkHasChanges(\n baseChunk,\n updatedChunk,\n changedLines\n );\n\n return {\n baseChunk,\n updatedChunk,\n hasChanges,\n };\n });\n};\n\n/**\n * Creates a mapping between line numbers in base file and updated file\n * Returns a map where key = base line number, value = updated line number (or null if deleted)\n */\nconst createLineMapping = (\n baseLines: string[],\n updatedLines: string[]\n): Map<number, number | null> => {\n const mapping = new Map<number, number | null>();\n\n // Use a simple diff algorithm (similar to Myers algorithm but simplified)\n const dp: number[][] = Array(baseLines.length + 1)\n .fill(null)\n .map(() => Array(updatedLines.length + 1).fill(0));\n\n // Fill the DP table\n for (let i = 1; i <= baseLines.length; i++) {\n for (let j = 1; j <= updatedLines.length; j++) {\n if (baseLines[i - 1] === updatedLines[j - 1]) {\n dp[i][j] = dp[i - 1][j - 1] + 1;\n } else {\n dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);\n }\n }\n }\n\n // Backtrack to create the mapping\n let i = baseLines.length;\n let j = updatedLines.length;\n\n while (i > 0 || j > 0) {\n if (i > 0 && j > 0 && baseLines[i - 1] === updatedLines[j - 1]) {\n // Lines match\n mapping.set(i - 1, j - 1);\n i--;\n j--;\n } else if (i > 0 && (j === 0 || dp[i - 1][j] >= dp[i][j - 1])) {\n // Line was deleted from base\n mapping.set(i - 1, null);\n i--;\n } else {\n // Line was added to updated (no mapping needed for base)\n j--;\n }\n }\n\n return mapping;\n};\n\n/**\n * Maps a line range from base file to updated file using the line mapping\n */\nconst mapLineRange = (\n baseStart: number,\n baseLength: number,\n lineMapping: Map<number, number | null>\n): { start: number; length: number } | null => {\n const mappedLines: number[] = [];\n\n for (let i = baseStart; i < baseStart + baseLength; i++) {\n const mappedLine = lineMapping.get(i);\n if (mappedLine !== null && mappedLine !== undefined) {\n mappedLines.push(mappedLine);\n }\n }\n\n if (mappedLines.length === 0) {\n return null; // All lines were deleted\n }\n\n // Find the continuous range in the mapped lines\n mappedLines.sort((a, b) => a - b);\n const start = mappedLines[0];\n const end = mappedLines[mappedLines.length - 1];\n\n return {\n start,\n length: end - start + 1,\n };\n};\n\n/**\n * Extracts lines from a range in the lines array\n */\nconst extractLinesFromRange = (\n lines: string[],\n start: number,\n length: number\n): string => {\n const endIndex = Math.min(start + length, lines.length);\n return lines.slice(start, endIndex).join('');\n};\n\n/**\n * Gets the character position where a line starts in the text\n */\nconst getCharStartForLine = (text: string, lineNumber: number): number => {\n const lines = splitTextByLines(text);\n let charStart = 0;\n\n for (let i = 0; i < Math.min(lineNumber, lines.length); i++) {\n charStart += lines[i].length;\n }\n\n return charStart;\n};\n\n/**\n * Determines if a chunk has changes based on git changed lines or content comparison\n */\nconst determineIfChunkHasChanges = (\n baseChunk: ChunkLineResult,\n updatedChunk: ChunkLineResult,\n changedLines?: number[]\n): boolean => {\n // If we have git changed lines, use them for precise detection\n if (changedLines && changedLines.length > 0) {\n return changedLines.some(\n (line) =>\n line >= updatedChunk.lineStart &&\n line < updatedChunk.lineStart + updatedChunk.lineLength\n );\n }\n\n // Fallback to content comparison\n return baseChunk.content !== updatedChunk.content;\n};\n"],"mappings":"uLAaA,MAAa,GACX,EACA,EACA,EAA2B,IAC3B,IACmB,CACnB,IAAM,EAAaA,EAAAA,UAAU,EAAiB,EAAkB,EAAE,CAC5D,GAAA,EAAA,EAAA,kBAA6B,EAAgB,CAC7C,GAAA,EAAA,EAAA,kBAAgC,EAAmB,CAGnD,EAAc,EAAkB,EAAW,EAAa,CAE9D,OAAO,EAAW,IAAK,GAA4B,CAEjD,IAAM,EAAc,EAClB,EAAU,UACV,EAAU,WACV,EACD,CAED,GAAI,CAAC,EAEH,MAAO,CACL,YACA,aAAc,KACd,WAAY,GACb,CAIH,IAAM,EAAgC,CACpC,UAAW,EAAY,MACvB,WAAY,EAAY,OACxB,UAAW,EACX,WAAY,EACZ,QAAS,EACP,EACA,EAAY,MACZ,EAAY,OACb,CACF,CAgBD,MAbA,GAAa,UAAY,EACvB,EACA,EAAa,UACd,CACD,EAAa,WAAa,EAAa,QAAQ,OASxC,CACL,YACA,eACA,WATiB,EACjB,EACA,EACA,EACD,CAMA,EACD,EAOE,GACJ,EACA,IAC+B,CAC/B,IAAM,EAAU,IAAI,IAGd,EAAiB,MAAM,EAAU,OAAS,EAAE,CAC/C,KAAK,KAAK,CACV,QAAU,MAAM,EAAa,OAAS,EAAE,CAAC,KAAK,EAAE,CAAC,CAGpD,IAAK,IAAI,EAAI,EAAG,GAAK,EAAU,OAAQ,IACrC,IAAK,IAAI,EAAI,EAAG,GAAK,EAAa,OAAQ,IACpC,EAAU,EAAI,KAAO,EAAa,EAAI,GACxC,EAAG,GAAG,GAAK,EAAG,EAAI,GAAG,EAAI,GAAK,EAE9B,EAAG,GAAG,GAAK,KAAK,IAAI,EAAG,EAAI,GAAG,GAAI,EAAG,GAAG,EAAI,GAAG,CAMrD,IAAI,EAAI,EAAU,OACd,EAAI,EAAa,OAErB,KAAO,EAAI,GAAK,EAAI,GACd,EAAI,GAAK,EAAI,GAAK,EAAU,EAAI,KAAO,EAAa,EAAI,IAE1D,EAAQ,IAAI,EAAI,EAAG,EAAI,EAAE,CACzB,IACA,KACS,EAAI,IAAM,IAAM,GAAK,EAAG,EAAI,GAAG,IAAM,EAAG,GAAG,EAAI,KAExD,EAAQ,IAAI,EAAI,EAAG,KAAK,CACxB,KAGA,IAIJ,OAAO,GAMH,GACJ,EACA,EACA,IAC6C,CAC7C,IAAM,EAAwB,EAAE,CAEhC,IAAK,IAAI,EAAI,EAAW,EAAI,EAAY,EAAY,IAAK,CACvD,IAAM,EAAa,EAAY,IAAI,EAAE,CACjC,GAAe,MACjB,EAAY,KAAK,EAAW,CAIhC,GAAI,EAAY,SAAW,EACzB,OAAO,KAIT,EAAY,MAAM,EAAG,IAAM,EAAI,EAAE,CACjC,IAAM,EAAQ,EAAY,GAG1B,MAAO,CACL,QACA,OAJU,EAAY,EAAY,OAAS,GAI7B,EAAQ,EACvB,EAMG,GACJ,EACA,EACA,IACW,CACX,IAAM,EAAW,KAAK,IAAI,EAAQ,EAAQ,EAAM,OAAO,CACvD,OAAO,EAAM,MAAM,EAAO,EAAS,CAAC,KAAK,GAAG,EAMxC,GAAuB,EAAc,IAA+B,CACxE,IAAM,GAAA,EAAA,EAAA,kBAAyB,EAAK,CAChC,EAAY,EAEhB,IAAK,IAAI,EAAI,EAAG,EAAI,KAAK,IAAI,EAAY,EAAM,OAAO,CAAE,IACtD,GAAa,EAAM,GAAG,OAGxB,OAAO,GAMH,GACJ,EACA,EACA,IAGI,GAAgB,EAAa,OAAS,EACjC,EAAa,KACjB,GACC,GAAQ,EAAa,WACrB,EAAO,EAAa,UAAY,EAAa,WAChD,CAII,EAAU,UAAY,EAAa"}
1
+ {"version":3,"file":"mapChunksBetweenFiles.cjs","names":["chunkText"],"sources":["../../../src/utils/mapChunksBetweenFiles.ts"],"sourcesContent":["import { splitTextByLines } from '@intlayer/chokidar/utils';\nimport { type ChunkLineResult, chunkText } from './calculateChunks';\n\nexport interface ChunkMapping {\n baseChunk: ChunkLineResult;\n updatedChunk: ChunkLineResult | null; // null if the chunk was deleted\n hasChanges: boolean;\n}\n\n/**\n * Maps chunks from base file to corresponding chunks in updated file,\n * handling insertions, deletions, and modifications properly.\n */\nexport const mapChunksBetweenFiles = (\n baseFileContent: string,\n updatedFileContent: string,\n maxCharsPerChunk: number = 800,\n changedLines?: number[]\n): ChunkMapping[] => {\n const baseChunks = chunkText(baseFileContent, maxCharsPerChunk, 0);\n const baseLines = splitTextByLines(baseFileContent);\n const updatedLines = splitTextByLines(updatedFileContent);\n\n // Create a simple line mapping using LCS (Longest Common Subsequence) approach\n const lineMapping = createLineMapping(baseLines, updatedLines);\n\n return baseChunks.map((baseChunk): ChunkMapping => {\n // Map the base chunk's line range to the updated file\n const mappedRange = mapLineRange(\n baseChunk.lineStart,\n baseChunk.lineLength,\n lineMapping\n );\n\n if (!mappedRange) {\n // This chunk was completely deleted\n return {\n baseChunk,\n updatedChunk: null,\n hasChanges: true,\n };\n }\n\n // Create the corresponding chunk in the updated file\n const updatedChunk: ChunkLineResult = {\n lineStart: mappedRange.start,\n lineLength: mappedRange.length,\n charStart: 0, // Will be calculated when needed\n charLength: 0, // Will be calculated when needed\n content: extractLinesFromRange(\n updatedLines,\n mappedRange.start,\n mappedRange.length\n ),\n };\n\n // Calculate character positions\n updatedChunk.charStart = getCharStartForLine(\n updatedFileContent,\n updatedChunk.lineStart\n );\n updatedChunk.charLength = updatedChunk.content.length;\n\n // Determine if this chunk has changes\n const hasChanges = determineIfChunkHasChanges(\n baseChunk,\n updatedChunk,\n changedLines\n );\n\n return {\n baseChunk,\n updatedChunk,\n hasChanges,\n };\n });\n};\n\n/**\n * Creates a mapping between line numbers in base file and updated file\n * Returns a map where key = base line number, value = updated line number (or null if deleted)\n */\nconst createLineMapping = (\n baseLines: string[],\n updatedLines: string[]\n): Map<number, number | null> => {\n const mapping = new Map<number, number | null>();\n\n // Use a simple diff algorithm (similar to Myers algorithm but simplified)\n const dp: number[][] = Array(baseLines.length + 1)\n .fill(null)\n .map(() => Array(updatedLines.length + 1).fill(0));\n\n // Fill the DP table\n for (let i = 1; i <= baseLines.length; i++) {\n for (let j = 1; j <= updatedLines.length; j++) {\n if (baseLines[i - 1] === updatedLines[j - 1]) {\n dp[i][j] = dp[i - 1][j - 1] + 1;\n } else {\n dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);\n }\n }\n }\n\n // Backtrack to create the mapping\n let i = baseLines.length;\n let j = updatedLines.length;\n\n while (i > 0 || j > 0) {\n if (i > 0 && j > 0 && baseLines[i - 1] === updatedLines[j - 1]) {\n // Lines match\n mapping.set(i - 1, j - 1);\n i--;\n j--;\n } else if (i > 0 && (j === 0 || dp[i - 1][j] >= dp[i][j - 1])) {\n // Line was deleted from base\n mapping.set(i - 1, null);\n i--;\n } else {\n // Line was added to updated (no mapping needed for base)\n j--;\n }\n }\n\n return mapping;\n};\n\n/**\n * Maps a line range from base file to updated file using the line mapping\n */\nconst mapLineRange = (\n baseStart: number,\n baseLength: number,\n lineMapping: Map<number, number | null>\n): { start: number; length: number } | null => {\n const mappedLines: number[] = [];\n\n for (let i = baseStart; i < baseStart + baseLength; i++) {\n const mappedLine = lineMapping.get(i);\n if (mappedLine !== null && mappedLine !== undefined) {\n mappedLines.push(mappedLine);\n }\n }\n\n if (mappedLines.length === 0) {\n return null; // All lines were deleted\n }\n\n // Find the continuous range in the mapped lines\n mappedLines.sort((a, b) => a - b);\n const start = mappedLines[0];\n const end = mappedLines[mappedLines.length - 1];\n\n return {\n start,\n length: end - start + 1,\n };\n};\n\n/**\n * Extracts lines from a range in the lines array\n */\nconst extractLinesFromRange = (\n lines: string[],\n start: number,\n length: number\n): string => {\n const endIndex = Math.min(start + length, lines.length);\n return lines.slice(start, endIndex).join('');\n};\n\n/**\n * Gets the character position where a line starts in the text\n */\nconst getCharStartForLine = (text: string, lineNumber: number): number => {\n const lines = splitTextByLines(text);\n let charStart = 0;\n\n for (let i = 0; i < Math.min(lineNumber, lines.length); i++) {\n charStart += lines[i].length;\n }\n\n return charStart;\n};\n\n/**\n * Determines if a chunk has changes based on git changed lines or content comparison\n */\nconst determineIfChunkHasChanges = (\n baseChunk: ChunkLineResult,\n updatedChunk: ChunkLineResult,\n changedLines?: number[]\n): boolean => {\n // If we have git changed lines, use them for precise detection\n if (changedLines && changedLines.length > 0) {\n return changedLines.some(\n (line) =>\n line >= updatedChunk.lineStart &&\n line < updatedChunk.lineStart + updatedChunk.lineLength\n );\n }\n\n // Fallback to content comparison\n return baseChunk.content !== updatedChunk.content;\n};\n"],"mappings":";;;;;;;;;;AAaA,MAAa,yBACX,iBACA,oBACA,mBAA2B,KAC3B,iBACmB;CACnB,MAAM,aAAaA,wCAAU,iBAAiB,kBAAkB,EAAE;CAClE,MAAM,2DAA6B,gBAAgB;CACnD,MAAM,8DAAgC,mBAAmB;CAGzD,MAAM,cAAc,kBAAkB,WAAW,aAAa;AAE9D,QAAO,WAAW,KAAK,cAA4B;EAEjD,MAAM,cAAc,aAClB,UAAU,WACV,UAAU,YACV,YACD;AAED,MAAI,CAAC,YAEH,QAAO;GACL;GACA,cAAc;GACd,YAAY;GACb;EAIH,MAAM,eAAgC;GACpC,WAAW,YAAY;GACvB,YAAY,YAAY;GACxB,WAAW;GACX,YAAY;GACZ,SAAS,sBACP,cACA,YAAY,OACZ,YAAY,OACb;GACF;AAGD,eAAa,YAAY,oBACvB,oBACA,aAAa,UACd;AACD,eAAa,aAAa,aAAa,QAAQ;AAS/C,SAAO;GACL;GACA;GACA,YATiB,2BACjB,WACA,cACA,aACD;GAMA;GACD;;;;;;AAOJ,MAAM,qBACJ,WACA,iBAC+B;CAC/B,MAAM,0BAAU,IAAI,KAA4B;CAGhD,MAAM,KAAiB,MAAM,UAAU,SAAS,EAAE,CAC/C,KAAK,KAAK,CACV,UAAU,MAAM,aAAa,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC;AAGpD,MAAK,IAAI,IAAI,GAAG,KAAK,UAAU,QAAQ,IACrC,MAAK,IAAI,IAAI,GAAG,KAAK,aAAa,QAAQ,IACxC,KAAI,UAAU,IAAI,OAAO,aAAa,IAAI,GACxC,IAAG,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,KAAK;KAE9B,IAAG,GAAG,KAAK,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,IAAI,GAAG;CAMrD,IAAI,IAAI,UAAU;CAClB,IAAI,IAAI,aAAa;AAErB,QAAO,IAAI,KAAK,IAAI,EAClB,KAAI,IAAI,KAAK,IAAI,KAAK,UAAU,IAAI,OAAO,aAAa,IAAI,IAAI;AAE9D,UAAQ,IAAI,IAAI,GAAG,IAAI,EAAE;AACzB;AACA;YACS,IAAI,MAAM,MAAM,KAAK,GAAG,IAAI,GAAG,MAAM,GAAG,GAAG,IAAI,KAAK;AAE7D,UAAQ,IAAI,IAAI,GAAG,KAAK;AACxB;OAGA;AAIJ,QAAO;;;;;AAMT,MAAM,gBACJ,WACA,YACA,gBAC6C;CAC7C,MAAM,cAAwB,EAAE;AAEhC,MAAK,IAAI,IAAI,WAAW,IAAI,YAAY,YAAY,KAAK;EACvD,MAAM,aAAa,YAAY,IAAI,EAAE;AACrC,MAAI,eAAe,QAAQ,eAAe,OACxC,aAAY,KAAK,WAAW;;AAIhC,KAAI,YAAY,WAAW,EACzB,QAAO;AAIT,aAAY,MAAM,GAAG,MAAM,IAAI,EAAE;CACjC,MAAM,QAAQ,YAAY;AAG1B,QAAO;EACL;EACA,QAJU,YAAY,YAAY,SAAS,KAI7B,QAAQ;EACvB;;;;;AAMH,MAAM,yBACJ,OACA,OACA,WACW;CACX,MAAM,WAAW,KAAK,IAAI,QAAQ,QAAQ,MAAM,OAAO;AACvD,QAAO,MAAM,MAAM,OAAO,SAAS,CAAC,KAAK,GAAG;;;;;AAM9C,MAAM,uBAAuB,MAAc,eAA+B;CACxE,MAAM,uDAAyB,KAAK;CACpC,IAAI,YAAY;AAEhB,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IAAI,YAAY,MAAM,OAAO,EAAE,IACtD,cAAa,MAAM,GAAG;AAGxB,QAAO;;;;;AAMT,MAAM,8BACJ,WACA,cACA,iBACY;AAEZ,KAAI,gBAAgB,aAAa,SAAS,EACxC,QAAO,aAAa,MACjB,SACC,QAAQ,aAAa,aACrB,OAAO,aAAa,YAAY,aAAa,WAChD;AAIH,QAAO,UAAU,YAAY,aAAa"}
@@ -1,2 +1,20 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`node:child_process`),t=require(`node:os`);const n=n=>{let r=(0,t.platform)(),i=``;i=r===`darwin`?`open "${n}"`:r===`win32`?`start "${n}"`:`xdg-open "${n}"`,(0,e.exec)(i,e=>{e&&console.error(`Failed to open browser: ${e.message}`)})};exports.openBrowser=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let node_child_process = require("node:child_process");
4
+ let node_os = require("node:os");
5
+
6
+ //#region src/utils/openBrowser.ts
7
+ const openBrowser = (url) => {
8
+ const osPlatform = (0, node_os.platform)();
9
+ let command = "";
10
+ if (osPlatform === "darwin") command = `open "${url}"`;
11
+ else if (osPlatform === "win32") command = `start "${url}"`;
12
+ else command = `xdg-open "${url}"`;
13
+ (0, node_child_process.exec)(command, (error) => {
14
+ if (error) console.error(`Failed to open browser: ${error.message}`);
15
+ });
16
+ };
17
+
18
+ //#endregion
19
+ exports.openBrowser = openBrowser;
2
20
  //# sourceMappingURL=openBrowser.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"openBrowser.cjs","names":[],"sources":["../../../src/utils/openBrowser.ts"],"sourcesContent":["import { exec } from 'node:child_process';\nimport { platform } from 'node:os';\n\nexport const openBrowser = (url: string) => {\n const osPlatform = platform();\n let command = '';\n\n if (osPlatform === 'darwin') {\n command = `open \"${url}\"`;\n } else if (osPlatform === 'win32') {\n command = `start \"${url}\"`;\n } else {\n command = `xdg-open \"${url}\"`;\n }\n\n exec(command, (error) => {\n if (error) {\n console.error(`Failed to open browser: ${error.message}`);\n }\n });\n};\n"],"mappings":"6JAGA,MAAa,EAAe,GAAgB,CAC1C,IAAM,GAAA,EAAA,EAAA,WAAuB,CACzB,EAAU,GAEd,AAKE,EALE,IAAe,SACP,SAAS,EAAI,GACd,IAAe,QACd,UAAU,EAAI,GAEd,aAAa,EAAI,IAG7B,EAAA,EAAA,MAAK,EAAU,GAAU,CACnB,GACF,QAAQ,MAAM,2BAA2B,EAAM,UAAU,EAE3D"}
1
+ {"version":3,"file":"openBrowser.cjs","names":[],"sources":["../../../src/utils/openBrowser.ts"],"sourcesContent":["import { exec } from 'node:child_process';\nimport { platform } from 'node:os';\n\nexport const openBrowser = (url: string) => {\n const osPlatform = platform();\n let command = '';\n\n if (osPlatform === 'darwin') {\n command = `open \"${url}\"`;\n } else if (osPlatform === 'win32') {\n command = `start \"${url}\"`;\n } else {\n command = `xdg-open \"${url}\"`;\n }\n\n exec(command, (error) => {\n if (error) {\n console.error(`Failed to open browser: ${error.message}`);\n }\n });\n};\n"],"mappings":";;;;;;AAGA,MAAa,eAAe,QAAgB;CAC1C,MAAM,oCAAuB;CAC7B,IAAI,UAAU;AAEd,KAAI,eAAe,SACjB,WAAU,SAAS,IAAI;UACd,eAAe,QACxB,WAAU,UAAU,IAAI;KAExB,WAAU,aAAa,IAAI;AAG7B,8BAAK,UAAU,UAAU;AACvB,MAAI,MACF,SAAQ,MAAM,2BAA2B,MAAM,UAAU;GAE3D"}
@@ -1,6 +1,94 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./listSpecialChars.cjs`),t=e=>{let t=[],n=e.split(/(\n{2,})/);for(let e=0;e<n.length;e++){let r=n[e];if(e%2==0){r&&t.push(r);continue}let i=Math.floor(r.length/2),a=Math.max(0,i-2);for(let e=0;e<a;e++)t.push(`
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_utils_listSpecialChars = require('./listSpecialChars.cjs');
2
3
 
3
- `)}return t},n=(e,t,n,r)=>{if(e===t)return!0;if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e].char!==r[e].char)return!1;return!0},r=(r,i)=>{let a=t(i),o=t(r),s=a.map(t=>e.listSpecialChars(t)),c=o.map(t=>e.listSpecialChars(t)),l=Array(a.length).fill(-1),u=Array(o.length).fill(null);for(let e=0;e<o.length;e++){let t=o[e],r=c[e],i=a.findIndex((e,n)=>l[n]===-1&&t===e);i===-1&&(i=a.findIndex((e,i)=>l[i]===-1&&n(t,e,r,s[i]))),i!==-1&&(l[i]=e,u[e]=i)}let d=Array(o.length).fill(-1),f=-1;for(let e=0;e<o.length;e++){let t=u[e];t===null?d[e]=f:t>f&&(f=t)}let p=[],m={};d.forEach((e,t)=>{e!==-1&&(m[e]=m[e]||[],m[e].push(t))});for(let e=0;e<a.length;e++){let t=l[e];t!==-1&&p.push(o[t]),m[e]&&m[e].forEach(e=>{p.push(o[e])})}let h=[];return d.forEach((e,t)=>{e===-1&&u[t]===null&&h.push(o[t])}),[...h,...p].join(`
4
+ //#region src/utils/reorderParagraphs.ts
5
+ /**
6
+ * Split a text into paragraphs.
7
+ *
8
+ * We consider a paragraph boundary to be a block of at least two consecutive
9
+ * new-lines that is immediately followed by a non-white-space character. This
10
+ * way, internal blank lines that are part of the same paragraph (e.g. a list
11
+ * item that purposely contains a visual break) are preserved while true
12
+ * paragraph breaks – the ones generated when calling `arr.join("\n\n")` in
13
+ * the tests – are still detected.
14
+ */
15
+ const splitByParagraph = (text) => {
16
+ const paragraphs = [];
17
+ const tokens = text.split(/(\n{2,})/);
18
+ for (let i = 0; i < tokens.length; i++) {
19
+ const token = tokens[i];
20
+ if (i % 2 === 0) {
21
+ if (token) paragraphs.push(token);
22
+ continue;
23
+ }
24
+ const pairsOfNewlines = Math.floor(token.length / 2);
25
+ const blankParagraphs = Math.max(0, pairsOfNewlines - 2);
26
+ for (let j = 0; j < blankParagraphs; j++) paragraphs.push("\n\n");
27
+ }
28
+ return paragraphs;
29
+ };
30
+ /**
31
+ * Determine whether two paragraphs match – either exactly, or by sharing the
32
+ * same "special-character signature".
33
+ */
34
+ const paragraphMatches = (paragraph, baseParagraph, paragraphSignature, baseSignature) => {
35
+ if (paragraph === baseParagraph) return true;
36
+ if (paragraphSignature.length !== baseSignature.length) return false;
37
+ for (let i = 0; i < paragraphSignature.length; i++) if (paragraphSignature[i].char !== baseSignature[i].char) return false;
38
+ return true;
39
+ };
40
+ /**
41
+ * Re-order `textToReorder` so that its paragraphs follow the ordering found in
42
+ * `baseFileContent`, while preserving any extra paragraphs (those not present
43
+ * in the base file) in a position that is intuitive for a human reader: right
44
+ * after the closest preceding paragraph coming from the base file.
45
+ */
46
+ const reorderParagraphs = (textToReorder, baseFileContent) => {
47
+ const baseFileParagraphs = splitByParagraph(baseFileContent);
48
+ const textToReorderParagraphs = splitByParagraph(textToReorder);
49
+ const baseSignatures = baseFileParagraphs.map((p) => require_utils_listSpecialChars.listSpecialChars(p));
50
+ const textSignatures = textToReorderParagraphs.map((p) => require_utils_listSpecialChars.listSpecialChars(p));
51
+ const firstMatchIndexForBase = Array(baseFileParagraphs.length).fill(-1);
52
+ const paragraphMatchedBaseIdx = Array(textToReorderParagraphs.length).fill(null);
53
+ for (let i = 0; i < textToReorderParagraphs.length; i++) {
54
+ const paragraph = textToReorderParagraphs[i];
55
+ const sig = textSignatures[i];
56
+ let foundIdx = baseFileParagraphs.findIndex((baseParagraph, idx) => firstMatchIndexForBase[idx] === -1 && paragraph === baseParagraph);
57
+ if (foundIdx === -1) foundIdx = baseFileParagraphs.findIndex((baseParagraph, idx) => firstMatchIndexForBase[idx] === -1 && paragraphMatches(paragraph, baseParagraph, sig, baseSignatures[idx]));
58
+ if (foundIdx !== -1) {
59
+ firstMatchIndexForBase[foundIdx] = i;
60
+ paragraphMatchedBaseIdx[i] = foundIdx;
61
+ }
62
+ }
63
+ const insertAfterBaseIdx = Array(textToReorderParagraphs.length).fill(-1);
64
+ let maxBaseIdxEncountered = -1;
65
+ for (let i = 0; i < textToReorderParagraphs.length; i++) {
66
+ const matchedBase = paragraphMatchedBaseIdx[i];
67
+ if (matchedBase !== null) {
68
+ if (matchedBase > maxBaseIdxEncountered) maxBaseIdxEncountered = matchedBase;
69
+ } else insertAfterBaseIdx[i] = maxBaseIdxEncountered;
70
+ }
71
+ const result = [];
72
+ const extraParagraphsBuckets = {};
73
+ insertAfterBaseIdx.forEach((afterIdx, paragraphIdx) => {
74
+ if (afterIdx === -1) return;
75
+ extraParagraphsBuckets[afterIdx] = extraParagraphsBuckets[afterIdx] || [];
76
+ extraParagraphsBuckets[afterIdx].push(paragraphIdx);
77
+ });
78
+ for (let bIdx = 0; bIdx < baseFileParagraphs.length; bIdx++) {
79
+ const matchedParagraphIdx = firstMatchIndexForBase[bIdx];
80
+ if (matchedParagraphIdx !== -1) result.push(textToReorderParagraphs[matchedParagraphIdx]);
81
+ if (extraParagraphsBuckets[bIdx]) extraParagraphsBuckets[bIdx].forEach((pIdx) => {
82
+ result.push(textToReorderParagraphs[pIdx]);
83
+ });
84
+ }
85
+ const leadingExtras = [];
86
+ insertAfterBaseIdx.forEach((afterIdx, pIdx) => {
87
+ if (afterIdx === -1 && paragraphMatchedBaseIdx[pIdx] === null) leadingExtras.push(textToReorderParagraphs[pIdx]);
88
+ });
89
+ return [...leadingExtras, ...result].join("\n\n");
90
+ };
4
91
 
5
- `)};exports.reorderParagraphs=r;
92
+ //#endregion
93
+ exports.reorderParagraphs = reorderParagraphs;
6
94
  //# sourceMappingURL=reorderParagraphs.cjs.map