@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,270 @@
1
+ import { prompt } from "../utils.js";
2
+ import JSON5 from "json5";
3
+ import { pathExists } from "../../services/file-handling/exists.js";
4
+ import nodePath from "node:path";
5
+ import { createRequire } from "node:module";
6
+ const require = createRequire(import.meta.url);
7
+ export const maybeUpdateTsConfig = async (ctx) => {
8
+ const ctx1 = await maybeUpdateTsConfigAllowJs(ctx);
9
+ return ctx1;
10
+ // return await maybeUpdateTsConfigModuleResolution(ctx1);
11
+ };
12
+ /**
13
+ * Paraligde JS compiles to JS with JSDoc comments. TypeScript doesn't allow JS files by default.
14
+ */
15
+ export const maybeUpdateTsConfigAllowJs = async (ctx) => {
16
+ if ((await pathExists("./tsconfig.json", ctx.fs)) === false) {
17
+ return ctx;
18
+ }
19
+ if (await hasAllowJsEnabled("./tsconfig.json", ctx.fs)) {
20
+ // all clear, allowJs is already set to true
21
+ return ctx;
22
+ }
23
+ ctx.logger.info(`The option \`compilerOptions.allowJs\` needs to be set to \`true\` in the \`tsconfig.json\` file:
24
+
25
+ \`{
26
+ "compilerOptions": {
27
+ "allowJs": true
28
+ }
29
+ }\``);
30
+ let isValid = false;
31
+ while (isValid === false) {
32
+ const response = await prompt(`Is \`compilerOptions.allowJs\` set to \`true\`?`, {
33
+ type: "confirm",
34
+ initial: true,
35
+ });
36
+ if (response === false) {
37
+ ctx.logger.warn("Continuing without adjusting the tsconfig.json. This may lead to type errors.");
38
+ return ctx;
39
+ }
40
+ if (await hasAllowJsEnabled("./tsconfig.json", ctx.fs)) {
41
+ isValid = true;
42
+ return ctx;
43
+ }
44
+ else {
45
+ ctx.logger.error("The compiler options has not been adjusted. Please sets `compilerOptions.allowJs` to `true`.");
46
+ }
47
+ }
48
+ return ctx;
49
+ };
50
+ /**
51
+ * Recursively checks whether allowJs is enabled in the provided tsconfig or any
52
+ * referenced configuration files.
53
+ *
54
+ * @param tsconfigPath The path to the tsconfig to inspect.
55
+ * @param fs The file system used to read the configs.
56
+ * @param visited A set of already inspected files to avoid circular lookups.
57
+ * @example
58
+ * ```ts
59
+ * await hasAllowJsEnabled("./tsconfig.json", fs);
60
+ * ```
61
+ */
62
+ export const hasAllowJsEnabled = async (tsconfigPath, fs, visited = new Set()) => {
63
+ const normalizedPath = normalizeConfigPath(tsconfigPath);
64
+ if (visited.has(normalizedPath)) {
65
+ return false;
66
+ }
67
+ visited.add(normalizedPath);
68
+ const file = await fs.readFile(normalizedPath, { encoding: "utf-8" });
69
+ const tsconfig = JSON5.parse(file);
70
+ if (tsconfig?.compilerOptions?.allowJs === true) {
71
+ return true;
72
+ }
73
+ const baseDir = nodePath.dirname(normalizedPath);
74
+ const extendCandidates = Array.isArray(tsconfig?.extends)
75
+ ? tsconfig.extends
76
+ : tsconfig?.extends
77
+ ? [tsconfig.extends]
78
+ : [];
79
+ for (const candidate of extendCandidates) {
80
+ if (typeof candidate !== "string")
81
+ continue;
82
+ const resolved = await resolveExtendedConfig(candidate, baseDir, fs);
83
+ if (resolved && (await hasAllowJsEnabled(resolved, fs, visited))) {
84
+ return true;
85
+ }
86
+ }
87
+ if (Array.isArray(tsconfig?.references)) {
88
+ for (const reference of tsconfig.references) {
89
+ const referencePath = reference?.path;
90
+ if (typeof referencePath !== "string")
91
+ continue;
92
+ const resolved = await resolveReferenceConfig(referencePath, baseDir, fs);
93
+ if (resolved && (await hasAllowJsEnabled(resolved, fs, visited))) {
94
+ return true;
95
+ }
96
+ }
97
+ }
98
+ return false;
99
+ };
100
+ /**
101
+ * Normalizes a tsconfig path to an absolute path.
102
+ */
103
+ const normalizeConfigPath = (configPath) => {
104
+ return nodePath.isAbsolute(configPath)
105
+ ? configPath
106
+ : nodePath.resolve(process.cwd(), configPath);
107
+ };
108
+ /**
109
+ * Resolves the extended tsconfig path relative to the base config.
110
+ */
111
+ const resolveExtendedConfig = async (extendsSpecifier, baseDir, fs) => {
112
+ const candidates = new Set();
113
+ const resolvedBase = nodePath.isAbsolute(extendsSpecifier)
114
+ ? extendsSpecifier
115
+ : nodePath.resolve(baseDir, extendsSpecifier);
116
+ candidates.add(resolvedBase);
117
+ if (nodePath.extname(resolvedBase) === "") {
118
+ candidates.add(`${resolvedBase}.json`);
119
+ candidates.add(nodePath.join(resolvedBase, "tsconfig.json"));
120
+ }
121
+ for (const candidate of candidates) {
122
+ if (await pathExists(candidate, fs)) {
123
+ return candidate;
124
+ }
125
+ }
126
+ try {
127
+ return require.resolve(extendsSpecifier, { paths: [baseDir] });
128
+ }
129
+ catch {
130
+ if (extendsSpecifier.endsWith(".json") === false) {
131
+ try {
132
+ return require.resolve(`${extendsSpecifier}.json`, {
133
+ paths: [baseDir],
134
+ });
135
+ }
136
+ catch {
137
+ return undefined;
138
+ }
139
+ }
140
+ }
141
+ return undefined;
142
+ };
143
+ /**
144
+ * Resolves the tsconfig referenced through the `references` property.
145
+ */
146
+ const resolveReferenceConfig = async (referenceSpecifier, baseDir, fs) => {
147
+ const candidates = new Set();
148
+ const resolvedBase = nodePath.isAbsolute(referenceSpecifier)
149
+ ? referenceSpecifier
150
+ : nodePath.resolve(baseDir, referenceSpecifier);
151
+ candidates.add(resolvedBase);
152
+ if (nodePath.extname(resolvedBase) === "") {
153
+ candidates.add(`${resolvedBase}.json`);
154
+ candidates.add(nodePath.join(resolvedBase, "tsconfig.json"));
155
+ }
156
+ for (const candidate of candidates) {
157
+ if (await pathExists(candidate, fs)) {
158
+ try {
159
+ const stats = await fs.stat(candidate);
160
+ if (stats.isDirectory()) {
161
+ const directoryConfig = nodePath.join(candidate, "tsconfig.json");
162
+ if (await pathExists(directoryConfig, fs)) {
163
+ return directoryConfig;
164
+ }
165
+ continue;
166
+ }
167
+ }
168
+ catch {
169
+ // ignore, we'll continue checking other candidates
170
+ }
171
+ return candidate;
172
+ }
173
+ }
174
+ return undefined;
175
+ };
176
+ // /**
177
+ // * Ensures that the moduleResolution compiler option is set to "bundler" or similar in the tsconfig.json.
178
+ // *
179
+ // * Otherwise, types defined in `package.exports` are not resolved by TypeScript. Leading to type
180
+ // * errors with Paraglide-JS.
181
+ // */
182
+ // const maybeUpdateTsConfigModuleResolution: CliStep<
183
+ // { fs: typeof import("node:fs/promises"); logger: Logger },
184
+ // unknown
185
+ // > = async (ctx) => {
186
+ // if ((await pathExists("./tsconfig.json", ctx.fs)) === false) {
187
+ // return ctx;
188
+ // }
189
+ // const file = await ctx.fs.readFile("./tsconfig.json", {
190
+ // encoding: "utf-8",
191
+ // });
192
+ // // tsconfig allows comments ... FML
193
+ // let tsconfig = JSON5.parse(file);
194
+ // let parentTsConfig: any | undefined;
195
+ // if (tsconfig.extends) {
196
+ // try {
197
+ // const parentTsConfigPath = nodePath.resolve(
198
+ // process.cwd(),
199
+ // tsconfig.extends
200
+ // );
201
+ // const parentTsConfigFile = await ctx.fs.readFile(parentTsConfigPath, {
202
+ // encoding: "utf-8",
203
+ // });
204
+ // parentTsConfig = JSON5.parse(parentTsConfigFile);
205
+ // } catch {
206
+ // ctx.logger.warn(
207
+ // `The tsconfig.json is extended from a tsconfig that couldn't be read. Maybe the file doesn't exist yet or is a NPM package. Continuing without taking the extended from tsconfig into consideration.`
208
+ // );
209
+ // }
210
+ // }
211
+ // // options that don't support package.exports
212
+ // const invalidOptions = ["classic", "node", "node10"];
213
+ // const moduleResolution =
214
+ // tsconfig.compilerOptions?.moduleResolution ??
215
+ // parentTsConfig?.compilerOptions?.moduleResolution;
216
+ // if (
217
+ // moduleResolution &&
218
+ // invalidOptions.includes(moduleResolution.toLowerCase()) === false
219
+ // ) {
220
+ // // the moduleResolution is already set to bundler or similar
221
+ // return ctx;
222
+ // }
223
+ // ctx.logger.info(
224
+ // `The \`compilerOptions.moduleResolution\` options must be set to "Bundler" in the \`tsconfig.json\` file:
225
+ // \`{
226
+ // "compilerOptions": {
227
+ // "moduleResolution": "Bundler"
228
+ // }
229
+ // }\``
230
+ // );
231
+ // let isValid = false;
232
+ // while (isValid === false) {
233
+ // const response = await prompt(
234
+ // `Is \`compilerOptions.moduleResolution\` set to "Bundler"?`,
235
+ // {
236
+ // type: "confirm",
237
+ // initial: true,
238
+ // }
239
+ // );
240
+ // if (response === false) {
241
+ // ctx.logger.warn(
242
+ // "Continuing without adjusting the tsconfig.json. This may lead to type errors."
243
+ // );
244
+ // return ctx;
245
+ // }
246
+ // // don't re-ask the question if there is an `extends` present in the tsconfig
247
+ // // just trust that it's correct.
248
+ // if (tsconfig.extends) {
249
+ // isValid = true;
250
+ // return ctx;
251
+ // }
252
+ // const file = await ctx.fs.readFile("./tsconfig.json", {
253
+ // encoding: "utf-8",
254
+ // });
255
+ // tsconfig = JSON5.parse(file);
256
+ // if (
257
+ // tsconfig?.compilerOptions?.moduleResolution &&
258
+ // tsconfig.compilerOptions.moduleResolution.toLowerCase() === "bundler"
259
+ // ) {
260
+ // isValid = true;
261
+ // return ctx;
262
+ // } else {
263
+ // ctx.logger.error(
264
+ // "The compiler options have not been adjusted. Please set the `compilerOptions.moduleResolution` to `Bundler`."
265
+ // );
266
+ // }
267
+ // }
268
+ // return ctx;
269
+ // };
270
+ //# sourceMappingURL=update-ts-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-ts-config.js","sourceRoot":"","sources":["../../../src/cli/steps/update-ts-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,CAAC,MAAM,mBAAmB,GAG5B,KAAK,EAAE,GAAG,EAAE,EAAE;IACjB,MAAM,IAAI,GAAG,MAAM,0BAA0B,CAAC,GAAG,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC;IACZ,0DAA0D;AAC3D,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAGnC,KAAK,EAAE,GAAG,EAAE,EAAE;IACjB,IAAI,CAAC,MAAM,UAAU,CAAC,iBAAiB,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC;QAC7D,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,IAAI,MAAM,iBAAiB,CAAC,iBAAiB,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QACxD,4CAA4C;QAC5C,OAAO,GAAG,CAAC;IACZ,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,IAAI,CACd;;;;;;IA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AAEN,4DAA4D;AAC5D,wBAAwB;AACxB,QAAQ;AACR,kCAAkC;AAClC,SAAS;AACT,oDAAoD;AACpD,2EAA2E;AAC3E,QAAQ;AACR,qBAAqB;AACrB,iBAAiB;AACjB,aAAa;AACb,uBAAuB;AACvB,qHAAqH;AACrH,QAAQ;AACR,MAAM;AACN,KAAK;AAEL,eAAe;AACf,KAAK","sourcesContent":["import type { CliStep } from \"../utils.js\";\nimport type { Logger } from \"../../services/logger/index.js\";\nimport { prompt } from \"../utils.js\";\nimport JSON5 from \"json5\";\nimport { pathExists } from \"../../services/file-handling/exists.js\";\nimport nodePath from \"node:path\";\nimport { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\n\nexport const maybeUpdateTsConfig: CliStep<\n\t{ fs: typeof import(\"node:fs/promises\"); logger: Logger },\n\tunknown\n> = async (ctx) => {\n\tconst ctx1 = await maybeUpdateTsConfigAllowJs(ctx);\n\treturn ctx1;\n\t// return await maybeUpdateTsConfigModuleResolution(ctx1);\n};\n\n/**\n * Paraligde JS compiles to JS with JSDoc comments. TypeScript doesn't allow JS files by default.\n */\nexport const maybeUpdateTsConfigAllowJs: CliStep<\n\t{ fs: typeof import(\"node:fs/promises\"); logger: Logger },\n\tunknown\n> = async (ctx) => {\n\tif ((await pathExists(\"./tsconfig.json\", ctx.fs)) === false) {\n\t\treturn ctx;\n\t}\n\tif (await hasAllowJsEnabled(\"./tsconfig.json\", ctx.fs)) {\n\t\t// all clear, allowJs is already set to true\n\t\treturn ctx;\n\t}\n\n\tctx.logger.info(\n\t\t`The option \\`compilerOptions.allowJs\\` needs to be set to \\`true\\` in the \\`tsconfig.json\\` file:\n\n\\`{\n \"compilerOptions\": {\n \"allowJs\": true\n }\n}\\``\n\t);\n\tlet isValid = false;\n\twhile (isValid === false) {\n\t\tconst response = await prompt(\n\t\t\t`Is \\`compilerOptions.allowJs\\` set to \\`true\\`?`,\n\t\t\t{\n\t\t\t\ttype: \"confirm\",\n\t\t\t\tinitial: true,\n\t\t\t}\n\t\t);\n\t\tif (response === false) {\n\t\t\tctx.logger.warn(\n\t\t\t\t\"Continuing without adjusting the tsconfig.json. This may lead to type errors.\"\n\t\t\t);\n\t\t\treturn ctx;\n\t\t}\n\n\t\tif (await hasAllowJsEnabled(\"./tsconfig.json\", ctx.fs)) {\n\t\t\tisValid = true;\n\t\t\treturn ctx;\n\t\t} else {\n\t\t\tctx.logger.error(\n\t\t\t\t\"The compiler options has not been adjusted. Please sets `compilerOptions.allowJs` to `true`.\"\n\t\t\t);\n\t\t}\n\t}\n\treturn ctx;\n};\n\n/**\n * Recursively checks whether allowJs is enabled in the provided tsconfig or any\n * referenced configuration files.\n *\n * @param tsconfigPath The path to the tsconfig to inspect.\n * @param fs The file system used to read the configs.\n * @param visited A set of already inspected files to avoid circular lookups.\n * @example\n * ```ts\n * await hasAllowJsEnabled(\"./tsconfig.json\", fs);\n * ```\n */\nexport const hasAllowJsEnabled = async (\n\ttsconfigPath: string,\n\tfs: typeof import(\"node:fs/promises\"),\n\tvisited: Set<string> = new Set()\n): Promise<boolean> => {\n\tconst normalizedPath = normalizeConfigPath(tsconfigPath);\n\n\tif (visited.has(normalizedPath)) {\n\t\treturn false;\n\t}\n\n\tvisited.add(normalizedPath);\n\n\tconst file = await fs.readFile(normalizedPath, { encoding: \"utf-8\" });\n\tconst tsconfig = JSON5.parse(file);\n\n\tif (tsconfig?.compilerOptions?.allowJs === true) {\n\t\treturn true;\n\t}\n\n\tconst baseDir = nodePath.dirname(normalizedPath);\n\n\tconst extendCandidates = Array.isArray(tsconfig?.extends)\n\t\t? tsconfig.extends\n\t\t: tsconfig?.extends\n\t\t\t? [tsconfig.extends]\n\t\t\t: [];\n\n\tfor (const candidate of extendCandidates) {\n\t\tif (typeof candidate !== \"string\") continue;\n\t\tconst resolved = await resolveExtendedConfig(candidate, baseDir, fs);\n\t\tif (resolved && (await hasAllowJsEnabled(resolved, fs, visited))) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tif (Array.isArray(tsconfig?.references)) {\n\t\tfor (const reference of tsconfig.references) {\n\t\t\tconst referencePath = reference?.path;\n\t\t\tif (typeof referencePath !== \"string\") continue;\n\t\t\tconst resolved = await resolveReferenceConfig(referencePath, baseDir, fs);\n\t\t\tif (resolved && (await hasAllowJsEnabled(resolved, fs, visited))) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n};\n\n/**\n * Normalizes a tsconfig path to an absolute path.\n */\nconst normalizeConfigPath = (configPath: string): string => {\n\treturn nodePath.isAbsolute(configPath)\n\t\t? configPath\n\t\t: nodePath.resolve(process.cwd(), configPath);\n};\n\n/**\n * Resolves the extended tsconfig path relative to the base config.\n */\nconst resolveExtendedConfig = async (\n\textendsSpecifier: string,\n\tbaseDir: string,\n\tfs: typeof import(\"node:fs/promises\")\n): Promise<string | undefined> => {\n\tconst candidates = new Set<string>();\n\tconst resolvedBase = nodePath.isAbsolute(extendsSpecifier)\n\t\t? extendsSpecifier\n\t\t: nodePath.resolve(baseDir, extendsSpecifier);\n\tcandidates.add(resolvedBase);\n\n\tif (nodePath.extname(resolvedBase) === \"\") {\n\t\tcandidates.add(`${resolvedBase}.json`);\n\t\tcandidates.add(nodePath.join(resolvedBase, \"tsconfig.json\"));\n\t}\n\n\tfor (const candidate of candidates) {\n\t\tif (await pathExists(candidate, fs)) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\ttry {\n\t\treturn require.resolve(extendsSpecifier, { paths: [baseDir] });\n\t} catch {\n\t\tif (extendsSpecifier.endsWith(\".json\") === false) {\n\t\t\ttry {\n\t\t\t\treturn require.resolve(`${extendsSpecifier}.json`, {\n\t\t\t\t\tpaths: [baseDir],\n\t\t\t\t});\n\t\t\t} catch {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\n/**\n * Resolves the tsconfig referenced through the `references` property.\n */\nconst resolveReferenceConfig = async (\n\treferenceSpecifier: string,\n\tbaseDir: string,\n\tfs: typeof import(\"node:fs/promises\")\n): Promise<string | undefined> => {\n\tconst candidates = new Set<string>();\n\tconst resolvedBase = nodePath.isAbsolute(referenceSpecifier)\n\t\t? referenceSpecifier\n\t\t: nodePath.resolve(baseDir, referenceSpecifier);\n\tcandidates.add(resolvedBase);\n\n\tif (nodePath.extname(resolvedBase) === \"\") {\n\t\tcandidates.add(`${resolvedBase}.json`);\n\t\tcandidates.add(nodePath.join(resolvedBase, \"tsconfig.json\"));\n\t}\n\n\tfor (const candidate of candidates) {\n\t\tif (await pathExists(candidate, fs)) {\n\t\t\ttry {\n\t\t\t\tconst stats = await fs.stat(candidate);\n\t\t\t\tif (stats.isDirectory()) {\n\t\t\t\t\tconst directoryConfig = nodePath.join(candidate, \"tsconfig.json\");\n\t\t\t\t\tif (await pathExists(directoryConfig, fs)) {\n\t\t\t\t\t\treturn directoryConfig;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// ignore, we'll continue checking other candidates\n\t\t\t}\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\n// /**\n// * Ensures that the moduleResolution compiler option is set to \"bundler\" or similar in the tsconfig.json.\n// *\n// * Otherwise, types defined in `package.exports` are not resolved by TypeScript. Leading to type\n// * errors with Paraglide-JS.\n// */\n// const maybeUpdateTsConfigModuleResolution: CliStep<\n// \t{ fs: typeof import(\"node:fs/promises\"); logger: Logger },\n// \tunknown\n// > = async (ctx) => {\n// \tif ((await pathExists(\"./tsconfig.json\", ctx.fs)) === false) {\n// \t\treturn ctx;\n// \t}\n// \tconst file = await ctx.fs.readFile(\"./tsconfig.json\", {\n// \t\tencoding: \"utf-8\",\n// \t});\n// \t// tsconfig allows comments ... FML\n// \tlet tsconfig = JSON5.parse(file);\n\n// \tlet parentTsConfig: any | undefined;\n\n// \tif (tsconfig.extends) {\n// \t\ttry {\n// \t\t\tconst parentTsConfigPath = nodePath.resolve(\n// \t\t\t\tprocess.cwd(),\n// \t\t\t\ttsconfig.extends\n// \t\t\t);\n// \t\t\tconst parentTsConfigFile = await ctx.fs.readFile(parentTsConfigPath, {\n// \t\t\t\tencoding: \"utf-8\",\n// \t\t\t});\n// \t\t\tparentTsConfig = JSON5.parse(parentTsConfigFile);\n// \t\t} catch {\n// \t\t\tctx.logger.warn(\n// \t\t\t\t`The tsconfig.json is extended from a tsconfig that couldn't be read. Maybe the file doesn't exist yet or is a NPM package. Continuing without taking the extended from tsconfig into consideration.`\n// \t\t\t);\n// \t\t}\n// \t}\n\n// \t// options that don't support package.exports\n// \tconst invalidOptions = [\"classic\", \"node\", \"node10\"];\n// \tconst moduleResolution =\n// \t\ttsconfig.compilerOptions?.moduleResolution ??\n// \t\tparentTsConfig?.compilerOptions?.moduleResolution;\n\n// \tif (\n// \t\tmoduleResolution &&\n// \t\tinvalidOptions.includes(moduleResolution.toLowerCase()) === false\n// \t) {\n// \t\t// the moduleResolution is already set to bundler or similar\n// \t\treturn ctx;\n// \t}\n\n// \tctx.logger.info(\n// \t\t`The \\`compilerOptions.moduleResolution\\` options must be set to \"Bundler\" in the \\`tsconfig.json\\` file:\n\n// \\`{\n// \"compilerOptions\": {\n// \"moduleResolution\": \"Bundler\"\n// }\n// }\\``\n// \t);\n// \tlet isValid = false;\n// \twhile (isValid === false) {\n// \t\tconst response = await prompt(\n// \t\t\t`Is \\`compilerOptions.moduleResolution\\` set to \"Bundler\"?`,\n// \t\t\t{\n// \t\t\t\ttype: \"confirm\",\n// \t\t\t\tinitial: true,\n// \t\t\t}\n// \t\t);\n// \t\tif (response === false) {\n// \t\t\tctx.logger.warn(\n// \t\t\t\t\"Continuing without adjusting the tsconfig.json. This may lead to type errors.\"\n// \t\t\t);\n// \t\t\treturn ctx;\n// \t\t}\n\n// \t\t// don't re-ask the question if there is an `extends` present in the tsconfig\n// \t\t// just trust that it's correct.\n// \t\tif (tsconfig.extends) {\n// \t\t\tisValid = true;\n// \t\t\treturn ctx;\n// \t\t}\n\n// \t\tconst file = await ctx.fs.readFile(\"./tsconfig.json\", {\n// \t\t\tencoding: \"utf-8\",\n// \t\t});\n// \t\ttsconfig = JSON5.parse(file);\n// \t\tif (\n// \t\t\ttsconfig?.compilerOptions?.moduleResolution &&\n// \t\t\ttsconfig.compilerOptions.moduleResolution.toLowerCase() === \"bundler\"\n// \t\t) {\n// \t\t\tisValid = true;\n// \t\t\treturn ctx;\n// \t\t} else {\n// \t\t\tctx.logger.error(\n// \t\t\t\t\"The compiler options have not been adjusted. Please set the `compilerOptions.moduleResolution` to `Bundler`.\"\n// \t\t\t);\n// \t\t}\n// \t}\n\n// \treturn ctx;\n// };\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-ts-config.test.d.ts","sourceRoot":"","sources":["../../../src/cli/steps/update-ts-config.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,60 @@
1
+ import { expect, test, vi } from "vitest";
2
+ import { memfs } from "memfs";
3
+ import { maybeUpdateTsConfigAllowJs } from "./update-ts-config.js";
4
+ import { Logger } from "../../services/logger/index.js";
5
+ const setCwd = (cwd) => {
6
+ const original = process.cwd;
7
+ process.cwd = (() => cwd);
8
+ return () => {
9
+ process.cwd = original;
10
+ };
11
+ };
12
+ // Regression coverage for https://github.com/opral/inlang-paraglide-js/issues/560
13
+ test("skips prompting when allowJs is set in a referenced tsconfig", async () => {
14
+ const fs = memfs({
15
+ "/tsconfig.json": JSON.stringify({
16
+ references: [{ path: "./tsconfig.app.json" }],
17
+ }),
18
+ "/tsconfig.app.json": JSON.stringify({
19
+ compilerOptions: { allowJs: true },
20
+ }),
21
+ }).fs;
22
+ const restoreCwd = setCwd("/");
23
+ const logger = new Logger({ silent: true, prefix: false });
24
+ const infoSpy = vi.spyOn(logger, "info");
25
+ try {
26
+ await maybeUpdateTsConfigAllowJs({
27
+ fs: fs.promises,
28
+ logger,
29
+ });
30
+ expect(infoSpy).not.toHaveBeenCalled();
31
+ }
32
+ finally {
33
+ restoreCwd();
34
+ }
35
+ });
36
+ // Regression coverage for https://github.com/opral/inlang-paraglide-js/issues/560
37
+ test("skips prompting when allowJs is provided via extends", async () => {
38
+ const fs = memfs({
39
+ "/tsconfig.json": JSON.stringify({
40
+ extends: "./tsconfig.base.json",
41
+ }),
42
+ "/tsconfig.base.json": JSON.stringify({
43
+ compilerOptions: { allowJs: true },
44
+ }),
45
+ }).fs;
46
+ const restoreCwd = setCwd("/");
47
+ const logger = new Logger({ silent: true, prefix: false });
48
+ const infoSpy = vi.spyOn(logger, "info");
49
+ try {
50
+ await maybeUpdateTsConfigAllowJs({
51
+ fs: fs.promises,
52
+ logger,
53
+ });
54
+ expect(infoSpy).not.toHaveBeenCalled();
55
+ }
56
+ finally {
57
+ restoreCwd();
58
+ }
59
+ });
60
+ //# sourceMappingURL=update-ts-config.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-ts-config.test.js","sourceRoot":"","sources":["../../../src/cli/steps/update-ts-config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE;IAC9B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAC7B,OAAO,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAuB,CAAC;IAChD,OAAO,GAAG,EAAE;QACX,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC;IACxB,CAAC,CAAC;AACH,CAAC,CAAC;AAEF,kFAAkF;AAClF,IAAI,CAAC,8DAA8D,EAAE,KAAK,IAAI,EAAE;IAC/E,MAAM,EAAE,GAAG,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AK,EAAE,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzC,IAAI,CAAC;QACJ,MAAM,0BAA0B,CAAC;YAChC,EAAE,EAAE,EAAE,CAAC,QAAQ;YACf,MAAM;SACN,CAAC,CAAC;QAEH,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACxC,CAAC;YAAS,CAAC;QACV,UAAU,EAAE,CAAC;IACd,CAAC;AACF,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test, vi } from \"vitest\";\nimport { memfs } from \"memfs\";\nimport { maybeUpdateTsConfigAllowJs } from \"./update-ts-config.js\";\nimport { Logger } from \"../../services/logger/index.js\";\n\nconst setCwd = (cwd: string) => {\n\tconst original = process.cwd;\n\tprocess.cwd = (() => cwd) as typeof process.cwd;\n\treturn () => {\n\t\tprocess.cwd = original;\n\t};\n};\n\n// Regression coverage for https://github.com/opral/inlang-paraglide-js/issues/560\ntest(\"skips prompting when allowJs is set in a referenced tsconfig\", async () => {\n\tconst fs = memfs({\n\t\t\"/tsconfig.json\": JSON.stringify({\n\t\t\treferences: [{ path: \"./tsconfig.app.json\" }],\n\t\t}),\n\t\t\"/tsconfig.app.json\": JSON.stringify({\n\t\t\tcompilerOptions: { allowJs: true },\n\t\t}),\n\t}).fs as unknown as typeof import(\"node:fs\");\n\n\tconst restoreCwd = setCwd(\"/\");\n\tconst logger = new Logger({ silent: true, prefix: false });\n\tconst infoSpy = vi.spyOn(logger, \"info\");\n\n\ttry {\n\t\tawait maybeUpdateTsConfigAllowJs({\n\t\t\tfs: fs.promises,\n\t\t\tlogger,\n\t\t});\n\n\t\texpect(infoSpy).not.toHaveBeenCalled();\n\t} finally {\n\t\trestoreCwd();\n\t}\n});\n\n// Regression coverage for https://github.com/opral/inlang-paraglide-js/issues/560\ntest(\"skips prompting when allowJs is provided via extends\", async () => {\n\tconst fs = memfs({\n\t\t\"/tsconfig.json\": JSON.stringify({\n\t\t\textends: \"./tsconfig.base.json\",\n\t\t}),\n\t\t\"/tsconfig.base.json\": JSON.stringify({\n\t\t\tcompilerOptions: { allowJs: true },\n\t\t}),\n\t}).fs as unknown as typeof import(\"node:fs\");\n\n\tconst restoreCwd = setCwd(\"/\");\n\tconst logger = new Logger({ silent: true, prefix: false });\n\tconst infoSpy = vi.spyOn(logger, \"info\");\n\n\ttry {\n\t\tawait maybeUpdateTsConfigAllowJs({\n\t\t\tfs: fs.promises,\n\t\t\tlogger,\n\t\t});\n\n\t\texpect(infoSpy).not.toHaveBeenCalled();\n\t} finally {\n\t\trestoreCwd();\n\t}\n});\n"]}
@@ -0,0 +1,36 @@
1
+ import consola from "consola";
2
+ /**
3
+ * One step in a CLI chain.
4
+ * Defines which types the context needs to extend and how it extends the context
5
+ *
6
+ * Cli Steps can be chained to slowly build up the context over time
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const step1: CliStep<unknown, { foo: string }> = async (ctx) => {
11
+ * return {...ctx, foo: "hello" }
12
+ * }
13
+ *
14
+ * const step2: CliStep<{ foo: string }, { bar: number }> = async (ctx) => {
15
+ * return { ...ctx, bar: 42 }
16
+ * }
17
+ *
18
+ * const initial = { baz: "baz" } as const;
19
+ * const ctx1 = await step1(initial);
20
+ * const ctx2 = await step2(ctx1);
21
+ *
22
+ * ctx2 // Has type { foo: string, bar: number, baz: "baz" }
23
+ * ```
24
+ */
25
+ export type CliStep<In extends object, Out> = <Ctx extends In>(ctx: Ctx) => Promise<Ctx & Out>;
26
+ /**
27
+ * Wrapper to exit the process if the user presses CTRL+C.
28
+ */
29
+ export declare const prompt: typeof consola.prompt;
30
+ export declare const promptSelection: <T extends string>(message: string, options?: {
31
+ initial?: T;
32
+ options: {
33
+ label: string;
34
+ value: T;
35
+ }[];
36
+ }) => Promise<T>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,SAAS,EAAE,EAC5D,GAAG,EAAE,GAAG,KACJ,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,OAAO,CAAC,MAMnC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,CAAC,SAAS,MAAM,WAC5C,MAAM,YACN;IAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,CAAA;KAAE,EAAE,CAAA;CAAE,KAG9D,OAAO,CAAC,CAAC,CAKX,CAAC"}
@@ -0,0 +1,20 @@
1
+ import consola from "consola";
2
+ /**
3
+ * Wrapper to exit the process if the user presses CTRL+C.
4
+ */
5
+ export const prompt = async (message, options) => {
6
+ const response = await consola.prompt(message, options);
7
+ if (response?.toString() === "Symbol(clack:cancel)") {
8
+ process.exit(0);
9
+ }
10
+ return response;
11
+ };
12
+ export const promptSelection = async (message, options = {
13
+ options: [],
14
+ }) => {
15
+ return prompt(message, {
16
+ type: "select",
17
+ ...options,
18
+ });
19
+ };
20
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AA6B9B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAA0B,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IACvE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxD,IAAI,QAAQ,EAAE,QAAQ,EAAE,KAAK,sBAAsB,EAAE,CAAC;QACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EACnC,OAAe,EACf,OAAO,GAA4D;IAClE,OAAO,EAAE,EAAE;CACX,EACY,EAAE;IACf,OAAO,MAAM,CAAC,OAAO,EAAE;QACtB,IAAI,EAAE,QAAQ;QACd,GAAG,OAAO;KACV,CAA0B,CAAC;AAC7B,CAAC,CAAC","sourcesContent":["import consola from \"consola\";\n\n/**\n * One step in a CLI chain.\n * Defines which types the context needs to extend and how it extends the context\n *\n * Cli Steps can be chained to slowly build up the context over time\n *\n * @example\n * ```ts\n * const step1: CliStep<unknown, { foo: string }> = async (ctx) => {\n * return {...ctx, foo: \"hello\" }\n * }\n *\n * const step2: CliStep<{ foo: string }, { bar: number }> = async (ctx) => {\n * return { ...ctx, bar: 42 }\n * }\n *\n * const initial = { baz: \"baz\" } as const;\n * const ctx1 = await step1(initial);\n * const ctx2 = await step2(ctx1);\n *\n * ctx2 // Has type { foo: string, bar: number, baz: \"baz\" }\n * ```\n */\nexport type CliStep<In extends object, Out> = <Ctx extends In>(\n\tctx: Ctx\n) => Promise<Ctx & Out>;\n\n/**\n * Wrapper to exit the process if the user presses CTRL+C.\n */\nexport const prompt: typeof consola.prompt = async (message, options) => {\n\tconst response = await consola.prompt(message, options);\n\tif (response?.toString() === \"Symbol(clack:cancel)\") {\n\t\tprocess.exit(0);\n\t}\n\treturn response;\n};\n\nexport const promptSelection = async <T extends string>(\n\tmessage: string,\n\toptions: { initial?: T; options: { label: string; value: T }[] } = {\n\t\toptions: [],\n\t}\n): Promise<T> => {\n\treturn prompt(message, {\n\t\ttype: \"select\",\n\t\t...options,\n\t}) as unknown as Promise<T>;\n};\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Ensures the global URLPattern API is available.
3
+ *
4
+ * Required when compiling or evaluating custom `urlPatterns` / `routeStrategies`.
5
+ * Default locale-prefix routing and `routing` do not need URLPattern.
6
+ */
7
+ export declare function assertURLPatternAvailable(): void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-url-pattern-available.d.ts","sourceRoot":"","sources":["../../src/compiler/assert-url-pattern-available.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAUhD"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Ensures the global URLPattern API is available.
3
+ *
4
+ * Required when compiling or evaluating custom `urlPatterns` / `routeStrategies`.
5
+ * Default locale-prefix routing and `routing` do not need URLPattern.
6
+ */
7
+ export function assertURLPatternAvailable() {
8
+ try {
9
+ new URLPattern({ pathname: "/:path(.*)?" });
10
+ }
11
+ catch {
12
+ throw new Error(`URLPattern is required for custom urlPatterns / routeStrategies. ` +
13
+ `Node.js 22+ includes it natively. For older runtimes, install and import ` +
14
+ `"urlpattern-polyfill" before compiling. See https://paraglidejs.com/i18n-routing#urlpattern-compatibility`);
15
+ }
16
+ }
17
+ //# sourceMappingURL=assert-url-pattern-available.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-url-pattern-available.js","sourceRoot":"","sources":["../../src/compiler/assert-url-pattern-available.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB;IACxC,IAAI,CAAC;QACJ,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACR,MAAM,IAAI,KAAK,CACd,mEAAmE;YAClE,2EAA2E;YAC3E,2GAA2G,CAC5G,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["/**\n * Ensures the global URLPattern API is available.\n *\n * Required when compiling or evaluating custom `urlPatterns` / `routeStrategies`.\n * Default locale-prefix routing and `routing` do not need URLPattern.\n */\nexport function assertURLPatternAvailable(): void {\n\ttry {\n\t\tnew URLPattern({ pathname: \"/:path(.*)?\" });\n\t} catch {\n\t\tthrow new Error(\n\t\t\t`URLPattern is required for custom urlPatterns / routeStrategies. ` +\n\t\t\t\t`Node.js 22+ includes it natively. For older runtimes, install and import ` +\n\t\t\t\t`\"urlpattern-polyfill\" before compiling. See https://paraglidejs.com/i18n-routing#urlpattern-compatibility`\n\t\t);\n\t}\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { FunctionReference } from "../messages/ast.js";
2
+ export declare function isRegistryFunction(name: string): boolean;
3
+ export declare function registryFunctionNamesForDisplay(): string;
4
+ /**
5
+ * Wraps a compiled expression value in a `registry.*` call if an
6
+ * annotation is present.
7
+ *
8
+ * @example
9
+ * compileAnnotation("i?.count", "en", { type: "function-reference", name: "number", options: [] })
10
+ * >> 'registry.number("en", i?.count, {})'
11
+ */
12
+ export declare function compileAnnotation(str: string, locale: string, annotation?: FunctionReference): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-annotation.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EAGjB,MAAM,oBAAoB,CAAC;AAgB5B,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,+BAA+B,IAAI,MAAM,CAExD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,iBAAiB,GAC5B,MAAM,CAQR"}
@@ -0,0 +1,136 @@
1
+ import { compileInputAccess } from "./variable-access.js";
2
+ import { escapeForDoubleQuoteString } from "../services/codegen/escape.js";
3
+ /**
4
+ * The functions shipped in the generated registry.js file.
5
+ *
6
+ * @see createRegistry()
7
+ */
8
+ const registryFunctionNames = new Set([
9
+ "plural",
10
+ "number",
11
+ "datetime",
12
+ "relativetime",
13
+ ]);
14
+ export function isRegistryFunction(name) {
15
+ return registryFunctionNames.has(name);
16
+ }
17
+ export function registryFunctionNamesForDisplay() {
18
+ return Array.from(registryFunctionNames).join(", ");
19
+ }
20
+ /**
21
+ * Wraps a compiled expression value in a `registry.*` call if an
22
+ * annotation is present.
23
+ *
24
+ * @example
25
+ * compileAnnotation("i?.count", "en", { type: "function-reference", name: "number", options: [] })
26
+ * >> 'registry.number("en", i?.count, {})'
27
+ */
28
+ export function compileAnnotation(str, locale, annotation) {
29
+ if (!annotation) {
30
+ return str;
31
+ }
32
+ if (annotation.name === "relativetime") {
33
+ validateRelativeTimeOptions(annotation);
34
+ }
35
+ return `registry.${annotation.name}("${locale}", ${str}, ${compileOptions(annotation.name, annotation.options)})`;
36
+ }
37
+ function compileOptions(annotationName, options) {
38
+ if (options.length === 0) {
39
+ return "{}";
40
+ }
41
+ const entries = options.map((option) => `${option.name}: ${compileOptionLiteralOrVarRef(annotationName, option.name, option.value)}`);
42
+ const code = "{ " + entries.join(", ") + " }";
43
+ return code;
44
+ }
45
+ const numericOptionNamesByAnnotation = {
46
+ number: new Set([
47
+ "minimumIntegerDigits",
48
+ "minimumFractionDigits",
49
+ "maximumFractionDigits",
50
+ "minimumSignificantDigits",
51
+ "maximumSignificantDigits",
52
+ "roundingIncrement",
53
+ ]),
54
+ plural: new Set([
55
+ "minimumIntegerDigits",
56
+ "minimumFractionDigits",
57
+ "maximumFractionDigits",
58
+ "minimumSignificantDigits",
59
+ "maximumSignificantDigits",
60
+ ]),
61
+ datetime: new Set(["fractionalSecondDigits"]),
62
+ };
63
+ const booleanOptionNamesByAnnotation = {
64
+ number: new Set(["useGrouping"]),
65
+ datetime: new Set(["hour12"]),
66
+ };
67
+ const jsNonNegativeIntegerPattern = /^(?:0|[1-9]\d*)$/;
68
+ function compileOptionLiteralOrVarRef(annotationName, optionName, value) {
69
+ if (value.type === "variable-reference") {
70
+ if (annotationName === "relativetime" && optionName === "unit") {
71
+ return `/** @type {import("../registry.js").RelativeTimeFormatUnit} */ (${compileInputAccess(value.name)})`;
72
+ }
73
+ return compileInputAccess(value.name);
74
+ }
75
+ if (annotationName === "relativetime" &&
76
+ optionName === "unit" &&
77
+ isDollarVariableReference(value.value)) {
78
+ return `/** @type {import("../registry.js").RelativeTimeFormatUnit} */ (${compileInputAccess(value.value.slice(1))})`;
79
+ }
80
+ if (shouldEmitNumberLiteral(annotationName, optionName, value.value)) {
81
+ return value.value;
82
+ }
83
+ if (shouldEmitBooleanLiteral(annotationName, optionName, value.value)) {
84
+ return value.value;
85
+ }
86
+ return `"${escapeForDoubleQuoteString(value.value)}"`;
87
+ }
88
+ function shouldEmitNumberLiteral(annotationName, optionName, literal) {
89
+ return (numericOptionNamesByAnnotation[annotationName]?.has(optionName) === true &&
90
+ jsNonNegativeIntegerPattern.test(literal));
91
+ }
92
+ function shouldEmitBooleanLiteral(annotationName, optionName, literal) {
93
+ return (booleanOptionNamesByAnnotation[annotationName]?.has(optionName) === true &&
94
+ (literal === "true" || literal === "false"));
95
+ }
96
+ const relativeTimeUnits = new Set([
97
+ "year",
98
+ "years",
99
+ "quarter",
100
+ "quarters",
101
+ "month",
102
+ "months",
103
+ "week",
104
+ "weeks",
105
+ "day",
106
+ "days",
107
+ "hour",
108
+ "hours",
109
+ "minute",
110
+ "minutes",
111
+ "second",
112
+ "seconds",
113
+ ]);
114
+ function validateRelativeTimeOptions(annotation) {
115
+ const unitOptions = annotation.options.filter((option) => option.name === "unit");
116
+ if (unitOptions.length === 0) {
117
+ throw new Error('The "relativetime" formatter requires a "unit" option.');
118
+ }
119
+ if (unitOptions.length > 1) {
120
+ throw new Error('The "relativetime" formatter requires exactly one "unit" option.');
121
+ }
122
+ const [unitOption] = unitOptions;
123
+ if (!unitOption || unitOption.value.type === "variable-reference") {
124
+ return;
125
+ }
126
+ if (isDollarVariableReference(unitOption.value.value)) {
127
+ return;
128
+ }
129
+ if (!relativeTimeUnits.has(unitOption.value.value)) {
130
+ throw new Error(`Invalid "relativetime" unit "${unitOption.value.value}". Expected one of: ${Array.from(relativeTimeUnits).join(", ")}.`);
131
+ }
132
+ }
133
+ function isDollarVariableReference(value) {
134
+ return value.startsWith("$") && value.length > 1;
135
+ }
136
+ //# sourceMappingURL=compile-annotation.js.map