dshmarket 1.37.0 → 1.38.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/client/client.js CHANGED
@@ -135,6 +135,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
135
135
  notesNone: "该插件未提供更新说明。",
136
136
  notesLoadFail: "暂时读不到更新说明,稍后再试。",
137
137
  restore: "恢复",
138
+ restoreOnline: "换用线上版本",
138
139
  restoreHint: "会卸载本地版本,重新安装线上版本,并保持更新检测。无法回退,请二次确认。",
139
140
  restoreContinue: "继续更新",
140
141
  restoreNoCatalog: "精选目录里没有这个插件,无法恢复到线上版本。可以卸载本地版,或继续用本地开发。",
@@ -603,6 +604,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
603
604
  notesNone: "This plugin does not publish update notes.",
604
605
  notesLoadFail: "Update notes are unavailable right now — try again later.",
605
606
  restore: "Restore",
607
+ restoreOnline: "Use online version",
606
608
  restoreHint: "This will uninstall the local version, reinstall the catalog version, and keep update checks. This cannot be undone — please confirm again.",
607
609
  restoreContinue: "Continue update",
608
610
  restoreNoCatalog: "This plugin is not in the curated catalog, so it cannot be restored. Uninstall the local copy, or keep developing it locally.",
@@ -5469,6 +5471,21 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
5469
5471
  const [qThemes, setQThemes] = (0, react.useState)("");
5470
5472
  const [qInstalled, setQInstalled] = (0, react.useState)("");
5471
5473
  const [cat, setCat] = (0, react.useState)("all");
5474
+ (0, react.useEffect)(() => {
5475
+ const target = props.preferredSubsectionId;
5476
+ if (target === void 0) return;
5477
+ const separator = target.indexOf(":");
5478
+ const kind = separator === -1 ? target : target.slice(0, separator);
5479
+ const value = separator === -1 ? "" : target.slice(separator + 1);
5480
+ if (kind === "installed") {
5481
+ setTab("installed");
5482
+ setQInstalled(value);
5483
+ } else if (kind === "discover") {
5484
+ setTab("discover");
5485
+ setCat("all");
5486
+ setQ(value);
5487
+ }
5488
+ }, [props.preferredSubsectionId]);
5472
5489
  const [confirming, setConfirming] = (0, react.useState)(null);
5473
5490
  /** The plugin whose comment thread is open, or null. */
5474
5491
  const [commentsFor, setCommentsFor] = (0, react.useState)(null);
@@ -6738,10 +6755,10 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
6738
6755
  });
6739
6756
  }, [doGroupAction, groups]);
6740
6757
  const selfName = installed["dshmarket"] !== void 0 ? "dshmarket" : "dsh-market";
6741
- const updatableNames = Object.keys(installed).filter((name) => name !== selfName && !updatedNames.includes(name) && updates[name] && updates[name].updateAvailable);
6758
+ const batchUpdatableNames = Object.keys(installed).filter((name) => name !== selfName && !updatedNames.includes(name) && updates[name] && updates[name].updateAvailable).filter((name) => updates[name]?.restoreRequired !== true);
6742
6759
  const installedOtherCount = Object.keys(installed).filter((name) => name !== selfName).length;
6743
6760
  const doUpdateAll = (0, react.useCallback)(() => {
6744
- const names = updatableNames.slice();
6761
+ const names = batchUpdatableNames.slice();
6745
6762
  setUpdatingAll(true);
6746
6763
  const next = () => {
6747
6764
  const name = names.shift();
@@ -6752,7 +6769,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
6752
6769
  doUpdate(name).then(next, next);
6753
6770
  };
6754
6771
  next();
6755
- }, [updatableNames, doUpdate]);
6772
+ }, [batchUpdatableNames, doUpdate]);
6756
6773
  const finishRestore = (0, react.useCallback)((body) => {
6757
6774
  const errors = Array.isArray(body.errors) ? body.errors : [];
6758
6775
  const unportable = Array.isArray(body.unportable) ? body.unportable : [];
@@ -7510,18 +7527,20 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
7510
7527
  }),
7511
7528
  (() => {
7512
7529
  const self = installed["dshmarket"] !== void 0 ? "dshmarket" : "dsh-market";
7513
- return updates[self] && updates[self].updateAvailable && !updatedNames.includes(self) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
7530
+ const status = updates[self];
7531
+ return status && status.updateAvailable && !updatedNames.includes(self) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
7514
7532
  variant: "primary",
7515
7533
  size: "sm",
7516
7534
  disabled: updatingName !== null || busyUrl !== null,
7517
7535
  onClick: () => {
7518
7536
  setTab("installed");
7519
- doUpdate(self);
7537
+ if (status.restoreRequired === true) askRestore(self);
7538
+ else doUpdate(self);
7520
7539
  },
7521
- children: updatingName === self ? t("updating") : t("marketUpdate")
7540
+ children: updatingName === self ? t("updating") : status.restoreRequired === true ? t("restoreOnline") : t("marketUpdate")
7522
7541
  });
7523
7542
  })(),
7524
- updatableNames.length >= 2 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
7543
+ batchUpdatableNames.length >= 2 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
7525
7544
  variant: "primary",
7526
7545
  size: "sm",
7527
7546
  disabled: updatingAll || updatingName !== null || busyUrl !== null || removingName !== null,
@@ -7529,7 +7548,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
7529
7548
  setTab("installed");
7530
7549
  doUpdateAll();
7531
7550
  },
7532
- children: updatingAll ? t("updating") : t("updateAll") + " (" + updatableNames.length + ")"
7551
+ children: updatingAll ? t("updating") : t("updateAll") + " (" + batchUpdatableNames.length + ")"
7533
7552
  })
7534
7553
  ]
7535
7554
  }),
@@ -8881,8 +8900,11 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
8881
8900
  size: "sm",
8882
8901
  className: Market_module_css_default.warnBtn,
8883
8902
  disabled: updatingName !== null,
8884
- onClick: () => doUpdate(name),
8885
- children: t("update")
8903
+ onClick: () => {
8904
+ if (status.restoreRequired === true) askRestore(name);
8905
+ else doUpdate(name);
8906
+ },
8907
+ children: status.restoreRequired === true ? t("restoreOnline") : t("update")
8886
8908
  }) : localDev ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
8887
8909
  className: Market_module_css_default.metaTag,
8888
8910
  title: t("linkedDev"),
@@ -8897,7 +8919,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
8897
8919
  className: Market_module_css_default.dangerBtn,
8898
8920
  disabled: true,
8899
8921
  children: t("uninstalling")
8900
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [localDev && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
8922
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [localDev && status?.restoreRequired !== true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
8901
8923
  variant: "outline",
8902
8924
  size: "sm",
8903
8925
  disabled: removingName !== null || busyUrl !== null || updatingName !== null,
@@ -9411,7 +9433,8 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
9411
9433
  return {
9412
9434
  updateAvailable: own.updateAvailable === true,
9413
9435
  latest: own.latest ?? null,
9414
- channelSwitch: own.channelSwitch ?? null
9436
+ channelSwitch: own.channelSwitch ?? null,
9437
+ restoreRequired: own.restoreRequired === true
9415
9438
  };
9416
9439
  }
9417
9440
  /**
@@ -9433,6 +9456,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
9433
9456
  const [status, setStatus] = (0, react.useState)(null);
9434
9457
  const [update, setUpdate] = (0, react.useState)(null);
9435
9458
  const [phase, setPhase] = (0, react.useState)("idle");
9459
+ const [restoreConfirming, setRestoreConfirming] = (0, react.useState)(false);
9436
9460
  const [purge, setPurge] = (0, react.useState)(false);
9437
9461
  const [error, setError] = (0, react.useState)(null);
9438
9462
  /**
@@ -9482,6 +9506,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
9482
9506
  })).json();
9483
9507
  }, []);
9484
9508
  const onUpdate = (0, react.useCallback)((force = false) => {
9509
+ setRestoreConfirming(false);
9485
9510
  setPhase("working");
9486
9511
  setError(null);
9487
9512
  setStale(false);
@@ -9489,6 +9514,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
9489
9514
  try {
9490
9515
  const body = await post(api("/dsh-market/update"), {
9491
9516
  name: "dshmarket",
9517
+ ...update?.restoreRequired === true ? { restore: true } : {},
9492
9518
  ...force ? { force: true } : {}
9493
9519
  });
9494
9520
  if (body.ok === true) setPhase("updated");
@@ -9502,7 +9528,11 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
9502
9528
  setPhase("failed");
9503
9529
  }
9504
9530
  })();
9505
- }, [post, t]);
9531
+ }, [
9532
+ post,
9533
+ t,
9534
+ update?.restoreRequired
9535
+ ]);
9506
9536
  const onRemove = (0, react.useCallback)(() => {
9507
9537
  setPhase("working");
9508
9538
  setError(null);
@@ -9608,13 +9638,26 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
9608
9638
  variant: "primary",
9609
9639
  size: "sm",
9610
9640
  disabled: busy,
9611
- onClick: () => onUpdate()
9612
- }, t("setSelfUpdate")) : update?.channelSwitch != null ? (0, react.createElement)(_deepseek_ai_dsh_client_ui_primitives.Button, {
9641
+ onClick: () => {
9642
+ if (update.restoreRequired) setRestoreConfirming(true);
9643
+ else onUpdate();
9644
+ }
9645
+ }, update.restoreRequired ? t("restoreOnline") : t("setSelfUpdate")) : update?.channelSwitch != null ? (0, react.createElement)(_deepseek_ai_dsh_client_ui_primitives.Button, {
9613
9646
  variant: "outline",
9614
9647
  size: "sm",
9615
9648
  disabled: busy,
9616
9649
  onClick: () => onUpdate()
9617
- }, t("setChannelSwitch")) : null) : null, status?.selfManaged === true ? row(t("setChannel"), t(CHANNEL_HINT[status.channel]), (0, react.createElement)("div", { className: Market_module_css_default.setSeg }, (status?.channels ?? ["stable", "beta"]).map((id) => (0, react.createElement)("button", {
9650
+ }, t("setChannelSwitch")) : null) : null, status?.selfManaged === true && restoreConfirming ? (0, react.createElement)("div", { className: Market_module_css_default.setConfirm }, (0, react.createElement)("div", { className: Market_module_css_default.setHint }, t("restoreHint")), (0, react.createElement)("div", { className: Market_module_css_default.setActions }, (0, react.createElement)(_deepseek_ai_dsh_client_ui_primitives.Button, {
9651
+ variant: "ghost",
9652
+ size: "sm",
9653
+ onClick: () => {
9654
+ setRestoreConfirming(false);
9655
+ }
9656
+ }, t("setSelfCancel")), (0, react.createElement)(_deepseek_ai_dsh_client_ui_primitives.Button, {
9657
+ variant: "primary",
9658
+ size: "sm",
9659
+ onClick: () => onUpdate()
9660
+ }, t("restoreContinue")))) : null, status?.selfManaged === true ? row(t("setChannel"), t(CHANNEL_HINT[status.channel]), (0, react.createElement)("div", { className: Market_module_css_default.setSeg }, (status?.channels ?? ["stable", "beta"]).map((id) => (0, react.createElement)("button", {
9618
9661
  key: id,
9619
9662
  type: "button",
9620
9663
  className: status?.channel === id ? `${Market_module_css_default.setSegBtn} ${Market_module_css_default.setSegOn}` : Market_module_css_default.setSegBtn,
@@ -9725,14 +9768,15 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
9725
9768
  label: () => t("nav"),
9726
9769
  locale: NS,
9727
9770
  inject: () => ({ t })
9728
- }, () => (0, react.createElement)(MarketSection, {
9771
+ }, (ownerProps = {}) => (0, react.createElement)(MarketSection, {
9729
9772
  t,
9730
9773
  locale: ctx.locale,
9731
9774
  theme: ctx.theme,
9732
9775
  themeStore: {
9733
9776
  subscribe: (cb) => ctx.on("theme/change", cb),
9734
9777
  getSnapshot: () => ctx.theme.getTheme()
9735
- }
9778
+ },
9779
+ preferredSubsectionId: ownerProps.preferredSubsectionId
9736
9780
  }));
9737
9781
  if (typeof off === "function") retireSection = off;
9738
9782
  return off;