dsh-plugin-core-demo 0.35.11 → 0.35.13

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/dist/client.js CHANGED
@@ -1324,6 +1324,26 @@ function groupOf(groups, value) {
1324
1324
  return void 0;
1325
1325
  return groups.find((g) => g.options.some((o) => o.value === value));
1326
1326
  }
1327
+ function retainSelectedValue(groups, value) {
1328
+ if (value === void 0 || value === "")
1329
+ return { groups, retained: false };
1330
+ if (flattenOptions(groups).some((o) => o.value === value))
1331
+ return { groups, retained: false };
1332
+ const slash3 = value.indexOf("/");
1333
+ const provider = slash3 > 0 ? value.slice(0, slash3) : "";
1334
+ const option = { value, label: value };
1335
+ const group = groups.find((g) => g.value === provider && g.value !== "");
1336
+ if (group !== void 0) {
1337
+ return {
1338
+ groups: groups.map((g) => g === group ? { value: g.value, label: g.label, options: [option, ...g.options] } : g),
1339
+ retained: true
1340
+ };
1341
+ }
1342
+ return {
1343
+ groups: [...groups, { value: provider, label: provider, options: [option] }],
1344
+ retained: true
1345
+ };
1346
+ }
1327
1347
  function resolveTriggerSizing(opts) {
1328
1348
  const px = (v) => typeof v === "number" ? `${v}px` : v;
1329
1349
  if (opts.width !== void 0) {
@@ -5624,6 +5644,24 @@ var WorkspaceListStore = class {
5624
5644
  };
5625
5645
  var workspaceList = new WorkspaceListStore();
5626
5646
  var workspaceFiles;
5647
+ var boundModelsPath;
5648
+ var catalogInFlight;
5649
+ function loadModelCatalog(path) {
5650
+ if (catalogInFlight !== void 0)
5651
+ return catalogInFlight;
5652
+ const job = fetch(path, { cache: "no-store" }).then((response) => response.ok ? response.json() : Promise.reject(new Error(`HTTP ${response.status}`))).then((data2) => {
5653
+ const routes = data2?.routes;
5654
+ if (!Array.isArray(routes))
5655
+ throw new Error("\u6A21\u578B\u76EE\u5F55\u54CD\u5E94\u7F3A\u5C11 routes");
5656
+ modelCatalog.setRoutes(routes);
5657
+ }).catch((error) => {
5658
+ modelCatalog.setUnavailable(String(error));
5659
+ }).finally(() => {
5660
+ catalogInFlight = void 0;
5661
+ });
5662
+ catalogInFlight = job;
5663
+ return job;
5664
+ }
5627
5665
  function isWorkspaceSource(value) {
5628
5666
  if (value === null || typeof value !== "object")
5629
5667
  return false;
@@ -5646,14 +5684,8 @@ function connectHost(ctx, options = {}) {
5646
5684
  const modelsPath = options.modelsPath;
5647
5685
  if (modelsPath === void 0)
5648
5686
  return;
5649
- void fetch(modelsPath).then((response) => response.ok ? response.json() : Promise.reject(new Error(`HTTP ${response.status}`))).then((data2) => {
5650
- const routes = data2?.routes;
5651
- if (!Array.isArray(routes))
5652
- throw new Error("\u6A21\u578B\u76EE\u5F55\u54CD\u5E94\u7F3A\u5C11 routes");
5653
- modelCatalog.setRoutes(routes);
5654
- }).catch((error) => {
5655
- modelCatalog.setUnavailable(String(error));
5656
- });
5687
+ boundModelsPath = modelsPath;
5688
+ void loadModelCatalog(modelsPath);
5657
5689
  }
5658
5690
 
5659
5691
  // dist/ui/inputs/picker-icons.js
@@ -5687,7 +5719,7 @@ function ModelPicker(props) {
5687
5719
  const searchable = props.searchable ?? true;
5688
5720
  const defaultOption = props.allowDefault === false ? void 0 : { value: "", label: props.defaultLabel ?? tt("modelDefault") };
5689
5721
  const catalog = (0, import_react16.useSyncExternalStore)(modelCatalog.subscribe, modelCatalog.getSnapshot, modelCatalog.getSnapshot);
5690
- const groups = props.groups ?? (catalog.status === "ready" ? catalog.routes.map((route) => ({
5722
+ const catalogGroups = props.groups ?? (catalog.status === "ready" ? catalog.routes.map((route) => ({
5691
5723
  value: route.provider,
5692
5724
  label: route.displayName,
5693
5725
  options: route.models.map((model) => ({
@@ -5695,7 +5727,9 @@ function ModelPicker(props) {
5695
5727
  label: model.name ?? model.id
5696
5728
  }))
5697
5729
  })) : []);
5698
- const degraded = props.degraded ?? (catalog.status === "unavailable" || catalog.status === "ready" && groups.length === 0);
5730
+ const retained = retainSelectedValue(catalogGroups, props.value);
5731
+ const groups = retained.groups;
5732
+ const degraded = props.degraded ?? (catalog.status === "unavailable" || catalog.status === "ready" && catalogGroups.length === 0 || retained.retained);
5699
5733
  const icon2 = props.icon === void 0 ? sparkleIcon() : props.icon ?? void 0;
5700
5734
  const emitModel = (v) => {
5701
5735
  props.onChange?.(typeof v === "string" ? v : v[0] ?? "");
@@ -5754,7 +5788,8 @@ function ModelPicker(props) {
5754
5788
  }
5755
5789
  const group = groups.find((g) => g.value === provider);
5756
5790
  const options = group === void 0 ? [] : flattenOptions([group]);
5757
- return (0, import_react16.createElement)("div", { className: "dshpc-picker__row" }, (0, import_react16.createElement)(Picker, {
5791
+ const rowClass = ["dshpc-picker__row", props.className, props.rowClassName].filter((part) => part !== void 0 && part !== "").join(" ");
5792
+ return (0, import_react16.createElement)("div", { className: rowClass }, (0, import_react16.createElement)(Picker, {
5758
5793
  options: groups.map((g) => ({ value: g.value, label: g.label })),
5759
5794
  value: provider === "" ? void 0 : provider,
5760
5795
  placeholder: tt("modelProvider"),
@@ -5764,6 +5799,8 @@ function ModelPicker(props) {
5764
5799
  searchSizing: props.searchSizing,
5765
5800
  searchable,
5766
5801
  size: props.size,
5802
+ placement: props.placement,
5803
+ className: props.providerClassName,
5767
5804
  translate: props.translate,
5768
5805
  onChange: (v) => {
5769
5806
  setPickedProvider(typeof v === "string" ? v : v[0] ?? "");
@@ -5784,7 +5821,7 @@ function ModelPicker(props) {
5784
5821
  hint: props.hint,
5785
5822
  size: props.size,
5786
5823
  placement: props.placement,
5787
- className: props.className,
5824
+ className: props.modelClassName,
5788
5825
  translate: props.translate,
5789
5826
  onChange: emitModel
5790
5827
  }));
@@ -6682,6 +6719,7 @@ function Pagination(props) {
6682
6719
  className: "dshpc-pagination__size",
6683
6720
  minWidth: "auto",
6684
6721
  mode: "single",
6722
+ size: props.size,
6685
6723
  options: options.map((size4) => ({
6686
6724
  value: String(size4),
6687
6725
  label: tt("paginationPageSizeOption", { n: size4 })
@@ -63863,8 +63901,12 @@ var docData = {
63863
63901
  "en": "\xA71 Initialize styles (once at entry): `id` must be unique within the plugin so co-mounted plugins don\u2019t clobber; vars and classes use the fixed `dshpc` prefix, no parameter."
63864
63902
  },
63865
63903
  {
63866
- "zh": "\xA72 \u7528\u4E00\u4E2A\u63A7\u4EF6",
63867
- "en": "\xA72 Use a control"
63904
+ "zh": "\xA72 \u7528\u4E00\u4E2A\u63A7\u4EF6\uFF1A\u901A\u7528 `Picker` \u7684\u9009\u9879\u7531\u8C03\u7528\u65B9\u7ED9\uFF08\u793A\u4F8B\u91CC\u662F `priorities`\uFF0C\u4E0D\u662F\u6A21\u578B\u76EE\u5F55\uFF09\u3002",
63905
+ "en": "\xA72 Use a control: a generic `Picker` takes its options from the caller (`priorities` in the example, not a model catalog)."
63906
+ },
63907
+ {
63908
+ "zh": "\xA72 \u9644\uFF1A\u9009\u6A21\u578B\u4E0D\u8981\u624B\u6413\u6570\u7EC4 \u2014\u2014 \u5BBF\u4E3B `serveModelCatalog(ctx, { path })` \u6CE8\u518C\u53EA\u8BFB\u76EE\u5F55\u8DEF\u7531\uFF0Cclient `connectHost(ctx, { modelsPath: path })` \u7528\u540C\u4E00\u4E2A path \u5E38\u91CF\u63A5\u4E0A\uFF0C\u518D\u6E32\u67D3 `ModelPicker`\uFF1B\u4F9B\u5E94\u5546 / \u6A21\u578B\u6709\u589E\u51CF\u8C03 `await refreshModelCatalog()` \u91CD\u62C9\u3002\u6F0F\u4E86 `modelsPath` \u5C31\u662F\u7A7A\u76EE\u5F55\uFF0C\u4E14\u4E0D\u4F1A\u6709\u62A5\u9519\u3002",
63909
+ "en": "\xA72a Model selection: never hand-roll a models array. Register `serveModelCatalog(ctx, { path })` on the host, call `connectHost(ctx, { modelsPath: path })` on the client with the same path constant, then render `ModelPicker`. `await refreshModelCatalog()` re-pulls the catalog when providers change. Omitting `modelsPath` leaves the catalog empty, silently."
63868
63910
  },
63869
63911
  {
63870
63912
  "zh": "\xA73 \u7528\u901A\u7528\u65B9\u6CD5",
@@ -63897,7 +63939,12 @@ var docData = {
63897
63939
  {
63898
63940
  "id": "integration-use-control",
63899
63941
  "lang": "tsx",
63900
- "src": "import { Button, Input, Picker, showToast } from 'dsh-plugin-core/ui'\n\nh(Input, { value: name, onChange: setName, placeholder: '\u4EFB\u52A1\u540D', error: nameError })\nh(Button, { variant: 'primary', onClick: save }, '\u4FDD\u5B58')\nh(Picker, {\n options: models, // [{ value, label }]\n value: current,\n onChange: (v) => setCurrent(v as string),\n searchable: true,\n clearable: true,\n})\nshowToast('\u5DF2\u4FDD\u5B58', { variant: 'success' })"
63942
+ "src": "import { Button, Input, Picker, showToast } from 'dsh-plugin-core/ui'\n\nh(Input, { value: name, onChange: setName, placeholder: '\u4EFB\u52A1\u540D', error: nameError })\nh(Button, { variant: 'primary', onClick: save }, '\u4FDD\u5B58')\nh(Picker, {\n options: priorities, // [{ value, label }]\uFF1A\u901A\u7528 Picker \u7684\u9009\u9879\u7531\u8C03\u7528\u65B9\u7ED9\n value: current,\n onChange: (v) => setCurrent(v as string),\n searchable: true,\n clearable: true,\n})\nshowToast('\u5DF2\u4FDD\u5B58', { variant: 'success' })"
63943
+ },
63944
+ {
63945
+ "id": "integration-use-model-catalog",
63946
+ "lang": "tsx",
63947
+ "src": "// paths.ts \u2014\u2014 \u5BBF\u4E3B\u4E0E client \u5171\u7528\u540C\u4E00\u4E2A\u5E38\u91CF\nexport const MODELS_PATH = '/api/dsh-task-reminder/models'\n\n// \u5BBF\u4E3B apply\uFF1A\u6CE8\u518C\u53EA\u8BFB\u6A21\u578B\u76EE\u5F55\u8DEF\u7531\nimport { serveModelCatalog } from 'dsh-plugin-core/host'\nserveModelCatalog(ctx, { path: MODELS_PATH })\n\n// client apply\uFF1A\u63A5\u540C\u4E00\u4E2A path\nimport { connectHost, refreshModelCatalog, ModelPicker } from 'dsh-plugin-core/ui'\nconnectHost(ctx, { modelsPath: MODELS_PATH })\n\n// \u4E09\u79CD\u5F62\u6001\u5171\u7528\u540C\u4E00\u4EFD\u76EE\u5F55\uFF0ConChange \u4E00\u5F8B\u53D1 provider/id\nh(ModelPicker, { variant: 'cascade', value: current, onChange: setCurrent })\nawait refreshModelCatalog() // \u4F9B\u5E94\u5546 / \u6A21\u578B\u6709\u589E\u51CF\u65F6\u91CD\u62C9\uFF08Promise\uFF09"
63901
63948
  },
63902
63949
  {
63903
63950
  "id": "integration-use-utils",
@@ -63974,12 +64021,21 @@ var docData = {
63974
64021
  }
63975
64022
  },
63976
64023
  {
63977
- "name": "\u60F3\u8BA9\u7EC4\u4EF6\u81EA\u5DF1\u53D6\u5DE5\u4F5C\u533A / \u6A21\u578B\u5217\u8868",
63978
- "type": "\u73B0\u8C61\uFF1A\u53D6\u4E0D\u5230\uFF08\u901A\u9053\u662F\u63D2\u4EF6\u79C1\u6709\u7684\uFF09",
64024
+ "name": "\u7ED9\u901A\u7528 Picker \u624B\u6413 models \u6570\u7EC4",
64025
+ "type": "\u73B0\u8C61\uFF1A\u5019\u9009\u5199\u6B7B / \u7A7A\u76EE\u5F55",
64026
+ "def": "\u2014",
64027
+ "desc": {
64028
+ "zh": "\u9009\u6A21\u578B\u8D70 ModelPicker + \u5BBF\u4E3B serveModelCatalog / client connectHost(ctx, { modelsPath }) \u4E24\u6BB5\u5F0F\u63A5\u7EBF",
64029
+ "en": "Use ModelPicker with the two-sided serveModelCatalog / connectHost(ctx, { modelsPath }) wiring"
64030
+ }
64031
+ },
64032
+ {
64033
+ "name": "connectHost(ctx) \u4E0D\u5E26 modelsPath",
64034
+ "type": "\u73B0\u8C61\uFF1A\u6A21\u578B\u76EE\u5F55\u6C38\u8FDC\u505C\u5728 loading\uFF0C\u4E0D\u62A5\u9519",
63979
64035
  "def": "\u2014",
63980
64036
  "desc": {
63981
- "zh": "\u6570\u636E\u7ECF props \u7ED9\uFF0C\u5BBF\u4E3B\u80FD\u529B\u7ECF\u63A5\u53E3\u6CE8\u5165",
63982
- "en": "Data via props, host capability via injected interface"
64037
+ "zh": "\u6A21\u578B\u76EE\u5F55\u4E0D\u662F\u5FEB\u7167\uFF0C\u5FC5\u987B\u4F20\u5BBF\u4E3B\u6CE8\u518C\u7684\u540C\u4E00\u4E2A path",
64038
+ "en": "The model catalog is an HTTP route, not a snapshot: pass the same path registered on the host"
63983
64039
  }
63984
64040
  },
63985
64041
  {
@@ -64299,8 +64355,8 @@ var docData = {
64299
64355
  "en": "WorkspacePicker: a domain picker that brings its own data. Call `connectHost(ctx)` once in the plugin apply and it subscribes to the official `workspaces` snapshot. Unwired = empty state, never fabricated data. Trigger and search-box sizing (`width` / `minWidth` / `maxWidth` / `searchSizing`) matches Picker; `translate` overrides all built-in copy in the component and its dropdown."
64300
64356
  },
64301
64357
  {
64302
- "zh": "ModelPicker\uFF1A\u9009\u62E9\u6A21\u578B\u7684\u5B8C\u6574\u5C01\u88C5\uFF0C\u4E09\u79CD\u5F62\u6001\u5171\u7528\u540C\u4E00\u4EFD\u5BBF\u4E3B\u76EE\u5F55\uFF08`serveModelCatalog`\uFF09\uFF0C`onChange` \u4E00\u5F8B\u53D1 `provider/id`\uFF1A`grouped`\uFF08\u9ED8\u8BA4\uFF09= \u4E00\u4E2A\u4E0B\u62C9\u3001\u4F9B\u5E94\u5546\u505A\u7EC4\u5934\uFF1B`flat` = \u4E00\u4E2A\u4E0B\u62C9\u3001\u5168\u90E8\u6A21\u578B\u5E73\u94FA\u6210\u300C\u5382\u5546-\u6A21\u578B\u300D\u5E76\u5E26\u641C\u7D22\uFF0C\u641C\u5382\u5546\u540D\u5373\u53EF\u7B5B\uFF1B`cascade` = \u4E24\u4E2A\u4E0B\u62C9\u8054\u52A8\uFF0C\u5382\u5546\u6846\u4E0E\u6A21\u578B\u6846\u90FD\u5E26\u641C\u7D22\uFF0C\u6362\u5382\u5546\u6E05\u7A7A\u6A21\u578B\u3002`width` / `minWidth` / `maxWidth` \u7BA1\u89E6\u53D1\u5668\uFF0C`searchSizing` \u7BA1\u6240\u6709\u641C\u7D22\u6846\uFF0C`providerSizing` / `modelSizing` \u8BA9\u8054\u52A8\u6001\u4E24\u4E2A\u6846\u5206\u522B\u8BBE\u5BBD\u3002",
64303
- "en": "ModelPicker: the complete model selector. Three variants share one host catalog (`serveModelCatalog`) and always emit `provider/id`: `grouped` (default) groups models under provider headers in one dropdown; `flat` lists every model as `vendor-model` in one searchable dropdown; `cascade` links two searchable dropdowns (provider then model). `width`/`minWidth`/`maxWidth` size triggers, `searchSizing` sizes every search box, and `providerSizing`/`modelSizing` size the two cascade boxes separately."
64358
+ "zh": "ModelPicker\uFF1A\u9009\u62E9\u6A21\u578B\u7684\u5B8C\u6574\u5C01\u88C5\uFF0C\u4E09\u79CD\u5F62\u6001\u5171\u7528\u540C\u4E00\u4EFD\u5BBF\u4E3B\u76EE\u5F55\uFF0C`onChange` \u4E00\u5F8B\u53D1 `provider/id`\uFF1A`grouped`\uFF08\u9ED8\u8BA4\uFF09= \u4E00\u4E2A\u4E0B\u62C9\u3001\u4F9B\u5E94\u5546\u505A\u7EC4\u5934\uFF1B`flat` = \u4E00\u4E2A\u4E0B\u62C9\u3001\u5168\u90E8\u6A21\u578B\u5E73\u94FA\u6210\u300C\u5382\u5546-\u6A21\u578B\u300D\u5E76\u5E26\u641C\u7D22\uFF0C\u641C\u5382\u5546\u540D\u5373\u53EF\u7B5B\uFF1B`cascade` = \u4E24\u4E2A\u4E0B\u62C9\u8054\u52A8\uFF0C\u5382\u5546\u6846\u4E0E\u6A21\u578B\u6846\u90FD\u5E26\u641C\u7D22\uFF0C\u6362\u5382\u5546\u6E05\u7A7A\u6A21\u578B\u3002**\u63A5\u7EBF\u662F\u4E24\u6BB5\u5F0F**\uFF1A\u5BBF\u4E3B `serveModelCatalog(ctx, { path })` + client `connectHost(ctx, { modelsPath: path })` \u7528\u540C\u4E00\u4E2A path \u5E38\u91CF\uFF0C\u6F0F\u4E86 `modelsPath` \u76EE\u5F55\u6C38\u8FDC\u505C\u5728 loading\uFF1B\u4F9B\u5E94\u5546 / \u6A21\u578B\u6709\u589E\u51CF\u65F6 `await refreshModelCatalog()` \u91CD\u62C9\u3002`width` / `minWidth` / `maxWidth` \u7BA1\u89E6\u53D1\u5668\uFF0C`searchSizing` \u7BA1\u6240\u6709\u641C\u7D22\u6846\uFF0C`providerSizing` / `modelSizing` \u8BA9\u8054\u52A8\u6001\u4E24\u4E2A\u6846\u5206\u522B\u8BBE\u5BBD\u3002\u65E7\u503C\u5DF2\u4E0D\u5728\u76EE\u5F55\u91CC\u65F6\u6309\u771F\u5B9E\u503C\u4FDD\u7559\u4E00\u9879\u5E76\u5982\u5B9E\u63D0\u793A\u300C\u5019\u9009\u53EF\u80FD\u4E0D\u5B8C\u6574\u300D\uFF0C\u4E0D\u9759\u9ED8\u4E22\u5F03\u3002",
64359
+ "en": 'ModelPicker: the complete model selector. Three variants share one host catalog and always emit `provider/id`: `grouped` (default) groups models under provider headers in one dropdown; `flat` lists every model as `vendor-model` in one searchable dropdown; `cascade` links two searchable dropdowns (provider then model). **Wiring is two-sided**: `serveModelCatalog(ctx, { path })` on the host and `connectHost(ctx, { modelsPath: path })` on the client with the same path constant \u2014 without `modelsPath` the catalog stays `loading` forever; `await refreshModelCatalog()` re-pulls it when providers change. `width`/`minWidth`/`maxWidth` size triggers, `searchSizing` sizes every search box, and `providerSizing`/`modelSizing` size the two cascade boxes separately. A controlled value no longer present in the catalog is retained as-is with an honest "candidates may be incomplete" hint instead of being silently dropped.'
64304
64360
  }
64305
64361
  ],
64306
64362
  "api": [
@@ -64668,9 +64724,45 @@ var docData = {
64668
64724
  "en": "icon: omitted = default star; null = hidden; element = custom"
64669
64725
  }
64670
64726
  },
64727
+ {
64728
+ "name": "className",
64729
+ "type": "string",
64730
+ "def": "\u2014",
64731
+ "desc": {
64732
+ "zh": "\u7EC4\u4EF6\u6839\u5143\u7D20\uFF1Agrouped / flat \u843D\u5728 Picker \u6839\uFF0Ccascade \u843D\u5728\u4E24\u6846\u5916\u5C42 row",
64733
+ "en": "Root element: the Picker root for grouped/flat, the outer row for cascade"
64734
+ }
64735
+ },
64736
+ {
64737
+ "name": "rowClassName",
64738
+ "type": "string",
64739
+ "def": "\u2014",
64740
+ "desc": {
64741
+ "zh": "cascade \u5916\u5C42 row \u7684\u9644\u52A0\u7C7B\u540D\uFF08\u63A7\u5236\u4E24\u6846\u95F4\u8DDD / \u5E03\u5C40\uFF09",
64742
+ "en": "Extra class for the cascade outer row (gap / layout)"
64743
+ }
64744
+ },
64745
+ {
64746
+ "name": "providerClassName / modelClassName",
64747
+ "type": "string",
64748
+ "def": "\u2014",
64749
+ "desc": {
64750
+ "zh": "cascade \u5382\u5546\u6846 / \u6A21\u578B\u6846\u5404\u81EA\u7684\u7C7B\u540D",
64751
+ "en": "Class for the cascade provider / model box"
64752
+ }
64753
+ },
64754
+ {
64755
+ "name": "refreshModelCatalog()",
64756
+ "type": "(path?: string) => Promise<ModelCatalogState>",
64757
+ "def": "\u2014",
64758
+ "desc": {
64759
+ "zh": "\u4F9B\u5E94\u5546 / \u6A21\u578B\u6709\u589E\u51CF\u65F6\u91CD\u62C9\u76EE\u5F55\uFF1B\u4E0D\u4F20 path \u7528 connectHost \u8BB0\u4E0B\u7684\u90A3\u4E2A\uFF1B\u672A\u63A5\u7EBF\u5219 reject",
64760
+ "en": "Re-pull the catalog when providers change; omit path to reuse the wired one; rejects if unwired"
64761
+ }
64762
+ },
64671
64763
  {
64672
64764
  "name": "\u900F\u4F20 Picker",
64673
- "type": "value / defaultValue / onChange / clearable / searchable / hint / size / placement / className / disabled / degraded / translate",
64765
+ "type": "value / defaultValue / onChange / clearable / searchable / hint / size / placement / disabled / degraded / translate",
64674
64766
  "def": "\u2014",
64675
64767
  "desc": {
64676
64768
  "zh": "\u540C Picker \u540C\u540D\u53C2\u6570",
@@ -64685,6 +64777,11 @@ var docData = {
64685
64777
  "id": "ui-workspacepicker-example",
64686
64778
  "lang": "tsx",
64687
64779
  "src": "import { WorkspacePicker, connectHost } from 'dsh-plugin-core/ui'\n\n// apply(ctx) \u91CC\uFF1AconnectHost(ctx)\nh(WorkspacePicker, { value: cur, onChange: setCur, clearable: true })"
64780
+ },
64781
+ {
64782
+ "id": "ui-modelpicker-example",
64783
+ "lang": "tsx",
64784
+ "src": "// paths.ts \u2014\u2014 \u5BBF\u4E3B\u4E0E client \u5171\u7528\u540C\u4E00\u4E2A\u5E38\u91CF\nexport const MODELS_PATH = '/api/dsh-task-reminder/models'\n\n// \u5BBF\u4E3B apply\uFF1A\u6CE8\u518C\u53EA\u8BFB\u6A21\u578B\u76EE\u5F55\u8DEF\u7531\nimport { serveModelCatalog } from 'dsh-plugin-core/host'\nserveModelCatalog(ctx, { path: MODELS_PATH })\n\n// client apply\uFF1A\u63A5\u540C\u4E00\u4E2A path\nimport { connectHost, refreshModelCatalog, ModelPicker } from 'dsh-plugin-core/ui'\nconnectHost(ctx, { modelsPath: MODELS_PATH })\n\n// \u4E09\u79CD\u5F62\u6001\u5171\u7528\u540C\u4E00\u4EFD\u76EE\u5F55\uFF0ConChange \u4E00\u5F8B\u53D1 provider/id\nh(ModelPicker, { variant: 'cascade', value: current, onChange: setCurrent })\nawait refreshModelCatalog() // \u4F9B\u5E94\u5546 / \u6A21\u578B\u6709\u589E\u51CF\u65F6\u91CD\u62C9\uFF08Promise\uFF09"
64688
64785
  }
64689
64786
  ]
64690
64787
  },
@@ -65832,6 +65929,15 @@ var docData = {
65832
65929
  "en": "Only then does the rows-per-page select appear"
65833
65930
  }
65834
65931
  },
65932
+ {
65933
+ "name": "size",
65934
+ "type": "'sm' | 'md' | 'lg'",
65935
+ "def": "'md'",
65936
+ "desc": {
65937
+ "zh": "\u300C\u6BCF\u9875\u6761\u6570\u300D\u4E0B\u62C9\u7684\u5C3A\u5BF8\u6863\u4F4D\uFF1B\u9875\u7801\u6309\u94AE\u56FA\u5B9A md",
65938
+ "en": "Size of the rows-per-page select; page buttons stay md"
65939
+ }
65940
+ },
65835
65941
  {
65836
65942
  "name": "showTotal",
65837
65943
  "type": "boolean | (total, from, to) => ReactNode",
@@ -65884,7 +65990,7 @@ var docData = {
65884
65990
  {
65885
65991
  "id": "ui-pagination-example",
65886
65992
  "lang": "tsx",
65887
- "src": "import { Pagination, Table } from 'dsh-plugin-core/ui'\n\n// \u72EC\u7ACB\u63A7\u4EF6\uFF1A\u53EA\u7ED9\u5F53\u524D\u9875 / \u6BCF\u9875\u6761\u6570 / \u603B\u6761\u6570 \u2014\u2014 \u603B\u9875\u6570\u4E0E\u7701\u7565\u7A97\u53E3\u7531\u63A7\u4EF6\u7B97\uFF0C\n// \u6D88\u8D39\u65B9\u6C38\u8FDC\u4E0D\u81EA\u5DF1\u7B97\u9875\u6570\u3001\u4E5F\u4E0D\u81EA\u5DF1\u6E32\u67D3\u9875\u7801\nh(Pagination, {\n page, pageSize, total: 86,\n onChange: (nextPage, nextSize) => { setPage(nextPage); setPageSize(nextSize) },\n align: 'right', // left / center / right\uFF08\u9ED8\u8BA4 right\uFF09\n pageSizeOptions: [10, 20, 50], // \u4F20\u4E86\u624D\u51FA\u73B0\u300C\u6BCF\u9875\u6761\u6570\u300D\u4E0B\u62C9\n showTotal: true, // \u4F20\u4E86\u624D\u51FA\u73B0\u300C\u7B2C 1-10 \u6761\uFF0C\u5171 86 \u6761\u300D\n siblingCount: 1, // \u5F53\u524D\u9875\u4E24\u4FA7\u7559\u51E0\u9875\uFF08\u9ED8\u8BA4 1\uFF09\n boundaryCount: 1, // \u9996\u5C3E\u5404\u56FA\u5B9A\u51E0\u9875\uFF08\u9ED8\u8BA4 1\uFF1B1/1 \u5408\u8BA1\u6700\u591A 7 \u4E2A\u4F4D\u7F6E\uFF09\n hideOnSinglePage: true, // \u53EA\u6709\u4E00\u9875\u65F6\u6574\u6761\u4E0D\u6E32\u67D3\n})\n\n// \u7B80\u6D01\u6A21\u5F0F\uFF1A\u53EA\u7559\u4E0A\u4E00\u9875 / \u4E0B\u4E00\u9875\u4E0E\u300C2 / 36\u300D\nh(Pagination, { page, pageSize, total: 86, simple: true, onChange })\n\n// Table \u5185\u5EFA\uFF1A\u4E0D\u4F20 total = \u672C\u5730\u5206\u9875\uFF08rows \u662F\u5168\u91CF\uFF0C\u8868\u683C\u81EA\u5DF1\u6309\u5F53\u524D\u9875\u5207\u7247\uFF0C\u9875\u7801\u6392\u5728\u8868\u4E0B\uFF09\nh(Table, {\n columns, rows,\n pagination: { page, pageSize, showTotal: true, onChange },\n})\n\n// \u670D\u52A1\u7AEF\u5206\u9875\uFF1A\u7ED9\u4E86 total \u5C31\u4E0D\u5207\u7247\uFF08rows \u53EA\u653E\u5F53\u524D\u9875\u90A3\u51E0\u6761\uFF09\uFF0C\u8868\u683C\u53EA\u8D1F\u8D23\u6446\u9875\u7801\nh(Table, {\n columns, rows: currentPageRows,\n pagination: { page, pageSize, total: 86, onChange },\n})\n\n// \u52A0\u8F7D\u6001\uFF08\u6EDA\u52A8\u52A0\u8F7D\uFF0C\u4E0E\u5206\u9875\u4E8C\u9009\u4E00\uFF09\uFF1AonLoadMore \u672C\u8EAB\u5C31\u662F\u5F00\u5173 \u2014\u2014 \u4F20\u4E86\u5C31\u76D1\u542C\u5E95\u90E8\nh(Table, {\n columns, rows: [],\n loading: true, // \u9996\u5C4F\u4E00\u6761\u6570\u636E\u90FD\u6CA1\u6709\uFF1A\u6574\u8868\u9AD8\u5360\u4F4D\uFF08\u9ED8\u8BA4 160px\uFF09\n loadingHeight: 160,\n})\n\nh(Table, {\n columns, rows,\n loadingMore: true, // \u6B63\u5728\u53D6\u4E0B\u4E00\u9875\uFF1A\u5E95\u90E8\u4E00\u884C\u5C0F\u8F6C\u5708\n hasMore: true, // false \u21D2 \u5E95\u90E8\u300C\u6CA1\u6709\u66F4\u591A\u6570\u636E\u300D\uFF1BnoMoreText: false \u53EF\u5173\n onLoadMore: () => fetchNextPage(), // \u6EDA\u5230\u63A5\u8FD1\u5E95\u90E8\u81EA\u52A8\u89E6\u53D1\u4E00\u6B21\n})"
65993
+ "src": "import { Pagination, Table } from 'dsh-plugin-core/ui'\n\n// \u72EC\u7ACB\u63A7\u4EF6\uFF1A\u53EA\u7ED9\u5F53\u524D\u9875 / \u6BCF\u9875\u6761\u6570 / \u603B\u6761\u6570 \u2014\u2014 \u603B\u9875\u6570\u4E0E\u7701\u7565\u7A97\u53E3\u7531\u63A7\u4EF6\u7B97\uFF0C\n// \u6D88\u8D39\u65B9\u6C38\u8FDC\u4E0D\u81EA\u5DF1\u7B97\u9875\u6570\u3001\u4E5F\u4E0D\u81EA\u5DF1\u6E32\u67D3\u9875\u7801\nh(Pagination, {\n page, pageSize, total: 86,\n onChange: (nextPage, nextSize) => { setPage(nextPage); setPageSize(nextSize) },\n align: 'right', // left / center / right\uFF08\u9ED8\u8BA4 right\uFF09\n pageSizeOptions: [10, 20, 50], // \u4F20\u4E86\u624D\u51FA\u73B0\u300C\u6BCF\u9875\u6761\u6570\u300D\u4E0B\u62C9\n size: 'sm', // \u8BE5\u4E0B\u62C9\u7684\u5C3A\u5BF8\uFF1Asm / md / lg\uFF08\u9ED8\u8BA4 md\uFF09\n showTotal: true, // \u4F20\u4E86\u624D\u51FA\u73B0\u300C\u7B2C 1-10 \u6761\uFF0C\u5171 86 \u6761\u300D\n siblingCount: 1, // \u5F53\u524D\u9875\u4E24\u4FA7\u7559\u51E0\u9875\uFF08\u9ED8\u8BA4 1\uFF09\n boundaryCount: 1, // \u9996\u5C3E\u5404\u56FA\u5B9A\u51E0\u9875\uFF08\u9ED8\u8BA4 1\uFF1B1/1 \u5408\u8BA1\u6700\u591A 7 \u4E2A\u4F4D\u7F6E\uFF09\n hideOnSinglePage: true, // \u53EA\u6709\u4E00\u9875\u65F6\u6574\u6761\u4E0D\u6E32\u67D3\n})\n\n// \u7B80\u6D01\u6A21\u5F0F\uFF1A\u53EA\u7559\u4E0A\u4E00\u9875 / \u4E0B\u4E00\u9875\u4E0E\u300C2 / 36\u300D\nh(Pagination, { page, pageSize, total: 86, simple: true, onChange })\n\n// Table \u5185\u5EFA\uFF1A\u4E0D\u4F20 total = \u672C\u5730\u5206\u9875\uFF08rows \u662F\u5168\u91CF\uFF0C\u8868\u683C\u81EA\u5DF1\u6309\u5F53\u524D\u9875\u5207\u7247\uFF0C\u9875\u7801\u6392\u5728\u8868\u4E0B\uFF09\nh(Table, {\n columns, rows,\n pagination: { page, pageSize, showTotal: true, onChange },\n})\n\n// \u670D\u52A1\u7AEF\u5206\u9875\uFF1A\u7ED9\u4E86 total \u5C31\u4E0D\u5207\u7247\uFF08rows \u53EA\u653E\u5F53\u524D\u9875\u90A3\u51E0\u6761\uFF09\uFF0C\u8868\u683C\u53EA\u8D1F\u8D23\u6446\u9875\u7801\nh(Table, {\n columns, rows: currentPageRows,\n pagination: { page, pageSize, total: 86, onChange },\n})\n\n// \u52A0\u8F7D\u6001\uFF08\u6EDA\u52A8\u52A0\u8F7D\uFF0C\u4E0E\u5206\u9875\u4E8C\u9009\u4E00\uFF09\uFF1AonLoadMore \u672C\u8EAB\u5C31\u662F\u5F00\u5173 \u2014\u2014 \u4F20\u4E86\u5C31\u76D1\u542C\u5E95\u90E8\nh(Table, {\n columns, rows: [],\n loading: true, // \u9996\u5C4F\u4E00\u6761\u6570\u636E\u90FD\u6CA1\u6709\uFF1A\u6574\u8868\u9AD8\u5360\u4F4D\uFF08\u9ED8\u8BA4 160px\uFF09\n loadingHeight: 160,\n})\n\nh(Table, {\n columns, rows,\n loadingMore: true, // \u6B63\u5728\u53D6\u4E0B\u4E00\u9875\uFF1A\u5E95\u90E8\u4E00\u884C\u5C0F\u8F6C\u5708\n hasMore: true, // false \u21D2 \u5E95\u90E8\u300C\u6CA1\u6709\u66F4\u591A\u6570\u636E\u300D\uFF1BnoMoreText: false \u53EF\u5173\n onLoadMore: () => fetchNextPage(), // \u6EDA\u5230\u63A5\u8FD1\u5E95\u90E8\u81EA\u52A8\u89E6\u53D1\u4E00\u6B21\n})"
65888
65994
  }
65889
65995
  ]
65890
65996
  },
@@ -71238,9 +71344,9 @@ function ReferencePage() {
71238
71344
  "tbody",
71239
71345
  null,
71240
71346
  [
71241
- [t3("buildCore"), `v${"0.35.11"}`],
71242
- [t3("buildDemo"), `v${"0.35.11"}`],
71243
- [t3("buildStamp"), "261110-053038-714"]
71347
+ [t3("buildCore"), `v${"0.35.13"}`],
71348
+ [t3("buildDemo"), `v${"0.35.13"}`],
71349
+ [t3("buildStamp"), "261110-080713-415"]
71244
71350
  ].map(
71245
71351
  ([label, value]) => (0, import_react98.createElement)(
71246
71352
  "tr",
@@ -71556,9 +71662,9 @@ function DemoPage() {
71556
71662
  lineHeight: "14px"
71557
71663
  }
71558
71664
  },
71559
- (0, import_react100.createElement)("span", null, `core v${"0.35.11"}`),
71560
- (0, import_react100.createElement)("span", null, `demo v${"0.35.11"}`),
71561
- (0, import_react100.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261110-053038-714")
71665
+ (0, import_react100.createElement)("span", null, `core v${"0.35.13"}`),
71666
+ (0, import_react100.createElement)("span", null, `demo v${"0.35.13"}`),
71667
+ (0, import_react100.createElement)("span", { style: { marginTop: "4px", fontSize: "9px" } }, "261110-080713-415")
71562
71668
  )
71563
71669
  )
71564
71670
  ),
package/dist/index.js CHANGED
@@ -1107,19 +1107,35 @@ async function buildModelRoutes(llm) {
1107
1107
  routes.sort((left, right) => left.displayName.localeCompare(right.displayName));
1108
1108
  return routes;
1109
1109
  }
1110
+ var JSON_HEADERS = { "content-type": "application/json; charset=utf-8" };
1110
1111
  function serveModelCatalog(ctx, options) {
1111
- ctx.inject(["llm", "webServer"], (services) => {
1112
- const llm = services.llm;
1112
+ ctx.inject(["webServer"], (services) => {
1113
1113
  const webServer = services.webServer;
1114
- if (llm === void 0 || webServer === void 0)
1114
+ if (webServer === void 0)
1115
1115
  return;
1116
1116
  webServer.register({
1117
1117
  kind: "exact",
1118
1118
  path: options.path,
1119
- handler: async (_req, res) => {
1120
- const routes = await buildModelRoutes(llm);
1121
- res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
1122
- res.end(JSON.stringify({ routes }));
1119
+ handler: async (req, res) => {
1120
+ if (options.authorize !== void 0 && !await options.authorize(req)) {
1121
+ res.writeHead(403, JSON_HEADERS);
1122
+ res.end(JSON.stringify({ error: "forbidden" }));
1123
+ return;
1124
+ }
1125
+ const llm = options.getLlm?.() ?? ctx.get?.("llm");
1126
+ if (llm === void 0) {
1127
+ res.writeHead(503, JSON_HEADERS);
1128
+ res.end(JSON.stringify({ routes: [], error: "llm-unavailable" }));
1129
+ return;
1130
+ }
1131
+ try {
1132
+ const routes = await buildModelRoutes(llm);
1133
+ res.writeHead(200, JSON_HEADERS);
1134
+ res.end(JSON.stringify({ routes }));
1135
+ } catch (error) {
1136
+ res.writeHead(500, JSON_HEADERS);
1137
+ res.end(JSON.stringify({ routes: [], error: String(error) }));
1138
+ }
1123
1139
  }
1124
1140
  });
1125
1141
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-core-demo",
3
- "version": "0.35.11",
3
+ "version": "0.35.13",
4
4
  "description": "The shared UI foundation for DSH plugins, with a live component preview: design tokens, common controls, workspace browsing and notifications maintained in one place — install it to preview every component in a real host.",
5
5
  "icon": "./assets/icon-components.svg",
6
6
  "keywords": [