@laraveladmin/dsh-stay-awake 0.3.0 → 0.3.1
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/CHANGELOG.md +12 -0
- package/client.js +90 -8
- package/docs/VERIFICATION.md +13 -0
- package/market/index.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# 变更记录 · Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.1 — 2026-12-03
|
|
4
|
+
|
|
5
|
+
### 修复
|
|
6
|
+
|
|
7
|
+
- 窗口缩小后弹层位置偶尔不对:CSS anchor positioning 只把弹层「绑」在触发点上,并不保证它落在视口内——
|
|
8
|
+
`left` 锚定触发点会让宽面板溢出右边缘,`@position-try` 回退又只改纵向。现在改为**测量后定位**:
|
|
9
|
+
打开时、窗口 resize、composer 滚动、弹层自身尺寸变化(状态行、语言切换、提示)都会重新计算,
|
|
10
|
+
取「优先在触发点上方、放不下就放下方」,左右按视口 12px 边距夹紧;触发点被窄屏布局隐藏或滚出视口时
|
|
11
|
+
回退到输入框上方居中;高度超过视口时改为内部滚动。
|
|
12
|
+
- 定位完成前弹层 `visibility:hidden`,避免先画在错误位置再跳一下。
|
|
13
|
+
|
|
14
|
+
|
|
3
15
|
## 0.3.0 — 2026-12-03
|
|
4
16
|
|
|
5
17
|
### 新功能:断网自动重试
|
package/client.js
CHANGED
|
@@ -202,19 +202,15 @@ window.__ModuleLoader__.load({
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
const CSS = `
|
|
205
|
-
.dsa-pill{box-sizing:border-box;border-radius:var(--dsw-radius-sm);max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;align-items:center;gap:6px;padding:1px 8px;display:inline-flex;cursor:pointer
|
|
205
|
+
.dsa-pill{box-sizing:border-box;border-radius:var(--dsw-radius-sm);max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;align-items:center;gap:6px;padding:1px 8px;display:inline-flex;cursor:pointer}
|
|
206
206
|
.dsa-pill[aria-expanded="true"]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}
|
|
207
207
|
@media (hover:hover){.dsa-pill:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}}
|
|
208
208
|
.dsa-pill:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}
|
|
209
209
|
.dsa-pill svg{flex:none;width:14px;height:14px}
|
|
210
210
|
.dsa-label{text-overflow:ellipsis;min-width:0;overflow:hidden}
|
|
211
211
|
.dsa-dot{width:5px;height:5px;border-radius:50%;flex:none}
|
|
212
|
-
.dsa-panel{position:fixed;
|
|
213
|
-
|
|
214
|
-
.dsa-panel{position-anchor:--dsh-stay-awake-panel;top:auto;bottom:max(12px, calc(anchor(top) + 8px));left:max(12px, anchor(left));right:auto;transform:none;height:fit-content;max-height:calc(100dvh - 24px);position-try-fallbacks:--dsa-below, --dsa-wide}
|
|
215
|
-
}
|
|
216
|
-
@position-try --dsa-below{top:max(12px, calc(anchor(bottom) + 8px));bottom:auto}
|
|
217
|
-
@position-try --dsa-wide{left:12px;right:12px;justify-self:stretch}
|
|
212
|
+
.dsa-panel{position:fixed;z-index:1100;box-sizing:border-box;height:fit-content;min-height:0;border:0;border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-secondary);width:max-content;min-width:min(300px,100vw - 24px);max-width:min(440px,100vw - 24px);max-height:calc(100dvh - 24px);overflow:hidden auto;margin:0;padding:16px;font-size:12px;line-height:18px;cursor:default;pointer-events:auto;text-align:left;visibility:hidden}
|
|
213
|
+
.dsa-panel[data-positioned="true"]{visibility:visible}
|
|
218
214
|
.dsa-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:8px;color:var(--dsw-alias-label-primary);font-weight:500}
|
|
219
215
|
.dsa-head-label{display:inline-flex;align-items:center;gap:6px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
220
216
|
.dsa-head-label svg{flex:none;width:14px;height:14px}
|
|
@@ -378,6 +374,59 @@ window.__ModuleLoader__.load({
|
|
|
378
374
|
return { text: `\u2713 ${t('panel.saved')}` }
|
|
379
375
|
}
|
|
380
376
|
|
|
377
|
+
const useLayoutEffect = typeof React.useLayoutEffect === 'function' ? React.useLayoutEffect : React.useEffect
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Place the popover above its trigger, clamped to the viewport.
|
|
381
|
+
*
|
|
382
|
+
* CSS anchor positioning kept the panel attached but did not keep it inside
|
|
383
|
+
* a smaller window: anchoring `left` to the trigger let a wide panel run
|
|
384
|
+
* off the right edge, and the `@position-try` fallbacks only moved it
|
|
385
|
+
* vertically. Measuring here means a resized window, a scrolled composer
|
|
386
|
+
* and a re-wrapped toolbar all end with the panel fully on screen.
|
|
387
|
+
* @param {HTMLElement} panel
|
|
388
|
+
*/
|
|
389
|
+
function placePanel(panel) {
|
|
390
|
+
const doc = globalThis.document
|
|
391
|
+
const win = globalThis.window
|
|
392
|
+
if (!panel || !doc || !win) return
|
|
393
|
+
const viewportW = win.innerWidth || doc.documentElement?.clientWidth || 0
|
|
394
|
+
const viewportH = win.innerHeight || doc.documentElement?.clientHeight || 0
|
|
395
|
+
if (viewportW === 0 || viewportH === 0) return
|
|
396
|
+
const margin = 12
|
|
397
|
+
const gap = 8
|
|
398
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max)
|
|
399
|
+
// The height cap belongs to the viewport, not to the content: a taller
|
|
400
|
+
// panel scrolls instead of poking out of a short window.
|
|
401
|
+
panel.style.maxHeight = `${Math.max(160, viewportH - margin * 2)}px`
|
|
402
|
+
const width = panel.offsetWidth
|
|
403
|
+
const height = panel.offsetHeight
|
|
404
|
+
const trigger = doc.querySelector('[data-dsa-anchor="stay-awake"]')
|
|
405
|
+
const rect = trigger && typeof trigger.getBoundingClientRect === 'function' ? trigger.getBoundingClientRect() : null
|
|
406
|
+
const anchored = rect !== null && (rect.width > 0 || rect.height > 0)
|
|
407
|
+
&& rect.bottom > 0 && rect.top < viewportH
|
|
408
|
+
let left
|
|
409
|
+
let top
|
|
410
|
+
if (anchored) {
|
|
411
|
+
left = clamp(rect.left, margin, Math.max(margin, viewportW - width - margin))
|
|
412
|
+
const above = rect.top - gap - height
|
|
413
|
+
if (above >= margin) {
|
|
414
|
+
top = above
|
|
415
|
+
} else {
|
|
416
|
+
const below = rect.bottom + gap
|
|
417
|
+
top = below + height <= viewportH - margin ? below : Math.max(margin, viewportH - height - margin)
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
// Trigger hidden (narrow layout) or scrolled away: stay reachable above
|
|
421
|
+
// the composer instead of anchoring to a zero-sized box.
|
|
422
|
+
left = clamp(Math.round((viewportW - width) / 2), margin, Math.max(margin, viewportW - width - margin))
|
|
423
|
+
top = Math.max(margin, viewportH - height - 120)
|
|
424
|
+
}
|
|
425
|
+
panel.style.left = `${Math.round(left)}px`
|
|
426
|
+
panel.style.top = `${Math.round(Math.max(margin, top))}px`
|
|
427
|
+
panel.dataset.positioned = 'true'
|
|
428
|
+
}
|
|
429
|
+
|
|
381
430
|
function Moon({ color }) {
|
|
382
431
|
return h(
|
|
383
432
|
'svg',
|
|
@@ -455,6 +504,7 @@ window.__ModuleLoader__.load({
|
|
|
455
504
|
{
|
|
456
505
|
type: 'button',
|
|
457
506
|
className: 'dsa-pill dsa-root',
|
|
507
|
+
'data-dsa-anchor': 'stay-awake',
|
|
458
508
|
'aria-expanded': snapshot.open === true,
|
|
459
509
|
'aria-haspopup': 'dialog',
|
|
460
510
|
onClick: () => store.toggle(),
|
|
@@ -476,6 +526,38 @@ window.__ModuleLoader__.load({
|
|
|
476
526
|
function Panel({ store, t, act }) {
|
|
477
527
|
const snapshot = useStore(store)
|
|
478
528
|
const open = snapshot.open === true
|
|
529
|
+
const panelRef = React.useRef(null)
|
|
530
|
+
|
|
531
|
+
// Reposition on open, on viewport changes, on composer scroll and when
|
|
532
|
+
// the panel's own size changes (status rows, locale switch, notice).
|
|
533
|
+
useLayoutEffect(() => {
|
|
534
|
+
if (!open) return undefined
|
|
535
|
+
const panel = panelRef.current
|
|
536
|
+
if (panel === null) return undefined
|
|
537
|
+
let frame = 0
|
|
538
|
+
const schedule = () => {
|
|
539
|
+
if (frame !== 0) return
|
|
540
|
+
if (typeof globalThis.requestAnimationFrame === 'function') {
|
|
541
|
+
frame = globalThis.requestAnimationFrame(() => {
|
|
542
|
+
frame = 0
|
|
543
|
+
placePanel(panel)
|
|
544
|
+
})
|
|
545
|
+
} else {
|
|
546
|
+
placePanel(panel)
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
placePanel(panel)
|
|
550
|
+
const observer = typeof globalThis.ResizeObserver === 'function' ? new globalThis.ResizeObserver(schedule) : null
|
|
551
|
+
observer?.observe(panel)
|
|
552
|
+
globalThis.window?.addEventListener('resize', schedule)
|
|
553
|
+
globalThis.window?.addEventListener('scroll', schedule, true)
|
|
554
|
+
return () => {
|
|
555
|
+
observer?.disconnect()
|
|
556
|
+
globalThis.window?.removeEventListener('resize', schedule)
|
|
557
|
+
globalThis.window?.removeEventListener('scroll', schedule, true)
|
|
558
|
+
if (frame !== 0 && typeof globalThis.cancelAnimationFrame === 'function') globalThis.cancelAnimationFrame(frame)
|
|
559
|
+
}
|
|
560
|
+
}, [open])
|
|
479
561
|
useTick(open)
|
|
480
562
|
const status = snapshot.status
|
|
481
563
|
const failures = snapshot.failures
|
|
@@ -549,7 +631,7 @@ window.__ModuleLoader__.load({
|
|
|
549
631
|
|
|
550
632
|
return h(
|
|
551
633
|
'div',
|
|
552
|
-
{ className: 'dsa-panel', role: 'dialog', 'aria-label': t('brand') },
|
|
634
|
+
{ className: 'dsa-panel', role: 'dialog', 'aria-label': t('brand'), ref: panelRef },
|
|
553
635
|
stylesheet === null ? h('style', { key: 'css' }, CSS) : null,
|
|
554
636
|
h(
|
|
555
637
|
'div',
|
package/docs/VERIFICATION.md
CHANGED
|
@@ -211,6 +211,19 @@
|
|
|
211
211
|
| 提问/审批提醒音实际听感 | 需要宿主重启加载新代码并真实触发一次 `ask_user_question` 或审批;本进程内无法重启宿主 | 用户重启后提问一次即可确认 |
|
|
212
212
|
| 繁体中文在 DSH 语言列表中出现并可选中 | `addLanguage` 注册成功后由 DSH 的「语言」设置行渲染,本会话无浏览器控制权 | 重启后在 设置 → 语言 中查看「繁體中文」 |
|
|
213
213
|
|
|
214
|
+
## 0.3.1 弹层定位改为测量后夹紧(2026-12-03)
|
|
215
|
+
|
|
216
|
+
- **问题**:窗口缩小后弹层位置偶尔不对。根因是 CSS anchor positioning 的语义:`bottom: anchor(top)`
|
|
217
|
+
保证纵向跟随,`left: max(12px, anchor(left))` 只保证贴住触发点左缘——面板 `width: max-content`
|
|
218
|
+
(最大 440px)在窄窗口下会直接溢出右边缘;`@position-try` 的两个回退只改纵向/或依赖
|
|
219
|
+
`justify-self: stretch`(对 `position: fixed` 不生效),所以「有时候」不生效。
|
|
220
|
+
- **改法**:`placePanel()` 用 `getBoundingClientRect()` 测量触发点与弹层,按 `12px` 视口边距夹紧
|
|
221
|
+
`left/top`:优先放触发点上方(间距 8px),放不下放下方,仍放不下则贴边并让弹层内部滚动;
|
|
222
|
+
触发点不可见(窄屏布局隐藏 / 已滚出视口)时回退到输入框上方居中。`useLayoutEffect` 在首帧绘制前
|
|
223
|
+
完成定位(定位前 `visibility: hidden`),并监听 `resize`、捕获阶段 `scroll` 与 `ResizeObserver`。
|
|
224
|
+
- 自动化:纯前端改动,109 项测试保持全绿;`node --check` 通过。
|
|
225
|
+
- 未验证:窄窗口、反复缩放、滚动后的观感需要刷新页面后目视确认(本会话无浏览器控制权)。
|
|
226
|
+
|
|
214
227
|
## 未验证(明确记录,不代替验证)
|
|
215
228
|
|
|
216
229
|
| ID / 项 | 原因 | 何时可验 |
|
package/market/index.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laraveladmin/dsh-stay-awake",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "DeepSeek Harness plugin that keeps the machine awake only while unattended work runs, and retries the turn that died with the network once it is back.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh-plugin",
|