@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,159 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { createParaglide } from "../create-paraglide.js";
|
|
3
|
+
test("generates localized URLs using default URL pattern", async () => {
|
|
4
|
+
const runtime = await createParaglide({
|
|
5
|
+
baseLocale: "en",
|
|
6
|
+
locales: ["en", "de", "fr"],
|
|
7
|
+
strategy: ["url"],
|
|
8
|
+
// undefined creates the default pattern
|
|
9
|
+
urlPatterns: undefined,
|
|
10
|
+
});
|
|
11
|
+
const urls = runtime.generateStaticLocalizedUrls([
|
|
12
|
+
"http://example.com/about",
|
|
13
|
+
"http://example.com/blog/post-1",
|
|
14
|
+
"http://example.com/contact",
|
|
15
|
+
]);
|
|
16
|
+
const pathnames = urls.map((url) => url.pathname).sort();
|
|
17
|
+
expect(pathnames).toEqual([
|
|
18
|
+
"/about",
|
|
19
|
+
"/blog/post-1",
|
|
20
|
+
"/contact",
|
|
21
|
+
"/de/about",
|
|
22
|
+
"/de/blog/post-1",
|
|
23
|
+
"/de/contact",
|
|
24
|
+
"/fr/about",
|
|
25
|
+
"/fr/blog/post-1",
|
|
26
|
+
"/fr/contact",
|
|
27
|
+
]);
|
|
28
|
+
// All URLs should be URL objects
|
|
29
|
+
expect(urls.every((url) => url instanceof URL)).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
test("generates localized URLs using custom URL patterns", async () => {
|
|
32
|
+
const runtime = await createParaglide({
|
|
33
|
+
baseLocale: "en",
|
|
34
|
+
locales: ["en", "de"],
|
|
35
|
+
strategy: ["url"],
|
|
36
|
+
urlPatterns: [
|
|
37
|
+
{
|
|
38
|
+
pattern: "/store/item/:id",
|
|
39
|
+
localized: [
|
|
40
|
+
["en", "/store/item/:id"],
|
|
41
|
+
["de", "/laden/artikel/:id"],
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
pattern: "/blog/:slug",
|
|
46
|
+
localized: [
|
|
47
|
+
["en", "/blog/:slug"],
|
|
48
|
+
["de", "/blog/:slug"], // Same pattern for both locales
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
const urls = runtime.generateStaticLocalizedUrls([
|
|
54
|
+
"https://example.com/store/item/123",
|
|
55
|
+
"https://example.com/store/item/456",
|
|
56
|
+
"https://example.com/blog/my-post",
|
|
57
|
+
]);
|
|
58
|
+
const pathnames = urls.map((url) => url.pathname).sort();
|
|
59
|
+
expect(pathnames).toEqual([
|
|
60
|
+
"/blog/my-post",
|
|
61
|
+
"/laden/artikel/123",
|
|
62
|
+
"/laden/artikel/456",
|
|
63
|
+
"/store/item/123",
|
|
64
|
+
"/store/item/456",
|
|
65
|
+
]);
|
|
66
|
+
// All URLs should be URL objects
|
|
67
|
+
expect(urls.every((url) => url instanceof URL)).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
test("handles paths that don't match any pattern by including them", async () => {
|
|
70
|
+
const runtime = await createParaglide({
|
|
71
|
+
baseLocale: "en",
|
|
72
|
+
locales: ["en", "de"],
|
|
73
|
+
strategy: ["url"],
|
|
74
|
+
urlPatterns: [
|
|
75
|
+
{
|
|
76
|
+
pattern: "https://example.com/store/:path*",
|
|
77
|
+
localized: [
|
|
78
|
+
["en", "https://example.com/store/:path*"],
|
|
79
|
+
["de", "https://example.com/laden/:path*"],
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
const urls = runtime.generateStaticLocalizedUrls([
|
|
85
|
+
"https://example.com/store/item/123", // Should match pattern
|
|
86
|
+
"https://example.com/about", // Should not match pattern
|
|
87
|
+
"https://example.com/contact", // Should not match pattern
|
|
88
|
+
]);
|
|
89
|
+
const pathnames = urls.map((url) => url.pathname).sort();
|
|
90
|
+
expect(pathnames).toEqual([
|
|
91
|
+
"/about",
|
|
92
|
+
"/contact",
|
|
93
|
+
"/laden/item/123",
|
|
94
|
+
"/store/item/123",
|
|
95
|
+
]);
|
|
96
|
+
// All URLs should be URL objects
|
|
97
|
+
expect(urls.every((url) => url instanceof URL)).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
test("handles URL objects as input", async () => {
|
|
100
|
+
const runtime = await createParaglide({
|
|
101
|
+
baseLocale: "en",
|
|
102
|
+
locales: ["en", "de"],
|
|
103
|
+
strategy: ["url"],
|
|
104
|
+
urlPatterns: [
|
|
105
|
+
{
|
|
106
|
+
pattern: "/store/:path*",
|
|
107
|
+
localized: [
|
|
108
|
+
["en", "/store/:path*"],
|
|
109
|
+
["de", "/laden/:path*"],
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
const urls = runtime.generateStaticLocalizedUrls([
|
|
115
|
+
new URL("https://example.com/store/item/123?color=blue#reviews"),
|
|
116
|
+
new URL("https://example.com/store/cart"),
|
|
117
|
+
new URL("https://example.com/about"), // Should not match pattern
|
|
118
|
+
]);
|
|
119
|
+
const pathnames = urls.map((url) => url.pathname).sort();
|
|
120
|
+
expect(pathnames).toEqual([
|
|
121
|
+
"/about",
|
|
122
|
+
"/laden/cart",
|
|
123
|
+
"/laden/item/123",
|
|
124
|
+
"/store/cart",
|
|
125
|
+
"/store/item/123",
|
|
126
|
+
]);
|
|
127
|
+
// Verify search params and hash fragments are preserve
|
|
128
|
+
// All URLs should be URL objects
|
|
129
|
+
expect(urls.every((url) => url instanceof URL)).toBe(true);
|
|
130
|
+
});
|
|
131
|
+
test("generates localized URLs from paths", async () => {
|
|
132
|
+
const runtime = await createParaglide({
|
|
133
|
+
baseLocale: "en",
|
|
134
|
+
locales: ["en", "de", "fr"],
|
|
135
|
+
strategy: ["url"],
|
|
136
|
+
// undefined creates the default pattern
|
|
137
|
+
urlPatterns: undefined,
|
|
138
|
+
});
|
|
139
|
+
const urls = runtime.generateStaticLocalizedUrls([
|
|
140
|
+
"/about",
|
|
141
|
+
"/blog/post-1",
|
|
142
|
+
"/contact",
|
|
143
|
+
]);
|
|
144
|
+
const pathnames = urls.map((url) => url.pathname).sort();
|
|
145
|
+
expect(pathnames).toEqual([
|
|
146
|
+
"/about",
|
|
147
|
+
"/blog/post-1",
|
|
148
|
+
"/contact",
|
|
149
|
+
"/de/about",
|
|
150
|
+
"/de/blog/post-1",
|
|
151
|
+
"/de/contact",
|
|
152
|
+
"/fr/about",
|
|
153
|
+
"/fr/blog/post-1",
|
|
154
|
+
"/fr/contact",
|
|
155
|
+
]);
|
|
156
|
+
// All URLs should be URL objects
|
|
157
|
+
expect(urls.every((url) => url instanceof URL)).toBe(true);
|
|
158
|
+
});
|
|
159
|
+
//# sourceMappingURL=generate-static-localized-urls.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-static-localized-urls.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/generate-static-localized-urls.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,oDAAoD,EAAE,KAAK,IAAI,EAAE;IACrE,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QAC3B,QAAQ,EAAE,CAAC,KAAK,CAAC;QACjB,wCAAwC;QACxC,WAAW,EAAE,SAAS;KACtB,CAA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,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;IACtD,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QAC3B,QAAQ,EAAE,CAAC,KAAK,CAAC;QACjB,wCAAwC;QACxC,WAAW,EAAE,SAAS;KACtB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,OAAO,CAAC,2BAA2B,CAAC;QAChD,QAAQ;QACR,cAAc;QACd,UAAU;KACV,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;IAEzD,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;QACzB,QAAQ;QACR,cAAc;QACd,UAAU;QACV,WAAW;QACX,iBAAiB;QACjB,aAAa;QACb,WAAW;QACX,iBAAiB;QACjB,aAAa;KACb,CAAC,CAAC;IAEH,iCAAiC;IACjC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\n\ntest(\"generates localized URLs using default URL pattern\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\tstrategy: [\"url\"],\n\t\t// undefined creates the default pattern\n\t\turlPatterns: undefined,\n\t});\n\n\tconst urls = runtime.generateStaticLocalizedUrls([\n\t\t\"http://example.com/about\",\n\t\t\"http://example.com/blog/post-1\",\n\t\t\"http://example.com/contact\",\n\t]);\n\tconst pathnames = urls.map((url) => url.pathname).sort();\n\n\texpect(pathnames).toEqual([\n\t\t\"/about\",\n\t\t\"/blog/post-1\",\n\t\t\"/contact\",\n\t\t\"/de/about\",\n\t\t\"/de/blog/post-1\",\n\t\t\"/de/contact\",\n\t\t\"/fr/about\",\n\t\t\"/fr/blog/post-1\",\n\t\t\"/fr/contact\",\n\t]);\n\n\t// All URLs should be URL objects\n\texpect(urls.every((url) => url instanceof URL)).toBe(true);\n});\n\ntest(\"generates localized URLs using custom URL patterns\", async () => {\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: \"/store/item/:id\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/store/item/:id\"],\n\t\t\t\t\t[\"de\", \"/laden/artikel/:id\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpattern: \"/blog/:slug\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/blog/:slug\"],\n\t\t\t\t\t[\"de\", \"/blog/:slug\"], // Same pattern for both locales\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst urls = runtime.generateStaticLocalizedUrls([\n\t\t\"https://example.com/store/item/123\",\n\t\t\"https://example.com/store/item/456\",\n\t\t\"https://example.com/blog/my-post\",\n\t]);\n\n\tconst pathnames = urls.map((url) => url.pathname).sort();\n\n\texpect(pathnames).toEqual([\n\t\t\"/blog/my-post\",\n\t\t\"/laden/artikel/123\",\n\t\t\"/laden/artikel/456\",\n\t\t\"/store/item/123\",\n\t\t\"/store/item/456\",\n\t]);\n\n\t// All URLs should be URL objects\n\texpect(urls.every((url) => url instanceof URL)).toBe(true);\n});\n\ntest(\"handles paths that don't match any pattern by including them\", async () => {\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: \"https://example.com/store/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/store/:path*\"],\n\t\t\t\t\t[\"de\", \"https://example.com/laden/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst urls = runtime.generateStaticLocalizedUrls([\n\t\t\"https://example.com/store/item/123\", // Should match pattern\n\t\t\"https://example.com/about\", // Should not match pattern\n\t\t\"https://example.com/contact\", // Should not match pattern\n\t]);\n\n\tconst pathnames = urls.map((url) => url.pathname).sort();\n\n\texpect(pathnames).toEqual([\n\t\t\"/about\",\n\t\t\"/contact\",\n\t\t\"/laden/item/123\",\n\t\t\"/store/item/123\",\n\t]);\n\n\t// All URLs should be URL objects\n\texpect(urls.every((url) => url instanceof URL)).toBe(true);\n});\n\ntest(\"handles URL objects as input\", async () => {\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: \"/store/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/store/:path*\"],\n\t\t\t\t\t[\"de\", \"/laden/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst urls = runtime.generateStaticLocalizedUrls([\n\t\tnew URL(\"https://example.com/store/item/123?color=blue#reviews\"),\n\t\tnew URL(\"https://example.com/store/cart\"),\n\t\tnew URL(\"https://example.com/about\"), // Should not match pattern\n\t]);\n\n\tconst pathnames = urls.map((url) => url.pathname).sort();\n\n\texpect(pathnames).toEqual([\n\t\t\"/about\",\n\t\t\"/laden/cart\",\n\t\t\"/laden/item/123\",\n\t\t\"/store/cart\",\n\t\t\"/store/item/123\",\n\t]);\n\n\t// Verify search params and hash fragments are preserve\n\t// All URLs should be URL objects\n\texpect(urls.every((url) => url instanceof URL)).toBe(true);\n});\n\ntest(\"generates localized URLs from paths\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\tstrategy: [\"url\"],\n\t\t// undefined creates the default pattern\n\t\turlPatterns: undefined,\n\t});\n\n\tconst urls = runtime.generateStaticLocalizedUrls([\n\t\t\"/about\",\n\t\t\"/blog/post-1\",\n\t\t\"/contact\",\n\t]);\n\n\tconst pathnames = urls.map((url) => url.pathname).sort();\n\n\texpect(pathnames).toEqual([\n\t\t\"/about\",\n\t\t\"/blog/post-1\",\n\t\t\"/contact\",\n\t\t\"/de/about\",\n\t\t\"/de/blog/post-1\",\n\t\t\"/de/contact\",\n\t\t\"/fr/about\",\n\t\t\"/fr/blog/post-1\",\n\t\t\"/fr/contact\",\n\t]);\n\n\t// All URLs should be URL objects\n\texpect(urls.every((url) => url instanceof URL)).toBe(true);\n});\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the current locale.
|
|
3
|
+
*
|
|
4
|
+
* The locale is resolved using your configured strategies (URL, cookie, localStorage, etc.)
|
|
5
|
+
* in the order they are defined. In SSR contexts, the locale is retrieved from AsyncLocalStorage
|
|
6
|
+
* which is set by the `paraglideMiddleware()`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://paraglidejs.com/strategy - Configure locale detection strategies
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* if (getLocale() === 'de') {
|
|
12
|
+
* console.log('Germany 🇩🇪');
|
|
13
|
+
* } else if (getLocale() === 'nl') {
|
|
14
|
+
* console.log('Netherlands 🇳🇱');
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* @returns {Locale} The current locale.
|
|
18
|
+
*/
|
|
19
|
+
export declare let getLocale: () => Locale;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve locale for a given URL using route-aware strategies.
|
|
22
|
+
*
|
|
23
|
+
* @param {string | URL} url
|
|
24
|
+
* @returns {Locale}
|
|
25
|
+
*/
|
|
26
|
+
export declare function getLocaleForUrl(url: string | URL): Locale;
|
|
27
|
+
/**
|
|
28
|
+
* Overwrite the `getLocale()` function.
|
|
29
|
+
*
|
|
30
|
+
* Use this function to overwrite how the locale is resolved. This is useful
|
|
31
|
+
* for custom locale resolution or advanced use cases like SSG with concurrent rendering.
|
|
32
|
+
*
|
|
33
|
+
* @see https://paraglidejs.com/strategy
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* overwriteGetLocale(() => {
|
|
37
|
+
* return Cookies.get('locale') ?? baseLocale
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* @param {() => Locale} fn - The new implementation for `getLocale()`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const overwriteGetLocale: (fn: () => Locale) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-locale.js"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,IAAI,SAAS,QAFP,MAsCZ,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAHxB,MAAM,GAAG,GAGe,GAFtB,MAAM,CAmBlB;AAiED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,OAFpB,MAAM,MAAM,SAItB,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { assertIsLocale, toLocale } from "./check-locale.js";
|
|
2
|
+
import { extractLocaleFromCookie } from "./extract-locale-from-cookie.js";
|
|
3
|
+
import { extractLocaleFromNavigator } from "./extract-locale-from-navigator.js";
|
|
4
|
+
import { extractLocaleFromUrl } from "./extract-locale-from-url.js";
|
|
5
|
+
import { getStrategyForUrl } from "./route-strategy.js";
|
|
6
|
+
import { setLocale } from "./set-locale.js";
|
|
7
|
+
import { customClientStrategies, isCustomStrategy } from "./strategy.js";
|
|
8
|
+
import { baseLocale, isServer, localStorageKey, serverAsyncLocalStorage, experimentalStaticLocale, strategy, TREE_SHAKE_COOKIE_STRATEGY_USED, TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED, TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED, TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED, TREE_SHAKE_URL_STRATEGY_USED, } from "./variables.js";
|
|
9
|
+
/**
|
|
10
|
+
* This is a fallback to get started with a custom
|
|
11
|
+
* strategy and avoid type errors.
|
|
12
|
+
*
|
|
13
|
+
* The implementation is overwritten
|
|
14
|
+
* by `overwriteGetLocale()` and `defineSetLocale()`.
|
|
15
|
+
*
|
|
16
|
+
* @type {Locale | undefined}
|
|
17
|
+
*/
|
|
18
|
+
let _locale;
|
|
19
|
+
let localeInitiallySet = false;
|
|
20
|
+
/**
|
|
21
|
+
* Get the current locale.
|
|
22
|
+
*
|
|
23
|
+
* The locale is resolved using your configured strategies (URL, cookie, localStorage, etc.)
|
|
24
|
+
* in the order they are defined. In SSR contexts, the locale is retrieved from AsyncLocalStorage
|
|
25
|
+
* which is set by the `paraglideMiddleware()`.
|
|
26
|
+
*
|
|
27
|
+
* @see https://paraglidejs.com/strategy - Configure locale detection strategies
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* if (getLocale() === 'de') {
|
|
31
|
+
* console.log('Germany 🇩🇪');
|
|
32
|
+
* } else if (getLocale() === 'nl') {
|
|
33
|
+
* console.log('Netherlands 🇳🇱');
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* @returns {Locale} The current locale.
|
|
37
|
+
*/
|
|
38
|
+
export let getLocale = () => {
|
|
39
|
+
if (experimentalStaticLocale !== undefined) {
|
|
40
|
+
return experimentalStaticLocale;
|
|
41
|
+
}
|
|
42
|
+
// if running in a server-side rendering context
|
|
43
|
+
// retrieve the locale from the async local storage
|
|
44
|
+
if (serverAsyncLocalStorage) {
|
|
45
|
+
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
46
|
+
if (locale) {
|
|
47
|
+
return locale;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let strategyToUse = strategy;
|
|
51
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
52
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
53
|
+
}
|
|
54
|
+
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
55
|
+
if (resolved) {
|
|
56
|
+
if (!localeInitiallySet) {
|
|
57
|
+
_locale = resolved;
|
|
58
|
+
// https://github.com/opral/inlang-paraglide-js/issues/455
|
|
59
|
+
localeInitiallySet = true;
|
|
60
|
+
setLocale(resolved, { reload: false });
|
|
61
|
+
}
|
|
62
|
+
return resolved;
|
|
63
|
+
}
|
|
64
|
+
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Resolve locale for a given URL using route-aware strategies.
|
|
68
|
+
*
|
|
69
|
+
* @param {string | URL} url
|
|
70
|
+
* @returns {Locale}
|
|
71
|
+
*/
|
|
72
|
+
export function getLocaleForUrl(url) {
|
|
73
|
+
if (experimentalStaticLocale !== undefined) {
|
|
74
|
+
return experimentalStaticLocale;
|
|
75
|
+
}
|
|
76
|
+
const strategyToUse = getStrategyForUrl(url);
|
|
77
|
+
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof url === "string" ? url : url.href);
|
|
78
|
+
if (resolved) {
|
|
79
|
+
return resolved;
|
|
80
|
+
}
|
|
81
|
+
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @param {typeof strategy} strategyToUse
|
|
85
|
+
* @param {string | undefined} urlForUrlStrategy
|
|
86
|
+
* @returns {Locale | undefined}
|
|
87
|
+
*/
|
|
88
|
+
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
89
|
+
/** @type {string | undefined} */
|
|
90
|
+
let locale;
|
|
91
|
+
for (const strat of strategyToUse) {
|
|
92
|
+
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
93
|
+
locale = extractLocaleFromCookie();
|
|
94
|
+
}
|
|
95
|
+
else if (strat === "baseLocale") {
|
|
96
|
+
locale = baseLocale;
|
|
97
|
+
}
|
|
98
|
+
else if (TREE_SHAKE_URL_STRATEGY_USED &&
|
|
99
|
+
strat === "url" &&
|
|
100
|
+
!isServer &&
|
|
101
|
+
typeof urlForUrlStrategy === "string") {
|
|
102
|
+
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
103
|
+
}
|
|
104
|
+
else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED &&
|
|
105
|
+
strat === "globalVariable" &&
|
|
106
|
+
_locale !== undefined) {
|
|
107
|
+
locale = _locale;
|
|
108
|
+
}
|
|
109
|
+
else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED &&
|
|
110
|
+
strat === "preferredLanguage" &&
|
|
111
|
+
!isServer) {
|
|
112
|
+
locale = extractLocaleFromNavigator();
|
|
113
|
+
}
|
|
114
|
+
else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED &&
|
|
115
|
+
strat === "localStorage" &&
|
|
116
|
+
!isServer) {
|
|
117
|
+
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
118
|
+
}
|
|
119
|
+
else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
120
|
+
const handler = customClientStrategies.get(strat);
|
|
121
|
+
if (handler) {
|
|
122
|
+
const result = handler.getLocale();
|
|
123
|
+
// Handle both sync and async results - skip async in sync getLocale
|
|
124
|
+
if (result instanceof Promise) {
|
|
125
|
+
// Can't await in sync function, skip async strategies
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (result !== undefined) {
|
|
129
|
+
return assertIsLocale(result);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const matchedLocale = toLocale(locale);
|
|
134
|
+
if (matchedLocale) {
|
|
135
|
+
return matchedLocale;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Overwrite the `getLocale()` function.
|
|
142
|
+
*
|
|
143
|
+
* Use this function to overwrite how the locale is resolved. This is useful
|
|
144
|
+
* for custom locale resolution or advanced use cases like SSG with concurrent rendering.
|
|
145
|
+
*
|
|
146
|
+
* @see https://paraglidejs.com/strategy
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* overwriteGetLocale(() => {
|
|
150
|
+
* return Cookies.get('locale') ?? baseLocale
|
|
151
|
+
* });
|
|
152
|
+
*
|
|
153
|
+
* @param {() => Locale} fn - The new implementation for `getLocale()`.
|
|
154
|
+
*/
|
|
155
|
+
export const overwriteGetLocale = (fn) => {
|
|
156
|
+
getLocale = fn;
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=get-locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-locale.js","sourceRoot":"","sources":["../../../src/compiler/runtime/get-locale.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACN,UAAU,EACV,QAAQ,EACR,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB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ACR,CAAC;YACF,MAAM,GAAG,0BAA0B,EAAE,CAAC;QACvC,CAAC;aAAM,IACN,sCAAsC;YACtC,KAAK,KAAK,cAAc;YACxB,CAAC,QAAQ,EACR,CAAC;YACF,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,SAAS,CAAC;QAC7D,CAAC;aAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACzE,MAAM,OAAO,GAAG,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAClD,IAAI,OAAO,EAAE,CAAC;gBACb,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;gBACnC,oEAAoE;gBACpE,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;oBAC/B,sDAAsD;oBACtD,SAAS;gBACV,CAAC;gBACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC1B,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;QACF,CAAC;QAED,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,aAAa,EAAE,CAAC;YACnB,OAAO,aAAa,CAAC;QACtB,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,EAAE,EAAE;IACxC,SAAS,GAAG,EAAE,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { assertIsLocale, toLocale } from \"./check-locale.js\";\nimport { extractLocaleFromCookie } from \"./extract-locale-from-cookie.js\";\nimport { extractLocaleFromNavigator } from \"./extract-locale-from-navigator.js\";\nimport { extractLocaleFromUrl } from \"./extract-locale-from-url.js\";\nimport { getStrategyForUrl } from \"./route-strategy.js\";\nimport { setLocale } from \"./set-locale.js\";\nimport { customClientStrategies, isCustomStrategy } from \"./strategy.js\";\nimport {\n\tbaseLocale,\n\tisServer,\n\tlocalStorageKey,\n\tserverAsyncLocalStorage,\n\texperimentalStaticLocale,\n\tstrategy,\n\tTREE_SHAKE_COOKIE_STRATEGY_USED,\n\tTREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED,\n\tTREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED,\n\tTREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED,\n\tTREE_SHAKE_URL_STRATEGY_USED,\n} from \"./variables.js\";\n\n/**\n * This is a fallback to get started with a custom\n * strategy and avoid type errors.\n *\n * The implementation is overwritten\n * by `overwriteGetLocale()` and `defineSetLocale()`.\n *\n * @type {Locale | undefined}\n */\nlet _locale;\n\nlet localeInitiallySet = false;\n\n/**\n * Get the current locale.\n *\n * The locale is resolved using your configured strategies (URL, cookie, localStorage, etc.)\n * in the order they are defined. In SSR contexts, the locale is retrieved from AsyncLocalStorage\n * which is set by the `paraglideMiddleware()`.\n *\n * @see https://paraglidejs.com/strategy - Configure locale detection strategies\n *\n * @example\n * if (getLocale() === 'de') {\n * console.log('Germany 🇩🇪');\n * } else if (getLocale() === 'nl') {\n * console.log('Netherlands 🇳🇱');\n * }\n *\n * @returns {Locale} The current locale.\n */\nexport let getLocale = () => {\n\tif (experimentalStaticLocale !== undefined) {\n\t\treturn experimentalStaticLocale;\n\t}\n\n\t// if running in a server-side rendering context\n\t// retrieve the locale from the async local storage\n\tif (serverAsyncLocalStorage) {\n\t\tconst locale = serverAsyncLocalStorage?.getStore()?.locale;\n\t\tif (locale) {\n\t\t\treturn locale;\n\t\t}\n\t}\n\n\tlet strategyToUse = strategy;\n\tif (!isServer && typeof window !== \"undefined\" && window.location?.href) {\n\t\tstrategyToUse = getStrategyForUrl(window.location.href);\n\t}\n\n\tconst resolved = resolveLocaleWithStrategies(\n\t\tstrategyToUse,\n\t\ttypeof window !== \"undefined\" ? window.location?.href : undefined\n\t);\n\tif (resolved) {\n\t\tif (!localeInitiallySet) {\n\t\t\t_locale = resolved;\n\t\t\t// https://github.com/opral/inlang-paraglide-js/issues/455\n\t\t\tlocaleInitiallySet = true;\n\t\t\tsetLocale(resolved, { reload: false });\n\t\t}\n\t\treturn resolved;\n\t}\n\n\tthrow new Error(\n\t\t\"No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found\"\n\t);\n};\n\n/**\n * Resolve locale for a given URL using route-aware strategies.\n *\n * @param {string | URL} url\n * @returns {Locale}\n */\nexport function getLocaleForUrl(url) {\n\tif (experimentalStaticLocale !== undefined) {\n\t\treturn experimentalStaticLocale;\n\t}\n\n\tconst strategyToUse = getStrategyForUrl(url);\n\tconst resolved = resolveLocaleWithStrategies(\n\t\tstrategyToUse,\n\t\ttypeof url === \"string\" ? url : url.href\n\t);\n\tif (resolved) {\n\t\treturn resolved;\n\t}\n\n\tthrow new Error(\n\t\t\"No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found\"\n\t);\n}\n\n/**\n * @param {typeof strategy} strategyToUse\n * @param {string | undefined} urlForUrlStrategy\n * @returns {Locale | undefined}\n */\nfunction resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {\n\t/** @type {string | undefined} */\n\tlet locale;\n\n\tfor (const strat of strategyToUse) {\n\t\tif (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === \"cookie\") {\n\t\t\tlocale = extractLocaleFromCookie();\n\t\t} else if (strat === \"baseLocale\") {\n\t\t\tlocale = baseLocale;\n\t\t} else if (\n\t\t\tTREE_SHAKE_URL_STRATEGY_USED &&\n\t\t\tstrat === \"url\" &&\n\t\t\t!isServer &&\n\t\t\ttypeof urlForUrlStrategy === \"string\"\n\t\t) {\n\t\t\tlocale = extractLocaleFromUrl(urlForUrlStrategy);\n\t\t} else if (\n\t\t\tTREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED &&\n\t\t\tstrat === \"globalVariable\" &&\n\t\t\t_locale !== undefined\n\t\t) {\n\t\t\tlocale = _locale;\n\t\t} else if (\n\t\t\tTREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED &&\n\t\t\tstrat === \"preferredLanguage\" &&\n\t\t\t!isServer\n\t\t) {\n\t\t\tlocale = extractLocaleFromNavigator();\n\t\t} else if (\n\t\t\tTREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED &&\n\t\t\tstrat === \"localStorage\" &&\n\t\t\t!isServer\n\t\t) {\n\t\t\tlocale = localStorage.getItem(localStorageKey) ?? undefined;\n\t\t} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {\n\t\t\tconst handler = customClientStrategies.get(strat);\n\t\t\tif (handler) {\n\t\t\t\tconst result = handler.getLocale();\n\t\t\t\t// Handle both sync and async results - skip async in sync getLocale\n\t\t\t\tif (result instanceof Promise) {\n\t\t\t\t\t// Can't await in sync function, skip async strategies\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (result !== undefined) {\n\t\t\t\t\treturn assertIsLocale(result);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst matchedLocale = toLocale(locale);\n\t\tif (matchedLocale) {\n\t\t\treturn matchedLocale;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Overwrite the `getLocale()` function.\n *\n * Use this function to overwrite how the locale is resolved. This is useful\n * for custom locale resolution or advanced use cases like SSG with concurrent rendering.\n *\n * @see https://paraglidejs.com/strategy\n *\n * @example\n * overwriteGetLocale(() => {\n * return Cookies.get('locale') ?? baseLocale\n * });\n *\n * @param {() => Locale} fn - The new implementation for `getLocale()`.\n */\nexport const overwriteGetLocale = (fn) => {\n\tgetLocale = fn;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-locale.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-locale.test.ts"],"names":[],"mappings":""}
|