@adea-ai/ui 0.102.0 → 0.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +27 -11
  2. package/dist/components/composites/appearance-editor/appearance-choices.d.ts +7 -0
  3. package/dist/components/composites/appearance-editor/appearance-choices.d.ts.map +1 -1
  4. package/dist/components/composites/appearance-editor/appearance-choices.js +44 -3
  5. package/dist/components/composites/appearance-editor/appearance-choices.js.map +1 -1
  6. package/dist/components/composites/appearance-editor/appearance-editor.d.ts.map +1 -1
  7. package/dist/components/composites/appearance-editor/appearance-editor.js +7 -3
  8. package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
  9. package/dist/components/composites/appearance-editor/appearance-types.d.ts +8 -0
  10. package/dist/components/composites/appearance-editor/appearance-types.d.ts.map +1 -1
  11. package/dist/components/composites/update-dialog/update-dialog.d.ts +15 -2
  12. package/dist/components/composites/update-dialog/update-dialog.d.ts.map +1 -1
  13. package/dist/components/composites/update-dialog/update-dialog.js +80 -16
  14. package/dist/components/composites/update-dialog/update-dialog.js.map +1 -1
  15. package/dist/components/theme/appearance-panel.d.ts +2 -1
  16. package/dist/components/theme/appearance-panel.d.ts.map +1 -1
  17. package/dist/components/theme/appearance-panel.js +62 -22
  18. package/dist/components/theme/appearance-panel.js.map +1 -1
  19. package/dist/components/theme/theme-provider.d.ts +13 -2
  20. package/dist/components/theme/theme-provider.d.ts.map +1 -1
  21. package/dist/components/theme/theme-provider.js +7 -4
  22. package/dist/components/theme/theme-provider.js.map +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +3 -2
  26. package/dist/lib/theme-accents.d.ts +9 -0
  27. package/dist/lib/theme-accents.d.ts.map +1 -0
  28. package/dist/lib/theme-accents.js +41 -0
  29. package/dist/lib/theme-accents.js.map +1 -0
  30. package/dist/lib/themes.d.ts +69 -5
  31. package/dist/lib/themes.d.ts.map +1 -1
  32. package/dist/lib/themes.js +100 -7
  33. package/dist/lib/themes.js.map +1 -1
  34. package/dist/r/appearance-editor.json +1 -1
  35. package/dist/r/lib.json +6 -1
  36. package/dist/r/registry.json +8 -2
  37. package/dist/r/src/components/composites/appearance-editor/appearance-choices.tsx +41 -4
  38. package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +12 -6
  39. package/dist/r/src/components/composites/appearance-editor/appearance-types.ts +8 -0
  40. package/dist/r/src/components/composites/update-dialog/update-dialog.tsx +90 -10
  41. package/dist/r/src/components/theme/appearance-panel.tsx +60 -29
  42. package/dist/r/src/components/theme/theme-provider.tsx +31 -7
  43. package/dist/r/src/lib/theme-accents.ts +44 -0
  44. package/dist/r/src/lib/themes.ts +116 -5
  45. package/dist/r/theming.json +1 -0
  46. package/package.json +2 -2
  47. package/registry.json +8 -2
  48. package/src/components/composites/appearance-editor/appearance-choices.tsx +41 -4
  49. package/src/components/composites/appearance-editor/appearance-editor.tsx +12 -6
  50. package/src/components/composites/appearance-editor/appearance-types.ts +8 -0
  51. package/src/components/composites/update-dialog/update-dialog.tsx +90 -10
  52. package/src/components/theme/appearance-panel.tsx +60 -29
  53. package/src/components/theme/theme-provider.tsx +31 -7
  54. package/src/index.ts +7 -0
  55. package/src/lib/theme-accents.ts +44 -0
  56. package/src/lib/themes.ts +116 -5
@@ -20,7 +20,8 @@ var _tmpl$7 = /*#__PURE__*/ template(`<div class="flex flex-col gap-2"><div clas
20
20
  var _tmpl$8 = /*#__PURE__*/ template(`<div class="flex flex-col gap-2"><div class="flex items-center gap-2"><h2 id=update-changelog class="text-sm font-semibold text-foreground">Installed changelog</h2></div><p class="text-xs text-muted-foreground">All versions and updates included with this installation.</p><div class="max-h-72 overflow-y-auto rounded-xl border border-border bg-background/45 p-4 font-mono text-xs leading-5 whitespace-pre-wrap text-muted-foreground"role=region aria-labelledby=update-changelog tabindex=0>`);
21
21
  var _tmpl$9 = /*#__PURE__*/ template(`<div class="flex min-h-0 flex-col gap-5 overflow-y-auto p-6"><section class="rounded-xl border border-border bg-background/45 p-4"aria-label="Version status"><div class="flex flex-wrap items-start justify-between gap-4"><div class="flex flex-col gap-1"><p class="text-2xs font-semibold tracking-widest text-muted-foreground uppercase">Installed version</p><p class="text-sm text-muted-foreground"></p></div><div class="flex flex-col items-end gap-2">`);
22
22
  var _tmpl$0 = /*#__PURE__*/ template(`<img alt class=size-10 aria-hidden=true>`);
23
- var _tmpl$1 = /*#__PURE__*/ template(`<p class="text-xs text-muted-foreground">Released `);
23
+ var _tmpl$1 = /*#__PURE__*/ template(`<div class="mt-4 border-t border-border pt-4">`);
24
+ var _tmpl$10 = /*#__PURE__*/ template(`<p class="text-xs text-muted-foreground">Released `);
24
25
  function messageText(value) {
25
26
  if (typeof value !== "string") return void 0;
26
27
  const message = value.trim();
@@ -53,6 +54,7 @@ function UpdateDialog(props) {
53
54
  "changelog",
54
55
  "fallbackVersion",
55
56
  "desktopOnlyMessage",
57
+ "channelControl",
56
58
  "open",
57
59
  "defaultOpen",
58
60
  "onOpenChange",
@@ -78,6 +80,7 @@ function UpdateDialog(props) {
78
80
  const [cancelPending, setCancelPending] = createSignal(false);
79
81
  let lifecycleEpoch = 0;
80
82
  let activeOpenEpoch;
83
+ let channelCheckUnconfirmed = false;
81
84
  let disposed = false;
82
85
  onCleanup(() => {
83
86
  disposed = true;
@@ -90,8 +93,9 @@ function UpdateDialog(props) {
90
93
  const status = await local.adapter.getStatus();
91
94
  const previous = state();
92
95
  const hasActionableSnapshot = (candidate) => candidate?.phase === "available" || isBusy(candidate);
96
+ const ignoresUnconfirmedChannelSnapshot = channelCheckUnconfirmed && hasActionableSnapshot(status);
93
97
  const preservesSnapshot = previous?.phase === "available" ? status.phase === "available" || isBusy(status) : isBusy(previous) && isBusy(status);
94
- if (isCurrent() && !(checkFailed() && hasActionableSnapshot(previous) && !preservesSnapshot)) setState(status);
98
+ if (isCurrent() && !ignoresUnconfirmedChannelSnapshot && !(checkFailed() && hasActionableSnapshot(previous) && !preservesSnapshot)) setState(status);
95
99
  } catch (caught) {
96
100
  if (isCurrent()) setError(errorMessage(caught, "Version status is unavailable"));
97
101
  }
@@ -107,9 +111,9 @@ function UpdateDialog(props) {
107
111
  setCheckFailed(true);
108
112
  setError(message);
109
113
  };
110
- const applyCheckResult = (next) => {
114
+ const applyCheckResult = (next, preserveOnFailure = true) => {
111
115
  if (next.phase === "failed") {
112
- if (!state()) setState(next);
116
+ if (!state() || !preserveOnFailure) setState(next);
113
117
  failCheck(next.error, "Could not check for updates");
114
118
  return;
115
119
  }
@@ -117,7 +121,7 @@ function UpdateDialog(props) {
117
121
  setCheckFailed(false);
118
122
  setError("");
119
123
  };
120
- const check = async () => {
124
+ const check = async (beforeCheck, clearStaleOffer = beforeCheck !== void 0) => {
121
125
  if (!desktop()) {
122
126
  setError(local.desktopOnlyMessage ?? `Update checks are available from the desktop app.`);
123
127
  return;
@@ -125,16 +129,44 @@ function UpdateDialog(props) {
125
129
  const epoch = activeOpenEpoch;
126
130
  const isCurrent = () => !disposed && epoch !== void 0 && activeOpenEpoch === epoch && lifecycleEpoch === epoch && open();
127
131
  if (!isCurrent()) return;
132
+ if (clearStaleOffer && working()) return;
133
+ if (clearStaleOffer) channelCheckUnconfirmed = true;
134
+ const discardStaleOffer = clearStaleOffer || channelCheckUnconfirmed;
128
135
  setBusy(true);
129
136
  setError("");
130
137
  setCheckFailed(false);
138
+ if (discardStaleOffer) {
139
+ const current = state();
140
+ if (current) setState({
141
+ phase: "checking",
142
+ currentVersion: current.currentVersion
143
+ });
144
+ }
145
+ let channelSaved = beforeCheck === void 0;
131
146
  try {
147
+ await beforeCheck?.();
148
+ channelSaved = true;
149
+ if (!isCurrent()) return;
132
150
  const checked = await local.adapter.check();
133
- if (isCurrent()) applyCheckResult(checked);
151
+ if (isCurrent()) {
152
+ applyCheckResult(checked, !discardStaleOffer);
153
+ if (discardStaleOffer && checked.phase !== "failed") channelCheckUnconfirmed = false;
154
+ }
134
155
  } catch (caught) {
135
156
  if (isCurrent()) {
136
- failCheck(caught, "Could not check for updates");
137
- await loadStatus(isCurrent);
157
+ if (discardStaleOffer) {
158
+ const fallback = channelSaved ? "Could not check for updates" : "Could not save the update channel";
159
+ const message = errorMessage(caught, fallback);
160
+ setState({
161
+ phase: "failed",
162
+ currentVersion: state()?.currentVersion ?? "",
163
+ error: message
164
+ });
165
+ failCheck(message, fallback);
166
+ } else {
167
+ failCheck(caught, "Could not check for updates");
168
+ await loadStatus(isCurrent);
169
+ }
138
170
  }
139
171
  } finally {
140
172
  if (isCurrent()) setBusy(false);
@@ -173,11 +205,28 @@ function UpdateDialog(props) {
173
205
  try {
174
206
  const current = await local.adapter.getStatus();
175
207
  if (!isCurrent()) return;
176
- setState(current);
208
+ const discardStaleOffer = channelCheckUnconfirmed;
209
+ setState(discardStaleOffer ? {
210
+ phase: "checking",
211
+ currentVersion: current.currentVersion
212
+ } : current);
177
213
  const checked = await local.adapter.check();
178
- if (isCurrent()) applyCheckResult(checked);
214
+ if (isCurrent()) {
215
+ applyCheckResult(checked, !discardStaleOffer);
216
+ if (discardStaleOffer && checked.phase !== "failed") channelCheckUnconfirmed = false;
217
+ }
179
218
  } catch (caught) {
180
- if (isCurrent()) failCheck(caught, "Could not check for updates");
219
+ if (isCurrent()) {
220
+ if (channelCheckUnconfirmed) {
221
+ const message = errorMessage(caught, "Could not check for updates");
222
+ setState({
223
+ phase: "failed",
224
+ currentVersion: state()?.currentVersion ?? "",
225
+ error: message
226
+ });
227
+ failCheck(message, "Could not check for updates");
228
+ } else failCheck(caught, "Could not check for updates");
229
+ }
181
230
  } finally {
182
231
  if (isCurrent()) setBusy(false);
183
232
  }
@@ -282,6 +331,8 @@ function UpdateDialog(props) {
282
331
  return value ? plainTextFromMarkdown(value) : "";
283
332
  };
284
333
  const working = () => busy() || cancelPending() || isBusy(state());
334
+ const channelControlDisabled = () => !desktop() || working();
335
+ const recheckChannel = (beforeCheck) => check(beforeCheck, true);
285
336
  const isCurrent = () => state()?.phase === "current" && !error() && !checkFailed() && !working();
286
337
  const triggerLabel = () => {
287
338
  const current = state();
@@ -385,7 +436,7 @@ function UpdateDialog(props) {
385
436
  return _el$;
386
437
  } }),
387
438
  (() => {
388
- var _el$3 = _tmpl$9(), _el$6 = _el$3.firstChild.firstChild.firstChild, _el$8 = _el$6.firstChild.nextSibling, _el$9 = _el$6.nextSibling;
439
+ var _el$3 = _tmpl$9(), _el$4 = _el$3.firstChild, _el$6 = _el$4.firstChild.firstChild, _el$8 = _el$6.firstChild.nextSibling, _el$9 = _el$6.nextSibling;
389
440
  insert(_el$6, createComponent(Heading, {
390
441
  as: "p",
391
442
  size: "page",
@@ -453,6 +504,19 @@ function UpdateDialog(props) {
453
504
  return _el$0;
454
505
  }
455
506
  }), null);
507
+ insert(_el$4, createComponent(Show, {
508
+ get when() {
509
+ return local.channelControl;
510
+ },
511
+ children: (channelControl) => (() => {
512
+ var _el$35 = _tmpl$1();
513
+ insert(_el$35, () => channelControl()({
514
+ disabled: channelControlDisabled,
515
+ recheck: recheckChannel
516
+ }));
517
+ return _el$35;
518
+ })()
519
+ }), null);
456
520
  insert(_el$3, createComponent(Show, {
457
521
  get when() {
458
522
  return memo(() => !!(state()?.availableVersion && state()?.phase !== "installed"))() && state()?.phase !== "unavailable";
@@ -478,10 +542,10 @@ function UpdateDialog(props) {
478
542
  return formatReleaseDate(state()?.releaseDate ?? null);
479
543
  },
480
544
  children: (released) => (() => {
481
- var _el$35 = _tmpl$1();
482
- _el$35.firstChild;
483
- insert(_el$35, released, null);
484
- return _el$35;
545
+ var _el$36 = _tmpl$10();
546
+ _el$36.firstChild;
547
+ insert(_el$36, released, null);
548
+ return _el$36;
485
549
  })()
486
550
  }), null);
487
551
  insert(_el$11, createComponent(ActionButton, {
@@ -1 +1 @@
1
- {"version":3,"file":"update-dialog.js","names":["createEffect","createMemo","createSignal","onCleanup","onMount","Show","splitProps","Accessor","Check","CircleStop","Download","ExternalLink","LoaderCircle","Monitor","RefreshCw","Sparkles","Badge","Button","ActionButton","Dialog","DialogClose","DialogContent","DialogDescription","DialogFooter","DialogHeader","DialogTitle","DialogTrigger","createDialogFocusRestoration","Progress","Heading","cn","formatBytes","formatReleaseDate","plainTextFromMarkdown","UpdatePhase","UpdateState","Readonly","phase","currentVersion","availableVersion","changelog","releaseNotes","releaseDate","downloadedBytes","totalBytes","error","releaseUrl","restartRequired","UpdateAdapter","getStatus","Promise","check","install","expectedVersion","cancel","pollIntervalMs","openExternal","url","isDesktopRuntime","UpdateDialogProps","adapter","appName","appIcon","fallbackVersion","desktopOnlyMessage","open","defaultOpen","onOpenChange","restoreFocusRef","HTMLElement","class","messageText","value","undefined","message","trim","errorMessage","caught","fallback","Error","plainMessage","record","safe","nestedError","isBusy","state","UpdateDialog","props","local","uncontrolledOpen","setUncontrolledOpen","setOpen","next","focusRestoration","desktop","setState","busy","setBusy","setError","checkFailed","setCheckFailed","cancelPending","setCancelPending","lifecycleEpoch","activeOpenEpoch","disposed","loadStatus","isCurrent","status","previous","hasActionableSnapshot","candidate","preservesSnapshot","epoch","failCheck","applyCheckResult","current","checked","active","version","includes","requestInFlight","timer","window","setInterval","Math","max","clearInterval","openRelease","notes","working","triggerLabel","progressValue","min","round","_$createComponent","children","when","as","variant","size","_$memo","onKeyDown","event","KeyboardEvent","key","defaultPrevented","preventDefault","onOpenAutoFocus","currentTarget","focus","preventScroll","onCloseAutoFocus","_el$","_tmpl$","_el$2","firstChild","_$insert","icon","_el$34","_tmpl$0","_$effect","_$setAttribute","_el$3","_tmpl$9","_el$4","_el$5","_el$6","_el$7","_el$8","nextSibling","_el$9","tone","type","tooltip","disabled","onClick","_el$0","_tmpl$2","_el$1","_el$10","_tmpl$3","_el$11","_el$12","_el$13","_el$14","_el$16","_el$15","_el$17","_el$18","_el$20","_el$19","released","_el$35","_tmpl$1","_el$36","_el$21","_tmpl$4","_el$22","aria-label","_el$23","_tmpl$5","_el$24","_tmpl$6","_el$25","_tmpl$7","_el$26","_el$27","_el$28","_el$29","_tmpl$8","_el$30","_el$31","_el$32","_el$33","_$createComponent","_$memo","_$setAttribute"],"sources":["../../../../src/components/composites/update-dialog/update-dialog.tsx"],"sourcesContent":["import {\n createEffect,\n createMemo,\n createSignal,\n onCleanup,\n onMount,\n Show,\n splitProps,\n} from 'solid-js'\nimport type { Accessor } from 'solid-js'\nimport {\n Check,\n CircleStop,\n Download,\n ExternalLink,\n LoaderCircle,\n Monitor,\n RefreshCw,\n Sparkles,\n} from 'lucide-solid'\nimport { Badge } from '../../ui/badge'\nimport { Button } from '../../ui/button'\nimport { ActionButton } from '../action-button'\nimport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from '../../ui/dialog'\nimport { createDialogFocusRestoration } from '../../ui/dialog/dialog'\nimport { Progress } from '../../ui/progress'\nimport { Heading } from '../../ui/typography'\nimport { cn } from '#lib/utils'\nimport { formatBytes, formatReleaseDate, plainTextFromMarkdown } from '#lib/version-notes'\n\n/**\n * UpdateDialog.\n *\n * A software-update surface: the installed version, whether a newer release\n * exists, a download that shows its progress, and the release notes for what is\n * about to arrive.\n *\n * The transport is an adapter, because an update is the one thing a component\n * library genuinely cannot implement: it is signed, downloaded and applied by the\n * application's own updater, and the mechanism differs per shell. What *is*\n * general is the phase machine and the way each phase is presented — and that is\n * where the hard-won detail lives:\n *\n * **A refused install answers with a normal payload, not a rejection.** adea's\n * shell returns a status whose phase is `failed` when a download or an extract\n * fails, rather than throwing. Without handling that, clicking install looked like\n * nothing happened at all — the button spun, the phase never changed, and the\n * error sat unread in a field nobody rendered. The `failed` phase after an install\n * is therefore surfaced as an error, explicitly.\n *\n * **Busy is derived from the snapshot as well as from the click.** An update can\n * be downloading while the dialog is open — started before it opened, or by the\n * shell's own poll — so a local `busy` flag alone would offer an enabled Install\n * button mid-download.\n *\n * **Opening the dialog loads status first, then checks.** Status paints the\n * installed version immediately; the check is a network round trip. Doing them in\n * the other order leaves the dialog blank for as long as the check takes, on a\n * dialog whose first question is always \"what am I running?\".\n *\n * **A failed check is not a current result.** A cached `current` status can only\n * be shown as up to date after the latest check succeeds; a failed check remains\n * retryable and suppresses that claim.\n *\n * **Errors are not always `Error`s.** An adapter can reject with a string or a\n * structured safe message. Unknown object fields are never serialized into the\n * UI; a generic fallback is shown instead.\n *\n * The adapter's `isDesktopRuntime` gate exists because an update is a desktop\n * concern: a browser build has no installer, and the honest thing to show is that\n * updates are available in the desktop application rather than a disabled button\n * with no reason.\n */\n\n/** The phase an update is in. The union is the state machine. */\nexport type UpdatePhase =\n | 'idle'\n | 'checking'\n | 'current'\n | 'available'\n | 'downloading'\n | 'installing'\n | 'installed'\n | 'cancelling'\n | 'cancelled'\n | 'unavailable'\n | 'failed'\n\n/** A snapshot of the updater. Every field the dialog renders, and nothing else. */\nexport type UpdateState = Readonly<{\n phase: UpdatePhase\n /** The version currently installed. */\n currentVersion: string\n /** The version that can be installed, when one can. */\n availableVersion?: string | null\n /** A changelog for the installed channel, as markdown. */\n changelog?: string\n /** Notes for the available release, as markdown. */\n releaseNotes?: string | null\n /** The available release's date, as an ISO string. */\n releaseDate?: string | null\n /** Bytes downloaded so far, during `downloading`. */\n downloadedBytes?: number\n /** Total bytes, when the server sent a length. */\n totalBytes?: number | null\n /** Set when `phase` is `failed`, and sometimes when it is not. */\n error?: string | null\n /** A URL for the release's page. */\n releaseUrl?: string | null\n /** True when the application must restart to finish. */\n restartRequired?: boolean\n}>\n\n/**\n * The updater, as the application exposes it. Three calls, each answering with a\n * full snapshot rather than a delta — an updater's state is small, and a snapshot\n * cannot drift from the shell's own view of it.\n */\nexport type UpdateAdapter = Readonly<{\n /** The current state, without contacting the release channel. */\n getStatus(): Promise<UpdateState>\n /** Ask the release channel, and answer with what it found. */\n check(): Promise<UpdateState>\n /**\n * Download and apply `expectedVersion`.\n *\n * The argument is the version the caller believes is available, so the updater\n * can refuse a request that raced a newer release rather than installing the\n * wrong one.\n */\n install(expectedVersion: string): Promise<UpdateState>\n /** Optional native cancellation, available only while work is in flight. */\n cancel?(): Promise<UpdateState>\n /** Enable status polling during native work; omit for push-driven adapters. */\n pollIntervalMs?: number\n /** Route external links through the native shell when needed. */\n openExternal?(url: string): Promise<void>\n /** False in a browser build, where there is no installer to drive. */\n isDesktopRuntime(): boolean\n}>\n\nexport type UpdateDialogProps = {\n adapter: UpdateAdapter\n /** The application's name, used in the title and the copy. */\n appName?: string\n /** The actual desktop application icon, supplied by its host. */\n appIcon?: string\n /** Complete build-time history, also available before the native status arrives. */\n changelog?: string\n /** Shown before the first status arrives, so the dialog is never blank. */\n fallbackVersion?: string\n /** Copy for the adapter's non-desktop case. */\n desktopOnlyMessage?: string\n /** A controlled open state. Omit for the trigger to manage its own. */\n open?: boolean\n /**\n * Start open, uncontrolled — for a caller that opens the dialog because it found\n * something (\"an update is available\") rather than because the user asked. The\n * trigger is still rendered, so the dialog is reachable again after closing.\n */\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n /**\n * Supplies a stable external control to focus when a controlled dialog closes.\n * Useful when a menu or other layer closes before this dialog opens; when omitted,\n * the element focused immediately before the dialog opens is used when available.\n */\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n /** Render only the panel, for a caller that provides its own dialog. */\n class?: string\n}\n\nfunction messageText(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const message = value.trim()\n return message && message !== '[object Object]' ? message : undefined\n}\n\nfunction errorMessage(caught: unknown, fallback: string): string {\n if (caught instanceof Error) return messageText(caught.message) ?? fallback\n const plainMessage = messageText(caught)\n if (plainMessage) return plainMessage\n if (!caught || typeof caught !== 'object') return fallback\n\n const record = caught as { error?: unknown; safe?: unknown }\n const safe = record.safe as { message?: unknown } | null | undefined\n const nestedError = record.error as { safe?: { message?: unknown } | null } | null | undefined\n return messageText(safe?.message) ?? messageText(nestedError?.safe?.message) ?? fallback\n}\n\n/**\n * The phases during which the updater is working. `downloading` and `installing`\n * are included because the shell can be in either while the dialog is open, and\n * offering an enabled Install button during a download is how a double-install\n * happens.\n */\nfunction isBusy(state: UpdateState | null): boolean {\n return (\n state?.phase === 'checking' ||\n state?.phase === 'downloading' ||\n state?.phase === 'installing' ||\n state?.phase === 'cancelling'\n )\n}\n\nexport function UpdateDialog(props: UpdateDialogProps) {\n const [local] = splitProps(props, [\n 'adapter',\n 'appName',\n 'appIcon',\n 'changelog',\n 'fallbackVersion',\n 'desktopOnlyMessage',\n 'open',\n 'defaultOpen',\n 'onOpenChange',\n 'restoreFocusRef',\n 'class',\n ])\n\n const [uncontrolledOpen, setUncontrolledOpen] = createSignal(local.defaultOpen ?? false)\n const open = () => local.open ?? uncontrolledOpen()\n const setOpen = (next: boolean) => {\n if (local.open === undefined) setUncontrolledOpen(next)\n local.onOpenChange?.(next)\n }\n\n const focusRestoration = createDialogFocusRestoration({\n open,\n restoreFocusRef: local.restoreFocusRef,\n })\n\n const appName = () => local.appName ?? 'the application'\n const desktop = () => local.adapter.isDesktopRuntime()\n const [state, setState] = createSignal<UpdateState | null>(null)\n const [busy, setBusy] = createSignal(false)\n const [error, setError] = createSignal('')\n const [checkFailed, setCheckFailed] = createSignal(false)\n const [cancelPending, setCancelPending] = createSignal(false)\n let lifecycleEpoch = 0\n let activeOpenEpoch: number | undefined\n let disposed = false\n\n onCleanup(() => {\n disposed = true\n activeOpenEpoch = undefined\n lifecycleEpoch += 1\n })\n\n const loadStatus = async (isCurrent: () => boolean = () => !disposed) => {\n if (!desktop() || !isCurrent()) return\n try {\n const status = await local.adapter.getStatus()\n const previous = state()\n const hasActionableSnapshot = (candidate: UpdateState | null) =>\n candidate?.phase === 'available' || isBusy(candidate)\n const preservesSnapshot =\n previous?.phase === 'available'\n ? status.phase === 'available' || isBusy(status)\n : isBusy(previous) && isBusy(status)\n if (\n isCurrent() &&\n !(checkFailed() && hasActionableSnapshot(previous) && !preservesSnapshot)\n ) {\n setState(status)\n }\n } catch (caught) {\n if (isCurrent()) setError(errorMessage(caught, 'Version status is unavailable'))\n }\n }\n\n onMount(() => {\n if (desktop() && !open()) {\n const epoch = lifecycleEpoch\n void loadStatus(() => !disposed && lifecycleEpoch === epoch)\n }\n })\n\n const failCheck = (caught: unknown, fallback: string) => {\n const message = errorMessage(caught, fallback)\n setCheckFailed(true)\n setError(message)\n }\n\n const applyCheckResult = (next: UpdateState) => {\n if (next.phase === 'failed') {\n const current = state()\n if (!current) setState(next)\n failCheck(next.error, 'Could not check for updates')\n return\n }\n setState(next)\n setCheckFailed(false)\n setError('')\n }\n\n const check = async () => {\n if (!desktop()) {\n setError(local.desktopOnlyMessage ?? `Update checks are available from the desktop app.`)\n return\n }\n const epoch = activeOpenEpoch\n const isCurrent = () =>\n !disposed &&\n epoch !== undefined &&\n activeOpenEpoch === epoch &&\n lifecycleEpoch === epoch &&\n open()\n if (!isCurrent()) return\n setBusy(true)\n setError('')\n setCheckFailed(false)\n try {\n const checked = await local.adapter.check()\n if (isCurrent()) applyCheckResult(checked)\n } catch (caught) {\n if (isCurrent()) {\n failCheck(caught, 'Could not check for updates')\n await loadStatus(isCurrent)\n }\n } finally {\n if (isCurrent()) setBusy(false)\n }\n }\n\n /**\n * Status first, then the check — and an `active` flag, because the dialog can\n * close while the check is in flight and a late `setState` would write into a\n * disposed scope.\n */\n createEffect(() => {\n if (!open() || !desktop()) {\n setCancelPending(false)\n if (activeOpenEpoch !== undefined) {\n activeOpenEpoch = undefined\n lifecycleEpoch += 1\n }\n return\n }\n const epoch = ++lifecycleEpoch\n activeOpenEpoch = epoch\n let active = true\n const isCurrent = () =>\n active && !disposed && activeOpenEpoch === epoch && lifecycleEpoch === epoch && open()\n onCleanup(() => {\n active = false\n if (activeOpenEpoch === epoch) {\n activeOpenEpoch = undefined\n lifecycleEpoch += 1\n }\n })\n setError('')\n setCheckFailed(false)\n setCancelPending(false)\n setBusy(true)\n void (async () => {\n try {\n const current = await local.adapter.getStatus()\n if (!isCurrent()) return\n setState(current)\n const checked = await local.adapter.check()\n if (isCurrent()) applyCheckResult(checked)\n } catch (caught) {\n if (isCurrent()) failCheck(caught, 'Could not check for updates')\n } finally {\n if (isCurrent()) setBusy(false)\n }\n })()\n })\n\n const install = async () => {\n const version = state()?.availableVersion\n const epoch = activeOpenEpoch\n const isCurrent = () =>\n !disposed &&\n epoch !== undefined &&\n activeOpenEpoch === epoch &&\n lifecycleEpoch === epoch &&\n open()\n if (!version || !isCurrent()) return\n setBusy(true)\n setError('')\n setState((current) =>\n current ? { ...current, phase: 'downloading', downloadedBytes: 0, totalBytes: null } : current\n )\n try {\n const next = await local.adapter.install(version)\n if (!isCurrent()) return\n setState(\n cancelPending() && ['downloading', 'installing'].includes(next.phase)\n ? { ...next, phase: 'cancelling' }\n : next\n )\n // A refused install answers with a normal payload whose phase is `failed`.\n // Without this the click looked like nothing happened.\n if (next.phase === 'failed') {\n setError(errorMessage(next.error, 'Update installation failed'))\n } else {\n setCheckFailed(false)\n }\n } catch (caught) {\n if (!isCurrent()) return\n setError(errorMessage(caught, 'Update installation failed'))\n await loadStatus(isCurrent)\n } finally {\n if (isCurrent()) setBusy(false)\n }\n }\n\n // Poll only an open, active native operation. Epoch ownership prevents a late\n // status response from replacing a reopened dialog's newer snapshot.\n createEffect(() => {\n const phase = state()?.phase\n if (\n !open() ||\n !desktop() ||\n !local.adapter.pollIntervalMs ||\n !['downloading', 'installing', 'cancelling'].includes(phase ?? '')\n )\n return\n const epoch = activeOpenEpoch\n let active = true\n let requestInFlight = false\n const timer = window.setInterval(\n () => {\n if (requestInFlight) return\n requestInFlight = true\n void (async () => {\n try {\n const next = await local.adapter.getStatus()\n if (!active || disposed || !open() || activeOpenEpoch !== epoch) return\n setState(\n cancelPending() && ['downloading', 'installing'].includes(next.phase)\n ? { ...next, phase: 'cancelling' }\n : next\n )\n if (next.phase === 'failed')\n setError(errorMessage(next.error, 'Update installation failed'))\n } catch (caught) {\n if (active && !disposed && activeOpenEpoch === epoch)\n setError(errorMessage(caught, 'Update progress is unavailable'))\n } finally {\n requestInFlight = false\n }\n })()\n },\n Math.max(250, local.adapter.pollIntervalMs)\n )\n onCleanup(() => {\n active = false\n window.clearInterval(timer)\n })\n })\n\n const cancel = async () => {\n if (!local.adapter.cancel || cancelPending() || state()?.phase === 'cancelling') return\n const epoch = activeOpenEpoch\n setError('')\n setCancelPending(true)\n setState((current) => (current ? { ...current, phase: 'cancelling' } : current))\n try {\n const next = await local.adapter.cancel()\n if (!disposed && open() && activeOpenEpoch === epoch) setState(next)\n } catch (caught) {\n if (!disposed && open() && activeOpenEpoch === epoch) {\n setError(errorMessage(caught, 'Could not cancel the update'))\n await loadStatus(() => !disposed && open() && activeOpenEpoch === epoch)\n }\n } finally {\n if (!disposed && open() && activeOpenEpoch === epoch) setCancelPending(false)\n }\n }\n\n const openRelease = async (url: string) => {\n try {\n if (local.adapter.openExternal) await local.adapter.openExternal(url)\n else window.open(url, '_blank', 'noopener,noreferrer')\n } catch (caught) {\n if (!disposed) setError(errorMessage(caught, 'Could not open the release page'))\n }\n }\n\n const changelog = createMemo(() =>\n plainTextFromMarkdown(state()?.changelog || local.changelog || '')\n )\n const notes = () => {\n const value = state()?.releaseNotes\n return value ? plainTextFromMarkdown(value) : ''\n }\n const working = () => busy() || cancelPending() || isBusy(state())\n const isCurrent = () => state()?.phase === 'current' && !error() && !checkFailed() && !working()\n\n const triggerLabel = () => {\n const current = state()\n const fallback = `v${local.fallbackVersion ?? '0.1.0'}`\n if (checkFailed()) return `Version ${current?.currentVersion || fallback} · Retry`\n if (!current) return `${appName()} ${fallback}`\n switch (current.phase) {\n case 'checking':\n return 'Checking for updates…'\n case 'available':\n return current.availableVersion\n ? `Update v${current.availableVersion} available`\n : 'Update available'\n case 'downloading':\n case 'installing':\n return 'Installing update…'\n case 'failed':\n return `Version ${current.currentVersion || fallback} · Retry`\n default:\n return `${appName()} v${current.currentVersion || fallback}`\n }\n }\n\n const progressValue = () => {\n const current = state()\n if (!current?.totalBytes || !current.downloadedBytes) return null\n return Math.min(100, Math.round((current.downloadedBytes / current.totalBytes) * 100))\n }\n\n return (\n <Dialog open={open()} onOpenChange={setOpen}>\n <Show when={local.open === undefined}>\n <DialogTrigger\n as={Button}\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Open version and updates\"\n aria-haspopup=\"dialog\"\n >\n <Show when={state()?.phase === 'available'} fallback={<RefreshCw aria-hidden=\"true\" />}>\n <Sparkles aria-hidden=\"true\" />\n </Show>\n {triggerLabel()}\n </DialogTrigger>\n </Show>\n\n <DialogContent\n class={cn('max-w-3xl', local.class)}\n onKeyDown={(event: KeyboardEvent) => {\n // An explanatory tooltip must not consume the popup's close shortcut,\n // including while its exit animation still owns Kobalte's top layer.\n if (event.key === 'Escape' && !event.defaultPrevented) {\n event.preventDefault()\n setOpen(false)\n }\n }}\n onOpenAutoFocus={(event) => {\n focusRestoration.onOpenAutoFocus(event)\n // Start at the readable panel rather than opening an action's tooltip.\n if (!event.defaultPrevented && event.currentTarget instanceof HTMLElement) {\n event.preventDefault()\n event.currentTarget.focus({ preventScroll: true })\n }\n }}\n onCloseAutoFocus={focusRestoration.onCloseAutoFocus}\n >\n <DialogHeader>\n <div class=\"flex items-center gap-3\">\n <Show\n when={local.appIcon}\n fallback={<Monitor class=\"size-10 text-primary\" aria-hidden=\"true\" />}\n >\n {(icon) => <img src={icon()} alt=\"\" class=\"size-10\" aria-hidden=\"true\" />}\n </Show>\n <div>\n <DialogTitle>Version &amp; updates</DialogTitle>\n <DialogDescription>\n Keep {appName()} current and review what changed in each release.\n </DialogDescription>\n </div>\n </div>\n </DialogHeader>\n\n <div class=\"flex min-h-0 flex-col gap-5 overflow-y-auto p-6\">\n <section\n class=\"rounded-xl border border-border bg-background/45 p-4\"\n aria-label=\"Version status\"\n >\n <div class=\"flex flex-wrap items-start justify-between gap-4\">\n <div class=\"flex flex-col gap-1\">\n <p class=\"text-2xs font-semibold tracking-widest text-muted-foreground uppercase\">\n Installed version\n </p>\n <Heading as=\"p\" size=\"page\" tone=\"foreground\">\n v{state()?.currentVersion || local.fallbackVersion || '0.1.0'}\n </Heading>\n <p class=\"text-sm text-muted-foreground\">\n <Show\n when={isCurrent()}\n fallback={\n <Show\n when={state()?.phase === 'available' && state()?.availableVersion}\n fallback={\n state()?.phase === 'unavailable'\n ? 'No signed package is published for this platform.'\n : state()?.phase === 'cancelled'\n ? 'Update cancelled. You can retry when ready.'\n : desktop()\n ? 'Check the release channel for the latest signed build.'\n : (local.desktopOnlyMessage ??\n `Open this dialog inside the desktop app to check for updates.`)\n }\n >\n {`A newer release, v${state()?.availableVersion}, is ready.`}\n </Show>\n }\n >\n You are running the latest release.\n </Show>\n </p>\n </div>\n <div class=\"flex flex-col items-end gap-2\">\n <ActionButton\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n tooltip=\"Check the release channel for the latest signed app version.\"\n disabled={!desktop() || working()}\n onClick={() => void check()}\n >\n <Show when={working()} fallback={<RefreshCw aria-hidden=\"true\" />}>\n <LoaderCircle class=\"animate-spin\" aria-hidden=\"true\" />\n </Show>\n {checkFailed() ? 'Retry update check' : 'Check latest version'}\n </ActionButton>\n {/* The up-to-date confirmation reads as the button's outcome,\n so it sits directly beneath it rather than floating as a\n full-width row between sections. */}\n <Show when={isCurrent()}>\n <p class=\"text-foreground flex items-center gap-2 text-sm\" role=\"status\">\n <Check class=\"size-4 text-success\" aria-hidden=\"true\" />\n {appName()} is up to date.\n </p>\n </Show>\n </div>\n </div>\n </section>\n\n <Show\n when={\n state()?.availableVersion &&\n state()?.phase !== 'installed' &&\n state()?.phase !== 'unavailable'\n }\n >\n <section\n class=\"rounded-xl border border-primary/35 bg-primary-subtle p-4\"\n aria-label=\"Available update\"\n >\n <div class=\"flex flex-wrap items-start justify-between gap-4\">\n <div class=\"flex flex-col gap-1\">\n <p class=\"flex items-center gap-2 text-sm font-semibold\">\n <Sparkles class=\"size-4 text-primary\" aria-hidden=\"true\" />\n Version {state()?.availableVersion}{' '}\n {['downloading', 'installing', 'cancelling'].includes(state()?.phase ?? '')\n ? 'is being prepared'\n : 'is ready'}\n </p>\n <p class=\"text-sm text-muted-foreground\">\n The signed installer is verified before {appName()} restarts.\n </p>\n <Show when={formatReleaseDate(state()?.releaseDate ?? null)}>\n {(released) => (\n <p class=\"text-xs text-muted-foreground\">Released {released()}</p>\n )}\n </Show>\n </div>\n <ActionButton\n type=\"button\"\n size=\"sm\"\n tooltip={`Download the signed update and restart ${appName()}.`}\n disabled={working()}\n onClick={() => void install()}\n >\n <Show when={working()} fallback={<Download aria-hidden=\"true\" />}>\n <LoaderCircle class=\"animate-spin\" aria-hidden=\"true\" />\n </Show>\n Install and restart\n </ActionButton>\n </div>\n </section>\n </Show>\n\n {/*\n Progress with both numbers: a bar alone does not distinguish a stalled\n download from a slow one, and \"12.4 MB of 48.1 MB\" does.\n */}\n <Show\n when={\n state()?.phase === 'downloading' ||\n state()?.phase === 'installing' ||\n state()?.phase === 'cancelling'\n }\n >\n <section class=\"grid gap-2\" aria-label=\"Update progress\">\n <Progress\n value={progressValue() ?? undefined}\n aria-label={\n state()?.phase === 'installing' ? 'Installing update' : 'Downloading update'\n }\n />\n <p class=\"text-xs text-muted-foreground\" role=\"status\">\n <Show\n when={state()?.phase === 'installing'}\n fallback={\n <Show when={progressValue() !== null} fallback=\"Downloading…\">\n {`${formatBytes(state()?.downloadedBytes ?? 0)} of ${formatBytes(\n state()?.totalBytes ?? 0\n )} · ${progressValue()}%`}\n </Show>\n }\n >\n Applying the update…\n </Show>\n </p>\n <Show when={local.adapter.cancel}>\n <ActionButton\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n tooltip=\"Stop the current update download or installation.\"\n disabled={cancelPending() || state()?.phase === 'cancelling'}\n onClick={() => void cancel()}\n >\n <CircleStop aria-hidden=\"true\" />\n {cancelPending() || state()?.phase === 'cancelling'\n ? 'Cancelling…'\n : 'Cancel update'}\n </ActionButton>\n </Show>\n </section>\n </Show>\n\n <Show when={state()?.phase === 'installed'}>\n <p class=\"text-foreground flex items-center gap-2 text-sm\" role=\"status\">\n <Check class=\"size-4 text-success\" aria-hidden=\"true\" />\n <Show when={state()?.restartRequired} fallback=\"The update is applied.\">\n Restart {appName()} to finish the update.\n </Show>\n </p>\n </Show>\n\n <Show when={error()}>\n <p\n class=\"text-foreground rounded-lg border border-destructive/35 bg-destructive-subtle px-3 py-2 text-sm\"\n role=\"alert\"\n >\n {error()}\n </p>\n </Show>\n\n <Show when={notes()}>\n <div class=\"flex flex-col gap-2\">\n <div class=\"flex items-center gap-2\">\n <h2 id=\"update-release-notes\" class=\"text-sm font-semibold text-foreground\">\n What changed in this release\n </h2>\n <Badge variant=\"subtle\" size=\"sm\">\n v{state()?.availableVersion}\n </Badge>\n </div>\n {/* A long text block with no focusable descendant: it needs its own tab\n stop, named by the heading above it, or a keyboard user cannot\n scroll it (`scrollable-region-focusable`). */}\n <div\n class=\"max-h-52 overflow-y-auto rounded-xl border border-border bg-background/45 p-4 font-mono text-xs leading-5 whitespace-pre-wrap text-muted-foreground\"\n role=\"region\"\n aria-labelledby=\"update-release-notes\"\n tabindex=\"0\"\n >\n {notes()}\n </div>\n </div>\n </Show>\n\n <Show when={changelog()}>\n <div class=\"flex flex-col gap-2\">\n <div class=\"flex items-center gap-2\">\n <h2 id=\"update-changelog\" class=\"text-sm font-semibold text-foreground\">\n Installed changelog\n </h2>\n {/* The version pill identifies which build's history this is —\n the same treatment the available-update heading carries. */}\n <Badge variant=\"subtle\" size=\"sm\">\n v{state()?.currentVersion || local.fallbackVersion || '0.1.0'}\n </Badge>\n </div>\n <p class=\"text-xs text-muted-foreground\">\n All versions and updates included with this installation.\n </p>\n {/* A long text block with no focusable descendant: it needs its own tab\n stop, named by the heading above it, or a keyboard user cannot\n scroll it (`scrollable-region-focusable`). */}\n <div\n class=\"max-h-72 overflow-y-auto rounded-xl border border-border bg-background/45 p-4 font-mono text-xs leading-5 whitespace-pre-wrap text-muted-foreground\"\n role=\"region\"\n aria-labelledby=\"update-changelog\"\n tabindex=\"0\"\n >\n {changelog()}\n </div>\n </div>\n </Show>\n </div>\n\n <DialogFooter>\n <Show when={state()?.releaseUrl}>\n {(url) => (\n <ActionButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n tooltip=\"Open the release history in your browser.\"\n // `noopener,noreferrer` because the release page is a different\n // origin and must not get a handle on this window.\n onClick={() => void openRelease(url())}\n >\n <ExternalLink aria-hidden=\"true\" />\n View releases\n </ActionButton>\n )}\n </Show>\n <DialogClose as={Button} variant=\"outline\" size=\"sm\">\n Close\n </DialogClose>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqLA,SAASuE,YAAYC,OAAoC;CACvD,IAAI,OAAOA,UAAU,UAAU,OAAOC,KAAAA;CACtC,MAAMC,UAAUF,MAAMG,KAAK;CAC3B,OAAOD,WAAWA,YAAY,oBAAoBA,UAAUD,KAAAA;AAC9D;AAEA,SAASG,aAAaC,QAAiBC,UAA0B;CAC/D,IAAID,kBAAkBE,OAAO,OAAOR,YAAYM,OAAOH,OAAO,KAAKI;CACnE,MAAME,eAAeT,YAAYM,MAAM;CACvC,IAAIG,cAAc,OAAOA;CACzB,IAAI,CAACH,UAAU,OAAOA,WAAW,UAAU,OAAOC;CAElD,MAAMG,SAASJ;CACf,MAAMK,OAAOD,OAAOC;CACpB,MAAMC,cAAcF,OAAOpC;CAC3B,OAAO0B,YAAYW,MAAMR,OAAO,KAAKH,YAAYY,aAAaD,MAAMR,OAAO,KAAKI;AAClF;;;;;;;AAQA,SAASM,OAAOC,OAAoC;CAClD,OACEA,OAAOhD,UAAU,cACjBgD,OAAOhD,UAAU,iBACjBgD,OAAOhD,UAAU,gBACjBgD,OAAOhD,UAAU;AAErB;AAEA,SAAgBiD,aAAaC,OAA0B;CACrD,MAAM,CAACC,SAASlF,WAAWiF,OAAO;EAChC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAAO,CACR;CAED,MAAM,CAACE,kBAAkBC,uBAAuBxF,aAAasF,MA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,MAAM,CAAC,EAAEvC;QAAU;QAAA0F,WAC3B/E,QAAG8E,gBACFrH,cAAY;SACX2J,MAAI;SACJlC,SAAO;SACPC,MAAI;SACJkC,SAAO;SAGPE,eAAe,KAAKhD,YAAYvE,IAAI,CAAC;SAAC,IAAA+E,WAAA;UAAA,OAAA,CAAAD,gBAErC5H,cAAY,EAAA,eAAA,OAAA,CAAA,GAAA,eAAA;SAAA;QAAA,CAAA;OAGhB,CAAA,GAAA4H,gBAEFnH,aAAW;QAACsH,IAAIzH;QAAQ0H,SAAO;QAAWC,MAAI;QAAAJ,UAAA;OAAA,CAAA,CAAA;MAAA,EAAA,CAAA;KAAA;IAAA;GAAA,CAAA,CAAA;EAAA;CAAA,CAAA;AAOzD"}
1
+ {"version":3,"file":"update-dialog.js","names":["createEffect","createMemo","createSignal","onCleanup","onMount","Show","splitProps","Accessor","JSX","Check","CircleStop","Download","ExternalLink","LoaderCircle","Monitor","RefreshCw","Sparkles","Badge","Button","ActionButton","Dialog","DialogClose","DialogContent","DialogDescription","DialogFooter","DialogHeader","DialogTitle","DialogTrigger","createDialogFocusRestoration","Progress","Heading","cn","formatBytes","formatReleaseDate","plainTextFromMarkdown","UpdatePhase","UpdateState","Readonly","phase","currentVersion","availableVersion","changelog","releaseNotes","releaseDate","downloadedBytes","totalBytes","error","releaseUrl","restartRequired","UpdateAdapter","getStatus","Promise","check","install","expectedVersion","cancel","pollIntervalMs","openExternal","url","isDesktopRuntime","ChannelControlActions","disabled","recheck","beforeCheck","UpdateDialogProps","adapter","appName","appIcon","fallbackVersion","desktopOnlyMessage","channelControl","actions","Element","open","defaultOpen","onOpenChange","restoreFocusRef","HTMLElement","class","messageText","value","undefined","message","trim","errorMessage","caught","fallback","Error","plainMessage","record","safe","nestedError","isBusy","state","UpdateDialog","props","local","uncontrolledOpen","setUncontrolledOpen","setOpen","next","focusRestoration","desktop","setState","busy","setBusy","setError","checkFailed","setCheckFailed","cancelPending","setCancelPending","lifecycleEpoch","activeOpenEpoch","channelCheckUnconfirmed","disposed","loadStatus","isCurrent","status","previous","hasActionableSnapshot","candidate","ignoresUnconfirmedChannelSnapshot","preservesSnapshot","epoch","failCheck","applyCheckResult","preserveOnFailure","current","clearStaleOffer","working","discardStaleOffer","channelSaved","checked","active","version","includes","requestInFlight","timer","window","setInterval","Math","max","clearInterval","openRelease","notes","channelControlDisabled","recheckChannel","triggerLabel","progressValue","min","round","_$createComponent","children","when","as","variant","size","_$memo","onKeyDown","event","KeyboardEvent","key","defaultPrevented","preventDefault","onOpenAutoFocus","currentTarget","focus","preventScroll","onCloseAutoFocus","_el$","_tmpl$","_el$2","firstChild","_$insert","icon","_el$34","_tmpl$0","_$effect","_$setAttribute","_el$3","_tmpl$9","_el$4","_el$5","_el$6","_el$7","_el$8","nextSibling","_el$9","tone","type","tooltip","onClick","_el$0","_tmpl$2","_el$1","_el$35","_tmpl$1","_el$10","_tmpl$3","_el$11","_el$12","_el$13","_el$14","_el$16","_el$15","_el$17","_el$18","_el$20","_el$19","released","_el$36","_tmpl$10","_el$37","_el$21","_tmpl$4","_el$22","aria-label","_el$23","_tmpl$5","_el$24","_tmpl$6","_el$25","_tmpl$7","_el$26","_el$27","_el$28","_el$29","_tmpl$8","_el$30","_el$31","_el$32","_el$33","_$createComponent","_$memo","_$setAttribute"],"sources":["../../../../src/components/composites/update-dialog/update-dialog.tsx"],"sourcesContent":["import {\n createEffect,\n createMemo,\n createSignal,\n onCleanup,\n onMount,\n Show,\n splitProps,\n} from 'solid-js'\nimport type { Accessor, JSX } from 'solid-js'\nimport {\n Check,\n CircleStop,\n Download,\n ExternalLink,\n LoaderCircle,\n Monitor,\n RefreshCw,\n Sparkles,\n} from 'lucide-solid'\nimport { Badge } from '../../ui/badge'\nimport { Button } from '../../ui/button'\nimport { ActionButton } from '../action-button'\nimport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from '../../ui/dialog'\nimport { createDialogFocusRestoration } from '../../ui/dialog/dialog'\nimport { Progress } from '../../ui/progress'\nimport { Heading } from '../../ui/typography'\nimport { cn } from '#lib/utils'\nimport { formatBytes, formatReleaseDate, plainTextFromMarkdown } from '#lib/version-notes'\n\n/**\n * UpdateDialog.\n *\n * A software-update surface: the installed version, whether a newer release\n * exists, a download that shows its progress, and the release notes for what is\n * about to arrive.\n *\n * The transport is an adapter, because an update is the one thing a component\n * library genuinely cannot implement: it is signed, downloaded and applied by the\n * application's own updater, and the mechanism differs per shell. What *is*\n * general is the phase machine and the way each phase is presented — and that is\n * where the hard-won detail lives:\n *\n * **A refused install answers with a normal payload, not a rejection.** adea's\n * shell returns a status whose phase is `failed` when a download or an extract\n * fails, rather than throwing. Without handling that, clicking install looked like\n * nothing happened at all — the button spun, the phase never changed, and the\n * error sat unread in a field nobody rendered. The `failed` phase after an install\n * is therefore surfaced as an error, explicitly.\n *\n * **Busy is derived from the snapshot as well as from the click.** An update can\n * be downloading while the dialog is open — started before it opened, or by the\n * shell's own poll — so a local `busy` flag alone would offer an enabled Install\n * button mid-download.\n *\n * **Opening the dialog loads status first, then checks.** Status paints the\n * installed version immediately; the check is a network round trip. Doing them in\n * the other order leaves the dialog blank for as long as the check takes, on a\n * dialog whose first question is always \"what am I running?\".\n *\n * **A failed check is not a current result.** A cached `current` status can only\n * be shown as up to date after the latest check succeeds; a failed check remains\n * retryable and suppresses that claim.\n *\n * **Errors are not always `Error`s.** An adapter can reject with a string or a\n * structured safe message. Unknown object fields are never serialized into the\n * UI; a generic fallback is shown instead.\n *\n * The adapter's `isDesktopRuntime` gate exists because an update is a desktop\n * concern: a browser build has no installer, and the honest thing to show is that\n * updates are available in the desktop application rather than a disabled button\n * with no reason.\n */\n\n/** The phase an update is in. The union is the state machine. */\nexport type UpdatePhase =\n | 'idle'\n | 'checking'\n | 'current'\n | 'available'\n | 'downloading'\n | 'installing'\n | 'installed'\n | 'cancelling'\n | 'cancelled'\n | 'unavailable'\n | 'failed'\n\n/** A snapshot of the updater. Every field the dialog renders, and nothing else. */\nexport type UpdateState = Readonly<{\n phase: UpdatePhase\n /** The version currently installed. */\n currentVersion: string\n /** The version that can be installed, when one can. */\n availableVersion?: string | null\n /** A changelog for the installed channel, as markdown. */\n changelog?: string\n /** Notes for the available release, as markdown. */\n releaseNotes?: string | null\n /** The available release's date, as an ISO string. */\n releaseDate?: string | null\n /** Bytes downloaded so far, during `downloading`. */\n downloadedBytes?: number\n /** Total bytes, when the server sent a length. */\n totalBytes?: number | null\n /** Set when `phase` is `failed`, and sometimes when it is not. */\n error?: string | null\n /** A URL for the release's page. */\n releaseUrl?: string | null\n /** True when the application must restart to finish. */\n restartRequired?: boolean\n}>\n\n/**\n * The updater, as the application exposes it. Three calls, each answering with a\n * full snapshot rather than a delta — an updater's state is small, and a snapshot\n * cannot drift from the shell's own view of it.\n */\nexport type UpdateAdapter = Readonly<{\n /** The current state, without contacting the release channel. */\n getStatus(): Promise<UpdateState>\n /** Ask the release channel, and answer with what it found. */\n check(): Promise<UpdateState>\n /**\n * Download and apply `expectedVersion`.\n *\n * The argument is the version the caller believes is available, so the updater\n * can refuse a request that raced a newer release rather than installing the\n * wrong one.\n */\n install(expectedVersion: string): Promise<UpdateState>\n /** Optional native cancellation, available only while work is in flight. */\n cancel?(): Promise<UpdateState>\n /** Enable status polling during native work; omit for push-driven adapters. */\n pollIntervalMs?: number\n /** Route external links through the native shell when needed. */\n openExternal?(url: string): Promise<void>\n /** False in a browser build, where there is no installer to drive. */\n isDesktopRuntime(): boolean\n}>\n\ntype ChannelControlActions = Readonly<{\n /** Disabled while the app is checking, downloading, installing, or saving a channel. */\n disabled: Accessor<boolean>\n /** Persist a channel change, then check that channel without retaining a stale offer. */\n recheck(beforeCheck?: () => Promise<void>): Promise<void>\n}>\n\nexport type UpdateDialogProps = {\n adapter: UpdateAdapter\n /** The application's name, used in the title and the copy. */\n appName?: string\n /** The actual desktop application icon, supplied by its host. */\n appIcon?: string\n /** Complete build-time history, also available before the native status arrives. */\n changelog?: string\n /** Shown before the first status arrives, so the dialog is never blank. */\n fallbackVersion?: string\n /** Copy for the adapter's non-desktop case. */\n desktopOnlyMessage?: string\n /**\n * Optional host-owned release-channel control, rendered in the version status\n * card. The host owns its accessible label and calls `recheck` after a selection;\n * the optional callback persists that selection before the dialog checks it.\n */\n channelControl?: (actions: ChannelControlActions) => JSX.Element\n /** A controlled open state. Omit for the trigger to manage its own. */\n open?: boolean\n /**\n * Start open, uncontrolled — for a caller that opens the dialog because it found\n * something (\"an update is available\") rather than because the user asked. The\n * trigger is still rendered, so the dialog is reachable again after closing.\n */\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n /**\n * Supplies a stable external control to focus when a controlled dialog closes.\n * Useful when a menu or other layer closes before this dialog opens; when omitted,\n * the element focused immediately before the dialog opens is used when available.\n */\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n /** Render only the panel, for a caller that provides its own dialog. */\n class?: string\n}\n\nfunction messageText(value: unknown): string | undefined {\n if (typeof value !== 'string') return undefined\n const message = value.trim()\n return message && message !== '[object Object]' ? message : undefined\n}\n\nfunction errorMessage(caught: unknown, fallback: string): string {\n if (caught instanceof Error) return messageText(caught.message) ?? fallback\n const plainMessage = messageText(caught)\n if (plainMessage) return plainMessage\n if (!caught || typeof caught !== 'object') return fallback\n\n const record = caught as { error?: unknown; safe?: unknown }\n const safe = record.safe as { message?: unknown } | null | undefined\n const nestedError = record.error as { safe?: { message?: unknown } | null } | null | undefined\n return messageText(safe?.message) ?? messageText(nestedError?.safe?.message) ?? fallback\n}\n\n/**\n * The phases during which the updater is working. `downloading` and `installing`\n * are included because the shell can be in either while the dialog is open, and\n * offering an enabled Install button during a download is how a double-install\n * happens.\n */\nfunction isBusy(state: UpdateState | null): boolean {\n return (\n state?.phase === 'checking' ||\n state?.phase === 'downloading' ||\n state?.phase === 'installing' ||\n state?.phase === 'cancelling'\n )\n}\n\nexport function UpdateDialog(props: UpdateDialogProps) {\n const [local] = splitProps(props, [\n 'adapter',\n 'appName',\n 'appIcon',\n 'changelog',\n 'fallbackVersion',\n 'desktopOnlyMessage',\n 'channelControl',\n 'open',\n 'defaultOpen',\n 'onOpenChange',\n 'restoreFocusRef',\n 'class',\n ])\n\n const [uncontrolledOpen, setUncontrolledOpen] = createSignal(local.defaultOpen ?? false)\n const open = () => local.open ?? uncontrolledOpen()\n const setOpen = (next: boolean) => {\n if (local.open === undefined) setUncontrolledOpen(next)\n local.onOpenChange?.(next)\n }\n\n const focusRestoration = createDialogFocusRestoration({\n open,\n restoreFocusRef: local.restoreFocusRef,\n })\n\n const appName = () => local.appName ?? 'the application'\n const desktop = () => local.adapter.isDesktopRuntime()\n const [state, setState] = createSignal<UpdateState | null>(null)\n const [busy, setBusy] = createSignal(false)\n const [error, setError] = createSignal('')\n const [checkFailed, setCheckFailed] = createSignal(false)\n const [cancelPending, setCancelPending] = createSignal(false)\n let lifecycleEpoch = 0\n let activeOpenEpoch: number | undefined\n let channelCheckUnconfirmed = false\n let disposed = false\n\n onCleanup(() => {\n disposed = true\n activeOpenEpoch = undefined\n lifecycleEpoch += 1\n })\n\n const loadStatus = async (isCurrent: () => boolean = () => !disposed) => {\n if (!desktop() || !isCurrent()) return\n try {\n const status = await local.adapter.getStatus()\n const previous = state()\n const hasActionableSnapshot = (candidate: UpdateState | null) =>\n candidate?.phase === 'available' || isBusy(candidate)\n const ignoresUnconfirmedChannelSnapshot =\n channelCheckUnconfirmed && hasActionableSnapshot(status)\n const preservesSnapshot =\n previous?.phase === 'available'\n ? status.phase === 'available' || isBusy(status)\n : isBusy(previous) && isBusy(status)\n if (\n isCurrent() &&\n !ignoresUnconfirmedChannelSnapshot &&\n !(checkFailed() && hasActionableSnapshot(previous) && !preservesSnapshot)\n ) {\n setState(status)\n }\n } catch (caught) {\n if (isCurrent()) setError(errorMessage(caught, 'Version status is unavailable'))\n }\n }\n\n onMount(() => {\n if (desktop() && !open()) {\n const epoch = lifecycleEpoch\n void loadStatus(() => !disposed && lifecycleEpoch === epoch)\n }\n })\n\n const failCheck = (caught: unknown, fallback: string) => {\n const message = errorMessage(caught, fallback)\n setCheckFailed(true)\n setError(message)\n }\n\n const applyCheckResult = (next: UpdateState, preserveOnFailure = true) => {\n if (next.phase === 'failed') {\n const current = state()\n if (!current || !preserveOnFailure) setState(next)\n failCheck(next.error, 'Could not check for updates')\n return\n }\n setState(next)\n setCheckFailed(false)\n setError('')\n }\n\n const check = async (\n beforeCheck?: () => Promise<void>,\n clearStaleOffer = beforeCheck !== undefined\n ) => {\n if (!desktop()) {\n setError(local.desktopOnlyMessage ?? `Update checks are available from the desktop app.`)\n return\n }\n const epoch = activeOpenEpoch\n const isCurrent = () =>\n !disposed &&\n epoch !== undefined &&\n activeOpenEpoch === epoch &&\n lifecycleEpoch === epoch &&\n open()\n if (!isCurrent()) return\n if (clearStaleOffer && working()) return\n if (clearStaleOffer) channelCheckUnconfirmed = true\n const discardStaleOffer = clearStaleOffer || channelCheckUnconfirmed\n setBusy(true)\n setError('')\n setCheckFailed(false)\n if (discardStaleOffer) {\n const current = state()\n if (current) setState({ phase: 'checking', currentVersion: current.currentVersion })\n }\n let channelSaved = beforeCheck === undefined\n try {\n await beforeCheck?.()\n channelSaved = true\n if (!isCurrent()) return\n const checked = await local.adapter.check()\n if (isCurrent()) {\n applyCheckResult(checked, !discardStaleOffer)\n if (discardStaleOffer && checked.phase !== 'failed') channelCheckUnconfirmed = false\n }\n } catch (caught) {\n if (isCurrent()) {\n if (discardStaleOffer) {\n const fallback = channelSaved\n ? 'Could not check for updates'\n : 'Could not save the update channel'\n const message = errorMessage(caught, fallback)\n setState({\n phase: 'failed',\n currentVersion: state()?.currentVersion ?? '',\n error: message,\n })\n failCheck(message, fallback)\n } else {\n failCheck(caught, 'Could not check for updates')\n await loadStatus(isCurrent)\n }\n }\n } finally {\n if (isCurrent()) setBusy(false)\n }\n }\n\n /**\n * Status first, then the check — and an `active` flag, because the dialog can\n * close while the check is in flight and a late `setState` would write into a\n * disposed scope.\n */\n createEffect(() => {\n if (!open() || !desktop()) {\n setCancelPending(false)\n if (activeOpenEpoch !== undefined) {\n activeOpenEpoch = undefined\n lifecycleEpoch += 1\n }\n return\n }\n const epoch = ++lifecycleEpoch\n activeOpenEpoch = epoch\n let active = true\n const isCurrent = () =>\n active && !disposed && activeOpenEpoch === epoch && lifecycleEpoch === epoch && open()\n onCleanup(() => {\n active = false\n if (activeOpenEpoch === epoch) {\n activeOpenEpoch = undefined\n lifecycleEpoch += 1\n }\n })\n setError('')\n setCheckFailed(false)\n setCancelPending(false)\n setBusy(true)\n void (async () => {\n try {\n const current = await local.adapter.getStatus()\n if (!isCurrent()) return\n const discardStaleOffer = channelCheckUnconfirmed\n setState(\n discardStaleOffer\n ? { phase: 'checking', currentVersion: current.currentVersion }\n : current\n )\n const checked = await local.adapter.check()\n if (isCurrent()) {\n applyCheckResult(checked, !discardStaleOffer)\n if (discardStaleOffer && checked.phase !== 'failed') channelCheckUnconfirmed = false\n }\n } catch (caught) {\n if (isCurrent()) {\n if (channelCheckUnconfirmed) {\n const message = errorMessage(caught, 'Could not check for updates')\n setState({\n phase: 'failed',\n currentVersion: state()?.currentVersion ?? '',\n error: message,\n })\n failCheck(message, 'Could not check for updates')\n } else {\n failCheck(caught, 'Could not check for updates')\n }\n }\n } finally {\n if (isCurrent()) setBusy(false)\n }\n })()\n })\n\n const install = async () => {\n const version = state()?.availableVersion\n const epoch = activeOpenEpoch\n const isCurrent = () =>\n !disposed &&\n epoch !== undefined &&\n activeOpenEpoch === epoch &&\n lifecycleEpoch === epoch &&\n open()\n if (!version || !isCurrent()) return\n setBusy(true)\n setError('')\n setState((current) =>\n current ? { ...current, phase: 'downloading', downloadedBytes: 0, totalBytes: null } : current\n )\n try {\n const next = await local.adapter.install(version)\n if (!isCurrent()) return\n setState(\n cancelPending() && ['downloading', 'installing'].includes(next.phase)\n ? { ...next, phase: 'cancelling' }\n : next\n )\n // A refused install answers with a normal payload whose phase is `failed`.\n // Without this the click looked like nothing happened.\n if (next.phase === 'failed') {\n setError(errorMessage(next.error, 'Update installation failed'))\n } else {\n setCheckFailed(false)\n }\n } catch (caught) {\n if (!isCurrent()) return\n setError(errorMessage(caught, 'Update installation failed'))\n await loadStatus(isCurrent)\n } finally {\n if (isCurrent()) setBusy(false)\n }\n }\n\n // Poll only an open, active native operation. Epoch ownership prevents a late\n // status response from replacing a reopened dialog's newer snapshot.\n createEffect(() => {\n const phase = state()?.phase\n if (\n !open() ||\n !desktop() ||\n !local.adapter.pollIntervalMs ||\n !['downloading', 'installing', 'cancelling'].includes(phase ?? '')\n )\n return\n const epoch = activeOpenEpoch\n let active = true\n let requestInFlight = false\n const timer = window.setInterval(\n () => {\n if (requestInFlight) return\n requestInFlight = true\n void (async () => {\n try {\n const next = await local.adapter.getStatus()\n if (!active || disposed || !open() || activeOpenEpoch !== epoch) return\n setState(\n cancelPending() && ['downloading', 'installing'].includes(next.phase)\n ? { ...next, phase: 'cancelling' }\n : next\n )\n if (next.phase === 'failed')\n setError(errorMessage(next.error, 'Update installation failed'))\n } catch (caught) {\n if (active && !disposed && activeOpenEpoch === epoch)\n setError(errorMessage(caught, 'Update progress is unavailable'))\n } finally {\n requestInFlight = false\n }\n })()\n },\n Math.max(250, local.adapter.pollIntervalMs)\n )\n onCleanup(() => {\n active = false\n window.clearInterval(timer)\n })\n })\n\n const cancel = async () => {\n if (!local.adapter.cancel || cancelPending() || state()?.phase === 'cancelling') return\n const epoch = activeOpenEpoch\n setError('')\n setCancelPending(true)\n setState((current) => (current ? { ...current, phase: 'cancelling' } : current))\n try {\n const next = await local.adapter.cancel()\n if (!disposed && open() && activeOpenEpoch === epoch) setState(next)\n } catch (caught) {\n if (!disposed && open() && activeOpenEpoch === epoch) {\n setError(errorMessage(caught, 'Could not cancel the update'))\n await loadStatus(() => !disposed && open() && activeOpenEpoch === epoch)\n }\n } finally {\n if (!disposed && open() && activeOpenEpoch === epoch) setCancelPending(false)\n }\n }\n\n const openRelease = async (url: string) => {\n try {\n if (local.adapter.openExternal) await local.adapter.openExternal(url)\n else window.open(url, '_blank', 'noopener,noreferrer')\n } catch (caught) {\n if (!disposed) setError(errorMessage(caught, 'Could not open the release page'))\n }\n }\n\n const changelog = createMemo(() =>\n plainTextFromMarkdown(state()?.changelog || local.changelog || '')\n )\n const notes = () => {\n const value = state()?.releaseNotes\n return value ? plainTextFromMarkdown(value) : ''\n }\n const working = () => busy() || cancelPending() || isBusy(state())\n const channelControlDisabled = () => !desktop() || working()\n const recheckChannel = (beforeCheck?: () => Promise<void>) => check(beforeCheck, true)\n const isCurrent = () => state()?.phase === 'current' && !error() && !checkFailed() && !working()\n\n const triggerLabel = () => {\n const current = state()\n const fallback = `v${local.fallbackVersion ?? '0.1.0'}`\n if (checkFailed()) return `Version ${current?.currentVersion || fallback} · Retry`\n if (!current) return `${appName()} ${fallback}`\n switch (current.phase) {\n case 'checking':\n return 'Checking for updates…'\n case 'available':\n return current.availableVersion\n ? `Update v${current.availableVersion} available`\n : 'Update available'\n case 'downloading':\n case 'installing':\n return 'Installing update…'\n case 'failed':\n return `Version ${current.currentVersion || fallback} · Retry`\n default:\n return `${appName()} v${current.currentVersion || fallback}`\n }\n }\n\n const progressValue = () => {\n const current = state()\n if (!current?.totalBytes || !current.downloadedBytes) return null\n return Math.min(100, Math.round((current.downloadedBytes / current.totalBytes) * 100))\n }\n\n return (\n <Dialog open={open()} onOpenChange={setOpen}>\n <Show when={local.open === undefined}>\n <DialogTrigger\n as={Button}\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Open version and updates\"\n aria-haspopup=\"dialog\"\n >\n <Show when={state()?.phase === 'available'} fallback={<RefreshCw aria-hidden=\"true\" />}>\n <Sparkles aria-hidden=\"true\" />\n </Show>\n {triggerLabel()}\n </DialogTrigger>\n </Show>\n\n <DialogContent\n class={cn('max-w-3xl', local.class)}\n onKeyDown={(event: KeyboardEvent) => {\n // An explanatory tooltip must not consume the popup's close shortcut,\n // including while its exit animation still owns Kobalte's top layer.\n if (event.key === 'Escape' && !event.defaultPrevented) {\n event.preventDefault()\n setOpen(false)\n }\n }}\n onOpenAutoFocus={(event) => {\n focusRestoration.onOpenAutoFocus(event)\n // Start at the readable panel rather than opening an action's tooltip.\n if (!event.defaultPrevented && event.currentTarget instanceof HTMLElement) {\n event.preventDefault()\n event.currentTarget.focus({ preventScroll: true })\n }\n }}\n onCloseAutoFocus={focusRestoration.onCloseAutoFocus}\n >\n <DialogHeader>\n <div class=\"flex items-center gap-3\">\n <Show\n when={local.appIcon}\n fallback={<Monitor class=\"size-10 text-primary\" aria-hidden=\"true\" />}\n >\n {(icon) => <img src={icon()} alt=\"\" class=\"size-10\" aria-hidden=\"true\" />}\n </Show>\n <div>\n <DialogTitle>Version &amp; updates</DialogTitle>\n <DialogDescription>\n Keep {appName()} current and review what changed in each release.\n </DialogDescription>\n </div>\n </div>\n </DialogHeader>\n\n <div class=\"flex min-h-0 flex-col gap-5 overflow-y-auto p-6\">\n <section\n class=\"rounded-xl border border-border bg-background/45 p-4\"\n aria-label=\"Version status\"\n >\n <div class=\"flex flex-wrap items-start justify-between gap-4\">\n <div class=\"flex flex-col gap-1\">\n <p class=\"text-2xs font-semibold tracking-widest text-muted-foreground uppercase\">\n Installed version\n </p>\n <Heading as=\"p\" size=\"page\" tone=\"foreground\">\n v{state()?.currentVersion || local.fallbackVersion || '0.1.0'}\n </Heading>\n <p class=\"text-sm text-muted-foreground\">\n <Show\n when={isCurrent()}\n fallback={\n <Show\n when={state()?.phase === 'available' && state()?.availableVersion}\n fallback={\n state()?.phase === 'unavailable'\n ? 'No signed package is published for this platform.'\n : state()?.phase === 'cancelled'\n ? 'Update cancelled. You can retry when ready.'\n : desktop()\n ? 'Check the release channel for the latest signed build.'\n : (local.desktopOnlyMessage ??\n `Open this dialog inside the desktop app to check for updates.`)\n }\n >\n {`A newer release, v${state()?.availableVersion}, is ready.`}\n </Show>\n }\n >\n You are running the latest release.\n </Show>\n </p>\n </div>\n <div class=\"flex flex-col items-end gap-2\">\n <ActionButton\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n tooltip=\"Check the release channel for the latest signed app version.\"\n disabled={!desktop() || working()}\n onClick={() => void check()}\n >\n <Show when={working()} fallback={<RefreshCw aria-hidden=\"true\" />}>\n <LoaderCircle class=\"animate-spin\" aria-hidden=\"true\" />\n </Show>\n {checkFailed() ? 'Retry update check' : 'Check latest version'}\n </ActionButton>\n {/* The up-to-date confirmation reads as the button's outcome,\n so it sits directly beneath it rather than floating as a\n full-width row between sections. */}\n <Show when={isCurrent()}>\n <p class=\"text-foreground flex items-center gap-2 text-sm\" role=\"status\">\n <Check class=\"size-4 text-success\" aria-hidden=\"true\" />\n {appName()} is up to date.\n </p>\n </Show>\n </div>\n </div>\n <Show when={local.channelControl}>\n {(channelControl) => (\n <div class=\"mt-4 border-t border-border pt-4\">\n {channelControl()({\n disabled: channelControlDisabled,\n recheck: recheckChannel,\n })}\n </div>\n )}\n </Show>\n </section>\n\n <Show\n when={\n state()?.availableVersion &&\n state()?.phase !== 'installed' &&\n state()?.phase !== 'unavailable'\n }\n >\n <section\n class=\"rounded-xl border border-primary/35 bg-primary-subtle p-4\"\n aria-label=\"Available update\"\n >\n <div class=\"flex flex-wrap items-start justify-between gap-4\">\n <div class=\"flex flex-col gap-1\">\n <p class=\"flex items-center gap-2 text-sm font-semibold\">\n <Sparkles class=\"size-4 text-primary\" aria-hidden=\"true\" />\n Version {state()?.availableVersion}{' '}\n {['downloading', 'installing', 'cancelling'].includes(state()?.phase ?? '')\n ? 'is being prepared'\n : 'is ready'}\n </p>\n <p class=\"text-sm text-muted-foreground\">\n The signed installer is verified before {appName()} restarts.\n </p>\n <Show when={formatReleaseDate(state()?.releaseDate ?? null)}>\n {(released) => (\n <p class=\"text-xs text-muted-foreground\">Released {released()}</p>\n )}\n </Show>\n </div>\n <ActionButton\n type=\"button\"\n size=\"sm\"\n tooltip={`Download the signed update and restart ${appName()}.`}\n disabled={working()}\n onClick={() => void install()}\n >\n <Show when={working()} fallback={<Download aria-hidden=\"true\" />}>\n <LoaderCircle class=\"animate-spin\" aria-hidden=\"true\" />\n </Show>\n Install and restart\n </ActionButton>\n </div>\n </section>\n </Show>\n\n {/*\n Progress with both numbers: a bar alone does not distinguish a stalled\n download from a slow one, and \"12.4 MB of 48.1 MB\" does.\n */}\n <Show\n when={\n state()?.phase === 'downloading' ||\n state()?.phase === 'installing' ||\n state()?.phase === 'cancelling'\n }\n >\n <section class=\"grid gap-2\" aria-label=\"Update progress\">\n <Progress\n value={progressValue() ?? undefined}\n aria-label={\n state()?.phase === 'installing' ? 'Installing update' : 'Downloading update'\n }\n />\n <p class=\"text-xs text-muted-foreground\" role=\"status\">\n <Show\n when={state()?.phase === 'installing'}\n fallback={\n <Show when={progressValue() !== null} fallback=\"Downloading…\">\n {`${formatBytes(state()?.downloadedBytes ?? 0)} of ${formatBytes(\n state()?.totalBytes ?? 0\n )} · ${progressValue()}%`}\n </Show>\n }\n >\n Applying the update…\n </Show>\n </p>\n <Show when={local.adapter.cancel}>\n <ActionButton\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n tooltip=\"Stop the current update download or installation.\"\n disabled={cancelPending() || state()?.phase === 'cancelling'}\n onClick={() => void cancel()}\n >\n <CircleStop aria-hidden=\"true\" />\n {cancelPending() || state()?.phase === 'cancelling'\n ? 'Cancelling…'\n : 'Cancel update'}\n </ActionButton>\n </Show>\n </section>\n </Show>\n\n <Show when={state()?.phase === 'installed'}>\n <p class=\"text-foreground flex items-center gap-2 text-sm\" role=\"status\">\n <Check class=\"size-4 text-success\" aria-hidden=\"true\" />\n <Show when={state()?.restartRequired} fallback=\"The update is applied.\">\n Restart {appName()} to finish the update.\n </Show>\n </p>\n </Show>\n\n <Show when={error()}>\n <p\n class=\"text-foreground rounded-lg border border-destructive/35 bg-destructive-subtle px-3 py-2 text-sm\"\n role=\"alert\"\n >\n {error()}\n </p>\n </Show>\n\n <Show when={notes()}>\n <div class=\"flex flex-col gap-2\">\n <div class=\"flex items-center gap-2\">\n <h2 id=\"update-release-notes\" class=\"text-sm font-semibold text-foreground\">\n What changed in this release\n </h2>\n <Badge variant=\"subtle\" size=\"sm\">\n v{state()?.availableVersion}\n </Badge>\n </div>\n {/* A long text block with no focusable descendant: it needs its own tab\n stop, named by the heading above it, or a keyboard user cannot\n scroll it (`scrollable-region-focusable`). */}\n <div\n class=\"max-h-52 overflow-y-auto rounded-xl border border-border bg-background/45 p-4 font-mono text-xs leading-5 whitespace-pre-wrap text-muted-foreground\"\n role=\"region\"\n aria-labelledby=\"update-release-notes\"\n tabindex=\"0\"\n >\n {notes()}\n </div>\n </div>\n </Show>\n\n <Show when={changelog()}>\n <div class=\"flex flex-col gap-2\">\n <div class=\"flex items-center gap-2\">\n <h2 id=\"update-changelog\" class=\"text-sm font-semibold text-foreground\">\n Installed changelog\n </h2>\n {/* The version pill identifies which build's history this is —\n the same treatment the available-update heading carries. */}\n <Badge variant=\"subtle\" size=\"sm\">\n v{state()?.currentVersion || local.fallbackVersion || '0.1.0'}\n </Badge>\n </div>\n <p class=\"text-xs text-muted-foreground\">\n All versions and updates included with this installation.\n </p>\n {/* A long text block with no focusable descendant: it needs its own tab\n stop, named by the heading above it, or a keyboard user cannot\n scroll it (`scrollable-region-focusable`). */}\n <div\n class=\"max-h-72 overflow-y-auto rounded-xl border border-border bg-background/45 p-4 font-mono text-xs leading-5 whitespace-pre-wrap text-muted-foreground\"\n role=\"region\"\n aria-labelledby=\"update-changelog\"\n tabindex=\"0\"\n >\n {changelog()}\n </div>\n </div>\n </Show>\n </div>\n\n <DialogFooter>\n <Show when={state()?.releaseUrl}>\n {(url) => (\n <ActionButton\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n tooltip=\"Open the release history in your browser.\"\n // `noopener,noreferrer` because the release page is a different\n // origin and must not get a handle on this window.\n onClick={() => void openRelease(url())}\n >\n <ExternalLink aria-hidden=\"true\" />\n View releases\n </ActionButton>\n )}\n </Show>\n <DialogClose as={Button} variant=\"outline\" size=\"sm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A,GAAA,IAAA;OAAA,OAAA/C;MAAA,EAAA,CAAA;MAAA5B,gBAMjB/H,cAAY,EAAA,IAAAgI,WAAA;OAAA,OAAA,CAAAD,gBACVlJ,MAAI;QAAA,IAACoJ,OAAI;SAAA,OAAE5D,MAAM,CAAC,EAAE9C;QAAU;QAAAyG,WAC3B9F,QAAG6F,gBACFpI,cAAY;SACX0K,MAAI;SACJlC,SAAO;SACPC,MAAI;SACJkC,SAAO;SAGPC,eAAe,KAAKhD,YAAYrF,IAAI,CAAC;SAAC,IAAA8F,WAAA;UAAA,OAAA,CAAAD,gBAErC3I,cAAY,EAAA,eAAA,OAAA,CAAA,GAAA,eAAA;SAAA;QAAA,CAAA;OAGhB,CAAA,GAAA2I,gBAEFlI,aAAW;QAACqI,IAAIxI;QAAQyI,SAAO;QAAWC,MAAI;QAAAJ,UAAA;OAAA,CAAA,CAAA;MAAA,EAAA,CAAA;KAAA;IAAA;GAAA,CAAA,CAAA;EAAA;CAAA,CAAA;AAOzD"}
@@ -14,7 +14,8 @@ import type { ComponentProps } from 'solid-js';
14
14
  * 2. **Themes** — one for each appearance. Both are shown at once, because the
15
15
  * choice is per-appearance and hiding the other half makes it feel like one
16
16
  * setting that keeps changing.
17
- * 3. **Accent** — adea's presets, layered on whichever theme is active.
17
+ * 3. **Accent** — adea's presets, then the accents the selected theme pair
18
+ * carries itself, layered on whichever theme is active.
18
19
  * 4. **Font** — the interface face.
19
20
  *
20
21
  * The panel reads and writes the provider's preference and keeps no state of its
@@ -1 +1 @@
1
- {"version":3,"file":"appearance-panel.d.ts","sourceRoot":"","sources":["../../../src/components/theme/appearance-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAW9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;AAKxD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,kCA8H1D"}
1
+ {"version":3,"file":"appearance-panel.d.ts","sourceRoot":"","sources":["../../../src/components/theme/appearance-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAW9C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;AAKxD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,kCA8H1D"}
@@ -9,14 +9,14 @@ import { useTheme } from "./theme-provider.js";
9
9
  import { createComponent, effect, insert, memo, mergeProps, setStyleProperty, spread, template } from "solid-js/web";
10
10
  import { For, Show, splitProps } from "solid-js";
11
11
  //#region src/components/theme/appearance-panel.tsx
12
- var _tmpl$ = /*#__PURE__*/ template(`<div data-slot=appearance-panel><section class="flex flex-col gap-3"><header class="flex flex-col gap-0.5"><p class="max-w-prose text-sm text-muted-foreground">Follow the system, or pin one. The theme below is chosen per appearance, so switching at sunset does not make you choose again.</p></header></section><section class="flex flex-col gap-3"><header class="flex flex-col gap-0.5"><p class="max-w-prose text-sm text-muted-foreground">Colours the interactive roles — the primary button, the focus ring, a selected row — on top of the theme above. Every preset is measured against the surface it lands on, so none of them can make a label unreadable.</p></header><div role=radiogroup aria-label=Accent class="flex flex-wrap gap-2"></div></section><section class="flex flex-col gap-3"><header class="flex flex-col gap-0.5"><p class="max-w-prose text-sm text-muted-foreground">The interface face. Every option is self-hosted, so nothing is fetched at runtime and the choice survives going offline.`);
12
+ var _tmpl$ = /*#__PURE__*/ template(`<div data-slot=appearance-panel><section class="flex flex-col gap-3"><header class="flex flex-col gap-0.5"><p class="max-w-prose text-sm text-muted-foreground">Follow the system, or pin one. The theme below is chosen per appearance, so switching at sunset does not make you choose again.</p></header></section><section class="flex flex-col gap-3"><header class="flex flex-col gap-0.5"><p class="max-w-prose text-sm text-muted-foreground">Colours the interactive roles — the primary button, the focus ring, a selected row — on top of the theme above — one of the presets, or a colour the theme carries itself. Every option is measured against the surface it lands on, so none of them can make a label unreadable.</p></header><div role=radiogroup aria-label=Accent class="flex flex-wrap gap-2"></div></section><section class="flex flex-col gap-3"><header class="flex flex-col gap-0.5"><p class="max-w-prose text-sm text-muted-foreground">The interface face. Every option is self-hosted, so nothing is fetched at runtime and the choice survives going offline.`);
13
13
  var _tmpl$2 = /*#__PURE__*/ template(`<span aria-hidden=true class="size-3 rounded-full border border-border">`);
14
14
  var _tmpl$3 = /*#__PURE__*/ template(`<section class="flex flex-col gap-3"><header class="flex flex-col gap-0.5"><p class="max-w-prose text-sm text-muted-foreground">`);
15
15
  var LIGHT_THEMES = themesForAppearance("light");
16
16
  var DARK_THEMES = themesForAppearance("dark");
17
17
  function AppearancePanel(props) {
18
18
  const [local, rest] = splitProps(props, ["class"]);
19
- const { selection, setSelection, resolvedAppearance } = useTheme();
19
+ const { selection, setSelection, resolvedAppearance, themeAccents } = useTheme();
20
20
  return (() => {
21
21
  var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild, _el$5 = _el$2.nextSibling, _el$6 = _el$5.firstChild, _el$7 = _el$6.firstChild, _el$8 = _el$6.nextSibling, _el$9 = _el$5.nextSibling, _el$0 = _el$9.firstChild, _el$1 = _el$0.firstChild;
22
22
  spread(_el$, mergeProps({ get ["class"]() {
@@ -94,31 +94,42 @@ function AppearancePanel(props) {
94
94
  }), _el$7);
95
95
  insert(_el$8, createComponent(For, {
96
96
  each: accentPresets,
97
- children: (preset) => createComponent(Button, {
98
- as: "button",
99
- type: "button",
100
- variant: "outline",
101
- size: "sm",
102
- role: "radio",
103
- get ["aria-checked"]() {
104
- return selection().accent === preset.id;
97
+ children: (preset) => createComponent(AccentOption, {
98
+ get id() {
99
+ return preset.id;
105
100
  },
106
- get ["aria-label"]() {
101
+ get label() {
107
102
  return preset.label;
108
103
  },
109
- get ["class"]() {
110
- return cn({ "border-ring ring-3 ring-primary-subtle": selection().accent === preset.id });
104
+ get checked() {
105
+ return selection().accent === preset.id;
106
+ },
107
+ get swatch() {
108
+ return memo(() => preset.id === "theme")() ? "var(--primary)" : `var(--accent-${preset.id}, ${preset.dark})`;
111
109
  },
112
- onClick: () => setSelection({ accent: preset.id }),
113
- get children() {
114
- return [(() => {
115
- var _el$10 = _tmpl$2();
116
- effect((_$p) => setStyleProperty(_el$10, "background-color", preset.id === "theme" ? "var(--primary)" : `var(--accent-${preset.id}, ${preset.dark})`));
117
- return _el$10;
118
- })(), memo(() => preset.label)];
119
- }
110
+ onSelect: () => setSelection({ accent: preset.id })
120
111
  })
121
- }));
112
+ }), null);
113
+ insert(_el$8, createComponent(For, {
114
+ get each() {
115
+ return themeAccents();
116
+ },
117
+ children: (accent) => createComponent(AccentOption, {
118
+ get id() {
119
+ return accent.id;
120
+ },
121
+ get label() {
122
+ return `Theme ${accent.label.toLowerCase()}`;
123
+ },
124
+ get checked() {
125
+ return selection().accent === accent.id;
126
+ },
127
+ get swatch() {
128
+ return memo(() => resolvedAppearance() === "dark")() ? accent.dark : accent.light;
129
+ },
130
+ onSelect: () => setSelection({ accent: accent.id })
131
+ })
132
+ }), null);
122
133
  insert(_el$0, createComponent(Heading, {
123
134
  as: "h2",
124
135
  size: "card",
@@ -150,6 +161,35 @@ function AppearancePanel(props) {
150
161
  return _el$;
151
162
  })();
152
163
  }
164
+ function AccentOption(props) {
165
+ return createComponent(Button, {
166
+ as: "button",
167
+ type: "button",
168
+ variant: "outline",
169
+ size: "sm",
170
+ role: "radio",
171
+ get ["data-accent-option"]() {
172
+ return props.id;
173
+ },
174
+ get ["aria-checked"]() {
175
+ return props.checked;
176
+ },
177
+ get ["aria-label"]() {
178
+ return props.label;
179
+ },
180
+ get ["class"]() {
181
+ return cn({ "border-ring ring-3 ring-primary-subtle": props.checked });
182
+ },
183
+ onClick: () => props.onSelect(),
184
+ get children() {
185
+ return [(() => {
186
+ var _el$10 = _tmpl$2();
187
+ effect((_$p) => setStyleProperty(_el$10, "background-color", props.swatch));
188
+ return _el$10;
189
+ })(), memo(() => props.label)];
190
+ }
191
+ });
192
+ }
153
193
  function ThemeSection(props) {
154
194
  return (() => {
155
195
  var _el$11 = _tmpl$3(), _el$12 = _el$11.firstChild, _el$13 = _el$12.firstChild;