@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,1709 @@
1
+ import { expect, test, describe, vi, beforeEach } from "vitest";
2
+ import { createProject as typescriptProject, ts, } from "@ts-morph/bootstrap";
3
+ import { createBundleNested, defaultTestSettings } from "./test-helpers.js";
4
+ import { compileProject, getFallbackMap } from "./compile-project.js";
5
+ import virtual from "@rollup/plugin-virtual";
6
+ import { rolldown } from "rolldown";
7
+ import { perLocaleBuildStaticLocaleExpression } from "./per-locale-build.js";
8
+ beforeEach(() => {
9
+ // reset the imports to make sure that the runtime is reloaded
10
+ vi.resetModules();
11
+ vi.clearAllMocks();
12
+ // mocking DOM globals
13
+ // @ts-expect-error - global variable definition
14
+ globalThis.window = undefined;
15
+ });
16
+ function hasFallbackCycle(fallbackMap, start) {
17
+ const visited = new Set();
18
+ let current = start;
19
+ while (current) {
20
+ if (visited.has(current))
21
+ return true;
22
+ visited.add(current);
23
+ current = fallbackMap[current];
24
+ }
25
+ return false;
26
+ }
27
+ test("emitGitignore", async () => {
28
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
29
+ const bundles = [];
30
+ const _default = await compileProject({ bundles, settings });
31
+ const _true = await compileProject({ bundles, settings, compilerOptions: { emitGitIgnore: true },
32
+ });
33
+ const _false = await compileProject({ bundles, settings, compilerOptions: { emitGitIgnore: false },
34
+ });
35
+ expect(_default).toHaveProperty(".gitignore");
36
+ expect(_true).toHaveProperty(".gitignore");
37
+ expect(_false).not.toHaveProperty(".gitignore");
38
+ });
39
+ test("marks tree-shakeable generated message layouts as side-effect-free", async () => {
40
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
41
+ const bundles = [];
42
+ const messageModules = await compileProject({ bundles, settings });
43
+ const localeModules = await compileProject({ bundles, settings, compilerOptions: { outputStructure: "locale-modules" },
44
+ });
45
+ const specializedLocaleModules = await compileProject({ bundles, settings, compilerOptions: {
46
+ outputStructure: "locale-modules",
47
+ experimentalStaticLocale: perLocaleBuildStaticLocaleExpression,
48
+ },
49
+ });
50
+ // message-modules: the message modules are side-effect-free, so bundlers can
51
+ // drop unused re-exports from the `m` barrel per entry instead of emitting one
52
+ // shared chunk with every message. `type: "module"` keeps the generated ESM
53
+ // files in the new `messages/` package scope from defaulting to CommonJS.
54
+ expect(messageModules).toHaveProperty("messages/package.json");
55
+ expect(JSON.parse(messageModules["messages/package.json"])).toEqual({
56
+ type: "module",
57
+ sideEffects: false,
58
+ });
59
+ expect(localeModules).not.toHaveProperty("messages/package.json");
60
+ expect(specializedLocaleModules).toHaveProperty("messages/package.json");
61
+ expect(JSON.parse(specializedLocaleModules["messages/package.json"])).toEqual({
62
+ type: "module",
63
+ sideEffects: false,
64
+ });
65
+ });
66
+ test("emitPrettierIgnore", async () => {
67
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
68
+ const bundles = [];
69
+ const _default = await compileProject({ bundles, settings });
70
+ const _true = await compileProject({ bundles, settings, compilerOptions: { emitPrettierIgnore: true },
71
+ });
72
+ const _false = await compileProject({ bundles, settings, compilerOptions: { emitPrettierIgnore: false },
73
+ });
74
+ expect(_default).toHaveProperty(".prettierignore");
75
+ expect(_true).toHaveProperty(".prettierignore");
76
+ expect(_false).not.toHaveProperty(".prettierignore");
77
+ });
78
+ test("emitReadme", async () => {
79
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
80
+ const bundles = [];
81
+ const projectPath = "./project.inlang";
82
+ const _default = await compileProject({
83
+ bundles,
84
+ settings,
85
+ sourceLabel: projectPath,
86
+ });
87
+ const _true = await compileProject({
88
+ bundles,
89
+ settings,
90
+ sourceLabel: projectPath,
91
+ compilerOptions: { emitReadme: true },
92
+ });
93
+ const _false = await compileProject({
94
+ bundles,
95
+ settings,
96
+ sourceLabel: projectPath,
97
+ compilerOptions: { emitReadme: false },
98
+ });
99
+ const _noProjectPath = await compileProject({ bundles, settings });
100
+ expect(_default).toHaveProperty("README.md");
101
+ expect(_true).toHaveProperty("README.md");
102
+ expect(_false).not.toHaveProperty("README.md");
103
+ // README should still be emitted even without projectPath
104
+ expect(_noProjectPath).toHaveProperty("README.md");
105
+ // but should not contain the "Compiled from:" line
106
+ expect(_noProjectPath["README.md"]).not.toContain("Compiled from:");
107
+ });
108
+ test("emitReadme includes project path", async () => {
109
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
110
+ const bundles = [];
111
+ const projectPath = "./my-custom-project.inlang";
112
+ const output = await compileProject({ bundles, settings, sourceLabel: projectPath });
113
+ expect(output["README.md"]).toContain(projectPath);
114
+ expect(output["README.md"]).toContain("Compiled from:");
115
+ expect(output["README.md"]).toContain("Paraglide JS");
116
+ });
117
+ test("throws during compile for invalid routeStrategies match patterns", async () => {
118
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
119
+ const bundles = [];
120
+ await expect(compileProject({ bundles, settings, compilerOptions: {
121
+ routeStrategies: [{ match: "/api/:path(.*", exclude: true }],
122
+ },
123
+ })).rejects.toThrow(`Invalid routeStrategies[0].match "/api/:path(.*"`);
124
+ });
125
+ // https://github.com/opral/paraglide-js/issues/539
126
+ test("omits async_hooks import when disableAsyncLocalStorage is true", async () => {
127
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
128
+ const bundles = [];
129
+ const output = await compileProject({ bundles, settings, compilerOptions: { disableAsyncLocalStorage: true },
130
+ });
131
+ expect(output["server.js"]).not.toContain('const { AsyncLocalStorage } = await import("node:async_hooks");');
132
+ });
133
+ // https://github.com/opral/paraglide-js/issues/544
134
+ test("fallback map should not create cycles for language-only + regional baseLocale", () => {
135
+ const fallbackMap = getFallbackMap(["it", "it-IT", "fr", "fr-FR"], "it-IT");
136
+ expect(hasFallbackCycle(fallbackMap, "it")).toBe(false);
137
+ expect(hasFallbackCycle(fallbackMap, "it-IT")).toBe(false);
138
+ expect(fallbackMap["it"]).toBe("it-IT");
139
+ expect(fallbackMap["it-IT"]).toBeUndefined();
140
+ });
141
+ test("emitTsDeclarations generates declaration files", async () => {
142
+ const output = await compileProject({ bundles, settings, compilerOptions: {
143
+ emitTsDeclarations: true,
144
+ outputStructure: "locale-modules",
145
+ },
146
+ });
147
+ expect(output).toHaveProperty("messages/_index.d.ts");
148
+ expect(output).toHaveProperty("messages.d.ts");
149
+ expect(output).toHaveProperty("registry.d.ts");
150
+ expect(output["messages/_index.d.ts"]).toContain("sad_penguin_bundle");
151
+ expect(output["messages/_index.d.ts"]).toContain("relative_time_dynamic");
152
+ expect(output["registry.d.ts"]).toContain("RelativeTimeFormatUnit");
153
+ expect(output["registry.d.ts"]).toContain("relativetime");
154
+ const tsProject = await typescriptProject({
155
+ useInMemoryFileSystem: true,
156
+ compilerOptions: {
157
+ module: ts.ModuleKind.Node16,
158
+ moduleResolution: ts.ModuleResolutionKind.Node16,
159
+ strict: true,
160
+ },
161
+ });
162
+ for (const [fileName, code] of Object.entries(output)) {
163
+ if (fileName.endsWith(".d.ts")) {
164
+ tsProject.createSourceFile(fileName, code);
165
+ }
166
+ }
167
+ tsProject.createSourceFile("test.ts", `
168
+ import { m, relative_time_dynamic } from "./messages.js";
169
+ import { relativetime } from "./registry.js";
170
+
171
+ m.sad_penguin_bundle() satisfies string;
172
+ relative_time_dynamic({ duration: -3, unit: "hour" }) satisfies string;
173
+ relativetime("en", -3, { unit: "hour", style: "short" }) satisfies string;
174
+ `);
175
+ const program = tsProject.createProgram();
176
+ const diagnostics = ts.getPreEmitDiagnostics(program).filter((d) => {
177
+ const text = d.messageText.toString();
178
+ return (!text.includes("Cannot find name 'URLPattern'") &&
179
+ !text.includes("Type 'string' is not assignable to type"));
180
+ });
181
+ for (const diagnostic of diagnostics) {
182
+ console.error(diagnostic.messageText, diagnostic.file?.fileName);
183
+ }
184
+ expect(diagnostics.length).toEqual(0);
185
+ });
186
+ test("emitTsDeclarations remains opt-in", async () => {
187
+ const output = await compileProject({ bundles: [], settings: defaultTestSettings });
188
+ expect(Object.keys(output).some((fileName) => fileName.endsWith(".d.ts"))).toBe(false);
189
+ });
190
+ test("emitTsDeclarations quotes unsafe export aliases", async () => {
191
+ const settings = { locales: ["en"], baseLocale: "en" };
192
+ const bundles = [];
193
+ bundles.push(createBundleNested({
194
+ id: "greeting.hello",
195
+ messages: [
196
+ {
197
+ locale: "en",
198
+ variants: [{ pattern: [{ type: "text", value: "Hello" }] }],
199
+ },
200
+ ],
201
+ }));
202
+ for (const outputStructure of [
203
+ "message-modules",
204
+ "locale-modules",
205
+ ]) {
206
+ const output = await compileProject({ bundles, settings, compilerOptions: {
207
+ emitTsDeclarations: true,
208
+ outputStructure,
209
+ },
210
+ });
211
+ const declarationFile = outputStructure === "message-modules"
212
+ ? "messages/greeting_hello.d.ts"
213
+ : "messages/_index.d.ts";
214
+ expect(output[declarationFile]).toContain(`export { greeting_hello as "greeting.hello" };`);
215
+ const tsProject = await typescriptProject({
216
+ useInMemoryFileSystem: true,
217
+ compilerOptions: {
218
+ module: ts.ModuleKind.Node16,
219
+ moduleResolution: ts.ModuleResolutionKind.Node16,
220
+ strict: true,
221
+ },
222
+ });
223
+ for (const [fileName, code] of Object.entries(output)) {
224
+ if (fileName.endsWith(".d.ts")) {
225
+ tsProject.createSourceFile(fileName, code);
226
+ }
227
+ }
228
+ tsProject.createSourceFile("test.ts", `
229
+ import { "greeting.hello" as greetingHello } from "./messages.js";
230
+
231
+ greetingHello() satisfies string;
232
+ `);
233
+ const program = tsProject.createProgram();
234
+ const diagnostics = ts.getPreEmitDiagnostics(program).filter((d) => {
235
+ return !d.messageText.toString().includes("Cannot find name 'URLPattern'");
236
+ });
237
+ for (const diagnostic of diagnostics) {
238
+ console.error(diagnostic.messageText, diagnostic.file?.fileName);
239
+ }
240
+ expect(diagnostics.length).toEqual(0);
241
+ }
242
+ });
243
+ test("handles message bundles with a : in the id", async () => {
244
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
245
+ const bundles = [];
246
+ bundles.push(createBundleNested({
247
+ id: "hello:world",
248
+ messages: [
249
+ {
250
+ locale: "en",
251
+ variants: [{ pattern: [{ type: "text", value: "Hello world!" }] }],
252
+ },
253
+ ],
254
+ }));
255
+ const output = await compileProject({ bundles, settings });
256
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
257
+ export * as runtime from "./paraglide/runtime.js"`);
258
+ const { m } = await importCode(code);
259
+ expect(m["hello:world"]()).toBe("Hello world!");
260
+ });
261
+ test("emits .parts() on bundle functions for markup messages", async () => {
262
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
263
+ const bundles = [];
264
+ bundles.push(createBundleNested({
265
+ id: "balance",
266
+ declarations: [
267
+ {
268
+ type: "input-variable",
269
+ name: "amount",
270
+ },
271
+ ],
272
+ messages: [
273
+ {
274
+ locale: "en",
275
+ variants: [
276
+ {
277
+ pattern: [
278
+ { type: "text", value: "You have " },
279
+ {
280
+ type: "markup-start",
281
+ name: "strong",
282
+ options: [],
283
+ attributes: [],
284
+ },
285
+ {
286
+ type: "expression",
287
+ arg: { type: "variable-reference", name: "amount" },
288
+ },
289
+ { type: "text", value: " coins" },
290
+ {
291
+ type: "markup-end",
292
+ name: "strong",
293
+ options: [],
294
+ attributes: [],
295
+ },
296
+ { type: "text", value: "." },
297
+ ],
298
+ },
299
+ ],
300
+ },
301
+ ],
302
+ }));
303
+ const output = await compileProject({ bundles, settings });
304
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
305
+ export * as runtime from "./paraglide/runtime.js"`);
306
+ const { m } = await importCode(code);
307
+ expect(m.balance({ amount: 7 }, { locale: "en" })).toBe("You have 7 coins.");
308
+ expect(m.balance.parts({ amount: 7 }, { locale: "en" })).toEqual([
309
+ { type: "text", value: "You have " },
310
+ { type: "markup-start", name: "strong", options: {}, attributes: {} },
311
+ { type: "text", value: "7" },
312
+ { type: "text", value: " coins" },
313
+ { type: "markup-end", name: "strong", options: {}, attributes: {} },
314
+ { type: "text", value: "." },
315
+ ]);
316
+ });
317
+ // https://github.com/opral/inlang-paraglide-js/issues/347
318
+ test("can emit message bundles with more than 255 characters", async () => {
319
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
320
+ const bundles = [];
321
+ bundles.push(createBundleNested({
322
+ // 300 characters long id
323
+ id: "a".repeat(300),
324
+ messages: [
325
+ {
326
+ locale: "en",
327
+ variants: [
328
+ {
329
+ pattern: [{ type: "text", value: "Hello" }],
330
+ },
331
+ ],
332
+ },
333
+ ],
334
+ }));
335
+ const output = await compileProject({ bundles, settings, compilerOptions: {
336
+ urlPatterns: [],
337
+ },
338
+ });
339
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
340
+ export * as runtime from "./paraglide/runtime.js"`);
341
+ const { m } = await importCode(code);
342
+ expect(m["a".repeat(300)]()).toBe("Hello");
343
+ });
344
+ describe.each([
345
+ // useTsImports must be true to test emitTs. Otherwise, rolldown can't resolve the imports
346
+ {
347
+ outputStructure: "locale-modules",
348
+ strategy: ["globalVariable", "baseLocale"],
349
+ },
350
+ {
351
+ outputStructure: "message-modules",
352
+ strategy: ["globalVariable", "baseLocale"],
353
+ },
354
+ ])("options", async (compilerOptions) => {
355
+ const output = await compileProject({ bundles, settings, compilerOptions });
356
+ describe("tree-shaking", () => {
357
+ test("should tree-shake unused messages", async () => {
358
+ const code = await bundleCode(output, `import * as m from "./paraglide/messages.js"
359
+
360
+ console.log(m.sad_penguin_bundle())`);
361
+ const log = vi.spyOn(console, "log").mockImplementation(() => { });
362
+ // all required code for the message to be rendered is included like sourceLanguageTag.
363
+ // but, all other messages except of 'sad_penguin_bundle' are tree-shaken away.
364
+ for (const { id } of bundles) {
365
+ if (id === "sad_penguin_bundle") {
366
+ expect(code).toContain(id);
367
+ }
368
+ else {
369
+ expect(code).not.toContain(id);
370
+ }
371
+ }
372
+ eval(code);
373
+ expect(log).toHaveBeenCalledWith("A simple message.");
374
+ });
375
+ // https://github.com/opral/inlang-paraglide-js/issues/345
376
+ test("importing { m } works and tree-shakes unused messages", async () => {
377
+ const code = await bundleCode(output, `import { m } from "./paraglide/messages.js"
378
+ console.log(m.sad_penguin_bundle())`);
379
+ const log = vi.spyOn(console, "log").mockImplementation(() => { });
380
+ // all required code for the message to be rendered is included like sourceLanguageTag.
381
+ // but, all other messages except of 'sad_penguin_bundle' are tree-shaken away.
382
+ for (const { id } of bundles) {
383
+ if (id === "sad_penguin_bundle") {
384
+ expect(code).toContain(id);
385
+ }
386
+ else {
387
+ expect(code).not.toContain(id);
388
+ }
389
+ }
390
+ eval(code);
391
+ expect(log).toHaveBeenCalledWith("A simple message.");
392
+ });
393
+ test("should not treeshake messages that are used", async () => {
394
+ const code = await bundleCode(output, `import * as m from "./paraglide/messages.js"
395
+
396
+ console.log(
397
+ m.sad_penguin_bundle(),
398
+ m.depressed_dog({ name: "Samuel" }),
399
+ m.insane_cats({ name: "Samuel", count: 5 })
400
+ )`);
401
+ const log = vi.spyOn(console, "log").mockImplementation(() => { });
402
+ for (const id of bundles.map((m) => m.id)) {
403
+ if (["sad_penguin_bundle", "depressed_dog", "insane_cats"].includes(id)) {
404
+ expect(code).toContain(id);
405
+ }
406
+ else {
407
+ expect(code).not.toContain(id);
408
+ }
409
+ }
410
+ eval(code);
411
+ expect(log).toHaveBeenCalledWith("A simple message.", "Good morning Samuel!", "Hello Samuel! You have 5 messages.");
412
+ });
413
+ });
414
+ // https://github.com/opral/inlang-paraglide-js/issues/379
415
+ test("plurals work", async () => {
416
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
417
+ const bundles = [];
418
+ bundles.push(createBundleNested({
419
+ id: "plural_test",
420
+ declarations: [
421
+ { type: "input-variable", name: "count" },
422
+ {
423
+ type: "local-variable",
424
+ name: "countPlural",
425
+ value: {
426
+ arg: { type: "variable-reference", name: "count" },
427
+ annotation: {
428
+ type: "function-reference",
429
+ name: "plural",
430
+ options: [],
431
+ },
432
+ type: "expression",
433
+ },
434
+ },
435
+ ],
436
+ messages: [
437
+ {
438
+ locale: "en",
439
+ selectors: [{ type: "variable-reference", name: "countPlural" }],
440
+ variants: [
441
+ {
442
+ matches: [
443
+ { type: "literal-match", value: "one", key: "countPlural" },
444
+ ],
445
+ pattern: [{ type: "text", value: "There is one cat." }],
446
+ },
447
+ {
448
+ matches: [
449
+ {
450
+ type: "literal-match",
451
+ value: "other",
452
+ key: "countPlural",
453
+ },
454
+ ],
455
+ pattern: [{ type: "text", value: "There are many cats." }],
456
+ },
457
+ ],
458
+ },
459
+ ],
460
+ }));
461
+ const { m } = await importCode(await bundleCode(await compileProject({ bundles, settings, compilerOptions }), `export * as m from "./paraglide/messages.js"`));
462
+ expect(m.plural_test({ count: 1 })).toBe("There is one cat.");
463
+ expect(m.plural_test({ count: 2 })).toBe("There are many cats.");
464
+ });
465
+ describe("e2e", async () => {
466
+ // The compiled output needs to be bundled into one file to be dynamically imported.
467
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
468
+ export * as runtime from "./paraglide/runtime.js"`);
469
+ // test is a direct result of a bug
470
+ test("locales should include locales with a hyphen", async () => {
471
+ const { runtime } = await importCode(code);
472
+ expect(runtime.locales).toContain("en-US");
473
+ });
474
+ test("should set the baseLocale as default getLocale value", async () => {
475
+ const { runtime } = await importCode(code);
476
+ expect(runtime.getLocale()).toBe(runtime.baseLocale);
477
+ });
478
+ test("should return the correct message for the current locale", async () => {
479
+ const { m, runtime } = await importCode(code);
480
+ console.log(m);
481
+ runtime.setLocale("en");
482
+ expect(m.sad_penguin_bundle()).toBe("A simple message.");
483
+ runtime.setLocale("de");
484
+ expect(m.sad_penguin_bundle()).toBe("Eine einfache Nachricht.");
485
+ });
486
+ test("overwriteGetLocale() works", async () => {
487
+ const { m, runtime } = await importCode(code);
488
+ let locale = "en";
489
+ runtime.overwriteGetLocale(() => locale);
490
+ expect(m.sad_penguin_bundle()).toBe("A simple message.");
491
+ locale = "de";
492
+ expect(m.sad_penguin_bundle()).toBe("Eine einfache Nachricht.");
493
+ });
494
+ test("overwriteSetLocale() works", async () => {
495
+ const { runtime } = await importCode(code);
496
+ let locale = "en";
497
+ runtime.overwriteSetLocale((newLocale) => {
498
+ locale = newLocale;
499
+ });
500
+ runtime.setLocale("de");
501
+ expect(locale).toBe("de");
502
+ });
503
+ test.skip("defining onSetLocale should be possible and should be called when the locale changes", async () => {
504
+ const { runtime } = await importCode(code);
505
+ const mockOnSetLocale = vi.fn().mockImplementation(() => { });
506
+ runtime.onSetLocale((locale) => {
507
+ mockOnSetLocale(locale);
508
+ });
509
+ runtime.setLocale("de");
510
+ expect(mockOnSetLocale).toHaveBeenLastCalledWith("de");
511
+ runtime.setLocale("en");
512
+ expect(mockOnSetLocale).toHaveBeenLastCalledWith("en");
513
+ expect(mockOnSetLocale).toHaveBeenCalledTimes(2);
514
+ });
515
+ test.skip("Calling onSetLocale() multiple times should override the previous callback", async () => {
516
+ const cb1 = vi.fn().mockImplementation(() => { });
517
+ const cb2 = vi.fn().mockImplementation(() => { });
518
+ const { runtime } = await importCode(code);
519
+ runtime.onSetLocale(cb1);
520
+ runtime.setLocale("en");
521
+ expect(cb1).toHaveBeenCalledTimes(1);
522
+ runtime.onSetLocale(cb2);
523
+ runtime.setLocale("de");
524
+ expect(cb2).toHaveBeenCalledTimes(1);
525
+ expect(cb1).toHaveBeenCalledTimes(1);
526
+ });
527
+ test("should return the correct message if a locale is set in the message options", async () => {
528
+ const { m, runtime } = await importCode(code);
529
+ // set the language tag to de to make sure that the message options override the runtime language tag
530
+ runtime.setLocale("de");
531
+ expect(m.sad_penguin_bundle()).toBe("Eine einfache Nachricht.");
532
+ expect(m.sad_penguin_bundle(undefined, { locale: "en" })).toBe("A simple message.");
533
+ });
534
+ test("relativetime formatter works with literal units and locale overrides", async () => {
535
+ const { m, runtime } = await importCode(code);
536
+ runtime.setLocale("de");
537
+ expect(m.relative_time_literal({ duration: -1 })).toBe("Updated gestern.");
538
+ expect(m.relative_time_literal({ duration: -1 }, { locale: "en" })).toBe("Updated yesterday.");
539
+ });
540
+ test("relativetime formatter works with dynamic units", async () => {
541
+ const { m, runtime } = await importCode(code);
542
+ runtime.setLocale("en");
543
+ expect(m.relative_time_dynamic({ duration: -3, unit: "hour" })).toBe("Updated 3 hr. ago.");
544
+ runtime.setLocale("de");
545
+ expect(m.relative_time_dynamic({ duration: 2, unit: "weeks" })).toBe("Updated in 2 Wochen.");
546
+ });
547
+ test("runtime.isLocale should only return `true` if a locale is passed to it", async () => {
548
+ const { runtime } = await importCode(code);
549
+ for (const tag of runtime.locales) {
550
+ expect(runtime.isLocale(tag)).toBe(true);
551
+ }
552
+ expect(runtime.isLocale("")).toBe(false);
553
+ expect(runtime.isLocale("pl")).toBe(false);
554
+ expect(runtime.isLocale("--")).toBe(false);
555
+ });
556
+ test("falls back to base locale", async () => {
557
+ const settings = { locales: ["en", "de", "en-US"], baseLocale: "en" };
558
+ const bundles = [];
559
+ bundles.push(createBundleNested({
560
+ id: "missingInGerman",
561
+ messages: [
562
+ {
563
+ locale: "en",
564
+ variants: [
565
+ { pattern: [{ type: "text", value: "A simple message." }] },
566
+ ],
567
+ },
568
+ ],
569
+ }));
570
+ const output = await compileProject({ bundles, settings, compilerOptions });
571
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
572
+ export * as runtime from "./paraglide/runtime.js"`);
573
+ const { m, runtime } = await importCode(code);
574
+ runtime.setLocale("de");
575
+ expect(m.missingInGerman()).toBe("A simple message.");
576
+ runtime.setLocale("en-US");
577
+ expect(m.missingInGerman()).toBe("A simple message.");
578
+ });
579
+ test("arbitrary module identifiers work", async () => {
580
+ const settings = { locales: ["en", "de"], baseLocale: "en" };
581
+ const bundles = [];
582
+ bundles.push(createBundleNested({
583
+ id: "$502.23-hello_world",
584
+ messages: [
585
+ {
586
+ locale: "en",
587
+ variants: [
588
+ { pattern: [{ type: "text", value: "A simple message." }] },
589
+ ],
590
+ },
591
+ ],
592
+ }));
593
+ const output = await compileProject({ bundles, settings, compilerOptions });
594
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
595
+ export * as runtime from "./paraglide/runtime.js"`);
596
+ const { m } = await importCode(code);
597
+ expect(m["$502.23-hello_world"]()).toBe("A simple message.");
598
+ });
599
+ test("falls back to parent locale if message doesn't exist", async () => {
600
+ const settings = { locales: ["en", "en-US"], baseLocale: "en" };
601
+ const bundles = [];
602
+ bundles.push(createBundleNested({
603
+ id: "exists_in_both",
604
+ messages: [
605
+ {
606
+ locale: "en",
607
+ variants: [
608
+ { pattern: [{ type: "text", value: "A simple message." }] },
609
+ ],
610
+ },
611
+ {
612
+ locale: "en-US",
613
+ variants: [
614
+ {
615
+ pattern: [
616
+ {
617
+ type: "text",
618
+ value: "A simple message for Americans.",
619
+ },
620
+ ],
621
+ },
622
+ ],
623
+ },
624
+ ],
625
+ }));
626
+ bundles.push(createBundleNested({
627
+ id: "missing_in_en_US",
628
+ messages: [
629
+ {
630
+ locale: "en",
631
+ variants: [
632
+ { pattern: [{ type: "text", value: "Fallback message." }] },
633
+ ],
634
+ },
635
+ ],
636
+ }));
637
+ const output = await compileProject({ bundles, settings, compilerOptions });
638
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
639
+ export * as runtime from "./paraglide/runtime.js"`);
640
+ const { m, runtime } = await importCode(code);
641
+ runtime.setLocale("en-US");
642
+ expect(m.exists_in_both()).toBe("A simple message for Americans.");
643
+ runtime.setLocale("en-US");
644
+ expect(m.missing_in_en_US()).toBe("Fallback message.");
645
+ });
646
+ test("arbitrary module identifiers", async () => {
647
+ const settings = { locales: ["en"], baseLocale: "en" };
648
+ const bundles = [];
649
+ bundles.push(createBundleNested({
650
+ id: "happy🍌",
651
+ messages: [
652
+ {
653
+ locale: "en",
654
+ variants: [{ pattern: [{ type: "text", value: "Hello" }] }],
655
+ },
656
+ ],
657
+ }));
658
+ const output = await compileProject({ bundles, settings, compilerOptions });
659
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
660
+ export * as runtime from "./paraglide/runtime.js"`);
661
+ const { m } = await importCode(code);
662
+ expect(m["happy🍌"]()).toBe("Hello");
663
+ });
664
+ });
665
+ test("relativetime dynamic unit casts generated options without narrowing public inputs", () => {
666
+ const relativeTimeDynamicFile = compilerOptions.outputStructure === "locale-modules"
667
+ ? "messages/en.js"
668
+ : "messages/relative_time_dynamic.js";
669
+ expect(output).toHaveProperty(relativeTimeDynamicFile);
670
+ const relativeTimeDynamicModule = output[relativeTimeDynamicFile];
671
+ expect(relativeTimeDynamicModule).toContain('unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit)');
672
+ expect(relativeTimeDynamicModule).toContain("{ duration: NonNullable<unknown>, unit: NonNullable<unknown> }");
673
+ });
674
+ test("case sensitivity handling for bundle IDs", async () => {
675
+ const settings = { locales: ["en"], baseLocale: "en" };
676
+ const bundles = [];
677
+ // Create two bundles with the same name but different case
678
+ bundles.push(createBundleNested({
679
+ id: "Helloworld",
680
+ messages: [
681
+ {
682
+ locale: "en",
683
+ variants: [
684
+ {
685
+ pattern: [
686
+ { type: "text", value: "Hello from uppercase bundle" },
687
+ ],
688
+ },
689
+ ],
690
+ },
691
+ ],
692
+ }));
693
+ bundles.push(createBundleNested({
694
+ id: "helloworld",
695
+ messages: [
696
+ {
697
+ locale: "en",
698
+ variants: [
699
+ {
700
+ pattern: [
701
+ { type: "text", value: "Hello from lowercase bundle" },
702
+ ],
703
+ },
704
+ ],
705
+ },
706
+ ],
707
+ }));
708
+ const output = await compileProject({ bundles, settings, compilerOptions });
709
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
710
+ export { helloworld, Helloworld } from "./paraglide/messages.js"`);
711
+ const imported = await importCode(code);
712
+ // Both message functions should be available
713
+ expect(imported.helloworld()).toBe("Hello from lowercase bundle");
714
+ expect(imported.Helloworld()).toBe("Hello from uppercase bundle");
715
+ // They should also be available through the m namespace
716
+ expect(imported.m.helloworld()).toBe("Hello from lowercase bundle");
717
+ expect(imported.m.Helloworld()).toBe("Hello from uppercase bundle");
718
+ });
719
+ // whatever the strictest users use, this is the ultimate nothing gets stricter than this
720
+ // (to avoid developers opening issues "i get a ts warning in my code")
721
+ const superStrictRuleOutAnyErrorTsSettings = {
722
+ outDir: "dist",
723
+ declaration: true,
724
+ allowJs: true,
725
+ checkJs: true,
726
+ noImplicitAny: true,
727
+ noUnusedLocals: true,
728
+ noUnusedParameters: true,
729
+ noImplicitReturns: true,
730
+ noImplicitThis: true,
731
+ noUncheckedIndexedAccess: true,
732
+ noPropertyAccessFromIndexSignature: true,
733
+ module: ts.ModuleKind.Node16,
734
+ strict: true,
735
+ };
736
+ test("./messages.js types", async () => {
737
+ const project = await typescriptProject({
738
+ useInMemoryFileSystem: true,
739
+ compilerOptions: superStrictRuleOutAnyErrorTsSettings,
740
+ });
741
+ for (const [fileName, code] of Object.entries(output)) {
742
+ if (fileName.endsWith(".js") || fileName.endsWith(".ts")) {
743
+ project.createSourceFile(fileName, code);
744
+ }
745
+ }
746
+ project.createSourceFile("test.ts", `
747
+ import * as m from "./messages.js"
748
+
749
+ // --------- MESSAGES ---------
750
+
751
+ // the return value of a message should be a string
752
+ m.insane_cats({ name: "John", count: 5 }) satisfies string
753
+
754
+ // @ts-expect-error - missing all params
755
+ m.insane_cats()
756
+
757
+ // @ts-expect-error - one param missing
758
+ m.insane_cats({ name: "John" })
759
+
760
+ // a message without params shouldn't require params
761
+ m.sad_penguin_bundle() satisfies string
762
+
763
+ // dynamic relativetime unit inputs stay consistent with other formatter inputs
764
+ m.relative_time_literal({ duration: -1 }) satisfies string
765
+ m.relative_time_dynamic({ duration: -3, unit: "hour" }) satisfies string
766
+ m.relative_time_dynamic({ duration: -3, unit: "not-a-relative-time-unit" }) satisfies string
767
+
768
+ // --------- MATCH TYPE INFERENCE ---------
769
+ // known match values should be accepted
770
+ m.auth_password_error({ type: "invalid" }) satisfies string
771
+ m.auth_password_error({ type: "empty" }) satisfies string
772
+ m.auth_password_error({ type: "min_length" }) satisfies string
773
+ m.auth_password_error({ type: "secure" }) satisfies string
774
+
775
+ // @ts-expect-error - unknown match value
776
+ m.auth_password_error({ type: "typo" })
777
+
778
+ // quoted keys should still get literal unions
779
+ m.error_with_dash({ "error-type": "network" }) satisfies string
780
+ m.error_with_dash({ "error-type": "timeout" }) satisfies string
781
+
782
+ // @ts-expect-error - unknown match value for quoted key
783
+ m.error_with_dash({ "error-type": "offline" })
784
+
785
+ // catchall should widen match value typing
786
+ m.auth_password_error_catchall({ type: "invalid" }) satisfies string
787
+ m.auth_password_error_catchall({ type: "typo" }) satisfies string
788
+
789
+ // multiple match keys should each get literal unions
790
+ m.multi_key_status_type({ type: "invalid", status: "ready" }) satisfies string
791
+ m.multi_key_status_type({ type: "empty", status: "done" }) satisfies string
792
+ m.multi_key_status_type({ type: "secure", status: "failed" }) satisfies string
793
+
794
+ // @ts-expect-error - invalid type literal
795
+ m.multi_key_status_type({ type: "typo", status: "ready" })
796
+
797
+ // @ts-expect-error - invalid status literal
798
+ m.multi_key_status_type({ type: "invalid", status: "pending" })
799
+
800
+ // numeric matches should accept both number and string forms
801
+ m.numeric_input_match({ input: 1 }) satisfies string
802
+ m.numeric_input_match({ input: 2 }) satisfies string
803
+ m.numeric_input_match({ input: "1" }) satisfies string
804
+ m.numeric_input_match({ input: "2" }) satisfies string
805
+
806
+ // @ts-expect-error - invalid numeric literal
807
+ m.numeric_input_match({ input: 3 })
808
+
809
+ // @ts-expect-error - invalid string literal
810
+ m.numeric_input_match({ input: "3" })
811
+
812
+ // @ts-expect-error - no loose boolean coercion
813
+ m.numeric_input_match({ input: true })
814
+
815
+ // empty matches should widen to NonNullable<unknown>
816
+ m.empty_matches_catchall({ type: "invalid" }) satisfies string
817
+ m.empty_matches_catchall({ type: "typo" }) satisfies string
818
+
819
+ // --------- MESSAGE OPTIONS ---------
820
+ // the locale option should be optional
821
+ m.sad_penguin_bundle({}, {}) satisfies string
822
+
823
+ // the locale option should be allowed
824
+ m.sad_penguin_bundle({}, { locale: "en" }) satisfies string
825
+
826
+ // the locale option must be a valid language tag
827
+ // @ts-expect-error - invalid language tag
828
+ m.sad_penguin_bundle({}, { locale: "---" })
829
+ `);
830
+ const program = project.createProgram();
831
+ const diagnostics = ts.getPreEmitDiagnostics(program).filter((d) => {
832
+ const text = d.messageText.toString();
833
+ return (!text.includes("Cannot find module 'async_hooks'") &&
834
+ !text.includes("Cannot find module 'node:async_hooks'") &&
835
+ !text.includes("Cannot find name 'async_hooks'") &&
836
+ !text.includes("Cannot find name 'node:async_hooks'") &&
837
+ !text.includes("Cannot find name 'URLPattern'") &&
838
+ !text.includes("Type 'string' is not assignable to type"));
839
+ });
840
+ for (const diagnostic of diagnostics) {
841
+ console.error(diagnostic.messageText, diagnostic.file?.fileName);
842
+ }
843
+ expect(diagnostics.length).toEqual(0);
844
+ });
845
+ test("./messages.js types (single locale should not emit TS6133)", async () => {
846
+ const singleLocaleProjectSettings = { locales: ["en"], baseLocale: "en" };
847
+ const singleLocaleProjectBundles = [];
848
+ singleLocaleProjectBundles.push(createBundleNested({
849
+ id: "single_locale_message",
850
+ messages: [
851
+ {
852
+ locale: "en",
853
+ variants: [{ pattern: [{ type: "text", value: "Hello" }] }],
854
+ },
855
+ ],
856
+ }));
857
+ const singleLocaleOutput = await compileProject({ bundles: singleLocaleProjectBundles, settings: singleLocaleProjectSettings,
858
+ compilerOptions,
859
+ });
860
+ const project = await typescriptProject({
861
+ useInMemoryFileSystem: true,
862
+ compilerOptions: superStrictRuleOutAnyErrorTsSettings,
863
+ });
864
+ for (const [fileName, code] of Object.entries(singleLocaleOutput)) {
865
+ if (fileName.endsWith(".js") || fileName.endsWith(".ts")) {
866
+ project.createSourceFile(fileName, code);
867
+ }
868
+ }
869
+ project.createSourceFile("test.ts", `import { single_locale_message } from "./messages.js"; single_locale_message();`);
870
+ const program = project.createProgram();
871
+ const diagnostics = ts.getPreEmitDiagnostics(program).filter((d) => {
872
+ const text = d.messageText.toString();
873
+ return (!text.includes("Cannot find module 'async_hooks'") &&
874
+ !text.includes("Cannot find module 'node:async_hooks'") &&
875
+ !text.includes("Cannot find name 'async_hooks'") &&
876
+ !text.includes("Cannot find name 'node:async_hooks'") &&
877
+ !text.includes("Cannot find name 'URLPattern'") &&
878
+ !text.includes("Type 'string' is not assignable to type"));
879
+ });
880
+ const ts6133LocaleDiagnostics = diagnostics.filter((d) => {
881
+ return (d.code === 6133 &&
882
+ d.messageText
883
+ .toString()
884
+ .includes("'locale' is declared but its value is never read"));
885
+ });
886
+ expect(ts6133LocaleDiagnostics.length).toEqual(0);
887
+ });
888
+ test("#625: number formatter digit options should pass checkJs", async () => {
889
+ const projectWithNumberOptionsSettings = {
890
+ baseLocale: "en",
891
+ locales: ["en"],
892
+ };
893
+ const projectWithNumberOptionsBundles = [];
894
+ projectWithNumberOptionsBundles.push(createBundleNested({
895
+ id: "formatted_percentage",
896
+ declarations: [
897
+ {
898
+ type: "input-variable",
899
+ name: "value",
900
+ },
901
+ {
902
+ type: "local-variable",
903
+ name: "formattedValue",
904
+ value: {
905
+ type: "expression",
906
+ arg: { type: "variable-reference", name: "value" },
907
+ annotation: {
908
+ type: "function-reference",
909
+ name: "number",
910
+ options: [
911
+ {
912
+ name: "minimumFractionDigits",
913
+ value: { type: "literal", value: "1" },
914
+ },
915
+ {
916
+ name: "maximumFractionDigits",
917
+ value: { type: "literal", value: "1" },
918
+ },
919
+ ],
920
+ },
921
+ },
922
+ },
923
+ ],
924
+ messages: [
925
+ {
926
+ locale: "en",
927
+ variants: [
928
+ {
929
+ pattern: [
930
+ {
931
+ type: "expression",
932
+ arg: {
933
+ type: "variable-reference",
934
+ name: "formattedValue",
935
+ },
936
+ },
937
+ { type: "text", value: "%" },
938
+ ],
939
+ },
940
+ ],
941
+ },
942
+ ],
943
+ }));
944
+ const output = await compileProject({ bundles: projectWithNumberOptionsBundles, settings: projectWithNumberOptionsSettings,
945
+ compilerOptions,
946
+ });
947
+ const tsProject = await typescriptProject({
948
+ useInMemoryFileSystem: true,
949
+ compilerOptions: superStrictRuleOutAnyErrorTsSettings,
950
+ });
951
+ for (const [fileName, code] of Object.entries(output)) {
952
+ if (fileName.endsWith(".js") || fileName.endsWith(".ts")) {
953
+ tsProject.createSourceFile(fileName, code);
954
+ }
955
+ }
956
+ const program = tsProject.createProgram();
957
+ const diagnostics = ts.getPreEmitDiagnostics(program).filter((d) => {
958
+ const text = d.messageText.toString();
959
+ return (!text.includes("Cannot find module 'async_hooks'") &&
960
+ !text.includes("Cannot find module 'node:async_hooks'") &&
961
+ !text.includes("Cannot find name 'async_hooks'") &&
962
+ !text.includes("Cannot find name 'node:async_hooks'") &&
963
+ !text.includes("Cannot find name 'URLPattern'") &&
964
+ !text.includes("Type 'string' is not assignable to type"));
965
+ });
966
+ for (const diagnostic of diagnostics) {
967
+ console.error(diagnostic.messageText, diagnostic.file?.fileName);
968
+ }
969
+ expect(diagnostics.length).toEqual(0);
970
+ });
971
+ test("#694: pattern-level annotations compile to registry calls and pass checkJs", async () => {
972
+ const projectWithPatternAnnotationSettings = {
973
+ baseLocale: "en",
974
+ locales: ["en"],
975
+ };
976
+ const projectWithPatternAnnotationBundles = [];
977
+ projectWithPatternAnnotationBundles.push(createBundleNested({
978
+ id: "views",
979
+ declarations: [
980
+ {
981
+ type: "input-variable",
982
+ name: "count",
983
+ },
984
+ ],
985
+ messages: [
986
+ {
987
+ locale: "en",
988
+ variants: [
989
+ {
990
+ pattern: [
991
+ {
992
+ type: "expression",
993
+ arg: { type: "variable-reference", name: "count" },
994
+ annotation: {
995
+ type: "function-reference",
996
+ name: "number",
997
+ options: [
998
+ {
999
+ name: "maximumFractionDigits",
1000
+ value: { type: "literal", value: "1" },
1001
+ },
1002
+ ],
1003
+ },
1004
+ },
1005
+ { type: "text", value: " views" },
1006
+ ],
1007
+ },
1008
+ ],
1009
+ },
1010
+ ],
1011
+ }));
1012
+ const output = await compileProject({ bundles: projectWithPatternAnnotationBundles, settings: projectWithPatternAnnotationSettings,
1013
+ compilerOptions,
1014
+ });
1015
+ expect(Object.values(output).join("\n")).toContain('registry.number("en", i?.count, { maximumFractionDigits: 1 })');
1016
+ const tsProject = await typescriptProject({
1017
+ useInMemoryFileSystem: true,
1018
+ compilerOptions: superStrictRuleOutAnyErrorTsSettings,
1019
+ });
1020
+ for (const [fileName, code] of Object.entries(output)) {
1021
+ if (fileName.endsWith(".js") || fileName.endsWith(".ts")) {
1022
+ tsProject.createSourceFile(fileName, code);
1023
+ }
1024
+ }
1025
+ const program = tsProject.createProgram();
1026
+ const diagnostics = ts.getPreEmitDiagnostics(program).filter((d) => {
1027
+ const text = d.messageText.toString();
1028
+ return (!text.includes("Cannot find module 'async_hooks'") &&
1029
+ !text.includes("Cannot find module 'node:async_hooks'") &&
1030
+ !text.includes("Cannot find name 'async_hooks'") &&
1031
+ !text.includes("Cannot find name 'node:async_hooks'") &&
1032
+ !text.includes("Cannot find name 'URLPattern'") &&
1033
+ !text.includes("Type 'string' is not assignable to type"));
1034
+ });
1035
+ for (const diagnostic of diagnostics) {
1036
+ console.error(diagnostic.messageText, diagnostic.file?.fileName);
1037
+ }
1038
+ expect(diagnostics.length).toEqual(0);
1039
+ });
1040
+ test("relativetime formatter options should pass checkJs", async () => {
1041
+ const projectWithRelativeTimeOptionsSettings = {
1042
+ baseLocale: "en",
1043
+ locales: ["en"],
1044
+ };
1045
+ const projectWithRelativeTimeOptionsBundles = [];
1046
+ projectWithRelativeTimeOptionsBundles.push(createBundleNested({
1047
+ id: "formatted_relative_time",
1048
+ declarations: [
1049
+ {
1050
+ type: "input-variable",
1051
+ name: "duration",
1052
+ },
1053
+ {
1054
+ type: "input-variable",
1055
+ name: "unit",
1056
+ },
1057
+ {
1058
+ type: "local-variable",
1059
+ name: "formattedDuration",
1060
+ value: {
1061
+ type: "expression",
1062
+ arg: { type: "variable-reference", name: "duration" },
1063
+ annotation: {
1064
+ type: "function-reference",
1065
+ name: "relativetime",
1066
+ options: [
1067
+ {
1068
+ name: "unit",
1069
+ value: { type: "variable-reference", name: "unit" },
1070
+ },
1071
+ {
1072
+ name: "style",
1073
+ value: { type: "literal", value: "short" },
1074
+ },
1075
+ ],
1076
+ },
1077
+ },
1078
+ },
1079
+ ],
1080
+ messages: [
1081
+ {
1082
+ locale: "en",
1083
+ variants: [
1084
+ {
1085
+ pattern: [
1086
+ {
1087
+ type: "expression",
1088
+ arg: {
1089
+ type: "variable-reference",
1090
+ name: "formattedDuration",
1091
+ },
1092
+ },
1093
+ ],
1094
+ },
1095
+ ],
1096
+ },
1097
+ ],
1098
+ }));
1099
+ const output = await compileProject({ bundles: projectWithRelativeTimeOptionsBundles, settings: projectWithRelativeTimeOptionsSettings,
1100
+ compilerOptions,
1101
+ });
1102
+ const tsProject = await typescriptProject({
1103
+ useInMemoryFileSystem: true,
1104
+ compilerOptions: superStrictRuleOutAnyErrorTsSettings,
1105
+ });
1106
+ for (const [fileName, code] of Object.entries(output)) {
1107
+ if (fileName.endsWith(".js") || fileName.endsWith(".ts")) {
1108
+ tsProject.createSourceFile(fileName, code);
1109
+ }
1110
+ }
1111
+ const program = tsProject.createProgram();
1112
+ const diagnostics = ts.getPreEmitDiagnostics(program).filter((d) => {
1113
+ const text = d.messageText.toString();
1114
+ return (!text.includes("Cannot find module 'async_hooks'") &&
1115
+ !text.includes("Cannot find module 'node:async_hooks'") &&
1116
+ !text.includes("Cannot find name 'async_hooks'") &&
1117
+ !text.includes("Cannot find name 'node:async_hooks'") &&
1118
+ !text.includes("Cannot find name 'URLPattern'") &&
1119
+ !text.includes("Type 'string' is not assignable to type"));
1120
+ });
1121
+ for (const diagnostic of diagnostics) {
1122
+ console.error(diagnostic.messageText, diagnostic.file?.fileName);
1123
+ }
1124
+ expect(diagnostics.length).toEqual(0);
1125
+ });
1126
+ });
1127
+ async function bundleCode(output, file) {
1128
+ output["runtime.js"] = output["runtime.js"].replace('const { AsyncLocalStorage } = await import("node:async_hooks");', "const AsyncLocalStorage = class {};");
1129
+ const bundle = await rolldown({
1130
+ input: ["main.js"],
1131
+ plugins: [
1132
+ // @ts-expect-error - rollup types are not up to date
1133
+ virtual({
1134
+ ...Object.fromEntries(Object.entries(output).map(([fileName, code]) => [
1135
+ "paraglide/" + fileName,
1136
+ code,
1137
+ ])),
1138
+ "main.js": file,
1139
+ }),
1140
+ ],
1141
+ });
1142
+ const compiled = await bundle.generate({ format: "esm" });
1143
+ const code = compiled.output[0].code;
1144
+ return code;
1145
+ }
1146
+ async function importCode(code) {
1147
+ // The random comment ensures that each code is a unique module
1148
+ // and state is not shared between imports
1149
+ const randomComment = `// ${Math.random()}`;
1150
+ const codeWithComment = `${randomComment}\n${code}`;
1151
+ return await import(`data:application/javascript;base64,${Buffer.from(codeWithComment, "utf8").toString("base64")}`);
1152
+ }
1153
+ const settings = {
1154
+ baseLocale: "en",
1155
+ locales: ["en", "de", "en-US"],
1156
+ };
1157
+ const bundles = [
1158
+ createBundleNested({
1159
+ id: "sad_penguin_bundle",
1160
+ messages: [
1161
+ {
1162
+ locale: "en",
1163
+ variants: [{ pattern: [{ type: "text", value: "A simple message." }] }],
1164
+ },
1165
+ {
1166
+ locale: "de",
1167
+ variants: [
1168
+ { pattern: [{ type: "text", value: "Eine einfache Nachricht." }] },
1169
+ ],
1170
+ },
1171
+ ],
1172
+ }),
1173
+ createBundleNested({
1174
+ id: "Sad_penguin_bundle",
1175
+ messages: [
1176
+ {
1177
+ locale: "en",
1178
+ variants: [
1179
+ { pattern: [{ type: "text", value: "Capital Sad penguin" }] },
1180
+ ],
1181
+ },
1182
+ {
1183
+ locale: "de",
1184
+ variants: [
1185
+ {
1186
+ pattern: [
1187
+ { type: "text", value: "Grossgeschriebenes Sad penguin" },
1188
+ ],
1189
+ },
1190
+ ],
1191
+ },
1192
+ ],
1193
+ }),
1194
+ {
1195
+ id: "depressed_dog",
1196
+ declarations: [
1197
+ {
1198
+ type: "input-variable",
1199
+ name: "name",
1200
+ },
1201
+ ],
1202
+ messages: [
1203
+ {
1204
+ id: "depressed_dog_en",
1205
+ bundleId: "depressed_dog",
1206
+ locale: "en",
1207
+ selectors: [],
1208
+ variants: [
1209
+ {
1210
+ id: "depressed_dog_en_variant_one",
1211
+ messageId: "depressed_dog_en",
1212
+ matches: [],
1213
+ pattern: [
1214
+ { type: "text", value: "Good morning " },
1215
+ {
1216
+ type: "expression",
1217
+ arg: { type: "variable-reference", name: "name" },
1218
+ },
1219
+ { type: "text", value: "!" },
1220
+ ],
1221
+ },
1222
+ ],
1223
+ },
1224
+ {
1225
+ id: "depressed_dog_de",
1226
+ bundleId: "depressed_dog",
1227
+ locale: "de",
1228
+ selectors: [],
1229
+ variants: [
1230
+ {
1231
+ id: "depressed_dog_de_variant_one",
1232
+ messageId: "depressed_dog_de",
1233
+ matches: [],
1234
+ pattern: [
1235
+ { type: "text", value: "Guten Morgen " },
1236
+ {
1237
+ type: "expression",
1238
+ arg: { type: "variable-reference", name: "name" },
1239
+ },
1240
+ { type: "text", value: "!" },
1241
+ ],
1242
+ },
1243
+ ],
1244
+ },
1245
+ ],
1246
+ },
1247
+ {
1248
+ id: "insane_cats",
1249
+ declarations: [
1250
+ {
1251
+ type: "input-variable",
1252
+ name: "name",
1253
+ },
1254
+ {
1255
+ type: "input-variable",
1256
+ name: "count",
1257
+ },
1258
+ ],
1259
+ messages: [
1260
+ {
1261
+ id: "insane_cats_en",
1262
+ bundleId: "insane_cats",
1263
+ locale: "en",
1264
+ selectors: [],
1265
+ variants: [
1266
+ {
1267
+ id: "insane_cats_en_variant_one",
1268
+ messageId: "insane_cats_en",
1269
+ matches: [],
1270
+ pattern: [
1271
+ { type: "text", value: "Hello " },
1272
+ {
1273
+ type: "expression",
1274
+ arg: { type: "variable-reference", name: "name" },
1275
+ },
1276
+ { type: "text", value: "! You have " },
1277
+ {
1278
+ type: "expression",
1279
+ arg: { type: "variable-reference", name: "count" },
1280
+ },
1281
+ { type: "text", value: " messages." },
1282
+ ],
1283
+ },
1284
+ ],
1285
+ },
1286
+ {
1287
+ id: "insane_cats_de",
1288
+ bundleId: "insane_cats",
1289
+ locale: "de",
1290
+ selectors: [],
1291
+ variants: [
1292
+ {
1293
+ id: "insane_cats_de_variant_one",
1294
+ messageId: "insane_cats_de",
1295
+ matches: [],
1296
+ pattern: [
1297
+ { type: "text", value: "Hallo " },
1298
+ {
1299
+ type: "expression",
1300
+ arg: { type: "variable-reference", name: "name" },
1301
+ },
1302
+ { type: "text", value: "! Du hast " },
1303
+ {
1304
+ type: "expression",
1305
+ arg: { type: "variable-reference", name: "count" },
1306
+ },
1307
+ { type: "text", value: " Nachrichten." },
1308
+ ],
1309
+ },
1310
+ ],
1311
+ },
1312
+ ],
1313
+ },
1314
+ createBundleNested({
1315
+ id: "relative_time_literal",
1316
+ declarations: [
1317
+ {
1318
+ type: "input-variable",
1319
+ name: "duration",
1320
+ },
1321
+ {
1322
+ type: "local-variable",
1323
+ name: "formattedDuration",
1324
+ value: {
1325
+ type: "expression",
1326
+ arg: { type: "variable-reference", name: "duration" },
1327
+ annotation: {
1328
+ type: "function-reference",
1329
+ name: "relativetime",
1330
+ options: [
1331
+ { name: "unit", value: { type: "literal", value: "day" } },
1332
+ { name: "numeric", value: { type: "literal", value: "auto" } },
1333
+ ],
1334
+ },
1335
+ },
1336
+ },
1337
+ ],
1338
+ messages: [
1339
+ {
1340
+ locale: "en",
1341
+ variants: [
1342
+ {
1343
+ pattern: [
1344
+ { type: "text", value: "Updated " },
1345
+ {
1346
+ type: "expression",
1347
+ arg: {
1348
+ type: "variable-reference",
1349
+ name: "formattedDuration",
1350
+ },
1351
+ },
1352
+ { type: "text", value: "." },
1353
+ ],
1354
+ },
1355
+ ],
1356
+ },
1357
+ {
1358
+ locale: "de",
1359
+ variants: [
1360
+ {
1361
+ pattern: [
1362
+ { type: "text", value: "Updated " },
1363
+ {
1364
+ type: "expression",
1365
+ arg: {
1366
+ type: "variable-reference",
1367
+ name: "formattedDuration",
1368
+ },
1369
+ },
1370
+ { type: "text", value: "." },
1371
+ ],
1372
+ },
1373
+ ],
1374
+ },
1375
+ ],
1376
+ }),
1377
+ createBundleNested({
1378
+ id: "relative_time_dynamic",
1379
+ declarations: [
1380
+ {
1381
+ type: "input-variable",
1382
+ name: "duration",
1383
+ },
1384
+ {
1385
+ type: "input-variable",
1386
+ name: "unit",
1387
+ },
1388
+ {
1389
+ type: "local-variable",
1390
+ name: "formattedDuration",
1391
+ value: {
1392
+ type: "expression",
1393
+ arg: { type: "variable-reference", name: "duration" },
1394
+ annotation: {
1395
+ type: "function-reference",
1396
+ name: "relativetime",
1397
+ options: [
1398
+ {
1399
+ name: "unit",
1400
+ value: { type: "variable-reference", name: "unit" },
1401
+ },
1402
+ { name: "style", value: { type: "literal", value: "short" } },
1403
+ ],
1404
+ },
1405
+ },
1406
+ },
1407
+ ],
1408
+ messages: [
1409
+ {
1410
+ locale: "en",
1411
+ variants: [
1412
+ {
1413
+ pattern: [
1414
+ { type: "text", value: "Updated " },
1415
+ {
1416
+ type: "expression",
1417
+ arg: {
1418
+ type: "variable-reference",
1419
+ name: "formattedDuration",
1420
+ },
1421
+ },
1422
+ { type: "text", value: "." },
1423
+ ],
1424
+ },
1425
+ ],
1426
+ },
1427
+ {
1428
+ locale: "de",
1429
+ variants: [
1430
+ {
1431
+ pattern: [
1432
+ { type: "text", value: "Updated " },
1433
+ {
1434
+ type: "expression",
1435
+ arg: {
1436
+ type: "variable-reference",
1437
+ name: "formattedDuration",
1438
+ },
1439
+ },
1440
+ { type: "text", value: "." },
1441
+ ],
1442
+ },
1443
+ ],
1444
+ },
1445
+ ],
1446
+ }),
1447
+ {
1448
+ id: "auth_password_error",
1449
+ declarations: [
1450
+ {
1451
+ type: "input-variable",
1452
+ name: "type",
1453
+ },
1454
+ ],
1455
+ messages: [
1456
+ {
1457
+ id: "auth_password_error_en",
1458
+ bundleId: "auth_password_error",
1459
+ locale: "en",
1460
+ selectors: [],
1461
+ variants: [
1462
+ {
1463
+ id: "auth_password_error_en_variant_invalid",
1464
+ messageId: "auth_password_error_en",
1465
+ matches: [{ type: "literal-match", key: "type", value: "invalid" }],
1466
+ pattern: [
1467
+ {
1468
+ type: "text",
1469
+ value: "The password provided is not valid",
1470
+ },
1471
+ ],
1472
+ },
1473
+ {
1474
+ id: "auth_password_error_en_variant_empty",
1475
+ messageId: "auth_password_error_en",
1476
+ matches: [{ type: "literal-match", key: "type", value: "empty" }],
1477
+ pattern: [
1478
+ {
1479
+ type: "text",
1480
+ value: "You must provide a password",
1481
+ },
1482
+ ],
1483
+ },
1484
+ {
1485
+ id: "auth_password_error_en_variant_min",
1486
+ messageId: "auth_password_error_en",
1487
+ matches: [
1488
+ {
1489
+ type: "literal-match",
1490
+ key: "type",
1491
+ value: "min_length",
1492
+ },
1493
+ ],
1494
+ pattern: [
1495
+ {
1496
+ type: "text",
1497
+ value: "Your password is not secure enough",
1498
+ },
1499
+ ],
1500
+ },
1501
+ {
1502
+ id: "auth_password_error_en_variant_secure",
1503
+ messageId: "auth_password_error_en",
1504
+ matches: [{ type: "literal-match", key: "type", value: "secure" }],
1505
+ pattern: [
1506
+ {
1507
+ type: "text",
1508
+ value: "Your password is not secure enough",
1509
+ },
1510
+ ],
1511
+ },
1512
+ ],
1513
+ },
1514
+ ],
1515
+ },
1516
+ {
1517
+ id: "error_with_dash",
1518
+ declarations: [
1519
+ {
1520
+ type: "input-variable",
1521
+ name: "error-type",
1522
+ },
1523
+ ],
1524
+ messages: [
1525
+ {
1526
+ id: "error_with_dash_en",
1527
+ bundleId: "error_with_dash",
1528
+ locale: "en",
1529
+ selectors: [],
1530
+ variants: [
1531
+ {
1532
+ id: "error_with_dash_en_variant_network",
1533
+ messageId: "error_with_dash_en",
1534
+ matches: [
1535
+ { type: "literal-match", key: "error-type", value: "network" },
1536
+ ],
1537
+ pattern: [{ type: "text", value: "Network error" }],
1538
+ },
1539
+ {
1540
+ id: "error_with_dash_en_variant_timeout",
1541
+ messageId: "error_with_dash_en",
1542
+ matches: [
1543
+ {
1544
+ type: "literal-match",
1545
+ key: "error-type",
1546
+ value: "timeout",
1547
+ },
1548
+ ],
1549
+ pattern: [{ type: "text", value: "Timeout error" }],
1550
+ },
1551
+ ],
1552
+ },
1553
+ ],
1554
+ },
1555
+ {
1556
+ id: "auth_password_error_catchall",
1557
+ declarations: [
1558
+ {
1559
+ type: "input-variable",
1560
+ name: "type",
1561
+ },
1562
+ ],
1563
+ messages: [
1564
+ {
1565
+ id: "auth_password_error_catchall_en",
1566
+ bundleId: "auth_password_error_catchall",
1567
+ locale: "en",
1568
+ selectors: [],
1569
+ variants: [
1570
+ {
1571
+ id: "auth_password_error_catchall_en_variant_invalid",
1572
+ messageId: "auth_password_error_catchall_en",
1573
+ matches: [{ type: "literal-match", key: "type", value: "invalid" }],
1574
+ pattern: [
1575
+ {
1576
+ type: "text",
1577
+ value: "The password provided is not valid",
1578
+ },
1579
+ ],
1580
+ },
1581
+ {
1582
+ id: "auth_password_error_catchall_en_variant_catchall",
1583
+ messageId: "auth_password_error_catchall_en",
1584
+ matches: [{ type: "catchall-match", key: "type" }],
1585
+ pattern: [
1586
+ {
1587
+ type: "text",
1588
+ value: "Unknown password error",
1589
+ },
1590
+ ],
1591
+ },
1592
+ ],
1593
+ },
1594
+ ],
1595
+ },
1596
+ {
1597
+ id: "multi_key_status_type",
1598
+ declarations: [
1599
+ {
1600
+ type: "input-variable",
1601
+ name: "type",
1602
+ },
1603
+ {
1604
+ type: "input-variable",
1605
+ name: "status",
1606
+ },
1607
+ ],
1608
+ messages: [
1609
+ {
1610
+ id: "multi_key_status_type_en",
1611
+ bundleId: "multi_key_status_type",
1612
+ locale: "en",
1613
+ selectors: [],
1614
+ variants: [
1615
+ {
1616
+ id: "multi_key_status_type_en_variant_ready_invalid",
1617
+ messageId: "multi_key_status_type_en",
1618
+ matches: [
1619
+ { type: "literal-match", key: "type", value: "invalid" },
1620
+ { type: "literal-match", key: "status", value: "ready" },
1621
+ ],
1622
+ pattern: [{ type: "text", value: "Ready invalid" }],
1623
+ },
1624
+ {
1625
+ id: "multi_key_status_type_en_variant_done_empty",
1626
+ messageId: "multi_key_status_type_en",
1627
+ matches: [
1628
+ { type: "literal-match", key: "type", value: "empty" },
1629
+ { type: "literal-match", key: "status", value: "done" },
1630
+ ],
1631
+ pattern: [{ type: "text", value: "Done empty" }],
1632
+ },
1633
+ {
1634
+ id: "multi_key_status_type_en_variant_failed_secure",
1635
+ messageId: "multi_key_status_type_en",
1636
+ matches: [
1637
+ { type: "literal-match", key: "type", value: "secure" },
1638
+ { type: "literal-match", key: "status", value: "failed" },
1639
+ ],
1640
+ pattern: [{ type: "text", value: "Failed secure" }],
1641
+ },
1642
+ ],
1643
+ },
1644
+ ],
1645
+ },
1646
+ {
1647
+ id: "empty_matches_catchall",
1648
+ declarations: [
1649
+ {
1650
+ type: "input-variable",
1651
+ name: "type",
1652
+ },
1653
+ ],
1654
+ messages: [
1655
+ {
1656
+ id: "empty_matches_catchall_en",
1657
+ bundleId: "empty_matches_catchall",
1658
+ locale: "en",
1659
+ selectors: [],
1660
+ variants: [
1661
+ {
1662
+ id: "empty_matches_catchall_en_variant_invalid",
1663
+ messageId: "empty_matches_catchall_en",
1664
+ matches: [{ type: "literal-match", key: "type", value: "invalid" }],
1665
+ pattern: [{ type: "text", value: "Invalid" }],
1666
+ },
1667
+ {
1668
+ id: "empty_matches_catchall_en_variant_any",
1669
+ messageId: "empty_matches_catchall_en",
1670
+ matches: [],
1671
+ pattern: [{ type: "text", value: "Any" }],
1672
+ },
1673
+ ],
1674
+ },
1675
+ ],
1676
+ },
1677
+ {
1678
+ id: "numeric_input_match",
1679
+ declarations: [
1680
+ {
1681
+ type: "input-variable",
1682
+ name: "input",
1683
+ },
1684
+ ],
1685
+ messages: [
1686
+ {
1687
+ id: "numeric_input_match_en",
1688
+ bundleId: "numeric_input_match",
1689
+ locale: "en",
1690
+ selectors: [],
1691
+ variants: [
1692
+ {
1693
+ id: "numeric_input_match_en_variant_1",
1694
+ messageId: "numeric_input_match_en",
1695
+ matches: [{ type: "literal-match", key: "input", value: "1" }],
1696
+ pattern: [{ type: "text", value: "Thing 1" }],
1697
+ },
1698
+ {
1699
+ id: "numeric_input_match_en_variant_2",
1700
+ messageId: "numeric_input_match_en",
1701
+ matches: [{ type: "literal-match", key: "input", value: "2" }],
1702
+ pattern: [{ type: "text", value: "Thing 2" }],
1703
+ },
1704
+ ],
1705
+ },
1706
+ ],
1707
+ },
1708
+ ];
1709
+ //# sourceMappingURL=compile-project.test.js.map