dsh-plugin-subscription-oauth 0.11.0 → 0.12.0

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
@@ -936,7 +936,16 @@ const styles = {
936
936
  height: 8,
937
937
  borderRadius: "50%",
938
938
  flexShrink: 0,
939
- boxShadow: "0 0 0 3px var(--dsw-alias-state-success-primary, transparent)"
939
+ border: "1.5px solid var(--dsw-alias-label-dimmed)",
940
+ background: "transparent"
941
+ },
942
+ dotLive: {
943
+ borderColor: "var(--dsw-alias-state-success-primary, #067647)",
944
+ background: "var(--dsw-alias-state-success-primary, #067647)"
945
+ },
946
+ dotBusy: {
947
+ borderColor: "var(--dsw-alias-state-warn-primary, #f5a524)",
948
+ background: "var(--dsw-alias-state-warn-primary, #f5a524)"
940
949
  },
941
950
  name: {
942
951
  fontWeight: 600,
@@ -944,15 +953,6 @@ const styles = {
944
953
  lineHeight: "22px",
945
954
  color: "var(--dsw-alias-label-primary)"
946
955
  },
947
- providerId: {
948
- fontSize: 11,
949
- lineHeight: "16px",
950
- color: "var(--dsw-alias-label-dimmed)",
951
- padding: "1px 6px",
952
- borderRadius: 999,
953
- background: "var(--dsw-alias-bg-layer-3, var(--dsw-alias-bg-layer-1))",
954
- fontFamily: "monospace"
955
- },
956
956
  statusLine: {
957
957
  margin: 0,
958
958
  fontSize: 12,
@@ -1183,6 +1183,12 @@ const styles = {
1183
1183
  background: "var(--dsw-alias-bg-layer-1)",
1184
1184
  border: "0.5px solid var(--dsw-alias-border-l2)"
1185
1185
  },
1186
+ usageInline: {
1187
+ display: "flex",
1188
+ flexDirection: "column",
1189
+ gap: 6,
1190
+ marginTop: 4
1191
+ },
1186
1192
  modelRow: {
1187
1193
  display: "flex",
1188
1194
  alignItems: "flex-start",
@@ -1291,11 +1297,11 @@ const styles = {
1291
1297
  },
1292
1298
  divider: { borderTop: "0.5px solid var(--dsw-alias-border-l2)" }
1293
1299
  };
1294
- /** Status dot color for one provider's connection state. */
1295
- function dotColor(status) {
1296
- if (status.busy) return "var(--dsw-alias-state-warn-label)";
1297
- if (status.loggedIn) return "var(--dsw-alias-state-success-primary)";
1298
- return "var(--dsw-alias-label-dimmed)";
1300
+ /** Status dot style for one provider's connection state. */
1301
+ function dotStyle(status) {
1302
+ if (status.busy) return styles.dotBusy;
1303
+ if (status.loggedIn) return styles.dotLive;
1304
+ return {};
1299
1305
  }
1300
1306
  /** Localized label for one provider-owned detail row. */
1301
1307
  function detailLabel(t, row) {
@@ -1313,70 +1319,38 @@ function windowAmount(window$1) {
1313
1319
  if (window$1.used !== void 0 && window$1.limit !== void 0) return `${String(window$1.used)}/${String(window$1.limit)}`;
1314
1320
  return "—";
1315
1321
  }
1316
- /** One account's plan and metered allowances. */
1317
- function UsageBlock(props) {
1318
- const { usage, error, t, busyAction, onRefresh } = props;
1322
+ /** One account's metered windows, rendered under its account row. */
1323
+ function AccountUsage(props) {
1324
+ const { entry, t } = props;
1325
+ if (entry === void 0) return null;
1319
1326
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1320
- style: styles.usage,
1321
- children: [
1322
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1323
- style: styles.usageHeader,
1324
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1325
- style: styles.catalogTitle,
1326
- children: t("usageTitle")
1327
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1328
- type: "button",
1329
- className: "dsh-subscription-quiet",
1330
- style: styles.pushRight,
1331
- disabled: busyAction,
1332
- onClick: onRefresh,
1333
- children: busyAction ? t("refreshing") : t("usageRefresh")
1327
+ style: styles.usageInline,
1328
+ children: [entry.windows.map((window$1) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1329
+ style: styles.usageRow,
1330
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1331
+ style: styles.usageLine,
1332
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1333
+ style: styles.modelName,
1334
+ children: [
1335
+ windowLabel(t, window$1),
1336
+ " · ",
1337
+ windowAmount(window$1)
1338
+ ]
1339
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1340
+ style: styles.modelMeta,
1341
+ children: window$1.resetsAt === void 0 ? "" : formatReset$1(window$1.resetsAt, t)
1334
1342
  })]
1335
- }),
1336
- error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1337
- className: "dsh-subscription-error",
1338
- children: t("usageError", { message: error })
1339
- }),
1340
- usage.length === 0 && error === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1341
- style: styles.statusLine,
1342
- children: t("usageNone")
1343
- }),
1344
- usage.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1345
- style: styles.usageAccount,
1346
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1347
- style: styles.usageLine,
1348
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1349
- style: styles.modelMeta,
1350
- children: [entry.plan === void 0 ? entry.account : t("usagePlan", { plan: entry.plan }), entry.renewsAt === void 0 ? "" : ` · ${t("usageRenews", { time: formatTime(entry.renewsAt) })}`]
1351
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1352
- style: styles.modelMeta,
1353
- children: t("usageFetched", { time: formatTime(entry.fetchedAt) })
1354
- })]
1355
- }), entry.windows.map((window$1) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1356
- style: styles.usageRow,
1357
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1358
- style: styles.usageLine,
1359
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1360
- style: styles.modelName,
1361
- children: [
1362
- windowLabel(t, window$1),
1363
- " · ",
1364
- windowAmount(window$1)
1365
- ]
1366
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1367
- style: styles.modelMeta,
1368
- children: window$1.resetsAt === void 0 ? "" : formatReset$1(window$1.resetsAt, t)
1369
- })]
1370
- }), window$1.usedPercent !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1371
- className: "dsh-subscription-meter",
1372
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1373
- style: { width: `${String(Math.min(100, Math.max(0, window$1.usedPercent)))}%` },
1374
- "data-exhausted": window$1.usedPercent >= 90 ? "true" : "false"
1375
- })
1376
- })]
1377
- }, `${entry.account}-${window$1.label}`))]
1378
- }, entry.account))
1379
- ]
1343
+ }), window$1.usedPercent !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1344
+ className: "dsh-subscription-meter",
1345
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1346
+ style: { width: `${String(Math.min(100, Math.max(0, window$1.usedPercent)))}%` },
1347
+ "data-exhausted": window$1.usedPercent >= 90 ? "true" : "false"
1348
+ })
1349
+ })]
1350
+ }, `${entry.account}-${window$1.label}`)), entry.windows.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1351
+ style: styles.statusLine,
1352
+ children: t("usageNone")
1353
+ })]
1380
1354
  });
1381
1355
  }
1382
1356
  /** The pending-login block: a device code, or a link to the sign-in page. */
@@ -1601,7 +1575,7 @@ function ProviderCard(props) {
1601
1575
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1602
1576
  style: {
1603
1577
  ...styles.dot,
1604
- background: dotColor(status)
1578
+ ...dotStyle(status)
1605
1579
  },
1606
1580
  "aria-hidden": "true"
1607
1581
  }),
@@ -1609,10 +1583,6 @@ function ProviderCard(props) {
1609
1583
  style: styles.name,
1610
1584
  children: status.displayName
1611
1585
  }),
1612
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1613
- style: styles.providerId,
1614
- children: status.provider
1615
- }),
1616
1586
  status.loggedIn && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1617
1587
  style: styles.badgeDefault,
1618
1588
  children: t("badgeLive")
@@ -1658,52 +1628,62 @@ function ProviderCard(props) {
1658
1628
  className: "dsh-subscription-success",
1659
1629
  children: message.text
1660
1630
  }),
1661
- accounts.map((account) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1662
- style: styles.accountRow,
1663
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1664
- style: styles.accountHeader,
1665
- children: [
1666
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1667
- type: "button",
1668
- style: styles.starButton,
1669
- title: account.isDefault ? t("defaultBadge") : t("makeDefault"),
1670
- "aria-label": account.isDefault ? t("defaultBadge") : t("makeDefault"),
1671
- disabled: busyAction || account.isDefault,
1672
- onClick: () => {
1673
- props.onSetDefault(account.account);
1674
- },
1675
- children: account.isDefault ? "★" : "☆"
1676
- }),
1677
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1678
- style: styles.accountName,
1679
- children: account.label
1680
- }),
1681
- account.isDefault && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1682
- style: styles.badgeDefault,
1683
- children: t("defaultBadge")
1684
- }),
1685
- account.needsLogin === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1686
- style: styles.badgeWarn,
1687
- title: t("accountNeedsLoginHint"),
1688
- children: t("accountNeedsLogin")
1689
- }),
1690
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1691
- style: styles.statusLine,
1692
- children: account.expired ? t("accountExpired") : t("accountExpires", { time: formatTime(account.expiresAt) })
1693
- }),
1694
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1695
- type: "button",
1696
- className: "dsh-subscription-quiet",
1697
- style: styles.pushRight,
1698
- disabled: busyAction,
1699
- onClick: () => {
1700
- props.onLogout(account.account);
1701
- },
1702
- children: t("logout")
1703
- })
1704
- ]
1705
- })
1706
- }, account.account)),
1631
+ accounts.map((account) => {
1632
+ const usageEntry = (status.usage ?? []).find((entry) => entry.account === account.account);
1633
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1634
+ style: styles.accountRow,
1635
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1636
+ style: styles.accountHeader,
1637
+ children: [
1638
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1639
+ type: "button",
1640
+ style: styles.starButton,
1641
+ title: account.isDefault ? t("defaultBadge") : t("makeDefault"),
1642
+ "aria-label": account.isDefault ? t("defaultBadge") : t("makeDefault"),
1643
+ disabled: busyAction || account.isDefault,
1644
+ onClick: () => {
1645
+ props.onSetDefault(account.account);
1646
+ },
1647
+ children: account.isDefault ? "★" : "☆"
1648
+ }),
1649
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1650
+ style: styles.accountName,
1651
+ children: account.label
1652
+ }),
1653
+ account.isDefault && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1654
+ style: styles.badgeDefault,
1655
+ children: t("defaultBadge")
1656
+ }),
1657
+ account.needsLogin === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1658
+ style: styles.badgeWarn,
1659
+ title: t("accountNeedsLoginHint"),
1660
+ children: t("accountNeedsLogin")
1661
+ }),
1662
+ usageEntry?.plan !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1663
+ style: styles.badge,
1664
+ children: t("usagePlan", { plan: usageEntry.plan })
1665
+ }),
1666
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1667
+ style: styles.statusLine,
1668
+ children: account.expired ? t("accountExpired") : t("accountExpires", { time: formatTime(account.expiresAt) })
1669
+ }),
1670
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1671
+ type: "button",
1672
+ className: "dsh-subscription-quiet",
1673
+ style: styles.pushRight,
1674
+ disabled: busyAction,
1675
+ onClick: () => {
1676
+ props.onLogout(account.account);
1677
+ },
1678
+ children: t("logout")
1679
+ })
1680
+ ]
1681
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccountUsage, {
1682
+ entry: usageEntry,
1683
+ t
1684
+ })]
1685
+ }, account.account);
1686
+ }),
1707
1687
  status.loggedIn && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1708
1688
  style: styles.catalog,
1709
1689
  children: [
@@ -1894,13 +1874,6 @@ function ProviderCard(props) {
1894
1874
  })
1895
1875
  ]
1896
1876
  }),
1897
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageBlock, {
1898
- usage: status.usage ?? [],
1899
- ...status.usageError === void 0 ? {} : { error: status.usageError },
1900
- t,
1901
- busyAction,
1902
- onRefresh: props.onRefreshUsage
1903
- }),
1904
1877
  connectable && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1905
1878
  style: styles.actions,
1906
1879
  children: [