@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,79 @@
|
|
|
1
|
+
import { toLocale } from "./check-locale.js";
|
|
2
|
+
import { baseLocale, locales, routing, } from "./variables.js";
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {{ baseLocale: string, locales: string[] }} HostRoutingRuleResolved
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} hostname
|
|
8
|
+
* @returns {HostRoutingRuleResolved}
|
|
9
|
+
*/
|
|
10
|
+
export function getRoutingRule(hostname) {
|
|
11
|
+
return (routing[hostname] ??
|
|
12
|
+
routing["*"] ?? {
|
|
13
|
+
baseLocale,
|
|
14
|
+
locales: /** @type {string[]} */ ([...locales]),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @param {string[]} segments
|
|
19
|
+
* @param {HostRoutingRuleResolved} rule
|
|
20
|
+
* @returns {Locale | undefined}
|
|
21
|
+
*/
|
|
22
|
+
function localeFromFirstSegment(segments, rule) {
|
|
23
|
+
if (segments.length === 0) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const canonical = toLocale(segments[0]);
|
|
27
|
+
if (canonical && rule.locales.includes(canonical)) {
|
|
28
|
+
return canonical;
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @param {string | URL} url
|
|
34
|
+
* @returns {Locale}
|
|
35
|
+
*/
|
|
36
|
+
export function extractLocaleFromUrlHostRouting(url) {
|
|
37
|
+
const urlObj = typeof url === "string" ? new URL(url, "http://localhost") : url;
|
|
38
|
+
const rule = getRoutingRule(urlObj.hostname);
|
|
39
|
+
const segments = urlObj.pathname.split("/").filter(Boolean);
|
|
40
|
+
return localeFromFirstSegment(segments, rule) ?? rule.baseLocale;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @param {string | URL} url
|
|
44
|
+
* @param {Locale} locale
|
|
45
|
+
* @returns {URL}
|
|
46
|
+
*/
|
|
47
|
+
export function localizeUrlHostRouting(url, locale) {
|
|
48
|
+
const urlObj = typeof url === "string" ? new URL(url) : new URL(url.href);
|
|
49
|
+
const rule = getRoutingRule(urlObj.hostname);
|
|
50
|
+
const segments = urlObj.pathname.split("/").filter(Boolean);
|
|
51
|
+
if (localeFromFirstSegment(segments, rule)) {
|
|
52
|
+
segments.shift();
|
|
53
|
+
}
|
|
54
|
+
if (locale === rule.baseLocale) {
|
|
55
|
+
urlObj.pathname = "/" + segments.join("/");
|
|
56
|
+
}
|
|
57
|
+
else if (segments.length === 0) {
|
|
58
|
+
urlObj.pathname = "/" + locale;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
urlObj.pathname = "/" + locale + "/" + segments.join("/");
|
|
62
|
+
}
|
|
63
|
+
return urlObj;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @param {string | URL} url
|
|
67
|
+
* @returns {URL}
|
|
68
|
+
*/
|
|
69
|
+
export function deLocalizeUrlHostRouting(url) {
|
|
70
|
+
const urlObj = typeof url === "string" ? new URL(url) : new URL(url.href);
|
|
71
|
+
const rule = getRoutingRule(urlObj.hostname);
|
|
72
|
+
const segments = urlObj.pathname.split("/").filter(Boolean);
|
|
73
|
+
if (localeFromFirstSegment(segments, rule)) {
|
|
74
|
+
segments.shift();
|
|
75
|
+
urlObj.pathname = "/" + segments.join("/");
|
|
76
|
+
}
|
|
77
|
+
return urlObj;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=host-routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-routing.js","sourceRoot":"","sources":["../../../src/compiler/runtime/host-routing.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACN,UAAU,EACV,OAAO,EACP,OAAO,GACP,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AAEH;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAQ;IACtC,OAAO,CACN,OAAO,CAAC,QAAQ,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,IAAI;QACf,UAAU;QACV,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;KAC/C,CACD,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,QAAQ,EAAE,IAAI;IAC7C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,IAAI,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACnD,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAAC,GAAG;IAClD,MAAM,MAAM,GACX,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAClE,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG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G,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE5D,IAAI,sBAAsB,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;QAC5C,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,CAAC,QAAQ,GAAG,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import { toLocale } from \"./check-locale.js\";\nimport {\n\tbaseLocale,\n\tlocales,\n\trouting,\n} from \"./variables.js\";\n\n/**\n * @typedef {{ baseLocale: string, locales: string[] }} HostRoutingRuleResolved\n */\n\n/**\n * @param {string} hostname\n * @returns {HostRoutingRuleResolved}\n */\nexport function getRoutingRule(hostname) {\n\treturn (\n\t\trouting[hostname] ??\n\t\trouting[\"*\"] ?? {\n\t\t\tbaseLocale,\n\t\t\tlocales: /** @type {string[]} */ ([...locales]),\n\t\t}\n\t);\n}\n\n/**\n * @param {string[]} segments\n * @param {HostRoutingRuleResolved} rule\n * @returns {Locale | undefined}\n */\nfunction localeFromFirstSegment(segments, rule) {\n\tif (segments.length === 0) {\n\t\treturn undefined;\n\t}\n\tconst canonical = toLocale(segments[0]);\n\tif (canonical && rule.locales.includes(canonical)) {\n\t\treturn canonical;\n\t}\n\treturn undefined;\n}\n\n/**\n * @param {string | URL} url\n * @returns {Locale}\n */\nexport function extractLocaleFromUrlHostRouting(url) {\n\tconst urlObj =\n\t\ttypeof url === \"string\" ? new URL(url, \"http://localhost\") : url;\n\tconst rule = getRoutingRule(urlObj.hostname);\n\tconst segments = urlObj.pathname.split(\"/\").filter(Boolean);\n\treturn localeFromFirstSegment(segments, rule) ?? rule.baseLocale;\n}\n\n/**\n * @param {string | URL} url\n * @param {Locale} locale\n * @returns {URL}\n */\nexport function localizeUrlHostRouting(url, locale) {\n\tconst urlObj =\n\t\ttypeof url === \"string\" ? new URL(url) : new URL(url.href);\n\tconst rule = getRoutingRule(urlObj.hostname);\n\tconst segments = urlObj.pathname.split(\"/\").filter(Boolean);\n\n\tif (localeFromFirstSegment(segments, rule)) {\n\t\tsegments.shift();\n\t}\n\n\tif (locale === rule.baseLocale) {\n\t\turlObj.pathname = \"/\" + segments.join(\"/\");\n\t} else if (segments.length === 0) {\n\t\turlObj.pathname = \"/\" + locale;\n\t} else {\n\t\turlObj.pathname = \"/\" + locale + \"/\" + segments.join(\"/\");\n\t}\n\n\treturn urlObj;\n}\n\n/**\n * @param {string | URL} url\n * @returns {URL}\n */\nexport function deLocalizeUrlHostRouting(url) {\n\tconst urlObj =\n\t\ttypeof url === \"string\" ? new URL(url) : new URL(url.href);\n\tconst rule = getRoutingRule(urlObj.hostname);\n\tconst segments = urlObj.pathname.split(\"/\").filter(Boolean);\n\n\tif (localeFromFirstSegment(segments, rule)) {\n\t\tsegments.shift();\n\t\turlObj.pathname = \"/\" + segments.join(\"/\");\n\t}\n\n\treturn urlObj;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-routing.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/host-routing.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { createParaglide } from "../create-paraglide.js";
|
|
3
|
+
import { createRuntimeFile, normalizeRouting } from "./create-runtime.js";
|
|
4
|
+
test("normalizeRouting fills * fallback and resolves defaults", () => {
|
|
5
|
+
const resolved = normalizeRouting({
|
|
6
|
+
routing: {
|
|
7
|
+
"fin.example.com": { baseLocale: "fi" },
|
|
8
|
+
"app.example.com": {
|
|
9
|
+
baseLocale: "sv",
|
|
10
|
+
locales: ["sv", "en", "pt-PT"],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
locales: ["en", "fi", "sv", "pt-PT", "de"],
|
|
14
|
+
baseLocale: "en",
|
|
15
|
+
});
|
|
16
|
+
expect(resolved).toEqual({
|
|
17
|
+
"fin.example.com": {
|
|
18
|
+
baseLocale: "fi",
|
|
19
|
+
locales: ["en", "fi", "sv", "pt-PT", "de"],
|
|
20
|
+
},
|
|
21
|
+
"app.example.com": {
|
|
22
|
+
baseLocale: "sv",
|
|
23
|
+
locales: ["sv", "en", "pt-PT"],
|
|
24
|
+
},
|
|
25
|
+
"*": {
|
|
26
|
+
baseLocale: "en",
|
|
27
|
+
locales: ["en", "fi", "sv", "pt-PT", "de"],
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
test("normalizeRouting rejects unknown locales", () => {
|
|
32
|
+
expect(() => normalizeRouting({
|
|
33
|
+
routing: {
|
|
34
|
+
"fin.example.com": { baseLocale: "nope" },
|
|
35
|
+
},
|
|
36
|
+
locales: ["en", "fi"],
|
|
37
|
+
baseLocale: "en",
|
|
38
|
+
})).toThrow(/Invalid baseLocale "nope"/);
|
|
39
|
+
});
|
|
40
|
+
test("createRuntimeFile rejects routing + urlPatterns together", () => {
|
|
41
|
+
expect(() => createRuntimeFile({
|
|
42
|
+
baseLocale: "en",
|
|
43
|
+
locales: ["en", "de"],
|
|
44
|
+
compilerOptions: {
|
|
45
|
+
strategy: ["url", "baseLocale"],
|
|
46
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
47
|
+
cookieMaxAge: 100,
|
|
48
|
+
cookieDomain: "",
|
|
49
|
+
localStorageKey: "PARAGLIDE_LOCALE",
|
|
50
|
+
isServer: "typeof window === 'undefined'",
|
|
51
|
+
experimentalMiddlewareLocaleSplitting: false,
|
|
52
|
+
disableAsyncLocalStorage: false,
|
|
53
|
+
routing: { "*": { baseLocale: "en" } },
|
|
54
|
+
urlPatterns: [
|
|
55
|
+
{
|
|
56
|
+
pattern: "/:path(.*)?",
|
|
57
|
+
localized: [
|
|
58
|
+
["en", "/:path(.*)?"],
|
|
59
|
+
["de", "/de/:path(.*)?"],
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
})).toThrow(/Cannot set both "routing" and "urlPatterns"/);
|
|
65
|
+
});
|
|
66
|
+
test("per-host baseLocale: bare path is host default, /en is english", async () => {
|
|
67
|
+
const runtime = await createParaglide({
|
|
68
|
+
baseLocale: "en",
|
|
69
|
+
locales: ["en", "fi", "sv", "de"],
|
|
70
|
+
strategy: ["url", "baseLocale"],
|
|
71
|
+
routing: {
|
|
72
|
+
"fin.example.com": { baseLocale: "fi" },
|
|
73
|
+
"app.example.com": { baseLocale: "sv" },
|
|
74
|
+
"*": { baseLocale: "en" },
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
expect(runtime.extractLocaleFromUrl("https://fin.example.com/")).toBe("fi");
|
|
78
|
+
expect(runtime.extractLocaleFromUrl("https://fin.example.com/about")).toBe("fi");
|
|
79
|
+
expect(runtime.extractLocaleFromUrl("https://fin.example.com/en")).toBe("en");
|
|
80
|
+
expect(runtime.extractLocaleFromUrl("https://fin.example.com/en/about")).toBe("en");
|
|
81
|
+
expect(runtime.extractLocaleFromUrl("https://app.example.com/")).toBe("sv");
|
|
82
|
+
expect(runtime.extractLocaleFromUrl("https://other.example.com/de/x")).toBe("de");
|
|
83
|
+
expect(runtime.localizeUrl("https://fin.example.com/about", { locale: "en" }).href).toBe("https://fin.example.com/en/about");
|
|
84
|
+
expect(runtime.localizeUrl("https://fin.example.com/en/about", { locale: "fi" })
|
|
85
|
+
.href).toBe("https://fin.example.com/about");
|
|
86
|
+
expect(runtime.localizeUrl("https://fin.example.com/about", { locale: "fi" }).href).toBe("https://fin.example.com/about");
|
|
87
|
+
expect(runtime.deLocalizeUrl("https://fin.example.com/en/about").href).toBe("https://fin.example.com/about");
|
|
88
|
+
expect(runtime.deLocalizeUrl("https://fin.example.com/about").href).toBe("https://fin.example.com/about");
|
|
89
|
+
});
|
|
90
|
+
test("host locales restrict which prefixes are recognized", async () => {
|
|
91
|
+
const runtime = await createParaglide({
|
|
92
|
+
baseLocale: "en",
|
|
93
|
+
locales: ["en", "sv", "pt-PT", "de"],
|
|
94
|
+
strategy: ["url", "baseLocale"],
|
|
95
|
+
routing: {
|
|
96
|
+
"app.example.com": {
|
|
97
|
+
baseLocale: "sv",
|
|
98
|
+
locales: ["sv", "en", "pt-PT"],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
expect(runtime.extractLocaleFromUrl("https://app.example.com/pt-PT/shop")).toBe("pt-PT");
|
|
103
|
+
// de is a project locale but not allowed on this host → treated as path
|
|
104
|
+
expect(runtime.extractLocaleFromUrl("https://app.example.com/de/shop")).toBe("sv");
|
|
105
|
+
expect(runtime.localizeUrl("https://app.example.com/shop", { locale: "pt-PT" })
|
|
106
|
+
.href).toBe("https://app.example.com/pt-PT/shop");
|
|
107
|
+
});
|
|
108
|
+
test("localizeHref works with host routing under ALS origin", async () => {
|
|
109
|
+
const runtime = await createParaglide({
|
|
110
|
+
baseLocale: "en",
|
|
111
|
+
locales: ["en", "fi"],
|
|
112
|
+
strategy: ["url", "baseLocale"],
|
|
113
|
+
routing: {
|
|
114
|
+
"fin.example.com": { baseLocale: "fi" },
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
runtime.overwriteServerAsyncLocalStorage({
|
|
118
|
+
getStore: () => ({
|
|
119
|
+
locale: "fi",
|
|
120
|
+
origin: "https://fin.example.com",
|
|
121
|
+
}),
|
|
122
|
+
run: () => undefined,
|
|
123
|
+
});
|
|
124
|
+
expect(runtime.localizeHref("/about")).toBe("/about");
|
|
125
|
+
expect(runtime.localizeHref("/about", { locale: "en" })).toBe("/en/about");
|
|
126
|
+
expect(runtime.localizeHref("/en/about", { locale: "fi" })).toBe("/about");
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=host-routing.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-routing.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/host-routing.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,IAAI,CAAC,yDAAyD,EAAE,GAAG,EAAE;IACpE,MAAM,QAAQ,GAAG,gBAAgB,CAAC;QACjC,OAAO,EAAE;YACR,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;YACvC,iBAAiB,EAAE;gBAClB,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;aAC9B;SACD;QACD,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;QAC1C,UAAU,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;QACxB,iBAAiB,EAAE;YAClB,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;SAC1C;QACD,iBAAiB,EAAE;YAClB,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;SAC9B;QACD,GAAG,EAAE;YACJ,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,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G,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC;QAC/B,OAAO,EAAE;YACR,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SACvC;KACD,CAAC,CAAC;IAEH,OAAO,CAAC,gCAAgC,CAAC;QACxC,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;YAChB,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,yBAAyB;SACjC,CAAC;QACF,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3E,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC5E,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\nimport { createRuntimeFile, normalizeRouting } from \"./create-runtime.js\";\n\ntest(\"normalizeRouting fills * fallback and resolves defaults\", () => {\n\tconst resolved = normalizeRouting({\n\t\trouting: {\n\t\t\t\"fin.example.com\": { baseLocale: \"fi\" },\n\t\t\t\"app.example.com\": {\n\t\t\t\tbaseLocale: \"sv\",\n\t\t\t\tlocales: [\"sv\", \"en\", \"pt-PT\"],\n\t\t\t},\n\t\t},\n\t\tlocales: [\"en\", \"fi\", \"sv\", \"pt-PT\", \"de\"],\n\t\tbaseLocale: \"en\",\n\t});\n\n\texpect(resolved).toEqual({\n\t\t\"fin.example.com\": {\n\t\t\tbaseLocale: \"fi\",\n\t\t\tlocales: [\"en\", \"fi\", \"sv\", \"pt-PT\", \"de\"],\n\t\t},\n\t\t\"app.example.com\": {\n\t\t\tbaseLocale: \"sv\",\n\t\t\tlocales: [\"sv\", \"en\", \"pt-PT\"],\n\t\t},\n\t\t\"*\": {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"fi\", \"sv\", \"pt-PT\", \"de\"],\n\t\t},\n\t});\n});\n\ntest(\"normalizeRouting rejects unknown locales\", () => {\n\texpect(() =>\n\t\tnormalizeRouting({\n\t\t\trouting: {\n\t\t\t\t\"fin.example.com\": { baseLocale: \"nope\" },\n\t\t\t},\n\t\t\tlocales: [\"en\", \"fi\"],\n\t\t\tbaseLocale: \"en\",\n\t\t})\n\t).toThrow(/Invalid baseLocale \"nope\"/);\n});\n\ntest(\"createRuntimeFile rejects routing + urlPatterns together\", () => {\n\texpect(() =>\n\t\tcreateRuntimeFile({\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\"],\n\t\t\tcompilerOptions: {\n\t\t\t\tstrategy: [\"url\", \"baseLocale\"],\n\t\t\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\t\t\tcookieMaxAge: 100,\n\t\t\t\tcookieDomain: \"\",\n\t\t\t\tlocalStorageKey: \"PARAGLIDE_LOCALE\",\n\t\t\t\tisServer: \"typeof window === 'undefined'\",\n\t\t\t\texperimentalMiddlewareLocaleSplitting: false,\n\t\t\t\tdisableAsyncLocalStorage: false,\n\t\t\t\trouting: { \"*\": { baseLocale: \"en\" } },\n\t\t\t\turlPatterns: [\n\t\t\t\t\t{\n\t\t\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\t\t\tlocalized: [\n\t\t\t\t\t\t\t[\"en\", \"/:path(.*)?\"],\n\t\t\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"],\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(/Cannot set both \"routing\" and \"urlPatterns\"/);\n});\n\ntest(\"per-host baseLocale: bare path is host default, /en is english\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fi\", \"sv\", \"de\"],\n\t\tstrategy: [\"url\", \"baseLocale\"],\n\t\trouting: {\n\t\t\t\"fin.example.com\": { baseLocale: \"fi\" },\n\t\t\t\"app.example.com\": { baseLocale: \"sv\" },\n\t\t\t\"*\": { baseLocale: \"en\" },\n\t\t},\n\t});\n\n\texpect(runtime.extractLocaleFromUrl(\"https://fin.example.com/\")).toBe(\"fi\");\n\texpect(runtime.extractLocaleFromUrl(\"https://fin.example.com/about\")).toBe(\n\t\t\"fi\"\n\t);\n\texpect(runtime.extractLocaleFromUrl(\"https://fin.example.com/en\")).toBe(\"en\");\n\texpect(\n\t\truntime.extractLocaleFromUrl(\"https://fin.example.com/en/about\")\n\t).toBe(\"en\");\n\texpect(runtime.extractLocaleFromUrl(\"https://app.example.com/\")).toBe(\"sv\");\n\texpect(runtime.extractLocaleFromUrl(\"https://other.example.com/de/x\")).toBe(\n\t\t\"de\"\n\t);\n\n\texpect(\n\t\truntime.localizeUrl(\"https://fin.example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://fin.example.com/en/about\");\n\texpect(\n\t\truntime.localizeUrl(\"https://fin.example.com/en/about\", { locale: \"fi\" })\n\t\t\t.href\n\t).toBe(\"https://fin.example.com/about\");\n\texpect(\n\t\truntime.localizeUrl(\"https://fin.example.com/about\", { locale: \"fi\" }).href\n\t).toBe(\"https://fin.example.com/about\");\n\n\texpect(runtime.deLocalizeUrl(\"https://fin.example.com/en/about\").href).toBe(\n\t\t\"https://fin.example.com/about\"\n\t);\n\texpect(runtime.deLocalizeUrl(\"https://fin.example.com/about\").href).toBe(\n\t\t\"https://fin.example.com/about\"\n\t);\n});\n\ntest(\"host locales restrict which prefixes are recognized\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"sv\", \"pt-PT\", \"de\"],\n\t\tstrategy: [\"url\", \"baseLocale\"],\n\t\trouting: {\n\t\t\t\"app.example.com\": {\n\t\t\t\tbaseLocale: \"sv\",\n\t\t\t\tlocales: [\"sv\", \"en\", \"pt-PT\"],\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(\n\t\truntime.extractLocaleFromUrl(\"https://app.example.com/pt-PT/shop\")\n\t).toBe(\"pt-PT\");\n\t// de is a project locale but not allowed on this host → treated as path\n\texpect(runtime.extractLocaleFromUrl(\"https://app.example.com/de/shop\")).toBe(\n\t\t\"sv\"\n\t);\n\texpect(\n\t\truntime.localizeUrl(\"https://app.example.com/shop\", { locale: \"pt-PT\" })\n\t\t\t.href\n\t).toBe(\"https://app.example.com/pt-PT/shop\");\n});\n\ntest(\"localizeHref works with host routing under ALS origin\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fi\"],\n\t\tstrategy: [\"url\", \"baseLocale\"],\n\t\trouting: {\n\t\t\t\"fin.example.com\": { baseLocale: \"fi\" },\n\t\t},\n\t});\n\n\truntime.overwriteServerAsyncLocalStorage({\n\t\tgetStore: () => ({\n\t\t\tlocale: \"fi\",\n\t\t\torigin: \"https://fin.example.com\",\n\t\t}),\n\t\trun: () => undefined,\n\t});\n\n\texpect(runtime.localizeHref(\"/about\")).toBe(\"/about\");\n\texpect(runtime.localizeHref(\"/about\", { locale: \"en\" })).toBe(\"/en/about\");\n\texpect(runtime.localizeHref(\"/en/about\", { locale: \"fi\" })).toBe(\"/about\");\n});\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level URL localization function optimized for client-side UI usage.
|
|
3
|
+
*
|
|
4
|
+
* This is a convenience wrapper around `localizeUrl()` that provides features
|
|
5
|
+
* needed in UI:
|
|
6
|
+
*
|
|
7
|
+
* - Accepts relative paths (e.g., "/about")
|
|
8
|
+
* - Returns relative paths when possible
|
|
9
|
+
* - Automatically detects current locale if not specified
|
|
10
|
+
* - Handles string input/output instead of URL objects
|
|
11
|
+
*
|
|
12
|
+
* @see https://paraglidejs.com/i18n-routing
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // In a React/Vue/Svelte component
|
|
17
|
+
* const NavLink = ({ href }) => {
|
|
18
|
+
* // Automatically uses current locale, keeps path relative
|
|
19
|
+
* return <a href={localizeHref(href)}>...</a>;
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* // Examples:
|
|
23
|
+
* localizeHref("/about")
|
|
24
|
+
* // => "/de/about" (if current locale is "de")
|
|
25
|
+
* localizeHref("/store", { locale: "fr" })
|
|
26
|
+
* // => "/fr/store" (explicit locale)
|
|
27
|
+
*
|
|
28
|
+
* // Cross-origin links remain absolute
|
|
29
|
+
* localizeHref("https://other-site.com/about")
|
|
30
|
+
* // => "https://other-site.com/de/about"
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* For server-side URL localization (e.g., in middleware), use `localizeUrl()`
|
|
34
|
+
* which provides more precise control over URL handling.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} href - The href to localize (can be relative or absolute)
|
|
37
|
+
* @param {object} [options] - Options for localization
|
|
38
|
+
* @param {Locale} [options.locale] - Target locale. If not provided, uses `getLocale()`
|
|
39
|
+
* @returns {string} The localized href, relative if input was relative
|
|
40
|
+
*/
|
|
41
|
+
export declare function localizeHref(href: string, options?: {
|
|
42
|
+
locale?: Locale;
|
|
43
|
+
}): string;
|
|
44
|
+
/**
|
|
45
|
+
* High-level URL de-localization function optimized for client-side UI usage.
|
|
46
|
+
*
|
|
47
|
+
* This is a convenience wrapper around `deLocalizeUrl()` that provides features
|
|
48
|
+
* needed in the UI:
|
|
49
|
+
*
|
|
50
|
+
* - Accepts relative paths (e.g., "/de/about")
|
|
51
|
+
* - Returns relative paths when possible
|
|
52
|
+
* - Handles string input/output instead of URL objects
|
|
53
|
+
*
|
|
54
|
+
* @see https://paraglidejs.com/i18n-routing
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // In a React/Vue/Svelte component
|
|
59
|
+
* const LocaleSwitcher = ({ href }) => {
|
|
60
|
+
* // Remove locale prefix before switching
|
|
61
|
+
* const baseHref = deLocalizeHref(href);
|
|
62
|
+
* return locales.map(locale =>
|
|
63
|
+
* <a href={localizeHref(baseHref, { locale })}>
|
|
64
|
+
* Switch to {locale}
|
|
65
|
+
* </a>
|
|
66
|
+
* );
|
|
67
|
+
* };
|
|
68
|
+
*
|
|
69
|
+
* // Examples:
|
|
70
|
+
* deLocalizeHref("/de/about") // => "/about"
|
|
71
|
+
* deLocalizeHref("/fr/store") // => "/store"
|
|
72
|
+
*
|
|
73
|
+
* // Cross-origin links remain absolute
|
|
74
|
+
* deLocalizeHref("https://example.com/de/about")
|
|
75
|
+
* // => "https://example.com/about"
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* For server-side URL de-localization (e.g., in middleware), use `deLocalizeUrl()`
|
|
79
|
+
* which provides more precise control over URL handling.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} href - The href to de-localize (can be relative or absolute)
|
|
82
|
+
* @returns {string} The de-localized href, relative if input was relative
|
|
83
|
+
*/
|
|
84
|
+
export declare function deLocalizeHref(href: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localize-href.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-href.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,YAAY,CAAC,IAAI,EALtB,MAKsB,EAAE,OAAO,AAJvC,CAEA,EADA;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;CAEuC,GAF7B,MAAM,CAyBlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAHxB,MAGwB,GAFtB,MAAM,CAclB"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { getLocale } from "./get-locale.js";
|
|
2
|
+
import { getUrlOrigin } from "./get-url-origin.js";
|
|
3
|
+
import { deLocalizeUrl, localizeUrl } from "./localize-url.js";
|
|
4
|
+
/**
|
|
5
|
+
* High-level URL localization function optimized for client-side UI usage.
|
|
6
|
+
*
|
|
7
|
+
* This is a convenience wrapper around `localizeUrl()` that provides features
|
|
8
|
+
* needed in UI:
|
|
9
|
+
*
|
|
10
|
+
* - Accepts relative paths (e.g., "/about")
|
|
11
|
+
* - Returns relative paths when possible
|
|
12
|
+
* - Automatically detects current locale if not specified
|
|
13
|
+
* - Handles string input/output instead of URL objects
|
|
14
|
+
*
|
|
15
|
+
* @see https://paraglidejs.com/i18n-routing
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // In a React/Vue/Svelte component
|
|
20
|
+
* const NavLink = ({ href }) => {
|
|
21
|
+
* // Automatically uses current locale, keeps path relative
|
|
22
|
+
* return <a href={localizeHref(href)}>...</a>;
|
|
23
|
+
* };
|
|
24
|
+
*
|
|
25
|
+
* // Examples:
|
|
26
|
+
* localizeHref("/about")
|
|
27
|
+
* // => "/de/about" (if current locale is "de")
|
|
28
|
+
* localizeHref("/store", { locale: "fr" })
|
|
29
|
+
* // => "/fr/store" (explicit locale)
|
|
30
|
+
*
|
|
31
|
+
* // Cross-origin links remain absolute
|
|
32
|
+
* localizeHref("https://other-site.com/about")
|
|
33
|
+
* // => "https://other-site.com/de/about"
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* For server-side URL localization (e.g., in middleware), use `localizeUrl()`
|
|
37
|
+
* which provides more precise control over URL handling.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} href - The href to localize (can be relative or absolute)
|
|
40
|
+
* @param {object} [options] - Options for localization
|
|
41
|
+
* @param {Locale} [options.locale] - Target locale. If not provided, uses `getLocale()`
|
|
42
|
+
* @returns {string} The localized href, relative if input was relative
|
|
43
|
+
*/
|
|
44
|
+
export function localizeHref(href, options) {
|
|
45
|
+
const currentLocale = getLocale();
|
|
46
|
+
const locale = options?.locale ?? currentLocale;
|
|
47
|
+
const url = new URL(href, getUrlOrigin());
|
|
48
|
+
const localized = localizeUrl(url, { locale });
|
|
49
|
+
// if the origin is identical and the href is relative,
|
|
50
|
+
// return the relative path
|
|
51
|
+
if (href.startsWith("/") && url.origin === localized.origin) {
|
|
52
|
+
// check for cross origin localization in which case an absolute URL must be returned.
|
|
53
|
+
if (locale !== currentLocale) {
|
|
54
|
+
const localizedCurrentLocale = localizeUrl(url, {
|
|
55
|
+
locale: currentLocale,
|
|
56
|
+
});
|
|
57
|
+
if (localizedCurrentLocale.origin !== localized.origin) {
|
|
58
|
+
return localized.href;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return localized.pathname + localized.search + localized.hash;
|
|
62
|
+
}
|
|
63
|
+
return localized.href;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* High-level URL de-localization function optimized for client-side UI usage.
|
|
67
|
+
*
|
|
68
|
+
* This is a convenience wrapper around `deLocalizeUrl()` that provides features
|
|
69
|
+
* needed in the UI:
|
|
70
|
+
*
|
|
71
|
+
* - Accepts relative paths (e.g., "/de/about")
|
|
72
|
+
* - Returns relative paths when possible
|
|
73
|
+
* - Handles string input/output instead of URL objects
|
|
74
|
+
*
|
|
75
|
+
* @see https://paraglidejs.com/i18n-routing
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // In a React/Vue/Svelte component
|
|
80
|
+
* const LocaleSwitcher = ({ href }) => {
|
|
81
|
+
* // Remove locale prefix before switching
|
|
82
|
+
* const baseHref = deLocalizeHref(href);
|
|
83
|
+
* return locales.map(locale =>
|
|
84
|
+
* <a href={localizeHref(baseHref, { locale })}>
|
|
85
|
+
* Switch to {locale}
|
|
86
|
+
* </a>
|
|
87
|
+
* );
|
|
88
|
+
* };
|
|
89
|
+
*
|
|
90
|
+
* // Examples:
|
|
91
|
+
* deLocalizeHref("/de/about") // => "/about"
|
|
92
|
+
* deLocalizeHref("/fr/store") // => "/store"
|
|
93
|
+
*
|
|
94
|
+
* // Cross-origin links remain absolute
|
|
95
|
+
* deLocalizeHref("https://example.com/de/about")
|
|
96
|
+
* // => "https://example.com/about"
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* For server-side URL de-localization (e.g., in middleware), use `deLocalizeUrl()`
|
|
100
|
+
* which provides more precise control over URL handling.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} href - The href to de-localize (can be relative or absolute)
|
|
103
|
+
* @returns {string} The de-localized href, relative if input was relative
|
|
104
|
+
*/
|
|
105
|
+
export function deLocalizeHref(href) {
|
|
106
|
+
const url = new URL(href, getUrlOrigin());
|
|
107
|
+
const deLocalized = deLocalizeUrl(url);
|
|
108
|
+
// If the origin is identical and the href is relative,
|
|
109
|
+
// return the relative path instead of the full URL.
|
|
110
|
+
if (href.startsWith("/") && url.origin === deLocalized.origin) {
|
|
111
|
+
return deLocalized.pathname + deLocalized.search + deLocalized.hash;
|
|
112
|
+
}
|
|
113
|
+
return deLocalized.href;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=localize-href.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localize-href.js","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-href.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;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,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;QAC/D,OAAO,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC;IACrE,CAAC;IAED,OAAO,WAAW,CAAC,IAAI,CAAC;AACzB,CAAC","sourcesContent":["import { getLocale } from \"./get-locale.js\";\nimport { getUrlOrigin } from \"./get-url-origin.js\";\nimport { deLocalizeUrl, localizeUrl } from \"./localize-url.js\";\n\n/**\n * High-level URL localization function optimized for client-side UI usage.\n *\n * This is a convenience wrapper around `localizeUrl()` that provides features\n * needed in UI:\n *\n * - Accepts relative paths (e.g., \"/about\")\n * - Returns relative paths when possible\n * - Automatically detects current locale if not specified\n * - Handles string input/output instead of URL objects\n *\n * @see https://paraglidejs.com/i18n-routing\n *\n * @example\n * ```typescript\n * // In a React/Vue/Svelte component\n * const NavLink = ({ href }) => {\n * // Automatically uses current locale, keeps path relative\n * return <a href={localizeHref(href)}>...</a>;\n * };\n *\n * // Examples:\n * localizeHref(\"/about\")\n * // => \"/de/about\" (if current locale is \"de\")\n * localizeHref(\"/store\", { locale: \"fr\" })\n * // => \"/fr/store\" (explicit locale)\n *\n * // Cross-origin links remain absolute\n * localizeHref(\"https://other-site.com/about\")\n * // => \"https://other-site.com/de/about\"\n * ```\n *\n * For server-side URL localization (e.g., in middleware), use `localizeUrl()`\n * which provides more precise control over URL handling.\n *\n * @param {string} href - The href to localize (can be relative or absolute)\n * @param {object} [options] - Options for localization\n * @param {Locale} [options.locale] - Target locale. If not provided, uses `getLocale()`\n * @returns {string} The localized href, relative if input was relative\n */\nexport function localizeHref(href, options) {\n\tconst currentLocale = getLocale();\n\tconst locale = options?.locale ?? currentLocale;\n\tconst url = new URL(href, getUrlOrigin());\n\n\tconst localized = localizeUrl(url, { locale });\n\n\t// if the origin is identical and the href is relative,\n\t// return the relative path\n\tif (href.startsWith(\"/\") && url.origin === localized.origin) {\n\t\t// check for cross origin localization in which case an absolute URL must be returned.\n\t\tif (locale !== currentLocale) {\n\t\t\tconst localizedCurrentLocale = localizeUrl(url, {\n\t\t\t\tlocale: currentLocale,\n\t\t\t});\n\t\t\tif (localizedCurrentLocale.origin !== localized.origin) {\n\t\t\t\treturn localized.href;\n\t\t\t}\n\t\t}\n\t\treturn localized.pathname + localized.search + localized.hash;\n\t}\n\n\treturn localized.href;\n}\n\n/**\n * High-level URL de-localization function optimized for client-side UI usage.\n *\n * This is a convenience wrapper around `deLocalizeUrl()` that provides features\n * needed in the UI:\n *\n * - Accepts relative paths (e.g., \"/de/about\")\n * - Returns relative paths when possible\n * - Handles string input/output instead of URL objects\n *\n * @see https://paraglidejs.com/i18n-routing\n *\n * @example\n * ```typescript\n * // In a React/Vue/Svelte component\n * const LocaleSwitcher = ({ href }) => {\n * // Remove locale prefix before switching\n * const baseHref = deLocalizeHref(href);\n * return locales.map(locale =>\n * <a href={localizeHref(baseHref, { locale })}>\n * Switch to {locale}\n * </a>\n * );\n * };\n *\n * // Examples:\n * deLocalizeHref(\"/de/about\") // => \"/about\"\n * deLocalizeHref(\"/fr/store\") // => \"/store\"\n *\n * // Cross-origin links remain absolute\n * deLocalizeHref(\"https://example.com/de/about\")\n * // => \"https://example.com/about\"\n * ```\n *\n * For server-side URL de-localization (e.g., in middleware), use `deLocalizeUrl()`\n * which provides more precise control over URL handling.\n *\n * @param {string} href - The href to de-localize (can be relative or absolute)\n * @returns {string} The de-localized href, relative if input was relative\n */\nexport function deLocalizeHref(href) {\n\tconst url = new URL(href, getUrlOrigin());\n\n\tconst deLocalized = deLocalizeUrl(url);\n\n\t// If the origin is identical and the href is relative,\n\t// return the relative path instead of the full URL.\n\tif (href.startsWith(\"/\") && url.origin === deLocalized.origin) {\n\t\treturn deLocalized.pathname + deLocalized.search + deLocalized.hash;\n\t}\n\n\treturn deLocalized.href;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localize-href.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-href.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { createParaglide } from "../create-paraglide.js";
|
|
3
|
+
test("uses the locale from getLocale() if no locale is provided", async () => {
|
|
4
|
+
const runtime = await createParaglide({
|
|
5
|
+
baseLocale: "en",
|
|
6
|
+
locales: ["en", "de"],
|
|
7
|
+
strategy: ["url", "globalVariable", "baseLocale"],
|
|
8
|
+
urlPatterns: [
|
|
9
|
+
{
|
|
10
|
+
pattern: "http://:domain(.*)/:locale(de|en)?/:path(.*)?",
|
|
11
|
+
localized: [
|
|
12
|
+
["de", "http://:domain(.*)/de/:path(.*)?"],
|
|
13
|
+
["en", "http://:domain(.*)/:path(.*)?"],
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
runtime.overwriteGetLocale(() => "de");
|
|
19
|
+
expect(runtime.localizeHref("/hello")).toBe("/de/hello");
|
|
20
|
+
expect(runtime.deLocalizeHref("/de/hello")).toBe("/hello");
|
|
21
|
+
});
|
|
22
|
+
test("returns an absolute href if the provided href is absolute", async () => {
|
|
23
|
+
const runtime = await createParaglide({
|
|
24
|
+
baseLocale: "en",
|
|
25
|
+
locales: ["en", "de"],
|
|
26
|
+
strategy: ["url", "globalVariable", "baseLocale"],
|
|
27
|
+
urlPatterns: [
|
|
28
|
+
{
|
|
29
|
+
pattern: "http://:domain(.*)/:locale(de|en)?/:path(.*)?",
|
|
30
|
+
localized: [
|
|
31
|
+
["de", "http://:domain(.*)/de/:path(.*)?"],
|
|
32
|
+
["en", "http://:domain(.*)/:path(.*)?"],
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
expect(runtime.localizeHref("http://example.com/hello", { locale: "de" })).toBe("http://example.com/de/hello");
|
|
38
|
+
expect(runtime.deLocalizeHref("http://example.com/de/hello")).toBe("http://example.com/hello");
|
|
39
|
+
});
|
|
40
|
+
// useful if domain based localization is used for example
|
|
41
|
+
test("returns an absolute href if the provided href is relative but the origin of the localized href differs", async () => {
|
|
42
|
+
const runtime = await createParaglide({
|
|
43
|
+
baseLocale: "en",
|
|
44
|
+
locales: ["en", "de"],
|
|
45
|
+
strategy: ["url", "globalVariable", "baseLocale"],
|
|
46
|
+
urlPatterns: [
|
|
47
|
+
{
|
|
48
|
+
pattern: "http://example.com/:path(.*)?",
|
|
49
|
+
localized: [
|
|
50
|
+
["de", "http://de.example.com/:path(.*)?"],
|
|
51
|
+
["en", "http://example.com/:path(.*)?"],
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
// simulating routing from current en page to de page
|
|
57
|
+
runtime.overwriteGetLocale(() => "en");
|
|
58
|
+
runtime.overwriteGetUrlOrigin(() => "http://example.com");
|
|
59
|
+
expect(runtime.localizeHref("/hello", { locale: "de" })).toBe("http://de.example.com/hello");
|
|
60
|
+
expect(runtime.deLocalizeHref("http://de.example.com/hello")).toBe("http://example.com/hello");
|
|
61
|
+
// simulating routing from current de page to en page
|
|
62
|
+
runtime.overwriteGetLocale(() => "de");
|
|
63
|
+
expect(runtime.localizeHref("/hello", { locale: "en" })).toBe("http://example.com/hello");
|
|
64
|
+
expect(runtime.deLocalizeHref("http://example.com/hello")).toBe("http://example.com/hello");
|
|
65
|
+
});
|
|
66
|
+
// https://github.com/opral/inlang-paraglide-js/issues/362
|
|
67
|
+
test("adding a base path", async () => {
|
|
68
|
+
const base = "shop";
|
|
69
|
+
const runtime = await createParaglide({
|
|
70
|
+
baseLocale: "en",
|
|
71
|
+
locales: ["en", "de"],
|
|
72
|
+
strategy: ["url"],
|
|
73
|
+
urlPatterns: [
|
|
74
|
+
{
|
|
75
|
+
pattern: `/{${base}/}?:path(.*)?`,
|
|
76
|
+
localized: [
|
|
77
|
+
["de", `/{${base}/}?de/:path(.*)?`],
|
|
78
|
+
["en", `/{${base}/}?:path(.*)?`],
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
});
|
|
83
|
+
// simulating the current locale to be en
|
|
84
|
+
runtime.overwriteGetLocale(() => "en");
|
|
85
|
+
expect(runtime.localizeHref("/about")).toBe("/shop/about");
|
|
86
|
+
expect(runtime.deLocalizeHref("/about")).toBe("/shop/about");
|
|
87
|
+
// simulating current locale to be de
|
|
88
|
+
runtime.overwriteGetLocale(() => "de");
|
|
89
|
+
expect(runtime.localizeHref("/about")).toBe("/shop/de/about");
|
|
90
|
+
expect(runtime.deLocalizeHref("/de/about")).toBe("/shop/about");
|
|
91
|
+
});
|
|
92
|
+
test("default url patterns to improve out of the box experience", async () => {
|
|
93
|
+
const runtime = await createParaglide({
|
|
94
|
+
baseLocale: "en",
|
|
95
|
+
locales: ["en", "de", "fr"],
|
|
96
|
+
isServer: "false",
|
|
97
|
+
strategy: ["url"],
|
|
98
|
+
urlPatterns: undefined,
|
|
99
|
+
});
|
|
100
|
+
// polyfilling window
|
|
101
|
+
globalThis.window = { location: new URL("http://example.com") };
|
|
102
|
+
expect(runtime.urlPatterns).toStrictEqual([
|
|
103
|
+
{
|
|
104
|
+
pattern: ":protocol://:domain(.*)::port?/:path(.*)?",
|
|
105
|
+
localized: [
|
|
106
|
+
["de", ":protocol://:domain(.*)::port?/de/:path(.*)?"],
|
|
107
|
+
["fr", ":protocol://:domain(.*)::port?/fr/:path(.*)?"],
|
|
108
|
+
["en", ":protocol://:domain(.*)::port?/:path(.*)?"],
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
]);
|
|
112
|
+
// expecting the baseLocale to not be included in the url
|
|
113
|
+
expect(runtime.localizeHref("/about", { locale: "en" })).toBe("/about");
|
|
114
|
+
expect(runtime.localizeHref("/about", { locale: "de" })).toBe("/de/about");
|
|
115
|
+
// expecting root path to work
|
|
116
|
+
expect(runtime.localizeHref("/", { locale: "en" })).toBe("/");
|
|
117
|
+
expect(runtime.localizeHref("/", { locale: "de" })).toBe("/de/");
|
|
118
|
+
// expecting de-localization to work
|
|
119
|
+
expect(runtime.deLocalizeHref("/de/")).toBe("/");
|
|
120
|
+
expect(runtime.deLocalizeHref("/de/about")).toBe("/about");
|
|
121
|
+
expect(runtime.deLocalizeHref("/about")).toBe("/about");
|
|
122
|
+
// expecting localhost to work (for development)
|
|
123
|
+
expect(runtime.localizeHref("http://localhost:5173/", { locale: "de" })).toBe("http://localhost:5173/de/");
|
|
124
|
+
// de-localizing localhost
|
|
125
|
+
expect(runtime.deLocalizeHref("http://localhost:5173/de")).toBe("http://localhost:5173/");
|
|
126
|
+
// pathnames
|
|
127
|
+
expect(runtime.localizeHref("http://localhost:5173/about", { locale: "de" })).toBe("http://localhost:5173/de/about");
|
|
128
|
+
expect(runtime.deLocalizeHref("http://localhost:5173/de/about")).toBe("http://localhost:5173/about");
|
|
129
|
+
});
|
|
130
|
+
test("normalizes mixed-case explicit locales in localizeHref", async () => {
|
|
131
|
+
const runtime = await createParaglide({
|
|
132
|
+
baseLocale: "en",
|
|
133
|
+
locales: ["en", "de"],
|
|
134
|
+
strategy: ["url"],
|
|
135
|
+
});
|
|
136
|
+
expect(runtime.localizeHref("/about", { locale: "DE" })).toBe("/de/about");
|
|
137
|
+
expect(runtime.localizeHref("/de/about", { locale: "EN" })).toBe("/about");
|
|
138
|
+
});
|
|
139
|
+
//# sourceMappingURL=localize-href.test.js.map
|