@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,72 @@
|
|
|
1
|
+
import { assertHostedRunner } from "./hosted-runner.js";
|
|
2
|
+
import { lstat, open, writeFile } from "node:fs/promises";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { realpathSync } from "node:fs";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
// src/installer/installer-worker-guard.ts
|
|
7
|
+
/** Worker interception adapted from adea-ai/adea scripts/desktop-worker-guard.mjs,
|
|
8
|
+
* commit 6155d18941acbb14d9099bc2a33a50ee9683a068 (Apache-2.0). */
|
|
9
|
+
function DeniedWorker() {
|
|
10
|
+
throw new Error("Nested workers forbidden in installer qualification");
|
|
11
|
+
}
|
|
12
|
+
/** Install before Electrobun starts its app worker, in a disposable hosted runner only. */
|
|
13
|
+
function interceptInstallerWorker(options) {
|
|
14
|
+
assertHostedRunner(options.env, "Worker guard");
|
|
15
|
+
if (!options.entry || !options.bootstrap || typeof options.globals.Worker !== "function") throw new Error("Missing worker guard context");
|
|
16
|
+
const Original = options.globals.Worker;
|
|
17
|
+
const expected = resolve(options.entry);
|
|
18
|
+
const matchesEntry = (path) => {
|
|
19
|
+
const actual = resolve(path);
|
|
20
|
+
if (actual === expected) return true;
|
|
21
|
+
try {
|
|
22
|
+
return realpathSync(actual) === realpathSync(expected);
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
let used = false;
|
|
28
|
+
class GuardedWorker extends Original {
|
|
29
|
+
constructor(path, workerOptions) {
|
|
30
|
+
if (used || typeof path !== "string" || !matchesEntry(path) || workerOptions !== void 0 && (workerOptions === null || Object.getPrototypeOf(workerOptions) !== Object.prototype || Reflect.ownKeys(workerOptions).length !== 0)) throw new Error("Unexpected Electrobun worker");
|
|
31
|
+
used = true;
|
|
32
|
+
super(options.bootstrap);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (!Reflect.set(options.globals, "Worker", GuardedWorker) || options.globals.Worker !== GuardedWorker) throw new Error("Cannot install application worker guard");
|
|
36
|
+
}
|
|
37
|
+
/** Deny nested workers and hold the installed app until its exact runtime has been verified. */
|
|
38
|
+
async function awaitInstallerWorkerPermit(options) {
|
|
39
|
+
assertHostedRunner(options.env, "Worker guard");
|
|
40
|
+
const { entry, nonce, acknowledgement, permit } = options;
|
|
41
|
+
const timeoutMs = options.timeoutMs ?? 9e4;
|
|
42
|
+
if (!entry || !/^[a-f0-9]{48}$/.test(nonce) || !acknowledgement || !permit || resolve(acknowledgement) === resolve(permit) || !Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 9e4) throw new Error("Invalid worker guard context");
|
|
43
|
+
if (!Reflect.set(options.globals, "Worker", DeniedWorker) || options.globals.Worker !== DeniedWorker) throw new Error("Cannot block nested workers");
|
|
44
|
+
await writeFile(acknowledgement, nonce + "\n", {
|
|
45
|
+
flag: "wx",
|
|
46
|
+
mode: 384
|
|
47
|
+
});
|
|
48
|
+
const deadline = Date.now() + timeoutMs;
|
|
49
|
+
while (Date.now() < deadline) {
|
|
50
|
+
try {
|
|
51
|
+
const info = await lstat(permit);
|
|
52
|
+
if (!info.isFile() || info.isSymbolicLink() || info.size > 49) throw new Error("Invalid worker permit");
|
|
53
|
+
const file = await open(permit, "r");
|
|
54
|
+
let contents;
|
|
55
|
+
try {
|
|
56
|
+
const buffer = Buffer.alloc(50);
|
|
57
|
+
const { bytesRead } = await file.read(buffer, 0, buffer.length, 0);
|
|
58
|
+
contents = buffer.subarray(0, bytesRead).toString("utf8");
|
|
59
|
+
} finally {
|
|
60
|
+
await file.close();
|
|
61
|
+
}
|
|
62
|
+
const expected = nonce + "\n";
|
|
63
|
+
if (!expected.startsWith(contents)) throw new Error("Invalid worker permit");
|
|
64
|
+
if (contents === expected) return pathToFileURL(resolve(entry)).href;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (error.code !== "ENOENT") throw error;
|
|
67
|
+
}
|
|
68
|
+
await new Promise((done) => setTimeout(done, Math.min(100, Math.max(1, deadline - Date.now()))));
|
|
69
|
+
}
|
|
70
|
+
throw new Error("Worker guard permit missing");
|
|
71
|
+
}
|
|
72
|
+
export { awaitInstallerWorkerPermit, interceptInstallerWorker };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FileHandle } from 'node:fs/promises';
|
|
2
|
+
import type { InstallerPlatform } from './installer-layout';
|
|
3
|
+
/** Require an open file to be a native executable for the platform: an arm64 Mach-O on
|
|
4
|
+
* macOS, an x86-64 ELF on Linux and an x64 PE image on Windows. `what` names it in errors. */
|
|
5
|
+
export declare function assertNativeExecutable(file: FileHandle, size: number, platform: InstallerPlatform, what: string): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/installer/native-executable.ts
|
|
2
|
+
/** Require an open file to be a native executable for the platform: an arm64 Mach-O on
|
|
3
|
+
* macOS, an x86-64 ELF on Linux and an x64 PE image on Windows. `what` names it in errors. */
|
|
4
|
+
async function assertNativeExecutable(file, size, platform, what) {
|
|
5
|
+
const head = Buffer.alloc(64);
|
|
6
|
+
if ((await file.read(head, 0, head.length, 0)).bytesRead !== head.length) throw new Error(`Invalid ${what}`);
|
|
7
|
+
if (platform === "macos-arm64") {
|
|
8
|
+
if (head.readUInt32LE(0) !== 4277009103 || head.readUInt32LE(4) !== 16777228) throw new Error(`Invalid macOS ${what}`);
|
|
9
|
+
} else if (platform === "linux-x64") {
|
|
10
|
+
if (!head.subarray(0, 4).equals(Buffer.from([
|
|
11
|
+
127,
|
|
12
|
+
69,
|
|
13
|
+
76,
|
|
14
|
+
70
|
|
15
|
+
])) || head[4] !== 2 || head.readUInt16LE(18) !== 62) throw new Error(`Invalid Linux ${what}`);
|
|
16
|
+
} else {
|
|
17
|
+
const offset = head.readUInt32LE(60), signature = Buffer.alloc(6);
|
|
18
|
+
if (head.subarray(0, 2).toString() !== "MZ" || offset + signature.length > size || (await file.read(signature, 0, signature.length, offset)).bytesRead !== signature.length || signature.subarray(0, 4).toString() !== "PE\0\0" || signature.readUInt16LE(4) !== 34404) throw new Error(`Invalid Windows ${what}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export { assertNativeExecutable };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { open } from 'node:fs/promises';
|
|
2
|
+
import { type FetchFunction } from '../updates/release-location';
|
|
3
|
+
/** Download one published release asset and check it against its release.json inventory. */
|
|
4
|
+
export declare function downloadAsset(options: {
|
|
5
|
+
/** The app's feed URL, ending in `/`. */
|
|
6
|
+
feed: string;
|
|
7
|
+
tag: string;
|
|
8
|
+
name: string;
|
|
9
|
+
destination: string;
|
|
10
|
+
fetch: FetchFunction;
|
|
11
|
+
openFile?: typeof open;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isFeedAssetName, isFeedTag, parseFeedRelease } from "../updates/release-feed.js";
|
|
2
|
+
import { fetchReleaseLocation, readReleaseJson } from "../updates/release-location.js";
|
|
3
|
+
import { writeAll } from "./write-all.js";
|
|
4
|
+
import { open, unlink } from "node:fs/promises";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
// src/installer/upgrade-asset-download.ts
|
|
7
|
+
var MAX_COMPRESSED_BYTES = 1073741824;
|
|
8
|
+
/** Download one published release asset and check it against its release.json inventory. */
|
|
9
|
+
async function downloadAsset(options) {
|
|
10
|
+
const { feed, tag, name, destination, fetch: fetcher } = options;
|
|
11
|
+
if (!isFeedTag(tag) || !isFeedAssetName(name)) throw new Error("Invalid release asset");
|
|
12
|
+
const release = parseFeedRelease(await readReleaseJson(await fetchReleaseLocation(`${feed}${tag}/release.json`, feed, fetcher, AbortSignal.timeout(3e4)), 262144));
|
|
13
|
+
const digest = release.tag === tag ? release.assets.find((asset) => asset.name === name)?.sha256 : void 0;
|
|
14
|
+
if (!digest) throw new Error("Previous release asset has no recorded digest");
|
|
15
|
+
const response = await fetchReleaseLocation(`${feed}${tag}/${name}`, feed, fetcher, options.signal ?? AbortSignal.timeout(6e5));
|
|
16
|
+
if (response.status !== 200 || !response.body) {
|
|
17
|
+
await response.body?.cancel();
|
|
18
|
+
throw new Error("Previous release download failed");
|
|
19
|
+
}
|
|
20
|
+
const file = await (options.openFile ?? open)(destination, "wx", 384), hash = createHash("sha256");
|
|
21
|
+
let completed = false;
|
|
22
|
+
try {
|
|
23
|
+
let size = 0;
|
|
24
|
+
for await (const chunk of response.body) {
|
|
25
|
+
size += chunk.length;
|
|
26
|
+
if (size > MAX_COMPRESSED_BYTES) throw new Error("Previous release asset exceeds bound");
|
|
27
|
+
hash.update(chunk);
|
|
28
|
+
await writeAll(file, chunk);
|
|
29
|
+
}
|
|
30
|
+
if (hash.digest("hex") !== digest) throw new Error("Previous release asset differs from its digest");
|
|
31
|
+
await file.close();
|
|
32
|
+
completed = true;
|
|
33
|
+
} finally {
|
|
34
|
+
try {
|
|
35
|
+
if (!completed) await file.close();
|
|
36
|
+
} finally {
|
|
37
|
+
if (!completed) await unlink(destination).catch(() => {});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export { downloadAsset };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/installer/write-all.ts
|
|
2
|
+
/** Write a complete chunk or fail if the destination makes no progress. */
|
|
3
|
+
async function writeAll(file, chunk) {
|
|
4
|
+
let offset = 0;
|
|
5
|
+
while (offset < chunk.length) {
|
|
6
|
+
const { bytesWritten } = await file.write(chunk, offset, chunk.length - offset);
|
|
7
|
+
if (!Number.isSafeInteger(bytesWritten) || bytesWritten <= 0 || bytesWritten > chunk.length - offset) throw new Error("Unable to write previous release asset");
|
|
8
|
+
offset += bytesWritten;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export { writeAll };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Electrobun packs the host worker at `Resources/app/bun/index.js`, so the
|
|
3
|
+
* `Resources` directory is two levels above the entry module's directory. Pass
|
|
4
|
+
* the entry's `import.meta.dir`; a framework module cannot know where the app's
|
|
5
|
+
* bundle lives.
|
|
6
|
+
*/
|
|
7
|
+
export declare function bundleResourcesDirectory(entryDirectory: string): string;
|
|
8
|
+
export type PackagedVersion = Readonly<{
|
|
9
|
+
version: string;
|
|
10
|
+
channel?: string;
|
|
11
|
+
identifier?: string;
|
|
12
|
+
hash?: string;
|
|
13
|
+
}>;
|
|
14
|
+
/** Read the version Electrobun wrote to `Resources/version.json` when it packaged the app. */
|
|
15
|
+
export declare function readPackagedVersion(entryDirectory: string): PackagedVersion;
|
|
16
|
+
/** Bundled sidecars live in `Resources/app/sidecars`; copy them there with Electrobun's `build.copy`. */
|
|
17
|
+
export declare const SIDECAR_DIRECTORY = "sidecars";
|
|
18
|
+
/** Validate the sidecar names an app ships: lowercase, portable, unique, at most 16. */
|
|
19
|
+
export declare function assertSidecarNames(names: unknown): readonly string[];
|
|
20
|
+
/** The executable's file name on a platform (`process.platform` or an installer platform). */
|
|
21
|
+
export declare function sidecarFileName(name: string, platform: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* The sidecar's path inside the packaged bundle, relative to the bundle's content
|
|
24
|
+
* root (`<App>.app/Contents` on macOS, the app directory on Windows and Linux).
|
|
25
|
+
*/
|
|
26
|
+
export declare function sidecarBundlePath(name: string, platform: string): string;
|
|
27
|
+
/** Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`. */
|
|
28
|
+
export declare function packagedSidecarPath(entryDirectory: string, name: string, platform?: string): string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { containsAsciiControl } from "../desktop/string-policy.js";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { readFileSync, statSync } from "node:fs";
|
|
4
|
+
// src/native/app-bundle.ts
|
|
5
|
+
/**
|
|
6
|
+
* Electrobun packs the host worker at `Resources/app/bun/index.js`, so the
|
|
7
|
+
* `Resources` directory is two levels above the entry module's directory. Pass
|
|
8
|
+
* the entry's `import.meta.dir`; a framework module cannot know where the app's
|
|
9
|
+
* bundle lives.
|
|
10
|
+
*/
|
|
11
|
+
function bundleResourcesDirectory(entryDirectory) {
|
|
12
|
+
return join(entryDirectory, "..", "..");
|
|
13
|
+
}
|
|
14
|
+
var text = (value, max) => typeof value === "string" && value.length > 0 && value.length <= max && !containsAsciiControl(value);
|
|
15
|
+
/** Read the version Electrobun wrote to `Resources/version.json` when it packaged the app. */
|
|
16
|
+
function readPackagedVersion(entryDirectory) {
|
|
17
|
+
const file = join(bundleResourcesDirectory(entryDirectory), "version.json");
|
|
18
|
+
const info = statSync(file);
|
|
19
|
+
if (!info.isFile() || info.size > 1048576) throw new Error("Invalid packaged version file");
|
|
20
|
+
const value = JSON.parse(readFileSync(file, "utf8"));
|
|
21
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("Invalid packaged version file");
|
|
22
|
+
const record = value;
|
|
23
|
+
if (!text(record.version, 64)) throw new Error("Invalid packaged version");
|
|
24
|
+
const result = { version: record.version };
|
|
25
|
+
for (const key of [
|
|
26
|
+
"channel",
|
|
27
|
+
"identifier",
|
|
28
|
+
"hash"
|
|
29
|
+
]) {
|
|
30
|
+
const field = record[key];
|
|
31
|
+
if (field === void 0 || field === "") continue;
|
|
32
|
+
if (!text(field, 255)) throw new Error(`Invalid packaged ${key}`);
|
|
33
|
+
result[key] = field;
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/** Bundled sidecars live in `Resources/app/sidecars`; copy them there with Electrobun's `build.copy`. */
|
|
38
|
+
var SIDECAR_DIRECTORY = "sidecars";
|
|
39
|
+
/** Validate the sidecar names an app ships: lowercase, portable, unique, at most 16. */
|
|
40
|
+
function assertSidecarNames(names) {
|
|
41
|
+
if (!Array.isArray(names) || names.length > 16 || names.some((name) => typeof name !== "string" || !/^[a-z0-9][a-z0-9_-]{0,63}$/.test(name)) || new Set(names).size !== names.length) throw new Error("Invalid sidecar names");
|
|
42
|
+
return [...names];
|
|
43
|
+
}
|
|
44
|
+
/** The executable's file name on a platform (`process.platform` or an installer platform). */
|
|
45
|
+
function sidecarFileName(name, platform) {
|
|
46
|
+
assertSidecarNames([name]);
|
|
47
|
+
return platform === "win32" || platform === "windows-x64" ? `${name}.exe` : name;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The sidecar's path inside the packaged bundle, relative to the bundle's content
|
|
51
|
+
* root (`<App>.app/Contents` on macOS, the app directory on Windows and Linux).
|
|
52
|
+
*/
|
|
53
|
+
function sidecarBundlePath(name, platform) {
|
|
54
|
+
return `Resources/app/${SIDECAR_DIRECTORY}/${sidecarFileName(name, platform)}`;
|
|
55
|
+
}
|
|
56
|
+
/** Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`. */
|
|
57
|
+
function packagedSidecarPath(entryDirectory, name, platform = process.platform) {
|
|
58
|
+
return join(entryDirectory, "..", SIDECAR_DIRECTORY, sidecarFileName(name, platform));
|
|
59
|
+
}
|
|
60
|
+
export { SIDECAR_DIRECTORY, assertSidecarNames, bundleResourcesDirectory, packagedSidecarPath, readPackagedVersion, sidecarBundlePath, sidecarFileName };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CEF_HELPER_SOURCES } from './electrobun-source-patch';
|
|
2
|
+
type Platform = keyof typeof CEF_HELPER_SOURCES;
|
|
3
|
+
type CefHelperTarget = Readonly<{
|
|
4
|
+
platform: Platform;
|
|
5
|
+
/** Spotify CEF build distribution name, with its size and SHA-256 (SHA-1 cross-checked with the index). */
|
|
6
|
+
sdk: string;
|
|
7
|
+
sdkBytes: number;
|
|
8
|
+
sdkSha256: string;
|
|
9
|
+
/** The helper Electrobun 2.0.5 ships in its core archive for this target. */
|
|
10
|
+
stockHelperSha256: string;
|
|
11
|
+
}>;
|
|
12
|
+
/** A failure message safe to print: this module's own bounded messages, never paths or tool output. */
|
|
13
|
+
export declare const cefHelperFailure: (error: unknown) => string;
|
|
14
|
+
/** Cache key for one target's patched helper: pinned source, patch, CEF SDK and recipe. */
|
|
15
|
+
export declare function cefHelperCacheKey(os: string | undefined, arch: string | undefined): string;
|
|
16
|
+
/** `ADEA_CEF_HELPER_CACHE` when set (CI caches it), otherwise the user's cache directory. */
|
|
17
|
+
export declare function cefHelperCacheRoot(env: Record<string, string | undefined>): string;
|
|
18
|
+
export type CefHelperBuild = (pin: CefHelperTarget, work: string, output: string) => Promise<void>;
|
|
19
|
+
/** Return the cached patched helper for this target, building it once from the pinned source. */
|
|
20
|
+
export declare function ensurePatchedCefHelper(env: Record<string, string | undefined>, os: string, arch: string, build?: CefHelperBuild): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Replace every stock Electrobun CEF helper in a just-built bundle with the
|
|
23
|
+
* main-frame-only build. Bundles without CEF are untouched. Any helper whose
|
|
24
|
+
* bytes are neither the pinned stock helper nor the patched build fails the
|
|
25
|
+
* build. Runs before Electrobun signs, so the helper is signed with the app.
|
|
26
|
+
*/
|
|
27
|
+
export declare function installPatchedCefHelpers(env: Record<string, string | undefined>, ensure?: typeof ensurePatchedCefHelper, stockSha256?: string): Promise<number>;
|
|
28
|
+
export {};
|