@laraveladmin/dsh-stay-awake 0.2.11 → 0.2.13
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 +33 -0
- package/client.js +54 -8
- package/docs/RELEASING.md +1 -1
- package/docs/VERIFICATION.md +26 -0
- package/lib/server.js +11 -3
- package/lib/sound.js +7 -3
- package/market/index.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# 变更记录 · Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.13 — 2026-12-03
|
|
4
|
+
|
|
5
|
+
### 优化
|
|
6
|
+
|
|
7
|
+
- 操作反馈不再新增一行:试听/保存的结果改为替换弹层底部那行说明文字(`✓ 试听已播放`、`✓ 已保存`,
|
|
8
|
+
失败用宿主错误色),160ms 淡入 + 上移 2px,2.5 秒后切回原说明。弹层是 `height: fit-content` 且底部
|
|
9
|
+
锚定,之前每点一次都会把面板顶边顶高一截,现在高度恒定、不再跳动。
|
|
10
|
+
- 「试听失败」缩短为「没有可用的播放器」,完整文案放进 `title`;状态行加 `role="status"` 与
|
|
11
|
+
`aria-live="polite"`,读屏也会播报。
|
|
12
|
+
- 按钮补 `:active` 按压反馈(宿主 `--dsw-alias-interactive-bg-hover`)。
|
|
13
|
+
- 顶部「宿主未加载最新版本」这类持久错误保持原位:它不是瞬态反馈,2.5 秒后消失反而有害。
|
|
14
|
+
|
|
15
|
+
### 测试
|
|
16
|
+
|
|
17
|
+
- 81 项单测/接线测试保持全绿;`node --check` 通过。
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## 0.2.12 — 2026-12-03
|
|
21
|
+
|
|
22
|
+
### 修复
|
|
23
|
+
|
|
24
|
+
- 弹层「试听」点击后错误地显示「已保存」:它和开关共用同一条成功提示。现在按结果提示
|
|
25
|
+
「试听已播放」或「试听失败:当前系统没有可用的提示音播放器」,并且提示不再挂在「临时保持」
|
|
26
|
+
区块下方,而是显示在开关区下面。
|
|
27
|
+
- 「试听」绕过宿主端 1 秒节流:连续点击都会立刻响,符合 FR-10.14「任何时候都能验证设备与音量」。
|
|
28
|
+
- 宿主回包新增 `testSound: played|unavailable`,前端据此判断,不再假定成功。
|
|
29
|
+
|
|
30
|
+
### 测试
|
|
31
|
+
|
|
32
|
+
- 新增 2 项:服务端试听「已播放 / 不可用」两种回包;音频模块 `force` 绕过节流。
|
|
33
|
+
- 单测总数 79 → 81。
|
|
34
|
+
|
|
35
|
+
|
|
3
36
|
## 0.2.11 — 2026-12-03
|
|
4
37
|
|
|
5
38
|
### 文档与发布流程
|
package/client.js
CHANGED
|
@@ -62,6 +62,8 @@ window.__ModuleLoader__.load({
|
|
|
62
62
|
'panel.holdCancel': '取消',
|
|
63
63
|
'panel.sound': '完成提示音',
|
|
64
64
|
'panel.testSound': '试听',
|
|
65
|
+
'panel.testPlayed': '试听已播放',
|
|
66
|
+
'panel.testUnavailable': '试听失败:没有可用的播放器',
|
|
65
67
|
'panel.holdDisabled': '总开关关闭时无法临时保持',
|
|
66
68
|
'panel.holdLeft': '剩余',
|
|
67
69
|
'panel.saved': '已保存',
|
|
@@ -109,6 +111,8 @@ window.__ModuleLoader__.load({
|
|
|
109
111
|
'panel.holdCancel': 'Cancel',
|
|
110
112
|
'panel.sound': 'Completion sound',
|
|
111
113
|
'panel.testSound': 'Test',
|
|
114
|
+
'panel.testPlayed': 'Test sound played',
|
|
115
|
+
'panel.testUnavailable': 'Test failed: no player found',
|
|
112
116
|
'panel.holdDisabled': 'Enable the plugin first to hold',
|
|
113
117
|
'panel.holdLeft': 'left',
|
|
114
118
|
'panel.saved': 'Saved',
|
|
@@ -157,10 +161,15 @@ window.__ModuleLoader__.load({
|
|
|
157
161
|
.dsa-switch:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}
|
|
158
162
|
.dsa-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}
|
|
159
163
|
.dsa-button{border:0;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);border-radius:var(--dsw-radius-sm);padding:4px 10px;cursor:pointer;font:inherit;line-height:16px}
|
|
164
|
+
.dsa-button:active:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}
|
|
160
165
|
.dsa-button:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
161
166
|
.dsa-button:disabled{opacity:.5;cursor:default}
|
|
162
167
|
.dsa-button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}
|
|
163
168
|
.dsa-note{color:var(--dsw-alias-label-tertiary);margin-top:8px}
|
|
169
|
+
.dsa-status{animation:dsa-status-in .16s ease-out}
|
|
170
|
+
@keyframes dsa-status-in{from{opacity:0;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}
|
|
171
|
+
.dsa-ok{color:var(--dsw-alias-label-secondary)}
|
|
172
|
+
@media (prefers-reduced-motion:reduce){.dsa-status{animation:none}}
|
|
164
173
|
.dsa-error{color:var(--dsw-alias-state-error-primary)}
|
|
165
174
|
.dsa-foot{display:flex;gap:10px;align-items:center;margin-top:14px;padding-top:10px;border-top:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
|
|
166
175
|
.dsa-foot .dsa-grow{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
@@ -257,6 +266,26 @@ window.__ModuleLoader__.load({
|
|
|
257
266
|
return null
|
|
258
267
|
}
|
|
259
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Transient feedback, rendered by replacing the footer's hint line instead
|
|
271
|
+
* of adding a row: the panel is bottom-anchored with `height: fit-content`,
|
|
272
|
+
* so a new row moved its top edge on every click. `stale` is not transient
|
|
273
|
+
* (it asks the user to restart something) and keeps its own persistent row.
|
|
274
|
+
*/
|
|
275
|
+
function noticeStatus(t, snapshot) {
|
|
276
|
+
const notice = snapshot.notice
|
|
277
|
+
if (notice === null || notice === undefined || notice === 'stale') return null
|
|
278
|
+
if (notice === 'testPlayed') return { text: `\u2713 ${t('panel.testPlayed')}` }
|
|
279
|
+
if (notice === 'testUnavailable') return { text: t('panel.testUnavailable'), tone: 'error' }
|
|
280
|
+
if (notice === 'failed') {
|
|
281
|
+
return {
|
|
282
|
+
text: `${t('panel.saveFailed')}${snapshot.noticeStatus ? ` (${snapshot.noticeStatus})` : ''}`,
|
|
283
|
+
tone: 'error',
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return { text: `\u2713 ${t('panel.saved')}` }
|
|
287
|
+
}
|
|
288
|
+
|
|
260
289
|
function Moon({ color }) {
|
|
261
290
|
return h(
|
|
262
291
|
'svg',
|
|
@@ -403,6 +432,8 @@ window.__ModuleLoader__.load({
|
|
|
403
432
|
const reason = status !== null && !unreachable ? errorInfo(t, status) : null
|
|
404
433
|
if (reason !== null) rows.push([t('detail.error'), reason.text, reason.raw])
|
|
405
434
|
|
|
435
|
+
const notice = noticeStatus(t, snapshot)
|
|
436
|
+
|
|
406
437
|
const switchOf = (checked, onClick, label, extraDisabled = false) => h('button', {
|
|
407
438
|
type: 'button',
|
|
408
439
|
className: 'dsa-switch',
|
|
@@ -498,16 +529,19 @@ window.__ModuleLoader__.load({
|
|
|
498
529
|
onClick: () => act({ action: 'cancel-hold' }),
|
|
499
530
|
}, t('panel.holdCancel')),
|
|
500
531
|
),
|
|
501
|
-
snapshot.notice === 'saved'
|
|
502
|
-
? h('div', { className: 'dsa-note' }, t('panel.saved'))
|
|
503
|
-
: snapshot.notice === 'failed'
|
|
504
|
-
? h('div', { className: 'dsa-note dsa-error' }, `${t('panel.saveFailed')}${snapshot.noticeStatus ? ` (${snapshot.noticeStatus})` : ''}`)
|
|
505
|
-
: null,
|
|
506
532
|
),
|
|
507
533
|
h(
|
|
508
534
|
'div',
|
|
509
535
|
{ className: 'dsa-foot', key: 'foot' },
|
|
510
|
-
h('span', {
|
|
536
|
+
h('span', {
|
|
537
|
+
// Remounted on every notice change so the entry animation replays;
|
|
538
|
+
// the line keeps its height either way, so the panel never resizes.
|
|
539
|
+
key: notice === null ? 'hint' : `notice:${snapshot.notice}`,
|
|
540
|
+
className: `dsa-grow dsa-status${notice === null ? '' : notice.tone === 'error' ? ' dsa-error' : ' dsa-ok'}`,
|
|
541
|
+
role: 'status',
|
|
542
|
+
'aria-live': 'polite',
|
|
543
|
+
title: notice === null ? t('panel.advanced') : notice.text,
|
|
544
|
+
}, notice === null ? t('panel.advanced') : notice.text),
|
|
511
545
|
h('a', {
|
|
512
546
|
className: 'dsa-icon-link',
|
|
513
547
|
href: REPO_URL,
|
|
@@ -627,8 +661,11 @@ window.__ModuleLoader__.load({
|
|
|
627
661
|
let noticeTimer = null
|
|
628
662
|
function flashNotice(notice, noticeStatus) {
|
|
629
663
|
if (noticeTimer !== null) globalThis.clearTimeout(noticeTimer)
|
|
664
|
+
noticeTimer = null
|
|
630
665
|
store.set({ notice, noticeStatus })
|
|
631
|
-
|
|
666
|
+
// `stale` and `failed` stay until the next action; everything else is
|
|
667
|
+
// an acknowledgement of a click and clears itself.
|
|
668
|
+
if (notice !== 'stale' && notice !== 'failed') {
|
|
632
669
|
noticeTimer = globalThis.setTimeout(() => {
|
|
633
670
|
noticeTimer = null
|
|
634
671
|
store.set({ notice: null, noticeStatus: null })
|
|
@@ -636,6 +673,15 @@ window.__ModuleLoader__.load({
|
|
|
636
673
|
}
|
|
637
674
|
}
|
|
638
675
|
|
|
676
|
+
/**
|
|
677
|
+
* `test-sound` answers with whether a player was spawned, so the note
|
|
678
|
+
* says what happened instead of claiming a preference was saved.
|
|
679
|
+
*/
|
|
680
|
+
function noticeFor(body, value) {
|
|
681
|
+
if (body?.action !== 'test-sound') return 'saved'
|
|
682
|
+
return value?.testSound === 'unavailable' ? 'testUnavailable' : 'testPlayed'
|
|
683
|
+
}
|
|
684
|
+
|
|
639
685
|
async function act(body) {
|
|
640
686
|
store.set({ busy: true, notice: null, noticeStatus: null })
|
|
641
687
|
let statusCode = 'network'
|
|
@@ -658,7 +704,7 @@ window.__ModuleLoader__.load({
|
|
|
658
704
|
}
|
|
659
705
|
const value = await response.json()
|
|
660
706
|
store.set({ status: value, failures: 0, busy: false })
|
|
661
|
-
flashNotice(
|
|
707
|
+
flashNotice(noticeFor(body, value), null)
|
|
662
708
|
} catch (error) {
|
|
663
709
|
const stale = error instanceof Error && error.message === 'stale-host'
|
|
664
710
|
store.set({ busy: false })
|
package/docs/RELEASING.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
node scripts/build-index.mjs # 由 package.json 生成 market/index.json
|
|
15
|
-
node --test test/*.test.js #
|
|
15
|
+
node --test test/*.test.js # 81 项;含索引与 manifest 的一致性检查
|
|
16
16
|
npm pack --dry-run # 确认 market/index.json、assets/icon-180.png 都在包里
|
|
17
17
|
```
|
|
18
18
|
|
package/docs/VERIFICATION.md
CHANGED
|
@@ -125,6 +125,32 @@
|
|
|
125
125
|
- **自动化**:75 个单测/接线测试保持全绿;`npm pack` 产物 24 个文件。
|
|
126
126
|
- 未验证:弹层实际锚定位置与观感需刷新页面后目视确认(本会话无浏览器控制权)。
|
|
127
127
|
|
|
128
|
+
## 0.2.12「试听」提示与节流修复(2026-12-03)
|
|
129
|
+
|
|
130
|
+
- **缺陷**:弹层「试听」与开关共用同一条成功提示,点击后显示「已保存」;且宿主的 1 秒节流会让连点的第二下
|
|
131
|
+
无声无息,前端仍按成功提示。另外该提示原本渲染在「临时保持」区块下方,位置与触发它的控件不对应。
|
|
132
|
+
- **修复**:宿主 `test-sound` 改为 `sound.play('success', { force: true })` 绕过节流,并在回包里带
|
|
133
|
+
`testSound: 'played' | 'unavailable'`;前端按 action 选择提示——「试听已播放」/「试听失败:当前系统没有可用的
|
|
134
|
+
提示音播放器」,提示移到开关区下方;`stale`、`failed` 仍常驻,其余提示 2.5 秒自动消失。
|
|
135
|
+
- 自动化:新增 2 项(服务端两种回包、`force` 绕过节流),单测 79 → 81,全绿;`node --check` 通过。
|
|
136
|
+
- 发布:npm `0.2.12`,`dist.shasum = 5e104df9408d371439f50c97f4fe05f55aa911ff`,本地 `npm pack` 与之一致;
|
|
137
|
+
拉取发布包确认 `client.js` 含新提示文案、`lib/sound.js` 含 `force`、`lib/server.js` 含 `testSound`;
|
|
138
|
+
GitHub raw 索引已指向 `0.2.12`,jsDelivr 备用索引 purge 返回 200。
|
|
139
|
+
- 未验证:实际点击「试听」的听觉与提示文案需宿主重启后目视/听感确认(本会话无浏览器控制权)。
|
|
140
|
+
|
|
141
|
+
## 0.2.13 反馈不再撑高弹层(2026-12-03)
|
|
142
|
+
|
|
143
|
+
- **问题**:0.2.12 把操作反馈渲染成开关区下方的新行;弹层是 `height: fit-content` 且底部锚定(CSS anchor
|
|
144
|
+
positioning),插一行就把顶边顶高,2.5 秒后再落回,观感是「窗口在抖」。
|
|
145
|
+
- **改法**:删掉这一行,改为替换弹层底部那行说明文字(`+` 号前面是勾号):默认 `panel.advanced`,
|
|
146
|
+
操作后 2.5 秒内显示 `✓ 试听已播放` / `✓ 已保存` / 失败文案(错误色),160ms 淡入 + `translateY(2px→0)`,
|
|
147
|
+
行高固定 16px、`nowrap` + 省略号,因此面板高度恒定;`prefers-reduced-motion` 下关闭动画。
|
|
148
|
+
持久错误(`stale` / `unreachable`)仍用原来的常驻行,不受影响。
|
|
149
|
+
- **可访问性**:状态行 `role="status"` + `aria-live="polite"`;省略时 `title` 给出完整文案;按钮补 `:active` 按压态。
|
|
150
|
+
- **自动化**:81 项单测/接线测试全绿(本次为纯前端改动,无新增用例);`node --check` 通过;
|
|
151
|
+
中英字典各 45 键、键集合一致、无空值、英文无 CJK 残留。
|
|
152
|
+
- 未验证:动画观感、面板是否确实零跳动、省略号在窄面板下的表现,需宿主重启后目视确认(本会话无浏览器控制权)。
|
|
153
|
+
|
|
128
154
|
## 未验证(明确记录,不代替验证)
|
|
129
155
|
|
|
130
156
|
| ID / 项 | 原因 | 何时可验 |
|
package/lib/server.js
CHANGED
|
@@ -27,6 +27,8 @@ export function createStatusHandler({ controller, activity, sound, config, platf
|
|
|
27
27
|
}
|
|
28
28
|
if (body === null || typeof body !== 'object') return json({ error: 'invalid-body' }, 400)
|
|
29
29
|
|
|
30
|
+
const base = () => payload({ controller, activity, config, platform, version, backend, verify })
|
|
31
|
+
|
|
30
32
|
switch (body.action) {
|
|
31
33
|
case 'hold':
|
|
32
34
|
controller.hold(typeof body.minutes === 'number' ? body.minutes : 30)
|
|
@@ -50,13 +52,19 @@ export function createStatusHandler({ controller, activity, sound, config, platf
|
|
|
50
52
|
notify(onChange)
|
|
51
53
|
break
|
|
52
54
|
case 'test-sound':
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
// The click is a request to hear the sound, so bypass the throttle and
|
|
56
|
+
// tell the caller whether a player was actually spawned: the button
|
|
57
|
+
// used to report the same "saved" note as a switch, which read as a
|
|
58
|
+
// failed test.
|
|
59
|
+
return json({
|
|
60
|
+
...base(),
|
|
61
|
+
testSound: sound?.play('success', { force: true }) === true ? 'played' : 'unavailable',
|
|
62
|
+
})
|
|
55
63
|
default:
|
|
56
64
|
return json({ error: 'invalid-action' }, 400)
|
|
57
65
|
}
|
|
58
66
|
|
|
59
|
-
return json(
|
|
67
|
+
return json(base())
|
|
60
68
|
} catch {
|
|
61
69
|
return json({ error: 'internal' }, 500)
|
|
62
70
|
}
|
package/lib/sound.js
CHANGED
|
@@ -60,10 +60,14 @@ export function createSound({ platform, config, log, spawn = nodeSpawn, now = Da
|
|
|
60
60
|
// `null` (not 0) so the very first trigger is never mistaken for a repeat.
|
|
61
61
|
let lastPlayedAt = null
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
|
|
63
|
+
/**
|
|
64
|
+
* @param {'success'|'error'} kind
|
|
65
|
+
* @param {{ force?: boolean }} [options] `force` skips the throttle — for the
|
|
66
|
+
* manual test button, where the click is the user asking for a sound.
|
|
67
|
+
*/
|
|
68
|
+
function play(kind = 'success', options = {}) {
|
|
65
69
|
const timestamp = now()
|
|
66
|
-
if (lastPlayedAt !== null && timestamp - lastPlayedAt < throttleMs) return false
|
|
70
|
+
if (options.force !== true && lastPlayedAt !== null && timestamp - lastPlayedAt < throttleMs) return false
|
|
67
71
|
|
|
68
72
|
const launch = buildSoundCommand({ platform, kind, config })
|
|
69
73
|
if (launch === null) return false
|
package/market/index.json
CHANGED