@base44/vite-plugin 0.2.22 → 0.2.24

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.
@@ -1,2 +1,2 @@
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};
1
+ function p(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 W(){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},f=(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=p(s||null);m(),o.forEach(i=>{let r=L(!1);document.body.appendChild(r),E.push(r),f(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=[],p(s||null).forEach(v=>{let y=L(!0);document.body.appendChild(y),c.push(y),f(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},w=["p","h1","h2","h3","h4","h5","h6","span","a","label"].includes(t.tagName?.toLowerCase()),O=t,V={type:"element-selected",tagName:t.tagName,classes:O.className?.baseVal||t.className||"",visualSelectorId:s,content:w?t.innerText:void 0,dataSourceLocation:a.dataset.sourceLocation,isDynamicContent:a.dataset.dynamicContent==="true",linenumber:a.dataset.linenumber,filename:a.dataset.filename,position:r,isTextElement:w};window.parent.postMessage(V,"*")},x=()=>{c.forEach(n=>{n&&n.parentNode&&n.remove()}),c=[],l=null},H=(n,e)=>{let t=p(n);t.length!==0&&(T(t,e),setTimeout(()=>{l===n&&c.forEach((a,s)=>{s<t.length&&f(a,t[s])}),u.length>0&&u[0]?.dataset?.visualSelectorId===n&&E.forEach((o,i)=>{i<u.length&&f(o,u[i])})},50))},D=(n,e)=>{let t=p(n);t.length!==0&&(t.forEach(a=>{a.innerText=e}),setTimeout(()=>{l===n&&c.forEach((a,s)=>{s<t.length&&f(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=p(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?H(e.data.visualSelectorId,e.data.classes):console.warn("[VisualEditAgent] Invalid update-classes message:",e);break;case"unselect-element":x();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=p(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,w={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:w,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}},b=()=>{if(l){let n=p(l);c.forEach((e,t)=>{t<n.length&&f(e,n[t])})}u.length>0&&E.forEach((n,e)=>{e<u.length&&f(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(b,50)});window.addEventListener("message",k),window.addEventListener("scroll",N,!0),document.addEventListener("scroll",N,!0),window.addEventListener("resize",b),window.addEventListener("scroll",b),A.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class","width","height"]}),window.parent.postMessage({type:"visual-edit-agent-ready"},"*")}export{W as setupVisualEditAgent};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
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,KAAK,EAC5C,OAAAA,EAAQ,MAAM,SAAW,WACzBA,EAAQ,MAAM,cAAgB,OAC9BA,EAAQ,MAAM,WAAa,uBAC3BA,EAAQ,MAAM,OAAS,OAEnBD,EACFC,EAAQ,MAAM,OAAS,qBAEvBA,EAAQ,MAAM,OAAS,oBACvBA,EAAQ,MAAM,gBAAkB,4BAG3BA,CACT,EAGMC,EAAkB,CACtBD,EACAE,EACAH,EAAa,KACV,CACH,GAAI,CAACG,GAAW,CAACX,EAAkB,OAEfW,EAEH,YAEjB,IAAMC,EAAOD,EAAQ,sBAAsB,EAC3CF,EAAQ,MAAM,IAAM,GAAGG,EAAK,IAAM,OAAO,OA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AAa,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
+ {"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 const isTextElement = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'a', 'label'].includes(element.tagName?.toLowerCase())\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: isTextElement ? (element as HTMLElement).innerText : undefined,\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 isTextElement: isTextElement,\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,KAAK,EAC5C,OAAAA,EAAQ,MAAM,SAAW,WACzBA,EAAQ,MAAM,cAAgB,OAC9BA,EA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/C,IAAMC,EAAeC,GAAwB,CAC3C,GAAIA,EAAK,WAAa,KAAK,aAAc,CACvC,IAAM/B,EAAK+B,EACX,GAAI/B,EAAG,SAAWA,EAAG,QAAQ,iBAC3B,MAAO,GAET,QAASgC,EAAI,EAAGA,EAAIhC,EAAG,SAAS,OAAQgC,IACtC,GAAIF,EAAY9B,EAAG,SAASgC,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","isTextElement","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;AAGnC,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,GAAG,WA2G9D;AAED,wBAAgB,gBAAgB,IAuKzB,MAAM,CACZ"}
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"}
@@ -2,6 +2,8 @@ import { parse } from "@babel/parser";
2
2
  import { default as traverse } from "@babel/traverse";
3
3
  import { default as generate } from "@babel/generator";
4
4
  import * as t from "@babel/types";
5
+ import { StaticArrayProcessor } from "./processors/static-array-processor.js";
6
+ import { JSXUtils } from "./jsx-utils.js";
5
7
  // Helper function to check if JSX element contains dynamic content
6
8
  export function checkIfElementHasDynamicContent(jsxElement) {
7
9
  let hasDynamicContent = false;
@@ -190,6 +192,8 @@ export function visualEditPlugin() {
190
192
  ],
191
193
  });
192
194
  // Traverse the AST and add source location and dynamic content attributes to JSX elements
195
+ JSXUtils.init(t);
196
+ const staticArrayProcessor = new StaticArrayProcessor(t);
193
197
  let elementsProcessed = 0;
194
198
  traverse.default(ast, {
195
199
  JSXElement(path) {
@@ -217,6 +221,7 @@ export function visualEditPlugin() {
217
221
  const dynamicContentAttr = t.jsxAttribute(t.jsxIdentifier("data-dynamic-content"), t.stringLiteral(isDynamic ? "true" : "false"));
218
222
  // Add both attributes to the beginning of the attributes array
219
223
  openingElement.attributes.unshift(sourceLocationAttr, dynamicContentAttr);
224
+ staticArrayProcessor.process(path.get("openingElement"));
220
225
  elementsProcessed++;
221
226
  },
222
227
  });
@@ -1 +1 @@
1
- {"version":3,"file":"visual-edit-plugin.js","sourceRoot":"","sources":["../src/visual-edit-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,mEAAmE;AACnE,MAAM,UAAU,+BAA+B,CAAC,UAAe;IAC7D,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAE9B,iEAAiE;IACjE,SAAS,0BAA0B,CAAC,IAAS;QAC3C,wDAAwD;QACxD,IAAI,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;YAEnC,4BAA4B;YAC5B,IAAI,CAAC,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACvC,OAAO,KAAK,CAAC;YACf,CAAC;YAED,mDAAmD;YACnD,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,IAAI,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,mDAAmD;QACnD,IAAI,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,C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BACd,WAAW,EAAE,IAAI;iBAClB,CAAC,CAAC;gBAEH,OAAO;oBACL,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,GAAG,EAAE,IAAI;iBACV,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;gBAC9D,OAAO;oBACL,IAAI,EAAE,IAAI,EAAE,kCAAkC;oBAC9C,GAAG,EAAE,IAAI;iBACV,CAAC;YACJ,CAAC;QACH,CAAC;KACQ,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44/vite-plugin",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "description": "The Vite plugin for base44 based applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,6 +23,7 @@
23
23
  "test:unit": "vitest run"
24
24
  },
25
25
  "devDependencies": {
26
+ "@babel/core": "^7.29.0",
26
27
  "@types/babel__generator": "^7.27.0",
27
28
  "@types/babel__traverse": "^7.28.0",
28
29
  "@types/node": "^24.6.2",
@@ -216,6 +216,8 @@ export function setupVisualEditAgent() {
216
216
  centerY: rect.top + rect.height / 2,
217
217
  };
218
218
 
219
+ const isTextElement = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'a', 'label'].includes(element.tagName?.toLowerCase())
220
+
219
221
  // Send message to parent window with element info including position
220
222
  const svgElement = element as SVGElement;
221
223
  const elementData = {
@@ -226,12 +228,13 @@ export function setupVisualEditAgent() {
226
228
  element.className ||
227
229
  "",
228
230
  visualSelectorId: visualSelectorId,
229
- content: (element as HTMLElement).innerText,
231
+ content: isTextElement ? (element as HTMLElement).innerText : undefined,
230
232
  dataSourceLocation: htmlElement.dataset.sourceLocation,
231
233
  isDynamicContent: htmlElement.dataset.dynamicContent === "true",
232
234
  linenumber: htmlElement.dataset.linenumber,
233
235
  filename: htmlElement.dataset.filename,
234
236
  position: elementPosition,
237
+ isTextElement: isTextElement,
235
238
  };
236
239
  window.parent.postMessage(elementData, "*");
237
240
  };
@@ -0,0 +1,147 @@
1
+ import type { NodePath } from "@babel/traverse";
2
+ import type * as t from "@babel/types";
3
+ import { StaticArrayProcessor } from "./processors/static-array-processor.js";
4
+
5
+ export class JSXProcessor {
6
+ private staticArrayProcessor: StaticArrayProcessor;
7
+
8
+ constructor(
9
+ private types: typeof t,
10
+ private filename: string
11
+ ) {
12
+ this.staticArrayProcessor = new StaticArrayProcessor(types);
13
+ }
14
+
15
+ processJSXElement(path: NodePath<t.JSXOpeningElement>): void {
16
+ if (this.hasAttribute(path, "data-source-location")) return;
17
+
18
+ this.addSourceLocationAttribute(path);
19
+ this.addDynamicContentAttribute(path);
20
+ this.addContentEditableAttribute(path);
21
+ this.staticArrayProcessor.process(path);
22
+ }
23
+
24
+ private addSourceLocationAttribute(
25
+ path: NodePath<t.JSXOpeningElement>
26
+ ): void {
27
+ const { line, column } = path.node.loc?.start || { line: 1, column: 0 };
28
+ const value = `${this.filename}:${line}:${column}`;
29
+
30
+ path.node.attributes.push(
31
+ this.types.jsxAttribute(
32
+ this.types.jsxIdentifier("data-source-location"),
33
+ this.types.stringLiteral(value)
34
+ )
35
+ );
36
+ }
37
+
38
+ private addDynamicContentAttribute(
39
+ path: NodePath<t.JSXOpeningElement>
40
+ ): void {
41
+ const parentElement = path.parentPath;
42
+ if (!parentElement?.isJSXElement()) return;
43
+
44
+ const isDynamic = this.checkIfElementHasDynamicContent(
45
+ parentElement.node as t.JSXElement
46
+ );
47
+
48
+ path.node.attributes.push(
49
+ this.types.jsxAttribute(
50
+ this.types.jsxIdentifier("data-dynamic-content"),
51
+ this.types.stringLiteral(isDynamic ? "true" : "false")
52
+ )
53
+ );
54
+ }
55
+
56
+ private addContentEditableAttribute(
57
+ path: NodePath<t.JSXOpeningElement>
58
+ ): void {
59
+ path.node.attributes.push(
60
+ this.types.jsxAttribute(
61
+ this.types.jsxIdentifier("content-editable"),
62
+ this.types.stringLiteral("true")
63
+ )
64
+ );
65
+ }
66
+
67
+ private hasAttribute(
68
+ path: NodePath<t.JSXOpeningElement>,
69
+ name: string
70
+ ): boolean {
71
+ return path.node.attributes.some(
72
+ (attr: t.JSXAttribute | t.JSXSpreadAttribute) =>
73
+ this.types.isJSXAttribute(attr) &&
74
+ this.types.isJSXIdentifier(attr.name) &&
75
+ attr.name.name === name
76
+ );
77
+ }
78
+
79
+ private checkIfElementHasDynamicContent(jsxElement: t.JSXElement): boolean {
80
+ let hasDynamicContent = false;
81
+
82
+ const checkNode = (node: t.Node): boolean => {
83
+ if (this.types.isJSXExpressionContainer(node)) {
84
+ const expression = (node as t.JSXExpressionContainer).expression;
85
+ if (this.types.isJSXEmptyExpression(expression)) return false;
86
+ if (!this.types.isLiteral(expression)) return true;
87
+ }
88
+
89
+ if (
90
+ this.types.isTemplateLiteral(node) &&
91
+ (node as t.TemplateLiteral).expressions.length > 0
92
+ ) {
93
+ return true;
94
+ }
95
+ if (this.types.isMemberExpression(node)) return true;
96
+ if (this.types.isCallExpression(node)) return true;
97
+ if (this.types.isConditionalExpression(node)) return true;
98
+
99
+ if (this.types.isIdentifier(node)) {
100
+ const dynamicNames = [
101
+ "props",
102
+ "state",
103
+ "data",
104
+ "item",
105
+ "value",
106
+ "text",
107
+ "content",
108
+ ];
109
+ if (dynamicNames.some((name) => (node as t.Identifier).name.includes(name))) {
110
+ return true;
111
+ }
112
+ }
113
+
114
+ return false;
115
+ };
116
+
117
+ const traverseNode = (node: Record<string, unknown>): void => {
118
+ if (hasDynamicContent) return;
119
+ if (checkNode(node as unknown as t.Node)) {
120
+ hasDynamicContent = true;
121
+ return;
122
+ }
123
+
124
+ for (const key of Object.keys(node)) {
125
+ if (hasDynamicContent) return;
126
+ const value = node[key];
127
+
128
+ if (Array.isArray(value)) {
129
+ for (const child of value) {
130
+ if (child && typeof child === "object" && "type" in child) {
131
+ traverseNode(child as Record<string, unknown>);
132
+ }
133
+ }
134
+ } else if (value && typeof value === "object" && "type" in value) {
135
+ traverseNode(value as Record<string, unknown>);
136
+ }
137
+ }
138
+ };
139
+
140
+ for (const child of jsxElement.children) {
141
+ if (hasDynamicContent) break;
142
+ traverseNode(child as unknown as Record<string, unknown>);
143
+ }
144
+
145
+ return hasDynamicContent;
146
+ }
147
+ }
@@ -0,0 +1,15 @@
1
+ import type * as t from "@babel/types";
2
+
3
+ export class JSXUtils {
4
+ private static types: typeof t;
5
+
6
+ static init(types: typeof t) {
7
+ this.types = types;
8
+ }
9
+
10
+ static getAttributeName(attr: t.JSXAttribute): string {
11
+ return this.types.isJSXNamespacedName(attr.name)
12
+ ? `${attr.name.namespace.name}:${attr.name.name.name}`
13
+ : attr.name.name;
14
+ }
15
+ }
@@ -0,0 +1,116 @@
1
+ import type { NodePath } from "@babel/traverse";
2
+ import type * as t from "@babel/types";
3
+ import { JSXUtils } from "../jsx-utils.js";
4
+
5
+ export class JSXAttributeUtils {
6
+ constructor(private types: typeof t) {}
7
+
8
+ hasAttribute(
9
+ path: NodePath<t.JSXOpeningElement>,
10
+ attributeName: string
11
+ ): boolean {
12
+ return path.node.attributes.some(
13
+ (attr: t.JSXAttribute | t.JSXSpreadAttribute) =>
14
+ this.types.isJSXAttribute(attr) &&
15
+ JSXUtils.getAttributeName(attr) === attributeName
16
+ );
17
+ }
18
+
19
+ addStringAttribute(
20
+ path: NodePath<t.JSXOpeningElement>,
21
+ attributeName: string,
22
+ value: string
23
+ ): void {
24
+ if (!this.hasAttribute(path, attributeName)) {
25
+ path.node.attributes.push(
26
+ this.types.jsxAttribute(
27
+ this.types.jsxIdentifier(attributeName),
28
+ this.types.stringLiteral(value)
29
+ )
30
+ );
31
+ }
32
+ }
33
+
34
+ addExpressionAttribute(
35
+ path: NodePath<t.JSXOpeningElement>,
36
+ attributeName: string,
37
+ expression: t.Expression
38
+ ): void {
39
+ if (!this.hasAttribute(path, attributeName)) {
40
+ path.node.attributes.push(
41
+ this.types.jsxAttribute(
42
+ this.types.jsxIdentifier(attributeName),
43
+ this.types.jsxExpressionContainer(expression)
44
+ )
45
+ );
46
+ }
47
+ }
48
+ }
49
+
50
+ export class StaticValueUtils {
51
+ constructor(private types: typeof t) {}
52
+
53
+ isPrimitiveLiteral(path: NodePath<t.Node>): boolean {
54
+ return (
55
+ path.isStringLiteral() ||
56
+ path.isNumericLiteral() ||
57
+ path.isBooleanLiteral() ||
58
+ path.isNullLiteral()
59
+ );
60
+ }
61
+
62
+ isStaticValue(
63
+ path: NodePath<t.Node>,
64
+ visited: Set<string> = new Set()
65
+ ): boolean {
66
+ if (this.isPrimitiveLiteral(path)) return true;
67
+ if (path.isIdentifier()) return this.isStaticIdentifier(path, visited);
68
+ if (path.isObjectExpression()) return this.isStaticObject(path, visited);
69
+ if (path.isArrayExpression())
70
+ return this.isStaticArrayExpression(path, visited);
71
+ return false;
72
+ }
73
+
74
+ isStaticIdentifier(
75
+ path: NodePath<t.Identifier>,
76
+ visited: Set<string> = new Set()
77
+ ): boolean {
78
+ const binding = path.scope.getBinding(path.node.name);
79
+ if (!binding) return false;
80
+
81
+ if (binding.kind === "module") return true;
82
+
83
+ if (binding.kind === "const" && binding.path.isVariableDeclarator()) {
84
+ const name = path.node.name;
85
+ if (visited.has(name)) return false;
86
+ visited.add(name);
87
+
88
+ const init = binding.path.get("init");
89
+ if (init.hasNode()) {
90
+ return this.isStaticValue(init as NodePath<t.Node>, visited);
91
+ }
92
+ }
93
+
94
+ return false;
95
+ }
96
+
97
+ isStaticObject(
98
+ path: NodePath<t.ObjectExpression>,
99
+ visited: Set<string> = new Set()
100
+ ): boolean {
101
+ return path.get("properties").every((prop: NodePath) => {
102
+ if (!prop.isObjectProperty()) return false;
103
+ return this.isStaticValue(prop.get("value") as NodePath<t.Node>, visited);
104
+ });
105
+ }
106
+
107
+ isStaticArrayExpression(
108
+ arrayExpression: NodePath<t.ArrayExpression>,
109
+ visited: Set<string> = new Set()
110
+ ): boolean {
111
+ return arrayExpression.get("elements").every((element) => {
112
+ if (!element.node || element.isSpreadElement()) return true;
113
+ return this.isStaticValue(element as unknown as NodePath<t.Node>, visited);
114
+ });
115
+ }
116
+ }