dsh-ustc-quota 1.1.34 → 1.1.38
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/client.js +123 -65
- package/index.js +2 -23
- 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.
|
|
14
|
+
const CLIENT_VERSION = '1.1.38';
|
|
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`;
|
|
@@ -476,7 +476,7 @@ window.__ModuleLoader__.load({
|
|
|
476
476
|
},
|
|
477
477
|
legendRow: {
|
|
478
478
|
display: 'grid',
|
|
479
|
-
gridTemplateColumns: 'var(--ustc-key-col, 36px) repeat(3, minmax(0, 1fr))',
|
|
479
|
+
gridTemplateColumns: 'var(--ustc-key-col, 36px) repeat(3, minmax(0, 1fr)) auto',
|
|
480
480
|
columnGap: 4,
|
|
481
481
|
alignItems: 'center',
|
|
482
482
|
minWidth: 0,
|
|
@@ -505,6 +505,14 @@ window.__ModuleLoader__.load({
|
|
|
505
505
|
color: 'var(--dsw-alias-label-primary)',
|
|
506
506
|
whiteSpace: 'nowrap',
|
|
507
507
|
},
|
|
508
|
+
legendMeta: {
|
|
509
|
+
fontSize: 8,
|
|
510
|
+
lineHeight: 1.2,
|
|
511
|
+
color: 'var(--dsw-alias-label-secondary)',
|
|
512
|
+
whiteSpace: 'nowrap',
|
|
513
|
+
textAlign: 'right',
|
|
514
|
+
paddingLeft: 2,
|
|
515
|
+
},
|
|
508
516
|
legendReset: {
|
|
509
517
|
width: '100%',
|
|
510
518
|
fontSize: 8,
|
|
@@ -555,8 +563,18 @@ window.__ModuleLoader__.load({
|
|
|
555
563
|
cell: {
|
|
556
564
|
minWidth: 0,
|
|
557
565
|
display: 'flex',
|
|
558
|
-
flexDirection: '
|
|
559
|
-
|
|
566
|
+
flexDirection: 'row',
|
|
567
|
+
alignItems: 'center',
|
|
568
|
+
gap: 3,
|
|
569
|
+
},
|
|
570
|
+
inlineBar: {
|
|
571
|
+
flex: '1 1 14px',
|
|
572
|
+
minWidth: 10,
|
|
573
|
+
height: 5,
|
|
574
|
+
position: 'relative',
|
|
575
|
+
borderRadius: 999,
|
|
576
|
+
background: 'transparent',
|
|
577
|
+
overflow: 'hidden',
|
|
560
578
|
},
|
|
561
579
|
valueLine: {
|
|
562
580
|
display: 'flex',
|
|
@@ -1141,36 +1159,70 @@ window.__ModuleLoader__.load({
|
|
|
1141
1159
|
const DOCK_TRANSCRIPT_FLOOR = 360;
|
|
1142
1160
|
|
|
1143
1161
|
|
|
1144
|
-
//
|
|
1145
|
-
//
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
let
|
|
1162
|
+
// When the blank strip beside the transcript is too narrow, free room on the
|
|
1163
|
+
// right instead of letting the card shrink: pad the conversation column and pin
|
|
1164
|
+
// the transcript to the left edge of that padded box.
|
|
1165
|
+
const DOCK_COMFORT = 220;
|
|
1166
|
+
let pushedColumn = null;
|
|
1167
|
+
let pushedTarget = null;
|
|
1168
|
+
let pushedSaved = null;
|
|
1169
|
+
let padState = 0;
|
|
1170
|
+
|
|
1171
|
+
function transcriptOf() {
|
|
1172
|
+
const flow = document.querySelector('[data-slot="conversation.chat.flow"]');
|
|
1173
|
+
if (!flow) return null;
|
|
1174
|
+
let node = flow;
|
|
1175
|
+
for (let i = 0; i < 6 && node; i += 1) {
|
|
1176
|
+
const style = getComputedStyle(node);
|
|
1177
|
+
if (style.marginLeft === 'auto' || style.marginRight === 'auto') return node;
|
|
1178
|
+
node = node.parentElement;
|
|
1179
|
+
}
|
|
1180
|
+
return flow.firstElementChild || flow;
|
|
1181
|
+
}
|
|
1149
1182
|
|
|
1150
|
-
function
|
|
1183
|
+
function pushConversation(reserve) {
|
|
1151
1184
|
const holder = document.querySelector('[data-slot="main.conversation"]');
|
|
1152
1185
|
const column = holder ? (holder.firstElementChild || holder) : null;
|
|
1153
|
-
if (!column) return
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1186
|
+
if (!column) return;
|
|
1187
|
+
const target = transcriptOf();
|
|
1188
|
+
if (!target) return;
|
|
1189
|
+
if (pushedColumn !== column) {
|
|
1190
|
+
releaseConversation();
|
|
1191
|
+
pushedColumn = column;
|
|
1192
|
+
pushedSaved = {
|
|
1193
|
+
pad: column.style.getPropertyValue('padding-right'),
|
|
1194
|
+
padPriority: column.style.getPropertyPriority('padding-right'),
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
if (pushedTarget !== target) {
|
|
1198
|
+
if (pushedTarget) {
|
|
1199
|
+
pushedTarget.style.removeProperty('margin-left');
|
|
1200
|
+
pushedTarget.style.removeProperty('margin-right');
|
|
1201
|
+
}
|
|
1202
|
+
pushedTarget = target;
|
|
1203
|
+
target.style.setProperty('margin-left', '0px', 'important');
|
|
1204
|
+
target.style.setProperty('margin-right', 'auto', 'important');
|
|
1159
1205
|
}
|
|
1160
1206
|
const wanted = reserve + 'px';
|
|
1161
1207
|
if (column.style.getPropertyValue('padding-right') !== wanted) {
|
|
1162
1208
|
column.style.setProperty('padding-right', wanted, 'important');
|
|
1163
1209
|
}
|
|
1164
|
-
|
|
1210
|
+
padState = reserve;
|
|
1165
1211
|
}
|
|
1166
1212
|
|
|
1167
|
-
function
|
|
1168
|
-
if (
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1213
|
+
function releaseConversation() {
|
|
1214
|
+
if (pushedTarget) {
|
|
1215
|
+
pushedTarget.style.removeProperty('margin-left');
|
|
1216
|
+
pushedTarget.style.removeProperty('margin-right');
|
|
1217
|
+
pushedTarget = null;
|
|
1218
|
+
}
|
|
1219
|
+
if (pushedColumn && pushedSaved) {
|
|
1220
|
+
if (pushedSaved.pad) pushedColumn.style.setProperty('padding-right', pushedSaved.pad, pushedSaved.padPriority);
|
|
1221
|
+
else pushedColumn.style.removeProperty('padding-right');
|
|
1222
|
+
}
|
|
1223
|
+
pushedColumn = null;
|
|
1224
|
+
pushedSaved = null;
|
|
1225
|
+
padState = 0;
|
|
1174
1226
|
}
|
|
1175
1227
|
|
|
1176
1228
|
function measureRightDock() {
|
|
@@ -1178,39 +1230,39 @@ window.__ModuleLoader__.load({
|
|
|
1178
1230
|
const column = holder ? (holder.firstElementChild || holder) : null;
|
|
1179
1231
|
if (!column) return null;
|
|
1180
1232
|
const columnRect = column.getBoundingClientRect();
|
|
1181
|
-
if (columnRect.width <
|
|
1182
|
-
|
|
1183
|
-
//
|
|
1184
|
-
//
|
|
1185
|
-
//
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1233
|
+
if (columnRect.width < 200 || columnRect.height < 120) return null;
|
|
1234
|
+
|
|
1235
|
+
// Left bound: the conversation boundary the user drags. DSH draws two
|
|
1236
|
+
// .widthHandle strips beside the transcript; the card starts to their right,
|
|
1237
|
+
// so it never covers the transcript and never touches the boundary.
|
|
1238
|
+
let boundaryRight = null;
|
|
1239
|
+
for (const handle of document.querySelectorAll('[class*="widthHandle"]')) {
|
|
1240
|
+
if (handle.getAttribute('data-side') === 'left') continue;
|
|
1241
|
+
const rect = handle.getBoundingClientRect();
|
|
1242
|
+
if (rect.width <= 0 || rect.height < 40) continue;
|
|
1243
|
+
boundaryRight = boundaryRight === null ? rect.right : Math.max(boundaryRight, rect.right);
|
|
1191
1244
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
//
|
|
1195
|
-
|
|
1245
|
+
if (boundaryRight === null) boundaryRight = columnRect.left + columnRect.width * 0.5 + 24;
|
|
1246
|
+
|
|
1247
|
+
// Right bound: whatever native chrome lives at the column's right edge — the
|
|
1248
|
+
// turn rail when there are turns, otherwise the right-sidebar rail button.
|
|
1249
|
+
let rightLimit = columnRect.right;
|
|
1196
1250
|
for (const button of document.querySelectorAll('button[aria-label]')) {
|
|
1197
1251
|
const label = button.getAttribute('aria-label') || '';
|
|
1198
|
-
if (
|
|
1252
|
+
if (!/turnNavigation|轮次|跳转|右侧边栏/i.test(label)) continue;
|
|
1199
1253
|
const rect = button.getBoundingClientRect();
|
|
1200
1254
|
if (rect.width <= 0 || rect.height <= 0) continue;
|
|
1201
|
-
if (rect.left
|
|
1202
|
-
|
|
1203
|
-
if (inset > 0 && inset <= 72) railInset = Math.max(railInset, inset);
|
|
1204
|
-
}
|
|
1205
|
-
width = Math.max(DOCK_FLOOR_WIDTH, width - railInset);
|
|
1206
|
-
let reserve = width + railInset + DOCK_GAP * 2;
|
|
1207
|
-
const reserveCap = Math.round(columnRect.width * 0.34);
|
|
1208
|
-
if (reserve > reserveCap) {
|
|
1209
|
-
reserve = Math.max(DOCK_FLOOR_WIDTH + DOCK_GAP * 2, reserveCap);
|
|
1210
|
-
width = Math.max(DOCK_FLOOR_WIDTH, reserve - railInset - DOCK_GAP * 2);
|
|
1255
|
+
if (rect.left <= boundaryRight) continue;
|
|
1256
|
+
if (rect.left < rightLimit) rightLimit = rect.left;
|
|
1211
1257
|
}
|
|
1258
|
+
if (rightLimit > columnRect.right) rightLimit = columnRect.right;
|
|
1259
|
+
|
|
1260
|
+
const leftEdge = Math.round(boundaryRight) + DOCK_GAP;
|
|
1261
|
+
const rightEdge = Math.round(rightLimit) - DOCK_GAP;
|
|
1262
|
+
const span = rightEdge - leftEdge;
|
|
1263
|
+
if (span < 40) return null;
|
|
1212
1264
|
|
|
1213
|
-
// Vertical bound:
|
|
1265
|
+
// Vertical bound: below the conversation tab strip, above the column bottom.
|
|
1214
1266
|
let contentTop = Math.round(columnRect.top) + DOCK_GAP;
|
|
1215
1267
|
const tabStrip = document.querySelector('[data-conversation-tabs]');
|
|
1216
1268
|
if (tabStrip) {
|
|
@@ -1221,11 +1273,13 @@ window.__ModuleLoader__.load({
|
|
|
1221
1273
|
}
|
|
1222
1274
|
}
|
|
1223
1275
|
|
|
1276
|
+
const floored = span < 240;
|
|
1224
1277
|
return {
|
|
1225
1278
|
top: contentTop,
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1279
|
+
left: floored ? Math.max(0, rightEdge - 240) : leftEdge,
|
|
1280
|
+
width: floored ? 240 : span,
|
|
1281
|
+
naturalSpan: span,
|
|
1282
|
+
columnWidth: Math.round(columnRect.width),
|
|
1229
1283
|
maxHeight: Math.max(120, Math.round(columnRect.bottom) - contentTop - DOCK_GAP),
|
|
1230
1284
|
};
|
|
1231
1285
|
}
|
|
@@ -1251,11 +1305,19 @@ window.__ModuleLoader__.load({
|
|
|
1251
1305
|
observer.observe(column);
|
|
1252
1306
|
}
|
|
1253
1307
|
const next = measureRightDock();
|
|
1308
|
+
if (activeRef.current && next) {
|
|
1309
|
+
const natural = next.naturalSpan;
|
|
1310
|
+
let pad = padState;
|
|
1311
|
+
if (natural < DOCK_COMFORT - 8) pad = pad + (DOCK_COMFORT - natural);
|
|
1312
|
+
else if (natural > DOCK_COMFORT + 24) pad = Math.max(0, pad - (natural - DOCK_COMFORT));
|
|
1313
|
+
const limit = Math.max(0, next.columnWidth - 340);
|
|
1314
|
+
pad = Math.min(Math.round(pad), limit);
|
|
1315
|
+
if (pad > 0) pushConversation(pad);
|
|
1316
|
+
else releaseConversation();
|
|
1317
|
+
} else {
|
|
1318
|
+
releaseConversation();
|
|
1319
|
+
}
|
|
1254
1320
|
setBox(next);
|
|
1255
|
-
// Apply the reserved padding from the same loop that measured it; a React
|
|
1256
|
-
// effect can be skipped when DSH re-renders the column behind our back.
|
|
1257
|
-
if (activeRef.current && next) applyReservedPadding(next.reserve);
|
|
1258
|
-
else releaseReservedPadding();
|
|
1259
1321
|
};
|
|
1260
1322
|
function schedule() {
|
|
1261
1323
|
if (!frame) frame = window.requestAnimationFrame(measure);
|
|
@@ -1270,10 +1332,6 @@ window.__ModuleLoader__.load({
|
|
|
1270
1332
|
if (frame) window.cancelAnimationFrame(frame);
|
|
1271
1333
|
};
|
|
1272
1334
|
}, []);
|
|
1273
|
-
React.useEffect(() => () => { releaseReservedPadding(); }, []);
|
|
1274
|
-
React.useEffect(() => {
|
|
1275
|
-
if (!active) releaseReservedPadding();
|
|
1276
|
-
}, [active]);
|
|
1277
1335
|
|
|
1278
1336
|
const shown = active && box !== null;
|
|
1279
1337
|
return h('div', {
|
|
@@ -1281,7 +1339,7 @@ window.__ModuleLoader__.load({
|
|
|
1281
1339
|
style: {
|
|
1282
1340
|
position: 'fixed',
|
|
1283
1341
|
top: box ? box.top : 0,
|
|
1284
|
-
|
|
1342
|
+
left: box ? box.left : 0,
|
|
1285
1343
|
width: box ? box.width : DOCK_MIN_WIDTH,
|
|
1286
1344
|
maxHeight: box ? box.maxHeight : 0,
|
|
1287
1345
|
overflow: 'visible',
|
|
@@ -1746,7 +1804,7 @@ window.__ModuleLoader__.load({
|
|
|
1746
1804
|
percent ? h('span', { style: { ...STYLE.percent, color: percentColor } }, percent) : null
|
|
1747
1805
|
),
|
|
1748
1806
|
h('div', {
|
|
1749
|
-
style: { ...STYLE.
|
|
1807
|
+
style: { ...STYLE.inlineBar, opacity: isStale ? 0.55 : 1 },
|
|
1750
1808
|
role: 'progressbar',
|
|
1751
1809
|
'aria-label': label,
|
|
1752
1810
|
'aria-valuemin': 0,
|
|
@@ -1857,7 +1915,6 @@ window.__ModuleLoader__.load({
|
|
|
1857
1915
|
? h('span', { style: STYLE.warn, title: warnings.join('\n'), 'aria-label': t('warnings') }, '!')
|
|
1858
1916
|
: null,
|
|
1859
1917
|
error && snapshot ? h('span', { style: STYLE.warn, title: error }, '!') : null,
|
|
1860
|
-
h('span', { style: STYLE.meta }, updated ? `${t('updatedLabel')} ${updated}` : ''),
|
|
1861
1918
|
|
|
1862
1919
|
h('button', {
|
|
1863
1920
|
type: 'button',
|
|
@@ -1894,7 +1951,8 @@ window.__ModuleLoader__.load({
|
|
|
1894
1951
|
h('div', { style: tableStyle },
|
|
1895
1952
|
h('div', { style: STYLE.legendRow },
|
|
1896
1953
|
h('div', { key: 'corner' }),
|
|
1897
|
-
WINDOW_IDS.map((id) => h(React.Fragment, { key: id }, windowLegend(id)))
|
|
1954
|
+
WINDOW_IDS.map((id) => h(React.Fragment, { key: id }, windowLegend(id))),
|
|
1955
|
+
h('div', { key: 'updated', style: STYLE.legendMeta, title: updated || '' }, updated ? `${t('updatedLabel')} ${updated}` : '')
|
|
1898
1956
|
),
|
|
1899
1957
|
keys.map((key, index) => keyRow(key, index, activeProvider))
|
|
1900
1958
|
),
|
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.
|
|
25
|
+
const PLUGIN_VERSION = '1.1.38';
|
|
26
26
|
const KEY_INFO_PATH = 'key/info';
|
|
27
27
|
const USER_INFO_PATH = 'user/info';
|
|
28
28
|
const DISCOVERY_TTL_MS = 30000;
|
|
@@ -57,28 +57,7 @@ export function apply(ctx, config) {
|
|
|
57
57
|
path: UPDATE_APPLY_PATH,
|
|
58
58
|
handler: (request, response) => handleUpdateApply(ctx, updates, updateTokens, request, response),
|
|
59
59
|
}), 'dsh-ustc-quota: update apply route');
|
|
60
|
-
|
|
61
|
-
// TEMPORARY probe (removed in the next build).
|
|
62
|
-
ctx.effect(() => ctx.webServer.register({
|
|
63
|
-
kind: 'exact',
|
|
64
|
-
path: '/plugins/dsh-ustc-quota/probe',
|
|
65
|
-
handler: (request, response) => {
|
|
66
|
-
const out = {};
|
|
67
|
-
try {
|
|
68
|
-
const conn = ctx.connection || {};
|
|
69
|
-
out.connectionKeys = Object.keys(conn);
|
|
70
|
-
for (const key of out.connectionKeys) {
|
|
71
|
-
const value = conn[key];
|
|
72
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') out[key] = value;
|
|
73
|
-
}
|
|
74
|
-
out.ctxKeys = Object.keys(ctx);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
out.error = String(error);
|
|
77
|
-
}
|
|
78
|
-
response.writeHead(200, { 'content-type': 'application/json', 'cache-control': 'no-store' });
|
|
79
|
-
response.end(JSON.stringify(out));
|
|
80
|
-
},
|
|
81
|
-
}), 'dsh-ustc-quota: probe route');}
|
|
60
|
+
}
|
|
82
61
|
|
|
83
62
|
function createReader(ctx, settings) {
|
|
84
63
|
const cache = new Map();
|
package/package.json
CHANGED