dsh-edge 0.18.0 → 0.19.0-alpha.2
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/README.i18n.yaml +2 -2
- package/README.md +8 -8
- package/README.zh.md +8 -8
- package/THIRD_PARTY_NOTICES.md +2011 -449
- package/dist/assets/fonts/Montserrat-OFL.txt +93 -0
- package/dist/assets/fonts/montserrat-light-Cvd2VjE_.woff2 +0 -0
- package/dist/assets/fonts/montserrat-medium-B4OyO9CN.woff2 +0 -0
- package/dist/assets/fonts/montserrat-regular-DYep38cA.woff2 +0 -0
- package/dist/assets/index-Cq6ljTv2.css +1 -0
- package/dist/assets/index-Dy0OhsZ5.js +127 -0
- package/dist/assets/langs/asciidoc-Ve4PFQV2.js +2 -0
- package/dist/assets/langs/bat-BkioyH1T.js +2 -0
- package/dist/assets/langs/bibtex-CHM0blh-.js +2 -0
- package/dist/assets/langs/clojure-P80f7IUj.js +2 -0
- package/dist/assets/langs/cmake-D1j8_8rp.js +2 -0
- package/dist/assets/langs/csv-fuZLfV_i.js +2 -0
- package/dist/assets/langs/dart-bE4Kk8sk.js +2 -0
- package/dist/assets/langs/diff-D97Zzqfu.js +2 -0
- package/dist/assets/langs/dotenv-Da5cRb03.js +2 -0
- package/dist/assets/langs/elixir-CvYZzuDY.js +2 -0
- package/dist/assets/langs/erlang-DsQrWhSR.js +2 -0
- package/dist/assets/langs/fish-BvzEVeQv.js +2 -0
- package/dist/assets/langs/fsharp-CXgrBDvD.js +2 -0
- package/dist/assets/langs/graphql-DujV8YkJ.js +2 -0
- package/dist/assets/langs/groovy-gcz8RCvz.js +2 -0
- package/dist/assets/langs/haskell-Df6bDoY_.js +2 -0
- package/dist/assets/langs/hcl-BWvSN4gD.js +2 -0
- package/dist/assets/langs/html-derivative-DOyKdj44.js +2 -0
- package/dist/assets/langs/html-fwsONPVS.js +2 -0
- package/dist/assets/langs/http-DcV90OkR.js +2 -0
- package/dist/assets/langs/javascript-DI5JR1nB.js +2 -0
- package/dist/assets/langs/julia-BpJ6DjL_.js +2 -0
- package/dist/assets/langs/latex-B4C7GdlO.js +2 -0
- package/dist/assets/langs/log-2UxHyX5q.js +2 -0
- package/dist/assets/langs/make-CHLpvVh8.js +2 -0
- package/dist/assets/langs/nix-CwoSXNpI.js +2 -0
- package/dist/assets/langs/perl-DsWkoyyU.js +2 -0
- package/dist/assets/langs/php-LEPfNACG.js +2 -0
- package/dist/assets/langs/powershell-Dpen1YoG.js +2 -0
- package/dist/assets/langs/proto-C7zT0LnQ.js +2 -0
- package/dist/assets/langs/r-Dspwwk_N.js +2 -0
- package/dist/assets/langs/rst-BbocfKWr.js +2 -0
- package/dist/assets/langs/ruby-R292Iif0.js +2 -0
- package/dist/assets/langs/scala-C151Ov-r.js +2 -0
- package/dist/assets/langs/svelte-DNMY6jOf.js +2 -0
- package/dist/assets/langs/system-verilog-CnnmHF94.js +2 -0
- package/dist/assets/langs/vb-D17OF-Vu.js +2 -0
- package/dist/assets/langs/verilog-BQ8w6xss.js +2 -0
- package/dist/assets/langs/vue-Dq2x6432.js +2 -0
- package/dist/favicon-dark.svg +3 -0
- package/dist/favicon.svg +0 -5
- package/dist/index.html +5 -4
- package/dist/manifest.webmanifest +3 -4
- package/dist/plugins/@deepseek-ai/dsh-api-gateway/client.js +353 -101
- package/dist/plugins/@deepseek-ai/dsh-api-job-controller/client.js +367 -0
- package/dist/plugins/@deepseek-ai/dsh-api-remotes/client.js +7223 -3584
- package/dist/plugins/@deepseek-ai/dsh-api-session-controller/client.js +1107 -991
- package/dist/plugins/@deepseek-ai/dsh-api-workspace-controller/client.js +119 -6
- package/dist/plugins/@deepseek-ai/dsh-api-workspace-files/client.js +41 -35
- package/dist/plugins/@deepseek-ai/dsh-client-connection/client.js +354 -5279
- package/dist/plugins/@deepseek-ai/dsh-client-file-upload/client.js +10 -23
- package/dist/plugins/@deepseek-ai/dsh-client-locale/client.js +234 -80
- package/dist/plugins/@deepseek-ai/dsh-client-modules/client.js +554 -46
- package/dist/plugins/@deepseek-ai/dsh-client-shortcuts/client.js +2006 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-agent-preset/client.js +1090 -914
- package/dist/plugins/@deepseek-ai/dsh-client-ui-approval/client.js +79 -6
- package/dist/plugins/@deepseek-ai/dsh-client-ui-attachment/client.js +126 -155
- package/dist/plugins/@deepseek-ai/dsh-client-ui-chat/client.js +5776 -1593
- package/dist/plugins/@deepseek-ai/dsh-client-ui-commands/client.js +375 -121
- package/dist/plugins/@deepseek-ai/dsh-client-ui-conversation/client.js +3524 -1923
- package/dist/plugins/@deepseek-ai/dsh-client-ui-deliverables/client.js +1615 -258
- package/dist/plugins/@deepseek-ai/dsh-client-ui-directory-picker-browse/client.js +9 -9
- package/dist/plugins/@deepseek-ai/dsh-client-ui-goal/client.js +25 -10
- package/dist/plugins/@deepseek-ai/dsh-client-ui-input-trigger/client.js +169 -24
- package/dist/plugins/@deepseek-ai/dsh-client-ui-jobs/client.js +413 -63
- package/dist/plugins/@deepseek-ai/dsh-client-ui-layout/client.js +131 -14
- package/dist/plugins/@deepseek-ai/dsh-client-ui-message-feedback/client.js +24 -22
- package/dist/plugins/@deepseek-ai/dsh-client-ui-model-selection/client.js +281 -128
- package/dist/plugins/@deepseek-ai/dsh-client-ui-open-in-app/client.js +674 -223
- package/dist/plugins/@deepseek-ai/dsh-client-ui-plan/client.js +596 -18
- package/dist/plugins/@deepseek-ai/dsh-client-ui-reference/client.js +92 -9
- package/dist/plugins/@deepseek-ai/dsh-client-ui-renderer/client.js +467 -59
- package/dist/plugins/@deepseek-ai/dsh-client-ui-session/client.js +231 -72
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings/client.js +281 -117
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-general/client.js +642 -122
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-models/client.js +1565 -438
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/client.js +201 -75
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugins/client.js +30 -1628
- package/dist/plugins/@deepseek-ai/dsh-client-ui-shortcuts/client.js +1163 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar/client.js +165 -39
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-browser/client.js +1648 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client.js +5515 -25622
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-files/client.js +419 -118
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-right/client.js +5692 -260
- package/dist/plugins/@deepseek-ai/dsh-client-ui-skill/client.js +156 -41
- package/dist/plugins/@deepseek-ai/dsh-client-ui-subagent/client.js +386 -263
- package/dist/plugins/@deepseek-ai/dsh-client-ui-theme/client.js +183 -73
- package/dist/plugins/@deepseek-ai/dsh-client-ui-tool/client.js +2367 -429
- package/dist/plugins/@deepseek-ai/dsh-client-ui-trajectory/client.js +788 -270
- package/dist/plugins/@deepseek-ai/dsh-client-ui-user-questions/client.js +87 -79
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workflow-run/client.js +28 -14
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workspace/client.js +2647 -1044
- package/dist/plugins/@deepseek-ai/dsh-typert-registry/client.js +22 -7
- package/dist/plugins/dsh-edge-client-ui/client.js +1 -10
- package/package.json +96 -86
- package/scripts/cli.mjs +16 -4
- package/scripts/install.d.mts +12 -2
- package/scripts/install.mjs +36 -9
- package/scripts/legal-files.mjs +15 -0
- package/worker/direct/index.js +2564 -1822
- package/worker/isolated/index.js +2144 -1402
- package/dist/assets/index-BKQ_L1z6.js +0 -117
- package/dist/assets/index-DPX2bQLO.css +0 -1
- package/dist/assets/langs/html-CfGypltT.js +0 -2
- package/dist/assets/langs/php-DJl5gRdb.js +0 -2
- package/dist/assets/langs/ruby-5eNB0pDK.js +0 -2
- package/dist/plugins/@deepseek-ai/dsh-client-ui-permission-presets/client.js +0 -505
- package/dist/plugins/@deepseek-ai/dsh-client-ui-schedule/client.js +0 -307
|
@@ -0,0 +1,1648 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@deepseek-ai/dsh-client-ui-sidebar-browser",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
10
|
+
let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
|
|
11
|
+
//#region lib/types/client/browser/BrowserFrame.js
|
|
12
|
+
/**
|
|
13
|
+
* Create idle navigation state without a page target.
|
|
14
|
+
* @returns state before any page has been requested.
|
|
15
|
+
*/
|
|
16
|
+
function emptyBrowserFrame() {
|
|
17
|
+
return {
|
|
18
|
+
target: void 0,
|
|
19
|
+
address: "empty",
|
|
20
|
+
loading: false,
|
|
21
|
+
canGoBack: false,
|
|
22
|
+
canGoForward: false,
|
|
23
|
+
error: void 0,
|
|
24
|
+
sandboxEnabled: void 0
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region lib/types/client/browser/BrowserPersistence.js
|
|
29
|
+
/**
|
|
30
|
+
* Read the selected address from a saved navigation record.
|
|
31
|
+
* @param state - saved navigation.
|
|
32
|
+
* @returns its last selected address, if any.
|
|
33
|
+
*/
|
|
34
|
+
function currentBrowserTarget(state) {
|
|
35
|
+
return state === void 0 || state.index < 0 ? void 0 : state.entries[state.index];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Checkpoint an observed address without serializing native history.
|
|
39
|
+
* @param target - current address.
|
|
40
|
+
* @param revision - navigation generation.
|
|
41
|
+
* @returns an address-only checkpoint.
|
|
42
|
+
*/
|
|
43
|
+
function browserAddressCheckpoint(target, revision) {
|
|
44
|
+
return {
|
|
45
|
+
entries: [target],
|
|
46
|
+
index: 0,
|
|
47
|
+
request: {
|
|
48
|
+
target,
|
|
49
|
+
revision
|
|
50
|
+
},
|
|
51
|
+
navigation: {
|
|
52
|
+
status: "known",
|
|
53
|
+
revision
|
|
54
|
+
},
|
|
55
|
+
failure: void 0
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-sidebar-browser/src/client/view/Browser.module.css.mjs
|
|
60
|
+
const css = ".SB_kFW_root{height:100%;min-height:0;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);flex-direction:column;flex:auto;display:flex}.SB_kFW_toolbar{box-sizing:border-box;border-bottom:.5px solid var(--dsw-alias-border-l3);flex:none;align-items:center;gap:4px;height:38px;padding:5px 6px;display:flex}.SB_kFW_tool{width:28px;height:28px;color:var(--dsw-alias-label-secondary);border-radius:var(--dsw-radius-sm);cursor:pointer;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.SB_kFW_tool:hover:not(:disabled){color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.SB_kFW_tool:disabled{color:var(--dsw-alias-label-quaternary);cursor:default}.SB_kFW_sandboxOff{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 10%, transparent)}.SB_kFW_addressBox{flex:auto;min-width:0;position:relative}.SB_kFW_address{box-sizing:border-box;width:100%;height:28px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-12);background:var(--dsw-alias-bg-layer-1);border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);padding:0 34px 0 9px}.SB_kFW_addressGo{visibility:hidden;opacity:0;position:absolute;top:0;right:0}.SB_kFW_addressBox:focus-within .SB_kFW_addressGo{visibility:visible;opacity:1}.SB_kFW_addressUnknown{--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2)}.SB_kFW_addressUnknown:focus{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1)}.SB_kFW_addressChanged{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxxs-11);pointer-events:none;background:var(--dsw-alias-bg-layer-2);padding-left:8px;line-height:16px;position:absolute;top:6px;right:8px}.SB_kFW_addressBox:focus-within .SB_kFW_addressChanged{visibility:hidden;opacity:0}.SB_kFW_address:focus{outline:1px solid var(--dsw-alias-state-business-primary);outline-offset:-1px}.SB_kFW_frame{background:var(--dsw-alias-bg-base);border:0;flex:auto;width:100%;min-height:0;display:flex}.SB_kFW_content{flex:auto;min-width:0;min-height:0;display:flex;position:relative}.SB_kFW_viewport{flex:auto;min-width:0;min-height:0;display:flex}.SB_kFW_placeholder{pointer-events:none;display:flex;position:absolute;inset:0}.SB_kFW_restore{text-align:center;flex-direction:column;align-items:center;gap:10px;padding:24px;display:flex;position:absolute;inset:0;overflow:auto}.SB_kFW_restoreLabel{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-12);margin:auto 0 0}.SB_kFW_restoreTitle{overflow-wrap:anywhere;max-width:100%;font:var(--dsw-font-xs-13);margin:0;font-weight:500}.SB_kFW_restoreUrl{overflow-wrap:anywhere;max-width:100%;color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxs-12);margin:0}.SB_kFW_restore>:last-child{flex-shrink:0;margin-bottom:auto}.SB_kFW_webview{-webkit-app-region:no-drag;border:0;flex:auto;width:100%;min-width:0;height:100%;min-height:0;display:flex}html:has([data-dockkit-pointer]) .SB_kFW_webview{pointer-events:none}.SB_kFW_start{min-height:0;color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);text-align:center;flex:auto;justify-content:center;align-items:center;padding:24px;display:flex}.SB_kFW_failure{color:var(--dsw-alias-state-error-primary);font:var(--dsw-font-xxxs-11);background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 8%, transparent);flex:none;padding:6px 12px}.SB_kFW_sandboxWarning{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxxs-11);background:var(--dsw-alias-state-warn-tertiary);flex:none;padding:6px 12px}.SB_kFW_limit{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxxs-11);text-overflow:ellipsis;white-space:nowrap;border-top:.5px solid var(--dsw-alias-border-l3);flex:none;margin:0;padding:4px 10px;overflow:hidden}.SB_kFW_titleIcon{flex:none;margin-right:4px}";
|
|
61
|
+
const tagId = "@deepseek-ai/dsh-client-ui-sidebar-browser/Browser.module.css";
|
|
62
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
63
|
+
const tag = document.createElement("style");
|
|
64
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-sidebar-browser";
|
|
65
|
+
tag.dataset.pluginCss = tagId;
|
|
66
|
+
tag.textContent = css;
|
|
67
|
+
document.head.appendChild(tag);
|
|
68
|
+
}
|
|
69
|
+
var Browser_module_css_default = {
|
|
70
|
+
"address": "SB_kFW_address",
|
|
71
|
+
"addressBox": "SB_kFW_addressBox",
|
|
72
|
+
"addressChanged": "SB_kFW_addressChanged",
|
|
73
|
+
"addressGo": "SB_kFW_addressGo",
|
|
74
|
+
"addressUnknown": "SB_kFW_addressUnknown",
|
|
75
|
+
"content": "SB_kFW_content",
|
|
76
|
+
"failure": "SB_kFW_failure",
|
|
77
|
+
"frame": "SB_kFW_frame",
|
|
78
|
+
"limit": "SB_kFW_limit",
|
|
79
|
+
"placeholder": "SB_kFW_placeholder",
|
|
80
|
+
"restore": "SB_kFW_restore",
|
|
81
|
+
"restoreLabel": "SB_kFW_restoreLabel",
|
|
82
|
+
"restoreTitle": "SB_kFW_restoreTitle",
|
|
83
|
+
"restoreUrl": "SB_kFW_restoreUrl",
|
|
84
|
+
"root": "SB_kFW_root",
|
|
85
|
+
"sandboxOff": "SB_kFW_sandboxOff",
|
|
86
|
+
"sandboxWarning": "SB_kFW_sandboxWarning",
|
|
87
|
+
"start": "SB_kFW_start",
|
|
88
|
+
"titleIcon": "SB_kFW_titleIcon",
|
|
89
|
+
"tool": "SB_kFW_tool",
|
|
90
|
+
"toolbar": "SB_kFW_toolbar",
|
|
91
|
+
"viewport": "SB_kFW_viewport",
|
|
92
|
+
"webview": "SB_kFW_webview"
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region lib/types/client/view/BrowserBody.js
|
|
96
|
+
/** Common browser chrome; a presentation adapter attaches the page inside its content container. */
|
|
97
|
+
const EMPTY_FRAME = emptyBrowserFrame();
|
|
98
|
+
function SandboxPolicyIcon({ sandboxed }) {
|
|
99
|
+
return (0, react_jsx_runtime.jsxs)("svg", {
|
|
100
|
+
width: "15",
|
|
101
|
+
height: "15",
|
|
102
|
+
viewBox: "0 0 16 16",
|
|
103
|
+
fill: "none",
|
|
104
|
+
"aria-hidden": true,
|
|
105
|
+
children: [(0, react_jsx_runtime.jsx)("path", {
|
|
106
|
+
d: _deepseek_ai_dsh_client_ui_primitives.SHIELD_OUTLINE_PATH,
|
|
107
|
+
stroke: "currentColor",
|
|
108
|
+
strokeWidth: _deepseek_ai_dsh_client_ui_primitives.ICON_REGULAR_STROKE,
|
|
109
|
+
strokeLinejoin: "round"
|
|
110
|
+
}), sandboxed ? (0, react_jsx_runtime.jsx)("path", {
|
|
111
|
+
d: "M12.1654 5.7552L8.9447 9.41475C8.73044 9.65816 8.53628 9.8804 8.35774 10.0423C8.1713 10.2114 7.94235 10.3717 7.64016 10.4254C7.48207 10.4535 7.32 10.4552 7.16151 10.4294C6.85843 10.3801 6.62728 10.2223 6.43836 10.0559C6.25752 9.89653 6.06037 9.67732 5.84264 9.43705L4.72925 8.20897L5.63557 7.38707L6.74897 8.61594C6.98603 8.87755 7.12974 9.03533 7.24673 9.13839C7.31033 9.19443 7.34485 9.21476 7.35823 9.22122C7.38068 9.22484 7.40352 9.22515 7.42593 9.22122C7.40522 9.22502 7.42893 9.23294 7.53583 9.136C7.65132 9.03126 7.79316 8.87139 8.02643 8.60638L11.2479 4.94763L12.1654 5.7552Z",
|
|
112
|
+
fill: "currentColor"
|
|
113
|
+
}) : (0, react_jsx_runtime.jsx)("path", {
|
|
114
|
+
d: "M10.6074 4.40278L8.00975 6.99973L10.6074 9.59739L9.59736 10.6074L6.9997 8.00978L4.40274 10.6074L3.3927 9.59739L5.98966 6.99973L3.3927 4.40278L4.40274 3.39273L6.9997 5.98969L9.59736 3.39273L10.6074 4.40278Z",
|
|
115
|
+
fill: "currentColor",
|
|
116
|
+
transform: "translate(1.2 0.8)"
|
|
117
|
+
})]
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function useBrowserDraft(url, revision) {
|
|
121
|
+
const [edit, setEdit] = (0, react.useState)();
|
|
122
|
+
return [edit?.revision === revision ? edit.value : url ?? "", (value) => {
|
|
123
|
+
setEdit({
|
|
124
|
+
revision,
|
|
125
|
+
value
|
|
126
|
+
});
|
|
127
|
+
}];
|
|
128
|
+
}
|
|
129
|
+
/** Render provider-neutral navigation state and optional controls. */
|
|
130
|
+
function BrowserBody(props) {
|
|
131
|
+
const { mount, loadUrl, restore, goBack, goForward, reload, setSandbox, useBrowserState, useStore, useTabInfo, t } = props;
|
|
132
|
+
const { tab } = useTabInfo();
|
|
133
|
+
(0, react.useEffect)(() => tab.actions.bindCommands({ refresh: () => {
|
|
134
|
+
reload(tab.id);
|
|
135
|
+
} }), [
|
|
136
|
+
tab.actions,
|
|
137
|
+
tab.id,
|
|
138
|
+
reload
|
|
139
|
+
]);
|
|
140
|
+
const initial = (0, react.useRef)(useStore((state) => state.byTab[tab.id]));
|
|
141
|
+
const initialUrl = (0, react.useRef)(tab.navigation.params?.url);
|
|
142
|
+
const viewportId = (0, react.useId)();
|
|
143
|
+
const [mountEpoch, setMountEpoch] = (0, react.useState)(0);
|
|
144
|
+
const state = useBrowserState(tab.id);
|
|
145
|
+
const frame = state?.frame ?? EMPTY_FRAME;
|
|
146
|
+
const restoreTarget = state === void 0 ? currentBrowserTarget(initial.current) : state.restoreTarget;
|
|
147
|
+
const target = frame.target ?? restoreTarget;
|
|
148
|
+
const [draft, setDraft] = useBrowserDraft(target?.url ?? initialUrl.current, state?.addressRevision ?? 0);
|
|
149
|
+
(0, react.useLayoutEffect)(() => {
|
|
150
|
+
const hide = mount({
|
|
151
|
+
tabId: tab.id,
|
|
152
|
+
signal: tab.signal,
|
|
153
|
+
viewportId,
|
|
154
|
+
applicationOrigin: window.location.origin,
|
|
155
|
+
initial: initial.current,
|
|
156
|
+
initialUrl: initialUrl.current,
|
|
157
|
+
openTab: (url) => {
|
|
158
|
+
tab.actions.openTab("browser", {
|
|
159
|
+
params: { url },
|
|
160
|
+
revealIfOpened: false
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
setMountEpoch((value) => value + 1);
|
|
165
|
+
return hide;
|
|
166
|
+
}, [
|
|
167
|
+
mount,
|
|
168
|
+
tab.id,
|
|
169
|
+
tab.signal,
|
|
170
|
+
tab.actions,
|
|
171
|
+
viewportId,
|
|
172
|
+
props.actions
|
|
173
|
+
]);
|
|
174
|
+
const unknown = frame.address === "unknown";
|
|
175
|
+
const externalUrl = unknown ? void 0 : target?.url;
|
|
176
|
+
const sandboxed = frame.sandboxEnabled;
|
|
177
|
+
const failure = state?.addressFailure;
|
|
178
|
+
const error = frame.error;
|
|
179
|
+
const submit = (event) => {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
loadUrl(tab.id, draft);
|
|
182
|
+
};
|
|
183
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
184
|
+
className: Browser_module_css_default.root,
|
|
185
|
+
children: [
|
|
186
|
+
(0, react_jsx_runtime.jsxs)("form", {
|
|
187
|
+
className: Browser_module_css_default.toolbar,
|
|
188
|
+
onSubmit: submit,
|
|
189
|
+
children: [
|
|
190
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
191
|
+
type: "button",
|
|
192
|
+
className: Browser_module_css_default.tool,
|
|
193
|
+
"aria-label": t("back"),
|
|
194
|
+
title: t("back"),
|
|
195
|
+
disabled: !frame.canGoBack,
|
|
196
|
+
onClick: () => {
|
|
197
|
+
goBack(tab.id);
|
|
198
|
+
},
|
|
199
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronLeftOutlineRegular, {})
|
|
200
|
+
}),
|
|
201
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
202
|
+
type: "button",
|
|
203
|
+
className: Browser_module_css_default.tool,
|
|
204
|
+
"aria-label": t("forward"),
|
|
205
|
+
title: t("forward"),
|
|
206
|
+
disabled: !frame.canGoForward,
|
|
207
|
+
onClick: () => {
|
|
208
|
+
goForward(tab.id);
|
|
209
|
+
},
|
|
210
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, {})
|
|
211
|
+
}),
|
|
212
|
+
(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
|
|
213
|
+
label: t("reload"),
|
|
214
|
+
shortcutKeys: tab.refreshShortcut?.keys,
|
|
215
|
+
side: "bottom",
|
|
216
|
+
delayMs: 500,
|
|
217
|
+
children: (0, react_jsx_runtime.jsx)("button", {
|
|
218
|
+
type: "button",
|
|
219
|
+
className: Browser_module_css_default.tool,
|
|
220
|
+
"aria-label": t("reload"),
|
|
221
|
+
"aria-keyshortcuts": tab.refreshShortcut?.aria,
|
|
222
|
+
disabled: target === void 0 || mountEpoch === 0,
|
|
223
|
+
onClick: () => {
|
|
224
|
+
reload(tab.id);
|
|
225
|
+
},
|
|
226
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, {})
|
|
227
|
+
})
|
|
228
|
+
}),
|
|
229
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
230
|
+
className: Browser_module_css_default.addressBox,
|
|
231
|
+
children: [
|
|
232
|
+
(0, react_jsx_runtime.jsx)("input", {
|
|
233
|
+
className: [Browser_module_css_default.address, unknown ? Browser_module_css_default.addressUnknown : ""].join(" "),
|
|
234
|
+
value: draft,
|
|
235
|
+
"aria-label": t("address.placeholder"),
|
|
236
|
+
placeholder: t("address.placeholder"),
|
|
237
|
+
spellCheck: false,
|
|
238
|
+
onChange: (event) => {
|
|
239
|
+
setDraft(event.currentTarget.value);
|
|
240
|
+
}
|
|
241
|
+
}),
|
|
242
|
+
unknown && (0, react_jsx_runtime.jsx)("span", {
|
|
243
|
+
className: Browser_module_css_default.addressChanged,
|
|
244
|
+
children: t("address.changed")
|
|
245
|
+
}),
|
|
246
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
247
|
+
type: "submit",
|
|
248
|
+
className: [Browser_module_css_default.tool, Browser_module_css_default.addressGo].join(" "),
|
|
249
|
+
"aria-label": t("go"),
|
|
250
|
+
title: t("go"),
|
|
251
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLinkOutlineRegular, {})
|
|
252
|
+
})
|
|
253
|
+
]
|
|
254
|
+
}),
|
|
255
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
256
|
+
type: "button",
|
|
257
|
+
className: Browser_module_css_default.tool,
|
|
258
|
+
"aria-label": t("external"),
|
|
259
|
+
title: t("external"),
|
|
260
|
+
disabled: externalUrl === void 0,
|
|
261
|
+
onClick: externalUrl === void 0 ? void 0 : () => {
|
|
262
|
+
window.open(externalUrl, "_blank", "noopener,noreferrer");
|
|
263
|
+
},
|
|
264
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRightUpOutlineRegular, { size: 14 })
|
|
265
|
+
}),
|
|
266
|
+
sandboxed !== void 0 && (0, react_jsx_runtime.jsx)("button", {
|
|
267
|
+
type: "button",
|
|
268
|
+
className: [Browser_module_css_default.tool, sandboxed ? "" : Browser_module_css_default.sandboxOff].join(" "),
|
|
269
|
+
"aria-label": t(sandboxed ? "sandbox.disable" : "sandbox.enable"),
|
|
270
|
+
title: t(sandboxed ? "sandbox.disable" : "sandbox.enable"),
|
|
271
|
+
"aria-pressed": !sandboxed,
|
|
272
|
+
onClick: () => {
|
|
273
|
+
setSandbox(tab.id, !sandboxed);
|
|
274
|
+
},
|
|
275
|
+
children: (0, react_jsx_runtime.jsx)(SandboxPolicyIcon, { sandboxed })
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
}),
|
|
279
|
+
sandboxed === false && (0, react_jsx_runtime.jsx)("div", {
|
|
280
|
+
className: Browser_module_css_default.sandboxWarning,
|
|
281
|
+
role: "status",
|
|
282
|
+
children: t("sandbox.warning")
|
|
283
|
+
}),
|
|
284
|
+
error !== void 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
285
|
+
className: Browser_module_css_default.failure,
|
|
286
|
+
role: "status",
|
|
287
|
+
children: error.code !== void 0 && error.description !== void 0 ? t("load.failed.detail", {
|
|
288
|
+
code: String(error.code),
|
|
289
|
+
description: error.description
|
|
290
|
+
}) : t("load.failed")
|
|
291
|
+
}),
|
|
292
|
+
failure !== void 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
293
|
+
className: Browser_module_css_default.failure,
|
|
294
|
+
role: "alert",
|
|
295
|
+
children: t(`error.${failure}`)
|
|
296
|
+
}),
|
|
297
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
298
|
+
className: Browser_module_css_default.content,
|
|
299
|
+
"aria-busy": frame.loading,
|
|
300
|
+
children: [
|
|
301
|
+
(0, react_jsx_runtime.jsx)("div", {
|
|
302
|
+
id: viewportId,
|
|
303
|
+
className: Browser_module_css_default.viewport,
|
|
304
|
+
"aria-label": t("type.label")
|
|
305
|
+
}),
|
|
306
|
+
restoreTarget !== void 0 && (0, react_jsx_runtime.jsxs)("section", {
|
|
307
|
+
className: Browser_module_css_default.restore,
|
|
308
|
+
"aria-label": t("restore.previous"),
|
|
309
|
+
children: [
|
|
310
|
+
(0, react_jsx_runtime.jsx)("p", {
|
|
311
|
+
className: Browser_module_css_default.restoreLabel,
|
|
312
|
+
children: t("restore.previous")
|
|
313
|
+
}),
|
|
314
|
+
(0, react_jsx_runtime.jsx)("p", {
|
|
315
|
+
className: Browser_module_css_default.restoreTitle,
|
|
316
|
+
children: restoreTarget.title
|
|
317
|
+
}),
|
|
318
|
+
(0, react_jsx_runtime.jsx)("p", {
|
|
319
|
+
className: Browser_module_css_default.restoreUrl,
|
|
320
|
+
children: restoreTarget.url
|
|
321
|
+
}),
|
|
322
|
+
(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
323
|
+
variant: "primary",
|
|
324
|
+
size: "sm",
|
|
325
|
+
disabled: mountEpoch === 0,
|
|
326
|
+
onClick: () => {
|
|
327
|
+
restore(tab.id);
|
|
328
|
+
},
|
|
329
|
+
children: t("restore.action")
|
|
330
|
+
})
|
|
331
|
+
]
|
|
332
|
+
}),
|
|
333
|
+
restoreTarget === void 0 && (target === void 0 || frame.loading) && error === void 0 && (0, react_jsx_runtime.jsx)("div", {
|
|
334
|
+
className: Browser_module_css_default.placeholder,
|
|
335
|
+
children: (0, react_jsx_runtime.jsx)("div", {
|
|
336
|
+
className: Browser_module_css_default.start,
|
|
337
|
+
children: t(target === void 0 ? "start" : "loading")
|
|
338
|
+
})
|
|
339
|
+
})
|
|
340
|
+
]
|
|
341
|
+
}),
|
|
342
|
+
unknown && (0, react_jsx_runtime.jsx)("p", {
|
|
343
|
+
className: Browser_module_css_default.limit,
|
|
344
|
+
children: t("address.unknown")
|
|
345
|
+
})
|
|
346
|
+
]
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region lib/types/client/view/BrowserTitle.js
|
|
351
|
+
/** Browser icon and current host name. */
|
|
352
|
+
function BrowserTitle({ useTabInfo, useStore }) {
|
|
353
|
+
const { tab } = useTabInfo();
|
|
354
|
+
const entry = useStore((state) => currentBrowserTarget(state.byTab[tab.id]));
|
|
355
|
+
return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconGlobeOutlineRegular, { className: Browser_module_css_default.titleIcon }), entry?.title ?? tab.title] });
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Parse one address-bar value into the fixed protocol allowlist.
|
|
359
|
+
* @param input - user or typed-open input.
|
|
360
|
+
* @param applicationOrigin - current DSH document origin, blocked for HTTPS.
|
|
361
|
+
* @returns a canonical target or the refusal reason.
|
|
362
|
+
*/
|
|
363
|
+
function parseBrowserAddress(input, applicationOrigin) {
|
|
364
|
+
const trimmed = input.trim();
|
|
365
|
+
if (trimmed === "") return {
|
|
366
|
+
ok: false,
|
|
367
|
+
reason: "empty"
|
|
368
|
+
};
|
|
369
|
+
if (trimmed.length > 16384) return {
|
|
370
|
+
ok: false,
|
|
371
|
+
reason: "invalid"
|
|
372
|
+
};
|
|
373
|
+
const candidate = /^[A-Za-z][A-Za-z\d+.-]*:(?!\d+(?:[/?#]|$))/u.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
374
|
+
let url;
|
|
375
|
+
try {
|
|
376
|
+
url = new URL(candidate);
|
|
377
|
+
} catch {
|
|
378
|
+
return {
|
|
379
|
+
ok: false,
|
|
380
|
+
reason: "invalid"
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
if (url.username !== "" || url.password !== "") return {
|
|
384
|
+
ok: false,
|
|
385
|
+
reason: "credentials"
|
|
386
|
+
};
|
|
387
|
+
if (url.protocol === "https:" || url.protocol === "http:") {
|
|
388
|
+
if (applicationOrigin !== void 0 && applicationOrigin !== "null") try {
|
|
389
|
+
if (url.origin === new URL(applicationOrigin).origin) return {
|
|
390
|
+
ok: false,
|
|
391
|
+
reason: "application-origin"
|
|
392
|
+
};
|
|
393
|
+
} catch {}
|
|
394
|
+
return {
|
|
395
|
+
ok: true,
|
|
396
|
+
target: {
|
|
397
|
+
kind: url.protocol === "https:" ? "https" : "http",
|
|
398
|
+
url: url.href,
|
|
399
|
+
title: url.hostname
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
ok: false,
|
|
405
|
+
reason: "protocol"
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region lib/types/client/browser/BrowserController.js
|
|
410
|
+
/** Carrier-independent tab commands and renderer-facing state. */
|
|
411
|
+
/** Owns input validation and page lifetime without inspecting the carrier type. */
|
|
412
|
+
var BrowserController = class {
|
|
413
|
+
options;
|
|
414
|
+
page;
|
|
415
|
+
store;
|
|
416
|
+
unsubscribe;
|
|
417
|
+
actions;
|
|
418
|
+
checkpoint;
|
|
419
|
+
started = false;
|
|
420
|
+
disposed = false;
|
|
421
|
+
disposal;
|
|
422
|
+
abort = () => {
|
|
423
|
+
this.dispose();
|
|
424
|
+
};
|
|
425
|
+
/** @param options - identity, persistence, page factory and source-tab navigation. */
|
|
426
|
+
constructor(options) {
|
|
427
|
+
this.options = options;
|
|
428
|
+
this.actions = options.actions;
|
|
429
|
+
this.checkpoint = options.initial;
|
|
430
|
+
this.page = options.createPage({
|
|
431
|
+
initial: options.initial,
|
|
432
|
+
persist: (state) => {
|
|
433
|
+
if (this.disposed) return;
|
|
434
|
+
this.checkpoint = state;
|
|
435
|
+
this.actions.replace(options.tabId, state);
|
|
436
|
+
},
|
|
437
|
+
openRequested: (value) => {
|
|
438
|
+
if (this.disposed) return;
|
|
439
|
+
const result = parseBrowserAddress(value, options.applicationOrigin);
|
|
440
|
+
if (!result.ok) {
|
|
441
|
+
this.addressFailed(result.reason);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
options.openTab(result.target.url);
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
this.store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
|
|
448
|
+
frame: this.page.frame.getSnapshot(),
|
|
449
|
+
restoreTarget: currentBrowserTarget(this.checkpoint),
|
|
450
|
+
addressFailure: void 0,
|
|
451
|
+
addressRevision: 0
|
|
452
|
+
});
|
|
453
|
+
this.unsubscribe = this.page.frame.subscribe(() => {
|
|
454
|
+
if (this.disposed) return;
|
|
455
|
+
const current = this.store.getSnapshot();
|
|
456
|
+
const frame = this.page.frame.getSnapshot();
|
|
457
|
+
const changed = frame.target?.url !== current.frame.target?.url;
|
|
458
|
+
this.store.set({
|
|
459
|
+
frame,
|
|
460
|
+
restoreTarget: frame.target === void 0 ? currentBrowserTarget(this.checkpoint) : void 0,
|
|
461
|
+
addressFailure: changed ? void 0 : current.addressFailure,
|
|
462
|
+
addressRevision: current.addressRevision + Number(changed)
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
options.signal.addEventListener("abort", this.abort, { once: true });
|
|
466
|
+
}
|
|
467
|
+
/** @returns immutable state for the common toolbar. */
|
|
468
|
+
getSnapshot = () => this.store.getSnapshot();
|
|
469
|
+
/** @param listener - state invalidation. @returns unsubscribe callback. */
|
|
470
|
+
subscribe = (listener) => this.store.subscribe(listener);
|
|
471
|
+
/**
|
|
472
|
+
* Attach the page without transferring ownership of its tab occurrence.
|
|
473
|
+
* @param viewportId - mounted content container.
|
|
474
|
+
* @returns physical attachment cleanup only.
|
|
475
|
+
*/
|
|
476
|
+
mount(viewportId) {
|
|
477
|
+
this.publishSaved();
|
|
478
|
+
return this.page.presentation.mount(viewportId);
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Consume initial navigation once; a saved checkpoint alone never starts a page.
|
|
482
|
+
* @param initialUrl - explicit typed-open address, or absence.
|
|
483
|
+
*/
|
|
484
|
+
start(initialUrl) {
|
|
485
|
+
if (this.started || this.disposed) return;
|
|
486
|
+
this.started = true;
|
|
487
|
+
if (initialUrl !== void 0) this.loadUrl(initialUrl);
|
|
488
|
+
}
|
|
489
|
+
/** Load the saved address only after an explicit restore action. */
|
|
490
|
+
restore() {
|
|
491
|
+
const target = this.store.getSnapshot().restoreTarget;
|
|
492
|
+
if (target !== void 0) this.loadUrl(target.url);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Validate an address before navigation, publishing invalid input for correction.
|
|
496
|
+
* @param value - address-bar or typed-open input.
|
|
497
|
+
*/
|
|
498
|
+
loadUrl(value) {
|
|
499
|
+
if (this.disposed) return;
|
|
500
|
+
const parsed = parseBrowserAddress(value, this.options.applicationOrigin);
|
|
501
|
+
if (!parsed.ok) {
|
|
502
|
+
this.addressFailed(parsed.reason);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
this.command(() => {
|
|
506
|
+
this.page.frame.loadUrl(parsed.target);
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
/** Delegate Back to the page's navigation provider. */
|
|
510
|
+
goBack() {
|
|
511
|
+
this.command(() => {
|
|
512
|
+
this.page.frame.goBack();
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
/** Delegate Forward to the page's navigation provider. */
|
|
516
|
+
goForward() {
|
|
517
|
+
this.command(() => {
|
|
518
|
+
this.page.frame.goForward();
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
/** Restore a saved address, or reload the already requested page. */
|
|
522
|
+
reload() {
|
|
523
|
+
if (this.store.getSnapshot().restoreTarget !== void 0) this.restore();
|
|
524
|
+
else this.command(() => {
|
|
525
|
+
this.page.frame.reload();
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Apply the optional embedding-sandbox control; unsupported providers remain unchanged.
|
|
530
|
+
* @param enabled - whether to enforce the provider's embedding sandbox.
|
|
531
|
+
*/
|
|
532
|
+
setSandbox(enabled) {
|
|
533
|
+
const sandbox = this.page.frame.sandbox;
|
|
534
|
+
if (sandbox !== void 0) this.command(() => {
|
|
535
|
+
sandbox.setEnabled(enabled);
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Redirect future checkpoint writes to a replacement Session binding.
|
|
540
|
+
* @param actions - replacement persistence writer.
|
|
541
|
+
*/
|
|
542
|
+
rebind(actions) {
|
|
543
|
+
this.actions = actions;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Release the page and detach occurrence and state listeners.
|
|
547
|
+
* @returns after page teardown; repeated callers join the same disposal.
|
|
548
|
+
*/
|
|
549
|
+
dispose() {
|
|
550
|
+
if (this.disposal !== void 0) return this.disposal;
|
|
551
|
+
this.disposed = true;
|
|
552
|
+
this.options.signal.removeEventListener("abort", this.abort);
|
|
553
|
+
this.unsubscribe();
|
|
554
|
+
this.disposal = this.page.frame.dispose();
|
|
555
|
+
return this.disposal;
|
|
556
|
+
}
|
|
557
|
+
publishSaved() {
|
|
558
|
+
if (this.checkpoint !== void 0) this.actions.replace(this.options.tabId, this.checkpoint);
|
|
559
|
+
}
|
|
560
|
+
addressFailed(reason) {
|
|
561
|
+
this.store.set({
|
|
562
|
+
...this.store.getSnapshot(),
|
|
563
|
+
addressFailure: reason
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
command(run) {
|
|
567
|
+
if (this.disposed) return;
|
|
568
|
+
const current = this.store.getSnapshot();
|
|
569
|
+
this.store.set({
|
|
570
|
+
...current,
|
|
571
|
+
addressFailure: void 0,
|
|
572
|
+
addressRevision: current.addressRevision + 1
|
|
573
|
+
});
|
|
574
|
+
run();
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
/**
|
|
578
|
+
* Own tab-occurrence controllers behind Session-scoped callbacks.
|
|
579
|
+
* @param actions - persisted view-state writer.
|
|
580
|
+
* @param createPage - composition-selected provider.
|
|
581
|
+
* @param isTabOpen - authoritative layout membership, independent of mounted bodies and plugin lifetime.
|
|
582
|
+
* @returns tab callbacks.
|
|
583
|
+
*/
|
|
584
|
+
function createBrowserControllers(actions, createPage, isTabOpen) {
|
|
585
|
+
let currentActions = actions;
|
|
586
|
+
const controllers = /* @__PURE__ */ new Map();
|
|
587
|
+
const controller = (id) => controllers.get(id)?.controller;
|
|
588
|
+
return {
|
|
589
|
+
keyedHooks: { browserState: (key) => controller(key) },
|
|
590
|
+
mount(request) {
|
|
591
|
+
const { tabId, signal } = request;
|
|
592
|
+
if (signal.aborted) return () => {};
|
|
593
|
+
let held = controllers.get(tabId);
|
|
594
|
+
if (held?.signal !== signal) {
|
|
595
|
+
if (held !== void 0) {
|
|
596
|
+
held.signal.removeEventListener("abort", held.forget);
|
|
597
|
+
held.controller.dispose();
|
|
598
|
+
}
|
|
599
|
+
const created = new BrowserController({
|
|
600
|
+
...request,
|
|
601
|
+
actions: currentActions,
|
|
602
|
+
createPage
|
|
603
|
+
});
|
|
604
|
+
const forget = () => {
|
|
605
|
+
controllers.delete(tabId);
|
|
606
|
+
if (!isTabOpen(tabId)) currentActions.forget(tabId);
|
|
607
|
+
};
|
|
608
|
+
held = {
|
|
609
|
+
signal,
|
|
610
|
+
controller: created,
|
|
611
|
+
forget
|
|
612
|
+
};
|
|
613
|
+
controllers.set(tabId, held);
|
|
614
|
+
signal.addEventListener("abort", forget, { once: true });
|
|
615
|
+
}
|
|
616
|
+
const hide = held.controller.mount(request.viewportId);
|
|
617
|
+
held.controller.start(request.initialUrl);
|
|
618
|
+
return hide;
|
|
619
|
+
},
|
|
620
|
+
dispose: async () => {
|
|
621
|
+
const pending = [...controllers.values()].map(({ signal, controller, forget }) => {
|
|
622
|
+
signal.removeEventListener("abort", forget);
|
|
623
|
+
return controller.dispose();
|
|
624
|
+
});
|
|
625
|
+
controllers.clear();
|
|
626
|
+
await Promise.all(pending);
|
|
627
|
+
},
|
|
628
|
+
rebind: (actions) => {
|
|
629
|
+
currentActions = actions;
|
|
630
|
+
for (const { controller } of controllers.values()) controller.rebind(actions);
|
|
631
|
+
},
|
|
632
|
+
loadUrl: (id, value) => {
|
|
633
|
+
controller(id)?.loadUrl(value);
|
|
634
|
+
},
|
|
635
|
+
restore: (id) => {
|
|
636
|
+
controller(id)?.restore();
|
|
637
|
+
},
|
|
638
|
+
goBack: (id) => {
|
|
639
|
+
controller(id)?.goBack();
|
|
640
|
+
},
|
|
641
|
+
goForward: (id) => {
|
|
642
|
+
controller(id)?.goForward();
|
|
643
|
+
},
|
|
644
|
+
reload: (id) => {
|
|
645
|
+
controller(id)?.reload();
|
|
646
|
+
},
|
|
647
|
+
setSandbox: (id, enabled) => {
|
|
648
|
+
controller(id)?.setSandbox(enabled);
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Owns the application-known URL history and the iframe observation state machine.
|
|
654
|
+
* The first load for a request keeps its URL authoritative; another load marks it unknown.
|
|
655
|
+
*/
|
|
656
|
+
var BrowserNavigation = class BrowserNavigation {
|
|
657
|
+
value;
|
|
658
|
+
/**
|
|
659
|
+
* @param initial - persisted state restored for this tab, or a fresh empty state.
|
|
660
|
+
*/
|
|
661
|
+
constructor(initial = BrowserNavigation.empty()) {
|
|
662
|
+
this.value = initial;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Create state before a tab has a controlled navigation target.
|
|
666
|
+
* @returns empty serializable state.
|
|
667
|
+
*/
|
|
668
|
+
static empty() {
|
|
669
|
+
return {
|
|
670
|
+
entries: [],
|
|
671
|
+
index: -1,
|
|
672
|
+
request: void 0,
|
|
673
|
+
navigation: { status: "empty" },
|
|
674
|
+
failure: void 0
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Read the selected application-history entry.
|
|
679
|
+
* @param state - serializable tab state.
|
|
680
|
+
* @returns the current target, if any.
|
|
681
|
+
*/
|
|
682
|
+
static current(state) {
|
|
683
|
+
return state === void 0 || state.index < 0 ? void 0 : state.entries[state.index];
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Test whether the Web carrier can use the preceding application-history entry.
|
|
687
|
+
* @param state - serializable tab state.
|
|
688
|
+
* @returns whether Back is available.
|
|
689
|
+
*/
|
|
690
|
+
static canGoBack(state) {
|
|
691
|
+
return state.navigation.status !== "unknown" && state.index > 0;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Test whether the Web carrier can use the following application-history entry.
|
|
695
|
+
* @param state - serializable tab state.
|
|
696
|
+
* @returns whether Forward is available.
|
|
697
|
+
*/
|
|
698
|
+
static canGoForward(state) {
|
|
699
|
+
return state.navigation.status !== "unknown" && state.index >= 0 && state.index < state.entries.length - 1;
|
|
700
|
+
}
|
|
701
|
+
/** Current immutable serializable state. */
|
|
702
|
+
get snapshot() {
|
|
703
|
+
return this.value;
|
|
704
|
+
}
|
|
705
|
+
/** Whether the Web iframe can safely use the application-owned Back entry. */
|
|
706
|
+
get canGoBack() {
|
|
707
|
+
return BrowserNavigation.canGoBack(this.value);
|
|
708
|
+
}
|
|
709
|
+
/** Whether the Web iframe can safely use the application-owned Forward entry. */
|
|
710
|
+
get canGoForward() {
|
|
711
|
+
return BrowserNavigation.canGoForward(this.value);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Add a controlled target and discard its stale forward branch.
|
|
715
|
+
* @param target - validated canonical target.
|
|
716
|
+
* @returns the new load request.
|
|
717
|
+
*/
|
|
718
|
+
navigate(target) {
|
|
719
|
+
const entries = [...this.value.entries.slice(0, this.value.index + 1), target];
|
|
720
|
+
if (entries.length > 100) entries.splice(0, entries.length - 100);
|
|
721
|
+
return this.request(target, {
|
|
722
|
+
...this.value,
|
|
723
|
+
entries,
|
|
724
|
+
index: entries.length - 1
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Select the preceding application-known target.
|
|
729
|
+
* @returns a new load request, or undefined when unavailable.
|
|
730
|
+
*/
|
|
731
|
+
back() {
|
|
732
|
+
if (!this.canGoBack) return void 0;
|
|
733
|
+
const index = this.value.index - 1;
|
|
734
|
+
const target = this.value.entries[index];
|
|
735
|
+
return this.request(target, {
|
|
736
|
+
...this.value,
|
|
737
|
+
index
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Select the following application-known target.
|
|
742
|
+
* @returns a new load request, or undefined when unavailable.
|
|
743
|
+
*/
|
|
744
|
+
forward() {
|
|
745
|
+
if (!this.canGoForward) return void 0;
|
|
746
|
+
const index = this.value.index + 1;
|
|
747
|
+
const target = this.value.entries[index];
|
|
748
|
+
return this.request(target, {
|
|
749
|
+
...this.value,
|
|
750
|
+
index
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Start another load of the last application-known target.
|
|
755
|
+
* @returns a new load request, or undefined before the first target.
|
|
756
|
+
*/
|
|
757
|
+
reload() {
|
|
758
|
+
const target = BrowserNavigation.current(this.value);
|
|
759
|
+
return target === void 0 ? void 0 : this.request(target, this.value);
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Record a frame load for its captured revision.
|
|
763
|
+
* @param revision - revision bound to the rendered frame.
|
|
764
|
+
*/
|
|
765
|
+
frameLoaded(revision) {
|
|
766
|
+
const navigation = this.value.navigation;
|
|
767
|
+
if (navigation.status === "empty" || navigation.revision !== revision) return;
|
|
768
|
+
if (navigation.status === "loading") this.value = {
|
|
769
|
+
...this.value,
|
|
770
|
+
navigation: {
|
|
771
|
+
status: "known",
|
|
772
|
+
revision
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
else if (navigation.status === "known") this.value = {
|
|
776
|
+
...this.value,
|
|
777
|
+
navigation: {
|
|
778
|
+
status: "unknown",
|
|
779
|
+
revision
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
request(target, basis) {
|
|
784
|
+
const request = {
|
|
785
|
+
revision: (this.value.request?.revision ?? 0) + 1,
|
|
786
|
+
target
|
|
787
|
+
};
|
|
788
|
+
this.value = {
|
|
789
|
+
...basis,
|
|
790
|
+
request,
|
|
791
|
+
navigation: {
|
|
792
|
+
status: "loading",
|
|
793
|
+
revision: request.revision
|
|
794
|
+
},
|
|
795
|
+
failure: void 0
|
|
796
|
+
};
|
|
797
|
+
return request;
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
//#endregion
|
|
801
|
+
//#region lib/types/client/browser/IframeImpl.js
|
|
802
|
+
/** Iframe navigation provider with bounded application-known history. */
|
|
803
|
+
/** Owns iframe navigation; the view reports loads without reading cross-origin content. */
|
|
804
|
+
var IframeImpl = class {
|
|
805
|
+
options;
|
|
806
|
+
presentation;
|
|
807
|
+
sandbox = { setEnabled: (enabled) => {
|
|
808
|
+
this.setSandbox(enabled);
|
|
809
|
+
} };
|
|
810
|
+
navigation;
|
|
811
|
+
store;
|
|
812
|
+
sandboxed = true;
|
|
813
|
+
error;
|
|
814
|
+
disposed = false;
|
|
815
|
+
disposal;
|
|
816
|
+
/** @param options - initial checkpoint and persistence writer. @param presentation - iframe DOM adapter. */
|
|
817
|
+
constructor(options, presentation) {
|
|
818
|
+
this.options = options;
|
|
819
|
+
this.presentation = presentation;
|
|
820
|
+
this.navigation = new BrowserNavigation(options.initial);
|
|
821
|
+
this.store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
|
|
822
|
+
...emptyBrowserFrame(),
|
|
823
|
+
sandboxEnabled: this.sandboxed
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Record a controlled load or a later navigation to an unreadable address.
|
|
828
|
+
* @param revision - document generation whose iframe emitted load.
|
|
829
|
+
*/
|
|
830
|
+
handleLoaded(revision) {
|
|
831
|
+
if (this.disposed) return;
|
|
832
|
+
this.navigation.frameLoaded(revision);
|
|
833
|
+
this.publish();
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Publish a failure only for the current document generation.
|
|
837
|
+
* @param revision - document generation whose iframe reported failure.
|
|
838
|
+
*/
|
|
839
|
+
handleLoadFailed(revision) {
|
|
840
|
+
if (this.disposed || this.navigation.snapshot.request?.revision !== revision) return;
|
|
841
|
+
this.error = {
|
|
842
|
+
code: void 0,
|
|
843
|
+
description: void 0
|
|
844
|
+
};
|
|
845
|
+
this.publish();
|
|
846
|
+
}
|
|
847
|
+
/** @returns immutable navigation state. */
|
|
848
|
+
getSnapshot = () => this.store.getSnapshot();
|
|
849
|
+
/** @param listener - state invalidation. @returns unsubscribe callback. */
|
|
850
|
+
subscribe = (listener) => this.store.subscribe(listener);
|
|
851
|
+
/** @param target - validated address; submitting the current address reloads it. */
|
|
852
|
+
loadUrl(target) {
|
|
853
|
+
if (this.disposed) return;
|
|
854
|
+
const request = BrowserNavigation.current(this.navigation.snapshot)?.url === target.url ? this.navigation.reload() : this.navigation.navigate(target);
|
|
855
|
+
this.load(request);
|
|
856
|
+
}
|
|
857
|
+
/** Move through application-known history while the iframe address remains known. */
|
|
858
|
+
goBack() {
|
|
859
|
+
if (!this.disposed) this.load(this.navigation.back());
|
|
860
|
+
}
|
|
861
|
+
/** Move through application-known history while the iframe address remains known. */
|
|
862
|
+
goForward() {
|
|
863
|
+
if (!this.disposed) this.load(this.navigation.forward());
|
|
864
|
+
}
|
|
865
|
+
/** Reload the last application-known address. */
|
|
866
|
+
reload() {
|
|
867
|
+
if (!this.disposed) this.load(this.navigation.reload());
|
|
868
|
+
}
|
|
869
|
+
/** @returns after the presentation has been removed; repeated calls join disposal. */
|
|
870
|
+
dispose() {
|
|
871
|
+
if (this.disposal !== void 0) return this.disposal;
|
|
872
|
+
this.disposed = true;
|
|
873
|
+
this.presentation.dispose();
|
|
874
|
+
this.disposal = Promise.resolve();
|
|
875
|
+
return this.disposal;
|
|
876
|
+
}
|
|
877
|
+
setSandbox(enabled) {
|
|
878
|
+
if (this.disposed || enabled === this.sandboxed) return;
|
|
879
|
+
this.sandboxed = enabled;
|
|
880
|
+
if (this.store.getSnapshot().target === void 0) {
|
|
881
|
+
this.store.set({
|
|
882
|
+
...this.store.getSnapshot(),
|
|
883
|
+
sandboxEnabled: enabled
|
|
884
|
+
});
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
this.load(this.navigation.reload());
|
|
888
|
+
}
|
|
889
|
+
load(request) {
|
|
890
|
+
if (request === void 0) return;
|
|
891
|
+
this.error = void 0;
|
|
892
|
+
this.publish();
|
|
893
|
+
this.presentation.show({
|
|
894
|
+
target: request.target,
|
|
895
|
+
revision: request.revision,
|
|
896
|
+
sandboxed: this.sandboxed
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
snapshot() {
|
|
900
|
+
const state = this.navigation.snapshot;
|
|
901
|
+
const target = BrowserNavigation.current(state);
|
|
902
|
+
return {
|
|
903
|
+
target,
|
|
904
|
+
address: target === void 0 ? "empty" : state.navigation.status === "unknown" ? "unknown" : "requested",
|
|
905
|
+
loading: state.navigation.status === "loading" && this.error === void 0,
|
|
906
|
+
canGoBack: this.navigation.canGoBack,
|
|
907
|
+
canGoForward: this.navigation.canGoForward,
|
|
908
|
+
error: this.error,
|
|
909
|
+
sandboxEnabled: this.sandboxed
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
publish() {
|
|
913
|
+
this.store.set(this.snapshot());
|
|
914
|
+
this.options.persist(this.navigation.snapshot);
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
//#endregion
|
|
918
|
+
//#region lib/types/client/view/IframePresentation.js
|
|
919
|
+
/** Fixed iframe policy; top navigation and downloads are not granted directly. */
|
|
920
|
+
const WEB_BROWSER_SANDBOX = "allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox";
|
|
921
|
+
/** Owns the iframe element; navigation and history remain in IframeImpl. */
|
|
922
|
+
var IframePresentation = class {
|
|
923
|
+
events;
|
|
924
|
+
host;
|
|
925
|
+
element;
|
|
926
|
+
document;
|
|
927
|
+
rendered = false;
|
|
928
|
+
/** @param events - provider-owned load and remount callbacks. */
|
|
929
|
+
constructor(events) {
|
|
930
|
+
this.events = events;
|
|
931
|
+
}
|
|
932
|
+
/** @param viewportId - mounted placeholder. @returns removes only the iframe presentation. */
|
|
933
|
+
mount(viewportId) {
|
|
934
|
+
const host = document.getElementById(viewportId);
|
|
935
|
+
if (host === null) throw new Error("iframe presentation: viewport is not mounted");
|
|
936
|
+
this.element?.remove();
|
|
937
|
+
this.element = void 0;
|
|
938
|
+
this.host = host;
|
|
939
|
+
if (this.rendered) this.events.remounted();
|
|
940
|
+
else this.render();
|
|
941
|
+
return () => {
|
|
942
|
+
if (this.host !== host) return;
|
|
943
|
+
this.element?.remove();
|
|
944
|
+
this.element = void 0;
|
|
945
|
+
this.host = void 0;
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Retain the prepared document and render it when a container is mounted.
|
|
950
|
+
* @param value - prepared document and event generation.
|
|
951
|
+
*/
|
|
952
|
+
show(value) {
|
|
953
|
+
this.document = value;
|
|
954
|
+
this.render();
|
|
955
|
+
}
|
|
956
|
+
/** Remove the owned DOM and retained presentation data. */
|
|
957
|
+
dispose() {
|
|
958
|
+
this.element?.remove();
|
|
959
|
+
this.element = void 0;
|
|
960
|
+
this.host = void 0;
|
|
961
|
+
this.document = void 0;
|
|
962
|
+
}
|
|
963
|
+
render() {
|
|
964
|
+
const current = this.document;
|
|
965
|
+
const host = this.host;
|
|
966
|
+
if (current === void 0 || host === void 0) return;
|
|
967
|
+
this.element?.remove();
|
|
968
|
+
const element = document.createElement("iframe");
|
|
969
|
+
element.className = Browser_module_css_default.frame;
|
|
970
|
+
element.src = current.target.url;
|
|
971
|
+
element.title = current.target.title;
|
|
972
|
+
element.referrerPolicy = "no-referrer";
|
|
973
|
+
element.dataset.sidebarBrowserFrame = "iframe";
|
|
974
|
+
if (current.sandboxed) element.setAttribute("sandbox", WEB_BROWSER_SANDBOX);
|
|
975
|
+
element.addEventListener("load", () => {
|
|
976
|
+
if (this.element === element) this.events.loaded(current.revision);
|
|
977
|
+
});
|
|
978
|
+
element.addEventListener("error", () => {
|
|
979
|
+
if (this.element === element) this.events.failed(current.revision);
|
|
980
|
+
});
|
|
981
|
+
this.element = element;
|
|
982
|
+
this.rendered = true;
|
|
983
|
+
host.append(element);
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
//#endregion
|
|
987
|
+
//#region lib/types/client/pages.js
|
|
988
|
+
/**
|
|
989
|
+
* Assemble an idle iframe provider and its DOM presentation.
|
|
990
|
+
* @param options - saved navigation and callbacks.
|
|
991
|
+
* @returns the Web page's navigation and presentation objects.
|
|
992
|
+
*/
|
|
993
|
+
function createIframePage(options) {
|
|
994
|
+
const presentation = new IframePresentation({
|
|
995
|
+
loaded: (revision) => {
|
|
996
|
+
frame.handleLoaded(revision);
|
|
997
|
+
},
|
|
998
|
+
failed: (revision) => {
|
|
999
|
+
frame.handleLoadFailed(revision);
|
|
1000
|
+
},
|
|
1001
|
+
remounted: () => {
|
|
1002
|
+
frame.reload();
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
const frame = new IframeImpl(options, presentation);
|
|
1006
|
+
return {
|
|
1007
|
+
frame,
|
|
1008
|
+
presentation
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
//#endregion
|
|
1012
|
+
//#region lib/types/client/electron/ElectronWebViewImpl.js
|
|
1013
|
+
/** Electron navigation and guest lifetime, independent from DOM placement. */
|
|
1014
|
+
/** Owns native history and translates Electron observations into common frame state. */
|
|
1015
|
+
var ElectronWebViewImpl = class {
|
|
1016
|
+
options;
|
|
1017
|
+
bridge;
|
|
1018
|
+
workspace;
|
|
1019
|
+
presentation;
|
|
1020
|
+
store;
|
|
1021
|
+
lifetime = new AbortController();
|
|
1022
|
+
guestLifetime;
|
|
1023
|
+
element;
|
|
1024
|
+
lease;
|
|
1025
|
+
workspaceKey;
|
|
1026
|
+
initializing;
|
|
1027
|
+
ready = false;
|
|
1028
|
+
pending;
|
|
1029
|
+
revision = 0;
|
|
1030
|
+
firstDocument = true;
|
|
1031
|
+
checkpoint;
|
|
1032
|
+
disposal;
|
|
1033
|
+
attachment;
|
|
1034
|
+
releases = /* @__PURE__ */ new Set();
|
|
1035
|
+
/**
|
|
1036
|
+
* @param options - saved address, persistence and source-tab opening callback.
|
|
1037
|
+
* @param bridge - main-process guest operations.
|
|
1038
|
+
* @param workspace - resolves the storage account once for this frame lifetime.
|
|
1039
|
+
* @param presentation - tag and Sidebar placement adapter.
|
|
1040
|
+
*/
|
|
1041
|
+
constructor(options, bridge, workspace, presentation) {
|
|
1042
|
+
this.options = options;
|
|
1043
|
+
this.bridge = bridge;
|
|
1044
|
+
this.workspace = workspace;
|
|
1045
|
+
this.presentation = presentation;
|
|
1046
|
+
this.checkpoint = currentBrowserTarget(options.initial);
|
|
1047
|
+
this.store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)(emptyBrowserFrame());
|
|
1048
|
+
}
|
|
1049
|
+
/** @returns immutable carrier-neutral navigation state. */
|
|
1050
|
+
getSnapshot = () => this.store.getSnapshot();
|
|
1051
|
+
/** @param listener - state invalidation. @returns unsubscribe callback. */
|
|
1052
|
+
subscribe = (listener) => this.store.subscribe(listener);
|
|
1053
|
+
/** A physical mount may recreate a lost guest; ordinary Sidebar hiding never calls this. */
|
|
1054
|
+
attach() {
|
|
1055
|
+
if (this.lifetime.signal.aborted) return;
|
|
1056
|
+
this.attachment = new AbortController();
|
|
1057
|
+
this.pending ??= this.store.getSnapshot().target;
|
|
1058
|
+
if (this.pending !== void 0) {
|
|
1059
|
+
this.store.set({
|
|
1060
|
+
...this.store.getSnapshot(),
|
|
1061
|
+
address: "requested",
|
|
1062
|
+
loading: true,
|
|
1063
|
+
canGoBack: false,
|
|
1064
|
+
canGoForward: false,
|
|
1065
|
+
error: void 0
|
|
1066
|
+
});
|
|
1067
|
+
this.initialize();
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
/** Invalidate pending attachment before the containing DOM is removed. */
|
|
1071
|
+
detach() {
|
|
1072
|
+
this.attachment?.abort();
|
|
1073
|
+
this.attachment = void 0;
|
|
1074
|
+
this.pending = this.store.getSnapshot().target;
|
|
1075
|
+
this.dropGuest();
|
|
1076
|
+
}
|
|
1077
|
+
/** @param target - validated address, loaded without replacing the guest. */
|
|
1078
|
+
loadUrl(target) {
|
|
1079
|
+
if (this.lifetime.signal.aborted) return;
|
|
1080
|
+
const current = this.store.getSnapshot();
|
|
1081
|
+
if (this.ready && current.address === "observed" && current.target?.url === target.url) {
|
|
1082
|
+
this.reload();
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
this.revision++;
|
|
1086
|
+
this.pending = target;
|
|
1087
|
+
this.store.set({
|
|
1088
|
+
...current,
|
|
1089
|
+
target,
|
|
1090
|
+
address: "requested",
|
|
1091
|
+
loading: true,
|
|
1092
|
+
error: void 0
|
|
1093
|
+
});
|
|
1094
|
+
this.persist(target);
|
|
1095
|
+
if (this.ready) this.loadPending();
|
|
1096
|
+
else this.initialize();
|
|
1097
|
+
}
|
|
1098
|
+
/** Move backward through Chromium history. */
|
|
1099
|
+
goBack() {
|
|
1100
|
+
if (this.store.getSnapshot().canGoBack) this.navigate("goBack");
|
|
1101
|
+
}
|
|
1102
|
+
/** Move forward through Chromium history. */
|
|
1103
|
+
goForward() {
|
|
1104
|
+
if (this.store.getSnapshot().canGoForward) this.navigate("goForward");
|
|
1105
|
+
}
|
|
1106
|
+
/** Reload the actual current page, or retry failed guest creation. */
|
|
1107
|
+
reload() {
|
|
1108
|
+
const current = this.store.getSnapshot();
|
|
1109
|
+
if (this.lifetime.signal.aborted || current.target === void 0) return;
|
|
1110
|
+
if (!this.ready || current.error !== void 0) {
|
|
1111
|
+
this.revision++;
|
|
1112
|
+
this.pending = current.target;
|
|
1113
|
+
this.store.set({
|
|
1114
|
+
...current,
|
|
1115
|
+
loading: true,
|
|
1116
|
+
error: void 0
|
|
1117
|
+
});
|
|
1118
|
+
if (this.ready) this.loadPending();
|
|
1119
|
+
else this.initialize();
|
|
1120
|
+
} else this.navigate("reload");
|
|
1121
|
+
}
|
|
1122
|
+
/** @returns after pending initialization and the owned guest have been released. */
|
|
1123
|
+
dispose() {
|
|
1124
|
+
if (this.disposal !== void 0) return this.disposal;
|
|
1125
|
+
this.lifetime.abort();
|
|
1126
|
+
this.pending = void 0;
|
|
1127
|
+
this.disposal = Promise.all([this.dropGuest(), this.initializing]).then(() => Promise.all(this.releases)).then(() => {});
|
|
1128
|
+
this.presentation.dispose();
|
|
1129
|
+
return this.disposal;
|
|
1130
|
+
}
|
|
1131
|
+
navigate(command) {
|
|
1132
|
+
if (this.lifetime.signal.aborted || !this.ready || this.element === void 0) return;
|
|
1133
|
+
this.revision++;
|
|
1134
|
+
this.pending = void 0;
|
|
1135
|
+
this.store.set({
|
|
1136
|
+
...this.store.getSnapshot(),
|
|
1137
|
+
loading: true,
|
|
1138
|
+
error: void 0
|
|
1139
|
+
});
|
|
1140
|
+
try {
|
|
1141
|
+
this.element[command]();
|
|
1142
|
+
} catch (error) {
|
|
1143
|
+
this.commandFailed(error);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
initialize() {
|
|
1147
|
+
const attachment = this.attachment;
|
|
1148
|
+
if (attachment === void 0 || this.initializing !== void 0 || this.element !== void 0 || this.lifetime.signal.aborted) return;
|
|
1149
|
+
const signal = AbortSignal.any([this.lifetime.signal, attachment.signal]);
|
|
1150
|
+
this.initializing = this.createGuest(signal).catch(async (error) => {
|
|
1151
|
+
await this.dropGuest();
|
|
1152
|
+
if (!signal.aborted) this.commandFailed(error);
|
|
1153
|
+
}).finally(() => {
|
|
1154
|
+
this.initializing = void 0;
|
|
1155
|
+
if (this.attachment !== attachment && this.pending !== void 0) this.initialize();
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
async createGuest(attachmentSignal) {
|
|
1159
|
+
this.workspaceKey ??= await this.workspace(attachmentSignal);
|
|
1160
|
+
if (attachmentSignal.aborted) return;
|
|
1161
|
+
const reservation = await this.bridge.acquire(this.workspaceKey);
|
|
1162
|
+
if (attachmentSignal.aborted) {
|
|
1163
|
+
await this.release(reservation.lease);
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
this.lease = reservation.lease;
|
|
1167
|
+
this.guestLifetime = new AbortController();
|
|
1168
|
+
const signal = AbortSignal.any([attachmentSignal, this.guestLifetime.signal]);
|
|
1169
|
+
const element = this.presentation.createElement(reservation);
|
|
1170
|
+
this.element = element;
|
|
1171
|
+
const unsubscribeOpen = this.bridge.onOpenRequested(reservation.lease, (url) => {
|
|
1172
|
+
if (this.element === element && !signal.aborted) this.options.openRequested(url);
|
|
1173
|
+
});
|
|
1174
|
+
signal.addEventListener("abort", unsubscribeOpen, { once: true });
|
|
1175
|
+
element.addEventListener("dom-ready", () => {
|
|
1176
|
+
this.ready = true;
|
|
1177
|
+
this.observe(this.store.getSnapshot().address !== "requested");
|
|
1178
|
+
this.loadPending();
|
|
1179
|
+
}, { signal });
|
|
1180
|
+
element.addEventListener("did-navigate", () => {
|
|
1181
|
+
this.observe(true);
|
|
1182
|
+
}, { signal });
|
|
1183
|
+
element.addEventListener("did-navigate-in-page", (event) => {
|
|
1184
|
+
if (event.isMainFrame) this.observe(true);
|
|
1185
|
+
}, { signal });
|
|
1186
|
+
element.addEventListener("did-start-navigation", (event) => {
|
|
1187
|
+
if (event.isMainFrame) this.store.set({
|
|
1188
|
+
...this.store.getSnapshot(),
|
|
1189
|
+
loading: true,
|
|
1190
|
+
error: void 0
|
|
1191
|
+
});
|
|
1192
|
+
}, { signal });
|
|
1193
|
+
for (const name of [
|
|
1194
|
+
"did-start-loading",
|
|
1195
|
+
"did-stop-loading",
|
|
1196
|
+
"page-title-updated"
|
|
1197
|
+
]) element.addEventListener(name, () => {
|
|
1198
|
+
this.observe(name === "page-title-updated" && this.store.getSnapshot().address === "observed");
|
|
1199
|
+
}, { signal });
|
|
1200
|
+
element.addEventListener("did-fail-load", (event) => {
|
|
1201
|
+
const failure = event;
|
|
1202
|
+
if (failure.isMainFrame && failure.errorCode !== -3) this.failed({
|
|
1203
|
+
code: failure.errorCode,
|
|
1204
|
+
description: failure.errorDescription
|
|
1205
|
+
});
|
|
1206
|
+
}, { signal });
|
|
1207
|
+
for (const name of ["render-process-gone", "destroyed"]) element.addEventListener(name, () => {
|
|
1208
|
+
this.dropGuest();
|
|
1209
|
+
this.failed();
|
|
1210
|
+
}, { signal });
|
|
1211
|
+
this.presentation.present(element);
|
|
1212
|
+
}
|
|
1213
|
+
loadPending() {
|
|
1214
|
+
const target = this.pending;
|
|
1215
|
+
const element = this.element;
|
|
1216
|
+
if (!this.ready || target === void 0 || element === void 0) return;
|
|
1217
|
+
const revision = this.revision;
|
|
1218
|
+
this.pending = void 0;
|
|
1219
|
+
element.loadURL(target.url).catch((error) => {
|
|
1220
|
+
if (this.element !== element || this.lifetime.signal.aborted || this.revision !== revision) return;
|
|
1221
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ERR_ABORTED") return;
|
|
1222
|
+
if (this.store.getSnapshot().error === void 0) this.commandFailed(error);
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
observe(committed) {
|
|
1226
|
+
if (!this.ready || this.element === void 0 || this.lifetime.signal.aborted) return;
|
|
1227
|
+
try {
|
|
1228
|
+
this.observeReady(this.element, committed);
|
|
1229
|
+
} catch (error) {
|
|
1230
|
+
this.commandFailed(error);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
observeReady(element, committed) {
|
|
1234
|
+
const current = this.store.getSnapshot();
|
|
1235
|
+
const parsed = committed ? parseBrowserAddress(element.getURL()) : void 0;
|
|
1236
|
+
if (parsed?.ok && this.firstDocument) {
|
|
1237
|
+
element.clearHistory();
|
|
1238
|
+
this.firstDocument = false;
|
|
1239
|
+
}
|
|
1240
|
+
let target = current.target;
|
|
1241
|
+
let address = current.address;
|
|
1242
|
+
if (parsed?.ok) {
|
|
1243
|
+
target = {
|
|
1244
|
+
...parsed.target,
|
|
1245
|
+
title: element.getTitle() || parsed.target.title
|
|
1246
|
+
};
|
|
1247
|
+
address = "observed";
|
|
1248
|
+
this.presentation.show(target.title);
|
|
1249
|
+
}
|
|
1250
|
+
const loading = current.error === void 0 && element.isLoading();
|
|
1251
|
+
const canGoBack = element.canGoBack();
|
|
1252
|
+
const canGoForward = element.canGoForward();
|
|
1253
|
+
if (target?.url !== current.target?.url || target?.title !== current.target?.title || address !== current.address || loading !== current.loading || canGoBack !== current.canGoBack || canGoForward !== current.canGoForward) this.store.set({
|
|
1254
|
+
...current,
|
|
1255
|
+
target,
|
|
1256
|
+
address,
|
|
1257
|
+
loading,
|
|
1258
|
+
canGoBack,
|
|
1259
|
+
canGoForward
|
|
1260
|
+
});
|
|
1261
|
+
if (parsed?.ok && target !== void 0) this.persist(target);
|
|
1262
|
+
}
|
|
1263
|
+
persist(target) {
|
|
1264
|
+
if (target.url === this.checkpoint?.url && target.title === this.checkpoint.title) return;
|
|
1265
|
+
this.checkpoint = target;
|
|
1266
|
+
this.options.persist(browserAddressCheckpoint(target, this.revision));
|
|
1267
|
+
}
|
|
1268
|
+
failed(error = {
|
|
1269
|
+
code: void 0,
|
|
1270
|
+
description: void 0
|
|
1271
|
+
}) {
|
|
1272
|
+
if (this.lifetime.signal.aborted) return;
|
|
1273
|
+
const current = this.store.getSnapshot();
|
|
1274
|
+
this.store.set({
|
|
1275
|
+
...current,
|
|
1276
|
+
loading: false,
|
|
1277
|
+
error,
|
|
1278
|
+
canGoBack: this.ready && current.canGoBack,
|
|
1279
|
+
canGoForward: this.ready && current.canGoForward
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
commandFailed(error) {
|
|
1283
|
+
console.error("Desktop browser operation failed", error);
|
|
1284
|
+
this.failed();
|
|
1285
|
+
}
|
|
1286
|
+
dropGuest() {
|
|
1287
|
+
this.guestLifetime?.abort();
|
|
1288
|
+
this.guestLifetime = void 0;
|
|
1289
|
+
this.presentation.clear();
|
|
1290
|
+
this.element = void 0;
|
|
1291
|
+
this.ready = false;
|
|
1292
|
+
this.firstDocument = true;
|
|
1293
|
+
const lease = this.lease;
|
|
1294
|
+
this.lease = void 0;
|
|
1295
|
+
return lease === void 0 ? Promise.resolve() : this.release(lease);
|
|
1296
|
+
}
|
|
1297
|
+
release(lease) {
|
|
1298
|
+
const released = this.bridge.release(lease).catch((error) => {
|
|
1299
|
+
console.error("Desktop browser guest release failed", error);
|
|
1300
|
+
}).finally(() => {
|
|
1301
|
+
this.releases.delete(released);
|
|
1302
|
+
});
|
|
1303
|
+
this.releases.add(released);
|
|
1304
|
+
return released;
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
//#endregion
|
|
1308
|
+
//#region lib/types/client/electron/ElectronWebviewPresentation.js
|
|
1309
|
+
/** Owns tag creation and attachment, without measuring or following another element. */
|
|
1310
|
+
var ElectronWebviewPresentation = class {
|
|
1311
|
+
events;
|
|
1312
|
+
element;
|
|
1313
|
+
host;
|
|
1314
|
+
constructor(events) {
|
|
1315
|
+
this.events = events;
|
|
1316
|
+
}
|
|
1317
|
+
/** @param viewportId - committed content container. @returns ends attachment and releases its guest. */
|
|
1318
|
+
mount(viewportId) {
|
|
1319
|
+
const host = document.getElementById(viewportId);
|
|
1320
|
+
if (host === null) throw new Error("Electron presentation: content container is not mounted");
|
|
1321
|
+
if (this.host !== void 0) this.events.unmounted();
|
|
1322
|
+
this.host = host;
|
|
1323
|
+
this.events.mounted();
|
|
1324
|
+
return () => {
|
|
1325
|
+
if (this.host !== host) return;
|
|
1326
|
+
this.events.unmounted();
|
|
1327
|
+
this.host = void 0;
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Configure a detached webview for an approved guest reservation.
|
|
1332
|
+
* @param reservation - main-approved partition and bootstrap lease.
|
|
1333
|
+
* @returns a detached, configured webview.
|
|
1334
|
+
*/
|
|
1335
|
+
createElement(reservation) {
|
|
1336
|
+
const element = document.createElement("webview");
|
|
1337
|
+
element.className = Browser_module_css_default.webview;
|
|
1338
|
+
element.dataset.sidebarBrowserFrame = "webview";
|
|
1339
|
+
element.setAttribute("name", reservation.lease);
|
|
1340
|
+
element.setAttribute("partition", reservation.partition);
|
|
1341
|
+
element.setAttribute("allowpopups", "");
|
|
1342
|
+
element.setAttribute("src", "about:blank#" + reservation.lease);
|
|
1343
|
+
return element;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Attach a prepared guest, removing any previous guest DOM from the container.
|
|
1347
|
+
* @param element - configured guest with its navigation listeners already installed.
|
|
1348
|
+
* @throws when no content container is mounted.
|
|
1349
|
+
*/
|
|
1350
|
+
present(element) {
|
|
1351
|
+
if (this.host === void 0) throw new Error("Electron presentation: cannot attach without a content container");
|
|
1352
|
+
this.clear();
|
|
1353
|
+
this.element = element;
|
|
1354
|
+
this.host.append(element);
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Set the guest element's accessible label.
|
|
1358
|
+
* @param title - observed document title.
|
|
1359
|
+
*/
|
|
1360
|
+
show(title) {
|
|
1361
|
+
this.element?.setAttribute("aria-label", title);
|
|
1362
|
+
}
|
|
1363
|
+
/** Destroy only the guest DOM; a replacement may use the same mounted container. */
|
|
1364
|
+
clear() {
|
|
1365
|
+
this.element?.remove();
|
|
1366
|
+
this.element = void 0;
|
|
1367
|
+
}
|
|
1368
|
+
/** Destroy the guest DOM and release its content container. */
|
|
1369
|
+
dispose() {
|
|
1370
|
+
this.clear();
|
|
1371
|
+
this.host = void 0;
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
//#endregion
|
|
1375
|
+
//#region lib/types/client/electron/pages.js
|
|
1376
|
+
/**
|
|
1377
|
+
* Assemble an idle Electron provider; guest creation waits for mounting and navigation.
|
|
1378
|
+
* @param options - checkpoint and source-tab callbacks.
|
|
1379
|
+
* @param bridge - desktop-only transport.
|
|
1380
|
+
* @param workspace - storage account resolver.
|
|
1381
|
+
* @returns separate navigation and presentation faces.
|
|
1382
|
+
*/
|
|
1383
|
+
function createElectronPage(options, bridge, workspace) {
|
|
1384
|
+
const presentation = new ElectronWebviewPresentation({
|
|
1385
|
+
mounted: () => {
|
|
1386
|
+
frame.attach();
|
|
1387
|
+
},
|
|
1388
|
+
unmounted: () => {
|
|
1389
|
+
frame.detach();
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
const frame = new ElectronWebViewImpl(options, bridge, workspace, presentation);
|
|
1393
|
+
return {
|
|
1394
|
+
frame,
|
|
1395
|
+
presentation
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
//#endregion
|
|
1399
|
+
//#region lib/types/client/electron/workspace.js
|
|
1400
|
+
/**
|
|
1401
|
+
* Use the Workspace's canonical CWD, not its record id; ungrouped Sessions remain isolated.
|
|
1402
|
+
* @param source - authoritative Workspace membership.
|
|
1403
|
+
* @param sessionId - owning DSH Session.
|
|
1404
|
+
* @param signal - guest initialization lifetime.
|
|
1405
|
+
* @returns the storage account for this occurrence.
|
|
1406
|
+
*/
|
|
1407
|
+
async function browserWorkspace(source, sessionId, signal) {
|
|
1408
|
+
signal.throwIfAborted();
|
|
1409
|
+
if (source.getSnapshot().phase !== "ready") await new Promise((resolve, reject) => {
|
|
1410
|
+
const abort = () => {
|
|
1411
|
+
stop();
|
|
1412
|
+
const reason = signal.reason;
|
|
1413
|
+
reject(reason);
|
|
1414
|
+
};
|
|
1415
|
+
const stop = source.subscribe(() => {
|
|
1416
|
+
if (source.getSnapshot().phase !== "ready") return;
|
|
1417
|
+
stop();
|
|
1418
|
+
signal.removeEventListener("abort", abort);
|
|
1419
|
+
resolve();
|
|
1420
|
+
});
|
|
1421
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
1422
|
+
});
|
|
1423
|
+
signal.throwIfAborted();
|
|
1424
|
+
const workspace = source.getSnapshot().items.find((item) => item.sessionIds.some((id) => id === sessionId));
|
|
1425
|
+
return workspace === void 0 ? `session:${sessionId}` : `cwd:${workspace.path}`;
|
|
1426
|
+
}
|
|
1427
|
+
//#endregion
|
|
1428
|
+
//#region lib/types/client/definition.js
|
|
1429
|
+
/** Browser tab kind. */
|
|
1430
|
+
const BROWSER_KIND = "browser";
|
|
1431
|
+
/** Browser implementation identity and keyed Slot dispatch key. */
|
|
1432
|
+
const BROWSER_ID = "@deepseek-ai/dsh-client-ui-sidebar-browser";
|
|
1433
|
+
/** Build the Browser type with locale-live copy. */
|
|
1434
|
+
function browserDefinition(t) {
|
|
1435
|
+
return {
|
|
1436
|
+
id: BROWSER_ID,
|
|
1437
|
+
kind: BROWSER_KIND,
|
|
1438
|
+
multiple: true,
|
|
1439
|
+
priority: "builtin",
|
|
1440
|
+
title: () => t("type.label"),
|
|
1441
|
+
guide: [{
|
|
1442
|
+
id: "new",
|
|
1443
|
+
commandId: "browser.new",
|
|
1444
|
+
order: 30,
|
|
1445
|
+
title: () => t("guide.title"),
|
|
1446
|
+
description: () => t("guide.description"),
|
|
1447
|
+
icon: _deepseek_ai_dsh_client_ui_primitives.GuideArtworkBrowser
|
|
1448
|
+
}]
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
//#endregion
|
|
1452
|
+
//#region lib/types/client/locales.js
|
|
1453
|
+
/** Locale-owned Browser tab copy. */
|
|
1454
|
+
const zh = {
|
|
1455
|
+
"type.label": "浏览器",
|
|
1456
|
+
"guide.title": "浏览器",
|
|
1457
|
+
"guide.description": "浏览网页",
|
|
1458
|
+
"shortcut.noSession": "请先打开一个会话",
|
|
1459
|
+
"address.placeholder": "输入 HTTP(S) 地址",
|
|
1460
|
+
"address.changed": "URL 已变化",
|
|
1461
|
+
back: "后退",
|
|
1462
|
+
forward: "前进",
|
|
1463
|
+
reload: "刷新",
|
|
1464
|
+
go: "前往",
|
|
1465
|
+
external: "在系统浏览器中打开",
|
|
1466
|
+
"sandbox.disable": "关闭沙箱限制",
|
|
1467
|
+
"sandbox.enable": "恢复沙箱限制",
|
|
1468
|
+
"sandbox.warning": "沙箱限制已关闭;页面可以导航顶层应用,并使用下载、模态对话框与输入锁定。",
|
|
1469
|
+
start: "输入 HTTP(S) 地址开始浏览",
|
|
1470
|
+
loading: "正在打开…",
|
|
1471
|
+
"restore.previous": "上次打开",
|
|
1472
|
+
"restore.action": "恢复页面",
|
|
1473
|
+
"error.empty": "请输入地址。",
|
|
1474
|
+
"error.invalid": "这个地址无效或过长。",
|
|
1475
|
+
"error.protocol": "只支持 HTTP 和 HTTPS 地址;本地文件请使用文档预览。",
|
|
1476
|
+
"error.credentials": "地址不能包含用户名或密码。",
|
|
1477
|
+
"error.application-origin": "不能在嵌入浏览器中打开 DSH 应用自身。",
|
|
1478
|
+
"load.failed": "页面加载失败;请刷新重试或在系统浏览器中打开。",
|
|
1479
|
+
"load.failed.detail": "页面加载失败 ({code}): {description}",
|
|
1480
|
+
"address.unknown": "页面已跳转;当前载体无法读取新的 URL。"
|
|
1481
|
+
};
|
|
1482
|
+
/** English dictionary with the same keys. */
|
|
1483
|
+
const en = {
|
|
1484
|
+
"type.label": "Browser",
|
|
1485
|
+
"guide.title": "Browser",
|
|
1486
|
+
"guide.description": "Browse web pages",
|
|
1487
|
+
"shortcut.noSession": "Open a session first",
|
|
1488
|
+
"address.placeholder": "Enter an HTTP(S) address",
|
|
1489
|
+
"address.changed": "URL changed",
|
|
1490
|
+
back: "Back",
|
|
1491
|
+
forward: "Forward",
|
|
1492
|
+
reload: "Reload",
|
|
1493
|
+
go: "Go",
|
|
1494
|
+
external: "Open in system browser",
|
|
1495
|
+
"sandbox.disable": "Disable sandbox restrictions",
|
|
1496
|
+
"sandbox.enable": "Restore sandbox restrictions",
|
|
1497
|
+
"sandbox.warning": "Sandbox restrictions are disabled; the page can navigate the top-level app and use downloads, modal dialogs, and input locks.",
|
|
1498
|
+
start: "Enter an HTTP(S) address to start browsing",
|
|
1499
|
+
loading: "Opening…",
|
|
1500
|
+
"restore.previous": "Previously opened",
|
|
1501
|
+
"restore.action": "Restore page",
|
|
1502
|
+
"error.empty": "Enter an address.",
|
|
1503
|
+
"error.invalid": "That address is invalid or too long.",
|
|
1504
|
+
"error.protocol": "Only HTTP and HTTPS addresses are supported; use Document Preview for local files.",
|
|
1505
|
+
"error.credentials": "Addresses cannot contain a username or password.",
|
|
1506
|
+
"error.application-origin": "The embedded browser cannot open the DSH application itself.",
|
|
1507
|
+
"load.failed": "The page could not load; reload or open it in the system browser.",
|
|
1508
|
+
"load.failed.detail": "Page load failed ({code}): {description}",
|
|
1509
|
+
"address.unknown": "The page navigated; this carrier cannot read its new URL."
|
|
1510
|
+
};
|
|
1511
|
+
//#endregion
|
|
1512
|
+
//#region lib/types/client/browser/store.js
|
|
1513
|
+
/** Persisted Browser tab snapshots shared by the body and title slots. */
|
|
1514
|
+
/**
|
|
1515
|
+
* Declare the Session-scoped Browser persistence store.
|
|
1516
|
+
* @returns a fresh store handle for Slot registration.
|
|
1517
|
+
*/
|
|
1518
|
+
function createBrowserStore() {
|
|
1519
|
+
return (0, _deepseek_ai_dsh_client_store.defineStore)({
|
|
1520
|
+
init: () => ({ byTab: {} }),
|
|
1521
|
+
persist: "dsh.sidebar-browser.v1",
|
|
1522
|
+
actions: {
|
|
1523
|
+
replace: (draft, tabId, state) => {
|
|
1524
|
+
draft.byTab[tabId] = state;
|
|
1525
|
+
},
|
|
1526
|
+
forget: (draft, tabId) => {
|
|
1527
|
+
const byTab = {};
|
|
1528
|
+
for (const [id, state] of Object.entries(draft.byTab)) if (id !== tabId) byTab[id] = state;
|
|
1529
|
+
draft.byTab = byTab;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
//#endregion
|
|
1535
|
+
//#region lib/types/client/index.js
|
|
1536
|
+
/** Required Browser services. */
|
|
1537
|
+
const inject = [
|
|
1538
|
+
"slots",
|
|
1539
|
+
"locale",
|
|
1540
|
+
"sidebarRight",
|
|
1541
|
+
"sidebarRightTabs"
|
|
1542
|
+
];
|
|
1543
|
+
/** Register the Browser type, localized guide entry, body, and title. */
|
|
1544
|
+
function apply(ctx) {
|
|
1545
|
+
const namespace = "sidebarBrowser";
|
|
1546
|
+
const t = ctx.locale.bind(namespace);
|
|
1547
|
+
ctx.inject(["shortcuts"], (ctx) => {
|
|
1548
|
+
ctx.effect(() => ctx.shortcuts.register({
|
|
1549
|
+
id: "browser.new",
|
|
1550
|
+
label: () => t("guide.title"),
|
|
1551
|
+
aliases: ["browser", "new browser tab"],
|
|
1552
|
+
defaults: {
|
|
1553
|
+
"desktop:macos": {
|
|
1554
|
+
code: "KeyT",
|
|
1555
|
+
modifiers: ["primary"]
|
|
1556
|
+
},
|
|
1557
|
+
"desktop:windows": {
|
|
1558
|
+
code: "KeyT",
|
|
1559
|
+
modifiers: ["primary"]
|
|
1560
|
+
},
|
|
1561
|
+
"desktop:linux": {
|
|
1562
|
+
code: "KeyT",
|
|
1563
|
+
modifiers: ["primary"]
|
|
1564
|
+
},
|
|
1565
|
+
"web:macos": {
|
|
1566
|
+
code: "KeyT",
|
|
1567
|
+
modifiers: ["primary", "alt"]
|
|
1568
|
+
},
|
|
1569
|
+
"web:windows": {
|
|
1570
|
+
code: "KeyT",
|
|
1571
|
+
modifiers: ["primary", "alt"]
|
|
1572
|
+
}
|
|
1573
|
+
},
|
|
1574
|
+
regions: [
|
|
1575
|
+
"page",
|
|
1576
|
+
"editable",
|
|
1577
|
+
"terminal"
|
|
1578
|
+
],
|
|
1579
|
+
modals: [],
|
|
1580
|
+
resolve: ({ target: element }) => {
|
|
1581
|
+
const target = ctx.sidebarRight.commandTarget(element);
|
|
1582
|
+
if (target === void 0) return {
|
|
1583
|
+
status: "blocked",
|
|
1584
|
+
reason: t("shortcut.noSession")
|
|
1585
|
+
};
|
|
1586
|
+
return {
|
|
1587
|
+
status: "handled",
|
|
1588
|
+
run: () => {
|
|
1589
|
+
ctx.sidebarRight.openTabFromTarget("browser", target);
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
}), "ui-sidebar-browser: shortcut");
|
|
1594
|
+
});
|
|
1595
|
+
const store = createBrowserStore();
|
|
1596
|
+
const openTabs = ctx.sidebarRight.openTabs;
|
|
1597
|
+
const carrier = globalThis.dshDesktop;
|
|
1598
|
+
const desktop = carrier?.protocolVersion === 1 ? carrier.browser : void 0;
|
|
1599
|
+
ctx.effect(() => ctx.locale.register(namespace, {
|
|
1600
|
+
zh,
|
|
1601
|
+
en
|
|
1602
|
+
}), "ui-sidebar-browser.copy");
|
|
1603
|
+
ctx.effect(() => ctx.sidebarRightTabs.register({
|
|
1604
|
+
...browserDefinition(t),
|
|
1605
|
+
keepMounted: desktop !== void 0
|
|
1606
|
+
}), "ui-sidebar-browser.type");
|
|
1607
|
+
const installFrames = (scope, factory) => {
|
|
1608
|
+
const controllers = /* @__PURE__ */ new Map();
|
|
1609
|
+
scope.effect(() => async () => {
|
|
1610
|
+
const pending = [...controllers.values()].map((controller) => controller.dispose());
|
|
1611
|
+
controllers.clear();
|
|
1612
|
+
await Promise.all(pending);
|
|
1613
|
+
}, "ui-sidebar-browser.frames");
|
|
1614
|
+
scope.effect(() => scope.slots.inject("sidebar.right.pane.tab", () => scope.slots.register({
|
|
1615
|
+
name: "sidebar.right.pane.tab",
|
|
1616
|
+
key: BROWSER_ID,
|
|
1617
|
+
locale: namespace,
|
|
1618
|
+
store,
|
|
1619
|
+
inject: (sessionId, actions) => {
|
|
1620
|
+
const existing = controllers.get(sessionId);
|
|
1621
|
+
if (existing !== void 0) {
|
|
1622
|
+
existing.rebind(actions);
|
|
1623
|
+
return existing;
|
|
1624
|
+
}
|
|
1625
|
+
const controller = createBrowserControllers(actions, factory(sessionId), (tabId) => openTabs.getSnapshot().some((tab) => tab.sessionId === sessionId && tab.tabId === tabId));
|
|
1626
|
+
controllers.set(sessionId, controller);
|
|
1627
|
+
return controller;
|
|
1628
|
+
}
|
|
1629
|
+
}, BrowserBody)), "ui-sidebar-browser.body");
|
|
1630
|
+
};
|
|
1631
|
+
if (desktop === void 0) installFrames(ctx, () => createIframePage);
|
|
1632
|
+
else ctx.inject(["workspaces"], (scope) => {
|
|
1633
|
+
installFrames(scope, (sessionId) => (options) => createElectronPage(options, desktop, (signal) => browserWorkspace(scope.workspaces.list, sessionId, signal)));
|
|
1634
|
+
});
|
|
1635
|
+
ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab.title", () => ctx.slots.register({
|
|
1636
|
+
name: "sidebar.right.pane.tab.title",
|
|
1637
|
+
key: BROWSER_ID,
|
|
1638
|
+
store
|
|
1639
|
+
}, BrowserTitle)), "ui-sidebar-browser.title");
|
|
1640
|
+
}
|
|
1641
|
+
//#endregion
|
|
1642
|
+
exports.apply = apply;
|
|
1643
|
+
exports.inject = inject;
|
|
1644
|
+
return module.exports;
|
|
1645
|
+
}
|
|
1646
|
+
});
|
|
1647
|
+
|
|
1648
|
+
//# sourceMappingURL=client.js.map
|