@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.cjs
CHANGED
|
@@ -145,7 +145,7 @@ var import_nanoid = require("nanoid");
|
|
|
145
145
|
var RPC_CIRCULAR_VALUE = "[Circular]";
|
|
146
146
|
var RPC_UNREADABLE_VALUE = "[Unreadable]";
|
|
147
147
|
function toRpcSafeValue(value) {
|
|
148
|
-
return toRpcSafeChildValue(value,
|
|
148
|
+
return toRpcSafeChildValue(value, createRpcSafeContext(), false);
|
|
149
149
|
}
|
|
150
150
|
function safeStringify(value) {
|
|
151
151
|
if (typeof value === "string") {
|
|
@@ -154,7 +154,13 @@ function safeStringify(value) {
|
|
|
154
154
|
const safeValue = toRpcSafeValue(value);
|
|
155
155
|
return safeValue === void 0 ? "undefined" : JSON.stringify(safeValue);
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function createRpcSafeContext() {
|
|
158
|
+
return {
|
|
159
|
+
cache: /* @__PURE__ */ new WeakMap(),
|
|
160
|
+
seen: /* @__PURE__ */ new WeakSet()
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function toRpcSafeChildValue(value, context, arrayItem) {
|
|
158
164
|
if (value === null) {
|
|
159
165
|
return null;
|
|
160
166
|
}
|
|
@@ -172,35 +178,41 @@ function toRpcSafeChildValue(value, seen, arrayItem) {
|
|
|
172
178
|
case "function":
|
|
173
179
|
return arrayItem ? null : void 0;
|
|
174
180
|
case "object":
|
|
175
|
-
return toRpcSafeObject(value,
|
|
181
|
+
return toRpcSafeObject(value, context);
|
|
176
182
|
default:
|
|
177
183
|
return arrayItem ? null : void 0;
|
|
178
184
|
}
|
|
179
185
|
}
|
|
180
|
-
function toRpcSafeObject(value,
|
|
181
|
-
if (seen.has(value)) {
|
|
186
|
+
function toRpcSafeObject(value, context) {
|
|
187
|
+
if (context.seen.has(value)) {
|
|
182
188
|
return RPC_CIRCULAR_VALUE;
|
|
183
189
|
}
|
|
184
|
-
|
|
190
|
+
const cached = context.cache.get(value);
|
|
191
|
+
if (cached) {
|
|
192
|
+
return cached;
|
|
193
|
+
}
|
|
194
|
+
context.seen.add(value);
|
|
185
195
|
try {
|
|
196
|
+
let safeValue;
|
|
186
197
|
if (value instanceof Date) {
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
198
|
+
safeValue = toSafeDate(value);
|
|
199
|
+
} else if (value instanceof Error) {
|
|
200
|
+
safeValue = toSafeError(value, context);
|
|
201
|
+
} else if (Array.isArray(value)) {
|
|
202
|
+
safeValue = toSafeArray(value, context);
|
|
203
|
+
} else {
|
|
204
|
+
safeValue = toSafeRecord(value, context);
|
|
194
205
|
}
|
|
195
|
-
|
|
206
|
+
context.cache.set(value, safeValue);
|
|
207
|
+
return safeValue;
|
|
196
208
|
} finally {
|
|
197
|
-
seen.delete(value);
|
|
209
|
+
context.seen.delete(value);
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
|
-
function toSafeArray(values,
|
|
201
|
-
return values.map((item) => toRpcSafeChildValue(item,
|
|
212
|
+
function toSafeArray(values, context) {
|
|
213
|
+
return values.map((item) => toRpcSafeChildValue(item, context, true) ?? null);
|
|
202
214
|
}
|
|
203
|
-
function toSafeRecord(value,
|
|
215
|
+
function toSafeRecord(value, context) {
|
|
204
216
|
const keys = getEnumerableKeys(value);
|
|
205
217
|
if (!keys) {
|
|
206
218
|
return RPC_UNREADABLE_VALUE;
|
|
@@ -218,14 +230,14 @@ function toSafeRecord(value, seen) {
|
|
|
218
230
|
result[key] = RPC_UNREADABLE_VALUE;
|
|
219
231
|
return;
|
|
220
232
|
}
|
|
221
|
-
const safeValue = toRpcSafeChildValue(field.value,
|
|
233
|
+
const safeValue = toRpcSafeChildValue(field.value, context, false);
|
|
222
234
|
if (safeValue !== void 0) {
|
|
223
235
|
result[key] = safeValue;
|
|
224
236
|
}
|
|
225
237
|
});
|
|
226
238
|
return result;
|
|
227
239
|
}
|
|
228
|
-
function toSafeError(error,
|
|
240
|
+
function toSafeError(error, context) {
|
|
229
241
|
const result = {
|
|
230
242
|
name: error.name,
|
|
231
243
|
message: error.message
|
|
@@ -236,7 +248,7 @@ function toSafeError(error, seen) {
|
|
|
236
248
|
}
|
|
237
249
|
if ("cause" in error) {
|
|
238
250
|
const cause = readObjectField(error, "cause");
|
|
239
|
-
result.cause = cause.ok ? toRpcSafeChildValue(cause.value,
|
|
251
|
+
result.cause = cause.ok ? toRpcSafeChildValue(cause.value, context, false) ?? null : RPC_UNREADABLE_VALUE;
|
|
240
252
|
}
|
|
241
253
|
return result;
|
|
242
254
|
}
|