@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,60 @@
1
+ /**
2
+ * Re: CUSTOMIZING THE REGISTRY
3
+ *
4
+ * We want to enable anyone (designer, developer, translator) to
5
+ * specify options for functions. That requires design work in
6
+ * the inlang SDK.
7
+ *
8
+ * For now, Paraglide ships a custom solution with INTL functions.
9
+ */
10
+ /**
11
+ * Creates the Registry file
12
+ */
13
+ export function createRegistry() {
14
+ return `
15
+ /**
16
+ * @typedef {"year" | "years" | "quarter" | "quarters" | "month" | "months" | "week" | "weeks" | "day" | "days" | "hour" | "hours" | "minute" | "minutes" | "second" | "seconds"} RelativeTimeFormatUnit
17
+ */
18
+
19
+ /**
20
+ * @param {import("./runtime.js").Locale} locale
21
+ * @param {unknown} input
22
+ * @param {Intl.PluralRulesOptions} [options]
23
+ * @returns {string}
24
+ */
25
+ export function plural(locale, input, options) {
26
+ return new Intl.PluralRules(locale, options).select(Number(input))
27
+ };
28
+
29
+ /**
30
+ * @param {import("./runtime.js").Locale} locale
31
+ * @param {unknown} input
32
+ * @param {Intl.NumberFormatOptions} [options]
33
+ * @returns {string}
34
+ */
35
+ export function number(locale, input, options) {
36
+ return new Intl.NumberFormat(locale, options).format(Number(input))
37
+ };
38
+
39
+ /**
40
+ * @param {import("./runtime.js").Locale} locale
41
+ * @param {unknown} input
42
+ * @param {Intl.DateTimeFormatOptions} [options]
43
+ * @returns {string}
44
+ */
45
+ export function datetime(locale, input, options) {
46
+ return new Intl.DateTimeFormat(locale, options).format(new Date(/** @type {string} */ (input)))
47
+ };
48
+
49
+ /**
50
+ * @param {import("./runtime.js").Locale} locale
51
+ * @param {unknown} input
52
+ * @param {Intl.RelativeTimeFormatOptions & { unit: RelativeTimeFormatUnit }} options
53
+ * @returns {string}
54
+ */
55
+ export function relativetime(locale, input, options) {
56
+ const { unit, ...intlOptions } = options;
57
+ return new Intl.RelativeTimeFormat(locale, intlOptions).format(Number(input), unit);
58
+ };`;
59
+ }
60
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/compiler/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,UAAU,cAAc;IAC7B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CL,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Re: CUSTOMIZING THE REGISTRY\n *\n * We want to enable anyone (designer, developer, translator) to\n * specify options for functions. That requires design work in\n * the inlang SDK.\n *\n * For now, Paraglide ships a custom solution with INTL functions.\n */\n\n/**\n * Creates the Registry file\n */\nexport function createRegistry(): string {\n\treturn `\n/**\n * @typedef {\"year\" | \"years\" | \"quarter\" | \"quarters\" | \"month\" | \"months\" | \"week\" | \"weeks\" | \"day\" | \"days\" | \"hour\" | \"hours\" | \"minute\" | \"minutes\" | \"second\" | \"seconds\"} RelativeTimeFormatUnit\n */\n\n/**\n * @param {import(\"./runtime.js\").Locale} locale\n * @param {unknown} input\n * @param {Intl.PluralRulesOptions} [options]\n * @returns {string}\n */\nexport function plural(locale, input, options) { \n\treturn new Intl.PluralRules(locale, options).select(Number(input))\n};\n\n/**\n * @param {import(\"./runtime.js\").Locale} locale\n * @param {unknown} input\n * @param {Intl.NumberFormatOptions} [options]\n * @returns {string}\n */\nexport function number(locale, input, options) {\n\treturn new Intl.NumberFormat(locale, options).format(Number(input))\n};\n\n/**\n * @param {import(\"./runtime.js\").Locale} locale\n * @param {unknown} input\n * @param {Intl.DateTimeFormatOptions} [options]\n * @returns {string}\n */\nexport function datetime(locale, input, options) {\n\treturn new Intl.DateTimeFormat(locale, options).format(new Date(/** @type {string} */ (input)))\n};\n\n/**\n * @param {import(\"./runtime.js\").Locale} locale\n * @param {unknown} input\n * @param {Intl.RelativeTimeFormatOptions & { unit: RelativeTimeFormatUnit }} options\n * @returns {string}\n */\nexport function relativetime(locale, input, options) {\n\tconst { unit, ...intlOptions } = options;\n\treturn new Intl.RelativeTimeFormat(locale, intlOptions).format(Number(input), unit);\n};`;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Resolves the path to the `tsc` CLI entry point of the installed
3
+ * `typescript` package.
4
+ *
5
+ * Lives in its own module so tests can point the TypeScript 7 emit
6
+ * path at a different TypeScript installation than the one the repo
7
+ * itself depends on.
8
+ */
9
+ export declare function resolveTscJsPath(): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-tsc-js-path.d.ts","sourceRoot":"","sources":["../../src/compiler/resolve-tsc-js-path.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAYzC"}
@@ -0,0 +1,23 @@
1
+ import { createRequire } from "node:module";
2
+ import { existsSync } from "node:fs";
3
+ import path from "node:path";
4
+ /**
5
+ * Resolves the path to the `tsc` CLI entry point of the installed
6
+ * `typescript` package.
7
+ *
8
+ * Lives in its own module so tests can point the TypeScript 7 emit
9
+ * path at a different TypeScript installation than the one the repo
10
+ * itself depends on.
11
+ */
12
+ export function resolveTscJsPath() {
13
+ const require = createRequire(import.meta.url);
14
+ const packageJsonPath = require.resolve("typescript/package.json");
15
+ const tscJsPath = path.join(path.dirname(packageJsonPath), "lib", "tsc.js");
16
+ // `lib/tsc.js` is internal package layout rather than a public export, so
17
+ // fail with a pointed error if a future TypeScript version moves it.
18
+ if (existsSync(tscJsPath) === false) {
19
+ throw new Error(`Paraglide's "emitTsDeclarations" option could not locate TypeScript's "tsc" CLI at ${tscJsPath}. As a workaround, install TypeScript 5 or 6, or disable "emitTsDeclarations".`);
20
+ }
21
+ return tscJsPath;
22
+ }
23
+ //# sourceMappingURL=resolve-tsc-js-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-tsc-js-path.js","sourceRoot":"","sources":["../../src/compiler/resolve-tsc-js-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB;IAC/B,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5E,0EAA0E;IAC1E,qEAAqE;IACrE,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACd,sFAAsF,SAAS,gFAAgF,CAC/K,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { createRequire } from \"node:module\";\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * Resolves the path to the `tsc` CLI entry point of the installed\n * `typescript` package.\n *\n * Lives in its own module so tests can point the TypeScript 7 emit\n * path at a different TypeScript installation than the one the repo\n * itself depends on.\n */\nexport function resolveTscJsPath(): string {\n\tconst require = createRequire(import.meta.url);\n\tconst packageJsonPath = require.resolve(\"typescript/package.json\");\n\tconst tscJsPath = path.join(path.dirname(packageJsonPath), \"lib\", \"tsc.js\");\n\t// `lib/tsc.js` is internal package layout rather than a public export, so\n\t// fail with a pointed error if a future TypeScript version moves it.\n\tif (existsSync(tscJsPath) === false) {\n\t\tthrow new Error(\n\t\t\t`Paraglide's \"emitTsDeclarations\" option could not locate TypeScript's \"tsc\" CLI at ${tscJsPath}. As a workaround, install TypeScript 5 or 6, or disable \"emitTsDeclarations\".`\n\t\t);\n\t}\n\treturn tscJsPath;\n}\n"]}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Coerces a locale-like string to the canonical locale value used by the runtime.
3
+ *
4
+ * @param {unknown} value
5
+ * @returns {Locale | undefined}
6
+ */
7
+ export declare function toLocale(value: unknown): Locale | undefined;
8
+ /**
9
+ * Check if something is an available locale with the canonical project casing.
10
+ *
11
+ * @example
12
+ * if (isLocale(params.locale)) {
13
+ * setLocale(params.locale);
14
+ * } else {
15
+ * setLocale('en');
16
+ * }
17
+ *
18
+ * Use `toLocale()` when you want case-insensitive matching and canonicalization.
19
+ *
20
+ * @param {unknown} locale
21
+ * @returns {locale is Locale}
22
+ */
23
+ export declare function isLocale(locale: unknown): locale is Locale;
24
+ /**
25
+ * Asserts that the input can be normalized to a locale.
26
+ *
27
+ * @param {unknown} input - The input to check.
28
+ * @returns {Locale} The input normalized to a Locale.
29
+ * @throws {Error} If the input is not a locale.
30
+ */
31
+ export declare function assertIsLocale(input: unknown): Locale;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/check-locale.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAHnB,OAGmB,GAFjB,MAAM,GAAG,SAAS,CAc9B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAHpB,OAGoB,GAFlB,MAAM,IAAI,MAAM,CAI5B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAJzB,OAIyB,GAHvB,MAAM,CASlB"}
@@ -0,0 +1,51 @@
1
+ import { locales } from "./variables.js";
2
+ /**
3
+ * Coerces a locale-like string to the canonical locale value used by the runtime.
4
+ *
5
+ * @param {unknown} value
6
+ * @returns {Locale | undefined}
7
+ */
8
+ export function toLocale(value) {
9
+ if (typeof value !== "string") {
10
+ return undefined;
11
+ }
12
+ const lowerValue = value.toLowerCase();
13
+ for (const locale of locales) {
14
+ if (locale.toLowerCase() === lowerValue) {
15
+ return locale;
16
+ }
17
+ }
18
+ return undefined;
19
+ }
20
+ /**
21
+ * Check if something is an available locale with the canonical project casing.
22
+ *
23
+ * @example
24
+ * if (isLocale(params.locale)) {
25
+ * setLocale(params.locale);
26
+ * } else {
27
+ * setLocale('en');
28
+ * }
29
+ *
30
+ * Use `toLocale()` when you want case-insensitive matching and canonicalization.
31
+ *
32
+ * @param {unknown} locale
33
+ * @returns {locale is Locale}
34
+ */
35
+ export function isLocale(locale) {
36
+ return !!locale && locales.some((item) => item === locale);
37
+ }
38
+ /**
39
+ * Asserts that the input can be normalized to a locale.
40
+ *
41
+ * @param {unknown} input - The input to check.
42
+ * @returns {Locale} The input normalized to a Locale.
43
+ * @throws {Error} If the input is not a locale.
44
+ */
45
+ export function assertIsLocale(input) {
46
+ const locale = toLocale(input);
47
+ if (locale)
48
+ return locale;
49
+ throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
50
+ }
51
+ //# sourceMappingURL=check-locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-locale.js","sourceRoot":"","sources":["../../../src/compiler/runtime/check-locale.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAK;IAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACvC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,UAAU,EAAE,CAAC;YACzC,OAAO,MAAM,CAAC;QACf,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAM;IAC9B,OAAO,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAK;IACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,IAAI,KAAK,CACd,mBAAmB,KAAK,sBAAsB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClE,CAAC;AACH,CAAC","sourcesContent":["import { locales } from \"./variables.js\";\n\n/**\n * Coerces a locale-like string to the canonical locale value used by the runtime.\n *\n * @param {unknown} value\n * @returns {Locale | undefined}\n */\nexport function toLocale(value) {\n\tif (typeof value !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst lowerValue = value.toLowerCase();\n\tfor (const locale of locales) {\n\t\tif (locale.toLowerCase() === lowerValue) {\n\t\t\treturn locale;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Check if something is an available locale with the canonical project casing.\n *\n * @example\n * if (isLocale(params.locale)) {\n * setLocale(params.locale);\n * } else {\n * setLocale('en');\n * }\n *\n * Use `toLocale()` when you want case-insensitive matching and canonicalization.\n *\n * @param {unknown} locale\n * @returns {locale is Locale}\n */\nexport function isLocale(locale) {\n\treturn !!locale && locales.some((item) => item === locale);\n}\n\n/**\n * Asserts that the input can be normalized to a locale.\n *\n * @param {unknown} input - The input to check.\n * @returns {Locale} The input normalized to a Locale.\n * @throws {Error} If the input is not a locale.\n */\nexport function assertIsLocale(input) {\n\tconst locale = toLocale(input);\n\tif (locale) return locale;\n\tthrow new Error(\n\t\t`Invalid locale: ${input}. Expected one of: ${locales.join(\", \")}`\n\t);\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-locale.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/check-locale.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,84 @@
1
+ import { expect, test } from "vitest";
2
+ import { createParaglide } from "../create-paraglide.js";
3
+ test("toLocale canonicalizes case-insensitive matches without throwing", async () => {
4
+ const runtime = await createParaglide({
5
+ baseLocale: "en",
6
+ locales: ["en", "pt-BR", "de-ch"],
7
+ });
8
+ expect(runtime.toLocale("EN")).toBe("en");
9
+ expect(runtime.toLocale("pT-bR")).toBe("pt-BR");
10
+ expect(runtime.toLocale("de-CH")).toBe("de-ch");
11
+ expect(runtime.toLocale("es")).toBeUndefined();
12
+ expect(runtime.toLocale(null)).toBeUndefined();
13
+ expect(runtime.toLocale(undefined)).toBeUndefined();
14
+ expect(runtime.toLocale(123)).toBeUndefined();
15
+ expect(runtime.toLocale({})).toBeUndefined();
16
+ });
17
+ test("isLocale still checks canonical locale casing", async () => {
18
+ const runtime = await createParaglide({
19
+ baseLocale: "en",
20
+ locales: ["en", "pt-BR", "de-ch"],
21
+ });
22
+ expect(runtime.isLocale("pt-BR")).toBe(true);
23
+ expect(runtime.isLocale("EN")).toBe(false);
24
+ expect(runtime.isLocale(null)).toBe(false);
25
+ });
26
+ test("isLocale returns false for non-existent locales", async () => {
27
+ const runtime = await createParaglide({
28
+ baseLocale: "en",
29
+ locales: ["en", "pt-BR", "de-ch"],
30
+ });
31
+ expect(runtime.isLocale("es")).toBe(false);
32
+ expect(runtime.isLocale("xx")).toBe(false);
33
+ expect(runtime.isLocale("")).toBe(false);
34
+ expect(runtime.isLocale(undefined)).toBe(false);
35
+ expect(runtime.isLocale(123)).toBe(false);
36
+ expect(runtime.isLocale({})).toBe(false);
37
+ expect(runtime.isLocale([])).toBe(false);
38
+ });
39
+ test("assertIsLocale throws if the locale is not available", async () => {
40
+ const runtime = await createParaglide({
41
+ baseLocale: "en",
42
+ locales: ["en", "de"],
43
+ });
44
+ expect(() => runtime.assertIsLocale("es")).toThrow();
45
+ });
46
+ test("assertIsLocale throws for non-string inputs", async () => {
47
+ const runtime = await createParaglide({
48
+ baseLocale: "en",
49
+ locales: ["en", "de"],
50
+ });
51
+ expect(() => runtime.assertIsLocale(null)).toThrow();
52
+ expect(() => runtime.assertIsLocale(undefined)).toThrow();
53
+ expect(() => runtime.assertIsLocale(123)).toThrow();
54
+ expect(() => runtime.assertIsLocale({})).toThrow();
55
+ expect(() => runtime.assertIsLocale([])).toThrow();
56
+ });
57
+ test("assertIsLocale passes if the locale is available", async () => {
58
+ const runtime = await createParaglide({
59
+ baseLocale: "en",
60
+ locales: ["en", "de"],
61
+ });
62
+ expect(() => runtime.assertIsLocale("en")).not.toThrow();
63
+ });
64
+ test("assertIsLocale return value is a Locale", async () => {
65
+ const runtime = await createParaglide({
66
+ baseLocale: "en",
67
+ locales: ["en", "de"],
68
+ });
69
+ const locale = runtime.assertIsLocale("en");
70
+ locale;
71
+ });
72
+ test("assertIsLocale is case-insensitive", async () => {
73
+ const runtime = await createParaglide({
74
+ baseLocale: "en",
75
+ locales: ["en", "pt-BR", "de-ch"],
76
+ });
77
+ expect(() => runtime.assertIsLocale("EN")).not.toThrow();
78
+ expect(() => runtime.assertIsLocale("pt-br")).not.toThrow();
79
+ expect(() => runtime.assertIsLocale("de-CH")).not.toThrow();
80
+ expect(runtime.assertIsLocale("EN")).toBe("en");
81
+ expect(runtime.assertIsLocale("pT-bR")).toBe("pt-BR");
82
+ expect(runtime.assertIsLocale("de-CH")).toBe("de-ch");
83
+ });
84
+ //# sourceMappingURL=check-locale.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-locale.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/check-locale.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,IAAI,CAAC,kEAAkE,EAAE,KAAK,IAAI,EAAE;IACnF,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;KACjC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,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AC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACzD,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAC5D,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAE5D,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\nimport type { Locale } from \"./type-definitions.js\";\n\ntest(\"toLocale canonicalizes case-insensitive matches without throwing\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"pt-BR\", \"de-ch\"],\n\t});\n\n\texpect(runtime.toLocale(\"EN\")).toBe(\"en\");\n\texpect(runtime.toLocale(\"pT-bR\")).toBe(\"pt-BR\");\n\texpect(runtime.toLocale(\"de-CH\")).toBe(\"de-ch\");\n\texpect(runtime.toLocale(\"es\")).toBeUndefined();\n\texpect(runtime.toLocale(null)).toBeUndefined();\n\texpect(runtime.toLocale(undefined)).toBeUndefined();\n\texpect(runtime.toLocale(123)).toBeUndefined();\n\texpect(runtime.toLocale({})).toBeUndefined();\n});\n\ntest(\"isLocale still checks canonical locale casing\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"pt-BR\", \"de-ch\"],\n\t});\n\n\texpect(runtime.isLocale(\"pt-BR\")).toBe(true);\n\texpect(runtime.isLocale(\"EN\")).toBe(false);\n\texpect(runtime.isLocale(null)).toBe(false);\n});\n\ntest(\"isLocale returns false for non-existent locales\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"pt-BR\", \"de-ch\"],\n\t});\n\n\texpect(runtime.isLocale(\"es\")).toBe(false);\n\texpect(runtime.isLocale(\"xx\")).toBe(false);\n\texpect(runtime.isLocale(\"\")).toBe(false);\n\texpect(runtime.isLocale(undefined)).toBe(false);\n\texpect(runtime.isLocale(123)).toBe(false);\n\texpect(runtime.isLocale({})).toBe(false);\n\texpect(runtime.isLocale([])).toBe(false);\n});\n\ntest(\"assertIsLocale throws if the locale is not available\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t});\n\n\texpect(() => runtime.assertIsLocale(\"es\")).toThrow();\n});\n\ntest(\"assertIsLocale throws for non-string inputs\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t});\n\n\texpect(() => runtime.assertIsLocale(null)).toThrow();\n\texpect(() => runtime.assertIsLocale(undefined)).toThrow();\n\texpect(() => runtime.assertIsLocale(123)).toThrow();\n\texpect(() => runtime.assertIsLocale({})).toThrow();\n\texpect(() => runtime.assertIsLocale([])).toThrow();\n});\n\ntest(\"assertIsLocale passes if the locale is available\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t});\n\n\texpect(() => runtime.assertIsLocale(\"en\")).not.toThrow();\n});\n\ntest(\"assertIsLocale return value is a Locale\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t});\n\n\tconst locale = runtime.assertIsLocale(\"en\");\n\tlocale satisfies Locale;\n});\n\ntest(\"assertIsLocale is case-insensitive\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"pt-BR\", \"de-ch\"],\n\t});\n\n\texpect(() => runtime.assertIsLocale(\"EN\")).not.toThrow();\n\texpect(() => runtime.assertIsLocale(\"pt-br\")).not.toThrow();\n\texpect(() => runtime.assertIsLocale(\"de-CH\")).not.toThrow();\n\n\texpect(runtime.assertIsLocale(\"EN\")).toBe(\"en\");\n\texpect(runtime.assertIsLocale(\"pT-bR\")).toBe(\"pt-BR\");\n\texpect(runtime.assertIsLocale(\"de-CH\")).toBe(\"de-ch\");\n});\n"]}
@@ -0,0 +1,35 @@
1
+ import type { CompilerOptions, RoutingConfig } from "../compiler-options.js";
2
+ type ResolvedHostRouting = Record<string, {
3
+ baseLocale: string;
4
+ locales: string[];
5
+ }>;
6
+ /**
7
+ * Normalize and validate host routing config for the generated runtime.
8
+ */
9
+ export declare function normalizeRouting(args: {
10
+ routing: RoutingConfig | undefined;
11
+ locales: string[];
12
+ baseLocale: string;
13
+ }): ResolvedHostRouting | undefined;
14
+ /**
15
+ * Returns the code for the `runtime.js` module
16
+ */
17
+ export declare function createRuntimeFile(args: {
18
+ baseLocale: string;
19
+ locales: string[];
20
+ compilerOptions: {
21
+ strategy: NonNullable<CompilerOptions["strategy"]>;
22
+ routeStrategies?: CompilerOptions["routeStrategies"];
23
+ cookieName: NonNullable<CompilerOptions["cookieName"]>;
24
+ cookieMaxAge: NonNullable<CompilerOptions["cookieMaxAge"]>;
25
+ cookieDomain: CompilerOptions["cookieDomain"];
26
+ urlPatterns?: CompilerOptions["urlPatterns"];
27
+ routing?: CompilerOptions["routing"];
28
+ experimentalMiddlewareLocaleSplitting: CompilerOptions["experimentalMiddlewareLocaleSplitting"];
29
+ isServer: CompilerOptions["isServer"];
30
+ experimentalStaticLocale?: CompilerOptions["experimentalStaticLocale"];
31
+ localStorageKey: CompilerOptions["localStorageKey"];
32
+ disableAsyncLocalStorage: NonNullable<CompilerOptions["disableAsyncLocalStorage"]>;
33
+ };
34
+ }): string;
35
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-runtime.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/create-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,eAAe,EACf,aAAa,EACb,MAAM,wBAAwB,CAAC;AAGhC,KAAK,mBAAmB,GAAG,MAAM,CAChC,MAAM,EACN;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CACzC,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACtC,OAAO,EAAE,aAAa,GAAG,SAAS,CAAC;IACnC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACnB,GAAG,mBAAmB,GAAG,SAAS,CA6ClC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE;QAChB,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;QACnD,eAAe,CAAC,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;QACrD,UAAU,EAAE,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;QACvD,YAAY,EAAE,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAAC;QAC3D,YAAY,EAAE,eAAe,CAAC,cAAc,CAAC,CAAC;QAC9C,WAAW,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;QAC7C,OAAO,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;QACrC,qCAAqC,EAAE,eAAe,CAAC,uCAAuC,CAAC,CAAC;QAChG,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;QACtC,wBAAwB,CAAC,EAAE,eAAe,CAAC,0BAA0B,CAAC,CAAC;QACvE,eAAe,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;QACpD,wBAAwB,EAAE,WAAW,CACpC,eAAe,CAAC,0BAA0B,CAAC,CAC3C,CAAC;KACF,CAAC;CACF,GAAG,MAAM,CA4NT"}
@@ -0,0 +1,196 @@
1
+ import fs from "node:fs";
2
+ import { perLocaleBuildStaticLocaleExpression } from "../per-locale-build.js";
3
+ /**
4
+ * Normalize and validate host routing config for the generated runtime.
5
+ */
6
+ export function normalizeRouting(args) {
7
+ if (args.routing === undefined) {
8
+ return undefined;
9
+ }
10
+ const resolved = {};
11
+ for (const [hostname, rule] of Object.entries(args.routing)) {
12
+ const hostBaseLocale = rule.baseLocale ?? args.baseLocale;
13
+ const hostLocales = rule.locales ?? [...args.locales];
14
+ if (!args.locales.includes(hostBaseLocale)) {
15
+ throw new Error(`Invalid baseLocale "${hostBaseLocale}" in routing["${hostname}"]. It must be one of the locales defined in the "locales" array.`);
16
+ }
17
+ for (const locale of hostLocales) {
18
+ if (!args.locales.includes(locale)) {
19
+ throw new Error(`Invalid locale "${locale}" in routing["${hostname}"].locales. It must be one of the locales defined in the "locales" array.`);
20
+ }
21
+ }
22
+ if (!hostLocales.includes(hostBaseLocale)) {
23
+ throw new Error(`routing["${hostname}"].baseLocale "${hostBaseLocale}" must be included in routing["${hostname}"].locales.`);
24
+ }
25
+ resolved[hostname] = {
26
+ baseLocale: hostBaseLocale,
27
+ locales: hostLocales,
28
+ };
29
+ }
30
+ if (resolved["*"] === undefined) {
31
+ resolved["*"] = {
32
+ baseLocale: args.baseLocale,
33
+ locales: [...args.locales],
34
+ };
35
+ }
36
+ return resolved;
37
+ }
38
+ /**
39
+ * Returns the code for the `runtime.js` module
40
+ */
41
+ export function createRuntimeFile(args) {
42
+ if (args.compilerOptions.routing !== undefined &&
43
+ args.compilerOptions.urlPatterns !== undefined) {
44
+ throw new Error(`Cannot set both "routing" and "urlPatterns". Use "routing" for per-host locale prefixes, or "urlPatterns" for custom URLPattern rules.`);
45
+ }
46
+ const hostRouting = normalizeRouting({
47
+ routing: args.compilerOptions.routing,
48
+ locales: args.locales,
49
+ baseLocale: args.baseLocale,
50
+ });
51
+ const hostRoutingUsed = hostRouting !== undefined;
52
+ const urlPatterns = args.compilerOptions.urlPatterns ?? [];
53
+ const routeStrategies = args.compilerOptions.routeStrategies ?? [];
54
+ let defaultUrlPatternUsed = false;
55
+ // Default string-prefix router when neither routing nor custom urlPatterns are set.
56
+ if (!hostRoutingUsed &&
57
+ args.compilerOptions.urlPatterns === undefined) {
58
+ defaultUrlPatternUsed = true;
59
+ urlPatterns.push({
60
+ pattern: `:protocol://:domain(.*)::port?/:path(.*)?`,
61
+ localized: [],
62
+ });
63
+ for (const locale of args.locales) {
64
+ if (locale === args.baseLocale) {
65
+ continue;
66
+ }
67
+ urlPatterns[0]?.localized.push([
68
+ locale,
69
+ `:protocol://:domain(.*)::port?/${locale}/:path(.*)?`,
70
+ ]);
71
+ }
72
+ urlPatterns[0]?.localized.push([
73
+ args.baseLocale,
74
+ `:protocol://:domain(.*)::port?/:path(.*)?`,
75
+ ]);
76
+ }
77
+ const strategiesUsedByRoutes = routeStrategies.flatMap((routeStrategy) => "strategy" in routeStrategy ? routeStrategy.strategy : []);
78
+ const allUsedStrategies = new Set([
79
+ ...args.compilerOptions.strategy,
80
+ ...strategiesUsedByRoutes,
81
+ ]);
82
+ // verify that urlPatterns' locales are valid
83
+ for (const urlPattern of urlPatterns) {
84
+ for (const [locale] of urlPattern.localized) {
85
+ if (!args.locales.includes(locale)) {
86
+ throw new Error(`Invalid locale "${locale}" in urlPatterns. It must be one of the locales defined in the "locales" array.`);
87
+ }
88
+ }
89
+ }
90
+ const code = `
91
+ ${injectCode("./variables.js")
92
+ .replace(`export const baseLocale = "en";`, `export const baseLocale = "${args.baseLocale}";`)
93
+ .replace(`export const locales = /** @type {readonly string[]} */ (["en", "de"]);`, `export const locales = /** @type {const} */ (${JSON.stringify(args.locales)});`)
94
+ .replace(`export const strategy = ["globalVariable"];`, `export const strategy = ${JSON.stringify(args.compilerOptions.strategy, null, 2)};`)
95
+ .replace(`<cookie-name>`, `${args.compilerOptions.cookieName}`)
96
+ .replace(`60 * 60 * 24 * 400`, `${args.compilerOptions.cookieMaxAge}`)
97
+ .replace(`<cookie-domain>`, `${args.compilerOptions.cookieDomain}`)
98
+ .replace(`export const routeStrategies = [];`, `export const routeStrategies = ${JSON.stringify(routeStrategies, null, 2)};`)
99
+ .replace(`export const TREE_SHAKE_COOKIE_STRATEGY_USED = false;`, `const TREE_SHAKE_COOKIE_STRATEGY_USED = ${allUsedStrategies.has("cookie")};`)
100
+ .replace(`export const TREE_SHAKE_URL_STRATEGY_USED = false;`, `const TREE_SHAKE_URL_STRATEGY_USED = ${allUsedStrategies.has("url")};`)
101
+ .replace(`export const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;`, `const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = ${allUsedStrategies.has("globalVariable")};`)
102
+ .replace(`export const TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = false;`, `const TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = ${allUsedStrategies.has("preferredLanguage")};`)
103
+ .replace(`export const urlPatterns = [];`, `export const urlPatterns = ${JSON.stringify(urlPatterns, null, 2)};`)
104
+ .replace(`export const routing = {};`, `export const routing = ${JSON.stringify(hostRouting ?? {}, null, 2)};`)
105
+ .replace(`export const disableAsyncLocalStorage = false;`, `export const disableAsyncLocalStorage = ${args.compilerOptions.disableAsyncLocalStorage};`)
106
+ .replace(`export const TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;`, `const TREE_SHAKE_DEFAULT_URL_PATTERN_USED = ${defaultUrlPatternUsed};`)
107
+ .replace(`export const TREE_SHAKE_HOST_ROUTING_USED = false;`, `const TREE_SHAKE_HOST_ROUTING_USED = ${hostRoutingUsed};`)
108
+ .replace(`export const experimentalMiddlewareLocaleSplitting = false;`, `export const experimentalMiddlewareLocaleSplitting = ${args.compilerOptions.experimentalMiddlewareLocaleSplitting};`)
109
+ .replace(`export const isServer = typeof window === "undefined";`, `export const isServer = ${args.compilerOptions.isServer};`)
110
+ .replace(`export const experimentalStaticLocale = undefined;`, args.compilerOptions.experimentalStaticLocale
111
+ ? `export const experimentalStaticLocale = ${args.compilerOptions.experimentalStaticLocale ===
112
+ perLocaleBuildStaticLocaleExpression
113
+ ? args.compilerOptions.experimentalStaticLocale
114
+ : `assertIsLocale(${args.compilerOptions.experimentalStaticLocale})`};`
115
+ : `export const experimentalStaticLocale = undefined;`)
116
+ .replace(`export const localStorageKey = "PARAGLIDE_LOCALE";`, `export const localStorageKey = "${args.compilerOptions.localStorageKey}";`)
117
+ .replace(`export const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;`, `const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = ${allUsedStrategies.has("localStorage")};`)}
118
+
119
+ /** @type {any} */ (globalThis).__paraglide =
120
+ /** @type {any} */ (globalThis).__paraglide ?? {};
121
+ /** @type {any} */ (globalThis).__paraglide.ssr =
122
+ /** @type {any} */ (globalThis).__paraglide.ssr ?? {};
123
+
124
+ ${injectCode("./get-locale.js")}
125
+
126
+ ${injectCode("./get-text-direction.js")}
127
+
128
+ ${injectCode("./set-locale.js")}
129
+
130
+ ${injectCode("./get-url-origin.js")}
131
+
132
+ ${injectCode("./check-locale.js")}
133
+
134
+ ${injectCode("./extract-locale-from-request.js")}
135
+
136
+ ${injectCode("./extract-locale-from-request-async.js")}
137
+
138
+ ${injectCode("./extract-locale-from-cookie.js", {
139
+ privateExports: ["clearLocaleCookieCache"],
140
+ })}
141
+
142
+ ${injectCode("./extract-locale-from-header.js")}
143
+
144
+ ${injectCode("./extract-locale-from-navigator.js")}
145
+
146
+ ${injectCode("./url-pattern.js")}
147
+
148
+ ${injectCode("./host-routing.js")}
149
+
150
+ ${injectCode("./extract-locale-from-url.js")}
151
+
152
+ ${injectCode("./localize-url.js")}
153
+
154
+ ${injectCode("./route-strategy.js")}
155
+
156
+ ${injectCode("./should-redirect.js")}
157
+
158
+ ${injectCode("./localize-href.js")}
159
+
160
+ ${injectCode("./track-message-call.js")}
161
+
162
+ ${injectCode("./generate-static-localized-urls.js")}
163
+
164
+ ${injectCode("./strategy.js")}
165
+
166
+ ${injectCode("./type-definitions.js").replace(`@typedef {string} Locale`, `@typedef {typeof locales[number]} Locale`)}
167
+ `;
168
+ return code;
169
+ }
170
+ /**
171
+ * Load a file from the current directory.
172
+ *
173
+ * Prunes the imports on top of the file as the runtime is
174
+ * self-contained.
175
+ *
176
+ * @param {string} path
177
+ * @param {{ privateExports?: string[] }} [options]
178
+ * @returns {string}
179
+ */
180
+ function injectCode(path, options) {
181
+ const code = fs.readFileSync(new URL(path, import.meta.url), "utf-8");
182
+ // Regex to match single-line and multi-line imports
183
+ const importRegex = /import\s+[\s\S]*?from\s+['"][^'"]+['"]\s*;?/g;
184
+ const sourceMapRegex = /\/\/# sourceMappingURL=.*$/gm;
185
+ const blockSourceMapRegex = /\/\*# sourceMappingURL=.*?\*\//g;
186
+ let injected = code
187
+ .replace(importRegex, "")
188
+ .replace(sourceMapRegex, "")
189
+ .replace(blockSourceMapRegex, "")
190
+ .trim();
191
+ for (const exportName of options?.privateExports ?? []) {
192
+ injected = injected.replace(new RegExp(`\\bexport\\s+function\\s+${exportName}\\b`, "g"), `function ${exportName}`);
193
+ }
194
+ return injected;
195
+ }
196
+ //# sourceMappingURL=create-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-runtime.js","sourceRoot":"","sources":["../../../src/compiler/runtime/create-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAKzB,OAAO,EAAE,oCAAoC,EAAE,MAAM,wBAAwB,CAAC;AAO9E;;GAEG;AACH,MAAM,UAAU,gBAAgB,C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CAC5C,0BAA0B,EAC1B,0CAA0C,CAC1C;CACA,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,UAAU,CAClB,IAAY,EACZ,OAAuC;IAEvC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IACtE,oDAAoD;IACpD,MAAM,WAAW,GAAG,8CAA8C,CAAC;IACnE,MAAM,cAAc,GAAG,8BAA8B,CAAC;IACtD,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;IAC9D,IAAI,QAAQ,GAAG,IAAI;SACjB,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,IAAI,EAAE,CAAC;IACT,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,cAAc,IAAI,EAAE,EAAE,CAAC;QACxD,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAC1B,IAAI,MAAM,CAAC,4BAA4B,UAAU,KAAK,EAAE,GAAG,CAAC,EAC5D,YAAY,UAAU,EAAE,CACxB,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport type {\n\tCompilerOptions,\n\tRoutingConfig,\n} from \"../compiler-options.js\";\nimport { perLocaleBuildStaticLocaleExpression } from \"../per-locale-build.js\";\n\ntype ResolvedHostRouting = Record<\n\tstring,\n\t{ baseLocale: string; locales: string[] }\n>;\n\n/**\n * Normalize and validate host routing config for the generated runtime.\n */\nexport function normalizeRouting(args: {\n\trouting: RoutingConfig | undefined;\n\tlocales: string[];\n\tbaseLocale: string;\n}): ResolvedHostRouting | undefined {\n\tif (args.routing === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst resolved: ResolvedHostRouting = {};\n\n\tfor (const [hostname, rule] of Object.entries(args.routing)) {\n\t\tconst hostBaseLocale = rule.baseLocale ?? args.baseLocale;\n\t\tconst hostLocales = rule.locales ?? [...args.locales];\n\n\t\tif (!args.locales.includes(hostBaseLocale)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid baseLocale \"${hostBaseLocale}\" in routing[\"${hostname}\"]. It must be one of the locales defined in the \"locales\" array.`\n\t\t\t);\n\t\t}\n\n\t\tfor (const locale of hostLocales) {\n\t\t\tif (!args.locales.includes(locale)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid locale \"${locale}\" in routing[\"${hostname}\"].locales. It must be one of the locales defined in the \"locales\" array.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!hostLocales.includes(hostBaseLocale)) {\n\t\t\tthrow new Error(\n\t\t\t\t`routing[\"${hostname}\"].baseLocale \"${hostBaseLocale}\" must be included in routing[\"${hostname}\"].locales.`\n\t\t\t);\n\t\t}\n\n\t\tresolved[hostname] = {\n\t\t\tbaseLocale: hostBaseLocale,\n\t\t\tlocales: hostLocales,\n\t\t};\n\t}\n\n\tif (resolved[\"*\"] === undefined) {\n\t\tresolved[\"*\"] = {\n\t\t\tbaseLocale: args.baseLocale,\n\t\t\tlocales: [...args.locales],\n\t\t};\n\t}\n\n\treturn resolved;\n}\n\n/**\n * Returns the code for the `runtime.js` module\n */\nexport function createRuntimeFile(args: {\n\tbaseLocale: string;\n\tlocales: string[];\n\tcompilerOptions: {\n\t\tstrategy: NonNullable<CompilerOptions[\"strategy\"]>;\n\t\trouteStrategies?: CompilerOptions[\"routeStrategies\"];\n\t\tcookieName: NonNullable<CompilerOptions[\"cookieName\"]>;\n\t\tcookieMaxAge: NonNullable<CompilerOptions[\"cookieMaxAge\"]>;\n\t\tcookieDomain: CompilerOptions[\"cookieDomain\"];\n\t\turlPatterns?: CompilerOptions[\"urlPatterns\"];\n\t\trouting?: CompilerOptions[\"routing\"];\n\t\texperimentalMiddlewareLocaleSplitting: CompilerOptions[\"experimentalMiddlewareLocaleSplitting\"];\n\t\tisServer: CompilerOptions[\"isServer\"];\n\t\texperimentalStaticLocale?: CompilerOptions[\"experimentalStaticLocale\"];\n\t\tlocalStorageKey: CompilerOptions[\"localStorageKey\"];\n\t\tdisableAsyncLocalStorage: NonNullable<\n\t\t\tCompilerOptions[\"disableAsyncLocalStorage\"]\n\t\t>;\n\t};\n}): string {\n\tif (\n\t\targs.compilerOptions.routing !== undefined &&\n\t\targs.compilerOptions.urlPatterns !== undefined\n\t) {\n\t\tthrow new Error(\n\t\t\t`Cannot set both \"routing\" and \"urlPatterns\". Use \"routing\" for per-host locale prefixes, or \"urlPatterns\" for custom URLPattern rules.`\n\t\t);\n\t}\n\n\tconst hostRouting = normalizeRouting({\n\t\trouting: args.compilerOptions.routing,\n\t\tlocales: args.locales,\n\t\tbaseLocale: args.baseLocale,\n\t});\n\tconst hostRoutingUsed = hostRouting !== undefined;\n\n\tconst urlPatterns = args.compilerOptions.urlPatterns ?? [];\n\tconst routeStrategies = args.compilerOptions.routeStrategies ?? [];\n\n\tlet defaultUrlPatternUsed = false;\n\n\t// Default string-prefix router when neither routing nor custom urlPatterns are set.\n\tif (\n\t\t!hostRoutingUsed &&\n\t\targs.compilerOptions.urlPatterns === undefined\n\t) {\n\t\tdefaultUrlPatternUsed = true;\n\t\turlPatterns.push({\n\t\t\tpattern: `:protocol://:domain(.*)::port?/:path(.*)?`,\n\t\t\tlocalized: [],\n\t\t});\n\t\tfor (const locale of args.locales) {\n\t\t\tif (locale === args.baseLocale) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\turlPatterns[0]?.localized.push([\n\t\t\t\tlocale,\n\t\t\t\t`:protocol://:domain(.*)::port?/${locale}/:path(.*)?`,\n\t\t\t]);\n\t\t}\n\t\turlPatterns[0]?.localized.push([\n\t\t\targs.baseLocale,\n\t\t\t`:protocol://:domain(.*)::port?/:path(.*)?`,\n\t\t]);\n\t}\n\tconst strategiesUsedByRoutes = routeStrategies.flatMap((routeStrategy) =>\n\t\t\"strategy\" in routeStrategy ? routeStrategy.strategy : []\n\t);\n\tconst allUsedStrategies = new Set([\n\t\t...args.compilerOptions.strategy,\n\t\t...strategiesUsedByRoutes,\n\t]);\n\t// verify that urlPatterns' locales are valid\n\tfor (const urlPattern of urlPatterns) {\n\t\tfor (const [locale] of urlPattern.localized) {\n\t\t\tif (!args.locales.includes(locale)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid locale \"${locale}\" in urlPatterns. It must be one of the locales defined in the \"locales\" array.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst code = `\n${injectCode(\"./variables.js\")\n\t.replace(\n\t\t`export const baseLocale = \"en\";`,\n\t\t`export const baseLocale = \"${args.baseLocale}\";`\n\t)\n\t.replace(\n\t\t`export const locales = /** @type {readonly string[]} */ ([\"en\", \"de\"]);`,\n\t\t`export const locales = /** @type {const} */ (${JSON.stringify(args.locales)});`\n\t)\n\t.replace(\n\t\t`export const strategy = [\"globalVariable\"];`,\n\t\t`export const strategy = ${JSON.stringify(args.compilerOptions.strategy, null, 2)};`\n\t)\n\t.replace(`<cookie-name>`, `${args.compilerOptions.cookieName}`)\n\t.replace(`60 * 60 * 24 * 400`, `${args.compilerOptions.cookieMaxAge}`)\n\t.replace(`<cookie-domain>`, `${args.compilerOptions.cookieDomain}`)\n\t.replace(\n\t\t`export const routeStrategies = [];`,\n\t\t`export const routeStrategies = ${JSON.stringify(routeStrategies, null, 2)};`\n\t)\n\t.replace(\n\t\t`export const TREE_SHAKE_COOKIE_STRATEGY_USED = false;`,\n\t\t`const TREE_SHAKE_COOKIE_STRATEGY_USED = ${allUsedStrategies.has(\"cookie\")};`\n\t)\n\t.replace(\n\t\t`export const TREE_SHAKE_URL_STRATEGY_USED = false;`,\n\t\t`const TREE_SHAKE_URL_STRATEGY_USED = ${allUsedStrategies.has(\"url\")};`\n\t)\n\t.replace(\n\t\t`export const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;`,\n\t\t`const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = ${allUsedStrategies.has(\"globalVariable\")};`\n\t)\n\t.replace(\n\t\t`export const TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = false;`,\n\t\t`const TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = ${allUsedStrategies.has(\"preferredLanguage\")};`\n\t)\n\t.replace(\n\t\t`export const urlPatterns = [];`,\n\t\t`export const urlPatterns = ${JSON.stringify(urlPatterns, null, 2)};`\n\t)\n\t.replace(\n\t\t`export const routing = {};`,\n\t\t`export const routing = ${JSON.stringify(hostRouting ?? {}, null, 2)};`\n\t)\n\t.replace(\n\t\t`export const disableAsyncLocalStorage = false;`,\n\t\t`export const disableAsyncLocalStorage = ${args.compilerOptions.disableAsyncLocalStorage};`\n\t)\n\t.replace(\n\t\t`export const TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;`,\n\t\t`const TREE_SHAKE_DEFAULT_URL_PATTERN_USED = ${defaultUrlPatternUsed};`\n\t)\n\t.replace(\n\t\t`export const TREE_SHAKE_HOST_ROUTING_USED = false;`,\n\t\t`const TREE_SHAKE_HOST_ROUTING_USED = ${hostRoutingUsed};`\n\t)\n\t.replace(\n\t\t`export const experimentalMiddlewareLocaleSplitting = false;`,\n\t\t`export const experimentalMiddlewareLocaleSplitting = ${args.compilerOptions.experimentalMiddlewareLocaleSplitting};`\n\t)\n\t.replace(\n\t\t`export const isServer = typeof window === \"undefined\";`,\n\t\t`export const isServer = ${args.compilerOptions.isServer};`\n\t)\n\t.replace(\n\t\t`export const experimentalStaticLocale = undefined;`,\n\t\targs.compilerOptions.experimentalStaticLocale\n\t\t\t? `export const experimentalStaticLocale = ${\n\t\t\t\t\targs.compilerOptions.experimentalStaticLocale ===\n\t\t\t\t\tperLocaleBuildStaticLocaleExpression\n\t\t\t\t\t\t? args.compilerOptions.experimentalStaticLocale\n\t\t\t\t\t\t: `assertIsLocale(${args.compilerOptions.experimentalStaticLocale})`\n\t\t\t\t};`\n\t\t\t: `export const experimentalStaticLocale = undefined;`\n\t)\n\t.replace(\n\t\t`export const localStorageKey = \"PARAGLIDE_LOCALE\";`,\n\t\t`export const localStorageKey = \"${args.compilerOptions.localStorageKey}\";`\n\t)\n\t.replace(\n\t\t`export const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;`,\n\t\t`const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = ${allUsedStrategies.has(\"localStorage\")};`\n\t)}\n\n/** @type {any} */ (globalThis).__paraglide =\n\t/** @type {any} */ (globalThis).__paraglide ?? {};\n/** @type {any} */ (globalThis).__paraglide.ssr =\n\t/** @type {any} */ (globalThis).__paraglide.ssr ?? {};\n\n${injectCode(\"./get-locale.js\")}\n\n${injectCode(\"./get-text-direction.js\")}\n\n${injectCode(\"./set-locale.js\")}\n\n${injectCode(\"./get-url-origin.js\")}\n\n${injectCode(\"./check-locale.js\")}\n\n${injectCode(\"./extract-locale-from-request.js\")}\n\n${injectCode(\"./extract-locale-from-request-async.js\")}\n\n${injectCode(\"./extract-locale-from-cookie.js\", {\n\tprivateExports: [\"clearLocaleCookieCache\"],\n})}\n\n${injectCode(\"./extract-locale-from-header.js\")}\n\n${injectCode(\"./extract-locale-from-navigator.js\")}\n\n${injectCode(\"./url-pattern.js\")}\n\n${injectCode(\"./host-routing.js\")}\n\n${injectCode(\"./extract-locale-from-url.js\")}\n\n${injectCode(\"./localize-url.js\")}\n\n${injectCode(\"./route-strategy.js\")}\n\n${injectCode(\"./should-redirect.js\")}\n\n${injectCode(\"./localize-href.js\")}\n\n${injectCode(\"./track-message-call.js\")}\n\n${injectCode(\"./generate-static-localized-urls.js\")}\n\n${injectCode(\"./strategy.js\")}\n\n${injectCode(\"./type-definitions.js\").replace(\n\t`@typedef {string} Locale`,\n\t`@typedef {typeof locales[number]} Locale`\n)}\n`;\n\n\treturn code;\n}\n\n/**\n * Load a file from the current directory.\n *\n * Prunes the imports on top of the file as the runtime is\n * self-contained.\n *\n * @param {string} path\n * @param {{ privateExports?: string[] }} [options]\n * @returns {string}\n */\nfunction injectCode(\n\tpath: string,\n\toptions?: { privateExports?: string[] }\n): string {\n\tconst code = fs.readFileSync(new URL(path, import.meta.url), \"utf-8\");\n\t// Regex to match single-line and multi-line imports\n\tconst importRegex = /import\\s+[\\s\\S]*?from\\s+['\"][^'\"]+['\"]\\s*;?/g;\n\tconst sourceMapRegex = /\\/\\/# sourceMappingURL=.*$/gm;\n\tconst blockSourceMapRegex = /\\/\\*# sourceMappingURL=.*?\\*\\//g;\n\tlet injected = code\n\t\t.replace(importRegex, \"\")\n\t\t.replace(sourceMapRegex, \"\")\n\t\t.replace(blockSourceMapRegex, \"\")\n\t\t.trim();\n\tfor (const exportName of options?.privateExports ?? []) {\n\t\tinjected = injected.replace(\n\t\t\tnew RegExp(`\\\\bexport\\\\s+function\\\\s+${exportName}\\\\b`, \"g\"),\n\t\t\t`function ${exportName}`\n\t\t);\n\t}\n\treturn injected;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Clears the cached locale from `document.cookie`.
3
+ */
4
+ export declare function clearLocaleCookieCache(): void;
5
+ /**
6
+ * Extracts a cookie from the document.
7
+ *
8
+ * Will return undefined if the document is not available or if the cookie is not set.
9
+ * The `document` object is not available in server-side rendering, so this function should not be called in that context.
10
+ *
11
+ * @returns {Locale | undefined}
12
+ */
13
+ export declare function extractLocaleFromCookie(): Locale | undefined;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-locale-from-cookie.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/extract-locale-from-cookie.js"],"names":[],"mappings":"AAYA;;GAEG;AACH,wBAAgB,sBAAsB,SAErC;AAUD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,IAF1B,MAAM,GAAG,SAAS,CAc9B"}