@ququ-jiaxk/dsh-plugin-center 0.1.45 → 0.1.47

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.
Files changed (2) hide show
  1. package/lib/client.js +60 -4
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -36,7 +36,7 @@ var logo_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" v
36
36
 
37
37
  // src/client.tsx
38
38
  var import_jsx_runtime = require("react/jsx-runtime");
39
- var PLUGIN_VERSION = true ? "0.1.45" : "0.0.0";
39
+ var PLUGIN_VERSION = true ? "0.1.47" : "0.0.0";
40
40
  var PANEL_ID = "plugin-center";
41
41
  var inject = ["slots", "remote", "remote.pluginManager"];
42
42
  var hostCtx = null;
@@ -50,6 +50,16 @@ var CATEGORIES = [
50
50
  { id: "design", label: "\u8BBE\u8BA1" },
51
51
  { id: "other", label: "\u5176\u4ED6" }
52
52
  ];
53
+ function isExperimentalBundle(bundle) {
54
+ return bundle.name.includes("experimental");
55
+ }
56
+ function localCategory(bundle) {
57
+ if (bundle.availability === "missing") return "offered";
58
+ if (isExperimentalBundle(bundle)) return "experimental";
59
+ if (bundle.optional) return "optional";
60
+ if (bundle.availability === "installation") return "builtin";
61
+ return "third";
62
+ }
53
63
  var panelSnapshot = null;
54
64
  var selfUpdateTarget = null;
55
65
  var selfUpdatePolling = false;
@@ -369,6 +379,7 @@ function InstalledList({
369
379
  bundles,
370
380
  centerItems,
371
381
  query,
382
+ filter,
372
383
  onOpen,
373
384
  onUninstall,
374
385
  onToggle,
@@ -376,7 +387,11 @@ function InstalledList({
376
387
  }) {
377
388
  const center = new Map(centerItems.map((item) => [item.packageName, item]));
378
389
  const keyword = query.trim().toLowerCase();
379
- const list = bundles.filter((bundle) => bundle.listedByDefault !== false || bundle.enabled).filter((bundle) => {
390
+ const list = bundles.filter((bundle) => {
391
+ if (filter === "all") return true;
392
+ if (filter === "disabled") return !bundle.enabled;
393
+ return localCategory(bundle) === filter;
394
+ }).filter((bundle) => {
380
395
  if (!keyword) return true;
381
396
  const display = center.get(bundle.name)?.displayName ?? "";
382
397
  return bundle.name.toLowerCase().includes(keyword) || display.toLowerCase().includes(keyword);
@@ -410,7 +425,7 @@ function InstalledList({
410
425
  experimental ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u5B9E\u9A8C\u6027" }) : null,
411
426
  bundle.optional ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u53EF\u9009" }) : null,
412
427
  bundle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge pcx-badge-danger", children: "\u8BFB\u53D6\u5F02\u5E38" }) : null,
413
- item ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u672A\u4E0A\u67B6" })
428
+ centerItems.length > 0 && !item ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "pcx-badge", children: "\u672A\u4E0A\u67B6" }) : null
414
429
  ] }),
415
430
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-pkg", children: bundle.name })
416
431
  ] })
@@ -482,6 +497,7 @@ function Panel() {
482
497
  const [items, setItems] = (0, import_react.useState)(cached?.items ?? []);
483
498
  const [total, setTotal] = (0, import_react.useState)(cached?.total ?? 0);
484
499
  const [scope, setScope] = (0, import_react.useState)(cached?.scope ?? "public");
500
+ const [localFilter, setLocalFilter] = (0, import_react.useState)("all");
485
501
  const [category, setCategory] = (0, import_react.useState)(cached?.category ?? "");
486
502
  const [query, setQuery] = (0, import_react.useState)(cached?.query ?? "");
487
503
  const [draft, setDraft] = (0, import_react.useState)(cached?.draft ?? "");
@@ -1316,7 +1332,46 @@ function Panel() {
1316
1332
  }
1317
1333
  )
1318
1334
  ] }),
1319
- scope === "installed" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-chips", children: [
1335
+ scope === "installed" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pcx-chips", children: (() => {
1336
+ const bundles = state?.bundles ?? [];
1337
+ const counts = {
1338
+ all: bundles.length,
1339
+ third: 0,
1340
+ builtin: 0,
1341
+ experimental: 0,
1342
+ optional: 0,
1343
+ offered: 0,
1344
+ disabled: 0
1345
+ };
1346
+ for (const bundle of bundles) {
1347
+ counts[localCategory(bundle)] += 1;
1348
+ if (!bundle.enabled) counts.disabled += 1;
1349
+ }
1350
+ const chips = [
1351
+ ["all", "\u5168\u90E8"],
1352
+ ["third", "\u7B2C\u4E09\u65B9"],
1353
+ ["builtin", "\u5185\u7F6E"],
1354
+ ["experimental", "\u5B9E\u9A8C\u6027"],
1355
+ ["optional", "\u53EF\u9009"],
1356
+ ["offered", "\u53EF\u5B89\u88C5"],
1357
+ ["disabled", "\u5DF2\u505C\u7528"]
1358
+ ];
1359
+ return chips.map(
1360
+ ([key, label]) => counts[key] ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1361
+ "button",
1362
+ {
1363
+ className: `pcx-chip ${localFilter === key ? "pcx-chip-active" : ""}`,
1364
+ onClick: () => setLocalFilter(key),
1365
+ children: [
1366
+ label,
1367
+ " \xB7 ",
1368
+ counts[key]
1369
+ ]
1370
+ },
1371
+ key
1372
+ ) : null
1373
+ );
1374
+ })() }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pcx-chips", children: [
1320
1375
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: `pcx-chip ${!category ? "pcx-chip-active" : ""}`, onClick: () => applyFilters({ category: "" }), children: "\u5168\u90E8" }),
1321
1376
  CATEGORIES.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1322
1377
  "button",
@@ -1334,6 +1389,7 @@ function Panel() {
1334
1389
  bundles: state?.bundles ?? state?.installed ?? [],
1335
1390
  centerItems: items,
1336
1391
  query,
1392
+ filter: localFilter,
1337
1393
  onOpen: (name) => {
1338
1394
  if (items.some((plugin) => plugin.packageName === name)) void openDetail(name);
1339
1395
  else void openLocalDetail(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ququ-jiaxk/dsh-plugin-center",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "description": "小趣插件中心:浏览、安装、更新和发布远端插件中心的插件",
5
5
  "icon": "logo.svg",
6
6
  "type": "module",