viewgate-wrapper 1.3.4 → 1.3.5

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.
@@ -825,15 +825,15 @@ const Lt = (e) => {
825
825
  l.unshift(m), u = u.parentElement;
826
826
  }
827
827
  return l.join(" > ");
828
- })(e), s = e.innerText.slice(0, 50).trim(), i = `${e.tagName.toLowerCase()}-${s.replace(/\s+/g, "_")}-${a.split(" > ").slice(-2).join("_")}`;
828
+ })(e), s = (e.innerText || "").slice(0, 50).trim(), i = `${e.tagName.toLowerCase()}-${s.replace(/\s+/g, "_")}-${a.split(" > ").slice(-2).join("_")}`;
829
829
  return {
830
830
  tag: e.tagName.toLowerCase(),
831
831
  id: e.id || "",
832
832
  classes: e.className || "",
833
- text: e.innerText.slice(0, 100).trim(),
833
+ text: (e.innerText || "").slice(0, 100).trim(),
834
834
  selector: a,
835
- outerHtml: e.outerHTML.slice(0, 500),
836
- parentContext: e.parentElement?.innerText.slice(0, 100).trim() || "",
835
+ outerHtml: (e.outerHTML || "").slice(0, 500),
836
+ parentContext: (e.parentElement?.innerText || "").slice(0, 100).trim(),
837
837
  componentPath: r,
838
838
  signature: i,
839
839
  source: t
@@ -851,7 +851,7 @@ const Lt = (e) => {
851
851
  source: g.getAttribute("data-source-path") || "unknown:0",
852
852
  rect: g.getBoundingClientRect(),
853
853
  element: g,
854
- previewText: g.innerText.slice(0, 100) || g.getAttribute("placeholder")?.slice(0, 100) || g.tagName.toLowerCase(),
854
+ previewText: (g.innerText || "").slice(0, 100) || (g.getAttribute("placeholder") || "").slice(0, 100) || g.tagName.toLowerCase(),
855
855
  semanticReference: Ft(g)
856
856
  });
857
857
  }, [s, u]), L = oe(async (b) => {
@@ -5,6 +5,6 @@
5
5
  React keys must be passed directly to JSX without using spread:
6
6
  let props = %s;
7
7
  <%s key={someKey} {...props} />`,w,y,A,y),_e[y+w]=!0)}if(y=null,p!==void 0&&(r(p),y=""+p),i(f)&&(r(f.key),y=""+f.key),"key"in f){p={};for(var te in f)te!=="key"&&(p[te]=f[te])}else p=f;return y&&c(p,typeof o=="function"?o.displayName||o.name||"Unknown":o),u(o,y,p,a(),U,ee)}function h(o){b(o)?o._store&&(o._store.validated=1):typeof o=="object"&&o!==null&&o.$$typeof===O&&(o._payload.status==="fulfilled"?b(o._payload.value)&&o._payload.value._store&&(o._payload.value._store.validated=1):o._store&&(o._store.validated=1))}function b(o){return typeof o=="object"&&o!==null&&o.$$typeof===F}var T=x,F=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),q=Symbol.for("react.consumer"),Z=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),At=Symbol.for("react.activity"),Lt=Symbol.for("react.client.reference"),K=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Re=Object.prototype.hasOwnProperty,Vt=Array.isArray,Q=console.createTask?console.createTask:function(){return null};T={react_stack_bottom_frame:function(o){return o()}};var Ce,Te={},Pe=T.react_stack_bottom_frame.bind(T,s)(),ke=Q(n(s)),_e={};V.Fragment=_,V.jsx=function(o,f,p){var w=1e4>K.recentlyCreatedOwnerStacks++;return m(o,f,p,!1,w?Error("react-stack-top-frame"):Pe,w?Q(n(o)):ke)},V.jsxs=function(o,f,p){var w=1e4>K.recentlyCreatedOwnerStacks++;return m(o,f,p,!0,w?Error("react-stack-top-frame"):Pe,w?Q(n(o)):ke)}})()),V}var se;function Ae(){return se||(se=1,process.env.NODE_ENV==="production"?$.exports=je():$.exports=Oe()),$.exports}var d=Ae();const Le={en:{enterMode:"🚀 Enter Feedback Mode",exitMode:"✨ Exit Mode",feedbackHeader:"Feedback",selectedElement:"Selected element:",line:"Line",placeholder:"Tell us what you'd like to change...",cancel:"Cancel",send:"Send Feedback",submitting:"Submitting...",success:"Your feedback has been submitted successfully!",error:"Failed to submit feedback. Check backend connection.",successHeader:"Success",errorHeader:"Error",preview:"Preview"},es:{enterMode:"🚀 Activar Modo Comentarios",exitMode:"✨ Salir del Modo",feedbackHeader:"Comentarios",selectedElement:"Elemento seleccionado:",line:"Línea",placeholder:"Cuéntanos qué te gustaría cambiar...",cancel:"Cancelar",send:"Enviar Comentarios",submitting:"Enviando...",success:"¡Tus comentarios se han enviado con éxito!",error:"Error al enviar comentarios. Revisa la conexión con el servidor.",successHeader:"Éxito",errorHeader:"Error",preview:"Vista previa"}},ae=x.createContext(void 0),oe=()=>{const e=x.useContext(ae);if(!e)throw new Error("useViewGate must be used within a ViewGateProvider");return e},Ve=({children:e,language:t="es",apiKey:r,baseUrl:n="https://view-gate.vercel.app"})=>{const[a,s]=x.useState([]),i=(l,u)=>{const m=Date.now();s(h=>[...h,{id:m,message:l,type:u}]),setTimeout(()=>{s(h=>h.filter(b=>b.id!==m))},4e3)},c=Le[t];return d.jsxs(ae.Provider,{"data-source-path":"/src/components/ViewGateProvider.tsx:99",value:{addToast:i,language:t,t:c,apiKey:r,baseUrl:n},children:[e,d.jsx(Se,{"data-source-path":"/src/components/ViewGateProvider.tsx:101"}),d.jsx("div",{"data-source-path":"/src/components/ViewGateProvider.tsx:102",className:"vg-toasts",children:a.map(l=>d.jsxs("div",{"data-source-path":"/src/components/ViewGateProvider.tsx:104",className:`vg-toast vg-glassmorphism vg-animate-slide ${l.type}`,children:[d.jsx("span",{"data-source-path":"/src/components/ViewGateProvider.tsx:105",style:{fontSize:"20px"},children:l.type==="success"?"✅":"❌"}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateProvider.tsx:106",children:[d.jsx("strong",{"data-source-path":"/src/components/ViewGateProvider.tsx:107",style:{display:"block"},children:l.type==="success"?c.successHeader:c.errorHeader}),d.jsx("span",{"data-source-path":"/src/components/ViewGateProvider.tsx:108",style:{fontSize:"14px"},children:l.message})]})]},l.id))})]})};function Fe(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const r=document.implementation.createHTMLDocument(),n=r.createElement("base"),a=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(a),t&&(n.href=t),a.href=e,a.href}const Ie=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function C(e){const t=[];for(let r=0,n=e.length;r<n;r++)t.push(e[r]);return t}let P=null;function ie(e={}){return P||(e.includeStyleProperties?(P=e.includeStyleProperties,P):(P=C(window.getComputedStyle(document.documentElement)),P))}function D(e,t){const n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace("px","")):0}function Ge(e){const t=D(e,"border-left-width"),r=D(e,"border-right-width");return e.clientWidth+t+r}function Me(e){const t=D(e,"border-top-width"),r=D(e,"border-bottom-width");return e.clientHeight+t+r}function ce(e,t={}){const r=t.width||Ge(e),n=t.height||Me(e);return{width:r,height:n}}function $e(){let e,t;try{t=process}catch{}const r=t&&t.env?t.env.devicePixelRatio:null;return r&&(e=parseInt(r,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const S=16384;function De(e){(e.width>S||e.height>S)&&(e.width>S&&e.height>S?e.width>e.height?(e.height*=S/e.width,e.width=S):(e.width*=S/e.height,e.height=S):e.width>S?(e.height*=S/e.width,e.width=S):(e.width*=S/e.height,e.height=S))}function H(e){return new Promise((t,r)=>{const n=new Image;n.onload=()=>{n.decode().then(()=>{requestAnimationFrame(()=>t(n))})},n.onerror=r,n.crossOrigin="anonymous",n.decoding="async",n.src=e})}async function He(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function We(e,t,r){const n="http://www.w3.org/2000/svg",a=document.createElementNS(n,"svg"),s=document.createElementNS(n,"foreignObject");return a.setAttribute("width",`${t}`),a.setAttribute("height",`${r}`),a.setAttribute("viewBox",`0 0 ${t} ${r}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),a.appendChild(s),s.appendChild(e),He(a)}const E=(e,t)=>{if(e instanceof t)return!0;const r=Object.getPrototypeOf(e);return r===null?!1:r.constructor.name===t.name||E(r,t)};function Ne(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function Ue(e,t){return ie(t).map(r=>{const n=e.getPropertyValue(r),a=e.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function ze(e,t,r,n){const a=`.${e}:${t}`,s=r.cssText?Ne(r):Ue(r,n);return document.createTextNode(`${a}{${s}}`)}function le(e,t,r,n){const a=window.getComputedStyle(e,r),s=a.getPropertyValue("content");if(s===""||s==="none")return;const i=Ie();try{t.className=`${t.className} ${i}`}catch{return}const c=document.createElement("style");c.appendChild(ze(i,r,a,n)),t.appendChild(c)}function Ye(e,t,r){le(e,t,":before",r),le(e,t,":after",r)}const ue="application/font-woff",fe="image/jpeg",Be={woff:ue,woff2:ue,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:fe,jpeg:fe,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Je(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function z(e){const t=Je(e).toLowerCase();return Be[t]||""}function Xe(e){return e.split(/,/)[1]}function Y(e){return e.search(/^(data:)/)!==-1}function qe(e,t){return`data:${t};base64,${e}`}async function de(e,t,r){const n=await fetch(e,t);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const a=await n.blob();return new Promise((s,i)=>{const c=new FileReader;c.onerror=i,c.onloadend=()=>{try{s(r({res:n,result:c.result}))}catch(l){i(l)}},c.readAsDataURL(a)})}const B={};function Ze(e,t,r){let n=e.replace(/\?.*/,"");return r&&(n=e),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),t?`[${t}]${n}`:n}async function J(e,t,r){const n=Ze(e,t,r.includeQueryParams);if(B[n]!=null)return B[n];r.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let a;try{const s=await de(e,r.fetchRequestInit,({res:i,result:c})=>(t||(t=i.headers.get("Content-Type")||""),Xe(c)));a=qe(s,t)}catch(s){a=r.imagePlaceholder||"";let i=`Failed to fetch resource: ${e}`;s&&(i=typeof s=="string"?s:s.message),i&&console.warn(i)}return B[n]=a,a}async function Ke(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):H(t)}async function Qe(e,t){if(e.currentSrc){const s=document.createElement("canvas"),i=s.getContext("2d");s.width=e.clientWidth,s.height=e.clientHeight,i?.drawImage(e,0,0,s.width,s.height);const c=s.toDataURL();return H(c)}const r=e.poster,n=z(r),a=await J(r,n,t);return H(a)}async function et(e,t){var r;try{if(!((r=e?.contentDocument)===null||r===void 0)&&r.body)return await W(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function tt(e,t){return E(e,HTMLCanvasElement)?Ke(e):E(e,HTMLVideoElement)?Qe(e,t):E(e,HTMLIFrameElement)?et(e,t):e.cloneNode(me(e))}const rt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",me=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function nt(e,t,r){var n,a;if(me(t))return t;let s=[];return rt(e)&&e.assignedNodes?s=C(e.assignedNodes()):E(e,HTMLIFrameElement)&&(!((n=e.contentDocument)===null||n===void 0)&&n.body)?s=C(e.contentDocument.body.childNodes):s=C(((a=e.shadowRoot)!==null&&a!==void 0?a:e).childNodes),s.length===0||E(e,HTMLVideoElement)||await s.reduce((i,c)=>i.then(()=>W(c,r)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function st(e,t,r){const n=t.style;if(!n)return;const a=window.getComputedStyle(e);a.cssText?(n.cssText=a.cssText,n.transformOrigin=a.transformOrigin):ie(r).forEach(s=>{let i=a.getPropertyValue(s);s==="font-size"&&i.endsWith("px")&&(i=`${Math.floor(parseFloat(i.substring(0,i.length-2)))-.1}px`),E(e,HTMLIFrameElement)&&s==="display"&&i==="inline"&&(i="block"),s==="d"&&t.getAttribute("d")&&(i=`path(${t.getAttribute("d")})`),n.setProperty(s,i,a.getPropertyPriority(s))})}function at(e,t){E(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),E(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function ot(e,t){if(E(e,HTMLSelectElement)){const n=Array.from(t.children).find(a=>e.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function it(e,t,r){return E(t,Element)&&(st(e,t,r),Ye(e,t,r),at(e,t),ot(e,t)),t}async function ct(e,t){const r=e.querySelectorAll?e.querySelectorAll("use"):[];if(r.length===0)return e;const n={};for(let s=0;s<r.length;s++){const c=r[s].getAttribute("xlink:href");if(c){const l=e.querySelector(c),u=document.querySelector(c);!l&&u&&!n[c]&&(n[c]=await W(u,t,!0))}}const a=Object.values(n);if(a.length){const s="http://www.w3.org/1999/xhtml",i=document.createElementNS(s,"svg");i.setAttribute("xmlns",s),i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.overflow="hidden",i.style.display="none";const c=document.createElementNS(s,"defs");i.appendChild(c);for(let l=0;l<a.length;l++)c.appendChild(a[l]);e.appendChild(i)}return e}async function W(e,t,r){return!r&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(n=>tt(n,t)).then(n=>nt(e,n,t)).then(n=>it(e,n,t)).then(n=>ct(n,t))}const he=/url\((['"]?)([^'"]+?)\1\)/g,lt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,ut=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function ft(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function dt(e){const t=[];return e.replace(he,(r,n,a)=>(t.push(a),r)),t.filter(r=>!Y(r))}async function mt(e,t,r,n,a){try{const s=r?Fe(t,r):t,i=z(t);let c;return a||(c=await J(s,i,n)),e.replace(ft(t),`$1${c}$3`)}catch{}return e}function ht(e,{preferredFontFormat:t}){return t?e.replace(ut,r=>{for(;;){const[n,,a]=lt.exec(r)||[];if(!a)return"";if(a===t)return`src: ${n};`}}):e}function pe(e){return e.search(he)!==-1}async function ge(e,t,r){if(!pe(e))return e;const n=ht(e,r);return dt(n).reduce((s,i)=>s.then(c=>mt(c,i,t,r)),Promise.resolve(n))}async function k(e,t,r){var n;const a=(n=t.style)===null||n===void 0?void 0:n.getPropertyValue(e);if(a){const s=await ge(a,null,r);return t.style.setProperty(e,s,t.style.getPropertyPriority(e)),!0}return!1}async function pt(e,t){await k("background",e,t)||await k("background-image",e,t),await k("mask",e,t)||await k("-webkit-mask",e,t)||await k("mask-image",e,t)||await k("-webkit-mask-image",e,t)}async function gt(e,t){const r=E(e,HTMLImageElement);if(!(r&&!Y(e.src))&&!(E(e,SVGImageElement)&&!Y(e.href.baseVal)))return;const n=r?e.src:e.href.baseVal,a=await J(n,z(n),t);await new Promise((s,i)=>{e.onload=s,e.onerror=t.onImageErrorHandler?(...l)=>{try{s(t.onImageErrorHandler(...l))}catch(u){i(u)}}:i;const c=e;c.decode&&(c.decode=s),c.loading==="lazy"&&(c.loading="eager"),r?(e.srcset="",e.src=a):e.href.baseVal=a})}async function wt(e,t){const n=C(e.childNodes).map(a=>we(a,t));await Promise.all(n).then(()=>e)}async function we(e,t){E(e,Element)&&(await pt(e,t),await gt(e,t),await wt(e,t))}function yt(e,t){const{style:r}=e;t.backgroundColor&&(r.backgroundColor=t.backgroundColor),t.width&&(r.width=`${t.width}px`),t.height&&(r.height=`${t.height}px`);const n=t.style;return n!=null&&Object.keys(n).forEach(a=>{r[a]=n[a]}),e}const ye={};async function xe(e){let t=ye[e];if(t!=null)return t;const n=await(await fetch(e)).text();return t={url:e,cssText:n},ye[e]=t,t}async function be(e,t){let r=e.cssText;const n=/url\(["']?([^"')]+)["']?\)/g,s=(r.match(/url\([^)]+\)/g)||[]).map(async i=>{let c=i.replace(n,"$1");return c.startsWith("https://")||(c=new URL(c,e.url).href),de(c,t.fetchRequestInit,({result:l})=>(r=r.replace(i,`url(${l})`),[i,l]))});return Promise.all(s).then(()=>r)}function ve(e){if(e==null)return[];const t=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=e.replace(r,"");const a=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=a.exec(n);if(l===null)break;t.push(l[0])}n=n.replace(a,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(i,"gi");for(;;){let l=s.exec(n);if(l===null){if(l=c.exec(n),l===null)break;s.lastIndex=c.lastIndex}else c.lastIndex=s.lastIndex;t.push(l[0])}return t}async function xt(e,t){const r=[],n=[];return e.forEach(a=>{if("cssRules"in a)try{C(a.cssRules||[]).forEach((s,i)=>{if(s.type===CSSRule.IMPORT_RULE){let c=i+1;const l=s.href,u=xe(l).then(m=>be(m,t)).then(m=>ve(m).forEach(h=>{try{a.insertRule(h,h.startsWith("@import")?c+=1:a.cssRules.length)}catch(b){console.error("Error inserting rule from remote css",{rule:h,error:b})}})).catch(m=>{console.error("Error loading remote css",m.toString())});n.push(u)}})}catch(s){const i=e.find(c=>c.href==null)||document.styleSheets[0];a.href!=null&&n.push(xe(a.href).then(c=>be(c,t)).then(c=>ve(c).forEach(l=>{i.insertRule(l,i.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",s)}}),Promise.all(n).then(()=>(e.forEach(a=>{if("cssRules"in a)try{C(a.cssRules||[]).forEach(s=>{r.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${a.href}`,s)}}),r))}function bt(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>pe(t.style.getPropertyValue("src")))}async function vt(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=C(e.ownerDocument.styleSheets),n=await xt(r,t);return bt(n)}function Ee(e){return e.trim().replace(/["']/g,"")}function Et(e){const t=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(s=>{t.add(Ee(s))}),Array.from(n.children).forEach(s=>{s instanceof HTMLElement&&r(s)})}return r(e),t}async function St(e,t){const r=await vt(e,t),n=Et(e);return(await Promise.all(r.filter(s=>n.has(Ee(s.style.fontFamily))).map(s=>{const i=s.parentStyleSheet?s.parentStyleSheet.href:null;return ge(s.cssText,i,t)}))).join(`
8
- `)}async function Rt(e,t){const r=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await St(e,t);if(r){const n=document.createElement("style"),a=document.createTextNode(r);n.appendChild(a),e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n)}}async function Ct(e,t={}){const{width:r,height:n}=ce(e,t),a=await W(e,t,!0);return await Rt(a,t),await we(a,t),yt(a,t),await We(a,r,n)}async function Tt(e,t={}){const{width:r,height:n}=ce(e,t),a=await Ct(e,t),s=await H(a),i=document.createElement("canvas"),c=i.getContext("2d"),l=t.pixelRatio||$e(),u=t.canvasWidth||r,m=t.canvasHeight||n;return i.width=u*l,i.height=m*l,t.skipAutoScale||De(i),i.style.width=`${u}`,i.style.height=`${m}`,t.backgroundColor&&(c.fillStyle=t.backgroundColor,c.fillRect(0,0,i.width,i.height)),c.drawImage(s,0,0,i.width,i.height),i}async function Pt(e,t={}){return(await Tt(e,t)).toDataURL()}const kt=e=>{const r=Object.keys(e).find(s=>s.startsWith("__reactFiber$")||s.startsWith("__reactInternalInstance$"));if(!r)return"";const n=[];let a=e[r];for(;a;){const s=a.type;if(typeof s=="function"){const i=s.displayName||s.name;i&&!i.includes("ViewGate")&&!n.includes(i)&&n.unshift(i)}a=a.return}return n.join(" > ")||"Generic Component"},_t=e=>{const t=e.getAttribute("data-source-path")||"unknown:0",r=kt(e),a=(c=>{const l=[];let u=c;for(;u&&u.nodeType===Node.ELEMENT_NODE;){let m=u.nodeName.toLowerCase();if(u.id){m+="#"+u.id,l.unshift(m);break}else{let h=u,b=1;for(;h.previousElementSibling;)h=h.previousElementSibling,h.nodeName.toLowerCase()===m&&b++;b>1&&(m+=`:nth-of-type(${b})`)}l.unshift(m),u=u.parentElement}return l.join(" > ")})(e),s=e.innerText.slice(0,50).trim(),i=`${e.tagName.toLowerCase()}-${s.replace(/\s+/g,"_")}-${a.split(" > ").slice(-2).join("_")}`;return{tag:e.tagName.toLowerCase(),id:e.id||"",classes:e.className||"",text:e.innerText.slice(0,100).trim(),selector:a,outerHtml:e.outerHTML.slice(0,500),parentContext:e.parentElement?.innerText.slice(0,100).trim()||"",componentPath:r,signature:i,source:t}},Se=()=>{const{addToast:e,language:t,t:r,apiKey:n,baseUrl:a}=oe(),[s,i]=x.useState(!1),[c,l]=x.useState(null),[u,m]=x.useState(null),[h,b]=x.useState(""),[T,F]=x.useState(!1),[N,_]=x.useState(!1),I=x.useCallback(v=>{if(!s||u)return;const g=document.elementFromPoint(v.clientX,v.clientY);if(!g||g.id==="viewgate-overlay"||g.closest("#viewgate-ui")){l(null);return}g.getAttribute("data-source-path"),l({tag:g.tagName.toLowerCase(),source:g.getAttribute("data-source-path")||"unknown:0",rect:g.getBoundingClientRect(),element:g,previewText:g.innerText.slice(0,100)||g.getAttribute("placeholder")?.slice(0,100)||g.tagName.toLowerCase(),semanticReference:_t(g)})},[s,u]),G=x.useCallback(async v=>{if(!(!s||u)&&c){v.preventDefault(),v.stopPropagation(),_(!0);try{const g=c.element.style.display,j=window.getComputedStyle(c.element).display==="inline";j&&(c.element.style.display="inline-block");const M=await Pt(c.element,{backgroundColor:"#ffffff",pixelRatio:2,skipFonts:!0,style:{margin:"0",padding:"4px"}});j&&(c.element.style.display=g),m({...c,visualPreview:M})}catch(g){console.error("Failed to capture preview:",g),m(c)}finally{_(!1),l(null)}}},[s,c,u]);x.useEffect(()=>(s&&!u?document.body.classList.add("vg-cursor-pointer"):document.body.classList.remove("vg-cursor-pointer"),window.addEventListener("mousemove",I),window.addEventListener("click",G,!0),()=>{document.body.classList.remove("vg-cursor-pointer"),window.removeEventListener("mousemove",I),window.removeEventListener("click",G,!0)}),[s,u,I,G]);const q=async()=>{if(!u||!h.trim())return;F(!0);const{semanticReference:v}=u,[g,j]=v.source.split(":"),M=j||"0";try{if(!(await fetch(`${a}/api/annotations`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":n},body:JSON.stringify({filePath:g,line:parseInt(M),url:window.location.href,message:h,componentName:v.componentPath||u.tag,reference:v})})).ok)throw new Error("Backend failed");e(r.success,"success"),m(null),b(""),i(!1)}catch(O){console.error(O),e(r.error,"error")}finally{F(!1)}},Z=v=>v.split("/").pop()?.split("\\").pop()||"unknown";return d.jsxs(d.Fragment,{children:[d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:230",style:{position:"fixed",bottom:"30px",right:"30px",zIndex:99999},id:"viewgate-ui",children:d.jsx("button",{onClick:()=>i(!s),className:"vg-button-primary",style:{padding:"12px 24px",fontSize:"15px"},children:s?r.exitMode:r.enterMode})}),N&&d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:242",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(255,255,255,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e5,cursor:"wait"},children:d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:255",className:"vg-glassmorphism",style:{padding:"20px 40px",fontWeight:700},children:"Capturing..."})}),s&&c&&!u&&!N&&d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:263",style:{position:"fixed",top:c.rect.top,left:c.rect.left,width:c.rect.width,height:c.rect.height,border:"2px solid var(--vg-primary)",backgroundColor:"rgba(37, 19, 236, 0.05)",pointerEvents:"none",zIndex:99998,borderRadius:"4px",boxShadow:"0 0 15px rgba(37, 19, 236, 0.2)",transition:"all 0.1s ease-out"}}),u&&d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:281",className:"vg-animate-fade",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999},children:d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:294",className:"vg-glassmorphism vg-animate-slide",style:{padding:"32px",width:"460px",background:"white",color:"#0f172a"},children:[d.jsx("h2",{"data-source-path":"/src/components/ViewGateOverlay.tsx:300",style:{margin:"0 0 10px 0",fontSize:"24px",fontWeight:800},children:r.feedbackHeader}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:302",style:{marginBottom:"20px"},children:[d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:303",style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center"},children:[u.semanticReference.componentPath?d.jsxs("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:305",className:"vg-badge",style:{backgroundColor:"#f5f3ff",color:"#7c3aed",borderColor:"#ddd6fe"},children:["📦 ",u.semanticReference.componentPath]}):d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:309",className:"vg-badge",children:u.tag}),u.semanticReference.source&&!u.semanticReference.source.startsWith("unknown")?d.jsx(d.Fragment,{children:d.jsxs("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:314",className:"vg-badge",style:{backgroundColor:"#fdf2f8",color:"#db2777",borderColor:"#fbcfe8"},children:["📄 ",Z(u.semanticReference.source.split(":")[0]||"unknown")]})}):d.jsxs("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:319",className:"vg-badge",style:{backgroundColor:"#f0f9ff",color:"#0369a1",borderColor:"#bae6fd",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["🆔 ",u.semanticReference.signature]})]}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:324",style:{marginTop:"8px",fontSize:"11px",color:"#94a3b8"},children:["🎯 ",u.semanticReference.selector]})]}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:330",style:{backgroundColor:"#f8fafc",borderRadius:"8px",border:"1px solid #e2e8f0",marginBottom:"20px",overflow:"hidden",display:"flex",flexDirection:"column"},children:[d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:339",style:{padding:"8px 12px",fontSize:"10px",color:"#94a3b8",textTransform:"uppercase",fontWeight:700,borderBottom:"1px solid #f1f5f9"},children:r.preview}),d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:342",style:{padding:"12px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:"60px",maxHeight:"150px",overflow:"hidden",backgroundColor:"white"},children:u.visualPreview?d.jsx("img",{src:u.visualPreview,alt:"Element Preview",style:{maxWidth:"100%",maxHeight:"120px",objectFit:"contain",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",borderRadius:"4px"}}):d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:365",style:{fontSize:"13px",color:"#64748b",fontStyle:"italic"},children:['"',u.previewText,'"']})})]}),d.jsx("textarea",{className:"vg-textarea",value:h,onChange:v=>b(v.target.value),rows:4,placeholder:r.placeholder,autoFocus:!0}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:381",style:{display:"flex",justifyContent:"flex-end",gap:"12px",marginTop:"24px"},children:[d.jsx("button",{onClick:()=>m(null),className:"vg-button-ghost",children:r.cancel}),d.jsx("button",{onClick:q,className:"vg-button-primary",disabled:T||!h.trim(),style:{opacity:T||!h.trim()?.6:1},children:T?r.submitting:r.send})]})]})})]})};function X(e,t,r){if(!t.endsWith(".tsx")&&!t.endsWith(".jsx")||t.includes("node_modules"))return e;const n=c=>c.replace(/\\/g,"/"),a=n(t).replace(n(r),"");return e.split(`
8
+ `)}async function Rt(e,t){const r=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await St(e,t);if(r){const n=document.createElement("style"),a=document.createTextNode(r);n.appendChild(a),e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n)}}async function Ct(e,t={}){const{width:r,height:n}=ce(e,t),a=await W(e,t,!0);return await Rt(a,t),await we(a,t),yt(a,t),await We(a,r,n)}async function Tt(e,t={}){const{width:r,height:n}=ce(e,t),a=await Ct(e,t),s=await H(a),i=document.createElement("canvas"),c=i.getContext("2d"),l=t.pixelRatio||$e(),u=t.canvasWidth||r,m=t.canvasHeight||n;return i.width=u*l,i.height=m*l,t.skipAutoScale||De(i),i.style.width=`${u}`,i.style.height=`${m}`,t.backgroundColor&&(c.fillStyle=t.backgroundColor,c.fillRect(0,0,i.width,i.height)),c.drawImage(s,0,0,i.width,i.height),i}async function Pt(e,t={}){return(await Tt(e,t)).toDataURL()}const kt=e=>{const r=Object.keys(e).find(s=>s.startsWith("__reactFiber$")||s.startsWith("__reactInternalInstance$"));if(!r)return"";const n=[];let a=e[r];for(;a;){const s=a.type;if(typeof s=="function"){const i=s.displayName||s.name;i&&!i.includes("ViewGate")&&!n.includes(i)&&n.unshift(i)}a=a.return}return n.join(" > ")||"Generic Component"},_t=e=>{const t=e.getAttribute("data-source-path")||"unknown:0",r=kt(e),a=(c=>{const l=[];let u=c;for(;u&&u.nodeType===Node.ELEMENT_NODE;){let m=u.nodeName.toLowerCase();if(u.id){m+="#"+u.id,l.unshift(m);break}else{let h=u,b=1;for(;h.previousElementSibling;)h=h.previousElementSibling,h.nodeName.toLowerCase()===m&&b++;b>1&&(m+=`:nth-of-type(${b})`)}l.unshift(m),u=u.parentElement}return l.join(" > ")})(e),s=(e.innerText||"").slice(0,50).trim(),i=`${e.tagName.toLowerCase()}-${s.replace(/\s+/g,"_")}-${a.split(" > ").slice(-2).join("_")}`;return{tag:e.tagName.toLowerCase(),id:e.id||"",classes:e.className||"",text:(e.innerText||"").slice(0,100).trim(),selector:a,outerHtml:(e.outerHTML||"").slice(0,500),parentContext:(e.parentElement?.innerText||"").slice(0,100).trim(),componentPath:r,signature:i,source:t}},Se=()=>{const{addToast:e,language:t,t:r,apiKey:n,baseUrl:a}=oe(),[s,i]=x.useState(!1),[c,l]=x.useState(null),[u,m]=x.useState(null),[h,b]=x.useState(""),[T,F]=x.useState(!1),[N,_]=x.useState(!1),I=x.useCallback(v=>{if(!s||u)return;const g=document.elementFromPoint(v.clientX,v.clientY);if(!g||g.id==="viewgate-overlay"||g.closest("#viewgate-ui")){l(null);return}g.getAttribute("data-source-path"),l({tag:g.tagName.toLowerCase(),source:g.getAttribute("data-source-path")||"unknown:0",rect:g.getBoundingClientRect(),element:g,previewText:(g.innerText||"").slice(0,100)||(g.getAttribute("placeholder")||"").slice(0,100)||g.tagName.toLowerCase(),semanticReference:_t(g)})},[s,u]),G=x.useCallback(async v=>{if(!(!s||u)&&c){v.preventDefault(),v.stopPropagation(),_(!0);try{const g=c.element.style.display,j=window.getComputedStyle(c.element).display==="inline";j&&(c.element.style.display="inline-block");const M=await Pt(c.element,{backgroundColor:"#ffffff",pixelRatio:2,skipFonts:!0,style:{margin:"0",padding:"4px"}});j&&(c.element.style.display=g),m({...c,visualPreview:M})}catch(g){console.error("Failed to capture preview:",g),m(c)}finally{_(!1),l(null)}}},[s,c,u]);x.useEffect(()=>(s&&!u?document.body.classList.add("vg-cursor-pointer"):document.body.classList.remove("vg-cursor-pointer"),window.addEventListener("mousemove",I),window.addEventListener("click",G,!0),()=>{document.body.classList.remove("vg-cursor-pointer"),window.removeEventListener("mousemove",I),window.removeEventListener("click",G,!0)}),[s,u,I,G]);const q=async()=>{if(!u||!h.trim())return;F(!0);const{semanticReference:v}=u,[g,j]=v.source.split(":"),M=j||"0";try{if(!(await fetch(`${a}/api/annotations`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":n},body:JSON.stringify({filePath:g,line:parseInt(M),url:window.location.href,message:h,componentName:v.componentPath||u.tag,reference:v})})).ok)throw new Error("Backend failed");e(r.success,"success"),m(null),b(""),i(!1)}catch(O){console.error(O),e(r.error,"error")}finally{F(!1)}},Z=v=>v.split("/").pop()?.split("\\").pop()||"unknown";return d.jsxs(d.Fragment,{children:[d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:230",style:{position:"fixed",bottom:"30px",right:"30px",zIndex:99999},id:"viewgate-ui",children:d.jsx("button",{onClick:()=>i(!s),className:"vg-button-primary",style:{padding:"12px 24px",fontSize:"15px"},children:s?r.exitMode:r.enterMode})}),N&&d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:242",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(255,255,255,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e5,cursor:"wait"},children:d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:255",className:"vg-glassmorphism",style:{padding:"20px 40px",fontWeight:700},children:"Capturing..."})}),s&&c&&!u&&!N&&d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:263",style:{position:"fixed",top:c.rect.top,left:c.rect.left,width:c.rect.width,height:c.rect.height,border:"2px solid var(--vg-primary)",backgroundColor:"rgba(37, 19, 236, 0.05)",pointerEvents:"none",zIndex:99998,borderRadius:"4px",boxShadow:"0 0 15px rgba(37, 19, 236, 0.2)",transition:"all 0.1s ease-out"}}),u&&d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:281",className:"vg-animate-fade",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999},children:d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:294",className:"vg-glassmorphism vg-animate-slide",style:{padding:"32px",width:"460px",background:"white",color:"#0f172a"},children:[d.jsx("h2",{"data-source-path":"/src/components/ViewGateOverlay.tsx:300",style:{margin:"0 0 10px 0",fontSize:"24px",fontWeight:800},children:r.feedbackHeader}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:302",style:{marginBottom:"20px"},children:[d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:303",style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center"},children:[u.semanticReference.componentPath?d.jsxs("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:305",className:"vg-badge",style:{backgroundColor:"#f5f3ff",color:"#7c3aed",borderColor:"#ddd6fe"},children:["📦 ",u.semanticReference.componentPath]}):d.jsx("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:309",className:"vg-badge",children:u.tag}),u.semanticReference.source&&!u.semanticReference.source.startsWith("unknown")?d.jsx(d.Fragment,{children:d.jsxs("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:314",className:"vg-badge",style:{backgroundColor:"#fdf2f8",color:"#db2777",borderColor:"#fbcfe8"},children:["📄 ",Z(u.semanticReference.source.split(":")[0]||"unknown")]})}):d.jsxs("span",{"data-source-path":"/src/components/ViewGateOverlay.tsx:319",className:"vg-badge",style:{backgroundColor:"#f0f9ff",color:"#0369a1",borderColor:"#bae6fd",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["🆔 ",u.semanticReference.signature]})]}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:324",style:{marginTop:"8px",fontSize:"11px",color:"#94a3b8"},children:["🎯 ",u.semanticReference.selector]})]}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:330",style:{backgroundColor:"#f8fafc",borderRadius:"8px",border:"1px solid #e2e8f0",marginBottom:"20px",overflow:"hidden",display:"flex",flexDirection:"column"},children:[d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:339",style:{padding:"8px 12px",fontSize:"10px",color:"#94a3b8",textTransform:"uppercase",fontWeight:700,borderBottom:"1px solid #f1f5f9"},children:r.preview}),d.jsx("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:342",style:{padding:"12px",display:"flex",justifyContent:"center",alignItems:"center",minHeight:"60px",maxHeight:"150px",overflow:"hidden",backgroundColor:"white"},children:u.visualPreview?d.jsx("img",{src:u.visualPreview,alt:"Element Preview",style:{maxWidth:"100%",maxHeight:"120px",objectFit:"contain",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",borderRadius:"4px"}}):d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:365",style:{fontSize:"13px",color:"#64748b",fontStyle:"italic"},children:['"',u.previewText,'"']})})]}),d.jsx("textarea",{className:"vg-textarea",value:h,onChange:v=>b(v.target.value),rows:4,placeholder:r.placeholder,autoFocus:!0}),d.jsxs("div",{"data-source-path":"/src/components/ViewGateOverlay.tsx:381",style:{display:"flex",justifyContent:"flex-end",gap:"12px",marginTop:"24px"},children:[d.jsx("button",{onClick:()=>m(null),className:"vg-button-ghost",children:r.cancel}),d.jsx("button",{onClick:q,className:"vg-button-primary",disabled:T||!h.trim(),style:{opacity:T||!h.trim()?.6:1},children:T?r.submitting:r.send})]})]})})]})};function X(e,t,r){if(!t.endsWith(".tsx")&&!t.endsWith(".jsx")||t.includes("node_modules"))return e;const n=c=>c.replace(/\\/g,"/"),a=n(t).replace(n(r),"");return e.split(`
9
9
  `).map((c,l)=>{const u=l+1;return c.replace(/(^|[^a-zA-Z0-9])<([a-zA-Z][a-zA-Z0-9\.]*)(?=[ \t\n\/\>])/g,(m,h,b)=>m.includes("data-source-path")||b==="Fragment"||b==="React.Fragment"?m:`${h}<${b} data-source-path="${a}:${u}"`)}).join(`
10
10
  `)}function jt(){return{name:"vite-plugin-viewgate",enforce:"pre",transform(e,t){return{code:X(e,t,process.cwd()),map:null}}}}function Ot(e){const t=this.resourcePath;return t?(process.env.NODE_ENV,X(e,t,process.cwd())):e}R.ViewGate=Ve,R.ViewGateOverlay=Se,R.transformSourcePaths=X,R.useViewGate=oe,R.viewgateNextLoader=Ot,R.viewgatePlugin=jt,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viewgate-wrapper",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "type": "module",
5
5
  "main": "./dist/viewgate-wrapper.umd.cjs",
6
6
  "module": "./dist/viewgate-wrapper.js",