@iasiv5/dsh-quota-watch 0.0.14 → 0.0.15

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/lib/client.js CHANGED
@@ -88,7 +88,7 @@ var CARD_SELECTOR = "[data-dsh-quota-watch-card]";
88
88
  var FETCH_TIMEOUT_MS = 15e3;
89
89
  var COPY = {
90
90
  zh: {
91
- title: "\u5957\u9910\u76D1\u63A7",
91
+ title: "Token\u989D\u5EA6",
92
92
  openDetails: "\u67E5\u770B\u8BE6\u60C5",
93
93
  backToOverview: "\u8FD4\u56DE\u989D\u5EA6\u6982\u89C8",
94
94
  providerNames: { glm: "GLM", copilot: "Copilot" },
@@ -166,7 +166,7 @@ var STYLE_TEXT = `
166
166
  .dqw-stale-mark { flex: none; font-size: 9px; line-height: 14px; color: var(--dsw-alias-label-warning, #b46900); cursor: help; }
167
167
  .dqw-errtext { font-size: 10px; line-height: 14px; opacity: .7; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
168
168
  .dqw-rail-trigger { display: none; flex: none; align-items: center; justify-content: center; width: 36px; height: 36px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--dsw-alias-label-primary, inherit); cursor: pointer; transition: background-color .12s, color .12s; }
169
- .dqw-rail-trigger svg { display: block; width: 16px; height: 16px; }
169
+ .dqw-rail-trigger svg { display: block; width: 20px; height: 20px; }
170
170
  .dqw-rail-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
171
171
  .dqw-rail-trigger:active:not(:disabled), .dqw-rail-trigger[aria-expanded="true"] { background: var(--dsw-alias-interactive-bg-active, rgba(128,128,128,.18)); color: var(--dsw-alias-label-primary, inherit); }
172
172
  .dqw-rail-trigger:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #5b8def); outline-offset: 2px; }
@@ -178,7 +178,8 @@ var STYLE_TEXT = `
178
178
  .dqw-pop[hidden] { display: none; }
179
179
  .dqw-pop *, .dqw-pop *::before, .dqw-pop *::after { box-sizing: border-box; }
180
180
  .dqw-pop-title { margin: 0; font-size: 11px; font-weight: 600; line-height: 16px; }
181
- .dqw-pop-back { align-self: flex-start; margin: 0; padding: 3px 5px; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-secondary, inherit); font: inherit; font-size: 10.5px; line-height: 14px; cursor: pointer; }
181
+ .dqw-pop-back { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 28px; height: 28px; margin: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-secondary, inherit); cursor: pointer; }
182
+ .dqw-pop-back svg { display: block; width: 16px; height: 16px; }
182
183
  .dqw-pop-back:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
183
184
  .dqw-overview-list { display: flex; flex-direction: column; gap: 2px; }
184
185
  .dqw-overview-row { display: flex; align-items: center; width: 100%; gap: 6px; margin: 0; padding: 5px 4px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
@@ -250,8 +251,8 @@ function quotaIcon(doc) {
250
251
  const namespace = "http://www.w3.org/2000/svg";
251
252
  const svg = doc.createElementNS(namespace, "svg");
252
253
  svg.setAttribute("viewBox", "0 0 24 24");
253
- svg.setAttribute("width", "16");
254
- svg.setAttribute("height", "16");
254
+ svg.setAttribute("width", "20");
255
+ svg.setAttribute("height", "20");
255
256
  svg.setAttribute("fill", "none");
256
257
  svg.setAttribute("stroke", "currentColor");
257
258
  svg.setAttribute("stroke-width", "1.7");
@@ -260,7 +261,7 @@ function quotaIcon(doc) {
260
261
  svg.setAttribute("aria-hidden", "true");
261
262
  svg.setAttribute("focusable", "false");
262
263
  const arc = doc.createElementNS(namespace, "path");
263
- arc.setAttribute("d", "M4 17a8 8 0 0 1 16 0");
264
+ arc.setAttribute("d", "M4 17a8 8 0 0 1 16 0H4");
264
265
  const needle = doc.createElementNS(namespace, "path");
265
266
  needle.setAttribute("d", "m12 17 3.2-5.2");
266
267
  const hub = doc.createElementNS(namespace, "circle");
@@ -272,6 +273,24 @@ function quotaIcon(doc) {
272
273
  svg.append(arc, needle, hub);
273
274
  return svg;
274
275
  }
276
+ function backIcon(doc) {
277
+ const namespace = "http://www.w3.org/2000/svg";
278
+ const svg = doc.createElementNS(namespace, "svg");
279
+ svg.setAttribute("viewBox", "0 0 16 16");
280
+ svg.setAttribute("width", "16");
281
+ svg.setAttribute("height", "16");
282
+ svg.setAttribute("fill", "none");
283
+ svg.setAttribute("stroke", "currentColor");
284
+ svg.setAttribute("stroke-width", "1.7");
285
+ svg.setAttribute("stroke-linecap", "round");
286
+ svg.setAttribute("stroke-linejoin", "round");
287
+ svg.setAttribute("aria-hidden", "true");
288
+ svg.setAttribute("focusable", "false");
289
+ const chevrons = doc.createElementNS(namespace, "path");
290
+ chevrons.setAttribute("d", "M11 4 7 8l4 4M7 4 3 8l4 4");
291
+ svg.append(chevrons);
292
+ return svg;
293
+ }
275
294
  function kvRow(doc, label, value) {
276
295
  const row = doc.createElement("div");
277
296
  row.className = "dqw-kv";
@@ -483,7 +502,8 @@ function mountQuotaCard({
483
502
  back.className = "dqw-pop-back";
484
503
  back.dataset.action = "back-to-overview";
485
504
  back.setAttribute("aria-label", copy.backToOverview);
486
- back.textContent = copy.backToOverview;
505
+ back.title = copy.backToOverview;
506
+ back.append(backIcon(doc));
487
507
  detail.append(back, text(doc, "p", "dqw-pop-title", copy.providerNames[key]));
488
508
  }
489
509
  if (provider?.status === "stale") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iasiv5/dsh-quota-watch",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "DSH Web sidebar monitor for GLM Coding Plan quotas and GitHub Copilot credits",
5
5
  "type": "module",
6
6
  "main": "./src/host.mjs",
package/src/client.mjs CHANGED
@@ -9,7 +9,7 @@ const FETCH_TIMEOUT_MS = 15_000
9
9
 
10
10
  const COPY = {
11
11
  zh: {
12
- title: '套餐监控',
12
+ title: 'Token额度',
13
13
  openDetails: '查看详情',
14
14
  backToOverview: '返回额度概览',
15
15
  providerNames: { glm: 'GLM', copilot: 'Copilot' },
@@ -88,7 +88,7 @@ const STYLE_TEXT = `
88
88
  .dqw-stale-mark { flex: none; font-size: 9px; line-height: 14px; color: var(--dsw-alias-label-warning, #b46900); cursor: help; }
89
89
  .dqw-errtext { font-size: 10px; line-height: 14px; opacity: .7; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
90
90
  .dqw-rail-trigger { display: none; flex: none; align-items: center; justify-content: center; width: 36px; height: 36px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--dsw-alias-label-primary, inherit); cursor: pointer; transition: background-color .12s, color .12s; }
91
- .dqw-rail-trigger svg { display: block; width: 16px; height: 16px; }
91
+ .dqw-rail-trigger svg { display: block; width: 20px; height: 20px; }
92
92
  .dqw-rail-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
93
93
  .dqw-rail-trigger:active:not(:disabled), .dqw-rail-trigger[aria-expanded="true"] { background: var(--dsw-alias-interactive-bg-active, rgba(128,128,128,.18)); color: var(--dsw-alias-label-primary, inherit); }
94
94
  .dqw-rail-trigger:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #5b8def); outline-offset: 2px; }
@@ -100,7 +100,8 @@ const STYLE_TEXT = `
100
100
  .dqw-pop[hidden] { display: none; }
101
101
  .dqw-pop *, .dqw-pop *::before, .dqw-pop *::after { box-sizing: border-box; }
102
102
  .dqw-pop-title { margin: 0; font-size: 11px; font-weight: 600; line-height: 16px; }
103
- .dqw-pop-back { align-self: flex-start; margin: 0; padding: 3px 5px; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-secondary, inherit); font: inherit; font-size: 10.5px; line-height: 14px; cursor: pointer; }
103
+ .dqw-pop-back { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 28px; height: 28px; margin: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-secondary, inherit); cursor: pointer; }
104
+ .dqw-pop-back svg { display: block; width: 16px; height: 16px; }
104
105
  .dqw-pop-back:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
105
106
  .dqw-overview-list { display: flex; flex-direction: column; gap: 2px; }
106
107
  .dqw-overview-row { display: flex; align-items: center; width: 100%; gap: 6px; margin: 0; padding: 5px 4px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
@@ -179,8 +180,8 @@ function quotaIcon(doc) {
179
180
  const namespace = 'http://www.w3.org/2000/svg'
180
181
  const svg = doc.createElementNS(namespace, 'svg')
181
182
  svg.setAttribute('viewBox', '0 0 24 24')
182
- svg.setAttribute('width', '16')
183
- svg.setAttribute('height', '16')
183
+ svg.setAttribute('width', '20')
184
+ svg.setAttribute('height', '20')
184
185
  svg.setAttribute('fill', 'none')
185
186
  svg.setAttribute('stroke', 'currentColor')
186
187
  svg.setAttribute('stroke-width', '1.7')
@@ -189,7 +190,7 @@ function quotaIcon(doc) {
189
190
  svg.setAttribute('aria-hidden', 'true')
190
191
  svg.setAttribute('focusable', 'false')
191
192
  const arc = doc.createElementNS(namespace, 'path')
192
- arc.setAttribute('d', 'M4 17a8 8 0 0 1 16 0')
193
+ arc.setAttribute('d', 'M4 17a8 8 0 0 1 16 0H4')
193
194
  const needle = doc.createElementNS(namespace, 'path')
194
195
  needle.setAttribute('d', 'm12 17 3.2-5.2')
195
196
  const hub = doc.createElementNS(namespace, 'circle')
@@ -202,6 +203,25 @@ function quotaIcon(doc) {
202
203
  return svg
203
204
  }
204
205
 
206
+ function backIcon(doc) {
207
+ const namespace = 'http://www.w3.org/2000/svg'
208
+ const svg = doc.createElementNS(namespace, 'svg')
209
+ svg.setAttribute('viewBox', '0 0 16 16')
210
+ svg.setAttribute('width', '16')
211
+ svg.setAttribute('height', '16')
212
+ svg.setAttribute('fill', 'none')
213
+ svg.setAttribute('stroke', 'currentColor')
214
+ svg.setAttribute('stroke-width', '1.7')
215
+ svg.setAttribute('stroke-linecap', 'round')
216
+ svg.setAttribute('stroke-linejoin', 'round')
217
+ svg.setAttribute('aria-hidden', 'true')
218
+ svg.setAttribute('focusable', 'false')
219
+ const chevrons = doc.createElementNS(namespace, 'path')
220
+ chevrons.setAttribute('d', 'M11 4 7 8l4 4M7 4 3 8l4 4')
221
+ svg.append(chevrons)
222
+ return svg
223
+ }
224
+
205
225
  /** Aligned label/value line used by the simplified Copilot detail. */
206
226
  function kvRow(doc, label, value) {
207
227
  const row = doc.createElement('div')
@@ -432,7 +452,8 @@ export function mountQuotaCard({
432
452
  back.className = 'dqw-pop-back'
433
453
  back.dataset.action = 'back-to-overview'
434
454
  back.setAttribute('aria-label', copy.backToOverview)
435
- back.textContent = copy.backToOverview
455
+ back.title = copy.backToOverview
456
+ back.append(backIcon(doc))
436
457
  detail.append(back, text(doc, 'p', 'dqw-pop-title', copy.providerNames[key]))
437
458
  }
438
459
  if (provider?.status === 'stale') {