@yuhere/js-jsonrpc2 2.1.13 → 2.1.14
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/core/llm-tools.js +41 -42
- package/dist/schema/json/index.d.ts +1 -1
- package/dist/schema/json/primitives.d.ts +49 -69
- package/dist/schema/json/primitives.js +70 -76
- package/dist/schema/z/protocol.d.ts +1 -1
- package/htdoc/assets/{index-CqI7vRAS.js → index-mYqtDOwe.js} +160 -78
- package/htdoc/assets/index-mYqtDOwe.js.map +1 -0
- package/htdoc/index.html +1 -1
- package/package.json +1 -1
- package/htdoc/assets/index-CqI7vRAS.js.map +0 -1
|
@@ -9219,7 +9219,7 @@ function formatConstraints$1(constraints) {
|
|
|
9219
9219
|
function SchemaNode({ schema, depth, defaultOpen, label }) {
|
|
9220
9220
|
const t = useT();
|
|
9221
9221
|
const [open, setOpen] = (0, import_react.useState)(defaultOpen);
|
|
9222
|
-
const hasChildren =
|
|
9222
|
+
const hasChildren = hasChildNodes(schema);
|
|
9223
9223
|
const constraintsText = formatConstraints$1(schema.constraints);
|
|
9224
9224
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
9225
9225
|
className: "schema-node",
|
|
@@ -9269,56 +9269,103 @@ function SchemaNode({ schema, depth, defaultOpen, label }) {
|
|
|
9269
9269
|
})]
|
|
9270
9270
|
});
|
|
9271
9271
|
}
|
|
9272
|
+
function isSchemaDescription(v) {
|
|
9273
|
+
return !!v && typeof v === "object" && typeof v.kind === "string";
|
|
9274
|
+
}
|
|
9275
|
+
/** 是否存在可展开的子节点(新结构 + stream 的兼容路径) */
|
|
9276
|
+
function hasChildNodes(schema) {
|
|
9277
|
+
switch (schema.kind) {
|
|
9278
|
+
case "array": return isSchemaDescription(schema.element);
|
|
9279
|
+
case "record": return isSchemaDescription(schema.value);
|
|
9280
|
+
case "tuple": {
|
|
9281
|
+
const els = schema.elements;
|
|
9282
|
+
return Array.isArray(els) && els.some(isSchemaDescription);
|
|
9283
|
+
}
|
|
9284
|
+
case "union": {
|
|
9285
|
+
const opts = schema.options;
|
|
9286
|
+
return Array.isArray(opts) && opts.some(isSchemaDescription);
|
|
9287
|
+
}
|
|
9288
|
+
case "object": {
|
|
9289
|
+
const props = schema.properties;
|
|
9290
|
+
return !!props && typeof props === "object" && !Array.isArray(props) && Object.keys(props).length > 0;
|
|
9291
|
+
}
|
|
9292
|
+
case "stream": {
|
|
9293
|
+
const any = schema;
|
|
9294
|
+
return isSchemaDescription(any.inner) || isSchemaDescription(any.children?.inner);
|
|
9295
|
+
}
|
|
9296
|
+
default: return false;
|
|
9297
|
+
}
|
|
9298
|
+
}
|
|
9272
9299
|
function renderChildren(schema, depth, t) {
|
|
9273
|
-
const c = schema.children ?? {};
|
|
9274
9300
|
const out = [];
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9301
|
+
switch (schema.kind) {
|
|
9302
|
+
case "array": {
|
|
9303
|
+
const element = schema.element;
|
|
9304
|
+
if (isSchemaDescription(element)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
|
|
9305
|
+
schema: element,
|
|
9306
|
+
depth,
|
|
9307
|
+
defaultOpen: true
|
|
9308
|
+
}, "element"));
|
|
9309
|
+
break;
|
|
9310
|
+
}
|
|
9311
|
+
case "record": {
|
|
9312
|
+
const value = schema.value;
|
|
9313
|
+
if (isSchemaDescription(value)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
|
|
9314
|
+
schema: value,
|
|
9315
|
+
depth,
|
|
9316
|
+
defaultOpen: true
|
|
9317
|
+
}, "value"));
|
|
9318
|
+
break;
|
|
9319
|
+
}
|
|
9320
|
+
case "tuple": {
|
|
9321
|
+
const elements = schema.elements;
|
|
9322
|
+
if (Array.isArray(elements)) elements.forEach((item, i) => {
|
|
9323
|
+
if (isSchemaDescription(item)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
|
|
9324
|
+
schema: item,
|
|
9325
|
+
depth,
|
|
9326
|
+
defaultOpen: true,
|
|
9327
|
+
label: String(i)
|
|
9328
|
+
}, `el-${i}`));
|
|
9329
|
+
});
|
|
9330
|
+
break;
|
|
9331
|
+
}
|
|
9332
|
+
case "union": {
|
|
9333
|
+
const options = schema.options;
|
|
9334
|
+
if (Array.isArray(options)) options.forEach((opt, i) => {
|
|
9335
|
+
if (isSchemaDescription(opt)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
|
|
9336
|
+
schema: opt,
|
|
9337
|
+
depth,
|
|
9338
|
+
defaultOpen: false,
|
|
9339
|
+
label: t("schema.optionIndex", { index: i })
|
|
9340
|
+
}, `opt-${i}`));
|
|
9341
|
+
});
|
|
9342
|
+
break;
|
|
9343
|
+
}
|
|
9344
|
+
case "object": {
|
|
9345
|
+
const props = schema.properties;
|
|
9346
|
+
if (props && typeof props === "object" && !Array.isArray(props)) {
|
|
9347
|
+
for (const [key, prop] of Object.entries(props)) if (isSchemaDescription(prop)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
|
|
9348
|
+
schema: prop,
|
|
9349
|
+
depth,
|
|
9350
|
+
defaultOpen: true,
|
|
9351
|
+
label: key
|
|
9352
|
+
}, `prop-${key}`));
|
|
9353
|
+
}
|
|
9354
|
+
break;
|
|
9355
|
+
}
|
|
9356
|
+
case "stream": {
|
|
9357
|
+
const any = schema;
|
|
9358
|
+
const inner = isSchemaDescription(any.inner) ? any.inner : isSchemaDescription(any.children?.inner) ? any.children.inner : void 0;
|
|
9359
|
+
if (inner) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
|
|
9360
|
+
schema: inner,
|
|
9361
|
+
depth,
|
|
9362
|
+
defaultOpen: true
|
|
9363
|
+
}, "inner"));
|
|
9364
|
+
break;
|
|
9365
|
+
}
|
|
9310
9366
|
}
|
|
9311
|
-
if (c.values && isSchemaDescription(c.values)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
|
|
9312
|
-
schema: c.values,
|
|
9313
|
-
depth,
|
|
9314
|
-
defaultOpen: true,
|
|
9315
|
-
label: t("schema.values")
|
|
9316
|
-
}, "values"));
|
|
9317
9367
|
return out;
|
|
9318
9368
|
}
|
|
9319
|
-
function isSchemaDescription(v) {
|
|
9320
|
-
return !!v && typeof v === "object" && typeof v.kind === "string";
|
|
9321
|
-
}
|
|
9322
9369
|
function SchemaView({ schema, defaultOpen = true, depth = 0 }) {
|
|
9323
9370
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
|
|
9324
9371
|
schema,
|
|
@@ -9387,12 +9434,11 @@ function isSchema$1(v) {
|
|
|
9387
9434
|
* - 原始类型返回零值(''、0、false)
|
|
9388
9435
|
* - literal 返回固定值
|
|
9389
9436
|
* - enum 返回第一个枚举值
|
|
9390
|
-
* -
|
|
9437
|
+
* - 容器类型递归展开(按新字段:element / value / properties / options / elements)
|
|
9391
9438
|
* - unknown 返回 null
|
|
9392
9439
|
*/
|
|
9393
9440
|
function sampleFromSchema(schema) {
|
|
9394
9441
|
if (schema.nullable) return null;
|
|
9395
|
-
const c = schema.children ?? {};
|
|
9396
9442
|
switch (schema.kind) {
|
|
9397
9443
|
case "string": return "";
|
|
9398
9444
|
case "number": return 0;
|
|
@@ -9403,19 +9449,19 @@ function sampleFromSchema(schema) {
|
|
|
9403
9449
|
const values = schema.constraints?.values;
|
|
9404
9450
|
return Array.isArray(values) && values.length > 0 ? values[0] : "";
|
|
9405
9451
|
}
|
|
9406
|
-
case "array": return [isSchema$1(
|
|
9407
|
-
case "tuple": return (Array.isArray(
|
|
9452
|
+
case "array": return [isSchema$1(schema.element) ? sampleFromSchema(schema.element) : null];
|
|
9453
|
+
case "tuple": return (Array.isArray(schema.elements) ? schema.elements : []).map((it) => isSchema$1(it) ? sampleFromSchema(it) : null);
|
|
9408
9454
|
case "union": {
|
|
9409
|
-
const options = Array.isArray(
|
|
9455
|
+
const options = Array.isArray(schema.options) ? schema.options : [];
|
|
9410
9456
|
return options.length > 0 && isSchema$1(options[0]) ? sampleFromSchema(options[0]) : null;
|
|
9411
9457
|
}
|
|
9412
9458
|
case "object": {
|
|
9413
|
-
const props =
|
|
9459
|
+
const props = schema.properties ?? {};
|
|
9414
9460
|
const out = {};
|
|
9415
9461
|
for (const [k, v] of Object.entries(props)) if (isSchema$1(v)) out[k] = sampleFromSchema(v);
|
|
9416
9462
|
return out;
|
|
9417
9463
|
}
|
|
9418
|
-
case "record": return { key: isSchema$1(
|
|
9464
|
+
case "record": return { key: isSchema$1(schema.value) ? sampleFromSchema(schema.value) : null };
|
|
9419
9465
|
default: return null;
|
|
9420
9466
|
}
|
|
9421
9467
|
}
|
|
@@ -9558,7 +9604,7 @@ function SchemaField({ schema, value, onChange, label, depth = 0, defaultOpen =
|
|
|
9558
9604
|
})]
|
|
9559
9605
|
});
|
|
9560
9606
|
if (kind === "union") {
|
|
9561
|
-
const options = Array.isArray(schema.
|
|
9607
|
+
const options = Array.isArray(schema.options) ? schema.options.filter(isSchema$1) : [];
|
|
9562
9608
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
9563
9609
|
className: "sf-node sf-row",
|
|
9564
9610
|
style: { paddingLeft: depth * 14 },
|
|
@@ -9744,9 +9790,8 @@ function UnionField({ options, value, onChange, depth, disabled }) {
|
|
|
9744
9790
|
}
|
|
9745
9791
|
function ContainerChildren({ schema, value, onChange, depth, disabled }) {
|
|
9746
9792
|
const t = useT();
|
|
9747
|
-
const c = schema.children ?? {};
|
|
9748
9793
|
if (schema.kind === "array") {
|
|
9749
|
-
const itemSchema = isSchema$1(
|
|
9794
|
+
const itemSchema = isSchema$1(schema.element) ? schema.element : void 0;
|
|
9750
9795
|
if (!itemSchema) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
9751
9796
|
className: "hint",
|
|
9752
9797
|
children: t("schema.arrayNoItem")
|
|
@@ -9782,7 +9827,7 @@ function ContainerChildren({ schema, value, onChange, depth, disabled }) {
|
|
|
9782
9827
|
})] });
|
|
9783
9828
|
}
|
|
9784
9829
|
if (schema.kind === "tuple") {
|
|
9785
|
-
const items = Array.isArray(
|
|
9830
|
+
const items = Array.isArray(schema.elements) ? schema.elements.filter(isSchema$1) : [];
|
|
9786
9831
|
const arr = Array.isArray(value) ? value : [];
|
|
9787
9832
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: items.map((itemSchema, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaField, {
|
|
9788
9833
|
schema: itemSchema,
|
|
@@ -9799,9 +9844,9 @@ function ContainerChildren({ schema, value, onChange, depth, disabled }) {
|
|
|
9799
9844
|
}, i)) });
|
|
9800
9845
|
}
|
|
9801
9846
|
if (schema.kind === "object") {
|
|
9802
|
-
const props =
|
|
9847
|
+
const props = schema.properties ?? {};
|
|
9803
9848
|
const obj = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
9804
|
-
const
|
|
9849
|
+
const allowUnknown = schema.constraints?.allowUnknownProps !== false;
|
|
9805
9850
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [Object.entries(props).map(([key, prop]) => {
|
|
9806
9851
|
if (!isSchema$1(prop)) return null;
|
|
9807
9852
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaField, {
|
|
@@ -9818,7 +9863,7 @@ function ContainerChildren({ schema, value, onChange, depth, disabled }) {
|
|
|
9818
9863
|
disabled,
|
|
9819
9864
|
defaultOpen: false
|
|
9820
9865
|
}, key);
|
|
9821
|
-
}),
|
|
9866
|
+
}), allowUnknown && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
9822
9867
|
className: "hint",
|
|
9823
9868
|
style: {
|
|
9824
9869
|
paddingLeft: depth * 14,
|
|
@@ -9828,7 +9873,7 @@ function ContainerChildren({ schema, value, onChange, depth, disabled }) {
|
|
|
9828
9873
|
})] });
|
|
9829
9874
|
}
|
|
9830
9875
|
if (schema.kind === "record") {
|
|
9831
|
-
const valueSchema = isSchema$1(
|
|
9876
|
+
const valueSchema = isSchema$1(schema.value) ? schema.value : void 0;
|
|
9832
9877
|
if (!valueSchema) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
9833
9878
|
className: "hint",
|
|
9834
9879
|
children: t("schema.recordNoValue")
|
|
@@ -10640,7 +10685,7 @@ function Footer() {
|
|
|
10640
10685
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
10641
10686
|
className: "footer-version",
|
|
10642
10687
|
title: t("footer.version"),
|
|
10643
|
-
children: ["v", "2.1.
|
|
10688
|
+
children: ["v", "2.1.14"]
|
|
10644
10689
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
10645
10690
|
className: "footer-links",
|
|
10646
10691
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
|
|
@@ -10746,6 +10791,13 @@ async function collectApiDoc(rpc, methods, onProgress) {
|
|
|
10746
10791
|
methods: out
|
|
10747
10792
|
};
|
|
10748
10793
|
}
|
|
10794
|
+
/**
|
|
10795
|
+
* 树状渲染 schema。
|
|
10796
|
+
* - array / record / stream:直接展开子节点,不挂 element / value / inner 标签
|
|
10797
|
+
* - object:属性名作标签
|
|
10798
|
+
* - union:option[i]
|
|
10799
|
+
* - tuple:[i]
|
|
10800
|
+
*/
|
|
10749
10801
|
function renderSchemaTree(schema, indent = 0) {
|
|
10750
10802
|
const pad = " ".repeat(indent);
|
|
10751
10803
|
const lines = [];
|
|
@@ -10758,26 +10810,57 @@ function renderSchemaTree(schema, indent = 0) {
|
|
|
10758
10810
|
if (parts.length) head += ` \`{ ${parts.join(", ")} }\``;
|
|
10759
10811
|
}
|
|
10760
10812
|
lines.push(head);
|
|
10761
|
-
|
|
10762
|
-
const
|
|
10813
|
+
/** 带标签的子节点(object 属性 / union 分支 / tuple 位) */
|
|
10814
|
+
const pushLabeled = (label, child) => {
|
|
10763
10815
|
const sub = renderSchemaTree(child, indent + 1);
|
|
10764
10816
|
if (sub.length) {
|
|
10765
10817
|
sub[0] = `${" ".repeat(indent + 1)}- **${label}**: ${sub[0].trim().replace(/^- /, "")}`;
|
|
10766
10818
|
lines.push(...sub);
|
|
10767
10819
|
}
|
|
10768
10820
|
};
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
}
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10821
|
+
/** 无标签,直接展开(array element / record value / stream inner) */
|
|
10822
|
+
const pushPlain = (child) => {
|
|
10823
|
+
lines.push(...renderSchemaTree(child, indent + 1));
|
|
10824
|
+
};
|
|
10825
|
+
switch (schema.kind) {
|
|
10826
|
+
case "array": {
|
|
10827
|
+
const element = schema.element;
|
|
10828
|
+
if (isSchema(element)) pushPlain(element);
|
|
10829
|
+
break;
|
|
10830
|
+
}
|
|
10831
|
+
case "record": {
|
|
10832
|
+
const value = schema.value;
|
|
10833
|
+
if (isSchema(value)) pushPlain(value);
|
|
10834
|
+
break;
|
|
10835
|
+
}
|
|
10836
|
+
case "tuple": {
|
|
10837
|
+
const elements = schema.elements;
|
|
10838
|
+
if (Array.isArray(elements)) elements.forEach((it, i) => {
|
|
10839
|
+
if (isSchema(it)) pushLabeled(`[${i}]`, it);
|
|
10840
|
+
});
|
|
10841
|
+
break;
|
|
10842
|
+
}
|
|
10843
|
+
case "union": {
|
|
10844
|
+
const options = schema.options;
|
|
10845
|
+
if (Array.isArray(options)) options.forEach((opt, i) => {
|
|
10846
|
+
if (isSchema(opt)) pushLabeled(`option[${i}]`, opt);
|
|
10847
|
+
});
|
|
10848
|
+
break;
|
|
10849
|
+
}
|
|
10850
|
+
case "object": {
|
|
10851
|
+
const props = schema.properties;
|
|
10852
|
+
if (props && typeof props === "object" && !Array.isArray(props)) {
|
|
10853
|
+
for (const [k, v] of Object.entries(props)) if (isSchema(v)) pushLabeled(k, v);
|
|
10854
|
+
}
|
|
10855
|
+
break;
|
|
10856
|
+
}
|
|
10857
|
+
case "stream": {
|
|
10858
|
+
const any = schema;
|
|
10859
|
+
const inner = isSchema(any.inner) ? any.inner : isSchema(any.children?.inner) ? any.children.inner : void 0;
|
|
10860
|
+
if (inner) pushPlain(inner);
|
|
10861
|
+
break;
|
|
10862
|
+
}
|
|
10779
10863
|
}
|
|
10780
|
-
if (isSchema(ch.values)) pushChild("values", ch.values);
|
|
10781
10864
|
return lines;
|
|
10782
10865
|
}
|
|
10783
10866
|
function renderMarkdown(doc) {
|
|
@@ -10814,7 +10897,7 @@ function renderMarkdown(doc) {
|
|
|
10814
10897
|
const [ret, ...params] = m.signature;
|
|
10815
10898
|
lines.push("**返回类型**");
|
|
10816
10899
|
lines.push("");
|
|
10817
|
-
lines.push(...renderSchemaTree(ret, 0));
|
|
10900
|
+
if (ret) lines.push(...renderSchemaTree(ret, 0));
|
|
10818
10901
|
lines.push("");
|
|
10819
10902
|
lines.push(`**参数**(${params.length} 个)`);
|
|
10820
10903
|
lines.push("");
|
|
@@ -10832,7 +10915,6 @@ function renderMarkdown(doc) {
|
|
|
10832
10915
|
}
|
|
10833
10916
|
return lines.join("\n");
|
|
10834
10917
|
}
|
|
10835
|
-
/** 触发浏览器下载 */
|
|
10836
10918
|
function downloadText(filename, text, mime = "text/plain") {
|
|
10837
10919
|
const blob = new Blob([text], { type: `${mime};charset=utf-8` });
|
|
10838
10920
|
const url = URL.createObjectURL(blob);
|
|
@@ -11019,4 +11101,4 @@ function App() {
|
|
|
11019
11101
|
import_client.createRoot(document.getElementById("root")).render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(I18nProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {}) }) }) }));
|
|
11020
11102
|
//#endregion
|
|
11021
11103
|
|
|
11022
|
-
//# sourceMappingURL=index-
|
|
11104
|
+
//# sourceMappingURL=index-mYqtDOwe.js.map
|