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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +30 -0
  3. package/README.md +1009 -2
  4. package/dist/app/application.d.ts +47 -0
  5. package/dist/app/application.js +115 -0
  6. package/dist/app/create-application.d.ts +13 -0
  7. package/dist/app/create-application.js +178 -0
  8. package/dist/app/service-registry.d.ts +44 -0
  9. package/dist/app/service-registry.js +116 -0
  10. package/dist/appearance/appearance-host.d.ts +62 -0
  11. package/dist/appearance/appearance-host.js +115 -0
  12. package/dist/appearance/appearance-preferences.d.ts +106 -0
  13. package/dist/appearance/appearance-preferences.js +175 -0
  14. package/dist/appearance/composition.d.ts +11 -0
  15. package/dist/appearance/composition.js +16 -0
  16. package/dist/appearance/custom-theme-import.d.ts +14 -0
  17. package/dist/appearance/custom-theme-import.js +315 -0
  18. package/dist/appearance/custom-theme-library.d.ts +146 -0
  19. package/dist/appearance/custom-theme-library.js +378 -0
  20. package/dist/appearance/editor.d.ts +20 -0
  21. package/dist/appearance/editor.js +47 -0
  22. package/dist/appearance/theme-file-importer.d.ts +23 -0
  23. package/dist/appearance/theme-file-importer.js +66 -0
  24. package/dist/appearance/theme-record-adapter.d.ts +26 -0
  25. package/dist/appearance/theme-record-adapter.js +64 -0
  26. package/dist/appearance/theme-registry.d.ts +10 -0
  27. package/dist/appearance/theme-registry.js +16 -0
  28. package/dist/appearance/window-surface.d.ts +5 -0
  29. package/dist/appearance/window-surface.js +9 -0
  30. package/dist/ci/toolchain-identity.d.ts +39 -0
  31. package/dist/ci/toolchain-identity.js +196 -0
  32. package/dist/cli/cef-helper-cli.d.ts +2 -0
  33. package/dist/cli/cef-helper-cli.js +18 -0
  34. package/dist/cli/cli-runner.d.ts +8 -0
  35. package/dist/cli/cli-runner.js +23 -0
  36. package/dist/cli/create-application-cli.d.ts +2 -0
  37. package/dist/cli/create-application-cli.js +40 -0
  38. package/dist/cli/electrobun-shortcut-patch-cli.d.ts +2 -0
  39. package/dist/cli/electrobun-shortcut-patch-cli.js +17 -0
  40. package/dist/cli/framework-update-cli.d.ts +2 -0
  41. package/dist/cli/framework-update-cli.js +40 -0
  42. package/dist/cli/release-assets-plan-cli.d.ts +2 -0
  43. package/dist/cli/release-assets-plan-cli.js +14 -0
  44. package/dist/cli/release-cut-cli.d.ts +2 -0
  45. package/dist/cli/release-cut-cli.js +27 -0
  46. package/dist/cli/release-descriptor-staging-cli.d.ts +2 -0
  47. package/dist/cli/release-descriptor-staging-cli.js +45 -0
  48. package/dist/cli/release-finalize-cli.d.ts +1 -0
  49. package/dist/cli/release-finalize-cli.js +30 -0
  50. package/dist/cli/release-promote-cli.d.ts +2 -0
  51. package/dist/cli/release-promote-cli.js +32 -0
  52. package/dist/cli/release-publish-cli.d.ts +2 -0
  53. package/dist/cli/release-publish-cli.js +48 -0
  54. package/dist/cli/release-sign-cli.d.ts +2 -0
  55. package/dist/cli/release-sign-cli.js +13 -0
  56. package/dist/cli/release-step-cli.d.ts +2 -0
  57. package/dist/cli/release-step-cli.js +44 -0
  58. package/dist/cli/toolchain-identity-cli.d.ts +2 -0
  59. package/dist/cli/toolchain-identity-cli.js +10 -0
  60. package/dist/cli/update-helper-cli.d.ts +1 -0
  61. package/dist/cli/update-helper-cli.js +10 -0
  62. package/dist/cli/windows-runtime-patch-cli.d.ts +2 -0
  63. package/dist/cli/windows-runtime-patch-cli.js +17 -0
  64. package/dist/desktop/application-command-client.d.ts +15 -0
  65. package/dist/desktop/application-command-client.js +21 -0
  66. package/dist/desktop/channel-handshake.d.ts +32 -0
  67. package/dist/desktop/channel-handshake.js +111 -0
  68. package/dist/desktop/channel-proof.d.ts +43 -0
  69. package/dist/desktop/channel-proof.js +85 -0
  70. package/dist/desktop/client-assets.d.ts +7 -0
  71. package/dist/desktop/client-assets.js +59 -0
  72. package/dist/desktop/desktop-client.d.ts +23 -0
  73. package/dist/desktop/desktop-client.js +231 -0
  74. package/dist/desktop/desktop-gateway.d.ts +18 -0
  75. package/dist/desktop/desktop-gateway.js +146 -0
  76. package/dist/desktop/desktop-host.d.ts +48 -0
  77. package/dist/desktop/desktop-host.js +208 -0
  78. package/dist/desktop/desktop-stream.d.ts +36 -0
  79. package/dist/desktop/desktop-stream.js +231 -0
  80. package/dist/desktop/loopback-policy.d.ts +19 -0
  81. package/dist/desktop/loopback-policy.js +23 -0
  82. package/dist/desktop/open-url-channel.d.ts +15 -0
  83. package/dist/desktop/open-url-channel.js +55 -0
  84. package/dist/desktop/string-policy.d.ts +2 -0
  85. package/dist/desktop/string-policy.js +11 -0
  86. package/dist/framework-source.json +1 -0
  87. package/dist/installer/archive-entry.d.ts +6 -0
  88. package/dist/installer/archive-entry.js +14 -0
  89. package/dist/installer/command-artifact.d.ts +47 -0
  90. package/dist/installer/command-artifact.js +261 -0
  91. package/dist/installer/command-qualification-command.d.ts +12 -0
  92. package/dist/installer/command-qualification-command.js +71 -0
  93. package/dist/installer/hosted-runner.d.ts +4 -0
  94. package/dist/installer/hosted-runner.js +10 -0
  95. package/dist/installer/installed-payload.d.ts +29 -0
  96. package/dist/installer/installed-payload.js +312 -0
  97. package/dist/installer/installer-ci-bootstrap.d.ts +26 -0
  98. package/dist/installer/installer-ci-bootstrap.js +160 -0
  99. package/dist/installer/installer-ci-preflight.d.ts +1 -0
  100. package/dist/installer/installer-ci-preflight.js +49 -0
  101. package/dist/installer/installer-ci-worker.d.ts +1 -0
  102. package/dist/installer/installer-ci-worker.js +105 -0
  103. package/dist/installer/installer-extraction.d.ts +14 -0
  104. package/dist/installer/installer-extraction.js +289 -0
  105. package/dist/installer/installer-fetch-guard.d.ts +15 -0
  106. package/dist/installer/installer-fetch-guard.js +50 -0
  107. package/dist/installer/installer-identity.d.ts +23 -0
  108. package/dist/installer/installer-identity.js +286 -0
  109. package/dist/installer/installer-layout.d.ts +21 -0
  110. package/dist/installer/installer-layout.js +89 -0
  111. package/dist/installer/installer-observation.d.ts +64 -0
  112. package/dist/installer/installer-observation.js +473 -0
  113. package/dist/installer/installer-process-cleanup.d.ts +18 -0
  114. package/dist/installer/installer-process-cleanup.js +158 -0
  115. package/dist/installer/installer-qualification-command.d.ts +11 -0
  116. package/dist/installer/installer-qualification-command.js +71 -0
  117. package/dist/installer/installer-renderer-evidence.d.ts +43 -0
  118. package/dist/installer/installer-renderer-evidence.js +136 -0
  119. package/dist/installer/installer-upgrade-command.d.ts +37 -0
  120. package/dist/installer/installer-upgrade-command.js +172 -0
  121. package/dist/installer/installer-worker-guard.d.ts +21 -0
  122. package/dist/installer/installer-worker-guard.js +72 -0
  123. package/dist/installer/native-executable.d.ts +5 -0
  124. package/dist/installer/native-executable.js +21 -0
  125. package/dist/installer/upgrade-asset-download.d.ts +13 -0
  126. package/dist/installer/upgrade-asset-download.js +41 -0
  127. package/dist/installer/write-all.d.ts +6 -0
  128. package/dist/installer/write-all.js +11 -0
  129. package/dist/native/app-bundle.d.ts +28 -0
  130. package/dist/native/app-bundle.js +60 -0
  131. package/dist/native/cef-helper.d.ts +28 -0
  132. package/dist/native/cef-helper.js +402 -0
  133. package/dist/native/desktop-build-hook.d.ts +7 -0
  134. package/dist/native/desktop-build-hook.js +20 -0
  135. package/dist/native/electrobun-source-patch.d.ts +25 -0
  136. package/dist/native/electrobun-source-patch.js +93 -0
  137. package/dist/native/linux-cef-links.d.ts +2 -0
  138. package/dist/native/linux-cef-links.js +15 -0
  139. package/dist/native/native-secret-store.d.ts +27 -0
  140. package/dist/native/native-secret-store.js +70 -0
  141. package/dist/native/native-utilities.d.ts +24 -0
  142. package/dist/native/native-utilities.js +85 -0
  143. package/dist/native/partitioned-window.d.ts +34 -0
  144. package/dist/native/partitioned-window.js +44 -0
  145. package/dist/native/renderer-profile.d.ts +53 -0
  146. package/dist/native/renderer-profile.js +30 -0
  147. package/dist/native/secure-window.d.ts +38 -0
  148. package/dist/native/secure-window.js +77 -0
  149. package/dist/native/sidecar-services.d.ts +23 -0
  150. package/dist/native/sidecar-services.js +46 -0
  151. package/dist/native/sidecar.d.ts +81 -0
  152. package/dist/native/sidecar.js +250 -0
  153. package/dist/native/window-bootstrap.d.ts +24 -0
  154. package/dist/native/window-bootstrap.js +63 -0
  155. package/dist/native/window-options.d.ts +32 -0
  156. package/dist/native/window-options.js +23 -0
  157. package/dist/native/windows-build-hook-internal.d.ts +2 -0
  158. package/dist/native/windows-build-hook-internal.js +32 -0
  159. package/dist/native/windows-build-hook.d.ts +2 -0
  160. package/dist/native/windows-build-hook.js +12 -0
  161. package/dist/native/windows-runtime-patch-internal.d.ts +3 -0
  162. package/dist/native/windows-runtime-patch-internal.js +20 -0
  163. package/dist/native/windows-runtime-patch.d.ts +4 -0
  164. package/dist/native/windows-runtime-patch.js +12 -0
  165. package/dist/release/feed-release-cut.d.ts +23 -0
  166. package/dist/release/feed-release-cut.js +93 -0
  167. package/dist/release/feed-state.d.ts +25 -0
  168. package/dist/release/feed-state.js +81 -0
  169. package/dist/release/framework-package-publish.d.ts +21 -0
  170. package/dist/release/framework-package-publish.js +127 -0
  171. package/dist/release/framework-update.d.ts +30 -0
  172. package/dist/release/framework-update.js +139 -0
  173. package/dist/release/github-cli.d.ts +6 -0
  174. package/dist/release/github-cli.js +16 -0
  175. package/dist/release/github-release-assets.d.ts +3 -0
  176. package/dist/release/github-release-assets.js +24 -0
  177. package/dist/release/github-release-cut.d.ts +14 -0
  178. package/dist/release/github-release-cut.js +174 -0
  179. package/dist/release/github-release-lookup.d.ts +7 -0
  180. package/dist/release/github-release-lookup.js +29 -0
  181. package/dist/release/github-release-promotion.d.ts +10 -0
  182. package/dist/release/github-release-promotion.js +78 -0
  183. package/dist/release/github-release-provenance.d.ts +9 -0
  184. package/dist/release/github-release-provenance.js +27 -0
  185. package/dist/release/github-release-publisher.d.ts +9 -0
  186. package/dist/release/github-release-publisher.js +63 -0
  187. package/dist/release/github-release-qualification.d.ts +12 -0
  188. package/dist/release/github-release-qualification.js +80 -0
  189. package/dist/release/local-provenance.d.ts +24 -0
  190. package/dist/release/local-provenance.js +72 -0
  191. package/dist/release/local-release.d.ts +133 -0
  192. package/dist/release/local-release.js +387 -0
  193. package/dist/release/macos-dmg.d.ts +22 -0
  194. package/dist/release/macos-dmg.js +91 -0
  195. package/dist/release/release-artifact.d.ts +6 -0
  196. package/dist/release/release-artifact.js +38 -0
  197. package/dist/release/release-assets-plan.d.ts +14 -0
  198. package/dist/release/release-assets-plan.js +65 -0
  199. package/dist/release/release-config.d.ts +76 -0
  200. package/dist/release/release-config.js +180 -0
  201. package/dist/release/release-cut-command.d.ts +13 -0
  202. package/dist/release/release-cut-command.js +39 -0
  203. package/dist/release/release-cut.d.ts +54 -0
  204. package/dist/release/release-cut.js +76 -0
  205. package/dist/release/release-descriptor-staging.d.ts +34 -0
  206. package/dist/release/release-descriptor-staging.js +147 -0
  207. package/dist/release/release-finalize.d.ts +16 -0
  208. package/dist/release/release-finalize.js +104 -0
  209. package/dist/release/release-promotion-command.d.ts +12 -0
  210. package/dist/release/release-promotion-command.js +28 -0
  211. package/dist/release/release-promotion.d.ts +29 -0
  212. package/dist/release/release-promotion.js +57 -0
  213. package/dist/release/release-publication.d.ts +33 -0
  214. package/dist/release/release-publication.js +138 -0
  215. package/dist/release/release-publish-command.d.ts +7 -0
  216. package/dist/release/release-publish-command.js +91 -0
  217. package/dist/release/release-qualification.d.ts +106 -0
  218. package/dist/release/release-qualification.js +135 -0
  219. package/dist/release/release-staging.d.ts +9 -0
  220. package/dist/release/release-staging.js +61 -0
  221. package/dist/release/release-steps.d.ts +38 -0
  222. package/dist/release/release-steps.js +147 -0
  223. package/dist/release/retained-release-build.d.ts +19 -0
  224. package/dist/release/retained-release-build.js +122 -0
  225. package/dist/shell/app-shell.d.ts +61 -0
  226. package/dist/shell/app-shell.js +306 -0
  227. package/dist/shell/app-utilities.d.ts +122 -0
  228. package/dist/shell/app-utilities.js +334 -0
  229. package/dist/shell/application-menu-commands.d.ts +5 -0
  230. package/dist/shell/application-menu-commands.js +11 -0
  231. package/dist/shell/application-menu.d.ts +61 -0
  232. package/dist/shell/application-menu.js +208 -0
  233. package/dist/shell/help-shortcuts.d.ts +12 -0
  234. package/dist/shell/help-shortcuts.js +22 -0
  235. package/dist/shell/navigation-drawer.d.ts +12 -0
  236. package/dist/shell/navigation-drawer.js +42 -0
  237. package/dist/shell/settings-sections.d.ts +31 -0
  238. package/dist/shell/settings-sections.js +50 -0
  239. package/dist/shell/shortcut-platform.d.ts +17 -0
  240. package/dist/shell/shortcut-platform.js +25 -0
  241. package/dist/update-helper.bundle.js +260 -0
  242. package/dist/updates/channel-update-manager.d.ts +46 -0
  243. package/dist/updates/channel-update-manager.js +114 -0
  244. package/dist/updates/desktop-updater.d.ts +104 -0
  245. package/dist/updates/desktop-updater.js +345 -0
  246. package/dist/updates/release-feed.d.ts +61 -0
  247. package/dist/updates/release-feed.js +111 -0
  248. package/dist/updates/release-location.d.ts +9 -0
  249. package/dist/updates/release-location.js +80 -0
  250. package/dist/updates/release-version.d.ts +12 -0
  251. package/dist/updates/release-version.js +43 -0
  252. package/dist/updates/signed-release.d.ts +63 -0
  253. package/dist/updates/signed-release.js +162 -0
  254. package/dist/updates/stable-file.d.ts +10 -0
  255. package/dist/updates/stable-file.js +22 -0
  256. package/dist/updates/update-adapter.d.ts +57 -0
  257. package/dist/updates/update-adapter.js +72 -0
  258. package/dist/updates/update-arm.d.ts +24 -0
  259. package/dist/updates/update-arm.js +95 -0
  260. package/dist/updates/update-channel-store.d.ts +8 -0
  261. package/dist/updates/update-channel-store.js +72 -0
  262. package/dist/updates/update-discovery.d.ts +13 -0
  263. package/dist/updates/update-discovery.js +56 -0
  264. package/dist/updates/update-download.d.ts +14 -0
  265. package/dist/updates/update-download.js +67 -0
  266. package/dist/updates/update-exclusive-rename.d.ts +2 -0
  267. package/dist/updates/update-exclusive-rename.js +52 -0
  268. package/dist/updates/update-extraction.d.ts +18 -0
  269. package/dist/updates/update-extraction.js +183 -0
  270. package/dist/updates/update-handoff-plan.d.ts +22 -0
  271. package/dist/updates/update-handoff-plan.js +28 -0
  272. package/dist/updates/update-helper.d.ts +24 -0
  273. package/dist/updates/update-helper.js +56 -0
  274. package/dist/updates/update-launch.d.ts +5 -0
  275. package/dist/updates/update-launch.js +27 -0
  276. package/dist/updates/update-manager.d.ts +40 -0
  277. package/dist/updates/update-manager.js +83 -0
  278. package/dist/updates/update-process-fence.d.ts +10 -0
  279. package/dist/updates/update-process-fence.js +114 -0
  280. package/dist/updates/update-resume.d.ts +13 -0
  281. package/dist/updates/update-resume.js +34 -0
  282. package/dist/updates/update-shutdown.d.ts +15 -0
  283. package/dist/updates/update-shutdown.js +29 -0
  284. package/dist/updates/update-state.d.ts +30 -0
  285. package/dist/updates/update-state.js +18 -0
  286. package/dist/updates/update-swap-stage.d.ts +27 -0
  287. package/dist/updates/update-swap-stage.js +58 -0
  288. package/dist/updates/update-swap.d.ts +10 -0
  289. package/dist/updates/update-swap.js +30 -0
  290. package/dist/views/app-about.d.ts +22 -0
  291. package/dist/views/app-about.js +43 -0
  292. package/dist/views/app-appearance.d.ts +11 -0
  293. package/dist/views/app-appearance.js +42 -0
  294. package/dist/views/app-help.d.ts +17 -0
  295. package/dist/views/app-help.js +42 -0
  296. package/dist/views/app-settings.d.ts +26 -0
  297. package/dist/views/app-settings.js +97 -0
  298. package/dist/views/appearance-surface.d.ts +9 -0
  299. package/dist/views/appearance-surface.js +334 -0
  300. package/dist/views/update-surface.d.ts +34 -0
  301. package/dist/views/update-surface.js +64 -0
  302. package/package.json +374 -4
  303. package/src/app/application.tsx +138 -0
  304. package/src/appearance/appearance-host.tsx +205 -0
  305. package/src/appearance/appearance-preferences.ts +287 -0
  306. package/src/appearance/composition.ts +29 -0
  307. package/src/appearance/custom-theme-import.ts +424 -0
  308. package/src/appearance/custom-theme-library.ts +600 -0
  309. package/src/appearance/editor.ts +94 -0
  310. package/src/appearance/theme-file-importer.ts +103 -0
  311. package/src/appearance/theme-record-adapter.ts +106 -0
  312. package/src/appearance/theme-registry.ts +20 -0
  313. package/src/appearance/window-surface.ts +18 -0
  314. package/src/desktop/client-assets.ts +75 -0
  315. package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
  316. package/src/native/electrobun-windows-shortcut-com.patch +923 -0
  317. package/src/native/renderer-profile.ts +27 -0
  318. package/src/native/window-options.ts +24 -0
  319. package/src/shell/app-shell.tsx +294 -0
  320. package/src/shell/app-utilities.tsx +437 -0
  321. package/src/shell/help-shortcuts.ts +24 -0
  322. package/src/shell/navigation-drawer.tsx +36 -0
  323. package/src/shell/settings-sections.ts +74 -0
  324. package/src/shell/shortcut-platform.ts +35 -0
  325. package/src/updates/release-version.ts +57 -0
  326. package/src/updates/update-adapter.ts +129 -0
  327. package/src/updates/update-state.ts +34 -0
  328. package/src/views/app-about.tsx +44 -0
  329. package/src/views/app-appearance.tsx +32 -0
  330. package/src/views/app-help.tsx +43 -0
  331. package/src/views/app-settings.tsx +88 -0
  332. package/src/views/appearance-surface.tsx +427 -0
  333. package/src/views/update-surface.tsx +85 -0
  334. package/templates/application/.gitattributes +1 -0
  335. package/templates/application/.github/workflows/release-assets.yml +29 -0
  336. package/templates/application/.github/workflows/release-finalize.yml +29 -0
  337. package/templates/application/.github/workflows/release-please.yml +19 -0
  338. package/templates/application/.github/workflows/release.yml +29 -0
  339. package/templates/application/.github/workflows/validation.yml +28 -0
  340. package/templates/application/.oxfmtrc.json +6 -0
  341. package/templates/application/.oxlintrc.json +48 -0
  342. package/templates/application/.release-please-manifest.json +3 -0
  343. package/templates/application/README.md +47 -0
  344. package/templates/application/electrobun.config.ts +22 -0
  345. package/templates/application/release-please-config.json +12 -0
  346. package/templates/application/scripts/app-version.ts +9 -0
  347. package/templates/application/scripts/build-desktop.ts +34 -0
  348. package/templates/application/scripts/secure-build.ts +1 -0
  349. package/templates/application/scripts/stage-release.ts +21 -0
  350. package/templates/application/src/bun/index.ts +80 -0
  351. package/templates/application/src/electrobun.d.ts +27 -0
  352. package/templates/application/src/web/index.html +12 -0
  353. package/templates/application/src/web/main.tsx +97 -0
  354. package/templates/application/src/web/public/icon.svg +1 -0
  355. package/templates/application/src/web/style.css +3 -0
  356. package/templates/application/tests/app-config.test.ts +9 -0
  357. package/templates/application/tsconfig.json +15 -0
  358. package/templates/application/vite.config.ts +10 -0
@@ -0,0 +1,104 @@
1
+ import { type createServiceRegistry } from '../app/service-registry';
2
+ import type { InstallerPlatform, InstallerRenderer } from '../installer/installer-layout';
3
+ import { createChannelUpdateManager } from './channel-update-manager';
4
+ import { type UpdateChannel } from './release-version';
5
+ import type { ReleaseTrust } from './signed-release';
6
+ import type { UpdateState } from './update-adapter';
7
+ import type { NativeUpdateState } from './update-state';
8
+ export type DesktopUpdatePhase = UpdateState['phase'];
9
+ /** The snapshot every update service returns. */
10
+ export type DesktopUpdateStatus = NativeUpdateState<DesktopUpdatePhase>;
11
+ type Manager = Pick<ReturnType<typeof createChannelUpdateManager>, 'status' | 'readChannel' | 'saveChannel' | 'check' | 'install'>;
12
+ /** The release identity an app's release-config.json declares. */
13
+ export type DesktopRelease = {
14
+ appId: string;
15
+ appName: string;
16
+ releaseSigningKeys: Readonly<Record<string, string>>;
17
+ /** Where releases are published: `{ base: 'https://adea.dev/releases/', app: 'adea' }`. */
18
+ releaseFeed: Readonly<{
19
+ base: string;
20
+ app: string;
21
+ }>;
22
+ sidecars?: readonly string[];
23
+ };
24
+ /** The release platform this host runs on, or null where framework apps ship no build. */
25
+ export declare function updatePlatform(platform?: string, arch?: string): InstallerPlatform | null;
26
+ /**
27
+ * The installed app tree the swap replaces: the `.app` bundle on macOS, the
28
+ * app directory elsewhere. The host entry runs from `Resources/app/bun`.
29
+ */
30
+ export declare function installTarget(entryDirectory: string, platform: InstallerPlatform): string;
31
+ /** Each channel's signed descriptor for `platform`, as the release workflows publish them. */
32
+ export declare function discoveryNames(platform: InstallerPlatform): Record<UpdateChannel, string>;
33
+ /**
34
+ * What a descriptor must match: this app, repository and platform, signed by a
35
+ * configured key. Null until a key is configured, so such a build reports
36
+ * updates as unavailable instead of failing.
37
+ */
38
+ export declare function updateTrust(platform: InstallerPlatform, identity: {
39
+ appId: string;
40
+ repository: string;
41
+ feed: string;
42
+ keys: Readonly<Record<string, string>>;
43
+ }): Omit<ReleaseTrust, 'channel'> | null;
44
+ export type UpdateInstallRequest = {
45
+ expectedVersion: string;
46
+ approved: boolean;
47
+ restart?: boolean;
48
+ };
49
+ export type UpdaterOptions = {
50
+ appName: string;
51
+ repository: string;
52
+ currentVersion: string;
53
+ changelog?: string;
54
+ /** Null where updates cannot apply: an unsupported platform or no trusted key. */
55
+ manager: Manager | null;
56
+ /** A status read while idle starts the one check, so a badge needs no second checker. */
57
+ checkWhenIdle?: boolean;
58
+ /** Hand off to the post-exit helper and quit, after a staged install the user asked to restart. */
59
+ restart(version: string): Promise<void>;
60
+ /** Aborts the download in flight. */
61
+ abortDownload?(): void;
62
+ };
63
+ /** The update commands over a framework channel update manager. */
64
+ export declare function createUpdater(options: UpdaterOptions): {
65
+ status(): Promise<DesktopUpdateStatus>;
66
+ check: () => Promise<DesktopUpdateStatus>;
67
+ channel(): Promise<UpdateChannel>;
68
+ saveChannel(channel: UpdateChannel): Promise<UpdateChannel>;
69
+ install(request: UpdateInstallRequest): Promise<DesktopUpdateStatus>;
70
+ cancel(): Promise<DesktopUpdateStatus>;
71
+ };
72
+ export type DesktopUpdater = ReturnType<typeof createUpdater>;
73
+ /**
74
+ * The updater for the packaged app at `entryDirectory`. Clears downloads left
75
+ * by an earlier run and reports what an earlier helper did.
76
+ */
77
+ export declare function createDesktopUpdater(options: {
78
+ release: DesktopRelease;
79
+ repository: string;
80
+ renderer: InstallerRenderer;
81
+ entryDirectory: string;
82
+ dataDirectory: string;
83
+ /** Where the chosen channel is kept; the data directory unless given. */
84
+ stateDirectory?: string;
85
+ currentVersion: string;
86
+ changelog?: string;
87
+ /** The shipped update helper, relative to `Resources/app`. */
88
+ helperScript: string;
89
+ checkWhenIdle?: boolean;
90
+ quit(): void;
91
+ log(line: string): void;
92
+ }): Promise<DesktopUpdater>;
93
+ type Services<Principal> = ReturnType<typeof createServiceRegistry<Principal>>;
94
+ /** The `desktop_update_channel_save` argument. */
95
+ export declare function parseUpdateChannel(value: unknown): UpdateChannel;
96
+ /** The `desktop_update_install` argument. */
97
+ export declare function parseUpdateInstall(value: unknown): UpdateInstallRequest;
98
+ /** Register the `desktop_update_*` services the web client's update adapter calls. */
99
+ export declare function registerUpdateServices<Principal>(options: {
100
+ services: Services<Principal>;
101
+ updater: DesktopUpdater;
102
+ authorize(principal: Principal): boolean;
103
+ }): () => void;
104
+ export {};
@@ -0,0 +1,345 @@
1
+ import { ServiceError } from "../app/service-registry.js";
2
+ import { feedUrl, parseReleaseFeed } from "./release-feed.js";
3
+ import { isUpdateChannel } from "./release-version.js";
4
+ import { stageUpdateSwap } from "./update-swap-stage.js";
5
+ import { createUpdateChannelStore } from "./update-channel-store.js";
6
+ import { createChannelUpdateManager } from "./channel-update-manager.js";
7
+ import { armUpdateHelper } from "./update-arm.js";
8
+ import { resumeUpdate } from "./update-resume.js";
9
+ import { scheduleUpdateShutdown } from "./update-shutdown.js";
10
+ import { mkdir, realpath, rm } from "node:fs/promises";
11
+ import { join, resolve } from "node:path";
12
+ // src/updates/desktop-updater.ts
13
+ /**
14
+ * The desktop host's signed updater, the same for every framework app: the
15
+ * channel the user picked, discovery of that channel's signed descriptor for
16
+ * this platform, verified download, a staged swap beside the install and the
17
+ * post-exit helper that swaps it in and relaunches. `resumeUpdate` reports and
18
+ * cleans up after a helper on the next start.
19
+ *
20
+ * `registerUpdateServices` serves it as the `desktop_update_*` services that
21
+ * the web client's update adapter drives.
22
+ */
23
+ /** Largest signed archive accepted for download. */
24
+ var MAX_DOWNLOAD_BYTES = 1073741824;
25
+ /** Largest tree an archive may expand to. */
26
+ var MAX_EXPANDED_BYTES = 4294967296;
27
+ /** Lets the install reply reach the window before the app quits. */
28
+ var QUIT_DELAY_MS = 250;
29
+ /** The release platform this host runs on, or null where framework apps ship no build. */
30
+ function updatePlatform(platform = process.platform, arch = process.arch) {
31
+ if (platform === "darwin" && arch === "arm64") return "macos-arm64";
32
+ if (platform === "win32" && arch === "x64") return "windows-x64";
33
+ if (platform === "linux" && arch === "x64") return "linux-x64";
34
+ return null;
35
+ }
36
+ /**
37
+ * The installed app tree the swap replaces: the `.app` bundle on macOS, the
38
+ * app directory elsewhere. The host entry runs from `Resources/app/bun`.
39
+ */
40
+ function installTarget(entryDirectory, platform) {
41
+ return resolve(entryDirectory, ...platform === "macos-arm64" ? [
42
+ "..",
43
+ "..",
44
+ "..",
45
+ ".."
46
+ ] : [
47
+ "..",
48
+ "..",
49
+ ".."
50
+ ]);
51
+ }
52
+ /** Each channel's signed descriptor for `platform`, as the release workflows publish them. */
53
+ function discoveryNames(platform) {
54
+ return {
55
+ stable: `stable-${platform}.json`,
56
+ "pre-release": `daily-${platform}.json`,
57
+ dev: `dev-${platform}.json`
58
+ };
59
+ }
60
+ /**
61
+ * What a descriptor must match: this app, repository and platform, signed by a
62
+ * configured key. Null until a key is configured, so such a build reports
63
+ * updates as unavailable instead of failing.
64
+ */
65
+ function updateTrust(platform, identity) {
66
+ const entries = Object.entries(identity.keys);
67
+ if (entries.length === 0) return null;
68
+ const [os, arch] = {
69
+ "macos-arm64": ["darwin", "arm64"],
70
+ "windows-x64": ["win32", "x64"],
71
+ "linux-x64": ["linux", "x64"]
72
+ }[platform];
73
+ return {
74
+ appId: identity.appId,
75
+ repository: identity.repository,
76
+ platform: os,
77
+ arch,
78
+ feed: identity.feed,
79
+ keys: new Map(entries)
80
+ };
81
+ }
82
+ var PHASES = {
83
+ idle: "idle",
84
+ checking: "checking",
85
+ current: "current",
86
+ available: "available",
87
+ downloading: "downloading",
88
+ staging: "installing",
89
+ staged: "installed",
90
+ failed: "failed"
91
+ };
92
+ /** The update commands over a framework channel update manager. */
93
+ function createUpdater(options) {
94
+ const { manager, currentVersion } = options;
95
+ const releases = `https://github.com/${options.repository}/releases`;
96
+ let cancelRequested = false;
97
+ let lastTag = null;
98
+ let inFlight = null;
99
+ const snapshot = () => {
100
+ const state = manager?.status();
101
+ const available = state?.availableVersion ?? null;
102
+ if (available) lastTag = `v${available}`;
103
+ const phase = !state ? "unavailable" : cancelRequested && state.phase === "downloading" ? "cancelling" : cancelRequested && state.phase === "failed" ? "cancelled" : PHASES[state.phase];
104
+ return {
105
+ current_version: currentVersion,
106
+ available_version: available,
107
+ release_date: null,
108
+ release_notes: null,
109
+ changelog: options.changelog ?? "",
110
+ github_url: lastTag ? `${releases}/tag/${lastTag}` : releases,
111
+ phase,
112
+ downloaded_bytes: 0,
113
+ total_bytes: null,
114
+ error: phase === "cancelled" ? null : state?.error ?? null,
115
+ restart_required: state?.phase === "staged"
116
+ };
117
+ };
118
+ const active = () => {
119
+ if (!manager) throw new ServiceError("unsupported", `Signed updates are not available for this ${options.appName} build`);
120
+ return manager;
121
+ };
122
+ const check = async () => {
123
+ if (!manager) return snapshot();
124
+ cancelRequested = false;
125
+ inFlight ??= manager.check().then(snapshot).finally(() => {
126
+ inFlight = null;
127
+ });
128
+ return inFlight;
129
+ };
130
+ return {
131
+ async status() {
132
+ if (options.checkWhenIdle && manager?.status().phase === "idle") return check();
133
+ return inFlight ?? snapshot();
134
+ },
135
+ check,
136
+ async channel() {
137
+ return manager ? manager.readChannel() : "stable";
138
+ },
139
+ async saveChannel(channel) {
140
+ return active().saveChannel(channel);
141
+ },
142
+ async install(request) {
143
+ const updates = active();
144
+ if (!request.approved) throw new ServiceError("command_failed", "update installation requires explicit approval");
145
+ cancelRequested = false;
146
+ const state = await updates.install({
147
+ approved: true,
148
+ expectedVersion: request.expectedVersion
149
+ });
150
+ if (state.phase === "staged" && request.restart !== false && state.availableVersion) await options.restart(state.availableVersion);
151
+ return snapshot();
152
+ },
153
+ async cancel() {
154
+ if (manager?.status().phase === "downloading" && options.abortDownload) {
155
+ cancelRequested = true;
156
+ options.abortDownload();
157
+ }
158
+ return snapshot();
159
+ }
160
+ };
161
+ }
162
+ /**
163
+ * The updater for the packaged app at `entryDirectory`. Clears downloads left
164
+ * by an earlier run and reports what an earlier helper did.
165
+ */
166
+ async function createDesktopUpdater(options) {
167
+ const { release } = options;
168
+ const platform = updatePlatform();
169
+ const trust = platform && updateTrust(platform, {
170
+ appId: release.appId,
171
+ repository: options.repository,
172
+ feed: feedUrl(parseReleaseFeed(release.releaseFeed)),
173
+ keys: release.releaseSigningKeys
174
+ });
175
+ let controller = new AbortController();
176
+ const updater = {
177
+ appName: release.appName,
178
+ repository: options.repository,
179
+ currentVersion: options.currentVersion,
180
+ changelog: options.changelog,
181
+ checkWhenIdle: options.checkWhenIdle,
182
+ abortDownload() {
183
+ controller.abort();
184
+ controller = new AbortController();
185
+ }
186
+ };
187
+ if (!platform || !trust) return createUpdater({
188
+ ...updater,
189
+ manager: null,
190
+ restart: async () => {}
191
+ });
192
+ const target = installTarget(options.entryDirectory, platform);
193
+ const resumed = await resumeUpdate({ target }).catch((error) => {
194
+ options.log(`update resume failed: ${String(error)}`);
195
+ return null;
196
+ });
197
+ if (resumed?.status === "updated") options.log(`updated to ${release.appName} ${resumed.version}`);
198
+ const state = options.stateDirectory ?? options.dataDirectory;
199
+ await mkdir(state, {
200
+ recursive: true,
201
+ mode: 448
202
+ });
203
+ const downloads = join(options.dataDirectory, "updates");
204
+ await rm(downloads, {
205
+ recursive: true,
206
+ force: true
207
+ });
208
+ await mkdir(downloads, {
209
+ recursive: true,
210
+ mode: 448
211
+ });
212
+ const manager = createChannelUpdateManager({
213
+ store: createUpdateChannelStore(await realpath(state)),
214
+ trust,
215
+ discoveryNames: discoveryNames(platform),
216
+ currentVersion: options.currentVersion,
217
+ directory: await realpath(downloads),
218
+ maxBytes: MAX_DOWNLOAD_BYTES,
219
+ fetch: (input, init) => fetch(input, {
220
+ ...init,
221
+ signal: init?.signal ? AbortSignal.any([init.signal, controller.signal]) : controller.signal
222
+ }),
223
+ async stage({ descriptor, path, directory }) {
224
+ try {
225
+ await stageUpdateSwap({
226
+ descriptor,
227
+ trust: {
228
+ ...trust,
229
+ channel: descriptor.channel
230
+ },
231
+ currentVersion: options.currentVersion,
232
+ approved: true,
233
+ approvedVersion: descriptor.version,
234
+ target,
235
+ appName: release.appName,
236
+ platform,
237
+ renderer: options.renderer,
238
+ archive: path,
239
+ maxCompressedBytes: MAX_DOWNLOAD_BYTES,
240
+ maxExpandedBytes: MAX_EXPANDED_BYTES,
241
+ ...release.sidecars ? { sidecars: release.sidecars } : {}
242
+ });
243
+ } finally {
244
+ await rm(directory, {
245
+ recursive: true,
246
+ force: true
247
+ });
248
+ }
249
+ }
250
+ });
251
+ return createUpdater({
252
+ ...updater,
253
+ manager,
254
+ async restart(version) {
255
+ await scheduleUpdateShutdown({
256
+ reserve: () => ({}),
257
+ cancelReservation: () => {},
258
+ arm: () => armUpdateHelper({
259
+ target,
260
+ platform,
261
+ version,
262
+ helperScript: join(options.entryDirectory, "..", options.helperScript)
263
+ }),
264
+ quit: () => {
265
+ setTimeout(options.quit, QUIT_DELAY_MS);
266
+ return true;
267
+ }
268
+ });
269
+ }
270
+ });
271
+ }
272
+ function record(value, keys) {
273
+ if (typeof value !== "object" || value === null || Array.isArray(value) || Object.keys(value).some((key) => !keys.includes(key))) throw new Error("Invalid input");
274
+ return value;
275
+ }
276
+ function parseNone(value) {
277
+ if (value !== void 0 && value !== null) record(value, []);
278
+ return null;
279
+ }
280
+ /** The `desktop_update_channel_save` argument. */
281
+ function parseUpdateChannel(value) {
282
+ const { channel } = record(value, ["channel"]);
283
+ if (!isUpdateChannel(channel)) throw new Error("Invalid input");
284
+ return channel;
285
+ }
286
+ /** The `desktop_update_install` argument. */
287
+ function parseUpdateInstall(value) {
288
+ const { expectedVersion, approved, restart } = record(value, [
289
+ "expectedVersion",
290
+ "approved",
291
+ "restart"
292
+ ]);
293
+ if (typeof expectedVersion !== "string" || expectedVersion.length > 64 || typeof approved !== "boolean" || restart !== void 0 && typeof restart !== "boolean") throw new Error("Invalid input");
294
+ return {
295
+ expectedVersion,
296
+ approved,
297
+ ...restart === void 0 ? {} : { restart }
298
+ };
299
+ }
300
+ /** Pass a service error through; give any other failure the update error code. */
301
+ function failure(error) {
302
+ if (error instanceof ServiceError) throw error;
303
+ throw new ServiceError("update_failed", error instanceof Error ? error.message : String(error));
304
+ }
305
+ /** Register the `desktop_update_*` services the web client's update adapter calls. */
306
+ function registerUpdateServices(options) {
307
+ const { services, updater } = options;
308
+ const authorize = (principal) => options.authorize(principal);
309
+ const unregister = [
310
+ services.register("desktop_update_status", {
311
+ parse: parseNone,
312
+ authorize,
313
+ run: () => updater.status().catch(failure)
314
+ }),
315
+ services.register("desktop_update_channel", {
316
+ parse: parseNone,
317
+ authorize,
318
+ run: () => updater.channel().catch(failure)
319
+ }),
320
+ services.register("desktop_update_channel_save", {
321
+ parse: parseUpdateChannel,
322
+ authorize,
323
+ run: (_principal, channel) => updater.saveChannel(channel).catch(failure)
324
+ }),
325
+ services.register("desktop_update_check", {
326
+ parse: parseNone,
327
+ authorize,
328
+ run: () => updater.check().catch(failure)
329
+ }),
330
+ services.register("desktop_update_install", {
331
+ parse: parseUpdateInstall,
332
+ authorize,
333
+ run: (_principal, request) => updater.install(request).catch(failure)
334
+ }),
335
+ services.register("desktop_update_cancel", {
336
+ parse: parseNone,
337
+ authorize,
338
+ run: () => updater.cancel()
339
+ })
340
+ ];
341
+ return () => {
342
+ for (const remove of unregister) remove();
343
+ };
344
+ }
345
+ export { createDesktopUpdater, createUpdater, discoveryNames, installTarget, parseUpdateChannel, parseUpdateInstall, registerUpdateServices, updatePlatform, updateTrust };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The HTTPS release feed an app publishes to and updates from (Cloudflare R2 behind
3
+ * adea.dev). Object keys are relative to the feed base, one prefix per app:
4
+ * `<app>/<tag>/<asset>` immutable assets and signed descriptors, `<app>/<tag>/release.json`
5
+ * the release's asset inventory, `<app>/index.json` the bounded release ledger and
6
+ * `<app>/channels/<channel>.json` a copy of the newest release.json on that channel.
7
+ */
8
+ export type ReleaseFeed = Readonly<{
9
+ base: string;
10
+ app: string;
11
+ }>;
12
+ export type FeedChannel = 'dev' | 'daily' | 'stable';
13
+ type FeedAsset = Readonly<{
14
+ name: string;
15
+ size: number;
16
+ sha256: string;
17
+ }>;
18
+ /** `<app>/<tag>/release.json` and the channel pointers that copy it; unsigned. */
19
+ export type FeedRelease = Readonly<{
20
+ tag: string;
21
+ channel: FeedChannel;
22
+ publishedAt: string;
23
+ assets: readonly FeedAsset[];
24
+ }>;
25
+ export type LedgerEntry = Readonly<{
26
+ tag: string;
27
+ kind: FeedChannel;
28
+ version: string;
29
+ sourceSha: string;
30
+ publishedAt: string;
31
+ /** When a daily became stable; present exactly on stable entries. */
32
+ promotedAt?: string;
33
+ }>;
34
+ /** `<app>/index.json`: newest first. */
35
+ export type ReleaseLedger = Readonly<{
36
+ schema: 1;
37
+ app: string;
38
+ releases: readonly LedgerEntry[];
39
+ }>;
40
+ /** Ledger entries kept; the oldest fall off a full ledger. */
41
+ export declare const MAX_LEDGER_RELEASES = 500;
42
+ /** A release tag in the feed: `vX.Y.Z` or `vX.Y.Z-dev.N`. */
43
+ export declare const isFeedTag: (value: unknown) => value is string;
44
+ export declare const isFeedAssetName: (value: unknown) => value is string;
45
+ /** Validate a feed: an https origin and path prefix ending in `/`, with no credentials,
46
+ * port, query or fragment, and an app slug. */
47
+ export declare function parseReleaseFeed(value: unknown): ReleaseFeed;
48
+ /** The URL every key of this app's feed lives under, ending in `/`. */
49
+ export declare const feedUrl: (feed: ReleaseFeed) => string;
50
+ /** The bucket key of one release asset. */
51
+ export declare function feedAssetKey(feed: ReleaseFeed, tag: string, name: string): string;
52
+ export declare const feedReleaseKey: (feed: ReleaseFeed, tag: string) => string;
53
+ export declare const feedIndexKey: (feed: ReleaseFeed) => string;
54
+ export declare const feedChannelKey: (feed: ReleaseFeed, channel: FeedChannel) => string;
55
+ /** Validate a release.json or channel pointer: a tag of its channel and a bounded,
56
+ * unique asset inventory. */
57
+ export declare function parseFeedRelease(value: unknown): FeedRelease;
58
+ /** Validate the ledger: this app, at most MAX_LEDGER_RELEASES unique tags, newest first,
59
+ * each kind matching its tag and only stable entries carrying a promotion time. */
60
+ export declare function parseReleaseLedger(value: unknown, app: string): ReleaseLedger;
61
+ export {};
@@ -0,0 +1,111 @@
1
+ // src/updates/release-feed.ts
2
+ /** Ledger entries kept; the oldest fall off a full ledger. */
3
+ var MAX_LEDGER_RELEASES = 500;
4
+ var MAX_RELEASE_ASSETS = 256;
5
+ var record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
6
+ var exactKeys = (value, keys) => Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
7
+ var segment = /^[a-z0-9][a-z0-9-]{0,62}$/;
8
+ var tagPattern = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-dev\.[1-9]\d*)?$/;
9
+ var timestamp = (value) => typeof value === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/.test(value) && Number.isFinite(Date.parse(value)) && new Date(value).toISOString().replace(".000Z", "Z") === value.replace(".000Z", "Z");
10
+ /** A release tag in the feed: `vX.Y.Z` or `vX.Y.Z-dev.N`. */
11
+ var isFeedTag = (value) => typeof value === "string" && value.length <= 65 && tagPattern.test(value);
12
+ var isFeedAssetName = (value) => typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/.test(value);
13
+ /** Validate a feed: an https origin and path prefix ending in `/`, with no credentials,
14
+ * port, query or fragment, and an app slug. */
15
+ function parseReleaseFeed(value) {
16
+ if (!record(value) || !exactKeys(value, ["base", "app"]) || typeof value.base !== "string") throw new Error("Invalid release feed");
17
+ let url;
18
+ try {
19
+ url = new URL(value.base);
20
+ } catch {
21
+ throw new Error("Invalid release feed");
22
+ }
23
+ const parts = url.pathname.split("/").slice(1, -1);
24
+ if (value.base.length > 200 || url.href !== value.base || url.protocol !== "https:" || url.username || url.password || url.port || url.search || url.hash || !url.pathname.endsWith("/") || !parts.every((part) => segment.test(part)) || typeof value.app !== "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(value.app)) throw new Error("Invalid release feed");
25
+ return {
26
+ base: value.base,
27
+ app: value.app
28
+ };
29
+ }
30
+ /** The URL every key of this app's feed lives under, ending in `/`. */
31
+ var feedUrl = (feed) => `${feed.base}${feed.app}/`;
32
+ /** The bucket key of one release asset. */
33
+ function feedAssetKey(feed, tag, name) {
34
+ if (!isFeedTag(tag) || !isFeedAssetName(name)) throw new Error("Invalid release asset");
35
+ return `${feed.app}/${tag}/${name}`;
36
+ }
37
+ var feedReleaseKey = (feed, tag) => feedAssetKey(feed, tag, "release.json");
38
+ var feedIndexKey = (feed) => `${feed.app}/index.json`;
39
+ var feedChannelKey = (feed, channel) => `${feed.app}/channels/${channel}.json`;
40
+ var channelOf = (tag) => tag.includes("-dev.") ? "dev" : "daily";
41
+ /** Validate a release.json or channel pointer: a tag of its channel and a bounded,
42
+ * unique asset inventory. */
43
+ function parseFeedRelease(value) {
44
+ if (!record(value) || !exactKeys(value, [
45
+ "tag",
46
+ "channel",
47
+ "publishedAt",
48
+ "assets"
49
+ ]) || !isFeedTag(value.tag) || ![
50
+ "dev",
51
+ "daily",
52
+ "stable"
53
+ ].includes(String(value.channel)) || value.channel === "dev" !== (channelOf(value.tag) === "dev") || !timestamp(value.publishedAt) || !Array.isArray(value.assets) || value.assets.length < 1 || value.assets.length > MAX_RELEASE_ASSETS) throw new Error("Invalid feed release");
54
+ const names = /* @__PURE__ */ new Set();
55
+ const assets = value.assets.map((asset) => {
56
+ if (!record(asset) || !exactKeys(asset, [
57
+ "name",
58
+ "size",
59
+ "sha256"
60
+ ]) || !isFeedAssetName(asset.name) || asset.name === "release.json" || names.has(asset.name) || !Number.isSafeInteger(asset.size) || Number(asset.size) < 1 || typeof asset.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(asset.sha256)) throw new Error("Invalid feed release asset");
61
+ names.add(asset.name);
62
+ return {
63
+ name: asset.name,
64
+ size: Number(asset.size),
65
+ sha256: asset.sha256
66
+ };
67
+ });
68
+ return {
69
+ tag: value.tag,
70
+ channel: value.channel,
71
+ publishedAt: value.publishedAt,
72
+ assets
73
+ };
74
+ }
75
+ /** Validate the ledger: this app, at most MAX_LEDGER_RELEASES unique tags, newest first,
76
+ * each kind matching its tag and only stable entries carrying a promotion time. */
77
+ function parseReleaseLedger(value, app) {
78
+ if (!record(value) || !exactKeys(value, [
79
+ "schema",
80
+ "app",
81
+ "releases"
82
+ ]) || value.schema !== 1 || value.app !== app || !Array.isArray(value.releases) || value.releases.length > 500) throw new Error("Invalid release ledger");
83
+ const tags = /* @__PURE__ */ new Set();
84
+ let previous = Infinity;
85
+ return {
86
+ schema: 1,
87
+ app,
88
+ releases: value.releases.map((entry) => {
89
+ const stable = record(entry) && entry.kind === "stable";
90
+ if (!record(entry) || !exactKeys(entry, [
91
+ "tag",
92
+ "kind",
93
+ "version",
94
+ "sourceSha",
95
+ "publishedAt",
96
+ ...stable ? ["promotedAt"] : []
97
+ ]) || !isFeedTag(entry.tag) || tags.has(entry.tag) || entry.version !== entry.tag.slice(1) || !(stable ? channelOf(entry.tag) === "daily" : entry.kind === channelOf(entry.tag)) || typeof entry.sourceSha !== "string" || !/^[a-f0-9]{40}$/.test(entry.sourceSha) || !timestamp(entry.publishedAt) || Date.parse(entry.publishedAt) > previous || stable && (!timestamp(entry.promotedAt) || Date.parse(entry.promotedAt) < Date.parse(entry.publishedAt))) throw new Error("Invalid release ledger entry");
98
+ tags.add(entry.tag);
99
+ previous = Date.parse(entry.publishedAt);
100
+ return {
101
+ tag: entry.tag,
102
+ kind: entry.kind,
103
+ version: entry.version,
104
+ sourceSha: entry.sourceSha,
105
+ publishedAt: entry.publishedAt,
106
+ ...stable ? { promotedAt: entry.promotedAt } : {}
107
+ };
108
+ })
109
+ };
110
+ }
111
+ export { MAX_LEDGER_RELEASES, feedAssetKey, feedChannelKey, feedIndexKey, feedReleaseKey, feedUrl, isFeedAssetName, isFeedTag, parseFeedRelease, parseReleaseFeed, parseReleaseLedger };
@@ -0,0 +1,9 @@
1
+ /** A fetch implementation. Bun's `typeof fetch` also requires `preconnect`, which callers never use. */
2
+ export type FetchFunction = (...args: Parameters<typeof fetch>) => Promise<Response>;
3
+ /** GET a release feed object without credentials, following at most five redirects that
4
+ * stay under `scope`, the app's feed URL. The caller reads or cancels the response body. */
5
+ export declare function fetchReleaseLocation(location: string, scope: string, fetcher: FetchFunction, signal: AbortSignal): Promise<Response>;
6
+ /** Read a 200 response body of at most `maximum` bytes. */
7
+ export declare function readReleaseBytes(response: Response, maximum: number): Promise<Uint8Array>;
8
+ /** Parse a 200 response of at most `maximum` bytes as UTF-8 JSON. */
9
+ export declare function readReleaseJson(response: Response, maximum: number): Promise<unknown>;