universal-plugin-hub 1.5.0 → 1.5.5

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.
@@ -0,0 +1,20 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36" fill="none">
2
+ <title>Universal Plugin Hub</title>
3
+ <defs>
4
+ <linearGradient id="uph-bg" x1="18" y1="2.2" x2="18" y2="34" gradientUnits="userSpaceOnUse">
5
+ <stop offset="0" stop-color="#3BBCE8"/>
6
+ <stop offset="0.26" stop-color="#4D88FE"/>
7
+ <stop offset="0.56" stop-color="#4D6BFE"/>
8
+ <stop offset="1" stop-color="#3B54E0"/>
9
+ </linearGradient>
10
+ <linearGradient id="uph-handle" x1="18" y1="5.2" x2="18" y2="13.2" gradientUnits="userSpaceOnUse">
11
+ <stop offset="0" stop-color="#FFFFFF"/>
12
+ <stop offset="1" stop-color="#EFF5FF"/>
13
+ </linearGradient>
14
+ </defs>
15
+ <path d="M34.000 18.000C34.000 22.002 34.000 23.948 33.887 25.574C33.709 28.145 33.220 30.303 31.762 31.762C30.303 33.220 28.145 33.709 25.574 33.887C23.948 34.000 22.002 34.000 18.000 34.000C13.998 34.000 12.052 34.000 10.426 33.887C7.855 33.709 5.697 33.220 4.238 31.762C2.780 30.303 2.291 28.145 2.113 25.574C2.000 23.948 2.000 22.002 2.000 18.000C2.000 13.998 2.000 12.052 2.113 10.426C2.291 7.855 2.780 5.697 4.238 4.238C5.697 2.780 7.855 2.291 10.426 2.113C12.052 2.000 13.998 2.000 18.000 2.000C22.002 2.000 23.948 2.000 25.574 2.113C28.145 2.291 30.303 2.780 31.762 4.238C33.220 5.697 33.709 7.855 33.887 10.426C34.000 12.052 34.000 13.998 34.000 18.000Z" fill="url(#uph-bg)"/>
16
+ <path d="M10.000 6.301A8.000 6.848 0 0 0 26.000 6.301A0.973 0.973 0 0 0 25.027 5.328L23.933 5.328A0.973 0.973 0 0 0 22.960 6.301A4.960 3.808 0 0 1 13.040 6.301A0.973 0.973 0 0 0 12.067 5.328L10.973 5.328A0.973 0.973 0 0 0 10.000 6.301Z" transform="translate(0 0.6)" fill="#18308C" fill-opacity="0.22"/>
17
+ <path d="M10.000 6.301A8.000 6.848 0 0 0 26.000 6.301A0.973 0.973 0 0 0 25.027 5.328L23.933 5.328A0.973 0.973 0 0 0 22.960 6.301A4.960 3.808 0 0 1 13.040 6.301A0.973 0.973 0 0 0 12.067 5.328L10.973 5.328A0.973 0.973 0 0 0 10.000 6.301Z" fill="url(#uph-handle)"/>
18
+ <path d="M8.61 22.98L8.61 24.90L7.86 24.90L7.86 19.70L9.37 19.70Q10.24 19.70 10.72 20.11Q11.19 20.52 11.19 21.27Q11.19 22.02 10.68 22.50Q10.17 22.98 9.30 22.98L8.61 22.98ZM8.61 20.34L8.61 22.34L9.20 22.34Q9.79 22.34 10.10 22.07Q10.41 21.80 10.41 21.31Q10.41 20.34 9.27 20.34L8.61 20.34ZM12.85 24.90L12.12 24.90L12.12 19.40L12.85 19.40L12.85 24.90ZM17.22 24.90L16.49 24.90L16.49 24.31L16.47 24.31Q16.11 24.99 15.33 24.99Q14.01 24.99 14.01 23.41L14.01 21.19L14.74 21.19L14.74 23.32Q14.74 24.39 15.57 24.39Q15.97 24.39 16.23 24.10Q16.49 23.80 16.49 23.32L16.49 21.19L17.22 21.19L17.22 24.90ZM21.73 24.60Q21.73 26.65 19.72 26.65Q19.01 26.65 18.49 26.40L18.49 25.71Q19.10 26.05 19.66 26.05Q21.00 26.05 21.00 24.68L21.00 24.28L20.99 24.28Q20.57 24.99 19.73 24.99Q19.04 24.99 18.62 24.49Q18.20 24.00 18.20 23.16Q18.20 22.22 18.65 21.66Q19.10 21.10 19.89 21.10Q20.63 21.10 20.99 21.70L21.00 21.70L21.00 21.19L21.73 21.19L21.73 24.60ZM21.01 23.21L21.01 22.70Q21.01 22.28 20.73 21.99Q20.45 21.69 20.04 21.69Q19.53 21.69 19.24 22.07Q18.95 22.44 18.95 23.12Q18.95 23.70 19.23 24.05Q19.51 24.39 19.96 24.39Q20.43 24.39 20.72 24.06Q21.01 23.73 21.01 23.21ZM23.34 20.33Q23.15 20.33 23.02 20.21Q22.89 20.09 22.89 19.90Q22.89 19.71 23.02 19.59Q23.15 19.46 23.34 19.46Q23.53 19.46 23.66 19.59Q23.80 19.71 23.80 19.90Q23.80 20.08 23.66 20.21Q23.53 20.33 23.34 20.33ZM23.70 24.90L22.97 24.90L22.97 21.19L23.70 21.19L23.70 24.90ZM28.14 24.90L27.41 24.90L27.41 22.80Q27.41 21.69 26.62 21.69Q26.20 21.69 25.93 22.00Q25.67 22.31 25.67 22.78L25.67 24.90L24.93 24.90L24.93 21.19L25.67 21.19L25.67 21.80L25.68 21.80Q26.10 21.10 26.89 21.10Q27.50 21.10 27.82 21.49Q28.14 21.89 28.14 22.63L28.14 24.90Z" transform="translate(0 0.4)" fill="#18308C" fill-opacity="0.20"/>
19
+ <path id="uph-wordmark" d="M8.61 22.98L8.61 24.90L7.86 24.90L7.86 19.70L9.37 19.70Q10.24 19.70 10.72 20.11Q11.19 20.52 11.19 21.27Q11.19 22.02 10.68 22.50Q10.17 22.98 9.30 22.98L8.61 22.98ZM8.61 20.34L8.61 22.34L9.20 22.34Q9.79 22.34 10.10 22.07Q10.41 21.80 10.41 21.31Q10.41 20.34 9.27 20.34L8.61 20.34ZM12.85 24.90L12.12 24.90L12.12 19.40L12.85 19.40L12.85 24.90ZM17.22 24.90L16.49 24.90L16.49 24.31L16.47 24.31Q16.11 24.99 15.33 24.99Q14.01 24.99 14.01 23.41L14.01 21.19L14.74 21.19L14.74 23.32Q14.74 24.39 15.57 24.39Q15.97 24.39 16.23 24.10Q16.49 23.80 16.49 23.32L16.49 21.19L17.22 21.19L17.22 24.90ZM21.73 24.60Q21.73 26.65 19.72 26.65Q19.01 26.65 18.49 26.40L18.49 25.71Q19.10 26.05 19.66 26.05Q21.00 26.05 21.00 24.68L21.00 24.28L20.99 24.28Q20.57 24.99 19.73 24.99Q19.04 24.99 18.62 24.49Q18.20 24.00 18.20 23.16Q18.20 22.22 18.65 21.66Q19.10 21.10 19.89 21.10Q20.63 21.10 20.99 21.70L21.00 21.70L21.00 21.19L21.73 21.19L21.73 24.60ZM21.01 23.21L21.01 22.70Q21.01 22.28 20.73 21.99Q20.45 21.69 20.04 21.69Q19.53 21.69 19.24 22.07Q18.95 22.44 18.95 23.12Q18.95 23.70 19.23 24.05Q19.51 24.39 19.96 24.39Q20.43 24.39 20.72 24.06Q21.01 23.73 21.01 23.21ZM23.34 20.33Q23.15 20.33 23.02 20.21Q22.89 20.09 22.89 19.90Q22.89 19.71 23.02 19.59Q23.15 19.46 23.34 19.46Q23.53 19.46 23.66 19.59Q23.80 19.71 23.80 19.90Q23.80 20.08 23.66 20.21Q23.53 20.33 23.34 20.33ZM23.70 24.90L22.97 24.90L22.97 21.19L23.70 21.19L23.70 24.90ZM28.14 24.90L27.41 24.90L27.41 22.80Q27.41 21.69 26.62 21.69Q26.20 21.69 25.93 22.00Q25.67 22.31 25.67 22.78L25.67 24.90L24.93 24.90L24.93 21.19L25.67 21.19L25.67 21.80L25.68 21.80Q26.10 21.10 26.89 21.10Q27.50 21.10 27.82 21.49Q28.14 21.89 28.14 22.63L28.14 24.90Z" fill="#FFFFFF"/>
20
+ </svg>
package/client/client.js CHANGED
@@ -5383,7 +5383,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
5383
5383
  }
5384
5384
 
5385
5385
  function AnthropicIcon({ isDark }) {
5386
- return h("div", {
5386
+ return h("span", {
5387
5387
  className: "cpm-card-icon",
5388
5388
  style: {
5389
5389
  background: isDark ? "#18181b" : "#f4f1ea",
@@ -5403,7 +5403,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
5403
5403
  }
5404
5404
 
5405
5405
  function Context7Icon({ isDark }) {
5406
- return h("div", {
5406
+ return h("span", {
5407
5407
  className: "cpm-card-icon",
5408
5408
  style: {
5409
5409
  background: isDark ? "#09090b" : "#000000",
@@ -5605,8 +5605,8 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
5605
5605
  const renderedFallback = (!inline && typeof React !== "undefined" && typeof PluginIconFallback === "function" && React.isValidElement?.(fallback) && fallback.type === PluginIconFallback)
5606
5606
  ? React.cloneElement(fallback, { underlay: !!avatarUrl })
5607
5607
  : fallback;
5608
- return h("div", { className: "cpm-card-icon", style: { position: "relative", overflow: "hidden" } },
5609
- h("div", { className: "cpm-icon-underlay", "aria-hidden": true, style: { position: "absolute", inset: 0, opacity: imgLoaded ? 0 : 1 } }, inline ? null : renderedFallback),
5608
+ return h("span", { className: "cpm-card-icon", style: { position: "relative", overflow: "hidden" } },
5609
+ h("span", { className: "cpm-icon-underlay", "aria-hidden": true, style: { position: "absolute", inset: 0, opacity: imgLoaded ? 0 : 1 } }, inline ? null : renderedFallback),
5610
5610
  // A plugin-local icon is a same-origin disk read, so deferring it to
5611
5611
  // the viewport buys nothing and costs a visible placeholder on scroll.
5612
5612
  // Only remote avatars are worth deferring — and never above the fold.
@@ -5668,7 +5668,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
5668
5668
  }
5669
5669
 
5670
5670
  // Use the upstream 3D PNG unchanged; declared logos retain priority.
5671
- return h("div", {
5671
+ return h("span", {
5672
5672
  className: "cpm-card-icon cpm-fallback-icon",
5673
5673
  "aria-hidden": true,
5674
5674
  style: {
@@ -5685,6 +5685,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
5685
5685
  plugin,
5686
5686
  iconPlugin = plugin,
5687
5687
  installed,
5688
+ installing = false,
5688
5689
  eagerIcon = false,
5689
5690
  isDark,
5690
5691
  onMouseEnter,
@@ -5715,8 +5716,9 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
5715
5716
  }, "管理")
5716
5717
  : h("button", {
5717
5718
  className: "cpm-card-pill",
5718
- onClick: onInstall,
5719
- }, "安装")),
5719
+ disabled: installing,
5720
+ onClick: installing ? (e) => e.stopPropagation() : onInstall,
5721
+ }, installing ? "安装中…" : "安装")),
5720
5722
  );
5721
5723
  }
5722
5724
 
@@ -8178,6 +8180,13 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
8178
8180
 
8179
8181
  const [confirmRemoveSource, setConfirmRemoveSource] = useState(null);
8180
8182
  const [installFor, setInstallFor] = useState(null);
8183
+ const installDialogBusyRef = useRef(false);
8184
+ useEffect(() => {
8185
+ if (!installFor) installDialogBusyRef.current = false;
8186
+ }, [installFor]);
8187
+ const installingNamesRef = useRef(new Set());
8188
+ const [installingNames, setInstallingNames] = useState(() => new Set());
8189
+ const isPluginInstalling = (name) => installingNames.has(String(name || "").toLowerCase());
8181
8190
  const [hoveredPreview, closePluginHover, pluginHover] = useHoverPreview(240);
8182
8191
  const installedByName = useMemo(() => new Map(state.plugins.map(plugin => [plugin.name, plugin])), [state.plugins]);
8183
8192
  const resolveMarketplaceIcon = useMemo(() => createMarketplaceIconResolver(installedByName, state.sources), [installedByName, state.sources]);
@@ -9198,7 +9207,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
9198
9207
  SESSION_STORE.browseSortSnapshots[activeSourceId] = { filter, query, sortBy, names: currentSourceInstalledNames };
9199
9208
  }, [activeSourceId, filter, query, sortBy, currentSourceInstalledNames]);
9200
9209
  const installedNames = useMemo(() => new Set(state.plugins.map((p) => p.name)), [state.plugins]);
9201
- const totalInstalledCount = state.plugins.length;
9210
+ const totalInstalledCount = Array.isArray(state?.plugins) ? state.plugins.length : 0;
9202
9211
  const currentSourcePlugins = useMemo(() => (rows && rows[activeSourceId]) || [], [rows, activeSourceId]);
9203
9212
  const totalSourcePluginsCount = currentSourcePlugins.length;
9204
9213
 
@@ -9309,9 +9318,9 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
9309
9318
  }, [view]);
9310
9319
 
9311
9320
  useDialogEscape(!!(installFor || addDialog || confirmRemoveSource || mcpDialog), () => {
9312
- if (installFor) setInstallFor(null);
9321
+ if (installFor && !installDialogBusyRef.current) setInstallFor(null);
9313
9322
  if (addDialog && !addDialogBusyRef.current) setAddDialog(false);
9314
- if (confirmRemoveSource) setConfirmRemoveSource(null);
9323
+ if (confirmRemoveSource && !busy) setConfirmRemoveSource(null);
9315
9324
  if (mcpDialog) {
9316
9325
  setMcpDialog(false);
9317
9326
  setEditMcp(null);
@@ -9434,12 +9443,18 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
9434
9443
  };
9435
9444
 
9436
9445
  const doInstall = async () => {
9446
+ const target = installFor;
9447
+ if (!target) return;
9448
+ const key = String(target.name || "").toLowerCase();
9449
+ if (installingNamesRef.current.has(key)) return;
9450
+ installingNamesRef.current.add(key);
9451
+ setInstallingNames((prev) => { const next = new Set(prev); next.add(key); return next; });
9437
9452
  try {
9438
9453
  const result = await api("/plugins/install", {
9439
9454
  method: "POST",
9440
9455
  body: JSON.stringify({
9441
- sourceId: installFor.sourceId,
9442
- pluginName: installFor.name,
9456
+ sourceId: target.sourceId,
9457
+ pluginName: target.name,
9443
9458
  }),
9444
9459
  });
9445
9460
  const parts = [];
@@ -9449,11 +9464,14 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
9449
9464
  if (result.connectors && result.connectors.length) parts.push(`${result.connectors.length} 个 MCP 服务`);
9450
9465
  const summary = parts.length ? `${parts.join("、")}已就绪。` : "插件已安装就绪。";
9451
9466
  void showApplicationToast(showToast, result, "安装完成", summary);
9452
- setInstallFor(null);
9467
+ setInstallFor((cur) => (cur && cur.name === target.name && cur.sourceId === target.sourceId ? null : cur));
9453
9468
  await refreshState();
9454
9469
  onInstalled();
9455
9470
  } catch (e) {
9456
9471
  showToast("安装失败", e.message, { restart: false });
9472
+ } finally {
9473
+ installingNamesRef.current.delete(key);
9474
+ setInstallingNames((prev) => { if (!prev.has(key)) return prev; const next = new Set(prev); next.delete(key); return next; });
9457
9475
  }
9458
9476
  };
9459
9477
 
@@ -9687,9 +9705,10 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
9687
9705
  pluginRecord: state.plugins.find((r) => r.name === currentDetailPlugin.name),
9688
9706
  scrollState: view,
9689
9707
  isDark,
9708
+ installing: Boolean(currentDetailPlugin && isPluginInstalling(currentDetailPlugin.name)),
9690
9709
  containerRef: detailContainerRef,
9691
9710
  onBack: () => setView({ type: "browse", sourceId: activeSourceId }),
9692
- onInstall: () => setInstallFor(currentDetailPlugin),
9711
+ onInstall: () => { if (!installDialogBusyRef.current && !installingNamesRef.current.has(String(currentDetailPlugin.name || "").toLowerCase())) setInstallFor(currentDetailPlugin); },
9693
9712
  onRemove: () => removePlugin(currentDetailPlugin.name),
9694
9713
  onManage: () => openManage(state.plugins.find((r) => r.name === currentDetailPlugin.name), { type: "detail", sourceId: activeSourceId, plugin: currentDetailPlugin }),
9695
9714
  onTogglePlugin: async (enabled) => {
@@ -9799,6 +9818,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
9799
9818
  iconPlugin: resolveMarketplaceIcon(p),
9800
9819
  eagerIcon: index < 12,
9801
9820
  installed,
9821
+ installing: isPluginInstalling(p.name),
9802
9822
  isDark,
9803
9823
  onMouseEnter: (e) => handleCardMouseEnter(p, e.currentTarget, { x: e.clientX, y: e.clientY, buttons: e.buttons }),
9804
9824
  onMouseLeave: () => handleCardMouseLeave(p),
@@ -9810,7 +9830,9 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
9810
9830
  onInstall: (e) => {
9811
9831
  e.stopPropagation();
9812
9832
  closePluginHover();
9813
- setInstallFor(p);
9833
+ if (!installDialogBusyRef.current && !installingNamesRef.current.has(String(p.name || "").toLowerCase())) {
9834
+ setInstallFor(p);
9835
+ }
9814
9836
  },
9815
9837
  });
9816
9838
  }),
@@ -9869,7 +9891,8 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
9869
9891
  installFor && h(InstallDialog, {
9870
9892
  plugin: installFor,
9871
9893
  isDark,
9872
- onCancel: () => setInstallFor(null),
9894
+ onBusyChange: (v) => { installDialogBusyRef.current = !!v; },
9895
+ onCancel: () => { if (!installDialogBusyRef.current) setInstallFor(null); },
9873
9896
  onConfirm: doInstall,
9874
9897
  }),
9875
9898
 
@@ -9936,7 +9959,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
9936
9959
  showToast,
9937
9960
  }),
9938
9961
 
9939
- confirmRemoveSource && h("div", { className: "cpm-dialog", ...backdropDismissProps(() => setConfirmRemoveSource(null)) },
9962
+ confirmRemoveSource && h("div", { className: "cpm-dialog", ...backdropDismissProps(() => { if (!busy) setConfirmRemoveSource(null); }) },
9940
9963
  h(ConfirmDialogBox, {
9941
9964
  titleId: "cpm-confirm-remove-source-title",
9942
9965
  title: `删除插件源「${confirmRemoveSource.name}」`,
@@ -10090,10 +10113,34 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
10090
10113
  }
10091
10114
 
10092
10115
  // ────────────────────────────── Modern Install Dialog ──────────────────────────────
10093
- function InstallDialog({ plugin, isDark, onCancel, onConfirm }) {
10094
- const [busy, setBusy] = useState(false);
10116
+ function InstallDialog({ plugin, isDark, onCancel, onConfirm, onBusyChange }) {
10117
+ const [busy, setBusyState] = useState(false);
10118
+ const busyRef = useRef(false);
10119
+ const unmountedRef = useRef(false);
10120
+ useEffect(() => () => { unmountedRef.current = true; }, []);
10121
+ const setBusy = (next) => {
10122
+ const val = !!next;
10123
+ busyRef.current = val;
10124
+ if (!unmountedRef.current) {
10125
+ setBusyState(val);
10126
+ if (typeof onBusyChange === "function") onBusyChange(val);
10127
+ }
10128
+ };
10129
+ const handleCancel = () => {
10130
+ if (busyRef.current) return;
10131
+ onCancel();
10132
+ };
10133
+ const handleConfirm = async () => {
10134
+ if (busyRef.current) return;
10135
+ setBusy(true);
10136
+ try {
10137
+ await onConfirm();
10138
+ } finally {
10139
+ setBusy(false);
10140
+ }
10141
+ };
10095
10142
  const titleId = "cpm-install-dialog-title";
10096
- return h("div", { className: "cpm-dialog", ...backdropDismissProps(onCancel) },
10143
+ return h("div", { className: "cpm-dialog", ...backdropDismissProps(handleCancel) },
10097
10144
  h("div", {
10098
10145
  className: "cpm-dialog-box cpm-install-dialog",
10099
10146
  role: "dialog",
@@ -10110,11 +10157,11 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
10110
10157
  ),
10111
10158
  plugin.description && h("div", { className: "cpm-install-desc" }, plugin.description),
10112
10159
  h("div", { className: "cpm-dialog-actions", style: { marginTop: 18 } },
10113
- h("button", { className: "cpm-btn cpm-btn-secondary", onClick: onCancel, disabled: busy }, "取消"),
10160
+ h("button", { className: "cpm-btn cpm-btn-secondary", onClick: handleCancel, disabled: busy }, "取消"),
10114
10161
  h("button", {
10115
10162
  className: "cpm-btn cpm-btn-primary",
10116
10163
  disabled: busy,
10117
- onClick: async () => { setBusy(true); await onConfirm(); setBusy(false); },
10164
+ onClick: handleConfirm,
10118
10165
  }, busy ? "正在安装…" : "确认安装"),
10119
10166
  ),
10120
10167
  ),
@@ -11798,7 +11845,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
11798
11845
  }
11799
11846
 
11800
11847
  // ────────────────────────────── Detail View ──────────────────────────────
11801
- function DetailView({ plugin, pluginRecord, isDark, onBack, onInstall, onRemove, onManage, onTogglePlugin, showToast, containerRef, scrollState }) {
11848
+ function DetailView({ plugin, pluginRecord, isDark, installing = false, onBack, onInstall, onRemove, onManage, onTogglePlugin, showToast, containerRef, scrollState }) {
11802
11849
  const [busy, setBusy] = useState(false);
11803
11850
  const [confirmRemove, setConfirmRemove] = useState(false);
11804
11851
  const [toggling, setToggling] = useState(false);
@@ -11912,9 +11959,9 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
11912
11959
  !installed &&
11913
11960
  h("button", {
11914
11961
  className: "cpm-btn cpm-btn-primary",
11915
- disabled: busy,
11916
- onClick: async () => { setBusy(true); try { await onInstall(); } finally { setBusy(false); } },
11917
- }, busy ? "安装中…" : "Install"),
11962
+ disabled: busy || installing,
11963
+ onClick: async () => { if (busy || installing) return; setBusy(true); try { await onInstall(); } finally { setBusy(false); } },
11964
+ }, (busy || installing) ? "安装中…" : "Install"),
11918
11965
  installed && [
11919
11966
  h("button", {
11920
11967
  key: "r",
@@ -13998,6 +14045,8 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
13998
14045
  const AT_PLUGIN_RAW_TOKEN_RE = /@([^\s\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul},。;:、!?()【】《》“”‘’」』]+)/uy;
13999
14046
  const AT_PLUGIN_LEFT_ALLOWED_RE = /[\s(\[{"'“‘(【《,。;:、!?\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
14000
14047
  const AT_PLUGIN_TRAILING_PUNCT_RE = /[.,;:!?,。;:!?)"'\]”’)】》]+$/u;
14048
+ const EASY_REWRITE_BUBBLE = '[data-dsh-easyrewrite="user"] .dsh-easyrewrite-bubble';
14049
+ const AT_PLUGIN_CLIPBOARD = "data-uph-plugin-clipboard";
14001
14050
  const AT_PLUGINS_CSS = `
14002
14051
  [role="listbox"] button[id^="dsh-slash-option-plugins-"] {
14003
14052
  gap: 8px;
@@ -14061,8 +14110,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
14061
14110
  object-fit: contain !important;
14062
14111
  display: block;
14063
14112
  }
14064
- [data-composer-chip="plugins"],
14065
- .cpm-at-plugin-chip {
14113
+ [data-composer-chip="plugins"] {
14066
14114
  display: inline-flex;
14067
14115
  align-items: baseline;
14068
14116
  gap: 4px;
@@ -14078,6 +14126,27 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
14078
14126
  cursor: default;
14079
14127
  transition: background-color 120ms ease;
14080
14128
  }
14129
+ .cpm-at-plugin-chip {
14130
+ display: inline;
14131
+ margin: 0 2px;
14132
+ border-radius: var(--dsw-radius-sm, 4px);
14133
+ color: var(--dsw-alias-label-primary, #18181b);
14134
+ font-weight: 600;
14135
+ overflow-wrap: anywhere;
14136
+ user-select: all;
14137
+ }
14138
+ .cpm-at-plugin-chip > .cpm-at-plugin-chip-icon-wrap {
14139
+ display: inline-block;
14140
+ margin-inline-end: 4px;
14141
+ vertical-align: -0.125em;
14142
+ top: auto;
14143
+ pointer-events: none;
14144
+ }
14145
+ .cpm-at-plugin-chip .cpm-at-plugin-chip-icon,
14146
+ .cpm-at-plugin-chip .cpm-card-icon {
14147
+ display: inline-block;
14148
+ vertical-align: top;
14149
+ }
14081
14150
  body[data-ds-dark-theme] [data-composer-chip="plugins"],
14082
14151
  body[data-ds-dark-theme] .cpm-at-plugin-chip {
14083
14152
  color: var(--dsw-alias-label-primary, #f4f4f5);
@@ -14134,11 +14203,6 @@ body[data-ds-dark-theme] .cpm-at-plugin-chip {
14134
14203
  position: relative;
14135
14204
  top: 0.05em;
14136
14205
  }
14137
- .cpm-at-plugin-chip-label {
14138
- overflow: hidden;
14139
- text-overflow: ellipsis;
14140
- white-space: nowrap;
14141
- }
14142
14206
  .cpm-at-plugin-popover {
14143
14207
  position: fixed;
14144
14208
  inset: auto;
@@ -14349,6 +14413,106 @@ body[data-ds-dark-theme] .cpm-at-plugin-popover,
14349
14413
  return { source: "plugins", ref: mention, label, clipboardText: mention };
14350
14414
  }
14351
14415
 
14416
+ function copyAtPluginReferences(event) {
14417
+ if (event.defaultPrevented || !event.clipboardData || event.target?.isContentEditable ||
14418
+ event.target?.closest?.("input, textarea")) return;
14419
+ const selection = document.getSelection?.();
14420
+ if (selection?.rangeCount !== 1 || selection.isCollapsed) return;
14421
+ const range = selection.getRangeAt(0);
14422
+ const common = range.commonAncestorContainer;
14423
+ const element = common.nodeType === 1 ? common : common.parentElement;
14424
+ const bubble = element?.closest('[data-message-bubble], ' + EASY_REWRITE_BUBBLE);
14425
+ const chipSelector = '[' + AT_PLUGIN_CLIPBOARD + ']';
14426
+ if (!bubble?.querySelector(chipSelector)) return;
14427
+
14428
+ const fragment = range.cloneContents();
14429
+ // User text is inline. Leave structured content such as a host JSON block
14430
+ // to the browser so its formatting and rich clipboard formats are kept.
14431
+ if (fragment.querySelector("div, p, pre, table, ul, ol, blockquote")) return;
14432
+ const enclosingChip = element.closest(chipSelector);
14433
+ let text;
14434
+ if (enclosingChip && fragment.textContent === enclosingChip.textContent) {
14435
+ text = enclosingChip.getAttribute(AT_PLUGIN_CLIPBOARD);
14436
+ } else {
14437
+ let replaced = false;
14438
+ for (const chip of fragment.querySelectorAll(chipSelector)) {
14439
+ // A clipped label is ordinary selected text. A whole chip carries the original reference.
14440
+ if (chip.querySelector(".cpm-at-plugin-chip-label")?.textContent !== chip.getAttribute("data-uph-plugin-label")) continue;
14441
+ chip.replaceWith(chip.getAttribute(AT_PLUGIN_CLIPBOARD));
14442
+ replaced = true;
14443
+ }
14444
+ if (!replaced) return;
14445
+ for (const br of fragment.querySelectorAll("br")) br.replaceWith("\n");
14446
+ text = fragment.textContent;
14447
+ }
14448
+ event.clipboardData.setData("text/plain", text);
14449
+ event.preventDefault();
14450
+ }
14451
+
14452
+ function restoreEasyRewriteBubble({ bubble, mount, original }) {
14453
+ if (mount.parentElement === bubble) mount.replaceWith(original);
14454
+ }
14455
+
14456
+ function watchEasyRewriteBubbles(publish) {
14457
+ const entries = new Map();
14458
+ let nextId = 0;
14459
+
14460
+ function collect(root, bubbles) {
14461
+ if (root.nodeType !== 1) return;
14462
+ if (root.matches(EASY_REWRITE_BUBBLE)) bubbles.add(root);
14463
+ for (const bubble of root.querySelectorAll(EASY_REWRITE_BUBBLE)) bubbles.add(bubble);
14464
+ }
14465
+
14466
+ function update(bubbles) {
14467
+ let changed = false;
14468
+ for (const bubble of bubbles) {
14469
+ const previous = entries.get(bubble);
14470
+ const original = bubble.firstChild;
14471
+ if (bubble.isConnected && original && !original.nextSibling &&
14472
+ (previous?.mount === original || (previous?.original === original && previous.text === original.data))) continue;
14473
+ if (entries.delete(bubble)) changed = true;
14474
+ // EasyRewrite renders the resting bubble as one text node. Leave its editor,
14475
+ // attachments, buttons and any future renderer using structured children alone.
14476
+ if (!bubble.isConnected || original?.nodeType !== 3 || original.nextSibling) continue;
14477
+ const text = original.data;
14478
+ const first = matchAtPluginMention(text, 0, null, true);
14479
+ if (!first) continue;
14480
+ const mount = document.createElement("span");
14481
+ mount.style.display = "contents";
14482
+ entries.set(bubble, { id: nextId++, bubble, original, text, first, mount });
14483
+ changed = true;
14484
+ }
14485
+ if (changed) publish([...entries.values()]);
14486
+ }
14487
+
14488
+ const observer = new MutationObserver((mutations) => {
14489
+ const bubbles = new Set();
14490
+ let removed = false;
14491
+ for (const mutation of mutations) {
14492
+ const target = mutation.type === "characterData" ? mutation.target.parentElement : mutation.target;
14493
+ if (target?.matches?.(EASY_REWRITE_BUBBLE)) bubbles.add(target);
14494
+ for (const node of mutation.addedNodes) collect(node, bubbles);
14495
+ if (!removed && entries.size > 0 && mutation.removedNodes.length > 0) {
14496
+ removed = Array.from(mutation.removedNodes).some((node) => node.nodeType === 1);
14497
+ }
14498
+ }
14499
+ if (removed) {
14500
+ for (const bubble of entries.keys()) {
14501
+ if (!bubble.isConnected) bubbles.add(bubble);
14502
+ }
14503
+ }
14504
+ update(bubbles);
14505
+ });
14506
+ observer.observe(document.body, { subtree: true, childList: true, characterData: true });
14507
+ update(document.querySelectorAll(EASY_REWRITE_BUBBLE));
14508
+ return () => {
14509
+ observer.disconnect();
14510
+ // Restore text before another client instance scans the bubbles.
14511
+ for (const entry of entries.values()) restoreEasyRewriteBubble(entry);
14512
+ entries.clear();
14513
+ };
14514
+ }
14515
+
14352
14516
  function pasteAtPluginReferences(event, byLowerName) {
14353
14517
  const clipboard = event.clipboardData;
14354
14518
  if (event.defaultPrevented || !clipboard || clipboard.files?.length ||
@@ -14783,12 +14947,13 @@ body[data-ds-dark-theme] .cpm-at-plugin-popover,
14783
14947
  const ReactDOM = (() => { try { return require("react-dom") || null; } catch { return null; } })();
14784
14948
  const ReactDOMClient = (() => { try { return require("react-dom/client") || null; } catch { return null; } })();
14785
14949
 
14786
- function PluginMentionChip({ node }) {
14950
+ function PluginMentionChip({ node, raw }) {
14787
14951
  const [revision, setRevision] = useState(0);
14788
14952
  useEffect(() => {
14789
14953
  const bump = () => setRevision((r) => r + 1);
14790
14954
  const offStore = store.subscribe(bump);
14791
14955
  const offTheme = store.subscribeTheme(bump);
14956
+ store.warm();
14792
14957
  return () => {
14793
14958
  offStore();
14794
14959
  offTheme();
@@ -14802,6 +14967,7 @@ body[data-ds-dark-theme] .cpm-at-plugin-popover,
14802
14967
  "data-uph-plugin-chip": "true",
14803
14968
  "data-uph-plugin-name": live?.name || node?.data?.name || "",
14804
14969
  "data-uph-plugin-label": label,
14970
+ [AT_PLUGIN_CLIPBOARD]: raw,
14805
14971
  },
14806
14972
  live
14807
14973
  ? h("span", { className: "cpm-at-plugin-chip-icon-wrap", "aria-hidden": "true" },
@@ -14814,6 +14980,27 @@ body[data-ds-dark-theme] .cpm-at-plugin-popover,
14814
14980
  );
14815
14981
  }
14816
14982
 
14983
+ function EasyRewritePluginText({ entry }) {
14984
+ const { bubble, original, text, first, mount } = entry;
14985
+ useSafeLayoutEffect(() => {
14986
+ // Stage the portal off-DOM, then swap only the same plain text once
14987
+ // the chips have rendered. EasyRewrite still owns the bubble and its events.
14988
+ if (!bubble.isConnected || bubble.firstChild !== original || original.nextSibling || original.data !== text) return;
14989
+ original.replaceWith(mount);
14990
+ return () => restoreEasyRewriteBubble(entry);
14991
+ }, [entry]);
14992
+ const children = [];
14993
+ let cursor = 0;
14994
+ for (let node = first; node; node = matchAtPluginMention(text, cursor, null, true)) {
14995
+ children.push(text.slice(cursor, node.start), h(PluginMentionChip, {
14996
+ key: node.start, node, raw: text.slice(node.start, node.end),
14997
+ }));
14998
+ cursor = node.end;
14999
+ }
15000
+ children.push(text.slice(cursor));
15001
+ return children;
15002
+ }
15003
+
14817
15004
  function PluginChipHoverPopover({ hovered, isDark, session }) {
14818
15005
  const popRef = useRef(null);
14819
15006
  const [position, setPosition] = useState(null);
@@ -14906,7 +15093,7 @@ body[data-ds-dark-theme] .cpm-at-plugin-popover,
14906
15093
  let knownComposerEl = null;
14907
15094
  let syncQueued = false;
14908
15095
  let blockDisposed = false;
14909
- let activeOverlayState = { chips: [], hovered: null, isDark: store.isDark() };
15096
+ let activeOverlayState = { chips: [], rewriteBubbles: [], hovered: null, isDark: store.isDark() };
14910
15097
  let setOverlayState = null;
14911
15098
  let hoverSession = null;
14912
15099
 
@@ -15191,11 +15378,13 @@ body[data-ds-dark-theme] .cpm-at-plugin-popover,
15191
15378
 
15192
15379
  if (typeof document.addEventListener === "function") {
15193
15380
  const onPaste = (event) => pasteAtPluginReferences(event, store.getByLowerName());
15381
+ document.addEventListener("copy", copyAtPluginReferences);
15194
15382
  document.addEventListener("paste", onPaste, true);
15195
15383
  document.addEventListener("pointerover", onPointerOver, true);
15196
15384
  document.addEventListener("focusin", onFocusIn, true);
15197
15385
  document.addEventListener("keydown", onComposerKeyDown, true);
15198
15386
  disposers.push(() => {
15387
+ document.removeEventListener("copy", copyAtPluginReferences);
15199
15388
  document.removeEventListener("paste", onPaste, true);
15200
15389
  document.removeEventListener("pointerover", onPointerOver, true);
15201
15390
  document.removeEventListener("focusin", onFocusIn, true);
@@ -15247,6 +15436,9 @@ body[data-ds-dark-theme] .cpm-at-plugin-popover,
15247
15436
  setLocalState(activeOverlayState);
15248
15437
  return () => { if (setOverlayState === setLocalState) setOverlayState = null; };
15249
15438
  }, []);
15439
+ const rewritePortals = useMemo(() => overlayState.rewriteBubbles.map((entry) => ReactDOM.createPortal(
15440
+ h(EasyRewritePluginText, { entry }), entry.mount, "easyrewrite-" + entry.id,
15441
+ )), [overlayState.rewriteBubbles]);
15250
15442
  return h(React.Fragment, null,
15251
15443
  overlayState.chips.map((entry) => (
15252
15444
  entry.iconSlot?.isConnected
@@ -15259,6 +15451,7 @@ body[data-ds-dark-theme] .cpm-at-plugin-popover,
15259
15451
  )
15260
15452
  : null
15261
15453
  )),
15454
+ rewritePortals,
15262
15455
  h(PluginChipHoverPopover, {
15263
15456
  hovered: overlayState.hovered,
15264
15457
  isDark: overlayState.isDark,
@@ -15271,11 +15464,17 @@ body[data-ds-dark-theme] .cpm-at-plugin-popover,
15271
15464
  overlayRoot.render(h(AtPluginsOverlay));
15272
15465
  disposers.push(() => {
15273
15466
  setOverlayState = null;
15274
- activeOverlayState = { chips: [], hovered: null, isDark: false };
15467
+ activeOverlayState = { chips: [], rewriteBubbles: [], hovered: null, isDark: false };
15275
15468
  cleanupStaleAtPluginDom();
15276
15469
  try { overlayRoot.unmount(); } catch {}
15277
15470
  try { overlayHost.remove(); } catch {}
15278
15471
  });
15472
+ if (typeof MutationObserver === "function") {
15473
+ disposers.push(watchEasyRewriteBubbles((rewriteBubbles) => {
15474
+ activeOverlayState = { ...activeOverlayState, rewriteBubbles };
15475
+ setOverlayState?.(activeOverlayState);
15476
+ }));
15477
+ }
15279
15478
  } else {
15280
15479
  disposers.push(() => cleanupStaleAtPluginDom());
15281
15480
  }
package/package.json CHANGED
@@ -3,7 +3,8 @@
3
3
  "title": "Universal Plugin Hub",
4
4
  "displayName": "Universal Plugin Hub",
5
5
  "description": "在 DSH 中使用 Claude Code、Codex 等软件生态的插件,一站式管理插件、Skills 与 MCP。支持添加 Git 插件源和 marketplace、上传插件和 Skills、添加 MCP 服务器,自动扫描并开关本地 Skills,接入插件提供的子代理、MCP、Hooks 与 LSP。",
6
- "version": "1.5.0",
6
+ "version": "1.5.5",
7
+ "icon": "./assets/icon.svg",
7
8
  "engines": {
8
9
  "dsh": ">=0.1.5-rc.1"
9
10
  },
@@ -64,6 +65,7 @@
64
65
  },
65
66
  "./client": "./client/client.js",
66
67
  "./cordis.patch.yml": "./cordis.patch.yml",
68
+ "./icon": "./assets/icon.svg",
67
69
  "./package.json": "./package.json"
68
70
  },
69
71
  "files": [
@@ -72,6 +74,7 @@
72
74
  "scripts/postinstall.js",
73
75
  "cordis.patch.yml",
74
76
  "screenshots.json",
77
+ "assets/icon.svg",
75
78
  "assets/Plugins-official.png",
76
79
  "assets/Skills.png",
77
80
  "assets/MCP.png",