@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,100 @@
|
|
|
1
|
+
export type ShouldRedirectServerInput = {
|
|
2
|
+
request: Request;
|
|
3
|
+
/**
|
|
4
|
+
* - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.
|
|
5
|
+
*/
|
|
6
|
+
effectiveRequestUrl?: string | URL;
|
|
7
|
+
locale?: Locale;
|
|
8
|
+
};
|
|
9
|
+
export type ShouldRedirectClientInput = {
|
|
10
|
+
request?: undefined;
|
|
11
|
+
url?: string | URL;
|
|
12
|
+
locale?: Locale;
|
|
13
|
+
};
|
|
14
|
+
export type ShouldRedirectInput = ShouldRedirectServerInput | ShouldRedirectClientInput;
|
|
15
|
+
export type ShouldRedirectResult = {
|
|
16
|
+
/**
|
|
17
|
+
* - Indicates whether the consumer should perform a redirect.
|
|
18
|
+
*/
|
|
19
|
+
shouldRedirect: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* - Locale resolved using the configured strategies.
|
|
22
|
+
*/
|
|
23
|
+
locale: Locale;
|
|
24
|
+
/**
|
|
25
|
+
* - Destination URL when a redirect is required.
|
|
26
|
+
*/
|
|
27
|
+
redirectUrl: URL | undefined;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {object} ShouldRedirectServerInput
|
|
31
|
+
* @property {Request} request
|
|
32
|
+
* @property {string | URL} [effectiveRequestUrl] - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.
|
|
33
|
+
* @property {Locale} [locale]
|
|
34
|
+
*
|
|
35
|
+
* @typedef {object} ShouldRedirectClientInput
|
|
36
|
+
* @property {undefined} [request]
|
|
37
|
+
* @property {string | URL} [url]
|
|
38
|
+
* @property {Locale} [locale]
|
|
39
|
+
*
|
|
40
|
+
* @typedef {ShouldRedirectServerInput | ShouldRedirectClientInput} ShouldRedirectInput
|
|
41
|
+
*
|
|
42
|
+
* @typedef {object} ShouldRedirectResult
|
|
43
|
+
* @property {boolean} shouldRedirect - Indicates whether the consumer should perform a redirect.
|
|
44
|
+
* @property {Locale} locale - Locale resolved using the configured strategies.
|
|
45
|
+
* @property {URL | undefined} redirectUrl - Destination URL when a redirect is required.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Determines whether a redirect is required to align the current URL with the active locale.
|
|
49
|
+
*
|
|
50
|
+
* This helper mirrors the logic that powers `paraglideMiddleware`, but works in both server
|
|
51
|
+
* and client environments. It evaluates the configured strategies in order, computes the
|
|
52
|
+
* canonical localized URL, and reports when the current URL does not match.
|
|
53
|
+
*
|
|
54
|
+
* When called in the browser without arguments, the current `window.location.href` is used.
|
|
55
|
+
*
|
|
56
|
+
* @see https://paraglidejs.com/i18n-routing#redirects
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Client side usage (e.g. TanStack Router beforeLoad hook)
|
|
60
|
+
* async function beforeLoad({ location }) {
|
|
61
|
+
* const decision = await shouldRedirect({ url: location.href });
|
|
62
|
+
*
|
|
63
|
+
* if (decision.shouldRedirect) {
|
|
64
|
+
* throw redirect({ to: decision.redirectUrl.href });
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Server side usage with a Request
|
|
70
|
+
* export async function handle(request) {
|
|
71
|
+
* const decision = await shouldRedirect({ request });
|
|
72
|
+
*
|
|
73
|
+
* if (decision.shouldRedirect) {
|
|
74
|
+
* return Response.redirect(decision.redirectUrl, 307);
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* return render(request, decision.locale);
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* // Server side usage behind a proxy where request.url is not public-facing
|
|
82
|
+
* export async function handle(request) {
|
|
83
|
+
* const effectiveRequestUrl = new URL(request.url);
|
|
84
|
+
* effectiveRequestUrl.protocol = "https:";
|
|
85
|
+
* effectiveRequestUrl.host = "example.com";
|
|
86
|
+
*
|
|
87
|
+
* const decision = await shouldRedirect({
|
|
88
|
+
* request,
|
|
89
|
+
* effectiveRequestUrl,
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* if (decision.shouldRedirect) {
|
|
93
|
+
* return Response.redirect(decision.redirectUrl, 307);
|
|
94
|
+
* }
|
|
95
|
+
* }
|
|
96
|
+
*
|
|
97
|
+
* @param {ShouldRedirectInput} [input]
|
|
98
|
+
* @returns {Promise<ShouldRedirectResult>}
|
|
99
|
+
*/
|
|
100
|
+
export declare function shouldRedirect(input?: ShouldRedirectInput): Promise<ShouldRedirectResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-redirect.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/should-redirect.js"],"names":[],"mappings":"AAWG,YAAkB,yBAAyB,GAC3C;IAAoB,OAAO,EAAhB,OAAO,CAClB;;;;IAA0B,mBAAmB,AAA7C,CACA,EADW,MAAM,GAAG,GAAG,CACvB;IAAoB,MAAM,AAA1B,CAEA,EAFW,MAAM,CAEjB;CAAA,CAAA;AAAA,YAAkB,yBAAyB,GAC3C;IAAuB,OAAO,AAA9B,CACA,EADW,SAAS,CACpB;IAA0B,GAAG,AAA7B,CACA,EADW,MAAM,GAAG,GAAG,CACvB;IAAoB,MAAM,AAA1B,CAEA,EAFW,MAAM,CAEjB;CAAA,CAAA;AAAA,YAAiE,mBAAmB,GAA1E,yBAAyB,GAAG,yBAAyB,CAAqB;AAEpF,YAAkB,oBAAoB,GACtC;;;;IAAoB,cAAc,EAAvB,OAAO,CAClB;;;;IAAmB,MAAM,EAAd,MAAM,CACjB;;;;IAA4B,WAAW,EAA5B,GAAG,GAAG,SAAS,CAC5B;CAAA,CAAA;AAjBD;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAsB,cAAc,CAAC,KAAK,AAHvC,CACA,EADQ,mBAGoC,GAFlC,OAAO,CAAC,oBAAoB,CAAC,CAqBzC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { localizeUrl } from "./localize-url.js";
|
|
2
|
+
import { toLocale } from "./check-locale.js";
|
|
3
|
+
import { getLocale, getLocaleForUrl } from "./get-locale.js";
|
|
4
|
+
import { getUrlOrigin } from "./get-url-origin.js";
|
|
5
|
+
import { extractLocaleFromRequestAsync } from "./extract-locale-from-request-async.js";
|
|
6
|
+
import { getStrategyForUrl, isExcludedByRouteStrategy, } from "./route-strategy.js";
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {object} ShouldRedirectServerInput
|
|
9
|
+
* @property {Request} request
|
|
10
|
+
* @property {string | URL} [effectiveRequestUrl] - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.
|
|
11
|
+
* @property {Locale} [locale]
|
|
12
|
+
*
|
|
13
|
+
* @typedef {object} ShouldRedirectClientInput
|
|
14
|
+
* @property {undefined} [request]
|
|
15
|
+
* @property {string | URL} [url]
|
|
16
|
+
* @property {Locale} [locale]
|
|
17
|
+
*
|
|
18
|
+
* @typedef {ShouldRedirectServerInput | ShouldRedirectClientInput} ShouldRedirectInput
|
|
19
|
+
*
|
|
20
|
+
* @typedef {object} ShouldRedirectResult
|
|
21
|
+
* @property {boolean} shouldRedirect - Indicates whether the consumer should perform a redirect.
|
|
22
|
+
* @property {Locale} locale - Locale resolved using the configured strategies.
|
|
23
|
+
* @property {URL | undefined} redirectUrl - Destination URL when a redirect is required.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Determines whether a redirect is required to align the current URL with the active locale.
|
|
27
|
+
*
|
|
28
|
+
* This helper mirrors the logic that powers `paraglideMiddleware`, but works in both server
|
|
29
|
+
* and client environments. It evaluates the configured strategies in order, computes the
|
|
30
|
+
* canonical localized URL, and reports when the current URL does not match.
|
|
31
|
+
*
|
|
32
|
+
* When called in the browser without arguments, the current `window.location.href` is used.
|
|
33
|
+
*
|
|
34
|
+
* @see https://paraglidejs.com/i18n-routing#redirects
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Client side usage (e.g. TanStack Router beforeLoad hook)
|
|
38
|
+
* async function beforeLoad({ location }) {
|
|
39
|
+
* const decision = await shouldRedirect({ url: location.href });
|
|
40
|
+
*
|
|
41
|
+
* if (decision.shouldRedirect) {
|
|
42
|
+
* throw redirect({ to: decision.redirectUrl.href });
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Server side usage with a Request
|
|
48
|
+
* export async function handle(request) {
|
|
49
|
+
* const decision = await shouldRedirect({ request });
|
|
50
|
+
*
|
|
51
|
+
* if (decision.shouldRedirect) {
|
|
52
|
+
* return Response.redirect(decision.redirectUrl, 307);
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* return render(request, decision.locale);
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Server side usage behind a proxy where request.url is not public-facing
|
|
60
|
+
* export async function handle(request) {
|
|
61
|
+
* const effectiveRequestUrl = new URL(request.url);
|
|
62
|
+
* effectiveRequestUrl.protocol = "https:";
|
|
63
|
+
* effectiveRequestUrl.host = "example.com";
|
|
64
|
+
*
|
|
65
|
+
* const decision = await shouldRedirect({
|
|
66
|
+
* request,
|
|
67
|
+
* effectiveRequestUrl,
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* if (decision.shouldRedirect) {
|
|
71
|
+
* return Response.redirect(decision.redirectUrl, 307);
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* @param {ShouldRedirectInput} [input]
|
|
76
|
+
* @returns {Promise<ShouldRedirectResult>}
|
|
77
|
+
*/
|
|
78
|
+
export async function shouldRedirect(input = {}) {
|
|
79
|
+
const currentUrl = resolveUrl(input);
|
|
80
|
+
const locale = await resolveLocale(input, currentUrl);
|
|
81
|
+
const strategy = getStrategyForUrl(currentUrl.href);
|
|
82
|
+
if (isExcludedByRouteStrategy(currentUrl.href) || !strategy.includes("url")) {
|
|
83
|
+
return { shouldRedirect: false, locale, redirectUrl: undefined };
|
|
84
|
+
}
|
|
85
|
+
const localizedUrl = localizeUrl(currentUrl.href, { locale });
|
|
86
|
+
const shouldRedirectToLocalizedUrl = normalizeUrl(localizedUrl.href) !== normalizeUrl(currentUrl.href);
|
|
87
|
+
return {
|
|
88
|
+
shouldRedirect: shouldRedirectToLocalizedUrl,
|
|
89
|
+
locale,
|
|
90
|
+
redirectUrl: shouldRedirectToLocalizedUrl ? localizedUrl : undefined,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Resolves the locale either from the provided input or by using the configured strategies.
|
|
95
|
+
*
|
|
96
|
+
* @param {ShouldRedirectInput} input
|
|
97
|
+
* @param {URL} currentUrl
|
|
98
|
+
* @returns {Promise<Locale>}
|
|
99
|
+
*/
|
|
100
|
+
async function resolveLocale(input, currentUrl) {
|
|
101
|
+
const locale = toLocale(input.locale);
|
|
102
|
+
if (locale) {
|
|
103
|
+
return locale;
|
|
104
|
+
}
|
|
105
|
+
if (input.request) {
|
|
106
|
+
return extractLocaleFromRequestAsync(input.request, {
|
|
107
|
+
effectiveRequestUrl: currentUrl,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if ("url" in input && typeof input.url !== "undefined") {
|
|
111
|
+
return getLocaleForUrl(currentUrl.href);
|
|
112
|
+
}
|
|
113
|
+
return getLocale();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Resolves the current URL from the provided input or runtime context.
|
|
117
|
+
*
|
|
118
|
+
* @param {ShouldRedirectInput} input
|
|
119
|
+
* @returns {URL}
|
|
120
|
+
*/
|
|
121
|
+
function resolveUrl(input) {
|
|
122
|
+
if ("effectiveRequestUrl" in input &&
|
|
123
|
+
input.effectiveRequestUrl instanceof URL) {
|
|
124
|
+
return new URL(input.effectiveRequestUrl.href);
|
|
125
|
+
}
|
|
126
|
+
if ("effectiveRequestUrl" in input &&
|
|
127
|
+
typeof input.effectiveRequestUrl === "string") {
|
|
128
|
+
return new URL(input.effectiveRequestUrl, input.request ? input.request.url : getUrlOrigin());
|
|
129
|
+
}
|
|
130
|
+
if (input.request) {
|
|
131
|
+
return new URL(input.request.url);
|
|
132
|
+
}
|
|
133
|
+
if ("url" in input && input.url instanceof URL) {
|
|
134
|
+
return new URL(input.url.href);
|
|
135
|
+
}
|
|
136
|
+
if ("url" in input && typeof input.url === "string") {
|
|
137
|
+
return new URL(input.url, getUrlOrigin());
|
|
138
|
+
}
|
|
139
|
+
if (typeof window !== "undefined" && window?.location?.href) {
|
|
140
|
+
return new URL(window.location.href);
|
|
141
|
+
}
|
|
142
|
+
throw new Error("shouldRedirect() requires either a request, an absolute URL, or must run in a browser environment.");
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Normalize url for comparison by stripping the trailing slash.
|
|
146
|
+
*
|
|
147
|
+
* @param {string} url
|
|
148
|
+
* @returns {string}
|
|
149
|
+
*/
|
|
150
|
+
function normalizeUrl(url) {
|
|
151
|
+
const urlObj = new URL(url);
|
|
152
|
+
urlObj.pathname = urlObj.pathname.replace(/\/$/, "");
|
|
153
|
+
return urlObj.href;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=should-redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-redirect.js","sourceRoot":"","sources":["../../../src/compiler/runtime/should-redirect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,GAAG,YAAY,GAAG,EAAE,CAAC;QAChD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;QACrD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC7D,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,IAAI,KAAK,CACd,oGAAoG,CACpG,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,GAAG;IACxB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,IAAI,CAAC;AACpB,CAAC","sourcesContent":["import { localizeUrl } from \"./localize-url.js\";\nimport { toLocale } from \"./check-locale.js\";\nimport { getLocale, getLocaleForUrl } from \"./get-locale.js\";\nimport { getUrlOrigin } from \"./get-url-origin.js\";\nimport { extractLocaleFromRequestAsync } from \"./extract-locale-from-request-async.js\";\nimport {\n\tgetStrategyForUrl,\n\tisExcludedByRouteStrategy,\n} from \"./route-strategy.js\";\n\n/**\n * @typedef {object} ShouldRedirectServerInput\n * @property {Request} request\n * @property {string | URL} [effectiveRequestUrl] - Effective request URL to use for route matching, locale detection with the URL strategy, and redirect targets.\n * @property {Locale} [locale]\n *\n * @typedef {object} ShouldRedirectClientInput\n * @property {undefined} [request]\n * @property {string | URL} [url]\n * @property {Locale} [locale]\n *\n * @typedef {ShouldRedirectServerInput | ShouldRedirectClientInput} ShouldRedirectInput\n *\n * @typedef {object} ShouldRedirectResult\n * @property {boolean} shouldRedirect - Indicates whether the consumer should perform a redirect.\n * @property {Locale} locale - Locale resolved using the configured strategies.\n * @property {URL | undefined} redirectUrl - Destination URL when a redirect is required.\n */\n\n/**\n * Determines whether a redirect is required to align the current URL with the active locale.\n *\n * This helper mirrors the logic that powers `paraglideMiddleware`, but works in both server\n * and client environments. It evaluates the configured strategies in order, computes the\n * canonical localized URL, and reports when the current URL does not match.\n *\n * When called in the browser without arguments, the current `window.location.href` is used.\n *\n * @see https://paraglidejs.com/i18n-routing#redirects\n *\n * @example\n * // Client side usage (e.g. TanStack Router beforeLoad hook)\n * async function beforeLoad({ location }) {\n * const decision = await shouldRedirect({ url: location.href });\n *\n * if (decision.shouldRedirect) {\n * throw redirect({ to: decision.redirectUrl.href });\n * }\n * }\n *\n * @example\n * // Server side usage with a Request\n * export async function handle(request) {\n * const decision = await shouldRedirect({ request });\n *\n * if (decision.shouldRedirect) {\n * return Response.redirect(decision.redirectUrl, 307);\n * }\n *\n * return render(request, decision.locale);\n * }\n *\n * @example\n * // Server side usage behind a proxy where request.url is not public-facing\n * export async function handle(request) {\n * const effectiveRequestUrl = new URL(request.url);\n * effectiveRequestUrl.protocol = \"https:\";\n * effectiveRequestUrl.host = \"example.com\";\n *\n * const decision = await shouldRedirect({\n * request,\n * effectiveRequestUrl,\n * });\n *\n * if (decision.shouldRedirect) {\n * return Response.redirect(decision.redirectUrl, 307);\n * }\n * }\n *\n * @param {ShouldRedirectInput} [input]\n * @returns {Promise<ShouldRedirectResult>}\n */\nexport async function shouldRedirect(input = {}) {\n\tconst currentUrl = resolveUrl(input);\n\tconst locale = await resolveLocale(input, currentUrl);\n\tconst strategy = getStrategyForUrl(currentUrl.href);\n\n\tif (isExcludedByRouteStrategy(currentUrl.href) || !strategy.includes(\"url\")) {\n\t\treturn { shouldRedirect: false, locale, redirectUrl: undefined };\n\t}\n\n\tconst localizedUrl = localizeUrl(currentUrl.href, { locale });\n\n\tconst shouldRedirectToLocalizedUrl =\n\t\tnormalizeUrl(localizedUrl.href) !== normalizeUrl(currentUrl.href);\n\n\treturn {\n\t\tshouldRedirect: shouldRedirectToLocalizedUrl,\n\t\tlocale,\n\t\tredirectUrl: shouldRedirectToLocalizedUrl ? localizedUrl : undefined,\n\t};\n}\n\n/**\n * Resolves the locale either from the provided input or by using the configured strategies.\n *\n * @param {ShouldRedirectInput} input\n * @param {URL} currentUrl\n * @returns {Promise<Locale>}\n */\nasync function resolveLocale(input, currentUrl) {\n\tconst locale = toLocale(input.locale);\n\tif (locale) {\n\t\treturn locale;\n\t}\n\n\tif (input.request) {\n\t\treturn extractLocaleFromRequestAsync(input.request, {\n\t\t\teffectiveRequestUrl: currentUrl,\n\t\t});\n\t}\n\n\tif (\"url\" in input && typeof input.url !== \"undefined\") {\n\t\treturn getLocaleForUrl(currentUrl.href);\n\t}\n\n\treturn getLocale();\n}\n\n/**\n * Resolves the current URL from the provided input or runtime context.\n *\n * @param {ShouldRedirectInput} input\n * @returns {URL}\n */\nfunction resolveUrl(input) {\n\tif (\n\t\t\"effectiveRequestUrl\" in input &&\n\t\tinput.effectiveRequestUrl instanceof URL\n\t) {\n\t\treturn new URL(input.effectiveRequestUrl.href);\n\t}\n\n\tif (\n\t\t\"effectiveRequestUrl\" in input &&\n\t\ttypeof input.effectiveRequestUrl === \"string\"\n\t) {\n\t\treturn new URL(\n\t\t\tinput.effectiveRequestUrl,\n\t\t\tinput.request ? input.request.url : getUrlOrigin()\n\t\t);\n\t}\n\n\tif (input.request) {\n\t\treturn new URL(input.request.url);\n\t}\n\n\tif (\"url\" in input && input.url instanceof URL) {\n\t\treturn new URL(input.url.href);\n\t}\n\n\tif (\"url\" in input && typeof input.url === \"string\") {\n\t\treturn new URL(input.url, getUrlOrigin());\n\t}\n\n\tif (typeof window !== \"undefined\" && window?.location?.href) {\n\t\treturn new URL(window.location.href);\n\t}\n\n\tthrow new Error(\n\t\t\"shouldRedirect() requires either a request, an absolute URL, or must run in a browser environment.\"\n\t);\n}\n\n/**\n * Normalize url for comparison by stripping the trailing slash.\n *\n * @param {string} url\n * @returns {string}\n */\nfunction normalizeUrl(url) {\n\tconst urlObj = new URL(url);\n\turlObj.pathname = urlObj.pathname.replace(/\\/$/, \"\");\n\treturn urlObj.href;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-redirect.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/should-redirect.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { createParaglide } from "../create-paraglide.js";
|
|
3
|
+
test("shouldRedirect redirects to the strategy-preferred locale on the server", async () => {
|
|
4
|
+
const runtime = await createParaglide({
|
|
5
|
+
baseLocale: "en",
|
|
6
|
+
locales: ["en", "fr"],
|
|
7
|
+
strategy: ["cookie", "url"],
|
|
8
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
9
|
+
urlPatterns: [
|
|
10
|
+
{
|
|
11
|
+
pattern: "https://example.com/:path(.*)?",
|
|
12
|
+
localized: [
|
|
13
|
+
["en", "https://example.com/en/:path(.*)?"],
|
|
14
|
+
["fr", "https://example.com/fr/:path(.*)?"],
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
const request = new Request("https://example.com/en/dashboard", {
|
|
20
|
+
headers: {
|
|
21
|
+
cookie: "PARAGLIDE_LOCALE=fr",
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const decision = await runtime.shouldRedirect({ request });
|
|
25
|
+
expect(decision.shouldRedirect).toBe(true);
|
|
26
|
+
expect(decision.redirectUrl?.href).toBe("https://example.com/fr/dashboard");
|
|
27
|
+
expect(decision.locale).toBe("fr");
|
|
28
|
+
});
|
|
29
|
+
test("shouldRedirect uses the provided public url when the transport request url differs", async () => {
|
|
30
|
+
const runtime = await createParaglide({
|
|
31
|
+
baseLocale: "en",
|
|
32
|
+
locales: ["en", "fr"],
|
|
33
|
+
strategy: ["cookie", "url"],
|
|
34
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
35
|
+
urlPatterns: [
|
|
36
|
+
{
|
|
37
|
+
pattern: "https://example.com/:path(.*)?",
|
|
38
|
+
localized: [
|
|
39
|
+
["en", "https://example.com/en/:path(.*)?"],
|
|
40
|
+
["fr", "https://example.com/fr/:path(.*)?"],
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
const request = new Request("http://internal.example.com/en/dashboard", {
|
|
46
|
+
headers: {
|
|
47
|
+
cookie: "PARAGLIDE_LOCALE=fr",
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const decision = await runtime.shouldRedirect({
|
|
51
|
+
request,
|
|
52
|
+
effectiveRequestUrl: "https://example.com/en/dashboard",
|
|
53
|
+
});
|
|
54
|
+
expect(decision.shouldRedirect).toBe(true);
|
|
55
|
+
expect(decision.redirectUrl?.href).toBe("https://example.com/fr/dashboard");
|
|
56
|
+
expect(decision.locale).toBe("fr");
|
|
57
|
+
});
|
|
58
|
+
test("shouldRedirect resolves relative effectiveRequestUrl strings against request.url", async () => {
|
|
59
|
+
const runtime = await createParaglide({
|
|
60
|
+
baseLocale: "en",
|
|
61
|
+
locales: ["en", "fr"],
|
|
62
|
+
strategy: ["cookie", "url"],
|
|
63
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
64
|
+
urlPatterns: [
|
|
65
|
+
{
|
|
66
|
+
pattern: "https://example.com/:path(.*)?",
|
|
67
|
+
localized: [
|
|
68
|
+
["en", "https://example.com/en/:path(.*)?"],
|
|
69
|
+
["fr", "https://example.com/fr/:path(.*)?"],
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
const request = new Request("https://example.com/en/dashboard", {
|
|
75
|
+
headers: {
|
|
76
|
+
cookie: "PARAGLIDE_LOCALE=fr",
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
const decision = await runtime.shouldRedirect({
|
|
80
|
+
request,
|
|
81
|
+
effectiveRequestUrl: "/en/dashboard",
|
|
82
|
+
});
|
|
83
|
+
expect(decision.shouldRedirect).toBe(true);
|
|
84
|
+
expect(decision.redirectUrl?.href).toBe("https://example.com/fr/dashboard");
|
|
85
|
+
expect(decision.locale).toBe("fr");
|
|
86
|
+
});
|
|
87
|
+
test("shouldRedirect keeps request precedence over url on the server", async () => {
|
|
88
|
+
const runtime = await createParaglide({
|
|
89
|
+
baseLocale: "en",
|
|
90
|
+
locales: ["en", "fr"],
|
|
91
|
+
strategy: ["cookie", "url"],
|
|
92
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
93
|
+
urlPatterns: [
|
|
94
|
+
{
|
|
95
|
+
pattern: "https://example.com/:path(.*)?",
|
|
96
|
+
localized: [
|
|
97
|
+
["en", "https://example.com/en/:path(.*)?"],
|
|
98
|
+
["fr", "https://example.com/fr/:path(.*)?"],
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
});
|
|
103
|
+
const request = new Request("https://example.com/en/dashboard", {
|
|
104
|
+
headers: {
|
|
105
|
+
cookie: "PARAGLIDE_LOCALE=fr",
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
const decision = await runtime.shouldRedirect({
|
|
109
|
+
request,
|
|
110
|
+
url: "/dashboard",
|
|
111
|
+
});
|
|
112
|
+
expect(decision.shouldRedirect).toBe(true);
|
|
113
|
+
expect(decision.redirectUrl?.href).toBe("https://example.com/fr/dashboard");
|
|
114
|
+
expect(decision.locale).toBe("fr");
|
|
115
|
+
});
|
|
116
|
+
test("shouldRedirect does nothing when the URL already matches", async () => {
|
|
117
|
+
const runtime = await createParaglide({
|
|
118
|
+
baseLocale: "en",
|
|
119
|
+
locales: ["en", "fr"],
|
|
120
|
+
strategy: ["cookie", "url"],
|
|
121
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
122
|
+
urlPatterns: [
|
|
123
|
+
{
|
|
124
|
+
pattern: "https://example.com/:path(.*)?",
|
|
125
|
+
localized: [
|
|
126
|
+
["en", "https://example.com/en/:path(.*)?"],
|
|
127
|
+
["fr", "https://example.com/fr/:path(.*)?"],
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
const request = new Request("https://example.com/fr/dashboard", {
|
|
133
|
+
headers: {
|
|
134
|
+
cookie: "PARAGLIDE_LOCALE=fr",
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const decision = await runtime.shouldRedirect({ request });
|
|
138
|
+
expect(decision.shouldRedirect).toBe(false);
|
|
139
|
+
expect(decision.redirectUrl).toBeUndefined();
|
|
140
|
+
expect(decision.locale).toBe("fr");
|
|
141
|
+
});
|
|
142
|
+
test("shouldRedirect falls back to the browser URL when no input is provided", async () => {
|
|
143
|
+
const runtime = await createParaglide({
|
|
144
|
+
baseLocale: "en",
|
|
145
|
+
locales: ["en", "de"],
|
|
146
|
+
strategy: ["url", "globalVariable"],
|
|
147
|
+
isServer: "false",
|
|
148
|
+
urlPatterns: undefined,
|
|
149
|
+
});
|
|
150
|
+
const originalWindow = globalThis.window;
|
|
151
|
+
try {
|
|
152
|
+
globalThis.window = {
|
|
153
|
+
location: {
|
|
154
|
+
href: "https://example.com/en/profile",
|
|
155
|
+
origin: "https://example.com",
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
runtime.overwriteGetLocale(() => "de");
|
|
159
|
+
const decision = await runtime.shouldRedirect();
|
|
160
|
+
expect(decision.shouldRedirect).toBe(true);
|
|
161
|
+
expect(decision.redirectUrl?.href).toBe("https://example.com/de/profile");
|
|
162
|
+
expect(decision.locale).toBe("de");
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
if (originalWindow === undefined) {
|
|
166
|
+
Reflect.deleteProperty(globalThis, "window");
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
globalThis.window = originalWindow;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
test("shouldRedirect({ url }) resolves locale using target URL routeStrategies on client", async () => {
|
|
174
|
+
const runtime = await createParaglide({
|
|
175
|
+
baseLocale: "en",
|
|
176
|
+
locales: ["en", "fr"],
|
|
177
|
+
strategy: ["url", "cookie", "baseLocale"],
|
|
178
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
179
|
+
isServer: "false",
|
|
180
|
+
urlPatterns: [
|
|
181
|
+
{
|
|
182
|
+
pattern: "https://example.com/:path(.*)?",
|
|
183
|
+
localized: [
|
|
184
|
+
["en", "https://example.com/en/:path(.*)?"],
|
|
185
|
+
["fr", "https://example.com/fr/:path(.*)?"],
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
routeStrategies: [
|
|
190
|
+
{
|
|
191
|
+
match: "/dashboard/:path(.*)?",
|
|
192
|
+
strategy: ["cookie", "baseLocale"],
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
});
|
|
196
|
+
const originalWindow = globalThis.window;
|
|
197
|
+
const originalDocument = globalThis.document;
|
|
198
|
+
try {
|
|
199
|
+
globalThis.window = {
|
|
200
|
+
location: {
|
|
201
|
+
href: "https://example.com/dashboard",
|
|
202
|
+
origin: "https://example.com",
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
globalThis.document = {
|
|
206
|
+
cookie: "PARAGLIDE_LOCALE=fr",
|
|
207
|
+
};
|
|
208
|
+
const decision = await runtime.shouldRedirect({
|
|
209
|
+
url: "https://example.com/en/profile",
|
|
210
|
+
});
|
|
211
|
+
expect(decision.shouldRedirect).toBe(false);
|
|
212
|
+
expect(decision.redirectUrl).toBeUndefined();
|
|
213
|
+
expect(decision.locale).toBe("en");
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
if (originalWindow === undefined) {
|
|
217
|
+
Reflect.deleteProperty(globalThis, "window");
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
globalThis.window = originalWindow;
|
|
221
|
+
}
|
|
222
|
+
if (originalDocument === undefined) {
|
|
223
|
+
Reflect.deleteProperty(globalThis, "document");
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
globalThis.document = originalDocument;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
test("shouldRedirect never suggests a redirect without the url strategy", async () => {
|
|
231
|
+
const runtime = await createParaglide({
|
|
232
|
+
baseLocale: "en",
|
|
233
|
+
locales: ["en", "fr"],
|
|
234
|
+
strategy: ["cookie"],
|
|
235
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
236
|
+
});
|
|
237
|
+
const request = new Request("https://example.com/en/dashboard", {
|
|
238
|
+
headers: {
|
|
239
|
+
cookie: "PARAGLIDE_LOCALE=fr",
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
const decision = await runtime.shouldRedirect({ request });
|
|
243
|
+
expect(decision.shouldRedirect).toBe(false);
|
|
244
|
+
expect(decision.redirectUrl).toBeUndefined();
|
|
245
|
+
expect(decision.locale).toBe("fr");
|
|
246
|
+
});
|
|
247
|
+
test("shouldRedirect respects routeStrategies that disable url strategy per route", async () => {
|
|
248
|
+
const runtime = await createParaglide({
|
|
249
|
+
baseLocale: "en",
|
|
250
|
+
locales: ["en", "fr"],
|
|
251
|
+
strategy: ["url", "cookie", "baseLocale"],
|
|
252
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
253
|
+
routeStrategies: [
|
|
254
|
+
{
|
|
255
|
+
match: "/dashboard/:path(.*)?",
|
|
256
|
+
strategy: ["cookie", "baseLocale"],
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
});
|
|
260
|
+
const request = new Request("https://example.com/dashboard", {
|
|
261
|
+
headers: {
|
|
262
|
+
cookie: "PARAGLIDE_LOCALE=fr",
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
const decision = await runtime.shouldRedirect({ request });
|
|
266
|
+
expect(decision.shouldRedirect).toBe(false);
|
|
267
|
+
expect(decision.redirectUrl).toBeUndefined();
|
|
268
|
+
expect(decision.locale).toBe("fr");
|
|
269
|
+
});
|
|
270
|
+
//# sourceMappingURL=should-redirect.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-redirect.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/should-redirect.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,IAAI,CAAC,yEAAyE,EAAE,KAAK,IAAI,EAAE;IAC1F,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QACrB,QAAQ,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC;QAC3B,UAAU,EAAE,kBAAkB;QAC9B,WAAW,EAAE;YACZ;gBACC,OAAO,EAAE,gCAAgC;gBACzC,SAAS,EAAE;oBACV,CAAC,IAAI,EAAE,mCAAmC,CAAC;oBAC3C,CAAC,IAAI,EAAE,mCAAmC,CAAC;iBAC3C;aACD;SACD;KACD,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,kCAAkC,EAAE;QAC/D,OAAO,EAAE;YACR,MAAM,EAAE,qBAAqB;SAC7B;KACD,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE3D,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,M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AE,KAAK,IAAI,EAAE;IAC9F,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC;QACzC,UAAU,EAAE,kBAAkB;QAC9B,eAAe,EAAE;YAChB;gBACC,KAAK,EAAE,uBAAuB;gBAC9B,QAAQ,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC;aAClC;SACD;KACD,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,+BAA+B,EAAE;QAC5D,OAAO,EAAE;YACR,MAAM,EAAE,qBAAqB;SAC7B;KACD,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE3D,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,aAAa,EAAE,CAAC;IAC7C,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\n\ntest(\"shouldRedirect redirects to the strategy-preferred locale on the server\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"cookie\", \"url\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path(.*)?\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst request = new Request(\"https://example.com/en/dashboard\", {\n\t\theaders: {\n\t\t\tcookie: \"PARAGLIDE_LOCALE=fr\",\n\t\t},\n\t});\n\n\tconst decision = await runtime.shouldRedirect({ request });\n\n\texpect(decision.shouldRedirect).toBe(true);\n\texpect(decision.redirectUrl?.href).toBe(\"https://example.com/fr/dashboard\");\n\texpect(decision.locale).toBe(\"fr\");\n});\n\ntest(\"shouldRedirect uses the provided public url when the transport request url differs\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"cookie\", \"url\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path(.*)?\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst request = new Request(\"http://internal.example.com/en/dashboard\", {\n\t\theaders: {\n\t\t\tcookie: \"PARAGLIDE_LOCALE=fr\",\n\t\t},\n\t});\n\n\tconst decision = await runtime.shouldRedirect({\n\t\trequest,\n\t\teffectiveRequestUrl: \"https://example.com/en/dashboard\",\n\t});\n\n\texpect(decision.shouldRedirect).toBe(true);\n\texpect(decision.redirectUrl?.href).toBe(\"https://example.com/fr/dashboard\");\n\texpect(decision.locale).toBe(\"fr\");\n});\n\ntest(\"shouldRedirect resolves relative effectiveRequestUrl strings against request.url\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"cookie\", \"url\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path(.*)?\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst request = new Request(\"https://example.com/en/dashboard\", {\n\t\theaders: {\n\t\t\tcookie: \"PARAGLIDE_LOCALE=fr\",\n\t\t},\n\t});\n\n\tconst decision = await runtime.shouldRedirect({\n\t\trequest,\n\t\teffectiveRequestUrl: \"/en/dashboard\",\n\t});\n\n\texpect(decision.shouldRedirect).toBe(true);\n\texpect(decision.redirectUrl?.href).toBe(\"https://example.com/fr/dashboard\");\n\texpect(decision.locale).toBe(\"fr\");\n});\n\ntest(\"shouldRedirect keeps request precedence over url on the server\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"cookie\", \"url\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path(.*)?\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst request = new Request(\"https://example.com/en/dashboard\", {\n\t\theaders: {\n\t\t\tcookie: \"PARAGLIDE_LOCALE=fr\",\n\t\t},\n\t});\n\n\tconst decision = await runtime.shouldRedirect({\n\t\trequest,\n\t\turl: \"/dashboard\",\n\t} as any);\n\n\texpect(decision.shouldRedirect).toBe(true);\n\texpect(decision.redirectUrl?.href).toBe(\"https://example.com/fr/dashboard\");\n\texpect(decision.locale).toBe(\"fr\");\n});\n\ntest(\"shouldRedirect does nothing when the URL already matches\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"cookie\", \"url\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path(.*)?\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst request = new Request(\"https://example.com/fr/dashboard\", {\n\t\theaders: {\n\t\t\tcookie: \"PARAGLIDE_LOCALE=fr\",\n\t\t},\n\t});\n\n\tconst decision = await runtime.shouldRedirect({ request });\n\n\texpect(decision.shouldRedirect).toBe(false);\n\texpect(decision.redirectUrl).toBeUndefined();\n\texpect(decision.locale).toBe(\"fr\");\n});\n\ntest(\"shouldRedirect falls back to the browser URL when no input is provided\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"url\", \"globalVariable\"],\n\t\tisServer: \"false\",\n\t\turlPatterns: undefined,\n\t});\n\n\tconst originalWindow = globalThis.window;\n\ttry {\n\t\tglobalThis.window = {\n\t\t\tlocation: {\n\t\t\t\thref: \"https://example.com/en/profile\",\n\t\t\t\torigin: \"https://example.com\",\n\t\t\t},\n\t\t} as any;\n\n\t\truntime.overwriteGetLocale(() => \"de\");\n\n\t\tconst decision = await runtime.shouldRedirect();\n\n\t\texpect(decision.shouldRedirect).toBe(true);\n\t\texpect(decision.redirectUrl?.href).toBe(\"https://example.com/de/profile\");\n\t\texpect(decision.locale).toBe(\"de\");\n\t} finally {\n\t\tif (originalWindow === undefined) {\n\t\t\tReflect.deleteProperty(globalThis, \"window\");\n\t\t} else {\n\t\t\tglobalThis.window = originalWindow;\n\t\t}\n\t}\n});\n\ntest(\"shouldRedirect({ url }) resolves locale using target URL routeStrategies on client\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"url\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tisServer: \"false\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path(.*)?\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t\trouteStrategies: [\n\t\t\t{\n\t\t\t\tmatch: \"/dashboard/:path(.*)?\",\n\t\t\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst originalWindow = globalThis.window;\n\tconst originalDocument = globalThis.document;\n\n\ttry {\n\t\tglobalThis.window = {\n\t\t\tlocation: {\n\t\t\t\thref: \"https://example.com/dashboard\",\n\t\t\t\torigin: \"https://example.com\",\n\t\t\t},\n\t\t} as any;\n\t\tglobalThis.document = {\n\t\t\tcookie: \"PARAGLIDE_LOCALE=fr\",\n\t\t} as any;\n\n\t\tconst decision = await runtime.shouldRedirect({\n\t\t\turl: \"https://example.com/en/profile\",\n\t\t});\n\n\t\texpect(decision.shouldRedirect).toBe(false);\n\t\texpect(decision.redirectUrl).toBeUndefined();\n\t\texpect(decision.locale).toBe(\"en\");\n\t} finally {\n\t\tif (originalWindow === undefined) {\n\t\t\tReflect.deleteProperty(globalThis, \"window\");\n\t\t} else {\n\t\t\tglobalThis.window = originalWindow;\n\t\t}\n\n\t\tif (originalDocument === undefined) {\n\t\t\tReflect.deleteProperty(globalThis, \"document\");\n\t\t} else {\n\t\t\tglobalThis.document = originalDocument;\n\t\t}\n\t}\n});\n\ntest(\"shouldRedirect never suggests a redirect without the url strategy\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\tconst request = new Request(\"https://example.com/en/dashboard\", {\n\t\theaders: {\n\t\t\tcookie: \"PARAGLIDE_LOCALE=fr\",\n\t\t},\n\t});\n\n\tconst decision = await runtime.shouldRedirect({ request });\n\n\texpect(decision.shouldRedirect).toBe(false);\n\texpect(decision.redirectUrl).toBeUndefined();\n\texpect(decision.locale).toBe(\"fr\");\n});\n\ntest(\"shouldRedirect respects routeStrategies that disable url strategy per route\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"url\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\trouteStrategies: [\n\t\t\t{\n\t\t\t\tmatch: \"/dashboard/:path(.*)?\",\n\t\t\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst request = new Request(\"https://example.com/dashboard\", {\n\t\theaders: {\n\t\t\tcookie: \"PARAGLIDE_LOCALE=fr\",\n\t\t},\n\t});\n\n\tconst decision = await runtime.shouldRedirect({ request });\n\n\texpect(decision.shouldRedirect).toBe(false);\n\texpect(decision.redirectUrl).toBeUndefined();\n\texpect(decision.locale).toBe(\"fr\");\n});\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {"cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage"} BuiltInStrategy
|
|
3
|
+
*/
|
|
4
|
+
export type BuiltInStrategy = "cookie" | "baseLocale" | "globalVariable" | "url" | "preferredLanguage" | "localStorage";
|
|
5
|
+
export type CustomStrategy = `custom_${string}`;
|
|
6
|
+
export type Strategy = BuiltInStrategy | CustomStrategy;
|
|
7
|
+
export type Strategies = Array<Strategy>;
|
|
8
|
+
export type CustomServerStrategyHandler = {
|
|
9
|
+
getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined);
|
|
10
|
+
};
|
|
11
|
+
export type CustomClientStrategyHandler = {
|
|
12
|
+
getLocale: () => Promise<string | undefined> | (string | undefined);
|
|
13
|
+
setLocale: (locale: string) => Promise<void> | void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {`custom_${string}`} CustomStrategy
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {BuiltInStrategy | CustomStrategy} Strategy
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {Array<Strategy>} Strategies
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {{ getLocale: (request?: Request) => Promise<string | undefined> | (string | undefined) }} CustomServerStrategyHandler
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {{ getLocale: () => Promise<string|undefined> | (string | undefined), setLocale: (locale: string) => Promise<void> | void }} CustomClientStrategyHandler
|
|
29
|
+
*/
|
|
30
|
+
/** @type {Map<string, CustomServerStrategyHandler>} */
|
|
31
|
+
export declare const customServerStrategies: Map<string, CustomServerStrategyHandler>;
|
|
32
|
+
/** @type {Map<string, CustomClientStrategyHandler>} */
|
|
33
|
+
export declare const customClientStrategies: Map<string, CustomClientStrategyHandler>;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if the given strategy is a custom strategy.
|
|
36
|
+
*
|
|
37
|
+
* @param {unknown} strategy The name of the custom strategy to validate.
|
|
38
|
+
* Must be a string that starts with "custom-" followed by alphanumeric characters, hyphens, or underscores.
|
|
39
|
+
* @returns {boolean} Returns true if it is a custom strategy, false otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isCustomStrategy(strategy: unknown): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Defines a custom strategy that is executed on the server.
|
|
44
|
+
*
|
|
45
|
+
* @see https://paraglidejs.com/strategy#write-your-own-strategy
|
|
46
|
+
*
|
|
47
|
+
* @param {string} strategy The name of the custom strategy to define. Must follow the pattern custom-name with alphanumeric characters, hyphens, or underscores.
|
|
48
|
+
* @param {CustomServerStrategyHandler} handler The handler for the custom strategy, which should implement
|
|
49
|
+
* the method getLocale.
|
|
50
|
+
* @returns {void}
|
|
51
|
+
*/
|
|
52
|
+
export declare function defineCustomServerStrategy(strategy: string, handler: CustomServerStrategyHandler): void;
|
|
53
|
+
/**
|
|
54
|
+
* Defines a custom strategy that is executed on the client.
|
|
55
|
+
*
|
|
56
|
+
* @see https://paraglidejs.com/strategy#write-your-own-strategy
|
|
57
|
+
*
|
|
58
|
+
* @param {string} strategy The name of the custom strategy to define. Must follow the pattern custom-name with alphanumeric characters, hyphens, or underscores.
|
|
59
|
+
* @param {CustomClientStrategyHandler} handler The handler for the custom strategy, which should implement the
|
|
60
|
+
* methods getLocale and setLocale.
|
|
61
|
+
* @returns {void}
|
|
62
|
+
*/
|
|
63
|
+
export declare function defineCustomClientStrategy(strategy: string, handler: CustomClientStrategyHandler): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/strategy.js"],"names":[],"mappings":"AAAA;;GAEG;AADA,YAAqG,eAAe,GAA1G,QAAQ,GAAG,YAAY,GAAG,gBAAgB,GAAG,KAAK,GAAG,mBAAmB,GAAG,cAAc,CAAiB;AAIpH,YAA8B,cAAc,GAAlC,UAAU,MAAM,EAAE,CAAgB;AAI5C,YAA4C,QAAQ,GAA1C,eAAe,GAAG,cAAc,CAAU;AAIpD,YAA2B,UAAU,GAA3B,KAAK,CAAC,QAAQ,CAAC,CAAY;AAIrC,YAAoG,2BAA2B,GAArH;IAAE,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAAE,CAA6B;AAI/H,YAAsI,2BAA2B,GAAvJ;IAAE,SAAS,EAAE,MA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