dsh-builtin-browser 0.5.8 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +410 -1
- package/README.en.md +16 -64
- package/README.md +33 -64
- package/assets/browser-carriers.svg +20 -0
- package/assets/browser-extension-identity.d.mts +2 -0
- package/assets/browser-extension-identity.mjs +2 -0
- package/assets/browser-messages.d.mts +5 -0
- package/assets/browser-messages.mjs +64 -0
- package/assets/browser-panel-locales.d.mts +2 -0
- package/assets/browser-panel-locales.mjs +380 -0
- package/assets/browser-policy.d.mts +37 -0
- package/assets/browser-policy.mjs +37 -0
- package/assets/browser-products.d.mts +6 -0
- package/assets/browser-products.mjs +76 -0
- package/assets/screenshots/1-main.png +0 -0
- package/assets/screenshots/2-form-fill.png +0 -0
- package/assets/screenshots/3-challenge.png +0 -0
- package/browser-extension/constants.mjs +20 -0
- package/browser-extension/controller.mjs +293 -0
- package/browser-extension/locales.mjs +15 -0
- package/browser-extension/manifest.json +12 -0
- package/browser-extension/options.html +14 -0
- package/browser-extension/options.mjs +9 -0
- package/browser-extension/permission-guard.mjs +13 -0
- package/browser-extension/worker.mjs +74 -0
- package/cordis.patch.yml +23 -48
- package/desktop-bridge/desktop-discovery.d.mts +2 -0
- package/desktop-bridge/desktop-discovery.mjs +36 -0
- package/desktop-bridge/desktop-identity.json +17 -1
- package/desktop-bridge/desktop-processes.d.mts +1 -0
- package/desktop-bridge/desktop-processes.mjs +15 -0
- package/desktop-bridge/guest-proxy.mjs +109 -0
- package/desktop-bridge/install.mjs +197 -74
- package/desktop-bridge/main.mjs +11 -0
- package/desktop-bridge/maintenance-files.d.mts +8 -0
- package/desktop-bridge/maintenance-files.mjs +28 -0
- package/desktop-bridge/maintenance-progress.ps1 +2 -2
- package/desktop-bridge/native-guests.mjs +41 -0
- package/desktop-bridge/plugin-browser-bridge.js +618 -370
- package/desktop-bridge/profile-loader.mjs +26 -0
- package/dist/client.cjs +43167 -0
- package/dist/client.d.cts +516 -0
- package/dist/client.d.mts +516 -0
- package/dist/index.cjs +92 -0
- package/dist/index.d.mts +2960 -0
- package/dist/index.mjs +24 -0
- package/docs/HANDOVER-2026-11-15.md +178 -0
- package/docs/README.md +10 -19
- package/docs/architecture.md +17 -145
- package/docs/child-tabs.md +13 -0
- package/docs/desktop-acceptance.md +9 -0
- package/docs/development.md +88 -18
- package/docs/extension-browser.md +44 -0
- package/docs/hardcoding-audit.md +64 -0
- package/docs/limitations.md +23 -73
- package/docs/pr64-extension-status.md +46 -0
- package/docs/pr64-maintenance.md +25 -0
- package/docs/pr64-native-children.md +52 -0
- package/docs/pr64-native-views.md +60 -0
- package/docs/tool-reference.md +87 -11
- package/docs/user-guide.md +47 -255
- package/docs/why-browser.md +6 -39
- package/dsh-host-patch/README.md +60 -0
- package/dsh-host-patch/apply.mjs +194 -0
- package/dsh-host-patch/legacy-bridge.mjs +53 -0
- package/dsh-host-patch/rc3-revision1.json +90 -0
- package/dsh-host-patch/rc3-revision2.json +112 -0
- package/dsh-host-patch/rc3-revision3.json.gz +0 -0
- package/dsh-host-patch/rc3-revision4.json.gz +0 -0
- package/dsh-host-patch/rc3-revision5.json.gz +0 -0
- package/dsh-host-patch/rc3-revision6.json.gz +0 -0
- package/dsh-host-patch/rc3-revision7.json.gz +0 -0
- package/dsh-host-patch/rc3-revision8.json.gz +0 -0
- package/dsh-host-patch/rc3.json +148 -0
- package/dsh-host-patch/rc5-revision1.json +90 -0
- package/dsh-host-patch/rc5-revision2.json +112 -0
- package/dsh-host-patch/rc5-revision3.json.gz +0 -0
- package/dsh-host-patch/rc5-revision4.json.gz +0 -0
- package/dsh-host-patch/rc5-revision5.json.gz +0 -0
- package/dsh-host-patch/rc5-revision6.json.gz +0 -0
- package/dsh-host-patch/rc5-revision7.json.gz +0 -0
- package/dsh-host-patch/rc5-revision8.json.gz +0 -0
- package/dsh-host-patch/rc5.json +148 -0
- package/lib/bridge-compatibility.js +38 -0
- package/lib/browser/handles.js +78 -0
- package/lib/browser/runtime.js +155 -43
- package/lib/browser/takeover-target.js +24 -0
- package/lib/browser-electron/authenticated-route.js +23 -0
- package/lib/browser-electron/automatic-maintenance.js +394 -51
- package/lib/browser-electron/bridge-auto.js +2 -1
- package/lib/browser-electron/bridge-connection.js +8 -1
- package/lib/browser-electron/bridge-install.js +27 -2
- package/lib/browser-electron/bridge-maintenance.js +35 -10
- package/lib/browser-electron/bridge-status.js +98 -27
- package/lib/browser-electron/desktop-bridge-host.js +193 -560
- package/lib/browser-electron/desktop-identity.js +40 -2
- package/lib/browser-electron/document-readiness.js +34 -0
- package/lib/browser-electron/electron-provision.js +14 -44
- package/lib/browser-electron/entry.js +659 -252
- package/lib/browser-electron/extension-browser.js +234 -0
- package/lib/browser-electron/extension-setup.js +69 -0
- package/lib/browser-electron/guest-cookie-jar.LICENSE.txt +32 -0
- package/lib/browser-electron/guest-cookie-jar.js +10559 -0
- package/lib/browser-electron/guest-cookie-store.js +74 -0
- package/lib/browser-electron/guest-css-runtime.js +75 -0
- package/lib/browser-electron/guest-css.js +106 -0
- package/lib/browser-electron/guest-route.js +603 -0
- package/lib/browser-electron/guest-runtime.js +356 -0
- package/lib/browser-electron/guest-storage-runtime.js +52 -0
- package/lib/browser-electron/guest-storage.js +163 -0
- package/lib/browser-electron/history-store.js +2 -1
- package/lib/browser-electron/host-main.js +162 -7
- package/lib/browser-electron/host-patch-maintenance.js +141 -0
- package/lib/browser-electron/http-body.js +22 -0
- package/lib/browser-electron/maintenance-broker.js +35 -5
- package/lib/browser-electron/maintenance-lifecycle.js +7 -5
- package/lib/browser-electron/maintenance-route.js +9 -6
- package/lib/browser-electron/open-slot.js +47 -0
- package/lib/browser-electron/paths.js +4 -1
- package/lib/browser-electron/preferred-browser.js +144 -0
- package/lib/browser-electron/preview-route.js +11 -8
- package/lib/browser-electron/process-ownership.js +198 -0
- package/lib/browser-electron/profile-checkpoint.js +222 -0
- package/lib/browser-electron/profile-command.js +60 -0
- package/lib/browser-electron/profile-extension.js +126 -0
- package/lib/browser-electron/profile-lease.js +157 -0
- package/lib/browser-electron/profile-residue.js +61 -0
- package/lib/browser-electron/provider.js +719 -262
- package/lib/browser-electron/reference-route.js +635 -0
- package/lib/browser-electron/remote-host.js +12 -13
- package/lib/browser-electron/runtime-route.js +6 -5
- package/lib/browser-electron/runtime-status.js +30 -29
- package/lib/browser-electron/settings-store.js +10 -5
- package/lib/browser-electron/shortcuts-route.js +108 -0
- package/lib/browser-electron/sidebar-only-host.js +119 -18
- package/lib/browser-electron/startpage-shortcuts.js +172 -0
- package/lib/browser-electron/system-browser.js +352 -371
- package/lib/browser-electron/windows-system.js +2 -1
- package/lib/browser-reference/delivery.js +326 -0
- package/lib/browser-reference/entry.js +597 -0
- package/lib/browser-reference/export.js +298 -0
- package/lib/browser-reference/import.js +295 -0
- package/lib/browser-reference/page-script.js +1406 -0
- package/lib/browser-reference/service.js +1062 -0
- package/lib/browser-reference/store.js +177 -0
- package/lib/browser-reference/submission-receipts.js +139 -0
- package/lib/browser-reference/text-quote.js +167 -0
- package/lib/browser-reference/types.js +11 -0
- package/lib/browser-reference/visible.js +311 -0
- package/lib/browser-reference/web-sources.js +97 -0
- package/lib/index.js +10 -3
- package/lib/reference-owner.js +5 -0
- package/lib/reference-page.js +12 -0
- package/lib/reference-source.js +2 -0
- package/lib/reference-text.js +188 -0
- package/lib/startpage-settings.js +63 -0
- package/lib/startpage.js +44 -0
- package/lib/takeover-protocol.js +2 -0
- package/lib/tool-browser/code-tool.js +416 -0
- package/lib/tool-browser/code-worker.js +872 -0
- package/lib/tool-browser/index.js +940 -76
- package/lib/tool-browser/page-probe.js +3 -3
- package/lib/tool-browser/panel-page.js +95 -0
- package/lib/tool-browser/screenshot-image.js +51 -0
- package/lib/tool-browser/takeover.js +205 -0
- package/lib/types.js +1 -0
- package/lib/web-guest.js +26 -0
- package/native-host/client.d.mts +17 -0
- package/native-host/client.mjs +100 -0
- package/native-host/host.mjs +150 -0
- package/native-host/identity.d.mts +2 -0
- package/native-host/identity.mjs +1 -0
- package/native-host/install.mjs +168 -0
- package/native-host/protocol.mjs +75 -0
- package/package.json +80 -92
- package/scripts/build.mjs +66 -0
- package/scripts/bundle-host.mjs +28 -0
- package/scripts/fix-exports.mjs +50 -0
- package/scripts/install-electron.mjs +11 -26
- package/scripts/verify-exports.mjs +47 -0
- package/scripts/verify-preview-sdk.mjs +93 -0
- package/skills/dsh-builtin-browser/SKILL.md +56 -47
- package/skills/dsh-builtin-browser/references/batch.md +31 -1
- package/skills/dsh-debug-host/SKILL.md +56 -0
- package/skills/dsh-debug-self/SKILL.md +50 -0
- package/src/bridge-compatibility.ts +39 -0
- package/src/browser/handles.ts +89 -0
- package/src/browser/runtime.ts +146 -50
- package/src/browser/takeover-target.ts +36 -0
- package/src/browser/types.ts +19 -7
- package/src/browser-electron/authenticated-route.ts +29 -1
- package/src/browser-electron/automatic-maintenance.ts +368 -56
- package/src/browser-electron/bridge-auto.ts +5 -4
- package/src/browser-electron/bridge-connection.ts +20 -2
- package/src/browser-electron/bridge-endpoint.ts +3 -3
- package/src/browser-electron/bridge-install.ts +40 -4
- package/src/browser-electron/bridge-maintenance.ts +42 -14
- package/src/browser-electron/bridge-status.ts +94 -23
- package/src/browser-electron/desktop-bridge-host.ts +185 -585
- package/src/browser-electron/desktop-identity.ts +53 -2
- package/src/browser-electron/document-readiness.ts +45 -0
- package/src/browser-electron/electron-provision.ts +12 -45
- package/src/browser-electron/entry.ts +1299 -882
- package/src/browser-electron/ephemeral-profile.ts +1 -1
- package/src/browser-electron/extension-browser.ts +223 -0
- package/src/browser-electron/extension-setup.ts +67 -0
- package/src/browser-electron/guest-cookie-jar.ts +176 -0
- package/src/browser-electron/guest-cookie-store.ts +59 -0
- package/src/browser-electron/guest-css-runtime.ts +76 -0
- package/src/browser-electron/guest-css.ts +68 -0
- package/src/browser-electron/guest-route.ts +568 -0
- package/src/browser-electron/guest-runtime.ts +357 -0
- package/src/browser-electron/guest-storage-runtime.ts +54 -0
- package/src/browser-electron/guest-storage.ts +117 -0
- package/src/browser-electron/history-store.ts +5 -4
- package/src/browser-electron/host-main.ts +156 -11
- package/src/browser-electron/host-patch-maintenance.ts +112 -0
- package/src/browser-electron/http-body.ts +23 -0
- package/src/browser-electron/maintenance-broker.ts +29 -5
- package/src/browser-electron/maintenance-lifecycle.ts +14 -9
- package/src/browser-electron/maintenance-route.ts +17 -14
- package/src/browser-electron/missing-system-browser.ts +2 -2
- package/src/browser-electron/open-slot.ts +49 -0
- package/src/browser-electron/paths.ts +5 -1
- package/src/browser-electron/preferred-browser.ts +120 -0
- package/src/browser-electron/preview-route.ts +18 -11
- package/src/browser-electron/process-ownership.ts +168 -0
- package/src/browser-electron/profile-checkpoint.ts +187 -0
- package/src/browser-electron/profile-command.ts +46 -0
- package/src/browser-electron/profile-extension.ts +124 -0
- package/src/browser-electron/profile-lease.ts +115 -0
- package/src/browser-electron/profile-residue.ts +49 -0
- package/src/browser-electron/provider.ts +771 -289
- package/src/browser-electron/reference-route.ts +608 -0
- package/src/browser-electron/remote-host.ts +15 -15
- package/src/browser-electron/runtime-route.ts +11 -10
- package/src/browser-electron/runtime-status.ts +51 -32
- package/src/browser-electron/settings-store.ts +27 -7
- package/src/browser-electron/shortcuts-route.ts +112 -0
- package/src/browser-electron/sidebar-only-host.ts +118 -19
- package/src/browser-electron/startpage-shortcuts.ts +213 -0
- package/src/browser-electron/system-browser.ts +309 -338
- package/src/browser-electron/windows-system.ts +2 -1
- package/src/browser-reference/delivery.ts +384 -0
- package/src/browser-reference/entry.ts +631 -0
- package/src/browser-reference/export.ts +339 -0
- package/src/browser-reference/import.ts +303 -0
- package/src/browser-reference/page-script.ts +1537 -0
- package/src/browser-reference/service.ts +1315 -0
- package/src/browser-reference/store.ts +172 -0
- package/src/browser-reference/submission-receipts.ts +122 -0
- package/src/browser-reference/text-quote.ts +219 -0
- package/src/browser-reference/types.ts +195 -0
- package/src/browser-reference/visible.ts +367 -0
- package/src/browser-reference/web-sources.ts +103 -0
- package/src/client/browser/BrowserController.ts +693 -0
- package/src/client/browser/BrowserFrame.ts +78 -0
- package/src/client/browser/BrowserNavigation.ts +169 -0
- package/src/client/browser/BrowserPage.ts +23 -0
- package/src/client/browser/BrowserPersistence.ts +44 -0
- package/src/client/browser/IframeImpl.ts +176 -0
- package/src/client/browser/child-tabs.ts +14 -0
- package/src/client/browser/iframe-reference.ts +67 -0
- package/src/client/browser/initialization.ts +262 -0
- package/src/client/browser/omnibox.ts +243 -0
- package/src/client/browser/store.ts +38 -0
- package/src/client/browser/takeover-channel.ts +72 -0
- package/src/client/browser/url.ts +46 -0
- package/src/client/browser/web-reference-source.ts +52 -0
- package/src/client/css-modules.d.ts +4 -0
- package/src/client/definition.tsx +30 -0
- package/src/client/electron/ElectronWebViewImpl.ts +364 -0
- package/src/client/electron/ElectronWebviewPresentation.ts +138 -0
- package/src/client/electron/NativeChildPresentation.ts +45 -0
- package/src/client/electron/NativeViewPage.ts +251 -0
- package/src/client/electron/pages.ts +23 -0
- package/src/client/electron/reference-overlay.ts +53 -0
- package/src/client/electron/workspace.ts +33 -0
- package/src/client/index.ts +293 -0
- package/src/client/locales.ts +857 -0
- package/src/client/pages.ts +28 -0
- package/src/client/reference/client/BrowserRefLink.tsx +142 -0
- package/src/client/reference/client/draft-reference.ts +167 -0
- package/src/client/reference/client/index.ts +7 -0
- package/src/client/reference/client/ordered-submission.ts +108 -0
- package/src/client/reference/client/pending-delivery.ts +216 -0
- package/src/client/reference/client/plugin.ts +189 -0
- package/src/client/reference/client/production/ReferenceCapsules.tsx +345 -0
- package/src/client/reference/client/production/ReferenceDock.module.css +193 -0
- package/src/client/reference/client/production/ReferenceDock.tsx +6 -0
- package/src/client/reference/client/production/ReferenceFeedback.tsx +15 -0
- package/src/client/reference/client/production/ReferenceMath.tsx +44 -0
- package/src/client/reference/client/production/ReferenceText.tsx +36 -0
- package/src/client/reference/client/production/assembly.ts +471 -0
- package/src/client/reference/client/production/asset-store.ts +144 -0
- package/src/client/reference/client/production/availability.ts +74 -0
- package/src/client/reference/client/production/bytes.ts +36 -0
- package/src/client/reference/client/production/delivery-client.ts +211 -0
- package/src/client/reference/client/production/draft-adapter.ts +508 -0
- package/src/client/reference/client/production/http-transport.ts +217 -0
- package/src/client/reference/client/production/production-submission.ts +310 -0
- package/src/client/reference/client/production/protocol.ts +231 -0
- package/src/client/reference/client/production/reference-card.ts +240 -0
- package/src/client/reference/client/production/reference-labels.ts +29 -0
- package/src/client/reference/client/production/reply-link-bridge.ts +222 -0
- package/src/client/reference/client/production/reveal.ts +215 -0
- package/src/client/reference/client/production/runtime.ts +1101 -0
- package/src/client/reference/client/production/snapshot-adapter.ts +154 -0
- package/src/client/reference/client/production/source-marker.ts +63 -0
- package/src/client/reference/client/production/source-opener.ts +55 -0
- package/src/client/reference/client/production/styles.ts +104 -0
- package/src/client/reference/client/production/user-text-rule.ts +58 -0
- package/src/client/reference/client/reveal.ts +107 -0
- package/src/client/reference/client/scheme.ts +114 -0
- package/src/client/reference/client/types.ts +168 -0
- package/src/client/reference/css-modules.d.ts +4 -0
- package/src/client/reference/index.ts +11 -0
- package/src/client/reference-capture-owner.ts +162 -0
- package/src/client/reference-intents.ts +36 -0
- package/src/client/settings/index.ts +34 -0
- package/{client.js → src/client/settings/panel.ts} +2657 -2231
- package/src/client/shortcut-open.ts +30 -0
- package/src/client/startpage/binding.ts +99 -0
- package/src/client/startpage/controller.ts +303 -0
- package/src/client/startpage/model.ts +279 -0
- package/src/client/view/Browser.module.css +751 -0
- package/src/client/view/BrowserBody.tsx +314 -0
- package/src/client/view/BrowserPresentation.ts +9 -0
- package/src/client/view/BrowserTitle.tsx +17 -0
- package/src/client/view/IframePresentation.ts +344 -0
- package/src/client/view/StartPage.tsx +597 -0
- package/src/client/view/TakeoverBanner.tsx +21 -0
- package/src/index.ts +110 -73
- package/src/reference-owner.ts +5 -0
- package/src/reference-page.ts +9 -0
- package/src/reference-source.ts +3 -0
- package/src/reference-text.ts +197 -0
- package/src/startpage-settings.ts +103 -0
- package/src/startpage.ts +71 -0
- package/src/takeover-protocol.ts +19 -0
- package/src/tool-browser/code-tool.ts +401 -0
- package/src/tool-browser/code-worker.ts +639 -0
- package/src/tool-browser/index.ts +908 -77
- package/src/tool-browser/page-probe.ts +4 -4
- package/src/tool-browser/panel-page.ts +124 -0
- package/src/tool-browser/screenshot-image.ts +49 -0
- package/src/tool-browser/takeover.ts +198 -0
- package/src/types/electron-shim.d.ts +20 -0
- package/src/types.ts +85 -0
- package/src/web-guest.ts +34 -0
- package/tools/accept-desktop.mjs +148 -0
- package/lib/browser/runtime.d.ts +0 -175
- package/lib/browser/types.d.ts +0 -797
- package/lib/browser-electron/authenticated-route.d.ts +0 -27
- package/lib/browser-electron/automatic-maintenance.d.ts +0 -41
- package/lib/browser-electron/bridge-auto.d.ts +0 -93
- package/lib/browser-electron/bridge-connection.d.ts +0 -93
- package/lib/browser-electron/bridge-endpoint.d.ts +0 -30
- package/lib/browser-electron/bridge-install.d.ts +0 -85
- package/lib/browser-electron/bridge-maintenance.d.ts +0 -24
- package/lib/browser-electron/bridge-status.d.ts +0 -50
- package/lib/browser-electron/desktop-bridge-host.d.ts +0 -248
- package/lib/browser-electron/desktop-identity.d.ts +0 -58
- package/lib/browser-electron/electron-provision.d.ts +0 -92
- package/lib/browser-electron/entry.d.ts +0 -64
- package/lib/browser-electron/ephemeral-profile.d.ts +0 -37
- package/lib/browser-electron/file-write.d.ts +0 -2
- package/lib/browser-electron/history-store.d.ts +0 -98
- package/lib/browser-electron/host-main.d.ts +0 -26
- package/lib/browser-electron/http-body.d.ts +0 -24
- package/lib/browser-electron/json-reply.d.ts +0 -33
- package/lib/browser-electron/maintenance-broker.d.ts +0 -35
- package/lib/browser-electron/maintenance-lifecycle.d.ts +0 -32
- package/lib/browser-electron/maintenance-route.d.ts +0 -18
- package/lib/browser-electron/missing-system-browser.d.ts +0 -54
- package/lib/browser-electron/paths.d.ts +0 -4
- package/lib/browser-electron/preview-route.d.ts +0 -89
- package/lib/browser-electron/process.d.ts +0 -14
- package/lib/browser-electron/provider.d.ts +0 -959
- package/lib/browser-electron/remote-host.d.ts +0 -256
- package/lib/browser-electron/rpc-input.d.ts +0 -4
- package/lib/browser-electron/rpc-ops.d.ts +0 -18
- package/lib/browser-electron/runtime-diagnostics.d.ts +0 -12
- package/lib/browser-electron/runtime-route.d.ts +0 -55
- package/lib/browser-electron/runtime-status.d.ts +0 -116
- package/lib/browser-electron/settings-route.d.ts +0 -15
- package/lib/browser-electron/settings-store.d.ts +0 -224
- package/lib/browser-electron/sidebar-only-host.d.ts +0 -36
- package/lib/browser-electron/system-browser.d.ts +0 -367
- package/lib/browser-electron/timing.d.ts +0 -8
- package/lib/browser-electron/virtual-cursor.d.ts +0 -67
- package/lib/browser-electron/windows-system.d.ts +0 -3
- package/lib/index.d.ts +0 -30
- package/lib/tool-browser/element-fields.d.ts +0 -145
- package/lib/tool-browser/index.d.ts +0 -53
- package/lib/tool-browser/page-probe.d.ts +0 -86
- package/scripts/consumer-install-check.mjs +0 -72
- package/scripts/run-tests.mjs +0 -32
- package/scripts/verify-host-compat.mjs +0 -195
- package/scripts/verify-preview-route.mjs +0 -168
- package/scripts/verify-runtime-status.mjs +0 -179
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Self-hosted Electron browser host (parent side): an
|
|
3
|
-
* {@link ElectronBrowserViewHost} implementation that spawns the plugin's own
|
|
4
|
-
* Electron child process (host-main.js) and drives it over line-delimited
|
|
5
|
-
* JSON-RPC on a loopback TCP socket. This is what makes the plugin work on
|
|
6
|
-
* surfaces without a desktop shell's electronViewHost (plain dsh web):
|
|
7
|
-
* installing the plugin is enough — the browser window appears on first use.
|
|
8
|
-
*
|
|
9
|
-
* Protocol (one JSON object per line, both directions):
|
|
10
|
-
* -> { id, op: 'createView' } | { id, op: 'destroyView', viewId } |
|
|
11
|
-
* { id, op: 'showView', viewId } | { id, op: 'command', viewId, method, params }
|
|
12
|
-
* <- { id, op: 'hello', token } (the child's FIRST message — authenticates it)
|
|
13
|
-
* <- { id, ok: true, result? } | { id, ok: false, err }
|
|
14
|
-
*
|
|
15
|
-
* The child is Electron's main process; host-main.js owns the BrowserWindow,
|
|
16
|
-
* WebContentsViews, and webContents.debugger (CDP).
|
|
17
|
-
*
|
|
18
|
-
* Security: the RPC server accepts exactly ONE connection, and only after
|
|
19
|
-
* that connection proves knowledge of the random per-spawn token (passed to
|
|
20
|
-
* the child via its stdin (first line, never in argv). A local process that
|
|
21
|
-
* connects to the loopback port without the token can neither impersonate the
|
|
22
|
-
* child nor inject replies — it is disconnected as soon as its first line
|
|
23
|
-
* arrives. Commands are only written after the hello authenticates, and every
|
|
24
|
-
* other inbound op (including the fire-and-forget `userAction` / `viewClosed`
|
|
25
|
-
* notifications) is dispatched only once that check has passed, so an
|
|
26
|
-
* unauthenticated peer can neither read traffic nor drive a session.
|
|
27
|
-
* @module dsh-browser/browser-electron/remote-host
|
|
28
|
-
*/
|
|
29
|
-
import type { BrowserUserAction, ElectronBrowserViewHost, ElectronViewHandle, PresentOptions } from './provider.js';
|
|
30
|
-
/**
|
|
31
|
-
* Locate a SPAWNABLE Electron binary — one that runs a script given as an
|
|
32
|
-
* argument, i.e. a BARE electron, never a packaged app executable:
|
|
33
|
-
* 0. ELECTRON_PATH (explicit override — user intent beats auto-discovery),
|
|
34
|
-
* 1. the plugin's own electron package (a real dependency since 0.1.18),
|
|
35
|
-
* found by a pure filesystem walk — never require(), whose semantics
|
|
36
|
-
* differ inside an Electron main process (there it is the built-in API
|
|
37
|
-
* module, not the npm package) and which would trigger electron 44+'s
|
|
38
|
-
* lazy binary download;
|
|
39
|
-
* 2. every DSH install anchor (electron installed separately, e.g.
|
|
40
|
-
* `dsh plugin add electron` into the profile or a global prefix),
|
|
41
|
-
* choosing the NEWEST version found. Older Electron releases (e.g.
|
|
42
|
-
* 33.x) have a compositor defect that intermittently breaks page
|
|
43
|
-
* capture, so prefer the newest binary available in the environment,
|
|
44
|
-
* 3. the current process, when it IS a bare Electron (dev hosts, e.g.
|
|
45
|
-
* `electron .`): reuse the host binary. Packaged app executables
|
|
46
|
-
* (resources/app.asar beside the exe) are never reused — they ignore
|
|
47
|
-
* the script argument and launch the app itself, typically exiting
|
|
48
|
-
* immediately via the single-instance lock, which is exactly the
|
|
49
|
-
* "browser host exited (code=0)" failure on DSH Desktop;
|
|
50
|
-
* 4. last resort: the process ancestry, for hosts that run this plugin in a
|
|
51
|
-
* child Node process of their own bare-Electron main process.
|
|
52
|
-
* @returns the path to the Electron executable.
|
|
53
|
-
*/
|
|
54
|
-
/** The discovery inputs {@link resolveElectronPathImpl} selects over, injectable for tests. */
|
|
55
|
-
interface ElectronPathInputs {
|
|
56
|
-
/** ELECTRON_PATH (may be unset, empty, or pointing at a missing file). */
|
|
57
|
-
readonly override: string | undefined;
|
|
58
|
-
/** True when running inside an Electron main process. */
|
|
59
|
-
readonly inElectron: boolean;
|
|
60
|
-
/** process.execPath (candidate for in-process host reuse). */
|
|
61
|
-
readonly execPath: string;
|
|
62
|
-
/** The plugin's own electron package probe (bundled). */
|
|
63
|
-
readonly bundled: () => string | undefined;
|
|
64
|
-
/** The DSH install-anchor probe. */
|
|
65
|
-
readonly anchored: () => string | undefined;
|
|
66
|
-
/** The process-ancestry probe (last resort). */
|
|
67
|
-
readonly ancestry: () => string | undefined;
|
|
68
|
-
}
|
|
69
|
-
declare function resolveElectronPath(): string;
|
|
70
|
-
/**
|
|
71
|
-
* Pure selection over the discovery probes, in order:
|
|
72
|
-
* 0. override (user intent) → 1. bundled package → 2. anchors (newest) →
|
|
73
|
-
* 3. in-process BARE host → 4. process ancestry → throw.
|
|
74
|
-
* Packaged app executables are never reused (steps 3/4 skip them).
|
|
75
|
-
*/
|
|
76
|
-
declare function resolveElectronPathImpl(inputs: ElectronPathInputs): string;
|
|
77
|
-
/**
|
|
78
|
-
* True when the executable is a BARE (unpackaged) Electron that can be
|
|
79
|
-
* spawned with a script argument (`exe script.js --rpc-port N`). Packaged
|
|
80
|
-
* apps carry their code inside a resources dir (`app.asar`, or an unpacked
|
|
81
|
-
* `app` dir) and are NOT spawnable as bare electron: they ignore the script
|
|
82
|
-
* argument and launch the app itself, typically exiting immediately via the
|
|
83
|
-
* single-instance lock — spawning e.g. DSH Desktop.exe is exactly the
|
|
84
|
-
* "browser host exited (code=0)" failure. A portable single-file build (no
|
|
85
|
-
* resources dir at all) likewise cannot run a script argument.
|
|
86
|
-
*/
|
|
87
|
-
declare function isBareElectron(exe: string): boolean;
|
|
88
|
-
/** Candidate executable layouts used by the Electron npm package on one platform. */
|
|
89
|
-
declare function electronDistCandidates(pkgRoot: string, platform?: NodeJS.Platform): string[];
|
|
90
|
-
/** From an electron package entry file, find the dist executable beside it. */
|
|
91
|
-
declare function electronExeBeside(entry: string, platform?: NodeJS.Platform): string | undefined;
|
|
92
|
-
/** From an electron package root, find its dist executable. */
|
|
93
|
-
declare function electronDistExe(pkgRoot: string, platform?: NodeJS.Platform): string | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* Self-hosted view host: spawns the plugin's Electron child on first use and
|
|
96
|
-
* keeps it alive until dispose(). Fallback when no desktop shell provides
|
|
97
|
-
* ctx.electronViewHost.
|
|
98
|
-
*/
|
|
99
|
-
export declare class RemoteElectronViewHost implements ElectronBrowserViewHost {
|
|
100
|
-
private readonly hostMainPath;
|
|
101
|
-
/** Test seam: the executable to spawn instead of the resolved Electron
|
|
102
|
-
* binary. Absent -> resolveElectronPath() (production behavior). */
|
|
103
|
-
private readonly spawnExecutable?;
|
|
104
|
-
/** Test seam: the binary probe behind `available()`. Absent ->
|
|
105
|
-
* resolveElectronPath(). */
|
|
106
|
-
private readonly probe;
|
|
107
|
-
private client;
|
|
108
|
-
private server;
|
|
109
|
-
private pendingSocket;
|
|
110
|
-
private readonly views;
|
|
111
|
-
private readyPromise;
|
|
112
|
-
private disposed;
|
|
113
|
-
/** Last probe result. A success is kept for the host's lifetime; a failure
|
|
114
|
-
* is retried after `PROBE_RETRY_MS` (see `available()`). */
|
|
115
|
-
private electronAvailable;
|
|
116
|
-
/** Earliest time the next probe may run after a negative one. */
|
|
117
|
-
private nextProbeAt;
|
|
118
|
-
/** Consecutive child starts that did not survive; drives {@link startRetryAt}. */
|
|
119
|
-
private startFailures;
|
|
120
|
-
/** Earliest time `ready()` may spawn another child after a failed start. */
|
|
121
|
-
private startRetryAt;
|
|
122
|
-
/** When the last start failure was reported, used to keep one death to one log line. */
|
|
123
|
-
private lastStartFailureAt;
|
|
124
|
-
/** Window groups (windowId per view), re-sent on every materialization so
|
|
125
|
-
* a restarted child still places views in the right windows. */
|
|
126
|
-
private readonly groups;
|
|
127
|
-
/** The provider's user-action handler; routes toolbar actions into sessions. */
|
|
128
|
-
private userActionHandler;
|
|
129
|
-
/**
|
|
130
|
-
* The provider's handler for a window the human closed. Closing the interface
|
|
131
|
-
* ends the session it showed: history and login state stay on disk, so the
|
|
132
|
-
* next open starts clean instead of resuming a window nobody can see.
|
|
133
|
-
*/
|
|
134
|
-
private viewClosedHandler;
|
|
135
|
-
constructor(hostMainPath: string,
|
|
136
|
-
/** Test seam: the executable to spawn instead of the resolved Electron
|
|
137
|
-
* binary. Absent -> resolveElectronPath() (production behavior). */
|
|
138
|
-
spawnExecutable?: string | undefined,
|
|
139
|
-
/** Test seam: the binary probe behind `available()`. Absent ->
|
|
140
|
-
* resolveElectronPath(). */
|
|
141
|
-
probe?: () => void);
|
|
142
|
-
/**
|
|
143
|
-
* Cheap usability probe: can we find an Electron binary to spawn? The scan
|
|
144
|
-
* is filesystem-only (no network), per the seam's contract, so a missing
|
|
145
|
-
* binary surfaces as `BROWSER_PROVIDER_UNAVAILABLE` at provider selection
|
|
146
|
-
* instead of a confusing spawn failure on first use.
|
|
147
|
-
*
|
|
148
|
-
* A success is cached for the host's lifetime. A failure is NOT: an install
|
|
149
|
-
* (`npm i electron`, or the postinstall that fetches the binary) can land
|
|
150
|
-
* long after DSH started, and provider selection happens once per process —
|
|
151
|
-
* caching "no" permanently reported "no usable browser provider is
|
|
152
|
-
* registered" until DSH restarted, with no way back short of that. Retrying
|
|
153
|
-
* on a cooldown heals it by itself while keeping the scan off the hot path.
|
|
154
|
-
*/
|
|
155
|
-
available(): boolean;
|
|
156
|
-
/**
|
|
157
|
-
* Retire the cached "an Electron binary is here" answer.
|
|
158
|
-
*
|
|
159
|
-
* A success is cached for the host's lifetime because rescanning on every tool call was
|
|
160
|
-
* the original bug — but the probe reads the FILESYSTEM, so it cannot see a binary that
|
|
161
|
-
* stops being usable afterwards. Only a real spawn attempt can observe that, which is why
|
|
162
|
-
* the two failure paths in {@link RemoteElectronViewHost.start} call this: the next
|
|
163
|
-
* `available()` rescans and reports what is actually on disk, instead of advertising a
|
|
164
|
-
* provider that cannot start.
|
|
165
|
-
*/
|
|
166
|
-
private forgetBinary;
|
|
167
|
-
/**
|
|
168
|
-
* Whether the binary the host would spawn — or the entry it needs — is no longer there.
|
|
169
|
-
*
|
|
170
|
-
* Only asked after a launch actually failed, so a healthy path never pays for it. The
|
|
171
|
-
* entry script counts because Electron exits 1 with empty stderr when it cannot load it,
|
|
172
|
-
* and resolution itself throws exactly when it can find nothing, which is the same answer.
|
|
173
|
-
* @returns true when the next `available()` must rescan instead of reusing its cache.
|
|
174
|
-
*/
|
|
175
|
-
private binaryIsGone;
|
|
176
|
-
/**
|
|
177
|
-
* Ensure the child is up and ready (lazy on first use; restarts after a crash).
|
|
178
|
-
*
|
|
179
|
-
* Never throws synchronously. Callers are fire-and-forget
|
|
180
|
-
* (`void this.ready().then(…).catch(…)`), and a synchronous throw escapes their
|
|
181
|
-
* `.catch` entirely — the shape that let a failed toolbar report take the whole
|
|
182
|
-
* DSH host down (issue #16). A disposed host is reported as a rejected promise
|
|
183
|
-
* instead, which those callers already handle.
|
|
184
|
-
*/
|
|
185
|
-
private ready;
|
|
186
|
-
/**
|
|
187
|
-
* Record one child that did not survive, and set the earliest retry time.
|
|
188
|
-
*
|
|
189
|
-
* `available()` answers "is there a binary to spawn" from the FILESYSTEM, and a success
|
|
190
|
-
* there is cached for the host's lifetime (correctly — rescanning on every tool call was
|
|
191
|
-
* the bug). That probe therefore cannot see the failure mode where the binary exists and
|
|
192
|
-
* crashes on every launch: the signature `code=1` with empty stderr that host-log.test.mjs
|
|
193
|
-
* asserts. Each browser call then spawned a child that died within milliseconds, with no
|
|
194
|
-
* backoff and nothing that ever gives up — an endless crash loop, each iteration a window
|
|
195
|
-
* flashing on screen.
|
|
196
|
-
*
|
|
197
|
-
* The first retry is immediate, so the ordinary transient death (the DSH restart in
|
|
198
|
-
* remote-host-recovery.test.mjs) still heals on the very next call. After that the delay
|
|
199
|
-
* grows: once {@link START_FAILURES_MAX} attempts have failed, every later attempt is
|
|
200
|
-
* spaced by the table's last entry — the host keeps trying, but a permanently broken
|
|
201
|
-
* install now costs one spawn per 30s instead of one per tool call. Nothing is marked
|
|
202
|
-
* dead for good: a repaired installation heals on the next attempt, and `dispose()`
|
|
203
|
-
* still stops everything immediately.
|
|
204
|
-
* @param error - what the failed attempt reported.
|
|
205
|
-
*/
|
|
206
|
-
private noteStartFailure;
|
|
207
|
-
private start;
|
|
208
|
-
/** The child died: tear down so the next use starts a fresh child. */
|
|
209
|
-
private onChildExit;
|
|
210
|
-
createView(): ElectronViewHandle;
|
|
211
|
-
private ensureView;
|
|
212
|
-
showView(handle: ElectronViewHandle, label?: string, options?: PresentOptions): void;
|
|
213
|
-
/**
|
|
214
|
-
* (Re)present a view and WAIT for the child to confirm it, so the provider
|
|
215
|
-
* can dispatch CDP `Input.*` knowing the view has a display surface.
|
|
216
|
-
*
|
|
217
|
-
* Two things this fixes, both silent before:
|
|
218
|
-
* - showing a view that does not exist yet is a no-op in the child, so the
|
|
219
|
-
* view must be materialized first (a fresh tab's createView races the
|
|
220
|
-
* provider's showActive);
|
|
221
|
-
* - a view whose renderer was replaced by a navigation is \"already\n * visible\" and therefore skipped by the child's flicker-avoidance fast
|
|
222
|
-
* path, leaving the new renderer without a surface.
|
|
223
|
-
*
|
|
224
|
-
* The barrier ping is meaningful because the child handles messages strictly
|
|
225
|
-
* in order: its reply is queued behind the showView and so only arrives once
|
|
226
|
-
* the visibility change has been applied.
|
|
227
|
-
*/
|
|
228
|
-
presentView(handle: ElectronViewHandle, label?: string, options?: PresentOptions): Promise<void>;
|
|
229
|
-
/** Route a view into its session's own window (one window per session). */
|
|
230
|
-
groupView(handle: ElectronViewHandle, windowId: string, label?: string): void;
|
|
231
|
-
/** Register the provider's handler for user-initiated toolbar actions. */
|
|
232
|
-
onUserAction(handler: (action: BrowserUserAction) => void): void;
|
|
233
|
-
/** Register the provider's handler for windows the human closed. */
|
|
234
|
-
onViewClosed(handler: (windowId: string) => void): void;
|
|
235
|
-
/** Surface a failed user action to the child's toolbar (address bar etc.). */
|
|
236
|
-
notifyUserActionError(windowId: string, message: string): void;
|
|
237
|
-
destroyView(handle: ElectronViewHandle): void;
|
|
238
|
-
/** Shut the child and the RPC server down. */
|
|
239
|
-
dispose(): void;
|
|
240
|
-
}
|
|
241
|
-
/** Default host-main path relative to this module's build output. */
|
|
242
|
-
export declare function defaultHostMainPath(): string;
|
|
243
|
-
/**
|
|
244
|
-
* Test/diagnostic hooks (mirrors tool-browser's `internals` convention).
|
|
245
|
-
* `isBareElectron` is the packaged-app discriminator behind the host-reuse
|
|
246
|
-
* steps; `resolveElectronPath` is the full resolution order.
|
|
247
|
-
*/
|
|
248
|
-
export declare const internals: {
|
|
249
|
-
electronDistCandidates: typeof electronDistCandidates;
|
|
250
|
-
electronDistExe: typeof electronDistExe;
|
|
251
|
-
electronExeBeside: typeof electronExeBeside;
|
|
252
|
-
isBareElectron: typeof isBareElectron;
|
|
253
|
-
resolveElectronPath: typeof resolveElectronPath;
|
|
254
|
-
resolveElectronPathImpl: typeof resolveElectronPathImpl;
|
|
255
|
-
};
|
|
256
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The RPC operation vocabulary, in one place.
|
|
3
|
-
*
|
|
4
|
-
* The child (`host-main.ts`) switches on these names and the parent (`remote-host.ts`) sends
|
|
5
|
-
* them. Both spelled them out independently and nothing connected the two, so a rename on one
|
|
6
|
-
* side compiled fine and failed at run time as "unknown op" — and this pair has already
|
|
7
|
-
* produced one silent failure of that shape (`noteStartFailure`'s dedupe comparison, which was
|
|
8
|
-
* never true and meant a log line that never appeared).
|
|
9
|
-
*
|
|
10
|
-
* The lists are the source of truth for a test that reads both switch statements and asserts
|
|
11
|
-
* they agree, which is what makes a one-sided rename fail loudly instead of at run time.
|
|
12
|
-
*/
|
|
13
|
-
/** Operations the parent asks the child to perform. */
|
|
14
|
-
export declare const RPC_OPS: readonly ["ping", "createView", "destroyView", "showView", "groupView", "focus", "command", "capture", "download", "flushAuth", "restoreAuth", "navigate", "new-tab", "activate", "close", "back", "forward", "reload", "userActionError"];
|
|
15
|
-
/** Notifications the child sends the parent, which carry no reply. */
|
|
16
|
-
export declare const RPC_NOTIFICATIONS: readonly ["userAction", "viewClosed"];
|
|
17
|
-
/** One operation name. */
|
|
18
|
-
export type RpcOp = (typeof RPC_OPS)[number];
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Versions reported by the running child, never inferred from an npm package or path. */
|
|
2
|
-
interface RuntimeVersions {
|
|
3
|
-
readonly electron?: string;
|
|
4
|
-
readonly chrome?: string;
|
|
5
|
-
readonly node?: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Startup diagnostics only: an explicit runtime remains the user's choice.
|
|
9
|
-
* Keep this pure so availability checks never spawn Electron or download it.
|
|
10
|
-
*/
|
|
11
|
-
export declare function electronRuntimeDiagnosticLines(versions: RuntimeVersions, stamp?: string): string[];
|
|
12
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The readiness endpoints the settings panel reads.
|
|
3
|
-
*
|
|
4
|
-
* The host authenticates both routes with its signed browser-session cookie. The read returns
|
|
5
|
-
* readiness, while a POST starts runtime preparation and also passes the settings write-origin
|
|
6
|
-
* checks.
|
|
7
|
-
*
|
|
8
|
-
* Both answer with the whole report rather than a delta: the panel replaces what it shows with what
|
|
9
|
-
* it is told, so a stale poll can never leave a wrong state on screen.
|
|
10
|
-
* @module dsh-browser/browser-electron/runtime-route
|
|
11
|
-
*/
|
|
12
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
13
|
-
import type { ProvisionSnapshot } from './electron-provision.js';
|
|
14
|
-
import type { RuntimeStatusReport } from './runtime-status.js';
|
|
15
|
-
/** Where the panel reads readiness. */
|
|
16
|
-
export declare const RUNTIME_STATUS_ROUTE = "/dsh-builtin-browser/runtime-status";
|
|
17
|
-
/**
|
|
18
|
-
* Where the panel asks for the bundled runtime.
|
|
19
|
-
*
|
|
20
|
-
* Non-blocking by design: it starts (or joins) the one background attempt and answers immediately
|
|
21
|
-
* with the state that attempt is in, which is `preparing`. A request that waited for the download
|
|
22
|
-
* would time out in the browser long before a slow network finished, and would hold a connection
|
|
23
|
-
* open for something the panel can poll instead.
|
|
24
|
-
*/
|
|
25
|
-
export declare const RUNTIME_PROVISION_ROUTE = "/dsh-builtin-browser/runtime-provision";
|
|
26
|
-
/** What both handlers need. */
|
|
27
|
-
export interface RuntimeRouteDeps {
|
|
28
|
-
/** The current report; a cheap read, never a spawn. */
|
|
29
|
-
readonly report: () => RuntimeStatusReport;
|
|
30
|
-
/**
|
|
31
|
-
* Start (or join) a provision and return the state it is in now.
|
|
32
|
-
*
|
|
33
|
-
* Must not throw: a failure belongs in the report as a 200 with a `failed` state, because a user
|
|
34
|
-
* looking at a panel needs to read the reason, not an HTTP status.
|
|
35
|
-
*/
|
|
36
|
-
readonly provision: () => ProvisionSnapshot;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Read readiness: `{ ok, runtime }`.
|
|
40
|
-
* @param request - the incoming request.
|
|
41
|
-
* @param response - the response to write.
|
|
42
|
-
* @param deps - the readers.
|
|
43
|
-
*/
|
|
44
|
-
export declare function handleRuntimeStatus(request: IncomingMessage, response: ServerResponse, deps: RuntimeRouteDeps): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Start (or join) a provision, then answer with the state it is in.
|
|
47
|
-
*
|
|
48
|
-
* Always 200 once admitted, whatever happened: the state carries `failed` with its reason, and a
|
|
49
|
-
* panel that had to distinguish 4xx from 5xx to say "the download failed" would show a network
|
|
50
|
-
* error where the user needs the sentence explaining it.
|
|
51
|
-
* @param request - the incoming request.
|
|
52
|
-
* @param response - the response to write.
|
|
53
|
-
* @param deps - the readers.
|
|
54
|
-
*/
|
|
55
|
-
export declare function handleRuntimeProvision(request: IncomingMessage, response: ServerResponse, deps: RuntimeRouteDeps): Promise<void>;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One answer to "can I use the browser right now", assembled from the three things that decide it.
|
|
3
|
-
*
|
|
4
|
-
* WHY THIS EXISTS
|
|
5
|
-
* Installing this plugin made the browser work with no setup, and that property got silently
|
|
6
|
-
* weaker as the carriers were added: the bundled carrier downloads a ~100 MB Electron runtime on
|
|
7
|
-
* first need (issue #41 — the download had to leave `postinstall`), so on a fresh install the first
|
|
8
|
-
* browser call can arrive while that download is still running, and the only trace anywhere in the
|
|
9
|
-
* product was a log line the settings panel cannot read. A user who saw "cannot locate a spawnable
|
|
10
|
-
* Electron binary" had no way to learn that the plugin was already fetching one, and no button to
|
|
11
|
-
* retry it once it failed.
|
|
12
|
-
*
|
|
13
|
-
* So the readiness of each part is computed ONCE here, in a pure function over injectable readers:
|
|
14
|
-
* the settings panel renders it, and a test drives it without touching Electron, a desktop install
|
|
15
|
-
* or the file system.
|
|
16
|
-
*
|
|
17
|
-
* Everything here is a cheap environment check. The launch path's own binary probes resolve the
|
|
18
|
-
* bundled runtime and installed system browsers; bridge readers inspect the installation and its
|
|
19
|
-
* published endpoint. Available files establish availability, while browser calls establish whether
|
|
20
|
-
* a particular page can be driven. Nothing spawns anything.
|
|
21
|
-
* @module dsh-browser/browser-electron/runtime-status
|
|
22
|
-
*/
|
|
23
|
-
import type { BridgeStatus } from './bridge-status.js';
|
|
24
|
-
import type { BridgeEndpointState } from './bridge-endpoint.js';
|
|
25
|
-
import type { ProvisionSnapshot } from './electron-provision.js';
|
|
26
|
-
import { type BrowserChannel, type DetectedBrowser } from './system-browser.js';
|
|
27
|
-
/** The part of the carrier the channel names, in the terms the panel has to explain. */
|
|
28
|
-
export type CarrierKind = 'sidebar' | 'bundled' | 'system' | 'auto';
|
|
29
|
-
/** Whether the chosen carrier's required files or running bridge are available. */
|
|
30
|
-
export type Readiness = 'ready' | 'blocked';
|
|
31
|
-
/** The system-browser discovery result, obtained without launching an executable. */
|
|
32
|
-
export interface SystemBrowserReadiness {
|
|
33
|
-
/** False for channels that use the sidebar or bundled runtime directly. */
|
|
34
|
-
readonly checked: boolean;
|
|
35
|
-
readonly present: boolean;
|
|
36
|
-
readonly kind?: DetectedBrowser['kind'];
|
|
37
|
-
readonly path?: string;
|
|
38
|
-
/** What was found or which configured product is missing. */
|
|
39
|
-
readonly detail: string;
|
|
40
|
-
}
|
|
41
|
-
/** The Electron runtime's state, as the panel needs it. */
|
|
42
|
-
export interface ElectronReadiness {
|
|
43
|
-
/** `present` — a launch would find a binary; `preparing` — a download is running now; and so on. */
|
|
44
|
-
readonly state: ProvisionSnapshot['state'];
|
|
45
|
-
/** One line, already user-facing: the provisioning module's own words. */
|
|
46
|
-
readonly detail: string;
|
|
47
|
-
/** When that state was reached, ISO. */
|
|
48
|
-
readonly at: string;
|
|
49
|
-
}
|
|
50
|
-
/** The desktop sidebar bridge, or the honest "there is no desktop here" shape. */
|
|
51
|
-
export interface BridgeReadiness {
|
|
52
|
-
/** Whether a DSH Desktop install was found at all. */
|
|
53
|
-
readonly present: boolean;
|
|
54
|
-
/** `absent` is reported separately from `missing`: nothing to repair versus something to repair. */
|
|
55
|
-
readonly state: BridgeStatus['state'] | 'absent';
|
|
56
|
-
/** The plugin's own words about the install tree. */
|
|
57
|
-
readonly detail: string;
|
|
58
|
-
/**
|
|
59
|
-
* Whether a shell is RUNNING and answering, as opposed to merely installed.
|
|
60
|
-
*
|
|
61
|
-
* Install-tree state survives a reboot and says nothing about a process; the published endpoint is
|
|
62
|
-
* the only thing that does. Reporting "installed" as "ready" is how a panel goes green while every
|
|
63
|
-
* call dials a port nobody owns — the desktop app being closed is the most common broken state
|
|
64
|
-
* there is.
|
|
65
|
-
*/
|
|
66
|
-
readonly running: boolean;
|
|
67
|
-
/** The plugin's own words about the running shell (or about why there is none). */
|
|
68
|
-
readonly runningDetail: string;
|
|
69
|
-
/** The command that installs or repairs it, for a human to run. Never run by the plugin. */
|
|
70
|
-
readonly command?: string;
|
|
71
|
-
}
|
|
72
|
-
/** The whole report. */
|
|
73
|
-
export interface RuntimeStatusReport {
|
|
74
|
-
/** What the settings document says, verbatim: the panel shows the switch it is honouring. */
|
|
75
|
-
readonly channel: BrowserChannel;
|
|
76
|
-
/** What that channel resolves to, in panel terms. */
|
|
77
|
-
readonly carrier: CarrierKind;
|
|
78
|
-
/** The concrete carrier selected by the same discovery priority as the browser provider. */
|
|
79
|
-
readonly resolvedCarrier: Exclude<CarrierKind, 'auto'>;
|
|
80
|
-
/** Whether the carrier's environment requirements are available. */
|
|
81
|
-
readonly readiness: Readiness;
|
|
82
|
-
readonly systemBrowser: SystemBrowserReadiness;
|
|
83
|
-
/** The system executable selected for the resolved carrier, when applicable. */
|
|
84
|
-
readonly executable?: string;
|
|
85
|
-
readonly electron: ElectronReadiness;
|
|
86
|
-
readonly bridge: BridgeReadiness;
|
|
87
|
-
/** Whether "Prepare the bundled browser" is worth offering (it is not while one is running). */
|
|
88
|
-
readonly canProvision: boolean;
|
|
89
|
-
}
|
|
90
|
-
/** Everything the report reads, so a test can answer without any of the real machinery. */
|
|
91
|
-
export interface RuntimeStatusDeps {
|
|
92
|
-
/** The stored `browser.channel`. */
|
|
93
|
-
readonly channel: () => BrowserChannel;
|
|
94
|
-
/** Whether a launch would find an Electron binary — the launch path's own probe. */
|
|
95
|
-
readonly hasBinary: () => boolean;
|
|
96
|
-
/** The provisioning state machine's current state. */
|
|
97
|
-
readonly provision: () => ProvisionSnapshot;
|
|
98
|
-
/** The desktop install's bridge state, or undefined when there is no desktop install. */
|
|
99
|
-
readonly bridge: () => BridgeStatus | undefined;
|
|
100
|
-
/** The endpoint the shell publishes while it runs; undefined when nothing published one. */
|
|
101
|
-
readonly endpoint: () => BridgeEndpointState | undefined;
|
|
102
|
-
/** The launch path's filesystem-only browser discovery; defaults to the production reader. */
|
|
103
|
-
readonly detectBrowser?: (channel: BrowserChannel) => DetectedBrowser | undefined;
|
|
104
|
-
/** The provider's current carrier, including a fallback selected after sidebar loss. */
|
|
105
|
-
readonly selectedCarrier?: () => Exclude<CarrierKind, 'auto'> | undefined;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Assemble the report.
|
|
109
|
-
*
|
|
110
|
-
* The `readiness` field is per carrier on purpose: "the browser is ready" is not a property of this
|
|
111
|
-
* plugin, it is a property of the carrier the user chose. A bundled carrier with a finished download
|
|
112
|
-
* is ready; the sidebar carrier with no bridge is not, however healthy the bundled runtime is.
|
|
113
|
-
* @param deps - the readers; every one of them is a cheap, side-effect-free read.
|
|
114
|
-
* @returns the report the panel renders.
|
|
115
|
-
*/
|
|
116
|
-
export declare function readRuntimeStatus(deps: RuntimeStatusDeps): RuntimeStatusReport;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser-origin checks used after DSH authenticates each plugin HTTP request.
|
|
3
|
-
* Desktop protocol forwarding supplies the host session cookie while Chromium may omit Origin
|
|
4
|
-
* and Referer for the custom application scheme. These checks preserve that request shape and
|
|
5
|
-
* reject browser requests that explicitly name another web origin.
|
|
6
|
-
* @module dsh-browser/browser-electron/settings-route
|
|
7
|
-
*/
|
|
8
|
-
import type { IncomingMessage } from 'node:http';
|
|
9
|
-
/**
|
|
10
|
-
* Whether a request may touch the settings document.
|
|
11
|
-
* @param request - the incoming request.
|
|
12
|
-
* @param writing - true for PUT/POST, which is held to the stricter rule.
|
|
13
|
-
* @returns whether the request is admitted.
|
|
14
|
-
*/
|
|
15
|
-
export declare function sameOrigin(request: IncomingMessage, writing?: boolean): boolean;
|