dsh-ustc-quota 1.1.31 → 1.1.32

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/client.js +1 -92
  2. package/index.js +2 -41
  3. package/package.json +1 -1
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.31';
14
+ const CLIENT_VERSION = '1.1.32';
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`;
@@ -1141,52 +1141,6 @@ window.__ModuleLoader__.load({
1141
1141
  const DOCK_TRANSCRIPT_FLOOR = 360;
1142
1142
 
1143
1143
 
1144
- let lastDiagAt = 0;
1145
- function reportDiag(payload) {
1146
- const now = Date.now();
1147
- if (now - lastDiagAt < 4000) return;
1148
- lastDiagAt = now;
1149
- try {
1150
- fetch('/plugins/dsh-ustc-quota/diag', {
1151
- method: 'POST',
1152
- cache: 'no-store',
1153
- headers: { 'content-type': 'application/json' },
1154
- body: JSON.stringify(payload),
1155
- }).catch(() => {});
1156
- } catch {
1157
- // diagnostics are best-effort
1158
- }
1159
- }
1160
- let reservedColumn = null;
1161
- let reservedSaved = null;
1162
- let reservedSavedPriority = '';
1163
-
1164
- function applyReservedPadding(reserve) {
1165
- const holder = document.querySelector('[data-slot="main.conversation"]');
1166
- const column = holder ? (holder.firstElementChild || holder) : null;
1167
- if (!column) return false;
1168
- if (reservedColumn !== column) {
1169
- releaseReservedPadding();
1170
- reservedColumn = column;
1171
- reservedSaved = column.style.getPropertyValue('padding-right');
1172
- reservedSavedPriority = column.style.getPropertyPriority('padding-right');
1173
- }
1174
- const wanted = reserve + 'px';
1175
- if (column.style.getPropertyValue('padding-right') !== wanted) {
1176
- column.style.setProperty('padding-right', wanted, 'important');
1177
- }
1178
- return true;
1179
- }
1180
-
1181
- function releaseReservedPadding() {
1182
- if (!reservedColumn) return;
1183
- if (reservedSaved) reservedColumn.style.setProperty('padding-right', reservedSaved, reservedSavedPriority);
1184
- else reservedColumn.style.removeProperty('padding-right');
1185
- reservedColumn = null;
1186
- reservedSaved = null;
1187
- reservedSavedPriority = '';
1188
- }
1189
-
1190
1144
  function measureRightDock() {
1191
1145
  const holder = document.querySelector('[data-slot="main.conversation"]');
1192
1146
  const column = holder ? (holder.firstElementChild || holder) : null;
@@ -1235,51 +1189,6 @@ window.__ModuleLoader__.load({
1235
1189
  }
1236
1190
  }
1237
1191
 
1238
- const rectOf = (el) => {
1239
- if (!el) return null;
1240
- const r = el.getBoundingClientRect();
1241
- return { x: Math.round(r.left), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height) };
1242
- };
1243
- const chain = [];
1244
- let node = document.querySelector('[data-slot="conversation.chat.flow"]');
1245
- while (node && chain.length < 8) {
1246
- chain.push({ tag: node.tagName, cls: String(node.className || '').slice(0, 60), r: rectOf(node), pad: getComputedStyle(node).paddingRight });
1247
- if (node === column) break;
1248
- node = node.parentElement;
1249
- }
1250
- reportDiag({
1251
- at: new Date().toISOString(),
1252
- column: rectOf(column),
1253
- columnPad: getComputedStyle(column).paddingRight,
1254
- columnInlinePad: column.style.getPropertyValue('padding-right'),
1255
- flowChain: chain,
1256
- handles: [...document.querySelectorAll('[class*="widthHandle"]')].map((el) => ({ side: el.getAttribute('data-side'), r: rectOf(el) })),
1257
- nav: (() => {
1258
- let min = null;
1259
- let count = 0;
1260
- for (const b of document.querySelectorAll('button[aria-label]')) {
1261
- const l = b.getAttribute('aria-label') || '';
1262
- if (!/turnNavigation|轮次|跳转/i.test(l)) continue;
1263
- const r = b.getBoundingClientRect();
1264
- if (r.width <= 0) continue;
1265
- count += 1;
1266
- min = min === null ? r.left : Math.min(min, r.left);
1267
- }
1268
- return { count, left: min === null ? null : Math.round(min) };
1269
- })(),
1270
- dock: { width, reserve, top: contentTop, railInset },
1271
- position: (() => { try { return window.localStorage.getItem(POSITION_KEY); } catch { return null; } })(),
1272
- dockRect: (() => {
1273
- const el = document.querySelector('[data-ustc-quota-dock]');
1274
- if (!el) return null;
1275
- const r = el.getBoundingClientRect();
1276
- return { x: Math.round(r.left), w: Math.round(r.width), display: getComputedStyle(el).display };
1277
- })(),
1278
- railButtons: [...document.querySelectorAll('button[aria-label]')]
1279
- .filter((b) => /右侧边栏/.test(b.getAttribute('aria-label') || ''))
1280
- .map((b) => ({ label: b.getAttribute('aria-label'), r: rectOf(b) })),
1281
- viewport: window.innerWidth,
1282
- });
1283
1192
  return {
1284
1193
  top: contentTop,
1285
1194
  width,
package/index.js CHANGED
@@ -1,6 +1,3 @@
1
- import fs from 'node:fs';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
1
  /**
5
2
  * Host half of dsh-ustc-quota.
6
3
  *
@@ -25,7 +22,7 @@ const ROUTE_PATH = '/plugins/dsh-ustc-quota/snapshot';
25
22
  const UPDATE_PATH = '/plugins/dsh-ustc-quota/update';
26
23
  const UPDATE_APPLY_PATH = '/plugins/dsh-ustc-quota/update/apply';
27
24
  const UPDATE_TOKEN_TTL_MS = 30 * 60 * 1000;
28
- const PLUGIN_VERSION = '1.1.31';
25
+ const PLUGIN_VERSION = '1.1.32';
29
26
  const KEY_INFO_PATH = 'key/info';
30
27
  const USER_INFO_PATH = 'user/info';
31
28
  const DISCOVERY_TTL_MS = 30000;
@@ -60,43 +57,7 @@ export function apply(ctx, config) {
60
57
  path: UPDATE_APPLY_PATH,
61
58
  handler: (request, response) => handleUpdateApply(ctx, updates, updateTokens, request, response),
62
59
  }), 'dsh-ustc-quota: update apply route');
63
-
64
- // TEMPORARY diagnostics channel (removed before the next public release).
65
- ctx.effect(() => ctx.webServer.register({
66
- kind: 'exact',
67
- path: '/plugins/dsh-ustc-quota/diag',
68
- handler: (request, response) => {
69
- if (request.method === 'GET') {
70
- try {
71
- const web = ctx.webServer || {};
72
- const info = {};
73
- for (const key of Object.keys(web)) {
74
- const value = web[key];
75
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') info[key] = value;
76
- }
77
- response.writeHead(200, { 'content-type': 'application/json', 'cache-control': 'no-store' });
78
- response.end(JSON.stringify({ info, keys: Object.keys(web) }));
79
- } catch (error) {
80
- response.writeHead(500);
81
- response.end(String(error));
82
- }
83
- return;
84
- }
85
- let body = '';
86
- request.on('data', (chunk) => { body += chunk; });
87
- request.on('end', () => {
88
- try {
89
- const file = path.join(os.tmpdir(), 'dsh-ustc-quota-diag.jsonl');
90
- fs.appendFileSync(file, String(body).replace(/[\r\n]+/g, ' ') + String.fromCharCode(10));
91
- response.writeHead(204, { 'cache-control': 'no-store' });
92
- response.end();
93
- } catch {
94
- response.writeHead(500);
95
- response.end();
96
- }
97
- });
98
- },
99
- }), 'dsh-ustc-quota: diag route');}
60
+ }
100
61
 
101
62
  function createReader(ctx, settings) {
102
63
  const cache = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ustc-quota",
3
- "version": "1.1.31",
3
+ "version": "1.1.32",
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).",