dsh-gufa-code 1.3.9 → 1.3.48

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.
@@ -231,6 +231,23 @@ const GUFA_PLUGIN = {
231
231
  if (floatMode) {
232
232
  document.documentElement.setAttribute('data-gufa-float', '1')
233
233
  document.documentElement.setAttribute('data-gufa-booting', '1')
234
+ /* 摸鱼窗口不需要皮肤:关掉皮肤插件的动画开关并移除其背景节点,
235
+ 否则它仍在 rAF 里持续写 body.style / 画 canvas(看不见但耗 CPU、占内存) */
236
+ const disableSkin = () => {
237
+ try {
238
+ const root = document.documentElement
239
+ if (root.getAttribute('data-liang-skin') === 'on') root.setAttribute('data-liang-skin', 'off')
240
+ root.removeAttribute('data-liang-stage')
241
+ root.removeAttribute('data-gufa-skin-live')
242
+ for (const node of document.querySelectorAll('.liang-skin-backdrop, .liang-ambient, .liang-skin-portrait, .liang-skin-root')) {
243
+ node.remove()
244
+ }
245
+ } catch {
246
+ /* ignore */
247
+ }
248
+ }
249
+ disableSkin()
250
+ for (const delay of [400, 1200, 2600, 5000]) window.setTimeout(disableSkin, delay)
234
251
  let attempts = 0
235
252
  const timer = window.setInterval(() => {
236
253
  attempts += 1
@@ -244,10 +261,100 @@ const GUFA_PLUGIN = {
244
261
  window.clearInterval(timer)
245
262
  /* 显式恢复主窗口状态(项目 → 标签页 → 会话),避免依赖 Web 版 App 的启动时序 */
246
263
  try {
264
+ /* 诊断:找出某个点上所有「会画背景」的元素(含 pointer-events:none 的覆盖层) */
265
+ try {
266
+ const describe = (el) => {
267
+ const cs = window.getComputedStyle(el)
268
+ const cls = typeof el.className === 'string' ? el.className.replace(/\s+/g, '.').slice(0, 32) : ''
269
+ const r = el.getBoundingClientRect()
270
+ return `${el.tagName.toLowerCase()}.${cls}[bg=${cs.backgroundColor} op=${cs.opacity} z=${cs.zIndex} pe=${cs.pointerEvents} bf=${cs.backdropFilter !== 'none' ? 'Y' : ''} img=${cs.backgroundImage !== 'none' ? 'Y' : ''}]@${Math.round(r.left)},${Math.round(r.top)} ${Math.round(r.width)}x${Math.round(r.height)}`
271
+ }
272
+ const paintersAt = (x, y) => {
273
+ const out = []
274
+ for (const el of document.querySelectorAll('body *')) {
275
+ const r = el.getBoundingClientRect()
276
+ if (!(x >= r.left && x <= r.right && y >= r.top && y <= r.bottom)) continue
277
+ const cs = window.getComputedStyle(el)
278
+ if (cs.backgroundColor !== 'rgba(0, 0, 0, 0)' || cs.backgroundImage !== 'none' || cs.backdropFilter !== 'none') {
279
+ out.push(describe(el) + (el.closest('.gufa-overlay-root') === null ? ' [OUTSIDE]' : ''))
280
+ if (out.length >= 18) break
281
+ }
282
+ }
283
+ return out.join(' || ')
284
+ }
285
+ const w = window.innerWidth
286
+ const h = window.innerHeight
287
+ void G.api('dev.log', { message: `float-painters chat=[${paintersAt(Math.round(w * 0.92), Math.round(h * 0.35))}]` }).catch(() => {})
288
+ } catch {
289
+ /* ignore */
290
+ }
291
+ /* 诊断:从像素点反查元素链,找出右侧会话框多出来的深色层 */
292
+ try {
293
+ const desc = (el) => {
294
+ if (el === null || el === undefined) return 'null'
295
+ const cs = window.getComputedStyle(el)
296
+ const cls = typeof el.className === 'string' ? el.className.replace(/\s+/g, '.').slice(0, 40) : ''
297
+ const img = cs.backgroundImage === 'none' ? '' : ` img=${cs.backgroundImage.slice(0, 50)}`
298
+ const bf = cs.backdropFilter === 'none' ? '' : ` bf=${cs.backdropFilter}`
299
+ return `${el.tagName.toLowerCase()}.${cls}[bg=${cs.backgroundColor} op=${cs.opacity}${img}${bf}]`
300
+ }
301
+ const chain = (x, y) => {
302
+ let el = document.elementFromPoint(x, y)
303
+ const parts = []
304
+ for (let i = 0; i < 7 && el !== null; i += 1) {
305
+ parts.push(desc(el))
306
+ const before = window.getComputedStyle(el, '::before').backgroundColor
307
+ if (before !== 'rgba(0, 0, 0, 0)' && before !== 'transparent') parts.push(`::before=${before}`)
308
+ el = el.parentElement
309
+ }
310
+ return parts.join(' <- ')
311
+ }
312
+ const w = window.innerWidth
313
+ const h = window.innerHeight
314
+ void G.api('dev.log', {
315
+ message: `float-probe editor=[${chain(Math.round(w * 0.45), Math.round(h * 0.55))}] chat=[${chain(Math.round(w * 0.92), Math.round(h * 0.4))}]`,
316
+ }).catch(() => {})
317
+ } catch {
318
+ /* ignore */
319
+ }
320
+ /* 诊断:找出会话框里非透明的背景元素(排查透明度不一致) */
321
+ try {
322
+ const chat = document.querySelector('.gufa-chatpane')
323
+ const found = []
324
+ if (chat !== null) {
325
+ for (const el of chat.querySelectorAll('*')) {
326
+ const bg = window.getComputedStyle(el).backgroundColor
327
+ if (bg !== 'rgba(0, 0, 0, 0)' && bg !== 'transparent') {
328
+ found.push(`${el.tagName.toLowerCase()}.${String(el.className || '').replace(/\s+/g, '.').slice(0, 60)}=${bg}`)
329
+ if (found.length >= 10) break
330
+ }
331
+ }
332
+ }
333
+ void G.api('dev.log', { message: `float-chat-bgs ${found.join(' | ') || 'none'}` }).catch(() => {})
334
+ } catch {
335
+ /* ignore */
336
+ }
337
+ /* 诊断:摸鱼窗口里各面板的实际底色(排查透明度不一致) */
338
+ try {
339
+ const pick = (sel) => {
340
+ const el = document.querySelector(sel)
341
+ if (el === null) return `${sel}=none`
342
+ const cs = window.getComputedStyle(el)
343
+ return `${sel}=${cs.backgroundColor}/${cs.opacity}`
344
+ }
345
+ const root = document.querySelector('.gufa-root')
346
+ void G.api('dev.log', {
347
+ message: `float-styles backdrop=${root === null ? '?' : root.getAttribute('data-backdrop')} ${pick('.gufa-overlay-root')} ${pick('.gufa-editor-area')} ${pick('.gufa-chatpane')} ${pick('.gufa-termpane')} ${pick('.gufa-termhead')} ${pick('.gufa-sidepanel')} ${pick('.gufa-main')} alphaVar=${window.getComputedStyle(document.documentElement).getPropertyValue('--gufa-float-alpha')}`,
348
+ }).catch(() => {})
349
+ } catch {
350
+ /* ignore */
351
+ }
352
+ void G.api('dev.log', { message: `float-boot hasState=${G.floatState !== null && G.floatState !== undefined} restoreRef=${G.floatRestoreRef !== null && G.floatRestoreRef !== undefined} state=${G.floatState === null || G.floatState === undefined ? 'null' : JSON.stringify({ projectRoot: G.floatState.projectRoot, tabs: Array.isArray(G.floatState.tabs) ? G.floatState.tabs.length : 0, activePath: G.floatState.activePath })}` }).catch(() => {})
247
353
  if (window.__gufaFloatRestored !== true && G.floatState !== null && G.floatState !== undefined) {
248
354
  window.__gufaFloatRestored = true
249
355
  void (async () => {
250
356
  const state = G.floatState
357
+ const paths = Array.isArray(state.tabs) ? state.tabs.filter((path) => typeof path === 'string' && path !== '') : []
251
358
  let projectValue = null
252
359
  if (typeof state.projectRoot === 'string' && state.projectRoot !== '') {
253
360
  try {
@@ -259,20 +366,28 @@ const GUFA_PLUGIN = {
259
366
  const restore = G.floatRestoreRef
260
367
  if (projectValue !== null && restore !== null && restore !== undefined && typeof restore.applyProject === 'function') {
261
368
  restore.applyProject(projectValue)
369
+ void G.api('dev.log', { message: `float-restore project=${String(projectValue.root)} tabs=${paths.length}` }).catch(() => {})
370
+ } else {
371
+ void G.api('dev.log', { message: `float-restore-failed projectValue=${projectValue === null ? 'null' : 'ok'} ref=${restore !== null && restore !== undefined}` }).catch(() => {})
262
372
  }
263
- await new Promise((resolve) => setTimeout(resolve, 350))
264
- const paths = Array.isArray(state.tabs) ? state.tabs.filter((path) => typeof path === 'string' && path !== '') : []
265
- const ordered = typeof state.activePath === 'string' && state.activePath !== ''
266
- ? paths.filter((path) => path !== state.activePath).concat([state.activePath])
267
- : paths
268
- const openFile = restore !== null && restore !== undefined && typeof restore.openFile === 'function' ? restore.openFile : null
269
- if (openFile !== null) {
373
+ /* 先恢复 UI 面板状态(终端/视图等) */
374
+ try {
375
+ if (typeof G.floatApplyUiRef === 'function' && state.ui !== null && typeof state.ui === 'object') G.floatApplyUiRef(state.ui)
376
+ } catch {
377
+ /* ignore */
378
+ }
379
+ await new Promise((resolve) => setTimeout(resolve, 500))
380
+ /* 按快照里的标签顺序打开,最后再激活 activePath,避免顺序漂移 */
381
+ const ordered = paths
382
+ const activeOne = typeof state.activePath === 'string' && state.activePath !== '' ? state.activePath : null
383
+ /* 关键:applyProject 之后 App 已重渲染,取最新恢复入口;优先原子恢复标签集合 */
384
+ await new Promise((resolve) => setTimeout(resolve, 250))
385
+ const latest = G.floatRestoreRef
386
+ if (latest !== null && latest !== undefined && typeof latest.applyTabs === 'function') {
387
+ await latest.applyTabs(ordered, activeOne)
388
+ } else if (latest !== null && latest !== undefined && typeof latest.openFile === 'function') {
270
389
  for (const path of ordered.slice(0, 10)) {
271
- try {
272
- await openFile(path)
273
- } catch {
274
- /* ignore */
275
- }
390
+ try { await latest.openFile(path) } catch { /* ignore */ }
276
391
  }
277
392
  }
278
393
  if (typeof state.sessionId === 'string' && state.sessionId !== '') {
@@ -392,7 +507,7 @@ const GUFA_PLUGIN = {
392
507
  try {
393
508
  const transport = typeof globalThis.__DSH_TRANSPORT__ === 'object' && globalThis.__DSH_TRANSPORT__ !== null ? globalThis.__DSH_TRANSPORT__ : null
394
509
  void G.api('dev.log', {
395
- message: `boot href=${location.href} base=${G.serverBase()} transport=${transport === null ? 'none' : JSON.stringify(transport)}`,
510
+ message: `boot build=${G.BUILD || '?'} href=${location.href} base=${G.serverBase()} transport=${transport === null ? 'none' : JSON.stringify(transport)}`,
396
511
  }).catch(() => {})
397
512
  } catch {
398
513
  /* 诊断失败不影响启动 */