@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/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2699,153 +2699,165 @@ function createServerVueRuntimeRpc(ctx) {
|
|
|
2699
2699
|
var import_nanoid4 = require("nanoid");
|
|
2700
2700
|
|
|
2701
2701
|
// src/shared/serialization.ts
|
|
2702
|
-
var
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2702
|
+
var DEFAULT_PREVIEW_OPTIONS = {
|
|
2703
|
+
maxDepth: 2,
|
|
2704
|
+
maxKeys: 20,
|
|
2705
|
+
maxArrayItems: 20,
|
|
2706
|
+
maxStringLength: 1e3,
|
|
2707
|
+
maxTotalNodes: 200
|
|
2708
|
+
};
|
|
2709
|
+
var CIRCULAR_VALUE = "[Circular]";
|
|
2710
|
+
var TRUNCATED_VALUE = "[Truncated]";
|
|
2711
|
+
var UNREADABLE_VALUE = "[Unreadable]";
|
|
2712
|
+
function createBoundedPreview(value, options = {}) {
|
|
2713
|
+
return previewValue(
|
|
2714
|
+
value,
|
|
2715
|
+
{
|
|
2716
|
+
options: { ...DEFAULT_PREVIEW_OPTIONS, ...options },
|
|
2717
|
+
seen: /* @__PURE__ */ new WeakSet(),
|
|
2718
|
+
visited: 0
|
|
2719
|
+
},
|
|
2720
|
+
0,
|
|
2721
|
+
false
|
|
2722
|
+
);
|
|
2706
2723
|
}
|
|
2707
2724
|
function safeStringify(value) {
|
|
2708
2725
|
if (typeof value === "string") {
|
|
2709
|
-
return value;
|
|
2726
|
+
return truncateString(value, DEFAULT_PREVIEW_OPTIONS.maxStringLength);
|
|
2710
2727
|
}
|
|
2711
|
-
const
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
return
|
|
2716
|
-
cache: /* @__PURE__ */ new WeakMap(),
|
|
2717
|
-
seen: /* @__PURE__ */ new WeakSet()
|
|
2718
|
-
};
|
|
2728
|
+
const preview = createBoundedPreview(value);
|
|
2729
|
+
if (preview === void 0) {
|
|
2730
|
+
return "undefined";
|
|
2731
|
+
}
|
|
2732
|
+
return JSON.stringify(preview);
|
|
2719
2733
|
}
|
|
2720
|
-
function
|
|
2734
|
+
function previewValue(value, context, depth, arrayItem) {
|
|
2721
2735
|
if (value === null) {
|
|
2722
2736
|
return null;
|
|
2723
2737
|
}
|
|
2724
2738
|
switch (typeof value) {
|
|
2725
2739
|
case "string":
|
|
2726
|
-
|
|
2727
|
-
return value;
|
|
2740
|
+
return truncateString(value, context.options.maxStringLength);
|
|
2728
2741
|
case "number":
|
|
2729
2742
|
return Number.isFinite(value) ? value : String(value);
|
|
2743
|
+
case "boolean":
|
|
2744
|
+
return value;
|
|
2730
2745
|
case "bigint":
|
|
2731
2746
|
return value.toString();
|
|
2732
2747
|
case "symbol":
|
|
2733
|
-
return
|
|
2734
|
-
case "undefined":
|
|
2748
|
+
return value.description ? `[Symbol(${value.description})]` : "[Symbol]";
|
|
2735
2749
|
case "function":
|
|
2750
|
+
return functionLabel(value);
|
|
2751
|
+
case "undefined":
|
|
2736
2752
|
return arrayItem ? null : void 0;
|
|
2737
2753
|
case "object":
|
|
2738
|
-
return
|
|
2754
|
+
return previewObject(value, context, depth);
|
|
2739
2755
|
default:
|
|
2740
2756
|
return arrayItem ? null : void 0;
|
|
2741
2757
|
}
|
|
2742
2758
|
}
|
|
2743
|
-
function
|
|
2759
|
+
function previewObject(value, context, depth) {
|
|
2744
2760
|
if (context.seen.has(value)) {
|
|
2745
|
-
return
|
|
2761
|
+
return CIRCULAR_VALUE;
|
|
2762
|
+
}
|
|
2763
|
+
if (context.visited >= context.options.maxTotalNodes) {
|
|
2764
|
+
return TRUNCATED_VALUE;
|
|
2746
2765
|
}
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
return cached;
|
|
2766
|
+
if (depth >= context.options.maxDepth) {
|
|
2767
|
+
return objectLabel(value);
|
|
2750
2768
|
}
|
|
2769
|
+
context.visited += 1;
|
|
2751
2770
|
context.seen.add(value);
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
} else {
|
|
2761
|
-
safeValue = toSafeRecord(value, context);
|
|
2762
|
-
}
|
|
2763
|
-
context.cache.set(value, safeValue);
|
|
2764
|
-
return safeValue;
|
|
2765
|
-
} finally {
|
|
2766
|
-
context.seen.delete(value);
|
|
2771
|
+
if (value instanceof Date) {
|
|
2772
|
+
return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
|
|
2773
|
+
}
|
|
2774
|
+
if (value instanceof Error) {
|
|
2775
|
+
return previewError(value, context, depth);
|
|
2776
|
+
}
|
|
2777
|
+
if (Array.isArray(value)) {
|
|
2778
|
+
return previewArray(value, context, depth);
|
|
2767
2779
|
}
|
|
2780
|
+
if (isElementLike(value)) {
|
|
2781
|
+
return elementLabel(value);
|
|
2782
|
+
}
|
|
2783
|
+
return previewRecord(value, context, depth);
|
|
2768
2784
|
}
|
|
2769
|
-
function
|
|
2770
|
-
|
|
2785
|
+
function previewArray(values, context, depth) {
|
|
2786
|
+
const result = values.slice(0, context.options.maxArrayItems).map((item) => previewValue(item, context, depth + 1, true) ?? null);
|
|
2787
|
+
if (values.length > context.options.maxArrayItems) {
|
|
2788
|
+
result.push(TRUNCATED_VALUE);
|
|
2789
|
+
}
|
|
2790
|
+
return result;
|
|
2771
2791
|
}
|
|
2772
|
-
function
|
|
2773
|
-
const keys =
|
|
2792
|
+
function previewRecord(value, context, depth) {
|
|
2793
|
+
const keys = enumerableKeys(value);
|
|
2774
2794
|
if (!keys) {
|
|
2775
|
-
return
|
|
2776
|
-
}
|
|
2777
|
-
if (keys.length === 0 && !isPlainRecord3(value)) {
|
|
2778
|
-
return toObjectSummary(value);
|
|
2795
|
+
return UNREADABLE_VALUE;
|
|
2779
2796
|
}
|
|
2780
2797
|
const result = {};
|
|
2781
|
-
keys.
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
const field = readObjectField(value, key);
|
|
2786
|
-
if (!field.ok) {
|
|
2787
|
-
result[key] = RPC_UNREADABLE_VALUE;
|
|
2788
|
-
return;
|
|
2789
|
-
}
|
|
2790
|
-
const safeValue = toRpcSafeChildValue(field.value, context, false);
|
|
2791
|
-
if (safeValue !== void 0) {
|
|
2792
|
-
result[key] = safeValue;
|
|
2793
|
-
}
|
|
2798
|
+
const limitedKeys = keys.filter((key) => key !== "toJSON");
|
|
2799
|
+
limitedKeys.slice(0, context.options.maxKeys).forEach((key) => {
|
|
2800
|
+
const field = readField(value, key);
|
|
2801
|
+
result[key] = field.ok ? previewValue(field.value, context, depth + 1, false) ?? null : UNREADABLE_VALUE;
|
|
2794
2802
|
});
|
|
2803
|
+
if (limitedKeys.length > context.options.maxKeys) {
|
|
2804
|
+
result[TRUNCATED_VALUE] = `${String(limitedKeys.length - context.options.maxKeys)} keys omitted`;
|
|
2805
|
+
}
|
|
2795
2806
|
return result;
|
|
2796
2807
|
}
|
|
2797
|
-
function
|
|
2808
|
+
function previewError(error, context, depth) {
|
|
2798
2809
|
const result = {
|
|
2799
2810
|
name: error.name,
|
|
2800
|
-
message: error.message
|
|
2811
|
+
message: truncateString(error.message, context.options.maxStringLength)
|
|
2801
2812
|
};
|
|
2802
|
-
const stack =
|
|
2813
|
+
const stack = readField(error, "stack");
|
|
2803
2814
|
if (stack.ok && typeof stack.value === "string") {
|
|
2804
|
-
result.stack = stack.value;
|
|
2815
|
+
result.stack = truncateString(stack.value, context.options.maxStringLength);
|
|
2805
2816
|
}
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
result.cause =
|
|
2817
|
+
const cause = readField(error, "cause");
|
|
2818
|
+
if (cause.ok && cause.value !== void 0) {
|
|
2819
|
+
result.cause = previewValue(cause.value, context, depth + 1, false) ?? null;
|
|
2809
2820
|
}
|
|
2810
2821
|
return result;
|
|
2811
2822
|
}
|
|
2812
|
-
function
|
|
2813
|
-
return Number.isNaN(value.getTime()) ? "Invalid Date" : value.toISOString();
|
|
2814
|
-
}
|
|
2815
|
-
function getEnumerableKeys(value) {
|
|
2823
|
+
function enumerableKeys(value) {
|
|
2816
2824
|
try {
|
|
2817
2825
|
return Object.keys(value);
|
|
2818
2826
|
} catch {
|
|
2819
2827
|
return void 0;
|
|
2820
2828
|
}
|
|
2821
2829
|
}
|
|
2822
|
-
function
|
|
2830
|
+
function readField(value, key) {
|
|
2823
2831
|
try {
|
|
2824
|
-
return {
|
|
2825
|
-
ok: true,
|
|
2826
|
-
value: value[key]
|
|
2827
|
-
};
|
|
2832
|
+
return { ok: true, value: value[key] };
|
|
2828
2833
|
} catch {
|
|
2829
2834
|
return { ok: false };
|
|
2830
2835
|
}
|
|
2831
2836
|
}
|
|
2832
|
-
function
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
return prototype === Object.prototype || prototype === null;
|
|
2836
|
-
} catch {
|
|
2837
|
-
return false;
|
|
2837
|
+
function truncateString(value, maxLength) {
|
|
2838
|
+
if (value.length <= maxLength) {
|
|
2839
|
+
return value;
|
|
2838
2840
|
}
|
|
2841
|
+
return `${value.slice(0, maxLength)}${TRUNCATED_VALUE}`;
|
|
2839
2842
|
}
|
|
2840
|
-
function
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2843
|
+
function functionLabel(value) {
|
|
2844
|
+
return value.name ? `[Function:${value.name}]` : "[Function]";
|
|
2845
|
+
}
|
|
2846
|
+
function objectLabel(value) {
|
|
2847
|
+
if (Array.isArray(value)) {
|
|
2848
|
+
return `[Array(${String(value.length)})]`;
|
|
2845
2849
|
}
|
|
2850
|
+
return "[Object]";
|
|
2846
2851
|
}
|
|
2847
|
-
function
|
|
2848
|
-
|
|
2852
|
+
function isElementLike(value) {
|
|
2853
|
+
const node = value;
|
|
2854
|
+
return node.nodeType === 1 && typeof node.nodeName === "string";
|
|
2855
|
+
}
|
|
2856
|
+
function elementLabel(value) {
|
|
2857
|
+
const name = value.nodeName.toLowerCase();
|
|
2858
|
+
const id = value.id ? `#${value.id}` : "";
|
|
2859
|
+
const className = typeof value.className === "string" && value.className ? `.${value.className.trim().replace(/\s+/g, ".")}` : "";
|
|
2860
|
+
return `[Element:${name}${id}${className}]`;
|
|
2849
2861
|
}
|
|
2850
2862
|
|
|
2851
2863
|
// src/cdp/cdpConsole.ts
|
|
@@ -3400,11 +3412,11 @@ var import_node_path7 = __toESM(require("path"), 1);
|
|
|
3400
3412
|
async function updateJsonMcpClientConfig(options) {
|
|
3401
3413
|
try {
|
|
3402
3414
|
const config = await readJsonConfig(options.configPath);
|
|
3403
|
-
if (!
|
|
3415
|
+
if (!isPlainRecord3(config)) {
|
|
3404
3416
|
warnConfigFailure(options, "config root must be a JSON object");
|
|
3405
3417
|
return;
|
|
3406
3418
|
}
|
|
3407
|
-
const mcpServers =
|
|
3419
|
+
const mcpServers = isPlainRecord3(config.mcpServers) ? config.mcpServers : {};
|
|
3408
3420
|
if (Object.hasOwn(mcpServers, options.serverName)) {
|
|
3409
3421
|
return;
|
|
3410
3422
|
}
|
|
@@ -3457,7 +3469,7 @@ async function readOptionalTextFile2(filePath) {
|
|
|
3457
3469
|
throw error;
|
|
3458
3470
|
}
|
|
3459
3471
|
}
|
|
3460
|
-
function
|
|
3472
|
+
function isPlainRecord3(value) {
|
|
3461
3473
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3462
3474
|
}
|
|
3463
3475
|
function warnConfigFailure(options, reason) {
|