@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,81 @@
1
+ import { toSafeModuleId } from "../safe-module-id.js";
2
+ import { inputsType } from "../jsdoc-types.js";
3
+ import { toBundleInputTypeAliasName } from "../compile-bundle.js";
4
+ const localeImportPrefix = "__";
5
+ export function messageReferenceExpression(locale, bundleId) {
6
+ return `${localeImportPrefix}${toSafeModuleId(locale)}.${toSafeModuleId(bundleId)}`;
7
+ }
8
+ export function generateOutput(compiledBundles, settings, fallbackMap, experimentalMiddlewareLocaleSplitting = false) {
9
+ const runtimeImport = experimentalMiddlewareLocaleSplitting
10
+ ? `import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer, experimentalStaticLocale } from "../runtime.js"`
11
+ : `import { getLocale, experimentalStaticLocale } from "../runtime.js"`;
12
+ const indexFile = [
13
+ runtimeImport,
14
+ "",
15
+ `/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */`,
16
+ ...compiledBundles.map((compiledBundle) => {
17
+ const bundleModuleId = toSafeModuleId(compiledBundle.bundle.node.id);
18
+ const inputTypeAliasName = compiledBundle.inputTypeAliasName ??
19
+ toBundleInputTypeAliasName(bundleModuleId);
20
+ const inputs = compiledBundle.bundle.node.declarations?.filter((decl) => decl.type === "input-variable") ?? [];
21
+ return `/** @typedef {${inputsType(inputs, compiledBundle.matchTypes)}} ${inputTypeAliasName} */`;
22
+ }),
23
+ settings.locales
24
+ .map((locale) => `import * as ${localeImportPrefix}${toSafeModuleId(locale)} from "./${locale}.js"`)
25
+ .join("\n"),
26
+ compiledBundles.map(({ bundle }) => bundle.code).join("\n"),
27
+ ].join("\n");
28
+ const output = {
29
+ ["messages/_index.js"]: indexFile,
30
+ };
31
+ // generate message files
32
+ for (const locale of settings.locales) {
33
+ const filename = `messages/${locale}.js`;
34
+ let file = "";
35
+ const inputTypeDefs = [];
36
+ const emittedInputTypeDefs = new Set();
37
+ for (const compiledBundle of compiledBundles) {
38
+ const compiledMessage = compiledBundle.messages[locale];
39
+ const bundleModuleId = toSafeModuleId(compiledBundle.bundle.node.id);
40
+ const bundleId = compiledBundle.bundle.node.id;
41
+ const inputs = compiledBundle.bundle.node.declarations?.filter((decl) => decl.type === "input-variable") ?? [];
42
+ const matchTypes = compiledBundle.matchTypes;
43
+ const inputTypeAliasName = compiledBundle.inputTypeAliasName ??
44
+ toBundleInputTypeAliasName(bundleModuleId);
45
+ if (!emittedInputTypeDefs.has(inputTypeAliasName)) {
46
+ inputTypeDefs.push(`/** @typedef {${inputsType(inputs, matchTypes)}} ${inputTypeAliasName} */`);
47
+ emittedInputTypeDefs.add(inputTypeAliasName);
48
+ }
49
+ if (!compiledMessage) {
50
+ const fallbackLocale = fallbackMap[locale];
51
+ if (fallbackLocale) {
52
+ // use the fall back locale e.g. render the message in English if the German message is missing
53
+ file += `\nexport { ${bundleModuleId} } from "./${fallbackLocale}.js"`;
54
+ }
55
+ else {
56
+ // no fallback exists, render the bundleId
57
+ file += `\n/** @type {(inputs: ${inputTypeAliasName}) => LocalizedString} */\nexport const ${bundleModuleId} = () => /** @type {LocalizedString} */ ('${bundleId}')`;
58
+ }
59
+ continue;
60
+ }
61
+ file += `\n\nexport const ${bundleModuleId} = ${compiledMessage.code}`;
62
+ }
63
+ // add import if used
64
+ if (file.includes("registry.")) {
65
+ file = `import * as registry from "../registry.js"\n` + file;
66
+ }
67
+ // add LocalizedString typedef reference if used
68
+ if (file.includes("LocalizedString")) {
69
+ const inputTypeDefsBlock = inputTypeDefs.length
70
+ ? `${inputTypeDefs.join("\n")}\n`
71
+ : "";
72
+ file =
73
+ `/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */\n` +
74
+ inputTypeDefsBlock +
75
+ file;
76
+ }
77
+ output[filename] = file;
78
+ }
79
+ return output;
80
+ }
81
+ //# sourceMappingURL=locale-modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-modules.js","sourceRoot":"","sources":["../../../src/compiler/output-structure/locale-modules.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,MAAM,UAAU,0BAA0B,CAAC,MAAc,EAAE,QAAgB;IAC1E,OAAO,GAAG,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,cAAc,CAC7B,eAA6C,EAC7C,QAA2D,EAC3D,WAA+C,EAC/C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kB,0CAA0C,cAAc,6CAA6C,QAAQ,IAAI,CAAC;gBACtK,CAAC;gBACD,SAAS;YACV,CAAC;YAED,IAAI,IAAI,oBAAoB,cAAc,MAAM,eAAe,CAAC,IAAI,EAAE,CAAC;QACxE,CAAC;QAED,qBAAqB;QACrB,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,IAAI,GAAG,8CAA8C,GAAG,IAAI,CAAC;QAC9D,CAAC;QAED,gDAAgD;QAChD,IAAI,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACtC,MAAM,kBAAkB,GAAG,aAAa,CAAC,MAAM;gBAC9C,CAAC,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;gBACjC,CAAC,CAAC,EAAE,CAAC;YACN,IAAI;gBACH,6EAA6E;oBAC7E,kBAAkB;oBAClB,IAAI,CAAC;QACP,CAAC;QAED,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import type { ParaglideSettings } from \"../../messages/ast.js\";\nimport type { CompiledBundleWithMessages } from \"../compile-bundle.js\";\nimport { toSafeModuleId } from \"../safe-module-id.js\";\nimport { inputsType } from \"../jsdoc-types.js\";\nimport { toBundleInputTypeAliasName } from \"../compile-bundle.js\";\n\nconst localeImportPrefix = \"__\";\n\nexport function messageReferenceExpression(locale: string, bundleId: string) {\n\treturn `${localeImportPrefix}${toSafeModuleId(locale)}.${toSafeModuleId(bundleId)}`;\n}\n\nexport function generateOutput(\n\tcompiledBundles: CompiledBundleWithMessages[],\n\tsettings: Pick<ParaglideSettings, \"locales\" | \"baseLocale\">,\n\tfallbackMap: Record<string, string | undefined>,\n\texperimentalMiddlewareLocaleSplitting = false\n): Record<string, string> {\n\tconst runtimeImport = experimentalMiddlewareLocaleSplitting\n\t\t? `import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer, experimentalStaticLocale } from \"../runtime.js\"`\n\t\t: `import { getLocale, experimentalStaticLocale } from \"../runtime.js\"`;\n\n\tconst indexFile = [\n\t\truntimeImport,\n\t\t\"\",\n\t\t`/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */`,\n\t\t...compiledBundles.map((compiledBundle) => {\n\t\t\tconst bundleModuleId = toSafeModuleId(compiledBundle.bundle.node.id);\n\t\t\tconst inputTypeAliasName =\n\t\t\t\tcompiledBundle.inputTypeAliasName ??\n\t\t\t\ttoBundleInputTypeAliasName(bundleModuleId);\n\t\t\tconst inputs =\n\t\t\t\tcompiledBundle.bundle.node.declarations?.filter(\n\t\t\t\t\t(decl) => decl.type === \"input-variable\"\n\t\t\t\t) ?? [];\n\t\t\treturn `/** @typedef {${inputsType(inputs, compiledBundle.matchTypes)}} ${inputTypeAliasName} */`;\n\t\t}),\n\t\tsettings.locales\n\t\t\t.map(\n\t\t\t\t(locale) =>\n\t\t\t\t\t`import * as ${localeImportPrefix}${toSafeModuleId(locale)} from \"./${locale}.js\"`\n\t\t\t)\n\t\t\t.join(\"\\n\"),\n\t\tcompiledBundles.map(({ bundle }) => bundle.code).join(\"\\n\"),\n\t].join(\"\\n\");\n\n\tconst output: Record<string, string> = {\n\t\t[\"messages/_index.js\"]: indexFile,\n\t};\n\n\t// generate message files\n\tfor (const locale of settings.locales) {\n\t\tconst filename = `messages/${locale}.js`;\n\t\tlet file = \"\";\n\t\tconst inputTypeDefs: string[] = [];\n\t\tconst emittedInputTypeDefs = new Set<string>();\n\n\t\tfor (const compiledBundle of compiledBundles) {\n\t\t\tconst compiledMessage = compiledBundle.messages[locale];\n\t\t\tconst bundleModuleId = toSafeModuleId(compiledBundle.bundle.node.id);\n\t\t\tconst bundleId = compiledBundle.bundle.node.id;\n\t\t\tconst inputs =\n\t\t\t\tcompiledBundle.bundle.node.declarations?.filter(\n\t\t\t\t\t(decl) => decl.type === \"input-variable\"\n\t\t\t\t) ?? [];\n\t\t\tconst matchTypes = compiledBundle.matchTypes;\n\t\t\tconst inputTypeAliasName =\n\t\t\t\tcompiledBundle.inputTypeAliasName ??\n\t\t\t\ttoBundleInputTypeAliasName(bundleModuleId);\n\t\t\tif (!emittedInputTypeDefs.has(inputTypeAliasName)) {\n\t\t\t\tinputTypeDefs.push(\n\t\t\t\t\t`/** @typedef {${inputsType(inputs, matchTypes)}} ${inputTypeAliasName} */`\n\t\t\t\t);\n\t\t\t\temittedInputTypeDefs.add(inputTypeAliasName);\n\t\t\t}\n\t\t\tif (!compiledMessage) {\n\t\t\t\tconst fallbackLocale = fallbackMap[locale];\n\t\t\t\tif (fallbackLocale) {\n\t\t\t\t\t// use the fall back locale e.g. render the message in English if the German message is missing\n\t\t\t\t\tfile += `\\nexport { ${bundleModuleId} } from \"./${fallbackLocale}.js\"`;\n\t\t\t\t} else {\n\t\t\t\t\t// no fallback exists, render the bundleId\n\t\t\t\t\tfile += `\\n/** @type {(inputs: ${inputTypeAliasName}) => LocalizedString} */\\nexport const ${bundleModuleId} = () => /** @type {LocalizedString} */ ('${bundleId}')`;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfile += `\\n\\nexport const ${bundleModuleId} = ${compiledMessage.code}`;\n\t\t}\n\n\t\t// add import if used\n\t\tif (file.includes(\"registry.\")) {\n\t\t\tfile = `import * as registry from \"../registry.js\"\\n` + file;\n\t\t}\n\n\t\t// add LocalizedString typedef reference if used\n\t\tif (file.includes(\"LocalizedString\")) {\n\t\t\tconst inputTypeDefsBlock = inputTypeDefs.length\n\t\t\t\t? `${inputTypeDefs.join(\"\\n\")}\\n`\n\t\t\t\t: \"\";\n\t\t\tfile =\n\t\t\t\t`/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */\\n` +\n\t\t\t\tinputTypeDefsBlock +\n\t\t\t\tfile;\n\t\t}\n\n\t\toutput[filename] = file;\n\t}\n\treturn output;\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-modules.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/output-structure/locale-modules.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,163 @@
1
+ import { test, expect } from "vitest";
2
+ import { generateOutput, messageReferenceExpression, } from "./locale-modules.js";
3
+ test("should emit per locale message files", () => {
4
+ const bundles = [
5
+ {
6
+ bundle: {
7
+ code: 'console.log("bundle code");',
8
+ node: {
9
+ id: "happy_elephant",
10
+ },
11
+ },
12
+ messages: {
13
+ en: {
14
+ code: 'console.log("message in English");',
15
+ node: {},
16
+ },
17
+ de: {
18
+ code: 'console.log("message in German");',
19
+ node: {},
20
+ },
21
+ },
22
+ matchTypes: new Map(),
23
+ },
24
+ ];
25
+ const settings = {
26
+ locales: ["en", "de"],
27
+ baseLocale: "en",
28
+ };
29
+ const fallbackMap = {
30
+ en: "de",
31
+ de: "en",
32
+ };
33
+ const output = generateOutput(bundles, settings, fallbackMap);
34
+ expect(output).toHaveProperty("messages/en.js");
35
+ expect(output).toHaveProperty("messages/de.js");
36
+ expect(output["messages/en.js"]).toContain(`console.log("message in English");`);
37
+ });
38
+ test("the files should include files for each locale, even if there are no messages", () => {
39
+ const bundles = [
40
+ {
41
+ bundle: {
42
+ code: 'console.log("bundle code");',
43
+ node: {
44
+ id: "happy_elephant",
45
+ },
46
+ },
47
+ messages: {},
48
+ matchTypes: new Map(),
49
+ },
50
+ ];
51
+ const settings = {
52
+ locales: ["en", "de", "fr"],
53
+ baseLocale: "en",
54
+ };
55
+ const fallbackMap = {
56
+ en: "de",
57
+ de: "en",
58
+ };
59
+ const output = generateOutput(bundles, settings, fallbackMap);
60
+ expect(output).toHaveProperty("messages/en.js");
61
+ expect(output).toHaveProperty("messages/de.js");
62
+ expect(output).toHaveProperty("messages/fr.js");
63
+ });
64
+ test("should handle case sensitivity in message IDs correctly", () => {
65
+ const bundles = [
66
+ {
67
+ bundle: {
68
+ code: 'console.log("bundle code");',
69
+ node: {
70
+ id: "sad_penguin_bundle",
71
+ },
72
+ },
73
+ messages: {
74
+ en: {
75
+ code: 'console.log("sad_penguin_bundle");',
76
+ node: {},
77
+ },
78
+ },
79
+ matchTypes: new Map(),
80
+ },
81
+ {
82
+ bundle: {
83
+ code: 'console.log("bundle code");',
84
+ node: {
85
+ id: "Sad_penguin_bundle",
86
+ },
87
+ },
88
+ messages: {
89
+ en: {
90
+ code: 'console.log("Sad_penguin_bundle");',
91
+ node: {},
92
+ },
93
+ },
94
+ matchTypes: new Map(),
95
+ },
96
+ ];
97
+ const settings = {
98
+ locales: ["en"],
99
+ baseLocale: "en",
100
+ };
101
+ const fallbackMap = {};
102
+ const output = generateOutput(bundles, settings, fallbackMap);
103
+ // Check that the output exists
104
+ expect(output).toHaveProperty("messages/_index.js");
105
+ expect(output).toHaveProperty("messages/en.js");
106
+ // The exported constants should not conflict
107
+ const content = output["messages/en.js"];
108
+ expect(content).toContain("export const sad_penguin_bundle");
109
+ expect(content).toContain("export const sad_penguin_bundle1"); // or some other unique name
110
+ });
111
+ test("prefixes locale imports to avoid message name collisions", () => {
112
+ // https://github.com/opral/paraglide-js/issues/492
113
+ const bundles = [
114
+ {
115
+ bundle: {
116
+ code: "const no = () => 'No';",
117
+ node: {
118
+ id: "no",
119
+ },
120
+ },
121
+ messages: {
122
+ no: {
123
+ code: "const no = () => 'Nei';",
124
+ node: {},
125
+ },
126
+ },
127
+ matchTypes: new Map(),
128
+ },
129
+ ];
130
+ const settings = {
131
+ locales: ["no"],
132
+ baseLocale: "no",
133
+ };
134
+ const output = generateOutput(bundles, settings, {});
135
+ expect(output["messages/_index.js"]).toContain(`import * as __no from "./no.js"`);
136
+ expect(output["messages/_index.js"]).not.toContain(`import * as no from "./no.js"`);
137
+ expect(messageReferenceExpression("no", "no")).toBe("__no.no");
138
+ });
139
+ test("emits minimal runtime imports in index when middleware splitting is disabled", () => {
140
+ const bundles = [
141
+ {
142
+ bundle: {
143
+ code: "export const happy_elephant = () => __en.happy_elephant()",
144
+ node: {
145
+ id: "happy_elephant",
146
+ },
147
+ },
148
+ messages: {
149
+ en: {
150
+ code: '() => "happy"',
151
+ node: {},
152
+ },
153
+ },
154
+ matchTypes: new Map(),
155
+ },
156
+ ];
157
+ const output = generateOutput(bundles, { locales: ["en"], baseLocale: "en" }, {}, false);
158
+ expect(output["messages/_index.js"]).toContain('import { getLocale, experimentalStaticLocale } from "../runtime.js"');
159
+ expect(output["messages/_index.js"]).not.toContain("trackMessageCall");
160
+ expect(output["messages/_index.js"]).not.toContain("experimentalMiddlewareLocaleSplitting");
161
+ expect(output["messages/_index.js"]).not.toContain("isServer");
162
+ });
163
+ //# sourceMappingURL=locale-modules.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-modules.test.js","sourceRoot":"","sources":["../../../src/compiler/output-structure/locale-modules.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACN,cAAc,EACd,0BAA0B,GAC1B,MAAM,qBAAqB,CAAC;AAI7B,IAAI,CAAC,sCAAsC,EAAE,GAAG,EAAE;IACjD,MAAM,OAAO,GAAiC;QAC7C;YACC,MAAM,EAAE;gBACP,IAAI,EAAE,6BAA6B;gBACnC,IAAI,EAAE;oBACL,EAAE,EAAE,gBAAgB;iBACC;aACtB;YACD,QAAQ,EAAE;gBACT,EAAE,EAAE;oBACH,IAAI,EAAE,oCAAoC;oBAC1C,IAAI,EAAE,EAAwB;iBAC9B;gBACD,EAAE,EAAE;oBACH,IAAI,EAAE,mCAAmC;oBACzC,IAAI,EAAE,EAAwB;iBAC9B;aACD;YACD,UAAU,EAAE,IAAI,GAAG,EAAE;SACrB;KACD,CAAC;IAEF,MAAM,QAAQ,GAAsD;QACnE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QACrB,UAAU,EAAE,IAAI;KAChB,CAAC;IAEF,MAAM,WAAW,GAAuC;QACvD,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;KACR,CAAC;IAEF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CACrE,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IACvE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,uCAAuC,CAAC,CAAC;IAC5F,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport {\n\tgenerateOutput,\n\tmessageReferenceExpression,\n} from \"./locale-modules.js\";\nimport type { Bundle, Message, ParaglideSettings } from \"../../messages/ast.js\";\nimport type { CompiledBundleWithMessages } from \"../compile-bundle.js\";\n\ntest(\"should emit per locale message files\", () => {\n\tconst bundles: CompiledBundleWithMessages[] = [\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: 'console.log(\"bundle code\");',\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"happy_elephant\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\ten: {\n\t\t\t\t\tcode: 'console.log(\"message in English\");',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t\tde: {\n\t\t\t\t\tcode: 'console.log(\"message in German\");',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t];\n\n\tconst settings: Pick<ParaglideSettings, \"locales\" | \"baseLocale\"> = {\n\t\tlocales: [\"en\", \"de\"],\n\t\tbaseLocale: \"en\",\n\t};\n\n\tconst fallbackMap: Record<string, string | undefined> = {\n\t\ten: \"de\",\n\t\tde: \"en\",\n\t};\n\n\tconst output = generateOutput(bundles, settings, fallbackMap);\n\n\texpect(output).toHaveProperty(\"messages/en.js\");\n\texpect(output).toHaveProperty(\"messages/de.js\");\n\n\texpect(output[\"messages/en.js\"]).toContain(\n\t\t`console.log(\"message in English\");`\n\t);\n});\n\ntest(\"the files should include files for each locale, even if there are no messages\", () => {\n\tconst bundles: CompiledBundleWithMessages[] = [\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: 'console.log(\"bundle code\");',\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"happy_elephant\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t];\n\n\tconst settings: Pick<ParaglideSettings, \"locales\" | \"baseLocale\"> = {\n\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\tbaseLocale: \"en\",\n\t};\n\n\tconst fallbackMap: Record<string, string | undefined> = {\n\t\ten: \"de\",\n\t\tde: \"en\",\n\t};\n\n\tconst output = generateOutput(bundles, settings, fallbackMap);\n\n\texpect(output).toHaveProperty(\"messages/en.js\");\n\texpect(output).toHaveProperty(\"messages/de.js\");\n\texpect(output).toHaveProperty(\"messages/fr.js\");\n});\n\ntest(\"should handle case sensitivity in message IDs correctly\", () => {\n\tconst bundles: CompiledBundleWithMessages[] = [\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: 'console.log(\"bundle code\");',\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"sad_penguin_bundle\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\ten: {\n\t\t\t\t\tcode: 'console.log(\"sad_penguin_bundle\");',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: 'console.log(\"bundle code\");',\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"Sad_penguin_bundle\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\ten: {\n\t\t\t\t\tcode: 'console.log(\"Sad_penguin_bundle\");',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t];\n\n\tconst settings: Pick<ParaglideSettings, \"locales\" | \"baseLocale\"> = {\n\t\tlocales: [\"en\"],\n\t\tbaseLocale: \"en\",\n\t};\n\n\tconst fallbackMap: Record<string, string | undefined> = {};\n\n\tconst output = generateOutput(bundles, settings, fallbackMap);\n\n\t// Check that the output exists\n\texpect(output).toHaveProperty(\"messages/_index.js\");\n\texpect(output).toHaveProperty(\"messages/en.js\");\n\n\t// The exported constants should not conflict\n\tconst content = output[\"messages/en.js\"];\n\texpect(content).toContain(\"export const sad_penguin_bundle\");\n\texpect(content).toContain(\"export const sad_penguin_bundle1\"); // or some other unique name\n});\n\ntest(\"prefixes locale imports to avoid message name collisions\", () => {\n\t// https://github.com/opral/paraglide-js/issues/492\n\tconst bundles: CompiledBundleWithMessages[] = [\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: \"const no = () => 'No';\",\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"no\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\tno: {\n\t\t\t\t\tcode: \"const no = () => 'Nei';\",\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t];\n\n\tconst settings: Pick<ParaglideSettings, \"locales\" | \"baseLocale\"> = {\n\t\tlocales: [\"no\"],\n\t\tbaseLocale: \"no\",\n\t};\n\n\tconst output = generateOutput(bundles, settings, {});\n\n\texpect(output[\"messages/_index.js\"]).toContain(\n\t\t`import * as __no from \"./no.js\"`\n\t);\n\texpect(output[\"messages/_index.js\"]).not.toContain(\n\t\t`import * as no from \"./no.js\"`\n\t);\n\texpect(messageReferenceExpression(\"no\", \"no\")).toBe(\"__no.no\");\n});\n\ntest(\"emits minimal runtime imports in index when middleware splitting is disabled\", () => {\n\tconst bundles: CompiledBundleWithMessages[] = [\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: \"export const happy_elephant = () => __en.happy_elephant()\",\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"happy_elephant\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\ten: {\n\t\t\t\t\tcode: '() => \"happy\"',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t];\n\n\tconst output = generateOutput(\n\t\tbundles,\n\t\t{ locales: [\"en\"], baseLocale: \"en\" },\n\t\t{},\n\t\tfalse\n\t);\n\n\texpect(output[\"messages/_index.js\"]).toContain(\n\t\t'import { getLocale, experimentalStaticLocale } from \"../runtime.js\"'\n\t);\n\texpect(output[\"messages/_index.js\"]).not.toContain(\"trackMessageCall\");\n\texpect(output[\"messages/_index.js\"]).not.toContain(\"experimentalMiddlewareLocaleSplitting\");\n\texpect(output[\"messages/_index.js\"]).not.toContain(\"isServer\");\n});\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ParaglideSettings } from "../../messages/ast.js";
2
+ import type { CompiledBundleWithMessages } from "../compile-bundle.js";
3
+ export declare function messageReferenceExpression(locale: string, bundleId: string): string;
4
+ export declare function generateOutput(compiledBundles: CompiledBundleWithMessages[], settings: Pick<ParaglideSettings, "locales" | "baseLocale">, fallbackMap: Record<string, string | undefined>, experimentalMiddlewareLocaleSplitting?: boolean): Record<string, string>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-modules.d.ts","sourceRoot":"","sources":["../../../src/compiler/output-structure/message-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAMvE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAE1E;AAED,wBAAgB,cAAc,CAC7B,eAAe,EAAE,0BAA0B,EAAE,EAC7C,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,GAAG,YAAY,CAAC,EAC3D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAC/C,qCAAqC,UAAQ,GAC3C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4HxB"}
@@ -0,0 +1,100 @@
1
+ import { escapeForSingleQuoteString } from "../../services/codegen/escape.js";
2
+ import { toSafeModuleId } from "../safe-module-id.js";
3
+ import { inputsType } from "../jsdoc-types.js";
4
+ import { toBundleInputTypeAliasName } from "../compile-bundle.js";
5
+ export function messageReferenceExpression(locale, bundleId) {
6
+ return `${toSafeModuleId(locale)}_${toSafeModuleId(bundleId)}`;
7
+ }
8
+ export function generateOutput(compiledBundles, settings, fallbackMap, experimentalMiddlewareLocaleSplitting = false) {
9
+ const output = {};
10
+ const moduleFilenames = new Set();
11
+ for (const compiledBundle of compiledBundles) {
12
+ const bundleId = compiledBundle.bundle.node.id;
13
+ const safeModuleId = toSafeModuleId(compiledBundle.bundle.node.id);
14
+ const inputs = compiledBundle.bundle.node.declarations?.filter((decl) => decl.type === "input-variable") ?? [];
15
+ const matchTypes = compiledBundle.matchTypes;
16
+ const inputTypeAliasName = compiledBundle.inputTypeAliasName ??
17
+ toBundleInputTypeAliasName(safeModuleId);
18
+ const inputTypeDefinition = inputsType(inputs, matchTypes);
19
+ // bundle file
20
+ const filename = `messages/${safeModuleId}.js`;
21
+ moduleFilenames.add(`${safeModuleId}.js`);
22
+ // create fresh bundle file
23
+ output[filename] = compiledBundle.bundle.code;
24
+ const needsFallback = [];
25
+ const messages = [];
26
+ // messages
27
+ for (const locale of settings.locales) {
28
+ const safeLocale = toSafeModuleId(locale);
29
+ const compiledMessage = compiledBundle.messages[locale];
30
+ if (!compiledMessage) {
31
+ needsFallback.push(locale);
32
+ }
33
+ else {
34
+ messages.push(`const ${safeLocale}_${safeModuleId} = ${compiledMessage.code}`);
35
+ }
36
+ }
37
+ // add the fallbacks (needs to be done after the messages to avoid referencing
38
+ // the message before they are defined)
39
+ const needsFallbackSet = new Set(needsFallback);
40
+ const emittedFallbacks = new Set();
41
+ const emittingFallbacks = new Set();
42
+ /**
43
+ * Emits the fallback definition for a locale ensuring that dependent fallbacks
44
+ * are declared beforehand.
45
+ *
46
+ * @example
47
+ * emitFallback("fr-ca");
48
+ */
49
+ const emitFallback = (locale) => {
50
+ if (emittedFallbacks.has(locale))
51
+ return;
52
+ if (emittingFallbacks.has(locale))
53
+ return;
54
+ emittingFallbacks.add(locale);
55
+ const safeLocale = toSafeModuleId(locale);
56
+ const fallbackLocale = fallbackMap[locale];
57
+ if (fallbackLocale &&
58
+ needsFallbackSet.has(fallbackLocale) &&
59
+ !compiledBundle.messages[fallbackLocale]) {
60
+ emitFallback(fallbackLocale);
61
+ }
62
+ if (fallbackLocale) {
63
+ const safeFallbackLocale = toSafeModuleId(fallbackLocale);
64
+ messages.push(`/** @type {(inputs: ${inputTypeAliasName}) => LocalizedString} */\nconst ${safeLocale}_${safeModuleId} = ${safeFallbackLocale}_${safeModuleId};`);
65
+ }
66
+ else {
67
+ messages.push(`/** @type {(inputs: ${inputTypeAliasName}) => LocalizedString} */\nconst ${safeLocale}_${safeModuleId} = () => /** @type {LocalizedString} */ ('${escapeForSingleQuoteString(bundleId)}')`);
68
+ }
69
+ emittingFallbacks.delete(locale);
70
+ emittedFallbacks.add(locale);
71
+ };
72
+ for (const locale of needsFallback) {
73
+ emitFallback(locale);
74
+ }
75
+ output[filename] = messages.join("\n\n") + "\n\n" + output[filename];
76
+ // add the imports and type reference (LocalizedString is defined in runtime.js)
77
+ const runtimeImport = experimentalMiddlewareLocaleSplitting
78
+ ? `import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer, experimentalStaticLocale } from '../runtime.js';\n\n`
79
+ : `import { getLocale, experimentalStaticLocale } from '../runtime.js';\n\n`;
80
+ output[filename] =
81
+ runtimeImport +
82
+ `/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */\n\n` +
83
+ `/** @typedef {${inputTypeDefinition}} ${inputTypeAliasName} */\n\n` +
84
+ output[filename];
85
+ // Add the registry import to the message file
86
+ // if registry is used
87
+ if (output[filename]?.includes("registry.")) {
88
+ output[filename] =
89
+ `import * as registry from '../registry.js'\n` + output[filename];
90
+ }
91
+ }
92
+ // all messages index file
93
+ output["messages/_index.js"] =
94
+ `/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */\n` +
95
+ Array.from(moduleFilenames)
96
+ .map((filename) => `export * from './${filename}'`)
97
+ .join("\n");
98
+ return output;
99
+ }
100
+ //# sourceMappingURL=message-modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-modules.js","sourceRoot":"","sources":["../../../src/compiler/output-structure/message-modules.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,MAAM,UAAU,0BAA0B,CAAC,MAAc,EAAE,QAAgB;IAC1E,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,cAAc,CAC7B,eAA6C,EAC7C,QAA2D,EAC3D,WAA+C,EAC/C,qCAAqC,GAAG,KAAK;IAE7C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAE1C,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,I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AAC;YACpC,YAAY,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;QAED,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAErE,gFAAgF;QAChF,MAAM,aAAa,GAAG,qCAAqC;YAC1D,CAAC,CAAC,6IAA6I;YAC/I,CAAC,CAAC,0EAA0E,CAAC;QAE9E,MAAM,CAAC,QAAQ,CAAC;YACf,aAAa;gBACb,+EAA+E;gBAC/E,iBAAiB,mBAAmB,KAAK,kBAAkB,SAAS;gBACpE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAElB,8CAA8C;QAC9C,sBAAsB;QACtB,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7C,MAAM,CAAC,QAAQ,CAAC;gBACf,8CAA8C,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpE,CAAC;IACF,CAAC;IAED,0BAA0B;IAC1B,MAAM,CAAC,oBAAoB,CAAC;QAC3B,6EAA6E;YAC7E,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;iBACzB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,oBAAoB,QAAQ,GAAG,CAAC;iBAClD,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import type { ParaglideSettings } from \"../../messages/ast.js\";\nimport type { CompiledBundleWithMessages } from \"../compile-bundle.js\";\nimport { escapeForSingleQuoteString } from \"../../services/codegen/escape.js\";\nimport { toSafeModuleId } from \"../safe-module-id.js\";\nimport { inputsType } from \"../jsdoc-types.js\";\nimport { toBundleInputTypeAliasName } from \"../compile-bundle.js\";\n\nexport function messageReferenceExpression(locale: string, bundleId: string) {\n\treturn `${toSafeModuleId(locale)}_${toSafeModuleId(bundleId)}`;\n}\n\nexport function generateOutput(\n\tcompiledBundles: CompiledBundleWithMessages[],\n\tsettings: Pick<ParaglideSettings, \"locales\" | \"baseLocale\">,\n\tfallbackMap: Record<string, string | undefined>,\n\texperimentalMiddlewareLocaleSplitting = false\n): Record<string, string> {\n\tconst output: Record<string, string> = {};\n\n\tconst moduleFilenames = new Set<string>();\n\n\tfor (const compiledBundle of compiledBundles) {\n\t\tconst bundleId = compiledBundle.bundle.node.id;\n\t\tconst safeModuleId = toSafeModuleId(compiledBundle.bundle.node.id);\n\t\tconst inputs =\n\t\t\tcompiledBundle.bundle.node.declarations?.filter(\n\t\t\t\t(decl) => decl.type === \"input-variable\"\n\t\t\t) ?? [];\n\t\tconst matchTypes = compiledBundle.matchTypes;\n\t\tconst inputTypeAliasName =\n\t\t\tcompiledBundle.inputTypeAliasName ??\n\t\t\ttoBundleInputTypeAliasName(safeModuleId);\n\t\tconst inputTypeDefinition = inputsType(inputs, matchTypes);\n\n\t\t// bundle file\n\t\tconst filename = `messages/${safeModuleId}.js`;\n\n\t\tmoduleFilenames.add(`${safeModuleId}.js`);\n\n\t\t// create fresh bundle file\n\t\toutput[filename] = compiledBundle.bundle.code;\n\n\t\tconst needsFallback: string[] = [];\n\n\t\tconst messages: string[] = [];\n\n\t\t// messages\n\t\tfor (const locale of settings.locales) {\n\t\t\tconst safeLocale = toSafeModuleId(locale);\n\t\t\tconst compiledMessage = compiledBundle.messages[locale];\n\n\t\t\tif (!compiledMessage) {\n\t\t\t\tneedsFallback.push(locale);\n\t\t\t} else {\n\t\t\t\tmessages.push(\n\t\t\t\t\t`const ${safeLocale}_${safeModuleId} = ${compiledMessage.code}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// add the fallbacks (needs to be done after the messages to avoid referencing\n\t\t// the message before they are defined)\n\t\tconst needsFallbackSet = new Set(needsFallback);\n\t\tconst emittedFallbacks = new Set<string>();\n\t\tconst emittingFallbacks = new Set<string>();\n\n\t\t/**\n\t\t * Emits the fallback definition for a locale ensuring that dependent fallbacks\n\t\t * are declared beforehand.\n\t\t *\n\t\t * @example\n\t\t * emitFallback(\"fr-ca\");\n\t\t */\n\t\tconst emitFallback = (locale: string) => {\n\t\t\tif (emittedFallbacks.has(locale)) return;\n\t\t\tif (emittingFallbacks.has(locale)) return;\n\n\t\t\temittingFallbacks.add(locale);\n\n\t\t\tconst safeLocale = toSafeModuleId(locale);\n\t\t\tconst fallbackLocale = fallbackMap[locale];\n\n\t\t\tif (\n\t\t\t\tfallbackLocale &&\n\t\t\t\tneedsFallbackSet.has(fallbackLocale) &&\n\t\t\t\t!compiledBundle.messages[fallbackLocale]\n\t\t\t) {\n\t\t\t\temitFallback(fallbackLocale);\n\t\t\t}\n\n\t\t\tif (fallbackLocale) {\n\t\t\t\tconst safeFallbackLocale = toSafeModuleId(fallbackLocale);\n\t\t\t\tmessages.push(\n\t\t\t\t\t`/** @type {(inputs: ${inputTypeAliasName}) => LocalizedString} */\\nconst ${safeLocale}_${safeModuleId} = ${safeFallbackLocale}_${safeModuleId};`\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tmessages.push(\n\t\t\t\t\t`/** @type {(inputs: ${inputTypeAliasName}) => LocalizedString} */\\nconst ${safeLocale}_${safeModuleId} = () => /** @type {LocalizedString} */ ('${escapeForSingleQuoteString(\n\t\t\t\t\t\tbundleId\n\t\t\t\t\t)}')`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\temittingFallbacks.delete(locale);\n\t\t\temittedFallbacks.add(locale);\n\t\t};\n\n\t\tfor (const locale of needsFallback) {\n\t\t\temitFallback(locale);\n\t\t}\n\n\t\toutput[filename] = messages.join(\"\\n\\n\") + \"\\n\\n\" + output[filename];\n\n\t\t// add the imports and type reference (LocalizedString is defined in runtime.js)\n\t\tconst runtimeImport = experimentalMiddlewareLocaleSplitting\n\t\t\t? `import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer, experimentalStaticLocale } from '../runtime.js';\\n\\n`\n\t\t\t: `import { getLocale, experimentalStaticLocale } from '../runtime.js';\\n\\n`;\n\n\t\toutput[filename] =\n\t\t\truntimeImport +\n\t\t\t`/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */\\n\\n` +\n\t\t\t`/** @typedef {${inputTypeDefinition}} ${inputTypeAliasName} */\\n\\n` +\n\t\t\toutput[filename];\n\n\t\t// Add the registry import to the message file\n\t\t// if registry is used\n\t\tif (output[filename]?.includes(\"registry.\")) {\n\t\t\toutput[filename] =\n\t\t\t\t`import * as registry from '../registry.js'\\n` + output[filename];\n\t\t}\n\t}\n\n\t// all messages index file\n\toutput[\"messages/_index.js\"] =\n\t\t`/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */\\n` +\n\t\tArray.from(moduleFilenames)\n\t\t\t.map((filename) => `export * from './${filename}'`)\n\t\t\t.join(\"\\n\");\n\n\treturn output;\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-modules.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/output-structure/message-modules.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,148 @@
1
+ import { test, expect } from "vitest";
2
+ import { generateOutput } from "./message-modules.js";
3
+ test("should emit per locale message files", () => {
4
+ const resources = [
5
+ {
6
+ bundle: {
7
+ code: 'console.log("bundle code");',
8
+ node: {
9
+ id: "happy_elephant",
10
+ },
11
+ },
12
+ messages: {
13
+ en: {
14
+ code: 'console.log("message in English");',
15
+ node: {},
16
+ },
17
+ de: {
18
+ code: 'console.log("message in German");',
19
+ node: {},
20
+ },
21
+ },
22
+ matchTypes: new Map(),
23
+ },
24
+ ];
25
+ const settings = {
26
+ locales: ["en", "de"],
27
+ baseLocale: "en",
28
+ };
29
+ const fallbackMap = {
30
+ en: "de",
31
+ de: "en",
32
+ };
33
+ const output = generateOutput(resources, settings, fallbackMap);
34
+ expect(output).not.toHaveProperty("messages/en.js");
35
+ expect(output).not.toHaveProperty("messages/de.js");
36
+ expect(output).toHaveProperty("messages/happy_elephant.js");
37
+ });
38
+ test("handles case senstivity by creating directories and files only in lowercase", () => {
39
+ const resources = [
40
+ {
41
+ bundle: {
42
+ code: "export const HappyElephant = () => en.HappyElephant",
43
+ node: {
44
+ id: "HappyElephant",
45
+ },
46
+ },
47
+ messages: {
48
+ en: {
49
+ code: 'export const HappyElephant = () => "HappyElephant0"',
50
+ node: {},
51
+ },
52
+ },
53
+ matchTypes: new Map(),
54
+ },
55
+ {
56
+ bundle: {
57
+ code: "export const happyelephant = () => en.happyelephant",
58
+ node: {
59
+ id: "happyelephant",
60
+ },
61
+ },
62
+ messages: {
63
+ en: {
64
+ code: 'export const happyelephant = () => "happyelephant1"',
65
+ node: {},
66
+ },
67
+ },
68
+ matchTypes: new Map(),
69
+ },
70
+ ];
71
+ const settings = {
72
+ locales: ["en"],
73
+ baseLocale: "en",
74
+ };
75
+ const output = generateOutput(resources, settings, {});
76
+ // expecting only lowercase directories and files
77
+ expect(output).toHaveProperty("messages/happyelephant.js");
78
+ expect(output).toHaveProperty("messages/happyelephant2.js");
79
+ expect(output).not.toHaveProperty("messages/HappyElephant.js");
80
+ });
81
+ test("emits minimal runtime imports when middleware splitting is disabled", () => {
82
+ const resources = [
83
+ {
84
+ bundle: {
85
+ code: "export const happy_elephant = () => en_happy_elephant()",
86
+ node: {
87
+ id: "happy_elephant",
88
+ },
89
+ },
90
+ messages: {
91
+ en: {
92
+ code: '() => "happy"',
93
+ node: {},
94
+ },
95
+ },
96
+ matchTypes: new Map(),
97
+ },
98
+ ];
99
+ const output = generateOutput(resources, { locales: ["en"], baseLocale: "en" }, {}, false);
100
+ expect(output["messages/happy_elephant.js"]).toContain("import { getLocale, experimentalStaticLocale } from '../runtime.js';");
101
+ expect(output["messages/happy_elephant.js"]).not.toContain("trackMessageCall");
102
+ expect(output["messages/happy_elephant.js"]).not.toContain("experimentalMiddlewareLocaleSplitting");
103
+ expect(output["messages/happy_elephant.js"]).not.toContain("isServer");
104
+ });
105
+ // Regression test for https://github.com/opral/inlang-paraglide-js/issues/507
106
+ test("emits fallback definitions after their dependencies", () => {
107
+ const resources = [
108
+ {
109
+ bundle: {
110
+ code: "export const admin_tasks = (inputs) => inputs;",
111
+ node: {
112
+ id: "admin_tasks",
113
+ declarations: [],
114
+ },
115
+ },
116
+ messages: {
117
+ en: {
118
+ code: '/** @type {(inputs: {}) => string} */ () => "admin"',
119
+ node: {},
120
+ },
121
+ },
122
+ matchTypes: new Map(),
123
+ },
124
+ ];
125
+ const settings = {
126
+ locales: ["fr-ca", "fr", "en"],
127
+ baseLocale: "en",
128
+ };
129
+ const fallbackMap = {
130
+ "fr-ca": "fr",
131
+ fr: "en",
132
+ en: undefined,
133
+ };
134
+ const output = generateOutput(resources, settings, fallbackMap);
135
+ const file = output["messages/admin_tasks.js"];
136
+ expect(file).toBeDefined();
137
+ if (!file) {
138
+ throw new Error("messages/admin_tasks.js should have been generated");
139
+ }
140
+ expect(file).toContain("const fr_admin_tasks = en_admin_tasks;");
141
+ expect(file).toContain("const fr_ca_admin_tasks = fr_admin_tasks;");
142
+ const frIndex = file.indexOf("const fr_admin_tasks");
143
+ const frCaIndex = file.indexOf("const fr_ca_admin_tasks");
144
+ expect(frIndex).toBeGreaterThan(-1);
145
+ expect(frCaIndex).toBeGreaterThan(-1);
146
+ expect(frIndex).toBeLessThan(frCaIndex);
147
+ });
148
+ //# sourceMappingURL=message-modules.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-modules.test.js","sourceRoot":"","sources":["../../../src/compiler/output-structure/message-modules.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,IAAI,CAAC,sCAAsC,EAAE,GAAG,EAAE;IACjD,MAAM,SAAS,GAAiC;QAC/C;YACC,MAAM,EAAE;gBACP,IAAI,EAAE,6BAA6B;gBACnC,IAAI,EAAE;oBACL,EAAE,EAAE,gBAAgB;iBACC;aACtB;YACD,QAAQ,EAA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AAO,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAE1D,MAAM,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { generateOutput } from \"./message-modules.js\";\nimport type { Bundle, Message, ParaglideSettings } from \"../../messages/ast.js\";\nimport type { CompiledBundleWithMessages } from \"../compile-bundle.js\";\n\ntest(\"should emit per locale message files\", () => {\n\tconst resources: CompiledBundleWithMessages[] = [\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: 'console.log(\"bundle code\");',\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"happy_elephant\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\ten: {\n\t\t\t\t\tcode: 'console.log(\"message in English\");',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t\tde: {\n\t\t\t\t\tcode: 'console.log(\"message in German\");',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t];\n\n\tconst settings: Pick<ParaglideSettings, \"locales\" | \"baseLocale\"> = {\n\t\tlocales: [\"en\", \"de\"],\n\t\tbaseLocale: \"en\",\n\t};\n\n\tconst fallbackMap: Record<string, string | undefined> = {\n\t\ten: \"de\",\n\t\tde: \"en\",\n\t};\n\n\tconst output = generateOutput(resources, settings, fallbackMap);\n\n\texpect(output).not.toHaveProperty(\"messages/en.js\");\n\texpect(output).not.toHaveProperty(\"messages/de.js\");\n\texpect(output).toHaveProperty(\"messages/happy_elephant.js\");\n});\n\ntest(\"handles case senstivity by creating directories and files only in lowercase\", () => {\n\tconst resources: CompiledBundleWithMessages[] = [\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: \"export const HappyElephant = () => en.HappyElephant\",\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"HappyElephant\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\ten: {\n\t\t\t\t\tcode: 'export const HappyElephant = () => \"HappyElephant0\"',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: \"export const happyelephant = () => en.happyelephant\",\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"happyelephant\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\ten: {\n\t\t\t\t\tcode: 'export const happyelephant = () => \"happyelephant1\"',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t];\n\tconst settings: Pick<ParaglideSettings, \"locales\" | \"baseLocale\"> = {\n\t\tlocales: [\"en\"],\n\t\tbaseLocale: \"en\",\n\t};\n\tconst output = generateOutput(resources, settings, {});\n\n\t// expecting only lowercase directories and files\n\texpect(output).toHaveProperty(\"messages/happyelephant.js\");\n\texpect(output).toHaveProperty(\"messages/happyelephant2.js\");\n\texpect(output).not.toHaveProperty(\"messages/HappyElephant.js\");\n});\n\ntest(\"emits minimal runtime imports when middleware splitting is disabled\", () => {\n\tconst resources: CompiledBundleWithMessages[] = [\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: \"export const happy_elephant = () => en_happy_elephant()\",\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"happy_elephant\",\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\ten: {\n\t\t\t\t\tcode: '() => \"happy\"',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t];\n\n\tconst output = generateOutput(\n\t\tresources,\n\t\t{ locales: [\"en\"], baseLocale: \"en\" },\n\t\t{},\n\t\tfalse\n\t);\n\n\texpect(output[\"messages/happy_elephant.js\"]).toContain(\n\t\t\"import { getLocale, experimentalStaticLocale } from '../runtime.js';\"\n\t);\n\texpect(output[\"messages/happy_elephant.js\"]).not.toContain(\n\t\t\"trackMessageCall\"\n\t);\n\texpect(output[\"messages/happy_elephant.js\"]).not.toContain(\n\t\t\"experimentalMiddlewareLocaleSplitting\"\n\t);\n\texpect(output[\"messages/happy_elephant.js\"]).not.toContain(\"isServer\");\n});\n\n// Regression test for https://github.com/opral/inlang-paraglide-js/issues/507\ntest(\"emits fallback definitions after their dependencies\", () => {\n\tconst resources: CompiledBundleWithMessages[] = [\n\t\t{\n\t\t\tbundle: {\n\t\t\t\tcode: \"export const admin_tasks = (inputs) => inputs;\",\n\t\t\t\tnode: {\n\t\t\t\t\tid: \"admin_tasks\",\n\t\t\t\t\tdeclarations: [],\n\t\t\t\t} as unknown as Bundle,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\ten: {\n\t\t\t\t\tcode: '/** @type {(inputs: {}) => string} */ () => \"admin\"',\n\t\t\t\t\tnode: {} as unknown as Message,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmatchTypes: new Map(),\n\t\t},\n\t];\n\n\tconst settings: Pick<ParaglideSettings, \"locales\" | \"baseLocale\"> = {\n\t\tlocales: [\"fr-ca\", \"fr\", \"en\"],\n\t\tbaseLocale: \"en\",\n\t};\n\n\tconst fallbackMap: Record<string, string | undefined> = {\n\t\t\"fr-ca\": \"fr\",\n\t\tfr: \"en\",\n\t\ten: undefined,\n\t};\n\n\tconst output = generateOutput(resources, settings, fallbackMap);\n\n\tconst file = output[\"messages/admin_tasks.js\"];\n\n\texpect(file).toBeDefined();\n\n\tif (!file) {\n\t\tthrow new Error(\"messages/admin_tasks.js should have been generated\");\n\t}\n\n\texpect(file).toContain(\"const fr_admin_tasks = en_admin_tasks;\");\n\texpect(file).toContain(\"const fr_ca_admin_tasks = fr_admin_tasks;\");\n\n\tconst frIndex = file.indexOf(\"const fr_admin_tasks\");\n\tconst frCaIndex = file.indexOf(\"const fr_ca_admin_tasks\");\n\n\texpect(frIndex).toBeGreaterThan(-1);\n\texpect(frCaIndex).toBeGreaterThan(-1);\n\texpect(frIndex).toBeLessThan(frCaIndex);\n});\n"]}
@@ -0,0 +1,2 @@
1
+ /** Internal compiler/bundler contract for locale-specialized client builds. */
2
+ export declare const perLocaleBuildStaticLocaleExpression = "/** @type {any} */ (globalThis).__PARAGLIDE_STATIC_LOCALE__";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-locale-build.d.ts","sourceRoot":"","sources":["../../src/compiler/per-locale-build.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,eAAO,MAAM,oCAAoC,gEACa,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Internal compiler/bundler contract for locale-specialized client builds. */
2
+ export const perLocaleBuildStaticLocaleExpression = "/** @type {any} */ (globalThis).__PARAGLIDE_STATIC_LOCALE__";
3
+ //# sourceMappingURL=per-locale-build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"per-locale-build.js","sourceRoot":"","sources":["../../src/compiler/per-locale-build.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oCAAoC,GAChD,6DAA6D,CAAC","sourcesContent":["/** Internal compiler/bundler contract for locale-specialized client builds. */\nexport const perLocaleBuildStaticLocaleExpression =\n\t\"/** @type {any} */ (globalThis).__PARAGLIDE_STATIC_LOCALE__\";\n"]}
@@ -0,0 +1,13 @@
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 declare function createRegistry(): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/compiler/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CA8CvC"}