dsh-plugin-shop 0.7.5-beta.0 → 0.8.0-beta.1

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
@@ -4324,6 +4324,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4324
4324
  });
4325
4325
  const dsh_plugin_shop_shop_installed_result$schema = array(object({
4326
4326
  "name": string(),
4327
+ "source": union([literal("npm"), literal("github")]),
4328
+ "repo": union([_undefined(), string()]).optional(),
4329
+ "subdir": union([_undefined(), string()]).optional(),
4327
4330
  "installed": string(),
4328
4331
  "latest": string(),
4329
4332
  "outdated": boolean(),
@@ -4336,7 +4339,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4336
4339
  _undefined(),
4337
4340
  literal(false),
4338
4341
  literal(true)
4339
- ]).optional()
4342
+ ]).optional(),
4343
+ "source": union([
4344
+ _undefined(),
4345
+ literal("npm"),
4346
+ literal("github")
4347
+ ]).optional(),
4348
+ "repo": union([_undefined(), string()]).optional(),
4349
+ "subdir": union([_undefined(), string()]).optional()
4340
4350
  });
4341
4351
  const dsh_plugin_shop_shop_installStart_result$schema = union([object({
4342
4352
  "ok": literal(true),
@@ -4348,7 +4358,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4348
4358
  literal("denied"),
4349
4359
  literal("version-mismatch"),
4350
4360
  literal("needs-acknowledgement"),
4351
- literal("tarball-integrity")
4361
+ literal("tarball-integrity"),
4362
+ literal("ambiguous-identity")
4352
4363
  ]),
4353
4364
  "detail": string()
4354
4365
  })]);
@@ -4437,7 +4448,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4437
4448
  },
4438
4449
  sourceLocation: {
4439
4450
  "file": "packages/dsh-plugin-shop/src/host/index.ts",
4440
- "line": 623,
4451
+ "line": 678,
4441
4452
  "column": 9
4442
4453
  }
4443
4454
  },
@@ -4455,7 +4466,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4455
4466
  },
4456
4467
  sourceLocation: {
4457
4468
  "file": "packages/dsh-plugin-shop/src/host/index.ts",
4458
- "line": 809,
4469
+ "line": 863,
4459
4470
  "column": 9
4460
4471
  }
4461
4472
  },
@@ -4483,7 +4494,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4483
4494
  },
4484
4495
  sourceLocation: {
4485
4496
  "file": "packages/dsh-plugin-shop/src/host/index.ts",
4486
- "line": 674,
4497
+ "line": 726,
4487
4498
  "column": 9
4488
4499
  }
4489
4500
  },
@@ -4510,7 +4521,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4510
4521
  },
4511
4522
  sourceLocation: {
4512
4523
  "file": "packages/dsh-plugin-shop/src/host/index.ts",
4513
- "line": 798,
4524
+ "line": 852,
4514
4525
  "column": 3
4515
4526
  }
4516
4527
  },
@@ -4528,7 +4539,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4528
4539
  },
4529
4540
  sourceLocation: {
4530
4541
  "file": "packages/dsh-plugin-shop/src/host/index.ts",
4531
- "line": 959,
4542
+ "line": 1021,
4532
4543
  "column": 9
4533
4544
  }
4534
4545
  },
@@ -4555,7 +4566,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4555
4566
  },
4556
4567
  sourceLocation: {
4557
4568
  "file": "packages/dsh-plugin-shop/src/host/index.ts",
4558
- "line": 515,
4569
+ "line": 535,
4559
4570
  "column": 9
4560
4571
  }
4561
4572
  },
@@ -4583,7 +4594,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4583
4594
  },
4584
4595
  sourceLocation: {
4585
4596
  "file": "packages/dsh-plugin-shop/src/host/index.ts",
4586
- "line": 901,
4597
+ "line": 956,
4587
4598
  "column": 9
4588
4599
  }
4589
4600
  },
@@ -4610,7 +4621,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4610
4621
  },
4611
4622
  sourceLocation: {
4612
4623
  "file": "packages/dsh-plugin-shop/src/host/index.ts",
4613
- "line": 1027,
4624
+ "line": 1106,
4614
4625
  "column": 9
4615
4626
  }
4616
4627
  },
@@ -4628,7 +4639,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4628
4639
  },
4629
4640
  sourceLocation: {
4630
4641
  "file": "packages/dsh-plugin-shop/src/host/index.ts",
4631
- "line": 1010,
4642
+ "line": 1089,
4632
4643
  "column": 9
4633
4644
  }
4634
4645
  }
@@ -4709,6 +4720,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4709
4720
  return hasPlugin || SHOP_KEYWORDS.includes(segments.at(-1));
4710
4721
  }
4711
4722
  //#endregion
4723
+ //#region src/shared/identity.ts
4724
+ /** The registry's uniqueness rule, shared with the presentation layer. */
4725
+ function identityKey(identity) {
4726
+ return identity.source === "npm" ? `npm:${identity.name}` : `github:${identity.repo ?? identity.name}#${identity.subdir ?? ""}`;
4727
+ }
4728
+ /** `owner/slug`, lowercased, or null when this is not a repository reference. */
4729
+ const REPO = "([\\w.-]+)\\/([\\w.-]+?)";
4730
+ new RegExp(`^github:${REPO}(?:[#&].*)?$`);
4731
+ new RegExp(`^(?:git\\+)?https?:\\/\\/(?:www\\.)?github\\.com\\/${REPO}(?:\\.git)?(?:[\\/?#].*)?$`);
4732
+ //#endregion
4712
4733
  //#region src/client/present.ts
4713
4734
  /** Hot-mount reason code → locale key, so the notice reads in the language
4714
4735
  * the person set in dsh. An absent (or unrecognized) reason keeps the generic
@@ -4733,9 +4754,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4733
4754
  }
4734
4755
  /** The peers the Host said this installation does not provide, or none when it
4735
4756
  * said nothing — a plugin that runs here and one the Host could not judge are
4736
- * both rendered as no warning at all. */
4737
- function missingPeersOf(incompatible, name) {
4738
- return incompatible[name] ?? [];
4757
+ * both rendered as no warning at all. The map is keyed by install identity,
4758
+ * never by name, because two entries can share a name. */
4759
+ function missingPeersOf(incompatible, key) {
4760
+ return incompatible[key] ?? [];
4739
4761
  }
4740
4762
  /** Spec §9.3 verbatim — the community-tier acknowledgement. The zh dictionary
4741
4763
  * states the same facts in its own register; never soften this wording. */
@@ -4751,6 +4773,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4751
4773
  case "version-mismatch": return "versionMismatchCode";
4752
4774
  case "needs-acknowledgement": return "needsAcknowledgementCode";
4753
4775
  case "tarball-integrity": return "tarballIntegrityCode";
4776
+ case "ambiguous-identity": return "ambiguousIdentityCode";
4754
4777
  }
4755
4778
  }
4756
4779
  /** The version a card displays: full for npm, the short commit for github. */
@@ -4815,6 +4838,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4815
4838
  if (status.state === "done") return {
4816
4839
  kind: "done",
4817
4840
  needsRestart: !!status.needsRestart,
4841
+ log: status.log,
4818
4842
  ...status.restartReason !== void 0 ? { restartReason: status.restartReason } : {}
4819
4843
  };
4820
4844
  return {
@@ -4934,7 +4958,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4934
4958
  * This mirrors the registry's identity verbatim; the two must not drift.
4935
4959
  */
4936
4960
  function entryKey(entry) {
4937
- return entry.source === "npm" ? `npm:${entry.name}` : `github:${entry.repo ?? entry.name}#${entry.subdir ?? ""}`;
4961
+ return identityKey(entry);
4938
4962
  }
4939
4963
  /**
4940
4964
  * One entry's star count from the sidecar, or undefined when it has none.
@@ -4951,8 +4975,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4951
4975
  * repo, one the catalog never even listed.
4952
4976
  */
4953
4977
  function starsOf(entry, stars) {
4954
- return stars[entry.repo ?? entry.name];
4955
- }
4978
+ const key = entry.repo ?? entry.name;
4979
+ if (!Object.hasOwn(stars, key)) return void 0;
4980
+ return stars[key];
4981
+ }
4982
+ /** One collator for the whole shelf. Passing an options object to
4983
+ * localeCompare creates a collator per comparison, which dominates the sort
4984
+ * for a catalog with thousands of entries. */
4985
+ const NAME_COLLATOR = new Intl.Collator(void 0, { sensitivity: "base" });
4956
4986
  /** Sort the shelf: stars descending, un-starred entries last, name ascending
4957
4987
  * (case-insensitive) on ties (spec 2026-08-26-github-stars-design.md D1).
4958
4988
  * Display-time only — the catalog's own name sort is untouched. */
@@ -4961,7 +4991,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4961
4991
  return [...entries].sort((a, b) => {
4962
4992
  const byStars = count(b) - count(a);
4963
4993
  if (byStars !== 0) return byStars;
4964
- return a.name.localeCompare(b.name, void 0, { sensitivity: "base" });
4994
+ return NAME_COLLATOR.compare(a.name, b.name);
4965
4995
  });
4966
4996
  }
4967
4997
  /** 999 → "999"; 1000 → "1k"; 1234 → "1.2k"; 1500 → "1.5k"; 99999 → "100k". */
@@ -5030,6 +5060,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5030
5060
  versionMismatchCode: "版本不匹配",
5031
5061
  needsAcknowledgementCode: "需要确认",
5032
5062
  tarballIntegrityCode: "压缩包完整性校验失败",
5063
+ ambiguousIdentityCode: "无法确定是哪一个条目",
5033
5064
  npmSource: "npm 包",
5034
5065
  githubSource: "源码在 GitHub",
5035
5066
  installedSection: "已安装",
@@ -5119,6 +5150,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5119
5150
  versionMismatchCode: "Version mismatch",
5120
5151
  needsAcknowledgementCode: "Acknowledgement required",
5121
5152
  tarballIntegrityCode: "tarball integrity check failed",
5153
+ ambiguousIdentityCode: "Ambiguous entry",
5122
5154
  npmSource: "npm package",
5123
5155
  githubSource: "source on GitHub",
5124
5156
  installedSection: "Installed",
@@ -5176,42 +5208,93 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5176
5208
  installStatus
5177
5209
  ]);
5178
5210
  }
5179
- /** Drive one install: rejections, the polling loop at INSTALL_POLL_MS, and
5180
- * terminal states. The interval is cleared on unmount and whenever the view
5181
- * leaves `running`, so a done/failed/rejected install never polls again. */
5182
- function useInstall(install, installStatus) {
5183
- const [view, setView] = (0, react.useState)({ kind: "idle" });
5184
- const start = (0, react.useCallback)(async (args) => {
5185
- setView({ kind: "idle" });
5211
+ /**
5212
+ * Install flows owned by the tab and keyed by install identity. Keeping the
5213
+ * state above individual cards preserves a running operation when filtering
5214
+ * unmounts its card, and makes the shelf and Outdated panels agree.
5215
+ */
5216
+ function useInstallFlows(install, installStatus, onSettled) {
5217
+ const [views, setViews] = (0, react.useState)(() => /* @__PURE__ */ new Map());
5218
+ const settled = (0, react.useRef)(onSettled);
5219
+ settled.current = onSettled;
5220
+ const put = (0, react.useCallback)((key, view) => {
5221
+ setViews((current) => {
5222
+ const next = new Map(current);
5223
+ next.set(key, view);
5224
+ return next;
5225
+ });
5226
+ }, []);
5227
+ const apply = (0, react.useCallback)((key, event) => {
5228
+ setViews((current) => {
5229
+ const before = current.get(key) ?? { kind: "idle" };
5230
+ const after = reduceInstall(before, event);
5231
+ if (after === before) return current;
5232
+ const next = new Map(current);
5233
+ next.set(key, after);
5234
+ return next;
5235
+ });
5236
+ }, []);
5237
+ const start = (0, react.useCallback)(async (key, args) => {
5238
+ put(key, { kind: "idle" });
5186
5239
  try {
5187
5240
  const result = await install(args);
5188
5241
  if (!result.ok) {
5189
- setView({
5242
+ put(key, {
5190
5243
  kind: "rejected",
5191
5244
  code: result.code,
5192
5245
  detail: result.detail
5193
5246
  });
5194
5247
  return;
5195
5248
  }
5196
- setView({
5249
+ put(key, {
5197
5250
  kind: "running",
5198
5251
  installId: result.installId,
5199
5252
  log: []
5200
5253
  });
5201
5254
  } catch {
5202
- setView({
5255
+ put(key, {
5203
5256
  kind: "failed",
5204
5257
  detail: "",
5205
5258
  log: []
5206
5259
  });
5207
5260
  }
5208
- }, [install]);
5209
- usePollStatus(view, setView, installStatus);
5210
- return {
5211
- view,
5261
+ }, [install, put]);
5262
+ const reset = (0, react.useCallback)((key) => {
5263
+ setViews((current) => {
5264
+ if (!current.has(key)) return current;
5265
+ const next = new Map(current);
5266
+ next.delete(key);
5267
+ return next;
5268
+ });
5269
+ }, []);
5270
+ (0, react.useEffect)(() => {
5271
+ const running = [];
5272
+ for (const [key, view] of views) if (view.kind === "running") running.push([key, view.installId]);
5273
+ if (running.length === 0) return;
5274
+ const timer = setInterval(() => {
5275
+ for (const [key, installId] of running) installStatus({ installId }).then((status) => {
5276
+ apply(key, {
5277
+ type: "status",
5278
+ status
5279
+ });
5280
+ if (status.found && status.state !== "running") settled.current?.(key);
5281
+ }, () => {});
5282
+ }, INSTALL_POLL_MS);
5283
+ return () => clearInterval(timer);
5284
+ }, [
5285
+ views,
5286
+ installStatus,
5287
+ apply
5288
+ ]);
5289
+ return { flowFor: (0, react.useCallback)((key) => ({
5290
+ view: views.get(key) ?? { kind: "idle" },
5291
+ start: (args) => start(key, args),
5292
+ reset: () => reset(key)
5293
+ }), [
5294
+ views,
5212
5295
  start,
5213
- reset: (0, react.useCallback)(() => setView({ kind: "idle" }), [])
5214
- };
5296
+ reset
5297
+ ]) };
5215
5298
  }
5216
5299
  //#endregion
5217
5300
  //#region src/client/useUninstall.ts
@@ -5433,13 +5516,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5433
5516
  * install controls. An installed plugin's card carries its installed row:
5434
5517
  * current → the non-interactive installed label, behind → the update button;
5435
5518
  * uninstalled → the install button. */
5436
- const EntryCard = (0, react.memo)(function EntryCard({ entry, stars, installed, missing, t, install, installStatus, uninstall, restart, restartSupported, setEnabled }) {
5519
+ const EntryCard = (0, react.memo)(function EntryCard({ entry, stars, installed, missing, t, flowFor, installStatus, uninstall, restart, restartSupported, setEnabled, onSettled }) {
5437
5520
  const [open, setOpen] = (0, react.useState)(false);
5438
5521
  const detailId = (0, react.useId)();
5439
5522
  const summary = entry.catalog?.summary;
5440
5523
  const npmUrl = npmPageUrl(entry);
5441
5524
  const author = authorOf(entry);
5442
5525
  const category = entry.catalog?.category ?? "other";
5526
+ const installTarget = {
5527
+ name: entry.name,
5528
+ version: entry.version,
5529
+ source: entry.source,
5530
+ repo: entry.repo,
5531
+ subdir: entry.subdir
5532
+ };
5533
+ const flow = flowFor(entryKey(entry));
5534
+ const uninstallSettled = (0, react.useCallback)(() => {
5535
+ flow.reset();
5536
+ onSettled();
5537
+ }, [flow, onSettled]);
5443
5538
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5444
5539
  className: _dsh_plugin_shop_css_e3675a89_default.card,
5445
5540
  "data-shop-entry": entry.name,
@@ -5589,27 +5684,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5589
5684
  className: _dsh_plugin_shop_css_e3675a89_default.cardActions,
5590
5685
  "data-shop-actions": true,
5591
5686
  children: [installed === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstallPanel, {
5592
- name: entry.name,
5593
- version: entry.version,
5687
+ target: installTarget,
5594
5688
  tier: entry.tier,
5595
5689
  missing,
5596
5690
  missingStated: true,
5691
+ flow,
5597
5692
  t,
5598
- install,
5599
- installStatus,
5600
5693
  restart,
5601
5694
  restartSupported
5602
5695
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
5603
- installed.outdated ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstallPanel, {
5604
- name: entry.name,
5605
- version: entry.version,
5696
+ installed.outdated || flow.view.kind !== "idle" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstallPanel, {
5697
+ target: installTarget,
5606
5698
  tier: entry.tier,
5607
- variant: "update",
5699
+ variant: installed.outdated ? "update" : "install",
5608
5700
  missing,
5609
5701
  missingStated: true,
5702
+ flow,
5610
5703
  t,
5611
- install,
5612
- installStatus,
5613
5704
  restart,
5614
5705
  restartSupported
5615
5706
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
@@ -5631,7 +5722,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5631
5722
  uninstall,
5632
5723
  installStatus,
5633
5724
  restart,
5634
- restartSupported
5725
+ restartSupported,
5726
+ onSettled: uninstallSettled
5635
5727
  })
5636
5728
  ] }), author !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5637
5729
  className: _dsh_plugin_shop_css_e3675a89_default.author,
@@ -5665,9 +5757,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5665
5757
  * failure detail, rejection detail — driven by `useInstall`. Shared by the
5666
5758
  * catalog cards (`variant: 'install'`) and the outdated rows' update button
5667
5759
  * (`variant: 'update'`, which drives the same install flow for `name@latest`). */
5668
- function InstallPanel({ name, version, tier, missing, missingStated = false, variant = "install", t, install, installStatus, restart, restartSupported }) {
5760
+ function InstallPanel({ target, tier, missing, missingStated = false, variant = "install", flow, t, restart, restartSupported }) {
5669
5761
  const [gateOpen, setGateOpen] = (0, react.useState)(false);
5670
- const { view, start } = useInstall(install, installStatus);
5762
+ const { view, start } = flow;
5671
5763
  if (view.kind === "running") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5672
5764
  className: _dsh_plugin_shop_css_e3675a89_default.installPanel,
5673
5765
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
@@ -5684,6 +5776,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5684
5776
  if (view.kind === "done") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5685
5777
  className: _dsh_plugin_shop_css_e3675a89_default.installedActions,
5686
5778
  children: [
5779
+ view.log.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5780
+ className: _dsh_plugin_shop_css_e3675a89_default.log,
5781
+ children: view.log.map((line, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5782
+ className: _dsh_plugin_shop_css_e3675a89_default.logLine,
5783
+ children: line
5784
+ }, index))
5785
+ }),
5687
5786
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
5688
5787
  className: _dsh_plugin_shop_css_e3675a89_default.notice,
5689
5788
  "data-shop-restart-notice": true,
@@ -5755,8 +5854,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5755
5854
  onClick: () => {
5756
5855
  setGateOpen(false);
5757
5856
  start({
5758
- name,
5759
- version,
5857
+ ...target,
5760
5858
  acknowledged: true
5761
5859
  });
5762
5860
  },
@@ -5777,8 +5875,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5777
5875
  ...update ? { "data-shop-update": true } : { "data-shop-install": true },
5778
5876
  onClick: () => {
5779
5877
  if (tier === "verified") start({
5780
- name,
5781
- version,
5878
+ ...target,
5782
5879
  acknowledged: void 0
5783
5880
  });
5784
5881
  else setGateOpen(true);
@@ -5795,8 +5892,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
5795
5892
  * §9.3 is about granting. A business failure (not in the catalog / not
5796
5893
  * installed) lands in the failed view with the host's published detail; a
5797
5894
  * transport failure carries the empty detail and the localized fallback. */
5798
- function UninstallPanel({ name, t, uninstall, installStatus, restart, restartSupported }) {
5895
+ function UninstallPanel({ name, t, uninstall, installStatus, restart, restartSupported, onSettled }) {
5799
5896
  const { view, start } = useUninstall(uninstall, installStatus);
5897
+ const settled = (0, react.useRef)(onSettled);
5898
+ settled.current = onSettled;
5899
+ (0, react.useEffect)(() => {
5900
+ if (view.kind === "done") settled.current();
5901
+ }, [view.kind]);
5800
5902
  if (view.kind === "running") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5801
5903
  className: _dsh_plugin_shop_css_e3675a89_default.installPanel,
5802
5904
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
@@ -6024,7 +6126,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6024
6126
  /** One outdated install row (§7.3): the name, the installed and latest
6025
6127
  * versions, the hot enable/disable switch, and the update button (the
6026
6128
  * install flow for `name@latest`, reusing `InstallPanel`). */
6027
- function OutdatedRow({ row, tier, source, missing, t, setEnabled, install, installStatus, restart, restartSupported }) {
6129
+ function OutdatedRow({ row, tier, missing, t, setEnabled, flowFor, restart, restartSupported }) {
6028
6130
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6029
6131
  className: _dsh_plugin_shop_css_e3675a89_default.outdatedRow,
6030
6132
  "data-shop-outdated-entry": row.name,
@@ -6035,7 +6137,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6035
6137
  children: row.name
6036
6138
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
6037
6139
  className: _dsh_plugin_shop_css_e3675a89_default.outdatedVersions,
6038
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("installedVersion", { version: source === "github" ? row.installed.slice(0, 7) : row.installed }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("latestVersion", { version: row.latest }) })]
6140
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("installedVersion", { version: row.source === "github" ? row.installed.slice(0, 7) : row.installed }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("latestVersion", { version: row.latest }) })]
6039
6141
  })]
6040
6142
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6041
6143
  className: _dsh_plugin_shop_css_e3675a89_default.outdatedActions,
@@ -6044,14 +6146,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6044
6146
  t,
6045
6147
  setEnabled
6046
6148
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstallPanel, {
6047
- name: row.name,
6048
- version: row.latest,
6149
+ target: {
6150
+ name: row.name,
6151
+ version: row.latest,
6152
+ source: row.source,
6153
+ repo: row.repo,
6154
+ subdir: row.subdir
6155
+ },
6049
6156
  tier,
6050
6157
  variant: "update",
6051
6158
  missing,
6159
+ flow: flowFor(identityKey(row)),
6052
6160
  t,
6053
- install,
6054
- installStatus,
6055
6161
  restart,
6056
6162
  restartSupported
6057
6163
  })]
@@ -6065,7 +6171,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6065
6171
  * tier for the update gate is looked up from the catalog by name (community →
6066
6172
  * acknowledgement); an entry absent from the catalog defaults to the
6067
6173
  * community gate (the safer read). */
6068
- function OutdatedSection({ state, tiers, sources, missingByName, t, setEnabled, install, installStatus, restart, restartSupported }) {
6174
+ function OutdatedSection({ state, entriesByKey, missingByKey, t, setEnabled, flowFor, restart, restartSupported }) {
6069
6175
  if (state.kind === "loading") return null;
6070
6176
  if (state.kind === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
6071
6177
  className: _dsh_plugin_shop_css_e3675a89_default.stateLine,
@@ -6084,16 +6190,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6084
6190
  className: _dsh_plugin_shop_css_e3675a89_default.outdatedList,
6085
6191
  children: outdated.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OutdatedRow, {
6086
6192
  row,
6087
- tier: tiers.get(row.name) ?? "community",
6088
- source: sources.get(row.name) ?? "npm",
6089
- missing: missingByName.get(row.name) ?? [],
6193
+ tier: entriesByKey.get(identityKey(row))?.tier ?? "community",
6194
+ missing: missingByKey.get(identityKey(row)) ?? [],
6090
6195
  t,
6091
6196
  setEnabled,
6092
- install,
6093
- installStatus,
6197
+ flowFor,
6094
6198
  restart,
6095
6199
  restartSupported
6096
- }) }, row.name))
6200
+ }) }, identityKey(row)))
6097
6201
  })]
6098
6202
  });
6099
6203
  }
@@ -6108,6 +6212,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6108
6212
  const [selfRestartGate, setSelfRestartGate] = (0, react.useState)(false);
6109
6213
  const selfUpdate = useUpdateSelf(updateStart, installStatus);
6110
6214
  const [request, setRequest] = (0, react.useState)({ kind: "initial" });
6215
+ const [mutations, setMutations] = (0, react.useState)(0);
6216
+ const noteMutation = (0, react.useCallback)(() => {
6217
+ setMutations((current) => current + 1);
6218
+ }, []);
6219
+ const flows = useInstallFlows(install, installStatus, noteMutation);
6111
6220
  const [reloading, setReloading] = (0, react.useState)(false);
6112
6221
  const [reloadFailed, setReloadFailed] = (0, react.useState)(false);
6113
6222
  const [query, setQuery] = (0, react.useState)("");
@@ -6188,10 +6297,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6188
6297
  return () => {
6189
6298
  cancelled = true;
6190
6299
  };
6191
- }, [installed, request]);
6192
- const installedByName = (0, react.useMemo)(() => {
6300
+ }, [
6301
+ installed,
6302
+ request,
6303
+ mutations
6304
+ ]);
6305
+ const installedByKey = (0, react.useMemo)(() => {
6193
6306
  const map = /* @__PURE__ */ new Map();
6194
- if (installedState.kind === "ready") for (const entry of installedState.entries) map.set(entry.name, entry);
6307
+ if (installedState.kind === "ready") for (const entry of installedState.entries) map.set(identityKey(entry), entry);
6195
6308
  return map;
6196
6309
  }, [installedState]);
6197
6310
  const browsable = (0, react.useMemo)(() => {
@@ -6199,11 +6312,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6199
6312
  const cleared = new Set(catalogState.result.notAShop ?? []);
6200
6313
  return catalogState.result.plugins.filter((entry) => cleared.has(entry.name) || !isShopLike(entry.name) && (entry.repo === void 0 || !isShopLike(entry.repo)));
6201
6314
  }, [catalogState]);
6315
+ const stars = (0, react.useMemo)(() => catalogState.kind === "ready" ? catalogState.result.stars : {}, [catalogState]);
6316
+ const sortedBrowsable = (0, react.useMemo)(() => sortByStars(browsable, stars), [browsable, stars]);
6202
6317
  const filtered = (0, react.useMemo)(() => {
6203
6318
  const q = query.trim().toLowerCase();
6204
- return browsable.filter((entry) => {
6319
+ return sortedBrowsable.filter((entry) => {
6205
6320
  if (category === "installed") {
6206
- if (!installedByName.has(entry.name)) return false;
6321
+ if (!installedByKey.has(entryKey(entry))) return false;
6207
6322
  } else if (category !== null && categoryKey(entry) !== categoryLocaleKey(category)) return false;
6208
6323
  if (q === "") return true;
6209
6324
  const summaryEn = entry.catalog?.summary.en ?? "";
@@ -6211,14 +6326,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6211
6326
  return entry.name.toLowerCase().includes(q) || summaryEn.toLowerCase().includes(q) || summaryZh.toLowerCase().includes(q);
6212
6327
  });
6213
6328
  }, [
6214
- browsable,
6329
+ sortedBrowsable,
6215
6330
  query,
6216
6331
  category,
6217
- installedByName
6332
+ installedByKey
6218
6333
  ]);
6219
6334
  filteredLenRef.current = filtered.length;
6220
- const stars = catalogState.kind === "ready" ? catalogState.result.stars : {};
6221
- const sorted = (0, react.useMemo)(() => sortByStars(filtered, stars), [filtered, stars]);
6222
6335
  (0, react.useEffect)(() => {
6223
6336
  if (!incremental) return;
6224
6337
  const node = sentinelRef.current;
@@ -6233,7 +6346,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6233
6346
  visibleCount,
6234
6347
  filtered.length
6235
6348
  ]);
6236
- const visible = incremental ? sorted.slice(0, visibleCount) : sorted;
6349
+ const visible = incremental ? filtered.slice(0, visibleCount) : filtered;
6237
6350
  const categoryCounts = (0, react.useMemo)(() => {
6238
6351
  const counts = /* @__PURE__ */ new Map();
6239
6352
  for (const entry of browsable) {
@@ -6247,19 +6360,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6247
6360
  if (installedState.kind !== "ready") return 0;
6248
6361
  return installedState.entries.filter((entry) => !isShopLike(entry.name)).length;
6249
6362
  }, [installedState]);
6250
- const tiers = (0, react.useMemo)(() => {
6363
+ const entriesByKey = (0, react.useMemo)(() => {
6251
6364
  const map = /* @__PURE__ */ new Map();
6252
- if (catalogState.kind === "ready") for (const entry of catalogState.result.plugins) map.set(entry.name, entry.tier);
6365
+ if (catalogState.kind === "ready") for (const entry of catalogState.result.plugins) map.set(entryKey(entry), entry);
6253
6366
  return map;
6254
6367
  }, [catalogState]);
6255
- const sources = (0, react.useMemo)(() => {
6368
+ const missingByKey = (0, react.useMemo)(() => {
6256
6369
  const map = /* @__PURE__ */ new Map();
6257
- if (catalogState.kind === "ready") for (const entry of catalogState.result.plugins) map.set(entry.name, entry.source);
6258
- return map;
6259
- }, [catalogState]);
6260
- const missingByName = (0, react.useMemo)(() => {
6261
- const map = /* @__PURE__ */ new Map();
6262
- if (catalogState.kind === "ready") for (const entry of catalogState.result.plugins) map.set(entry.name, missingPeersOf(catalogState.result.incompatible, entry.name));
6370
+ if (catalogState.kind === "ready") for (const entry of catalogState.result.plugins) map.set(entryKey(entry), missingPeersOf(catalogState.result.incompatible, entryKey(entry)));
6263
6371
  return map;
6264
6372
  }, [catalogState]);
6265
6373
  if (catalogState.kind === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -6522,15 +6630,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6522
6630
  children: [visible.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EntryCard, {
6523
6631
  entry,
6524
6632
  stars: starsOf(entry, stars),
6525
- installed: installedByName.get(entry.name),
6526
- missing: missingByName.get(entry.name) ?? [],
6633
+ installed: installedByKey.get(entryKey(entry)),
6634
+ missing: missingByKey.get(entryKey(entry)) ?? [],
6527
6635
  t,
6528
- install,
6636
+ flowFor: flows.flowFor,
6529
6637
  installStatus,
6530
6638
  uninstall,
6531
6639
  restart,
6532
6640
  restartSupported,
6533
- setEnabled
6641
+ setEnabled,
6642
+ onSettled: noteMutation
6534
6643
  }) }, entryKey(entry))), incremental && visibleCount < filtered.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
6535
6644
  ref: sentinelRef,
6536
6645
  className: _dsh_plugin_shop_css_e3675a89_default.cardsSentry,
@@ -6547,13 +6656,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6547
6656
  })] }),
6548
6657
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OutdatedSection, {
6549
6658
  state: installedState,
6550
- tiers,
6551
- sources,
6552
- missingByName,
6659
+ entriesByKey,
6660
+ missingByKey,
6553
6661
  t,
6554
6662
  setEnabled,
6555
- install,
6556
- installStatus,
6663
+ flowFor: flows.flowFor,
6557
6664
  restart,
6558
6665
  restartSupported
6559
6666
  })
@@ -6564,13 +6671,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6564
6671
  //#region src/client/index.ts
6565
6672
  /** Dictionary namespace owned by this plugin. */
6566
6673
  const NS = "settings.shop";
6674
+ /** How long a stashed catalog may satisfy a plain open. The host applies the
6675
+ * same five-minute freshness window, so the client stash must not outlive it. */
6676
+ const WARM_TTL_MS = 3e5;
6567
6677
  /** The boot-time warm fetch: the catalog the tab wants on its first open.
6568
6678
  * Started in apply — the client bundle boots with the web app, long before
6569
6679
  * the user reaches Settings — so the host's slow network fetch runs while
6570
6680
  * nobody is looking at the shop, and the tab's mount consumes this promise
6571
6681
  * instead of starting its own fetch. A rejection stays stored (the injected
6572
6682
  * catalog falls back to a fresh call); the extra catch keeps the
6573
- * fire-and-forget from surfacing as an unhandled rejection. */
6683
+ * fire-and-forget from surfacing as an unhandled rejection. Every later
6684
+ * result, including an explicit refresh, replaces this timestamped stash. */
6574
6685
  let warmCatalog = null;
6575
6686
  /** Services required by the tab registration and the Remote mount.
6576
6687
  *
@@ -6602,19 +6713,33 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6602
6713
  return result.value;
6603
6714
  };
6604
6715
  warmCatalog = null;
6605
- warmCatalog = Promise.resolve(ns.catalog(void 0)).then((result) => unwrap(result));
6606
- warmCatalog.catch(() => {});
6716
+ const warmed = Promise.resolve(ns.catalog(void 0)).then((result) => unwrap(result));
6717
+ warmCatalog = {
6718
+ at: Date.now(),
6719
+ result: warmed
6720
+ };
6721
+ warmed.catch(() => {});
6607
6722
  Promise.resolve(ns.installed()).then((result) => unwrap(result)).catch(() => {});
6608
6723
  Promise.resolve(ns.version()).then((result) => unwrap(result)).catch(() => {});
6609
6724
  const injected = () => ({
6610
6725
  catalog: async (args) => {
6611
- if (args?.refresh === true) return unwrap(await ns.catalog(args));
6726
+ if (args?.refresh === true) {
6727
+ const refreshed = unwrap(await ns.catalog(args));
6728
+ warmCatalog = {
6729
+ at: Date.now(),
6730
+ result: Promise.resolve(refreshed)
6731
+ };
6732
+ return refreshed;
6733
+ }
6612
6734
  const warm = warmCatalog;
6613
- if (warm !== null) try {
6614
- return await warm;
6735
+ if (warm !== null && Date.now() - warm.at < 3e5) try {
6736
+ return await warm.result;
6615
6737
  } catch {}
6616
6738
  const fresh = unwrap(await ns.catalog(args));
6617
- warmCatalog = Promise.resolve(fresh);
6739
+ warmCatalog = {
6740
+ at: Date.now(),
6741
+ result: Promise.resolve(fresh)
6742
+ };
6618
6743
  return fresh;
6619
6744
  },
6620
6745
  install: async (args) => unwrap(await ns.installStart(args)),
@@ -6637,6 +6762,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6637
6762
  }
6638
6763
  //#endregion
6639
6764
  exports.NS = NS;
6765
+ exports.WARM_TTL_MS = WARM_TTL_MS;
6640
6766
  exports.apply = apply;
6641
6767
  exports.inject = inject;
6642
6768
  return module.exports;