@xiaou66/vite-plugin-vue-mcp-next 1.3.2 → 1.3.3
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/index.cjs +34 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -22
- package/dist/index.js.map +1 -1
- package/dist/runtime/client.cjs +33 -21
- package/dist/runtime/client.cjs.map +1 -1
- package/dist/runtime/client.js +33 -21
- package/dist/runtime/client.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2665,7 +2665,7 @@ import { nanoid as nanoid4 } from "nanoid";
|
|
|
2665
2665
|
var RPC_CIRCULAR_VALUE = "[Circular]";
|
|
2666
2666
|
var RPC_UNREADABLE_VALUE = "[Unreadable]";
|
|
2667
2667
|
function toRpcSafeValue(value) {
|
|
2668
|
-
return toRpcSafeChildValue(value,
|
|
2668
|
+
return toRpcSafeChildValue(value, createRpcSafeContext(), false);
|
|
2669
2669
|
}
|
|
2670
2670
|
function safeStringify(value) {
|
|
2671
2671
|
if (typeof value === "string") {
|
|
@@ -2674,7 +2674,13 @@ function safeStringify(value) {
|
|
|
2674
2674
|
const safeValue = toRpcSafeValue(value);
|
|
2675
2675
|
return safeValue === void 0 ? "undefined" : JSON.stringify(safeValue);
|
|
2676
2676
|
}
|
|
2677
|
-
function
|
|
2677
|
+
function createRpcSafeContext() {
|
|
2678
|
+
return {
|
|
2679
|
+
cache: /* @__PURE__ */ new WeakMap(),
|
|
2680
|
+
seen: /* @__PURE__ */ new WeakSet()
|
|
2681
|
+
};
|
|
2682
|
+
}
|
|
2683
|
+
function toRpcSafeChildValue(value, context, arrayItem) {
|
|
2678
2684
|
if (value === null) {
|
|
2679
2685
|
return null;
|
|
2680
2686
|
}
|
|
@@ -2692,35 +2698,41 @@ function toRpcSafeChildValue(value, seen, arrayItem) {
|
|
|
2692
2698
|
case "function":
|
|
2693
2699
|
return arrayItem ? null : void 0;
|
|
2694
2700
|
case "object":
|
|
2695
|
-
return toRpcSafeObject(value,
|
|
2701
|
+
return toRpcSafeObject(value, context);
|
|
2696
2702
|
default:
|
|
2697
2703
|
return arrayItem ? null : void 0;
|
|
2698
2704
|
}
|
|
2699
2705
|
}
|
|
2700
|
-
function toRpcSafeObject(value,
|
|
2701
|
-
if (seen.has(value)) {
|
|
2706
|
+
function toRpcSafeObject(value, context) {
|
|
2707
|
+
if (context.seen.has(value)) {
|
|
2702
2708
|
return RPC_CIRCULAR_VALUE;
|
|
2703
2709
|
}
|
|
2704
|
-
|
|
2710
|
+
const cached = context.cache.get(value);
|
|
2711
|
+
if (cached) {
|
|
2712
|
+
return cached;
|
|
2713
|
+
}
|
|
2714
|
+
context.seen.add(value);
|
|
2705
2715
|
try {
|
|
2716
|
+
let safeValue;
|
|
2706
2717
|
if (value instanceof Date) {
|
|
2707
|
-
|
|
2708
|
-
}
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
}
|
|
2715
|
-
|
|
2718
|
+
safeValue = toSafeDate(value);
|
|
2719
|
+
} else if (value instanceof Error) {
|
|
2720
|
+
safeValue = toSafeError(value, context);
|
|
2721
|
+
} else if (Array.isArray(value)) {
|
|
2722
|
+
safeValue = toSafeArray(value, context);
|
|
2723
|
+
} else {
|
|
2724
|
+
safeValue = toSafeRecord(value, context);
|
|
2725
|
+
}
|
|
2726
|
+
context.cache.set(value, safeValue);
|
|
2727
|
+
return safeValue;
|
|
2716
2728
|
} finally {
|
|
2717
|
-
seen.delete(value);
|
|
2729
|
+
context.seen.delete(value);
|
|
2718
2730
|
}
|
|
2719
2731
|
}
|
|
2720
|
-
function toSafeArray(values,
|
|
2721
|
-
return values.map((item) => toRpcSafeChildValue(item,
|
|
2732
|
+
function toSafeArray(values, context) {
|
|
2733
|
+
return values.map((item) => toRpcSafeChildValue(item, context, true) ?? null);
|
|
2722
2734
|
}
|
|
2723
|
-
function toSafeRecord(value,
|
|
2735
|
+
function toSafeRecord(value, context) {
|
|
2724
2736
|
const keys = getEnumerableKeys(value);
|
|
2725
2737
|
if (!keys) {
|
|
2726
2738
|
return RPC_UNREADABLE_VALUE;
|
|
@@ -2738,14 +2750,14 @@ function toSafeRecord(value, seen) {
|
|
|
2738
2750
|
result[key] = RPC_UNREADABLE_VALUE;
|
|
2739
2751
|
return;
|
|
2740
2752
|
}
|
|
2741
|
-
const safeValue = toRpcSafeChildValue(field.value,
|
|
2753
|
+
const safeValue = toRpcSafeChildValue(field.value, context, false);
|
|
2742
2754
|
if (safeValue !== void 0) {
|
|
2743
2755
|
result[key] = safeValue;
|
|
2744
2756
|
}
|
|
2745
2757
|
});
|
|
2746
2758
|
return result;
|
|
2747
2759
|
}
|
|
2748
|
-
function toSafeError(error,
|
|
2760
|
+
function toSafeError(error, context) {
|
|
2749
2761
|
const result = {
|
|
2750
2762
|
name: error.name,
|
|
2751
2763
|
message: error.message
|
|
@@ -2756,7 +2768,7 @@ function toSafeError(error, seen) {
|
|
|
2756
2768
|
}
|
|
2757
2769
|
if ("cause" in error) {
|
|
2758
2770
|
const cause = readObjectField(error, "cause");
|
|
2759
|
-
result.cause = cause.ok ? toRpcSafeChildValue(cause.value,
|
|
2771
|
+
result.cause = cause.ok ? toRpcSafeChildValue(cause.value, context, false) ?? null : RPC_UNREADABLE_VALUE;
|
|
2760
2772
|
}
|
|
2761
2773
|
return result;
|
|
2762
2774
|
}
|