dsh-ustc-quota 1.1.29 → 1.1.30
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 +43 -29
- package/index.js +2 -2
- 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.30';
|
|
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`;
|
|
@@ -1157,6 +1157,36 @@ window.__ModuleLoader__.load({
|
|
|
1157
1157
|
// diagnostics are best-effort
|
|
1158
1158
|
}
|
|
1159
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
|
+
|
|
1160
1190
|
function measureRightDock() {
|
|
1161
1191
|
const holder = document.querySelector('[data-slot="main.conversation"]');
|
|
1162
1192
|
const column = holder ? (holder.firstElementChild || holder) : null;
|
|
@@ -1256,6 +1286,8 @@ window.__ModuleLoader__.load({
|
|
|
1256
1286
|
const position = usePanelPosition();
|
|
1257
1287
|
const active = position === 'right';
|
|
1258
1288
|
const [box, setBox] = React.useState(null);
|
|
1289
|
+
const activeRef = React.useRef(active);
|
|
1290
|
+
activeRef.current = active;
|
|
1259
1291
|
React.useEffect(() => {
|
|
1260
1292
|
let frame = 0;
|
|
1261
1293
|
let observer = null;
|
|
@@ -1270,7 +1302,12 @@ window.__ModuleLoader__.load({
|
|
|
1270
1302
|
observer = new ResizeObserver(schedule);
|
|
1271
1303
|
observer.observe(column);
|
|
1272
1304
|
}
|
|
1273
|
-
|
|
1305
|
+
const next = measureRightDock();
|
|
1306
|
+
setBox(next);
|
|
1307
|
+
// Apply the reserved padding from the same loop that measured it; a React
|
|
1308
|
+
// effect can be skipped when DSH re-renders the column behind our back.
|
|
1309
|
+
if (activeRef.current && next) applyReservedPadding(next.reserve);
|
|
1310
|
+
else releaseReservedPadding();
|
|
1274
1311
|
};
|
|
1275
1312
|
function schedule() {
|
|
1276
1313
|
if (!frame) frame = window.requestAnimationFrame(measure);
|
|
@@ -1285,34 +1322,11 @@ window.__ModuleLoader__.load({
|
|
|
1285
1322
|
if (frame) window.cancelAnimationFrame(frame);
|
|
1286
1323
|
};
|
|
1287
1324
|
}, []);
|
|
1288
|
-
|
|
1325
|
+
React.useEffect(() => () => { releaseReservedPadding(); }, []);
|
|
1289
1326
|
React.useEffect(() => {
|
|
1290
|
-
if (!active
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
if (!column) return undefined;
|
|
1294
|
-
const saved = column.style.getPropertyValue('padding-right');
|
|
1295
|
-
const priority = column.style.getPropertyPriority('padding-right');
|
|
1296
|
-
const wanted = reserve + 'px';
|
|
1297
|
-
const apply = () => {
|
|
1298
|
-
if (column.style.getPropertyValue('padding-right') !== wanted) {
|
|
1299
|
-
column.style.setProperty('padding-right', wanted, 'important');
|
|
1300
|
-
}
|
|
1301
|
-
};
|
|
1302
|
-
apply();
|
|
1303
|
-
// DSH re-renders the column and rewrites its style attribute, so watch it.
|
|
1304
|
-
const observer = typeof MutationObserver === 'function'
|
|
1305
|
-
? new MutationObserver(apply)
|
|
1306
|
-
: null;
|
|
1307
|
-
if (observer) observer.observe(column, { attributes: true, attributeFilter: ['style'] });
|
|
1308
|
-
const timer = window.setInterval(apply, 1000);
|
|
1309
|
-
return () => {
|
|
1310
|
-
if (observer) observer.disconnect();
|
|
1311
|
-
window.clearInterval(timer);
|
|
1312
|
-
if (saved) column.style.setProperty('padding-right', saved, priority);
|
|
1313
|
-
else column.style.removeProperty('padding-right');
|
|
1314
|
-
};
|
|
1315
|
-
}, [active, reserve]);
|
|
1327
|
+
if (!active) releaseReservedPadding();
|
|
1328
|
+
}, [active]);
|
|
1329
|
+
|
|
1316
1330
|
const shown = active && box !== null;
|
|
1317
1331
|
return h('div', {
|
|
1318
1332
|
'data-ustc-quota-dock': 'right',
|
package/index.js
CHANGED
|
@@ -25,7 +25,7 @@ const ROUTE_PATH = '/plugins/dsh-ustc-quota/snapshot';
|
|
|
25
25
|
const UPDATE_PATH = '/plugins/dsh-ustc-quota/update';
|
|
26
26
|
const UPDATE_APPLY_PATH = '/plugins/dsh-ustc-quota/update/apply';
|
|
27
27
|
const UPDATE_TOKEN_TTL_MS = 30 * 60 * 1000;
|
|
28
|
-
const PLUGIN_VERSION = '1.1.
|
|
28
|
+
const PLUGIN_VERSION = '1.1.30';
|
|
29
29
|
const KEY_INFO_PATH = 'key/info';
|
|
30
30
|
const USER_INFO_PATH = 'user/info';
|
|
31
31
|
const DISCOVERY_TTL_MS = 30000;
|
|
@@ -87,7 +87,7 @@ export function apply(ctx, config) {
|
|
|
87
87
|
request.on('end', () => {
|
|
88
88
|
try {
|
|
89
89
|
const file = path.join(os.tmpdir(), 'dsh-ustc-quota-diag.jsonl');
|
|
90
|
-
fs.appendFileSync(file, String(body).replace(
|
|
90
|
+
fs.appendFileSync(file, String(body).replace(/[\r\n]+/g, ' ') + String.fromCharCode(10));
|
|
91
91
|
response.writeHead(204, { 'cache-control': 'no-store' });
|
|
92
92
|
response.end();
|
|
93
93
|
} catch {
|
package/package.json
CHANGED