@intlayer/cli 6.1.6-canary.0 → 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,28 +1,28 @@
1
- import {
2
- getIntlayerAPIProxy
3
- } from "@intlayer/api";
1
+ import { getIntlayerAPIProxy } from "@intlayer/api";
4
2
  import { retryManager } from "@intlayer/config";
3
+
4
+ //#region src/utils/chunkInference.ts
5
+ /**
6
+ * Translates a single chunk via the OpenAI API.
7
+ * Includes retry logic if the call fails.
8
+ */
5
9
  const chunkInference = async (messages, aiOptions, configuration) => {
6
- let lastResult;
7
- await retryManager(async () => {
8
- const api = getIntlayerAPIProxy(void 0, configuration);
9
- const response = await api.ai.customQuery({
10
- aiOptions,
11
- messages
12
- });
13
- if (!response.data) {
14
- throw new Error("No response from AI API");
15
- }
16
- const { fileContent, tokenUsed } = response.data;
17
- const newContent = fileContent.replaceAll("///chunksStart///", "").replaceAll("///chunkStart///", "").replaceAll("///chunksEnd///", "").replaceAll("///chunkEnd///", "").replaceAll("///chunksStart///", "").replaceAll("chunkStart///", "").replaceAll("chunksEnd///", "").replaceAll("chunkEnd///", "").replaceAll("///chunksStart", "").replaceAll("///chunkStart", "").replaceAll("///chunksEnd", "").replaceAll("///chunkEnd", "").replaceAll("chunksStart", "").replaceAll("chunkStart", "").replaceAll("chunksEnd", "").replaceAll("chunkEnd", "");
18
- lastResult = {
19
- fileContent: newContent,
20
- tokenUsed
21
- };
22
- })();
23
- return lastResult;
24
- };
25
- export {
26
- chunkInference
10
+ let lastResult;
11
+ await retryManager(async () => {
12
+ const response = await getIntlayerAPIProxy(void 0, configuration).ai.customQuery({
13
+ aiOptions,
14
+ messages
15
+ });
16
+ if (!response.data) throw new Error("No response from AI API");
17
+ const { fileContent, tokenUsed } = response.data;
18
+ lastResult = {
19
+ fileContent: fileContent.replaceAll("///chunksStart///", "").replaceAll("///chunkStart///", "").replaceAll("///chunksEnd///", "").replaceAll("///chunkEnd///", "").replaceAll("///chunksStart///", "").replaceAll("chunkStart///", "").replaceAll("chunksEnd///", "").replaceAll("chunkEnd///", "").replaceAll("///chunksStart", "").replaceAll("///chunkStart", "").replaceAll("///chunksEnd", "").replaceAll("///chunkEnd", "").replaceAll("chunksStart", "").replaceAll("chunkStart", "").replaceAll("chunksEnd", "").replaceAll("chunkEnd", ""),
20
+ tokenUsed
21
+ };
22
+ })();
23
+ return lastResult;
27
24
  };
25
+
26
+ //#endregion
27
+ export { chunkInference };
28
28
  //# sourceMappingURL=chunkInference.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/chunkInference.ts"],"sourcesContent":["import {\n type AIOptions,\n getIntlayerAPIProxy,\n type Messages,\n} from '@intlayer/api';\nimport { type IntlayerConfig, retryManager } from '@intlayer/config';\n\ntype ChunkInferenceResult = {\n fileContent: string;\n tokenUsed: number;\n};\n\n/**\n * Translates a single chunk via the OpenAI API.\n * Includes retry logic if the call fails.\n */\nexport const chunkInference = async (\n messages: Messages,\n aiOptions?: AIOptions,\n configuration?: IntlayerConfig\n): Promise<ChunkInferenceResult> => {\n let lastResult: ChunkInferenceResult;\n\n await retryManager(async () => {\n const api = getIntlayerAPIProxy(undefined, configuration);\n\n const response = await api.ai.customQuery({\n aiOptions,\n messages,\n });\n\n if (!response.data) {\n throw new Error('No response from AI API');\n }\n\n const { fileContent, tokenUsed } = response.data;\n\n const newContent = fileContent\n .replaceAll('///chunksStart///', '')\n .replaceAll('///chunkStart///', '')\n .replaceAll('///chunksEnd///', '')\n .replaceAll('///chunkEnd///', '')\n .replaceAll('///chunksStart///', '')\n .replaceAll('chunkStart///', '')\n .replaceAll('chunksEnd///', '')\n .replaceAll('chunkEnd///', '')\n .replaceAll('///chunksStart', '')\n .replaceAll('///chunkStart', '')\n .replaceAll('///chunksEnd', '')\n .replaceAll('///chunkEnd', '')\n .replaceAll('chunksStart', '')\n .replaceAll('chunkStart', '')\n .replaceAll('chunksEnd', '')\n .replaceAll('chunkEnd', '');\n\n lastResult = {\n fileContent: newContent,\n tokenUsed,\n };\n })();\n\n return lastResult!;\n};\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,OAEK;AACP,SAA8B,oBAAoB;AAW3C,MAAM,iBAAiB,OAC5B,UACA,WACA,kBACkC;AAClC,MAAI;AAEJ,QAAM,aAAa,YAAY;AAC7B,UAAM,MAAM,oBAAoB,QAAW,aAAa;AAExD,UAAM,WAAW,MAAM,IAAI,GAAG,YAAY;AAAA,MACxC;AAAA,MACA;AAAA,IACF,CAAC;AAED,QAAI,CAAC,SAAS,MAAM;AAClB,YAAM,IAAI,MAAM,yBAAyB;AAAA,IAC3C;AAEA,UAAM,EAAE,aAAa,UAAU,IAAI,SAAS;AAE5C,UAAM,aAAa,YAChB,WAAW,qBAAqB,EAAE,EAClC,WAAW,oBAAoB,EAAE,EACjC,WAAW,mBAAmB,EAAE,EAChC,WAAW,kBAAkB,EAAE,EAC/B,WAAW,qBAAqB,EAAE,EAClC,WAAW,iBAAiB,EAAE,EAC9B,WAAW,gBAAgB,EAAE,EAC7B,WAAW,eAAe,EAAE,EAC5B,WAAW,kBAAkB,EAAE,EAC/B,WAAW,iBAAiB,EAAE,EAC9B,WAAW,gBAAgB,EAAE,EAC7B,WAAW,eAAe,EAAE,EAC5B,WAAW,eAAe,EAAE,EAC5B,WAAW,cAAc,EAAE,EAC3B,WAAW,aAAa,EAAE,EAC1B,WAAW,YAAY,EAAE;AAE5B,iBAAa;AAAA,MACX,aAAa;AAAA,MACb;AAAA,IACF;AAAA,EACF,CAAC,EAAE;AAEH,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"chunkInference.mjs","names":["lastResult: ChunkInferenceResult"],"sources":["../../../src/utils/chunkInference.ts"],"sourcesContent":["import {\n type AIOptions,\n getIntlayerAPIProxy,\n type Messages,\n} from '@intlayer/api';\nimport { retryManager } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\ntype ChunkInferenceResult = {\n fileContent: string;\n tokenUsed: number;\n};\n\n/**\n * Translates a single chunk via the OpenAI API.\n * Includes retry logic if the call fails.\n */\nexport const chunkInference = async (\n messages: Messages,\n aiOptions?: AIOptions,\n configuration?: IntlayerConfig\n): Promise<ChunkInferenceResult> => {\n let lastResult: ChunkInferenceResult;\n\n await retryManager(async () => {\n const api = getIntlayerAPIProxy(undefined, configuration);\n\n const response = await api.ai.customQuery({\n aiOptions,\n messages,\n });\n\n if (!response.data) {\n throw new Error('No response from AI API');\n }\n\n const { fileContent, tokenUsed } = response.data;\n\n const newContent = fileContent\n .replaceAll('///chunksStart///', '')\n .replaceAll('///chunkStart///', '')\n .replaceAll('///chunksEnd///', '')\n .replaceAll('///chunkEnd///', '')\n .replaceAll('///chunksStart///', '')\n .replaceAll('chunkStart///', '')\n .replaceAll('chunksEnd///', '')\n .replaceAll('chunkEnd///', '')\n .replaceAll('///chunksStart', '')\n .replaceAll('///chunkStart', '')\n .replaceAll('///chunksEnd', '')\n .replaceAll('///chunkEnd', '')\n .replaceAll('chunksStart', '')\n .replaceAll('chunkStart', '')\n .replaceAll('chunksEnd', '')\n .replaceAll('chunkEnd', '');\n\n lastResult = {\n fileContent: newContent,\n tokenUsed,\n };\n })();\n\n return lastResult!;\n};\n"],"mappings":";;;;;;;;AAiBA,MAAa,iBAAiB,OAC5B,UACA,WACA,kBACkC;CAClC,IAAIA;AAEJ,OAAM,aAAa,YAAY;EAG7B,MAAM,WAAW,MAFL,oBAAoB,QAAW,cAAc,CAE9B,GAAG,YAAY;GACxC;GACA;GACD,CAAC;AAEF,MAAI,CAAC,SAAS,KACZ,OAAM,IAAI,MAAM,0BAA0B;EAG5C,MAAM,EAAE,aAAa,cAAc,SAAS;AAoB5C,eAAa;GACX,aAnBiB,YAChB,WAAW,qBAAqB,GAAG,CACnC,WAAW,oBAAoB,GAAG,CAClC,WAAW,mBAAmB,GAAG,CACjC,WAAW,kBAAkB,GAAG,CAChC,WAAW,qBAAqB,GAAG,CACnC,WAAW,iBAAiB,GAAG,CAC/B,WAAW,gBAAgB,GAAG,CAC9B,WAAW,eAAe,GAAG,CAC7B,WAAW,kBAAkB,GAAG,CAChC,WAAW,iBAAiB,GAAG,CAC/B,WAAW,gBAAgB,GAAG,CAC9B,WAAW,eAAe,GAAG,CAC7B,WAAW,eAAe,GAAG,CAC7B,WAAW,cAAc,GAAG,CAC5B,WAAW,aAAa,GAAG,CAC3B,WAAW,YAAY,GAAG;GAI3B;GACD;GACD,EAAE;AAEJ,QAAO"}
@@ -1,23 +1,27 @@
1
- const CHAR_TO_CHECK_FORMATTING = ["```", "\n\n", "\n", "---", "{{", "}}"];
1
+ //#region src/utils/fixChunkStartEndChars.ts
2
+ const CHAR_TO_CHECK_FORMATTING = [
3
+ "```",
4
+ "\n\n",
5
+ "\n",
6
+ "---",
7
+ "{{",
8
+ "}}"
9
+ ];
2
10
  const escapeForRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\n/g, "\\n");
3
11
  const FORMATTING_REGEX_SOURCE = `(?:${CHAR_TO_CHECK_FORMATTING.map(escapeForRegExp).join("|")})+`;
4
- const LEADING_FORMATTING_REGEX = new RegExp(`^${FORMATTING_REGEX_SOURCE}`);
5
- const TRAILING_FORMATTING_REGEX = new RegExp(`${FORMATTING_REGEX_SOURCE}$`);
12
+ const LEADING_FORMATTING_REGEX = /* @__PURE__ */ new RegExp(`^${FORMATTING_REGEX_SOURCE}`);
13
+ const TRAILING_FORMATTING_REGEX = /* @__PURE__ */ new RegExp(`${FORMATTING_REGEX_SOURCE}$`);
6
14
  const fixChunkStartEndChars = (reviewedChunkResult, baseChunkContext) => {
7
- let result = reviewedChunkResult;
8
- const baseLeading = baseChunkContext.match(LEADING_FORMATTING_REGEX)?.[0] ?? "";
9
- const baseTrailing = baseChunkContext.match(TRAILING_FORMATTING_REGEX)?.[0] ?? "";
10
- const resultLeading = result.match(LEADING_FORMATTING_REGEX)?.[0] ?? "";
11
- const resultTrailing = result.match(TRAILING_FORMATTING_REGEX)?.[0] ?? "";
12
- if (baseLeading !== resultLeading) {
13
- result = baseLeading + result.slice(resultLeading.length);
14
- }
15
- if (baseTrailing !== resultTrailing) {
16
- result = result.slice(0, result.length - resultTrailing.length) + baseTrailing;
17
- }
18
- return result;
19
- };
20
- export {
21
- fixChunkStartEndChars
15
+ let result = reviewedChunkResult;
16
+ const baseLeading = baseChunkContext.match(LEADING_FORMATTING_REGEX)?.[0] ?? "";
17
+ const baseTrailing = baseChunkContext.match(TRAILING_FORMATTING_REGEX)?.[0] ?? "";
18
+ const resultLeading = result.match(LEADING_FORMATTING_REGEX)?.[0] ?? "";
19
+ const resultTrailing = result.match(TRAILING_FORMATTING_REGEX)?.[0] ?? "";
20
+ if (baseLeading !== resultLeading) result = baseLeading + result.slice(resultLeading.length);
21
+ if (baseTrailing !== resultTrailing) result = result.slice(0, result.length - resultTrailing.length) + baseTrailing;
22
+ return result;
22
23
  };
24
+
25
+ //#endregion
26
+ export { fixChunkStartEndChars };
23
27
  //# sourceMappingURL=fixChunkStartEndChars.mjs.map
@@ -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,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.mjs","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,22 +1,19 @@
1
+ //#region src/utils/formatTimeDiff.ts
1
2
  const formatTimeDiff = (realtiveTime) => {
2
- const diff = realtiveTime.getTime();
3
- const MS_IN_SECOND = 1e3;
4
- const MS_IN_MINUTE = 60 * MS_IN_SECOND;
5
- const MS_IN_HOUR = 60 * MS_IN_MINUTE;
6
- const MS_IN_DAY = 24 * MS_IN_HOUR;
7
- const days = Math.floor(diff / MS_IN_DAY);
8
- const hours = Math.floor(diff % MS_IN_DAY / MS_IN_HOUR);
9
- const minutes = Math.floor(diff % MS_IN_HOUR / MS_IN_MINUTE);
10
- const seconds = Math.floor(diff % MS_IN_MINUTE / MS_IN_SECOND);
11
- if (days > 0) {
12
- return `${days}d ${hours}h ${minutes}m ${seconds}s`;
13
- }
14
- if (hours > 0) {
15
- return `${hours}h ${minutes}m ${seconds}s`;
16
- }
17
- return `${minutes}m ${seconds}s`;
18
- };
19
- export {
20
- formatTimeDiff
3
+ const diff = realtiveTime.getTime();
4
+ const MS_IN_SECOND = 1e3;
5
+ const MS_IN_MINUTE = 60 * MS_IN_SECOND;
6
+ const MS_IN_HOUR = 60 * MS_IN_MINUTE;
7
+ const MS_IN_DAY = 24 * MS_IN_HOUR;
8
+ const days = Math.floor(diff / MS_IN_DAY);
9
+ const hours = Math.floor(diff % MS_IN_DAY / MS_IN_HOUR);
10
+ const minutes = Math.floor(diff % MS_IN_HOUR / MS_IN_MINUTE);
11
+ const seconds = Math.floor(diff % MS_IN_MINUTE / MS_IN_SECOND);
12
+ if (days > 0) return `${days}d ${hours}h ${minutes}m ${seconds}s`;
13
+ if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
14
+ return `${minutes}m ${seconds}s`;
21
15
  };
16
+
17
+ //#endregion
18
+ export { formatTimeDiff };
22
19
  //# sourceMappingURL=formatTimeDiff.mjs.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":"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.mjs","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,12 +1,15 @@
1
- import { statSync } from "fs";
1
+ import { statSync } from "node:fs";
2
+
3
+ //#region src/utils/getIsFileUpdatedRecently.ts
2
4
  const SKIP_RANGE_OF_LAST_UPDATE_TIME = 0;
5
+ /**
6
+ * Check if file was updated recently, to skip re-translation
7
+ */
3
8
  const getIsFileUpdatedRecently = (localeFilePath) => {
4
- const stats = statSync(localeFilePath);
5
- const lastModified = new Date(stats.mtime);
6
- const threshold = new Date(Date.now() - SKIP_RANGE_OF_LAST_UPDATE_TIME);
7
- return lastModified > threshold;
8
- };
9
- export {
10
- getIsFileUpdatedRecently
9
+ const stats = statSync(localeFilePath);
10
+ return new Date(stats.mtime) > new Date(Date.now() - SKIP_RANGE_OF_LAST_UPDATE_TIME);
11
11
  };
12
+
13
+ //#endregion
14
+ export { getIsFileUpdatedRecently };
12
15
  //# sourceMappingURL=getIsFileUpdatedRecently.mjs.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,SAAS,gBAAgB;AAEzB,MAAM,iCAAyC;AAKxC,MAAM,2BAA2B,CAAC,mBAAoC;AAC3E,QAAM,QAAQ,SAAS,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.mjs","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,QAAQ,SAAS,eAAe;AAItC,QAHqB,IAAI,KAAK,MAAM,MAAM,GACxB,IAAI,KAAK,KAAK,KAAK,GAAG,+BAA+B"}
@@ -1,65 +1,73 @@
1
+ //#region src/utils/getOutputFilePath.ts
2
+ /**
3
+ * Get the output file path by replacing the base locale with the target locale
4
+ *
5
+ * This function handles two types of replacements:
6
+ * 1. Actual locale values (e.g., `/en/` → `/fr/`)
7
+ * 2. Template placeholders (e.g., `{{baseLocale}}` → `{{locale}}`, `{{baseLocaleName}}` → `{{localeName}}`)
8
+ *
9
+ * Replacement patterns:
10
+ * - `/baseLocale/` → `/locale/`
11
+ * - `\baseLocale\` → `\locale\`
12
+ * - `_baseLocale.` → `_locale.`
13
+ * - `baseLocale_` → `locale_`
14
+ * - `.baseLocaleName.` → `.localeName.`
15
+ * - `{{baseLocale}}` → `{{locale}}`
16
+ * - `{{baseLocaleName}}` → `{{localeName}}`
17
+ *
18
+ * If no patterns match, appends `.locale` to the file extension.
19
+ *
20
+ * @param filePath - The input file path
21
+ * @param locale - The target locale
22
+ * @param baseLocale - The base locale to replace
23
+ * @returns The output file path with locale replacements
24
+ */
1
25
  const getOutputFilePath = (filePath, locale, baseLocale) => {
2
- if (!filePath || !locale || !baseLocale) {
3
- throw new Error("filePath, locale, and baseLocale are required");
4
- }
5
- let outputFilePath = filePath;
6
- const replacements = [
7
- // Template placeholders (processed first)
8
- {
9
- pattern: /\{\{baseLocale\}\}/g,
10
- replacement: "{{locale}}"
11
- },
12
- {
13
- pattern: /\{\{baseLocaleName\}\}/g,
14
- replacement: "{{localeName}}"
15
- },
16
- // Path separators (most specific first)
17
- {
18
- // Unix path separators
19
- pattern: new RegExp(`/${baseLocale}/`, "g"),
20
- replacement: `/${locale}/`
21
- },
22
- {
23
- // Windows path separators
24
- pattern: new RegExp(`\\\\${baseLocale}\\\\`, "g"),
25
- replacement: `\\${locale}\\`
26
- },
27
- // File naming patterns
28
- {
29
- // file_en.md → file_fr.md
30
- pattern: new RegExp(`_${baseLocale}\\.`, "g"),
31
- replacement: `_${locale}.`
32
- },
33
- {
34
- // /file_en.md /file_fr.md
35
- pattern: new RegExp(`/${baseLocale}_`, "g"),
36
- replacement: `/${locale}_`
37
- },
38
- {
39
- // Start of filename pattern en_guide.md → fr_guide.md (or after path separator)
40
- pattern: new RegExp(`(^|[\\/])${baseLocale}_`, "g"),
41
- replacement: `$1${locale}_`
42
- },
43
- {
44
- // Dot delimited pattern guide.en.md → guide.fr.md
45
- pattern: new RegExp(`\\.${baseLocale}\\.`, "g"),
46
- replacement: `.${locale}.`
47
- }
48
- ];
49
- for (const { pattern, replacement } of replacements) {
50
- outputFilePath = outputFilePath.replace(pattern, replacement);
51
- }
52
- if (outputFilePath === filePath) {
53
- const lastDotIndex = filePath.lastIndexOf(".");
54
- if (lastDotIndex > 0) {
55
- return `${filePath.slice(0, lastDotIndex)}.${locale}${filePath.slice(lastDotIndex)}`;
56
- } else {
57
- return `${filePath}.${locale}`;
58
- }
59
- }
60
- return outputFilePath;
61
- };
62
- export {
63
- getOutputFilePath
26
+ if (!filePath || !locale || !baseLocale) throw new Error("filePath, locale, and baseLocale are required");
27
+ let outputFilePath = filePath;
28
+ const replacements = [
29
+ {
30
+ pattern: /\{\{baseLocale\}\}/g,
31
+ replacement: "{{locale}}"
32
+ },
33
+ {
34
+ pattern: /\{\{baseLocaleName\}\}/g,
35
+ replacement: "{{localeName}}"
36
+ },
37
+ {
38
+ pattern: new RegExp(`/${baseLocale}/`, "g"),
39
+ replacement: `/${locale}/`
40
+ },
41
+ {
42
+ pattern: new RegExp(`\\\\${baseLocale}\\\\`, "g"),
43
+ replacement: `\\${locale}\\`
44
+ },
45
+ {
46
+ pattern: new RegExp(`_${baseLocale}\\.`, "g"),
47
+ replacement: `_${locale}.`
48
+ },
49
+ {
50
+ pattern: new RegExp(`/${baseLocale}_`, "g"),
51
+ replacement: `/${locale}_`
52
+ },
53
+ {
54
+ pattern: new RegExp(`(^|[\\/])${baseLocale}_`, "g"),
55
+ replacement: `$1${locale}_`
56
+ },
57
+ {
58
+ pattern: new RegExp(`\\.${baseLocale}\\.`, "g"),
59
+ replacement: `.${locale}.`
60
+ }
61
+ ];
62
+ for (const { pattern, replacement } of replacements) outputFilePath = outputFilePath.replace(pattern, replacement);
63
+ if (outputFilePath === filePath) {
64
+ const lastDotIndex = filePath.lastIndexOf(".");
65
+ if (lastDotIndex > 0) return `${filePath.slice(0, lastDotIndex)}.${locale}${filePath.slice(lastDotIndex)}`;
66
+ else return `${filePath}.${locale}`;
67
+ }
68
+ return outputFilePath;
64
69
  };
70
+
71
+ //#endregion
72
+ export { getOutputFilePath };
65
73
  //# sourceMappingURL=getOutputFilePath.mjs.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":"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.mjs","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,23 +1,19 @@
1
- import { existsSync, readFileSync } from "fs";
2
- import { dirname, resolve } from "path";
1
+ import { dirname, resolve } from "node:path";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+
4
+ //#region src/utils/getParentPackageJSON.ts
3
5
  const getParentPackageJSON = (startDir) => {
4
- let currentDir = startDir;
5
- while (currentDir !== dirname(currentDir)) {
6
- const packageJsonPath = resolve(currentDir, "package.json");
7
- if (existsSync(packageJsonPath)) {
8
- return JSON.parse(readFileSync(packageJsonPath, "utf8"));
9
- }
10
- currentDir = dirname(currentDir);
11
- }
12
- const rootPackageJsonPath = resolve(currentDir, "package.json");
13
- if (existsSync(rootPackageJsonPath)) {
14
- return JSON.parse(readFileSync(rootPackageJsonPath, "utf8"));
15
- }
16
- throw new Error(
17
- `No package.json found in any parent directory of ${startDir}`
18
- );
19
- };
20
- export {
21
- getParentPackageJSON
6
+ let currentDir = startDir;
7
+ while (currentDir !== dirname(currentDir)) {
8
+ const packageJsonPath = resolve(currentDir, "package.json");
9
+ if (existsSync(packageJsonPath)) return JSON.parse(readFileSync(packageJsonPath, "utf8"));
10
+ currentDir = dirname(currentDir);
11
+ }
12
+ const rootPackageJsonPath = resolve(currentDir, "package.json");
13
+ if (existsSync(rootPackageJsonPath)) return JSON.parse(readFileSync(rootPackageJsonPath, "utf8"));
14
+ throw new Error(`No package.json found in any parent directory of ${startDir}`);
22
15
  };
16
+
17
+ //#endregion
18
+ export { getParentPackageJSON };
23
19
  //# sourceMappingURL=getParentPackageJSON.mjs.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,SAAS,YAAY,oBAAoB;AACzC,SAAS,SAAS,eAAe;AAgC1B,MAAM,uBAAuB,CAAC,aAAkC;AACrE,MAAI,aAAa;AAEjB,SAAO,eAAe,QAAQ,UAAU,GAAG;AAEzC,UAAM,kBAAkB,QAAQ,YAAY,cAAc;AAE1D,QAAI,WAAW,eAAe,GAAG;AAC/B,aAAO,KAAK,MAAM,aAAa,iBAAiB,MAAM,CAAC;AAAA,IACzD;AAGA,iBAAa,QAAQ,UAAU;AAAA,EACjC;AAGA,QAAM,sBAAsB,QAAQ,YAAY,cAAc;AAC9D,MAAI,WAAW,mBAAmB,GAAG;AACnC,WAAO,KAAK,MAAM,aAAa,qBAAqB,MAAM,CAAC;AAAA,EAC7D;AAGA,QAAM,IAAI;AAAA,IACR,oDAAoD,QAAQ;AAAA,EAC9D;AACF;","names":[]}
1
+ {"version":3,"file":"getParentPackageJSON.mjs","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,eAAe,QAAQ,WAAW,EAAE;EAEzC,MAAM,kBAAkB,QAAQ,YAAY,eAAe;AAE3D,MAAI,WAAW,gBAAgB,CAC7B,QAAO,KAAK,MAAM,aAAa,iBAAiB,OAAO,CAAC;AAI1D,eAAa,QAAQ,WAAW;;CAIlC,MAAM,sBAAsB,QAAQ,YAAY,eAAe;AAC/D,KAAI,WAAW,oBAAoB,CACjC,QAAO,KAAK,MAAM,aAAa,qBAAqB,OAAO,CAAC;AAI9D,OAAM,IAAI,MACR,oDAAoD,WACrD"}
@@ -1,54 +1,53 @@
1
+ //#region src/utils/listSpecialChars.ts
1
2
  const SPECIAL_CHARS = [
2
- " ",
3
- "\\",
4
- "|",
5
- "(",
6
- ")",
7
- "{",
8
- "}",
9
- "[",
10
- "]",
11
- "<",
12
- ">",
13
- '"',
14
- "=",
15
- "+",
16
- "*",
17
- "&",
18
- "#",
19
- "%",
20
- "$",
21
- "!",
22
- "?",
23
- ":",
24
- ";",
25
- "~"
3
+ " ",
4
+ "\\",
5
+ "|",
6
+ "(",
7
+ ")",
8
+ "{",
9
+ "}",
10
+ "[",
11
+ "]",
12
+ "<",
13
+ ">",
14
+ "\"",
15
+ "=",
16
+ "+",
17
+ "*",
18
+ "&",
19
+ "#",
20
+ "%",
21
+ "$",
22
+ "!",
23
+ "?",
24
+ ":",
25
+ ";",
26
+ "~"
26
27
  ];
27
28
  const listSpecialChars = (text) => {
28
- const results = [];
29
- let lineIndex = 0;
30
- for (let i = 0; i < text.length; i++) {
31
- const currentChar = text[i];
32
- if (currentChar === "\n") {
33
- results.push({
34
- char: "\\",
35
- lineStart: lineIndex,
36
- charStart: i
37
- });
38
- lineIndex++;
39
- continue;
40
- }
41
- if (SPECIAL_CHARS.includes(currentChar)) {
42
- results.push({
43
- char: currentChar,
44
- lineStart: lineIndex,
45
- charStart: i
46
- });
47
- }
48
- }
49
- return results;
50
- };
51
- export {
52
- listSpecialChars
29
+ const results = [];
30
+ let lineIndex = 0;
31
+ for (let i = 0; i < text.length; i++) {
32
+ const currentChar = text[i];
33
+ if (currentChar === "\n") {
34
+ results.push({
35
+ char: "\\",
36
+ lineStart: lineIndex,
37
+ charStart: i
38
+ });
39
+ lineIndex++;
40
+ continue;
41
+ }
42
+ if (SPECIAL_CHARS.includes(currentChar)) results.push({
43
+ char: currentChar,
44
+ lineStart: lineIndex,
45
+ charStart: i
46
+ });
47
+ }
48
+ return results;
53
49
  };
50
+
51
+ //#endregion
52
+ export { listSpecialChars };
54
53
  //# sourceMappingURL=listSpecialChars.mjs.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":"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.mjs","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"}