universal-plugin-hub 1.0.50 → 1.1.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
@@ -243,7 +243,14 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
243
243
  const useSafeLayoutEffect = typeof useLayoutEffect === "function" ? useLayoutEffect : useEffect;
244
244
 
245
245
  // ────────────────────────────── Styles ──────────────────────────────
246
- const CSS = `
246
+ const ICON_SHAPE_CSS = `
247
+ :root {
248
+ --cpm-icon-corner-shape: squircle;
249
+ --cpm-connector-icon-radius: calc(100% / 3);
250
+ }
251
+ `;
252
+
253
+ const CSS = `${ICON_SHAPE_CSS}
247
254
  /* ────────────────────────────── Light Theme (Default) ────────────────────────────── */
248
255
  .cpm-root {
249
256
  /* A damped spring (damping 0.62, ~8.4% overshoot) sampled into linear().
@@ -2651,7 +2658,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
2651
2658
  height: var(--del-size);
2652
2659
  padding: 0;
2653
2660
  border-radius: var(--del-radius);
2654
- corner-shape: squircle;
2661
+ corner-shape: var(--cpm-icon-corner-shape);
2655
2662
  /* The resting state already carries the squircle surface, so the control
2656
2663
  reads as a button before the pointer arrives; hover only deepens it. */
2657
2664
  border: 1px solid rgba(0, 0, 0, 0.07);
@@ -2912,14 +2919,14 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
2912
2919
  width: 24px;
2913
2920
  height: 24px;
2914
2921
  flex: 0 0 24px;
2915
- border-radius: 8px;
2922
+ border-radius: var(--cpm-connector-icon-radius);
2916
2923
  overflow: hidden;
2917
2924
  }
2918
2925
  .cpm-connector-owner-icon > .cpm-card-icon {
2919
2926
  width: 24px;
2920
2927
  height: 24px;
2921
2928
  flex: 0 0 24px;
2922
- border-radius: 8px;
2929
+ border-radius: var(--cpm-connector-icon-radius);
2923
2930
  box-shadow: none;
2924
2931
  }
2925
2932
  /* The fallback badge carries a hard-coded 34px <img>, which overflows a 24px
@@ -3725,9 +3732,11 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
3725
3732
  if (!el) {
3726
3733
  el = document.createElement("style");
3727
3734
  el.id = "cpm-style";
3735
+ el.textContent = CSS;
3728
3736
  document.head.appendChild(el);
3737
+ } else if (el.textContent !== CSS) {
3738
+ el.textContent = CSS;
3729
3739
  }
3730
- el.textContent = CSS;
3731
3740
  }
3732
3741
 
3733
3742
  function isDarkMode(ctx, rootEl) {
@@ -3800,6 +3809,10 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
3800
3809
  let body = null;
3801
3810
  try { body = await res.json(); } catch { /* no body */ }
3802
3811
  if (!res.ok) throw new Error((body && body.error) || `HTTP ${res.status}`);
3812
+ if (body?.ok !== false && !body?.error && /^(POST|PUT|PATCH|DELETE)$/.test(options?.method || "") &&
3813
+ /^\/(plugins|mcps)(\/|$)/.test(path) && !/\/(verify|oauth-status|inspect|tools\/toggle)$/.test(path)) {
3814
+ document.dispatchEvent(new Event("uph-mcp-branding-changed"));
3815
+ }
3803
3816
  return body;
3804
3817
  }
3805
3818
 
@@ -5095,7 +5108,6 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
5095
5108
  }, []);
5096
5109
 
5097
5110
  useEffect(() => {
5098
- ensureCss();
5099
5111
  const update = () => setIsDark(getEffectiveTheme());
5100
5112
  update();
5101
5113
  const raf = requestAnimationFrame(update);
@@ -8089,7 +8101,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
8089
8101
  const ownerLower = (owner || "").toLowerCase();
8090
8102
  const repoLower = (repo || "").toLowerCase();
8091
8103
 
8092
- if (repoLower === "claude-plugins-official" || ownerLower === "anthropics") return "Anthropic";
8104
+ if (repoLower === "claude-plugins-official") return "Anthropic";
8093
8105
  if (repoLower === "claude-plugins-community") return "Community";
8094
8106
 
8095
8107
  const genericWords = new Set([
@@ -8146,7 +8158,8 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
8146
8158
  const finalSuggested = computeSmartSuggestedName(raw, body.suggestedName);
8147
8159
  setRepoLabel(finalRepoLabel);
8148
8160
  setSuggested(finalSuggested);
8149
- setCustomName(finalSuggested);
8161
+ setCustomName("");
8162
+ setMode("suggest");
8150
8163
  setNormalizedUrl(body.normalizedUrl || raw);
8151
8164
  setPluginCount(body.pluginCount || 0);
8152
8165
  setPhase("name");
@@ -8469,12 +8482,13 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
8469
8482
  ref: customInputRef,
8470
8483
  className: "cpm-input cpm-source-custom-input",
8471
8484
  value: customName,
8485
+ autoComplete: "off",
8472
8486
  placeholder: "输入自定义标签名",
8473
8487
  onChange: (e) => { setCustomName(e.target.value); setMode("custom"); },
8474
8488
  onFocus: () => setMode("custom"),
8475
8489
  onClick: (e) => e.stopPropagation(),
8476
8490
  onKeyDown: (e) => {
8477
- if (e.key === "Enter" && !busy && customName.trim()) confirm();
8491
+ if (e.key === "Enter" && !e.nativeEvent.isComposing && !busy && customName.trim()) confirm();
8478
8492
  }
8479
8493
  }),
8480
8494
  h(ClearBtn, { value: customName, onClear: () => setCustomName("") }),
@@ -10834,7 +10848,294 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
10834
10848
  }
10835
10849
 
10836
10850
  // ────────────────────────────── Main sidebar & panel entry ──────────────────────────────
10851
+ // DSH's keyed slot adds a display:contents anchor around the fallback row.
10852
+ const TOOL_CALL_ROW = ':is([data-chat-call-id], [data-chat-call-id] > [data-slot="tool.call.toolview"]) > [data-variant="others"]';
10853
+
10854
+ function toolCallIconCss(names, url) {
10855
+ const selectors = [];
10856
+ for (const name of names) {
10857
+ if (!/^mcp__[A-Za-z0-9_-]{1,59}$/.test(name)) continue;
10858
+ // DSH ToolCallTree → generic ToolRow → collapsed DisclosureRow.
10859
+ // The idle span fades on hover, so the native chevron still wins.
10860
+ const row = `${TOOL_CALL_ROW}[data-tool="${name}"]:not([data-state="error"], [data-state="stopped"]) > div:not([data-open]) > [data-disclosure-header] > [data-disclosure-row]`;
10861
+ const leading = `${row} > span:first-child`;
10862
+ selectors.push(`${leading} > svg:only-child`, `${leading} > span:first-child > svg:only-child`);
10863
+ }
10864
+ if (!selectors.length) return "";
10865
+ return `@media (forced-colors: none) {
10866
+ ${selectors.join(",\n")} {
10867
+ background: url(${JSON.stringify(url)}) center / contain no-repeat;
10868
+ border-radius: var(--cpm-connector-icon-radius);
10869
+ @supports (corner-shape: squircle) {
10870
+ border-radius: 50%;
10871
+ corner-shape: var(--cpm-icon-corner-shape);
10872
+ }
10873
+ }
10874
+ ${selectors.map(selector => `${selector} > *`).join(",\n")} { opacity: 0; }
10875
+ }`;
10876
+ }
10877
+
10878
+ function formatToolCallLabel(name, summary, pluginName, rawName) {
10879
+ if (summary !== name && !summary.startsWith(name + " · ")) return summary;
10880
+ const label = `${pluginName} MCP ${rawName.replace(/_+/g, " ").trim()}`;
10881
+ return label + summary.slice(name.length);
10882
+ }
10883
+
10884
+ function createToolCallLabels(onRow) {
10885
+ const rowSelector = `${TOOL_CALL_ROW}[data-tool]`;
10886
+ const headerSelector = ':scope > div > [data-disclosure-header] > [data-disclosure-row]';
10887
+ const shimmerAttribute = "data-shimmer-text";
10888
+ const summaryAttribute = "data-uph-tool-summary";
10889
+ const brandKey = "uph-mcp-brand";
10890
+ const registry = globalThis.CSS?.highlights;
10891
+ const brandHighlight = registry && typeof Highlight === "function" ? new Highlight() : null;
10892
+ if (brandHighlight) registry.set(brandKey, brandHighlight);
10893
+ const changes = new Map();
10894
+ let labelsByName = new Map();
10895
+ let observedTextRows = new WeakSet();
10896
+ const read = (node, attribute) => attribute ? node.getAttribute(attribute) : node.data;
10897
+ const write = (node, attribute, value) => {
10898
+ if (!attribute) node.data = value;
10899
+ else if (value === null) node.removeAttribute(attribute);
10900
+ else node.setAttribute(attribute, value);
10901
+ };
10902
+
10903
+ function restoreChange(node) {
10904
+ const change = changes.get(node);
10905
+ if (!change) return;
10906
+ const { attribute, original, label, brandRange } = change;
10907
+ if (brandRange) brandHighlight.delete(brandRange);
10908
+ if (node.isConnected && read(node, attribute) === label) write(node, attribute, original);
10909
+ changes.delete(node);
10910
+ }
10911
+
10912
+ function restore() {
10913
+ observer?.disconnect();
10914
+ observedTextRows = new WeakSet();
10915
+ for (const node of changes.keys()) restoreChange(node);
10916
+ }
10917
+
10918
+ function updateRow(row) {
10919
+ const name = row.getAttribute("data-tool");
10920
+ if (name?.startsWith("mcp__")) onRow?.(name);
10921
+ const identity = labelsByName.get(name);
10922
+ if (!identity && !row.querySelector(`[${summaryAttribute}]`)) return;
10923
+ if (identity && observer && !observedTextRows.has(row)) {
10924
+ observer.observe(row, { subtree: true, characterData: true });
10925
+ observedTextRows.add(row);
10926
+ }
10927
+ const header = row.querySelector(headerSelector);
10928
+ if (!header) return;
10929
+ for (const summary of header.querySelectorAll("[data-shimmer-decoration] + *")) {
10930
+ const shimmer = summary.querySelector(`[${shimmerAttribute}]`);
10931
+ const node = shimmer || document.createTreeWalker(summary, 4).nextNode();
10932
+ if (!node || !identity) {
10933
+ if (node) restoreChange(node);
10934
+ restoreChange(summary);
10935
+ continue;
10936
+ }
10937
+ const attribute = shimmer ? shimmerAttribute : null;
10938
+ const original = read(node, attribute);
10939
+ const label = formatToolCallLabel(name, original, identity.pluginName, identity.rawName);
10940
+ if (label === original) {
10941
+ if (changes.get(node)?.label !== original) {
10942
+ restoreChange(node);
10943
+ restoreChange(summary);
10944
+ }
10945
+ continue;
10946
+ }
10947
+ restoreChange(node);
10948
+ write(node, attribute, label);
10949
+ let brandRange;
10950
+ if (brandHighlight && !attribute) {
10951
+ brandRange = document.createRange();
10952
+ brandRange.setStart(node, 0);
10953
+ brandRange.setEnd(node, identity.pluginName.length + " MCP".length);
10954
+ brandHighlight.add(brandRange);
10955
+ }
10956
+ changes.set(node, { attribute, original, label, brandRange });
10957
+ if (!changes.has(summary)) {
10958
+ changes.set(summary, { attribute: summaryAttribute, original: read(summary, summaryAttribute), label: "" });
10959
+ write(summary, summaryAttribute, "");
10960
+ }
10961
+ }
10962
+ }
10963
+
10964
+ const observer = typeof MutationObserver === "undefined" ? null : new MutationObserver(records => {
10965
+ const rows = new Set();
10966
+ for (const { target, addedNodes } of records) {
10967
+ const element = target.nodeType === 1 ? target : target.parentElement;
10968
+ const row = element?.closest(rowSelector);
10969
+ if (row) rows.add(row);
10970
+ for (const node of addedNodes) {
10971
+ if (node.nodeType !== 1) continue;
10972
+ if (node.matches(rowSelector)) rows.add(node);
10973
+ for (const child of node.querySelectorAll(rowSelector)) rows.add(child);
10974
+ }
10975
+ }
10976
+ for (const row of rows) if (row.isConnected) updateRow(row);
10977
+ if (records.some(record => record.removedNodes.length)) {
10978
+ for (const node of changes.keys()) if (!node.isConnected) restoreChange(node);
10979
+ }
10980
+ });
10981
+
10982
+ return {
10983
+ update(groups) {
10984
+ restore();
10985
+ labelsByName = new Map(groups.flatMap(({ plugin, tools }) =>
10986
+ tools.map(({ name, rawName }) => [name, { pluginName: plugin.displayName || plugin.name, rawName }])
10987
+ ));
10988
+ if ((!labelsByName.size && !onRow) || !observer || !document.body) return;
10989
+ for (const row of document.querySelectorAll(rowSelector)) updateRow(row);
10990
+ observer.observe(document.body, {
10991
+ childList: true, subtree: true,
10992
+ attributes: true, attributeFilter: [shimmerAttribute, "data-tool"],
10993
+ });
10994
+ },
10995
+ dispose() {
10996
+ restore();
10997
+ if (brandHighlight && registry.get(brandKey) === brandHighlight) registry.delete(brandKey);
10998
+ },
10999
+ };
11000
+ }
11001
+
11002
+ function installToolCallIcons(ctx) {
11003
+ const style = document.createElement("style");
11004
+ style.dataset.plugin = "universal-plugin-hub";
11005
+ style.dataset.uphToolCallIcons = "";
11006
+ const chatCss = `${ICON_SHAPE_CSS}
11007
+ [data-disclosure-row] [data-shimmer-decoration]:has(+ [data-uph-tool-summary]),
11008
+ [data-disclosure-row] :has(+ [data-shimmer-decoration] + [data-uph-tool-summary]) {
11009
+ display: none;
11010
+ }
11011
+ @media (forced-colors: none) {
11012
+ ::highlight(uph-mcp-brand) { color: #4D6BFE; }
11013
+ }`;
11014
+ style.textContent = chatCss;
11015
+ document.head.append(style);
11016
+ const labels = createToolCallLabels(onRow);
11017
+ const images = new Map();
11018
+ const byName = new Map();
11019
+ const mcpRowSelector = `${TOOL_CALL_ROW}[data-tool^="mcp__"]`;
11020
+ let disposed = false;
11021
+ let request;
11022
+ let checkedAt = -Infinity;
11023
+ let current = "";
11024
+ let generation = 0;
11025
+ const refreshInterval = 10000;
11026
+
11027
+ function decodeIcon(url, warm) {
11028
+ if (!images.has(url)) {
11029
+ const image = new Image();
11030
+ if (warm) image.fetchPriority = "low";
11031
+ image.src = url;
11032
+ const decoded = image.decode().then(() => true, () => {
11033
+ if (images.get(url) === decoded) images.delete(url);
11034
+ return false;
11035
+ });
11036
+ if (images.size >= 128) images.delete(images.keys().next().value);
11037
+ images.set(url, decoded);
11038
+ }
11039
+ return images.get(url);
11040
+ }
11041
+
11042
+ async function publishIcon(group, warm = false) {
11043
+ const revision = generation;
11044
+ const candidates = warm ? group.urls.slice(0, 1) : group.urls;
11045
+ for (const url of candidates) {
11046
+ if (disposed || revision !== generation || group.published) return;
11047
+ if (!await decodeIcon(url, warm)) continue;
11048
+ if (disposed || revision !== generation || group.published) return;
11049
+ const rule = toolCallIconCss(group.names, url);
11050
+ if (rule && style.sheet) style.sheet.insertRule(rule, style.sheet.cssRules.length);
11051
+ group.published = true;
11052
+ return;
11053
+ }
11054
+ }
11055
+
11056
+ function onRow(name) {
11057
+ const group = byName.get(name);
11058
+ const now = Date.now();
11059
+ if (group && !group.loading && !group.published && now >= (group.retryAt ?? 0)) {
11060
+ group.loading = true;
11061
+ void publishIcon(group).catch(() => {}).finally(() => {
11062
+ group.loading = false;
11063
+ if (!group.published) group.retryAt = Date.now() + refreshInterval;
11064
+ });
11065
+ }
11066
+ if (now - checkedAt >= refreshInterval) void refresh(true);
11067
+ }
11068
+
11069
+ function setGroups(groups, dark) {
11070
+ const signature = JSON.stringify([dark, groups]);
11071
+ if (signature === current) return;
11072
+ generation++;
11073
+ current = signature;
11074
+ byName.clear();
11075
+ style.textContent = chatCss;
11076
+ // Only decode small, already available artwork on the startup path.
11077
+ let warmCount = 0;
11078
+ let warmBytes = 0;
11079
+ for (const { plugin, tools } of groups) {
11080
+ const names = tools.map(tool => tool.name);
11081
+ const urls = getPluginIconCandidates(plugin, dark)
11082
+ .flatMap(url => [plugin.icons?.previews?.[url], url]).filter(Boolean);
11083
+ const group = { names, urls };
11084
+ for (const name of names) byName.set(name, group);
11085
+ const inline = urls[0];
11086
+ if (warmCount < 12 && inline?.startsWith("data:image/") && warmBytes + inline.length <= 256 * 1024) {
11087
+ warmCount++;
11088
+ warmBytes += inline.length;
11089
+ void publishIcon(group, true).catch(() => {});
11090
+ }
11091
+ }
11092
+ labels.update(groups);
11093
+ }
11094
+
11095
+ async function refresh(force = false) {
11096
+ if (disposed || request || document.hidden) return;
11097
+ if (!force && !document.querySelector(mcpRowSelector)) return;
11098
+ const controller = new AbortController();
11099
+ request = controller;
11100
+ checkedAt = Date.now();
11101
+ try {
11102
+ const { groups } = await api("/tool-call-icons", { cache: "no-store", signal: controller.signal });
11103
+ if (request === controller) setGroups(groups, isDarkMode(ctx, document.documentElement));
11104
+ } catch {
11105
+ if (request === controller) setGroups([], false);
11106
+ } finally {
11107
+ if (request === controller) request = undefined;
11108
+ }
11109
+ }
11110
+
11111
+ function invalidate() {
11112
+ request?.abort();
11113
+ request = undefined;
11114
+ checkedAt = -Infinity;
11115
+ void refresh(true);
11116
+ setGroups([], false);
11117
+ }
11118
+
11119
+ const onVisibility = () => void refresh(!current || Date.now() - checkedAt >= refreshInterval);
11120
+ const timer = setInterval(refresh, refreshInterval);
11121
+ document.addEventListener("visibilitychange", onVisibility);
11122
+ document.addEventListener("uph-mcp-branding-changed", invalidate);
11123
+ void refresh(true);
11124
+ return () => {
11125
+ disposed = true;
11126
+ request?.abort();
11127
+ request = undefined;
11128
+ clearInterval(timer);
11129
+ document.removeEventListener("visibilitychange", onVisibility);
11130
+ document.removeEventListener("uph-mcp-branding-changed", invalidate);
11131
+ labels.dispose();
11132
+ style.remove();
11133
+ };
11134
+ }
11135
+
10837
11136
  function Section({ ctx }) {
11137
+ const useStyleEffect = React.useInsertionEffect || useSafeLayoutEffect;
11138
+ useStyleEffect(ensureCss, []);
10838
11139
  return h(ErrorBoundary, null, h(MarketApp, { ctx }));
10839
11140
  }
10840
11141
 
@@ -10862,7 +11163,7 @@ window.__ModuleLoader__.load({ id: "universal-plugin-hub", factory: (require) =>
10862
11163
  const inject = ["slots", "theme"];
10863
11164
 
10864
11165
  function apply(ctx) {
10865
- ensureCss();
11166
+ ctx.effect?.(() => installToolCallIcons(ctx), "universal-plugin-hub: tool call icons");
10866
11167
  ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
10867
11168
  name: "sidebar.panellist",
10868
11169
  id: "universal-plugin-hub",
package/package.json CHANGED
@@ -3,7 +3,7 @@
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.0.50",
6
+ "version": "1.1.0",
7
7
  "engines": {
8
8
  "dsh": ">=0.1.5-rc.1"
9
9
  },
package/src/index.js CHANGED
@@ -26,7 +26,7 @@ export function apply(ctx) {
26
26
  // Everything below that resolves a profile path has to run *after* this, so
27
27
  // it lives inside the injection rather than beside it.
28
28
  let provisioned = Promise.resolve()
29
- ctx.inject(['profileContext'], (hostCtx) => {
29
+ ctx.inject(['profileContext'], async (hostCtx) => {
30
30
  const name = hostCtx.profileContext?.name
31
31
  if (typeof name === 'string' && name.trim()) process.env.DSH_PROFILE = name.trim()
32
32
 
@@ -34,7 +34,7 @@ export function apply(ctx) {
34
34
  try {
35
35
  restoreUploadedSkills()
36
36
 
37
- syncAllInstalledSkillsToDsh()
37
+ await syncAllInstalledSkillsToDsh()
38
38
  } catch (err) {
39
39
  ctx.logger?.warn?.(`[universal-plugin-hub] skill sync error: ${err.message}`)
40
40
  }