@xiaou66/vite-plugin-vue-mcp-next 1.3.0 → 1.3.2
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 +133 -17
- 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 +133 -17
- package/dist/index.js.map +1 -1
- package/dist/runtime/client.cjs +177 -36
- 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 +177 -37
- package/dist/runtime/client.js.map +1 -1
- package/dist/{types-BKXdHkwk.d.cts → types-DAx3jHdz.d.cts} +2 -2
- package/dist/{types-BKXdHkwk.d.ts → types-DAx3jHdz.d.ts} +2 -2
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
-
import { l as VueMcpNextOptions } from './types-
|
|
3
|
-
export { C as CdpOptions, a as ConsoleOptions, b as ConsoleRecord, c as CursorMcpConfig, D as DomOptions, E as ElementContextResult, d as ElementPickerOptions, e as ElementPickerShortcut, f as EvaluateOptions, M as McpClientConfigOptions, N as NetworkOptions, g as NetworkRecord, P as PageTarget, R as ResolvedVueMcpNextOptions, i as RuntimeElementContextRequest, j as RuntimeMode, k as RuntimeOptions, S as SkillConfigOptions, V as VueMcpNextContext } from './types-
|
|
2
|
+
import { l as VueMcpNextOptions } from './types-DAx3jHdz.cjs';
|
|
3
|
+
export { C as CdpOptions, a as ConsoleOptions, b as ConsoleRecord, c as CursorMcpConfig, D as DomOptions, E as ElementContextResult, d as ElementPickerOptions, e as ElementPickerShortcut, f as EvaluateOptions, M as McpClientConfigOptions, N as NetworkOptions, g as NetworkRecord, P as PageTarget, R as ResolvedVueMcpNextOptions, i as RuntimeElementContextRequest, j as RuntimeMode, k as RuntimeOptions, S as SkillConfigOptions, V as VueMcpNextContext } from './types-DAx3jHdz.cjs';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
-
import { l as VueMcpNextOptions } from './types-
|
|
3
|
-
export { C as CdpOptions, a as ConsoleOptions, b as ConsoleRecord, c as CursorMcpConfig, D as DomOptions, E as ElementContextResult, d as ElementPickerOptions, e as ElementPickerShortcut, f as EvaluateOptions, M as McpClientConfigOptions, N as NetworkOptions, g as NetworkRecord, P as PageTarget, R as ResolvedVueMcpNextOptions, i as RuntimeElementContextRequest, j as RuntimeMode, k as RuntimeOptions, S as SkillConfigOptions, V as VueMcpNextContext } from './types-
|
|
2
|
+
import { l as VueMcpNextOptions } from './types-DAx3jHdz.js';
|
|
3
|
+
export { C as CdpOptions, a as ConsoleOptions, b as ConsoleRecord, c as CursorMcpConfig, D as DomOptions, E as ElementContextResult, d as ElementPickerOptions, e as ElementPickerShortcut, f as EvaluateOptions, M as McpClientConfigOptions, N as NetworkOptions, g as NetworkRecord, P as PageTarget, R as ResolvedVueMcpNextOptions, i as RuntimeElementContextRequest, j as RuntimeMode, k as RuntimeOptions, S as SkillConfigOptions, V as VueMcpNextContext } from './types-DAx3jHdz.js';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2662,25 +2662,141 @@ function createServerVueRuntimeRpc(ctx) {
|
|
|
2662
2662
|
import { nanoid as nanoid4 } from "nanoid";
|
|
2663
2663
|
|
|
2664
2664
|
// src/shared/serialization.ts
|
|
2665
|
+
var RPC_CIRCULAR_VALUE = "[Circular]";
|
|
2666
|
+
var RPC_UNREADABLE_VALUE = "[Unreadable]";
|
|
2667
|
+
function toRpcSafeValue(value) {
|
|
2668
|
+
return toRpcSafeChildValue(value, /* @__PURE__ */ new WeakSet(), false);
|
|
2669
|
+
}
|
|
2665
2670
|
function safeStringify(value) {
|
|
2666
2671
|
if (typeof value === "string") {
|
|
2667
2672
|
return value;
|
|
2668
2673
|
}
|
|
2669
|
-
const
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2674
|
+
const safeValue = toRpcSafeValue(value);
|
|
2675
|
+
return safeValue === void 0 ? "undefined" : JSON.stringify(safeValue);
|
|
2676
|
+
}
|
|
2677
|
+
function toRpcSafeChildValue(value, seen, arrayItem) {
|
|
2678
|
+
if (value === null) {
|
|
2679
|
+
return null;
|
|
2680
|
+
}
|
|
2681
|
+
switch (typeof value) {
|
|
2682
|
+
case "string":
|
|
2683
|
+
case "boolean":
|
|
2684
|
+
return value;
|
|
2685
|
+
case "number":
|
|
2686
|
+
return Number.isFinite(value) ? value : String(value);
|
|
2687
|
+
case "bigint":
|
|
2688
|
+
return value.toString();
|
|
2689
|
+
case "symbol":
|
|
2690
|
+
return toSymbolPlaceholder(value);
|
|
2691
|
+
case "undefined":
|
|
2692
|
+
case "function":
|
|
2693
|
+
return arrayItem ? null : void 0;
|
|
2694
|
+
case "object":
|
|
2695
|
+
return toRpcSafeObject(value, seen);
|
|
2696
|
+
default:
|
|
2697
|
+
return arrayItem ? null : void 0;
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
function toRpcSafeObject(value, seen) {
|
|
2701
|
+
if (seen.has(value)) {
|
|
2702
|
+
return RPC_CIRCULAR_VALUE;
|
|
2703
|
+
}
|
|
2704
|
+
seen.add(value);
|
|
2705
|
+
try {
|
|
2706
|
+
if (value instanceof Date) {
|
|
2707
|
+
return toSafeDate(value);
|
|
2681
2708
|
}
|
|
2682
|
-
|
|
2683
|
-
|
|
2709
|
+
if (value instanceof Error) {
|
|
2710
|
+
return toSafeError(value, seen);
|
|
2711
|
+
}
|
|
2712
|
+
if (Array.isArray(value)) {
|
|
2713
|
+
return toSafeArray(value, seen);
|
|
2714
|
+
}
|
|
2715
|
+
return toSafeRecord(value, seen);
|
|
2716
|
+
} finally {
|
|
2717
|
+
seen.delete(value);
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
function toSafeArray(values, seen) {
|
|
2721
|
+
return values.map((item) => toRpcSafeChildValue(item, seen, true) ?? null);
|
|
2722
|
+
}
|
|
2723
|
+
function toSafeRecord(value, seen) {
|
|
2724
|
+
const keys = getEnumerableKeys(value);
|
|
2725
|
+
if (!keys) {
|
|
2726
|
+
return RPC_UNREADABLE_VALUE;
|
|
2727
|
+
}
|
|
2728
|
+
if (keys.length === 0 && !isPlainRecord3(value)) {
|
|
2729
|
+
return toObjectSummary(value);
|
|
2730
|
+
}
|
|
2731
|
+
const result = {};
|
|
2732
|
+
keys.forEach((key) => {
|
|
2733
|
+
if (key === "toJSON") {
|
|
2734
|
+
return;
|
|
2735
|
+
}
|
|
2736
|
+
const field = readObjectField(value, key);
|
|
2737
|
+
if (!field.ok) {
|
|
2738
|
+
result[key] = RPC_UNREADABLE_VALUE;
|
|
2739
|
+
return;
|
|
2740
|
+
}
|
|
2741
|
+
const safeValue = toRpcSafeChildValue(field.value, seen, false);
|
|
2742
|
+
if (safeValue !== void 0) {
|
|
2743
|
+
result[key] = safeValue;
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
return result;
|
|
2747
|
+
}
|
|
2748
|
+
function toSafeError(error, seen) {
|
|
2749
|
+
const result = {
|
|
2750
|
+
name: error.name,
|
|
2751
|
+
message: error.message
|
|
2752
|
+
};
|
|
2753
|
+
const stack = readObjectField(error, "stack");
|
|
2754
|
+
if (stack.ok && typeof stack.value === "string") {
|
|
2755
|
+
result.stack = stack.value;
|
|
2756
|
+
}
|
|
2757
|
+
if ("cause" in error) {
|
|
2758
|
+
const cause = readObjectField(error, "cause");
|
|
2759
|
+
result.cause = cause.ok ? toRpcSafeChildValue(cause.value, seen, false) ?? null : RPC_UNREADABLE_VALUE;
|
|
2760
|
+
}
|
|
2761
|
+
return result;
|
|
2762
|
+
}
|
|
2763
|
+
function toSafeDate(value) {
|
|
2764
|
+
return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
|
|
2765
|
+
}
|
|
2766
|
+
function getEnumerableKeys(value) {
|
|
2767
|
+
try {
|
|
2768
|
+
return Object.keys(value);
|
|
2769
|
+
} catch {
|
|
2770
|
+
return void 0;
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
function readObjectField(value, key) {
|
|
2774
|
+
try {
|
|
2775
|
+
return {
|
|
2776
|
+
ok: true,
|
|
2777
|
+
value: value[key]
|
|
2778
|
+
};
|
|
2779
|
+
} catch {
|
|
2780
|
+
return { ok: false };
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
function isPlainRecord3(value) {
|
|
2784
|
+
try {
|
|
2785
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2786
|
+
return prototype === Object.prototype || prototype === null;
|
|
2787
|
+
} catch {
|
|
2788
|
+
return false;
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
function toObjectSummary(value) {
|
|
2792
|
+
try {
|
|
2793
|
+
return Object.prototype.toString.call(value);
|
|
2794
|
+
} catch {
|
|
2795
|
+
return "[Object]";
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
function toSymbolPlaceholder(value) {
|
|
2799
|
+
return value.description ? `[Symbol(${value.description})]` : "[Symbol]";
|
|
2684
2800
|
}
|
|
2685
2801
|
|
|
2686
2802
|
// src/cdp/cdpConsole.ts
|
|
@@ -3235,11 +3351,11 @@ import path4 from "path";
|
|
|
3235
3351
|
async function updateJsonMcpClientConfig(options) {
|
|
3236
3352
|
try {
|
|
3237
3353
|
const config = await readJsonConfig(options.configPath);
|
|
3238
|
-
if (!
|
|
3354
|
+
if (!isPlainRecord4(config)) {
|
|
3239
3355
|
warnConfigFailure(options, "config root must be a JSON object");
|
|
3240
3356
|
return;
|
|
3241
3357
|
}
|
|
3242
|
-
const mcpServers =
|
|
3358
|
+
const mcpServers = isPlainRecord4(config.mcpServers) ? config.mcpServers : {};
|
|
3243
3359
|
if (Object.hasOwn(mcpServers, options.serverName)) {
|
|
3244
3360
|
return;
|
|
3245
3361
|
}
|
|
@@ -3292,7 +3408,7 @@ async function readOptionalTextFile2(filePath) {
|
|
|
3292
3408
|
throw error;
|
|
3293
3409
|
}
|
|
3294
3410
|
}
|
|
3295
|
-
function
|
|
3411
|
+
function isPlainRecord4(value) {
|
|
3296
3412
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3297
3413
|
}
|
|
3298
3414
|
function warnConfigFailure(options, reason) {
|