dsh-ustc-quota 1.1.16 → 1.1.18

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
@@ -32,18 +32,18 @@ github:Awenforever/dsh-ustc-quota
32
32
  ```
33
33
 
34
34
  > **升级前必读:DSH Desktop 0.2.1-rc.3–0.2.1-rc.5 的 client-modules 增量扫描缓存问题需要完整重启。** 在这些旧版本上从旧版本升级本插件后,必须完全退出并重新打开 DSH;仅刷新页面可能不够。若升级后启动崩溃,请使用 DSH 崩溃对话框里的 **重启** 或 **退出**。
35
- > **DSH 0.2.2-rc.1 及以上已支持插件热更新。** v1.1.16 在这些版本上不再显示强制重启警告,更新后由 DSH 热重载;全新安装本来就不需要完整重启。
35
+ > **DSH 0.2.2-rc.1 及以上已支持插件热更新。** 从 v1.1.17 起,只有“宿主已安装的包版本比页面正在运行的 client 版本更新”时才提示重启;更新成功后第一次启动不会再误报。全新安装本来就不需要完整重启。
36
36
 
37
37
  固定版本(推荐,避免默认分支后续变动):
38
38
 
39
39
  ```text
40
- github:Awenforever/dsh-ustc-quota#v1.1.16
40
+ github:Awenforever/dsh-ustc-quota#v1.1.18
41
41
  ```
42
42
 
43
43
  也可以直接从 npm 安装(这样 DSH 的插件页能用官方渠道检查新版本,并直接更新):
44
44
 
45
45
  ```text
46
- dsh-ustc-quota@1.1.16
46
+ dsh-ustc-quota@1.1.18
47
47
  ```
48
48
 
49
49
  或者用你已有的安装方式指定同一目录/仓库:
@@ -53,7 +53,7 @@ plugin_manager install_bundle
53
53
  target = github:Awenforever/dsh-ustc-quota
54
54
  ```
55
55
 
56
- 安装完成后 Host、插件清单和 Client slot 会即时生效。**全新安装**不需要完全重启 DSH;如果页面提示刷新,刷新一次即可。**从旧版本升级**时,DSH Desktop 0.2.1-rc.3–0.2.1-rc.5 的 client-modules 增量扫描缓存问题要求完全退出并重新打开 DSH;页面刷新不够。**DSH 0.2.2-rc.1 及以上已支持插件热更新**,v1.1.16 会在这些版本上隐藏强制重启警告,由 DSH 热重载;只有热更新失败并返回 `restart-required` 时才提示完整重启。详见 [docs/RELEASE_ACCEPTANCE.md](docs/RELEASE_ACCEPTANCE.md) 的 carrier 限制。
56
+ 安装完成后 Host、插件清单和 Client slot 会即时生效。**全新安装**不需要完全重启 DSH;如果页面提示刷新,刷新一次即可。**从旧版本升级**时,DSH Desktop 0.2.1-rc.3–0.2.1-rc.5 的 client-modules 增量扫描缓存问题要求完全退出并重新打开 DSH;页面刷新不够。**DSH 0.2.2-rc.1 及以上已支持插件热更新**,v1.1.18 只在宿主包版本高于页面 client 版本时提示重启,由 DSH 热重载;只有热更新失败并返回 `restart-required` 时才提示完整重启。详见 [docs/RELEASE_ACCEPTANCE.md](docs/RELEASE_ACCEPTANCE.md) 的 carrier 限制。
57
57
 
58
58
  > **从 GitHub 仓库安装和从 npm 安装的区别:** 两者内容相同。从 npm 安装的副本能走 DSH 官方更新通道(插件页可直接检查并更新);从 GitHub 安装的副本没有 registry 身份,卡片会自动退回 GitHub Release 检查更新,安装动作仍由 DSH 的插件管理器执行。
59
59
 
@@ -62,13 +62,13 @@ target = github:Awenforever/dsh-ustc-quota
62
62
  TokenWorks 是 USTC 基于 DSH 的发行版,自带 **插件** 页面和 `@deepseek-ai/dsh-plugin-manager`:
63
63
 
64
64
  1. 在左侧栏打开 **插件** → 点右上角 **+ 添加插件**;
65
- 2. 填入 `dsh-ustc-quota@1.1.16`(npm)或 `github:Awenforever/dsh-ustc-quota#v1.1.16`(GitHub);
65
+ 2. 填入 `dsh-ustc-quota@1.1.18`(npm)或 `github:Awenforever/dsh-ustc-quota#v1.1.18`(GitHub);
66
66
  3. **全新安装**后只需让插件页加载/刷新一次;**从旧版本升级**则必须完全退出并重新打开词元工坊。TokenWorks 的插件页「更新」只应用 Host bundle,页面刷新不能清掉 DSH client-module 缓存;若刷新后插件仍未恢复,请完全退出并重开词元工坊;
67
67
  4. 用学校统一身份登录后,卡片会自动出现。
68
68
 
69
69
  > 词元工坊插件页的「官方」只列出发行版自带的插件;第三方插件(包括本插件)不会出现在「官方」里,安装后会出现在「已安装」区域。这是正常的,不是没有装上。
70
70
 
71
- > 如果之前装过旧版本并看到「插件异常」,先在插件页移除旧条目,再安装上面的 v1.1.16;v1.1.16 已包含旧包 `package.json` 的 BOM 修复、额度接口错误文案修正、报警图标出现时自动加宽 Key 列、更新器令牌/重试修复、DSH 0.2.2 热更新适配、分屏焦点跟随、深色主题适配,以及官方插件更新通道。安装/刷新后若仍未恢复,请完全退出并重开词元工坊,不要只凭一次页面刷新判断安装失败。
71
+ > 如果之前装过旧版本并看到「插件异常」,先在插件页移除旧条目,再安装上面的 v1.1.18;v1.1.18 已包含旧包 `package.json` 的 BOM 修复、额度接口错误文案修正、报警图标出现时自动加宽 Key 列、更新器令牌/重试修复、DSH 0.2.2 热更新适配、分屏焦点跟随、深色主题适配,以及官方插件更新通道。安装/刷新后若仍未恢复,请完全退出并重开词元工坊,不要只凭一次页面刷新判断安装失败。
72
72
 
73
73
  TokenWorks 的额度来自它内置的 `tokenworksUsage` 服务,因此:
74
74
 
@@ -84,7 +84,7 @@ TokenWorks 的额度来自它内置的 `tokenworksUsage` 服务,因此:
84
84
 
85
85
  卡片独占侧边栏底部的一整行:TokenWorks 的「更新」按钮或 DSH 的 Cordis 按钮留在上一行,不会被并排挤压;卡片内部的三列也不会被截断。
86
86
 
87
- > v1.1.6 起不再依赖 `<style>`/`:has`:客户端挂载后直接找到 `footerActions`,折叠只包含本卡片的 slot cell,并让 footer 换行。若仍看到并排,确认装的是 v1.1.16,并刷新一次页面让新的 client bundle 生效。
87
+ > v1.1.6 起不再依赖 `<style>`/`:has`:客户端挂载后直接找到 `footerActions`,折叠只包含本卡片的 slot cell,并让 footer 换行。若仍看到并排,确认装的是 v1.1.18,并刷新一次页面让新的 client bundle 生效。
88
88
 
89
89
  每把 Key(TokenWorks 下是当前账户)一行,三列:
90
90
 
@@ -108,7 +108,7 @@ key-c 8.7/30 29% 8.7/70 12% 11.1/100 11%
108
108
  ## 更新
109
109
 
110
110
  - 标题「USTC 词元额度」右侧显示灰色小字版本号;点击版本号可手动检查更新;
111
- - 启动时检查一次,之后每 24 小时自动检查一次 GitHub 最新 release;
111
+ - 启动时检查一次,之后每 24 小时自动检查一次;先问宿主 `pluginManager.listVersions`(npm 安装的副本可用),再读 GitHub 最新 release 作为回退——**两条通道任意一条可用就能给出结果**;
112
112
  - 有新版本时版本号旁出现小红点,点击弹出更新确认弹窗;
113
113
  - 当前 DSH 通过宿主的官方 `pluginManager` 更新路由直接安装最新 release 的 tarball;从 v1.1.6 起,安装成功后**不自动重载**,弹窗会明确要求完全退出并重新打开 DSH;如果载体仍自动刷新了页面,新 client 会在卡片上显示同样的重启提示,以避免 DSH carrier 的 client-module 启动缓存(rc.3/rc.5);
114
114
  - 已预留 `pluginUpdates.applyUpdate({ id, spec, version })` 适配接口,供后续 DSH 官方插件更新预览版接入;接口不可用时回退到 `pluginManager`,再不可用则弹窗显示安装 spec;
@@ -195,7 +195,9 @@ tokenworksUsage.snapshot({language})
195
195
  - 从 v1.1.15 起,分屏视图中的星号跟随当前焦点 pane:每个 `conversation.composer.dock` 注册隐藏 session marker,按 `focusin` / `pointerdown` 和 pane 的 `data-focused` 解析;共享 split 容器不会误切。`dsh-multiview` 0.1.4 已验证;其他分屏插件采用同一通用逻辑,best-effort。
196
196
  - 从 v1.1.15 起,深色主题完全跟随 DSH token:卡片、弹窗、边框、文字和状态色不写死浅色值,警告/重启底色用 `color-mix` 从 DSH state token 派生;不需要手动开关。
197
197
  - 从 v1.1.16 起,更新检查优先走 DSH 官方通道:先问宿主 `pluginManager.listVersions`(只对 npm 安装的副本有效),没结果再回退 GitHub Release;安装动作也优先用 `pluginManager.updateBundle`,宿主拒绝时回退到 release tarball 的 `installBundle`,两者都不可用时才显示可复制的安装 spec。插件版本已发布到 npm(`dsh-ustc-quota`),每个版本由 GitHub Actions 用 OIDC 可信发布自动上传。
198
- - **首次从 v1.1.11/v1.1.12 升级到 v1.1.13–v1.1.16 仍由旧更新器执行。** 如果自动更新失败,请在插件页直接安装 `github:Awenforever/dsh-ustc-quota#v1.1.16` 或 `dsh-ustc-quota@1.1.16`;装到新版后,后续自动更新才使用新的令牌/重试逻辑。
198
+ - 从 v1.1.17 起,升级后的重启 banner 只在“宿主安装的版本比页面已加载的 client 版本更新”时出现:更新后第一次启动不会再误报“请完全退出并重开”(旧载体 0.2.1-rc.5 上尤其明显),降级时也不会误报。
199
+ - 从 v1.1.18 起,更新检查改为 registry 优先、GitHub 回退:GitHub 不可达(或被防火墙阻断)时不再整体失败,只要 `listVersions` 能给出更新就照常提示;两条通道都不可用才报检查失败。
200
+ - **首次从 v1.1.11/v1.1.12 升级到 v1.1.13–v1.1.18 仍由旧更新器执行。** 如果自动更新失败,请在插件页直接安装 `github:Awenforever/dsh-ustc-quota#v1.1.18` 或 `dsh-ustc-quota@1.1.18`;装到新版后,后续自动更新才使用新的令牌/重试逻辑。
199
201
  - 24h 可能是用户级预算,同一用户多把 Key 会共享;24h 单元格会标注“密钥级 / 用户级 / 上次查询”。
200
202
  - 12:00 / 00:00 边界上平台可能短暂返回旧用量;插件把过期窗口标成“重置中”,8 秒后重查。
201
203
  - 额度数值是平台额度单位(当前 3h/12h/24h 为 30/70/100),不是 DSH token 数;插件不擅自换算。
package/client.js CHANGED
@@ -11,7 +11,7 @@ window.__ModuleLoader__.load({
11
11
  const UPDATE_ENDPOINT = 'plugins/dsh-ustc-quota/update';
12
12
  const UPDATE_APPLY_ENDPOINT = 'plugins/dsh-ustc-quota/update/apply';
13
13
  const WINDOW_IDS = ['3h', '12h', '24h'];
14
- const CLIENT_VERSION = '1.1.16';
14
+ const CLIENT_VERSION = '1.1.18';
15
15
  const UPDATE_INTERVAL_MS = 24 * 60 * 60 * 1000;
16
16
  const CLIENT_VERSION_KEY = `${NS}:client-version`;
17
17
  const CLIENT_RELOAD_KEY = `${NS}:client-reload`;
@@ -41,7 +41,6 @@ window.__ModuleLoader__.load({
41
41
  let clientCtx = null;
42
42
  let activeSessionId = null;
43
43
  let holdHostReload = false;
44
- let previousClientVersion = null;
45
44
  const activeSessionListeners = new Set();
46
45
 
47
46
  function setActiveSession(id) {
@@ -1014,9 +1013,7 @@ window.__ModuleLoader__.load({
1014
1013
  const [updateChecking, setUpdateChecking] = React.useState(false);
1015
1014
  const [updateApplying, setUpdateApplying] = React.useState(false);
1016
1015
  const [updateRestartPending, setUpdateRestartPending] = React.useState(false);
1017
- const [restartNotice, setRestartNotice] = React.useState(
1018
- () => !DSH_HOT_UPDATE && previousClientVersion !== null && previousClientVersion !== CLIENT_VERSION,
1019
- );
1016
+ const [restartNotice, setRestartNotice] = React.useState(false);
1020
1017
  const [updateNotice, setUpdateNotice] = React.useState('');
1021
1018
  const [updateError, setUpdateError] = React.useState('');
1022
1019
  const [updateResult, setUpdateResult] = React.useState('');
@@ -1054,6 +1051,7 @@ window.__ModuleLoader__.load({
1054
1051
  if (!body || !Array.isArray(body.keys)) throw new Error('invalid snapshot');
1055
1052
  if (seq !== requestSeq.current || cancelledRef.current) return null;
1056
1053
  reloadForHostVersion(body.pluginVersion);
1054
+ setRestartNotice(needsRestartForStaleClient(body));
1057
1055
  setSnapshot(body);
1058
1056
  setError(null);
1059
1057
  setLoading(false);
@@ -1702,6 +1700,17 @@ window.__ModuleLoader__.load({
1702
1700
  return false;
1703
1701
  }
1704
1702
 
1703
+ // The restart banner is for carriers that keep serving the client bundle the
1704
+ // page booted with: only a host package newer than the loaded client proves
1705
+ // the page still runs stale code. A fresh launch carries the same version in
1706
+ // both places, and a downgraded package is not newer, so neither asks for a
1707
+ // restart that already happened.
1708
+ function needsRestartForStaleClient(snapshot) {
1709
+ if (DSH_HOT_UPDATE) return false;
1710
+ const hostVersion = snapshot && typeof snapshot.pluginVersion === 'string' ? snapshot.pluginVersion : '';
1711
+ return hostVersion ? isNewerVersion(hostVersion, CLIENT_VERSION) : false;
1712
+ }
1713
+
1705
1714
  function normalizeUpdateInfo(value) {
1706
1715
  if (!value || typeof value !== 'object' || typeof value.latestVersion !== 'string') return null;
1707
1716
  const latest = value.latestVersion.trim().replace(/^v/i, '');
@@ -1758,8 +1767,6 @@ window.__ModuleLoader__.load({
1758
1767
  function reloadOnceAfterClientUpdate() {
1759
1768
  if (typeof window === 'undefined' || typeof localStorage === 'undefined') return;
1760
1769
  try {
1761
- const storedVersion = localStorage.getItem(CLIENT_VERSION_KEY);
1762
- if (storedVersion && storedVersion !== CLIENT_VERSION) previousClientVersion = storedVersion;
1763
1770
  if (localStorage.getItem(CLIENT_VERSION_KEY) === CLIENT_VERSION) return;
1764
1771
  localStorage.setItem(CLIENT_VERSION_KEY, CLIENT_VERSION);
1765
1772
  if (typeof performance !== 'undefined' && performance.now() < 10000) return;
package/index.js CHANGED
@@ -22,7 +22,7 @@ const ROUTE_PATH = '/plugins/dsh-ustc-quota/snapshot';
22
22
  const UPDATE_PATH = '/plugins/dsh-ustc-quota/update';
23
23
  const UPDATE_APPLY_PATH = '/plugins/dsh-ustc-quota/update/apply';
24
24
  const UPDATE_TOKEN_TTL_MS = 30 * 60 * 1000;
25
- const PLUGIN_VERSION = '1.1.16';
25
+ const PLUGIN_VERSION = '1.1.18';
26
26
  const KEY_INFO_PATH = 'key/info';
27
27
  const USER_INFO_PATH = 'user/info';
28
28
  const DISCOVERY_TTL_MS = 30000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ustc-quota",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Live 3h/12h/24h USTC token quota card in the DSH sidebar (works with the USTC TokenWorks distribution).",
package/update.js CHANGED
@@ -363,17 +363,28 @@ export class UpdateService {
363
363
  if (this.inFlight) return this.inFlight;
364
364
 
365
365
  const promise = (async () => {
366
- const release = await fetchLatestRelease(this.fetchImpl, {
367
- repository: this.repository,
368
- timeoutMs: this.timeoutMs,
369
- });
370
-
371
- // Official discovery first, release feed second. `listVersions` only
372
- // answers for a registry-installed dependency; anything else keeps the
373
- // GitHub release as the source of truth.
366
+ // Registry first: `listVersions` answers locally through the carrier and
367
+ // works on networks that cannot reach GitHub. The release feed is only a
368
+ // fallback, so a GitHub failure must not discard a registry answer.
374
369
  const registryHit = await discoverRegistryUpdate(this.ctx, this.currentVersion);
370
+
371
+ let release = null;
372
+ let releaseError = null;
373
+ try {
374
+ release = await fetchLatestRelease(this.fetchImpl, {
375
+ repository: this.repository,
376
+ timeoutMs: this.timeoutMs,
377
+ });
378
+ } catch (error) {
379
+ releaseError = error;
380
+ }
381
+
382
+ if (!release && !registryHit) {
383
+ throw releaseError || new Error('no-update-source');
384
+ }
385
+
375
386
  const preferRegistry = Boolean(registryHit)
376
- && compareVersions(registryHit.version, release.version) >= 0;
387
+ && (!release || compareVersions(registryHit.version, release.version) >= 0);
377
388
 
378
389
  const latestVersion = preferRegistry ? registryHit.version : release.version;
379
390
  const updateAvailable = isUpdateAvailable(this.currentVersion, latestVersion);
@@ -388,10 +399,10 @@ export class UpdateService {
388
399
  registry: preferRegistry ? registryHit.registry : null,
389
400
  releaseUrl: preferRegistry
390
401
  ? releaseUrlForVersion(latestVersion)
391
- : (release.htmlUrl || releaseUrlForVersion(release.version)),
392
- releaseName: preferRegistry ? `${PLUGIN_ID} ${latestVersion}` : release.name,
393
- releaseNotes: preferRegistry ? '' : release.notes.slice(0, 4000),
394
- publishedAt: preferRegistry ? null : release.publishedAt,
402
+ : (release && release.htmlUrl) || releaseUrlForVersion(latestVersion),
403
+ releaseName: preferRegistry ? `${PLUGIN_ID} ${latestVersion}` : (release ? release.name : `${PLUGIN_ID} ${latestVersion}`),
404
+ releaseNotes: preferRegistry || !release ? '' : release.notes.slice(0, 4000),
405
+ publishedAt: preferRegistry || !release ? null : release.publishedAt,
395
406
  checkedAt: new Date(now).toISOString(),
396
407
  };
397
408
  this.cached = info;