vite-plugin-refresh-guard 0.3.0 → 0.3.1

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,10 @@
1
1
  # 更新日志
2
2
 
3
+ ## v0.3.1 (2026-10-18)
4
+
5
+ - **组件依赖纯净化 (`UpdateCard.vue`)**:
6
+ 优化 `UpdateCard.vue` 的 Props 声明与要点解析器为 SFC 内联实现,消除对外部相对路径文件的类型与函数引用,避免在跨包/无 Node fs 环境的某些 Vue 编译管道(如纯客户端编译)中报 `compileScript No fs option provided` 错误。
7
+
3
8
  ## v0.3.0 (2026-10-18)
4
9
 
5
10
  - **全量更新日志导出 (`allVersions`)**:
@@ -1,9 +1,49 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, ref, watch } from 'vue'
3
- import { extractBulletPoints } from '../core/changelog'
4
- import type { UpdateCardProps } from '../core/types'
5
3
 
6
- const props = withDefaults(defineProps<UpdateCardProps>(), {
4
+ function parseBulletPoints(text: string | null | undefined): string[] {
5
+ if (!text || typeof text !== 'string') return []
6
+ const lines = text.split('\n')
7
+ const bullets: string[] = []
8
+ for (const line of lines) {
9
+ const trimmed = line.trim()
10
+ const m = trimmed.match(/^(?:[-*+•]|\d+\.)\s+(.+)$/)
11
+ if (m && m[1]) {
12
+ const item = m[1].trim()
13
+ if (item) bullets.push(item)
14
+ }
15
+ }
16
+ return bullets
17
+ }
18
+
19
+ const props = withDefaults(defineProps<{
20
+ /** 控制卡片显隐。默认:true */
21
+ visible?: boolean
22
+ /** 显式版本号,如 "v1.2.0" */
23
+ version?: string | null
24
+ /** 版本发布日期,如 "2026-10-18" */
25
+ date?: string | null
26
+ /** 更新日志正文(Markdown 字符串)。若未显式指定 bulletPoints,将自动提炼其中的列表项 */
27
+ content?: string | null
28
+ /** 手工指定的更新要点列表 */
29
+ bulletPoints?: string[]
30
+ /** 最多展示的 bullet 要点条数。默认:4 */
31
+ maxBullets?: number
32
+ /** 卡片标题。默认:"✨ 新版本上线" */
33
+ title?: string
34
+ /** "查看完整更新日志 / 查看更多" 的外链 URL 或跳转目标。若传入则显示查看更多链接 */
35
+ viewMoreUrl?: string
36
+ /** "查看更多" 按钮或链接文案。默认:"查看完整更新日志" */
37
+ viewMoreText?: string
38
+ /** "立即刷新" 按钮文案。默认:"立即刷新" */
39
+ refreshText?: string
40
+ /** 是否允许关闭/暂不更新。默认:true */
41
+ closable?: boolean
42
+ /** 卡片布局:'floating'(右下角浮动卡片)或 'inline'(流式嵌入)。默认:'floating' */
43
+ layout?: 'floating' | 'inline'
44
+ /** 显式指定深色/浅色外观。null/undefined 则跟随系统的 prefers-color-scheme */
45
+ dark?: boolean | null
46
+ }>(), {
7
47
  visible: true,
8
48
  version: null,
9
49
  date: null,
@@ -39,7 +79,7 @@ const bullets = computed(() => {
39
79
  return props.bulletPoints
40
80
  }
41
81
  if (props.content) {
42
- return extractBulletPoints(props.content)
82
+ return parseBulletPoints(props.content)
43
83
  }
44
84
  return []
45
85
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-refresh-guard",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "$schema": "https://raw.githubusercontent.com/vitejs/vite-plugin-registry/refs/heads/main/data/schema/extended-package-json.schema.json",
5
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 应用版本更新检测与自动刷新方案。",
6
6
  "type": "module",