@laraveladmin/dsh-stay-awake 0.2.11 → 0.2.12

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # 变更记录 · Changelog
2
2
 
3
+ ## 0.2.12 — 2026-12-03
4
+
5
+ ### 修复
6
+
7
+ - 弹层「试听」点击后错误地显示「已保存」:它和开关共用同一条成功提示。现在按结果提示
8
+ 「试听已播放」或「试听失败:当前系统没有可用的提示音播放器」,并且提示不再挂在「临时保持」
9
+ 区块下方,而是显示在开关区下面。
10
+ - 「试听」绕过宿主端 1 秒节流:连续点击都会立刻响,符合 FR-10.14「任何时候都能验证设备与音量」。
11
+ - 宿主回包新增 `testSound: played|unavailable`,前端据此判断,不再假定成功。
12
+
13
+ ### 测试
14
+
15
+ - 新增 2 项:服务端试听「已播放 / 不可用」两种回包;音频模块 `force` 绕过节流。
16
+ - 单测总数 79 → 81。
17
+
18
+
3
19
  ## 0.2.11 — 2026-12-03
4
20
 
5
21
  ### 文档与发布流程
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 sound failed: no audio player on this system',
112
116
  'panel.holdDisabled': 'Enable the plugin first to hold',
113
117
  'panel.holdLeft': 'left',
114
118
  'panel.saved': 'Saved',
@@ -257,6 +261,25 @@ window.__ModuleLoader__.load({
257
261
  return null
258
262
  }
259
263
 
264
+ /**
265
+ * One transient line under the switches. `stale` is rendered next to the
266
+ * status grid instead — it is about the host build, not about an action.
267
+ */
268
+ function noticeOf(t, snapshot) {
269
+ const notice = snapshot.notice
270
+ if (notice === null || notice === undefined || notice === 'stale') return null
271
+ if (notice === 'testPlayed') return h('div', { className: 'dsa-note' }, t('panel.testPlayed'))
272
+ if (notice === 'testUnavailable') return h('div', { className: 'dsa-note dsa-error' }, t('panel.testUnavailable'))
273
+ if (notice === 'failed') {
274
+ return h(
275
+ 'div',
276
+ { className: 'dsa-note dsa-error' },
277
+ `${t('panel.saveFailed')}${snapshot.noticeStatus ? ` (${snapshot.noticeStatus})` : ''}`,
278
+ )
279
+ }
280
+ return h('div', { className: 'dsa-note' }, t('panel.saved'))
281
+ }
282
+
260
283
  function Moon({ color }) {
261
284
  return h(
262
285
  'svg',
@@ -472,6 +495,7 @@ window.__ModuleLoader__.load({
472
495
  }, t('panel.testSound')),
473
496
  switchOf(soundOn, () => act({ action: 'set-sound', enabled: !soundOn }), t('panel.sound')),
474
497
  ),
498
+ noticeOf(t, snapshot),
475
499
  ),
476
500
  h(
477
501
  'div',
@@ -498,11 +522,6 @@ window.__ModuleLoader__.load({
498
522
  onClick: () => act({ action: 'cancel-hold' }),
499
523
  }, t('panel.holdCancel')),
500
524
  ),
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
525
  ),
507
526
  h(
508
527
  'div',
@@ -627,8 +646,11 @@ window.__ModuleLoader__.load({
627
646
  let noticeTimer = null
628
647
  function flashNotice(notice, noticeStatus) {
629
648
  if (noticeTimer !== null) globalThis.clearTimeout(noticeTimer)
649
+ noticeTimer = null
630
650
  store.set({ notice, noticeStatus })
631
- if (notice === 'saved') {
651
+ // `stale` and `failed` stay until the next action; everything else is
652
+ // an acknowledgement of a click and clears itself.
653
+ if (notice !== 'stale' && notice !== 'failed') {
632
654
  noticeTimer = globalThis.setTimeout(() => {
633
655
  noticeTimer = null
634
656
  store.set({ notice: null, noticeStatus: null })
@@ -636,6 +658,15 @@ window.__ModuleLoader__.load({
636
658
  }
637
659
  }
638
660
 
661
+ /**
662
+ * `test-sound` answers with whether a player was spawned, so the note
663
+ * says what happened instead of claiming a preference was saved.
664
+ */
665
+ function noticeFor(body, value) {
666
+ if (body?.action !== 'test-sound') return 'saved'
667
+ return value?.testSound === 'unavailable' ? 'testUnavailable' : 'testPlayed'
668
+ }
669
+
639
670
  async function act(body) {
640
671
  store.set({ busy: true, notice: null, noticeStatus: null })
641
672
  let statusCode = 'network'
@@ -658,7 +689,7 @@ window.__ModuleLoader__.load({
658
689
  }
659
690
  const value = await response.json()
660
691
  store.set({ status: value, failures: 0, busy: false })
661
- flashNotice('saved', null)
692
+ flashNotice(noticeFor(body, value), null)
662
693
  } catch (error) {
663
694
  const stale = error instanceof Error && error.message === 'stale-host'
664
695
  store.set({ busy: false })
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
- if (typeof sound?.play === 'function') sound.play('success')
54
- break
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(payload({ controller, activity, config, platform, version, backend, verify }))
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
- /** @param {'success'|'error'} kind */
64
- function play(kind = 'success') {
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
@@ -51,8 +51,8 @@
51
51
  },
52
52
  "versions": [
53
53
  {
54
- "version": "0.2.11",
55
- "publishTimestamp": 1796278765,
54
+ "version": "0.2.12",
55
+ "publishTimestamp": 1796290611,
56
56
  "source": {
57
57
  "type": "npm"
58
58
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laraveladmin/dsh-stay-awake",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "DeepSeek Harness plugin that keeps the machine awake only while unattended work runs.",
5
5
  "keywords": [
6
6
  "dsh-plugin",