@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
|
@@ -3,6 +3,7 @@ import createConfigPlugin from "@gtkx/config/vite-plugin";
|
|
|
3
3
|
import { gtkxAssetImports } from "./asset-imports.js";
|
|
4
4
|
import { gtkxBuiltUrl } from "./built-url.js";
|
|
5
5
|
import { gtkxCss } from "./css.js";
|
|
6
|
+
import { gtkxFont } from "./font.js";
|
|
6
7
|
import { gtkxI18n } from "./i18n.js";
|
|
7
8
|
import { gtkxIcons } from "./icons.js";
|
|
8
9
|
import { gtkxReactCompiler } from "./react-compiler.js";
|
|
@@ -10,17 +11,30 @@ import { gtkxResources } from "./resources.js";
|
|
|
10
11
|
import { gtkxSettings } from "./settings.js";
|
|
11
12
|
import { gtkxStoreLinks } from "./store-links.js";
|
|
12
13
|
import { gtkxUndeclaredLibrary } from "./undeclared-library.js";
|
|
13
|
-
const gtkxVitePlugins = (
|
|
14
|
-
const
|
|
14
|
+
const gtkxVitePlugins = (options = {}) => {
|
|
15
|
+
const { buildManifest, configFile, entryPath, mode, onCatalogsWritten, shouldPreserveI18nMetadata = true, } = options;
|
|
16
|
+
const loadConfig = createConfigLoader({
|
|
17
|
+
...(mode !== undefined && { mode }),
|
|
18
|
+
...(configFile !== undefined && { configFile }),
|
|
19
|
+
});
|
|
15
20
|
return [
|
|
16
21
|
createConfigPlugin({ name: "gtkx:config", loadConfig }),
|
|
17
|
-
...(entryPath === undefined
|
|
22
|
+
...(entryPath === undefined
|
|
23
|
+
? []
|
|
24
|
+
: [gtkxI18n({
|
|
25
|
+
entryPath,
|
|
26
|
+
loadConfig,
|
|
27
|
+
onCatalogsWritten,
|
|
28
|
+
shouldPreserveMetadataMessages: shouldPreserveI18nMetadata,
|
|
29
|
+
shouldRecoverExtractionErrors: mode === "development",
|
|
30
|
+
})]),
|
|
18
31
|
gtkxStoreLinks(),
|
|
19
32
|
gtkxUndeclaredLibrary(loadConfig),
|
|
20
33
|
gtkxSettings(buildManifest),
|
|
21
34
|
gtkxIcons(loadConfig),
|
|
22
35
|
gtkxAssetImports(),
|
|
23
36
|
gtkxBuiltUrl(),
|
|
37
|
+
gtkxFont(),
|
|
24
38
|
gtkxResources(loadConfig, entryPath),
|
|
25
39
|
gtkxCss(),
|
|
26
40
|
gtkxReactCompiler(loadConfig),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite-plugins/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite-plugins/index.ts"],"names":[],"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,iBAAiB;oBACjB,8BAA8B,EAAE,0BAA0B;oBAC1D,6BAA6B,EAAE,IAAI,KAAK,aAAa;iBACxD,CAAC,CAAC,CAAC;QACZ,cAAc,EAAE;QAChB,qBAAqB,CAAC,UAAU,CAAC;QACjC,YAAY,CAAC,aAAa,CAAC;QAC3B,SAAS,CAAC,UAAU,CAAC;QACrB,gBAAgB,EAAE;QAClB,YAAY,EAAE;QACd,QAAQ,EAAE;QACV,aAAa,CAAC,UAAU,EAAE,SAAS,CAAC;QACpC,OAAO,EAAE;QACT,iBAAiB,CAAC,UAAU,CAAC;KAChC,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\nimport { createConfigLoader } from \"@gtkx/config/internal\";\nimport createConfigPlugin from \"@gtkx/config/vite-plugin\";\nimport type { BuildManifestCollector } from \"../internal/build-manifest.js\";\nimport { gtkxAssetImports } from \"./asset-imports.js\";\nimport { gtkxBuiltUrl } from \"./built-url.js\";\nimport { gtkxCss } from \"./css.js\";\nimport { gtkxFont } from \"./font.js\";\nimport { type CatalogWriteListener, gtkxI18n } from \"./i18n.js\";\nimport { gtkxIcons } from \"./icons.js\";\nimport { gtkxReactCompiler } from \"./react-compiler.js\";\nimport { gtkxResources } from \"./resources.js\";\nimport { gtkxSettings } from \"./settings.js\";\nimport { gtkxStoreLinks } from \"./store-links.js\";\nimport { gtkxUndeclaredLibrary } from \"./undeclared-library.js\";\n\ntype GtkxVitePluginOptions = {\n buildManifest?: BuildManifestCollector | undefined;\n configFile?: string | undefined;\n entryPath?: string | undefined;\n mode?: string | undefined;\n onCatalogsWritten?: CatalogWriteListener | undefined;\n shouldPreserveI18nMetadata?: boolean | undefined;\n};\n\nconst gtkxVitePlugins = (options: GtkxVitePluginOptions = {}): Plugin[] => {\n const {\n buildManifest,\n configFile,\n entryPath,\n mode,\n onCatalogsWritten,\n shouldPreserveI18nMetadata = true,\n } = options;\n const loadConfig = createConfigLoader({\n ...(mode !== undefined && { mode }),\n ...(configFile !== undefined && { configFile }),\n });\n\n return [\n createConfigPlugin({ name: \"gtkx:config\", loadConfig }),\n ...(entryPath === undefined\n ? []\n : [gtkxI18n({\n entryPath,\n loadConfig,\n onCatalogsWritten,\n shouldPreserveMetadataMessages: shouldPreserveI18nMetadata,\n shouldRecoverExtractionErrors: mode === \"development\",\n })]),\n gtkxStoreLinks(),\n gtkxUndeclaredLibrary(loadConfig),\n gtkxSettings(buildManifest),\n gtkxIcons(loadConfig),\n gtkxAssetImports(),\n gtkxBuiltUrl(),\n gtkxFont(),\n gtkxResources(loadConfig, entryPath),\n gtkxCss(),\n gtkxReactCompiler(loadConfig),\n ];\n};\n\nexport { gtkxVitePlugins };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AA0EnC,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA4BxC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -3,7 +3,6 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { arch, platform } from "node:os";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { stripQuery } from "./strip-query.js";
|
|
6
|
-
const EMITTED_BINDING_SPECIFIER = "./gtkx.node";
|
|
7
6
|
const BINDING_FILENAME = "gtkx.node";
|
|
8
7
|
function resolveBinaryPath(projectRequire, currentArch) {
|
|
9
8
|
const nativeRoot = dirname(projectRequire.resolve("@gtkx/native/package.json"));
|
|
@@ -69,9 +68,6 @@ function gtkxNative(root) {
|
|
|
69
68
|
source: resolvePlatformBinary(projectRequire),
|
|
70
69
|
});
|
|
71
70
|
},
|
|
72
|
-
resolveId(id) {
|
|
73
|
-
return id === EMITTED_BINDING_SPECIFIER ? { id, external: true } : null;
|
|
74
|
-
},
|
|
75
71
|
transform(code, id) {
|
|
76
72
|
return transformLoader(code, id, loaderPath(), bindingReferenceId);
|
|
77
73
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/vite-plugins/native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/vite-plugins/native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAErC,SAAS,iBAAiB,CAAC,cAAgD,EAAE,WAAmB;IAC5F,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC,CAAC;IAChF,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,gBAAgB,WAAW,WAAW,C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";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { arch, platform } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { stripQuery } from \"./strip-query.js\";\n\nconst BINDING_FILENAME = \"gtkx.node\";\n\nfunction resolveBinaryPath(projectRequire: ReturnType<typeof createRequire>, currentArch: string): string {\n const nativeRoot = dirname(projectRequire.resolve(\"@gtkx/native/package.json\"));\n const localBinary = join(nativeRoot, `native.linux-${currentArch}-gnu.node`);\n\n return existsSync(localBinary) ? localBinary : projectRequire.resolve(`@gtkx/native-linux-${currentArch}-gnu`);\n}\n\nfunction resolvePlatformBinary(projectRequire: ReturnType<typeof createRequire>): Buffer {\n const currentPlatform = platform();\n\n if (currentPlatform !== \"linux\") {\n throw new Error(`Unsupported build platform: ${currentPlatform}, only Linux is supported`);\n }\n\n const currentArch = arch();\n\n if (currentArch !== \"x64\" && currentArch !== \"arm64\") {\n throw new Error(`Unsupported build architecture: ${currentArch}, only x64 and arm64 are supported`);\n }\n\n return readFileSync(resolveBinaryPath(projectRequire, currentArch));\n}\n\nfunction rewriteLoader(code: string, bindingReferenceId: string): string {\n const idents: string[] = [];\n\n for (const match of code.matchAll(/export\\s*\\{\\s*([A-Za-z0-9_$]+)\\s*\\}/g)) {\n const ident = match[1];\n\n if (ident) {\n idents.push(ident);\n }\n }\n\n const bindings = idents.join(\", \");\n\n return [\n \"import { createRequire as __gtkxCreateRequire } from \\\"node:module\\\";\",\n \"import { fileURLToPath as __gtkxFileURLToPath } from \\\"node:url\\\";\",\n `const __gtkxNativeLocation = import.meta.ROLLUP_FILE_URL_${bindingReferenceId};`,\n \"const __gtkxNativePath = __gtkxNativeLocation.startsWith(\\\"file:\\\") \" +\n \"? __gtkxFileURLToPath(__gtkxNativeLocation) : __gtkxNativeLocation;\",\n \"const __gtkxNative = __gtkxCreateRequire(import.meta.url)(__gtkxNativePath);\",\n `const { ${bindings} } = __gtkxNative;`,\n `export { ${bindings} };`,\n ].join(\"\\n\");\n}\n\nconst transformLoader = (\n code: string,\n id: string,\n loaderPath: string,\n bindingReferenceId: string | null,\n): string | null => {\n if (stripQuery(id) !== loaderPath) {\n return null;\n }\n\n if (bindingReferenceId === null) {\n throw new Error(\"Cannot render the native loader before its binary has been emitted\");\n }\n\n return rewriteLoader(code, bindingReferenceId);\n};\n\nfunction gtkxNative(root: string): Plugin {\n const projectRequire = createRequire(join(root, \"package.json\"));\n let cachedLoaderPath: string | undefined;\n let bindingReferenceId: string | null = null;\n\n const loaderPath = (): string => {\n cachedLoaderPath ??= join(dirname(projectRequire.resolve(\"@gtkx/native/package.json\")), \"index.js\");\n\n return cachedLoaderPath;\n };\n\n return {\n name: \"gtkx:native\",\n enforce: \"pre\",\n apply: \"build\",\n\n buildStart() {\n bindingReferenceId = this.emitFile({\n type: \"asset\",\n fileName: BINDING_FILENAME,\n source: resolvePlatformBinary(projectRequire),\n });\n },\n\n transform(code, id) {\n return transformLoader(code, id, loaderPath(), bindingReferenceId);\n },\n };\n}\n\nexport { gtkxNative };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-compiler.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/react-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAA8B,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"react-compiler.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/react-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAA8B,MAAM,MAAM,CAAC;AA2G/D,iBAAS,iBAAiB,CAAC,UAAU,GAAE,YAAmC,GAAG,MAAM,CAqClF;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { createConfigLoader } from "@gtkx/config/internal";
|
|
4
|
-
import babelPluginReactCompilerNs from "babel-plugin-react-compiler";
|
|
5
|
-
const babelPresetTypescript = babelPresetTypescriptNs.default ?? babelPresetTypescriptNs;
|
|
6
|
-
const babelPluginReactCompiler = babelPluginReactCompilerNs.default ?? babelPluginReactCompilerNs;
|
|
1
|
+
import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
|
|
2
|
+
import { createReactCompilerCache, } from "../internal/react-compiler-cache.js";
|
|
7
3
|
const SOURCE_EXTENSION = /\.[jt]sx?$/;
|
|
8
4
|
const TYPESCRIPT_EXTENSION = /\.tsx?$/;
|
|
9
5
|
const NODE_MODULES = /(?:^|\/)node_modules\//;
|
|
6
|
+
const MEMOIZABLE_SOURCE = /use[A-Z0-9]|use memo|use forget/;
|
|
7
|
+
const JSX_MARK = "<";
|
|
8
|
+
const PLAIN_TYPESCRIPT = ".ts";
|
|
9
|
+
const ALL_FUNCTIONS = "all";
|
|
10
|
+
const babel = { toolchain: undefined };
|
|
11
|
+
const loadBabelToolchain = async () => {
|
|
12
|
+
const [core, preset, plugin] = await Promise.all([
|
|
13
|
+
import("@babel/core"),
|
|
14
|
+
import("@babel/preset-typescript"),
|
|
15
|
+
import("babel-plugin-react-compiler"),
|
|
16
|
+
]);
|
|
17
|
+
return {
|
|
18
|
+
presetTypescript: preset.default.default ?? preset.default,
|
|
19
|
+
reactCompiler: plugin.default.default ?? plugin.default,
|
|
20
|
+
transformAsync: core.transformAsync,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const babelToolchain = () => (babel.toolchain ??= loadBabelToolchain());
|
|
10
24
|
const isProjectSource = (root, id) => {
|
|
11
25
|
if (!SOURCE_EXTENSION.test(id)) {
|
|
12
26
|
return false;
|
|
@@ -19,42 +33,67 @@ const isProjectSource = (root, id) => {
|
|
|
19
33
|
}
|
|
20
34
|
return true;
|
|
21
35
|
};
|
|
36
|
+
const isMemoizable = (code, id, options) => {
|
|
37
|
+
if (options.compilationMode === ALL_FUNCTIONS || MEMOIZABLE_SOURCE.test(code)) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return !id.endsWith(PLAIN_TYPESCRIPT) && code.includes(JSX_MARK);
|
|
41
|
+
};
|
|
22
42
|
const compileSource = async (code, id, options) => {
|
|
23
|
-
const
|
|
43
|
+
const toolchain = await babelToolchain();
|
|
44
|
+
const result = await toolchain.transformAsync(code, {
|
|
24
45
|
filename: id,
|
|
25
46
|
babelrc: false,
|
|
26
47
|
configFile: false,
|
|
27
48
|
sourceMaps: true,
|
|
28
|
-
parserOpts: { plugins: id.endsWith(
|
|
29
|
-
presets: TYPESCRIPT_EXTENSION.test(id) ? [
|
|
30
|
-
plugins: [[
|
|
49
|
+
parserOpts: { plugins: id.endsWith(PLAIN_TYPESCRIPT) ? [] : ["jsx"] },
|
|
50
|
+
presets: TYPESCRIPT_EXTENSION.test(id) ? [toolchain.presetTypescript] : [],
|
|
51
|
+
plugins: [[toolchain.reactCompiler, options]],
|
|
31
52
|
});
|
|
32
53
|
if (!result?.code) {
|
|
33
54
|
return;
|
|
34
55
|
}
|
|
35
56
|
return result.map == null ? { code: result.code } : { code: result.code, map: JSON.stringify(result.map) };
|
|
36
57
|
};
|
|
58
|
+
const cachedSource = async (cache, code, id, options) => {
|
|
59
|
+
const key = cache.keyFor(code, id);
|
|
60
|
+
const cached = cache.read(key);
|
|
61
|
+
if (cached !== undefined) {
|
|
62
|
+
return cached;
|
|
63
|
+
}
|
|
64
|
+
const compiled = await compileSource(code, id, options);
|
|
65
|
+
if (compiled !== undefined) {
|
|
66
|
+
cache.write(key, compiled);
|
|
67
|
+
}
|
|
68
|
+
return compiled;
|
|
69
|
+
};
|
|
37
70
|
function gtkxReactCompiler(loadConfig = createConfigLoader()) {
|
|
38
71
|
const state = {
|
|
39
|
-
|
|
72
|
+
cache: null,
|
|
40
73
|
options: null,
|
|
74
|
+
root: "",
|
|
41
75
|
};
|
|
42
76
|
return {
|
|
43
77
|
name: "gtkx:react-compiler",
|
|
44
78
|
enforce: "pre",
|
|
45
79
|
async config(config) {
|
|
46
|
-
const resolved = await loadConfig.resolve(config
|
|
80
|
+
const resolved = await loadConfig.resolve(viteProjectRoot(config));
|
|
47
81
|
state.options = resolved.reactCompiler;
|
|
48
82
|
},
|
|
49
83
|
configResolved(config) {
|
|
50
84
|
state.root = config.root;
|
|
85
|
+
state.cache = state.options === null ? null : createReactCompilerCache(config.cacheDir, state.options);
|
|
51
86
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
87
|
+
transform: {
|
|
88
|
+
filter: { id: { include: SOURCE_EXTENSION, exclude: NODE_MODULES } },
|
|
89
|
+
async handler(code, id) {
|
|
90
|
+
const options = state.options;
|
|
91
|
+
if (options === null || !isProjectSource(state.root, id) || !isMemoizable(code, id, options)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const cache = state.cache;
|
|
95
|
+
return cache === null ? compileSource(code, id, options) : cachedSource(cache, code, id, options);
|
|
96
|
+
},
|
|
58
97
|
},
|
|
59
98
|
};
|
|
60
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-compiler.js","sourceRoot":"","sources":["../../src/vite-plugins/react-compiler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"react-compiler.js","sourceRoot":"","sources":["../../src/vite-plugins/react-compiler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAEH,wBAAwB,GAE3B,MAAM,qCAAqC,CAAC;AAU7C,MAAM,gBAAgB,GAAG,YAAY,CAAC;AACtC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAC9C,MAAM,iBAAiB,GAAG,iC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,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3G,CAAC;QAED,SAAS,EAAE;YACP,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;YAEpE,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE;gBAClB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;gBAE9B,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,CAAC;oBAC3F,OAAO;gBACX,CAAC;gBAED,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;gBAE1B,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YACtG,CAAC;SACJ;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type { ConfigLoader } from \"@gtkx/config\";\nimport type { ResolvedReactCompilerOptions } from \"@gtkx/config/internal\";\nimport type { Plugin, ResolvedConfig, UserConfig } from \"vite\";\nimport { createConfigLoader, viteProjectRoot } from \"@gtkx/config/internal\";\nimport {\n type CompilerOutput,\n createReactCompilerCache,\n type ReactCompilerCache,\n} from \"../internal/react-compiler-cache.js\";\n\ntype ReactCompilerState = {\n cache: ReactCompilerCache | null;\n options: ResolvedReactCompilerOptions | null;\n root: string;\n};\n\ntype BabelToolchain = Awaited<ReturnType<typeof loadBabelToolchain>>;\n\nconst SOURCE_EXTENSION = /\\.[jt]sx?$/;\nconst TYPESCRIPT_EXTENSION = /\\.tsx?$/;\nconst NODE_MODULES = /(?:^|\\/)node_modules\\//;\nconst MEMOIZABLE_SOURCE = /use[A-Z0-9]|use memo|use forget/;\nconst JSX_MARK = \"<\";\nconst PLAIN_TYPESCRIPT = \".ts\";\nconst ALL_FUNCTIONS = \"all\";\nconst babel: { toolchain: Promise<BabelToolchain> | undefined } = { toolchain: undefined };\n\nconst loadBabelToolchain = async () => {\n const [core, preset, plugin] = await Promise.all([\n import(\"@babel/core\"),\n import(\"@babel/preset-typescript\"),\n import(\"babel-plugin-react-compiler\"),\n ]);\n\n return {\n presetTypescript: preset.default.default ?? preset.default,\n reactCompiler: plugin.default.default ?? plugin.default,\n transformAsync: core.transformAsync,\n };\n};\n\nconst babelToolchain = (): Promise<BabelToolchain> => (babel.toolchain ??= loadBabelToolchain());\n\nconst isProjectSource = (root: string, id: string): boolean => {\n if (!SOURCE_EXTENSION.test(id)) {\n return false;\n }\n\n if (NODE_MODULES.test(id)) {\n return false;\n }\n\n if (root !== \"\" && !id.startsWith(`${root}/`)) {\n return false;\n }\n\n return true;\n};\n\nconst isMemoizable = (code: string, id: string, options: ResolvedReactCompilerOptions): boolean => {\n if (options.compilationMode === ALL_FUNCTIONS || MEMOIZABLE_SOURCE.test(code)) {\n return true;\n }\n\n return !id.endsWith(PLAIN_TYPESCRIPT) && code.includes(JSX_MARK);\n};\n\nconst compileSource = async (code: string, id: string, options: ResolvedReactCompilerOptions) => {\n const toolchain = await babelToolchain();\n\n const result = await toolchain.transformAsync(code, {\n filename: id,\n babelrc: false,\n configFile: false,\n sourceMaps: true,\n parserOpts: { plugins: id.endsWith(PLAIN_TYPESCRIPT) ? [] : [\"jsx\"] },\n presets: TYPESCRIPT_EXTENSION.test(id) ? [toolchain.presetTypescript] : [],\n plugins: [[toolchain.reactCompiler, options]],\n });\n\n if (!result?.code) {\n return;\n }\n\n return result.map == null ? { code: result.code } : { code: result.code, map: JSON.stringify(result.map) };\n};\n\nconst cachedSource = async (\n cache: ReactCompilerCache,\n code: string,\n id: string,\n options: ResolvedReactCompilerOptions,\n): Promise<CompilerOutput | undefined> => {\n const key = cache.keyFor(code, id);\n const cached = cache.read(key);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const compiled = await compileSource(code, id, options);\n\n if (compiled !== undefined) {\n cache.write(key, compiled);\n }\n\n return compiled;\n};\n\nfunction gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader()): Plugin {\n const state: ReactCompilerState = {\n cache: null,\n options: null,\n root: \"\",\n };\n\n return {\n name: \"gtkx:react-compiler\",\n enforce: \"pre\",\n\n async config(config: UserConfig) {\n const resolved = await loadConfig.resolve(viteProjectRoot(config));\n state.options = resolved.reactCompiler;\n },\n\n configResolved(config: ResolvedConfig) {\n state.root = config.root;\n state.cache = state.options === null ? null : createReactCompilerCache(config.cacheDir, state.options);\n },\n\n transform: {\n filter: { id: { include: SOURCE_EXTENSION, exclude: NODE_MODULES } },\n\n async handler(code, id) {\n const options = state.options;\n\n if (options === null || !isProjectSource(state.root, id) || !isMemoizable(code, id, options)) {\n return;\n }\n\n const cache = state.cache;\n\n return cache === null ? compileSource(code, id, options) : cachedSource(cache, code, id, options);\n },\n },\n };\n}\n\nexport { gtkxReactCompiler };\n"]}
|
|
@@ -5,7 +5,9 @@ declare const ICON_NAME_SEPARATOR = "\0icon=";
|
|
|
5
5
|
declare const REFRESH_EXPORT = "__refresh";
|
|
6
6
|
declare const REGISTER_REFRESH_EXPORT = "__registerRefresh";
|
|
7
7
|
declare const RESOURCE_PATH_EXPORT = "path";
|
|
8
|
+
declare const VIRTUAL_ID_RE: RegExp;
|
|
9
|
+
declare const VIRTUAL_INIT_RE: RegExp;
|
|
8
10
|
declare const isVirtual: (id: string) => boolean, toVirtualId: (realId: string) => string, fromVirtualId: (id: string) => string;
|
|
9
11
|
declare const escapeXml: (value: string) => string;
|
|
10
|
-
export { VIRTUAL_INIT, BUNDLE_FILENAME, REL_SEPARATOR, ICON_NAME_SEPARATOR, REFRESH_EXPORT, REGISTER_REFRESH_EXPORT, RESOURCE_PATH_EXPORT, escapeXml, isVirtual, toVirtualId, fromVirtualId, };
|
|
12
|
+
export { VIRTUAL_ID_RE, VIRTUAL_INIT, VIRTUAL_INIT_RE, BUNDLE_FILENAME, REL_SEPARATOR, ICON_NAME_SEPARATOR, REFRESH_EXPORT, REGISTER_REFRESH_EXPORT, RESOURCE_PATH_EXPORT, escapeXml, isVirtual, toVirtualId, fromVirtualId, };
|
|
11
13
|
//# sourceMappingURL=resource-shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-shared.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/resource-shared.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,YAAY,0BAA0B,CAAC;AAC7C,QAAA,MAAM,eAAe,mBAAmB,CAAC;AACzC,QAAA,MAAM,aAAa,WAAW,CAAC;AAC/B,QAAA,MAAM,mBAAmB,YAAY,CAAC;AACtC,QAAA,MAAM,cAAc,cAAc,CAAC;AACnC,QAAA,MAAM,uBAAuB,sBAAsB,CAAC;AACpD,QAAA,MAAM,oBAAoB,SAAS,CAAC;AACpC,QAAA,MAAQ,SAAS,2BAAE,WAAW,8BAAE,aAAa,wBAA2C,CAAC;AAEzF,QAAA,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAmB7B,CAAC;AAEP,OAAO,EACH,YAAY,EACZ,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,WAAW,EACX,aAAa,GAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"resource-shared.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/resource-shared.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,YAAY,0BAA0B,CAAC;AAC7C,QAAA,MAAM,eAAe,mBAAmB,CAAC;AACzC,QAAA,MAAM,aAAa,WAAW,CAAC;AAC/B,QAAA,MAAM,mBAAmB,YAAY,CAAC;AACtC,QAAA,MAAM,cAAc,cAAc,CAAC;AACnC,QAAA,MAAM,uBAAuB,sBAAsB,CAAC;AACpD,QAAA,MAAM,oBAAoB,SAAS,CAAC;AACpC,QAAA,MAAM,aAAa,QAAmC,CAAC;AACvD,QAAA,MAAM,eAAe,QAAkC,CAAC;AACxD,QAAA,MAAQ,SAAS,2BAAE,WAAW,8BAAE,aAAa,wBAA2C,CAAC;AAEzF,QAAA,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAmB7B,CAAC;AAEP,OAAO,EACH,aAAa,EACb,YAAY,EACZ,eAAe,EACf,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,WAAW,EACX,aAAa,GAChB,CAAC"}
|
|
@@ -7,6 +7,8 @@ const ICON_NAME_SEPARATOR = "\0icon=";
|
|
|
7
7
|
const REFRESH_EXPORT = "__refresh";
|
|
8
8
|
const REGISTER_REFRESH_EXPORT = "__registerRefresh";
|
|
9
9
|
const RESOURCE_PATH_EXPORT = "path";
|
|
10
|
+
const VIRTUAL_ID_RE = new RegExp(`^${VIRTUAL_PREFIX}`);
|
|
11
|
+
const VIRTUAL_INIT_RE = new RegExp(`^${VIRTUAL_INIT}$`);
|
|
10
12
|
const { isVirtual, toVirtualId, fromVirtualId } = createVirtualNamespace(VIRTUAL_PREFIX);
|
|
11
13
|
const escapeXml = (value) => value.replaceAll(/[<>&"']/g, (char) => {
|
|
12
14
|
switch (char) {
|
|
@@ -27,5 +29,5 @@ const escapeXml = (value) => value.replaceAll(/[<>&"']/g, (char) => {
|
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
|
-
export { VIRTUAL_INIT, BUNDLE_FILENAME, REL_SEPARATOR, ICON_NAME_SEPARATOR, REFRESH_EXPORT, REGISTER_REFRESH_EXPORT, RESOURCE_PATH_EXPORT, escapeXml, isVirtual, toVirtualId, fromVirtualId, };
|
|
32
|
+
export { VIRTUAL_ID_RE, VIRTUAL_INIT, VIRTUAL_INIT_RE, BUNDLE_FILENAME, REL_SEPARATOR, ICON_NAME_SEPARATOR, REFRESH_EXPORT, REGISTER_REFRESH_EXPORT, RESOURCE_PATH_EXPORT, escapeXml, isVirtual, toVirtualId, fromVirtualId, };
|
|
31
33
|
//# sourceMappingURL=resource-shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-shared.js","sourceRoot":"","sources":["../../src/vite-plugins/resource-shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAC3C,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,aAAa,GAAG,QAAQ,CAAC;AAC/B,MAAM,mBAAmB,GAAG,SAAS,CAAC;AACtC,MAAM,cAAc,GAAG,WAAW,CAAC;AACnC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AACpD,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,sBAAsB,CAAC,cAAc,CAAC,CAAC;AAEzF,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE,CACxC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;IAClC,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,GAAG,CAAC,CAAC,CAAC;YACP,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,KAAK,GAAG,CAAC,CAAC,CAAC;YACP,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,KAAK,GAAG,CAAC,CAAC,CAAC;YACP,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,KAAK,IAAI,CAAC,CAAC,CAAC;YACR,OAAO,QAAQ,CAAC;QACpB,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACN,OAAO,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;AACL,CAAC,CAAC,CAAC;AAEP,OAAO,EACH,YAAY,EACZ,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,WAAW,EACX,aAAa,GAChB,CAAC","sourcesContent":["import { createVirtualNamespace } from \"./virtual-module.js\";\n\nconst VIRTUAL_PREFIX = \"\\0gtkx-resources:\";\nconst VIRTUAL_INIT = \"\\0gtkx-resources-init\";\nconst BUNDLE_FILENAME = \"gtkx.gresource\";\nconst REL_SEPARATOR = \"\\0rel=\";\nconst ICON_NAME_SEPARATOR = \"\\0icon=\";\nconst REFRESH_EXPORT = \"__refresh\";\nconst REGISTER_REFRESH_EXPORT = \"__registerRefresh\";\nconst RESOURCE_PATH_EXPORT = \"path\";\nconst { isVirtual, toVirtualId, fromVirtualId } = createVirtualNamespace(VIRTUAL_PREFIX);\n\nconst escapeXml = (value: string): string =>\n value.replaceAll(/[<>&\"']/g, (char) => {\n switch (char) {\n case \"<\": {\n return \"<\";\n }\n case \">\": {\n return \">\";\n }\n case \"&\": {\n return \"&\";\n }\n case \"\\\"\": {\n return \""\";\n }\n default: {\n return \"'\";\n }\n }\n });\n\nexport {\n VIRTUAL_INIT,\n BUNDLE_FILENAME,\n REL_SEPARATOR,\n ICON_NAME_SEPARATOR,\n REFRESH_EXPORT,\n REGISTER_REFRESH_EXPORT,\n RESOURCE_PATH_EXPORT,\n escapeXml,\n isVirtual,\n toVirtualId,\n fromVirtualId,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"resource-shared.js","sourceRoot":"","sources":["../../src/vite-plugins/resource-shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAC3C,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,eAAe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:\";\nconst VIRTUAL_INIT = \"\\0gtkx-resources-init\";\nconst BUNDLE_FILENAME = \"gtkx.gresource\";\nconst REL_SEPARATOR = \"\\0rel=\";\nconst ICON_NAME_SEPARATOR = \"\\0icon=\";\nconst REFRESH_EXPORT = \"__refresh\";\nconst REGISTER_REFRESH_EXPORT = \"__registerRefresh\";\nconst RESOURCE_PATH_EXPORT = \"path\";\nconst VIRTUAL_ID_RE = new RegExp(`^${VIRTUAL_PREFIX}`);\nconst VIRTUAL_INIT_RE = new RegExp(`^${VIRTUAL_INIT}$`);\nconst { isVirtual, toVirtualId, fromVirtualId } = createVirtualNamespace(VIRTUAL_PREFIX);\n\nconst escapeXml = (value: string): string =>\n value.replaceAll(/[<>&\"']/g, (char) => {\n switch (char) {\n case \"<\": {\n return \"<\";\n }\n case \">\": {\n return \">\";\n }\n case \"&\": {\n return \"&\";\n }\n case \"\\\"\": {\n return \""\";\n }\n default: {\n return \"'\";\n }\n }\n });\n\nexport {\n VIRTUAL_ID_RE,\n VIRTUAL_INIT,\n VIRTUAL_INIT_RE,\n BUNDLE_FILENAME,\n REL_SEPARATOR,\n ICON_NAME_SEPARATOR,\n REFRESH_EXPORT,\n REGISTER_REFRESH_EXPORT,\n RESOURCE_PATH_EXPORT,\n escapeXml,\n isVirtual,\n toVirtualId,\n fromVirtualId,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAc,MAAM,EAAuD,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAc,MAAM,EAAuD,MAAM,MAAM,CAAC;AA0/CpG,iBAAS,aAAa,CAAC,UAAU,GAAE,YAAmC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAuBlG;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createConfigLoader, resourceBasePath } from "@gtkx/config/internal";
|
|
1
|
+
import { createConfigLoader, resourceBasePath, viteProjectRoot } from "@gtkx/config/internal";
|
|
2
2
|
import { error, info, isPathInside, isRecord, sortStrings, toPosixPath } from "@gtkx/utils";
|
|
3
3
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { basename, dirname, extname, isAbsolute, join, posix, relative, sep } from "node:path";
|
|
@@ -10,7 +10,7 @@ import { createRetainedStagingDir, withStagingDir } from "../internal/staging-di
|
|
|
10
10
|
import { ASSET_RE } from "./asset-extensions.js";
|
|
11
11
|
import { isBareRelativeAsset, parseIconSpecifier, parseResourceSpecifier, } from "./asset-specifier.js";
|
|
12
12
|
import { renderInitModule } from "./resource-init-module.js";
|
|
13
|
-
import { BUNDLE_FILENAME, escapeXml, fromVirtualId, ICON_NAME_SEPARATOR, isVirtual, REFRESH_EXPORT, REGISTER_REFRESH_EXPORT, REL_SEPARATOR, RESOURCE_PATH_EXPORT, toVirtualId, VIRTUAL_INIT, } from "./resource-shared.js";
|
|
13
|
+
import { BUNDLE_FILENAME, escapeXml, fromVirtualId, ICON_NAME_SEPARATOR, isVirtual, REFRESH_EXPORT, REGISTER_REFRESH_EXPORT, REL_SEPARATOR, RESOURCE_PATH_EXPORT, toVirtualId, VIRTUAL_ID_RE, VIRTUAL_INIT, VIRTUAL_INIT_RE, } from "./resource-shared.js";
|
|
14
14
|
import { stripQuery } from "./strip-query.js";
|
|
15
15
|
const RESOURCE_COMPILER = "glib-compile-resources";
|
|
16
16
|
const MANIFEST_PREFIX = "/";
|
|
@@ -781,7 +781,7 @@ const reconcileImporter = async (ctx, state, id) => {
|
|
|
781
781
|
}
|
|
782
782
|
};
|
|
783
783
|
const resolveResourceConfig = async (state, config, loadConfig) => {
|
|
784
|
-
const loaded = await loadConfig.load(config
|
|
784
|
+
const loaded = await loadConfig.load(viteProjectRoot(config));
|
|
785
785
|
state.prefix = resourceBasePath(loaded.config.applicationId);
|
|
786
786
|
state.root = loaded.root;
|
|
787
787
|
return {
|
|
@@ -859,7 +859,7 @@ const rejectInvalidSpecifier = (source) => {
|
|
|
859
859
|
}
|
|
860
860
|
if (isBareRelativeAsset(source)) {
|
|
861
861
|
throw new Error(`${JSON.stringify(source)} must choose ?resource for a GResource, ?icon for a themed icon, ` +
|
|
862
|
-
"or ?url for an emitted file");
|
|
862
|
+
"?font for a bundled font, or ?url for an emitted file");
|
|
863
863
|
}
|
|
864
864
|
};
|
|
865
865
|
const resolveExplicitResourceId = async (ctx, state, request) => {
|
|
@@ -937,8 +937,11 @@ const createResourcesPlugin = (state, loadConfig) => ({
|
|
|
937
937
|
resolveId(source, importer, options) {
|
|
938
938
|
return resolveResourceId(this, state, { source, importer, options });
|
|
939
939
|
},
|
|
940
|
-
load
|
|
941
|
-
|
|
940
|
+
load: {
|
|
941
|
+
filter: { id: { include: [VIRTUAL_INIT_RE, VIRTUAL_ID_RE] } },
|
|
942
|
+
handler(id) {
|
|
943
|
+
return loadResourceModule(state, id);
|
|
944
|
+
},
|
|
942
945
|
},
|
|
943
946
|
async transform(code, id) {
|
|
944
947
|
await withExclusiveLoad(state, () => reconcileImporter(this, state, id));
|