@yuhere/js-jsonrpc2 2.1.14 → 2.1.16

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.
@@ -9204,7 +9204,8 @@ var KIND_COLORS$1 = {
9204
9204
  enum: "var(--syn-union)",
9205
9205
  unknown: "var(--syn-muted)",
9206
9206
  null: "var(--syn-muted)",
9207
- stream: "var(--syn-container)"
9207
+ stream: "var(--syn-container)",
9208
+ void: "var(--syn-muted)"
9208
9209
  };
9209
9210
  function colorOf$1(kind) {
9210
9211
  return KIND_COLORS$1[kind] ?? "var(--fg)";
@@ -9214,21 +9215,37 @@ function formatConstraints$1(constraints) {
9214
9215
  if (!constraints) return "";
9215
9216
  const entries = Object.entries(constraints).filter(([, v]) => v !== void 0);
9216
9217
  if (entries.length === 0) return "";
9217
- return entries.map(([k, v]) => `${k}=${typeof v === "string" ? JSON.stringify(v) : JSON.stringify(v)}`).join(", ");
9218
+ return entries.map(([k, v]) => `${k}=${JSON.stringify(v)}`).join(", ");
9219
+ }
9220
+ function isSchemaDescription(v) {
9221
+ return !!v && typeof v === "object" && typeof v.kind === "string";
9222
+ }
9223
+ function hasChildNodes(schema) {
9224
+ switch (schema.kind) {
9225
+ case "array": return isSchemaDescription(schema.element);
9226
+ case "record": return isSchemaDescription(schema.value);
9227
+ case "tuple": return Array.isArray(schema.elements) && schema.elements.some(isSchemaDescription);
9228
+ case "union": return Array.isArray(schema.options) && schema.options.some(isSchemaDescription);
9229
+ case "object": return !!schema.properties && typeof schema.properties === "object" && !Array.isArray(schema.properties) && Object.values(schema.properties).some(isSchemaDescription);
9230
+ case "stream": return !!(isSchemaDescription(schema.inner) ? schema.inner : void 0);
9231
+ default: return false;
9232
+ }
9218
9233
  }
9219
9234
  function SchemaNode({ schema, depth, defaultOpen, label }) {
9220
9235
  const t = useT();
9221
9236
  const [open, setOpen] = (0, import_react.useState)(defaultOpen);
9222
- const hasChildren = hasChildNodes(schema);
9237
+ const anySchema = schema;
9238
+ const expandable = hasChildNodes(anySchema);
9223
9239
  const constraintsText = formatConstraints$1(schema.constraints);
9240
+ const validationOff = anySchema.validate === false;
9224
9241
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9225
9242
  className: "schema-node",
9226
9243
  style: { paddingLeft: depth * 14 },
9227
9244
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
9228
9245
  className: "schema-head",
9229
- onClick: () => hasChildren && setOpen((o) => !o),
9246
+ onClick: () => expandable && setOpen((o) => !o),
9230
9247
  children: [
9231
- hasChildren ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
9248
+ expandable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
9232
9249
  className: "schema-expander",
9233
9250
  children: open ? "▾" : "▸"
9234
9251
  }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "schema-expander" }),
@@ -9249,77 +9266,52 @@ function SchemaNode({ schema, depth, defaultOpen, label }) {
9249
9266
  className: "schema-nullable-badge",
9250
9267
  children: "nullable"
9251
9268
  }),
9252
- constraintsText && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
9269
+ validationOff && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
9270
+ className: "schema-nullable-badge",
9271
+ title: t("schema.validationOff"),
9272
+ children: "no-validate"
9273
+ }),
9274
+ constraintsText ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
9253
9275
  className: "schema-constraints",
9254
9276
  children: `{ ${constraintsText} }`
9255
- }),
9256
- schema.description && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
9277
+ }) : null,
9278
+ schema.description ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
9257
9279
  className: "schema-description",
9258
- title: schema.description,
9259
- children: [
9260
- " ",
9261
- "// ",
9262
- schema.description
9263
- ]
9264
- })
9280
+ children: ["— ", schema.description]
9281
+ }) : null
9265
9282
  ]
9266
- }), open && hasChildren && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
9283
+ }), expandable && open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
9267
9284
  className: "schema-children",
9268
- children: renderChildren(schema, depth + 1, t)
9285
+ children: renderChildren(anySchema, depth + 1, t)
9269
9286
  })]
9270
9287
  });
9271
9288
  }
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
- }
9289
+ /**
9290
+ * 子节点渲染约定:
9291
+ * - array / record / stream:直接展开,不挂 element / value / inner 标签
9292
+ * - object:属性名作标签
9293
+ * - union:option[i]
9294
+ * - tuple:[i]
9295
+ */
9299
9296
  function renderChildren(schema, depth, t) {
9300
9297
  const out = [];
9301
9298
  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,
9299
+ case "array":
9300
+ if (isSchemaDescription(schema.element)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
9301
+ schema: schema.element,
9306
9302
  depth,
9307
9303
  defaultOpen: true
9308
9304
  }, "element"));
9309
9305
  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,
9306
+ case "record":
9307
+ if (isSchemaDescription(schema.value)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
9308
+ schema: schema.value,
9315
9309
  depth,
9316
9310
  defaultOpen: true
9317
9311
  }, "value"));
9318
9312
  break;
9319
- }
9320
- case "tuple": {
9321
- const elements = schema.elements;
9322
- if (Array.isArray(elements)) elements.forEach((item, i) => {
9313
+ case "tuple":
9314
+ if (Array.isArray(schema.elements)) schema.elements.forEach((item, i) => {
9323
9315
  if (isSchemaDescription(item)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
9324
9316
  schema: item,
9325
9317
  depth,
@@ -9328,10 +9320,8 @@ function renderChildren(schema, depth, t) {
9328
9320
  }, `el-${i}`));
9329
9321
  });
9330
9322
  break;
9331
- }
9332
- case "union": {
9333
- const options = schema.options;
9334
- if (Array.isArray(options)) options.forEach((opt, i) => {
9323
+ case "union":
9324
+ if (Array.isArray(schema.options)) schema.options.forEach((opt, i) => {
9335
9325
  if (isSchemaDescription(opt)) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
9336
9326
  schema: opt,
9337
9327
  depth,
@@ -9340,7 +9330,6 @@ function renderChildren(schema, depth, t) {
9340
9330
  }, `opt-${i}`));
9341
9331
  });
9342
9332
  break;
9343
- }
9344
9333
  case "object": {
9345
9334
  const props = schema.properties;
9346
9335
  if (props && typeof props === "object" && !Array.isArray(props)) {
@@ -9354,8 +9343,7 @@ function renderChildren(schema, depth, t) {
9354
9343
  break;
9355
9344
  }
9356
9345
  case "stream": {
9357
- const any = schema;
9358
- const inner = isSchemaDescription(any.inner) ? any.inner : isSchemaDescription(any.children?.inner) ? any.children.inner : void 0;
9346
+ const inner = isSchemaDescription(schema.inner) ? schema.inner : void 0;
9359
9347
  if (inner) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaNode, {
9360
9348
  schema: inner,
9361
9349
  depth,
@@ -10685,7 +10673,7 @@ function Footer() {
10685
10673
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
10686
10674
  className: "footer-version",
10687
10675
  title: t("footer.version"),
10688
- children: ["v", "2.1.14"]
10676
+ children: ["v", "2.1.16"]
10689
10677
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
10690
10678
  className: "footer-links",
10691
10679
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
@@ -10797,12 +10785,14 @@ async function collectApiDoc(rpc, methods, onProgress) {
10797
10785
  * - object:属性名作标签
10798
10786
  * - union:option[i]
10799
10787
  * - tuple:[i]
10788
+ * - validate === false 时在行尾标注 _(no validate)_
10800
10789
  */
10801
10790
  function renderSchemaTree(schema, indent = 0) {
10802
10791
  const pad = " ".repeat(indent);
10803
10792
  const lines = [];
10804
10793
  let head = `${pad}- \`${schema.kind}\``;
10805
10794
  if (schema.nullable) head += " _(nullable)_";
10795
+ if (schema.validate === false) head += " _(no validate)_";
10806
10796
  if (schema.description) head += ` — ${schema.description}`;
10807
10797
  const c = schema.constraints;
10808
10798
  if (c && Object.keys(c).length > 0) {
@@ -10856,7 +10846,7 @@ function renderSchemaTree(schema, indent = 0) {
10856
10846
  }
10857
10847
  case "stream": {
10858
10848
  const any = schema;
10859
- const inner = isSchema(any.inner) ? any.inner : isSchema(any.children?.inner) ? any.children.inner : void 0;
10849
+ const inner = isSchema(any.inner) ? any.inner : void 0;
10860
10850
  if (inner) pushPlain(inner);
10861
10851
  break;
10862
10852
  }
@@ -11101,4 +11091,4 @@ function App() {
11101
11091
  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, {}) }) }) }));
11102
11092
  //#endregion
11103
11093
 
11104
- //# sourceMappingURL=index-mYqtDOwe.js.map
11094
+ //# sourceMappingURL=index-C2Pf9oxO.js.map