@xiaou66/vite-plugin-vue-mcp-next 1.3.2 → 1.3.4
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/README.md +1 -1
- package/dist/index.cjs +17 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -133
- package/dist/index.js.map +1 -1
- package/dist/runtime/client.cjs +36 -177
- package/dist/runtime/client.cjs.map +1 -1
- package/dist/runtime/client.d.cts +1 -1
- package/dist/runtime/client.d.ts +1 -1
- package/dist/runtime/client.js +37 -177
- package/dist/runtime/client.js.map +1 -1
- package/dist/{types-DAx3jHdz.d.cts → types-BKXdHkwk.d.cts} +2 -2
- package/dist/{types-DAx3jHdz.d.ts → types-BKXdHkwk.d.ts} +2 -2
- package/package.json +1 -1
package/dist/runtime/client.cjs
CHANGED
|
@@ -142,141 +142,25 @@ var DEFAULT_OPTIONS = {
|
|
|
142
142
|
var import_nanoid = require("nanoid");
|
|
143
143
|
|
|
144
144
|
// src/shared/serialization.ts
|
|
145
|
-
var RPC_CIRCULAR_VALUE = "[Circular]";
|
|
146
|
-
var RPC_UNREADABLE_VALUE = "[Unreadable]";
|
|
147
|
-
function toRpcSafeValue(value) {
|
|
148
|
-
return toRpcSafeChildValue(value, /* @__PURE__ */ new WeakSet(), false);
|
|
149
|
-
}
|
|
150
145
|
function safeStringify(value) {
|
|
151
146
|
if (typeof value === "string") {
|
|
152
147
|
return value;
|
|
153
148
|
}
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return Number.isFinite(value) ? value : String(value);
|
|
167
|
-
case "bigint":
|
|
168
|
-
return value.toString();
|
|
169
|
-
case "symbol":
|
|
170
|
-
return toSymbolPlaceholder(value);
|
|
171
|
-
case "undefined":
|
|
172
|
-
case "function":
|
|
173
|
-
return arrayItem ? null : void 0;
|
|
174
|
-
case "object":
|
|
175
|
-
return toRpcSafeObject(value, seen);
|
|
176
|
-
default:
|
|
177
|
-
return arrayItem ? null : void 0;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
function toRpcSafeObject(value, seen) {
|
|
181
|
-
if (seen.has(value)) {
|
|
182
|
-
return RPC_CIRCULAR_VALUE;
|
|
183
|
-
}
|
|
184
|
-
seen.add(value);
|
|
185
|
-
try {
|
|
186
|
-
if (value instanceof Date) {
|
|
187
|
-
return toSafeDate(value);
|
|
188
|
-
}
|
|
189
|
-
if (value instanceof Error) {
|
|
190
|
-
return toSafeError(value, seen);
|
|
191
|
-
}
|
|
192
|
-
if (Array.isArray(value)) {
|
|
193
|
-
return toSafeArray(value, seen);
|
|
194
|
-
}
|
|
195
|
-
return toSafeRecord(value, seen);
|
|
196
|
-
} finally {
|
|
197
|
-
seen.delete(value);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function toSafeArray(values, seen) {
|
|
201
|
-
return values.map((item) => toRpcSafeChildValue(item, seen, true) ?? null);
|
|
202
|
-
}
|
|
203
|
-
function toSafeRecord(value, seen) {
|
|
204
|
-
const keys = getEnumerableKeys(value);
|
|
205
|
-
if (!keys) {
|
|
206
|
-
return RPC_UNREADABLE_VALUE;
|
|
207
|
-
}
|
|
208
|
-
if (keys.length === 0 && !isPlainRecord(value)) {
|
|
209
|
-
return toObjectSummary(value);
|
|
210
|
-
}
|
|
211
|
-
const result = {};
|
|
212
|
-
keys.forEach((key) => {
|
|
213
|
-
if (key === "toJSON") {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const field = readObjectField(value, key);
|
|
217
|
-
if (!field.ok) {
|
|
218
|
-
result[key] = RPC_UNREADABLE_VALUE;
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
const safeValue = toRpcSafeChildValue(field.value, seen, false);
|
|
222
|
-
if (safeValue !== void 0) {
|
|
223
|
-
result[key] = safeValue;
|
|
149
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
150
|
+
const serialized = JSON.stringify(
|
|
151
|
+
value,
|
|
152
|
+
(_key, current) => {
|
|
153
|
+
if (typeof current !== "object" || current === null) {
|
|
154
|
+
return current;
|
|
155
|
+
}
|
|
156
|
+
if (seen.has(current)) {
|
|
157
|
+
return "[Circular]";
|
|
158
|
+
}
|
|
159
|
+
seen.add(current);
|
|
160
|
+
return current;
|
|
224
161
|
}
|
|
225
|
-
|
|
226
|
-
return
|
|
227
|
-
}
|
|
228
|
-
function toSafeError(error, seen) {
|
|
229
|
-
const result = {
|
|
230
|
-
name: error.name,
|
|
231
|
-
message: error.message
|
|
232
|
-
};
|
|
233
|
-
const stack = readObjectField(error, "stack");
|
|
234
|
-
if (stack.ok && typeof stack.value === "string") {
|
|
235
|
-
result.stack = stack.value;
|
|
236
|
-
}
|
|
237
|
-
if ("cause" in error) {
|
|
238
|
-
const cause = readObjectField(error, "cause");
|
|
239
|
-
result.cause = cause.ok ? toRpcSafeChildValue(cause.value, seen, false) ?? null : RPC_UNREADABLE_VALUE;
|
|
240
|
-
}
|
|
241
|
-
return result;
|
|
242
|
-
}
|
|
243
|
-
function toSafeDate(value) {
|
|
244
|
-
return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
|
|
245
|
-
}
|
|
246
|
-
function getEnumerableKeys(value) {
|
|
247
|
-
try {
|
|
248
|
-
return Object.keys(value);
|
|
249
|
-
} catch {
|
|
250
|
-
return void 0;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function readObjectField(value, key) {
|
|
254
|
-
try {
|
|
255
|
-
return {
|
|
256
|
-
ok: true,
|
|
257
|
-
value: value[key]
|
|
258
|
-
};
|
|
259
|
-
} catch {
|
|
260
|
-
return { ok: false };
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
function isPlainRecord(value) {
|
|
264
|
-
try {
|
|
265
|
-
const prototype = Object.getPrototypeOf(value);
|
|
266
|
-
return prototype === Object.prototype || prototype === null;
|
|
267
|
-
} catch {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
function toObjectSummary(value) {
|
|
272
|
-
try {
|
|
273
|
-
return Object.prototype.toString.call(value);
|
|
274
|
-
} catch {
|
|
275
|
-
return "[Object]";
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function toSymbolPlaceholder(value) {
|
|
279
|
-
return value.description ? `[Symbol(${value.description})]` : "[Symbol]";
|
|
162
|
+
);
|
|
163
|
+
return serialized;
|
|
280
164
|
}
|
|
281
165
|
|
|
282
166
|
// src/runtime/consoleHook.ts
|
|
@@ -289,14 +173,13 @@ function installConsoleHook(options) {
|
|
|
289
173
|
debug: console.debug
|
|
290
174
|
};
|
|
291
175
|
const emit = (level, args) => {
|
|
292
|
-
const serializedArgs = serializeConsoleArgs(args);
|
|
293
176
|
options.send({
|
|
294
177
|
id: (0, import_nanoid.nanoid)(),
|
|
295
178
|
pageId: options.pageId,
|
|
296
179
|
source: "hook",
|
|
297
180
|
level,
|
|
298
|
-
message:
|
|
299
|
-
args
|
|
181
|
+
message: args.map((arg) => safeStringify(arg)).join(" "),
|
|
182
|
+
args,
|
|
300
183
|
timestamp: Date.now()
|
|
301
184
|
});
|
|
302
185
|
};
|
|
@@ -323,9 +206,6 @@ function installConsoleHook(options) {
|
|
|
323
206
|
window.removeEventListener("error", onError);
|
|
324
207
|
};
|
|
325
208
|
}
|
|
326
|
-
function serializeConsoleArgs(args) {
|
|
327
|
-
return args.map((arg) => safeStringify(arg));
|
|
328
|
-
}
|
|
329
209
|
|
|
330
210
|
// src/runtime/elementRegistry.ts
|
|
331
211
|
var import_nanoid2 = require("nanoid");
|
|
@@ -2159,15 +2039,6 @@ function installVueBridge(hot) {
|
|
|
2159
2039
|
);
|
|
2160
2040
|
rpcRef.current = rpc;
|
|
2161
2041
|
}
|
|
2162
|
-
function toVueRpcPayload(value) {
|
|
2163
|
-
return toRpcSafeValue(value);
|
|
2164
|
-
}
|
|
2165
|
-
function toVueRpcJsonPayload(value) {
|
|
2166
|
-
return JSON.stringify(toRpcSafeValue(value) ?? null);
|
|
2167
|
-
}
|
|
2168
|
-
function toVueRpcPrettyJsonPayload(value) {
|
|
2169
|
-
return JSON.stringify(toRpcSafeValue(value), null, 2);
|
|
2170
|
-
}
|
|
2171
2042
|
function createClientVueRuntimeRpc(getRpc) {
|
|
2172
2043
|
return {
|
|
2173
2044
|
...createRuntimeDevtoolsRpc(getRpc),
|
|
@@ -2176,10 +2047,7 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2176
2047
|
inspectorId: COMPONENTS_INSPECTOR_ID,
|
|
2177
2048
|
filter: query.componentName ?? ""
|
|
2178
2049
|
});
|
|
2179
|
-
getRpc().onInspectorTreeUpdated(
|
|
2180
|
-
query.event,
|
|
2181
|
-
toVueRpcPayload(inspectorTree[0])
|
|
2182
|
-
);
|
|
2050
|
+
getRpc().onInspectorTreeUpdated(query.event, inspectorTree[0]);
|
|
2183
2051
|
},
|
|
2184
2052
|
onInspectorTreeUpdated: () => void 0,
|
|
2185
2053
|
async getInspectorState(query) {
|
|
@@ -2187,7 +2055,7 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2187
2055
|
if (!targetNode) {
|
|
2188
2056
|
getRpc().onInspectorStateUpdated(
|
|
2189
2057
|
query.event,
|
|
2190
|
-
|
|
2058
|
+
createMissingComponentError(query.componentName)
|
|
2191
2059
|
);
|
|
2192
2060
|
return;
|
|
2193
2061
|
}
|
|
@@ -2195,10 +2063,7 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2195
2063
|
inspectorId: COMPONENTS_INSPECTOR_ID,
|
|
2196
2064
|
nodeId: targetNode.id
|
|
2197
2065
|
});
|
|
2198
|
-
getRpc().onInspectorStateUpdated(
|
|
2199
|
-
query.event,
|
|
2200
|
-
toVueRpcJsonPayload(inspectorState)
|
|
2201
|
-
);
|
|
2066
|
+
getRpc().onInspectorStateUpdated(query.event, (0, import_devtools_kit.stringify)(inspectorState));
|
|
2202
2067
|
},
|
|
2203
2068
|
onInspectorStateUpdated: () => void 0,
|
|
2204
2069
|
async editComponentState(query) {
|
|
@@ -2235,7 +2100,7 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2235
2100
|
getRouterInfo(query) {
|
|
2236
2101
|
getRpc().onRouterInfoUpdated(
|
|
2237
2102
|
query.event,
|
|
2238
|
-
|
|
2103
|
+
JSON.stringify(import_devtools_kit.devtoolsRouterInfo, null, 2)
|
|
2239
2104
|
);
|
|
2240
2105
|
},
|
|
2241
2106
|
onRouterInfoUpdated: () => void 0,
|
|
@@ -2246,7 +2111,7 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2246
2111
|
filter: ""
|
|
2247
2112
|
})
|
|
2248
2113
|
);
|
|
2249
|
-
getRpc().onPiniaTreeUpdated(query.event,
|
|
2114
|
+
getRpc().onPiniaTreeUpdated(query.event, inspectorTree);
|
|
2250
2115
|
},
|
|
2251
2116
|
onPiniaTreeUpdated: () => void 0,
|
|
2252
2117
|
async getPiniaState(query) {
|
|
@@ -2261,7 +2126,7 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2261
2126
|
}
|
|
2262
2127
|
return import_devtools_kit.devtools.ctx.api.getInspectorState(payload);
|
|
2263
2128
|
});
|
|
2264
|
-
getRpc().onPiniaInfoUpdated(query.event,
|
|
2129
|
+
getRpc().onPiniaInfoUpdated(query.event, (0, import_devtools_kit.stringify)(result));
|
|
2265
2130
|
},
|
|
2266
2131
|
onPiniaInfoUpdated: () => void 0,
|
|
2267
2132
|
async recordPerformance(query) {
|
|
@@ -2269,7 +2134,7 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2269
2134
|
if (!collector) {
|
|
2270
2135
|
getRpc().onPerformanceRecorded(
|
|
2271
2136
|
query.event,
|
|
2272
|
-
|
|
2137
|
+
createPerformanceUnavailableError()
|
|
2273
2138
|
);
|
|
2274
2139
|
return;
|
|
2275
2140
|
}
|
|
@@ -2279,11 +2144,11 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2279
2144
|
includeMemory: query.includeMemory,
|
|
2280
2145
|
includeStacks: query.includeStacks
|
|
2281
2146
|
});
|
|
2282
|
-
getRpc().onPerformanceRecorded(query.event,
|
|
2147
|
+
getRpc().onPerformanceRecorded(query.event, report);
|
|
2283
2148
|
} catch (error) {
|
|
2284
2149
|
getRpc().onPerformanceRecorded(
|
|
2285
2150
|
query.event,
|
|
2286
|
-
|
|
2151
|
+
createPerformanceError(error)
|
|
2287
2152
|
);
|
|
2288
2153
|
}
|
|
2289
2154
|
},
|
|
@@ -2293,7 +2158,7 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2293
2158
|
if (!collector) {
|
|
2294
2159
|
getRpc().onPerformanceRecordingStarted(
|
|
2295
2160
|
query.event,
|
|
2296
|
-
|
|
2161
|
+
createPerformanceUnavailableError()
|
|
2297
2162
|
);
|
|
2298
2163
|
return;
|
|
2299
2164
|
}
|
|
@@ -2302,19 +2167,16 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2302
2167
|
includeMemory: query.includeMemory,
|
|
2303
2168
|
includeStacks: query.includeStacks
|
|
2304
2169
|
});
|
|
2305
|
-
getRpc().onPerformanceRecordingStarted(
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
source: "hook"
|
|
2312
|
-
})
|
|
2313
|
-
);
|
|
2170
|
+
getRpc().onPerformanceRecordingStarted(query.event, {
|
|
2171
|
+
ok: true,
|
|
2172
|
+
recordingId,
|
|
2173
|
+
startedAt: Date.now(),
|
|
2174
|
+
source: "hook"
|
|
2175
|
+
});
|
|
2314
2176
|
} catch (error) {
|
|
2315
2177
|
getRpc().onPerformanceRecordingStarted(
|
|
2316
2178
|
query.event,
|
|
2317
|
-
|
|
2179
|
+
createPerformanceError(error)
|
|
2318
2180
|
);
|
|
2319
2181
|
}
|
|
2320
2182
|
},
|
|
@@ -2324,20 +2186,17 @@ function createClientVueRuntimeRpc(getRpc) {
|
|
|
2324
2186
|
if (!collector) {
|
|
2325
2187
|
getRpc().onPerformanceRecordingStopped(
|
|
2326
2188
|
query.event,
|
|
2327
|
-
|
|
2189
|
+
createPerformanceUnavailableError()
|
|
2328
2190
|
);
|
|
2329
2191
|
return;
|
|
2330
2192
|
}
|
|
2331
2193
|
try {
|
|
2332
2194
|
const report = collector.stop(query.recordingId);
|
|
2333
|
-
getRpc().onPerformanceRecordingStopped(
|
|
2334
|
-
query.event,
|
|
2335
|
-
toVueRpcPayload(report)
|
|
2336
|
-
);
|
|
2195
|
+
getRpc().onPerformanceRecordingStopped(query.event, report);
|
|
2337
2196
|
} catch (error) {
|
|
2338
2197
|
getRpc().onPerformanceRecordingStopped(
|
|
2339
2198
|
query.event,
|
|
2340
|
-
|
|
2199
|
+
createPerformanceError(error)
|
|
2341
2200
|
);
|
|
2342
2201
|
}
|
|
2343
2202
|
},
|