@adea-ai/app-framework 0.39.0 → 0.39.2
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/ci/desktop-release-feed.sh +108 -0
- package/ci/desktop-release.sh +15 -33
- package/dist/cli/release-finalize-cli.d.ts +1 -0
- package/dist/cli/release-finalize-cli.js +17 -13
- package/dist/desktop/client-assets.js +52 -7
- package/dist/developer-app/developer-app.js +30 -12
- package/dist/framework-source.json +1 -1
- package/dist/native/sidecar.d.ts +0 -19
- package/dist/native/sidecar.js +35 -9
- package/dist/native/window-bootstrap.js +3 -1
- package/dist/shell/app-shell.js +49 -60
- package/dist/shell/app-utilities.js +17 -10
- package/dist/shell/media-query.d.ts +2 -1
- package/dist/shell/media-query.js +4 -3
- package/dist/update-helper.bundle.js +4 -4
- package/dist/updates/desktop-updater.js +2 -2
- package/dist/updates/helper/resume-staging.d.ts +4 -1
- package/dist/updates/helper/resume-staging.js +7 -9
- package/dist/updates/helper/update-resume.js +4 -3
- package/dist/updates/install/update-download.d.ts +1 -0
- package/dist/updates/install/update-download.js +10 -2
- package/dist/updates/install/update-swap.d.ts +2 -0
- package/dist/updates/install/update-swap.js +6 -2
- package/dist/updates/launch/update-launch-gate.d.ts +3 -2
- package/dist/updates/launch/update-launch-gate.js +3 -2
- package/dist/updates/locks/update-download-lock.js +2 -2
- package/dist/updates/retention/retirement-inventory.d.ts +4 -0
- package/dist/updates/retention/retirement-inventory.js +6 -4
- package/dist/updates/update-state-store.js +3 -3
- package/package.json +2 -1
- package/src/desktop/client-assets.ts +73 -13
- package/src/shell/app-shell.tsx +38 -47
- package/src/shell/app-utilities.tsx +22 -17
- package/src/shell/media-query.ts +4 -3
package/dist/shell/app-shell.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { hasEditableKeyboardTarget } from "./keyboard-target.js";
|
|
2
|
+
import { createMediaQuery } from "./media-query.js";
|
|
2
3
|
import { className, createComponent, effect, insert, memo, mergeProps, template } from "solid-js/web";
|
|
3
|
-
import { For, Show, Suspense, createComputed, createEffect, createSignal, lazy, onCleanup, onMount, untrack } from "solid-js";
|
|
4
|
+
import { For, Show, Suspense, children, createComputed, createEffect, createSignal, lazy, onCleanup, onMount, untrack } from "solid-js";
|
|
4
5
|
import { AppShell, AppShellBody, AppShellContent, AppShellMain, SkipLink } from "@adea-ai/ui/components/layout/app-shell";
|
|
5
6
|
import { ContextualSidebar } from "@adea-ai/ui/components/layout/contextual-sidebar";
|
|
6
7
|
import { PixelPane } from "@adea-ai/ui/components/layout/pixel-pane";
|
|
@@ -14,30 +15,14 @@ import { PanelLeftClose, PanelLeftIcon, PanelLeftOpen } from "lucide-solid";
|
|
|
14
15
|
var _tmpl$ = /*#__PURE__*/ template(`<div>`);
|
|
15
16
|
var _tmpl$2 = /*#__PURE__*/ template(`<div data-slot=app-shell-main class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">`);
|
|
16
17
|
var NavigationDrawer = lazy(() => import("./navigation-drawer.js").then((module) => ({ default: module.NavigationDrawer })));
|
|
17
|
-
function createNarrow(query) {
|
|
18
|
-
const [narrow, setNarrow] = createSignal(false);
|
|
19
|
-
createEffect(() => {
|
|
20
|
-
const value = query();
|
|
21
|
-
if (!value || typeof window === "undefined" || !window.matchMedia) return setNarrow(false);
|
|
22
|
-
const media = window.matchMedia(value);
|
|
23
|
-
const update = () => setNarrow(media.matches);
|
|
24
|
-
update();
|
|
25
|
-
media.addEventListener("change", update);
|
|
26
|
-
onCleanup(() => media.removeEventListener("change", update));
|
|
27
|
-
});
|
|
28
|
-
return narrow;
|
|
29
|
-
}
|
|
30
18
|
function getSidebarResponsiveMode(sidebar) {
|
|
31
|
-
|
|
32
|
-
const mode = sidebar.responsiveMode;
|
|
33
|
-
if (mode === "auto" || mode === "desktop" || mode === "mobile") return mode;
|
|
34
|
-
}
|
|
19
|
+
return sidebar?.responsiveMode;
|
|
35
20
|
}
|
|
36
21
|
/** Shared chrome and navigation composition; applications own routes and services. */
|
|
37
22
|
function ApplicationShell(props) {
|
|
38
23
|
let sidebarToggle;
|
|
39
|
-
const narrow =
|
|
40
|
-
const sidebarMobile =
|
|
24
|
+
const narrow = createMediaQuery(() => props.drawer ? props.narrowQuery ?? "(max-width: 799px)" : void 0);
|
|
25
|
+
const sidebarMobile = createMediaQuery(() => !props.drawer && props.sidebar ? "(max-width: 48rem)" : void 0);
|
|
41
26
|
const [sidebarElementMobile, setSidebarElementMobile] = createSignal();
|
|
42
27
|
const sidebarElements = /* @__PURE__ */ new Map();
|
|
43
28
|
const sidebarElementCallbacks = /* @__PURE__ */ new Map();
|
|
@@ -130,6 +115,49 @@ function ApplicationShell(props) {
|
|
|
130
115
|
window.removeEventListener("keydown", handleToggle);
|
|
131
116
|
});
|
|
132
117
|
});
|
|
118
|
+
const RailContent = () => {
|
|
119
|
+
const rail = children(() => props.rail);
|
|
120
|
+
return createComponent(Show, {
|
|
121
|
+
get when() {
|
|
122
|
+
return rail();
|
|
123
|
+
},
|
|
124
|
+
get fallback() {
|
|
125
|
+
return createComponent(SideRailSection, {
|
|
126
|
+
label: "Views",
|
|
127
|
+
get children() {
|
|
128
|
+
return createComponent(For, {
|
|
129
|
+
get each() {
|
|
130
|
+
return props.destinations;
|
|
131
|
+
},
|
|
132
|
+
children: (item) => createComponent(SideRailItem, {
|
|
133
|
+
as: "button",
|
|
134
|
+
type: "button",
|
|
135
|
+
get label() {
|
|
136
|
+
return item.label;
|
|
137
|
+
},
|
|
138
|
+
get ["aria-label"]() {
|
|
139
|
+
return item.label;
|
|
140
|
+
},
|
|
141
|
+
get active() {
|
|
142
|
+
return props.activeDestination === item.id;
|
|
143
|
+
},
|
|
144
|
+
get ["aria-pressed"]() {
|
|
145
|
+
return props.activeDestination === item.id;
|
|
146
|
+
},
|
|
147
|
+
onClick: () => props.onNavigate(item.id),
|
|
148
|
+
get children() {
|
|
149
|
+
return item.icon;
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
get children() {
|
|
157
|
+
return rail();
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
};
|
|
133
161
|
return createComponent(TooltipProvider, {
|
|
134
162
|
openDelay: 150,
|
|
135
163
|
get children() {
|
|
@@ -259,46 +287,7 @@ function ApplicationShell(props) {
|
|
|
259
287
|
return props.footer;
|
|
260
288
|
},
|
|
261
289
|
get children() {
|
|
262
|
-
return createComponent(
|
|
263
|
-
get when() {
|
|
264
|
-
return props.rail;
|
|
265
|
-
},
|
|
266
|
-
get fallback() {
|
|
267
|
-
return createComponent(SideRailSection, {
|
|
268
|
-
label: "Views",
|
|
269
|
-
get children() {
|
|
270
|
-
return createComponent(For, {
|
|
271
|
-
get each() {
|
|
272
|
-
return props.destinations;
|
|
273
|
-
},
|
|
274
|
-
children: (item) => createComponent(SideRailItem, {
|
|
275
|
-
as: "button",
|
|
276
|
-
type: "button",
|
|
277
|
-
get label() {
|
|
278
|
-
return item.label;
|
|
279
|
-
},
|
|
280
|
-
get ["aria-label"]() {
|
|
281
|
-
return item.label;
|
|
282
|
-
},
|
|
283
|
-
get active() {
|
|
284
|
-
return props.activeDestination === item.id;
|
|
285
|
-
},
|
|
286
|
-
get ["aria-pressed"]() {
|
|
287
|
-
return props.activeDestination === item.id;
|
|
288
|
-
},
|
|
289
|
-
onClick: () => props.onNavigate(item.id),
|
|
290
|
-
get children() {
|
|
291
|
-
return item.icon;
|
|
292
|
-
}
|
|
293
|
-
})
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
},
|
|
298
|
-
get children() {
|
|
299
|
-
return props.rail;
|
|
300
|
-
}
|
|
301
|
-
});
|
|
290
|
+
return createComponent(RailContent, {});
|
|
302
291
|
}
|
|
303
292
|
});
|
|
304
293
|
}
|
|
@@ -70,7 +70,7 @@ function ApplicationUtilities(props) {
|
|
|
70
70
|
if (changed) props.settings?.onSectionChange?.(id);
|
|
71
71
|
};
|
|
72
72
|
const settingsOpen = () => props.settings?.open !== void 0 ? props.settings.open : dialog() === "settings";
|
|
73
|
-
const updatesAlways = () => props.accountMenu?.updates === "always";
|
|
73
|
+
const updatesAlways = createMemo(() => props.accountMenu?.updates === "always");
|
|
74
74
|
const updateAdapter = createMemo(() => props.updater ?? browserUpdateAdapter(props.identity.version));
|
|
75
75
|
const markMounted = (value) => {
|
|
76
76
|
if (!mounted().has(value)) setMounted((current) => new Set(current).add(value));
|
|
@@ -147,20 +147,27 @@ function ApplicationUtilities(props) {
|
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
149
|
const close = () => show(void 0);
|
|
150
|
-
const
|
|
151
|
-
|
|
150
|
+
const menuSettingsShortcut = createMemo(() => props.accountMenu?.settingsShortcut);
|
|
151
|
+
const menuSettingsKeyshortcuts = createMemo(() => props.accountMenu?.settingsKeyshortcuts ?? "Meta+, Control+,");
|
|
152
|
+
const menuAppearance = createMemo(() => props.accountMenu?.appearance !== false);
|
|
153
|
+
const hasSettings = createMemo(() => Boolean(props.settings));
|
|
154
|
+
const hasHelp = createMemo(() => Boolean(props.help));
|
|
155
|
+
const hasUpdates = createMemo(() => Boolean(props.updater || props.onUpdates || updatesAlways()));
|
|
156
|
+
const items = createMemo(() => {
|
|
157
|
+
const onSettings = props.onSettings;
|
|
158
|
+
const onHelp = props.onHelp;
|
|
152
159
|
const shared = createAppMenuItems({
|
|
153
160
|
primaryItem: props.primaryItem,
|
|
154
|
-
settingsShortcut:
|
|
161
|
+
settingsShortcut: menuSettingsShortcut(),
|
|
155
162
|
onAbout: (target) => open("about", target),
|
|
156
|
-
onUpdates:
|
|
157
|
-
onSettings:
|
|
158
|
-
onHelp:
|
|
163
|
+
onUpdates: hasUpdates() ? (target) => openUpdates(target) : void 0,
|
|
164
|
+
onSettings: onSettings ?? (hasSettings() ? (target) => openSettings(void 0, target) : void 0),
|
|
165
|
+
onHelp: onHelp ?? (hasHelp() ? (target) => open("help", target) : void 0),
|
|
159
166
|
onFeedback: props.onFeedback
|
|
160
167
|
}).map((item) => {
|
|
161
168
|
if (item.id === "settings" && item.shortcut) return {
|
|
162
169
|
...item,
|
|
163
|
-
keyshortcuts:
|
|
170
|
+
keyshortcuts: menuSettingsKeyshortcuts()
|
|
164
171
|
};
|
|
165
172
|
if (item.id === "updates" && updatesAlways()) return {
|
|
166
173
|
...item,
|
|
@@ -168,14 +175,14 @@ function ApplicationUtilities(props) {
|
|
|
168
175
|
};
|
|
169
176
|
return item;
|
|
170
177
|
});
|
|
171
|
-
if (
|
|
178
|
+
if (!menuAppearance()) return shared;
|
|
172
179
|
return [{
|
|
173
180
|
id: "appearance",
|
|
174
181
|
label: "Appearance",
|
|
175
182
|
icon: createComponent(Palette, { "aria-hidden": "true" }),
|
|
176
183
|
onSelectAfterClose: (target) => open("appearance", target)
|
|
177
184
|
}, ...shared];
|
|
178
|
-
};
|
|
185
|
+
});
|
|
179
186
|
return [createComponent(AccountMenu, {
|
|
180
187
|
get items() {
|
|
181
188
|
return items();
|
|
@@ -3,6 +3,7 @@ export declare const DEFAULT_NARROW_QUERY = "(max-width: 799px)";
|
|
|
3
3
|
/**
|
|
4
4
|
* Reactive `matchMedia`. Components watching the same query share one listener. The query
|
|
5
5
|
* may be reactive and the subscription follows it; an empty or absent query, or a runtime
|
|
6
|
-
* without `matchMedia`, reads as not matching.
|
|
6
|
+
* without `matchMedia`, reads as not matching. The first read already reflects the window, so
|
|
7
|
+
* a narrow window never renders its wide layout for a frame and then swaps it out.
|
|
7
8
|
*/
|
|
8
9
|
export declare function createMediaQuery(query: string | (() => string | undefined)): () => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createComputed, createSignal, onCleanup } from "solid-js";
|
|
2
2
|
// src/shell/media-query.ts
|
|
3
3
|
/** When the application shell counts a window as narrow. */
|
|
4
4
|
var DEFAULT_NARROW_QUERY = "(max-width: 799px)";
|
|
@@ -33,12 +33,13 @@ function subscribe(query, subscriber) {
|
|
|
33
33
|
/**
|
|
34
34
|
* Reactive `matchMedia`. Components watching the same query share one listener. The query
|
|
35
35
|
* may be reactive and the subscription follows it; an empty or absent query, or a runtime
|
|
36
|
-
* without `matchMedia`, reads as not matching.
|
|
36
|
+
* without `matchMedia`, reads as not matching. The first read already reflects the window, so
|
|
37
|
+
* a narrow window never renders its wide layout for a frame and then swaps it out.
|
|
37
38
|
*/
|
|
38
39
|
function createMediaQuery(query) {
|
|
39
40
|
const text = typeof query === "function" ? query : () => query;
|
|
40
41
|
const [matches, setMatches] = createSignal(false);
|
|
41
|
-
|
|
42
|
+
createComputed(() => {
|
|
42
43
|
const value = text();
|
|
43
44
|
if (!value || !supported()) {
|
|
44
45
|
setMatches(false);
|
|
@@ -632,14 +632,14 @@ class UpdateLockBusyError extends Error {
|
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
634
|
async function acquireUpdateLock(target, timeoutMs = 5000) {
|
|
635
|
-
const deadline =
|
|
635
|
+
const deadline = performance.now() + timeoutMs;
|
|
636
636
|
while (true) {
|
|
637
637
|
const lock = await tryAcquireUpdateLock(target);
|
|
638
638
|
if (lock)
|
|
639
639
|
return lock;
|
|
640
|
-
if (
|
|
640
|
+
if (performance.now() >= deadline)
|
|
641
641
|
throw new UpdateLockBusyError;
|
|
642
|
-
await Bun.sleep(Math.min(25, Math.max(1, deadline -
|
|
642
|
+
await Bun.sleep(Math.min(25, Math.max(1, deadline - performance.now())));
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
645
|
function parseState(value) {
|
|
@@ -793,7 +793,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
793
793
|
}
|
|
794
794
|
if (before.isDirectory()) {
|
|
795
795
|
writeRecord("directory", relative, before.mode, 0n);
|
|
796
|
-
const names = (await readdir(path)).
|
|
796
|
+
const names = (await readdir(path)).map((name) => ({ name, bytes: Buffer.from(name, "utf8") })).toSorted((left, right) => Buffer.compare(left.bytes, right.bytes)).map(({ name }) => name);
|
|
797
797
|
for (const name of names) {
|
|
798
798
|
const child = relative ? `${relative}/${name}` : name;
|
|
799
799
|
await visit(join6(path, name), child);
|
|
@@ -388,7 +388,7 @@ async function createDesktopUpdater(options) {
|
|
|
388
388
|
options.log(`update channel read failed during health recovery: ${String(error)}`);
|
|
389
389
|
}
|
|
390
390
|
if (channel) {
|
|
391
|
-
const deadline =
|
|
391
|
+
const deadline = performance.now() + HEALTH_ACK_HELPER_WAIT_MS;
|
|
392
392
|
for (;;) {
|
|
393
393
|
if ((await resumeUpdate({
|
|
394
394
|
target,
|
|
@@ -401,7 +401,7 @@ async function createDesktopUpdater(options) {
|
|
|
401
401
|
options.log(`update resume failed during health recovery: ${String(error)}`);
|
|
402
402
|
return null;
|
|
403
403
|
}))?.status !== "in-progress") break;
|
|
404
|
-
const remaining = deadline -
|
|
404
|
+
const remaining = deadline - performance.now();
|
|
405
405
|
if (remaining <= 0) {
|
|
406
406
|
options.log("update helper remains active; health acknowledgement is deferred");
|
|
407
407
|
break;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type ReleaseTrust } from '../feed/signed-release';
|
|
2
2
|
import { type UpdateStageState } from '../update-state-store';
|
|
3
|
+
import { exists } from '../install/update-swap';
|
|
3
4
|
import type { UpdateResumeResult } from './update-resume';
|
|
4
|
-
export
|
|
5
|
+
export { exists };
|
|
6
|
+
/** Candidate digests proved by a staged resume result, keyed by that result object. */
|
|
7
|
+
export declare const provenCandidateTreeDigests: WeakMap<object, string>;
|
|
5
8
|
export declare function readTreeDigestForProof(path: string): Promise<string | undefined>;
|
|
6
9
|
/** Prove an installed tree, which may gain hard links after the exchange. */
|
|
7
10
|
export declare function readInstalledTreeDigestForProof(path: string): Promise<string | undefined>;
|
|
@@ -4,17 +4,11 @@ import { renameExclusive } from "../../native/native-rename.js";
|
|
|
4
4
|
import { parseUpdateHelperRequest } from "./update-helper.js";
|
|
5
5
|
import { updateProcessMayBeAlive } from "../locks/update-process-liveness.js";
|
|
6
6
|
import { readUpdateHelperRequestFile, writeUpdateStageState } from "../update-state-store.js";
|
|
7
|
-
import { readInstalledUpdateTreeDigest, readUpdateTreeDigest, readUpdateTreeIdentity, readUpdateTreeVersion, sameUpdateTreeDigest, sameUpdateTreeIdentity } from "../install/update-swap.js";
|
|
7
|
+
import { exists, readInstalledUpdateTreeDigest, readUpdateTreeDigest, readUpdateTreeIdentity, readUpdateTreeVersion, sameUpdateTreeDigest, sameUpdateTreeIdentity } from "../install/update-swap.js";
|
|
8
8
|
import { lstat, readdir, rm } from "node:fs/promises";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
11
|
// src/updates/helper/resume-staging.ts
|
|
12
|
-
async function exists(path) {
|
|
13
|
-
return lstat(path).then(() => true, (error) => {
|
|
14
|
-
if (errorCode(error) === "ENOENT") return false;
|
|
15
|
-
throw error;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
12
|
/** Validate the empty extraction remainder left by the legacy stage publisher. */
|
|
19
13
|
async function isLegacyExtractionRemainder(path) {
|
|
20
14
|
const info = await lstat(path);
|
|
@@ -25,6 +19,8 @@ async function isLegacyExtractionRemainder(path) {
|
|
|
25
19
|
const payloadInfo = await lstat(payload);
|
|
26
20
|
return payloadInfo.isDirectory() && !payloadInfo.isSymbolicLink() && (await readdir(payload)).length === 0;
|
|
27
21
|
}
|
|
22
|
+
/** Candidate digests proved by a staged resume result, keyed by that result object. */
|
|
23
|
+
var provenCandidateTreeDigests = /* @__PURE__ */ new WeakMap();
|
|
28
24
|
async function readTreeDigestForProof(path) {
|
|
29
25
|
try {
|
|
30
26
|
return await readUpdateTreeDigest(path);
|
|
@@ -179,10 +175,12 @@ async function recoverStagedCandidate(options) {
|
|
|
179
175
|
}
|
|
180
176
|
if (!info.isDirectory() || info.isSymbolicLink()) return { status: "recovery-required" };
|
|
181
177
|
if (await exists(join(staging, "old")) || await readUpdateTreeVersion(candidate) !== state.version || !sameUpdateTreeIdentity(await readUpdateTreeIdentity(candidate), state.candidateTreeIdentity) || state.candidateTreeDigest !== void 0 && !sameUpdateTreeDigest(await readTreeDigestForProof(candidate), state.candidateTreeDigest)) return { status: "recovery-required" };
|
|
182
|
-
|
|
178
|
+
const result = {
|
|
183
179
|
status: "staged",
|
|
184
180
|
version: state.version,
|
|
185
181
|
channel: verified.descriptor.channel
|
|
186
182
|
};
|
|
183
|
+
if (state.candidateTreeDigest !== void 0) provenCandidateTreeDigests.set(result, state.candidateTreeDigest);
|
|
184
|
+
return result;
|
|
187
185
|
}
|
|
188
|
-
export { exists, hasUnknownStagingEntries, readInstalledTreeDigestForProof, readTreeDigestForProof, reconcileSwap, recoverLegacyHandoff, recoverStagedCandidate, resetToStaged };
|
|
186
|
+
export { exists, hasUnknownStagingEntries, provenCandidateTreeDigests, readInstalledTreeDigestForProof, readTreeDigestForProof, reconcileSwap, recoverLegacyHandoff, recoverStagedCandidate, resetToStaged };
|
|
@@ -2,12 +2,12 @@ import { renameExclusive } from "../../native/native-rename.js";
|
|
|
2
2
|
import { hasUpdateHelperArtifacts } from "./update-helper.js";
|
|
3
3
|
import { updateProcessMayBeAlive } from "../locks/update-process-liveness.js";
|
|
4
4
|
import { UpdateLockBusyError, acquireUpdateLock, readUpdateStageState } from "../update-state-store.js";
|
|
5
|
-
import { readUpdateTreeIdentity, readUpdateTreeVersion, sameUpdateTreeDigest, sameUpdateTreeIdentity, updateStagingFor } from "../install/update-swap.js";
|
|
5
|
+
import { exists, readUpdateTreeIdentity, readUpdateTreeVersion, sameUpdateTreeDigest, sameUpdateTreeIdentity, updateStagingFor } from "../install/update-swap.js";
|
|
6
6
|
import { acquireRetainedUpdateTrees, acquireRetainedUpdateTreesWhileLocked } from "../retention/retirement-inventory.js";
|
|
7
7
|
import { reconcileRetirementCleanupMarkerWhileLocked, retireCompletedUpdateWhileLocked } from "../retention/update-retirement.js";
|
|
8
8
|
import { matchesOldTree, updateRetirementPaths } from "../retention/retirement-records.js";
|
|
9
9
|
import { readUpdateLaunchGate } from "../launch/update-launch-gate.js";
|
|
10
|
-
import {
|
|
10
|
+
import { hasUnknownStagingEntries, provenCandidateTreeDigests, readInstalledTreeDigestForProof, reconcileSwap, recoverLegacyHandoff, recoverStagedCandidate, resetToStaged } from "./resume-staging.js";
|
|
11
11
|
import { recoverUpdateLaunchGate } from "./launch-gate-recovery.js";
|
|
12
12
|
import { lstat, readFile, readdir, rmdir, unlink } from "node:fs/promises";
|
|
13
13
|
import { join } from "node:path";
|
|
@@ -246,7 +246,8 @@ async function resumeUpdateWithRetainedTrees(options) {
|
|
|
246
246
|
currentVersion: resumed.status === "updated" ? resumed.version : options.currentVersion,
|
|
247
247
|
...resumed.status === "staged" ? {
|
|
248
248
|
validatedStagedVersion: resumed.version,
|
|
249
|
-
stagedTrust: options.trust
|
|
249
|
+
stagedTrust: options.trust,
|
|
250
|
+
provenCandidateTreeDigest: provenCandidateTreeDigests.get(resumed)
|
|
250
251
|
} : {}
|
|
251
252
|
});
|
|
252
253
|
if (retained.status === "busy") return { status: "busy" };
|
|
@@ -5,6 +5,7 @@ export declare function downloadVerifiedRelease(options: {
|
|
|
5
5
|
descriptor: VerifiedRelease;
|
|
6
6
|
directory: string;
|
|
7
7
|
maxBytes: number;
|
|
8
|
+
/** How long the transfer may make no progress (connect, headers, or between chunks). */
|
|
8
9
|
timeoutMs?: number;
|
|
9
10
|
signal?: AbortSignal;
|
|
10
11
|
fetch?: FetchFunction;
|
|
@@ -8,8 +8,14 @@ async function downloadVerifiedRelease(options) {
|
|
|
8
8
|
const { descriptor, maxBytes } = options;
|
|
9
9
|
const timeout = options.timeoutMs ?? 12e4;
|
|
10
10
|
if (!isVerifiedRelease(descriptor) || !Number.isSafeInteger(maxBytes) || maxBytes < 1 || descriptor.asset.size > maxBytes || !Number.isSafeInteger(timeout) || timeout < 1 || timeout > 6e5) throw new Error("Invalid verified download request");
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const stall = new AbortController();
|
|
12
|
+
let stallTimer;
|
|
13
|
+
const progressed = () => {
|
|
14
|
+
if (stallTimer !== void 0) clearTimeout(stallTimer);
|
|
15
|
+
stallTimer = setTimeout(() => stall.abort(new DOMException("The release download stalled", "TimeoutError")), timeout);
|
|
16
|
+
};
|
|
17
|
+
progressed();
|
|
18
|
+
const signal = options.signal ? AbortSignal.any([stall.signal, options.signal]) : stall.signal;
|
|
13
19
|
const fetcher = options.fetch ?? globalThis.fetch;
|
|
14
20
|
let temporary;
|
|
15
21
|
let response;
|
|
@@ -48,6 +54,7 @@ async function downloadVerifiedRelease(options) {
|
|
|
48
54
|
break;
|
|
49
55
|
}
|
|
50
56
|
if (!(chunk instanceof Uint8Array) || signal.aborted) throw new Error("Invalid download chunk");
|
|
57
|
+
progressed();
|
|
51
58
|
size += chunk.length;
|
|
52
59
|
if (!Number.isSafeInteger(size) || size > descriptor.asset.size) throw new Error("Release download exceeds signed size");
|
|
53
60
|
let offset = 0;
|
|
@@ -82,6 +89,7 @@ async function downloadVerifiedRelease(options) {
|
|
|
82
89
|
});
|
|
83
90
|
throw error;
|
|
84
91
|
} finally {
|
|
92
|
+
clearTimeout(stallTimer);
|
|
85
93
|
if (response?.body && !response.bodyUsed && !response.body.locked) try {
|
|
86
94
|
response.body.cancel().catch(() => {});
|
|
87
95
|
} catch {}
|
|
@@ -47,6 +47,8 @@ export declare function sameUpdateTreeDigest(left: UpdateTreeDigest | undefined,
|
|
|
47
47
|
export declare function syncUpdateTree(tree: string): Promise<void>;
|
|
48
48
|
/** Sync parent directory entries after the atomic exchange has completed. */
|
|
49
49
|
export declare function syncUpdateTreeParent(target: string): Promise<void>;
|
|
50
|
+
/** Whether a path exists, without following a final symbolic link. */
|
|
51
|
+
export declare function exists(path: string): Promise<boolean>;
|
|
50
52
|
/**
|
|
51
53
|
* Exchange the staged `candidate` and the install location atomically. The
|
|
52
54
|
* previous install remains at `staging/candidate` for journaled cleanup.
|
|
@@ -96,7 +96,10 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
96
96
|
}
|
|
97
97
|
if (before.isDirectory()) {
|
|
98
98
|
writeRecord("directory", relative, before.mode, 0n);
|
|
99
|
-
const names = (await readdir(path)).
|
|
99
|
+
const names = (await readdir(path)).map((name) => ({
|
|
100
|
+
name,
|
|
101
|
+
bytes: Buffer.from(name, "utf8")
|
|
102
|
+
})).toSorted((left, right) => Buffer.compare(left.bytes, right.bytes)).map(({ name }) => name);
|
|
100
103
|
for (const name of names) {
|
|
101
104
|
const child = relative ? `${relative}/${name}` : name;
|
|
102
105
|
await visit(join(path, name), child);
|
|
@@ -185,6 +188,7 @@ async function syncUpdateTreeParent(target) {
|
|
|
185
188
|
await directory.close();
|
|
186
189
|
}
|
|
187
190
|
}
|
|
191
|
+
/** Whether a path exists, without following a final symbolic link. */
|
|
188
192
|
async function exists(path) {
|
|
189
193
|
return lstat(path).then(() => true, (error) => {
|
|
190
194
|
if (errorCode(error) === "ENOENT") return false;
|
|
@@ -230,4 +234,4 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
|
|
|
230
234
|
]);
|
|
231
235
|
if (nextTargetVersion !== candidateVersion || nextCandidateVersion !== previousVersion || !sameUpdateTreeIdentity(nextTargetId, candidateIdentity) || !sameUpdateTreeIdentity(nextCandidateId, previousIdentity)) throw new Error("Atomic update exchange did not preserve both app trees");
|
|
232
236
|
}
|
|
233
|
-
export { readInstalledUpdateTreeDigest, readUpdateTreeDigest, readUpdateTreeIdentity, readUpdateTreeVersion, sameUpdateTreeDigest, sameUpdateTreeIdentity, swapUpdateTree, swapUpdateTreeWhileLocked, syncUpdateTree, syncUpdateTreeParent, updateStagingFor, updateTreeIdentityFromStat };
|
|
237
|
+
export { exists, readInstalledUpdateTreeDigest, readUpdateTreeDigest, readUpdateTreeIdentity, readUpdateTreeVersion, sameUpdateTreeDigest, sameUpdateTreeIdentity, swapUpdateTree, swapUpdateTreeWhileLocked, syncUpdateTree, syncUpdateTreeParent, updateStagingFor, updateTreeIdentityFromStat };
|
|
@@ -89,8 +89,9 @@ export declare function publishUpdateLaunchGate(target: string, helperLiveness:
|
|
|
89
89
|
* The callback must verify journal generation/version and a recovery-safe phase,
|
|
90
90
|
* reconcile the actual tree for that exact gate, and return true only after the
|
|
91
91
|
* reconciliation is durable. False or a thrown error leaves the gate in place.
|
|
92
|
-
*
|
|
93
|
-
* substitutes unless they
|
|
92
|
+
* `recoverPackagedUpdateLaunchGate` (helper/launch-gate-recovery) is its caller;
|
|
93
|
+
* other resume paths are not safe substitutes unless they enforce these
|
|
94
|
+
* ownership and validation steps too.
|
|
94
95
|
*/
|
|
95
96
|
export declare function tryRecoverUpdateLaunchGate(target: string, reconcileJournalAndTree: (gate: UpdateLaunchGate) => Promise<boolean>): Promise<UpdateLaunchGateRecoveryResult>;
|
|
96
97
|
/**
|
|
@@ -279,8 +279,9 @@ async function publishUpdateLaunchGate(target, helperLiveness, input, persistOwn
|
|
|
279
279
|
* The callback must verify journal generation/version and a recovery-safe phase,
|
|
280
280
|
* reconcile the actual tree for that exact gate, and return true only after the
|
|
281
281
|
* reconciliation is durable. False or a thrown error leaves the gate in place.
|
|
282
|
-
*
|
|
283
|
-
* substitutes unless they
|
|
282
|
+
* `recoverPackagedUpdateLaunchGate` (helper/launch-gate-recovery) is its caller;
|
|
283
|
+
* other resume paths are not safe substitutes unless they enforce these
|
|
284
|
+
* ownership and validation steps too.
|
|
284
285
|
*/
|
|
285
286
|
async function tryRecoverUpdateLaunchGate(target, reconcileJournalAndTree) {
|
|
286
287
|
validateTarget(target);
|
|
@@ -45,11 +45,11 @@ async function acquireUpdateDownloadLease(directory, tryOnly = false) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
async function acquireWithin(path, timeoutMs) {
|
|
48
|
-
const deadline =
|
|
48
|
+
const deadline = performance.now() + timeoutMs;
|
|
49
49
|
while (true) {
|
|
50
50
|
const lock = await tryAcquireNativeFileLock(path, "exclusive");
|
|
51
51
|
if (lock) return lock;
|
|
52
|
-
if (
|
|
52
|
+
if (performance.now() >= deadline) throw new Error("Update download lock timed out");
|
|
53
53
|
await Bun.sleep(25);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -59,6 +59,8 @@ export declare function planRetentionWhileLocked(target: string, currentVersion:
|
|
|
59
59
|
allowUnhealthyReads?: boolean;
|
|
60
60
|
validatedStagedVersion?: string;
|
|
61
61
|
stagedTrust?: ReleaseTrust;
|
|
62
|
+
/** A candidate digest the caller proved in this same lock hold. */
|
|
63
|
+
provenCandidateTreeDigest?: string;
|
|
62
64
|
}>): Promise<{
|
|
63
65
|
inventory: Readonly<{
|
|
64
66
|
actualVersion: string;
|
|
@@ -89,5 +91,7 @@ export declare function acquireRetainedUpdateTreesWhileLocked(options: {
|
|
|
89
91
|
currentVersion: string;
|
|
90
92
|
validatedStagedVersion?: string;
|
|
91
93
|
stagedTrust?: ReleaseTrust;
|
|
94
|
+
/** A candidate digest the caller proved in this same lock hold; skips a second full hash. */
|
|
95
|
+
provenCandidateTreeDigest?: string;
|
|
92
96
|
}): Promise<RetainedUpdateTrees>;
|
|
93
97
|
export {};
|
|
@@ -204,10 +204,11 @@ async function planValidatedUpdateRetention(options) {
|
|
|
204
204
|
}
|
|
205
205
|
async function planRetentionWhileLocked(target, currentVersion, options = {}) {
|
|
206
206
|
const staging = updateStagingFor(target);
|
|
207
|
-
|
|
207
|
+
const stagedInfo = await pathInfo(staging);
|
|
208
|
+
if (stagedInfo) {
|
|
208
209
|
if (!options.validatedStagedVersion || !options.stagedTrust) throw new Error("An update staging directory requires recovery");
|
|
209
210
|
const stagedTrust = options.stagedTrust;
|
|
210
|
-
const info =
|
|
211
|
+
const info = stagedInfo;
|
|
211
212
|
const state = await readUpdateStageState(staging);
|
|
212
213
|
const descriptor = state?.signedRelease ? verifyReleaseDescriptor(state.signedRelease, stagedTrust) : { ok: false };
|
|
213
214
|
const candidate = join(staging, "candidate");
|
|
@@ -217,7 +218,7 @@ async function planRetentionWhileLocked(target, currentVersion, options = {}) {
|
|
|
217
218
|
readUpdateTreeIdentity(target),
|
|
218
219
|
readUpdateTreeIdentity(candidate)
|
|
219
220
|
]);
|
|
220
|
-
if (!info?.isDirectory() || info.isSymbolicLink() || !state || state.phase !== "staged" || state.version !== options.validatedStagedVersion || state.previousVersion !== currentVersion || state.helperPid !== void 0 || state.helperOwner !== void 0 || state.launchGateOwner !== void 0 || !state.candidateTreeDigest || !descriptor.ok || descriptor.descriptor.version !== state.version || descriptor.descriptor.channel !== stagedTrust.channel || await readUpdateLaunchGate(target) || await hasUpdateHelperArtifacts(staging) || await pathInfo(join(staging, "old")) || targetVersion !== currentVersion || candidateVersion !== state.version || state.previousTreeIdentity !== void 0 && !sameUpdateTreeIdentity(targetIdentity, state.previousTreeIdentity) || !sameUpdateTreeIdentity(candidateIdentity, state.candidateTreeIdentity) || !sameUpdateTreeDigest(await readUpdateTreeDigest(candidate), state.candidateTreeDigest)) throw new Error("A staged update changed before retained tree acquisition");
|
|
221
|
+
if (!info?.isDirectory() || info.isSymbolicLink() || !state || state.phase !== "staged" || state.version !== options.validatedStagedVersion || state.previousVersion !== currentVersion || state.helperPid !== void 0 || state.helperOwner !== void 0 || state.launchGateOwner !== void 0 || !state.candidateTreeDigest || !descriptor.ok || descriptor.descriptor.version !== state.version || descriptor.descriptor.channel !== stagedTrust.channel || await readUpdateLaunchGate(target) || await hasUpdateHelperArtifacts(staging) || await pathInfo(join(staging, "old")) || targetVersion !== currentVersion || candidateVersion !== state.version || state.previousTreeIdentity !== void 0 && !sameUpdateTreeIdentity(targetIdentity, state.previousTreeIdentity) || !sameUpdateTreeIdentity(candidateIdentity, state.candidateTreeIdentity) || !(sameUpdateTreeDigest(options.provenCandidateTreeDigest, state.candidateTreeDigest) || sameUpdateTreeDigest(await readUpdateTreeDigest(candidate), state.candidateTreeDigest))) throw new Error("A staged update changed before retained tree acquisition");
|
|
221
222
|
}
|
|
222
223
|
const inventory = await readValidatedRetirementInventoryWhileLocked(target, currentVersion, {
|
|
223
224
|
strictRetentionState: true,
|
|
@@ -308,7 +309,8 @@ async function acquireRetainedUpdateTreesWhileLocked(options) {
|
|
|
308
309
|
allowUnhealthyReads: true,
|
|
309
310
|
...options.validatedStagedVersion === void 0 ? {} : {
|
|
310
311
|
validatedStagedVersion: options.validatedStagedVersion,
|
|
311
|
-
stagedTrust: options.stagedTrust
|
|
312
|
+
stagedTrust: options.stagedTrust,
|
|
313
|
+
provenCandidateTreeDigest: options.provenCandidateTreeDigest
|
|
312
314
|
}
|
|
313
315
|
});
|
|
314
316
|
if (lineage.status !== "ready") throw new Error("Update retention lineage requires recovery");
|
|
@@ -18,12 +18,12 @@ function readUpdateHelperRequestFile(staging) {
|
|
|
18
18
|
}
|
|
19
19
|
/** Acquire the stable per-install lock, waiting briefly for short transitions. */
|
|
20
20
|
async function acquireUpdateLock(target, timeoutMs = 5e3) {
|
|
21
|
-
const deadline =
|
|
21
|
+
const deadline = performance.now() + timeoutMs;
|
|
22
22
|
while (true) {
|
|
23
23
|
const lock = await tryAcquireUpdateLock(target);
|
|
24
24
|
if (lock) return lock;
|
|
25
|
-
if (
|
|
26
|
-
await Bun.sleep(Math.min(25, Math.max(1, deadline -
|
|
25
|
+
if (performance.now() >= deadline) throw new UpdateLockBusyError();
|
|
26
|
+
await Bun.sleep(Math.min(25, Math.max(1, deadline - performance.now())));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
function newUpdateStageState(input) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/app-framework",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"ci/desktop-release.sh",
|
|
31
|
+
"ci/desktop-release-feed.sh",
|
|
31
32
|
"dist",
|
|
32
33
|
"src/app/application.tsx",
|
|
33
34
|
"src/appearance",
|