dsh-gufa-code 1.3.10 → 1.3.49
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/README.md +19 -11
- package/client.js +670 -97
- package/desktop/float/GufaFloat.m +283 -29
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/docs/KNOWN-PITFALLS.md +61 -0
- package/docs/MODES.md +42 -0
- package/host/dev.js +125 -6
- package/package.json +1 -1
- package/scripts/build-client.mjs +5 -1
- package/scripts/build-float-macos.sh +43 -14
- package/src/client/00-core.js +121 -12
- package/src/client/30-terminal.js +51 -8
- package/src/client/55-backdrop.js +28 -4
- package/src/client/85-shortcuts.js +22 -16
- package/src/client/90-app.js +320 -44
- package/src/client/99-main.js +128 -13
|
@@ -328,7 +328,10 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
328
328
|
const canvasRef = useRef(null)
|
|
329
329
|
const strengthRaw = typeof props.strength === 'number' && Number.isFinite(props.strength) ? props.strength : 1
|
|
330
330
|
const strength = Math.max(0, Math.min(1, strengthRaw))
|
|
331
|
+
/* 摸鱼窗口里背景层是被 CSS 隐藏的:完全不要创建 canvas / 跑动画,省 CPU 与内存 */
|
|
332
|
+
const skipFloat = typeof G.isFloatMode === 'function' && G.isFloatMode() === true
|
|
331
333
|
useEffect(() => {
|
|
334
|
+
if (skipFloat) return undefined
|
|
332
335
|
const canvas = canvasRef.current
|
|
333
336
|
if (canvas === null || canvas === undefined) return undefined
|
|
334
337
|
const context = canvas.getContext('2d')
|
|
@@ -341,7 +344,7 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
341
344
|
}
|
|
342
345
|
if (reduced) return undefined
|
|
343
346
|
|
|
344
|
-
const dpr = Math.min(1.
|
|
347
|
+
const dpr = Math.min(1.25, window.devicePixelRatio || 1)
|
|
345
348
|
let width = 0
|
|
346
349
|
let height = 0
|
|
347
350
|
const resize = () => {
|
|
@@ -397,9 +400,11 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
397
400
|
const pointer = { x: -1e4, y: -1e4, down: false }
|
|
398
401
|
let last = 0
|
|
399
402
|
let raf = 0
|
|
403
|
+
let paused = document.visibilityState === 'hidden'
|
|
400
404
|
const tick = (now) => {
|
|
405
|
+
if (paused) { raf = 0; return }
|
|
401
406
|
raf = window.requestAnimationFrame(tick)
|
|
402
|
-
if (now - last <
|
|
407
|
+
if (now - last < 40) return
|
|
403
408
|
const dt = Math.min(0.048, (last === 0 ? 0.016 : (now - last) / 1000))
|
|
404
409
|
last = now
|
|
405
410
|
context.clearRect(0, 0, width, height)
|
|
@@ -456,13 +461,28 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
456
461
|
}
|
|
457
462
|
const onPointerDown = () => { pointer.down = true }
|
|
458
463
|
const onPointerUp = () => { pointer.down = false }
|
|
464
|
+
const resume = () => {
|
|
465
|
+
paused = false
|
|
466
|
+
last = 0
|
|
467
|
+
if (raf === 0) raf = window.requestAnimationFrame(tick)
|
|
468
|
+
}
|
|
469
|
+
const pause = () => {
|
|
470
|
+
paused = true
|
|
471
|
+
if (raf !== 0) { window.cancelAnimationFrame(raf); raf = 0 }
|
|
472
|
+
}
|
|
473
|
+
const onVisibility = () => { if (document.visibilityState === 'hidden') pause(); else resume() }
|
|
474
|
+
const onBlur = () => pause()
|
|
475
|
+
const onFocus = () => resume()
|
|
476
|
+
document.addEventListener('visibilitychange', onVisibility)
|
|
477
|
+
window.addEventListener('blur', onBlur)
|
|
478
|
+
window.addEventListener('focus', onFocus)
|
|
459
479
|
window.addEventListener('pointermove', onPointerMove)
|
|
460
480
|
window.addEventListener('pointerdown', onPointerDown)
|
|
461
481
|
window.addEventListener('pointerup', onPointerUp)
|
|
462
482
|
window.addEventListener('pointerleave', onPointerLeave)
|
|
463
483
|
window.addEventListener('resize', resize)
|
|
464
484
|
resize()
|
|
465
|
-
raf = window.requestAnimationFrame(tick)
|
|
485
|
+
if (!paused) raf = window.requestAnimationFrame(tick)
|
|
466
486
|
try {
|
|
467
487
|
void G.api('dev.log', { message: `particles-start count=${activeCount} size=2-5.2css dpr=${dpr} canvas=${width}x${height}` }).catch(() => {})
|
|
468
488
|
} catch {
|
|
@@ -470,13 +490,17 @@ G.BackdropParticles = function BackdropParticles(props) {
|
|
|
470
490
|
}
|
|
471
491
|
return () => {
|
|
472
492
|
if (raf !== 0) window.cancelAnimationFrame(raf)
|
|
493
|
+
document.removeEventListener('visibilitychange', onVisibility)
|
|
494
|
+
window.removeEventListener('blur', onBlur)
|
|
495
|
+
window.removeEventListener('focus', onFocus)
|
|
473
496
|
window.removeEventListener('pointermove', onPointerMove)
|
|
474
497
|
window.removeEventListener('pointerdown', onPointerDown)
|
|
475
498
|
window.removeEventListener('pointerup', onPointerUp)
|
|
476
499
|
window.removeEventListener('pointerleave', onPointerLeave)
|
|
477
500
|
window.removeEventListener('resize', resize)
|
|
478
501
|
}
|
|
479
|
-
}, [strength])
|
|
502
|
+
}, [strength, skipFloat])
|
|
503
|
+
if (skipFloat) return null
|
|
480
504
|
return h('canvas', { ref: canvasRef, className: 'gufa-backdrop-particles', 'aria-hidden': 'true', style: { mixBlendMode: 'screen' } })
|
|
481
505
|
}
|
|
482
506
|
|
|
@@ -278,21 +278,23 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
278
278
|
try {
|
|
279
279
|
if (typeof window !== 'undefined' && window !== null) {
|
|
280
280
|
if (wrapped.length < expected) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
service.__gufaIntegrationTimer
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
281
|
+
/* 累计尝试次数上限:配置变更会反复触发安装,不能每次都重新开 40 次重试(之前会变成常驻 2Hz 循环) */
|
|
282
|
+
if ((service.__gufaIntegrationAttempts ?? 0) < 40) {
|
|
283
|
+
if (service.__gufaIntegrationTimer === undefined || service.__gufaIntegrationTimer === null) {
|
|
284
|
+
service.__gufaIntegrationTimer = window.setInterval(() => {
|
|
285
|
+
service.__gufaIntegrationAttempts = (service.__gufaIntegrationAttempts ?? 0) + 1
|
|
286
|
+
if (service.__gufaIntegrationAttempts > 40) {
|
|
287
|
+
window.clearInterval(service.__gufaIntegrationTimer)
|
|
288
|
+
service.__gufaIntegrationTimer = null
|
|
289
|
+
return
|
|
290
|
+
}
|
|
291
|
+
try {
|
|
292
|
+
G.installShortcutIntegration(service)
|
|
293
|
+
} catch {
|
|
294
|
+
/* ignore */
|
|
295
|
+
}
|
|
296
|
+
}, 500)
|
|
297
|
+
}
|
|
296
298
|
}
|
|
297
299
|
} else {
|
|
298
300
|
if (service.__gufaIntegrationTimer !== undefined && service.__gufaIntegrationTimer !== null) {
|
|
@@ -414,7 +416,11 @@ G.installShortcutIntegration = function installShortcutIntegration(service) {
|
|
|
414
416
|
} catch {
|
|
415
417
|
edrvIds = []
|
|
416
418
|
}
|
|
417
|
-
|
|
419
|
+
const signature = `${JSON.stringify(wrapped)}|${totalCommands}|${configStatus}|${edrvIds.length}|${edrvBindings.length}`
|
|
420
|
+
if (service.__gufaLastIntegrationSignature !== signature) {
|
|
421
|
+
service.__gufaLastIntegrationSignature = signature
|
|
422
|
+
void G.api('dev.log', { message: `shortcut-integration wrapped=${JSON.stringify(wrapped)} total=${totalCommands} configStatus=${configStatus} edrv=${JSON.stringify(edrvIds).slice(0, 1500)} edrvBindings=${JSON.stringify(edrvBindings).slice(0, 2500)}` }).catch(() => {})
|
|
423
|
+
}
|
|
418
424
|
} catch {
|
|
419
425
|
/* ignore */
|
|
420
426
|
}
|