@fabianactor/dsh-lil-whale-group-ui 1.12.2 → 1.12.3

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/lib/client.js CHANGED
@@ -121,7 +121,7 @@ window.__ModuleLoader__.load({
121
121
  }
122
122
 
123
123
  /**
124
- * 版本:读两个包当前版本;「检查更新」才去问 npm。
124
+ * 版本:读两个包当前版本;「检查更新」才去问 GitHub Releases。
125
125
  * 两个包必须一起用,所以两条一起显示、一起说"有没有新的"。
126
126
  */
127
127
  async function loadVersions() {
@@ -1759,7 +1759,9 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
1759
1759
  multiple: true,
1760
1760
  style: { display: 'none' },
1761
1761
  onChange: (event) => {
1762
- const files = event.target.files
1762
+ // FileList 是活的:先摘出文件再清 value。反过来会把 files 清空——
1763
+ // 2026-11-20 他报:点按钮选图选得动、但图不进输入框;拖入正常(拖入不走这个 input)。
1764
+ const files = Array.from(event.target.files ?? [])
1763
1765
  event.target.value = ''
1764
1766
  void attachImages(files)
1765
1767
  },
@@ -2734,7 +2736,9 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
2734
2736
  multiple: true,
2735
2737
  style: { display: 'none' },
2736
2738
  onChange: (event) => {
2737
- const files = event.target.files
2739
+ // FileList 是活的:先摘出文件再清 value。反过来会把 files 清空——
2740
+ // 2026-11-20 他报:点按钮选图选得动、但图不进输入框;拖入正常(拖入不走这个 input)。
2741
+ const files = Array.from(event.target.files ?? [])
2738
2742
  event.target.value = ''
2739
2743
  void attachImages(files)
2740
2744
  },
@@ -3108,6 +3112,8 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
3108
3112
  : null,
3109
3113
  ),
3110
3114
 
3115
+ h('div', { style: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)', marginTop: 6 } },
3116
+ '查的是 GitHub Releases;npm 上只有两块 bundle,安装与更新请走仓库。'),
3111
3117
  h('div', {
3112
3118
  style: { marginTop: 16, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },
3113
3119
  }, status || '改动会自动保存。侧边栏名称要刷新页面才变。'),
@@ -3827,7 +3833,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
3827
3833
  inject: ['slots'],
3828
3834
  apply(ctx) {
3829
3835
  // 一行"我跑的是哪一版"的自报,方便判断浏览器是不是还在用旧 bundle
3830
- console.info('[dsh-lil-whale-group-ui] client build v55 · read-truth:', Object.keys(MARKDOWN_LABELS).join(','))
3836
+ console.info('[dsh-lil-whale-group-ui] client build v57 · image-picker-files:', Object.keys(MARKDOWN_LABELS).join(','))
3831
3837
  // 「正在回复…」那三个点的呼吸动画 + 过场转圈。只在浏览器里注入一次。
3832
3838
  if (typeof document !== 'undefined' && !document.getElementById('dsh-lil-whale-group-keyframes')) {
3833
3839
  const style = document.createElement('style')
package/lib/index.js CHANGED
@@ -15,6 +15,7 @@ import { createRequire } from 'node:module'
15
15
  import { config } from './config.js'
16
16
  import { parseMessageLines } from './messages-core.js'
17
17
  import { presenceReasonOf } from './presence-core.js'
18
+ import { newerThan, latestReleaseOf, LATEST_RELEASE_API } from './version-core.js'
18
19
 
19
20
  export const name = '@fabianactor/dsh-lil-whale-group-ui'
20
21
  export const inject = ['webServer', 'agents']
@@ -60,7 +61,7 @@ const IMAGE_EXT = { png: 'image/png', jpg: 'image/jpeg', webp: 'image/webp', gif
60
61
  const IMAGE_FMT = 2
61
62
  const IMAGE_ALGO = 'sha256'
62
63
 
63
- // 版本:设置页要显示「当前版本」并检查 npm 上的最新版。
64
+ // 版本:设置页要显示「当前版本」并检查 GitHub Releases 上的最新版。
64
65
  // 当前版本从两个包自己的 package.json 读(ui 就是自己;host 走模块解析,
65
66
  // 解析不到再按同 scope 的兄弟目录找)——不写死数字,免得代码和 package.json 各说各话。
66
67
  const UI_PACKAGE = JSON.parse(readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf8'))
@@ -87,34 +88,21 @@ function versionState() {
87
88
  }
88
89
  }
89
90
 
90
- /** 只比 x.y.z 的数字段;预发布标签(-rc.1)忽略——给人看的是版本,不是 semver 全集。 */
91
- function newerThan(latest, current) {
92
- if (!latest || !current) return null
93
- const a = String(latest).split('-')[0].split('.').map((n) => Number(n) || 0)
94
- const b = String(current).split('-')[0].split('.').map((n) => Number(n) || 0)
95
- for (let i = 0; i < 3; i += 1) {
96
- if ((a[i] ?? 0) > (b[i] ?? 0)) return true
97
- if ((a[i] ?? 0) < (b[i] ?? 0)) return false
98
- }
99
- return false
100
- }
101
-
102
- async function latestOnNpm(packageName) {
91
+ async function latestReleaseOnGitHub() {
103
92
  const controller = new AbortController()
104
93
  const timer = setTimeout(() => controller.abort(), 8000)
105
94
  try {
106
- const response = await fetch(`https://registry.npmjs.org/${packageName.replace('/', '%2F')}/latest`, {
95
+ const response = await fetch(LATEST_RELEASE_API, {
107
96
  signal: controller.signal,
108
- headers: { accept: 'application/json' },
97
+ headers: { accept: "application/vnd.github+json", "user-agent": "dsh-lil-whale-panel" },
109
98
  })
110
99
  if (!response.ok) throw new Error(`HTTP ${response.status}`)
111
100
  const data = await response.json()
112
- return typeof data?.version === 'string' ? data.version : null
101
+ return latestReleaseOf(data)
113
102
  } finally {
114
103
  clearTimeout(timer)
115
104
  }
116
105
  }
117
-
118
106
  /**
119
107
  * 读不到的图片必须留痕,否则"没有图"和"图丢了"看起来一样(小肥鱼的原话:
120
108
  * 校验的价值不在拦住坏路径,在让坏路径有痕迹)。
@@ -914,7 +902,7 @@ export function apply(ctx) {
914
902
  },
915
903
  }))
916
904
 
917
- // 版本:当前版本随时能看;「检查更新」才去问 npm。
905
+ // 版本:当前版本随时能看;「检查更新」才去问 GitHub Releases(npm 只作镜像,不再当渠道)。
918
906
  // 网络不通要说清楚,不能装成"已是最新"——那和真的检查过长得一样(§60)。
919
907
  disposers.push(ctx.webServer.register({
920
908
  kind: 'exact',
@@ -938,14 +926,21 @@ export function apply(ctx) {
938
926
  return
939
927
  }
940
928
  const base = versionState()
941
- const result = { checkedAt: new Date().toISOString(), host: { ...base.host }, ui: { ...base.ui } }
942
- for (const side of ['host', 'ui']) {
943
- try {
944
- const latest = await latestOnNpm(result[side].name)
945
- result[side].latest = latest
946
- result[side].updateAvailable = newerThan(latest, result[side].current)
947
- } catch (error) {
948
- result[side].error = String(error?.message ?? error)
929
+ const result = { checkedAt: new Date().toISOString(), source: "github-releases", host: { ...base.host }, ui: { ...base.ui } }
930
+ // 两个包同一个仓库、同一条 Release:查一次就够,别各查一次(结果不一致时还得分谁对)。
931
+ let release = null
932
+ let releaseError = null
933
+ try {
934
+ release = await latestReleaseOnGitHub()
935
+ } catch (error) {
936
+ releaseError = String(error?.message ?? error)
937
+ }
938
+ for (const side of ["host", "ui"]) {
939
+ if (release) {
940
+ result[side].latest = release.version
941
+ result[side].updateAvailable = newerThan(release.version, result[side].current)
942
+ } else {
943
+ result[side].error = releaseError
949
944
  }
950
945
  }
951
946
  sendJson(res, 200, result)
@@ -0,0 +1,45 @@
1
+ /**
2
+ * 「有没有新版本」的纯计算:读 GitHub Releases 的 tag、比版本号。
3
+ *
4
+ * 为什么数据源从 npm 换成 GitHub(2026-11-20,Fabian 定的口径):
5
+ * npm 上只有两块 bundle,缺 pool\homes\模板\启动脚本——只从 npm 装出来的鱼塘跑不起来
6
+ * (面板会显示「没装完整」,写接口回 409)。所以 npm 从"安装/更新渠道"降级成镜像;
7
+ * 唯一可信的更新来源是 GitHub 仓库与它的 Releases。设置页的「检查更新」跟着改查 Releases,
8
+ * 不然以后不再拿 npm 当渠道时,那个按钮会永远显示"已是最新"。
9
+ *
10
+ * 这里只做纯计算(不联网):tag 解析、版本比较。网络与超时在 index.js 里。
11
+ */
12
+
13
+ /** 仓库:唯一安装与更新来源。 */
14
+ export const REPO = 'FabianActor/dsh-lil-whale'
15
+
16
+ /** Releases API:最新一条正式 Release。预发布(prerelease)不算。 */
17
+ export const LATEST_RELEASE_API = `https://api.github.com/repos/${REPO}/releases/latest`
18
+
19
+ /** `v1.12.2` → `1.12.2`;认不出的 tag 返回 null(不猜)。 */
20
+ export function versionFromTag(tag) {
21
+ const text = String(tag ?? '').trim().replace(/^v/i, '')
22
+ return /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(text) ? text : null
23
+ }
24
+
25
+ /** 只比 x.y.z 的数字段;预发布标签(-rc.1)忽略——给人看的是版本,不是 semver 全集。 */
26
+ export function newerThan(latest, current) {
27
+ if (!latest || !current) return null
28
+ const a = String(latest).split('-')[0].split('.').map((n) => Number(n) || 0)
29
+ const b = String(current).split('-')[0].split('.').map((n) => Number(n) || 0)
30
+ for (let i = 0; i < 3; i += 1) {
31
+ if ((a[i] ?? 0) > (b[i] ?? 0)) return true
32
+ if ((a[i] ?? 0) < (b[i] ?? 0)) return false
33
+ }
34
+ return false
35
+ }
36
+
37
+ /**
38
+ * Releases API 的 JSON → 最新版本号。
39
+ * 读不出 tag 就抛错:宁可让面板写"查不到原因",也不要装成"已是最新"(§60)。
40
+ */
41
+ export function latestReleaseOf(json) {
42
+ const version = versionFromTag(json?.tag_name)
43
+ if (!version) throw new Error(`Release 里没有能读的 tag_name:${JSON.stringify(json?.tag_name ?? null)}`)
44
+ return { version, tag: String(json.tag_name), url: typeof json?.html_url === 'string' ? json.html_url : null }
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabianactor/dsh-lil-whale-group-ui",
3
- "version": "1.12.2",
3
+ "version": "1.12.3",
4
4
  "type": "module",
5
5
  "description": "群聊页面:侧边栏一个图标,点开是三条鱼的群(读写 lil-whale\\group\\messages.jsonl)",
6
6
  "author": "Fabian",