@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,295 @@
|
|
|
1
|
+
import { expect, test, vi } from "vitest";
|
|
2
|
+
import { createParaglide } from "../create-paraglide.js";
|
|
3
|
+
test("matching by strategy works", async () => {
|
|
4
|
+
const baseLocale = "en";
|
|
5
|
+
const runtime = await createParaglide({
|
|
6
|
+
baseLocale: "en",
|
|
7
|
+
locales: ["en", "de"],
|
|
8
|
+
strategy: ["cookie", "baseLocale"],
|
|
9
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
10
|
+
});
|
|
11
|
+
// @ts-expect-error - global variable definition
|
|
12
|
+
globalThis.document = {};
|
|
13
|
+
globalThis.document.cookie = "OTHER_COOKIE=blaba;";
|
|
14
|
+
const locale = runtime.getLocale();
|
|
15
|
+
expect(locale).toBe(baseLocale);
|
|
16
|
+
});
|
|
17
|
+
test("experimentalStaticLocale overrides runtime strategies", async () => {
|
|
18
|
+
const runtime = await createParaglide({
|
|
19
|
+
baseLocale: "en",
|
|
20
|
+
locales: ["en", "de"],
|
|
21
|
+
strategy: ["cookie", "baseLocale"],
|
|
22
|
+
experimentalStaticLocale: JSON.stringify("de"),
|
|
23
|
+
});
|
|
24
|
+
expect(runtime.getLocale()).toBe("de");
|
|
25
|
+
});
|
|
26
|
+
test("invalid experimentalStaticLocale throws during runtime creation", async () => {
|
|
27
|
+
await expect(createParaglide({
|
|
28
|
+
baseLocale: "en",
|
|
29
|
+
locales: ["en", "de"],
|
|
30
|
+
strategy: ["cookie", "baseLocale"],
|
|
31
|
+
experimentalStaticLocale: JSON.stringify("fr"),
|
|
32
|
+
})).rejects.toThrow("Invalid locale: fr. Expected one of: en, de");
|
|
33
|
+
});
|
|
34
|
+
test("throws if variable is used without baseLocale as fallback strategy", async () => {
|
|
35
|
+
const runtime = await createParaglide({
|
|
36
|
+
baseLocale: "en",
|
|
37
|
+
locales: ["en", "de"],
|
|
38
|
+
strategy: ["globalVariable"],
|
|
39
|
+
});
|
|
40
|
+
expect(() => runtime.getLocale()).toThrow();
|
|
41
|
+
runtime.setLocale("de");
|
|
42
|
+
expect(runtime.getLocale()).toBe("de");
|
|
43
|
+
});
|
|
44
|
+
test("retrieves the locale for a url pattern", async () => {
|
|
45
|
+
const runtime = await createParaglide({
|
|
46
|
+
baseLocale: "en",
|
|
47
|
+
locales: ["en", "de"],
|
|
48
|
+
strategy: ["url"],
|
|
49
|
+
isServer: "false",
|
|
50
|
+
urlPatterns: [
|
|
51
|
+
{
|
|
52
|
+
pattern: "https://example.:tld/:path*",
|
|
53
|
+
localized: [
|
|
54
|
+
["en", "https://example.com/:path*"],
|
|
55
|
+
["de", "https://example.de/:path*"],
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
globalThis.window = { location: { href: "https://example.com/page" } };
|
|
61
|
+
expect(runtime.getLocale()).toBe("en");
|
|
62
|
+
globalThis.window = { location: { href: "https://example.de/page" } };
|
|
63
|
+
expect(runtime.getLocale()).toBe("de");
|
|
64
|
+
});
|
|
65
|
+
test("url pattern strategy doesn't throw during SSR", async () => {
|
|
66
|
+
const runtime = await createParaglide({
|
|
67
|
+
baseLocale: "en",
|
|
68
|
+
locales: ["en", "de"],
|
|
69
|
+
strategy: ["url", "baseLocale"],
|
|
70
|
+
urlPatterns: [
|
|
71
|
+
{
|
|
72
|
+
pattern: "https://example.:tld/:path*",
|
|
73
|
+
localized: [
|
|
74
|
+
["en", "https://example.com/:path*"],
|
|
75
|
+
["de", "https://example.de/:path*"],
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
expect(() => runtime.getLocale()).not.toThrow();
|
|
81
|
+
});
|
|
82
|
+
test("doesn't throw for an old cookie locale", async () => {
|
|
83
|
+
const baseLocale = "en";
|
|
84
|
+
const runtime = await createParaglide({
|
|
85
|
+
baseLocale: "en",
|
|
86
|
+
locales: ["en", "de"],
|
|
87
|
+
strategy: ["cookie", "baseLocale"],
|
|
88
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
89
|
+
});
|
|
90
|
+
// @ts-expect-error - global variable definition
|
|
91
|
+
globalThis.document = {};
|
|
92
|
+
globalThis.document.cookie = "PARAGLIDE_LOCALE=fr;";
|
|
93
|
+
const locale = runtime.getLocale();
|
|
94
|
+
expect(locale).toBe(baseLocale);
|
|
95
|
+
});
|
|
96
|
+
test("returns the preferred locale from navigator.languages", async () => {
|
|
97
|
+
const originalNavigator = globalThis.navigator;
|
|
98
|
+
const runtime = await createParaglide({
|
|
99
|
+
baseLocale: "en",
|
|
100
|
+
locales: ["en", "fr", "de"],
|
|
101
|
+
isServer: "false",
|
|
102
|
+
strategy: ["preferredLanguage"],
|
|
103
|
+
});
|
|
104
|
+
// Mock navigator.languages
|
|
105
|
+
Object.defineProperty(globalThis, "navigator", {
|
|
106
|
+
value: {
|
|
107
|
+
languages: ["fr-FR", "en-US", "de"],
|
|
108
|
+
},
|
|
109
|
+
configurable: true,
|
|
110
|
+
});
|
|
111
|
+
expect(runtime.getLocale()).toBe("fr");
|
|
112
|
+
// Restore original navigator
|
|
113
|
+
Object.defineProperty(globalThis, "navigator", {
|
|
114
|
+
value: originalNavigator,
|
|
115
|
+
configurable: true,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
test("returns the locale from local storage", async () => {
|
|
119
|
+
const runtime = await createParaglide({
|
|
120
|
+
baseLocale: "en",
|
|
121
|
+
locales: ["en", "de"],
|
|
122
|
+
strategy: ["localStorage"],
|
|
123
|
+
localStorageKey: "PARAGLIDE_LOCALE",
|
|
124
|
+
isServer: "false",
|
|
125
|
+
});
|
|
126
|
+
// @ts-expect-error - global variable definition
|
|
127
|
+
globalThis.localStorage = {
|
|
128
|
+
setItem: vi.fn(),
|
|
129
|
+
getItem: vi.fn(() => "de"),
|
|
130
|
+
};
|
|
131
|
+
expect(runtime.getLocale()).toBe("de");
|
|
132
|
+
});
|
|
133
|
+
test("initially sets the locale after resolving it for the first time", async () => {
|
|
134
|
+
// Create runtime with multiple strategies
|
|
135
|
+
const runtime = await createParaglide({
|
|
136
|
+
baseLocale: "en",
|
|
137
|
+
locales: ["en", "de", "fr"],
|
|
138
|
+
strategy: ["url", "cookie"],
|
|
139
|
+
isServer: "false",
|
|
140
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
141
|
+
urlPatterns: [
|
|
142
|
+
{
|
|
143
|
+
pattern: "https://example.com/:path*",
|
|
144
|
+
localized: [
|
|
145
|
+
["en", "https://example.com/en/:path*"],
|
|
146
|
+
["de", "https://example.com/de/:path*"],
|
|
147
|
+
["fr", "https://example.com/fr/:path*"],
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
});
|
|
152
|
+
// Setup global objects for URL strategy
|
|
153
|
+
globalThis.window = {
|
|
154
|
+
// @ts-expect-error - global variable definition
|
|
155
|
+
location: {
|
|
156
|
+
hostname: "example.com",
|
|
157
|
+
href: "https://example.com/de/page",
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
// Create a spy on the internal _locale variable to verify it was set
|
|
161
|
+
// We can do this by checking if setLocale works without explicitly setting it first
|
|
162
|
+
// @ts-expect-error - global variable definition
|
|
163
|
+
globalThis.document = { cookie: "" };
|
|
164
|
+
// First call to getLocale should resolve and set the locale
|
|
165
|
+
expect(runtime.getLocale()).toBe("de");
|
|
166
|
+
// Cookie should be set, proving that the locale was initially set
|
|
167
|
+
expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=de; path=/; max-age=34560000");
|
|
168
|
+
expect(globalThis.window.location.href).toBe("https://example.com/de/page");
|
|
169
|
+
});
|
|
170
|
+
test("returns locale from custom strategy", async () => {
|
|
171
|
+
const runtime = await createParaglide({
|
|
172
|
+
baseLocale: "en",
|
|
173
|
+
locales: ["en", "fr", "de"],
|
|
174
|
+
strategy: ["custom-client", "baseLocale"],
|
|
175
|
+
isServer: "false",
|
|
176
|
+
});
|
|
177
|
+
runtime.defineCustomClientStrategy("custom-client", {
|
|
178
|
+
getLocale: () => "fr",
|
|
179
|
+
setLocale: () => { },
|
|
180
|
+
});
|
|
181
|
+
const locale = runtime.getLocale();
|
|
182
|
+
expect(locale).toBe("fr");
|
|
183
|
+
});
|
|
184
|
+
test("falls back to next strategy when custom strategy returns undefined", async () => {
|
|
185
|
+
const runtime = await createParaglide({
|
|
186
|
+
baseLocale: "en",
|
|
187
|
+
locales: ["en", "fr"],
|
|
188
|
+
strategy: ["custom-undefined", "baseLocale"],
|
|
189
|
+
isServer: "false",
|
|
190
|
+
});
|
|
191
|
+
runtime.defineCustomClientStrategy("custom-undefined", {
|
|
192
|
+
getLocale: () => undefined,
|
|
193
|
+
setLocale: () => { },
|
|
194
|
+
});
|
|
195
|
+
const locale = runtime.getLocale();
|
|
196
|
+
expect(locale).toBe("en"); // Should fall back to baseLocale
|
|
197
|
+
});
|
|
198
|
+
test("throws error if custom strategy returns invalid locale", async () => {
|
|
199
|
+
const runtime = await createParaglide({
|
|
200
|
+
baseLocale: "en",
|
|
201
|
+
locales: ["en", "fr"],
|
|
202
|
+
strategy: ["custom-invalid", "baseLocale"],
|
|
203
|
+
isServer: "false",
|
|
204
|
+
});
|
|
205
|
+
runtime.defineCustomClientStrategy("custom-invalid", {
|
|
206
|
+
getLocale: () => "invalid-locale",
|
|
207
|
+
setLocale: () => { },
|
|
208
|
+
});
|
|
209
|
+
expect(() => runtime.getLocale()).toThrow();
|
|
210
|
+
});
|
|
211
|
+
test("custom strategy takes precedence over built-in strategies in getLocale", async () => {
|
|
212
|
+
// @ts-expect-error - global variable definition
|
|
213
|
+
globalThis.document = { cookie: "PARAGLIDE_LOCALE=fr" };
|
|
214
|
+
const runtime = await createParaglide({
|
|
215
|
+
baseLocale: "en",
|
|
216
|
+
locales: ["en", "fr", "de"],
|
|
217
|
+
strategy: ["custom-priority", "cookie", "baseLocale"],
|
|
218
|
+
cookieName: "PARAGLIDE_LOCALE",
|
|
219
|
+
isServer: "false",
|
|
220
|
+
});
|
|
221
|
+
runtime.defineCustomClientStrategy("custom-priority", {
|
|
222
|
+
getLocale: () => "de",
|
|
223
|
+
setLocale: () => { },
|
|
224
|
+
});
|
|
225
|
+
const locale = runtime.getLocale();
|
|
226
|
+
expect(locale).toBe("de"); // Should use custom strategy, not cookie
|
|
227
|
+
});
|
|
228
|
+
test("multiple custom strategies work in order in getLocale", async () => {
|
|
229
|
+
const runtime = await createParaglide({
|
|
230
|
+
baseLocale: "en",
|
|
231
|
+
locales: ["en", "fr", "de"],
|
|
232
|
+
strategy: ["custom-first", "custom-second", "baseLocale"],
|
|
233
|
+
isServer: "false",
|
|
234
|
+
});
|
|
235
|
+
// Define two custom strategies
|
|
236
|
+
runtime.defineCustomClientStrategy("custom-first", {
|
|
237
|
+
getLocale: () => undefined, // This one returns undefined
|
|
238
|
+
setLocale: () => { },
|
|
239
|
+
});
|
|
240
|
+
runtime.defineCustomClientStrategy("custom-second", {
|
|
241
|
+
getLocale: () => "fr", // This one returns a locale
|
|
242
|
+
setLocale: () => { },
|
|
243
|
+
});
|
|
244
|
+
const locale = runtime.getLocale();
|
|
245
|
+
expect(locale).toBe("fr"); // Should use second custom strategy
|
|
246
|
+
});
|
|
247
|
+
test("custom strategy works with session storage simulation", async () => {
|
|
248
|
+
// Simulate a custom strategy that reads from session storage
|
|
249
|
+
let sessionData = "de";
|
|
250
|
+
const runtime = await createParaglide({
|
|
251
|
+
baseLocale: "en",
|
|
252
|
+
locales: ["en", "fr", "de"],
|
|
253
|
+
strategy: ["custom-session", "baseLocale"],
|
|
254
|
+
isServer: "false",
|
|
255
|
+
});
|
|
256
|
+
runtime.defineCustomClientStrategy("custom-session", {
|
|
257
|
+
getLocale: () => sessionData,
|
|
258
|
+
setLocale: (locale) => {
|
|
259
|
+
sessionData = locale;
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
const locale = runtime.getLocale();
|
|
263
|
+
expect(locale).toBe("de");
|
|
264
|
+
});
|
|
265
|
+
test("custom strategy integrates with locale initialization", async () => {
|
|
266
|
+
// @ts-expect-error - global variable definition
|
|
267
|
+
globalThis.window = {};
|
|
268
|
+
// Define a custom strategy that tracks if it was called
|
|
269
|
+
let getLocaleCalled = false;
|
|
270
|
+
let setLocaleCalled = false;
|
|
271
|
+
const runtime = await createParaglide({
|
|
272
|
+
baseLocale: "en",
|
|
273
|
+
locales: ["en", "fr", "de"],
|
|
274
|
+
strategy: ["custom-tracking"],
|
|
275
|
+
isServer: "false",
|
|
276
|
+
});
|
|
277
|
+
runtime.defineCustomClientStrategy("custom-tracking", {
|
|
278
|
+
getLocale: () => {
|
|
279
|
+
getLocaleCalled = true;
|
|
280
|
+
return "fr";
|
|
281
|
+
},
|
|
282
|
+
setLocale: () => {
|
|
283
|
+
setLocaleCalled = true;
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
// First call should trigger the custom strategy
|
|
287
|
+
const locale = runtime.getLocale();
|
|
288
|
+
expect(locale).toBe("fr");
|
|
289
|
+
expect(getLocaleCalled).toBe(true);
|
|
290
|
+
// Setting the locale should also call the custom strategy
|
|
291
|
+
runtime.setLocale("de");
|
|
292
|
+
// The locale should be set internally after first resolution
|
|
293
|
+
expect(setLocaleCalled).toBe(true);
|
|
294
|
+
});
|
|
295
|
+
//# sourceMappingURL=get-locale.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-locale.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/get-locale.test.ts"],"names":[],"mappings":"AAAA,O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\";\n\ntest(\"matching by strategy works\", async () => {\n\tconst baseLocale = \"en\";\n\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\tglobalThis.document.cookie = \"OTHER_COOKIE=blaba;\";\n\n\tconst locale = runtime.getLocale();\n\texpect(locale).toBe(baseLocale);\n});\n\ntest(\"experimentalStaticLocale overrides runtime strategies\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\texperimentalStaticLocale: JSON.stringify(\"de\"),\n\t});\n\n\texpect(runtime.getLocale()).toBe(\"de\");\n});\n\ntest(\"invalid experimentalStaticLocale throws during runtime creation\", async () => {\n\tawait expect(\n\t\tcreateParaglide({\n\t\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\t\texperimentalStaticLocale: JSON.stringify(\"fr\"),\n\t\t})\n\t).rejects.toThrow(\"Invalid locale: fr. Expected one of: en, de\");\n});\n\ntest(\"throws if variable is used without baseLocale as fallback strategy\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"globalVariable\"],\n\t});\n\n\texpect(() => runtime.getLocale()).toThrow();\n\n\truntime.setLocale(\"de\");\n\n\texpect(runtime.getLocale()).toBe(\"de\");\n});\n\ntest(\"retrieves the locale for a url pattern\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"url\"],\n\t\tisServer: \"false\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.:tld/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/:path*\"],\n\t\t\t\t\t[\"de\", \"https://example.de/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tglobalThis.window = { location: { href: \"https://example.com/page\" } } as any;\n\n\texpect(runtime.getLocale()).toBe(\"en\");\n\n\tglobalThis.window = { location: { href: \"https://example.de/page\" } } as any;\n\n\texpect(runtime.getLocale()).toBe(\"de\");\n});\n\ntest(\"url pattern strategy doesn't throw during SSR\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"url\", \"baseLocale\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.:tld/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/:path*\"],\n\t\t\t\t\t[\"de\", \"https://example.de/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(() => runtime.getLocale()).not.toThrow();\n});\n\ntest(\"doesn't throw for an old cookie locale\", async () => {\n\tconst baseLocale = \"en\";\n\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=fr;\";\n\n\tconst locale = runtime.getLocale();\n\texpect(locale).toBe(baseLocale);\n});\n\ntest(\"returns the preferred locale from navigator.languages\", async () => {\n\tconst originalNavigator = globalThis.navigator;\n\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\", \"de\"],\n\t\tisServer: \"false\",\n\t\tstrategy: [\"preferredLanguage\"],\n\t});\n\n\t// Mock navigator.languages\n\tObject.defineProperty(globalThis, \"navigator\", {\n\t\tvalue: {\n\t\t\tlanguages: [\"fr-FR\", \"en-US\", \"de\"],\n\t\t},\n\t\tconfigurable: true,\n\t});\n\n\texpect(runtime.getLocale()).toBe(\"fr\");\n\n\t// Restore original navigator\n\tObject.defineProperty(globalThis, \"navigator\", {\n\t\tvalue: originalNavigator,\n\t\tconfigurable: true,\n\t});\n});\n\ntest(\"returns the locale from local storage\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tstrategy: [\"localStorage\"],\n\t\tlocalStorageKey: \"PARAGLIDE_LOCALE\",\n\t\tisServer: \"false\",\n\t});\n\n\t// @ts-expect-error - global variable definition\n\tglobalThis.localStorage = {\n\t\tsetItem: vi.fn(),\n\t\tgetItem: vi.fn(() => \"de\"),\n\t};\n\n\texpect(runtime.getLocale()).toBe(\"de\");\n});\n\ntest(\"initially sets the locale after resolving it for the first time\", async () => {\n\t// Create runtime with multiple strategies\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\tstrategy: [\"url\", \"cookie\"],\n\t\tisServer: \"false\",\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path*\"],\n\t\t\t\t\t[\"de\", \"https://example.com/de/:path*\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Setup global objects for URL strategy\n\tglobalThis.window = {\n\t\t// @ts-expect-error - global variable definition\n\t\tlocation: {\n\t\t\thostname: \"example.com\",\n\t\t\thref: \"https://example.com/de/page\",\n\t\t},\n\t};\n\n\t// Create a spy on the internal _locale variable to verify it was set\n\t// We can do this by checking if setLocale works without explicitly setting it first\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = { cookie: \"\" };\n\n\t// First call to getLocale should resolve and set the locale\n\texpect(runtime.getLocale()).toBe(\"de\");\n\t// Cookie should be set, proving that the locale was initially set\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000\"\n\t);\n\texpect(globalThis.window.location.href).toBe(\"https://example.com/de/page\");\n});\n\ntest(\"returns locale from custom strategy\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\", \"de\"],\n\t\tstrategy: [\"custom-client\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-client\", {\n\t\tgetLocale: () => \"fr\",\n\t\tsetLocale: () => {},\n\t});\n\n\tconst locale = runtime.getLocale();\n\texpect(locale).toBe(\"fr\");\n});\n\ntest(\"falls back to next strategy when custom strategy returns undefined\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"custom-undefined\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-undefined\", {\n\t\tgetLocale: () => undefined,\n\t\tsetLocale: () => {},\n\t});\n\n\tconst locale = runtime.getLocale();\n\texpect(locale).toBe(\"en\"); // Should fall back to baseLocale\n});\n\ntest(\"throws error if custom strategy returns invalid locale\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\"],\n\t\tstrategy: [\"custom-invalid\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-invalid\", {\n\t\tgetLocale: () => \"invalid-locale\",\n\t\tsetLocale: () => {},\n\t});\n\n\texpect(() => runtime.getLocale()).toThrow();\n});\n\ntest(\"custom strategy takes precedence over built-in strategies in getLocale\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = { cookie: \"PARAGLIDE_LOCALE=fr\" };\n\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\", \"de\"],\n\t\tstrategy: [\"custom-priority\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-priority\", {\n\t\tgetLocale: () => \"de\",\n\t\tsetLocale: () => {},\n\t});\n\n\tconst locale = runtime.getLocale();\n\texpect(locale).toBe(\"de\"); // Should use custom strategy, not cookie\n});\n\ntest(\"multiple custom strategies work in order in getLocale\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\", \"de\"],\n\t\tstrategy: [\"custom-first\", \"custom-second\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\t// Define two custom strategies\n\truntime.defineCustomClientStrategy(\"custom-first\", {\n\t\tgetLocale: () => undefined, // This one returns undefined\n\t\tsetLocale: () => {},\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-second\", {\n\t\tgetLocale: () => \"fr\", // This one returns a locale\n\t\tsetLocale: () => {},\n\t});\n\n\tconst locale = runtime.getLocale();\n\texpect(locale).toBe(\"fr\"); // Should use second custom strategy\n});\n\ntest(\"custom strategy works with session storage simulation\", async () => {\n\t// Simulate a custom strategy that reads from session storage\n\tlet sessionData = \"de\";\n\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\", \"de\"],\n\t\tstrategy: [\"custom-session\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-session\", {\n\t\tgetLocale: () => sessionData,\n\t\tsetLocale: (locale) => {\n\t\t\tsessionData = locale;\n\t\t},\n\t});\n\n\tconst locale = runtime.getLocale();\n\texpect(locale).toBe(\"de\");\n});\n\ntest(\"custom strategy integrates with locale initialization\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\n\t// Define a custom strategy that tracks if it was called\n\tlet getLocaleCalled = false;\n\tlet setLocaleCalled = false;\n\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"fr\", \"de\"],\n\t\tstrategy: [\"custom-tracking\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-tracking\", {\n\t\tgetLocale: () => {\n\t\t\tgetLocaleCalled = true;\n\t\t\treturn \"fr\";\n\t\t},\n\t\tsetLocale: () => {\n\t\t\tsetLocaleCalled = true;\n\t\t},\n\t});\n\n\t// First call should trigger the custom strategy\n\tconst locale = runtime.getLocale();\n\texpect(locale).toBe(\"fr\");\n\texpect(getLocaleCalled).toBe(true);\n\n\t// Setting the locale should also call the custom strategy\n\truntime.setLocale(\"de\");\n\n\t// The locale should be set internally after first resolution\n\texpect(setLocaleCalled).toBe(true);\n});\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get writing direction for a locale.
|
|
3
|
+
*
|
|
4
|
+
* Uses `Intl.Locale` text info when available and falls back to a
|
|
5
|
+
* language-based RTL check for runtimes without `getTextInfo()`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* getTextDirection(); // "ltr" or "rtl" for current locale
|
|
9
|
+
* getTextDirection("ar"); // "rtl"
|
|
10
|
+
* getTextDirection("en"); // "ltr"
|
|
11
|
+
*
|
|
12
|
+
* @param {string} [locale] - Target locale. If not provided, uses `getLocale()`
|
|
13
|
+
* @returns {"ltr" | "rtl"}
|
|
14
|
+
*/
|
|
15
|
+
export declare function getTextDirection(locale?: string): "ltr" | "rtl";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-text-direction.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-text-direction.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,AAHpC,CACA,EADQ,MAG0C,GAFxC,KAAK,GAAG,KAAK,CAoBzB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getLocale } from "./get-locale.js";
|
|
2
|
+
const rtlLanguages = new Set([
|
|
3
|
+
"ar",
|
|
4
|
+
"dv",
|
|
5
|
+
"fa",
|
|
6
|
+
"he",
|
|
7
|
+
"ks",
|
|
8
|
+
"ku",
|
|
9
|
+
"ps",
|
|
10
|
+
"sd",
|
|
11
|
+
"ug",
|
|
12
|
+
"ur",
|
|
13
|
+
"yi",
|
|
14
|
+
]);
|
|
15
|
+
/**
|
|
16
|
+
* Get writing direction for a locale.
|
|
17
|
+
*
|
|
18
|
+
* Uses `Intl.Locale` text info when available and falls back to a
|
|
19
|
+
* language-based RTL check for runtimes without `getTextInfo()`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* getTextDirection(); // "ltr" or "rtl" for current locale
|
|
23
|
+
* getTextDirection("ar"); // "rtl"
|
|
24
|
+
* getTextDirection("en"); // "ltr"
|
|
25
|
+
*
|
|
26
|
+
* @param {string} [locale] - Target locale. If not provided, uses `getLocale()`
|
|
27
|
+
* @returns {"ltr" | "rtl"}
|
|
28
|
+
*/
|
|
29
|
+
export function getTextDirection(locale = getLocale()) {
|
|
30
|
+
try {
|
|
31
|
+
const intlLocale = /** @type {Intl.Locale & {
|
|
32
|
+
getTextInfo?: () => { direction?: string };
|
|
33
|
+
textInfo?: { direction?: string };
|
|
34
|
+
}} */ (new Intl.Locale(locale));
|
|
35
|
+
const direction = intlLocale.getTextInfo?.().direction ?? intlLocale.textInfo?.direction;
|
|
36
|
+
if (direction === "ltr" || direction === "rtl") {
|
|
37
|
+
return direction;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Ignore Intl.Locale parsing/runtime errors and use fallback below.
|
|
42
|
+
}
|
|
43
|
+
const language = locale.split("-")[0]?.toLowerCase();
|
|
44
|
+
return rtlLanguages.has(language ?? "") ? "rtl" : "ltr";
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=get-text-direction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-text-direction.js","sourceRoot":"","sources":["../../../src/compiler/runtime/get-text-direction.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC5B,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACJ,CAAC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAM,GAAG,SAAS,EAAE;IACpD,IAAI,CAAC;QACJ,MAAM,UAAU,GAAG;;;aAGd,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAChC,MAAM,SAAS,GACd,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,SAAS,IAAI,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC;QAExE,IAAI,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YAChD,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,oEAAoE;IACrE,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IACrD,OAAO,YAAY,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AACzD,CAAC","sourcesContent":["import { getLocale } from \"./get-locale.js\";\n\nconst rtlLanguages = new Set([\n\t\"ar\",\n\t\"dv\",\n\t\"fa\",\n\t\"he\",\n\t\"ks\",\n\t\"ku\",\n\t\"ps\",\n\t\"sd\",\n\t\"ug\",\n\t\"ur\",\n\t\"yi\",\n]);\n\n/**\n * Get writing direction for a locale.\n *\n * Uses `Intl.Locale` text info when available and falls back to a\n * language-based RTL check for runtimes without `getTextInfo()`.\n *\n * @example\n * getTextDirection(); // \"ltr\" or \"rtl\" for current locale\n * getTextDirection(\"ar\"); // \"rtl\"\n * getTextDirection(\"en\"); // \"ltr\"\n *\n * @param {string} [locale] - Target locale. If not provided, uses `getLocale()`\n * @returns {\"ltr\" | \"rtl\"}\n */\nexport function getTextDirection(locale = getLocale()) {\n\ttry {\n\t\tconst intlLocale = /** @type {Intl.Locale & {\n\t\t\tgetTextInfo?: () => { direction?: string };\n\t\t\ttextInfo?: { direction?: string };\n\t\t}} */ (new Intl.Locale(locale));\n\t\tconst direction =\n\t\t\tintlLocale.getTextInfo?.().direction ?? intlLocale.textInfo?.direction;\n\n\t\tif (direction === \"ltr\" || direction === \"rtl\") {\n\t\t\treturn direction;\n\t\t}\n\t} catch {\n\t\t// Ignore Intl.Locale parsing/runtime errors and use fallback below.\n\t}\n\n\tconst language = locale.split(\"-\")[0]?.toLowerCase();\n\treturn rtlLanguages.has(language ?? \"\") ? \"rtl\" : \"ltr\";\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-text-direction.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-text-direction.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { createParaglide } from "../create-paraglide.js";
|
|
3
|
+
const runtime = await createParaglide({
|
|
4
|
+
baseLocale: "en",
|
|
5
|
+
locales: ["en", "ar"],
|
|
6
|
+
});
|
|
7
|
+
test("returns direction for a provided locale", () => {
|
|
8
|
+
expect(runtime.getTextDirection("en")).toBe("ltr");
|
|
9
|
+
expect(runtime.getTextDirection("ar")).toBe("rtl");
|
|
10
|
+
});
|
|
11
|
+
test("uses current locale when no locale is provided", () => {
|
|
12
|
+
runtime.setLocale("ar", { reload: false });
|
|
13
|
+
expect(runtime.getTextDirection()).toBe("rtl");
|
|
14
|
+
runtime.setLocale("en", { reload: false });
|
|
15
|
+
expect(runtime.getTextDirection()).toBe("ltr");
|
|
16
|
+
});
|
|
17
|
+
test("falls back when Intl.Locale text info is unavailable", () => {
|
|
18
|
+
const OriginalLocale = Intl.Locale;
|
|
19
|
+
class MockLocale {
|
|
20
|
+
constructor(_locale) { }
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(Intl, "Locale", {
|
|
23
|
+
value: MockLocale,
|
|
24
|
+
configurable: true,
|
|
25
|
+
});
|
|
26
|
+
try {
|
|
27
|
+
expect(runtime.getTextDirection("ar")).toBe("rtl");
|
|
28
|
+
expect(runtime.getTextDirection("ug")).toBe("rtl");
|
|
29
|
+
expect(runtime.getTextDirection("sd")).toBe("rtl");
|
|
30
|
+
expect(runtime.getTextDirection("ks")).toBe("rtl");
|
|
31
|
+
expect(runtime.getTextDirection("en")).toBe("ltr");
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
Object.defineProperty(Intl, "Locale", {
|
|
35
|
+
value: OriginalLocale,
|
|
36
|
+
configurable: true,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=get-text-direction.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-text-direction.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/get-text-direction.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC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AAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;YAAS,CAAC;QACV,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE;YACrC,KAAK,EAAE,cAAc;YACrB,YAAY,EAAE,IAAI;SAClB,CAAC,CAAC;IACJ,CAAC;AACF,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\n\nconst runtime = await createParaglide({\n\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"ar\"],\n});\n\ntest(\"returns direction for a provided locale\", () => {\n\texpect(runtime.getTextDirection(\"en\")).toBe(\"ltr\");\n\texpect(runtime.getTextDirection(\"ar\")).toBe(\"rtl\");\n});\n\ntest(\"uses current locale when no locale is provided\", () => {\n\truntime.setLocale(\"ar\", { reload: false });\n\texpect(runtime.getTextDirection()).toBe(\"rtl\");\n\truntime.setLocale(\"en\", { reload: false });\n\texpect(runtime.getTextDirection()).toBe(\"ltr\");\n});\n\ntest(\"falls back when Intl.Locale text info is unavailable\", () => {\n\tconst OriginalLocale = Intl.Locale;\n\n\tclass MockLocale {\n\t\tconstructor(_locale: string) {}\n\t}\n\n\tObject.defineProperty(Intl, \"Locale\", {\n\t\tvalue: MockLocale,\n\t\tconfigurable: true,\n\t});\n\n\ttry {\n\t\texpect(runtime.getTextDirection(\"ar\")).toBe(\"rtl\");\n\t\texpect(runtime.getTextDirection(\"ug\")).toBe(\"rtl\");\n\t\texpect(runtime.getTextDirection(\"sd\")).toBe(\"rtl\");\n\t\texpect(runtime.getTextDirection(\"ks\")).toBe(\"rtl\");\n\t\texpect(runtime.getTextDirection(\"en\")).toBe(\"ltr\");\n\t} finally {\n\t\tObject.defineProperty(Intl, \"Locale\", {\n\t\t\tvalue: OriginalLocale,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n});\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The origin of the current URL.
|
|
3
|
+
*
|
|
4
|
+
* Defaults to "http://example.com" in non-browser environments. If this
|
|
5
|
+
* behavior is not desired, the implementation can be overwritten
|
|
6
|
+
* by `overwriteGetUrlOrigin()`.
|
|
7
|
+
*
|
|
8
|
+
* @type {() => string}
|
|
9
|
+
*/
|
|
10
|
+
export declare let getUrlOrigin: () => string;
|
|
11
|
+
/**
|
|
12
|
+
* Overwrite the getUrlOrigin function.
|
|
13
|
+
*
|
|
14
|
+
* Use this function in server environments to
|
|
15
|
+
* define how the URL origin is resolved.
|
|
16
|
+
*
|
|
17
|
+
* @param {() => string} fn - The new implementation for `getUrlOrigin()`.
|
|
18
|
+
*/
|
|
19
|
+
export declare let overwriteGetUrlOrigin: (fn: () => string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-url-origin.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-url-origin.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,IAAI,YAAY,EAFb,MAAM,MASf,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,IAAI,qBAAqB,OAFrB,MAAM,MAAM,SAItB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { serverAsyncLocalStorage } from "./variables.js";
|
|
2
|
+
/**
|
|
3
|
+
* The origin of the current URL.
|
|
4
|
+
*
|
|
5
|
+
* Defaults to "http://example.com" in non-browser environments. If this
|
|
6
|
+
* behavior is not desired, the implementation can be overwritten
|
|
7
|
+
* by `overwriteGetUrlOrigin()`.
|
|
8
|
+
*
|
|
9
|
+
* @type {() => string}
|
|
10
|
+
*/
|
|
11
|
+
export let getUrlOrigin = () => {
|
|
12
|
+
if (serverAsyncLocalStorage) {
|
|
13
|
+
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
14
|
+
}
|
|
15
|
+
else if (typeof window !== "undefined") {
|
|
16
|
+
return window.location.origin;
|
|
17
|
+
}
|
|
18
|
+
return "http://fallback.com";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Overwrite the getUrlOrigin function.
|
|
22
|
+
*
|
|
23
|
+
* Use this function in server environments to
|
|
24
|
+
* define how the URL origin is resolved.
|
|
25
|
+
*
|
|
26
|
+
* @param {() => string} fn - The new implementation for `getUrlOrigin()`.
|
|
27
|
+
*/
|
|
28
|
+
export let overwriteGetUrlOrigin = (fn) => {
|
|
29
|
+
getUrlOrigin = fn;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=get-url-origin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-url-origin.js","sourceRoot":"","sources":["../../../src/compiler/runtime/get-url-origin.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,CAAC,IAAI,YAAY,GAAG,GAAG,EAAE;IAC9B,IAAI,uBAAuB,EAAE,CAAC;QAC7B,OAAO,uBAAuB,CAAC,QAAQ,EAAE,EAAE,MAAM,IAAI,qBAAqB,CAAC;IAC5E,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAC1C,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC/B,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC9B,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,IAAI,qBAAqB,GAAG,CAAC,EAAE,EAAE,EAAE;IACzC,YAAY,GAAG,EAAE,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { serverAsyncLocalStorage } from \"./variables.js\";\n\n/**\n * The origin of the current URL.\n *\n * Defaults to \"http://example.com\" in non-browser environments. If this\n * behavior is not desired, the implementation can be overwritten\n * by `overwriteGetUrlOrigin()`.\n *\n * @type {() => string}\n */\nexport let getUrlOrigin = () => {\n\tif (serverAsyncLocalStorage) {\n\t\treturn serverAsyncLocalStorage.getStore()?.origin ?? \"http://fallback.com\";\n\t} else if (typeof window !== \"undefined\") {\n\t\treturn window.location.origin;\n\t}\n\treturn \"http://fallback.com\";\n};\n\n/**\n * Overwrite the getUrlOrigin function.\n *\n * Use this function in server environments to\n * define how the URL origin is resolved.\n *\n * @param {() => string} fn - The new implementation for `getUrlOrigin()`.\n */\nexport let overwriteGetUrlOrigin = (fn) => {\n\tgetUrlOrigin = fn;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-url-origin.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/get-url-origin.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { test, expect } from "vitest";
|
|
2
|
+
import { createParaglide } from "../create-paraglide.js";
|
|
3
|
+
test("returns a placeholder in server environment as placeholder to make dependent apis work", async () => {
|
|
4
|
+
const runtime = await createParaglide({
|
|
5
|
+
baseLocale: "en",
|
|
6
|
+
locales: ["en", "de"],
|
|
7
|
+
});
|
|
8
|
+
expect(runtime.getUrlOrigin()).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
test("returns the window.location.origin if available", async () => {
|
|
11
|
+
const runtime = await createParaglide({
|
|
12
|
+
baseLocale: "en",
|
|
13
|
+
locales: ["en", "de"],
|
|
14
|
+
});
|
|
15
|
+
globalThis.window = { location: { origin: "https://example.com" } };
|
|
16
|
+
expect(runtime.getUrlOrigin()).toBe("https://example.com");
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=get-url-origin.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-url-origin.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/get-url-origin.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,wFAAwF,EAAE,KAAK,IAAI,EAAE;IACzG,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;KACrB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAC9C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;IAClE,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;KACrB,CAAC,CAAC;IAEH,UAAU,CAAC,MAAM,GAAG,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE,EAAS,CAAC;IAE3E,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\n\ntest(\"returns a placeholder in server environment as placeholder to make dependent apis work\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t});\n\n\texpect(runtime.getUrlOrigin()).toBeDefined();\n});\n\ntest(\"returns the window.location.origin if available\", async () => {\n\tconst runtime = await createParaglide({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t});\n\n\tglobalThis.window = { location: { origin: \"https://example.com\" } } as any;\n\n\texpect(runtime.getUrlOrigin()).toBe(\"https://example.com\");\n});\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type HostRoutingRuleResolved = {
|
|
2
|
+
baseLocale: string;
|
|
3
|
+
locales: string[];
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {{ baseLocale: string, locales: string[] }} HostRoutingRuleResolved
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} hostname
|
|
10
|
+
* @returns {HostRoutingRuleResolved}
|
|
11
|
+
*/
|
|
12
|
+
export declare function getRoutingRule(hostname: string): HostRoutingRuleResolved;
|
|
13
|
+
/**
|
|
14
|
+
* @param {string | URL} url
|
|
15
|
+
* @returns {Locale}
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractLocaleFromUrlHostRouting(url: string | URL): Locale;
|
|
18
|
+
/**
|
|
19
|
+
* @param {string | URL} url
|
|
20
|
+
* @param {Locale} locale
|
|
21
|
+
* @returns {URL}
|
|
22
|
+
*/
|
|
23
|
+
export declare function localizeUrlHostRouting(url: string | URL, locale: Locale): URL;
|
|
24
|
+
/**
|
|
25
|
+
* @param {string | URL} url
|
|
26
|
+
* @returns {URL}
|
|
27
|
+
*/
|
|
28
|
+
export declare function deLocalizeUrlHostRouting(url: string | URL): URL;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-routing.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/host-routing.js"],"names":[],"mappings":"AAQG,YAAqD,uBAAuB,GAAlE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAyB;AAD/E;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAH5B,MAG4B,GAF1B,uBAAuB,CAUnC;AAkBD;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,GAAG,EAHxC,MAAM,GAAG,GAG+B,GAFtC,MAAM,CAQlB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAJ/B,MAAM,GAAG,GAIsB,EAAE,MAAM,EAHvC,MAGuC,GAFrC,GAAG,CAqBf;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAHjC,MAAM,GAAG,GAGwB,GAF/B,GAAG,CAcf"}
|