dsh-notice-center 1.4.0 → 1.4.2

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
@@ -5,9 +5,51 @@
5
5
 
6
6
  约定:正式版发到 `latest`,`-rc.N` 只发 `next`(不动 `latest`);括号里的短哈希是那次改动的提交。
7
7
 
8
+ ## 1.4.2 — 2026-09-27
9
+
10
+ > **兼容性**:仍是 DSH `0.1.7-rc.2` 起(区间未变,见 1.4.0 那条)。本版有一处**行为变更**:
11
+ > `notifyEnabled` 默认值从 `false` 改为 `true` —— 升级后默认就订阅通知;不想收的把「系统通知」
12
+ > 开关关掉即可,无需任何配置迁移。该改动在**宿主半**(schema 默认值),**重启 Harness 后生效**;
13
+ > 浏览器半 `Ctrl+F5` 刷新即可。
14
+
15
+ ### 变更
16
+
17
+ - **系统通知默认开启,并在首次交互时自动请求授权**(`db2fa91`)
18
+ `notifyEnabled` 默认改为 `true`。打开页面后,借用户的**第一次点击 / 按键**自动请求一次浏览器
19
+ 通知授权 —— 浏览器不允许没有用户手势的请求(MDN:Firefox 72 起、Safari 更早直接拒绝),页面
20
+ 自己弹不出来,这是能做到的最"自动"的形态。频率:每次打开页面最多问一次、**不落任何持久标记**:
21
+ 在授权窗里选「允许」/「阻止」后不再打扰;只点 × / Esc(什么也没选)不算做选择,下次刷新会再
22
+ 问一次,直到做出选择或把开关关掉。
23
+
24
+ ### 修复
25
+
26
+ - **任何配置项改完都要等一会儿才生效**(`db2fa91`)
27
+ 与 1.4.0 里音量、颜色那两条同源,这次把设置区**全字段**统一到一张当帧回显草稿表:官方
28
+ `Switch` 是 fully controlled(只认 `props.checked`)、音效下拉只认受控 `value`、滑杆与取色器
29
+ 的受控 `value` 也会被旧快照拽回,而每笔写都要重写整份 profile 补丁并热重载插件条目
30
+ (实测约 1s/笔)—— 只读快照的控件在回显到达前一直显示旧值。现在写入当帧先画、快照追平后
31
+ 交还;滑杆 / 取色器仍按手势合并(首笔立即 + 静默 150ms 补最后一笔)。
32
+
33
+ - **连点几次开关后,最后落在开启上却「自己关掉」**(`db2fa91`)
34
+ 回显草稿是 React state,设置区随热重载重建就丢;写被拒时又会把画面摔回旧快照;排队中的尾笔
35
+ 写也可能随实例一起没掉。现在照官方「代码工作工具」那一行(`DeveloperToolsRow`)的写法:一笔
36
+ 写在途就把开关 `disabled`(原生 `<button disabled>`,浏览器不派发点击 → 连点只产生一笔写),
37
+ 写被拒时行内 `role="alert"` 报「保存失败,请重试」并回滚画面;同时删掉上一版的后台重推
38
+ (它会和用户下一次点击抢着写)。「最后一次操作」另提到模块级,组件重建时不闪回更早的宿主值。
39
+
40
+ ### 新增
41
+
42
+ - **通知权限状态 chip**(`db2fa91`)
43
+ 「系统通知」开关**正下方**常驻短状态,长解释交给官方 `Tooltip`(hover 与 focus 都触发,键盘
44
+ 可达):未授权 =「未授权 · 授权」可点(点了重新弹授权窗);已拒绝 = 叹号 +「已被拒绝」+
45
+ 恢复路径(浏览器不会二次弹窗,网页也无权打开站点设置页);不支持 = 一行小字(多为非安全
46
+ 上下文,例如用局域网 IP 打开);已授权 = 不显示。权限态用 Permissions API 的 `onchange` +
47
+ `focus` / `visibilitychange` 实时刷新;授权成功当场弹一条「通知已开启」确认。
48
+
8
49
  ## 1.4.0 — 2026-09-27
9
50
 
10
- > **兼容性**:`engines.dsh` 要求 `>=0.1.7-rc.2 <0.2.0-0`。设置表单改用 0.1.7 的
51
+ > **兼容性**:要求 DSH `0.1.7-rc.2` 起 —— 0.1.x 线内放行,跨到 0.2 线(含其预发布)须重新
52
+ > 验证后再放行(声明原文 `>=0.1.7-rc.2 <0.2.0-0`)。设置表单改用 0.1.7 的
11
53
  > `runtime.Config` 派生,**宿主 0.1.6 及更早请继续用 1.3.1**。
12
54
 
13
55
  ### 修复
@@ -44,7 +86,8 @@
44
86
  - 导航图标换成自定义铃铛(`viewBox 0 0 1024 1024`):铃身 + 底座合并成一条 `currentColor`
45
87
  路径跟随主题,高光保留 `#3399FF`;官方回退齿轮的 path 不够用时只追加克隆节点(不删 React
46
88
  管的节点),幂等跳过避免 rAF 死循环。
47
- - `engines` / `peerDependencies` 收到 `>=0.1.7-rc.2 <0.2.0-0`。
89
+ - `engines` / `peerDependencies` 收到 `0.1.7-rc.2` 起(上限锁在 0.2 线之前,声明原文
90
+ `>=0.1.7-rc.2 <0.2.0-0`)。
48
91
 
49
92
  ### 测试与工程
50
93
 
package/README.en.md CHANGED
@@ -163,7 +163,23 @@ Remove the dependency and the `dsh.profile.bundles` entry, then restart — noth
163
163
  ## Getting started in three steps
164
164
 
165
165
  1. **Open the settings page** — Settings → **Notification center** (a sidebar entry)
166
- 2. **Turn on system notifications** — flip the **System notifications** master switch; the browser asks for permission, choose *Allow*. If it was denied, the settings page tells you, and you must re-enable it in the browser's **site settings** (browsers do not ask twice)
166
+ 2. **Grant system notifications** — the master switch is **on by default**: after the page loads, your first click or key press makes the plugin ask the browser for notification permission once (browsers **refuse** requests without a user gesture, so the page cannot pop it on its own — it borrows your first interaction). Choose *Allow* and you also get a "Notifications enabled" confirmation. Frequency rules:
167
+
168
+ - **at most once per page load** (clicking more in the same session never re-prompts);
169
+ - choose *Allow* or *Block* → **never asked again** (the permission is settled);
170
+ - merely closing the prompt with **× / Esc** (neither choice) → not a decision, so the **next page load asks again** until you decide;
171
+ - to stop it entirely: turn the **System notifications** switch off, or choose *Block*.
172
+
173
+ Later, use the status chip right **below the switch** (the short state is always visible; hover it or focus it with the keyboard for the full explanation):
174
+
175
+ | State | Chip | What to do |
176
+ |---|---|---|
177
+ | **Not granted** (you dismissed the prompt) | "Not granted - Grant", clickable | Click it and the browser asks again |
178
+ | **Blocked** | warning icon + "Blocked" | Browsers do **not** ask twice (and a page may not open site settings): hover for the recovery path — click the icon at the left of the address bar → Notifications → Allow, or open `chrome://settings/content/notifications` |
179
+ | **Unsupported** | one small line | Usually a **secure context** problem (see *Install → Requirements*): use `http://127.0.0.1:3080` |
180
+ | Granted | hidden (the row stays clean) | — |
181
+
182
+ The switch itself always works (you can turn notifications off even while unauthorised — and turning it off stops the automatic request); change the permission in site settings and the chip follows immediately.
167
183
  3. **Tune as you like** — expand the two groups: change colours, pick sounds, set volume, toggle **Notify in the foreground** / **Auto hide**
168
184
 
169
185
  <img src="docs/images/settings-en.png" width="440" alt="Notification center settings page">
@@ -178,7 +194,7 @@ After that, whenever you switch away or minimise, a finished session or a pendin
178
194
  | | Finished | `green` | `#22C55E` | Finished status-light colour (official sidebar colour) |
179
195
  | | Pending | `amber` | `#F59E0B` | Pending status-light colour (official sidebar colour) |
180
196
  | | Default colour | `black` | unset | Unset = keep the stock `/favicon.svg` |
181
- | System notifications | Master switch | `notifyEnabled` | **off** | opt-in; turning it on asks for browser permission |
197
+ | System notifications | Master switch | `notifyEnabled` | **on** | On by default; the first interaction asks for browser permission, and a status chip appears below the switch while it is missing |
182
198
  | | Auto hide | `notifyAutoHide` | on | Off = the notification stays until you dismiss it |
183
199
  | | Notify in the foreground | `notifyForeground` | off | On = also notify while you are looking at the page |
184
200
  | | Sound | `notifySound` | on | When on, the system sound is muted and the plugin sound plays |
@@ -195,6 +211,7 @@ The settings page also shows a one-line footer at the very top with the plugin n
195
211
  |---|---|
196
212
  | No "Notification center" entry in Settings | The plugin did not load. Make sure you **restarted Harness** after installing, then look for `settings namespace "notice-center" registered` in the Harness console |
197
213
  | A switch does nothing / a new setting has no effect | After changing the **host half** (`lib/index.mjs`) you must restart Harness — settings writes go through the host schema |
214
+ | A permission prompt popped up on my very first click after installing | The master switch is on by default, so the plugin borrows your **first interaction** (click / key press) to ask once — browsers refuse permission requests without a user gesture. Choose *Block* if you do not want it, and use the status chip in the settings later |
198
215
  | No notifications at all | Three conditions are required: ① the master switch is on; ② browser permission is *Allow*; ③ the page is not in the foreground when the event fires (use **Notify in the foreground** to relax this) |
199
216
  | No notifications over a LAN IP | Non-secure context: the browser disables the Notification API, so system notifications are **entirely unavailable** (unrelated to *Notify in the foreground*). Use `127.0.0.1` / `localhost`; over a LAN only the tab status light works |
200
217
  | Nothing after closing the tab | Known limitation, see below |
package/README.md CHANGED
@@ -162,7 +162,23 @@ dsh plugin --profile web remove dsh-notice-center
162
162
  ## 上手三步
163
163
 
164
164
  1. **打开设置页** —— 设置 → **通知中心**(侧栏导航项)
165
- 2. **开启系统通知** —— 打开「系统通知」总开关,浏览器会弹出授权请求,选「允许」。被拒绝时设置页会提示,需要到浏览器的**站点设置**里恢复(浏览器不会二次弹窗)
165
+ 2. **授权系统通知** —— 总开关**默认就是开的**:打开页面后,你**第一次点击或按键**时,插件会自动向浏览器请求一次通知授权(浏览器**不允许**没有用户手势的请求,页面自己弹不出来,所以只能借你的一次交互),选「允许」,同时会收到一条「通知已开启」的确认。频率规则:
166
+
167
+ - **每次打开页面最多问一次**(同一次会话里点多少下都只问一次,不会连环弹);
168
+ - 你在授权窗上选了「允许」或「阻止」→ **不会再问**(权限有定论了);
169
+ - 你只是点了 **× / Esc**(既没允许也没阻止)→ 不算做出选择,**下次刷新页面会再问一次**,直到你选为止;
170
+ - 想彻底不被打扰:把「系统通知」开关**关掉**,或在授权窗里选「阻止」。
171
+
172
+ 之后想补授权,用开关**正下方**那枚状态 chip(短状态常驻、鼠标悬浮或键盘聚焦问号/叹号看完整说明):
173
+
174
+ | 状态 | chip 长什么样 | 怎么办 |
175
+ |---|---|---|
176
+ | **未授权**(自动请求被你关掉了,或从没问过) | 「未授权 · 授权」可点 | 点它,浏览器会重新弹授权窗 |
177
+ | **已被拒绝** | 叹号 +「已被拒绝」 | 浏览器**不会二次弹窗**(网页也无权打开站点设置页):悬浮看恢复路径 —— 点地址栏左侧的图标 → 通知 → 允许,或打开 `chrome://settings/content/notifications` |
178
+ | **当前浏览器不支持** | 一行小字 | 多半是**安全上下文**问题(见「安装 → 前置要求」),用 `http://127.0.0.1:3080` 访问即可 |
179
+ | 已授权 | 不显示(行保持干净) | — |
180
+
181
+ 开关本身始终可切(未授权时也能把通知关掉,关掉后就不会再自动请求);你在站点设置里改完权限回到页面,chip 会立刻跟上。
166
182
  3. **按需微调** —— 展开两个分组:调颜色、选音效、调音量、开关「前台提醒」/「自动隐藏」
167
183
 
168
184
  <img src="docs/images/settings.png" width="440" alt="通知中心设置页">
@@ -177,7 +193,7 @@ dsh plugin --profile web remove dsh-notice-center
177
193
  | | 完成 | `green` | `#22C55E` | 完成状态灯颜色(官方侧边栏色) |
178
194
  | | 待处理 | `amber` | `#F59E0B` | 待处理状态灯颜色(官方侧边栏色) |
179
195
  | | 默认色 | `black` | 未设置 | 不设置=沿用官方原版 `/favicon.svg` |
180
- | 系统通知 | 总开关 | `notifyEnabled` | **关** | opt-in;开启需浏览器授权 |
196
+ | 系统通知 | 总开关 | `notifyEnabled` | **开** | 默认开启;首次交互自动请求浏览器授权,未授权时开关下方给状态 chip |
181
197
  | | 自动隐藏 | `notifyAutoHide` | 开 | 关=通知常驻屏幕,需手动关闭 |
182
198
  | | 前台提醒 | `notifyForeground` | 关 | 开=你正看着页面时也提醒 |
183
199
  | | 提示音 | `notifySound` | 开 | 开启后静音系统提示音,改播插件音效 |
@@ -194,7 +210,9 @@ dsh plugin --profile web remove dsh-notice-center
194
210
  |---|---|
195
211
  | 设置里找不到「通知中心」 | 插件没加载成功。确认装完**重启过 Harness**,再看 Harness 控制台有没有 `settings namespace "notice-center" registered` 这行日志 |
196
212
  | 开关点了没反应 / 加了新设置项不生效 | 改过**宿主半**(`lib/index.mjs`)后必须重启 Harness——设置写入要过宿主 schema 校验 |
213
+ | 装完插件后第一次点页面就弹出授权窗 | 通知开关默认开启,插件借你**第一次交互**(点击/按键)自动请求一次授权 —— 浏览器不允许没有用户手势的请求,页面自己弹不出来。不想授权就点「阻止」,之后可在设置页用状态 chip 补授权 |
197
214
  | 完全不弹通知 | 三个条件缺一不可:① 系统通知总开关已打开;② 浏览器权限为「允许」;③ 触发时页面不在前台(默认策略,可用「前台提醒」放宽) |
215
+ | 打开开关没弹授权窗 | 只有权限处于「还没问过」时浏览器才会弹;已经「拒绝」过就**不会再弹**,页面会给出站点设置的恢复路径。另外授权请求必须在点击里发起、且要安全上下文(`127.0.0.1` / `localhost`) |
198
216
  | 用局域网 IP 打开时不弹 | 非安全上下文,浏览器禁用 Notification API,系统通知**完全不可用**(与「前台提醒」无关)。改用 `127.0.0.1` / `localhost`;局域网下只能靠标签页状态灯 |
199
217
  | 标签页关掉后收不到 | 已知限制,见下文 |
200
218
  | 刷新页面后绿灯变回黑色 | 正常。该状态是官方信号的内存态,刷新即丢 |
@@ -0,0 +1,14 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="-368 -368 1760 1760">
2
+ <!-- 通知中心的插件图标:官方插件页(侧栏 Plugins 面板)每张卡片/每一行用的就是它。
3
+ 宿主 (dsh-app-boot) 读 package.json 顶层 icon,校验后转成 data:URL 交给 <img> 渲染,
4
+ 所以写死颜色、不能用 currentColor 跟随主题(与 lib/client.cjs 里那颗侧栏导航铃铛不同)。
5
+ 铃身 #3399FF 是品牌蓝,浅色与深色背景都看得清;高光 #E8F2FF。
6
+ 想要原图那种深灰铃身,把第一条 path 的 fill 换成 #333333 即可。
7
+ viewBox 按官方插件图标的留白对齐(官方两款同样画在 36x36 网格上,实测:「自动审查」
8
+ 内容占 52.7% x 66.6%、留白 23.6%/16.7%;「智能体团队」内容占 50% x 50%、留白 25%/24%)。
9
+ 本图铃铛本体实测 922 x 1025(比宽略高),取外框 1760 并居中 —— 内容占 52.4% x 58.2%,
10
+ 横向留白 23.8%(与官方一致)、纵向 20.9%(介于官方两款之间),缩到插件页的 30/36px
11
+ 观感与官方图标齐平;文件 <=256 KiB。 -->
12
+ <path fill="#3399FF" d="M921.6 880.64h-819.2A51.2 51.2 0 0 1 51.2 829.44v-66.56A107.7248 107.7248 0 0 1 158.72 655.36a30.72 30.72 0 0 0 30.72-30.72V376.832A319.6928 319.6928 0 0 1 399.36 78.2336a112.0256 112.0256 0 0 1 213.6064 0A319.6928 319.6928 0 0 1 824.32 376.832v247.808a30.72 30.72 0 0 0 30.72 30.72h10.24A107.7248 107.7248 0 0 1 972.8 762.88v66.56a51.2 51.2 0 0 1-51.2 51.2zM112.64 819.2h798.72v-56.32A46.08 46.08 0 0 0 865.28 716.8h-10.24a92.16 92.16 0 0 1-92.16-92.16V376.832a257.8432 257.8432 0 0 0-184.32-245.76l-19.0464-5.7344-2.6624-20.48a50.7904 50.7904 0 0 0-100.7616 0l-2.6624 20.48-19.0464 5.7344a257.8432 257.8432 0 0 0-184.32 245.76v247.808A92.16 92.16 0 0 1 158.72 716.8 46.08 46.08 0 0 0 112.64 762.88z M512 1024a174.2848 174.2848 0 0 1-174.08-174.08h61.44a112.64 112.64 0 0 0 225.28 0h61.44a174.2848 174.2848 0 0 1-174.08 174.08z"/>
13
+ <path fill="#E8F2FF" d="M665.6 353.6896a30.72 30.72 0 0 1-25.6-13.9264A259.4816 259.4816 0 0 0 542.72 251.904a30.72 30.72 0 0 1 28.2624-54.4768 320.9216 320.9216 0 0 1 120.6272 108.7488A30.72 30.72 0 0 1 665.6 353.6896z"/>
14
+ </svg>