@intlayer/cli 6.1.6 → 7.0.0-canary.0

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 (287) hide show
  1. package/dist/cjs/IntlayerEventListener.cjs +187 -239
  2. package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
  3. package/dist/cjs/_virtual/_utils_asset.cjs +104 -0
  4. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  5. package/dist/cjs/build.cjs +23 -42
  6. package/dist/cjs/build.cjs.map +1 -1
  7. package/dist/cjs/cli.cjs +370 -431
  8. package/dist/cjs/cli.cjs.map +1 -1
  9. package/dist/cjs/config.cjs +10 -35
  10. package/dist/cjs/config.cjs.map +1 -1
  11. package/dist/cjs/editor.cjs +51 -66
  12. package/dist/cjs/editor.cjs.map +1 -1
  13. package/dist/cjs/fill/fill.cjs +73 -301
  14. package/dist/cjs/fill/fill.cjs.map +1 -1
  15. package/dist/cjs/fill/formatAutoFillData.cjs +48 -106
  16. package/dist/cjs/fill/formatAutoFillData.cjs.map +1 -1
  17. package/dist/cjs/fill/formatAutoFilledFilePath.cjs +27 -43
  18. package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
  19. package/dist/cjs/fill/formatFillData.cjs +50 -0
  20. package/dist/cjs/fill/formatFillData.cjs.map +1 -0
  21. package/dist/cjs/fill/groupLimiter.cjs +42 -0
  22. package/dist/cjs/fill/groupLimiter.cjs.map +1 -0
  23. package/dist/cjs/fill/index.cjs +5 -25
  24. package/dist/cjs/fill/listTranslationsTasks.cjs +77 -0
  25. package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -0
  26. package/dist/cjs/fill/test-original-case.cjs +10 -0
  27. package/dist/cjs/fill/test-original-case.cjs.map +1 -0
  28. package/dist/cjs/fill/translateDictionary.cjs +148 -0
  29. package/dist/cjs/fill/translateDictionary.cjs.map +1 -0
  30. package/dist/cjs/fill/writeAutoFill.cjs +48 -0
  31. package/dist/cjs/fill/writeAutoFill.cjs.map +1 -0
  32. package/dist/cjs/fill/writeFill.cjs +50 -0
  33. package/dist/cjs/fill/writeFill.cjs.map +1 -0
  34. package/dist/cjs/getTargetDictionary.cjs +36 -76
  35. package/dist/cjs/getTargetDictionary.cjs.map +1 -1
  36. package/dist/cjs/index.cjs +31 -45
  37. package/dist/cjs/listContentDeclaration.cjs +36 -64
  38. package/dist/cjs/listContentDeclaration.cjs.map +1 -1
  39. package/dist/cjs/liveSync.cjs +146 -221
  40. package/dist/cjs/liveSync.cjs.map +1 -1
  41. package/dist/cjs/pull.cjs +132 -195
  42. package/dist/cjs/pull.cjs.map +1 -1
  43. package/dist/cjs/push/pullLog.cjs +101 -144
  44. package/dist/cjs/push/pullLog.cjs.map +1 -1
  45. package/dist/cjs/push/push.cjs +159 -249
  46. package/dist/cjs/push/push.cjs.map +1 -1
  47. package/dist/cjs/pushConfig.cjs +18 -45
  48. package/dist/cjs/pushConfig.cjs.map +1 -1
  49. package/dist/cjs/pushLog.cjs +87 -128
  50. package/dist/cjs/pushLog.cjs.map +1 -1
  51. package/dist/cjs/reviewDoc.cjs +183 -291
  52. package/dist/cjs/reviewDoc.cjs.map +1 -1
  53. package/dist/cjs/test/index.cjs +52 -91
  54. package/dist/cjs/test/index.cjs.map +1 -1
  55. package/dist/cjs/test/listMissingTranslations.cjs +35 -62
  56. package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
  57. package/dist/cjs/translateDoc.cjs +127 -221
  58. package/dist/cjs/translateDoc.cjs.map +1 -1
  59. package/dist/cjs/utils/calculateChunks.cjs +85 -115
  60. package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
  61. package/dist/cjs/utils/checkAccess.cjs +33 -72
  62. package/dist/cjs/utils/checkAccess.cjs.map +1 -1
  63. package/dist/cjs/utils/checkFileModifiedRange.cjs +75 -91
  64. package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
  65. package/dist/cjs/utils/checkLastUpdateTime.cjs +17 -30
  66. package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
  67. package/dist/cjs/utils/chunkInference.cjs +28 -47
  68. package/dist/cjs/utils/chunkInference.cjs.map +1 -1
  69. package/dist/cjs/utils/fixChunkStartEndChars.cjs +23 -42
  70. package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
  71. package/dist/cjs/utils/formatTimeDiff.cjs +17 -43
  72. package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
  73. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +13 -32
  74. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
  75. package/dist/cjs/utils/getOutputFilePath.cjs +71 -86
  76. package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
  77. package/dist/cjs/utils/getParentPackageJSON.cjs +19 -44
  78. package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
  79. package/dist/cjs/utils/listSpecialChars.cjs +49 -73
  80. package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
  81. package/dist/cjs/utils/mapChunksBetweenFiles.cjs +90 -132
  82. package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
  83. package/dist/cjs/utils/reorderParagraphs.cjs +86 -118
  84. package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
  85. package/dist/cjs/watch.cjs +21 -39
  86. package/dist/cjs/watch.cjs.map +1 -1
  87. package/dist/esm/IntlayerEventListener.mjs +178 -201
  88. package/dist/esm/IntlayerEventListener.mjs.map +1 -1
  89. package/dist/esm/_virtual/_utils_asset.mjs +100 -0
  90. package/dist/esm/_virtual/rolldown_runtime.mjs +8 -0
  91. package/dist/esm/build.mjs +20 -23
  92. package/dist/esm/build.mjs.map +1 -1
  93. package/dist/esm/cli.mjs +349 -380
  94. package/dist/esm/cli.mjs.map +1 -1
  95. package/dist/esm/config.mjs +8 -14
  96. package/dist/esm/config.mjs.map +1 -1
  97. package/dist/esm/editor.mjs +47 -41
  98. package/dist/esm/editor.mjs.map +1 -1
  99. package/dist/esm/fill/fill.mjs +68 -300
  100. package/dist/esm/fill/fill.mjs.map +1 -1
  101. package/dist/esm/fill/formatAutoFillData.mjs +47 -81
  102. package/dist/esm/fill/formatAutoFillData.mjs.map +1 -1
  103. package/dist/esm/fill/formatAutoFilledFilePath.mjs +25 -19
  104. package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
  105. package/dist/esm/fill/formatFillData.mjs +50 -0
  106. package/dist/esm/fill/formatFillData.mjs.map +1 -0
  107. package/dist/esm/fill/groupLimiter.mjs +40 -0
  108. package/dist/esm/fill/groupLimiter.mjs.map +1 -0
  109. package/dist/esm/fill/index.mjs +4 -3
  110. package/dist/esm/fill/listTranslationsTasks.mjs +70 -0
  111. package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -0
  112. package/dist/esm/fill/test-original-case.mjs +10 -0
  113. package/dist/esm/fill/test-original-case.mjs.map +1 -0
  114. package/dist/esm/fill/translateDictionary.mjs +141 -0
  115. package/dist/esm/fill/translateDictionary.mjs.map +1 -0
  116. package/dist/esm/fill/writeAutoFill.mjs +44 -0
  117. package/dist/esm/fill/writeAutoFill.mjs.map +1 -0
  118. package/dist/esm/fill/writeFill.mjs +45 -0
  119. package/dist/esm/fill/writeFill.mjs.map +1 -0
  120. package/dist/esm/getTargetDictionary.mjs +27 -48
  121. package/dist/esm/getTargetDictionary.mjs.map +1 -1
  122. package/dist/esm/index.mjs +15 -13
  123. package/dist/esm/listContentDeclaration.mjs +28 -43
  124. package/dist/esm/listContentDeclaration.mjs.map +1 -1
  125. package/dist/esm/liveSync.mjs +135 -187
  126. package/dist/esm/liveSync.mjs.map +1 -1
  127. package/dist/esm/pull.mjs +125 -178
  128. package/dist/esm/pull.mjs.map +1 -1
  129. package/dist/esm/push/pullLog.mjs +99 -125
  130. package/dist/esm/push/pullLog.mjs.map +1 -1
  131. package/dist/esm/push/push.mjs +149 -221
  132. package/dist/esm/push/push.mjs.map +1 -1
  133. package/dist/esm/pushConfig.mjs +14 -23
  134. package/dist/esm/pushConfig.mjs.map +1 -1
  135. package/dist/esm/pushLog.mjs +85 -109
  136. package/dist/esm/pushLog.mjs.map +1 -1
  137. package/dist/esm/reviewDoc.mjs +167 -264
  138. package/dist/esm/reviewDoc.mjs.map +1 -1
  139. package/dist/esm/test/index.mjs +47 -73
  140. package/dist/esm/test/index.mjs.map +1 -1
  141. package/dist/esm/test/listMissingTranslations.mjs +30 -41
  142. package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
  143. package/dist/esm/translateDoc.mjs +114 -193
  144. package/dist/esm/translateDoc.mjs.map +1 -1
  145. package/dist/esm/utils/calculateChunks.mjs +83 -91
  146. package/dist/esm/utils/calculateChunks.mjs.map +1 -1
  147. package/dist/esm/utils/checkAccess.mjs +28 -46
  148. package/dist/esm/utils/checkAccess.mjs.map +1 -1
  149. package/dist/esm/utils/checkFileModifiedRange.mjs +73 -65
  150. package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
  151. package/dist/esm/utils/checkLastUpdateTime.mjs +15 -6
  152. package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
  153. package/dist/esm/utils/chunkInference.mjs +24 -24
  154. package/dist/esm/utils/chunkInference.mjs.map +1 -1
  155. package/dist/esm/utils/fixChunkStartEndChars.mjs +22 -18
  156. package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
  157. package/dist/esm/utils/formatTimeDiff.mjs +16 -19
  158. package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
  159. package/dist/esm/utils/getIsFileUpdatedRecently.mjs +11 -8
  160. package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
  161. package/dist/esm/utils/getOutputFilePath.mjs +70 -62
  162. package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
  163. package/dist/esm/utils/getParentPackageJSON.mjs +16 -20
  164. package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
  165. package/dist/esm/utils/listSpecialChars.mjs +48 -49
  166. package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
  167. package/dist/esm/utils/mapChunksBetweenFiles.mjs +87 -107
  168. package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
  169. package/dist/esm/utils/reorderParagraphs.mjs +85 -93
  170. package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
  171. package/dist/esm/watch.mjs +17 -17
  172. package/dist/esm/watch.mjs.map +1 -1
  173. package/dist/types/IntlayerEventListener.d.ts +63 -59
  174. package/dist/types/IntlayerEventListener.d.ts.map +1 -1
  175. package/dist/types/build.d.ts +10 -7
  176. package/dist/types/build.d.ts.map +1 -1
  177. package/dist/types/cli.d.ts +13 -10
  178. package/dist/types/cli.d.ts.map +1 -1
  179. package/dist/types/config.d.ts +7 -4
  180. package/dist/types/config.d.ts.map +1 -1
  181. package/dist/types/editor.d.ts +6 -4
  182. package/dist/types/editor.d.ts.map +1 -1
  183. package/dist/types/fill/fill.d.ts +20 -14
  184. package/dist/types/fill/fill.d.ts.map +1 -1
  185. package/dist/types/fill/formatAutoFillData.d.ts +10 -7
  186. package/dist/types/fill/formatAutoFillData.d.ts.map +1 -1
  187. package/dist/types/fill/formatAutoFilledFilePath.d.ts +6 -2
  188. package/dist/types/fill/formatAutoFilledFilePath.d.ts.map +1 -1
  189. package/dist/types/fill/formatFillData.d.ts +12 -0
  190. package/dist/types/fill/formatFillData.d.ts.map +1 -0
  191. package/dist/types/fill/groupLimiter.d.ts +15 -0
  192. package/dist/types/fill/groupLimiter.d.ts.map +1 -0
  193. package/dist/types/fill/index.d.ts +3 -3
  194. package/dist/types/fill/listTranslationsTasks.d.ts +15 -0
  195. package/dist/types/fill/listTranslationsTasks.d.ts.map +1 -0
  196. package/dist/types/fill/test-original-case.d.ts +1 -0
  197. package/dist/types/fill/translateDictionary.d.ts +19 -0
  198. package/dist/types/fill/translateDictionary.d.ts.map +1 -0
  199. package/dist/types/fill/writeAutoFill.d.ts +7 -0
  200. package/dist/types/fill/writeAutoFill.d.ts.map +1 -0
  201. package/dist/types/fill/writeFill.d.ts +7 -0
  202. package/dist/types/fill/writeFill.d.ts.map +1 -0
  203. package/dist/types/getTargetDictionary.d.ts +17 -13
  204. package/dist/types/getTargetDictionary.d.ts.map +1 -1
  205. package/dist/types/index.d.ts +15 -14
  206. package/dist/types/listContentDeclaration.d.ts +10 -7
  207. package/dist/types/listContentDeclaration.d.ts.map +1 -1
  208. package/dist/types/liveSync.d.ts +8 -3
  209. package/dist/types/liveSync.d.ts.map +1 -1
  210. package/dist/types/pull.d.ts +9 -6
  211. package/dist/types/pull.d.ts.map +1 -1
  212. package/dist/types/push/pullLog.d.ts +25 -21
  213. package/dist/types/push/pullLog.d.ts.map +1 -1
  214. package/dist/types/push/push.d.ts +13 -9
  215. package/dist/types/push/push.d.ts.map +1 -1
  216. package/dist/types/pushConfig.d.ts +7 -4
  217. package/dist/types/pushConfig.d.ts.map +1 -1
  218. package/dist/types/pushLog.d.ts +23 -20
  219. package/dist/types/pushLog.d.ts.map +1 -1
  220. package/dist/types/reviewDoc.d.ts +34 -17
  221. package/dist/types/reviewDoc.d.ts.map +1 -1
  222. package/dist/types/test/index.d.ts +9 -5
  223. package/dist/types/test/index.d.ts.map +1 -1
  224. package/dist/types/test/listMissingTranslations.d.ts +14 -10
  225. package/dist/types/test/listMissingTranslations.d.ts.map +1 -1
  226. package/dist/types/translateDoc.d.ts +34 -17
  227. package/dist/types/translateDoc.d.ts.map +1 -1
  228. package/dist/types/utils/calculateChunks.d.ts +10 -7
  229. package/dist/types/utils/calculateChunks.d.ts.map +1 -1
  230. package/dist/types/utils/checkAccess.d.ts +8 -4
  231. package/dist/types/utils/checkAccess.d.ts.map +1 -1
  232. package/dist/types/utils/checkFileModifiedRange.d.ts +8 -6
  233. package/dist/types/utils/checkFileModifiedRange.d.ts.map +1 -1
  234. package/dist/types/utils/checkLastUpdateTime.d.ts +4 -1
  235. package/dist/types/utils/checkLastUpdateTime.d.ts.map +1 -1
  236. package/dist/types/utils/chunkInference.d.ts +9 -6
  237. package/dist/types/utils/chunkInference.d.ts.map +1 -1
  238. package/dist/types/utils/fixChunkStartEndChars.d.ts +4 -1
  239. package/dist/types/utils/fixChunkStartEndChars.d.ts.map +1 -1
  240. package/dist/types/utils/formatTimeDiff.d.ts +4 -1
  241. package/dist/types/utils/formatTimeDiff.d.ts.map +1 -1
  242. package/dist/types/utils/getIsFileUpdatedRecently.d.ts +4 -1
  243. package/dist/types/utils/getIsFileUpdatedRecently.d.ts.map +1 -1
  244. package/dist/types/utils/getOutputFilePath.d.ts +7 -2
  245. package/dist/types/utils/getOutputFilePath.d.ts.map +1 -1
  246. package/dist/types/utils/getParentPackageJSON.d.ts +30 -28
  247. package/dist/types/utils/getParentPackageJSON.d.ts.map +1 -1
  248. package/dist/types/utils/listSpecialChars.d.ts +9 -7
  249. package/dist/types/utils/listSpecialChars.d.ts.map +1 -1
  250. package/dist/types/utils/mapChunksBetweenFiles.d.ts +10 -6
  251. package/dist/types/utils/mapChunksBetweenFiles.d.ts.map +1 -1
  252. package/dist/types/utils/reorderParagraphs.d.ts +4 -1
  253. package/dist/types/utils/reorderParagraphs.d.ts.map +1 -1
  254. package/dist/types/watch.d.ts +9 -6
  255. package/dist/types/watch.d.ts.map +1 -1
  256. package/package.json +42 -47
  257. package/LICENSE +0 -202
  258. package/dist/cjs/fill/autoFill.cjs +0 -105
  259. package/dist/cjs/fill/autoFill.cjs.map +0 -1
  260. package/dist/cjs/fill/index.cjs.map +0 -1
  261. package/dist/cjs/index.cjs.map +0 -1
  262. package/dist/cjs/utils/getChunk.cjs +0 -77
  263. package/dist/cjs/utils/getChunk.cjs.map +0 -1
  264. package/dist/cjs/utils/splitTextByLine.cjs +0 -35
  265. package/dist/cjs/utils/splitTextByLine.cjs.map +0 -1
  266. package/dist/esm/fill/autoFill.mjs +0 -92
  267. package/dist/esm/fill/autoFill.mjs.map +0 -1
  268. package/dist/esm/fill/index.mjs.map +0 -1
  269. package/dist/esm/index.mjs.map +0 -1
  270. package/dist/esm/prompts/REVIEW_PROMPT.md +0 -37
  271. package/dist/esm/prompts/TRANSLATE_PROMPT.md +0 -38
  272. package/dist/esm/utils/calculrateChunkTest.md +0 -9
  273. package/dist/esm/utils/getChunk.mjs +0 -53
  274. package/dist/esm/utils/getChunk.mjs.map +0 -1
  275. package/dist/esm/utils/splitTextByLine.mjs +0 -11
  276. package/dist/esm/utils/splitTextByLine.mjs.map +0 -1
  277. package/dist/types/fill/autoFill.d.ts +0 -4
  278. package/dist/types/fill/autoFill.d.ts.map +0 -1
  279. package/dist/types/fill/index.d.ts.map +0 -1
  280. package/dist/types/index.d.ts.map +0 -1
  281. package/dist/types/utils/getChunk.d.ts +0 -9
  282. package/dist/types/utils/getChunk.d.ts.map +0 -1
  283. package/dist/types/utils/splitTextByLine.d.ts +0 -2
  284. package/dist/types/utils/splitTextByLine.d.ts.map +0 -1
  285. /package/dist/{cjs → assets}/prompts/REVIEW_PROMPT.md +0 -0
  286. /package/dist/{cjs → assets}/prompts/TRANSLATE_PROMPT.md +0 -0
  287. /package/dist/{cjs/utils/calculrateChunkTest.md → assets/utils/_calculateChunkTest.md} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/fixChunkStartEndChars.ts"],"sourcesContent":["const CHAR_TO_CHECK_FORMATTING = ['```', '\\n\\n', '\\n', '---', '{{', '}}'];\n\n// Escape a string for use in RegExp\nconst escapeForRegExp = (str: string) =>\n str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\n/g, '\\\\n');\n\n// Build once the regex that matches any combination of the formatting chars appearing\n// sequentially at the beginning or at the end of a string.\nconst FORMATTING_REGEX_SOURCE = `(?:${CHAR_TO_CHECK_FORMATTING.map(escapeForRegExp).join('|')})+`;\nconst LEADING_FORMATTING_REGEX = new RegExp(`^${FORMATTING_REGEX_SOURCE}`);\nconst TRAILING_FORMATTING_REGEX = new RegExp(`${FORMATTING_REGEX_SOURCE}$`);\n\nexport const fixChunkStartEndChars = (\n reviewedChunkResult: string,\n baseChunkContext: string\n) => {\n let result = reviewedChunkResult;\n\n const baseLeading =\n baseChunkContext.match(LEADING_FORMATTING_REGEX)?.[0] ?? '';\n const baseTrailing =\n baseChunkContext.match(TRAILING_FORMATTING_REGEX)?.[0] ?? '';\n\n const resultLeading = result.match(LEADING_FORMATTING_REGEX)?.[0] ?? '';\n const resultTrailing = result.match(TRAILING_FORMATTING_REGEX)?.[0] ?? '';\n\n // Fix leading formatting\n if (baseLeading !== resultLeading) {\n // Remove current leading formatting found in result and prepend the correct one\n result = baseLeading + result.slice(resultLeading.length);\n }\n\n // Fix trailing formatting\n if (baseTrailing !== resultTrailing) {\n // Remove current trailing formatting found in result and append the correct one\n result =\n result.slice(0, result.length - resultTrailing.length) + baseTrailing;\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,2BAA2B,CAAC,OAAO,QAAQ,MAAM,OAAO,MAAM,IAAI;AAGxE,MAAM,kBAAkB,CAAC,QACvB,IAAI,QAAQ,uBAAuB,MAAM,EAAE,QAAQ,OAAO,KAAK;AAIjE,MAAM,0BAA0B,MAAM,yBAAyB,IAAI,eAAe,EAAE,KAAK,GAAG,CAAC;AAC7F,MAAM,2BAA2B,IAAI,OAAO,IAAI,uBAAuB,EAAE;AACzE,MAAM,4BAA4B,IAAI,OAAO,GAAG,uBAAuB,GAAG;AAEnE,MAAM,wBAAwB,CACnC,qBACA,qBACG;AACH,MAAI,SAAS;AAEb,QAAM,cACJ,iBAAiB,MAAM,wBAAwB,IAAI,CAAC,KAAK;AAC3D,QAAM,eACJ,iBAAiB,MAAM,yBAAyB,IAAI,CAAC,KAAK;AAE5D,QAAM,gBAAgB,OAAO,MAAM,wBAAwB,IAAI,CAAC,KAAK;AACrE,QAAM,iBAAiB,OAAO,MAAM,yBAAyB,IAAI,CAAC,KAAK;AAGvE,MAAI,gBAAgB,eAAe;AAEjC,aAAS,cAAc,OAAO,MAAM,cAAc,MAAM;AAAA,EAC1D;AAGA,MAAI,iBAAiB,gBAAgB;AAEnC,aACE,OAAO,MAAM,GAAG,OAAO,SAAS,eAAe,MAAM,IAAI;AAAA,EAC7D;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"fixChunkStartEndChars.cjs","names":[],"sources":["../../../src/utils/fixChunkStartEndChars.ts"],"sourcesContent":["const CHAR_TO_CHECK_FORMATTING = ['```', '\\n\\n', '\\n', '---', '{{', '}}'];\n\n// Escape a string for use in RegExp\nconst escapeForRegExp = (str: string) =>\n str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\n/g, '\\\\n');\n\n// Build once the regex that matches any combination of the formatting chars appearing\n// sequentially at the beginning or at the end of a string.\nconst FORMATTING_REGEX_SOURCE = `(?:${CHAR_TO_CHECK_FORMATTING.map(escapeForRegExp).join('|')})+`;\nconst LEADING_FORMATTING_REGEX = new RegExp(`^${FORMATTING_REGEX_SOURCE}`);\nconst TRAILING_FORMATTING_REGEX = new RegExp(`${FORMATTING_REGEX_SOURCE}$`);\n\nexport const fixChunkStartEndChars = (\n reviewedChunkResult: string,\n baseChunkContext: string\n) => {\n let result = reviewedChunkResult;\n\n const baseLeading =\n baseChunkContext.match(LEADING_FORMATTING_REGEX)?.[0] ?? '';\n const baseTrailing =\n baseChunkContext.match(TRAILING_FORMATTING_REGEX)?.[0] ?? '';\n\n const resultLeading = result.match(LEADING_FORMATTING_REGEX)?.[0] ?? '';\n const resultTrailing = result.match(TRAILING_FORMATTING_REGEX)?.[0] ?? '';\n\n // Fix leading formatting\n if (baseLeading !== resultLeading) {\n // Remove current leading formatting found in result and prepend the correct one\n result = baseLeading + result.slice(resultLeading.length);\n }\n\n // Fix trailing formatting\n if (baseTrailing !== resultTrailing) {\n // Remove current trailing formatting found in result and append the correct one\n result =\n result.slice(0, result.length - resultTrailing.length) + baseTrailing;\n }\n\n return result;\n};\n"],"mappings":";;AAAA,MAAM,2BAA2B;CAAC;CAAO;CAAQ;CAAM;CAAO;CAAM;CAAK;AAGzE,MAAM,mBAAmB,QACvB,IAAI,QAAQ,uBAAuB,OAAO,CAAC,QAAQ,OAAO,MAAM;AAIlE,MAAM,0BAA0B,MAAM,yBAAyB,IAAI,gBAAgB,CAAC,KAAK,IAAI,CAAC;AAC9F,MAAM,2CAA2B,IAAI,OAAO,IAAI,0BAA0B;AAC1E,MAAM,4CAA4B,IAAI,OAAO,GAAG,wBAAwB,GAAG;AAE3E,MAAa,yBACX,qBACA,qBACG;CACH,IAAI,SAAS;CAEb,MAAM,cACJ,iBAAiB,MAAM,yBAAyB,GAAG,MAAM;CAC3D,MAAM,eACJ,iBAAiB,MAAM,0BAA0B,GAAG,MAAM;CAE5D,MAAM,gBAAgB,OAAO,MAAM,yBAAyB,GAAG,MAAM;CACrE,MAAM,iBAAiB,OAAO,MAAM,0BAA0B,GAAG,MAAM;AAGvE,KAAI,gBAAgB,cAElB,UAAS,cAAc,OAAO,MAAM,cAAc,OAAO;AAI3D,KAAI,iBAAiB,eAEnB,UACE,OAAO,MAAM,GAAG,OAAO,SAAS,eAAe,OAAO,GAAG;AAG7D,QAAO"}
@@ -1,46 +1,20 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var formatTimeDiff_exports = {};
20
- __export(formatTimeDiff_exports, {
21
- formatTimeDiff: () => formatTimeDiff
22
- });
23
- module.exports = __toCommonJS(formatTimeDiff_exports);
1
+
2
+ //#region src/utils/formatTimeDiff.ts
24
3
  const formatTimeDiff = (realtiveTime) => {
25
- const diff = realtiveTime.getTime();
26
- const MS_IN_SECOND = 1e3;
27
- const MS_IN_MINUTE = 60 * MS_IN_SECOND;
28
- const MS_IN_HOUR = 60 * MS_IN_MINUTE;
29
- const MS_IN_DAY = 24 * MS_IN_HOUR;
30
- const days = Math.floor(diff / MS_IN_DAY);
31
- const hours = Math.floor(diff % MS_IN_DAY / MS_IN_HOUR);
32
- const minutes = Math.floor(diff % MS_IN_HOUR / MS_IN_MINUTE);
33
- const seconds = Math.floor(diff % MS_IN_MINUTE / MS_IN_SECOND);
34
- if (days > 0) {
35
- return `${days}d ${hours}h ${minutes}m ${seconds}s`;
36
- }
37
- if (hours > 0) {
38
- return `${hours}h ${minutes}m ${seconds}s`;
39
- }
40
- return `${minutes}m ${seconds}s`;
4
+ const diff = realtiveTime.getTime();
5
+ const MS_IN_SECOND = 1e3;
6
+ const MS_IN_MINUTE = 60 * MS_IN_SECOND;
7
+ const MS_IN_HOUR = 60 * MS_IN_MINUTE;
8
+ const MS_IN_DAY = 24 * MS_IN_HOUR;
9
+ const days = Math.floor(diff / MS_IN_DAY);
10
+ const hours = Math.floor(diff % MS_IN_DAY / MS_IN_HOUR);
11
+ const minutes = Math.floor(diff % MS_IN_HOUR / MS_IN_MINUTE);
12
+ const seconds = Math.floor(diff % MS_IN_MINUTE / MS_IN_SECOND);
13
+ if (days > 0) return `${days}d ${hours}h ${minutes}m ${seconds}s`;
14
+ if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
15
+ return `${minutes}m ${seconds}s`;
41
16
  };
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- formatTimeDiff
45
- });
17
+
18
+ //#endregion
19
+ exports.formatTimeDiff = formatTimeDiff;
46
20
  //# sourceMappingURL=formatTimeDiff.cjs.map
@@ -1 +1 @@
1
- {"version":3,"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;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,iBAAiB,CAAC,iBAA+B;AAC5D,QAAM,OAAO,aAAa,QAAQ;AAElC,QAAM,eAAe;AACrB,QAAM,eAAe,KAAK;AAC1B,QAAM,aAAa,KAAK;AACxB,QAAM,YAAY,KAAK;AAEvB,QAAM,OAAO,KAAK,MAAM,OAAO,SAAS;AACxC,QAAM,QAAQ,KAAK,MAAO,OAAO,YAAa,UAAU;AACxD,QAAM,UAAU,KAAK,MAAO,OAAO,aAAc,YAAY;AAC7D,QAAM,UAAU,KAAK,MAAO,OAAO,eAAgB,YAAY;AAE/D,MAAI,OAAO,GAAG;AACZ,WAAO,GAAG,IAAI,KAAK,KAAK,KAAK,OAAO,KAAK,OAAO;AAAA,EAClD;AACA,MAAI,QAAQ,GAAG;AACb,WAAO,GAAG,KAAK,KAAK,OAAO,KAAK,OAAO;AAAA,EACzC;AAEA,SAAO,GAAG,OAAO,KAAK,OAAO;AAC/B;","names":[]}
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,36 +1,17 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var getIsFileUpdatedRecently_exports = {};
20
- __export(getIsFileUpdatedRecently_exports, {
21
- getIsFileUpdatedRecently: () => getIsFileUpdatedRecently
22
- });
23
- module.exports = __toCommonJS(getIsFileUpdatedRecently_exports);
24
- var import_fs = require("fs");
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let node_fs = require("node:fs");
3
+ node_fs = require_rolldown_runtime.__toESM(node_fs);
4
+
5
+ //#region src/utils/getIsFileUpdatedRecently.ts
25
6
  const SKIP_RANGE_OF_LAST_UPDATE_TIME = 0;
7
+ /**
8
+ * Check if file was updated recently, to skip re-translation
9
+ */
26
10
  const getIsFileUpdatedRecently = (localeFilePath) => {
27
- const stats = (0, import_fs.statSync)(localeFilePath);
28
- const lastModified = new Date(stats.mtime);
29
- const threshold = new Date(Date.now() - SKIP_RANGE_OF_LAST_UPDATE_TIME);
30
- return lastModified > threshold;
11
+ const stats = (0, node_fs.statSync)(localeFilePath);
12
+ return new Date(stats.mtime) > new Date(Date.now() - SKIP_RANGE_OF_LAST_UPDATE_TIME);
31
13
  };
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {
34
- getIsFileUpdatedRecently
35
- });
14
+
15
+ //#endregion
16
+ exports.getIsFileUpdatedRecently = getIsFileUpdatedRecently;
36
17
  //# sourceMappingURL=getIsFileUpdatedRecently.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/getIsFileUpdatedRecently.ts"],"sourcesContent":["import { statSync } from '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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAyB;AAEzB,MAAM,iCAAyC;AAKxC,MAAM,2BAA2B,CAAC,mBAAoC;AAC3E,QAAM,YAAQ,oBAAS,cAAc;AACrC,QAAM,eAAe,IAAI,KAAK,MAAM,KAAK;AACzC,QAAM,YAAY,IAAI,KAAK,KAAK,IAAI,IAAI,8BAA8B;AAEtE,SAAO,eAAe;AACxB;","names":[]}
1
+ {"version":3,"file":"getIsFileUpdatedRecently.cjs","names":["SKIP_RANGE_OF_LAST_UPDATE_TIME: number"],"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,MAAMA,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,89 +1,74 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var getOutputFilePath_exports = {};
20
- __export(getOutputFilePath_exports, {
21
- getOutputFilePath: () => getOutputFilePath
22
- });
23
- module.exports = __toCommonJS(getOutputFilePath_exports);
1
+
2
+ //#region src/utils/getOutputFilePath.ts
3
+ /**
4
+ * Get the output file path by replacing the base locale with the target locale
5
+ *
6
+ * This function handles two types of replacements:
7
+ * 1. Actual locale values (e.g., `/en/` `/fr/`)
8
+ * 2. Template placeholders (e.g., `{{baseLocale}}` `{{locale}}`, `{{baseLocaleName}}` `{{localeName}}`)
9
+ *
10
+ * Replacement patterns:
11
+ * - `/baseLocale/` `/locale/`
12
+ * - `\baseLocale\` `\locale\`
13
+ * - `_baseLocale.` `_locale.`
14
+ * - `baseLocale_` `locale_`
15
+ * - `.baseLocaleName.` → `.localeName.`
16
+ * - `{{baseLocale}}` → `{{locale}}`
17
+ * - `{{baseLocaleName}}` → `{{localeName}}`
18
+ *
19
+ * If no patterns match, appends `.locale` to the file extension.
20
+ *
21
+ * @param filePath - The input file path
22
+ * @param locale - The target locale
23
+ * @param baseLocale - The base locale to replace
24
+ * @returns The output file path with locale replacements
25
+ */
24
26
  const getOutputFilePath = (filePath, locale, baseLocale) => {
25
- if (!filePath || !locale || !baseLocale) {
26
- throw new Error("filePath, locale, and baseLocale are required");
27
- }
28
- let outputFilePath = filePath;
29
- const replacements = [
30
- // Template placeholders (processed first)
31
- {
32
- pattern: /\{\{baseLocale\}\}/g,
33
- replacement: "{{locale}}"
34
- },
35
- {
36
- pattern: /\{\{baseLocaleName\}\}/g,
37
- replacement: "{{localeName}}"
38
- },
39
- // Path separators (most specific first)
40
- {
41
- // Unix path separators
42
- pattern: new RegExp(`/${baseLocale}/`, "g"),
43
- replacement: `/${locale}/`
44
- },
45
- {
46
- // Windows path separators
47
- pattern: new RegExp(`\\\\${baseLocale}\\\\`, "g"),
48
- replacement: `\\${locale}\\`
49
- },
50
- // File naming patterns
51
- {
52
- // file_en.md → file_fr.md
53
- pattern: new RegExp(`_${baseLocale}\\.`, "g"),
54
- replacement: `_${locale}.`
55
- },
56
- {
57
- // /file_en.md /file_fr.md
58
- pattern: new RegExp(`/${baseLocale}_`, "g"),
59
- replacement: `/${locale}_`
60
- },
61
- {
62
- // Start of filename pattern en_guide.md → fr_guide.md (or after path separator)
63
- pattern: new RegExp(`(^|[\\/])${baseLocale}_`, "g"),
64
- replacement: `$1${locale}_`
65
- },
66
- {
67
- // Dot delimited pattern guide.en.md → guide.fr.md
68
- pattern: new RegExp(`\\.${baseLocale}\\.`, "g"),
69
- replacement: `.${locale}.`
70
- }
71
- ];
72
- for (const { pattern, replacement } of replacements) {
73
- outputFilePath = outputFilePath.replace(pattern, replacement);
74
- }
75
- if (outputFilePath === filePath) {
76
- const lastDotIndex = filePath.lastIndexOf(".");
77
- if (lastDotIndex > 0) {
78
- return `${filePath.slice(0, lastDotIndex)}.${locale}${filePath.slice(lastDotIndex)}`;
79
- } else {
80
- return `${filePath}.${locale}`;
81
- }
82
- }
83
- return outputFilePath;
27
+ if (!filePath || !locale || !baseLocale) throw new Error("filePath, locale, and baseLocale are required");
28
+ let outputFilePath = filePath;
29
+ const replacements = [
30
+ {
31
+ pattern: /\{\{baseLocale\}\}/g,
32
+ replacement: "{{locale}}"
33
+ },
34
+ {
35
+ pattern: /\{\{baseLocaleName\}\}/g,
36
+ replacement: "{{localeName}}"
37
+ },
38
+ {
39
+ pattern: new RegExp(`/${baseLocale}/`, "g"),
40
+ replacement: `/${locale}/`
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: `$1${locale}_`
57
+ },
58
+ {
59
+ pattern: new RegExp(`\\.${baseLocale}\\.`, "g"),
60
+ replacement: `.${locale}.`
61
+ }
62
+ ];
63
+ for (const { pattern, replacement } of replacements) outputFilePath = outputFilePath.replace(pattern, replacement);
64
+ if (outputFilePath === filePath) {
65
+ const lastDotIndex = filePath.lastIndexOf(".");
66
+ if (lastDotIndex > 0) return `${filePath.slice(0, lastDotIndex)}.${locale}${filePath.slice(lastDotIndex)}`;
67
+ else return `${filePath}.${locale}`;
68
+ }
69
+ return outputFilePath;
84
70
  };
85
- // Annotate the CommonJS export names for ESM import in node:
86
- 0 && (module.exports = {
87
- getOutputFilePath
88
- });
71
+
72
+ //#endregion
73
+ exports.getOutputFilePath = getOutputFilePath;
89
74
  //# sourceMappingURL=getOutputFilePath.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/getOutputFilePath.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config';\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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBO,MAAM,oBAAoB,CAC/B,UACA,QACA,eACW;AACX,MAAI,CAAC,YAAY,CAAC,UAAU,CAAC,YAAY;AACvC,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACjE;AAEA,MAAI,iBAAiB;AAGrB,QAAM,eAAe;AAAA;AAAA,IAEnB;AAAA,MACE,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA;AAAA,IAGA;AAAA;AAAA,MAEE,SAAS,IAAI,OAAO,IAAI,UAAU,KAAK,GAAG;AAAA,MAC1C,aAAa,IAAI,MAAM;AAAA,IACzB;AAAA,IACA;AAAA;AAAA,MAEE,SAAS,IAAI,OAAO,OAAO,UAAU,QAAQ,GAAG;AAAA,MAChD,aAAa,KAAK,MAAM;AAAA,IAC1B;AAAA;AAAA,IAGA;AAAA;AAAA,MAEE,SAAS,IAAI,OAAO,IAAI,UAAU,OAAO,GAAG;AAAA,MAC5C,aAAa,IAAI,MAAM;AAAA,IACzB;AAAA,IACA;AAAA;AAAA,MAEE,SAAS,IAAI,OAAO,IAAI,UAAU,KAAK,GAAG;AAAA,MAC1C,aAAa,IAAI,MAAM;AAAA,IACzB;AAAA,IACA;AAAA;AAAA,MAEE,SAAS,IAAI,OAAO,YAAY,UAAU,KAAK,GAAG;AAAA,MAClD,aAAa,KAAK,MAAM;AAAA,IAC1B;AAAA,IACA;AAAA;AAAA,MAEE,SAAS,IAAI,OAAO,MAAM,UAAU,OAAO,GAAG;AAAA,MAC9C,aAAa,IAAI,MAAM;AAAA,IACzB;AAAA,EACF;AAGA,aAAW,EAAE,SAAS,YAAY,KAAK,cAAc;AACnD,qBAAiB,eAAe,QAAQ,SAAS,WAAW;AAAA,EAC9D;AAGA,MAAI,mBAAmB,UAAU;AAC/B,UAAM,eAAe,SAAS,YAAY,GAAG;AAC7C,QAAI,eAAe,GAAG;AAEpB,aAAO,GAAG,SAAS,MAAM,GAAG,YAAY,CAAC,IAAI,MAAM,GAAG,SAAS,MAAM,YAAY,CAAC;AAAA,IACpF,OAAO;AAEL,aAAO,GAAG,QAAQ,IAAI,MAAM;AAAA,IAC9B;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"getOutputFilePath.cjs","names":[],"sources":["../../../src/utils/getOutputFilePath.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types';\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":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,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"}
@@ -1,47 +1,22 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var getParentPackageJSON_exports = {};
20
- __export(getParentPackageJSON_exports, {
21
- getParentPackageJSON: () => getParentPackageJSON
22
- });
23
- module.exports = __toCommonJS(getParentPackageJSON_exports);
24
- var import_fs = require("fs");
25
- var import_path = require("path");
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let node_path = require("node:path");
3
+ node_path = require_rolldown_runtime.__toESM(node_path);
4
+ let node_fs = require("node:fs");
5
+ node_fs = require_rolldown_runtime.__toESM(node_fs);
6
+
7
+ //#region src/utils/getParentPackageJSON.ts
26
8
  const getParentPackageJSON = (startDir) => {
27
- let currentDir = startDir;
28
- while (currentDir !== (0, import_path.dirname)(currentDir)) {
29
- const packageJsonPath = (0, import_path.resolve)(currentDir, "package.json");
30
- if ((0, import_fs.existsSync)(packageJsonPath)) {
31
- return JSON.parse((0, import_fs.readFileSync)(packageJsonPath, "utf8"));
32
- }
33
- currentDir = (0, import_path.dirname)(currentDir);
34
- }
35
- const rootPackageJsonPath = (0, import_path.resolve)(currentDir, "package.json");
36
- if ((0, import_fs.existsSync)(rootPackageJsonPath)) {
37
- return JSON.parse((0, import_fs.readFileSync)(rootPackageJsonPath, "utf8"));
38
- }
39
- throw new Error(
40
- `No package.json found in any parent directory of ${startDir}`
41
- );
9
+ let currentDir = startDir;
10
+ while (currentDir !== (0, node_path.dirname)(currentDir)) {
11
+ const packageJsonPath = (0, node_path.resolve)(currentDir, "package.json");
12
+ if ((0, node_fs.existsSync)(packageJsonPath)) return JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf8"));
13
+ currentDir = (0, node_path.dirname)(currentDir);
14
+ }
15
+ const rootPackageJsonPath = (0, node_path.resolve)(currentDir, "package.json");
16
+ if ((0, node_fs.existsSync)(rootPackageJsonPath)) return JSON.parse((0, node_fs.readFileSync)(rootPackageJsonPath, "utf8"));
17
+ throw new Error(`No package.json found in any parent directory of ${startDir}`);
42
18
  };
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- getParentPackageJSON
46
- });
19
+
20
+ //#endregion
21
+ exports.getParentPackageJSON = getParentPackageJSON;
47
22
  //# sourceMappingURL=getParentPackageJSON.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/getParentPackageJSON.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'fs';\nimport { dirname, resolve } from '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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAyC;AACzC,kBAAiC;AAgC1B,MAAM,uBAAuB,CAAC,aAAkC;AACrE,MAAI,aAAa;AAEjB,SAAO,mBAAe,qBAAQ,UAAU,GAAG;AAEzC,UAAM,sBAAkB,qBAAQ,YAAY,cAAc;AAE1D,YAAI,sBAAW,eAAe,GAAG;AAC/B,aAAO,KAAK,UAAM,wBAAa,iBAAiB,MAAM,CAAC;AAAA,IACzD;AAGA,qBAAa,qBAAQ,UAAU;AAAA,EACjC;AAGA,QAAM,0BAAsB,qBAAQ,YAAY,cAAc;AAC9D,UAAI,sBAAW,mBAAmB,GAAG;AACnC,WAAO,KAAK,UAAM,wBAAa,qBAAqB,MAAM,CAAC;AAAA,EAC7D;AAGA,QAAM,IAAI;AAAA,IACR,oDAAoD,QAAQ;AAAA,EAC9D;AACF;","names":[]}
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,78 +1,54 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var listSpecialChars_exports = {};
20
- __export(listSpecialChars_exports, {
21
- listSpecialChars: () => listSpecialChars
22
- });
23
- module.exports = __toCommonJS(listSpecialChars_exports);
1
+
2
+ //#region src/utils/listSpecialChars.ts
24
3
  const SPECIAL_CHARS = [
25
- " ",
26
- "\\",
27
- "|",
28
- "(",
29
- ")",
30
- "{",
31
- "}",
32
- "[",
33
- "]",
34
- "<",
35
- ">",
36
- '"',
37
- "=",
38
- "+",
39
- "*",
40
- "&",
41
- "#",
42
- "%",
43
- "$",
44
- "!",
45
- "?",
46
- ":",
47
- ";",
48
- "~"
4
+ " ",
5
+ "\\",
6
+ "|",
7
+ "(",
8
+ ")",
9
+ "{",
10
+ "}",
11
+ "[",
12
+ "]",
13
+ "<",
14
+ ">",
15
+ "\"",
16
+ "=",
17
+ "+",
18
+ "*",
19
+ "&",
20
+ "#",
21
+ "%",
22
+ "$",
23
+ "!",
24
+ "?",
25
+ ":",
26
+ ";",
27
+ "~"
49
28
  ];
50
29
  const listSpecialChars = (text) => {
51
- const results = [];
52
- let lineIndex = 0;
53
- for (let i = 0; i < text.length; i++) {
54
- const currentChar = text[i];
55
- if (currentChar === "\n") {
56
- results.push({
57
- char: "\\",
58
- lineStart: lineIndex,
59
- charStart: i
60
- });
61
- lineIndex++;
62
- continue;
63
- }
64
- if (SPECIAL_CHARS.includes(currentChar)) {
65
- results.push({
66
- char: currentChar,
67
- lineStart: lineIndex,
68
- charStart: i
69
- });
70
- }
71
- }
72
- return results;
30
+ const results = [];
31
+ let lineIndex = 0;
32
+ for (let i = 0; i < text.length; i++) {
33
+ const currentChar = text[i];
34
+ if (currentChar === "\n") {
35
+ results.push({
36
+ char: "\\",
37
+ lineStart: lineIndex,
38
+ charStart: i
39
+ });
40
+ lineIndex++;
41
+ continue;
42
+ }
43
+ if (SPECIAL_CHARS.includes(currentChar)) results.push({
44
+ char: currentChar,
45
+ lineStart: lineIndex,
46
+ charStart: i
47
+ });
48
+ }
49
+ return results;
73
50
  };
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
76
- listSpecialChars
77
- });
51
+
52
+ //#endregion
53
+ exports.listSpecialChars = listSpecialChars;
78
54
  //# sourceMappingURL=listSpecialChars.cjs.map
@@ -1 +1 @@
1
- {"version":3,"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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,mBAAmB,CAAC,SAAiC;AAChE,QAAM,UAA0B,CAAC;AAEjC,MAAI,YAAY;AAEhB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,cAAc,KAAK,CAAC;AAG1B,QAAI,gBAAgB,MAAM;AACxB,cAAQ,KAAK;AAAA,QACX,MAAM;AAAA,QACN,WAAW;AAAA,QACX,WAAW;AAAA,MACb,CAAC;AAGD;AACA;AAAA,IACF;AAGA,QAAI,cAAc,SAAS,WAAW,GAAG;AACvC,cAAQ,KAAK;AAAA,QACX,MAAM;AAAA,QACN,WAAW;AAAA,QACX,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"listSpecialChars.cjs","names":["results: ListCharResult"],"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,MAAMA,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"}