@ququ-jiaxk/dsh-plugin-center 0.1.40 → 0.1.41

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
@@ -30,7 +30,7 @@ __export(client_exports, {
30
30
  module.exports = __toCommonJS(client_exports);
31
31
  var import_react = require("react");
32
32
  var import_jsx_runtime = require("react/jsx-runtime");
33
- var PLUGIN_VERSION = true ? "0.1.40" : "0.0.0";
33
+ var PLUGIN_VERSION = true ? "0.1.41" : "0.0.0";
34
34
  var PANEL_ID = "plugin-center";
35
35
  var inject = ["slots", "remote", "remote.pluginManager"];
36
36
  var hostCtx = null;
@@ -205,6 +205,64 @@ function InstallProgressCard({ progress }) {
205
205
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-progress-package", children: progress.packageName })
206
206
  ] });
207
207
  }
208
+ function iconLetter(name) {
209
+ const clean = name.startsWith("@") ? name.split("/").pop() ?? name : name;
210
+ return clean.slice(0, 1).toUpperCase();
211
+ }
212
+ function InstalledList({
213
+ bundles,
214
+ centerItems,
215
+ query,
216
+ onOpen,
217
+ onUninstall
218
+ }) {
219
+ const center = new Map(centerItems.map((item) => [item.packageName, item]));
220
+ const keyword = query.trim().toLowerCase();
221
+ const list = bundles.filter((bundle) => {
222
+ if (!keyword) return true;
223
+ const display = center.get(bundle.name)?.displayName ?? "";
224
+ return bundle.name.toLowerCase().includes(keyword) || display.toLowerCase().includes(keyword);
225
+ });
226
+ if (list.length === 0) {
227
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-empty", children: [
228
+ keyword ? "\u6CA1\u6709\u5339\u914D\u7684\u672C\u673A\u63D2\u4EF6" : "\u672C\u673A\u8FD8\u6CA1\u6709\u5B89\u88C5\u63D2\u4EF6",
229
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-empty-hint", children: "\u8FD9\u91CC\u5217\u51FA DSH \u63D2\u4EF6\u7BA1\u7406\u5668\u626B\u63CF\u5230\u7684\u672C\u673A\u63D2\u4EF6\uFF0C\u5305\u542B\u672A\u5728\u4E2D\u5FC3\u4E0A\u67B6\u7684" })
230
+ ] });
231
+ }
232
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-grid", children: list.map((bundle) => {
233
+ const item = center.get(bundle.name);
234
+ const localInstall = !bundle.source || /(?:^|[^a-z0-9])(?:file|link):/iu.test(bundle.source);
235
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: "pcx-card", children: [
236
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
237
+ "div",
238
+ {
239
+ className: "pcx-card-main",
240
+ style: item ? void 0 : { cursor: "default" },
241
+ onClick: item ? () => onOpen(bundle.name) : void 0,
242
+ children: [
243
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-top", children: [
244
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-icon", children: iconLetter(item?.displayName ?? bundle.name) }),
245
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-card-titles", children: [
246
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-row", children: [
247
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-name", children: item?.displayName ?? bundle.name }),
248
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `pcx-badge ${bundle.enabled ? "pcx-badge-ok" : "pcx-badge-warn"}`, children: bundle.enabled ? "\u5DF2\u542F\u7528" : "\u5DF2\u505C\u7528" }),
249
+ bundle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge pcx-badge-danger", children: "\u8BFB\u53D6\u5F02\u5E38" }) : null,
250
+ item ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u672A\u4E0A\u67B6" })
251
+ ] }),
252
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-pkg", children: bundle.name })
253
+ ] })
254
+ ] }),
255
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-foot", children: [
256
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-foot-owner", children: bundle.official ? "\u968F DSH \u5B89\u88C5" : localInstall ? "\u672C\u5730\u5305\u5B89\u88C5" : "registry \u5B89\u88C5" }),
257
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-foot-meta", children: bundle.version ? `v${bundle.version}` : "\u7248\u672C\u672A\u77E5" })
258
+ ] })
259
+ ]
260
+ }
261
+ ),
262
+ bundle.removable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-card-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "pcx-btn pcx-btn-sm pcx-btn-danger", onClick: () => onUninstall(bundle.name), children: "\u5378\u8F7D" }) }) : null
263
+ ] }, bundle.name);
264
+ }) });
265
+ }
208
266
  function Panel() {
209
267
  const cached = panelSnapshot;
210
268
  const rootRef = (0, import_react.useRef)(null);
@@ -260,12 +318,18 @@ function Panel() {
260
318
  try {
261
319
  const snapshot = await api("/state");
262
320
  setState(snapshot);
263
- const effectiveScope = snapshot.user || nextScope === "public" ? nextScope : "public";
321
+ const effectiveScope = snapshot.user || nextScope === "public" || nextScope === "installed" ? nextScope : "public";
264
322
  const effectiveOffset = effectiveScope === nextScope ? nextOffset : 0;
265
323
  if (effectiveScope !== nextScope) {
266
324
  setScope("public");
267
325
  setNotice("\u767B\u5F55\u72B6\u6001\u5DF2\u5931\u6548\uFF0C\u5DF2\u5207\u56DE\u516C\u5F00\u5217\u8868");
268
326
  }
327
+ if (effectiveScope === "installed") {
328
+ setTotal(snapshot.installed?.length ?? 0);
329
+ setOffset(0);
330
+ setHasMore(false);
331
+ return;
332
+ }
269
333
  const params = new URLSearchParams({
270
334
  scope: effectiveScope,
271
335
  limit: "24",
@@ -509,6 +573,20 @@ function Panel() {
509
573
  } catch {
510
574
  }
511
575
  }
576
+ function uninstallLocal(packageName) {
577
+ setDialog({
578
+ title: `\u5378\u8F7D\u300C${packageName}\u300D\uFF1F`,
579
+ description: "\u53EA\u4ECE\u672C\u673A DSH \u79FB\u9664\uFF0C\u4E0D\u5F71\u54CD\u63D2\u4EF6\u4E2D\u5FC3\u91CC\u7684\u7248\u672C\u3002",
580
+ input: false,
581
+ confirmLabel: "\u5378\u8F7D",
582
+ danger: true,
583
+ action: async () => {
584
+ await api("/uninstall", { method: "POST", body: { packageName } });
585
+ setNotice(`\u5DF2\u5378\u8F7D ${packageName}`);
586
+ await load(scope, category, query);
587
+ }
588
+ });
589
+ }
512
590
  async function install(packageName, version) {
513
591
  setNotice(`\u6B63\u5728\u5B89\u88C5 ${packageName}${version ? `@${version}` : ""}\u2026`);
514
592
  setError("");
@@ -937,7 +1015,19 @@ function Panel() {
937
1015
  onClick: () => applyFilters({ scope: "all" }),
938
1016
  children: "\u5168\u90E8"
939
1017
  }
940
- ) : null
1018
+ ) : null,
1019
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1020
+ "button",
1021
+ {
1022
+ className: `pcx-tab ${scope === "installed" ? "pcx-tab-active" : ""}`,
1023
+ title: "\u626B\u63CF\u672C\u673A DSH \u5DF2\u5B89\u88C5\u7684\u63D2\u4EF6\uFF08\u542B\u672A\u5728\u4E2D\u5FC3\u4E0A\u67B6\u7684\uFF09",
1024
+ onClick: () => applyFilters({ scope: "installed" }),
1025
+ children: [
1026
+ "\u5DF2\u88C5",
1027
+ state?.installed?.length ? ` \xB7 ${state.installed.length}` : ""
1028
+ ]
1029
+ }
1030
+ )
941
1031
  ] }),
942
1032
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
943
1033
  "form",
@@ -962,7 +1052,7 @@ function Panel() {
962
1052
  }
963
1053
  )
964
1054
  ] }),
965
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-chips", children: [
1055
+ scope === "installed" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-chips", children: [
966
1056
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: `pcx-chip ${!category ? "pcx-chip-active" : ""}`, onClick: () => applyFilters({ category: "" }), children: "\u5168\u90E8" }),
967
1057
  CATEGORIES.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
968
1058
  "button",
@@ -974,7 +1064,16 @@ function Panel() {
974
1064
  item.id
975
1065
  ))
976
1066
  ] }),
977
- loading && items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-empty", children: "\u6B63\u5728\u52A0\u8F7D\u2026" }) : items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-empty", children: [
1067
+ scope === "installed" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1068
+ InstalledList,
1069
+ {
1070
+ bundles: state?.installed ?? [],
1071
+ centerItems: items,
1072
+ query,
1073
+ onOpen: (name) => void openDetail(name),
1074
+ onUninstall: uninstallLocal
1075
+ }
1076
+ ) : loading && items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-empty", children: "\u6B63\u5728\u52A0\u8F7D\u2026" }) : items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-empty", children: [
978
1077
  scope === "mine" ? "\u4F60\u8FD8\u6CA1\u6709\u4E0A\u4F20\u8FC7\u63D2\u4EF6" : "\u6CA1\u6709\u627E\u5230\u63D2\u4EF6",
979
1078
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-empty-hint", children: scope === "mine" ? "\u70B9\u53F3\u4E0A\u89D2\u300C\u4E0A\u4F20\u63D2\u4EF6\u300D\u5F00\u59CB" : "\u6362\u4E2A\u5173\u952E\u8BCD\u6216\u5206\u7C7B\u8BD5\u8BD5" })
980
1079
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-grid", children: items.map((plugin) => {
package/lib/index.js CHANGED
@@ -388,11 +388,16 @@ export function apply(ctx) {
388
388
  try {
389
389
  const bundles = await manager.listBundles()
390
390
  installed = bundles
391
- .filter((bundle) => bundle.installed && bundle.version)
391
+ .filter((bundle) => bundle.installed)
392
392
  .map((bundle) => ({
393
393
  name: bundle.name,
394
- version: bundle.version,
394
+ version: bundle.version ?? null,
395
395
  enabled: bundle.enabled,
396
+ official: Boolean(bundle.official),
397
+ availability: bundle.availability ?? null,
398
+ removable: Boolean(bundle.removable),
399
+ source: bundle.source ?? null,
400
+ error: bundle.error?.code ?? null,
396
401
  }))
397
402
  const own = bundles.find((bundle) => bundle.name === SELF_PACKAGE)
398
403
  if (own) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ququ-jiaxk/dsh-plugin-center",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "DSH 插件中心面板:浏览、安装、更新和发布远端插件中心的插件",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",