@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.
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/bin/run.js +4 -0
- package/dist/bundler-plugins/esbuild.d.ts +1 -0
- package/dist/bundler-plugins/esbuild.d.ts.map +1 -0
- package/dist/bundler-plugins/esbuild.js +4 -0
- package/dist/bundler-plugins/esbuild.js.map +1 -0
- package/dist/bundler-plugins/index.d.ts +6 -0
- package/dist/bundler-plugins/index.d.ts.map +1 -0
- package/dist/bundler-plugins/index.js +7 -0
- package/dist/bundler-plugins/index.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts +19 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.js +85 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts +2 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js +53 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/ssr.d.ts +31 -0
- package/dist/bundler-plugins/lazy-modules/ssr.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/ssr.js +42 -0
- package/dist/bundler-plugins/lazy-modules/ssr.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts +2 -0
- package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/ssr.test.js +48 -0
- package/dist/bundler-plugins/lazy-modules/ssr.test.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts +7 -0
- package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/virtual-ids.js +30 -0
- package/dist/bundler-plugins/lazy-modules/virtual-ids.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/virtual.d.ts +86 -0
- package/dist/bundler-plugins/lazy-modules/virtual.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/virtual.js +2 -0
- package/dist/bundler-plugins/lazy-modules/virtual.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts +18 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.js +328 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts +2 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js +45 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/constants.d.ts +2 -0
- package/dist/bundler-plugins/per-locale-build/constants.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/constants.js +3 -0
- package/dist/bundler-plugins/per-locale-build/constants.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/index.d.ts +6 -0
- package/dist/bundler-plugins/per-locale-build/index.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/index.js +43 -0
- package/dist/bundler-plugins/per-locale-build/index.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/locale-id.d.ts +8 -0
- package/dist/bundler-plugins/per-locale-build/locale-id.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/locale-id.js +13 -0
- package/dist/bundler-plugins/per-locale-build/locale-id.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/types.d.ts +4 -0
- package/dist/bundler-plugins/per-locale-build/types.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/types.js +2 -0
- package/dist/bundler-plugins/per-locale-build/types.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts +51 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.js +250 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +250 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -0
- package/dist/bundler-plugins/plugin-core.d.ts +74 -0
- package/dist/bundler-plugins/plugin-core.d.ts.map +1 -0
- package/dist/bundler-plugins/plugin-core.js +292 -0
- package/dist/bundler-plugins/plugin-core.js.map +1 -0
- package/dist/bundler-plugins/rolldown.d.ts +10 -0
- package/dist/bundler-plugins/rolldown.d.ts.map +1 -0
- package/dist/bundler-plugins/rolldown.js +36 -0
- package/dist/bundler-plugins/rolldown.js.map +1 -0
- package/dist/bundler-plugins/rolldown.test.d.ts +1 -0
- package/dist/bundler-plugins/rolldown.test.d.ts.map +1 -0
- package/dist/bundler-plugins/rolldown.test.js +72 -0
- package/dist/bundler-plugins/rolldown.test.js.map +1 -0
- package/dist/bundler-plugins/rollup.d.ts +1 -0
- package/dist/bundler-plugins/rollup.d.ts.map +1 -0
- package/dist/bundler-plugins/rollup.js +4 -0
- package/dist/bundler-plugins/rollup.js.map +1 -0
- package/dist/bundler-plugins/rspack.d.ts +1 -0
- package/dist/bundler-plugins/rspack.d.ts.map +1 -0
- package/dist/bundler-plugins/rspack.js +4 -0
- package/dist/bundler-plugins/rspack.js.map +1 -0
- package/dist/bundler-plugins/unplugin.d.ts +3 -0
- package/dist/bundler-plugins/unplugin.d.ts.map +1 -0
- package/dist/bundler-plugins/unplugin.js +62 -0
- package/dist/bundler-plugins/unplugin.js.map +1 -0
- package/dist/bundler-plugins/unplugin.test.d.ts +1 -0
- package/dist/bundler-plugins/unplugin.test.d.ts.map +1 -0
- package/dist/bundler-plugins/unplugin.test.js +256 -0
- package/dist/bundler-plugins/unplugin.test.js.map +1 -0
- package/dist/bundler-plugins/virtual-modules.test.d.ts +1 -0
- package/dist/bundler-plugins/virtual-modules.test.d.ts.map +1 -0
- package/dist/bundler-plugins/virtual-modules.test.js +77 -0
- package/dist/bundler-plugins/virtual-modules.test.js.map +1 -0
- package/dist/bundler-plugins/vite.d.ts +17 -0
- package/dist/bundler-plugins/vite.d.ts.map +1 -0
- package/dist/bundler-plugins/vite.js +15 -0
- package/dist/bundler-plugins/vite.js.map +1 -0
- package/dist/bundler-plugins/vite.test.d.ts +1 -0
- package/dist/bundler-plugins/vite.test.d.ts.map +1 -0
- package/dist/bundler-plugins/vite.test.js +61 -0
- package/dist/bundler-plugins/vite.test.js.map +1 -0
- package/dist/bundler-plugins/webpack.d.ts +1 -0
- package/dist/bundler-plugins/webpack.d.ts.map +1 -0
- package/dist/bundler-plugins/webpack.js +4 -0
- package/dist/bundler-plugins/webpack.js.map +1 -0
- package/dist/cli/commands/compile/command.d.ts +2 -0
- package/dist/cli/commands/compile/command.d.ts.map +1 -0
- package/dist/cli/commands/compile/command.js +225 -0
- package/dist/cli/commands/compile/command.js.map +1 -0
- package/dist/cli/commands/compile/command.test.d.ts +1 -0
- package/dist/cli/commands/compile/command.test.d.ts.map +1 -0
- package/dist/cli/commands/compile/command.test.js +69 -0
- package/dist/cli/commands/compile/command.test.js.map +1 -0
- package/dist/cli/commands/init/command.d.ts +2 -0
- package/dist/cli/commands/init/command.d.ts.map +1 -0
- package/dist/cli/commands/init/command.js +90 -0
- package/dist/cli/commands/init/command.js.map +1 -0
- package/dist/cli/defaults.d.ts +11 -0
- package/dist/cli/defaults.d.ts.map +1 -0
- package/dist/cli/defaults.js +13 -0
- package/dist/cli/defaults.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +11 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/steps/add-vite-plugin.d.ts +31 -0
- package/dist/cli/steps/add-vite-plugin.d.ts.map +1 -0
- package/dist/cli/steps/add-vite-plugin.js +65 -0
- package/dist/cli/steps/add-vite-plugin.js.map +1 -0
- package/dist/cli/steps/add-vite-plugin.test.d.ts +1 -0
- package/dist/cli/steps/add-vite-plugin.test.d.ts.map +1 -0
- package/dist/cli/steps/add-vite-plugin.test.js +74 -0
- package/dist/cli/steps/add-vite-plugin.test.js.map +1 -0
- package/dist/cli/steps/check-for-uncomitted-changes.d.ts +5 -0
- package/dist/cli/steps/check-for-uncomitted-changes.d.ts.map +1 -0
- package/dist/cli/steps/check-for-uncomitted-changes.js +37 -0
- package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -0
- package/dist/cli/steps/detect-bundler.d.ts +10 -0
- package/dist/cli/steps/detect-bundler.d.ts.map +1 -0
- package/dist/cli/steps/detect-bundler.js +22 -0
- package/dist/cli/steps/detect-bundler.js.map +1 -0
- package/dist/cli/steps/detect-bundler.test.d.ts +1 -0
- package/dist/cli/steps/detect-bundler.test.d.ts.map +1 -0
- package/dist/cli/steps/detect-bundler.test.js +29 -0
- package/dist/cli/steps/detect-bundler.test.js.map +1 -0
- package/dist/cli/steps/initialize-messages.d.ts +11 -0
- package/dist/cli/steps/initialize-messages.d.ts.map +1 -0
- package/dist/cli/steps/initialize-messages.js +31 -0
- package/dist/cli/steps/initialize-messages.js.map +1 -0
- package/dist/cli/steps/prompt-for-outdir.d.ts +8 -0
- package/dist/cli/steps/prompt-for-outdir.d.ts.map +1 -0
- package/dist/cli/steps/prompt-for-outdir.js +19 -0
- package/dist/cli/steps/prompt-for-outdir.js.map +1 -0
- package/dist/cli/steps/update-package-json.d.ts +11 -0
- package/dist/cli/steps/update-package-json.d.ts.map +1 -0
- package/dist/cli/steps/update-package-json.js +34 -0
- package/dist/cli/steps/update-package-json.js.map +1 -0
- package/dist/cli/steps/update-ts-config.d.ts +26 -0
- package/dist/cli/steps/update-ts-config.d.ts.map +1 -0
- package/dist/cli/steps/update-ts-config.js +270 -0
- package/dist/cli/steps/update-ts-config.js.map +1 -0
- package/dist/cli/steps/update-ts-config.test.d.ts +1 -0
- package/dist/cli/steps/update-ts-config.test.d.ts.map +1 -0
- package/dist/cli/steps/update-ts-config.test.js +60 -0
- package/dist/cli/steps/update-ts-config.test.js.map +1 -0
- package/dist/cli/utils.d.ts +36 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +20 -0
- package/dist/cli/utils.js.map +1 -0
- package/dist/compiler/assert-url-pattern-available.d.ts +7 -0
- package/dist/compiler/assert-url-pattern-available.d.ts.map +1 -0
- package/dist/compiler/assert-url-pattern-available.js +17 -0
- package/dist/compiler/assert-url-pattern-available.js.map +1 -0
- package/dist/compiler/compile-annotation.d.ts +12 -0
- package/dist/compiler/compile-annotation.d.ts.map +1 -0
- package/dist/compiler/compile-annotation.js +136 -0
- package/dist/compiler/compile-annotation.js.map +1 -0
- package/dist/compiler/compile-bundle.d.ts +28 -0
- package/dist/compiler/compile-bundle.d.ts.map +1 -0
- package/dist/compiler/compile-bundle.js +431 -0
- package/dist/compiler/compile-bundle.js.map +1 -0
- package/dist/compiler/compile-bundle.test.d.ts +1 -0
- package/dist/compiler/compile-bundle.test.d.ts.map +1 -0
- package/dist/compiler/compile-bundle.test.js +399 -0
- package/dist/compiler/compile-bundle.test.js.map +1 -0
- package/dist/compiler/compile-local-variable.d.ts +16 -0
- package/dist/compiler/compile-local-variable.d.ts.map +1 -0
- package/dist/compiler/compile-local-variable.js +28 -0
- package/dist/compiler/compile-local-variable.js.map +1 -0
- package/dist/compiler/compile-local-variable.test.d.ts +1 -0
- package/dist/compiler/compile-local-variable.test.d.ts.map +1 -0
- package/dist/compiler/compile-local-variable.test.js +359 -0
- package/dist/compiler/compile-local-variable.test.js.map +1 -0
- package/dist/compiler/compile-message.d.ts +8 -0
- package/dist/compiler/compile-message.d.ts.map +1 -0
- package/dist/compiler/compile-message.js +174 -0
- package/dist/compiler/compile-message.js.map +1 -0
- package/dist/compiler/compile-message.test.d.ts +1 -0
- package/dist/compiler/compile-message.test.d.ts.map +1 -0
- package/dist/compiler/compile-message.test.js +1060 -0
- package/dist/compiler/compile-message.test.js.map +1 -0
- package/dist/compiler/compile-pattern.d.ts +29 -0
- package/dist/compiler/compile-pattern.d.ts.map +1 -0
- package/dist/compiler/compile-pattern.js +143 -0
- package/dist/compiler/compile-pattern.js.map +1 -0
- package/dist/compiler/compile-pattern.test.d.ts +1 -0
- package/dist/compiler/compile-pattern.test.d.ts.map +1 -0
- package/dist/compiler/compile-pattern.test.js +255 -0
- package/dist/compiler/compile-pattern.test.js.map +1 -0
- package/dist/compiler/compile-project.d.ts +21 -0
- package/dist/compiler/compile-project.d.ts.map +1 -0
- package/dist/compiler/compile-project.js +147 -0
- package/dist/compiler/compile-project.js.map +1 -0
- package/dist/compiler/compile-project.test.d.ts +1 -0
- package/dist/compiler/compile-project.test.d.ts.map +1 -0
- package/dist/compiler/compile-project.test.js +1709 -0
- package/dist/compiler/compile-project.test.js.map +1 -0
- package/dist/compiler/compile.bench.d.ts +1 -0
- package/dist/compiler/compile.bench.d.ts.map +1 -0
- package/dist/compiler/compile.bench.js +89 -0
- package/dist/compiler/compile.bench.js.map +1 -0
- package/dist/compiler/compile.d.ts +24 -0
- package/dist/compiler/compile.d.ts.map +1 -0
- package/dist/compiler/compile.js +106 -0
- package/dist/compiler/compile.js.map +1 -0
- package/dist/compiler/compile.test.d.ts +1 -0
- package/dist/compiler/compile.test.d.ts.map +1 -0
- package/dist/compiler/compile.test.js +66 -0
- package/dist/compiler/compile.test.js.map +1 -0
- package/dist/compiler/compiler-options.d.ts +466 -0
- package/dist/compiler/compiler-options.d.ts.map +1 -0
- package/dist/compiler/compiler-options.js +22 -0
- package/dist/compiler/compiler-options.js.map +1 -0
- package/dist/compiler/create-paraglide.d.ts +21 -0
- package/dist/compiler/create-paraglide.d.ts.map +1 -0
- package/dist/compiler/create-paraglide.js +69 -0
- package/dist/compiler/create-paraglide.js.map +1 -0
- package/dist/compiler/create-paraglide.test.d.ts +1 -0
- package/dist/compiler/create-paraglide.test.d.ts.map +1 -0
- package/dist/compiler/create-paraglide.test.js +55 -0
- package/dist/compiler/create-paraglide.test.js.map +1 -0
- package/dist/compiler/create-readme.d.ts +9 -0
- package/dist/compiler/create-readme.d.ts.map +1 -0
- package/dist/compiler/create-readme.js +127 -0
- package/dist/compiler/create-readme.js.map +1 -0
- package/dist/compiler/emit-files.d.ts +15 -0
- package/dist/compiler/emit-files.d.ts.map +1 -0
- package/dist/compiler/emit-files.js +58 -0
- package/dist/compiler/emit-files.js.map +1 -0
- package/dist/compiler/emit-files.test.d.ts +1 -0
- package/dist/compiler/emit-files.test.d.ts.map +1 -0
- package/dist/compiler/emit-files.test.js +43 -0
- package/dist/compiler/emit-files.test.js.map +1 -0
- package/dist/compiler/emit-ts-declarations.d.ts +11 -0
- package/dist/compiler/emit-ts-declarations.d.ts.map +1 -0
- package/dist/compiler/emit-ts-declarations.interop.test.d.ts +1 -0
- package/dist/compiler/emit-ts-declarations.interop.test.d.ts.map +1 -0
- package/dist/compiler/emit-ts-declarations.interop.test.js +33 -0
- package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -0
- package/dist/compiler/emit-ts-declarations.js +353 -0
- package/dist/compiler/emit-ts-declarations.js.map +1 -0
- package/dist/compiler/emit-ts-declarations.test.d.ts +1 -0
- package/dist/compiler/emit-ts-declarations.test.d.ts.map +1 -0
- package/dist/compiler/emit-ts-declarations.test.js +161 -0
- package/dist/compiler/emit-ts-declarations.test.js.map +1 -0
- package/dist/compiler/index.d.ts +13 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +11 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/jsdoc-types.d.ts +21 -0
- package/dist/compiler/jsdoc-types.d.ts.map +1 -0
- package/dist/compiler/jsdoc-types.js +59 -0
- package/dist/compiler/jsdoc-types.js.map +1 -0
- package/dist/compiler/jsdoc-types.test.d.ts +1 -0
- package/dist/compiler/jsdoc-types.test.d.ts.map +1 -0
- package/dist/compiler/jsdoc-types.test.js +100 -0
- package/dist/compiler/jsdoc-types.test.js.map +1 -0
- package/dist/compiler/lazy-modules/compile-cache.d.ts +37 -0
- package/dist/compiler/lazy-modules/compile-cache.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/compile-cache.js +34 -0
- package/dist/compiler/lazy-modules/compile-cache.js.map +1 -0
- package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts +2 -0
- package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/compile-project.lazy.test.js +65 -0
- package/dist/compiler/lazy-modules/compile-project.lazy.test.js.map +1 -0
- package/dist/compiler/lazy-modules/create-loader.d.ts +18 -0
- package/dist/compiler/lazy-modules/create-loader.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/create-loader.js +182 -0
- package/dist/compiler/lazy-modules/create-loader.js.map +1 -0
- package/dist/compiler/lazy-modules/create-loader.test.d.ts +2 -0
- package/dist/compiler/lazy-modules/create-loader.test.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/create-loader.test.js +82 -0
- package/dist/compiler/lazy-modules/create-loader.test.js.map +1 -0
- package/dist/compiler/lazy-modules/manifest.d.ts +32 -0
- package/dist/compiler/lazy-modules/manifest.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/manifest.js +11 -0
- package/dist/compiler/lazy-modules/manifest.js.map +1 -0
- package/dist/compiler/match-literals.d.ts +2 -0
- package/dist/compiler/match-literals.d.ts.map +1 -0
- package/dist/compiler/match-literals.js +42 -0
- package/dist/compiler/match-literals.js.map +1 -0
- package/dist/compiler/output-structure/lazy-modules.d.ts +27 -0
- package/dist/compiler/output-structure/lazy-modules.d.ts.map +1 -0
- package/dist/compiler/output-structure/lazy-modules.js +157 -0
- package/dist/compiler/output-structure/lazy-modules.js.map +1 -0
- package/dist/compiler/output-structure/lazy-modules.test.d.ts +2 -0
- package/dist/compiler/output-structure/lazy-modules.test.d.ts.map +1 -0
- package/dist/compiler/output-structure/lazy-modules.test.js +128 -0
- package/dist/compiler/output-structure/lazy-modules.test.js.map +1 -0
- package/dist/compiler/output-structure/locale-modules.d.ts +4 -0
- package/dist/compiler/output-structure/locale-modules.d.ts.map +1 -0
- package/dist/compiler/output-structure/locale-modules.js +81 -0
- package/dist/compiler/output-structure/locale-modules.js.map +1 -0
- package/dist/compiler/output-structure/locale-modules.test.d.ts +1 -0
- package/dist/compiler/output-structure/locale-modules.test.d.ts.map +1 -0
- package/dist/compiler/output-structure/locale-modules.test.js +163 -0
- package/dist/compiler/output-structure/locale-modules.test.js.map +1 -0
- package/dist/compiler/output-structure/message-modules.d.ts +4 -0
- package/dist/compiler/output-structure/message-modules.d.ts.map +1 -0
- package/dist/compiler/output-structure/message-modules.js +100 -0
- package/dist/compiler/output-structure/message-modules.js.map +1 -0
- package/dist/compiler/output-structure/message-modules.test.d.ts +1 -0
- package/dist/compiler/output-structure/message-modules.test.d.ts.map +1 -0
- package/dist/compiler/output-structure/message-modules.test.js +148 -0
- package/dist/compiler/output-structure/message-modules.test.js.map +1 -0
- package/dist/compiler/per-locale-build.d.ts +2 -0
- package/dist/compiler/per-locale-build.d.ts.map +1 -0
- package/dist/compiler/per-locale-build.js +3 -0
- package/dist/compiler/per-locale-build.js.map +1 -0
- package/dist/compiler/registry.d.ts +13 -0
- package/dist/compiler/registry.d.ts.map +1 -0
- package/dist/compiler/registry.js +60 -0
- package/dist/compiler/registry.js.map +1 -0
- package/dist/compiler/resolve-tsc-js-path.d.ts +9 -0
- package/dist/compiler/resolve-tsc-js-path.d.ts.map +1 -0
- package/dist/compiler/resolve-tsc-js-path.js +23 -0
- package/dist/compiler/resolve-tsc-js-path.js.map +1 -0
- package/dist/compiler/runtime/check-locale.d.ts +31 -0
- package/dist/compiler/runtime/check-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/check-locale.js +51 -0
- package/dist/compiler/runtime/check-locale.js.map +1 -0
- package/dist/compiler/runtime/check-locale.test.d.ts +1 -0
- package/dist/compiler/runtime/check-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/check-locale.test.js +84 -0
- package/dist/compiler/runtime/check-locale.test.js.map +1 -0
- package/dist/compiler/runtime/create-runtime.d.ts +35 -0
- package/dist/compiler/runtime/create-runtime.d.ts.map +1 -0
- package/dist/compiler/runtime/create-runtime.js +196 -0
- package/dist/compiler/runtime/create-runtime.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +13 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.js +43 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js +149 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.d.ts +13 -0
- package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.js +45 -0
- package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.js +55 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +12 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.js +33 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.test.js +45 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +34 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.js +70 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.test.js +119 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.d.ts +41 -0
- package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.js +96 -0
- package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.js +351 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.d.ts +11 -0
- package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.js +68 -0
- package/dist/compiler/runtime/extract-locale-from-url.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.js +127 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.js.map +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts +44 -0
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.js +133 -0
- package/dist/compiler/runtime/generate-static-localized-urls.js.map +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts.map +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.test.js +159 -0
- package/dist/compiler/runtime/generate-static-localized-urls.test.js.map +1 -0
- package/dist/compiler/runtime/get-locale.d.ts +42 -0
- package/dist/compiler/runtime/get-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale.js +158 -0
- package/dist/compiler/runtime/get-locale.js.map +1 -0
- package/dist/compiler/runtime/get-locale.test.d.ts +1 -0
- package/dist/compiler/runtime/get-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale.test.js +295 -0
- package/dist/compiler/runtime/get-locale.test.js.map +1 -0
- package/dist/compiler/runtime/get-text-direction.d.ts +15 -0
- package/dist/compiler/runtime/get-text-direction.d.ts.map +1 -0
- package/dist/compiler/runtime/get-text-direction.js +46 -0
- package/dist/compiler/runtime/get-text-direction.js.map +1 -0
- package/dist/compiler/runtime/get-text-direction.test.d.ts +1 -0
- package/dist/compiler/runtime/get-text-direction.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-text-direction.test.js +40 -0
- package/dist/compiler/runtime/get-text-direction.test.js.map +1 -0
- package/dist/compiler/runtime/get-url-origin.d.ts +19 -0
- package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -0
- package/dist/compiler/runtime/get-url-origin.js +31 -0
- package/dist/compiler/runtime/get-url-origin.js.map +1 -0
- package/dist/compiler/runtime/get-url-origin.test.d.ts +1 -0
- package/dist/compiler/runtime/get-url-origin.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-url-origin.test.js +18 -0
- package/dist/compiler/runtime/get-url-origin.test.js.map +1 -0
- package/dist/compiler/runtime/host-routing.d.ts +28 -0
- package/dist/compiler/runtime/host-routing.d.ts.map +1 -0
- package/dist/compiler/runtime/host-routing.js +79 -0
- package/dist/compiler/runtime/host-routing.js.map +1 -0
- package/dist/compiler/runtime/host-routing.test.d.ts +1 -0
- package/dist/compiler/runtime/host-routing.test.d.ts.map +1 -0
- package/dist/compiler/runtime/host-routing.test.js +128 -0
- package/dist/compiler/runtime/host-routing.test.js.map +1 -0
- package/dist/compiler/runtime/localize-href.d.ts +84 -0
- package/dist/compiler/runtime/localize-href.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-href.js +115 -0
- package/dist/compiler/runtime/localize-href.js.map +1 -0
- package/dist/compiler/runtime/localize-href.test.d.ts +1 -0
- package/dist/compiler/runtime/localize-href.test.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-href.test.js +139 -0
- package/dist/compiler/runtime/localize-href.test.js.map +1 -0
- package/dist/compiler/runtime/localize-url.d.ts +95 -0
- package/dist/compiler/runtime/localize-url.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-url.js +327 -0
- package/dist/compiler/runtime/localize-url.js.map +1 -0
- package/dist/compiler/runtime/localize-url.test.d.ts +1 -0
- package/dist/compiler/runtime/localize-url.test.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-url.test.js +533 -0
- package/dist/compiler/runtime/localize-url.test.js.map +1 -0
- package/dist/compiler/runtime/route-strategy.d.ts +32 -0
- package/dist/compiler/runtime/route-strategy.d.ts.map +1 -0
- package/dist/compiler/runtime/route-strategy.js +72 -0
- package/dist/compiler/runtime/route-strategy.js.map +1 -0
- package/dist/compiler/runtime/set-locale.d.ts +46 -0
- package/dist/compiler/runtime/set-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/set-locale.js +172 -0
- package/dist/compiler/runtime/set-locale.js.map +1 -0
- package/dist/compiler/runtime/set-locale.test.d.ts +1 -0
- package/dist/compiler/runtime/set-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/set-locale.test.js +555 -0
- package/dist/compiler/runtime/set-locale.test.js.map +1 -0
- package/dist/compiler/runtime/should-redirect.d.ts +100 -0
- package/dist/compiler/runtime/should-redirect.d.ts.map +1 -0
- package/dist/compiler/runtime/should-redirect.js +155 -0
- package/dist/compiler/runtime/should-redirect.js.map +1 -0
- package/dist/compiler/runtime/should-redirect.test.d.ts +1 -0
- package/dist/compiler/runtime/should-redirect.test.d.ts.map +1 -0
- package/dist/compiler/runtime/should-redirect.test.js +270 -0
- package/dist/compiler/runtime/should-redirect.test.js.map +1 -0
- package/dist/compiler/runtime/strategy.d.ts +63 -0
- package/dist/compiler/runtime/strategy.d.ts.map +1 -0
- package/dist/compiler/runtime/strategy.js +65 -0
- package/dist/compiler/runtime/strategy.js.map +1 -0
- package/dist/compiler/runtime/strategy.test.d.ts +1 -0
- package/dist/compiler/runtime/strategy.test.d.ts.map +1 -0
- package/dist/compiler/runtime/strategy.test.js +90 -0
- package/dist/compiler/runtime/strategy.test.js.map +1 -0
- package/dist/compiler/runtime/track-message-call.d.ts +5 -0
- package/dist/compiler/runtime/track-message-call.d.ts.map +1 -0
- package/dist/compiler/runtime/track-message-call.js +14 -0
- package/dist/compiler/runtime/track-message-call.js.map +1 -0
- package/dist/compiler/runtime/track-message-call.test.d.ts +1 -0
- package/dist/compiler/runtime/track-message-call.test.d.ts.map +1 -0
- package/dist/compiler/runtime/track-message-call.test.js +22 -0
- package/dist/compiler/runtime/track-message-call.test.js.map +1 -0
- package/dist/compiler/runtime/type-definitions.d.ts +197 -0
- package/dist/compiler/runtime/type-definitions.d.ts.map +1 -0
- package/dist/compiler/runtime/type-definitions.js +150 -0
- package/dist/compiler/runtime/type-definitions.js.map +1 -0
- package/dist/compiler/runtime/type.d.ts +47 -0
- package/dist/compiler/runtime/type.d.ts.map +1 -0
- package/dist/compiler/runtime/type.js +2 -0
- package/dist/compiler/runtime/type.js.map +1 -0
- package/dist/compiler/runtime/type.test.d.ts +1 -0
- package/dist/compiler/runtime/type.test.d.ts.map +1 -0
- package/dist/compiler/runtime/type.test.js +153 -0
- package/dist/compiler/runtime/type.test.js.map +1 -0
- package/dist/compiler/runtime/url-pattern.d.ts +12 -0
- package/dist/compiler/runtime/url-pattern.d.ts.map +1 -0
- package/dist/compiler/runtime/url-pattern.js +35 -0
- package/dist/compiler/runtime/url-pattern.js.map +1 -0
- package/dist/compiler/runtime/variables.d.ts +128 -0
- package/dist/compiler/runtime/variables.d.ts.map +1 -0
- package/dist/compiler/runtime/variables.js +111 -0
- package/dist/compiler/runtime/variables.js.map +1 -0
- package/dist/compiler/safe-module-id.d.ts +7 -0
- package/dist/compiler/safe-module-id.d.ts.map +1 -0
- package/dist/compiler/safe-module-id.js +78 -0
- package/dist/compiler/safe-module-id.js.map +1 -0
- package/dist/compiler/safe-module-id.test.d.ts +1 -0
- package/dist/compiler/safe-module-id.test.d.ts.map +1 -0
- package/dist/compiler/safe-module-id.test.js +36 -0
- package/dist/compiler/safe-module-id.test.js.map +1 -0
- package/dist/compiler/seed-previous-compilation.d.ts +7 -0
- package/dist/compiler/seed-previous-compilation.d.ts.map +1 -0
- package/dist/compiler/seed-previous-compilation.js +9 -0
- package/dist/compiler/seed-previous-compilation.js.map +1 -0
- package/dist/compiler/server/create-server-file.d.ts +12 -0
- package/dist/compiler/server/create-server-file.d.ts.map +1 -0
- package/dist/compiler/server/create-server-file.js +91 -0
- package/dist/compiler/server/create-server-file.js.map +1 -0
- package/dist/compiler/server/create-server-file.test.d.ts +1 -0
- package/dist/compiler/server/create-server-file.test.d.ts.map +1 -0
- package/dist/compiler/server/create-server-file.test.js +48 -0
- package/dist/compiler/server/create-server-file.test.js.map +1 -0
- package/dist/compiler/server/middleware.d.ts +98 -0
- package/dist/compiler/server/middleware.d.ts.map +1 -0
- package/dist/compiler/server/middleware.js +278 -0
- package/dist/compiler/server/middleware.js.map +1 -0
- package/dist/compiler/server/middleware.test.d.ts +1 -0
- package/dist/compiler/server/middleware.test.d.ts.map +1 -0
- package/dist/compiler/server/middleware.test.js +1001 -0
- package/dist/compiler/server/middleware.test.js.map +1 -0
- package/dist/compiler/server/type.d.ts +6 -0
- package/dist/compiler/server/type.d.ts.map +1 -0
- package/dist/compiler/server/type.js +2 -0
- package/dist/compiler/server/type.js.map +1 -0
- package/dist/compiler/test-helpers.d.ts +30 -0
- package/dist/compiler/test-helpers.d.ts.map +1 -0
- package/dist/compiler/test-helpers.js +50 -0
- package/dist/compiler/test-helpers.js.map +1 -0
- package/dist/compiler/types.d.ts +7 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/compiler/types.js +2 -0
- package/dist/compiler/types.js.map +1 -0
- package/dist/compiler/variable-access.d.ts +3 -0
- package/dist/compiler/variable-access.d.ts.map +1 -0
- package/dist/compiler/variable-access.js +15 -0
- package/dist/compiler/variable-access.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/ast.d.ts +102 -0
- package/dist/messages/ast.d.ts.map +1 -0
- package/dist/messages/ast.js +8 -0
- package/dist/messages/ast.js.map +1 -0
- package/dist/messages/create-bundle-nested.d.ts +16 -0
- package/dist/messages/create-bundle-nested.d.ts.map +1 -0
- package/dist/messages/create-bundle-nested.js +22 -0
- package/dist/messages/create-bundle-nested.js.map +1 -0
- package/dist/messages/index.d.ts +5 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/index.js +5 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/messages/load-messages.d.ts +19 -0
- package/dist/messages/load-messages.d.ts.map +1 -0
- package/dist/messages/load-messages.js +49 -0
- package/dist/messages/load-messages.js.map +1 -0
- package/dist/messages/message-format/flatten.d.ts +9 -0
- package/dist/messages/message-format/flatten.d.ts.map +1 -0
- package/dist/messages/message-format/flatten.js +32 -0
- package/dist/messages/message-format/flatten.js.map +1 -0
- package/dist/messages/message-format/import-files.d.ts +32 -0
- package/dist/messages/message-format/import-files.d.ts.map +1 -0
- package/dist/messages/message-format/import-files.js +53 -0
- package/dist/messages/message-format/import-files.js.map +1 -0
- package/dist/messages/message-format/import-files.test.d.ts +1 -0
- package/dist/messages/message-format/import-files.test.d.ts.map +1 -0
- package/dist/messages/message-format/import-files.test.js +145 -0
- package/dist/messages/message-format/import-files.test.js.map +1 -0
- package/dist/messages/message-format/index.d.ts +6 -0
- package/dist/messages/message-format/index.d.ts.map +1 -0
- package/dist/messages/message-format/index.js +7 -0
- package/dist/messages/message-format/index.js.map +1 -0
- package/dist/messages/message-format/parse-bundle.d.ts +31 -0
- package/dist/messages/message-format/parse-bundle.d.ts.map +1 -0
- package/dist/messages/message-format/parse-bundle.js +169 -0
- package/dist/messages/message-format/parse-bundle.js.map +1 -0
- package/dist/messages/message-format/parse-declaration.d.ts +2 -0
- package/dist/messages/message-format/parse-declaration.d.ts.map +1 -0
- package/dist/messages/message-format/parse-declaration.js +56 -0
- package/dist/messages/message-format/parse-declaration.js.map +1 -0
- package/dist/messages/message-format/parse-markup.d.ts +4 -0
- package/dist/messages/message-format/parse-markup.d.ts.map +1 -0
- package/dist/messages/message-format/parse-markup.js +167 -0
- package/dist/messages/message-format/parse-markup.js.map +1 -0
- package/dist/messages/message-format/parse-matches.d.ts +5 -0
- package/dist/messages/message-format/parse-matches.d.ts.map +1 -0
- package/dist/messages/message-format/parse-matches.js +31 -0
- package/dist/messages/message-format/parse-matches.js.map +1 -0
- package/dist/messages/message-format/parse-pattern.d.ts +5 -0
- package/dist/messages/message-format/parse-pattern.d.ts.map +1 -0
- package/dist/messages/message-format/parse-pattern.js +120 -0
- package/dist/messages/message-format/parse-pattern.js.map +1 -0
- package/dist/messages/message-format/unique.d.ts +2 -0
- package/dist/messages/message-format/unique.d.ts.map +1 -0
- package/dist/messages/message-format/unique.js +5 -0
- package/dist/messages/message-format/unique.js.map +1 -0
- package/dist/messages/nest-bundles.d.ts +19 -0
- package/dist/messages/nest-bundles.d.ts.map +1 -0
- package/dist/messages/nest-bundles.js +49 -0
- package/dist/messages/nest-bundles.js.map +1 -0
- package/dist/services/account/index.d.ts +14 -0
- package/dist/services/account/index.d.ts.map +1 -0
- package/dist/services/account/index.js +43 -0
- package/dist/services/account/index.js.map +1 -0
- package/dist/services/account/types.d.ts +4 -0
- package/dist/services/account/types.d.ts.map +1 -0
- package/dist/services/account/types.js +2 -0
- package/dist/services/account/types.js.map +1 -0
- package/dist/services/codegen/escape.d.ts +9 -0
- package/dist/services/codegen/escape.d.ts.map +1 -0
- package/dist/services/codegen/escape.js +19 -0
- package/dist/services/codegen/escape.js.map +1 -0
- package/dist/services/codegen/quotes.d.ts +4 -0
- package/dist/services/codegen/quotes.d.ts.map +1 -0
- package/dist/services/codegen/quotes.js +5 -0
- package/dist/services/codegen/quotes.js.map +1 -0
- package/dist/services/env-variables/create-index-file.d.ts +9 -0
- package/dist/services/env-variables/create-index-file.d.ts.map +1 -0
- package/dist/services/env-variables/create-index-file.js +28 -0
- package/dist/services/env-variables/create-index-file.js.map +1 -0
- package/dist/services/env-variables/index.d.ts +3 -0
- package/dist/services/env-variables/index.d.ts.map +1 -0
- package/dist/services/env-variables/index.js +4 -0
- package/dist/services/env-variables/index.js.map +1 -0
- package/dist/services/environment/package.d.ts +9 -0
- package/dist/services/environment/package.d.ts.map +1 -0
- package/dist/services/environment/package.js +31 -0
- package/dist/services/environment/package.js.map +1 -0
- package/dist/services/environment/package.test.d.ts +1 -0
- package/dist/services/environment/package.test.d.ts.map +1 -0
- package/dist/services/environment/package.test.js +21 -0
- package/dist/services/environment/package.test.js.map +1 -0
- package/dist/services/error-handling.d.ts +12 -0
- package/dist/services/error-handling.d.ts.map +1 -0
- package/dist/services/error-handling.js +27 -0
- package/dist/services/error-handling.js.map +1 -0
- package/dist/services/error-handling.test.d.ts +1 -0
- package/dist/services/error-handling.test.d.ts.map +1 -0
- package/dist/services/error-handling.test.js +10 -0
- package/dist/services/error-handling.test.js.map +1 -0
- package/dist/services/file-handling/content-hash.d.ts +9 -0
- package/dist/services/file-handling/content-hash.js +19 -0
- package/dist/services/file-handling/content-hash.js.map +1 -0
- package/dist/services/file-handling/exists.d.ts +7 -0
- package/dist/services/file-handling/exists.d.ts.map +1 -0
- package/dist/services/file-handling/exists.js +24 -0
- package/dist/services/file-handling/exists.js.map +1 -0
- package/dist/services/file-handling/exists.test.d.ts +1 -0
- package/dist/services/file-handling/exists.test.d.ts.map +1 -0
- package/dist/services/file-handling/exists.test.js +27 -0
- package/dist/services/file-handling/exists.test.js.map +1 -0
- package/dist/services/file-handling/types.d.ts +4 -0
- package/dist/services/file-handling/types.d.ts.map +1 -0
- package/dist/services/file-handling/types.js +2 -0
- package/dist/services/file-handling/types.js.map +1 -0
- package/dist/services/file-handling/write-output.d.ts +21 -0
- package/dist/services/file-handling/write-output.d.ts.map +1 -0
- package/dist/services/file-handling/write-output.js +157 -0
- package/dist/services/file-handling/write-output.js.map +1 -0
- package/dist/services/file-handling/write-output.test.d.ts +1 -0
- package/dist/services/file-handling/write-output.test.d.ts.map +1 -0
- package/dist/services/file-handling/write-output.test.js +217 -0
- package/dist/services/file-handling/write-output.test.js.map +1 -0
- package/dist/services/file-watching/tracked-fs.d.ts +25 -0
- package/dist/services/file-watching/tracked-fs.d.ts.map +1 -0
- package/dist/services/file-watching/tracked-fs.js +94 -0
- package/dist/services/file-watching/tracked-fs.js.map +1 -0
- package/dist/services/file-watching/tracked-fs.test.d.ts +1 -0
- package/dist/services/file-watching/tracked-fs.test.d.ts.map +1 -0
- package/dist/services/file-watching/tracked-fs.test.js +87 -0
- package/dist/services/file-watching/tracked-fs.test.js.map +1 -0
- package/dist/services/logger/index.d.ts +17 -0
- package/dist/services/logger/index.d.ts.map +1 -0
- package/dist/services/logger/index.js +58 -0
- package/dist/services/logger/index.js.map +1 -0
- package/dist/services/lookup.d.ts +14 -0
- package/dist/services/lookup.d.ts.map +1 -0
- package/dist/services/lookup.js +24 -0
- package/dist/services/lookup.js.map +1 -0
- package/dist/urlpattern-polyfill/index.d.ts +2 -0
- package/dist/urlpattern-polyfill/index.d.ts.map +1 -0
- package/dist/urlpattern-polyfill/index.js +2 -0
- package/dist/urlpattern-polyfill/index.js.map +1 -0
- package/dist/utilities/detect-json-formatting.d.ts +10 -0
- package/dist/utilities/detect-json-formatting.d.ts.map +1 -0
- package/dist/utilities/detect-json-formatting.js +80 -0
- package/dist/utilities/detect-json-formatting.js.map +1 -0
- package/dist/utilities/node-normalize-path.d.ts +1 -0
- package/dist/utilities/node-normalize-path.d.ts.map +1 -0
- package/dist/utilities/node-normalize-path.js +10 -0
- package/dist/utilities/node-normalize-path.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { compileLocalVariable } from "./compile-local-variable.js";
|
|
3
|
+
test("compiles a literal local variable", () => {
|
|
4
|
+
const code = compileLocalVariable({
|
|
5
|
+
locale: "en",
|
|
6
|
+
declaration: {
|
|
7
|
+
type: "local-variable",
|
|
8
|
+
name: "myVar",
|
|
9
|
+
value: { type: "expression", arg: { type: "literal", value: "Hello" } },
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
expect(code).toEqual('const myVar = "Hello";');
|
|
13
|
+
});
|
|
14
|
+
test("compiles a variable reference local variable", () => {
|
|
15
|
+
const code = compileLocalVariable({
|
|
16
|
+
locale: "en",
|
|
17
|
+
declaration: {
|
|
18
|
+
type: "local-variable",
|
|
19
|
+
name: "myVar",
|
|
20
|
+
value: {
|
|
21
|
+
type: "expression",
|
|
22
|
+
arg: { type: "variable-reference", name: "name" },
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
expect(code).toEqual("const myVar = i?.name;");
|
|
27
|
+
});
|
|
28
|
+
test("compiles a variable reference local variable with a non-identifier name", () => {
|
|
29
|
+
const code = compileLocalVariable({
|
|
30
|
+
locale: "en",
|
|
31
|
+
declaration: {
|
|
32
|
+
type: "local-variable",
|
|
33
|
+
name: "myVar",
|
|
34
|
+
value: {
|
|
35
|
+
type: "expression",
|
|
36
|
+
arg: { type: "variable-reference", name: "half!" },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
expect(code).toEqual('const myVar = i?.["half!"];');
|
|
41
|
+
});
|
|
42
|
+
test("compiles a local variable with an annotation and empty options", () => {
|
|
43
|
+
const code = compileLocalVariable({
|
|
44
|
+
locale: "en",
|
|
45
|
+
declaration: {
|
|
46
|
+
type: "local-variable",
|
|
47
|
+
name: "myVar",
|
|
48
|
+
value: {
|
|
49
|
+
type: "expression",
|
|
50
|
+
arg: { type: "literal", value: "Hello" },
|
|
51
|
+
annotation: {
|
|
52
|
+
type: "function-reference",
|
|
53
|
+
name: "myFunction",
|
|
54
|
+
options: [],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
expect(code).toEqual('const myVar = registry.myFunction("en", "Hello", {});');
|
|
60
|
+
});
|
|
61
|
+
test("compiles a local variable with an annotation and options", () => {
|
|
62
|
+
const code = compileLocalVariable({
|
|
63
|
+
locale: "en",
|
|
64
|
+
declaration: {
|
|
65
|
+
type: "local-variable",
|
|
66
|
+
name: "myVar",
|
|
67
|
+
value: {
|
|
68
|
+
type: "expression",
|
|
69
|
+
arg: { type: "literal", value: "Hello" },
|
|
70
|
+
annotation: {
|
|
71
|
+
type: "function-reference",
|
|
72
|
+
name: "myFunction",
|
|
73
|
+
options: [
|
|
74
|
+
{ name: "option1", value: { type: "literal", value: "value1" } },
|
|
75
|
+
{
|
|
76
|
+
name: "option2",
|
|
77
|
+
value: { type: "variable-reference", name: "varRef" },
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
expect(code).toEqual('const myVar = registry.myFunction("en", "Hello", { option1: "value1", option2: i?.varRef });');
|
|
85
|
+
});
|
|
86
|
+
test("compiles number formatter fraction digit options as numeric literals", () => {
|
|
87
|
+
const code = compileLocalVariable({
|
|
88
|
+
locale: "en",
|
|
89
|
+
declaration: {
|
|
90
|
+
type: "local-variable",
|
|
91
|
+
name: "formattedValue",
|
|
92
|
+
value: {
|
|
93
|
+
type: "expression",
|
|
94
|
+
arg: { type: "variable-reference", name: "value" },
|
|
95
|
+
annotation: {
|
|
96
|
+
type: "function-reference",
|
|
97
|
+
name: "number",
|
|
98
|
+
options: [
|
|
99
|
+
{
|
|
100
|
+
name: "minimumFractionDigits",
|
|
101
|
+
value: { type: "literal", value: "1" },
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "maximumFractionDigits",
|
|
105
|
+
value: { type: "literal", value: "1" },
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
expect(code).toEqual('const formattedValue = registry.number("en", i?.value, { minimumFractionDigits: 1, maximumFractionDigits: 1 });');
|
|
113
|
+
});
|
|
114
|
+
test("compiles number formatter useGrouping option as boolean literal", () => {
|
|
115
|
+
const code = compileLocalVariable({
|
|
116
|
+
locale: "en",
|
|
117
|
+
declaration: {
|
|
118
|
+
type: "local-variable",
|
|
119
|
+
name: "formattedValue",
|
|
120
|
+
value: {
|
|
121
|
+
type: "expression",
|
|
122
|
+
arg: { type: "variable-reference", name: "value" },
|
|
123
|
+
annotation: {
|
|
124
|
+
type: "function-reference",
|
|
125
|
+
name: "number",
|
|
126
|
+
options: [
|
|
127
|
+
{
|
|
128
|
+
name: "useGrouping",
|
|
129
|
+
value: { type: "literal", value: "false" },
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
expect(code).toEqual('const formattedValue = registry.number("en", i?.value, { useGrouping: false });');
|
|
137
|
+
});
|
|
138
|
+
test("keeps negative digit options as strings to avoid emitting invalid numeric literals", () => {
|
|
139
|
+
const code = compileLocalVariable({
|
|
140
|
+
locale: "en",
|
|
141
|
+
declaration: {
|
|
142
|
+
type: "local-variable",
|
|
143
|
+
name: "formattedValue",
|
|
144
|
+
value: {
|
|
145
|
+
type: "expression",
|
|
146
|
+
arg: { type: "variable-reference", name: "value" },
|
|
147
|
+
annotation: {
|
|
148
|
+
type: "function-reference",
|
|
149
|
+
name: "number",
|
|
150
|
+
options: [
|
|
151
|
+
{
|
|
152
|
+
name: "minimumFractionDigits",
|
|
153
|
+
value: { type: "literal", value: "-1" },
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
expect(code).toEqual('const formattedValue = registry.number("en", i?.value, { minimumFractionDigits: "-1" });');
|
|
161
|
+
});
|
|
162
|
+
test("compiles relative time formatter with a literal unit", () => {
|
|
163
|
+
const code = compileLocalVariable({
|
|
164
|
+
locale: "en",
|
|
165
|
+
declaration: {
|
|
166
|
+
type: "local-variable",
|
|
167
|
+
name: "formattedDuration",
|
|
168
|
+
value: {
|
|
169
|
+
type: "expression",
|
|
170
|
+
arg: { type: "variable-reference", name: "duration" },
|
|
171
|
+
annotation: {
|
|
172
|
+
type: "function-reference",
|
|
173
|
+
name: "relativetime",
|
|
174
|
+
options: [
|
|
175
|
+
{ name: "unit", value: { type: "literal", value: "day" } },
|
|
176
|
+
{ name: "numeric", value: { type: "literal", value: "auto" } },
|
|
177
|
+
{ name: "style", value: { type: "literal", value: "short" } },
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: "day", numeric: "auto", style: "short" });');
|
|
184
|
+
});
|
|
185
|
+
test("compiles relative time formatter with a dynamic unit cast", () => {
|
|
186
|
+
const code = compileLocalVariable({
|
|
187
|
+
locale: "en",
|
|
188
|
+
declaration: {
|
|
189
|
+
type: "local-variable",
|
|
190
|
+
name: "formattedDuration",
|
|
191
|
+
value: {
|
|
192
|
+
type: "expression",
|
|
193
|
+
arg: { type: "variable-reference", name: "duration" },
|
|
194
|
+
annotation: {
|
|
195
|
+
type: "function-reference",
|
|
196
|
+
name: "relativetime",
|
|
197
|
+
options: [
|
|
198
|
+
{
|
|
199
|
+
name: "unit",
|
|
200
|
+
value: { type: "variable-reference", name: "unit" },
|
|
201
|
+
},
|
|
202
|
+
{ name: "style", value: { type: "literal", value: "short" } },
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit), style: "short" });');
|
|
209
|
+
});
|
|
210
|
+
test("throws if relative time formatter is missing a unit option", () => {
|
|
211
|
+
expect(() => compileLocalVariable({
|
|
212
|
+
locale: "en",
|
|
213
|
+
declaration: {
|
|
214
|
+
type: "local-variable",
|
|
215
|
+
name: "formattedDuration",
|
|
216
|
+
value: {
|
|
217
|
+
type: "expression",
|
|
218
|
+
arg: { type: "variable-reference", name: "duration" },
|
|
219
|
+
annotation: {
|
|
220
|
+
type: "function-reference",
|
|
221
|
+
name: "relativetime",
|
|
222
|
+
options: [],
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
})).toThrow('The "relativetime" formatter requires a "unit" option.');
|
|
227
|
+
});
|
|
228
|
+
test("throws if relative time formatter has duplicate unit options", () => {
|
|
229
|
+
expect(() => compileLocalVariable({
|
|
230
|
+
locale: "en",
|
|
231
|
+
declaration: {
|
|
232
|
+
type: "local-variable",
|
|
233
|
+
name: "formattedDuration",
|
|
234
|
+
value: {
|
|
235
|
+
type: "expression",
|
|
236
|
+
arg: { type: "variable-reference", name: "duration" },
|
|
237
|
+
annotation: {
|
|
238
|
+
type: "function-reference",
|
|
239
|
+
name: "relativetime",
|
|
240
|
+
options: [
|
|
241
|
+
{ name: "unit", value: { type: "literal", value: "day" } },
|
|
242
|
+
{ name: "unit", value: { type: "literal", value: "hour" } },
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
})).toThrow('The "relativetime" formatter requires exactly one "unit" option.');
|
|
248
|
+
});
|
|
249
|
+
test("throws if relative time formatter has an invalid literal unit", () => {
|
|
250
|
+
expect(() => compileLocalVariable({
|
|
251
|
+
locale: "en",
|
|
252
|
+
declaration: {
|
|
253
|
+
type: "local-variable",
|
|
254
|
+
name: "formattedDuration",
|
|
255
|
+
value: {
|
|
256
|
+
type: "expression",
|
|
257
|
+
arg: { type: "variable-reference", name: "duration" },
|
|
258
|
+
annotation: {
|
|
259
|
+
type: "function-reference",
|
|
260
|
+
name: "relativetime",
|
|
261
|
+
options: [
|
|
262
|
+
{ name: "unit", value: { type: "literal", value: "century" } },
|
|
263
|
+
],
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
})).toThrow('Invalid "relativetime" unit "century".');
|
|
268
|
+
});
|
|
269
|
+
test("accepts plural relative time formatter units", () => {
|
|
270
|
+
const code = compileLocalVariable({
|
|
271
|
+
locale: "en",
|
|
272
|
+
declaration: {
|
|
273
|
+
type: "local-variable",
|
|
274
|
+
name: "formattedDuration",
|
|
275
|
+
value: {
|
|
276
|
+
type: "expression",
|
|
277
|
+
arg: { type: "variable-reference", name: "duration" },
|
|
278
|
+
annotation: {
|
|
279
|
+
type: "function-reference",
|
|
280
|
+
name: "relativetime",
|
|
281
|
+
options: [
|
|
282
|
+
{ name: "unit", value: { type: "literal", value: "days" } },
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: "days" });');
|
|
289
|
+
});
|
|
290
|
+
test("accepts dynamic relative time formatter units", () => {
|
|
291
|
+
const code = compileLocalVariable({
|
|
292
|
+
locale: "en",
|
|
293
|
+
declaration: {
|
|
294
|
+
type: "local-variable",
|
|
295
|
+
name: "formattedDuration",
|
|
296
|
+
value: {
|
|
297
|
+
type: "expression",
|
|
298
|
+
arg: { type: "variable-reference", name: "duration" },
|
|
299
|
+
annotation: {
|
|
300
|
+
type: "function-reference",
|
|
301
|
+
name: "relativetime",
|
|
302
|
+
options: [
|
|
303
|
+
{
|
|
304
|
+
name: "unit",
|
|
305
|
+
value: { type: "variable-reference", name: "unit" },
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit) });');
|
|
313
|
+
});
|
|
314
|
+
test("accepts dollar-prefixed relative time formatter unit options from message files", () => {
|
|
315
|
+
const code = compileLocalVariable({
|
|
316
|
+
locale: "en",
|
|
317
|
+
declaration: {
|
|
318
|
+
type: "local-variable",
|
|
319
|
+
name: "formattedDuration",
|
|
320
|
+
value: {
|
|
321
|
+
type: "expression",
|
|
322
|
+
arg: { type: "variable-reference", name: "duration" },
|
|
323
|
+
annotation: {
|
|
324
|
+
type: "function-reference",
|
|
325
|
+
name: "relativetime",
|
|
326
|
+
options: [
|
|
327
|
+
{ name: "unit", value: { type: "literal", value: "$unit" } },
|
|
328
|
+
],
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit) });');
|
|
334
|
+
});
|
|
335
|
+
test("accepts dollar-prefixed relative time formatter unit options with non-identifier input names", () => {
|
|
336
|
+
const code = compileLocalVariable({
|
|
337
|
+
locale: "en",
|
|
338
|
+
declaration: {
|
|
339
|
+
type: "local-variable",
|
|
340
|
+
name: "formattedDuration",
|
|
341
|
+
value: {
|
|
342
|
+
type: "expression",
|
|
343
|
+
arg: { type: "variable-reference", name: "duration" },
|
|
344
|
+
annotation: {
|
|
345
|
+
type: "function-reference",
|
|
346
|
+
name: "relativetime",
|
|
347
|
+
options: [
|
|
348
|
+
{
|
|
349
|
+
name: "unit",
|
|
350
|
+
value: { type: "literal", value: "$relative-unit" },
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.["relative-unit"]) });');
|
|
358
|
+
});
|
|
359
|
+
//# sourceMappingURL=compile-local-variable.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-local-variable.test.js","sourceRoot":"","sources":["../../src/compiler/compile-local-variable.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,IAAI,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAC9C,MAAM,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE;YACZ,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;SACvE;KACD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;IACzD,MAAM,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE;YACZ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AAsK,CACtK,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { compileLocalVariable } from \"./compile-local-variable.js\";\n\ntest(\"compiles a literal local variable\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"Hello\" } },\n\t\t},\n\t});\n\texpect(code).toEqual('const myVar = \"Hello\";');\n});\n\ntest(\"compiles a variable reference local variable\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"name\" },\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual(\"const myVar = i?.name;\");\n});\n\ntest(\"compiles a variable reference local variable with a non-identifier name\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"half!\" },\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual('const myVar = i?.[\"half!\"];');\n});\n\ntest(\"compiles a local variable with an annotation and empty options\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"literal\", value: \"Hello\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"myFunction\",\n\t\t\t\t\toptions: [],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual('const myVar = registry.myFunction(\"en\", \"Hello\", {});');\n});\n\ntest(\"compiles a local variable with an annotation and options\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"literal\", value: \"Hello\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"myFunction\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"option1\", value: { type: \"literal\", value: \"value1\" } },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"option2\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"varRef\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual(\n\t\t'const myVar = registry.myFunction(\"en\", \"Hello\", { option1: \"value1\", option2: i?.varRef });'\n\t);\n});\n\ntest(\"compiles number formatter fraction digit options as numeric literals\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedValue\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"1\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"maximumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"1\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedValue = registry.number(\"en\", i?.value, { minimumFractionDigits: 1, maximumFractionDigits: 1 });'\n\t);\n});\n\ntest(\"compiles number formatter useGrouping option as boolean literal\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedValue\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"useGrouping\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"false\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedValue = registry.number(\"en\", i?.value, { useGrouping: false });'\n\t);\n});\n\ntest(\"keeps negative digit options as strings to avoid emitting invalid numeric literals\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedValue\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"-1\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedValue = registry.number(\"en\", i?.value, { minimumFractionDigits: \"-1\" });'\n\t);\n});\n\ntest(\"compiles relative time formatter with a literal unit\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\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{ name: \"unit\", value: { type: \"literal\", value: \"day\" } },\n\t\t\t\t\t\t{ name: \"numeric\", value: { type: \"literal\", value: \"auto\" } },\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\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: \"day\", numeric: \"auto\", style: \"short\" });'\n\t);\n});\n\ntest(\"compiles relative time formatter with a dynamic unit cast\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\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\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.unit), style: \"short\" });'\n\t);\n});\n\ntest(\"throws if relative time formatter is missing a unit option\", () => {\n\texpect(() =>\n\t\tcompileLocalVariable({\n\t\t\tlocale: \"en\",\n\t\t\tdeclaration: {\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"formattedDuration\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\t\toptions: [],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t).toThrow('The \"relativetime\" formatter requires a \"unit\" option.');\n});\n\ntest(\"throws if relative time formatter has duplicate unit options\", () => {\n\texpect(() =>\n\t\tcompileLocalVariable({\n\t\t\tlocale: \"en\",\n\t\t\tdeclaration: {\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"formattedDuration\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"day\" } },\n\t\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"hour\" } },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t).toThrow('The \"relativetime\" formatter requires exactly one \"unit\" option.');\n});\n\ntest(\"throws if relative time formatter has an invalid literal unit\", () => {\n\texpect(() =>\n\t\tcompileLocalVariable({\n\t\t\tlocale: \"en\",\n\t\t\tdeclaration: {\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"formattedDuration\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"century\" } },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t).toThrow('Invalid \"relativetime\" unit \"century\".');\n});\n\ntest(\"accepts plural relative time formatter units\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\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{ name: \"unit\", value: { type: \"literal\", value: \"days\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: \"days\" });'\n\t);\n});\n\ntest(\"accepts dynamic relative time formatter units\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\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],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.unit) });'\n\t);\n});\n\ntest(\"accepts dollar-prefixed relative time formatter unit options from message files\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\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{ name: \"unit\", value: { type: \"literal\", value: \"$unit\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.unit) });'\n\t);\n});\n\ntest(\"accepts dollar-prefixed relative time formatter unit options with non-identifier input names\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\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: \"literal\", value: \"$relative-unit\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.[\"relative-unit\"]) });'\n\t);\n});\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Declaration, Message, Variant } from "../messages/ast.js";
|
|
2
|
+
import type { Compiled } from "./types.js";
|
|
3
|
+
import { type InputMatchTypes } from "./jsdoc-types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the compiled message as a string
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export declare const compileMessage: (declarations: Declaration[], message: Message, variants: Variant[], matchTypes?: InputMatchTypes, inputTypeAliasName?: string) => Compiled<Message>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-message.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAW,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKpE;;;GAGG;AACH,eAAO,MAAM,cAAc,iBACZ,WAAW,EAAE,WAClB,OAAO,YACN,OAAO,EAAE,eACN,eAAe,uBACP,MAAM,KACzB,QAAQ,CAAC,OAAO,CAsBlB,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { compilePattern } from "./compile-pattern.js";
|
|
2
|
+
import { inputsType } from "./jsdoc-types.js";
|
|
3
|
+
import { compileLocalVariable } from "./compile-local-variable.js";
|
|
4
|
+
import { renderInputMatchCondition } from "./match-literals.js";
|
|
5
|
+
import { compileInputAccess } from "./variable-access.js";
|
|
6
|
+
/**
|
|
7
|
+
* Returns the compiled message as a string
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export const compileMessage = (declarations, message, variants, matchTypes, inputTypeAliasName) => {
|
|
11
|
+
// return empty string instead?
|
|
12
|
+
if (variants.length == 0) {
|
|
13
|
+
throw new Error("Message must have at least one variant");
|
|
14
|
+
}
|
|
15
|
+
const hasMultipleVariants = variants.length > 1;
|
|
16
|
+
return hasMultipleVariants
|
|
17
|
+
? compileMessageWithMultipleVariants(declarations, message, variants, matchTypes, inputTypeAliasName)
|
|
18
|
+
: compileMessageWithOneVariant(declarations, message, variants, matchTypes, inputTypeAliasName);
|
|
19
|
+
};
|
|
20
|
+
function compileMessageWithOneVariant(declarations, message, variants, matchTypes, inputTypeAliasName) {
|
|
21
|
+
const variant = variants[0];
|
|
22
|
+
if (!variant || variants.length !== 1) {
|
|
23
|
+
throw new Error("Message must have exactly one variant");
|
|
24
|
+
}
|
|
25
|
+
const hasMarkup = patternHasMarkup(variant.pattern);
|
|
26
|
+
const inputs = declarations.filter((decl) => decl.type === "input-variable");
|
|
27
|
+
const hasInputs = inputs.length > 0;
|
|
28
|
+
const messageInputType = inputTypeAliasName ?? inputsType(inputs, matchTypes);
|
|
29
|
+
const compiledPattern = compilePattern({
|
|
30
|
+
pattern: variant.pattern,
|
|
31
|
+
declarations,
|
|
32
|
+
locale: message.locale,
|
|
33
|
+
});
|
|
34
|
+
const compiledLocalVariables = [];
|
|
35
|
+
for (const declaration of declarations) {
|
|
36
|
+
if (declaration.type === "local-variable") {
|
|
37
|
+
compiledLocalVariables.push(compileLocalVariable({ declaration, locale: message.locale }));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (!hasMarkup) {
|
|
41
|
+
const code = `/** @type {(inputs: ${messageInputType}) => LocalizedString} */ (${hasInputs ? "i" : ""}) => {
|
|
42
|
+
${compiledLocalVariables.join("\n\t")}return /** @type {LocalizedString} */ (${compiledPattern.code})
|
|
43
|
+
};`;
|
|
44
|
+
return { code, node: message };
|
|
45
|
+
}
|
|
46
|
+
const compiledPartsPattern = compilePattern({
|
|
47
|
+
pattern: variant.pattern,
|
|
48
|
+
declarations,
|
|
49
|
+
mode: "parts",
|
|
50
|
+
locale: message.locale,
|
|
51
|
+
});
|
|
52
|
+
const localVariablesCode = compiledLocalVariables.length
|
|
53
|
+
? compiledLocalVariables.join("\n\t") + "\n\t"
|
|
54
|
+
: "";
|
|
55
|
+
const inputType = messageInputType;
|
|
56
|
+
const messageInput = hasInputs ? "i" : "";
|
|
57
|
+
const partsCode = `/** @type {((inputs: ${inputType}) => LocalizedString) & { parts: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (
|
|
58
|
+
/* @__PURE__ */ Object.assign(
|
|
59
|
+
/** @type {(inputs: ${inputType}) => LocalizedString} */ ((${messageInput}) => {
|
|
60
|
+
${localVariablesCode}return /** @type {LocalizedString} */ (${compiledPattern.code})
|
|
61
|
+
}),
|
|
62
|
+
{
|
|
63
|
+
parts: /** @type {(inputs: ${inputType}) => import('../runtime.js').MessagePart[]} */ ((${messageInput}) => {
|
|
64
|
+
${localVariablesCode}return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code})
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
);`;
|
|
69
|
+
return { code: partsCode, node: message };
|
|
70
|
+
}
|
|
71
|
+
function compileMessageWithMultipleVariants(declarations, message, variants, matchTypes, inputTypeAliasName) {
|
|
72
|
+
if (variants.length <= 1) {
|
|
73
|
+
throw new Error("Message must have more than one variant");
|
|
74
|
+
}
|
|
75
|
+
const hasMarkup = variants.some((variant) => patternHasMarkup(variant.pattern));
|
|
76
|
+
const inputs = declarations.filter((decl) => decl.type === "input-variable");
|
|
77
|
+
const hasInputs = inputs.length > 0;
|
|
78
|
+
const messageInputType = inputTypeAliasName ?? inputsType(inputs, matchTypes);
|
|
79
|
+
// TODO make sure that matchers use keys instead of indexes
|
|
80
|
+
const compiledVariants = [];
|
|
81
|
+
const compiledPartsVariants = [];
|
|
82
|
+
let hasCatchAll = false;
|
|
83
|
+
for (const variant of variants) {
|
|
84
|
+
const compiledPattern = compilePattern({
|
|
85
|
+
pattern: variant.pattern,
|
|
86
|
+
declarations,
|
|
87
|
+
locale: message.locale,
|
|
88
|
+
});
|
|
89
|
+
const compiledPartsPattern = hasMarkup
|
|
90
|
+
? compilePattern({
|
|
91
|
+
pattern: variant.pattern,
|
|
92
|
+
declarations,
|
|
93
|
+
mode: "parts",
|
|
94
|
+
locale: message.locale,
|
|
95
|
+
})
|
|
96
|
+
: undefined;
|
|
97
|
+
const isCatchAll = variant.matches.every((match) => match.type === "catchall-match");
|
|
98
|
+
if (isCatchAll) {
|
|
99
|
+
compiledVariants.push(`return /** @type {LocalizedString} */ (${compiledPattern.code})`);
|
|
100
|
+
if (compiledPartsPattern) {
|
|
101
|
+
compiledPartsVariants.push(`return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code})`);
|
|
102
|
+
}
|
|
103
|
+
hasCatchAll = true;
|
|
104
|
+
}
|
|
105
|
+
const conditions = [];
|
|
106
|
+
for (const match of variant.matches) {
|
|
107
|
+
// catch all matches are not used in the conditions
|
|
108
|
+
if (match.type !== "literal-match") {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const variableType = declarations.find((decl) => decl.name === match.key)?.type;
|
|
112
|
+
if (variableType === "input-variable") {
|
|
113
|
+
conditions.push(renderInputMatchCondition(compileInputAccess(match.key), match.value));
|
|
114
|
+
}
|
|
115
|
+
else if (variableType === "local-variable") {
|
|
116
|
+
conditions.push(`${match.key} === ${JSON.stringify(match.value)}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (conditions.length === 0)
|
|
120
|
+
continue;
|
|
121
|
+
compiledVariants.push(`if (${conditions.join(" && ")}) return /** @type {LocalizedString} */ (${compiledPattern.code});`);
|
|
122
|
+
if (compiledPartsPattern) {
|
|
123
|
+
compiledPartsVariants.push(`if (${conditions.join(" && ")}) return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code});`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const compiledLocalVariables = [];
|
|
127
|
+
for (const declaration of declarations) {
|
|
128
|
+
if (declaration.type === "local-variable") {
|
|
129
|
+
compiledLocalVariables.push(compileLocalVariable({ declaration, locale: message.locale }));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!hasMarkup) {
|
|
133
|
+
const code = `/** @type {(inputs: ${messageInputType}) => LocalizedString} */ (${hasInputs ? "i" : ""}) => {${compiledLocalVariables.join("\n\t")}
|
|
134
|
+
${compiledVariants.join("\n\t")}
|
|
135
|
+
${hasCatchAll ? "" : `return /** @type {LocalizedString} */ ("${message.bundleId}");`}
|
|
136
|
+
};`;
|
|
137
|
+
return { code, node: message };
|
|
138
|
+
}
|
|
139
|
+
const localVariablesCode = compiledLocalVariables.length
|
|
140
|
+
? compiledLocalVariables.join("\n\t") + "\n\t"
|
|
141
|
+
: "";
|
|
142
|
+
const stringVariantsCode = compiledVariants.length
|
|
143
|
+
? compiledVariants.join("\n\t") + "\n\t"
|
|
144
|
+
: "";
|
|
145
|
+
const partsVariantsCode = compiledPartsVariants.length
|
|
146
|
+
? compiledPartsVariants.join("\n\t") + "\n\t"
|
|
147
|
+
: "";
|
|
148
|
+
const inputType = messageInputType;
|
|
149
|
+
const fallbackParts = `[{ type: "text", value: ${JSON.stringify(message.bundleId)} }]`;
|
|
150
|
+
const messageInput = hasInputs ? "i" : "";
|
|
151
|
+
const code = `/** @type {((inputs: ${inputType}) => LocalizedString) & { parts: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (
|
|
152
|
+
/* @__PURE__ */ Object.assign(
|
|
153
|
+
/** @type {(inputs: ${inputType}) => LocalizedString} */ ((${messageInput}) => {
|
|
154
|
+
${localVariablesCode}${stringVariantsCode}${hasCatchAll
|
|
155
|
+
? ""
|
|
156
|
+
: `return /** @type {LocalizedString} */ (${JSON.stringify(message.bundleId)});`}
|
|
157
|
+
}),
|
|
158
|
+
{
|
|
159
|
+
parts: /** @type {(inputs: ${inputType}) => import('../runtime.js').MessagePart[]} */ ((${messageInput}) => {
|
|
160
|
+
${localVariablesCode}${partsVariantsCode}${hasCatchAll
|
|
161
|
+
? ""
|
|
162
|
+
: `return /** @type {import('../runtime.js').MessagePart[]} */ (${fallbackParts});`}
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
);`;
|
|
167
|
+
return { code, node: message };
|
|
168
|
+
}
|
|
169
|
+
function patternHasMarkup(pattern) {
|
|
170
|
+
return pattern.some((part) => part.type === "markup-start" ||
|
|
171
|
+
part.type === "markup-end" ||
|
|
172
|
+
part.type === "markup-standalone");
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=compile-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-message.js","sourceRoot":"","sources":["../../src/compiler/compile-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,YAA2B,EAC3B,OAAgB,EAChB,QAAmB,EACnB,UAA4B,EAC5B,kBAA2B,EACP,EAAE;IACtB,+BAA+B;IAC/B,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAChD,OAAO,mBAAmB;QACzB,CAAC,CAAC,kCAAkC,CAClC,YAAY,EACZ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CAAC,CAAC,EAAE,CAAC;IAE1C,MAAM,IAAI,GAAG,wBAAwB,SAAS,6CAA6C,SAAS;;wBAE7E,SAAS,8BAA8B,YAAY;KACtE,kBAAkB,GAAG,kBAAkB,GACxC,WAAW;QACV,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,0CAA0C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,IAC9E;;;gCAG6B,SAAS,oDAAoD,YAAY;MACnG,kBAAkB,GAAG,iBAAiB,GACvC,WAAW;QACV,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,gEAAgE,aAAa,IACjF;;;;GAID,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAgB;IACzC,OAAO,OAAO,CAAC,IAAI,CAClB,CAAC,IAAI,EAAE,EAAE,CACR,IAAI,CAAC,IAAI,KAAK,cAAc;QAC5B,IAAI,CAAC,IAAI,KAAK,YAAY;QAC1B,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAClC,CAAC;AACH,CAAC","sourcesContent":["import type { Declaration, Message, Pattern, Variant } from \"../messages/ast.js\";\nimport { compilePattern } from \"./compile-pattern.js\";\nimport type { Compiled } from \"./types.js\";\nimport { inputsType, type InputMatchTypes } from \"./jsdoc-types.js\";\nimport { compileLocalVariable } from \"./compile-local-variable.js\";\nimport { renderInputMatchCondition } from \"./match-literals.js\";\nimport { compileInputAccess } from \"./variable-access.js\";\n\n/**\n * Returns the compiled message as a string\n *\n */\nexport const compileMessage = (\n\tdeclarations: Declaration[],\n\tmessage: Message,\n\tvariants: Variant[],\n\tmatchTypes?: InputMatchTypes,\n\tinputTypeAliasName?: string\n): Compiled<Message> => {\n\t// return empty string instead?\n\tif (variants.length == 0) {\n\t\tthrow new Error(\"Message must have at least one variant\");\n\t}\n\n\tconst hasMultipleVariants = variants.length > 1;\n\treturn hasMultipleVariants\n\t\t? compileMessageWithMultipleVariants(\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tvariants,\n\t\t\t\tmatchTypes,\n\t\t\t\tinputTypeAliasName\n\t\t\t)\n\t\t: compileMessageWithOneVariant(\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tvariants,\n\t\t\t\tmatchTypes,\n\t\t\t\tinputTypeAliasName\n\t\t\t);\n};\n\nfunction compileMessageWithOneVariant(\n\tdeclarations: Declaration[],\n\tmessage: Message,\n\tvariants: Variant[],\n\tmatchTypes?: InputMatchTypes,\n\tinputTypeAliasName?: string\n): Compiled<Message> {\n\tconst variant = variants[0];\n\tif (!variant || variants.length !== 1) {\n\t\tthrow new Error(\"Message must have exactly one variant\");\n\t}\n\n\tconst hasMarkup = patternHasMarkup(variant.pattern);\n\tconst inputs = declarations.filter((decl) => decl.type === \"input-variable\");\n\tconst hasInputs = inputs.length > 0;\n\tconst messageInputType = inputTypeAliasName ?? inputsType(inputs, matchTypes);\n\tconst compiledPattern = compilePattern({\n\t\tpattern: variant.pattern,\n\t\tdeclarations,\n\t\tlocale: message.locale,\n\t});\n\n\tconst compiledLocalVariables = [];\n\n\tfor (const declaration of declarations) {\n\t\tif (declaration.type === \"local-variable\") {\n\t\t\tcompiledLocalVariables.push(\n\t\t\t\tcompileLocalVariable({ declaration, locale: message.locale })\n\t\t\t);\n\t\t}\n\t}\n\n\tif (!hasMarkup) {\n\t\tconst code = `/** @type {(inputs: ${messageInputType}) => LocalizedString} */ (${hasInputs ? \"i\" : \"\"}) => {\n\t${compiledLocalVariables.join(\"\\n\\t\")}return /** @type {LocalizedString} */ (${compiledPattern.code})\n};`;\n\n\t\treturn { code, node: message };\n\t}\n\n\tconst compiledPartsPattern = compilePattern({\n\t\tpattern: variant.pattern,\n\t\tdeclarations,\n\t\tmode: \"parts\",\n\t\tlocale: message.locale,\n\t});\n\tconst localVariablesCode = compiledLocalVariables.length\n\t\t? compiledLocalVariables.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n\tconst inputType = messageInputType;\n\tconst messageInput = hasInputs ? \"i\" : \"\";\n\n\tconst partsCode = `/** @type {((inputs: ${inputType}) => LocalizedString) & { parts: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (\n\t/* @__PURE__ */ Object.assign(\n\t\t/** @type {(inputs: ${inputType}) => LocalizedString} */ ((${messageInput}) => {\n\t\t\t${localVariablesCode}return /** @type {LocalizedString} */ (${compiledPattern.code})\n\t\t}),\n\t\t{\n\t\t\tparts: /** @type {(inputs: ${inputType}) => import('../runtime.js').MessagePart[]} */ ((${messageInput}) => {\n\t\t\t\t${localVariablesCode}return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code})\n\t\t\t})\n\t\t}\n\t)\n);`;\n\n\treturn { code: partsCode, node: message };\n}\n\nfunction compileMessageWithMultipleVariants(\n\tdeclarations: Declaration[],\n\tmessage: Message,\n\tvariants: Variant[],\n\tmatchTypes?: InputMatchTypes,\n\tinputTypeAliasName?: string\n): Compiled<Message> {\n\tif (variants.length <= 1) {\n\t\tthrow new Error(\"Message must have more than one variant\");\n\t}\n\n\tconst hasMarkup = variants.some((variant) =>\n\t\tpatternHasMarkup(variant.pattern)\n\t);\n\tconst inputs = declarations.filter((decl) => decl.type === \"input-variable\");\n\tconst hasInputs = inputs.length > 0;\n\tconst messageInputType = inputTypeAliasName ?? inputsType(inputs, matchTypes);\n\n\t// TODO make sure that matchers use keys instead of indexes\n\tconst compiledVariants = [];\n\tconst compiledPartsVariants = [];\n\n\tlet hasCatchAll = false;\n\n\tfor (const variant of variants) {\n\t\tconst compiledPattern = compilePattern({\n\t\t\tpattern: variant.pattern,\n\t\t\tdeclarations,\n\t\t\tlocale: message.locale,\n\t\t});\n\t\tconst compiledPartsPattern = hasMarkup\n\t\t\t? compilePattern({\n\t\t\t\t\tpattern: variant.pattern,\n\t\t\t\t\tdeclarations,\n\t\t\t\t\tmode: \"parts\",\n\t\t\t\t\tlocale: message.locale,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\tconst isCatchAll = variant.matches.every(\n\t\t\t(match) => match.type === \"catchall-match\"\n\t\t);\n\n\t\tif (isCatchAll) {\n\t\t\tcompiledVariants.push(\n\t\t\t\t`return /** @type {LocalizedString} */ (${compiledPattern.code})`\n\t\t\t);\n\t\t\tif (compiledPartsPattern) {\n\t\t\t\tcompiledPartsVariants.push(\n\t\t\t\t\t`return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code})`\n\t\t\t\t);\n\t\t\t}\n\t\t\thasCatchAll = true;\n\t\t}\n\n\t\tconst conditions: string[] = [];\n\n\t\tfor (const match of variant.matches) {\n\t\t\t// catch all matches are not used in the conditions\n\t\t\tif (match.type !== \"literal-match\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst variableType = declarations.find(\n\t\t\t\t(decl) => decl.name === match.key\n\t\t\t)?.type;\n\t\t\tif (variableType === \"input-variable\") {\n\t\t\t\tconditions.push(\n\t\t\t\t\trenderInputMatchCondition(compileInputAccess(match.key), match.value)\n\t\t\t\t);\n\t\t\t} else if (variableType === \"local-variable\") {\n\t\t\t\tconditions.push(`${match.key} === ${JSON.stringify(match.value)}`);\n\t\t\t}\n\t\t}\n\n\t\tif (conditions.length === 0) continue;\n\t\tcompiledVariants.push(\n\t\t\t`if (${conditions.join(\" && \")}) return /** @type {LocalizedString} */ (${compiledPattern.code});`\n\t\t);\n\t\tif (compiledPartsPattern) {\n\t\t\tcompiledPartsVariants.push(\n\t\t\t\t`if (${conditions.join(\" && \")}) return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code});`\n\t\t\t);\n\t\t}\n\t}\n\n\tconst compiledLocalVariables = [];\n\n\tfor (const declaration of declarations) {\n\t\tif (declaration.type === \"local-variable\") {\n\t\t\tcompiledLocalVariables.push(\n\t\t\t\tcompileLocalVariable({ declaration, locale: message.locale })\n\t\t\t);\n\t\t}\n\t}\n\n\tif (!hasMarkup) {\n\t\tconst code = `/** @type {(inputs: ${messageInputType}) => LocalizedString} */ (${hasInputs ? \"i\" : \"\"}) => {${compiledLocalVariables.join(\"\\n\\t\")}\n\t${compiledVariants.join(\"\\n\\t\")}\n\t${hasCatchAll ? \"\" : `return /** @type {LocalizedString} */ (\"${message.bundleId}\");`}\n};`;\n\n\t\treturn { code, node: message };\n\t}\n\n\tconst localVariablesCode = compiledLocalVariables.length\n\t\t? compiledLocalVariables.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n\tconst stringVariantsCode = compiledVariants.length\n\t\t? compiledVariants.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n\tconst partsVariantsCode = compiledPartsVariants.length\n\t\t? compiledPartsVariants.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n\tconst inputType = messageInputType;\n\tconst fallbackParts = `[{ type: \"text\", value: ${JSON.stringify(message.bundleId)} }]`;\n\tconst messageInput = hasInputs ? \"i\" : \"\";\n\n\tconst code = `/** @type {((inputs: ${inputType}) => LocalizedString) & { parts: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (\n\t/* @__PURE__ */ Object.assign(\n\t\t/** @type {(inputs: ${inputType}) => LocalizedString} */ ((${messageInput}) => {\n\t\t\t${localVariablesCode}${stringVariantsCode}${\n\t\t\t\thasCatchAll\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: `return /** @type {LocalizedString} */ (${JSON.stringify(message.bundleId)});`\n\t\t\t}\n\t\t}),\n\t\t{\n\t\t\tparts: /** @type {(inputs: ${inputType}) => import('../runtime.js').MessagePart[]} */ ((${messageInput}) => {\n\t\t\t\t${localVariablesCode}${partsVariantsCode}${\n\t\t\t\t\thasCatchAll\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `return /** @type {import('../runtime.js').MessagePart[]} */ (${fallbackParts});`\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t)\n);`;\n\n\treturn { code, node: message };\n}\n\nfunction patternHasMarkup(pattern: Pattern): boolean {\n\treturn pattern.some(\n\t\t(part) =>\n\t\t\tpart.type === \"markup-start\" ||\n\t\t\tpart.type === \"markup-end\" ||\n\t\t\tpart.type === \"markup-standalone\"\n\t);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-message.test.d.ts","sourceRoot":"","sources":["../../src/compiler/compile-message.test.ts"],"names":[],"mappings":""}
|