dsh-browser-cdp 1.7.12 → 1.9.6

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/lib/client.js CHANGED
@@ -583,7 +583,7 @@ var watchEn = {
583
583
  refresh: "Refresh",
584
584
  backToLive: "← Back to live",
585
585
  dragHint: "Drag to move panel",
586
- loginTitle: "Log in via the CDP browser bridge window on your desktop",
586
+ loginTitle: "If the page asks you to sign in, log in in the {where} on your desktop.",
587
587
  loginBtn: "Logged in, save",
588
588
  loginSaving: "Saving…",
589
589
  loginSaved: "Saved {n} sessions",
@@ -591,7 +591,14 @@ var watchEn = {
591
591
  loginFailed: "Save failed",
592
592
  loginDismiss: "Dismiss",
593
593
  captchaTitle: "⚠️ CAPTCHA detected",
594
- captchaHint: "Complete verification in the CDP browser bridge window; the agent will continue.",
594
+ captchaHint: "Complete the verification manually in the {where}; the agent will continue after that.",
595
+ whereCdp: "“{label}” browser window",
596
+ whereEgo: "ego browser window",
597
+ whereTabbit: "Tabbit browser window",
598
+ whereLocal: "managed Chrome window",
599
+ whereGeneric: "agent browser window",
600
+ loginHeadless: "The active target is Lightpanda (headless) — there is no window to sign in or verify in. Switch to a headed target (CDP endpoint / local Chrome / ego CLI / Tabbit).",
601
+ loginSelfPersist: "This browser keeps the login in its own profile — nothing to save here.",
595
602
  captchaDismiss: "Dismiss",
596
603
  hintReset: "Reset · scroll to pan · Ctrl+scroll to zoom · double-click to reset",
597
604
  hintPan: "Ctrl+scroll to zoom · Ctrl+drag to pan · double-click to reset",
@@ -646,7 +653,30 @@ var watchEn = {
646
653
  linksLocalEnableHint: "Checked = auto mode may fall back to the managed local browser when the activated target is unreachable",
647
654
  pickCardTitle: "Browser picks",
648
655
  pickCardElements: "{n} element(s) picked",
649
- pickCardRemove: "Remove these picks"
656
+ pickCardRemove: "Remove these picks",
657
+ pickCardSnapshotTag: "(capture-time snapshot)",
658
+ pickCardRecapture: "Recapture",
659
+ pickCardRecaptureHint: "Re-read this tab and overwrite the quoted report (same @ token)",
660
+ pickCardLive: "live",
661
+ trackAllOn: "全模式 · 全部 tab",
662
+ trackAllOff: "仅激活 tab",
663
+ trackAllHintOn: "全模式:space 内每个 tab 都单独报图,外框标出当前激活的那个。点一下回到仅激活。",
664
+ trackAllHintOff: "仅激活:只报激活 tab 的图。点一下切到全模式(track every tab)。",
665
+ pageRefresh: "Reload page",
666
+ pageRefreshHint: "Reload the agent page itself (Page.reload)",
667
+ openUrl: "Open URL",
668
+ openUrlHint: "Navigate the agent page to a URL",
669
+ openUrlPrompt: "URL to open in the agent browser",
670
+ sizeSyncOff: "🔒 Size lock",
671
+ sizeSyncOn: "🔓 Size sync",
672
+ sizeSyncHint: "Unlocked: dragging this panel resizes the REAL agent browser window. Click again to lock.",
673
+ sizePresets: "Presets",
674
+ sizePresetsHint: "Resize the agent browser window to a fixed aspect ratio",
675
+ maximizeWindow: "Maximize",
676
+ maximizeHint: "Maximize the real agent browser window",
677
+ resizeHint: "Drag to resize the real agent browser window",
678
+ sizeApiOutdated: "Size API not ready — restart DSH to load the new host build",
679
+ actionFailed: "Action failed"
650
680
  };
651
681
  var watchDict = {
652
682
  en: watchEn,
@@ -685,7 +715,7 @@ var watchDict = {
685
715
  refresh: "刷新",
686
716
  backToLive: "← 返回实时",
687
717
  dragHint: "拖动移动面板",
688
- loginTitle: "需要账号登录时,请到桌面上那个 「CDP 浏览器代理」 Chrome 窗口完成登录。",
718
+ loginTitle: "需要账号登录时,请到桌面上那个 {where} 完成登录。",
689
719
  loginBtn: "已登录,保存",
690
720
  loginSaving: "保存中…",
691
721
  loginSaved: "已保存 {n} 条会话",
@@ -693,7 +723,14 @@ var watchDict = {
693
723
  loginFailed: "保存失败",
694
724
  loginDismiss: "关闭提示",
695
725
  captchaTitle: "⚠️ 检测到人机验证",
696
- captchaHint: "请在桌面那个 「CDP 浏览器代理」 浏览器窗口手动完成验证,agent 会继续。",
726
+ captchaHint: "请在桌面那个 {where} 手动完成验证,agent 会继续。",
727
+ whereCdp: "「{label}」浏览器窗口",
728
+ whereEgo: "ego 浏览器窗口",
729
+ whereTabbit: "Tabbit 浏览器窗口",
730
+ whereLocal: "本机 Chrome 窗口(受管启动)",
731
+ whereGeneric: "agent 浏览器窗口",
732
+ loginHeadless: "当前激活的是 Lightpanda(无头引擎),没有可登录/验证的窗口;请切换到有头目标(CDP 端点 / 本机 Chrome / ego CLI / Tabbit)。",
733
+ loginSelfPersist: "登录态保存在该浏览器自己的 profile 里,无需手动落盘。",
697
734
  captchaDismiss: "关闭提示",
698
735
  hintReset: "已复位 · 滚轮滚动页面 · Ctrl+滚轮缩放 · 双击复位",
699
736
  hintPan: "Ctrl+滚轮缩放 · Ctrl+拖动平移 · 双击复位",
@@ -748,7 +785,30 @@ var watchDict = {
748
785
  linksLocalEnableHint: "勾选 = 允许 auto 模式在激活目标不可达时回落本机启动",
749
786
  pickCardTitle: "浏览器点选内容",
750
787
  pickCardElements: "已选 {n} 个元素",
751
- pickCardRemove: "移除这段点选"
788
+ pickCardRemove: "移除这段点选",
789
+ pickCardSnapshotTag: "(点击时快照)",
790
+ pickCardRecapture: "重抓快照",
791
+ pickCardRecaptureHint: "重新读取这个 tab 并覆盖引用的报告(@ token 不变)",
792
+ pickCardLive: "实时",
793
+ trackAllOn: "全模式 · 全部 tab",
794
+ trackAllOff: "仅激活 tab",
795
+ trackAllHintOn: "全模式:space 内每个 tab 都单独出图,外框标出当前激活的那个;再点一下回到仅激活。",
796
+ trackAllHintOff: "仅激活:只出激活 tab 的图;点一下切到全模式(所有 tab 都跟踪)。",
797
+ pageRefresh: "刷新页面",
798
+ pageRefreshHint: "重新加载 agent 当前页面(Page.reload)",
799
+ openUrl: "打开网址",
800
+ openUrlHint: "让 agent 页面跳转到指定网址",
801
+ openUrlPrompt: "要在 agent 浏览器里打开的网址",
802
+ sizeSyncOff: "🔒 锁定尺寸",
803
+ sizeSyncOn: "🔓 尺寸同步",
804
+ sizeSyncHint: "解锁后拖动面板会直接改变 agent 浏览器真实窗口大小;再点一下锁定。",
805
+ sizePresets: "尺寸预设",
806
+ sizePresetsHint: "按固定比例设置 agent 浏览器窗口",
807
+ maximizeWindow: "最大化",
808
+ maximizeHint: "最大化真实 agent 浏览器窗口",
809
+ resizeHint: "拖动调整 agent 浏览器窗口大小",
810
+ sizeApiOutdated: "尺寸接口未就绪:请重启 DSH 以加载最新 host 构建",
811
+ actionFailed: "操作失败"
752
812
  }
753
813
  };
754
814
  function wt(key, params = void 0) {
@@ -756,7 +816,31 @@ function wt(key, params = void 0) {
756
816
  if (params) for (var k in params) text = text.replace(new RegExp("{" + k + "}", "g"), String(params[k]));
757
817
  return text;
758
818
  }
819
+ function linkWhere(link) {
820
+ var kind = link && link.kind || "";
821
+ var label = link && link.label || "";
822
+ if (kind === "lightpanda") return "";
823
+ if (kind === "ego-cli") return wt("whereEgo");
824
+ if (kind === "tabbit-cli") return wt("whereTabbit");
825
+ if (kind === "localhost" || kind === "local") return wt("whereLocal");
826
+ if (label) return wt("whereCdp", { label });
827
+ return wt("whereGeneric");
828
+ }
829
+ function linkLoginLine(link) {
830
+ if ((link && link.kind) === "lightpanda") return wt("loginHeadless");
831
+ return wt("loginTitle", { where: linkWhere(link) });
832
+ }
833
+ function linkCaptchaLine(link) {
834
+ if ((link && link.kind) === "lightpanda") return wt("loginHeadless");
835
+ return wt("captchaHint", { where: linkWhere(link) });
836
+ }
837
+ function linkFlushable(link) {
838
+ var kind = link && link.kind || "";
839
+ return kind !== "ego-cli" && kind !== "tabbit-cli" && kind !== "lightpanda";
840
+ }
759
841
  const SPACES_ROUTE = "/api/bcdp/spaces";
842
+ const TRACKING_ROUTE = "/api/bcdp/tracking";
843
+ const SWITCH_TAB_ROUTE = "/api/bcdp/switch-tab";
760
844
  const EGO_CLOSE_ROUTE = "/api/bcdp/close";
761
845
  const WATCH_START_ROUTE = "/api/bcdp/watch/start";
762
846
  const WATCH_SWITCH_ROUTE = "/api/bcdp/watch/switch";
@@ -776,6 +860,19 @@ function postJson(path, body) {
776
860
  });
777
861
  });
778
862
  }
863
+ /** Make one tab the browser's active target (panel click = "show me that tab"). */
864
+ function switchTabRemote(targetId) {
865
+ if (targetId === void 0 || targetId === null || targetId === "") return Promise.resolve(null);
866
+ return postJson(SWITCH_TAB_ROUTE, { targetId: String(targetId) }).catch(function() {
867
+ return null;
868
+ });
869
+ }
870
+ /** 全模式 switch: GET returns the current value, POST flips it. */
871
+ function setTrackAllRemote(all) {
872
+ return postJson(TRACKING_ROUTE, { all }).catch(function() {
873
+ return null;
874
+ });
875
+ }
779
876
  function createKeyboardProxy(send) {
780
877
  var input = document.createElement("textarea");
781
878
  input.className = "dsh-ego-keyboard-proxy";
@@ -1231,6 +1328,22 @@ const PANEL_CSS = `
1231
1328
  }
1232
1329
  .dsh-ego-back:hover { background: rgba(255,255,255,.2); }
1233
1330
  .dsh-ego-back.dsh-ego-pick-on { background: rgba(56,189,248,.3); color: #7dd3fc; }
1331
+ .dsh-ego-back.on { background: rgba(217,119,87,.45); border-color: rgba(217,119,87,.7); }
1332
+ .dsh-ego-presets {
1333
+ display:inline-flex; gap:3px; padding:3px; border-radius:7px;
1334
+ background: rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.12);
1335
+ }
1336
+ .dsh-ego-preset-item {
1337
+ background:transparent; border:none; color:#f5f5f7; cursor:pointer;
1338
+ font-size:11px; padding:2px 7px; border-radius:5px;
1339
+ }
1340
+ .dsh-ego-preset-item:hover { background: rgba(255,255,255,.2); }
1341
+ /* live/active indication: the picture that belongs to the browser's ACTIVE tab
1342
+ gets a green frame (全模式 makes this the only way to tell them apart). */
1343
+ .dsh-ego-liveview.is-live img, .dsh-ego-liveview.is-live video {
1344
+ box-shadow: 0 0 0 2px #30d158, 0 0 14px rgba(48,209,88,.3);
1345
+ }
1346
+ .dsh-ego-tab.is-live .dsh-ego-tabdot { background:#30d158; box-shadow:0 0 6px #30d15888; }
1234
1347
  .dsh-ego-liveimg {
1235
1348
  width:100%; border-radius:11px; display:block;
1236
1349
  max-height:50vh; object-fit:contain;
@@ -1283,6 +1396,13 @@ const ICON_REFRESH = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none
1283
1396
  const ICON_CLOCK = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 7.5V12l3 2"/></svg>`;
1284
1397
  const ICON_CLOSE = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>`;
1285
1398
  const ICON_GRIP = `<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><circle cx="8" cy="6" r="1.8"/><circle cx="16" cy="6" r="1.8"/><circle cx="8" cy="12" r="1.8"/><circle cx="16" cy="12" r="1.8"/><circle cx="8" cy="18" r="1.8"/><circle cx="16" cy="18" r="1.8"/></svg>`;
1399
+ const ICON_LOCK = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><rect x="4.5" y="10.5" width="15" height="10" rx="2"/><path d="M8 10.5V7.5a4 4 0 0 1 8 0v3"/></svg>`;
1400
+ const ICON_UNLOCK = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><rect x="4.5" y="10.5" width="15" height="10" rx="2"/><path d="M8 10.5V7.5a4 4 0 0 1 7.2-2.4"/></svg>`;
1401
+ const ICON_ASPECT = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="2.2"/><path d="M3 10h18"/><path d="M8 5v5"/></svg>`;
1402
+ const ICON_MAXIMIZE = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H3v5"/><path d="M16 3h5v5"/><path d="M8 21H3v-5"/><path d="M16 21h5v-5"/></svg>`;
1403
+ const ICON_LINK = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"><path d="M10 13.5a4 4 0 0 0 5.7 0l2.8-2.8a4 4 0 0 0-5.7-5.7L11.5 6.3"/><path d="M14 10.5a4 4 0 0 0-5.7 0l-2.8 2.8a4 4 0 0 0 5.7 5.7l1.3-1.3"/></svg>`;
1404
+ const ICON_GRID = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"><rect x="3.5" y="3.5" width="7" height="7" rx="1.6"/><rect x="13.5" y="3.5" width="7" height="7" rx="1.6"/><rect x="3.5" y="13.5" width="7" height="7" rx="1.6"/><rect x="13.5" y="13.5" width="7" height="7" rx="1.6"/></svg>`;
1405
+ const ICON_SQUARE = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"><rect x="5" y="5" width="14" height="14" rx="2.4"/></svg>`;
1286
1406
  var BRIDGE_ROUTES = {
1287
1407
  describe: "/api/dsh-browser-cdp/settings/describe",
1288
1408
  mutate: "/api/dsh-browser-cdp/settings/mutate"
@@ -1737,6 +1857,13 @@ var FAM_FIELD_GROUPS = [
1737
1857
  kind: "bool",
1738
1858
  en: ["ego-cli fallback frames (5s)", "With no CDP screencast (local ego-cli link active), capture one screenshot every 5s through the CLI so the watch panel still fills. Off = panel shows a placeholder and no screenshot subprocess is spawned"],
1739
1859
  zh: ["ego-cli 降级帧(5s 一刷)", "无 CDP screencast(本机 ego-cli 激活)时,每 5s 走一次 CLI 截图填充观察窗画面区。关 = 面板显示占位提示、不拉截图子进程"]
1860
+ },
1861
+ {
1862
+ k: "tabTracking",
1863
+ kind: "sel",
1864
+ options: ["active", "all"],
1865
+ en: ["Tab tracking (CLI routes)", "active = capture only the browser-active tab; all = capture every tab in the space (one picture each), the active one outlined green"],
1866
+ zh: ["tab 跟踪模式(CLI 路线)", "仅激活 = 只抓浏览器激活的那个 tab;全模式 = space 内每个 tab 各出一张图,激活那个用绿框标出"]
1740
1867
  }
1741
1868
  ]
1742
1869
  },
@@ -2691,13 +2818,13 @@ function mountFloatingWatch(ctx) {
2691
2818
  </div>
2692
2819
  <div id="dsh-ego-tabs"></div>
2693
2820
  <div id="dsh-ego-login">
2694
- <span class="dsh-ego-login-txt">${wt("loginTitle")}</span>
2821
+ <span class="dsh-ego-login-txt" id="dsh-ego-login-txt">${wt("loginTitle", { where: wt("whereGeneric") })}</span>
2695
2822
  <button id="dsh-ego-login-btn" class="dsh-ego-login-btn" type="button">${wt("loginBtn")}</button>
2696
2823
  <span class="dsh-ego-login-note" id="dsh-ego-login-note"></span>
2697
2824
  <button class="dsh-ego-dismiss" type="button" title="${wt("loginDismiss")}" data-dismiss="login">×</button>
2698
2825
  </div>
2699
2826
  <div id="dsh-ego-captcha">
2700
- <span class="dsh-ego-captcha-txt"><b>${wt("captchaTitle")}</b> — ${wt("captchaHint")}</span>
2827
+ <span class="dsh-ego-captcha-txt"><b>${wt("captchaTitle")}</b> — <span id="dsh-ego-captcha-hint">${wt("captchaHint", { where: wt("whereGeneric") })}</span></span>
2701
2828
  <span class="dsh-ego-captcha-kind" id="dsh-ego-captcha-kind"></span>
2702
2829
  <button class="dsh-ego-dismiss" type="button" title="${wt("captchaDismiss")}" data-dismiss="captcha">×</button>
2703
2830
  </div>
@@ -2727,10 +2854,12 @@ function mountFloatingWatch(ctx) {
2727
2854
  const historyList = panel.querySelector("#dsh-ego-historylist");
2728
2855
  const tabsEl = panel.querySelector("#dsh-ego-tabs");
2729
2856
  const loginEl = panel.querySelector("#dsh-ego-login");
2857
+ const loginTxt = panel.querySelector("#dsh-ego-login-txt");
2730
2858
  const loginBtn = panel.querySelector("#dsh-ego-login-btn");
2731
2859
  const loginNote = panel.querySelector("#dsh-ego-login-note");
2732
2860
  const captchaEl = panel.querySelector("#dsh-ego-captcha");
2733
2861
  const captchaKindEl = panel.querySelector("#dsh-ego-captcha-kind");
2862
+ const captchaHintEl = panel.querySelector("#dsh-ego-captcha-hint");
2734
2863
  const FLUSH_ROUTE$1 = "/api/bcdp/flush";
2735
2864
  const dismissedGuides = {
2736
2865
  login: false,
@@ -2753,6 +2882,8 @@ function mountFloatingWatch(ctx) {
2753
2882
  let disposed = false;
2754
2883
  let historyOpen = false;
2755
2884
  let lastList = [];
2885
+ let panelLink = null;
2886
+ let trackAll = false;
2756
2887
  const setHistory = (open) => {
2757
2888
  historyOpen = open;
2758
2889
  historyEl.classList.toggle("open", open);
@@ -3194,6 +3325,7 @@ function mountFloatingWatch(ctx) {
3194
3325
  });
3195
3326
  tab.appendChild(closeBtn$1);
3196
3327
  if (s.targetId === selectedTabId || selectedTabId === null && s.targetId === currentActiveId) tab.classList.add("active");
3328
+ if (s.active === true) tab.classList.add("is-live");
3197
3329
  tab.addEventListener("click", () => {
3198
3330
  if (selectedTabId === s.targetId) {
3199
3331
  selectedTabId = null;
@@ -3201,6 +3333,7 @@ function mountFloatingWatch(ctx) {
3201
3333
  renderSpaces(lastList);
3202
3334
  return;
3203
3335
  }
3336
+ if (s.targetId !== currentActiveId) switchTabRemote(s.targetId).then(() => refresh());
3204
3337
  selectedTabId = s.targetId;
3205
3338
  pinned = null;
3206
3339
  renderLiveMain(s, true);
@@ -3262,7 +3395,9 @@ function mountFloatingWatch(ctx) {
3262
3395
  };
3263
3396
  const renderSpaces = (spaces) => {
3264
3397
  if (disposed) return;
3265
- lastList = Array.isArray(spaces) ? spaces : [];
3398
+ const incoming = Array.isArray(spaces) ? spaces : [];
3399
+ lastList = trackAll ? incoming : incoming.filter((s) => s && s.active === true).slice(0, 1);
3400
+ if (lastList.length === 0 && incoming.length === 1) lastList = incoming.slice(0, 1);
3266
3401
  for (const s of lastList) {
3267
3402
  const prev = pageMeta.get(s.targetId) || { targetId: s.targetId };
3268
3403
  pageMeta.set(s.targetId, {
@@ -3316,7 +3451,7 @@ function mountFloatingWatch(ctx) {
3316
3451
  const renderLiveMain = (current, isPinned) => {
3317
3452
  body.innerHTML = "";
3318
3453
  const view = document.createElement("div");
3319
- view.className = "dsh-ego-liveview";
3454
+ view.className = "dsh-ego-liveview" + (isPinned ? "" : " is-live");
3320
3455
  const badge = document.createElement("div");
3321
3456
  badge.className = "dsh-ego-livebadge";
3322
3457
  badge.innerHTML = isPinned ? `<span class="dsh-ego-state-dot pin"></span> ${wt("pinned")}` : `<span class="dsh-ego-state-dot${fab.classList.contains("dsh-ego-busy") ? " busy" : ""}"></span> ${wt("realtime")}`;
@@ -3362,6 +3497,90 @@ function mountFloatingWatch(ctx) {
3362
3497
  }).then((r) => r.json().catch(() => null)).catch(() => null);
3363
3498
  });
3364
3499
  badge.appendChild(raiseBtn);
3500
+ const liveNotice = (text) => {
3501
+ if (!text) return;
3502
+ u.textContent = String(text);
3503
+ u.classList.add("dsh-ego-hint");
3504
+ };
3505
+ const runPanelAction = (btn, promise, onOk) => {
3506
+ btn.disabled = true;
3507
+ promise.then((res) => {
3508
+ if (res && res.ok === true) {
3509
+ if (onOk) onOk(res);
3510
+ } else liveNotice(res && res.error || wt("actionFailed"));
3511
+ }).catch(() => {
3512
+ liveNotice(wt("actionFailed"));
3513
+ }).then(() => {
3514
+ btn.disabled = false;
3515
+ });
3516
+ };
3517
+ const pageRefreshBtn = document.createElement("button");
3518
+ pageRefreshBtn.type = "button";
3519
+ pageRefreshBtn.className = "dsh-ego-back";
3520
+ pageRefreshBtn.title = wt("pageRefreshHint");
3521
+ pageRefreshBtn.textContent = wt("pageRefresh");
3522
+ pageRefreshBtn.addEventListener("click", () => {
3523
+ runPanelAction(pageRefreshBtn, panelNavigate("", true), () => refresh());
3524
+ });
3525
+ badge.appendChild(pageRefreshBtn);
3526
+ const openUrlBtn = document.createElement("button");
3527
+ openUrlBtn.type = "button";
3528
+ openUrlBtn.className = "dsh-ego-back";
3529
+ openUrlBtn.title = wt("openUrlHint");
3530
+ openUrlBtn.textContent = wt("openUrl");
3531
+ openUrlBtn.addEventListener("click", () => {
3532
+ const entered = window.prompt(wt("openUrlPrompt"), current.url || "https://");
3533
+ if (entered === null) return;
3534
+ const url = normalizeUrlInput(entered);
3535
+ if (url === "") return;
3536
+ runPanelAction(openUrlBtn, panelNavigate(url, false), () => refresh());
3537
+ });
3538
+ badge.appendChild(openUrlBtn);
3539
+ const maximizeBtn = document.createElement("button");
3540
+ maximizeBtn.type = "button";
3541
+ maximizeBtn.className = "dsh-ego-back";
3542
+ maximizeBtn.title = wt("maximizeHint");
3543
+ maximizeBtn.innerHTML = `${ICON_MAXIMIZE}<span style="margin-left:4px">${wt("maximizeWindow")}</span>`;
3544
+ maximizeBtn.addEventListener("click", () => {
3545
+ runPanelAction(maximizeBtn, panelWindowSize({ maximize: true }), () => refresh());
3546
+ });
3547
+ badge.appendChild(maximizeBtn);
3548
+ const presetBtn = document.createElement("button");
3549
+ presetBtn.type = "button";
3550
+ presetBtn.className = "dsh-ego-back";
3551
+ presetBtn.title = wt("sizePresetsHint");
3552
+ presetBtn.innerHTML = `${ICON_ASPECT}<span style="margin-left:4px">${wt("sizePresets")}</span>`;
3553
+ const presetRow = document.createElement("div");
3554
+ presetRow.className = "dsh-ego-presets";
3555
+ presetRow.hidden = true;
3556
+ for (const preset of SIZE_PRESETS || []) {
3557
+ const item = document.createElement("button");
3558
+ item.type = "button";
3559
+ item.className = "dsh-ego-preset-item";
3560
+ item.textContent = preset.label;
3561
+ item.addEventListener("click", () => {
3562
+ presetRow.hidden = true;
3563
+ presetBtn.classList.remove("on");
3564
+ runPanelAction(presetBtn, panelWindowSize({ aspect: preset.ratio }), () => refresh());
3565
+ });
3566
+ presetRow.appendChild(item);
3567
+ }
3568
+ presetBtn.addEventListener("click", () => {
3569
+ presetRow.hidden = !presetRow.hidden;
3570
+ presetBtn.classList.toggle("on", !presetRow.hidden);
3571
+ });
3572
+ badge.appendChild(presetBtn);
3573
+ badge.appendChild(presetRow);
3574
+ const trackBtn = document.createElement("button");
3575
+ trackBtn.type = "button";
3576
+ trackBtn.className = "dsh-ego-back" + (trackAll ? " on" : "");
3577
+ trackBtn.title = trackAll ? wt("trackAllHintOn") : wt("trackAllHintOff");
3578
+ trackBtn.innerHTML = `${trackAll ? ICON_GRID : ICON_SQUARE}<span style="margin-left:4px">${trackAll ? wt("trackAllOn") : wt("trackAllOff")}</span>`;
3579
+ trackBtn.addEventListener("click", () => {
3580
+ trackAll = !trackAll;
3581
+ setTrackAllRemote(trackAll).then(() => refresh());
3582
+ });
3583
+ badge.appendChild(trackBtn);
3365
3584
  const cached = frameCache.get(current.targetId);
3366
3585
  if (captureBackend === "ffmpeg" || cached) {
3367
3586
  const img = makeZoomImage(u, captureBackend === "ffmpeg" ? "video" : "img");
@@ -3396,10 +3615,11 @@ function mountFloatingWatch(ctx) {
3396
3615
  renderEmpty();
3397
3616
  return;
3398
3617
  }
3618
+ if (data.link) panelLink = data.link;
3399
3619
  applyCaptureStatus(data.capture);
3400
3620
  if (data.cliFrameMode === true && Array.isArray(data.spaces)) {
3401
- const cli = data.spaces.find((s) => s && s.targetId === CLI_FRAME_TARGET_ID);
3402
- if (cli) frameCache.set(CLI_FRAME_TARGET_ID, `${CLI_FRAME_ROUTE}?t=${cli.lastActive || Date.now()}`);
3621
+ const cliActive = data.spaces.find((s) => s && (s.targetId === data.cliFrameTargetId || s.active === true)) || data.spaces[0];
3622
+ if (cliActive) frameCache.set(cliActive.targetId || CLI_FRAME_TARGET_ID, `${CLI_FRAME_ROUTE}?t=${cliActive.lastActive || Date.now()}`);
3403
3623
  renderSpaces(data.spaces);
3404
3624
  return;
3405
3625
  }
@@ -3661,6 +3881,12 @@ function mountFloatingWatch(ctx) {
3661
3881
  panel.offsetHeight;
3662
3882
  panel.classList.add("dsh-ego-panel-open");
3663
3883
  fab.classList.add("on");
3884
+ fetch(TRACKING_ROUTE, { cache: "no-store" }).then((r) => r.json().catch(() => null)).then((data) => {
3885
+ if (data && typeof data.all === "boolean" && data.all !== trackAll) {
3886
+ trackAll = data.all;
3887
+ refresh();
3888
+ }
3889
+ }).catch(() => {});
3664
3890
  refresh();
3665
3891
  openStream();
3666
3892
  if (currentActiveId) syncWatch(selectedTabId || currentActiveId);
@@ -3702,6 +3928,10 @@ function mountFloatingWatch(ctx) {
3702
3928
  const show = lastList.some((s) => s.url && !s.url.startsWith("about:")) && !captchaEl.classList.contains("show");
3703
3929
  loginEl.classList.toggle("show", show);
3704
3930
  loginNote.textContent = "";
3931
+ if (loginTxt) loginTxt.textContent = linkLoginLine(panelLink);
3932
+ const canFlush = linkFlushable(panelLink);
3933
+ if (loginBtn instanceof HTMLElement) loginBtn.hidden = !canFlush;
3934
+ if (!canFlush) loginNote.textContent = wt("loginSelfPersist");
3705
3935
  };
3706
3936
  const maybeShowCaptchaGuide = () => {
3707
3937
  if (disposed || dismissedGuides.captcha) return;
@@ -3709,6 +3939,7 @@ function mountFloatingWatch(ctx) {
3709
3939
  const show = !!hit;
3710
3940
  captchaEl.classList.toggle("show", show);
3711
3941
  if (show && captchaKindEl) captchaKindEl.textContent = hit.humanCheck.kind || "captcha";
3942
+ if (captchaHintEl) captchaHintEl.textContent = linkCaptchaLine(panelLink);
3712
3943
  };
3713
3944
  loginBtn.addEventListener("click", () => {
3714
3945
  (async () => {
@@ -3771,7 +4002,174 @@ function mountFloatingWatch(ctx) {
3771
4002
  }
3772
4003
  var INPUT_ROUTE = "/api/bcdp/input";
3773
4004
  var FLUSH_ROUTE = "/api/bcdp/flush";
4005
+ var WINDOW_SIZE_ROUTE = "/api/bcdp/window-size";
4006
+ var PANEL_NAVIGATE_ROUTE = "/api/bcdp/navigate";
3774
4007
  var FRAME_FOLLOW_MIN_MS = 350;
4008
+ var SIZE_SYNC_KEY = "dsh-browser-cdp:size-sync";
4009
+ function sizeSyncStored() {
4010
+ try {
4011
+ return window.localStorage.getItem(SIZE_SYNC_KEY) === "1";
4012
+ } catch (e) {
4013
+ return false;
4014
+ }
4015
+ }
4016
+ function sizeSyncStore(enabled) {
4017
+ try {
4018
+ window.localStorage.setItem(SIZE_SYNC_KEY, enabled ? "1" : "0");
4019
+ } catch (e) {}
4020
+ }
4021
+ function createWindowSizeSync() {
4022
+ var enabled = false;
4023
+ var element = null;
4024
+ var observer = null;
4025
+ var timer = null;
4026
+ var inFlight = false;
4027
+ var baseWidth = 0;
4028
+ var pointerDown = false;
4029
+ var dragUntil = 0;
4030
+ var lastAt = 0;
4031
+ function onPointerDown() {
4032
+ pointerDown = true;
4033
+ }
4034
+ function onPointerUp() {
4035
+ if (!pointerDown) return;
4036
+ pointerDown = false;
4037
+ dragUntil = Date.now() + 350;
4038
+ if (enabled) schedule();
4039
+ }
4040
+ function stageWidth() {
4041
+ return Math.round(element && element.clientWidth || 0);
4042
+ }
4043
+ function schedule() {
4044
+ if (timer !== null) return;
4045
+ timer = setTimeout(send, 180);
4046
+ }
4047
+ function send() {
4048
+ timer = null;
4049
+ if (!enabled || !element) return;
4050
+ var w = stageWidth();
4051
+ if (w < 120) return;
4052
+ var now = Date.now();
4053
+ if (!pointerDown && now > dragUntil) {
4054
+ baseWidth = w;
4055
+ return;
4056
+ }
4057
+ var delta = w - baseWidth;
4058
+ if (Math.abs(delta) < 12) return;
4059
+ if (now - lastAt < 200) {
4060
+ schedule();
4061
+ return;
4062
+ }
4063
+ if (inFlight) {
4064
+ schedule();
4065
+ return;
4066
+ }
4067
+ inFlight = true;
4068
+ lastAt = now;
4069
+ var sentBase = w;
4070
+ postJson(WINDOW_SIZE_ROUTE, { delta }).then(function(parsed) {
4071
+ if (parsed && parsed.ok === true) baseWidth = sentBase;
4072
+ }).catch(function() {
4073
+ return null;
4074
+ }).then(function() {
4075
+ inFlight = false;
4076
+ });
4077
+ }
4078
+ function attach(el) {
4079
+ element = el || null;
4080
+ if (!enabled) return;
4081
+ if (observer !== null) {
4082
+ observer.disconnect();
4083
+ observer = null;
4084
+ }
4085
+ if (element && typeof ResizeObserver !== "undefined") try {
4086
+ observer = new ResizeObserver(function() {
4087
+ if (enabled) schedule();
4088
+ });
4089
+ observer.observe(element);
4090
+ } catch (e) {
4091
+ observer = null;
4092
+ }
4093
+ if (baseWidth === 0) baseWidth = stageWidth();
4094
+ }
4095
+ function setEnabled(next) {
4096
+ enabled = next === true;
4097
+ sizeSyncStore(enabled);
4098
+ if (!enabled) {
4099
+ if (timer !== null) {
4100
+ clearTimeout(timer);
4101
+ timer = null;
4102
+ }
4103
+ if (observer !== null) {
4104
+ observer.disconnect();
4105
+ observer = null;
4106
+ }
4107
+ document.removeEventListener("pointerdown", onPointerDown, true);
4108
+ document.removeEventListener("pointerup", onPointerUp, true);
4109
+ return;
4110
+ }
4111
+ baseWidth = stageWidth();
4112
+ lastAt = 0;
4113
+ document.addEventListener("pointerdown", onPointerDown, true);
4114
+ document.addEventListener("pointerup", onPointerUp, true);
4115
+ if (element) attach(element);
4116
+ }
4117
+ function dispose() {
4118
+ if (timer !== null) timer = null;
4119
+ if (observer !== null) {
4120
+ observer.disconnect();
4121
+ observer = null;
4122
+ }
4123
+ document.removeEventListener("pointerdown", onPointerDown, true);
4124
+ document.removeEventListener("pointerup", onPointerUp, true);
4125
+ element = null;
4126
+ }
4127
+ return {
4128
+ isEnabled: function() {
4129
+ return enabled;
4130
+ },
4131
+ setEnabled,
4132
+ attach,
4133
+ dispose
4134
+ };
4135
+ }
4136
+ var SIZE_PRESETS = [
4137
+ {
4138
+ label: "16:9",
4139
+ ratio: "16:9"
4140
+ },
4141
+ {
4142
+ label: "4:3",
4143
+ ratio: "4:3"
4144
+ },
4145
+ {
4146
+ label: "21:9",
4147
+ ratio: "21:9"
4148
+ },
4149
+ {
4150
+ label: "1:1",
4151
+ ratio: "1:1"
4152
+ },
4153
+ {
4154
+ label: "9:16",
4155
+ ratio: "9:16"
4156
+ }
4157
+ ];
4158
+ /** Panel refresh / URL: ONE body shape for both host routes. */
4159
+ function panelNavigate(url, reload) {
4160
+ return postJson(PANEL_NAVIGATE_ROUTE, reload ? { reload: true } : { url: String(url || "") });
4161
+ }
4162
+ /** Size sync / presets / maximize. */
4163
+ function panelWindowSize(body) {
4164
+ return postJson(WINDOW_SIZE_ROUTE, body || {});
4165
+ }
4166
+ /** Normalize whatever the user typed into an absolute URL. */
4167
+ function normalizeUrlInput(entered) {
4168
+ var url = String(entered || "").trim();
4169
+ if (url === "") return "";
4170
+ if (!/^[a-z][a-z0-9+.-]*:/i.test(url)) url = "https://" + url;
4171
+ return url;
4172
+ }
3775
4173
  var TAB_CSS = `
3776
4174
  .dsh-ego-side-root {
3777
4175
  display: flex; flex-direction: column; height: 100%; min-height: 0;
@@ -3886,6 +4284,34 @@ var TAB_CSS = `
3886
4284
  }
3887
4285
  .dsh-ego-side-back:hover { background: rgba(128,128,128,.3); }
3888
4286
  .dsh-ego-side-back.dsh-ego-pick-on { background: rgba(56,189,248,.28); color: #0ea5e9; }
4287
+ .dsh-ego-side-back.on { background: rgba(217,119,87,.35); border-color: rgba(217,119,87,.6); }
4288
+ .dsh-ego-side-presets {
4289
+ display: inline-flex; gap: 3px; padding: 3px; border-radius: 7px;
4290
+ background: rgba(128,128,128,.12); border: 1px solid rgba(128,128,128,.18);
4291
+ }
4292
+ .dsh-ego-side-preset-item {
4293
+ background: transparent; border: none; color: inherit; cursor: pointer;
4294
+ font-size: 10.5px; padding: 2px 7px; border-radius: 5px; opacity: .8;
4295
+ }
4296
+ .dsh-ego-side-preset-item:hover { background: rgba(128,128,128,.24); opacity: 1; }
4297
+ /* size-sync stage: the live image sits in a positioned box so the edge/
4298
+ corner handles can overlay it. */
4299
+ .dsh-ego-side-stage { position: relative; display: flex; min-width: 0; }
4300
+ .dsh-ego-side-resize { position: absolute; z-index: 6; background: transparent; }
4301
+ .dsh-ego-side-resize-right { top: 0; bottom: 0; right: 0; width: 10px; cursor: col-resize; }
4302
+ .dsh-ego-side-resize-bottom { left: 0; right: 0; bottom: 0; height: 10px; cursor: row-resize; }
4303
+ .dsh-ego-side-resize-corner { right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; }
4304
+ .dsh-ego-size-unlocked .dsh-ego-side-resize-right,
4305
+ .dsh-ego-size-unlocked .dsh-ego-side-resize-bottom { background: rgba(217,119,87,.14); }
4306
+ .dsh-ego-size-unlocked .dsh-ego-side-resize-corner {
4307
+ background: rgba(217,119,87,.3); border-bottom-right-radius: 9px;
4308
+ }
4309
+ /* Green frame = this image belongs to the browser's ACTIVE tab. In 全模式 every
4310
+ tab has its own picture, so the outline is what marks the live one. */
4311
+ .dsh-ego-side-stage.is-live { box-shadow: 0 0 0 2px #30d158, 0 0 12px rgba(48,209,88,.3); border-radius: 11px; }
4312
+ .dsh-ego-side-tab.is-live .dsh-ego-side-tabdot { background: #30d158; box-shadow: 0 0 6px #30d158; }
4313
+ .dsh-ego-side-tab.is-live .dsh-ego-side-tabtxt { font-weight: 600; }
4314
+ .dsh-ego-side-resize:hover { background: rgba(217,119,87,.5) !important; }
3889
4315
  .dsh-ego-side-liveimg {
3890
4316
  width: 100%; border-radius: 9px; display: block;
3891
4317
  max-height: 50vh; object-fit: contain;
@@ -4000,6 +4426,35 @@ function CdpPicksDockCard(props) {
4000
4426
  var filesKey = refs.map(function(r) {
4001
4427
  return r.file;
4002
4428
  }).join("|");
4429
+ var reloadState = React.useState(0);
4430
+ var reloadKey = reloadState[0];
4431
+ var setReloadKey = reloadState[1];
4432
+ var liveState = React.useState({});
4433
+ var liveMeta = liveState[0];
4434
+ var setLiveMeta = liveState[1];
4435
+ React.useEffect(function() {
4436
+ var cancelled = false;
4437
+ fetch(SPACES_ROUTE, { cache: "no-store" }).then(function(res) {
4438
+ return res.json().catch(function() {
4439
+ return null;
4440
+ });
4441
+ }).then(function(data) {
4442
+ if (cancelled || !data || !Array.isArray(data.spaces)) return;
4443
+ var map = {};
4444
+ for (var i = 0; i < data.spaces.length; i++) {
4445
+ var s = data.spaces[i];
4446
+ if (s && s.targetId != null) map[String(s.targetId)] = {
4447
+ url: s.url || "",
4448
+ title: s.title || "",
4449
+ active: s.active === true
4450
+ };
4451
+ }
4452
+ setLiveMeta(map);
4453
+ }).catch(function() {});
4454
+ return function() {
4455
+ cancelled = true;
4456
+ };
4457
+ }, [Math.floor(tick[0] / 3)]);
4003
4458
  React.useEffect(function() {
4004
4459
  var cancelled = false;
4005
4460
  refs.forEach(function(r) {
@@ -4051,7 +4506,11 @@ function CdpPicksDockCard(props) {
4051
4506
  return function() {
4052
4507
  cancelled = true;
4053
4508
  };
4054
- }, [filesKey, Math.floor(tick[0] / 5)]);
4509
+ }, [
4510
+ filesKey,
4511
+ reloadKey,
4512
+ Math.floor(tick[0] / 5)
4513
+ ]);
4055
4514
  if (refs.length === 0) return null;
4056
4515
  function removeRef(line) {
4057
4516
  var cur = readDraftText(input);
@@ -4061,6 +4520,20 @@ function CdpPicksDockCard(props) {
4061
4520
  next = next.replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
4062
4521
  input.setDraft(next);
4063
4522
  }
4523
+ function recapture(r, targetId, live) {
4524
+ if (targetId === "") return;
4525
+ postJson("/bcdp/api/tab-anchor-report", {
4526
+ targetId,
4527
+ session: sid,
4528
+ file: r.file.slice(6),
4529
+ ...live && live.url ? { url: live.url } : {},
4530
+ ...live && live.title ? { title: live.title } : {}
4531
+ }).then(function(res) {
4532
+ if (res && res.ok !== false) setReloadKey(function(n) {
4533
+ return n + 1;
4534
+ });
4535
+ }).catch(function() {});
4536
+ }
4064
4537
  return h("div", { style: {
4065
4538
  display: "grid",
4066
4539
  gap: "6px"
@@ -4072,6 +4545,8 @@ function CdpPicksDockCard(props) {
4072
4545
  var isTabReport = false;
4073
4546
  var truncated = false;
4074
4547
  var degraded = "";
4548
+ var targetId = "";
4549
+ var reportSource = "";
4075
4550
  if (typeof content === "string" && content !== "") try {
4076
4551
  var obj = JSON.parse(content);
4077
4552
  elements = obj && obj.elements || [];
@@ -4080,14 +4555,29 @@ function CdpPicksDockCard(props) {
4080
4555
  isTabReport = !!(obj && obj.type === "tab-anchor-report");
4081
4556
  truncated = !!(obj && obj.truncated);
4082
4557
  degraded = obj && obj.degraded || "";
4558
+ targetId = obj && obj.targetId ? String(obj.targetId) : "";
4559
+ reportSource = obj && obj.source ? String(obj.source) : "";
4083
4560
  } catch (e) {
4084
4561
  pageTitle = "";
4085
4562
  }
4563
+ var live = targetId !== "" ? liveMeta[targetId] : null;
4564
+ var liveTitle = live && live.title || "";
4565
+ var liveUrl = live && live.url || "";
4086
4566
  var countText;
4087
4567
  if (typeof content !== "string" || content === "") countText = errs[r.file] ? "⚠ " + errs[r.file] : "…";
4088
4568
  else if (degraded) countText = wt("pickCardElements", { n: 0 }) + " · ⚠ " + degraded;
4089
- else countText = wt("pickCardElements", { n: elements.length }) + (truncated ? "+" : "");
4090
- var head = h("div", { className: "dsh-cdp-picks-head" }, h("span", { style: { fontWeight: 700 } }, isTabReport ? "🌐 " + (pageTitle || wt("pickCardTitle")) : "🌐 " + wt("pickCardTitle")), h("span", { className: "dsh-cdp-picks-sub" }, "@" + r.file), isTabReport && pageUrl ? h("span", { className: "dsh-cdp-picks-sub" }, pageUrl) : h("span", { className: "dsh-cdp-picks-sub" }, pageTitle), h("span", { className: "dsh-cdp-picks-sub" }, countText), h("button", {
4569
+ else countText = wt("pickCardElements", { n: elements.length }) + (truncated ? "+" : "") + (isTabReport ? " " + wt("pickCardSnapshotTag") : "");
4570
+ var head = h("div", { className: "dsh-cdp-picks-head" }, h("span", { style: { fontWeight: 700 } }, isTabReport ? "🌐 " + (liveTitle || pageTitle || wt("pickCardTitle")) : "🌐 " + wt("pickCardTitle")), h("span", { className: "dsh-cdp-picks-sub" }, "@" + r.file), h("span", { className: "dsh-cdp-picks-sub" }, liveUrl || pageUrl || pageTitle), isTabReport && live ? h("span", {
4571
+ className: "dsh-cdp-picks-sub",
4572
+ title: reportSource || "live"
4573
+ }, "● " + wt("pickCardLive")) : null, h("span", { className: "dsh-cdp-picks-sub" }, countText), isTabReport && targetId !== "" ? h("button", {
4574
+ type: "button",
4575
+ title: wt("pickCardRecaptureHint"),
4576
+ className: "dsh-cdp-picks-close",
4577
+ onClick: function() {
4578
+ recapture(r, targetId, live);
4579
+ }
4580
+ }, "⟳") : null, h("button", {
4091
4581
  type: "button",
4092
4582
  title: wt("pickCardRemove"),
4093
4583
  className: "dsh-cdp-picks-close",
@@ -4658,6 +5148,8 @@ function LivePreviewController(ctx) {
4658
5148
  this._zoomHint = null;
4659
5149
  this._zoomHintTimer = null;
4660
5150
  this._pointerState = null;
5151
+ this.link = null;
5152
+ this.trackAll = false;
4661
5153
  var self = this;
4662
5154
  this.keyboardProxy = createKeyboardProxy(function(targetId, type, params) {
4663
5155
  self.sendInput(targetId, type, params);
@@ -4686,6 +5178,9 @@ LivePreviewController.prototype._initialState = function() {
4686
5178
  busy: false,
4687
5179
  showLoginGuide: false,
4688
5180
  captchaKind: null,
5181
+ link: null,
5182
+ trackAll: false,
5183
+ agentActiveId: null,
4689
5184
  historyOpen: false,
4690
5185
  zoomHint: null,
4691
5186
  wiringStale: false,
@@ -4732,7 +5227,7 @@ LivePreviewController.prototype._recompute = function() {
4732
5227
  return s.targetId === self.selectedTabId;
4733
5228
  }) || null;
4734
5229
  currentTargetId = this.selectedTabId;
4735
- if (currentSpace && !currentSpace.thumbnail) {
5230
+ if (currentSpace) {
4736
5231
  var cached = this.frameCache.get(currentTargetId);
4737
5232
  if (cached) currentSpace = Object.assign({}, currentSpace, { thumbnail: cached });
4738
5233
  }
@@ -4746,10 +5241,8 @@ LivePreviewController.prototype._recompute = function() {
4746
5241
  if (activeMarked) {
4747
5242
  currentSpace = Object.assign({}, activeMarked);
4748
5243
  currentTargetId = activeMarked.targetId;
4749
- if (!currentSpace.thumbnail) {
4750
- var cached2 = this.frameCache.get(currentTargetId);
4751
- if (cached2) currentSpace.thumbnail = cached2;
4752
- }
5244
+ var cached2 = this.frameCache.get(currentTargetId);
5245
+ if (cached2) currentSpace.thumbnail = cached2;
4753
5246
  }
4754
5247
  }
4755
5248
  this.currentActiveId = currentTargetId;
@@ -4778,17 +5271,36 @@ LivePreviewController.prototype._recompute = function() {
4778
5271
  s.engineUnsupported = self.engineUnsupported;
4779
5272
  s.pick = self._pick;
4780
5273
  s.pickMessage = self._pickMessage;
5274
+ s.link = self.link;
5275
+ s.trackAll = self.trackAll;
5276
+ s.agentActiveId = self.agentActiveId;
4781
5277
  });
4782
5278
  this._syncWatch(currentTargetId);
4783
5279
  };
4784
5280
  LivePreviewController.prototype.start = function() {
4785
5281
  document.addEventListener("visibilitychange", this.onDocumentVisibility);
5282
+ var self = this;
5283
+ fetch(TRACKING_ROUTE, { cache: "no-store" }).then(function(res) {
5284
+ return res.json().catch(function() {
5285
+ return null;
5286
+ });
5287
+ }).then(function(data) {
5288
+ if (data && typeof data.all === "boolean") {
5289
+ self.trackAll = data.all;
5290
+ self._recompute();
5291
+ }
5292
+ }).catch(function() {});
4786
5293
  this._recompute();
4787
5294
  if (this.visible) {
4788
5295
  this.refresh();
4789
5296
  this.openStream();
4790
5297
  }
4791
5298
  };
5299
+ LivePreviewController.prototype.setTrackAll = function(all) {
5300
+ this.trackAll = all === true;
5301
+ this._recompute();
5302
+ setTrackAllRemote(this.trackAll);
5303
+ };
4792
5304
  LivePreviewController.prototype.togglePick = function() {
4793
5305
  var targetId = this.currentActiveId;
4794
5306
  if (this.pickControl.isEnabled()) {
@@ -4968,12 +5480,13 @@ LivePreviewController.prototype.refresh = function() {
4968
5480
  self._renderEmpty();
4969
5481
  return;
4970
5482
  }
5483
+ if (data.link) self.link = data.link;
4971
5484
  self._applyCaptureStatus(data.capture);
4972
5485
  if (data.cliFrameMode === true && Array.isArray(data.spaces)) {
4973
- var cli = data.spaces.find(function(s) {
4974
- return s && s.targetId === CLI_FRAME_TARGET_ID;
4975
- });
4976
- if (cli) self.frameCache.set(CLI_FRAME_TARGET_ID, CLI_FRAME_ROUTE + "?t=" + (cli.lastActive || Date.now()));
5486
+ var cliActive = data.spaces.find(function(s) {
5487
+ return s && (s.targetId === data.cliFrameTargetId || s.active === true);
5488
+ }) || data.spaces[0];
5489
+ if (cliActive) self.frameCache.set(cliActive.targetId || CLI_FRAME_TARGET_ID, CLI_FRAME_ROUTE + "?t=" + (cliActive.lastActive || Date.now()));
4977
5490
  self._processSpaces(data.spaces);
4978
5491
  return;
4979
5492
  }
@@ -4988,7 +5501,11 @@ LivePreviewController.prototype._renderEmpty = function() {
4988
5501
  };
4989
5502
  LivePreviewController.prototype._processSpaces = function(spaces) {
4990
5503
  if (this.disposed) return;
4991
- this.lastList = Array.isArray(spaces) ? spaces : [];
5504
+ var incoming = Array.isArray(spaces) ? spaces : [];
5505
+ this.lastList = this.trackAll ? incoming : incoming.filter(function(s$1) {
5506
+ return s$1 && s$1.active === true;
5507
+ }).slice(0, 1);
5508
+ if (this.lastList.length === 0 && incoming.length === 1) this.lastList = incoming.slice(0, 1);
4992
5509
  for (var i = 0; i < this.lastList.length; i++) {
4993
5510
  var s = this.lastList[i];
4994
5511
  var prev = this.pageMeta.get(s.targetId) || { targetId: s.targetId };
@@ -5180,6 +5697,7 @@ LivePreviewController.prototype.unpin = function() {
5180
5697
  this._recompute();
5181
5698
  };
5182
5699
  LivePreviewController.prototype.selectTab = function(targetId) {
5700
+ if (targetId !== this.currentActiveId) switchTabRemote(targetId);
5183
5701
  if (this.selectedTabId === targetId) {
5184
5702
  this.selectedTabId = null;
5185
5703
  this.pinned = null;
@@ -5245,6 +5763,15 @@ LivePreviewController.prototype.noteWired = function() {
5245
5763
  if (!self.disposed) self._recompute();
5246
5764
  });
5247
5765
  };
5766
+ LivePreviewController.prototype.noteViewport = function(targetId, width, height) {
5767
+ if (targetId == null) return;
5768
+ if (!Number.isFinite(width) || !Number.isFinite(height)) return;
5769
+ if (width <= 0 || height <= 0) return;
5770
+ var meta = this.pageMeta.get(targetId) || {};
5771
+ meta.vw = width;
5772
+ meta.vh = height;
5773
+ this.pageMeta.set(targetId, meta);
5774
+ };
5248
5775
  LivePreviewController.prototype._signalUnwired = function() {
5249
5776
  var now = Date.now();
5250
5777
  if (now - this._lastUnwiredAt < 5e3) return;
@@ -5400,12 +5927,141 @@ function EgoBrowserTab(props) {
5400
5927
  });
5401
5928
  var imgRef = React.useRef(null);
5402
5929
  var videoRef = React.useRef(null);
5930
+ var stageRef = React.useRef(null);
5931
+ var sizeSyncRef = React.useRef(null);
5932
+ if (sizeSyncRef.current === null) {
5933
+ sizeSyncRef.current = createWindowSizeSync();
5934
+ sizeSyncRef.current.setEnabled(sizeSyncStored());
5935
+ }
5936
+ var sizeSync = sizeSyncRef.current;
5937
+ var sizeSyncState = React.useState(sizeSync.isEnabled());
5938
+ var sizeSyncOn = sizeSyncState[0];
5939
+ var setSizeSyncOn = sizeSyncState[1];
5940
+ var presetState = React.useState(false);
5941
+ var presetOpen = presetState[0];
5942
+ var setPresetOpen = presetState[1];
5943
+ var noticeState = React.useState("");
5944
+ var sizeNotice = noticeState[0];
5945
+ var setSizeNotice = noticeState[1];
5946
+ var noteSizeResult = function(status, parsed) {
5947
+ if (status === 400 || status === 404) setSizeNotice(wt("sizeApiOutdated"));
5948
+ else if (parsed && parsed.ok === true) setSizeNotice("");
5949
+ };
5950
+ var noteViewport = function(targetId, parsed) {
5951
+ if (parsed && parsed.ok === true && parsed.viewport) controller.noteViewport(targetId, parsed.viewport.width, parsed.viewport.height);
5952
+ };
5953
+ var applyPreset = function(ratio) {
5954
+ setPresetOpen(false);
5955
+ var targetId = state.currentTargetId;
5956
+ panelWindowSize({ aspect: ratio }).then(function(parsed) {
5957
+ noteSizeResult(200, parsed);
5958
+ noteViewport(targetId, parsed);
5959
+ if (parsed && parsed.ok === true) controller.refresh();
5960
+ }).catch(function() {
5961
+ setSizeNotice(wt("actionFailed"));
5962
+ });
5963
+ };
5964
+ var openUrlInPanel = function() {
5965
+ var current = state.currentSpace;
5966
+ var entered = window.prompt(wt("openUrlPrompt"), current && current.url || "https://");
5967
+ if (entered === null) return;
5968
+ var url = normalizeUrlInput(entered);
5969
+ if (url === "") return;
5970
+ var targetId = state.currentTargetId;
5971
+ setSizeNotice("");
5972
+ panelNavigate(url, false).then(function(parsed) {
5973
+ if (parsed && parsed.ok === true) {
5974
+ setSizeNotice("");
5975
+ noteViewport(targetId, parsed);
5976
+ controller.refresh();
5977
+ } else setSizeNotice(parsed && parsed.error || wt("actionFailed"));
5978
+ }).catch(function() {
5979
+ setSizeNotice(wt("actionFailed"));
5980
+ });
5981
+ };
5982
+ var reloadPage = function() {
5983
+ setSizeNotice("");
5984
+ panelNavigate("", true).then(function(parsed) {
5985
+ if (parsed && parsed.ok === true) {
5986
+ setSizeNotice("");
5987
+ controller.refresh();
5988
+ } else setSizeNotice(parsed && parsed.error || wt("actionFailed"));
5989
+ }).catch(function() {
5990
+ setSizeNotice(wt("actionFailed"));
5991
+ });
5992
+ };
5993
+ var maximizeWindow = function() {
5994
+ var targetId = state.currentTargetId;
5995
+ setSizeNotice("");
5996
+ panelWindowSize({ maximize: true }).then(function(parsed) {
5997
+ noteSizeResult(200, parsed);
5998
+ noteViewport(targetId, parsed);
5999
+ if (parsed && parsed.ok === true) controller.refresh();
6000
+ else setSizeNotice(parsed && parsed.error || wt("actionFailed"));
6001
+ }).catch(function() {
6002
+ setSizeNotice(wt("actionFailed"));
6003
+ });
6004
+ };
6005
+ React.useEffect(function() {
6006
+ if (!presetOpen) return;
6007
+ return function() {};
6008
+ }, [presetOpen]);
6009
+ var beginResize = function(axis) {
6010
+ return function(event) {
6011
+ event.preventDefault();
6012
+ event.stopPropagation();
6013
+ var startX = event.clientX;
6014
+ var startY = event.clientY;
6015
+ var sentX = 0;
6016
+ var sentY = 0;
6017
+ var lastAt = 0;
6018
+ var inFlight = false;
6019
+ var targetId = state.currentTargetId;
6020
+ var sendStep = function(stepX, stepY) {
6021
+ var payload = {};
6022
+ if (Math.abs(stepX) >= 1) payload.delta = Math.round(stepX);
6023
+ if (Math.abs(stepY) >= 1) payload.dy = Math.round(stepY);
6024
+ if (payload.delta === void 0 && payload.dy === void 0) return;
6025
+ panelWindowSize(payload).then(function(parsed) {
6026
+ noteSizeResult(200, parsed);
6027
+ noteViewport(targetId, parsed);
6028
+ }).catch(function() {
6029
+ return null;
6030
+ }).then(function() {
6031
+ inFlight = false;
6032
+ });
6033
+ };
6034
+ var onMove = function(ev) {
6035
+ var dxTotal = axis === "y" ? 0 : ev.clientX - startX;
6036
+ var dyTotal = axis === "x" ? 0 : ev.clientY - startY;
6037
+ var stepX = dxTotal - sentX;
6038
+ var stepY = dyTotal - sentY;
6039
+ if (Math.abs(stepX) < 3 && Math.abs(stepY) < 3) return;
6040
+ var now = Date.now();
6041
+ if (inFlight || now - lastAt < 120) return;
6042
+ inFlight = true;
6043
+ lastAt = now;
6044
+ sentX = dxTotal;
6045
+ sentY = dyTotal;
6046
+ sendStep(stepX, stepY);
6047
+ };
6048
+ var onUp = function() {
6049
+ document.removeEventListener("pointermove", onMove);
6050
+ document.removeEventListener("pointerup", onUp);
6051
+ document.removeEventListener("pointercancel", onUp);
6052
+ };
6053
+ document.addEventListener("pointermove", onMove);
6054
+ document.addEventListener("pointerup", onUp);
6055
+ document.addEventListener("pointercancel", onUp);
6056
+ };
6057
+ };
5403
6058
  var bindLiveImg = function(el) {
5404
6059
  imgRef.current = el;
5405
6060
  if (el && state.currentTargetId != null && (controller.liveImg !== el || controller.liveImgTargetId !== state.currentTargetId)) {
5406
6061
  controller.setLiveImg(el, state.currentTargetId);
5407
6062
  controller.noteWired();
5408
6063
  }
6064
+ if (sizeSyncOn) sizeSync.attach(stageRef.current || el);
5409
6065
  };
5410
6066
  var bindLiveVideo = function(el) {
5411
6067
  videoRef.current = el;
@@ -5413,6 +6069,7 @@ function EgoBrowserTab(props) {
5413
6069
  controller.setLiveVideo(el, state.currentTargetId);
5414
6070
  controller.noteWired();
5415
6071
  }
6072
+ if (sizeSyncOn) sizeSync.attach(stageRef.current || el);
5416
6073
  };
5417
6074
  React.useEffect(function() {
5418
6075
  controller.start();
@@ -5423,6 +6080,21 @@ function EgoBrowserTab(props) {
5423
6080
  React.useEffect(function() {
5424
6081
  controller.setVisible(visible);
5425
6082
  }, [visible, controller]);
6083
+ React.useEffect(function() {
6084
+ if (!visible) sizeSync.attach(null);
6085
+ else if (sizeSyncOn) sizeSync.attach(stageRef.current || imgRef.current || videoRef.current);
6086
+ }, [
6087
+ visible,
6088
+ sizeSyncOn,
6089
+ sizeSync,
6090
+ state.currentTargetId,
6091
+ state.backend
6092
+ ]);
6093
+ React.useEffect(function() {
6094
+ return function() {
6095
+ sizeSync.dispose();
6096
+ };
6097
+ }, [sizeSync]);
5426
6098
  React.useEffect(function() {
5427
6099
  if (imgRef.current && state.currentTargetId != null) controller.setLiveImg(imgRef.current, state.currentTargetId);
5428
6100
  if (videoRef.current && state.currentTargetId != null) controller.setLiveVideo(videoRef.current, state.currentTargetId);
@@ -5450,6 +6122,15 @@ function EgoBrowserTab(props) {
5450
6122
  state.streamGeneration
5451
6123
  ]);
5452
6124
  var h = React.createElement;
6125
+ var icon = function(svg) {
6126
+ return h("span", {
6127
+ style: {
6128
+ display: "inline-flex",
6129
+ alignItems: "center"
6130
+ },
6131
+ dangerouslySetInnerHTML: { __html: svg }
6132
+ });
6133
+ };
5453
6134
  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("button", {
5454
6135
  className: "dsh-ego-side-iconbtn" + (state.busy ? " spinning" : ""),
5455
6136
  title: wt("refresh"),
@@ -5511,18 +6192,20 @@ function EgoBrowserTab(props) {
5511
6192
  var guides = [];
5512
6193
  if (state.showLoginGuide) guides.push(h(EgoLoginGuide, {
5513
6194
  key: "login",
5514
- controller
6195
+ controller,
6196
+ link: state.link
5515
6197
  }));
5516
6198
  if (state.captchaKind) guides.push(h(EgoCaptchaGuide, {
5517
6199
  key: "captcha",
5518
6200
  kind: state.captchaKind,
5519
- controller
6201
+ controller,
6202
+ link: state.link
5520
6203
  }));
5521
6204
  var tabsEl = state.spaces.length > 0 ? h("div", { className: "dsh-ego-side-tabs" }, state.spaces.map(function(s) {
5522
6205
  var isActive = s.targetId === state.selectedTabId || state.selectedTabId === null && s.targetId === state.currentTargetId;
5523
6206
  return h("div", {
5524
6207
  key: s.targetId,
5525
- className: "dsh-ego-side-tab" + (isActive ? " active" : ""),
6208
+ className: "dsh-ego-side-tab" + (isActive ? " active" : "") + (s.active === true ? " is-live" : ""),
5526
6209
  title: s.url || "",
5527
6210
  onClick: function() {
5528
6211
  controller.selectTab(s.targetId);
@@ -5623,7 +6306,70 @@ function EgoBrowserTab(props) {
5623
6306
  return null;
5624
6307
  });
5625
6308
  }
5626
- }, wt("raiseWindow"))), liveImg, h("div", { className: "dsh-ego-side-livetitle" }, currentSpace.title || currentSpace.url || wt("newTab")), h("div", { className: "dsh-ego-side-liveurl" + (state.zoomHint ? " dsh-ego-side-hint" : "") }, state.zoomHint || currentSpace.url || "")));
6309
+ }, wt("raiseWindow")), h("button", {
6310
+ className: "dsh-ego-side-back",
6311
+ type: "button",
6312
+ title: wt("pageRefreshHint"),
6313
+ onClick: reloadPage
6314
+ }, icon(ICON_REFRESH), wt("pageRefresh")), h("button", {
6315
+ className: "dsh-ego-side-back",
6316
+ type: "button",
6317
+ title: wt("openUrlHint"),
6318
+ onClick: openUrlInPanel
6319
+ }, icon(ICON_LINK), wt("openUrl")), h("button", {
6320
+ className: "dsh-ego-side-back" + (state.trackAll ? " on" : ""),
6321
+ type: "button",
6322
+ title: state.trackAll ? wt("trackAllHintOn") : wt("trackAllHintOff"),
6323
+ onClick: function() {
6324
+ controller.setTrackAll(!state.trackAll);
6325
+ }
6326
+ }, icon(state.trackAll ? ICON_GRID : ICON_SQUARE), state.trackAll ? wt("trackAllOn") : wt("trackAllOff")), h("button", {
6327
+ className: "dsh-ego-side-back" + (sizeSyncOn ? " on" : ""),
6328
+ type: "button",
6329
+ title: wt("sizeSyncHint"),
6330
+ onClick: function() {
6331
+ var next = !sizeSyncOn;
6332
+ setSizeSyncOn(next);
6333
+ sizeSync.setEnabled(next);
6334
+ if (next) sizeSync.attach(stageRef.current || imgRef.current || videoRef.current);
6335
+ }
6336
+ }, icon(sizeSyncOn ? ICON_LOCK : ICON_UNLOCK), sizeSyncOn ? wt("sizeSyncOn") : wt("sizeSyncOff")), h("button", {
6337
+ className: "dsh-ego-side-back" + (presetOpen ? " on" : ""),
6338
+ type: "button",
6339
+ title: wt("sizePresetsHint"),
6340
+ onClick: function() {
6341
+ setPresetOpen(!presetOpen);
6342
+ }
6343
+ }, icon(ICON_ASPECT), wt("sizePresets")), h("button", {
6344
+ className: "dsh-ego-side-back",
6345
+ type: "button",
6346
+ title: wt("maximizeHint"),
6347
+ onClick: maximizeWindow
6348
+ }, icon(ICON_MAXIMIZE), wt("maximizeWindow")), presetOpen ? h("div", { className: "dsh-ego-side-presets" }, SIZE_PRESETS.map(function(preset) {
6349
+ return h("button", {
6350
+ key: preset.label,
6351
+ type: "button",
6352
+ className: "dsh-ego-side-preset-item",
6353
+ onClick: function() {
6354
+ applyPreset(preset.ratio);
6355
+ }
6356
+ }, preset.label);
6357
+ })) : null), h("div", {
6358
+ className: "dsh-ego-side-stage" + (sizeSyncOn ? " dsh-ego-size-unlocked" : "") + (state.currentTargetId != null && state.currentTargetId === state.agentActiveId ? " is-live" : ""),
6359
+ ref: stageRef
6360
+ }, liveImg, h("div", {
6361
+ className: "dsh-ego-side-resize dsh-ego-side-resize-right",
6362
+ title: wt("resizeHint"),
6363
+ onPointerDown: beginResize("x")
6364
+ }), h("div", {
6365
+ className: "dsh-ego-side-resize dsh-ego-side-resize-bottom",
6366
+ title: wt("resizeHint"),
6367
+ onPointerDown: beginResize("y")
6368
+ }), h("div", {
6369
+ className: "dsh-ego-side-resize dsh-ego-side-resize-corner",
6370
+ title: wt("resizeHint"),
6371
+ onPointerDown: beginResize("xy")
6372
+ })), h("div", { className: "dsh-ego-side-livetitle" }, currentSpace.title || currentSpace.url || wt("newTab")), h("div", { className: "dsh-ego-side-liveurl" + (state.zoomHint || sizeNotice ? " dsh-ego-side-hint" : "") }, sizeNotice || state.zoomHint || currentSpace.url || "")));
5627
6373
  }
5628
6374
  return h("div", { className: "dsh-ego-side-root" }, header, guides, tabsEl, body);
5629
6375
  }
@@ -5634,7 +6380,8 @@ function EgoLoginGuide(props) {
5634
6380
  var note = noteState[0], setNote = noteState[1];
5635
6381
  var savingState = React.useState(false);
5636
6382
  var saving = savingState[0], setSaving = savingState[1];
5637
- return h("div", { className: "dsh-ego-side-login" }, h("span", { className: "dsh-ego-side-login-txt" }, wt("loginTitle")), h("button", {
6383
+ var canFlush = linkFlushable(props.link);
6384
+ return h("div", { className: "dsh-ego-side-login" }, h("span", { className: "dsh-ego-side-login-txt" }, linkLoginLine(props.link)), canFlush ? h("button", {
5638
6385
  className: "dsh-ego-side-login-btn" + (saving ? " saving" : ""),
5639
6386
  type: "button",
5640
6387
  disabled: saving,
@@ -5650,7 +6397,7 @@ function EgoLoginGuide(props) {
5650
6397
  setSaving(false);
5651
6398
  });
5652
6399
  }
5653
- }, saving ? wt("loginSaving") : wt("loginBtn")), note ? h("span", { className: "dsh-ego-side-login-note" }, note) : null, h("button", {
6400
+ }, saving ? wt("loginSaving") : wt("loginBtn")) : null, !canFlush ? h("span", { className: "dsh-ego-side-login-note" }, wt("loginSelfPersist")) : null, note ? h("span", { className: "dsh-ego-side-login-note" }, note) : null, h("button", {
5654
6401
  className: "dsh-ego-side-iconbtn",
5655
6402
  type: "button",
5656
6403
  title: wt("loginDismiss"),
@@ -5663,7 +6410,7 @@ function EgoCaptchaGuide(props) {
5663
6410
  var controller = props.controller;
5664
6411
  var kind = props.kind;
5665
6412
  var h = React.createElement;
5666
- return h("div", { className: "dsh-ego-side-captcha" }, h("span", { className: "dsh-ego-side-captcha-txt" }, h("b", null, wt("captchaTitle")), " — " + wt("captchaHint")), h("span", { className: "dsh-ego-side-captcha-kind" }, kind), h("button", {
6413
+ return h("div", { className: "dsh-ego-side-captcha" }, h("span", { className: "dsh-ego-side-captcha-txt" }, h("b", null, wt("captchaTitle")), " — " + linkCaptchaLine(props.link)), h("span", { className: "dsh-ego-side-captcha-kind" }, kind), h("button", {
5667
6414
  className: "dsh-ego-side-iconbtn",
5668
6415
  type: "button",
5669
6416
  title: wt("captchaDismiss"),