@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/runtime/client.js
CHANGED
|
@@ -118,7 +118,7 @@ import { nanoid } from "nanoid";
|
|
|
118
118
|
var RPC_CIRCULAR_VALUE = "[Circular]";
|
|
119
119
|
var RPC_UNREADABLE_VALUE = "[Unreadable]";
|
|
120
120
|
function toRpcSafeValue(value) {
|
|
121
|
-
return toRpcSafeChildValue(value,
|
|
121
|
+
return toRpcSafeChildValue(value, createRpcSafeContext(), false);
|
|
122
122
|
}
|
|
123
123
|
function safeStringify(value) {
|
|
124
124
|
if (typeof value === "string") {
|
|
@@ -127,7 +127,13 @@ function safeStringify(value) {
|
|
|
127
127
|
const safeValue = toRpcSafeValue(value);
|
|
128
128
|
return safeValue === void 0 ? "undefined" : JSON.stringify(safeValue);
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function createRpcSafeContext() {
|
|
131
|
+
return {
|
|
132
|
+
cache: /* @__PURE__ */ new WeakMap(),
|
|
133
|
+
seen: /* @__PURE__ */ new WeakSet()
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function toRpcSafeChildValue(value, context, arrayItem) {
|
|
131
137
|
if (value === null) {
|
|
132
138
|
return null;
|
|
133
139
|
}
|
|
@@ -145,35 +151,41 @@ function toRpcSafeChildValue(value, seen, arrayItem) {
|
|
|
145
151
|
case "function":
|
|
146
152
|
return arrayItem ? null : void 0;
|
|
147
153
|
case "object":
|
|
148
|
-
return toRpcSafeObject(value,
|
|
154
|
+
return toRpcSafeObject(value, context);
|
|
149
155
|
default:
|
|
150
156
|
return arrayItem ? null : void 0;
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
|
-
function toRpcSafeObject(value,
|
|
154
|
-
if (seen.has(value)) {
|
|
159
|
+
function toRpcSafeObject(value, context) {
|
|
160
|
+
if (context.seen.has(value)) {
|
|
155
161
|
return RPC_CIRCULAR_VALUE;
|
|
156
162
|
}
|
|
157
|
-
|
|
163
|
+
const cached = context.cache.get(value);
|
|
164
|
+
if (cached) {
|
|
165
|
+
return cached;
|
|
166
|
+
}
|
|
167
|
+
context.seen.add(value);
|
|
158
168
|
try {
|
|
169
|
+
let safeValue;
|
|
159
170
|
if (value instanceof Date) {
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
171
|
+
safeValue = toSafeDate(value);
|
|
172
|
+
} else if (value instanceof Error) {
|
|
173
|
+
safeValue = toSafeError(value, context);
|
|
174
|
+
} else if (Array.isArray(value)) {
|
|
175
|
+
safeValue = toSafeArray(value, context);
|
|
176
|
+
} else {
|
|
177
|
+
safeValue = toSafeRecord(value, context);
|
|
167
178
|
}
|
|
168
|
-
|
|
179
|
+
context.cache.set(value, safeValue);
|
|
180
|
+
return safeValue;
|
|
169
181
|
} finally {
|
|
170
|
-
seen.delete(value);
|
|
182
|
+
context.seen.delete(value);
|
|
171
183
|
}
|
|
172
184
|
}
|
|
173
|
-
function toSafeArray(values,
|
|
174
|
-
return values.map((item) => toRpcSafeChildValue(item,
|
|
185
|
+
function toSafeArray(values, context) {
|
|
186
|
+
return values.map((item) => toRpcSafeChildValue(item, context, true) ?? null);
|
|
175
187
|
}
|
|
176
|
-
function toSafeRecord(value,
|
|
188
|
+
function toSafeRecord(value, context) {
|
|
177
189
|
const keys = getEnumerableKeys(value);
|
|
178
190
|
if (!keys) {
|
|
179
191
|
return RPC_UNREADABLE_VALUE;
|
|
@@ -191,14 +203,14 @@ function toSafeRecord(value, seen) {
|
|
|
191
203
|
result[key] = RPC_UNREADABLE_VALUE;
|
|
192
204
|
return;
|
|
193
205
|
}
|
|
194
|
-
const safeValue = toRpcSafeChildValue(field.value,
|
|
206
|
+
const safeValue = toRpcSafeChildValue(field.value, context, false);
|
|
195
207
|
if (safeValue !== void 0) {
|
|
196
208
|
result[key] = safeValue;
|
|
197
209
|
}
|
|
198
210
|
});
|
|
199
211
|
return result;
|
|
200
212
|
}
|
|
201
|
-
function toSafeError(error,
|
|
213
|
+
function toSafeError(error, context) {
|
|
202
214
|
const result = {
|
|
203
215
|
name: error.name,
|
|
204
216
|
message: error.message
|
|
@@ -209,7 +221,7 @@ function toSafeError(error, seen) {
|
|
|
209
221
|
}
|
|
210
222
|
if ("cause" in error) {
|
|
211
223
|
const cause = readObjectField(error, "cause");
|
|
212
|
-
result.cause = cause.ok ? toRpcSafeChildValue(cause.value,
|
|
224
|
+
result.cause = cause.ok ? toRpcSafeChildValue(cause.value, context, false) ?? null : RPC_UNREADABLE_VALUE;
|
|
213
225
|
}
|
|
214
226
|
return result;
|
|
215
227
|
}
|