dsh-builtin-browser 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/README.md +1 -1
- package/assets/browser-panel-locales.mjs +37 -5
- package/assets/browser-policy.d.mts +29 -0
- package/assets/browser-policy.mjs +40 -0
- package/desktop-bridge/desktop-discovery.d.mts +1 -1
- package/desktop-bridge/desktop-discovery.mjs +59 -9
- package/desktop-bridge/desktop-identity.json +12 -0
- package/desktop-bridge/install.mjs +14 -7
- package/desktop-bridge/plugin-browser-bridge.js +19 -7
- package/docs/acceptance-2026-11-27.md +67 -0
- package/docs/architecture.md +1 -1
- package/docs/development.md +33 -4
- package/docs/dsh-0.2.3-host-patch-task.md +34 -0
- package/docs/hardcoding-audit.md +28 -8
- package/docs/known-issues.md +26 -0
- package/docs/limitations.md +6 -2
- package/docs/tool-reference.md +1 -1
- package/docs/v1.1.0-bu-data-batching-task.md +66 -0
- package/docs/v1.1.0-compat-hardcoding-task.md +85 -0
- package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
- package/dsh-builtin-browser-1.0.3.tgz +0 -0
- package/dsh-host-patch/README.md +4 -0
- package/dsh-host-patch/apply.mjs +61 -13
- package/dsh-host-patch/rc3-revision9.json.gz +0 -0
- package/dsh-host-patch/rc5-revision9.json.gz +0 -0
- package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/manifest.json +218 -0
- package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/series.json +260 -0
- package/dsh-host-patch/tauri/desktop-main.cjs +62 -0
- package/dsh-host-patch/tauri/sidebar-session.cjs +104 -0
- package/dsh-host-patch/tauri-revision1.json +39 -0
- package/dsh-host-patch/tauri.json +43 -0
- package/dsh-host-patch/v023-alpha2.json +153 -0
- package/lib/browser/anti-bot.js +215 -0
- package/lib/browser/deep-dom.js +39 -0
- package/lib/browser/runtime.js +15 -0
- package/lib/browser/takeover-target.js +13 -6
- package/lib/browser/types.js +30 -1
- package/lib/browser-electron/authenticated-route.js +16 -2
- package/lib/browser-electron/automatic-maintenance.js +16 -10
- package/lib/browser-electron/bridge-connection.js +3 -8
- package/lib/browser-electron/bridge-install.js +2 -1
- package/lib/browser-electron/bridge-status.js +55 -26
- package/lib/browser-electron/desktop-bridge-host.js +7 -6
- package/lib/browser-electron/desktop-identity.js +28 -5
- package/lib/browser-electron/desktop-shell.js +64 -0
- package/lib/browser-electron/electron-provision.js +105 -18
- package/lib/browser-electron/entry.js +129 -44
- package/lib/browser-electron/extension-browser.js +4 -4
- package/lib/browser-electron/foreground-watch.js +134 -0
- package/lib/browser-electron/guest-cookie-jar.js +13 -13
- package/lib/browser-electron/guest-route.js +181 -32
- package/lib/browser-electron/guest-runtime.js +61 -10
- package/lib/browser-electron/guest-storage.js +2 -2
- package/lib/browser-electron/history-store.js +1 -5
- package/lib/browser-electron/host-main.js +8 -4
- package/lib/browser-electron/host-patch-maintenance.js +14 -8
- package/lib/browser-electron/maintenance-route.js +2 -1
- package/lib/browser-electron/missing-system-browser.js +5 -9
- package/lib/browser-electron/preferred-browser.js +7 -3
- package/lib/browser-electron/preview-route.js +9 -13
- package/lib/browser-electron/process-ownership.js +1 -1
- package/lib/browser-electron/profile-command.js +2 -1
- package/lib/browser-electron/profile-extension.js +5 -0
- package/lib/browser-electron/profile-lease.js +152 -47
- package/lib/browser-electron/provider-core.js +527 -0
- package/lib/browser-electron/provider-interaction.js +963 -0
- package/lib/browser-electron/provider-media.js +518 -0
- package/lib/browser-electron/provider-navigation.js +301 -0
- package/lib/browser-electron/provider-observation.js +623 -0
- package/lib/browser-electron/provider-tabs.js +372 -0
- package/lib/browser-electron/provider.js +150 -3301
- package/lib/browser-electron/reference-route.js +9 -18
- package/lib/browser-electron/remote-host.js +79 -34
- package/lib/browser-electron/runtime-status.js +56 -6
- package/lib/browser-electron/settings-store.js +3 -6
- package/lib/browser-electron/sidebar-only-host.js +1 -1
- package/lib/browser-electron/system-browser.js +539 -172
- package/lib/browser-electron/tauri-host.js +208 -0
- package/lib/browser-electron/virtual-cursor.js +23 -13
- package/lib/browser-reference/service.js +22 -4
- package/lib/browser-reference/web-sources.js +1 -1
- package/lib/client.js +43409 -0
- package/lib/compat/host-features.js +75 -0
- package/lib/reference-source.js +1 -1
- package/lib/reference-text.js +23 -1
- package/lib/takeover-protocol.js +1 -1
- package/lib/tool-browser/block-recovery.js +69 -0
- package/lib/tool-browser/code-tool.js +170 -19
- package/lib/tool-browser/code-worker.js +115 -20
- package/lib/tool-browser/errors.js +34 -0
- package/lib/tool-browser/index.js +66 -3593
- package/lib/tool-browser/page-probe.js +227 -28
- package/lib/tool-browser/panel-page.js +2 -1
- package/lib/tool-browser/probe-client.js +157 -0
- package/lib/tool-browser/screenshot-annotations.js +108 -0
- package/lib/tool-browser/state.js +337 -0
- package/lib/tool-browser/takeover.js +1 -1
- package/lib/tool-browser/tools-debug.js +862 -0
- package/lib/tool-browser/tools-interaction.js +993 -0
- package/lib/tool-browser/tools-navigation.js +807 -0
- package/lib/tool-browser/tools-observation.js +461 -0
- package/lib/tool-browser/tools-reference.js +293 -0
- package/lib/web-guest.js +1 -0
- package/package.json +15 -53
- package/README.en.md +0 -89
- package/browser-extension/constants.mjs +0 -20
- package/browser-extension/controller.mjs +0 -293
- package/browser-extension/locales.mjs +0 -15
- package/browser-extension/manifest.json +0 -12
- package/browser-extension/options.html +0 -14
- package/browser-extension/options.mjs +0 -9
- package/browser-extension/permission-guard.mjs +0 -13
- package/browser-extension/worker.mjs +0 -74
- package/dist/client.cjs +0 -43167
- package/lib/browser-reference/submission-receipts.js +0 -139
- package/scripts/build.mjs +0 -66
- package/scripts/bundle-host.mjs +0 -28
- package/scripts/fix-exports.mjs +0 -50
- package/scripts/install-electron.mjs +0 -51
- package/scripts/verify-exports.mjs +0 -47
- package/scripts/verify-preview-sdk.mjs +0 -93
- package/skills/dsh-builtin-browser/SKILL.md +0 -73
- package/skills/dsh-builtin-browser/references/batch.md +0 -53
- package/skills/dsh-builtin-browser/references/deliver.md +0 -31
- package/skills/dsh-builtin-browser/references/locate.md +0 -11
- package/skills/dsh-builtin-browser/references/recover.md +0 -11
- package/skills/dsh-builtin-browser/references/verify.md +0 -13
- package/skills/dsh-debug-host/SKILL.md +0 -56
- package/skills/dsh-debug-self/SKILL.md +0 -50
- package/src/bridge-compatibility.ts +0 -39
- package/src/browser/handles.ts +0 -89
- package/src/browser/runtime.ts +0 -560
- package/src/browser/takeover-target.ts +0 -36
- package/src/browser/types.ts +0 -817
- package/src/browser-electron/authenticated-route.ts +0 -84
- package/src/browser-electron/automatic-maintenance.ts +0 -726
- package/src/browser-electron/bridge-auto.ts +0 -159
- package/src/browser-electron/bridge-connection.ts +0 -385
- package/src/browser-electron/bridge-endpoint.ts +0 -129
- package/src/browser-electron/bridge-install.ts +0 -289
- package/src/browser-electron/bridge-maintenance.ts +0 -189
- package/src/browser-electron/bridge-status.ts +0 -347
- package/src/browser-electron/desktop-bridge-host.ts +0 -251
- package/src/browser-electron/desktop-identity.ts +0 -320
- package/src/browser-electron/document-readiness.ts +0 -45
- package/src/browser-electron/electron-provision.ts +0 -261
- package/src/browser-electron/entry.ts +0 -1299
- package/src/browser-electron/ephemeral-profile.ts +0 -189
- package/src/browser-electron/extension-browser.ts +0 -223
- package/src/browser-electron/extension-setup.ts +0 -67
- package/src/browser-electron/file-write.ts +0 -31
- package/src/browser-electron/guest-cookie-jar.ts +0 -176
- package/src/browser-electron/guest-cookie-store.ts +0 -59
- package/src/browser-electron/guest-css-runtime.ts +0 -76
- package/src/browser-electron/guest-css.ts +0 -68
- package/src/browser-electron/guest-route.ts +0 -568
- package/src/browser-electron/guest-runtime.ts +0 -357
- package/src/browser-electron/guest-storage-runtime.ts +0 -54
- package/src/browser-electron/guest-storage.ts +0 -117
- package/src/browser-electron/history-store.ts +0 -227
- package/src/browser-electron/host-main.ts +0 -1381
- package/src/browser-electron/host-patch-maintenance.ts +0 -112
- package/src/browser-electron/http-body.ts +0 -65
- package/src/browser-electron/json-reply.ts +0 -47
- package/src/browser-electron/maintenance-broker.ts +0 -166
- package/src/browser-electron/maintenance-lifecycle.ts +0 -91
- package/src/browser-electron/maintenance-route.ts +0 -67
- package/src/browser-electron/missing-system-browser.ts +0 -113
- package/src/browser-electron/open-slot.ts +0 -49
- package/src/browser-electron/paths.ts +0 -25
- package/src/browser-electron/preferred-browser.ts +0 -120
- package/src/browser-electron/preview-route.ts +0 -218
- package/src/browser-electron/process-ownership.ts +0 -168
- package/src/browser-electron/process.ts +0 -23
- package/src/browser-electron/profile-checkpoint.ts +0 -187
- package/src/browser-electron/profile-command.ts +0 -46
- package/src/browser-electron/profile-extension.ts +0 -124
- package/src/browser-electron/profile-lease.ts +0 -115
- package/src/browser-electron/profile-residue.ts +0 -49
- package/src/browser-electron/provider.ts +0 -4571
- package/src/browser-electron/reference-route.ts +0 -608
- package/src/browser-electron/remote-host.ts +0 -1462
- package/src/browser-electron/rpc-input.ts +0 -13
- package/src/browser-electron/rpc-ops.ts +0 -41
- package/src/browser-electron/runtime-diagnostics.ts +0 -38
- package/src/browser-electron/runtime-route.ts +0 -105
- package/src/browser-electron/runtime-status.ts +0 -242
- package/src/browser-electron/settings-route.ts +0 -64
- package/src/browser-electron/settings-store.ts +0 -589
- package/src/browser-electron/shortcuts-route.ts +0 -112
- package/src/browser-electron/sidebar-only-host.ts +0 -298
- package/src/browser-electron/startpage-shortcuts.ts +0 -213
- package/src/browser-electron/system-browser.ts +0 -1497
- package/src/browser-electron/timing.ts +0 -16
- package/src/browser-electron/virtual-cursor.ts +0 -152
- package/src/browser-electron/windows-system.ts +0 -24
- package/src/browser-reference/delivery.ts +0 -384
- package/src/browser-reference/entry.ts +0 -631
- package/src/browser-reference/export.ts +0 -339
- package/src/browser-reference/import.ts +0 -303
- package/src/browser-reference/page-script.ts +0 -1537
- package/src/browser-reference/service.ts +0 -1315
- package/src/browser-reference/store.ts +0 -172
- package/src/browser-reference/submission-receipts.ts +0 -122
- package/src/browser-reference/text-quote.ts +0 -219
- package/src/browser-reference/types.ts +0 -195
- package/src/browser-reference/visible.ts +0 -367
- package/src/browser-reference/web-sources.ts +0 -103
- package/src/client/browser/BrowserController.ts +0 -693
- package/src/client/browser/BrowserFrame.ts +0 -78
- package/src/client/browser/BrowserNavigation.ts +0 -169
- package/src/client/browser/BrowserPage.ts +0 -23
- package/src/client/browser/BrowserPersistence.ts +0 -44
- package/src/client/browser/IframeImpl.ts +0 -176
- package/src/client/browser/child-tabs.ts +0 -14
- package/src/client/browser/iframe-reference.ts +0 -67
- package/src/client/browser/initialization.ts +0 -262
- package/src/client/browser/omnibox.ts +0 -243
- package/src/client/browser/store.ts +0 -38
- package/src/client/browser/takeover-channel.ts +0 -72
- package/src/client/browser/url.ts +0 -46
- package/src/client/browser/web-reference-source.ts +0 -52
- package/src/client/css-modules.d.ts +0 -4
- package/src/client/definition.tsx +0 -30
- package/src/client/electron/ElectronWebViewImpl.ts +0 -364
- package/src/client/electron/ElectronWebviewPresentation.ts +0 -138
- package/src/client/electron/NativeChildPresentation.ts +0 -45
- package/src/client/electron/NativeViewPage.ts +0 -251
- package/src/client/electron/pages.ts +0 -23
- package/src/client/electron/reference-overlay.ts +0 -53
- package/src/client/electron/workspace.ts +0 -33
- package/src/client/index.ts +0 -293
- package/src/client/locales.ts +0 -857
- package/src/client/pages.ts +0 -28
- package/src/client/reference/client/BrowserRefLink.tsx +0 -142
- package/src/client/reference/client/draft-reference.ts +0 -167
- package/src/client/reference/client/index.ts +0 -7
- package/src/client/reference/client/ordered-submission.ts +0 -108
- package/src/client/reference/client/pending-delivery.ts +0 -216
- package/src/client/reference/client/plugin.ts +0 -189
- package/src/client/reference/client/production/ReferenceCapsules.tsx +0 -345
- package/src/client/reference/client/production/ReferenceDock.module.css +0 -193
- package/src/client/reference/client/production/ReferenceDock.tsx +0 -6
- package/src/client/reference/client/production/ReferenceFeedback.tsx +0 -15
- package/src/client/reference/client/production/ReferenceMath.tsx +0 -44
- package/src/client/reference/client/production/ReferenceText.tsx +0 -36
- package/src/client/reference/client/production/assembly.ts +0 -471
- package/src/client/reference/client/production/asset-store.ts +0 -144
- package/src/client/reference/client/production/availability.ts +0 -74
- package/src/client/reference/client/production/bytes.ts +0 -36
- package/src/client/reference/client/production/delivery-client.ts +0 -211
- package/src/client/reference/client/production/draft-adapter.ts +0 -508
- package/src/client/reference/client/production/http-transport.ts +0 -217
- package/src/client/reference/client/production/production-submission.ts +0 -310
- package/src/client/reference/client/production/protocol.ts +0 -231
- package/src/client/reference/client/production/reference-card.ts +0 -240
- package/src/client/reference/client/production/reference-labels.ts +0 -29
- package/src/client/reference/client/production/reply-link-bridge.ts +0 -222
- package/src/client/reference/client/production/reveal.ts +0 -215
- package/src/client/reference/client/production/runtime.ts +0 -1101
- package/src/client/reference/client/production/snapshot-adapter.ts +0 -154
- package/src/client/reference/client/production/source-marker.ts +0 -63
- package/src/client/reference/client/production/source-opener.ts +0 -55
- package/src/client/reference/client/production/styles.ts +0 -104
- package/src/client/reference/client/production/user-text-rule.ts +0 -58
- package/src/client/reference/client/reveal.ts +0 -107
- package/src/client/reference/client/scheme.ts +0 -114
- package/src/client/reference/client/types.ts +0 -168
- package/src/client/reference/css-modules.d.ts +0 -4
- package/src/client/reference/index.ts +0 -11
- package/src/client/reference-capture-owner.ts +0 -162
- package/src/client/reference-intents.ts +0 -36
- package/src/client/settings/index.ts +0 -34
- package/src/client/settings/panel.ts +0 -2657
- package/src/client/shortcut-open.ts +0 -30
- package/src/client/startpage/binding.ts +0 -99
- package/src/client/startpage/controller.ts +0 -303
- package/src/client/startpage/model.ts +0 -279
- package/src/client/view/Browser.module.css +0 -751
- package/src/client/view/BrowserBody.tsx +0 -314
- package/src/client/view/BrowserPresentation.ts +0 -9
- package/src/client/view/BrowserTitle.tsx +0 -17
- package/src/client/view/IframePresentation.ts +0 -344
- package/src/client/view/StartPage.tsx +0 -597
- package/src/client/view/TakeoverBanner.tsx +0 -21
- package/src/index.ts +0 -110
- package/src/reference-owner.ts +0 -5
- package/src/reference-page.ts +0 -9
- package/src/reference-source.ts +0 -3
- package/src/reference-text.ts +0 -197
- package/src/startpage-settings.ts +0 -103
- package/src/startpage.ts +0 -71
- package/src/takeover-protocol.ts +0 -19
- package/src/tool-browser/code-tool.ts +0 -401
- package/src/tool-browser/code-worker.ts +0 -639
- package/src/tool-browser/element-fields.ts +0 -167
- package/src/tool-browser/index.ts +0 -3733
- package/src/tool-browser/page-probe.ts +0 -474
- package/src/tool-browser/panel-page.ts +0 -124
- package/src/tool-browser/screenshot-image.ts +0 -49
- package/src/tool-browser/takeover.ts +0 -198
- package/src/types/electron-shim.d.ts +0 -144
- package/src/types.ts +0 -85
- package/src/web-guest.ts +0 -34
- package/tools/accept-desktop.mjs +0 -148
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Client plugin entry: what the DSH client bundle actually loads.
|
|
3
|
-
*
|
|
4
|
-
* The bundle contract is `export const inject` + `export function apply(ctx,
|
|
5
|
-
* config)`; everything else here exists to supply the two things a YAML row
|
|
6
|
-
* cannot carry:
|
|
7
|
-
* - `createElement` / `useSyncExternalStore` ← React, a shared platform module.
|
|
8
|
-
* - `hostInputFor` and the active Session id ← the Session-scope props the
|
|
9
|
-
* `conversation.input.dock` registration receives on every render
|
|
10
|
-
* (`session`, `input`, `inputActions`).
|
|
11
|
-
*
|
|
12
|
-
* Both come from inside this package, so no separate `browserReferenceDeps`
|
|
13
|
-
* service has to be published by another package.
|
|
14
|
-
*
|
|
15
|
-
* @module dsh-browser-reference/plugin
|
|
16
|
-
*/
|
|
17
|
-
import { createElement } from 'react'
|
|
18
|
-
import { referenceOwnerKey } from '../../../reference-owner.ts'
|
|
19
|
-
import type { BrowserInitializationReader } from '../../browser/initialization.ts'
|
|
20
|
-
import { openReferenceSource, type SourceSidebar } from './production/source-opener.ts'
|
|
21
|
-
import {
|
|
22
|
-
apply as applyProduction,
|
|
23
|
-
type AssemblyConfig,
|
|
24
|
-
type HostContext,
|
|
25
|
-
type HostElementFactory,
|
|
26
|
-
} from './production/assembly.ts'
|
|
27
|
-
import type { HostInputFace } from './production/draft-adapter.ts'
|
|
28
|
-
import type { ProductionRuntime } from './production/runtime.ts'
|
|
29
|
-
import type { ReferenceChipInsert } from './types.ts'
|
|
30
|
-
|
|
31
|
-
/** Slots render the dock, uiConversation parses source links, and locale supplies labels. */
|
|
32
|
-
export const inject = ['slots', 'uiConversation', 'locale']
|
|
33
|
-
|
|
34
|
-
/** The caret span the host editor hands out (`captureInsertion`). */
|
|
35
|
-
interface CaretSpan {
|
|
36
|
-
readonly start: number
|
|
37
|
-
readonly end: number
|
|
38
|
-
readonly draftRev: number
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** `SessionInput.actions`, as handed to a Session-scope slot registration. */
|
|
42
|
-
interface SlotInputActions {
|
|
43
|
-
captureInsertion(): CaretSpan
|
|
44
|
-
insertText(text: string, span: CaretSpan): boolean
|
|
45
|
-
persistDraft(): void
|
|
46
|
-
/**
|
|
47
|
-
* Insert a real reference chip into the editor — the same entry point the host's own built-in
|
|
48
|
-
* references use. Going through this instead of a decorator portal is what makes a web reference
|
|
49
|
-
* behave like a native one: the editor owns its content, its draft persistence, its caret guard and
|
|
50
|
-
* its send gating.
|
|
51
|
-
*/
|
|
52
|
-
insertReference?(ref: ReferenceChipInsert, span: CaretSpan): boolean
|
|
53
|
-
insertQuote?(text: string, summary?: string): boolean
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Session-scope props the `conversation.input.dock` registration receives. */
|
|
57
|
-
interface DockProps {
|
|
58
|
-
readonly sessionId?: string
|
|
59
|
-
readonly session?: { readonly sessionId?: string }
|
|
60
|
-
readonly input?: { readonly draft?: string }
|
|
61
|
-
readonly inputActions?: SlotInputActions
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Per-Session input face, so an async delivery never lands in another draft. */
|
|
65
|
-
interface InputBinding {
|
|
66
|
-
readonly sessionId: string
|
|
67
|
-
readonly face: HostInputFace
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** The slice of the shell's sidebar service this plugin drives. */
|
|
71
|
-
interface SidebarRightService {
|
|
72
|
-
/** Open — or re-aim — one session's `browser` tab at `url`. */
|
|
73
|
-
openTabIn(sessionId: string, kind: string, options?: { readonly params?: { readonly url?: string } }): void
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
interface SidebarScope {
|
|
77
|
-
readonly sidebarRight: SidebarRightService
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const inertFace: HostInputFace = {
|
|
81
|
-
captureInsertion: () => ({ start: 0, end: 0, draftRev: 0 }),
|
|
82
|
-
insertText: () => false,
|
|
83
|
-
persistDraft: () => { throw new Error('browser reference input is not bound to its conversation') },
|
|
84
|
-
readText: () => '',
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function apply(ctx: HostContext, config: AssemblyConfig = {}): ProductionRuntime {
|
|
88
|
-
const bindings = new Map<string, InputBinding>()
|
|
89
|
-
const hostSessions = new Map<string, string>()
|
|
90
|
-
|
|
91
|
-
const bindingFor = (sessionId: string): HostInputFace =>
|
|
92
|
-
(sessionId === '' ? undefined : bindings.get(sessionId)?.face) ?? inertFace
|
|
93
|
-
|
|
94
|
-
const runtime: ProductionRuntime = applyProduction(ctx, {
|
|
95
|
-
...config,
|
|
96
|
-
createElement: (config.createElement ?? createElement) as unknown as HostElementFactory,
|
|
97
|
-
hostInputFor: bindingFor,
|
|
98
|
-
onDockProps: (props) => {
|
|
99
|
-
config.onDockProps?.(props)
|
|
100
|
-
const dock = props as DockProps | undefined
|
|
101
|
-
const rawSession = dock?.sessionId ?? dock?.session?.sessionId
|
|
102
|
-
const sessionId = typeof rawSession === 'string' ? referenceOwnerKey(rawSession) : undefined
|
|
103
|
-
const actions = dock?.inputActions
|
|
104
|
-
if (typeof rawSession !== 'string' || typeof sessionId !== 'string' || sessionId === '') { runtime.setSession(''); return }
|
|
105
|
-
hostSessions.set(sessionId, rawSession.trim())
|
|
106
|
-
// The visible Session becomes the active one: this is what makes the
|
|
107
|
-
// default entry poll a real conversation instead of the empty id, and it
|
|
108
|
-
// keeps an async delivery bound to the Session it belongs to.
|
|
109
|
-
runtime.setSession(sessionId)
|
|
110
|
-
if (actions === undefined) return
|
|
111
|
-
const readDraft = (): string => {
|
|
112
|
-
const text = dock?.input?.draft
|
|
113
|
-
return typeof text === 'string' ? text : ''
|
|
114
|
-
}
|
|
115
|
-
const face: HostInputFace = {
|
|
116
|
-
captureInsertion: () => actions.captureInsertion(),
|
|
117
|
-
insertText: (span, text) => actions.insertText(text, span),
|
|
118
|
-
persistDraft: () => { actions.persistDraft() },
|
|
119
|
-
// Only used to prove the typed question was not disturbed; the
|
|
120
|
-
// authoritative guard remains the editor's `draftRev` compare-and-set.
|
|
121
|
-
readText: readDraft,
|
|
122
|
-
// 插入引文需要编辑器里有光标。确认按钮是在**侧栏 iframe 里**点的,那一刻焦点不在输入框,
|
|
123
|
-
// `insertQuote` 会静默失败(引文与标记都没进草稿)。插之前先把光标放回编辑器。
|
|
124
|
-
focusEditor: () => {
|
|
125
|
-
try {
|
|
126
|
-
const editor = document.querySelector('[contenteditable="true"]')
|
|
127
|
-
if (editor instanceof HTMLElement) editor.focus()
|
|
128
|
-
} catch {
|
|
129
|
-
// 文档里没有编辑器时无需处理:调用方按失败重试。
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
// rc.3 的门径:编辑器原生「原子引用」插入。插进去以后 `InputState.draft` 会展开成引文、
|
|
133
|
-
// `occurrences` 增加,上游发送闸门不再判空——「只有引用也能发」由此成立,且不改上游。
|
|
134
|
-
...(typeof actions.insertQuote === 'function'
|
|
135
|
-
? { insertQuote: (text: string, summary?: string) => actions.insertQuote?.(text, summary) === true }
|
|
136
|
-
: {}),
|
|
137
|
-
...(typeof actions.insertReference === 'function'
|
|
138
|
-
? { insertReference: (ref: ReferenceChipInsert, span: CaretSpan) => actions.insertReference?.(ref, span) === true }
|
|
139
|
-
: {}),
|
|
140
|
-
}
|
|
141
|
-
const binding: InputBinding = { sessionId, face }
|
|
142
|
-
bindings.set(sessionId, binding)
|
|
143
|
-
// 每次 dock 渲染把当前草稿交给运行时:草稿由非空变空即「消息已被接受」,需要退役本会话的引用,
|
|
144
|
-
// 否则发完消息输入框里还留着上一次的胶囊。
|
|
145
|
-
try { runtime.noteDraft(sessionId, readDraft()) } catch { /* 清理是尽力而为 */ }
|
|
146
|
-
},
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
// 侧栏页(同源 guest)需要知道「这条引用属于哪个会话」。旧实现把应答放在设置面板里,于是
|
|
150
|
-
// 只在设置页打开时才成立;现在由客户端半自己应答:页面加载时会 postMessage 询问,这里回当前的
|
|
151
|
-
// 会话 id,并把已知的同源 iframe 一并推一遍(会话切换后已加载的页面也能收到)。
|
|
152
|
-
if (typeof window !== 'undefined') {
|
|
153
|
-
// 页面可能在会话还没绑定好之前就发问(面板先挂载、dock props 后到)。早退会让它永远拿不到
|
|
154
|
-
// 会话 id,引用就落到空会话上——于是「卡片不出现、发送被禁用」。挂起的询问在这里等 id 到手
|
|
155
|
-
// 再回,而不是丢掉。
|
|
156
|
-
const pendingAsks = new Set<{ readonly source: Window; readonly origin: string }>()
|
|
157
|
-
const answer = (ask: { readonly source: Window; readonly origin: string }, sessionId: string): void => {
|
|
158
|
-
try {
|
|
159
|
-
ask.source.postMessage({ type: 'dsh.sidebar.session', sessionId }, ask.origin)
|
|
160
|
-
} catch {
|
|
161
|
-
// 跨源或已卸载的窗口:它不是我们的侧栏页,忽略。
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
const respond = (event: MessageEvent): void => {
|
|
165
|
-
const data = event.data as { readonly type?: string } | null
|
|
166
|
-
if (data === null || data.type !== 'dsh.sidebar.session.request') return
|
|
167
|
-
const source = event.source as Window | null
|
|
168
|
-
if (source === null) return
|
|
169
|
-
const ask = { source, origin: event.origin }
|
|
170
|
-
const sessionId = runtime.currentSessionId()
|
|
171
|
-
if (sessionId === '') { pendingAsks.add(ask); return }
|
|
172
|
-
answer(ask, sessionId)
|
|
173
|
-
}
|
|
174
|
-
window.addEventListener('message', respond)
|
|
175
|
-
runtime.onSessionChange((sessionId) => {
|
|
176
|
-
for (const ask of pendingAsks) answer(ask, sessionId)
|
|
177
|
-
pendingAsks.clear()
|
|
178
|
-
})
|
|
179
|
-
ctx.effect(() => () => { window.removeEventListener('message', respond) }, 'ui-browser-reference: guest session responder')
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
runtime.setSourceOpener(async (url, signal) => {
|
|
183
|
-
const sessionId = runtime.currentSessionId()
|
|
184
|
-
if (sessionId === '') throw new Error('reference source requires a conversation')
|
|
185
|
-
return openReferenceSource(ctx.get('sidebarRight') as SourceSidebar,
|
|
186
|
-
ctx.get('sidebarBrowserInitialization') as BrowserInitializationReader, hostSessions.get(sessionId) ?? sessionId, url, signal)
|
|
187
|
-
})
|
|
188
|
-
return runtime
|
|
189
|
-
}
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser references inside the composer.
|
|
3
|
-
*
|
|
4
|
-
* COLLAPSED BY DEFAULT: every reference is one compact pill (`[1] 标题`) in a
|
|
5
|
-
* single wrapping row. A second selection is added BESIDE the first, so the row
|
|
6
|
-
* grows sideways instead of the composer growing taller, and the box keeps the
|
|
7
|
-
* height the user typed into.
|
|
8
|
-
*
|
|
9
|
-
* Hovering or focusing a pill opens a floating detail card ABOVE it: the
|
|
10
|
-
* captured content in its own shape (paragraphs keep their line breaks, images
|
|
11
|
-
* stay images, tables stay tables), the user's note, and the three actions —
|
|
12
|
-
* edit note, go to source, remove. The card is portalled with fixed positioning
|
|
13
|
-
* and bounded height, so opening it never pushes the input box or the
|
|
14
|
-
* conversation around; it also stays open while the pointer travels from the
|
|
15
|
-
* pill into the card, which is what makes “edit the note” reachable by mouse.
|
|
16
|
-
* Removal is final: the pill disappears and nothing offers to undo it.
|
|
17
|
-
*/
|
|
18
|
-
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
19
|
-
import { createPortal } from 'react-dom'
|
|
20
|
-
import { IconEditOutlineRegular, IconLinkOutlineRegular, IconTrashOutlineRegular, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
21
|
-
import type { CardActions, CardPart, CardViewModel } from './reference-card.ts'
|
|
22
|
-
import type { ReferenceLabels } from './reference-labels.ts'
|
|
23
|
-
import css from './ReferenceDock.module.css'
|
|
24
|
-
import { ReferenceText } from './ReferenceText.tsx'
|
|
25
|
-
import { referenceTableRows } from '../../../../reference-text.ts'
|
|
26
|
-
|
|
27
|
-
export interface ReferenceCapsulesProps {
|
|
28
|
-
readonly sessionId: string
|
|
29
|
-
readonly cards: readonly CardViewModel[]
|
|
30
|
-
readonly actions: CardActions
|
|
31
|
-
readonly labels: ReferenceLabels
|
|
32
|
-
readonly notice?: string
|
|
33
|
-
readonly readOnly?: boolean
|
|
34
|
-
readonly anchor?: HTMLElement
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** Time the pointer may leave the pill and land on the card without a flicker. */
|
|
38
|
-
const CLOSE_DELAY_MS = 180
|
|
39
|
-
const PANEL_GAP_PX = 8
|
|
40
|
-
const VIEWPORT_PAD_PX = 8
|
|
41
|
-
const PANEL_MAX_WIDTH_PX = 460
|
|
42
|
-
const PANEL_MAX_HEIGHT_PX = 420
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function Part({ part, labels }: { readonly part: CardPart; readonly labels: ReferenceLabels }): ReactNode {
|
|
46
|
-
if (part.kind === 'text') return part.value.content === undefined
|
|
47
|
-
? <p className={css.quote} data-part-kind="text">{part.value.text}</p>
|
|
48
|
-
: <div className={css.quote} data-part-kind="text"><ReferenceText content={part.value.content} /></div>
|
|
49
|
-
if (part.kind === 'image') return part.value.bound
|
|
50
|
-
? <figure data-part-kind="image"><img className={css.image} src={part.value.thumbnailSrc} alt={part.value.alt ?? labels.image} />
|
|
51
|
-
{part.value.caption !== undefined && <figcaption>{part.value.caption}</figcaption>}</figure>
|
|
52
|
-
: <p className={css.secondary} data-part-kind="image" role="status">{labels.loadingImage}</p>
|
|
53
|
-
const rows = referenceTableRows(part.value)
|
|
54
|
-
return <div className={css.tableScroll} data-part-kind="table" tabIndex={0} aria-label={part.value.caption ?? labels.table}>
|
|
55
|
-
<table className={css.table}>
|
|
56
|
-
{part.value.caption !== undefined && <caption>{part.value.caption}</caption>}
|
|
57
|
-
<tbody>{rows.map(({ row, cells }) => <tr key={row}>
|
|
58
|
-
{cells.map(({ column, columnSpan, rowSpan, value: cell }) => {
|
|
59
|
-
if (cell === undefined) return <td key={column} colSpan={columnSpan} />
|
|
60
|
-
const Cell = cell.role === 'header' ? 'th' : 'td'
|
|
61
|
-
return <Cell key={column} rowSpan={rowSpan} colSpan={columnSpan}>{cell.content === undefined ? cell.text : <ReferenceText content={cell.content} />}
|
|
62
|
-
{cell.inlineImages.map(image => image.thumbnailSrc === undefined
|
|
63
|
-
? <span key={image.partId} className={css.secondary}>{labels.loadingImage}</span>
|
|
64
|
-
: <img key={image.partId} className={css.image} src={image.thumbnailSrc} alt={labels.image} />)}
|
|
65
|
-
</Cell>
|
|
66
|
-
})}
|
|
67
|
-
</tr>)}</tbody>
|
|
68
|
-
</table>
|
|
69
|
-
</div>
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Presentation receives only data and callbacks; delivery and sending stay in the runtime. */
|
|
73
|
-
export function ReferenceCapsules({ sessionId, cards, actions, labels, notice, readOnly = true, anchor }: ReferenceCapsulesProps): ReactNode {
|
|
74
|
-
const [openId, setOpenId] = useState<string | undefined>(anchor === undefined ? undefined : cards[0]?.referenceId)
|
|
75
|
-
/** A click pins the card open so a touch user (and the note editor) keeps it. */
|
|
76
|
-
const [pinned, setPinned] = useState(false)
|
|
77
|
-
const [edit, setEdit] = useState<{ id: string; value: string }>()
|
|
78
|
-
const chips = useRef(new Map<string, HTMLButtonElement>())
|
|
79
|
-
const panel = useRef<HTMLDivElement | null>(null)
|
|
80
|
-
const closeTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
|
|
81
|
-
const id = useIdSafe()
|
|
82
|
-
|
|
83
|
-
const active = useMemo(() => cards.find(card => card.referenceId === openId), [cards, openId])
|
|
84
|
-
|
|
85
|
-
const clearTimer = useCallback(() => {
|
|
86
|
-
if (closeTimer.current !== undefined) { clearTimeout(closeTimer.current); closeTimer.current = undefined }
|
|
87
|
-
}, [])
|
|
88
|
-
|
|
89
|
-
const open = useCallback((referenceId: string) => {
|
|
90
|
-
clearTimer()
|
|
91
|
-
setOpenId(referenceId)
|
|
92
|
-
}, [clearTimer])
|
|
93
|
-
|
|
94
|
-
const scheduleClose = useCallback(() => {
|
|
95
|
-
if (pinned) return
|
|
96
|
-
clearTimer()
|
|
97
|
-
closeTimer.current = setTimeout(() => {
|
|
98
|
-
closeTimer.current = undefined
|
|
99
|
-
setOpenId(undefined)
|
|
100
|
-
setEdit(undefined)
|
|
101
|
-
}, CLOSE_DELAY_MS)
|
|
102
|
-
}, [clearTimer, pinned])
|
|
103
|
-
|
|
104
|
-
const close = useCallback(() => {
|
|
105
|
-
clearTimer()
|
|
106
|
-
setPinned(false)
|
|
107
|
-
setOpenId(undefined)
|
|
108
|
-
setEdit(undefined)
|
|
109
|
-
}, [clearTimer])
|
|
110
|
-
|
|
111
|
-
useEffect(() => () => { clearTimer() }, [clearTimer])
|
|
112
|
-
|
|
113
|
-
// The card floats over the composer instead of living in it. Placement is written STRAIGHT TO THE
|
|
114
|
-
// NODE: routing a measurement back through `setState` re-renders the card, and a render that can
|
|
115
|
-
// change measured geometry is exactly the measure→render→measure cycle that ends in
|
|
116
|
-
// "ResizeObserver loop completed with undelivered notifications". A `position: fixed` node cannot
|
|
117
|
-
// feed back into the layout it measured, so writing its style is final — no state, no second pass.
|
|
118
|
-
useLayoutEffect(() => {
|
|
119
|
-
const node = panel.current
|
|
120
|
-
if (openId === undefined || node === null) return
|
|
121
|
-
const measure = (): void => {
|
|
122
|
-
const chip = anchor ?? chips.current.get(openId)
|
|
123
|
-
if (chip === undefined) return
|
|
124
|
-
const rect = chip.getBoundingClientRect()
|
|
125
|
-
// A zero box means the pill is not laid out yet (or the host hides the composer). Fall back near
|
|
126
|
-
// the bottom-left corner so the card still renders rather than leaving the reference with no detail.
|
|
127
|
-
const laidOut = rect.width !== 0 || rect.height !== 0
|
|
128
|
-
const anchorTop = laidOut ? rect.top : window.innerHeight - 96
|
|
129
|
-
const anchorBottom = laidOut ? rect.bottom : anchorTop
|
|
130
|
-
const anchorLeft = laidOut ? rect.left : VIEWPORT_PAD_PX
|
|
131
|
-
const width = Math.max(240, Math.min(PANEL_MAX_WIDTH_PX, window.innerWidth - VIEWPORT_PAD_PX * 2))
|
|
132
|
-
const left = Math.min(Math.max(VIEWPORT_PAD_PX, anchorLeft), window.innerWidth - width - VIEWPORT_PAD_PX)
|
|
133
|
-
// Anchored by its BOTTOM edge so the card grows upward: the composer sits at the bottom of the
|
|
134
|
-
// window, a top-anchored card would open off-screen.
|
|
135
|
-
const bottom = Math.max(VIEWPORT_PAD_PX, window.innerHeight - anchorTop + PANEL_GAP_PX)
|
|
136
|
-
const below = readOnly && window.innerHeight - anchorBottom > anchorTop
|
|
137
|
-
const maxHeight = Math.min(PANEL_MAX_HEIGHT_PX, Math.max(140,
|
|
138
|
-
below ? window.innerHeight - anchorBottom - PANEL_GAP_PX - VIEWPORT_PAD_PX : anchorTop - VIEWPORT_PAD_PX * 2))
|
|
139
|
-
node.style.left = `${left}px`
|
|
140
|
-
node.style.bottom = below ? 'auto' : `${bottom}px`
|
|
141
|
-
node.style.top = below ? `${Math.max(VIEWPORT_PAD_PX, anchorBottom + PANEL_GAP_PX)}px` : 'auto'
|
|
142
|
-
node.style.width = `${width}px`
|
|
143
|
-
node.style.maxHeight = `${maxHeight}px`
|
|
144
|
-
}
|
|
145
|
-
measure()
|
|
146
|
-
window.addEventListener('resize', measure)
|
|
147
|
-
window.addEventListener('scroll', measure, true)
|
|
148
|
-
return () => {
|
|
149
|
-
window.removeEventListener('resize', measure)
|
|
150
|
-
window.removeEventListener('scroll', measure, true)
|
|
151
|
-
}
|
|
152
|
-
}, [openId, cards.length, anchor, readOnly])
|
|
153
|
-
|
|
154
|
-
useEffect(() => {
|
|
155
|
-
if (openId === undefined) return
|
|
156
|
-
const onKey = (event: KeyboardEvent): void => {
|
|
157
|
-
if (event.key !== 'Escape') return
|
|
158
|
-
if (edit !== undefined) { setEdit(undefined); return }
|
|
159
|
-
close()
|
|
160
|
-
}
|
|
161
|
-
const onPointerDown = (event: MouseEvent): void => {
|
|
162
|
-
const target = event.target as Node | null
|
|
163
|
-
if (target === null) return
|
|
164
|
-
if (panel.current?.contains(target) === true) return
|
|
165
|
-
if (anchor?.contains(target) === true) return
|
|
166
|
-
for (const chip of chips.current.values()) if (chip.contains(target)) return
|
|
167
|
-
close()
|
|
168
|
-
}
|
|
169
|
-
window.addEventListener('keydown', onKey)
|
|
170
|
-
window.addEventListener('mousedown', onPointerDown)
|
|
171
|
-
return () => {
|
|
172
|
-
window.removeEventListener('keydown', onKey)
|
|
173
|
-
window.removeEventListener('mousedown', onPointerDown)
|
|
174
|
-
}
|
|
175
|
-
}, [openId, edit, close, anchor])
|
|
176
|
-
|
|
177
|
-
useEffect(() => {
|
|
178
|
-
if (anchor === undefined) return
|
|
179
|
-
const enter = (): void => { if (cards[0] !== undefined) open(cards[0].referenceId) }
|
|
180
|
-
anchor.addEventListener('pointerenter', enter)
|
|
181
|
-
anchor.addEventListener('focus', enter)
|
|
182
|
-
anchor.addEventListener('pointerleave', scheduleClose)
|
|
183
|
-
anchor.addEventListener('blur', scheduleClose)
|
|
184
|
-
return () => {
|
|
185
|
-
anchor.removeEventListener('pointerenter', enter)
|
|
186
|
-
anchor.removeEventListener('focus', enter)
|
|
187
|
-
anchor.removeEventListener('pointerleave', scheduleClose)
|
|
188
|
-
anchor.removeEventListener('blur', scheduleClose)
|
|
189
|
-
}
|
|
190
|
-
}, [anchor, cards, open, scheduleClose])
|
|
191
|
-
|
|
192
|
-
const save = (): void => {
|
|
193
|
-
if (edit === undefined) return
|
|
194
|
-
actions.onEditComment?.(edit.id, edit.value)
|
|
195
|
-
setEdit(undefined)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Nothing to draw: render NOTHING rather than an empty wrapper. The host seat
|
|
199
|
-
// is a flex row inside the composer card, and a zero-height child would still
|
|
200
|
-
// defeat the row's `:empty` collapse (and its -4px pull on the text surface).
|
|
201
|
-
// Never return null when empty: this component is the ONLY place the host's input face is handed to
|
|
202
|
-
// the runtime (`noteDockProps`), and the runtime needs that face to append a card. Returning null
|
|
203
|
-
// made it a chicken-and-egg loop — no cards, so no face, so no card could ever be appended, and the
|
|
204
|
-
// reference stayed a pending delivery forever. The empty host is invisible (the stylesheet hides an
|
|
205
|
-
// empty `.dock`), so nothing is drawn until a card exists.
|
|
206
|
-
if (cards.length === 0 && notice === undefined) {
|
|
207
|
-
return <div className={`dsh-browser-reference-dock ${css.dock}`} data-session={sessionId} data-cards={0} />
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return <span className={readOnly ? 'dsh-browser-reference-capsules' : `dsh-browser-reference-dock ${css.dock}`} data-session={sessionId} data-cards={cards.length}>
|
|
211
|
-
{anchor === undefined && cards.length > 0 && <span className={readOnly ? css.sentRail : css.rail} role="group" aria-label={labels.count} data-count={cards.length}
|
|
212
|
-
data-pending={cards.some(card => card.state !== 'acknowledged') ? 'yes' : 'no'}>
|
|
213
|
-
{cards.map(card => <button
|
|
214
|
-
key={card.referenceId}
|
|
215
|
-
ref={(node) => {
|
|
216
|
-
if (node === null) chips.current.delete(card.referenceId)
|
|
217
|
-
else chips.current.set(card.referenceId, node)
|
|
218
|
-
}}
|
|
219
|
-
type="button"
|
|
220
|
-
className={css.chip}
|
|
221
|
-
data-reference-id={card.referenceId}
|
|
222
|
-
data-index={card.index}
|
|
223
|
-
data-has-note={card.comment !== undefined && card.comment !== '' ? 'yes' : 'no'}
|
|
224
|
-
aria-haspopup="dialog"
|
|
225
|
-
aria-expanded={openId === card.referenceId}
|
|
226
|
-
aria-controls={openId === card.referenceId ? `${id}-${card.index}` : undefined}
|
|
227
|
-
onMouseEnter={() => { open(card.referenceId) }}
|
|
228
|
-
onMouseLeave={scheduleClose}
|
|
229
|
-
onFocus={() => { open(card.referenceId) }}
|
|
230
|
-
onBlur={() => { if (!pinned) scheduleClose() }}
|
|
231
|
-
onClick={(event) => {
|
|
232
|
-
if (readOnly) {
|
|
233
|
-
if (!event.ctrlKey && !event.metaKey && !event.shiftKey && !event.altKey) actions.onReveal?.(card.referenceId)
|
|
234
|
-
return
|
|
235
|
-
}
|
|
236
|
-
// Click pins the card (touch has no hover); a second click releases it.
|
|
237
|
-
if (openId === card.referenceId && pinned) { close(); return }
|
|
238
|
-
setPinned(true)
|
|
239
|
-
open(card.referenceId)
|
|
240
|
-
}}
|
|
241
|
-
>
|
|
242
|
-
<span className={css.badge} aria-hidden>{card.index}</span>
|
|
243
|
-
<span className={css.label}>{card.excerpt || card.source.title || card.source.host}</span>
|
|
244
|
-
{/* 这个位置原来是装饰性灰点:直接换成可点的删除键(交叉线由 CSS 画,避免字形缺失渲染成圆点)。 */}
|
|
245
|
-
{!readOnly && <span
|
|
246
|
-
role="button"
|
|
247
|
-
tabIndex={0}
|
|
248
|
-
className={css.chipRemove}
|
|
249
|
-
aria-label={labels.removeDraft}
|
|
250
|
-
title={labels.removeDraft}
|
|
251
|
-
data-chip-remove={card.referenceId}
|
|
252
|
-
onClick={(event) => {
|
|
253
|
-
event.preventDefault()
|
|
254
|
-
event.stopPropagation()
|
|
255
|
-
actions.onRemove?.(card.referenceId)
|
|
256
|
-
}}
|
|
257
|
-
onKeyDown={(event) => {
|
|
258
|
-
if (event.key !== 'Enter' && event.key !== ' ') return
|
|
259
|
-
event.preventDefault()
|
|
260
|
-
event.stopPropagation()
|
|
261
|
-
actions.onRemove?.(card.referenceId)
|
|
262
|
-
}}
|
|
263
|
-
>
|
|
264
|
-
{/* 叉用内联 SVG 画:不依赖字体字形,也不依赖 CSS 伪元素(两者都曾导致它不可见)。 */}
|
|
265
|
-
<svg width="9" height="9" viewBox="0 0 9 9" aria-hidden="true" focusable="false">
|
|
266
|
-
<path d="M1 1 L8 8 M8 1 L1 8" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" fill="none" />
|
|
267
|
-
</svg>
|
|
268
|
-
</span>}
|
|
269
|
-
|
|
270
|
-
</button>)}
|
|
271
|
-
</span>}
|
|
272
|
-
|
|
273
|
-
{active !== undefined && typeof document !== 'undefined' && createPortal(
|
|
274
|
-
<div
|
|
275
|
-
id={`${id}-${active.index}`}
|
|
276
|
-
ref={node => { panel.current = node }}
|
|
277
|
-
className={css.panel}
|
|
278
|
-
role="dialog"
|
|
279
|
-
aria-label={`${active.index}. ${active.source.title || active.source.host}`}
|
|
280
|
-
// `position: fixed` is also in the stylesheet; inline keeps the card out of the
|
|
281
|
-
// composer's flow even if the stylesheet has not loaded yet. Left/bottom/width/maxHeight
|
|
282
|
-
// are written by the layout effect above, directly on this node.
|
|
283
|
-
style={{ position: 'fixed' }}
|
|
284
|
-
// The pointer may travel from the pill into the card: crossing the gap
|
|
285
|
-
// must not close it, or the note editor is unreachable by mouse.
|
|
286
|
-
onMouseEnter={() => { clearTimer() }}
|
|
287
|
-
onMouseLeave={scheduleClose}
|
|
288
|
-
onFocus={clearTimer}
|
|
289
|
-
onBlur={(event) => {
|
|
290
|
-
if (event.relatedTarget !== null && event.currentTarget.contains(event.relatedTarget)) return
|
|
291
|
-
scheduleClose()
|
|
292
|
-
}}
|
|
293
|
-
onKeyDown={(event) => { if (event.key === 'Escape') { event.stopPropagation(); close() } }}
|
|
294
|
-
>
|
|
295
|
-
<div className={css.head}>
|
|
296
|
-
<span className={css.badge} aria-hidden>{active.index}</span>
|
|
297
|
-
<div className={css.heading}>
|
|
298
|
-
<span className={css.title}>{active.source.title || active.source.host}</span>
|
|
299
|
-
<span className={css.host}>{active.source.host}</span>
|
|
300
|
-
</div>
|
|
301
|
-
{!readOnly && <div className={css.tools}>
|
|
302
|
-
<Tooltip label={labels.edit} portal><button type="button" aria-label={labels.edit} className={css.icon}
|
|
303
|
-
aria-pressed={edit?.id === active.referenceId}
|
|
304
|
-
onClick={() => {
|
|
305
|
-
setPinned(true)
|
|
306
|
-
setEdit(previous => previous?.id === active.referenceId
|
|
307
|
-
? undefined
|
|
308
|
-
: { id: active.referenceId, value: active.comment ?? '' })
|
|
309
|
-
}}><IconEditOutlineRegular size={14} /></button></Tooltip>
|
|
310
|
-
<Tooltip label={labels.remove} portal><button type="button" aria-label={labels.remove} className={css.icon}
|
|
311
|
-
onClick={() => { close(); actions.onRemove?.(active.referenceId) }}><IconTrashOutlineRegular size={14} /></button></Tooltip>
|
|
312
|
-
</div>}
|
|
313
|
-
</div>
|
|
314
|
-
<div className={css.parts}>{active.parts.map((part, index) => <Part key={`${part.kind}:${index}`} part={part} labels={labels} />)}</div>
|
|
315
|
-
{active.failures.length > 0 && <p className={css.notice} role="status">{labels.partial}</p>}
|
|
316
|
-
{edit?.id === active.referenceId ? <div className={css.editor}>
|
|
317
|
-
<label htmlFor={`${id}-${active.index}-note`}>{labels.comment}</label>
|
|
318
|
-
<textarea id={`${id}-${active.index}-note`} value={edit.value} rows={2} placeholder={labels.optional} autoFocus
|
|
319
|
-
onChange={(event) => { setEdit({ id: active.referenceId, value: event.currentTarget.value }) }}
|
|
320
|
-
onKeyDown={(event) => {
|
|
321
|
-
if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') { event.preventDefault(); save() }
|
|
322
|
-
// First Escape leaves the editor; the card stays open (a second one closes it).
|
|
323
|
-
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); setEdit(undefined) }
|
|
324
|
-
}} />
|
|
325
|
-
<div className={css.editorActions}><button type="button" onClick={() => { setEdit(undefined) }}>{labels.cancel}</button><button type="button" onClick={save}>{labels.save}</button></div>
|
|
326
|
-
</div> : active.comment !== undefined && active.comment !== ''
|
|
327
|
-
? <div className={css.comment}><span className={css.secondary}>{labels.comment}</span><p>{active.comment}</p></div>
|
|
328
|
-
: null}
|
|
329
|
-
<button type="button" className={css.source} title={active.source.pageUrl} onClick={() => { actions.onReveal?.(active.referenceId) }}>
|
|
330
|
-
<IconLinkOutlineRegular size={12} /><span>{labels.reveal}</span>
|
|
331
|
-
</button>
|
|
332
|
-
{(anchor !== undefined || readOnly) && notice !== undefined && <p className={css.status} role="status">{notice}</p>}
|
|
333
|
-
</div>,
|
|
334
|
-
document.body,
|
|
335
|
-
)}
|
|
336
|
-
|
|
337
|
-
{anchor === undefined && (!readOnly || active === undefined) && cards.length > 0 && notice !== undefined && <p className={css.status} role="status">{notice}</p>}
|
|
338
|
-
</span>
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/** `useId` is React 18-only; the bundle also loads in hosts that pin 17. */
|
|
342
|
-
function useIdSafe(): string {
|
|
343
|
-
const [value] = useState(() => `dsh-ref-${Math.random().toString(36).slice(2, 9)}`)
|
|
344
|
-
return value
|
|
345
|
-
}
|