@visual-agentic-dev/react-devtools 1.1.4

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.
@@ -0,0 +1,12 @@
1
+ import * as _babel_core from '@babel/core';
2
+ import { PluginObj } from '@babel/core';
3
+
4
+ interface PluginOptions {
5
+ /** Prefix for the data attribute (default: 'vdev') */
6
+ prefix?: string;
7
+ /** File patterns to exclude */
8
+ exclude?: RegExp[];
9
+ }
10
+ declare const _default: (api: object, options: PluginOptions | null | undefined, dirname: string) => PluginObj<_babel_core.PluginPass>;
11
+
12
+ export { _default as default };
@@ -0,0 +1,12 @@
1
+ import * as _babel_core from '@babel/core';
2
+ import { PluginObj } from '@babel/core';
3
+
4
+ interface PluginOptions {
5
+ /** Prefix for the data attribute (default: 'vdev') */
6
+ prefix?: string;
7
+ /** File patterns to exclude */
8
+ exclude?: RegExp[];
9
+ }
10
+ declare const _default: (api: object, options: PluginOptions | null | undefined, dirname: string) => PluginObj<_babel_core.PluginPass>;
11
+
12
+ export { _default as default };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/babel-plugin/jsx-source.ts
31
+ var jsx_source_exports = {};
32
+ __export(jsx_source_exports, {
33
+ default: () => jsx_source_default
34
+ });
35
+ module.exports = __toCommonJS(jsx_source_exports);
36
+ var import_helper_plugin_utils = require("@babel/helper-plugin-utils");
37
+ var t = __toESM(require("@babel/types"));
38
+ var jsx_source_default = (0, import_helper_plugin_utils.declare)((api, options) => {
39
+ api.assertVersion(7);
40
+ const prefix = options.prefix || "vdev";
41
+ const exclude = options.exclude || [/node_modules/];
42
+ return {
43
+ name: "visual-agentic-dev-jsx-source",
44
+ visitor: {
45
+ JSXOpeningElement(path, state) {
46
+ const filename = state.filename || "";
47
+ if (exclude.some((pattern) => pattern.test(filename))) {
48
+ return;
49
+ }
50
+ const { line, column } = path.node.loc?.start || {};
51
+ if (!filename || line === void 0) return;
52
+ const hasAttr = path.node.attributes.some(
53
+ (attr) => t.isJSXAttribute(attr) && (attr.name.name === `data-${prefix}-file` || attr.name.name === `data-${prefix}-source`)
54
+ );
55
+ if (hasAttr) return;
56
+ const fileAttr = t.jsxAttribute(
57
+ t.jsxIdentifier(`data-${prefix}-file`),
58
+ t.stringLiteral(filename)
59
+ );
60
+ const lineAttr = t.jsxAttribute(
61
+ t.jsxIdentifier(`data-${prefix}-line`),
62
+ t.stringLiteral(String(line))
63
+ );
64
+ const colAttr = t.jsxAttribute(
65
+ t.jsxIdentifier(`data-${prefix}-col`),
66
+ t.stringLiteral(String(column))
67
+ );
68
+ path.node.attributes.push(fileAttr, lineAttr, colAttr);
69
+ }
70
+ }
71
+ };
72
+ });
73
+ //# sourceMappingURL=jsx-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/babel-plugin/jsx-source.ts"],"sourcesContent":["import { declare } from '@babel/helper-plugin-utils';\nimport type { PluginObj, NodePath } from '@babel/core';\nimport * as t from '@babel/types';\n\ninterface PluginOptions {\n /** Prefix for the data attribute (default: 'vdev') */\n prefix?: string;\n /** File patterns to exclude */\n exclude?: RegExp[];\n}\n\nexport default declare((api, options: PluginOptions): PluginObj => {\n api.assertVersion(7);\n\n const prefix = options.prefix || 'vdev';\n const exclude = options.exclude || [/node_modules/];\n\n return {\n name: 'visual-agentic-dev-jsx-source',\n visitor: {\n JSXOpeningElement(path: NodePath<t.JSXOpeningElement>, state) {\n const filename = state.filename || '';\n\n // Check if file should be excluded\n if (exclude.some(pattern => pattern.test(filename))) {\n return;\n }\n\n const { line, column } = path.node.loc?.start || {};\n\n if (!filename || line === undefined) return;\n\n // Check if attribute already exists\n const hasAttr = path.node.attributes.some(\n attr => t.isJSXAttribute(attr) &&\n (attr.name.name === `data-${prefix}-file` ||\n attr.name.name === `data-${prefix}-source`)\n );\n\n if (hasAttr) return;\n\n // Use separate attributes to avoid JSON escaping issues with esbuild\n // Format: data-vdev-file, data-vdev-line, data-vdev-col\n const fileAttr = t.jsxAttribute(\n t.jsxIdentifier(`data-${prefix}-file`),\n t.stringLiteral(filename)\n );\n\n const lineAttr = t.jsxAttribute(\n t.jsxIdentifier(`data-${prefix}-line`),\n t.stringLiteral(String(line))\n );\n\n const colAttr = t.jsxAttribute(\n t.jsxIdentifier(`data-${prefix}-col`),\n t.stringLiteral(String(column))\n );\n\n path.node.attributes.push(fileAttr, lineAttr, colAttr);\n },\n },\n };\n});\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAwB;AAExB,QAAmB;AASnB,IAAO,yBAAQ,oCAAQ,CAAC,KAAK,YAAsC;AAC/D,MAAI,cAAc,CAAC;AAEnB,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,UAAU,QAAQ,WAAW,CAAC,cAAc;AAElD,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,MACL,kBAAkB,MAAqC,OAAO;AAC1D,cAAM,WAAW,MAAM,YAAY;AAGnC,YAAI,QAAQ,KAAK,aAAW,QAAQ,KAAK,QAAQ,CAAC,GAAG;AACjD;AAAA,QACJ;AAEA,cAAM,EAAE,MAAM,OAAO,IAAI,KAAK,KAAK,KAAK,SAAS,CAAC;AAElD,YAAI,CAAC,YAAY,SAAS,OAAW;AAGrC,cAAM,UAAU,KAAK,KAAK,WAAW;AAAA,UACjC,UAAU,iBAAe,IAAI,MACxB,KAAK,KAAK,SAAS,QAAQ,MAAM,WAC9B,KAAK,KAAK,SAAS,QAAQ,MAAM;AAAA,QAC7C;AAEA,YAAI,QAAS;AAIb,cAAM,WAAa;AAAA,UACb,gBAAc,QAAQ,MAAM,OAAO;AAAA,UACnC,gBAAc,QAAQ;AAAA,QAC5B;AAEA,cAAM,WAAa;AAAA,UACb,gBAAc,QAAQ,MAAM,OAAO;AAAA,UACnC,gBAAc,OAAO,IAAI,CAAC;AAAA,QAChC;AAEA,cAAM,UAAY;AAAA,UACZ,gBAAc,QAAQ,MAAM,MAAM;AAAA,UAClC,gBAAc,OAAO,MAAM,CAAC;AAAA,QAClC;AAEA,aAAK,KAAK,WAAW,KAAK,UAAU,UAAU,OAAO;AAAA,MACzD;AAAA,IACJ;AAAA,EACJ;AACJ,CAAC;","names":[]}
@@ -0,0 +1,42 @@
1
+ // src/babel-plugin/jsx-source.ts
2
+ import { declare } from "@babel/helper-plugin-utils";
3
+ import * as t from "@babel/types";
4
+ var jsx_source_default = declare((api, options) => {
5
+ api.assertVersion(7);
6
+ const prefix = options.prefix || "vdev";
7
+ const exclude = options.exclude || [/node_modules/];
8
+ return {
9
+ name: "visual-agentic-dev-jsx-source",
10
+ visitor: {
11
+ JSXOpeningElement(path, state) {
12
+ const filename = state.filename || "";
13
+ if (exclude.some((pattern) => pattern.test(filename))) {
14
+ return;
15
+ }
16
+ const { line, column } = path.node.loc?.start || {};
17
+ if (!filename || line === void 0) return;
18
+ const hasAttr = path.node.attributes.some(
19
+ (attr) => t.isJSXAttribute(attr) && (attr.name.name === `data-${prefix}-file` || attr.name.name === `data-${prefix}-source`)
20
+ );
21
+ if (hasAttr) return;
22
+ const fileAttr = t.jsxAttribute(
23
+ t.jsxIdentifier(`data-${prefix}-file`),
24
+ t.stringLiteral(filename)
25
+ );
26
+ const lineAttr = t.jsxAttribute(
27
+ t.jsxIdentifier(`data-${prefix}-line`),
28
+ t.stringLiteral(String(line))
29
+ );
30
+ const colAttr = t.jsxAttribute(
31
+ t.jsxIdentifier(`data-${prefix}-col`),
32
+ t.stringLiteral(String(column))
33
+ );
34
+ path.node.attributes.push(fileAttr, lineAttr, colAttr);
35
+ }
36
+ }
37
+ };
38
+ });
39
+ export {
40
+ jsx_source_default as default
41
+ };
42
+ //# sourceMappingURL=jsx-source.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/babel-plugin/jsx-source.ts"],"sourcesContent":["import { declare } from '@babel/helper-plugin-utils';\nimport type { PluginObj, NodePath } from '@babel/core';\nimport * as t from '@babel/types';\n\ninterface PluginOptions {\n /** Prefix for the data attribute (default: 'vdev') */\n prefix?: string;\n /** File patterns to exclude */\n exclude?: RegExp[];\n}\n\nexport default declare((api, options: PluginOptions): PluginObj => {\n api.assertVersion(7);\n\n const prefix = options.prefix || 'vdev';\n const exclude = options.exclude || [/node_modules/];\n\n return {\n name: 'visual-agentic-dev-jsx-source',\n visitor: {\n JSXOpeningElement(path: NodePath<t.JSXOpeningElement>, state) {\n const filename = state.filename || '';\n\n // Check if file should be excluded\n if (exclude.some(pattern => pattern.test(filename))) {\n return;\n }\n\n const { line, column } = path.node.loc?.start || {};\n\n if (!filename || line === undefined) return;\n\n // Check if attribute already exists\n const hasAttr = path.node.attributes.some(\n attr => t.isJSXAttribute(attr) &&\n (attr.name.name === `data-${prefix}-file` ||\n attr.name.name === `data-${prefix}-source`)\n );\n\n if (hasAttr) return;\n\n // Use separate attributes to avoid JSON escaping issues with esbuild\n // Format: data-vdev-file, data-vdev-line, data-vdev-col\n const fileAttr = t.jsxAttribute(\n t.jsxIdentifier(`data-${prefix}-file`),\n t.stringLiteral(filename)\n );\n\n const lineAttr = t.jsxAttribute(\n t.jsxIdentifier(`data-${prefix}-line`),\n t.stringLiteral(String(line))\n );\n\n const colAttr = t.jsxAttribute(\n t.jsxIdentifier(`data-${prefix}-col`),\n t.stringLiteral(String(column))\n );\n\n path.node.attributes.push(fileAttr, lineAttr, colAttr);\n },\n },\n };\n});\n\n"],"mappings":";AAAA,SAAS,eAAe;AAExB,YAAY,OAAO;AASnB,IAAO,qBAAQ,QAAQ,CAAC,KAAK,YAAsC;AAC/D,MAAI,cAAc,CAAC;AAEnB,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,UAAU,QAAQ,WAAW,CAAC,cAAc;AAElD,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,MACL,kBAAkB,MAAqC,OAAO;AAC1D,cAAM,WAAW,MAAM,YAAY;AAGnC,YAAI,QAAQ,KAAK,aAAW,QAAQ,KAAK,QAAQ,CAAC,GAAG;AACjD;AAAA,QACJ;AAEA,cAAM,EAAE,MAAM,OAAO,IAAI,KAAK,KAAK,KAAK,SAAS,CAAC;AAElD,YAAI,CAAC,YAAY,SAAS,OAAW;AAGrC,cAAM,UAAU,KAAK,KAAK,WAAW;AAAA,UACjC,UAAU,iBAAe,IAAI,MACxB,KAAK,KAAK,SAAS,QAAQ,MAAM,WAC9B,KAAK,KAAK,SAAS,QAAQ,MAAM;AAAA,QAC7C;AAEA,YAAI,QAAS;AAIb,cAAM,WAAa;AAAA,UACb,gBAAc,QAAQ,MAAM,OAAO;AAAA,UACnC,gBAAc,QAAQ;AAAA,QAC5B;AAEA,cAAM,WAAa;AAAA,UACb,gBAAc,QAAQ,MAAM,OAAO;AAAA,UACnC,gBAAc,OAAO,IAAI,CAAC;AAAA,QAChC;AAEA,cAAM,UAAY;AAAA,UACZ,gBAAc,QAAQ,MAAM,MAAM;AAAA,UAClC,gBAAc,OAAO,MAAM,CAAC;AAAA,QAClC;AAEA,aAAK,KAAK,WAAW,KAAK,UAAU,UAAU,OAAO;AAAA,MACzD;AAAA,IACJ;AAAA,EACJ;AACJ,CAAC;","names":[]}
@@ -0,0 +1,87 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ interface SourceLocation {
4
+ fileName: string;
5
+ lineNumber: number;
6
+ columnNumber: number;
7
+ }
8
+ interface ElementInfo {
9
+ tagName: string;
10
+ className: string;
11
+ textContent: string;
12
+ }
13
+ interface VDevMessage {
14
+ type: string;
15
+ source?: string;
16
+ payload?: unknown;
17
+ }
18
+ interface ElementSelectedPayload {
19
+ source: SourceLocation;
20
+ elementInfo: ElementInfo;
21
+ }
22
+
23
+ interface DevToolsContextValue {
24
+ isInspecting: boolean;
25
+ setInspecting: (v: boolean) => void;
26
+ selectedElement: HTMLElement | null;
27
+ selectedSource: SourceLocation | null;
28
+ clearSelection: () => void;
29
+ }
30
+ declare const useDevTools: () => DevToolsContextValue;
31
+ interface DevToolsProviderProps {
32
+ children: ReactNode;
33
+ /** Only enable in development mode (default: true) */
34
+ enabled?: boolean;
35
+ /** Attribute prefix (default: 'vdev') */
36
+ prefix?: string;
37
+ }
38
+ declare const DevToolsProvider: React.FC<DevToolsProviderProps>;
39
+
40
+ interface Props$1 {
41
+ element: HTMLElement;
42
+ color?: string;
43
+ }
44
+ /**
45
+ * Highlighter overlay component - shows a blue overlay on hovered elements
46
+ */
47
+ declare const Highlighter: React.FC<Props$1>;
48
+
49
+ interface Props {
50
+ element: HTMLElement;
51
+ prefix?: string;
52
+ }
53
+ /**
54
+ * SelectionBox component - shows a persistent selection box with source info label
55
+ */
56
+ declare const SelectionBox: React.FC<Props>;
57
+
58
+ /**
59
+ * Parse the data-vdev-source attribute value into a SourceLocation object
60
+ * (Legacy support for projects using the babel/vite plugin)
61
+ */
62
+ declare function parseSourceAttr(attrValue: string | null): SourceLocation | null;
63
+ /**
64
+ * Find the closest element with source information
65
+ * First tries React Fiber (runtime), then falls back to data attributes
66
+ */
67
+ declare function findSourceElement(target: HTMLElement, prefix?: string): HTMLElement | null;
68
+ /**
69
+ * Get source location from an element
70
+ * Prioritizes React Fiber _debugSource, falls back to data attributes
71
+ */
72
+ declare function getSourceFromElement(element: HTMLElement, prefix?: string): SourceLocation | null;
73
+
74
+ /**
75
+ * Send a message to the Chrome extension via window.postMessage
76
+ */
77
+ declare function sendToExtension(message: VDevMessage): void;
78
+ /**
79
+ * Notify extension that SDK is ready
80
+ */
81
+ declare function notifyReady(): void;
82
+ /**
83
+ * Create a message handler that only processes messages from the extension
84
+ */
85
+ declare function createMessageHandler(handler: (message: VDevMessage) => void): (event: MessageEvent) => void;
86
+
87
+ export { DevToolsProvider, type ElementInfo, type ElementSelectedPayload, Highlighter, SelectionBox, type SourceLocation, type VDevMessage, createMessageHandler, findSourceElement, getSourceFromElement, notifyReady, parseSourceAttr, sendToExtension, useDevTools };
@@ -0,0 +1,87 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ interface SourceLocation {
4
+ fileName: string;
5
+ lineNumber: number;
6
+ columnNumber: number;
7
+ }
8
+ interface ElementInfo {
9
+ tagName: string;
10
+ className: string;
11
+ textContent: string;
12
+ }
13
+ interface VDevMessage {
14
+ type: string;
15
+ source?: string;
16
+ payload?: unknown;
17
+ }
18
+ interface ElementSelectedPayload {
19
+ source: SourceLocation;
20
+ elementInfo: ElementInfo;
21
+ }
22
+
23
+ interface DevToolsContextValue {
24
+ isInspecting: boolean;
25
+ setInspecting: (v: boolean) => void;
26
+ selectedElement: HTMLElement | null;
27
+ selectedSource: SourceLocation | null;
28
+ clearSelection: () => void;
29
+ }
30
+ declare const useDevTools: () => DevToolsContextValue;
31
+ interface DevToolsProviderProps {
32
+ children: ReactNode;
33
+ /** Only enable in development mode (default: true) */
34
+ enabled?: boolean;
35
+ /** Attribute prefix (default: 'vdev') */
36
+ prefix?: string;
37
+ }
38
+ declare const DevToolsProvider: React.FC<DevToolsProviderProps>;
39
+
40
+ interface Props$1 {
41
+ element: HTMLElement;
42
+ color?: string;
43
+ }
44
+ /**
45
+ * Highlighter overlay component - shows a blue overlay on hovered elements
46
+ */
47
+ declare const Highlighter: React.FC<Props$1>;
48
+
49
+ interface Props {
50
+ element: HTMLElement;
51
+ prefix?: string;
52
+ }
53
+ /**
54
+ * SelectionBox component - shows a persistent selection box with source info label
55
+ */
56
+ declare const SelectionBox: React.FC<Props>;
57
+
58
+ /**
59
+ * Parse the data-vdev-source attribute value into a SourceLocation object
60
+ * (Legacy support for projects using the babel/vite plugin)
61
+ */
62
+ declare function parseSourceAttr(attrValue: string | null): SourceLocation | null;
63
+ /**
64
+ * Find the closest element with source information
65
+ * First tries React Fiber (runtime), then falls back to data attributes
66
+ */
67
+ declare function findSourceElement(target: HTMLElement, prefix?: string): HTMLElement | null;
68
+ /**
69
+ * Get source location from an element
70
+ * Prioritizes React Fiber _debugSource, falls back to data attributes
71
+ */
72
+ declare function getSourceFromElement(element: HTMLElement, prefix?: string): SourceLocation | null;
73
+
74
+ /**
75
+ * Send a message to the Chrome extension via window.postMessage
76
+ */
77
+ declare function sendToExtension(message: VDevMessage): void;
78
+ /**
79
+ * Notify extension that SDK is ready
80
+ */
81
+ declare function notifyReady(): void;
82
+ /**
83
+ * Create a message handler that only processes messages from the extension
84
+ */
85
+ declare function createMessageHandler(handler: (message: VDevMessage) => void): (event: MessageEvent) => void;
86
+
87
+ export { DevToolsProvider, type ElementInfo, type ElementSelectedPayload, Highlighter, SelectionBox, type SourceLocation, type VDevMessage, createMessageHandler, findSourceElement, getSourceFromElement, notifyReady, parseSourceAttr, sendToExtension, useDevTools };