@base44-preview/vite-plugin 0.2.27-pr.41.77be9cb → 0.2.27-pr.43.93e5e43
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/consts.d.ts +12 -0
- package/dist/consts.d.ts.map +1 -0
- package/dist/consts.js +12 -0
- package/dist/consts.js.map +1 -0
- package/dist/injections/visual-edit-agent.d.ts +1 -1
- package/dist/injections/visual-edit-agent.d.ts.map +1 -1
- package/dist/injections/visual-edit-agent.js +566 -1
- package/dist/injections/visual-edit-agent.js.map +1 -1
- package/dist/jsx-processor.d.ts +4 -1
- package/dist/jsx-processor.d.ts.map +1 -1
- package/dist/jsx-processor.js +33 -6
- package/dist/jsx-processor.js.map +1 -1
- package/dist/jsx-utils.d.ts +9 -0
- package/dist/jsx-utils.d.ts.map +1 -1
- package/dist/jsx-utils.js +86 -0
- package/dist/jsx-utils.js.map +1 -1
- package/dist/processors/collection-id-processor.d.ts +20 -0
- package/dist/processors/collection-id-processor.d.ts.map +1 -0
- package/dist/processors/collection-id-processor.js +182 -0
- package/dist/processors/collection-id-processor.js.map +1 -0
- package/dist/processors/collection-item-field-processor.d.ts +39 -0
- package/dist/processors/collection-item-field-processor.d.ts.map +1 -0
- package/dist/processors/collection-item-field-processor.js +281 -0
- package/dist/processors/collection-item-field-processor.js.map +1 -0
- package/dist/processors/collection-item-id-processor.d.ts +12 -0
- package/dist/processors/collection-item-id-processor.d.ts.map +1 -0
- package/dist/processors/collection-item-id-processor.js +50 -0
- package/dist/processors/collection-item-id-processor.js.map +1 -0
- package/dist/processors/collection-reference-field-processor.d.ts +31 -0
- package/dist/processors/collection-reference-field-processor.d.ts.map +1 -0
- package/dist/processors/collection-reference-field-processor.js +174 -0
- package/dist/processors/collection-reference-field-processor.js.map +1 -0
- package/dist/processors/collection-tracing-utils.d.ts +36 -0
- package/dist/processors/collection-tracing-utils.d.ts.map +1 -0
- package/dist/processors/collection-tracing-utils.js +390 -0
- package/dist/processors/collection-tracing-utils.js.map +1 -0
- package/dist/processors/shared-utils.d.ts +77 -0
- package/dist/processors/shared-utils.d.ts.map +1 -1
- package/dist/processors/shared-utils.js +525 -0
- package/dist/processors/shared-utils.js.map +1 -1
- package/dist/processors/static-array-processor.d.ts +2 -3
- package/dist/processors/static-array-processor.d.ts.map +1 -1
- package/dist/processors/static-array-processor.js +2 -3
- package/dist/processors/static-array-processor.js.map +1 -1
- package/dist/statics/index.mjs +2 -2
- package/dist/statics/index.mjs.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/visual-edit-plugin.d.ts +0 -1
- package/dist/visual-edit-plugin.d.ts.map +1 -1
- package/dist/visual-edit-plugin.js +29 -178
- package/dist/visual-edit-plugin.js.map +1 -1
- package/package.json +1 -1
- package/src/consts.ts +12 -0
- package/src/injections/visual-edit-agent.ts +698 -1
- package/src/jsx-processor.ts +41 -14
- package/src/jsx-utils.ts +116 -0
- package/src/processors/collection-id-processor.ts +261 -0
- package/src/processors/collection-item-field-processor.ts +433 -0
- package/src/processors/collection-item-id-processor.ts +69 -0
- package/src/processors/collection-reference-field-processor.ts +225 -0
- package/src/processors/collection-tracing-utils.ts +507 -0
- package/src/processors/shared-utils.ts +671 -0
- package/src/processors/static-array-processor.ts +6 -3
- package/src/types.ts +4 -0
- package/src/visual-edit-plugin.ts +34 -215
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.d.ts +0 -25
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.js +0 -95
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/core.js.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.d.ts +0 -4
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.js +0 -4
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/index.js.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.d.ts +0 -9
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.js +0 -26
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/styles.js.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.d.ts +0 -17
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.js +0 -76
- package/dist/injections/visual-edit-agent/capabilities/inline-editing/validation.js.map +0 -1
- package/dist/injections/visual-edit-agent/constants.d.ts +0 -10
- package/dist/injections/visual-edit-agent/constants.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/constants.js +0 -10
- package/dist/injections/visual-edit-agent/constants.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/click-handlers.d.ts +0 -10
- package/dist/injections/visual-edit-agent/handlers/click-handlers.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/click-handlers.js +0 -117
- package/dist/injections/visual-edit-agent/handlers/click-handlers.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.d.ts +0 -14
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.js +0 -64
- package/dist/injections/visual-edit-agent/handlers/hover-handlers.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.d.ts +0 -14
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.js +0 -114
- package/dist/injections/visual-edit-agent/handlers/inline-edit-handlers.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/message-handlers.d.ts +0 -26
- package/dist/injections/visual-edit-agent/handlers/message-handlers.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/message-handlers.js +0 -148
- package/dist/injections/visual-edit-agent/handlers/message-handlers.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.d.ts +0 -7
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.js +0 -54
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.d.ts +0 -11
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.js +0 -32
- package/dist/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.js.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/types.d.ts +0 -105
- package/dist/injections/visual-edit-agent/handlers/messages/types.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/handlers/messages/types.js +0 -28
- package/dist/injections/visual-edit-agent/handlers/messages/types.js.map +0 -1
- package/dist/injections/visual-edit-agent/index.d.ts +0 -6
- package/dist/injections/visual-edit-agent/index.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/index.js +0 -109
- package/dist/injections/visual-edit-agent/index.js.map +0 -1
- package/dist/injections/visual-edit-agent/state/agent-state.d.ts +0 -17
- package/dist/injections/visual-edit-agent/state/agent-state.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/state/agent-state.js +0 -18
- package/dist/injections/visual-edit-agent/state/agent-state.js.map +0 -1
- package/dist/injections/visual-edit-agent/ui/overlay.d.ts +0 -26
- package/dist/injections/visual-edit-agent/ui/overlay.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/ui/overlay.js +0 -104
- package/dist/injections/visual-edit-agent/ui/overlay.js.map +0 -1
- package/dist/injections/visual-edit-agent/utils/dom-utils.d.ts +0 -14
- package/dist/injections/visual-edit-agent/utils/dom-utils.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/utils/dom-utils.js +0 -34
- package/dist/injections/visual-edit-agent/utils/dom-utils.js.map +0 -1
- package/src/injections/visual-edit-agent/README.md +0 -222
- package/src/injections/visual-edit-agent/capabilities/inline-editing/core.ts +0 -120
- package/src/injections/visual-edit-agent/capabilities/inline-editing/index.ts +0 -10
- package/src/injections/visual-edit-agent/capabilities/inline-editing/styles.ts +0 -26
- package/src/injections/visual-edit-agent/capabilities/inline-editing/validation.ts +0 -87
- package/src/injections/visual-edit-agent/constants.ts +0 -9
- package/src/injections/visual-edit-agent/handlers/click-handlers.ts +0 -146
- package/src/injections/visual-edit-agent/handlers/hover-handlers.ts +0 -78
- package/src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts +0 -146
- package/src/injections/visual-edit-agent/handlers/message-handlers.ts +0 -201
- package/src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts +0 -65
- package/src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts +0 -40
- package/src/injections/visual-edit-agent/handlers/messages/types.ts +0 -134
- package/src/injections/visual-edit-agent/index.ts +0 -121
- package/src/injections/visual-edit-agent/state/agent-state.ts +0 -31
- package/src/injections/visual-edit-agent/ui/overlay.ts +0 -126
- package/src/injections/visual-edit-agent/utils/dom-utils.ts +0 -39
|
@@ -3,196 +3,31 @@ import { default as traverse } from "@babel/traverse";
|
|
|
3
3
|
import { default as generate } from "@babel/generator";
|
|
4
4
|
import * as t from "@babel/types";
|
|
5
5
|
import type { Plugin } from "vite";
|
|
6
|
-
import {
|
|
6
|
+
import { JSXProcessor } from "./jsx-processor.js";
|
|
7
7
|
import { JSXUtils } from "./jsx-utils.js";
|
|
8
8
|
|
|
9
|
-
// Helper function to check if JSX element contains dynamic content
|
|
10
|
-
export function checkIfElementHasDynamicContent(jsxElement: any) {
|
|
11
|
-
let hasDynamicContent = false;
|
|
12
|
-
|
|
13
|
-
// Helper function to check if any node contains dynamic patterns
|
|
14
|
-
function checkNodeForDynamicContent(node: any) {
|
|
15
|
-
// JSX expressions like {variable}, {func()}, {obj.prop}
|
|
16
|
-
if (t.isJSXExpressionContainer(node)) {
|
|
17
|
-
const expression = node.expression;
|
|
18
|
-
|
|
19
|
-
// Skip empty expressions {}
|
|
20
|
-
if (t.isJSXEmptyExpression(expression)) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Any non-literal expression is considered dynamic
|
|
25
|
-
if (!t.isLiteral(expression)) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Template literals with expressions `Hello ${name}`
|
|
31
|
-
if (t.isTemplateLiteral(node) && node.expressions.length > 0) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Member expressions like props.title, state.value
|
|
36
|
-
if (t.isMemberExpression(node)) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Function calls like getData(), format()
|
|
41
|
-
if (t.isCallExpression(node)) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Conditional expressions like condition ? "yes" : "no"
|
|
46
|
-
if (t.isConditionalExpression(node)) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Identifier references (could be props, state, variables)
|
|
51
|
-
if (t.isIdentifier(node)) {
|
|
52
|
-
// Common dynamic identifiers
|
|
53
|
-
const dynamicNames = [
|
|
54
|
-
"props",
|
|
55
|
-
"state",
|
|
56
|
-
"data",
|
|
57
|
-
"item",
|
|
58
|
-
"value",
|
|
59
|
-
"text",
|
|
60
|
-
"content",
|
|
61
|
-
];
|
|
62
|
-
if (dynamicNames.some((name) => node.name.includes(name))) {
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Recursively traverse all child nodes
|
|
71
|
-
function traverseNode(node: any) {
|
|
72
|
-
if (checkNodeForDynamicContent(node)) {
|
|
73
|
-
hasDynamicContent = true;
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Recursively check child nodes
|
|
78
|
-
Object.keys(node).forEach((key) => {
|
|
79
|
-
const value = node[key];
|
|
80
|
-
|
|
81
|
-
if (Array.isArray(value)) {
|
|
82
|
-
value.forEach((child) => {
|
|
83
|
-
if (child && typeof child === "object" && child.type) {
|
|
84
|
-
traverseNode(child);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
} else if (value && typeof value === "object" && value.type) {
|
|
88
|
-
traverseNode(value);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Check the element's own attributes for dynamic content
|
|
94
|
-
const attributes = jsxElement.openingElement?.attributes || [];
|
|
95
|
-
attributes.forEach((attr: any) => {
|
|
96
|
-
if (hasDynamicContent) return; // Early exit if already found dynamic content
|
|
97
|
-
|
|
98
|
-
// Spread attributes like {...props} are always dynamic
|
|
99
|
-
if (t.isJSXSpreadAttribute(attr)) {
|
|
100
|
-
hasDynamicContent = true;
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Check attribute values for dynamic expressions
|
|
105
|
-
if (t.isJSXAttribute(attr) && attr.value) {
|
|
106
|
-
traverseNode(attr.value);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Check all children of the JSX element
|
|
111
|
-
jsxElement.children.forEach((child: any) => {
|
|
112
|
-
if (hasDynamicContent) return; // Early exit if already found dynamic content
|
|
113
|
-
traverseNode(child);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
return hasDynamicContent;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
9
|
export function visualEditPlugin() {
|
|
120
10
|
return {
|
|
121
11
|
name: "visual-edit-transform",
|
|
122
12
|
apply: (config) => config.mode === "development",
|
|
123
13
|
enforce: "pre",
|
|
124
14
|
order: "pre",
|
|
125
|
-
// Inject Tailwind CDN for visual editing capabilities
|
|
126
15
|
transformIndexHtml(html: any) {
|
|
127
|
-
// Inject the Tailwind CSS CDN script right before the closing </head> tag
|
|
128
16
|
const tailwindScript = ` <!-- Tailwind CSS CDN for visual editing -->\n <script src="https://cdn.tailwindcss.com"></script>\n `;
|
|
129
17
|
return html.replace("</head>", tailwindScript + "</head>");
|
|
130
18
|
},
|
|
131
19
|
transform(code: any, id: any) {
|
|
132
|
-
// Skip node_modules and visual-edit-agent itself
|
|
133
20
|
if (id.includes("node_modules") || id.includes("visual-edit-agent")) {
|
|
134
21
|
return null;
|
|
135
22
|
}
|
|
136
23
|
|
|
137
|
-
// Process JS/JSX/TS/TSX files
|
|
138
24
|
if (!id.match(/\.(jsx?|tsx?)$/)) {
|
|
139
25
|
return null;
|
|
140
26
|
}
|
|
141
27
|
|
|
142
|
-
|
|
143
|
-
const pathParts = id.split("/");
|
|
144
|
-
let filename;
|
|
145
|
-
|
|
146
|
-
// Check if this is a pages or components file
|
|
147
|
-
if (id.includes("/pages/")) {
|
|
148
|
-
const pagesIndex = pathParts.findIndex((part: any) => part === "pages");
|
|
149
|
-
if (pagesIndex >= 0 && pagesIndex < pathParts.length - 1) {
|
|
150
|
-
// Get all parts from 'pages' to the file, preserving nested structure
|
|
151
|
-
const relevantParts = pathParts.slice(pagesIndex, pathParts.length);
|
|
152
|
-
const lastPart = relevantParts[relevantParts.length - 1];
|
|
153
|
-
// Remove file extension from the last part
|
|
154
|
-
relevantParts[relevantParts.length - 1] = lastPart.includes(".")
|
|
155
|
-
? lastPart.split(".")[0]
|
|
156
|
-
: lastPart;
|
|
157
|
-
filename = relevantParts.join("/");
|
|
158
|
-
} else {
|
|
159
|
-
filename = pathParts[pathParts.length - 1];
|
|
160
|
-
if (filename.includes(".")) {
|
|
161
|
-
filename = filename.split(".")[0];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
} else if (id.includes("/components/")) {
|
|
165
|
-
const componentsIndex = pathParts.findIndex(
|
|
166
|
-
(part: any) => part === "components"
|
|
167
|
-
);
|
|
168
|
-
if (componentsIndex >= 0 && componentsIndex < pathParts.length - 1) {
|
|
169
|
-
// Get all parts from 'components' to the file, preserving nested structure
|
|
170
|
-
const relevantParts = pathParts.slice(
|
|
171
|
-
componentsIndex,
|
|
172
|
-
pathParts.length
|
|
173
|
-
);
|
|
174
|
-
const lastPart = relevantParts[relevantParts.length - 1];
|
|
175
|
-
// Remove file extension from the last part
|
|
176
|
-
relevantParts[relevantParts.length - 1] = lastPart.includes(".")
|
|
177
|
-
? lastPart.split(".")[0]
|
|
178
|
-
: lastPart;
|
|
179
|
-
filename = relevantParts.join("/");
|
|
180
|
-
} else {
|
|
181
|
-
filename = pathParts[pathParts.length - 1];
|
|
182
|
-
if (filename.includes(".")) {
|
|
183
|
-
filename = filename.split(".")[0];
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
} else {
|
|
187
|
-
// For other files (like layout), just use the filename
|
|
188
|
-
filename = pathParts[pathParts.length - 1];
|
|
189
|
-
if (filename.includes(".")) {
|
|
190
|
-
filename = filename.split(".")[0];
|
|
191
|
-
}
|
|
192
|
-
}
|
|
28
|
+
const filename = extractFilename(id);
|
|
193
29
|
|
|
194
30
|
try {
|
|
195
|
-
// Parse the code into an AST
|
|
196
31
|
const ast = parse(code, {
|
|
197
32
|
sourceType: "module",
|
|
198
33
|
plugins: [
|
|
@@ -214,61 +49,17 @@ export function visualEditPlugin() {
|
|
|
214
49
|
],
|
|
215
50
|
});
|
|
216
51
|
|
|
217
|
-
// Traverse the AST and add source location and dynamic content attributes to JSX elements
|
|
218
52
|
JSXUtils.init(t);
|
|
219
|
-
const
|
|
220
|
-
|
|
53
|
+
const processor = new JSXProcessor(t, filename);
|
|
54
|
+
|
|
221
55
|
traverse.default(ast, {
|
|
222
56
|
JSXElement(path) {
|
|
223
57
|
const jsxElement = path.node;
|
|
224
|
-
const openingElement = jsxElement.openingElement;
|
|
225
|
-
|
|
226
|
-
// Skip fragments
|
|
227
58
|
if (t.isJSXFragment(jsxElement)) return;
|
|
228
|
-
|
|
229
|
-
// Skip if already has source location attribute
|
|
230
|
-
const hasSourceLocation = openingElement.attributes.some(
|
|
231
|
-
(attr) =>
|
|
232
|
-
t.isJSXAttribute(attr) &&
|
|
233
|
-
t.isJSXIdentifier(attr.name) &&
|
|
234
|
-
attr.name.name === "data-source-location"
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
if (hasSourceLocation) return;
|
|
238
|
-
|
|
239
|
-
// Get line and column from AST node location
|
|
240
|
-
const { line, column } = openingElement.loc?.start || {
|
|
241
|
-
line: 1,
|
|
242
|
-
column: 0,
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
// Create the source location attribute
|
|
246
|
-
const sourceLocationAttr = t.jsxAttribute(
|
|
247
|
-
t.jsxIdentifier("data-source-location"),
|
|
248
|
-
t.stringLiteral(`${filename}:${line}:${column}`)
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
// Check if element has dynamic content
|
|
252
|
-
const isDynamic = checkIfElementHasDynamicContent(jsxElement);
|
|
253
|
-
|
|
254
|
-
// Create the dynamic content attribute
|
|
255
|
-
const dynamicContentAttr = t.jsxAttribute(
|
|
256
|
-
t.jsxIdentifier("data-dynamic-content"),
|
|
257
|
-
t.stringLiteral(isDynamic ? "true" : "false")
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
// Add both attributes to the beginning of the attributes array
|
|
261
|
-
openingElement.attributes.unshift(
|
|
262
|
-
sourceLocationAttr,
|
|
263
|
-
dynamicContentAttr
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
staticArrayProcessor.process(path.get("openingElement"));
|
|
267
|
-
elementsProcessed++;
|
|
59
|
+
processor.processJSXElement(path.get("openingElement"));
|
|
268
60
|
},
|
|
269
61
|
});
|
|
270
62
|
|
|
271
|
-
// Generate the code back from the AST
|
|
272
63
|
const result = generate.default(ast, {
|
|
273
64
|
compact: false,
|
|
274
65
|
concise: false,
|
|
@@ -282,10 +73,38 @@ export function visualEditPlugin() {
|
|
|
282
73
|
} catch (error) {
|
|
283
74
|
console.error("Failed to add source location to JSX:", error);
|
|
284
75
|
return {
|
|
285
|
-
code: code,
|
|
76
|
+
code: code,
|
|
286
77
|
map: null,
|
|
287
78
|
};
|
|
288
79
|
}
|
|
289
80
|
},
|
|
290
81
|
} as Plugin;
|
|
291
82
|
}
|
|
83
|
+
|
|
84
|
+
function extractFilename(id: string): string {
|
|
85
|
+
const pathParts = id.split("/");
|
|
86
|
+
|
|
87
|
+
const segmentIndex = findSegmentIndex(pathParts, ["pages", "components"]);
|
|
88
|
+
if (segmentIndex >= 0 && segmentIndex < pathParts.length - 1) {
|
|
89
|
+
const relevantParts = pathParts.slice(segmentIndex);
|
|
90
|
+
const last = relevantParts[relevantParts.length - 1];
|
|
91
|
+
relevantParts[relevantParts.length - 1] = stripExtension(last ?? "");
|
|
92
|
+
return relevantParts.join("/");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const lastPart = pathParts[pathParts.length - 1] ?? "";
|
|
96
|
+
return stripExtension(lastPart);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function findSegmentIndex(parts: string[], segments: string[]): number {
|
|
100
|
+
for (const segment of segments) {
|
|
101
|
+
const idx = parts.findIndex((part) => part === segment);
|
|
102
|
+
if (idx >= 0) return idx;
|
|
103
|
+
}
|
|
104
|
+
return -1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function stripExtension(filename: string): string {
|
|
108
|
+
const dotIndex = filename.indexOf(".");
|
|
109
|
+
return dotIndex >= 0 ? filename.substring(0, dotIndex) : filename;
|
|
110
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Callback function type for handling text input changes
|
|
3
|
-
*/
|
|
4
|
-
type OnTextInputChange = (element: HTMLElement) => void;
|
|
5
|
-
/**
|
|
6
|
-
* Set the callback function that will be called on text input changes
|
|
7
|
-
*/
|
|
8
|
-
export declare function setInlineEditCallback(callback: OnTextInputChange | null): void;
|
|
9
|
-
/**
|
|
10
|
-
* Check if an element should enter inline editing mode
|
|
11
|
-
* Called when user clicks on an already-selected element
|
|
12
|
-
*/
|
|
13
|
-
export declare function shouldEnterInlineEditingMode(element: Element): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Enable contentEditable mode on an element
|
|
16
|
-
* Follows the exact flow from inlineEdit.md
|
|
17
|
-
*/
|
|
18
|
-
export declare function enterInlineEditingMode(element: HTMLElement): void;
|
|
19
|
-
/**
|
|
20
|
-
* Disable contentEditable mode on an element
|
|
21
|
-
* Reverses everything done by enterInlineEditingMode
|
|
22
|
-
*/
|
|
23
|
-
export declare function clearInlineEditingMode(element: HTMLElement): void;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/core.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,KAAK,iBAAiB,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;AAQxD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAE9E;AAkBD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAYtE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CA4BjE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CA0BjE"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { injectFocusOutlineCSS, removeFocusOutlineCSS } from "./styles.js";
|
|
2
|
-
import { selectText, isEditableTextElement } from "./validation.js";
|
|
3
|
-
/**
|
|
4
|
-
* Global callback that gets triggered on every input event
|
|
5
|
-
* This is set by the visual-edit-agent and includes both updatePosition and reportInlineEdit
|
|
6
|
-
*/
|
|
7
|
-
let onTextInputChangeCallback = null;
|
|
8
|
-
/**
|
|
9
|
-
* Set the callback function that will be called on text input changes
|
|
10
|
-
*/
|
|
11
|
-
export function setInlineEditCallback(callback) {
|
|
12
|
-
onTextInputChangeCallback = callback;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* WeakMap to track AbortControllers for each element's input listener.
|
|
16
|
-
* Using WeakMap ensures no memory leaks — when an element is garbage collected,
|
|
17
|
-
* its entry is automatically removed.
|
|
18
|
-
*/
|
|
19
|
-
const listenerAbortControllers = new WeakMap();
|
|
20
|
-
/**
|
|
21
|
-
* Internal handler for the native input event
|
|
22
|
-
*/
|
|
23
|
-
function handleInputEvent(e) {
|
|
24
|
-
if (onTextInputChangeCallback) {
|
|
25
|
-
onTextInputChangeCallback(this);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Check if an element should enter inline editing mode
|
|
30
|
-
* Called when user clicks on an already-selected element
|
|
31
|
-
*/
|
|
32
|
-
export function shouldEnterInlineEditingMode(element) {
|
|
33
|
-
// Must have data-selected="true"
|
|
34
|
-
if (!(element instanceof HTMLElement) || element.dataset.selected !== "true") {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
// Must pass all editability checks
|
|
38
|
-
if (!isEditableTextElement(element)) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Enable contentEditable mode on an element
|
|
45
|
-
* Follows the exact flow from inlineEdit.md
|
|
46
|
-
*/
|
|
47
|
-
export function enterInlineEditingMode(element) {
|
|
48
|
-
// Inject CSS to suppress focus outline
|
|
49
|
-
injectFocusOutlineCSS();
|
|
50
|
-
// Store original state
|
|
51
|
-
element.dataset.originalTextContent = element.textContent || "";
|
|
52
|
-
element.dataset.originalCursor = element.style.cursor;
|
|
53
|
-
// Enable contentEditable
|
|
54
|
-
element.contentEditable = "true";
|
|
55
|
-
// Create an AbortController to manage the input listener lifecycle
|
|
56
|
-
const abortController = new AbortController();
|
|
57
|
-
listenerAbortControllers.set(element, abortController);
|
|
58
|
-
// Add input event listener with AbortSignal for automatic cleanup
|
|
59
|
-
element.addEventListener("input", handleInputEvent, { signal: abortController.signal });
|
|
60
|
-
// Set cursor to text
|
|
61
|
-
element.style.cursor = "text";
|
|
62
|
-
// Select all text
|
|
63
|
-
selectText(element);
|
|
64
|
-
// Focus after render
|
|
65
|
-
setTimeout(() => {
|
|
66
|
-
element.focus();
|
|
67
|
-
}, 0);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Disable contentEditable mode on an element
|
|
71
|
-
* Reverses everything done by enterInlineEditingMode
|
|
72
|
-
*/
|
|
73
|
-
export function clearInlineEditingMode(element) {
|
|
74
|
-
// Abort the input event listener using the stored AbortController
|
|
75
|
-
const abortController = listenerAbortControllers.get(element);
|
|
76
|
-
if (abortController) {
|
|
77
|
-
abortController.abort();
|
|
78
|
-
listenerAbortControllers.delete(element);
|
|
79
|
-
}
|
|
80
|
-
// If element was removed from DOM before cleanup, skip DOM operations
|
|
81
|
-
if (!element.isConnected) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
removeFocusOutlineCSS();
|
|
85
|
-
// Disable contentEditable
|
|
86
|
-
element.contentEditable = "false";
|
|
87
|
-
// Remove stored original text content
|
|
88
|
-
delete element.dataset.originalTextContent;
|
|
89
|
-
// Restore original cursor
|
|
90
|
-
if (element.dataset.originalCursor !== undefined) {
|
|
91
|
-
element.style.cursor = element.dataset.originalCursor;
|
|
92
|
-
delete element.dataset.originalCursor;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=core.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/core.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { enterInlineEditingMode, clearInlineEditingMode, shouldEnterInlineEditingMode, setInlineEditCallback, } from "./core.js";
|
|
2
|
-
export { injectFocusOutlineCSS, removeFocusOutlineCSS } from "./styles.js";
|
|
3
|
-
export { isEditableTextElement, isStaticArrayTextElement, selectText } from "./validation.js";
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE3E,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { enterInlineEditingMode, clearInlineEditingMode, shouldEnterInlineEditingMode, setInlineEditCallback, } from "./core.js";
|
|
2
|
-
export { injectFocusOutlineCSS, removeFocusOutlineCSS } from "./styles.js";
|
|
3
|
-
export { isEditableTextElement, isStaticArrayTextElement, selectText } from "./validation.js";
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE3E,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inject CSS to suppress the browser's default focus outline on contentEditable elements
|
|
3
|
-
*/
|
|
4
|
-
export declare function injectFocusOutlineCSS(): void;
|
|
5
|
-
/**
|
|
6
|
-
* Remove the injected focus outline CSS
|
|
7
|
-
*/
|
|
8
|
-
export declare function removeFocusOutlineCSS(): void;
|
|
9
|
-
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAY5C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAK5C"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inject CSS to suppress the browser's default focus outline on contentEditable elements
|
|
3
|
-
*/
|
|
4
|
-
export function injectFocusOutlineCSS() {
|
|
5
|
-
const existingStyle = document.getElementById("visual-edit-focus-styles");
|
|
6
|
-
if (existingStyle)
|
|
7
|
-
return;
|
|
8
|
-
const style = document.createElement("style");
|
|
9
|
-
style.id = "visual-edit-focus-styles";
|
|
10
|
-
style.textContent = `
|
|
11
|
-
[data-selected="true"][contenteditable="true"]:focus {
|
|
12
|
-
outline: none !important;
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
document.head.appendChild(style);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Remove the injected focus outline CSS
|
|
19
|
-
*/
|
|
20
|
-
export function removeFocusOutlineCSS() {
|
|
21
|
-
const style = document.getElementById("visual-edit-focus-styles");
|
|
22
|
-
if (style) {
|
|
23
|
-
style.remove();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,0BAA0B,CAAC,CAAC;IAC1E,IAAI,aAAa;QAAE,OAAO;IAE1B,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,EAAE,GAAG,0BAA0B,CAAC;IACtC,KAAK,CAAC,WAAW,GAAG;;;;GAInB,CAAC;IACF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,0BAA0B,CAAC,CAAC;IAClE,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Select all text content in an element using the Selection API
|
|
3
|
-
*/
|
|
4
|
-
export declare function selectText(element: HTMLElement): void;
|
|
5
|
-
/**
|
|
6
|
-
* Check if an element is a static array text element.
|
|
7
|
-
* These elements are "dynamic" (they reference item.field) but their source
|
|
8
|
-
* is a compile-time static array, so they can be safely edited inline.
|
|
9
|
-
*/
|
|
10
|
-
export declare function isStaticArrayTextElement(element: HTMLElement): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Check if an element is an editable text element
|
|
13
|
-
* Based on the eligibility rules from inlineEdit.md (non-dynamic only),
|
|
14
|
-
* with an exception for static array elements.
|
|
15
|
-
*/
|
|
16
|
-
export declare function isEditableTextElement(element: Element): boolean;
|
|
17
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAMrD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAEtE;AA4CD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAmB/D"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Select all text content in an element using the Selection API
|
|
3
|
-
*/
|
|
4
|
-
export function selectText(element) {
|
|
5
|
-
const range = document.createRange();
|
|
6
|
-
range.selectNodeContents(element);
|
|
7
|
-
const selection = window.getSelection();
|
|
8
|
-
selection?.removeAllRanges();
|
|
9
|
-
selection?.addRange(range);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Check if an element is a static array text element.
|
|
13
|
-
* These elements are "dynamic" (they reference item.field) but their source
|
|
14
|
-
* is a compile-time static array, so they can be safely edited inline.
|
|
15
|
-
*/
|
|
16
|
-
export function isStaticArrayTextElement(element) {
|
|
17
|
-
return !!element.dataset.arrField;
|
|
18
|
-
}
|
|
19
|
-
const ALLOWED_INLINE_EDIT_TAGS = [
|
|
20
|
-
"div",
|
|
21
|
-
"p",
|
|
22
|
-
"h1",
|
|
23
|
-
"h2",
|
|
24
|
-
"h3",
|
|
25
|
-
"h4",
|
|
26
|
-
"h5",
|
|
27
|
-
"h6",
|
|
28
|
-
"span",
|
|
29
|
-
"li",
|
|
30
|
-
"td",
|
|
31
|
-
"a",
|
|
32
|
-
"button",
|
|
33
|
-
"label",
|
|
34
|
-
];
|
|
35
|
-
/**
|
|
36
|
-
* Structural checks shared by both regular and static-array inline editing:
|
|
37
|
-
* allowed tag, non-empty text, no media children, leaf node.
|
|
38
|
-
*/
|
|
39
|
-
function passesStructuralChecks(element) {
|
|
40
|
-
if (!ALLOWED_INLINE_EDIT_TAGS.includes(element.tagName.toLowerCase())) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
const textContent = element.textContent?.trim() || "";
|
|
44
|
-
if (textContent.length === 0) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
if (element.querySelector("img, video, canvas, svg") !== null) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
if (element.children.length > 0) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Check if an element is an editable text element
|
|
57
|
-
* Based on the eligibility rules from inlineEdit.md (non-dynamic only),
|
|
58
|
-
* with an exception for static array elements.
|
|
59
|
-
*/
|
|
60
|
-
export function isEditableTextElement(element) {
|
|
61
|
-
if (!(element instanceof HTMLElement)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
if (!passesStructuralChecks(element)) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
// Static array elements are editable even though they are technically "dynamic"
|
|
68
|
-
if (isStaticArrayTextElement(element)) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
if (element.dataset.dynamicContent === "true") {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../src/injections/visual-edit-agent/capabilities/inline-editing/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAoB;IAC7C,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IACxC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAoB;IAC3D,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;AACpC,CAAC;AAED,MAAM,wBAAwB,GAAG;IAC/B,KAAK;IACL,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,QAAQ;IACR,OAAO;CACR,CAAC;AAEF;;;GAGG;AACH,SAAS,sBAAsB,CAAC,OAAoB;IAClD,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QACtE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACtD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,CAAC,aAAa,CAAC,yBAAyB,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,IAAI,CAAC,CAAC,OAAO,YAAY,WAAW,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gFAAgF;IAChF,IAAI,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const INLINE_EDIT_DEBOUNCE_MS = 500;
|
|
2
|
-
export declare const OVERLAY_TRANSITION = "all 0.1s ease-in-out";
|
|
3
|
-
export declare const OVERLAY_Z_INDEX = "9999";
|
|
4
|
-
export declare const SELECTED_BORDER_COLOR = "#2563EB";
|
|
5
|
-
export declare const HOVER_BORDER_COLOR = "#95a5fc";
|
|
6
|
-
export declare const HOVER_BACKGROUND_COLOR = "rgba(99, 102, 241, 0.05)";
|
|
7
|
-
export declare const LABEL_TOP_OFFSET = "-27px";
|
|
8
|
-
export declare const LABEL_LEFT_OFFSET = "-2px";
|
|
9
|
-
export declare const REPOSITION_DELAY_MS = 50;
|
|
10
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/injections/visual-edit-agent/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,kBAAkB,yBAAyB,CAAC;AACzD,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAC/C,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAC5C,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AACjE,eAAO,MAAM,gBAAgB,UAAU,CAAC;AACxC,eAAO,MAAM,iBAAiB,SAAS,CAAC;AACxC,eAAO,MAAM,mBAAmB,KAAK,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const INLINE_EDIT_DEBOUNCE_MS = 500;
|
|
2
|
-
export const OVERLAY_TRANSITION = "all 0.1s ease-in-out";
|
|
3
|
-
export const OVERLAY_Z_INDEX = "9999";
|
|
4
|
-
export const SELECTED_BORDER_COLOR = "#2563EB";
|
|
5
|
-
export const HOVER_BORDER_COLOR = "#95a5fc";
|
|
6
|
-
export const HOVER_BACKGROUND_COLOR = "rgba(99, 102, 241, 0.05)";
|
|
7
|
-
export const LABEL_TOP_OFFSET = "-27px";
|
|
8
|
-
export const LABEL_LEFT_OFFSET = "-2px";
|
|
9
|
-
export const REPOSITION_DELAY_MS = 50;
|
|
10
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/injections/visual-edit-agent/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AACzD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAC/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AgentState } from "../state/agent-state.js";
|
|
2
|
-
/**
|
|
3
|
-
* Handle element selection (first click)
|
|
4
|
-
*/
|
|
5
|
-
export declare function handleElementSelection(state: AgentState, element: Element, visualSelectorId: string | null): void;
|
|
6
|
-
/**
|
|
7
|
-
* Handle element click
|
|
8
|
-
*/
|
|
9
|
-
export declare function handleElementClick(state: AgentState, e: MouseEvent): void;
|
|
10
|
-
//# sourceMappingURL=click-handlers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"click-handlers.d.ts","sourceRoot":"","sources":["../../../../src/injections/visual-edit-agent/handlers/click-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAS1D;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,IAAI,CAwDN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,IAAI,CAoEzE"}
|