@base44-preview/vite-plugin 0.2.22-pr.37.fd9cb1a → 0.2.22-pr.39.4150ff4
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/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 +458 -1
- package/dist/injections/visual-edit-agent.js.map +1 -1
- package/dist/jsx-processor.d.ts +15 -0
- package/dist/jsx-processor.d.ts.map +1 -0
- package/dist/jsx-processor.js +106 -0
- package/dist/jsx-processor.js.map +1 -0
- package/dist/jsx-utils.d.ts +7 -0
- package/dist/jsx-utils.d.ts.map +1 -0
- package/dist/jsx-utils.js +12 -0
- package/dist/jsx-utils.js.map +1 -0
- package/dist/processors/shared-utils.d.ts +19 -0
- package/dist/processors/shared-utils.d.ts.map +1 -0
- package/dist/processors/shared-utils.js +77 -0
- package/dist/processors/shared-utils.js.map +1 -0
- package/dist/processors/static-array-processor.d.ts +31 -0
- package/dist/processors/static-array-processor.d.ts.map +1 -0
- package/dist/processors/static-array-processor.js +175 -0
- package/dist/processors/static-array-processor.js.map +1 -0
- package/dist/statics/index.mjs +1 -5
- package/dist/statics/index.mjs.map +1 -1
- package/dist/visual-edit-plugin.d.ts.map +1 -1
- package/dist/visual-edit-plugin.js +5 -0
- package/dist/visual-edit-plugin.js.map +1 -1
- package/package.json +2 -1
- package/src/injections/visual-edit-agent.ts +561 -1
- package/src/jsx-processor.ts +147 -0
- package/src/jsx-utils.ts +15 -0
- package/src/processors/shared-utils.ts +116 -0
- package/src/processors/static-array-processor.ts +257 -0
- package/src/visual-edit-plugin.ts +6 -0
- 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 -10
- 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 -60
- 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 -108
- 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 -109
- 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 -145
- 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 -86
- 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 -5
- package/dist/injections/visual-edit-agent/index.d.ts.map +0 -1
- package/dist/injections/visual-edit-agent/index.js +0 -95
- 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 -67
- package/src/injections/visual-edit-agent/constants.ts +0 -9
- package/src/injections/visual-edit-agent/handlers/click-handlers.ts +0 -135
- package/src/injections/visual-edit-agent/handlers/hover-handlers.ts +0 -78
- package/src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts +0 -141
- package/src/injections/visual-edit-agent/handlers/message-handlers.ts +0 -191
- 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 -112
- package/src/injections/visual-edit-agent/index.ts +0 -108
- 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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NodePath } from "@babel/traverse";
|
|
2
|
+
import type * as t from "@babel/types";
|
|
3
|
+
export declare class JSXAttributeUtils {
|
|
4
|
+
private types;
|
|
5
|
+
constructor(types: typeof t);
|
|
6
|
+
hasAttribute(path: NodePath<t.JSXOpeningElement>, attributeName: string): boolean;
|
|
7
|
+
addStringAttribute(path: NodePath<t.JSXOpeningElement>, attributeName: string, value: string): void;
|
|
8
|
+
addExpressionAttribute(path: NodePath<t.JSXOpeningElement>, attributeName: string, expression: t.Expression): void;
|
|
9
|
+
}
|
|
10
|
+
export declare class StaticValueUtils {
|
|
11
|
+
private types;
|
|
12
|
+
constructor(types: typeof t);
|
|
13
|
+
isPrimitiveLiteral(path: NodePath<t.Node>): boolean;
|
|
14
|
+
isStaticValue(path: NodePath<t.Node>, visited?: Set<string>): boolean;
|
|
15
|
+
isStaticIdentifier(path: NodePath<t.Identifier>, visited?: Set<string>): boolean;
|
|
16
|
+
isStaticObject(path: NodePath<t.ObjectExpression>, visited?: Set<string>): boolean;
|
|
17
|
+
isStaticArrayExpression(arrayExpression: NodePath<t.ArrayExpression>, visited?: Set<string>): boolean;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=shared-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-utils.d.ts","sourceRoot":"","sources":["../../src/processors/shared-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AAGvC,qBAAa,iBAAiB;IAChB,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,OAAO,CAAC;IAEnC,YAAY,CACV,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,EACnC,aAAa,EAAE,MAAM,GACpB,OAAO;IAQV,kBAAkB,CAChB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,EACnC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,GACZ,IAAI;IAWP,sBAAsB,CACpB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,EACnC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,CAAC,CAAC,UAAU,GACvB,IAAI;CAUR;AAED,qBAAa,gBAAgB;IACf,OAAO,CAAC,KAAK;gBAAL,KAAK,EAAE,OAAO,CAAC;IAEnC,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO;IASnD,aAAa,CACX,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,EACtB,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,OAAO;IASV,kBAAkB,CAChB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,EAC5B,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,OAAO;IAoBV,cAAc,CACZ,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAClC,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,OAAO;IAOV,uBAAuB,CACrB,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,EAC5C,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,OAAO;CAMX"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { JSXUtils } from "../jsx-utils.js";
|
|
2
|
+
export class JSXAttributeUtils {
|
|
3
|
+
types;
|
|
4
|
+
constructor(types) {
|
|
5
|
+
this.types = types;
|
|
6
|
+
}
|
|
7
|
+
hasAttribute(path, attributeName) {
|
|
8
|
+
return path.node.attributes.some((attr) => this.types.isJSXAttribute(attr) &&
|
|
9
|
+
JSXUtils.getAttributeName(attr) === attributeName);
|
|
10
|
+
}
|
|
11
|
+
addStringAttribute(path, attributeName, value) {
|
|
12
|
+
if (!this.hasAttribute(path, attributeName)) {
|
|
13
|
+
path.node.attributes.push(this.types.jsxAttribute(this.types.jsxIdentifier(attributeName), this.types.stringLiteral(value)));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
addExpressionAttribute(path, attributeName, expression) {
|
|
17
|
+
if (!this.hasAttribute(path, attributeName)) {
|
|
18
|
+
path.node.attributes.push(this.types.jsxAttribute(this.types.jsxIdentifier(attributeName), this.types.jsxExpressionContainer(expression)));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class StaticValueUtils {
|
|
23
|
+
types;
|
|
24
|
+
constructor(types) {
|
|
25
|
+
this.types = types;
|
|
26
|
+
}
|
|
27
|
+
isPrimitiveLiteral(path) {
|
|
28
|
+
return (path.isStringLiteral() ||
|
|
29
|
+
path.isNumericLiteral() ||
|
|
30
|
+
path.isBooleanLiteral() ||
|
|
31
|
+
path.isNullLiteral());
|
|
32
|
+
}
|
|
33
|
+
isStaticValue(path, visited = new Set()) {
|
|
34
|
+
if (this.isPrimitiveLiteral(path))
|
|
35
|
+
return true;
|
|
36
|
+
if (path.isIdentifier())
|
|
37
|
+
return this.isStaticIdentifier(path, visited);
|
|
38
|
+
if (path.isObjectExpression())
|
|
39
|
+
return this.isStaticObject(path, visited);
|
|
40
|
+
if (path.isArrayExpression())
|
|
41
|
+
return this.isStaticArrayExpression(path, visited);
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
isStaticIdentifier(path, visited = new Set()) {
|
|
45
|
+
const binding = path.scope.getBinding(path.node.name);
|
|
46
|
+
if (!binding)
|
|
47
|
+
return false;
|
|
48
|
+
if (binding.kind === "module")
|
|
49
|
+
return true;
|
|
50
|
+
if (binding.kind === "const" && binding.path.isVariableDeclarator()) {
|
|
51
|
+
const name = path.node.name;
|
|
52
|
+
if (visited.has(name))
|
|
53
|
+
return false;
|
|
54
|
+
visited.add(name);
|
|
55
|
+
const init = binding.path.get("init");
|
|
56
|
+
if (init.hasNode()) {
|
|
57
|
+
return this.isStaticValue(init, visited);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
isStaticObject(path, visited = new Set()) {
|
|
63
|
+
return path.get("properties").every((prop) => {
|
|
64
|
+
if (!prop.isObjectProperty())
|
|
65
|
+
return false;
|
|
66
|
+
return this.isStaticValue(prop.get("value"), visited);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
isStaticArrayExpression(arrayExpression, visited = new Set()) {
|
|
70
|
+
return arrayExpression.get("elements").every((element) => {
|
|
71
|
+
if (!element.node || element.isSpreadElement())
|
|
72
|
+
return true;
|
|
73
|
+
return this.isStaticValue(element, visited);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=shared-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-utils.js","sourceRoot":"","sources":["../../src/processors/shared-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,OAAO,iBAAiB;IACR;IAApB,YAAoB,KAAe;QAAf,UAAK,GAAL,KAAK,CAAU;IAAG,CAAC;IAEvC,YAAY,CACV,IAAmC,EACnC,aAAqB;QAErB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAC9B,CAAC,IAA2C,EAAE,EAAE,CAC9C,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;YAC/B,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,aAAa,CACpD,CAAC;IACJ,CAAC;IAED,kBAAkB,CAChB,IAAmC,EACnC,aAAqB,EACrB,KAAa;QAEb,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,aAAa,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CACvB,IAAI,CAAC,KAAK,CAAC,YAAY,CACrB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,EACvC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAChC,CACF,CAAC;QACJ,CA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AE;YACvD,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE;gBAAE,OAAO,IAAI,CAAC;YAC5D,OAAO,IAAI,CAAC,aAAa,CAAC,OAAsC,EAAE,OAAO,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { NodePath } from "@babel/traverse";
|
|
2
|
+
import type * as t from "@babel/types";
|
|
3
|
+
export declare const DATA_ARR_INDEX = "data-arr-index";
|
|
4
|
+
export declare const DATA_ARR_VARIABLE_NAME = "data-arr-variable-name";
|
|
5
|
+
export declare const DATA_ARR_FIELD = "data-arr-field";
|
|
6
|
+
export declare class StaticArrayProcessor {
|
|
7
|
+
private types;
|
|
8
|
+
private attributeUtils;
|
|
9
|
+
private staticValueUtils;
|
|
10
|
+
constructor(types: typeof t);
|
|
11
|
+
process(path: NodePath<t.JSXOpeningElement>): void;
|
|
12
|
+
private addDataAttributes;
|
|
13
|
+
private findTextContentFieldPath;
|
|
14
|
+
private extractFieldPathFromChild;
|
|
15
|
+
private extractFieldPath;
|
|
16
|
+
private collectMemberExpressionParts;
|
|
17
|
+
private ensureIndexParam;
|
|
18
|
+
private addIndexParamToCallback;
|
|
19
|
+
private getMapCallback;
|
|
20
|
+
private findParentArrayMap;
|
|
21
|
+
private tryExtractMapInfo;
|
|
22
|
+
private isMapCall;
|
|
23
|
+
private extractArrayMapInfo;
|
|
24
|
+
private extractIndexParam;
|
|
25
|
+
private extractArrayVariableName;
|
|
26
|
+
private isStaticArray;
|
|
27
|
+
private resolveArrayExpression;
|
|
28
|
+
private resolveIdentifierToArray;
|
|
29
|
+
private isStaticArrayExpression;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=static-array-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-array-processor.d.ts","sourceRoot":"","sources":["../../src/processors/static-array-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AAGvC,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAW/C,qBAAa,oBAAoB;IAInB,OAAO,CAAC,KAAK;IAHzB,OAAO,CAAC,cAAc,CAAoB;IAC1C,OAAO,CAAC,gBAAgB,CAAmB;gBAEvB,KAAK,EAAE,OAAO,CAAC;IAKnC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAUlD,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,wBAAwB;IAehC,OAAO,CAAC,yBAAyB;IAYjC,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,4BAA4B;IAmBpC,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,uBAAuB;IAY/B,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,mBAAmB;IAsB3B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,wBAAwB;IAWhC,OAAO,CAAC,uBAAuB;CAKhC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { JSXAttributeUtils, StaticValueUtils } from "./shared-utils.js";
|
|
2
|
+
export const DATA_ARR_INDEX = "data-arr-index";
|
|
3
|
+
export const DATA_ARR_VARIABLE_NAME = "data-arr-variable-name";
|
|
4
|
+
export const DATA_ARR_FIELD = "data-arr-field";
|
|
5
|
+
const GENERATED_INDEX_PARAM = "__arrIdx__";
|
|
6
|
+
export class StaticArrayProcessor {
|
|
7
|
+
types;
|
|
8
|
+
attributeUtils;
|
|
9
|
+
staticValueUtils;
|
|
10
|
+
constructor(types) {
|
|
11
|
+
this.types = types;
|
|
12
|
+
this.attributeUtils = new JSXAttributeUtils(types);
|
|
13
|
+
this.staticValueUtils = new StaticValueUtils(types);
|
|
14
|
+
}
|
|
15
|
+
process(path) {
|
|
16
|
+
const arrayInfo = this.findParentArrayMap(path);
|
|
17
|
+
if (!arrayInfo)
|
|
18
|
+
return;
|
|
19
|
+
if (!this.isStaticArray(arrayInfo.arrayExpression))
|
|
20
|
+
return;
|
|
21
|
+
const indexIdentifier = this.ensureIndexParam(arrayInfo);
|
|
22
|
+
this.addDataAttributes(path, arrayInfo, indexIdentifier);
|
|
23
|
+
}
|
|
24
|
+
addDataAttributes(path, arrayInfo, indexIdentifier) {
|
|
25
|
+
this.attributeUtils.addExpressionAttribute(path, DATA_ARR_INDEX, this.types.identifier(indexIdentifier));
|
|
26
|
+
if (arrayInfo.arrayVariableName) {
|
|
27
|
+
this.attributeUtils.addStringAttribute(path, DATA_ARR_VARIABLE_NAME, arrayInfo.arrayVariableName);
|
|
28
|
+
}
|
|
29
|
+
const fieldPath = this.findTextContentFieldPath(path, arrayInfo.callbackParam);
|
|
30
|
+
if (fieldPath) {
|
|
31
|
+
this.attributeUtils.addStringAttribute(path, DATA_ARR_FIELD, fieldPath);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
findTextContentFieldPath(path, callbackParam) {
|
|
35
|
+
const parentElement = path.parentPath;
|
|
36
|
+
if (!parentElement?.isJSXElement())
|
|
37
|
+
return null;
|
|
38
|
+
for (const child of parentElement.get("children")) {
|
|
39
|
+
const fieldPath = this.extractFieldPathFromChild(child, callbackParam);
|
|
40
|
+
if (fieldPath)
|
|
41
|
+
return fieldPath;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
extractFieldPathFromChild(child, callbackParam) {
|
|
46
|
+
if (!child.isJSXExpressionContainer())
|
|
47
|
+
return null;
|
|
48
|
+
const expression = child.get("expression");
|
|
49
|
+
if (!expression.isMemberExpression())
|
|
50
|
+
return null;
|
|
51
|
+
return this.extractFieldPath(expression, callbackParam);
|
|
52
|
+
}
|
|
53
|
+
extractFieldPath(expr, callbackParam) {
|
|
54
|
+
const parts = this.collectMemberExpressionParts(expr);
|
|
55
|
+
if (!parts)
|
|
56
|
+
return null;
|
|
57
|
+
const { rootName, propertyNames } = parts;
|
|
58
|
+
return rootName === callbackParam ? propertyNames.join(".") : null;
|
|
59
|
+
}
|
|
60
|
+
collectMemberExpressionParts(expr) {
|
|
61
|
+
const propertyNames = [];
|
|
62
|
+
let current = expr;
|
|
63
|
+
while (current.isMemberExpression()) {
|
|
64
|
+
const property = current.get("property");
|
|
65
|
+
if (!property.isIdentifier())
|
|
66
|
+
return null;
|
|
67
|
+
propertyNames.unshift(property.node.name);
|
|
68
|
+
current = current.get("object");
|
|
69
|
+
}
|
|
70
|
+
if (!current.isIdentifier())
|
|
71
|
+
return null;
|
|
72
|
+
return { rootName: current.node.name, propertyNames };
|
|
73
|
+
}
|
|
74
|
+
ensureIndexParam(arrayInfo) {
|
|
75
|
+
if (arrayInfo.indexParam) {
|
|
76
|
+
return arrayInfo.indexParam;
|
|
77
|
+
}
|
|
78
|
+
this.addIndexParamToCallback(arrayInfo.mapCallPath);
|
|
79
|
+
return GENERATED_INDEX_PARAM;
|
|
80
|
+
}
|
|
81
|
+
addIndexParamToCallback(mapCallPath) {
|
|
82
|
+
const callback = this.getMapCallback(mapCallPath);
|
|
83
|
+
if (!callback)
|
|
84
|
+
return;
|
|
85
|
+
const params = callback.get("params");
|
|
86
|
+
if (params.length === 1) {
|
|
87
|
+
callback.node.params.push(this.types.identifier(GENERATED_INDEX_PARAM));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
getMapCallback(mapCallPath) {
|
|
91
|
+
const args = mapCallPath.get("arguments");
|
|
92
|
+
const firstArg = args[0];
|
|
93
|
+
if (firstArg && firstArg.isFunction()) {
|
|
94
|
+
return firstArg;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
findParentArrayMap(path, maxDepth = 5) {
|
|
99
|
+
let currentPath = path;
|
|
100
|
+
let depth = 0;
|
|
101
|
+
while (currentPath.parentPath && depth < maxDepth) {
|
|
102
|
+
const mapInfo = this.tryExtractMapInfo(currentPath.parentPath);
|
|
103
|
+
if (mapInfo)
|
|
104
|
+
return mapInfo;
|
|
105
|
+
currentPath = currentPath.parentPath;
|
|
106
|
+
depth++;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
tryExtractMapInfo(parent) {
|
|
111
|
+
if (!parent.isCallExpression())
|
|
112
|
+
return null;
|
|
113
|
+
if (!this.isMapCall(parent))
|
|
114
|
+
return null;
|
|
115
|
+
return this.extractArrayMapInfo(parent);
|
|
116
|
+
}
|
|
117
|
+
isMapCall(callExpr) {
|
|
118
|
+
const callee = callExpr.get("callee");
|
|
119
|
+
if (!callee.isMemberExpression())
|
|
120
|
+
return false;
|
|
121
|
+
const property = callee.get("property");
|
|
122
|
+
return property.isIdentifier() && property.node.name === "map";
|
|
123
|
+
}
|
|
124
|
+
extractArrayMapInfo(mapCall) {
|
|
125
|
+
const callback = this.getMapCallback(mapCall);
|
|
126
|
+
if (!callback)
|
|
127
|
+
return null;
|
|
128
|
+
const params = callback.get("params");
|
|
129
|
+
const firstParam = params[0];
|
|
130
|
+
if (!firstParam || !firstParam.isIdentifier())
|
|
131
|
+
return null;
|
|
132
|
+
const callee = mapCall.get("callee");
|
|
133
|
+
const arrayExpression = callee.get("object");
|
|
134
|
+
return {
|
|
135
|
+
arrayExpression,
|
|
136
|
+
callbackParam: firstParam.node.name,
|
|
137
|
+
indexParam: this.extractIndexParam(params),
|
|
138
|
+
arrayVariableName: this.extractArrayVariableName(arrayExpression),
|
|
139
|
+
mapCallPath: mapCall,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
extractIndexParam(params) {
|
|
143
|
+
const secondParam = params[1];
|
|
144
|
+
return secondParam && secondParam.isIdentifier()
|
|
145
|
+
? secondParam.node.name
|
|
146
|
+
: null;
|
|
147
|
+
}
|
|
148
|
+
extractArrayVariableName(arrayExpression) {
|
|
149
|
+
return arrayExpression.isIdentifier() ? arrayExpression.node.name : null;
|
|
150
|
+
}
|
|
151
|
+
isStaticArray(arrayExpression) {
|
|
152
|
+
const arrayExpr = this.resolveArrayExpression(arrayExpression);
|
|
153
|
+
return arrayExpr ? this.isStaticArrayExpression(arrayExpr) : false;
|
|
154
|
+
}
|
|
155
|
+
resolveArrayExpression(expression) {
|
|
156
|
+
if (expression.isArrayExpression()) {
|
|
157
|
+
return expression;
|
|
158
|
+
}
|
|
159
|
+
if (expression.isIdentifier()) {
|
|
160
|
+
return this.resolveIdentifierToArray(expression);
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
resolveIdentifierToArray(identifier) {
|
|
165
|
+
const binding = identifier.scope.getBinding(identifier.node.name);
|
|
166
|
+
if (!binding?.path.isVariableDeclarator())
|
|
167
|
+
return null;
|
|
168
|
+
const init = binding.path.get("init");
|
|
169
|
+
return init.isArrayExpression() ? init : null;
|
|
170
|
+
}
|
|
171
|
+
isStaticArrayExpression(arrayExpression) {
|
|
172
|
+
return this.staticValueUtils.isStaticArrayExpression(arrayExpression);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=static-array-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-array-processor.js","sourceRoot":"","sources":["../../src/processors/static-array-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAExE,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,wB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AC,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACrE,CAAC;IAEO,sBAAsB,CAC5B,UAAkC;QAElC,IAAI,UAAU,CAAC,iBAAiB,EAAE,EAAE,CAAC;YACnC,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,IAAI,UAAU,CAAC,YAAY,EAAE,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,wBAAwB,CAC9B,UAAkC;QAElC,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAElE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE;YAAE,OAAO,IAAI,CAAC;QAEvD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAChD,CAAC;IAEO,uBAAuB,CAC7B,eAA4C;QAE5C,OAAO,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC;IACxE,CAAC;CACF"}
|
package/dist/statics/index.mjs
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
[data-selected="true"][contenteditable="true"]:focus {
|
|
3
|
-
outline: none !important;
|
|
4
|
-
}
|
|
5
|
-
`,document.head.appendChild(t)}function M(){let e=document.getElementById("visual-edit-focus-styles");e&&e.remove()}function L(e){let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}function b(e){return!(!(e instanceof HTMLElement)||!["div","p","h1","h2","h3","h4","h5","h6","span","li","td","a","button","label"].includes(e.tagName.toLowerCase())||(e.textContent?.trim()||"").length===0||e.querySelector("img, video, canvas, svg")!==null||e.children.length>0||e.dataset.dynamicContent==="true")}var x=null;function A(e){x=e}var C=new WeakMap;function ee(e){x&&x(this)}function f(e){return!(!(e instanceof HTMLElement)||e.dataset.selected!=="true"||!b(e))}function _(e){y(),e.dataset.originalTextContent=e.textContent||"",e.dataset.originalCursor=e.style.cursor,e.contentEditable="true";let t=new AbortController;C.set(e,t),e.addEventListener("input",ee,{signal:t.signal}),e.style.cursor="text",L(e),setTimeout(()=>{e.focus()},0)}function D(e){let t=C.get(e);t&&(t.abort(),C.delete(e)),e.isConnected&&(M(),e.contentEditable="false",delete e.dataset.originalTextContent,e.dataset.originalCursor!==void 0&&(e.style.cursor=e.dataset.originalCursor,delete e.dataset.originalCursor))}function p(e){return{top:e.top,left:e.left,right:e.right,bottom:e.bottom,width:e.width,height:e.height,centerX:e.left+e.width/2,centerY:e.top+e.height/2}}function Y(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function T(e){return e instanceof SVGElement?e.className?.baseVal||"":e.className||""}function v(e,t){e.currentEditingElement=t,e.selectedOverlays.forEach(n=>{n.style.display="none"}),_(t),window.parent.postMessage({type:"content-editing-started",visualSelectorId:e.selectedElementId},"*")}function s(e){if(!e.currentEditingElement)return;e.debouncedSendTimeout&&(clearTimeout(e.debouncedSendTimeout),e.debouncedSendTimeout=null);let t=e.currentEditingElement;D(t),e.selectedOverlays.forEach(n=>{n.style.display=""}),u(e),window.parent.postMessage({type:"content-editing-ended",visualSelectorId:e.selectedElementId},"*"),e.currentEditingElement=null}function ne(e,t){let n=t.dataset.originalTextContent,o=t.textContent,i={tagName:t.tagName,classes:T(t),visualSelectorId:e.selectedElementId,content:o,dataSourceLocation:t.dataset.sourceLocation,isDynamicContent:t.dataset.dynamicContent==="true",linenumber:t.dataset.linenumber,filename:t.dataset.filename,position:p(t.getBoundingClientRect())};window.parent.postMessage({type:"inline-edit",elementInfo:i,originalContent:n,newContent:o},"*"),t.dataset.originalTextContent=o||""}function oe(e,t){e.debouncedSendTimeout&&clearTimeout(e.debouncedSendTimeout),e.debouncedSendTimeout=setTimeout(()=>{ne(e,t)},500)}function ie(e){return t=>{u(e),oe(e,t)}}function $(e){A(ie(e))}function re(e,t,n){e.currentEditingElement&&s(e),c(e);let o=l(n);e.isInlineEditExperimentEnabled&&o.forEach(d=>{d instanceof HTMLElement&&(d.dataset.selected="true")}),o.forEach(d=>{let g=m(!0);document.body.appendChild(g),e.selectedOverlays.push(g),E(g,d,!0,e.isVisualEditMode)}),e.selectedElementId=n,a(e);let i=t,r={type:"element-selected",tagName:t.tagName,classes:T(t),visualSelectorId:n,content:i.innerText,dataSourceLocation:i.dataset.sourceLocation,isDynamicContent:i.dataset.dynamicContent==="true",linenumber:i.dataset.linenumber,filename:i.dataset.filename,position:p(t.getBoundingClientRect())};window.parent.postMessage(r,"*")}function q(e,t){if(!e.isVisualEditMode)return;let n=t.target;if(e.isInlineEditExperimentEnabled&&n instanceof HTMLElement&&n.contentEditable==="true")return;if(e.currentEditingElement){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),s(e);return}if(e.isDropdownOpen){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),window.parent.postMessage({type:"close-dropdowns"},"*");return}if(n.tagName.toLowerCase()==="path")return;t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();let o=n.closest("[data-source-location], [data-visual-selector-id]");if(!o)return;let i=o,r=i.dataset.sourceLocation||i.dataset.visualSelectorId;if(e.selectedElementId===r&&i.dataset.selected==="true"&&e.isInlineEditExperimentEnabled&&f(i)){v(e,i);return}re(e,o,r||null)}function le(e,t){e.isVisualEditMode=t,t?document.body.style.cursor="crosshair":(e.currentEditingElement&&s(e),a(e),c(e),e.currentHighlightedElements=[],document.body.style.cursor="default")}function z(e,t){le(e,t.data.enabled),t.data.specs?.newInlineEditEnabled!==void 0&&(e.isInlineEditExperimentEnabled=t.data.specs.newInlineEditEnabled)}function X(e,t){if(!e.isInlineEditExperimentEnabled||!t.data||!t.data.dataSourceLocation)return;let n=l(t.data.dataSourceLocation);if(n.length===0||!(n[0]instanceof HTMLElement))return;let o=n[0];t.data.inlineEditingMode?f(o)&&(e.selectedElementId!==t.data.dataSourceLocation&&(e.currentEditingElement&&s(e),c(e),n.forEach(i=>{i instanceof HTMLElement&&(i.dataset.selected="true")}),n.forEach(i=>{let r=m(!0);document.body.appendChild(r),e.selectedOverlays.push(r),E(r,i,!0,e.isVisualEditMode)}),e.selectedElementId=t.data.dataSourceLocation),v(e,o)):e.currentEditingElement===o&&s(e)}function K(e){if(!e.selectedElementId)return;let t=l(e.selectedElementId),[n]=t;if(!n)return;let o=n.getBoundingClientRect();window.parent.postMessage({type:"element-position-update",position:p(o),isInViewport:Y(o),visualSelectorId:e.selectedElementId},"*")}function ae(e){e.currentEditingElement&&s(e),c(e)}function se(e,t,n){let o=l(t);o.length!==0&&(P(o,n),setTimeout(()=>{e.selectedElementId===t&&u(e),e.currentHighlightedElements.length>0&&e.currentHighlightedElements[0]?.dataset?.visualSelectorId===t&&O(e)},50))}function de(e,t,n){let o=l(t);o.length!==0&&(o.forEach(i=>{i.innerText=n}),setTimeout(()=>{e.selectedElementId===t&&u(e)},50))}function w(e){K(e)}function I(e){u(e),O(e)}function Z(e,t){let n=t.data;switch(n.type){case"toggle-visual-edit-mode":z(e,n);break;case"update-classes":n.data&&n.data.classes!==void 0?se(e,n.data.visualSelectorId,n.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",n);break;case"unselect-element":ae(e);break;case"refresh-page":window.location.reload();break;case"update-content":n.data&&n.data.content!==void 0?de(e,n.data.visualSelectorId,n.data.content):console.warn("[VisualEditAgent] Invalid update-content message:",n);break;case"toggle-inline-edit-mode":X(e,n);break;case"request-element-position":K(e);break;case"popover-drag-state":n.data&&n.data.isDragging!==void 0&&(e.isPopoverDragging=n.data.isDragging,n.data.isDragging&&a(e));break;case"dropdown-state":n.data&&n.data.isOpen!==void 0&&(e.isDropdownOpen=n.data.isOpen,n.data.isOpen&&a(e));break;default:break}}function Ee(){document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])").forEach((t,n)=>{let o=t,i=`visual-id-${o.dataset.filename}-${o.dataset.linenumber}-${n}`;o.dataset.visualSelectorId=i})}function ce(e){let t=null,n=o=>{if(o.nodeType!==Node.ELEMENT_NODE)return!1;let i=o;if(i.dataset?.visualSelectorId)return!0;for(let r of Array.from(i.children))if(n(r))return!0;return!1};return new MutationObserver(o=>{if(t!==null)return;o.some(r=>r.type==="attributes"&&(r.attributeName==="style"||r.attributeName==="class"||r.attributeName==="width"||r.attributeName==="height")&&n(r.target))&&(t=requestAnimationFrame(()=>{t=null,e()}))})}function ue(e){window.addEventListener("message",t=>Z(e,t)),window.addEventListener("scroll",()=>w(e),!0),document.addEventListener("scroll",()=>w(e),!0),window.addEventListener("resize",()=>I(e)),window.addEventListener("scroll",()=>I(e)),document.addEventListener("click",t=>q(e,t),!0),document.addEventListener("mouseover",t=>j(e,t)),document.addEventListener("mouseout",()=>W(e))}function J(){let e=R();Ee(),$(e),ue(e),ce(()=>I(e)).observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class","width","height"]}),window.parent.postMessage({type:"visual-edit-agent-ready"},"*")}export{J as setupVisualEditAgent};
|
|
1
|
+
function f(d){if(!d)return[];let h=Array.from(document.querySelectorAll(`[data-source-location="${d}"]`));return h.length>0?h:Array.from(document.querySelectorAll(`[data-visual-selector-id="${d}"]`))}function T(d,h){d.forEach(g=>{g.setAttribute("class",h)})}function V(){let d=!1,h=!1,g=!1,E=[],c=[],u=[],l=null,L=(n=!1)=>{let e=document.createElement("div");return e.style.position="absolute",e.style.pointerEvents="none",e.style.transition="all 0.1s ease-in-out",e.style.zIndex="9999",n?e.style.border="2px solid #2563EB":(e.style.border="2px solid #95a5fc",e.style.backgroundColor="rgba(99, 102, 241, 0.05)"),e},p=(n,e,t=!1)=>{if(!e||!d)return;e.offsetWidth;let s=e.getBoundingClientRect();n.style.top=`${s.top+window.scrollY}px`,n.style.left=`${s.left+window.scrollX}px`,n.style.width=`${s.width}px`,n.style.height=`${s.height}px`;let o=n.querySelector("div");o||(o=document.createElement("div"),o.textContent=e.tagName.toLowerCase(),o.style.position="absolute",o.style.top="-27px",o.style.left="-2px",o.style.padding="2px 8px",o.style.fontSize="11px",o.style.fontWeight=t?"500":"400",o.style.color=t?"#ffffff":"#526cff",o.style.backgroundColor=t?"#526cff":"#DBEAFE",o.style.borderRadius="3px",o.style.minWidth="24px",o.style.textAlign="center",n.appendChild(o))},m=()=>{E.forEach(n=>{n&&n.parentNode&&n.remove()}),E=[],u=[]},M=n=>{if(!d||h)return;let e=n.target;if(g){m();return}if(e.tagName.toLowerCase()==="path"){m();return}let t=e.closest("[data-source-location], [data-visual-selector-id]");if(!t){m();return}let a=t,s=a.dataset.sourceLocation||a.dataset.visualSelectorId;if(l===s){m();return}let o=f(s||null);m(),o.forEach(i=>{let r=L(!1);document.body.appendChild(r),E.push(r),p(r,i)}),u=o},I=()=>{h||m()},C=n=>{if(!d)return;let e=n.target;if(g){n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),window.parent.postMessage({type:"close-dropdowns"},"*");return}if(e.tagName.toLowerCase()==="path")return;n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation();let t=e.closest("[data-source-location], [data-visual-selector-id]");if(!t)return;let a=t,s=a.dataset.sourceLocation||a.dataset.visualSelectorId;c.forEach(v=>{v&&v.parentNode&&v.remove()}),c=[],f(s||null).forEach(v=>{let y=L(!0);document.body.appendChild(y),c.push(y),p(y,v,!0)}),l=s||null,m();let i=t.getBoundingClientRect(),r={top:i.top,left:i.left,right:i.right,bottom:i.bottom,width:i.width,height:i.height,centerX:i.left+i.width/2,centerY:i.top+i.height/2},b=t,O={type:"element-selected",tagName:t.tagName,classes:b.className?.baseVal||t.className||"",visualSelectorId:s,content:t.innerText,dataSourceLocation:a.dataset.sourceLocation,isDynamicContent:a.dataset.dynamicContent==="true",linenumber:a.dataset.linenumber,filename:a.dataset.filename,position:r};window.parent.postMessage(O,"*")},H=()=>{c.forEach(n=>{n&&n.parentNode&&n.remove()}),c=[],l=null},x=(n,e)=>{let t=f(n);t.length!==0&&(T(t,e),setTimeout(()=>{l===n&&c.forEach((a,s)=>{s<t.length&&p(a,t[s])}),u.length>0&&u[0]?.dataset?.visualSelectorId===n&&E.forEach((o,i)=>{i<u.length&&p(o,u[i])})},50))},D=(n,e)=>{let t=f(n);t.length!==0&&(t.forEach(a=>{a.innerText=e}),setTimeout(()=>{l===n&&c.forEach((a,s)=>{s<t.length&&p(a,t[s])})},50))},S=n=>{d=n,n?(document.body.style.cursor="crosshair",document.addEventListener("mouseover",M),document.addEventListener("mouseout",I),document.addEventListener("click",C,!0)):(m(),c.forEach(e=>{e&&e.parentNode&&e.remove()}),c=[],u=[],l=null,document.body.style.cursor="default",document.removeEventListener("mouseover",M),document.removeEventListener("mouseout",I),document.removeEventListener("click",C,!0))},N=()=>{if(l){let n=f(l);if(n.length>0){let t=n[0].getBoundingClientRect(),a=window.innerHeight,s=window.innerWidth,o=t.top<a&&t.bottom>0&&t.left<s&&t.right>0,i={top:t.top,left:t.left,right:t.right,bottom:t.bottom,width:t.width,height:t.height,centerX:t.left+t.width/2,centerY:t.top+t.height/2};window.parent.postMessage({type:"element-position-update",position:i,isInViewport:o,visualSelectorId:l},"*")}}},k=n=>{let e=n.data;switch(e.type){case"toggle-visual-edit-mode":S(e.data.enabled);break;case"update-classes":e.data&&e.data.classes!==void 0?x(e.data.visualSelectorId,e.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",e);break;case"unselect-element":H();break;case"refresh-page":window.location.reload();break;case"update-content":e.data&&e.data.content!==void 0?D(e.data.visualSelectorId,e.data.content):console.warn("[VisualEditAgent] Invalid update-content message:",e);break;case"request-element-position":if(l){let t=f(l);if(t.length>0){let s=t[0].getBoundingClientRect(),o=window.innerHeight,i=window.innerWidth,r=s.top<o&&s.bottom>0&&s.left<i&&s.right>0,b={top:s.top,left:s.left,right:s.right,bottom:s.bottom,width:s.width,height:s.height,centerX:s.left+s.width/2,centerY:s.top+s.height/2};window.parent.postMessage({type:"element-position-update",position:b,isInViewport:r,visualSelectorId:l},"*")}}break;case"popover-drag-state":e.data&&e.data.isDragging!==void 0&&(h=e.data.isDragging,e.data.isDragging&&m());break;case"dropdown-state":e.data&&e.data.isOpen!==void 0&&(g=e.data.isOpen,e.data.isOpen&&m());break;default:break}},w=()=>{if(l){let n=f(l);c.forEach((e,t)=>{t<n.length&&p(e,n[t])})}u.length>0&&E.forEach((n,e)=>{e<u.length&&p(n,u[e])})};document.querySelectorAll("[data-linenumber]:not([data-visual-selector-id])").forEach((n,e)=>{let t=n,a=`visual-id-${t.dataset.filename}-${t.dataset.linenumber}-${e}`;t.dataset.visualSelectorId=a});let A=new MutationObserver(n=>{n.some(t=>{let a=o=>{if(o.nodeType===Node.ELEMENT_NODE){let i=o;if(i.dataset&&i.dataset.visualSelectorId)return!0;for(let r=0;r<i.children.length;r++)if(a(i.children[r]))return!0}return!1};return t.type==="attributes"&&(t.attributeName==="style"||t.attributeName==="class"||t.attributeName==="width"||t.attributeName==="height")&&a(t.target)})&&setTimeout(w,50)});window.addEventListener("message",k),window.addEventListener("scroll",N,!0),document.addEventListener("scroll",N,!0),window.addEventListener("resize",w),window.addEventListener("scroll",w),A.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class","width","height"]}),window.parent.postMessage({type:"visual-edit-agent-ready"},"*")}export{V as setupVisualEditAgent};
|
|
6
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/injections/visual-edit-agent/state/agent-state.ts","../../src/injections/utils.ts","../../src/injections/visual-edit-agent/constants.ts","../../src/injections/visual-edit-agent/ui/overlay.ts","../../src/injections/visual-edit-agent/handlers/hover-handlers.ts","../../src/injections/visual-edit-agent/capabilities/inline-editing/styles.ts","../../src/injections/visual-edit-agent/capabilities/inline-editing/validation.ts","../../src/injections/visual-edit-agent/capabilities/inline-editing/core.ts","../../src/injections/visual-edit-agent/utils/dom-utils.ts","../../src/injections/visual-edit-agent/handlers/inline-edit-handlers.ts","../../src/injections/visual-edit-agent/handlers/click-handlers.ts","../../src/injections/visual-edit-agent/handlers/messages/toggle-visual-edit-mode.ts","../../src/injections/visual-edit-agent/handlers/messages/toggle-inline-edit-mode.ts","../../src/injections/visual-edit-agent/handlers/message-handlers.ts","../../src/injections/visual-edit-agent/index.ts"],"sourcesContent":["/**\n * Central state management for the visual edit agent\n */\n\nexport interface AgentState {\n isVisualEditMode: boolean;\n isPopoverDragging: boolean;\n isDropdownOpen: boolean;\n hoverOverlays: HTMLDivElement[];\n selectedOverlays: HTMLDivElement[];\n currentHighlightedElements: Element[];\n selectedElementId: string | null;\n currentEditingElement: HTMLElement | null;\n debouncedSendTimeout: ReturnType<typeof setTimeout> | null;\n isInlineEditExperimentEnabled: boolean;\n}\n\nexport function createAgentState(): AgentState {\n return {\n isVisualEditMode: false,\n isPopoverDragging: false,\n isDropdownOpen: false,\n hoverOverlays: [],\n selectedOverlays: [],\n currentHighlightedElements: [],\n selectedElementId: null,\n currentEditingElement: null,\n debouncedSendTimeout: null,\n isInlineEditExperimentEnabled: false,\n };\n}\n","/** Find elements by ID - first try data-source-location, fallback to data-visual-selector-id */\nexport function findElementsById(id: string | null): Element[] {\n if (!id) return [];\n const sourceElements = Array.from(\n document.querySelectorAll(`[data-source-location=\"${id}\"]`)\n );\n if (sourceElements.length > 0) {\n return sourceElements;\n }\n return Array.from(\n document.querySelectorAll(`[data-visual-selector-id=\"${id}\"]`)\n );\n}\n\n/**\n * Update element classes by visual selector ID.\n * Uses setAttribute instead of className to support both HTML and SVG elements.\n */\nexport function updateElementClasses(elements: Element[], classes: string): void {\n elements.forEach((element) => {\n element.setAttribute(\"class\", classes);\n }); \n}\n","export const INLINE_EDIT_DEBOUNCE_MS = 500;\nexport const OVERLAY_TRANSITION = \"all 0.1s ease-in-out\";\nexport const OVERLAY_Z_INDEX = \"9999\";\nexport const SELECTED_BORDER_COLOR = \"#2563EB\";\nexport const HOVER_BORDER_COLOR = \"#95a5fc\";\nexport const HOVER_BACKGROUND_COLOR = \"rgba(99, 102, 241, 0.05)\";\nexport const LABEL_TOP_OFFSET = \"-27px\";\nexport const LABEL_LEFT_OFFSET = \"-2px\";\nexport const REPOSITION_DELAY_MS = 50;\n","import {\n OVERLAY_TRANSITION,\n OVERLAY_Z_INDEX,\n SELECTED_BORDER_COLOR,\n HOVER_BORDER_COLOR,\n HOVER_BACKGROUND_COLOR,\n LABEL_TOP_OFFSET,\n LABEL_LEFT_OFFSET,\n} from \"../constants.js\";\nimport type { AgentState } from \"../state/agent-state.js\";\nimport { findElementsById } from \"../../utils.js\";\n\n/**\n * Create an overlay element for highlighting\n */\nexport function createOverlay(isSelected = false): HTMLDivElement {\n const overlay = document.createElement(\"div\");\n overlay.style.position = \"absolute\";\n overlay.style.pointerEvents = \"none\";\n overlay.style.transition = OVERLAY_TRANSITION;\n overlay.style.zIndex = OVERLAY_Z_INDEX;\n\n if (isSelected) {\n overlay.style.border = `2px solid ${SELECTED_BORDER_COLOR}`;\n } else {\n overlay.style.border = `2px solid ${HOVER_BORDER_COLOR}`;\n overlay.style.backgroundColor = HOVER_BACKGROUND_COLOR;\n }\n\n return overlay;\n}\n\n/**\n * Position overlay relative to element\n */\nexport function positionOverlay(\n overlay: HTMLDivElement,\n element: Element,\n isSelected = false,\n isVisualEditMode = true\n): void {\n if (!element || !isVisualEditMode) return;\n\n // Force layout recalculation before reading bounding rect\n void (element as HTMLElement).offsetWidth;\n\n const rect = element.getBoundingClientRect();\n overlay.style.top = `${rect.top + window.scrollY}px`;\n overlay.style.left = `${rect.left + window.scrollX}px`;\n overlay.style.width = `${rect.width}px`;\n overlay.style.height = `${rect.height}px`;\n\n // Check if label already exists in overlay\n let label = overlay.querySelector(\"div\") as HTMLDivElement | null;\n\n if (!label) {\n label = document.createElement(\"div\");\n label.textContent = element.tagName.toLowerCase();\n label.style.position = \"absolute\";\n label.style.top = LABEL_TOP_OFFSET;\n label.style.left = LABEL_LEFT_OFFSET;\n label.style.padding = \"2px 8px\";\n label.style.fontSize = \"11px\";\n label.style.fontWeight = isSelected ? \"500\" : \"400\";\n label.style.color = isSelected ? \"#ffffff\" : \"#526cff\";\n label.style.backgroundColor = isSelected ? \"#526cff\" : \"#DBEAFE\";\n label.style.borderRadius = \"3px\";\n label.style.minWidth = \"24px\";\n label.style.textAlign = \"center\";\n overlay.appendChild(label);\n }\n}\n\n/**\n * Clear all overlays from DOM\n */\nexport function clearOverlays(overlays: HTMLDivElement[]): void {\n overlays.forEach((overlay) => {\n if (overlay && overlay.parentNode) {\n overlay.remove();\n }\n });\n}\n\n/**\n * Remove data-selected attribute, clear selected overlays, and reset selection state\n */\nexport function clearSelection(state: AgentState): void {\n if (state.isInlineEditExperimentEnabled && state.selectedElementId) {\n const elements = findElementsById(state.selectedElementId);\n elements.forEach((el) => {\n if (el instanceof HTMLElement) {\n delete el.dataset.selected;\n }\n });\n }\n clearOverlays(state.selectedOverlays);\n state.selectedOverlays = [];\n state.selectedElementId = null;\n}\n\n/**\n * Reposition selected overlays to match current element bounds\n */\nexport function repositionSelectedOverlays(state: AgentState): void {\n if (!state.selectedElementId) return;\n const elements = findElementsById(state.selectedElementId);\n state.selectedOverlays.forEach((overlay, index) => {\n const element = elements[index];\n if (element) {\n positionOverlay(overlay, element, true, state.isVisualEditMode);\n }\n });\n}\n\n/**\n * Reposition hover overlays to match current element bounds\n */\nexport function repositionHoverOverlays(state: AgentState): void {\n state.hoverOverlays.forEach((overlay, index) => {\n const element = state.currentHighlightedElements[index];\n if (element) {\n positionOverlay(overlay, element, false, state.isVisualEditMode);\n }\n });\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { findElementsById } from \"../../utils.js\";\nimport { createOverlay, positionOverlay, clearOverlays } from \"../ui/overlay.js\";\n\n/**\n * Clear hover overlays\n */\nexport function clearHoverOverlays(state: AgentState): void {\n clearOverlays(state.hoverOverlays);\n state.hoverOverlays = [];\n state.currentHighlightedElements = [];\n}\n\n/**\n * Handle mouse over event\n */\nexport function handleMouseOver(state: AgentState, e: MouseEvent): void {\n if (!state.isVisualEditMode || state.isPopoverDragging || state.currentEditingElement) return;\n\n const target = e.target as Element;\n\n // Prevent hover effects when a dropdown is open\n if (state.isDropdownOpen) {\n clearHoverOverlays(state);\n return;\n }\n\n // Prevent hover effects on SVG path elements\n if (target.tagName.toLowerCase() === \"path\") {\n clearHoverOverlays(state);\n return;\n }\n\n // Support both data-source-location and data-visual-selector-id\n const element = target.closest(\n \"[data-source-location], [data-visual-selector-id]\"\n );\n if (!element) {\n clearHoverOverlays(state);\n return;\n }\n\n // Prefer data-source-location, fallback to data-visual-selector-id\n const htmlElement = element as HTMLElement;\n const selectorId =\n htmlElement.dataset.sourceLocation ||\n htmlElement.dataset.visualSelectorId;\n\n // Skip if this element is already selected\n if (state.selectedElementId === selectorId) {\n clearHoverOverlays(state);\n return;\n }\n\n // Find all elements with the same ID\n const elements = findElementsById(selectorId || null);\n\n // Clear previous hover overlays\n clearHoverOverlays(state);\n\n // Create overlays for all matching elements\n elements.forEach((el) => {\n const overlay = createOverlay(false);\n document.body.appendChild(overlay);\n state.hoverOverlays.push(overlay);\n positionOverlay(overlay, el, false, state.isVisualEditMode);\n });\n\n state.currentHighlightedElements = elements;\n}\n\n/**\n * Handle mouse out event\n */\nexport function handleMouseOut(state: AgentState): void {\n if (state.isPopoverDragging || state.currentEditingElement) return;\n clearHoverOverlays(state);\n}\n","/**\n * Inject CSS to suppress the browser's default focus outline on contentEditable elements\n */\nexport function injectFocusOutlineCSS(): void {\n const existingStyle = document.getElementById(\"visual-edit-focus-styles\");\n if (existingStyle) return;\n\n const style = document.createElement(\"style\");\n style.id = \"visual-edit-focus-styles\";\n style.textContent = `\n [data-selected=\"true\"][contenteditable=\"true\"]:focus {\n outline: none !important;\n }\n `;\n document.head.appendChild(style);\n}\n\n/**\n * Remove the injected focus outline CSS\n */\nexport function removeFocusOutlineCSS(): void {\n const style = document.getElementById(\"visual-edit-focus-styles\");\n if (style) {\n style.remove();\n }\n}\n","/**\n * Select all text content in an element using the Selection API\n */\nexport function selectText(element: HTMLElement): void {\n const range = document.createRange();\n range.selectNodeContents(element);\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(range);\n}\n\n/**\n * Check if an element is an editable text element\n * Based on the eligibility rules from inlineEdit.md (non-dynamic only)\n */\nexport function isEditableTextElement(element: Element): boolean {\n // Must be an HTMLElement\n if (!(element instanceof HTMLElement)) {\n return false;\n }\n\n // Must be an allowed tag\n const allowedTags = [\n \"div\",\n \"p\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"span\",\n \"li\",\n \"td\",\n \"a\",\n \"button\",\n \"label\",\n ];\n if (!allowedTags.includes(element.tagName.toLowerCase())) {\n return false;\n }\n\n // Must have text content\n const textContent = element.textContent?.trim() || \"\";\n if (textContent.length === 0) {\n return false;\n }\n\n // Must NOT contain img, video, canvas, or svg\n const hasMediaElements =\n element.querySelector(\"img, video, canvas, svg\") !== null;\n if (hasMediaElements) {\n return false;\n }\n\n // Must NOT have complex children (must be a leaf text node or simple container)\n if (element.children.length > 0) {\n return false;\n }\n\n // Must NOT be dynamic content\n if (element.dataset.dynamicContent === \"true\") {\n return false;\n }\n\n return true;\n}\n","import { injectFocusOutlineCSS, removeFocusOutlineCSS } from \"./styles.js\";\nimport { selectText, isEditableTextElement } from \"./validation.js\";\n\n/**\n * Callback function type for handling text input changes\n */\ntype OnTextInputChange = (element: HTMLElement) => void;\n\n/**\n * Global callback that gets triggered on every input event\n * This is set by the visual-edit-agent and includes both updatePosition and reportInlineEdit\n */\nlet onTextInputChangeCallback: OnTextInputChange | null = null;\n\n/**\n * Set the callback function that will be called on text input changes\n */\nexport function setInlineEditCallback(callback: OnTextInputChange | null): void {\n onTextInputChangeCallback = callback;\n}\n\n/**\n * WeakMap to track AbortControllers for each element's input listener.\n * Using WeakMap ensures no memory leaks — when an element is garbage collected,\n * its entry is automatically removed.\n */\nconst listenerAbortControllers = new WeakMap<HTMLElement, AbortController>();\n\n/**\n * Internal handler for the native input event\n */\nfunction handleInputEvent(this: HTMLElement, e: Event): void {\n if (onTextInputChangeCallback) {\n onTextInputChangeCallback(this);\n }\n}\n\n/**\n * Check if an element should enter inline editing mode\n * Called when user clicks on an already-selected element\n */\nexport function shouldEnterInlineEditingMode(element: Element): boolean {\n // Must have data-selected=\"true\"\n if (!(element instanceof HTMLElement) || element.dataset.selected !== \"true\") {\n return false;\n }\n\n // Must pass all editability checks\n if (!isEditableTextElement(element)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Enable contentEditable mode on an element\n * Follows the exact flow from inlineEdit.md\n */\nexport function enterInlineEditingMode(element: HTMLElement): void {\n // Inject CSS to suppress focus outline\n injectFocusOutlineCSS();\n\n // Store original state\n element.dataset.originalTextContent = element.textContent || \"\";\n element.dataset.originalCursor = element.style.cursor;\n\n // Enable contentEditable\n element.contentEditable = \"true\";\n\n // Create an AbortController to manage the input listener lifecycle\n const abortController = new AbortController();\n listenerAbortControllers.set(element, abortController);\n\n // Add input event listener with AbortSignal for automatic cleanup\n element.addEventListener(\"input\", handleInputEvent, { signal: abortController.signal });\n\n // Set cursor to text\n element.style.cursor = \"text\";\n\n // Select all text\n selectText(element);\n\n // Focus after render\n setTimeout(() => {\n element.focus();\n }, 0);\n}\n\n/**\n * Disable contentEditable mode on an element\n * Reverses everything done by enterInlineEditingMode\n */\nexport function clearInlineEditingMode(element: HTMLElement): void {\n // Abort the input event listener using the stored AbortController\n const abortController = listenerAbortControllers.get(element);\n if (abortController) {\n abortController.abort();\n listenerAbortControllers.delete(element);\n }\n\n // If element was removed from DOM before cleanup, skip DOM operations\n if (!element.isConnected) {\n return;\n }\n\n removeFocusOutlineCSS();\n\n // Disable contentEditable\n element.contentEditable = \"false\";\n\n // Remove stored original text content\n delete element.dataset.originalTextContent;\n\n // Restore original cursor\n if (element.dataset.originalCursor !== undefined) {\n element.style.cursor = element.dataset.originalCursor;\n delete element.dataset.originalCursor;\n }\n}\n","import type { ElementPosition } from \"../handlers/messages/types.js\";\n\n/**\n * Calculate element position from bounding rect\n */\nexport function getElementPosition(rect: DOMRect): ElementPosition {\n return {\n top: rect.top,\n left: rect.left,\n right: rect.right,\n bottom: rect.bottom,\n width: rect.width,\n height: rect.height,\n centerX: rect.left + rect.width / 2,\n centerY: rect.top + rect.height / 2,\n };\n}\n\n/**\n * Check if element rect is in viewport\n */\nexport function isElementInViewport(rect: DOMRect): boolean {\n return (\n rect.top < window.innerHeight &&\n rect.bottom > 0 &&\n rect.left < window.innerWidth &&\n rect.right > 0\n );\n}\n\n/**\n * Get element classes (handles both HTML and SVG)\n */\nexport function getElementClasses(element: Element): string {\n if (element instanceof SVGElement) {\n return (element.className as unknown as SVGAnimatedString)?.baseVal || \"\";\n }\n return element.className || \"\";\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { OutgoingMessageType } from \"./messages/types.js\";\nimport { repositionSelectedOverlays } from \"../ui/overlay.js\";\nimport {\n enterInlineEditingMode,\n clearInlineEditingMode,\n setInlineEditCallback,\n} from \"../capabilities/inline-editing/index.js\";\nimport { INLINE_EDIT_DEBOUNCE_MS } from \"../constants.js\";\nimport { getElementPosition, getElementClasses } from \"../utils/dom-utils.js\";\n\n/**\n * Enter inline editing mode\n */\nexport function handleEnterInlineEditingMode(state: AgentState, element: HTMLElement): void {\n state.currentEditingElement = element;\n\n // Hide overlays during editing\n state.selectedOverlays.forEach((overlay) => {\n overlay.style.display = \"none\";\n });\n\n // Enter inline editing mode (from capabilities/inline-editing)\n enterInlineEditingMode(element);\n\n // Notify parent\n window.parent.postMessage(\n {\n type: OutgoingMessageType.CONTENT_EDITING_STARTED,\n visualSelectorId: state.selectedElementId,\n },\n \"*\"\n );\n}\n\n/**\n * Clear inline editing mode\n */\nexport function handleClearInlineEditingMode(state: AgentState): void {\n if (!state.currentEditingElement) return;\n\n // Cancel any pending debounced edit — originalTextContent will be deleted below\n if (state.debouncedSendTimeout) {\n clearTimeout(state.debouncedSendTimeout);\n state.debouncedSendTimeout = null;\n }\n\n const element = state.currentEditingElement;\n\n // Clear inline editing mode (from capabilities/inline-editing)\n clearInlineEditingMode(element);\n\n // Show overlays again\n state.selectedOverlays.forEach((overlay) => {\n overlay.style.display = \"\";\n });\n\n repositionSelectedOverlays(state);\n\n // Notify parent that editing ended\n window.parent.postMessage(\n {\n type: OutgoingMessageType.CONTENT_EDITING_ENDED,\n visualSelectorId: state.selectedElementId,\n },\n \"*\"\n );\n\n state.currentEditingElement = null;\n}\n\n/**\n * Report inline edit to parent\n */\nfunction reportInlineEdit(state: AgentState, element: HTMLElement): void {\n const originalContent = element.dataset.originalTextContent;\n const newContent = element.textContent;\n\n const elementInfo = {\n tagName: element.tagName,\n classes: getElementClasses(element),\n visualSelectorId: state.selectedElementId,\n content: newContent,\n dataSourceLocation: element.dataset.sourceLocation,\n isDynamicContent: element.dataset.dynamicContent === \"true\",\n linenumber: element.dataset.linenumber,\n filename: element.dataset.filename,\n position: getElementPosition(element.getBoundingClientRect()),\n };\n\n // Send inline edit message\n window.parent.postMessage(\n {\n type: OutgoingMessageType.INLINE_EDIT,\n elementInfo,\n originalContent,\n newContent,\n },\n \"*\"\n );\n\n // Update baseline for next edit\n element.dataset.originalTextContent = newContent || \"\";\n}\n\n/**\n * Debounced function to send inline edit messages\n * \n * Intentionally overwrites the previous timeout on each keystroke — this is the\n * correct debounce behavior. We only send ONE message 500ms after the user stops\n * typing, containing the final text. Intermediate keystrokes are not sent to avoid\n * flooding the parent with dozens of messages per second.\n */\nfunction debouncedSendInlineEditMessage(state: AgentState, element: HTMLElement): void {\n // Clear any existing timeout\n if (state.debouncedSendTimeout) {\n clearTimeout(state.debouncedSendTimeout);\n }\n\n // Set new timeout\n state.debouncedSendTimeout = setTimeout(() => {\n reportInlineEdit(state, element);\n }, INLINE_EDIT_DEBOUNCE_MS);\n}\n\n/**\n * Callback for text input changes (combines updatePosition and reportInlineEdit)\n */\nfunction createTextInputChangeCallback(state: AgentState) {\n return (element: HTMLElement) => {\n repositionSelectedOverlays(state);\n debouncedSendInlineEditMessage(state, element);\n };\n}\n\n/**\n * Setup inline edit callback\n */\nexport function setupInlineEditCallback(state: AgentState): void {\n setInlineEditCallback(createTextInputChangeCallback(state));\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { OutgoingMessageType } from \"./messages/types.js\";\nimport { findElementsById } from \"../../utils.js\";\nimport { createOverlay, positionOverlay, clearSelection } from \"../ui/overlay.js\";\nimport { clearHoverOverlays } from \"./hover-handlers.js\";\nimport { shouldEnterInlineEditingMode } from \"../capabilities/inline-editing/index.js\";\nimport { handleClearInlineEditingMode, handleEnterInlineEditingMode } from \"./inline-edit-handlers.js\";\nimport { getElementPosition, getElementClasses } from \"../utils/dom-utils.js\";\n\n/**\n * Handle element selection (first click)\n */\nexport function handleElementSelection(\n state: AgentState,\n element: Element,\n visualSelectorId: string | null\n): void {\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n clearSelection(state);\n\n // Find all elements with the same ID\n const elements = findElementsById(visualSelectorId);\n\n if (state.isInlineEditExperimentEnabled) {\n elements.forEach((el) => {\n if (el instanceof HTMLElement) {\n el.dataset.selected = \"true\";\n }\n });\n }\n\n // Create selected overlays for all matching elements\n elements.forEach((el) => {\n const overlay = createOverlay(true);\n document.body.appendChild(overlay);\n state.selectedOverlays.push(overlay);\n positionOverlay(overlay, el, true, state.isVisualEditMode);\n });\n\n state.selectedElementId = visualSelectorId;\n\n // Clear hover overlays\n clearHoverOverlays(state);\n\n // Send message to parent window with element info\n const htmlElement = element as HTMLElement;\n const elementData = {\n type: OutgoingMessageType.ELEMENT_SELECTED,\n tagName: element.tagName,\n classes: getElementClasses(element),\n visualSelectorId: visualSelectorId,\n content: htmlElement.innerText,\n dataSourceLocation: htmlElement.dataset.sourceLocation,\n isDynamicContent: htmlElement.dataset.dynamicContent === \"true\",\n linenumber: htmlElement.dataset.linenumber,\n filename: htmlElement.dataset.filename,\n position: getElementPosition(element.getBoundingClientRect()),\n };\n window.parent.postMessage(elementData, \"*\");\n}\n\n/**\n * Handle element click\n */\nexport function handleElementClick(state: AgentState, e: MouseEvent): void {\n if (!state.isVisualEditMode) return;\n\n const target = e.target as Element;\n\n // Bail out early if clicking on a contentEditable element (allow normal editing)\n if (state.isInlineEditExperimentEnabled && target instanceof HTMLElement && target.contentEditable === \"true\") {\n return;\n }\n\n // If currently editing, clicking outside should exit editing mode\n if (state.currentEditingElement) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n handleClearInlineEditingMode(state);\n return;\n }\n\n // Close dropdowns when clicking anywhere in iframe if a dropdown is open\n if (state.isDropdownOpen) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n\n window.parent.postMessage({ type: OutgoingMessageType.CLOSE_DROPDOWNS }, \"*\");\n return;\n }\n\n // Prevent clicking on SVG path elements\n if (target.tagName.toLowerCase() === \"path\") {\n return;\n }\n\n // Prevent default behavior immediately when in visual edit mode\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n\n // Support both data-source-location and data-visual-selector-id\n const element = target.closest(\n \"[data-source-location], [data-visual-selector-id]\"\n );\n if (!element) {\n return;\n }\n\n const htmlElement = element as HTMLElement;\n const visualSelectorId =\n htmlElement.dataset.sourceLocation ||\n htmlElement.dataset.visualSelectorId;\n\n // Check if this element is already selected (second click scenario)\n const isAlreadySelected =\n state.selectedElementId === visualSelectorId &&\n htmlElement.dataset.selected === \"true\";\n\n if (isAlreadySelected) {\n // Second click on already-selected element: check if it should enter inline editing\n // Only if the experiment is enabled\n if (state.isInlineEditExperimentEnabled && shouldEnterInlineEditingMode(htmlElement)) {\n handleEnterInlineEditingMode(state, htmlElement);\n return;\n }\n }\n\n // First click: select the element\n handleElementSelection(state, element, visualSelectorId || null);\n}\n","import type { AgentState } from \"../../state/agent-state.js\";\nimport type { ToggleVisualEditModeMessage } from \"./types.js\";\nimport { clearSelection } from \"../../ui/overlay.js\";\nimport { clearHoverOverlays } from \"../hover-handlers.js\";\nimport { handleClearInlineEditingMode } from \"../inline-edit-handlers.js\";\n\n/**\n * Toggle visual edit mode on/off\n */\nexport function toggleVisualEditMode(state: AgentState, isEnabled: boolean): void {\n state.isVisualEditMode = isEnabled;\n\n if (!isEnabled) {\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n\n clearHoverOverlays(state);\n clearSelection(state);\n state.currentHighlightedElements = [];\n document.body.style.cursor = \"default\";\n } else {\n document.body.style.cursor = \"crosshair\";\n }\n}\n\n/**\n * Handle toggle-visual-edit-mode message\n */\nexport function handleToggleVisualEditMode(\n state: AgentState,\n message: ToggleVisualEditModeMessage\n): void {\n toggleVisualEditMode(state, message.data.enabled);\n \n // Update inline edit experiment flag if provided\n if (message.data.specs?.newInlineEditEnabled !== undefined) {\n state.isInlineEditExperimentEnabled = message.data.specs.newInlineEditEnabled;\n }\n}\n","import type { AgentState } from \"../../state/agent-state.js\";\nimport type { ToggleInlineEditModeMessage } from \"./types.js\";\nimport { findElementsById } from \"../../../utils.js\";\nimport { shouldEnterInlineEditingMode } from \"../../capabilities/inline-editing/index.js\";\nimport { handleEnterInlineEditingMode, handleClearInlineEditingMode } from \"../inline-edit-handlers.js\";\nimport { clearSelection } from \"../../ui/overlay.js\";\nimport { createOverlay, positionOverlay } from \"../../ui/overlay.js\";\n\n/**\n * Handle toggle-inline-edit-mode message (parent-initiated)\n */\nexport function handleToggleInlineEditMode(\n state: AgentState,\n message: ToggleInlineEditModeMessage\n): void {\n if (!state.isInlineEditExperimentEnabled) {\n return;\n }\n\n if (!message.data || !message.data.dataSourceLocation) {\n return;\n }\n\n const elements = findElementsById(message.data.dataSourceLocation);\n if (elements.length === 0 || !(elements[0] instanceof HTMLElement)) {\n return;\n }\n\n const element = elements[0];\n\n if (message.data.inlineEditingMode) {\n // Enable inline editing (only for non-dynamic text elements)\n if (shouldEnterInlineEditingMode(element)) {\n // Select the element first if not already selected\n if (state.selectedElementId !== message.data.dataSourceLocation) {\n // Clear any existing selection\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n clearSelection(state);\n\n elements.forEach((el) => {\n if (el instanceof HTMLElement) {\n el.dataset.selected = \"true\";\n }\n });\n\n elements.forEach((el) => {\n const overlay = createOverlay(true);\n document.body.appendChild(overlay);\n state.selectedOverlays.push(overlay);\n positionOverlay(overlay, el, true, state.isVisualEditMode);\n });\n\n state.selectedElementId = message.data.dataSourceLocation;\n }\n handleEnterInlineEditingMode(state, element);\n }\n } else {\n // Disable inline editing\n if (state.currentEditingElement === element) {\n handleClearInlineEditingMode(state);\n }\n }\n}\n","import type { AgentState } from \"../state/agent-state.js\";\nimport { IncomingMessageType, OutgoingMessageType } from \"./messages/types.js\";\nimport { findElementsById, updateElementClasses } from \"../../utils.js\";\nimport { clearSelection, repositionSelectedOverlays, repositionHoverOverlays } from \"../ui/overlay.js\";\nimport { clearHoverOverlays } from \"./hover-handlers.js\";\nimport { handleClearInlineEditingMode } from \"./inline-edit-handlers.js\";\nimport { REPOSITION_DELAY_MS } from \"../constants.js\";\nimport { handleToggleVisualEditMode } from \"./messages/toggle-visual-edit-mode.js\";\nimport { handleToggleInlineEditMode } from \"./messages/toggle-inline-edit-mode.js\";\nimport { getElementPosition, isElementInViewport } from \"../utils/dom-utils.js\";\n\n/**\n * Send element position update to parent\n */\nfunction sendElementPositionUpdate(state: AgentState): void {\n if (!state.selectedElementId) return;\n\n const elements = findElementsById(state.selectedElementId);\n const [element] = elements;\n if (!element) return;\n\n const rect = element.getBoundingClientRect();\n\n window.parent.postMessage(\n {\n type: OutgoingMessageType.ELEMENT_POSITION_UPDATE,\n position: getElementPosition(rect),\n isInViewport: isElementInViewport(rect),\n visualSelectorId: state.selectedElementId,\n },\n \"*\"\n );\n}\n\n/**\n * Unselect the current element\n */\nexport function unselectElement(state: AgentState): void {\n if (state.currentEditingElement) {\n handleClearInlineEditingMode(state);\n }\n clearSelection(state);\n}\n\n/**\n * Update element classes and reposition overlays\n */\nexport function updateElementClassesAndReposition(\n state: AgentState,\n visualSelectorId: string,\n classes: string\n): void {\n const elements = findElementsById(visualSelectorId);\n if (elements.length === 0) return;\n\n updateElementClasses(elements, classes);\n\n // Use a small delay to allow the browser to recalculate layout before repositioning\n setTimeout(() => {\n if (state.selectedElementId === visualSelectorId) {\n repositionSelectedOverlays(state);\n }\n\n if (state.currentHighlightedElements.length > 0) {\n const hoveredElement = state.currentHighlightedElements[0] as HTMLElement;\n if (hoveredElement?.dataset?.visualSelectorId === visualSelectorId) {\n repositionHoverOverlays(state);\n }\n }\n }, REPOSITION_DELAY_MS);\n}\n\n/**\n * Update element content by visual selector ID\n */\nexport function updateElementContent(\n state: AgentState,\n visualSelectorId: string,\n content: string\n): void {\n const elements = findElementsById(visualSelectorId);\n\n if (elements.length === 0) {\n return;\n }\n\n elements.forEach((element) => {\n (element as HTMLElement).innerText = content;\n });\n\n setTimeout(() => {\n if (state.selectedElementId === visualSelectorId) {\n repositionSelectedOverlays(state);\n }\n }, REPOSITION_DELAY_MS);\n}\n\n/**\n * Handle scroll events to update popover position\n */\nexport function handleScroll(state: AgentState): void {\n sendElementPositionUpdate(state);\n}\n\n/**\n * Handle window resize to reposition overlays\n */\nexport function handleResize(state: AgentState): void {\n repositionSelectedOverlays(state);\n repositionHoverOverlays(state);\n}\n\n/**\n * Handle messages from parent window\n */\nexport function handleMessage(state: AgentState, event: MessageEvent): void {\n const message = event.data;\n\n switch (message.type as IncomingMessageType) {\n case IncomingMessageType.TOGGLE_VISUAL_EDIT_MODE:\n handleToggleVisualEditMode(state, message);\n break;\n\n case IncomingMessageType.UPDATE_CLASSES:\n if (message.data && message.data.classes !== undefined) {\n updateElementClassesAndReposition(\n state,\n message.data.visualSelectorId,\n message.data.classes\n );\n } else {\n console.warn(\n \"[VisualEditAgent] Invalid update-classes message:\",\n message\n );\n }\n break;\n\n case IncomingMessageType.UNSELECT_ELEMENT:\n unselectElement(state);\n break;\n\n case IncomingMessageType.REFRESH_PAGE:\n window.location.reload();\n break;\n\n case IncomingMessageType.UPDATE_CONTENT:\n if (message.data && message.data.content !== undefined) {\n updateElementContent(\n state,\n message.data.visualSelectorId,\n message.data.content\n );\n } else {\n console.warn(\n \"[VisualEditAgent] Invalid update-content message:\",\n message\n );\n }\n break;\n\n case IncomingMessageType.TOGGLE_INLINE_EDIT_MODE:\n handleToggleInlineEditMode(state, message);\n break;\n\n case IncomingMessageType.REQUEST_ELEMENT_POSITION:\n sendElementPositionUpdate(state);\n break;\n\n case IncomingMessageType.POPOVER_DRAG_STATE:\n if (message.data && message.data.isDragging !== undefined) {\n state.isPopoverDragging = message.data.isDragging;\n if (message.data.isDragging) {\n clearHoverOverlays(state);\n }\n }\n break;\n\n case IncomingMessageType.DROPDOWN_STATE:\n if (message.data && message.data.isOpen !== undefined) {\n state.isDropdownOpen = message.data.isOpen;\n if (message.data.isOpen) {\n clearHoverOverlays(state);\n }\n }\n break;\n\n default:\n break;\n }\n}\n","import { createAgentState } from \"./state/agent-state.js\";\nimport { handleMouseOver, handleMouseOut } from \"./handlers/hover-handlers.js\";\nimport { handleElementClick } from \"./handlers/click-handlers.js\";\nimport { handleMessage, handleScroll, handleResize } from \"./handlers/message-handlers.js\";\nimport { setupInlineEditCallback } from \"./handlers/inline-edit-handlers.js\";\nimport { OutgoingMessageType } from \"./handlers/messages/types.js\";\n\n/**\n * Initialize element IDs for elements with line numbers\n */\nfunction initializeElementIds(): void {\n const elementsWithLineNumber = document.querySelectorAll(\n \"[data-linenumber]:not([data-visual-selector-id])\"\n );\n elementsWithLineNumber.forEach((el, index) => {\n const htmlEl = el as HTMLElement;\n const id = `visual-id-${htmlEl.dataset.filename}-${htmlEl.dataset.linenumber}-${index}`;\n htmlEl.dataset.visualSelectorId = id;\n });\n}\n\n/**\n * Create mutation observer to detect layout changes.\n * Uses requestAnimationFrame to coalesce many rapid mutations into one reposition\n * per paint frame, avoiding stacking multiple timers during CSS transitions.\n */\nfunction createLayoutObserver(onLayoutChange: () => void): MutationObserver {\n let rafHandle: number | null = null;\n\n const hasVisualId = (node: Node): boolean => {\n if (node.nodeType !== Node.ELEMENT_NODE) return false;\n const el = node as HTMLElement;\n if (el.dataset?.visualSelectorId) return true;\n for (const child of Array.from(el.children)) {\n if (hasVisualId(child)) return true;\n }\n return false;\n };\n\n return new MutationObserver((mutations) => {\n if (rafHandle !== null) return;\n\n const needsUpdate = mutations.some((mutation) => {\n const isLayoutChange =\n mutation.type === \"attributes\" &&\n (mutation.attributeName === \"style\" ||\n mutation.attributeName === \"class\" ||\n mutation.attributeName === \"width\" ||\n mutation.attributeName === \"height\");\n\n return isLayoutChange && hasVisualId(mutation.target);\n });\n\n if (needsUpdate) {\n // Coalesce rapid mutations into a single reposition per paint frame,\n // avoiding stacked timers during CSS transitions\n rafHandle = requestAnimationFrame(() => {\n rafHandle = null;\n onLayoutChange();\n });\n }\n });\n}\n\n/**\n * Setup event listeners\n */\nfunction setupEventListeners(state: ReturnType<typeof createAgentState>): void {\n // Message handling\n window.addEventListener(\"message\", (e) => handleMessage(state, e));\n\n // Scroll handling\n window.addEventListener(\"scroll\", () => handleScroll(state), true);\n document.addEventListener(\"scroll\", () => handleScroll(state), true);\n\n // Resize handling\n window.addEventListener(\"resize\", () => handleResize(state));\n window.addEventListener(\"scroll\", () => handleResize(state));\n\n // Click handling\n document.addEventListener(\"click\", (e) => handleElementClick(state, e), true);\n\n // Hover handling\n document.addEventListener(\"mouseover\", (e) => handleMouseOver(state, e));\n document.addEventListener(\"mouseout\", () => handleMouseOut(state));\n}\n\n/**\n * Main setup function for visual edit agent\n */\nexport function setupVisualEditAgent(): void {\n const state = createAgentState();\n initializeElementIds();\n setupInlineEditCallback(state);\n setupEventListeners(state);\n\n // Create and start mutation observer\n const mutationObserver = createLayoutObserver(() => handleResize(state));\n mutationObserver.observe(document.body, {\n attributes: true,\n childList: true,\n subtree: true,\n attributeFilter: [\"style\", \"class\", \"width\", \"height\"],\n });\n\n // Send ready message to parent\n window.parent.postMessage({ type: OutgoingMessageType.VISUAL_EDIT_AGENT_READY }, \"*\");\n}\n"],"mappings":"AAiBO,SAASA,GAA+B,CAC7C,MAAO,CACL,iBAAkB,GAClB,kBAAmB,GACnB,eAAgB,GAChB,cAAe,CAAC,EAChB,iBAAkB,CAAC,EACnB,2BAA4B,CAAC,EAC7B,kBAAmB,KACnB,sBAAuB,KACvB,qBAAsB,KACtB,8BAA+B,EACjC,CACF,CC7BO,SAASC,EAAiBC,EAA8B,CAC7D,GAAI,CAACA,EAAI,MAAO,CAAC,EACjB,IAAMC,EAAiB,MAAM,KAC3B,SAAS,iBAAiB,0BAA0BD,CAAE,IAAI,CAC5D,EACA,OAAIC,EAAe,OAAS,EACnBA,EAEF,MAAM,KACX,SAAS,iBAAiB,6BAA6BD,CAAE,IAAI,CAC/D,CACF,CAMO,SAASE,EAAqBC,EAAqBC,EAAuB,CAC/ED,EAAS,QAASE,GAAY,CAC5BA,EAAQ,aAAa,QAASD,CAAO,CACvC,CAAC,CACH,CCrBO,IAAME,EAAqB,uBACrBC,EAAkB,OAClBC,EAAwB,UACxBC,EAAqB,UACrBC,EAAyB,2BACzBC,EAAmB,QACnBC,EAAoB,OCQ1B,SAASC,EAAcC,EAAa,GAAuB,CAChE,IAAMC,EAAU,SAAS,cAAc,KAAK,EAC5C,OAAAA,EAAQ,MAAM,SAAW,WACzBA,EAAQ,MAAM,cAAgB,OAC9BA,EAAQ,MAAM,WAAaC,EAC3BD,EAAQ,MAAM,OAASE,EAEnBH,EACFC,EAAQ,MAAM,OAAS,aAAaG,CAAqB,IAEzDH,EAAQ,MAAM,OAAS,aAAaI,CAAkB,GACtDJ,EAAQ,MAAM,gBAAkBK,GAG3BL,CACT,CAKO,SAASM,EACdN,EACAO,EACAR,EAAa,GACbS,EAAmB,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AAmBL,EAAOC,CAAC,EAAG,EAAI,EAG5E,SAAS,iBAAiB,YAAcA,GAAMK,EAAgBN,EAAOC,CAAC,CAAC,EACvE,SAAS,iBAAiB,WAAY,IAAMM,EAAeP,CAAK,CAAC,CACnE,CAKO,SAASQ,GAA6B,CAC3C,IAAMR,EAAQS,EAAiB,EAC/BvB,GAAqB,EACrBwB,EAAwBV,CAAK,EAC7BD,GAAoBC,CAAK,EAGAT,GAAqB,IAAMa,EAAaJ,CAAK,CAAC,EACtD,QAAQ,SAAS,KAAM,CACtC,WAAY,GACZ,UAAW,GACX,QAAS,GACT,gBAAiB,CAAC,QAAS,QAAS,QAAS,QAAQ,CACvD,CAAC,EAGD,OAAO,OAAO,YAAY,CAAE,8BAAkD,EAAG,GAAG,CACtF","names":["createAgentState","findElementsById","id","sourceElements","updateElementClasses","elements","classes","element","OVERLAY_TRANSITION","OVERLAY_Z_INDEX","SELECTED_BORDER_COLOR","HOVER_BORDER_COLOR","HOVER_BACKGROUND_COLOR","LABEL_TOP_OFFSET","LABEL_LEFT_OFFSET","createOverlay","isSelected","overlay","OVERLAY_TRANSITION","OVERLAY_Z_INDEX","SELECTED_BORDER_COLOR","HOVER_BORDER_COLOR","HOVER_BACKGROUND_COLOR","positionOverlay","element","isVisualEditMode","rect","label","LABEL_TOP_OFFSET","LABEL_LEFT_OFFSET","clearOverlays","overlays","clearSelection","state","findElementsById","el","repositionSelectedOverlays","elements","index","repositionHoverOverlays","clearHoverOverlays","state","clearOverlays","handleMouseOver","e","target","element","htmlElement","selectorId","elements","findElementsById","el","overlay","createOverlay","positionOverlay","handleMouseOut","injectFocusOutlineCSS","style","removeFocusOutlineCSS","selectText","element","range","selection","isEditableTextElement","onTextInputChangeCallback","setInlineEditCallback","callback","listenerAbortControllers","handleInputEvent","shouldEnterInlineEditingMode","element","isEditableTextElement","enterInlineEditingMode","injectFocusOutlineCSS","abortController","selectText","clearInlineEditingMode","removeFocusOutlineCSS","getElementPosition","rect","isElementInViewport","getElementClasses","element","handleEnterInlineEditingMode","state","element","overlay","enterInlineEditingMode","handleClearInlineEditingMode","clearInlineEditingMode","repositionSelectedOverlays","reportInlineEdit","originalContent","newContent","elementInfo","getElementClasses","getElementPosition","debouncedSendInlineEditMessage","createTextInputChangeCallback","setupInlineEditCallback","setInlineEditCallback","handleElementSelection","state","element","visualSelectorId","handleClearInlineEditingMode","clearSelection","elements","findElementsById","el","overlay","createOverlay","positionOverlay","clearHoverOverlays","htmlElement","elementData","getElementClasses","getElementPosition","handleElementClick","e","target","shouldEnterInlineEditingMode","handleEnterInlineEditingMode","toggleVisualEditMode","state","isEnabled","handleClearInlineEditingMode","clearHoverOverlays","clearSelection","handleToggleVisualEditMode","message","handleToggleInlineEditMode","state","message","elements","findElementsById","element","shouldEnterInlineEditingMode","handleClearInlineEditingMode","clearSelection","el","overlay","createOverlay","positionOverlay","handleEnterInlineEditingMode","sendElementPositionUpdate","state","elements","findElementsById","element","rect","getElementPosition","isElementInViewport","unselectElement","handleClearInlineEditingMode","clearSelection","updateElementClassesAndReposition","visualSelectorId","classes","updateElementClasses","repositionSelectedOverlays","repositionHoverOverlays","updateElementContent","content","handleScroll","handleResize","handleMessage","event","message","handleToggleVisualEditMode","handleToggleInlineEditMode","clearHoverOverlays","initializeElementIds","el","index","htmlEl","id","createLayoutObserver","onLayoutChange","rafHandle","hasVisualId","node","child","mutations","mutation","setupEventListeners","state","e","handleMessage","handleScroll","handleResize","handleElementClick","handleMouseOver","handleMouseOut","setupVisualEditAgent","createAgentState","setupInlineEditCallback"]}
|
|
1
|
+
{"version":3,"sources":["../../src/injections/utils.ts","../../src/injections/visual-edit-agent.ts"],"sourcesContent":["/** Find elements by ID - first try data-source-location, fallback to data-visual-selector-id */\nexport function findElementsById(id: string | null): Element[] {\n if (!id) return [];\n const sourceElements = Array.from(\n document.querySelectorAll(`[data-source-location=\"${id}\"]`)\n );\n if (sourceElements.length > 0) {\n return sourceElements;\n }\n return Array.from(\n document.querySelectorAll(`[data-visual-selector-id=\"${id}\"]`)\n );\n}\n\n/**\n * Update element classes by visual selector ID.\n * Uses setAttribute instead of className to support both HTML and SVG elements.\n */\nexport function updateElementClasses(elements: Element[], classes: string): void {\n elements.forEach((element) => {\n element.setAttribute(\"class\", classes);\n }); \n}\n","import { findElementsById, updateElementClasses } from \"./utils.js\";\n\nexport function setupVisualEditAgent() {\n // State variables (replacing React useState/useRef)\n let isVisualEditMode = false;\n let isPopoverDragging = false;\n let isDropdownOpen = false;\n let hoverOverlays: HTMLDivElement[] = [];\n let selectedOverlays: HTMLDivElement[] = [];\n let currentHighlightedElements: Element[] = [];\n let selectedElementId: string | null = null;\n\n // Create overlay element\n const createOverlay = (isSelected = false): HTMLDivElement => {\n const overlay = document.createElement(\"div\");\n overlay.style.position = \"absolute\";\n overlay.style.pointerEvents = \"none\";\n overlay.style.transition = \"all 0.1s ease-in-out\";\n overlay.style.zIndex = \"9999\";\n\n if (isSelected) {\n overlay.style.border = \"2px solid #2563EB\";\n } else {\n overlay.style.border = \"2px solid #95a5fc\";\n overlay.style.backgroundColor = \"rgba(99, 102, 241, 0.05)\";\n }\n\n return overlay;\n };\n\n // Position overlay relative to element\n const positionOverlay = (\n overlay: HTMLDivElement,\n element: Element,\n isSelected = false\n ) => {\n if (!element || !isVisualEditMode) return;\n\n const htmlElement = element as HTMLElement;\n // Force layout recalculation\n void htmlElement.offsetWidth;\n\n const rect = element.getBoundingClientRect();\n overlay.style.top = `${rect.top + window.scrollY}px`;\n overlay.style.left = `${rect.left + window.scrollX}px`;\n overlay.style.width = `${rect.width}px`;\n overlay.style.height = `${rect.height}px`;\n\n // Check if label already exists in overlay\n let label = overlay.querySelector(\"div\") as HTMLDivElement | null;\n\n if (!label) {\n label = document.createElement(\"div\");\n label.textContent = element.tagName.toLowerCase();\n label.style.position = \"absolute\";\n label.style.top = \"-27px\";\n label.style.left = \"-2px\";\n label.style.padding = \"2px 8px\";\n label.style.fontSize = \"11px\";\n label.style.fontWeight = isSelected ? \"500\" : \"400\";\n label.style.color = isSelected ? \"#ffffff\" : \"#526cff\";\n label.style.backgroundColor = isSelected ? \"#526cff\" : \"#DBEAFE\";\n label.style.borderRadius = \"3px\";\n label.style.minWidth = \"24px\";\n label.style.textAlign = \"center\";\n overlay.appendChild(label);\n }\n };\n\n // Clear hover overlays\n const clearHoverOverlays = () => {\n hoverOverlays.forEach((overlay) => {\n if (overlay && overlay.parentNode) {\n overlay.remove();\n }\n });\n hoverOverlays = [];\n currentHighlightedElements = [];\n };\n\n // Handle mouse over event\n const handleMouseOver = (e: MouseEvent) => {\n if (!isVisualEditMode || isPopoverDragging) return;\n\n const target = e.target as Element;\n\n // Prevent hover effects when a dropdown is open\n if (isDropdownOpen) {\n clearHoverOverlays();\n return;\n }\n\n // Prevent hover effects on SVG path elements\n if (target.tagName.toLowerCase() === \"path\") {\n clearHoverOverlays();\n return;\n }\n\n // Support both data-source-location and data-visual-selector-id\n const element = target.closest(\n \"[data-source-location], [data-visual-selector-id]\"\n );\n if (!element) {\n clearHoverOverlays();\n return;\n }\n\n // Prefer data-source-location, fallback to data-visual-selector-id\n const htmlElement = element as HTMLElement;\n const selectorId =\n htmlElement.dataset.sourceLocation ||\n htmlElement.dataset.visualSelectorId;\n\n // Skip if this element is already selected\n if (selectedElementId === selectorId) {\n clearHoverOverlays();\n return;\n }\n\n // Find all elements with the same ID\n const elements = findElementsById(selectorId || null);\n\n // Clear previous hover overlays\n clearHoverOverlays();\n\n // Create overlays for all matching elements\n elements.forEach((el) => {\n const overlay = createOverlay(false);\n document.body.appendChild(overlay);\n hoverOverlays.push(overlay);\n positionOverlay(overlay, el);\n });\n\n currentHighlightedElements = elements;\n };\n\n // Handle mouse out event\n const handleMouseOut = () => {\n if (isPopoverDragging) return;\n clearHoverOverlays();\n };\n\n // Handle element click\n const handleElementClick = (e: MouseEvent) => {\n if (!isVisualEditMode) return;\n\n const target = e.target as Element;\n\n // Close dropdowns when clicking anywhere in iframe if a dropdown is open\n if (isDropdownOpen) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n\n window.parent.postMessage({ type: \"close-dropdowns\" }, \"*\");\n return;\n }\n\n // Prevent clicking on SVG path elements\n if (target.tagName.toLowerCase() === \"path\") {\n return;\n }\n\n // Prevent default behavior immediately when in visual edit mode\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n\n // Support both data-source-location and data-visual-selector-id\n const element = target.closest(\n \"[data-source-location], [data-visual-selector-id]\"\n );\n if (!element) {\n return;\n }\n\n const htmlElement = element as HTMLElement;\n const visualSelectorId =\n htmlElement.dataset.sourceLocation ||\n htmlElement.dataset.visualSelectorId;\n\n // Clear any existing selected overlays\n selectedOverlays.forEach((overlay) => {\n if (overlay && overlay.parentNode) {\n overlay.remove();\n }\n });\n selectedOverlays = [];\n\n // Find all elements with the same ID\n const elements = findElementsById(visualSelectorId || null);\n\n // Create selected overlays for all matching elements\n elements.forEach((el) => {\n const overlay = createOverlay(true);\n document.body.appendChild(overlay);\n selectedOverlays.push(overlay);\n positionOverlay(overlay, el, true);\n });\n\n selectedElementId = visualSelectorId || null;\n\n // Clear hover overlays\n clearHoverOverlays();\n\n // Calculate element position for popover positioning\n const rect = element.getBoundingClientRect();\n const elementPosition = {\n top: rect.top,\n left: rect.left,\n right: rect.right,\n bottom: rect.bottom,\n width: rect.width,\n height: rect.height,\n centerX: rect.left + rect.width / 2,\n centerY: rect.top + rect.height / 2,\n };\n\n // Send message to parent window with element info including position\n const svgElement = element as SVGElement;\n const elementData = {\n type: \"element-selected\",\n tagName: element.tagName,\n classes:\n (svgElement.className as unknown as SVGAnimatedString)?.baseVal ||\n element.className ||\n \"\",\n visualSelectorId: visualSelectorId,\n content: (element as HTMLElement).innerText,\n dataSourceLocation: htmlElement.dataset.sourceLocation,\n isDynamicContent: htmlElement.dataset.dynamicContent === \"true\",\n linenumber: htmlElement.dataset.linenumber,\n filename: htmlElement.dataset.filename,\n position: elementPosition,\n };\n window.parent.postMessage(elementData, \"*\");\n };\n\n // Unselect the current element\n const unselectElement = () => {\n selectedOverlays.forEach((overlay) => {\n if (overlay && overlay.parentNode) {\n overlay.remove();\n }\n });\n selectedOverlays = [];\n selectedElementId = null;\n };\n\n const updateElementClassesAndReposition = (visualSelectorId: string, classes: string) => {\n const elements = findElementsById(visualSelectorId);\n if (elements.length === 0) return;\n\n updateElementClasses(elements, classes);\n\n // Use a small delay to allow the browser to recalculate layout before repositioning\n setTimeout(() => {\n // Reposition selected overlays\n if (selectedElementId === visualSelectorId) {\n selectedOverlays.forEach((overlay, index) => {\n if (index < elements.length) {\n positionOverlay(overlay, elements[index]!);\n }\n });\n }\n\n // Reposition hover overlays if needed\n if (currentHighlightedElements.length > 0) {\n const hoveredElement = currentHighlightedElements[0] as HTMLElement;\n const hoveredId = hoveredElement?.dataset?.visualSelectorId;\n if (hoveredId === visualSelectorId) {\n hoverOverlays.forEach((overlay, index) => {\n if (index < currentHighlightedElements.length) {\n positionOverlay(overlay, currentHighlightedElements[index]!);\n }\n });\n }\n }\n }, 50);\n };\n\n // Update element content by visual selector ID\n const updateElementContent = (visualSelectorId: string, content: string) => {\n const elements = findElementsById(visualSelectorId);\n\n if (elements.length === 0) {\n return;\n }\n\n elements.forEach((element) => {\n (element as HTMLElement).innerText = content;\n });\n\n setTimeout(() => {\n if (selectedElementId === visualSelectorId) {\n selectedOverlays.forEach((overlay, index) => {\n if (index < elements.length) {\n positionOverlay(overlay, elements[index]!);\n }\n });\n }\n }, 50);\n };\n\n // Toggle visual edit mode\n const toggleVisualEditMode = (isEnabled: boolean) => {\n isVisualEditMode = isEnabled;\n\n if (!isEnabled) {\n clearHoverOverlays();\n\n selectedOverlays.forEach((overlay) => {\n if (overlay && overlay.parentNode) {\n overlay.remove();\n }\n });\n selectedOverlays = [];\n\n currentHighlightedElements = [];\n selectedElementId = null;\n document.body.style.cursor = \"default\";\n\n document.removeEventListener(\"mouseover\", handleMouseOver);\n document.removeEventListener(\"mouseout\", handleMouseOut);\n document.removeEventListener(\"click\", handleElementClick, true);\n } else {\n document.body.style.cursor = \"crosshair\";\n document.addEventListener(\"mouseover\", handleMouseOver);\n document.addEventListener(\"mouseout\", handleMouseOut);\n document.addEventListener(\"click\", handleElementClick, true);\n }\n };\n\n // Handle scroll events to update popover position\n const handleScroll = () => {\n if (selectedElementId) {\n const elements = findElementsById(selectedElementId);\n if (elements.length > 0) {\n const element = elements[0];\n const rect = element!.getBoundingClientRect();\n\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n const isInViewport =\n rect.top < viewportHeight &&\n rect.bottom > 0 &&\n rect.left < viewportWidth &&\n rect.right > 0;\n\n const elementPosition = {\n top: rect.top,\n left: rect.left,\n right: rect.right,\n bottom: rect.bottom,\n width: rect.width,\n height: rect.height,\n centerX: rect.left + rect.width / 2,\n centerY: rect.top + rect.height / 2,\n };\n\n window.parent.postMessage(\n {\n type: \"element-position-update\",\n position: elementPosition,\n isInViewport: isInViewport,\n visualSelectorId: selectedElementId,\n },\n \"*\"\n );\n }\n }\n };\n\n // Handle messages from parent window\n const handleMessage = (event: MessageEvent) => {\n const message = event.data;\n\n switch (message.type) {\n case \"toggle-visual-edit-mode\":\n toggleVisualEditMode(message.data.enabled);\n break;\n\n case \"update-classes\":\n if (message.data && message.data.classes !== undefined) {\n updateElementClassesAndReposition(\n message.data.visualSelectorId,\n message.data.classes\n );\n } else {\n console.warn(\n \"[VisualEditAgent] Invalid update-classes message:\",\n message\n );\n }\n break;\n\n case \"unselect-element\":\n unselectElement();\n break;\n\n case \"refresh-page\":\n window.location.reload();\n break;\n\n case \"update-content\":\n if (message.data && message.data.content !== undefined) {\n updateElementContent(\n message.data.visualSelectorId,\n message.data.content\n );\n } else {\n console.warn(\n \"[VisualEditAgent] Invalid update-content message:\",\n message\n );\n }\n break;\n\n case \"request-element-position\":\n if (selectedElementId) {\n const elements = findElementsById(selectedElementId);\n if (elements.length > 0) {\n const element = elements[0];\n const rect = element!.getBoundingClientRect();\n\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n const isInViewport =\n rect.top < viewportHeight &&\n rect.bottom > 0 &&\n rect.left < viewportWidth &&\n rect.right > 0;\n\n const elementPosition = {\n top: rect.top,\n left: rect.left,\n right: rect.right,\n bottom: rect.bottom,\n width: rect.width,\n height: rect.height,\n centerX: rect.left + rect.width / 2,\n centerY: rect.top + rect.height / 2,\n };\n\n window.parent.postMessage(\n {\n type: \"element-position-update\",\n position: elementPosition,\n isInViewport: isInViewport,\n visualSelectorId: selectedElementId,\n },\n \"*\"\n );\n }\n }\n break;\n\n case \"popover-drag-state\":\n if (message.data && message.data.isDragging !== undefined) {\n isPopoverDragging = message.data.isDragging;\n if (message.data.isDragging) {\n clearHoverOverlays();\n }\n }\n break;\n\n case \"dropdown-state\":\n if (message.data && message.data.isOpen !== undefined) {\n isDropdownOpen = message.data.isOpen;\n if (message.data.isOpen) {\n clearHoverOverlays();\n }\n }\n break;\n\n default:\n break;\n }\n };\n\n // Handle window resize to reposition overlays\n const handleResize = () => {\n if (selectedElementId) {\n const elements = findElementsById(selectedElementId);\n selectedOverlays.forEach((overlay, index) => {\n if (index < elements.length) {\n positionOverlay(overlay, elements[index]!);\n }\n });\n }\n\n if (currentHighlightedElements.length > 0) {\n hoverOverlays.forEach((overlay, index) => {\n if (index < currentHighlightedElements.length) {\n positionOverlay(overlay, currentHighlightedElements[index]!);\n }\n });\n }\n };\n\n // Initialize: Add IDs to elements that don't have them but have linenumbers\n const elementsWithLineNumber = document.querySelectorAll(\n \"[data-linenumber]:not([data-visual-selector-id])\"\n );\n elementsWithLineNumber.forEach((el, index) => {\n const htmlEl = el as HTMLElement;\n const id = `visual-id-${htmlEl.dataset.filename}-${htmlEl.dataset.linenumber}-${index}`;\n htmlEl.dataset.visualSelectorId = id;\n });\n\n // Create mutation observer to detect layout changes\n const mutationObserver = new MutationObserver((mutations) => {\n const needsUpdate = mutations.some((mutation) => {\n const hasVisualId = (node: Node): boolean => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const el = node as HTMLElement;\n if (el.dataset && el.dataset.visualSelectorId) {\n return true;\n }\n for (let i = 0; i < el.children.length; i++) {\n if (hasVisualId(el.children[i]!)) {\n return true;\n }\n }\n }\n return false;\n };\n\n const isLayoutChange =\n mutation.type === \"attributes\" &&\n (mutation.attributeName === \"style\" ||\n mutation.attributeName === \"class\" ||\n mutation.attributeName === \"width\" ||\n mutation.attributeName === \"height\");\n\n return isLayoutChange && hasVisualId(mutation.target);\n });\n\n if (needsUpdate) {\n setTimeout(handleResize, 50);\n }\n });\n\n // Set up event listeners\n window.addEventListener(\"message\", handleMessage);\n window.addEventListener(\"scroll\", handleScroll, true);\n document.addEventListener(\"scroll\", handleScroll, true);\n window.addEventListener(\"resize\", handleResize);\n window.addEventListener(\"scroll\", handleResize);\n\n // Start observing DOM mutations\n mutationObserver.observe(document.body, {\n attributes: true,\n childList: true,\n subtree: true,\n attributeFilter: [\"style\", \"class\", \"width\", \"height\"],\n });\n\n // Send ready message to parent\n window.parent.postMessage({ type: \"visual-edit-agent-ready\" }, \"*\");\n}"],"mappings":"AACO,SAASA,EAAiBC,EAA8B,CAC7D,GAAI,CAACA,EAAI,MAAO,CAAC,EACjB,IAAMC,EAAiB,MAAM,KAC3B,SAAS,iBAAiB,0BAA0BD,CAAE,IAAI,CAC5D,EACA,OAAIC,EAAe,OAAS,EACnBA,EAEF,MAAM,KACX,SAAS,iBAAiB,6BAA6BD,CAAE,IAAI,CAC/D,CACF,CAMO,SAASE,EAAqBC,EAAqBC,EAAuB,CAC/ED,EAAS,QAASE,GAAY,CAC5BA,EAAQ,aAAa,QAASD,CAAO,CACvC,CAAC,CACH,CCpBO,SAASE,GAAuB,CAErC,IAAIC,EAAmB,GACnBC,EAAoB,GACpBC,EAAiB,GACjBC,EAAkC,CAAC,EACnCC,EAAqC,CAAC,EACtCC,EAAwC,CAAC,EACzCC,EAAmC,KAGjCC,EAAgB,CAACC,EAAa,KAA0B,CAC5D,IAAMC,EAAU,SAAS,cAAc,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AK8B,EACX,GAAI9B,EAAG,SAAWA,EAAG,QAAQ,iBAC3B,MAAO,GAET,QAAS+B,EAAI,EAAGA,EAAI/B,EAAG,SAAS,OAAQ+B,IACtC,GAAIF,EAAY7B,EAAG,SAAS+B,CAAC,CAAE,EAC7B,MAAO,EAGb,CACA,MAAO,EACT,EASA,OANEH,EAAS,OAAS,eACjBA,EAAS,gBAAkB,SAC1BA,EAAS,gBAAkB,SAC3BA,EAAS,gBAAkB,SAC3BA,EAAS,gBAAkB,WAENC,EAAYD,EAAS,MAAM,CACtD,CAAC,GAGC,WAAWL,EAAc,EAAE,CAE/B,CAAC,EAGD,OAAO,iBAAiB,UAAWH,CAAa,EAChD,OAAO,iBAAiB,SAAUJ,EAAc,EAAI,EACpD,SAAS,iBAAiB,SAAUA,EAAc,EAAI,EACtD,OAAO,iBAAiB,SAAUO,CAAY,EAC9C,OAAO,iBAAiB,SAAUA,CAAY,EAG9CG,EAAiB,QAAQ,SAAS,KAAM,CACtC,WAAY,GACZ,UAAW,GACX,QAAS,GACT,gBAAiB,CAAC,QAAS,QAAS,QAAS,QAAQ,CACvD,CAAC,EAGD,OAAO,OAAO,YAAY,CAAE,KAAM,yBAA0B,EAAG,GAAG,CACpE","names":["findElementsById","id","sourceElements","updateElementClasses","elements","classes","element","setupVisualEditAgent","isVisualEditMode","isPopoverDragging","isDropdownOpen","hoverOverlays","selectedOverlays","currentHighlightedElements","selectedElementId","createOverlay","isSelected","overlay","positionOverlay","element","rect","label","clearHoverOverlays","handleMouseOver","e","target","htmlElement","selectorId","elements","findElementsById","el","handleMouseOut","handleElementClick","visualSelectorId","elementPosition","svgElement","elementData","unselectElement","updateElementClassesAndReposition","classes","updateElementClasses","index","updateElementContent","content","toggleVisualEditMode","isEnabled","handleScroll","viewportHeight","viewportWidth","isInViewport","handleMessage","event","message","handleResize","htmlEl","id","mutationObserver","mutations","mutation","hasVisualId","node","i"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual-edit-plugin.d.ts","sourceRoot":"","sources":["../src/visual-edit-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"visual-edit-plugin.d.ts","sourceRoot":"","sources":["../src/visual-edit-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,GAAG,WA2G9D;AAED,wBAAgB,gBAAgB,IA2KzB,MAAM,CACZ"}
|