dsh-multipane 1.0.56 → 1.1.10
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/LICENSE +21 -21
- package/README.en.md +49 -3
- package/README.md +326 -280
- package/cordis.patch.yml +11 -11
- package/lib/client.js +1560 -119
- package/lib/index.js +166 -9
- package/package.json +4 -4
package/lib/client.js
CHANGED
|
@@ -8,6 +8,8 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
let react = require("react");
|
|
9
9
|
const h = react.createElement;
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
|
|
11
13
|
//#region constants
|
|
12
14
|
const PANEL_ID = "split-view";
|
|
13
15
|
/**
|
|
@@ -17,7 +19,7 @@ window.__ModuleLoader__.load({
|
|
|
17
19
|
*/
|
|
18
20
|
const PLUGIN_LABEL = "多栏视图";
|
|
19
21
|
/* 与 package.json 的 version 必须一致(发版时两处同改;check-names.cjs 会校验)。 */
|
|
20
|
-
const PLUGIN_VERSION = "1.
|
|
22
|
+
const PLUGIN_VERSION = "1.1.10";
|
|
21
23
|
const NPM_LATEST_URL = "https://registry.npmjs.org/dsh-multipane/latest";
|
|
22
24
|
|
|
23
25
|
|
|
@@ -433,6 +435,10 @@ const PLUGIN_VERSION = "1.0.56";
|
|
|
433
435
|
}
|
|
434
436
|
const STORAGE_KEY = "dsh-split-view:workspace:v1";
|
|
435
437
|
const STYLE_ID = "dsh-split-view-style";
|
|
438
|
+
/* 自清开关:宿主说插件已被禁用后置 true。置上之后,所有"补样式 / 补行标记"的
|
|
439
|
+
心跳都必须停手 —— 否则 700ms 那一拍会把刚删掉的 <style> 和 data-dsv-row 又加回来,
|
|
440
|
+
用户看到的就是"清了又回来、根本关不掉"。页面重新加载后归 false。 */
|
|
441
|
+
let hostPurged = false;
|
|
436
442
|
/* 轮次导航条的阈值规则单独一张表:阈值是设置项,改一次只重写这一小段。 */
|
|
437
443
|
const RAIL_STYLE_ID = "dsh-split-view-rail-threshold";
|
|
438
444
|
const CONTENT_FACTORY = "conversation.content";
|
|
@@ -612,6 +618,83 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
612
618
|
return SERVICES.uiWorkspace;
|
|
613
619
|
}
|
|
614
620
|
|
|
621
|
+
/**
|
|
622
|
+
* 0.2.2 → 0.2.3 兼容层(2026-11-23 实测)。
|
|
623
|
+
*
|
|
624
|
+
* 宿主 0.2.3-alpha.2 做了两处搬家:
|
|
625
|
+
* · 右栏方法从 `layout.panels.openRightbar/closeRightbar` **拍平**到 `layout` 自己身上;
|
|
626
|
+
* · 删掉 `uiWorkspace.replaceMain(sid, signal, mode)`,只留 `openSession(target)`。
|
|
627
|
+
* 插件里这两个接口共 6 处调用,宿主一升级就全部空转:右栏点不开、焦点会话不再跟着
|
|
628
|
+
* 切标签走、退回单栏时宿主主会话还停在上一个。这里各包一层,两代接口都认。
|
|
629
|
+
*/
|
|
630
|
+
function layoutPanels() {
|
|
631
|
+
try {
|
|
632
|
+
const layout = SERVICES.layout ?? service("layout");
|
|
633
|
+
SERVICES.layout = layout;
|
|
634
|
+
if (layout === void 0 || layout === null) return null;
|
|
635
|
+
/* 0.2.2:包在 layout.panels 里 */
|
|
636
|
+
if (layout.panels !== void 0 && layout.panels !== null) return layout.panels;
|
|
637
|
+
/* 0.2.3:直接挂在 layout 上 */
|
|
638
|
+
return typeof layout.openRightbar === "function" || typeof layout.closeRightbar === "function" ? layout : null;
|
|
639
|
+
} catch {
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function openRightbarCompat(track, fullscreen) {
|
|
645
|
+
const panels = layoutPanels();
|
|
646
|
+
if (panels === null || typeof panels.openRightbar !== "function") return false;
|
|
647
|
+
try {
|
|
648
|
+
panels.openRightbar(track !== false, fullscreen === true);
|
|
649
|
+
return true;
|
|
650
|
+
} catch (error) {
|
|
651
|
+
console.warn("[split-view] 打开右栏失败:", error);
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function closeRightbarCompat() {
|
|
657
|
+
const panels = layoutPanels();
|
|
658
|
+
if (panels === null || typeof panels.closeRightbar !== "function") return false;
|
|
659
|
+
try {
|
|
660
|
+
panels.closeRightbar();
|
|
661
|
+
return true;
|
|
662
|
+
} catch {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** 让宿主的「当前会话」切到 sessionId。0.2.2 走 replaceMain,0.2.3 走 openSession。 */
|
|
668
|
+
function openMainCompat(sessionId) {
|
|
669
|
+
if (typeof sessionId !== "string" || sessionId === "") return false;
|
|
670
|
+
try {
|
|
671
|
+
const workspace = resolveWorkspaceService();
|
|
672
|
+
if (workspace === void 0 || workspace === null) return false;
|
|
673
|
+
if (typeof workspace.replaceMain === "function") {
|
|
674
|
+
const ac = typeof AbortController === "function" ? new AbortController() : null;
|
|
675
|
+
workspace.replaceMain(sessionId, ac === null ? void 0 : ac.signal, "keep");
|
|
676
|
+
return true;
|
|
677
|
+
}
|
|
678
|
+
if (typeof workspace.openSession === "function") {
|
|
679
|
+
workspace.openSession(sessionId);
|
|
680
|
+
return true;
|
|
681
|
+
}
|
|
682
|
+
} catch (error) {
|
|
683
|
+
console.warn("[split-view] 切换宿主主会话失败:", error);
|
|
684
|
+
}
|
|
685
|
+
return false;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/** 0.2.3 的会话面板开关(官方那颗三横线);它自己就是「右栏」的官方入口。 */
|
|
689
|
+
function hostPanelToggle(root) {
|
|
690
|
+
try {
|
|
691
|
+
const scope = root === void 0 || root === null ? document : root;
|
|
692
|
+
return scope.querySelector("[data-session-panel-toggle]");
|
|
693
|
+
} catch {
|
|
694
|
+
return null;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
615
698
|
/** Handles the panel publishes so document-level bridges can drive it. */
|
|
616
699
|
const bridge = {
|
|
617
700
|
open: null,
|
|
@@ -887,7 +970,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
887
970
|
}
|
|
888
971
|
|
|
889
972
|
/** Whatever is currently being dragged (session row from the tree, or a tab). */
|
|
890
|
-
const drag = { sessionId: null, tab: null };
|
|
973
|
+
const drag = { sessionId: null, tab: null, fromPointer: false };
|
|
891
974
|
|
|
892
975
|
/* 宿主「会话右键菜单」里的贡献项在 React 之外被 resolve,拿不到组件内的 state / apply,
|
|
893
976
|
所以留两个模块级指针:最近一次渲染的布局状态、以及写状态的 apply。 */
|
|
@@ -1341,6 +1424,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1341
1424
|
|
|
1342
1425
|
const prefs = {
|
|
1343
1426
|
state: { enabled: true, showSettings: false, showInSidebar: true },
|
|
1427
|
+
/* 每次 write 自增:700ms 心跳用它判断"颜色设置变过没有",避免每拍都重写 40 多个 CSS 变量。 */
|
|
1428
|
+
rev: 0,
|
|
1344
1429
|
listeners: new Set(),
|
|
1345
1430
|
read() {
|
|
1346
1431
|
try {
|
|
@@ -1381,6 +1466,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1381
1466
|
write(next) {
|
|
1382
1467
|
const appearance = normalizeAppearance(next.appearance, next);
|
|
1383
1468
|
prefs.state = { ...next, appearance };
|
|
1469
|
+
prefs.rev += 1;
|
|
1384
1470
|
try {
|
|
1385
1471
|
window.localStorage.setItem(
|
|
1386
1472
|
PREFS_KEY,
|
|
@@ -1468,11 +1554,12 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1468
1554
|
* var(--dsv-line) 全部回落到备用值,也就是「颜色设置管不到侧栏」。
|
|
1469
1555
|
* 写到根上之后,无论在插件根里还是在宿主侧栏里,读到的都是同一份。
|
|
1470
1556
|
*/
|
|
1557
|
+
let lastLineRev = -1;
|
|
1471
1558
|
function applyLineVars() {
|
|
1472
1559
|
try {
|
|
1473
1560
|
/* 关掉插件后不该继续往根上写变量(连同样的变量都会让宿主看起来"没关干净")。
|
|
1474
1561
|
重新打开时这里会再跑一遍,样式表一并补回来。 */
|
|
1475
|
-
if (prefs.state.enabled !== true) return;
|
|
1562
|
+
if (prefs.state.enabled !== true || hostPurged === true) return;
|
|
1476
1563
|
installStyles();
|
|
1477
1564
|
const el = document.documentElement;
|
|
1478
1565
|
const state = prefs.state;
|
|
@@ -1559,6 +1646,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1559
1646
|
} catch {
|
|
1560
1647
|
/* 忽略 */
|
|
1561
1648
|
}
|
|
1649
|
+
lastLineRev = prefs.rev;
|
|
1562
1650
|
} catch {
|
|
1563
1651
|
/* 非浏览器环境 */
|
|
1564
1652
|
}
|
|
@@ -1652,8 +1740,13 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1652
1740
|
}
|
|
1653
1741
|
syncSettingsFlag();
|
|
1654
1742
|
prefs.subscribe(syncSettingsFlag);
|
|
1655
|
-
/* 颜色 / 浓度 / 粗细写到 <html>:侧栏会话行在插件根之外,只有根上的变量它读得到。
|
|
1656
|
-
|
|
1743
|
+
/* 颜色 / 浓度 / 粗细写到 <html>:侧栏会话行在插件根之外,只有根上的变量它读得到。
|
|
1744
|
+
⚠️ 这里**不能**直接调用:样式表文案是后面才初始化的 `const CSS`,模块体跑到这一行
|
|
1745
|
+
时它还在 TDZ 里,installStyles 会抛 `Cannot access 'CSS' before initialization`
|
|
1746
|
+
→ 样式表没装上、整块界面裸奔(0.2.3 实测连报两条)。推迟一个微任务,等模块体
|
|
1747
|
+
跑完(CSS 已初始化)再调,副作用只是晚一拍,样式照常装上。 */
|
|
1748
|
+
if (typeof queueMicrotask === "function") queueMicrotask(applyLineVars);
|
|
1749
|
+
else window.setTimeout(applyLineVars, 0);
|
|
1657
1750
|
prefs.subscribe(applyLineVars);
|
|
1658
1751
|
/* 阈值改了要立刻重写那段容器查询,不用重启。 */
|
|
1659
1752
|
prefs.subscribe(applyRailThreshold);
|
|
@@ -1869,6 +1962,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1869
1962
|
* @param force 忽略启用开关(插件卸载 / 停用时强制还原)
|
|
1870
1963
|
*/
|
|
1871
1964
|
function syncPaneBlankRows(state, force) {
|
|
1965
|
+
if (hostPurged === true) force = true;
|
|
1872
1966
|
const sessions = resolveSessions();
|
|
1873
1967
|
const list = sessions?.list;
|
|
1874
1968
|
let snap;
|
|
@@ -1997,6 +2091,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1997
2091
|
}
|
|
1998
2092
|
|
|
1999
2093
|
function paintSidebarRows(state) {
|
|
2094
|
+
if (hostPurged === true) return;
|
|
2000
2095
|
const sessions = resolveSessions();
|
|
2001
2096
|
let snap;
|
|
2002
2097
|
try {
|
|
@@ -2062,10 +2157,43 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2062
2157
|
* WorkspaceRoot 卸载后这个引用仍然在,所以设置页里也能正确标记。
|
|
2063
2158
|
* 冷启动时它还没写 → 回退到 localStorage(readState)。
|
|
2064
2159
|
*/
|
|
2160
|
+
/* purge 时给 .dsv-root 写过 style.display="none"。如果宿主复用了同一个 DOM 节点,
|
|
2161
|
+
这条内联样式会跨上下文活下来:新插件实例明明在跑,主区却一直是 display:none。
|
|
2162
|
+
启动时和每拍都摘一次(只摘我们自己写的 display,不动别的内联样式)。 */
|
|
2163
|
+
function clearPurgeDisplay() {
|
|
2164
|
+
try {
|
|
2165
|
+
for (const node of document.querySelectorAll(".dsv-root")) {
|
|
2166
|
+
if (node.style.display === "none") node.style.removeProperty("display");
|
|
2167
|
+
}
|
|
2168
|
+
} catch {
|
|
2169
|
+
/* 忽略 */
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2065
2173
|
function startSidebarMarks() {
|
|
2174
|
+
clearPurgeDisplay();
|
|
2066
2175
|
let scheduled = false;
|
|
2067
2176
|
const tick = () => {
|
|
2068
2177
|
scheduled = false;
|
|
2178
|
+
if (hostPurged !== true) clearPurgeDisplay();
|
|
2179
|
+
/* 已判定禁用:这一拍只负责把宿主重渲染后可能冒出来的标记再清一遍,
|
|
2180
|
+
绝不补样式、绝不重新打标。 */
|
|
2181
|
+
if (hostPurged === true) {
|
|
2182
|
+
try {
|
|
2183
|
+
syncPaneBlankRows(null, true);
|
|
2184
|
+
} catch {
|
|
2185
|
+
/* 忽略 */
|
|
2186
|
+
}
|
|
2187
|
+
clearHostMarks();
|
|
2188
|
+
clearLineVars();
|
|
2189
|
+
/* 槽位 dispose 之后宿主可能还来不及换树;把残存的插件根也藏掉,双保险。 */
|
|
2190
|
+
try {
|
|
2191
|
+
for (const node of document.querySelectorAll(".dsv-root")) node.style.display = "none";
|
|
2192
|
+
} catch {
|
|
2193
|
+
/* 忽略 */
|
|
2194
|
+
}
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2069
2197
|
/* 样式表 id 是全局唯一的。宿主热更新会同时跑新旧两份插件代码,
|
|
2070
2198
|
旧的一份可能还在删这张表 —— 每拍检查一次,缺了就补回来。 */
|
|
2071
2199
|
if (
|
|
@@ -2096,6 +2224,12 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2096
2224
|
return;
|
|
2097
2225
|
}
|
|
2098
2226
|
try {
|
|
2227
|
+
/* 颜色变量也每拍补一次:禁用→启用后,applyLineVars 的 prefs 订阅可能
|
|
2228
|
+
随旧 context 一起没了;只靠订阅就会出现"分栏回来了,竖条/标签颜色却是灰的"。
|
|
2229
|
+
这个 tick 挂在 globalThis 上,能活过 context dispose,补变量最可靠。 */
|
|
2230
|
+
if (document.documentElement.style.getPropertyValue("--dsv-line") === "" || prefs.rev !== lastLineRev) {
|
|
2231
|
+
applyLineVars();
|
|
2232
|
+
}
|
|
2099
2233
|
const state = window.__dsvState ?? readState();
|
|
2100
2234
|
syncPaneBlankRows(state);
|
|
2101
2235
|
paintSidebarRows(state);
|
|
@@ -2164,6 +2298,84 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2164
2298
|
}
|
|
2165
2299
|
}
|
|
2166
2300
|
|
|
2301
|
+
/**
|
|
2302
|
+
* 全局看门狗:不依赖 ctx 生命周期。
|
|
2303
|
+
*
|
|
2304
|
+
* 宿主在插件管理里禁用插件时,可能直接把客户端上下文 dispose 掉 —— ctx.effect 的
|
|
2305
|
+
* 清理函数跑没跑、什么时候跑,都不由我们控制。这个定时器挂在 globalThis 上,
|
|
2306
|
+
* 上下文被拆掉之后仍然活着;只要宿主半身答 enabled:false(或路由整个消失),
|
|
2307
|
+
* 就调用 __dsvPurge 把页面痕迹清掉。清完自停,避免重复打扰。
|
|
2308
|
+
*/
|
|
2309
|
+
function startHostWatchdog() {
|
|
2310
|
+
try {
|
|
2311
|
+
if (globalThis.__dsvHostWatchdog !== void 0) {
|
|
2312
|
+
clearInterval(globalThis.__dsvHostWatchdog);
|
|
2313
|
+
globalThis.__dsvHostWatchdog = void 0;
|
|
2314
|
+
}
|
|
2315
|
+
} catch {
|
|
2316
|
+
/* 忽略 */
|
|
2317
|
+
}
|
|
2318
|
+
let everSeen = false;
|
|
2319
|
+
let misses = 0;
|
|
2320
|
+
/* armed:本轮"启用"还没处理过禁用信号。清完场就置 false,避免每 2.5s 重复清;
|
|
2321
|
+
一旦宿主重新答 enabled:true,再重新上膛,下一轮禁用还能再清。 */
|
|
2322
|
+
let armed = true;
|
|
2323
|
+
const tick = () => {
|
|
2324
|
+
let request = null;
|
|
2325
|
+
try {
|
|
2326
|
+
request = fetch(`${SELF_STATUS_URL}?wd=${Date.now()}`, { cache: "no-store" });
|
|
2327
|
+
} catch {
|
|
2328
|
+
return;
|
|
2329
|
+
}
|
|
2330
|
+
if (request === null || typeof request.then !== "function") return;
|
|
2331
|
+
request
|
|
2332
|
+
.then((response) => (response.ok === true ? response.json() : null))
|
|
2333
|
+
.then((data) => {
|
|
2334
|
+
if (data !== null && typeof data === "object" && data.enabled === false) {
|
|
2335
|
+
if (armed === true) {
|
|
2336
|
+
armed = false;
|
|
2337
|
+
try {
|
|
2338
|
+
if (typeof globalThis.__dsvPurge === "function") globalThis.__dsvPurge();
|
|
2339
|
+
} catch {
|
|
2340
|
+
/* 忽略 */
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2345
|
+
if (data !== null && typeof data === "object" && typeof data.version === "string") {
|
|
2346
|
+
everSeen = true;
|
|
2347
|
+
misses = 0;
|
|
2348
|
+
armed = true;
|
|
2349
|
+
/* 宿主上下文被拆掉时,liveness probe 已经没了;看门狗还能看到
|
|
2350
|
+
"重新启用了",顺手调一次 revive,尽量原地把界面装回来。 */
|
|
2351
|
+
if (hostPurged === true) {
|
|
2352
|
+
try {
|
|
2353
|
+
if (typeof globalThis.__dsvRevive === "function") globalThis.__dsvRevive();
|
|
2354
|
+
} catch {
|
|
2355
|
+
/* 忽略 */
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
return;
|
|
2359
|
+
}
|
|
2360
|
+
throw new Error("watchdog: no version");
|
|
2361
|
+
})
|
|
2362
|
+
.catch(() => {
|
|
2363
|
+
if (everSeen !== true) return;
|
|
2364
|
+
misses += 1;
|
|
2365
|
+
if (misses < 2) return;
|
|
2366
|
+
if (armed === false) return;
|
|
2367
|
+
armed = false;
|
|
2368
|
+
try {
|
|
2369
|
+
if (typeof globalThis.__dsvPurge === "function") globalThis.__dsvPurge();
|
|
2370
|
+
} catch {
|
|
2371
|
+
/* 忽略 */
|
|
2372
|
+
}
|
|
2373
|
+
});
|
|
2374
|
+
};
|
|
2375
|
+
globalThis.__dsvHostWatchdog = setInterval(tick, 2500);
|
|
2376
|
+
tick();
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2167
2379
|
function useSidebarRowMarks(state, sessions, bumpStatus) {
|
|
2168
2380
|
/* 运行中状态来自宿主 session 列表的 row.running。
|
|
2169
2381
|
⚠️ 必须在 compute 里**每次现读 getSnapshot**,不能依赖 useSessionList 的订阅:
|
|
@@ -2172,6 +2384,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2172
2384
|
const runningIdsRef = react.useRef(new Set());
|
|
2173
2385
|
react.useEffect(() => {
|
|
2174
2386
|
const compute = () => {
|
|
2387
|
+
/* 已判定禁用:别再往宿主行上补任何标记。 */
|
|
2388
|
+
if (hostPurged === true) return;
|
|
2175
2389
|
/* 先把「还开着的新会话」补进侧栏列表:焦点栏一换,宿主就会
|
|
2176
2390
|
把另一栏那个空白会话过滤掉,这一步在每次重算时都补回来。 */
|
|
2177
2391
|
try {
|
|
@@ -2508,17 +2722,18 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2508
2722
|
⚠️ 用背景渐变画左条,不用 inset box-shadow:宿主这一行有 2.67px 的透明左边框,
|
|
2509
2723
|
inset 阴影从 padding box 起画,会在最左边留一道 2.67px 的"底板缝"(2026-11-09 用户指出)。
|
|
2510
2724
|
背景渐变默认按 border-box 绘制,能盖住边框区域,左条才是齐边的。 */
|
|
2511
|
-
|
|
2725
|
+
/* 兜底规则已删除:.dsv-root 不存在不等于被禁用(打开插件管理页/设置页时工作区本来就会卸载)。禁用后的清理由客户端存活探测负责。 */
|
|
2726
|
+
[data-row-key^="session:"][data-dsv-row="focus"]{background-clip:border-box!important;background-origin:border-box!important;background-color:var(--dsv-row-focus-bg,rgba(167,170,175,.15))!important;background-image:none!important;background-image:linear-gradient(to right,var(--dsv-row-focus-a,rgba(167,170,175,.75)) 0,var(--dsv-row-focus-a,rgba(167,170,175,.75)) var(--dsv-row-w-focus,3px),transparent var(--dsv-row-w-focus,3px))!important;box-shadow:none!important;font-weight:var(--dsv-row-fw,400)}
|
|
2512
2727
|
[data-row-key^="session:"][data-dsv-row="focus"] *{color:inherit}
|
|
2513
2728
|
/* 已打开但未激活:与焦点行**同一条线色,只靠浓度区分**(2026-11-09 起颜色统一由外观设置驱动):
|
|
2514
2729
|
焦点 = 3px 75% 左条 + 15% 底;已打开 = 2px 52% 左条 + 6% 底;未打开 = 无色。
|
|
2515
2730
|
浓度压得很低,不抢注意力。 */
|
|
2516
|
-
[data-row-key^="session:"][data-dsv-row="open"]{background-clip:border-box!important;background-origin:border-box!important;background-color:var(--dsv-row-open-bg,rgba(167,170,175,.06))!important;background-image:linear-gradient(to right,var(--dsv-row-open-a,rgba(167,170,175,.52)) 0,var(--dsv-row-open-a,rgba(167,170,175,.52)) var(--dsv-row-w-open,2px),transparent var(--dsv-row-w-open,2px))!important;box-shadow:none!important;font-weight:400}
|
|
2731
|
+
[data-row-key^="session:"][data-dsv-row="open"]{background-clip:border-box!important;background-origin:border-box!important;background-color:var(--dsv-row-open-bg,rgba(167,170,175,.06))!important;background-image:none!important;background-image:linear-gradient(to right,var(--dsv-row-open-a,rgba(167,170,175,.52)) 0,var(--dsv-row-open-a,rgba(167,170,175,.52)) var(--dsv-row-w-open,2px),transparent var(--dsv-row-w-open,2px))!important;box-shadow:none!important;font-weight:400}
|
|
2517
2732
|
/* 已打开的会话行只换底色 + 左竖线,**不压文字透明度**:
|
|
2518
2733
|
以前这里写 *{opacity:.70},把行内的悬浮操作按钮也一起压暗了,按钮根本看不见。 */
|
|
2519
2734
|
/* 已打开但**没有显示**(在标签里、不是当前激活标签):与「打开显示」同一套底色/文字,
|
|
2520
2735
|
只是默认不画左竖线 —— 一眼能分出"这个开过但没在屏幕上"。 */
|
|
2521
|
-
[data-row-key^="session:"][data-dsv-row="open-hidden"]{background-clip:border-box!important;background-origin:border-box!important;background-color:var(--dsv-row-open-bg,rgba(167,170,175,.06))!important;background-image:
|
|
2736
|
+
[data-row-key^="session:"][data-dsv-row="open-hidden"]{background-clip:border-box!important;background-origin:border-box!important;background-color:var(--dsv-row-open-bg,rgba(167,170,175,.06))!important;background-image:none!important;box-shadow:none!important;font-weight:400}
|
|
2522
2737
|
/* 新会话投影行:外观与原生「新会话」行一致 —— 不显示行尾时间 / 悬浮操作。 */
|
|
2523
2738
|
[data-row-key^="session:"][data-dsv-pane-blank="1"] [class*="_rowResting"],
|
|
2524
2739
|
[data-row-key^="session:"][data-dsv-pane-blank="1"] [class*="_rowActions"]{display:none!important}
|
|
@@ -2535,25 +2750,17 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2535
2750
|
@keyframes dsv-breathe-open{0%,100%{--dsv-pv-c:var(--dsv-pv-openShown-lo)}50%{--dsv-pv-c:var(--dsv-pv-openShown-hi)}}
|
|
2536
2751
|
@keyframes dsv-breathe-hidden{0%,100%{--dsv-pv-c:var(--dsv-pv-openHidden-lo)}50%{--dsv-pv-c:var(--dsv-pv-openHidden-hi)}}
|
|
2537
2752
|
@keyframes dsv-breathe-un{0%,100%{--dsv-pv-c:var(--dsv-pv-unopened-lo)}50%{--dsv-pv-c:var(--dsv-pv-unopened-hi)}}
|
|
2538
|
-
/*
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
[data-row-key^="session:"][data-dsv-pulse="1"]
|
|
2544
|
-
|
|
2545
|
-
[data-row-key^="session:"][data-dsv-pulse="1"][data-dsv-row="
|
|
2546
|
-
[data-row-key^="session:"][data-dsv-pulse="1"][data-dsv-row
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
/* 呼吸时行底板必须让位(2026-11-11 用户:最亮填成和底板一样的值,看着还是明显更亮)。
|
|
2550
|
-
行底色和呼吸伪元素是**两层**:底板 15% 之上再叠一层 15%,合成后 1-(1-.15)(1-.15)=27.75%,
|
|
2551
|
-
所以设置里的「最亮」在真实列表里永远比底板亮一大截;而设置页预览是单层(直接动画
|
|
2552
|
-
background-color),两边对不上。让行底色透明、只留伪元素那一层,屏幕上看到的透明度就
|
|
2553
|
-
等于设置里的数值。左竖线是 background-image,不受影响。 */
|
|
2554
|
-
[data-row-key^="session:"][data-dsv-pulse="1"][data-dsv-row="focus"],
|
|
2555
|
-
[data-row-key^="session:"][data-dsv-pulse="1"][data-dsv-row="open"],
|
|
2556
|
-
[data-row-key^="session:"][data-dsv-pulse="1"][data-dsv-row="open-hidden"]{background-color:transparent!important}
|
|
2753
|
+
/* 真实列表的呼吸(2026-11-23 重写):直接动画行自己的 background-color(--dsv-pv-c 是注册过的 <color>),
|
|
2754
|
+
不再挂伪元素 —— 伪元素是"另一块形状",圆角处必然露缝。只有被标成 pulse 的少数行在动,
|
|
2755
|
+
重绘范围可控;设置页的预览(.dsv-pv-row)用同一套变量。 */
|
|
2756
|
+
[data-row-key^="session:"][data-dsv-pulse="1"]{position:relative;background-color:var(--dsv-pv-c,rgba(0,0,0,0))!important;animation:dsv-breathe-pulse var(--dsv-pv-dur,3s) ease-in-out infinite}
|
|
2757
|
+
@keyframes dsv-breathe-pulse{0%,100%{--dsv-pv-c:var(--dsv-pv-lo,rgba(0,0,0,0))}50%{--dsv-pv-c:var(--dsv-pv-hi,rgba(0,0,0,0))}}
|
|
2758
|
+
[data-row-key^="session:"][data-dsv-pulse="1"][data-dsv-row="focus"]{--dsv-pv-lo:var(--dsv-pv-active-lo);--dsv-pv-hi:var(--dsv-pv-active-hi);--dsv-pv-dur:var(--dsv-pv-active-dur,3s)}
|
|
2759
|
+
[data-row-key^="session:"][data-dsv-pulse="1"][data-dsv-row="open"]{--dsv-pv-lo:var(--dsv-pv-openShown-lo);--dsv-pv-hi:var(--dsv-pv-openShown-hi);--dsv-pv-dur:var(--dsv-pv-openShown-dur,3s)}
|
|
2760
|
+
[data-row-key^="session:"][data-dsv-pulse="1"][data-dsv-row="open-hidden"]{--dsv-pv-lo:var(--dsv-pv-openHidden-lo);--dsv-pv-hi:var(--dsv-pv-openHidden-hi);--dsv-pv-dur:var(--dsv-pv-openHidden-dur,3s)}
|
|
2761
|
+
[data-row-key^="session:"][data-dsv-pulse="1"]:not([data-dsv-row]){--dsv-pv-lo:var(--dsv-pv-unopened-lo);--dsv-pv-hi:var(--dsv-pv-unopened-hi);--dsv-pv-dur:var(--dsv-pv-unopened-dur,3s)}
|
|
2762
|
+
/* 底板与竖线现在是同一个盒子的两种绘制:竖线=行自己的 border-left-color(宿主本来就给每行留了 2.67px 左侧透明边框),底板=行自己的 background-color。
|
|
2763
|
+
上一版的伪元素方案已删除:伪元素是「另一块形状」,无论怎么对齐,圆角处都会露出一条缝。 */
|
|
2557
2764
|
.dsv-pv-row[data-pulse="1"][data-state="focus"]{background-color:var(--dsv-pv-c)!important;animation:dsv-breathe-active var(--dsv-pv-active-dur,3s) ease-in-out infinite}
|
|
2558
2765
|
.dsv-pv-row[data-pulse="1"][data-state="open"]{background-color:var(--dsv-pv-c)!important;animation:dsv-breathe-open var(--dsv-pv-openShown-dur,3s) ease-in-out infinite}
|
|
2559
2766
|
.dsv-pv-row[data-pulse="1"][data-state="open-hidden"]{background-color:var(--dsv-pv-c)!important;animation:dsv-breathe-hidden var(--dsv-pv-openHidden-dur,3s) ease-in-out infinite}
|
|
@@ -2938,7 +3145,10 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2938
3145
|
/**
|
|
2939
3146
|
* Install the stylesheet once per document.
|
|
2940
3147
|
*/
|
|
3148
|
+
let STYLES_RETRY = false;
|
|
2941
3149
|
function installStyles() {
|
|
3150
|
+
/* 已被宿主判定为禁用:任何调用方(心跳、prefs 订阅、设置页)都不许再把样式装回来。 */
|
|
3151
|
+
if (hostPurged === true) return;
|
|
2942
3152
|
try {
|
|
2943
3153
|
if (document.getElementById(STYLE_ID) === null) {
|
|
2944
3154
|
const style = document.createElement("style");
|
|
@@ -2954,6 +3164,15 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2954
3164
|
applyRailThreshold();
|
|
2955
3165
|
} catch (error) {
|
|
2956
3166
|
console.warn("[split-view] styles unavailable:", error);
|
|
3167
|
+
/* 模块加载期就有人调用(prefs.write 的订阅者会立刻跑),此时 CSS 还在 TDZ。
|
|
3168
|
+
补一次延迟重试:等模块体跑完再装,界面就不会裸奔。只重试一次,防死循环。 */
|
|
3169
|
+
if (STYLES_RETRY !== true && typeof queueMicrotask === "function") {
|
|
3170
|
+
STYLES_RETRY = true;
|
|
3171
|
+
queueMicrotask(() => {
|
|
3172
|
+
STYLES_RETRY = false;
|
|
3173
|
+
installStyles();
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
2957
3176
|
}
|
|
2958
3177
|
}
|
|
2959
3178
|
//#endregion
|
|
@@ -3462,6 +3681,18 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
3462
3681
|
|
|
3463
3682
|
function makeReference(sessions, sessionId) {
|
|
3464
3683
|
if (typeof sessionId !== "string" || sessionId === "") return void 0;
|
|
3684
|
+
/* ✅ 2026-11-23 定案(对照实验):这里**不能**交回宿主的真 retain 句柄。
|
|
3685
|
+
真句柄会被宿主当成「有挂载面在用」,工作区一卸载(进插件管理页)就可能
|
|
3686
|
+
替我们把它释放掉 —— 那个会话随即从侧栏列表里消失(实测只剩一行)。
|
|
3687
|
+
假壳子宿主不认识,反而安全;正文能不能显示取决于两件事,与引用形状无关:
|
|
3688
|
+
① retain 时必须带 facets.conversation(见 retainSession);
|
|
3689
|
+
② SessionProvider 收到的是这个壳子 + 上面那份 facet。
|
|
3690
|
+
1.0.55 就是这么工作的,实测两行都在、两栏都有正文。 */
|
|
3691
|
+
const USE_REAL_REFERENCE = false;
|
|
3692
|
+
if (USE_REAL_REFERENCE === true) {
|
|
3693
|
+
const entry = retainGuard.get(retainKey(sessionId, RETAIN_SOURCE));
|
|
3694
|
+
if (entry !== void 0 && entry.handle !== null && entry.handle !== void 0) return entry.handle;
|
|
3695
|
+
}
|
|
3465
3696
|
let binding;
|
|
3466
3697
|
try {
|
|
3467
3698
|
binding = typeof sessions.binding === "function" ? sessions.binding(sessionId) : void 0;
|
|
@@ -3509,7 +3740,13 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
3509
3740
|
entry.count += 1;
|
|
3510
3741
|
if (entry.handle === null) {
|
|
3511
3742
|
try {
|
|
3512
|
-
|
|
3743
|
+
/* ⚠️ 0.2.3 关键:宿主自己给「独立会话视图」retain 时带了
|
|
3744
|
+
`facets: { conversation: true }`(见 ui-sidebar-right 的 SidebarSessionView)。
|
|
3745
|
+
不带这个 facet,控制器不会为这个会话物化「对话」这一面 →
|
|
3746
|
+
我们栏里的正文拿不到会话内容,回退成宿主当前会话,于是
|
|
3747
|
+
「只有焦点栏有正文、别的栏全空」。这是 1.0.60 只换 reference 形状
|
|
3748
|
+
没解决的那一半原因。 */
|
|
3749
|
+
entry.handle = sessions.retain(sessionId, { source: src, facets: { conversation: true } });
|
|
3513
3750
|
} catch (error) {
|
|
3514
3751
|
entry.count -= 1;
|
|
3515
3752
|
if (entry.count <= 0) retainGuard.delete(key);
|
|
@@ -3590,6 +3827,20 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
3590
3827
|
}, [sessions, sessionId]);
|
|
3591
3828
|
|
|
3592
3829
|
const reference = makeReference(sessions, sessionId);
|
|
3830
|
+
/* [diag] 0.2.3 绑定问题的现场取证:每栏每个会话只打一次。 */
|
|
3831
|
+
try {
|
|
3832
|
+
if (typeof window !== "undefined") {
|
|
3833
|
+
const kind = reference === void 0 ? "none" : typeof reference.release === "function" || typeof reference.ready !== "undefined" || reference.handle !== void 0 ? "retain" : "shell";
|
|
3834
|
+
const key = String(sessionId) + "|" + kind;
|
|
3835
|
+
window.__dsvDiag = window.__dsvDiag ?? new Set();
|
|
3836
|
+
if (!window.__dsvDiag.has(key)) {
|
|
3837
|
+
window.__dsvDiag.add(key);
|
|
3838
|
+
if (window.__dsvDiagOn === true) console.warn("[split-view:diag] reference", { sessionId, kind, hasBinding: reference !== void 0 && reference.binding !== void 0, keys: reference === void 0 ? [] : Object.keys(reference) });
|
|
3839
|
+
}
|
|
3840
|
+
}
|
|
3841
|
+
} catch {
|
|
3842
|
+
/* 忽略 */
|
|
3843
|
+
}
|
|
3593
3844
|
return { reference, status: reference === void 0 ? "pending" : "ready" };
|
|
3594
3845
|
}
|
|
3595
3846
|
//#endregion
|
|
@@ -4393,6 +4644,61 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
4393
4644
|
};
|
|
4394
4645
|
}
|
|
4395
4646
|
|
|
4647
|
+
/* ===== 粘贴定向:落在输入框之外的截图粘贴,交给**当前栏** =====
|
|
4648
|
+
*
|
|
4649
|
+
* 宿主的 document 层粘贴路由(`createComposerFileIntake`,0.2.2-rc.5 与
|
|
4650
|
+
* 0.2.3-alpha.2 是同一份实现)只认两种人:① 最近持有过焦点的那个 composer;
|
|
4651
|
+
* ② `occurrence === 'main'` 的那一个。多栏把宿主的 `main` 槽整条换成自己的面板,
|
|
4652
|
+
* 每栏的输入框都是按 `variant: "embedded"` 渲染的 → 全页没有 `main`。于是:
|
|
4653
|
+
* · 光标不在输入框里、但别的栏点过输入框 → 图跑进**那个栏**(错栏,实测复现);
|
|
4654
|
+
* · 从没点过输入框 → 谁都不认,路由直接放弃,连提示都没有。
|
|
4655
|
+
* 而光标落在输入框里时走的是编辑器自己的粘贴命令,一切正常 ——
|
|
4656
|
+
* 所以这个毛病看起来「时好时坏」,且关掉插件就消失(宿主原生面板是 `main`)。
|
|
4657
|
+
*
|
|
4658
|
+
* 修法:在 window **捕获**阶段抢在宿主(document 冒泡)之前,只做一件事 ——
|
|
4659
|
+
* 把当前栏激活标签的输入框 focus() 一下。focus 会同步触发 focusin,
|
|
4660
|
+
* 宿主路由的 `focused` 当场更新,紧接着它自己的监听就把这次粘贴投给正确的栏。
|
|
4661
|
+
* 不 preventDefault、不 stopPropagation、不读文件内容;任何一步对不上就整个让路。
|
|
4662
|
+
*
|
|
4663
|
+
* @returns 卸载函数(只拆这一个监听)
|
|
4664
|
+
*/
|
|
4665
|
+
function installPastePaneRouting() {
|
|
4666
|
+
const EDITABLE = 'input, textarea, select, [contenteditable]:not([contenteditable="false"])';
|
|
4667
|
+
const focusOwner = (node) => (node !== null && node !== void 0 && typeof node.closest === "function" ? node.closest(EDITABLE) : null);
|
|
4668
|
+
const onPaste = (event) => {
|
|
4669
|
+
try {
|
|
4670
|
+
const dt = event.clipboardData;
|
|
4671
|
+
if (dt === null || dt === void 0 || dt.files === void 0 || dt.files.length === 0) return;
|
|
4672
|
+
/* 落点本身在可编辑元素里 → 编辑器自己会处理(含文本优先的规则),别插手。 */
|
|
4673
|
+
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
4674
|
+
const origin = path.length > 0 ? path[0] : event.target;
|
|
4675
|
+
if (focusOwner(origin) !== null) return;
|
|
4676
|
+
const active = document.activeElement;
|
|
4677
|
+
/* 焦点已经在某个输入框里 → 宿主认的就是它,不改判。 */
|
|
4678
|
+
if (focusOwner(active) !== null) return;
|
|
4679
|
+
/* 前台有模态框/菜单时抢焦点会打架,让路。 */
|
|
4680
|
+
if (active !== null && active !== void 0 && typeof active.closest === "function"
|
|
4681
|
+
&& active.closest('[role="dialog"], dialog[open], [aria-modal="true"]') !== null) return;
|
|
4682
|
+
const pane = currentPaneEl();
|
|
4683
|
+
if (pane === null || pane === void 0) return;
|
|
4684
|
+
/* 注意:这里不能因为「焦点已经在本栏」就提前收手 —— 焦点可能停在本栏的
|
|
4685
|
+
某个按钮上而不是输入框里,此时宿主仍然会把粘贴投给**上次**持有焦点的
|
|
4686
|
+
composer(可能在别的栏)。只有「焦点已经在某个可编辑元素里」才让路
|
|
4687
|
+
(上面已判),其余情况一律把当前栏的输入框扶正。 */
|
|
4688
|
+
const editor = pane.querySelector('.dsv-tab-slot[data-active="1"] [contenteditable="true"]')
|
|
4689
|
+
?? pane.querySelector('[contenteditable="true"]');
|
|
4690
|
+
if (editor === null || editor === void 0 || typeof editor.focus !== "function") return;
|
|
4691
|
+
editor.focus({ preventScroll: true });
|
|
4692
|
+
} catch {
|
|
4693
|
+
/* 任何异常都只是「让路」:绝不吞掉这次粘贴,最坏退回宿主原行为。 */
|
|
4694
|
+
}
|
|
4695
|
+
};
|
|
4696
|
+
window.addEventListener("paste", onPaste, true);
|
|
4697
|
+
return () => {
|
|
4698
|
+
window.removeEventListener("paste", onPaste, true);
|
|
4699
|
+
};
|
|
4700
|
+
}
|
|
4701
|
+
|
|
4396
4702
|
/* Ctrl+Tab 跨栏跳过去之后**不抢键盘焦点**(插入符留在原栏的输入框里,回头再按一次
|
|
4397
4703
|
就能接着打字)。但「当前栏」原本是按 document.activeElement 判的 —— 不记一笔,
|
|
4398
4704
|
连按 Ctrl+Tab 会每次都从旧栏重新算,在两栏之间打乒乓;Ctrl+W 也会关掉旧栏的标签。
|
|
@@ -4889,7 +5195,8 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
4889
5195
|
className: "dsv-paneheader",
|
|
4890
5196
|
"data-focus": focused ? "1" : "0",
|
|
4891
5197
|
onDragOver: (event) => {
|
|
4892
|
-
if (drag.sessionId === null && drag.tab === null) return;
|
|
5198
|
+
if (drag.sessionId === null && drag.tab === null) { if (window.__dsvDiagOn === true) console.warn("[split-view:diag] drop 放行:没识别出拖拽来源"); return; }
|
|
5199
|
+
if (window.__dsvDiagOn === true) console.warn("[split-view:diag] drop", { sessionId: drag.sessionId, tab: drag.tab === null ? null : drag.tab.tabId });
|
|
4893
5200
|
event.preventDefault();
|
|
4894
5201
|
event.stopPropagation();
|
|
4895
5202
|
/* 不显式设 dropEffect:与拖拽源设置的 effectAllowed 不一致时浏览器会显示禁止图标 */
|
|
@@ -4949,7 +5256,8 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
4949
5256
|
发起的拖拽触发)。这里一旦 stopPropagation,宿主收不到 drop →
|
|
4950
5257
|
计数器永久卡住 → 遮罩常驻且界面没有任何退出入口。
|
|
4951
5258
|
标签/会话的正常拖拽照旧走下面的 preventDefault + stopPropagation。 */
|
|
4952
|
-
if (drag.sessionId === null && drag.tab === null) return;
|
|
5259
|
+
if (drag.sessionId === null && drag.tab === null) { if (window.__dsvDiagOn === true) console.warn("[split-view:diag] drop 放行:没识别出拖拽来源"); return; }
|
|
5260
|
+
if (window.__dsvDiagOn === true) console.warn("[split-view:diag] drop", { sessionId: drag.sessionId, tab: drag.tab === null ? null : drag.tab.tabId });
|
|
4953
5261
|
event.preventDefault();
|
|
4954
5262
|
event.stopPropagation();
|
|
4955
5263
|
if (drag.tab !== null && drag.tab.paneId === pane.id) {
|
|
@@ -5173,7 +5481,8 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
5173
5481
|
|
|
5174
5482
|
onPointerDownCapture: () => actions.focusPane(pane.id),
|
|
5175
5483
|
onDragOver: (event) => {
|
|
5176
|
-
if (drag.sessionId === null && drag.tab === null) return;
|
|
5484
|
+
if (drag.sessionId === null && drag.tab === null) { if (window.__dsvDiagOn === true) console.warn("[split-view:diag] drop 放行:没识别出拖拽来源"); return; }
|
|
5485
|
+
if (window.__dsvDiagOn === true) console.warn("[split-view:diag] drop", { sessionId: drag.sessionId, tab: drag.tab === null ? null : drag.tab.tabId });
|
|
5177
5486
|
/* 标签条那一条高度内的事件归 PaneHeader 管(它自己会 stopPropagation),
|
|
5178
5487
|
万一冒到这里,别再算一遍边缘——窄栏时会把「拖到标签上」误判成分栏。 */
|
|
5179
5488
|
if (event.target instanceof Element && event.target.closest(".dsv-paneheader") !== null) return;
|
|
@@ -5222,7 +5531,8 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
5222
5531
|
onDrop: (event) => {
|
|
5223
5532
|
/* 同 PaneHeader:外部文件拖拽一律放行,让宿主的 document 级 drop
|
|
5224
5533
|
收到并重置 dragDepth(否则「拖到此处添加」遮罩永久常驻)。 */
|
|
5225
|
-
if (drag.sessionId === null && drag.tab === null) return;
|
|
5534
|
+
if (drag.sessionId === null && drag.tab === null) { if (window.__dsvDiagOn === true) console.warn("[split-view:diag] drop 放行:没识别出拖拽来源"); return; }
|
|
5535
|
+
if (window.__dsvDiagOn === true) console.warn("[split-view:diag] drop", { sessionId: drag.sessionId, tab: drag.tab === null ? null : drag.tab.tabId });
|
|
5226
5536
|
event.preventDefault();
|
|
5227
5537
|
event.stopPropagation();
|
|
5228
5538
|
if (event.target instanceof Element && event.target.closest(".dsv-paneheader") !== null) return;
|
|
@@ -5903,6 +6213,35 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
5903
6213
|
};
|
|
5904
6214
|
}
|
|
5905
6215
|
|
|
6216
|
+
/**
|
|
6217
|
+
* 宿主的 `useSessions(selector)`:数据源是会话列表快照(宿主给每个条目注入的标准 prop)。
|
|
6218
|
+
*
|
|
6219
|
+
* 0.2.3 实测:agent-preset 标签、子智能体 lineage 两个组件第一行就调它,
|
|
6220
|
+
* 我们手搓的 props 里没有 → `TypeError: useSessions is not a function`
|
|
6221
|
+
* → 整颗条目被错误边界吞掉,界面上直接没有。这里补一个等价物。
|
|
6222
|
+
* 做成模块级单例:hook 的引用必须稳定,否则每次渲染都是新组件类型。
|
|
6223
|
+
*/
|
|
6224
|
+
let USE_SESSIONS = null;
|
|
6225
|
+
function makeSessionsHook() {
|
|
6226
|
+
if (USE_SESSIONS !== null) return USE_SESSIONS;
|
|
6227
|
+
try {
|
|
6228
|
+
const sessions = SERVICES.sessions ?? service("sessions");
|
|
6229
|
+
if (sessions === void 0 || sessions === null || sessions.list === void 0) return null;
|
|
6230
|
+
const list = sessions.list;
|
|
6231
|
+
USE_SESSIONS = function useSessions(selector) {
|
|
6232
|
+
const snapshot = react.useSyncExternalStore(
|
|
6233
|
+
(listener) => list.subscribe(listener),
|
|
6234
|
+
() => list.getSnapshot(),
|
|
6235
|
+
() => list.getSnapshot()
|
|
6236
|
+
);
|
|
6237
|
+
return typeof selector === "function" ? selector(snapshot) : snapshot;
|
|
6238
|
+
};
|
|
6239
|
+
} catch {
|
|
6240
|
+
return null;
|
|
6241
|
+
}
|
|
6242
|
+
return USE_SESSIONS;
|
|
6243
|
+
}
|
|
6244
|
+
|
|
5906
6245
|
/**
|
|
5907
6246
|
* 会话级的 useSession:宿主是把它塞在 SessionProvider 里给组件的,
|
|
5908
6247
|
* 我们不在那个 scope 里,所以自己造一个 —— 数据源是宿主的会话列表快照。
|
|
@@ -6062,10 +6401,8 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
6062
6401
|
console.warn("[split-view] setExpanded 失败:", error);
|
|
6063
6402
|
}
|
|
6064
6403
|
try {
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
if (value === true) panels.openRightbar?.(true, false);
|
|
6068
|
-
else panels.closeRightbar?.();
|
|
6404
|
+
if (value === true) openRightbarCompat(true, false);
|
|
6405
|
+
else closeRightbarCompat();
|
|
6069
6406
|
} catch (error) {
|
|
6070
6407
|
console.warn("[split-view] 右侧栏开合失败:", error);
|
|
6071
6408
|
}
|
|
@@ -6084,6 +6421,35 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
6084
6421
|
return true;
|
|
6085
6422
|
};
|
|
6086
6423
|
}
|
|
6424
|
+
/* ── 0.2.3 的补给:宿主给每个条目注入的一整套「标准 props」。
|
|
6425
|
+
我们手搓时缺哪一个,哪个条目就整格报错消失 —— 实测这一天之内
|
|
6426
|
+
掉了四颗:会话面板(session-panel)、定时任务(schedule-catalog)、
|
|
6427
|
+
子智能体面包屑(lineage)、智能体预设标签(agent-preset)。
|
|
6428
|
+
原则:能拿到真服务就用真的,拿不到就给一个**稳定的空实现**,
|
|
6429
|
+
宁可按钮能点、由宿主自己兜底,也不要整颗按钮凭空消失。 */
|
|
6430
|
+
if (typeof propsForComponent.useSessions !== "function") {
|
|
6431
|
+
const useSessions = makeSessionsHook();
|
|
6432
|
+
if (useSessions !== null) propsForComponent.useSessions = useSessions;
|
|
6433
|
+
}
|
|
6434
|
+
/* useAccess / useSessionAccess / useWorkspaceAccess(action) → boolean。
|
|
6435
|
+
拿不到权限模型时按「允许」处理(宿主点了之后自己会再判一次)。 */
|
|
6436
|
+
if (typeof propsForComponent.useAccess !== "function") propsForComponent.useAccess = () => true;
|
|
6437
|
+
if (typeof propsForComponent.useSessionAccess !== "function") propsForComponent.useSessionAccess = () => true;
|
|
6438
|
+
if (typeof propsForComponent.useWorkspaceAccess !== "function") propsForComponent.useWorkspaceAccess = () => true;
|
|
6439
|
+
/* 条目自己声明的子槽(会话面板开关就靠它渲染那颗「有后台任务」的蓝点)。
|
|
6440
|
+
⚠️ 宿主的 renderSlot 授权是**按条目绑定**的:拿别处的 renderSlot 渲这种
|
|
6441
|
+
子槽会抛 `slot '…' is not declared by this entry's children`,然后整格没了。
|
|
6442
|
+
这里改成:声明过就用我们自己的通用渲染器画,没声明就**安静返回 null**,
|
|
6443
|
+
一条异常都不往外抛。 */
|
|
6444
|
+
const childSlots = item.entry.options !== void 0 && item.entry.options !== null && item.entry.options.children !== void 0 && item.entry.options.children !== null ? item.entry.options.children : null;
|
|
6445
|
+
propsForComponent.renderSlot = (slotName) => {
|
|
6446
|
+
try {
|
|
6447
|
+
if (childSlots === null || Object.prototype.hasOwnProperty.call(childSlots, slotName) === false) return null;
|
|
6448
|
+
return h(SlotList, { key: slotName, slotName, sessionId, className: "dsv-slotrow", place: "child" });
|
|
6449
|
+
} catch {
|
|
6450
|
+
return null;
|
|
6451
|
+
}
|
|
6452
|
+
};
|
|
6087
6453
|
if (extra !== void 0) Object.assign(propsForComponent, extra);
|
|
6088
6454
|
return propsForComponent;
|
|
6089
6455
|
}, [item, sessionId, extra]);
|
|
@@ -6116,16 +6482,13 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
6116
6482
|
* layout 的 track;列宽 0 时面板挤在 0 宽轨道里 → 空白。
|
|
6117
6483
|
*/
|
|
6118
6484
|
try {
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
const ac = new AbortController();
|
|
6122
|
-
workspace.replaceMain(sessionId, ac.signal, "keep");
|
|
6123
|
-
}
|
|
6485
|
+
/* 0.2.2 用 replaceMain,0.2.3 已删(兼容层里自动选路)。 */
|
|
6486
|
+
openMainCompat(sessionId);
|
|
6124
6487
|
} catch (error) {
|
|
6125
6488
|
console.warn("[split-view] 诊断前切会话失败:", error);
|
|
6126
6489
|
}
|
|
6127
6490
|
try {
|
|
6128
|
-
|
|
6491
|
+
openRightbarCompat(true, false);
|
|
6129
6492
|
} catch (error) {
|
|
6130
6493
|
console.warn("[split-view] 诊断前开右栏失败:", error);
|
|
6131
6494
|
}
|
|
@@ -6262,7 +6625,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
6262
6625
|
setInterval(() => {
|
|
6263
6626
|
try {
|
|
6264
6627
|
const right = SERVICES.ctx?.get?.("sidebarRight");
|
|
6265
|
-
const panels =
|
|
6628
|
+
const panels = layoutPanels();
|
|
6266
6629
|
if (right === void 0 || right === null || panels === void 0 || panels === null) return;
|
|
6267
6630
|
/* 插件关掉后不再干预宿主的右栏 —— 它自己会管开合。 */
|
|
6268
6631
|
if (prefs.state.enabled !== true) return;
|
|
@@ -6270,7 +6633,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
6270
6633
|
const col = document.querySelector(".mP3x-q_rightbarCol");
|
|
6271
6634
|
if (col === null) return;
|
|
6272
6635
|
if (col.getBoundingClientRect().width > 1) return;
|
|
6273
|
-
|
|
6636
|
+
openRightbarCompat(true, false);
|
|
6274
6637
|
} catch {
|
|
6275
6638
|
/* 忽略 */
|
|
6276
6639
|
}
|
|
@@ -6282,8 +6645,15 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
6282
6645
|
const measure = react.useCallback(() => {
|
|
6283
6646
|
let next = false;
|
|
6284
6647
|
try {
|
|
6285
|
-
|
|
6286
|
-
|
|
6648
|
+
/* 优先问 sidebarRight 控制器:0.2.3 的 isExpanded() 读的是真实挂载面,
|
|
6649
|
+
比找那串随构建变化的哈希类名(.mP3x-q_rightbarCol)可靠。 */
|
|
6650
|
+
const right = SERVICES.ctx?.get?.("sidebarRight");
|
|
6651
|
+
if (right !== null && right !== void 0 && typeof right.isExpanded === "function") {
|
|
6652
|
+
next = right.isExpanded() === true;
|
|
6653
|
+
} else {
|
|
6654
|
+
const col = document.querySelector(".mP3x-q_rightbarCol");
|
|
6655
|
+
next = col !== null && col.getBoundingClientRect().width > 1;
|
|
6656
|
+
}
|
|
6287
6657
|
} catch {
|
|
6288
6658
|
next = false;
|
|
6289
6659
|
}
|
|
@@ -6313,29 +6683,52 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
6313
6683
|
"aria-pressed": open ? "true" : "false",
|
|
6314
6684
|
"data-dsv-rightbar-toggle": "1",
|
|
6315
6685
|
onClick: () => {
|
|
6316
|
-
|
|
6317
|
-
|
|
6686
|
+
/* 这颗按钮的语义从 0.2.2 起没变过:开/关**右侧边栏**(sidebarRight)。
|
|
6687
|
+
⚠️ 1.0.58 我一度把点击转交给 0.2.3 新增的「会话面板」开关(栏头那颗
|
|
6688
|
+
三横线)。用户实测:点最右这颗,结果去折叠了别的东西 —— 两个面板
|
|
6689
|
+
不是一回事(会话面板是浮在对话区右侧的小卡片,右侧边栏是带页签的栏)。
|
|
6690
|
+
这里回到正路:store 的 toggleExpanded 管状态,layout 的
|
|
6691
|
+
open/closeRightbar 管列宽轨道;两代接口由兼容层选路。 */
|
|
6318
6692
|
const isOpen = measure();
|
|
6319
6693
|
const next = !isOpen;
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
try {
|
|
6326
|
-
const right = SERVICES.ctx?.get?.("sidebarRight");
|
|
6327
|
-
if (right !== null && right !== void 0 && typeof right.isExpanded === "function" && typeof right.toggleExpanded === "function") {
|
|
6328
|
-
if ((right.isExpanded() === true) !== next) right.toggleExpanded();
|
|
6694
|
+
const right = (() => {
|
|
6695
|
+
try {
|
|
6696
|
+
return SERVICES.ctx?.get?.("sidebarRight");
|
|
6697
|
+
} catch {
|
|
6698
|
+
return void 0;
|
|
6329
6699
|
}
|
|
6330
|
-
}
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6700
|
+
})();
|
|
6701
|
+
const canToggle = right !== null && right !== void 0 && typeof right.isExpanded === "function" && typeof right.toggleExpanded === "function";
|
|
6702
|
+
/* ⚠️ 0.2.3 的顺序坑(用户实测「第一次点只有宽度、里面空白,要点第二次」):
|
|
6703
|
+
toggleExpanded() 内部用的是 mountedSurface(),右栏还没展开、没有挂载面时
|
|
6704
|
+
它直接空转。所以开要「先撑轨道、再补状态」,关要「先切状态、再收轨道」。 */
|
|
6705
|
+
if (next === true) {
|
|
6706
|
+
openRightbarCompat(true, false);
|
|
6707
|
+
if (canToggle === true) {
|
|
6708
|
+
let tries = 0;
|
|
6709
|
+
const ensure = () => {
|
|
6710
|
+
tries += 1;
|
|
6711
|
+
try {
|
|
6712
|
+
if (right.isExpanded() !== true) right.toggleExpanded();
|
|
6713
|
+
if (right.isExpanded() === true) return;
|
|
6714
|
+
} catch {
|
|
6715
|
+
/* 忽略 */
|
|
6716
|
+
}
|
|
6717
|
+
if (tries < 10) window.setTimeout(ensure, 60);
|
|
6718
|
+
};
|
|
6719
|
+
window.setTimeout(ensure, 30);
|
|
6720
|
+
}
|
|
6721
|
+
} else {
|
|
6722
|
+
if (canToggle === true) {
|
|
6723
|
+
try {
|
|
6724
|
+
right.toggleExpanded();
|
|
6725
|
+
} catch (error) {
|
|
6726
|
+
console.warn("[split-view] 右栏收起失败:", error);
|
|
6727
|
+
}
|
|
6728
|
+
}
|
|
6729
|
+
closeRightbarCompat();
|
|
6338
6730
|
}
|
|
6731
|
+
if (canToggle !== true && layoutPanels() === null) return;
|
|
6339
6732
|
setOpen(next);
|
|
6340
6733
|
window.setTimeout(measure, 500);
|
|
6341
6734
|
window.setTimeout(measure, 1400);
|
|
@@ -6582,6 +6975,19 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
6582
6975
|
/* ⚠️ 必须包 SessionProvider:不少 header 组件(尤其是第三方的)
|
|
6583
6976
|
在点击时读 React Context 拿「当前 session」,不在 provider 里就静默失效
|
|
6584
6977
|
——按钮画得出来、点了什么都不发生。这一层不能省。 */
|
|
6978
|
+
/* [diag] 宿主会话上下文到底有没有挂上(每栏每会话一次)。 */
|
|
6979
|
+
try {
|
|
6980
|
+
if (typeof window !== "undefined") {
|
|
6981
|
+
const key = "prov|" + String(sessionId) + "|" + (typeof SessionProvider);
|
|
6982
|
+
window.__dsvDiag = window.__dsvDiag ?? new Set();
|
|
6983
|
+
if (!window.__dsvDiag.has(key)) {
|
|
6984
|
+
window.__dsvDiag.add(key);
|
|
6985
|
+
if (window.__dsvDiagOn === true) console.warn("[split-view:diag] provider", { sessionId, provider: typeof SessionProvider, hasReference: reference !== void 0 });
|
|
6986
|
+
}
|
|
6987
|
+
}
|
|
6988
|
+
} catch {
|
|
6989
|
+
/* 忽略 */
|
|
6990
|
+
}
|
|
6585
6991
|
if (typeof SessionProvider === "function" && reference !== void 0) {
|
|
6586
6992
|
return h(SessionProvider, { session: reference }, inner);
|
|
6587
6993
|
}
|
|
@@ -8915,60 +9321,37 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
8915
9321
|
/* 防抖 120ms:拖标签 / 拖分隔条时焦点会高频跳变,只认最后一次。 */
|
|
8916
9322
|
st.timer = window.setTimeout(() => {
|
|
8917
9323
|
try {
|
|
8918
|
-
const workspace =
|
|
8919
|
-
if (workspace === void 0 || workspace === null
|
|
9324
|
+
const workspace = resolveWorkspaceService();
|
|
9325
|
+
if (workspace === void 0 || workspace === null) return;
|
|
9326
|
+
if (typeof workspace.replaceMain !== "function" && typeof workspace.openSession !== "function") return;
|
|
8920
9327
|
const cur = SERVICES.ctx?.get?.("uiSession")?.adapter?.current?.getSnapshot?.();
|
|
8921
9328
|
if (cur !== void 0 && cur !== null && cur.key === focusKey) {
|
|
8922
9329
|
st.done = focusKey;
|
|
8923
9330
|
return;
|
|
8924
9331
|
}
|
|
8925
9332
|
const col = document.querySelector(".mP3x-q_rightbarCol");
|
|
8926
|
-
|
|
9333
|
+
/* 优先问 sidebarRight:它才是右侧边栏的真正状态源。 */
|
|
9334
|
+
let wasOpen = false;
|
|
9335
|
+
try {
|
|
9336
|
+
const right = SERVICES.ctx?.get?.("sidebarRight");
|
|
9337
|
+
if (right !== null && right !== void 0 && typeof right.isExpanded === "function") {
|
|
9338
|
+
wasOpen = right.isExpanded() === true;
|
|
9339
|
+
} else {
|
|
9340
|
+
wasOpen = col !== null && col.getBoundingClientRect().width > 1;
|
|
9341
|
+
}
|
|
9342
|
+
} catch {
|
|
9343
|
+
wasOpen = col !== null && col.getBoundingClientRect().width > 1;
|
|
9344
|
+
}
|
|
8927
9345
|
/* 决策 2b 的兜底素材:切换**前**右栏是不是正开着一个会话相关内容。
|
|
8928
9346
|
记下来是为了「切到一个从没开过侧栏的会话」时,能沿用同一种类型,
|
|
8929
9347
|
而不是给用户一个空栏。 */
|
|
8930
|
-
const hadSessionScoped = col !== null && /Token
|
|
9348
|
+
const hadSessionScoped = col !== null && /Token 统计|缓存命中|子智能体|上下文|后台任务|工作目录/.test(col.innerText);
|
|
8931
9349
|
st.abort?.abort?.();
|
|
8932
9350
|
const ac = new AbortController();
|
|
8933
9351
|
st.abort = ac;
|
|
8934
|
-
|
|
9352
|
+
/* 0.2.2 replaceMain / 0.2.3 openSession,兼容层自己选路。 */
|
|
9353
|
+
if (openMainCompat(focusKey) !== true) return;
|
|
8935
9354
|
st.done = focusKey;
|
|
8936
|
-
/* 决策 3b:右栏保持展开,只换内容。
|
|
8937
|
-
目标会话自己的 layout.expanded 多半是 false(它从没开过右栏),
|
|
8938
|
-
宿主的 syncPresentation 会顺手把栏收起 —— 用户切个标签就看到
|
|
8939
|
-
「右栏突然消失」。这里把「开/关」这个用户动作和「显示谁的内容」
|
|
8940
|
-
解耦:同步后若发现被收起,补一次开。 */
|
|
8941
|
-
if (wasOpen === true && hadSessionScoped === true) {
|
|
8942
|
-
/* 决策 2b:宿主的页签本身就是 per-session 的(openTabs 每项带
|
|
8943
|
-
sessionId),所以切到一个从没开过侧栏的会话时,右栏会是空的。
|
|
8944
|
-
这时沿用「刚才在看同一类内容」的语义,替用户把它打开 ——
|
|
8945
|
-
跟「切换标签,侧栏就该刷新成对应标签的内容」是同一个意思。 */
|
|
8946
|
-
window.setTimeout(() => {
|
|
8947
|
-
try {
|
|
8948
|
-
if (document.querySelectorAll("[data-sidebar-right-tab]").length > 0) return;
|
|
8949
|
-
const pane = document.querySelector('.dsv-pane[data-focus="1"]') ?? document.querySelector(".dsv-pane");
|
|
8950
|
-
const btn = pane === null ? null : pane.querySelector(".dsv-hostbar [data-dsh-ctx-entry]");
|
|
8951
|
-
btn?.click?.();
|
|
8952
|
-
} catch {
|
|
8953
|
-
/* 忽略 */
|
|
8954
|
-
}
|
|
8955
|
-
}, 900);
|
|
8956
|
-
}
|
|
8957
|
-
if (wasOpen === true) {
|
|
8958
|
-
/* 无条件补开(openRightbar 幂等),而且打两拍:
|
|
8959
|
-
实测只打一拍(280ms)时,宿主收起动画还没结束、列宽仍在
|
|
8960
|
-
576→0 的路上,那次「width<=1 才补」判断为 false → 不补,
|
|
8961
|
-
结果切回原标签时右栏就真的关上了(实测 colW 576→0)。 */
|
|
8962
|
-
for (const delay of [280, 720]) {
|
|
8963
|
-
window.setTimeout(() => {
|
|
8964
|
-
try {
|
|
8965
|
-
SERVICES.layout?.panels?.openRightbar?.(true, false);
|
|
8966
|
-
} catch {
|
|
8967
|
-
/* 忽略 */
|
|
8968
|
-
}
|
|
8969
|
-
}, delay);
|
|
8970
|
-
}
|
|
8971
|
-
}
|
|
8972
9355
|
} catch (error) {
|
|
8973
9356
|
console.warn("[split-view] 同步焦点会话失败:", error);
|
|
8974
9357
|
}
|
|
@@ -9148,10 +9531,8 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
9148
9531
|
if (typeof keepSession === "string" && keepSession !== "") {
|
|
9149
9532
|
window.setTimeout(() => {
|
|
9150
9533
|
try {
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
workspace.replaceMain(keepSession, new AbortController().signal, "preserve");
|
|
9154
|
-
}
|
|
9534
|
+
/* 0.2.3 已删 replaceMain,兼容层走 openSession。 */
|
|
9535
|
+
openMainCompat(keepSession);
|
|
9155
9536
|
} catch {
|
|
9156
9537
|
/* 忽略 */
|
|
9157
9538
|
}
|
|
@@ -9229,21 +9610,241 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
9229
9610
|
const row = target.closest('[data-row-key^="session:"]');
|
|
9230
9611
|
if (row === null) return;
|
|
9231
9612
|
const key = row.getAttribute("data-row-key") ?? "";
|
|
9232
|
-
drag.sessionId = key.slice("session:".length);
|
|
9613
|
+
drag.sessionId = key.slice("session:".length); if (window.__dsvDiagOn === true) console.warn("[split-view:diag] dragstart 识别到会话", drag.sessionId);
|
|
9233
9614
|
drag.tab = null;
|
|
9615
|
+
drag.fromPointer = false;
|
|
9234
9616
|
setDragging(true);
|
|
9235
9617
|
};
|
|
9236
9618
|
const onDragEnd = () => {
|
|
9237
9619
|
drag.sessionId = null;
|
|
9238
9620
|
drag.tab = null;
|
|
9621
|
+
drag.fromPointer = false;
|
|
9239
9622
|
setDragging(false);
|
|
9240
9623
|
setHoverDrop(null);
|
|
9241
9624
|
};
|
|
9625
|
+
/* ⚠️ 兜底(0.2.3):别的插件/官方可能在**捕获阶段**先截走 dragstart
|
|
9626
|
+
(stopImmediatePropagation),我们收不到信号 → 这次拖拽被当成"外部拖拽"
|
|
9627
|
+
原样放行给官方,用户看到的就是「官方那个『在侧边栏打开』把落点抢了」。
|
|
9628
|
+
这里改成鼠标按下的那一刻就记下按的是哪一行会话,识别不再依赖 dragstart。 */
|
|
9629
|
+
const onPointerDown = (event) => {
|
|
9630
|
+
try {
|
|
9631
|
+
if (event.button !== 0) return;
|
|
9632
|
+
const target = event.target;
|
|
9633
|
+
if (!(target instanceof Element)) return;
|
|
9634
|
+
if (target.closest(".dsv-tab") !== null) return;
|
|
9635
|
+
const row = target.closest('[data-row-key^="session:"]');
|
|
9636
|
+
if (row === null) return;
|
|
9637
|
+
const key = row.getAttribute("data-row-key") ?? "";
|
|
9638
|
+
const id = key.slice("session:".length);
|
|
9639
|
+
if (id === "" || drag.sessionId !== null) return;
|
|
9640
|
+
drag.sessionId = id; if (window.__dsvDiagOn === true) console.warn("[split-view:diag] pointerdown 记住会话", id);
|
|
9641
|
+
drag.tab = null;
|
|
9642
|
+
drag.fromPointer = true;
|
|
9643
|
+
markSessionDrag(true);
|
|
9644
|
+
} catch {
|
|
9645
|
+
/* 忽略 */
|
|
9646
|
+
}
|
|
9647
|
+
};
|
|
9648
|
+
/* 只是单击(没有真的拖起来)就把标记清掉,别让下一次无关的拖拽误判。 */
|
|
9649
|
+
const onPointerUp = () => {
|
|
9650
|
+
if (drag.fromPointer !== true) return;
|
|
9651
|
+
drag.fromPointer = false;
|
|
9652
|
+
drag.sessionId = null;
|
|
9653
|
+
drag.tab = null;
|
|
9654
|
+
};
|
|
9655
|
+
/* ⚠️ 0.2.3:官方在拖会话时盖一层「在侧边栏打开」的预览,并在 document 上听事件,
|
|
9656
|
+
把我们的落点挡住、最后自己接手。这里在 **window 捕获阶段**(比 document 更早)
|
|
9657
|
+
截下整段拖拽:官方连事件都收不到(预览不出现),再往我们的栏补发同坐标的合成
|
|
9658
|
+
事件,让已有的 React 落点逻辑(边缘分栏 / 中间加标签)照原样跑。 */
|
|
9659
|
+
const synth = (type, paneEl, source) => {
|
|
9660
|
+
try {
|
|
9661
|
+
const echo = new DragEvent(type, {
|
|
9662
|
+
bubbles: true,
|
|
9663
|
+
cancelable: true,
|
|
9664
|
+
composed: true,
|
|
9665
|
+
clientX: source.clientX,
|
|
9666
|
+
clientY: source.clientY,
|
|
9667
|
+
dataTransfer: source.dataTransfer
|
|
9668
|
+
});
|
|
9669
|
+
Object.defineProperty(echo, "__dsvSynth", { value: true });
|
|
9670
|
+
paneEl.dispatchEvent(echo);
|
|
9671
|
+
} catch {
|
|
9672
|
+
/* 忽略 */
|
|
9673
|
+
}
|
|
9674
|
+
};
|
|
9675
|
+
const paneAt = (event) => {
|
|
9676
|
+
try {
|
|
9677
|
+
const el = document.elementFromPoint(event.clientX, event.clientY);
|
|
9678
|
+
return el instanceof Element ? el.closest(".dsv-pane[data-pane-id]") : null;
|
|
9679
|
+
} catch {
|
|
9680
|
+
return null;
|
|
9681
|
+
}
|
|
9682
|
+
};
|
|
9683
|
+
/* [diag-overlay] 抓「官方那层预览」的现行:拖拽经过时,找出页面上
|
|
9684
|
+
带虚线描边、且尺寸够大的元素,把它的 class / data 属性 / 文本打出来。
|
|
9685
|
+
一次拖拽只打一次,避免刷屏。 */
|
|
9686
|
+
let overlayProbed = false;
|
|
9687
|
+
const probeOverlay = () => {
|
|
9688
|
+
if (overlayProbed === true) return;
|
|
9689
|
+
try {
|
|
9690
|
+
const hits = [];
|
|
9691
|
+
for (const el of document.body.querySelectorAll("*")) {
|
|
9692
|
+
const cs = getComputedStyle(el);
|
|
9693
|
+
const dashed = cs.outlineStyle === "dashed" || cs.borderStyle.indexOf("dashed") >= 0;
|
|
9694
|
+
if (dashed === false) continue;
|
|
9695
|
+
const rect = el.getBoundingClientRect();
|
|
9696
|
+
if (rect.width < 300 || rect.height < 200) continue;
|
|
9697
|
+
const attrs = [];
|
|
9698
|
+
for (const attr of el.attributes) {
|
|
9699
|
+
if (attr.name.indexOf("data-") === 0 || attr.name === "class" || attr.name === "id") attrs.push(attr.name + "=" + String(attr.value).slice(0, 120));
|
|
9700
|
+
}
|
|
9701
|
+
hits.push({ tag: el.tagName, attrs: attrs.slice(0, 8), text: String(el.innerText ?? "").slice(0, 40) });
|
|
9702
|
+
if (hits.length >= 3) break;
|
|
9703
|
+
}
|
|
9704
|
+
if (hits.length > 0) {
|
|
9705
|
+
overlayProbed = true;
|
|
9706
|
+
/* 宿主 0.2.3 的会话拖放区(SessionDropZone,position:fixed / z-index:72)
|
|
9707
|
+
在 dragenter 就把「在侧边栏打开」卡片挂出来,盖住我们的落点提示。
|
|
9708
|
+
我们接管这次拖拽时直接把它藏掉;dragend 之后宿主自己会卸掉。 */
|
|
9709
|
+
|
|
9710
|
+
if (window.__dsvDiagOn === true) console.warn("[split-view:diag] overlay " + JSON.stringify(hits).slice(0, 1200));
|
|
9711
|
+
}
|
|
9712
|
+
} catch {
|
|
9713
|
+
/* 忽略 */
|
|
9714
|
+
}
|
|
9715
|
+
}; /* 府主 0.2.3 的会话拖放区(SessionDropZone)是 React 每帧重画出来的,
|
|
9716
|
+
藏一次不够 —— 每次 dragover 都要再藏一次。同时把我们自己的拖拽视觉
|
|
9717
|
+
(分隔符高亮/加宽、栏的落点描边)在拖拽结束时清干净,避免"分隔符一直是
|
|
9718
|
+
高亮而且很宽"这种残留。 */
|
|
9719
|
+
const hideHostZone = () => {
|
|
9720
|
+
try {
|
|
9721
|
+
for (const node of document.querySelectorAll("[class*=fLOeka_], .fLOeka_zone")) {
|
|
9722
|
+
if (node.style.display !== "none") node.style.display = "none";
|
|
9723
|
+
}
|
|
9724
|
+
} catch {
|
|
9725
|
+
/* 忽略 */
|
|
9726
|
+
}
|
|
9727
|
+
};
|
|
9728
|
+
const clearDragVisuals = () => {
|
|
9729
|
+
try {
|
|
9730
|
+
for (const node of document.querySelectorAll(".dsv-divider, .dsv-pane")) {
|
|
9731
|
+
try {
|
|
9732
|
+
node.dispatchEvent(new DragEvent("dragleave", { bubbles: true, cancelable: true }));
|
|
9733
|
+
} catch {
|
|
9734
|
+
/* 忽略 */
|
|
9735
|
+
}
|
|
9736
|
+
node.removeAttribute("data-drop");
|
|
9737
|
+
node.removeAttribute("data-drop-target");
|
|
9738
|
+
node.removeAttribute("data-drop-side");
|
|
9739
|
+
node.style.removeProperty("--dsv-drop-w");
|
|
9740
|
+
}
|
|
9741
|
+
const root = document.querySelector(".dsv-root");
|
|
9742
|
+
if (root !== null) root.removeAttribute("data-drop-armed");
|
|
9743
|
+
} catch {
|
|
9744
|
+
/* 忽略 */
|
|
9745
|
+
}
|
|
9746
|
+
}; const onWinOver = (event) => {
|
|
9747
|
+
if (drag.sessionId === null || event.__dsvSynth === true) return;
|
|
9748
|
+
/* ⚠️ 只要是我们认出的会话拖拽,就**整窗**拦下:用户在"还没进入栏里"
|
|
9749
|
+
那一段(侧栏边缘、栏间空隙)时官方也会挂上它那层蒙版 —— 只拦栏内
|
|
9750
|
+
不够。这里先无条件 preventDefault + stopPropagation,官方收不到
|
|
9751
|
+
事件自然不会武装;指针在栏上时再补发合成事件给我们的落点逻辑。 */
|
|
9752
|
+
/* ⚠️ 探针很重:要全量扫 DOM 并逐个算 computedStyle。它只能在显式打开
|
|
9753
|
+
诊断时跑(Console 里 window.__dsvDiagOn = true),否则第一次拖拽会明显卡顿
|
|
9754
|
+
——「刚开始拖像卡死」就是这个原因。隐藏官方那层已经由 CSS 负责,不需要它。 */
|
|
9755
|
+
if (typeof window !== "undefined" && window.__dsvDiagOn === true) probeOverlay();
|
|
9756
|
+
hideHostZone();
|
|
9757
|
+
event.preventDefault();
|
|
9758
|
+
event.stopPropagation();
|
|
9759
|
+
const paneEl = paneAt(event);
|
|
9760
|
+
if (paneEl === null) return;
|
|
9761
|
+
synth("dragover", paneEl, event);
|
|
9762
|
+
};
|
|
9763
|
+
const onWinDrop = (event) => {
|
|
9764
|
+
if (drag.sessionId === null || event.__dsvSynth === true) return;
|
|
9765
|
+
event.preventDefault();
|
|
9766
|
+
event.stopPropagation();
|
|
9767
|
+
const paneEl = paneAt(event);
|
|
9768
|
+
if (paneEl === null) {
|
|
9769
|
+
clearDragVisuals();
|
|
9770
|
+
return;
|
|
9771
|
+
}
|
|
9772
|
+
synth("drop", paneEl, event);
|
|
9773
|
+
clearDragVisuals();
|
|
9774
|
+
}; /* 官方那层是 React 在 dragstart 那一刻就挂出来的,靠 JS 每帧去藏总要慢一帧
|
|
9775
|
+
(用户看到"闪一下")。改成一条**在渲染前就生效**的 CSS:只要我们还处在
|
|
9776
|
+
会话拖拽中(<html data-dsv-session-drag="1">),宿主 SessioDropZone 一律不显示。
|
|
9777
|
+
类名是宿主构建哈希(fLOeka),换了版本会失效 —— 失效时只是退回"闪一下",
|
|
9778
|
+
不会变坏。 */
|
|
9779
|
+
const ensureDragHideStyle = () => {
|
|
9780
|
+
if (hostPurged === true) return;
|
|
9781
|
+
try {
|
|
9782
|
+
if (document.getElementById("dsv-drag-hide") !== null) return;
|
|
9783
|
+
const style = document.createElement("style");
|
|
9784
|
+
style.id = "dsv-drag-hide";
|
|
9785
|
+
style.textContent = 'html[data-dsv-session-drag="1"] [class*="fLOeka_"],html[data-dsv-session-drag="1"] .fLOeka_zone{display:none!important}';
|
|
9786
|
+
document.head.appendChild(style);
|
|
9787
|
+
} catch {
|
|
9788
|
+
/* 忽略 */
|
|
9789
|
+
}
|
|
9790
|
+
};
|
|
9791
|
+
const markSessionDrag = (on) => {
|
|
9792
|
+
try {
|
|
9793
|
+
if (on === true) document.documentElement.setAttribute("data-dsv-session-drag", "1");
|
|
9794
|
+
else document.documentElement.removeAttribute("data-dsv-session-drag");
|
|
9795
|
+
} catch {
|
|
9796
|
+
/* 忽略 */
|
|
9797
|
+
}
|
|
9798
|
+
}; /* 我们补发的合成事件是给 React 的(React 在 #root 上监听)。它冒泡到 body
|
|
9799
|
+
之后还会继续上传给宿主的 document 级监听器 —— 宿主收到就闪一下它那层
|
|
9800
|
+
蒙版,这就是「进入显示区时突然闪一下」。在 body 的**冒泡阶段**(React 已
|
|
9801
|
+
处理完、document 还没收到)把它截住。 */
|
|
9802
|
+
const guardSynth = (event) => {
|
|
9803
|
+
if (event.__dsvSynth === true) event.stopPropagation();
|
|
9804
|
+
};
|
|
9805
|
+
document.body.addEventListener("dragover", guardSynth, false);
|
|
9806
|
+
document.body.addEventListener("drop", guardSynth, false); ensureDragHideStyle();
|
|
9807
|
+
/* 挂载时先清一次:上一次拖拽留下的分隔符高亮/加宽不会自己消失。 */
|
|
9808
|
+
hideHostZone();
|
|
9809
|
+
clearDragVisuals();
|
|
9242
9810
|
document.addEventListener("dragstart", onDragStart, true);
|
|
9243
9811
|
document.addEventListener("dragend", onDragEnd, true);
|
|
9812
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
9813
|
+
document.addEventListener("pointerup", onPointerUp, true);
|
|
9814
|
+
const clearMark = () => markSessionDrag(false);
|
|
9815
|
+
window.addEventListener("dragend", clearMark, true);
|
|
9816
|
+
window.addEventListener("drop", clearMark, true);
|
|
9817
|
+
window.addEventListener("dragenter", onWinOver, true);
|
|
9818
|
+
/* 自愈看门狗:拖拽如果在窗口外结束(或 dragend 没发),分隔条的「预览中」
|
|
9819
|
+
状态会一直留在 React 里,表现就是「高亮 + 很宽」再也不消失。
|
|
9820
|
+
这里在**没有拖拽进行中**时定期检查,一旦发现残留就清一次 ——
|
|
9821
|
+
React 状态没变就不会重新画回来,所以清掉即稳定。 */
|
|
9822
|
+
const healStuckDragUi = () => {
|
|
9823
|
+
try {
|
|
9824
|
+
if (drag.sessionId !== null || drag.tab !== null) return;
|
|
9825
|
+
const stuck = document.querySelector('.dsv-divider[data-drop="1"], .dsv-pane[data-drop="1"], .dsv-pane[data-drop-target="1"], .dsv-pane[data-drop-side]');
|
|
9826
|
+
if (stuck === null) return;
|
|
9827
|
+
markSessionDrag(false);
|
|
9828
|
+
clearDragVisuals();
|
|
9829
|
+
} catch {
|
|
9830
|
+
/* 忽略 */
|
|
9831
|
+
}
|
|
9832
|
+
};
|
|
9833
|
+
const healTimer = window.setInterval(healStuckDragUi, 500); window.addEventListener("dragover", onWinOver, true);
|
|
9834
|
+
window.addEventListener("drop", onWinDrop, true);
|
|
9244
9835
|
return () => {
|
|
9245
9836
|
document.removeEventListener("dragstart", onDragStart, true);
|
|
9246
9837
|
document.removeEventListener("dragend", onDragEnd, true);
|
|
9838
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
9839
|
+
document.removeEventListener("pointerup", onPointerUp, true);
|
|
9840
|
+
document.body.removeEventListener("dragover", guardSynth, false);
|
|
9841
|
+
document.body.removeEventListener("drop", guardSynth, false);
|
|
9842
|
+
window.removeEventListener("dragend", clearMark, true);
|
|
9843
|
+
window.removeEventListener("drop", clearMark, true);
|
|
9844
|
+
window.removeEventListener("dragenter", onWinOver, true);
|
|
9845
|
+
window.clearInterval(healTimer);
|
|
9846
|
+
window.removeEventListener("dragover", onWinOver, true);
|
|
9847
|
+
window.removeEventListener("drop", onWinDrop, true);
|
|
9247
9848
|
};
|
|
9248
9849
|
}, []);
|
|
9249
9850
|
|
|
@@ -9311,11 +9912,166 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
9311
9912
|
if (event.relatedTarget === null) disarm();
|
|
9312
9913
|
};
|
|
9313
9914
|
const onWindowBlur = () => disarm();
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9915
|
+
/* ⚠️ 0.2.3:官方在拖会话时盖一层「在侧边栏打开」的预览,并在 document 上听事件,
|
|
9916
|
+
把我们的落点挡住、最后自己接手。这里在 **window 捕获阶段**(比 document 更早)
|
|
9917
|
+
截下整段拖拽:官方连事件都收不到(预览不出现),再往我们的栏补发同坐标的合成
|
|
9918
|
+
事件,让已有的 React 落点逻辑(边缘分栏 / 中间加标签)照原样跑。 */
|
|
9919
|
+
const synth = (type, paneEl, source) => {
|
|
9920
|
+
try {
|
|
9921
|
+
const echo = new DragEvent(type, {
|
|
9922
|
+
bubbles: true,
|
|
9923
|
+
cancelable: true,
|
|
9924
|
+
composed: true,
|
|
9925
|
+
clientX: source.clientX,
|
|
9926
|
+
clientY: source.clientY,
|
|
9927
|
+
dataTransfer: source.dataTransfer
|
|
9928
|
+
});
|
|
9929
|
+
Object.defineProperty(echo, "__dsvSynth", { value: true });
|
|
9930
|
+
paneEl.dispatchEvent(echo);
|
|
9931
|
+
} catch {
|
|
9932
|
+
/* 忽略 */
|
|
9933
|
+
}
|
|
9934
|
+
};
|
|
9935
|
+
const paneAt = (event) => {
|
|
9936
|
+
try {
|
|
9937
|
+
const el = document.elementFromPoint(event.clientX, event.clientY);
|
|
9938
|
+
return el instanceof Element ? el.closest(".dsv-pane[data-pane-id]") : null;
|
|
9939
|
+
} catch {
|
|
9940
|
+
return null;
|
|
9941
|
+
}
|
|
9942
|
+
};
|
|
9943
|
+
/* [diag-overlay] 抓「官方那层预览」的现行:拖拽经过时,找出页面上
|
|
9944
|
+
带虚线描边、且尺寸够大的元素,把它的 class / data 属性 / 文本打出来。
|
|
9945
|
+
一次拖拽只打一次,避免刷屏。 */
|
|
9946
|
+
let overlayProbed = false;
|
|
9947
|
+
const probeOverlay = () => {
|
|
9948
|
+
if (overlayProbed === true) return;
|
|
9949
|
+
try {
|
|
9950
|
+
const hits = [];
|
|
9951
|
+
for (const el of document.body.querySelectorAll("*")) {
|
|
9952
|
+
const cs = getComputedStyle(el);
|
|
9953
|
+
const dashed = cs.outlineStyle === "dashed" || cs.borderStyle.indexOf("dashed") >= 0;
|
|
9954
|
+
if (dashed === false) continue;
|
|
9955
|
+
const rect = el.getBoundingClientRect();
|
|
9956
|
+
if (rect.width < 300 || rect.height < 200) continue;
|
|
9957
|
+
const attrs = [];
|
|
9958
|
+
for (const attr of el.attributes) {
|
|
9959
|
+
if (attr.name.indexOf("data-") === 0 || attr.name === "class" || attr.name === "id") attrs.push(attr.name + "=" + String(attr.value).slice(0, 120));
|
|
9960
|
+
}
|
|
9961
|
+
hits.push({ tag: el.tagName, attrs: attrs.slice(0, 8), text: String(el.innerText ?? "").slice(0, 40) });
|
|
9962
|
+
if (hits.length >= 3) break;
|
|
9963
|
+
}
|
|
9964
|
+
if (hits.length > 0) {
|
|
9965
|
+
overlayProbed = true;
|
|
9966
|
+
/* 宿主 0.2.3 的会话拖放区(SessionDropZone,position:fixed / z-index:72)
|
|
9967
|
+
在 dragenter 就把「在侧边栏打开」卡片挂出来,盖住我们的落点提示。
|
|
9968
|
+
我们接管这次拖拽时直接把它藏掉;dragend 之后宿主自己会卸掉。 */
|
|
9969
|
+
|
|
9970
|
+
if (window.__dsvDiagOn === true) console.warn("[split-view:diag] overlay " + JSON.stringify(hits).slice(0, 1200));
|
|
9971
|
+
}
|
|
9972
|
+
} catch {
|
|
9973
|
+
/* 忽略 */
|
|
9974
|
+
}
|
|
9975
|
+
}; /* 府主 0.2.3 的会话拖放区(SessionDropZone)是 React 每帧重画出来的,
|
|
9976
|
+
藏一次不够 —— 每次 dragover 都要再藏一次。同时把我们自己的拖拽视觉
|
|
9977
|
+
(分隔符高亮/加宽、栏的落点描边)在拖拽结束时清干净,避免"分隔符一直是
|
|
9978
|
+
高亮而且很宽"这种残留。 */
|
|
9979
|
+
const hideHostZone = () => {
|
|
9980
|
+
try {
|
|
9981
|
+
for (const node of document.querySelectorAll("[class*=fLOeka_], .fLOeka_zone")) {
|
|
9982
|
+
if (node.style.display !== "none") node.style.display = "none";
|
|
9983
|
+
}
|
|
9984
|
+
} catch {
|
|
9985
|
+
/* 忽略 */
|
|
9986
|
+
}
|
|
9987
|
+
};
|
|
9988
|
+
const clearDragVisuals = () => {
|
|
9989
|
+
try {
|
|
9990
|
+
for (const node of document.querySelectorAll(".dsv-divider, .dsv-pane")) {
|
|
9991
|
+
try {
|
|
9992
|
+
node.dispatchEvent(new DragEvent("dragleave", { bubbles: true, cancelable: true }));
|
|
9993
|
+
} catch {
|
|
9994
|
+
/* 忽略 */
|
|
9995
|
+
}
|
|
9996
|
+
node.removeAttribute("data-drop");
|
|
9997
|
+
node.removeAttribute("data-drop-target");
|
|
9998
|
+
node.removeAttribute("data-drop-side");
|
|
9999
|
+
node.style.removeProperty("--dsv-drop-w");
|
|
10000
|
+
}
|
|
10001
|
+
const root = document.querySelector(".dsv-root");
|
|
10002
|
+
if (root !== null) root.removeAttribute("data-drop-armed");
|
|
10003
|
+
} catch {
|
|
10004
|
+
/* 忽略 */
|
|
10005
|
+
}
|
|
10006
|
+
}; const onWinOver = (event) => {
|
|
10007
|
+
if (drag.sessionId === null || event.__dsvSynth === true) return;
|
|
10008
|
+
/* ⚠️ 只要是我们认出的会话拖拽,就**整窗**拦下:用户在"还没进入栏里"
|
|
10009
|
+
那一段(侧栏边缘、栏间空隙)时官方也会挂上它那层蒙版 —— 只拦栏内
|
|
10010
|
+
不够。这里先无条件 preventDefault + stopPropagation,官方收不到
|
|
10011
|
+
事件自然不会武装;指针在栏上时再补发合成事件给我们的落点逻辑。 */
|
|
10012
|
+
/* ⚠️ 探针很重:要全量扫 DOM 并逐个算 computedStyle。它只能在显式打开
|
|
10013
|
+
诊断时跑(Console 里 window.__dsvDiagOn = true),否则第一次拖拽会明显卡顿
|
|
10014
|
+
——「刚开始拖像卡死」就是这个原因。隐藏官方那层已经由 CSS 负责,不需要它。 */
|
|
10015
|
+
if (typeof window !== "undefined" && window.__dsvDiagOn === true) probeOverlay();
|
|
10016
|
+
hideHostZone();
|
|
10017
|
+
event.preventDefault();
|
|
10018
|
+
event.stopPropagation();
|
|
10019
|
+
const paneEl = paneAt(event);
|
|
10020
|
+
if (paneEl === null) return;
|
|
10021
|
+
synth("dragover", paneEl, event);
|
|
10022
|
+
};
|
|
10023
|
+
const onWinDrop = (event) => {
|
|
10024
|
+
if (drag.sessionId === null || event.__dsvSynth === true) return;
|
|
10025
|
+
event.preventDefault();
|
|
10026
|
+
event.stopPropagation();
|
|
10027
|
+
const paneEl = paneAt(event);
|
|
10028
|
+
if (paneEl === null) {
|
|
10029
|
+
clearDragVisuals();
|
|
10030
|
+
return;
|
|
10031
|
+
}
|
|
10032
|
+
synth("drop", paneEl, event);
|
|
10033
|
+
clearDragVisuals();
|
|
10034
|
+
}; /* 官方那层是 React 在 dragstart 那一刻就挂出来的,靠 JS 每帧去藏总要慢一帧
|
|
10035
|
+
(用户看到"闪一下")。改成一条**在渲染前就生效**的 CSS:只要我们还处在
|
|
10036
|
+
会话拖拽中(<html data-dsv-session-drag="1">),宿主 SessioDropZone 一律不显示。
|
|
10037
|
+
类名是宿主构建哈希(fLOeka),换了版本会失效 —— 失效时只是退回"闪一下",
|
|
10038
|
+
不会变坏。 */
|
|
10039
|
+
const ensureDragHideStyle = () => {
|
|
10040
|
+
if (hostPurged === true) return;
|
|
10041
|
+
try {
|
|
10042
|
+
if (document.getElementById("dsv-drag-hide") !== null) return;
|
|
10043
|
+
const style = document.createElement("style");
|
|
10044
|
+
style.id = "dsv-drag-hide";
|
|
10045
|
+
style.textContent = 'html[data-dsv-session-drag="1"] [class*="fLOeka_"],html[data-dsv-session-drag="1"] .fLOeka_zone{display:none!important}';
|
|
10046
|
+
document.head.appendChild(style);
|
|
10047
|
+
} catch {
|
|
10048
|
+
/* 忽略 */
|
|
10049
|
+
}
|
|
10050
|
+
};
|
|
10051
|
+
const markSessionDrag = (on) => {
|
|
10052
|
+
try {
|
|
10053
|
+
if (on === true) document.documentElement.setAttribute("data-dsv-session-drag", "1");
|
|
10054
|
+
else document.documentElement.removeAttribute("data-dsv-session-drag");
|
|
10055
|
+
} catch {
|
|
10056
|
+
/* 忽略 */
|
|
10057
|
+
}
|
|
10058
|
+
}; /* 我们补发的合成事件是给 React 的(React 在 #root 上监听)。它冒泡到 body
|
|
10059
|
+
之后还会继续上传给宿主的 document 级监听器 —— 宿主收到就闪一下它那层
|
|
10060
|
+
蒙版,这就是「进入显示区时突然闪一下」。在 body 的**冒泡阶段**(React 已
|
|
10061
|
+
处理完、document 还没收到)把它截住。 */
|
|
10062
|
+
const guardSynth = (event) => {
|
|
10063
|
+
if (event.__dsvSynth === true) event.stopPropagation();
|
|
10064
|
+
};
|
|
10065
|
+
document.body.addEventListener("dragover", guardSynth, false);
|
|
10066
|
+
document.body.addEventListener("drop", guardSynth, false); ensureDragHideStyle();
|
|
10067
|
+
/* 挂载时先清一次:上一次拖拽留下的分隔符高亮/加宽不会自己消失。 */
|
|
10068
|
+
hideHostZone();
|
|
10069
|
+
clearDragVisuals();
|
|
10070
|
+
document.addEventListener("dragstart", onDragStart, true);
|
|
10071
|
+
document.addEventListener("dragenter", onDragEnter, true);
|
|
10072
|
+
document.addEventListener("dragover", onDragOver, true);
|
|
10073
|
+
document.addEventListener("drop", onDrop, true);
|
|
10074
|
+
document.addEventListener("dragend", onDragEnd, true);
|
|
9319
10075
|
document.addEventListener("dragleave", onDragLeave, true);
|
|
9320
10076
|
window.addEventListener("blur", onWindowBlur);
|
|
9321
10077
|
return () => {
|
|
@@ -9878,6 +10634,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
9878
10634
|
return ctx.effect(() => {
|
|
9879
10635
|
let disposed = false;
|
|
9880
10636
|
let timer = null;
|
|
10637
|
+
let tries = 0;
|
|
9881
10638
|
const undos = [];
|
|
9882
10639
|
|
|
9883
10640
|
const capture = (value) => {
|
|
@@ -9928,11 +10685,19 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
9928
10685
|
return;
|
|
9929
10686
|
}
|
|
9930
10687
|
const counter = { missing: 0 };
|
|
9931
|
-
|
|
10688
|
+
/* 0.2.3 把建会话入口换成了 connectWorkspace / startSession(createNamed、
|
|
10689
|
+
createInWorkspace、replaceMain 三个都删了)。名字一起挂上:哪一代有就钩哪一代。
|
|
10690
|
+
connectWorkspace 返回 Promise<SessionId>,capture() 会解 thenable 拿到 id。 */
|
|
10691
|
+
for (const name of ["createNamed", "createInWorkspace", "replaceMain", "connectWorkspace", "startSession"]) {
|
|
9932
10692
|
hookInto(workspace, name, undos, counter);
|
|
9933
10693
|
}
|
|
9934
10694
|
if (sessions !== void 0) hookInto(sessions, "create", undos, counter);
|
|
9935
|
-
|
|
10695
|
+
/* ⚠️ 以前是「缺一个就一直重试」,宿主删接口之后变成每 300ms 重试到天荒地老。
|
|
10696
|
+
改成最多 20 次(约 6s):够等宿主服务就绪,又不会常驻空转。 */
|
|
10697
|
+
if (counter.missing > 0 && tries < 20) {
|
|
10698
|
+
tries += 1;
|
|
10699
|
+
timer = setTimeout(tryInstall, 300);
|
|
10700
|
+
}
|
|
9936
10701
|
};
|
|
9937
10702
|
|
|
9938
10703
|
tryInstall();
|
|
@@ -10176,6 +10941,486 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
10176
10941
|
applyLineVars();
|
|
10177
10942
|
return () => clearAllDsvState();
|
|
10178
10943
|
}, "dsh-split-view: line color vars");
|
|
10944
|
+
/* 侧栏样式的「存活心跳」。
|
|
10945
|
+
插件被宿主插件管理禁用时,客户端模块不一定走卸载清理,标记会留在宿主会话行上
|
|
10946
|
+
(用户实测:竖条还在)。这里每 700ms 给 <html> 打一次 data-dsv-alive,
|
|
10947
|
+
并挂一个 1.6s 的定时器把它摘掉 —— 插件一停就没有代码续期,属性自然消失,
|
|
10948
|
+
CSS 里 html:not([data-dsv-alive]) 那组规则随即把行样式还原成官方外观。
|
|
10949
|
+
⚠️ 不要用「工作区是否可见」判断插件死活:打开插件管理页时工作区本来就被切走,
|
|
10950
|
+
那样会误清,实测把侧栏的整套渲染都清没了。 */
|
|
10951
|
+
ctx.effect(() => {
|
|
10952
|
+
let expire = 0;
|
|
10953
|
+
const beat = () => {
|
|
10954
|
+
/* 已判定禁用:不要再续期存活标记,否则 purge 摘掉后 700ms 又被打回来。 */
|
|
10955
|
+
if (hostPurged === true) return;
|
|
10956
|
+
try {
|
|
10957
|
+
document.documentElement.setAttribute("data-dsv-alive", "1");
|
|
10958
|
+
if (expire !== 0) window.clearTimeout(expire);
|
|
10959
|
+
expire = window.setTimeout(() => {
|
|
10960
|
+
try {
|
|
10961
|
+
document.documentElement.removeAttribute("data-dsv-alive");
|
|
10962
|
+
} catch {
|
|
10963
|
+
/* 忽略 */
|
|
10964
|
+
}
|
|
10965
|
+
}, 1600);
|
|
10966
|
+
} catch {
|
|
10967
|
+
/* 忽略 */
|
|
10968
|
+
}
|
|
10969
|
+
};
|
|
10970
|
+
beat();
|
|
10971
|
+
const interval = window.setInterval(beat, 700);
|
|
10972
|
+
return () => {
|
|
10973
|
+
window.clearInterval(interval);
|
|
10974
|
+
if (expire !== 0) window.clearTimeout(expire);
|
|
10975
|
+
try {
|
|
10976
|
+
document.documentElement.removeAttribute("data-dsv-alive");
|
|
10977
|
+
} catch {
|
|
10978
|
+
/* 忽略 */
|
|
10979
|
+
}
|
|
10980
|
+
};
|
|
10981
|
+
}, "dsh-split-view: sidebar styling heartbeat");
|
|
10982
|
+
|
|
10983
|
+
/* 宿主插件管理里「禁用」→ 页面痕迹立刻自清(不等用户 Ctrl+R)。
|
|
10984
|
+
0.2.3 实测:管理器禁用只停宿主入口,已经注入页面的客户端代码不卸载、也收不到通知。
|
|
10985
|
+
唯一可靠的存活信号是**本插件自己的宿主半身**:lib/index.js 启用时注册
|
|
10986
|
+
/dsh-multipane/status,禁用时随 ctx.effect 一起注销 —— 路由消失就说明被禁用了。
|
|
10987
|
+
先确认它真的答过一次(everSeen)再认失败:没有 webServer 的环境永远不会有第一次成功,
|
|
10988
|
+
也就永远不会误清正常使用中的界面。 */
|
|
10989
|
+
ctx.effect(() => {
|
|
10990
|
+
/* watch = 还活着、正常监听;purged = 已判定被禁用并清场,只等宿主半身回来。 */
|
|
10991
|
+
let phase = "watch";
|
|
10992
|
+
let everSeen = false;
|
|
10993
|
+
let misses = 0;
|
|
10994
|
+
let hits = 0;
|
|
10995
|
+
let stopped = false;
|
|
10996
|
+
let timer = 0;
|
|
10997
|
+
let graphTimer = 0;
|
|
10998
|
+
let lastStatus = null;
|
|
10999
|
+
try {
|
|
11000
|
+
globalThis.__dsvLastStatus = null;
|
|
11001
|
+
} catch {
|
|
11002
|
+
/* 忽略 */
|
|
11003
|
+
}
|
|
11004
|
+
const purge = () => {
|
|
11005
|
+
/* 先落闸,再清场:700ms 心跳和 prefs 订阅都可能在同一拍里抢着补样式/补标记。 */
|
|
11006
|
+
hostPurged = true;
|
|
11007
|
+
try {
|
|
11008
|
+
console.info("[split-view] host says disabled — purging page traces");
|
|
11009
|
+
} catch {
|
|
11010
|
+
/* 忽略 */
|
|
11011
|
+
}
|
|
11012
|
+
try {
|
|
11013
|
+
if (globalThis.__dsvHostWatchdog !== void 0) {
|
|
11014
|
+
window.clearInterval(globalThis.__dsvHostWatchdog);
|
|
11015
|
+
globalThis.__dsvHostWatchdog = void 0;
|
|
11016
|
+
}
|
|
11017
|
+
} catch {
|
|
11018
|
+
/* 忽略 */
|
|
11019
|
+
}
|
|
11020
|
+
/* 留一份"确实清过场"的取证:宿主 dispose 掉客户端上下文时,诊断心跳也停了,
|
|
11021
|
+
没有这一条,事后只能看到最后一份"还没清"的快照。sendBeacon 不等待响应,
|
|
11022
|
+
上下文正在拆也能发出去。 */
|
|
11023
|
+
try {
|
|
11024
|
+
const note = JSON.stringify({
|
|
11025
|
+
at: new Date().toISOString(),
|
|
11026
|
+
seq: -1,
|
|
11027
|
+
build: PLUGIN_VERSION,
|
|
11028
|
+
purged: true,
|
|
11029
|
+
source: "purge",
|
|
11030
|
+
href: location.href
|
|
11031
|
+
});
|
|
11032
|
+
if (typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function") {
|
|
11033
|
+
navigator.sendBeacon("/dsh-multipane/diag", new Blob([note], { type: "application/json" }));
|
|
11034
|
+
} else {
|
|
11035
|
+
fetch("/dsh-multipane/diag", {
|
|
11036
|
+
method: "POST",
|
|
11037
|
+
headers: { "content-type": "application/json" },
|
|
11038
|
+
body: note,
|
|
11039
|
+
keepalive: true
|
|
11040
|
+
}).catch(() => {});
|
|
11041
|
+
}
|
|
11042
|
+
} catch {
|
|
11043
|
+
/* 忽略 */
|
|
11044
|
+
}
|
|
11045
|
+
/* 只删样式不够:main 槽的注册还在,宿主就会继续渲染插件的 React 树。
|
|
11046
|
+
把内存里的 enabled 改成 false 并通知所有订阅者,让 ctx.effect 自己 dispose
|
|
11047
|
+
掉 main / attachments 等槽位注册 —— 宿主随即恢复原生会话面板,React 树真正卸载。
|
|
11048
|
+
不写 localStorage:这是"被宿主禁用"的一次性清场,不是用户的偏好。 */
|
|
11049
|
+
try {
|
|
11050
|
+
prefs.state = { ...prefs.state, enabled: false, showInSidebar: false };
|
|
11051
|
+
prefs.listeners.forEach((listener) => {
|
|
11052
|
+
try {
|
|
11053
|
+
listener();
|
|
11054
|
+
} catch {
|
|
11055
|
+
/* 某个订阅者坏了不影响其它 */
|
|
11056
|
+
}
|
|
11057
|
+
});
|
|
11058
|
+
} catch {
|
|
11059
|
+
/* 忽略 */
|
|
11060
|
+
}
|
|
11061
|
+
try {
|
|
11062
|
+
clearAllDsvState();
|
|
11063
|
+
} catch {
|
|
11064
|
+
/* 忽略 */
|
|
11065
|
+
}
|
|
11066
|
+
try {
|
|
11067
|
+
for (const node of document.querySelectorAll(".dsv-root")) node.style.display = "none";
|
|
11068
|
+
for (const id of [STYLE_ID, RAIL_STYLE_ID, "dsv-drag-hide"]) {
|
|
11069
|
+
const node = document.getElementById(id);
|
|
11070
|
+
if (node !== null) node.remove();
|
|
11071
|
+
}
|
|
11072
|
+
document.documentElement.removeAttribute("data-dsv-settings");
|
|
11073
|
+
document.documentElement.removeAttribute("data-dsv-session-drag");
|
|
11074
|
+
document.documentElement.removeAttribute("data-dsv-alive");
|
|
11075
|
+
} catch {
|
|
11076
|
+
/* 忽略 */
|
|
11077
|
+
}
|
|
11078
|
+
};
|
|
11079
|
+
/* 把清场函数挂到页面上:宿主 dispose 客户端上下文时,这个 ctx.effect 自己的心跳
|
|
11080
|
+
也会被一起清掉;只有挂在 globalThis 上的定时器能活下来,看到禁用后调用它。 */
|
|
11081
|
+
try {
|
|
11082
|
+
globalThis.__dsvPurge = purge;
|
|
11083
|
+
} catch {
|
|
11084
|
+
/* 忽略 */
|
|
11085
|
+
}
|
|
11086
|
+
try {
|
|
11087
|
+
globalThis.__dsvRevive = () => {
|
|
11088
|
+
revive();
|
|
11089
|
+
};
|
|
11090
|
+
} catch {
|
|
11091
|
+
/* 忽略 */
|
|
11092
|
+
}
|
|
11093
|
+
/* 反向:被禁用后又重新启用时,尽量原地复活,别让用户看一段"裸渲染"再等重载。
|
|
11094
|
+
清场时只是撤了槽位注册、没销毁这些 effect,所以把 enabled 改回 true 并通知订阅者,
|
|
11095
|
+
main / attachments / 侧栏入口会自己重新注册,样式表也会重新装上。 */
|
|
11096
|
+
const revive = () => {
|
|
11097
|
+
if (stopped === true) return;
|
|
11098
|
+
hostPurged = false;
|
|
11099
|
+
try {
|
|
11100
|
+
prefs.state = { ...prefs.state, enabled: true, showInSidebar: true };
|
|
11101
|
+
prefs.listeners.forEach((listener) => {
|
|
11102
|
+
try {
|
|
11103
|
+
listener();
|
|
11104
|
+
} catch {
|
|
11105
|
+
/* 忽略 */
|
|
11106
|
+
}
|
|
11107
|
+
});
|
|
11108
|
+
} catch {
|
|
11109
|
+
/* 忽略 */
|
|
11110
|
+
}
|
|
11111
|
+
try {
|
|
11112
|
+
applyLineVars();
|
|
11113
|
+
} catch {
|
|
11114
|
+
/* 忽略 */
|
|
11115
|
+
}
|
|
11116
|
+
/* purge 时给旧根写过 style.display="none";宿主重挂载如果复用同一个 DOM 节点,
|
|
11117
|
+
这条内联样式会留着,插件看起来"完全没有工作"。复活时把它摘掉。 */
|
|
11118
|
+
try {
|
|
11119
|
+
for (const node of document.querySelectorAll(".dsv-root")) node.style.removeProperty("display");
|
|
11120
|
+
} catch {
|
|
11121
|
+
/* 忽略 */
|
|
11122
|
+
}
|
|
11123
|
+
phase = "watch";
|
|
11124
|
+
hits = 0;
|
|
11125
|
+
misses = 0;
|
|
11126
|
+
};
|
|
11127
|
+
/* 路由消失只能说明「可能被禁用了」:宿主在管理器里禁用时不一定会 dispose 插件,路由反而
|
|
11128
|
+
一直健在(实测禁用后照样答 200),拿它单独判死会永远不动手。权威判据是宿主发给页面的
|
|
11129
|
+
**插件清单**:每次加载首页宿主都把启用中的插件写进 __DSH_BOOT__,禁用后清单里就没有本插件。
|
|
11130
|
+
所以这里重拉一次首页 HTML 做二次确认,清单里还有我们就不动手。 */
|
|
11131
|
+
let confirming = false;
|
|
11132
|
+
let graphSeenAlive = false;
|
|
11133
|
+
const confirmGone = () => {
|
|
11134
|
+
if (confirming === true || stopped === true || phase !== "watch") return;
|
|
11135
|
+
confirming = true;
|
|
11136
|
+
let request = null;
|
|
11137
|
+
try {
|
|
11138
|
+
request = fetch(`/?dsvProbe=${Date.now()}`, { cache: "no-store" });
|
|
11139
|
+
} catch {
|
|
11140
|
+
confirming = false;
|
|
11141
|
+
return;
|
|
11142
|
+
}
|
|
11143
|
+
if (request === null || typeof request.then !== "function") {
|
|
11144
|
+
confirming = false;
|
|
11145
|
+
return;
|
|
11146
|
+
}
|
|
11147
|
+
request
|
|
11148
|
+
.then((response) => (response.ok === true ? response.text() : ""))
|
|
11149
|
+
.then((text) => {
|
|
11150
|
+
confirming = false;
|
|
11151
|
+
if (stopped === true || phase !== "watch") return;
|
|
11152
|
+
if (typeof text !== "string" || text === "") return;
|
|
11153
|
+
const alive = text.indexOf("dsh-multipane") >= 0 || text.indexOf("dsh-split-view") >= 0;
|
|
11154
|
+
try {
|
|
11155
|
+
window.__dsvGraph = { alive: alive, at: Date.now(), length: text.length };
|
|
11156
|
+
} catch {
|
|
11157
|
+
/* 忽略 */
|
|
11158
|
+
}
|
|
11159
|
+
if (alive === true) {
|
|
11160
|
+
graphSeenAlive = true;
|
|
11161
|
+
misses = 0;
|
|
11162
|
+
return;
|
|
11163
|
+
}
|
|
11164
|
+
if (graphSeenAlive !== true) return;
|
|
11165
|
+
phase = "purged";
|
|
11166
|
+
purge();
|
|
11167
|
+
})
|
|
11168
|
+
.catch(() => {
|
|
11169
|
+
confirming = false;
|
|
11170
|
+
});
|
|
11171
|
+
};
|
|
11172
|
+
const probe = () => {
|
|
11173
|
+
if (stopped === true) return;
|
|
11174
|
+
let request = null;
|
|
11175
|
+
try {
|
|
11176
|
+
request = fetch(`${SELF_STATUS_URL}?probe=${Date.now()}`, { cache: "no-store" });
|
|
11177
|
+
} catch {
|
|
11178
|
+
request = null;
|
|
11179
|
+
}
|
|
11180
|
+
if (request === null || typeof request.then !== "function") return;
|
|
11181
|
+
request
|
|
11182
|
+
.then((response) => (response.ok === true ? response.json() : null))
|
|
11183
|
+
.then((data) => {
|
|
11184
|
+
lastStatus = data;
|
|
11185
|
+
try {
|
|
11186
|
+
globalThis.__dsvLastStatus = data;
|
|
11187
|
+
} catch {
|
|
11188
|
+
/* 忽略 */
|
|
11189
|
+
}
|
|
11190
|
+
/* 宿主自己说被禁用了 → 立刻清场(不再等路由消失)。 */
|
|
11191
|
+
if (data !== null && typeof data === "object" && data.enabled === false) {
|
|
11192
|
+
if (stopped !== true && phase === "watch") {
|
|
11193
|
+
phase = "purged";
|
|
11194
|
+
purge();
|
|
11195
|
+
}
|
|
11196
|
+
return;
|
|
11197
|
+
}
|
|
11198
|
+
if (data !== null && typeof data === "object" && typeof data.version === "string") {
|
|
11199
|
+
hits += 1;
|
|
11200
|
+
misses = 0;
|
|
11201
|
+
/* 被禁用之后又答上了 = 用户刚在管理器里重新启用。 */
|
|
11202
|
+
if (phase === "purged") {
|
|
11203
|
+
/* 宿主明确说 enabled:true → 原地复活,避免"裸渲染"那几秒。 */
|
|
11204
|
+
if (data.enabled === true) {
|
|
11205
|
+
revive();
|
|
11206
|
+
return;
|
|
11207
|
+
}
|
|
11208
|
+
/* 旧版宿主不给 enabled:两次确认后整页重载,最干净。 */
|
|
11209
|
+
if (hits >= 2) {
|
|
11210
|
+
stopped = true;
|
|
11211
|
+
try {
|
|
11212
|
+
window.clearInterval(timer);
|
|
11213
|
+
} catch {
|
|
11214
|
+
/* 忽略 */
|
|
11215
|
+
}
|
|
11216
|
+
try {
|
|
11217
|
+
window.location.reload();
|
|
11218
|
+
} catch {
|
|
11219
|
+
/* 忽略 */
|
|
11220
|
+
}
|
|
11221
|
+
return;
|
|
11222
|
+
}
|
|
11223
|
+
}
|
|
11224
|
+
everSeen = true;
|
|
11225
|
+
return;
|
|
11226
|
+
}
|
|
11227
|
+
throw new Error("host half answered without version");
|
|
11228
|
+
})
|
|
11229
|
+
.catch(() => {
|
|
11230
|
+
lastStatus = { error: true, at: Date.now() };
|
|
11231
|
+
try {
|
|
11232
|
+
globalThis.__dsvLastStatus = lastStatus;
|
|
11233
|
+
} catch {
|
|
11234
|
+
/* 忽略 */
|
|
11235
|
+
}
|
|
11236
|
+
hits = 0;
|
|
11237
|
+
if (stopped === true) return;
|
|
11238
|
+
if (everSeen !== true) return;
|
|
11239
|
+
misses += 1;
|
|
11240
|
+
if (misses < 2) return;
|
|
11241
|
+
if (phase !== "watch") return;
|
|
11242
|
+
/* 路由整个消失 = 宿主确实 dispose 了插件,这种情况直接清场。 */
|
|
11243
|
+
phase = "purged";
|
|
11244
|
+
purge();
|
|
11245
|
+
});
|
|
11246
|
+
};
|
|
11247
|
+
timer = window.setInterval(probe, 2500);
|
|
11248
|
+
probe();
|
|
11249
|
+
return () => {
|
|
11250
|
+
stopped = true;
|
|
11251
|
+
try {
|
|
11252
|
+
window.clearInterval(timer);
|
|
11253
|
+
} catch {
|
|
11254
|
+
/* 忽略 */
|
|
11255
|
+
}
|
|
11256
|
+
/* 宿主如果直接 dispose 掉客户端上下文,探针来不及跑最后一轮 ——
|
|
11257
|
+
在 effect 的 cleanup 里补一次清场,否则行标记和样式会留在页面上。 */
|
|
11258
|
+
try {
|
|
11259
|
+
purge();
|
|
11260
|
+
} catch {
|
|
11261
|
+
/* 忽略 */
|
|
11262
|
+
}
|
|
11263
|
+
};
|
|
11264
|
+
}, "dsh-split-view: host liveness probe");
|
|
11265
|
+
|
|
11266
|
+
/* 诊断取证:把宿主侧栏会话行的真实几何/计算样式,以及可能盖住侧栏的浮层,
|
|
11267
|
+
一起 POST 给宿主半身(/dsh-multipane/diag → ~/.dsh/.dsv-diag.json)。
|
|
11268
|
+
目的只有一个:侧栏是宿主的 DOM,"竖线和底板有缝"已经靠猜改错过几次,
|
|
11269
|
+
取一次真实像素级数据再动手。控制台里随时可以手动触发 window.__dsvDiag()。 */
|
|
11270
|
+
ctx.effect(() => {
|
|
11271
|
+
let sent = 0;
|
|
11272
|
+
let stopped = false;
|
|
11273
|
+
const dump = () => {
|
|
11274
|
+
if (stopped === true) return;
|
|
11275
|
+
sent += 1;
|
|
11276
|
+
let payload;
|
|
11277
|
+
try {
|
|
11278
|
+
const rows = [];
|
|
11279
|
+
for (const row of document.querySelectorAll('[data-row-key^="session:"]')) {
|
|
11280
|
+
if (rows.length >= 6) break;
|
|
11281
|
+
const cs = getComputedStyle(row);
|
|
11282
|
+
const rect = row.getBoundingClientRect();
|
|
11283
|
+
const child = row.firstElementChild;
|
|
11284
|
+
const childCs = child === null ? null : getComputedStyle(child);
|
|
11285
|
+
rows.push({
|
|
11286
|
+
key: row.getAttribute("data-row-key"),
|
|
11287
|
+
mark: row.getAttribute("data-dsv-row"),
|
|
11288
|
+
pulse: row.getAttribute("data-dsv-pulse"),
|
|
11289
|
+
cls: String(row.className || "").slice(0, 90),
|
|
11290
|
+
rect: [Math.round(rect.x), Math.round(rect.y), Math.round(rect.width), Math.round(rect.height)],
|
|
11291
|
+
radius: cs.borderRadius,
|
|
11292
|
+
borderLeft: cs.borderLeftWidth,
|
|
11293
|
+
bgClip: cs.backgroundClip,
|
|
11294
|
+
bgOrigin: cs.backgroundOrigin,
|
|
11295
|
+
bgColor: cs.backgroundColor,
|
|
11296
|
+
bgImage: cs.backgroundImage.slice(0, 140),
|
|
11297
|
+
boxShadow: cs.boxShadow.slice(0, 140),
|
|
11298
|
+
child: childCs === null ? null : {
|
|
11299
|
+
cls: String(child.className || "").slice(0, 60),
|
|
11300
|
+
bg: childCs.backgroundColor,
|
|
11301
|
+
radius: childCs.borderRadius
|
|
11302
|
+
}
|
|
11303
|
+
});
|
|
11304
|
+
}
|
|
11305
|
+
const overlays = [];
|
|
11306
|
+
for (const node of document.querySelectorAll("body *")) {
|
|
11307
|
+
if (overlays.length >= 10) break;
|
|
11308
|
+
const cs = getComputedStyle(node);
|
|
11309
|
+
if (cs.position !== "fixed" && cs.position !== "absolute") continue;
|
|
11310
|
+
const rect = node.getBoundingClientRect();
|
|
11311
|
+
if (rect.width < 220 || rect.height < 220 || rect.x > 460) continue;
|
|
11312
|
+
overlays.push({
|
|
11313
|
+
cls: String(node.className || "").slice(0, 90),
|
|
11314
|
+
tag: node.tagName,
|
|
11315
|
+
rect: [Math.round(rect.x), Math.round(rect.y), Math.round(rect.width), Math.round(rect.height)],
|
|
11316
|
+
pos: cs.position,
|
|
11317
|
+
z: cs.zIndex,
|
|
11318
|
+
opacity: cs.opacity,
|
|
11319
|
+
display: cs.display,
|
|
11320
|
+
bg: cs.backgroundColor
|
|
11321
|
+
});
|
|
11322
|
+
}
|
|
11323
|
+
payload = {
|
|
11324
|
+
at: new Date().toISOString(),
|
|
11325
|
+
seq: sent,
|
|
11326
|
+
build: PLUGIN_VERSION,
|
|
11327
|
+
href: location.href,
|
|
11328
|
+
viewport: [window.innerWidth, window.innerHeight],
|
|
11329
|
+
htmlAttrs: Array.from(document.documentElement.attributes).map((attr) => attr.name + "=" + attr.value).slice(0, 24),
|
|
11330
|
+
rootPresent: document.querySelector(".dsv-root") !== null,
|
|
11331
|
+
panel: (() => {
|
|
11332
|
+
try {
|
|
11333
|
+
const layout = SERVICES.layout ?? service("layout");
|
|
11334
|
+
SERVICES.layout = layout;
|
|
11335
|
+
const info = layout?.panelInfo?.getSnapshot?.();
|
|
11336
|
+
return info === void 0 ? null : { activePanelId: info.activePanelId ?? null };
|
|
11337
|
+
} catch {
|
|
11338
|
+
return null;
|
|
11339
|
+
}
|
|
11340
|
+
})(),
|
|
11341
|
+
dom: (() => {
|
|
11342
|
+
try {
|
|
11343
|
+
const root = document.querySelector(".dsv-root");
|
|
11344
|
+
if (root === null) return null;
|
|
11345
|
+
const rr = root.getBoundingClientRect();
|
|
11346
|
+
const panes = Array.from(root.querySelectorAll(".dsv-pane")).slice(0, 8).map((pane) => {
|
|
11347
|
+
const pr = pane.getBoundingClientRect();
|
|
11348
|
+
return {
|
|
11349
|
+
rect: [Math.round(pr.x), Math.round(pr.y), Math.round(pr.width), Math.round(pr.height)],
|
|
11350
|
+
display: getComputedStyle(pane).display,
|
|
11351
|
+
hidden: pane.hidden === true
|
|
11352
|
+
};
|
|
11353
|
+
});
|
|
11354
|
+
const tabs = Array.from(root.querySelectorAll('.dsv-tab[data-active="1"]')).slice(0, 8).map((tab) => {
|
|
11355
|
+
const tcs = getComputedStyle(tab);
|
|
11356
|
+
return {
|
|
11357
|
+
boxShadow: tcs.boxShadow.slice(0, 120),
|
|
11358
|
+
bg: tcs.backgroundColor
|
|
11359
|
+
};
|
|
11360
|
+
});
|
|
11361
|
+
return {
|
|
11362
|
+
rect: [Math.round(rr.x), Math.round(rr.y), Math.round(rr.width), Math.round(rr.height)],
|
|
11363
|
+
display: getComputedStyle(root).display,
|
|
11364
|
+
panes,
|
|
11365
|
+
tabs
|
|
11366
|
+
};
|
|
11367
|
+
} catch {
|
|
11368
|
+
return null;
|
|
11369
|
+
}
|
|
11370
|
+
})(),
|
|
11371
|
+
purged: hostPurged === true,
|
|
11372
|
+
status: (typeof globalThis.__dsvLastStatus === "object" ? globalThis.__dsvLastStatus : null),
|
|
11373
|
+
ctxKeys: (() => {
|
|
11374
|
+
try {
|
|
11375
|
+
return Object.keys(ctx).slice(0, 40);
|
|
11376
|
+
} catch {
|
|
11377
|
+
return null;
|
|
11378
|
+
}
|
|
11379
|
+
})(),
|
|
11380
|
+
graph: (typeof window.__dsvGraph === "object" ? window.__dsvGraph : null),
|
|
11381
|
+
rows,
|
|
11382
|
+
overlays
|
|
11383
|
+
};
|
|
11384
|
+
} catch (error) {
|
|
11385
|
+
payload = { at: new Date().toISOString(), seq: sent, error: String((error && error.message) || error) };
|
|
11386
|
+
}
|
|
11387
|
+
try {
|
|
11388
|
+
fetch("/dsh-multipane/diag", {
|
|
11389
|
+
method: "POST",
|
|
11390
|
+
headers: { "content-type": "application/json" },
|
|
11391
|
+
body: JSON.stringify(payload)
|
|
11392
|
+
}).catch(() => {});
|
|
11393
|
+
} catch {
|
|
11394
|
+
/* 忽略 */
|
|
11395
|
+
}
|
|
11396
|
+
};
|
|
11397
|
+
try {
|
|
11398
|
+
window.__dsvDiag = dump;
|
|
11399
|
+
} catch {
|
|
11400
|
+
/* 忽略 */
|
|
11401
|
+
}
|
|
11402
|
+
const first = window.setTimeout(dump, 4000);
|
|
11403
|
+
const repeat = window.setInterval(() => {
|
|
11404
|
+
if (sent >= 24) {
|
|
11405
|
+
window.clearInterval(repeat);
|
|
11406
|
+
return;
|
|
11407
|
+
}
|
|
11408
|
+
dump();
|
|
11409
|
+
}, 5000);
|
|
11410
|
+
/* 从插件管理页回来、或窗口从后台切回来时再拍一次:用户报的「置灰/缝」
|
|
11411
|
+
恰恰出现在这种切换之后。 */
|
|
11412
|
+
const onVisible = () => {
|
|
11413
|
+
if (document.visibilityState !== "visible") return;
|
|
11414
|
+
window.setTimeout(dump, 1500);
|
|
11415
|
+
};
|
|
11416
|
+
document.addEventListener("visibilitychange", onVisible);
|
|
11417
|
+
return () => {
|
|
11418
|
+
stopped = true;
|
|
11419
|
+
window.clearTimeout(first);
|
|
11420
|
+
window.clearInterval(repeat);
|
|
11421
|
+
document.removeEventListener("visibilitychange", onVisible);
|
|
11422
|
+
};
|
|
11423
|
+
}, "dsh-split-view: sidebar diag dump");
|
|
10179
11424
|
|
|
10180
11425
|
/* 拖放定向:接管宿主的 `conversation.input.attachments` 槽位。
|
|
10181
11426
|
**只在总开关打开时接管**:关掉插件后,宿主的附件栏、拖放、加号选文件必须全部原样工作。
|
|
@@ -10294,6 +11539,53 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
10294
11539
|
};
|
|
10295
11540
|
}, "dsh-split-view: attachments drop routing");
|
|
10296
11541
|
|
|
11542
|
+
/* 粘贴定向:跟随总开关装/卸。关掉插件时这条监听必须消失,宿主的原生粘贴路由
|
|
11543
|
+
才能原样工作(与上面的拖放定向同一个纪律:关掉后不许留任何痕迹)。 */
|
|
11544
|
+
ctx.effect(() => {
|
|
11545
|
+
let stopPaste = null;
|
|
11546
|
+
const sync = () => {
|
|
11547
|
+
const want = prefs.state.enabled === true;
|
|
11548
|
+
if (want === true) {
|
|
11549
|
+
if (stopPaste === null) {
|
|
11550
|
+
try {
|
|
11551
|
+
stopPaste = installPastePaneRouting();
|
|
11552
|
+
} catch (error) {
|
|
11553
|
+
console.warn("[split-view] 粘贴定向未启用:", error);
|
|
11554
|
+
stopPaste = null;
|
|
11555
|
+
}
|
|
11556
|
+
}
|
|
11557
|
+
return;
|
|
11558
|
+
}
|
|
11559
|
+
if (stopPaste !== null) {
|
|
11560
|
+
try {
|
|
11561
|
+
stopPaste();
|
|
11562
|
+
} catch {
|
|
11563
|
+
/* 忽略 */
|
|
11564
|
+
}
|
|
11565
|
+
stopPaste = null;
|
|
11566
|
+
}
|
|
11567
|
+
};
|
|
11568
|
+
const off = prefs.subscribe(sync);
|
|
11569
|
+
sync();
|
|
11570
|
+
return () => {
|
|
11571
|
+
if (typeof off === "function") {
|
|
11572
|
+
try {
|
|
11573
|
+
off();
|
|
11574
|
+
} catch {
|
|
11575
|
+
/* 忽略 */
|
|
11576
|
+
}
|
|
11577
|
+
}
|
|
11578
|
+
if (stopPaste !== null) {
|
|
11579
|
+
try {
|
|
11580
|
+
stopPaste();
|
|
11581
|
+
} catch {
|
|
11582
|
+
/* 忽略 */
|
|
11583
|
+
}
|
|
11584
|
+
stopPaste = null;
|
|
11585
|
+
}
|
|
11586
|
+
};
|
|
11587
|
+
}, "dsh-split-view: paste pane routing");
|
|
11588
|
+
|
|
10297
11589
|
/* 跨栏标签切换:Ctrl+Tab / Ctrl+Shift+Tab。设置页没有 .dsv-pane,自然不会触发。 */
|
|
10298
11590
|
ctx.effect(() => installTabCycling(), "dsh-split-view: tab cycling shortcut");
|
|
10299
11591
|
ctx.effect(() => installCloseTabShortcut(), "dsh-split-view: ctrl+w closes the tab");
|
|
@@ -10502,7 +11794,9 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
10502
11794
|
} catch {
|
|
10503
11795
|
onSettingsPage = false;
|
|
10504
11796
|
}
|
|
10505
|
-
|
|
11797
|
+
/* hostPurged = 在插件管理页里被宿主禁用:只撤销注册,不把用户从当前页面拽走
|
|
11798
|
+
(插件管理页不是 PANEL_ID,onSettingsPage 判不到它)。 */
|
|
11799
|
+
if (onSettingsPage === false && hostPurged !== true) selectPanel(NATIVE_PANEL);
|
|
10506
11800
|
}
|
|
10507
11801
|
};
|
|
10508
11802
|
sync();
|
|
@@ -10546,8 +11840,58 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
10546
11840
|
|
|
10547
11841
|
/* 槽位注册表变化轮询:宿主那条订阅通道不推送,只能自己比对。
|
|
10548
11842
|
全局一个定时器,2s 一次,只比「条目指纹」,没变就不 bump。 */
|
|
11843
|
+
/* 「我们还在不在宿主的登记表里」:插件管理里禁用时宿主会把入口从槽位登记表
|
|
11844
|
+
摘掉,但不卸载已经注入页面的客户端代码(0.2.3 实测:代码还在跑,样式和行标记
|
|
11845
|
+
一直留着)。拿登记表当存活信号:先确认自己登记过,之后一旦发现条目消失,
|
|
11846
|
+
就当作被禁用,立刻清掉页面上的全部痕迹并收起工作区 DOM。 */
|
|
11847
|
+
let sawPanel = false;
|
|
11848
|
+
let disabledByHost = false;
|
|
11849
|
+
const panelStillRegistered = () => {
|
|
11850
|
+
try {
|
|
11851
|
+
const slots = service("slots");
|
|
11852
|
+
if (slots === void 0 || slots === null) return true;
|
|
11853
|
+
const list = slots.entriesOfSlot?.("main") ?? slots.entries?.("main") ?? [];
|
|
11854
|
+
for (const entry of Array.isArray(list) ? list : []) {
|
|
11855
|
+
const options = entry?.options ?? {};
|
|
11856
|
+
if (options.key === PANEL_ID || options.id === PANEL_ID) return true;
|
|
11857
|
+
if (entry?.key === PANEL_ID) return true;
|
|
11858
|
+
}
|
|
11859
|
+
} catch {
|
|
11860
|
+
return true;
|
|
11861
|
+
}
|
|
11862
|
+
return false;
|
|
11863
|
+
};
|
|
11864
|
+
const vanishIfDisabled = () => {
|
|
11865
|
+
if (disabledByHost === true) return;
|
|
11866
|
+
if (panelStillRegistered() === true) {
|
|
11867
|
+
sawPanel = true;
|
|
11868
|
+
return;
|
|
11869
|
+
}
|
|
11870
|
+
if (sawPanel !== true) return;
|
|
11871
|
+
disabledByHost = true;
|
|
11872
|
+
try {
|
|
11873
|
+
clearAllDsvState();
|
|
11874
|
+
} catch {
|
|
11875
|
+
/* 忽略 */
|
|
11876
|
+
}
|
|
11877
|
+
try {
|
|
11878
|
+
for (const node of document.querySelectorAll(".dsv-root")) node.style.display = "none";
|
|
11879
|
+
for (const id of [STYLE_ID, RAIL_STYLE_ID, "dsv-drag-hide"]) {
|
|
11880
|
+
const node = document.getElementById(id);
|
|
11881
|
+
if (node !== null) node.remove();
|
|
11882
|
+
}
|
|
11883
|
+
document.documentElement.removeAttribute("data-dsv-settings");
|
|
11884
|
+
document.documentElement.removeAttribute("data-dsv-session-drag");
|
|
11885
|
+
} catch {
|
|
11886
|
+
/* 忽略 */
|
|
11887
|
+
}
|
|
11888
|
+
};
|
|
10549
11889
|
let slotFingerprint = "";
|
|
10550
11890
|
const pollSlots = () => {
|
|
11891
|
+
/* 这里原本调用 vanishIfDisabled():用宿主登记表判断是否被禁用。
|
|
11892
|
+
实测**误判**(打开插件管理页时查询返回空),把我们的样式和行标记一起清掉,
|
|
11893
|
+
用户看到「一进管理页,会话列表渲染就没了」。已停用;是否失效应交给
|
|
11894
|
+
CSS 的 html:not(:has(.dsv-root)) 判定。 */
|
|
10551
11895
|
const parts = [];
|
|
10552
11896
|
for (const name of WATCHED_SLOTS) {
|
|
10553
11897
|
for (const item of readSlotEntries(name)) parts.push(name + ":" + item.key);
|
|
@@ -10561,6 +11905,102 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
10561
11905
|
pollSlots();
|
|
10562
11906
|
const slotTimer = setInterval(pollSlots, 2000);
|
|
10563
11907
|
ctx.effect(() => () => clearInterval(slotTimer), "dsh-split-view: slot registry poll");
|
|
11908
|
+
/* 进入别的面板(插件管理 / 设置 / 宿主原生页)时工作区会卸载,
|
|
11909
|
+
侧栏那两件事就没人做了:① 把「还开着的新会话」补进列表,
|
|
11910
|
+
② 给会话行打焦点/已打开标记。实测表现为「一进插件管理页,
|
|
11911
|
+
会话列表只剩一个会话」。这里在 apply 层常驻一个 900ms 的看护循环,
|
|
11912
|
+
用最后一次已知的分栏状态继续维持这两件事 —— 与工作区是否挂载无关。 */
|
|
11913
|
+
const applyRetained = new Set();
|
|
11914
|
+
/* 开在栏里的会话的「行快照」:宿主把它藏了就用这份补回去。 */
|
|
11915
|
+
const applyRowCache = new Map();
|
|
11916
|
+
ctx.effect(() => {
|
|
11917
|
+
const timer = window.setInterval(() => {
|
|
11918
|
+
try {
|
|
11919
|
+
const sessions = resolveSessions();
|
|
11920
|
+
if (sessions === void 0 || sessions === null) return;
|
|
11921
|
+
const state = window.__dsvState;
|
|
11922
|
+
/* 关掉插件:把本层替分栏持有的会话全部放掉。 */
|
|
11923
|
+
if (prefs.state.enabled !== true) {
|
|
11924
|
+
for (const id of Array.from(applyRetained)) {
|
|
11925
|
+
try {
|
|
11926
|
+
releaseSession(id);
|
|
11927
|
+
} catch {
|
|
11928
|
+
/* 忽略 */
|
|
11929
|
+
}
|
|
11930
|
+
applyRetained.delete(id);
|
|
11931
|
+
}
|
|
11932
|
+
return;
|
|
11933
|
+
}
|
|
11934
|
+
if (state === void 0 || state === null) return;
|
|
11935
|
+
/* ⚠️ 关键:分栏里的会话原先只由「工作区组件挂载时」持有(retain),
|
|
11936
|
+
一进插件管理页工作区卸载 → 引用被放掉 → 宿主把那个会话从列表里
|
|
11937
|
+
摘掉 → 用户看到「只剩一个会话」。这里把持有提升到**插件生命周期**:
|
|
11938
|
+
只要还开在某一栏里,就一直替它 retain,与工作区挂不挂载无关。 */
|
|
11939
|
+
const { open } = paneSessionsOf(state);
|
|
11940
|
+
for (const id of open) {
|
|
11941
|
+
if (applyRetained.has(id)) continue;
|
|
11942
|
+
try {
|
|
11943
|
+
retainSession(sessions, id);
|
|
11944
|
+
applyRetained.add(id);
|
|
11945
|
+
} catch {
|
|
11946
|
+
/* 拿不到就先放着,下一拍再试 */
|
|
11947
|
+
}
|
|
11948
|
+
}
|
|
11949
|
+
for (const id of Array.from(applyRetained)) {
|
|
11950
|
+
if (open.has(id)) continue;
|
|
11951
|
+
try {
|
|
11952
|
+
releaseSession(id);
|
|
11953
|
+
} catch {
|
|
11954
|
+
/* 忽略 */
|
|
11955
|
+
}
|
|
11956
|
+
applyRetained.delete(id);
|
|
11957
|
+
}
|
|
11958
|
+
/* ── 会话行保活(不依赖宿主为什么把它藏起来)────────────────
|
|
11959
|
+
只要某个会话还开在某一栏里,它就应该在侧栏里出现。
|
|
11960
|
+
每拍把在册的行缓存一份;一旦发现它从宿主快照里消失了,
|
|
11961
|
+
就用缓存把这一行连同 ids 顺序补回去。这样无论宿主是因为
|
|
11962
|
+
「不在当前面板」「子会话折叠」还是别的规则过滤,行都不会丢。 */
|
|
11963
|
+
let snapNow;
|
|
11964
|
+
try {
|
|
11965
|
+
snapNow = sessions.list.getSnapshot();
|
|
11966
|
+
} catch {
|
|
11967
|
+
snapNow = void 0;
|
|
11968
|
+
}
|
|
11969
|
+
const byIdNow = snapNow !== void 0 && snapNow !== null && snapNow.byId !== void 0 ? snapNow.byId : void 0;
|
|
11970
|
+
if (byIdNow !== void 0 && byIdNow !== null) {
|
|
11971
|
+
for (const id of open) {
|
|
11972
|
+
const row = byIdNow[id];
|
|
11973
|
+
if (row !== void 0 && row !== null) applyRowCache.set(id, row);
|
|
11974
|
+
}
|
|
11975
|
+
for (const id of Array.from(applyRowCache.keys())) {
|
|
11976
|
+
if (open.has(id) === false) applyRowCache.delete(id);
|
|
11977
|
+
}
|
|
11978
|
+
const missing = [];
|
|
11979
|
+
for (const id of open) {
|
|
11980
|
+
if (byIdNow[id] === void 0 && applyRowCache.has(id)) missing.push(id);
|
|
11981
|
+
}
|
|
11982
|
+
if (missing.length > 0) {
|
|
11983
|
+
const nextById = { ...byIdNow };
|
|
11984
|
+
const nextIds = Array.isArray(snapNow.ids) ? [...snapNow.ids] : [];
|
|
11985
|
+
for (const id of missing) {
|
|
11986
|
+
nextById[id] = applyRowCache.get(id);
|
|
11987
|
+
if (nextIds.indexOf(id) < 0) nextIds.push(id);
|
|
11988
|
+
}
|
|
11989
|
+
try {
|
|
11990
|
+
sessions.list.set({ ...snapNow, ids: nextIds, byId: nextById });
|
|
11991
|
+
} catch (error) {
|
|
11992
|
+
console.warn("[split-view] 会话行保活失败:", error);
|
|
11993
|
+
}
|
|
11994
|
+
}
|
|
11995
|
+
}
|
|
11996
|
+
syncPaneBlankRows(state);
|
|
11997
|
+
paintSidebarRows(state);
|
|
11998
|
+
} catch {
|
|
11999
|
+
/* 忽略 */
|
|
12000
|
+
}
|
|
12001
|
+
}, 900);
|
|
12002
|
+
return () => window.clearInterval(timer);
|
|
12003
|
+
}, "dsh-split-view: keep sidebar rows alive while the workspace is hidden");
|
|
10564
12004
|
|
|
10565
12005
|
/* 持续保险:activePanelId 指向 main 注册表里不存在的面板时,
|
|
10566
12006
|
main 槽会渲染成空、整页空白(用户实测「点两下就空白」)。
|
|
@@ -10635,6 +12075,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
10635
12075
|
|
|
10636
12076
|
startRightbarKeepOpen();
|
|
10637
12077
|
startSidebarMarks();
|
|
12078
|
+
startHostWatchdog();
|
|
10638
12079
|
activateWorkspace(ctx);
|
|
10639
12080
|
|
|
10640
12081
|
try {
|