@adea-ai/app-framework 0.0.0-stage → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +30 -0
  3. package/README.md +1009 -2
  4. package/dist/app/application.d.ts +47 -0
  5. package/dist/app/application.js +115 -0
  6. package/dist/app/create-application.d.ts +13 -0
  7. package/dist/app/create-application.js +178 -0
  8. package/dist/app/service-registry.d.ts +44 -0
  9. package/dist/app/service-registry.js +116 -0
  10. package/dist/appearance/appearance-host.d.ts +62 -0
  11. package/dist/appearance/appearance-host.js +115 -0
  12. package/dist/appearance/appearance-preferences.d.ts +106 -0
  13. package/dist/appearance/appearance-preferences.js +175 -0
  14. package/dist/appearance/composition.d.ts +11 -0
  15. package/dist/appearance/composition.js +16 -0
  16. package/dist/appearance/custom-theme-import.d.ts +14 -0
  17. package/dist/appearance/custom-theme-import.js +315 -0
  18. package/dist/appearance/custom-theme-library.d.ts +146 -0
  19. package/dist/appearance/custom-theme-library.js +378 -0
  20. package/dist/appearance/editor.d.ts +20 -0
  21. package/dist/appearance/editor.js +47 -0
  22. package/dist/appearance/theme-file-importer.d.ts +23 -0
  23. package/dist/appearance/theme-file-importer.js +66 -0
  24. package/dist/appearance/theme-record-adapter.d.ts +26 -0
  25. package/dist/appearance/theme-record-adapter.js +64 -0
  26. package/dist/appearance/theme-registry.d.ts +10 -0
  27. package/dist/appearance/theme-registry.js +16 -0
  28. package/dist/appearance/window-surface.d.ts +5 -0
  29. package/dist/appearance/window-surface.js +9 -0
  30. package/dist/ci/toolchain-identity.d.ts +39 -0
  31. package/dist/ci/toolchain-identity.js +196 -0
  32. package/dist/cli/cef-helper-cli.d.ts +2 -0
  33. package/dist/cli/cef-helper-cli.js +18 -0
  34. package/dist/cli/cli-runner.d.ts +8 -0
  35. package/dist/cli/cli-runner.js +23 -0
  36. package/dist/cli/create-application-cli.d.ts +2 -0
  37. package/dist/cli/create-application-cli.js +40 -0
  38. package/dist/cli/electrobun-shortcut-patch-cli.d.ts +2 -0
  39. package/dist/cli/electrobun-shortcut-patch-cli.js +17 -0
  40. package/dist/cli/framework-update-cli.d.ts +2 -0
  41. package/dist/cli/framework-update-cli.js +40 -0
  42. package/dist/cli/release-assets-plan-cli.d.ts +2 -0
  43. package/dist/cli/release-assets-plan-cli.js +14 -0
  44. package/dist/cli/release-cut-cli.d.ts +2 -0
  45. package/dist/cli/release-cut-cli.js +27 -0
  46. package/dist/cli/release-descriptor-staging-cli.d.ts +2 -0
  47. package/dist/cli/release-descriptor-staging-cli.js +45 -0
  48. package/dist/cli/release-finalize-cli.d.ts +1 -0
  49. package/dist/cli/release-finalize-cli.js +30 -0
  50. package/dist/cli/release-promote-cli.d.ts +2 -0
  51. package/dist/cli/release-promote-cli.js +32 -0
  52. package/dist/cli/release-publish-cli.d.ts +2 -0
  53. package/dist/cli/release-publish-cli.js +48 -0
  54. package/dist/cli/release-sign-cli.d.ts +2 -0
  55. package/dist/cli/release-sign-cli.js +13 -0
  56. package/dist/cli/release-step-cli.d.ts +2 -0
  57. package/dist/cli/release-step-cli.js +44 -0
  58. package/dist/cli/toolchain-identity-cli.d.ts +2 -0
  59. package/dist/cli/toolchain-identity-cli.js +10 -0
  60. package/dist/cli/update-helper-cli.d.ts +1 -0
  61. package/dist/cli/update-helper-cli.js +10 -0
  62. package/dist/cli/windows-runtime-patch-cli.d.ts +2 -0
  63. package/dist/cli/windows-runtime-patch-cli.js +17 -0
  64. package/dist/desktop/application-command-client.d.ts +15 -0
  65. package/dist/desktop/application-command-client.js +21 -0
  66. package/dist/desktop/channel-handshake.d.ts +32 -0
  67. package/dist/desktop/channel-handshake.js +111 -0
  68. package/dist/desktop/channel-proof.d.ts +43 -0
  69. package/dist/desktop/channel-proof.js +85 -0
  70. package/dist/desktop/client-assets.d.ts +7 -0
  71. package/dist/desktop/client-assets.js +59 -0
  72. package/dist/desktop/desktop-client.d.ts +23 -0
  73. package/dist/desktop/desktop-client.js +231 -0
  74. package/dist/desktop/desktop-gateway.d.ts +18 -0
  75. package/dist/desktop/desktop-gateway.js +146 -0
  76. package/dist/desktop/desktop-host.d.ts +48 -0
  77. package/dist/desktop/desktop-host.js +208 -0
  78. package/dist/desktop/desktop-stream.d.ts +36 -0
  79. package/dist/desktop/desktop-stream.js +231 -0
  80. package/dist/desktop/loopback-policy.d.ts +19 -0
  81. package/dist/desktop/loopback-policy.js +23 -0
  82. package/dist/desktop/open-url-channel.d.ts +15 -0
  83. package/dist/desktop/open-url-channel.js +55 -0
  84. package/dist/desktop/string-policy.d.ts +2 -0
  85. package/dist/desktop/string-policy.js +11 -0
  86. package/dist/framework-source.json +1 -0
  87. package/dist/installer/archive-entry.d.ts +6 -0
  88. package/dist/installer/archive-entry.js +14 -0
  89. package/dist/installer/command-artifact.d.ts +47 -0
  90. package/dist/installer/command-artifact.js +261 -0
  91. package/dist/installer/command-qualification-command.d.ts +12 -0
  92. package/dist/installer/command-qualification-command.js +71 -0
  93. package/dist/installer/hosted-runner.d.ts +4 -0
  94. package/dist/installer/hosted-runner.js +10 -0
  95. package/dist/installer/installed-payload.d.ts +29 -0
  96. package/dist/installer/installed-payload.js +312 -0
  97. package/dist/installer/installer-ci-bootstrap.d.ts +26 -0
  98. package/dist/installer/installer-ci-bootstrap.js +160 -0
  99. package/dist/installer/installer-ci-preflight.d.ts +1 -0
  100. package/dist/installer/installer-ci-preflight.js +49 -0
  101. package/dist/installer/installer-ci-worker.d.ts +1 -0
  102. package/dist/installer/installer-ci-worker.js +105 -0
  103. package/dist/installer/installer-extraction.d.ts +14 -0
  104. package/dist/installer/installer-extraction.js +289 -0
  105. package/dist/installer/installer-fetch-guard.d.ts +15 -0
  106. package/dist/installer/installer-fetch-guard.js +50 -0
  107. package/dist/installer/installer-identity.d.ts +23 -0
  108. package/dist/installer/installer-identity.js +286 -0
  109. package/dist/installer/installer-layout.d.ts +21 -0
  110. package/dist/installer/installer-layout.js +89 -0
  111. package/dist/installer/installer-observation.d.ts +64 -0
  112. package/dist/installer/installer-observation.js +473 -0
  113. package/dist/installer/installer-process-cleanup.d.ts +18 -0
  114. package/dist/installer/installer-process-cleanup.js +158 -0
  115. package/dist/installer/installer-qualification-command.d.ts +11 -0
  116. package/dist/installer/installer-qualification-command.js +71 -0
  117. package/dist/installer/installer-renderer-evidence.d.ts +43 -0
  118. package/dist/installer/installer-renderer-evidence.js +136 -0
  119. package/dist/installer/installer-upgrade-command.d.ts +37 -0
  120. package/dist/installer/installer-upgrade-command.js +172 -0
  121. package/dist/installer/installer-worker-guard.d.ts +21 -0
  122. package/dist/installer/installer-worker-guard.js +72 -0
  123. package/dist/installer/native-executable.d.ts +5 -0
  124. package/dist/installer/native-executable.js +21 -0
  125. package/dist/installer/upgrade-asset-download.d.ts +13 -0
  126. package/dist/installer/upgrade-asset-download.js +41 -0
  127. package/dist/installer/write-all.d.ts +6 -0
  128. package/dist/installer/write-all.js +11 -0
  129. package/dist/native/app-bundle.d.ts +28 -0
  130. package/dist/native/app-bundle.js +60 -0
  131. package/dist/native/cef-helper.d.ts +28 -0
  132. package/dist/native/cef-helper.js +402 -0
  133. package/dist/native/desktop-build-hook.d.ts +7 -0
  134. package/dist/native/desktop-build-hook.js +20 -0
  135. package/dist/native/electrobun-source-patch.d.ts +25 -0
  136. package/dist/native/electrobun-source-patch.js +93 -0
  137. package/dist/native/linux-cef-links.d.ts +2 -0
  138. package/dist/native/linux-cef-links.js +15 -0
  139. package/dist/native/native-secret-store.d.ts +27 -0
  140. package/dist/native/native-secret-store.js +70 -0
  141. package/dist/native/native-utilities.d.ts +24 -0
  142. package/dist/native/native-utilities.js +85 -0
  143. package/dist/native/partitioned-window.d.ts +34 -0
  144. package/dist/native/partitioned-window.js +44 -0
  145. package/dist/native/renderer-profile.d.ts +53 -0
  146. package/dist/native/renderer-profile.js +30 -0
  147. package/dist/native/secure-window.d.ts +38 -0
  148. package/dist/native/secure-window.js +77 -0
  149. package/dist/native/sidecar-services.d.ts +23 -0
  150. package/dist/native/sidecar-services.js +46 -0
  151. package/dist/native/sidecar.d.ts +81 -0
  152. package/dist/native/sidecar.js +250 -0
  153. package/dist/native/window-bootstrap.d.ts +24 -0
  154. package/dist/native/window-bootstrap.js +63 -0
  155. package/dist/native/window-options.d.ts +32 -0
  156. package/dist/native/window-options.js +23 -0
  157. package/dist/native/windows-build-hook-internal.d.ts +2 -0
  158. package/dist/native/windows-build-hook-internal.js +32 -0
  159. package/dist/native/windows-build-hook.d.ts +2 -0
  160. package/dist/native/windows-build-hook.js +12 -0
  161. package/dist/native/windows-runtime-patch-internal.d.ts +3 -0
  162. package/dist/native/windows-runtime-patch-internal.js +20 -0
  163. package/dist/native/windows-runtime-patch.d.ts +4 -0
  164. package/dist/native/windows-runtime-patch.js +12 -0
  165. package/dist/release/feed-release-cut.d.ts +23 -0
  166. package/dist/release/feed-release-cut.js +93 -0
  167. package/dist/release/feed-state.d.ts +25 -0
  168. package/dist/release/feed-state.js +81 -0
  169. package/dist/release/framework-package-publish.d.ts +21 -0
  170. package/dist/release/framework-package-publish.js +127 -0
  171. package/dist/release/framework-update.d.ts +30 -0
  172. package/dist/release/framework-update.js +139 -0
  173. package/dist/release/github-cli.d.ts +6 -0
  174. package/dist/release/github-cli.js +16 -0
  175. package/dist/release/github-release-assets.d.ts +3 -0
  176. package/dist/release/github-release-assets.js +24 -0
  177. package/dist/release/github-release-cut.d.ts +14 -0
  178. package/dist/release/github-release-cut.js +174 -0
  179. package/dist/release/github-release-lookup.d.ts +7 -0
  180. package/dist/release/github-release-lookup.js +29 -0
  181. package/dist/release/github-release-promotion.d.ts +10 -0
  182. package/dist/release/github-release-promotion.js +78 -0
  183. package/dist/release/github-release-provenance.d.ts +9 -0
  184. package/dist/release/github-release-provenance.js +27 -0
  185. package/dist/release/github-release-publisher.d.ts +9 -0
  186. package/dist/release/github-release-publisher.js +63 -0
  187. package/dist/release/github-release-qualification.d.ts +12 -0
  188. package/dist/release/github-release-qualification.js +80 -0
  189. package/dist/release/local-provenance.d.ts +24 -0
  190. package/dist/release/local-provenance.js +72 -0
  191. package/dist/release/local-release.d.ts +133 -0
  192. package/dist/release/local-release.js +387 -0
  193. package/dist/release/macos-dmg.d.ts +22 -0
  194. package/dist/release/macos-dmg.js +91 -0
  195. package/dist/release/release-artifact.d.ts +6 -0
  196. package/dist/release/release-artifact.js +38 -0
  197. package/dist/release/release-assets-plan.d.ts +14 -0
  198. package/dist/release/release-assets-plan.js +65 -0
  199. package/dist/release/release-config.d.ts +76 -0
  200. package/dist/release/release-config.js +180 -0
  201. package/dist/release/release-cut-command.d.ts +13 -0
  202. package/dist/release/release-cut-command.js +39 -0
  203. package/dist/release/release-cut.d.ts +54 -0
  204. package/dist/release/release-cut.js +76 -0
  205. package/dist/release/release-descriptor-staging.d.ts +34 -0
  206. package/dist/release/release-descriptor-staging.js +147 -0
  207. package/dist/release/release-finalize.d.ts +16 -0
  208. package/dist/release/release-finalize.js +104 -0
  209. package/dist/release/release-promotion-command.d.ts +12 -0
  210. package/dist/release/release-promotion-command.js +28 -0
  211. package/dist/release/release-promotion.d.ts +29 -0
  212. package/dist/release/release-promotion.js +57 -0
  213. package/dist/release/release-publication.d.ts +33 -0
  214. package/dist/release/release-publication.js +138 -0
  215. package/dist/release/release-publish-command.d.ts +7 -0
  216. package/dist/release/release-publish-command.js +91 -0
  217. package/dist/release/release-qualification.d.ts +106 -0
  218. package/dist/release/release-qualification.js +135 -0
  219. package/dist/release/release-staging.d.ts +9 -0
  220. package/dist/release/release-staging.js +61 -0
  221. package/dist/release/release-steps.d.ts +38 -0
  222. package/dist/release/release-steps.js +147 -0
  223. package/dist/release/retained-release-build.d.ts +19 -0
  224. package/dist/release/retained-release-build.js +122 -0
  225. package/dist/shell/app-shell.d.ts +61 -0
  226. package/dist/shell/app-shell.js +306 -0
  227. package/dist/shell/app-utilities.d.ts +122 -0
  228. package/dist/shell/app-utilities.js +334 -0
  229. package/dist/shell/application-menu-commands.d.ts +5 -0
  230. package/dist/shell/application-menu-commands.js +11 -0
  231. package/dist/shell/application-menu.d.ts +61 -0
  232. package/dist/shell/application-menu.js +208 -0
  233. package/dist/shell/help-shortcuts.d.ts +12 -0
  234. package/dist/shell/help-shortcuts.js +22 -0
  235. package/dist/shell/navigation-drawer.d.ts +12 -0
  236. package/dist/shell/navigation-drawer.js +42 -0
  237. package/dist/shell/settings-sections.d.ts +31 -0
  238. package/dist/shell/settings-sections.js +50 -0
  239. package/dist/shell/shortcut-platform.d.ts +17 -0
  240. package/dist/shell/shortcut-platform.js +25 -0
  241. package/dist/update-helper.bundle.js +260 -0
  242. package/dist/updates/channel-update-manager.d.ts +46 -0
  243. package/dist/updates/channel-update-manager.js +114 -0
  244. package/dist/updates/desktop-updater.d.ts +104 -0
  245. package/dist/updates/desktop-updater.js +345 -0
  246. package/dist/updates/release-feed.d.ts +61 -0
  247. package/dist/updates/release-feed.js +111 -0
  248. package/dist/updates/release-location.d.ts +9 -0
  249. package/dist/updates/release-location.js +80 -0
  250. package/dist/updates/release-version.d.ts +12 -0
  251. package/dist/updates/release-version.js +43 -0
  252. package/dist/updates/signed-release.d.ts +63 -0
  253. package/dist/updates/signed-release.js +162 -0
  254. package/dist/updates/stable-file.d.ts +10 -0
  255. package/dist/updates/stable-file.js +22 -0
  256. package/dist/updates/update-adapter.d.ts +57 -0
  257. package/dist/updates/update-adapter.js +72 -0
  258. package/dist/updates/update-arm.d.ts +24 -0
  259. package/dist/updates/update-arm.js +95 -0
  260. package/dist/updates/update-channel-store.d.ts +8 -0
  261. package/dist/updates/update-channel-store.js +72 -0
  262. package/dist/updates/update-discovery.d.ts +13 -0
  263. package/dist/updates/update-discovery.js +56 -0
  264. package/dist/updates/update-download.d.ts +14 -0
  265. package/dist/updates/update-download.js +67 -0
  266. package/dist/updates/update-exclusive-rename.d.ts +2 -0
  267. package/dist/updates/update-exclusive-rename.js +52 -0
  268. package/dist/updates/update-extraction.d.ts +18 -0
  269. package/dist/updates/update-extraction.js +183 -0
  270. package/dist/updates/update-handoff-plan.d.ts +22 -0
  271. package/dist/updates/update-handoff-plan.js +28 -0
  272. package/dist/updates/update-helper.d.ts +24 -0
  273. package/dist/updates/update-helper.js +56 -0
  274. package/dist/updates/update-launch.d.ts +5 -0
  275. package/dist/updates/update-launch.js +27 -0
  276. package/dist/updates/update-manager.d.ts +40 -0
  277. package/dist/updates/update-manager.js +83 -0
  278. package/dist/updates/update-process-fence.d.ts +10 -0
  279. package/dist/updates/update-process-fence.js +114 -0
  280. package/dist/updates/update-resume.d.ts +13 -0
  281. package/dist/updates/update-resume.js +34 -0
  282. package/dist/updates/update-shutdown.d.ts +15 -0
  283. package/dist/updates/update-shutdown.js +29 -0
  284. package/dist/updates/update-state.d.ts +30 -0
  285. package/dist/updates/update-state.js +18 -0
  286. package/dist/updates/update-swap-stage.d.ts +27 -0
  287. package/dist/updates/update-swap-stage.js +58 -0
  288. package/dist/updates/update-swap.d.ts +10 -0
  289. package/dist/updates/update-swap.js +30 -0
  290. package/dist/views/app-about.d.ts +22 -0
  291. package/dist/views/app-about.js +43 -0
  292. package/dist/views/app-appearance.d.ts +11 -0
  293. package/dist/views/app-appearance.js +42 -0
  294. package/dist/views/app-help.d.ts +17 -0
  295. package/dist/views/app-help.js +42 -0
  296. package/dist/views/app-settings.d.ts +26 -0
  297. package/dist/views/app-settings.js +97 -0
  298. package/dist/views/appearance-surface.d.ts +9 -0
  299. package/dist/views/appearance-surface.js +334 -0
  300. package/dist/views/update-surface.d.ts +34 -0
  301. package/dist/views/update-surface.js +64 -0
  302. package/package.json +374 -4
  303. package/src/app/application.tsx +138 -0
  304. package/src/appearance/appearance-host.tsx +205 -0
  305. package/src/appearance/appearance-preferences.ts +287 -0
  306. package/src/appearance/composition.ts +29 -0
  307. package/src/appearance/custom-theme-import.ts +424 -0
  308. package/src/appearance/custom-theme-library.ts +600 -0
  309. package/src/appearance/editor.ts +94 -0
  310. package/src/appearance/theme-file-importer.ts +103 -0
  311. package/src/appearance/theme-record-adapter.ts +106 -0
  312. package/src/appearance/theme-registry.ts +20 -0
  313. package/src/appearance/window-surface.ts +18 -0
  314. package/src/desktop/client-assets.ts +75 -0
  315. package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
  316. package/src/native/electrobun-windows-shortcut-com.patch +923 -0
  317. package/src/native/renderer-profile.ts +27 -0
  318. package/src/native/window-options.ts +24 -0
  319. package/src/shell/app-shell.tsx +294 -0
  320. package/src/shell/app-utilities.tsx +437 -0
  321. package/src/shell/help-shortcuts.ts +24 -0
  322. package/src/shell/navigation-drawer.tsx +36 -0
  323. package/src/shell/settings-sections.ts +74 -0
  324. package/src/shell/shortcut-platform.ts +35 -0
  325. package/src/updates/release-version.ts +57 -0
  326. package/src/updates/update-adapter.ts +129 -0
  327. package/src/updates/update-state.ts +34 -0
  328. package/src/views/app-about.tsx +44 -0
  329. package/src/views/app-appearance.tsx +32 -0
  330. package/src/views/app-help.tsx +43 -0
  331. package/src/views/app-settings.tsx +88 -0
  332. package/src/views/appearance-surface.tsx +427 -0
  333. package/src/views/update-surface.tsx +85 -0
  334. package/templates/application/.gitattributes +1 -0
  335. package/templates/application/.github/workflows/release-assets.yml +29 -0
  336. package/templates/application/.github/workflows/release-finalize.yml +29 -0
  337. package/templates/application/.github/workflows/release-please.yml +19 -0
  338. package/templates/application/.github/workflows/release.yml +29 -0
  339. package/templates/application/.github/workflows/validation.yml +28 -0
  340. package/templates/application/.oxfmtrc.json +6 -0
  341. package/templates/application/.oxlintrc.json +48 -0
  342. package/templates/application/.release-please-manifest.json +3 -0
  343. package/templates/application/README.md +47 -0
  344. package/templates/application/electrobun.config.ts +22 -0
  345. package/templates/application/release-please-config.json +12 -0
  346. package/templates/application/scripts/app-version.ts +9 -0
  347. package/templates/application/scripts/build-desktop.ts +34 -0
  348. package/templates/application/scripts/secure-build.ts +1 -0
  349. package/templates/application/scripts/stage-release.ts +21 -0
  350. package/templates/application/src/bun/index.ts +80 -0
  351. package/templates/application/src/electrobun.d.ts +27 -0
  352. package/templates/application/src/web/index.html +12 -0
  353. package/templates/application/src/web/main.tsx +97 -0
  354. package/templates/application/src/web/public/icon.svg +1 -0
  355. package/templates/application/src/web/style.css +3 -0
  356. package/templates/application/tests/app-config.test.ts +9 -0
  357. package/templates/application/tsconfig.json +15 -0
  358. package/templates/application/vite.config.ts +10 -0
@@ -0,0 +1,437 @@
1
+ import {
2
+ AccountMenu,
3
+ createAppMenuItems,
4
+ type AccountMenuItem,
5
+ } from '@adea-ai/ui/components/composites/account-menu'
6
+ import type { UpdateAdapter, UpdateState } from '@adea-ai/ui/components/composites/update-dialog'
7
+ import { ThemeProvider, type ThemeProviderProps } from '@adea-ai/ui/components/theme/lazy'
8
+ import { Palette } from 'lucide-solid'
9
+ import {
10
+ createEffect,
11
+ createMemo,
12
+ createSignal,
13
+ lazy,
14
+ on,
15
+ onCleanup,
16
+ onMount,
17
+ Show,
18
+ Suspense,
19
+ type JSX,
20
+ } from 'solid-js'
21
+ import type { HelpLink, HelpShortcut } from './help-shortcuts'
22
+ import {
23
+ defineSettingsSections,
24
+ settingsSectionFromHash,
25
+ type ApplicationSettingsSection,
26
+ } from './settings-sections'
27
+ import { resolveShortcutPlatform, type ShortcutPlatform } from './shortcut-platform'
28
+ import { browserUpdateAdapter, type UpdateChannelSource } from '../updates/update-adapter'
29
+
30
+ export * from './shortcut-platform'
31
+
32
+ const AppearancePanel = lazy(() =>
33
+ import('@adea-ai/ui/components/theme').then((module) => ({ default: module.AppearancePanel }))
34
+ )
35
+ const ApplicationAppearance = lazy(() =>
36
+ import('../views/app-appearance').then((module) => ({ default: module.ApplicationAppearance }))
37
+ )
38
+ const ApplicationAbout = lazy(() =>
39
+ import('../views/app-about').then((module) => ({ default: module.ApplicationAbout }))
40
+ )
41
+ const ApplicationSettings = lazy(() =>
42
+ import('../views/app-settings').then((module) => ({ default: module.ApplicationSettings }))
43
+ )
44
+ const ApplicationHelp = lazy(() =>
45
+ import('../views/app-help').then((module) => ({ default: module.ApplicationHelp }))
46
+ )
47
+ const UpdateSurface = lazy(() =>
48
+ import('../views/update-surface').then((module) => ({ default: module.ApplicationUpdateSurface }))
49
+ )
50
+
51
+ export type ApplicationIdentity = Readonly<{
52
+ name: string
53
+ icon: string
54
+ version?: string
55
+ /** The platform label About shows, e.g. `macOS`, `desktop` or `web`. */
56
+ platform: string
57
+ /**
58
+ * Which modifier shortcut hints draw. Defaults to `mac` when `platform` names an
59
+ * Apple OS and to the browser's platform otherwise, so a `desktop` or `web` label
60
+ * never advertises Ctrl on a Mac.
61
+ */
62
+ shortcutPlatform?: ShortcutPlatform
63
+ copyright: string
64
+ sourceUrl: string
65
+ }>
66
+
67
+ /** Theme selection and persistence are supplied by the shared design system. */
68
+ export function ApplicationThemeProvider(props: ThemeProviderProps & { storageKey: string }) {
69
+ return <ThemeProvider {...props}>{props.children}</ThemeProvider>
70
+ }
71
+
72
+ /** Opens the shared application surfaces, for native menus and app-owned triggers. */
73
+ export type ApplicationCommands = Readonly<{
74
+ openSettings(section?: string): void
75
+ openAppearance(): void
76
+ openAbout(): void
77
+ openHelp(): void
78
+ openUpdates(): void
79
+ }>
80
+
81
+ /** Where the framework's Appearance section sits in the shared settings dialog. */
82
+ export type ApplicationSettingsAppearance = Readonly<{
83
+ /** `start` (default), `end`, or an index among the app's sections. */
84
+ position?: 'start' | 'end' | number
85
+ /** The navigation group; defaults to `Application`. */
86
+ group?: string
87
+ label?: string
88
+ }>
89
+
90
+ export type ApplicationSettingsConfig = Readonly<{
91
+ /** App-owned sections, listed after the framework's Appearance section by default. */
92
+ sections: readonly ApplicationSettingsSection[]
93
+ title?: string
94
+ /**
95
+ * Include the framework Appearance section (the default), place it, or pass `false`
96
+ * for apps that present appearance inside their own sections.
97
+ */
98
+ appearance?: boolean | ApplicationSettingsAppearance
99
+ /** The section opened when none is named (Settings item, chord, bare `#settings`). */
100
+ defaultSection?: string
101
+ /** Controlled open state. Supply `onOpenChange` to observe requests. */
102
+ open?: boolean
103
+ /** Controlled selected section. Supply `onSectionChange` to observe requests. */
104
+ section?: string
105
+ onOpenChange?(open: boolean): void
106
+ onSectionChange?(id: string): void
107
+ }>
108
+
109
+ export type ApplicationHelpConfig = Readonly<{
110
+ links: readonly HelpLink[]
111
+ /** App-specific shortcuts, listed before the ones the framework binds. */
112
+ shortcuts?: readonly HelpShortcut[]
113
+ /** Whether the host binds the framework search chord. */
114
+ search?: boolean
115
+ }>
116
+
117
+ export type ApplicationAccountMenuConfig = Readonly<{
118
+ /** The trigger's accessible name; defaults to `Application settings`. */
119
+ label?: string
120
+ /** Disable the session row while a sign-in or sign-out is in flight. */
121
+ busy?: boolean
122
+ /** Fires on hover or focus of the trigger, e.g. to prefetch. */
123
+ onIntent?(): void
124
+ /** A chord drawn on the Settings row, e.g. `settingsShortcutLabel('mac')`. */
125
+ settingsShortcut?: string
126
+ /** The parseable chord behind `settingsShortcut`; defaults to `Meta+, Control+,`. */
127
+ settingsKeyshortcuts?: string
128
+ /** Show the Appearance item (the default). Apps with their own control can hide it. */
129
+ appearance?: boolean
130
+ /**
131
+ * `updater` (default) shows Updates on desktop, enabled only with an updater.
132
+ * `always` shows it on every runtime and keeps it enabled: without an updater or
133
+ * `onUpdates` it opens the dialog's desktop-only explanation.
134
+ */
135
+ updates?: 'updater' | 'always'
136
+ }>
137
+
138
+ export type ApplicationUtilitiesProps = {
139
+ identity: ApplicationIdentity
140
+ runtime: 'desktop' | 'web'
141
+ updater?: UpdateAdapter
142
+ /** Release-channel persistence: `read`/`persist`, or a service with `channel`/`setChannel`. */
143
+ channel?: UpdateChannelSource
144
+ /** Receives every updater snapshot the updates dialog sees, for a pending-update badge. */
145
+ onUpdateState?(state: UpdateState): void
146
+ openExternal?(url: string): Promise<void>
147
+ copyVersionInfo?(text: string): Promise<void>
148
+ onSettings?(opener: HTMLButtonElement | undefined): void
149
+ onHelp?(opener: HTMLButtonElement | undefined): void
150
+ onFeedback?(opener: HTMLButtonElement | undefined): void
151
+ /** Replaces the shared updates dialog with an app-owned surface. */
152
+ onUpdates?(opener: HTMLButtonElement | undefined): void
153
+ primaryItem?: AccountMenuItem
154
+ appearance?: JSX.Element
155
+ authenticated?: boolean
156
+ showSession?: boolean
157
+ onSignIn?(): void
158
+ onSignOut?(): void
159
+ updateAvailable?: boolean
160
+ /** Account menu label, busy state, prefetch hook and item visibility. */
161
+ accountMenu?: ApplicationAccountMenuConfig
162
+ /** Supplies the shared settings dialog; Settings, the settings chord and `#settings/<id>` open it. */
163
+ settings?: ApplicationSettingsConfig
164
+ /** Supplies the shared Help Center, opened from the account menu's Help item. */
165
+ help?: ApplicationHelpConfig
166
+ /** Receives commands that open the shared surfaces. */
167
+ commands?(commands: ApplicationCommands): void
168
+ }
169
+
170
+ const appearanceSectionId = 'appearance'
171
+ const settingsKeyshortcuts = 'Meta+, Control+,'
172
+
173
+ function isSettingsChord(event: KeyboardEvent) {
174
+ return (
175
+ !event.defaultPrevented &&
176
+ (event.metaKey || event.ctrlKey) &&
177
+ !event.altKey &&
178
+ !event.shiftKey &&
179
+ event.key === ','
180
+ )
181
+ }
182
+
183
+ function placeAppearance(
184
+ sections: readonly ApplicationSettingsSection[],
185
+ appearance: ApplicationSettingsSection,
186
+ position: ApplicationSettingsAppearance['position']
187
+ ) {
188
+ const index =
189
+ position === 'end'
190
+ ? sections.length
191
+ : typeof position === 'number'
192
+ ? Math.max(0, Math.min(sections.length, Math.trunc(position)))
193
+ : 0
194
+ return [...sections.slice(0, index), appearance, ...sections.slice(index)]
195
+ }
196
+
197
+ /** Shared account menu and application dialogs. Mount inside ApplicationThemeProvider. */
198
+ export function ApplicationUtilities(props: ApplicationUtilitiesProps) {
199
+ type Surface = 'appearance' | 'about' | 'updates' | 'settings' | 'help'
200
+ const [dialog, setDialog] = createSignal<Surface>()
201
+ const [mounted, setMounted] = createSignal<ReadonlySet<Surface>>(new Set())
202
+ const [localSection, setLocalSection] = createSignal<string>()
203
+ let opener: HTMLElement | undefined
204
+ const appearanceOption = () => props.settings?.appearance ?? true
205
+ const settingsSections = createMemo(() => {
206
+ const settings = props.settings
207
+ if (!settings) return undefined
208
+ const option = appearanceOption()
209
+ if (option === false) return defineSettingsSections(settings.sections)
210
+ const placement = option === true ? {} : option
211
+ return defineSettingsSections(
212
+ placeAppearance(
213
+ settings.sections,
214
+ {
215
+ id: appearanceSectionId,
216
+ label: placement.label ?? 'Appearance',
217
+ group: placement.group ?? 'Application',
218
+ icon: <Palette aria-hidden="true" />,
219
+ render: () => props.appearance ?? <AppearancePanel />,
220
+ },
221
+ placement.position
222
+ )
223
+ )
224
+ })
225
+ const hasAppearanceSection = () => Boolean(props.settings) && appearanceOption() !== false
226
+ const knownSection = (id: string | undefined) =>
227
+ id !== undefined && Boolean(settingsSections()?.some((item) => item.id === id))
228
+ const defaultSection = () => {
229
+ const preferred = props.settings?.defaultSection
230
+ return knownSection(preferred) ? preferred! : settingsSections()?.[0]?.id
231
+ }
232
+ const section = () => {
233
+ const controlled = props.settings?.section
234
+ if (controlled !== undefined) return controlled
235
+ return localSection() ?? defaultSection() ?? ''
236
+ }
237
+ const selectSection = (id: string) => {
238
+ const changed = id !== section()
239
+ setLocalSection(id)
240
+ if (changed) props.settings?.onSectionChange?.(id)
241
+ }
242
+ const settingsOpen = () =>
243
+ props.settings?.open !== undefined ? props.settings.open : dialog() === 'settings'
244
+ const updatesAlways = () => props.accountMenu?.updates === 'always'
245
+ const updateAdapter = createMemo(
246
+ () => props.updater ?? browserUpdateAdapter(props.identity.version)
247
+ )
248
+ const markMounted = (value: Surface) => {
249
+ if (!mounted().has(value)) setMounted((current) => new Set(current).add(value))
250
+ }
251
+ const show = (value: Surface | undefined) => {
252
+ const wasOpen = settingsOpen()
253
+ if (value) markMounted(value)
254
+ setDialog(value)
255
+ const isOpen = value === 'settings'
256
+ if (wasOpen !== isOpen) props.settings?.onOpenChange?.(isOpen)
257
+ }
258
+ const open = (value: Surface, target?: HTMLElement) => {
259
+ if (value === 'updates' && !props.updater && !updatesAlways()) return
260
+ if (value === 'help' && !props.help) return
261
+ opener = target ?? (document.activeElement as HTMLElement | null) ?? undefined
262
+ show(value)
263
+ }
264
+ const openSettings = (id?: string, target?: HTMLElement) => {
265
+ if (!settingsSections()) {
266
+ open('appearance', target)
267
+ return
268
+ }
269
+ selectSection(knownSection(id) ? id! : defaultSection()!)
270
+ open('settings', target)
271
+ }
272
+ const openAppearance = (target?: HTMLElement) => {
273
+ if (hasAppearanceSection()) openSettings(appearanceSectionId, target)
274
+ else open('appearance', target)
275
+ }
276
+ const openUpdates = (target?: HTMLButtonElement) => {
277
+ if (props.onUpdates) props.onUpdates(target)
278
+ else open('updates', target)
279
+ }
280
+ // A controlled open from the app's own store mounts the dialog it opens.
281
+ createEffect(
282
+ on(
283
+ () => props.settings?.open,
284
+ (value) => {
285
+ if (value === false && dialog() === 'settings') setDialog(undefined)
286
+ if (!value || !settingsSections()) return
287
+ if (!opener) opener = (document.activeElement as HTMLElement | null) ?? undefined
288
+ markMounted('settings')
289
+ if (dialog() !== 'settings') setDialog('settings')
290
+ }
291
+ )
292
+ )
293
+ props.commands?.(
294
+ Object.freeze({
295
+ openSettings: (id?: string) => openSettings(id),
296
+ openAppearance: () => openAppearance(),
297
+ openAbout: () => open('about'),
298
+ openHelp: () => open('help'),
299
+ openUpdates: () => openUpdates(),
300
+ })
301
+ )
302
+ const onKeyDown = (event: KeyboardEvent) => {
303
+ if (!props.settings || !isSettingsChord(event)) return
304
+ event.preventDefault()
305
+ openSettings()
306
+ }
307
+ const onHash = () => {
308
+ const sections = settingsSections()
309
+ if (!sections) return
310
+ const id = settingsSectionFromHash(window.location.hash, sections, defaultSection())
311
+ if (id) openSettings(id)
312
+ }
313
+ onMount(() => {
314
+ onHash()
315
+ window.addEventListener('keydown', onKeyDown, { capture: true })
316
+ window.addEventListener('hashchange', onHash)
317
+ onCleanup(() => {
318
+ window.removeEventListener('keydown', onKeyDown, { capture: true })
319
+ window.removeEventListener('hashchange', onHash)
320
+ })
321
+ })
322
+ const close = () => show(undefined)
323
+ const items = (): AccountMenuItem[] => {
324
+ const menu = props.accountMenu
325
+ const shared = createAppMenuItems({
326
+ primaryItem: props.primaryItem,
327
+ settingsShortcut: menu?.settingsShortcut,
328
+ onAbout: (target) => open('about', target),
329
+ onUpdates:
330
+ props.updater || props.onUpdates || updatesAlways()
331
+ ? (target) => openUpdates(target)
332
+ : undefined,
333
+ onSettings:
334
+ props.onSettings ??
335
+ (props.settings ? (target) => openSettings(undefined, target) : undefined),
336
+ onHelp: props.onHelp ?? (props.help ? (target) => open('help', target) : undefined),
337
+ onFeedback: props.onFeedback,
338
+ }).map((item) => {
339
+ if (item.id === 'settings' && item.shortcut)
340
+ return { ...item, keyshortcuts: menu?.settingsKeyshortcuts ?? settingsKeyshortcuts }
341
+ if (item.id === 'updates' && updatesAlways()) return { ...item, platform: undefined }
342
+ return item
343
+ })
344
+ if (menu?.appearance === false) return shared
345
+ return [
346
+ {
347
+ id: 'appearance',
348
+ label: 'Appearance',
349
+ icon: <Palette aria-hidden="true" />,
350
+ onSelectAfterClose: (target: HTMLButtonElement | undefined) => open('appearance', target),
351
+ },
352
+ ...shared,
353
+ ]
354
+ }
355
+ return (
356
+ <>
357
+ <AccountMenu
358
+ items={items()}
359
+ platform={props.runtime}
360
+ authenticated={props.authenticated ?? false}
361
+ showSession={props.showSession ?? false}
362
+ busy={props.accountMenu?.busy}
363
+ onIntent={() => props.accountMenu?.onIntent?.()}
364
+ onSignIn={props.onSignIn}
365
+ onSignOut={props.onSignOut}
366
+ updateAvailable={props.updateAvailable}
367
+ label={props.accountMenu?.label ?? 'Application settings'}
368
+ railTrigger
369
+ placement="right-end"
370
+ gutter={4}
371
+ hideArrow
372
+ />
373
+ <Suspense fallback={dialog() ? <span role="status">Loading…</span> : null}>
374
+ <Show when={mounted().has('appearance')}>
375
+ <ApplicationAppearance
376
+ open={dialog() === 'appearance'}
377
+ onClose={close}
378
+ panel={props.appearance}
379
+ restoreFocusRef={() => opener}
380
+ />
381
+ </Show>
382
+ <Show when={mounted().has('settings') && settingsSections()}>
383
+ {(sections) => (
384
+ <ApplicationSettings
385
+ open={settingsOpen()}
386
+ onClose={close}
387
+ sections={sections()}
388
+ section={section()}
389
+ onSectionChange={selectSection}
390
+ title={props.settings?.title}
391
+ restoreFocusRef={() => opener}
392
+ />
393
+ )}
394
+ </Show>
395
+ <Show when={mounted().has('help') && props.help}>
396
+ {(help) => (
397
+ <ApplicationHelp
398
+ open={dialog() === 'help'}
399
+ onClose={close}
400
+ appName={props.identity.name}
401
+ shortcuts={help().shortcuts ?? []}
402
+ standard={{
403
+ search: help().search,
404
+ settings: Boolean(props.settings),
405
+ shortcutPlatform: resolveShortcutPlatform(props.identity),
406
+ }}
407
+ links={help().links}
408
+ openExternal={props.openExternal}
409
+ restoreFocusRef={() => opener}
410
+ />
411
+ )}
412
+ </Show>
413
+ <Show when={mounted().has('about')}>
414
+ <ApplicationAbout
415
+ identity={props.identity}
416
+ copyVersionInfo={props.copyVersionInfo}
417
+ openExternal={props.openExternal}
418
+ open={dialog() === 'about'}
419
+ onClose={close}
420
+ restoreFocusRef={() => opener}
421
+ />
422
+ </Show>
423
+ <Show when={mounted().has('updates') && (props.updater || updatesAlways())}>
424
+ <UpdateSurface
425
+ adapter={updateAdapter()}
426
+ identity={props.identity}
427
+ channel={props.updater ? props.channel : undefined}
428
+ onUpdateState={props.onUpdateState}
429
+ open={dialog() === 'updates'}
430
+ onClose={close}
431
+ restoreFocusRef={() => opener}
432
+ />
433
+ </Show>
434
+ </Suspense>
435
+ </>
436
+ )
437
+ }
@@ -0,0 +1,24 @@
1
+ import type { HelpLink, HelpShortcut } from '@adea-ai/ui/components/composites/help-center'
2
+ import { platformModifierKey } from '@adea-ai/ui/components/ui/kbd'
3
+ import { shortcutModifierKey, type ShortcutPlatform } from './shortcut-platform'
4
+
5
+ export type { HelpLink, HelpShortcut }
6
+
7
+ /** Shortcuts the framework binds itself, drawn with the running platform's modifier. */
8
+ export function standardShortcuts(options: {
9
+ search?: boolean
10
+ settings?: boolean
11
+ /** A navigator-style platform string; ignored when `shortcutPlatform` is supplied. */
12
+ platform?: string
13
+ shortcutPlatform?: ShortcutPlatform
14
+ }): HelpShortcut[] {
15
+ const mod = options.shortcutPlatform
16
+ ? shortcutModifierKey(options.shortcutPlatform)
17
+ : platformModifierKey(options.platform)
18
+ return [
19
+ ...(options.search ? [{ label: 'Open search', keys: [mod, 'K'] }] : []),
20
+ ...(options.settings ? [{ label: 'Open settings', keys: [mod, ','] }] : []),
21
+ { label: 'Close panels and dialogs', keys: ['Esc'] },
22
+ ]
23
+ }
24
+ export * from './shortcut-platform'
@@ -0,0 +1,36 @@
1
+ import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@adea-ai/ui/components/ui/sheet'
2
+ import type { JSX } from 'solid-js'
3
+
4
+ /**
5
+ * The narrow-window navigation drawer. The shell loads it the first time the window is
6
+ * narrow, so wide windows never fetch the dialog primitives behind the sheet.
7
+ */
8
+ export function NavigationDrawer(props: {
9
+ name: string
10
+ open: boolean
11
+ onOpenChange(open: boolean): void
12
+ restoreFocus(): HTMLElement | undefined
13
+ children: JSX.Element
14
+ }) {
15
+ return (
16
+ <Sheet open={props.open} onOpenChange={props.onOpenChange}>
17
+ <SheetContent
18
+ data-mobile="true"
19
+ side="start"
20
+ closeButton={false}
21
+ class="w-72 max-w-full"
22
+ onCloseAutoFocus={(event: Event) => {
23
+ const target = props.restoreFocus()
24
+ if (!target) return
25
+ event.preventDefault()
26
+ target.focus()
27
+ }}
28
+ >
29
+ <SheetHeader class="sr-only">
30
+ <SheetTitle>{`${props.name} navigation`}</SheetTitle>
31
+ </SheetHeader>
32
+ {props.children}
33
+ </SheetContent>
34
+ </Sheet>
35
+ )
36
+ }
@@ -0,0 +1,74 @@
1
+ import type { JSX } from 'solid-js'
2
+
3
+ /** One settings destination. The framework owns layout and navigation; the app owns the panel. */
4
+ export type ApplicationSettingsSection = Readonly<{
5
+ id: string
6
+ label: string
7
+ /** Visible group heading; sections sharing a group are listed together in order. */
8
+ group: string
9
+ icon?: JSX.Element
10
+ description?: string
11
+ render(): JSX.Element
12
+ }>
13
+
14
+ const sectionId = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/
15
+ const hashPrefix = '#settings'
16
+
17
+ /** Validate section identifiers, labels and groups before the dialog mounts. */
18
+ export function defineSettingsSections(
19
+ sections: readonly ApplicationSettingsSection[]
20
+ ): readonly ApplicationSettingsSection[] {
21
+ if (sections.length === 0) throw new Error('At least one settings section is required')
22
+ const ids = new Set<string>()
23
+ return Object.freeze(
24
+ sections.map((section) => {
25
+ if (
26
+ !sectionId.test(section.id) ||
27
+ !section.label.trim() ||
28
+ !section.group.trim() ||
29
+ typeof section.render !== 'function' ||
30
+ ids.has(section.id)
31
+ )
32
+ throw new Error('Settings section identifiers, labels and groups must be valid and unique')
33
+ ids.add(section.id)
34
+ return Object.freeze({ ...section })
35
+ })
36
+ )
37
+ }
38
+
39
+ /** The canonical deep link for a settings section. */
40
+ export function settingsHash(id: string): string {
41
+ return `${hashPrefix}/${id}`
42
+ }
43
+
44
+ /** Whether a location hash addresses the settings surface. */
45
+ export function isSettingsHash(hash: string): boolean {
46
+ return hash === hashPrefix || hash.startsWith(`${hashPrefix}/`)
47
+ }
48
+
49
+ /**
50
+ * The section a `#settings/<id>` hash addresses. When it names no known section, the
51
+ * known `fallback` section, or else the first section.
52
+ */
53
+ export function settingsSectionFromHash(
54
+ hash: string,
55
+ sections: readonly Pick<ApplicationSettingsSection, 'id'>[],
56
+ fallback?: string
57
+ ): string | undefined {
58
+ if (!isSettingsHash(hash)) return undefined
59
+ const known = (id: string | undefined) => sections.some((section) => section.id === id)
60
+ const candidate = hash.slice(hashPrefix.length + 1)
61
+ if (known(candidate)) return candidate
62
+ return known(fallback) ? fallback : sections[0]?.id
63
+ }
64
+
65
+ /** Group sections in first-appearance order for the shared settings navigation. */
66
+ export function settingsGroups(sections: readonly ApplicationSettingsSection[]) {
67
+ const groups = new Map<string, { value: string; label: string; icon?: JSX.Element }[]>()
68
+ for (const section of sections) {
69
+ const items = groups.get(section.group) ?? []
70
+ items.push({ value: section.id, label: section.label, icon: section.icon })
71
+ groups.set(section.group, items)
72
+ }
73
+ return [...groups].map(([label, items]) => ({ label, items }))
74
+ }
@@ -0,0 +1,35 @@
1
+ /** Which modifier family the running OS uses for chords: ⌘ on Apple platforms, Ctrl elsewhere. */
2
+ export type ShortcutPlatform = 'mac' | 'other'
3
+
4
+ const applePlatform = /Mac|iPhone|iPad|iPod/i
5
+
6
+ /** The shortcut platform the browser reports; `other` where there is no navigator. */
7
+ export function detectShortcutPlatform(): ShortcutPlatform {
8
+ return typeof navigator !== 'undefined' && applePlatform.test(navigator.platform)
9
+ ? 'mac'
10
+ : 'other'
11
+ }
12
+
13
+ /**
14
+ * The shortcut platform for an application identity. An explicit `shortcutPlatform`
15
+ * wins; a `platform` label that names an Apple OS keeps its earlier meaning; any other
16
+ * label (`desktop`, `web`, a product name) defers to the browser.
17
+ */
18
+ export function resolveShortcutPlatform(identity: {
19
+ platform?: string
20
+ shortcutPlatform?: ShortcutPlatform
21
+ }): ShortcutPlatform {
22
+ if (identity.shortcutPlatform) return identity.shortcutPlatform
23
+ if (identity.platform && applePlatform.test(identity.platform)) return 'mac'
24
+ return detectShortcutPlatform()
25
+ }
26
+
27
+ /** The modifier glyph drawn for a shortcut platform. */
28
+ export function shortcutModifierKey(platform: ShortcutPlatform): '⌘' | 'Ctrl' {
29
+ return platform === 'mac' ? '⌘' : 'Ctrl'
30
+ }
31
+
32
+ /** The settings chord as a menu row draws it: `⌘,` or `Ctrl+,`. */
33
+ export function settingsShortcutLabel(platform: ShortcutPlatform): string {
34
+ return platform === 'mac' ? '⌘,' : 'Ctrl+,'
35
+ }
@@ -0,0 +1,57 @@
1
+ /** The update channel an installation follows. */
2
+ export type UpdateChannel = 'stable' | 'pre-release' | 'dev'
3
+
4
+ export function isUpdateChannel(value: unknown): value is UpdateChannel {
5
+ return value === 'stable' || value === 'pre-release' || value === 'dev'
6
+ }
7
+
8
+ /**
9
+ * Parse a version in the update grammar into `[major, minor, patch, dev]`,
10
+ * where a release carries no dev counter and sorts after every dev build of
11
+ * its own triple. Components use exact integers, including the dev counter.
12
+ * Unparseable versions return null so the caller can fall back.
13
+ */
14
+ function parseUpdateVersion(version: string): [bigint, bigint, bigint, bigint | null] | null {
15
+ const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-dev\.(\d+))?$/.exec(version.trim())
16
+ if (!match) return null
17
+ return [
18
+ BigInt(match[1]!),
19
+ BigInt(match[2]!),
20
+ BigInt(match[3]!),
21
+ match[4] === undefined ? null : BigInt(match[4]),
22
+ ]
23
+ }
24
+
25
+ /**
26
+ * Semver ordering for everything the update grammar produces: `x.y.z` and the
27
+ * dev builds `x.y.z-dev.N`. A dev build sorts below its own release
28
+ * (`0.75.0-dev.1 < 0.75.0`) and above every earlier release, which is why dev
29
+ * builds are numbered for the next unreleased version. The order is the same on
30
+ * every channel. Unparseable versions fall back to the historic numeric-triple
31
+ * comparison — a malformed version must never wedge the state machine.
32
+ */
33
+ export function versionLessThan(a: string, b: string): boolean {
34
+ const pa = parseUpdateVersion(a)
35
+ const pb = parseUpdateVersion(b)
36
+ if (pa && pb) {
37
+ for (let i = 0; i < 3; i++) {
38
+ if (pa[i] !== pb[i]) return pa[i]! < pb[i]!
39
+ }
40
+ if (pa[3] === null) return false
41
+ if (pb[3] === null) return true
42
+ return pa[3] < pb[3]
43
+ }
44
+ const fallbackA = a
45
+ .replace(/^v/, '')
46
+ .split('.')
47
+ .map((n) => parseInt(n, 10) || 0)
48
+ const fallbackB = b
49
+ .replace(/^v/, '')
50
+ .split('.')
51
+ .map((n) => parseInt(n, 10) || 0)
52
+ for (let i = 0; i < 3; i++) {
53
+ if ((fallbackB[i] ?? 0) !== (fallbackA[i] ?? 0))
54
+ return (fallbackB[i] ?? 0) > (fallbackA[i] ?? 0)
55
+ }
56
+ return false
57
+ }