@adea-ai/app-framework 0.0.0-stage → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +30 -0
- package/README.md +967 -2
- package/dist/app/application.d.ts +47 -0
- package/dist/app/application.js +115 -0
- package/dist/app/create-application.d.ts +13 -0
- package/dist/app/create-application.js +178 -0
- package/dist/app/service-registry.d.ts +44 -0
- package/dist/app/service-registry.js +116 -0
- package/dist/appearance/appearance-host.d.ts +62 -0
- package/dist/appearance/appearance-host.js +115 -0
- package/dist/appearance/appearance-preferences.d.ts +106 -0
- package/dist/appearance/appearance-preferences.js +175 -0
- package/dist/appearance/composition.d.ts +11 -0
- package/dist/appearance/composition.js +16 -0
- package/dist/appearance/custom-theme-import.d.ts +14 -0
- package/dist/appearance/custom-theme-import.js +315 -0
- package/dist/appearance/custom-theme-library.d.ts +146 -0
- package/dist/appearance/custom-theme-library.js +378 -0
- package/dist/appearance/editor.d.ts +20 -0
- package/dist/appearance/editor.js +47 -0
- package/dist/appearance/theme-file-importer.d.ts +23 -0
- package/dist/appearance/theme-file-importer.js +66 -0
- package/dist/appearance/theme-record-adapter.d.ts +26 -0
- package/dist/appearance/theme-record-adapter.js +64 -0
- package/dist/appearance/theme-registry.d.ts +10 -0
- package/dist/appearance/theme-registry.js +16 -0
- package/dist/appearance/window-surface.d.ts +5 -0
- package/dist/appearance/window-surface.js +9 -0
- package/dist/ci/toolchain-identity.d.ts +39 -0
- package/dist/ci/toolchain-identity.js +196 -0
- package/dist/cli/cef-helper-cli.d.ts +2 -0
- package/dist/cli/cef-helper-cli.js +18 -0
- package/dist/cli/cli-runner.d.ts +8 -0
- package/dist/cli/cli-runner.js +23 -0
- package/dist/cli/create-application-cli.d.ts +2 -0
- package/dist/cli/create-application-cli.js +40 -0
- package/dist/cli/electrobun-shortcut-patch-cli.d.ts +2 -0
- package/dist/cli/electrobun-shortcut-patch-cli.js +17 -0
- package/dist/cli/framework-update-cli.d.ts +2 -0
- package/dist/cli/framework-update-cli.js +40 -0
- package/dist/cli/release-assets-plan-cli.d.ts +2 -0
- package/dist/cli/release-assets-plan-cli.js +14 -0
- package/dist/cli/release-cut-cli.d.ts +2 -0
- package/dist/cli/release-cut-cli.js +27 -0
- package/dist/cli/release-descriptor-staging-cli.d.ts +2 -0
- package/dist/cli/release-descriptor-staging-cli.js +45 -0
- package/dist/cli/release-finalize-cli.d.ts +1 -0
- package/dist/cli/release-finalize-cli.js +30 -0
- package/dist/cli/release-promote-cli.d.ts +2 -0
- package/dist/cli/release-promote-cli.js +32 -0
- package/dist/cli/release-publish-cli.d.ts +2 -0
- package/dist/cli/release-publish-cli.js +48 -0
- package/dist/cli/release-sign-cli.d.ts +2 -0
- package/dist/cli/release-sign-cli.js +13 -0
- package/dist/cli/release-step-cli.d.ts +2 -0
- package/dist/cli/release-step-cli.js +44 -0
- package/dist/cli/toolchain-identity-cli.d.ts +2 -0
- package/dist/cli/toolchain-identity-cli.js +10 -0
- package/dist/cli/update-helper-cli.d.ts +1 -0
- package/dist/cli/update-helper-cli.js +10 -0
- package/dist/cli/windows-runtime-patch-cli.d.ts +2 -0
- package/dist/cli/windows-runtime-patch-cli.js +17 -0
- package/dist/desktop/application-command-client.d.ts +15 -0
- package/dist/desktop/application-command-client.js +21 -0
- package/dist/desktop/channel-handshake.d.ts +32 -0
- package/dist/desktop/channel-handshake.js +111 -0
- package/dist/desktop/channel-proof.d.ts +43 -0
- package/dist/desktop/channel-proof.js +85 -0
- package/dist/desktop/client-assets.d.ts +7 -0
- package/dist/desktop/client-assets.js +59 -0
- package/dist/desktop/desktop-client.d.ts +23 -0
- package/dist/desktop/desktop-client.js +231 -0
- package/dist/desktop/desktop-gateway.d.ts +18 -0
- package/dist/desktop/desktop-gateway.js +146 -0
- package/dist/desktop/desktop-host.d.ts +48 -0
- package/dist/desktop/desktop-host.js +208 -0
- package/dist/desktop/desktop-stream.d.ts +36 -0
- package/dist/desktop/desktop-stream.js +231 -0
- package/dist/desktop/loopback-policy.d.ts +19 -0
- package/dist/desktop/loopback-policy.js +23 -0
- package/dist/desktop/open-url-channel.d.ts +15 -0
- package/dist/desktop/open-url-channel.js +55 -0
- package/dist/desktop/string-policy.d.ts +2 -0
- package/dist/desktop/string-policy.js +11 -0
- package/dist/framework-source.json +1 -0
- package/dist/installer/archive-entry.d.ts +6 -0
- package/dist/installer/archive-entry.js +14 -0
- package/dist/installer/command-artifact.d.ts +47 -0
- package/dist/installer/command-artifact.js +261 -0
- package/dist/installer/command-qualification-command.d.ts +12 -0
- package/dist/installer/command-qualification-command.js +71 -0
- package/dist/installer/hosted-runner.d.ts +4 -0
- package/dist/installer/hosted-runner.js +10 -0
- package/dist/installer/installed-payload.d.ts +29 -0
- package/dist/installer/installed-payload.js +312 -0
- package/dist/installer/installer-ci-bootstrap.d.ts +26 -0
- package/dist/installer/installer-ci-bootstrap.js +160 -0
- package/dist/installer/installer-ci-preflight.d.ts +1 -0
- package/dist/installer/installer-ci-preflight.js +49 -0
- package/dist/installer/installer-ci-worker.d.ts +1 -0
- package/dist/installer/installer-ci-worker.js +105 -0
- package/dist/installer/installer-extraction.d.ts +14 -0
- package/dist/installer/installer-extraction.js +289 -0
- package/dist/installer/installer-fetch-guard.d.ts +15 -0
- package/dist/installer/installer-fetch-guard.js +50 -0
- package/dist/installer/installer-identity.d.ts +23 -0
- package/dist/installer/installer-identity.js +286 -0
- package/dist/installer/installer-layout.d.ts +21 -0
- package/dist/installer/installer-layout.js +89 -0
- package/dist/installer/installer-observation.d.ts +64 -0
- package/dist/installer/installer-observation.js +473 -0
- package/dist/installer/installer-process-cleanup.d.ts +18 -0
- package/dist/installer/installer-process-cleanup.js +158 -0
- package/dist/installer/installer-qualification-command.d.ts +11 -0
- package/dist/installer/installer-qualification-command.js +71 -0
- package/dist/installer/installer-renderer-evidence.d.ts +43 -0
- package/dist/installer/installer-renderer-evidence.js +136 -0
- package/dist/installer/installer-upgrade-command.d.ts +37 -0
- package/dist/installer/installer-upgrade-command.js +172 -0
- package/dist/installer/installer-worker-guard.d.ts +21 -0
- package/dist/installer/installer-worker-guard.js +72 -0
- package/dist/installer/native-executable.d.ts +5 -0
- package/dist/installer/native-executable.js +21 -0
- package/dist/installer/upgrade-asset-download.d.ts +13 -0
- package/dist/installer/upgrade-asset-download.js +41 -0
- package/dist/installer/write-all.d.ts +6 -0
- package/dist/installer/write-all.js +11 -0
- package/dist/native/app-bundle.d.ts +28 -0
- package/dist/native/app-bundle.js +60 -0
- package/dist/native/cef-helper.d.ts +28 -0
- package/dist/native/cef-helper.js +402 -0
- package/dist/native/desktop-build-hook.d.ts +7 -0
- package/dist/native/desktop-build-hook.js +20 -0
- package/dist/native/electrobun-source-patch.d.ts +25 -0
- package/dist/native/electrobun-source-patch.js +93 -0
- package/dist/native/linux-cef-links.d.ts +2 -0
- package/dist/native/linux-cef-links.js +15 -0
- package/dist/native/native-secret-store.d.ts +27 -0
- package/dist/native/native-secret-store.js +70 -0
- package/dist/native/native-utilities.d.ts +24 -0
- package/dist/native/native-utilities.js +85 -0
- package/dist/native/partitioned-window.d.ts +34 -0
- package/dist/native/partitioned-window.js +44 -0
- package/dist/native/renderer-profile.d.ts +53 -0
- package/dist/native/renderer-profile.js +30 -0
- package/dist/native/secure-window.d.ts +38 -0
- package/dist/native/secure-window.js +77 -0
- package/dist/native/sidecar-services.d.ts +23 -0
- package/dist/native/sidecar-services.js +46 -0
- package/dist/native/sidecar.d.ts +81 -0
- package/dist/native/sidecar.js +250 -0
- package/dist/native/window-bootstrap.d.ts +24 -0
- package/dist/native/window-bootstrap.js +63 -0
- package/dist/native/window-options.d.ts +32 -0
- package/dist/native/window-options.js +23 -0
- package/dist/native/windows-build-hook-internal.d.ts +2 -0
- package/dist/native/windows-build-hook-internal.js +32 -0
- package/dist/native/windows-build-hook.d.ts +2 -0
- package/dist/native/windows-build-hook.js +12 -0
- package/dist/native/windows-runtime-patch-internal.d.ts +3 -0
- package/dist/native/windows-runtime-patch-internal.js +20 -0
- package/dist/native/windows-runtime-patch.d.ts +4 -0
- package/dist/native/windows-runtime-patch.js +12 -0
- package/dist/release/feed-release-cut.d.ts +23 -0
- package/dist/release/feed-release-cut.js +93 -0
- package/dist/release/feed-state.d.ts +25 -0
- package/dist/release/feed-state.js +81 -0
- package/dist/release/framework-package-publish.d.ts +21 -0
- package/dist/release/framework-package-publish.js +125 -0
- package/dist/release/framework-update.d.ts +30 -0
- package/dist/release/framework-update.js +139 -0
- package/dist/release/github-cli.d.ts +6 -0
- package/dist/release/github-cli.js +16 -0
- package/dist/release/github-release-assets.d.ts +3 -0
- package/dist/release/github-release-assets.js +24 -0
- package/dist/release/github-release-cut.d.ts +14 -0
- package/dist/release/github-release-cut.js +174 -0
- package/dist/release/github-release-lookup.d.ts +7 -0
- package/dist/release/github-release-lookup.js +29 -0
- package/dist/release/github-release-promotion.d.ts +10 -0
- package/dist/release/github-release-promotion.js +78 -0
- package/dist/release/github-release-provenance.d.ts +9 -0
- package/dist/release/github-release-provenance.js +27 -0
- package/dist/release/github-release-publisher.d.ts +9 -0
- package/dist/release/github-release-publisher.js +63 -0
- package/dist/release/github-release-qualification.d.ts +12 -0
- package/dist/release/github-release-qualification.js +80 -0
- package/dist/release/local-provenance.d.ts +24 -0
- package/dist/release/local-provenance.js +72 -0
- package/dist/release/local-release.d.ts +133 -0
- package/dist/release/local-release.js +387 -0
- package/dist/release/macos-dmg.d.ts +22 -0
- package/dist/release/macos-dmg.js +91 -0
- package/dist/release/release-artifact.d.ts +6 -0
- package/dist/release/release-artifact.js +38 -0
- package/dist/release/release-assets-plan.d.ts +14 -0
- package/dist/release/release-assets-plan.js +65 -0
- package/dist/release/release-config.d.ts +76 -0
- package/dist/release/release-config.js +180 -0
- package/dist/release/release-cut-command.d.ts +13 -0
- package/dist/release/release-cut-command.js +39 -0
- package/dist/release/release-cut.d.ts +54 -0
- package/dist/release/release-cut.js +76 -0
- package/dist/release/release-descriptor-staging.d.ts +34 -0
- package/dist/release/release-descriptor-staging.js +147 -0
- package/dist/release/release-finalize.d.ts +16 -0
- package/dist/release/release-finalize.js +104 -0
- package/dist/release/release-promotion-command.d.ts +12 -0
- package/dist/release/release-promotion-command.js +28 -0
- package/dist/release/release-promotion.d.ts +29 -0
- package/dist/release/release-promotion.js +57 -0
- package/dist/release/release-publication.d.ts +33 -0
- package/dist/release/release-publication.js +138 -0
- package/dist/release/release-publish-command.d.ts +7 -0
- package/dist/release/release-publish-command.js +91 -0
- package/dist/release/release-qualification.d.ts +106 -0
- package/dist/release/release-qualification.js +135 -0
- package/dist/release/release-staging.d.ts +9 -0
- package/dist/release/release-staging.js +61 -0
- package/dist/release/release-steps.d.ts +38 -0
- package/dist/release/release-steps.js +147 -0
- package/dist/release/retained-release-build.d.ts +19 -0
- package/dist/release/retained-release-build.js +122 -0
- package/dist/shell/app-shell.d.ts +61 -0
- package/dist/shell/app-shell.js +318 -0
- package/dist/shell/app-utilities.d.ts +122 -0
- package/dist/shell/app-utilities.js +334 -0
- package/dist/shell/application-menu-commands.d.ts +5 -0
- package/dist/shell/application-menu-commands.js +11 -0
- package/dist/shell/application-menu.d.ts +61 -0
- package/dist/shell/application-menu.js +208 -0
- package/dist/shell/help-shortcuts.d.ts +12 -0
- package/dist/shell/help-shortcuts.js +22 -0
- package/dist/shell/settings-sections.d.ts +31 -0
- package/dist/shell/settings-sections.js +50 -0
- package/dist/shell/shortcut-platform.d.ts +17 -0
- package/dist/shell/shortcut-platform.js +25 -0
- package/dist/update-helper.bundle.js +260 -0
- package/dist/updates/channel-update-manager.d.ts +46 -0
- package/dist/updates/channel-update-manager.js +114 -0
- package/dist/updates/desktop-updater.d.ts +104 -0
- package/dist/updates/desktop-updater.js +345 -0
- package/dist/updates/release-feed.d.ts +61 -0
- package/dist/updates/release-feed.js +111 -0
- package/dist/updates/release-location.d.ts +9 -0
- package/dist/updates/release-location.js +80 -0
- package/dist/updates/release-version.d.ts +12 -0
- package/dist/updates/release-version.js +43 -0
- package/dist/updates/signed-release.d.ts +63 -0
- package/dist/updates/signed-release.js +162 -0
- package/dist/updates/stable-file.d.ts +10 -0
- package/dist/updates/stable-file.js +22 -0
- package/dist/updates/update-adapter.d.ts +57 -0
- package/dist/updates/update-adapter.js +72 -0
- package/dist/updates/update-arm.d.ts +24 -0
- package/dist/updates/update-arm.js +95 -0
- package/dist/updates/update-channel-store.d.ts +8 -0
- package/dist/updates/update-channel-store.js +72 -0
- package/dist/updates/update-discovery.d.ts +13 -0
- package/dist/updates/update-discovery.js +56 -0
- package/dist/updates/update-download.d.ts +14 -0
- package/dist/updates/update-download.js +67 -0
- package/dist/updates/update-exclusive-rename.d.ts +2 -0
- package/dist/updates/update-exclusive-rename.js +52 -0
- package/dist/updates/update-extraction.d.ts +18 -0
- package/dist/updates/update-extraction.js +183 -0
- package/dist/updates/update-handoff-plan.d.ts +22 -0
- package/dist/updates/update-handoff-plan.js +28 -0
- package/dist/updates/update-helper.d.ts +24 -0
- package/dist/updates/update-helper.js +56 -0
- package/dist/updates/update-launch.d.ts +5 -0
- package/dist/updates/update-launch.js +27 -0
- package/dist/updates/update-manager.d.ts +40 -0
- package/dist/updates/update-manager.js +83 -0
- package/dist/updates/update-process-fence.d.ts +10 -0
- package/dist/updates/update-process-fence.js +114 -0
- package/dist/updates/update-resume.d.ts +13 -0
- package/dist/updates/update-resume.js +34 -0
- package/dist/updates/update-shutdown.d.ts +15 -0
- package/dist/updates/update-shutdown.js +29 -0
- package/dist/updates/update-state.d.ts +30 -0
- package/dist/updates/update-state.js +18 -0
- package/dist/updates/update-swap-stage.d.ts +27 -0
- package/dist/updates/update-swap-stage.js +58 -0
- package/dist/updates/update-swap.d.ts +10 -0
- package/dist/updates/update-swap.js +30 -0
- package/dist/views/app-about.d.ts +22 -0
- package/dist/views/app-about.js +43 -0
- package/dist/views/app-appearance.d.ts +11 -0
- package/dist/views/app-appearance.js +42 -0
- package/dist/views/app-help.d.ts +17 -0
- package/dist/views/app-help.js +42 -0
- package/dist/views/app-settings.d.ts +26 -0
- package/dist/views/app-settings.js +97 -0
- package/dist/views/appearance-surface.d.ts +9 -0
- package/dist/views/appearance-surface.js +334 -0
- package/dist/views/update-surface.d.ts +34 -0
- package/dist/views/update-surface.js +64 -0
- package/package.json +363 -4
- package/src/app/application.tsx +138 -0
- package/src/app/create-application.ts +245 -0
- package/src/app/service-registry.ts +124 -0
- package/src/appearance/appearance-host.tsx +205 -0
- package/src/appearance/appearance-preferences.ts +287 -0
- package/src/appearance/composition.ts +29 -0
- package/src/appearance/custom-theme-import.ts +424 -0
- package/src/appearance/custom-theme-library.ts +600 -0
- package/src/appearance/editor.ts +94 -0
- package/src/appearance/theme-file-importer.ts +103 -0
- package/src/appearance/theme-record-adapter.ts +106 -0
- package/src/appearance/theme-registry.ts +20 -0
- package/src/appearance/window-surface.ts +18 -0
- package/src/ci/toolchain-identity.ts +244 -0
- package/src/cli/cef-helper-cli.ts +21 -0
- package/src/cli/cli-runner.ts +29 -0
- package/src/cli/create-application-cli.ts +62 -0
- package/src/cli/electrobun-shortcut-patch-cli.ts +24 -0
- package/src/cli/framework-update-cli.ts +41 -0
- package/src/cli/release-assets-plan-cli.ts +14 -0
- package/src/cli/release-cut-cli.ts +41 -0
- package/src/cli/release-descriptor-staging-cli.ts +57 -0
- package/src/cli/release-finalize-cli.ts +34 -0
- package/src/cli/release-promote-cli.ts +31 -0
- package/src/cli/release-publish-cli.ts +46 -0
- package/src/cli/release-sign-cli.ts +24 -0
- package/src/cli/release-step-cli.ts +71 -0
- package/src/cli/toolchain-identity-cli.ts +12 -0
- package/src/cli/update-helper-cli.ts +12 -0
- package/src/cli/windows-runtime-patch-cli.ts +17 -0
- package/src/desktop/application-command-client.ts +43 -0
- package/src/desktop/channel-handshake.ts +136 -0
- package/src/desktop/channel-proof.ts +122 -0
- package/src/desktop/client-assets.ts +75 -0
- package/src/desktop/desktop-client.ts +303 -0
- package/src/desktop/desktop-gateway.ts +189 -0
- package/src/desktop/desktop-host.ts +335 -0
- package/src/desktop/desktop-stream.ts +324 -0
- package/src/desktop/loopback-policy.ts +41 -0
- package/src/desktop/open-url-channel.ts +79 -0
- package/src/desktop/string-policy.ts +9 -0
- package/src/installer/archive-entry.ts +32 -0
- package/src/installer/command-artifact.ts +307 -0
- package/src/installer/command-qualification-command.ts +75 -0
- package/src/installer/hosted-runner.ts +11 -0
- package/src/installer/installed-payload.ts +408 -0
- package/src/installer/installer-ci-bootstrap.ts +199 -0
- package/src/installer/installer-ci-preflight.ts +61 -0
- package/src/installer/installer-ci-worker.ts +105 -0
- package/src/installer/installer-extraction.ts +367 -0
- package/src/installer/installer-fetch-guard.ts +75 -0
- package/src/installer/installer-identity.ts +331 -0
- package/src/installer/installer-layout.ts +167 -0
- package/src/installer/installer-observation.ts +671 -0
- package/src/installer/installer-process-cleanup.ts +167 -0
- package/src/installer/installer-qualification-command.ts +81 -0
- package/src/installer/installer-renderer-evidence.ts +268 -0
- package/src/installer/installer-upgrade-command.ts +226 -0
- package/src/installer/installer-worker-guard.ts +112 -0
- package/src/installer/native-executable.ts +37 -0
- package/src/installer/upgrade-asset-download.ts +72 -0
- package/src/installer/write-all.ts +19 -0
- package/src/native/app-bundle.ts +86 -0
- package/src/native/cef-helper.ts +471 -0
- package/src/native/desktop-build-hook.ts +21 -0
- package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
- package/src/native/electrobun-source-patch.ts +107 -0
- package/src/native/electrobun-windows-shortcut-com.patch +923 -0
- package/src/native/linux-cef-links.ts +14 -0
- package/src/native/native-secret-store.ts +99 -0
- package/src/native/native-utilities.ts +166 -0
- package/src/native/partitioned-window.ts +62 -0
- package/src/native/renderer-profile.ts +27 -0
- package/src/native/secure-window.ts +115 -0
- package/src/native/sidecar-services.ts +71 -0
- package/src/native/sidecar.ts +387 -0
- package/src/native/window-bootstrap.ts +77 -0
- package/src/native/window-options.ts +24 -0
- package/src/native/windows-build-hook-internal.ts +49 -0
- package/src/native/windows-build-hook.ts +12 -0
- package/src/native/windows-runtime-patch-internal.ts +48 -0
- package/src/native/windows-runtime-patch.ts +15 -0
- package/src/release/feed-release-cut.ts +110 -0
- package/src/release/feed-state.ts +135 -0
- package/src/release/framework-package-publish.ts +163 -0
- package/src/release/framework-update.ts +196 -0
- package/src/release/github-cli.ts +27 -0
- package/src/release/github-release-assets.ts +36 -0
- package/src/release/github-release-cut.ts +237 -0
- package/src/release/github-release-lookup.ts +39 -0
- package/src/release/github-release-promotion.ts +112 -0
- package/src/release/github-release-provenance.ts +65 -0
- package/src/release/github-release-publisher.ts +90 -0
- package/src/release/github-release-qualification.ts +144 -0
- package/src/release/local-provenance.ts +92 -0
- package/src/release/local-release.ts +525 -0
- package/src/release/macos-dmg.ts +113 -0
- package/src/release/release-artifact.ts +53 -0
- package/src/release/release-assets-plan.ts +118 -0
- package/src/release/release-config.ts +420 -0
- package/src/release/release-cut-command.ts +80 -0
- package/src/release/release-cut.ts +133 -0
- package/src/release/release-descriptor-staging.ts +242 -0
- package/src/release/release-finalize.ts +191 -0
- package/src/release/release-promotion-command.ts +36 -0
- package/src/release/release-promotion.ts +132 -0
- package/src/release/release-publication.ts +213 -0
- package/src/release/release-publish-command.ts +163 -0
- package/src/release/release-qualification.ts +397 -0
- package/src/release/release-staging.ts +87 -0
- package/src/release/release-steps.ts +173 -0
- package/src/release/retained-release-build.ts +217 -0
- package/src/shell/app-shell.tsx +285 -0
- package/src/shell/app-utilities.tsx +437 -0
- package/src/shell/application-menu-commands.ts +6 -0
- package/src/shell/application-menu.ts +250 -0
- package/src/shell/help-shortcuts.ts +24 -0
- package/src/shell/settings-sections.ts +74 -0
- package/src/shell/shortcut-platform.ts +35 -0
- package/src/updates/channel-update-manager.ts +127 -0
- package/src/updates/desktop-updater.ts +440 -0
- package/src/updates/release-feed.ts +187 -0
- package/src/updates/release-location.ts +101 -0
- package/src/updates/release-version.ts +57 -0
- package/src/updates/signed-release.ts +311 -0
- package/src/updates/stable-file.ts +32 -0
- package/src/updates/update-adapter.ts +129 -0
- package/src/updates/update-arm.ts +107 -0
- package/src/updates/update-channel-store.ts +86 -0
- package/src/updates/update-discovery.ts +113 -0
- package/src/updates/update-download.ts +82 -0
- package/src/updates/update-exclusive-rename.ts +58 -0
- package/src/updates/update-extraction.ts +261 -0
- package/src/updates/update-handoff-plan.ts +75 -0
- package/src/updates/update-helper.ts +87 -0
- package/src/updates/update-launch.ts +33 -0
- package/src/updates/update-manager.ts +130 -0
- package/src/updates/update-process-fence.ts +125 -0
- package/src/updates/update-resume.ts +34 -0
- package/src/updates/update-shutdown.ts +37 -0
- package/src/updates/update-state.ts +34 -0
- package/src/updates/update-swap-stage.ts +75 -0
- package/src/updates/update-swap.ts +30 -0
- package/src/views/app-about.tsx +44 -0
- package/src/views/app-appearance.tsx +32 -0
- package/src/views/app-help.tsx +43 -0
- package/src/views/app-settings.tsx +88 -0
- package/src/views/appearance-surface.tsx +427 -0
- package/src/views/update-surface.tsx +85 -0
- package/templates/application/.gitattributes +1 -0
- package/templates/application/.github/workflows/release-assets.yml +29 -0
- package/templates/application/.github/workflows/release-finalize.yml +29 -0
- package/templates/application/.github/workflows/release-please.yml +19 -0
- package/templates/application/.github/workflows/release.yml +29 -0
- package/templates/application/.github/workflows/validation.yml +28 -0
- package/templates/application/.oxfmtrc.json +6 -0
- package/templates/application/.oxlintrc.json +48 -0
- package/templates/application/.release-please-manifest.json +3 -0
- package/templates/application/README.md +47 -0
- package/templates/application/electrobun.config.ts +22 -0
- package/templates/application/release-please-config.json +12 -0
- package/templates/application/scripts/app-version.ts +9 -0
- package/templates/application/scripts/build-desktop.ts +34 -0
- package/templates/application/scripts/secure-build.ts +1 -0
- package/templates/application/scripts/stage-release.ts +21 -0
- package/templates/application/src/bun/index.ts +80 -0
- package/templates/application/src/electrobun.d.ts +27 -0
- package/templates/application/src/web/index.html +12 -0
- package/templates/application/src/web/main.tsx +97 -0
- package/templates/application/src/web/public/icon.svg +1 -0
- package/templates/application/src/web/style.css +3 -0
- package/templates/application/tests/app-config.test.ts +9 -0
- package/templates/application/tsconfig.json +15 -0
- package/templates/application/vite.config.ts +10 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const linuxCefLibraries = new Set([
|
|
2
|
+
'libcef.so',
|
|
3
|
+
'libvulkan.so.1',
|
|
4
|
+
'libvk_swiftshader.so',
|
|
5
|
+
'libEGL.so',
|
|
6
|
+
'libGLESv2.so',
|
|
7
|
+
])
|
|
8
|
+
|
|
9
|
+
/** These links are emitted by Electrobun's Linux CEF bundle, and are relative to bin/. */
|
|
10
|
+
export function isLinuxCefLibraryLink(path: string, target: string): boolean {
|
|
11
|
+
if (!path.startsWith('bin/')) return false
|
|
12
|
+
const name = path.slice(4)
|
|
13
|
+
return linuxCefLibraries.has(name) && target === `cef/${name}`
|
|
14
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
type SecretBackend = {
|
|
2
|
+
get(input: { service: string; name: string }): Promise<string | null>
|
|
3
|
+
set(input: { service: string; name: string; value: string; persist: 'local' }): Promise<void>
|
|
4
|
+
delete(input: { service: string; name: string }): Promise<boolean>
|
|
5
|
+
}
|
|
6
|
+
const identifier = (value: unknown): value is string =>
|
|
7
|
+
typeof value === 'string' &&
|
|
8
|
+
value.length > 0 &&
|
|
9
|
+
value.length <= 128 &&
|
|
10
|
+
/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(value)
|
|
11
|
+
|
|
12
|
+
/** Native credentials only. Apps choose the service namespace and own authorization and migration. */
|
|
13
|
+
export function createNativeSecretStore(options: {
|
|
14
|
+
service: string
|
|
15
|
+
backend?: SecretBackend
|
|
16
|
+
maxBytes?: number
|
|
17
|
+
}) {
|
|
18
|
+
const maxBytes = options.maxBytes ?? 2048
|
|
19
|
+
if (
|
|
20
|
+
!identifier(options.service) ||
|
|
21
|
+
!Number.isSafeInteger(maxBytes) ||
|
|
22
|
+
maxBytes < 1 ||
|
|
23
|
+
maxBytes > 2048
|
|
24
|
+
)
|
|
25
|
+
throw new Error('Invalid credential store configuration')
|
|
26
|
+
const backend = options.backend ?? Bun.secrets
|
|
27
|
+
if (
|
|
28
|
+
!backend ||
|
|
29
|
+
typeof backend.get !== 'function' ||
|
|
30
|
+
typeof backend.set !== 'function' ||
|
|
31
|
+
typeof backend.delete !== 'function'
|
|
32
|
+
)
|
|
33
|
+
throw new Error('Credential store unavailable')
|
|
34
|
+
let queue = Promise.resolve()
|
|
35
|
+
const name = (value: unknown) => {
|
|
36
|
+
if (!identifier(value)) throw new Error('Invalid credential name')
|
|
37
|
+
return value
|
|
38
|
+
}
|
|
39
|
+
function ordered<T>(task: () => Promise<T>): Promise<T> {
|
|
40
|
+
const result = queue.then(task)
|
|
41
|
+
queue = result.then(
|
|
42
|
+
() => {},
|
|
43
|
+
() => {}
|
|
44
|
+
)
|
|
45
|
+
return result
|
|
46
|
+
}
|
|
47
|
+
async function read(account: string): Promise<string | null> {
|
|
48
|
+
try {
|
|
49
|
+
const value = await backend.get({ service: options.service, name: account })
|
|
50
|
+
if (
|
|
51
|
+
value !== null &&
|
|
52
|
+
(typeof value !== 'string' ||
|
|
53
|
+
value.includes('\0') ||
|
|
54
|
+
Buffer.byteLength(value, 'utf8') > maxBytes)
|
|
55
|
+
)
|
|
56
|
+
throw new Error('Invalid native result')
|
|
57
|
+
return value
|
|
58
|
+
} catch {
|
|
59
|
+
throw new Error('Credential store unavailable')
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
get(account: string) {
|
|
64
|
+
const key = name(account)
|
|
65
|
+
return ordered(() => read(key))
|
|
66
|
+
},
|
|
67
|
+
set(account: string, value: string) {
|
|
68
|
+
const key = name(account)
|
|
69
|
+
if (
|
|
70
|
+
typeof value !== 'string' ||
|
|
71
|
+
!value ||
|
|
72
|
+
value.includes('\0') ||
|
|
73
|
+
Buffer.byteLength(value, 'utf8') > maxBytes
|
|
74
|
+
)
|
|
75
|
+
throw new Error('Invalid credential value')
|
|
76
|
+
return ordered(async () => {
|
|
77
|
+
try {
|
|
78
|
+
await backend.set({ service: options.service, name: key, value, persist: 'local' })
|
|
79
|
+
} catch {
|
|
80
|
+
throw new Error('Credential store unavailable')
|
|
81
|
+
}
|
|
82
|
+
if ((await read(key)) !== value) throw new Error('Credential store verification failed')
|
|
83
|
+
})
|
|
84
|
+
},
|
|
85
|
+
delete(account: string) {
|
|
86
|
+
const key = name(account)
|
|
87
|
+
return ordered(async () => {
|
|
88
|
+
try {
|
|
89
|
+
const removed = await backend.delete({ service: options.service, name: key })
|
|
90
|
+
if (typeof removed !== 'boolean' || (await read(key)) !== null)
|
|
91
|
+
throw new Error('Invalid native result')
|
|
92
|
+
return removed
|
|
93
|
+
} catch {
|
|
94
|
+
throw new Error('Credential store unavailable')
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { isAbsolute } from 'node:path'
|
|
2
|
+
import type { createServiceRegistry } from '../app/service-registry'
|
|
3
|
+
import { containsAsciiControl } from '../desktop/string-policy'
|
|
4
|
+
|
|
5
|
+
type Utility = 'info' | 'open-external' | 'pick-folder' | 'pick-files'
|
|
6
|
+
/** What the web side may ask an open-file dialog for. Electrobun 2.0.5 has no save dialog. */
|
|
7
|
+
export type PickFilesRequest = Readonly<{
|
|
8
|
+
startingFolder?: string
|
|
9
|
+
/** File extensions without the dot, e.g. `['png', 'jpg']`; omitted allows any file. */
|
|
10
|
+
extensions?: readonly string[]
|
|
11
|
+
multiple: boolean
|
|
12
|
+
}>
|
|
13
|
+
const MAX_PICKED_FILES = 1000
|
|
14
|
+
const object = (value: unknown): value is Record<string, unknown> =>
|
|
15
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
16
|
+
const path = (value: unknown): value is string =>
|
|
17
|
+
typeof value === 'string' &&
|
|
18
|
+
value.length > 0 &&
|
|
19
|
+
value.length <= 4096 &&
|
|
20
|
+
!containsAsciiControl(value) &&
|
|
21
|
+
isAbsolute(value) &&
|
|
22
|
+
(process.platform !== 'win32' ||
|
|
23
|
+
/^[A-Za-z]:[\\/]/.test(value) ||
|
|
24
|
+
/^\\\\[A-Za-z0-9][A-Za-z0-9._-]*\\[^\\/?]+(?:\\|$)/.test(value))
|
|
25
|
+
/** Register shared native utilities behind the host's authenticated principal and policy. */
|
|
26
|
+
export function registerNativeUtilities<Principal>(options: {
|
|
27
|
+
services: ReturnType<typeof createServiceRegistry<Principal>>
|
|
28
|
+
info: Readonly<{ name: string; version: string; platform: string }>
|
|
29
|
+
authorize(principal: Principal, utility: Utility): boolean | Promise<boolean>
|
|
30
|
+
openExternal(url: string): boolean | Promise<boolean>
|
|
31
|
+
pickFolder(startingFolder?: string): Promise<readonly string[]>
|
|
32
|
+
/** Optional open-file dialog, registered as `shell.pick-files` when supplied. */
|
|
33
|
+
pickFiles?(request: PickFilesRequest): Promise<readonly string[]>
|
|
34
|
+
}): () => void {
|
|
35
|
+
const { services, authorize, openExternal, pickFolder, pickFiles } = options
|
|
36
|
+
const info = {
|
|
37
|
+
name: options.info?.name,
|
|
38
|
+
version: options.info?.version,
|
|
39
|
+
platform: options.info?.platform,
|
|
40
|
+
}
|
|
41
|
+
if (
|
|
42
|
+
!services ||
|
|
43
|
+
typeof authorize !== 'function' ||
|
|
44
|
+
typeof openExternal !== 'function' ||
|
|
45
|
+
typeof pickFolder !== 'function' ||
|
|
46
|
+
(pickFiles !== undefined && typeof pickFiles !== 'function') ||
|
|
47
|
+
typeof info.name !== 'string' ||
|
|
48
|
+
!info.name.trim() ||
|
|
49
|
+
info.name.length > 100 ||
|
|
50
|
+
containsAsciiControl(info.name) ||
|
|
51
|
+
typeof info.version !== 'string' ||
|
|
52
|
+
info.version.length > 64 ||
|
|
53
|
+
!/^\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(info.version) ||
|
|
54
|
+
!['darwin', 'win32', 'linux'].includes(info.platform)
|
|
55
|
+
)
|
|
56
|
+
throw new Error('Invalid native utility configuration')
|
|
57
|
+
const unregister: (() => void)[] = []
|
|
58
|
+
const remove = () => {
|
|
59
|
+
// splice returns a fresh array; reverse it while keeping the runtime target at ES2022.
|
|
60
|
+
// oxlint-disable-next-line unicorn/no-array-reverse
|
|
61
|
+
for (const fn of unregister.splice(0).reverse()) fn()
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
unregister.push(
|
|
65
|
+
services.register('shell.info', {
|
|
66
|
+
parse(value) {
|
|
67
|
+
if (value !== null) throw new Error('Invalid input')
|
|
68
|
+
return null
|
|
69
|
+
},
|
|
70
|
+
authorize: (principal) => authorize(principal, 'info'),
|
|
71
|
+
run: () => ({ ...info }),
|
|
72
|
+
})
|
|
73
|
+
)
|
|
74
|
+
unregister.push(
|
|
75
|
+
services.register('shell.open-external', {
|
|
76
|
+
parse(value) {
|
|
77
|
+
if (
|
|
78
|
+
!object(value) ||
|
|
79
|
+
Object.keys(value).length !== 1 ||
|
|
80
|
+
typeof value.url !== 'string' ||
|
|
81
|
+
value.url.length > 2048 ||
|
|
82
|
+
containsAsciiControl(value.url, true)
|
|
83
|
+
)
|
|
84
|
+
throw new Error('Invalid URL')
|
|
85
|
+
const url = new URL(value.url)
|
|
86
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password)
|
|
87
|
+
throw new Error('Invalid URL')
|
|
88
|
+
return url.href
|
|
89
|
+
},
|
|
90
|
+
authorize: (principal) => authorize(principal, 'open-external'),
|
|
91
|
+
async run(_principal, url) {
|
|
92
|
+
const opened = await openExternal(url)
|
|
93
|
+
if (typeof opened !== 'boolean') throw new Error('Invalid native result')
|
|
94
|
+
return { opened }
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
)
|
|
98
|
+
unregister.push(
|
|
99
|
+
services.register('shell.pick-folder', {
|
|
100
|
+
parse(value) {
|
|
101
|
+
if (
|
|
102
|
+
!object(value) ||
|
|
103
|
+
Object.keys(value).some((key) => key !== 'startingFolder') ||
|
|
104
|
+
(value.startingFolder !== undefined && !path(value.startingFolder))
|
|
105
|
+
)
|
|
106
|
+
throw new Error('Invalid folder request')
|
|
107
|
+
return value.startingFolder as string | undefined
|
|
108
|
+
},
|
|
109
|
+
authorize: (principal) => authorize(principal, 'pick-folder'),
|
|
110
|
+
async run(_principal, startingFolder) {
|
|
111
|
+
const paths = await pickFolder(startingFolder)
|
|
112
|
+
if (!Array.isArray(paths) || paths.length > 1 || paths.some((value) => !path(value)))
|
|
113
|
+
throw new Error('Invalid native result')
|
|
114
|
+
return { paths: [...paths] }
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
)
|
|
118
|
+
if (pickFiles)
|
|
119
|
+
unregister.push(
|
|
120
|
+
services.register('shell.pick-files', {
|
|
121
|
+
parse(value): PickFilesRequest {
|
|
122
|
+
if (
|
|
123
|
+
!object(value) ||
|
|
124
|
+
Object.keys(value).some(
|
|
125
|
+
(key) => !['startingFolder', 'extensions', 'multiple'].includes(key)
|
|
126
|
+
) ||
|
|
127
|
+
(value.startingFolder !== undefined && !path(value.startingFolder)) ||
|
|
128
|
+
(value.multiple !== undefined && typeof value.multiple !== 'boolean') ||
|
|
129
|
+
(value.extensions !== undefined &&
|
|
130
|
+
(!Array.isArray(value.extensions) ||
|
|
131
|
+
value.extensions.length === 0 ||
|
|
132
|
+
value.extensions.length > 32 ||
|
|
133
|
+
value.extensions.some(
|
|
134
|
+
(item) => typeof item !== 'string' || !/^[A-Za-z0-9]{1,16}$/.test(item)
|
|
135
|
+
)))
|
|
136
|
+
)
|
|
137
|
+
throw new Error('Invalid file request')
|
|
138
|
+
return {
|
|
139
|
+
...(value.startingFolder === undefined
|
|
140
|
+
? {}
|
|
141
|
+
: { startingFolder: value.startingFolder as string }),
|
|
142
|
+
...(value.extensions === undefined
|
|
143
|
+
? {}
|
|
144
|
+
: { extensions: [...(value.extensions as string[])] }),
|
|
145
|
+
multiple: value.multiple === true,
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
authorize: (principal) => authorize(principal, 'pick-files'),
|
|
149
|
+
async run(_principal, request) {
|
|
150
|
+
const paths = await pickFiles(request)
|
|
151
|
+
if (
|
|
152
|
+
!Array.isArray(paths) ||
|
|
153
|
+
paths.length > (request.multiple ? MAX_PICKED_FILES : 1) ||
|
|
154
|
+
paths.some((value) => !path(value))
|
|
155
|
+
)
|
|
156
|
+
throw new Error('Invalid native result')
|
|
157
|
+
return { paths: [...paths] }
|
|
158
|
+
},
|
|
159
|
+
})
|
|
160
|
+
)
|
|
161
|
+
} catch (error) {
|
|
162
|
+
remove()
|
|
163
|
+
throw error
|
|
164
|
+
}
|
|
165
|
+
return remove
|
|
166
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part of Electrobun's `BrowserView` class this helper relies on: the
|
|
3
|
+
* constructor stores `options.partition` and then calls `init()`, which passes
|
|
4
|
+
* `this.partition` to the native `createWebview` request (2.0.1 and 2.0.5).
|
|
5
|
+
*/
|
|
6
|
+
export type PartitionableViewClass = {
|
|
7
|
+
prototype: { init(this: { partition: string | null }): unknown }
|
|
8
|
+
}
|
|
9
|
+
export type PartitionedWindow = {
|
|
10
|
+
webview?: { partition?: string | null } | null
|
|
11
|
+
close(): unknown
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const PARTITION = /^(?:persist:)?[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/
|
|
15
|
+
let constructing = false
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Construct a `BrowserWindow` whose own webview uses `partition`.
|
|
19
|
+
*
|
|
20
|
+
* Electrobun accepts `partition` on `BrowserView` but its `BrowserWindow`
|
|
21
|
+
* constructor does not forward it to the view it creates. While `construct`
|
|
22
|
+
* runs synchronously, this assigns the partition to the first view initialized
|
|
23
|
+
* and restores `BrowserView.prototype.init` afterwards. It fails closed (and
|
|
24
|
+
* closes the window) unless exactly one view was created and the window's view
|
|
25
|
+
* reports the requested partition. Without a partition it only calls
|
|
26
|
+
* `construct`, so ordinary windows keep Electrobun's default profile.
|
|
27
|
+
*/
|
|
28
|
+
export function constructPartitionedWindow<Window extends PartitionedWindow>(options: {
|
|
29
|
+
BrowserView: PartitionableViewClass
|
|
30
|
+
partition: string | null | undefined
|
|
31
|
+
construct(): Window
|
|
32
|
+
}): Window {
|
|
33
|
+
const { partition } = options
|
|
34
|
+
if (partition === undefined || partition === null) return options.construct()
|
|
35
|
+
if (!PARTITION.test(partition)) throw new Error('Invalid browser partition')
|
|
36
|
+
const prototype = options.BrowserView.prototype
|
|
37
|
+
const init = prototype.init
|
|
38
|
+
if (typeof init !== 'function') throw new Error('Unsupported Electrobun BrowserView')
|
|
39
|
+
if (constructing) throw new Error('Partitioned windows must be constructed one at a time')
|
|
40
|
+
let views = 0
|
|
41
|
+
let window: Window | undefined
|
|
42
|
+
constructing = true
|
|
43
|
+
prototype.init = function (this: { partition: string | null }) {
|
|
44
|
+
if (++views === 1) this.partition = partition
|
|
45
|
+
return init.call(this)
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
window = options.construct()
|
|
49
|
+
} finally {
|
|
50
|
+
prototype.init = init
|
|
51
|
+
constructing = false
|
|
52
|
+
}
|
|
53
|
+
if (views !== 1 || window.webview?.partition !== partition) {
|
|
54
|
+
try {
|
|
55
|
+
window.close()
|
|
56
|
+
} catch {
|
|
57
|
+
/* Preserve the partition error. */
|
|
58
|
+
}
|
|
59
|
+
throw new Error('Electrobun did not create the window view in the requested partition')
|
|
60
|
+
}
|
|
61
|
+
return window
|
|
62
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Electrobun's system webview or an explicitly bundled Chromium runtime. */
|
|
2
|
+
export type DesktopRenderer = 'native' | 'cef'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Use the same renderer for build and window creation. Merge each build fragment
|
|
6
|
+
* with the app's existing per-platform signing and packaging configuration.
|
|
7
|
+
*/
|
|
8
|
+
export function createRendererProfile(renderer: DesktopRenderer = 'native') {
|
|
9
|
+
if (renderer !== 'native' && renderer !== 'cef') throw new Error('Unsupported desktop renderer')
|
|
10
|
+
const platform = () =>
|
|
11
|
+
renderer === 'cef'
|
|
12
|
+
? {
|
|
13
|
+
bundleCEF: true,
|
|
14
|
+
defaultRenderer: renderer,
|
|
15
|
+
chromiumFlags: {
|
|
16
|
+
'disable-web-security': false,
|
|
17
|
+
'remote-allow-origins': false,
|
|
18
|
+
'allow-insecure-localhost': false,
|
|
19
|
+
'remote-debugging-port': false,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
: { bundleCEF: false, defaultRenderer: renderer }
|
|
23
|
+
return {
|
|
24
|
+
renderer,
|
|
25
|
+
build: { mac: platform(), win: platform(), linux: platform() },
|
|
26
|
+
} as const
|
|
27
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { createLoopbackPolicy } from '../desktop/loopback-policy'
|
|
2
|
+
import { createRendererProfile, type DesktopRenderer } from './renderer-profile'
|
|
3
|
+
import { createWindowOptions, type WindowFrame } from './window-options'
|
|
4
|
+
|
|
5
|
+
export type SecureWindowOptions = Omit<ReturnType<typeof createWindowOptions>, 'url'> & {
|
|
6
|
+
url: null | 'about:blank'
|
|
7
|
+
renderer: DesktopRenderer
|
|
8
|
+
preload: string
|
|
9
|
+
sandbox: true
|
|
10
|
+
hidden?: boolean
|
|
11
|
+
}
|
|
12
|
+
export type NativeWindow = {
|
|
13
|
+
webview: {
|
|
14
|
+
setNavigationRules(rules: string[]): unknown
|
|
15
|
+
loadURL(url: string): unknown
|
|
16
|
+
on?(
|
|
17
|
+
event: 'did-commit-navigation' | 'will-navigate',
|
|
18
|
+
handler: (event: unknown) => void
|
|
19
|
+
): unknown
|
|
20
|
+
}
|
|
21
|
+
on(event: 'close', handler: () => void): unknown
|
|
22
|
+
close(): unknown
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create a blank window, install navigation rules, then load its trusted origin.
|
|
27
|
+
* Electrobun 2.0.1 does not reliably apply the constructor's navigationRules;
|
|
28
|
+
* setting them after a URL starts loading is too late to protect the preload.
|
|
29
|
+
*/
|
|
30
|
+
export function createSecureWindow<Window extends NativeWindow>(options: {
|
|
31
|
+
origin: string
|
|
32
|
+
grant: { origin: string; preload: string; revoke(): void }
|
|
33
|
+
renderer: DesktopRenderer
|
|
34
|
+
platform: string
|
|
35
|
+
title: string
|
|
36
|
+
frame?: WindowFrame
|
|
37
|
+
transparent?: boolean
|
|
38
|
+
hidden?: boolean
|
|
39
|
+
construct(options: SecureWindowOptions): Window
|
|
40
|
+
}): Window {
|
|
41
|
+
const origin = createLoopbackPolicy(options.origin).origin
|
|
42
|
+
if (origin !== options.grant.origin) throw new Error('Window grant origin mismatch')
|
|
43
|
+
const renderer = createRendererProfile(options.renderer).renderer
|
|
44
|
+
let window: Window | undefined
|
|
45
|
+
let deadline: ReturnType<typeof setTimeout> | undefined
|
|
46
|
+
const clearDeadline = () => {
|
|
47
|
+
if (deadline) clearTimeout(deadline)
|
|
48
|
+
deadline = undefined
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
window = options.construct({
|
|
52
|
+
...createWindowOptions({
|
|
53
|
+
title: options.title,
|
|
54
|
+
url: origin + '/',
|
|
55
|
+
platform: options.platform,
|
|
56
|
+
renderer,
|
|
57
|
+
frame: options.frame,
|
|
58
|
+
transparent: options.transparent,
|
|
59
|
+
}),
|
|
60
|
+
url: options.platform === 'linux' && renderer === 'cef' ? 'about:blank' : null,
|
|
61
|
+
renderer,
|
|
62
|
+
preload: options.grant.preload,
|
|
63
|
+
sandbox: true,
|
|
64
|
+
hidden: options.hidden,
|
|
65
|
+
})
|
|
66
|
+
window.on('close', () => {
|
|
67
|
+
clearDeadline()
|
|
68
|
+
options.grant.revoke()
|
|
69
|
+
})
|
|
70
|
+
window.webview.setNavigationRules(['^*', origin + '/*'])
|
|
71
|
+
// Linux CEF creates the browser asynchronously and starts with about:blank.
|
|
72
|
+
// Wait for that initial navigation to commit before loading the trusted page:
|
|
73
|
+
// otherwise the initial blank navigation can supersede the requested URL.
|
|
74
|
+
if (options.platform === 'linux' && renderer === 'cef') {
|
|
75
|
+
const view = window.webview
|
|
76
|
+
const on = view.on
|
|
77
|
+
if (!on) throw new Error('Window navigation events are unavailable')
|
|
78
|
+
let blankCommitted = false
|
|
79
|
+
on.call(view, 'did-commit-navigation', (event) => {
|
|
80
|
+
const detail = (event as { data?: { detail?: unknown } })?.data?.detail
|
|
81
|
+
if (detail === 'about:blank' && !blankCommitted) {
|
|
82
|
+
blankCommitted = true
|
|
83
|
+
try {
|
|
84
|
+
view.loadURL(origin + '/')
|
|
85
|
+
} catch {
|
|
86
|
+
clearDeadline()
|
|
87
|
+
options.grant.revoke()
|
|
88
|
+
window?.close()
|
|
89
|
+
}
|
|
90
|
+
} else if (typeof detail === 'string') {
|
|
91
|
+
try {
|
|
92
|
+
if (new URL(detail).origin === origin) clearDeadline()
|
|
93
|
+
} catch {
|
|
94
|
+
/* Ignore unrelated navigation. */
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
deadline = setTimeout(() => {
|
|
99
|
+
clearDeadline()
|
|
100
|
+
options.grant.revoke()
|
|
101
|
+
window?.close()
|
|
102
|
+
}, 10000)
|
|
103
|
+
} else window.webview.loadURL(origin + '/')
|
|
104
|
+
return window
|
|
105
|
+
} catch (error) {
|
|
106
|
+
clearDeadline()
|
|
107
|
+
options.grant.revoke()
|
|
108
|
+
try {
|
|
109
|
+
window?.close()
|
|
110
|
+
} catch {
|
|
111
|
+
/* Preserve the setup error. */
|
|
112
|
+
}
|
|
113
|
+
throw error
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ServiceError, type createServiceRegistry } from '../app/service-registry'
|
|
2
|
+
import type { Sidecar } from './sidecar'
|
|
3
|
+
|
|
4
|
+
const MAX_ARGUMENT_KEYS = 64
|
|
5
|
+
|
|
6
|
+
/** Accept a web caller's arguments: absent, null, or a plain object. */
|
|
7
|
+
export function parseSidecarArgs(value: unknown): Record<string, unknown> {
|
|
8
|
+
if (value === undefined || value === null) return {}
|
|
9
|
+
if (typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid input')
|
|
10
|
+
const prototype = Object.getPrototypeOf(value)
|
|
11
|
+
if (prototype !== Object.prototype && prototype !== null) throw new Error('Invalid input')
|
|
12
|
+
if (Object.keys(value).length > MAX_ARGUMENT_KEYS) throw new Error('Invalid input')
|
|
13
|
+
return value as Record<string, unknown>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Register sidecar commands as framework services so the web side calls them
|
|
18
|
+
* through the desktop client. A service named `${prefix}${command}` forwards its
|
|
19
|
+
* arguments to the sidecar command and returns the reply value. A sidecar
|
|
20
|
+
* failure becomes a `ServiceError` whose code is the failure reason
|
|
21
|
+
* (`command_failed`, `timeout`, `exited`, ...) and whose message is readable.
|
|
22
|
+
*/
|
|
23
|
+
export function registerSidecarServices<Principal>(options: {
|
|
24
|
+
services: ReturnType<typeof createServiceRegistry<Principal>>
|
|
25
|
+
sidecar: Pick<Sidecar, 'call'>
|
|
26
|
+
commands: readonly string[]
|
|
27
|
+
authorize(principal: Principal, command: string): boolean | Promise<boolean>
|
|
28
|
+
/** Prepended to each command to form its service name. Default none. */
|
|
29
|
+
prefix?: string
|
|
30
|
+
/** Replaces the default plain-object argument check. */
|
|
31
|
+
parse?(command: string, value: unknown): Record<string, unknown>
|
|
32
|
+
/** Invoke body limit for each service; see `ServiceDefinition.maxBodyBytes`. */
|
|
33
|
+
maxBodyBytes?: number
|
|
34
|
+
}): () => void {
|
|
35
|
+
const { services, sidecar, commands, authorize } = options
|
|
36
|
+
const prefix = options.prefix ?? ''
|
|
37
|
+
const parse = options.parse ?? ((_command: string, value: unknown) => parseSidecarArgs(value))
|
|
38
|
+
if (
|
|
39
|
+
!services ||
|
|
40
|
+
typeof sidecar?.call !== 'function' ||
|
|
41
|
+
typeof authorize !== 'function' ||
|
|
42
|
+
typeof parse !== 'function' ||
|
|
43
|
+
typeof prefix !== 'string' ||
|
|
44
|
+
!Array.isArray(commands) ||
|
|
45
|
+
new Set(commands).size !== commands.length
|
|
46
|
+
)
|
|
47
|
+
throw new Error('Invalid sidecar service configuration')
|
|
48
|
+
const unregister: (() => void)[] = []
|
|
49
|
+
const remove = () => {
|
|
50
|
+
for (const fn of unregister.splice(0)) fn()
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
for (const command of commands)
|
|
54
|
+
unregister.push(
|
|
55
|
+
services.register(prefix + command, {
|
|
56
|
+
parse: (value) => parse(command, value),
|
|
57
|
+
authorize: (principal) => authorize(principal, command),
|
|
58
|
+
async run(_principal, args) {
|
|
59
|
+
const reply = await sidecar.call(command, args)
|
|
60
|
+
if (reply.ok) return reply.value
|
|
61
|
+
throw new ServiceError(reply.reason, reply.error)
|
|
62
|
+
},
|
|
63
|
+
...(options.maxBodyBytes === undefined ? {} : { maxBodyBytes: options.maxBodyBytes }),
|
|
64
|
+
})
|
|
65
|
+
)
|
|
66
|
+
} catch (error) {
|
|
67
|
+
remove()
|
|
68
|
+
throw error
|
|
69
|
+
}
|
|
70
|
+
return remove
|
|
71
|
+
}
|