@sebbro/paraglide-lite 0.1.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 (715) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -0
  3. package/bin/run.js +4 -0
  4. package/dist/bundler-plugins/esbuild.d.ts +1 -0
  5. package/dist/bundler-plugins/esbuild.d.ts.map +1 -0
  6. package/dist/bundler-plugins/esbuild.js +4 -0
  7. package/dist/bundler-plugins/esbuild.js.map +1 -0
  8. package/dist/bundler-plugins/index.d.ts +6 -0
  9. package/dist/bundler-plugins/index.d.ts.map +1 -0
  10. package/dist/bundler-plugins/index.js +7 -0
  11. package/dist/bundler-plugins/index.js.map +1 -0
  12. package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts +19 -0
  13. package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts.map +1 -0
  14. package/dist/bundler-plugins/lazy-modules/scan-message-keys.js +85 -0
  15. package/dist/bundler-plugins/lazy-modules/scan-message-keys.js.map +1 -0
  16. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts +2 -0
  17. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts.map +1 -0
  18. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js +53 -0
  19. package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js.map +1 -0
  20. package/dist/bundler-plugins/lazy-modules/ssr.d.ts +31 -0
  21. package/dist/bundler-plugins/lazy-modules/ssr.d.ts.map +1 -0
  22. package/dist/bundler-plugins/lazy-modules/ssr.js +42 -0
  23. package/dist/bundler-plugins/lazy-modules/ssr.js.map +1 -0
  24. package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts +2 -0
  25. package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts.map +1 -0
  26. package/dist/bundler-plugins/lazy-modules/ssr.test.js +48 -0
  27. package/dist/bundler-plugins/lazy-modules/ssr.test.js.map +1 -0
  28. package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts +7 -0
  29. package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts.map +1 -0
  30. package/dist/bundler-plugins/lazy-modules/virtual-ids.js +30 -0
  31. package/dist/bundler-plugins/lazy-modules/virtual-ids.js.map +1 -0
  32. package/dist/bundler-plugins/lazy-modules/virtual.d.ts +86 -0
  33. package/dist/bundler-plugins/lazy-modules/virtual.d.ts.map +1 -0
  34. package/dist/bundler-plugins/lazy-modules/virtual.js +2 -0
  35. package/dist/bundler-plugins/lazy-modules/virtual.js.map +1 -0
  36. package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts +18 -0
  37. package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts.map +1 -0
  38. package/dist/bundler-plugins/lazy-modules/vite-plugin.js +328 -0
  39. package/dist/bundler-plugins/lazy-modules/vite-plugin.js.map +1 -0
  40. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts +2 -0
  41. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts.map +1 -0
  42. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js +45 -0
  43. package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js.map +1 -0
  44. package/dist/bundler-plugins/per-locale-build/constants.d.ts +2 -0
  45. package/dist/bundler-plugins/per-locale-build/constants.d.ts.map +1 -0
  46. package/dist/bundler-plugins/per-locale-build/constants.js +3 -0
  47. package/dist/bundler-plugins/per-locale-build/constants.js.map +1 -0
  48. package/dist/bundler-plugins/per-locale-build/index.d.ts +6 -0
  49. package/dist/bundler-plugins/per-locale-build/index.d.ts.map +1 -0
  50. package/dist/bundler-plugins/per-locale-build/index.js +43 -0
  51. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -0
  52. package/dist/bundler-plugins/per-locale-build/locale-id.d.ts +8 -0
  53. package/dist/bundler-plugins/per-locale-build/locale-id.d.ts.map +1 -0
  54. package/dist/bundler-plugins/per-locale-build/locale-id.js +13 -0
  55. package/dist/bundler-plugins/per-locale-build/locale-id.js.map +1 -0
  56. package/dist/bundler-plugins/per-locale-build/types.d.ts +4 -0
  57. package/dist/bundler-plugins/per-locale-build/types.d.ts.map +1 -0
  58. package/dist/bundler-plugins/per-locale-build/types.js +2 -0
  59. package/dist/bundler-plugins/per-locale-build/types.js.map +1 -0
  60. package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts +51 -0
  61. package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts.map +1 -0
  62. package/dist/bundler-plugins/per-locale-build/vite-environments.js +250 -0
  63. package/dist/bundler-plugins/per-locale-build/vite-environments.js.map +1 -0
  64. package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts +1 -0
  65. package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts.map +1 -0
  66. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +250 -0
  67. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -0
  68. package/dist/bundler-plugins/plugin-core.d.ts +74 -0
  69. package/dist/bundler-plugins/plugin-core.d.ts.map +1 -0
  70. package/dist/bundler-plugins/plugin-core.js +292 -0
  71. package/dist/bundler-plugins/plugin-core.js.map +1 -0
  72. package/dist/bundler-plugins/rolldown.d.ts +10 -0
  73. package/dist/bundler-plugins/rolldown.d.ts.map +1 -0
  74. package/dist/bundler-plugins/rolldown.js +36 -0
  75. package/dist/bundler-plugins/rolldown.js.map +1 -0
  76. package/dist/bundler-plugins/rolldown.test.d.ts +1 -0
  77. package/dist/bundler-plugins/rolldown.test.d.ts.map +1 -0
  78. package/dist/bundler-plugins/rolldown.test.js +72 -0
  79. package/dist/bundler-plugins/rolldown.test.js.map +1 -0
  80. package/dist/bundler-plugins/rollup.d.ts +1 -0
  81. package/dist/bundler-plugins/rollup.d.ts.map +1 -0
  82. package/dist/bundler-plugins/rollup.js +4 -0
  83. package/dist/bundler-plugins/rollup.js.map +1 -0
  84. package/dist/bundler-plugins/rspack.d.ts +1 -0
  85. package/dist/bundler-plugins/rspack.d.ts.map +1 -0
  86. package/dist/bundler-plugins/rspack.js +4 -0
  87. package/dist/bundler-plugins/rspack.js.map +1 -0
  88. package/dist/bundler-plugins/unplugin.d.ts +3 -0
  89. package/dist/bundler-plugins/unplugin.d.ts.map +1 -0
  90. package/dist/bundler-plugins/unplugin.js +62 -0
  91. package/dist/bundler-plugins/unplugin.js.map +1 -0
  92. package/dist/bundler-plugins/unplugin.test.d.ts +1 -0
  93. package/dist/bundler-plugins/unplugin.test.d.ts.map +1 -0
  94. package/dist/bundler-plugins/unplugin.test.js +256 -0
  95. package/dist/bundler-plugins/unplugin.test.js.map +1 -0
  96. package/dist/bundler-plugins/virtual-modules.test.d.ts +1 -0
  97. package/dist/bundler-plugins/virtual-modules.test.d.ts.map +1 -0
  98. package/dist/bundler-plugins/virtual-modules.test.js +77 -0
  99. package/dist/bundler-plugins/virtual-modules.test.js.map +1 -0
  100. package/dist/bundler-plugins/vite.d.ts +17 -0
  101. package/dist/bundler-plugins/vite.d.ts.map +1 -0
  102. package/dist/bundler-plugins/vite.js +15 -0
  103. package/dist/bundler-plugins/vite.js.map +1 -0
  104. package/dist/bundler-plugins/vite.test.d.ts +1 -0
  105. package/dist/bundler-plugins/vite.test.d.ts.map +1 -0
  106. package/dist/bundler-plugins/vite.test.js +61 -0
  107. package/dist/bundler-plugins/vite.test.js.map +1 -0
  108. package/dist/bundler-plugins/webpack.d.ts +1 -0
  109. package/dist/bundler-plugins/webpack.d.ts.map +1 -0
  110. package/dist/bundler-plugins/webpack.js +4 -0
  111. package/dist/bundler-plugins/webpack.js.map +1 -0
  112. package/dist/cli/commands/compile/command.d.ts +2 -0
  113. package/dist/cli/commands/compile/command.d.ts.map +1 -0
  114. package/dist/cli/commands/compile/command.js +225 -0
  115. package/dist/cli/commands/compile/command.js.map +1 -0
  116. package/dist/cli/commands/compile/command.test.d.ts +1 -0
  117. package/dist/cli/commands/compile/command.test.d.ts.map +1 -0
  118. package/dist/cli/commands/compile/command.test.js +69 -0
  119. package/dist/cli/commands/compile/command.test.js.map +1 -0
  120. package/dist/cli/commands/init/command.d.ts +2 -0
  121. package/dist/cli/commands/init/command.d.ts.map +1 -0
  122. package/dist/cli/commands/init/command.js +90 -0
  123. package/dist/cli/commands/init/command.js.map +1 -0
  124. package/dist/cli/defaults.d.ts +11 -0
  125. package/dist/cli/defaults.d.ts.map +1 -0
  126. package/dist/cli/defaults.js +13 -0
  127. package/dist/cli/defaults.js.map +1 -0
  128. package/dist/cli/index.d.ts +2 -0
  129. package/dist/cli/index.d.ts.map +1 -0
  130. package/dist/cli/index.js +11 -0
  131. package/dist/cli/index.js.map +1 -0
  132. package/dist/cli/steps/add-vite-plugin.d.ts +31 -0
  133. package/dist/cli/steps/add-vite-plugin.d.ts.map +1 -0
  134. package/dist/cli/steps/add-vite-plugin.js +65 -0
  135. package/dist/cli/steps/add-vite-plugin.js.map +1 -0
  136. package/dist/cli/steps/add-vite-plugin.test.d.ts +1 -0
  137. package/dist/cli/steps/add-vite-plugin.test.d.ts.map +1 -0
  138. package/dist/cli/steps/add-vite-plugin.test.js +74 -0
  139. package/dist/cli/steps/add-vite-plugin.test.js.map +1 -0
  140. package/dist/cli/steps/check-for-uncomitted-changes.d.ts +5 -0
  141. package/dist/cli/steps/check-for-uncomitted-changes.d.ts.map +1 -0
  142. package/dist/cli/steps/check-for-uncomitted-changes.js +37 -0
  143. package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -0
  144. package/dist/cli/steps/detect-bundler.d.ts +10 -0
  145. package/dist/cli/steps/detect-bundler.d.ts.map +1 -0
  146. package/dist/cli/steps/detect-bundler.js +22 -0
  147. package/dist/cli/steps/detect-bundler.js.map +1 -0
  148. package/dist/cli/steps/detect-bundler.test.d.ts +1 -0
  149. package/dist/cli/steps/detect-bundler.test.d.ts.map +1 -0
  150. package/dist/cli/steps/detect-bundler.test.js +29 -0
  151. package/dist/cli/steps/detect-bundler.test.js.map +1 -0
  152. package/dist/cli/steps/initialize-messages.d.ts +11 -0
  153. package/dist/cli/steps/initialize-messages.d.ts.map +1 -0
  154. package/dist/cli/steps/initialize-messages.js +31 -0
  155. package/dist/cli/steps/initialize-messages.js.map +1 -0
  156. package/dist/cli/steps/prompt-for-outdir.d.ts +8 -0
  157. package/dist/cli/steps/prompt-for-outdir.d.ts.map +1 -0
  158. package/dist/cli/steps/prompt-for-outdir.js +19 -0
  159. package/dist/cli/steps/prompt-for-outdir.js.map +1 -0
  160. package/dist/cli/steps/update-package-json.d.ts +11 -0
  161. package/dist/cli/steps/update-package-json.d.ts.map +1 -0
  162. package/dist/cli/steps/update-package-json.js +34 -0
  163. package/dist/cli/steps/update-package-json.js.map +1 -0
  164. package/dist/cli/steps/update-ts-config.d.ts +26 -0
  165. package/dist/cli/steps/update-ts-config.d.ts.map +1 -0
  166. package/dist/cli/steps/update-ts-config.js +270 -0
  167. package/dist/cli/steps/update-ts-config.js.map +1 -0
  168. package/dist/cli/steps/update-ts-config.test.d.ts +1 -0
  169. package/dist/cli/steps/update-ts-config.test.d.ts.map +1 -0
  170. package/dist/cli/steps/update-ts-config.test.js +60 -0
  171. package/dist/cli/steps/update-ts-config.test.js.map +1 -0
  172. package/dist/cli/utils.d.ts +36 -0
  173. package/dist/cli/utils.d.ts.map +1 -0
  174. package/dist/cli/utils.js +20 -0
  175. package/dist/cli/utils.js.map +1 -0
  176. package/dist/compiler/assert-url-pattern-available.d.ts +7 -0
  177. package/dist/compiler/assert-url-pattern-available.d.ts.map +1 -0
  178. package/dist/compiler/assert-url-pattern-available.js +17 -0
  179. package/dist/compiler/assert-url-pattern-available.js.map +1 -0
  180. package/dist/compiler/compile-annotation.d.ts +12 -0
  181. package/dist/compiler/compile-annotation.d.ts.map +1 -0
  182. package/dist/compiler/compile-annotation.js +136 -0
  183. package/dist/compiler/compile-annotation.js.map +1 -0
  184. package/dist/compiler/compile-bundle.d.ts +28 -0
  185. package/dist/compiler/compile-bundle.d.ts.map +1 -0
  186. package/dist/compiler/compile-bundle.js +431 -0
  187. package/dist/compiler/compile-bundle.js.map +1 -0
  188. package/dist/compiler/compile-bundle.test.d.ts +1 -0
  189. package/dist/compiler/compile-bundle.test.d.ts.map +1 -0
  190. package/dist/compiler/compile-bundle.test.js +399 -0
  191. package/dist/compiler/compile-bundle.test.js.map +1 -0
  192. package/dist/compiler/compile-local-variable.d.ts +16 -0
  193. package/dist/compiler/compile-local-variable.d.ts.map +1 -0
  194. package/dist/compiler/compile-local-variable.js +28 -0
  195. package/dist/compiler/compile-local-variable.js.map +1 -0
  196. package/dist/compiler/compile-local-variable.test.d.ts +1 -0
  197. package/dist/compiler/compile-local-variable.test.d.ts.map +1 -0
  198. package/dist/compiler/compile-local-variable.test.js +359 -0
  199. package/dist/compiler/compile-local-variable.test.js.map +1 -0
  200. package/dist/compiler/compile-message.d.ts +8 -0
  201. package/dist/compiler/compile-message.d.ts.map +1 -0
  202. package/dist/compiler/compile-message.js +174 -0
  203. package/dist/compiler/compile-message.js.map +1 -0
  204. package/dist/compiler/compile-message.test.d.ts +1 -0
  205. package/dist/compiler/compile-message.test.d.ts.map +1 -0
  206. package/dist/compiler/compile-message.test.js +1060 -0
  207. package/dist/compiler/compile-message.test.js.map +1 -0
  208. package/dist/compiler/compile-pattern.d.ts +29 -0
  209. package/dist/compiler/compile-pattern.d.ts.map +1 -0
  210. package/dist/compiler/compile-pattern.js +143 -0
  211. package/dist/compiler/compile-pattern.js.map +1 -0
  212. package/dist/compiler/compile-pattern.test.d.ts +1 -0
  213. package/dist/compiler/compile-pattern.test.d.ts.map +1 -0
  214. package/dist/compiler/compile-pattern.test.js +255 -0
  215. package/dist/compiler/compile-pattern.test.js.map +1 -0
  216. package/dist/compiler/compile-project.d.ts +21 -0
  217. package/dist/compiler/compile-project.d.ts.map +1 -0
  218. package/dist/compiler/compile-project.js +147 -0
  219. package/dist/compiler/compile-project.js.map +1 -0
  220. package/dist/compiler/compile-project.test.d.ts +1 -0
  221. package/dist/compiler/compile-project.test.d.ts.map +1 -0
  222. package/dist/compiler/compile-project.test.js +1709 -0
  223. package/dist/compiler/compile-project.test.js.map +1 -0
  224. package/dist/compiler/compile.bench.d.ts +1 -0
  225. package/dist/compiler/compile.bench.d.ts.map +1 -0
  226. package/dist/compiler/compile.bench.js +89 -0
  227. package/dist/compiler/compile.bench.js.map +1 -0
  228. package/dist/compiler/compile.d.ts +24 -0
  229. package/dist/compiler/compile.d.ts.map +1 -0
  230. package/dist/compiler/compile.js +106 -0
  231. package/dist/compiler/compile.js.map +1 -0
  232. package/dist/compiler/compile.test.d.ts +1 -0
  233. package/dist/compiler/compile.test.d.ts.map +1 -0
  234. package/dist/compiler/compile.test.js +66 -0
  235. package/dist/compiler/compile.test.js.map +1 -0
  236. package/dist/compiler/compiler-options.d.ts +466 -0
  237. package/dist/compiler/compiler-options.d.ts.map +1 -0
  238. package/dist/compiler/compiler-options.js +22 -0
  239. package/dist/compiler/compiler-options.js.map +1 -0
  240. package/dist/compiler/create-paraglide.d.ts +21 -0
  241. package/dist/compiler/create-paraglide.d.ts.map +1 -0
  242. package/dist/compiler/create-paraglide.js +69 -0
  243. package/dist/compiler/create-paraglide.js.map +1 -0
  244. package/dist/compiler/create-paraglide.test.d.ts +1 -0
  245. package/dist/compiler/create-paraglide.test.d.ts.map +1 -0
  246. package/dist/compiler/create-paraglide.test.js +55 -0
  247. package/dist/compiler/create-paraglide.test.js.map +1 -0
  248. package/dist/compiler/create-readme.d.ts +9 -0
  249. package/dist/compiler/create-readme.d.ts.map +1 -0
  250. package/dist/compiler/create-readme.js +127 -0
  251. package/dist/compiler/create-readme.js.map +1 -0
  252. package/dist/compiler/emit-files.d.ts +15 -0
  253. package/dist/compiler/emit-files.d.ts.map +1 -0
  254. package/dist/compiler/emit-files.js +58 -0
  255. package/dist/compiler/emit-files.js.map +1 -0
  256. package/dist/compiler/emit-files.test.d.ts +1 -0
  257. package/dist/compiler/emit-files.test.d.ts.map +1 -0
  258. package/dist/compiler/emit-files.test.js +43 -0
  259. package/dist/compiler/emit-files.test.js.map +1 -0
  260. package/dist/compiler/emit-ts-declarations.d.ts +11 -0
  261. package/dist/compiler/emit-ts-declarations.d.ts.map +1 -0
  262. package/dist/compiler/emit-ts-declarations.interop.test.d.ts +1 -0
  263. package/dist/compiler/emit-ts-declarations.interop.test.d.ts.map +1 -0
  264. package/dist/compiler/emit-ts-declarations.interop.test.js +33 -0
  265. package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -0
  266. package/dist/compiler/emit-ts-declarations.js +353 -0
  267. package/dist/compiler/emit-ts-declarations.js.map +1 -0
  268. package/dist/compiler/emit-ts-declarations.test.d.ts +1 -0
  269. package/dist/compiler/emit-ts-declarations.test.d.ts.map +1 -0
  270. package/dist/compiler/emit-ts-declarations.test.js +161 -0
  271. package/dist/compiler/emit-ts-declarations.test.js.map +1 -0
  272. package/dist/compiler/index.d.ts +13 -0
  273. package/dist/compiler/index.d.ts.map +1 -0
  274. package/dist/compiler/index.js +11 -0
  275. package/dist/compiler/index.js.map +1 -0
  276. package/dist/compiler/jsdoc-types.d.ts +21 -0
  277. package/dist/compiler/jsdoc-types.d.ts.map +1 -0
  278. package/dist/compiler/jsdoc-types.js +59 -0
  279. package/dist/compiler/jsdoc-types.js.map +1 -0
  280. package/dist/compiler/jsdoc-types.test.d.ts +1 -0
  281. package/dist/compiler/jsdoc-types.test.d.ts.map +1 -0
  282. package/dist/compiler/jsdoc-types.test.js +100 -0
  283. package/dist/compiler/jsdoc-types.test.js.map +1 -0
  284. package/dist/compiler/lazy-modules/compile-cache.d.ts +37 -0
  285. package/dist/compiler/lazy-modules/compile-cache.d.ts.map +1 -0
  286. package/dist/compiler/lazy-modules/compile-cache.js +34 -0
  287. package/dist/compiler/lazy-modules/compile-cache.js.map +1 -0
  288. package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts +2 -0
  289. package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts.map +1 -0
  290. package/dist/compiler/lazy-modules/compile-project.lazy.test.js +65 -0
  291. package/dist/compiler/lazy-modules/compile-project.lazy.test.js.map +1 -0
  292. package/dist/compiler/lazy-modules/create-loader.d.ts +18 -0
  293. package/dist/compiler/lazy-modules/create-loader.d.ts.map +1 -0
  294. package/dist/compiler/lazy-modules/create-loader.js +182 -0
  295. package/dist/compiler/lazy-modules/create-loader.js.map +1 -0
  296. package/dist/compiler/lazy-modules/create-loader.test.d.ts +2 -0
  297. package/dist/compiler/lazy-modules/create-loader.test.d.ts.map +1 -0
  298. package/dist/compiler/lazy-modules/create-loader.test.js +82 -0
  299. package/dist/compiler/lazy-modules/create-loader.test.js.map +1 -0
  300. package/dist/compiler/lazy-modules/manifest.d.ts +32 -0
  301. package/dist/compiler/lazy-modules/manifest.d.ts.map +1 -0
  302. package/dist/compiler/lazy-modules/manifest.js +11 -0
  303. package/dist/compiler/lazy-modules/manifest.js.map +1 -0
  304. package/dist/compiler/match-literals.d.ts +2 -0
  305. package/dist/compiler/match-literals.d.ts.map +1 -0
  306. package/dist/compiler/match-literals.js +42 -0
  307. package/dist/compiler/match-literals.js.map +1 -0
  308. package/dist/compiler/output-structure/lazy-modules.d.ts +27 -0
  309. package/dist/compiler/output-structure/lazy-modules.d.ts.map +1 -0
  310. package/dist/compiler/output-structure/lazy-modules.js +157 -0
  311. package/dist/compiler/output-structure/lazy-modules.js.map +1 -0
  312. package/dist/compiler/output-structure/lazy-modules.test.d.ts +2 -0
  313. package/dist/compiler/output-structure/lazy-modules.test.d.ts.map +1 -0
  314. package/dist/compiler/output-structure/lazy-modules.test.js +128 -0
  315. package/dist/compiler/output-structure/lazy-modules.test.js.map +1 -0
  316. package/dist/compiler/output-structure/locale-modules.d.ts +4 -0
  317. package/dist/compiler/output-structure/locale-modules.d.ts.map +1 -0
  318. package/dist/compiler/output-structure/locale-modules.js +81 -0
  319. package/dist/compiler/output-structure/locale-modules.js.map +1 -0
  320. package/dist/compiler/output-structure/locale-modules.test.d.ts +1 -0
  321. package/dist/compiler/output-structure/locale-modules.test.d.ts.map +1 -0
  322. package/dist/compiler/output-structure/locale-modules.test.js +163 -0
  323. package/dist/compiler/output-structure/locale-modules.test.js.map +1 -0
  324. package/dist/compiler/output-structure/message-modules.d.ts +4 -0
  325. package/dist/compiler/output-structure/message-modules.d.ts.map +1 -0
  326. package/dist/compiler/output-structure/message-modules.js +100 -0
  327. package/dist/compiler/output-structure/message-modules.js.map +1 -0
  328. package/dist/compiler/output-structure/message-modules.test.d.ts +1 -0
  329. package/dist/compiler/output-structure/message-modules.test.d.ts.map +1 -0
  330. package/dist/compiler/output-structure/message-modules.test.js +148 -0
  331. package/dist/compiler/output-structure/message-modules.test.js.map +1 -0
  332. package/dist/compiler/per-locale-build.d.ts +2 -0
  333. package/dist/compiler/per-locale-build.d.ts.map +1 -0
  334. package/dist/compiler/per-locale-build.js +3 -0
  335. package/dist/compiler/per-locale-build.js.map +1 -0
  336. package/dist/compiler/registry.d.ts +13 -0
  337. package/dist/compiler/registry.d.ts.map +1 -0
  338. package/dist/compiler/registry.js +60 -0
  339. package/dist/compiler/registry.js.map +1 -0
  340. package/dist/compiler/resolve-tsc-js-path.d.ts +9 -0
  341. package/dist/compiler/resolve-tsc-js-path.d.ts.map +1 -0
  342. package/dist/compiler/resolve-tsc-js-path.js +23 -0
  343. package/dist/compiler/resolve-tsc-js-path.js.map +1 -0
  344. package/dist/compiler/runtime/check-locale.d.ts +31 -0
  345. package/dist/compiler/runtime/check-locale.d.ts.map +1 -0
  346. package/dist/compiler/runtime/check-locale.js +51 -0
  347. package/dist/compiler/runtime/check-locale.js.map +1 -0
  348. package/dist/compiler/runtime/check-locale.test.d.ts +1 -0
  349. package/dist/compiler/runtime/check-locale.test.d.ts.map +1 -0
  350. package/dist/compiler/runtime/check-locale.test.js +84 -0
  351. package/dist/compiler/runtime/check-locale.test.js.map +1 -0
  352. package/dist/compiler/runtime/create-runtime.d.ts +35 -0
  353. package/dist/compiler/runtime/create-runtime.d.ts.map +1 -0
  354. package/dist/compiler/runtime/create-runtime.js +196 -0
  355. package/dist/compiler/runtime/create-runtime.js.map +1 -0
  356. package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +13 -0
  357. package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -0
  358. package/dist/compiler/runtime/extract-locale-from-cookie.js +43 -0
  359. package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -0
  360. package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts +1 -0
  361. package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts.map +1 -0
  362. package/dist/compiler/runtime/extract-locale-from-cookie.test.js +149 -0
  363. package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -0
  364. package/dist/compiler/runtime/extract-locale-from-header.d.ts +13 -0
  365. package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -0
  366. package/dist/compiler/runtime/extract-locale-from-header.js +45 -0
  367. package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -0
  368. package/dist/compiler/runtime/extract-locale-from-header.test.d.ts +1 -0
  369. package/dist/compiler/runtime/extract-locale-from-header.test.d.ts.map +1 -0
  370. package/dist/compiler/runtime/extract-locale-from-header.test.js +55 -0
  371. package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -0
  372. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +12 -0
  373. package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -0
  374. package/dist/compiler/runtime/extract-locale-from-navigator.js +33 -0
  375. package/dist/compiler/runtime/extract-locale-from-navigator.js.map +1 -0
  376. package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts +1 -0
  377. package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts.map +1 -0
  378. package/dist/compiler/runtime/extract-locale-from-navigator.test.js +45 -0
  379. package/dist/compiler/runtime/extract-locale-from-navigator.test.js.map +1 -0
  380. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +34 -0
  381. package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -0
  382. package/dist/compiler/runtime/extract-locale-from-request-async.js +70 -0
  383. package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -0
  384. package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts +1 -0
  385. package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts.map +1 -0
  386. package/dist/compiler/runtime/extract-locale-from-request-async.test.js +119 -0
  387. package/dist/compiler/runtime/extract-locale-from-request-async.test.js.map +1 -0
  388. package/dist/compiler/runtime/extract-locale-from-request.d.ts +41 -0
  389. package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -0
  390. package/dist/compiler/runtime/extract-locale-from-request.js +96 -0
  391. package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -0
  392. package/dist/compiler/runtime/extract-locale-from-request.test.d.ts +1 -0
  393. package/dist/compiler/runtime/extract-locale-from-request.test.d.ts.map +1 -0
  394. package/dist/compiler/runtime/extract-locale-from-request.test.js +351 -0
  395. package/dist/compiler/runtime/extract-locale-from-request.test.js.map +1 -0
  396. package/dist/compiler/runtime/extract-locale-from-url.d.ts +11 -0
  397. package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -0
  398. package/dist/compiler/runtime/extract-locale-from-url.js +68 -0
  399. package/dist/compiler/runtime/extract-locale-from-url.js.map +1 -0
  400. package/dist/compiler/runtime/extract-locale-from-url.test.d.ts +1 -0
  401. package/dist/compiler/runtime/extract-locale-from-url.test.d.ts.map +1 -0
  402. package/dist/compiler/runtime/extract-locale-from-url.test.js +127 -0
  403. package/dist/compiler/runtime/extract-locale-from-url.test.js.map +1 -0
  404. package/dist/compiler/runtime/generate-static-localized-urls.d.ts +44 -0
  405. package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -0
  406. package/dist/compiler/runtime/generate-static-localized-urls.js +133 -0
  407. package/dist/compiler/runtime/generate-static-localized-urls.js.map +1 -0
  408. package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts +1 -0
  409. package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts.map +1 -0
  410. package/dist/compiler/runtime/generate-static-localized-urls.test.js +159 -0
  411. package/dist/compiler/runtime/generate-static-localized-urls.test.js.map +1 -0
  412. package/dist/compiler/runtime/get-locale.d.ts +42 -0
  413. package/dist/compiler/runtime/get-locale.d.ts.map +1 -0
  414. package/dist/compiler/runtime/get-locale.js +158 -0
  415. package/dist/compiler/runtime/get-locale.js.map +1 -0
  416. package/dist/compiler/runtime/get-locale.test.d.ts +1 -0
  417. package/dist/compiler/runtime/get-locale.test.d.ts.map +1 -0
  418. package/dist/compiler/runtime/get-locale.test.js +295 -0
  419. package/dist/compiler/runtime/get-locale.test.js.map +1 -0
  420. package/dist/compiler/runtime/get-text-direction.d.ts +15 -0
  421. package/dist/compiler/runtime/get-text-direction.d.ts.map +1 -0
  422. package/dist/compiler/runtime/get-text-direction.js +46 -0
  423. package/dist/compiler/runtime/get-text-direction.js.map +1 -0
  424. package/dist/compiler/runtime/get-text-direction.test.d.ts +1 -0
  425. package/dist/compiler/runtime/get-text-direction.test.d.ts.map +1 -0
  426. package/dist/compiler/runtime/get-text-direction.test.js +40 -0
  427. package/dist/compiler/runtime/get-text-direction.test.js.map +1 -0
  428. package/dist/compiler/runtime/get-url-origin.d.ts +19 -0
  429. package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -0
  430. package/dist/compiler/runtime/get-url-origin.js +31 -0
  431. package/dist/compiler/runtime/get-url-origin.js.map +1 -0
  432. package/dist/compiler/runtime/get-url-origin.test.d.ts +1 -0
  433. package/dist/compiler/runtime/get-url-origin.test.d.ts.map +1 -0
  434. package/dist/compiler/runtime/get-url-origin.test.js +18 -0
  435. package/dist/compiler/runtime/get-url-origin.test.js.map +1 -0
  436. package/dist/compiler/runtime/host-routing.d.ts +28 -0
  437. package/dist/compiler/runtime/host-routing.d.ts.map +1 -0
  438. package/dist/compiler/runtime/host-routing.js +79 -0
  439. package/dist/compiler/runtime/host-routing.js.map +1 -0
  440. package/dist/compiler/runtime/host-routing.test.d.ts +1 -0
  441. package/dist/compiler/runtime/host-routing.test.d.ts.map +1 -0
  442. package/dist/compiler/runtime/host-routing.test.js +128 -0
  443. package/dist/compiler/runtime/host-routing.test.js.map +1 -0
  444. package/dist/compiler/runtime/localize-href.d.ts +84 -0
  445. package/dist/compiler/runtime/localize-href.d.ts.map +1 -0
  446. package/dist/compiler/runtime/localize-href.js +115 -0
  447. package/dist/compiler/runtime/localize-href.js.map +1 -0
  448. package/dist/compiler/runtime/localize-href.test.d.ts +1 -0
  449. package/dist/compiler/runtime/localize-href.test.d.ts.map +1 -0
  450. package/dist/compiler/runtime/localize-href.test.js +139 -0
  451. package/dist/compiler/runtime/localize-href.test.js.map +1 -0
  452. package/dist/compiler/runtime/localize-url.d.ts +95 -0
  453. package/dist/compiler/runtime/localize-url.d.ts.map +1 -0
  454. package/dist/compiler/runtime/localize-url.js +327 -0
  455. package/dist/compiler/runtime/localize-url.js.map +1 -0
  456. package/dist/compiler/runtime/localize-url.test.d.ts +1 -0
  457. package/dist/compiler/runtime/localize-url.test.d.ts.map +1 -0
  458. package/dist/compiler/runtime/localize-url.test.js +533 -0
  459. package/dist/compiler/runtime/localize-url.test.js.map +1 -0
  460. package/dist/compiler/runtime/route-strategy.d.ts +32 -0
  461. package/dist/compiler/runtime/route-strategy.d.ts.map +1 -0
  462. package/dist/compiler/runtime/route-strategy.js +72 -0
  463. package/dist/compiler/runtime/route-strategy.js.map +1 -0
  464. package/dist/compiler/runtime/set-locale.d.ts +46 -0
  465. package/dist/compiler/runtime/set-locale.d.ts.map +1 -0
  466. package/dist/compiler/runtime/set-locale.js +172 -0
  467. package/dist/compiler/runtime/set-locale.js.map +1 -0
  468. package/dist/compiler/runtime/set-locale.test.d.ts +1 -0
  469. package/dist/compiler/runtime/set-locale.test.d.ts.map +1 -0
  470. package/dist/compiler/runtime/set-locale.test.js +555 -0
  471. package/dist/compiler/runtime/set-locale.test.js.map +1 -0
  472. package/dist/compiler/runtime/should-redirect.d.ts +100 -0
  473. package/dist/compiler/runtime/should-redirect.d.ts.map +1 -0
  474. package/dist/compiler/runtime/should-redirect.js +155 -0
  475. package/dist/compiler/runtime/should-redirect.js.map +1 -0
  476. package/dist/compiler/runtime/should-redirect.test.d.ts +1 -0
  477. package/dist/compiler/runtime/should-redirect.test.d.ts.map +1 -0
  478. package/dist/compiler/runtime/should-redirect.test.js +270 -0
  479. package/dist/compiler/runtime/should-redirect.test.js.map +1 -0
  480. package/dist/compiler/runtime/strategy.d.ts +63 -0
  481. package/dist/compiler/runtime/strategy.d.ts.map +1 -0
  482. package/dist/compiler/runtime/strategy.js +65 -0
  483. package/dist/compiler/runtime/strategy.js.map +1 -0
  484. package/dist/compiler/runtime/strategy.test.d.ts +1 -0
  485. package/dist/compiler/runtime/strategy.test.d.ts.map +1 -0
  486. package/dist/compiler/runtime/strategy.test.js +90 -0
  487. package/dist/compiler/runtime/strategy.test.js.map +1 -0
  488. package/dist/compiler/runtime/track-message-call.d.ts +5 -0
  489. package/dist/compiler/runtime/track-message-call.d.ts.map +1 -0
  490. package/dist/compiler/runtime/track-message-call.js +14 -0
  491. package/dist/compiler/runtime/track-message-call.js.map +1 -0
  492. package/dist/compiler/runtime/track-message-call.test.d.ts +1 -0
  493. package/dist/compiler/runtime/track-message-call.test.d.ts.map +1 -0
  494. package/dist/compiler/runtime/track-message-call.test.js +22 -0
  495. package/dist/compiler/runtime/track-message-call.test.js.map +1 -0
  496. package/dist/compiler/runtime/type-definitions.d.ts +197 -0
  497. package/dist/compiler/runtime/type-definitions.d.ts.map +1 -0
  498. package/dist/compiler/runtime/type-definitions.js +150 -0
  499. package/dist/compiler/runtime/type-definitions.js.map +1 -0
  500. package/dist/compiler/runtime/type.d.ts +47 -0
  501. package/dist/compiler/runtime/type.d.ts.map +1 -0
  502. package/dist/compiler/runtime/type.js +2 -0
  503. package/dist/compiler/runtime/type.js.map +1 -0
  504. package/dist/compiler/runtime/type.test.d.ts +1 -0
  505. package/dist/compiler/runtime/type.test.d.ts.map +1 -0
  506. package/dist/compiler/runtime/type.test.js +153 -0
  507. package/dist/compiler/runtime/type.test.js.map +1 -0
  508. package/dist/compiler/runtime/url-pattern.d.ts +12 -0
  509. package/dist/compiler/runtime/url-pattern.d.ts.map +1 -0
  510. package/dist/compiler/runtime/url-pattern.js +35 -0
  511. package/dist/compiler/runtime/url-pattern.js.map +1 -0
  512. package/dist/compiler/runtime/variables.d.ts +128 -0
  513. package/dist/compiler/runtime/variables.d.ts.map +1 -0
  514. package/dist/compiler/runtime/variables.js +111 -0
  515. package/dist/compiler/runtime/variables.js.map +1 -0
  516. package/dist/compiler/safe-module-id.d.ts +7 -0
  517. package/dist/compiler/safe-module-id.d.ts.map +1 -0
  518. package/dist/compiler/safe-module-id.js +78 -0
  519. package/dist/compiler/safe-module-id.js.map +1 -0
  520. package/dist/compiler/safe-module-id.test.d.ts +1 -0
  521. package/dist/compiler/safe-module-id.test.d.ts.map +1 -0
  522. package/dist/compiler/safe-module-id.test.js +36 -0
  523. package/dist/compiler/safe-module-id.test.js.map +1 -0
  524. package/dist/compiler/seed-previous-compilation.d.ts +7 -0
  525. package/dist/compiler/seed-previous-compilation.d.ts.map +1 -0
  526. package/dist/compiler/seed-previous-compilation.js +9 -0
  527. package/dist/compiler/seed-previous-compilation.js.map +1 -0
  528. package/dist/compiler/server/create-server-file.d.ts +12 -0
  529. package/dist/compiler/server/create-server-file.d.ts.map +1 -0
  530. package/dist/compiler/server/create-server-file.js +91 -0
  531. package/dist/compiler/server/create-server-file.js.map +1 -0
  532. package/dist/compiler/server/create-server-file.test.d.ts +1 -0
  533. package/dist/compiler/server/create-server-file.test.d.ts.map +1 -0
  534. package/dist/compiler/server/create-server-file.test.js +48 -0
  535. package/dist/compiler/server/create-server-file.test.js.map +1 -0
  536. package/dist/compiler/server/middleware.d.ts +98 -0
  537. package/dist/compiler/server/middleware.d.ts.map +1 -0
  538. package/dist/compiler/server/middleware.js +278 -0
  539. package/dist/compiler/server/middleware.js.map +1 -0
  540. package/dist/compiler/server/middleware.test.d.ts +1 -0
  541. package/dist/compiler/server/middleware.test.d.ts.map +1 -0
  542. package/dist/compiler/server/middleware.test.js +1001 -0
  543. package/dist/compiler/server/middleware.test.js.map +1 -0
  544. package/dist/compiler/server/type.d.ts +6 -0
  545. package/dist/compiler/server/type.d.ts.map +1 -0
  546. package/dist/compiler/server/type.js +2 -0
  547. package/dist/compiler/server/type.js.map +1 -0
  548. package/dist/compiler/test-helpers.d.ts +30 -0
  549. package/dist/compiler/test-helpers.d.ts.map +1 -0
  550. package/dist/compiler/test-helpers.js +50 -0
  551. package/dist/compiler/test-helpers.js.map +1 -0
  552. package/dist/compiler/types.d.ts +7 -0
  553. package/dist/compiler/types.d.ts.map +1 -0
  554. package/dist/compiler/types.js +2 -0
  555. package/dist/compiler/types.js.map +1 -0
  556. package/dist/compiler/variable-access.d.ts +3 -0
  557. package/dist/compiler/variable-access.d.ts.map +1 -0
  558. package/dist/compiler/variable-access.js +15 -0
  559. package/dist/compiler/variable-access.js.map +1 -0
  560. package/dist/index.d.ts +2 -0
  561. package/dist/index.d.ts.map +1 -0
  562. package/dist/index.js +3 -0
  563. package/dist/index.js.map +1 -0
  564. package/dist/messages/ast.d.ts +102 -0
  565. package/dist/messages/ast.d.ts.map +1 -0
  566. package/dist/messages/ast.js +8 -0
  567. package/dist/messages/ast.js.map +1 -0
  568. package/dist/messages/create-bundle-nested.d.ts +16 -0
  569. package/dist/messages/create-bundle-nested.d.ts.map +1 -0
  570. package/dist/messages/create-bundle-nested.js +22 -0
  571. package/dist/messages/create-bundle-nested.js.map +1 -0
  572. package/dist/messages/index.d.ts +5 -0
  573. package/dist/messages/index.d.ts.map +1 -0
  574. package/dist/messages/index.js +5 -0
  575. package/dist/messages/index.js.map +1 -0
  576. package/dist/messages/load-messages.d.ts +19 -0
  577. package/dist/messages/load-messages.d.ts.map +1 -0
  578. package/dist/messages/load-messages.js +49 -0
  579. package/dist/messages/load-messages.js.map +1 -0
  580. package/dist/messages/message-format/flatten.d.ts +9 -0
  581. package/dist/messages/message-format/flatten.d.ts.map +1 -0
  582. package/dist/messages/message-format/flatten.js +32 -0
  583. package/dist/messages/message-format/flatten.js.map +1 -0
  584. package/dist/messages/message-format/import-files.d.ts +32 -0
  585. package/dist/messages/message-format/import-files.d.ts.map +1 -0
  586. package/dist/messages/message-format/import-files.js +53 -0
  587. package/dist/messages/message-format/import-files.js.map +1 -0
  588. package/dist/messages/message-format/import-files.test.d.ts +1 -0
  589. package/dist/messages/message-format/import-files.test.d.ts.map +1 -0
  590. package/dist/messages/message-format/import-files.test.js +145 -0
  591. package/dist/messages/message-format/import-files.test.js.map +1 -0
  592. package/dist/messages/message-format/index.d.ts +6 -0
  593. package/dist/messages/message-format/index.d.ts.map +1 -0
  594. package/dist/messages/message-format/index.js +7 -0
  595. package/dist/messages/message-format/index.js.map +1 -0
  596. package/dist/messages/message-format/parse-bundle.d.ts +31 -0
  597. package/dist/messages/message-format/parse-bundle.d.ts.map +1 -0
  598. package/dist/messages/message-format/parse-bundle.js +169 -0
  599. package/dist/messages/message-format/parse-bundle.js.map +1 -0
  600. package/dist/messages/message-format/parse-declaration.d.ts +2 -0
  601. package/dist/messages/message-format/parse-declaration.d.ts.map +1 -0
  602. package/dist/messages/message-format/parse-declaration.js +56 -0
  603. package/dist/messages/message-format/parse-declaration.js.map +1 -0
  604. package/dist/messages/message-format/parse-markup.d.ts +4 -0
  605. package/dist/messages/message-format/parse-markup.d.ts.map +1 -0
  606. package/dist/messages/message-format/parse-markup.js +167 -0
  607. package/dist/messages/message-format/parse-markup.js.map +1 -0
  608. package/dist/messages/message-format/parse-matches.d.ts +5 -0
  609. package/dist/messages/message-format/parse-matches.d.ts.map +1 -0
  610. package/dist/messages/message-format/parse-matches.js +31 -0
  611. package/dist/messages/message-format/parse-matches.js.map +1 -0
  612. package/dist/messages/message-format/parse-pattern.d.ts +5 -0
  613. package/dist/messages/message-format/parse-pattern.d.ts.map +1 -0
  614. package/dist/messages/message-format/parse-pattern.js +120 -0
  615. package/dist/messages/message-format/parse-pattern.js.map +1 -0
  616. package/dist/messages/message-format/unique.d.ts +2 -0
  617. package/dist/messages/message-format/unique.d.ts.map +1 -0
  618. package/dist/messages/message-format/unique.js +5 -0
  619. package/dist/messages/message-format/unique.js.map +1 -0
  620. package/dist/messages/nest-bundles.d.ts +19 -0
  621. package/dist/messages/nest-bundles.d.ts.map +1 -0
  622. package/dist/messages/nest-bundles.js +49 -0
  623. package/dist/messages/nest-bundles.js.map +1 -0
  624. package/dist/services/account/index.d.ts +14 -0
  625. package/dist/services/account/index.d.ts.map +1 -0
  626. package/dist/services/account/index.js +43 -0
  627. package/dist/services/account/index.js.map +1 -0
  628. package/dist/services/account/types.d.ts +4 -0
  629. package/dist/services/account/types.d.ts.map +1 -0
  630. package/dist/services/account/types.js +2 -0
  631. package/dist/services/account/types.js.map +1 -0
  632. package/dist/services/codegen/escape.d.ts +9 -0
  633. package/dist/services/codegen/escape.d.ts.map +1 -0
  634. package/dist/services/codegen/escape.js +19 -0
  635. package/dist/services/codegen/escape.js.map +1 -0
  636. package/dist/services/codegen/quotes.d.ts +4 -0
  637. package/dist/services/codegen/quotes.d.ts.map +1 -0
  638. package/dist/services/codegen/quotes.js +5 -0
  639. package/dist/services/codegen/quotes.js.map +1 -0
  640. package/dist/services/env-variables/create-index-file.d.ts +9 -0
  641. package/dist/services/env-variables/create-index-file.d.ts.map +1 -0
  642. package/dist/services/env-variables/create-index-file.js +28 -0
  643. package/dist/services/env-variables/create-index-file.js.map +1 -0
  644. package/dist/services/env-variables/index.d.ts +3 -0
  645. package/dist/services/env-variables/index.d.ts.map +1 -0
  646. package/dist/services/env-variables/index.js +4 -0
  647. package/dist/services/env-variables/index.js.map +1 -0
  648. package/dist/services/environment/package.d.ts +9 -0
  649. package/dist/services/environment/package.d.ts.map +1 -0
  650. package/dist/services/environment/package.js +31 -0
  651. package/dist/services/environment/package.js.map +1 -0
  652. package/dist/services/environment/package.test.d.ts +1 -0
  653. package/dist/services/environment/package.test.d.ts.map +1 -0
  654. package/dist/services/environment/package.test.js +21 -0
  655. package/dist/services/environment/package.test.js.map +1 -0
  656. package/dist/services/error-handling.d.ts +12 -0
  657. package/dist/services/error-handling.d.ts.map +1 -0
  658. package/dist/services/error-handling.js +27 -0
  659. package/dist/services/error-handling.js.map +1 -0
  660. package/dist/services/error-handling.test.d.ts +1 -0
  661. package/dist/services/error-handling.test.d.ts.map +1 -0
  662. package/dist/services/error-handling.test.js +10 -0
  663. package/dist/services/error-handling.test.js.map +1 -0
  664. package/dist/services/file-handling/content-hash.d.ts +9 -0
  665. package/dist/services/file-handling/content-hash.js +19 -0
  666. package/dist/services/file-handling/content-hash.js.map +1 -0
  667. package/dist/services/file-handling/exists.d.ts +7 -0
  668. package/dist/services/file-handling/exists.d.ts.map +1 -0
  669. package/dist/services/file-handling/exists.js +24 -0
  670. package/dist/services/file-handling/exists.js.map +1 -0
  671. package/dist/services/file-handling/exists.test.d.ts +1 -0
  672. package/dist/services/file-handling/exists.test.d.ts.map +1 -0
  673. package/dist/services/file-handling/exists.test.js +27 -0
  674. package/dist/services/file-handling/exists.test.js.map +1 -0
  675. package/dist/services/file-handling/types.d.ts +4 -0
  676. package/dist/services/file-handling/types.d.ts.map +1 -0
  677. package/dist/services/file-handling/types.js +2 -0
  678. package/dist/services/file-handling/types.js.map +1 -0
  679. package/dist/services/file-handling/write-output.d.ts +21 -0
  680. package/dist/services/file-handling/write-output.d.ts.map +1 -0
  681. package/dist/services/file-handling/write-output.js +157 -0
  682. package/dist/services/file-handling/write-output.js.map +1 -0
  683. package/dist/services/file-handling/write-output.test.d.ts +1 -0
  684. package/dist/services/file-handling/write-output.test.d.ts.map +1 -0
  685. package/dist/services/file-handling/write-output.test.js +217 -0
  686. package/dist/services/file-handling/write-output.test.js.map +1 -0
  687. package/dist/services/file-watching/tracked-fs.d.ts +25 -0
  688. package/dist/services/file-watching/tracked-fs.d.ts.map +1 -0
  689. package/dist/services/file-watching/tracked-fs.js +94 -0
  690. package/dist/services/file-watching/tracked-fs.js.map +1 -0
  691. package/dist/services/file-watching/tracked-fs.test.d.ts +1 -0
  692. package/dist/services/file-watching/tracked-fs.test.d.ts.map +1 -0
  693. package/dist/services/file-watching/tracked-fs.test.js +87 -0
  694. package/dist/services/file-watching/tracked-fs.test.js.map +1 -0
  695. package/dist/services/logger/index.d.ts +17 -0
  696. package/dist/services/logger/index.d.ts.map +1 -0
  697. package/dist/services/logger/index.js +58 -0
  698. package/dist/services/logger/index.js.map +1 -0
  699. package/dist/services/lookup.d.ts +14 -0
  700. package/dist/services/lookup.d.ts.map +1 -0
  701. package/dist/services/lookup.js +24 -0
  702. package/dist/services/lookup.js.map +1 -0
  703. package/dist/urlpattern-polyfill/index.d.ts +2 -0
  704. package/dist/urlpattern-polyfill/index.d.ts.map +1 -0
  705. package/dist/urlpattern-polyfill/index.js +2 -0
  706. package/dist/urlpattern-polyfill/index.js.map +1 -0
  707. package/dist/utilities/detect-json-formatting.d.ts +10 -0
  708. package/dist/utilities/detect-json-formatting.d.ts.map +1 -0
  709. package/dist/utilities/detect-json-formatting.js +80 -0
  710. package/dist/utilities/detect-json-formatting.js.map +1 -0
  711. package/dist/utilities/node-normalize-path.d.ts +1 -0
  712. package/dist/utilities/node-normalize-path.d.ts.map +1 -0
  713. package/dist/utilities/node-normalize-path.js +10 -0
  714. package/dist/utilities/node-normalize-path.js.map +1 -0
  715. package/package.json +87 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAwB,MAAM,WAAW,CAAC;AA2B1D,eAAO,MAAM,cAAc,SA0TzB,CAAC"}
@@ -0,0 +1,225 @@
1
+ import { Command, InvalidArgumentError } from "commander";
2
+ import fs from "node:fs";
3
+ import { resolve, relative } from "node:path";
4
+ import { Logger } from "../../../services/logger/index.js";
5
+ import { DEFAULT_BASE_LOCALE, DEFAULT_LOCALES, DEFAULT_MESSAGES, DEFAULT_OUTDIR } from "../../defaults.js";
6
+ import { compile } from "../../../compiler/compile.js";
7
+ import { seedPreviousCompilationFromOutdir } from "../../../compiler/seed-previous-compilation.js";
8
+ import { defaultCompilerOptions, } from "../../../compiler/compiler-options.js";
9
+ import { createTrackedFs, getWatchTargets, } from "../../../services/file-watching/tracked-fs.js";
10
+ const parseOutputStructure = (value) => {
11
+ if (value === "message-modules" || value === "locale-modules") {
12
+ return value;
13
+ }
14
+ throw new InvalidArgumentError(`Invalid output structure "${value}". Expected "message-modules" or "locale-modules".`);
15
+ };
16
+ export const compileCommand = new Command()
17
+ .name("compile")
18
+ .summary("Compiles paraglide-lite message files")
19
+ .option("--messages <path>", 'Path pattern for locale files. Example: "./messages/{locale}.json"', DEFAULT_MESSAGES)
20
+ .option("--locales <items...>", "Locales to compile. Example: --locales en de", [...DEFAULT_LOCALES])
21
+ .option("--base-locale <locale>", "Base locale for fallbacks", DEFAULT_BASE_LOCALE)
22
+ .requiredOption("--outdir <path>", 'The path to the output directory. Example: "./src/paraglide"', DEFAULT_OUTDIR)
23
+ .option("--strategy <items...>", [
24
+ "The strategy to be used.",
25
+ "",
26
+ "Example: --strategy cookie globalVariable baseLocale",
27
+ "Upstream docs: https://paraglidejs.com/strategy",
28
+ ].join("\n"))
29
+ .requiredOption("--silent", "Only log errors to the console", false)
30
+ .option("--emit-ts-declarations", "Emit .d.ts files for the generated output (requires the typescript package)", defaultCompilerOptions.emitTsDeclarations)
31
+ .option("--no-emit-ts-declarations", "Do not emit .d.ts files for the generated output")
32
+ .option("--emit-git-ignore", "Emit a .gitignore in the output directory", defaultCompilerOptions.emitGitIgnore)
33
+ .option("--no-emit-git-ignore", "Do not emit a .gitignore in the output directory")
34
+ .option("--emit-prettier-ignore", "Emit a .prettierignore in the output directory", defaultCompilerOptions.emitPrettierIgnore)
35
+ .option("--no-emit-prettier-ignore", "Do not emit a .prettierignore in the output directory")
36
+ .option("--emit-readme", "Emit a README.md in the output directory (helps LLMs understand the generated code)", defaultCompilerOptions.emitReadme)
37
+ .option("--no-emit-readme", "Do not emit README.md in the output directory")
38
+ .option("--is-server <expression>", [
39
+ "JavaScript expression for runtime `isServer` (enables server/client tree-shaking).",
40
+ 'Quote if the expression contains spaces, e.g. --is-server \'typeof window === "undefined"\'.',
41
+ "Vite SSR example: --is-server 'import.meta.env.SSR'",
42
+ ].join(" "))
43
+ .option("--output-structure <structure>", [
44
+ 'The output structure for compiled messages. Either "message-modules" or "locale-modules".',
45
+ "",
46
+ '"message-modules" gives each message its own module (better tree-shaking).',
47
+ '"locale-modules" bundles messages per locale (fewer files, better for large projects in dev).',
48
+ ].join("\n"), parseOutputStructure, defaultCompilerOptions.outputStructure)
49
+ .option("--watch", "Watch message files and recompile on change", false)
50
+ .action(async (options) => {
51
+ const logger = new Logger({ silent: options.silent, prefix: true });
52
+ const compileOptions = {
53
+ messages: options.messages,
54
+ locales: options.locales,
55
+ baseLocale: options.baseLocale,
56
+ outdir: options.outdir,
57
+ strategy: options.strategy ?? defaultCompilerOptions.strategy,
58
+ emitTsDeclarations: options.emitTsDeclarations ??
59
+ defaultCompilerOptions.emitTsDeclarations,
60
+ emitGitIgnore: options.emitGitIgnore ?? defaultCompilerOptions.emitGitIgnore,
61
+ emitPrettierIgnore: options.emitPrettierIgnore ??
62
+ defaultCompilerOptions.emitPrettierIgnore,
63
+ emitReadme: options.emitReadme ?? defaultCompilerOptions.emitReadme,
64
+ isServer: options.isServer ?? defaultCompilerOptions.isServer,
65
+ outputStructure: options.outputStructure ??
66
+ defaultCompilerOptions.outputStructure,
67
+ // CLI always writes the full output tree to disk.
68
+ emitFiles: true,
69
+ };
70
+ if (!options.watch) {
71
+ logger.info(`Compiling messages ...`);
72
+ try {
73
+ await compile(compileOptions);
74
+ }
75
+ catch (e) {
76
+ logger.error("Error while compiling messages.");
77
+ logger.error(e);
78
+ process.exit(1);
79
+ }
80
+ logger.success(`Successfully compiled messages.`);
81
+ process.exit(0);
82
+ }
83
+ const { fs: trackedFs, readFiles, clearReadFiles } = createTrackedFs();
84
+ const fileWatchers = new Map();
85
+ const directoryWatchers = new Map();
86
+ let previousCompilation;
87
+ let compileTimer;
88
+ let compileInProgress = false;
89
+ let compileRequested = false;
90
+ const updateWatchers = (files) => {
91
+ const { files: nextFiles, directories: nextDirectories, isIgnoredPath, } = getWatchTargets(files, { outdir: options.outdir });
92
+ for (const [filePath, watcher] of fileWatchers) {
93
+ if (!nextFiles.has(filePath)) {
94
+ watcher.close();
95
+ fileWatchers.delete(filePath);
96
+ }
97
+ }
98
+ for (const [directoryPath, watcher] of directoryWatchers) {
99
+ if (!nextDirectories.has(directoryPath)) {
100
+ watcher.close();
101
+ directoryWatchers.delete(directoryPath);
102
+ }
103
+ }
104
+ const attachWatcherErrorHandler = (watcher, targetPath, targetType) => {
105
+ watcher.on("error", (error) => {
106
+ logger.warn(`Watch ${targetType} error for ${targetPath}: ${error.message}`);
107
+ });
108
+ };
109
+ for (const filePath of nextFiles) {
110
+ if (fileWatchers.has(filePath)) {
111
+ continue;
112
+ }
113
+ try {
114
+ const watcher = fs.watch(filePath, () => {
115
+ scheduleCompile(filePath);
116
+ });
117
+ attachWatcherErrorHandler(watcher, filePath, "file");
118
+ fileWatchers.set(filePath, watcher);
119
+ }
120
+ catch (error) {
121
+ logger.warn(`Failed to watch file: ${filePath}`);
122
+ }
123
+ }
124
+ for (const directoryPath of nextDirectories) {
125
+ if (directoryWatchers.has(directoryPath)) {
126
+ continue;
127
+ }
128
+ try {
129
+ const watcher = fs.watch(directoryPath, (eventType, filename) => {
130
+ if (!filename) {
131
+ scheduleCompile(directoryPath);
132
+ return;
133
+ }
134
+ const changedPath = resolve(directoryPath, filename.toString());
135
+ if (isIgnoredPath(changedPath)) {
136
+ return;
137
+ }
138
+ scheduleCompile(changedPath);
139
+ });
140
+ attachWatcherErrorHandler(watcher, directoryPath, "directory");
141
+ directoryWatchers.set(directoryPath, watcher);
142
+ }
143
+ catch (error) {
144
+ logger.warn(`Failed to watch directory: ${directoryPath}`);
145
+ }
146
+ }
147
+ };
148
+ const runCompile = async (changedPath) => {
149
+ if (compileInProgress) {
150
+ compileRequested = true;
151
+ return;
152
+ }
153
+ compileInProgress = true;
154
+ const previouslyReadFiles = new Set(readFiles);
155
+ clearReadFiles();
156
+ if (changedPath) {
157
+ logger.info(`Re-compiling messages... File "${relative(process.cwd(), changedPath)}" has changed.`);
158
+ }
159
+ else {
160
+ logger.info("Compiling messages ...");
161
+ }
162
+ try {
163
+ const seededPrevious = previousCompilation ??
164
+ (await seedPreviousCompilationFromOutdir({
165
+ outdir: compileOptions.outdir,
166
+ }));
167
+ previousCompilation = await compile({
168
+ ...compileOptions,
169
+ fs: trackedFs,
170
+ previousCompilation: seededPrevious,
171
+ cleanOutdir: false,
172
+ });
173
+ if (changedPath) {
174
+ logger.success("Re-compilation complete.");
175
+ }
176
+ else {
177
+ logger.success("Successfully compiled messages.");
178
+ }
179
+ }
180
+ catch (e) {
181
+ if (previouslyReadFiles.size > 0) {
182
+ clearReadFiles();
183
+ for (const filePath of previouslyReadFiles) {
184
+ readFiles.add(filePath);
185
+ }
186
+ }
187
+ previousCompilation = undefined;
188
+ logger.error("Error while compiling messages.");
189
+ logger.error(e);
190
+ }
191
+ finally {
192
+ updateWatchers(readFiles);
193
+ compileInProgress = false;
194
+ if (compileRequested) {
195
+ compileRequested = false;
196
+ runCompile();
197
+ }
198
+ }
199
+ };
200
+ const scheduleCompile = (changedPath) => {
201
+ if (compileTimer) {
202
+ clearTimeout(compileTimer);
203
+ }
204
+ compileTimer = setTimeout(() => {
205
+ runCompile(changedPath);
206
+ }, 100);
207
+ };
208
+ const closeWatchers = () => {
209
+ for (const watcher of fileWatchers.values()) {
210
+ watcher.close();
211
+ }
212
+ for (const watcher of directoryWatchers.values()) {
213
+ watcher.close();
214
+ }
215
+ fileWatchers.clear();
216
+ directoryWatchers.clear();
217
+ };
218
+ process.on("SIGINT", () => {
219
+ closeWatchers();
220
+ process.exit(0);
221
+ });
222
+ await runCompile();
223
+ logger.info("Watching for changes...");
224
+ });
225
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAAE,OAAO,EAA0B,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,iCAAiC,EAAE,MAAM,gDAAgD,CAAC;AACnG,OAAO,EACN,sBAAsB,GAEtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,eAAe,EACf,eAAe,GACf,MAAM,+CAA+C,CAAC;AAEvD,MAAM,oBAAoB,GAAG,CAC5B,KAAa,EACqC,EAAE;IACpD,IAAI,KAAK,KAAK,iBAAiB,IAAI,KAAK,KAAK,gBAAgB,EAAE,CAAC;QAC/D,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,IAAI,oBAAoB,CAC7B,6BAA6B,KAAK,oDAAoD,CACtF,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,OAAO,EAAE;KACzC,IAAI,CAAC,SAAS,CAAC;KACf,OAAO,CAAC,uCAAuC,CAAC;KAChD,MAAM,CACN,mBAAmB,EACnB,oEAAoE,EACpE,gBAAgB,CAChB;KACA,MAAM,CACN,sBAAsB,EACtB,8CAA8C,EAC9C,CAAC,GAAG,eAAe,CAAC,CACpB;KACA,MAAM,CACN,wBAAwB,EACxB,2BAA2B,EAC3B,mBAAmB,CACnB;KACA,cAAc,CACd,iBAAiB,E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AAC;IACjB,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,EAAE,CAAC;IACnB,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AACxC,CAAC,CACD,CAAC","sourcesContent":["import { Command, InvalidArgumentError } from \"commander\";\nimport fs from \"node:fs\";\nimport { resolve, relative } from \"node:path\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport { DEFAULT_BASE_LOCALE, DEFAULT_LOCALES, DEFAULT_MESSAGES, DEFAULT_OUTDIR } from \"../../defaults.js\";\nimport { compile, type CompilationResult } from \"../../../compiler/compile.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../../../compiler/seed-previous-compilation.js\";\nimport {\n\tdefaultCompilerOptions,\n\ttype CompilerOptions,\n} from \"../../../compiler/compiler-options.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n} from \"../../../services/file-watching/tracked-fs.js\";\n\nconst parseOutputStructure = (\n\tvalue: string\n): NonNullable<CompilerOptions[\"outputStructure\"]> => {\n\tif (value === \"message-modules\" || value === \"locale-modules\") {\n\t\treturn value;\n\t}\n\tthrow new InvalidArgumentError(\n\t\t`Invalid output structure \"${value}\". Expected \"message-modules\" or \"locale-modules\".`\n\t);\n};\n\nexport const compileCommand = new Command()\n\t.name(\"compile\")\n\t.summary(\"Compiles paraglide-lite message files\")\n\t.option(\n\t\t\"--messages <path>\",\n\t\t'Path pattern for locale files. Example: \"./messages/{locale}.json\"',\n\t\tDEFAULT_MESSAGES\n\t)\n\t.option(\n\t\t\"--locales <items...>\",\n\t\t\"Locales to compile. Example: --locales en de\",\n\t\t[...DEFAULT_LOCALES]\n\t)\n\t.option(\n\t\t\"--base-locale <locale>\",\n\t\t\"Base locale for fallbacks\",\n\t\tDEFAULT_BASE_LOCALE\n\t)\n\t.requiredOption(\n\t\t\"--outdir <path>\",\n\t\t'The path to the output directory. Example: \"./src/paraglide\"',\n\t\tDEFAULT_OUTDIR\n\t)\n\t.option(\n\t\t\"--strategy <items...>\",\n\t\t[\n\t\t\t\"The strategy to be used.\",\n\t\t\t\"\",\n\t\t\t\"Example: --strategy cookie globalVariable baseLocale\",\n\t\t\t\"Upstream docs: https://paraglidejs.com/strategy\",\n\t\t].join(\"\\n\")\n\t)\n\t.requiredOption(\"--silent\", \"Only log errors to the console\", false)\n\t.option(\n\t\t\"--emit-ts-declarations\",\n\t\t\"Emit .d.ts files for the generated output (requires the typescript package)\",\n\t\tdefaultCompilerOptions.emitTsDeclarations\n\t)\n\t.option(\n\t\t\"--no-emit-ts-declarations\",\n\t\t\"Do not emit .d.ts files for the generated output\"\n\t)\n\t.option(\n\t\t\"--emit-git-ignore\",\n\t\t\"Emit a .gitignore in the output directory\",\n\t\tdefaultCompilerOptions.emitGitIgnore\n\t)\n\t.option(\n\t\t\"--no-emit-git-ignore\",\n\t\t\"Do not emit a .gitignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-prettier-ignore\",\n\t\t\"Emit a .prettierignore in the output directory\",\n\t\tdefaultCompilerOptions.emitPrettierIgnore\n\t)\n\t.option(\n\t\t\"--no-emit-prettier-ignore\",\n\t\t\"Do not emit a .prettierignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-readme\",\n\t\t\"Emit a README.md in the output directory (helps LLMs understand the generated code)\",\n\t\tdefaultCompilerOptions.emitReadme\n\t)\n\t.option(\n\t\t\"--no-emit-readme\",\n\t\t\"Do not emit README.md in the output directory\"\n\t)\n\t.option(\n\t\t\"--is-server <expression>\",\n\t\t[\n\t\t\t\"JavaScript expression for runtime `isServer` (enables server/client tree-shaking).\",\n\t\t\t'Quote if the expression contains spaces, e.g. --is-server \\'typeof window === \"undefined\"\\'.',\n\t\t\t\"Vite SSR example: --is-server 'import.meta.env.SSR'\",\n\t\t].join(\" \")\n\t)\n\t.option(\n\t\t\"--output-structure <structure>\",\n\t\t[\n\t\t\t'The output structure for compiled messages. Either \"message-modules\" or \"locale-modules\".',\n\t\t\t\"\",\n\t\t\t'\"message-modules\" gives each message its own module (better tree-shaking).',\n\t\t\t'\"locale-modules\" bundles messages per locale (fewer files, better for large projects in dev).',\n\t\t].join(\"\\n\"),\n\t\tparseOutputStructure,\n\t\tdefaultCompilerOptions.outputStructure\n\t)\n\t.option(\"--watch\", \"Watch message files and recompile on change\", false)\n\t.action(\n\t\tasync (options: {\n\t\t\tsilent: boolean;\n\t\t\tmessages: string;\n\t\t\tlocales: string[];\n\t\t\tbaseLocale: string;\n\t\t\toutdir: string;\n\t\t\tstrategy?: CompilerOptions[\"strategy\"];\n\t\t\temitTsDeclarations?: CompilerOptions[\"emitTsDeclarations\"];\n\t\t\temitGitIgnore?: CompilerOptions[\"emitGitIgnore\"];\n\t\t\temitPrettierIgnore?: CompilerOptions[\"emitPrettierIgnore\"];\n\t\t\temitReadme?: CompilerOptions[\"emitReadme\"];\n\t\t\tisServer?: CompilerOptions[\"isServer\"];\n\t\t\toutputStructure?: CompilerOptions[\"outputStructure\"];\n\t\t\twatch?: boolean;\n\t\t}) => {\n\t\t\tconst logger = new Logger({ silent: options.silent, prefix: true });\n\n\t\t\tconst compileOptions = {\n\t\t\t\tmessages: options.messages,\n\t\t\t\tlocales: options.locales,\n\t\t\t\tbaseLocale: options.baseLocale,\n\t\t\t\toutdir: options.outdir,\n\t\t\t\tstrategy: options.strategy ?? defaultCompilerOptions.strategy,\n\t\t\t\temitTsDeclarations:\n\t\t\t\t\toptions.emitTsDeclarations ??\n\t\t\t\t\tdefaultCompilerOptions.emitTsDeclarations,\n\t\t\t\temitGitIgnore:\n\t\t\t\t\toptions.emitGitIgnore ?? defaultCompilerOptions.emitGitIgnore,\n\t\t\t\temitPrettierIgnore:\n\t\t\t\t\toptions.emitPrettierIgnore ??\n\t\t\t\t\tdefaultCompilerOptions.emitPrettierIgnore,\n\t\t\t\temitReadme: options.emitReadme ?? defaultCompilerOptions.emitReadme,\n\t\t\t\tisServer: options.isServer ?? defaultCompilerOptions.isServer,\n\t\t\t\toutputStructure:\n\t\t\t\t\toptions.outputStructure ??\n\t\t\t\t\tdefaultCompilerOptions.outputStructure,\n\t\t\t\t// CLI always writes the full output tree to disk.\n\t\t\t\temitFiles: true as const,\n\t\t\t};\n\n\t\t\tif (!options.watch) {\n\t\t\t\tlogger.info(`Compiling messages ...`);\n\n\t\t\t\ttry {\n\t\t\t\t\tawait compile(compileOptions);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlogger.error(\"Error while compiling messages.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlogger.success(`Successfully compiled messages.`);\n\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\n\t\t\tconst { fs: trackedFs, readFiles, clearReadFiles } = createTrackedFs();\n\t\t\tconst fileWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tconst directoryWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tlet previousCompilation: CompilationResult | undefined;\n\t\t\tlet compileTimer: NodeJS.Timeout | undefined;\n\t\t\tlet compileInProgress = false;\n\t\t\tlet compileRequested = false;\n\n\t\t\tconst updateWatchers = (files: Set<string>) => {\n\t\t\t\tconst {\n\t\t\t\t\tfiles: nextFiles,\n\t\t\t\t\tdirectories: nextDirectories,\n\t\t\t\t\tisIgnoredPath,\n\t\t\t\t} = getWatchTargets(files, { outdir: options.outdir });\n\n\t\t\t\tfor (const [filePath, watcher] of fileWatchers) {\n\t\t\t\t\tif (!nextFiles.has(filePath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tfileWatchers.delete(filePath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const [directoryPath, watcher] of directoryWatchers) {\n\t\t\t\t\tif (!nextDirectories.has(directoryPath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tdirectoryWatchers.delete(directoryPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst attachWatcherErrorHandler = (\n\t\t\t\t\twatcher: fs.FSWatcher,\n\t\t\t\t\ttargetPath: string,\n\t\t\t\t\ttargetType: \"file\" | \"directory\"\n\t\t\t\t) => {\n\t\t\t\t\twatcher.on(\"error\", (error) => {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t`Watch ${targetType} error for ${targetPath}: ${(error as Error).message}`\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tfor (const filePath of nextFiles) {\n\t\t\t\t\tif (fileWatchers.has(filePath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(filePath, () => {\n\t\t\t\t\t\t\tscheduleCompile(filePath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, filePath, \"file\");\n\t\t\t\t\t\tfileWatchers.set(filePath, watcher);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlogger.warn(`Failed to watch file: ${filePath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const directoryPath of nextDirectories) {\n\t\t\t\t\tif (directoryWatchers.has(directoryPath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(directoryPath, (eventType, filename) => {\n\t\t\t\t\t\t\tif (!filename) {\n\t\t\t\t\t\t\t\tscheduleCompile(directoryPath);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst changedPath = resolve(directoryPath, filename.toString());\n\t\t\t\t\t\t\tif (isIgnoredPath(changedPath)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tscheduleCompile(changedPath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, directoryPath, \"directory\");\n\t\t\t\t\t\tdirectoryWatchers.set(directoryPath, watcher);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlogger.warn(`Failed to watch directory: ${directoryPath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst runCompile = async (changedPath?: string) => {\n\t\t\t\tif (compileInProgress) {\n\t\t\t\t\tcompileRequested = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcompileInProgress = true;\n\t\t\t\tconst previouslyReadFiles = new Set(readFiles);\n\t\t\t\tclearReadFiles();\n\n\t\t\t\tif (changedPath) {\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t`Re-compiling messages... File \"${relative(process.cwd(), changedPath)}\" has changed.`\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.info(\"Compiling messages ...\");\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tpreviousCompilation ??\n\t\t\t\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t\t}));\n\n\t\t\t\t\tpreviousCompilation = await compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tfs: trackedFs,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (changedPath) {\n\t\t\t\t\t\tlogger.success(\"Re-compilation complete.\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.success(\"Successfully compiled messages.\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (previouslyReadFiles.size > 0) {\n\t\t\t\t\t\tclearReadFiles();\n\t\t\t\t\t\tfor (const filePath of previouslyReadFiles) {\n\t\t\t\t\t\t\treadFiles.add(filePath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpreviousCompilation = undefined;\n\t\t\t\t\tlogger.error(\"Error while compiling messages.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t} finally {\n\t\t\t\t\tupdateWatchers(readFiles);\n\t\t\t\t\tcompileInProgress = false;\n\t\t\t\t\tif (compileRequested) {\n\t\t\t\t\t\tcompileRequested = false;\n\t\t\t\t\t\trunCompile();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleCompile = (changedPath?: string) => {\n\t\t\t\tif (compileTimer) {\n\t\t\t\t\tclearTimeout(compileTimer);\n\t\t\t\t}\n\t\t\t\tcompileTimer = setTimeout(() => {\n\t\t\t\t\trunCompile(changedPath);\n\t\t\t\t}, 100);\n\t\t\t};\n\n\t\t\tconst closeWatchers = () => {\n\t\t\t\tfor (const watcher of fileWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfor (const watcher of directoryWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfileWatchers.clear();\n\t\t\t\tdirectoryWatchers.clear();\n\t\t\t};\n\n\t\t\tprocess.on(\"SIGINT\", () => {\n\t\t\t\tcloseWatchers();\n\t\t\t\tprocess.exit(0);\n\t\t\t});\n\n\t\t\tawait runCompile();\n\t\t\tlogger.info(\"Watching for changes...\");\n\t\t}\n\t);\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.test.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,69 @@
1
+ import { mkdtemp, rm } from "node:fs/promises";
2
+ import * as nodeFs from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import path from "node:path";
5
+ import { afterEach, beforeEach, expect, test, vi } from "vitest";
6
+ let testDirectories = [];
7
+ let initialSigintListeners = [];
8
+ beforeEach(() => {
9
+ vi.resetModules();
10
+ testDirectories = [];
11
+ initialSigintListeners = process.listeners("SIGINT");
12
+ });
13
+ afterEach(async () => {
14
+ for (const listener of process.listeners("SIGINT")) {
15
+ if (!initialSigintListeners.includes(listener)) {
16
+ process.removeListener("SIGINT", listener);
17
+ }
18
+ }
19
+ for (const directory of testDirectories) {
20
+ await rm(directory, { recursive: true, force: true });
21
+ }
22
+ });
23
+ test("compile --watch seeds existing outdir and disables cleaning on first compile (#688)", async () => {
24
+ const testDirectory = await mkdtemp(path.join(tmpdir(), "paraglide-cli-"));
25
+ testDirectories.push(testDirectory);
26
+ const outdir = path.join(testDirectory, "output");
27
+ const { writeOutput } = await import("../../../services/file-handling/write-output.js");
28
+ await writeOutput({
29
+ directory: outdir,
30
+ output: {
31
+ "runtime.js": "export const runtime = true;",
32
+ },
33
+ fs: nodeFs,
34
+ });
35
+ const compileMock = vi.fn().mockResolvedValue({
36
+ outputHashes: {
37
+ "runtime.js": "next-hash",
38
+ },
39
+ });
40
+ vi.doMock("../../../compiler/compile.js", () => ({
41
+ compile: compileMock,
42
+ }));
43
+ const { compileCommand } = await import("./command.js");
44
+ await compileCommand.parseAsync([
45
+ "--messages",
46
+ "./messages/{locale}.json",
47
+ "--locales",
48
+ "en",
49
+ "de",
50
+ "--base-locale",
51
+ "en",
52
+ "--outdir",
53
+ outdir,
54
+ "--watch",
55
+ "--silent",
56
+ ], { from: "user" });
57
+ expect(compileMock).toHaveBeenCalledTimes(1);
58
+ expect(compileMock).toHaveBeenCalledWith(expect.objectContaining({
59
+ outdir,
60
+ cleanOutdir: false,
61
+ previousCompilation: {
62
+ outputHashes: {
63
+ "runtime.js": expect.any(String),
64
+ },
65
+ output: {},
66
+ },
67
+ }));
68
+ });
69
+ //# sourceMappingURL=command.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.test.js","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS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AAM,WAAW,CAAC;QACjB,SAAS,EAAE,MAAM;QACjB,MAAM,EAAE;YACP,YAAY,EAAE,8BAA8B;SAC5C;QACD,EAAE,EAAE,MAAM;KACV,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;QAC7C,YAAY,EAAE;YACb,YAAY,EAAE,WAAW;SACzB;KACD,CAAC,CAAC;IACH,EAAE,CAAC,MAAM,CAAC,8BAA8B,EAAE,GAAG,EAAE,CAAC,CAAC;QAChD,OAAO,EAAE,WAAW;KACpB,CAAC,CAAC,CAAC;IAEJ,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;IAExD,MAAM,cAAc,CAAC,UAAU,CAC9B;QACC,YAAY;QACZ,0BAA0B;QAC1B,WAAW;QACX,IAAI;QACJ,IAAI;QACJ,eAAe;QACf,IAAI;QACJ,UAAU;QACV,MAAM;QACN,SAAS;QACT,UAAU;KACV,EACD,EAAE,IAAI,EAAE,MAAM,EAAE,CAChB,CAAC;IAEF,MAAM,CAAC,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,WAAW,CAAC,CAAC,oBAAoB,CACvC,MAAM,CAAC,gBAAgB,CAAC;QACvB,MAAM;QACN,WAAW,EAAE,KAAK;QAClB,mBAAmB,EAAE;YACpB,YAAY,EAAE;gBACb,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;aAChC;YACD,MAAM,EAAE,EAAE;SACV;KACD,CAAC,CACF,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { mkdtemp, rm } from \"node:fs/promises\";\nimport * as nodeFs from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { afterEach, beforeEach, expect, test, vi } from \"vitest\";\n\nlet testDirectories: string[] = [];\nlet initialSigintListeners: NodeJS.SignalsListener[] = [];\n\nbeforeEach(() => {\n\tvi.resetModules();\n\ttestDirectories = [];\n\tinitialSigintListeners = process.listeners(\"SIGINT\");\n});\n\nafterEach(async () => {\n\tfor (const listener of process.listeners(\"SIGINT\")) {\n\t\tif (!initialSigintListeners.includes(listener)) {\n\t\t\tprocess.removeListener(\"SIGINT\", listener);\n\t\t}\n\t}\n\tfor (const directory of testDirectories) {\n\t\tawait rm(directory, { recursive: true, force: true });\n\t}\n});\n\ntest(\"compile --watch seeds existing outdir and disables cleaning on first compile (#688)\", async () => {\n\tconst testDirectory = await mkdtemp(path.join(tmpdir(), \"paraglide-cli-\"));\n\ttestDirectories.push(testDirectory);\n\tconst outdir = path.join(testDirectory, \"output\");\n\tconst { writeOutput } = await import(\n\t\t\"../../../services/file-handling/write-output.js\"\n\t);\n\tawait writeOutput({\n\t\tdirectory: outdir,\n\t\toutput: {\n\t\t\t\"runtime.js\": \"export const runtime = true;\",\n\t\t},\n\t\tfs: nodeFs,\n\t});\n\n\tconst compileMock = vi.fn().mockResolvedValue({\n\t\toutputHashes: {\n\t\t\t\"runtime.js\": \"next-hash\",\n\t\t},\n\t});\n\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\tcompile: compileMock,\n\t}));\n\n\tconst { compileCommand } = await import(\"./command.js\");\n\n\tawait compileCommand.parseAsync(\n\t\t[\n\t\t\t\"--messages\",\n\t\t\t\"./messages/{locale}.json\",\n\t\t\t\"--locales\",\n\t\t\t\"en\",\n\t\t\t\"de\",\n\t\t\t\"--base-locale\",\n\t\t\t\"en\",\n\t\t\t\"--outdir\",\n\t\t\toutdir,\n\t\t\t\"--watch\",\n\t\t\t\"--silent\",\n\t\t],\n\t\t{ from: \"user\" }\n\t);\n\n\texpect(compileMock).toHaveBeenCalledTimes(1);\n\texpect(compileMock).toHaveBeenCalledWith(\n\t\texpect.objectContaining({\n\t\t\toutdir,\n\t\t\tcleanOutdir: false,\n\t\t\tpreviousCompilation: {\n\t\t\t\toutputHashes: {\n\t\t\t\t\t\"runtime.js\": expect.any(String),\n\t\t\t\t},\n\t\t\t\toutput: {},\n\t\t\t},\n\t\t})\n\t);\n});\n"]}
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const initCommand: Command;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBpC,eAAO,MAAM,WAAW,SAqDrB,CAAC"}
@@ -0,0 +1,90 @@
1
+ import { Command } from "commander";
2
+ import { Logger } from "../../../services/logger/index.js";
3
+ import { findPackageJson } from "../../../services/environment/package.js";
4
+ import { checkForUncommittedChanges } from "../../steps/check-for-uncomitted-changes.js";
5
+ import { initializeMessages } from "../../steps/initialize-messages.js";
6
+ import { maybeUpdateTsConfig } from "../../steps/update-ts-config.js";
7
+ import { promptForOutdir } from "../../steps/prompt-for-outdir.js";
8
+ import { updatePackageJson } from "../../steps/update-package-json.js";
9
+ import nodeFs from "node:fs";
10
+ import { ENV_VARIABLES } from "../../../services/env-variables/index.js";
11
+ import { detectBundler } from "../../steps/detect-bundler.js";
12
+ import { addVitePlugin } from "../../steps/add-vite-plugin.js";
13
+ import { compile } from "../../../compiler/compile.js";
14
+ import { DEFAULT_BASE_LOCALE, DEFAULT_LOCALES, DEFAULT_MESSAGES, } from "../../defaults.js";
15
+ export const initCommand = new Command()
16
+ .name("init")
17
+ .summary("Initializes paraglide-lite.")
18
+ .action(async () => {
19
+ const logger = new Logger({ silent: false, prefix: false });
20
+ logger.box("Welcome to paraglide-lite");
21
+ const ctx = {
22
+ logger,
23
+ fs: nodeFs.promises,
24
+ syncFs: nodeFs,
25
+ root: process.cwd(),
26
+ };
27
+ const ctx1 = await checkForUncommittedChanges(ctx);
28
+ const ctx2 = await enforcePackageJsonExists(ctx1);
29
+ const ctx3 = await initializeMessages(ctx2);
30
+ const ctx4 = await promptForOutdir(ctx3);
31
+ const ctx5 = await addParaglideJsToDevDependencies(ctx4);
32
+ const ctx6 = await detectBundler(ctx5);
33
+ if (ctx6.bundler === "vite") {
34
+ await addVitePlugin(ctx6);
35
+ }
36
+ else {
37
+ await addCompileStepToPackageJSON(ctx6);
38
+ }
39
+ const ctx7 = await maybeUpdateTsConfig(ctx6);
40
+ try {
41
+ await compile({
42
+ messages: ctx7.messages ?? DEFAULT_MESSAGES,
43
+ locales: ctx7.locales ?? [...DEFAULT_LOCALES],
44
+ baseLocale: ctx7.baseLocale ?? DEFAULT_BASE_LOCALE,
45
+ outdir: ctx7.outdir,
46
+ });
47
+ ctx.logger.success("Ran the paraglide-lite compiler");
48
+ }
49
+ catch {
50
+ ctx.logger.warn("Failed to compile project automatically. You will need to run the compiler manually");
51
+ }
52
+ const successMessage = [
53
+ "Setup complete! Run `npm install` and then `npm run build`.",
54
+ "Unofficial fork of Paraglide JS — for most users prefer https://paraglidejs.com",
55
+ "\n",
56
+ "Repo: https://github.com/SebbeBroman/paraglide-js",
57
+ ].join("\n");
58
+ ctx.logger.box(successMessage);
59
+ process.exit(0);
60
+ });
61
+ const addParaglideJsToDevDependencies = async (ctx) => {
62
+ const ctx1 = await updatePackageJson({
63
+ devDependencies: async (devDeps) => ({
64
+ ...devDeps,
65
+ "@sebbro/paraglide-lite": `^${ENV_VARIABLES.PARJS_PACKAGE_VERSION}`,
66
+ }),
67
+ })(ctx);
68
+ ctx.logger.success("Added @sebbro/paraglide-lite to the devDependencies in package.json.");
69
+ return ctx1;
70
+ };
71
+ const enforcePackageJsonExists = async (ctx) => {
72
+ const packageJsonPath = await findPackageJson(ctx.fs, process.cwd());
73
+ if (!packageJsonPath) {
74
+ ctx.logger.warn("No package.json found. Please run this command in a project directory.");
75
+ process.exit(1);
76
+ }
77
+ return { ...ctx, packageJsonPath };
78
+ };
79
+ const addCompileStepToPackageJSON = async (ctx) => {
80
+ const localesFlag = ctx.locales.join(" ");
81
+ await updatePackageJson({
82
+ scripts: async (scripts) => ({
83
+ ...scripts,
84
+ "paraglide:compile": `paraglide-lite compile --messages '${ctx.messages}' --locales ${localesFlag} --base-locale ${ctx.baseLocale} --outdir ${ctx.outdir}`,
85
+ }),
86
+ })(ctx);
87
+ ctx.logger.success("Added paraglide:compile script to package.json.");
88
+ return ctx;
89
+ };
90
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/cli/commands/init/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,EAAE;KACtC,IAAI,CAAC,MAAM,CAAC;KACZ,OAAO,CAAC,6BAA6B,CAAC;KACtC,MAAM,CAAC,KAAK,IAAI,EAAE;IAClB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAA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AC1C,MAAM,iBAAiB,CAAC;QACvB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;YAC5B,GAAG,OAAO;YACV,mBAAmB,EAAE,sCAAsC,GAAG,CAAC,QAAQ,eAAe,WAAW,kBAAkB,GAAG,CAAC,UAAU,aAAa,GAAG,CAAC,MAAM,EAAE;SAC1J,CAAC;KACF,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,iDAAiD,CAAC,CAAC;IACtE,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport { findPackageJson } from \"../../../services/environment/package.js\";\nimport { checkForUncommittedChanges } from \"../../steps/check-for-uncomitted-changes.js\";\nimport { initializeMessages } from \"../../steps/initialize-messages.js\";\nimport { maybeUpdateTsConfig } from \"../../steps/update-ts-config.js\";\nimport { promptForOutdir } from \"../../steps/prompt-for-outdir.js\";\nimport { updatePackageJson } from \"../../steps/update-package-json.js\";\nimport type { CliStep } from \"../../utils.js\";\nimport nodeFs from \"node:fs\";\nimport { ENV_VARIABLES } from \"../../../services/env-variables/index.js\";\nimport { detectBundler } from \"../../steps/detect-bundler.js\";\nimport { addVitePlugin } from \"../../steps/add-vite-plugin.js\";\nimport { compile } from \"../../../compiler/compile.js\";\nimport {\n\tDEFAULT_BASE_LOCALE,\n\tDEFAULT_LOCALES,\n\tDEFAULT_MESSAGES,\n} from \"../../defaults.js\";\n\nexport const initCommand = new Command()\n\t.name(\"init\")\n\t.summary(\"Initializes paraglide-lite.\")\n\t.action(async () => {\n\t\tconst logger = new Logger({ silent: false, prefix: false });\n\n\t\tlogger.box(\"Welcome to paraglide-lite\");\n\n\t\tconst ctx = {\n\t\t\tlogger,\n\t\t\tfs: nodeFs.promises,\n\t\t\tsyncFs: nodeFs,\n\t\t\troot: process.cwd(),\n\t\t} as const;\n\n\t\tconst ctx1 = await checkForUncommittedChanges(ctx);\n\t\tconst ctx2 = await enforcePackageJsonExists(ctx1);\n\t\tconst ctx3 = await initializeMessages(ctx2);\n\t\tconst ctx4 = await promptForOutdir(ctx3);\n\t\tconst ctx5 = await addParaglideJsToDevDependencies(ctx4);\n\t\tconst ctx6 = await detectBundler(ctx5);\n\n\t\tif (ctx6.bundler === \"vite\") {\n\t\t\tawait addVitePlugin(ctx6);\n\t\t} else {\n\t\t\tawait addCompileStepToPackageJSON(ctx6);\n\t\t}\n\n\t\tconst ctx7 = await maybeUpdateTsConfig(ctx6);\n\n\t\ttry {\n\t\t\tawait compile({\n\t\t\t\tmessages: ctx7.messages ?? DEFAULT_MESSAGES,\n\t\t\t\tlocales: ctx7.locales ?? [...DEFAULT_LOCALES],\n\t\t\t\tbaseLocale: ctx7.baseLocale ?? DEFAULT_BASE_LOCALE,\n\t\t\t\toutdir: ctx7.outdir,\n\t\t\t});\n\t\t\tctx.logger.success(\"Ran the paraglide-lite compiler\");\n\t\t} catch {\n\t\t\tctx.logger.warn(\n\t\t\t\t\"Failed to compile project automatically. You will need to run the compiler manually\"\n\t\t\t);\n\t\t}\n\n\t\tconst successMessage = [\n\t\t\t\"Setup complete! Run `npm install` and then `npm run build`.\",\n\t\t\t\"Unofficial fork of Paraglide JS — for most users prefer https://paraglidejs.com\",\n\t\t\t\"\\n\",\n\t\t\t\"Repo: https://github.com/SebbeBroman/paraglide-js\",\n\t\t].join(\"\\n\");\n\t\tctx.logger.box(successMessage);\n\t\tprocess.exit(0);\n\t});\n\nconst addParaglideJsToDevDependencies: CliStep<\n\t{\n\t\tfs: typeof import(\"node:fs/promises\");\n\t\tlogger: Logger;\n\t\tpackageJsonPath: string;\n\t},\n\tunknown\n> = async (ctx) => {\n\tconst ctx1 = await updatePackageJson({\n\t\tdevDependencies: async (devDeps) => ({\n\t\t\t...devDeps,\n\t\t\t\"@sebbro/paraglide-lite\": `^${ENV_VARIABLES.PARJS_PACKAGE_VERSION}`,\n\t\t}),\n\t})(ctx);\n\tctx.logger.success(\n\t\t\"Added @sebbro/paraglide-lite to the devDependencies in package.json.\"\n\t);\n\treturn ctx1;\n};\n\nconst enforcePackageJsonExists: CliStep<\n\t{ logger: Logger; fs: typeof import(\"node:fs/promises\") },\n\t{ packageJsonPath: string }\n> = async (ctx) => {\n\tconst packageJsonPath = await findPackageJson(ctx.fs, process.cwd());\n\tif (!packageJsonPath) {\n\t\tctx.logger.warn(\n\t\t\t\"No package.json found. Please run this command in a project directory.\"\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\treturn { ...ctx, packageJsonPath };\n};\n\nconst addCompileStepToPackageJSON: CliStep<\n\t{\n\t\tfs: typeof import(\"node:fs/promises\");\n\t\tlogger: Logger;\n\t\tpackageJsonPath: string;\n\t\toutdir: string;\n\t\tmessages: string;\n\t\tlocales: string[];\n\t\tbaseLocale: string;\n\t},\n\tunknown\n> = async (ctx) => {\n\tconst localesFlag = ctx.locales.join(\" \");\n\tawait updatePackageJson({\n\t\tscripts: async (scripts) => ({\n\t\t\t...scripts,\n\t\t\t\"paraglide:compile\": `paraglide-lite compile --messages '${ctx.messages}' --locales ${localesFlag} --base-locale ${ctx.baseLocale} --outdir ${ctx.outdir}`,\n\t\t}),\n\t})(ctx);\n\tctx.logger.success(\"Added paraglide:compile script to package.json.\");\n\treturn ctx;\n};\n"]}
@@ -0,0 +1,11 @@
1
+ export declare const DEFAULT_MESSAGES = "./messages/{locale}.json";
2
+ export declare const DEFAULT_LOCALES: readonly ["en", "de"];
3
+ export declare const DEFAULT_BASE_LOCALE = "en";
4
+ export declare const DEFAULT_OUTDIR = "./src/paraglide";
5
+ export type ParaglideDefaults = {
6
+ messages: string;
7
+ locales: string[];
8
+ baseLocale: string;
9
+ outdir: string;
10
+ };
11
+ export declare function getDefaultParaglideConfig(): ParaglideDefaults;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAC3D,eAAO,MAAM,eAAe,YAAI,IAAI,EAAE,IAAI,CAAU,CAAC;AACrD,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,iBAAiB,CAO7D"}
@@ -0,0 +1,13 @@
1
+ export const DEFAULT_MESSAGES = "./messages/{locale}.json";
2
+ export const DEFAULT_LOCALES = ["en", "de"];
3
+ export const DEFAULT_BASE_LOCALE = "en";
4
+ export const DEFAULT_OUTDIR = "./src/paraglide";
5
+ export function getDefaultParaglideConfig() {
6
+ return {
7
+ messages: DEFAULT_MESSAGES,
8
+ locales: [...DEFAULT_LOCALES],
9
+ baseLocale: DEFAULT_BASE_LOCALE,
10
+ outdir: DEFAULT_OUTDIR,
11
+ };
12
+ }
13
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAShD,MAAM,UAAU,yBAAyB;IACxC,OAAO;QACN,QAAQ,EAAE,gBAAgB;QAC1B,OAAO,EAAE,CAAC,GAAG,eAAe,CAAC;QAC7B,UAAU,EAAE,mBAAmB;QAC/B,MAAM,EAAE,cAAc;KACtB,CAAC;AACH,CAAC","sourcesContent":["export const DEFAULT_MESSAGES = \"./messages/{locale}.json\";\nexport const DEFAULT_LOCALES = [\"en\", \"de\"] as const;\nexport const DEFAULT_BASE_LOCALE = \"en\";\nexport const DEFAULT_OUTDIR = \"./src/paraglide\";\n\nexport type ParaglideDefaults = {\n\tmessages: string;\n\tlocales: string[];\n\tbaseLocale: string;\n\toutdir: string;\n};\n\nexport function getDefaultParaglideConfig(): ParaglideDefaults {\n\treturn {\n\t\tmessages: DEFAULT_MESSAGES,\n\t\tlocales: [...DEFAULT_LOCALES],\n\t\tbaseLocale: DEFAULT_BASE_LOCALE,\n\t\toutdir: DEFAULT_OUTDIR,\n\t};\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const cli: Command;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,GAAG,SAK8B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Command } from "commander";
2
+ import { compileCommand } from "./commands/compile/command.js";
3
+ import { ENV_VARIABLES } from "../services/env-variables/index.js";
4
+ import { initCommand } from "./commands/init/command.js";
5
+ export const cli = new Command()
6
+ .name("paraglide-lite")
7
+ .addCommand(compileCommand)
8
+ .addCommand(initCommand)
9
+ .showHelpAfterError()
10
+ .version(ENV_VARIABLES.PARJS_PACKAGE_VERSION);
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,OAAO,EAAE;KAC9B,IAAI,CAAC,gBAAgB,CAAC;KACtB,UAAU,CAAC,cAAc,CAAC;KAC1B,UAAU,CAAC,WAAW,CAAC;KACvB,kBAAkB,EAAE;KACpB,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { compileCommand } from \"./commands/compile/command.js\";\nimport { ENV_VARIABLES } from \"../services/env-variables/index.js\";\nimport { initCommand } from \"./commands/init/command.js\";\n\nexport const cli = new Command()\n\t.name(\"paraglide-lite\")\n\t.addCommand(compileCommand)\n\t.addCommand(initCommand)\n\t.showHelpAfterError()\n\t.version(ENV_VARIABLES.PARJS_PACKAGE_VERSION);\n"]}
@@ -0,0 +1,31 @@
1
+ import type { Logger } from "../../services/logger/index.js";
2
+ import type { CliStep } from "../utils.js";
3
+ export declare const addVitePlugin: CliStep<{
4
+ fs: typeof import("node:fs/promises");
5
+ messages: string;
6
+ locales: string[];
7
+ baseLocale: string;
8
+ outdir: string;
9
+ logger?: Logger;
10
+ configPath: string;
11
+ }, unknown>;
12
+ type UpdateResult = {
13
+ ok: true;
14
+ updated: string;
15
+ reason?: undefined;
16
+ } | {
17
+ ok: false;
18
+ reason: string;
19
+ updated?: undefined;
20
+ };
21
+ /**
22
+ * @private Only exported for testings
23
+ */
24
+ export declare function updateViteConfig(args: {
25
+ config: string;
26
+ messages: string;
27
+ locales: string[];
28
+ baseLocale: string;
29
+ outdir: string;
30
+ }): UpdateResult;
31
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-vite-plugin.d.ts","sourceRoot":"","sources":["../../../src/cli/steps/add-vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,eAAO,MAAM,aAAa,EAAE,OAAO,CAClC;IACC,EAAE,EAAE,cAAc,kBAAkB,CAAC,CAAC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB,EACD,OAAO,CAsCP,CAAC;AAEF,KAAK,YAAY,GACd;IACA,EAAE,EAAE,IAAI,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;CAClB,GACD;IACA,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEL;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CACf,GAAG,YAAY,CAiCf"}
@@ -0,0 +1,65 @@
1
+ export const addVitePlugin = async (ctx) => {
2
+ try {
3
+ const fileContent = await ctx.fs.readFile(ctx.configPath, {
4
+ encoding: "utf-8",
5
+ });
6
+ const result = updateViteConfig({
7
+ config: fileContent,
8
+ messages: ctx.messages,
9
+ locales: ctx.locales,
10
+ baseLocale: ctx.baseLocale,
11
+ outdir: ctx.outdir,
12
+ });
13
+ if (result.ok) {
14
+ await ctx.fs.writeFile(ctx.configPath, result.updated);
15
+ ctx.logger?.success("Added the paraglide-lite vite plugin to the vite config.");
16
+ }
17
+ else {
18
+ const msg = [
19
+ "Failed to add the paraglide-lite vite plugin in vite.config.js.",
20
+ "Reason: " + result.reason,
21
+ "",
22
+ "Please add the plugin manually.",
23
+ ].join("\n");
24
+ ctx.logger?.warn(msg);
25
+ return ctx;
26
+ }
27
+ }
28
+ catch {
29
+ ctx.logger?.error(`Failed to add the paraglide-lite vite plugin to ${ctx.configPath}.`);
30
+ process.exit(1);
31
+ }
32
+ return ctx;
33
+ };
34
+ /**
35
+ * @private Only exported for testings
36
+ */
37
+ export function updateViteConfig(args) {
38
+ if (args.config.includes("@sebbro/paraglide-lite")) {
39
+ return {
40
+ ok: false,
41
+ reason: "Already present",
42
+ };
43
+ }
44
+ const PLUGINS_REGEX = /plugins\s*:\s*\[/g;
45
+ const match = PLUGINS_REGEX.exec(args.config);
46
+ if (!match) {
47
+ return {
48
+ ok: false,
49
+ reason: "Could not find the plugins array",
50
+ };
51
+ }
52
+ const endIndex = match.index + match[0].length;
53
+ const before = args.config.slice(0, endIndex);
54
+ const after = args.config.slice(endIndex);
55
+ const localesLiteral = JSON.stringify(args.locales);
56
+ const updatedConfig = "import { paraglideVitePlugin } from '@sebbro/paraglide-lite'\n" +
57
+ before +
58
+ `paraglideVitePlugin({ messages: '${args.messages}', locales: ${localesLiteral}, baseLocale: '${args.baseLocale}', outdir: '${args.outdir}' }),` +
59
+ after;
60
+ return {
61
+ ok: true,
62
+ updated: updatedConfig,
63
+ };
64
+ }
65
+ //# sourceMappingURL=add-vite-plugin.js.map