dsh-ustc-quota 1.1.52 → 1.1.54

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