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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (474) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +30 -0
  3. package/README.md +967 -2
  4. package/dist/app/application.d.ts +47 -0
  5. package/dist/app/application.js +115 -0
  6. package/dist/app/create-application.d.ts +13 -0
  7. package/dist/app/create-application.js +178 -0
  8. package/dist/app/service-registry.d.ts +44 -0
  9. package/dist/app/service-registry.js +116 -0
  10. package/dist/appearance/appearance-host.d.ts +62 -0
  11. package/dist/appearance/appearance-host.js +115 -0
  12. package/dist/appearance/appearance-preferences.d.ts +106 -0
  13. package/dist/appearance/appearance-preferences.js +175 -0
  14. package/dist/appearance/composition.d.ts +11 -0
  15. package/dist/appearance/composition.js +16 -0
  16. package/dist/appearance/custom-theme-import.d.ts +14 -0
  17. package/dist/appearance/custom-theme-import.js +315 -0
  18. package/dist/appearance/custom-theme-library.d.ts +146 -0
  19. package/dist/appearance/custom-theme-library.js +378 -0
  20. package/dist/appearance/editor.d.ts +20 -0
  21. package/dist/appearance/editor.js +47 -0
  22. package/dist/appearance/theme-file-importer.d.ts +23 -0
  23. package/dist/appearance/theme-file-importer.js +66 -0
  24. package/dist/appearance/theme-record-adapter.d.ts +26 -0
  25. package/dist/appearance/theme-record-adapter.js +64 -0
  26. package/dist/appearance/theme-registry.d.ts +10 -0
  27. package/dist/appearance/theme-registry.js +16 -0
  28. package/dist/appearance/window-surface.d.ts +5 -0
  29. package/dist/appearance/window-surface.js +9 -0
  30. package/dist/ci/toolchain-identity.d.ts +39 -0
  31. package/dist/ci/toolchain-identity.js +196 -0
  32. package/dist/cli/cef-helper-cli.d.ts +2 -0
  33. package/dist/cli/cef-helper-cli.js +18 -0
  34. package/dist/cli/cli-runner.d.ts +8 -0
  35. package/dist/cli/cli-runner.js +23 -0
  36. package/dist/cli/create-application-cli.d.ts +2 -0
  37. package/dist/cli/create-application-cli.js +40 -0
  38. package/dist/cli/electrobun-shortcut-patch-cli.d.ts +2 -0
  39. package/dist/cli/electrobun-shortcut-patch-cli.js +17 -0
  40. package/dist/cli/framework-update-cli.d.ts +2 -0
  41. package/dist/cli/framework-update-cli.js +40 -0
  42. package/dist/cli/release-assets-plan-cli.d.ts +2 -0
  43. package/dist/cli/release-assets-plan-cli.js +14 -0
  44. package/dist/cli/release-cut-cli.d.ts +2 -0
  45. package/dist/cli/release-cut-cli.js +27 -0
  46. package/dist/cli/release-descriptor-staging-cli.d.ts +2 -0
  47. package/dist/cli/release-descriptor-staging-cli.js +45 -0
  48. package/dist/cli/release-finalize-cli.d.ts +1 -0
  49. package/dist/cli/release-finalize-cli.js +30 -0
  50. package/dist/cli/release-promote-cli.d.ts +2 -0
  51. package/dist/cli/release-promote-cli.js +32 -0
  52. package/dist/cli/release-publish-cli.d.ts +2 -0
  53. package/dist/cli/release-publish-cli.js +48 -0
  54. package/dist/cli/release-sign-cli.d.ts +2 -0
  55. package/dist/cli/release-sign-cli.js +13 -0
  56. package/dist/cli/release-step-cli.d.ts +2 -0
  57. package/dist/cli/release-step-cli.js +44 -0
  58. package/dist/cli/toolchain-identity-cli.d.ts +2 -0
  59. package/dist/cli/toolchain-identity-cli.js +10 -0
  60. package/dist/cli/update-helper-cli.d.ts +1 -0
  61. package/dist/cli/update-helper-cli.js +10 -0
  62. package/dist/cli/windows-runtime-patch-cli.d.ts +2 -0
  63. package/dist/cli/windows-runtime-patch-cli.js +17 -0
  64. package/dist/desktop/application-command-client.d.ts +15 -0
  65. package/dist/desktop/application-command-client.js +21 -0
  66. package/dist/desktop/channel-handshake.d.ts +32 -0
  67. package/dist/desktop/channel-handshake.js +111 -0
  68. package/dist/desktop/channel-proof.d.ts +43 -0
  69. package/dist/desktop/channel-proof.js +85 -0
  70. package/dist/desktop/client-assets.d.ts +7 -0
  71. package/dist/desktop/client-assets.js +59 -0
  72. package/dist/desktop/desktop-client.d.ts +23 -0
  73. package/dist/desktop/desktop-client.js +231 -0
  74. package/dist/desktop/desktop-gateway.d.ts +18 -0
  75. package/dist/desktop/desktop-gateway.js +146 -0
  76. package/dist/desktop/desktop-host.d.ts +48 -0
  77. package/dist/desktop/desktop-host.js +208 -0
  78. package/dist/desktop/desktop-stream.d.ts +36 -0
  79. package/dist/desktop/desktop-stream.js +231 -0
  80. package/dist/desktop/loopback-policy.d.ts +19 -0
  81. package/dist/desktop/loopback-policy.js +23 -0
  82. package/dist/desktop/open-url-channel.d.ts +15 -0
  83. package/dist/desktop/open-url-channel.js +55 -0
  84. package/dist/desktop/string-policy.d.ts +2 -0
  85. package/dist/desktop/string-policy.js +11 -0
  86. package/dist/framework-source.json +1 -0
  87. package/dist/installer/archive-entry.d.ts +6 -0
  88. package/dist/installer/archive-entry.js +14 -0
  89. package/dist/installer/command-artifact.d.ts +47 -0
  90. package/dist/installer/command-artifact.js +261 -0
  91. package/dist/installer/command-qualification-command.d.ts +12 -0
  92. package/dist/installer/command-qualification-command.js +71 -0
  93. package/dist/installer/hosted-runner.d.ts +4 -0
  94. package/dist/installer/hosted-runner.js +10 -0
  95. package/dist/installer/installed-payload.d.ts +29 -0
  96. package/dist/installer/installed-payload.js +312 -0
  97. package/dist/installer/installer-ci-bootstrap.d.ts +26 -0
  98. package/dist/installer/installer-ci-bootstrap.js +160 -0
  99. package/dist/installer/installer-ci-preflight.d.ts +1 -0
  100. package/dist/installer/installer-ci-preflight.js +49 -0
  101. package/dist/installer/installer-ci-worker.d.ts +1 -0
  102. package/dist/installer/installer-ci-worker.js +105 -0
  103. package/dist/installer/installer-extraction.d.ts +14 -0
  104. package/dist/installer/installer-extraction.js +289 -0
  105. package/dist/installer/installer-fetch-guard.d.ts +15 -0
  106. package/dist/installer/installer-fetch-guard.js +50 -0
  107. package/dist/installer/installer-identity.d.ts +23 -0
  108. package/dist/installer/installer-identity.js +286 -0
  109. package/dist/installer/installer-layout.d.ts +21 -0
  110. package/dist/installer/installer-layout.js +89 -0
  111. package/dist/installer/installer-observation.d.ts +64 -0
  112. package/dist/installer/installer-observation.js +473 -0
  113. package/dist/installer/installer-process-cleanup.d.ts +18 -0
  114. package/dist/installer/installer-process-cleanup.js +158 -0
  115. package/dist/installer/installer-qualification-command.d.ts +11 -0
  116. package/dist/installer/installer-qualification-command.js +71 -0
  117. package/dist/installer/installer-renderer-evidence.d.ts +43 -0
  118. package/dist/installer/installer-renderer-evidence.js +136 -0
  119. package/dist/installer/installer-upgrade-command.d.ts +37 -0
  120. package/dist/installer/installer-upgrade-command.js +172 -0
  121. package/dist/installer/installer-worker-guard.d.ts +21 -0
  122. package/dist/installer/installer-worker-guard.js +72 -0
  123. package/dist/installer/native-executable.d.ts +5 -0
  124. package/dist/installer/native-executable.js +21 -0
  125. package/dist/installer/upgrade-asset-download.d.ts +13 -0
  126. package/dist/installer/upgrade-asset-download.js +41 -0
  127. package/dist/installer/write-all.d.ts +6 -0
  128. package/dist/installer/write-all.js +11 -0
  129. package/dist/native/app-bundle.d.ts +28 -0
  130. package/dist/native/app-bundle.js +60 -0
  131. package/dist/native/cef-helper.d.ts +28 -0
  132. package/dist/native/cef-helper.js +402 -0
  133. package/dist/native/desktop-build-hook.d.ts +7 -0
  134. package/dist/native/desktop-build-hook.js +20 -0
  135. package/dist/native/electrobun-source-patch.d.ts +25 -0
  136. package/dist/native/electrobun-source-patch.js +93 -0
  137. package/dist/native/linux-cef-links.d.ts +2 -0
  138. package/dist/native/linux-cef-links.js +15 -0
  139. package/dist/native/native-secret-store.d.ts +27 -0
  140. package/dist/native/native-secret-store.js +70 -0
  141. package/dist/native/native-utilities.d.ts +24 -0
  142. package/dist/native/native-utilities.js +85 -0
  143. package/dist/native/partitioned-window.d.ts +34 -0
  144. package/dist/native/partitioned-window.js +44 -0
  145. package/dist/native/renderer-profile.d.ts +53 -0
  146. package/dist/native/renderer-profile.js +30 -0
  147. package/dist/native/secure-window.d.ts +38 -0
  148. package/dist/native/secure-window.js +77 -0
  149. package/dist/native/sidecar-services.d.ts +23 -0
  150. package/dist/native/sidecar-services.js +46 -0
  151. package/dist/native/sidecar.d.ts +81 -0
  152. package/dist/native/sidecar.js +250 -0
  153. package/dist/native/window-bootstrap.d.ts +24 -0
  154. package/dist/native/window-bootstrap.js +63 -0
  155. package/dist/native/window-options.d.ts +32 -0
  156. package/dist/native/window-options.js +23 -0
  157. package/dist/native/windows-build-hook-internal.d.ts +2 -0
  158. package/dist/native/windows-build-hook-internal.js +32 -0
  159. package/dist/native/windows-build-hook.d.ts +2 -0
  160. package/dist/native/windows-build-hook.js +12 -0
  161. package/dist/native/windows-runtime-patch-internal.d.ts +3 -0
  162. package/dist/native/windows-runtime-patch-internal.js +20 -0
  163. package/dist/native/windows-runtime-patch.d.ts +4 -0
  164. package/dist/native/windows-runtime-patch.js +12 -0
  165. package/dist/release/feed-release-cut.d.ts +23 -0
  166. package/dist/release/feed-release-cut.js +93 -0
  167. package/dist/release/feed-state.d.ts +25 -0
  168. package/dist/release/feed-state.js +81 -0
  169. package/dist/release/framework-package-publish.d.ts +21 -0
  170. package/dist/release/framework-package-publish.js +125 -0
  171. package/dist/release/framework-update.d.ts +30 -0
  172. package/dist/release/framework-update.js +139 -0
  173. package/dist/release/github-cli.d.ts +6 -0
  174. package/dist/release/github-cli.js +16 -0
  175. package/dist/release/github-release-assets.d.ts +3 -0
  176. package/dist/release/github-release-assets.js +24 -0
  177. package/dist/release/github-release-cut.d.ts +14 -0
  178. package/dist/release/github-release-cut.js +174 -0
  179. package/dist/release/github-release-lookup.d.ts +7 -0
  180. package/dist/release/github-release-lookup.js +29 -0
  181. package/dist/release/github-release-promotion.d.ts +10 -0
  182. package/dist/release/github-release-promotion.js +78 -0
  183. package/dist/release/github-release-provenance.d.ts +9 -0
  184. package/dist/release/github-release-provenance.js +27 -0
  185. package/dist/release/github-release-publisher.d.ts +9 -0
  186. package/dist/release/github-release-publisher.js +63 -0
  187. package/dist/release/github-release-qualification.d.ts +12 -0
  188. package/dist/release/github-release-qualification.js +80 -0
  189. package/dist/release/local-provenance.d.ts +24 -0
  190. package/dist/release/local-provenance.js +72 -0
  191. package/dist/release/local-release.d.ts +133 -0
  192. package/dist/release/local-release.js +387 -0
  193. package/dist/release/macos-dmg.d.ts +22 -0
  194. package/dist/release/macos-dmg.js +91 -0
  195. package/dist/release/release-artifact.d.ts +6 -0
  196. package/dist/release/release-artifact.js +38 -0
  197. package/dist/release/release-assets-plan.d.ts +14 -0
  198. package/dist/release/release-assets-plan.js +65 -0
  199. package/dist/release/release-config.d.ts +76 -0
  200. package/dist/release/release-config.js +180 -0
  201. package/dist/release/release-cut-command.d.ts +13 -0
  202. package/dist/release/release-cut-command.js +39 -0
  203. package/dist/release/release-cut.d.ts +54 -0
  204. package/dist/release/release-cut.js +76 -0
  205. package/dist/release/release-descriptor-staging.d.ts +34 -0
  206. package/dist/release/release-descriptor-staging.js +147 -0
  207. package/dist/release/release-finalize.d.ts +16 -0
  208. package/dist/release/release-finalize.js +104 -0
  209. package/dist/release/release-promotion-command.d.ts +12 -0
  210. package/dist/release/release-promotion-command.js +28 -0
  211. package/dist/release/release-promotion.d.ts +29 -0
  212. package/dist/release/release-promotion.js +57 -0
  213. package/dist/release/release-publication.d.ts +33 -0
  214. package/dist/release/release-publication.js +138 -0
  215. package/dist/release/release-publish-command.d.ts +7 -0
  216. package/dist/release/release-publish-command.js +91 -0
  217. package/dist/release/release-qualification.d.ts +106 -0
  218. package/dist/release/release-qualification.js +135 -0
  219. package/dist/release/release-staging.d.ts +9 -0
  220. package/dist/release/release-staging.js +61 -0
  221. package/dist/release/release-steps.d.ts +38 -0
  222. package/dist/release/release-steps.js +147 -0
  223. package/dist/release/retained-release-build.d.ts +19 -0
  224. package/dist/release/retained-release-build.js +122 -0
  225. package/dist/shell/app-shell.d.ts +61 -0
  226. package/dist/shell/app-shell.js +318 -0
  227. package/dist/shell/app-utilities.d.ts +122 -0
  228. package/dist/shell/app-utilities.js +334 -0
  229. package/dist/shell/application-menu-commands.d.ts +5 -0
  230. package/dist/shell/application-menu-commands.js +11 -0
  231. package/dist/shell/application-menu.d.ts +61 -0
  232. package/dist/shell/application-menu.js +208 -0
  233. package/dist/shell/help-shortcuts.d.ts +12 -0
  234. package/dist/shell/help-shortcuts.js +22 -0
  235. package/dist/shell/settings-sections.d.ts +31 -0
  236. package/dist/shell/settings-sections.js +50 -0
  237. package/dist/shell/shortcut-platform.d.ts +17 -0
  238. package/dist/shell/shortcut-platform.js +25 -0
  239. package/dist/update-helper.bundle.js +260 -0
  240. package/dist/updates/channel-update-manager.d.ts +46 -0
  241. package/dist/updates/channel-update-manager.js +114 -0
  242. package/dist/updates/desktop-updater.d.ts +104 -0
  243. package/dist/updates/desktop-updater.js +345 -0
  244. package/dist/updates/release-feed.d.ts +61 -0
  245. package/dist/updates/release-feed.js +111 -0
  246. package/dist/updates/release-location.d.ts +9 -0
  247. package/dist/updates/release-location.js +80 -0
  248. package/dist/updates/release-version.d.ts +12 -0
  249. package/dist/updates/release-version.js +43 -0
  250. package/dist/updates/signed-release.d.ts +63 -0
  251. package/dist/updates/signed-release.js +162 -0
  252. package/dist/updates/stable-file.d.ts +10 -0
  253. package/dist/updates/stable-file.js +22 -0
  254. package/dist/updates/update-adapter.d.ts +57 -0
  255. package/dist/updates/update-adapter.js +72 -0
  256. package/dist/updates/update-arm.d.ts +24 -0
  257. package/dist/updates/update-arm.js +95 -0
  258. package/dist/updates/update-channel-store.d.ts +8 -0
  259. package/dist/updates/update-channel-store.js +72 -0
  260. package/dist/updates/update-discovery.d.ts +13 -0
  261. package/dist/updates/update-discovery.js +56 -0
  262. package/dist/updates/update-download.d.ts +14 -0
  263. package/dist/updates/update-download.js +67 -0
  264. package/dist/updates/update-exclusive-rename.d.ts +2 -0
  265. package/dist/updates/update-exclusive-rename.js +52 -0
  266. package/dist/updates/update-extraction.d.ts +18 -0
  267. package/dist/updates/update-extraction.js +183 -0
  268. package/dist/updates/update-handoff-plan.d.ts +22 -0
  269. package/dist/updates/update-handoff-plan.js +28 -0
  270. package/dist/updates/update-helper.d.ts +24 -0
  271. package/dist/updates/update-helper.js +56 -0
  272. package/dist/updates/update-launch.d.ts +5 -0
  273. package/dist/updates/update-launch.js +27 -0
  274. package/dist/updates/update-manager.d.ts +40 -0
  275. package/dist/updates/update-manager.js +83 -0
  276. package/dist/updates/update-process-fence.d.ts +10 -0
  277. package/dist/updates/update-process-fence.js +114 -0
  278. package/dist/updates/update-resume.d.ts +13 -0
  279. package/dist/updates/update-resume.js +34 -0
  280. package/dist/updates/update-shutdown.d.ts +15 -0
  281. package/dist/updates/update-shutdown.js +29 -0
  282. package/dist/updates/update-state.d.ts +30 -0
  283. package/dist/updates/update-state.js +18 -0
  284. package/dist/updates/update-swap-stage.d.ts +27 -0
  285. package/dist/updates/update-swap-stage.js +58 -0
  286. package/dist/updates/update-swap.d.ts +10 -0
  287. package/dist/updates/update-swap.js +30 -0
  288. package/dist/views/app-about.d.ts +22 -0
  289. package/dist/views/app-about.js +43 -0
  290. package/dist/views/app-appearance.d.ts +11 -0
  291. package/dist/views/app-appearance.js +42 -0
  292. package/dist/views/app-help.d.ts +17 -0
  293. package/dist/views/app-help.js +42 -0
  294. package/dist/views/app-settings.d.ts +26 -0
  295. package/dist/views/app-settings.js +97 -0
  296. package/dist/views/appearance-surface.d.ts +9 -0
  297. package/dist/views/appearance-surface.js +334 -0
  298. package/dist/views/update-surface.d.ts +34 -0
  299. package/dist/views/update-surface.js +64 -0
  300. package/package.json +363 -4
  301. package/src/app/application.tsx +138 -0
  302. package/src/app/create-application.ts +245 -0
  303. package/src/app/service-registry.ts +124 -0
  304. package/src/appearance/appearance-host.tsx +205 -0
  305. package/src/appearance/appearance-preferences.ts +287 -0
  306. package/src/appearance/composition.ts +29 -0
  307. package/src/appearance/custom-theme-import.ts +424 -0
  308. package/src/appearance/custom-theme-library.ts +600 -0
  309. package/src/appearance/editor.ts +94 -0
  310. package/src/appearance/theme-file-importer.ts +103 -0
  311. package/src/appearance/theme-record-adapter.ts +106 -0
  312. package/src/appearance/theme-registry.ts +20 -0
  313. package/src/appearance/window-surface.ts +18 -0
  314. package/src/ci/toolchain-identity.ts +244 -0
  315. package/src/cli/cef-helper-cli.ts +21 -0
  316. package/src/cli/cli-runner.ts +29 -0
  317. package/src/cli/create-application-cli.ts +62 -0
  318. package/src/cli/electrobun-shortcut-patch-cli.ts +24 -0
  319. package/src/cli/framework-update-cli.ts +41 -0
  320. package/src/cli/release-assets-plan-cli.ts +14 -0
  321. package/src/cli/release-cut-cli.ts +41 -0
  322. package/src/cli/release-descriptor-staging-cli.ts +57 -0
  323. package/src/cli/release-finalize-cli.ts +34 -0
  324. package/src/cli/release-promote-cli.ts +31 -0
  325. package/src/cli/release-publish-cli.ts +46 -0
  326. package/src/cli/release-sign-cli.ts +24 -0
  327. package/src/cli/release-step-cli.ts +71 -0
  328. package/src/cli/toolchain-identity-cli.ts +12 -0
  329. package/src/cli/update-helper-cli.ts +12 -0
  330. package/src/cli/windows-runtime-patch-cli.ts +17 -0
  331. package/src/desktop/application-command-client.ts +43 -0
  332. package/src/desktop/channel-handshake.ts +136 -0
  333. package/src/desktop/channel-proof.ts +122 -0
  334. package/src/desktop/client-assets.ts +75 -0
  335. package/src/desktop/desktop-client.ts +303 -0
  336. package/src/desktop/desktop-gateway.ts +189 -0
  337. package/src/desktop/desktop-host.ts +335 -0
  338. package/src/desktop/desktop-stream.ts +324 -0
  339. package/src/desktop/loopback-policy.ts +41 -0
  340. package/src/desktop/open-url-channel.ts +79 -0
  341. package/src/desktop/string-policy.ts +9 -0
  342. package/src/installer/archive-entry.ts +32 -0
  343. package/src/installer/command-artifact.ts +307 -0
  344. package/src/installer/command-qualification-command.ts +75 -0
  345. package/src/installer/hosted-runner.ts +11 -0
  346. package/src/installer/installed-payload.ts +408 -0
  347. package/src/installer/installer-ci-bootstrap.ts +199 -0
  348. package/src/installer/installer-ci-preflight.ts +61 -0
  349. package/src/installer/installer-ci-worker.ts +105 -0
  350. package/src/installer/installer-extraction.ts +367 -0
  351. package/src/installer/installer-fetch-guard.ts +75 -0
  352. package/src/installer/installer-identity.ts +331 -0
  353. package/src/installer/installer-layout.ts +167 -0
  354. package/src/installer/installer-observation.ts +671 -0
  355. package/src/installer/installer-process-cleanup.ts +167 -0
  356. package/src/installer/installer-qualification-command.ts +81 -0
  357. package/src/installer/installer-renderer-evidence.ts +268 -0
  358. package/src/installer/installer-upgrade-command.ts +226 -0
  359. package/src/installer/installer-worker-guard.ts +112 -0
  360. package/src/installer/native-executable.ts +37 -0
  361. package/src/installer/upgrade-asset-download.ts +72 -0
  362. package/src/installer/write-all.ts +19 -0
  363. package/src/native/app-bundle.ts +86 -0
  364. package/src/native/cef-helper.ts +471 -0
  365. package/src/native/desktop-build-hook.ts +21 -0
  366. package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
  367. package/src/native/electrobun-source-patch.ts +107 -0
  368. package/src/native/electrobun-windows-shortcut-com.patch +923 -0
  369. package/src/native/linux-cef-links.ts +14 -0
  370. package/src/native/native-secret-store.ts +99 -0
  371. package/src/native/native-utilities.ts +166 -0
  372. package/src/native/partitioned-window.ts +62 -0
  373. package/src/native/renderer-profile.ts +27 -0
  374. package/src/native/secure-window.ts +115 -0
  375. package/src/native/sidecar-services.ts +71 -0
  376. package/src/native/sidecar.ts +387 -0
  377. package/src/native/window-bootstrap.ts +77 -0
  378. package/src/native/window-options.ts +24 -0
  379. package/src/native/windows-build-hook-internal.ts +49 -0
  380. package/src/native/windows-build-hook.ts +12 -0
  381. package/src/native/windows-runtime-patch-internal.ts +48 -0
  382. package/src/native/windows-runtime-patch.ts +15 -0
  383. package/src/release/feed-release-cut.ts +110 -0
  384. package/src/release/feed-state.ts +135 -0
  385. package/src/release/framework-package-publish.ts +163 -0
  386. package/src/release/framework-update.ts +196 -0
  387. package/src/release/github-cli.ts +27 -0
  388. package/src/release/github-release-assets.ts +36 -0
  389. package/src/release/github-release-cut.ts +237 -0
  390. package/src/release/github-release-lookup.ts +39 -0
  391. package/src/release/github-release-promotion.ts +112 -0
  392. package/src/release/github-release-provenance.ts +65 -0
  393. package/src/release/github-release-publisher.ts +90 -0
  394. package/src/release/github-release-qualification.ts +144 -0
  395. package/src/release/local-provenance.ts +92 -0
  396. package/src/release/local-release.ts +525 -0
  397. package/src/release/macos-dmg.ts +113 -0
  398. package/src/release/release-artifact.ts +53 -0
  399. package/src/release/release-assets-plan.ts +118 -0
  400. package/src/release/release-config.ts +420 -0
  401. package/src/release/release-cut-command.ts +80 -0
  402. package/src/release/release-cut.ts +133 -0
  403. package/src/release/release-descriptor-staging.ts +242 -0
  404. package/src/release/release-finalize.ts +191 -0
  405. package/src/release/release-promotion-command.ts +36 -0
  406. package/src/release/release-promotion.ts +132 -0
  407. package/src/release/release-publication.ts +213 -0
  408. package/src/release/release-publish-command.ts +163 -0
  409. package/src/release/release-qualification.ts +397 -0
  410. package/src/release/release-staging.ts +87 -0
  411. package/src/release/release-steps.ts +173 -0
  412. package/src/release/retained-release-build.ts +217 -0
  413. package/src/shell/app-shell.tsx +285 -0
  414. package/src/shell/app-utilities.tsx +437 -0
  415. package/src/shell/application-menu-commands.ts +6 -0
  416. package/src/shell/application-menu.ts +250 -0
  417. package/src/shell/help-shortcuts.ts +24 -0
  418. package/src/shell/settings-sections.ts +74 -0
  419. package/src/shell/shortcut-platform.ts +35 -0
  420. package/src/updates/channel-update-manager.ts +127 -0
  421. package/src/updates/desktop-updater.ts +440 -0
  422. package/src/updates/release-feed.ts +187 -0
  423. package/src/updates/release-location.ts +101 -0
  424. package/src/updates/release-version.ts +57 -0
  425. package/src/updates/signed-release.ts +311 -0
  426. package/src/updates/stable-file.ts +32 -0
  427. package/src/updates/update-adapter.ts +129 -0
  428. package/src/updates/update-arm.ts +107 -0
  429. package/src/updates/update-channel-store.ts +86 -0
  430. package/src/updates/update-discovery.ts +113 -0
  431. package/src/updates/update-download.ts +82 -0
  432. package/src/updates/update-exclusive-rename.ts +58 -0
  433. package/src/updates/update-extraction.ts +261 -0
  434. package/src/updates/update-handoff-plan.ts +75 -0
  435. package/src/updates/update-helper.ts +87 -0
  436. package/src/updates/update-launch.ts +33 -0
  437. package/src/updates/update-manager.ts +130 -0
  438. package/src/updates/update-process-fence.ts +125 -0
  439. package/src/updates/update-resume.ts +34 -0
  440. package/src/updates/update-shutdown.ts +37 -0
  441. package/src/updates/update-state.ts +34 -0
  442. package/src/updates/update-swap-stage.ts +75 -0
  443. package/src/updates/update-swap.ts +30 -0
  444. package/src/views/app-about.tsx +44 -0
  445. package/src/views/app-appearance.tsx +32 -0
  446. package/src/views/app-help.tsx +43 -0
  447. package/src/views/app-settings.tsx +88 -0
  448. package/src/views/appearance-surface.tsx +427 -0
  449. package/src/views/update-surface.tsx +85 -0
  450. package/templates/application/.gitattributes +1 -0
  451. package/templates/application/.github/workflows/release-assets.yml +29 -0
  452. package/templates/application/.github/workflows/release-finalize.yml +29 -0
  453. package/templates/application/.github/workflows/release-please.yml +19 -0
  454. package/templates/application/.github/workflows/release.yml +29 -0
  455. package/templates/application/.github/workflows/validation.yml +28 -0
  456. package/templates/application/.oxfmtrc.json +6 -0
  457. package/templates/application/.oxlintrc.json +48 -0
  458. package/templates/application/.release-please-manifest.json +3 -0
  459. package/templates/application/README.md +47 -0
  460. package/templates/application/electrobun.config.ts +22 -0
  461. package/templates/application/release-please-config.json +12 -0
  462. package/templates/application/scripts/app-version.ts +9 -0
  463. package/templates/application/scripts/build-desktop.ts +34 -0
  464. package/templates/application/scripts/secure-build.ts +1 -0
  465. package/templates/application/scripts/stage-release.ts +21 -0
  466. package/templates/application/src/bun/index.ts +80 -0
  467. package/templates/application/src/electrobun.d.ts +27 -0
  468. package/templates/application/src/web/index.html +12 -0
  469. package/templates/application/src/web/main.tsx +97 -0
  470. package/templates/application/src/web/public/icon.svg +1 -0
  471. package/templates/application/src/web/style.css +3 -0
  472. package/templates/application/tests/app-config.test.ts +9 -0
  473. package/templates/application/tsconfig.json +15 -0
  474. package/templates/application/vite.config.ts +10 -0
@@ -0,0 +1,923 @@
1
+ Electrobun 2.0.5 (MIT), commit d06abc9edf0b4e55116129cabbfe17bf89e11791.
2
+
3
+ Create the installer's Desktop and Start Menu shortcuts through Windows Shell
4
+ Link COM in an isolated extractor helper process instead of an unbounded
5
+ PowerShell child. Each shortcut waits at most 30 seconds; on timeout only the
6
+ helper is terminated and the installation fails. COM and file-write failures
7
+ fail the installation. Neither shortcut is skipped. Ported from the Adea
8
+ Electrobun 2.0.1 patch onto the 2.0.5 extractor (Zig 0.17).
9
+
10
+ diff --git a/package/src/extractor/build.zig b/package/src/extractor/build.zig
11
+ index 9f1297e7e62ea12ed59cea8702987f48b2d8c6f3..b9c4aa9fc87a3ac38ed33930b050074f59611e83 100644
12
+ --- a/package/src/extractor/build.zig
13
+ +++ b/package/src/extractor/build.zig
14
+ @@ -70,7 +70,12 @@ pub fn build(b: *std.Build) void {
15
+ .file = b.path("windows_uninstall_prompt.c"),
16
+ .flags = &.{},
17
+ });
18
+ + exe.root_module.addCSourceFile(.{
19
+ + .file = b.path("windows_shortcut.c"),
20
+ + .flags = &.{"-Werror=incompatible-pointer-types"},
21
+ + });
22
+ exe.root_module.linkSystemLibrary("comctl32", .{});
23
+ + exe.root_module.linkSystemLibrary("ole32", .{});
24
+
25
+ // Installers are user-facing GUI executables. The console subsystem
26
+ // both flashes a debug terminal and can keep the parent terminal tied
27
+ @@ -149,7 +154,12 @@ pub fn build(b: *std.Build) void {
28
+ .file = b.path("windows_uninstall_prompt.c"),
29
+ .flags = &.{},
30
+ });
31
+ + unit_tests.root_module.addCSourceFile(.{
32
+ + .file = b.path("windows_shortcut.c"),
33
+ + .flags = &.{"-DELECTROBUN_WINDOWS_SHORTCUT_TESTING=1", "-Werror=incompatible-pointer-types"},
34
+ + });
35
+ unit_tests.root_module.linkSystemLibrary("comctl32", .{});
36
+ + unit_tests.root_module.linkSystemLibrary("ole32", .{});
37
+ }
38
+ const run_unit_tests = b.addRunArtifact(unit_tests);
39
+
40
+ diff --git a/package/src/extractor/main.zig b/package/src/extractor/main.zig
41
+ index ee657ec20f3542982feefa52634aedfe609e6191..de32449c09b70d0c3b6fc598eb48d29b22e1b8cf 100644
42
+ --- a/package/src/extractor/main.zig
43
+ +++ b/package/src/extractor/main.zig
44
+ @@ -91,6 +91,42 @@ const windows_uninstall_sync = if (builtin.os.tag == .windows) struct {
45
+ const movefile_delay_until_reboot: win.DWORD = 0x00000004;
46
+ } else struct {};
47
+
48
+ +const windows_shortcut_api = if (builtin.os.tag == .windows) struct {
49
+ + extern fn electrobun_create_windows_shortcut(
50
+ + shortcut_path: [*:0]const u8,
51
+ + target_path: [*:0]const u8,
52
+ + working_dir: [*:0]const u8,
53
+ + icon_path: [*:0]const u8,
54
+ + ) callconv(.c) c_int;
55
+ + extern fn electrobun_run_windows_shortcut_bounded(
56
+ + shortcut_path: [*:0]const u8,
57
+ + target_path: [*:0]const u8,
58
+ + working_dir: [*:0]const u8,
59
+ + icon_path: [*:0]const u8,
60
+ + timeout_milliseconds: u32,
61
+ + termination_confirmed: *c_int,
62
+ + ) callconv(.c) c_int;
63
+ + extern fn electrobun_verify_windows_shortcut(
64
+ + shortcut_path: [*:0]const u8,
65
+ + target_path: [*:0]const u8,
66
+ + working_dir: [*:0]const u8,
67
+ + icon_path: [*:0]const u8,
68
+ + ) callconv(.c) c_int;
69
+ + extern fn electrobun_test_shortcut_roundtrip_bounded(
70
+ + shortcut_path: [*:0]const u8, target_path: [*:0]const u8,
71
+ + working_dir: [*:0]const u8, icon_path: [*:0]const u8,
72
+ + timeout_milliseconds: u32, termination_confirmed: *c_int,
73
+ + ) callconv(.c) c_int;
74
+ + extern fn electrobun_test_shortcut_roundtrip_timeout(termination_confirmed: *c_int) callconv(.c) c_int;
75
+ + extern fn electrobun_test_hung_windows_shortcut_helper(
76
+ + timeout_milliseconds: u32,
77
+ + termination_confirmed: *c_int,
78
+ + ) callconv(.c) c_int;
79
+ + extern fn electrobun_test_shortcut_wait_failure_cleanup() callconv(.c) c_int;
80
+ +} else struct {};
81
+ +
82
+ +const WINDOWS_SHORTCUT_TIMEOUT_MILLISECONDS: u32 = 30_000;
83
+ +
84
+ const windows_uninstall_ui = if (builtin.os.tag == .windows) struct {
85
+ extern fn electrobun_show_windows_uninstall_prompt(app_name: [*:0]const u16) callconv(.c) c_int;
86
+ extern fn electrobun_preview_windows_uninstall_prompt(app_name: [*:0]const u16) callconv(.c) c_int;
87
+ @@ -2781,40 +2817,155 @@ fn createWindowsShortcutFile(
88
+ working_dir: []const u8,
89
+ icon_path: []const u8,
90
+ ) !void {
91
+ - const escaped_lnk = try powershellSingleQuoted(allocator, lnk_path);
92
+ - defer allocator.free(escaped_lnk);
93
+ - const escaped_target = try powershellSingleQuoted(allocator, target_path);
94
+ - defer allocator.free(escaped_target);
95
+ - const escaped_working = try powershellSingleQuoted(allocator, working_dir);
96
+ - defer allocator.free(escaped_working);
97
+ - const escaped_icon = try powershellSingleQuoted(allocator, icon_path);
98
+ - defer allocator.free(escaped_icon);
99
+ + const shortcut_path_z = try allocator.dupeSentinel(u8, lnk_path, 0);
100
+ + defer allocator.free(shortcut_path_z);
101
+ + const target_path_z = try allocator.dupeSentinel(u8, target_path, 0);
102
+ + defer allocator.free(target_path_z);
103
+ + const working_dir_z = try allocator.dupeSentinel(u8, working_dir, 0);
104
+ + defer allocator.free(working_dir_z);
105
+ + const icon_path_z = try allocator.dupeSentinel(u8, icon_path, 0);
106
+ + defer allocator.free(icon_path_z);
107
+ +
108
+ + var termination_confirmed: c_int = 1;
109
+ + const result = windows_shortcut_api.electrobun_run_windows_shortcut_bounded(
110
+ + shortcut_path_z,
111
+ + target_path_z,
112
+ + working_dir_z,
113
+ + icon_path_z,
114
+ + WINDOWS_SHORTCUT_TIMEOUT_MILLISECONDS,
115
+ + &termination_confirmed,
116
+ + );
117
+ + if (result != 0) {
118
+ + if (termination_confirmed == 0) {
119
+ + std.debug.print("Windows shortcut helper termination could not be confirmed\n", .{});
120
+ + }
121
+ + std.debug.print(
122
+ + "Could not create Windows shortcut (HRESULT 0x{x:0>8}): {s}\n",
123
+ + .{ @as(u32, @bitCast(result)), lnk_path },
124
+ + );
125
+ + return error.WindowsShortcutFailed;
126
+ + }
127
+ + std.debug.print("Created Windows shortcut: {s}\n", .{lnk_path});
128
+ +}
129
+
130
+ - const ps_content = try std.fmt.allocPrint(allocator,
131
+ - \\$WshShell = New-Object -ComObject WScript.Shell
132
+ - \\$Shortcut = $WshShell.CreateShortcut('{s}')
133
+ - \\$Shortcut.TargetPath = '{s}'
134
+ - \\$Shortcut.WorkingDirectory = '{s}'
135
+ - \\$Shortcut.IconLocation = '{s}'
136
+ - \\$Shortcut.WindowStyle = 1
137
+ - \\$Shortcut.Save()
138
+ - \\
139
+ - , .{ escaped_lnk, escaped_target, escaped_working, escaped_icon });
140
+ - defer allocator.free(ps_content);
141
+ - const powershell_path = try getWindowsPowerShellPath(allocator);
142
+ - defer allocator.free(powershell_path);
143
+ +fn runWindowsShortcutHelper(allocator: std.mem.Allocator, init: std.process.Init) !bool {
144
+ + if (builtin.os.tag != .windows) return false;
145
+ +
146
+ + var args = try std.process.Args.Iterator.initAllocator(init.minimal.args, allocator);
147
+ + defer args.deinit();
148
+ + _ = args.next() orelse return error.InvalidArguments;
149
+ + const mode = args.next() orelse return false;
150
+ + if (!std.mem.eql(u8, mode, "--electrobun-create-shortcut")) return false;
151
+ +
152
+ + const shortcut_path = args.next() orelse return error.InvalidArguments;
153
+ + const target_path = args.next() orelse return error.InvalidArguments;
154
+ + const working_dir = args.next() orelse return error.InvalidArguments;
155
+ + const icon_path = args.next() orelse return error.InvalidArguments;
156
+ + if (args.next() != null) return error.InvalidArguments;
157
+ +
158
+ + const shortcut_path_z = try allocator.dupeSentinel(u8, shortcut_path, 0);
159
+ + defer allocator.free(shortcut_path_z);
160
+ + const target_path_z = try allocator.dupeSentinel(u8, target_path, 0);
161
+ + defer allocator.free(target_path_z);
162
+ + const working_dir_z = try allocator.dupeSentinel(u8, working_dir, 0);
163
+ + defer allocator.free(working_dir_z);
164
+ + const icon_path_z = try allocator.dupeSentinel(u8, icon_path, 0);
165
+ + defer allocator.free(icon_path_z);
166
+ +
167
+ + const result = windows_shortcut_api.electrobun_create_windows_shortcut(
168
+ + shortcut_path_z,
169
+ + target_path_z,
170
+ + working_dir_z,
171
+ + icon_path_z,
172
+ + );
173
+ + if (result != 0) {
174
+ + std.debug.print(
175
+ + "Could not create Windows shortcut in helper (HRESULT 0x{x:0>8})\n",
176
+ + .{@as(u32, @bitCast(result))},
177
+ + );
178
+ + return error.WindowsShortcutFailed;
179
+ + }
180
+ + return true;
181
+ +}
182
+
183
+ - const ps_args = [_][]const u8{
184
+ - powershell_path,
185
+ - "-NoProfile",
186
+ - "-NonInteractive",
187
+ - "-WindowStyle",
188
+ - "Hidden",
189
+ - "-Command",
190
+ - ps_content,
191
+ - };
192
+ - try runWindowsCommandChecked(&ps_args);
193
+ - std.debug.print("Created Windows shortcut: {s}\n", .{lnk_path});
194
+ +fn createWindowsShortcutForTest(
195
+ + allocator: std.mem.Allocator,
196
+ + shortcut_path: []const u8,
197
+ + target_path: []const u8,
198
+ + working_dir: []const u8,
199
+ + icon_path: []const u8,
200
+ +) !void {
201
+ + const shortcut_path_z = try allocator.dupeSentinel(u8, shortcut_path, 0);
202
+ + defer allocator.free(shortcut_path_z);
203
+ + const target_path_z = try allocator.dupeSentinel(u8, target_path, 0);
204
+ + defer allocator.free(target_path_z);
205
+ + const working_dir_z = try allocator.dupeSentinel(u8, working_dir, 0);
206
+ + defer allocator.free(working_dir_z);
207
+ + const icon_path_z = try allocator.dupeSentinel(u8, icon_path, 0);
208
+ + defer allocator.free(icon_path_z);
209
+ + var termination_confirmed: c_int = 0;
210
+ + const result = windows_shortcut_api.electrobun_test_shortcut_roundtrip_bounded(
211
+ + shortcut_path_z, target_path_z, working_dir_z, icon_path_z, 10_000, &termination_confirmed,
212
+ + );
213
+ + try std.testing.expectEqual(@as(c_int, 1), termination_confirmed);
214
+ + try std.testing.expectEqual(@as(c_int, 0), result);
215
+ +}
216
+ +
217
+ +test "Windows shortcut creation writes both shell-link locations with the requested target" {
218
+ + if (builtin.os.tag != .windows) return error.SkipZigTest;
219
+ +
220
+ + var tmp = std.testing.tmpDir(.{});
221
+ + defer tmp.cleanup();
222
+ + try tmp.dir.createDirPath(std.testing.io, "app/bin");
223
+ + try tmp.dir.createDirPath(std.testing.io, "Desktop");
224
+ + try tmp.dir.createDirPath(std.testing.io, "Start Menu/Programs");
225
+ + try tmp.dir.writeFile(std.testing.io, .{
226
+ + .sub_path = "app/bin/launcher.exe",
227
+ + .data = "disposable launcher fixture",
228
+ + });
229
+ +
230
+ + const root = try tmp.dir.realPathFileAlloc(std.testing.io, ".", std.testing.allocator);
231
+ + defer std.testing.allocator.free(root);
232
+ + const target_path = try std.fs.path.join(std.testing.allocator, &.{ root, "app", "bin", "launcher.exe" });
233
+ + defer std.testing.allocator.free(target_path);
234
+ + const working_dir = try std.fs.path.join(std.testing.allocator, &.{ root, "app", "bin" });
235
+ + defer std.testing.allocator.free(working_dir);
236
+ + const desktop_path = try std.fs.path.join(std.testing.allocator, &.{ root, "Desktop", "Example 🌱.lnk" });
237
+ + defer std.testing.allocator.free(desktop_path);
238
+ + const start_menu_path = try std.fs.path.join(std.testing.allocator, &.{ root, "Start Menu", "Programs", "Example 🌱.lnk" });
239
+ + defer std.testing.allocator.free(start_menu_path);
240
+ +
241
+ + try createWindowsShortcutForTest(std.testing.allocator, desktop_path, target_path, working_dir, target_path);
242
+ + try createWindowsShortcutForTest(std.testing.allocator, start_menu_path, target_path, working_dir, target_path);
243
+ +}
244
+ +
245
+ +test "Windows round-trip test helper timeout terminates the owned helper" {
246
+ + if (builtin.os.tag != .windows) return error.SkipZigTest;
247
+ + var termination_confirmed: c_int = 0;
248
+ + const result = windows_shortcut_api.electrobun_test_shortcut_roundtrip_timeout(&termination_confirmed);
249
+ + try std.testing.expectEqual(@as(c_int, @bitCast(@as(u32, 0x800705b4))), result);
250
+ + try std.testing.expectEqual(@as(c_int, 1), termination_confirmed);
251
+ +}
252
+ +
253
+ +test "Windows hung shortcut helper is terminated and confirmed within the timeout" {
254
+ + if (builtin.os.tag != .windows) return error.SkipZigTest;
255
+ +
256
+ + var termination_confirmed: c_int = 0;
257
+ + const result = windows_shortcut_api.electrobun_test_hung_windows_shortcut_helper(
258
+ + 100,
259
+ + &termination_confirmed,
260
+ + );
261
+ + try std.testing.expectEqual(@as(c_int, 0), result);
262
+ + try std.testing.expectEqual(@as(c_int, 1), termination_confirmed);
263
+ +}
264
+ +
265
+ +test "Windows shortcut helper handles wait failure and unconfirmed termination" {
266
+ + if (builtin.os.tag != .windows) return error.SkipZigTest;
267
+ +
268
+ + try std.testing.expectEqual(
269
+ + @as(c_int, 0),
270
+ + windows_shortcut_api.electrobun_test_shortcut_wait_failure_cleanup(),
271
+ + );
272
+ }
273
+
274
+ fn deleteWindowsShortcutIfTargets(
275
+ @@ -7969,6 +8120,10 @@ pub fn main(init: std.process.Init) !void {
276
+
277
+ const allocator = init.gpa;
278
+
279
+ + // The installer runs this isolated mode as a bounded helper because
280
+ + // Shell Link COM calls can stall on some Windows hosts.
281
+ + if (try runWindowsShortcutHelper(allocator, init)) return;
282
+ +
283
+ // The update helper is always a unique temporary copy of the installed
284
+ // manager. Dispatch it before preview or normal uninstall-manager modes.
285
+ {
286
+ diff --git a/package/src/extractor/windows_shortcut.c b/package/src/extractor/windows_shortcut.c
287
+ new file mode 100644
288
+ index 0000000000000000000000000000000000000000..7bf5e5de1b80cb2ceffb62826eee54d03e71f39d
289
+ --- /dev/null
290
+ +++ b/package/src/extractor/windows_shortcut.c
291
+ @@ -0,0 +1,586 @@
292
+ +#define WIN32_LEAN_AND_MEAN
293
+ +#define COBJMACROS
294
+ +#define CINTERFACE
295
+ +#include <windows.h>
296
+ +#include <objbase.h>
297
+ +#include <shobjidl.h>
298
+ +
299
+ +#include <stdint.h>
300
+ +#include <stdlib.h>
301
+ +#include <string.h>
302
+ +#include <wchar.h>
303
+ +
304
+ +static const CLSID CLSID_ElectrobunShellLink = {
305
+ + 0x00021401, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
306
+ +static const IID IID_ElectrobunShellLinkW = {
307
+ + 0x000214F9, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
308
+ +static const IID IID_ElectrobunPersistFile = {
309
+ + 0x0000010B, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
310
+ +
311
+ +static HRESULT utf8_to_wide(const char *value, wchar_t **result) {
312
+ + int length;
313
+ + wchar_t *wide;
314
+ +
315
+ + if (value == NULL || result == NULL) return E_INVALIDARG;
316
+ + *result = NULL;
317
+ + length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, value, -1, NULL, 0);
318
+ + if (length <= 0) return HRESULT_FROM_WIN32(GetLastError());
319
+ + if ((size_t)length > SIZE_MAX / sizeof(*wide)) return E_OUTOFMEMORY;
320
+ + wide = (wchar_t *)calloc((size_t)length, sizeof(*wide));
321
+ + if (wide == NULL) return E_OUTOFMEMORY;
322
+ + if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, value, -1, wide, length) != length) {
323
+ + HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
324
+ + free(wide);
325
+ + return hr;
326
+ + }
327
+ + *result = wide;
328
+ + return S_OK;
329
+ +}
330
+ +
331
+ +HRESULT electrobun_create_windows_shortcut(
332
+ + const char *shortcut_path_utf8,
333
+ + const char *target_path_utf8,
334
+ + const char *working_dir_utf8,
335
+ + const char *icon_path_utf8) {
336
+ + HRESULT hr;
337
+ + int initialized = 0;
338
+ + wchar_t *shortcut_path = NULL;
339
+ + wchar_t *target_path = NULL;
340
+ + wchar_t *working_dir = NULL;
341
+ + wchar_t *icon_path = NULL;
342
+ + IShellLinkW *link = NULL;
343
+ + IPersistFile *persist = NULL;
344
+ +
345
+ + hr = utf8_to_wide(shortcut_path_utf8, &shortcut_path);
346
+ + if (FAILED(hr)) goto cleanup;
347
+ + hr = utf8_to_wide(target_path_utf8, &target_path);
348
+ + if (FAILED(hr)) goto cleanup;
349
+ + hr = utf8_to_wide(working_dir_utf8, &working_dir);
350
+ + if (FAILED(hr)) goto cleanup;
351
+ + hr = utf8_to_wide(icon_path_utf8, &icon_path);
352
+ + if (FAILED(hr)) goto cleanup;
353
+ +
354
+ + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
355
+ + if (hr == RPC_E_CHANGED_MODE) {
356
+ + // COM is already initialized on this thread; use its existing apartment.
357
+ + hr = S_OK;
358
+ + } else if (FAILED(hr)) {
359
+ + goto cleanup;
360
+ + } else {
361
+ + initialized = 1;
362
+ + }
363
+ +
364
+ + hr = CoCreateInstance(
365
+ + &CLSID_ElectrobunShellLink,
366
+ + NULL,
367
+ + CLSCTX_INPROC_SERVER,
368
+ + &IID_ElectrobunShellLinkW,
369
+ + (void **)&link);
370
+ + if (FAILED(hr)) goto cleanup;
371
+ + hr = IShellLinkW_SetPath(link, target_path);
372
+ + if (FAILED(hr)) goto cleanup;
373
+ + hr = IShellLinkW_SetWorkingDirectory(link, working_dir);
374
+ + if (FAILED(hr)) goto cleanup;
375
+ + hr = IShellLinkW_SetIconLocation(link, icon_path, 0);
376
+ + if (FAILED(hr)) goto cleanup;
377
+ + hr = IShellLinkW_SetShowCmd(link, SW_SHOWNORMAL);
378
+ + if (FAILED(hr)) goto cleanup;
379
+ + hr = IShellLinkW_QueryInterface(link, &IID_ElectrobunPersistFile, (void **)&persist);
380
+ + if (FAILED(hr)) goto cleanup;
381
+ + hr = IPersistFile_Save(persist, shortcut_path, TRUE);
382
+ +
383
+ +cleanup:
384
+ + if (persist != NULL) IPersistFile_Release(persist);
385
+ + if (link != NULL) IShellLinkW_Release(link);
386
+ + if (initialized) CoUninitialize();
387
+ + free(icon_path);
388
+ + free(working_dir);
389
+ + free(target_path);
390
+ + free(shortcut_path);
391
+ + return hr;
392
+ +}
393
+ +
394
+ +static int append_command_character(
395
+ + wchar_t *buffer,
396
+ + size_t capacity,
397
+ + size_t *position,
398
+ + wchar_t character) {
399
+ + if (*position >= capacity) return 0;
400
+ + buffer[(*position)++] = character;
401
+ + return 1;
402
+ +}
403
+ +
404
+ +static int append_command_slashes(
405
+ + wchar_t *buffer,
406
+ + size_t capacity,
407
+ + size_t *position,
408
+ + size_t count) {
409
+ + while (count-- > 0) {
410
+ + if (!append_command_character(buffer, capacity, position, L'\\')) return 0;
411
+ + }
412
+ + return 1;
413
+ +}
414
+ +
415
+ +static int append_quoted_argument(
416
+ + wchar_t *buffer,
417
+ + size_t capacity,
418
+ + size_t *position,
419
+ + const wchar_t *argument) {
420
+ + const wchar_t *cursor = argument;
421
+ + if (!append_command_character(buffer, capacity, position, L'"')) return 0;
422
+ +
423
+ + while (*cursor != L'\0') {
424
+ + size_t slash_count = 0;
425
+ + while (cursor[slash_count] == L'\\') slash_count++;
426
+ + cursor += slash_count;
427
+ + if (*cursor == L'"') {
428
+ + if (slash_count > (SIZE_MAX - 1) / 2 ||
429
+ + !append_command_slashes(buffer, capacity, position, slash_count * 2 + 1) ||
430
+ + !append_command_character(buffer, capacity, position, L'"'))
431
+ + {
432
+ + return 0;
433
+ + }
434
+ + cursor++;
435
+ + } else if (*cursor == L'\0') {
436
+ + if (slash_count > SIZE_MAX / 2 ||
437
+ + !append_command_slashes(buffer, capacity, position, slash_count * 2))
438
+ + {
439
+ + return 0;
440
+ + }
441
+ + } else {
442
+ + if (!append_command_slashes(buffer, capacity, position, slash_count) ||
443
+ + !append_command_character(buffer, capacity, position, *cursor))
444
+ + {
445
+ + return 0;
446
+ + }
447
+ + cursor++;
448
+ + }
449
+ + }
450
+ +
451
+ + return append_command_character(buffer, capacity, position, L'"');
452
+ +}
453
+ +
454
+ +typedef DWORD (WINAPI *electrobun_shortcut_wait_fn)(HANDLE, DWORD);
455
+ +typedef BOOL (WINAPI *electrobun_shortcut_terminate_fn)(HANDLE, UINT);
456
+ +
457
+ +static int terminate_shortcut_helper_and_confirm(
458
+ + HANDLE process,
459
+ + UINT exit_code,
460
+ + electrobun_shortcut_wait_fn wait_fn,
461
+ + electrobun_shortcut_terminate_fn terminate_fn,
462
+ + DWORD *error_code) {
463
+ + DWORD wait_result;
464
+ +
465
+ + *error_code = ERROR_SUCCESS;
466
+ + if (!terminate_fn(process, exit_code)) *error_code = GetLastError();
467
+ + wait_result = wait_fn(process, 5000);
468
+ + if (wait_result == WAIT_OBJECT_0) return 1;
469
+ + if (*error_code == ERROR_SUCCESS && wait_result == WAIT_FAILED) {
470
+ + *error_code = GetLastError();
471
+ + }
472
+ + if (*error_code == ERROR_SUCCESS) *error_code = ERROR_PROCESS_ABORTED;
473
+ + return 0;
474
+ +}
475
+ +
476
+ +static HRESULT wait_for_shortcut_helper_with_api(
477
+ + HANDLE process,
478
+ + DWORD timeout_milliseconds,
479
+ + int *termination_confirmed,
480
+ + electrobun_shortcut_wait_fn wait_fn,
481
+ + electrobun_shortcut_terminate_fn terminate_fn) {
482
+ + DWORD wait_result;
483
+ +
484
+ + if (termination_confirmed == NULL || wait_fn == NULL || terminate_fn == NULL) return E_INVALIDARG;
485
+ + *termination_confirmed = 1;
486
+ + wait_result = wait_fn(process, timeout_milliseconds);
487
+ + if (wait_result == WAIT_TIMEOUT) {
488
+ + DWORD error_code;
489
+ + *termination_confirmed = 0;
490
+ + if (!terminate_shortcut_helper_and_confirm(
491
+ + process, ERROR_TIMEOUT, wait_fn, terminate_fn, &error_code)) {
492
+ + return HRESULT_FROM_WIN32(error_code);
493
+ + }
494
+ + *termination_confirmed = 1;
495
+ + return HRESULT_FROM_WIN32(ERROR_TIMEOUT);
496
+ + }
497
+ + if (wait_result != WAIT_OBJECT_0) {
498
+ + DWORD wait_error = wait_result == WAIT_FAILED ? GetLastError() : ERROR_PROCESS_ABORTED;
499
+ + DWORD cleanup_error;
500
+ + *termination_confirmed = 0;
501
+ + if (!terminate_shortcut_helper_and_confirm(
502
+ + process, ERROR_PROCESS_ABORTED, wait_fn, terminate_fn, &cleanup_error)) {
503
+ + return HRESULT_FROM_WIN32(cleanup_error);
504
+ + }
505
+ + *termination_confirmed = 1;
506
+ + return HRESULT_FROM_WIN32(wait_error ? wait_error : ERROR_PROCESS_ABORTED);
507
+ + }
508
+ + return S_OK;
509
+ +}
510
+ +
511
+ +static HRESULT wait_for_shortcut_helper(
512
+ + HANDLE process,
513
+ + DWORD timeout_milliseconds,
514
+ + int *termination_confirmed) {
515
+ + return wait_for_shortcut_helper_with_api(
516
+ + process, timeout_milliseconds, termination_confirmed, WaitForSingleObject, TerminateProcess);
517
+ +}
518
+ +
519
+ +static HRESULT run_windows_shortcut_bounded_with_helper(
520
+ + const wchar_t *helper_override,
521
+ + const wchar_t *mode_override,
522
+ + const char *shortcut_path_utf8,
523
+ + const char *target_path_utf8,
524
+ + const char *working_dir_utf8,
525
+ + const char *icon_path_utf8,
526
+ + DWORD timeout_milliseconds,
527
+ + int *termination_confirmed) {
528
+ + const DWORD shortcut_timeout_milliseconds = 30000;
529
+ + const wchar_t *shortcut_mode = mode_override ? mode_override : L"--electrobun-create-shortcut";
530
+ + HRESULT hr = E_FAIL;
531
+ + wchar_t module_path[32768];
532
+ + wchar_t *shortcut_path = NULL;
533
+ + wchar_t *target_path = NULL;
534
+ + wchar_t *working_dir = NULL;
535
+ + wchar_t *icon_path = NULL;
536
+ + wchar_t *command_line = NULL;
537
+ + size_t command_capacity = 1;
538
+ + size_t command_position = 0;
539
+ + DWORD module_length;
540
+ + DWORD child_exit_code = 1;
541
+ + STARTUPINFOW startup_info;
542
+ + PROCESS_INFORMATION process_info;
543
+ + const wchar_t *arguments[6];
544
+ + size_t i;
545
+ +
546
+ + if (termination_confirmed == NULL) return E_INVALIDARG;
547
+ + *termination_confirmed = 1;
548
+ + if (timeout_milliseconds == 0 || timeout_milliseconds > shortcut_timeout_milliseconds) {
549
+ + timeout_milliseconds = shortcut_timeout_milliseconds;
550
+ + }
551
+ +
552
+ + if (helper_override) {
553
+ + size_t length = wcslen(helper_override);
554
+ + if (length == 0 || length >= sizeof(module_path) / sizeof(module_path[0])) return E_INVALIDARG;
555
+ + memcpy(module_path, helper_override, (length + 1) * sizeof(wchar_t));
556
+ + } else {
557
+ + module_length = GetModuleFileNameW(NULL, module_path, (DWORD)(sizeof(module_path) / sizeof(module_path[0])));
558
+ + if (module_length == 0) return HRESULT_FROM_WIN32(GetLastError());
559
+ + if (module_length >= sizeof(module_path) / sizeof(module_path[0])) return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
560
+ + }
561
+ +
562
+ + hr = utf8_to_wide(shortcut_path_utf8, &shortcut_path);
563
+ + if (FAILED(hr)) goto cleanup;
564
+ + hr = utf8_to_wide(target_path_utf8, &target_path);
565
+ + if (FAILED(hr)) goto cleanup;
566
+ + hr = utf8_to_wide(working_dir_utf8, &working_dir);
567
+ + if (FAILED(hr)) goto cleanup;
568
+ + hr = utf8_to_wide(icon_path_utf8, &icon_path);
569
+ + if (FAILED(hr)) goto cleanup;
570
+ +
571
+ + arguments[0] = module_path;
572
+ + arguments[1] = shortcut_mode;
573
+ + arguments[2] = shortcut_path;
574
+ + arguments[3] = target_path;
575
+ + arguments[4] = working_dir;
576
+ + arguments[5] = icon_path;
577
+ + for (i = 0; i < sizeof(arguments) / sizeof(arguments[0]); i++) {
578
+ + size_t length = wcslen(arguments[i]);
579
+ + if (length > (SIZE_MAX - 3) / 2 || command_capacity > SIZE_MAX - (length * 2 + 3)) {
580
+ + hr = E_OUTOFMEMORY;
581
+ + goto cleanup;
582
+ + }
583
+ + command_capacity += length * 2 + 3;
584
+ + }
585
+ + if (command_capacity > 32767) {
586
+ + hr = HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE);
587
+ + goto cleanup;
588
+ + }
589
+ + command_line = (wchar_t *)calloc(command_capacity, sizeof(*command_line));
590
+ + if (command_line == NULL) {
591
+ + hr = E_OUTOFMEMORY;
592
+ + goto cleanup;
593
+ + }
594
+ + for (i = 0; i < sizeof(arguments) / sizeof(arguments[0]); i++) {
595
+ + if (i > 0 && !append_command_character(command_line, command_capacity, &command_position, L' ')) {
596
+ + hr = E_OUTOFMEMORY;
597
+ + goto cleanup;
598
+ + }
599
+ + if (!append_quoted_argument(command_line, command_capacity, &command_position, arguments[i])) {
600
+ + hr = E_OUTOFMEMORY;
601
+ + goto cleanup;
602
+ + }
603
+ + }
604
+ + if (!append_command_character(command_line, command_capacity, &command_position, L'\0')) {
605
+ + hr = E_OUTOFMEMORY;
606
+ + goto cleanup;
607
+ + }
608
+ +
609
+ + memset(&startup_info, 0, sizeof(startup_info));
610
+ + memset(&process_info, 0, sizeof(process_info));
611
+ + startup_info.cb = sizeof(startup_info);
612
+ + if (!CreateProcessW(
613
+ + module_path,
614
+ + command_line,
615
+ + NULL,
616
+ + NULL,
617
+ + FALSE,
618
+ + CREATE_NO_WINDOW,
619
+ + NULL,
620
+ + NULL,
621
+ + &startup_info,
622
+ + &process_info))
623
+ + {
624
+ + hr = HRESULT_FROM_WIN32(GetLastError());
625
+ + goto cleanup;
626
+ + }
627
+ +
628
+ + hr = wait_for_shortcut_helper(
629
+ + process_info.hProcess,
630
+ + timeout_milliseconds,
631
+ + termination_confirmed);
632
+ + if (hr == HRESULT_FROM_WIN32(ERROR_TIMEOUT) || FAILED(hr)) goto close_process;
633
+ + if (!GetExitCodeProcess(process_info.hProcess, &child_exit_code)) {
634
+ + hr = HRESULT_FROM_WIN32(GetLastError());
635
+ + goto close_process;
636
+ + }
637
+ + hr = child_exit_code == 0 ? S_OK : HRESULT_FROM_WIN32(ERROR_INSTALL_FAILURE);
638
+ +
639
+ +close_process:
640
+ + CloseHandle(process_info.hThread);
641
+ + CloseHandle(process_info.hProcess);
642
+ +
643
+ +cleanup:
644
+ + free(command_line);
645
+ + free(icon_path);
646
+ + free(working_dir);
647
+ + free(target_path);
648
+ + free(shortcut_path);
649
+ + return hr;
650
+ +}
651
+ +
652
+ +HRESULT electrobun_run_windows_shortcut_bounded(
653
+ + const char *shortcut, const char *target, const char *working, const char *icon,
654
+ + DWORD timeout, int *confirmed) {
655
+ + return run_windows_shortcut_bounded_with_helper(NULL, NULL, shortcut, target, working, icon, timeout, confirmed);
656
+ +}
657
+ +
658
+ +#ifdef ELECTROBUN_WINDOWS_SHORTCUT_TESTING
659
+ +HRESULT electrobun_test_shortcut_roundtrip_bounded(
660
+ + const char *shortcut, const char *target, const char *working, const char *icon,
661
+ + DWORD timeout, int *confirmed) {
662
+ + wchar_t helper[32768];
663
+ + DWORD length = GetEnvironmentVariableW(L"ELECTROBUN_WINDOWS_SHORTCUT_TEST_HELPER", helper, 32768);
664
+ + if (length == 0 || length >= 32768) return E_INVALIDARG;
665
+ + return run_windows_shortcut_bounded_with_helper(helper, L"--electrobun-test-roundtrip",
666
+ + shortcut, target, working, icon, timeout, confirmed);
667
+ +}
668
+ +
669
+ +HRESULT electrobun_test_shortcut_roundtrip_timeout(int *confirmed) {
670
+ + wchar_t helper[32768];
671
+ + DWORD length = GetEnvironmentVariableW(L"ELECTROBUN_WINDOWS_SHORTCUT_TEST_HELPER", helper, 32768);
672
+ + if (length == 0 || length >= 32768) return E_INVALIDARG;
673
+ + return run_windows_shortcut_bounded_with_helper(helper, L"--electrobun-test-hang",
674
+ + "", "", "", "", 100, confirmed);
675
+ +}
676
+ +
677
+ +HRESULT electrobun_test_hung_windows_shortcut_helper(
678
+ + DWORD timeout_milliseconds,
679
+ + int *termination_confirmed) {
680
+ + const wchar_t suffix[] = L"\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
681
+ + wchar_t powershell_path[32768];
682
+ + wchar_t command_line[] =
683
+ + L"powershell.exe -NoProfile -NonInteractive -Command Start-Sleep -Seconds 60";
684
+ + DWORD windows_length;
685
+ + size_t suffix_length = sizeof(suffix) / sizeof(suffix[0]) - 1;
686
+ + STARTUPINFOW startup_info;
687
+ + PROCESS_INFORMATION process_info;
688
+ + HRESULT hr;
689
+ +
690
+ + if (termination_confirmed == NULL) return E_INVALIDARG;
691
+ + *termination_confirmed = 0;
692
+ + windows_length = GetWindowsDirectoryW(
693
+ + powershell_path,
694
+ + (UINT)(sizeof(powershell_path) / sizeof(powershell_path[0])));
695
+ + if (windows_length == 0 || windows_length >= sizeof(powershell_path) / sizeof(powershell_path[0])) {
696
+ + return HRESULT_FROM_WIN32(GetLastError());
697
+ + }
698
+ + if ((size_t)windows_length + suffix_length + 1 >= sizeof(powershell_path) / sizeof(powershell_path[0])) {
699
+ + return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
700
+ + }
701
+ + memcpy(
702
+ + powershell_path + windows_length,
703
+ + suffix,
704
+ + (suffix_length + 1) * sizeof(powershell_path[0]));
705
+ +
706
+ + memset(&startup_info, 0, sizeof(startup_info));
707
+ + memset(&process_info, 0, sizeof(process_info));
708
+ + startup_info.cb = sizeof(startup_info);
709
+ + if (!CreateProcessW(
710
+ + powershell_path,
711
+ + command_line,
712
+ + NULL,
713
+ + NULL,
714
+ + FALSE,
715
+ + CREATE_NO_WINDOW,
716
+ + NULL,
717
+ + NULL,
718
+ + &startup_info,
719
+ + &process_info))
720
+ + {
721
+ + return HRESULT_FROM_WIN32(GetLastError());
722
+ + }
723
+ +
724
+ + hr = wait_for_shortcut_helper(
725
+ + process_info.hProcess,
726
+ + timeout_milliseconds,
727
+ + termination_confirmed);
728
+ + if (hr == HRESULT_FROM_WIN32(ERROR_TIMEOUT) && *termination_confirmed) {
729
+ + hr = S_OK;
730
+ + } else if (hr == S_OK) {
731
+ + hr = E_UNEXPECTED;
732
+ + }
733
+ + CloseHandle(process_info.hThread);
734
+ + CloseHandle(process_info.hProcess);
735
+ + return hr;
736
+ +}
737
+ +
738
+ +#ifdef ELECTROBUN_WINDOWS_SHORTCUT_TESTING
739
+ +typedef struct electrobun_shortcut_wait_test_state {
740
+ + DWORD wait_calls;
741
+ + DWORD terminate_calls;
742
+ + DWORD requested_timeout;
743
+ + DWORD confirmation_wait;
744
+ + BOOL terminate_succeeds;
745
+ + DWORD terminate_error;
746
+ + UINT terminate_exit_code;
747
+ +} electrobun_shortcut_wait_test_state;
748
+ +
749
+ +static DWORD WINAPI electrobun_test_shortcut_wait(HANDLE process, DWORD timeout) {
750
+ + electrobun_shortcut_wait_test_state *state = (electrobun_shortcut_wait_test_state *)process;
751
+ + state->wait_calls++;
752
+ + if (state->wait_calls == 1) {
753
+ + state->requested_timeout = timeout;
754
+ + SetLastError(ERROR_INVALID_HANDLE);
755
+ + return WAIT_FAILED;
756
+ + }
757
+ + if (timeout != 5000) {
758
+ + SetLastError(ERROR_INVALID_PARAMETER);
759
+ + return WAIT_FAILED;
760
+ + }
761
+ + if (state->confirmation_wait == WAIT_FAILED) SetLastError(ERROR_INVALID_HANDLE);
762
+ + return state->confirmation_wait;
763
+ +}
764
+ +
765
+ +static BOOL WINAPI electrobun_test_shortcut_terminate(HANDLE process, UINT exit_code) {
766
+ + electrobun_shortcut_wait_test_state *state = (electrobun_shortcut_wait_test_state *)process;
767
+ + state->terminate_calls++;
768
+ + state->terminate_exit_code = exit_code;
769
+ + if (!state->terminate_succeeds) SetLastError(state->terminate_error);
770
+ + return state->terminate_succeeds;
771
+ +}
772
+ +
773
+ +HRESULT electrobun_test_shortcut_wait_failure_cleanup(void) {
774
+ + electrobun_shortcut_wait_test_state state;
775
+ + int termination_confirmed = 0;
776
+ + HRESULT result;
777
+ +
778
+ + memset(&state, 0, sizeof(state));
779
+ + state.confirmation_wait = WAIT_OBJECT_0;
780
+ + state.terminate_succeeds = TRUE;
781
+ + result = wait_for_shortcut_helper_with_api(
782
+ + (HANDLE)&state, 123, &termination_confirmed,
783
+ + electrobun_test_shortcut_wait, electrobun_test_shortcut_terminate);
784
+ + if (result != HRESULT_FROM_WIN32(ERROR_INVALID_HANDLE) || !termination_confirmed ||
785
+ + state.wait_calls != 2 || state.terminate_calls != 1 || state.requested_timeout != 123 ||
786
+ + state.terminate_exit_code != ERROR_PROCESS_ABORTED) return E_FAIL;
787
+ +
788
+ + memset(&state, 0, sizeof(state));
789
+ + state.confirmation_wait = WAIT_TIMEOUT;
790
+ + state.terminate_succeeds = FALSE;
791
+ + state.terminate_error = ERROR_ACCESS_DENIED;
792
+ + termination_confirmed = 1;
793
+ + result = wait_for_shortcut_helper_with_api(
794
+ + (HANDLE)&state, 123, &termination_confirmed,
795
+ + electrobun_test_shortcut_wait, electrobun_test_shortcut_terminate);
796
+ + if (result != HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) || termination_confirmed ||
797
+ + state.wait_calls != 2 || state.terminate_calls != 1 || state.requested_timeout != 123 ||
798
+ + state.terminate_exit_code != ERROR_PROCESS_ABORTED) return E_FAIL;
799
+ + return S_OK;
800
+ +}
801
+ +#endif
802
+ +
803
+ +static int equal_wide_case_insensitive(const wchar_t *left, const wchar_t *right) {
804
+ + return CompareStringOrdinal(left, -1, right, -1, TRUE) == CSTR_EQUAL;
805
+ +}
806
+ +
807
+ +HRESULT electrobun_verify_windows_shortcut(
808
+ + const char *shortcut_path_utf8,
809
+ + const char *target_path_utf8,
810
+ + const char *working_dir_utf8,
811
+ + const char *icon_path_utf8) {
812
+ + HRESULT hr;
813
+ + int initialized = 0;
814
+ + wchar_t *shortcut_path = NULL;
815
+ + wchar_t *target_path = NULL;
816
+ + wchar_t *working_dir = NULL;
817
+ + wchar_t *icon_path = NULL;
818
+ + wchar_t actual_target[MAX_PATH] = {0};
819
+ + wchar_t actual_working_dir[MAX_PATH] = {0};
820
+ + wchar_t actual_icon[MAX_PATH] = {0};
821
+ + int icon_index = -1;
822
+ + IShellLinkW *link = NULL;
823
+ + IPersistFile *persist = NULL;
824
+ +
825
+ + hr = utf8_to_wide(shortcut_path_utf8, &shortcut_path);
826
+ + if (FAILED(hr)) goto cleanup;
827
+ + hr = utf8_to_wide(target_path_utf8, &target_path);
828
+ + if (FAILED(hr)) goto cleanup;
829
+ + hr = utf8_to_wide(working_dir_utf8, &working_dir);
830
+ + if (FAILED(hr)) goto cleanup;
831
+ + hr = utf8_to_wide(icon_path_utf8, &icon_path);
832
+ + if (FAILED(hr)) goto cleanup;
833
+ +
834
+ + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
835
+ + if (hr == RPC_E_CHANGED_MODE) {
836
+ + // COM is already initialized on this thread; use its existing apartment.
837
+ + hr = S_OK;
838
+ + } else if (FAILED(hr)) {
839
+ + goto cleanup;
840
+ + } else {
841
+ + initialized = 1;
842
+ + }
843
+ +
844
+ + hr = CoCreateInstance(
845
+ + &CLSID_ElectrobunShellLink,
846
+ + NULL,
847
+ + CLSCTX_INPROC_SERVER,
848
+ + &IID_ElectrobunShellLinkW,
849
+ + (void **)&link);
850
+ + if (FAILED(hr)) goto cleanup;
851
+ + hr = IShellLinkW_QueryInterface(link, &IID_ElectrobunPersistFile, (void **)&persist);
852
+ + if (FAILED(hr)) goto cleanup;
853
+ + hr = IPersistFile_Load(persist, shortcut_path, STGM_READ);
854
+ + if (FAILED(hr)) goto cleanup;
855
+ + hr = IShellLinkW_GetPath(link, actual_target, MAX_PATH, NULL, SLGP_RAWPATH);
856
+ + if (FAILED(hr)) goto cleanup;
857
+ + hr = IShellLinkW_GetWorkingDirectory(link, actual_working_dir, MAX_PATH);
858
+ + if (FAILED(hr)) goto cleanup;
859
+ + hr = IShellLinkW_GetIconLocation(link, actual_icon, MAX_PATH, &icon_index);
860
+ + if (FAILED(hr)) goto cleanup;
861
+ + if (!equal_wide_case_insensitive(actual_target, target_path) ||
862
+ + !equal_wide_case_insensitive(actual_working_dir, working_dir) ||
863
+ + !equal_wide_case_insensitive(actual_icon, icon_path) || icon_index != 0) {
864
+ + hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
865
+ + }
866
+ +
867
+ +cleanup:
868
+ + if (persist != NULL) IPersistFile_Release(persist);
869
+ + if (link != NULL) IShellLinkW_Release(link);
870
+ + if (initialized) CoUninitialize();
871
+ + free(icon_path);
872
+ + free(working_dir);
873
+ + free(target_path);
874
+ + free(shortcut_path);
875
+ + return hr;
876
+ +}
877
+ +#endif
878
+ diff --git a/package/src/extractor/windows_shortcut_test_helper.c b/package/src/extractor/windows_shortcut_test_helper.c
879
+ new file mode 100644
880
+ index 0000000000000000000000000000000000000000..4fe304c7d748e16f8e5f37955075eba837185d2c
881
+ --- /dev/null
882
+ +++ b/package/src/extractor/windows_shortcut_test_helper.c
883
+ @@ -0,0 +1,40 @@
884
+ +#define WIN32_LEAN_AND_MEAN
885
+ +#include <windows.h>
886
+ +#include <stdlib.h>
887
+ +#include <wchar.h>
888
+ +
889
+ +HRESULT electrobun_create_windows_shortcut(const char *, const char *, const char *, const char *);
890
+ +HRESULT electrobun_verify_windows_shortcut(const char *, const char *, const char *, const char *);
891
+ +
892
+ +static char *to_utf8(const wchar_t *value) {
893
+ + int size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, value, -1, NULL, 0, NULL, NULL);
894
+ + if (size <= 0) return NULL;
895
+ + char *out = (char *)malloc((size_t)size);
896
+ + if (!out) return NULL;
897
+ + if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, value, -1, out, size, NULL, NULL) != size) {
898
+ + free(out);
899
+ + return NULL;
900
+ + }
901
+ + return out;
902
+ +}
903
+ +
904
+ +int wmain(int argc, wchar_t **argv) {
905
+ + char *args[4] = {NULL, NULL, NULL, NULL};
906
+ + int result = 1;
907
+ + if (argc != 6) return 1;
908
+ + if (wcscmp(argv[1], L"--electrobun-test-hang") == 0) {
909
+ + Sleep(60000);
910
+ + return 1;
911
+ + }
912
+ + if (wcscmp(argv[1], L"--electrobun-test-roundtrip") != 0) return 1;
913
+ + for (int i = 0; i < 4; i++) {
914
+ + args[i] = to_utf8(argv[i + 2]);
915
+ + if (!args[i]) goto cleanup;
916
+ + }
917
+ + if (FAILED(electrobun_create_windows_shortcut(args[0], args[1], args[2], args[3]))) goto cleanup;
918
+ + if (FAILED(electrobun_verify_windows_shortcut(args[0], args[1], args[2], args[3]))) goto cleanup;
919
+ + result = 0;
920
+ +cleanup:
921
+ + for (int i = 0; i < 4; i++) free(args[i]);
922
+ + return result;
923
+ +}