dsh-builtin-browser 1.0.1 → 1.0.3

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 (360) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +1 -1
  3. package/assets/browser-panel-locales.mjs +37 -5
  4. package/assets/browser-policy.d.mts +29 -0
  5. package/assets/browser-policy.mjs +40 -0
  6. package/desktop-bridge/desktop-discovery.d.mts +1 -1
  7. package/desktop-bridge/desktop-discovery.mjs +59 -9
  8. package/desktop-bridge/desktop-identity.json +12 -0
  9. package/desktop-bridge/install.mjs +14 -7
  10. package/desktop-bridge/plugin-browser-bridge.js +19 -7
  11. package/docs/acceptance-2026-11-27.md +67 -0
  12. package/docs/architecture.md +1 -1
  13. package/docs/development.md +33 -4
  14. package/docs/dsh-0.2.3-host-patch-task.md +34 -0
  15. package/docs/hardcoding-audit.md +28 -8
  16. package/docs/known-issues.md +26 -0
  17. package/docs/limitations.md +6 -2
  18. package/docs/tool-reference.md +1 -1
  19. package/docs/v1.1.0-bu-data-batching-task.md +66 -0
  20. package/docs/v1.1.0-compat-hardcoding-task.md +85 -0
  21. package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
  22. package/dsh-builtin-browser-1.0.3.tgz +0 -0
  23. package/dsh-host-patch/README.md +4 -0
  24. package/dsh-host-patch/apply.mjs +61 -13
  25. package/dsh-host-patch/rc3-revision9.json.gz +0 -0
  26. package/dsh-host-patch/rc5-revision9.json.gz +0 -0
  27. package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  28. package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  29. package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  30. package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  31. package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  32. package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  33. package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  34. package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  35. package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  36. package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  37. package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  38. package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  39. package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  40. package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  41. package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  42. package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  43. package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  44. package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  45. package/dsh-host-patch/sources/manifest.json +218 -0
  46. package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  47. package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  48. package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  49. package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  50. package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  51. package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  52. package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  53. package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  54. package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  55. package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  56. package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  57. package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  58. package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  59. package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  60. package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  61. package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  62. package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  63. package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  64. package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  65. package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  66. package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  67. package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  68. package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  69. package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  70. package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  71. package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  72. package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  73. package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  74. package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  75. package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  76. package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  77. package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  78. package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  79. package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  80. package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  81. package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  82. package/dsh-host-patch/sources/series.json +260 -0
  83. package/dsh-host-patch/tauri/desktop-main.cjs +62 -0
  84. package/dsh-host-patch/tauri/sidebar-session.cjs +104 -0
  85. package/dsh-host-patch/tauri-revision1.json +39 -0
  86. package/dsh-host-patch/tauri.json +43 -0
  87. package/dsh-host-patch/v023-alpha2.json +153 -0
  88. package/lib/browser/anti-bot.js +215 -0
  89. package/lib/browser/deep-dom.js +39 -0
  90. package/lib/browser/runtime.js +15 -0
  91. package/lib/browser/takeover-target.js +13 -6
  92. package/lib/browser/types.js +30 -1
  93. package/lib/browser-electron/authenticated-route.js +16 -2
  94. package/lib/browser-electron/automatic-maintenance.js +16 -10
  95. package/lib/browser-electron/bridge-connection.js +3 -8
  96. package/lib/browser-electron/bridge-install.js +2 -1
  97. package/lib/browser-electron/bridge-status.js +55 -26
  98. package/lib/browser-electron/desktop-bridge-host.js +7 -6
  99. package/lib/browser-electron/desktop-identity.js +28 -5
  100. package/lib/browser-electron/desktop-shell.js +64 -0
  101. package/lib/browser-electron/electron-provision.js +105 -18
  102. package/lib/browser-electron/entry.js +129 -44
  103. package/lib/browser-electron/extension-browser.js +4 -4
  104. package/lib/browser-electron/foreground-watch.js +134 -0
  105. package/lib/browser-electron/guest-cookie-jar.js +13 -13
  106. package/lib/browser-electron/guest-route.js +181 -32
  107. package/lib/browser-electron/guest-runtime.js +61 -10
  108. package/lib/browser-electron/guest-storage.js +2 -2
  109. package/lib/browser-electron/history-store.js +1 -5
  110. package/lib/browser-electron/host-main.js +8 -4
  111. package/lib/browser-electron/host-patch-maintenance.js +14 -8
  112. package/lib/browser-electron/maintenance-route.js +2 -1
  113. package/lib/browser-electron/missing-system-browser.js +5 -9
  114. package/lib/browser-electron/preferred-browser.js +7 -3
  115. package/lib/browser-electron/preview-route.js +9 -13
  116. package/lib/browser-electron/process-ownership.js +1 -1
  117. package/lib/browser-electron/profile-command.js +2 -1
  118. package/lib/browser-electron/profile-extension.js +5 -0
  119. package/lib/browser-electron/profile-lease.js +152 -47
  120. package/lib/browser-electron/provider-core.js +527 -0
  121. package/lib/browser-electron/provider-interaction.js +963 -0
  122. package/lib/browser-electron/provider-media.js +518 -0
  123. package/lib/browser-electron/provider-navigation.js +301 -0
  124. package/lib/browser-electron/provider-observation.js +623 -0
  125. package/lib/browser-electron/provider-tabs.js +372 -0
  126. package/lib/browser-electron/provider.js +150 -3301
  127. package/lib/browser-electron/reference-route.js +9 -18
  128. package/lib/browser-electron/remote-host.js +79 -34
  129. package/lib/browser-electron/runtime-status.js +56 -6
  130. package/lib/browser-electron/settings-store.js +3 -6
  131. package/lib/browser-electron/sidebar-only-host.js +1 -1
  132. package/lib/browser-electron/system-browser.js +539 -172
  133. package/lib/browser-electron/tauri-host.js +208 -0
  134. package/lib/browser-electron/virtual-cursor.js +23 -13
  135. package/lib/browser-reference/service.js +22 -4
  136. package/lib/browser-reference/web-sources.js +1 -1
  137. package/lib/client.js +43409 -0
  138. package/lib/compat/host-features.js +75 -0
  139. package/lib/reference-source.js +1 -1
  140. package/lib/reference-text.js +23 -1
  141. package/lib/takeover-protocol.js +1 -1
  142. package/lib/tool-browser/block-recovery.js +69 -0
  143. package/lib/tool-browser/code-tool.js +170 -19
  144. package/lib/tool-browser/code-worker.js +115 -20
  145. package/lib/tool-browser/errors.js +34 -0
  146. package/lib/tool-browser/index.js +66 -3593
  147. package/lib/tool-browser/page-probe.js +227 -28
  148. package/lib/tool-browser/panel-page.js +2 -1
  149. package/lib/tool-browser/probe-client.js +157 -0
  150. package/lib/tool-browser/screenshot-annotations.js +108 -0
  151. package/lib/tool-browser/state.js +337 -0
  152. package/lib/tool-browser/takeover.js +1 -1
  153. package/lib/tool-browser/tools-debug.js +862 -0
  154. package/lib/tool-browser/tools-interaction.js +993 -0
  155. package/lib/tool-browser/tools-navigation.js +807 -0
  156. package/lib/tool-browser/tools-observation.js +461 -0
  157. package/lib/tool-browser/tools-reference.js +293 -0
  158. package/lib/web-guest.js +1 -0
  159. package/package.json +15 -53
  160. package/README.en.md +0 -89
  161. package/browser-extension/constants.mjs +0 -20
  162. package/browser-extension/controller.mjs +0 -293
  163. package/browser-extension/locales.mjs +0 -15
  164. package/browser-extension/manifest.json +0 -12
  165. package/browser-extension/options.html +0 -14
  166. package/browser-extension/options.mjs +0 -9
  167. package/browser-extension/permission-guard.mjs +0 -13
  168. package/browser-extension/worker.mjs +0 -74
  169. package/dist/client.cjs +0 -43167
  170. package/lib/browser-reference/submission-receipts.js +0 -139
  171. package/scripts/build.mjs +0 -66
  172. package/scripts/bundle-host.mjs +0 -28
  173. package/scripts/fix-exports.mjs +0 -50
  174. package/scripts/install-electron.mjs +0 -51
  175. package/scripts/verify-exports.mjs +0 -47
  176. package/scripts/verify-preview-sdk.mjs +0 -93
  177. package/skills/dsh-builtin-browser/SKILL.md +0 -73
  178. package/skills/dsh-builtin-browser/references/batch.md +0 -53
  179. package/skills/dsh-builtin-browser/references/deliver.md +0 -31
  180. package/skills/dsh-builtin-browser/references/locate.md +0 -11
  181. package/skills/dsh-builtin-browser/references/recover.md +0 -11
  182. package/skills/dsh-builtin-browser/references/verify.md +0 -13
  183. package/skills/dsh-debug-host/SKILL.md +0 -56
  184. package/skills/dsh-debug-self/SKILL.md +0 -50
  185. package/src/bridge-compatibility.ts +0 -39
  186. package/src/browser/handles.ts +0 -89
  187. package/src/browser/runtime.ts +0 -560
  188. package/src/browser/takeover-target.ts +0 -36
  189. package/src/browser/types.ts +0 -817
  190. package/src/browser-electron/authenticated-route.ts +0 -84
  191. package/src/browser-electron/automatic-maintenance.ts +0 -726
  192. package/src/browser-electron/bridge-auto.ts +0 -159
  193. package/src/browser-electron/bridge-connection.ts +0 -385
  194. package/src/browser-electron/bridge-endpoint.ts +0 -129
  195. package/src/browser-electron/bridge-install.ts +0 -289
  196. package/src/browser-electron/bridge-maintenance.ts +0 -189
  197. package/src/browser-electron/bridge-status.ts +0 -347
  198. package/src/browser-electron/desktop-bridge-host.ts +0 -251
  199. package/src/browser-electron/desktop-identity.ts +0 -320
  200. package/src/browser-electron/document-readiness.ts +0 -45
  201. package/src/browser-electron/electron-provision.ts +0 -261
  202. package/src/browser-electron/entry.ts +0 -1299
  203. package/src/browser-electron/ephemeral-profile.ts +0 -189
  204. package/src/browser-electron/extension-browser.ts +0 -223
  205. package/src/browser-electron/extension-setup.ts +0 -67
  206. package/src/browser-electron/file-write.ts +0 -31
  207. package/src/browser-electron/guest-cookie-jar.ts +0 -176
  208. package/src/browser-electron/guest-cookie-store.ts +0 -59
  209. package/src/browser-electron/guest-css-runtime.ts +0 -76
  210. package/src/browser-electron/guest-css.ts +0 -68
  211. package/src/browser-electron/guest-route.ts +0 -568
  212. package/src/browser-electron/guest-runtime.ts +0 -357
  213. package/src/browser-electron/guest-storage-runtime.ts +0 -54
  214. package/src/browser-electron/guest-storage.ts +0 -117
  215. package/src/browser-electron/history-store.ts +0 -227
  216. package/src/browser-electron/host-main.ts +0 -1381
  217. package/src/browser-electron/host-patch-maintenance.ts +0 -112
  218. package/src/browser-electron/http-body.ts +0 -65
  219. package/src/browser-electron/json-reply.ts +0 -47
  220. package/src/browser-electron/maintenance-broker.ts +0 -166
  221. package/src/browser-electron/maintenance-lifecycle.ts +0 -91
  222. package/src/browser-electron/maintenance-route.ts +0 -67
  223. package/src/browser-electron/missing-system-browser.ts +0 -113
  224. package/src/browser-electron/open-slot.ts +0 -49
  225. package/src/browser-electron/paths.ts +0 -25
  226. package/src/browser-electron/preferred-browser.ts +0 -120
  227. package/src/browser-electron/preview-route.ts +0 -218
  228. package/src/browser-electron/process-ownership.ts +0 -168
  229. package/src/browser-electron/process.ts +0 -23
  230. package/src/browser-electron/profile-checkpoint.ts +0 -187
  231. package/src/browser-electron/profile-command.ts +0 -46
  232. package/src/browser-electron/profile-extension.ts +0 -124
  233. package/src/browser-electron/profile-lease.ts +0 -115
  234. package/src/browser-electron/profile-residue.ts +0 -49
  235. package/src/browser-electron/provider.ts +0 -4571
  236. package/src/browser-electron/reference-route.ts +0 -608
  237. package/src/browser-electron/remote-host.ts +0 -1462
  238. package/src/browser-electron/rpc-input.ts +0 -13
  239. package/src/browser-electron/rpc-ops.ts +0 -41
  240. package/src/browser-electron/runtime-diagnostics.ts +0 -38
  241. package/src/browser-electron/runtime-route.ts +0 -105
  242. package/src/browser-electron/runtime-status.ts +0 -242
  243. package/src/browser-electron/settings-route.ts +0 -64
  244. package/src/browser-electron/settings-store.ts +0 -589
  245. package/src/browser-electron/shortcuts-route.ts +0 -112
  246. package/src/browser-electron/sidebar-only-host.ts +0 -298
  247. package/src/browser-electron/startpage-shortcuts.ts +0 -213
  248. package/src/browser-electron/system-browser.ts +0 -1497
  249. package/src/browser-electron/timing.ts +0 -16
  250. package/src/browser-electron/virtual-cursor.ts +0 -152
  251. package/src/browser-electron/windows-system.ts +0 -24
  252. package/src/browser-reference/delivery.ts +0 -384
  253. package/src/browser-reference/entry.ts +0 -631
  254. package/src/browser-reference/export.ts +0 -339
  255. package/src/browser-reference/import.ts +0 -303
  256. package/src/browser-reference/page-script.ts +0 -1537
  257. package/src/browser-reference/service.ts +0 -1315
  258. package/src/browser-reference/store.ts +0 -172
  259. package/src/browser-reference/submission-receipts.ts +0 -122
  260. package/src/browser-reference/text-quote.ts +0 -219
  261. package/src/browser-reference/types.ts +0 -195
  262. package/src/browser-reference/visible.ts +0 -367
  263. package/src/browser-reference/web-sources.ts +0 -103
  264. package/src/client/browser/BrowserController.ts +0 -693
  265. package/src/client/browser/BrowserFrame.ts +0 -78
  266. package/src/client/browser/BrowserNavigation.ts +0 -169
  267. package/src/client/browser/BrowserPage.ts +0 -23
  268. package/src/client/browser/BrowserPersistence.ts +0 -44
  269. package/src/client/browser/IframeImpl.ts +0 -176
  270. package/src/client/browser/child-tabs.ts +0 -14
  271. package/src/client/browser/iframe-reference.ts +0 -67
  272. package/src/client/browser/initialization.ts +0 -262
  273. package/src/client/browser/omnibox.ts +0 -243
  274. package/src/client/browser/store.ts +0 -38
  275. package/src/client/browser/takeover-channel.ts +0 -72
  276. package/src/client/browser/url.ts +0 -46
  277. package/src/client/browser/web-reference-source.ts +0 -52
  278. package/src/client/css-modules.d.ts +0 -4
  279. package/src/client/definition.tsx +0 -30
  280. package/src/client/electron/ElectronWebViewImpl.ts +0 -364
  281. package/src/client/electron/ElectronWebviewPresentation.ts +0 -138
  282. package/src/client/electron/NativeChildPresentation.ts +0 -45
  283. package/src/client/electron/NativeViewPage.ts +0 -251
  284. package/src/client/electron/pages.ts +0 -23
  285. package/src/client/electron/reference-overlay.ts +0 -53
  286. package/src/client/electron/workspace.ts +0 -33
  287. package/src/client/index.ts +0 -293
  288. package/src/client/locales.ts +0 -857
  289. package/src/client/pages.ts +0 -28
  290. package/src/client/reference/client/BrowserRefLink.tsx +0 -142
  291. package/src/client/reference/client/draft-reference.ts +0 -167
  292. package/src/client/reference/client/index.ts +0 -7
  293. package/src/client/reference/client/ordered-submission.ts +0 -108
  294. package/src/client/reference/client/pending-delivery.ts +0 -216
  295. package/src/client/reference/client/plugin.ts +0 -189
  296. package/src/client/reference/client/production/ReferenceCapsules.tsx +0 -345
  297. package/src/client/reference/client/production/ReferenceDock.module.css +0 -193
  298. package/src/client/reference/client/production/ReferenceDock.tsx +0 -6
  299. package/src/client/reference/client/production/ReferenceFeedback.tsx +0 -15
  300. package/src/client/reference/client/production/ReferenceMath.tsx +0 -44
  301. package/src/client/reference/client/production/ReferenceText.tsx +0 -36
  302. package/src/client/reference/client/production/assembly.ts +0 -471
  303. package/src/client/reference/client/production/asset-store.ts +0 -144
  304. package/src/client/reference/client/production/availability.ts +0 -74
  305. package/src/client/reference/client/production/bytes.ts +0 -36
  306. package/src/client/reference/client/production/delivery-client.ts +0 -211
  307. package/src/client/reference/client/production/draft-adapter.ts +0 -508
  308. package/src/client/reference/client/production/http-transport.ts +0 -217
  309. package/src/client/reference/client/production/production-submission.ts +0 -310
  310. package/src/client/reference/client/production/protocol.ts +0 -231
  311. package/src/client/reference/client/production/reference-card.ts +0 -240
  312. package/src/client/reference/client/production/reference-labels.ts +0 -29
  313. package/src/client/reference/client/production/reply-link-bridge.ts +0 -222
  314. package/src/client/reference/client/production/reveal.ts +0 -215
  315. package/src/client/reference/client/production/runtime.ts +0 -1101
  316. package/src/client/reference/client/production/snapshot-adapter.ts +0 -154
  317. package/src/client/reference/client/production/source-marker.ts +0 -63
  318. package/src/client/reference/client/production/source-opener.ts +0 -55
  319. package/src/client/reference/client/production/styles.ts +0 -104
  320. package/src/client/reference/client/production/user-text-rule.ts +0 -58
  321. package/src/client/reference/client/reveal.ts +0 -107
  322. package/src/client/reference/client/scheme.ts +0 -114
  323. package/src/client/reference/client/types.ts +0 -168
  324. package/src/client/reference/css-modules.d.ts +0 -4
  325. package/src/client/reference/index.ts +0 -11
  326. package/src/client/reference-capture-owner.ts +0 -162
  327. package/src/client/reference-intents.ts +0 -36
  328. package/src/client/settings/index.ts +0 -34
  329. package/src/client/settings/panel.ts +0 -2657
  330. package/src/client/shortcut-open.ts +0 -30
  331. package/src/client/startpage/binding.ts +0 -99
  332. package/src/client/startpage/controller.ts +0 -303
  333. package/src/client/startpage/model.ts +0 -279
  334. package/src/client/view/Browser.module.css +0 -751
  335. package/src/client/view/BrowserBody.tsx +0 -314
  336. package/src/client/view/BrowserPresentation.ts +0 -9
  337. package/src/client/view/BrowserTitle.tsx +0 -17
  338. package/src/client/view/IframePresentation.ts +0 -344
  339. package/src/client/view/StartPage.tsx +0 -597
  340. package/src/client/view/TakeoverBanner.tsx +0 -21
  341. package/src/index.ts +0 -110
  342. package/src/reference-owner.ts +0 -5
  343. package/src/reference-page.ts +0 -9
  344. package/src/reference-source.ts +0 -3
  345. package/src/reference-text.ts +0 -197
  346. package/src/startpage-settings.ts +0 -103
  347. package/src/startpage.ts +0 -71
  348. package/src/takeover-protocol.ts +0 -19
  349. package/src/tool-browser/code-tool.ts +0 -401
  350. package/src/tool-browser/code-worker.ts +0 -639
  351. package/src/tool-browser/element-fields.ts +0 -167
  352. package/src/tool-browser/index.ts +0 -3733
  353. package/src/tool-browser/page-probe.ts +0 -474
  354. package/src/tool-browser/panel-page.ts +0 -124
  355. package/src/tool-browser/screenshot-image.ts +0 -49
  356. package/src/tool-browser/takeover.ts +0 -198
  357. package/src/types/electron-shim.d.ts +0 -144
  358. package/src/types.ts +0 -85
  359. package/src/web-guest.ts +0 -34
  360. package/tools/accept-desktop.mjs +0 -148
@@ -1,52 +0,0 @@
1
- import { WEB_SOURCE_ROUTE, type WebRevealStatus } from '../../reference-source.ts'
2
- import { referenceOwnerKey } from '../../reference-owner.ts'
3
- import type { FrozenSnapshot } from '../reference/client/production/protocol.ts'
4
- import { iframeReferenceSource } from './iframe-reference.ts'
5
-
6
- class WebSourceHttpError extends Error {
7
- constructor(readonly status: number) { super(`web source channel failed (${status})`) }
8
- }
9
-
10
- /** The authenticated app, not the opaque guest, owns this lease and its replies. */
11
- export async function connectWebReferenceSource(owner: string, pageId: string, currentUrl: () => string, signal: AbortSignal): Promise<void> {
12
- owner = referenceOwnerKey(owner)
13
- const post = async (body: object): Promise<{ lease?: string; commands?: readonly { id: string; reference: FrozenSnapshot; partId?: string }[] }> => {
14
- const response = await fetch(WEB_SOURCE_ROUTE, { method: 'POST', credentials: 'include', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body), signal })
15
- if (!response.ok) throw new WebSourceHttpError(response.status)
16
- return response.json()
17
- }
18
- let { lease } = await post({ operation: 'register', sessionId: owner, pageId, url: currentUrl() })
19
- if (!lease) throw new Error('web source lease missing')
20
- let timer: ReturnType<typeof setTimeout> | undefined
21
- let acknowledgements: { id: string; status: WebRevealStatus }[] = []
22
- const poll = async (): Promise<void> => {
23
- try {
24
- if (lease === undefined) {
25
- const registered = await post({ operation: 'register', sessionId: owner, pageId, url: currentUrl() })
26
- lease = registered.lease
27
- if (!lease) throw new Error('web source lease missing')
28
- }
29
- const response = await post({ operation: 'poll', lease, url: currentUrl(), acknowledgements })
30
- acknowledgements = []
31
- for (const command of response.commands ?? []) {
32
- let status: WebRevealStatus = 'unavailable'
33
- try {
34
- const source = iframeReferenceSource(pageId, owner)
35
- const result = await source?.reveal?.(command.reference, command.partId, AbortSignal.any([signal, AbortSignal.timeout(6_000)]))
36
- if (result === 'revealed' || result === 'ambiguous' || result === 'missing' || result === 'not-found' || result === 'page-mismatch' || result === 'partial') status = result
37
- } catch { /* A changed document cannot acknowledge a successful reveal. */ }
38
- acknowledgements.push({ id: command.id, status })
39
- }
40
- } catch (error) {
41
- if (error instanceof WebSourceHttpError && error.status === 410) { lease = undefined; acknowledgements = [] }
42
- }
43
- if (!signal.aborted) timer = setTimeout(() => { void poll() }, acknowledgements.length > 0 ? 0 : 500)
44
- }
45
- const stop = (): void => {
46
- clearTimeout(timer)
47
- void fetch(WEB_SOURCE_ROUTE, { method: 'POST', credentials: 'include', keepalive: true, headers: { 'content-type': 'application/json' }, body: JSON.stringify({ operation: 'remove', lease }) }).catch(() => {})
48
- }
49
- signal.addEventListener('abort', stop, { once: true })
50
- if (signal.aborted) stop()
51
- else void poll()
52
- }
@@ -1,4 +0,0 @@
1
- declare module '*.module.css' {
2
- const classes: Readonly<Record<string, string>>
3
- export default classes
4
- }
@@ -1,30 +0,0 @@
1
- /** Static Browser tab type and guide declaration. */
2
- import type { ShortcutCommandId } from '@deepseek-ai/dsh-client-shortcuts/client'
3
- import type { TranslateNS } from '@deepseek-ai/dsh-client-locale/client'
4
- import { GuideArtworkBrowser } from '@deepseek-ai/dsh-client-ui-primitives'
5
- import type { SidebarRightTabDefinition } from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
6
- import type {} from './locales.ts'
7
-
8
- /** Browser tab kind. */
9
- export const BROWSER_KIND = 'browser'
10
-
11
- /** Browser implementation identity and keyed Slot dispatch key. */
12
- export const BROWSER_ID = '@deepseek-ai/dsh-client-ui-sidebar-browser'
13
-
14
- /** Build the Browser type with locale-live copy. */
15
- export function browserDefinition(t: TranslateNS<'sidebarBrowser'>): SidebarRightTabDefinition {
16
- return {
17
- id: BROWSER_ID,
18
- kind: BROWSER_KIND,
19
- // 单标签:`multiple: true` 会让宿主在每次 `openTabIn` 时铸一个新的 content id,
20
- // 于是「打开百度 → 搜索数独」变成新开一个标签、上一页被丢弃(用户实测报的就是这个)。
21
- // 浏览器标签按会话只有一个,新的地址在**原地**导航。
22
- multiple: false,
23
- priority: 'builtin',
24
- title: () => t('type.label'),
25
- guide: [{
26
- id: 'new', commandId: 'browser.new' as ShortcutCommandId, order: 30, title: () => t('guide.title'),
27
- description: () => t('guide.description'), icon: GuideArtworkBrowser,
28
- }],
29
- }
30
- }
@@ -1,364 +0,0 @@
1
- /** Electron navigation and guest lifetime, independent from DOM placement. */
2
- import { createSnapshotStore, type SnapshotStore } from '@deepseek-ai/dsh-client-store'
3
- import type { DesktopBrowserBridge, DesktopBrowserLeaseId, BrowserChildTabRequest, BrowserChildTabResult } from '../../types.ts'
4
- import type { ElectronWebviewPresentation, WebviewElement } from './ElectronWebviewPresentation.ts'
5
- import { emptyBrowserFrame, type BrowserFrame, type BrowserFrameState, type BrowserLoadError } from '../browser/BrowserFrame.ts'
6
- import type { BrowserCarrierState } from '../browser/BrowserFrame.ts'
7
- import type { BrowserPageOptions } from '../browser/BrowserPage.ts'
8
- import { browserAddressCheckpoint, currentBrowserTarget } from '../browser/BrowserPersistence.ts'
9
- import { parseBrowserAddress, type BrowserTarget } from '../browser/url.ts'
10
- import { captureReferenceIntent } from '../reference-intents.ts'
11
- import { installReferenceOverlay } from './reference-overlay.ts'
12
- import { dispatchChildTab } from '../browser/child-tabs.ts'
13
-
14
- interface NavigationEvent extends Event { readonly isMainFrame: boolean; readonly isInPlace?: boolean }
15
- interface LoadFailureEvent extends NavigationEvent {
16
- readonly errorCode: number
17
- readonly errorDescription: string
18
- }
19
-
20
- /** Owns native history and translates Electron observations into common frame state. */
21
- export class ElectronWebViewImpl implements BrowserFrame {
22
- private readonly store: SnapshotStore<BrowserFrameState>
23
- /** Carrier proof, separate from navigation state: guest created, document ready, bootstrap failed. */
24
- private readonly carrier: SnapshotStore<BrowserCarrierState>
25
- private readonly lifetime = new AbortController()
26
- private guestLifetime: AbortController | undefined
27
- private documentLifetime: AbortController | undefined
28
- private element: WebviewElement | undefined
29
- private lease: DesktopBrowserLeaseId | undefined
30
- private workspaceKey: string | undefined
31
- private initializing: Promise<void> | undefined
32
- private ready = false
33
- private pending: BrowserTarget | undefined
34
- private revision = 0
35
- private firstDocument = true
36
- private checkpoint: BrowserTarget | undefined
37
- private disposal: Promise<void> | undefined
38
- private attachment: AbortController | undefined
39
- private readonly releases = new Set<Promise<void>>()
40
-
41
- /**
42
- * @param options - saved address, persistence and source-tab opening callback.
43
- * @param bridge - main-process guest operations.
44
- * @param workspace - resolves the storage account once for this frame lifetime.
45
- * @param presentation - tag and Sidebar placement adapter.
46
- */
47
- constructor(private readonly options: BrowserPageOptions, private readonly bridge: DesktopBrowserBridge,
48
- private readonly workspace: (signal: AbortSignal) => Promise<string>,
49
- private readonly presentation: ElectronWebviewPresentation, private readonly sessionId: string,
50
- private readonly capture: (intent: object, owner?: string) => Promise<void> = (intent, owner) => captureReferenceIntent(intent, owner ?? '')) {
51
- this.checkpoint = currentBrowserTarget(options.initial)
52
- this.store = createSnapshotStore(emptyBrowserFrame())
53
- this.carrier = createSnapshotStore<BrowserCarrierState>({ stage: 'idle' })
54
- }
55
-
56
- /** @returns immutable carrier-level initialization proof. */
57
- readonly lifecycle = {
58
- getSnapshot: (): BrowserCarrierState => this.carrier.getSnapshot(),
59
- subscribe: (listener: () => void): (() => void) => this.carrier.subscribe(listener),
60
- }
61
-
62
- /** @returns immutable carrier-neutral navigation state. */
63
- getSnapshot = (): BrowserFrameState => this.store.getSnapshot()
64
- /** @param listener - state invalidation. @returns unsubscribe callback. */
65
- subscribe = (listener: () => void): (() => void) => this.store.subscribe(listener)
66
-
67
- /** A physical mount may recreate a lost guest; ordinary Sidebar hiding never calls this. */
68
- attach(): void {
69
- if (this.lifetime.signal.aborted) return
70
- this.attachment = new AbortController()
71
- this.carrier.set({ stage: 'idle' })
72
- this.pending ??= this.store.getSnapshot().target
73
- if (this.pending !== undefined) {
74
- this.store.set({ ...this.store.getSnapshot(), address: 'requested', loading: true, documentReady: false,
75
- canGoBack: false, canGoForward: false, error: undefined })
76
- this.initialize()
77
- }
78
- }
79
-
80
- /** Invalidate pending attachment before the containing DOM is removed. */
81
- detach(): void {
82
- this.attachment?.abort()
83
- this.attachment = undefined
84
- this.pending = this.store.getSnapshot().target
85
- this.carrier.set({ stage: 'idle' })
86
- void this.dropGuest()
87
- }
88
-
89
- /** @param target - validated address, loaded without replacing the guest. */
90
- loadUrl(target: BrowserTarget, navigationId?: string): void {
91
- if (this.lifetime.signal.aborted) return
92
- const current = this.store.getSnapshot()
93
- if (this.ready && current.address === 'observed' && current.target?.url === target.url) {
94
- this.store.set({ ...current, navigationId, loading: true, documentReady: false })
95
- this.reload()
96
- return
97
- }
98
- this.revision++
99
- this.pending = target
100
- this.store.set({ ...current, navigationId, target, address: 'requested', loading: true, documentReady: false, error: undefined })
101
- this.persist(target)
102
- if (this.ready) this.loadPending()
103
- else this.initialize()
104
- }
105
-
106
- /** Move backward through Chromium history. */
107
- goBack(): void {
108
- if (this.store.getSnapshot().canGoBack) this.navigate('goBack')
109
- }
110
-
111
- /** Move forward through Chromium history. */
112
- goForward(): void {
113
- if (this.store.getSnapshot().canGoForward) this.navigate('goForward')
114
- }
115
-
116
- /** Reload the actual current page, or retry failed guest creation. */
117
- reload(): void {
118
- const current = this.store.getSnapshot()
119
- if (this.lifetime.signal.aborted || current.target === undefined) return
120
- if (!this.ready || current.error !== undefined) {
121
- this.revision++
122
- this.pending = current.target
123
- this.store.set({ ...current, loading: true, documentReady: false, error: undefined })
124
- if (this.ready) this.loadPending()
125
- else this.initialize()
126
- } else this.navigate('reload')
127
- }
128
-
129
- /** @returns after pending initialization and the owned guest have been released. */
130
- dispose(): Promise<void> {
131
- if (this.disposal !== undefined) return this.disposal
132
- this.lifetime.abort()
133
- this.pending = undefined
134
- this.disposal = (async () => {
135
- await this.dropGuest()
136
- // A cancelled createGuest can restart initialize() for a replacement
137
- // attachment inside its .finally. Await every generation so no guest
138
- // creation or lease release outlives disposal.
139
- for (let init = this.initializing; init !== undefined; init = this.initializing) {
140
- await init
141
- }
142
- await Promise.all(this.releases)
143
- })()
144
- this.presentation.dispose()
145
- return this.disposal
146
- }
147
-
148
- private navigate(command: 'goBack' | 'goForward' | 'reload'): void {
149
- if (this.lifetime.signal.aborted || !this.ready || this.element === undefined) return
150
- this.revision++
151
- this.pending = undefined
152
- this.store.set({ ...this.store.getSnapshot(), loading: true, documentReady: false, error: undefined })
153
- try { this.element[command]() }
154
- catch (error) { this.commandFailed(error) }
155
- }
156
-
157
- private initialize(): void {
158
- const attachment = this.attachment
159
- if (attachment === undefined || this.initializing !== undefined || this.element !== undefined || this.lifetime.signal.aborted) return
160
- const signal = AbortSignal.any([this.lifetime.signal, attachment.signal])
161
- this.initializing = this.createGuest(signal, attachment).catch(async (error: unknown) => {
162
- await this.dropGuest()
163
- if (!signal.aborted) this.commandFailed(error)
164
- }).finally(() => {
165
- this.initializing = undefined
166
- if (this.attachment !== attachment && this.pending !== undefined) this.initialize()
167
- })
168
- }
169
-
170
- /** True when a guest's attachment was invalidated by detach/remount or disposal. */
171
- private superseded(attachment: AbortController, signal: AbortSignal): boolean {
172
- return signal.aborted || this.attachment !== attachment
173
- }
174
-
175
- private async createGuest(attachmentSignal: AbortSignal, attachment: AbortController): Promise<void> {
176
- try {
177
- this.workspaceKey ??= await this.workspace(attachmentSignal)
178
- } catch (error) {
179
- // A cancelled/superseded attachment is not a bootstrap failure. Publishing
180
- // `failed` here would let the OLD mount fail the CURRENT occurrence's
181
- // initialization receipt; initialize()'s .finally starts the new guest.
182
- if (!this.superseded(attachment, attachmentSignal)) {
183
- this.carrier.set({ stage: 'failed', reason: 'workspace-unavailable',
184
- detail: (error instanceof Error ? error.message : String(error)).slice(0, 2000) })
185
- }
186
- throw error
187
- }
188
- if (attachmentSignal.aborted) return
189
- let reservation: Awaited<ReturnType<DesktopBrowserBridge['acquire']>>
190
- try {
191
- reservation = await (this.bridge.persistentSession === true
192
- ? this.bridge.acquire(this.workspaceKey, true) : this.bridge.acquire(this.workspaceKey))
193
- } catch (error) {
194
- if (!this.superseded(attachment, attachmentSignal)) {
195
- this.carrier.set({ stage: 'failed', reason: 'acquire-failed',
196
- detail: (error instanceof Error ? error.message : String(error)).slice(0, 2000) })
197
- }
198
- throw error
199
- }
200
- // oxlint-disable-next-line typescript/no-unnecessary-condition -- The signal can abort while acquire is pending.
201
- if (attachmentSignal.aborted) { await this.release(reservation.lease); return }
202
- this.lease = reservation.lease
203
- this.guestLifetime = new AbortController()
204
- const signal = AbortSignal.any([attachmentSignal, this.guestLifetime.signal])
205
- let element: WebviewElement
206
- try {
207
- element = this.presentation.createElement(reservation)
208
- } catch (error) {
209
- if (!this.superseded(attachment, attachmentSignal)) {
210
- this.carrier.set({ stage: 'failed', reason: 'guest-bootstrap-failed',
211
- detail: (error instanceof Error ? error.message : String(error)).slice(0, 2000) })
212
- }
213
- throw error
214
- }
215
- this.element = element
216
- this.carrier.set({ stage: 'guest' })
217
- const requested = (request: BrowserChildTabRequest): BrowserChildTabResult => {
218
- const result = dispatchChildTab(request, location.origin, this.options.openRequested, this.element === element && !signal.aborted)
219
- if (result.status === 'unsupported' && result.code !== 'guest-disposed') {
220
- this.store.set({ ...this.store.getSnapshot(), error: { code: 'browser-capability-unavailable', description: result.code } })
221
- }
222
- return result
223
- }
224
- const unsubscribeOpen = this.bridge.childTabs?.protocolVersion === 1
225
- ? this.bridge.childTabs.onRequested(reservation.lease, requested)
226
- : this.bridge.onOpenRequested(reservation.lease, url => { requested({ mode: 'url-only', url }) })
227
- signal.addEventListener('abort', unsubscribeOpen, { once: true })
228
- element.addEventListener('dom-ready', () => {
229
- this.documentLifetime?.abort()
230
- this.documentLifetime = new AbortController()
231
- installReferenceOverlay(source => element.executeJavaScript(source),
232
- intent => this.capture(intent, this.sessionId),
233
- AbortSignal.any([signal, this.documentLifetime.signal]))
234
- this.ready = true
235
- const guestId = element.getWebContentsId?.()
236
- this.carrier.set({ stage: 'ready', ...guestId === undefined ? {} : { guestId: String(guestId) } })
237
- this.store.set({ ...this.store.getSnapshot(), documentReady: true })
238
- this.observe(this.store.getSnapshot().address !== 'requested')
239
- this.loadPending()
240
- }, { signal })
241
- element.addEventListener('did-navigate', () => { this.observe(true) }, { signal })
242
- element.addEventListener('did-navigate-in-page', (event) => {
243
- if ((event as NavigationEvent).isMainFrame) this.observe(true)
244
- }, { signal })
245
- element.addEventListener('did-start-navigation', (event) => {
246
- if ((event as NavigationEvent).isMainFrame) {
247
- if (!(event as NavigationEvent).isInPlace) {
248
- this.documentLifetime?.abort()
249
- const guestId = element.getWebContentsId?.()
250
- this.carrier.set({ stage: 'guest', ...guestId === undefined ? {} : { guestId: String(guestId) } })
251
- }
252
- this.store.set({ ...this.store.getSnapshot(), loading: true,
253
- ...!(event as NavigationEvent).isInPlace ? { documentReady: false } : {}, error: undefined })
254
- }
255
- }, { signal })
256
- for (const name of ['did-start-loading', 'did-stop-loading', 'page-title-updated']) {
257
- element.addEventListener(name, () => {
258
- this.observe(name === 'page-title-updated' && this.store.getSnapshot().address === 'observed')
259
- }, { signal })
260
- }
261
- element.addEventListener('did-fail-load', (event) => {
262
- const failure = event as LoadFailureEvent
263
- if (failure.isMainFrame && failure.errorCode !== -3) {
264
- this.failed({ code: failure.errorCode, description: failure.errorDescription })
265
- }
266
- }, { signal })
267
- for (const name of ['render-process-gone', 'destroyed']) {
268
- element.addEventListener(name, () => { void this.dropGuest(); this.failed() }, { signal })
269
- }
270
- try {
271
- this.presentation.present(element)
272
- } catch (error) {
273
- if (!this.superseded(attachment, attachmentSignal)) {
274
- this.carrier.set({ stage: 'failed', reason: 'guest-bootstrap-failed',
275
- detail: (error instanceof Error ? error.message : String(error)).slice(0, 2000) })
276
- }
277
- throw error
278
- }
279
- }
280
-
281
- private loadPending(): void {
282
- const target = this.pending
283
- const element = this.element
284
- if (!this.ready || target === undefined || element === undefined) return
285
- const revision = this.revision
286
- this.pending = undefined
287
- void element.loadURL(target.url).catch((error: unknown) => {
288
- if (this.element !== element || this.lifetime.signal.aborted || this.revision !== revision) return
289
- if (typeof error === 'object' && error !== null && 'code' in error && error.code === 'ERR_ABORTED') return
290
- if (this.store.getSnapshot().error === undefined) this.commandFailed(error)
291
- })
292
- }
293
-
294
- private observe(committed: boolean): void {
295
- if (!this.ready || this.element === undefined || this.lifetime.signal.aborted) return
296
- try { this.observeReady(this.element, committed) }
297
- catch (error) { this.commandFailed(error) }
298
- }
299
-
300
- private observeReady(element: WebviewElement, committed: boolean): void {
301
- const current = this.store.getSnapshot()
302
- const parsed = committed ? parseBrowserAddress(element.getURL()) : undefined
303
- if (parsed?.ok && this.firstDocument) {
304
- // The lease-bearing bootstrap document is not a user history entry.
305
- element.clearHistory()
306
- this.firstDocument = false
307
- }
308
- let target = current.target
309
- let address = current.address
310
- if (parsed?.ok) {
311
- target = { ...parsed.target, title: element.getTitle() || parsed.target.title }
312
- address = 'observed'
313
- this.presentation.show(target.title)
314
- }
315
- const loading = current.error === undefined && element.isLoading()
316
- const canGoBack = element.canGoBack()
317
- const canGoForward = element.canGoForward()
318
- if (target?.url !== current.target?.url || target?.title !== current.target?.title || address !== current.address
319
- || loading !== current.loading || canGoBack !== current.canGoBack || canGoForward !== current.canGoForward) {
320
- this.store.set({ ...current, target, address, loading, canGoBack, canGoForward })
321
- }
322
- if (parsed?.ok && target !== undefined) this.persist(target)
323
- }
324
-
325
- private persist(target: BrowserTarget): void {
326
- if (target.url === this.checkpoint?.url && target.title === this.checkpoint.title) return
327
- this.checkpoint = target
328
- this.options.persist(browserAddressCheckpoint(target, this.revision))
329
- }
330
-
331
- private failed(error: BrowserLoadError = { code: undefined, description: undefined }): void {
332
- if (this.lifetime.signal.aborted) return
333
- const current = this.store.getSnapshot()
334
- this.store.set({ ...current, loading: false, error,
335
- canGoBack: this.ready && current.canGoBack, canGoForward: this.ready && current.canGoForward })
336
- }
337
-
338
- private commandFailed(error: unknown): void {
339
- console.error('Desktop browser operation failed', error)
340
- this.failed()
341
- }
342
-
343
- private dropGuest(): Promise<void> {
344
- this.documentLifetime?.abort()
345
- this.documentLifetime = undefined
346
- this.guestLifetime?.abort()
347
- this.guestLifetime = undefined
348
- this.presentation.clear()
349
- this.element = undefined
350
- this.ready = false
351
- this.firstDocument = true
352
- const lease = this.lease
353
- this.lease = undefined
354
- return lease === undefined ? Promise.resolve() : this.release(lease)
355
- }
356
-
357
- private release(lease: DesktopBrowserLeaseId): Promise<void> {
358
- const released = this.bridge.release(lease)
359
- .catch((error: unknown) => { console.error('Desktop browser guest release failed', error) })
360
- .finally(() => { this.releases.delete(released) })
361
- this.releases.add(released)
362
- return released
363
- }
364
- }
@@ -1,138 +0,0 @@
1
- /** Electron tag DOM inside a Sidebar-owned, stable content container. */
2
- import type { DesktopBrowserReservation } from '../../types.ts'
3
- import type { BrowserPresentation } from '../view/BrowserPresentation.ts'
4
- import css from '../view/Browser.module.css'
5
-
6
- /** The Electron tag API used by its navigation provider. */
7
- export interface WebviewElement extends HTMLElement {
8
- loadURL(url: string): Promise<void>
9
- executeJavaScript(source: string): Promise<unknown>
10
- getURL(): string
11
- getTitle(): string
12
- canGoBack(): boolean
13
- canGoForward(): boolean
14
- clearHistory(): void
15
- goBack(): void
16
- goForward(): void
17
- reload(): void
18
- isLoading(): boolean
19
- getWebContentsId?(): number
20
- getZoomFactor(): number
21
- setZoomFactor(factor: number): void
22
- }
23
-
24
- /** Physical attachment notifications; hiding a retained Sidebar body emits neither. */
25
- export interface ElectronPresentationEvents {
26
- readonly mounted: () => void
27
- readonly unmounted: () => void
28
- }
29
-
30
- /** Owns tag creation and attachment, without measuring or following another element. */
31
- export class ElectronWebviewPresentation implements BrowserPresentation {
32
- private element: WebviewElement | undefined
33
- private host: HTMLElement | undefined
34
- private zoomRevision = 0
35
- private scaleQuery: MediaQueryList | undefined
36
- private readonly ready = (): void => { void this.syncZoom() }
37
- private readonly scaleChanged = (): void => {
38
- this.watchScale()
39
- void this.syncZoom()
40
- }
41
-
42
- constructor(private readonly events: ElectronPresentationEvents) {}
43
-
44
- /** @param viewportId - committed content container. @returns ends attachment and releases its guest. */
45
- mount(viewportId: string): () => void {
46
- const host = document.getElementById(viewportId)
47
- if (host === null) throw new Error('Electron presentation: content container is not mounted')
48
- if (this.host !== undefined) this.events.unmounted()
49
- this.host = host
50
- this.watchScale()
51
- this.events.mounted()
52
- return () => {
53
- if (this.host !== host) return
54
- this.events.unmounted()
55
- this.unwatchScale()
56
- this.host = undefined
57
- }
58
- }
59
-
60
- /**
61
- * Configure a detached webview for an approved guest reservation.
62
- * @param reservation - main-approved partition and bootstrap lease.
63
- * @returns a detached, configured webview.
64
- */
65
- createElement(reservation: DesktopBrowserReservation): WebviewElement {
66
- const element = document.createElement('webview') as WebviewElement
67
- element.className = css.webview as string
68
- element.dataset.sidebarBrowserFrame = 'webview'
69
- element.setAttribute('name', reservation.lease)
70
- element.setAttribute('partition', reservation.partition)
71
- element.setAttribute('allowpopups', '')
72
- element.setAttribute('src', 'about:blank#' + reservation.lease)
73
- return element
74
- }
75
-
76
- /**
77
- * Attach a prepared guest, removing any previous guest DOM from the container.
78
- * @param element - configured guest with its navigation listeners already installed.
79
- * @throws when no content container is mounted.
80
- */
81
- present(element: WebviewElement): void {
82
- if (this.host === undefined) throw new Error('Electron presentation: cannot attach without a content container')
83
- this.clear()
84
- this.element = element
85
- element.addEventListener('dom-ready', this.ready)
86
- this.host.append(element)
87
- }
88
-
89
- /**
90
- * Set the guest element's accessible label.
91
- * @param title - observed document title.
92
- */
93
- show(title: string): void {
94
- this.element?.setAttribute('aria-label', title)
95
- }
96
-
97
- /** Destroy only the guest DOM; a replacement may use the same mounted container. */
98
- clear(): void {
99
- this.zoomRevision++
100
- this.element?.removeEventListener('dom-ready', this.ready)
101
- this.element?.remove()
102
- this.element = undefined
103
- }
104
-
105
- /** Destroy the guest DOM and release its content container. */
106
- dispose(): void {
107
- this.clear()
108
- this.unwatchScale()
109
- this.host = undefined
110
- }
111
-
112
- private watchScale(): void {
113
- this.unwatchScale()
114
- this.scaleQuery = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)
115
- this.scaleQuery.addEventListener('change', this.scaleChanged)
116
- }
117
-
118
- private unwatchScale(): void {
119
- this.scaleQuery?.removeEventListener('change', this.scaleChanged)
120
- this.scaleQuery = undefined
121
- }
122
-
123
- private async syncZoom(): Promise<void> {
124
- const element = this.element
125
- if (element === undefined) return
126
- const revision = ++this.zoomRevision
127
- try {
128
- const guestRatio = await element.executeJavaScript('window.devicePixelRatio')
129
- if (this.element !== element || revision !== this.zoomRevision) return
130
- if (typeof guestRatio !== 'number' || !Number.isFinite(guestRatio) || guestRatio <= 0) return
131
- const zoom = element.getZoomFactor()
132
- const factor = zoom * window.devicePixelRatio / guestRatio
133
- if (Math.abs(zoom - factor) > 0.0001) element.setZoomFactor(factor)
134
- } catch (error) {
135
- if (this.element === element && revision === this.zoomRevision) console.error('Electron presentation: cannot align guest zoom', error)
136
- }
137
- }
138
- }
@@ -1,45 +0,0 @@
1
- /** Session-owned native child addresses; no URL replay or replacement guest. */
2
- import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit'
3
- import type { DesktopNativeChild, DesktopNativeChildTabs } from '../../types.ts'
4
- import { readTabHandle } from '../../browser/handles.ts'
5
-
6
- export class NativeChildPresentation {
7
- private readonly children = new Map<string, DesktopNativeChild>()
8
-
9
- constructor(readonly api: DesktopNativeChildTabs, private readonly owner: string,
10
- private readonly open: (tab: TabId) => boolean, private readonly close: (tab: TabId) => void) {}
11
-
12
- child(tab: TabId): DesktopNativeChild | undefined { return this.children.get(tab) }
13
-
14
- listen(parent: string): () => void {
15
- const owned = new Set<string>()
16
- let active = true
17
- let unsubscribeClosed: (() => void) | undefined
18
- const created = this.api.onCreated(parent, child => {
19
- if (!active || child.opener !== parent) return
20
- const address = readTabHandle(child.child), opener = readTabHandle(parent)
21
- if (address.owner !== this.owner || address.owner !== opener.owner || address.session !== opener.session
22
- || this.children.has(address.tab)) return
23
- this.children.set(address.tab, child)
24
- owned.add(child.child)
25
- if (!this.open(address.tab as TabId)) {
26
- this.children.delete(address.tab)
27
- owned.delete(child.child)
28
- }
29
- })
30
- unsubscribeClosed = this.api.onClosed(parent, child => {
31
- if (child.opener !== parent || !owned.has(child.child)) return
32
- const address = readTabHandle(child.child)
33
- if (this.children.get(address.tab)?.request !== child.request) return
34
- owned.delete(child.child)
35
- this.children.delete(address.tab)
36
- this.close(address.tab as TabId)
37
- if (!active && owned.size === 0) unsubscribeClosed?.()
38
- })
39
- return () => {
40
- active = false
41
- created()
42
- if (owned.size === 0) unsubscribeClosed?.()
43
- }
44
- }
45
- }