@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,261 @@
1
+ import { createHash } from 'node:crypto'
2
+ import { constants } from 'node:fs'
3
+ import { lstat, mkdir, mkdtemp, open, readFile, realpath, rm, symlink } from 'node:fs/promises'
4
+ import { isAbsolute, join } from 'node:path'
5
+ import { Transform } from 'node:stream'
6
+ import { pipeline } from 'node:stream/promises'
7
+ import { createZstdDecompress } from 'node:zlib'
8
+ import { x as extract } from 'tar'
9
+ import {
10
+ assertBuildMetadata,
11
+ assertPayloadLayout,
12
+ assertPortableAppName,
13
+ type InstallerPlatform,
14
+ type InstallerRenderer,
15
+ } from '../installer/installer-layout'
16
+ import { isVerifiedRelease, verifyReleaseStream, type VerifiedRelease } from './signed-release'
17
+ import { isLinuxCefLibraryLink } from '../native/linux-cef-links'
18
+ import { safeArchivePath } from '../installer/archive-entry'
19
+ import { assertSidecarNames, sidecarBundlePath } from '../native/app-bundle'
20
+
21
+ /** Extract a verified full update into a new private directory. Does not replace an installed app. */
22
+ export async function extractVerifiedUpdate(options: {
23
+ descriptor: VerifiedRelease
24
+ archive: string
25
+ directory: string
26
+ platform: InstallerPlatform
27
+ renderer: InstallerRenderer
28
+ appName: string
29
+ maxCompressedBytes: number
30
+ maxExpandedBytes: number
31
+ /** Sidecar executables the app bundles; each must be a present, executable file. */
32
+ sidecars?: readonly string[]
33
+ }): Promise<{ directory: string; payload: string }> {
34
+ const { descriptor, archive, platform, renderer, appName, maxCompressedBytes, maxExpandedBytes } =
35
+ options
36
+ const expected = {
37
+ 'macos-arm64': ['darwin', 'arm64'],
38
+ 'windows-x64': ['win32', 'x64'],
39
+ 'linux-x64': ['linux', 'x64'],
40
+ } as const
41
+ if (
42
+ !isVerifiedRelease(descriptor) ||
43
+ !expected[platform] ||
44
+ descriptor.platform !== expected[platform][0] ||
45
+ descriptor.arch !== expected[platform][1] ||
46
+ !isAbsolute(archive) ||
47
+ !isAbsolute(options.directory) ||
48
+ !Number.isSafeInteger(maxCompressedBytes) ||
49
+ maxCompressedBytes < 1 ||
50
+ descriptor.asset.size > maxCompressedBytes ||
51
+ !Number.isSafeInteger(maxExpandedBytes) ||
52
+ maxExpandedBytes < 1
53
+ )
54
+ throw new Error('Invalid update extraction context')
55
+ assertPortableAppName(appName)
56
+ const sidecars = assertSidecarNames(options.sidecars ?? [])
57
+ const archiveRoot = platform === 'macos-arm64' ? `${appName}.app` : appName.replaceAll(' ', '')
58
+ const info = await lstat(archive)
59
+ if (!info.isFile() || info.isSymbolicLink() || info.size !== descriptor.asset.size)
60
+ throw new Error('Invalid update archive')
61
+ const file = await open(archive, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0))
62
+ let directory: string | undefined
63
+ try {
64
+ const before = await file.stat()
65
+ if (
66
+ !before.isFile() ||
67
+ before.dev !== info.dev ||
68
+ before.ino !== info.ino ||
69
+ before.size !== info.size ||
70
+ !(await verifyReleaseStream(
71
+ file.createReadStream({ autoClose: false, start: 0 }),
72
+ descriptor
73
+ ))
74
+ )
75
+ throw new Error('Update archive verification failed')
76
+ const parent = await realpath(options.directory)
77
+ if (!(await lstat(parent)).isDirectory()) throw new Error('Invalid update staging directory')
78
+ directory = await mkdtemp(join(parent, 'framework-update-extract-'))
79
+ const payloadRoot = join(directory, 'payload'),
80
+ decompressed = join(directory, 'payload.tar')
81
+ await mkdir(payloadRoot, { mode: 0o700 })
82
+ const entries: string[] = [],
83
+ links: { path: string; target: string }[] = [],
84
+ seen = new Set<string>(),
85
+ fold = platform === 'windows-x64'
86
+ let invalid = false
87
+ const reject = () => {
88
+ invalid = true
89
+ return false
90
+ }
91
+ let expanded = 0,
92
+ fileBytes = 0
93
+ const bound = new Transform({
94
+ transform(chunk, _encoding, done) {
95
+ expanded += chunk.length
96
+ if (!Number.isSafeInteger(expanded) || expanded > maxExpandedBytes)
97
+ done(new Error('Expanded update exceeds bound'))
98
+ else done(null, chunk)
99
+ },
100
+ })
101
+ const hash = createHash('sha256')
102
+ let compressedBytes = 0
103
+ const verifyInput = new Transform({
104
+ transform(chunk, _encoding, done) {
105
+ compressedBytes += chunk.length
106
+ if (!Number.isSafeInteger(compressedBytes) || compressedBytes > descriptor.asset.size)
107
+ done(new Error('Update archive exceeds signed size'))
108
+ else {
109
+ hash.update(chunk)
110
+ done(null, chunk)
111
+ }
112
+ },
113
+ })
114
+ const output = await open(decompressed, 'wx', 0o600)
115
+ try {
116
+ await pipeline(
117
+ file.createReadStream({ autoClose: false, start: 0 }),
118
+ verifyInput,
119
+ createZstdDecompress(),
120
+ bound,
121
+ output.createWriteStream({ autoClose: true })
122
+ )
123
+ } finally {
124
+ await output.close()
125
+ }
126
+ if (compressedBytes !== descriptor.asset.size || hash.digest('hex') !== descriptor.asset.sha256)
127
+ throw new Error('Update archive changed during decompression')
128
+ const unpack = extract({
129
+ file: decompressed,
130
+ cwd: payloadRoot,
131
+ strict: true,
132
+ preserveOwner: false,
133
+ chmod: true,
134
+ umask: 0o7022,
135
+ maxMetaEntrySize: 1024 * 1024,
136
+ filter(path, entry) {
137
+ if (!('type' in entry)) return reject()
138
+ if (path === '.' || path === './') {
139
+ if (entry.type !== 'Directory') return reject()
140
+ return false
141
+ }
142
+ const normalized = safeArchivePath(path, fold)
143
+ if (!normalized) return reject()
144
+ const canonical = normalized.normalize('NFC'),
145
+ canonicalRoot = archiveRoot.normalize('NFC')
146
+ const key = fold ? canonical.toLowerCase() : canonical
147
+ const rootKey = fold ? canonicalRoot.toLowerCase() : canonicalRoot
148
+ if (key !== rootKey && !key.startsWith(rootKey + '/')) return reject()
149
+ if (seen.has(key) || seen.size >= 200000) return reject()
150
+ const relative = normalized.slice(archiveRoot.length + 1),
151
+ linkTarget = typeof entry.linkpath === 'string' ? entry.linkpath : ''
152
+ const cefLink =
153
+ platform === 'linux-x64' &&
154
+ renderer === 'cef' &&
155
+ entry.type === 'SymbolicLink' &&
156
+ isLinuxCefLibraryLink(relative, linkTarget)
157
+ if (entry.type !== 'File' && entry.type !== 'Directory' && !cefLink) return reject()
158
+ seen.add(key)
159
+ entries.push(normalized)
160
+ // Never let the tar extractor traverse a link: create the known links
161
+ // only after every ordinary entry has been extracted and validated.
162
+ if (cefLink) {
163
+ links.push({ path: normalized, target: linkTarget })
164
+ return false
165
+ }
166
+ if (entry.type === 'File') {
167
+ if (!Number.isSafeInteger(entry.size) || entry.size < 0) return reject()
168
+ fileBytes += entry.size
169
+ if (!Number.isSafeInteger(fileBytes) || fileBytes > maxExpandedBytes) return reject()
170
+ }
171
+ return true
172
+ },
173
+ })
174
+ await unpack
175
+ if (invalid) throw new Error('Unsafe or unsupported update archive entry')
176
+ if (links.length) {
177
+ const bin = join(payloadRoot, archiveRoot, 'bin'),
178
+ cef = join(bin, 'cef')
179
+ for (const path of [join(payloadRoot, archiveRoot), bin, cef]) {
180
+ const value = await lstat(path)
181
+ if (!value.isDirectory() || value.isSymbolicLink())
182
+ throw new Error('Invalid CEF link directory')
183
+ }
184
+ for (const link of links) {
185
+ const destination = join(payloadRoot, link.path),
186
+ target = join(bin, link.target),
187
+ value = await lstat(target)
188
+ if (!value.isFile() || value.isSymbolicLink()) throw new Error('Invalid CEF link target')
189
+ await symlink(link.target, destination)
190
+ }
191
+ }
192
+ await rm(decompressed)
193
+ const after = await file.stat()
194
+ if (
195
+ after.dev !== before.dev ||
196
+ after.ino !== before.ino ||
197
+ after.size !== before.size ||
198
+ after.mtimeMs !== before.mtimeMs ||
199
+ !(await verifyReleaseStream(
200
+ file.createReadStream({ autoClose: false, start: 0 }),
201
+ descriptor
202
+ ))
203
+ )
204
+ throw new Error('Update archive changed during extraction')
205
+ assertPayloadLayout({ platform, renderer, appName, entries, sidecars })
206
+ const prefix =
207
+ platform === 'macos-arm64' ? join(`${appName}.app`, 'Contents') : appName.replaceAll(' ', '')
208
+ const resources = join(payloadRoot, prefix, 'Resources')
209
+ const bin = platform === 'macos-arm64' ? 'MacOS' : 'bin',
210
+ suffix = platform === 'windows-x64' ? '.exe' : ''
211
+ const executables = [
212
+ join(bin, `launcher${suffix}`),
213
+ join(bin, `bun${suffix}`),
214
+ ...sidecars.map((name) => sidecarBundlePath(name, platform)),
215
+ ]
216
+ const critical = [
217
+ ...executables,
218
+ 'Resources/main.js',
219
+ 'Resources/app/bun/index.js',
220
+ 'Resources/app/client/index.html',
221
+ ]
222
+ for (const path of critical) {
223
+ const item = await lstat(join(payloadRoot, prefix, path))
224
+ if (
225
+ !item.isFile() ||
226
+ item.isSymbolicLink() ||
227
+ item.size < 1 ||
228
+ (platform !== 'windows-x64' &&
229
+ process.platform !== 'win32' &&
230
+ executables.includes(path) &&
231
+ !(item.mode & 0o100))
232
+ )
233
+ throw new Error('Invalid critical update file')
234
+ }
235
+ for (const name of ['version.json', 'build.json']) {
236
+ const metadata = await lstat(join(resources, name))
237
+ if (
238
+ !metadata.isFile() ||
239
+ metadata.isSymbolicLink() ||
240
+ metadata.size < 1 ||
241
+ metadata.size > 1024 * 1024
242
+ )
243
+ throw new Error('Invalid update metadata')
244
+ }
245
+ if (
246
+ JSON.parse(await readFile(join(resources, 'version.json'), 'utf8')).version !==
247
+ descriptor.version
248
+ )
249
+ throw new Error('Update version mismatch')
250
+ assertBuildMetadata(JSON.parse(await readFile(join(resources, 'build.json'), 'utf8')), renderer)
251
+ return {
252
+ directory,
253
+ payload: join(payloadRoot, platform === 'macos-arm64' ? `${appName}.app` : prefix),
254
+ }
255
+ } catch (error) {
256
+ if (directory) await rm(directory, { recursive: true, force: true })
257
+ throw error
258
+ } finally {
259
+ await file.close()
260
+ }
261
+ }
@@ -0,0 +1,75 @@
1
+ import { basename, isAbsolute, resolve } from 'node:path'
2
+ import {
3
+ assertPortableAppName,
4
+ type InstallerPlatform,
5
+ type InstallerRenderer,
6
+ } from '../installer/installer-layout'
7
+ import {
8
+ isVerifiedReleaseForTrust,
9
+ type ReleaseTrust,
10
+ type VerifiedRelease,
11
+ } from './signed-release'
12
+ import { versionLessThan } from './release-version'
13
+
14
+ /** Validate an explicitly approved update and its intended installation. This plan does not move files or launch a helper. */
15
+ export function planUpdateHandoff(options: {
16
+ descriptor: VerifiedRelease
17
+ trust: ReleaseTrust
18
+ currentVersion: string
19
+ approved: boolean
20
+ approvedVersion: string
21
+ target: string
22
+ appName: string
23
+ platform: InstallerPlatform
24
+ renderer: InstallerRenderer
25
+ }) {
26
+ const {
27
+ descriptor,
28
+ trust,
29
+ currentVersion,
30
+ approved,
31
+ approvedVersion,
32
+ target,
33
+ appName,
34
+ platform,
35
+ renderer,
36
+ } = options
37
+ assertPortableAppName(appName)
38
+ const expected = {
39
+ 'macos-arm64': ['darwin', 'arm64'],
40
+ 'windows-x64': ['win32', 'x64'],
41
+ 'linux-x64': ['linux', 'x64'],
42
+ } as const
43
+ if (
44
+ !expected[platform] ||
45
+ !['native', 'cef'].includes(renderer) ||
46
+ !isVerifiedReleaseForTrust(descriptor, trust) ||
47
+ descriptor.platform !== expected[platform][0] ||
48
+ descriptor.arch !== expected[platform][1] ||
49
+ approved !== true ||
50
+ approvedVersion !== descriptor.version ||
51
+ typeof currentVersion !== 'string' ||
52
+ currentVersion.length > 64 ||
53
+ !/^\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(currentVersion) ||
54
+ !versionLessThan(currentVersion, descriptor.version)
55
+ )
56
+ throw new Error('Invalid approved update')
57
+ // Electrobun installs a macOS bundle by name and Windows/Linux trees at `<identifier>/<channel>/app`.
58
+ const name = platform === 'macos-arm64' ? `${appName}.app` : 'app'
59
+ if (
60
+ typeof target !== 'string' ||
61
+ !isAbsolute(target) ||
62
+ resolve(target) !== target ||
63
+ basename(target) !== name
64
+ )
65
+ throw new Error('Invalid update target')
66
+ return Object.freeze({
67
+ target,
68
+ appName,
69
+ platform,
70
+ renderer,
71
+ currentVersion,
72
+ version: descriptor.version,
73
+ archiveSha256: descriptor.asset.sha256,
74
+ })
75
+ }
@@ -0,0 +1,87 @@
1
+ import { constants, writeFileSync } from 'node:fs'
2
+ import { lstat, open, writeFile } from 'node:fs/promises'
3
+ import { isAbsolute, join, resolve } from 'node:path'
4
+ import { launchInstalledApp } from './update-launch'
5
+ import { waitForUpdateProcesses } from './update-process-fence'
6
+ import { swapUpdateTree, updateStagingFor } from './update-swap'
7
+ import type { InstallerPlatform } from '../installer/installer-layout'
8
+
9
+ /** Everything the post-exit helper needs, written by the app into its private staging directory. */
10
+ export type UpdateHelperRequest = Readonly<{
11
+ schema: 1
12
+ target: string
13
+ platform: InstallerPlatform
14
+ version: string
15
+ processes: readonly Readonly<{ pid: number; executable: string }>[]
16
+ processTimeoutMs: number
17
+ }>
18
+
19
+ /** Validate a helper request's shape. */
20
+ export function parseUpdateHelperRequest(value: unknown): UpdateHelperRequest {
21
+ const data = value as Record<string, unknown>
22
+ if (
23
+ typeof value !== 'object' ||
24
+ value === null ||
25
+ Array.isArray(value) ||
26
+ data.schema !== 1 ||
27
+ typeof data.target !== 'string' ||
28
+ !isAbsolute(data.target) ||
29
+ resolve(data.target) !== data.target ||
30
+ !['macos-arm64', 'windows-x64', 'linux-x64'].includes(data.platform as string) ||
31
+ typeof data.version !== 'string' ||
32
+ !/^\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(data.version) ||
33
+ !Array.isArray(data.processes) ||
34
+ !Number.isSafeInteger(data.processTimeoutMs) ||
35
+ (data.processTimeoutMs as number) < 1 ||
36
+ (data.processTimeoutMs as number) > 120000
37
+ )
38
+ throw new Error('Invalid update helper request')
39
+ return Object.freeze(data as UpdateHelperRequest)
40
+ }
41
+
42
+ async function readRequest(staging: string): Promise<UpdateHelperRequest> {
43
+ const path = join(staging, 'request.json'),
44
+ info = await lstat(path)
45
+ if (!info.isFile() || info.size < 1 || info.size > 65536)
46
+ throw new Error('Invalid update helper request')
47
+ const file = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0))
48
+ try {
49
+ return parseUpdateHelperRequest(JSON.parse(await file.readFile('utf8')))
50
+ } finally {
51
+ await file.close()
52
+ }
53
+ }
54
+
55
+ /**
56
+ * The post-exit helper: wait for the app's processes to exit, swap in the
57
+ * staged candidate, record the new version and relaunch the app. Run from a
58
+ * copy outside the install tree; `armUpdateHelper` prepares that copy.
59
+ */
60
+ export async function runUpdateHelper(options: {
61
+ staging: string
62
+ env?: Record<string, string | undefined>
63
+ }): Promise<'updated' | 'failed'> {
64
+ const request = await readRequest(options.staging)
65
+ if (updateStagingFor(request.target) !== options.staging)
66
+ throw new Error('Update helper request does not match its staging directory')
67
+ await waitForUpdateProcesses({
68
+ processes: request.processes,
69
+ timeoutMs: request.processTimeoutMs,
70
+ // The app waits for this marker before it quits, so the fence sees it alive.
71
+ onVerified: () =>
72
+ writeFileSync(join(options.staging, 'helper-armed'), String(process.pid), {
73
+ flag: 'wx',
74
+ mode: 0o600,
75
+ }),
76
+ })
77
+ let outcome: 'updated' | 'failed' = 'failed'
78
+ try {
79
+ await swapUpdateTree({ target: request.target, staging: options.staging })
80
+ await writeFile(join(options.staging, 'updated'), request.version, { mode: 0o600 })
81
+ outcome = 'updated'
82
+ } catch {
83
+ /* Relaunch the unchanged install. */
84
+ }
85
+ await launchInstalledApp(request.platform, request.target, options.env)
86
+ return outcome
87
+ }
@@ -0,0 +1,33 @@
1
+ import { spawn } from 'node:child_process'
2
+ import { dirname, isAbsolute, join, resolve } from 'node:path'
3
+ import type { InstallerPlatform } from '../installer/installer-layout'
4
+
5
+ /** The Electrobun launcher inside an installed app tree. */
6
+ export function updateLauncherPath(platform: InstallerPlatform, target: string): string {
7
+ if (typeof target !== 'string' || !isAbsolute(target) || resolve(target) !== target)
8
+ throw new Error('Invalid update target')
9
+ if (platform === 'macos-arm64') return join(target, 'Contents', 'MacOS', 'launcher')
10
+ if (platform === 'windows-x64') return join(target, 'bin', 'launcher.exe')
11
+ if (platform === 'linux-x64') return join(target, 'bin', 'launcher')
12
+ throw new Error('Unsupported update platform')
13
+ }
14
+
15
+ /** Start the installed app's launcher detached from the helper. */
16
+ export async function launchInstalledApp(
17
+ platform: InstallerPlatform,
18
+ target: string,
19
+ env: Record<string, string | undefined> = process.env
20
+ ): Promise<void> {
21
+ const executable = updateLauncherPath(platform, target)
22
+ const child = spawn(executable, [], {
23
+ cwd: dirname(executable),
24
+ detached: true,
25
+ stdio: 'ignore',
26
+ env,
27
+ })
28
+ await new Promise<void>((done, reject) => {
29
+ child.once('spawn', done)
30
+ child.once('error', reject)
31
+ })
32
+ child.unref()
33
+ }
@@ -0,0 +1,130 @@
1
+ import { discoverSignedRelease } from './update-discovery'
2
+ import { downloadVerifiedRelease } from './update-download'
3
+ import {
4
+ isVerifiedReleaseForTrust,
5
+ type ReleaseTrust,
6
+ type VerifiedRelease,
7
+ } from './signed-release'
8
+ import { versionLessThan } from './release-version'
9
+ import type { FetchFunction } from './release-location'
10
+
11
+ type Phase =
12
+ | 'idle'
13
+ | 'checking'
14
+ | 'current'
15
+ | 'available'
16
+ | 'downloading'
17
+ | 'staging'
18
+ | 'staged'
19
+ | 'failed'
20
+ type State = Readonly<{
21
+ phase: Phase
22
+ currentVersion: string
23
+ availableVersion: string | null
24
+ error: string | null
25
+ }>
26
+ /** Coordinates trusted discovery and download; the platform adapter owns safe application and recovery. */
27
+ export function createUpdateManager(options: {
28
+ currentVersion: string
29
+ trust: ReleaseTrust
30
+ discoveryName: string
31
+ directory: string
32
+ maxBytes: number
33
+ stage: (input: { descriptor: VerifiedRelease; path: string; directory: string }) => Promise<void>
34
+ discover?: typeof discoverSignedRelease
35
+ download?: typeof downloadVerifiedRelease
36
+ fetch?: FetchFunction
37
+ }) {
38
+ if (
39
+ !/^\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(options.currentVersion) ||
40
+ options.currentVersion.length > 64 ||
41
+ !Number.isSafeInteger(options.maxBytes) ||
42
+ options.maxBytes < 1 ||
43
+ typeof options.stage !== 'function'
44
+ )
45
+ throw new Error('Invalid update manager configuration')
46
+ let state: State = Object.freeze({
47
+ phase: 'idle',
48
+ currentVersion: options.currentVersion,
49
+ availableVersion: null,
50
+ error: null,
51
+ })
52
+ let pending: VerifiedRelease | undefined,
53
+ busy = false
54
+ const set = (
55
+ phase: Phase,
56
+ version: string | null = pending?.version ?? null,
57
+ error: string | null = null
58
+ ): State =>
59
+ (state = Object.freeze({
60
+ phase,
61
+ currentVersion: options.currentVersion,
62
+ availableVersion: version,
63
+ error,
64
+ }))
65
+ const acquire = () => {
66
+ if (busy) throw new Error('Update manager is busy')
67
+ busy = true
68
+ }
69
+ return {
70
+ status: () => state,
71
+ async check(): Promise<State> {
72
+ acquire()
73
+ if (state.phase === 'staged') {
74
+ busy = false
75
+ throw new Error('An update is already staged')
76
+ }
77
+ pending = undefined
78
+ set('checking', null)
79
+ try {
80
+ const descriptor = await (options.discover ?? discoverSignedRelease)({
81
+ trust: options.trust,
82
+ discoveryName: options.discoveryName,
83
+ fetch: options.fetch,
84
+ })
85
+ if (!isVerifiedReleaseForTrust(descriptor, options.trust))
86
+ throw new Error('Untrusted update')
87
+ if (!versionLessThan(options.currentVersion, descriptor.version))
88
+ return set('current', null)
89
+ pending = descriptor
90
+ return set('available')
91
+ } catch {
92
+ pending = undefined
93
+ return set('failed', null, 'Update check failed. Please try again.')
94
+ } finally {
95
+ busy = false
96
+ }
97
+ },
98
+ async install(input: { approved: boolean; expectedVersion: string }): Promise<State> {
99
+ acquire()
100
+ try {
101
+ if (
102
+ input.approved !== true ||
103
+ !pending ||
104
+ state.phase !== 'available' ||
105
+ input.expectedVersion !== pending.version
106
+ )
107
+ throw new Error('Update approval does not match the available version')
108
+ const descriptor = pending
109
+ set('downloading')
110
+ try {
111
+ const download = await (options.download ?? downloadVerifiedRelease)({
112
+ descriptor,
113
+ directory: options.directory,
114
+ maxBytes: options.maxBytes,
115
+ fetch: options.fetch,
116
+ })
117
+ set('staging')
118
+ await options.stage({ descriptor, ...download })
119
+ pending = undefined
120
+ return set('staged', descriptor.version)
121
+ } catch {
122
+ pending = undefined
123
+ return set('failed', null, 'Update staging failed. Please try again.')
124
+ }
125
+ } finally {
126
+ busy = false
127
+ }
128
+ },
129
+ }
130
+ }