dsh-browser-cdp 1.9.15 → 1.9.50
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.de.md +4 -0
- package/CHANGELOG.es.md +4 -0
- package/CHANGELOG.fr.md +4 -0
- package/CHANGELOG.it.md +4 -0
- package/CHANGELOG.md +94 -0
- package/CHANGELOG.ru.md +4 -0
- package/README.md +3 -3
- package/bin/cdp-cast-worker.mjs +198 -9
- package/dsh-plugin.json +1 -1
- package/lib/client.js +362 -36
- package/lib/index.js +4305 -2516
- package/package.json +15 -11
package/lib/client.js
CHANGED
|
@@ -479,6 +479,31 @@ function commitField(scope, field, value, options = {}) {
|
|
|
479
479
|
return once();
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region src/client/gen1-gate.ts
|
|
484
|
+
/**
|
|
485
|
+
* @param hasConfigForms 宿主是否提供 configForms 服务(0.1.7+ 声明式设置页标志)。
|
|
486
|
+
* @param hasOpenSettingsDocument 宿主是否暴露 settings/openSettingsDocument remote(0.1.2+ 可达设置页标志)。
|
|
487
|
+
* @returns 是否应挂 Gen-1 设置齿轮。仅在两信号都缺失(0.1.0/0.1.1)时为 true。
|
|
488
|
+
*/
|
|
489
|
+
function shouldShowGen1SettingsGear(hasConfigForms, hasOpenSettingsDocument) {
|
|
490
|
+
return !hasConfigForms && !hasOpenSettingsDocument;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/client/build.ts
|
|
495
|
+
/**
|
|
496
|
+
* Single source of truth for the client bundle's build id.
|
|
497
|
+
*
|
|
498
|
+
* Both halves import it: the client stamps it in the panel title, the host serves
|
|
499
|
+
* it from `/api/bcdp/stats` so a running renderer can notice it is behind and
|
|
500
|
+
* reload itself once (the module URL DSH serves has a revision that does not
|
|
501
|
+
* change with file contents, so the browser happily keeps an old bundle).
|
|
502
|
+
*
|
|
503
|
+
* Keep in sync with package.json — `node scripts/bump.mjs <version>` writes both.
|
|
504
|
+
*/
|
|
505
|
+
const CLIENT_BUILD = "1.9.50";
|
|
506
|
+
|
|
482
507
|
//#endregion
|
|
483
508
|
//#region src/client/index.ts
|
|
484
509
|
var React = require("react");
|
|
@@ -1297,17 +1322,27 @@ const PANEL_CSS = `
|
|
|
1297
1322
|
background: rgba(255,255,255,.12); color:#ffd8d5; text-transform:uppercase; letter-spacing:.4px; }
|
|
1298
1323
|
|
|
1299
1324
|
/* ---- tab bar: frosted pills ---- */
|
|
1300
|
-
|
|
1301
|
-
|
|
1325
|
+
/* Wrap instead of scrolling: with 4+ tabs a horizontal scrollbar hid the tabs
|
|
1326
|
+
the user was looking for, and the scrollbar itself ate a row of space. */
|
|
1327
|
+
#dsh-ego-tabs { display:flex; flex-wrap:wrap; align-content:flex-start; gap:6px; padding:9px 12px;
|
|
1328
|
+
border-bottom:1px solid rgba(255,255,255,.08); overflow-x:hidden; overflow-y:auto; max-height:92px;
|
|
1329
|
+
flex-shrink:0; scrollbar-width:thin; }
|
|
1302
1330
|
#dsh-ego-tabs:empty { display:none; }
|
|
1303
1331
|
.dsh-ego-tab {
|
|
1304
|
-
display:inline-flex; align-items:center; gap:6px; max-width:
|
|
1305
|
-
padding:5px 12px; border-radius: 999px; cursor:pointer; font-size:11.5px; flex
|
|
1332
|
+
display:inline-flex; align-items:center; gap:6px; max-width:100%; min-width:0; white-space:nowrap;
|
|
1333
|
+
padding:5px 12px; border-radius: 999px; cursor:pointer; font-size:11.5px; flex:0 1 auto;
|
|
1306
1334
|
border:1px solid rgba(255,255,255,.1);
|
|
1307
1335
|
background: rgba(72,72,74,.45); color:#aeaeb2;
|
|
1308
1336
|
transition: background .15s ease, color .15s ease, border-color .15s ease;
|
|
1309
1337
|
}
|
|
1310
|
-
.dsh-ego-tab > .dsh-ego-tabtxt { overflow:hidden; text-overflow:ellipsis; }
|
|
1338
|
+
.dsh-ego-tab > .dsh-ego-tabtxt { overflow:hidden; text-overflow:ellipsis; max-width:150px; }
|
|
1339
|
+
/* Which browser window a pill belongs to. Two Tabbit windows with the same pages
|
|
1340
|
+
used to read as duplicated tabs; a W1/W2 badge explains them instead of hiding. */
|
|
1341
|
+
.dsh-ego-tab .dsh-ego-tabwin { flex-shrink:0; font-size:9.5px; line-height:14px; padding:0 3px;
|
|
1342
|
+
border-radius:4px; border:1px solid currentColor; opacity:.55; letter-spacing:.2px; }
|
|
1343
|
+
/* Transient failure text inside the strip (close refused, capture failed). */
|
|
1344
|
+
.dsh-ego-taberr { flex-shrink:0; font-size:10.5px; line-height:16px; padding:0 6px; border-radius:999px;
|
|
1345
|
+
color:#ff453a; border:1px solid rgba(255,69,58,.45); background: rgba(255,69,58,.12); }
|
|
1311
1346
|
.dsh-ego-tab:hover { color:#f5f5f7; background: rgba(72,72,74,.65); }
|
|
1312
1347
|
.dsh-ego-tab.active {
|
|
1313
1348
|
background: #0a84ff; color:#fff; border-color: transparent;
|
|
@@ -1602,6 +1637,129 @@ function mountPluginsPageCard(ctx) {
|
|
|
1602
1637
|
}, FamilySettingsCard);
|
|
1603
1638
|
}, "dsh-browser-cdp: plugins-page config card");
|
|
1604
1639
|
}
|
|
1640
|
+
function mountLegacySettingsCard(ctx) {
|
|
1641
|
+
var forms = typeof ctx.get === "function" ? ctx.get("configForms") : void 0;
|
|
1642
|
+
var scope = forms && typeof forms.get === "function" ? forms.get("dsh-browser-cdp") : void 0;
|
|
1643
|
+
if (!scope) scope = makeBridgeScope();
|
|
1644
|
+
ctx.slots.inject("settings.plugin.item", function() {
|
|
1645
|
+
return ctx.slots.register({
|
|
1646
|
+
name: "settings.plugin.item",
|
|
1647
|
+
key: "dsh-browser-cdp",
|
|
1648
|
+
inject: function() {
|
|
1649
|
+
return { scope };
|
|
1650
|
+
}
|
|
1651
|
+
}, FamilySettingsCard);
|
|
1652
|
+
}, "dsh-browser-cdp: legacy gen-2 settings card");
|
|
1653
|
+
}
|
|
1654
|
+
function mountGen1SettingsGear(ctx) {
|
|
1655
|
+
var forms = typeof ctx.get === "function" ? ctx.get("configForms") : void 0;
|
|
1656
|
+
var hasConfigForms = !!(forms && typeof forms.get === "function");
|
|
1657
|
+
var remote = (typeof ctx.get === "function" ? ctx.get("remote") : void 0) || ctx.remote;
|
|
1658
|
+
if (!shouldShowGen1SettingsGear(hasConfigForms, !!(remote && remote.settings && typeof remote.settings.openSettingsDocument === "function"))) return;
|
|
1659
|
+
var scope = makeBridgeScope();
|
|
1660
|
+
ctx.slots.inject("shell.overlay", function() {
|
|
1661
|
+
return ctx.slots.register({
|
|
1662
|
+
name: "shell.overlay",
|
|
1663
|
+
id: "dsh-browser-cdp-settings-gear",
|
|
1664
|
+
inject: function() {
|
|
1665
|
+
return { scope };
|
|
1666
|
+
}
|
|
1667
|
+
}, SettingsGearOverlay);
|
|
1668
|
+
}, "dsh-browser-cdp: gen-1 settings gear");
|
|
1669
|
+
}
|
|
1670
|
+
function SettingsGearOverlay(props) {
|
|
1671
|
+
var scope = props.scope;
|
|
1672
|
+
var openState = React.useState(false);
|
|
1673
|
+
var isOpen = openState[0];
|
|
1674
|
+
var setOpen = openState[1];
|
|
1675
|
+
var h = React.createElement;
|
|
1676
|
+
var gearTitle = _egoLocale === "zh" ? "Agent 浏览器设置" : "Agent Browser settings";
|
|
1677
|
+
React.useEffect(function() {
|
|
1678
|
+
if (!isOpen) return;
|
|
1679
|
+
function onKey(e) {
|
|
1680
|
+
if (e && e.key === "Escape") setOpen(false);
|
|
1681
|
+
}
|
|
1682
|
+
window.addEventListener("keydown", onKey);
|
|
1683
|
+
return function() {
|
|
1684
|
+
window.removeEventListener("keydown", onKey);
|
|
1685
|
+
};
|
|
1686
|
+
}, [isOpen]);
|
|
1687
|
+
return h(React.Fragment, null, h("button", {
|
|
1688
|
+
type: "button",
|
|
1689
|
+
title: gearTitle,
|
|
1690
|
+
"aria-label": gearTitle,
|
|
1691
|
+
onClick: function() {
|
|
1692
|
+
setOpen(function(v) {
|
|
1693
|
+
return !v;
|
|
1694
|
+
});
|
|
1695
|
+
},
|
|
1696
|
+
style: {
|
|
1697
|
+
position: "fixed",
|
|
1698
|
+
right: 16,
|
|
1699
|
+
bottom: 64,
|
|
1700
|
+
zIndex: 2147483e3,
|
|
1701
|
+
width: 34,
|
|
1702
|
+
height: 34,
|
|
1703
|
+
borderRadius: "50%",
|
|
1704
|
+
border: "1px solid rgba(0,0,0,.18)",
|
|
1705
|
+
background: "rgba(255,255,255,.92)",
|
|
1706
|
+
color: "#333",
|
|
1707
|
+
cursor: "pointer",
|
|
1708
|
+
display: "flex",
|
|
1709
|
+
alignItems: "center",
|
|
1710
|
+
justifyContent: "center",
|
|
1711
|
+
boxShadow: "0 2px 8px rgba(0,0,0,.18)",
|
|
1712
|
+
padding: 0
|
|
1713
|
+
}
|
|
1714
|
+
}, h("span", { style: {
|
|
1715
|
+
fontSize: 18,
|
|
1716
|
+
lineHeight: 1
|
|
1717
|
+
} }, "⚙")), isOpen ? h("div", {
|
|
1718
|
+
onClick: function() {
|
|
1719
|
+
setOpen(false);
|
|
1720
|
+
},
|
|
1721
|
+
style: {
|
|
1722
|
+
position: "fixed",
|
|
1723
|
+
inset: 0,
|
|
1724
|
+
zIndex: 2147483001,
|
|
1725
|
+
background: "rgba(0,0,0,.35)",
|
|
1726
|
+
display: "flex",
|
|
1727
|
+
alignItems: "center",
|
|
1728
|
+
justifyContent: "center"
|
|
1729
|
+
}
|
|
1730
|
+
}, h("div", {
|
|
1731
|
+
onClick: function(e) {
|
|
1732
|
+
e.stopPropagation();
|
|
1733
|
+
},
|
|
1734
|
+
style: {
|
|
1735
|
+
width: "min(720px, 92vw)",
|
|
1736
|
+
maxHeight: "86vh",
|
|
1737
|
+
overflowY: "auto",
|
|
1738
|
+
background: "#fff",
|
|
1739
|
+
color: "#222",
|
|
1740
|
+
borderRadius: 12,
|
|
1741
|
+
boxShadow: "0 12px 40px rgba(0,0,0,.28)",
|
|
1742
|
+
padding: "16px 18px"
|
|
1743
|
+
}
|
|
1744
|
+
}, h("div", { style: {
|
|
1745
|
+
display: "flex",
|
|
1746
|
+
alignItems: "center",
|
|
1747
|
+
marginBottom: 12
|
|
1748
|
+
} }, h("strong", { style: { flex: 1 } }, gearTitle), h("button", {
|
|
1749
|
+
type: "button",
|
|
1750
|
+
"aria-label": "close",
|
|
1751
|
+
onClick: function() {
|
|
1752
|
+
setOpen(false);
|
|
1753
|
+
},
|
|
1754
|
+
style: {
|
|
1755
|
+
border: "none",
|
|
1756
|
+
background: "transparent",
|
|
1757
|
+
fontSize: 20,
|
|
1758
|
+
cursor: "pointer",
|
|
1759
|
+
lineHeight: 1
|
|
1760
|
+
}
|
|
1761
|
+
}, "×")), h(FamilySettingsCard, { scope }))) : null);
|
|
1762
|
+
}
|
|
1605
1763
|
var FAM_FIELD_GROUPS = [
|
|
1606
1764
|
{
|
|
1607
1765
|
gk: "gTools",
|
|
@@ -1867,8 +2025,8 @@ var FAM_FIELD_GROUPS = [
|
|
|
1867
2025
|
{
|
|
1868
2026
|
k: "cliFramePollEnabled",
|
|
1869
2027
|
kind: "bool",
|
|
1870
|
-
en: ["ego-cli fallback frames (
|
|
1871
|
-
zh: ["ego-cli 降级帧(
|
|
2028
|
+
en: ["ego-cli fallback frames (3s)", "With no CDP screencast (local ego-cli link active), capture one screenshot every 3s through the CLI so the watch panel still fills. Off = panel shows a placeholder and no screenshot subprocess is spawned"],
|
|
2029
|
+
zh: ["ego-cli 降级帧(3s 一刷)", "无 CDP screencast(本机 ego-cli 激活)时,每 3s 走一次 CLI 截图填充观察窗画面区。关 = 面板显示占位提示、不拉截图子进程"]
|
|
1872
2030
|
},
|
|
1873
2031
|
{
|
|
1874
2032
|
k: "tabTracking",
|
|
@@ -2766,6 +2924,8 @@ function apply(ctx) {
|
|
|
2766
2924
|
var mounts = [
|
|
2767
2925
|
["family settings tab", mountFamilySettingsCard],
|
|
2768
2926
|
["plugins-page config card", mountPluginsPageCard],
|
|
2927
|
+
["legacy gen-2 settings card", mountLegacySettingsCard],
|
|
2928
|
+
["gen-1 settings gear", mountGen1SettingsGear],
|
|
2769
2929
|
["picks dock", mountPicksDockCard],
|
|
2770
2930
|
["picks badge", mountPicksBadge]
|
|
2771
2931
|
];
|
|
@@ -2823,7 +2983,7 @@ function mountFloatingWatch(ctx) {
|
|
|
2823
2983
|
panel.innerHTML = `
|
|
2824
2984
|
<div id="dsh-ego-head">
|
|
2825
2985
|
<span class="dsh-ego-grip" title="${wt("dragHint")}">${ICON_GRIP}</span>
|
|
2826
|
-
<span id="dsh-ego-title">${ICON_GLOBE}<span style="margin-left:6px;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${wt("title")}</span></span>
|
|
2986
|
+
<span id="dsh-ego-title">${ICON_GLOBE}<span style="margin-left:6px;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${wt("title")}</span><span id="dsh-ego-ver" style="margin-left:6px;font-size:10px;opacity:.5;flex-shrink:0;">v${CLIENT_BUILD}</span></span>
|
|
2827
2987
|
<button id="dsh-ego-refresh" class="dsh-ego-iconbtn" title="${wt("refresh")}">${ICON_REFRESH}</button>
|
|
2828
2988
|
<button id="dsh-ego-historybtn" class="dsh-ego-iconbtn off" title="${wt("historyShow")}">${ICON_CLOCK}</button>
|
|
2829
2989
|
<button id="dsh-ego-close" class="dsh-ego-iconbtn" title="${wt("settingsHide")}">${ICON_CLOSE}</button>
|
|
@@ -2860,6 +3020,17 @@ function mountFloatingWatch(ctx) {
|
|
|
2860
3020
|
const body = panel.querySelector("#dsh-ego-body");
|
|
2861
3021
|
const titleEl = panel.querySelector("#dsh-ego-title");
|
|
2862
3022
|
const refreshBtn = panel.querySelector("#dsh-ego-refresh");
|
|
3023
|
+
if (refreshBtn !== null) refreshBtn.addEventListener("click", () => {
|
|
3024
|
+
(async () => {
|
|
3025
|
+
try {
|
|
3026
|
+
await fetch(SYNC_ROUTE, {
|
|
3027
|
+
method: "POST",
|
|
3028
|
+
cache: "no-store"
|
|
3029
|
+
});
|
|
3030
|
+
} catch {}
|
|
3031
|
+
refresh();
|
|
3032
|
+
})();
|
|
3033
|
+
});
|
|
2863
3034
|
const closeBtn = panel.querySelector("#dsh-ego-close");
|
|
2864
3035
|
const historyBtn = panel.querySelector("#dsh-ego-historybtn");
|
|
2865
3036
|
const historyEl = panel.querySelector("#dsh-ego-history");
|
|
@@ -2873,6 +3044,27 @@ function mountFloatingWatch(ctx) {
|
|
|
2873
3044
|
const captchaKindEl = panel.querySelector("#dsh-ego-captcha-kind");
|
|
2874
3045
|
const captchaHintEl = panel.querySelector("#dsh-ego-captcha-hint");
|
|
2875
3046
|
const FLUSH_ROUTE$1 = "/api/bcdp/flush";
|
|
3047
|
+
const SYNC_ROUTE = "/api/bcdp/sync";
|
|
3048
|
+
const CAPTURE_ROUTE = "/api/bcdp/capture";
|
|
3049
|
+
const captureTab = (targetId) => fetch(CAPTURE_ROUTE, {
|
|
3050
|
+
method: "POST",
|
|
3051
|
+
headers: { "content-type": "application/json" },
|
|
3052
|
+
cache: "no-store",
|
|
3053
|
+
body: JSON.stringify({ targetId })
|
|
3054
|
+
}).catch(() => null);
|
|
3055
|
+
fetch("/api/bcdp/hello", {
|
|
3056
|
+
method: "POST",
|
|
3057
|
+
headers: { "content-type": "application/json" },
|
|
3058
|
+
cache: "no-store",
|
|
3059
|
+
body: JSON.stringify({ build: CLIENT_BUILD })
|
|
3060
|
+
}).then((res) => res.json()).then((data) => {
|
|
3061
|
+
const hostBuild = data && typeof data.hostBuild === "string" ? data.hostBuild : "";
|
|
3062
|
+
if (hostBuild === "" || hostBuild === CLIENT_BUILD) return;
|
|
3063
|
+
const key = "bcdp:reloaded-for";
|
|
3064
|
+
if (window.sessionStorage.getItem(key) === hostBuild) return;
|
|
3065
|
+
window.sessionStorage.setItem(key, hostBuild);
|
|
3066
|
+
window.location.reload();
|
|
3067
|
+
}).catch(() => {});
|
|
2876
3068
|
const dismissedGuides = {
|
|
2877
3069
|
login: false,
|
|
2878
3070
|
captcha: false
|
|
@@ -2974,7 +3166,8 @@ function mountFloatingWatch(ctx) {
|
|
|
2974
3166
|
let liveFlushRaf = null;
|
|
2975
3167
|
const pageMeta = /* @__PURE__ */ new Map();
|
|
2976
3168
|
const watchClientId = "floating-" + Math.random().toString(36).slice(2);
|
|
2977
|
-
let watchStarted = false, watchTargetId = null, watchRenewTimer = null, watchStopTimer = null, watchRequest = null
|
|
3169
|
+
let watchStarted = false, watchTargetId = null, watchRenewTimer = null, watchStopTimer = null, watchRequest = null;
|
|
3170
|
+
let watchUnsupported = false, watchRequestTarget = null, watchRequestPendingTarget = null, captureBackend = "cdp", streamGeneration = 0, streamState = "idle", streamMime = "video/mp4; codecs=\"avc1.42E01E\"", videoCleanup = null;
|
|
2978
3171
|
let streamEngineUnsupported = false;
|
|
2979
3172
|
const effectiveVisible = () => !panel.hidden;
|
|
2980
3173
|
const stopVideo = () => {
|
|
@@ -3014,31 +3207,49 @@ function mountFloatingWatch(ctx) {
|
|
|
3014
3207
|
};
|
|
3015
3208
|
const syncWatch = (targetId) => {
|
|
3016
3209
|
if (disposed || !effectiveVisible() || !targetId) return;
|
|
3210
|
+
const kind = panelLink && panelLink.kind ? String(panelLink.kind) : "";
|
|
3211
|
+
if (kind === "tabbit-cli" || kind === "ego-cli" || kind === "lightpanda") return;
|
|
3212
|
+
if (watchUnsupported) return;
|
|
3017
3213
|
if (watchStopTimer) {
|
|
3018
3214
|
window.clearTimeout(watchStopTimer);
|
|
3019
3215
|
watchStopTimer = null;
|
|
3020
3216
|
}
|
|
3021
3217
|
if (watchStarted && watchTargetId === targetId) return;
|
|
3218
|
+
if (watchRequest) {
|
|
3219
|
+
if (watchRequestTarget !== targetId) watchRequestPendingTarget = targetId;
|
|
3220
|
+
return;
|
|
3221
|
+
}
|
|
3022
3222
|
const request = requestWatch(watchStarted ? WATCH_SWITCH_ROUTE : WATCH_START_ROUTE, {
|
|
3023
3223
|
clientId: watchClientId,
|
|
3024
3224
|
targetId
|
|
3025
3225
|
});
|
|
3026
|
-
if (!request)
|
|
3027
|
-
|
|
3028
|
-
return;
|
|
3029
|
-
}
|
|
3226
|
+
if (!request) return;
|
|
3227
|
+
watchRequestTarget = targetId;
|
|
3030
3228
|
request.then((status) => {
|
|
3031
|
-
|
|
3032
|
-
|
|
3229
|
+
if (!status || status.ok === false) {
|
|
3230
|
+
watchUnsupported = true;
|
|
3231
|
+
if (watchRenewTimer) {
|
|
3232
|
+
window.clearInterval(watchRenewTimer);
|
|
3233
|
+
watchRenewTimer = null;
|
|
3234
|
+
}
|
|
3235
|
+
return;
|
|
3236
|
+
}
|
|
3237
|
+
watchStarted = true;
|
|
3238
|
+
watchTargetId = status.targetId || targetId;
|
|
3033
3239
|
if (watchTargetId !== targetId) {
|
|
3034
3240
|
selectedTabId = null;
|
|
3035
3241
|
currentActiveId = watchTargetId;
|
|
3036
3242
|
}
|
|
3037
3243
|
applyCaptureStatus(status);
|
|
3038
3244
|
if (!effectiveVisible()) stopWatch(true);
|
|
3039
|
-
|
|
3245
|
+
const pending = watchRequestPendingTarget;
|
|
3246
|
+
watchRequestPendingTarget = null;
|
|
3247
|
+
if (pending && pending !== watchTargetId) syncWatch(pending);
|
|
3248
|
+
}).catch(() => {
|
|
3249
|
+
watchUnsupported = true;
|
|
3250
|
+
});
|
|
3040
3251
|
if (!watchRenewTimer) watchRenewTimer = window.setInterval(() => {
|
|
3041
|
-
if (effectiveVisible() && watchTargetId) {
|
|
3252
|
+
if (watchStarted && effectiveVisible() && watchTargetId) {
|
|
3042
3253
|
const renewal = requestWatch(WATCH_START_ROUTE, {
|
|
3043
3254
|
clientId: watchClientId,
|
|
3044
3255
|
targetId: watchTargetId
|
|
@@ -3298,21 +3509,61 @@ function mountFloatingWatch(ctx) {
|
|
|
3298
3509
|
};
|
|
3299
3510
|
const renderTabs = (spaces) => {
|
|
3300
3511
|
tabsEl.innerHTML = "";
|
|
3512
|
+
const strip = tabsEl;
|
|
3513
|
+
strip.style.display = "flex";
|
|
3514
|
+
strip.style.flexWrap = "wrap";
|
|
3515
|
+
strip.style.alignContent = "flex-start";
|
|
3516
|
+
strip.style.overflowX = "hidden";
|
|
3517
|
+
strip.style.overflowY = "auto";
|
|
3518
|
+
strip.style.maxHeight = "92px";
|
|
3519
|
+
strip.style.width = "100%";
|
|
3520
|
+
strip.style.maxWidth = "100%";
|
|
3521
|
+
strip.style.minWidth = "0";
|
|
3522
|
+
strip.style.boxSizing = "border-box";
|
|
3523
|
+
const panelEl = strip.parentElement;
|
|
3524
|
+
if (panelEl) {
|
|
3525
|
+
panelEl.style.minWidth = "0";
|
|
3526
|
+
panelEl.style.maxWidth = "100%";
|
|
3527
|
+
panelEl.style.boxSizing = "border-box";
|
|
3528
|
+
}
|
|
3301
3529
|
const list = Array.isArray(spaces) ? spaces : [];
|
|
3302
3530
|
if (list.length === 0) {
|
|
3303
3531
|
if (selectedTabId) selectedTabId = null;
|
|
3304
3532
|
return;
|
|
3305
3533
|
}
|
|
3534
|
+
const winIds = [];
|
|
3535
|
+
for (const s of list) {
|
|
3536
|
+
const id = Number(s && s.windowId) || 0;
|
|
3537
|
+
if (!winIds.includes(id)) winIds.push(id);
|
|
3538
|
+
}
|
|
3539
|
+
const winLabel = (raw) => {
|
|
3540
|
+
if (winIds.length < 2) return "";
|
|
3541
|
+
const idx = winIds.indexOf(Number(raw) || 0);
|
|
3542
|
+
return idx >= 0 ? `W${idx + 1}` : "";
|
|
3543
|
+
};
|
|
3306
3544
|
for (const s of list) {
|
|
3307
3545
|
const tab = document.createElement("div");
|
|
3308
3546
|
tab.className = "dsh-ego-tab";
|
|
3309
3547
|
tab.title = s.url || "";
|
|
3310
3548
|
tab.__tid = s.targetId;
|
|
3549
|
+
const badge = winLabel(s.windowId);
|
|
3550
|
+
if (badge !== "") {
|
|
3551
|
+
const win = document.createElement("span");
|
|
3552
|
+
win.className = "dsh-ego-tabwin";
|
|
3553
|
+
win.textContent = badge;
|
|
3554
|
+
tab.appendChild(win);
|
|
3555
|
+
}
|
|
3311
3556
|
const dot = document.createElement("span");
|
|
3312
3557
|
dot.className = "dsh-ego-tabdot";
|
|
3313
3558
|
const txt = document.createElement("span");
|
|
3314
3559
|
txt.className = "dsh-ego-tabtxt";
|
|
3315
3560
|
txt.textContent = s.title || s.url || wt("newTab");
|
|
3561
|
+
tab.style.flex = "0 1 auto";
|
|
3562
|
+
tab.style.minWidth = "0";
|
|
3563
|
+
tab.style.maxWidth = "100%";
|
|
3564
|
+
txt.style.maxWidth = "150px";
|
|
3565
|
+
txt.style.overflow = "hidden";
|
|
3566
|
+
txt.style.textOverflow = "ellipsis";
|
|
3316
3567
|
tab.appendChild(dot);
|
|
3317
3568
|
tab.appendChild(txt);
|
|
3318
3569
|
const closeBtn$1 = document.createElement("span");
|
|
@@ -3321,19 +3572,34 @@ function mountFloatingWatch(ctx) {
|
|
|
3321
3572
|
closeBtn$1.textContent = "×";
|
|
3322
3573
|
closeBtn$1.addEventListener("click", (e) => {
|
|
3323
3574
|
e.stopPropagation();
|
|
3575
|
+
tab.remove();
|
|
3576
|
+
if (selectedTabId === s.targetId) {
|
|
3577
|
+
selectedTabId = null;
|
|
3578
|
+
pinned = null;
|
|
3579
|
+
}
|
|
3324
3580
|
(async () => {
|
|
3325
3581
|
try {
|
|
3326
|
-
await fetch(EGO_CLOSE_ROUTE, {
|
|
3582
|
+
const res = await fetch(EGO_CLOSE_ROUTE, {
|
|
3327
3583
|
method: "POST",
|
|
3328
3584
|
headers: { "content-type": "application/json" },
|
|
3329
3585
|
body: JSON.stringify({ targetId: s.targetId })
|
|
3330
3586
|
});
|
|
3587
|
+
if (!res.ok) {
|
|
3588
|
+
const body$1 = await res.json().catch(() => null);
|
|
3589
|
+
const reason = body$1 && typeof body$1.reason === "string" ? body$1.reason : "http-" + res.status;
|
|
3590
|
+
const err = document.createElement("span");
|
|
3591
|
+
err.className = "dsh-ego-taberr";
|
|
3592
|
+
err.textContent = "关闭失败:" + reason;
|
|
3593
|
+
tabsEl.appendChild(err);
|
|
3594
|
+
window.setTimeout(() => {
|
|
3595
|
+
err.remove();
|
|
3596
|
+
}, 5e3);
|
|
3597
|
+
}
|
|
3331
3598
|
} catch {}
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
})().then(() => refresh());
|
|
3599
|
+
window.setTimeout(() => {
|
|
3600
|
+
refresh();
|
|
3601
|
+
}, 700);
|
|
3602
|
+
})();
|
|
3337
3603
|
});
|
|
3338
3604
|
tab.appendChild(closeBtn$1);
|
|
3339
3605
|
if (s.targetId === selectedTabId || selectedTabId === null && s.targetId === currentActiveId) tab.classList.add("active");
|
|
@@ -3350,6 +3616,9 @@ function mountFloatingWatch(ctx) {
|
|
|
3350
3616
|
pinned = null;
|
|
3351
3617
|
renderLiveMain(s, true);
|
|
3352
3618
|
syncWatch(s.targetId);
|
|
3619
|
+
if (!frameCache.has(s.targetId)) captureTab(String(s.targetId)).then(() => window.setTimeout(() => {
|
|
3620
|
+
refresh();
|
|
3621
|
+
}, 600));
|
|
3353
3622
|
[...tabsEl.querySelectorAll(".dsh-ego-tab")].forEach((t) => t.classList.toggle("active", t.__tid === s.targetId));
|
|
3354
3623
|
});
|
|
3355
3624
|
tabsEl.appendChild(tab);
|
|
@@ -3411,7 +3680,7 @@ function mountFloatingWatch(ctx) {
|
|
|
3411
3680
|
if (disposed) return;
|
|
3412
3681
|
const incoming = Array.isArray(spaces) ? spaces : [];
|
|
3413
3682
|
lastList = trackAll ? incoming : incoming.filter((s) => s && s.active === true).slice(0, 1);
|
|
3414
|
-
if (lastList.length === 0 && incoming.length
|
|
3683
|
+
if (lastList.length === 0 && incoming.length > 0) lastList = incoming.slice(0, 1);
|
|
3415
3684
|
for (const s of lastList) {
|
|
3416
3685
|
const prev = pageMeta.get(s.targetId) || { targetId: s.targetId };
|
|
3417
3686
|
pageMeta.set(s.targetId, {
|
|
@@ -3534,7 +3803,12 @@ function mountFloatingWatch(ctx) {
|
|
|
3534
3803
|
pageRefreshBtn.title = wt("pageRefreshHint");
|
|
3535
3804
|
pageRefreshBtn.textContent = wt("pageRefresh");
|
|
3536
3805
|
pageRefreshBtn.addEventListener("click", () => {
|
|
3537
|
-
runPanelAction(pageRefreshBtn, panelNavigate("", true), () =>
|
|
3806
|
+
runPanelAction(pageRefreshBtn, panelNavigate("", true), () => {
|
|
3807
|
+
if (current && current.targetId) captureTab(String(current.targetId)).then(() => window.setTimeout(() => {
|
|
3808
|
+
refresh();
|
|
3809
|
+
}, 600));
|
|
3810
|
+
else refresh();
|
|
3811
|
+
});
|
|
3538
3812
|
});
|
|
3539
3813
|
badge.appendChild(pageRefreshBtn);
|
|
3540
3814
|
const openUrlBtn = document.createElement("button");
|
|
@@ -3635,7 +3909,7 @@ function mountFloatingWatch(ctx) {
|
|
|
3635
3909
|
applyCaptureStatus(data.capture);
|
|
3636
3910
|
if (data.cliFrameMode === true && Array.isArray(data.spaces)) {
|
|
3637
3911
|
const cliActive = data.spaces.find((s) => s && (s.targetId === data.cliFrameTargetId || s.active === true)) || data.spaces[0];
|
|
3638
|
-
if (cliActive) frameCache.set(cliActive.targetId || CLI_FRAME_TARGET_ID, `${CLI_FRAME_ROUTE}?t=${cliActive.lastActive || Date.now()}`);
|
|
3912
|
+
if (cliActive) frameCache.set(cliActive.targetId || CLI_FRAME_TARGET_ID, `${CLI_FRAME_ROUTE}?targetId=${encodeURIComponent(String(cliActive.targetId || ""))}&t=${cliActive.lastActive || Date.now()}`);
|
|
3639
3913
|
renderSpaces(data.spaces);
|
|
3640
3914
|
return;
|
|
3641
3915
|
}
|
|
@@ -4256,20 +4530,31 @@ var TAB_CSS = `
|
|
|
4256
4530
|
}
|
|
4257
4531
|
|
|
4258
4532
|
/* ---- tab strip: frosted pills ---- */
|
|
4533
|
+
/* The SIDEBAR strip is a different component from the floating panel's, and it
|
|
4534
|
+
used to scroll horizontally — that is the scrollbar the user kept reporting
|
|
4535
|
+
while every wrap fix landed on the floating panel's strip. Wrap here too, and
|
|
4536
|
+
pin the width chain so the flex container is actually constrained. */
|
|
4259
4537
|
.dsh-ego-side-tabs {
|
|
4260
|
-
display: flex; gap: 5px; padding: 7px 10px;
|
|
4261
|
-
border-bottom: 1px solid rgba(128,128,128,.12);
|
|
4262
|
-
overflow-x: auto;
|
|
4538
|
+
display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; padding: 7px 10px;
|
|
4539
|
+
flex-shrink: 0; border-bottom: 1px solid rgba(128,128,128,.12);
|
|
4540
|
+
overflow-x: hidden; overflow-y: auto; max-height: 96px;
|
|
4541
|
+
scrollbar-width: thin; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box;
|
|
4263
4542
|
}
|
|
4264
4543
|
.dsh-ego-side-tabs:empty { display: none; }
|
|
4265
4544
|
.dsh-ego-side-tab {
|
|
4266
|
-
display: inline-flex; align-items: center; gap: 5px; max-width:
|
|
4545
|
+
display: inline-flex; align-items: center; gap: 5px; max-width: 100%; min-width: 0;
|
|
4267
4546
|
white-space: nowrap; padding: 4px 10px; border-radius: 999px; cursor: pointer;
|
|
4268
|
-
font-size: 11px; flex
|
|
4547
|
+
font-size: 11px; flex: 0 1 auto;
|
|
4269
4548
|
border: 1px solid rgba(128,128,128,.2); background: rgba(128,128,128,.12);
|
|
4270
4549
|
opacity: .7; transition: background .15s, opacity .15s, border-color .15s;
|
|
4271
4550
|
}
|
|
4272
|
-
.dsh-ego-side-tab > .dsh-ego-side-tabtxt { overflow: hidden; text-overflow: ellipsis; }
|
|
4551
|
+
.dsh-ego-side-tab > .dsh-ego-side-tabtxt { overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
|
|
4552
|
+
/* Window badge: two Tabbit windows with the same pages otherwise read as
|
|
4553
|
+
duplicated tabs. */
|
|
4554
|
+
.dsh-ego-side-tab > .dsh-ego-side-tabwin {
|
|
4555
|
+
flex-shrink: 0; font-size: 9px; line-height: 12px; padding: 0 3px; border-radius: 4px;
|
|
4556
|
+
border: 1px solid currentColor; opacity: .55; letter-spacing: .2px;
|
|
4557
|
+
}
|
|
4273
4558
|
.dsh-ego-side-tab:hover { opacity: 1; background: rgba(128,128,128,.2); }
|
|
4274
4559
|
.dsh-ego-side-tab.active {
|
|
4275
4560
|
background: #0a84ff; color: #fff; border-color: transparent; opacity: 1;
|
|
@@ -5513,7 +5798,7 @@ LivePreviewController.prototype.refresh = function() {
|
|
|
5513
5798
|
var cliActive = data.spaces.find(function(s) {
|
|
5514
5799
|
return s && (s.targetId === data.cliFrameTargetId || s.active === true);
|
|
5515
5800
|
}) || data.spaces[0];
|
|
5516
|
-
if (cliActive) self.frameCache.set(cliActive.targetId || CLI_FRAME_TARGET_ID, CLI_FRAME_ROUTE + "?t=" + (cliActive.lastActive || Date.now()));
|
|
5801
|
+
if (cliActive) self.frameCache.set(cliActive.targetId || CLI_FRAME_TARGET_ID, CLI_FRAME_ROUTE + "?targetId=" + encodeURIComponent(String(cliActive.targetId || "")) + "&t=" + (cliActive.lastActive || Date.now()));
|
|
5517
5802
|
self._processSpaces(data.spaces);
|
|
5518
5803
|
return;
|
|
5519
5804
|
}
|
|
@@ -6158,7 +6443,12 @@ function EgoBrowserTab(props) {
|
|
|
6158
6443
|
dangerouslySetInnerHTML: { __html: svg }
|
|
6159
6444
|
});
|
|
6160
6445
|
};
|
|
6161
|
-
var header = h("div", { className: "dsh-ego-side-head" }, h("span", { className: "dsh-ego-side-title" }, h("span", { dangerouslySetInnerHTML: { __html: ICON_GLOBE } }), h("span", { style: { marginLeft: "5px" } }, state.busy ? wt("titleLive") : wt("title"))
|
|
6446
|
+
var header = h("div", { className: "dsh-ego-side-head" }, h("span", { className: "dsh-ego-side-title" }, h("span", { dangerouslySetInnerHTML: { __html: ICON_GLOBE } }), h("span", { style: { marginLeft: "5px" } }, state.busy ? wt("titleLive") : wt("title")), h("span", { style: {
|
|
6447
|
+
marginLeft: "6px",
|
|
6448
|
+
fontSize: "9.5px",
|
|
6449
|
+
opacity: ".5",
|
|
6450
|
+
flexShrink: "0"
|
|
6451
|
+
} }, "v" + CLIENT_BUILD)), h("button", {
|
|
6162
6452
|
className: "dsh-ego-side-iconbtn" + (state.busy ? " spinning" : ""),
|
|
6163
6453
|
title: wt("refresh"),
|
|
6164
6454
|
onClick: function() {
|
|
@@ -6228,16 +6518,52 @@ function EgoBrowserTab(props) {
|
|
|
6228
6518
|
controller,
|
|
6229
6519
|
link: state.link
|
|
6230
6520
|
}));
|
|
6231
|
-
var
|
|
6521
|
+
var sideWinIds = [];
|
|
6522
|
+
state.spaces.forEach(function(s) {
|
|
6523
|
+
var id = Number(s && s.windowId) || 0;
|
|
6524
|
+
if (sideWinIds.indexOf(id) < 0) sideWinIds.push(id);
|
|
6525
|
+
});
|
|
6526
|
+
var sideWinLabel = function(raw) {
|
|
6527
|
+
if (sideWinIds.length < 2) return "";
|
|
6528
|
+
var idx = sideWinIds.indexOf(Number(raw) || 0);
|
|
6529
|
+
return idx >= 0 ? "W" + (idx + 1) : "";
|
|
6530
|
+
};
|
|
6531
|
+
var tabsEl = state.spaces.length > 0 ? h("div", {
|
|
6532
|
+
className: "dsh-ego-side-tabs",
|
|
6533
|
+
style: {
|
|
6534
|
+
display: "flex",
|
|
6535
|
+
flexWrap: "wrap",
|
|
6536
|
+
alignContent: "flex-start",
|
|
6537
|
+
overflowX: "hidden",
|
|
6538
|
+
overflowY: "auto",
|
|
6539
|
+
maxHeight: "96px",
|
|
6540
|
+
width: "100%",
|
|
6541
|
+
minWidth: "0",
|
|
6542
|
+
boxSizing: "border-box"
|
|
6543
|
+
}
|
|
6544
|
+
}, state.spaces.map(function(s) {
|
|
6232
6545
|
var isActive = s.targetId === state.selectedTabId || state.selectedTabId === null && s.targetId === state.currentTargetId;
|
|
6546
|
+
var badge = sideWinLabel(s.windowId);
|
|
6233
6547
|
return h("div", {
|
|
6234
6548
|
key: s.targetId,
|
|
6235
6549
|
className: "dsh-ego-side-tab" + (isActive ? " active" : "") + (s.active === true ? " is-live" : ""),
|
|
6236
6550
|
title: s.url || "",
|
|
6551
|
+
style: {
|
|
6552
|
+
flex: "0 1 auto",
|
|
6553
|
+
minWidth: "0",
|
|
6554
|
+
maxWidth: "100%"
|
|
6555
|
+
},
|
|
6237
6556
|
onClick: function() {
|
|
6238
6557
|
controller.selectTab(s.targetId);
|
|
6239
6558
|
}
|
|
6240
|
-
}, h("span", { className: "dsh-ego-side-
|
|
6559
|
+
}, badge !== "" ? h("span", { className: "dsh-ego-side-tabwin" }, badge) : null, h("span", { className: "dsh-ego-side-tabdot" }), h("span", {
|
|
6560
|
+
className: "dsh-ego-side-tabtxt",
|
|
6561
|
+
style: {
|
|
6562
|
+
maxWidth: "150px",
|
|
6563
|
+
overflow: "hidden",
|
|
6564
|
+
textOverflow: "ellipsis"
|
|
6565
|
+
}
|
|
6566
|
+
}, s.title || s.url || wt("newTab")), h("span", {
|
|
6241
6567
|
className: "dsh-ego-side-tabclose",
|
|
6242
6568
|
title: wt("closeTab"),
|
|
6243
6569
|
onClick: function(e) {
|