@xiaou66/vite-plugin-vue-mcp-next 1.3.4 → 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/dist/index.cjs +155 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +155 -15
- package/dist/index.js.map +1 -1
- package/dist/runtime/client.cjs +237 -20
- package/dist/runtime/client.cjs.map +1 -1
- package/dist/runtime/client.js +237 -20
- package/dist/runtime/client.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2699,25 +2699,165 @@ function createServerVueRuntimeRpc(ctx) {
|
|
|
2699
2699
|
var import_nanoid4 = require("nanoid");
|
|
2700
2700
|
|
|
2701
2701
|
// src/shared/serialization.ts
|
|
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
|
+
);
|
|
2723
|
+
}
|
|
2702
2724
|
function safeStringify(value) {
|
|
2703
2725
|
if (typeof value === "string") {
|
|
2726
|
+
return truncateString(value, DEFAULT_PREVIEW_OPTIONS.maxStringLength);
|
|
2727
|
+
}
|
|
2728
|
+
const preview = createBoundedPreview(value);
|
|
2729
|
+
if (preview === void 0) {
|
|
2730
|
+
return "undefined";
|
|
2731
|
+
}
|
|
2732
|
+
return JSON.stringify(preview);
|
|
2733
|
+
}
|
|
2734
|
+
function previewValue(value, context, depth, arrayItem) {
|
|
2735
|
+
if (value === null) {
|
|
2736
|
+
return null;
|
|
2737
|
+
}
|
|
2738
|
+
switch (typeof value) {
|
|
2739
|
+
case "string":
|
|
2740
|
+
return truncateString(value, context.options.maxStringLength);
|
|
2741
|
+
case "number":
|
|
2742
|
+
return Number.isFinite(value) ? value : String(value);
|
|
2743
|
+
case "boolean":
|
|
2744
|
+
return value;
|
|
2745
|
+
case "bigint":
|
|
2746
|
+
return value.toString();
|
|
2747
|
+
case "symbol":
|
|
2748
|
+
return value.description ? `[Symbol(${value.description})]` : "[Symbol]";
|
|
2749
|
+
case "function":
|
|
2750
|
+
return functionLabel(value);
|
|
2751
|
+
case "undefined":
|
|
2752
|
+
return arrayItem ? null : void 0;
|
|
2753
|
+
case "object":
|
|
2754
|
+
return previewObject(value, context, depth);
|
|
2755
|
+
default:
|
|
2756
|
+
return arrayItem ? null : void 0;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
function previewObject(value, context, depth) {
|
|
2760
|
+
if (context.seen.has(value)) {
|
|
2761
|
+
return CIRCULAR_VALUE;
|
|
2762
|
+
}
|
|
2763
|
+
if (context.visited >= context.options.maxTotalNodes) {
|
|
2764
|
+
return TRUNCATED_VALUE;
|
|
2765
|
+
}
|
|
2766
|
+
if (depth >= context.options.maxDepth) {
|
|
2767
|
+
return objectLabel(value);
|
|
2768
|
+
}
|
|
2769
|
+
context.visited += 1;
|
|
2770
|
+
context.seen.add(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);
|
|
2779
|
+
}
|
|
2780
|
+
if (isElementLike(value)) {
|
|
2781
|
+
return elementLabel(value);
|
|
2782
|
+
}
|
|
2783
|
+
return previewRecord(value, context, depth);
|
|
2784
|
+
}
|
|
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;
|
|
2791
|
+
}
|
|
2792
|
+
function previewRecord(value, context, depth) {
|
|
2793
|
+
const keys = enumerableKeys(value);
|
|
2794
|
+
if (!keys) {
|
|
2795
|
+
return UNREADABLE_VALUE;
|
|
2796
|
+
}
|
|
2797
|
+
const result = {};
|
|
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;
|
|
2802
|
+
});
|
|
2803
|
+
if (limitedKeys.length > context.options.maxKeys) {
|
|
2804
|
+
result[TRUNCATED_VALUE] = `${String(limitedKeys.length - context.options.maxKeys)} keys omitted`;
|
|
2805
|
+
}
|
|
2806
|
+
return result;
|
|
2807
|
+
}
|
|
2808
|
+
function previewError(error, context, depth) {
|
|
2809
|
+
const result = {
|
|
2810
|
+
name: error.name,
|
|
2811
|
+
message: truncateString(error.message, context.options.maxStringLength)
|
|
2812
|
+
};
|
|
2813
|
+
const stack = readField(error, "stack");
|
|
2814
|
+
if (stack.ok && typeof stack.value === "string") {
|
|
2815
|
+
result.stack = truncateString(stack.value, context.options.maxStringLength);
|
|
2816
|
+
}
|
|
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;
|
|
2820
|
+
}
|
|
2821
|
+
return result;
|
|
2822
|
+
}
|
|
2823
|
+
function enumerableKeys(value) {
|
|
2824
|
+
try {
|
|
2825
|
+
return Object.keys(value);
|
|
2826
|
+
} catch {
|
|
2827
|
+
return void 0;
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
function readField(value, key) {
|
|
2831
|
+
try {
|
|
2832
|
+
return { ok: true, value: value[key] };
|
|
2833
|
+
} catch {
|
|
2834
|
+
return { ok: false };
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
function truncateString(value, maxLength) {
|
|
2838
|
+
if (value.length <= maxLength) {
|
|
2704
2839
|
return value;
|
|
2705
2840
|
}
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2841
|
+
return `${value.slice(0, maxLength)}${TRUNCATED_VALUE}`;
|
|
2842
|
+
}
|
|
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)})]`;
|
|
2849
|
+
}
|
|
2850
|
+
return "[Object]";
|
|
2851
|
+
}
|
|
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}]`;
|
|
2721
2861
|
}
|
|
2722
2862
|
|
|
2723
2863
|
// src/cdp/cdpConsole.ts
|