dsh-aupdate 0.6.7 → 0.6.8

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 (4) hide show
  1. package/README.md +7 -1
  2. package/client.js +76 -13
  3. package/index.js +30 -2
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -190,6 +190,10 @@ mtime 为准:那是磁盘事实。会话目录整个读不到时返回「不
190
190
  发现可更新版本时,界面右下角浮一条提醒,列出插件名和「当前 → 新」版本;超过 8 条
191
191
  时余下给一句「还有 N 个」,15 秒后自动消失。
192
192
 
193
+ 提醒逐条列出**包名**和「当前版本 → 新版本」,包名过长时省略包名那一侧、不动版本;
194
+ 超过 6 条在框内滚动。设置页的「上一次」卡片也会列出同一份清单,不用只靠一句
195
+ 「4 个可更新」猜是哪几个。
196
+
193
197
  同一批更新只提醒一次:这批更新的签名记在 `localStorage` 里,刷新页面不会重复弹。
194
198
  关掉「发现更新时提醒我」就完全不弹,日志和设置页照常记录——提醒只是别让它装完你
195
199
  还不知道,不是唯一的告知渠道。
@@ -410,7 +414,9 @@ in the same language. Wording only — it changes no update behaviour.
410
414
 
411
415
  When a check finds updates, a notice appears in the bottom-right corner listing each
412
416
  plugin and its current → new version; past eight it adds "and N more", and it closes
413
- itself after 15 seconds. Each batch is announced once — the signature is kept in
417
+ itself after 15 seconds. Long package names are truncated on the name side so the
418
+ versions stay visible, and past six entries the list scrolls. The Last run card on the
419
+ settings page lists the same plugins and version pairs. Each batch is announced once — the signature is kept in
414
420
  `localStorage` — and turning "Tell me when updates are found" off silences it entirely
415
421
  while the log and settings page keep recording.
416
422
 
package/client.js CHANGED
@@ -936,6 +936,23 @@ window.__ModuleLoader__.load({
936
936
  : T.upToDate),
937
937
  h('span', null, last.reason || last.status || ''),
938
938
  ),
939
+ // 只报「4 个可更新」不够:要看得出是哪几个、从哪版到哪版。
940
+ // 列表封高度、内部滚动,30 个包也不会把这张卡拉成一屏多。
941
+ (() => {
942
+ const rows = (Array.isArray(last?.updates) ? last.updates : [])
943
+ .map((item) => describeUpdate(item))
944
+ .filter((row) => row !== null)
945
+ if (rows.length === 0) return null
946
+ return h('div', { style: S.scrollList },
947
+ rows.map((row, index) => h('div', {
948
+ key: row.name + ':' + index,
949
+ style: { display: 'flex', alignItems: 'baseline', gap: '8px' },
950
+ },
951
+ h('span', { style: S.pkgName, title: row.name }, row.name),
952
+ row.versions === '' ? null : h('span', { style: S.pkgVer }, row.versions),
953
+ )),
954
+ )
955
+ })(),
939
956
  runHint ? h('span', { style: S.status }, runHint) : null,
940
957
  ),
941
958
  // 更新记录:谁、从哪到哪、什么时候、成没成,以及回滚入口。
@@ -1100,40 +1117,85 @@ window.__ModuleLoader__.load({
1100
1117
 
1101
1118
  let toastOpen = false
1102
1119
 
1120
+ /**
1121
+ * 把一条「可更新」记录归一成 { name, versions }。
1122
+ *
1123
+ * 后端 0.6.8 起存 { name, from, to };更早的版本存的是成品句子
1124
+ * 「名字 1.0 -> 1.1」。两种都要能显示——旧数据不该因为升级就变成
1125
+ * undefined。之前正是只按对象读,句子条目全是 undefined ? → ?。
1126
+ */
1127
+ function describeUpdate(item) {
1128
+ if (typeof item === 'string') {
1129
+ const text = item.trim()
1130
+ if (text === '') return null
1131
+ const match = /^(.*) (\S+) -> (\S+)$/u.exec(text)
1132
+ if (match === null) return { name: text, versions: '' }
1133
+ return { name: match[1], versions: match[2] + ' → ' + match[3] }
1134
+ }
1135
+ if (item === null || typeof item !== 'object') return null
1136
+ const name = typeof item.name === 'string' ? item.name : ''
1137
+ if (name === '') return null
1138
+ const from = typeof item.from === 'string' && item.from !== '' ? item.from : '?'
1139
+ const to = typeof item.to === 'string' && item.to !== '' ? item.to : '?'
1140
+ return { name, versions: from + ' → ' + to }
1141
+ }
1142
+
1143
+ function updateSignature(updates) {
1144
+ return (Array.isArray(updates) ? updates : [])
1145
+ .map((item) => describeUpdate(item))
1146
+ .filter((row) => row !== null)
1147
+ .map((row) => row.name + '@' + row.versions)
1148
+ .sort()
1149
+ .join('|')
1150
+ }
1151
+
1103
1152
  function showUpdateToast(updates) {
1104
1153
  if (toastOpen) return
1105
1154
  const doc = typeof document === 'undefined' ? null : document
1106
1155
  if (doc === null || doc.body === null) return
1156
+ const rows = (Array.isArray(updates) ? updates : []).map((item) => describeUpdate(item)).filter((row) => row !== null)
1157
+ if (rows.length === 0) return
1107
1158
  toastOpen = true
1108
1159
  const box = doc.createElement('div')
1109
1160
  box.setAttribute('data-dsh-aupdate', 'toast')
1110
1161
  box.style.cssText = [
1111
1162
  'position:fixed', 'right:16px', 'bottom:16px', 'z-index:2147483000',
1112
- 'max-width:340px', 'padding:12px 14px', 'border-radius:10px',
1163
+ 'width:320px', 'max-width:calc(100vw - 32px)', 'padding:12px 14px', 'border-radius:10px',
1113
1164
  'background:rgba(28,28,30,0.97)', 'color:#f4f4f5',
1114
1165
  'box-shadow:0 8px 28px rgba(0,0,0,0.38)', 'border:1px solid rgba(255,255,255,0.14)',
1115
1166
  'font:13px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif',
1116
- 'display:flex', 'flex-direction:column', 'gap:8px',
1167
+ 'display:flex', 'flex-direction:column', 'gap:9px',
1117
1168
  ].join(';')
1118
1169
 
1119
1170
  const title = doc.createElement('div')
1120
- title.textContent = T.toastTitle.replace('{n}', String(updates.length))
1121
- title.style.cssText = 'font-weight:600'
1171
+ title.textContent = T.toastTitle.replace('{n}', String(rows.length))
1172
+ title.style.cssText = 'font-weight:600;display:flex;align-items:center;gap:6px'
1122
1173
  box.appendChild(title)
1123
1174
 
1124
1175
  const list = doc.createElement('div')
1125
- list.style.cssText = 'display:flex;flex-direction:column;gap:3px;max-height:180px;overflow:auto'
1126
- for (const item of updates.slice(0, 8)) {
1127
- const row = doc.createElement('div')
1128
- row.textContent = item.name + ' ' + (item.current || '?') + ' → ' + (item.target || '?')
1129
- row.style.cssText = 'font-size:12px;opacity:0.9;white-space:nowrap;overflow:hidden;text-overflow:ellipsis'
1130
- list.appendChild(row)
1176
+ // 超过 6 条就在框内滚动:提醒不该占掉半屏。
1177
+ list.style.cssText = 'display:flex;flex-direction:column;gap:2px;max-height:190px;overflow:auto;margin:0 -4px'
1178
+ for (const row of rows.slice(0, 12)) {
1179
+ const line = doc.createElement('div')
1180
+ line.style.cssText = 'display:flex;align-items:baseline;gap:8px;padding:2px 4px;border-radius:4px;background:rgba(255,255,255,0.05)'
1181
+ const nameEl = doc.createElement('span')
1182
+ nameEl.textContent = row.name
1183
+ // 包名可能很长(@scope/name),压缩它而不是压缩版本。
1184
+ nameEl.style.cssText = 'flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap'
1185
+ line.appendChild(nameEl)
1186
+ if (row.versions !== '') {
1187
+ const verEl = doc.createElement('span')
1188
+ verEl.textContent = row.versions
1189
+ verEl.style.cssText = 'flex:0 0 auto;font-size:11.5px;opacity:0.72;font-variant-numeric:tabular-nums'
1190
+ line.appendChild(verEl)
1191
+ }
1192
+ list.appendChild(line)
1131
1193
  }
1132
1194
  box.appendChild(list)
1133
1195
 
1134
- if (updates.length > 8) {
1196
+ if (rows.length > 12) {
1135
1197
  const more = doc.createElement('div')
1136
- more.textContent = T.toastMore.replace('{n}', String(updates.length - 8))
1198
+ more.textContent = T.toastMore.replace('{n}', String(rows.length - 12))
1137
1199
  more.style.cssText = 'font-size:11.5px;opacity:0.6'
1138
1200
  box.appendChild(more)
1139
1201
  }
@@ -1163,7 +1225,8 @@ window.__ModuleLoader__.load({
1163
1225
  if (state?.settings?.notify !== false) {
1164
1226
  const updates = Array.isArray(state?.lastRun?.updates) ? state.lastRun.updates : []
1165
1227
  if (updates.length > 0) {
1166
- const sig = updates.map((item) => item.name + '@' + (item.target || '')).sort().join('|')
1228
+ // 签名算的是「包名+版本变化」,旧格式也能算出来,不会重复弹。
1229
+ const sig = updateSignature(updates)
1167
1230
  if (sig !== notifiedMark()) {
1168
1231
  markNotified(sig)
1169
1232
  showUpdateToast(updates)
package/index.js CHANGED
@@ -784,11 +784,38 @@ function readLastRun() {
784
784
  if (raw === null || typeof raw !== 'object') return null
785
785
  if (typeof raw.at !== 'string' || raw.at === '') return null
786
786
  const textList = (value) => (Array.isArray(value) ? value.filter((item) => typeof item === 'string') : [])
787
+ /**
788
+ * 待更新清单。
789
+ *
790
+ * 0.6.7 及更早把这一项存成「名字 1.0 -> 1.1」的句子,界面只能整行照搬;
791
+ * 现在存 { name, from, to },提醒和设置页才能把包名和版本分开排版。
792
+ * 旧数据在这里解析回来,不需要用户清文件。
793
+ */
794
+ const updateList = (value) => {
795
+ if (!Array.isArray(value)) return []
796
+ const out = []
797
+ for (const item of value) {
798
+ if (item !== null && typeof item === 'object') {
799
+ if (typeof item.name !== 'string' || item.name === '') continue
800
+ out.push({
801
+ name: item.name,
802
+ from: typeof item.from === 'string' ? item.from : '',
803
+ to: typeof item.to === 'string' ? item.to : '',
804
+ })
805
+ continue
806
+ }
807
+ if (typeof item !== 'string' || item === '') continue
808
+ const match = /^(.*) (\S+) -> (\S+)$/u.exec(item)
809
+ if (match === null) out.push({ name: item, from: '', to: '' })
810
+ else out.push({ name: match[1], from: match[2], to: match[3] })
811
+ }
812
+ return out
813
+ }
787
814
  return {
788
815
  status: typeof raw.status === 'string' ? raw.status : 'unknown',
789
816
  at: raw.at,
790
817
  checked: Number.isFinite(raw.checked) ? raw.checked : 0,
791
- updates: textList(raw.updates),
818
+ updates: updateList(raw.updates),
792
819
  installed: textList(raw.installed),
793
820
  reload: typeof raw.reload === 'string' ? raw.reload : 'none',
794
821
  // 0.6.2 及更早存的是句子;0.6.3 起是 { code, args },两种都要能读。
@@ -1783,7 +1810,8 @@ async function runCycle(mode, ctxRef) {
1783
1810
  status: report.status,
1784
1811
  at: report.finishedAt,
1785
1812
  checked: report.checked,
1786
- updates: report.updates.map((item) => item.name + ' ' + (item.current ?? '?') + ' -> ' + item.target),
1813
+ // 结构化存:界面要分开排「包名」和「版本」,句子做不到。
1814
+ updates: report.updates.map((item) => ({ name: item.name, from: item.current ?? '', to: item.target })),
1787
1815
  installed: report.installed.map((item) => item.name + '@' + item.version + (item.ok ? '' : ' !failed')),
1788
1816
  reload: report.reload?.status ?? 'none',
1789
1817
  reason: report.reason,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aupdate",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "type": "module",
5
5
  "description": "定时检查 DSH 插件更新,串行安装后就地生效,不重启;支持多种调度节奏、失败抑制、按包回滚,并在动手前留快照、忙时自动让开;不更新/只更新哪些插件改成勾选,发现更新在右下角提醒,日志最新在最上面,并在「设置 → 插件更新」里有独立一页。",
6
6
  "license": "MIT",