rune-grab 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react.cjs +61 -32
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +61 -32
- package/dist/react.js.map +1 -1
- package/dist/rune-grab.cjs +61 -32
- package/dist/rune-grab.cjs.map +1 -1
- package/dist/rune-grab.iife.global.js +21 -21
- package/dist/rune-grab.iife.global.js.map +1 -1
- package/dist/rune-grab.js +61 -32
- package/dist/rune-grab.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var RuneGrab=(()=>{var
|
|
1
|
+
"use strict";var RuneGrab=(()=>{var Z=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var Pt=Object.prototype.hasOwnProperty;var Rt=(t,n)=>{for(var o in n)Z(t,o,{get:n[o],enumerable:!0})},At=(t,n,o,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Lt(n))!Pt.call(t,r)&&r!==o&&Z(t,r,{get:()=>n[r],enumerable:!(i=Tt(n,r))||i.enumerable});return t};var Ft=t=>At(Z({},"__esModule",{value:!0}),t);var ln={};Rt(ln,{activate:()=>K,deactivate:()=>_,getTarget:()=>kt,init:()=>Me,isActive:()=>Ct,setTarget:()=>St,toggle:()=>Ee});var _e=null;var x=null;async function $t(){if(x){let t=x.getVideoTracks();if(t.length>0&&t[0].readyState==="live")return x;x=null}try{return x=await navigator.mediaDevices.getDisplayMedia({video:!0,preferCurrentTab:!0,selfBrowserSurface:"include"}),x.getVideoTracks()[0].addEventListener("ended",()=>{x=null}),x}catch{return null}}async function It(t,n,o,i){let r=document.createElement("video");r.srcObject=t,r.muted=!0,r.playsInline=!0,await new Promise((E,we)=>{r.onloadedmetadata=()=>{r.play().then(E).catch(we)},r.onerror=we}),"requestVideoFrameCallback"in r?await new Promise(E=>r.requestVideoFrameCallback(()=>E())):await new Promise(E=>setTimeout(E,200));let s=r.videoWidth,a=r.videoHeight,c=s/window.innerWidth,d=a/window.innerHeight,l=n.left*c,u=n.top*d,p=n.width*c,g=n.height*d,m=window.devicePixelRatio||1,f=document.createElement("canvas");return f.width=n.width*m,f.height=n.height*m,f.getContext("2d").drawImage(r,l,u,p,g,0,0,f.width,f.height),r.pause(),r.srcObject=null,f.toDataURL(o,i)}async function Ce(t,n="image/png",o=.92){if(t.width===0||t.height===0)return null;try{let i=new DOMRect(t.x,t.y,t.width,t.height);if(_e)return await _e(i);let r=await $t();return r?await It(r,i,n,o):(console.warn("[rune-grab] Screenshot permission was denied or unavailable. In Electron apps, use setCaptureProvider() instead."),null)}catch(i){return console.warn("[rune-grab] Screenshot capture failed:",i),null}}function Se(){x&&(x.getTracks().forEach(t=>t.stop()),x=null)}async function H(t){try{let n={};if(n["text/plain"]=new Blob([t.text],{type:"text/plain"}),t.image){let i=await(await fetch(t.image)).blob();n["image/png"]=i}return await navigator.clipboard.write([new ClipboardItem(n)]),!0}catch{try{return await navigator.clipboard.writeText(t.text),!0}catch{return!1}}}var ke=19274;async function Bt(){try{let t=new AbortController,n=setTimeout(()=>t.abort(),500),o=await fetch(`http://127.0.0.1:${ke}/health`,{signal:t.signal});return clearTimeout(n),o.ok}catch{return!1}}async function Dt(t,n){try{return(await fetch(`http://127.0.0.1:${ke}/paste`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:t,text:n.text,image:n.image??null,label:n.label})})).ok}catch{return!1}}async function Te(t,n){return await H(n),t==="clipboard"?{success:!0,method:"clipboard"}:await Bt()&&await Dt(t,n)?{success:!0,method:"auto"}:{success:!0,method:"clipboard"}}var Nt=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),q={shortcut:Nt?"Meta+Shift+G":"Ctrl+Shift+G",target:"clipboard",accentColor:"#f5f5f5",maxStackDepth:3,onGrab:()=>{},onToggle:()=>{},showTargetPicker:!0,skipComponents:[]},e={initialized:!1,active:!1,locked:!1,promptMode:!1,menuExpanded:!1,targetsExpanded:!1,grabType:"screenshot",autoPasteEnabled:!1,helperAvailable:!1,helperChecking:!1,dockedEdge:null,selectedElement:null,mmRAF:0,config:{...q},customSkipSet:void 0,miniMenu:null,overlay:null,label:null,toolbar:null,cursorStyle:null,selectionBox:null,ssDrawing:!1,ssStartX:0,ssStartY:0,lastMouseX:0,lastMouseY:0,dragging:!1,dragPending:!1,dragStartX:0,dragStartY:0,hasDragged:!1,dragW:0,dragH:0,dragBaseX:0,dragBaseY:0,dragPointerId:-1,dragLastX:0,dragLastY:0};var J=["_","$","Styled(","motion(","chakra(","withRouter(","connect(","styled.","styled(","tw.","rc-","__"];function Ot(t){return t.includes("node_modules")}function $(t){return!(!t||Ot(t)||t.startsWith("webpack-internal:///node_modules/")||t.includes("_next/static/")||t.includes(".vite/deps/")||/^webpack[\w-]*\.js$/.test(t)||/[\\/]webpack[\w-]*\.js$/.test(t))}var Le=["display","position","overflow","width","height","minWidth","minHeight","maxWidth","maxHeight","flexDirection","flexWrap","justifyContent","alignItems","alignSelf","gap","gridTemplateColumns","gridTemplateRows","padding","margin","fontSize","fontWeight","fontFamily","lineHeight","letterSpacing","textAlign","textTransform","color","backgroundColor","backgroundImage","borderRadius","boxShadow","borderWidth","borderStyle","borderColor","opacity","transform","filter","backdropFilter","objectFit"],Pe=new Set(["block","inline","none","normal","auto","0px","transparent","rgba(0, 0, 0, 0)","start","visible","static","row","stretch","0px 0px 0px 0px","baseline"]),Re=["type","href","src","alt","role","aria-label","placeholder","name","id","data-testid"],Q=2147483640,C=2147483641,Ae=["__rune-grab-overlay__","__rune-grab-label__","__rune-grab-toolbar__","__rune-grab-menu__","__rune-grab-selection__"],ee=4,Fe=19274,$e=800,Ie=1e3,Be=1200,te="__rune-grab-autopaste__";var M="-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif",G="ui-monospace,SFMono-Regular,Menlo,monospace",v="#f5f5f5",h="#171717",b="#737373",w="#e5e5e5",S="#ebebeb",k="#171717",T="#f5f5f5",De='<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',Ne='<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',Oe='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',ne='<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>',oe='<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>',He='<svg width="10" height="10" viewBox="0 0 448 512" fill="currentColor"><path d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264.5 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L70.2 289.1c-9.3 9.8-24.8 10-34.3.4z"/></svg>',Ge='<svg width="6" height="10" viewBox="0 0 6 10" fill="currentColor"><circle cx="1" cy="1" r="1"/><circle cx="5" cy="1" r="1"/><circle cx="1" cy="5" r="1"/><circle cx="5" cy="5" r="1"/><circle cx="1" cy="9" r="1"/><circle cx="5" cy="9" r="1"/></svg>',W={clipboard:"Clipboard",claude:"Claude",cursor:"Cursor",codex:"Codex","claude-code":"CLI"},ie=["clipboard"],We=["claude","cursor","codex","claude-code"];var re,I;function Xe(t,n){re=t,I=n}function Ve(){try{return localStorage.getItem(te)==="1"}catch{return!1}}function Ht(t){try{localStorage.setItem(te,t?"1":"0")}catch{}}async function le(){try{let t=new AbortController,n=setTimeout(()=>t.abort(),$e),o=await fetch(`http://127.0.0.1:${Fe}/health`,{signal:t.signal});return clearTimeout(n),o.ok}catch{return!1}}async function Gt(t){e.autoPasteEnabled=t,Ht(t),t?(e.helperChecking=!0,y(),e.helperAvailable=await le(),e.helperChecking=!1,e.helperAvailable||(e.config.target="clipboard")):(e.helperAvailable=!1,e.config.target="clipboard"),y()}function Wt(t,n){let o=document.createElement("div");o.style.cssText="display:inline-flex;align-items:center;flex-shrink:0;";let i=document.createElement("div");i.style.cssText=`
|
|
2
2
|
width:28px;height:16px;border-radius:8px;cursor:pointer;
|
|
3
3
|
transition:background 0.15s;position:relative;
|
|
4
4
|
background:${t?k:"#d4d4d4"};
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
position:absolute;top:2px;transition:left 0.15s;
|
|
9
9
|
left:${t?"14px":"2px"};
|
|
10
10
|
box-shadow:0 1px 2px rgba(0,0,0,0.15);
|
|
11
|
-
`,i.appendChild(r),i.addEventListener("click",s=>{s.stopPropagation(),n(!t)}),o.appendChild(i),o}function
|
|
11
|
+
`,i.appendChild(r),i.addEventListener("click",s=>{s.stopPropagation(),n(!t)}),o.appendChild(i),o}function Ye(t,n,o){let i=document.createElement("button");return i.innerHTML=t,i.style.cssText=`
|
|
12
12
|
width:28px;height:28px;border:none;border-radius:6px;cursor:pointer;
|
|
13
13
|
display:flex;align-items:center;justify-content:center;padding:0;
|
|
14
14
|
transition:all 0.15s;
|
|
15
15
|
background:${n?k:"transparent"};
|
|
16
16
|
color:${n?T:b};
|
|
17
|
-
`,i.addEventListener("mouseenter",()=>{n||(i.style.background=S,i.style.color=h)}),i.addEventListener("mouseleave",()=>{n||(i.style.background="transparent",i.style.color=b)}),i.addEventListener("click",r=>{r.stopPropagation(),r.preventDefault(),o()}),i}function
|
|
17
|
+
`,i.addEventListener("mouseenter",()=>{n||(i.style.background=S,i.style.color=h)}),i.addEventListener("mouseleave",()=>{n||(i.style.background="transparent",i.style.color=b)}),i.addEventListener("click",r=>{r.stopPropagation(),r.preventDefault(),o()}),i}function Y(){let t=document.createElement("div");return t.style.cssText=`width:1px;height:16px;background:${w};margin:0 2px;flex-shrink:0;`,t}function Yt(t){if(t.button!==0||!e.menuExpanded||!e.miniMenu)return;t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),e.dragPointerId=t.pointerId,e.dragStartX=t.clientX,e.dragStartY=t.clientY,e.dragPending=!0,e.dragging=!1;let o=e.miniMenu.getBoundingClientRect();e.dragW=o.width,e.dragH=o.height,e.hasDragged||(e.miniMenu.style.top=o.top+"px",e.miniMenu.style.left=o.left+"px",e.miniMenu.style.bottom="auto",e.miniMenu.style.right="auto",e.hasDragged=!0),e.dragBaseX=parseFloat(e.miniMenu.style.left)||o.left,e.dragBaseY=parseFloat(e.miniMenu.style.top)||o.top,e.dragLastX=e.dragBaseX,e.dragLastY=e.dragBaseY}function jt(t){if(t.pointerId!==e.dragPointerId||!e.miniMenu||!e.dragPending&&!e.dragging)return;let n=t.clientX-e.dragStartX,o=t.clientY-e.dragStartY;if(e.dragPending&&!e.dragging){if(Math.abs(n)<ee&&Math.abs(o)<ee)return;e.dragging=!0,e.dragPending=!1,e.miniMenu.style.transition="none",e.miniMenu.style.willChange="left, top",document.body.style.cursor="grabbing",document.body.style.userSelect="none"}if(e.dragging){let i=document.documentElement.clientWidth,r=document.documentElement.clientHeight;e.dragLastX=Math.max(0,Math.min(e.dragBaseX+n,i-e.dragW)),e.dragLastY=Math.max(0,Math.min(e.dragBaseY+o,r-e.dragH)),e.miniMenu.style.left=e.dragLastX+"px",e.miniMenu.style.top=e.dragLastY+"px"}}function Xt(t){t.pointerId!==e.dragPointerId||!e.miniMenu||(e.dragPointerId=-1,document.body.style.cursor="",document.body.style.userSelect="",e.dragging&&(e.dragging=!1,e.miniMenu.style.willChange="",e.miniMenu.style.transition="left 0.15s ease, top 0.15s ease",e.miniMenu.style.pointerEvents="none",requestAnimationFrame(()=>{e.miniMenu&&(e.miniMenu.style.pointerEvents="")})),e.dragPending=!1)}function Vt(){if(!e.miniMenu)return;let t=e.miniMenu.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,i=document.documentElement.clientWidth,r=document.documentElement.clientHeight,s=o,a=r-o,c=n,d=i-n,l=Math.min(s,a,c,d);l===s?e.dockedEdge="top":l===a?e.dockedEdge="bottom":l===c?e.dockedEdge="left":e.dockedEdge="right",e.miniMenu.style.transition="none",y(),requestAnimationFrame(()=>{if(!e.miniMenu)return;let u=e.miniMenu.getBoundingClientRect(),p=u.width,g=u.height,m=parseFloat(e.miniMenu.style.left)||0,f=parseFloat(e.miniMenu.style.top)||0;e.dockedEdge==="top"?f=0:e.dockedEdge==="bottom"?f=r-g:e.dockedEdge==="left"?m=0:e.dockedEdge==="right"&&(m=i-p),m=Math.max(0,Math.min(m,i-p)),f=Math.max(0,Math.min(f,r-g)),e.miniMenu.style.transition="left 0.25s ease, top 0.25s ease",e.miniMenu.style.left=m+"px",e.miniMenu.style.top=f+"px",setTimeout(()=>{e.miniMenu&&(e.miniMenu.style.transition="left 0.15s ease, top 0.15s ease")},270)})}function je(){if(!e.miniMenu||!e.hasDragged)return;let t=e.miniMenu.getBoundingClientRect(),n=t.left,o=t.top,i=!1,r=document.documentElement.clientWidth,s=document.documentElement.clientHeight;n+t.width>r&&(n=r-t.width,i=!0),n<0&&(n=0,i=!0),o+t.height>s&&(o=s-t.height,i=!0),o<0&&(o=0,i=!0),i&&(e.miniMenu.style.transition="left 0.2s ease, top 0.2s ease",e.miniMenu.style.left=n+"px",e.miniMenu.style.top=o+"px",setTimeout(()=>{e.miniMenu&&(e.miniMenu.style.transition="left 0.15s ease, top 0.15s ease")},220))}function Ue(){e.miniMenu=document.createElement("div"),e.miniMenu.id="__rune-grab-menu__",e.dockedEdge="bottom",e.menuExpanded=!1,e.miniMenu.style.cssText=`
|
|
18
18
|
position:fixed;z-index:${C+2};
|
|
19
19
|
background:transparent;border:none;
|
|
20
20
|
border-radius:9px;font-family:${M};
|
|
@@ -22,46 +22,46 @@
|
|
|
22
22
|
transition:left 0.15s ease, top 0.15s ease;
|
|
23
23
|
user-select:none;
|
|
24
24
|
bottom:0px;right:16px;
|
|
25
|
-
`,document.addEventListener("mousemove",t=>{e.lastMouseX=t.clientX,e.lastMouseY=t.clientY},{passive:!0}),document.body.appendChild(e.miniMenu),y()}function y(){if(!e.miniMenu)return;let t=document.createDocumentFragment();if(!e.menuExpanded){e.miniMenu.style.padding="0",e.miniMenu.style.border="none",e.miniMenu.style.boxShadow="none",e.miniMenu.style.background="transparent";let
|
|
26
|
-
width:${
|
|
25
|
+
`,document.addEventListener("mousemove",t=>{e.lastMouseX=t.clientX,e.lastMouseY=t.clientY},{passive:!0}),document.body.appendChild(e.miniMenu),y()}function y(){if(!e.miniMenu)return;let t=document.createDocumentFragment();if(!e.menuExpanded){e.miniMenu.style.padding="0",e.miniMenu.style.border="none",e.miniMenu.style.boxShadow="none",e.miniMenu.style.background="transparent";let l,u,p,g,m=e.dockedEdge||"bottom";m==="bottom"?(l=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="${h}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"/></svg>`,u=40,p=28,g="10px 10px 0 0"):m==="top"?(l=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="${h}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>`,u=40,p=28,g="0 0 10px 10px"):m==="left"?(l=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="${h}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>`,u=28,p=40,g="0 10px 10px 0"):(l=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="${h}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>`,u=28,p=40,g="10px 0 0 10px");let f=document.createElement("button");f.title="Rune Grab",f.innerHTML=l,f.style.cssText=`
|
|
26
|
+
width:${u}px;height:${p}px;border:none;cursor:pointer;
|
|
27
27
|
display:flex;align-items:center;justify-content:center;
|
|
28
28
|
background:${v};color:${h};
|
|
29
|
-
border-radius:${
|
|
29
|
+
border-radius:${g};
|
|
30
30
|
box-shadow:0 2px 8px rgba(0,0,0,0.08),0 0 0 1px rgba(0,0,0,0.04);
|
|
31
31
|
transition:background 0.12s;padding:0;
|
|
32
|
-
`,f.addEventListener("mouseenter",()=>{f.style.background=S}),f.addEventListener("mouseleave",()=>{f.style.background=v}),f.addEventListener("click",
|
|
32
|
+
`,f.addEventListener("mouseenter",()=>{f.style.background=S}),f.addEventListener("mouseleave",()=>{f.style.background=v}),f.addEventListener("click",F=>{if(F.stopPropagation(),!e.miniMenu)return;let E=e.miniMenu.getBoundingClientRect();e.miniMenu.style.bottom="auto",e.miniMenu.style.right="auto",e.miniMenu.style.top=E.top+"px",e.miniMenu.style.left=E.left+"px",e.hasDragged=!0,e.menuExpanded=!0,e.dockedEdge=null,e.miniMenu.style.background=v,e.miniMenu.style.border=`1px solid ${w}`,e.miniMenu.style.boxShadow="0 2px 8px rgba(0,0,0,0.08),0 0 0 1px rgba(0,0,0,0.04)",e.miniMenu.style.borderRadius="9px",e.miniMenu.style.transition="none",y(),e.miniMenu.offsetWidth,je()}),t.appendChild(f),e.miniMenu.textContent="",e.miniMenu.appendChild(t);return}e.miniMenu.style.padding="3px";let n=document.createElement("div");n.style.cssText="display:flex;align-items:center;gap:2px;";let o=document.createElement("div");o.style.cssText=`
|
|
33
33
|
width:12px;height:28px;cursor:grab;display:flex;align-items:center;justify-content:center;
|
|
34
34
|
flex-shrink:0;border-radius:4px;color:${b};transition:color 0.12s;
|
|
35
|
-
`,o.innerHTML=
|
|
35
|
+
`,o.innerHTML=Ge,o.addEventListener("mouseenter",()=>{o.style.color=h}),o.addEventListener("mouseleave",()=>{e.dragging||(o.style.color=b)}),o.addEventListener("pointerdown",Yt),o.addEventListener("pointermove",jt),o.addEventListener("pointerup",Xt),o.style.touchAction="none",n.appendChild(o);let i=e.active&&e.grabType==="screenshot";n.appendChild(Ye(De,i,()=>{i?I():(e.active&&I(),e.grabType="screenshot",re()),y()}));let r=e.active&&e.grabType==="reference";n.appendChild(Ye(Ne,r,()=>{r?I():(e.active&&I(),e.grabType="reference",re()),y()})),n.appendChild(Y());let s=e.autoPasteEnabled&&e.helperAvailable?[...ie,...We]:ie,a=document.createElement("button");a.innerHTML=e.targetsExpanded?ne:oe,a.title=e.targetsExpanded?"Collapse targets":"Send to\u2026",a.style.cssText=`
|
|
36
36
|
width:24px;height:28px;border:none;background:transparent;cursor:pointer;
|
|
37
37
|
display:flex;align-items:center;justify-content:center;border-radius:6px;
|
|
38
38
|
color:${b};transition:all 0.12s;padding:0;flex-shrink:0;
|
|
39
|
-
`,
|
|
39
|
+
`,a.addEventListener("mouseenter",()=>{a.style.background=S,a.style.color=h}),a.addEventListener("mouseleave",()=>{a.style.background="transparent",a.style.color=b}),a.addEventListener("click",l=>{if(l.stopPropagation(),e.targetsExpanded=!e.targetsExpanded,c)if(e.targetsExpanded){c.style.width="auto";let u=c.scrollWidth;c.style.width="0px",c.offsetWidth,c.style.width=u+"px",c.style.opacity="1",setTimeout(()=>{c&&(c.style.width="auto"),je()},200)}else{let u=c.scrollWidth;c.style.width=u+"px",c.offsetWidth,c.style.width="0px",c.style.opacity="0"}a.innerHTML=e.targetsExpanded?ne:oe,a.title=e.targetsExpanded?"Collapse targets":"Send to\u2026"}),n.appendChild(a);let c=document.createElement("div");c.style.cssText=`
|
|
40
40
|
display:flex;align-items:center;gap:2px;
|
|
41
41
|
overflow:hidden;white-space:nowrap;
|
|
42
42
|
transition:width 0.2s ease, opacity 0.15s ease;
|
|
43
43
|
${e.targetsExpanded?"opacity:1;":"width:0px;opacity:0;"}
|
|
44
|
-
`;for(let
|
|
44
|
+
`;for(let l of s){let u=l===e.config.target,p=document.createElement("button");p.textContent=W[l],p.style.cssText=`
|
|
45
45
|
height:28px;padding:0 8px;border:none;border-radius:6px;cursor:pointer;
|
|
46
|
-
font-size:11px;font-weight:${
|
|
46
|
+
font-size:11px;font-weight:${u?"600":"500"};font-family:${M};
|
|
47
47
|
transition:all 0.12s;flex-shrink:0;
|
|
48
|
-
background:${
|
|
49
|
-
color:${
|
|
50
|
-
`,p.addEventListener("mouseenter",()=>{
|
|
51
|
-
font-size:8px;font-family:${
|
|
48
|
+
background:${u?k:"transparent"};
|
|
49
|
+
color:${u?T:b};
|
|
50
|
+
`,p.addEventListener("mouseenter",()=>{u||(p.style.background=S)}),p.addEventListener("mouseleave",()=>{u||(p.style.background="transparent")}),p.addEventListener("click",g=>{g.stopPropagation(),e.config.target=l,y()}),c.appendChild(p)}if(n.appendChild(c),e.targetsExpanded&&n.appendChild(Y()),n.appendChild(Wt(e.autoPasteEnabled,Gt)),e.autoPasteEnabled&&!e.helperAvailable&&!e.helperChecking){n.appendChild(Y());let l=document.createElement("div");l.style.cssText=`
|
|
51
|
+
font-size:8px;font-family:${G};color:${b};
|
|
52
52
|
padding:0 6px;white-space:nowrap;flex-shrink:0;line-height:1.3;
|
|
53
|
-
`,
|
|
53
|
+
`,l.innerHTML=`To enable auto pasting: add <br><span style="color:${h};font-weight:600;">rune-grab serve</span> to your dev script.`,n.appendChild(l)}if(e.helperChecking){n.appendChild(Y());let l=document.createElement("span");l.textContent="Connecting\u2026",l.style.cssText=`font-size:10px;font-family:${M};color:${b};padding:0 4px;flex-shrink:0;`,n.appendChild(l)}let d=document.createElement("button");d.innerHTML=Oe,d.style.cssText=`
|
|
54
54
|
width:28px;height:28px;border:none;background:transparent;cursor:pointer;
|
|
55
55
|
display:flex;align-items:center;justify-content:center;border-radius:6px;
|
|
56
56
|
color:${b};transition:all 0.12s;padding:0;
|
|
57
|
-
`,
|
|
58
|
-
`);for(let o of n){let i=o.match(/\((.+):(\d+):(\d+)\)/)||o.match(/at\s+(.+):(\d+):(\d+)/);if(i){let r=i[1].trim(),s=
|
|
59
|
-
`)}async function
|
|
60
|
-
position:fixed;z-index:${
|
|
57
|
+
`,d.addEventListener("mouseenter",()=>{d.style.background=S,d.style.color=h}),d.addEventListener("mouseleave",()=>{d.style.background="transparent",d.style.color=b}),d.addEventListener("click",l=>{if(l.stopPropagation(),e.menuExpanded=!1,!e.hasDragged&&e.miniMenu){let u=e.miniMenu.getBoundingClientRect();e.miniMenu.style.top=u.top+"px",e.miniMenu.style.left=u.left+"px",e.miniMenu.style.bottom="auto",e.miniMenu.style.right="auto",e.hasDragged=!0}Vt()}),n.appendChild(d),t.appendChild(n),e.miniMenu.textContent="",e.miniMenu.appendChild(t)}var ze="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ke=new Uint8Array(128);for(let t=0;t<ze.length;t++)Ke[ze.charCodeAt(t)]=t;function Ut(t){let n=[],o=0,i=0,r=0,s=0,a=0,c=0,d=t.length;for(;c<d;){let l=t.charCodeAt(c);if(l===59)o++,i=0,c++;else if(l===44)c++;else{let u=[];for(;c<d&&t.charCodeAt(c)!==59&&t.charCodeAt(c)!==44;){let p=0,g=0,m;do m=Ke[t.charCodeAt(c++)],p+=(m&31)<<g,g+=5;while(m&32);u.push(p&1?-(p>>1):p>>1)}u.length>=4?(i+=u[0],r+=u[1],s+=u[2],a+=u[3],n.push({genLine:o,genCol:i,srcIdx:r,srcLine:s,srcCol:a})):u.length>=1&&(i+=u[0])}}return n}var se=new Map,j=new Map;async function Ze(t){if(se.has(t))return se.get(t);if(j.has(t))return j.get(t);let n=(async()=>{try{let i=await fetch(t);if(!i.ok)return null;let s=(await i.text()).match(/\/\/[#@]\s*sourceMappingURL=(.+?)(?:\s|$)/);if(!s)return null;let a,c=s[1];if(c.startsWith("data:")){let u=c.split(",")[1];a=atob(u)}else{let u=new URL(c,t).href,p=await fetch(u);if(!p.ok)return null;a=await p.text()}let d=JSON.parse(a),l=Ut(d.mappings||"");return{sources:d.sources||[],mappings:l}}catch{return null}})();j.set(t,n);let o=await n;return se.set(t,o),j.delete(t),o}async function ae(t,n,o){let i=await Ze(t);if(!i||i.mappings.length===0)return null;let r=n-1,s=null;for(let c of i.mappings)if(c.genLine===r&&c.genCol<=o&&(!s||c.genCol>s.genCol)&&(s=c),c.genLine>r)break;if(!s)return null;let a=i.sources[s.srcIdx]||"";try{a=new URL(a,t).href}catch{}return{source:a,line:s.srcLine+1,column:s.srcCol}}function qe(t){Ze(t)}var B=new WeakMap;function Je(t,n,o){if(!t||t.length<=1||o?.has(t)||t[0]!==t[0].toUpperCase())return!1;for(let i of J)if(t.startsWith(i))return!1;return!(/^[A-Z][a-zA-Z]+\d+$/.test(t)||n&&!$(n))}function Qe(t,n){if(!t||t.length<=1||n?.has(t)||t[0]!==t[0].toUpperCase())return!1;for(let o of J)if(t.startsWith(o))return!1;return!/^[A-Z][a-zA-Z]+\d+$/.test(t)}function et(t){return/(?:Provider|Context|Consumer|Boundary|Wrapper|Root|Layout|Suspense)$/i.test(t)}function D(t){return t.replace(/^https?:\/\/[^/]+\//,"").replace(/^rsc:\/\/[^/]+\/[^/]+\//,"").replace(/^webpack-internal:\/\/\//,"").replace(/^\([\w-]+\)\//,"").replace(/\?.*$/,"").replace(/^\/app\//,"").replace(/^\.\//,"")}function zt(t){if(!t)return null;let n=t.split(`
|
|
58
|
+
`);for(let o of n){let i=o.match(/\((.+):(\d+):(\d+)\)/)||o.match(/at\s+(.+):(\d+):(\d+)/);if(i){let r=i[1].trim(),s=D(r);if($(s)){let a=parseInt(i[2],10),c=parseInt(i[3],10);return{fileName:s,lineNumber:a,columnNumber:c,_bundledUrl:r,_bundledLine:a,_bundledCol:c}}}}return null}function L(t){if(t._debugSource)return{fileName:t._debugSource.fileName,lineNumber:t._debugSource.lineNumber??null,columnNumber:t._debugSource.columnNumber??null};let n=t._debugStack;if(n){let o=typeof n=="string"?n:n?.stack,i=zt(o);if(i)return i._bundledUrl?.startsWith("http")?(qe(i._bundledUrl),{fileName:i.fileName,lineNumber:null,columnNumber:null,_bundledUrl:i._bundledUrl,_bundledLine:i._bundledLine,_bundledCol:i._bundledCol}):{fileName:i.fileName,lineNumber:i._bundledLine??null,columnNumber:i._bundledCol??null}}return null}function tt(t){let n=Object.keys(t);for(let o of n)if(o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$"))return t[o];return null}function X(t,n){n._bundledUrl&&n._bundledLine!=null&&B.set(t,{url:n._bundledUrl,line:n._bundledLine,col:n._bundledCol??0})}function Kt(t,n){let o=tt(t);if(!o)return null;let i=L(o),r=!0,s=null,a=o;for(;a;){let c=null,d=null;if(a.type&&typeof a.type=="function")c=a.type.displayName||a.type.name,d=r&&i?i:L(a);else if(a.type?.$$typeof){let l=a.type.render||a.type.type;c=a.type.displayName||(l&&typeof l=="function"?l.displayName||l.name:null)||null,c&&(d=r&&i?i:L(a))}if(c){let l=d?.fileName?D(d.fileName):null;if(l&&Je(c,l,n)){let u={name:c,filePath:l,line:d?.lineNumber??null,column:d?.columnNumber??null};return d&&X(u,d),u}if(!s&&Qe(c,n)&&!et(c)){let u=l&&$(l)?l:null;s={info:{name:c,filePath:u,line:u?d?.lineNumber??null:null,column:u?d?.columnNumber??null:null},src:d||null}}r=!1}a=a.return}return s?(s.src&&X(s.info,s.src),s.info):null}function Zt(t,n=6,o){let i=tt(t);if(!i)return[];let r=L(i),s=[],a=[],c=new Set,d=new Set,l=i,u=!0;for(;l&&s.length<n;){let p=null,g=null;if(l.type&&typeof l.type=="function")p=l.type.displayName||l.type.name,g=u&&r?r:L(l);else if(l.type?.$$typeof){let m=l.type.render||l.type.type;p=l.type.displayName||(m&&typeof m=="function"?m.displayName||m.name:null)||null,p&&(g=u&&r?r:L(l))}if(p){let m=g?.fileName?D(g.fileName):null;if(m&&Je(p,m,o)&&!c.has(p)){c.add(p);let f={name:p,filePath:m,line:g?.lineNumber??null};g&&X(f,g),s.push(f),u=!1}else if(a.length<n&&Qe(p,o)&&!et(p)&&!d.has(p)){d.add(p);let f=m&&$(m)?m:null,F={name:p,filePath:f,line:f?g?.lineNumber??null:null};g&&X(F,g),a.push(F)}}l=l.return}return s.length>0?s:a}function nt(t){let n=t;for(;n;){let o=n.__vueParentComponent;if(o){let r=o.type?.name||o.type?.__name;if(r){let s=o.type?.__file??null;return{name:r,filePath:s,line:null,column:null}}}let i=n.__vue__;if(i){let r=i.$options?.name||i.$options?._componentTag;if(r){let s=i.$options?.__file??null;return{name:r,filePath:s,line:null,column:null}}}n=n.parentElement}return null}function ot(t){let n=t.__svelte_meta;if(n?.loc){let i=n.loc.file,r=i?i.split("/").pop()?.replace(/\.svelte$/,""):null;if(r)return{name:r,filePath:i,line:n.loc.line??null,column:n.loc.column??null}}let o=Object.keys(t);for(let i of o)if(i.startsWith("__svelte"))return{name:"SvelteComponent",filePath:null,line:null,column:null};return null}function it(t,n){return Kt(t,n)||nt(t)||ot(t)||null}function rt(t,n=6,o){let i=Zt(t,n,o);if(i.length>0)return i;let r=nt(t)||ot(t);return r?[{name:r.name,filePath:r.filePath,line:r.line}]:[]}async function lt(t){if(t.line!=null)return;let n=B.get(t);if(!n)return;let o=await ae(n.url,n.line,n.col);o&&(t.line=o.line,t.column=o.column,o.source&&(t.filePath=D(o.source))),B.delete(t)}async function st(t){if(t.line!=null)return;let n=B.get(t);if(!n)return;let o=await ae(n.url,n.line,n.col);o&&(t.line=o.line,o.source&&(t.filePath=D(o.source))),B.delete(t)}function P(){let t=location.hostname;return t==="localhost"||t==="127.0.0.1"||t==="0.0.0.0"||t.endsWith(".local")}function qt(t){let n="";function o(i){if(i.nodeType===3){let r=(i.textContent||"").trim();r&&(n+=(n?" ":"")+r)}else if(i.nodeType===1)for(let r=0;r<i.childNodes.length;r++)o(i.childNodes[r])}return o(t),n||(n=t.getAttribute("value")||t.getAttribute("alt")||t.getAttribute("aria-label")||t.placeholder||""),n.length>80&&(n=n.slice(0,80)+"..."),n}function Jt(t){let n=t.tagName.toLowerCase();t.id&&(n+="#"+t.id);let o=Array.from(t.classList).filter(i=>!i.startsWith("__rune-grab")).slice(0,3);return o.length&&(n+="."+o.join(".")),n}function Qt(t){let n=window.getComputedStyle(t),o=[];for(let i of Le){let r=i.replace(/[A-Z]/g,a=>"-"+a.toLowerCase()),s=n.getPropertyValue(r);if(!(!s||Pe.has(s))&&!(i==="fontSize"&&s==="16px")&&!(i==="fontWeight"&&(s==="400"||s==="normal"))&&!(i==="color"&&s==="rgb(0, 0, 0)")&&!(i==="lineHeight"&&s==="normal")&&!(i==="letterSpacing"&&s==="normal")&&!(i==="textAlign"&&s==="start")&&!(i==="opacity"&&s==="1")&&!(i==="borderWidth"&&s==="0px")&&!((i==="padding"||i==="margin")&&(s==="0px"||/^0px(\s+0px)*$/.test(s)))){if(i==="fontFamily"){let a=s.split(",")[0].trim().replace(/^["']+|["']+$/g,"");if(!a||["system-ui","sans-serif","serif","monospace","-apple-system"].includes(a))continue;o.push("fontFamily: "+a);continue}o.push(i+": "+s)}}return o.join("; ")}function en(t){let n=t.tagName.toLowerCase(),o=[];for(let l of Re){let u=t.getAttribute(l);u&&o.push(`${l}="${u}"`)}let i=Array.from(t.classList).filter(l=>!/^(css-|chakra-|__rune)/.test(l));i.length&&o.push(`class="${i.join(" ")}"`);let r=`<${n}${o.length?" "+o.join(" "):""}>`,s=`</${n}>`,a="";t.childNodes.forEach(l=>{l.nodeType===3&&(a+=(l.textContent||"").trim())});let c=t.children.length,d=a;return c>0&&(d=(a?a+" ":"")+`[${c} child element${c>1?"s":""}]`),d.length>200&&(d=d.slice(0,200)+"..."),r+d+s}function V(t,n){let o=P(),i=it(t,n),r=Jt(t),s=qt(t),a=en(t),c={tag:r,visibleText:s,html:a,attrs:{role:t.getAttribute("role")||void 0,ariaLabel:t.getAttribute("aria-label")||void 0,alt:t.getAttribute("alt")||void 0,placeholder:t.placeholder||void 0,type:t.getAttribute("type")||void 0,href:t.getAttribute("href")||void 0,id:t.id||void 0,testId:t.getAttribute("data-testid")||void 0},component:i||void 0,isLocal:o};return o?c.componentStack=rt(t,3,n):c.styles=Qt(t),c}function ce(t){let n=t.visibleText?`"${t.visibleText.slice(0,30)}"`:"",o=t.tag.split(".")[0].split("#")[0],i;o==="button"||t.attrs.role==="button"?i="button":o==="a"?i="link":o==="input"?i=`${t.attrs.type||"text"} input`:o==="img"?i="image":o==="textarea"?i="textarea":/^h[1-6]$/.test(o)?i="heading":["nav","section","article","main","aside","footer","header"].includes(o)?i=o:i=`<${o}>`;let r=n?`${n} ${i}`:i;return(t.component?.name||t.component?.filePath||t.isLocal)&&(r+=" in:"),r.length>80&&(r=r.slice(0,77)+"..."),r}function at(t,n){let o=[];if(n&&o.push(n),o.push(ce(t)),t.isLocal&&t.componentStack?.length){let i=t.componentStack[0],r=` ${i.name}`;i.filePath&&(r+=` at ${i.filePath}`,i.line&&(r+=`:${i.line}`)),o.push(r)}else if(t.component){let i=` ${t.component.name}`;t.component.filePath&&(i+=` at ${t.component.filePath}`,t.component.line&&(i+=`:${t.component.line}`)),o.push(i)}else if(t.isLocal){let i=location.pathname.replace(/^\//,"")||"index.html";o.push(` ${i}`)}return o.join(`
|
|
59
|
+
`)}async function U(t){let n=[];if(t.component&&n.push(lt(t.component)),t.componentStack)for(let o of t.componentStack)n.push(st(o));await Promise.all(n)}function N(t){if(!t)return!1;let n=t;for(;n;){if(n.id&&Ae.includes(n.id))return!0;n=n.parentElement}return!1}function ct(){return`position:fixed;z-index:${C};background:${v};border:1px solid ${w};border-radius:9px;box-shadow:0 2px 8px rgba(0,0,0,0.08),0 0 0 1px rgba(0,0,0,0.04);display:none;flex-direction:row;align-items:center;top:0;left:0;font-family:${M};`}function ue(){e.overlay||(e.overlay=document.createElement("div"),e.overlay.id="__rune-grab-overlay__",e.overlay.style.cssText=`position:fixed;pointer-events:none;z-index:${Q};border:1px dashed ${v};background:transparent;border-radius:3px;transition:all 0.08s ease-out;display:none;top:0;left:0;width:0;height:0;`,e.label=document.createElement("div"),e.label.id="__rune-grab-label__",e.label.style.cssText=`position:fixed;pointer-events:none;z-index:${C};background:${v};border:1px solid ${w};color:${h};font-size:10px;font-family:${G};padding:2px 6px;border-radius:5px;white-space:nowrap;display:none;top:0;left:0;line-height:1.4;font-weight:500;letter-spacing:0.01em;box-shadow:0 2px 8px rgba(0,0,0,0.08);`,e.toolbar=document.createElement("div"),e.toolbar.id="__rune-grab-toolbar__",e.toolbar.style.cssText=ct()+"padding:4px;gap:2px;",e.cursorStyle=document.createElement("style"),e.cursorStyle.id="__rune-grab-cursor__",e.cursorStyle.textContent=".__rune-grab-active__ *{cursor:crosshair !important;}.__rune-grab-active__{cursor:crosshair !important;}",document.head.appendChild(e.cursorStyle),document.body.appendChild(e.overlay),document.body.appendChild(e.label),document.body.appendChild(e.toolbar))}function ut(){e.overlay?.remove(),e.label?.remove(),e.toolbar?.remove(),e.cursorStyle?.remove(),e.overlay=null,e.label=null,e.toolbar=null,e.cursorStyle=null}function O(){e.selectionBox||(e.selectionBox=document.createElement("div"),e.selectionBox.id="__rune-grab-selection__",e.selectionBox.style.cssText=`
|
|
60
|
+
position:fixed;z-index:${Q};
|
|
61
61
|
border:1px dashed ${v};
|
|
62
62
|
background:transparent;
|
|
63
63
|
border-radius:2px;display:none;
|
|
64
64
|
pointer-events:none;
|
|
65
65
|
top:0;left:0;width:0;height:0;
|
|
66
|
-
`,document.body.appendChild(e.selectionBox))}function
|
|
66
|
+
`,document.body.appendChild(e.selectionBox))}function dt(){e.selectionBox?.remove(),e.selectionBox=null}function de(t){if(!e.overlay||!e.label)return;let n=t.getBoundingClientRect();e.overlay.style.top=n.top+"px",e.overlay.style.left=n.left+"px",e.overlay.style.width=n.width+"px",e.overlay.style.height=n.height+"px",e.overlay.style.display="block";let o=V(t,e.customSkipSet);function i(){if(P()&&o.component){let s=o.component.name;if(o.component.filePath){let a=o.component.filePath.split("/");s+=` \xB7 ${a[a.length-1]}`,o.component.line&&(s+=`:${o.component.line}`)}return s}return o.component?`<${o.component.name}>`:`<${o.tag}>`}e.label.textContent=i(),P()&&o.component&&!o.component.line&&U(o).then(()=>{e.label&&e.selectedElement===t&&(e.label.textContent=i())}),e.label.style.display="block";let r=n.top-22;r<4&&(r=n.bottom+4),e.label.style.top=r+"px",e.label.style.left=n.left+"px"}function R(){e.overlay&&(e.overlay.style.display="none"),e.label&&(e.label.style.display="none")}function A(){e.toolbar&&(e.toolbar.style.display="none")}function z(t){if(!document.body)return;let n=document.createElement("div");n.textContent=t;let o=e.lastMouseX+12,i=e.lastMouseY-30;o+150>window.innerWidth&&(o=e.lastMouseX-150),i<4&&(i=e.lastMouseY+16),n.style.cssText=`position:fixed;z-index:${C+3};top:${i}px;left:${o}px;background:${v};color:${h};font-size:11px;font-family:${M};padding:5px 12px;border-radius:7px;font-weight:500;pointer-events:none;opacity:1;transition:opacity 0.3s ease-out;box-shadow:0 2px 8px rgba(0,0,0,0.08),0 0 0 1px rgba(0,0,0,0.04);border:1px solid ${w};`,document.body.appendChild(n),setTimeout(()=>n.style.opacity="0",Ie),setTimeout(()=>n.remove(),Be)}function pt(t){if(!e.toolbar)return;e.promptMode=!0;let n=e.toolbar.style.top,o=e.toolbar.style.left;e.toolbar.innerHTML="",e.toolbar.style.cssText=ct()+"padding:3px 4px 3px 10px;gap:6px;",e.toolbar.style.top=n,e.toolbar.style.left=o;let i=document.createElement("input");if(i.type="text",i.placeholder="Comment (Enter \u21B5 send, Esc cancel)",i.className="__rune-grab-prompt__",i.style.cssText=`background:transparent;border:none;outline:none;color:${h};font-size:12px;font-family:${M};width:230px;padding:2px 0;caret-color:${h};`,!document.getElementById("__rune-grab-placeholder-style__")){let l=document.createElement("style");l.id="__rune-grab-placeholder-style__",l.textContent=`.__rune-grab-prompt__::placeholder{color:${b} !important;opacity:1 !important;}`,document.head.appendChild(l)}let r=document.createElement("button");r.innerHTML=He,r.style.cssText=`width:22px;height:22px;border:1px solid ${w};background:${k};color:${T};border-radius:50%;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:all 0.15s;`;function s(){let l=i.value.trim();l&&!l.endsWith(":")&&(l+=":"),e.promptMode=!1,t(l)}function a(){e.promptMode=!1,e.locked=!1,A(),R(),e.selectedElement=null}r.addEventListener("click",l=>{l.stopPropagation(),l.preventDefault(),s()}),i.addEventListener("keydown",l=>{l.stopPropagation(),l.key==="Enter"&&(l.preventDefault(),s()),l.key==="Escape"&&(l.preventDefault(),a())}),i.addEventListener("click",l=>l.stopPropagation()),e.toolbar.appendChild(i),e.toolbar.appendChild(r);let c=270;parseFloat(e.toolbar.style.left)+c>window.innerWidth-8&&(e.toolbar.style.left=Math.max(8,window.innerWidth-c-8)+"px"),e.toolbar.style.display="flex",setTimeout(()=>i.focus(),0)}function tn(t){let n=t.split("+");return{key:n[n.length-1].toLowerCase(),meta:n.some(o=>/^(meta|cmd)$/i.test(o)),ctrl:n.some(o=>/^(ctrl|control)$/i.test(o)),shift:n.some(o=>/^shift$/i.test(o)),alt:n.some(o=>/^(alt|option)$/i.test(o))}}var mt,ft;function gt(t,n){mt=t,ft=n}function pe(t){let n=tn(e.config.shortcut);t.key.toLowerCase()===n.key&&t.metaKey===n.meta&&t.ctrlKey===n.ctrl&&t.shiftKey===n.shift&&t.altKey===n.alt&&(t.preventDefault(),mt(),ft())}var ht,bt,yt;function xt(t,n,o){ht=t,bt=n,yt=o}async function nn(t,n){let o=V(t,e.customSkipSet);await U(o);let i=ce(o),r=at(o,n);await ht({type:"reference",label:i,text:r,prompt:n,meta:o}),z(`Sent to ${W[e.config.target]}`),e.locked=!1,A(),R(),e.selectedElement=null}function on(t){if(!e.toolbar)return;let n=t.getBoundingClientRect(),o=270,i=34,r=n.bottom+6,s=n.left+n.width/2-o/2;r+i>window.innerHeight-8&&(r=n.top-i-6),s<8&&(s=8),s+o>window.innerWidth-8&&(s=window.innerWidth-o-8),e.toolbar.style.top=r+"px",e.toolbar.style.left=s+"px",pt(async a=>{await nn(t,a)})}function me(t){e.locked||e.mmRAF||(e.mmRAF=requestAnimationFrame(()=>{e.mmRAF=0;let n=document.elementFromPoint(t.clientX,t.clientY);if(!n||N(n)||n===document.body||n===document.documentElement){R(),e.selectedElement=null;return}e.selectedElement=n,de(n)}))}function fe(t){if(!N(t.target)&&!e.promptMode){if(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e.locked){e.locked=!1,A();return}e.selectedElement&&(e.locked=!0,de(e.selectedElement),on(e.selectedElement))}}function ge(t){e.promptMode||t.key==="Escape"&&(e.locked?(e.locked=!1,A(),e.selectedElement=null,R()):(bt(),yt()))}function he(){e.promptMode||e.locked&&(e.locked=!1,A(),e.selectedElement=null,R())}var vt,Et,Mt;function wt(t,n,o){vt=t,Et=n,Mt=o}function be(t){t.button===0&&(N(t.target)||(t.preventDefault(),t.stopPropagation(),e.ssDrawing=!0,e.ssStartX=t.clientX,e.ssStartY=t.clientY,e.selectionBox&&(e.selectionBox.style.left=e.ssStartX+"px",e.selectionBox.style.top=e.ssStartY+"px",e.selectionBox.style.width="0px",e.selectionBox.style.height="0px",e.selectionBox.style.display="block")))}function ye(t){if(!e.ssDrawing||!e.selectionBox)return;t.preventDefault();let n=Math.min(t.clientX,e.ssStartX),o=Math.min(t.clientY,e.ssStartY),i=Math.abs(t.clientX-e.ssStartX),r=Math.abs(t.clientY-e.ssStartY);e.selectionBox.style.left=n+"px",e.selectionBox.style.top=o+"px",e.selectionBox.style.width=i+"px",e.selectionBox.style.height=r+"px"}async function xe(t){if(!e.ssDrawing)return;e.ssDrawing=!1,t.preventDefault(),t.stopPropagation();let n=Math.min(t.clientX,e.ssStartX),o=Math.min(t.clientY,e.ssStartY),i=Math.abs(t.clientX-e.ssStartX),r=Math.abs(t.clientY-e.ssStartY),s=e.selectionBox;if(s&&s.remove(),e.selectionBox=null,e.miniMenu&&(e.miniMenu.style.display="none"),e.cursorStyle&&(e.cursorStyle.disabled=!0),await new Promise(a=>requestAnimationFrame(()=>requestAnimationFrame(a))),i>=10&&r>=10){let a=await Ce({x:n,y:o,width:i,height:r});if(e.miniMenu&&(e.miniMenu.style.display=""),e.cursorStyle&&(e.cursorStyle.disabled=!1),O(),a){let c={type:"screenshot",label:`Region ${i}\xD7${r}`,text:`Screenshot region: ${i}\xD7${r} at (${Math.round(n)}, ${Math.round(o)})`,prompt:"",image:a,meta:{tag:"region",visibleText:"",html:"",attrs:{},isLocal:P()}};await vt(c),z("Screenshot captured")}}else e.miniMenu&&(e.miniMenu.style.display=""),e.cursorStyle&&(e.cursorStyle.disabled=!1),O()}function ve(t){t.key==="Escape"&&(e.ssDrawing?(e.ssDrawing=!1,e.selectionBox&&(e.selectionBox.style.display="none")):(Et(),Mt()))}async function _t(t){e.config.onGrab(t),window.dispatchEvent(new CustomEvent("rune:grab",{detail:t})),e.config.target==="clipboard"?await H(t):await Te(e.config.target,t)}function K(){e.active||!document.body||!document.head||(e.active=!0,document.documentElement.classList.add("__rune-grab-active__"),e.grabType==="screenshot"?(ue(),O(),document.addEventListener("mousedown",be,!0),document.addEventListener("mousemove",ye,!0),document.addEventListener("mouseup",xe,!0),document.addEventListener("keydown",ve,!0)):(ue(),document.addEventListener("mousemove",me,!0),document.addEventListener("click",fe,!0),document.addEventListener("keydown",ge,!0),document.addEventListener("scroll",he,!0)),e.config.onToggle(!0))}function _(){e.active&&(e.active=!1,e.locked=!1,e.promptMode=!1,e.ssDrawing=!1,e.selectedElement=null,e.mmRAF&&(cancelAnimationFrame(e.mmRAF),e.mmRAF=0),document.removeEventListener("mousedown",be,!0),document.removeEventListener("mousemove",ye,!0),document.removeEventListener("mouseup",xe,!0),document.removeEventListener("keydown",ve,!0),document.removeEventListener("mousemove",me,!0),document.removeEventListener("click",fe,!0),document.removeEventListener("keydown",ge,!0),document.removeEventListener("scroll",he,!0),ut(),dt(),document.documentElement.classList.remove("__rune-grab-active__"),e.config.onToggle(!1))}function Ee(){e.active?_():K()}function Ct(){return e.active}function St(t){e.config.target=t,e.menuExpanded&&y()}function kt(){return e.config.target}function Me(t={}){if(e.initialized)return()=>{};e.config={...q,...t},e.initialized=!0,t.skipComponents?.length&&(e.customSkipSet=new Set(t.skipComponents)),Xe(K,_),gt(Ee,y),xt(_t,_,y),wt(_t,_,y),Ve()&&(e.autoPasteEnabled=!0,le().then(i=>{e.helperAvailable=i,i||(e.config.target="clipboard"),e.menuExpanded&&y()}));let o=()=>{Ue(),document.addEventListener("keydown",pe,!0)};return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o,{once:!0}):o(),()=>{_(),Se(),e.miniMenu?.remove(),document.removeEventListener("keydown",pe,!0),e.initialized=!1,e.hasDragged=!1}}var rn=typeof window<"u"&&window.__RUNE_GRAB_CONFIG__||{};Me(rn);return Ft(ln);})();
|
|
67
67
|
//# sourceMappingURL=rune-grab.iife.global.js.map
|