@refeain/dsh-xdpool 3.0.7 → 3.0.9

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
@@ -269,7 +269,7 @@ window.__ModuleLoader__.load({
269
269
  const POOL_NAV_ICON_MASK_URL = `data:image/svg+xml;utf8,${encodeURIComponent(POOL_NAV_ICON_SVG)}`;
270
270
  //#endregion
271
271
  //#region src/version.ts
272
- const POOL_VERSION = "3.0.6";
272
+ const POOL_VERSION = "3.0.9";
273
273
  function compareVersions(left, right) {
274
274
  const parse = (value) => {
275
275
  const [core, ...rest] = value.trim().replace(/^v/u, "").split("-");
@@ -10314,7 +10314,7 @@ window.__ModuleLoader__.load({
10314
10314
  return "签到失败";
10315
10315
  }
10316
10316
  }
10317
- function ChannelPoolSection({ t, active, onAddAccount, autoClaim, autoClaimBusy, onAutoClaim, autoClaimRunning, onAutoClaimRun, banner, regionCards }) {
10317
+ function ChannelPoolSection({ t, active, onAddAccount, autoClaim, autoClaimBusy, onAutoClaim, autoClaimRunning, onAutoClaimRun, autoClaimReport, autoClaimFailing, banner, regionCards }) {
10318
10318
  const [ownActive, setOwnActive] = (0, react.useState)("");
10319
10319
  const [loginState, setLoginState] = (0, react.useState)(void 0);
10320
10320
  const loginAbort = (0, react.useRef)(void 0);
@@ -11640,6 +11640,11 @@ window.__ModuleLoader__.load({
11640
11640
  (0, react_jsx_runtime.jsx)("span", {
11641
11641
  className: "policy-hint",
11642
11642
  children: t?.("channelpool.autoClaimHint") ?? "开着就会在后台领每天的积分,不用手动点。"
11643
+ }),
11644
+ autoClaimReport === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
11645
+ className: "sum-sub",
11646
+ ...autoClaimFailing === true ? { "data-tone": "err" } : {},
11647
+ children: autoClaimReport
11643
11648
  })
11644
11649
  ]
11645
11650
  })]
@@ -15286,7 +15291,9 @@ window.__ModuleLoader__.load({
15286
15291
  })]
15287
15292
  });
15288
15293
  }
15289
- Object.freeze({
15294
+ //#endregion
15295
+ //#region src/client/region-card.tsx
15296
+ const REGION_CHANNEL_BY_REGION = Object.freeze({
15290
15297
  cn: "buddy",
15291
15298
  global: "workbuddy"
15292
15299
  });
@@ -16140,9 +16147,30 @@ window.__ModuleLoader__.load({
16140
16147
  }
16141
16148
  const AUTOMATION_POLL_MS = 2e3;
16142
16149
  const AUTOMATION_POLL_ATTEMPTS = 90;
16150
+ const AUTOMATION_JOBS = [
16151
+ "checkin",
16152
+ "report",
16153
+ "tasks",
16154
+ "streak",
16155
+ "travel",
16156
+ "compensation"
16157
+ ];
16143
16158
  function hoursOrDefault(configured, fallback) {
16144
16159
  return configured !== void 0 && configured.length > 0 ? [...configured] : [...fallback];
16145
16160
  }
16161
+ function automationJobs(status) {
16162
+ const jobs = status?.automation?.jobs;
16163
+ if (jobs === void 0) return [];
16164
+ return AUTOMATION_JOBS.map((kind) => jobs[kind]);
16165
+ }
16166
+ const FAILURE_LINES_SHOWN = 2;
16167
+ function automationFailures(status) {
16168
+ const lines = automationJobs(status).flatMap((job) => job.failures ?? []);
16169
+ if (lines.length === 0) return void 0;
16170
+ const shown = lines.slice(0, FAILURE_LINES_SHOWN);
16171
+ const hidden = lines.length - shown.length;
16172
+ return hidden > 0 ? `${shown.join(" · ")} · +${String(hidden)}` : shown.join(" · ");
16173
+ }
16146
16174
  const REGION_CARDS = ["cn", "global"];
16147
16175
  function PoolCard({ t, settingsScope }) {
16148
16176
  const settingsWritable = settingsScope?.getSnapshot().writable === true;
@@ -16510,6 +16538,7 @@ window.__ModuleLoader__.load({
16510
16538
  };
16511
16539
  t?.("row.title");
16512
16540
  t?.("row.desc");
16541
+ const showPoolAccounts = selectedChannel === REGION_CHANNEL_BY_REGION.cn || selectedChannel === REGION_CHANNEL_BY_REGION.global;
16513
16542
  return (0, react_jsx_runtime.jsx)(PoolShell, {
16514
16543
  t,
16515
16544
  version: POOL_VERSION,
@@ -16550,7 +16579,7 @@ window.__ModuleLoader__.load({
16550
16579
  style: { display: "contents" },
16551
16580
  children: (0, react_jsx_runtime.jsx)(ChannelPoolSection, {
16552
16581
  t,
16553
- regionCards: ["cn", "global"].map((region) => {
16582
+ regionCards: showPoolAccounts ? ["cn", "global"].map((region) => {
16554
16583
  const here = statusOf(region);
16555
16584
  const rows = here?.accounts ?? [];
16556
16585
  if (rows.length === 0) return null;
@@ -16563,7 +16592,7 @@ window.__ModuleLoader__.load({
16563
16592
  children: [region === "cn" ? t?.("row.tabCn") ?? "CN" : t?.("row.tabGlobal") ?? "Global", ` · ${String(rows.length)}`]
16564
16593
  })
16565
16594
  }), (0, react_jsx_runtime.jsx)("div", {
16566
- className: "xdp-accts",
16595
+ className: "accts",
16567
16596
  children: rows.map((account) => (0, react_jsx_runtime.jsx)(AccountCard, {
16568
16597
  account,
16569
16598
  t,
@@ -16585,7 +16614,7 @@ window.__ModuleLoader__.load({
16585
16614
  }, account.id))
16586
16615
  })]
16587
16616
  }, region);
16588
- }),
16617
+ }) : void 0,
16589
16618
  active: selectedChannel,
16590
16619
  onAddAccount: () => {
16591
16620
  setPage("channels");
@@ -16599,6 +16628,8 @@ window.__ModuleLoader__.load({
16599
16628
  onAutoClaimRun: () => {
16600
16629
  runAutomationJob("cn");
16601
16630
  },
16631
+ autoClaimReport: automationFailures(statusOf("cn")),
16632
+ autoClaimFailing: automationJobs(statusOf("cn")).some((job) => job.failed > 0),
16602
16633
  banner: flash === void 0 && error === void 0 ? void 0 : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [flash === void 0 ? null : (0, react_jsx_runtime.jsx)("p", {
16603
16634
  className: "note",
16604
16635
  children: flash
package/lib/index.d.ts CHANGED
@@ -1716,6 +1716,18 @@ export declare class WorkBuddyAccountPool {
1716
1716
  * Returns true when the token is known good afterwards (refreshed, or still
1717
1717
  * valid), false when the credential was proven dead.
1718
1718
  */
1719
+ /**
1720
+ * 取一个账号「可以用来发一次请求」的凭据:过期就先刷新。
1721
+ *
1722
+ * 签到 / 积分这些端点走的是「按 id 直接找账号」的路径,和选号路径不同 ——
1723
+ * 以前它们直接拿池里的 `account.credential`,凭据过期时上游回 401,界面只能
1724
+ * 说「领取失败」,而同一时刻对话却正常(对话走 `getAvailableAccount`,那里会
1725
+ * 先 `ensureFresh`)。用户反馈的「积分领取全部失败」就是这一处。
1726
+ *
1727
+ * 返回 undefined 表示「刷新失败」:调用方应当直接告诉用户重新登录,
1728
+ * 而不是拿旧 token 再去撞一次 401。
1729
+ */
1730
+ freshCredential(id: string): Promise<WorkBuddyCredential | undefined>;
1719
1731
  private ensureFresh;
1720
1732
  /**
1721
1733
  * Cool a whole account after the upstream reports its credits are spent.
@@ -2528,6 +2540,19 @@ interface PoolWebAutomationJob {
2528
2540
  claimed: number;
2529
2541
  /** One-line summary of the last run. */
2530
2542
  message?: string;
2543
+ /**
2544
+ * Why each failing account failed, one line per account, already redacted.
2545
+ *
2546
+ * `message` counts the failures; this names them. Before it existed the card
2547
+ * could say "4 accounts ok, 2 failed" and nothing else, so an account that
2548
+ * failed because the gateway has no check-in activity read exactly like one
2549
+ * whose token expired — two opposite pieces of advice at the same glance.
2550
+ *
2551
+ * Absent rather than empty when the last run had no failures: the card keys
2552
+ * its warning line off presence, and an empty array would keep a stale line
2553
+ * of red on screen after a clean run.
2554
+ */
2555
+ failures?: readonly string[];
2531
2556
  /**
2532
2557
  * What the last run actually did, in the words of the task board.
2533
2558
  *
@@ -3838,6 +3863,19 @@ interface AutomationJobState {
3838
3863
  */
3839
3864
  progress?: string;
3840
3865
  message?: string;
3866
+ /**
3867
+ * Why each failing account failed, one line per account, already redacted.
3868
+ *
3869
+ * `message` counts the failures; this names them. Without it the card could
3870
+ * say "4 accounts ok, 2 failed" and nothing else — and the reason lived only
3871
+ * in `logger.warn`, which on a desktop box goes to a log nobody opens. That
3872
+ * made "this gateway has no check-in activity" (waiting will never help)
3873
+ * indistinguishable from "the token expired" (sign in again works).
3874
+ *
3875
+ * Absent when the last run had no failures, rather than an empty array, so a
3876
+ * stale reason from a previous run cannot survive a clean one.
3877
+ */
3878
+ failures?: readonly string[];
3841
3879
  }
3842
3880
  /**
3843
3881
  * What the automation earned for ONE account today.