@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 @@
|
|
|
1
|
+
{"version":3,"file":"localize-href.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-href.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,IAAI,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;IAC5E,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,YAAY,CAAC;QACjD,WAAW,EAAE;YACZ;gBACC,OAAO,EAAE,+CAA+C;gBACxD,SAAS,EAAE;oBACV,CAAC,IAAI,EAAE,kCAAkC,CAAC;oBAC1C,CAAC,IAAI,EAAE,+BAA+B,CAAC;iBACvC;aACD;SACD;KACD,CAAC,CAAC;IAEH,OAAO,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAEvC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAA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AC,CAAC,CAAC,IAAI,CACpE,6BAA6B,CAC7B,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;IACzE,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QACrB,QAAQ,EAAE,CAAC,KAAK,CAAC;KACjB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAE3E,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\";\n\ntest(\"uses the locale from getLocale() if no locale is provided\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"url\", \"globalVariable\", \"baseLocale\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"http://:domain(.*)/:locale(de|en)?/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"http://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"http://:domain(.*)/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\truntime.overwriteGetLocale(() => \"de\");\n\n\texpect(runtime.localizeHref(\"/hello\")).toBe(\"/de/hello\");\n\texpect(runtime.deLocalizeHref(\"/de/hello\")).toBe(\"/hello\");\n});\n\ntest(\"returns an absolute href if the provided href is absolute\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"url\", \"globalVariable\", \"baseLocale\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"http://:domain(.*)/:locale(de|en)?/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"http://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"http://:domain(.*)/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeHref(\"http://example.com/hello\", { locale: \"de\" })\n\t).toBe(\"http://example.com/de/hello\");\n\texpect(runtime.deLocalizeHref(\"http://example.com/de/hello\")).toBe(\n\t\t\"http://example.com/hello\"\n\t);\n});\n\n// useful if domain based localization is used for example\ntest(\"returns an absolute href if the provided href is relative but the origin of the localized href differs\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"url\", \"globalVariable\", \"baseLocale\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"http://example.com/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"http://de.example.com/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"http://example.com/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// simulating routing from current en page to de page\n\truntime.overwriteGetLocale(() => \"en\");\n\truntime.overwriteGetUrlOrigin(() => \"http://example.com\");\n\n\texpect(runtime.localizeHref(\"/hello\", { locale: \"de\" })).toBe(\n\t\t\"http://de.example.com/hello\"\n\t);\n\texpect(runtime.deLocalizeHref(\"http://de.example.com/hello\")).toBe(\n\t\t\"http://example.com/hello\"\n\t);\n\n\t// simulating routing from current de page to en page\n\truntime.overwriteGetLocale(() => \"de\");\n\n\texpect(runtime.localizeHref(\"/hello\", { locale: \"en\" })).toBe(\n\t\t\"http://example.com/hello\"\n\t);\n\texpect(runtime.deLocalizeHref(\"http://example.com/hello\")).toBe(\n\t\t\"http://example.com/hello\"\n\t);\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/362\ntest(\"adding a base path\", async () => {\n\tconst base = \"shop\";\n\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: `/{${base}/}?:path(.*)?`,\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", `/{${base}/}?de/:path(.*)?`],\n\t\t\t\t\t[\"en\", `/{${base}/}?:path(.*)?`],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// simulating the current locale to be en\n\truntime.overwriteGetLocale(() => \"en\");\n\n\texpect(runtime.localizeHref(\"/about\")).toBe(\"/shop/about\");\n\texpect(runtime.deLocalizeHref(\"/about\")).toBe(\"/shop/about\");\n\n\t// simulating current locale to be de\n\truntime.overwriteGetLocale(() => \"de\");\n\texpect(runtime.localizeHref(\"/about\")).toBe(\"/shop/de/about\");\n\texpect(runtime.deLocalizeHref(\"/de/about\")).toBe(\"/shop/about\");\n});\n\ntest(\"default url patterns to improve out of the box experience\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\tisServer: \"false\",\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: undefined,\n\t});\n\n\t// polyfilling window\n\tglobalThis.window = { location: new URL(\"http://example.com\") } as any;\n\n\texpect(runtime.urlPatterns).toStrictEqual([\n\t\t{\n\t\t\tpattern: \":protocol://:domain(.*)::port?/:path(.*)?\",\n\t\t\tlocalized: [\n\t\t\t\t[\"de\", \":protocol://:domain(.*)::port?/de/:path(.*)?\"],\n\t\t\t\t[\"fr\", \":protocol://:domain(.*)::port?/fr/:path(.*)?\"],\n\t\t\t\t[\"en\", \":protocol://:domain(.*)::port?/:path(.*)?\"],\n\t\t\t],\n\t\t},\n\t]);\n\n\t// expecting the baseLocale to not be included in the url\n\texpect(runtime.localizeHref(\"/about\", { locale: \"en\" })).toBe(\"/about\");\n\texpect(runtime.localizeHref(\"/about\", { locale: \"de\" })).toBe(\"/de/about\");\n\n\t// expecting root path to work\n\texpect(runtime.localizeHref(\"/\", { locale: \"en\" })).toBe(\"/\");\n\texpect(runtime.localizeHref(\"/\", { locale: \"de\" })).toBe(\"/de/\");\n\n\t// expecting de-localization to work\n\texpect(runtime.deLocalizeHref(\"/de/\")).toBe(\"/\");\n\texpect(runtime.deLocalizeHref(\"/de/about\")).toBe(\"/about\");\n\texpect(runtime.deLocalizeHref(\"/about\")).toBe(\"/about\");\n\n\t// expecting localhost to work (for development)\n\texpect(runtime.localizeHref(\"http://localhost:5173/\", { locale: \"de\" })).toBe(\n\t\t\"http://localhost:5173/de/\"\n\t);\n\n\t// de-localizing localhost\n\texpect(runtime.deLocalizeHref(\"http://localhost:5173/de\")).toBe(\n\t\t\"http://localhost:5173/\"\n\t);\n\n\t// pathnames\n\texpect(\n\t\truntime.localizeHref(\"http://localhost:5173/about\", { locale: \"de\" })\n\t).toBe(\"http://localhost:5173/de/about\");\n\n\texpect(runtime.deLocalizeHref(\"http://localhost:5173/de/about\")).toBe(\n\t\t\"http://localhost:5173/about\"\n\t);\n});\n\ntest(\"normalizes mixed-case explicit locales in localizeHref\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"url\"],\n\t});\n\n\texpect(runtime.localizeHref(\"/about\", { locale: \"DE\" })).toBe(\"/de/about\");\n\n\texpect(runtime.localizeHref(\"/de/about\", { locale: \"EN\" })).toBe(\"/about\");\n});\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lower-level URL localization function, primarily used in server contexts.
|
|
3
|
+
*
|
|
4
|
+
* This function is designed for server-side usage where you need precise control
|
|
5
|
+
* over URL localization, such as in middleware or request handlers. It works with
|
|
6
|
+
* URL objects and always returns absolute URLs.
|
|
7
|
+
*
|
|
8
|
+
* For client-side UI components, use `localizeHref()` instead, which provides
|
|
9
|
+
* a more convenient API with relative paths and automatic locale detection.
|
|
10
|
+
*
|
|
11
|
+
* @see https://paraglidejs.com/i18n-routing
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Server middleware example
|
|
16
|
+
* app.use((req, res, next) => {
|
|
17
|
+
* const url = new URL(req.url, `${req.protocol}://${req.headers.host}`);
|
|
18
|
+
* const localized = localizeUrl(url, { locale: "de" });
|
|
19
|
+
*
|
|
20
|
+
* if (localized.href !== url.href) {
|
|
21
|
+
* return res.redirect(localized.href);
|
|
22
|
+
* }
|
|
23
|
+
* next();
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // Using with URL patterns
|
|
30
|
+
* const url = new URL("https://example.com/about");
|
|
31
|
+
* localizeUrl(url, { locale: "de" });
|
|
32
|
+
* // => URL("https://example.com/de/about")
|
|
33
|
+
*
|
|
34
|
+
* // Using with domain-based localization
|
|
35
|
+
* const url = new URL("https://example.com/store");
|
|
36
|
+
* localizeUrl(url, { locale: "de" });
|
|
37
|
+
* // => URL("https://de.example.com/store")
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param {string | URL} url - The URL to localize. If string, must be absolute.
|
|
41
|
+
* @param {object} [options] - Options for localization
|
|
42
|
+
* @param {Locale} [options.locale] - Target locale. If not provided, uses getLocale()
|
|
43
|
+
* @returns {URL} The localized URL, always absolute
|
|
44
|
+
*/
|
|
45
|
+
export declare function localizeUrl(url: string | URL, options?: {
|
|
46
|
+
locale?: Locale;
|
|
47
|
+
}): URL;
|
|
48
|
+
/**
|
|
49
|
+
* Low-level URL de-localization function, primarily used in server contexts.
|
|
50
|
+
*
|
|
51
|
+
* This function is designed for server-side usage where you need precise control
|
|
52
|
+
* over URL de-localization, such as in middleware or request handlers. It works with
|
|
53
|
+
* URL objects and always returns absolute URLs.
|
|
54
|
+
*
|
|
55
|
+
* For client-side UI components, use `deLocalizeHref()` instead, which provides
|
|
56
|
+
* a more convenient API with relative paths.
|
|
57
|
+
*
|
|
58
|
+
* @see https://paraglidejs.com/i18n-routing
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Server middleware example
|
|
63
|
+
* app.use((req, res, next) => {
|
|
64
|
+
* const url = new URL(req.url, `${req.protocol}://${req.headers.host}`);
|
|
65
|
+
* const baseUrl = deLocalizeUrl(url);
|
|
66
|
+
*
|
|
67
|
+
* // Store the base URL for later use
|
|
68
|
+
* req.baseUrl = baseUrl;
|
|
69
|
+
* next();
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* // Using with URL patterns
|
|
76
|
+
* const url = new URL("https://example.com/de/about");
|
|
77
|
+
* deLocalizeUrl(url); // => URL("https://example.com/about")
|
|
78
|
+
*
|
|
79
|
+
* // Using with domain-based localization
|
|
80
|
+
* const url = new URL("https://de.example.com/store");
|
|
81
|
+
* deLocalizeUrl(url); // => URL("https://example.com/store")
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param {string | URL} url - The URL to de-localize. If string, must be absolute.
|
|
85
|
+
* @returns {URL} The de-localized URL, always absolute
|
|
86
|
+
*/
|
|
87
|
+
export declare function deLocalizeUrl(url: string | URL): URL;
|
|
88
|
+
/**
|
|
89
|
+
* Aggregates named groups from various parts of the URLPattern match result.
|
|
90
|
+
*
|
|
91
|
+
*
|
|
92
|
+
* @param {any} match - The URLPattern match result object.
|
|
93
|
+
* @returns {Record<string, string | null | undefined>} An object containing all named groups from the match.
|
|
94
|
+
*/
|
|
95
|
+
export declare function aggregateGroups(match: any): Record<string, string | null | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localize-url.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-url.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,WAAW,CAAC,GAAG,EALpB,MAAM,GAAG,GAKW,EAAE,OAAO,AAJrC,CAEA,EADA;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;CAEqC,GAF3B,GAAG,CA+Df;AAsCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAHtB,MAAM,GAAG,GAGa,GAFpB,GAAG,CA4Cf;AAiJD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAH1B,GAG0B,GAFxB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAarD"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { extractLocaleFromUrl } from "./extract-locale-from-url.js";
|
|
2
|
+
import { getLocale } from "./get-locale.js";
|
|
3
|
+
import { getUrlOrigin } from "./get-url-origin.js";
|
|
4
|
+
import { assertIsLocale, toLocale } from "./check-locale.js";
|
|
5
|
+
import { getCompiledUrlPattern } from "./url-pattern.js";
|
|
6
|
+
import { deLocalizeUrlHostRouting, localizeUrlHostRouting, } from "./host-routing.js";
|
|
7
|
+
import { baseLocale, TREE_SHAKE_DEFAULT_URL_PATTERN_USED, TREE_SHAKE_HOST_ROUTING_USED, urlPatterns, } from "./variables.js";
|
|
8
|
+
/**
|
|
9
|
+
* Lower-level URL localization function, primarily used in server contexts.
|
|
10
|
+
*
|
|
11
|
+
* This function is designed for server-side usage where you need precise control
|
|
12
|
+
* over URL localization, such as in middleware or request handlers. It works with
|
|
13
|
+
* URL objects and always returns absolute URLs.
|
|
14
|
+
*
|
|
15
|
+
* For client-side UI components, use `localizeHref()` instead, which provides
|
|
16
|
+
* a more convenient API with relative paths and automatic locale detection.
|
|
17
|
+
*
|
|
18
|
+
* @see https://paraglidejs.com/i18n-routing
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Server middleware example
|
|
23
|
+
* app.use((req, res, next) => {
|
|
24
|
+
* const url = new URL(req.url, `${req.protocol}://${req.headers.host}`);
|
|
25
|
+
* const localized = localizeUrl(url, { locale: "de" });
|
|
26
|
+
*
|
|
27
|
+
* if (localized.href !== url.href) {
|
|
28
|
+
* return res.redirect(localized.href);
|
|
29
|
+
* }
|
|
30
|
+
* next();
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // Using with URL patterns
|
|
37
|
+
* const url = new URL("https://example.com/about");
|
|
38
|
+
* localizeUrl(url, { locale: "de" });
|
|
39
|
+
* // => URL("https://example.com/de/about")
|
|
40
|
+
*
|
|
41
|
+
* // Using with domain-based localization
|
|
42
|
+
* const url = new URL("https://example.com/store");
|
|
43
|
+
* localizeUrl(url, { locale: "de" });
|
|
44
|
+
* // => URL("https://de.example.com/store")
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param {string | URL} url - The URL to localize. If string, must be absolute.
|
|
48
|
+
* @param {object} [options] - Options for localization
|
|
49
|
+
* @param {Locale} [options.locale] - Target locale. If not provided, uses getLocale()
|
|
50
|
+
* @returns {URL} The localized URL, always absolute
|
|
51
|
+
*/
|
|
52
|
+
export function localizeUrl(url, options) {
|
|
53
|
+
const targetLocale = options?.locale
|
|
54
|
+
? assertIsLocale(options?.locale)
|
|
55
|
+
: getLocale();
|
|
56
|
+
if (TREE_SHAKE_HOST_ROUTING_USED) {
|
|
57
|
+
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : url;
|
|
58
|
+
return localizeUrlHostRouting(urlObj, targetLocale);
|
|
59
|
+
}
|
|
60
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
61
|
+
return localizeUrlDefaultPattern(url, targetLocale);
|
|
62
|
+
}
|
|
63
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
64
|
+
// Iterate over URL patterns
|
|
65
|
+
for (const element of urlPatterns) {
|
|
66
|
+
// match localized patterns
|
|
67
|
+
for (const [, localizedPattern] of element.localized) {
|
|
68
|
+
const match = getCompiledUrlPattern(localizedPattern).exec(urlObj.href);
|
|
69
|
+
if (!match) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
73
|
+
if (!targetPattern) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
77
|
+
return fillMissingUrlParts(localizedUrl, match);
|
|
78
|
+
}
|
|
79
|
+
const unlocalizedMatch = getCompiledUrlPattern(element.pattern).exec(urlObj.href);
|
|
80
|
+
if (unlocalizedMatch) {
|
|
81
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
82
|
+
if (targetPattern) {
|
|
83
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
84
|
+
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// If no match found, return the original URL
|
|
89
|
+
return urlObj;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* https://github.com/opral/inlang-paraglide-js/issues/381
|
|
93
|
+
*
|
|
94
|
+
* @param {string | URL} url
|
|
95
|
+
* @param {Locale} locale
|
|
96
|
+
* @returns {URL}
|
|
97
|
+
*/
|
|
98
|
+
function localizeUrlDefaultPattern(url, locale) {
|
|
99
|
+
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
100
|
+
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
101
|
+
// If current locale matches target locale, no change needed
|
|
102
|
+
if (currentLocale === locale) {
|
|
103
|
+
return urlObj;
|
|
104
|
+
}
|
|
105
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
106
|
+
// If current path starts with a locale, remove it
|
|
107
|
+
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
108
|
+
pathSegments.shift();
|
|
109
|
+
}
|
|
110
|
+
// For base locale, don't add prefix
|
|
111
|
+
if (locale === baseLocale) {
|
|
112
|
+
urlObj.pathname = "/" + pathSegments.join("/");
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// For other locales, add prefix
|
|
116
|
+
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
117
|
+
}
|
|
118
|
+
return urlObj;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Low-level URL de-localization function, primarily used in server contexts.
|
|
122
|
+
*
|
|
123
|
+
* This function is designed for server-side usage where you need precise control
|
|
124
|
+
* over URL de-localization, such as in middleware or request handlers. It works with
|
|
125
|
+
* URL objects and always returns absolute URLs.
|
|
126
|
+
*
|
|
127
|
+
* For client-side UI components, use `deLocalizeHref()` instead, which provides
|
|
128
|
+
* a more convenient API with relative paths.
|
|
129
|
+
*
|
|
130
|
+
* @see https://paraglidejs.com/i18n-routing
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* // Server middleware example
|
|
135
|
+
* app.use((req, res, next) => {
|
|
136
|
+
* const url = new URL(req.url, `${req.protocol}://${req.headers.host}`);
|
|
137
|
+
* const baseUrl = deLocalizeUrl(url);
|
|
138
|
+
*
|
|
139
|
+
* // Store the base URL for later use
|
|
140
|
+
* req.baseUrl = baseUrl;
|
|
141
|
+
* next();
|
|
142
|
+
* });
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* // Using with URL patterns
|
|
148
|
+
* const url = new URL("https://example.com/de/about");
|
|
149
|
+
* deLocalizeUrl(url); // => URL("https://example.com/about")
|
|
150
|
+
*
|
|
151
|
+
* // Using with domain-based localization
|
|
152
|
+
* const url = new URL("https://de.example.com/store");
|
|
153
|
+
* deLocalizeUrl(url); // => URL("https://example.com/store")
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @param {string | URL} url - The URL to de-localize. If string, must be absolute.
|
|
157
|
+
* @returns {URL} The de-localized URL, always absolute
|
|
158
|
+
*/
|
|
159
|
+
export function deLocalizeUrl(url) {
|
|
160
|
+
if (TREE_SHAKE_HOST_ROUTING_USED) {
|
|
161
|
+
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : url;
|
|
162
|
+
return deLocalizeUrlHostRouting(urlObj);
|
|
163
|
+
}
|
|
164
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
165
|
+
return deLocalizeUrlDefaultPattern(url);
|
|
166
|
+
}
|
|
167
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
168
|
+
// Iterate over URL patterns
|
|
169
|
+
for (const element of urlPatterns) {
|
|
170
|
+
// Iterate over localized versions
|
|
171
|
+
for (const [, localizedPattern] of element.localized) {
|
|
172
|
+
const match = getCompiledUrlPattern(localizedPattern).exec(urlObj.href);
|
|
173
|
+
if (match) {
|
|
174
|
+
// Convert localized URL back to the base pattern
|
|
175
|
+
const groups = aggregateGroups(match);
|
|
176
|
+
const baseUrl = fillPattern(element.pattern, groups, urlObj.origin);
|
|
177
|
+
return fillMissingUrlParts(baseUrl, match);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// match unlocalized pattern
|
|
181
|
+
const unlocalizedMatch = getCompiledUrlPattern(element.pattern).exec(urlObj.href);
|
|
182
|
+
if (unlocalizedMatch) {
|
|
183
|
+
const baseUrl = fillPattern(element.pattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
184
|
+
return fillMissingUrlParts(baseUrl, unlocalizedMatch);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// no match found return the original url
|
|
188
|
+
return urlObj;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* De-localizes a URL using the default pattern (/:locale/*)
|
|
192
|
+
* @param {string|URL} url
|
|
193
|
+
* @returns {URL}
|
|
194
|
+
*/
|
|
195
|
+
function deLocalizeUrlDefaultPattern(url) {
|
|
196
|
+
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
197
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
198
|
+
// If first segment is a locale, remove it
|
|
199
|
+
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
200
|
+
urlObj.pathname = "/" + pathSegments.slice(1).join("/");
|
|
201
|
+
}
|
|
202
|
+
return urlObj;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Takes matches of implicit wildcards in the UrlPattern (when a part is missing
|
|
206
|
+
* it is equal to '*') and adds them back to the result of fillPattern.
|
|
207
|
+
*
|
|
208
|
+
* At least protocol and hostname are required to create a valid URL inside fillPattern.
|
|
209
|
+
*
|
|
210
|
+
* @param {URL} url
|
|
211
|
+
* @param {any} match
|
|
212
|
+
* @returns {URL}
|
|
213
|
+
*/
|
|
214
|
+
function fillMissingUrlParts(url, match) {
|
|
215
|
+
if (match.protocol.groups["0"]) {
|
|
216
|
+
url.protocol = match.protocol.groups["0"] ?? "";
|
|
217
|
+
}
|
|
218
|
+
if (match.hostname.groups["0"]) {
|
|
219
|
+
url.hostname = match.hostname.groups["0"] ?? "";
|
|
220
|
+
}
|
|
221
|
+
if (match.username.groups["0"]) {
|
|
222
|
+
url.username = match.username.groups["0"] ?? "";
|
|
223
|
+
}
|
|
224
|
+
if (match.password.groups["0"]) {
|
|
225
|
+
url.password = match.password.groups["0"] ?? "";
|
|
226
|
+
}
|
|
227
|
+
if (match.port.groups["0"]) {
|
|
228
|
+
url.port = match.port.groups["0"] ?? "";
|
|
229
|
+
}
|
|
230
|
+
if (match.pathname.groups["0"]) {
|
|
231
|
+
url.pathname = match.pathname.groups["0"] ?? "";
|
|
232
|
+
}
|
|
233
|
+
if (match.search.groups["0"]) {
|
|
234
|
+
url.search = match.search.groups["0"] ?? "";
|
|
235
|
+
}
|
|
236
|
+
if (match.hash.groups["0"]) {
|
|
237
|
+
url.hash = match.hash.groups["0"] ?? "";
|
|
238
|
+
}
|
|
239
|
+
return url;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Fills a URL pattern with values for named groups, supporting all URLPattern-style modifiers.
|
|
243
|
+
*
|
|
244
|
+
* This function will eventually be replaced by https://github.com/whatwg/urlpattern/issues/73
|
|
245
|
+
*
|
|
246
|
+
* Matches:
|
|
247
|
+
* - :name -> Simple
|
|
248
|
+
* - :name? -> Optional
|
|
249
|
+
* - :name+ -> One or more
|
|
250
|
+
* - :name* -> Zero or more
|
|
251
|
+
* - :name(...) -> Regex group
|
|
252
|
+
* - {text} -> Group delimiter
|
|
253
|
+
* - {text}? -> Optional group delimiter
|
|
254
|
+
*
|
|
255
|
+
* If the value is `null`, the segment is removed.
|
|
256
|
+
*
|
|
257
|
+
* @param {string} pattern - The URL pattern containing named groups.
|
|
258
|
+
* @param {Record<string, string | null | undefined>} values - Object of values for named groups.
|
|
259
|
+
* @param {string} origin - Base URL to use for URL construction.
|
|
260
|
+
* @returns {URL} - The constructed URL with named groups filled.
|
|
261
|
+
*/
|
|
262
|
+
function fillPattern(pattern, values, origin) {
|
|
263
|
+
// Pre-process the pattern to handle explicit port numbers
|
|
264
|
+
// This detects patterns like "http://localhost:5173" and protects the port number
|
|
265
|
+
// from being interpreted as a parameter
|
|
266
|
+
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
267
|
+
// Replace ":5173" with "#PORT-5173#" to protect it from parameter replacement
|
|
268
|
+
return `${protocol}#PORT-${port}#${slash}`;
|
|
269
|
+
});
|
|
270
|
+
// First, handle group delimiters with curly braces
|
|
271
|
+
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
272
|
+
// For optional group delimiters
|
|
273
|
+
if (modifier === "?") {
|
|
274
|
+
// For optional groups, we'll include the content
|
|
275
|
+
return content;
|
|
276
|
+
}
|
|
277
|
+
// For non-optional group delimiters, always include the content
|
|
278
|
+
return content;
|
|
279
|
+
});
|
|
280
|
+
// Then handle named groups
|
|
281
|
+
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
282
|
+
const value = values[name];
|
|
283
|
+
if (value === null) {
|
|
284
|
+
// If value is null, remove the entire segment including the preceding slash
|
|
285
|
+
return "";
|
|
286
|
+
}
|
|
287
|
+
if (modifier === "?") {
|
|
288
|
+
// Optional segment
|
|
289
|
+
return value !== undefined ? `${slash}${value}` : "";
|
|
290
|
+
}
|
|
291
|
+
if (modifier === "+" || modifier === "*") {
|
|
292
|
+
// Repeatable segments
|
|
293
|
+
if (value === undefined && modifier === "+") {
|
|
294
|
+
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
295
|
+
}
|
|
296
|
+
return value ? `${slash}${value}` : "";
|
|
297
|
+
}
|
|
298
|
+
// Simple named group (no modifier)
|
|
299
|
+
if (value === undefined) {
|
|
300
|
+
throw new Error(`Missing value for "${name}"`);
|
|
301
|
+
}
|
|
302
|
+
return `${slash}${value}`;
|
|
303
|
+
});
|
|
304
|
+
// Restore port numbers
|
|
305
|
+
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
306
|
+
return new URL(filled, origin);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Aggregates named groups from various parts of the URLPattern match result.
|
|
310
|
+
*
|
|
311
|
+
*
|
|
312
|
+
* @param {any} match - The URLPattern match result object.
|
|
313
|
+
* @returns {Record<string, string | null | undefined>} An object containing all named groups from the match.
|
|
314
|
+
*/
|
|
315
|
+
export function aggregateGroups(match) {
|
|
316
|
+
return {
|
|
317
|
+
...match.hash.groups,
|
|
318
|
+
...match.hostname.groups,
|
|
319
|
+
...match.password.groups,
|
|
320
|
+
...match.pathname.groups,
|
|
321
|
+
...match.port.groups,
|
|
322
|
+
...match.protocol.groups,
|
|
323
|
+
...match.search.groups,
|
|
324
|
+
...match.username.groups,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
//# sourceMappingURL=localize-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localize-url.js","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-url.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACN,wBAAwB,EACxB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,UAAU,EACV,mCAAmC,EACnC,4BAA4B,EAC5B,WAAW,GACX,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,WAAW,CAAC,GAAG,EAAE,OAAO;IACvC,MAAM,YAAY,GAAG,OAAO,EAAE,MAAM;QACnC,CAAC,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC;QACjC,CAAC,CAAC,SAAS,EAAE,CAAC;IAEf,IAAI,4BAA4B,EAAE,CAAC;QAClC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AAM;KACxB,CAAC;AACH,CAAC","sourcesContent":["import { extractLocaleFromUrl } from \"./extract-locale-from-url.js\";\nimport { getLocale } from \"./get-locale.js\";\nimport { getUrlOrigin } from \"./get-url-origin.js\";\nimport { assertIsLocale, toLocale } from \"./check-locale.js\";\nimport { getCompiledUrlPattern } from \"./url-pattern.js\";\nimport {\n\tdeLocalizeUrlHostRouting,\n\tlocalizeUrlHostRouting,\n} from \"./host-routing.js\";\nimport {\n\tbaseLocale,\n\tTREE_SHAKE_DEFAULT_URL_PATTERN_USED,\n\tTREE_SHAKE_HOST_ROUTING_USED,\n\turlPatterns,\n} from \"./variables.js\";\n\n/**\n * Lower-level URL localization function, primarily used in server contexts.\n *\n * This function is designed for server-side usage where you need precise control\n * over URL localization, such as in middleware or request handlers. It works with\n * URL objects and always returns absolute URLs.\n *\n * For client-side UI components, use `localizeHref()` instead, which provides\n * a more convenient API with relative paths and automatic locale detection.\n *\n * @see https://paraglidejs.com/i18n-routing\n *\n * @example\n * ```typescript\n * // Server middleware example\n * app.use((req, res, next) => {\n * const url = new URL(req.url, `${req.protocol}://${req.headers.host}`);\n * const localized = localizeUrl(url, { locale: \"de\" });\n *\n * if (localized.href !== url.href) {\n * return res.redirect(localized.href);\n * }\n * next();\n * });\n * ```\n *\n * @example\n * ```typescript\n * // Using with URL patterns\n * const url = new URL(\"https://example.com/about\");\n * localizeUrl(url, { locale: \"de\" });\n * // => URL(\"https://example.com/de/about\")\n *\n * // Using with domain-based localization\n * const url = new URL(\"https://example.com/store\");\n * localizeUrl(url, { locale: \"de\" });\n * // => URL(\"https://de.example.com/store\")\n * ```\n *\n * @param {string | URL} url - The URL to localize. If string, must be absolute.\n * @param {object} [options] - Options for localization\n * @param {Locale} [options.locale] - Target locale. If not provided, uses getLocale()\n * @returns {URL} The localized URL, always absolute\n */\nexport function localizeUrl(url, options) {\n\tconst targetLocale = options?.locale\n\t\t? assertIsLocale(options?.locale)\n\t\t: getLocale();\n\n\tif (TREE_SHAKE_HOST_ROUTING_USED) {\n\t\tconst urlObj =\n\t\t\ttypeof url === \"string\" ? new URL(url, getUrlOrigin()) : url;\n\t\treturn localizeUrlHostRouting(urlObj, targetLocale);\n\t}\n\n\tif (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {\n\t\treturn localizeUrlDefaultPattern(url, targetLocale);\n\t}\n\n\tconst urlObj = typeof url === \"string\" ? new URL(url) : url;\n\n\t// Iterate over URL patterns\n\tfor (const element of urlPatterns) {\n\t\t// match localized patterns\n\t\tfor (const [, localizedPattern] of element.localized) {\n\t\t\tconst match = getCompiledUrlPattern(localizedPattern).exec(urlObj.href);\n\n\t\t\tif (!match) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst targetPattern = element.localized.find(\n\t\t\t\t([locale]) => locale === targetLocale\n\t\t\t)?.[1];\n\n\t\t\tif (!targetPattern) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst localizedUrl = fillPattern(\n\t\t\t\ttargetPattern,\n\t\t\t\taggregateGroups(match),\n\t\t\t\turlObj.origin\n\t\t\t);\n\t\t\treturn fillMissingUrlParts(localizedUrl, match);\n\t\t}\n\t\tconst unlocalizedMatch = getCompiledUrlPattern(element.pattern).exec(\n\t\t\turlObj.href\n\t\t);\n\t\tif (unlocalizedMatch) {\n\t\t\tconst targetPattern = element.localized.find(\n\t\t\t\t([locale]) => locale === targetLocale\n\t\t\t)?.[1];\n\t\t\tif (targetPattern) {\n\t\t\t\tconst localizedUrl = fillPattern(\n\t\t\t\t\ttargetPattern,\n\t\t\t\t\taggregateGroups(unlocalizedMatch),\n\t\t\t\t\turlObj.origin\n\t\t\t\t);\n\t\t\t\treturn fillMissingUrlParts(localizedUrl, unlocalizedMatch);\n\t\t\t}\n\t\t}\n\t}\n\t// If no match found, return the original URL\n\treturn urlObj;\n}\n\n/**\n * https://github.com/opral/inlang-paraglide-js/issues/381\n *\n * @param {string | URL} url\n * @param {Locale} locale\n * @returns {URL}\n */\nfunction localizeUrlDefaultPattern(url, locale) {\n\tconst urlObj =\n\t\ttypeof url === \"string\" ? new URL(url, getUrlOrigin()) : new URL(url);\n\n\tconst currentLocale = extractLocaleFromUrl(urlObj);\n\n\t// If current locale matches target locale, no change needed\n\tif (currentLocale === locale) {\n\t\treturn urlObj;\n\t}\n\n\tconst pathSegments = urlObj.pathname.split(\"/\").filter(Boolean);\n\n\t// If current path starts with a locale, remove it\n\tif (pathSegments.length > 0 && toLocale(pathSegments[0])) {\n\t\tpathSegments.shift();\n\t}\n\n\t// For base locale, don't add prefix\n\tif (locale === baseLocale) {\n\t\turlObj.pathname = \"/\" + pathSegments.join(\"/\");\n\t} else {\n\t\t// For other locales, add prefix\n\t\turlObj.pathname = \"/\" + locale + \"/\" + pathSegments.join(\"/\");\n\t}\n\n\treturn urlObj;\n}\n\n/**\n * Low-level URL de-localization function, primarily used in server contexts.\n *\n * This function is designed for server-side usage where you need precise control\n * over URL de-localization, such as in middleware or request handlers. It works with\n * URL objects and always returns absolute URLs.\n *\n * For client-side UI components, use `deLocalizeHref()` instead, which provides\n * a more convenient API with relative paths.\n *\n * @see https://paraglidejs.com/i18n-routing\n *\n * @example\n * ```typescript\n * // Server middleware example\n * app.use((req, res, next) => {\n * const url = new URL(req.url, `${req.protocol}://${req.headers.host}`);\n * const baseUrl = deLocalizeUrl(url);\n *\n * // Store the base URL for later use\n * req.baseUrl = baseUrl;\n * next();\n * });\n * ```\n *\n * @example\n * ```typescript\n * // Using with URL patterns\n * const url = new URL(\"https://example.com/de/about\");\n * deLocalizeUrl(url); // => URL(\"https://example.com/about\")\n *\n * // Using with domain-based localization\n * const url = new URL(\"https://de.example.com/store\");\n * deLocalizeUrl(url); // => URL(\"https://example.com/store\")\n * ```\n *\n * @param {string | URL} url - The URL to de-localize. If string, must be absolute.\n * @returns {URL} The de-localized URL, always absolute\n */\nexport function deLocalizeUrl(url) {\n\tif (TREE_SHAKE_HOST_ROUTING_USED) {\n\t\tconst urlObj =\n\t\t\ttypeof url === \"string\" ? new URL(url, getUrlOrigin()) : url;\n\t\treturn deLocalizeUrlHostRouting(urlObj);\n\t}\n\n\tif (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {\n\t\treturn deLocalizeUrlDefaultPattern(url);\n\t}\n\n\tconst urlObj = typeof url === \"string\" ? new URL(url) : url;\n\n\t// Iterate over URL patterns\n\tfor (const element of urlPatterns) {\n\t\t// Iterate over localized versions\n\t\tfor (const [, localizedPattern] of element.localized) {\n\t\t\tconst match = getCompiledUrlPattern(localizedPattern).exec(urlObj.href);\n\n\t\t\tif (match) {\n\t\t\t\t// Convert localized URL back to the base pattern\n\t\t\t\tconst groups = aggregateGroups(match);\n\n\t\t\t\tconst baseUrl = fillPattern(element.pattern, groups, urlObj.origin);\n\t\t\t\treturn fillMissingUrlParts(baseUrl, match);\n\t\t\t}\n\t\t}\n\t\t// match unlocalized pattern\n\t\tconst unlocalizedMatch = getCompiledUrlPattern(element.pattern).exec(\n\t\t\turlObj.href\n\t\t);\n\t\tif (unlocalizedMatch) {\n\t\t\tconst baseUrl = fillPattern(\n\t\t\t\telement.pattern,\n\t\t\t\taggregateGroups(unlocalizedMatch),\n\t\t\t\turlObj.origin\n\t\t\t);\n\t\t\treturn fillMissingUrlParts(baseUrl, unlocalizedMatch);\n\t\t}\n\t}\n\t// no match found return the original url\n\treturn urlObj;\n}\n\n/**\n * De-localizes a URL using the default pattern (/:locale/*)\n * @param {string|URL} url\n * @returns {URL}\n */\nfunction deLocalizeUrlDefaultPattern(url) {\n\tconst urlObj =\n\t\ttypeof url === \"string\" ? new URL(url, getUrlOrigin()) : new URL(url);\n\tconst pathSegments = urlObj.pathname.split(\"/\").filter(Boolean);\n\n\t// If first segment is a locale, remove it\n\tif (pathSegments.length > 0 && toLocale(pathSegments[0])) {\n\t\turlObj.pathname = \"/\" + pathSegments.slice(1).join(\"/\");\n\t}\n\n\treturn urlObj;\n}\n\n/**\n * Takes matches of implicit wildcards in the UrlPattern (when a part is missing\n * it is equal to '*') and adds them back to the result of fillPattern.\n *\n * At least protocol and hostname are required to create a valid URL inside fillPattern.\n *\n * @param {URL} url\n * @param {any} match\n * @returns {URL}\n */\nfunction fillMissingUrlParts(url, match) {\n\tif (match.protocol.groups[\"0\"]) {\n\t\turl.protocol = match.protocol.groups[\"0\"] ?? \"\";\n\t}\n\tif (match.hostname.groups[\"0\"]) {\n\t\turl.hostname = match.hostname.groups[\"0\"] ?? \"\";\n\t}\n\tif (match.username.groups[\"0\"]) {\n\t\turl.username = match.username.groups[\"0\"] ?? \"\";\n\t}\n\tif (match.password.groups[\"0\"]) {\n\t\turl.password = match.password.groups[\"0\"] ?? \"\";\n\t}\n\tif (match.port.groups[\"0\"]) {\n\t\turl.port = match.port.groups[\"0\"] ?? \"\";\n\t}\n\tif (match.pathname.groups[\"0\"]) {\n\t\turl.pathname = match.pathname.groups[\"0\"] ?? \"\";\n\t}\n\tif (match.search.groups[\"0\"]) {\n\t\turl.search = match.search.groups[\"0\"] ?? \"\";\n\t}\n\tif (match.hash.groups[\"0\"]) {\n\t\turl.hash = match.hash.groups[\"0\"] ?? \"\";\n\t}\n\n\treturn url;\n}\n\n/**\n * Fills a URL pattern with values for named groups, supporting all URLPattern-style modifiers.\n *\n * This function will eventually be replaced by https://github.com/whatwg/urlpattern/issues/73\n *\n * Matches:\n * - :name -> Simple\n * - :name? -> Optional\n * - :name+ -> One or more\n * - :name* -> Zero or more\n * - :name(...) -> Regex group\n * - {text} -> Group delimiter\n * - {text}? -> Optional group delimiter\n *\n * If the value is `null`, the segment is removed.\n *\n * @param {string} pattern - The URL pattern containing named groups.\n * @param {Record<string, string | null | undefined>} values - Object of values for named groups.\n * @param {string} origin - Base URL to use for URL construction.\n * @returns {URL} - The constructed URL with named groups filled.\n */\nfunction fillPattern(pattern, values, origin) {\n\t// Pre-process the pattern to handle explicit port numbers\n\t// This detects patterns like \"http://localhost:5173\" and protects the port number\n\t// from being interpreted as a parameter\n\tlet processedPattern = pattern.replace(\n\t\t/(https?:\\/\\/[^:/]+):(\\d+)(\\/|$)/g,\n\t\t(_, protocol, port, slash) => {\n\t\t\t// Replace \":5173\" with \"#PORT-5173#\" to protect it from parameter replacement\n\t\t\treturn `${protocol}#PORT-${port}#${slash}`;\n\t\t}\n\t);\n\n\t// First, handle group delimiters with curly braces\n\tlet processedGroupDelimiters = processedPattern.replace(\n\t\t/\\{([^{}]*)\\}([?+*]?)/g,\n\t\t(_, content, modifier) => {\n\t\t\t// For optional group delimiters\n\t\t\tif (modifier === \"?\") {\n\t\t\t\t// For optional groups, we'll include the content\n\t\t\t\treturn content;\n\t\t\t}\n\t\t\t// For non-optional group delimiters, always include the content\n\t\t\treturn content;\n\t\t}\n\t);\n\n\t// Then handle named groups\n\tlet filled = processedGroupDelimiters.replace(\n\t\t/(\\/?):([a-zA-Z0-9_]+)(\\([^)]*\\))?([?+*]?)/g,\n\t\t(_, slash, name, __, modifier) => {\n\t\t\tconst value = values[name];\n\n\t\t\tif (value === null) {\n\t\t\t\t// If value is null, remove the entire segment including the preceding slash\n\t\t\t\treturn \"\";\n\t\t\t}\n\n\t\t\tif (modifier === \"?\") {\n\t\t\t\t// Optional segment\n\t\t\t\treturn value !== undefined ? `${slash}${value}` : \"\";\n\t\t\t}\n\n\t\t\tif (modifier === \"+\" || modifier === \"*\") {\n\t\t\t\t// Repeatable segments\n\t\t\t\tif (value === undefined && modifier === \"+\") {\n\t\t\t\t\tthrow new Error(`Missing value for \"${name}\" (one or more required)`);\n\t\t\t\t}\n\t\t\t\treturn value ? `${slash}${value}` : \"\";\n\t\t\t}\n\n\t\t\t// Simple named group (no modifier)\n\t\t\tif (value === undefined) {\n\t\t\t\tthrow new Error(`Missing value for \"${name}\"`);\n\t\t\t}\n\n\t\t\treturn `${slash}${value}`;\n\t\t}\n\t);\n\n\t// Restore port numbers\n\tfilled = filled.replace(/#PORT-(\\d+)#/g, \":$1\");\n\n\treturn new URL(filled, origin);\n}\n\n/**\n * Aggregates named groups from various parts of the URLPattern match result.\n *\n *\n * @param {any} match - The URLPattern match result object.\n * @returns {Record<string, string | null | undefined>} An object containing all named groups from the match.\n */\nexport function aggregateGroups(match) {\n\treturn {\n\t\t...match.hash.groups,\n\t\t...match.hostname.groups,\n\t\t...match.password.groups,\n\t\t...match.pathname.groups,\n\t\t...match.port.groups,\n\t\t...match.protocol.groups,\n\t\t...match.search.groups,\n\t\t...match.username.groups,\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localize-url.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-url.test.ts"],"names":[],"mappings":""}
|