dsh-reminder-notify 0.14.0 → 0.15.0

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 CHANGED
@@ -85,3 +85,18 @@ dsh plugin --profile desktop add link:<本目录绝对路径>
85
85
  - 仅 Windows(`os: ["win32"]`):卡片宿主是 WinForms。
86
86
  - 每次弹卡片要起一个 PowerShell 进程,`Add-Type` 编译约 0.6 s 才出现(有轻微延迟,播放与动画照旧)。
87
87
  - 卡片随 DSH 宿主进程存活;DSH 关掉时正在显示的卡片也会一起消失。
88
+
89
+ ## 给别的插件用(0.15 起)
90
+
91
+ 插件把整套提醒能力挂在宿主的一个服务上,别的插件不用自己起 PowerShell、也不用重复写排队与免打扰逻辑:
92
+
93
+ ```js
94
+ const reminder = ctx.get('reminder') // 服务名固定为 reminder
95
+ await reminder.notify('decide', { message: '有个改动等你点头', seconds: 30 })
96
+ await reminder.digest({ force: true }) // 忽略「今天已发过」,立刻发一条日报
97
+ reminder.stats() // { total, today, byKind, byAction, last7 }
98
+ reminder.config() // 当前生效配置的只读副本
99
+ ```
100
+
101
+ `notify()` 的 `kind` 与 `notify_user` 一致(`done` / `decide` / `raw`),其余参数同工具参数;调用同样受冷却、排队、合并、免打扰、历史记录约束。
102
+
package/docs/PUBLISH.md CHANGED
@@ -4,7 +4,7 @@ DSH 的「插件市场 → 发现」页读的是**索引 URL**:一份 JSON(
4
4
  索引本身不托管代码,只给出版本从哪儿装(`git` 仓库 + 固定提交,或 npm 包名)。
5
5
  本目录的 `index.json` 由 `scripts/build-index.mjs` 生成,**不要手改**。
6
6
 
7
- ## 已发布状态(2026-11-20 更新)
7
+ ## 已发布状态(2026-11-21 更新)
8
8
 
9
9
  | 项目 | 值 |
10
10
  | --- | --- |
@@ -12,7 +12,7 @@ DSH 的「插件市场 → 发现」页读的是**索引 URL**:一份 JSON(
12
12
  | 索引地址(他人添加这个) | `https://jiangshuaiye1203.github.io/dsh-reminder-notify/publish/index.json` |
13
13
  | 站点首页 | https://jiangshuaiye1203.github.io/dsh-reminder-notify/ |
14
14
  | npm 包 | https://www.npmjs.com/package/dsh-reminder-notify |
15
- | 当前版本 | **0.12.1**,装源为 **npm**(`dsh-reminder-notify@0.12.1`),不再是 git 固定提交 |
15
+ | 当前版本 | **0.14.0**,装源为 **npm**(`dsh-reminder-notify@0.14.0`),不再是 git 固定提交 |
16
16
  | Pages | Deploy from a branch,`main` / `(root)` |
17
17
 
18
18
  发新版(npm 源):改代码 → 升 `package.json` 版本 → `scripts\publish-npm.cmd` 发布到 npm →
package/docs/detail.en.md CHANGED
@@ -10,3 +10,4 @@ Cards are drawn by the bundled `host/ReminderHost.ps1` with the built-in PowerSh
10
10
  - **Want to see it now**: press one of the three "try it" buttons; a sample card closes itself after 20 seconds.
11
11
  - **Want it on your phone**: open push under "Digest & push", pick the format, paste your own webhook URL (WeCom bot or Server Chan), then press "Send one now".
12
12
  - **Everything else**: folded into "How it works (expand to read)" inside the settings panel below, one topic at a time.
13
+ - **For other plugins**: this plugin exposes a `reminder` service (`notify` / `digest` / `stats` / `config`); see the README.
package/docs/detail.zh.md CHANGED
@@ -10,3 +10,4 @@
10
10
  - **想马上看效果**:点「试试看」里的三个按钮,各弹一张样卡,20 秒自动关。
11
11
  - **想推到手机**:在「日报与推送」里打开推送、选格式、填自己的 webhook 地址(企业微信机器人或 Server 酱),点「现在发一条」验证。
12
12
  - **其余说明**:全部收在下面设置面板的「使用说明(点开才看)」里,一次只展开一条。
13
+ - **给别的插件用**:本插件对外提供 `reminder` 服务(`notify` / `digest` / `stats` / `config`),写法见 README。
package/index.js CHANGED
@@ -1579,7 +1579,48 @@ function registerHistoryRoute(ctx, getSettings) {
1579
1579
  }, 'dsh-reminder-notify: history route')
1580
1580
  }
1581
1581
 
1582
+ /** Host 服务名:别的插件用 ctx.get('reminder') 拿它。 */
1583
+ export const SERVICE_NAME = 'reminder'
1584
+
1585
+ function packageVersion() {
1586
+ try {
1587
+ return JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8')).version
1588
+ } catch {
1589
+ return null
1590
+ }
1591
+ }
1592
+
1593
+ /**
1594
+ * 0.15 起对外提供的服务:让别的插件也能发提醒、发日报、读统计,而不用自己起宿主。
1595
+ * 全部方法是 fire-and-forget 语义(返回 Promise,失败只在返回值里体现),不会抛给调用方。
1596
+ */
1597
+ export function serviceOf(ctx, getSettings) {
1598
+ return {
1599
+ name: 'dsh-reminder-notify',
1600
+ version: packageVersion(),
1601
+ /** 发一张提醒卡。kind: done | decide | raw;options 同 notify_user 的参数。 */
1602
+ notify: (kind, options = {}) => notify(nodeKind(kind), options || {}, getSettings()),
1603
+ /** 立刻发一条日报(force: true 时忽略「今天已经发过」和「日报未开启」)。 */
1604
+ digest: (options = {}) => runDigest(ctx, getSettings, { force: (options || {}).force === true }),
1605
+ /** 提醒历史统计(不弹卡、不写文件)。 */
1606
+ stats: () => historyStats(readHistory(getSettings())),
1607
+ /** 当前生效的配置快照(只读副本)。 */
1608
+ config: () => ({ ...getSettings() }),
1609
+ }
1610
+ }
1611
+
1612
+ function nodeKind(kind) {
1613
+ return kind === 'decide' || kind === 'raw' ? kind : 'done'
1614
+ }
1615
+
1582
1616
  export function apply(ctx, config) {
1617
+ const getSettings = () => settingsOf(config)
1618
+ if (typeof ctx.provide === 'function') {
1619
+ // 服务在 apply 里一次性注册;ctx.provide 自己挂在本 fiber 上,插件卸载时会自动回收。
1620
+ ctx.provide(SERVICE_NAME, serviceOf(ctx, getSettings))
1621
+ } else {
1622
+ ctx.logger?.warn?.('dsh-reminder-notify: ctx.provide is unavailable, the reminder service was not provided')
1623
+ }
1583
1624
  registerAudioRoute(ctx, () => settingsOf(config))
1584
1625
  registerConfigRoute(ctx, () => settingsOf(config))
1585
1626
  registerPreviewRoute(ctx, () => settingsOf(config))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-reminder-notify",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "DSH 桌面提醒插件:把「完成/需要决定」提醒变成 notify_user 工具(浮动卡片 + 提示音,不抢焦点,纯 PowerShell 源码宿主,仓库零 exe)",
5
5
  "author": "Jiangshuaiye1203",
6
6
  "type": "module",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "versions": [
50
50
  {
51
- "version": "0.13.0",
52
- "publishTimestamp": 1795189754,
51
+ "version": "0.14.0",
52
+ "publishTimestamp": 1795191602,
53
53
  "source": {
54
54
  "type": "npm"
55
55
  },