@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,103 @@
1
+ /*
2
+ * The Manage themes dialog's import flow, with the parsing and projection code
3
+ * behind a dynamic import. Selecting a file is what loads it, so opening
4
+ * Appearance never downloads the importer.
5
+ *
6
+ * A newer selection, a closed dialog and a disposed panel each supersede an
7
+ * import still in flight: the result of a superseded run is dropped before
8
+ * anything is stored, selected or reported.
9
+ */
10
+ import type { CustomThemeStored } from './custom-theme-library'
11
+
12
+ import type { CustomThemeImportResult } from './custom-theme-import'
13
+
14
+ export type ThemeFileImporterHost = Readonly<{
15
+ /**
16
+ * Loads the importer and returns the function that imports one file's text.
17
+ * It runs after every await so the library it merges into is read fresh.
18
+ */
19
+ load: () => Promise<(text: string) => CustomThemeImportResult>
20
+ onPending: (pending: boolean) => void
21
+ onStatus: (message: string) => void
22
+ onImported: (theme: CustomThemeStored) => void
23
+ }>
24
+
25
+ type ThemeFileImporter = Readonly<{
26
+ importFile: (file: Pick<File, 'text'>) => Promise<void>
27
+ /** Drops the run in flight, if any, and clears its pending status. */
28
+ cancel: () => void
29
+ }>
30
+
31
+ export const THEME_IMPORT_PENDING = 'Importing theme…'
32
+ export const THEME_IMPORT_UNREADABLE = 'That file could not be read.'
33
+ export const THEME_IMPORT_UNAVAILABLE =
34
+ 'The theme importer could not be loaded. Reload the app and try again.'
35
+ export const THEME_IMPORT_FAILED = 'That theme could not be imported.'
36
+
37
+ export function createThemeFileImporter(host: ThemeFileImporterHost): ThemeFileImporter {
38
+ let latest = 0
39
+ let pending = false
40
+ const settle = () => {
41
+ if (!pending) return
42
+ pending = false
43
+ host.onPending(false)
44
+ }
45
+
46
+ return {
47
+ cancel() {
48
+ latest += 1
49
+ if (!pending) return
50
+ settle()
51
+ host.onStatus('')
52
+ },
53
+ async importFile(file) {
54
+ latest += 1
55
+ const run = latest
56
+ const current = () => run === latest
57
+ pending = true
58
+ host.onPending(true)
59
+ host.onStatus(THEME_IMPORT_PENDING)
60
+
61
+ let text: string
62
+ try {
63
+ text = await file.text()
64
+ } catch {
65
+ if (!current()) return
66
+ settle()
67
+ host.onStatus(THEME_IMPORT_UNREADABLE)
68
+ return
69
+ }
70
+ if (!current()) return
71
+
72
+ let importText: (text: string) => CustomThemeImportResult
73
+ try {
74
+ importText = await host.load()
75
+ } catch {
76
+ if (!current()) return
77
+ settle()
78
+ host.onStatus(THEME_IMPORT_UNAVAILABLE)
79
+ return
80
+ }
81
+ if (!current()) return
82
+
83
+ let result: CustomThemeImportResult
84
+ try {
85
+ result = importText(text)
86
+ } catch {
87
+ settle()
88
+ host.onStatus(THEME_IMPORT_FAILED)
89
+ return
90
+ }
91
+ settle()
92
+ if (!result.ok) {
93
+ host.onStatus(result.error)
94
+ return
95
+ }
96
+ host.onStatus(
97
+ `Imported “${result.theme.name}”.` +
98
+ (result.theme.notes.length > 0 ? ` ${result.theme.notes.join(' ')}` : '')
99
+ )
100
+ host.onImported(result.theme)
101
+ },
102
+ }
103
+ }
@@ -0,0 +1,106 @@
1
+ /*
2
+ * Published AppearanceEditor bridge.
3
+ *
4
+ * @adea-ai/ui owns the presentation, the catalogue values and the theme API
5
+ * Adea consumes. Adea keeps its V2 preference model; this adapter hands the
6
+ * published editor the catalogue's own theme records (the shared ThemeProvider
7
+ * paints from the same catalogue), plus a record per imported theme.
8
+ */
9
+ import { colorToHex, normalizeAccentValue, parseColor } from '@adea-ai/ui/lib/accent-roles'
10
+ import { getAccent } from '@adea-ai/ui/lib/accent-presets'
11
+ import { defaultThemeRecord } from '@adea-ai/ui/lib/theme-projection'
12
+ import type { AdeaTheme, AdeaThemeRecord } from '@adea-ai/ui/lib/theme-records'
13
+ import {
14
+ accentRolesForSelection,
15
+ themeRecordById,
16
+ themeRecords,
17
+ type ThemeVariant,
18
+ } from '@adea-ai/ui/lib/themes'
19
+
20
+ import { APPEARANCE_ACCENT_CONTRAST_FLOOR } from './appearance-preferences'
21
+ import { customThemeVariants, storedVariantRecord } from './custom-theme-library'
22
+ import { themeRegistry } from './theme-registry'
23
+
24
+ const adeaLight = defaultThemeRecord('light')
25
+ const adeaDark = defaultThemeRecord('dark')
26
+
27
+ /** The published blue preset is the host's default custom accent. */
28
+ export const DEFAULT_CUSTOM_ACCENT = getAccent('blue')?.light ?? adeaLight.colors.accent
29
+
30
+ /** Imported themes, re-projected on every registry change. */
31
+ export function customThemeRecords(): readonly AdeaThemeRecord[] {
32
+ return customThemeVariants().map(storedVariantRecord)
33
+ }
34
+
35
+ /** The built-in catalogue led by the published pair; import lives separately. */
36
+ export const appearanceThemeRecords: readonly AdeaThemeRecord[] = Object.freeze([
37
+ adeaLight,
38
+ adeaDark,
39
+ ...themeRecords.filter((record) => record.id !== adeaLight.id && record.id !== adeaDark.id),
40
+ ])
41
+
42
+ /** Every selectable record: built-ins first, then imported themes. */
43
+ export function allThemeRecords(): readonly AdeaThemeRecord[] {
44
+ return [...appearanceThemeRecords, ...customThemeRecords()]
45
+ }
46
+
47
+ function withAccent(
48
+ theme: AdeaTheme,
49
+ accent: string,
50
+ pair: { lightThemeId: string; darkThemeId: string } | undefined
51
+ ): AdeaTheme {
52
+ if (accent === 'theme') return theme
53
+ const variant = themeRegistry().find((candidate) => candidate.id === theme.id)
54
+ // The 3:1 floor needs the variant's background. A record whose variant has
55
+ // vanished previews its own accent rather than throwing mid-interaction.
56
+ if (!variant) return theme
57
+ const roles = accentRolesForSelection(accent, theme.appearance, pair, {
58
+ background: variant.colors.background,
59
+ floor: APPEARANCE_ACCENT_CONTRAST_FLOOR,
60
+ variantId: variant.id,
61
+ })
62
+ if (!roles) return theme
63
+ return {
64
+ ...theme,
65
+ colors: {
66
+ ...theme.colors,
67
+ accent: roles.primary,
68
+ accentForeground: roles.primaryForeground,
69
+ },
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Resolve a selected local ID to the external editor's raw preview contract.
75
+ * `pair` is the draft's light/dark theme ids, which a theme-derived (`ansi-*`)
76
+ * accent is read from.
77
+ */
78
+ export function appearanceThemeForPreview(
79
+ variant: ThemeVariant,
80
+ accent: string,
81
+ pair?: { lightThemeId: string; darkThemeId: string }
82
+ ): AdeaTheme {
83
+ // Imported themes have no catalogue record; their stored variant projects to
84
+ // one on the spot, so every record takes the same accent overlay path.
85
+ const record =
86
+ themeRecordById(variant.id) ??
87
+ customThemeRecords().find((candidate) => candidate.id === variant.id) ??
88
+ (variant.appearance === 'dark' ? adeaDark : adeaLight)
89
+ return withAccent(record, accent, pair)
90
+ }
91
+
92
+ type AccentDraftValidation = Readonly<{
93
+ value?: string
94
+ error?: string
95
+ }>
96
+
97
+ /** Preserve the host's invalid-input behavior while feeding the pure editor. */
98
+ export function normalizeCustomAccent(value: string, background: string): AccentDraftValidation {
99
+ const normalized = normalizeAccentValue(value, background)
100
+ if (normalized === undefined) {
101
+ return { error: `“${value}” is not a hex color such as ${DEFAULT_CUSTOM_ACCENT}.` }
102
+ }
103
+ // Stored accents are opaque #rrggbb; an alpha channel is dropped.
104
+ const parsed = parseColor(normalized)
105
+ return { value: parsed ? colorToHex({ ...parsed, a: 255 }) : normalized }
106
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (c) 2026 Wing
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { builtinThemes, type ThemeVariant } from '@adea-ai/ui/lib/themes'
6
+
7
+ import { customUiVariants } from './custom-theme-library'
8
+
9
+ /**
10
+ * Every selectable theme: the catalogue first, then imported themes.
11
+ *
12
+ * This is the one place the app reads the whole catalogue (`builtinThemes`), and it
13
+ * is a module of its own on purpose: the appearance editor imports it from its lazy
14
+ * chunk. Left in `custom-theme-library.ts`, which the shell's provider imports at
15
+ * start-up, it would keep the 34-theme catalogue in the start-up closure (ADR 0014).
16
+ */
17
+ export function themeRegistry(): readonly ThemeVariant[] {
18
+ const custom = customUiVariants()
19
+ return custom.length > 0 ? [...builtinThemes, ...custom] : builtinThemes
20
+ }
@@ -0,0 +1,18 @@
1
+ // The desktop mirror for the glass appearance setting. The appearance editor
2
+ // persists its surface to localStorage (device-local), but the native window
3
+ // is the shell's: it reads the mirrored value from the persisted workspace
4
+ // preferences at boot. The host (apps/web, desktop only) registers the
5
+ // transport — dev-view stays platform-agnostic and calls the seam.
6
+ export type WindowSurface = 'theme' | 'frosted' | 'opaque'
7
+
8
+ type WindowSurfaceMirror = (surface: WindowSurface) => void
9
+
10
+ let mirror: WindowSurfaceMirror | undefined
11
+
12
+ export function registerWindowSurfaceMirror(next: WindowSurfaceMirror): void {
13
+ mirror = next
14
+ }
15
+
16
+ export function mirrorWindowSurface(surface: WindowSurface): void {
17
+ mirror?.(surface)
18
+ }
@@ -0,0 +1,75 @@
1
+ import { realpath, stat } from 'node:fs/promises'
2
+ import { extname, join, posix, relative, resolve, sep } from 'node:path'
3
+
4
+ const MIME: Record<string, string> = {
5
+ '.html': 'text/html',
6
+ '.js': 'text/javascript',
7
+ '.css': 'text/css',
8
+ '.svg': 'image/svg+xml',
9
+ '.json': 'application/json',
10
+ '.png': 'image/png',
11
+ '.ico': 'image/x-icon',
12
+ '.woff2': 'font/woff2',
13
+ '.wasm': 'application/wasm',
14
+ }
15
+
16
+ export type ClientOptions = {
17
+ root: string
18
+ deniedPaths?: readonly string[]
19
+ transformHtml?: (html: string, request: Request) => string
20
+ }
21
+
22
+ const unavailable = (status = 404) =>
23
+ new Response(null, { status, headers: { 'cache-control': 'no-store' } })
24
+
25
+ /** Serve a bundled SPA without resolving links outside its client root. */
26
+ export async function serveClient(request: Request, options: ClientOptions): Promise<Response> {
27
+ let logical: string
28
+ try {
29
+ logical = posix.normalize(
30
+ '/' + decodeURIComponent(new URL(request.url).pathname).replaceAll('\\', '/')
31
+ )
32
+ } catch {
33
+ return unavailable()
34
+ }
35
+ if (logical.includes('\0')) return unavailable()
36
+ const denied = (path: string) =>
37
+ (options.deniedPaths ?? []).some((item) => {
38
+ const prefix =
39
+ posix
40
+ .normalize('/' + item.replaceAll('\\', '/'))
41
+ .toLowerCase()
42
+ .replace(/\/$/, '') || '/'
43
+ const folded = path.toLowerCase()
44
+ return prefix === '/' || folded === prefix || folded.startsWith(prefix + '/')
45
+ })
46
+ if (denied(logical)) return unavailable()
47
+ const root = await realpath(options.root)
48
+ let filePath = resolve(root, '.' + logical)
49
+ const inside = (path: string) => path === root || path.startsWith(root + sep)
50
+ if (!inside(filePath)) return unavailable(403)
51
+ let metadata = await stat(filePath).catch(() => null)
52
+ if (metadata?.isDirectory()) {
53
+ filePath = join(filePath, 'index.html')
54
+ metadata = await stat(filePath).catch(() => null)
55
+ }
56
+ if (!metadata?.isFile()) {
57
+ const folded = logical.toLowerCase()
58
+ if (folded === '/assets' || folded.startsWith('/assets/')) return unavailable()
59
+ filePath = join(root, 'index.html')
60
+ }
61
+ const physical = await realpath(filePath).catch(() => null)
62
+ if (!physical) return unavailable()
63
+ if (!inside(physical)) return unavailable(403)
64
+ if (denied('/' + relative(root, physical).replaceAll('\\', '/'))) return unavailable()
65
+ let body = new Uint8Array(await Bun.file(physical).arrayBuffer())
66
+ if (extname(physical).toLowerCase() === '.html' && options.transformHtml) {
67
+ body = new TextEncoder().encode(options.transformHtml(new TextDecoder().decode(body), request))
68
+ }
69
+ return new Response(body, {
70
+ headers: {
71
+ 'content-type': MIME[extname(physical).toLowerCase()] ?? 'application/octet-stream',
72
+ 'cache-control': 'no-store',
73
+ },
74
+ })
75
+ }
@@ -0,0 +1,63 @@
1
+ Electrobun 2.0.5 (MIT), commit d06abc9edf0b4e55116129cabbfe17bf89e11791.
2
+
3
+ Install the CEF renderer bridges (__electrobunEventBridge,
4
+ __electrobunHostBridge, __electrobunBunBridge and __electrobunInternalBridge)
5
+ only in the main frame. Their postMessage handlers send through the browser's
6
+ main frame, so the browser process cannot distinguish a subframe's message from
7
+ the application's: a cross-origin iframe could otherwise drive internal RPC
8
+ such as webviewTagInit. Applies to the macOS, Linux and Windows helpers.
9
+
10
+ diff --git a/package/src/native/linux/cef_process_helper_linux.cpp b/package/src/native/linux/cef_process_helper_linux.cpp
11
+ index 7d8404a1eac0999e9d63e6458a201fa06561f740..9d72f4a3cf6a4d4d7432617121c407c8ae091cbb 100644
12
+ --- a/package/src/native/linux/cef_process_helper_linux.cpp
13
+ +++ b/package/src/native/linux/cef_process_helper_linux.cpp
14
+ @@ -50,6 +50,13 @@ public:
15
+ virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
16
+ CefRefPtr<CefFrame> frame,
17
+ CefRefPtr<CefV8Context> context) override {
18
+ + // The bridges send through the browser's main frame, so the browser
19
+ + // process cannot tell a subframe's message from the app's own. Only
20
+ + // the main frame receives them; subframes keep plain web APIs.
21
+ + if (!frame->IsMain()) {
22
+ + return;
23
+ + }
24
+ +
25
+ // Check if this browser is sandboxed
26
+ bool is_sandboxed = false;
27
+ {
28
+ diff --git a/package/src/native/macos/cef_process_helper_mac.cc b/package/src/native/macos/cef_process_helper_mac.cc
29
+ index 220ec6ddbdc3fc1e1635e29455ad7727f73a11ed..d6dccfad3ca44aa2b86bfb338f28895307f5cbac 100644
30
+ --- a/package/src/native/macos/cef_process_helper_mac.cc
31
+ +++ b/package/src/native/macos/cef_process_helper_mac.cc
32
+ @@ -50,6 +50,13 @@ public:
33
+ virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
34
+ CefRefPtr<CefFrame> frame,
35
+ CefRefPtr<CefV8Context> context) override {
36
+ + // The bridges send through the browser's main frame, so the browser
37
+ + // process cannot tell a subframe's message from the app's own. Only
38
+ + // the main frame receives them; subframes keep plain web APIs.
39
+ + if (!frame->IsMain()) {
40
+ + return;
41
+ + }
42
+ +
43
+ // Check if this browser is sandboxed
44
+ bool is_sandboxed = false;
45
+ {
46
+ diff --git a/package/src/native/win/cef_process_helper_win.cpp b/package/src/native/win/cef_process_helper_win.cpp
47
+ index 205f6951ee9a3455027e1e2c4fb5e4fa1287e576..04a12110eda463d8e1dc684b9bb41303aa29be84 100644
48
+ --- a/package/src/native/win/cef_process_helper_win.cpp
49
+ +++ b/package/src/native/win/cef_process_helper_win.cpp
50
+ @@ -45,6 +45,13 @@ public:
51
+ virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
52
+ CefRefPtr<CefFrame> frame,
53
+ CefRefPtr<CefV8Context> context) override {
54
+ + // The bridges send through the browser's main frame, so the browser
55
+ + // process cannot tell a subframe's message from the app's own. Only
56
+ + // the main frame receives them; subframes keep plain web APIs.
57
+ + if (!frame->IsMain()) {
58
+ + return;
59
+ + }
60
+ +
61
+ // Check if this browser is sandboxed
62
+ bool is_sandboxed = false;
63
+ {