@xiaou66/vite-plugin-vue-mcp-next 1.3.3 → 1.3.5
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 +104 -92
- 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 +104 -92
- package/dist/index.js.map +1 -1
- package/dist/runtime/client.cjs +196 -132
- 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 +197 -132
- 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/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-BKXdHkwk.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-BKXdHkwk.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-BKXdHkwk.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-BKXdHkwk.js';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2662,153 +2662,165 @@ function createServerVueRuntimeRpc(ctx) {
|
|
|
2662
2662
|
import { nanoid as nanoid4 } from "nanoid";
|
|
2663
2663
|
|
|
2664
2664
|
// src/shared/serialization.ts
|
|
2665
|
-
var
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2665
|
+
var DEFAULT_PREVIEW_OPTIONS = {
|
|
2666
|
+
maxDepth: 2,
|
|
2667
|
+
maxKeys: 20,
|
|
2668
|
+
maxArrayItems: 20,
|
|
2669
|
+
maxStringLength: 1e3,
|
|
2670
|
+
maxTotalNodes: 200
|
|
2671
|
+
};
|
|
2672
|
+
var CIRCULAR_VALUE = "[Circular]";
|
|
2673
|
+
var TRUNCATED_VALUE = "[Truncated]";
|
|
2674
|
+
var UNREADABLE_VALUE = "[Unreadable]";
|
|
2675
|
+
function createBoundedPreview(value, options = {}) {
|
|
2676
|
+
return previewValue(
|
|
2677
|
+
value,
|
|
2678
|
+
{
|
|
2679
|
+
options: { ...DEFAULT_PREVIEW_OPTIONS, ...options },
|
|
2680
|
+
seen: /* @__PURE__ */ new WeakSet(),
|
|
2681
|
+
visited: 0
|
|
2682
|
+
},
|
|
2683
|
+
0,
|
|
2684
|
+
false
|
|
2685
|
+
);
|
|
2669
2686
|
}
|
|
2670
2687
|
function safeStringify(value) {
|
|
2671
2688
|
if (typeof value === "string") {
|
|
2672
|
-
return value;
|
|
2689
|
+
return truncateString(value, DEFAULT_PREVIEW_OPTIONS.maxStringLength);
|
|
2673
2690
|
}
|
|
2674
|
-
const
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
return
|
|
2679
|
-
cache: /* @__PURE__ */ new WeakMap(),
|
|
2680
|
-
seen: /* @__PURE__ */ new WeakSet()
|
|
2681
|
-
};
|
|
2691
|
+
const preview = createBoundedPreview(value);
|
|
2692
|
+
if (preview === void 0) {
|
|
2693
|
+
return "undefined";
|
|
2694
|
+
}
|
|
2695
|
+
return JSON.stringify(preview);
|
|
2682
2696
|
}
|
|
2683
|
-
function
|
|
2697
|
+
function previewValue(value, context, depth, arrayItem) {
|
|
2684
2698
|
if (value === null) {
|
|
2685
2699
|
return null;
|
|
2686
2700
|
}
|
|
2687
2701
|
switch (typeof value) {
|
|
2688
2702
|
case "string":
|
|
2689
|
-
|
|
2690
|
-
return value;
|
|
2703
|
+
return truncateString(value, context.options.maxStringLength);
|
|
2691
2704
|
case "number":
|
|
2692
2705
|
return Number.isFinite(value) ? value : String(value);
|
|
2706
|
+
case "boolean":
|
|
2707
|
+
return value;
|
|
2693
2708
|
case "bigint":
|
|
2694
2709
|
return value.toString();
|
|
2695
2710
|
case "symbol":
|
|
2696
|
-
return
|
|
2697
|
-
case "undefined":
|
|
2711
|
+
return value.description ? `[Symbol(${value.description})]` : "[Symbol]";
|
|
2698
2712
|
case "function":
|
|
2713
|
+
return functionLabel(value);
|
|
2714
|
+
case "undefined":
|
|
2699
2715
|
return arrayItem ? null : void 0;
|
|
2700
2716
|
case "object":
|
|
2701
|
-
return
|
|
2717
|
+
return previewObject(value, context, depth);
|
|
2702
2718
|
default:
|
|
2703
2719
|
return arrayItem ? null : void 0;
|
|
2704
2720
|
}
|
|
2705
2721
|
}
|
|
2706
|
-
function
|
|
2722
|
+
function previewObject(value, context, depth) {
|
|
2707
2723
|
if (context.seen.has(value)) {
|
|
2708
|
-
return
|
|
2724
|
+
return CIRCULAR_VALUE;
|
|
2725
|
+
}
|
|
2726
|
+
if (context.visited >= context.options.maxTotalNodes) {
|
|
2727
|
+
return TRUNCATED_VALUE;
|
|
2709
2728
|
}
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
return cached;
|
|
2729
|
+
if (depth >= context.options.maxDepth) {
|
|
2730
|
+
return objectLabel(value);
|
|
2713
2731
|
}
|
|
2732
|
+
context.visited += 1;
|
|
2714
2733
|
context.seen.add(value);
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
} else {
|
|
2724
|
-
safeValue = toSafeRecord(value, context);
|
|
2725
|
-
}
|
|
2726
|
-
context.cache.set(value, safeValue);
|
|
2727
|
-
return safeValue;
|
|
2728
|
-
} finally {
|
|
2729
|
-
context.seen.delete(value);
|
|
2734
|
+
if (value instanceof Date) {
|
|
2735
|
+
return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
|
|
2736
|
+
}
|
|
2737
|
+
if (value instanceof Error) {
|
|
2738
|
+
return previewError(value, context, depth);
|
|
2739
|
+
}
|
|
2740
|
+
if (Array.isArray(value)) {
|
|
2741
|
+
return previewArray(value, context, depth);
|
|
2730
2742
|
}
|
|
2743
|
+
if (isElementLike(value)) {
|
|
2744
|
+
return elementLabel(value);
|
|
2745
|
+
}
|
|
2746
|
+
return previewRecord(value, context, depth);
|
|
2731
2747
|
}
|
|
2732
|
-
function
|
|
2733
|
-
|
|
2748
|
+
function previewArray(values, context, depth) {
|
|
2749
|
+
const result = values.slice(0, context.options.maxArrayItems).map((item) => previewValue(item, context, depth + 1, true) ?? null);
|
|
2750
|
+
if (values.length > context.options.maxArrayItems) {
|
|
2751
|
+
result.push(TRUNCATED_VALUE);
|
|
2752
|
+
}
|
|
2753
|
+
return result;
|
|
2734
2754
|
}
|
|
2735
|
-
function
|
|
2736
|
-
const keys =
|
|
2755
|
+
function previewRecord(value, context, depth) {
|
|
2756
|
+
const keys = enumerableKeys(value);
|
|
2737
2757
|
if (!keys) {
|
|
2738
|
-
return
|
|
2739
|
-
}
|
|
2740
|
-
if (keys.length === 0 && !isPlainRecord3(value)) {
|
|
2741
|
-
return toObjectSummary(value);
|
|
2758
|
+
return UNREADABLE_VALUE;
|
|
2742
2759
|
}
|
|
2743
2760
|
const result = {};
|
|
2744
|
-
keys.
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
const field = readObjectField(value, key);
|
|
2749
|
-
if (!field.ok) {
|
|
2750
|
-
result[key] = RPC_UNREADABLE_VALUE;
|
|
2751
|
-
return;
|
|
2752
|
-
}
|
|
2753
|
-
const safeValue = toRpcSafeChildValue(field.value, context, false);
|
|
2754
|
-
if (safeValue !== void 0) {
|
|
2755
|
-
result[key] = safeValue;
|
|
2756
|
-
}
|
|
2761
|
+
const limitedKeys = keys.filter((key) => key !== "toJSON");
|
|
2762
|
+
limitedKeys.slice(0, context.options.maxKeys).forEach((key) => {
|
|
2763
|
+
const field = readField(value, key);
|
|
2764
|
+
result[key] = field.ok ? previewValue(field.value, context, depth + 1, false) ?? null : UNREADABLE_VALUE;
|
|
2757
2765
|
});
|
|
2766
|
+
if (limitedKeys.length > context.options.maxKeys) {
|
|
2767
|
+
result[TRUNCATED_VALUE] = `${String(limitedKeys.length - context.options.maxKeys)} keys omitted`;
|
|
2768
|
+
}
|
|
2758
2769
|
return result;
|
|
2759
2770
|
}
|
|
2760
|
-
function
|
|
2771
|
+
function previewError(error, context, depth) {
|
|
2761
2772
|
const result = {
|
|
2762
2773
|
name: error.name,
|
|
2763
|
-
message: error.message
|
|
2774
|
+
message: truncateString(error.message, context.options.maxStringLength)
|
|
2764
2775
|
};
|
|
2765
|
-
const stack =
|
|
2776
|
+
const stack = readField(error, "stack");
|
|
2766
2777
|
if (stack.ok && typeof stack.value === "string") {
|
|
2767
|
-
result.stack = stack.value;
|
|
2778
|
+
result.stack = truncateString(stack.value, context.options.maxStringLength);
|
|
2768
2779
|
}
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
result.cause =
|
|
2780
|
+
const cause = readField(error, "cause");
|
|
2781
|
+
if (cause.ok && cause.value !== void 0) {
|
|
2782
|
+
result.cause = previewValue(cause.value, context, depth + 1, false) ?? null;
|
|
2772
2783
|
}
|
|
2773
2784
|
return result;
|
|
2774
2785
|
}
|
|
2775
|
-
function
|
|
2776
|
-
return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
|
|
2777
|
-
}
|
|
2778
|
-
function getEnumerableKeys(value) {
|
|
2786
|
+
function enumerableKeys(value) {
|
|
2779
2787
|
try {
|
|
2780
2788
|
return Object.keys(value);
|
|
2781
2789
|
} catch {
|
|
2782
2790
|
return void 0;
|
|
2783
2791
|
}
|
|
2784
2792
|
}
|
|
2785
|
-
function
|
|
2793
|
+
function readField(value, key) {
|
|
2786
2794
|
try {
|
|
2787
|
-
return {
|
|
2788
|
-
ok: true,
|
|
2789
|
-
value: value[key]
|
|
2790
|
-
};
|
|
2795
|
+
return { ok: true, value: value[key] };
|
|
2791
2796
|
} catch {
|
|
2792
2797
|
return { ok: false };
|
|
2793
2798
|
}
|
|
2794
2799
|
}
|
|
2795
|
-
function
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
return prototype === Object.prototype || prototype === null;
|
|
2799
|
-
} catch {
|
|
2800
|
-
return false;
|
|
2800
|
+
function truncateString(value, maxLength) {
|
|
2801
|
+
if (value.length <= maxLength) {
|
|
2802
|
+
return value;
|
|
2801
2803
|
}
|
|
2804
|
+
return `${value.slice(0, maxLength)}${TRUNCATED_VALUE}`;
|
|
2802
2805
|
}
|
|
2803
|
-
function
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2806
|
+
function functionLabel(value) {
|
|
2807
|
+
return value.name ? `[Function:${value.name}]` : "[Function]";
|
|
2808
|
+
}
|
|
2809
|
+
function objectLabel(value) {
|
|
2810
|
+
if (Array.isArray(value)) {
|
|
2811
|
+
return `[Array(${String(value.length)})]`;
|
|
2808
2812
|
}
|
|
2813
|
+
return "[Object]";
|
|
2809
2814
|
}
|
|
2810
|
-
function
|
|
2811
|
-
|
|
2815
|
+
function isElementLike(value) {
|
|
2816
|
+
const node = value;
|
|
2817
|
+
return node.nodeType === 1 && typeof node.nodeName === "string";
|
|
2818
|
+
}
|
|
2819
|
+
function elementLabel(value) {
|
|
2820
|
+
const name = value.nodeName.toLowerCase();
|
|
2821
|
+
const id = value.id ? `#${value.id}` : "";
|
|
2822
|
+
const className = typeof value.className === "string" && value.className ? `.${value.className.trim().replace(/\s+/g, ".")}` : "";
|
|
2823
|
+
return `[Element:${name}${id}${className}]`;
|
|
2812
2824
|
}
|
|
2813
2825
|
|
|
2814
2826
|
// src/cdp/cdpConsole.ts
|
|
@@ -3363,11 +3375,11 @@ import path4 from "path";
|
|
|
3363
3375
|
async function updateJsonMcpClientConfig(options) {
|
|
3364
3376
|
try {
|
|
3365
3377
|
const config = await readJsonConfig(options.configPath);
|
|
3366
|
-
if (!
|
|
3378
|
+
if (!isPlainRecord3(config)) {
|
|
3367
3379
|
warnConfigFailure(options, "config root must be a JSON object");
|
|
3368
3380
|
return;
|
|
3369
3381
|
}
|
|
3370
|
-
const mcpServers =
|
|
3382
|
+
const mcpServers = isPlainRecord3(config.mcpServers) ? config.mcpServers : {};
|
|
3371
3383
|
if (Object.hasOwn(mcpServers, options.serverName)) {
|
|
3372
3384
|
return;
|
|
3373
3385
|
}
|
|
@@ -3420,7 +3432,7 @@ async function readOptionalTextFile2(filePath) {
|
|
|
3420
3432
|
throw error;
|
|
3421
3433
|
}
|
|
3422
3434
|
}
|
|
3423
|
-
function
|
|
3435
|
+
function isPlainRecord3(value) {
|
|
3424
3436
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3425
3437
|
}
|
|
3426
3438
|
function warnConfigFailure(options, reason) {
|