@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.
@@ -1,4 +1,4 @@
1
- import { h as RuntimeClientOptions } from '../types-DAx3jHdz.cjs';
1
+ import { h as RuntimeClientOptions } from '../types-BKXdHkwk.cjs';
2
2
  import 'hookable';
3
3
  import 'vite';
4
4
 
@@ -1,4 +1,4 @@
1
- import { h as RuntimeClientOptions } from '../types-DAx3jHdz.js';
1
+ import { h as RuntimeClientOptions } from '../types-BKXdHkwk.js';
2
2
  import 'hookable';
3
3
  import 'vite';
4
4
 
@@ -115,141 +115,25 @@ var DEFAULT_OPTIONS = {
115
115
  import { nanoid } from "nanoid";
116
116
 
117
117
  // src/shared/serialization.ts
118
- var RPC_CIRCULAR_VALUE = "[Circular]";
119
- var RPC_UNREADABLE_VALUE = "[Unreadable]";
120
- function toRpcSafeValue(value) {
121
- return toRpcSafeChildValue(value, /* @__PURE__ */ new WeakSet(), false);
122
- }
123
118
  function safeStringify(value) {
124
119
  if (typeof value === "string") {
125
120
  return value;
126
121
  }
127
- const safeValue = toRpcSafeValue(value);
128
- return safeValue === void 0 ? "undefined" : JSON.stringify(safeValue);
129
- }
130
- function toRpcSafeChildValue(value, seen, arrayItem) {
131
- if (value === null) {
132
- return null;
133
- }
134
- switch (typeof value) {
135
- case "string":
136
- case "boolean":
137
- return value;
138
- case "number":
139
- return Number.isFinite(value) ? value : String(value);
140
- case "bigint":
141
- return value.toString();
142
- case "symbol":
143
- return toSymbolPlaceholder(value);
144
- case "undefined":
145
- case "function":
146
- return arrayItem ? null : void 0;
147
- case "object":
148
- return toRpcSafeObject(value, seen);
149
- default:
150
- return arrayItem ? null : void 0;
151
- }
152
- }
153
- function toRpcSafeObject(value, seen) {
154
- if (seen.has(value)) {
155
- return RPC_CIRCULAR_VALUE;
156
- }
157
- seen.add(value);
158
- try {
159
- if (value instanceof Date) {
160
- return toSafeDate(value);
161
- }
162
- if (value instanceof Error) {
163
- return toSafeError(value, seen);
164
- }
165
- if (Array.isArray(value)) {
166
- return toSafeArray(value, seen);
167
- }
168
- return toSafeRecord(value, seen);
169
- } finally {
170
- seen.delete(value);
171
- }
172
- }
173
- function toSafeArray(values, seen) {
174
- return values.map((item) => toRpcSafeChildValue(item, seen, true) ?? null);
175
- }
176
- function toSafeRecord(value, seen) {
177
- const keys = getEnumerableKeys(value);
178
- if (!keys) {
179
- return RPC_UNREADABLE_VALUE;
180
- }
181
- if (keys.length === 0 && !isPlainRecord(value)) {
182
- return toObjectSummary(value);
183
- }
184
- const result = {};
185
- keys.forEach((key) => {
186
- if (key === "toJSON") {
187
- return;
188
- }
189
- const field = readObjectField(value, key);
190
- if (!field.ok) {
191
- result[key] = RPC_UNREADABLE_VALUE;
192
- return;
193
- }
194
- const safeValue = toRpcSafeChildValue(field.value, seen, false);
195
- if (safeValue !== void 0) {
196
- result[key] = safeValue;
122
+ const seen = /* @__PURE__ */ new WeakSet();
123
+ const serialized = JSON.stringify(
124
+ value,
125
+ (_key, current) => {
126
+ if (typeof current !== "object" || current === null) {
127
+ return current;
128
+ }
129
+ if (seen.has(current)) {
130
+ return "[Circular]";
131
+ }
132
+ seen.add(current);
133
+ return current;
197
134
  }
198
- });
199
- return result;
200
- }
201
- function toSafeError(error, seen) {
202
- const result = {
203
- name: error.name,
204
- message: error.message
205
- };
206
- const stack = readObjectField(error, "stack");
207
- if (stack.ok && typeof stack.value === "string") {
208
- result.stack = stack.value;
209
- }
210
- if ("cause" in error) {
211
- const cause = readObjectField(error, "cause");
212
- result.cause = cause.ok ? toRpcSafeChildValue(cause.value, seen, false) ?? null : RPC_UNREADABLE_VALUE;
213
- }
214
- return result;
215
- }
216
- function toSafeDate(value) {
217
- return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
218
- }
219
- function getEnumerableKeys(value) {
220
- try {
221
- return Object.keys(value);
222
- } catch {
223
- return void 0;
224
- }
225
- }
226
- function readObjectField(value, key) {
227
- try {
228
- return {
229
- ok: true,
230
- value: value[key]
231
- };
232
- } catch {
233
- return { ok: false };
234
- }
235
- }
236
- function isPlainRecord(value) {
237
- try {
238
- const prototype = Object.getPrototypeOf(value);
239
- return prototype === Object.prototype || prototype === null;
240
- } catch {
241
- return false;
242
- }
243
- }
244
- function toObjectSummary(value) {
245
- try {
246
- return Object.prototype.toString.call(value);
247
- } catch {
248
- return "[Object]";
249
- }
250
- }
251
- function toSymbolPlaceholder(value) {
252
- return value.description ? `[Symbol(${value.description})]` : "[Symbol]";
135
+ );
136
+ return serialized;
253
137
  }
254
138
 
255
139
  // src/runtime/consoleHook.ts
@@ -262,14 +146,13 @@ function installConsoleHook(options) {
262
146
  debug: console.debug
263
147
  };
264
148
  const emit = (level, args) => {
265
- const serializedArgs = serializeConsoleArgs(args);
266
149
  options.send({
267
150
  id: nanoid(),
268
151
  pageId: options.pageId,
269
152
  source: "hook",
270
153
  level,
271
- message: serializedArgs.join(" "),
272
- args: serializedArgs,
154
+ message: args.map((arg) => safeStringify(arg)).join(" "),
155
+ args,
273
156
  timestamp: Date.now()
274
157
  });
275
158
  };
@@ -296,9 +179,6 @@ function installConsoleHook(options) {
296
179
  window.removeEventListener("error", onError);
297
180
  };
298
181
  }
299
- function serializeConsoleArgs(args) {
300
- return args.map((arg) => safeStringify(arg));
301
- }
302
182
 
303
183
  // src/runtime/elementRegistry.ts
304
184
  import { nanoid as nanoid2 } from "nanoid";
@@ -1611,6 +1491,7 @@ import {
1611
1491
  devtoolsRouterInfo,
1612
1492
  devtoolsState,
1613
1493
  getInspector,
1494
+ stringify,
1614
1495
  toggleHighPerfMode
1615
1496
  } from "@vue/devtools-kit";
1616
1497
  import { createRPCClient } from "vite-dev-rpc";
@@ -2138,15 +2019,6 @@ function installVueBridge(hot) {
2138
2019
  );
2139
2020
  rpcRef.current = rpc;
2140
2021
  }
2141
- function toVueRpcPayload(value) {
2142
- return toRpcSafeValue(value);
2143
- }
2144
- function toVueRpcJsonPayload(value) {
2145
- return JSON.stringify(toRpcSafeValue(value) ?? null);
2146
- }
2147
- function toVueRpcPrettyJsonPayload(value) {
2148
- return JSON.stringify(toRpcSafeValue(value), null, 2);
2149
- }
2150
2022
  function createClientVueRuntimeRpc(getRpc) {
2151
2023
  return {
2152
2024
  ...createRuntimeDevtoolsRpc(getRpc),
@@ -2155,10 +2027,7 @@ function createClientVueRuntimeRpc(getRpc) {
2155
2027
  inspectorId: COMPONENTS_INSPECTOR_ID,
2156
2028
  filter: query.componentName ?? ""
2157
2029
  });
2158
- getRpc().onInspectorTreeUpdated(
2159
- query.event,
2160
- toVueRpcPayload(inspectorTree[0])
2161
- );
2030
+ getRpc().onInspectorTreeUpdated(query.event, inspectorTree[0]);
2162
2031
  },
2163
2032
  onInspectorTreeUpdated: () => void 0,
2164
2033
  async getInspectorState(query) {
@@ -2166,7 +2035,7 @@ function createClientVueRuntimeRpc(getRpc) {
2166
2035
  if (!targetNode) {
2167
2036
  getRpc().onInspectorStateUpdated(
2168
2037
  query.event,
2169
- toVueRpcPayload(createMissingComponentError(query.componentName))
2038
+ createMissingComponentError(query.componentName)
2170
2039
  );
2171
2040
  return;
2172
2041
  }
@@ -2174,10 +2043,7 @@ function createClientVueRuntimeRpc(getRpc) {
2174
2043
  inspectorId: COMPONENTS_INSPECTOR_ID,
2175
2044
  nodeId: targetNode.id
2176
2045
  });
2177
- getRpc().onInspectorStateUpdated(
2178
- query.event,
2179
- toVueRpcJsonPayload(inspectorState)
2180
- );
2046
+ getRpc().onInspectorStateUpdated(query.event, stringify(inspectorState));
2181
2047
  },
2182
2048
  onInspectorStateUpdated: () => void 0,
2183
2049
  async editComponentState(query) {
@@ -2214,7 +2080,7 @@ function createClientVueRuntimeRpc(getRpc) {
2214
2080
  getRouterInfo(query) {
2215
2081
  getRpc().onRouterInfoUpdated(
2216
2082
  query.event,
2217
- toVueRpcPrettyJsonPayload(devtoolsRouterInfo)
2083
+ JSON.stringify(devtoolsRouterInfo, null, 2)
2218
2084
  );
2219
2085
  },
2220
2086
  onRouterInfoUpdated: () => void 0,
@@ -2225,7 +2091,7 @@ function createClientVueRuntimeRpc(getRpc) {
2225
2091
  filter: ""
2226
2092
  })
2227
2093
  );
2228
- getRpc().onPiniaTreeUpdated(query.event, toVueRpcPayload(inspectorTree));
2094
+ getRpc().onPiniaTreeUpdated(query.event, inspectorTree);
2229
2095
  },
2230
2096
  onPiniaTreeUpdated: () => void 0,
2231
2097
  async getPiniaState(query) {
@@ -2240,7 +2106,7 @@ function createClientVueRuntimeRpc(getRpc) {
2240
2106
  }
2241
2107
  return devtools.ctx.api.getInspectorState(payload);
2242
2108
  });
2243
- getRpc().onPiniaInfoUpdated(query.event, toVueRpcJsonPayload(result));
2109
+ getRpc().onPiniaInfoUpdated(query.event, stringify(result));
2244
2110
  },
2245
2111
  onPiniaInfoUpdated: () => void 0,
2246
2112
  async recordPerformance(query) {
@@ -2248,7 +2114,7 @@ function createClientVueRuntimeRpc(getRpc) {
2248
2114
  if (!collector) {
2249
2115
  getRpc().onPerformanceRecorded(
2250
2116
  query.event,
2251
- toVueRpcPayload(createPerformanceUnavailableError())
2117
+ createPerformanceUnavailableError()
2252
2118
  );
2253
2119
  return;
2254
2120
  }
@@ -2258,11 +2124,11 @@ function createClientVueRuntimeRpc(getRpc) {
2258
2124
  includeMemory: query.includeMemory,
2259
2125
  includeStacks: query.includeStacks
2260
2126
  });
2261
- getRpc().onPerformanceRecorded(query.event, toVueRpcPayload(report));
2127
+ getRpc().onPerformanceRecorded(query.event, report);
2262
2128
  } catch (error) {
2263
2129
  getRpc().onPerformanceRecorded(
2264
2130
  query.event,
2265
- toVueRpcPayload(createPerformanceError(error))
2131
+ createPerformanceError(error)
2266
2132
  );
2267
2133
  }
2268
2134
  },
@@ -2272,7 +2138,7 @@ function createClientVueRuntimeRpc(getRpc) {
2272
2138
  if (!collector) {
2273
2139
  getRpc().onPerformanceRecordingStarted(
2274
2140
  query.event,
2275
- toVueRpcPayload(createPerformanceUnavailableError())
2141
+ createPerformanceUnavailableError()
2276
2142
  );
2277
2143
  return;
2278
2144
  }
@@ -2281,19 +2147,16 @@ function createClientVueRuntimeRpc(getRpc) {
2281
2147
  includeMemory: query.includeMemory,
2282
2148
  includeStacks: query.includeStacks
2283
2149
  });
2284
- getRpc().onPerformanceRecordingStarted(
2285
- query.event,
2286
- toVueRpcPayload({
2287
- ok: true,
2288
- recordingId,
2289
- startedAt: Date.now(),
2290
- source: "hook"
2291
- })
2292
- );
2150
+ getRpc().onPerformanceRecordingStarted(query.event, {
2151
+ ok: true,
2152
+ recordingId,
2153
+ startedAt: Date.now(),
2154
+ source: "hook"
2155
+ });
2293
2156
  } catch (error) {
2294
2157
  getRpc().onPerformanceRecordingStarted(
2295
2158
  query.event,
2296
- toVueRpcPayload(createPerformanceError(error))
2159
+ createPerformanceError(error)
2297
2160
  );
2298
2161
  }
2299
2162
  },
@@ -2303,20 +2166,17 @@ function createClientVueRuntimeRpc(getRpc) {
2303
2166
  if (!collector) {
2304
2167
  getRpc().onPerformanceRecordingStopped(
2305
2168
  query.event,
2306
- toVueRpcPayload(createPerformanceUnavailableError())
2169
+ createPerformanceUnavailableError()
2307
2170
  );
2308
2171
  return;
2309
2172
  }
2310
2173
  try {
2311
2174
  const report = collector.stop(query.recordingId);
2312
- getRpc().onPerformanceRecordingStopped(
2313
- query.event,
2314
- toVueRpcPayload(report)
2315
- );
2175
+ getRpc().onPerformanceRecordingStopped(query.event, report);
2316
2176
  } catch (error) {
2317
2177
  getRpc().onPerformanceRecordingStopped(
2318
2178
  query.event,
2319
- toVueRpcPayload(createPerformanceError(error))
2179
+ createPerformanceError(error)
2320
2180
  );
2321
2181
  }
2322
2182
  },