@gtkx/cli 2.0.0-beta.1 → 2.0.0-beta.10
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 +43 -40
- package/bin/gtkx-dev-runner.js +5 -1
- package/bin/gtkx.js +5 -1
- package/dist/builder.d.ts +1 -0
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +44 -12
- package/dist/builder.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -2
- package/dist/cli.js.map +1 -1
- package/dist/codegen/config-dependencies.d.ts +3 -0
- package/dist/codegen/config-dependencies.d.ts.map +1 -0
- package/dist/codegen/config-dependencies.js +355 -0
- package/dist/codegen/config-dependencies.js.map +1 -0
- package/dist/codegen/freshness.d.ts.map +1 -1
- package/dist/codegen/freshness.js +5 -1
- package/dist/codegen/freshness.js.map +1 -1
- package/dist/codegen/reference.d.ts.map +1 -1
- package/dist/codegen/reference.js +1 -0
- package/dist/codegen/reference.js.map +1 -1
- package/dist/codegen/run-codegen.d.ts +6 -3
- package/dist/codegen/run-codegen.d.ts.map +1 -1
- package/dist/codegen/run-codegen.js +42 -18
- package/dist/codegen/run-codegen.js.map +1 -1
- package/dist/codegen/store-resolver.d.ts +3 -1
- package/dist/codegen/store-resolver.d.ts.map +1 -1
- package/dist/codegen/store-resolver.js +7 -4
- package/dist/codegen/store-resolver.js.map +1 -1
- package/dist/commands/build.d.ts +5 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +83 -10
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/cleanup.d.ts +9 -0
- package/dist/commands/cleanup.d.ts.map +1 -0
- package/dist/commands/cleanup.js +42 -0
- package/dist/commands/cleanup.js.map +1 -0
- package/dist/commands/codegen.d.ts +1 -0
- package/dist/commands/codegen.d.ts.map +1 -1
- package/dist/commands/codegen.js +6 -5
- package/dist/commands/codegen.js.map +1 -1
- package/dist/commands/deploy.d.ts +5 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +10 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +9 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +31 -4
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +1 -0
- package/dist/commands/docs.js.map +1 -1
- package/dist/deploy/depends.d.ts.map +1 -1
- package/dist/deploy/depends.js +24 -2
- package/dist/deploy/depends.js.map +1 -1
- package/dist/deploy/download.d.ts +7 -3
- package/dist/deploy/download.d.ts.map +1 -1
- package/dist/deploy/download.js +19 -20
- package/dist/deploy/download.js.map +1 -1
- package/dist/deploy/freedesktop/metainfo.d.ts.map +1 -1
- package/dist/deploy/freedesktop/metainfo.js +41 -2
- package/dist/deploy/freedesktop/metainfo.js.map +1 -1
- package/dist/deploy/freedesktop/validate.d.ts.map +1 -1
- package/dist/deploy/freedesktop/validate.js +58 -14
- package/dist/deploy/freedesktop/validate.js.map +1 -1
- package/dist/deploy/native-addon.d.ts +5 -0
- package/dist/deploy/native-addon.d.ts.map +1 -0
- package/dist/deploy/native-addon.js +134 -0
- package/dist/deploy/native-addon.js.map +1 -0
- package/dist/deploy/nfpm/config.d.ts +3 -2
- package/dist/deploy/nfpm/config.d.ts.map +1 -1
- package/dist/deploy/nfpm/config.js +7 -4
- package/dist/deploy/nfpm/config.js.map +1 -1
- package/dist/deploy/nfpm/contents.d.ts.map +1 -1
- package/dist/deploy/nfpm/contents.js +8 -0
- package/dist/deploy/nfpm/contents.js.map +1 -1
- package/dist/deploy/node-runtime/download.js +2 -2
- package/dist/deploy/node-runtime/download.js.map +1 -1
- package/dist/deploy/node-runtime/elf.d.ts +4 -1
- package/dist/deploy/node-runtime/elf.d.ts.map +1 -1
- package/dist/deploy/node-runtime/elf.js +34 -5
- package/dist/deploy/node-runtime/elf.js.map +1 -1
- package/dist/deploy/node-runtime/guard.d.ts.map +1 -1
- package/dist/deploy/node-runtime/guard.js +7 -14
- package/dist/deploy/node-runtime/guard.js.map +1 -1
- package/dist/deploy/node-runtime/index.d.ts +3 -1
- package/dist/deploy/node-runtime/index.d.ts.map +1 -1
- package/dist/deploy/node-runtime/index.js +103 -10
- package/dist/deploy/node-runtime/index.js.map +1 -1
- package/dist/deploy/node-runtime/sonames.d.ts +5 -0
- package/dist/deploy/node-runtime/sonames.d.ts.map +1 -0
- package/dist/deploy/node-runtime/sonames.js +13 -0
- package/dist/deploy/node-runtime/sonames.js.map +1 -0
- package/dist/deploy/notices/node-runtime.js +2 -2
- package/dist/deploy/notices/node-runtime.js.map +1 -1
- package/dist/deploy/payload/launcher.d.ts.map +1 -1
- package/dist/deploy/payload/launcher.js +14 -1
- package/dist/deploy/payload/launcher.js.map +1 -1
- package/dist/deploy/payload/stage.d.ts +2 -1
- package/dist/deploy/payload/stage.d.ts.map +1 -1
- package/dist/deploy/payload/stage.js +46 -5
- package/dist/deploy/payload/stage.js.map +1 -1
- package/dist/deploy/run-deploy.d.ts +2 -0
- package/dist/deploy/run-deploy.d.ts.map +1 -1
- package/dist/deploy/run-deploy.js +197 -52
- package/dist/deploy/run-deploy.js.map +1 -1
- package/dist/deploy/settings/arch.d.ts +9 -3
- package/dist/deploy/settings/arch.d.ts.map +1 -1
- package/dist/deploy/settings/arch.js +27 -6
- package/dist/deploy/settings/arch.js.map +1 -1
- package/dist/deploy/settings/build-manifest.d.ts +6 -1
- package/dist/deploy/settings/build-manifest.d.ts.map +1 -1
- package/dist/deploy/settings/build-manifest.js +15 -4
- package/dist/deploy/settings/build-manifest.js.map +1 -1
- package/dist/deploy/settings/extra-files.d.ts +1 -1
- package/dist/deploy/settings/extra-files.d.ts.map +1 -1
- package/dist/deploy/settings/extra-files.js +25 -3
- package/dist/deploy/settings/extra-files.js.map +1 -1
- package/dist/deploy/settings/index.d.ts +3 -1
- package/dist/deploy/settings/index.d.ts.map +1 -1
- package/dist/deploy/settings/index.js +4 -2
- package/dist/deploy/settings/index.js.map +1 -1
- package/dist/deploy/settings/libraries.d.ts.map +1 -1
- package/dist/deploy/settings/libraries.js +2 -1
- package/dist/deploy/settings/libraries.js.map +1 -1
- package/dist/deploy/settings/paths.d.ts +4 -2
- package/dist/deploy/settings/paths.d.ts.map +1 -1
- package/dist/deploy/settings/paths.js +121 -12
- package/dist/deploy/settings/paths.js.map +1 -1
- package/dist/deploy/targets/appimage.d.ts.map +1 -1
- package/dist/deploy/targets/appimage.js +1 -0
- package/dist/deploy/targets/appimage.js.map +1 -1
- package/dist/deploy/targets/flatpak-pnpm.js +4 -4
- package/dist/deploy/targets/flatpak-pnpm.js.map +1 -1
- package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak-source.js +13 -2
- package/dist/deploy/targets/flatpak-source.js.map +1 -1
- package/dist/deploy/targets/flatpak.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak.js +1 -0
- package/dist/deploy/targets/flatpak.js.map +1 -1
- package/dist/deploy/targets/nfpm-target.d.ts.map +1 -1
- package/dist/deploy/targets/nfpm-target.js +13 -7
- package/dist/deploy/targets/nfpm-target.js.map +1 -1
- package/dist/deploy/types.d.ts +5 -2
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/deploy/types.js.map +1 -1
- package/dist/deploy/vendored/appimagetool.js +2 -2
- package/dist/deploy/vendored/appimagetool.js.map +1 -1
- package/dist/deploy/vendored/nfpm.js +1 -1
- package/dist/deploy/vendored/nfpm.js.map +1 -1
- package/dist/dev/catalog-writes.d.ts +8 -0
- package/dist/dev/catalog-writes.d.ts.map +1 -0
- package/dist/dev/catalog-writes.js +26 -0
- package/dist/dev/catalog-writes.js.map +1 -0
- package/dist/dev/entry-env.d.ts +2 -1
- package/dist/dev/entry-env.d.ts.map +1 -1
- package/dist/dev/entry-env.js +2 -1
- package/dist/dev/entry-env.js.map +1 -1
- package/dist/dev/font-dir.d.ts +3 -0
- package/dist/dev/font-dir.d.ts.map +1 -0
- package/dist/dev/font-dir.js +9 -0
- package/dist/dev/font-dir.js.map +1 -0
- package/dist/dev/headless.d.ts +3 -0
- package/dist/dev/headless.d.ts.map +1 -0
- package/dist/dev/headless.js +35 -0
- package/dist/dev/headless.js.map +1 -0
- package/dist/dev/runner-deps.d.ts +1 -1
- package/dist/dev/runner-deps.d.ts.map +1 -1
- package/dist/dev/runner-deps.js +12 -7
- package/dist/dev/runner-deps.js.map +1 -1
- package/dist/dev/runner-main.d.ts.map +1 -1
- package/dist/dev/runner-main.js +10 -3
- package/dist/dev/runner-main.js.map +1 -1
- package/dist/dev/runner.d.ts +2 -0
- package/dist/dev/runner.d.ts.map +1 -1
- package/dist/dev/runner.js +26 -7
- package/dist/dev/runner.js.map +1 -1
- package/dist/dev/supervisor.d.ts +3 -1
- package/dist/dev/supervisor.d.ts.map +1 -1
- package/dist/dev/supervisor.js +132 -29
- package/dist/dev/supervisor.js.map +1 -1
- package/dist/dev/vite-dev-server.d.ts +1 -1
- package/dist/dev/vite-dev-server.d.ts.map +1 -1
- package/dist/dev/vite-dev-server.js +14 -2
- package/dist/dev/vite-dev-server.js.map +1 -1
- package/dist/dev/watch-ignore.d.ts +3 -0
- package/dist/dev/watch-ignore.d.ts.map +1 -0
- package/dist/dev/watch-ignore.js +11 -0
- package/dist/dev/watch-ignore.js.map +1 -0
- package/dist/i18n/catalogs.d.ts +6 -2
- package/dist/i18n/catalogs.d.ts.map +1 -1
- package/dist/i18n/catalogs.js +10 -7
- package/dist/i18n/catalogs.js.map +1 -1
- package/dist/i18n/source-messages.d.ts +3 -1
- package/dist/i18n/source-messages.d.ts.map +1 -1
- package/dist/i18n/source-messages.js +973 -9
- package/dist/i18n/source-messages.js.map +1 -1
- package/dist/internal/agent-rules.d.ts.map +1 -1
- package/dist/internal/agent-rules.js +7 -2
- package/dist/internal/agent-rules.js.map +1 -1
- package/dist/internal/banner.d.ts +4 -2
- package/dist/internal/banner.d.ts.map +1 -1
- package/dist/internal/banner.js +19 -5
- package/dist/internal/banner.js.map +1 -1
- package/dist/internal/build-manifest.d.ts +5 -2
- package/dist/internal/build-manifest.d.ts.map +1 -1
- package/dist/internal/build-manifest.js +15 -2
- package/dist/internal/build-manifest.js.map +1 -1
- package/dist/internal/build-output.d.ts +8 -0
- package/dist/internal/build-output.d.ts.map +1 -0
- package/dist/internal/build-output.js +116 -0
- package/dist/internal/build-output.js.map +1 -0
- package/dist/internal/cache-root.d.ts +3 -0
- package/dist/internal/cache-root.d.ts.map +1 -0
- package/dist/internal/cache-root.js +9 -0
- package/dist/internal/cache-root.js.map +1 -0
- package/dist/internal/compile-cache-store.d.ts +4 -0
- package/dist/internal/compile-cache-store.d.ts.map +1 -0
- package/dist/internal/compile-cache-store.js +41 -0
- package/dist/internal/compile-cache-store.js.map +1 -0
- package/dist/internal/compile-cache.d.ts +4 -0
- package/dist/internal/compile-cache.d.ts.map +1 -0
- package/dist/internal/compile-cache.js +16 -0
- package/dist/internal/compile-cache.js.map +1 -0
- package/dist/internal/deploy-out-dir.d.ts +4 -0
- package/dist/internal/deploy-out-dir.d.ts.map +1 -0
- package/dist/internal/deploy-out-dir.js +5 -0
- package/dist/internal/deploy-out-dir.js.map +1 -0
- package/dist/internal/docs-elements.d.ts +1 -0
- package/dist/internal/docs-elements.d.ts.map +1 -1
- package/dist/internal/docs-elements.js +5 -4
- package/dist/internal/docs-elements.js.map +1 -1
- package/dist/internal/entry-arg.d.ts +4 -1
- package/dist/internal/entry-arg.d.ts.map +1 -1
- package/dist/internal/entry-arg.js +7 -1
- package/dist/internal/entry-arg.js.map +1 -1
- package/dist/internal/errors.d.ts +2 -1
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +1 -1
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/font-path.d.ts +4 -0
- package/dist/internal/font-path.d.ts.map +1 -0
- package/dist/internal/font-path.js +12 -0
- package/dist/internal/font-path.js.map +1 -0
- package/dist/internal/font-staging.d.ts +6 -0
- package/dist/internal/font-staging.d.ts.map +1 -0
- package/dist/internal/font-staging.js +94 -0
- package/dist/internal/font-staging.js.map +1 -0
- package/dist/internal/icon-staging.d.ts +3 -0
- package/dist/internal/icon-staging.d.ts.map +1 -0
- package/dist/internal/icon-staging.js +40 -0
- package/dist/internal/icon-staging.js.map +1 -0
- package/dist/internal/import-scan.d.ts +4 -0
- package/dist/internal/import-scan.d.ts.map +1 -0
- package/dist/internal/import-scan.js +138 -0
- package/dist/internal/import-scan.js.map +1 -0
- package/dist/internal/module-hash.d.ts +3 -0
- package/dist/internal/module-hash.d.ts.map +1 -0
- package/dist/internal/module-hash.js +19 -0
- package/dist/internal/module-hash.js.map +1 -0
- package/dist/internal/output-directory.d.ts +15 -0
- package/dist/internal/output-directory.d.ts.map +1 -0
- package/dist/internal/output-directory.js +490 -0
- package/dist/internal/output-directory.js.map +1 -0
- package/dist/internal/parent-process.d.ts +12 -0
- package/dist/internal/parent-process.d.ts.map +1 -0
- package/dist/internal/parent-process.js +74 -0
- package/dist/internal/parent-process.js.map +1 -0
- package/dist/internal/prepare-project.d.ts +3 -0
- package/dist/internal/prepare-project.d.ts.map +1 -1
- package/dist/internal/prepare-project.js +9 -3
- package/dist/internal/prepare-project.js.map +1 -1
- package/dist/internal/react-compiler-cache.d.ts +13 -0
- package/dist/internal/react-compiler-cache.d.ts.map +1 -0
- package/dist/internal/react-compiler-cache.js +182 -0
- package/dist/internal/react-compiler-cache.js.map +1 -0
- package/dist/internal/source-imports.d.ts +7 -2
- package/dist/internal/source-imports.d.ts.map +1 -1
- package/dist/internal/source-imports.js +31 -11
- package/dist/internal/source-imports.js.map +1 -1
- package/dist/internal/staging-file.d.ts +5 -0
- package/dist/internal/staging-file.d.ts.map +1 -0
- package/dist/internal/staging-file.js +35 -0
- package/dist/internal/staging-file.js.map +1 -0
- package/dist/internal/xdg-banner.d.ts +4 -0
- package/dist/internal/xdg-banner.d.ts.map +1 -0
- package/dist/internal/xdg-banner.js +11 -0
- package/dist/internal/xdg-banner.js.map +1 -0
- package/dist/internal/xdg-data-dirs.d.ts +2 -1
- package/dist/internal/xdg-data-dirs.d.ts.map +1 -1
- package/dist/internal/xdg-data-dirs.js +1 -1
- package/dist/internal/xdg-data-dirs.js.map +1 -1
- package/dist/mcp/client.js +2 -2
- package/dist/mcp/client.js.map +1 -1
- package/dist/settings/schema.d.ts.map +1 -1
- package/dist/settings/schema.js +3 -8
- package/dist/settings/schema.js.map +1 -1
- package/dist/vite-plugins/asset-extensions.d.ts.map +1 -1
- package/dist/vite-plugins/asset-extensions.js +2 -0
- package/dist/vite-plugins/asset-extensions.js.map +1 -1
- package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
- package/dist/vite-plugins/asset-imports.js +20 -6
- package/dist/vite-plugins/asset-imports.js.map +1 -1
- package/dist/vite-plugins/asset-specifier.d.ts +5 -1
- package/dist/vite-plugins/asset-specifier.d.ts.map +1 -1
- package/dist/vite-plugins/asset-specifier.js +10 -1
- package/dist/vite-plugins/asset-specifier.js.map +1 -1
- package/dist/vite-plugins/build-manifest.d.ts +5 -1
- package/dist/vite-plugins/build-manifest.d.ts.map +1 -1
- package/dist/vite-plugins/build-manifest.js +2 -1
- package/dist/vite-plugins/build-manifest.js.map +1 -1
- package/dist/vite-plugins/built-url.d.ts.map +1 -1
- package/dist/vite-plugins/built-url.js +5 -2
- package/dist/vite-plugins/built-url.js.map +1 -1
- package/dist/vite-plugins/css.d.ts.map +1 -1
- package/dist/vite-plugins/css.js +13 -5
- package/dist/vite-plugins/css.js.map +1 -1
- package/dist/vite-plugins/ensure-store.d.ts +1 -1
- package/dist/vite-plugins/ensure-store.d.ts.map +1 -1
- package/dist/vite-plugins/ensure-store.js +2 -2
- package/dist/vite-plugins/ensure-store.js.map +1 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts +6 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts.map +1 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.js +3 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.js.map +1 -1
- package/dist/vite-plugins/fast-refresh/swc-refresh.d.ts.map +1 -1
- package/dist/vite-plugins/fast-refresh/swc-refresh.js +23 -14
- package/dist/vite-plugins/fast-refresh/swc-refresh.js.map +1 -1
- package/dist/vite-plugins/font-name.d.ts +3 -0
- package/dist/vite-plugins/font-name.d.ts.map +1 -0
- package/dist/vite-plugins/font-name.js +406 -0
- package/dist/vite-plugins/font-name.js.map +1 -0
- package/dist/vite-plugins/font-worker-env.d.ts +4 -0
- package/dist/vite-plugins/font-worker-env.d.ts.map +1 -0
- package/dist/vite-plugins/font-worker-env.js +19 -0
- package/dist/vite-plugins/font-worker-env.js.map +1 -0
- package/dist/vite-plugins/font.d.ts +4 -0
- package/dist/vite-plugins/font.d.ts.map +1 -0
- package/dist/vite-plugins/font.js +111 -0
- package/dist/vite-plugins/font.js.map +1 -0
- package/dist/vite-plugins/i18n.d.ts +11 -2
- package/dist/vite-plugins/i18n.d.ts.map +1 -1
- package/dist/vite-plugins/i18n.js +74 -8
- package/dist/vite-plugins/i18n.js.map +1 -1
- package/dist/vite-plugins/icon-worker-env.d.ts +4 -0
- package/dist/vite-plugins/icon-worker-env.d.ts.map +1 -0
- package/dist/vite-plugins/icon-worker-env.js +23 -0
- package/dist/vite-plugins/icon-worker-env.js.map +1 -0
- package/dist/vite-plugins/icons.d.ts.map +1 -1
- package/dist/vite-plugins/icons.js +4 -9
- package/dist/vite-plugins/icons.js.map +1 -1
- package/dist/vite-plugins/index.d.ts +10 -1
- package/dist/vite-plugins/index.d.ts.map +1 -1
- package/dist/vite-plugins/index.js +17 -3
- package/dist/vite-plugins/index.js.map +1 -1
- package/dist/vite-plugins/native.d.ts.map +1 -1
- package/dist/vite-plugins/native.js +0 -4
- package/dist/vite-plugins/native.js.map +1 -1
- package/dist/vite-plugins/react-compiler.d.ts.map +1 -1
- package/dist/vite-plugins/react-compiler.js +57 -18
- package/dist/vite-plugins/react-compiler.js.map +1 -1
- package/dist/vite-plugins/resource-shared.d.ts +3 -1
- package/dist/vite-plugins/resource-shared.d.ts.map +1 -1
- package/dist/vite-plugins/resource-shared.js +3 -1
- package/dist/vite-plugins/resource-shared.js.map +1 -1
- package/dist/vite-plugins/resources.d.ts.map +1 -1
- package/dist/vite-plugins/resources.js +9 -6
- package/dist/vite-plugins/resources.js.map +1 -1
- package/dist/vite-plugins/self-contained.d.ts.map +1 -1
- package/dist/vite-plugins/self-contained.js +159 -158
- package/dist/vite-plugins/self-contained.js.map +1 -1
- package/dist/vite-plugins/settings-worker-env.d.ts +1 -1
- package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -1
- package/dist/vite-plugins/settings-worker-env.js +4 -4
- package/dist/vite-plugins/settings-worker-env.js.map +1 -1
- package/dist/vite-plugins/settings.d.ts.map +1 -1
- package/dist/vite-plugins/settings.js +25 -14
- package/dist/vite-plugins/settings.js.map +1 -1
- package/dist/vite-plugins/store-links.d.ts.map +1 -1
- package/dist/vite-plugins/store-links.js +9 -5
- package/dist/vite-plugins/store-links.js.map +1 -1
- package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
- package/dist/vite-plugins/undeclared-library.js +18 -15
- package/dist/vite-plugins/undeclared-library.js.map +1 -1
- package/dist/vite-plugins/worker.d.ts.map +1 -1
- package/dist/vite-plugins/worker.js +21 -13
- package/dist/vite-plugins/worker.js.map +1 -1
- package/dist/vitest-plugin.d.ts +4 -3
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js +12 -8
- package/dist/vitest-plugin.js.map +1 -1
- package/env.d.ts +9 -0
- package/package.json +18 -13
- package/src/builder.ts +45 -12
- package/src/cli.ts +15 -2
- package/src/codegen/config-dependencies.ts +470 -0
- package/src/codegen/freshness.ts +5 -1
- package/src/codegen/reference.ts +1 -0
- package/src/codegen/run-codegen.ts +51 -21
- package/src/codegen/store-resolver.ts +9 -4
- package/src/commands/build.ts +13 -2
- package/src/commands/cleanup.ts +48 -0
- package/src/commands/codegen.ts +6 -5
- package/src/commands/deploy.ts +10 -2
- package/src/commands/dev.ts +45 -4
- package/src/commands/docs.ts +1 -0
- package/src/deploy/depends.ts +30 -3
- package/src/deploy/download.ts +33 -24
- package/src/deploy/freedesktop/metainfo.ts +73 -21
- package/src/deploy/freedesktop/validate.ts +80 -15
- package/src/deploy/native-addon.ts +183 -0
- package/src/deploy/nfpm/config.ts +13 -4
- package/src/deploy/nfpm/contents.ts +8 -0
- package/src/deploy/node-runtime/download.ts +2 -2
- package/src/deploy/node-runtime/elf.ts +46 -5
- package/src/deploy/node-runtime/guard.ts +10 -14
- package/src/deploy/node-runtime/index.ts +148 -12
- package/src/deploy/node-runtime/sonames.ts +17 -0
- package/src/deploy/notices/node-runtime.ts +2 -2
- package/src/deploy/payload/launcher.ts +20 -1
- package/src/deploy/payload/stage.ts +76 -5
- package/src/deploy/run-deploy.ts +227 -72
- package/src/deploy/settings/arch.ts +40 -8
- package/src/deploy/settings/build-manifest.ts +28 -3
- package/src/deploy/settings/extra-files.ts +30 -4
- package/src/deploy/settings/index.ts +7 -2
- package/src/deploy/settings/libraries.ts +2 -1
- package/src/deploy/settings/paths.ts +80 -13
- package/src/deploy/targets/appimage.ts +1 -0
- package/src/deploy/targets/flatpak-pnpm.ts +4 -4
- package/src/deploy/targets/flatpak-source.ts +15 -2
- package/src/deploy/targets/flatpak.ts +1 -0
- package/src/deploy/targets/nfpm-target.ts +14 -6
- package/src/deploy/types.ts +5 -1
- package/src/deploy/vendored/appimagetool.ts +2 -2
- package/src/deploy/vendored/nfpm.ts +1 -1
- package/src/dev/catalog-writes.ts +35 -0
- package/src/dev/entry-env.ts +2 -1
- package/src/dev/font-dir.ts +11 -0
- package/src/dev/headless.ts +40 -0
- package/src/dev/runner-deps.ts +20 -7
- package/src/dev/runner-main.ts +12 -3
- package/src/dev/runner.ts +37 -7
- package/src/dev/supervisor.ts +183 -32
- package/src/dev/vite-dev-server.ts +20 -2
- package/src/dev/watch-ignore.ts +16 -0
- package/src/i18n/catalogs.ts +21 -8
- package/src/i18n/source-messages.ts +1446 -29
- package/src/internal/agent-rules.ts +7 -2
- package/src/internal/banner.ts +27 -6
- package/src/internal/build-manifest.ts +25 -1
- package/src/internal/build-output.ts +171 -0
- package/src/internal/cache-root.ts +12 -0
- package/src/internal/compile-cache-store.ts +50 -0
- package/src/internal/compile-cache.ts +20 -0
- package/src/internal/deploy-out-dir.ts +8 -0
- package/src/internal/docs-elements.ts +10 -4
- package/src/internal/entry-arg.ts +8 -1
- package/src/internal/errors.ts +1 -1
- package/src/internal/font-path.ts +15 -0
- package/src/internal/font-staging.ts +131 -0
- package/src/internal/icon-staging.ts +58 -0
- package/src/internal/import-scan.ts +206 -0
- package/src/internal/module-hash.ts +22 -0
- package/src/internal/output-directory.ts +699 -0
- package/src/internal/parent-process.ts +110 -0
- package/src/internal/prepare-project.ts +11 -5
- package/src/internal/react-compiler-cache.ts +246 -0
- package/src/internal/source-imports.ts +57 -12
- package/src/internal/staging-file.ts +42 -0
- package/src/internal/xdg-banner.ts +13 -0
- package/src/internal/xdg-data-dirs.ts +1 -1
- package/src/mcp/client.ts +2 -2
- package/src/settings/schema.ts +4 -10
- package/src/vite-plugins/asset-extensions.ts +2 -0
- package/src/vite-plugins/asset-imports.ts +23 -5
- package/src/vite-plugins/asset-specifier.ts +17 -0
- package/src/vite-plugins/build-manifest.ts +7 -1
- package/src/vite-plugins/built-url.ts +6 -2
- package/src/vite-plugins/css.ts +16 -5
- package/src/vite-plugins/ensure-store.ts +2 -2
- package/src/vite-plugins/fast-refresh/refresh-filter.ts +10 -1
- package/src/vite-plugins/fast-refresh/swc-refresh.ts +33 -14
- package/src/vite-plugins/font-name.ts +582 -0
- package/src/vite-plugins/font-worker-env.ts +25 -0
- package/src/vite-plugins/font.ts +180 -0
- package/src/vite-plugins/i18n.ts +122 -11
- package/src/vite-plugins/icon-worker-env.ts +36 -0
- package/src/vite-plugins/icons.ts +4 -10
- package/src/vite-plugins/index.ts +34 -9
- package/src/vite-plugins/native.ts +0 -5
- package/src/vite-plugins/react-compiler.ts +83 -19
- package/src/vite-plugins/resource-shared.ts +4 -0
- package/src/vite-plugins/resources.ts +11 -5
- package/src/vite-plugins/self-contained.ts +184 -185
- package/src/vite-plugins/settings-worker-env.ts +4 -4
- package/src/vite-plugins/settings.ts +36 -16
- package/src/vite-plugins/store-links.ts +10 -5
- package/src/vite-plugins/undeclared-library.ts +19 -15
- package/src/vite-plugins/worker.ts +31 -15
- package/src/vitest-plugin.ts +12 -8
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { Plugin, Rollup } from "vite";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { parseSync } from "vite";
|
|
4
|
+
import type { AssetEmitter } from "./asset-emitter.js";
|
|
5
|
+
import { prependBanner } from "../internal/banner.js";
|
|
6
|
+
import { fontFileName, FONTS_DIR } from "../internal/font-path.js";
|
|
7
|
+
import { stagedFontStatus } from "../internal/font-staging.js";
|
|
8
|
+
import { SOURCE_ID_RE, sourceLanguage } from "../internal/source-imports.js";
|
|
9
|
+
import { xdgDataDirsBanner } from "../internal/xdg-banner.js";
|
|
10
|
+
import { parseFontSpecifier } from "./asset-specifier.js";
|
|
11
|
+
import { fontFamilyNames } from "./font-name.js";
|
|
12
|
+
import { stripQuery } from "./strip-query.js";
|
|
13
|
+
import { createVirtualNamespace } from "./virtual-module.js";
|
|
14
|
+
|
|
15
|
+
type PluginState = {
|
|
16
|
+
isBuild: boolean;
|
|
17
|
+
root: string;
|
|
18
|
+
emitted: Set<string>;
|
|
19
|
+
importers: Map<string, string>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type ResolveContext = Parameters<typeof resolveToVirtual>[0];
|
|
23
|
+
type ResolveRequest = Parameters<typeof resolveToVirtual>[1];
|
|
24
|
+
|
|
25
|
+
type RetainedFontModuleId = {
|
|
26
|
+
id: string;
|
|
27
|
+
moduleSideEffects: true;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type LoadContext = AssetEmitter & {
|
|
31
|
+
addWatchFile: (file: string) => void;
|
|
32
|
+
error: (message: string) => never;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const FONT_QUERY = "?font";
|
|
36
|
+
const FONT_ID_RE = /\?font$/;
|
|
37
|
+
const VIRTUAL_PREFIX = "\0gtkx-font:";
|
|
38
|
+
const VIRTUAL_ID_RE = new RegExp(`^${VIRTUAL_PREFIX}`);
|
|
39
|
+
const { isVirtual, fromVirtualId, resolveToVirtual } = createVirtualNamespace(VIRTUAL_PREFIX);
|
|
40
|
+
|
|
41
|
+
const unreadableFontError = (filePath: string): string =>
|
|
42
|
+
`Cannot read a font family name from ${filePath}; ?font expects a TrueType, OpenType, ` +
|
|
43
|
+
"TrueType Collection, WOFF, or WOFF2 font";
|
|
44
|
+
|
|
45
|
+
const unstagedFontError = (filePath: string, importer: string): string =>
|
|
46
|
+
`${filePath} was not staged before the toolkit started, so ${importer} would resolve its family to a ` +
|
|
47
|
+
"fallback font. Fonts are staged from ?font imports found in source files under the project root; move " +
|
|
48
|
+
"the import there, or restart to pick it up.";
|
|
49
|
+
|
|
50
|
+
const resolveFontId = async (
|
|
51
|
+
ctx: ResolveContext,
|
|
52
|
+
state: PluginState,
|
|
53
|
+
request: ResolveRequest,
|
|
54
|
+
): Promise<RetainedFontModuleId | undefined> => {
|
|
55
|
+
if (parseFontSpecifier(request.source) === null) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const virtualId = await resolveToVirtual(ctx, request);
|
|
60
|
+
|
|
61
|
+
if (virtualId === undefined) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
state.importers.set(virtualId, request.importer ?? state.root);
|
|
66
|
+
|
|
67
|
+
return { id: virtualId, moduleSideEffects: true };
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const emitFont = (ctx: LoadContext, state: PluginState, filePath: string, content: Buffer): void => {
|
|
71
|
+
const fileName = `${FONTS_DIR}/${fontFileName(filePath, content)}`;
|
|
72
|
+
|
|
73
|
+
if (state.emitted.has(fileName)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
state.emitted.add(fileName);
|
|
78
|
+
ctx.emitFile({ type: "asset", fileName, source: content });
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const loadFontModule = (ctx: LoadContext, state: PluginState, id: string): string | undefined => {
|
|
82
|
+
if (!isVirtual(id)) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const filePath = stripQuery(fromVirtualId(id));
|
|
87
|
+
const content = readFileSync(filePath);
|
|
88
|
+
const [family] = fontFamilyNames(content);
|
|
89
|
+
|
|
90
|
+
if (family === undefined) {
|
|
91
|
+
return ctx.error(unreadableFontError(filePath));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
ctx.addWatchFile(filePath);
|
|
95
|
+
|
|
96
|
+
if (state.isBuild) {
|
|
97
|
+
emitFont(ctx, state, filePath, content);
|
|
98
|
+
} else if (stagedFontStatus(filePath, content) === "absent") {
|
|
99
|
+
return ctx.error(unstagedFontError(filePath, state.importers.get(id) ?? state.root));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return `export default ${JSON.stringify(family)};`;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const hasSideEffectFontImport = (code: string, id: string): boolean => {
|
|
106
|
+
const lang = sourceLanguage(stripQuery(id));
|
|
107
|
+
|
|
108
|
+
if (lang === undefined || !code.includes(FONT_QUERY)) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const parsed = parseSync(id, code, { lang });
|
|
113
|
+
|
|
114
|
+
if (parsed.errors.length > 0) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return parsed.module.staticImports.some(
|
|
119
|
+
(statement) => statement.entries.length === 0 && parseFontSpecifier(statement.moduleRequest.value) !== null,
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const retainSideEffectFontImport = (
|
|
124
|
+
code: string,
|
|
125
|
+
id: string,
|
|
126
|
+
): { code: string; moduleSideEffects: true } | null =>
|
|
127
|
+
hasSideEffectFontImport(code, id)
|
|
128
|
+
? { code, moduleSideEffects: true }
|
|
129
|
+
: null;
|
|
130
|
+
|
|
131
|
+
const fontBanner = (state: PluginState) => (chunk: Rollup.RenderedChunk): string =>
|
|
132
|
+
state.emitted.size === 0 ? "" : xdgDataDirsBanner(chunk);
|
|
133
|
+
|
|
134
|
+
function gtkxFont(): Plugin {
|
|
135
|
+
const state: PluginState = { isBuild: false, root: "", emitted: new Set(), importers: new Map() };
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
name: "gtkx:font",
|
|
139
|
+
enforce: "pre",
|
|
140
|
+
|
|
141
|
+
configResolved(config) {
|
|
142
|
+
state.isBuild = config.command === "build";
|
|
143
|
+
state.root = config.root;
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
resolveId: {
|
|
147
|
+
filter: { id: FONT_ID_RE },
|
|
148
|
+
|
|
149
|
+
handler(source, importer, options) {
|
|
150
|
+
return resolveFontId(this, state, { source, importer, options });
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
load: {
|
|
155
|
+
filter: { id: VIRTUAL_ID_RE },
|
|
156
|
+
|
|
157
|
+
handler(id) {
|
|
158
|
+
return loadFontModule(this, state, id);
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
transform: {
|
|
163
|
+
filter: { id: SOURCE_ID_RE, code: FONT_QUERY },
|
|
164
|
+
|
|
165
|
+
handler(code, id) {
|
|
166
|
+
return retainSideEffectFontImport(code, id);
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
outputOptions(options) {
|
|
171
|
+
if (!state.isBuild) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return prependBanner(options, fontBanner(state));
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { gtkxFont };
|
package/src/vite-plugins/i18n.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConfigLoader } from "@gtkx/config";
|
|
2
2
|
import type { Plugin, ResolvedConfig } from "vite";
|
|
3
3
|
import { createConfigLoader } from "@gtkx/config/internal";
|
|
4
|
-
import { toPosixPath } from "@gtkx/utils";
|
|
4
|
+
import { isPathWithin, logger, toPosixPath } from "@gtkx/utils";
|
|
5
5
|
import { existsSync, mkdirSync } from "node:fs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { dirname, join, posix, relative, resolve } from "node:path";
|
|
@@ -11,16 +11,31 @@ import {
|
|
|
11
11
|
LOCALE_DIRNAME,
|
|
12
12
|
resolveCatalogProject,
|
|
13
13
|
synchronizeCatalogs,
|
|
14
|
+
type WrittenCatalog,
|
|
14
15
|
} from "../i18n/catalogs.js";
|
|
15
|
-
import { extractSourceCatalog } from "../i18n/source-messages.js";
|
|
16
|
-
import {
|
|
16
|
+
import { extractSourceCatalog, SourceExtractionError } from "../i18n/source-messages.js";
|
|
17
|
+
import { emitI18nTypes } from "../i18n/types.js";
|
|
18
|
+
import { discoverSourceFiles, sourceLanguage } from "../internal/source-imports.js";
|
|
17
19
|
import { stripQuery } from "./strip-query.js";
|
|
18
20
|
|
|
21
|
+
type CatalogWriteListener = (catalogs: WrittenCatalog[]) => void;
|
|
22
|
+
|
|
23
|
+
type I18nPluginOptions = {
|
|
24
|
+
entryPath: string;
|
|
25
|
+
loadConfig?: ConfigLoader | undefined;
|
|
26
|
+
onCatalogsWritten?: CatalogWriteListener | undefined;
|
|
27
|
+
shouldPreserveMetadataMessages?: boolean | undefined;
|
|
28
|
+
shouldRecoverExtractionErrors?: boolean | undefined;
|
|
29
|
+
};
|
|
30
|
+
|
|
19
31
|
type I18nState = {
|
|
20
32
|
entryPath: string;
|
|
21
33
|
i18nRoot: string;
|
|
22
34
|
outDir: string;
|
|
23
35
|
project: CatalogProject | null;
|
|
36
|
+
extraction: Promise<void>;
|
|
37
|
+
hotUpdateTimestamp: number | null;
|
|
38
|
+
onCatalogsWritten: CatalogWriteListener;
|
|
24
39
|
};
|
|
25
40
|
|
|
26
41
|
const BOOTSTRAP_SPECIFIER = "@gtkx/i18n/bootstrap";
|
|
@@ -94,6 +109,7 @@ const buildCatalogs = (state: I18nState): void => {
|
|
|
94
109
|
const extractProjectMessages = async (
|
|
95
110
|
state: I18nState,
|
|
96
111
|
shouldPreserveMetadataMessages: boolean,
|
|
112
|
+
shouldSynchronizeCatalogs: boolean,
|
|
97
113
|
): Promise<void> => {
|
|
98
114
|
const project = state.project;
|
|
99
115
|
|
|
@@ -104,15 +120,98 @@ const extractProjectMessages = async (
|
|
|
104
120
|
const srcDir = join(project.root, "src");
|
|
105
121
|
const sourceFiles = discoverSourceFiles(existsSync(srcDir) ? srcDir : project.root);
|
|
106
122
|
await extractSourceCatalog(project, sourceFiles, shouldPreserveMetadataMessages);
|
|
107
|
-
|
|
123
|
+
|
|
124
|
+
if (shouldSynchronizeCatalogs) {
|
|
125
|
+
state.onCatalogsWritten(synchronizeCatalogs(project));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
await emitI18nTypes(project.root);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const settleExtraction = async (pending: Promise<void>): Promise<void> => {
|
|
132
|
+
try {
|
|
133
|
+
await pending;
|
|
134
|
+
} catch {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const queueExtraction = (
|
|
140
|
+
state: I18nState,
|
|
141
|
+
shouldPreserveMetadataMessages: boolean,
|
|
142
|
+
shouldSynchronizeCatalogs: boolean,
|
|
143
|
+
): Promise<void> => {
|
|
144
|
+
const prior = state.extraction;
|
|
145
|
+
const pending = (async (): Promise<void> => {
|
|
146
|
+
await settleExtraction(prior);
|
|
147
|
+
await extractProjectMessages(
|
|
148
|
+
state,
|
|
149
|
+
shouldPreserveMetadataMessages,
|
|
150
|
+
shouldSynchronizeCatalogs,
|
|
151
|
+
);
|
|
152
|
+
})();
|
|
153
|
+
|
|
154
|
+
state.extraction = pending;
|
|
155
|
+
|
|
156
|
+
return pending;
|
|
108
157
|
};
|
|
109
158
|
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
159
|
+
const isProjectSource = (state: I18nState, path: string): boolean => {
|
|
160
|
+
const project = state.project;
|
|
161
|
+
|
|
162
|
+
if (project === null || sourceLanguage(path) === undefined) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const srcDir = join(project.root, "src");
|
|
167
|
+
const sourceRoot = existsSync(srcDir) ? srcDir : project.root;
|
|
168
|
+
|
|
169
|
+
return isPathWithin(sourceRoot, path);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const refreshProjectMessages = async (
|
|
173
|
+
state: I18nState,
|
|
174
|
+
shouldPreserveMetadataMessages: boolean,
|
|
175
|
+
shouldSynchronizeCatalogs = false,
|
|
176
|
+
): Promise<void> => {
|
|
177
|
+
try {
|
|
178
|
+
await queueExtraction(state, shouldPreserveMetadataMessages, shouldSynchronizeCatalogs);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
logger.error(error instanceof Error ? error.message : String(error));
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const recoverInitialSourceExtraction = async (
|
|
185
|
+
state: I18nState,
|
|
186
|
+
shouldPreserveMetadataMessages: boolean,
|
|
187
|
+
): Promise<void> => {
|
|
188
|
+
try {
|
|
189
|
+
await queueExtraction(state, shouldPreserveMetadataMessages, true);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
if (!(error instanceof SourceExtractionError)) {
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
logger.error(error.message);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const gtkxI18n = ({
|
|
200
|
+
entryPath,
|
|
201
|
+
loadConfig = createConfigLoader(),
|
|
202
|
+
onCatalogsWritten = (): void => undefined,
|
|
113
203
|
shouldPreserveMetadataMessages = true,
|
|
114
|
-
|
|
115
|
-
|
|
204
|
+
shouldRecoverExtractionErrors = false,
|
|
205
|
+
}: I18nPluginOptions): Plugin => {
|
|
206
|
+
const state: I18nState = {
|
|
207
|
+
entryPath,
|
|
208
|
+
extraction: Promise.resolve(),
|
|
209
|
+
hotUpdateTimestamp: null,
|
|
210
|
+
i18nRoot: "",
|
|
211
|
+
outDir: "",
|
|
212
|
+
project: null,
|
|
213
|
+
onCatalogsWritten,
|
|
214
|
+
};
|
|
116
215
|
|
|
117
216
|
return {
|
|
118
217
|
name: "gtkx:i18n",
|
|
@@ -120,7 +219,19 @@ const gtkxI18n = (
|
|
|
120
219
|
|
|
121
220
|
configResolved: (config) => applyResolvedConfig(state, config, loadConfig),
|
|
122
221
|
|
|
123
|
-
buildStart: () =>
|
|
222
|
+
buildStart: () => shouldRecoverExtractionErrors
|
|
223
|
+
? recoverInitialSourceExtraction(state, shouldPreserveMetadataMessages)
|
|
224
|
+
: queueExtraction(state, shouldPreserveMetadataMessages, true),
|
|
225
|
+
|
|
226
|
+
hotUpdate(options) {
|
|
227
|
+
if (!isProjectSource(state, options.file) || state.hotUpdateTimestamp === options.timestamp) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
state.hotUpdateTimestamp = options.timestamp;
|
|
232
|
+
|
|
233
|
+
return refreshProjectMessages(state, shouldPreserveMetadataMessages);
|
|
234
|
+
},
|
|
124
235
|
|
|
125
236
|
transform(code, id) {
|
|
126
237
|
if (isI18nLocaleModule(state, id)) {
|
|
@@ -144,4 +255,4 @@ const gtkxI18n = (
|
|
|
144
255
|
};
|
|
145
256
|
};
|
|
146
257
|
|
|
147
|
-
export { gtkxI18n };
|
|
258
|
+
export { type CatalogWriteListener, gtkxI18n };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { UserConfig } from "vite";
|
|
2
|
+
import type { Plugin } from "vitest/config";
|
|
3
|
+
import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
|
|
4
|
+
import { stageProjectIcons } from "../internal/icon-staging.js";
|
|
5
|
+
import { prependXdgDataDir } from "../internal/xdg-data-dirs.js";
|
|
6
|
+
|
|
7
|
+
function gtkxIconWorkerEnv(configFile?: string): Plugin {
|
|
8
|
+
const loadConfig = createConfigLoader({ configFile });
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
name: "gtkx:icon-worker-env",
|
|
12
|
+
enforce: "pre",
|
|
13
|
+
|
|
14
|
+
async config(config: UserConfig) {
|
|
15
|
+
const loaded = await loadConfig.load(viteProjectRoot(config));
|
|
16
|
+
|
|
17
|
+
const shareDir = stageProjectIcons(
|
|
18
|
+
loaded.root,
|
|
19
|
+
loaded.config.applicationId,
|
|
20
|
+
loaded.config.applicationIcon,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if (shareDir === null) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const existing = config.test?.env?.XDG_DATA_DIRS ?? process.env.XDG_DATA_DIRS;
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
test: { env: { XDG_DATA_DIRS: prependXdgDataDir(shareDir, existing) } },
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { gtkxIconWorkerEnv };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConfigLoader } from "@gtkx/config";
|
|
2
2
|
import type { Plugin, UserConfig } from "vite";
|
|
3
|
-
import { createConfigLoader } from "@gtkx/config/internal";
|
|
3
|
+
import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
|
|
4
4
|
import { info } from "@gtkx/utils";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { join } from "node:path";
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type ResolvedApplicationIcon,
|
|
13
13
|
} from "../internal/icon-path.js";
|
|
14
14
|
import { type ListedFile, listFilesRecursive } from "../internal/list-files.js";
|
|
15
|
+
import { xdgDataDirsBanner } from "../internal/xdg-banner.js";
|
|
15
16
|
|
|
16
17
|
type PluginState = {
|
|
17
18
|
applicationId: string;
|
|
@@ -20,13 +21,6 @@ type PluginState = {
|
|
|
20
21
|
|
|
21
22
|
const ICONS_DIR = "icons";
|
|
22
23
|
|
|
23
|
-
const XDG_ENV_BANNER = [
|
|
24
|
-
"process.env.XDG_DATA_DIRS = [",
|
|
25
|
-
" decodeURIComponent(new URL(\".\", import.meta.url).pathname),",
|
|
26
|
-
" process.env.XDG_DATA_DIRS || \"/usr/local/share:/usr/share\",",
|
|
27
|
-
"].join(\":\");",
|
|
28
|
-
].join("\n");
|
|
29
|
-
|
|
30
24
|
const findIconFiles = (state: PluginState): ListedFile[] => {
|
|
31
25
|
if (state.source.kind === "theme") {
|
|
32
26
|
return listFilesRecursive(state.source.path);
|
|
@@ -43,7 +37,7 @@ const findIconFiles = (state: PluginState): ListedFile[] => {
|
|
|
43
37
|
};
|
|
44
38
|
|
|
45
39
|
const applyUserConfig = async (state: PluginState, config: UserConfig, loadConfig: ConfigLoader): Promise<void> => {
|
|
46
|
-
const { config: gtkxConfig, root } = await loadConfig.load(config
|
|
40
|
+
const { config: gtkxConfig, root } = await loadConfig.load(viteProjectRoot(config));
|
|
47
41
|
state.applicationId = gtkxConfig.applicationId;
|
|
48
42
|
state.source = resolveApplicationIcon(root, gtkxConfig.applicationId, gtkxConfig.applicationIcon);
|
|
49
43
|
};
|
|
@@ -78,7 +72,7 @@ function gtkxIcons(loadConfig: ConfigLoader = createConfigLoader()): Plugin {
|
|
|
78
72
|
return;
|
|
79
73
|
}
|
|
80
74
|
|
|
81
|
-
return prependBanner(options,
|
|
75
|
+
return prependBanner(options, xdgDataDirsBanner);
|
|
82
76
|
},
|
|
83
77
|
|
|
84
78
|
buildEnd() {
|
|
@@ -5,7 +5,8 @@ import type { BuildManifestCollector } from "../internal/build-manifest.js";
|
|
|
5
5
|
import { gtkxAssetImports } from "./asset-imports.js";
|
|
6
6
|
import { gtkxBuiltUrl } from "./built-url.js";
|
|
7
7
|
import { gtkxCss } from "./css.js";
|
|
8
|
-
import {
|
|
8
|
+
import { gtkxFont } from "./font.js";
|
|
9
|
+
import { type CatalogWriteListener, gtkxI18n } from "./i18n.js";
|
|
9
10
|
import { gtkxIcons } from "./icons.js";
|
|
10
11
|
import { gtkxReactCompiler } from "./react-compiler.js";
|
|
11
12
|
import { gtkxResources } from "./resources.js";
|
|
@@ -13,23 +14,47 @@ import { gtkxSettings } from "./settings.js";
|
|
|
13
14
|
import { gtkxStoreLinks } from "./store-links.js";
|
|
14
15
|
import { gtkxUndeclaredLibrary } from "./undeclared-library.js";
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
type GtkxVitePluginOptions = {
|
|
18
|
+
buildManifest?: BuildManifestCollector | undefined;
|
|
19
|
+
configFile?: string | undefined;
|
|
20
|
+
entryPath?: string | undefined;
|
|
21
|
+
mode?: string | undefined;
|
|
22
|
+
onCatalogsWritten?: CatalogWriteListener | undefined;
|
|
23
|
+
shouldPreserveI18nMetadata?: boolean | undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const gtkxVitePlugins = (options: GtkxVitePluginOptions = {}): Plugin[] => {
|
|
27
|
+
const {
|
|
28
|
+
buildManifest,
|
|
29
|
+
configFile,
|
|
30
|
+
entryPath,
|
|
31
|
+
mode,
|
|
32
|
+
onCatalogsWritten,
|
|
33
|
+
shouldPreserveI18nMetadata = true,
|
|
34
|
+
} = options;
|
|
35
|
+
const loadConfig = createConfigLoader({
|
|
36
|
+
...(mode !== undefined && { mode }),
|
|
37
|
+
...(configFile !== undefined && { configFile }),
|
|
38
|
+
});
|
|
23
39
|
|
|
24
40
|
return [
|
|
25
41
|
createConfigPlugin({ name: "gtkx:config", loadConfig }),
|
|
26
|
-
...(entryPath === undefined
|
|
42
|
+
...(entryPath === undefined
|
|
43
|
+
? []
|
|
44
|
+
: [gtkxI18n({
|
|
45
|
+
entryPath,
|
|
46
|
+
loadConfig,
|
|
47
|
+
onCatalogsWritten,
|
|
48
|
+
shouldPreserveMetadataMessages: shouldPreserveI18nMetadata,
|
|
49
|
+
shouldRecoverExtractionErrors: mode === "development",
|
|
50
|
+
})]),
|
|
27
51
|
gtkxStoreLinks(),
|
|
28
52
|
gtkxUndeclaredLibrary(loadConfig),
|
|
29
53
|
gtkxSettings(buildManifest),
|
|
30
54
|
gtkxIcons(loadConfig),
|
|
31
55
|
gtkxAssetImports(),
|
|
32
56
|
gtkxBuiltUrl(),
|
|
57
|
+
gtkxFont(),
|
|
33
58
|
gtkxResources(loadConfig, entryPath),
|
|
34
59
|
gtkxCss(),
|
|
35
60
|
gtkxReactCompiler(loadConfig),
|
|
@@ -5,7 +5,6 @@ import { arch, platform } from "node:os";
|
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
import { stripQuery } from "./strip-query.js";
|
|
7
7
|
|
|
8
|
-
const EMITTED_BINDING_SPECIFIER = "./gtkx.node";
|
|
9
8
|
const BINDING_FILENAME = "gtkx.node";
|
|
10
9
|
|
|
11
10
|
function resolveBinaryPath(projectRequire: ReturnType<typeof createRequire>, currentArch: string): string {
|
|
@@ -97,10 +96,6 @@ function gtkxNative(root: string): Plugin {
|
|
|
97
96
|
});
|
|
98
97
|
},
|
|
99
98
|
|
|
100
|
-
resolveId(id) {
|
|
101
|
-
return id === EMITTED_BINDING_SPECIFIER ? { id, external: true } : null;
|
|
102
|
-
},
|
|
103
|
-
|
|
104
99
|
transform(code, id) {
|
|
105
100
|
return transformLoader(code, id, loaderPath(), bindingReferenceId);
|
|
106
101
|
},
|
|
@@ -1,21 +1,45 @@
|
|
|
1
1
|
import type { ConfigLoader } from "@gtkx/config";
|
|
2
2
|
import type { ResolvedReactCompilerOptions } from "@gtkx/config/internal";
|
|
3
3
|
import type { Plugin, ResolvedConfig, UserConfig } from "vite";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
|
|
5
|
+
import {
|
|
6
|
+
type CompilerOutput,
|
|
7
|
+
createReactCompilerCache,
|
|
8
|
+
type ReactCompilerCache,
|
|
9
|
+
} from "../internal/react-compiler-cache.js";
|
|
8
10
|
|
|
9
11
|
type ReactCompilerState = {
|
|
10
|
-
|
|
12
|
+
cache: ReactCompilerCache | null;
|
|
11
13
|
options: ResolvedReactCompilerOptions | null;
|
|
14
|
+
root: string;
|
|
12
15
|
};
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
type BabelToolchain = Awaited<ReturnType<typeof loadBabelToolchain>>;
|
|
18
|
+
|
|
16
19
|
const SOURCE_EXTENSION = /\.[jt]sx?$/;
|
|
17
20
|
const TYPESCRIPT_EXTENSION = /\.tsx?$/;
|
|
18
21
|
const NODE_MODULES = /(?:^|\/)node_modules\//;
|
|
22
|
+
const MEMOIZABLE_SOURCE = /use[A-Z0-9]|use memo|use forget/;
|
|
23
|
+
const JSX_MARK = "<";
|
|
24
|
+
const PLAIN_TYPESCRIPT = ".ts";
|
|
25
|
+
const ALL_FUNCTIONS = "all";
|
|
26
|
+
const babel: { toolchain: Promise<BabelToolchain> | undefined } = { toolchain: undefined };
|
|
27
|
+
|
|
28
|
+
const loadBabelToolchain = async () => {
|
|
29
|
+
const [core, preset, plugin] = await Promise.all([
|
|
30
|
+
import("@babel/core"),
|
|
31
|
+
import("@babel/preset-typescript"),
|
|
32
|
+
import("babel-plugin-react-compiler"),
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
presetTypescript: preset.default.default ?? preset.default,
|
|
37
|
+
reactCompiler: plugin.default.default ?? plugin.default,
|
|
38
|
+
transformAsync: core.transformAsync,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const babelToolchain = (): Promise<BabelToolchain> => (babel.toolchain ??= loadBabelToolchain());
|
|
19
43
|
|
|
20
44
|
const isProjectSource = (root: string, id: string): boolean => {
|
|
21
45
|
if (!SOURCE_EXTENSION.test(id)) {
|
|
@@ -33,15 +57,25 @@ const isProjectSource = (root: string, id: string): boolean => {
|
|
|
33
57
|
return true;
|
|
34
58
|
};
|
|
35
59
|
|
|
60
|
+
const isMemoizable = (code: string, id: string, options: ResolvedReactCompilerOptions): boolean => {
|
|
61
|
+
if (options.compilationMode === ALL_FUNCTIONS || MEMOIZABLE_SOURCE.test(code)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return !id.endsWith(PLAIN_TYPESCRIPT) && code.includes(JSX_MARK);
|
|
66
|
+
};
|
|
67
|
+
|
|
36
68
|
const compileSource = async (code: string, id: string, options: ResolvedReactCompilerOptions) => {
|
|
37
|
-
const
|
|
69
|
+
const toolchain = await babelToolchain();
|
|
70
|
+
|
|
71
|
+
const result = await toolchain.transformAsync(code, {
|
|
38
72
|
filename: id,
|
|
39
73
|
babelrc: false,
|
|
40
74
|
configFile: false,
|
|
41
75
|
sourceMaps: true,
|
|
42
|
-
parserOpts: { plugins: id.endsWith(
|
|
43
|
-
presets: TYPESCRIPT_EXTENSION.test(id) ? [
|
|
44
|
-
plugins: [[
|
|
76
|
+
parserOpts: { plugins: id.endsWith(PLAIN_TYPESCRIPT) ? [] : ["jsx"] },
|
|
77
|
+
presets: TYPESCRIPT_EXTENSION.test(id) ? [toolchain.presetTypescript] : [],
|
|
78
|
+
plugins: [[toolchain.reactCompiler, options]],
|
|
45
79
|
});
|
|
46
80
|
|
|
47
81
|
if (!result?.code) {
|
|
@@ -51,10 +85,33 @@ const compileSource = async (code: string, id: string, options: ResolvedReactCom
|
|
|
51
85
|
return result.map == null ? { code: result.code } : { code: result.code, map: JSON.stringify(result.map) };
|
|
52
86
|
};
|
|
53
87
|
|
|
88
|
+
const cachedSource = async (
|
|
89
|
+
cache: ReactCompilerCache,
|
|
90
|
+
code: string,
|
|
91
|
+
id: string,
|
|
92
|
+
options: ResolvedReactCompilerOptions,
|
|
93
|
+
): Promise<CompilerOutput | undefined> => {
|
|
94
|
+
const key = cache.keyFor(code, id);
|
|
95
|
+
const cached = cache.read(key);
|
|
96
|
+
|
|
97
|
+
if (cached !== undefined) {
|
|
98
|
+
return cached;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const compiled = await compileSource(code, id, options);
|
|
102
|
+
|
|
103
|
+
if (compiled !== undefined) {
|
|
104
|
+
cache.write(key, compiled);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return compiled;
|
|
108
|
+
};
|
|
109
|
+
|
|
54
110
|
function gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader()): Plugin {
|
|
55
111
|
const state: ReactCompilerState = {
|
|
56
|
-
|
|
112
|
+
cache: null,
|
|
57
113
|
options: null,
|
|
114
|
+
root: "",
|
|
58
115
|
};
|
|
59
116
|
|
|
60
117
|
return {
|
|
@@ -62,22 +119,29 @@ function gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader()): Plu
|
|
|
62
119
|
enforce: "pre",
|
|
63
120
|
|
|
64
121
|
async config(config: UserConfig) {
|
|
65
|
-
const resolved = await loadConfig.resolve(config
|
|
122
|
+
const resolved = await loadConfig.resolve(viteProjectRoot(config));
|
|
66
123
|
state.options = resolved.reactCompiler;
|
|
67
124
|
},
|
|
68
125
|
|
|
69
126
|
configResolved(config: ResolvedConfig) {
|
|
70
127
|
state.root = config.root;
|
|
128
|
+
state.cache = state.options === null ? null : createReactCompilerCache(config.cacheDir, state.options);
|
|
71
129
|
},
|
|
72
130
|
|
|
73
|
-
|
|
74
|
-
|
|
131
|
+
transform: {
|
|
132
|
+
filter: { id: { include: SOURCE_EXTENSION, exclude: NODE_MODULES } },
|
|
133
|
+
|
|
134
|
+
async handler(code, id) {
|
|
135
|
+
const options = state.options;
|
|
136
|
+
|
|
137
|
+
if (options === null || !isProjectSource(state.root, id) || !isMemoizable(code, id, options)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
75
140
|
|
|
76
|
-
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
141
|
+
const cache = state.cache;
|
|
79
142
|
|
|
80
|
-
|
|
143
|
+
return cache === null ? compileSource(code, id, options) : cachedSource(cache, code, id, options);
|
|
144
|
+
},
|
|
81
145
|
},
|
|
82
146
|
};
|
|
83
147
|
}
|