dsh-builtin-browser 1.0.3 → 1.0.4

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 (293) hide show
  1. package/README.en.md +89 -0
  2. package/browser-extension/constants.mjs +20 -0
  3. package/browser-extension/controller.mjs +293 -0
  4. package/browser-extension/locales.mjs +15 -0
  5. package/browser-extension/manifest.json +12 -0
  6. package/browser-extension/options.html +14 -0
  7. package/browser-extension/options.mjs +9 -0
  8. package/browser-extension/permission-guard.mjs +13 -0
  9. package/browser-extension/worker.mjs +74 -0
  10. package/package.json +20 -2
  11. package/scripts/build-client.mjs +305 -0
  12. package/scripts/build.mjs +69 -0
  13. package/scripts/bundle-host.mjs +28 -0
  14. package/scripts/fix-exports.mjs +40 -0
  15. package/scripts/install-electron.mjs +101 -0
  16. package/scripts/pack.mjs +99 -0
  17. package/scripts/publish-manifest.mjs +56 -0
  18. package/scripts/verify-exports.mjs +58 -0
  19. package/scripts/verify-preview-sdk.mjs +93 -0
  20. package/skills/dsh-builtin-browser/SKILL.md +98 -0
  21. package/skills/dsh-builtin-browser/references/batch.md +68 -0
  22. package/skills/dsh-builtin-browser/references/deliver.md +31 -0
  23. package/skills/dsh-builtin-browser/references/locate.md +11 -0
  24. package/skills/dsh-builtin-browser/references/recover.md +11 -0
  25. package/skills/dsh-builtin-browser/references/verify.md +13 -0
  26. package/skills/dsh-debug-host/SKILL.md +56 -0
  27. package/skills/dsh-debug-self/SKILL.md +50 -0
  28. package/src/bridge-compatibility.ts +39 -0
  29. package/src/browser/anti-bot.ts +251 -0
  30. package/src/browser/deep-dom.ts +40 -0
  31. package/src/browser/handles.ts +89 -0
  32. package/src/browser/runtime.ts +578 -0
  33. package/src/browser/takeover-target.ts +45 -0
  34. package/src/browser/types.ts +870 -0
  35. package/src/browser-electron/authenticated-route.ts +109 -0
  36. package/src/browser-electron/automatic-maintenance.ts +736 -0
  37. package/src/browser-electron/bridge-auto.ts +159 -0
  38. package/src/browser-electron/bridge-connection.ts +386 -0
  39. package/src/browser-electron/bridge-endpoint.ts +129 -0
  40. package/src/browser-electron/bridge-install.ts +290 -0
  41. package/src/browser-electron/bridge-maintenance.ts +189 -0
  42. package/src/browser-electron/bridge-status.ts +386 -0
  43. package/src/browser-electron/desktop-bridge-host.ts +253 -0
  44. package/src/browser-electron/desktop-identity.ts +353 -0
  45. package/src/browser-electron/desktop-shell.ts +100 -0
  46. package/src/browser-electron/document-readiness.ts +45 -0
  47. package/src/browser-electron/electron-provision.ts +347 -0
  48. package/src/browser-electron/entry.ts +1378 -0
  49. package/src/browser-electron/ephemeral-profile.ts +189 -0
  50. package/src/browser-electron/extension-browser.ts +230 -0
  51. package/src/browser-electron/extension-setup.ts +67 -0
  52. package/src/browser-electron/file-write.ts +31 -0
  53. package/src/browser-electron/foreground-watch.ts +142 -0
  54. package/src/browser-electron/guest-cookie-jar.ts +177 -0
  55. package/src/browser-electron/guest-cookie-store.ts +59 -0
  56. package/src/browser-electron/guest-css-runtime.ts +76 -0
  57. package/src/browser-electron/guest-css.ts +68 -0
  58. package/src/browser-electron/guest-route.ts +716 -0
  59. package/src/browser-electron/guest-runtime.ts +408 -0
  60. package/src/browser-electron/guest-storage-runtime.ts +54 -0
  61. package/src/browser-electron/guest-storage.ts +120 -0
  62. package/src/browser-electron/history-store.ts +224 -0
  63. package/src/browser-electron/host-main.ts +1385 -0
  64. package/src/browser-electron/host-patch-maintenance.ts +121 -0
  65. package/src/browser-electron/http-body.ts +65 -0
  66. package/src/browser-electron/json-reply.ts +47 -0
  67. package/src/browser-electron/maintenance-broker.ts +166 -0
  68. package/src/browser-electron/maintenance-lifecycle.ts +91 -0
  69. package/src/browser-electron/maintenance-route.ts +68 -0
  70. package/src/browser-electron/missing-system-browser.ts +114 -0
  71. package/src/browser-electron/open-slot.ts +49 -0
  72. package/src/browser-electron/paths.ts +25 -0
  73. package/src/browser-electron/preferred-browser.ts +130 -0
  74. package/src/browser-electron/preview-route.ts +215 -0
  75. package/src/browser-electron/process-ownership.ts +174 -0
  76. package/src/browser-electron/process.ts +23 -0
  77. package/src/browser-electron/profile-checkpoint.ts +187 -0
  78. package/src/browser-electron/profile-command.ts +47 -0
  79. package/src/browser-electron/profile-extension.ts +129 -0
  80. package/src/browser-electron/profile-lease.ts +211 -0
  81. package/src/browser-electron/profile-residue.ts +49 -0
  82. package/src/browser-electron/provider-core.ts +1107 -0
  83. package/src/browser-electron/provider-interaction.ts +1034 -0
  84. package/src/browser-electron/provider-media.ts +589 -0
  85. package/src/browser-electron/provider-navigation.ts +323 -0
  86. package/src/browser-electron/provider-observation.ts +664 -0
  87. package/src/browser-electron/provider-tabs.ts +372 -0
  88. package/src/browser-electron/provider.ts +666 -0
  89. package/src/browser-electron/reference-route.ts +598 -0
  90. package/src/browser-electron/remote-host.ts +1538 -0
  91. package/src/browser-electron/rpc-input.ts +13 -0
  92. package/src/browser-electron/rpc-ops.ts +41 -0
  93. package/src/browser-electron/runtime-diagnostics.ts +38 -0
  94. package/src/browser-electron/runtime-route.ts +105 -0
  95. package/src/browser-electron/runtime-status.ts +309 -0
  96. package/src/browser-electron/settings-route.ts +64 -0
  97. package/src/browser-electron/settings-store.ts +593 -0
  98. package/src/browser-electron/shortcuts-route.ts +112 -0
  99. package/src/browser-electron/sidebar-only-host.ts +300 -0
  100. package/src/browser-electron/startpage-shortcuts.ts +213 -0
  101. package/src/browser-electron/system-browser.ts +1850 -0
  102. package/src/browser-electron/tauri-host.ts +194 -0
  103. package/src/browser-electron/timing.ts +16 -0
  104. package/src/browser-electron/virtual-cursor.ts +162 -0
  105. package/src/browser-electron/windows-system.ts +24 -0
  106. package/src/browser-reference/delivery.ts +384 -0
  107. package/src/browser-reference/entry.ts +631 -0
  108. package/src/browser-reference/export.ts +339 -0
  109. package/src/browser-reference/import.ts +303 -0
  110. package/src/browser-reference/page-script.ts +1537 -0
  111. package/src/browser-reference/service.ts +1346 -0
  112. package/src/browser-reference/store.ts +172 -0
  113. package/src/browser-reference/text-quote.ts +219 -0
  114. package/src/browser-reference/types.ts +195 -0
  115. package/src/browser-reference/visible.ts +367 -0
  116. package/src/browser-reference/web-sources.ts +106 -0
  117. package/src/client/apply-guard.ts +22 -0
  118. package/src/client/browser/BrowserController.ts +693 -0
  119. package/src/client/browser/BrowserFrame.ts +78 -0
  120. package/src/client/browser/BrowserNavigation.ts +169 -0
  121. package/src/client/browser/BrowserPage.ts +23 -0
  122. package/src/client/browser/BrowserPersistence.ts +44 -0
  123. package/src/client/browser/IframeImpl.ts +182 -0
  124. package/src/client/browser/child-tabs.ts +14 -0
  125. package/src/client/browser/frame-history.ts +125 -0
  126. package/src/client/browser/frame-state.ts +27 -0
  127. package/src/client/browser/iframe-reference.ts +67 -0
  128. package/src/client/browser/initialization.ts +262 -0
  129. package/src/client/browser/omnibox.ts +243 -0
  130. package/src/client/browser/store.ts +38 -0
  131. package/src/client/browser/takeover-channel.ts +72 -0
  132. package/src/client/browser/url.ts +46 -0
  133. package/src/client/browser/web-reference-source.ts +56 -0
  134. package/src/client/css-modules.d.ts +4 -0
  135. package/src/client/definition.tsx +36 -0
  136. package/src/client/electron/ElectronWebViewImpl.ts +371 -0
  137. package/src/client/electron/ElectronWebviewPresentation.ts +140 -0
  138. package/src/client/electron/NativeChildPresentation.ts +53 -0
  139. package/src/client/electron/NativeViewPage.ts +265 -0
  140. package/src/client/electron/pages.ts +23 -0
  141. package/src/client/electron/reference-overlay.ts +53 -0
  142. package/src/client/electron/workspace.ts +33 -0
  143. package/src/client/index.ts +333 -0
  144. package/src/client/locales.ts +860 -0
  145. package/src/client/pages.ts +28 -0
  146. package/src/client/reference/client/BrowserRefLink.tsx +142 -0
  147. package/src/client/reference/client/draft-reference.ts +167 -0
  148. package/src/client/reference/client/index.ts +7 -0
  149. package/src/client/reference/client/ordered-submission.ts +108 -0
  150. package/src/client/reference/client/pending-delivery.ts +216 -0
  151. package/src/client/reference/client/plugin.ts +208 -0
  152. package/src/client/reference/client/production/ReferenceCapsules.tsx +345 -0
  153. package/src/client/reference/client/production/ReferenceDock.module.css +193 -0
  154. package/src/client/reference/client/production/ReferenceDock.tsx +6 -0
  155. package/src/client/reference/client/production/ReferenceFeedback.tsx +15 -0
  156. package/src/client/reference/client/production/ReferenceMath.tsx +44 -0
  157. package/src/client/reference/client/production/ReferenceText.tsx +36 -0
  158. package/src/client/reference/client/production/assembly.ts +447 -0
  159. package/src/client/reference/client/production/asset-store.ts +144 -0
  160. package/src/client/reference/client/production/availability.ts +72 -0
  161. package/src/client/reference/client/production/bytes.ts +36 -0
  162. package/src/client/reference/client/production/composer-attachments.ts +44 -0
  163. package/src/client/reference/client/production/delivery-client.ts +211 -0
  164. package/src/client/reference/client/production/draft-adapter.ts +512 -0
  165. package/src/client/reference/client/production/http-transport.ts +212 -0
  166. package/src/client/reference/client/production/production-submission.ts +70 -0
  167. package/src/client/reference/client/production/protocol.ts +234 -0
  168. package/src/client/reference/client/production/reference-card.ts +240 -0
  169. package/src/client/reference/client/production/reference-labels.ts +29 -0
  170. package/src/client/reference/client/production/reply-link-bridge.ts +222 -0
  171. package/src/client/reference/client/production/reveal.ts +215 -0
  172. package/src/client/reference/client/production/runtime.ts +1056 -0
  173. package/src/client/reference/client/production/snapshot-adapter.ts +154 -0
  174. package/src/client/reference/client/production/source-marker.ts +99 -0
  175. package/src/client/reference/client/production/source-opener.ts +55 -0
  176. package/src/client/reference/client/production/styles.ts +104 -0
  177. package/src/client/reference/client/production/user-text-rule.ts +67 -0
  178. package/src/client/reference/client/reveal.ts +109 -0
  179. package/src/client/reference/client/scheme.ts +114 -0
  180. package/src/client/reference/client/session-schedule.ts +36 -0
  181. package/src/client/reference/client/types.ts +168 -0
  182. package/src/client/reference/css-modules.d.ts +4 -0
  183. package/src/client/reference/index.ts +11 -0
  184. package/src/client/reference-capture-owner.ts +162 -0
  185. package/src/client/reference-intents.ts +36 -0
  186. package/src/client/settings/index.ts +42 -0
  187. package/src/client/settings/mount-guard.ts +31 -0
  188. package/src/client/settings/panel.ts +2768 -0
  189. package/src/client/shortcut-open.ts +30 -0
  190. package/src/client/startpage/binding.ts +99 -0
  191. package/src/client/startpage/controller.ts +300 -0
  192. package/src/client/startpage/model.ts +279 -0
  193. package/src/client/view/Browser.module.css +751 -0
  194. package/src/client/view/BrowserBody.tsx +315 -0
  195. package/src/client/view/BrowserPresentation.ts +9 -0
  196. package/src/client/view/BrowserTitle.tsx +17 -0
  197. package/src/client/view/IframePresentation.ts +365 -0
  198. package/src/client/view/StartPage.tsx +598 -0
  199. package/src/client/view/TakeoverBanner.tsx +21 -0
  200. package/src/compat/host-features.ts +92 -0
  201. package/src/index.ts +110 -0
  202. package/src/reference-owner.ts +5 -0
  203. package/src/reference-page.ts +9 -0
  204. package/src/reference-source.ts +3 -0
  205. package/src/reference-text.ts +219 -0
  206. package/src/startpage-settings.ts +103 -0
  207. package/src/startpage.ts +71 -0
  208. package/src/takeover-protocol.ts +28 -0
  209. package/src/tool-browser/block-recovery.ts +85 -0
  210. package/src/tool-browser/code-tool.ts +555 -0
  211. package/src/tool-browser/code-worker.ts +725 -0
  212. package/src/tool-browser/element-fields.ts +167 -0
  213. package/src/tool-browser/errors.ts +40 -0
  214. package/src/tool-browser/index.ts +265 -0
  215. package/src/tool-browser/page-probe.ts +675 -0
  216. package/src/tool-browser/panel-page.ts +126 -0
  217. package/src/tool-browser/probe-client.ts +183 -0
  218. package/src/tool-browser/screenshot-annotations.ts +131 -0
  219. package/src/tool-browser/screenshot-image.ts +49 -0
  220. package/src/tool-browser/state.ts +375 -0
  221. package/src/tool-browser/takeover.ts +199 -0
  222. package/src/tool-browser/tools-debug.ts +806 -0
  223. package/src/tool-browser/tools-interaction.ts +956 -0
  224. package/src/tool-browser/tools-navigation.ts +786 -0
  225. package/src/tool-browser/tools-observation.ts +474 -0
  226. package/src/tool-browser/tools-reference.ts +294 -0
  227. package/src/types/electron-shim.d.ts +144 -0
  228. package/src/types.ts +85 -0
  229. package/src/web-guest.ts +35 -0
  230. package/tools/accept-desktop.mjs +148 -0
  231. package/dist/client.d.cts +0 -516
  232. package/dist/client.d.mts +0 -516
  233. package/dist/index.cjs +0 -92
  234. package/dist/index.d.mts +0 -2960
  235. package/dist/index.mjs +0 -24
  236. package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
  237. package/dsh-builtin-browser-1.0.3.tgz +0 -0
  238. package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  239. package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  240. package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  241. package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  242. package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  243. package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  244. package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  245. package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  246. package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  247. package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  248. package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  249. package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  250. package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  251. package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  252. package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  253. package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  254. package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  255. package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  256. package/dsh-host-patch/sources/manifest.json +0 -218
  257. package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  258. package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  259. package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  260. package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  261. package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  262. package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  263. package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  264. package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  265. package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  266. package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  267. package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  268. package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  269. package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  270. package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  271. package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  272. package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  273. package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  274. package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  275. package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  276. package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  277. package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  278. package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  279. package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  280. package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  281. package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  282. package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  283. package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  284. package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  285. package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  286. package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  287. package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  288. package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  289. package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  290. package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  291. package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  292. package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  293. package/dsh-host-patch/sources/series.json +0 -260
@@ -0,0 +1,353 @@
1
+ /**
2
+ * What proves a directory is a DSH Desktop install.
3
+ *
4
+ * Reported as issue #40. Every reader of an install directory used to accept a *generic* Electron
5
+ * layout (`resources/app/lib/main.js` or `resources/app.asar`) as proof, and that is not proof of
6
+ * anything: any Electron app has it. The consequence was measured — a throwaway app in a temp
7
+ * directory, whose own package.json said `unrelated-meeting-app`, was accepted by discovery, got a
8
+ * "bridge not installed" verdict with a ready-to-run installer command aimed at it, and (with that
9
+ * command) had its entry file rewritten and the bridge copied in.
10
+ *
11
+ * So identity is one rule, in one file (`desktop-bridge/desktop-identity.json`), read by both the
12
+ * installer and this module. Nothing else may decide what a DSH Desktop install is.
13
+ *
14
+ * Two properties are load-bearing and are why this is not a one-line `name ===` check:
15
+ *
16
+ * - **The archive wins.** Electron loads `resources/app.asar` in preference to `resources/app`, and
17
+ * a desktop update leaves the old extraction lying around. Reading identity from the extraction
18
+ * while the archive holds a different build would verify the wrong bytes, so when the archive is
19
+ * present that is what is read — and the sibling directory is not consulted at all.
20
+ * - **Unreadable means not DSH.** Every failure path (missing file, truncated pickle, unsupported
21
+ * archive version, malformed JSON, unreadable name) refuses. There is no "assume yes" branch: the
22
+ * caller is about to write into, or delete from, this directory.
23
+ * @module dsh-browser/browser-electron/desktop-identity
24
+ */
25
+ import { closeSync, existsSync, openSync, readFileSync, readSync } from 'node:fs'
26
+ import { createRequire } from 'node:module'
27
+ import { join } from 'node:path'
28
+
29
+ // Electron's patched fs opens an ASAR as a virtual directory. Identity needs the raw archive
30
+ // header and file offsets, including when this reader runs in the Desktop's Node-mode worker.
31
+ const archiveFs: Pick<typeof import('node:fs'), 'openSync' | 'readSync' | 'closeSync' | 'existsSync'> = (() => {
32
+ try { return createRequire(import.meta.url)('original-fs') as typeof import('node:fs') }
33
+ catch { return { openSync, readSync, closeSync, existsSync } }
34
+ })()
35
+
36
+ /** The identity rule, as data. */
37
+ /** Where one kind of install keeps its resources, executable and CLI launcher (all relative). */
38
+ export interface DesktopLayout {
39
+ readonly name: string
40
+ /** The layout applies when this path exists under the install root; the default has none. */
41
+ readonly marker?: string
42
+ readonly resources: string
43
+ readonly executable: string
44
+ readonly cliLauncher: string
45
+ }
46
+
47
+ interface IdentityRule {
48
+ readonly packageNames: readonly string[]
49
+ readonly mainEntry: string
50
+ /** Main entries of look-alike Desktops that are recognized only to be refused, with the reason. */
51
+ readonly unsupportedMainEntries?: Readonly<Record<string, string>>
52
+ readonly layouts: readonly DesktopLayout[]
53
+ }
54
+
55
+ /**
56
+ * The rule shipped in `desktop-bridge/desktop-identity.json`, used when the file cannot be read.
57
+ *
58
+ * A copy exists here only as a fallback for a broken package layout; the test suite asserts that it
59
+ * equals the JSON, so the two can never drift apart silently.
60
+ */
61
+ export const FALLBACK_RULE: IdentityRule = {
62
+ packageNames: ['@deepseek-ai/dsh-desktop', 'dsh-desktop'],
63
+ mainEntry: 'lib/main.js',
64
+ unsupportedMainEntries: {
65
+ 'out/main/index.js': 'the electron-vite layout of a third-party DSH Desktop (dataelement/dsh-desktop, issue #62), which shares the package name but not the DeepSeek Harness Desktop shell the bridge patches',
66
+ },
67
+ layouts: [
68
+ { name: 'macos-bundle', marker: 'Contents/Info.plist', resources: 'Contents/Resources', executable: 'Contents/MacOS/DeepSeek Harness', cliLauncher: 'runtime/cli/bin/dsh' },
69
+ { name: 'directory', resources: 'resources', executable: 'DeepSeek Harness.exe', cliLauncher: 'runtime/cli/bin/dsh.cmd' },
70
+ ],
71
+ }
72
+
73
+ /** A verified install. */
74
+ export interface DesktopIdentity {
75
+ readonly ok: true
76
+ /** The install root that was verified. */
77
+ readonly root: string
78
+ /** Which shape was verified — the archive when it exists, the extraction only without one. */
79
+ readonly layout: 'packed' | 'unpacked'
80
+ /** `name` from the package the caller will actually run. */
81
+ readonly packageName: string
82
+ /** `version`, when the package declares one. */
83
+ readonly version?: string
84
+ }
85
+
86
+ /** A refusal, with a reason a human can act on. */
87
+ export interface IdentityRefusal {
88
+ readonly ok: false
89
+ readonly reason: string
90
+ /**
91
+ * Set once the manifest has named a DSH Desktop package: `third-party-shell` for a layout the rule
92
+ * attributes to another shell, `official-unsupported` for an official package without the patched entry.
93
+ */
94
+ readonly shell?: 'third-party-shell' | 'official-unsupported'
95
+ /** The manifest version, when the refusal came after reading it. */
96
+ readonly version?: string
97
+ }
98
+
99
+ function versionOf(manifest: { version?: unknown }): { version?: string } {
100
+ return typeof manifest.version === 'string' ? { version: manifest.version } : {}
101
+ }
102
+
103
+ /**
104
+ * Read the identity rule.
105
+ *
106
+ * Resolved relative to this module, which in both the repository and the published tarball puts
107
+ * `desktop-bridge/` beside `lib/`. A missing file is not fatal — the fallback is the same rule —
108
+ * but a *malformed* one is an error the caller should not ignore, so it is reported through the
109
+ * refusal path rather than silently swapped for the fallback.
110
+ * @returns the rule, or an error string.
111
+ */
112
+ export function readIdentityRule(): IdentityRule | { readonly error: string } {
113
+ try {
114
+ const path = new URL('../../desktop-bridge/desktop-identity.json', import.meta.url)
115
+ const raw = JSON.parse(readFileSync(path, 'utf8')) as Partial<IdentityRule>
116
+ const names = raw.packageNames
117
+ const main = raw.mainEntry
118
+ if (!Array.isArray(names) || names.length === 0 || names.some(n => typeof n !== 'string')) {
119
+ return { error: 'desktop-identity.json: packageNames must be a non-empty array of strings' }
120
+ }
121
+ if (typeof main !== 'string' || main === '') {
122
+ return { error: 'desktop-identity.json: mainEntry must be a non-empty string' }
123
+ }
124
+ const layouts = raw.layouts
125
+ const field = (value: unknown): boolean => typeof value === 'string' && value !== ''
126
+ if (!Array.isArray(layouts) || layouts.length === 0
127
+ || layouts.some(l => l === null || typeof l !== 'object' || !field(l.name) || !field(l.resources) || !field(l.executable) || !field(l.cliLauncher)
128
+ || (l.marker !== undefined && !field(l.marker)))
129
+ || layouts[layouts.length - 1]?.marker !== undefined) {
130
+ return { error: 'desktop-identity.json: layouts must be a non-empty array whose last entry has no marker' }
131
+ }
132
+ const unsupported = raw.unsupportedMainEntries
133
+ if (unsupported !== undefined && (unsupported === null || typeof unsupported !== 'object' || Array.isArray(unsupported)
134
+ || Object.entries(unsupported).some(([entry, reason]) => entry === '' || !field(reason)))) {
135
+ return { error: 'desktop-identity.json: unsupportedMainEntries must map entry paths to reasons' }
136
+ }
137
+ return unsupported === undefined
138
+ ? { packageNames: names, mainEntry: main, layouts }
139
+ : { packageNames: names, mainEntry: main, unsupportedMainEntries: unsupported, layouts }
140
+ } catch (error) {
141
+ if (error instanceof Error && 'code' in error && (error as NodeJS.ErrnoException).code === 'ENOENT') {
142
+ return FALLBACK_RULE
143
+ }
144
+ return { error: `desktop-identity.json could not be read: ${String(error)}` }
145
+ }
146
+ }
147
+
148
+ function layoutOf(rule: IdentityRule, installRoot: string): DesktopLayout {
149
+ return rule.layouts.find(layout => layout.marker === undefined || existsSync(join(installRoot, ...layout.marker.split('/'))))
150
+ ?? rule.layouts[rule.layouts.length - 1] as DesktopLayout
151
+ }
152
+
153
+ /**
154
+ * The layout of an install root: a macOS `.app` bundle or a plain directory (Windows).
155
+ * Decided by the install's own shape rather than the host OS, so every platform reads it the same.
156
+ * @param installRoot - the install directory.
157
+ * @returns the layout, or an error when the identity rule cannot be read.
158
+ */
159
+ export function desktopLayout(installRoot: string): DesktopLayout | { readonly error: string } {
160
+ const rule = readIdentityRule()
161
+ return 'error' in rule ? rule : layoutOf(rule, installRoot)
162
+ }
163
+
164
+ /**
165
+ * Absolute paths an install keeps, from its layout.
166
+ * @param installRoot - the install directory.
167
+ * @returns resources directory, GUI executable and CLI launcher.
168
+ */
169
+ export function desktopPaths(installRoot: string): { readonly resources: string; readonly executable: string; readonly cliLauncher: string } {
170
+ const layout = desktopLayout(installRoot)
171
+ if ('error' in layout) throw new Error(layout.error)
172
+ const resources = join(installRoot, ...layout.resources.split('/'))
173
+ return { resources, executable: join(installRoot, ...layout.executable.split('/')), cliLauncher: join(resources, ...layout.cliLauncher.split('/')) }
174
+ }
175
+
176
+ /**
177
+ * One entry of a Chromium pickle header.
178
+ *
179
+ * `offset` is relative to the content area that follows the header; `unpacked` entries carry no
180
+ * bytes in the archive and live beside it instead.
181
+ */
182
+ interface AsarEntry {
183
+ readonly size: number
184
+ readonly offset?: string
185
+ readonly unpacked?: boolean
186
+ readonly files?: Record<string, AsarEntry>
187
+ }
188
+
189
+ /**
190
+ * Parse an asar header, the same way the installer does.
191
+ *
192
+ * Layout, for the next reader: an 8-byte outer pickle (`[size][jsonLength]`), then the header
193
+ * pickle whose first 4 bytes are the JSON length, then the JSON tree. File content starts right
194
+ * after the header pickle.
195
+ * @param archive - the archive path.
196
+ * @returns the header tree and the offset where content starts, or an error string.
197
+ */
198
+ function readAsarHeader(archive: string): { header: { files?: Record<string, AsarEntry> }; contentBase: number } | { error: string } {
199
+ let fd: number | undefined
200
+ try {
201
+ fd = archiveFs.openSync(archive, 'r')
202
+ const outer = Buffer.alloc(8)
203
+ if (archiveFs.readSync(fd, outer, 0, 8, 0) !== 8) return { error: 'the archive header is truncated' }
204
+ const headerSize = outer.readUInt32LE(4)
205
+ if (headerSize < 8 || headerSize > 64 * 1024 * 1024) return { error: `implausible archive header size (${headerSize})` }
206
+ const header = Buffer.alloc(headerSize)
207
+ if (archiveFs.readSync(fd, header, 0, headerSize, 8) !== headerSize) return { error: 'the archive header is truncated' }
208
+ const jsonLength = header.readUInt32LE(4)
209
+ if (jsonLength <= 0 || jsonLength > headerSize - 8) return { error: 'the archive header has an implausible JSON length' }
210
+ return { header: JSON.parse(header.toString('utf8', 8, 8 + jsonLength)), contentBase: 8 + headerSize }
211
+ } catch (error) {
212
+ return { error: `the archive header could not be read: ${String(error)}` }
213
+ } finally {
214
+ if (fd !== undefined) {
215
+ try { archiveFs.closeSync(fd) } catch { /* already closed */ }
216
+ }
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Walk a slash-separated path inside an asar header tree.
222
+ * @param tree - the header's `files` node.
223
+ * @param path - e.g. `lib/main.js`.
224
+ * @returns the entry, or undefined when the path does not exist.
225
+ */
226
+ function entryAt(tree: Record<string, AsarEntry> | undefined, path: string): AsarEntry | undefined {
227
+ let node: AsarEntry | undefined
228
+ let files: Record<string, AsarEntry> | undefined = tree
229
+ for (const part of path.split('/')) {
230
+ if (files === undefined) return undefined
231
+ node = files[part]
232
+ if (node === undefined) return undefined
233
+ files = node.files
234
+ }
235
+ return node
236
+ }
237
+
238
+ /**
239
+ * Read one file out of an asar archive without extracting the tree.
240
+ * @param archive - the archive path.
241
+ * @param path - a slash-separated path inside the archive.
242
+ * @returns the bytes, or undefined when the entry is absent or unreadable.
243
+ */
244
+ export function readAsarFile(archive: string, path: string): Buffer | undefined {
245
+ const parsed = readAsarHeader(archive)
246
+ if ('error' in parsed) return undefined
247
+ const entry = entryAt(parsed.header.files, path)
248
+ if (entry === undefined || entry.files !== undefined || entry.unpacked === true) return undefined
249
+ if (typeof entry.offset !== 'string' || typeof entry.size !== 'number' || entry.size < 0) return undefined
250
+ let fd: number | undefined
251
+ try {
252
+ fd = archiveFs.openSync(archive, 'r')
253
+ const buffer = Buffer.alloc(entry.size)
254
+ const read = archiveFs.readSync(fd, buffer, 0, entry.size, parsed.contentBase + Number(entry.offset))
255
+ return read === entry.size ? buffer : undefined
256
+ } catch {
257
+ return undefined
258
+ } finally {
259
+ if (fd !== undefined) {
260
+ try { archiveFs.closeSync(fd) } catch { /* already closed */ }
261
+ }
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Whether an install directory is DSH Desktop.
267
+ *
268
+ * Everything the caller does next (stop the app, delete a tree, extract, rename, write) depends on
269
+ * this being right, so every uncertainty resolves to a refusal that names what was found.
270
+ * @param installRoot - the directory a user or the discovery probe named.
271
+ * @returns the verified identity, or a refusal with a reason.
272
+ */
273
+ export function readDesktopIdentity(installRoot: string): DesktopIdentity | IdentityRefusal {
274
+ const rule = readIdentityRule()
275
+ if ('error' in rule) return { ok: false, reason: rule.error }
276
+ const resources = join(installRoot, ...layoutOf(rule, installRoot).resources.split('/'))
277
+ const appDir = join(resources, 'app')
278
+ const archive = join(resources, 'app.asar')
279
+
280
+ let archivePresent: boolean
281
+ try {
282
+ archivePresent = archiveFs.existsSync(archive)
283
+ } catch {
284
+ return { ok: false, reason: `cannot inspect ${archive}` }
285
+ }
286
+
287
+ const layout: 'packed' | 'unpacked' = archivePresent ? 'packed' : 'unpacked'
288
+ let manifestText: string | undefined
289
+ let mainPresent: boolean
290
+ let hasEntry: (entry: string) => boolean
291
+ if (archivePresent) {
292
+ const parsed = readAsarHeader(archive)
293
+ if ('error' in parsed) {
294
+ return { ok: false, reason: `${archive} could not be read: ${parsed.error}` }
295
+ }
296
+ const manifest = entryAt(parsed.header.files, 'package.json')
297
+ if (manifest === undefined || manifest.files !== undefined || manifest.unpacked === true) {
298
+ return { ok: false, reason: `${archive} has no plain package.json; an archive without one is not proof of identity` }
299
+ }
300
+ manifestText = readAsarFile(archive, 'package.json')?.toString('utf8')
301
+ if (manifestText === undefined) {
302
+ return { ok: false, reason: `${archive}: package.json is listed but its bytes cannot be read` }
303
+ }
304
+ hasEntry = entry => entryAt(parsed.header.files, entry) !== undefined
305
+ mainPresent = hasEntry(rule.mainEntry)
306
+ } else {
307
+ const manifestPath = join(appDir, 'package.json')
308
+ try {
309
+ manifestText = readFileSync(manifestPath, 'utf8')
310
+ } catch (error) {
311
+ // Candidate probe directories routinely do not contain resources/app/package.json (issue #106).
312
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
313
+ console.error(`[dsh-browser] cannot read the package manifest at ${manifestPath}: ${String(error)}`)
314
+ }
315
+ return { ok: false, reason: `${manifestPath} is missing; a directory without a package manifest is not a DSH Desktop install` }
316
+ }
317
+ hasEntry = entry => existsSync(join(appDir, ...entry.split('/')))
318
+ mainPresent = hasEntry(rule.mainEntry)
319
+ }
320
+
321
+ let manifest: { name?: unknown; version?: unknown }
322
+ try {
323
+ manifest = JSON.parse(manifestText) as { name?: unknown; version?: unknown }
324
+ } catch {
325
+ return { ok: false, reason: 'the package manifest is not valid JSON' }
326
+ }
327
+ const name = typeof manifest.name === 'string' ? manifest.name : ''
328
+ if (!rule.packageNames.includes(name)) {
329
+ return {
330
+ ok: false,
331
+ reason: `the app calls itself ${name === '' ? '(no name)' : JSON.stringify(name)}, which is not one of `
332
+ + `${rule.packageNames.join(' / ')} — refusing to touch a different application`,
333
+ }
334
+ }
335
+
336
+ // The main entry is the file the installer patches and the shell runs; if it is not there, this
337
+ // is not an install this plugin can reason about even though the manifest looks right.
338
+ if (!mainPresent) {
339
+ const foreign = Object.entries(rule.unsupportedMainEntries ?? {}).find(([entry]) => hasEntry(entry))
340
+ if (foreign !== undefined) {
341
+ return { ok: false, shell: 'third-party-shell', ...versionOf(manifest), reason: `${foreign[0]} instead of ${rule.mainEntry}: ${foreign[1]}; use DSH Web or DeepSeek Harness Desktop` }
342
+ }
343
+ return { ok: false, shell: 'official-unsupported', ...versionOf(manifest), reason: `${rule.mainEntry} is not present under ${archivePresent ? archive : appDir}` }
344
+ }
345
+
346
+ return {
347
+ ok: true,
348
+ root: installRoot,
349
+ layout,
350
+ packageName: name,
351
+ ...typeof manifest.version === 'string' ? { version: manifest.version } : {},
352
+ }
353
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * What kind of desktop shell an install is, and what the user should do with it.
3
+ *
4
+ * The bridge patches exactly one shell: DeepSeek Harness Desktop with its `lib/main.js` entry. A
5
+ * community shell that reuses the `dsh-desktop` package name (dataelement/dsh-desktop, issue #62)
6
+ * is recognised as such and never patched; the report tells the settings page to hide bridge
7
+ * install / repair and to point at the system browser first.
8
+ * @module dsh-browser/browser-electron/desktop-shell
9
+ */
10
+ import type { DesktopIdentity, IdentityRefusal } from './desktop-identity.ts'
11
+ import type { TauriHostPatch, TauriRuntime } from './tauri-host.ts'
12
+
13
+ export type DesktopShellKind = 'official-supported' | 'tauri' | 'official-unsupported' | 'third-party-shell' | 'none'
14
+ export type RecommendedCarrier = 'sidebar' | 'chrome' | 'edge'
15
+
16
+ /** One desktop shell, classified. `official-supported` takes the bridge; `tauri` takes only its sidebar host patch. */
17
+ export interface DesktopShellReport {
18
+ readonly kind: DesktopShellKind
19
+ readonly patchable: boolean
20
+ readonly reason: string
21
+ readonly recommendedCarrier: RecommendedCarrier
22
+ readonly root?: string
23
+ readonly version?: string
24
+ /** DSH Tauri only: its electron-rs runtime directory, whether it hosts this process, and its host patch. */
25
+ readonly runtime?: string
26
+ readonly running?: boolean
27
+ readonly hostPatch?: TauriHostPatch
28
+ }
29
+
30
+ interface CarrierHints {
31
+ /** The stored `browser.channel`; a system browser the user already chose is the one to recommend. */
32
+ readonly preferredBrowser?: string
33
+ readonly platform?: NodeJS.Platform
34
+ }
35
+
36
+ /**
37
+ * The system browser to recommend when the sidebar cannot carry the browser.
38
+ * @param hints - the user's current channel and platform.
39
+ * @returns `chrome` or `edge`.
40
+ */
41
+ export function systemCarrier(hints: CarrierHints = {}): 'chrome' | 'edge' {
42
+ if (hints.preferredBrowser === 'chrome' || hints.preferredBrowser === 'edge') return hints.preferredBrowser
43
+ return (hints.platform ?? process.platform) === 'win32' ? 'edge' : 'chrome'
44
+ }
45
+
46
+ /**
47
+ * Classify one candidate install from its identity reading.
48
+ * @param root - the install directory.
49
+ * @param identity - `readDesktopIdentity(root)`.
50
+ * @param hints - used for the recommended carrier of an unpatchable shell.
51
+ * @returns the report; `none` when the directory is not a DSH-named shell at all.
52
+ */
53
+ export function classifyDesktopShell(root: string, identity: DesktopIdentity | IdentityRefusal, hints: CarrierHints = {}): DesktopShellReport {
54
+ if (identity.ok) {
55
+ return { kind: 'official-supported', patchable: true, reason: `DeepSeek Harness Desktop ${identity.version} at ${root}`, recommendedCarrier: 'sidebar', root, version: identity.version }
56
+ }
57
+ if (identity.shell === undefined) return { ...noDesktopShell(hints), reason: identity.reason }
58
+ return {
59
+ kind: identity.shell,
60
+ patchable: false,
61
+ reason: identity.reason,
62
+ recommendedCarrier: systemCarrier(hints),
63
+ root,
64
+ ...identity.version === undefined ? {} : { version: identity.version },
65
+ }
66
+ }
67
+
68
+ /**
69
+ * The report when no DSH desktop shell was found.
70
+ * @param hints - used for the recommended carrier.
71
+ * @returns a `none` report.
72
+ */
73
+ export function noDesktopShell(hints: CarrierHints = {}): DesktopShellReport {
74
+ return {
75
+ kind: 'none',
76
+ patchable: false,
77
+ reason: 'no DSH Desktop install found in the usual roots, at DSH_DESKTOP_PATH or DSH_DESKTOP_APP, in the uninstall registry, or at this platform\'s conventional locations',
78
+ recommendedCarrier: systemCarrier(hints),
79
+ }
80
+ }
81
+
82
+ /**
83
+ * The report for DSH Tauri. Its sidebar is driven through its own `dshDesktop.browser`; what the
84
+ * plugin patches is only the sidebar partition (`dsh-host-patch/tauri.json`), never the bridge.
85
+ * @param runtime - the Tauri runtime.
86
+ * @param hostPatch - the runtime's host patch state.
87
+ * @returns a `tauri` report, patchable when the patch can be applied or is applied.
88
+ */
89
+ export function tauriShell(runtime: TauriRuntime, hostPatch: TauriHostPatch): DesktopShellReport {
90
+ return {
91
+ kind: 'tauri',
92
+ patchable: hostPatch.status === 'absent' || hostPatch.status === 'applied',
93
+ reason: `DSH Tauri at ${runtime.root ?? runtime.runtime}; sidebar host patch ${hostPatch.status}${hostPatch.reason === undefined ? '' : `: ${hostPatch.reason}`}`,
94
+ recommendedCarrier: 'sidebar',
95
+ ...runtime.root === undefined ? {} : { root: runtime.root },
96
+ runtime: runtime.runtime,
97
+ running: runtime.running,
98
+ hostPatch,
99
+ }
100
+ }
@@ -0,0 +1,45 @@
1
+ import { BrowserError } from '../browser/types.ts'
2
+ import type { ElectronViewHandle } from './provider.ts'
3
+
4
+ export interface DocumentIdentity {
5
+ readonly id: string
6
+ readonly loaderId: string
7
+ readonly url: string
8
+ readonly unreachableUrl?: string
9
+ }
10
+
11
+ export function mainDocument(value: unknown, options?: { readonly allowErrorDocument?: boolean }): DocumentIdentity {
12
+ const frame = (value as { frameTree?: { frame?: DocumentIdentity } } | undefined)?.frameTree?.frame
13
+ if (typeof frame?.id !== 'string' || frame.id === ''
14
+ || typeof frame.loaderId !== 'string' || frame.loaderId === '' || typeof frame.url !== 'string') {
15
+ throw new BrowserError('browser: the guest did not acknowledge its main document identity', 'BROWSER_DOCUMENT_UNACKNOWLEDGED')
16
+ }
17
+ if (frame.unreachableUrl && options?.allowErrorDocument !== true) {
18
+ throw new BrowserError(`browser: failed to load ${frame.unreachableUrl}`, 'BROWSER_NAVIGATION_FAILED')
19
+ }
20
+ return frame
21
+ }
22
+
23
+ /** Check parse readiness in an isolated world bound to the acknowledged main frame. */
24
+ export async function documentReady(handle: ElectronViewHandle, expected: DocumentIdentity, checkCurrent = (): void => {}): Promise<boolean> {
25
+ checkCurrent()
26
+ const world = await handle.sendCommand('Page.createIsolatedWorld', { frameId: expected.id, worldName: 'dsh-browser-readiness' }, { present: false, initialize: false }) as { executionContextId?: number }
27
+ checkCurrent()
28
+ if (!Number.isSafeInteger(world?.executionContextId) || world.executionContextId! <= 0) {
29
+ throw new BrowserError('browser: the guest did not acknowledge a document execution context', 'BROWSER_DOCUMENT_UNACKNOWLEDGED')
30
+ }
31
+ const result = await handle.sendCommand('Runtime.evaluate', {
32
+ expression: 'document.readyState', contextId: world.executionContextId, returnByValue: true,
33
+ }, { present: false, initialize: false }) as { result?: { value?: unknown }; exceptionDetails?: unknown }
34
+ checkCurrent()
35
+ const after = mainDocument(await handle.sendCommand('Page.getFrameTree', undefined, { present: false, initialize: false }),
36
+ { allowErrorDocument: !!expected.unreachableUrl })
37
+ checkCurrent()
38
+ if (after.id !== expected.id || after.loaderId !== expected.loaderId) {
39
+ throw new BrowserError('browser: the acknowledged document was superseded', 'BROWSER_NAVIGATION_SUPERSEDED')
40
+ }
41
+ if (result.exceptionDetails !== undefined || !['loading', 'interactive', 'complete'].includes(String(result.result?.value))) {
42
+ throw new BrowserError('browser: the document did not acknowledge its parse state', 'BROWSER_DOCUMENT_UNACKNOWLEDGED')
43
+ }
44
+ return result.result?.value !== 'loading'
45
+ }