@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,437 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountMenu,
|
|
3
|
+
createAppMenuItems,
|
|
4
|
+
type AccountMenuItem,
|
|
5
|
+
} from '@adea-ai/ui/components/composites/account-menu'
|
|
6
|
+
import type { UpdateAdapter, UpdateState } from '@adea-ai/ui/components/composites/update-dialog'
|
|
7
|
+
import { ThemeProvider, type ThemeProviderProps } from '@adea-ai/ui/components/theme/lazy'
|
|
8
|
+
import { Palette } from 'lucide-solid'
|
|
9
|
+
import {
|
|
10
|
+
createEffect,
|
|
11
|
+
createMemo,
|
|
12
|
+
createSignal,
|
|
13
|
+
lazy,
|
|
14
|
+
on,
|
|
15
|
+
onCleanup,
|
|
16
|
+
onMount,
|
|
17
|
+
Show,
|
|
18
|
+
Suspense,
|
|
19
|
+
type JSX,
|
|
20
|
+
} from 'solid-js'
|
|
21
|
+
import type { HelpLink, HelpShortcut } from './help-shortcuts'
|
|
22
|
+
import {
|
|
23
|
+
defineSettingsSections,
|
|
24
|
+
settingsSectionFromHash,
|
|
25
|
+
type ApplicationSettingsSection,
|
|
26
|
+
} from './settings-sections'
|
|
27
|
+
import { resolveShortcutPlatform, type ShortcutPlatform } from './shortcut-platform'
|
|
28
|
+
import { browserUpdateAdapter, type UpdateChannelSource } from '../updates/update-adapter'
|
|
29
|
+
|
|
30
|
+
export * from './shortcut-platform'
|
|
31
|
+
|
|
32
|
+
const AppearancePanel = lazy(() =>
|
|
33
|
+
import('@adea-ai/ui/components/theme').then((module) => ({ default: module.AppearancePanel }))
|
|
34
|
+
)
|
|
35
|
+
const ApplicationAppearance = lazy(() =>
|
|
36
|
+
import('../views/app-appearance').then((module) => ({ default: module.ApplicationAppearance }))
|
|
37
|
+
)
|
|
38
|
+
const ApplicationAbout = lazy(() =>
|
|
39
|
+
import('../views/app-about').then((module) => ({ default: module.ApplicationAbout }))
|
|
40
|
+
)
|
|
41
|
+
const ApplicationSettings = lazy(() =>
|
|
42
|
+
import('../views/app-settings').then((module) => ({ default: module.ApplicationSettings }))
|
|
43
|
+
)
|
|
44
|
+
const ApplicationHelp = lazy(() =>
|
|
45
|
+
import('../views/app-help').then((module) => ({ default: module.ApplicationHelp }))
|
|
46
|
+
)
|
|
47
|
+
const UpdateSurface = lazy(() =>
|
|
48
|
+
import('../views/update-surface').then((module) => ({ default: module.ApplicationUpdateSurface }))
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
export type ApplicationIdentity = Readonly<{
|
|
52
|
+
name: string
|
|
53
|
+
icon: string
|
|
54
|
+
version?: string
|
|
55
|
+
/** The platform label About shows, e.g. `macOS`, `desktop` or `web`. */
|
|
56
|
+
platform: string
|
|
57
|
+
/**
|
|
58
|
+
* Which modifier shortcut hints draw. Defaults to `mac` when `platform` names an
|
|
59
|
+
* Apple OS and to the browser's platform otherwise, so a `desktop` or `web` label
|
|
60
|
+
* never advertises Ctrl on a Mac.
|
|
61
|
+
*/
|
|
62
|
+
shortcutPlatform?: ShortcutPlatform
|
|
63
|
+
copyright: string
|
|
64
|
+
sourceUrl: string
|
|
65
|
+
}>
|
|
66
|
+
|
|
67
|
+
/** Theme selection and persistence are supplied by the shared design system. */
|
|
68
|
+
export function ApplicationThemeProvider(props: ThemeProviderProps & { storageKey: string }) {
|
|
69
|
+
return <ThemeProvider {...props}>{props.children}</ThemeProvider>
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Opens the shared application surfaces, for native menus and app-owned triggers. */
|
|
73
|
+
export type ApplicationCommands = Readonly<{
|
|
74
|
+
openSettings(section?: string): void
|
|
75
|
+
openAppearance(): void
|
|
76
|
+
openAbout(): void
|
|
77
|
+
openHelp(): void
|
|
78
|
+
openUpdates(): void
|
|
79
|
+
}>
|
|
80
|
+
|
|
81
|
+
/** Where the framework's Appearance section sits in the shared settings dialog. */
|
|
82
|
+
export type ApplicationSettingsAppearance = Readonly<{
|
|
83
|
+
/** `start` (default), `end`, or an index among the app's sections. */
|
|
84
|
+
position?: 'start' | 'end' | number
|
|
85
|
+
/** The navigation group; defaults to `Application`. */
|
|
86
|
+
group?: string
|
|
87
|
+
label?: string
|
|
88
|
+
}>
|
|
89
|
+
|
|
90
|
+
export type ApplicationSettingsConfig = Readonly<{
|
|
91
|
+
/** App-owned sections, listed after the framework's Appearance section by default. */
|
|
92
|
+
sections: readonly ApplicationSettingsSection[]
|
|
93
|
+
title?: string
|
|
94
|
+
/**
|
|
95
|
+
* Include the framework Appearance section (the default), place it, or pass `false`
|
|
96
|
+
* for apps that present appearance inside their own sections.
|
|
97
|
+
*/
|
|
98
|
+
appearance?: boolean | ApplicationSettingsAppearance
|
|
99
|
+
/** The section opened when none is named (Settings item, chord, bare `#settings`). */
|
|
100
|
+
defaultSection?: string
|
|
101
|
+
/** Controlled open state. Supply `onOpenChange` to observe requests. */
|
|
102
|
+
open?: boolean
|
|
103
|
+
/** Controlled selected section. Supply `onSectionChange` to observe requests. */
|
|
104
|
+
section?: string
|
|
105
|
+
onOpenChange?(open: boolean): void
|
|
106
|
+
onSectionChange?(id: string): void
|
|
107
|
+
}>
|
|
108
|
+
|
|
109
|
+
export type ApplicationHelpConfig = Readonly<{
|
|
110
|
+
links: readonly HelpLink[]
|
|
111
|
+
/** App-specific shortcuts, listed before the ones the framework binds. */
|
|
112
|
+
shortcuts?: readonly HelpShortcut[]
|
|
113
|
+
/** Whether the host binds the framework search chord. */
|
|
114
|
+
search?: boolean
|
|
115
|
+
}>
|
|
116
|
+
|
|
117
|
+
export type ApplicationAccountMenuConfig = Readonly<{
|
|
118
|
+
/** The trigger's accessible name; defaults to `Application settings`. */
|
|
119
|
+
label?: string
|
|
120
|
+
/** Disable the session row while a sign-in or sign-out is in flight. */
|
|
121
|
+
busy?: boolean
|
|
122
|
+
/** Fires on hover or focus of the trigger, e.g. to prefetch. */
|
|
123
|
+
onIntent?(): void
|
|
124
|
+
/** A chord drawn on the Settings row, e.g. `settingsShortcutLabel('mac')`. */
|
|
125
|
+
settingsShortcut?: string
|
|
126
|
+
/** The parseable chord behind `settingsShortcut`; defaults to `Meta+, Control+,`. */
|
|
127
|
+
settingsKeyshortcuts?: string
|
|
128
|
+
/** Show the Appearance item (the default). Apps with their own control can hide it. */
|
|
129
|
+
appearance?: boolean
|
|
130
|
+
/**
|
|
131
|
+
* `updater` (default) shows Updates on desktop, enabled only with an updater.
|
|
132
|
+
* `always` shows it on every runtime and keeps it enabled: without an updater or
|
|
133
|
+
* `onUpdates` it opens the dialog's desktop-only explanation.
|
|
134
|
+
*/
|
|
135
|
+
updates?: 'updater' | 'always'
|
|
136
|
+
}>
|
|
137
|
+
|
|
138
|
+
export type ApplicationUtilitiesProps = {
|
|
139
|
+
identity: ApplicationIdentity
|
|
140
|
+
runtime: 'desktop' | 'web'
|
|
141
|
+
updater?: UpdateAdapter
|
|
142
|
+
/** Release-channel persistence: `read`/`persist`, or a service with `channel`/`setChannel`. */
|
|
143
|
+
channel?: UpdateChannelSource
|
|
144
|
+
/** Receives every updater snapshot the updates dialog sees, for a pending-update badge. */
|
|
145
|
+
onUpdateState?(state: UpdateState): void
|
|
146
|
+
openExternal?(url: string): Promise<void>
|
|
147
|
+
copyVersionInfo?(text: string): Promise<void>
|
|
148
|
+
onSettings?(opener: HTMLButtonElement | undefined): void
|
|
149
|
+
onHelp?(opener: HTMLButtonElement | undefined): void
|
|
150
|
+
onFeedback?(opener: HTMLButtonElement | undefined): void
|
|
151
|
+
/** Replaces the shared updates dialog with an app-owned surface. */
|
|
152
|
+
onUpdates?(opener: HTMLButtonElement | undefined): void
|
|
153
|
+
primaryItem?: AccountMenuItem
|
|
154
|
+
appearance?: JSX.Element
|
|
155
|
+
authenticated?: boolean
|
|
156
|
+
showSession?: boolean
|
|
157
|
+
onSignIn?(): void
|
|
158
|
+
onSignOut?(): void
|
|
159
|
+
updateAvailable?: boolean
|
|
160
|
+
/** Account menu label, busy state, prefetch hook and item visibility. */
|
|
161
|
+
accountMenu?: ApplicationAccountMenuConfig
|
|
162
|
+
/** Supplies the shared settings dialog; Settings, the settings chord and `#settings/<id>` open it. */
|
|
163
|
+
settings?: ApplicationSettingsConfig
|
|
164
|
+
/** Supplies the shared Help Center, opened from the account menu's Help item. */
|
|
165
|
+
help?: ApplicationHelpConfig
|
|
166
|
+
/** Receives commands that open the shared surfaces. */
|
|
167
|
+
commands?(commands: ApplicationCommands): void
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const appearanceSectionId = 'appearance'
|
|
171
|
+
const settingsKeyshortcuts = 'Meta+, Control+,'
|
|
172
|
+
|
|
173
|
+
function isSettingsChord(event: KeyboardEvent) {
|
|
174
|
+
return (
|
|
175
|
+
!event.defaultPrevented &&
|
|
176
|
+
(event.metaKey || event.ctrlKey) &&
|
|
177
|
+
!event.altKey &&
|
|
178
|
+
!event.shiftKey &&
|
|
179
|
+
event.key === ','
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function placeAppearance(
|
|
184
|
+
sections: readonly ApplicationSettingsSection[],
|
|
185
|
+
appearance: ApplicationSettingsSection,
|
|
186
|
+
position: ApplicationSettingsAppearance['position']
|
|
187
|
+
) {
|
|
188
|
+
const index =
|
|
189
|
+
position === 'end'
|
|
190
|
+
? sections.length
|
|
191
|
+
: typeof position === 'number'
|
|
192
|
+
? Math.max(0, Math.min(sections.length, Math.trunc(position)))
|
|
193
|
+
: 0
|
|
194
|
+
return [...sections.slice(0, index), appearance, ...sections.slice(index)]
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Shared account menu and application dialogs. Mount inside ApplicationThemeProvider. */
|
|
198
|
+
export function ApplicationUtilities(props: ApplicationUtilitiesProps) {
|
|
199
|
+
type Surface = 'appearance' | 'about' | 'updates' | 'settings' | 'help'
|
|
200
|
+
const [dialog, setDialog] = createSignal<Surface>()
|
|
201
|
+
const [mounted, setMounted] = createSignal<ReadonlySet<Surface>>(new Set())
|
|
202
|
+
const [localSection, setLocalSection] = createSignal<string>()
|
|
203
|
+
let opener: HTMLElement | undefined
|
|
204
|
+
const appearanceOption = () => props.settings?.appearance ?? true
|
|
205
|
+
const settingsSections = createMemo(() => {
|
|
206
|
+
const settings = props.settings
|
|
207
|
+
if (!settings) return undefined
|
|
208
|
+
const option = appearanceOption()
|
|
209
|
+
if (option === false) return defineSettingsSections(settings.sections)
|
|
210
|
+
const placement = option === true ? {} : option
|
|
211
|
+
return defineSettingsSections(
|
|
212
|
+
placeAppearance(
|
|
213
|
+
settings.sections,
|
|
214
|
+
{
|
|
215
|
+
id: appearanceSectionId,
|
|
216
|
+
label: placement.label ?? 'Appearance',
|
|
217
|
+
group: placement.group ?? 'Application',
|
|
218
|
+
icon: <Palette aria-hidden="true" />,
|
|
219
|
+
render: () => props.appearance ?? <AppearancePanel />,
|
|
220
|
+
},
|
|
221
|
+
placement.position
|
|
222
|
+
)
|
|
223
|
+
)
|
|
224
|
+
})
|
|
225
|
+
const hasAppearanceSection = () => Boolean(props.settings) && appearanceOption() !== false
|
|
226
|
+
const knownSection = (id: string | undefined) =>
|
|
227
|
+
id !== undefined && Boolean(settingsSections()?.some((item) => item.id === id))
|
|
228
|
+
const defaultSection = () => {
|
|
229
|
+
const preferred = props.settings?.defaultSection
|
|
230
|
+
return knownSection(preferred) ? preferred! : settingsSections()?.[0]?.id
|
|
231
|
+
}
|
|
232
|
+
const section = () => {
|
|
233
|
+
const controlled = props.settings?.section
|
|
234
|
+
if (controlled !== undefined) return controlled
|
|
235
|
+
return localSection() ?? defaultSection() ?? ''
|
|
236
|
+
}
|
|
237
|
+
const selectSection = (id: string) => {
|
|
238
|
+
const changed = id !== section()
|
|
239
|
+
setLocalSection(id)
|
|
240
|
+
if (changed) props.settings?.onSectionChange?.(id)
|
|
241
|
+
}
|
|
242
|
+
const settingsOpen = () =>
|
|
243
|
+
props.settings?.open !== undefined ? props.settings.open : dialog() === 'settings'
|
|
244
|
+
const updatesAlways = () => props.accountMenu?.updates === 'always'
|
|
245
|
+
const updateAdapter = createMemo(
|
|
246
|
+
() => props.updater ?? browserUpdateAdapter(props.identity.version)
|
|
247
|
+
)
|
|
248
|
+
const markMounted = (value: Surface) => {
|
|
249
|
+
if (!mounted().has(value)) setMounted((current) => new Set(current).add(value))
|
|
250
|
+
}
|
|
251
|
+
const show = (value: Surface | undefined) => {
|
|
252
|
+
const wasOpen = settingsOpen()
|
|
253
|
+
if (value) markMounted(value)
|
|
254
|
+
setDialog(value)
|
|
255
|
+
const isOpen = value === 'settings'
|
|
256
|
+
if (wasOpen !== isOpen) props.settings?.onOpenChange?.(isOpen)
|
|
257
|
+
}
|
|
258
|
+
const open = (value: Surface, target?: HTMLElement) => {
|
|
259
|
+
if (value === 'updates' && !props.updater && !updatesAlways()) return
|
|
260
|
+
if (value === 'help' && !props.help) return
|
|
261
|
+
opener = target ?? (document.activeElement as HTMLElement | null) ?? undefined
|
|
262
|
+
show(value)
|
|
263
|
+
}
|
|
264
|
+
const openSettings = (id?: string, target?: HTMLElement) => {
|
|
265
|
+
if (!settingsSections()) {
|
|
266
|
+
open('appearance', target)
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
selectSection(knownSection(id) ? id! : defaultSection()!)
|
|
270
|
+
open('settings', target)
|
|
271
|
+
}
|
|
272
|
+
const openAppearance = (target?: HTMLElement) => {
|
|
273
|
+
if (hasAppearanceSection()) openSettings(appearanceSectionId, target)
|
|
274
|
+
else open('appearance', target)
|
|
275
|
+
}
|
|
276
|
+
const openUpdates = (target?: HTMLButtonElement) => {
|
|
277
|
+
if (props.onUpdates) props.onUpdates(target)
|
|
278
|
+
else open('updates', target)
|
|
279
|
+
}
|
|
280
|
+
// A controlled open from the app's own store mounts the dialog it opens.
|
|
281
|
+
createEffect(
|
|
282
|
+
on(
|
|
283
|
+
() => props.settings?.open,
|
|
284
|
+
(value) => {
|
|
285
|
+
if (value === false && dialog() === 'settings') setDialog(undefined)
|
|
286
|
+
if (!value || !settingsSections()) return
|
|
287
|
+
if (!opener) opener = (document.activeElement as HTMLElement | null) ?? undefined
|
|
288
|
+
markMounted('settings')
|
|
289
|
+
if (dialog() !== 'settings') setDialog('settings')
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
)
|
|
293
|
+
props.commands?.(
|
|
294
|
+
Object.freeze({
|
|
295
|
+
openSettings: (id?: string) => openSettings(id),
|
|
296
|
+
openAppearance: () => openAppearance(),
|
|
297
|
+
openAbout: () => open('about'),
|
|
298
|
+
openHelp: () => open('help'),
|
|
299
|
+
openUpdates: () => openUpdates(),
|
|
300
|
+
})
|
|
301
|
+
)
|
|
302
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
303
|
+
if (!props.settings || !isSettingsChord(event)) return
|
|
304
|
+
event.preventDefault()
|
|
305
|
+
openSettings()
|
|
306
|
+
}
|
|
307
|
+
const onHash = () => {
|
|
308
|
+
const sections = settingsSections()
|
|
309
|
+
if (!sections) return
|
|
310
|
+
const id = settingsSectionFromHash(window.location.hash, sections, defaultSection())
|
|
311
|
+
if (id) openSettings(id)
|
|
312
|
+
}
|
|
313
|
+
onMount(() => {
|
|
314
|
+
onHash()
|
|
315
|
+
window.addEventListener('keydown', onKeyDown, { capture: true })
|
|
316
|
+
window.addEventListener('hashchange', onHash)
|
|
317
|
+
onCleanup(() => {
|
|
318
|
+
window.removeEventListener('keydown', onKeyDown, { capture: true })
|
|
319
|
+
window.removeEventListener('hashchange', onHash)
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
const close = () => show(undefined)
|
|
323
|
+
const items = (): AccountMenuItem[] => {
|
|
324
|
+
const menu = props.accountMenu
|
|
325
|
+
const shared = createAppMenuItems({
|
|
326
|
+
primaryItem: props.primaryItem,
|
|
327
|
+
settingsShortcut: menu?.settingsShortcut,
|
|
328
|
+
onAbout: (target) => open('about', target),
|
|
329
|
+
onUpdates:
|
|
330
|
+
props.updater || props.onUpdates || updatesAlways()
|
|
331
|
+
? (target) => openUpdates(target)
|
|
332
|
+
: undefined,
|
|
333
|
+
onSettings:
|
|
334
|
+
props.onSettings ??
|
|
335
|
+
(props.settings ? (target) => openSettings(undefined, target) : undefined),
|
|
336
|
+
onHelp: props.onHelp ?? (props.help ? (target) => open('help', target) : undefined),
|
|
337
|
+
onFeedback: props.onFeedback,
|
|
338
|
+
}).map((item) => {
|
|
339
|
+
if (item.id === 'settings' && item.shortcut)
|
|
340
|
+
return { ...item, keyshortcuts: menu?.settingsKeyshortcuts ?? settingsKeyshortcuts }
|
|
341
|
+
if (item.id === 'updates' && updatesAlways()) return { ...item, platform: undefined }
|
|
342
|
+
return item
|
|
343
|
+
})
|
|
344
|
+
if (menu?.appearance === false) return shared
|
|
345
|
+
return [
|
|
346
|
+
{
|
|
347
|
+
id: 'appearance',
|
|
348
|
+
label: 'Appearance',
|
|
349
|
+
icon: <Palette aria-hidden="true" />,
|
|
350
|
+
onSelectAfterClose: (target: HTMLButtonElement | undefined) => open('appearance', target),
|
|
351
|
+
},
|
|
352
|
+
...shared,
|
|
353
|
+
]
|
|
354
|
+
}
|
|
355
|
+
return (
|
|
356
|
+
<>
|
|
357
|
+
<AccountMenu
|
|
358
|
+
items={items()}
|
|
359
|
+
platform={props.runtime}
|
|
360
|
+
authenticated={props.authenticated ?? false}
|
|
361
|
+
showSession={props.showSession ?? false}
|
|
362
|
+
busy={props.accountMenu?.busy}
|
|
363
|
+
onIntent={() => props.accountMenu?.onIntent?.()}
|
|
364
|
+
onSignIn={props.onSignIn}
|
|
365
|
+
onSignOut={props.onSignOut}
|
|
366
|
+
updateAvailable={props.updateAvailable}
|
|
367
|
+
label={props.accountMenu?.label ?? 'Application settings'}
|
|
368
|
+
railTrigger
|
|
369
|
+
placement="right-end"
|
|
370
|
+
gutter={4}
|
|
371
|
+
hideArrow
|
|
372
|
+
/>
|
|
373
|
+
<Suspense fallback={dialog() ? <span role="status">Loading…</span> : null}>
|
|
374
|
+
<Show when={mounted().has('appearance')}>
|
|
375
|
+
<ApplicationAppearance
|
|
376
|
+
open={dialog() === 'appearance'}
|
|
377
|
+
onClose={close}
|
|
378
|
+
panel={props.appearance}
|
|
379
|
+
restoreFocusRef={() => opener}
|
|
380
|
+
/>
|
|
381
|
+
</Show>
|
|
382
|
+
<Show when={mounted().has('settings') && settingsSections()}>
|
|
383
|
+
{(sections) => (
|
|
384
|
+
<ApplicationSettings
|
|
385
|
+
open={settingsOpen()}
|
|
386
|
+
onClose={close}
|
|
387
|
+
sections={sections()}
|
|
388
|
+
section={section()}
|
|
389
|
+
onSectionChange={selectSection}
|
|
390
|
+
title={props.settings?.title}
|
|
391
|
+
restoreFocusRef={() => opener}
|
|
392
|
+
/>
|
|
393
|
+
)}
|
|
394
|
+
</Show>
|
|
395
|
+
<Show when={mounted().has('help') && props.help}>
|
|
396
|
+
{(help) => (
|
|
397
|
+
<ApplicationHelp
|
|
398
|
+
open={dialog() === 'help'}
|
|
399
|
+
onClose={close}
|
|
400
|
+
appName={props.identity.name}
|
|
401
|
+
shortcuts={help().shortcuts ?? []}
|
|
402
|
+
standard={{
|
|
403
|
+
search: help().search,
|
|
404
|
+
settings: Boolean(props.settings),
|
|
405
|
+
shortcutPlatform: resolveShortcutPlatform(props.identity),
|
|
406
|
+
}}
|
|
407
|
+
links={help().links}
|
|
408
|
+
openExternal={props.openExternal}
|
|
409
|
+
restoreFocusRef={() => opener}
|
|
410
|
+
/>
|
|
411
|
+
)}
|
|
412
|
+
</Show>
|
|
413
|
+
<Show when={mounted().has('about')}>
|
|
414
|
+
<ApplicationAbout
|
|
415
|
+
identity={props.identity}
|
|
416
|
+
copyVersionInfo={props.copyVersionInfo}
|
|
417
|
+
openExternal={props.openExternal}
|
|
418
|
+
open={dialog() === 'about'}
|
|
419
|
+
onClose={close}
|
|
420
|
+
restoreFocusRef={() => opener}
|
|
421
|
+
/>
|
|
422
|
+
</Show>
|
|
423
|
+
<Show when={mounted().has('updates') && (props.updater || updatesAlways())}>
|
|
424
|
+
<UpdateSurface
|
|
425
|
+
adapter={updateAdapter()}
|
|
426
|
+
identity={props.identity}
|
|
427
|
+
channel={props.updater ? props.channel : undefined}
|
|
428
|
+
onUpdateState={props.onUpdateState}
|
|
429
|
+
open={dialog() === 'updates'}
|
|
430
|
+
onClose={close}
|
|
431
|
+
restoreFocusRef={() => opener}
|
|
432
|
+
/>
|
|
433
|
+
</Show>
|
|
434
|
+
</Suspense>
|
|
435
|
+
</>
|
|
436
|
+
)
|
|
437
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Shared surfaces a native menu can open in the window. */
|
|
2
|
+
export const applicationMenuCommands = ['about', 'settings', 'help', 'updates'] as const
|
|
3
|
+
export type ApplicationMenuCommand = (typeof applicationMenuCommands)[number]
|
|
4
|
+
|
|
5
|
+
/** The stream the window opens to receive menu commands. */
|
|
6
|
+
export const applicationCommandStream = 'shell.commands'
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import type { createDesktopStreams } from '../desktop/desktop-stream'
|
|
2
|
+
import { containsAsciiControl } from '../desktop/string-policy'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
applicationCommandStream,
|
|
6
|
+
applicationMenuCommands,
|
|
7
|
+
type ApplicationMenuCommand,
|
|
8
|
+
} from './application-menu-commands'
|
|
9
|
+
|
|
10
|
+
export * from './application-menu-commands'
|
|
11
|
+
|
|
12
|
+
/** The subset of Electrobun's application menu item configuration the framework emits. */
|
|
13
|
+
export type ApplicationMenuItem =
|
|
14
|
+
| { type: 'separator' }
|
|
15
|
+
| {
|
|
16
|
+
label?: string
|
|
17
|
+
role?: string
|
|
18
|
+
action?: string
|
|
19
|
+
accelerator?: string
|
|
20
|
+
enabled?: boolean
|
|
21
|
+
submenu?: ApplicationMenuItem[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type ApplicationMenuLink = Readonly<{ label: string; url: string }>
|
|
25
|
+
|
|
26
|
+
/** An app-owned top-level menu; its actions are delivered to `onAction`. */
|
|
27
|
+
export type ApplicationMenuSection = Readonly<{
|
|
28
|
+
label: string
|
|
29
|
+
items: readonly ApplicationMenuItem[]
|
|
30
|
+
}>
|
|
31
|
+
|
|
32
|
+
export type ApplicationMenuOptions = Readonly<{
|
|
33
|
+
name: string
|
|
34
|
+
platform: string
|
|
35
|
+
/** Adds Check for Updates to the application menu. */
|
|
36
|
+
updates?: boolean
|
|
37
|
+
/** Adds Settings… with the platform settings accelerator. */
|
|
38
|
+
settings?: boolean
|
|
39
|
+
/** Help menu links opened in the system browser. */
|
|
40
|
+
helpLinks?: readonly ApplicationMenuLink[]
|
|
41
|
+
/** App menus placed between View and Window. */
|
|
42
|
+
sections?: readonly ApplicationMenuSection[]
|
|
43
|
+
}>
|
|
44
|
+
|
|
45
|
+
const prefix = 'app-framework:'
|
|
46
|
+
const linkPrefix = `${prefix}link:`
|
|
47
|
+
const appAction = /^[a-z][a-z0-9]*(?:[.:-][a-z0-9]+)*$/
|
|
48
|
+
const separator = { type: 'separator' } as const
|
|
49
|
+
|
|
50
|
+
function label(value: string) {
|
|
51
|
+
return (
|
|
52
|
+
typeof value === 'string' && value.trim() && value.length <= 100 && !containsAsciiControl(value)
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function validateItems(items: readonly ApplicationMenuItem[], depth = 0): ApplicationMenuItem[] {
|
|
57
|
+
if (!Array.isArray(items) || items.length > 64 || depth > 2) throw new Error('Invalid menu items')
|
|
58
|
+
return items.map((item) => {
|
|
59
|
+
if ('type' in item) return separator
|
|
60
|
+
if (
|
|
61
|
+
(item.label !== undefined && !label(item.label)) ||
|
|
62
|
+
(item.action !== undefined &&
|
|
63
|
+
(!appAction.test(item.action) || item.action.startsWith(prefix))) ||
|
|
64
|
+
(item.role !== undefined && !/^[a-zA-Z]+$/.test(item.role)) ||
|
|
65
|
+
(item.action === undefined && item.role === undefined && item.submenu === undefined) ||
|
|
66
|
+
(item.label === undefined && item.role === undefined)
|
|
67
|
+
)
|
|
68
|
+
throw new Error('Invalid menu item')
|
|
69
|
+
return {
|
|
70
|
+
...item,
|
|
71
|
+
...(item.submenu ? { submenu: validateItems(item.submenu, depth + 1) } : {}),
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function validLink(link: ApplicationMenuLink) {
|
|
77
|
+
if (!label(link.label)) return false
|
|
78
|
+
try {
|
|
79
|
+
const url = new URL(link.url)
|
|
80
|
+
return url.protocol === 'https:' && url.username === '' && url.password === ''
|
|
81
|
+
} catch {
|
|
82
|
+
return false
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Build the standard native menu: application, Edit, View, app sections, Window and Help.
|
|
88
|
+
* Electrobun implements application menus on macOS and Windows; Linux apps keep the same
|
|
89
|
+
* surfaces in the window's account menu.
|
|
90
|
+
*/
|
|
91
|
+
export function createApplicationMenu(options: ApplicationMenuOptions): ApplicationMenuItem[] {
|
|
92
|
+
const links = options.helpLinks ?? []
|
|
93
|
+
if (
|
|
94
|
+
!label(options.name) ||
|
|
95
|
+
!Array.isArray(links) ||
|
|
96
|
+
links.length > 16 ||
|
|
97
|
+
!links.every(validLink) ||
|
|
98
|
+
(options.sections?.length ?? 0) > 8
|
|
99
|
+
)
|
|
100
|
+
throw new Error('Invalid application menu configuration')
|
|
101
|
+
const sections = (options.sections ?? []).map((section) => {
|
|
102
|
+
if (!label(section.label)) throw new Error('Invalid application menu configuration')
|
|
103
|
+
return { label: section.label, submenu: validateItems(section.items) }
|
|
104
|
+
})
|
|
105
|
+
const mac = options.platform === 'darwin'
|
|
106
|
+
const about = { label: `About ${options.name}`, action: `${prefix}about` }
|
|
107
|
+
const settings = options.settings
|
|
108
|
+
? [{ label: mac ? 'Settings…' : 'Settings', action: `${prefix}settings`, accelerator: ',' }]
|
|
109
|
+
: []
|
|
110
|
+
const updates = options.updates
|
|
111
|
+
? [{ label: 'Check for Updates…', action: `${prefix}updates` }]
|
|
112
|
+
: []
|
|
113
|
+
const help: ApplicationMenuItem[] = [
|
|
114
|
+
{ label: `${options.name} Help`, action: `${prefix}help` },
|
|
115
|
+
...(links.length ? [separator] : []),
|
|
116
|
+
...links.map((link, index) => ({ label: link.label, action: `${linkPrefix}${index}` })),
|
|
117
|
+
]
|
|
118
|
+
const edit: ApplicationMenuItem = {
|
|
119
|
+
label: 'Edit',
|
|
120
|
+
submenu: [
|
|
121
|
+
{ role: 'undo' },
|
|
122
|
+
{ role: 'redo' },
|
|
123
|
+
separator,
|
|
124
|
+
{ role: 'cut' },
|
|
125
|
+
{ role: 'copy' },
|
|
126
|
+
{ role: 'paste' },
|
|
127
|
+
...(mac ? [{ role: 'pasteAndMatchStyle' }] : []),
|
|
128
|
+
{ role: 'delete' },
|
|
129
|
+
{ role: 'selectAll' },
|
|
130
|
+
],
|
|
131
|
+
}
|
|
132
|
+
const view: ApplicationMenuItem = { label: 'View', submenu: [{ role: 'toggleFullScreen' }] }
|
|
133
|
+
const window: ApplicationMenuItem = {
|
|
134
|
+
label: 'Window',
|
|
135
|
+
submenu: mac
|
|
136
|
+
? [{ role: 'minimize' }, { role: 'zoom' }, separator, { role: 'bringAllToFront' }]
|
|
137
|
+
: [{ role: 'minimize' }, { role: 'close' }],
|
|
138
|
+
}
|
|
139
|
+
if (mac)
|
|
140
|
+
return [
|
|
141
|
+
{
|
|
142
|
+
label: options.name,
|
|
143
|
+
submenu: [
|
|
144
|
+
about,
|
|
145
|
+
...updates,
|
|
146
|
+
separator,
|
|
147
|
+
...settings,
|
|
148
|
+
...(settings.length ? [separator] : []),
|
|
149
|
+
{ role: 'hide' },
|
|
150
|
+
{ role: 'hideOthers' },
|
|
151
|
+
{ role: 'showAll' },
|
|
152
|
+
separator,
|
|
153
|
+
{ role: 'quit' },
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
edit,
|
|
157
|
+
view,
|
|
158
|
+
...sections,
|
|
159
|
+
window,
|
|
160
|
+
{ label: 'Help', submenu: help },
|
|
161
|
+
]
|
|
162
|
+
return [
|
|
163
|
+
{
|
|
164
|
+
label: 'File',
|
|
165
|
+
submenu: [...settings, ...(settings.length ? [separator] : []), { role: 'quit' }],
|
|
166
|
+
},
|
|
167
|
+
edit,
|
|
168
|
+
view,
|
|
169
|
+
...sections,
|
|
170
|
+
window,
|
|
171
|
+
{ label: 'Help', submenu: [...help, separator, ...updates, about] },
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export type ApplicationMenuDispatch = Readonly<{
|
|
176
|
+
/** Deliver a shared surface command to the window. */
|
|
177
|
+
command(command: ApplicationMenuCommand): void
|
|
178
|
+
openExternal(url: string): unknown
|
|
179
|
+
/** App-owned actions from `sections`. */
|
|
180
|
+
action?(action: string): void
|
|
181
|
+
}>
|
|
182
|
+
|
|
183
|
+
function actionOf(event: unknown): string | undefined {
|
|
184
|
+
if (typeof event !== 'object' || event === null) return undefined
|
|
185
|
+
const data = (event as { data?: unknown }).data
|
|
186
|
+
if (typeof data !== 'object' || data === null) return undefined
|
|
187
|
+
const action = (data as { action?: unknown }).action
|
|
188
|
+
return typeof action === 'string' && action.length <= 200 ? action : undefined
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Route an `application-menu-clicked` event to shared commands, help links or app actions. */
|
|
192
|
+
export function createApplicationMenuHandler(
|
|
193
|
+
options: Pick<ApplicationMenuOptions, 'helpLinks'> & ApplicationMenuDispatch
|
|
194
|
+
) {
|
|
195
|
+
const links = [...(options.helpLinks ?? [])]
|
|
196
|
+
return (event: unknown) => {
|
|
197
|
+
const action = actionOf(event)
|
|
198
|
+
if (action === undefined) return
|
|
199
|
+
if (action.startsWith(linkPrefix)) {
|
|
200
|
+
const index = action.slice(linkPrefix.length)
|
|
201
|
+
const link = /^(?:0|[1-9]\d?)$/.test(index) ? links[Number(index)] : undefined
|
|
202
|
+
if (link && validLink(link)) void options.openExternal(link.url)
|
|
203
|
+
return
|
|
204
|
+
}
|
|
205
|
+
if (action.startsWith(prefix)) {
|
|
206
|
+
const command = action.slice(prefix.length)
|
|
207
|
+
if ((applicationMenuCommands as readonly string[]).includes(command))
|
|
208
|
+
options.command(command as ApplicationMenuCommand)
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
if (appAction.test(action)) options.action?.(action)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Broadcast menu commands to authenticated windows over the desktop stream channel.
|
|
217
|
+
* Commands carry no data beyond their name; the window decides how to present them.
|
|
218
|
+
*/
|
|
219
|
+
export function createApplicationCommandBroadcaster<Principal>(options: {
|
|
220
|
+
authorize(principal: Principal): boolean | Promise<boolean>
|
|
221
|
+
}) {
|
|
222
|
+
const subscribers = new Set<(payload: string) => boolean>()
|
|
223
|
+
return {
|
|
224
|
+
register(streams: ReturnType<typeof createDesktopStreams<Principal>>) {
|
|
225
|
+
streams.register(applicationCommandStream, {
|
|
226
|
+
parse(value) {
|
|
227
|
+
if (value !== null) throw new Error('Invalid input')
|
|
228
|
+
return null
|
|
229
|
+
},
|
|
230
|
+
authorize: (principal) => options.authorize(principal),
|
|
231
|
+
open(_principal, _input, context) {
|
|
232
|
+
const send = (payload: string) => context.current() && context.send(payload)
|
|
233
|
+
subscribers.add(send)
|
|
234
|
+
return {
|
|
235
|
+
receive: () => context.close(),
|
|
236
|
+
close: () => subscribers.delete(send),
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
})
|
|
240
|
+
},
|
|
241
|
+
/** Returns whether at least one window received the command. */
|
|
242
|
+
send(command: ApplicationMenuCommand): boolean {
|
|
243
|
+
if (!(applicationMenuCommands as readonly string[]).includes(command)) return false
|
|
244
|
+
const payload = JSON.stringify({ command })
|
|
245
|
+
let delivered = false
|
|
246
|
+
for (const send of subscribers) delivered = send(payload) || delivered
|
|
247
|
+
return delivered
|
|
248
|
+
},
|
|
249
|
+
}
|
|
250
|
+
}
|