@adea-ai/app-framework 0.39.2 → 0.39.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -52
- package/dist/app/application.d.ts +0 -1
- package/dist/app/application.js +8 -6
- package/dist/app/create-application.js +3 -11
- package/dist/app/service-registry.d.ts +0 -1
- package/dist/app/service-registry.js +3 -3
- package/dist/app/value-guards.d.ts +2 -0
- package/dist/app/value-guards.js +6 -1
- package/dist/appearance/appearance-host.d.ts +1 -1
- package/dist/appearance/appearance-host.js +11 -2
- package/dist/appearance/appearance-preferences.d.ts +0 -1
- package/dist/appearance/custom-theme-import.d.ts +8 -2
- package/dist/appearance/custom-theme-import.js +58 -23
- package/dist/appearance/custom-theme-library.d.ts +3 -3
- package/dist/appearance/custom-theme-library.js +3 -3
- package/dist/appearance/theme-file-importer.d.ts +1 -1
- package/dist/appearance/theme-file-importer.js +2 -1
- package/dist/appearance/theme-library-mutation.d.ts +7 -0
- package/dist/appearance/theme-library-mutation.js +10 -2
- package/dist/appearance/theme-library-store.d.ts +17 -13
- package/dist/appearance/theme-library-store.js +35 -22
- package/dist/appearance/theme-record-adapter.js +1 -2
- package/dist/appearance/theme-registry.js +0 -1
- package/dist/cli/cli-runner.d.ts +3 -2
- package/dist/cli/cli-runner.js +5 -10
- package/dist/cli/release-assets-plan-cli.js +2 -2
- package/dist/cli/release-cut-cli.js +2 -3
- package/dist/cli/release-descriptor-staging-cli.js +2 -2
- package/dist/cli/release-finalize-cli.js +3 -3
- package/dist/cli/release-promote-cli.js +2 -2
- package/dist/cli/release-publish-cli.js +2 -2
- package/dist/cli/release-sign-cli.js +2 -1
- package/dist/cli/release-step-cli.js +2 -2
- package/dist/desktop/channel-proof.js +27 -11
- package/dist/desktop/client-assets.d.ts +6 -1
- package/dist/desktop/client-assets.js +16 -3
- package/dist/desktop/client-dev-proxy.d.ts +0 -2
- package/dist/desktop/client-dev-proxy.js +2 -2
- package/dist/desktop/desktop-client.js +2 -1
- package/dist/desktop/desktop-gateway.js +24 -82
- package/dist/desktop/desktop-host-websocket.d.ts +5 -1
- package/dist/desktop/desktop-host-websocket.js +9 -7
- package/dist/desktop/desktop-host.d.ts +5 -0
- package/dist/desktop/desktop-host.js +3 -0
- package/dist/desktop/desktop-stream.js +5 -10
- package/dist/desktop/typed-array-intrinsics.d.ts +6 -0
- package/dist/desktop/typed-array-intrinsics.js +13 -1
- package/dist/developer-app/developer-app.d.ts +1 -1
- package/dist/developer-app/developer-app.js +26 -13
- package/dist/framework-source.json +1 -1
- package/dist/installer/command-artifact.d.ts +1 -0
- package/dist/installer/command-artifact.js +47 -27
- package/dist/installer/installed-payload.js +3 -1
- package/dist/installer/installer-ci-bootstrap.js +5 -6
- package/dist/installer/installer-ci-preflight.js +3 -3
- package/dist/installer/installer-identity.d.ts +0 -22
- package/dist/installer/installer-identity.js +3 -53
- package/dist/installer/installer-image-mount.d.ts +0 -1
- package/dist/installer/installer-image-mount.js +1 -1
- package/dist/installer/installer-observation.d.ts +5 -5
- package/dist/installer/installer-observation.js +32 -47
- package/dist/installer/installer-process-cleanup.js +2 -2
- package/dist/installer/installer-renderer-evidence.js +7 -28
- package/dist/installer/installer-upgrade-command.js +8 -20
- package/dist/installer/installer-worker-guard.js +3 -3
- package/dist/native/cef-helper.js +4 -4
- package/dist/native/desktop-build.d.ts +0 -3
- package/dist/native/desktop-build.js +2 -2
- package/dist/native/electrobun-source-patch.d.ts +4 -0
- package/dist/native/electrobun-source-patch.js +5 -1
- package/dist/native/native-utilities.js +4 -3
- package/dist/native/pinned-download.d.ts +16 -0
- package/dist/native/pinned-download.js +42 -0
- package/dist/native/posix-launcher-build.js +15 -35
- package/dist/native/posix-tree-removal.js +21 -33
- package/dist/native/sidecar-services.d.ts +0 -2
- package/dist/native/sidecar-services.js +1 -1
- package/dist/native/sidecar.d.ts +3 -0
- package/dist/native/sidecar.js +15 -2
- package/dist/native/window-surface-store.js +3 -3
- package/dist/native/windows-extractor-build.d.ts +6 -16
- package/dist/native/windows-extractor-build.js +11 -14
- package/dist/release/feed-release-cut.d.ts +2 -6
- package/dist/release/feed-release-cut.js +5 -93
- package/dist/release/feed-state.js +1 -5
- package/dist/release/github-release-cut.js +5 -66
- package/dist/release/github-release-provenance.d.ts +2 -0
- package/dist/release/github-release-provenance.js +4 -7
- package/dist/release/github-release-publisher.js +2 -2
- package/dist/release/github-release-qualification.js +3 -3
- package/dist/release/local-release.d.ts +3 -3
- package/dist/release/local-release.js +12 -23
- package/dist/release/qualification-run.js +1 -1
- package/dist/release/release-assets-plan.js +1 -1
- package/dist/release/release-config.d.ts +7 -15
- package/dist/release/release-config.js +25 -29
- package/dist/release/release-cut-command.d.ts +1 -1
- package/dist/release/release-cut-command.js +1 -1
- package/dist/release/release-cut.d.ts +5 -32
- package/dist/release/release-cut.js +9 -55
- package/dist/release/release-descriptor-staging.js +3 -8
- package/dist/release/release-promotion.js +2 -1
- package/dist/release/release-publish-command.js +5 -15
- package/dist/release/release-qualification.js +1 -1
- package/dist/shared/bounded-body.d.ts +33 -0
- package/dist/shared/bounded-body.js +102 -0
- package/dist/shared/file-system.d.ts +12 -0
- package/dist/shared/file-system.js +40 -0
- package/dist/shell/app-shell.js +29 -14
- package/dist/shell/app-utilities.d.ts +2 -1
- package/dist/shell/app-utilities.js +2 -1
- package/dist/shell/application-menu.d.ts +1 -1
- package/dist/shell/application-menu.js +7 -3
- package/dist/shell/poll.d.ts +27 -0
- package/dist/shell/poll.js +88 -0
- package/dist/update-helper.bundle.js +268 -144
- package/dist/updates/channel-update-manager.js +0 -1
- package/dist/updates/desktop-updater.d.ts +9 -0
- package/dist/updates/desktop-updater.js +103 -50
- package/dist/updates/feed/release-feed.d.ts +7 -4
- package/dist/updates/feed/release-feed.js +3 -7
- package/dist/updates/feed/release-location.js +6 -26
- package/dist/updates/feed/release-version.d.ts +7 -2
- package/dist/updates/feed/release-version.js +9 -2
- package/dist/updates/feed/signed-release.d.ts +1 -1
- package/dist/updates/feed/signed-release.js +2 -2
- package/dist/updates/feed/update-discovery.js +2 -6
- package/dist/updates/helper/launch-gate-recovery.js +28 -78
- package/dist/updates/helper/resume-staging.d.ts +14 -3
- package/dist/updates/helper/resume-staging.js +23 -37
- package/dist/updates/helper/update-helper.d.ts +6 -2
- package/dist/updates/helper/update-helper.js +38 -33
- package/dist/updates/helper/update-resume.js +9 -6
- package/dist/updates/install/update-extraction.js +28 -8
- package/dist/updates/install/update-handoff-plan.d.ts +0 -1
- package/dist/updates/install/update-handoff-plan.js +3 -4
- package/dist/updates/install/update-swap-stage.js +1 -6
- package/dist/updates/install/update-swap.d.ts +5 -2
- package/dist/updates/install/update-swap.js +193 -72
- package/dist/updates/launch/helper-exit-wait.d.ts +6 -0
- package/dist/updates/launch/helper-exit-wait.js +18 -0
- package/dist/updates/launch/packaged-update-startup.js +8 -6
- package/dist/updates/launch/update-launch-gate.js +7 -14
- package/dist/updates/locks/stable-file.js +4 -1
- package/dist/updates/locks/update-helper-presence.d.ts +12 -0
- package/dist/updates/locks/update-helper-presence.js +27 -0
- package/dist/updates/retention/retention-cleanup.js +10 -9
- package/dist/updates/retention/retention-maintenance.d.ts +40 -0
- package/dist/updates/retention/retention-maintenance.js +95 -0
- package/dist/updates/retention/retention-prune-progress.js +4 -5
- package/dist/updates/retention/retirement-inventory.d.ts +13 -0
- package/dist/updates/retention/retirement-inventory.js +39 -31
- package/dist/updates/retention/retirement-records.d.ts +1 -4
- package/dist/updates/retention/retirement-records.js +18 -32
- package/dist/updates/retention/update-retention-marker.d.ts +4 -0
- package/dist/updates/retention/update-retention-marker.js +9 -14
- package/dist/updates/retention/update-retirement.d.ts +12 -0
- package/dist/updates/retention/update-retirement.js +59 -31
- package/dist/updates/update-adapter.d.ts +1 -23
- package/dist/updates/update-adapter.js +31 -24
- package/dist/updates/update-channel-store.d.ts +2 -1
- package/dist/updates/update-channel-store.js +6 -4
- package/dist/updates/update-manager.js +2 -2
- package/dist/updates/update-services.d.ts +1 -1
- package/dist/updates/update-services.js +9 -4
- package/dist/updates/update-state-store.d.ts +0 -2
- package/dist/updates/update-state-store.js +5 -12
- package/dist/updates/update-state.d.ts +6 -10
- package/dist/updates/update-state.js +1 -1
- package/dist/views/app-help.d.ts +1 -1
- package/dist/views/app-help.js +1 -3
- package/dist/views/appearance-surface.js +15 -8
- package/dist/views/update-surface.d.ts +1 -3
- package/dist/views/update-surface.js +2 -2
- package/package.json +18 -16
- package/src/app/application.tsx +13 -6
- package/src/appearance/appearance-host.tsx +17 -7
- package/src/appearance/appearance-preferences.ts +0 -1
- package/src/appearance/custom-theme-import.ts +99 -26
- package/src/appearance/custom-theme-library.ts +3 -2
- package/src/appearance/theme-file-importer.ts +3 -2
- package/src/appearance/theme-library-mutation.ts +20 -8
- package/src/appearance/theme-library-schema.ts +7 -0
- package/src/appearance/theme-library-store.ts +41 -26
- package/src/desktop/client-assets.ts +27 -12
- package/src/shell/app-shell.tsx +33 -13
- package/src/shell/app-utilities.tsx +7 -1
- package/src/shell/poll.ts +125 -0
- package/src/updates/feed/release-version.ts +11 -3
- package/src/updates/update-adapter.ts +27 -44
- package/src/updates/update-state.ts +7 -13
- package/src/views/app-help.tsx +1 -1
- package/src/views/appearance-surface.tsx +39 -11
- package/src/views/update-surface.tsx +0 -4
- package/templates/application/.github/workflows/release-assets.yml +2 -2
- package/templates/application/README.md +3 -3
- package/dist/native/cef-helper-download.d.ts +0 -1
- package/dist/native/cef-helper-download.js +0 -35
- package/src/desktop/client-response-lifecycle.ts +0 -305
|
@@ -46,8 +46,8 @@ async function awaitInstallerWorkerPermit(options) {
|
|
|
46
46
|
flag: "wx",
|
|
47
47
|
mode: 384
|
|
48
48
|
});
|
|
49
|
-
const deadline =
|
|
50
|
-
while (
|
|
49
|
+
const deadline = performance.now() + timeoutMs;
|
|
50
|
+
while (performance.now() < deadline) {
|
|
51
51
|
try {
|
|
52
52
|
const info = await lstat(permit);
|
|
53
53
|
if (!info.isFile() || info.isSymbolicLink() || info.size > 49) throw new Error("Invalid worker permit");
|
|
@@ -66,7 +66,7 @@ async function awaitInstallerWorkerPermit(options) {
|
|
|
66
66
|
} catch (error) {
|
|
67
67
|
if (errorCode(error) !== "ENOENT") throw error;
|
|
68
68
|
}
|
|
69
|
-
await new Promise((done) => setTimeout(done, Math.min(100, Math.max(1, deadline -
|
|
69
|
+
await new Promise((done) => setTimeout(done, Math.min(100, Math.max(1, deadline - performance.now()))));
|
|
70
70
|
}
|
|
71
71
|
throw new Error("Worker guard permit missing");
|
|
72
72
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { errorCode } from "../app/value-guards.js";
|
|
2
|
-
import {
|
|
2
|
+
import { downloadPinnedInput } from "./pinned-download.js";
|
|
3
3
|
import { CEF_BRIDGE_PATCH_PATH, CEF_HELPER_SOURCES, ELECTROBUN_COMMIT, PINNED_CEF_BRIDGE_PATCH, applyElectrobunPatch } from "./electrobun-source-patch.js";
|
|
4
4
|
import { chmod, lstat, mkdir, mkdtemp, open, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { dirname, isAbsolute, join } from "node:path";
|
|
@@ -41,7 +41,7 @@ var TARGETS = {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
/** A failure message safe to print: this module's own bounded messages, never paths or tool output. */
|
|
44
|
-
var cefHelperFailure = (error) => error instanceof Error && /^(?:CEF|Unexpected|Unsupported|Expected|Invalid|Electrobun)\b/.test(error.message) ? error.message : "CEF helper preparation failed";
|
|
44
|
+
var cefHelperFailure = (error) => error instanceof Error && /^(?:CEF|Unexpected|Unsupported|Expected|Invalid|Electrobun|Pinned)\b/.test(error.message) ? error.message : "CEF helper preparation failed";
|
|
45
45
|
var sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
46
46
|
function target(os, arch) {
|
|
47
47
|
const found = TARGETS[`${os}-${arch}`];
|
|
@@ -227,14 +227,14 @@ async function buildPatchedCefHelper(pin, work, output) {
|
|
|
227
227
|
const source = join(work, "electrobun");
|
|
228
228
|
for (const path of Object.values(CEF_HELPER_SOURCES)) {
|
|
229
229
|
await mkdir(dirname(join(source, path)), { recursive: true });
|
|
230
|
-
await
|
|
230
|
+
await downloadPinnedInput(`https://raw.githubusercontent.com/blackboardsh/electrobun/${ELECTROBUN_COMMIT}/${path}`, join(source, path), 65536);
|
|
231
231
|
}
|
|
232
232
|
step("source", "git", ["init", "-q"], source);
|
|
233
233
|
applyElectrobunPatch(source, CEF_BRIDGE_PATCH_PATH, PINNED_CEF_BRIDGE_PATCH);
|
|
234
234
|
const helperSource = join(source, CEF_HELPER_SOURCES[pin.platform]);
|
|
235
235
|
const distribution = `cef_binary_${CEF_VERSION}+chromium-${CHROMIUM_VERSION}_${pin.sdk}_minimal`;
|
|
236
236
|
const archive = join(work, "cef.tar.bz2");
|
|
237
|
-
if (await
|
|
237
|
+
if (await downloadPinnedInput(`https://cef-builds.spotifycdn.com/${encodeURIComponent(distribution)}.tar.bz2`, archive, pin.sdkBytes) !== pin.sdkSha256 || (await stat(archive)).size !== pin.sdkBytes) throw new Error("Unexpected CEF distribution digest");
|
|
238
238
|
const cef = join(work, "cef");
|
|
239
239
|
await mkdir(cef);
|
|
240
240
|
const library = {
|
|
@@ -45,12 +45,9 @@ export declare function runElectrobunBuild(options: {
|
|
|
45
45
|
arch?: string;
|
|
46
46
|
run?: BuildCommandRunner;
|
|
47
47
|
createDmg?: typeof createMacosDmg;
|
|
48
|
-
tarVersion?: TarVersionProbe;
|
|
49
48
|
}): Promise<{
|
|
50
49
|
dmg?: string;
|
|
51
50
|
}>;
|
|
52
|
-
/** The framework's post-exit update helper, as the installed package resolves it. */
|
|
53
|
-
export declare function updateHelperSource(): string;
|
|
54
51
|
/**
|
|
55
52
|
* Copy the framework's update helper into `directory` (as `update-helper.js` by default) so
|
|
56
53
|
* Electrobun's `build.copy` can pack it. Resolves the helper through the package's exports
|
|
@@ -80,7 +80,7 @@ async function runElectrobunBuild(options) {
|
|
|
80
80
|
const arch = options.arch ?? process.arch;
|
|
81
81
|
const base = options.env ?? process.env;
|
|
82
82
|
assertPosixLaunchLeaseTarget(base, environment, platform, arch);
|
|
83
|
-
const env = tarEnv(macosSigningEnv(base, platform, environment), platform
|
|
83
|
+
const env = tarEnv(macosSigningEnv(base, platform, environment), platform);
|
|
84
84
|
if (await (options.run ?? runCommand)([
|
|
85
85
|
"node",
|
|
86
86
|
join(cwd, "node_modules", "electrobun", "bin", "electrobun.cjs"),
|
|
@@ -116,4 +116,4 @@ function stageUpdateHelper(directory, options = {}) {
|
|
|
116
116
|
copyFileSync(options.source ?? updateHelperSource(), destination);
|
|
117
117
|
return destination;
|
|
118
118
|
}
|
|
119
|
-
export { assertPosixLaunchLeaseTarget, macosSigningEnv, parseDesktopBuildEnvironment, runElectrobunBuild, signsMacosBuild, stageUpdateHelper, tarEnv
|
|
119
|
+
export { assertPosixLaunchLeaseTarget, macosSigningEnv, parseDesktopBuildEnvironment, runElectrobunBuild, signsMacosBuild, stageUpdateHelper, tarEnv };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/** Electrobun 2.0.5 (MIT), tag v2.0.5: the only source these patches target. */
|
|
2
2
|
export declare const ELECTROBUN_COMMIT = "d06abc9edf0b4e55116129cabbfe17bf89e11791";
|
|
3
|
+
/** The Electrobun release that commit is tagged as. */
|
|
4
|
+
export declare const ELECTROBUN_VERSION = "2.0.5";
|
|
5
|
+
/** The Zig release Electrobun 2.0.5 builds with (its src/shared/build-dependencies.ts). */
|
|
6
|
+
export declare const ZIG_VERSION = "0.17.0";
|
|
3
7
|
export declare const SHORTCUT_PATCH_PATH: string;
|
|
4
8
|
export declare const CEF_BRIDGE_PATCH_PATH: string;
|
|
5
9
|
export declare const POSIX_LAUNCH_LEASE_PATCH_PATH: string;
|
|
@@ -7,6 +7,10 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
// src/native/electrobun-source-patch.ts
|
|
8
8
|
/** Electrobun 2.0.5 (MIT), tag v2.0.5: the only source these patches target. */
|
|
9
9
|
var ELECTROBUN_COMMIT = "d06abc9edf0b4e55116129cabbfe17bf89e11791";
|
|
10
|
+
/** The Electrobun release that commit is tagged as. */
|
|
11
|
+
var ELECTROBUN_VERSION = "2.0.5";
|
|
12
|
+
/** The Zig release Electrobun 2.0.5 builds with (its src/shared/build-dependencies.ts). */
|
|
13
|
+
var ZIG_VERSION = "0.17.0";
|
|
10
14
|
/** Patches ship in `src/native/` so packaged consumers apply the reviewed bytes from `dist/` or `src/`. */
|
|
11
15
|
var shippedPatch = (name) => join(dirname(fileURLToPath(import.meta.url)), "..", "..", "src", "native", name);
|
|
12
16
|
var SHORTCUT_PATCH_PATH = shippedPatch("electrobun-windows-shortcut-com.patch");
|
|
@@ -109,4 +113,4 @@ function applyElectrobunPatch(root, patchPath, pin, git = runGit) {
|
|
|
109
113
|
]);
|
|
110
114
|
for (const [path, expected] of Object.entries(pin.after)) if (sourceDigest(root, path) !== expected) throw new Error("Unexpected patched Electrobun source");
|
|
111
115
|
}
|
|
112
|
-
export { CEF_BRIDGE_PATCH_PATH, CEF_HELPER_SOURCES, ELECTROBUN_COMMIT, PINNED_CEF_BRIDGE_PATCH, PINNED_POSIX_LAUNCH_LEASE_PATCH, PINNED_SHORTCUT_PATCH, POSIX_LAUNCH_LEASE_PATCH_PATH, SHORTCUT_PATCH_PATH, applyElectrobunPatch };
|
|
116
|
+
export { CEF_BRIDGE_PATCH_PATH, CEF_HELPER_SOURCES, ELECTROBUN_COMMIT, ELECTROBUN_VERSION, PINNED_CEF_BRIDGE_PATCH, PINNED_POSIX_LAUNCH_LEASE_PATCH, PINNED_SHORTCUT_PATCH, POSIX_LAUNCH_LEASE_PATCH_PATH, SHORTCUT_PATCH_PATH, ZIG_VERSION, applyElectrobunPatch };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { isRecord } from "../app/value-guards.js";
|
|
1
|
+
import { hasExactOwnKeys, isRecord } from "../app/value-guards.js";
|
|
2
2
|
import { containsAsciiControl } from "../desktop/string-policy.js";
|
|
3
|
+
import { isReleaseVersion } from "../updates/feed/release-version.js";
|
|
3
4
|
import { isAbsolute } from "node:path";
|
|
4
5
|
// src/native/native-utilities.ts
|
|
5
6
|
var MAX_PICKED_FILES = 1e3;
|
|
@@ -12,7 +13,7 @@ function registerNativeUtilities(options) {
|
|
|
12
13
|
version: options.info?.version,
|
|
13
14
|
platform: options.info?.platform
|
|
14
15
|
};
|
|
15
|
-
if (!services || typeof authorize !== "function" || typeof openExternal !== "function" || typeof pickFolder !== "function" || pickFiles !== void 0 && typeof pickFiles !== "function" || typeof info.name !== "string" || !info.name.trim() || info.name.length > 100 || containsAsciiControl(info.name) || typeof info.version !== "string" || info.version.length > 64 ||
|
|
16
|
+
if (!services || typeof authorize !== "function" || typeof openExternal !== "function" || typeof pickFolder !== "function" || pickFiles !== void 0 && typeof pickFiles !== "function" || typeof info.name !== "string" || !info.name.trim() || info.name.length > 100 || containsAsciiControl(info.name) || typeof info.version !== "string" || info.version.length > 64 || !isReleaseVersion(info.version) || ![
|
|
16
17
|
"darwin",
|
|
17
18
|
"win32",
|
|
18
19
|
"linux"
|
|
@@ -32,7 +33,7 @@ function registerNativeUtilities(options) {
|
|
|
32
33
|
}));
|
|
33
34
|
unregister.push(services.register("shell.open-external", {
|
|
34
35
|
parse(value) {
|
|
35
|
-
if (!isRecord(value) ||
|
|
36
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["url"]) || typeof value.url !== "string" || value.url.length > 2048 || containsAsciiControl(value.url, true)) throw new Error("Invalid URL");
|
|
36
37
|
const url = new URL(value.url);
|
|
37
38
|
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) throw new Error("Invalid URL");
|
|
38
39
|
return url.href;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** The part of `fetch` a pinned download uses; injectable for tests. */
|
|
2
|
+
export type PinnedFetch = (url: string, init: {
|
|
3
|
+
signal: AbortSignal;
|
|
4
|
+
}) => Promise<Readonly<{
|
|
5
|
+
ok: boolean;
|
|
6
|
+
body: ReadableStream<Uint8Array> | null;
|
|
7
|
+
url: string;
|
|
8
|
+
}>>;
|
|
9
|
+
/**
|
|
10
|
+
* Stream a pinned build input to a new file within a byte bound, returning its SHA-256.
|
|
11
|
+
* With `host`, a response whose final URL (after redirects) is on another host is refused.
|
|
12
|
+
*/
|
|
13
|
+
export declare function downloadPinnedInput(url: string, path: string, maxBytes: number, options?: Readonly<{
|
|
14
|
+
fetch?: PinnedFetch;
|
|
15
|
+
host?: string;
|
|
16
|
+
}>): Promise<string>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { discardStream } from "../shared/discard-stream.js";
|
|
2
|
+
import { open } from "node:fs/promises";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
// src/native/pinned-download.ts
|
|
5
|
+
/**
|
|
6
|
+
* Stream a pinned build input to a new file within a byte bound, returning its SHA-256.
|
|
7
|
+
* With `host`, a response whose final URL (after redirects) is on another host is refused.
|
|
8
|
+
*/
|
|
9
|
+
async function downloadPinnedInput(url, path, maxBytes, options = {}) {
|
|
10
|
+
const hash = createHash("sha256");
|
|
11
|
+
const file = await open(path, "wx");
|
|
12
|
+
let size = 0;
|
|
13
|
+
let closeFailed = false;
|
|
14
|
+
let closeError;
|
|
15
|
+
try {
|
|
16
|
+
const response = await (options.fetch ?? fetch)(url, { signal: AbortSignal.timeout(9e5) });
|
|
17
|
+
if (!response.ok || !response.body) {
|
|
18
|
+
discardStream(response.body);
|
|
19
|
+
throw new Error("Pinned download failed");
|
|
20
|
+
}
|
|
21
|
+
if (options.host !== void 0 && new URL(response.url).hostname !== options.host) {
|
|
22
|
+
discardStream(response.body);
|
|
23
|
+
throw new Error(`Pinned download redirected away from ${options.host}`);
|
|
24
|
+
}
|
|
25
|
+
for await (const chunk of response.body) {
|
|
26
|
+
size += chunk.byteLength;
|
|
27
|
+
if (size > maxBytes) throw new Error("Pinned download exceeded its size");
|
|
28
|
+
hash.update(chunk);
|
|
29
|
+
await file.writeFile(chunk);
|
|
30
|
+
}
|
|
31
|
+
} finally {
|
|
32
|
+
try {
|
|
33
|
+
await file.close();
|
|
34
|
+
} catch (error) {
|
|
35
|
+
closeFailed = true;
|
|
36
|
+
closeError = error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (closeFailed) throw closeError;
|
|
40
|
+
return hash.digest("hex");
|
|
41
|
+
}
|
|
42
|
+
export { downloadPinnedInput };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ELECTROBUN_COMMIT, PINNED_POSIX_LAUNCH_LEASE_PATCH, POSIX_LAUNCH_LEASE_PATCH_PATH, applyElectrobunPatch } from "./electrobun-source-patch.js";
|
|
2
|
-
import {
|
|
1
|
+
import { ELECTROBUN_COMMIT, ELECTROBUN_VERSION, PINNED_POSIX_LAUNCH_LEASE_PATCH, POSIX_LAUNCH_LEASE_PATCH_PATH, ZIG_VERSION, applyElectrobunPatch } from "./electrobun-source-patch.js";
|
|
2
|
+
import { downloadPinnedInput } from "./pinned-download.js";
|
|
3
|
+
import { chmod, copyFile, lstat, mkdir, mkdtemp, readFile, rename, rm } from "node:fs/promises";
|
|
3
4
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
5
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
6
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
@@ -12,10 +13,8 @@ var ELECTROBUN_OS = "ELECTROBUN_OS";
|
|
|
12
13
|
var ELECTROBUN_ARCH = "ELECTROBUN_ARCH";
|
|
13
14
|
var ELECTROBUN_APP_NAME = "ELECTROBUN_APP_NAME";
|
|
14
15
|
var ELECTROBUN_REPOSITORY = "https://github.com/blackboardsh/electrobun.git";
|
|
15
|
-
var ELECTROBUN_TAG =
|
|
16
|
-
var
|
|
17
|
-
var ZIG_VERSION = "0.17.0";
|
|
18
|
-
var ZIG_ARCHIVE_URL = "https://ziglang.org/download/0.17.0/zig-aarch64-macos-0.17.0.tar.xz";
|
|
16
|
+
var ELECTROBUN_TAG = `v${ELECTROBUN_VERSION}`;
|
|
17
|
+
var ZIG_ARCHIVE_URL = `https://ziglang.org/download/${ZIG_VERSION}/zig-aarch64-macos-${ZIG_VERSION}.tar.xz`;
|
|
19
18
|
var ZIG_ARCHIVE_SHA256 = "b607e9b9234790a008116ae5bdb71c6243b84b9fb42a53a9e70fde41c06c536a";
|
|
20
19
|
var ZIG_ARCHIVE_MAX_BYTES = 67108864;
|
|
21
20
|
var BUILD_TIMEOUT_MILLISECONDS = 9e5;
|
|
@@ -40,32 +39,13 @@ function sourceHead(source) {
|
|
|
40
39
|
}).trim();
|
|
41
40
|
}
|
|
42
41
|
async function downloadPinnedZigArchive(destination) {
|
|
43
|
-
|
|
44
|
-
const file = await open(destination, "wx");
|
|
45
|
-
let size = 0;
|
|
42
|
+
let digest;
|
|
46
43
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} catch (error) {
|
|
51
|
-
throw new Error("Pinned POSIX launcher Zig download failed", { cause: error });
|
|
52
|
-
}
|
|
53
|
-
if (!response.ok || !response.body) {
|
|
54
|
-
try {
|
|
55
|
-
response.body?.cancel().catch(() => {});
|
|
56
|
-
} catch {}
|
|
57
|
-
throw new Error("Pinned POSIX launcher Zig download failed");
|
|
58
|
-
}
|
|
59
|
-
for await (const chunk of response.body) {
|
|
60
|
-
size += chunk.byteLength;
|
|
61
|
-
if (size > ZIG_ARCHIVE_MAX_BYTES) throw new Error("Pinned POSIX launcher Zig archive is too large");
|
|
62
|
-
hash.update(chunk);
|
|
63
|
-
await file.writeFile(chunk);
|
|
64
|
-
}
|
|
65
|
-
} finally {
|
|
66
|
-
await file.close();
|
|
44
|
+
digest = await downloadPinnedInput(ZIG_ARCHIVE_URL, destination, ZIG_ARCHIVE_MAX_BYTES);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw new Error("Pinned POSIX launcher Zig download failed", { cause: error });
|
|
67
47
|
}
|
|
68
|
-
if (
|
|
48
|
+
if (digest !== ZIG_ARCHIVE_SHA256) throw new Error("Unexpected pinned POSIX launcher Zig archive digest");
|
|
69
49
|
}
|
|
70
50
|
async function preparePinnedLauncher(work) {
|
|
71
51
|
const source = join(work, "electrobun");
|
|
@@ -129,7 +109,7 @@ async function preparePinnedLauncher(work) {
|
|
|
129
109
|
} catch (error) {
|
|
130
110
|
throw new Error("Pinned POSIX launcher Zig version check failed", { cause: error });
|
|
131
111
|
}
|
|
132
|
-
if (version !==
|
|
112
|
+
if (version !== "0.17.0") throw new Error("Unexpected pinned POSIX launcher Zig version");
|
|
133
113
|
step("build", zig, [
|
|
134
114
|
"build",
|
|
135
115
|
"-Doptimize=ReleaseFast",
|
|
@@ -158,7 +138,7 @@ async function regularDirectory(path) {
|
|
|
158
138
|
return false;
|
|
159
139
|
}
|
|
160
140
|
}
|
|
161
|
-
async function packagedLauncher(
|
|
141
|
+
async function packagedLauncher(environment, buildDirectory, appName) {
|
|
162
142
|
if (environment !== "stable") throw new Error("POSIX launch lease supports stable builds only");
|
|
163
143
|
if (!buildDirectory || !isAbsolute(buildDirectory) || !appName) throw new Error("Missing Electrobun build output identity");
|
|
164
144
|
if (basename(appName) !== appName || appName === "." || appName === ".." || appName.includes("\\") || appName.includes("\0")) throw new Error("Invalid Electrobun app name");
|
|
@@ -195,7 +175,7 @@ async function verifyElectrobunPackage(cwd) {
|
|
|
195
175
|
} catch (error) {
|
|
196
176
|
throw new Error("Missing pinned Electrobun 2.0.5 package", { cause: error });
|
|
197
177
|
}
|
|
198
|
-
if (manifest.version !==
|
|
178
|
+
if (manifest.version !== "2.0.5") throw new Error("Unexpected pinned Electrobun package version");
|
|
199
179
|
}
|
|
200
180
|
/**
|
|
201
181
|
* Replace the stable macOS arm64 package launcher only when explicitly enabled.
|
|
@@ -214,12 +194,12 @@ async function installOptInPosixLaunchLeaseLauncher(options = {}) {
|
|
|
214
194
|
if (environment !== "stable") throw new Error("POSIX launch lease supports stable builds only");
|
|
215
195
|
const buildDirectory = env[ELECTROBUN_BUILD_DIR];
|
|
216
196
|
const appName = env[ELECTROBUN_APP_NAME];
|
|
217
|
-
const destination = await packagedLauncher(
|
|
197
|
+
const destination = await packagedLauncher(environment, buildDirectory, appName);
|
|
218
198
|
await verifyElectrobunPackage(cwd);
|
|
219
199
|
const work = await mkdtemp(join(tmpdir(), "adea-posix-launcher-"));
|
|
220
200
|
try {
|
|
221
201
|
const prepared = await (options.prepareLauncher ?? preparePinnedLauncher)(work);
|
|
222
|
-
if (await packagedLauncher(
|
|
202
|
+
if (await packagedLauncher(environment, buildDirectory, appName) !== destination) throw new Error("Electrobun build output path changed during launcher build");
|
|
223
203
|
await replacePackagedLauncher(prepared, destination);
|
|
224
204
|
return prepared;
|
|
225
205
|
} finally {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isCanonicalPath } from "./canonical-path.js";
|
|
2
|
+
import { isReleaseVersion } from "../updates/feed/release-version.js";
|
|
2
3
|
import { lstat, open } from "node:fs/promises";
|
|
3
4
|
import { FFIType, dlopen, ptr, read } from "bun:ffi";
|
|
4
5
|
import { constants as constants$1 } from "node:fs";
|
|
@@ -94,31 +95,21 @@ function loadLibrary() {
|
|
|
94
95
|
}
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
|
-
function identityFromStat(stat
|
|
98
|
-
return
|
|
98
|
+
function identityFromStat(stat) {
|
|
99
|
+
return {
|
|
99
100
|
device: read.i32(ptr(stat), 0).toString(),
|
|
100
101
|
inode: read.u64(ptr(stat), 8).toString()
|
|
101
|
-
} : {
|
|
102
|
-
device: read.u64(ptr(stat), 0).toString(),
|
|
103
|
-
inode: read.u64(ptr(stat), 8).toString()
|
|
104
102
|
};
|
|
105
103
|
}
|
|
106
|
-
function modeFromStat(stat
|
|
107
|
-
return
|
|
108
|
-
}
|
|
109
|
-
function direntLayout(darwin) {
|
|
110
|
-
return darwin ? {
|
|
111
|
-
recordLengthOffset: 16,
|
|
112
|
-
typeOffset: 20,
|
|
113
|
-
inodeOffset: 0,
|
|
114
|
-
nameOffset: 21
|
|
115
|
-
} : {
|
|
116
|
-
recordLengthOffset: 16,
|
|
117
|
-
typeOffset: 18,
|
|
118
|
-
inodeOffset: 0,
|
|
119
|
-
nameOffset: 19
|
|
120
|
-
};
|
|
104
|
+
function modeFromStat(stat) {
|
|
105
|
+
return read.u16(ptr(stat), 4);
|
|
121
106
|
}
|
|
107
|
+
var layout = {
|
|
108
|
+
recordLengthOffset: 16,
|
|
109
|
+
typeOffset: 20,
|
|
110
|
+
inodeOffset: 0,
|
|
111
|
+
nameOffset: 21
|
|
112
|
+
};
|
|
122
113
|
function fileType(mode) {
|
|
123
114
|
return mode & 61440;
|
|
124
115
|
}
|
|
@@ -169,11 +160,11 @@ function mountPointForDescriptor(context, fd) {
|
|
|
169
160
|
function statAt(context, directory, name) {
|
|
170
161
|
const output = Buffer.alloc(256);
|
|
171
162
|
if (context.library.symbols.fstatat(directory, ptr(name), ptr(output), AT_SYMLINK_NOFOLLOW_DARWIN) !== 0) throw new Error("Could not inspect filesystem entry during tree removal");
|
|
172
|
-
const identity = identityFromStat(output
|
|
163
|
+
const identity = identityFromStat(output);
|
|
173
164
|
if (identity.device !== context.rootDevice) throw new Error("Tree removal refused to cross a device boundary");
|
|
174
165
|
return {
|
|
175
166
|
identity,
|
|
176
|
-
mode: modeFromStat(output
|
|
167
|
+
mode: modeFromStat(output)
|
|
177
168
|
};
|
|
178
169
|
}
|
|
179
170
|
function openDirectoryAt(context, parent, name) {
|
|
@@ -227,7 +218,6 @@ function removeDirectoryContents(context, directory, depth) {
|
|
|
227
218
|
outcome = empty ? "empty" : "more";
|
|
228
219
|
break;
|
|
229
220
|
}
|
|
230
|
-
const layout = direntLayout(context.darwin);
|
|
231
221
|
const recordLength = read.u16(ptr(entry), layout.recordLengthOffset);
|
|
232
222
|
if (recordLength < layout.nameOffset + 1 || recordLength > 4096) throw new Error("Invalid directory entry returned by the filesystem");
|
|
233
223
|
let nameLength = 0;
|
|
@@ -260,7 +250,7 @@ function removeDirectoryContents(context, directory, depth) {
|
|
|
260
250
|
if (withClosedDescriptor(context, child, () => {
|
|
261
251
|
const childStat = Buffer.alloc(256);
|
|
262
252
|
if (context.library.symbols.fstat(child, ptr(childStat)) !== 0) throw new Error("Could not verify opened directory");
|
|
263
|
-
const opened = identityFromStat(childStat
|
|
253
|
+
const opened = identityFromStat(childStat);
|
|
264
254
|
if (!sameInode(opened, before.identity)) throw new Error("Opened directory identity changed during tree removal");
|
|
265
255
|
if (opened.device !== context.rootDevice) throw new Error("Tree removal refused to cross a device boundary");
|
|
266
256
|
if (!mountPointForDescriptor(context, child).equals(context.rootMountPoint)) throw new Error("Tree removal refused to cross a mount boundary");
|
|
@@ -321,8 +311,8 @@ function removePrioritizedVersionMarker(context, root, relativePath, expectedVer
|
|
|
321
311
|
withClosedDescriptor(context, child, () => {
|
|
322
312
|
const stat = Buffer.alloc(256);
|
|
323
313
|
if (context.library.symbols.fstat(child, ptr(stat)) !== 0) throw new Error("Could not verify retained tree version marker directory");
|
|
324
|
-
const opened = identityFromStat(stat
|
|
325
|
-
if (!sameInode(opened, before.identity) || fileType(modeFromStat(stat
|
|
314
|
+
const opened = identityFromStat(stat);
|
|
315
|
+
if (!sameInode(opened, before.identity) || fileType(modeFromStat(stat)) !== 16384) throw new Error("Retained tree version marker directory changed");
|
|
326
316
|
if (opened.device !== context.rootDevice || !mountPointForDescriptor(context, child).equals(context.rootMountPoint)) throw new Error("Retained tree version marker crossed a filesystem boundary");
|
|
327
317
|
visit(child, index + 1);
|
|
328
318
|
});
|
|
@@ -334,8 +324,8 @@ function removePrioritizedVersionMarker(context, root, relativePath, expectedVer
|
|
|
334
324
|
withClosedDescriptor(context, descriptor, () => {
|
|
335
325
|
const stat = Buffer.alloc(256);
|
|
336
326
|
if (context.library.symbols.fstat(descriptor, ptr(stat)) !== 0) throw new Error("Could not verify opened retained tree version marker");
|
|
337
|
-
const opened = identityFromStat(stat
|
|
338
|
-
if (!sameInode(opened, before.identity) || fileType(modeFromStat(stat
|
|
327
|
+
const opened = identityFromStat(stat);
|
|
328
|
+
if (!sameInode(opened, before.identity) || fileType(modeFromStat(stat)) !== 32768) throw new Error("Opened retained tree version marker changed");
|
|
339
329
|
if (versionFromDescriptor(context, descriptor) !== expectedVersion) throw new Error("Retained tree version marker no longer matches its owner");
|
|
340
330
|
const after = statAt(context, parent, name);
|
|
341
331
|
if (!sameInode(after.identity, opened) || fileType(after.mode) !== 32768) throw new Error("Retained tree version marker changed before removal");
|
|
@@ -344,7 +334,7 @@ function removePrioritizedVersionMarker(context, root, relativePath, expectedVer
|
|
|
344
334
|
context.removed++;
|
|
345
335
|
});
|
|
346
336
|
};
|
|
347
|
-
if (relativePath.length < 1 || relativePath.some((segment) => segment.length === 0 || segment === "." || segment === ".." || segment.includes("/") || segment.includes("\0")) ||
|
|
337
|
+
if (relativePath.length < 1 || relativePath.some((segment) => segment.length === 0 || segment === "." || segment === ".." || segment.includes("/") || segment.includes("\0")) || !isReleaseVersion(expectedVersion)) throw new Error("Invalid prioritized retained tree version marker request");
|
|
348
338
|
visit(root, 0);
|
|
349
339
|
}
|
|
350
340
|
/**
|
|
@@ -369,8 +359,7 @@ function removePrioritizedVersionMarker(context, root, relativePath, expectedVer
|
|
|
369
359
|
*/
|
|
370
360
|
async function removeDirectoryContentsChunk(options) {
|
|
371
361
|
const { root, expectedRootIdentity, maxOperations, prioritizeVersionMarker, testOnlyFailBarrierAtCall } = options;
|
|
372
|
-
|
|
373
|
-
if (!darwin || process.arch !== "arm64") throw new Error("Safe directory-relative removal is unsupported on this platform");
|
|
362
|
+
if (process.platform !== "darwin" || process.arch !== "arm64") throw new Error("Safe directory-relative removal is unsupported on this platform");
|
|
374
363
|
if (!isCanonicalPath(root) || !expectedRootIdentity || !/^[1-9]\d{0,19}$/.test(expectedRootIdentity.device) || !/^[1-9]\d{0,19}$/.test(expectedRootIdentity.inode) || !Number.isSafeInteger(maxOperations) || maxOperations < 1 || maxOperations > 4096 || testOnlyFailBarrierAtCall !== void 0 && (!Number.isSafeInteger(testOnlyFailBarrierAtCall) || testOnlyFailBarrierAtCall < 1)) throw new Error("Invalid bounded tree removal request");
|
|
375
364
|
const rootInfo = await lstat(root, { bigint: true });
|
|
376
365
|
if (!rootInfo.isDirectory() || rootInfo.isSymbolicLink()) throw new Error("Tree removal root is not a directory");
|
|
@@ -391,14 +380,13 @@ async function removeDirectoryContentsChunk(options) {
|
|
|
391
380
|
maxInspectedEntries: Math.max(256, maxOperations * 64),
|
|
392
381
|
barrierCalls: 0,
|
|
393
382
|
testOnlyFailBarrierAtCall,
|
|
394
|
-
darwin,
|
|
395
383
|
rootDevice: "",
|
|
396
384
|
rootMountPoint: Buffer.alloc(0)
|
|
397
385
|
};
|
|
398
386
|
try {
|
|
399
387
|
const descriptorStat = Buffer.alloc(256);
|
|
400
388
|
if (library.symbols.fstat(handle.fd, ptr(descriptorStat)) !== 0) throw new Error("Could not verify opened tree removal root");
|
|
401
|
-
const descriptorIdentity = identityFromStat(descriptorStat
|
|
389
|
+
const descriptorIdentity = identityFromStat(descriptorStat);
|
|
402
390
|
if (descriptorIdentity.device !== expectedRootIdentity.device || descriptorIdentity.inode !== expectedRootIdentity.inode) throw new Error("Opened tree removal root identity changed");
|
|
403
391
|
context.rootDevice = descriptorIdentity.device;
|
|
404
392
|
context.rootMountPoint = mountPointForDescriptor(context, handle.fd);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type createServiceRegistry } from '../app/service-registry';
|
|
2
2
|
import type { Sidecar } from './sidecar';
|
|
3
|
-
/** Accept a web caller's arguments: absent, null, or a plain object. */
|
|
4
|
-
export declare function parseSidecarArgs(value: unknown): Record<string, unknown>;
|
|
5
3
|
/**
|
|
6
4
|
* A sidecar reply's value; a failure becomes a `ServiceError` carrying the failure reason as
|
|
7
5
|
* its code and the sidecar's readable message.
|
package/dist/native/sidecar.d.ts
CHANGED
|
@@ -44,6 +44,9 @@ export type SidecarOptions = {
|
|
|
44
44
|
maxStderrBytes?: number;
|
|
45
45
|
/** Receives stderr lines and lifecycle notes. */
|
|
46
46
|
log?: (line: string) => void;
|
|
47
|
+
/** Send `{"cancel": id}` when a call times out or is aborted. Only for sidecars that
|
|
48
|
+
* understand it; others would log it as an unparseable request. Default false. */
|
|
49
|
+
cancellation?: boolean;
|
|
47
50
|
};
|
|
48
51
|
export type Sidecar<Commands extends SidecarCommands = SidecarCommands> = {
|
|
49
52
|
call<Command extends keyof Commands & string>(command: Command, args?: Commands[Command]['args'], options?: {
|
package/dist/native/sidecar.js
CHANGED
|
@@ -10,7 +10,12 @@ import { Buffer } from "node:buffer";
|
|
|
10
10
|
* sidecar → host {"id": 1, "ok": true, "value": ...}
|
|
11
11
|
* {"id": 1, "ok": false, "error": "readable message"}
|
|
12
12
|
*
|
|
13
|
+
* host → sidecar {"cancel": 1} (only with `cancellation: true`)
|
|
14
|
+
*
|
|
13
15
|
* Ids are positive JavaScript-safe integers; replies may arrive in any order.
|
|
16
|
+
* With `cancellation`, the host sends `{"cancel": id}` when a call times out or
|
|
17
|
+
* its signal aborts, so the sidecar can stop that work. It needs no reply, and a
|
|
18
|
+
* late reply to a cancelled id is ignored.
|
|
14
19
|
* A sidecar must exit when its stdin closes so it never outlives the host, and
|
|
15
20
|
* should answer a request it cannot parse with `"id": null` (logged here).
|
|
16
21
|
*
|
|
@@ -272,8 +277,16 @@ function createSidecar(options) {
|
|
|
272
277
|
resolve(reply);
|
|
273
278
|
}
|
|
274
279
|
};
|
|
275
|
-
const
|
|
276
|
-
|
|
280
|
+
const abandon = (reply) => {
|
|
281
|
+
if (!state.pending.has(id)) return;
|
|
282
|
+
settle(reply);
|
|
283
|
+
if (!options.cancellation || running !== state || state.retiring) return;
|
|
284
|
+
try {
|
|
285
|
+
Promise.resolve(state.process.stdin.write(JSON.stringify({ cancel: id }) + "\n")).then(() => state.process.stdin.flush()).catch(() => {});
|
|
286
|
+
} catch {}
|
|
287
|
+
};
|
|
288
|
+
const onAbort = () => abandon(fail("aborted", `The ${name} call was cancelled`));
|
|
289
|
+
const timer = setTimeout(() => abandon(fail("timeout", `The ${name} did not reply in time`)), timeoutMs);
|
|
277
290
|
const cleanup = () => {
|
|
278
291
|
clearTimeout(timer);
|
|
279
292
|
signal?.removeEventListener("abort", onAbort);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasExactOwnKeys, isRecord } from "../app/value-guards.js";
|
|
1
2
|
import { dirname, join } from "node:path";
|
|
2
3
|
import { randomUUID } from "node:crypto";
|
|
3
4
|
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -52,9 +53,8 @@ function registerWindowSurfaceService(options) {
|
|
|
52
53
|
const current = options.current ?? readWindowSurface(stateFile);
|
|
53
54
|
return services.register("shell.window-surface", {
|
|
54
55
|
parse(value) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return record.surface;
|
|
56
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["surface"]) || !isWindowSurface(value.surface)) throw new Error("Invalid input");
|
|
57
|
+
return value.surface;
|
|
58
58
|
},
|
|
59
59
|
authorize: (principal) => authorize(principal),
|
|
60
60
|
run(_principal, surface) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { ELECTROBUN_VERSION, ZIG_VERSION } from './electrobun-source-patch';
|
|
2
|
+
import { type PinnedFetch } from './pinned-download';
|
|
3
|
+
export { ELECTROBUN_VERSION, ZIG_VERSION };
|
|
1
4
|
/**
|
|
2
5
|
* Electrobun 2.0.5's Windows installer runs `extractor.exe`, whose shortcut code this
|
|
3
6
|
* framework patches (electrobun-windows-shortcut-com.patch). A stable Windows build
|
|
4
7
|
* rebuilds that extractor from the pinned source with the pinned Zig toolchain and points
|
|
5
8
|
* Electrobun at a copy of its devkit holding the rebuilt binary.
|
|
6
9
|
*/
|
|
7
|
-
export declare const ELECTROBUN_VERSION = "2.0.5";
|
|
8
|
-
/** The Zig release Electrobun 2.0.5 builds with (its src/shared/build-dependencies.ts). */
|
|
9
|
-
export declare const ZIG_VERSION = "0.17.0";
|
|
10
10
|
/**
|
|
11
11
|
* Zig builds for the build host's own CPU unless told otherwise, and some Windows runners
|
|
12
12
|
* have AVX-512 while others do not; a native build then dies with STATUS_ILLEGAL_INSTRUCTION
|
|
@@ -51,16 +51,9 @@ export declare function runBuildCommand(command: string, args: readonly string[]
|
|
|
51
51
|
capture?: boolean;
|
|
52
52
|
spawnProcess?: (command: string, args: readonly string[], options: object) => SpawnResult;
|
|
53
53
|
}): string;
|
|
54
|
-
|
|
55
|
-
ok: boolean;
|
|
56
|
-
body: ReadableStream<Uint8Array> | null;
|
|
57
|
-
url: string;
|
|
58
|
-
};
|
|
59
|
-
/** Download the pinned Zig archive from ziglang.org and check its size and SHA-256. */
|
|
54
|
+
/** Download the pinned Zig archive from ziglang.org, bounded by its size, and check its SHA-256. */
|
|
60
55
|
export declare function downloadPinnedZig(archivePath: string, options?: {
|
|
61
|
-
fetch?:
|
|
62
|
-
redirect: 'follow';
|
|
63
|
-
}) => Promise<FetchResponse>;
|
|
56
|
+
fetch?: PinnedFetch;
|
|
64
57
|
expectedSize?: number;
|
|
65
58
|
expectedSha256?: string;
|
|
66
59
|
}): Promise<void>;
|
|
@@ -82,9 +75,7 @@ export declare function buildPatchedWindowsInstaller(options: {
|
|
|
82
75
|
/** Where scratch state goes; defaults to `RUNNER_TEMP`, then the system temp directory. */
|
|
83
76
|
scratchParent?: string;
|
|
84
77
|
runCommand?: WindowsBuildCommand;
|
|
85
|
-
fetch?:
|
|
86
|
-
redirect: 'follow';
|
|
87
|
-
}) => Promise<FetchResponse>;
|
|
78
|
+
fetch?: PinnedFetch;
|
|
88
79
|
zigArchiveSize?: number;
|
|
89
80
|
zigArchiveSha256?: string;
|
|
90
81
|
/** Replaces the pinned-patch apply step; tests only. */
|
|
@@ -92,4 +83,3 @@ export declare function buildPatchedWindowsInstaller(options: {
|
|
|
92
83
|
now?: () => number;
|
|
93
84
|
logStage?: (message: string) => void;
|
|
94
85
|
}): Promise<string>;
|
|
95
|
-
export {};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { electrobunArtifacts } from "../release/release-steps.js";
|
|
2
|
-
import { ELECTROBUN_COMMIT, PINNED_SHORTCUT_PATCH, SHORTCUT_PATCH_PATH, applyElectrobunPatch } from "./electrobun-source-patch.js";
|
|
2
|
+
import { ELECTROBUN_COMMIT, ELECTROBUN_VERSION, PINNED_SHORTCUT_PATCH, SHORTCUT_PATCH_PATH, ZIG_VERSION, applyElectrobunPatch } from "./electrobun-source-patch.js";
|
|
3
|
+
import { downloadPinnedInput } from "./pinned-download.js";
|
|
3
4
|
import { join, resolve } from "node:path";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
5
|
-
import { copyFileSync, createReadStream,
|
|
6
|
+
import { copyFileSync, createReadStream, existsSync, linkSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync } from "node:fs";
|
|
6
7
|
import { spawnSync } from "node:child_process";
|
|
7
8
|
import { tmpdir } from "node:os";
|
|
8
|
-
import { Readable } from "node:stream";
|
|
9
|
-
import { pipeline } from "node:stream/promises";
|
|
10
9
|
import { performance } from "node:perf_hooks";
|
|
11
10
|
// src/native/windows-extractor-build.ts
|
|
12
11
|
/**
|
|
@@ -15,9 +14,6 @@ import { performance } from "node:perf_hooks";
|
|
|
15
14
|
* rebuilds that extractor from the pinned source with the pinned Zig toolchain and points
|
|
16
15
|
* Electrobun at a copy of its devkit holding the rebuilt binary.
|
|
17
16
|
*/
|
|
18
|
-
var ELECTROBUN_VERSION = "2.0.5";
|
|
19
|
-
/** The Zig release Electrobun 2.0.5 builds with (its src/shared/build-dependencies.ts). */
|
|
20
|
-
var ZIG_VERSION = "0.17.0";
|
|
21
17
|
/**
|
|
22
18
|
* Zig builds for the build host's own CPU unless told otherwise, and some Windows runners
|
|
23
19
|
* have AVX-512 while others do not; a native build then dies with STATUS_ILLEGAL_INSTRUCTION
|
|
@@ -127,14 +123,15 @@ function runBuildCommand(command, args, options = {}) {
|
|
|
127
123
|
}
|
|
128
124
|
return options.capture ? (result.stdout ?? "").trim() : "";
|
|
129
125
|
}
|
|
130
|
-
/** Download the pinned Zig archive from ziglang.org
|
|
126
|
+
/** Download the pinned Zig archive from ziglang.org, bounded by its size, and check its SHA-256. */
|
|
131
127
|
async function downloadPinnedZig(archivePath, options = {}) {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (
|
|
128
|
+
const expectedSize = options.expectedSize ?? ZIG_WINDOWS_X64_SIZE;
|
|
129
|
+
const digest = await downloadPinnedInput(ZIG_WINDOWS_X64_URL, archivePath, expectedSize, {
|
|
130
|
+
...options.fetch ? { fetch: options.fetch } : {},
|
|
131
|
+
host: "ziglang.org"
|
|
132
|
+
});
|
|
133
|
+
if (statSync(archivePath).size !== expectedSize) throw new Error("Pinned Zig Windows archive has an unexpected size");
|
|
134
|
+
if (digest !== (options.expectedSha256 ?? ZIG_WINDOWS_X64_SHA256)) throw new Error("Pinned Zig Windows archive failed its official SHA-256 check");
|
|
138
135
|
}
|
|
139
136
|
/**
|
|
140
137
|
* Build a stable Windows x64 installer whose extractor carries the framework's shortcut
|