@sebbro/paraglide-lite 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/bin/run.js +4 -0
- package/dist/bundler-plugins/esbuild.d.ts +1 -0
- package/dist/bundler-plugins/esbuild.d.ts.map +1 -0
- package/dist/bundler-plugins/esbuild.js +4 -0
- package/dist/bundler-plugins/esbuild.js.map +1 -0
- package/dist/bundler-plugins/index.d.ts +6 -0
- package/dist/bundler-plugins/index.d.ts.map +1 -0
- package/dist/bundler-plugins/index.js +7 -0
- package/dist/bundler-plugins/index.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts +19 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.js +85 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts +2 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js +53 -0
- package/dist/bundler-plugins/lazy-modules/scan-message-keys.test.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/ssr.d.ts +31 -0
- package/dist/bundler-plugins/lazy-modules/ssr.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/ssr.js +42 -0
- package/dist/bundler-plugins/lazy-modules/ssr.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts +2 -0
- package/dist/bundler-plugins/lazy-modules/ssr.test.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/ssr.test.js +48 -0
- package/dist/bundler-plugins/lazy-modules/ssr.test.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts +7 -0
- package/dist/bundler-plugins/lazy-modules/virtual-ids.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/virtual-ids.js +30 -0
- package/dist/bundler-plugins/lazy-modules/virtual-ids.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/virtual.d.ts +86 -0
- package/dist/bundler-plugins/lazy-modules/virtual.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/virtual.js +2 -0
- package/dist/bundler-plugins/lazy-modules/virtual.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts +18 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.js +328 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.js.map +1 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts +2 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.test.d.ts.map +1 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js +45 -0
- package/dist/bundler-plugins/lazy-modules/vite-plugin.test.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/constants.d.ts +2 -0
- package/dist/bundler-plugins/per-locale-build/constants.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/constants.js +3 -0
- package/dist/bundler-plugins/per-locale-build/constants.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/index.d.ts +6 -0
- package/dist/bundler-plugins/per-locale-build/index.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/index.js +43 -0
- package/dist/bundler-plugins/per-locale-build/index.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/locale-id.d.ts +8 -0
- package/dist/bundler-plugins/per-locale-build/locale-id.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/locale-id.js +13 -0
- package/dist/bundler-plugins/per-locale-build/locale-id.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/types.d.ts +4 -0
- package/dist/bundler-plugins/per-locale-build/types.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/types.js +2 -0
- package/dist/bundler-plugins/per-locale-build/types.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts +51 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.js +250 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.js.map +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.d.ts.map +1 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +250 -0
- package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -0
- package/dist/bundler-plugins/plugin-core.d.ts +74 -0
- package/dist/bundler-plugins/plugin-core.d.ts.map +1 -0
- package/dist/bundler-plugins/plugin-core.js +292 -0
- package/dist/bundler-plugins/plugin-core.js.map +1 -0
- package/dist/bundler-plugins/rolldown.d.ts +10 -0
- package/dist/bundler-plugins/rolldown.d.ts.map +1 -0
- package/dist/bundler-plugins/rolldown.js +36 -0
- package/dist/bundler-plugins/rolldown.js.map +1 -0
- package/dist/bundler-plugins/rolldown.test.d.ts +1 -0
- package/dist/bundler-plugins/rolldown.test.d.ts.map +1 -0
- package/dist/bundler-plugins/rolldown.test.js +72 -0
- package/dist/bundler-plugins/rolldown.test.js.map +1 -0
- package/dist/bundler-plugins/rollup.d.ts +1 -0
- package/dist/bundler-plugins/rollup.d.ts.map +1 -0
- package/dist/bundler-plugins/rollup.js +4 -0
- package/dist/bundler-plugins/rollup.js.map +1 -0
- package/dist/bundler-plugins/rspack.d.ts +1 -0
- package/dist/bundler-plugins/rspack.d.ts.map +1 -0
- package/dist/bundler-plugins/rspack.js +4 -0
- package/dist/bundler-plugins/rspack.js.map +1 -0
- package/dist/bundler-plugins/unplugin.d.ts +3 -0
- package/dist/bundler-plugins/unplugin.d.ts.map +1 -0
- package/dist/bundler-plugins/unplugin.js +62 -0
- package/dist/bundler-plugins/unplugin.js.map +1 -0
- package/dist/bundler-plugins/unplugin.test.d.ts +1 -0
- package/dist/bundler-plugins/unplugin.test.d.ts.map +1 -0
- package/dist/bundler-plugins/unplugin.test.js +256 -0
- package/dist/bundler-plugins/unplugin.test.js.map +1 -0
- package/dist/bundler-plugins/virtual-modules.test.d.ts +1 -0
- package/dist/bundler-plugins/virtual-modules.test.d.ts.map +1 -0
- package/dist/bundler-plugins/virtual-modules.test.js +77 -0
- package/dist/bundler-plugins/virtual-modules.test.js.map +1 -0
- package/dist/bundler-plugins/vite.d.ts +17 -0
- package/dist/bundler-plugins/vite.d.ts.map +1 -0
- package/dist/bundler-plugins/vite.js +15 -0
- package/dist/bundler-plugins/vite.js.map +1 -0
- package/dist/bundler-plugins/vite.test.d.ts +1 -0
- package/dist/bundler-plugins/vite.test.d.ts.map +1 -0
- package/dist/bundler-plugins/vite.test.js +61 -0
- package/dist/bundler-plugins/vite.test.js.map +1 -0
- package/dist/bundler-plugins/webpack.d.ts +1 -0
- package/dist/bundler-plugins/webpack.d.ts.map +1 -0
- package/dist/bundler-plugins/webpack.js +4 -0
- package/dist/bundler-plugins/webpack.js.map +1 -0
- package/dist/cli/commands/compile/command.d.ts +2 -0
- package/dist/cli/commands/compile/command.d.ts.map +1 -0
- package/dist/cli/commands/compile/command.js +225 -0
- package/dist/cli/commands/compile/command.js.map +1 -0
- package/dist/cli/commands/compile/command.test.d.ts +1 -0
- package/dist/cli/commands/compile/command.test.d.ts.map +1 -0
- package/dist/cli/commands/compile/command.test.js +69 -0
- package/dist/cli/commands/compile/command.test.js.map +1 -0
- package/dist/cli/commands/init/command.d.ts +2 -0
- package/dist/cli/commands/init/command.d.ts.map +1 -0
- package/dist/cli/commands/init/command.js +90 -0
- package/dist/cli/commands/init/command.js.map +1 -0
- package/dist/cli/defaults.d.ts +11 -0
- package/dist/cli/defaults.d.ts.map +1 -0
- package/dist/cli/defaults.js +13 -0
- package/dist/cli/defaults.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +11 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/steps/add-vite-plugin.d.ts +31 -0
- package/dist/cli/steps/add-vite-plugin.d.ts.map +1 -0
- package/dist/cli/steps/add-vite-plugin.js +65 -0
- package/dist/cli/steps/add-vite-plugin.js.map +1 -0
- package/dist/cli/steps/add-vite-plugin.test.d.ts +1 -0
- package/dist/cli/steps/add-vite-plugin.test.d.ts.map +1 -0
- package/dist/cli/steps/add-vite-plugin.test.js +74 -0
- package/dist/cli/steps/add-vite-plugin.test.js.map +1 -0
- package/dist/cli/steps/check-for-uncomitted-changes.d.ts +5 -0
- package/dist/cli/steps/check-for-uncomitted-changes.d.ts.map +1 -0
- package/dist/cli/steps/check-for-uncomitted-changes.js +37 -0
- package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -0
- package/dist/cli/steps/detect-bundler.d.ts +10 -0
- package/dist/cli/steps/detect-bundler.d.ts.map +1 -0
- package/dist/cli/steps/detect-bundler.js +22 -0
- package/dist/cli/steps/detect-bundler.js.map +1 -0
- package/dist/cli/steps/detect-bundler.test.d.ts +1 -0
- package/dist/cli/steps/detect-bundler.test.d.ts.map +1 -0
- package/dist/cli/steps/detect-bundler.test.js +29 -0
- package/dist/cli/steps/detect-bundler.test.js.map +1 -0
- package/dist/cli/steps/initialize-messages.d.ts +11 -0
- package/dist/cli/steps/initialize-messages.d.ts.map +1 -0
- package/dist/cli/steps/initialize-messages.js +31 -0
- package/dist/cli/steps/initialize-messages.js.map +1 -0
- package/dist/cli/steps/prompt-for-outdir.d.ts +8 -0
- package/dist/cli/steps/prompt-for-outdir.d.ts.map +1 -0
- package/dist/cli/steps/prompt-for-outdir.js +19 -0
- package/dist/cli/steps/prompt-for-outdir.js.map +1 -0
- package/dist/cli/steps/update-package-json.d.ts +11 -0
- package/dist/cli/steps/update-package-json.d.ts.map +1 -0
- package/dist/cli/steps/update-package-json.js +34 -0
- package/dist/cli/steps/update-package-json.js.map +1 -0
- package/dist/cli/steps/update-ts-config.d.ts +26 -0
- package/dist/cli/steps/update-ts-config.d.ts.map +1 -0
- package/dist/cli/steps/update-ts-config.js +270 -0
- package/dist/cli/steps/update-ts-config.js.map +1 -0
- package/dist/cli/steps/update-ts-config.test.d.ts +1 -0
- package/dist/cli/steps/update-ts-config.test.d.ts.map +1 -0
- package/dist/cli/steps/update-ts-config.test.js +60 -0
- package/dist/cli/steps/update-ts-config.test.js.map +1 -0
- package/dist/cli/utils.d.ts +36 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +20 -0
- package/dist/cli/utils.js.map +1 -0
- package/dist/compiler/assert-url-pattern-available.d.ts +7 -0
- package/dist/compiler/assert-url-pattern-available.d.ts.map +1 -0
- package/dist/compiler/assert-url-pattern-available.js +17 -0
- package/dist/compiler/assert-url-pattern-available.js.map +1 -0
- package/dist/compiler/compile-annotation.d.ts +12 -0
- package/dist/compiler/compile-annotation.d.ts.map +1 -0
- package/dist/compiler/compile-annotation.js +136 -0
- package/dist/compiler/compile-annotation.js.map +1 -0
- package/dist/compiler/compile-bundle.d.ts +28 -0
- package/dist/compiler/compile-bundle.d.ts.map +1 -0
- package/dist/compiler/compile-bundle.js +431 -0
- package/dist/compiler/compile-bundle.js.map +1 -0
- package/dist/compiler/compile-bundle.test.d.ts +1 -0
- package/dist/compiler/compile-bundle.test.d.ts.map +1 -0
- package/dist/compiler/compile-bundle.test.js +399 -0
- package/dist/compiler/compile-bundle.test.js.map +1 -0
- package/dist/compiler/compile-local-variable.d.ts +16 -0
- package/dist/compiler/compile-local-variable.d.ts.map +1 -0
- package/dist/compiler/compile-local-variable.js +28 -0
- package/dist/compiler/compile-local-variable.js.map +1 -0
- package/dist/compiler/compile-local-variable.test.d.ts +1 -0
- package/dist/compiler/compile-local-variable.test.d.ts.map +1 -0
- package/dist/compiler/compile-local-variable.test.js +359 -0
- package/dist/compiler/compile-local-variable.test.js.map +1 -0
- package/dist/compiler/compile-message.d.ts +8 -0
- package/dist/compiler/compile-message.d.ts.map +1 -0
- package/dist/compiler/compile-message.js +174 -0
- package/dist/compiler/compile-message.js.map +1 -0
- package/dist/compiler/compile-message.test.d.ts +1 -0
- package/dist/compiler/compile-message.test.d.ts.map +1 -0
- package/dist/compiler/compile-message.test.js +1060 -0
- package/dist/compiler/compile-message.test.js.map +1 -0
- package/dist/compiler/compile-pattern.d.ts +29 -0
- package/dist/compiler/compile-pattern.d.ts.map +1 -0
- package/dist/compiler/compile-pattern.js +143 -0
- package/dist/compiler/compile-pattern.js.map +1 -0
- package/dist/compiler/compile-pattern.test.d.ts +1 -0
- package/dist/compiler/compile-pattern.test.d.ts.map +1 -0
- package/dist/compiler/compile-pattern.test.js +255 -0
- package/dist/compiler/compile-pattern.test.js.map +1 -0
- package/dist/compiler/compile-project.d.ts +21 -0
- package/dist/compiler/compile-project.d.ts.map +1 -0
- package/dist/compiler/compile-project.js +147 -0
- package/dist/compiler/compile-project.js.map +1 -0
- package/dist/compiler/compile-project.test.d.ts +1 -0
- package/dist/compiler/compile-project.test.d.ts.map +1 -0
- package/dist/compiler/compile-project.test.js +1709 -0
- package/dist/compiler/compile-project.test.js.map +1 -0
- package/dist/compiler/compile.bench.d.ts +1 -0
- package/dist/compiler/compile.bench.d.ts.map +1 -0
- package/dist/compiler/compile.bench.js +89 -0
- package/dist/compiler/compile.bench.js.map +1 -0
- package/dist/compiler/compile.d.ts +24 -0
- package/dist/compiler/compile.d.ts.map +1 -0
- package/dist/compiler/compile.js +106 -0
- package/dist/compiler/compile.js.map +1 -0
- package/dist/compiler/compile.test.d.ts +1 -0
- package/dist/compiler/compile.test.d.ts.map +1 -0
- package/dist/compiler/compile.test.js +66 -0
- package/dist/compiler/compile.test.js.map +1 -0
- package/dist/compiler/compiler-options.d.ts +466 -0
- package/dist/compiler/compiler-options.d.ts.map +1 -0
- package/dist/compiler/compiler-options.js +22 -0
- package/dist/compiler/compiler-options.js.map +1 -0
- package/dist/compiler/create-paraglide.d.ts +21 -0
- package/dist/compiler/create-paraglide.d.ts.map +1 -0
- package/dist/compiler/create-paraglide.js +69 -0
- package/dist/compiler/create-paraglide.js.map +1 -0
- package/dist/compiler/create-paraglide.test.d.ts +1 -0
- package/dist/compiler/create-paraglide.test.d.ts.map +1 -0
- package/dist/compiler/create-paraglide.test.js +55 -0
- package/dist/compiler/create-paraglide.test.js.map +1 -0
- package/dist/compiler/create-readme.d.ts +9 -0
- package/dist/compiler/create-readme.d.ts.map +1 -0
- package/dist/compiler/create-readme.js +127 -0
- package/dist/compiler/create-readme.js.map +1 -0
- package/dist/compiler/emit-files.d.ts +15 -0
- package/dist/compiler/emit-files.d.ts.map +1 -0
- package/dist/compiler/emit-files.js +58 -0
- package/dist/compiler/emit-files.js.map +1 -0
- package/dist/compiler/emit-files.test.d.ts +1 -0
- package/dist/compiler/emit-files.test.d.ts.map +1 -0
- package/dist/compiler/emit-files.test.js +43 -0
- package/dist/compiler/emit-files.test.js.map +1 -0
- package/dist/compiler/emit-ts-declarations.d.ts +11 -0
- package/dist/compiler/emit-ts-declarations.d.ts.map +1 -0
- package/dist/compiler/emit-ts-declarations.interop.test.d.ts +1 -0
- package/dist/compiler/emit-ts-declarations.interop.test.d.ts.map +1 -0
- package/dist/compiler/emit-ts-declarations.interop.test.js +33 -0
- package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -0
- package/dist/compiler/emit-ts-declarations.js +353 -0
- package/dist/compiler/emit-ts-declarations.js.map +1 -0
- package/dist/compiler/emit-ts-declarations.test.d.ts +1 -0
- package/dist/compiler/emit-ts-declarations.test.d.ts.map +1 -0
- package/dist/compiler/emit-ts-declarations.test.js +161 -0
- package/dist/compiler/emit-ts-declarations.test.js.map +1 -0
- package/dist/compiler/index.d.ts +13 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +11 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/jsdoc-types.d.ts +21 -0
- package/dist/compiler/jsdoc-types.d.ts.map +1 -0
- package/dist/compiler/jsdoc-types.js +59 -0
- package/dist/compiler/jsdoc-types.js.map +1 -0
- package/dist/compiler/jsdoc-types.test.d.ts +1 -0
- package/dist/compiler/jsdoc-types.test.d.ts.map +1 -0
- package/dist/compiler/jsdoc-types.test.js +100 -0
- package/dist/compiler/jsdoc-types.test.js.map +1 -0
- package/dist/compiler/lazy-modules/compile-cache.d.ts +37 -0
- package/dist/compiler/lazy-modules/compile-cache.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/compile-cache.js +34 -0
- package/dist/compiler/lazy-modules/compile-cache.js.map +1 -0
- package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts +2 -0
- package/dist/compiler/lazy-modules/compile-project.lazy.test.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/compile-project.lazy.test.js +65 -0
- package/dist/compiler/lazy-modules/compile-project.lazy.test.js.map +1 -0
- package/dist/compiler/lazy-modules/create-loader.d.ts +18 -0
- package/dist/compiler/lazy-modules/create-loader.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/create-loader.js +182 -0
- package/dist/compiler/lazy-modules/create-loader.js.map +1 -0
- package/dist/compiler/lazy-modules/create-loader.test.d.ts +2 -0
- package/dist/compiler/lazy-modules/create-loader.test.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/create-loader.test.js +82 -0
- package/dist/compiler/lazy-modules/create-loader.test.js.map +1 -0
- package/dist/compiler/lazy-modules/manifest.d.ts +32 -0
- package/dist/compiler/lazy-modules/manifest.d.ts.map +1 -0
- package/dist/compiler/lazy-modules/manifest.js +11 -0
- package/dist/compiler/lazy-modules/manifest.js.map +1 -0
- package/dist/compiler/match-literals.d.ts +2 -0
- package/dist/compiler/match-literals.d.ts.map +1 -0
- package/dist/compiler/match-literals.js +42 -0
- package/dist/compiler/match-literals.js.map +1 -0
- package/dist/compiler/output-structure/lazy-modules.d.ts +27 -0
- package/dist/compiler/output-structure/lazy-modules.d.ts.map +1 -0
- package/dist/compiler/output-structure/lazy-modules.js +157 -0
- package/dist/compiler/output-structure/lazy-modules.js.map +1 -0
- package/dist/compiler/output-structure/lazy-modules.test.d.ts +2 -0
- package/dist/compiler/output-structure/lazy-modules.test.d.ts.map +1 -0
- package/dist/compiler/output-structure/lazy-modules.test.js +128 -0
- package/dist/compiler/output-structure/lazy-modules.test.js.map +1 -0
- package/dist/compiler/output-structure/locale-modules.d.ts +4 -0
- package/dist/compiler/output-structure/locale-modules.d.ts.map +1 -0
- package/dist/compiler/output-structure/locale-modules.js +81 -0
- package/dist/compiler/output-structure/locale-modules.js.map +1 -0
- package/dist/compiler/output-structure/locale-modules.test.d.ts +1 -0
- package/dist/compiler/output-structure/locale-modules.test.d.ts.map +1 -0
- package/dist/compiler/output-structure/locale-modules.test.js +163 -0
- package/dist/compiler/output-structure/locale-modules.test.js.map +1 -0
- package/dist/compiler/output-structure/message-modules.d.ts +4 -0
- package/dist/compiler/output-structure/message-modules.d.ts.map +1 -0
- package/dist/compiler/output-structure/message-modules.js +100 -0
- package/dist/compiler/output-structure/message-modules.js.map +1 -0
- package/dist/compiler/output-structure/message-modules.test.d.ts +1 -0
- package/dist/compiler/output-structure/message-modules.test.d.ts.map +1 -0
- package/dist/compiler/output-structure/message-modules.test.js +148 -0
- package/dist/compiler/output-structure/message-modules.test.js.map +1 -0
- package/dist/compiler/per-locale-build.d.ts +2 -0
- package/dist/compiler/per-locale-build.d.ts.map +1 -0
- package/dist/compiler/per-locale-build.js +3 -0
- package/dist/compiler/per-locale-build.js.map +1 -0
- package/dist/compiler/registry.d.ts +13 -0
- package/dist/compiler/registry.d.ts.map +1 -0
- package/dist/compiler/registry.js +60 -0
- package/dist/compiler/registry.js.map +1 -0
- package/dist/compiler/resolve-tsc-js-path.d.ts +9 -0
- package/dist/compiler/resolve-tsc-js-path.d.ts.map +1 -0
- package/dist/compiler/resolve-tsc-js-path.js +23 -0
- package/dist/compiler/resolve-tsc-js-path.js.map +1 -0
- package/dist/compiler/runtime/check-locale.d.ts +31 -0
- package/dist/compiler/runtime/check-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/check-locale.js +51 -0
- package/dist/compiler/runtime/check-locale.js.map +1 -0
- package/dist/compiler/runtime/check-locale.test.d.ts +1 -0
- package/dist/compiler/runtime/check-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/check-locale.test.js +84 -0
- package/dist/compiler/runtime/check-locale.test.js.map +1 -0
- package/dist/compiler/runtime/create-runtime.d.ts +35 -0
- package/dist/compiler/runtime/create-runtime.d.ts.map +1 -0
- package/dist/compiler/runtime/create-runtime.js +196 -0
- package/dist/compiler/runtime/create-runtime.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +13 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.js +43 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js +149 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.d.ts +13 -0
- package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.js +45 -0
- package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.js +55 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts +12 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.js +33 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.test.js +45 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts +34 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.js +70 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.test.js +119 -0
- package/dist/compiler/runtime/extract-locale-from-request-async.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.d.ts +41 -0
- package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.js +96 -0
- package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.js +351 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.d.ts +11 -0
- package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.js +68 -0
- package/dist/compiler/runtime/extract-locale-from-url.js.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.d.ts +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.js +127 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.js.map +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts +44 -0
- package/dist/compiler/runtime/generate-static-localized-urls.d.ts.map +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.js +133 -0
- package/dist/compiler/runtime/generate-static-localized-urls.js.map +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.test.d.ts.map +1 -0
- package/dist/compiler/runtime/generate-static-localized-urls.test.js +159 -0
- package/dist/compiler/runtime/generate-static-localized-urls.test.js.map +1 -0
- package/dist/compiler/runtime/get-locale.d.ts +42 -0
- package/dist/compiler/runtime/get-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale.js +158 -0
- package/dist/compiler/runtime/get-locale.js.map +1 -0
- package/dist/compiler/runtime/get-locale.test.d.ts +1 -0
- package/dist/compiler/runtime/get-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale.test.js +295 -0
- package/dist/compiler/runtime/get-locale.test.js.map +1 -0
- package/dist/compiler/runtime/get-text-direction.d.ts +15 -0
- package/dist/compiler/runtime/get-text-direction.d.ts.map +1 -0
- package/dist/compiler/runtime/get-text-direction.js +46 -0
- package/dist/compiler/runtime/get-text-direction.js.map +1 -0
- package/dist/compiler/runtime/get-text-direction.test.d.ts +1 -0
- package/dist/compiler/runtime/get-text-direction.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-text-direction.test.js +40 -0
- package/dist/compiler/runtime/get-text-direction.test.js.map +1 -0
- package/dist/compiler/runtime/get-url-origin.d.ts +19 -0
- package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -0
- package/dist/compiler/runtime/get-url-origin.js +31 -0
- package/dist/compiler/runtime/get-url-origin.js.map +1 -0
- package/dist/compiler/runtime/get-url-origin.test.d.ts +1 -0
- package/dist/compiler/runtime/get-url-origin.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-url-origin.test.js +18 -0
- package/dist/compiler/runtime/get-url-origin.test.js.map +1 -0
- package/dist/compiler/runtime/host-routing.d.ts +28 -0
- package/dist/compiler/runtime/host-routing.d.ts.map +1 -0
- package/dist/compiler/runtime/host-routing.js +79 -0
- package/dist/compiler/runtime/host-routing.js.map +1 -0
- package/dist/compiler/runtime/host-routing.test.d.ts +1 -0
- package/dist/compiler/runtime/host-routing.test.d.ts.map +1 -0
- package/dist/compiler/runtime/host-routing.test.js +128 -0
- package/dist/compiler/runtime/host-routing.test.js.map +1 -0
- package/dist/compiler/runtime/localize-href.d.ts +84 -0
- package/dist/compiler/runtime/localize-href.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-href.js +115 -0
- package/dist/compiler/runtime/localize-href.js.map +1 -0
- package/dist/compiler/runtime/localize-href.test.d.ts +1 -0
- package/dist/compiler/runtime/localize-href.test.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-href.test.js +139 -0
- package/dist/compiler/runtime/localize-href.test.js.map +1 -0
- package/dist/compiler/runtime/localize-url.d.ts +95 -0
- package/dist/compiler/runtime/localize-url.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-url.js +327 -0
- package/dist/compiler/runtime/localize-url.js.map +1 -0
- package/dist/compiler/runtime/localize-url.test.d.ts +1 -0
- package/dist/compiler/runtime/localize-url.test.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-url.test.js +533 -0
- package/dist/compiler/runtime/localize-url.test.js.map +1 -0
- package/dist/compiler/runtime/route-strategy.d.ts +32 -0
- package/dist/compiler/runtime/route-strategy.d.ts.map +1 -0
- package/dist/compiler/runtime/route-strategy.js +72 -0
- package/dist/compiler/runtime/route-strategy.js.map +1 -0
- package/dist/compiler/runtime/set-locale.d.ts +46 -0
- package/dist/compiler/runtime/set-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/set-locale.js +172 -0
- package/dist/compiler/runtime/set-locale.js.map +1 -0
- package/dist/compiler/runtime/set-locale.test.d.ts +1 -0
- package/dist/compiler/runtime/set-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/set-locale.test.js +555 -0
- package/dist/compiler/runtime/set-locale.test.js.map +1 -0
- package/dist/compiler/runtime/should-redirect.d.ts +100 -0
- package/dist/compiler/runtime/should-redirect.d.ts.map +1 -0
- package/dist/compiler/runtime/should-redirect.js +155 -0
- package/dist/compiler/runtime/should-redirect.js.map +1 -0
- package/dist/compiler/runtime/should-redirect.test.d.ts +1 -0
- package/dist/compiler/runtime/should-redirect.test.d.ts.map +1 -0
- package/dist/compiler/runtime/should-redirect.test.js +270 -0
- package/dist/compiler/runtime/should-redirect.test.js.map +1 -0
- package/dist/compiler/runtime/strategy.d.ts +63 -0
- package/dist/compiler/runtime/strategy.d.ts.map +1 -0
- package/dist/compiler/runtime/strategy.js +65 -0
- package/dist/compiler/runtime/strategy.js.map +1 -0
- package/dist/compiler/runtime/strategy.test.d.ts +1 -0
- package/dist/compiler/runtime/strategy.test.d.ts.map +1 -0
- package/dist/compiler/runtime/strategy.test.js +90 -0
- package/dist/compiler/runtime/strategy.test.js.map +1 -0
- package/dist/compiler/runtime/track-message-call.d.ts +5 -0
- package/dist/compiler/runtime/track-message-call.d.ts.map +1 -0
- package/dist/compiler/runtime/track-message-call.js +14 -0
- package/dist/compiler/runtime/track-message-call.js.map +1 -0
- package/dist/compiler/runtime/track-message-call.test.d.ts +1 -0
- package/dist/compiler/runtime/track-message-call.test.d.ts.map +1 -0
- package/dist/compiler/runtime/track-message-call.test.js +22 -0
- package/dist/compiler/runtime/track-message-call.test.js.map +1 -0
- package/dist/compiler/runtime/type-definitions.d.ts +197 -0
- package/dist/compiler/runtime/type-definitions.d.ts.map +1 -0
- package/dist/compiler/runtime/type-definitions.js +150 -0
- package/dist/compiler/runtime/type-definitions.js.map +1 -0
- package/dist/compiler/runtime/type.d.ts +47 -0
- package/dist/compiler/runtime/type.d.ts.map +1 -0
- package/dist/compiler/runtime/type.js +2 -0
- package/dist/compiler/runtime/type.js.map +1 -0
- package/dist/compiler/runtime/type.test.d.ts +1 -0
- package/dist/compiler/runtime/type.test.d.ts.map +1 -0
- package/dist/compiler/runtime/type.test.js +153 -0
- package/dist/compiler/runtime/type.test.js.map +1 -0
- package/dist/compiler/runtime/url-pattern.d.ts +12 -0
- package/dist/compiler/runtime/url-pattern.d.ts.map +1 -0
- package/dist/compiler/runtime/url-pattern.js +35 -0
- package/dist/compiler/runtime/url-pattern.js.map +1 -0
- package/dist/compiler/runtime/variables.d.ts +128 -0
- package/dist/compiler/runtime/variables.d.ts.map +1 -0
- package/dist/compiler/runtime/variables.js +111 -0
- package/dist/compiler/runtime/variables.js.map +1 -0
- package/dist/compiler/safe-module-id.d.ts +7 -0
- package/dist/compiler/safe-module-id.d.ts.map +1 -0
- package/dist/compiler/safe-module-id.js +78 -0
- package/dist/compiler/safe-module-id.js.map +1 -0
- package/dist/compiler/safe-module-id.test.d.ts +1 -0
- package/dist/compiler/safe-module-id.test.d.ts.map +1 -0
- package/dist/compiler/safe-module-id.test.js +36 -0
- package/dist/compiler/safe-module-id.test.js.map +1 -0
- package/dist/compiler/seed-previous-compilation.d.ts +7 -0
- package/dist/compiler/seed-previous-compilation.d.ts.map +1 -0
- package/dist/compiler/seed-previous-compilation.js +9 -0
- package/dist/compiler/seed-previous-compilation.js.map +1 -0
- package/dist/compiler/server/create-server-file.d.ts +12 -0
- package/dist/compiler/server/create-server-file.d.ts.map +1 -0
- package/dist/compiler/server/create-server-file.js +91 -0
- package/dist/compiler/server/create-server-file.js.map +1 -0
- package/dist/compiler/server/create-server-file.test.d.ts +1 -0
- package/dist/compiler/server/create-server-file.test.d.ts.map +1 -0
- package/dist/compiler/server/create-server-file.test.js +48 -0
- package/dist/compiler/server/create-server-file.test.js.map +1 -0
- package/dist/compiler/server/middleware.d.ts +98 -0
- package/dist/compiler/server/middleware.d.ts.map +1 -0
- package/dist/compiler/server/middleware.js +278 -0
- package/dist/compiler/server/middleware.js.map +1 -0
- package/dist/compiler/server/middleware.test.d.ts +1 -0
- package/dist/compiler/server/middleware.test.d.ts.map +1 -0
- package/dist/compiler/server/middleware.test.js +1001 -0
- package/dist/compiler/server/middleware.test.js.map +1 -0
- package/dist/compiler/server/type.d.ts +6 -0
- package/dist/compiler/server/type.d.ts.map +1 -0
- package/dist/compiler/server/type.js +2 -0
- package/dist/compiler/server/type.js.map +1 -0
- package/dist/compiler/test-helpers.d.ts +30 -0
- package/dist/compiler/test-helpers.d.ts.map +1 -0
- package/dist/compiler/test-helpers.js +50 -0
- package/dist/compiler/test-helpers.js.map +1 -0
- package/dist/compiler/types.d.ts +7 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/compiler/types.js +2 -0
- package/dist/compiler/types.js.map +1 -0
- package/dist/compiler/variable-access.d.ts +3 -0
- package/dist/compiler/variable-access.d.ts.map +1 -0
- package/dist/compiler/variable-access.js +15 -0
- package/dist/compiler/variable-access.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/ast.d.ts +102 -0
- package/dist/messages/ast.d.ts.map +1 -0
- package/dist/messages/ast.js +8 -0
- package/dist/messages/ast.js.map +1 -0
- package/dist/messages/create-bundle-nested.d.ts +16 -0
- package/dist/messages/create-bundle-nested.d.ts.map +1 -0
- package/dist/messages/create-bundle-nested.js +22 -0
- package/dist/messages/create-bundle-nested.js.map +1 -0
- package/dist/messages/index.d.ts +5 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/index.js +5 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/messages/load-messages.d.ts +19 -0
- package/dist/messages/load-messages.d.ts.map +1 -0
- package/dist/messages/load-messages.js +49 -0
- package/dist/messages/load-messages.js.map +1 -0
- package/dist/messages/message-format/flatten.d.ts +9 -0
- package/dist/messages/message-format/flatten.d.ts.map +1 -0
- package/dist/messages/message-format/flatten.js +32 -0
- package/dist/messages/message-format/flatten.js.map +1 -0
- package/dist/messages/message-format/import-files.d.ts +32 -0
- package/dist/messages/message-format/import-files.d.ts.map +1 -0
- package/dist/messages/message-format/import-files.js +53 -0
- package/dist/messages/message-format/import-files.js.map +1 -0
- package/dist/messages/message-format/import-files.test.d.ts +1 -0
- package/dist/messages/message-format/import-files.test.d.ts.map +1 -0
- package/dist/messages/message-format/import-files.test.js +145 -0
- package/dist/messages/message-format/import-files.test.js.map +1 -0
- package/dist/messages/message-format/index.d.ts +6 -0
- package/dist/messages/message-format/index.d.ts.map +1 -0
- package/dist/messages/message-format/index.js +7 -0
- package/dist/messages/message-format/index.js.map +1 -0
- package/dist/messages/message-format/parse-bundle.d.ts +31 -0
- package/dist/messages/message-format/parse-bundle.d.ts.map +1 -0
- package/dist/messages/message-format/parse-bundle.js +169 -0
- package/dist/messages/message-format/parse-bundle.js.map +1 -0
- package/dist/messages/message-format/parse-declaration.d.ts +2 -0
- package/dist/messages/message-format/parse-declaration.d.ts.map +1 -0
- package/dist/messages/message-format/parse-declaration.js +56 -0
- package/dist/messages/message-format/parse-declaration.js.map +1 -0
- package/dist/messages/message-format/parse-markup.d.ts +4 -0
- package/dist/messages/message-format/parse-markup.d.ts.map +1 -0
- package/dist/messages/message-format/parse-markup.js +167 -0
- package/dist/messages/message-format/parse-markup.js.map +1 -0
- package/dist/messages/message-format/parse-matches.d.ts +5 -0
- package/dist/messages/message-format/parse-matches.d.ts.map +1 -0
- package/dist/messages/message-format/parse-matches.js +31 -0
- package/dist/messages/message-format/parse-matches.js.map +1 -0
- package/dist/messages/message-format/parse-pattern.d.ts +5 -0
- package/dist/messages/message-format/parse-pattern.d.ts.map +1 -0
- package/dist/messages/message-format/parse-pattern.js +120 -0
- package/dist/messages/message-format/parse-pattern.js.map +1 -0
- package/dist/messages/message-format/unique.d.ts +2 -0
- package/dist/messages/message-format/unique.d.ts.map +1 -0
- package/dist/messages/message-format/unique.js +5 -0
- package/dist/messages/message-format/unique.js.map +1 -0
- package/dist/messages/nest-bundles.d.ts +19 -0
- package/dist/messages/nest-bundles.d.ts.map +1 -0
- package/dist/messages/nest-bundles.js +49 -0
- package/dist/messages/nest-bundles.js.map +1 -0
- package/dist/services/account/index.d.ts +14 -0
- package/dist/services/account/index.d.ts.map +1 -0
- package/dist/services/account/index.js +43 -0
- package/dist/services/account/index.js.map +1 -0
- package/dist/services/account/types.d.ts +4 -0
- package/dist/services/account/types.d.ts.map +1 -0
- package/dist/services/account/types.js +2 -0
- package/dist/services/account/types.js.map +1 -0
- package/dist/services/codegen/escape.d.ts +9 -0
- package/dist/services/codegen/escape.d.ts.map +1 -0
- package/dist/services/codegen/escape.js +19 -0
- package/dist/services/codegen/escape.js.map +1 -0
- package/dist/services/codegen/quotes.d.ts +4 -0
- package/dist/services/codegen/quotes.d.ts.map +1 -0
- package/dist/services/codegen/quotes.js +5 -0
- package/dist/services/codegen/quotes.js.map +1 -0
- package/dist/services/env-variables/create-index-file.d.ts +9 -0
- package/dist/services/env-variables/create-index-file.d.ts.map +1 -0
- package/dist/services/env-variables/create-index-file.js +28 -0
- package/dist/services/env-variables/create-index-file.js.map +1 -0
- package/dist/services/env-variables/index.d.ts +3 -0
- package/dist/services/env-variables/index.d.ts.map +1 -0
- package/dist/services/env-variables/index.js +4 -0
- package/dist/services/env-variables/index.js.map +1 -0
- package/dist/services/environment/package.d.ts +9 -0
- package/dist/services/environment/package.d.ts.map +1 -0
- package/dist/services/environment/package.js +31 -0
- package/dist/services/environment/package.js.map +1 -0
- package/dist/services/environment/package.test.d.ts +1 -0
- package/dist/services/environment/package.test.d.ts.map +1 -0
- package/dist/services/environment/package.test.js +21 -0
- package/dist/services/environment/package.test.js.map +1 -0
- package/dist/services/error-handling.d.ts +12 -0
- package/dist/services/error-handling.d.ts.map +1 -0
- package/dist/services/error-handling.js +27 -0
- package/dist/services/error-handling.js.map +1 -0
- package/dist/services/error-handling.test.d.ts +1 -0
- package/dist/services/error-handling.test.d.ts.map +1 -0
- package/dist/services/error-handling.test.js +10 -0
- package/dist/services/error-handling.test.js.map +1 -0
- package/dist/services/file-handling/content-hash.d.ts +9 -0
- package/dist/services/file-handling/content-hash.js +19 -0
- package/dist/services/file-handling/content-hash.js.map +1 -0
- package/dist/services/file-handling/exists.d.ts +7 -0
- package/dist/services/file-handling/exists.d.ts.map +1 -0
- package/dist/services/file-handling/exists.js +24 -0
- package/dist/services/file-handling/exists.js.map +1 -0
- package/dist/services/file-handling/exists.test.d.ts +1 -0
- package/dist/services/file-handling/exists.test.d.ts.map +1 -0
- package/dist/services/file-handling/exists.test.js +27 -0
- package/dist/services/file-handling/exists.test.js.map +1 -0
- package/dist/services/file-handling/types.d.ts +4 -0
- package/dist/services/file-handling/types.d.ts.map +1 -0
- package/dist/services/file-handling/types.js +2 -0
- package/dist/services/file-handling/types.js.map +1 -0
- package/dist/services/file-handling/write-output.d.ts +21 -0
- package/dist/services/file-handling/write-output.d.ts.map +1 -0
- package/dist/services/file-handling/write-output.js +157 -0
- package/dist/services/file-handling/write-output.js.map +1 -0
- package/dist/services/file-handling/write-output.test.d.ts +1 -0
- package/dist/services/file-handling/write-output.test.d.ts.map +1 -0
- package/dist/services/file-handling/write-output.test.js +217 -0
- package/dist/services/file-handling/write-output.test.js.map +1 -0
- package/dist/services/file-watching/tracked-fs.d.ts +25 -0
- package/dist/services/file-watching/tracked-fs.d.ts.map +1 -0
- package/dist/services/file-watching/tracked-fs.js +94 -0
- package/dist/services/file-watching/tracked-fs.js.map +1 -0
- package/dist/services/file-watching/tracked-fs.test.d.ts +1 -0
- package/dist/services/file-watching/tracked-fs.test.d.ts.map +1 -0
- package/dist/services/file-watching/tracked-fs.test.js +87 -0
- package/dist/services/file-watching/tracked-fs.test.js.map +1 -0
- package/dist/services/logger/index.d.ts +17 -0
- package/dist/services/logger/index.d.ts.map +1 -0
- package/dist/services/logger/index.js +58 -0
- package/dist/services/logger/index.js.map +1 -0
- package/dist/services/lookup.d.ts +14 -0
- package/dist/services/lookup.d.ts.map +1 -0
- package/dist/services/lookup.js +24 -0
- package/dist/services/lookup.js.map +1 -0
- package/dist/urlpattern-polyfill/index.d.ts +2 -0
- package/dist/urlpattern-polyfill/index.d.ts.map +1 -0
- package/dist/urlpattern-polyfill/index.js +2 -0
- package/dist/urlpattern-polyfill/index.js.map +1 -0
- package/dist/utilities/detect-json-formatting.d.ts +10 -0
- package/dist/utilities/detect-json-formatting.d.ts.map +1 -0
- package/dist/utilities/detect-json-formatting.js +80 -0
- package/dist/utilities/detect-json-formatting.js.map +1 -0
- package/dist/utilities/node-normalize-path.d.ts +1 -0
- package/dist/utilities/node-normalize-path.d.ts.map +1 -0
- package/dist/utilities/node-normalize-path.js +10 -0
- package/dist/utilities/node-normalize-path.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAwB,MAAM,WAAW,CAAC;AA2B1D,eAAO,MAAM,cAAc,SA0TzB,CAAC"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Command, InvalidArgumentError } from "commander";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { resolve, relative } from "node:path";
|
|
4
|
+
import { Logger } from "../../../services/logger/index.js";
|
|
5
|
+
import { DEFAULT_BASE_LOCALE, DEFAULT_LOCALES, DEFAULT_MESSAGES, DEFAULT_OUTDIR } from "../../defaults.js";
|
|
6
|
+
import { compile } from "../../../compiler/compile.js";
|
|
7
|
+
import { seedPreviousCompilationFromOutdir } from "../../../compiler/seed-previous-compilation.js";
|
|
8
|
+
import { defaultCompilerOptions, } from "../../../compiler/compiler-options.js";
|
|
9
|
+
import { createTrackedFs, getWatchTargets, } from "../../../services/file-watching/tracked-fs.js";
|
|
10
|
+
const parseOutputStructure = (value) => {
|
|
11
|
+
if (value === "message-modules" || value === "locale-modules") {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
throw new InvalidArgumentError(`Invalid output structure "${value}". Expected "message-modules" or "locale-modules".`);
|
|
15
|
+
};
|
|
16
|
+
export const compileCommand = new Command()
|
|
17
|
+
.name("compile")
|
|
18
|
+
.summary("Compiles paraglide-lite message files")
|
|
19
|
+
.option("--messages <path>", 'Path pattern for locale files. Example: "./messages/{locale}.json"', DEFAULT_MESSAGES)
|
|
20
|
+
.option("--locales <items...>", "Locales to compile. Example: --locales en de", [...DEFAULT_LOCALES])
|
|
21
|
+
.option("--base-locale <locale>", "Base locale for fallbacks", DEFAULT_BASE_LOCALE)
|
|
22
|
+
.requiredOption("--outdir <path>", 'The path to the output directory. Example: "./src/paraglide"', DEFAULT_OUTDIR)
|
|
23
|
+
.option("--strategy <items...>", [
|
|
24
|
+
"The strategy to be used.",
|
|
25
|
+
"",
|
|
26
|
+
"Example: --strategy cookie globalVariable baseLocale",
|
|
27
|
+
"Upstream docs: https://paraglidejs.com/strategy",
|
|
28
|
+
].join("\n"))
|
|
29
|
+
.requiredOption("--silent", "Only log errors to the console", false)
|
|
30
|
+
.option("--emit-ts-declarations", "Emit .d.ts files for the generated output (requires the typescript package)", defaultCompilerOptions.emitTsDeclarations)
|
|
31
|
+
.option("--no-emit-ts-declarations", "Do not emit .d.ts files for the generated output")
|
|
32
|
+
.option("--emit-git-ignore", "Emit a .gitignore in the output directory", defaultCompilerOptions.emitGitIgnore)
|
|
33
|
+
.option("--no-emit-git-ignore", "Do not emit a .gitignore in the output directory")
|
|
34
|
+
.option("--emit-prettier-ignore", "Emit a .prettierignore in the output directory", defaultCompilerOptions.emitPrettierIgnore)
|
|
35
|
+
.option("--no-emit-prettier-ignore", "Do not emit a .prettierignore in the output directory")
|
|
36
|
+
.option("--emit-readme", "Emit a README.md in the output directory (helps LLMs understand the generated code)", defaultCompilerOptions.emitReadme)
|
|
37
|
+
.option("--no-emit-readme", "Do not emit README.md in the output directory")
|
|
38
|
+
.option("--is-server <expression>", [
|
|
39
|
+
"JavaScript expression for runtime `isServer` (enables server/client tree-shaking).",
|
|
40
|
+
'Quote if the expression contains spaces, e.g. --is-server \'typeof window === "undefined"\'.',
|
|
41
|
+
"Vite SSR example: --is-server 'import.meta.env.SSR'",
|
|
42
|
+
].join(" "))
|
|
43
|
+
.option("--output-structure <structure>", [
|
|
44
|
+
'The output structure for compiled messages. Either "message-modules" or "locale-modules".',
|
|
45
|
+
"",
|
|
46
|
+
'"message-modules" gives each message its own module (better tree-shaking).',
|
|
47
|
+
'"locale-modules" bundles messages per locale (fewer files, better for large projects in dev).',
|
|
48
|
+
].join("\n"), parseOutputStructure, defaultCompilerOptions.outputStructure)
|
|
49
|
+
.option("--watch", "Watch message files and recompile on change", false)
|
|
50
|
+
.action(async (options) => {
|
|
51
|
+
const logger = new Logger({ silent: options.silent, prefix: true });
|
|
52
|
+
const compileOptions = {
|
|
53
|
+
messages: options.messages,
|
|
54
|
+
locales: options.locales,
|
|
55
|
+
baseLocale: options.baseLocale,
|
|
56
|
+
outdir: options.outdir,
|
|
57
|
+
strategy: options.strategy ?? defaultCompilerOptions.strategy,
|
|
58
|
+
emitTsDeclarations: options.emitTsDeclarations ??
|
|
59
|
+
defaultCompilerOptions.emitTsDeclarations,
|
|
60
|
+
emitGitIgnore: options.emitGitIgnore ?? defaultCompilerOptions.emitGitIgnore,
|
|
61
|
+
emitPrettierIgnore: options.emitPrettierIgnore ??
|
|
62
|
+
defaultCompilerOptions.emitPrettierIgnore,
|
|
63
|
+
emitReadme: options.emitReadme ?? defaultCompilerOptions.emitReadme,
|
|
64
|
+
isServer: options.isServer ?? defaultCompilerOptions.isServer,
|
|
65
|
+
outputStructure: options.outputStructure ??
|
|
66
|
+
defaultCompilerOptions.outputStructure,
|
|
67
|
+
// CLI always writes the full output tree to disk.
|
|
68
|
+
emitFiles: true,
|
|
69
|
+
};
|
|
70
|
+
if (!options.watch) {
|
|
71
|
+
logger.info(`Compiling messages ...`);
|
|
72
|
+
try {
|
|
73
|
+
await compile(compileOptions);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
logger.error("Error while compiling messages.");
|
|
77
|
+
logger.error(e);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
logger.success(`Successfully compiled messages.`);
|
|
81
|
+
process.exit(0);
|
|
82
|
+
}
|
|
83
|
+
const { fs: trackedFs, readFiles, clearReadFiles } = createTrackedFs();
|
|
84
|
+
const fileWatchers = new Map();
|
|
85
|
+
const directoryWatchers = new Map();
|
|
86
|
+
let previousCompilation;
|
|
87
|
+
let compileTimer;
|
|
88
|
+
let compileInProgress = false;
|
|
89
|
+
let compileRequested = false;
|
|
90
|
+
const updateWatchers = (files) => {
|
|
91
|
+
const { files: nextFiles, directories: nextDirectories, isIgnoredPath, } = getWatchTargets(files, { outdir: options.outdir });
|
|
92
|
+
for (const [filePath, watcher] of fileWatchers) {
|
|
93
|
+
if (!nextFiles.has(filePath)) {
|
|
94
|
+
watcher.close();
|
|
95
|
+
fileWatchers.delete(filePath);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (const [directoryPath, watcher] of directoryWatchers) {
|
|
99
|
+
if (!nextDirectories.has(directoryPath)) {
|
|
100
|
+
watcher.close();
|
|
101
|
+
directoryWatchers.delete(directoryPath);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const attachWatcherErrorHandler = (watcher, targetPath, targetType) => {
|
|
105
|
+
watcher.on("error", (error) => {
|
|
106
|
+
logger.warn(`Watch ${targetType} error for ${targetPath}: ${error.message}`);
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
for (const filePath of nextFiles) {
|
|
110
|
+
if (fileWatchers.has(filePath)) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const watcher = fs.watch(filePath, () => {
|
|
115
|
+
scheduleCompile(filePath);
|
|
116
|
+
});
|
|
117
|
+
attachWatcherErrorHandler(watcher, filePath, "file");
|
|
118
|
+
fileWatchers.set(filePath, watcher);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
logger.warn(`Failed to watch file: ${filePath}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
for (const directoryPath of nextDirectories) {
|
|
125
|
+
if (directoryWatchers.has(directoryPath)) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const watcher = fs.watch(directoryPath, (eventType, filename) => {
|
|
130
|
+
if (!filename) {
|
|
131
|
+
scheduleCompile(directoryPath);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const changedPath = resolve(directoryPath, filename.toString());
|
|
135
|
+
if (isIgnoredPath(changedPath)) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
scheduleCompile(changedPath);
|
|
139
|
+
});
|
|
140
|
+
attachWatcherErrorHandler(watcher, directoryPath, "directory");
|
|
141
|
+
directoryWatchers.set(directoryPath, watcher);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
logger.warn(`Failed to watch directory: ${directoryPath}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const runCompile = async (changedPath) => {
|
|
149
|
+
if (compileInProgress) {
|
|
150
|
+
compileRequested = true;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
compileInProgress = true;
|
|
154
|
+
const previouslyReadFiles = new Set(readFiles);
|
|
155
|
+
clearReadFiles();
|
|
156
|
+
if (changedPath) {
|
|
157
|
+
logger.info(`Re-compiling messages... File "${relative(process.cwd(), changedPath)}" has changed.`);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
logger.info("Compiling messages ...");
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const seededPrevious = previousCompilation ??
|
|
164
|
+
(await seedPreviousCompilationFromOutdir({
|
|
165
|
+
outdir: compileOptions.outdir,
|
|
166
|
+
}));
|
|
167
|
+
previousCompilation = await compile({
|
|
168
|
+
...compileOptions,
|
|
169
|
+
fs: trackedFs,
|
|
170
|
+
previousCompilation: seededPrevious,
|
|
171
|
+
cleanOutdir: false,
|
|
172
|
+
});
|
|
173
|
+
if (changedPath) {
|
|
174
|
+
logger.success("Re-compilation complete.");
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
logger.success("Successfully compiled messages.");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
if (previouslyReadFiles.size > 0) {
|
|
182
|
+
clearReadFiles();
|
|
183
|
+
for (const filePath of previouslyReadFiles) {
|
|
184
|
+
readFiles.add(filePath);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
previousCompilation = undefined;
|
|
188
|
+
logger.error("Error while compiling messages.");
|
|
189
|
+
logger.error(e);
|
|
190
|
+
}
|
|
191
|
+
finally {
|
|
192
|
+
updateWatchers(readFiles);
|
|
193
|
+
compileInProgress = false;
|
|
194
|
+
if (compileRequested) {
|
|
195
|
+
compileRequested = false;
|
|
196
|
+
runCompile();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const scheduleCompile = (changedPath) => {
|
|
201
|
+
if (compileTimer) {
|
|
202
|
+
clearTimeout(compileTimer);
|
|
203
|
+
}
|
|
204
|
+
compileTimer = setTimeout(() => {
|
|
205
|
+
runCompile(changedPath);
|
|
206
|
+
}, 100);
|
|
207
|
+
};
|
|
208
|
+
const closeWatchers = () => {
|
|
209
|
+
for (const watcher of fileWatchers.values()) {
|
|
210
|
+
watcher.close();
|
|
211
|
+
}
|
|
212
|
+
for (const watcher of directoryWatchers.values()) {
|
|
213
|
+
watcher.close();
|
|
214
|
+
}
|
|
215
|
+
fileWatchers.clear();
|
|
216
|
+
directoryWatchers.clear();
|
|
217
|
+
};
|
|
218
|
+
process.on("SIGINT", () => {
|
|
219
|
+
closeWatchers();
|
|
220
|
+
process.exit(0);
|
|
221
|
+
});
|
|
222
|
+
await runCompile();
|
|
223
|
+
logger.info("Watching for changes...");
|
|
224
|
+
});
|
|
225
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","s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CAAC,yBAAyB,CAAC,CAAC;AACxC,CAAC,CACD,CAAC","sourcesContent":["import { Command, InvalidArgumentError } from \"commander\";\nimport fs from \"node:fs\";\nimport { resolve, relative } from \"node:path\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport { DEFAULT_BASE_LOCALE, DEFAULT_LOCALES, DEFAULT_MESSAGES, DEFAULT_OUTDIR } from \"../../defaults.js\";\nimport { compile, type CompilationResult } from \"../../../compiler/compile.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../../../compiler/seed-previous-compilation.js\";\nimport {\n\tdefaultCompilerOptions,\n\ttype CompilerOptions,\n} from \"../../../compiler/compiler-options.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n} from \"../../../services/file-watching/tracked-fs.js\";\n\nconst parseOutputStructure = (\n\tvalue: string\n): NonNullable<CompilerOptions[\"outputStructure\"]> => {\n\tif (value === \"message-modules\" || value === \"locale-modules\") {\n\t\treturn value;\n\t}\n\tthrow new InvalidArgumentError(\n\t\t`Invalid output structure \"${value}\". Expected \"message-modules\" or \"locale-modules\".`\n\t);\n};\n\nexport const compileCommand = new Command()\n\t.name(\"compile\")\n\t.summary(\"Compiles paraglide-lite message files\")\n\t.option(\n\t\t\"--messages <path>\",\n\t\t'Path pattern for locale files. Example: \"./messages/{locale}.json\"',\n\t\tDEFAULT_MESSAGES\n\t)\n\t.option(\n\t\t\"--locales <items...>\",\n\t\t\"Locales to compile. Example: --locales en de\",\n\t\t[...DEFAULT_LOCALES]\n\t)\n\t.option(\n\t\t\"--base-locale <locale>\",\n\t\t\"Base locale for fallbacks\",\n\t\tDEFAULT_BASE_LOCALE\n\t)\n\t.requiredOption(\n\t\t\"--outdir <path>\",\n\t\t'The path to the output directory. Example: \"./src/paraglide\"',\n\t\tDEFAULT_OUTDIR\n\t)\n\t.option(\n\t\t\"--strategy <items...>\",\n\t\t[\n\t\t\t\"The strategy to be used.\",\n\t\t\t\"\",\n\t\t\t\"Example: --strategy cookie globalVariable baseLocale\",\n\t\t\t\"Upstream docs: https://paraglidejs.com/strategy\",\n\t\t].join(\"\\n\")\n\t)\n\t.requiredOption(\"--silent\", \"Only log errors to the console\", false)\n\t.option(\n\t\t\"--emit-ts-declarations\",\n\t\t\"Emit .d.ts files for the generated output (requires the typescript package)\",\n\t\tdefaultCompilerOptions.emitTsDeclarations\n\t)\n\t.option(\n\t\t\"--no-emit-ts-declarations\",\n\t\t\"Do not emit .d.ts files for the generated output\"\n\t)\n\t.option(\n\t\t\"--emit-git-ignore\",\n\t\t\"Emit a .gitignore in the output directory\",\n\t\tdefaultCompilerOptions.emitGitIgnore\n\t)\n\t.option(\n\t\t\"--no-emit-git-ignore\",\n\t\t\"Do not emit a .gitignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-prettier-ignore\",\n\t\t\"Emit a .prettierignore in the output directory\",\n\t\tdefaultCompilerOptions.emitPrettierIgnore\n\t)\n\t.option(\n\t\t\"--no-emit-prettier-ignore\",\n\t\t\"Do not emit a .prettierignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-readme\",\n\t\t\"Emit a README.md in the output directory (helps LLMs understand the generated code)\",\n\t\tdefaultCompilerOptions.emitReadme\n\t)\n\t.option(\n\t\t\"--no-emit-readme\",\n\t\t\"Do not emit README.md in the output directory\"\n\t)\n\t.option(\n\t\t\"--is-server <expression>\",\n\t\t[\n\t\t\t\"JavaScript expression for runtime `isServer` (enables server/client tree-shaking).\",\n\t\t\t'Quote if the expression contains spaces, e.g. --is-server \\'typeof window === \"undefined\"\\'.',\n\t\t\t\"Vite SSR example: --is-server 'import.meta.env.SSR'\",\n\t\t].join(\" \")\n\t)\n\t.option(\n\t\t\"--output-structure <structure>\",\n\t\t[\n\t\t\t'The output structure for compiled messages. Either \"message-modules\" or \"locale-modules\".',\n\t\t\t\"\",\n\t\t\t'\"message-modules\" gives each message its own module (better tree-shaking).',\n\t\t\t'\"locale-modules\" bundles messages per locale (fewer files, better for large projects in dev).',\n\t\t].join(\"\\n\"),\n\t\tparseOutputStructure,\n\t\tdefaultCompilerOptions.outputStructure\n\t)\n\t.option(\"--watch\", \"Watch message files and recompile on change\", false)\n\t.action(\n\t\tasync (options: {\n\t\t\tsilent: boolean;\n\t\t\tmessages: string;\n\t\t\tlocales: string[];\n\t\t\tbaseLocale: string;\n\t\t\toutdir: string;\n\t\t\tstrategy?: CompilerOptions[\"strategy\"];\n\t\t\temitTsDeclarations?: CompilerOptions[\"emitTsDeclarations\"];\n\t\t\temitGitIgnore?: CompilerOptions[\"emitGitIgnore\"];\n\t\t\temitPrettierIgnore?: CompilerOptions[\"emitPrettierIgnore\"];\n\t\t\temitReadme?: CompilerOptions[\"emitReadme\"];\n\t\t\tisServer?: CompilerOptions[\"isServer\"];\n\t\t\toutputStructure?: CompilerOptions[\"outputStructure\"];\n\t\t\twatch?: boolean;\n\t\t}) => {\n\t\t\tconst logger = new Logger({ silent: options.silent, prefix: true });\n\n\t\t\tconst compileOptions = {\n\t\t\t\tmessages: options.messages,\n\t\t\t\tlocales: options.locales,\n\t\t\t\tbaseLocale: options.baseLocale,\n\t\t\t\toutdir: options.outdir,\n\t\t\t\tstrategy: options.strategy ?? defaultCompilerOptions.strategy,\n\t\t\t\temitTsDeclarations:\n\t\t\t\t\toptions.emitTsDeclarations ??\n\t\t\t\t\tdefaultCompilerOptions.emitTsDeclarations,\n\t\t\t\temitGitIgnore:\n\t\t\t\t\toptions.emitGitIgnore ?? defaultCompilerOptions.emitGitIgnore,\n\t\t\t\temitPrettierIgnore:\n\t\t\t\t\toptions.emitPrettierIgnore ??\n\t\t\t\t\tdefaultCompilerOptions.emitPrettierIgnore,\n\t\t\t\temitReadme: options.emitReadme ?? defaultCompilerOptions.emitReadme,\n\t\t\t\tisServer: options.isServer ?? defaultCompilerOptions.isServer,\n\t\t\t\toutputStructure:\n\t\t\t\t\toptions.outputStructure ??\n\t\t\t\t\tdefaultCompilerOptions.outputStructure,\n\t\t\t\t// CLI always writes the full output tree to disk.\n\t\t\t\temitFiles: true as const,\n\t\t\t};\n\n\t\t\tif (!options.watch) {\n\t\t\t\tlogger.info(`Compiling messages ...`);\n\n\t\t\t\ttry {\n\t\t\t\t\tawait compile(compileOptions);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlogger.error(\"Error while compiling messages.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlogger.success(`Successfully compiled messages.`);\n\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\n\t\t\tconst { fs: trackedFs, readFiles, clearReadFiles } = createTrackedFs();\n\t\t\tconst fileWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tconst directoryWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tlet previousCompilation: CompilationResult | undefined;\n\t\t\tlet compileTimer: NodeJS.Timeout | undefined;\n\t\t\tlet compileInProgress = false;\n\t\t\tlet compileRequested = false;\n\n\t\t\tconst updateWatchers = (files: Set<string>) => {\n\t\t\t\tconst {\n\t\t\t\t\tfiles: nextFiles,\n\t\t\t\t\tdirectories: nextDirectories,\n\t\t\t\t\tisIgnoredPath,\n\t\t\t\t} = getWatchTargets(files, { outdir: options.outdir });\n\n\t\t\t\tfor (const [filePath, watcher] of fileWatchers) {\n\t\t\t\t\tif (!nextFiles.has(filePath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tfileWatchers.delete(filePath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const [directoryPath, watcher] of directoryWatchers) {\n\t\t\t\t\tif (!nextDirectories.has(directoryPath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tdirectoryWatchers.delete(directoryPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst attachWatcherErrorHandler = (\n\t\t\t\t\twatcher: fs.FSWatcher,\n\t\t\t\t\ttargetPath: string,\n\t\t\t\t\ttargetType: \"file\" | \"directory\"\n\t\t\t\t) => {\n\t\t\t\t\twatcher.on(\"error\", (error) => {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t`Watch ${targetType} error for ${targetPath}: ${(error as Error).message}`\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tfor (const filePath of nextFiles) {\n\t\t\t\t\tif (fileWatchers.has(filePath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(filePath, () => {\n\t\t\t\t\t\t\tscheduleCompile(filePath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, filePath, \"file\");\n\t\t\t\t\t\tfileWatchers.set(filePath, watcher);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlogger.warn(`Failed to watch file: ${filePath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const directoryPath of nextDirectories) {\n\t\t\t\t\tif (directoryWatchers.has(directoryPath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(directoryPath, (eventType, filename) => {\n\t\t\t\t\t\t\tif (!filename) {\n\t\t\t\t\t\t\t\tscheduleCompile(directoryPath);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst changedPath = resolve(directoryPath, filename.toString());\n\t\t\t\t\t\t\tif (isIgnoredPath(changedPath)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tscheduleCompile(changedPath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, directoryPath, \"directory\");\n\t\t\t\t\t\tdirectoryWatchers.set(directoryPath, watcher);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlogger.warn(`Failed to watch directory: ${directoryPath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst runCompile = async (changedPath?: string) => {\n\t\t\t\tif (compileInProgress) {\n\t\t\t\t\tcompileRequested = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcompileInProgress = true;\n\t\t\t\tconst previouslyReadFiles = new Set(readFiles);\n\t\t\t\tclearReadFiles();\n\n\t\t\t\tif (changedPath) {\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t`Re-compiling messages... File \"${relative(process.cwd(), changedPath)}\" has changed.`\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.info(\"Compiling messages ...\");\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tpreviousCompilation ??\n\t\t\t\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t\t}));\n\n\t\t\t\t\tpreviousCompilation = await compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tfs: trackedFs,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (changedPath) {\n\t\t\t\t\t\tlogger.success(\"Re-compilation complete.\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.success(\"Successfully compiled messages.\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (previouslyReadFiles.size > 0) {\n\t\t\t\t\t\tclearReadFiles();\n\t\t\t\t\t\tfor (const filePath of previouslyReadFiles) {\n\t\t\t\t\t\t\treadFiles.add(filePath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpreviousCompilation = undefined;\n\t\t\t\t\tlogger.error(\"Error while compiling messages.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t} finally {\n\t\t\t\t\tupdateWatchers(readFiles);\n\t\t\t\t\tcompileInProgress = false;\n\t\t\t\t\tif (compileRequested) {\n\t\t\t\t\t\tcompileRequested = false;\n\t\t\t\t\t\trunCompile();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleCompile = (changedPath?: string) => {\n\t\t\t\tif (compileTimer) {\n\t\t\t\t\tclearTimeout(compileTimer);\n\t\t\t\t}\n\t\t\t\tcompileTimer = setTimeout(() => {\n\t\t\t\t\trunCompile(changedPath);\n\t\t\t\t}, 100);\n\t\t\t};\n\n\t\t\tconst closeWatchers = () => {\n\t\t\t\tfor (const watcher of fileWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfor (const watcher of directoryWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfileWatchers.clear();\n\t\t\t\tdirectoryWatchers.clear();\n\t\t\t};\n\n\t\t\tprocess.on(\"SIGINT\", () => {\n\t\t\t\tcloseWatchers();\n\t\t\t\tprocess.exit(0);\n\t\t\t});\n\n\t\t\tawait runCompile();\n\t\t\tlogger.info(\"Watching for changes...\");\n\t\t}\n\t);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.test.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
2
|
+
import * as nodeFs from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { afterEach, beforeEach, expect, test, vi } from "vitest";
|
|
6
|
+
let testDirectories = [];
|
|
7
|
+
let initialSigintListeners = [];
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
vi.resetModules();
|
|
10
|
+
testDirectories = [];
|
|
11
|
+
initialSigintListeners = process.listeners("SIGINT");
|
|
12
|
+
});
|
|
13
|
+
afterEach(async () => {
|
|
14
|
+
for (const listener of process.listeners("SIGINT")) {
|
|
15
|
+
if (!initialSigintListeners.includes(listener)) {
|
|
16
|
+
process.removeListener("SIGINT", listener);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
for (const directory of testDirectories) {
|
|
20
|
+
await rm(directory, { recursive: true, force: true });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
test("compile --watch seeds existing outdir and disables cleaning on first compile (#688)", async () => {
|
|
24
|
+
const testDirectory = await mkdtemp(path.join(tmpdir(), "paraglide-cli-"));
|
|
25
|
+
testDirectories.push(testDirectory);
|
|
26
|
+
const outdir = path.join(testDirectory, "output");
|
|
27
|
+
const { writeOutput } = await import("../../../services/file-handling/write-output.js");
|
|
28
|
+
await writeOutput({
|
|
29
|
+
directory: outdir,
|
|
30
|
+
output: {
|
|
31
|
+
"runtime.js": "export const runtime = true;",
|
|
32
|
+
},
|
|
33
|
+
fs: nodeFs,
|
|
34
|
+
});
|
|
35
|
+
const compileMock = vi.fn().mockResolvedValue({
|
|
36
|
+
outputHashes: {
|
|
37
|
+
"runtime.js": "next-hash",
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
vi.doMock("../../../compiler/compile.js", () => ({
|
|
41
|
+
compile: compileMock,
|
|
42
|
+
}));
|
|
43
|
+
const { compileCommand } = await import("./command.js");
|
|
44
|
+
await compileCommand.parseAsync([
|
|
45
|
+
"--messages",
|
|
46
|
+
"./messages/{locale}.json",
|
|
47
|
+
"--locales",
|
|
48
|
+
"en",
|
|
49
|
+
"de",
|
|
50
|
+
"--base-locale",
|
|
51
|
+
"en",
|
|
52
|
+
"--outdir",
|
|
53
|
+
outdir,
|
|
54
|
+
"--watch",
|
|
55
|
+
"--silent",
|
|
56
|
+
], { from: "user" });
|
|
57
|
+
expect(compileMock).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(compileMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
59
|
+
outdir,
|
|
60
|
+
cleanOutdir: false,
|
|
61
|
+
previousCompilation: {
|
|
62
|
+
outputHashes: {
|
|
63
|
+
"runtime.js": expect.any(String),
|
|
64
|
+
},
|
|
65
|
+
output: {},
|
|
66
|
+
},
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=command.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.test.js","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEjE,IAAI,eAAe,GAAa,EAAE,CAAC;AACnC,IAAI,sBAAsB,GAA6B,EAAE,CAAC;AAE1D,UAAU,CAAC,GAAG,EAAE;IACf,EAAE,CAAC,YAAY,EAAE,CAAC;IAClB,eAAe,GAAG,EAAE,CAAC;IACrB,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AACtD,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,KAAK,IAAI,EAAE;IACpB,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpD,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChD,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC;IACD,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,S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AC,CAAC,oBAAoB,CACvC,MAAM,CAAC,gBAAgB,CAAC;QACvB,MAAM;QACN,WAAW,EAAE,KAAK;QAClB,mBAAmB,EAAE;YACpB,YAAY,EAAE;gBACb,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;aAChC;YACD,MAAM,EAAE,EAAE;SACV;KACD,CAAC,CACF,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { mkdtemp, rm } from \"node:fs/promises\";\nimport * as nodeFs from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { afterEach, beforeEach, expect, test, vi } from \"vitest\";\n\nlet testDirectories: string[] = [];\nlet initialSigintListeners: NodeJS.SignalsListener[] = [];\n\nbeforeEach(() => {\n\tvi.resetModules();\n\ttestDirectories = [];\n\tinitialSigintListeners = process.listeners(\"SIGINT\");\n});\n\nafterEach(async () => {\n\tfor (const listener of process.listeners(\"SIGINT\")) {\n\t\tif (!initialSigintListeners.includes(listener)) {\n\t\t\tprocess.removeListener(\"SIGINT\", listener);\n\t\t}\n\t}\n\tfor (const directory of testDirectories) {\n\t\tawait rm(directory, { recursive: true, force: true });\n\t}\n});\n\ntest(\"compile --watch seeds existing outdir and disables cleaning on first compile (#688)\", async () => {\n\tconst testDirectory = await mkdtemp(path.join(tmpdir(), \"paraglide-cli-\"));\n\ttestDirectories.push(testDirectory);\n\tconst outdir = path.join(testDirectory, \"output\");\n\tconst { writeOutput } = await import(\n\t\t\"../../../services/file-handling/write-output.js\"\n\t);\n\tawait writeOutput({\n\t\tdirectory: outdir,\n\t\toutput: {\n\t\t\t\"runtime.js\": \"export const runtime = true;\",\n\t\t},\n\t\tfs: nodeFs,\n\t});\n\n\tconst compileMock = vi.fn().mockResolvedValue({\n\t\toutputHashes: {\n\t\t\t\"runtime.js\": \"next-hash\",\n\t\t},\n\t});\n\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\tcompile: compileMock,\n\t}));\n\n\tconst { compileCommand } = await import(\"./command.js\");\n\n\tawait compileCommand.parseAsync(\n\t\t[\n\t\t\t\"--messages\",\n\t\t\t\"./messages/{locale}.json\",\n\t\t\t\"--locales\",\n\t\t\t\"en\",\n\t\t\t\"de\",\n\t\t\t\"--base-locale\",\n\t\t\t\"en\",\n\t\t\t\"--outdir\",\n\t\t\toutdir,\n\t\t\t\"--watch\",\n\t\t\t\"--silent\",\n\t\t],\n\t\t{ from: \"user\" }\n\t);\n\n\texpect(compileMock).toHaveBeenCalledTimes(1);\n\texpect(compileMock).toHaveBeenCalledWith(\n\t\texpect.objectContaining({\n\t\t\toutdir,\n\t\t\tcleanOutdir: false,\n\t\t\tpreviousCompilation: {\n\t\t\t\toutputHashes: {\n\t\t\t\t\t\"runtime.js\": expect.any(String),\n\t\t\t\t},\n\t\t\t\toutput: {},\n\t\t\t},\n\t\t})\n\t);\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/init/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBpC,eAAO,MAAM,WAAW,SAqDrB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { Logger } from "../../../services/logger/index.js";
|
|
3
|
+
import { findPackageJson } from "../../../services/environment/package.js";
|
|
4
|
+
import { checkForUncommittedChanges } from "../../steps/check-for-uncomitted-changes.js";
|
|
5
|
+
import { initializeMessages } from "../../steps/initialize-messages.js";
|
|
6
|
+
import { maybeUpdateTsConfig } from "../../steps/update-ts-config.js";
|
|
7
|
+
import { promptForOutdir } from "../../steps/prompt-for-outdir.js";
|
|
8
|
+
import { updatePackageJson } from "../../steps/update-package-json.js";
|
|
9
|
+
import nodeFs from "node:fs";
|
|
10
|
+
import { ENV_VARIABLES } from "../../../services/env-variables/index.js";
|
|
11
|
+
import { detectBundler } from "../../steps/detect-bundler.js";
|
|
12
|
+
import { addVitePlugin } from "../../steps/add-vite-plugin.js";
|
|
13
|
+
import { compile } from "../../../compiler/compile.js";
|
|
14
|
+
import { DEFAULT_BASE_LOCALE, DEFAULT_LOCALES, DEFAULT_MESSAGES, } from "../../defaults.js";
|
|
15
|
+
export const initCommand = new Command()
|
|
16
|
+
.name("init")
|
|
17
|
+
.summary("Initializes paraglide-lite.")
|
|
18
|
+
.action(async () => {
|
|
19
|
+
const logger = new Logger({ silent: false, prefix: false });
|
|
20
|
+
logger.box("Welcome to paraglide-lite");
|
|
21
|
+
const ctx = {
|
|
22
|
+
logger,
|
|
23
|
+
fs: nodeFs.promises,
|
|
24
|
+
syncFs: nodeFs,
|
|
25
|
+
root: process.cwd(),
|
|
26
|
+
};
|
|
27
|
+
const ctx1 = await checkForUncommittedChanges(ctx);
|
|
28
|
+
const ctx2 = await enforcePackageJsonExists(ctx1);
|
|
29
|
+
const ctx3 = await initializeMessages(ctx2);
|
|
30
|
+
const ctx4 = await promptForOutdir(ctx3);
|
|
31
|
+
const ctx5 = await addParaglideJsToDevDependencies(ctx4);
|
|
32
|
+
const ctx6 = await detectBundler(ctx5);
|
|
33
|
+
if (ctx6.bundler === "vite") {
|
|
34
|
+
await addVitePlugin(ctx6);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
await addCompileStepToPackageJSON(ctx6);
|
|
38
|
+
}
|
|
39
|
+
const ctx7 = await maybeUpdateTsConfig(ctx6);
|
|
40
|
+
try {
|
|
41
|
+
await compile({
|
|
42
|
+
messages: ctx7.messages ?? DEFAULT_MESSAGES,
|
|
43
|
+
locales: ctx7.locales ?? [...DEFAULT_LOCALES],
|
|
44
|
+
baseLocale: ctx7.baseLocale ?? DEFAULT_BASE_LOCALE,
|
|
45
|
+
outdir: ctx7.outdir,
|
|
46
|
+
});
|
|
47
|
+
ctx.logger.success("Ran the paraglide-lite compiler");
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
ctx.logger.warn("Failed to compile project automatically. You will need to run the compiler manually");
|
|
51
|
+
}
|
|
52
|
+
const successMessage = [
|
|
53
|
+
"Setup complete! Run `npm install` and then `npm run build`.",
|
|
54
|
+
"Unofficial fork of Paraglide JS — for most users prefer https://paraglidejs.com",
|
|
55
|
+
"\n",
|
|
56
|
+
"Repo: https://github.com/SebbeBroman/paraglide-js",
|
|
57
|
+
].join("\n");
|
|
58
|
+
ctx.logger.box(successMessage);
|
|
59
|
+
process.exit(0);
|
|
60
|
+
});
|
|
61
|
+
const addParaglideJsToDevDependencies = async (ctx) => {
|
|
62
|
+
const ctx1 = await updatePackageJson({
|
|
63
|
+
devDependencies: async (devDeps) => ({
|
|
64
|
+
...devDeps,
|
|
65
|
+
"@sebbro/paraglide-lite": `^${ENV_VARIABLES.PARJS_PACKAGE_VERSION}`,
|
|
66
|
+
}),
|
|
67
|
+
})(ctx);
|
|
68
|
+
ctx.logger.success("Added @sebbro/paraglide-lite to the devDependencies in package.json.");
|
|
69
|
+
return ctx1;
|
|
70
|
+
};
|
|
71
|
+
const enforcePackageJsonExists = async (ctx) => {
|
|
72
|
+
const packageJsonPath = await findPackageJson(ctx.fs, process.cwd());
|
|
73
|
+
if (!packageJsonPath) {
|
|
74
|
+
ctx.logger.warn("No package.json found. Please run this command in a project directory.");
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
return { ...ctx, packageJsonPath };
|
|
78
|
+
};
|
|
79
|
+
const addCompileStepToPackageJSON = async (ctx) => {
|
|
80
|
+
const localesFlag = ctx.locales.join(" ");
|
|
81
|
+
await updatePackageJson({
|
|
82
|
+
scripts: async (scripts) => ({
|
|
83
|
+
...scripts,
|
|
84
|
+
"paraglide:compile": `paraglide-lite compile --messages '${ctx.messages}' --locales ${localesFlag} --base-locale ${ctx.baseLocale} --outdir ${ctx.outdir}`,
|
|
85
|
+
}),
|
|
86
|
+
})(ctx);
|
|
87
|
+
ctx.logger.success("Added paraglide:compile script to package.json.");
|
|
88
|
+
return ctx;
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/cli/commands/init/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,EAAE;KACtC,IAAI,CAAC,MAAM,CAAC;KACZ,OAAO,CAAC,6BAA6B,CAAC;KACtC,MAAM,CAAC,KAAK,IAAI,EAAE;IAClB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAE5D,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAExC,MAAM,GAAG,GAAG;QACX,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C,QAAQ,eAAe,WAAW,kBAAkB,GAAG,CAAC,UAAU,aAAa,GAAG,CAAC,MAAM,EAAE;SAC1J,CAAC;KACF,CAAC,CAAC,GAAG,CAAC,CAAC;IACR,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,iDAAiD,CAAC,CAAC;IACtE,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport { findPackageJson } from \"../../../services/environment/package.js\";\nimport { checkForUncommittedChanges } from \"../../steps/check-for-uncomitted-changes.js\";\nimport { initializeMessages } from \"../../steps/initialize-messages.js\";\nimport { maybeUpdateTsConfig } from \"../../steps/update-ts-config.js\";\nimport { promptForOutdir } from \"../../steps/prompt-for-outdir.js\";\nimport { updatePackageJson } from \"../../steps/update-package-json.js\";\nimport type { CliStep } from \"../../utils.js\";\nimport nodeFs from \"node:fs\";\nimport { ENV_VARIABLES } from \"../../../services/env-variables/index.js\";\nimport { detectBundler } from \"../../steps/detect-bundler.js\";\nimport { addVitePlugin } from \"../../steps/add-vite-plugin.js\";\nimport { compile } from \"../../../compiler/compile.js\";\nimport {\n\tDEFAULT_BASE_LOCALE,\n\tDEFAULT_LOCALES,\n\tDEFAULT_MESSAGES,\n} from \"../../defaults.js\";\n\nexport const initCommand = new Command()\n\t.name(\"init\")\n\t.summary(\"Initializes paraglide-lite.\")\n\t.action(async () => {\n\t\tconst logger = new Logger({ silent: false, prefix: false });\n\n\t\tlogger.box(\"Welcome to paraglide-lite\");\n\n\t\tconst ctx = {\n\t\t\tlogger,\n\t\t\tfs: nodeFs.promises,\n\t\t\tsyncFs: nodeFs,\n\t\t\troot: process.cwd(),\n\t\t} as const;\n\n\t\tconst ctx1 = await checkForUncommittedChanges(ctx);\n\t\tconst ctx2 = await enforcePackageJsonExists(ctx1);\n\t\tconst ctx3 = await initializeMessages(ctx2);\n\t\tconst ctx4 = await promptForOutdir(ctx3);\n\t\tconst ctx5 = await addParaglideJsToDevDependencies(ctx4);\n\t\tconst ctx6 = await detectBundler(ctx5);\n\n\t\tif (ctx6.bundler === \"vite\") {\n\t\t\tawait addVitePlugin(ctx6);\n\t\t} else {\n\t\t\tawait addCompileStepToPackageJSON(ctx6);\n\t\t}\n\n\t\tconst ctx7 = await maybeUpdateTsConfig(ctx6);\n\n\t\ttry {\n\t\t\tawait compile({\n\t\t\t\tmessages: ctx7.messages ?? DEFAULT_MESSAGES,\n\t\t\t\tlocales: ctx7.locales ?? [...DEFAULT_LOCALES],\n\t\t\t\tbaseLocale: ctx7.baseLocale ?? DEFAULT_BASE_LOCALE,\n\t\t\t\toutdir: ctx7.outdir,\n\t\t\t});\n\t\t\tctx.logger.success(\"Ran the paraglide-lite compiler\");\n\t\t} catch {\n\t\t\tctx.logger.warn(\n\t\t\t\t\"Failed to compile project automatically. You will need to run the compiler manually\"\n\t\t\t);\n\t\t}\n\n\t\tconst successMessage = [\n\t\t\t\"Setup complete! Run `npm install` and then `npm run build`.\",\n\t\t\t\"Unofficial fork of Paraglide JS — for most users prefer https://paraglidejs.com\",\n\t\t\t\"\\n\",\n\t\t\t\"Repo: https://github.com/SebbeBroman/paraglide-js\",\n\t\t].join(\"\\n\");\n\t\tctx.logger.box(successMessage);\n\t\tprocess.exit(0);\n\t});\n\nconst addParaglideJsToDevDependencies: CliStep<\n\t{\n\t\tfs: typeof import(\"node:fs/promises\");\n\t\tlogger: Logger;\n\t\tpackageJsonPath: string;\n\t},\n\tunknown\n> = async (ctx) => {\n\tconst ctx1 = await updatePackageJson({\n\t\tdevDependencies: async (devDeps) => ({\n\t\t\t...devDeps,\n\t\t\t\"@sebbro/paraglide-lite\": `^${ENV_VARIABLES.PARJS_PACKAGE_VERSION}`,\n\t\t}),\n\t})(ctx);\n\tctx.logger.success(\n\t\t\"Added @sebbro/paraglide-lite to the devDependencies in package.json.\"\n\t);\n\treturn ctx1;\n};\n\nconst enforcePackageJsonExists: CliStep<\n\t{ logger: Logger; fs: typeof import(\"node:fs/promises\") },\n\t{ packageJsonPath: string }\n> = async (ctx) => {\n\tconst packageJsonPath = await findPackageJson(ctx.fs, process.cwd());\n\tif (!packageJsonPath) {\n\t\tctx.logger.warn(\n\t\t\t\"No package.json found. Please run this command in a project directory.\"\n\t\t);\n\t\tprocess.exit(1);\n\t}\n\treturn { ...ctx, packageJsonPath };\n};\n\nconst addCompileStepToPackageJSON: CliStep<\n\t{\n\t\tfs: typeof import(\"node:fs/promises\");\n\t\tlogger: Logger;\n\t\tpackageJsonPath: string;\n\t\toutdir: string;\n\t\tmessages: string;\n\t\tlocales: string[];\n\t\tbaseLocale: string;\n\t},\n\tunknown\n> = async (ctx) => {\n\tconst localesFlag = ctx.locales.join(\" \");\n\tawait updatePackageJson({\n\t\tscripts: async (scripts) => ({\n\t\t\t...scripts,\n\t\t\t\"paraglide:compile\": `paraglide-lite compile --messages '${ctx.messages}' --locales ${localesFlag} --base-locale ${ctx.baseLocale} --outdir ${ctx.outdir}`,\n\t\t}),\n\t})(ctx);\n\tctx.logger.success(\"Added paraglide:compile script to package.json.\");\n\treturn ctx;\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const DEFAULT_MESSAGES = "./messages/{locale}.json";
|
|
2
|
+
export declare const DEFAULT_LOCALES: readonly ["en", "de"];
|
|
3
|
+
export declare const DEFAULT_BASE_LOCALE = "en";
|
|
4
|
+
export declare const DEFAULT_OUTDIR = "./src/paraglide";
|
|
5
|
+
export type ParaglideDefaults = {
|
|
6
|
+
messages: string;
|
|
7
|
+
locales: string[];
|
|
8
|
+
baseLocale: string;
|
|
9
|
+
outdir: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function getDefaultParaglideConfig(): ParaglideDefaults;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAC3D,eAAO,MAAM,eAAe,YAAI,IAAI,EAAE,IAAI,CAAU,CAAC;AACrD,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,iBAAiB,CAO7D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const DEFAULT_MESSAGES = "./messages/{locale}.json";
|
|
2
|
+
export const DEFAULT_LOCALES = ["en", "de"];
|
|
3
|
+
export const DEFAULT_BASE_LOCALE = "en";
|
|
4
|
+
export const DEFAULT_OUTDIR = "./src/paraglide";
|
|
5
|
+
export function getDefaultParaglideConfig() {
|
|
6
|
+
return {
|
|
7
|
+
messages: DEFAULT_MESSAGES,
|
|
8
|
+
locales: [...DEFAULT_LOCALES],
|
|
9
|
+
baseLocale: DEFAULT_BASE_LOCALE,
|
|
10
|
+
outdir: DEFAULT_OUTDIR,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAShD,MAAM,UAAU,yBAAyB;IACxC,OAAO;QACN,QAAQ,EAAE,gBAAgB;QAC1B,OAAO,EAAE,CAAC,GAAG,eAAe,CAAC;QAC7B,UAAU,EAAE,mBAAmB;QAC/B,MAAM,EAAE,cAAc;KACtB,CAAC;AACH,CAAC","sourcesContent":["export const DEFAULT_MESSAGES = \"./messages/{locale}.json\";\nexport const DEFAULT_LOCALES = [\"en\", \"de\"] as const;\nexport const DEFAULT_BASE_LOCALE = \"en\";\nexport const DEFAULT_OUTDIR = \"./src/paraglide\";\n\nexport type ParaglideDefaults = {\n\tmessages: string;\n\tlocales: string[];\n\tbaseLocale: string;\n\toutdir: string;\n};\n\nexport function getDefaultParaglideConfig(): ParaglideDefaults {\n\treturn {\n\t\tmessages: DEFAULT_MESSAGES,\n\t\tlocales: [...DEFAULT_LOCALES],\n\t\tbaseLocale: DEFAULT_BASE_LOCALE,\n\t\toutdir: DEFAULT_OUTDIR,\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,GAAG,SAK8B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { compileCommand } from "./commands/compile/command.js";
|
|
3
|
+
import { ENV_VARIABLES } from "../services/env-variables/index.js";
|
|
4
|
+
import { initCommand } from "./commands/init/command.js";
|
|
5
|
+
export const cli = new Command()
|
|
6
|
+
.name("paraglide-lite")
|
|
7
|
+
.addCommand(compileCommand)
|
|
8
|
+
.addCommand(initCommand)
|
|
9
|
+
.showHelpAfterError()
|
|
10
|
+
.version(ENV_VARIABLES.PARJS_PACKAGE_VERSION);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,OAAO,EAAE;KAC9B,IAAI,CAAC,gBAAgB,CAAC;KACtB,UAAU,CAAC,cAAc,CAAC;KAC1B,UAAU,CAAC,WAAW,CAAC;KACvB,kBAAkB,EAAE;KACpB,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport { compileCommand } from \"./commands/compile/command.js\";\nimport { ENV_VARIABLES } from \"../services/env-variables/index.js\";\nimport { initCommand } from \"./commands/init/command.js\";\n\nexport const cli = new Command()\n\t.name(\"paraglide-lite\")\n\t.addCommand(compileCommand)\n\t.addCommand(initCommand)\n\t.showHelpAfterError()\n\t.version(ENV_VARIABLES.PARJS_PACKAGE_VERSION);\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Logger } from "../../services/logger/index.js";
|
|
2
|
+
import type { CliStep } from "../utils.js";
|
|
3
|
+
export declare const addVitePlugin: CliStep<{
|
|
4
|
+
fs: typeof import("node:fs/promises");
|
|
5
|
+
messages: string;
|
|
6
|
+
locales: string[];
|
|
7
|
+
baseLocale: string;
|
|
8
|
+
outdir: string;
|
|
9
|
+
logger?: Logger;
|
|
10
|
+
configPath: string;
|
|
11
|
+
}, unknown>;
|
|
12
|
+
type UpdateResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
updated: string;
|
|
15
|
+
reason?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
ok: false;
|
|
18
|
+
reason: string;
|
|
19
|
+
updated?: undefined;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* @private Only exported for testings
|
|
23
|
+
*/
|
|
24
|
+
export declare function updateViteConfig(args: {
|
|
25
|
+
config: string;
|
|
26
|
+
messages: string;
|
|
27
|
+
locales: string[];
|
|
28
|
+
baseLocale: string;
|
|
29
|
+
outdir: string;
|
|
30
|
+
}): UpdateResult;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-vite-plugin.d.ts","sourceRoot":"","sources":["../../../src/cli/steps/add-vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,eAAO,MAAM,aAAa,EAAE,OAAO,CAClC;IACC,EAAE,EAAE,cAAc,kBAAkB,CAAC,CAAC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB,EACD,OAAO,CAsCP,CAAC;AAEF,KAAK,YAAY,GACd;IACA,EAAE,EAAE,IAAI,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;CAClB,GACD;IACA,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEL;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CACf,GAAG,YAAY,CAiCf"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const addVitePlugin = async (ctx) => {
|
|
2
|
+
try {
|
|
3
|
+
const fileContent = await ctx.fs.readFile(ctx.configPath, {
|
|
4
|
+
encoding: "utf-8",
|
|
5
|
+
});
|
|
6
|
+
const result = updateViteConfig({
|
|
7
|
+
config: fileContent,
|
|
8
|
+
messages: ctx.messages,
|
|
9
|
+
locales: ctx.locales,
|
|
10
|
+
baseLocale: ctx.baseLocale,
|
|
11
|
+
outdir: ctx.outdir,
|
|
12
|
+
});
|
|
13
|
+
if (result.ok) {
|
|
14
|
+
await ctx.fs.writeFile(ctx.configPath, result.updated);
|
|
15
|
+
ctx.logger?.success("Added the paraglide-lite vite plugin to the vite config.");
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const msg = [
|
|
19
|
+
"Failed to add the paraglide-lite vite plugin in vite.config.js.",
|
|
20
|
+
"Reason: " + result.reason,
|
|
21
|
+
"",
|
|
22
|
+
"Please add the plugin manually.",
|
|
23
|
+
].join("\n");
|
|
24
|
+
ctx.logger?.warn(msg);
|
|
25
|
+
return ctx;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
ctx.logger?.error(`Failed to add the paraglide-lite vite plugin to ${ctx.configPath}.`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
return ctx;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @private Only exported for testings
|
|
36
|
+
*/
|
|
37
|
+
export function updateViteConfig(args) {
|
|
38
|
+
if (args.config.includes("@sebbro/paraglide-lite")) {
|
|
39
|
+
return {
|
|
40
|
+
ok: false,
|
|
41
|
+
reason: "Already present",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const PLUGINS_REGEX = /plugins\s*:\s*\[/g;
|
|
45
|
+
const match = PLUGINS_REGEX.exec(args.config);
|
|
46
|
+
if (!match) {
|
|
47
|
+
return {
|
|
48
|
+
ok: false,
|
|
49
|
+
reason: "Could not find the plugins array",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const endIndex = match.index + match[0].length;
|
|
53
|
+
const before = args.config.slice(0, endIndex);
|
|
54
|
+
const after = args.config.slice(endIndex);
|
|
55
|
+
const localesLiteral = JSON.stringify(args.locales);
|
|
56
|
+
const updatedConfig = "import { paraglideVitePlugin } from '@sebbro/paraglide-lite'\n" +
|
|
57
|
+
before +
|
|
58
|
+
`paraglideVitePlugin({ messages: '${args.messages}', locales: ${localesLiteral}, baseLocale: '${args.baseLocale}', outdir: '${args.outdir}' }),` +
|
|
59
|
+
after;
|
|
60
|
+
return {
|
|
61
|
+
ok: true,
|
|
62
|
+
updated: updatedConfig,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=add-vite-plugin.js.map
|