dsh-gufa-code 1.3.1 → 1.3.3

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 CHANGED
@@ -8137,11 +8137,41 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
8137
8137
  '.gufa-shortcuts-backdrop',
8138
8138
  ].join(',')
8139
8139
 
8140
+ /* 真正需要抬的是 overlay root 的 body 级祖先:它和停靠会话都是 body 的直接子节点,
8141
+ 在祖先上设 z-index 才能压过会话的 2147483040;只抬 .gufa-overlay-root 出不了
8142
+ 它自己的层叠上下文。 */
8143
+ let liftedNodes = []
8144
+ const lift = (open) => {
8145
+ try {
8146
+ if (open) {
8147
+ if (liftedNodes.length > 0) return
8148
+ let node = document.querySelector('.gufa-overlay-root')
8149
+ if (node === null) return
8150
+ while (node.parentElement !== null && node.parentElement !== document.body) node = node.parentElement
8151
+ if (node.parentElement !== document.body) return
8152
+ const saved = { node, zIndex: node.style.zIndex, position: node.style.position }
8153
+ node.style.zIndex = '2147483300'
8154
+ if (window.getComputedStyle(node).position === 'static') node.style.position = 'relative'
8155
+ liftedNodes.push(saved)
8156
+ if (node.parentElement !== document.body) return
8157
+ } else {
8158
+ for (const saved of liftedNodes) {
8159
+ saved.node.style.zIndex = saved.zIndex
8160
+ saved.node.style.position = saved.position
8161
+ }
8162
+ liftedNodes = []
8163
+ }
8164
+ } catch {
8165
+ /* ignore */
8166
+ }
8167
+ }
8168
+
8140
8169
  const sync = () => {
8141
8170
  try {
8142
8171
  const root = document.querySelector('.gufa-root')
8143
8172
  const popup = root === null ? null : root.querySelector(SELECTOR)
8144
8173
  const open = popup !== null
8174
+ lift(open)
8145
8175
  if ((document.documentElement.getAttribute(ATTR) === '1') === open) return
8146
8176
  if (open) document.documentElement.setAttribute(ATTR, '1')
8147
8177
  else document.documentElement.removeAttribute(ATTR)
@@ -8162,6 +8192,7 @@ G.installPopupLayerWatch = function installPopupLayerWatch(ctx) {
8162
8192
  return () => {
8163
8193
  if (observer !== null) observer.disconnect()
8164
8194
  window.clearInterval(timer)
8195
+ lift(false)
8165
8196
  document.documentElement.removeAttribute(ATTR)
8166
8197
  }
8167
8198
  }
@@ -11521,11 +11552,12 @@ G.GufaApp = function GufaApp(props) {
11521
11552
  'div',
11522
11553
  { className: 'gufa-float-permission' },
11523
11554
  h('div', { className: 'gufa-float-permission-title' }, '需要「屏幕录制」权限'),
11524
- h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App 的窗口尺寸(只读尺寸,不录屏)。请在「系统设置 → 隐私与安全性 → 屏幕录制」里勾选 **DeepSeek Harness**(若列表只显示自己,请重启一次 DeepSeek Harness 让权限生效),然后点「重试」。'),
11555
+ h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App 的窗口尺寸(只读尺寸,不录屏)。系统只认悬浮层 App 自己的授权:请在「系统设置 → 隐私与安全性 → 屏幕录制」里点左下角「+」,添加「古法编程悬浮层.app」并打开开关(DeepSeek Harness 的开关也保持打开)。加好后点「重试」。'),
11525
11556
  h(
11526
11557
  'div',
11527
- { className: 'gufa-row', style: { gap: 8, marginTop: 12 } },
11558
+ { className: 'gufa-row', style: { gap: 8, marginTop: 12, flexWrap: 'wrap' } },
11528
11559
  h(G.Button, { primary: true, onClick: () => void G.api('float.openPrivacy').catch(() => {}) }, '打开系统设置'),
11560
+ h(G.Button, { onClick: () => void G.api('float.revealHelper').catch(() => {}) }, '在 Finder 中显示悬浮层 App'),
11529
11561
  h(G.Button, { onClick: () => void openFloatPicker() }, '重试'),
11530
11562
  ),
11531
11563
  )
@@ -530,13 +530,23 @@ static NSArray<NSDictionary *> *GufaEnumerateWindows(void) {
530
530
  return rows;
531
531
  }
532
532
 
533
- static void GufaPrintPermissionResult(void) {
534
- NSDictionary *out = @{@"ok": @NO, @"permission": @"screen-recording"};
533
+ static NSString *GufaOutputPath = nil;
534
+
535
+ static void GufaEmitJSON(NSDictionary *out) {
535
536
  NSData *json = [NSJSONSerialization dataWithJSONObject:out options:0 error:NULL];
536
- if (json != nil) fwrite(json.bytes, 1, json.length, stdout);
537
+ if (json == nil) return;
538
+ if (GufaOutputPath.length > 0) {
539
+ [json writeToFile:GufaOutputPath atomically:YES];
540
+ return;
541
+ }
542
+ fwrite(json.bytes, 1, json.length, stdout);
537
543
  fputc('\n', stdout);
538
544
  }
539
545
 
546
+ static void GufaPrintPermissionResult(void) {
547
+ GufaEmitJSON(@{@"ok": @NO, @"permission": @"screen-recording"});
548
+ }
549
+
540
550
  /** 没权限时 CGWindowList 只返回「自己这个 App」的窗口;据此判断权限,而不是信 CGPreflight。 */
541
551
  static BOOL GufaRowsHaveForeignWindows(NSArray<NSDictionary *> *rows) {
542
552
  NSString *own = NSProcessInfo.processInfo.processName;
@@ -558,16 +568,16 @@ static int GufaListWindowsMode(void) {
558
568
  GufaPrintPermissionResult();
559
569
  return 2;
560
570
  }
561
- NSDictionary *out = @{@"ok": @YES, @"windows": rows};
562
- NSData *json = [NSJSONSerialization dataWithJSONObject:out options:0 error:NULL];
563
- fwrite(json.bytes, 1, json.length, stdout);
564
- fputc('\n', stdout);
571
+ GufaEmitJSON(@{@"ok": @YES, @"windows": rows});
565
572
  return 0;
566
573
  }
567
574
 
568
575
  int main(int argc, const char *argv[]) {
569
576
  if (argc > 1 && strcmp(argv[1], "--list-windows") == 0) {
570
577
  @autoreleasepool {
578
+ for (int i = 2; i + 1 < argc; i++) {
579
+ if (strcmp(argv[i], "--out") == 0) GufaOutputPath = [NSString stringWithUTF8String:argv[i + 1]];
580
+ }
571
581
  return GufaListWindowsMode();
572
582
  }
573
583
  }
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleIdentifier</key><string>com.gufa.float</string>
6
+ <key>CFBundleName</key><string>古法编程悬浮层</string>
7
+ <key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
8
+ <key>CFBundleExecutable</key><string>gufa-float</string>
9
+ <key>CFBundlePackageType</key><string>APPL</string>
10
+ <key>CFBundleShortVersionString</key><string>1.3.1</string>
11
+ <key>CFBundleVersion</key><string>1.3.1</string>
12
+ <key>LSUIElement</key><true/>
13
+ <key>NSHighResolutionCapable</key><true/>
14
+ <key>NSPrincipalClass</key><string>NSApplication</string>
15
+ </dict>
16
+ </plist>
@@ -0,0 +1,115 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>files</key>
6
+ <dict/>
7
+ <key>files2</key>
8
+ <dict/>
9
+ <key>rules</key>
10
+ <dict>
11
+ <key>^Resources/</key>
12
+ <true/>
13
+ <key>^Resources/.*\.lproj/</key>
14
+ <dict>
15
+ <key>optional</key>
16
+ <true/>
17
+ <key>weight</key>
18
+ <real>1000</real>
19
+ </dict>
20
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
21
+ <dict>
22
+ <key>omit</key>
23
+ <true/>
24
+ <key>weight</key>
25
+ <real>1100</real>
26
+ </dict>
27
+ <key>^Resources/Base\.lproj/</key>
28
+ <dict>
29
+ <key>weight</key>
30
+ <real>1010</real>
31
+ </dict>
32
+ <key>^version.plist$</key>
33
+ <true/>
34
+ </dict>
35
+ <key>rules2</key>
36
+ <dict>
37
+ <key>.*\.dSYM($|/)</key>
38
+ <dict>
39
+ <key>weight</key>
40
+ <real>11</real>
41
+ </dict>
42
+ <key>^(.*/)?\.DS_Store$</key>
43
+ <dict>
44
+ <key>omit</key>
45
+ <true/>
46
+ <key>weight</key>
47
+ <real>2000</real>
48
+ </dict>
49
+ <key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
50
+ <dict>
51
+ <key>nested</key>
52
+ <true/>
53
+ <key>weight</key>
54
+ <real>10</real>
55
+ </dict>
56
+ <key>^.*</key>
57
+ <true/>
58
+ <key>^Info\.plist$</key>
59
+ <dict>
60
+ <key>omit</key>
61
+ <true/>
62
+ <key>weight</key>
63
+ <real>20</real>
64
+ </dict>
65
+ <key>^PkgInfo$</key>
66
+ <dict>
67
+ <key>omit</key>
68
+ <true/>
69
+ <key>weight</key>
70
+ <real>20</real>
71
+ </dict>
72
+ <key>^Resources/</key>
73
+ <dict>
74
+ <key>weight</key>
75
+ <real>20</real>
76
+ </dict>
77
+ <key>^Resources/.*\.lproj/</key>
78
+ <dict>
79
+ <key>optional</key>
80
+ <true/>
81
+ <key>weight</key>
82
+ <real>1000</real>
83
+ </dict>
84
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
85
+ <dict>
86
+ <key>omit</key>
87
+ <true/>
88
+ <key>weight</key>
89
+ <real>1100</real>
90
+ </dict>
91
+ <key>^Resources/Base\.lproj/</key>
92
+ <dict>
93
+ <key>weight</key>
94
+ <real>1010</real>
95
+ </dict>
96
+ <key>^[^/]+$</key>
97
+ <dict>
98
+ <key>nested</key>
99
+ <true/>
100
+ <key>weight</key>
101
+ <real>10</real>
102
+ </dict>
103
+ <key>^embedded\.provisionprofile$</key>
104
+ <dict>
105
+ <key>weight</key>
106
+ <real>20</real>
107
+ </dict>
108
+ <key>^version\.plist$</key>
109
+ <dict>
110
+ <key>weight</key>
111
+ <real>20</real>
112
+ </dict>
113
+ </dict>
114
+ </dict>
115
+ </plist>
package/host/dev.js CHANGED
@@ -3,6 +3,8 @@
3
3
  * 旧版本 Host(没有本方法)会让 api('dev.version') 返回 not-found,客户端据此提示重启 Harness。
4
4
  */
5
5
  import { appendFileSync, existsSync } from 'node:fs'
6
+ import { readFile, rm } from 'node:fs/promises'
7
+ import { tmpdir } from 'node:os'
6
8
  import { execFile, spawn } from 'node:child_process'
7
9
  import { promisify } from 'node:util'
8
10
  import { dirname, join } from 'node:path'
@@ -43,36 +45,132 @@ export function register(router, env) {
43
45
  const startedAt = new Date().toISOString()
44
46
  const ctx = env?.ctx ?? router.ctx
45
47
 
46
- /* ── 桌面悬浮层(P0,macOS) ─────────────────────────────────────── */
47
- router.method('float.status', async () => ({
48
- supported: process.platform === 'darwin' && floatBinaryPath() !== null,
49
- platform: process.platform,
50
- running: floatRunning(),
51
- pid: floatRunning() ? floatState.child.pid : null,
52
- binary: floatBinaryPath(),
53
- }))
48
+ /* ── 桌面悬浮层 / 摸鱼模式(macOS) ────────────────────────────────
49
+ * 通过 .app bundle 启动 helper:TCC(屏幕录制)按 bundle 身份授权,
50
+ * 用户在「系统设置 → 隐私与安全性 → 屏幕录制」里添加「古法编程悬浮层.app」即可。
51
+ */
52
+ const appBundlePath = () => {
53
+ const candidates = [
54
+ join(PLUGIN_ROOT, 'desktop', 'float', '古法编程悬浮层.app'),
55
+ join(PLUGIN_ROOT, 'desktop', 'float', 'GufaFloat.app'),
56
+ ]
57
+ for (const candidate of candidates) {
58
+ if (existsSync(candidate)) return candidate
59
+ }
60
+ return null
61
+ }
62
+ const floatProcessPattern = '古法编程悬浮层.app/Contents/MacOS/gufa-float'
63
+
64
+ const listFloatPids = async () => {
65
+ try {
66
+ const { stdout } = await runFile('pgrep', ['-f', floatProcessPattern], { timeout: 3000 })
67
+ return String(stdout ?? '').split('\n').map((line) => Number(line.trim())).filter((pid) => Number.isFinite(pid) && pid > 0)
68
+ } catch {
69
+ return []
70
+ }
71
+ }
72
+ const floatRunningAsync = async () => (await listFloatPids()).length > 0
54
73
 
55
- /** 列出可吸附的 App 窗口(spawn helper 的 --list-windows 模式,JSON 输出)。 */
74
+ const openApp = (args) => new Promise((resolve, reject) => {
75
+ const app = appBundlePath()
76
+ if (app === null) {
77
+ reject(new ApiError('missing-helper', '悬浮层 App 未构建,请先运行 scripts/build-float-macos.sh', 500))
78
+ return
79
+ }
80
+ const child = spawn('open', ['-n', app, '--args', ...args], { detached: true, stdio: 'ignore' })
81
+ child.once('error', reject)
82
+ child.once('exit', (code) => {
83
+ if (code === 0) resolve()
84
+ else reject(new ApiError('open-failed', `悬浮层启动失败(open exit ${code})`, 500))
85
+ })
86
+ })
87
+
88
+ const killFloat = async () => {
89
+ const pids = await listFloatPids()
90
+ for (const pid of pids) {
91
+ try {
92
+ process.kill(pid, 'SIGTERM')
93
+ } catch {
94
+ /* ignore */
95
+ }
96
+ }
97
+ if (pids.length > 0) await new Promise((resolve) => setTimeout(resolve, 400))
98
+ floatState.child = null
99
+ }
100
+
101
+ router.method('float.status', async () => {
102
+ const running = await floatRunningAsync()
103
+ return {
104
+ supported: process.platform === 'darwin' && appBundlePath() !== null,
105
+ platform: process.platform,
106
+ running,
107
+ pid: running ? (await listFloatPids())[0] ?? null : null,
108
+ app: appBundlePath(),
109
+ }
110
+ })
111
+
112
+ /** 在 Finder 里显示悬浮层 App,便于用户在「屏幕录制」里手动添加。 */
113
+ router.method('float.revealHelper', async () => {
114
+ const app = appBundlePath()
115
+ if (app === null) throw new ApiError('missing-helper', '悬浮层 App 未构建', 500)
116
+ try {
117
+ spawn('open', ['-R', app], { detached: true, stdio: 'ignore' }).unref()
118
+ return { ok: true, app }
119
+ } catch {
120
+ return { ok: false, app }
121
+ }
122
+ })
123
+
124
+ /** 列出可吸附的 App 窗口(通过 .app 身份启动 helper,输出到临时文件)。 */
56
125
  router.method('float.windows', async () => {
57
126
  if (process.platform !== 'darwin') throw new ApiError('unsupported', '摸鱼模式目前只支持 macOS', 400)
127
+ if (appBundlePath() === null) throw new ApiError('missing-helper', '悬浮层 App 未构建,请先运行 scripts/build-float-macos.sh', 500)
58
128
  const binary = floatBinaryPath()
59
- if (binary === null) throw new ApiError('missing-helper', '悬浮层程序未构建,请先运行 scripts/build-float-macos.sh', 500)
60
- let stdout = ''
61
- try {
62
- const result = await runFile(binary, ['--list-windows'], { timeout: 10_000, maxBuffer: 8 * 1024 * 1024 })
63
- stdout = String(result.stdout ?? '')
64
- } catch (error) {
65
- stdout = String(error && error.stdout || '')
129
+ const outPath = join(tmpdir(), `gufa-float-windows-${process.pid}-${Date.now()}.json`)
130
+ const readResult = async () => {
131
+ const deadline = Date.now() + 10_000
132
+ let raw = ''
133
+ while (Date.now() < deadline) {
134
+ try {
135
+ raw = await readFile(outPath, 'utf8')
136
+ if (raw.trim() !== '') break
137
+ } catch {
138
+ /* 还没写出来 */
139
+ }
140
+ await new Promise((resolve) => setTimeout(resolve, 120))
141
+ }
142
+ try {
143
+ return JSON.parse(raw.trim())
144
+ } catch {
145
+ return null
146
+ }
66
147
  }
67
- const line = stdout.trim().split('\n').filter(Boolean).pop() ?? ''
68
- let parsed = null
69
148
  try {
70
- parsed = JSON.parse(line)
71
- } catch {
72
- parsed = null
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')}`)
165
+ if (parsed === null) throw new ApiError('list-failed', '读取窗口列表失败(helper 无输出)', 500)
166
+ return parsed
167
+ } finally {
168
+ try {
169
+ await rm(outPath, { force: true })
170
+ } catch {
171
+ /* ignore */
172
+ }
73
173
  }
74
- if (parsed === null) throw new ApiError('list-failed', '读取窗口列表失败(helper 无输出)', 500)
75
- return parsed
76
174
  })
77
175
 
78
176
  router.method('float.openPrivacy', async () => {
@@ -86,71 +184,36 @@ export function register(router, env) {
86
184
  })
87
185
 
88
186
  router.method('float.start', async (body) => {
89
- if (process.platform !== 'darwin') throw new ApiError('unsupported', '桌面悬浮层目前只支持 macOS', 400)
90
- const binary = floatBinaryPath()
91
- if (binary === null) throw new ApiError('missing-helper', '悬浮层程序未构建,请先运行 scripts/build-float-macos.sh', 500)
187
+ if (process.platform !== 'darwin') throw new ApiError('unsupported', '摸鱼模式目前只支持 macOS', 400)
188
+ if (appBundlePath() === null) throw new ApiError('missing-helper', '悬浮层 App 未构建,请先运行 scripts/build-float-macos.sh', 500)
92
189
  const follow = body !== null && typeof body === 'object' && body.follow !== null && typeof body.follow === 'object'
93
190
  ? { windowNumber: Number(body.follow.windowNumber) || 0, pid: Number(body.follow.pid) || 0 }
94
191
  : null
95
192
  if (follow !== null && follow.windowNumber > 0) {
96
- /* 切换摸鱼目标:先关掉旧悬浮层再起一个新的 */
97
- if (floatRunning()) {
98
- try {
99
- floatState.child.kill('SIGTERM')
100
- } catch {
101
- /* ignore */
102
- }
103
- await new Promise((resolve) => setTimeout(resolve, 500))
104
- }
105
- } else if (floatRunning()) {
106
- return { running: true, pid: floatState.child.pid }
107
- }
108
- let webServer
109
- let connection
110
- try {
111
- webServer = ctx.get('webServer')
112
- connection = ctx.get('connection')
113
- } catch {
114
- /* ignore */
193
+ await killFloat()
194
+ } else if (await floatRunningAsync()) {
195
+ return { running: true, pid: (await listFloatPids())[0] ?? null }
115
196
  }
197
+ const webServer = ctx.get('webServer')
198
+ const connection = ctx.get('connection')
116
199
  if (webServer === undefined || webServer === null || connection === undefined || connection === null || typeof connection.authenticatedUrl !== 'function') {
117
200
  throw new ApiError('unavailable', '当前 Host 不提供 Web 服务地址,无法启动悬浮层', 500)
118
201
  }
119
202
  const base = `${webServer.protocol}//127.0.0.1:${String(webServer.port)}`
120
203
  const authUrl = connection.authenticatedUrl(`${base}/`)
121
204
  const payload = JSON.stringify({ authUrl, appUrl: `${base}/`, follow: follow !== null && follow.windowNumber > 0 ? follow : undefined })
122
- let child
123
- try {
124
- child = spawn(binary, [payload], { detached: true, stdio: 'ignore' })
125
- } catch (error) {
126
- throw new ApiError('spawn-failed', `悬浮层启动失败:${String(error && error.message || error)}`, 500)
127
- }
128
- child.unref()
129
- floatState.child = child
205
+ await openApp([payload])
206
+ await new Promise((resolve) => setTimeout(resolve, 300))
207
+ const pids = await listFloatPids()
130
208
  floatState.startedAt = Date.now()
131
- child.once('exit', () => {
132
- if (floatState.child === child) floatState.child = null
133
- })
134
- return { running: true, pid: child.pid ?? null }
209
+ return { running: pids.length > 0, pid: pids[0] ?? null }
135
210
  })
136
211
 
137
212
  router.method('float.stop', async () => {
138
- if (floatRunning()) {
139
- try {
140
- floatState.child.kill('SIGTERM')
141
- } catch {
142
- /* ignore */
143
- }
144
- }
145
- floatState.child = null
213
+ await killFloat()
146
214
  return { running: false }
147
215
  })
148
216
 
149
- router.method('dev.log', async (body) => {
150
- const message = body !== null && typeof body === 'object' && typeof body.message === 'string' ? body.message : ''
151
- if (message !== '') debugLog(message)
152
- return { ok: true }
153
- })
154
217
  router.method('dev.version', async () => ({
155
218
  name: 'dsh-gufa-code',
156
219
  version: '1.0.0',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env bash
2
- # 构建 macOS 悬浮层 helper(P0):Objective-C + AppKit + WebKit,避免本机 Swift/SDK 版本不匹配问题。
2
+ # 构建 macOS 悬浮层 helper(P0/P1):Objective-C + AppKit + WebKit。
3
+ # 产物 1:可直接启动的二进制(Host spawn 用)
4
+ # 产物 2:.app bundle(方便用户在「屏幕录制」隐私列表里手动添加)
3
5
  set -euo pipefail
4
6
  cd "$(dirname "$0")/.."
5
7
  mkdir -p desktop/float/bin
@@ -7,5 +9,31 @@ ARCH="$(uname -m)"
7
9
  OUT="desktop/float/bin/gufa-float-macos-${ARCH}"
8
10
  clang -fobjc-arc -O2 -framework AppKit -framework WebKit -framework Carbon -o "$OUT" desktop/float/GufaFloat.m
9
11
  chmod +x "$OUT"
10
- codesign --force --sign - "$OUT" >/dev/null 2>&1 || true
12
+ # 带稳定的 code identifier 签名(TCC 按它识别,避免每次构建都换身份字符串)
13
+ codesign --force --sign - -i com.gufa.float "$OUT" >/dev/null 2>&1 || true
14
+
15
+ APP="desktop/float/古法编程悬浮层.app"
16
+ rm -rf "$APP"
17
+ mkdir -p "$APP/Contents/MacOS"
18
+ cp "$OUT" "$APP/Contents/MacOS/gufa-float"
19
+ cat > "$APP/Contents/Info.plist" <<'PLIST'
20
+ <?xml version="1.0" encoding="UTF-8"?>
21
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
22
+ <plist version="1.0">
23
+ <dict>
24
+ <key>CFBundleIdentifier</key><string>com.gufa.float</string>
25
+ <key>CFBundleName</key><string>古法编程悬浮层</string>
26
+ <key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
27
+ <key>CFBundleExecutable</key><string>gufa-float</string>
28
+ <key>CFBundlePackageType</key><string>APPL</string>
29
+ <key>CFBundleShortVersionString</key><string>1.3.1</string>
30
+ <key>CFBundleVersion</key><string>1.3.1</string>
31
+ <key>LSUIElement</key><true/>
32
+ <key>NSHighResolutionCapable</key><true/>
33
+ <key>NSPrincipalClass</key><string>NSApplication</string>
34
+ </dict>
35
+ </plist>
36
+ PLIST
37
+ codesign --force --deep --sign - "$APP" >/dev/null 2>&1 || true
11
38
  echo "built: $OUT"
39
+ echo "built: $APP"
@@ -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
  }
@@ -2164,11 +2164,12 @@ G.GufaApp = function GufaApp(props) {
2164
2164
  'div',
2165
2165
  { className: 'gufa-float-permission' },
2166
2166
  h('div', { className: 'gufa-float-permission-title' }, '需要「屏幕录制」权限'),
2167
- h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App 的窗口尺寸(只读尺寸,不录屏)。请在「系统设置 → 隐私与安全性 → 屏幕录制」里勾选 **DeepSeek Harness**(若列表只显示自己,请重启一次 DeepSeek Harness 让权限生效),然后点「重试」。'),
2167
+ h('div', { className: 'gufa-hint' }, '摸鱼列表需要读取其他 App 的窗口尺寸(只读尺寸,不录屏)。系统只认悬浮层 App 自己的授权:请在「系统设置 → 隐私与安全性 → 屏幕录制」里点左下角「+」,添加「古法编程悬浮层.app」并打开开关(DeepSeek Harness 的开关也保持打开)。加好后点「重试」。'),
2168
2168
  h(
2169
2169
  'div',
2170
- { className: 'gufa-row', style: { gap: 8, marginTop: 12 } },
2170
+ { className: 'gufa-row', style: { gap: 8, marginTop: 12, flexWrap: 'wrap' } },
2171
2171
  h(G.Button, { primary: true, onClick: () => void G.api('float.openPrivacy').catch(() => {}) }, '打开系统设置'),
2172
+ h(G.Button, { onClick: () => void G.api('float.revealHelper').catch(() => {}) }, '在 Finder 中显示悬浮层 App'),
2172
2173
  h(G.Button, { onClick: () => void openFloatPicker() }, '重试'),
2173
2174
  ),
2174
2175
  )