@adea-ai/app-framework 0.0.0-stage → 0.24.1
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 +1009 -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 +127 -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 +306 -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/navigation-drawer.d.ts +12 -0
- package/dist/shell/navigation-drawer.js +42 -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 +374 -4
- package/src/app/application.tsx +138 -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/desktop/client-assets.ts +75 -0
- package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
- package/src/native/electrobun-windows-shortcut-com.patch +923 -0
- package/src/native/renderer-profile.ts +27 -0
- package/src/native/window-options.ts +24 -0
- package/src/shell/app-shell.tsx +294 -0
- package/src/shell/app-utilities.tsx +437 -0
- package/src/shell/help-shortcuts.ts +24 -0
- package/src/shell/navigation-drawer.tsx +36 -0
- package/src/shell/settings-sections.ts +74 -0
- package/src/shell/shortcut-platform.ts +35 -0
- package/src/updates/release-version.ts +57 -0
- package/src/updates/update-adapter.ts +129 -0
- package/src/updates/update-state.ts +34 -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,40 @@
|
|
|
1
|
+
import { discoverSignedRelease } from './update-discovery';
|
|
2
|
+
import { downloadVerifiedRelease } from './update-download';
|
|
3
|
+
import { type ReleaseTrust, type VerifiedRelease } from './signed-release';
|
|
4
|
+
import type { FetchFunction } from './release-location';
|
|
5
|
+
type Phase = 'idle' | 'checking' | 'current' | 'available' | 'downloading' | 'staging' | 'staged' | 'failed';
|
|
6
|
+
type State = Readonly<{
|
|
7
|
+
phase: Phase;
|
|
8
|
+
currentVersion: string;
|
|
9
|
+
availableVersion: string | null;
|
|
10
|
+
error: string | null;
|
|
11
|
+
}>;
|
|
12
|
+
/** Coordinates trusted discovery and download; the platform adapter owns safe application and recovery. */
|
|
13
|
+
export declare function createUpdateManager(options: {
|
|
14
|
+
currentVersion: string;
|
|
15
|
+
trust: ReleaseTrust;
|
|
16
|
+
discoveryName: string;
|
|
17
|
+
directory: string;
|
|
18
|
+
maxBytes: number;
|
|
19
|
+
stage: (input: {
|
|
20
|
+
descriptor: VerifiedRelease;
|
|
21
|
+
path: string;
|
|
22
|
+
directory: string;
|
|
23
|
+
}) => Promise<void>;
|
|
24
|
+
discover?: typeof discoverSignedRelease;
|
|
25
|
+
download?: typeof downloadVerifiedRelease;
|
|
26
|
+
fetch?: FetchFunction;
|
|
27
|
+
}): {
|
|
28
|
+
status: () => Readonly<{
|
|
29
|
+
phase: Phase;
|
|
30
|
+
currentVersion: string;
|
|
31
|
+
availableVersion: string | null;
|
|
32
|
+
error: string | null;
|
|
33
|
+
}>;
|
|
34
|
+
check(): Promise<State>;
|
|
35
|
+
install(input: {
|
|
36
|
+
approved: boolean;
|
|
37
|
+
expectedVersion: string;
|
|
38
|
+
}): Promise<State>;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isVerifiedReleaseForTrust } from "./signed-release.js";
|
|
2
|
+
import { versionLessThan } from "./release-version.js";
|
|
3
|
+
import { discoverSignedRelease } from "./update-discovery.js";
|
|
4
|
+
import { downloadVerifiedRelease } from "./update-download.js";
|
|
5
|
+
// src/updates/update-manager.ts
|
|
6
|
+
/** Coordinates trusted discovery and download; the platform adapter owns safe application and recovery. */
|
|
7
|
+
function createUpdateManager(options) {
|
|
8
|
+
if (!/^\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(options.currentVersion) || options.currentVersion.length > 64 || !Number.isSafeInteger(options.maxBytes) || options.maxBytes < 1 || typeof options.stage !== "function") throw new Error("Invalid update manager configuration");
|
|
9
|
+
let state = Object.freeze({
|
|
10
|
+
phase: "idle",
|
|
11
|
+
currentVersion: options.currentVersion,
|
|
12
|
+
availableVersion: null,
|
|
13
|
+
error: null
|
|
14
|
+
});
|
|
15
|
+
let pending, busy = false;
|
|
16
|
+
const set = (phase, version = pending?.version ?? null, error = null) => state = Object.freeze({
|
|
17
|
+
phase,
|
|
18
|
+
currentVersion: options.currentVersion,
|
|
19
|
+
availableVersion: version,
|
|
20
|
+
error
|
|
21
|
+
});
|
|
22
|
+
const acquire = () => {
|
|
23
|
+
if (busy) throw new Error("Update manager is busy");
|
|
24
|
+
busy = true;
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
status: () => state,
|
|
28
|
+
async check() {
|
|
29
|
+
acquire();
|
|
30
|
+
if (state.phase === "staged") {
|
|
31
|
+
busy = false;
|
|
32
|
+
throw new Error("An update is already staged");
|
|
33
|
+
}
|
|
34
|
+
pending = void 0;
|
|
35
|
+
set("checking", null);
|
|
36
|
+
try {
|
|
37
|
+
const descriptor = await (options.discover ?? discoverSignedRelease)({
|
|
38
|
+
trust: options.trust,
|
|
39
|
+
discoveryName: options.discoveryName,
|
|
40
|
+
fetch: options.fetch
|
|
41
|
+
});
|
|
42
|
+
if (!isVerifiedReleaseForTrust(descriptor, options.trust)) throw new Error("Untrusted update");
|
|
43
|
+
if (!versionLessThan(options.currentVersion, descriptor.version)) return set("current", null);
|
|
44
|
+
pending = descriptor;
|
|
45
|
+
return set("available");
|
|
46
|
+
} catch {
|
|
47
|
+
pending = void 0;
|
|
48
|
+
return set("failed", null, "Update check failed. Please try again.");
|
|
49
|
+
} finally {
|
|
50
|
+
busy = false;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
async install(input) {
|
|
54
|
+
acquire();
|
|
55
|
+
try {
|
|
56
|
+
if (input.approved !== true || !pending || state.phase !== "available" || input.expectedVersion !== pending.version) throw new Error("Update approval does not match the available version");
|
|
57
|
+
const descriptor = pending;
|
|
58
|
+
set("downloading");
|
|
59
|
+
try {
|
|
60
|
+
const download = await (options.download ?? downloadVerifiedRelease)({
|
|
61
|
+
descriptor,
|
|
62
|
+
directory: options.directory,
|
|
63
|
+
maxBytes: options.maxBytes,
|
|
64
|
+
fetch: options.fetch
|
|
65
|
+
});
|
|
66
|
+
set("staging");
|
|
67
|
+
await options.stage({
|
|
68
|
+
descriptor,
|
|
69
|
+
...download
|
|
70
|
+
});
|
|
71
|
+
pending = void 0;
|
|
72
|
+
return set("staged", descriptor.version);
|
|
73
|
+
} catch {
|
|
74
|
+
pending = void 0;
|
|
75
|
+
return set("failed", null, "Update staging failed. Please try again.");
|
|
76
|
+
}
|
|
77
|
+
} finally {
|
|
78
|
+
busy = false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export { createUpdateManager };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Wait without signalling only processes whose executables were verified. This is not complete app-process discovery. */
|
|
2
|
+
export declare function waitForUpdateProcesses(options: {
|
|
3
|
+
processes: readonly {
|
|
4
|
+
pid: number;
|
|
5
|
+
executable: string;
|
|
6
|
+
}[];
|
|
7
|
+
timeoutMs: number;
|
|
8
|
+
env?: Record<string, string | undefined>;
|
|
9
|
+
onVerified?: () => void;
|
|
10
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { realpath } from "node:fs/promises";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
import { execFile } from "node:child_process";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { FFIType, dlopen, ptr } from "bun:ffi";
|
|
6
|
+
// src/updates/update-process-fence.ts
|
|
7
|
+
var execute = promisify(execFile);
|
|
8
|
+
function isProcessRunning(pid) {
|
|
9
|
+
try {
|
|
10
|
+
process.kill(pid, 0);
|
|
11
|
+
return true;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
if (error.code === "ESRCH") return false;
|
|
14
|
+
throw new Error("Cannot inspect update process", { cause: error });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Wait without signalling only processes whose executables were verified. This is not complete app-process discovery. */
|
|
18
|
+
async function waitForUpdateProcesses(options) {
|
|
19
|
+
if (!Array.isArray(options.processes) || options.processes.length < 1 || options.processes.length > 16 || !Number.isSafeInteger(options.timeoutMs) || options.timeoutMs < 1 || options.timeoutMs > 12e4) throw new Error("Invalid update process fence");
|
|
20
|
+
const seen = /* @__PURE__ */ new Set(), env = {};
|
|
21
|
+
const deadline = Date.now() + options.timeoutMs;
|
|
22
|
+
for (const key of [
|
|
23
|
+
"PATH",
|
|
24
|
+
"SystemRoot",
|
|
25
|
+
"WINDIR",
|
|
26
|
+
"TMP",
|
|
27
|
+
"TEMP",
|
|
28
|
+
"TMPDIR",
|
|
29
|
+
"LANG",
|
|
30
|
+
"LC_ALL"
|
|
31
|
+
]) if ((options.env ?? process.env)[key]) env[key] = (options.env ?? process.env)[key];
|
|
32
|
+
async function executable(pid) {
|
|
33
|
+
if (process.platform === "linux") return realpath(`/proc/${pid}/exe`);
|
|
34
|
+
if (process.platform === "darwin") return realpath((await execute("/bin/ps", [
|
|
35
|
+
"-p",
|
|
36
|
+
String(pid),
|
|
37
|
+
"-o",
|
|
38
|
+
"comm="
|
|
39
|
+
], {
|
|
40
|
+
env,
|
|
41
|
+
timeout: Math.max(1, Math.min(5e3, deadline - Date.now())),
|
|
42
|
+
maxBuffer: 16384
|
|
43
|
+
})).stdout.trim());
|
|
44
|
+
if (process.platform === "win32") {
|
|
45
|
+
const library = dlopen("kernel32.dll", {
|
|
46
|
+
OpenProcess: {
|
|
47
|
+
args: [
|
|
48
|
+
FFIType.u32,
|
|
49
|
+
FFIType.i32,
|
|
50
|
+
FFIType.u32
|
|
51
|
+
],
|
|
52
|
+
returns: FFIType.ptr
|
|
53
|
+
},
|
|
54
|
+
QueryFullProcessImageNameW: {
|
|
55
|
+
args: [
|
|
56
|
+
FFIType.ptr,
|
|
57
|
+
FFIType.u32,
|
|
58
|
+
FFIType.ptr,
|
|
59
|
+
FFIType.ptr
|
|
60
|
+
],
|
|
61
|
+
returns: FFIType.i32
|
|
62
|
+
},
|
|
63
|
+
CloseHandle: {
|
|
64
|
+
args: [FFIType.ptr],
|
|
65
|
+
returns: FFIType.i32
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
const handle = library.symbols.OpenProcess(4096, 0, pid);
|
|
70
|
+
if (!handle) throw new Error("Cannot open update process");
|
|
71
|
+
try {
|
|
72
|
+
const buffer = Buffer.alloc(65536), length = Buffer.alloc(4);
|
|
73
|
+
length.writeUInt32LE(32768);
|
|
74
|
+
if (!library.symbols.QueryFullProcessImageNameW(handle, 0, ptr(buffer), ptr(length))) throw new Error("Cannot inspect update process");
|
|
75
|
+
const count = length.readUInt32LE();
|
|
76
|
+
if (!count || count >= 32768) throw new Error("Invalid update process path");
|
|
77
|
+
return await realpath(buffer.subarray(0, count * 2).toString("utf16le"));
|
|
78
|
+
} finally {
|
|
79
|
+
library.symbols.CloseHandle(handle);
|
|
80
|
+
}
|
|
81
|
+
} finally {
|
|
82
|
+
library.close();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw new Error("Unsupported update process platform");
|
|
86
|
+
}
|
|
87
|
+
const waiting = /* @__PURE__ */ new Set();
|
|
88
|
+
for (const processInfo of options.processes) {
|
|
89
|
+
if (!processInfo || !Number.isSafeInteger(processInfo.pid) || processInfo.pid < 2 || processInfo.pid > 4294967295 || processInfo.pid === process.pid || seen.has(processInfo.pid) || typeof processInfo.executable !== "string" || !isAbsolute(processInfo.executable)) throw new Error("Invalid update process identity");
|
|
90
|
+
if (Date.now() >= deadline) throw new Error("Update process fence timed out");
|
|
91
|
+
seen.add(processInfo.pid);
|
|
92
|
+
if (!isProcessRunning(processInfo.pid)) throw new Error("Update process exited before verification");
|
|
93
|
+
let actual;
|
|
94
|
+
try {
|
|
95
|
+
actual = await executable(processInfo.pid);
|
|
96
|
+
} catch {
|
|
97
|
+
throw new Error("Cannot verify update process");
|
|
98
|
+
}
|
|
99
|
+
const expected = await realpath(processInfo.executable);
|
|
100
|
+
if (process.platform === "win32" ? actual.toLowerCase() !== expected.toLowerCase() : actual !== expected) throw new Error("Update process executable mismatch");
|
|
101
|
+
waiting.add(processInfo.pid);
|
|
102
|
+
}
|
|
103
|
+
if (Date.now() >= deadline) throw new Error("Update process fence timed out");
|
|
104
|
+
for (const pid of waiting) if (!isProcessRunning(pid)) throw new Error("Update process exited before verification");
|
|
105
|
+
const notified = options.onVerified?.();
|
|
106
|
+
if (typeof notified === "object" && notified !== null && "then" in notified) throw new Error("Update process acknowledgement must be synchronous");
|
|
107
|
+
while (waiting.size) {
|
|
108
|
+
for (const pid of waiting) if (!isProcessRunning(pid)) waiting.delete(pid);
|
|
109
|
+
if (!waiting.size) return;
|
|
110
|
+
if (Date.now() >= deadline) throw new Error("Update processes did not exit");
|
|
111
|
+
await Bun.sleep(Math.min(100, Math.max(1, deadline - Date.now())));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export { waitForUpdateProcesses };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type UpdateResumeResult = Readonly<{
|
|
2
|
+
status: 'none' | 'in-progress' | 'not-applied';
|
|
3
|
+
} | {
|
|
4
|
+
status: 'updated';
|
|
5
|
+
version: string;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Call on app start. Reports whether an earlier helper installed an update and
|
|
9
|
+
* removes the staging directory, unless a helper is still running from it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resumeUpdate(options: {
|
|
12
|
+
target: string;
|
|
13
|
+
}): Promise<UpdateResumeResult>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { updateStagingFor } from "./update-swap.js";
|
|
2
|
+
import { lstat, readFile, rm } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
// src/updates/update-resume.ts
|
|
5
|
+
function alive(pid) {
|
|
6
|
+
try {
|
|
7
|
+
process.kill(pid, 0);
|
|
8
|
+
return true;
|
|
9
|
+
} catch (error) {
|
|
10
|
+
return error.code === "EPERM";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Call on app start. Reports whether an earlier helper installed an update and
|
|
15
|
+
* removes the staging directory, unless a helper is still running from it.
|
|
16
|
+
*/
|
|
17
|
+
async function resumeUpdate(options) {
|
|
18
|
+
const staging = updateStagingFor(options.target);
|
|
19
|
+
const info = await lstat(staging).catch(() => void 0);
|
|
20
|
+
if (!info) return { status: "none" };
|
|
21
|
+
if (!info.isDirectory() || info.isSymbolicLink()) throw new Error("Unexpected update staging entry");
|
|
22
|
+
const helper = Number(await readFile(join(staging, "helper-armed"), "utf8").catch(() => 0));
|
|
23
|
+
if (Number.isSafeInteger(helper) && helper > 1 && helper !== process.pid && alive(helper)) return { status: "in-progress" };
|
|
24
|
+
const version = await readFile(join(staging, "updated"), "utf8").catch(() => void 0);
|
|
25
|
+
await rm(staging, {
|
|
26
|
+
recursive: true,
|
|
27
|
+
force: true
|
|
28
|
+
});
|
|
29
|
+
return version ? {
|
|
30
|
+
status: "updated",
|
|
31
|
+
version
|
|
32
|
+
} : { status: "not-applied" };
|
|
33
|
+
}
|
|
34
|
+
export { resumeUpdate };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reserve an app's existing quit approval before arming a post-exit helper.
|
|
3
|
+
* The native adapter must guarantee its token cannot be reused or vetoed again.
|
|
4
|
+
* `arm` must clean up partial startup before rejecting, and `quit` must only
|
|
5
|
+
* resolve after shutdown is accepted. The helper still needs a bounded process
|
|
6
|
+
* fence; this ordering alone does not establish that the app has exited.
|
|
7
|
+
*/
|
|
8
|
+
export declare function scheduleUpdateShutdown<Token>(options: {
|
|
9
|
+
reserve(): Token | null | Promise<Token | null>;
|
|
10
|
+
cancelReservation(token: Token): void | Promise<void>;
|
|
11
|
+
arm(): Promise<{
|
|
12
|
+
cancel(): void | Promise<void>;
|
|
13
|
+
}>;
|
|
14
|
+
quit(token: Token): boolean | Promise<boolean>;
|
|
15
|
+
}): Promise<'cancelled' | 'scheduled'>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/updates/update-shutdown.ts
|
|
2
|
+
/**
|
|
3
|
+
* Reserve an app's existing quit approval before arming a post-exit helper.
|
|
4
|
+
* The native adapter must guarantee its token cannot be reused or vetoed again.
|
|
5
|
+
* `arm` must clean up partial startup before rejecting, and `quit` must only
|
|
6
|
+
* resolve after shutdown is accepted. The helper still needs a bounded process
|
|
7
|
+
* fence; this ordering alone does not establish that the app has exited.
|
|
8
|
+
*/
|
|
9
|
+
async function scheduleUpdateShutdown(options) {
|
|
10
|
+
const token = await options.reserve();
|
|
11
|
+
if (token === null) return "cancelled";
|
|
12
|
+
if (token === void 0) throw new Error("Invalid update quit approval");
|
|
13
|
+
let helper;
|
|
14
|
+
try {
|
|
15
|
+
helper = await options.arm();
|
|
16
|
+
if (!helper || typeof helper.cancel !== "function") throw new Error("Update helper was not armed");
|
|
17
|
+
if (await options.quit(token) !== true) throw new Error("Update shutdown rejected");
|
|
18
|
+
return "scheduled";
|
|
19
|
+
} catch {
|
|
20
|
+
try {
|
|
21
|
+
await helper?.cancel();
|
|
22
|
+
} catch {}
|
|
23
|
+
try {
|
|
24
|
+
await options.cancelReservation(token);
|
|
25
|
+
} catch {}
|
|
26
|
+
throw new Error("Update shutdown could not be scheduled");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export { scheduleUpdateShutdown };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The shared fields returned by the desktop update services. */
|
|
2
|
+
export type NativeUpdateState<Phase extends string = string> = Readonly<{
|
|
3
|
+
phase: Phase;
|
|
4
|
+
current_version: string;
|
|
5
|
+
available_version: string | null;
|
|
6
|
+
changelog: string;
|
|
7
|
+
release_notes: string | null;
|
|
8
|
+
release_date: string | null;
|
|
9
|
+
downloaded_bytes: number;
|
|
10
|
+
total_bytes: number | null;
|
|
11
|
+
error: string | null;
|
|
12
|
+
github_url: string;
|
|
13
|
+
restart_required: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
/** Project a native snapshot into the shared UI update dialog contract. */
|
|
16
|
+
export declare function toUpdateState<Phase extends string>(update: NativeUpdateState<Phase>, options?: {
|
|
17
|
+
includeReleaseNotes?: boolean;
|
|
18
|
+
}): {
|
|
19
|
+
phase: Phase;
|
|
20
|
+
currentVersion: string;
|
|
21
|
+
availableVersion: string | null;
|
|
22
|
+
changelog: string;
|
|
23
|
+
releaseNotes: string | null;
|
|
24
|
+
releaseDate: string | null;
|
|
25
|
+
downloadedBytes: number;
|
|
26
|
+
totalBytes: number | null;
|
|
27
|
+
error: string | null;
|
|
28
|
+
releaseUrl: string;
|
|
29
|
+
restartRequired: boolean;
|
|
30
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/updates/update-state.ts
|
|
2
|
+
/** Project a native snapshot into the shared UI update dialog contract. */
|
|
3
|
+
function toUpdateState(update, options = {}) {
|
|
4
|
+
return {
|
|
5
|
+
phase: update.phase,
|
|
6
|
+
currentVersion: update.current_version,
|
|
7
|
+
availableVersion: update.available_version,
|
|
8
|
+
changelog: update.changelog,
|
|
9
|
+
releaseNotes: options.includeReleaseNotes === false ? null : update.release_notes,
|
|
10
|
+
releaseDate: update.release_date,
|
|
11
|
+
downloadedBytes: update.downloaded_bytes,
|
|
12
|
+
totalBytes: update.total_bytes,
|
|
13
|
+
error: update.error,
|
|
14
|
+
releaseUrl: update.github_url,
|
|
15
|
+
restartRequired: update.restart_required
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export { toUpdateState };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { InstallerPlatform, InstallerRenderer } from '../installer/installer-layout';
|
|
2
|
+
import type { ReleaseTrust, VerifiedRelease } from './signed-release';
|
|
3
|
+
/**
|
|
4
|
+
* Extract an approved, signature-verified update into `candidate` inside a new
|
|
5
|
+
* private staging directory beside the install. Does not stop, replace or
|
|
6
|
+
* relaunch the app.
|
|
7
|
+
*/
|
|
8
|
+
export declare function stageUpdateSwap(options: {
|
|
9
|
+
descriptor: VerifiedRelease;
|
|
10
|
+
trust: ReleaseTrust;
|
|
11
|
+
currentVersion: string;
|
|
12
|
+
approved: boolean;
|
|
13
|
+
approvedVersion: string;
|
|
14
|
+
target: string;
|
|
15
|
+
appName: string;
|
|
16
|
+
platform: InstallerPlatform;
|
|
17
|
+
renderer: InstallerRenderer;
|
|
18
|
+
archive: string;
|
|
19
|
+
maxCompressedBytes: number;
|
|
20
|
+
maxExpandedBytes: number;
|
|
21
|
+
/** Sidecar executables the app bundles; the update must contain each. */
|
|
22
|
+
sidecars?: readonly string[];
|
|
23
|
+
}): Promise<{
|
|
24
|
+
staging: string;
|
|
25
|
+
candidate: string;
|
|
26
|
+
version: string;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { planUpdateHandoff } from "./update-handoff-plan.js";
|
|
2
|
+
import { extractVerifiedUpdate } from "./update-extraction.js";
|
|
3
|
+
import { renameUpdateExclusive } from "./update-exclusive-rename.js";
|
|
4
|
+
import { updateStagingFor } from "./update-swap.js";
|
|
5
|
+
import { lstat, mkdtemp, readFile, realpath, rm } from "node:fs/promises";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
// src/updates/update-swap-stage.ts
|
|
8
|
+
/**
|
|
9
|
+
* Extract an approved, signature-verified update into `candidate` inside a new
|
|
10
|
+
* private staging directory beside the install. Does not stop, replace or
|
|
11
|
+
* relaunch the app.
|
|
12
|
+
*/
|
|
13
|
+
async function stageUpdateSwap(options) {
|
|
14
|
+
const plan = planUpdateHandoff(options);
|
|
15
|
+
const expectedHost = {
|
|
16
|
+
"macos-arm64": "darwin/arm64",
|
|
17
|
+
"windows-x64": "win32/x64",
|
|
18
|
+
"linux-x64": "linux/x64"
|
|
19
|
+
}[plan.platform];
|
|
20
|
+
if (`${process.platform}/${process.arch}` !== expectedHost) throw new Error("Update requires the matching native platform");
|
|
21
|
+
const info = await lstat(plan.target);
|
|
22
|
+
if (!info.isDirectory() || info.isSymbolicLink() || await realpath(plan.target) !== plan.target) throw new Error("Invalid update install target");
|
|
23
|
+
const versionFile = join(plan.target, ...plan.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
24
|
+
const versionInfo = await lstat(versionFile);
|
|
25
|
+
if (!versionInfo.isFile() || versionInfo.size > 1048576) throw new Error("Installed update version mismatch");
|
|
26
|
+
if (JSON.parse(await readFile(versionFile, "utf8")).version !== plan.currentVersion) throw new Error("Installed update version mismatch");
|
|
27
|
+
const staging = updateStagingFor(plan.target);
|
|
28
|
+
const preparing = await mkdtemp(`${staging}.preparing-`);
|
|
29
|
+
const candidate = join(staging, "candidate");
|
|
30
|
+
let published = false;
|
|
31
|
+
try {
|
|
32
|
+
const extracted = await extractVerifiedUpdate({
|
|
33
|
+
descriptor: options.descriptor,
|
|
34
|
+
archive: options.archive,
|
|
35
|
+
directory: preparing,
|
|
36
|
+
platform: plan.platform,
|
|
37
|
+
renderer: plan.renderer,
|
|
38
|
+
appName: plan.appName,
|
|
39
|
+
maxCompressedBytes: options.maxCompressedBytes,
|
|
40
|
+
maxExpandedBytes: options.maxExpandedBytes,
|
|
41
|
+
...options.sidecars === void 0 ? {} : { sidecars: options.sidecars }
|
|
42
|
+
});
|
|
43
|
+
renameUpdateExclusive(extracted.payload, join(preparing, "candidate"));
|
|
44
|
+
renameUpdateExclusive(preparing, staging);
|
|
45
|
+
published = true;
|
|
46
|
+
return {
|
|
47
|
+
staging,
|
|
48
|
+
candidate,
|
|
49
|
+
version: plan.version
|
|
50
|
+
};
|
|
51
|
+
} finally {
|
|
52
|
+
if (!published) await rm(preparing, {
|
|
53
|
+
recursive: true,
|
|
54
|
+
force: true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export { stageUpdateSwap };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The private staging directory the framework keeps beside an install. */
|
|
2
|
+
export declare function updateStagingFor(target: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Move the staged `candidate` into the install location once the app has
|
|
5
|
+
* exited. The old tree is moved aside into staging and deleted.
|
|
6
|
+
*/
|
|
7
|
+
export declare function swapUpdateTree(options: {
|
|
8
|
+
target: string;
|
|
9
|
+
staging: string;
|
|
10
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { renameUpdateExclusive } from "./update-exclusive-rename.js";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
3
|
+
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
// src/updates/update-swap.ts
|
|
5
|
+
/** The private staging directory the framework keeps beside an install. */
|
|
6
|
+
function updateStagingFor(target) {
|
|
7
|
+
if (typeof target !== "string" || !isAbsolute(target) || resolve(target) !== target) throw new Error("Invalid update target");
|
|
8
|
+
return join(dirname(target), `.${basename(target)}.framework-update`);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Move the staged `candidate` into the install location once the app has
|
|
12
|
+
* exited. The old tree is moved aside into staging and deleted.
|
|
13
|
+
*/
|
|
14
|
+
async function swapUpdateTree(options) {
|
|
15
|
+
const { target, staging } = options;
|
|
16
|
+
if (dirname(staging) !== dirname(target) || staging === target) throw new Error("Invalid update swap context");
|
|
17
|
+
const old = join(staging, "old");
|
|
18
|
+
renameUpdateExclusive(target, old);
|
|
19
|
+
try {
|
|
20
|
+
renameUpdateExclusive(join(staging, "candidate"), target);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
renameUpdateExclusive(old, target);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
await rm(old, {
|
|
26
|
+
recursive: true,
|
|
27
|
+
force: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export { swapUpdateTree, updateStagingFor };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Accessor } from 'solid-js';
|
|
2
|
+
export type ApplicationAboutProps = {
|
|
3
|
+
/** The application's identity; `platform` is the label About shows. */
|
|
4
|
+
identity: Readonly<{
|
|
5
|
+
name: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
platform: string;
|
|
9
|
+
copyright: string;
|
|
10
|
+
sourceUrl: string;
|
|
11
|
+
}>;
|
|
12
|
+
open: boolean;
|
|
13
|
+
/** Called when the dialog asks to close. */
|
|
14
|
+
onClose?(): void;
|
|
15
|
+
/** Called with every open-state change the dialog requests. */
|
|
16
|
+
onOpenChange?(open: boolean): void;
|
|
17
|
+
copyVersionInfo?(text: string): Promise<void>;
|
|
18
|
+
openExternal?(url: string): Promise<void>;
|
|
19
|
+
restoreFocusRef?: Accessor<HTMLElement | undefined>;
|
|
20
|
+
};
|
|
21
|
+
/** The shared About dialog, usable without `ApplicationUtilities`. Load it lazily. */
|
|
22
|
+
export declare function ApplicationAbout(props: ApplicationAboutProps): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createComponent } from "solid-js/web";
|
|
2
|
+
import { AboutDialog } from "@adea-ai/ui/components/composites/about-dialog";
|
|
3
|
+
// src/views/app-about.tsx
|
|
4
|
+
/** The shared About dialog, usable without `ApplicationUtilities`. Load it lazily. */
|
|
5
|
+
function ApplicationAbout(props) {
|
|
6
|
+
return createComponent(AboutDialog, {
|
|
7
|
+
get appName() {
|
|
8
|
+
return props.identity.name;
|
|
9
|
+
},
|
|
10
|
+
get appIcon() {
|
|
11
|
+
return props.identity.icon;
|
|
12
|
+
},
|
|
13
|
+
get version() {
|
|
14
|
+
return props.identity.version;
|
|
15
|
+
},
|
|
16
|
+
get platform() {
|
|
17
|
+
return props.identity.platform;
|
|
18
|
+
},
|
|
19
|
+
get copyright() {
|
|
20
|
+
return props.identity.copyright;
|
|
21
|
+
},
|
|
22
|
+
get sourceUrl() {
|
|
23
|
+
return props.identity.sourceUrl;
|
|
24
|
+
},
|
|
25
|
+
get copyVersionInfo() {
|
|
26
|
+
return props.copyVersionInfo;
|
|
27
|
+
},
|
|
28
|
+
get openExternal() {
|
|
29
|
+
return props.openExternal;
|
|
30
|
+
},
|
|
31
|
+
get open() {
|
|
32
|
+
return props.open;
|
|
33
|
+
},
|
|
34
|
+
onOpenChange: (open) => {
|
|
35
|
+
props.onOpenChange?.(open);
|
|
36
|
+
if (!open) props.onClose?.();
|
|
37
|
+
},
|
|
38
|
+
get restoreFocusRef() {
|
|
39
|
+
return props.restoreFocusRef;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export { ApplicationAbout };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Accessor, type JSX } from 'solid-js';
|
|
2
|
+
export type ApplicationAppearanceProps = {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose(): void;
|
|
5
|
+
/** The app's appearance surface; defaults to the shared provider's panel. */
|
|
6
|
+
panel?: JSX.Element;
|
|
7
|
+
title?: string;
|
|
8
|
+
restoreFocusRef?: Accessor<HTMLElement | undefined>;
|
|
9
|
+
};
|
|
10
|
+
/** The shared Appearance dialog, usable without `ApplicationUtilities`. Load it lazily. */
|
|
11
|
+
export declare function ApplicationAppearance(props: ApplicationAppearanceProps): JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createComponent, template } from "solid-js/web";
|
|
2
|
+
import { Show, Suspense, lazy } from "solid-js";
|
|
3
|
+
import { ModalDialog } from "@adea-ai/ui/components/ui/modal-dialog";
|
|
4
|
+
// src/views/app-appearance.tsx
|
|
5
|
+
var _tmpl$ = /*#__PURE__*/ template(`<span role=status>Loading appearance…`);
|
|
6
|
+
var AppearancePanel = lazy(() => import("@adea-ai/ui/components/theme").then((module) => ({ default: module.AppearancePanel })));
|
|
7
|
+
/** The shared Appearance dialog, usable without `ApplicationUtilities`. Load it lazily. */
|
|
8
|
+
function ApplicationAppearance(props) {
|
|
9
|
+
return createComponent(ModalDialog, {
|
|
10
|
+
get open() {
|
|
11
|
+
return props.open;
|
|
12
|
+
},
|
|
13
|
+
get onClose() {
|
|
14
|
+
return props.onClose;
|
|
15
|
+
},
|
|
16
|
+
get title() {
|
|
17
|
+
return props.title ?? "Appearance";
|
|
18
|
+
},
|
|
19
|
+
size: "settings",
|
|
20
|
+
get restoreFocusRef() {
|
|
21
|
+
return props.restoreFocusRef;
|
|
22
|
+
},
|
|
23
|
+
get children() {
|
|
24
|
+
return createComponent(Suspense, {
|
|
25
|
+
get fallback() {
|
|
26
|
+
return _tmpl$();
|
|
27
|
+
},
|
|
28
|
+
get children() {
|
|
29
|
+
return createComponent(Show, {
|
|
30
|
+
get when() {
|
|
31
|
+
return props.open;
|
|
32
|
+
},
|
|
33
|
+
get children() {
|
|
34
|
+
return props.panel ?? createComponent(AppearancePanel, {});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export { ApplicationAppearance };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Accessor } from 'solid-js';
|
|
2
|
+
import { standardShortcuts, type HelpLink, type HelpShortcut } from '../shell/help-shortcuts';
|
|
3
|
+
export * from '../shell/help-shortcuts';
|
|
4
|
+
export type ApplicationHelpProps = {
|
|
5
|
+
open: boolean;
|
|
6
|
+
onClose(): void;
|
|
7
|
+
appName: string;
|
|
8
|
+
/** App-specific shortcuts, listed before the framework's own. */
|
|
9
|
+
shortcuts: readonly HelpShortcut[];
|
|
10
|
+
/** Appends the chords the framework binds; omit to list only the app's shortcuts. */
|
|
11
|
+
standard?: Parameters<typeof standardShortcuts>[0];
|
|
12
|
+
links: readonly HelpLink[];
|
|
13
|
+
openExternal?(url: string): Promise<void>;
|
|
14
|
+
restoreFocusRef?: Accessor<HTMLElement | undefined>;
|
|
15
|
+
};
|
|
16
|
+
/** The shared Help Center dialog: the app's real shortcuts and project resources. */
|
|
17
|
+
export declare function ApplicationHelp(props: ApplicationHelpProps): import("solid-js").JSX.Element;
|