dsh-ustc-quota 1.1.52 → 1.1.53

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 +34 -4
  2. package/index.js +1 -1
  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.52';
14
+ const CLIENT_VERSION = '1.1.53';
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`;
@@ -587,11 +587,15 @@ window.__ModuleLoader__.load({
587
587
  display: 'flex',
588
588
  flexDirection: 'row',
589
589
  alignItems: 'center',
590
- gap: 3,
590
+ gap: 2,
591
+ padding: 0,
592
+ margin: 0,
591
593
  },
592
594
  inlineBar: {
593
595
  flex: '1 1 0',
594
596
  minWidth: 8,
597
+ margin: 0,
598
+ padding: 0,
595
599
  height: 5,
596
600
  position: 'relative',
597
601
  borderRadius: 999,
@@ -628,7 +632,7 @@ window.__ModuleLoader__.load({
628
632
  percentWide: {
629
633
  flex: '0 0 auto',
630
634
  width: 24,
631
- textAlign: 'right',
635
+ textAlign: 'left',
632
636
  fontSize: 8.5,
633
637
  color: 'var(--dsw-alias-label-secondary)',
634
638
  whiteSpace: 'nowrap',
@@ -1914,6 +1918,32 @@ window.__ModuleLoader__.load({
1914
1918
  if (text.length > valueChars) valueChars = text.length;
1915
1919
  }
1916
1920
  }
1921
+ // Width = exactly the widest value on screen, measured with the card's own font.
1922
+ let valueWidthPx = null;
1923
+ try {
1924
+ const rootNode = rootRef.current;
1925
+ const canvas = document.createElement('canvas');
1926
+ const ctx = canvas && canvas.getContext ? canvas.getContext('2d') : null;
1927
+ if (ctx) {
1928
+ const family = rootNode ? getComputedStyle(rootNode).fontFamily : 'system-ui';
1929
+ ctx.font = '650 10px ' + family;
1930
+ let widest = 0;
1931
+ for (const key of keys) {
1932
+ for (const window of (key.windows || [])) {
1933
+ const usedValue = typeof window.used === 'number' && Number.isFinite(window.used) ? window.used : null;
1934
+ const limitValue = typeof window.limit === 'number' && Number.isFinite(window.limit) ? window.limit : null;
1935
+ const text = usedValue === null
1936
+ ? '—'
1937
+ : `${formatNumber(usedValue)}/${limitValue === null ? '—' : formatNumber(limitValue)}`;
1938
+ const rendered = window.state === 'stale' ? `≈ ${text}` : text;
1939
+ widest = Math.max(widest, ctx.measureText(rendered).width);
1940
+ }
1941
+ }
1942
+ if (widest > 0) valueWidthPx = Math.ceil(widest) + 1;
1943
+ }
1944
+ } catch {
1945
+ // measurement is best-effort; the ch fallback below still aligns the columns
1946
+ }
1917
1947
  // Stale windows render an '≈ ' prefix, so the value column needs those chars too.
1918
1948
  const hasStaleWindow = keys.some((key) => (key.windows || []).some((window) => window.state === 'stale'));
1919
1949
  if (hasStaleWindow) valueChars += 2;
@@ -1921,7 +1951,7 @@ window.__ModuleLoader__.load({
1921
1951
  ...STYLE.table,
1922
1952
  '--ustc-key-col': `${keyColumnWidth}px`,
1923
1953
  '--ustc-gap': wideLayout ? '8px' : '4px',
1924
- '--ustc-value-w': `${Math.min(12, valueChars + 0.5)}ch`,
1954
+ '--ustc-value-w': valueWidthPx ? `${valueWidthPx}px` : `${Math.min(12, valueChars + 0.5)}ch`,
1925
1955
  };
1926
1956
  const versionTitle = updateInfo && updateInfo.updateAvailable
1927
1957
  ? `${t('updateAvailable')} v${updateInfo.latestVersion}`
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.52';
25
+ const PLUGIN_VERSION = '1.1.53';
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.52",
3
+ "version": "1.1.53",
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).",