@inlang/paraglide-js 2.0.0-beta.2 → 2.0.0-beta.21
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/README.md +3 -3
- package/dist/adapter-utils/routing/resolveUserPathDefinition.test.js +6 -6
- package/dist/adapter-utils/routing/resolveUserPathDefinitions.d.ts +4 -4
- package/dist/adapter-utils/routing/resolveUserPathDefinitions.d.ts.map +1 -1
- package/dist/adapter-utils/routing/resolveUserPathDefinitions.js +4 -7
- package/dist/bundler-plugins/index.d.ts +1 -0
- package/dist/bundler-plugins/index.d.ts.map +1 -1
- package/dist/bundler-plugins/index.js +1 -0
- package/dist/bundler-plugins/rollup.d.ts +1 -5
- package/dist/bundler-plugins/rollup.d.ts.map +1 -1
- package/dist/bundler-plugins/unplugin.d.ts +2 -16
- package/dist/bundler-plugins/unplugin.d.ts.map +1 -1
- package/dist/bundler-plugins/unplugin.js +69 -28
- package/dist/bundler-plugins/vite.d.ts +1 -5
- package/dist/bundler-plugins/vite.d.ts.map +1 -1
- package/dist/bundler-plugins/webpack.d.ts +2 -0
- package/dist/bundler-plugins/webpack.d.ts.map +1 -0
- package/dist/bundler-plugins/webpack.js +3 -0
- package/dist/cli/commands/compile/command.d.ts.map +1 -1
- package/dist/cli/commands/compile/command.js +21 -22
- package/dist/cli/commands/init/command.d.ts.map +1 -1
- package/dist/cli/commands/init/command.js +20 -9
- package/dist/cli/defaults.d.ts +1 -1
- package/dist/cli/defaults.d.ts.map +1 -1
- package/dist/cli/defaults.js +5 -10
- package/dist/cli/index.d.ts +0 -9
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -9
- package/dist/cli/steps/add-vite-plugin.d.ts +10 -0
- package/dist/cli/steps/add-vite-plugin.d.ts.map +1 -0
- package/dist/cli/steps/add-vite-plugin.js +61 -0
- package/dist/cli/steps/add-vite-plugin.test.d.ts +2 -0
- package/dist/cli/steps/add-vite-plugin.test.d.ts.map +1 -0
- package/dist/cli/steps/add-vite-plugin.test.js +69 -0
- package/dist/cli/steps/detect-bundler.d.ts +11 -0
- package/dist/cli/steps/detect-bundler.d.ts.map +1 -0
- package/dist/cli/steps/detect-bundler.js +21 -0
- package/dist/cli/steps/detect-bundler.test.d.ts +2 -0
- package/dist/cli/steps/detect-bundler.test.d.ts.map +1 -0
- package/dist/cli/steps/detect-bundler.test.js +28 -0
- package/dist/cli/steps/index.d.ts +9 -0
- package/dist/cli/steps/index.d.ts.map +1 -0
- package/dist/cli/steps/index.js +8 -0
- package/dist/cli/steps/initialize-inlang-project.d.ts +1 -11
- package/dist/cli/steps/initialize-inlang-project.d.ts.map +1 -1
- package/dist/cli/steps/initialize-inlang-project.js +143 -118
- package/dist/cli/steps/maybe-add-sherlock.d.ts.map +1 -1
- package/dist/cli/steps/maybe-add-sherlock.js +13 -14
- package/dist/cli/steps/run-compiler.d.ts.map +1 -1
- package/dist/cli/steps/run-compiler.js +2 -2
- package/dist/cli/steps/update-ts-config.d.ts +2 -2
- package/dist/cli/steps/update-ts-config.js +5 -5
- package/dist/compiler/{compileBundle.d.ts → compile-bundle.d.ts} +1 -3
- package/dist/compiler/compile-bundle.d.ts.map +1 -0
- package/dist/compiler/compile-bundle.js +55 -0
- package/dist/compiler/compile-bundle.test.d.ts +2 -0
- package/dist/compiler/compile-bundle.test.d.ts.map +1 -0
- package/dist/compiler/compile-bundle.test.js +91 -0
- package/dist/compiler/{compileExpression.d.ts → compile-expression.d.ts} +1 -1
- package/dist/compiler/compile-expression.d.ts.map +1 -0
- package/dist/compiler/compile-local-variable.d.ts +17 -0
- package/dist/compiler/compile-local-variable.d.ts.map +1 -0
- package/dist/compiler/compile-local-variable.js +38 -0
- package/dist/compiler/compile-local-variable.test.d.ts +2 -0
- package/dist/compiler/compile-local-variable.test.d.ts.map +1 -0
- package/dist/compiler/compile-local-variable.test.js +71 -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 +94 -0
- package/dist/compiler/compile-message.test.d.ts +2 -0
- package/dist/compiler/compile-message.test.d.ts.map +1 -0
- package/dist/compiler/compile-message.test.js +279 -0
- package/dist/compiler/compile-pattern.d.ts +20 -0
- package/dist/compiler/compile-pattern.d.ts.map +1 -0
- package/dist/compiler/compile-pattern.js +40 -0
- package/dist/compiler/compile-pattern.test.d.ts +2 -0
- package/dist/compiler/compile-pattern.test.d.ts.map +1 -0
- package/dist/compiler/compile-pattern.test.js +75 -0
- package/dist/compiler/compile-project.d.ts +18 -0
- package/dist/compiler/compile-project.d.ts.map +1 -0
- package/dist/compiler/{compileProject.js → compile-project.js} +13 -50
- package/dist/compiler/compile-project.test.d.ts +2 -0
- package/dist/compiler/compile-project.test.d.ts.map +1 -0
- package/dist/compiler/{compileProject.test.js → compile-project.test.js} +208 -175
- package/dist/compiler/compile.bench.d.ts +2 -0
- package/dist/compiler/compile.bench.d.ts.map +1 -0
- package/dist/compiler/compile.bench.js +39 -0
- package/dist/compiler/compile.d.ts +7 -7
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/compile.js +55 -22
- package/dist/compiler/compile.test.js +149 -0
- package/dist/compiler/compiler-options.d.ts +172 -0
- package/dist/compiler/compiler-options.d.ts.map +1 -0
- package/dist/compiler/compiler-options.js +8 -0
- package/dist/compiler/index.d.ts +7 -4
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/index.js +5 -4
- package/dist/compiler/jsdoc-types.d.ts +15 -0
- package/dist/compiler/jsdoc-types.d.ts.map +1 -0
- package/dist/compiler/jsdoc-types.js +26 -0
- package/dist/compiler/output-structure/locale-modules.d.ts +6 -2
- package/dist/compiler/output-structure/locale-modules.d.ts.map +1 -1
- package/dist/compiler/output-structure/locale-modules.js +26 -21
- package/dist/compiler/output-structure/locale-modules.test.js +3 -2
- package/dist/compiler/output-structure/message-modules.d.ts +6 -2
- package/dist/compiler/output-structure/message-modules.d.ts.map +1 -1
- package/dist/compiler/output-structure/message-modules.js +51 -30
- package/dist/compiler/output-structure/message-modules.test.js +50 -1
- package/dist/compiler/registry.d.ts +10 -10
- package/dist/compiler/registry.d.ts.map +1 -1
- package/dist/compiler/registry.js +23 -34
- package/dist/compiler/runtime/assert-is-locale.d.ts +9 -0
- package/dist/compiler/runtime/assert-is-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/assert-is-locale.js +15 -0
- package/dist/compiler/runtime/assert-is-locale.test.d.ts +2 -0
- package/dist/compiler/runtime/assert-is-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/assert-is-locale.test.js +26 -0
- package/dist/compiler/runtime/base-locale.d.ts +10 -0
- package/dist/compiler/runtime/base-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/base-locale.js +9 -0
- package/dist/compiler/runtime/cookie-name.d.ts +3 -0
- package/dist/compiler/runtime/cookie-name.d.ts.map +1 -0
- package/dist/compiler/runtime/cookie-name.js +2 -0
- package/dist/compiler/runtime/create-runtime.d.ts +29 -0
- package/dist/compiler/runtime/create-runtime.d.ts.map +1 -0
- package/dist/compiler/runtime/create-runtime.js +110 -0
- package/dist/compiler/runtime/de-localize-path.d.ts +27 -0
- package/dist/compiler/runtime/de-localize-path.d.ts.map +1 -0
- package/dist/compiler/runtime/de-localize-path.js +52 -0
- package/dist/compiler/runtime/de-localize-path.test.d.ts +2 -0
- package/dist/compiler/runtime/de-localize-path.test.d.ts.map +1 -0
- package/dist/compiler/runtime/de-localize-path.test.js +109 -0
- package/dist/compiler/runtime/de-localized-path.d.ts +27 -0
- package/dist/compiler/runtime/de-localized-path.d.ts.map +1 -0
- package/dist/compiler/runtime/de-localized-path.js +32 -0
- package/dist/compiler/runtime/de-localized-path.test.d.ts +2 -0
- package/dist/compiler/runtime/de-localized-path.test.d.ts.map +1 -0
- package/dist/compiler/runtime/de-localized-path.test.js +48 -0
- package/dist/compiler/runtime/detect-locale-from-request.d.ts +22 -0
- package/dist/compiler/runtime/detect-locale-from-request.d.ts.map +1 -0
- package/dist/compiler/runtime/detect-locale-from-request.js +44 -0
- package/dist/compiler/runtime/e2e.test.d.ts +2 -0
- package/dist/compiler/runtime/e2e.test.d.ts.map +1 -0
- package/dist/compiler/runtime/e2e.test.js +50 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts +10 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.js +21 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.d.ts +2 -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 +45 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.d.ts +13 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.js +35 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.test.d.ts +2 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.test.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-pathname.test.js +103 -0
- package/dist/compiler/runtime/extract-locale-from-request.d.ts +16 -0
- package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-request.js +85 -0
- package/dist/compiler/runtime/extract-locale-from-request.test.d.ts +2 -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 +100 -0
- package/dist/compiler/runtime/extract-locale-from-url.d.ts +8 -0
- package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -0
- package/dist/compiler/runtime/extract-locale-from-url.js +70 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.d.ts +2 -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 +101 -0
- package/dist/compiler/runtime/get-locale-from-path.d.ts +13 -0
- package/dist/compiler/runtime/get-locale-from-path.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale-from-path.js +17 -0
- package/dist/compiler/runtime/get-locale-from-path.test.d.ts +2 -0
- package/dist/compiler/runtime/get-locale-from-path.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale-from-path.test.js +22 -0
- package/dist/compiler/runtime/get-locale.d.ts +30 -0
- package/dist/compiler/runtime/get-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale.js +108 -0
- package/dist/compiler/runtime/get-locale.test.d.ts +2 -0
- package/dist/compiler/runtime/get-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-locale.test.js +114 -0
- package/dist/compiler/runtime/get-url-origin.d.ts +20 -0
- package/dist/compiler/runtime/get-url-origin.d.ts.map +1 -0
- package/dist/compiler/runtime/get-url-origin.js +29 -0
- package/dist/compiler/runtime/get-url-origin.test.d.ts +2 -0
- package/dist/compiler/runtime/get-url-origin.test.d.ts.map +1 -0
- package/dist/compiler/runtime/get-url-origin.test.js +19 -0
- package/dist/compiler/runtime/is-locale.d.ts +15 -0
- package/dist/compiler/runtime/is-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/is-locale.js +17 -0
- package/dist/compiler/runtime/jsdoc-runtime.d.ts +2 -0
- package/dist/compiler/runtime/jsdoc-runtime.d.ts.map +1 -0
- package/dist/compiler/{runtime.js → runtime/jsdoc-runtime.js} +29 -56
- package/dist/compiler/runtime/locale-in-path.d.ts +13 -0
- package/dist/compiler/runtime/locale-in-path.d.ts.map +1 -0
- package/dist/compiler/runtime/locale-in-path.js +17 -0
- package/dist/compiler/runtime/locale-in-path.test.d.ts +2 -0
- package/dist/compiler/runtime/locale-in-path.test.d.ts.map +1 -0
- package/dist/compiler/runtime/locale-in-path.test.js +22 -0
- package/dist/compiler/runtime/locales.d.ts +10 -0
- package/dist/compiler/runtime/locales.d.ts.map +1 -0
- package/dist/compiler/runtime/locales.js +9 -0
- package/dist/compiler/runtime/localize-href.d.ts +82 -0
- package/dist/compiler/runtime/localize-href.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-href.js +108 -0
- package/dist/compiler/runtime/localize-href.test.d.ts +2 -0
- package/dist/compiler/runtime/localize-href.test.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-href.test.js +136 -0
- package/dist/compiler/runtime/localize-path.d.ts +32 -0
- package/dist/compiler/runtime/localize-path.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-path.js +95 -0
- package/dist/compiler/runtime/localize-path.test.d.ts +2 -0
- package/dist/compiler/runtime/localize-path.test.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-path.test.js +220 -0
- package/dist/compiler/runtime/localize-url.d.ts +85 -0
- package/dist/compiler/runtime/localize-url.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-url.js +245 -0
- package/dist/compiler/runtime/localize-url.test.d.ts +2 -0
- package/dist/compiler/runtime/localize-url.test.d.ts.map +1 -0
- package/dist/compiler/runtime/localize-url.test.js +288 -0
- package/dist/compiler/runtime/localized-path.d.ts +32 -0
- package/dist/compiler/runtime/localized-path.d.ts.map +1 -0
- package/dist/compiler/runtime/localized-path.js +44 -0
- package/dist/compiler/runtime/localized-path.test.d.ts +2 -0
- package/dist/compiler/runtime/localized-path.test.d.ts.map +1 -0
- package/dist/compiler/runtime/localized-path.test.js +42 -0
- package/dist/compiler/runtime/mock-runtime.d.ts +6 -0
- package/dist/compiler/runtime/mock-runtime.d.ts.map +1 -0
- package/dist/compiler/runtime/mock-runtime.js +31 -0
- package/dist/compiler/runtime/path-to-regexp.d.ts +2 -0
- package/dist/compiler/runtime/path-to-regexp.d.ts.map +1 -0
- package/dist/compiler/runtime/path-to-regexp.js +1 -0
- package/dist/compiler/runtime/pathname-pattern.d.ts +30 -0
- package/dist/compiler/runtime/pathname-pattern.d.ts.map +1 -0
- package/dist/compiler/runtime/pathname-pattern.js +99 -0
- package/dist/compiler/runtime/pathname-pattern.test.d.ts +2 -0
- package/dist/compiler/runtime/pathname-pattern.test.d.ts.map +1 -0
- package/dist/compiler/runtime/pathname-pattern.test.js +103 -0
- package/dist/compiler/runtime/server-middleware.d.ts +50 -0
- package/dist/compiler/runtime/server-middleware.d.ts.map +1 -0
- package/dist/compiler/runtime/server-middleware.js +85 -0
- package/dist/compiler/runtime/server-middleware.test.d.ts +2 -0
- package/dist/compiler/runtime/server-middleware.test.d.ts.map +1 -0
- package/dist/compiler/runtime/server-middleware.test.js +117 -0
- package/dist/compiler/runtime/set-locale.d.ts +11 -0
- package/dist/compiler/runtime/set-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/set-locale.js +76 -0
- package/dist/compiler/runtime/set-locale.test.d.ts +2 -0
- package/dist/compiler/runtime/set-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/set-locale.test.js +100 -0
- package/dist/compiler/runtime/strategy.d.ts +5 -0
- package/dist/compiler/runtime/strategy.d.ts.map +1 -0
- package/dist/compiler/runtime/strategy.js +4 -0
- package/dist/compiler/runtime/ts-runtime.d.ts +2 -0
- package/dist/compiler/runtime/ts-runtime.d.ts.map +1 -0
- package/dist/compiler/runtime/ts-runtime.js +119 -0
- package/dist/compiler/runtime/type.d.ts +27 -0
- package/dist/compiler/runtime/type.d.ts.map +1 -0
- package/dist/compiler/runtime/type.js +1 -0
- package/dist/compiler/runtime/type.test.d.ts +2 -0
- package/dist/compiler/runtime/type.test.d.ts.map +1 -0
- package/dist/compiler/runtime/type.test.js +91 -0
- package/dist/compiler/runtime/variables.d.ts +40 -0
- package/dist/compiler/runtime/variables.d.ts.map +1 -0
- package/dist/compiler/runtime/variables.js +35 -0
- package/dist/compiler/safe-module-id.d.ts +8 -0
- package/dist/compiler/safe-module-id.d.ts.map +1 -0
- package/dist/compiler/safe-module-id.js +71 -0
- package/dist/compiler/safe-module-id.test.d.ts +2 -0
- package/dist/compiler/safe-module-id.test.d.ts.map +1 -0
- package/dist/compiler/safe-module-id.test.js +27 -0
- package/dist/compiler/strategy.d.ts +13 -0
- package/dist/compiler/strategy.d.ts.map +1 -0
- package/dist/compiler/strategy.js +12 -0
- package/dist/compiler/strategy.test.d.ts +2 -0
- package/dist/compiler/strategy.test.d.ts.map +1 -0
- package/dist/compiler/strategy.test.js +9 -0
- package/dist/compiler/types.d.ts +17 -2
- package/dist/compiler/types.d.ts.map +1 -1
- package/dist/compiler/types.js +1 -28
- package/dist/compiler/urlpattern-polyfill/index.d.ts +2 -0
- package/dist/compiler/urlpattern-polyfill/index.d.ts.map +1 -0
- package/dist/compiler/urlpattern-polyfill/index.js +1 -0
- package/dist/index.d.ts +2 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/path-to-regexp/index.d.ts +12 -0
- package/dist/path-to-regexp/index.d.ts.map +1 -0
- package/dist/path-to-regexp/index.js +11 -0
- package/dist/playground.d.ts +2 -0
- package/dist/playground.d.ts.map +1 -0
- package/dist/playground.js +5 -0
- package/dist/services/env-variables/create-index-file.d.ts +2 -0
- package/dist/services/env-variables/create-index-file.d.ts.map +1 -0
- package/dist/services/env-variables/create-index-file.js +29 -0
- package/dist/services/env-variables/index.js +1 -1
- package/dist/services/file-handling/write-output.d.ts +6 -1
- package/dist/services/file-handling/write-output.d.ts.map +1 -1
- package/dist/services/file-handling/write-output.js +34 -26
- package/dist/services/file-handling/write-output.test.js +93 -45
- package/dist/services/logger/index.d.ts +0 -4
- package/dist/services/logger/index.d.ts.map +1 -1
- package/dist/services/logger/index.js +11 -14
- package/dist/services/telemetry/capture.d.ts +1 -2
- package/dist/services/telemetry/capture.d.ts.map +1 -1
- package/dist/services/telemetry/stack-detection.d.ts +1 -1
- package/dist/services/telemetry/stack-detection.d.ts.map +1 -1
- package/dist/services/telemetry/stack-detection.js +3 -8
- package/dist/services/telemetry/stack-detection.test.js +9 -12
- package/dist/services/valid-js-identifier/index.js +1 -1
- package/dist/services/valid-js-identifier/reserved-words.d.ts +2 -0
- package/dist/services/valid-js-identifier/reserved-words.d.ts.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 +1 -0
- package/dist/utilities/node-normalize-path.d.ts +2 -0
- package/dist/utilities/node-normalize-path.d.ts.map +1 -0
- package/dist/utilities/node-normalize-path.js +9 -0
- package/package.json +34 -41
- package/dist/compiler/compileBundle.d.ts.map +0 -1
- package/dist/compiler/compileBundle.js +0 -55
- package/dist/compiler/compileExpression.d.ts.map +0 -1
- package/dist/compiler/compileMessage.d.ts +0 -12
- package/dist/compiler/compileMessage.d.ts.map +0 -1
- package/dist/compiler/compileMessage.js +0 -64
- package/dist/compiler/compileMessage.test.d.ts +0 -2
- package/dist/compiler/compileMessage.test.d.ts.map +0 -1
- package/dist/compiler/compileMessage.test.js +0 -74
- package/dist/compiler/compilePattern.d.ts +0 -12
- package/dist/compiler/compilePattern.d.ts.map +0 -1
- package/dist/compiler/compilePattern.js +0 -28
- package/dist/compiler/compilePattern.test.d.ts +0 -2
- package/dist/compiler/compilePattern.test.d.ts.map +0 -1
- package/dist/compiler/compilePattern.test.js +0 -67
- package/dist/compiler/compileProject.d.ts +0 -43
- package/dist/compiler/compileProject.d.ts.map +0 -1
- package/dist/compiler/compileProject.test.d.ts +0 -2
- package/dist/compiler/compileProject.test.d.ts.map +0 -1
- package/dist/compiler/emit-dts.d.ts +0 -7
- package/dist/compiler/emit-dts.d.ts.map +0 -1
- package/dist/compiler/emit-dts.js +0 -56
- package/dist/compiler/emit-dts.test.d.ts +0 -2
- package/dist/compiler/emit-dts.test.d.ts.map +0 -1
- package/dist/compiler/emit-dts.test.js +0 -43
- package/dist/compiler/jsDocComment.d.ts +0 -9
- package/dist/compiler/jsDocComment.d.ts.map +0 -1
- package/dist/compiler/jsDocComment.js +0 -30
- package/dist/compiler/runtime.d.ts +0 -6
- package/dist/compiler/runtime.d.ts.map +0 -1
- package/dist/services/valid-js-identifier/reservedWords.d.ts +0 -2
- package/dist/services/valid-js-identifier/reservedWords.d.ts.map +0 -1
- /package/dist/compiler/{compileExpression.js → compile-expression.js} +0 -0
- /package/dist/services/valid-js-identifier/{reservedWords.js → reserved-words.js} +0 -0
package/README.md
CHANGED
|
@@ -35,10 +35,10 @@ _If you are using a Bundler use one of the [Bundler Plugins](usage#usage-with-a-
|
|
|
35
35
|
|
|
36
36
|
## Using messages in code
|
|
37
37
|
|
|
38
|
-
After running the compiler import the messages with `import
|
|
38
|
+
After running the compiler import the messages with `import { m } from "./paraglide/messages"`. By convention, a wildcard import is used.
|
|
39
39
|
|
|
40
40
|
```js
|
|
41
|
-
import
|
|
41
|
+
import { m } from "./paraglide/messages.js";
|
|
42
42
|
|
|
43
43
|
m.greeting({ name: "Samuel" }); // Hello Samuel!
|
|
44
44
|
```
|
|
@@ -49,7 +49,7 @@ To change the locale, use the `setLocale` function.
|
|
|
49
49
|
|
|
50
50
|
```js
|
|
51
51
|
import { setLocale } from "./paraglide/runtime.js";
|
|
52
|
-
import
|
|
52
|
+
import { m } from "./paraglide/messages.js";
|
|
53
53
|
|
|
54
54
|
m.greeting({ name: "Samuel" }); // Hello Samuel!
|
|
55
55
|
|
|
@@ -8,14 +8,14 @@ describe("resolvePathTranslations", () => {
|
|
|
8
8
|
de: "/ueber-uns",
|
|
9
9
|
},
|
|
10
10
|
};
|
|
11
|
-
const
|
|
12
|
-
const result = resolveUserPathDefinitions(userTranslations,
|
|
11
|
+
const availableLocales = ["en", "de"];
|
|
12
|
+
const result = resolveUserPathDefinitions(userTranslations, availableLocales);
|
|
13
13
|
expect(result).toEqual(userTranslations);
|
|
14
14
|
});
|
|
15
15
|
it("resolves message translations", () => {
|
|
16
16
|
const userTranslations = {
|
|
17
|
-
"/about": (_, {
|
|
18
|
-
switch (
|
|
17
|
+
"/about": (_, { locale }) => {
|
|
18
|
+
switch (locale) {
|
|
19
19
|
case "en":
|
|
20
20
|
return "/about";
|
|
21
21
|
case "de":
|
|
@@ -23,8 +23,8 @@ describe("resolvePathTranslations", () => {
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
|
-
const
|
|
27
|
-
const result = resolveUserPathDefinitions(userTranslations,
|
|
26
|
+
const availableLocales = ["en", "de"];
|
|
27
|
+
const result = resolveUserPathDefinitions(userTranslations, availableLocales);
|
|
28
28
|
expect(result).toEqual({
|
|
29
29
|
"/about": {
|
|
30
30
|
en: "/about",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MessageBundleFunction } from "../../compiler/types.js";
|
|
2
2
|
import type { PathDefinitionTranslations } from "./routeDefinitions.js";
|
|
3
3
|
/**
|
|
4
4
|
* Maps canonical paths to translations for each language.
|
|
@@ -22,7 +22,7 @@ import type { PathDefinitionTranslations } from "./routeDefinitions.js";
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
export type UserPathDefinitionTranslations<T extends string = string> = {
|
|
25
|
-
[canonicalPath: `/${string}`]: Record<T, `/${string}`> |
|
|
25
|
+
[canonicalPath: `/${string}`]: Record<T, `/${string}`> | MessageBundleFunction<T>;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* For UX purpouses we let users pass messages as pathnames.
|
|
@@ -33,8 +33,8 @@ export type UserPathDefinitionTranslations<T extends string = string> = {
|
|
|
33
33
|
* Does NOT perform any validation on if the user-provided path translation configuration is valid.
|
|
34
34
|
*
|
|
35
35
|
* @param userTranslations The user-provided path translation configuration.
|
|
36
|
-
* @param
|
|
36
|
+
* @param availableLocales The available language tags.
|
|
37
37
|
* @returns The resolved path translations.
|
|
38
38
|
*/
|
|
39
|
-
export declare const resolveUserPathDefinitions: <T extends string>(userTranslations: UserPathDefinitionTranslations<T>,
|
|
39
|
+
export declare const resolveUserPathDefinitions: <T extends string>(userTranslations: UserPathDefinitionTranslations<T>, availableLocales: readonly T[]) => PathDefinitionTranslations<T>;
|
|
40
40
|
//# sourceMappingURL=resolveUserPathDefinitions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveUserPathDefinitions.d.ts","sourceRoot":"","sources":["../../../src/adapter-utils/routing/resolveUserPathDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"resolveUserPathDefinitions.d.ts","sourceRoot":"","sources":["../../../src/adapter-utils/routing/resolveUserPathDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,8BAA8B,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IACvE,CAAC,aAAa,EAAE,IAAI,MAAM,EAAE,GACzB,MAAM,CAAC,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC,GACvB,qBAAqB,CAAC,CAAC,CAAC,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,MAAM,oBACxC,8BAA8B,CAAC,CAAC,CAAC,oBACjC,SAAS,CAAC,EAAE,KAC5B,0BAA0B,CAAC,CAAC,CAQ7B,CAAC"}
|
|
@@ -7,16 +7,13 @@
|
|
|
7
7
|
* Does NOT perform any validation on if the user-provided path translation configuration is valid.
|
|
8
8
|
*
|
|
9
9
|
* @param userTranslations The user-provided path translation configuration.
|
|
10
|
-
* @param
|
|
10
|
+
* @param availableLocales The available language tags.
|
|
11
11
|
* @returns The resolved path translations.
|
|
12
12
|
*/
|
|
13
|
-
export const resolveUserPathDefinitions = (userTranslations,
|
|
13
|
+
export const resolveUserPathDefinitions = (userTranslations, availableLocales) => Object.fromEntries(Object.entries(userTranslations).map(([path, translation]) => [
|
|
14
14
|
path,
|
|
15
15
|
typeof translation === "object"
|
|
16
16
|
? translation
|
|
17
|
-
: fromMessage(translation,
|
|
18
|
-
]));
|
|
19
|
-
const fromMessage = (message, availableLanguageTags) => Object.fromEntries(availableLanguageTags.map((languageTag) => [
|
|
20
|
-
languageTag,
|
|
21
|
-
message({}, { languageTag }),
|
|
17
|
+
: fromMessage(translation, availableLocales),
|
|
22
18
|
]));
|
|
19
|
+
const fromMessage = (message, availableLocales) => Object.fromEntries(availableLocales.map((locale) => [locale, message({}, { locale })]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export declare const paraglideRollupPlugin: (options:
|
|
2
|
-
project: string;
|
|
3
|
-
outdir: string;
|
|
4
|
-
options?: import("../compiler/compileProject.js").ParaglideCompilerOptions;
|
|
5
|
-
}) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
|
|
1
|
+
export declare const paraglideRollupPlugin: (options: import("../index.js").CompilerOptions) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
|
|
6
2
|
//# sourceMappingURL=rollup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/rollup.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/rollup.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,mHAAsC,CAAC"}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
import type { UnpluginFactory } from "unplugin";
|
|
2
|
-
import type {
|
|
3
|
-
export declare const unpluginFactory: UnpluginFactory<
|
|
4
|
-
/**
|
|
5
|
-
* The path to the inlang project.
|
|
6
|
-
*
|
|
7
|
-
* @example "./project.inlang"
|
|
8
|
-
*/
|
|
9
|
-
project: string;
|
|
10
|
-
/**
|
|
11
|
-
* The path to the output directory.
|
|
12
|
-
*
|
|
13
|
-
* @example "./src/paraglide"
|
|
14
|
-
*/
|
|
15
|
-
outdir: string;
|
|
16
|
-
options?: ParaglideCompilerOptions;
|
|
17
|
-
}>;
|
|
2
|
+
import type { CompilerOptions } from "../compiler/compiler-options.js";
|
|
3
|
+
export declare const unpluginFactory: UnpluginFactory<CompilerOptions>;
|
|
18
4
|
//# sourceMappingURL=unplugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"unplugin.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/unplugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAMhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAQvE,eAAO,MAAM,eAAe,EAAE,eAAe,CAAC,eAAe,CAiF3D,CAAC"}
|
|
@@ -1,66 +1,107 @@
|
|
|
1
1
|
import { compile } from "../compiler/compile.js";
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
3
|
+
import { resolve, relative } from "node:path";
|
|
4
|
+
import { nodeNormalizePath } from "../utilities/node-normalize-path.js";
|
|
5
|
+
import { Logger } from "../services/logger/index.js";
|
|
4
6
|
const PLUGIN_NAME = "unplugin-paraglide-js";
|
|
7
|
+
const logger = new Logger();
|
|
8
|
+
let previousCompilation;
|
|
5
9
|
export const unpluginFactory = (args) => ({
|
|
6
10
|
name: PLUGIN_NAME,
|
|
7
11
|
enforce: "pre",
|
|
8
12
|
async buildStart() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
logger.info("Compiling inlang project...");
|
|
14
|
+
try {
|
|
15
|
+
previousCompilation = await compile({
|
|
16
|
+
fs: wrappedFs,
|
|
17
|
+
previousCompilation,
|
|
18
|
+
...args,
|
|
19
|
+
});
|
|
20
|
+
logger.success("Compilation complete");
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
logger.error("Failed to compile project:", error.message);
|
|
24
|
+
logger.info("Please check your translation files for syntax errors.");
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
// in any case add the files to watch
|
|
28
|
+
for (const path of Array.from(readFiles)) {
|
|
29
|
+
this.addWatchFile(path);
|
|
30
|
+
}
|
|
18
31
|
}
|
|
19
32
|
},
|
|
20
33
|
async watchChange(path) {
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
const shouldCompile = readFiles.has(path) && !path.includes("cache");
|
|
35
|
+
if (shouldCompile === false) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const previouslyReadFiles = new Set(readFiles);
|
|
39
|
+
try {
|
|
40
|
+
logger.info(`Re-compiling inlang project... File "${relative(process.cwd(), path)}" has changed.`);
|
|
41
|
+
// Clear readFiles to track fresh file reads
|
|
23
42
|
readFiles.clear();
|
|
24
|
-
await compile({
|
|
25
|
-
project: args.project,
|
|
26
|
-
outdir: args.outdir,
|
|
27
|
-
options: args.options,
|
|
43
|
+
previousCompilation = await compile({
|
|
28
44
|
fs: wrappedFs,
|
|
45
|
+
previousCompilation,
|
|
46
|
+
...args,
|
|
29
47
|
});
|
|
48
|
+
logger.success("Compilation complete");
|
|
49
|
+
// Add any new files to watch
|
|
50
|
+
for (const filePath of Array.from(readFiles)) {
|
|
51
|
+
this.addWatchFile(filePath);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
readFiles = previouslyReadFiles;
|
|
56
|
+
// Reset compilation result on error
|
|
57
|
+
previousCompilation = undefined;
|
|
58
|
+
logger.warn("Failed to re-compile project:", e.message);
|
|
30
59
|
}
|
|
31
60
|
},
|
|
32
61
|
webpack(compiler) {
|
|
33
|
-
|
|
34
|
-
|
|
62
|
+
compiler.options.resolve = {
|
|
63
|
+
...compiler.options.resolve,
|
|
64
|
+
fallback: {
|
|
65
|
+
...compiler.options.resolve?.fallback,
|
|
66
|
+
// https://stackoverflow.com/a/72989932
|
|
67
|
+
async_hooks: false,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
35
70
|
compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, async () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
71
|
+
try {
|
|
72
|
+
previousCompilation = await compile({
|
|
73
|
+
fs: wrappedFs,
|
|
74
|
+
previousCompilation,
|
|
75
|
+
...args,
|
|
76
|
+
});
|
|
77
|
+
logger.success("Compilation complete");
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
logger.warn("Failed to compile project:", error.message);
|
|
81
|
+
logger.warn("Please check your translation files for syntax errors.");
|
|
82
|
+
}
|
|
42
83
|
});
|
|
43
84
|
},
|
|
44
85
|
});
|
|
45
|
-
|
|
86
|
+
let readFiles = new Set();
|
|
46
87
|
// Create a wrapper around the fs object to intercept and store read files
|
|
47
88
|
const wrappedFs = {
|
|
48
89
|
...fs,
|
|
49
90
|
// @ts-expect-error - Node's fs has too many overloads
|
|
50
91
|
readFile: (path, options, callback) => {
|
|
51
|
-
readFiles.add(resolve(process.cwd(), path.toString()));
|
|
92
|
+
readFiles.add(nodeNormalizePath(resolve(process.cwd(), path.toString())));
|
|
52
93
|
return fs.readFile(path, options, callback);
|
|
53
94
|
},
|
|
54
95
|
// @ts-expect-error - Node's fs has too many overloads
|
|
55
96
|
readFileSync: (path, options) => {
|
|
56
|
-
readFiles.add(resolve(process.cwd(), path.toString()));
|
|
97
|
+
readFiles.add(nodeNormalizePath(resolve(process.cwd(), path.toString())));
|
|
57
98
|
return fs.readFileSync(path, options);
|
|
58
99
|
},
|
|
59
100
|
promises: {
|
|
60
101
|
...fs.promises,
|
|
61
102
|
// @ts-expect-error - Node's fs.promises has too many overloads
|
|
62
103
|
readFile: async (path, options) => {
|
|
63
|
-
readFiles.add(resolve(process.cwd(), path.toString()));
|
|
104
|
+
readFiles.add(nodeNormalizePath(resolve(process.cwd(), path.toString())));
|
|
64
105
|
return fs.promises.readFile(path, options);
|
|
65
106
|
},
|
|
66
107
|
},
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export declare const paraglideVitePlugin: (options:
|
|
2
|
-
project: string;
|
|
3
|
-
outdir: string;
|
|
4
|
-
options?: import("../compiler/compileProject.js").ParaglideCompilerOptions;
|
|
5
|
-
}) => import("unplugin").VitePlugin<any> | import("unplugin").VitePlugin<any>[];
|
|
1
|
+
export declare const paraglideVitePlugin: (options: import("../index.js").CompilerOptions) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
|
|
6
2
|
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/vite.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/vite.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,+GAAoC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../../src/bundler-plugins/webpack.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,2EAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,cAAc,SAkDzB,CAAC"}
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import fs from "node:fs";
|
|
3
2
|
import { resolve } from "node:path";
|
|
4
3
|
import { Logger } from "../../../services/logger/index.js";
|
|
5
|
-
import { runCompiler } from "../../steps/run-compiler.js";
|
|
6
4
|
import { DEFAULT_OUTDIR } from "../../defaults.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { compile } from "../../../compiler/compile.js";
|
|
6
|
+
import { defaultCompilerOptions, } from "../../../compiler/compiler-options.js";
|
|
9
7
|
export const compileCommand = new Command()
|
|
10
8
|
.name("compile")
|
|
11
9
|
.summary("Compiles inlang Paraglide-JS")
|
|
12
10
|
.requiredOption("--project <path>", 'The path to the inlang project. Example: "./project.inlang"')
|
|
13
11
|
.requiredOption("--outdir <path>", 'The path to the output directory. Example: "./src/paraglide"', DEFAULT_OUTDIR)
|
|
12
|
+
.option("--strategy <items...>", [
|
|
13
|
+
"The strategy to be used.",
|
|
14
|
+
"",
|
|
15
|
+
"Example: --strategy cookie globalVariable baseLocale",
|
|
16
|
+
"Read more on https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy",
|
|
17
|
+
].join("\n"))
|
|
14
18
|
.requiredOption("--silent", "Only log errors to the console", false)
|
|
15
19
|
.action(async (options) => {
|
|
16
20
|
const logger = new Logger({ silent: options.silent, prefix: true });
|
|
17
21
|
const path = resolve(process.cwd(), options.project);
|
|
18
|
-
logger.info(`Compiling inlang project
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
project,
|
|
26
|
-
fs: fs.promises,
|
|
27
|
-
outdir: options.outdir,
|
|
28
|
-
});
|
|
29
|
-
logger.success("Successfully compiled the project.");
|
|
30
|
-
const errors = await project.errors.get();
|
|
31
|
-
if (errors.length > 0) {
|
|
32
|
-
logger.warn(`But the project reported the following warnings and/or errors that might have influenced compilation:`);
|
|
33
|
-
for (const error of errors) {
|
|
34
|
-
logger.log(`${error}`);
|
|
35
|
-
}
|
|
22
|
+
logger.info(`Compiling inlang project ...`);
|
|
23
|
+
try {
|
|
24
|
+
await compile({
|
|
25
|
+
project: path,
|
|
26
|
+
outdir: options.outdir,
|
|
27
|
+
strategy: options.strategy ?? defaultCompilerOptions.strategy,
|
|
28
|
+
});
|
|
36
29
|
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
logger.error("Error while compiling inlang project.");
|
|
32
|
+
logger.error(e);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
logger.success(`Successfully compiled inlang project.`);
|
|
37
36
|
process.exit(0);
|
|
38
37
|
});
|
|
@@ -1 +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;AAGpC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;
|
|
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;AAGpC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAQ3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAO9C,eAAO,MAAM,WAAW,SAiErB,CAAC;AAEJ,eAAO,MAAM,+BAA+B,EAAE,OAAO,CACpD;IACC,EAAE,EAAE,cAAc,kBAAkB,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACxB,EACD,OAAO,CAYP,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAC7C;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,cAAc,kBAAkB,CAAC,CAAA;CAAE,EACzD;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,CAU3B,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAChD;IACC,EAAE,EAAE,cAAc,kBAAkB,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACxB,EACD,OAAO,CAuDP,CAAC"}
|
|
@@ -6,18 +6,20 @@ import { findPackageJson } from "../../../services/environment/package.js";
|
|
|
6
6
|
import { checkForUncommittedChanges } from "../../steps/check-for-uncomitted-changes.js";
|
|
7
7
|
import { initializeInlangProject } from "../../steps/initialize-inlang-project.js";
|
|
8
8
|
import { maybeAddSherlock } from "../../steps/maybe-add-sherlock.js";
|
|
9
|
-
import {
|
|
9
|
+
import { maybeUpdateTsConfig } from "../../steps/update-ts-config.js";
|
|
10
10
|
import { promptForOutdir } from "../../steps/prompt-for-outdir.js";
|
|
11
11
|
import { updatePackageJson } from "../../steps/update-package-json.js";
|
|
12
|
-
import { runCompiler } from "../../steps/run-compiler.js";
|
|
13
12
|
import nodeFs from "node:fs";
|
|
14
13
|
import { ENV_VARIABLES } from "../../../services/env-variables/index.js";
|
|
14
|
+
import { detectBundler } from "../../steps/detect-bundler.js";
|
|
15
|
+
import { addVitePlugin } from "../../steps/add-vite-plugin.js";
|
|
16
|
+
import { compile } from "../../../compiler/compile.js";
|
|
15
17
|
export const initCommand = new Command()
|
|
16
18
|
.name("init")
|
|
17
19
|
.summary("Initializes inlang Paraglide-JS.")
|
|
18
20
|
.action(async () => {
|
|
19
21
|
const logger = new Logger({ silent: false, prefix: false });
|
|
20
|
-
logger.box("Welcome to inlang Paraglide
|
|
22
|
+
logger.box("Welcome to inlang Paraglide JS 🪂");
|
|
21
23
|
const ctx = {
|
|
22
24
|
logger,
|
|
23
25
|
fs: nodeFs.promises,
|
|
@@ -29,11 +31,20 @@ export const initCommand = new Command()
|
|
|
29
31
|
const ctx3 = await initializeInlangProject(ctx2);
|
|
30
32
|
const ctx4 = await promptForOutdir(ctx3);
|
|
31
33
|
const ctx5 = await addParaglideJsToDevDependencies(ctx4);
|
|
32
|
-
const ctx6 = await
|
|
33
|
-
|
|
34
|
+
const ctx6 = await detectBundler(ctx5);
|
|
35
|
+
if (ctx6.bundler === "vite") {
|
|
36
|
+
await addVitePlugin(ctx6);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
await addCompileStepToPackageJSON(ctx6);
|
|
40
|
+
}
|
|
41
|
+
const ctx7 = await maybeUpdateTsConfig(ctx6);
|
|
34
42
|
const ctx8 = await maybeAddSherlock(ctx7);
|
|
35
43
|
try {
|
|
36
|
-
await
|
|
44
|
+
await compile({
|
|
45
|
+
project: ctx8.projectPath,
|
|
46
|
+
outdir: ctx8.outdir,
|
|
47
|
+
});
|
|
37
48
|
ctx.logger.success("Run paraglide compiler");
|
|
38
49
|
}
|
|
39
50
|
catch {
|
|
@@ -45,15 +56,15 @@ export const initCommand = new Command()
|
|
|
45
56
|
`inlang Paraglide-JS has been set up sucessfully.`,
|
|
46
57
|
"\n",
|
|
47
58
|
`1. Run your install command (npm i, yarn install, etc)`,
|
|
48
|
-
`2.
|
|
49
|
-
`3.
|
|
50
|
-
`4. Done :) Happy paragliding 🪂`,
|
|
59
|
+
`2. Run the build script (npm run build, or similar.)`,
|
|
60
|
+
`3. Define the locales in ${relativeSettingsFilePath}`,
|
|
51
61
|
"\n",
|
|
52
62
|
"\n",
|
|
53
63
|
`For questions and feedback, visit`,
|
|
54
64
|
`https://github.com/opral/inlang-paraglide-js/issues`,
|
|
55
65
|
].join("\n");
|
|
56
66
|
ctx.logger.box(successMessage);
|
|
67
|
+
process.exit(0);
|
|
57
68
|
});
|
|
58
69
|
export const addParaglideJsToDevDependencies = async (ctx) => {
|
|
59
70
|
const ctx1 = await updatePackageJson({
|
package/dist/cli/defaults.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,wBAAgB,qBAAqB;;;;;;;;EAEpC;AAED,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,cAAc,oBAAoB,CAAC"}
|
package/dist/cli/defaults.js
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
const defaultProjectSettings = {
|
|
6
6
|
$schema: "https://inlang.com/schema/project-settings",
|
|
7
7
|
baseLocale: "en",
|
|
8
|
-
locales: ["en"],
|
|
9
|
-
modules: [
|
|
8
|
+
locales: ["en", "de"],
|
|
9
|
+
modules: [
|
|
10
|
+
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@3/dist/index.js",
|
|
11
|
+
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@1/dist/index.js",
|
|
12
|
+
],
|
|
10
13
|
"plugin.inlang.messageFormat": {
|
|
11
14
|
pathPattern: "./messages/{locale}.json",
|
|
12
15
|
},
|
|
@@ -15,14 +18,6 @@ const defaultProjectSettings = {
|
|
|
15
18
|
* @returns A new copy of the default project template that is safe to mutate.
|
|
16
19
|
*/
|
|
17
20
|
export function getNewProjectTemplate() {
|
|
18
|
-
if (!("structuredClone" in globalThis)) {
|
|
19
|
-
try {
|
|
20
|
-
return JSON.parse(JSON.stringify(defaultProjectSettings));
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
throw new Error("structuredClone is not supported in your Node Version. Please use version 17 or higher");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
21
|
return structuredClone(defaultProjectSettings);
|
|
27
22
|
}
|
|
28
23
|
export const DEFAULT_PROJECT_PATH = "./project.inlang";
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
export { checkForUncommittedChanges } from "./steps/check-for-uncomitted-changes.js";
|
|
3
|
-
export { initializeInlangProject } from "./steps/initialize-inlang-project.js";
|
|
4
|
-
export { maybeAddSherlock } from "./steps/maybe-add-sherlock.js";
|
|
5
|
-
export { maybeChangeTsConfig } from "./steps/update-ts-config.js";
|
|
6
|
-
export { promptForOutdir } from "./steps/prompt-for-outdir.js";
|
|
7
|
-
export { updatePackageJson } from "./steps/update-package-json.js";
|
|
8
|
-
export { runCompiler } from "./steps/run-compiler.js";
|
|
9
2
|
export declare const cli: Command;
|
|
10
|
-
export * as Utils from "./utils.js";
|
|
11
|
-
export * as Defaults from "./defaults.js";
|
|
12
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
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"}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { compileCommand } from "./commands/compile/command.js";
|
|
3
3
|
import { ENV_VARIABLES } from "../services/env-variables/index.js";
|
|
4
|
-
|
|
5
|
-
export { initializeInlangProject } from "./steps/initialize-inlang-project.js";
|
|
6
|
-
export { maybeAddSherlock } from "./steps/maybe-add-sherlock.js";
|
|
7
|
-
export { maybeChangeTsConfig } from "./steps/update-ts-config.js";
|
|
8
|
-
export { promptForOutdir } from "./steps/prompt-for-outdir.js";
|
|
9
|
-
export { updatePackageJson } from "./steps/update-package-json.js";
|
|
10
|
-
export { runCompiler } from "./steps/run-compiler.js";
|
|
4
|
+
import { initCommand } from "./commands/init/command.js";
|
|
11
5
|
export const cli = new Command()
|
|
12
6
|
.name("paraglide-js")
|
|
13
7
|
.addCommand(compileCommand)
|
|
8
|
+
.addCommand(initCommand)
|
|
14
9
|
.showHelpAfterError()
|
|
15
10
|
.version(ENV_VARIABLES.PARJS_PACKAGE_VERSION);
|
|
16
|
-
export * as Utils from "./utils.js";
|
|
17
|
-
export * as Defaults from "./defaults.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
projectPath: string;
|
|
6
|
+
outdir: string;
|
|
7
|
+
logger?: Logger;
|
|
8
|
+
configPath: string;
|
|
9
|
+
}, unknown>;
|
|
10
|
+
//# sourceMappingURL=add-vite-plugin.d.ts.map
|
|
@@ -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,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB,EACD,OAAO,CAoCP,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
projectPath: ctx.projectPath,
|
|
9
|
+
outdir: ctx.outdir,
|
|
10
|
+
});
|
|
11
|
+
if (result.ok) {
|
|
12
|
+
await ctx.fs.writeFile(ctx.configPath, result.updated);
|
|
13
|
+
ctx.logger?.success("Added the Paraglide JS vite plugin to the vite config.");
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const msg = [
|
|
17
|
+
"Failed to add the Paraglide JS vite plugin in vite.config.js.",
|
|
18
|
+
"Reason: " + result.reason,
|
|
19
|
+
"",
|
|
20
|
+
"Please add the plugin manually.",
|
|
21
|
+
].join("\n");
|
|
22
|
+
ctx.logger?.warn(msg);
|
|
23
|
+
return ctx;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
ctx.logger?.error(`Failed to add the Paraglide JS vite plugin to ${ctx.configPath}.`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
return ctx;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @private Only exported for testings
|
|
34
|
+
*/
|
|
35
|
+
function updateViteConfig(args) {
|
|
36
|
+
if (args.config.includes("@inlang/paraglide-js")) {
|
|
37
|
+
return {
|
|
38
|
+
ok: false,
|
|
39
|
+
reason: "Already present",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const PLUGINS_REGEX = /plugins\s*:\s*\[/g;
|
|
43
|
+
const match = PLUGINS_REGEX.exec(args.config);
|
|
44
|
+
if (!match) {
|
|
45
|
+
return {
|
|
46
|
+
ok: false,
|
|
47
|
+
reason: "Could not find the plugins array",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const endIndex = match.index + match[0].length;
|
|
51
|
+
const before = args.config.slice(0, endIndex);
|
|
52
|
+
const after = args.config.slice(endIndex);
|
|
53
|
+
const updatedConfig = "import { paraglideVitePlugin } from '@inlang/paraglide-js'\n" +
|
|
54
|
+
before +
|
|
55
|
+
`paraglideVitePlugin({ project: '${args.projectPath}', outdir: '${args.outdir}' }),` +
|
|
56
|
+
after;
|
|
57
|
+
return {
|
|
58
|
+
ok: true,
|
|
59
|
+
updated: updatedConfig,
|
|
60
|
+
};
|
|
61
|
+
}
|