@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,49 @@
1
+ import path from "node:path";
2
+ import { importFiles } from "./message-format/import-files.js";
3
+ import { nestBundles } from "./nest-bundles.js";
4
+ /**
5
+ * Reads locale JSON files and parses them into compiler-ready bundles.
6
+ */
7
+ export async function loadMessages(options) {
8
+ const cwd = options.cwd ?? process.cwd();
9
+ const settings = {
10
+ baseLocale: options.baseLocale,
11
+ locales: [...options.locales],
12
+ };
13
+ if (settings.locales.length === 0) {
14
+ throw new Error("At least one locale is required.");
15
+ }
16
+ if (!settings.locales.includes(settings.baseLocale)) {
17
+ throw new Error(`baseLocale "${settings.baseLocale}" must be one of locales: ${settings.locales.join(", ")}`);
18
+ }
19
+ const files = [];
20
+ for (const locale of settings.locales) {
21
+ const relativePath = options.messages.replace("{locale}", locale);
22
+ const absolutePath = path.resolve(cwd, relativePath);
23
+ let content;
24
+ try {
25
+ content = await options.fs.promises.readFile(absolutePath);
26
+ }
27
+ catch (error) {
28
+ if (isEnoent(error)) {
29
+ throw new Error(`Missing message file for locale "${locale}": ${relativePath}`);
30
+ }
31
+ throw error;
32
+ }
33
+ files.push({
34
+ locale,
35
+ content: new Uint8Array(content),
36
+ name: relativePath,
37
+ });
38
+ }
39
+ const imported = importFiles({ files });
40
+ const bundles = nestBundles(imported);
41
+ return { bundles, settings };
42
+ }
43
+ function isEnoent(error) {
44
+ return (typeof error === "object" &&
45
+ error !== null &&
46
+ "code" in error &&
47
+ error.code === "ENOENT");
48
+ }
49
+ //# sourceMappingURL=load-messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-messages.js","sourceRoot":"","sources":["../../src/messages/load-messages.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAkBhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,OAA4B;IAE5B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,QAAQ,GAAsB;QACnC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;KAC7B,CAAC;IAEF,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,C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f,KAAK,CAAC,IAAI,KAAK,QAAQ,CACvB,CAAC;AACH,CAAC","sourcesContent":["import path from \"node:path\";\nimport type { BundleNested, ParaglideSettings } from \"./ast.js\";\nimport { importFiles } from \"./message-format/import-files.js\";\nimport { nestBundles } from \"./nest-bundles.js\";\n\nexport type LoadMessagesOptions = ParaglideSettings & {\n\t/**\n\t * Path pattern with a `{locale}` placeholder.\n\t *\n\t * @example \"./messages/{locale}.json\"\n\t */\n\tmessages: string;\n\tfs: typeof import(\"node:fs\");\n\tcwd?: string;\n};\n\nexport type LoadedMessages = {\n\tbundles: BundleNested[];\n\tsettings: ParaglideSettings;\n};\n\n/**\n * Reads locale JSON files and parses them into compiler-ready bundles.\n */\nexport async function loadMessages(\n\toptions: LoadMessagesOptions\n): Promise<LoadedMessages> {\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst settings: ParaglideSettings = {\n\t\tbaseLocale: options.baseLocale,\n\t\tlocales: [...options.locales],\n\t};\n\n\tif (settings.locales.length === 0) {\n\t\tthrow new Error(\"At least one locale is required.\");\n\t}\n\n\tif (!settings.locales.includes(settings.baseLocale)) {\n\t\tthrow new Error(\n\t\t\t`baseLocale \"${settings.baseLocale}\" must be one of locales: ${settings.locales.join(\", \")}`\n\t\t);\n\t}\n\n\tconst files: Array<{\n\t\tlocale: string;\n\t\tcontent: Uint8Array;\n\t\tname: string;\n\t}> = [];\n\n\tfor (const locale of settings.locales) {\n\t\tconst relativePath = options.messages.replace(\"{locale}\", locale);\n\t\tconst absolutePath = path.resolve(cwd, relativePath);\n\t\tlet content: Buffer;\n\t\ttry {\n\t\t\tcontent = await options.fs.promises.readFile(absolutePath);\n\t\t} catch (error) {\n\t\t\tif (isEnoent(error)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Missing message file for locale \"${locale}\": ${relativePath}`\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\tfiles.push({\n\t\t\tlocale,\n\t\t\tcontent: new Uint8Array(content),\n\t\t\tname: relativePath,\n\t\t});\n\t}\n\n\tconst imported = importFiles({ files });\n\tconst bundles = nestBundles(imported);\n\n\treturn { bundles, settings };\n}\n\nfunction isEnoent(error: unknown): boolean {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"code\" in error &&\n\t\terror.code === \"ENOENT\"\n\t);\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Safe object flatten — nested plain objects become dotted keys, arrays stay values.
3
+ * Adapted from the `flat` package behavior used by @inlang/plugin-message-format.
4
+ */
5
+ export declare function flatten(target: Record<string, unknown>, opts?: {
6
+ delimiter?: string;
7
+ maxDepth?: number;
8
+ safe?: boolean;
9
+ }): Record<string, unknown>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../../src/messages/message-format/flatten.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqCzB"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Safe object flatten — nested plain objects become dotted keys, arrays stay values.
3
+ * Adapted from the `flat` package behavior used by @inlang/plugin-message-format.
4
+ */
5
+ export function flatten(target, opts) {
6
+ const delimiter = opts?.delimiter ?? ".";
7
+ const maxDepth = opts?.maxDepth;
8
+ const safe = opts?.safe ?? false;
9
+ const output = {};
10
+ function step(object, prev, currentDepth) {
11
+ for (const key of Object.keys(object)) {
12
+ const value = object[key];
13
+ const isarray = safe && Array.isArray(value);
14
+ const type = Object.prototype.toString.call(value);
15
+ const isobject = type === "[object Object]" || type === "[object Array]";
16
+ const newKey = prev ? prev + delimiter + key : key;
17
+ if (!isarray &&
18
+ isobject &&
19
+ value !== null &&
20
+ typeof value === "object" &&
21
+ Object.keys(value).length > 0 &&
22
+ (!maxDepth || currentDepth < maxDepth)) {
23
+ step(value, newKey, currentDepth + 1);
24
+ continue;
25
+ }
26
+ output[newKey] = value;
27
+ }
28
+ }
29
+ step(target, undefined, 1);
30
+ return output;
31
+ }
32
+ //# sourceMappingURL=flatten.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten.js","sourceRoot":"","sources":["../../../src/messages/message-format/flatten.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,OAAO,CACtB,MAA+B,EAC/B,IAAgE;IAEhE,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,GAAG,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,KAAK,CAAC;IACjC,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,SAAS,IAAI,CACZ,MAA+B,EAC/B,IAAwB,EACxB,YAAoB;QAEpB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC1B,MAAM,OAAO,GAAG,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnD,MAAM,QAAQ,GACb,IAAI,KAAK,iBAAiB,IAAI,IAAI,KAAK,gBAAgB,CAAC;YACzD,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAEnD,IACC,CAAC,OAAO;gBACR,QAAQ;gBACR,KAAK,KAAK,IAAI;gBACd,OAAO,KAAK,KAAK,QAAQ;gBACzB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;gBAC7B,CAAC,CAAC,QAAQ,IAAI,YAAY,GAAG,QAAQ,CAAC,EACrC,CAAC;gBACF,IAAI,CAAC,KAAgC,EAAE,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;gBACjE,SAAS;YACV,CAAC;YAED,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;IACF,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/**\n * Safe object flatten — nested plain objects become dotted keys, arrays stay values.\n * Adapted from the `flat` package behavior used by @inlang/plugin-message-format.\n */\nexport function flatten(\n\ttarget: Record<string, unknown>,\n\topts?: { delimiter?: string; maxDepth?: number; safe?: boolean }\n): Record<string, unknown> {\n\tconst delimiter = opts?.delimiter ?? \".\";\n\tconst maxDepth = opts?.maxDepth;\n\tconst safe = opts?.safe ?? false;\n\tconst output: Record<string, unknown> = {};\n\n\tfunction step(\n\t\tobject: Record<string, unknown>,\n\t\tprev: string | undefined,\n\t\tcurrentDepth: number\n\t) {\n\t\tfor (const key of Object.keys(object)) {\n\t\t\tconst value = object[key];\n\t\t\tconst isarray = safe && Array.isArray(value);\n\t\t\tconst type = Object.prototype.toString.call(value);\n\t\t\tconst isobject =\n\t\t\t\ttype === \"[object Object]\" || type === \"[object Array]\";\n\t\t\tconst newKey = prev ? prev + delimiter + key : key;\n\n\t\t\tif (\n\t\t\t\t!isarray &&\n\t\t\t\tisobject &&\n\t\t\t\tvalue !== null &&\n\t\t\t\ttypeof value === \"object\" &&\n\t\t\t\tObject.keys(value).length > 0 &&\n\t\t\t\t(!maxDepth || currentDepth < maxDepth)\n\t\t\t) {\n\t\t\t\tstep(value as Record<string, unknown>, newKey, currentDepth + 1);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\toutput[newKey] = value;\n\t\t}\n\t}\n\n\tstep(target, undefined, 1);\n\treturn output;\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import type { Declaration, Match, Pattern, VariableReference } from "../ast.js";
2
+ import { type FlatVariant } from "./parse-bundle.js";
3
+ export type ImportFile = {
4
+ locale: string;
5
+ content: Uint8Array;
6
+ name: string;
7
+ };
8
+ export type FlatImport = {
9
+ bundles: Array<{
10
+ id: string;
11
+ declarations: Declaration[];
12
+ }>;
13
+ messages: Array<{
14
+ bundleId: string;
15
+ locale: string;
16
+ selectors: VariableReference[];
17
+ }>;
18
+ variants: FlatVariant[];
19
+ };
20
+ /**
21
+ * Parses locale JSON message files into flat bundle/message/variant records.
22
+ *
23
+ * Compatible with the @inlang/plugin-message-format import shape.
24
+ *
25
+ * The first locale that mentions a key runs the full bundle parse. Later
26
+ * locales only parse that locale's message contribution and merge any newly
27
+ * discovered declarations — avoiding repeated bundle finalization work.
28
+ */
29
+ export declare function importFiles(args: {
30
+ files: ImportFile[];
31
+ }): FlatImport;
32
+ export type { Match, Pattern };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-files.d.ts","sourceRoot":"","sources":["../../../src/messages/message-format/import-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGlE,MAAM,MAAM,UAAU,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,UAAU,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACxB,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC,CAAC;IAC5D,QAAQ,EAAE,KAAK,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,iBAAiB,EAAE,CAAC;KAC/B,CAAC,CAAC;IACH,QAAQ,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,UAAU,EAAE,CAAA;CAAE,GAAG,UAAU,CAiCrE;AAED,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { flatten } from "./flatten.js";
2
+ import { parseBundle, parseLocaleContribution, } from "./parse-bundle.js";
3
+ /**
4
+ * Parses locale JSON message files into flat bundle/message/variant records.
5
+ *
6
+ * Compatible with the @inlang/plugin-message-format import shape.
7
+ *
8
+ * The first locale that mentions a key runs the full bundle parse. Later
9
+ * locales only parse that locale's message contribution and merge any newly
10
+ * discovered declarations — avoiding repeated bundle finalization work.
11
+ */
12
+ export function importFiles(args) {
13
+ const bundles = [];
14
+ const bundlesById = new Map();
15
+ const declarationKeysById = new Map();
16
+ const messages = [];
17
+ const variants = [];
18
+ for (const file of args.files) {
19
+ const json = JSON.parse(new TextDecoder().decode(file.content));
20
+ const flattened = flatten(json, { safe: true });
21
+ for (const key of Object.keys(flattened)) {
22
+ if (key === "$schema") {
23
+ continue;
24
+ }
25
+ const existingBundle = bundlesById.get(key);
26
+ if (existingBundle === undefined) {
27
+ const result = parseBundle(key, file.locale, flattened[key]);
28
+ messages.push(result.message);
29
+ variants.push(...result.variants);
30
+ bundles.push(result.bundle);
31
+ bundlesById.set(result.bundle.id, result.bundle);
32
+ declarationKeysById.set(result.bundle.id, new Set(result.bundle.declarations.map((declaration) => JSON.stringify(declaration))));
33
+ continue;
34
+ }
35
+ const result = parseLocaleContribution(key, file.locale, flattened[key]);
36
+ messages.push(result.message);
37
+ variants.push(...result.variants);
38
+ mergeDeclarations(existingBundle, declarationKeysById.get(key), result.declarations);
39
+ }
40
+ }
41
+ return { bundles, messages, variants };
42
+ }
43
+ function mergeDeclarations(bundle, seen, incoming) {
44
+ for (const declaration of incoming) {
45
+ const key = JSON.stringify(declaration);
46
+ if (seen.has(key)) {
47
+ continue;
48
+ }
49
+ bundle.declarations.push(declaration);
50
+ seen.add(key);
51
+ }
52
+ }
53
+ //# sourceMappingURL=import-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-files.js","sourceRoot":"","sources":["../../../src/messages/message-format/import-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACN,WAAW,EACX,uBAAuB,GAEvB,MAAM,mBAAmB,CAAC;AAkB3B;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,IAA6B;IACxD,MAAM,OAAO,GAA0B,EAAE,CAAC;IAC1C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAyC,CAAC;IACrE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC3D,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,MAAM,QAAQ,GAAkB,EAAE,CAAC;IAEnC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CACtB,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CACX,CAAC;QAC7B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAEhD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACvB,SAAS;YACV,CAAC;YAED,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,C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Q,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACxC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACnB,SAAS;QACV,CAAC;QACD,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;AACF,CAAC","sourcesContent":["import type { Declaration, Match, Pattern, VariableReference } from \"../ast.js\";\nimport { flatten } from \"./flatten.js\";\nimport {\n\tparseBundle,\n\tparseLocaleContribution,\n\ttype FlatVariant,\n} from \"./parse-bundle.js\";\n\nexport type ImportFile = {\n\tlocale: string;\n\tcontent: Uint8Array;\n\tname: string;\n};\n\nexport type FlatImport = {\n\tbundles: Array<{ id: string; declarations: Declaration[] }>;\n\tmessages: Array<{\n\t\tbundleId: string;\n\t\tlocale: string;\n\t\tselectors: VariableReference[];\n\t}>;\n\tvariants: FlatVariant[];\n};\n\n/**\n * Parses locale JSON message files into flat bundle/message/variant records.\n *\n * Compatible with the @inlang/plugin-message-format import shape.\n *\n * The first locale that mentions a key runs the full bundle parse. Later\n * locales only parse that locale's message contribution and merge any newly\n * discovered declarations — avoiding repeated bundle finalization work.\n */\nexport function importFiles(args: { files: ImportFile[] }): FlatImport {\n\tconst bundles: FlatImport[\"bundles\"] = [];\n\tconst bundlesById = new Map<string, FlatImport[\"bundles\"][number]>();\n\tconst declarationKeysById = new Map<string, Set<string>>();\n\tconst messages: FlatImport[\"messages\"] = [];\n\tconst variants: FlatVariant[] = [];\n\n\tfor (const file of args.files) {\n\t\tconst json = JSON.parse(\n\t\t\tnew TextDecoder().decode(file.content)\n\t\t) as Record<string, unknown>;\n\t\tconst flattened = flatten(json, { safe: true });\n\n\t\tfor (const key of Object.keys(flattened)) {\n\t\t\tif (key === \"$schema\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst existingBundle = bundlesById.get(key);\n\t\t\tif (existingBundle === undefined) {\n\t\t\t\tconst result = parseBundle(key, file.locale, flattened[key]);\n\t\t\t\tmessages.push(result.message);\n\t\t\t\tvariants.push(...result.variants);\n\t\t\t\tbundles.push(result.bundle);\n\t\t\t\tbundlesById.set(result.bundle.id, result.bundle);\n\t\t\t\tdeclarationKeysById.set(\n\t\t\t\t\tresult.bundle.id,\n\t\t\t\t\tnew Set(\n\t\t\t\t\t\tresult.bundle.declarations.map((declaration) =>\n\t\t\t\t\t\t\tJSON.stringify(declaration)\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = parseLocaleContribution(\n\t\t\t\tkey,\n\t\t\t\tfile.locale,\n\t\t\t\tflattened[key]\n\t\t\t);\n\t\t\tmessages.push(result.message);\n\t\t\tvariants.push(...result.variants);\n\t\t\tmergeDeclarations(\n\t\t\t\texistingBundle,\n\t\t\t\tdeclarationKeysById.get(key)!,\n\t\t\t\tresult.declarations\n\t\t\t);\n\t\t}\n\t}\n\n\treturn { bundles, messages, variants };\n}\n\nfunction mergeDeclarations(\n\tbundle: FlatImport[\"bundles\"][number],\n\tseen: Set<string>,\n\tincoming: Declaration[]\n): void {\n\tfor (const declaration of incoming) {\n\t\tconst key = JSON.stringify(declaration);\n\t\tif (seen.has(key)) {\n\t\t\tcontinue;\n\t\t}\n\t\tbundle.declarations.push(declaration);\n\t\tseen.add(key);\n\t}\n}\n\nexport type { Match, Pattern };\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-files.test.d.ts","sourceRoot":"","sources":["../../../src/messages/message-format/import-files.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,145 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { readFileSync } from "node:fs";
3
+ import { flatten } from "./flatten.js";
4
+ import { importFiles } from "./import-files.js";
5
+ import { parsePattern } from "./parse-pattern.js";
6
+ import { parseDeclaration } from "./parse-declaration.js";
7
+ import { nestBundles } from "../nest-bundles.js";
8
+ function encode(json) {
9
+ return new TextEncoder().encode(JSON.stringify(json));
10
+ }
11
+ describe("flatten", () => {
12
+ test("flattens nested objects but keeps arrays", () => {
13
+ expect(flatten({
14
+ a: { b: "x" },
15
+ c: [{ match: { "n=*": "y" } }],
16
+ }, { safe: true })).toEqual({
17
+ "a.b": "x",
18
+ c: [{ match: { "n=*": "y" } }],
19
+ });
20
+ });
21
+ });
22
+ describe("parsePattern", () => {
23
+ test("parses text and placeholders", () => {
24
+ expect(parsePattern("Hello {name}!")).toEqual({
25
+ declarations: [{ type: "input-variable", name: "name" }],
26
+ pattern: [
27
+ { type: "text", value: "Hello " },
28
+ {
29
+ type: "expression",
30
+ arg: { type: "variable-reference", name: "name" },
31
+ },
32
+ { type: "text", value: "!" },
33
+ ],
34
+ });
35
+ });
36
+ test("handles escapes", () => {
37
+ expect(parsePattern("Use \\{brace\\}")).toEqual({
38
+ declarations: [],
39
+ pattern: [{ type: "text", value: "Use {brace}" }],
40
+ });
41
+ });
42
+ test("parses markup", () => {
43
+ expect(parsePattern("Hi {#b}bold{/b}!")).toEqual({
44
+ declarations: [],
45
+ pattern: [
46
+ { type: "text", value: "Hi " },
47
+ { type: "markup-start", name: "b" },
48
+ { type: "text", value: "bold" },
49
+ { type: "markup-end", name: "b" },
50
+ { type: "text", value: "!" },
51
+ ],
52
+ });
53
+ });
54
+ });
55
+ describe("parseDeclaration", () => {
56
+ test("parses local with options and variable refs", () => {
57
+ expect(parseDeclaration("local formattedDuration = duration: relativetime unit=$unit style=short")).toEqual({
58
+ type: "local-variable",
59
+ name: "formattedDuration",
60
+ value: {
61
+ type: "expression",
62
+ arg: { type: "variable-reference", name: "duration" },
63
+ annotation: {
64
+ type: "function-reference",
65
+ name: "relativetime",
66
+ options: [
67
+ {
68
+ name: "unit",
69
+ value: { type: "variable-reference", name: "unit" },
70
+ },
71
+ { name: "style", value: { type: "literal", value: "short" } },
72
+ ],
73
+ },
74
+ },
75
+ });
76
+ });
77
+ });
78
+ describe("importFiles", () => {
79
+ test("imports simple, nested, and complex messages from fixtures", () => {
80
+ const en = JSON.parse(readFileSync(new URL("../../../examples/cli/messages/en.json", import.meta.url), "utf8"));
81
+ const imported = importFiles({
82
+ files: [{ locale: "en", content: encode(en), name: "en.json" }],
83
+ });
84
+ const bundles = nestBundles(imported);
85
+ const byId = Object.fromEntries(bundles.map((b) => [b.id, b]));
86
+ expect(byId.simple?.messages[0]?.variants[0]?.pattern).toEqual([
87
+ { type: "text", value: "This is a simple message." },
88
+ ]);
89
+ expect(byId["nesting.level1.level2.level3"]).toBeDefined();
90
+ expect(byId.jojo_mountain_day?.messages[0]?.variants.length).toBe(3);
91
+ expect(byId.blue_horse_shoe?.declarations.map((d) => d.name).sort()).toEqual(["placename", "username"]);
92
+ });
93
+ test("imports formatting declarations", () => {
94
+ const en = JSON.parse(readFileSync(new URL("./fixtures/formatting-en.json", import.meta.url), "utf8"));
95
+ const bundles = nestBundles(importFiles({
96
+ files: [{ locale: "en", content: encode(en), name: "en.json" }],
97
+ }));
98
+ const balance = bundles.find((b) => b.id === "personal_balance");
99
+ expect(balance?.declarations.some((d) => d.type === "local-variable")).toBe(true);
100
+ expect(balance?.messages[0]?.variants[0]?.matches[0]?.type).toBe("catchall-match");
101
+ });
102
+ test("merges declarations across locales", () => {
103
+ const imported = importFiles({
104
+ files: [
105
+ {
106
+ locale: "en",
107
+ content: encode({ hello: "Hello {name}" }),
108
+ name: "en.json",
109
+ },
110
+ {
111
+ locale: "de",
112
+ content: encode({ hello: "Hallo {name}" }),
113
+ name: "de.json",
114
+ },
115
+ ],
116
+ });
117
+ expect(imported.bundles).toHaveLength(1);
118
+ expect(imported.messages).toHaveLength(2);
119
+ expect(imported.variants).toHaveLength(2);
120
+ expect(imported.bundles[0]?.declarations).toEqual([
121
+ { type: "input-variable", name: "name" },
122
+ ]);
123
+ });
124
+ test("merges additional declarations from a later locale", () => {
125
+ const imported = importFiles({
126
+ files: [
127
+ {
128
+ locale: "en",
129
+ content: encode({ hello: "Hello" }),
130
+ name: "en.json",
131
+ },
132
+ {
133
+ locale: "de",
134
+ content: encode({ hello: "Hallo {name}" }),
135
+ name: "de.json",
136
+ },
137
+ ],
138
+ });
139
+ expect(imported.bundles).toHaveLength(1);
140
+ expect(imported.bundles[0]?.declarations).toEqual([
141
+ { type: "input-variable", name: "name" },
142
+ ]);
143
+ });
144
+ });
145
+ //# sourceMappingURL=import-files.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-files.test.js","sourceRoot":"","sources":["../../../src/messages/message-format/import-files.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,SAAS,MAAM,CAAC,IAAa;IAC5B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACxB,IAAI,CAAC,0CAA0C,EAAE,GAAG,EAAE;QACrD,MAAM,CACL,OAAO,CACN;YACC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE;YACb,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;SAC9B,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACd,CACD,CAAC,OAAO,CAAC;YAC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Y,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC;YACjD,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE;SACxC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC/D,MAAM,QAAQ,GAAG,WAAW,CAAC;YAC5B,KAAK,EAAE;gBACN;oBACC,MAAM,EAAE,IAAI;oBACZ,OAAO,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;oBACnC,IAAI,EAAE,SAAS;iBACf;gBACD;oBACC,MAAM,EAAE,IAAI;oBACZ,OAAO,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;oBAC1C,IAAI,EAAE,SAAS;iBACf;aACD;SACD,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC;YACjD,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE;SACxC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"vitest\";\nimport { readFileSync } from \"node:fs\";\nimport { flatten } from \"./flatten.js\";\nimport { importFiles } from \"./import-files.js\";\nimport { parsePattern } from \"./parse-pattern.js\";\nimport { parseDeclaration } from \"./parse-declaration.js\";\nimport { nestBundles } from \"../nest-bundles.js\";\n\nfunction encode(json: unknown): Uint8Array {\n\treturn new TextEncoder().encode(JSON.stringify(json));\n}\n\ndescribe(\"flatten\", () => {\n\ttest(\"flattens nested objects but keeps arrays\", () => {\n\t\texpect(\n\t\t\tflatten(\n\t\t\t\t{\n\t\t\t\t\ta: { b: \"x\" },\n\t\t\t\t\tc: [{ match: { \"n=*\": \"y\" } }],\n\t\t\t\t},\n\t\t\t\t{ safe: true }\n\t\t\t)\n\t\t).toEqual({\n\t\t\t\"a.b\": \"x\",\n\t\t\tc: [{ match: { \"n=*\": \"y\" } }],\n\t\t});\n\t});\n});\n\ndescribe(\"parsePattern\", () => {\n\ttest(\"parses text and placeholders\", () => {\n\t\texpect(parsePattern(\"Hello {name}!\")).toEqual({\n\t\t\tdeclarations: [{ type: \"input-variable\", name: \"name\" }],\n\t\t\tpattern: [\n\t\t\t\t{ type: \"text\", value: \"Hello \" },\n\t\t\t\t{\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"name\" },\n\t\t\t\t},\n\t\t\t\t{ type: \"text\", value: \"!\" },\n\t\t\t],\n\t\t});\n\t});\n\n\ttest(\"handles escapes\", () => {\n\t\texpect(parsePattern(\"Use \\\\{brace\\\\}\")).toEqual({\n\t\t\tdeclarations: [],\n\t\t\tpattern: [{ type: \"text\", value: \"Use {brace}\" }],\n\t\t});\n\t});\n\n\ttest(\"parses markup\", () => {\n\t\texpect(parsePattern(\"Hi {#b}bold{/b}!\")).toEqual({\n\t\t\tdeclarations: [],\n\t\t\tpattern: [\n\t\t\t\t{ type: \"text\", value: \"Hi \" },\n\t\t\t\t{ type: \"markup-start\", name: \"b\" },\n\t\t\t\t{ type: \"text\", value: \"bold\" },\n\t\t\t\t{ type: \"markup-end\", name: \"b\" },\n\t\t\t\t{ type: \"text\", value: \"!\" },\n\t\t\t],\n\t\t});\n\t});\n});\n\ndescribe(\"parseDeclaration\", () => {\n\ttest(\"parses local with options and variable refs\", () => {\n\t\texpect(\n\t\t\tparseDeclaration(\n\t\t\t\t\"local formattedDuration = duration: relativetime unit=$unit style=short\"\n\t\t\t)\n\t\t).toEqual({\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"unit\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"unit\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ name: \"style\", value: { type: \"literal\", value: \"short\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t});\n});\n\ndescribe(\"importFiles\", () => {\n\ttest(\"imports simple, nested, and complex messages from fixtures\", () => {\n\t\tconst en = JSON.parse(\n\t\t\treadFileSync(\n\t\t\t\tnew URL(\"../../../examples/cli/messages/en.json\", import.meta.url),\n\t\t\t\t\"utf8\"\n\t\t\t)\n\t\t);\n\t\tconst imported = importFiles({\n\t\t\tfiles: [{ locale: \"en\", content: encode(en), name: \"en.json\" }],\n\t\t});\n\t\tconst bundles = nestBundles(imported);\n\t\tconst byId = Object.fromEntries(bundles.map((b) => [b.id, b]));\n\n\t\texpect(byId.simple?.messages[0]?.variants[0]?.pattern).toEqual([\n\t\t\t{ type: \"text\", value: \"This is a simple message.\" },\n\t\t]);\n\t\texpect(byId[\"nesting.level1.level2.level3\"]).toBeDefined();\n\t\texpect(byId.jojo_mountain_day?.messages[0]?.variants.length).toBe(3);\n\t\texpect(byId.blue_horse_shoe?.declarations.map((d) => d.name).sort()).toEqual(\n\t\t\t[\"placename\", \"username\"]\n\t\t);\n\t});\n\n\ttest(\"imports formatting declarations\", () => {\n\t\tconst en = JSON.parse(\n\t\t\treadFileSync(\n\t\t\t\tnew URL(\"./fixtures/formatting-en.json\", import.meta.url),\n\t\t\t\t\"utf8\"\n\t\t\t)\n\t\t);\n\t\tconst bundles = nestBundles(\n\t\t\timportFiles({\n\t\t\t\tfiles: [{ locale: \"en\", content: encode(en), name: \"en.json\" }],\n\t\t\t})\n\t\t);\n\t\tconst balance = bundles.find((b) => b.id === \"personal_balance\");\n\t\texpect(balance?.declarations.some((d) => d.type === \"local-variable\")).toBe(\n\t\t\ttrue\n\t\t);\n\t\texpect(\n\t\t\tbalance?.messages[0]?.variants[0]?.matches[0]?.type\n\t\t).toBe(\"catchall-match\");\n\t});\n\n\ttest(\"merges declarations across locales\", () => {\n\t\tconst imported = importFiles({\n\t\t\tfiles: [\n\t\t\t\t{\n\t\t\t\t\tlocale: \"en\",\n\t\t\t\t\tcontent: encode({ hello: \"Hello {name}\" }),\n\t\t\t\t\tname: \"en.json\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlocale: \"de\",\n\t\t\t\t\tcontent: encode({ hello: \"Hallo {name}\" }),\n\t\t\t\t\tname: \"de.json\",\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\t\texpect(imported.bundles).toHaveLength(1);\n\t\texpect(imported.messages).toHaveLength(2);\n\t\texpect(imported.variants).toHaveLength(2);\n\t\texpect(imported.bundles[0]?.declarations).toEqual([\n\t\t\t{ type: \"input-variable\", name: \"name\" },\n\t\t]);\n\t});\n\n\ttest(\"merges additional declarations from a later locale\", () => {\n\t\tconst imported = importFiles({\n\t\t\tfiles: [\n\t\t\t\t{\n\t\t\t\t\tlocale: \"en\",\n\t\t\t\t\tcontent: encode({ hello: \"Hello\" }),\n\t\t\t\t\tname: \"en.json\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlocale: \"de\",\n\t\t\t\t\tcontent: encode({ hello: \"Hallo {name}\" }),\n\t\t\t\t\tname: \"de.json\",\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\t\texpect(imported.bundles).toHaveLength(1);\n\t\texpect(imported.bundles[0]?.declarations).toEqual([\n\t\t\t{ type: \"input-variable\", name: \"name\" },\n\t\t]);\n\t});\n});\n"]}
@@ -0,0 +1,6 @@
1
+ export { flatten } from "./flatten.js";
2
+ export { importFiles, type FlatImport, type ImportFile } from "./import-files.js";
3
+ export { parseBundle } from "./parse-bundle.js";
4
+ export { parseDeclaration } from "./parse-declaration.js";
5
+ export { parseMatches } from "./parse-matches.js";
6
+ export { parsePattern } from "./parse-pattern.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/messages/message-format/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { flatten } from "./flatten.js";
2
+ export { importFiles } from "./import-files.js";
3
+ export { parseBundle } from "./parse-bundle.js";
4
+ export { parseDeclaration } from "./parse-declaration.js";
5
+ export { parseMatches } from "./parse-matches.js";
6
+ export { parsePattern } from "./parse-pattern.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/messages/message-format/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAoC,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { flatten } from \"./flatten.js\";\nexport { importFiles, type FlatImport, type ImportFile } from \"./import-files.js\";\nexport { parseBundle } from \"./parse-bundle.js\";\nexport { parseDeclaration } from \"./parse-declaration.js\";\nexport { parseMatches } from \"./parse-matches.js\";\nexport { parsePattern } from \"./parse-pattern.js\";\n"]}
@@ -0,0 +1,31 @@
1
+ import type { Declaration, Match, Pattern, VariableReference } from "../ast.js";
2
+ export type FlatVariant = {
3
+ messageBundleId: string;
4
+ messageLocale: string;
5
+ matches: Match[];
6
+ pattern: Pattern;
7
+ };
8
+ export type ParsedBundle = {
9
+ bundle: {
10
+ id: string;
11
+ declarations: Declaration[];
12
+ };
13
+ message: {
14
+ bundleId: string;
15
+ selectors: VariableReference[];
16
+ locale: string;
17
+ };
18
+ variants: FlatVariant[];
19
+ };
20
+ export declare function parseBundle(key: string, locale: string, value: unknown): ParsedBundle;
21
+ /**
22
+ * Parse one locale's message/variants for a bundle that already exists.
23
+ *
24
+ * Skips building a new bundle and first-seen selector/input finalization.
25
+ * Callers still merge any newly discovered declarations into the existing bundle.
26
+ */
27
+ export declare function parseLocaleContribution(key: string, locale: string, value: unknown): {
28
+ declarations: Declaration[];
29
+ message: ParsedBundle["message"];
30
+ variants: FlatVariant[];
31
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-bundle.d.ts","sourceRoot":"","sources":["../../../src/messages/message-format/parse-bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,KAAK,EACL,OAAO,EACP,iBAAiB,EACjB,MAAM,WAAW,CAAC;AAMnB,MAAM,MAAM,WAAW,GAAG;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,YAAY,EAAE,WAAW,EAAE,CAAC;KAC5B,CAAC;IACF,OAAO,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,iBAAiB,EAAE,CAAC;QAC/B,MAAM,EAAE,MAAM,CAAC;KACf,CAAC;IACF,QAAQ,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AAEF,wBAAgB,WAAW,CAC1B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACZ,YAAY,CA4Bd"}
@@ -0,0 +1,169 @@
1
+ import { parseDeclaration } from "./parse-declaration.js";
2
+ import { parseMatches } from "./parse-matches.js";
3
+ import { parsePattern } from "./parse-pattern.js";
4
+ import { unique } from "./unique.js";
5
+ export function parseBundle(key, locale, value) {
6
+ const parsed = parseVariants(key, locale, value);
7
+ const declarations = uniqueDeclarations(parsed.declarations);
8
+ addInputDeclarationsForLocalReferences(declarations);
9
+ const selectors = uniqueSelectors(parsed.selectors);
10
+ const undeclaredSelectors = selectors.filter((selector) => declarations.find((d) => d.name === selector.name) === undefined);
11
+ for (const undeclaredSelector of undeclaredSelectors) {
12
+ declarations.push({
13
+ type: "input-variable",
14
+ name: undeclaredSelector.name,
15
+ });
16
+ }
17
+ return {
18
+ bundle: {
19
+ id: key,
20
+ declarations,
21
+ },
22
+ message: {
23
+ bundleId: key,
24
+ selectors,
25
+ locale,
26
+ },
27
+ variants: parsed.variants,
28
+ };
29
+ }
30
+ /**
31
+ * Parse one locale's message/variants for a bundle that already exists.
32
+ *
33
+ * Skips building a new bundle and first-seen selector/input finalization.
34
+ * Callers still merge any newly discovered declarations into the existing bundle.
35
+ */
36
+ export function parseLocaleContribution(key, locale, value) {
37
+ // Simple string messages: parse the pattern only. Bundle-level input
38
+ // finalization already ran when the key was first seen.
39
+ if (typeof value === "string") {
40
+ const parsed = parsePattern(value);
41
+ return {
42
+ declarations: uniqueDeclarations(parsed.declarations),
43
+ message: {
44
+ bundleId: key,
45
+ selectors: [],
46
+ locale,
47
+ },
48
+ variants: [
49
+ {
50
+ messageBundleId: key,
51
+ messageLocale: locale,
52
+ matches: [],
53
+ pattern: parsed.pattern,
54
+ },
55
+ ],
56
+ };
57
+ }
58
+ const parsed = parseVariants(key, locale, value);
59
+ const declarations = uniqueDeclarations(parsed.declarations);
60
+ addInputDeclarationsForLocalReferences(declarations);
61
+ return {
62
+ declarations,
63
+ message: {
64
+ bundleId: key,
65
+ selectors: uniqueSelectors(parsed.selectors),
66
+ locale,
67
+ },
68
+ variants: parsed.variants,
69
+ };
70
+ }
71
+ function uniqueDeclarations(declarations) {
72
+ if (declarations.length <= 1) {
73
+ return declarations;
74
+ }
75
+ return unique(declarations);
76
+ }
77
+ function uniqueSelectors(selectors) {
78
+ if (selectors.length <= 1) {
79
+ return selectors;
80
+ }
81
+ return unique(selectors);
82
+ }
83
+ function addInputDeclarationsForLocalReferences(declarations) {
84
+ const declaredNames = new Set(declarations.map((declaration) => declaration.name));
85
+ for (const declaration of declarations) {
86
+ if (declaration.type !== "local-variable") {
87
+ continue;
88
+ }
89
+ const references = [];
90
+ if (declaration.value.arg.type === "variable-reference") {
91
+ references.push(declaration.value.arg.name);
92
+ }
93
+ for (const option of declaration.value.annotation?.options ?? []) {
94
+ if (option.value.type === "variable-reference") {
95
+ references.push(option.value.name);
96
+ }
97
+ }
98
+ for (const name of references) {
99
+ if (declaredNames.has(name)) {
100
+ continue;
101
+ }
102
+ declarations.push({ type: "input-variable", name });
103
+ declaredNames.add(name);
104
+ }
105
+ }
106
+ }
107
+ function parseVariants(bundleId, locale, value) {
108
+ if (typeof value === "string") {
109
+ const parsed = parsePattern(value);
110
+ return {
111
+ variants: [
112
+ {
113
+ messageBundleId: bundleId,
114
+ messageLocale: locale,
115
+ matches: [],
116
+ pattern: parsed.pattern,
117
+ },
118
+ ],
119
+ declarations: parsed.declarations,
120
+ selectors: [],
121
+ };
122
+ }
123
+ if (!Array.isArray(value) || value.length === 0) {
124
+ throw new Error(`Invalid message value for "${bundleId}": expected string or complex message array`);
125
+ }
126
+ const complexMessage = value[0];
127
+ const variants = [];
128
+ const selectors = (complexMessage.selectors ?? []).map((name) => ({
129
+ type: "variable-reference",
130
+ name,
131
+ }));
132
+ const declarations = new Set();
133
+ for (const declaration of complexMessage.declarations ?? []) {
134
+ declarations.add(parseDeclaration(declaration));
135
+ }
136
+ const detectedSelectors = new Set();
137
+ for (const [match, pattern] of Object.entries(complexMessage.match ?? {})) {
138
+ const parsed = parsePattern(pattern);
139
+ const parsedMatches = parseMatches(match);
140
+ for (const declaration of parsed.declarations) {
141
+ let isDuplicate = false;
142
+ for (const existingDeclaration of declarations) {
143
+ if (existingDeclaration.name === declaration.name) {
144
+ isDuplicate = true;
145
+ break;
146
+ }
147
+ }
148
+ if (isDuplicate) {
149
+ break;
150
+ }
151
+ declarations.add(declaration);
152
+ }
153
+ for (const selector of parsedMatches.selectors) {
154
+ detectedSelectors.add(selector);
155
+ }
156
+ variants.push({
157
+ messageBundleId: bundleId,
158
+ messageLocale: locale,
159
+ matches: parsedMatches.matches,
160
+ pattern: parsed.pattern,
161
+ });
162
+ }
163
+ return {
164
+ variants,
165
+ declarations: Array.from(declarations),
166
+ selectors: unique([...selectors, ...Array.from(detectedSelectors)]),
167
+ };
168
+ }
169
+ //# sourceMappingURL=parse-bundle.js.map