@xiaou66/vite-plugin-vue-mcp-next 1.3.4 → 1.3.6

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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from 'vite';
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';
2
+ import { l as VueMcpNextOptions } from './types-Ct73MnH0.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-Ct73MnH0.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-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';
2
+ import { l as VueMcpNextOptions } from './types-Ct73MnH0.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-Ct73MnH0.js';
4
4
  import 'hookable';
5
5
 
6
6
  /**
package/dist/index.js CHANGED
@@ -2662,25 +2662,165 @@ function createServerVueRuntimeRpc(ctx) {
2662
2662
  import { nanoid as nanoid4 } from "nanoid";
2663
2663
 
2664
2664
  // src/shared/serialization.ts
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
+ );
2686
+ }
2665
2687
  function safeStringify(value) {
2666
2688
  if (typeof value === "string") {
2689
+ return truncateString(value, DEFAULT_PREVIEW_OPTIONS.maxStringLength);
2690
+ }
2691
+ const preview = createBoundedPreview(value);
2692
+ if (preview === void 0) {
2693
+ return "undefined";
2694
+ }
2695
+ return JSON.stringify(preview);
2696
+ }
2697
+ function previewValue(value, context, depth, arrayItem) {
2698
+ if (value === null) {
2699
+ return null;
2700
+ }
2701
+ switch (typeof value) {
2702
+ case "string":
2703
+ return truncateString(value, context.options.maxStringLength);
2704
+ case "number":
2705
+ return Number.isFinite(value) ? value : String(value);
2706
+ case "boolean":
2707
+ return value;
2708
+ case "bigint":
2709
+ return value.toString();
2710
+ case "symbol":
2711
+ return value.description ? `[Symbol(${value.description})]` : "[Symbol]";
2712
+ case "function":
2713
+ return functionLabel(value);
2714
+ case "undefined":
2715
+ return arrayItem ? null : void 0;
2716
+ case "object":
2717
+ return previewObject(value, context, depth);
2718
+ default:
2719
+ return arrayItem ? null : void 0;
2720
+ }
2721
+ }
2722
+ function previewObject(value, context, depth) {
2723
+ if (context.seen.has(value)) {
2724
+ return CIRCULAR_VALUE;
2725
+ }
2726
+ if (context.visited >= context.options.maxTotalNodes) {
2727
+ return TRUNCATED_VALUE;
2728
+ }
2729
+ if (depth >= context.options.maxDepth) {
2730
+ return objectLabel(value);
2731
+ }
2732
+ context.visited += 1;
2733
+ context.seen.add(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);
2742
+ }
2743
+ if (isElementLike(value)) {
2744
+ return elementLabel(value);
2745
+ }
2746
+ return previewRecord(value, context, depth);
2747
+ }
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;
2754
+ }
2755
+ function previewRecord(value, context, depth) {
2756
+ const keys = enumerableKeys(value);
2757
+ if (!keys) {
2758
+ return UNREADABLE_VALUE;
2759
+ }
2760
+ const result = {};
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;
2765
+ });
2766
+ if (limitedKeys.length > context.options.maxKeys) {
2767
+ result[TRUNCATED_VALUE] = `${String(limitedKeys.length - context.options.maxKeys)} keys omitted`;
2768
+ }
2769
+ return result;
2770
+ }
2771
+ function previewError(error, context, depth) {
2772
+ const result = {
2773
+ name: error.name,
2774
+ message: truncateString(error.message, context.options.maxStringLength)
2775
+ };
2776
+ const stack = readField(error, "stack");
2777
+ if (stack.ok && typeof stack.value === "string") {
2778
+ result.stack = truncateString(stack.value, context.options.maxStringLength);
2779
+ }
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;
2783
+ }
2784
+ return result;
2785
+ }
2786
+ function enumerableKeys(value) {
2787
+ try {
2788
+ return Object.keys(value);
2789
+ } catch {
2790
+ return void 0;
2791
+ }
2792
+ }
2793
+ function readField(value, key) {
2794
+ try {
2795
+ return { ok: true, value: value[key] };
2796
+ } catch {
2797
+ return { ok: false };
2798
+ }
2799
+ }
2800
+ function truncateString(value, maxLength) {
2801
+ if (value.length <= maxLength) {
2667
2802
  return value;
2668
2803
  }
2669
- const seen = /* @__PURE__ */ new WeakSet();
2670
- const serialized = JSON.stringify(
2671
- value,
2672
- (_key, current) => {
2673
- if (typeof current !== "object" || current === null) {
2674
- return current;
2675
- }
2676
- if (seen.has(current)) {
2677
- return "[Circular]";
2678
- }
2679
- seen.add(current);
2680
- return current;
2681
- }
2682
- );
2683
- return serialized;
2804
+ return `${value.slice(0, maxLength)}${TRUNCATED_VALUE}`;
2805
+ }
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)})]`;
2812
+ }
2813
+ return "[Object]";
2814
+ }
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}]`;
2684
2824
  }
2685
2825
 
2686
2826
  // src/cdp/cdpConsole.ts