vite-plugin-refresh-guard 0.2.0 → 0.2.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +30 -10
  3. package/package.json +29 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # 更新日志
2
2
 
3
+ ## v0.2.2 (2026-10-09)
4
+
5
+ **只动 npm 元数据,一行运行期代码没改** —— 目的是让插件在「版本更新提示」这个品类里被搜到。
6
+
7
+ 查了官方 [Vite Plugin Registry](https://registry.vite.dev/plugins)(真源 [vitejs/vite-plugin-registry](https://github.com/vitejs/vite-plugin-registry),每天从 npm 抓一次,全库 6128 个插件):插件**早已被收录**,但同品类可见性差得离谱 —— `@plugin-web-update-notification/vite` 周下载 12,934,本插件 132。
8
+
9
+ 根因不是代码,是词。registry 的搜索是**对 name + description + keywords 做原始子串匹配、不分词**(见 `PluginList.vue`),而本插件这三处都没有 `update notification` 这个连续子串;旧 description 还是中文打头,英文用户搜英文词完全命中不到。竞品的包名本身就是 `web-update-notification`,等于三重命中。
10
+
11
+ - **`description` 改成英文品类词前置**:`Vite plugin for web update notification — detect a new version on every page load and prompt users to reload…`,中文压到句尾,中文搜索照样命中。
12
+ - **`keywords` 补 7 个品类词**:`web-update-notification` / `update-notification` / `new-version` / `auto-reload` / `auto-refresh` / `force-refresh` / `更新提示`,原有 10 个全部保留。子串匹配下必须写**连字符整词** —— 只写 `update`,搜 `update notification` 是匹配不到的。
13
+ - **带空格的短语(`new version` / `auto reload` / `force refresh`)放 description,不放 keywords**:registry 是原始子串匹配,`force-refresh` 匹配不到用户手打的 `force refresh`。实测两种写法命中数相同,但 keywords 连字符+空格双写要 21 个(npm 页面显示重复标签),靠 description 承载只要 17 个。按 registry 的真实判据跑 22 个真实搜索词:**0.2.1 命中 6 个,改完 16 个**。
14
+ - **新增 `compatiblePackages`**(registry 官方扩展字段,带 `$schema`):`rollup` / `rolldown` 从自动推断的 `unknown` 改成显式 `incompatible` + 原因(本插件依赖 Vite 的 `config` / `configResolved`,Rollup 不调这两个钩子)。
15
+
16
+ ⚠️ 一处边界要说清:`compatiblePackages` 修的是**声明是否诚实**,不是筛选器可见性 —— registry 判据是 `if (type === 'incompatible' || type === 'unknown') return false`,两种状态在按 rollup / rolldown 版本筛选时**都会被隐藏**。真正的可见性杠杆只有 `description` 与 `keywords`。
17
+
18
+ ## v0.2.1 (2026-10-08)
19
+
20
+ **补上从 0.2.0 起就欠的两件事**(两件都不改运行期行为):
21
+
22
+ - **README 重写**(10281B → 精简版):0.2.0 发布时 README 已经是精简后的版本,但 CHANGELOG
23
+ 没记,属于用户可见变化却无记录 —— 补上。README 随包发布,装 0.2.0 的用户拿到的就是这一版。
24
+ - **补 `.github/workflows/publish.yml`**:0.2.0 当初是手工 `npm publish` 发的,仓库既没有
25
+ tag 也没有发布工作流,于是 `prepublish-gate` / `readme-gate` **从未在 CI 上被触发过** ——
26
+ 门禁写了等于白写。本次改成 tag `v*` 触发(npm Trusted Publishing / OIDC)。
27
+
28
+
3
29
  ## v0.2.0 (2026-08-13)
4
30
 
5
31
  **dev 下改 CHANGELOG.md 即时热更新**:此前虚拟模块 `virtual:refresh-guard-changelog` 的内容在 dev server 启动时缓存,改了 CHANGELOG 必须重启 vite 才生效——在真实项目里踩到(改了日志以为没生效,重启才发现)。
package/README.md CHANGED
@@ -1,13 +1,33 @@
1
- # vite-plugin-refresh-guard
2
-
3
- 中文 | [English](./README.en.md)
4
-
5
- [![CI](https://github.com/webkubor/vite-plugin-refresh-guard/actions/workflows/ci.yml/badge.svg)](https://github.com/webkubor/vite-plugin-refresh-guard/actions/workflows/ci.yml)
6
- [![npm version](https://img.shields.io/npm/v/vite-plugin-refresh-guard.svg)](https://www.npmjs.com/package/vite-plugin-refresh-guard)
7
- [![license](https://img.shields.io/npm/l/vite-plugin-refresh-guard.svg)](./LICENSE)
8
- [![vite](https://img.shields.io/badge/vite-%3E%3D4%20%3C9-646CFF?logo=vite&logoColor=white)](https://vitejs.dev)
9
- [![vue](https://img.shields.io/badge/vue-%3E%3D3-4FC08D?logo=vue.js&logoColor=white)](https://vuejs.org)
10
- [![react](https://img.shields.io/badge/react-%3E%3D18-61DAFB?logo=react&logoColor=white)](https://react.dev)
1
+ <h1 align="center">🔄 vite-plugin-refresh-guard</h1>
2
+
3
+ <p align="center">
4
+ <strong>部署了新版本,接下来怎么办 —— 把这件事变成一行配置。</strong><br>
5
+ 静默刷新 / 提示后刷新 / 弹窗阻断,三选一写进 config;<br>
6
+ 核心逻辑与框架无关,Vue 与 React 各一层薄适配。
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/vite-plugin-refresh-guard"><img src="https://img.shields.io/npm/v/vite-plugin-refresh-guard?style=for-the-badge&color=4d6bfe&logo=npm&label=npm" alt="npm" /></a>
11
+ <a href="https://www.npmjs.com/package/vite-plugin-refresh-guard"><img src="https://img.shields.io/npm/dm/vite-plugin-refresh-guard?style=for-the-badge&color=6d7f9c&label=downloads" alt="downloads" /></a>
12
+ <a href="https://github.com/webkubor/vite-plugin-refresh-guard/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/webkubor/vite-plugin-refresh-guard/ci.yml?style=for-the-badge&label=CI" alt="CI" /></a>
13
+ <img src="https://img.shields.io/badge/vite-%3E%3D4%20%3C9-646CFF?style=for-the-badge&logo=vite&logoColor=white" alt="vite" />
14
+ <img src="https://img.shields.io/badge/vue-%3E%3D3-4FC08D?style=for-the-badge&logo=vue.js&logoColor=white" alt="vue" />
15
+ <img src="https://img.shields.io/badge/react-%3E%3D18-61DAFB?style=for-the-badge&logo=react&logoColor=white" alt="react" />
16
+ <img src="https://img.shields.io/badge/license-MIT-777?style=for-the-badge" alt="MIT" />
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="./README.en.md">English</a> | 中文
21
+ </p>
22
+
23
+ ## Why This
24
+
25
+ | | 本插件 | 各项目自己写胶水 | 完全不管 |
26
+ |---|---|---|---|
27
+ | 策略是否显式 | ✅ 写进 config,三选一 | ❌ 散落各处,改一次跑偏一次 | ❌ 没有这回事 |
28
+ | 框架覆盖 | ✅ 核心无关 + Vue / React 适配 | ⚠️ 每个项目复制一遍 | — |
29
+ | 新版本探测 | ✅ 构建产物指纹比对 | ⚠️ 各写各的,边界情况没人管 | ❌ 无 |
30
+ | 用户拿到旧版本时 | ✅ 提示 / 弹窗文案可定制 | ⚠️ 看实现 | ❌ 静默跑旧代码 |
11
31
 
12
32
  给 Vite 项目做"部署了新版本,接下来怎么办"的可配置方案。
13
33
 
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "vite-plugin-refresh-guard",
3
- "version": "0.2.0",
4
- "description": "Vite 应用的可配置版本更新检测+刷新方案:静默自动刷新 / 提示后自动刷新 / 弹窗阻断,按产品需要选档位,核心逻辑框架无关,附 Vue/React 适配层。Configurable new-version detection + refresh for Vite apps — silent / toast-auto / modal-blocking, framework-agnostic core with Vue and React adapters.",
3
+ "version": "0.2.2",
4
+ "$schema": "https://raw.githubusercontent.com/vitejs/vite-plugin-registry/refs/heads/main/data/schema/extended-package-json.schema.json",
5
+ "description": "Vite plugin for web update notification — detect a new version on every page load and prompt users to reload: silent auto reload, force refresh, toast prompt, or blocking modal. Framework-agnostic core with Vue and React adapters. Vite 应用版本更新检测与自动刷新方案。",
5
6
  "type": "module",
6
7
  "license": "MIT",
7
8
  "repository": {
@@ -11,14 +12,21 @@
11
12
  "keywords": [
12
13
  "vite",
13
14
  "vite-plugin",
15
+ "web-update-notification",
16
+ "update-notification",
17
+ "new-version",
14
18
  "version-check",
15
19
  "app-update",
20
+ "auto-reload",
21
+ "auto-refresh",
22
+ "force-refresh",
23
+ "refresh",
16
24
  "service-worker",
17
25
  "pwa",
18
- "refresh",
19
26
  "changelog",
20
27
  "vue",
21
- "react"
28
+ "react",
29
+ "更新提示"
22
30
  ],
23
31
  "exports": {
24
32
  ".": {
@@ -53,7 +61,7 @@
53
61
  "typecheck": "tsc --noEmit",
54
62
  "test": "vitest run",
55
63
  "compat": "npm run typecheck && npm test && npm run build",
56
- "prepublishOnly": "npm run build"
64
+ "prepublishOnly": "npm run build && node scripts/prepublish-gate.mjs && node scripts/readme-gate.mjs"
57
65
  },
58
66
  "peerDependencies": {
59
67
  "react": ">=18",
@@ -72,6 +80,22 @@
72
80
  "optional": true
73
81
  }
74
82
  },
83
+ "compatiblePackages": {
84
+ "schemaVersion": 1,
85
+ "vite": {
86
+ "type": "compatible",
87
+ "versions": ">=4 <10",
88
+ "note": "Vite 6-8 走 per-environment hotUpdate,Vite 4-5 兜底 handleHotUpdate;两个钩子都实现了。"
89
+ },
90
+ "rollup": {
91
+ "type": "incompatible",
92
+ "reason": "Vite-only:版本号与项目根在 Vite 的 config / configResolved 钩子里解析,Rollup 不调用这两个钩子,虚拟模块 virtual:refresh-guard-changelog 的 load 会直接抛错。"
93
+ },
94
+ "rolldown": {
95
+ "type": "incompatible",
96
+ "reason": "Vite-only:本插件不是 Rolldown 插件,依赖 Vite 的配置钩子与 dev server 的 HMR 生命周期。"
97
+ }
98
+ },
75
99
  "devDependencies": {
76
100
  "@types/node": "^24.10.11",
77
101
  "@types/react": "^19.2.18",