dsh-gufa-code 1.3.2 → 1.3.4
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/client.js +66 -7
- package/host/dev.js +22 -5
- package/package.json +1 -1
- package/src/client/00-core.js +26 -0
- package/src/client/59-popup-layer.js +31 -0
- package/src/client/90-app.js +9 -7
package/client.js
CHANGED
|
@@ -21,6 +21,29 @@ G.pendingEntryWorkspace = null
|
|
|
21
21
|
G.ctx = null
|
|
22
22
|
G.h = h
|
|
23
23
|
G.React = React
|
|
24
|
+
/** 官方同款 portal:把弹窗渲染到 body(与 DSH 自己的设置/会话弹窗同一层级机制),
|
|
25
|
+
* 避免被右侧停靠会话(body 级 fixed z-index 2147483040)盖住。 */
|
|
26
|
+
G.portal = (function createPortalHelper() {
|
|
27
|
+
let ReactDOM = null
|
|
28
|
+
try {
|
|
29
|
+
ReactDOM = require('react-dom')
|
|
30
|
+
} catch {
|
|
31
|
+
ReactDOM = null
|
|
32
|
+
}
|
|
33
|
+
const ensureHost = () => {
|
|
34
|
+
let host = document.getElementById('gufa-portal-root')
|
|
35
|
+
if (host === null) {
|
|
36
|
+
host = document.createElement('div')
|
|
37
|
+
host.id = 'gufa-portal-root'
|
|
38
|
+
document.body.appendChild(host)
|
|
39
|
+
}
|
|
40
|
+
return host
|
|
41
|
+
}
|
|
42
|
+
return function portal(content) {
|
|
43
|
+
if (ReactDOM === null || typeof ReactDOM.createPortal !== 'function' || typeof document === 'undefined') return content
|
|
44
|
+
return ReactDOM.createPortal(content, ensureHost())
|
|
45
|
+
}
|
|
46
|
+
})()
|
|
24
47
|
G.hooks = { useState, useEffect, useRef, useMemo, useCallback, useLayoutEffect }
|
|
25
48
|
|
|
26
49
|
/* ── 事件总线(零件之间解耦:SSH → 终端 发送命令等) ───────────────────── */
|
|
@@ -1124,6 +1147,9 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1124
1147
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1125
1148
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1126
1149
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1150
|
+
/* 官方同款 body 级 portal 容器(弹窗渲染到这里,天然在停靠会话之上) */
|
|
1151
|
+
#gufa-portal-root{position:fixed;inset:0;z-index:2147483350;pointer-events:none}
|
|
1152
|
+
#gufa-portal-root>*{pointer-events:auto}
|
|
1127
1153
|
/* 摸鱼模式:App 窗口选择器 */
|
|
1128
1154
|
.gufa-float-backdrop{position:fixed;inset:0;z-index:2147483200;display:flex;align-items:center;justify-content:center;
|
|
1129
1155
|
background:rgba(0,0,0,0.42);padding:24px;box-sizing:border-box}
|
|
@@ -8137,11 +8163,41 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
|
|
|
8137
8163
|
'.gufa-shortcuts-backdrop',
|
|
8138
8164
|
].join(',')
|
|
8139
8165
|
|
|
8166
|
+
/* 真正需要抬的是 overlay root 的 body 级祖先:它和停靠会话都是 body 的直接子节点,
|
|
8167
|
+
在祖先上设 z-index 才能压过会话的 2147483040;只抬 .gufa-overlay-root 出不了
|
|
8168
|
+
它自己的层叠上下文。 */
|
|
8169
|
+
let liftedNodes = []
|
|
8170
|
+
const lift = (open) => {
|
|
8171
|
+
try {
|
|
8172
|
+
if (open) {
|
|
8173
|
+
if (liftedNodes.length > 0) return
|
|
8174
|
+
let node = document.querySelector('.gufa-overlay-root')
|
|
8175
|
+
if (node === null) return
|
|
8176
|
+
while (node.parentElement !== null && node.parentElement !== document.body) node = node.parentElement
|
|
8177
|
+
if (node.parentElement !== document.body) return
|
|
8178
|
+
const saved = { node, zIndex: node.style.zIndex, position: node.style.position }
|
|
8179
|
+
node.style.zIndex = '2147483300'
|
|
8180
|
+
if (window.getComputedStyle(node).position === 'static') node.style.position = 'relative'
|
|
8181
|
+
liftedNodes.push(saved)
|
|
8182
|
+
if (node.parentElement !== document.body) return
|
|
8183
|
+
} else {
|
|
8184
|
+
for (const saved of liftedNodes) {
|
|
8185
|
+
saved.node.style.zIndex = saved.zIndex
|
|
8186
|
+
saved.node.style.position = saved.position
|
|
8187
|
+
}
|
|
8188
|
+
liftedNodes = []
|
|
8189
|
+
}
|
|
8190
|
+
} catch {
|
|
8191
|
+
/* ignore */
|
|
8192
|
+
}
|
|
8193
|
+
}
|
|
8194
|
+
|
|
8140
8195
|
const sync = () => {
|
|
8141
8196
|
try {
|
|
8142
8197
|
const root = document.querySelector('.gufa-root')
|
|
8143
8198
|
const popup = root === null ? null : root.querySelector(SELECTOR)
|
|
8144
8199
|
const open = popup !== null
|
|
8200
|
+
lift(open)
|
|
8145
8201
|
if ((document.documentElement.getAttribute(ATTR) === '1') === open) return
|
|
8146
8202
|
if (open) document.documentElement.setAttribute(ATTR, '1')
|
|
8147
8203
|
else document.documentElement.removeAttribute(ATTR)
|
|
@@ -8162,6 +8218,7 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
|
|
|
8162
8218
|
return () => {
|
|
8163
8219
|
if (observer !== null) observer.disconnect()
|
|
8164
8220
|
window.clearInterval(timer)
|
|
8221
|
+
lift(false)
|
|
8165
8222
|
document.documentElement.removeAttribute(ATTR)
|
|
8166
8223
|
}
|
|
8167
8224
|
}
|
|
@@ -11362,7 +11419,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11362
11419
|
),
|
|
11363
11420
|
),
|
|
11364
11421
|
typeof G.UsageDock === 'function' ? h(G.UsageDock, { active: true }) : null,
|
|
11365
|
-
workspaceDialog === null
|
|
11422
|
+
G.portal(workspaceDialog === null
|
|
11366
11423
|
? null
|
|
11367
11424
|
: h(
|
|
11368
11425
|
'div',
|
|
@@ -11426,7 +11483,8 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11426
11483
|
),
|
|
11427
11484
|
),
|
|
11428
11485
|
),
|
|
11429
|
-
|
|
11486
|
+
),
|
|
11487
|
+
G.portal(branchMenu === null
|
|
11430
11488
|
? null
|
|
11431
11489
|
: h(
|
|
11432
11490
|
'div',
|
|
@@ -11495,9 +11553,10 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11495
11553
|
),
|
|
11496
11554
|
),
|
|
11497
11555
|
),
|
|
11556
|
+
),
|
|
11498
11557
|
/* 弹窗 */
|
|
11499
|
-
modal === null ? null : renderModal(),
|
|
11500
|
-
floatPicker !== null
|
|
11558
|
+
G.portal(modal === null ? null : renderModal()),
|
|
11559
|
+
G.portal(floatPicker !== null
|
|
11501
11560
|
? h(
|
|
11502
11561
|
'div',
|
|
11503
11562
|
{
|
|
@@ -11571,9 +11630,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11571
11630
|
),
|
|
11572
11631
|
),
|
|
11573
11632
|
)
|
|
11574
|
-
: null,
|
|
11575
|
-
sessionsOpen ? renderSessionsDialog() : null,
|
|
11576
|
-
shortcutsOpen ? renderShortcutsDialog() : null,
|
|
11633
|
+
: null),
|
|
11634
|
+
G.portal(sessionsOpen ? renderSessionsDialog() : null),
|
|
11635
|
+
G.portal(shortcutsOpen ? renderShortcutsDialog() : null),
|
|
11577
11636
|
)
|
|
11578
11637
|
|
|
11579
11638
|
function renderShortcutsDialog() {
|
package/host/dev.js
CHANGED
|
@@ -125,9 +125,9 @@ export function register(router, env) {
|
|
|
125
125
|
router.method('float.windows', async () => {
|
|
126
126
|
if (process.platform !== 'darwin') throw new ApiError('unsupported', '摸鱼模式目前只支持 macOS', 400)
|
|
127
127
|
if (appBundlePath() === null) throw new ApiError('missing-helper', '悬浮层 App 未构建,请先运行 scripts/build-float-macos.sh', 500)
|
|
128
|
+
const binary = floatBinaryPath()
|
|
128
129
|
const outPath = join(tmpdir(), `gufa-float-windows-${process.pid}-${Date.now()}.json`)
|
|
129
|
-
|
|
130
|
-
await openApp(['--list-windows', '--out', outPath])
|
|
130
|
+
const readResult = async () => {
|
|
131
131
|
const deadline = Date.now() + 10_000
|
|
132
132
|
let raw = ''
|
|
133
133
|
while (Date.now() < deadline) {
|
|
@@ -139,12 +139,29 @@ export function register(router, env) {
|
|
|
139
139
|
}
|
|
140
140
|
await new Promise((resolve) => setTimeout(resolve, 120))
|
|
141
141
|
}
|
|
142
|
-
let parsed = null
|
|
143
142
|
try {
|
|
144
|
-
|
|
143
|
+
return JSON.parse(raw.trim())
|
|
145
144
|
} catch {
|
|
146
|
-
|
|
145
|
+
return null
|
|
147
146
|
}
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
/* 路线 A:直接从 Host 进程 spawn(responsible app = DeepSeek Harness,可继承 DSH 的屏幕录制授权) */
|
|
150
|
+
if (binary !== null) {
|
|
151
|
+
try {
|
|
152
|
+
await runFile(binary, ['--list-windows', '--out', outPath], { timeout: 12_000 })
|
|
153
|
+
} catch {
|
|
154
|
+
/* 走读取兜底 */
|
|
155
|
+
}
|
|
156
|
+
const parsed = await readResult()
|
|
157
|
+
debugLog(`float-windows route=direct ok=${String(parsed !== null && parsed.ok === true)} permission=${String(parsed !== null ? parsed.permission : 'none')}`)
|
|
158
|
+
if (parsed !== null && parsed.ok === true) return parsed
|
|
159
|
+
try { await rm(outPath, { force: true }) } catch { /* ignore */ }
|
|
160
|
+
}
|
|
161
|
+
/* 路线 B:通过 .app 身份启动(用户给「古法编程悬浮层.app」单独授权) */
|
|
162
|
+
await openApp(['--list-windows', '--out', outPath])
|
|
163
|
+
const parsed = await readResult()
|
|
164
|
+
debugLog(`float-windows route=app ok=${String(parsed !== null && parsed.ok === true)} permission=${String(parsed !== null ? parsed.permission : 'none')}`)
|
|
148
165
|
if (parsed === null) throw new ApiError('list-failed', '读取窗口列表失败(helper 无输出)', 500)
|
|
149
166
|
return parsed
|
|
150
167
|
} finally {
|
package/package.json
CHANGED
package/src/client/00-core.js
CHANGED
|
@@ -13,6 +13,29 @@ G.pendingEntryWorkspace = null
|
|
|
13
13
|
G.ctx = null
|
|
14
14
|
G.h = h
|
|
15
15
|
G.React = React
|
|
16
|
+
/** 官方同款 portal:把弹窗渲染到 body(与 DSH 自己的设置/会话弹窗同一层级机制),
|
|
17
|
+
* 避免被右侧停靠会话(body 级 fixed z-index 2147483040)盖住。 */
|
|
18
|
+
G.portal = (function createPortalHelper() {
|
|
19
|
+
let ReactDOM = null
|
|
20
|
+
try {
|
|
21
|
+
ReactDOM = require('react-dom')
|
|
22
|
+
} catch {
|
|
23
|
+
ReactDOM = null
|
|
24
|
+
}
|
|
25
|
+
const ensureHost = () => {
|
|
26
|
+
let host = document.getElementById('gufa-portal-root')
|
|
27
|
+
if (host === null) {
|
|
28
|
+
host = document.createElement('div')
|
|
29
|
+
host.id = 'gufa-portal-root'
|
|
30
|
+
document.body.appendChild(host)
|
|
31
|
+
}
|
|
32
|
+
return host
|
|
33
|
+
}
|
|
34
|
+
return function portal(content) {
|
|
35
|
+
if (ReactDOM === null || typeof ReactDOM.createPortal !== 'function' || typeof document === 'undefined') return content
|
|
36
|
+
return ReactDOM.createPortal(content, ensureHost())
|
|
37
|
+
}
|
|
38
|
+
})()
|
|
16
39
|
G.hooks = { useState, useEffect, useRef, useMemo, useCallback, useLayoutEffect }
|
|
17
40
|
|
|
18
41
|
/* ── 事件总线(零件之间解耦:SSH → 终端 发送命令等) ───────────────────── */
|
|
@@ -1116,6 +1139,9 @@ html[data-gufa-ide] [role="dialog"] {
|
|
|
1116
1139
|
.gufa-session-group-count{font-size:10.5px;opacity:.6;font-variant-numeric:tabular-nums}
|
|
1117
1140
|
.gufa-session-group[data-current] .gufa-session-group-head{color:var(--gufa-text)}
|
|
1118
1141
|
.gufa-session-group .gufa-session-row{margin-left:10px}
|
|
1142
|
+
/* 官方同款 body 级 portal 容器(弹窗渲染到这里,天然在停靠会话之上) */
|
|
1143
|
+
#gufa-portal-root{position:fixed;inset:0;z-index:2147483350;pointer-events:none}
|
|
1144
|
+
#gufa-portal-root>*{pointer-events:auto}
|
|
1119
1145
|
/* 摸鱼模式:App 窗口选择器 */
|
|
1120
1146
|
.gufa-float-backdrop{position:fixed;inset:0;z-index:2147483200;display:flex;align-items:center;justify-content:center;
|
|
1121
1147
|
background:rgba(0,0,0,0.42);padding:24px;box-sizing:border-box}
|
|
@@ -25,11 +25,41 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
|
|
|
25
25
|
'.gufa-shortcuts-backdrop',
|
|
26
26
|
].join(',')
|
|
27
27
|
|
|
28
|
+
/* 真正需要抬的是 overlay root 的 body 级祖先:它和停靠会话都是 body 的直接子节点,
|
|
29
|
+
在祖先上设 z-index 才能压过会话的 2147483040;只抬 .gufa-overlay-root 出不了
|
|
30
|
+
它自己的层叠上下文。 */
|
|
31
|
+
let liftedNodes = []
|
|
32
|
+
const lift = (open) => {
|
|
33
|
+
try {
|
|
34
|
+
if (open) {
|
|
35
|
+
if (liftedNodes.length > 0) return
|
|
36
|
+
let node = document.querySelector('.gufa-overlay-root')
|
|
37
|
+
if (node === null) return
|
|
38
|
+
while (node.parentElement !== null && node.parentElement !== document.body) node = node.parentElement
|
|
39
|
+
if (node.parentElement !== document.body) return
|
|
40
|
+
const saved = { node, zIndex: node.style.zIndex, position: node.style.position }
|
|
41
|
+
node.style.zIndex = '2147483300'
|
|
42
|
+
if (window.getComputedStyle(node).position === 'static') node.style.position = 'relative'
|
|
43
|
+
liftedNodes.push(saved)
|
|
44
|
+
if (node.parentElement !== document.body) return
|
|
45
|
+
} else {
|
|
46
|
+
for (const saved of liftedNodes) {
|
|
47
|
+
saved.node.style.zIndex = saved.zIndex
|
|
48
|
+
saved.node.style.position = saved.position
|
|
49
|
+
}
|
|
50
|
+
liftedNodes = []
|
|
51
|
+
}
|
|
52
|
+
} catch {
|
|
53
|
+
/* ignore */
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
28
57
|
const sync = () => {
|
|
29
58
|
try {
|
|
30
59
|
const root = document.querySelector('.gufa-root')
|
|
31
60
|
const popup = root === null ? null : root.querySelector(SELECTOR)
|
|
32
61
|
const open = popup !== null
|
|
62
|
+
lift(open)
|
|
33
63
|
if ((document.documentElement.getAttribute(ATTR) === '1') === open) return
|
|
34
64
|
if (open) document.documentElement.setAttribute(ATTR, '1')
|
|
35
65
|
else document.documentElement.removeAttribute(ATTR)
|
|
@@ -50,6 +80,7 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
|
|
|
50
80
|
return () => {
|
|
51
81
|
if (observer !== null) observer.disconnect()
|
|
52
82
|
window.clearInterval(timer)
|
|
83
|
+
lift(false)
|
|
53
84
|
document.documentElement.removeAttribute(ATTR)
|
|
54
85
|
}
|
|
55
86
|
}
|
package/src/client/90-app.js
CHANGED
|
@@ -2005,7 +2005,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2005
2005
|
),
|
|
2006
2006
|
),
|
|
2007
2007
|
typeof G.UsageDock === 'function' ? h(G.UsageDock, { active: true }) : null,
|
|
2008
|
-
workspaceDialog === null
|
|
2008
|
+
G.portal(workspaceDialog === null
|
|
2009
2009
|
? null
|
|
2010
2010
|
: h(
|
|
2011
2011
|
'div',
|
|
@@ -2069,7 +2069,8 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2069
2069
|
),
|
|
2070
2070
|
),
|
|
2071
2071
|
),
|
|
2072
|
-
|
|
2072
|
+
),
|
|
2073
|
+
G.portal(branchMenu === null
|
|
2073
2074
|
? null
|
|
2074
2075
|
: h(
|
|
2075
2076
|
'div',
|
|
@@ -2138,9 +2139,10 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2138
2139
|
),
|
|
2139
2140
|
),
|
|
2140
2141
|
),
|
|
2142
|
+
),
|
|
2141
2143
|
/* 弹窗 */
|
|
2142
|
-
modal === null ? null : renderModal(),
|
|
2143
|
-
floatPicker !== null
|
|
2144
|
+
G.portal(modal === null ? null : renderModal()),
|
|
2145
|
+
G.portal(floatPicker !== null
|
|
2144
2146
|
? h(
|
|
2145
2147
|
'div',
|
|
2146
2148
|
{
|
|
@@ -2214,9 +2216,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2214
2216
|
),
|
|
2215
2217
|
),
|
|
2216
2218
|
)
|
|
2217
|
-
: null,
|
|
2218
|
-
sessionsOpen ? renderSessionsDialog() : null,
|
|
2219
|
-
shortcutsOpen ? renderShortcutsDialog() : null,
|
|
2219
|
+
: null),
|
|
2220
|
+
G.portal(sessionsOpen ? renderSessionsDialog() : null),
|
|
2221
|
+
G.portal(shortcutsOpen ? renderShortcutsDialog() : null),
|
|
2220
2222
|
)
|
|
2221
2223
|
|
|
2222
2224
|
function renderShortcutsDialog() {
|