dsh-ustc-quota 1.1.33 → 1.1.37

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
@@ -108,7 +108,7 @@ key-c 8.7/30 29% 8.7/70 12% 11.1/100 11%
108
108
  ## 面板位置
109
109
 
110
110
  - 卡片默认在左侧边栏底部。**鼠标移到卡片上时,标题左边的品牌图标会变成方向图标**(布局图示,标出卡片将要去的那一侧),点一下即可换边;移开鼠标图标复原。选择会记住,重启后保持。
111
- - 右侧位置会在对话区右侧**预留一条槽**:插件给对话列加右侧内边距,正文与轮次导航条整体左移,卡片占住这条槽——因此不遮挡正文、不遮挡轮次导航条、也不遮挡右侧原生按钮。上沿从「对话 / 轨迹 / 看板」选项卡下的分隔线以下 6px 开始。
111
+ - 右侧位置会在对话区右侧**预留一条槽**:插件给对话列加右侧内边距(约列宽的 26%,封顶 34%),正文与轮次导航条整体左移,卡片占住这条槽——因此不遮挡正文、不遮挡轮次导航条、也不遮挡右侧原生按钮。上沿从「对话 / 轨迹 / 看板」选项卡下的分隔线以下 6px 开始。
112
112
  - 窄窗口或打开侧栏时槽宽自动收窄(下限 140px),卡片始终可见;如果连正文最小宽度都不够,则允许卡片比常规更窄,而不是消失。
113
113
  - 换边不重新加载:两处卡片共用同一份已取到的数据。底色用左侧边栏的底色(`--dsw-specific-sidebar-fill`),阴影与左侧一致。
114
114
  ## 更新
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.33';
14
+ const CLIENT_VERSION = '1.1.37';
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,76 +1141,44 @@ window.__ModuleLoader__.load({
1141
1141
  const DOCK_TRANSCRIPT_FLOOR = 360;
1142
1142
 
1143
1143
 
1144
- // Reserved right strip: applied from the measure loop so a DSH re-render of the
1145
- // column cannot drop it, and restored whenever the dock leaves the right seat.
1146
- let reservedColumn = null;
1147
- let reservedSaved = null;
1148
- let reservedSavedPriority = '';
1149
-
1150
- function applyReservedPadding(reserve) {
1151
- const holder = document.querySelector('[data-slot="main.conversation"]');
1152
- const column = holder ? (holder.firstElementChild || holder) : null;
1153
- if (!column) return false;
1154
- if (reservedColumn !== column) {
1155
- releaseReservedPadding();
1156
- reservedColumn = column;
1157
- reservedSaved = column.style.getPropertyValue('padding-right');
1158
- reservedSavedPriority = column.style.getPropertyPriority('padding-right');
1159
- }
1160
- const wanted = reserve + 'px';
1161
- if (column.style.getPropertyValue('padding-right') !== wanted) {
1162
- column.style.setProperty('padding-right', wanted, 'important');
1163
- }
1164
- return true;
1165
- }
1166
-
1167
- function releaseReservedPadding() {
1168
- if (!reservedColumn) return;
1169
- if (reservedSaved) reservedColumn.style.setProperty('padding-right', reservedSaved, reservedSavedPriority);
1170
- else reservedColumn.style.removeProperty('padding-right');
1171
- reservedColumn = null;
1172
- reservedSaved = null;
1173
- reservedSavedPriority = '';
1174
- }
1175
-
1176
1144
  function measureRightDock() {
1177
1145
  const holder = document.querySelector('[data-slot="main.conversation"]');
1178
1146
  const column = holder ? (holder.firstElementChild || holder) : null;
1179
1147
  if (!column) return null;
1180
1148
  const columnRect = column.getBoundingClientRect();
1181
- if (columnRect.width < 220 || columnRect.height < 160) return null;
1182
-
1183
- // Reserve a strip on the right of the conversation box instead of overlapping
1184
- // it: DSH centres the transcript and the turn rail inside the padding box, so
1185
- // padding-right slides both of them left and the dock owns the strip.
1186
- const columnWidth = Math.round(columnRect.width);
1187
- let width = Math.round(columnWidth * 0.26);
1188
- width = Math.min(DOCK_MAX_WIDTH, Math.max(DOCK_MIN_WIDTH, width));
1189
- if (columnWidth - (width + DOCK_GAP * 2) < DOCK_TRANSCRIPT_FLOOR) {
1190
- width = Math.max(DOCK_FLOOR_WIDTH, columnWidth - DOCK_TRANSCRIPT_FLOOR - DOCK_GAP * 2);
1149
+ if (columnRect.width < 200 || columnRect.height < 120) return null;
1150
+
1151
+ // Left bound: the conversation boundary the user drags. DSH draws two
1152
+ // .widthHandle strips beside the transcript; the card starts to their right,
1153
+ // so it never covers the transcript and never touches the boundary.
1154
+ let boundaryRight = null;
1155
+ for (const handle of document.querySelectorAll('[class*="widthHandle"]')) {
1156
+ if (handle.getAttribute('data-side') === 'left') continue;
1157
+ const rect = handle.getBoundingClientRect();
1158
+ if (rect.width <= 0 || rect.height < 40) continue;
1159
+ boundaryRight = boundaryRight === null ? rect.right : Math.max(boundaryRight, rect.right);
1191
1160
  }
1192
- // A collapsed right sidebar keeps a narrow icon rail at the column's right
1193
- // edge. Only a small inset counts as that rail: a wide one means the sidebar is
1194
- // open and the dock must not try to dodge a whole panel.
1195
- let railInset = 0;
1161
+ if (boundaryRight === null) boundaryRight = columnRect.left + columnRect.width * 0.5 + 24;
1162
+
1163
+ // Right bound: whatever native chrome lives at the column's right edge — the
1164
+ // turn rail when there are turns, otherwise the right-sidebar rail button.
1165
+ let rightLimit = columnRect.right;
1196
1166
  for (const button of document.querySelectorAll('button[aria-label]')) {
1197
1167
  const label = button.getAttribute('aria-label') || '';
1198
- if (!/右侧边栏/.test(label)) continue;
1168
+ if (!/turnNavigation|轮次|跳转|右侧边栏/i.test(label)) continue;
1199
1169
  const rect = button.getBoundingClientRect();
1200
1170
  if (rect.width <= 0 || rect.height <= 0) continue;
1201
- if (rect.left < columnRect.left || rect.left > columnRect.right) continue;
1202
- const inset = Math.round(columnRect.right - rect.left);
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);
1171
+ if (rect.left <= boundaryRight) continue;
1172
+ if (rect.left < rightLimit) rightLimit = rect.left;
1211
1173
  }
1174
+ if (rightLimit > columnRect.right) rightLimit = columnRect.right;
1175
+
1176
+ const leftEdge = Math.round(boundaryRight) + DOCK_GAP;
1177
+ const rightEdge = Math.round(rightLimit) - DOCK_GAP;
1178
+ const span = rightEdge - leftEdge;
1179
+ if (span < 40) return null;
1212
1180
 
1213
- // Vertical bound: never cross or touch the separator under the tab strip.
1181
+ // Vertical bound: below the conversation tab strip, above the column bottom.
1214
1182
  let contentTop = Math.round(columnRect.top) + DOCK_GAP;
1215
1183
  const tabStrip = document.querySelector('[data-conversation-tabs]');
1216
1184
  if (tabStrip) {
@@ -1223,9 +1191,9 @@ window.__ModuleLoader__.load({
1223
1191
 
1224
1192
  return {
1225
1193
  top: contentTop,
1226
- width,
1227
- reserve,
1228
- railInset,
1194
+ left: leftEdge,
1195
+ width: Math.max(span, 160),
1196
+ columnWidth: Math.round(columnRect.width),
1229
1197
  maxHeight: Math.max(120, Math.round(columnRect.bottom) - contentTop - DOCK_GAP),
1230
1198
  };
1231
1199
  }
@@ -1250,12 +1218,7 @@ window.__ModuleLoader__.load({
1250
1218
  observer = new ResizeObserver(schedule);
1251
1219
  observer.observe(column);
1252
1220
  }
1253
- const next = measureRightDock();
1254
- 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();
1221
+ setBox(measureRightDock());
1259
1222
  };
1260
1223
  function schedule() {
1261
1224
  if (!frame) frame = window.requestAnimationFrame(measure);
@@ -1270,10 +1233,6 @@ window.__ModuleLoader__.load({
1270
1233
  if (frame) window.cancelAnimationFrame(frame);
1271
1234
  };
1272
1235
  }, []);
1273
- React.useEffect(() => () => { releaseReservedPadding(); }, []);
1274
- React.useEffect(() => {
1275
- if (!active) releaseReservedPadding();
1276
- }, [active]);
1277
1236
 
1278
1237
  const shown = active && box !== null;
1279
1238
  return h('div', {
@@ -1281,7 +1240,7 @@ window.__ModuleLoader__.load({
1281
1240
  style: {
1282
1241
  position: 'fixed',
1283
1242
  top: box ? box.top : 0,
1284
- right: DOCK_GAP + (box ? box.railInset : 0),
1243
+ left: box ? box.left : 0,
1285
1244
  width: box ? box.width : DOCK_MIN_WIDTH,
1286
1245
  maxHeight: box ? box.maxHeight : 0,
1287
1246
  overflow: 'visible',
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.33';
25
+ const PLUGIN_VERSION = '1.1.37';
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.33",
3
+ "version": "1.1.37",
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).",