@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,250 @@
1
+ // src/native/sidecar.ts
2
+ var MAX_REQUEST_ID = Number.MAX_SAFE_INTEGER;
3
+ var NEWLINE = 10;
4
+ var fail = (reason, error) => ({
5
+ ok: false,
6
+ reason,
7
+ error
8
+ });
9
+ var positive = (value, max = Number.MAX_SAFE_INTEGER) => Number.isSafeInteger(value) && value > 0 && value <= max;
10
+ function createSidecar(options) {
11
+ const name = options.name ?? "sidecar";
12
+ const requestTimeoutMs = options.requestTimeoutMs ?? 3e4;
13
+ const maxRequestBytes = options.maxRequestBytes ?? 1048576;
14
+ const maxReplyBytes = options.maxReplyBytes ?? 8389632;
15
+ const maxStderrBytes = options.maxStderrBytes ?? 65536;
16
+ const { maxRestarts, windowMs } = options.restart ?? {};
17
+ if (typeof options.executable !== "string" || !options.executable || options.args !== void 0 && (!Array.isArray(options.args) || options.args.some((arg) => typeof arg !== "string")) || typeof name !== "string" || !name || name.length > 100 || !positive(requestTimeoutMs, 2147483647) || !positive(maxRequestBytes) || !positive(maxReplyBytes) || !positive(maxStderrBytes) || !Number.isSafeInteger(maxRestarts) || maxRestarts < 0 || !positive(windowMs)) throw new Error("Invalid sidecar options");
18
+ const log = options.log ?? (() => {});
19
+ const encoder = new TextEncoder();
20
+ let running;
21
+ let stopped = false;
22
+ let nextId = 1;
23
+ let starts = [];
24
+ let stderrTail = "";
25
+ const note = (line) => {
26
+ try {
27
+ log(line);
28
+ } catch {}
29
+ };
30
+ function failAll(state, reason, error) {
31
+ for (const [id, pending] of state.pending) {
32
+ state.pending.delete(id);
33
+ pending.cleanup();
34
+ pending.resolve(fail(reason, error));
35
+ }
36
+ }
37
+ let hooked = false;
38
+ const onHostExit = () => kill();
39
+ const hook = (on) => {
40
+ if (on === hooked) return;
41
+ hooked = on;
42
+ if (on) process.on("exit", onHostExit);
43
+ else process.off("exit", onHostExit);
44
+ };
45
+ function spawn() {
46
+ const now = performance.now();
47
+ starts = starts.filter((at) => now - at < windowMs);
48
+ if (starts.length > maxRestarts) return fail("restart_limit", `The ${name} stopped repeatedly; try again shortly`);
49
+ starts.push(now);
50
+ let child;
51
+ try {
52
+ child = Bun.spawn({
53
+ cmd: [options.executable, ...options.args ?? []],
54
+ env: options.env ?? Bun.env,
55
+ stdin: "pipe",
56
+ stdout: "pipe",
57
+ stderr: "pipe"
58
+ });
59
+ } catch (error) {
60
+ note(`${name} failed to start: ${String(error)}`);
61
+ return fail("unavailable", `The ${name} could not be started`);
62
+ }
63
+ const state = {
64
+ process: child,
65
+ pending: /* @__PURE__ */ new Map()
66
+ };
67
+ hook(true);
68
+ readReplies(state);
69
+ readStderr(child.stderr);
70
+ child.exited.then((code) => {
71
+ if (running === state) {
72
+ running = void 0;
73
+ hook(false);
74
+ }
75
+ if (!stopped) note(`${name} exited with code ${code}`);
76
+ failAll(state, "exited", `The ${name} stopped before replying`);
77
+ return null;
78
+ });
79
+ return state;
80
+ }
81
+ async function readReplies(state) {
82
+ const decoder = new TextDecoder();
83
+ let parts = [];
84
+ let partial = 0;
85
+ const tooLarge = () => {
86
+ note(`${name} reply exceeded ${maxReplyBytes} bytes; restarting it`);
87
+ failAll(state, "reply_too_large", `The ${name} sent an oversized reply`);
88
+ state.process.kill();
89
+ };
90
+ try {
91
+ for await (const chunk of state.process.stdout) {
92
+ let start = 0;
93
+ let newline;
94
+ while ((newline = chunk.indexOf(NEWLINE, start)) !== -1) {
95
+ const piece = chunk.subarray(start, newline);
96
+ start = newline + 1;
97
+ if (partial + piece.byteLength > maxReplyBytes) return tooLarge();
98
+ let line = piece;
99
+ if (parts.length) {
100
+ line = new Uint8Array(partial + piece.byteLength);
101
+ let offset = 0;
102
+ for (const part of parts) {
103
+ line.set(part, offset);
104
+ offset += part.byteLength;
105
+ }
106
+ line.set(piece, offset);
107
+ parts = [];
108
+ partial = 0;
109
+ }
110
+ deliver(state, decoder.decode(line));
111
+ }
112
+ if (start < chunk.byteLength) {
113
+ const rest = chunk.subarray(start);
114
+ partial += rest.byteLength;
115
+ if (partial > maxReplyBytes) return tooLarge();
116
+ parts.push(rest.slice());
117
+ }
118
+ }
119
+ } catch (error) {
120
+ note(`${name} stdout failed: ${String(error)}`);
121
+ }
122
+ }
123
+ function deliver(state, line) {
124
+ if (!line.trim()) return;
125
+ let reply;
126
+ try {
127
+ reply = JSON.parse(line);
128
+ } catch {
129
+ note(`${name} wrote a line that is not JSON`);
130
+ return;
131
+ }
132
+ if (typeof reply !== "object" || reply === null || Array.isArray(reply)) return;
133
+ const record = reply;
134
+ if (typeof record.id !== "number") {
135
+ note(`${name} rejected a request: ${String(record.error).slice(0, 4096)}`);
136
+ return;
137
+ }
138
+ const pending = state.pending.get(record.id);
139
+ if (!pending) return;
140
+ state.pending.delete(record.id);
141
+ pending.cleanup();
142
+ if (record.ok === true) pending.resolve({
143
+ ok: true,
144
+ value: record.value ?? null
145
+ });
146
+ else pending.resolve(fail("command_failed", typeof record.error === "string" && record.error ? record.error : `The ${name} command failed`));
147
+ }
148
+ async function readStderr(stream) {
149
+ const decoder = new TextDecoder();
150
+ let buffer = "";
151
+ try {
152
+ for await (const chunk of stream) {
153
+ const text = decoder.decode(chunk, { stream: true });
154
+ stderrTail += text;
155
+ if (stderrTail.length > maxStderrBytes) stderrTail = stderrTail.slice(-maxStderrBytes);
156
+ buffer += text;
157
+ const lines = buffer.split("\n");
158
+ buffer = lines.pop() ?? "";
159
+ if (buffer.length > maxStderrBytes) buffer = "";
160
+ for (const line of lines) if (line.trim()) note(`${name}: ${line.slice(0, 4096)}`);
161
+ }
162
+ } catch {}
163
+ }
164
+ function ensure() {
165
+ if (stopped) return fail("stopped", `The ${name} is shut down`);
166
+ if (running) return running;
167
+ const state = spawn();
168
+ if ("process" in state) running = state;
169
+ return state;
170
+ }
171
+ function kill() {
172
+ const state = running;
173
+ running = void 0;
174
+ hook(false);
175
+ if (!state) return;
176
+ failAll(state, "stopped", `The ${name} is shut down`);
177
+ try {
178
+ state.process.stdin.end();
179
+ } catch {}
180
+ state.process.kill();
181
+ }
182
+ function call(command, args, callOptions) {
183
+ const signal = callOptions?.signal;
184
+ const timeoutMs = callOptions?.timeoutMs ?? requestTimeoutMs;
185
+ if (typeof command !== "string" || !command || command.length > 128) return Promise.resolve(fail("invalid_request", `Invalid ${name} command`));
186
+ if (!positive(timeoutMs, 2147483647)) return Promise.resolve(fail("invalid_request", `Invalid ${name} timeout`));
187
+ if (signal?.aborted) return Promise.resolve(fail("aborted", `The ${name} call was cancelled`));
188
+ if (nextId > MAX_REQUEST_ID) nextId = 1;
189
+ const id = nextId++;
190
+ let line;
191
+ try {
192
+ line = JSON.stringify({
193
+ id,
194
+ command,
195
+ args: args ?? {}
196
+ });
197
+ } catch {
198
+ return Promise.resolve(fail("invalid_request", `The ${name} request is not JSON`));
199
+ }
200
+ if (encoder.encode(line).byteLength > maxRequestBytes) return Promise.resolve(fail("request_too_large", `The ${name} request is too large`));
201
+ const state = ensure();
202
+ if (!("process" in state)) return Promise.resolve(state);
203
+ return new Promise((resolve) => {
204
+ const settle = (reply) => {
205
+ if (state.pending.delete(id)) {
206
+ cleanup();
207
+ resolve(reply);
208
+ }
209
+ };
210
+ const onAbort = () => settle(fail("aborted", `The ${name} call was cancelled`));
211
+ const timer = setTimeout(() => settle(fail("timeout", `The ${name} did not reply in time`)), timeoutMs);
212
+ const cleanup = () => {
213
+ clearTimeout(timer);
214
+ signal?.removeEventListener("abort", onAbort);
215
+ };
216
+ signal?.addEventListener("abort", onAbort, { once: true });
217
+ state.pending.set(id, {
218
+ resolve,
219
+ cleanup
220
+ });
221
+ try {
222
+ state.process.stdin.write(line + "\n");
223
+ Promise.resolve(state.process.stdin.flush()).catch(() => {});
224
+ } catch {
225
+ settle(fail("exited", `The ${name} is not accepting requests`));
226
+ }
227
+ });
228
+ }
229
+ return {
230
+ call,
231
+ start() {
232
+ const state = ensure();
233
+ if ("process" in state) return true;
234
+ note(state.error);
235
+ return false;
236
+ },
237
+ stop() {
238
+ stopped = true;
239
+ kill();
240
+ },
241
+ get state() {
242
+ return stopped ? "stopped" : running ? "running" : "idle";
243
+ },
244
+ get pid() {
245
+ return running?.process.pid;
246
+ },
247
+ stderr: () => stderrTail
248
+ };
249
+ }
250
+ export { createSidecar };
@@ -0,0 +1,24 @@
1
+ import { type SignedRequest } from '../desktop/channel-proof';
2
+ import type { createChannelAuthority } from '../desktop/channel-handshake';
3
+ /**
4
+ * Window-specific proof key and preload. This requires a native renderer that
5
+ * protects the preload secret from untrusted frames and enforces a navigation
6
+ * allowlist before injecting it. Native injection behavior must be verified for
7
+ * each renderer and platform before this can be used in a packaged app.
8
+ */
9
+ export declare function createNativeWindowGrant<Principal>(options: {
10
+ origin: string;
11
+ authority: ReturnType<typeof createChannelAuthority<Principal>>;
12
+ principal: Principal;
13
+ now?: () => number;
14
+ lifetimeMs?: number;
15
+ }): {
16
+ origin: string;
17
+ preload: string;
18
+ /** Called only after the gateway has checked origin and bounded the body. */
19
+ acquire(request: SignedRequest): {
20
+ bootstrap: string;
21
+ expiresAt: number;
22
+ } | undefined;
23
+ revoke(): void;
24
+ };
@@ -0,0 +1,63 @@
1
+ import { createChannelProofVerifier } from "../desktop/channel-proof.js";
2
+ import { createLoopbackPolicy } from "../desktop/loopback-policy.js";
3
+ import { createHash, randomBytes, randomUUID } from "node:crypto";
4
+ // src/native/window-bootstrap.ts
5
+ /**
6
+ * Window-specific proof key and preload. This requires a native renderer that
7
+ * protects the preload secret from untrusted frames and enforces a navigation
8
+ * allowlist before injecting it. Native injection behavior must be verified for
9
+ * each renderer and platform before this can be used in a packaged app.
10
+ */
11
+ function createNativeWindowGrant(options) {
12
+ const origin = createLoopbackPolicy(options.origin).origin;
13
+ const clock = options.now ?? Date.now;
14
+ const lifetime = options.lifetimeMs ?? 432e5;
15
+ const started = clock();
16
+ if (!Number.isSafeInteger(lifetime) || lifetime < 1 || !Number.isSafeInteger(started) || started < 0 || started > Number.MAX_SAFE_INTEGER - lifetime) throw new Error("Invalid window grant lifetime");
17
+ const expiresAt = started + lifetime;
18
+ const secret = randomBytes(32);
19
+ const channelId = randomUUID();
20
+ const credentialId = randomUUID();
21
+ let live = true;
22
+ const verifier = createChannelProofVerifier({
23
+ now: clock,
24
+ context: "framework-window-bootstrap-v1",
25
+ resolve: (identity) => live && identity.channelId === channelId && identity.credentialId === credentialId ? {
26
+ secret,
27
+ expiresAt,
28
+ principal: options.principal
29
+ } : void 0
30
+ });
31
+ const bodySha256 = createHash("sha256").update("{}").digest("hex");
32
+ return {
33
+ origin,
34
+ preload: `(() => {
35
+ if (window.top !== window || location.origin !== ${JSON.stringify(origin)}) return;
36
+ const keyBytes = Uint8Array.from(atob(${JSON.stringify(secret.toString("base64"))}), c => c.charCodeAt(0));
37
+ const nativeFetch = fetch.bind(window);
38
+ const encode = bytes => btoa(String.fromCharCode(...new Uint8Array(bytes))).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');
39
+ Object.defineProperty(window, '__frameworkAcquireBootstrap', { configurable: false, value: async () => {
40
+ const nonce = encode(crypto.getRandomValues(new Uint8Array(24)));
41
+ const timestamp = String(Date.now());
42
+ const fields = ['framework-window-bootstrap-v1', ${JSON.stringify(channelId)}, ${JSON.stringify(credentialId)}, nonce, timestamp, ${JSON.stringify(bodySha256)}];
43
+ const key = await crypto.subtle.importKey('raw', keyBytes, {name:'HMAC', hash:'SHA-256'}, false, ['sign']);
44
+ const proof = encode(await crypto.subtle.sign('HMAC', key, new TextEncoder().encode(fields.join('\\u001f'))));
45
+ const response = await nativeFetch(${JSON.stringify(origin + "/__framework/bootstrap")}, {method:'POST', headers:{'content-type':'application/json', 'x-adea-channel':${JSON.stringify(channelId)}, 'x-adea-credential':${JSON.stringify(credentialId)}, 'x-adea-nonce':nonce, 'x-adea-timestamp':timestamp, 'x-adea-proof':proof}, body:'{}'});
46
+ if (!response.ok) throw new Error('Window bootstrap unavailable');
47
+ return response.json();
48
+ }});
49
+ })();`,
50
+ /** Called only after the gateway has checked origin and bounded the body. */
51
+ acquire(request) {
52
+ if (request.body !== "{}" || !verifier.verify(request).ok) return void 0;
53
+ options.authority.revokeAll();
54
+ return options.authority.issue(options.principal);
55
+ },
56
+ revoke() {
57
+ live = false;
58
+ secret.fill(0);
59
+ options.authority.revokeAll();
60
+ }
61
+ };
62
+ }
63
+ export { createNativeWindowGrant };
@@ -0,0 +1,32 @@
1
+ import type { DesktopRenderer } from './renderer-profile';
2
+ export type WindowFrame = Readonly<{
3
+ width: number;
4
+ height: number;
5
+ x: number;
6
+ y: number;
7
+ }>;
8
+ /** Shared Electrobun window chrome; the host supplies identity and capability. */
9
+ export declare function createWindowOptions(options: {
10
+ title: string;
11
+ url: string;
12
+ platform: string;
13
+ transparent?: boolean;
14
+ renderer?: DesktopRenderer;
15
+ frame?: WindowFrame;
16
+ }): {
17
+ title: string;
18
+ renderer?: DesktopRenderer | undefined;
19
+ url: string;
20
+ titleBarStyle: "default" | "hiddenInset";
21
+ trafficLightOffset: {
22
+ x: number;
23
+ y: number;
24
+ } | undefined;
25
+ transparent: boolean;
26
+ frame: Readonly<{
27
+ width: number;
28
+ height: number;
29
+ x: number;
30
+ y: number;
31
+ }>;
32
+ };
@@ -0,0 +1,23 @@
1
+ // src/native/window-options.ts
2
+ /** Shared Electrobun window chrome; the host supplies identity and capability. */
3
+ function createWindowOptions(options) {
4
+ const mac = options.platform === "darwin";
5
+ return {
6
+ title: options.title,
7
+ ...options.renderer === void 0 ? {} : { renderer: options.renderer },
8
+ url: options.url,
9
+ titleBarStyle: mac ? "hiddenInset" : "default",
10
+ trafficLightOffset: mac ? {
11
+ x: 0,
12
+ y: 8
13
+ } : void 0,
14
+ transparent: mac && (options.transparent ?? false),
15
+ frame: options.frame ?? {
16
+ width: 1280,
17
+ height: 840,
18
+ x: 120,
19
+ y: 90
20
+ }
21
+ };
22
+ }
23
+ export { createWindowOptions };
@@ -0,0 +1,2 @@
1
+ /** Internal hook plumbing; the public hook always supplies the pinned patch. */
2
+ export declare function patchWindowsBuildForTest(env: Record<string, string | undefined>, patch: (input: Buffer) => Buffer): Promise<void>;
@@ -0,0 +1,32 @@
1
+ import { assertPortableAppName } from "../installer/installer-layout.js";
2
+ import { lstat, readFile, realpath, rename, rm, writeFile } from "node:fs/promises";
3
+ import { isAbsolute, join, relative } from "node:path";
4
+ import { randomUUID } from "node:crypto";
5
+ // src/native/windows-build-hook-internal.ts
6
+ /** Internal hook plumbing; the public hook always supplies the pinned patch. */
7
+ async function patchWindowsBuildForTest(env, patch) {
8
+ if (env.ELECTROBUN_OS === "macos" || env.ELECTROBUN_OS === "linux") return;
9
+ if (env.ELECTROBUN_OS !== "win" || env.ELECTROBUN_ARCH !== "x64" || !env.ELECTROBUN_BUILD_DIR || !env.ELECTROBUN_APP_NAME || ![
10
+ "dev",
11
+ "canary",
12
+ "stable"
13
+ ].includes(env.ELECTROBUN_BUILD_ENV ?? "")) throw new Error("Invalid Electrobun build context");
14
+ assertPortableAppName(env.ELECTROBUN_APP_NAME);
15
+ const buildRoot = await realpath(env.ELECTROBUN_BUILD_DIR);
16
+ const suffix = env.ELECTROBUN_BUILD_ENV === "stable" ? "" : `-${env.ELECTROBUN_BUILD_ENV}`;
17
+ const path = join(buildRoot, env.ELECTROBUN_APP_NAME.replaceAll(" ", "") + suffix, "bin", "libNativeWrapper.dll");
18
+ const info = await lstat(path);
19
+ if (!info.isFile() || info.isSymbolicLink() || info.size > 67108864) throw new Error("Invalid Windows build runtime");
20
+ const physical = await realpath(path);
21
+ const within = relative(buildRoot, physical);
22
+ if (!within || within === ".." || within.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute(within)) throw new Error("Runtime escaped the build directory");
23
+ const output = patch(await readFile(physical));
24
+ const temp = `${physical}.${randomUUID()}.tmp`;
25
+ try {
26
+ await writeFile(temp, output, { flag: "wx" });
27
+ await rename(temp, physical);
28
+ } finally {
29
+ await rm(temp, { force: true });
30
+ }
31
+ }
32
+ export { patchWindowsBuildForTest };
@@ -0,0 +1,2 @@
1
+ /** Electrobun postBuild hook; runs before release hashing, packaging and signing. */
2
+ export default function secureWindowsBuild(): Promise<void>;
@@ -0,0 +1,12 @@
1
+ import { patchPinnedWindowsRuntime } from "./windows-runtime-patch.js";
2
+ import { patchWindowsBuildForTest } from "./windows-build-hook-internal.js";
3
+ import { createHash } from "node:crypto";
4
+ // src/native/windows-build-hook.ts
5
+ /** Electrobun postBuild hook; runs before release hashing, packaging and signing. */
6
+ async function secureWindowsBuild() {
7
+ await patchWindowsBuildForTest(process.env, (input) => {
8
+ if (createHash("sha256").update(input).digest("hex") === "4806357dc333785ae22cdf3526d623cd56283d9c374ceafbf847c3ba6d5d59c3") return input;
9
+ return patchPinnedWindowsRuntime(input);
10
+ });
11
+ }
12
+ export { secureWindowsBuild as default };
@@ -0,0 +1,3 @@
1
+ export declare const UNSAFE_WEBVIEW_ARGUMENTS = "--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection --allow-insecure-localhost --disable-web-security";
2
+ /** Internal deterministic patch primitive. Callers should use the pinned wrapper below. */
3
+ export declare function patchWindowsBinaryForDigest(input: Buffer, expectedSha256: string): Buffer;
@@ -0,0 +1,20 @@
1
+ import { createHash } from "node:crypto";
2
+ // src/native/windows-runtime-patch-internal.ts
3
+ var UNSAFE_WEBVIEW_ARGUMENTS = "--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection --allow-insecure-localhost --disable-web-security";
4
+ var digest = (bytes) => createHash("sha256").update(bytes).digest("hex");
5
+ /** Internal deterministic patch primitive. Callers should use the pinned wrapper below. */
6
+ function patchWindowsBinaryForDigest(input, expectedSha256) {
7
+ if (!Buffer.isBuffer(input) || input.length < 512 || input.length > 67108864 || digest(input) !== expectedSha256 || input.toString("ascii", 0, 2) !== "MZ") throw new Error("Unexpected Windows runtime binary");
8
+ const pe = input.readUInt32LE(60);
9
+ if (pe > input.length - 24 || input.toString("binary", pe, pe + 4) !== "PE\0\0" || input.readUInt16LE(pe + 4) !== 34404 || (input.readUInt16LE(pe + 22) & 8192) === 0) throw new Error("Expected a Windows x64 DLL");
10
+ const optional = pe + 24;
11
+ const optionalSize = input.readUInt16LE(pe + 20);
12
+ if (optionalSize < 152 || optional + optionalSize > input.length || input.readUInt16LE(optional) !== 523 || input.readUInt32LE(optional + 108) < 5 || input.readUInt32LE(optional + 144) !== 0 || input.readUInt32LE(optional + 148) !== 0) throw new Error("Expected an unsigned Windows x64 DLL");
13
+ const marker = Buffer.from(UNSAFE_WEBVIEW_ARGUMENTS, "utf16le");
14
+ const offset = input.indexOf(marker);
15
+ if (offset < 0 || input.indexOf(marker, offset + marker.length) >= 0 || offset + marker.length + 2 > input.length || input.readUInt16LE(offset + marker.length) !== 0) throw new Error("Unexpected WebView2 argument declaration");
16
+ const output = Buffer.from(input);
17
+ output.fill(0, offset, offset + marker.length);
18
+ return output;
19
+ }
20
+ export { UNSAFE_WEBVIEW_ARGUMENTS, patchWindowsBinaryForDigest };
@@ -0,0 +1,4 @@
1
+ export declare const ELECTROBUN_WINDOWS_WRAPPER_SHA256 = "e162c21696c1676bd4522e0c94d934aa32a6394aea852687d111ab86ed97fe1b";
2
+ export declare const SECURE_WINDOWS_WRAPPER_SHA256 = "4806357dc333785ae22cdf3526d623cd56283d9c374ceafbf847c3ba6d5d59c3";
3
+ /** Patch only the exact pinned unsigned SDK. Sign the application after applying it. */
4
+ export declare function patchPinnedWindowsRuntime(input: Buffer): Buffer;
@@ -0,0 +1,12 @@
1
+ import { patchWindowsBinaryForDigest } from "./windows-runtime-patch-internal.js";
2
+ import { createHash } from "node:crypto";
3
+ // src/native/windows-runtime-patch.ts
4
+ var ELECTROBUN_WINDOWS_WRAPPER_SHA256 = "e162c21696c1676bd4522e0c94d934aa32a6394aea852687d111ab86ed97fe1b";
5
+ var SECURE_WINDOWS_WRAPPER_SHA256 = "4806357dc333785ae22cdf3526d623cd56283d9c374ceafbf847c3ba6d5d59c3";
6
+ /** Patch only the exact pinned unsigned SDK. Sign the application after applying it. */
7
+ function patchPinnedWindowsRuntime(input) {
8
+ const output = patchWindowsBinaryForDigest(input, ELECTROBUN_WINDOWS_WRAPPER_SHA256);
9
+ if (createHash("sha256").update(output).digest("hex") !== "4806357dc333785ae22cdf3526d623cd56283d9c374ceafbf847c3ba6d5d59c3") throw new Error("Unexpected patched runtime digest");
10
+ return output;
11
+ }
12
+ export { ELECTROBUN_WINDOWS_WRAPPER_SHA256, SECURE_WINDOWS_WRAPPER_SHA256, patchPinnedWindowsRuntime };
@@ -0,0 +1,23 @@
1
+ import type { FeedRelease, ReleaseLedger } from '../updates/release-feed';
2
+ import { type GitRun } from './local-provenance';
3
+ import type { ReleaseCutProvider } from './release-cut';
4
+ /**
5
+ * Release feed adapter for local release cuts. The feed's ledger replaces the GitHub release
6
+ * listing and the local checkout's fetched `origin/main` replaces GitHub's compare API. A dev
7
+ * cut lives in memory until its build is published; a daily not yet in the ledger stands for
8
+ * the Release Please release of the source manifest's version, as a stageable draft. A release
9
+ * is qualified once its published release.json carries every payload this host builds, so a
10
+ * second host adds its platform to an existing release. Nothing is built remotely, so a cut
11
+ * is never pending and dispatch only hands the tag back to the caller to build.
12
+ */
13
+ export declare function createFeedReleaseCutProvider(options: {
14
+ ledger: ReleaseLedger;
15
+ /** The published release.json of a tag, or null. */
16
+ release(tag: string): Promise<FeedRelease | null>;
17
+ git: GitRun;
18
+ /** The source commit and the version its manifest names. */
19
+ sourceSha: string;
20
+ releasedVersion: string;
21
+ /** The payload names this host builds for a tag. */
22
+ payloads(tag: string): readonly string[];
23
+ }): ReleaseCutProvider;
@@ -0,0 +1,93 @@
1
+ import { gitIsAncestor } from "./local-provenance.js";
2
+ // src/release/feed-release-cut.ts
3
+ function checkTag(tag) {
4
+ if (!/^v\d+\.\d+\.\d+(?:-dev\.\d+)?$/.test(tag) || tag.length > 65) throw new Error("Invalid release tag");
5
+ }
6
+ /**
7
+ * Release feed adapter for local release cuts. The feed's ledger replaces the GitHub release
8
+ * listing and the local checkout's fetched `origin/main` replaces GitHub's compare API. A dev
9
+ * cut lives in memory until its build is published; a daily not yet in the ledger stands for
10
+ * the Release Please release of the source manifest's version, as a stageable draft. A release
11
+ * is qualified once its published release.json carries every payload this host builds, so a
12
+ * second host adds its platform to an existing release. Nothing is built remotely, so a cut
13
+ * is never pending and dispatch only hands the tag back to the caller to build.
14
+ */
15
+ function createFeedReleaseCutProvider(options) {
16
+ const { ledger, git } = options;
17
+ const created = /* @__PURE__ */ new Map();
18
+ return {
19
+ async find(tag) {
20
+ checkTag(tag);
21
+ const kind = tag.includes("-dev.") ? "dev" : "daily";
22
+ const entry = ledger.releases.find((item) => item.tag === tag);
23
+ if (entry) return {
24
+ tag,
25
+ sourceSha: entry.sourceSha,
26
+ kind,
27
+ draft: false,
28
+ prerelease: entry.kind !== "stable"
29
+ };
30
+ const sourceSha = created.get(tag);
31
+ if (sourceSha) return {
32
+ tag,
33
+ sourceSha,
34
+ kind,
35
+ draft: false,
36
+ prerelease: true
37
+ };
38
+ if (kind === "daily" && tag === `v${options.releasedVersion}`) return {
39
+ tag,
40
+ sourceSha: options.sourceSha,
41
+ kind,
42
+ draft: true,
43
+ prerelease: false,
44
+ stageableDraft: true
45
+ };
46
+ return null;
47
+ },
48
+ isMainAncestor: (sha) => gitIsAncestor(git, sha, "refs/remotes/origin/main"),
49
+ async isAncestor(older, newer) {
50
+ return older !== newer && await gitIsAncestor(git, older, newer);
51
+ },
52
+ async create(identity) {
53
+ checkTag(identity.tag);
54
+ if (!identity.tag.includes("-dev.") || created.has(identity.tag)) throw new Error("Only a new dev release is cut locally");
55
+ created.set(identity.tag, identity.sourceSha);
56
+ },
57
+ async qualification(release) {
58
+ if (!ledger.releases.some((item) => item.tag === release.tag)) return "not-qualified";
59
+ try {
60
+ const published = await options.release(release.tag);
61
+ const names = new Set(published?.assets.map((asset) => asset.name));
62
+ return options.payloads(release.tag).every((name) => names.has(name)) ? "qualified" : "not-qualified";
63
+ } catch {
64
+ return "unknown";
65
+ }
66
+ },
67
+ pendingBuild: async () => "idle",
68
+ async highestDevCounter(version) {
69
+ if (typeof version !== "string" || version.length > 64 || !/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(version)) throw new Error("Invalid source version");
70
+ const prefix = `v${version}-dev.`;
71
+ let highest = 0;
72
+ for (const tag of [...ledger.releases.map((item) => item.tag), ...created.keys()]) {
73
+ if (!tag.startsWith(prefix)) continue;
74
+ const suffix = tag.slice(prefix.length);
75
+ if (!/^[1-9]\d{0,15}$/.test(suffix) || !Number.isSafeInteger(Number(suffix))) throw new Error("Invalid dev release counter");
76
+ highest = Math.max(highest, Number(suffix));
77
+ }
78
+ return highest;
79
+ },
80
+ async tagExists(tag) {
81
+ checkTag(tag);
82
+ return ledger.releases.some((item) => item.tag === tag) || await git([
83
+ "tag",
84
+ "--list",
85
+ tag
86
+ ]) !== "";
87
+ },
88
+ async dispatch(tag) {
89
+ checkTag(tag);
90
+ }
91
+ };
92
+ }
93
+ export { createFeedReleaseCutProvider };
@@ -0,0 +1,25 @@
1
+ import { type FeedChannel, type FeedRelease, type ReleaseFeed, type ReleaseLedger } from '../updates/release-feed';
2
+ import { type FetchFunction } from '../updates/release-location';
3
+ /** The published ledger, or an empty one before the app's first release. */
4
+ export declare function readFeedLedger(feed: ReleaseFeed, fetcher: FetchFunction): Promise<ReleaseLedger>;
5
+ /** A tag's published release.json, or null when none is published. */
6
+ export declare function readFeedRelease(feed: ReleaseFeed, tag: string, fetcher: FetchFunction): Promise<FeedRelease | null>;
7
+ /**
8
+ * Verify a published release from the feed: its ledger entry and release.json agree, and every
9
+ * signed descriptor it lists for `channels` (all of its channels by default) has the listed
10
+ * bytes, authenticates against the app's trust and names a listed payload with the same size
11
+ * and digest. Returns the release platforms whose descriptors all verified; a platform whose
12
+ * payload is listed but whose descriptors are missing fails.
13
+ */
14
+ export declare function verifyFeedRelease(options: {
15
+ config: unknown;
16
+ feed: ReleaseFeed;
17
+ tag: string;
18
+ repository: string;
19
+ keys: ReadonlyMap<string, string>;
20
+ fetch: FetchFunction;
21
+ channels?: readonly FeedChannel[];
22
+ }): Promise<{
23
+ release: FeedRelease;
24
+ platforms: string[];
25
+ }>;