@adea-ai/app-framework 0.0.0-stage → 0.24.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 (474) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +30 -0
  3. package/README.md +967 -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 +125 -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 +318 -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/settings-sections.d.ts +31 -0
  236. package/dist/shell/settings-sections.js +50 -0
  237. package/dist/shell/shortcut-platform.d.ts +17 -0
  238. package/dist/shell/shortcut-platform.js +25 -0
  239. package/dist/update-helper.bundle.js +260 -0
  240. package/dist/updates/channel-update-manager.d.ts +46 -0
  241. package/dist/updates/channel-update-manager.js +114 -0
  242. package/dist/updates/desktop-updater.d.ts +104 -0
  243. package/dist/updates/desktop-updater.js +345 -0
  244. package/dist/updates/release-feed.d.ts +61 -0
  245. package/dist/updates/release-feed.js +111 -0
  246. package/dist/updates/release-location.d.ts +9 -0
  247. package/dist/updates/release-location.js +80 -0
  248. package/dist/updates/release-version.d.ts +12 -0
  249. package/dist/updates/release-version.js +43 -0
  250. package/dist/updates/signed-release.d.ts +63 -0
  251. package/dist/updates/signed-release.js +162 -0
  252. package/dist/updates/stable-file.d.ts +10 -0
  253. package/dist/updates/stable-file.js +22 -0
  254. package/dist/updates/update-adapter.d.ts +57 -0
  255. package/dist/updates/update-adapter.js +72 -0
  256. package/dist/updates/update-arm.d.ts +24 -0
  257. package/dist/updates/update-arm.js +95 -0
  258. package/dist/updates/update-channel-store.d.ts +8 -0
  259. package/dist/updates/update-channel-store.js +72 -0
  260. package/dist/updates/update-discovery.d.ts +13 -0
  261. package/dist/updates/update-discovery.js +56 -0
  262. package/dist/updates/update-download.d.ts +14 -0
  263. package/dist/updates/update-download.js +67 -0
  264. package/dist/updates/update-exclusive-rename.d.ts +2 -0
  265. package/dist/updates/update-exclusive-rename.js +52 -0
  266. package/dist/updates/update-extraction.d.ts +18 -0
  267. package/dist/updates/update-extraction.js +183 -0
  268. package/dist/updates/update-handoff-plan.d.ts +22 -0
  269. package/dist/updates/update-handoff-plan.js +28 -0
  270. package/dist/updates/update-helper.d.ts +24 -0
  271. package/dist/updates/update-helper.js +56 -0
  272. package/dist/updates/update-launch.d.ts +5 -0
  273. package/dist/updates/update-launch.js +27 -0
  274. package/dist/updates/update-manager.d.ts +40 -0
  275. package/dist/updates/update-manager.js +83 -0
  276. package/dist/updates/update-process-fence.d.ts +10 -0
  277. package/dist/updates/update-process-fence.js +114 -0
  278. package/dist/updates/update-resume.d.ts +13 -0
  279. package/dist/updates/update-resume.js +34 -0
  280. package/dist/updates/update-shutdown.d.ts +15 -0
  281. package/dist/updates/update-shutdown.js +29 -0
  282. package/dist/updates/update-state.d.ts +30 -0
  283. package/dist/updates/update-state.js +18 -0
  284. package/dist/updates/update-swap-stage.d.ts +27 -0
  285. package/dist/updates/update-swap-stage.js +58 -0
  286. package/dist/updates/update-swap.d.ts +10 -0
  287. package/dist/updates/update-swap.js +30 -0
  288. package/dist/views/app-about.d.ts +22 -0
  289. package/dist/views/app-about.js +43 -0
  290. package/dist/views/app-appearance.d.ts +11 -0
  291. package/dist/views/app-appearance.js +42 -0
  292. package/dist/views/app-help.d.ts +17 -0
  293. package/dist/views/app-help.js +42 -0
  294. package/dist/views/app-settings.d.ts +26 -0
  295. package/dist/views/app-settings.js +97 -0
  296. package/dist/views/appearance-surface.d.ts +9 -0
  297. package/dist/views/appearance-surface.js +334 -0
  298. package/dist/views/update-surface.d.ts +34 -0
  299. package/dist/views/update-surface.js +64 -0
  300. package/package.json +363 -4
  301. package/src/app/application.tsx +138 -0
  302. package/src/app/create-application.ts +245 -0
  303. package/src/app/service-registry.ts +124 -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/ci/toolchain-identity.ts +244 -0
  315. package/src/cli/cef-helper-cli.ts +21 -0
  316. package/src/cli/cli-runner.ts +29 -0
  317. package/src/cli/create-application-cli.ts +62 -0
  318. package/src/cli/electrobun-shortcut-patch-cli.ts +24 -0
  319. package/src/cli/framework-update-cli.ts +41 -0
  320. package/src/cli/release-assets-plan-cli.ts +14 -0
  321. package/src/cli/release-cut-cli.ts +41 -0
  322. package/src/cli/release-descriptor-staging-cli.ts +57 -0
  323. package/src/cli/release-finalize-cli.ts +34 -0
  324. package/src/cli/release-promote-cli.ts +31 -0
  325. package/src/cli/release-publish-cli.ts +46 -0
  326. package/src/cli/release-sign-cli.ts +24 -0
  327. package/src/cli/release-step-cli.ts +71 -0
  328. package/src/cli/toolchain-identity-cli.ts +12 -0
  329. package/src/cli/update-helper-cli.ts +12 -0
  330. package/src/cli/windows-runtime-patch-cli.ts +17 -0
  331. package/src/desktop/application-command-client.ts +43 -0
  332. package/src/desktop/channel-handshake.ts +136 -0
  333. package/src/desktop/channel-proof.ts +122 -0
  334. package/src/desktop/client-assets.ts +75 -0
  335. package/src/desktop/desktop-client.ts +303 -0
  336. package/src/desktop/desktop-gateway.ts +189 -0
  337. package/src/desktop/desktop-host.ts +335 -0
  338. package/src/desktop/desktop-stream.ts +324 -0
  339. package/src/desktop/loopback-policy.ts +41 -0
  340. package/src/desktop/open-url-channel.ts +79 -0
  341. package/src/desktop/string-policy.ts +9 -0
  342. package/src/installer/archive-entry.ts +32 -0
  343. package/src/installer/command-artifact.ts +307 -0
  344. package/src/installer/command-qualification-command.ts +75 -0
  345. package/src/installer/hosted-runner.ts +11 -0
  346. package/src/installer/installed-payload.ts +408 -0
  347. package/src/installer/installer-ci-bootstrap.ts +199 -0
  348. package/src/installer/installer-ci-preflight.ts +61 -0
  349. package/src/installer/installer-ci-worker.ts +105 -0
  350. package/src/installer/installer-extraction.ts +367 -0
  351. package/src/installer/installer-fetch-guard.ts +75 -0
  352. package/src/installer/installer-identity.ts +331 -0
  353. package/src/installer/installer-layout.ts +167 -0
  354. package/src/installer/installer-observation.ts +671 -0
  355. package/src/installer/installer-process-cleanup.ts +167 -0
  356. package/src/installer/installer-qualification-command.ts +81 -0
  357. package/src/installer/installer-renderer-evidence.ts +268 -0
  358. package/src/installer/installer-upgrade-command.ts +226 -0
  359. package/src/installer/installer-worker-guard.ts +112 -0
  360. package/src/installer/native-executable.ts +37 -0
  361. package/src/installer/upgrade-asset-download.ts +72 -0
  362. package/src/installer/write-all.ts +19 -0
  363. package/src/native/app-bundle.ts +86 -0
  364. package/src/native/cef-helper.ts +471 -0
  365. package/src/native/desktop-build-hook.ts +21 -0
  366. package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
  367. package/src/native/electrobun-source-patch.ts +107 -0
  368. package/src/native/electrobun-windows-shortcut-com.patch +923 -0
  369. package/src/native/linux-cef-links.ts +14 -0
  370. package/src/native/native-secret-store.ts +99 -0
  371. package/src/native/native-utilities.ts +166 -0
  372. package/src/native/partitioned-window.ts +62 -0
  373. package/src/native/renderer-profile.ts +27 -0
  374. package/src/native/secure-window.ts +115 -0
  375. package/src/native/sidecar-services.ts +71 -0
  376. package/src/native/sidecar.ts +387 -0
  377. package/src/native/window-bootstrap.ts +77 -0
  378. package/src/native/window-options.ts +24 -0
  379. package/src/native/windows-build-hook-internal.ts +49 -0
  380. package/src/native/windows-build-hook.ts +12 -0
  381. package/src/native/windows-runtime-patch-internal.ts +48 -0
  382. package/src/native/windows-runtime-patch.ts +15 -0
  383. package/src/release/feed-release-cut.ts +110 -0
  384. package/src/release/feed-state.ts +135 -0
  385. package/src/release/framework-package-publish.ts +163 -0
  386. package/src/release/framework-update.ts +196 -0
  387. package/src/release/github-cli.ts +27 -0
  388. package/src/release/github-release-assets.ts +36 -0
  389. package/src/release/github-release-cut.ts +237 -0
  390. package/src/release/github-release-lookup.ts +39 -0
  391. package/src/release/github-release-promotion.ts +112 -0
  392. package/src/release/github-release-provenance.ts +65 -0
  393. package/src/release/github-release-publisher.ts +90 -0
  394. package/src/release/github-release-qualification.ts +144 -0
  395. package/src/release/local-provenance.ts +92 -0
  396. package/src/release/local-release.ts +525 -0
  397. package/src/release/macos-dmg.ts +113 -0
  398. package/src/release/release-artifact.ts +53 -0
  399. package/src/release/release-assets-plan.ts +118 -0
  400. package/src/release/release-config.ts +420 -0
  401. package/src/release/release-cut-command.ts +80 -0
  402. package/src/release/release-cut.ts +133 -0
  403. package/src/release/release-descriptor-staging.ts +242 -0
  404. package/src/release/release-finalize.ts +191 -0
  405. package/src/release/release-promotion-command.ts +36 -0
  406. package/src/release/release-promotion.ts +132 -0
  407. package/src/release/release-publication.ts +213 -0
  408. package/src/release/release-publish-command.ts +163 -0
  409. package/src/release/release-qualification.ts +397 -0
  410. package/src/release/release-staging.ts +87 -0
  411. package/src/release/release-steps.ts +173 -0
  412. package/src/release/retained-release-build.ts +217 -0
  413. package/src/shell/app-shell.tsx +285 -0
  414. package/src/shell/app-utilities.tsx +437 -0
  415. package/src/shell/application-menu-commands.ts +6 -0
  416. package/src/shell/application-menu.ts +250 -0
  417. package/src/shell/help-shortcuts.ts +24 -0
  418. package/src/shell/settings-sections.ts +74 -0
  419. package/src/shell/shortcut-platform.ts +35 -0
  420. package/src/updates/channel-update-manager.ts +127 -0
  421. package/src/updates/desktop-updater.ts +440 -0
  422. package/src/updates/release-feed.ts +187 -0
  423. package/src/updates/release-location.ts +101 -0
  424. package/src/updates/release-version.ts +57 -0
  425. package/src/updates/signed-release.ts +311 -0
  426. package/src/updates/stable-file.ts +32 -0
  427. package/src/updates/update-adapter.ts +129 -0
  428. package/src/updates/update-arm.ts +107 -0
  429. package/src/updates/update-channel-store.ts +86 -0
  430. package/src/updates/update-discovery.ts +113 -0
  431. package/src/updates/update-download.ts +82 -0
  432. package/src/updates/update-exclusive-rename.ts +58 -0
  433. package/src/updates/update-extraction.ts +261 -0
  434. package/src/updates/update-handoff-plan.ts +75 -0
  435. package/src/updates/update-helper.ts +87 -0
  436. package/src/updates/update-launch.ts +33 -0
  437. package/src/updates/update-manager.ts +130 -0
  438. package/src/updates/update-process-fence.ts +125 -0
  439. package/src/updates/update-resume.ts +34 -0
  440. package/src/updates/update-shutdown.ts +37 -0
  441. package/src/updates/update-state.ts +34 -0
  442. package/src/updates/update-swap-stage.ts +75 -0
  443. package/src/updates/update-swap.ts +30 -0
  444. package/src/views/app-about.tsx +44 -0
  445. package/src/views/app-appearance.tsx +32 -0
  446. package/src/views/app-help.tsx +43 -0
  447. package/src/views/app-settings.tsx +88 -0
  448. package/src/views/appearance-surface.tsx +427 -0
  449. package/src/views/update-surface.tsx +85 -0
  450. package/templates/application/.gitattributes +1 -0
  451. package/templates/application/.github/workflows/release-assets.yml +29 -0
  452. package/templates/application/.github/workflows/release-finalize.yml +29 -0
  453. package/templates/application/.github/workflows/release-please.yml +19 -0
  454. package/templates/application/.github/workflows/release.yml +29 -0
  455. package/templates/application/.github/workflows/validation.yml +28 -0
  456. package/templates/application/.oxfmtrc.json +6 -0
  457. package/templates/application/.oxlintrc.json +48 -0
  458. package/templates/application/.release-please-manifest.json +3 -0
  459. package/templates/application/README.md +47 -0
  460. package/templates/application/electrobun.config.ts +22 -0
  461. package/templates/application/release-please-config.json +12 -0
  462. package/templates/application/scripts/app-version.ts +9 -0
  463. package/templates/application/scripts/build-desktop.ts +34 -0
  464. package/templates/application/scripts/secure-build.ts +1 -0
  465. package/templates/application/scripts/stage-release.ts +21 -0
  466. package/templates/application/src/bun/index.ts +80 -0
  467. package/templates/application/src/electrobun.d.ts +27 -0
  468. package/templates/application/src/web/index.html +12 -0
  469. package/templates/application/src/web/main.tsx +97 -0
  470. package/templates/application/src/web/public/icon.svg +1 -0
  471. package/templates/application/src/web/style.css +3 -0
  472. package/templates/application/tests/app-config.test.ts +9 -0
  473. package/templates/application/tsconfig.json +15 -0
  474. package/templates/application/vite.config.ts +10 -0
@@ -0,0 +1,63 @@
1
+ import { type KeyObject } from 'node:crypto';
2
+ export type ReleaseDescriptor = Readonly<{
3
+ schema: 2;
4
+ appId: string;
5
+ repository: string;
6
+ channel: 'dev' | 'daily' | 'stable';
7
+ tag: string;
8
+ version: string;
9
+ sourceSha: string;
10
+ workflowSha: string;
11
+ runId: string;
12
+ runAttempt: number;
13
+ platform: 'darwin' | 'win32' | 'linux';
14
+ arch: 'arm64' | 'x64';
15
+ asset: Readonly<{
16
+ name: string;
17
+ url: string;
18
+ size: number;
19
+ sha256: string;
20
+ }>;
21
+ keyId: string;
22
+ }>;
23
+ declare const verifiedBrand: unique symbol;
24
+ export type VerifiedRelease = ReleaseDescriptor & {
25
+ readonly [verifiedBrand]: true;
26
+ };
27
+ export type SignedRelease = Readonly<{
28
+ descriptor: ReleaseDescriptor;
29
+ signature: string;
30
+ }>;
31
+ export type ReleaseTrust = Readonly<{
32
+ appId: string;
33
+ repository: string;
34
+ channel: ReleaseDescriptor['channel'];
35
+ platform: ReleaseDescriptor['platform'];
36
+ arch: ReleaseDescriptor['arch'];
37
+ /** The app's release feed URL, ending in `/`; every asset URL is `<feed><tag>/<name>`. */
38
+ feed: string;
39
+ keys: ReadonlyMap<string, string>;
40
+ }>;
41
+ /** A GitHub `owner/name` slug that is safe to place in API and download paths. */
42
+ export declare function isRepositorySlug(value: string): boolean;
43
+ export declare function assertRepositorySlug(value: string): void;
44
+ /** Sign canonical release metadata with an application-owned Ed25519 private key. */
45
+ export declare function signReleaseDescriptor(descriptor: ReleaseDescriptor, privateKey: KeyObject): SignedRelease;
46
+ /** Authenticate the entire descriptor against an application-owned trust policy. */
47
+ export declare function verifyReleaseDescriptor(value: unknown, trust: ReleaseTrust): {
48
+ ok: true;
49
+ descriptor: VerifiedRelease;
50
+ } | {
51
+ ok: false;
52
+ };
53
+ /** A verified descriptor remains valid only in the process that authenticated it. */
54
+ export declare function isVerifiedRelease(value: unknown): value is VerifiedRelease;
55
+ /** Check that an authenticated descriptor used this exact application's current trust key. */
56
+ export declare function isVerifiedReleaseForTrust(value: unknown, trust: ReleaseTrust): value is VerifiedRelease;
57
+ /** Return the authenticated signed envelope for re-verification in another process. */
58
+ export declare function exportVerifiedRelease(value: VerifiedRelease, trust: ReleaseTrust): SignedRelease;
59
+ /** Check exact archive bytes after the descriptor has been authenticated. */
60
+ export declare function verifyReleaseBytes(bytes: Uint8Array, descriptor: VerifiedRelease): boolean;
61
+ /** Check a streamed archive without buffering the whole artifact. */
62
+ export declare function verifyReleaseStream(chunks: AsyncIterable<Uint8Array>, descriptor: VerifiedRelease): Promise<boolean>;
63
+ export {};
@@ -0,0 +1,162 @@
1
+ import { createHash, createPublicKey, sign, timingSafeEqual, verify } from "node:crypto";
2
+ // src/updates/signed-release.ts
3
+ var verifiedDescriptors = /* @__PURE__ */ new WeakMap();
4
+ /** A GitHub `owner/name` slug that is safe to place in API and download paths. */
5
+ function isRepositorySlug(value) {
6
+ return /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(value) && value.length <= 200 && value.split("/").every((part) => part !== "." && part !== "..");
7
+ }
8
+ function assertRepositorySlug(value) {
9
+ if (!isRepositorySlug(value)) throw new Error("Invalid GitHub repository");
10
+ }
11
+ var keys = [
12
+ "schema",
13
+ "appId",
14
+ "repository",
15
+ "channel",
16
+ "tag",
17
+ "version",
18
+ "sourceSha",
19
+ "workflowSha",
20
+ "runId",
21
+ "runAttempt",
22
+ "platform",
23
+ "arch",
24
+ "asset",
25
+ "keyId"
26
+ ];
27
+ var assetKeys = [
28
+ "name",
29
+ "url",
30
+ "size",
31
+ "sha256"
32
+ ];
33
+ var record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
34
+ var exactKeys = (value, expected) => Object.keys(value).length === expected.length && expected.every((key) => Object.hasOwn(value, key));
35
+ function valid(value) {
36
+ if (!record(value) || !exactKeys(value, keys) || !record(value.asset) || !exactKeys(value.asset, assetKeys)) return false;
37
+ if (value.schema !== 2 || typeof value.appId !== "string" || !/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+$/.test(value.appId) || value.appId.length > 255) return false;
38
+ if (typeof value.repository !== "string" || !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(value.repository) || value.repository.length > 200) return false;
39
+ if (value.channel !== "dev" && value.channel !== "daily" && value.channel !== "stable") return false;
40
+ if (typeof value.version !== "string" || value.version.length > 64 || !/^\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(value.version) || value.tag !== `v${value.version}` || value.channel === "dev" !== /-dev\.\d+$/.test(value.version)) return false;
41
+ if (typeof value.sourceSha !== "string" || !/^[a-f0-9]{40}$/.test(value.sourceSha) || typeof value.workflowSha !== "string" || !/^[a-f0-9]{40}$/.test(value.workflowSha)) return false;
42
+ if (typeof value.runId !== "string" || !/^[1-9]\d{0,19}$/.test(value.runId) || !Number.isSafeInteger(value.runAttempt) || Number(value.runAttempt) < 1) return false;
43
+ if (![
44
+ "darwin",
45
+ "win32",
46
+ "linux"
47
+ ].includes(String(value.platform)) || !["arm64", "x64"].includes(String(value.arch))) return false;
48
+ if (typeof value.keyId !== "string" || !/^[a-z0-9][a-z0-9._-]{0,63}$/.test(value.keyId)) return false;
49
+ const asset = value.asset;
50
+ if (typeof asset.name !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/.test(asset.name) || typeof asset.url !== "string" || asset.url.length > 2048 || typeof asset.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(asset.sha256) || !Number.isSafeInteger(asset.size) || Number(asset.size) < 1) return false;
51
+ try {
52
+ const url = new URL(asset.url);
53
+ return url.protocol === "https:" && url.href === asset.url && !url.port && !url.username && !url.password && !url.search && !url.hash && url.pathname.endsWith(`/${value.tag}/${asset.name}`);
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+ /** Whether the asset URL is exactly this release's object in the trusted feed. */
59
+ var inFeed = (value, feed) => typeof feed === "string" && feed.startsWith("https://") && feed.endsWith("/") && value.asset.url === `${feed}${value.tag}/${value.asset.name}`;
60
+ function message(value) {
61
+ return Buffer.from(JSON.stringify([
62
+ "adea-app-framework-release-v2",
63
+ value.schema,
64
+ value.appId,
65
+ value.repository,
66
+ value.channel,
67
+ value.tag,
68
+ value.version,
69
+ value.sourceSha,
70
+ value.workflowSha,
71
+ value.runId,
72
+ value.runAttempt,
73
+ value.platform,
74
+ value.arch,
75
+ value.asset.name,
76
+ value.asset.url,
77
+ value.asset.size,
78
+ value.asset.sha256,
79
+ value.keyId
80
+ ]), "utf8");
81
+ }
82
+ /** Sign canonical release metadata with an application-owned Ed25519 private key. */
83
+ function signReleaseDescriptor(descriptor, privateKey) {
84
+ if (!valid(descriptor) || privateKey.type !== "private" || privateKey.asymmetricKeyType !== "ed25519") throw new Error("Invalid release descriptor or signing key");
85
+ return {
86
+ descriptor,
87
+ signature: sign(null, message(descriptor), privateKey).toString("base64url")
88
+ };
89
+ }
90
+ /** Authenticate the entire descriptor against an application-owned trust policy. */
91
+ function verifyReleaseDescriptor(value, trust) {
92
+ try {
93
+ if (!record(value) || !exactKeys(value, ["descriptor", "signature"]) || typeof value.signature !== "string" || !/^[A-Za-z0-9_-]{86}$/.test(value.signature)) return { ok: false };
94
+ if (!valid(value.descriptor)) return { ok: false };
95
+ const descriptor = structuredClone(value.descriptor);
96
+ if (!valid(descriptor)) return { ok: false };
97
+ if (descriptor.appId !== trust.appId || descriptor.repository !== trust.repository || descriptor.channel !== trust.channel || descriptor.platform !== trust.platform || descriptor.arch !== trust.arch || !inFeed(descriptor, trust.feed)) return { ok: false };
98
+ const encoded = trust.keys.get(descriptor.keyId);
99
+ if (!encoded) return { ok: false };
100
+ const raw = Buffer.from(encoded, "base64");
101
+ const signature = Buffer.from(value.signature, "base64url");
102
+ if (raw.length !== 32 || signature.length !== 64 || signature.toString("base64url") !== value.signature) return { ok: false };
103
+ const key = createPublicKey({
104
+ key: Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), raw]),
105
+ format: "der",
106
+ type: "spki"
107
+ });
108
+ if (!verify(null, message(descriptor), key, signature)) return { ok: false };
109
+ Object.freeze(descriptor.asset);
110
+ Object.freeze(descriptor);
111
+ verifiedDescriptors.set(descriptor, {
112
+ key: encoded,
113
+ signature: value.signature
114
+ });
115
+ return {
116
+ ok: true,
117
+ descriptor
118
+ };
119
+ } catch {
120
+ return { ok: false };
121
+ }
122
+ }
123
+ /** A verified descriptor remains valid only in the process that authenticated it. */
124
+ function isVerifiedRelease(value) {
125
+ return typeof value === "object" && value !== null && verifiedDescriptors.has(value);
126
+ }
127
+ /** Check that an authenticated descriptor used this exact application's current trust key. */
128
+ function isVerifiedReleaseForTrust(value, trust) {
129
+ return isVerifiedRelease(value) && value.appId === trust.appId && value.repository === trust.repository && value.channel === trust.channel && value.platform === trust.platform && value.arch === trust.arch && inFeed(value, trust.feed) && verifiedDescriptors.get(value)?.key === trust.keys.get(value.keyId);
130
+ }
131
+ /** Return the authenticated signed envelope for re-verification in another process. */
132
+ function exportVerifiedRelease(value, trust) {
133
+ if (!isVerifiedReleaseForTrust(value, trust)) throw new Error("Untrusted release descriptor");
134
+ return Object.freeze({
135
+ descriptor: value,
136
+ signature: verifiedDescriptors.get(value).signature
137
+ });
138
+ }
139
+ /** Check exact archive bytes after the descriptor has been authenticated. */
140
+ function verifyReleaseBytes(bytes, descriptor) {
141
+ if (!(bytes instanceof Uint8Array) || !verifiedDescriptors.has(descriptor) || bytes.byteLength !== descriptor.asset.size) return false;
142
+ const actual = createHash("sha256").update(bytes).digest();
143
+ return timingSafeEqual(actual, Buffer.from(descriptor.asset.sha256, "hex"));
144
+ }
145
+ /** Check a streamed archive without buffering the whole artifact. */
146
+ async function verifyReleaseStream(chunks, descriptor) {
147
+ if (!verifiedDescriptors.has(descriptor)) return false;
148
+ const hash = createHash("sha256");
149
+ let size = 0;
150
+ try {
151
+ for await (const chunk of chunks) {
152
+ if (!(chunk instanceof Uint8Array)) return false;
153
+ size += chunk.byteLength;
154
+ if (!Number.isSafeInteger(size) || size > descriptor.asset.size) return false;
155
+ hash.update(chunk);
156
+ }
157
+ return size === descriptor.asset.size && timingSafeEqual(hash.digest(), Buffer.from(descriptor.asset.sha256, "hex"));
158
+ } catch {
159
+ return false;
160
+ }
161
+ }
162
+ export { assertRepositorySlug, exportVerifiedRelease, isRepositorySlug, isVerifiedRelease, isVerifiedReleaseForTrust, signReleaseDescriptor, verifyReleaseBytes, verifyReleaseDescriptor, verifyReleaseStream };
@@ -0,0 +1,10 @@
1
+ import type { Stats } from 'node:fs';
2
+ import { type FileHandle } from 'node:fs/promises';
3
+ /** Whether two stats describe the same, unmodified file. */
4
+ export declare function sameFile(left: Stats, right: Stats): boolean;
5
+ /** Open the regular file `info` (from lstat) described, without following a link or
6
+ * blocking on a FIFO, and only if it has not been swapped or modified since. */
7
+ export declare function openUnchangedFile(path: string, info: Stats, message: string): Promise<{
8
+ file: FileHandle;
9
+ before: Stats;
10
+ }>;
@@ -0,0 +1,22 @@
1
+ import { open } from "node:fs/promises";
2
+ import { constants as constants$1 } from "node:fs";
3
+ // src/updates/stable-file.ts
4
+ /** Whether two stats describe the same, unmodified file. */
5
+ function sameFile(left, right) {
6
+ return left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs;
7
+ }
8
+ /** Open the regular file `info` (from lstat) described, without following a link or
9
+ * blocking on a FIFO, and only if it has not been swapped or modified since. */
10
+ async function openUnchangedFile(path, info, message) {
11
+ const file = await open(path, constants$1.O_RDONLY | (constants$1.O_NOFOLLOW ?? 0) | (constants$1.O_NONBLOCK ?? 0));
12
+ const before = await file.stat();
13
+ if (!before.isFile() || !sameFile(before, info)) {
14
+ await file.close();
15
+ throw new Error(message);
16
+ }
17
+ return {
18
+ file,
19
+ before
20
+ };
21
+ }
22
+ export { openUnchangedFile, sameFile };
@@ -0,0 +1,57 @@
1
+ import type { UpdateAdapter, UpdateChannel, UpdateState } from '@adea-ai/ui/components/composites/update-dialog';
2
+ export type { UpdateAdapter, UpdateChannel, UpdateState };
3
+ /** Channel persistence as a `read`/`persist` pair. */
4
+ export type UpdateChannelStore = Readonly<{
5
+ read(): Promise<UpdateChannel>;
6
+ /** Persist a selection; resolves with the channel that actually stuck. */
7
+ persist(channel: UpdateChannel): Promise<UpdateChannel>;
8
+ }>;
9
+ /** Channel persistence as a service exposing `channel`/`setChannel`. */
10
+ export type UpdateChannelService = Readonly<{
11
+ channel(): Promise<UpdateChannel>;
12
+ setChannel(channel: UpdateChannel): Promise<UpdateChannel>;
13
+ }>;
14
+ /** Either channel shape the update surface accepts. */
15
+ export type UpdateChannelSource = UpdateChannelStore | UpdateChannelService;
16
+ /** Normalize either channel shape to `read`/`persist`. */
17
+ export declare function updateChannelStore(source: UpdateChannelSource): UpdateChannelStore;
18
+ /**
19
+ * Report every snapshot the updater answers with, for a pending-update badge that
20
+ * must not run a second checker. The wrapped adapter otherwise behaves identically.
21
+ */
22
+ export declare function mirrorUpdateState(adapter: UpdateAdapter, onState: (state: UpdateState) => void): UpdateAdapter;
23
+ /** A native updater snapshot in snake_case, as Rust and older desktop hosts report it. */
24
+ export type NativeUpdateSnapshot = Readonly<{
25
+ available_version: string | null;
26
+ changelog: string;
27
+ current_version: string;
28
+ downloaded_bytes: number;
29
+ error: string | null;
30
+ github_url: string | null;
31
+ phase: UpdateState['phase'];
32
+ release_date: string | null;
33
+ release_notes?: string | null;
34
+ restart_required: boolean;
35
+ total_bytes: number | null;
36
+ }>;
37
+ /** A native updater that answers with snake_case snapshots. */
38
+ export type NativeUpdateAdapter = Readonly<{
39
+ check(): Promise<NativeUpdateSnapshot>;
40
+ getStatus(): Promise<NativeUpdateSnapshot>;
41
+ install(expectedVersion: string): Promise<NativeUpdateSnapshot>;
42
+ isDesktopRuntime(): boolean;
43
+ pollIntervalMs?: number;
44
+ }>;
45
+ /** Map a snake_case native snapshot to the shared update state. */
46
+ export declare function updateStateFromNative(update: NativeUpdateSnapshot, options?: {
47
+ releaseNotes?: boolean;
48
+ }): UpdateState;
49
+ /**
50
+ * Bridge a snake_case native updater to the shared adapter. Release notes are dropped
51
+ * unless requested, which keeps the dialog's per-release notes section hidden.
52
+ */
53
+ export declare function nativeUpdateAdapter(native: NativeUpdateAdapter | (() => NativeUpdateAdapter), options?: {
54
+ releaseNotes?: boolean;
55
+ }): UpdateAdapter;
56
+ /** The adapter for a build with no installer: the dialog explains updates are desktop-only. */
57
+ export declare function browserUpdateAdapter(currentVersion?: string): UpdateAdapter;
@@ -0,0 +1,72 @@
1
+ // src/updates/update-adapter.ts
2
+ /** Normalize either channel shape to `read`/`persist`. */
3
+ function updateChannelStore(source) {
4
+ if ("read" in source) return source;
5
+ return {
6
+ read: () => source.channel(),
7
+ persist: (channel) => source.setChannel(channel)
8
+ };
9
+ }
10
+ /**
11
+ * Report every snapshot the updater answers with, for a pending-update badge that
12
+ * must not run a second checker. The wrapped adapter otherwise behaves identically.
13
+ */
14
+ function mirrorUpdateState(adapter, onState) {
15
+ const note = async (pending) => {
16
+ const state = await pending;
17
+ onState(state);
18
+ return state;
19
+ };
20
+ const cancel = adapter.cancel;
21
+ return {
22
+ ...adapter,
23
+ check: () => note(adapter.check()),
24
+ getStatus: () => note(adapter.getStatus()),
25
+ install: (expectedVersion) => note(adapter.install(expectedVersion)),
26
+ ...cancel ? { cancel: () => note(cancel.call(adapter)) } : {}
27
+ };
28
+ }
29
+ /** Map a snake_case native snapshot to the shared update state. */
30
+ function updateStateFromNative(update, options = {}) {
31
+ return {
32
+ availableVersion: update.available_version,
33
+ changelog: update.changelog,
34
+ currentVersion: update.current_version,
35
+ downloadedBytes: update.downloaded_bytes,
36
+ error: update.error,
37
+ phase: update.phase,
38
+ releaseDate: update.release_date,
39
+ releaseNotes: options.releaseNotes ? update.release_notes ?? null : null,
40
+ releaseUrl: update.github_url,
41
+ restartRequired: update.restart_required,
42
+ totalBytes: update.total_bytes
43
+ };
44
+ }
45
+ /**
46
+ * Bridge a snake_case native updater to the shared adapter. Release notes are dropped
47
+ * unless requested, which keeps the dialog's per-release notes section hidden.
48
+ */
49
+ function nativeUpdateAdapter(native, options = {}) {
50
+ const current = typeof native === "function" ? native : () => native;
51
+ return {
52
+ check: async () => updateStateFromNative(await current().check(), options),
53
+ getStatus: async () => updateStateFromNative(await current().getStatus(), options),
54
+ install: async (expectedVersion) => updateStateFromNative(await current().install(expectedVersion), options),
55
+ isDesktopRuntime: () => current().isDesktopRuntime(),
56
+ pollIntervalMs: current().pollIntervalMs
57
+ };
58
+ }
59
+ /** The adapter for a build with no installer: the dialog explains updates are desktop-only. */
60
+ function browserUpdateAdapter(currentVersion = "") {
61
+ const state = {
62
+ phase: "unavailable",
63
+ currentVersion
64
+ };
65
+ return {
66
+ check: async () => state,
67
+ getStatus: async () => state,
68
+ install: async () => state,
69
+ isDesktopRuntime: () => false
70
+ };
71
+ }
72
+ export { browserUpdateAdapter, mirrorUpdateState, nativeUpdateAdapter, updateChannelStore, updateStateFromNative };
@@ -0,0 +1,24 @@
1
+ import type { UpdateHelperRequest } from './update-helper';
2
+ /**
3
+ * Start the post-exit update helper for a staged update, then resolve once the
4
+ * helper has verified this app's processes. The helper runs from copies of the
5
+ * app's Bun runtime and bundled helper script inside the private staging
6
+ * directory, because the install tree is about to move.
7
+ *
8
+ * Use it as the `arm` step of `scheduleUpdateShutdown`: quit only after it
9
+ * resolves, and call `cancel()` if the quit is vetoed.
10
+ */
11
+ export declare function armUpdateHelper(options: {
12
+ target: string;
13
+ platform: UpdateHelperRequest['platform'];
14
+ version: string;
15
+ /** Absolute path of the bundled helper script shipped with the app. */
16
+ helperScript: string;
17
+ /** Processes that must exit before the swap. Defaults to this process and its launcher parent. */
18
+ processes?: UpdateHelperRequest['processes'];
19
+ processTimeoutMs?: number;
20
+ armTimeoutMs?: number;
21
+ env?: Record<string, string | undefined>;
22
+ }): Promise<{
23
+ cancel(): Promise<void>;
24
+ }>;
@@ -0,0 +1,95 @@
1
+ import { updateStagingFor } from "./update-swap.js";
2
+ import { updateLauncherPath } from "./update-launch.js";
3
+ import { copyFile, lstat, mkdir, realpath, rm, unlink, writeFile } from "node:fs/promises";
4
+ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
5
+ import { spawn } from "node:child_process";
6
+ // src/updates/update-arm.ts
7
+ function exited(child) {
8
+ return child.exitCode !== null || child.signalCode !== null;
9
+ }
10
+ /** The Bun runtime inside an installed app tree, which the helper copy runs on. */
11
+ function updateRuntimePath(platform, target) {
12
+ const launcher = updateLauncherPath(platform, target);
13
+ return join(dirname(launcher), platform === "windows-x64" ? "bun.exe" : "bun");
14
+ }
15
+ /**
16
+ * Start the post-exit update helper for a staged update, then resolve once the
17
+ * helper has verified this app's processes. The helper runs from copies of the
18
+ * app's Bun runtime and bundled helper script inside the private staging
19
+ * directory, because the install tree is about to move.
20
+ *
21
+ * Use it as the `arm` step of `scheduleUpdateShutdown`: quit only after it
22
+ * resolves, and call `cancel()` if the quit is vetoed.
23
+ */
24
+ async function armUpdateHelper(options) {
25
+ const staging = updateStagingFor(options.target);
26
+ if (!isAbsolute(options.helperScript) || resolve(options.helperScript) !== options.helperScript) throw new Error("Invalid update helper script");
27
+ const info = await lstat(staging);
28
+ if (!info.isDirectory() || info.isSymbolicLink() || await realpath(staging) !== staging) throw new Error("Invalid update staging directory");
29
+ const helper = join(staging, "helper");
30
+ const runtime = join(helper, basename(updateRuntimePath(options.platform, options.target)));
31
+ const script = join(helper, "update-helper.js");
32
+ const request = {
33
+ schema: 1,
34
+ target: options.target,
35
+ platform: options.platform,
36
+ version: options.version,
37
+ processes: options.processes ?? [{
38
+ pid: process.pid,
39
+ executable: process.execPath
40
+ }, ...process.ppid > 1 ? [{
41
+ pid: process.ppid,
42
+ executable: updateLauncherPath(options.platform, options.target)
43
+ }] : []],
44
+ processTimeoutMs: options.processTimeoutMs ?? 3e4
45
+ };
46
+ const armed = join(staging, "helper-armed");
47
+ let child;
48
+ async function reset() {
49
+ if (child && !exited(child) && child.pid !== void 0) try {
50
+ process.kill(child.pid);
51
+ } catch {}
52
+ for (const name of ["request.json", "helper-armed"]) await unlink(join(staging, name)).catch(() => void 0);
53
+ await rm(helper, {
54
+ recursive: true,
55
+ force: true
56
+ });
57
+ }
58
+ try {
59
+ await mkdir(helper, { mode: 448 });
60
+ await copyFile(updateRuntimePath(options.platform, options.target), runtime);
61
+ await copyFile(options.helperScript, script);
62
+ await writeFile(join(staging, "request.json"), JSON.stringify(request) + "\n", {
63
+ flag: "wx",
64
+ mode: 384
65
+ });
66
+ const started = spawn(runtime, [
67
+ script,
68
+ "--staging",
69
+ staging
70
+ ], {
71
+ cwd: helper,
72
+ detached: true,
73
+ stdio: "ignore",
74
+ env: options.env ?? process.env,
75
+ windowsHide: true
76
+ });
77
+ child = started;
78
+ await new Promise((done, reject) => {
79
+ started.once("spawn", () => done());
80
+ started.once("error", reject);
81
+ });
82
+ started.unref();
83
+ const deadline = Date.now() + (options.armTimeoutMs ?? 15e3);
84
+ while (!await lstat(armed).catch(() => void 0)) {
85
+ if (exited(started)) throw new Error("Update helper exited before arming");
86
+ if (Date.now() >= deadline) throw new Error("Update helper did not arm in time");
87
+ await Bun.sleep(50);
88
+ }
89
+ } catch (error) {
90
+ await reset();
91
+ throw error;
92
+ }
93
+ return { cancel: reset };
94
+ }
95
+ export { armUpdateHelper };
@@ -0,0 +1,8 @@
1
+ import { type UpdateChannel } from './release-version';
2
+ /** Persist one app-owned update channel; the caller must supply a private state directory. */
3
+ export declare function createUpdateChannelStore(directory: string): {
4
+ read: () => Promise<UpdateChannel>;
5
+ save: (channel: UpdateChannel) => Promise<UpdateChannel>;
6
+ };
7
+ /** Shared UI uses pre-release; release descriptors use daily. */
8
+ export declare function releaseChannelForUpdate(channel: UpdateChannel): 'stable' | 'daily' | 'dev';
@@ -0,0 +1,72 @@
1
+ import { isUpdateChannel } from "./release-version.js";
2
+ import { openUnchangedFile, sameFile } from "./stable-file.js";
3
+ import { lstat, open, realpath, rename, unlink } from "node:fs/promises";
4
+ import { isAbsolute, join, resolve } from "node:path";
5
+ import { randomUUID } from "node:crypto";
6
+ // src/updates/update-channel-store.ts
7
+ /** Persist one app-owned update channel; the caller must supply a private state directory. */
8
+ function createUpdateChannelStore(directory) {
9
+ if (typeof directory !== "string" || !isAbsolute(directory) || resolve(directory) !== directory) throw new Error("Invalid update channel directory");
10
+ const path = join(directory, "update-channel.json");
11
+ let queue = Promise.resolve();
12
+ async function assertDirectory() {
13
+ const info = await lstat(directory);
14
+ if (!info.isDirectory() || info.isSymbolicLink() || await realpath(directory) !== directory) throw new Error("Invalid update channel directory");
15
+ }
16
+ async function read() {
17
+ await assertDirectory();
18
+ let info;
19
+ try {
20
+ info = await lstat(path);
21
+ } catch (error) {
22
+ if (error.code === "ENOENT") return "stable";
23
+ throw error;
24
+ }
25
+ if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || info.size > 4096) throw new Error("Invalid update channel file");
26
+ const { file, before } = await openUnchangedFile(path, info, "Invalid update channel file");
27
+ try {
28
+ const bytes = Buffer.alloc(before.size + 1);
29
+ const fileRead = await file.read(bytes, 0, bytes.length, 0);
30
+ if (fileRead.bytesRead !== before.size) throw new Error("Invalid update channel file");
31
+ const value = JSON.parse(bytes.subarray(0, fileRead.bytesRead).toString("utf8"));
32
+ const after = await file.stat();
33
+ if (!sameFile(before, after) || typeof value !== "object" || value === null || Array.isArray(value) || Object.keys(value).length !== 1 || !isUpdateChannel(value.channel)) throw new Error("Invalid update channel file");
34
+ return value.channel;
35
+ } finally {
36
+ await file.close();
37
+ }
38
+ }
39
+ function ordered(task) {
40
+ const result = queue.then(task);
41
+ queue = result.then(() => {}, () => {});
42
+ return result;
43
+ }
44
+ return {
45
+ read: () => ordered(read),
46
+ save: (channel) => ordered(async () => {
47
+ if (!isUpdateChannel(channel)) throw new Error("Invalid update channel");
48
+ await assertDirectory();
49
+ const temporary = join(directory, `.update-channel-${randomUUID()}.tmp`);
50
+ const file = await open(temporary, "wx", 384);
51
+ let moved = false;
52
+ try {
53
+ await file.writeFile(JSON.stringify({ channel }) + "\n");
54
+ await file.sync();
55
+ await file.close();
56
+ await rename(temporary, path);
57
+ moved = true;
58
+ if (await read() !== channel) throw new Error("Update channel write did not persist");
59
+ return channel;
60
+ } finally {
61
+ await file.close().catch(() => {});
62
+ if (!moved) await unlink(temporary).catch(() => {});
63
+ }
64
+ })
65
+ };
66
+ }
67
+ /** Shared UI uses pre-release; release descriptors use daily. */
68
+ function releaseChannelForUpdate(channel) {
69
+ if (!isUpdateChannel(channel)) throw new Error("Invalid update channel");
70
+ return channel === "pre-release" ? "daily" : channel;
71
+ }
72
+ export { createUpdateChannelStore, releaseChannelForUpdate };
@@ -0,0 +1,13 @@
1
+ import { type ReleaseTrust, type VerifiedRelease } from './signed-release';
2
+ import { type FetchFunction } from './release-location';
3
+ /** Discover and authenticate the app's channel descriptor without trusting feed metadata as an update. */
4
+ export declare function discoverSignedRelease(options: {
5
+ trust: ReleaseTrust;
6
+ discoveryName: string;
7
+ timeoutMs?: number;
8
+ signal?: AbortSignal;
9
+ fetch?: FetchFunction;
10
+ /** Take the newest release of the channel that sorts below this version instead of the
11
+ * channel pointer's release. */
12
+ olderThan?: string;
13
+ }): Promise<VerifiedRelease>;
@@ -0,0 +1,56 @@
1
+ import { isRepositorySlug, verifyReleaseDescriptor } from "./signed-release.js";
2
+ import { parseFeedRelease, parseReleaseLedger } from "./release-feed.js";
3
+ import { versionLessThan } from "./release-version.js";
4
+ import { fetchReleaseLocation, readReleaseBytes, readReleaseJson } from "./release-location.js";
5
+ import { createHash } from "node:crypto";
6
+ // src/updates/update-discovery.ts
7
+ var MAX_POINTER_BYTES = 262144;
8
+ var MAX_LEDGER_BYTES = 1048576;
9
+ /** Discover and authenticate the app's channel descriptor without trusting feed metadata as an update. */
10
+ async function discoverSignedRelease(options) {
11
+ const { trust, discoveryName, olderThan } = options;
12
+ const timeout = options.timeoutMs ?? 1e4;
13
+ if (!trust || !isRepositorySlug(trust.repository) || ![
14
+ "stable",
15
+ "daily",
16
+ "dev"
17
+ ].includes(trust.channel) || typeof trust.feed !== "string" || typeof discoveryName !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}\.json$/.test(discoveryName) || discoveryName === "release.json" || !Number.isSafeInteger(timeout) || timeout < 1 || timeout > 6e4) throw new Error("Invalid release discovery policy");
18
+ const controller = new AbortController(), timer = setTimeout(() => controller.abort(), timeout);
19
+ const signal = options.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
20
+ const fetcher = options.fetch ?? globalThis.fetch;
21
+ const get = (path) => fetchReleaseLocation(`${trust.feed}${path}`, trust.feed, fetcher, signal);
22
+ try {
23
+ if (signal.aborted) throw new Error("Release discovery cancelled");
24
+ let selected = null;
25
+ if (olderThan === void 0) {
26
+ selected = parseFeedRelease(await readReleaseJson(await get(`channels/${trust.channel}.json`), MAX_POINTER_BYTES));
27
+ if (selected.channel !== trust.channel) throw new Error("Invalid channel pointer");
28
+ } else {
29
+ const kinds = trust.channel === "stable" ? ["stable"] : trust.channel === "dev" ? ["dev"] : ["daily", "stable"];
30
+ const entry = parseReleaseLedger(await readReleaseJson(await get("index.json"), MAX_LEDGER_BYTES), new URL(trust.feed).pathname.split("/").at(-2)).releases.find((item) => kinds.includes(item.kind) && versionLessThan(item.tag, olderThan));
31
+ if (entry) {
32
+ selected = parseFeedRelease(await readReleaseJson(await get(`${entry.tag}/release.json`), MAX_POINTER_BYTES));
33
+ if (selected.tag !== entry.tag) throw new Error("Invalid feed release");
34
+ }
35
+ }
36
+ const listed = selected?.assets.find((asset) => asset.name === discoveryName);
37
+ if (!selected || !listed) throw new Error("No qualified channel descriptor is available");
38
+ const { tag } = selected;
39
+ const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
40
+ if (bytes.length !== listed.size || createHash("sha256").update(bytes).digest("hex") !== listed.sha256) throw new Error("Channel descriptor differs from its release");
41
+ let signed;
42
+ try {
43
+ signed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
44
+ } catch {
45
+ throw new Error("Invalid release feed response");
46
+ }
47
+ const result = verifyReleaseDescriptor(signed, trust);
48
+ if (!result.ok || result.descriptor.tag !== tag) throw new Error("Untrusted channel descriptor");
49
+ const payload = selected.assets.find((asset) => asset.name === result.descriptor.asset.name);
50
+ if (!payload || payload.size !== result.descriptor.asset.size || payload.sha256 !== result.descriptor.asset.sha256) throw new Error("Release payload is missing or differs from its descriptor");
51
+ return result.descriptor;
52
+ } finally {
53
+ clearTimeout(timer);
54
+ }
55
+ }
56
+ export { discoverSignedRelease };