@omnipad/core 0.5.0 → 0.6.0
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/chunk-42WBUPM3.cjs +1 -0
- package/dist/chunk-45F3BQT7.cjs +1 -0
- package/dist/chunk-52YF3VHH.cjs +1 -0
- package/dist/chunk-6XY2ZHZ3.mjs +1 -0
- package/dist/chunk-AK3RL7NL.mjs +1 -0
- package/dist/chunk-EYKCVOUA.mjs +1 -0
- package/dist/chunk-HCOFKHVV.cjs +1 -0
- package/dist/chunk-HQNUZXP5.mjs +1 -0
- package/dist/chunk-J5SVBM6K.mjs +1 -0
- package/dist/chunk-NB4FTDOP.cjs +1 -0
- package/dist/chunk-OVV5DKL6.cjs +1 -0
- package/dist/chunk-YAS6LFBF.mjs +1 -0
- package/dist/dom/index.cjs +1 -1
- package/dist/dom/index.d.cts +105 -36
- package/dist/dom/index.d.ts +105 -36
- package/dist/dom/index.mjs +1 -1
- package/dist/guest/index.cjs +1 -0
- package/dist/guest/index.d.cts +21 -0
- package/dist/guest/index.d.ts +21 -0
- package/dist/guest/index.mjs +1 -0
- package/dist/{index-DVegtw8s.d.cts → index-Dd0aHJaA.d.cts} +739 -27
- package/dist/{index-DVegtw8s.d.ts → index-Dd0aHJaA.d.ts} +739 -27
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +282 -5
- package/dist/index.d.ts +282 -5
- package/dist/index.mjs +1 -1
- package/dist/sticky-CCj0ECTY.d.cts +285 -0
- package/dist/sticky-d_z_GU83.d.ts +285 -0
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +122 -69
- package/dist/utils/index.d.ts +122 -69
- package/dist/utils/index.mjs +1 -1
- package/package.json +9 -1
- package/dist/chunk-FSJTQU4W.cjs +0 -1
- package/dist/chunk-MKVX5ALC.mjs +0 -1
- package/dist/chunk-PACTGVBB.mjs +0 -1
- package/dist/chunk-U52W5J3K.cjs +0 -1
- package/dist/chunk-V7AHGFPB.mjs +0 -1
- package/dist/chunk-VHF3K5X6.cjs +0 -1
- package/dist/chunk-ZHPNS73J.cjs +0 -1
- package/dist/chunk-ZM2LX5IW.mjs +0 -1
- package/dist/sticky-4yk5DLzG.d.cts +0 -59
- package/dist/sticky-CLBq1EPa.d.ts +0 -59
- package/dist/traits-D6ePqSA6.d.cts +0 -152
- package/dist/traits-dAndzyWS.d.ts +0 -152
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var u=(e,t,n="omnipad-prevent")=>{let r=document.elementsFromPoint(e,t).find(o=>!o.classList.contains(n));if(!r)return null;for(;r&&r.shadowRoot;){let i=r.shadowRoot.elementsFromPoint(e,t).find(c=>!c.classList.contains(n));if(!i||i===r)break;r=i;}return r},d=()=>{let e=document.activeElement;for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e},a=e=>{if(!e)return null;if(e.startsWith("#")){let t=e.slice(1),n=document.getElementById(t);if(n)return n}try{return document.querySelector(e)}catch{return null}};var E=(e,t)=>{m(e,t);},m=(e,t)=>{let n=new KeyboardEvent(e,{...t,which:t.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(n);},v=(e,t,n,s)=>{let r=u(t,n);r&&l(r,e,t,n,s);},l=(e,t,n,s,r)=>{if(!Number.isFinite(n)||!Number.isFinite(s))return;let o={bubbles:true,cancelable:true,composed:true,clientX:n,clientY:s,view:window,...r};if(t.startsWith("pointer")){e.dispatchEvent(new PointerEvent(t,{isPrimary:true,pointerId:9999,pointerType:"mouse",...o}));let i=t.replace("pointer","mouse");e.dispatchEvent(new MouseEvent(i,o));}else e.dispatchEvent(new MouseEvent(t,o));};exports.a=u;exports.b=d;exports.c=a;exports.d=E;exports.e=m;exports.f=v;exports.g=l;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var s={rect:["left","right","top","bottom","width","height"],pointer:["pointerId","clientX","clientY","button"]};function o(t,e){let r={};for(let n=0;n<e.length;n++){let c=e[n];r[c]=t[c];}return r}var i=t=>o(t,s.rect),a=t=>o(t,s.pointer),l=(t,e)=>o(t,e);exports.a=i;exports.b=a;exports.c=l;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var S={Backspace:{type:"keyboard",key:"Backspace",code:"Backspace",keyCode:8},Tab:{type:"keyboard",key:"Tab",code:"Tab",keyCode:9},Enter:{type:"keyboard",key:"Enter",code:"Enter",keyCode:13},ShiftLeft:{type:"keyboard",key:"Shift",code:"ShiftLeft",keyCode:16},ControlLeft:{type:"keyboard",key:"Control",code:"ControlLeft",keyCode:17},AltLeft:{type:"keyboard",key:"Alt",code:"AltLeft",keyCode:18},Pause:{type:"keyboard",key:"Pause",code:"Pause",keyCode:19},CapsLock:{type:"keyboard",key:"CapsLock",code:"CapsLock",keyCode:20},Escape:{type:"keyboard",key:"Escape",code:"Escape",keyCode:27},Space:{type:"keyboard",key:" ",code:"Space",keyCode:32},PageUp:{type:"keyboard",key:"PageUp",code:"PageUp",keyCode:33},PageDown:{type:"keyboard",key:"PageDown",code:"PageDown",keyCode:34},End:{type:"keyboard",key:"End",code:"End",keyCode:35},Home:{type:"keyboard",key:"Home",code:"Home",keyCode:36},ArrowLeft:{type:"keyboard",key:"ArrowLeft",code:"ArrowLeft",keyCode:37},ArrowUp:{type:"keyboard",key:"ArrowUp",code:"ArrowUp",keyCode:38},ArrowRight:{type:"keyboard",key:"ArrowRight",code:"ArrowRight",keyCode:39},ArrowDown:{type:"keyboard",key:"ArrowDown",code:"ArrowDown",keyCode:40},PrintScreen:{type:"keyboard",key:"PrintScreen",code:"PrintScreen",keyCode:44},Insert:{type:"keyboard",key:"Insert",code:"Insert",keyCode:45},Delete:{type:"keyboard",key:"Delete",code:"Delete",keyCode:46},Digit0:{type:"keyboard",key:"0",code:"Digit0",keyCode:48},Digit1:{type:"keyboard",key:"1",code:"Digit1",keyCode:49},Digit2:{type:"keyboard",key:"2",code:"Digit2",keyCode:50},Digit3:{type:"keyboard",key:"3",code:"Digit3",keyCode:51},Digit4:{type:"keyboard",key:"4",code:"Digit4",keyCode:52},Digit5:{type:"keyboard",key:"5",code:"Digit5",keyCode:53},Digit6:{type:"keyboard",key:"6",code:"Digit6",keyCode:54},Digit7:{type:"keyboard",key:"7",code:"Digit7",keyCode:55},Digit8:{type:"keyboard",key:"8",code:"Digit8",keyCode:56},Digit9:{type:"keyboard",key:"9",code:"Digit9",keyCode:57},KeyA:{type:"keyboard",key:"a",code:"KeyA",keyCode:65},KeyB:{type:"keyboard",key:"b",code:"KeyB",keyCode:66},KeyC:{type:"keyboard",key:"c",code:"KeyC",keyCode:67},KeyD:{type:"keyboard",key:"d",code:"KeyD",keyCode:68},KeyE:{type:"keyboard",key:"e",code:"KeyE",keyCode:69},KeyF:{type:"keyboard",key:"f",code:"KeyF",keyCode:70},KeyG:{type:"keyboard",key:"g",code:"KeyG",keyCode:71},KeyH:{type:"keyboard",key:"h",code:"KeyH",keyCode:72},KeyI:{type:"keyboard",key:"i",code:"KeyI",keyCode:73},KeyJ:{type:"keyboard",key:"j",code:"KeyJ",keyCode:74},KeyK:{type:"keyboard",key:"k",code:"KeyK",keyCode:75},KeyL:{type:"keyboard",key:"l",code:"KeyL",keyCode:76},KeyM:{type:"keyboard",key:"m",code:"KeyM",keyCode:77},KeyN:{type:"keyboard",key:"n",code:"KeyN",keyCode:78},KeyO:{type:"keyboard",key:"o",code:"KeyO",keyCode:79},KeyP:{type:"keyboard",key:"p",code:"KeyP",keyCode:80},KeyQ:{type:"keyboard",key:"q",code:"KeyQ",keyCode:81},KeyR:{type:"keyboard",key:"r",code:"KeyR",keyCode:82},KeyS:{type:"keyboard",key:"s",code:"KeyS",keyCode:83},KeyT:{type:"keyboard",key:"t",code:"KeyT",keyCode:84},KeyU:{type:"keyboard",key:"u",code:"KeyU",keyCode:85},KeyV:{type:"keyboard",key:"v",code:"KeyV",keyCode:86},KeyW:{type:"keyboard",key:"w",code:"KeyW",keyCode:87},KeyX:{type:"keyboard",key:"x",code:"KeyX",keyCode:88},KeyY:{type:"keyboard",key:"y",code:"KeyY",keyCode:89},KeyZ:{type:"keyboard",key:"z",code:"KeyZ",keyCode:90},MetaLeft:{type:"keyboard",key:"Meta",code:"MetaLeft",keyCode:91},ContextMenu:{type:"keyboard",key:"ContextMenu",code:"ContextMenu",keyCode:93},Numpad0:{type:"keyboard",key:"0",code:"Numpad0",keyCode:96},Numpad1:{type:"keyboard",key:"1",code:"Numpad1",keyCode:97},Numpad2:{type:"keyboard",key:"2",code:"Numpad2",keyCode:98},Numpad3:{type:"keyboard",key:"3",code:"Numpad3",keyCode:99},Numpad4:{type:"keyboard",key:"4",code:"Numpad4",keyCode:100},Numpad5:{type:"keyboard",key:"5",code:"Numpad5",keyCode:101},Numpad6:{type:"keyboard",key:"6",code:"Numpad6",keyCode:102},Numpad7:{type:"keyboard",key:"7",code:"Numpad7",keyCode:103},Numpad8:{type:"keyboard",key:"8",code:"Numpad8",keyCode:104},Numpad9:{type:"keyboard",key:"9",code:"Numpad9",keyCode:105},NumpadMultiply:{type:"keyboard",key:"*",code:"NumpadMultiply",keyCode:106},NumpadAdd:{type:"keyboard",key:"+",code:"NumpadAdd",keyCode:107},NumpadSubtract:{type:"keyboard",key:"-",code:"NumpadSubtract",keyCode:109},NumpadDecimal:{type:"keyboard",key:".",code:"NumpadDecimal",keyCode:110},NumpadDivide:{type:"keyboard",key:"/",code:"NumpadDivide",keyCode:111},F1:{type:"keyboard",key:"F1",code:"F1",keyCode:112},F2:{type:"keyboard",key:"F2",code:"F2",keyCode:113},F3:{type:"keyboard",key:"F3",code:"F3",keyCode:114},F4:{type:"keyboard",key:"F4",code:"F4",keyCode:115},F5:{type:"keyboard",key:"F5",code:"F5",keyCode:116},F6:{type:"keyboard",key:"F6",code:"F6",keyCode:117},F7:{type:"keyboard",key:"F7",code:"F7",keyCode:118},F8:{type:"keyboard",key:"F8",code:"F8",keyCode:119},F9:{type:"keyboard",key:"F9",code:"F9",keyCode:120},F10:{type:"keyboard",key:"F10",code:"F10",keyCode:121},F11:{type:"keyboard",key:"F11",code:"F11",keyCode:122},F12:{type:"keyboard",key:"F12",code:"F12",keyCode:123},NumLock:{type:"keyboard",key:"NumLock",code:"NumLock",keyCode:144},ScrollLock:{type:"keyboard",key:"ScrollLock",code:"ScrollLock",keyCode:145},Semicolon:{type:"keyboard",key:";",code:"Semicolon",keyCode:186},Equal:{type:"keyboard",key:"=",code:"Equal",keyCode:187},Comma:{type:"keyboard",key:",",code:"Comma",keyCode:188},Minus:{type:"keyboard",key:"-",code:"Minus",keyCode:189},Period:{type:"keyboard",key:".",code:"Period",keyCode:190},Slash:{type:"keyboard",key:"/",code:"Slash",keyCode:191},Backquote:{type:"keyboard",key:"`",code:"Backquote",keyCode:192},BracketLeft:{type:"keyboard",key:"[",code:"BracketLeft",keyCode:219},Backslash:{type:"keyboard",key:"\\",code:"Backslash",keyCode:220},BracketRight:{type:"keyboard",key:"]",code:"BracketRight",keyCode:221},Quote:{type:"keyboard",key:"'",code:"Quote",keyCode:222},Mouse:{type:"mouse",button:0},MouseLeft:{type:"mouse",button:0},MouseMiddle:{type:"mouse",button:1},MouseRight:{type:"mouse",button:2}},L=S;var V={INPUT_ZONE:"input-zone",TARGET_ZONE:"target-zone",BUTTON:"button",KEYBOARD_BUTTON:"keyboard-button",MOUSE_BUTTON:"mouse-button",JOYSTICK:"joystick",D_PAD:"d-pad",TRACKPAD:"trackpad",VIRTUAL_CURSOR:"virtual-cursor",ROOT_LAYER:"root-layer"},_={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},h=["px","%","vh","vw","vmin","vmax","rem","em"],I={PARENT_ID_KEY:"omnipad-parent-id-link"};function j(e){let t=null,o=true;return {get:()=>((o||!t)&&(t=e(),o=false),t),markDirty:()=>{o=true;}}}var W=(e="omnipad")=>{let t=Date.now().toString(36),o=new Uint8Array(4),r=globalThis.crypto;if(r?.getRandomValues)r.getRandomValues(o);else for(let n=0;n<o.length;n++)o[n]=Math.floor(Math.random()*256);let y=Array.from(o).map(n=>n.toString(36).padStart(2,"0")).join("").substring(0,4);return `${e}-${t}-${y}`};function Z(e){return e.startsWith("$")}var P=/^[a-zA-Z0-9\s._#$\-*>+~]+$/,N=Object.freeze(["__proto__","constructor","prototype"]),K=Object.freeze(["script","javascript:","onerror","onload","eval","expression"]);function C(e,t=""){if(!e)return t;let o=e.trim();return o.length>256?t:P.test(o)?K.some(r=>o.toLowerCase().includes(r))?t:o:(undefined?.DEV&&console.warn(`[OmniPad-Validation] Unsafe DOM string blocked: "${o}"`),t)}var D=/^[a-zA-Z0-9\-_]+$/;function G(e){return e?e.split(/\s+/).filter(t=>D.test(t)).join(" "):""}function X(e){let t=new Set([...N]),o=r=>{if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(d=>o(d));let y={},n=Object.keys(r);for(let d=0;d<n.length;d++){let i=n[d];if(t.has(i)){console.warn(`[OmniPad-Security] Stripped dangerous key: "${i}"`);continue}let p=r[i];y[i]=p!==null&&typeof p=="object"?o(p):p;}return y};return o(e)}var Q=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),ee=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),A=(e,t)=>({x:e.x*t,y:e.y*t}),m=(e,t,o)=>Math.max(t,Math.min(o,e)),E=(e,t,o)=>e+(t-e)*o,x=(e,t=2)=>{let o=Math.pow(10,t);return Math.round(e*o)/o},te=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),oe=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),re=e=>e*180/Math.PI,ye=e=>e*Math.PI/180,ne=(e,t,o)=>{let r=t.x-e.x,y=t.y-e.y;if(Math.hypot(r,y)<=o)return t;let d=Math.atan2(y,r);return {x:e.x+Math.cos(d)*o,y:e.y+Math.sin(d)*o}},de=e=>{let t=Math.PI/4;return Math.round(e/t)*t},ae=e=>{let t=Math.PI/2;return Math.round(e/t)*t},ce=(e,t)=>x(e*t/100),ie=(e,t)=>t===0?0:x(e*100/t),pe=e=>{let t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},ke=e=>({x:Math.cos(e),y:Math.sin(e)}),se=(e,t,o,r,y)=>{let n=(e-t)/(o-t);return E(r,y,m(n,0,1))},ue=(e,t,o=1e-4)=>Math.abs(e.x-t.x)<o&&Math.abs(e.y-t.y)<o,f=(e,t,o)=>{if(e<t)return 0;let r=(e-t)/(o-t);return m(r,0,1)},be=(e,t,o)=>{let r=Math.hypot(e.x,e.y),y=t*o,n=f(r,y,t);if(n===0)return {x:0,y:0};let d={x:e.x/r,y:e.y/r};return A(d,n)},me=(e,t,o)=>({x:f(Math.abs(e.x),o,t)*Math.sign(e.x),y:f(Math.abs(e.y),o,t)*Math.sign(e.y)});function a(e){if(e==null)return;if(typeof e=="object"&&"unit"in e&&"value"in e)return T(e);if(typeof e=="number")return {value:Number.isFinite(e)?e:0,unit:"px"};let t=e.trim().toLowerCase(),o=parseFloat(t);if(isNaN(o))return {value:0,unit:"px"};let r=t.slice(String(o).length).trim();return T({value:o,unit:r})}var T=e=>{let{value:t,unit:o}=e;return !isNaN(t)&&h.includes(o)?{value:t,unit:o}:(console.warn(`[OmniPad-Core] Blocked invalid CSS unit: ${o}`),{value:isNaN(t)?0:t,unit:"px"})},k=e=>e==null?void 0:`${e.value}${e.unit}`;function De(e){return {...e,left:a(e.left),top:a(e.top),right:a(e.right),bottom:a(e.bottom),width:a(e.width),height:a(e.height),stickySelector:C(e.stickySelector)}}function Ae(e){return {...e,left:k(e.left),top:k(e.top),right:k(e.right),bottom:k(e.bottom),width:k(e.width),height:k(e.height)}}function Ee(e,t,o){let r=e.left!==void 0?a(e.left):null,y=e.right!==void 0?a(e.right):null,n=e.top!==void 0?a(e.top):null,d=e.bottom!==void 0?a(e.bottom):null,i=e.width!==void 0?a(e.width):null,p=e.height!==void 0?a(e.height):null;o||(o=(c,b)=>c?c.unit==="%"?c.value/100*b:c.value:0);let l,s;if(i!=null&&i.value!==0)l=o(i,t.width),r!=null?s=t.left+o(r,t.width):y!=null?s=t.right-o(y,t.width)-l:s=t.left;else {let c=r!=null?o(r,t.width):0,b=y!=null?o(y,t.width):0;s=t.left+c,l=Math.max(0,t.width-c-b);}let g,u;if(p!=null&&p.value!==0)g=o(p,t.height),n!=null?u=t.top+o(n,t.height):d!=null?u=t.bottom-o(d,t.height)-g:u=t.top;else {let c=n!=null?o(n,t.height):0,b=d!=null?o(d,t.height):0;u=t.top+c,g=Math.max(0,t.height-c-b);}return {...e,left:`${s}px`,top:`${u}px`,width:`${l}px`,height:`${g}px`,right:void 0,bottom:void 0}}var Me=e=>{if(Object.keys(e??{}).length===0)return {};let t={};t.position=e.stickySelector?"fixed":"absolute",e.isSquare&&(t.aspectRatio="1/1"),["left","top","right","bottom","width","height"].forEach(y=>{let n=e[y];if(n!=null){let d=a(n);d!=null&&(t[y]=k(d));}}),e.zIndex!==void 0&&(t.zIndex=e.zIndex);let r={"top-left":"translate(0, 0)","top-center":"translate(-50%, 0)","top-right":"translate(-100%, 0)","center-left":"translate(0, -50%)",center:"translate(-50%, -50%)","center-right":"translate(-100%, -50%)","bottom-left":"translate(0, -100%)","bottom-center":"translate(-50%, -100%)","bottom-right":"translate(-100%, -100%)"};return e.anchor&&(t.transform=r[e.anchor]),t},M=(e,t,o=false)=>{let r=m(e.x+1,0,2),y=m(e.y+1,0,2);return o?{width:"100cqw",height:"100cqh",x:`${r*50}cqw`,y:`${y*50}cqh`}:{width:`${t.x}px`,height:`${t.y}px`,x:`${r*t.x/2}px`,y:`${y*t.y/2}px`}},Le=(e,t,o=false)=>{let r={x:e.x/50-1,y:e.y/50-1};return M(r,o?r:t(),o)};exports.A=ce;exports.B=ie;exports.C=pe;exports.D=ke;exports.E=se;exports.F=ue;exports.G=f;exports.H=be;exports.I=me;exports.J=a;exports.K=T;exports.L=k;exports.M=De;exports.N=Ae;exports.O=Ee;exports.P=Me;exports.Q=M;exports.R=Le;exports.a=L;exports.b=V;exports.c=_;exports.d=h;exports.e=I;exports.f=j;exports.g=W;exports.h=Z;exports.i=N;exports.j=K;exports.k=C;exports.l=G;exports.m=X;exports.n=Q;exports.o=ee;exports.p=A;exports.q=m;exports.r=E;exports.s=x;exports.t=te;exports.u=oe;exports.v=re;exports.w=ye;exports.x=ne;exports.y=de;exports.z=ae;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=(e,t,n="omnipad-prevent")=>{let r=document.elementsFromPoint(e,t).find(o=>!o.classList.contains(n));if(!r)return null;for(;r&&r.shadowRoot;){let i=r.shadowRoot.elementsFromPoint(e,t).find(c=>!c.classList.contains(n));if(!i||i===r)break;r=i;}return r},d=()=>{let e=document.activeElement;for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e},a=e=>{if(!e)return null;if(e.startsWith("#")){let t=e.slice(1),n=document.getElementById(t);if(n)return n}try{return document.querySelector(e)}catch{return null}};var E=(e,t)=>{m(e,t);},m=(e,t)=>{let n=new KeyboardEvent(e,{...t,which:t.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(n);},v=(e,t,n,s)=>{let r=u(t,n);r&&l(r,e,t,n,s);},l=(e,t,n,s,r)=>{if(!Number.isFinite(n)||!Number.isFinite(s))return;let o={bubbles:true,cancelable:true,composed:true,clientX:n,clientY:s,view:window,...r};if(t.startsWith("pointer")){e.dispatchEvent(new PointerEvent(t,{isPrimary:true,pointerId:9999,pointerType:"mouse",...o}));let i=t.replace("pointer","mouse");e.dispatchEvent(new MouseEvent(i,o));}else e.dispatchEvent(new MouseEvent(t,o));};export{u as a,d as b,a as c,E as d,m as e,v as f,l as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function f(r,n){let e={},c=Object.keys(r);for(let i=0;i<c.length;i++){let s=c[i],t=r[s];t!==void 0&&!n.has(s)&&(e[s]=t);}return e}function y(r,n){let e={};if(!r)return {...n};let c=Object.keys(n);for(let i=0;i<c.length;i++){let s=c[i],t=n[s],o=r[s];if(t!==o){if(typeof t=="object"&&t!==null&&o!==null&&JSON.stringify(t)===JSON.stringify(o))continue;e[s]=t;}}return e}function u(...r){return r.reduce((n,e)=>e?{...n,...e}:n,{})}export{f as a,y as b,u as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var S={Backspace:{type:"keyboard",key:"Backspace",code:"Backspace",keyCode:8},Tab:{type:"keyboard",key:"Tab",code:"Tab",keyCode:9},Enter:{type:"keyboard",key:"Enter",code:"Enter",keyCode:13},ShiftLeft:{type:"keyboard",key:"Shift",code:"ShiftLeft",keyCode:16},ControlLeft:{type:"keyboard",key:"Control",code:"ControlLeft",keyCode:17},AltLeft:{type:"keyboard",key:"Alt",code:"AltLeft",keyCode:18},Pause:{type:"keyboard",key:"Pause",code:"Pause",keyCode:19},CapsLock:{type:"keyboard",key:"CapsLock",code:"CapsLock",keyCode:20},Escape:{type:"keyboard",key:"Escape",code:"Escape",keyCode:27},Space:{type:"keyboard",key:" ",code:"Space",keyCode:32},PageUp:{type:"keyboard",key:"PageUp",code:"PageUp",keyCode:33},PageDown:{type:"keyboard",key:"PageDown",code:"PageDown",keyCode:34},End:{type:"keyboard",key:"End",code:"End",keyCode:35},Home:{type:"keyboard",key:"Home",code:"Home",keyCode:36},ArrowLeft:{type:"keyboard",key:"ArrowLeft",code:"ArrowLeft",keyCode:37},ArrowUp:{type:"keyboard",key:"ArrowUp",code:"ArrowUp",keyCode:38},ArrowRight:{type:"keyboard",key:"ArrowRight",code:"ArrowRight",keyCode:39},ArrowDown:{type:"keyboard",key:"ArrowDown",code:"ArrowDown",keyCode:40},PrintScreen:{type:"keyboard",key:"PrintScreen",code:"PrintScreen",keyCode:44},Insert:{type:"keyboard",key:"Insert",code:"Insert",keyCode:45},Delete:{type:"keyboard",key:"Delete",code:"Delete",keyCode:46},Digit0:{type:"keyboard",key:"0",code:"Digit0",keyCode:48},Digit1:{type:"keyboard",key:"1",code:"Digit1",keyCode:49},Digit2:{type:"keyboard",key:"2",code:"Digit2",keyCode:50},Digit3:{type:"keyboard",key:"3",code:"Digit3",keyCode:51},Digit4:{type:"keyboard",key:"4",code:"Digit4",keyCode:52},Digit5:{type:"keyboard",key:"5",code:"Digit5",keyCode:53},Digit6:{type:"keyboard",key:"6",code:"Digit6",keyCode:54},Digit7:{type:"keyboard",key:"7",code:"Digit7",keyCode:55},Digit8:{type:"keyboard",key:"8",code:"Digit8",keyCode:56},Digit9:{type:"keyboard",key:"9",code:"Digit9",keyCode:57},KeyA:{type:"keyboard",key:"a",code:"KeyA",keyCode:65},KeyB:{type:"keyboard",key:"b",code:"KeyB",keyCode:66},KeyC:{type:"keyboard",key:"c",code:"KeyC",keyCode:67},KeyD:{type:"keyboard",key:"d",code:"KeyD",keyCode:68},KeyE:{type:"keyboard",key:"e",code:"KeyE",keyCode:69},KeyF:{type:"keyboard",key:"f",code:"KeyF",keyCode:70},KeyG:{type:"keyboard",key:"g",code:"KeyG",keyCode:71},KeyH:{type:"keyboard",key:"h",code:"KeyH",keyCode:72},KeyI:{type:"keyboard",key:"i",code:"KeyI",keyCode:73},KeyJ:{type:"keyboard",key:"j",code:"KeyJ",keyCode:74},KeyK:{type:"keyboard",key:"k",code:"KeyK",keyCode:75},KeyL:{type:"keyboard",key:"l",code:"KeyL",keyCode:76},KeyM:{type:"keyboard",key:"m",code:"KeyM",keyCode:77},KeyN:{type:"keyboard",key:"n",code:"KeyN",keyCode:78},KeyO:{type:"keyboard",key:"o",code:"KeyO",keyCode:79},KeyP:{type:"keyboard",key:"p",code:"KeyP",keyCode:80},KeyQ:{type:"keyboard",key:"q",code:"KeyQ",keyCode:81},KeyR:{type:"keyboard",key:"r",code:"KeyR",keyCode:82},KeyS:{type:"keyboard",key:"s",code:"KeyS",keyCode:83},KeyT:{type:"keyboard",key:"t",code:"KeyT",keyCode:84},KeyU:{type:"keyboard",key:"u",code:"KeyU",keyCode:85},KeyV:{type:"keyboard",key:"v",code:"KeyV",keyCode:86},KeyW:{type:"keyboard",key:"w",code:"KeyW",keyCode:87},KeyX:{type:"keyboard",key:"x",code:"KeyX",keyCode:88},KeyY:{type:"keyboard",key:"y",code:"KeyY",keyCode:89},KeyZ:{type:"keyboard",key:"z",code:"KeyZ",keyCode:90},MetaLeft:{type:"keyboard",key:"Meta",code:"MetaLeft",keyCode:91},ContextMenu:{type:"keyboard",key:"ContextMenu",code:"ContextMenu",keyCode:93},Numpad0:{type:"keyboard",key:"0",code:"Numpad0",keyCode:96},Numpad1:{type:"keyboard",key:"1",code:"Numpad1",keyCode:97},Numpad2:{type:"keyboard",key:"2",code:"Numpad2",keyCode:98},Numpad3:{type:"keyboard",key:"3",code:"Numpad3",keyCode:99},Numpad4:{type:"keyboard",key:"4",code:"Numpad4",keyCode:100},Numpad5:{type:"keyboard",key:"5",code:"Numpad5",keyCode:101},Numpad6:{type:"keyboard",key:"6",code:"Numpad6",keyCode:102},Numpad7:{type:"keyboard",key:"7",code:"Numpad7",keyCode:103},Numpad8:{type:"keyboard",key:"8",code:"Numpad8",keyCode:104},Numpad9:{type:"keyboard",key:"9",code:"Numpad9",keyCode:105},NumpadMultiply:{type:"keyboard",key:"*",code:"NumpadMultiply",keyCode:106},NumpadAdd:{type:"keyboard",key:"+",code:"NumpadAdd",keyCode:107},NumpadSubtract:{type:"keyboard",key:"-",code:"NumpadSubtract",keyCode:109},NumpadDecimal:{type:"keyboard",key:".",code:"NumpadDecimal",keyCode:110},NumpadDivide:{type:"keyboard",key:"/",code:"NumpadDivide",keyCode:111},F1:{type:"keyboard",key:"F1",code:"F1",keyCode:112},F2:{type:"keyboard",key:"F2",code:"F2",keyCode:113},F3:{type:"keyboard",key:"F3",code:"F3",keyCode:114},F4:{type:"keyboard",key:"F4",code:"F4",keyCode:115},F5:{type:"keyboard",key:"F5",code:"F5",keyCode:116},F6:{type:"keyboard",key:"F6",code:"F6",keyCode:117},F7:{type:"keyboard",key:"F7",code:"F7",keyCode:118},F8:{type:"keyboard",key:"F8",code:"F8",keyCode:119},F9:{type:"keyboard",key:"F9",code:"F9",keyCode:120},F10:{type:"keyboard",key:"F10",code:"F10",keyCode:121},F11:{type:"keyboard",key:"F11",code:"F11",keyCode:122},F12:{type:"keyboard",key:"F12",code:"F12",keyCode:123},NumLock:{type:"keyboard",key:"NumLock",code:"NumLock",keyCode:144},ScrollLock:{type:"keyboard",key:"ScrollLock",code:"ScrollLock",keyCode:145},Semicolon:{type:"keyboard",key:";",code:"Semicolon",keyCode:186},Equal:{type:"keyboard",key:"=",code:"Equal",keyCode:187},Comma:{type:"keyboard",key:",",code:"Comma",keyCode:188},Minus:{type:"keyboard",key:"-",code:"Minus",keyCode:189},Period:{type:"keyboard",key:".",code:"Period",keyCode:190},Slash:{type:"keyboard",key:"/",code:"Slash",keyCode:191},Backquote:{type:"keyboard",key:"`",code:"Backquote",keyCode:192},BracketLeft:{type:"keyboard",key:"[",code:"BracketLeft",keyCode:219},Backslash:{type:"keyboard",key:"\\",code:"Backslash",keyCode:220},BracketRight:{type:"keyboard",key:"]",code:"BracketRight",keyCode:221},Quote:{type:"keyboard",key:"'",code:"Quote",keyCode:222},Mouse:{type:"mouse",button:0},MouseLeft:{type:"mouse",button:0},MouseMiddle:{type:"mouse",button:1},MouseRight:{type:"mouse",button:2}},L=S;var V={INPUT_ZONE:"input-zone",TARGET_ZONE:"target-zone",BUTTON:"button",KEYBOARD_BUTTON:"keyboard-button",MOUSE_BUTTON:"mouse-button",JOYSTICK:"joystick",D_PAD:"d-pad",TRACKPAD:"trackpad",VIRTUAL_CURSOR:"virtual-cursor",ROOT_LAYER:"root-layer"},_={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},h=["px","%","vh","vw","vmin","vmax","rem","em"],I={PARENT_ID_KEY:"omnipad-parent-id-link"};function j(e){let t=null,o=true;return {get:()=>((o||!t)&&(t=e(),o=false),t),markDirty:()=>{o=true;}}}var W=(e="omnipad")=>{let t=Date.now().toString(36),o=new Uint8Array(4),r=globalThis.crypto;if(r?.getRandomValues)r.getRandomValues(o);else for(let n=0;n<o.length;n++)o[n]=Math.floor(Math.random()*256);let y=Array.from(o).map(n=>n.toString(36).padStart(2,"0")).join("").substring(0,4);return `${e}-${t}-${y}`};function Z(e){return e.startsWith("$")}var P=/^[a-zA-Z0-9\s._#$\-*>+~]+$/,N=Object.freeze(["__proto__","constructor","prototype"]),K=Object.freeze(["script","javascript:","onerror","onload","eval","expression"]);function C(e,t=""){if(!e)return t;let o=e.trim();return o.length>256?t:P.test(o)?K.some(r=>o.toLowerCase().includes(r))?t:o:(import.meta.env?.DEV&&console.warn(`[OmniPad-Validation] Unsafe DOM string blocked: "${o}"`),t)}var D=/^[a-zA-Z0-9\-_]+$/;function G(e){return e?e.split(/\s+/).filter(t=>D.test(t)).join(" "):""}function X(e){let t=new Set([...N]),o=r=>{if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(d=>o(d));let y={},n=Object.keys(r);for(let d=0;d<n.length;d++){let i=n[d];if(t.has(i)){console.warn(`[OmniPad-Security] Stripped dangerous key: "${i}"`);continue}let p=r[i];y[i]=p!==null&&typeof p=="object"?o(p):p;}return y};return o(e)}var Q=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),ee=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),A=(e,t)=>({x:e.x*t,y:e.y*t}),m=(e,t,o)=>Math.max(t,Math.min(o,e)),E=(e,t,o)=>e+(t-e)*o,x=(e,t=2)=>{let o=Math.pow(10,t);return Math.round(e*o)/o},te=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),oe=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),re=e=>e*180/Math.PI,ye=e=>e*Math.PI/180,ne=(e,t,o)=>{let r=t.x-e.x,y=t.y-e.y;if(Math.hypot(r,y)<=o)return t;let d=Math.atan2(y,r);return {x:e.x+Math.cos(d)*o,y:e.y+Math.sin(d)*o}},de=e=>{let t=Math.PI/4;return Math.round(e/t)*t},ae=e=>{let t=Math.PI/2;return Math.round(e/t)*t},ce=(e,t)=>x(e*t/100),ie=(e,t)=>t===0?0:x(e*100/t),pe=e=>{let t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},ke=e=>({x:Math.cos(e),y:Math.sin(e)}),se=(e,t,o,r,y)=>{let n=(e-t)/(o-t);return E(r,y,m(n,0,1))},ue=(e,t,o=1e-4)=>Math.abs(e.x-t.x)<o&&Math.abs(e.y-t.y)<o,f=(e,t,o)=>{if(e<t)return 0;let r=(e-t)/(o-t);return m(r,0,1)},be=(e,t,o)=>{let r=Math.hypot(e.x,e.y),y=t*o,n=f(r,y,t);if(n===0)return {x:0,y:0};let d={x:e.x/r,y:e.y/r};return A(d,n)},me=(e,t,o)=>({x:f(Math.abs(e.x),o,t)*Math.sign(e.x),y:f(Math.abs(e.y),o,t)*Math.sign(e.y)});function a(e){if(e==null)return;if(typeof e=="object"&&"unit"in e&&"value"in e)return T(e);if(typeof e=="number")return {value:Number.isFinite(e)?e:0,unit:"px"};let t=e.trim().toLowerCase(),o=parseFloat(t);if(isNaN(o))return {value:0,unit:"px"};let r=t.slice(String(o).length).trim();return T({value:o,unit:r})}var T=e=>{let{value:t,unit:o}=e;return !isNaN(t)&&h.includes(o)?{value:t,unit:o}:(console.warn(`[OmniPad-Core] Blocked invalid CSS unit: ${o}`),{value:isNaN(t)?0:t,unit:"px"})},k=e=>e==null?void 0:`${e.value}${e.unit}`;function De(e){return {...e,left:a(e.left),top:a(e.top),right:a(e.right),bottom:a(e.bottom),width:a(e.width),height:a(e.height),stickySelector:C(e.stickySelector)}}function Ae(e){return {...e,left:k(e.left),top:k(e.top),right:k(e.right),bottom:k(e.bottom),width:k(e.width),height:k(e.height)}}function Ee(e,t,o){let r=e.left!==void 0?a(e.left):null,y=e.right!==void 0?a(e.right):null,n=e.top!==void 0?a(e.top):null,d=e.bottom!==void 0?a(e.bottom):null,i=e.width!==void 0?a(e.width):null,p=e.height!==void 0?a(e.height):null;o||(o=(c,b)=>c?c.unit==="%"?c.value/100*b:c.value:0);let l,s;if(i!=null&&i.value!==0)l=o(i,t.width),r!=null?s=t.left+o(r,t.width):y!=null?s=t.right-o(y,t.width)-l:s=t.left;else {let c=r!=null?o(r,t.width):0,b=y!=null?o(y,t.width):0;s=t.left+c,l=Math.max(0,t.width-c-b);}let g,u;if(p!=null&&p.value!==0)g=o(p,t.height),n!=null?u=t.top+o(n,t.height):d!=null?u=t.bottom-o(d,t.height)-g:u=t.top;else {let c=n!=null?o(n,t.height):0,b=d!=null?o(d,t.height):0;u=t.top+c,g=Math.max(0,t.height-c-b);}return {...e,left:`${s}px`,top:`${u}px`,width:`${l}px`,height:`${g}px`,right:void 0,bottom:void 0}}var Me=e=>{if(Object.keys(e??{}).length===0)return {};let t={};t.position=e.stickySelector?"fixed":"absolute",e.isSquare&&(t.aspectRatio="1/1"),["left","top","right","bottom","width","height"].forEach(y=>{let n=e[y];if(n!=null){let d=a(n);d!=null&&(t[y]=k(d));}}),e.zIndex!==void 0&&(t.zIndex=e.zIndex);let r={"top-left":"translate(0, 0)","top-center":"translate(-50%, 0)","top-right":"translate(-100%, 0)","center-left":"translate(0, -50%)",center:"translate(-50%, -50%)","center-right":"translate(-100%, -50%)","bottom-left":"translate(0, -100%)","bottom-center":"translate(-50%, -100%)","bottom-right":"translate(-100%, -100%)"};return e.anchor&&(t.transform=r[e.anchor]),t},M=(e,t,o=false)=>{let r=m(e.x+1,0,2),y=m(e.y+1,0,2);return o?{width:"100cqw",height:"100cqh",x:`${r*50}cqw`,y:`${y*50}cqh`}:{width:`${t.x}px`,height:`${t.y}px`,x:`${r*t.x/2}px`,y:`${y*t.y/2}px`}},Le=(e,t,o=false)=>{let r={x:e.x/50-1,y:e.y/50-1};return M(r,o?r:t(),o)};export{ce as A,ie as B,pe as C,ke as D,se as E,ue as F,f as G,be as H,me as I,a as J,T as K,k as L,De as M,Ae as N,Ee as O,Me as P,M as Q,Le as R,L as a,V as b,_ as c,h as d,I as e,j as f,W as g,Z as h,N as i,K as j,C as k,G as l,X as m,Q as n,ee as o,A as p,m as q,E as r,x as s,te as t,oe as u,re as v,ye as w,ne as x,de as y,ae as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var I=Object.defineProperty;var a=(t,e,_)=>e in t?I(t,e,{enumerable:true,configurable:true,writable:true,value:_}):t[e]=_;var o=(t,e,_)=>a(t,typeof e!="symbol"?e+"":e,_);var p="__OMNIPAD_IPC_V1__";exports.a=o;exports.b=p;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var I=Object.defineProperty;var a=(t,e,_)=>e in t?I(t,e,{enumerable:true,configurable:true,writable:true,value:_}):t[e]=_;var o=(t,e,_)=>a(t,typeof e!="symbol"?e+"":e,_);var p="__OMNIPAD_IPC_V1__";export{o as a,p as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s={rect:["left","right","top","bottom","width","height"],pointer:["pointerId","clientX","clientY","button"]};function o(t,e){let r={};for(let n=0;n<e.length;n++){let c=e[n];r[c]=t[c];}return r}var i=t=>o(t,s.rect),a=t=>o(t,s.pointer),l=(t,e)=>o(t,e);export{i as a,a as b,l as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk52YF3VHH_cjs=require('./chunk-52YF3VHH.cjs'),chunkHCOFKHVV_cjs=require('./chunk-HCOFKHVV.cjs');var g=Symbol.for("omnipad.registry.instance"),p=null;function I(i){p=i;}var b=class i{constructor(){chunkHCOFKHVV_cjs.a(this,"entities",new Map);undefined?.DEV&&console.log("[OmniPad-Core] Registry initialized.");}static getInstance(){let t=globalThis;return t[g]||(t[g]=new i),t[g]}register(t){if(!t.uid){console.warn("[OmniPad-Core] Registry: Attempted to register entity without UID.",t);return}this.entities.has(t.uid),this.entities.set(t.uid,t);}unregister(t){this.entities.has(t)&&this.entities.delete(t);}getEntity(t){return this.entities.get(t)}getAllEntities(){return Array.from(this.entities.values())}getEntitiesByRoot(t){let e=this.getAllEntities();if(!t)return e;if(!this.entities.get(t))return console.warn(`[OmniPad-Core] Registry: Root entity ${t} not found.`),[];let r=new Map;e.forEach(a=>{let u=a;if(typeof u.getConfig=="function"){let l=u.getConfig();l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(a));}});let s=[],o=[t],d=new Set;for(;o.length>0;){let a=o.shift();if(d.has(a))continue;d.add(a);let u=this.entities.get(a);if(u){s.push(u);let l=r.get(a);l&&l.forEach(v=>o.push(v.uid));}}return s}destroyByRoot(t){let e=this.getEntitiesByRoot(t);for(let n=e.length-1;n>=0;n--){let r=e[n];try{r.destroy();}catch(s){console.error(`[OmniPad-Core] Error during destroyByRoot at ${r.uid}:`,s);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(t=>{"reset"in t&&t.reset();});}markAllRectDirty(){this.entities.forEach(t=>{"markRectDirty"in t&&t.markRectDirty();});}broadcastSignal(t){let e=this.getEntity(t.targetStageId);e&&"handleSignal"in e?e.handleSignal(t):p&&p(t);}};var y=class{constructor(t,e,n,r){this.finder=e;this.rectProvider=n;this.presenceChecker=r;chunkHCOFKHVV_cjs.a(this,"_selector");chunkHCOFKHVV_cjs.a(this,"_cachedTarget",null);chunkHCOFKHVV_cjs.a(this,"_rectCache");this._selector=t,this._rectCache=chunk52YF3VHH_cjs.f(()=>{let s=this.getTarget();return s?this.rectProvider(s):null});}getTarget(){return this._cachedTarget&&this.presenceChecker(this._cachedTarget)?this._cachedTarget:(this._cachedTarget=this.finder(this._selector),this._cachedTarget)}getRect(){return this._rectCache.get()}markDirty(){this._rectCache.markDirty();}updateSelector(t){return this._selector===t?false:(this._selector=t,this._cachedTarget=null,this.markDirty(),true)}},m=class{constructor(t,e,n){this.observer=t;this.instance=e;this.onUpdate=n;}get uid(){return this.instance.uid+"-sticky"}handleSelectorChange(t,e,n){if(!t)return this.observer.disconnect(this.uid),{provider:null,updated:true};let r=e,s=false;if(r?s=r.updateSelector(t):(r=n(t),s=true),s){let o=r.getTarget();o&&(this.observer.observeResize(this.uid,o,()=>{r?.markDirty(),this.instance.markRectDirty(),this.onUpdate();}),this.observer.observeIntersect(this.uid,o,d=>{d||this.instance.reset();}),this.onUpdate());}return {provider:r,updated:s}}onCleanUp(){this.observer.disconnect(this.uid);}};var h=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):i=>setTimeout(i,16),T=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):i=>clearTimeout(i);function k(i){let t=false,e;return function(n){e=n,t||(t=true,h(()=>{i(e),t=false;}));}}function S(i){let t=null,e=()=>{i(),t=h(e);};return {start:()=>{t===null&&e();},stop:()=>{t!==null&&(T(t),t=null);}}}var P=(i=2)=>new Promise(t=>{let e=0,n=()=>{++e>=i?t():h(n);};h(n);});exports.a=I;exports.b=b;exports.c=y;exports.d=m;exports.e=k;exports.f=S;exports.g=P;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function f(r,n){let e={},c=Object.keys(r);for(let i=0;i<c.length;i++){let s=c[i],t=r[s];t!==void 0&&!n.has(s)&&(e[s]=t);}return e}function y(r,n){let e={};if(!r)return {...n};let c=Object.keys(n);for(let i=0;i<c.length;i++){let s=c[i],t=n[s],o=r[s];if(t!==o){if(typeof t=="object"&&t!==null&&o!==null&&JSON.stringify(t)===JSON.stringify(o))continue;e[s]=t;}}return e}function u(...r){return r.reduce((n,e)=>e?{...n,...e}:n,{})}exports.a=f;exports.b=y;exports.c=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {f}from'./chunk-EYKCVOUA.mjs';import {a}from'./chunk-HQNUZXP5.mjs';var g=Symbol.for("omnipad.registry.instance"),p=null;function I(i){p=i;}var b=class i{constructor(){a(this,"entities",new Map);import.meta.env?.DEV&&console.log("[OmniPad-Core] Registry initialized.");}static getInstance(){let t=globalThis;return t[g]||(t[g]=new i),t[g]}register(t){if(!t.uid){console.warn("[OmniPad-Core] Registry: Attempted to register entity without UID.",t);return}this.entities.has(t.uid),this.entities.set(t.uid,t);}unregister(t){this.entities.has(t)&&this.entities.delete(t);}getEntity(t){return this.entities.get(t)}getAllEntities(){return Array.from(this.entities.values())}getEntitiesByRoot(t){let e=this.getAllEntities();if(!t)return e;if(!this.entities.get(t))return console.warn(`[OmniPad-Core] Registry: Root entity ${t} not found.`),[];let r=new Map;e.forEach(a=>{let u=a;if(typeof u.getConfig=="function"){let l=u.getConfig();l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(a));}});let s=[],o=[t],d=new Set;for(;o.length>0;){let a=o.shift();if(d.has(a))continue;d.add(a);let u=this.entities.get(a);if(u){s.push(u);let l=r.get(a);l&&l.forEach(v=>o.push(v.uid));}}return s}destroyByRoot(t){let e=this.getEntitiesByRoot(t);for(let n=e.length-1;n>=0;n--){let r=e[n];try{r.destroy();}catch(s){console.error(`[OmniPad-Core] Error during destroyByRoot at ${r.uid}:`,s);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(t=>{"reset"in t&&t.reset();});}markAllRectDirty(){this.entities.forEach(t=>{"markRectDirty"in t&&t.markRectDirty();});}broadcastSignal(t){let e=this.getEntity(t.targetStageId);e&&"handleSignal"in e?e.handleSignal(t):p&&p(t);}};var y=class{constructor(t,e,n,r){this.finder=e;this.rectProvider=n;this.presenceChecker=r;a(this,"_selector");a(this,"_cachedTarget",null);a(this,"_rectCache");this._selector=t,this._rectCache=f(()=>{let s=this.getTarget();return s?this.rectProvider(s):null});}getTarget(){return this._cachedTarget&&this.presenceChecker(this._cachedTarget)?this._cachedTarget:(this._cachedTarget=this.finder(this._selector),this._cachedTarget)}getRect(){return this._rectCache.get()}markDirty(){this._rectCache.markDirty();}updateSelector(t){return this._selector===t?false:(this._selector=t,this._cachedTarget=null,this.markDirty(),true)}},m=class{constructor(t,e,n){this.observer=t;this.instance=e;this.onUpdate=n;}get uid(){return this.instance.uid+"-sticky"}handleSelectorChange(t,e,n){if(!t)return this.observer.disconnect(this.uid),{provider:null,updated:true};let r=e,s=false;if(r?s=r.updateSelector(t):(r=n(t),s=true),s){let o=r.getTarget();o&&(this.observer.observeResize(this.uid,o,()=>{r?.markDirty(),this.instance.markRectDirty(),this.onUpdate();}),this.observer.observeIntersect(this.uid,o,d=>{d||this.instance.reset();}),this.onUpdate());}return {provider:r,updated:s}}onCleanUp(){this.observer.disconnect(this.uid);}};var h=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):i=>setTimeout(i,16),T=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):i=>clearTimeout(i);function k(i){let t=false,e;return function(n){e=n,t||(t=true,h(()=>{i(e),t=false;}));}}function S(i){let t=null,e=()=>{i(),t=h(e);};return {start:()=>{t===null&&e();},stop:()=>{t!==null&&(T(t),t=null);}}}var P=(i=2)=>new Promise(t=>{let e=0,n=()=>{++e>=i?t():h(n);};h(n);});export{I as a,b,y as c,m as d,k as e,S as f,P as g};
|
package/dist/dom/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunkVHF3K5X6_cjs=require('../chunk-VHF3K5X6.cjs'),chunkFSJTQU4W_cjs=require('../chunk-FSJTQU4W.cjs'),chunkZHPNS73J_cjs=require('../chunk-ZHPNS73J.cjs');var m=(n,t,e="omnipad-prevent")=>{let i=document.elementsFromPoint(n,t).find(s=>!s.classList.contains(e));if(!i)return null;for(;i&&i.shadowRoot;){let a=i.shadowRoot.elementsFromPoint(n,t).find(l=>!l.classList.contains(e));if(!a||a===i)break;i=a;}return i},g=()=>{let n=document.activeElement;for(;n&&n.shadowRoot&&n.shadowRoot.activeElement;)n=n.shadowRoot.activeElement;return n},R=n=>{if(!n)return null;if(n.startsWith("#")){let t=n.slice(1),e=document.getElementById(t);if(e)return e}try{return document.querySelector(n)}catch{return null}};var x=n=>{g()!==n&&(n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus());},M=(n,t)=>{let e=new KeyboardEvent(n,{...t,which:t.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(e);},D=(n,t,e,r)=>{let i=m(t,e);if(!i)return;let s={bubbles:true,cancelable:true,composed:true,clientX:t,clientY:e,view:window,...r};if(n.startsWith("pointer")){i.dispatchEvent(new PointerEvent(n,{isPrimary:true,pointerId:9999,pointerType:"mouse",...s}));let a=n.replace("pointer","mouse");i.dispatchEvent(new MouseEvent(a,s));}else i.dispatchEvent(new MouseEvent(n,s));},L=(n,t,e)=>{let r=m(n,t);if(!r)return;g()!==r&&(x(r),e());};var w=(n,t)=>{if(n instanceof Element)try{n.setPointerCapture(t);}catch(e){undefined?.DEV&&console.warn("[OmniPad-DOM] Failed to set pointer capture:",e);}},f=(n,t)=>{if(n instanceof Element&&n.hasPointerCapture(t))try{n.releasePointerCapture(t);}catch{}};function O(n,t={}){return {onPointerDown(e){if(!e.isTrusted||t?.requireDirectHit&&e.target!==e.currentTarget||n.activePointerId!=null)return;e.cancelable&&e.preventDefault(),e.stopPropagation();let r=e.currentTarget;r&&w(r,e.pointerId),n.onPointerDown(e);},onPointerMove(e){e.isTrusted&&(n.activePointerId!=null&&n.activePointerId!==e.pointerId||(e.cancelable&&e.preventDefault(),n.onPointerMove(e)));},onPointerUp(e){if(!e.isTrusted||n.activePointerId!=null&&n.activePointerId!==e.pointerId)return;e.cancelable&&e.preventDefault();let r=e.currentTarget;r&&f(r,e.pointerId),n.onPointerUp(e);},onPointerCancel(e){if(!e.isTrusted||n.activePointerId!=null&&n.activePointerId!==e.pointerId)return;let r=e.currentTarget;r&&f(r,e.pointerId),n.onPointerCancel(e);}}}var p,z=()=>(p!==void 0||(p=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),p);var U=n=>new chunkFSJTQU4W_cjs.k(n,t=>R(t),t=>t.getBoundingClientRect(),t=>document.contains(t));var h=Symbol.for("omnipad.element_observer.instance"),y=class n{constructor(){chunkZHPNS73J_cjs.a(this,"_ro");chunkZHPNS73J_cjs.a(this,"_roRegistry",new Map);chunkZHPNS73J_cjs.a(this,"_elToRoCb",new WeakMap);chunkZHPNS73J_cjs.a(this,"_io");chunkZHPNS73J_cjs.a(this,"_ioRegistry",new Map);chunkZHPNS73J_cjs.a(this,"_elToIoCb",new WeakMap);let t=chunkVHF3K5X6_cjs.a(e=>{for(let r of e)this._elToRoCb.get(r.target)?.();});this._ro=new ResizeObserver(e=>{t(e);}),this._io=new IntersectionObserver(e=>{for(let r of e)this._elToIoCb.get(r.target)?.(r.isIntersecting);},{threshold:0});}static getInstance(){let t=globalThis;return t[h]||(t[h]=new n),t[h]}observeResize(t,e,r){this.unobserveResize(t),this._roRegistry.set(t,e),this._elToRoCb.set(e,r),this._ro.observe(e);}unobserveResize(t){let e=this._roRegistry.get(t);e&&(this._ro.unobserve(e),this._elToRoCb.delete(e),this._roRegistry.delete(t));}observeIntersect(t,e,r){this.unobserveIntersect(t),this._ioRegistry.set(t,e),this._elToIoCb.set(e,r),this._io.observe(e);}unobserveIntersect(t){let e=this._ioRegistry.get(t);e&&(this._io.unobserve(e),this._elToIoCb.delete(e),this._ioRegistry.delete(t));}disconnect(t){this.unobserveResize(t),this.unobserveIntersect(t);}};var v=Symbol.for("omnipad.gamepad_manager.instance"),_={A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,Select:8,Start:9,L3:10,R3:11,Up:12,Down:13,Left:14,Right:15},P=class n{constructor(){chunkZHPNS73J_cjs.a(this,"isRunning",false);chunkZHPNS73J_cjs.a(this,"config",null);chunkZHPNS73J_cjs.a(this,"lastButtonStates",[]);chunkZHPNS73J_cjs.a(this,"loop",()=>{if(!this.isRunning)return;let t=navigator.getGamepads();this.config?.forEach((e,r)=>{let i=t[r];i&&i.connected&&e&&(this.lastButtonStates[r]||(this.lastButtonStates[r]=[]),this.processButtons(i,e,r),this.processDPad(i,e),this.processAxes(i,e));}),requestAnimationFrame(this.loop);});}static getInstance(){let t=globalThis;return t[v]||(t[v]=new n),t[v]}setConfig(t){this.config=t;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",t=>{undefined?.DEV&&console.log("[OmniPad-DOM] Gamepad Connected:",t.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{undefined?.DEV&&console.log("[OmniPad-DOM] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(t,e,r){e.buttons&&Object.entries(e.buttons).forEach(([i,s])=>{let a=_[i];if(a===void 0||!t.buttons[a])return;let l=t.buttons[a].pressed,u=this.lastButtonStates[r][a]||false;l&&!u?this.triggerVirtualEntity(s,"down"):!l&&u&&this.triggerVirtualEntity(s,"up"),this.lastButtonStates[r][a]=l;});}processDPad(t,e){let r=e?.dpad;if(!r)return;let i=t.buttons[12]?.pressed?-1:0,s=t.buttons[13]?.pressed?1:0,a=t.buttons[14]?.pressed?-1:0,l=t.buttons[15]?.pressed?1:0,u=a+l,C=i+s;this.triggerVirtualEntity(r,"vector",{x:u,y:C});}processAxes(t,e){let r=e?.deadzone??.1;if(e?.leftStick){let i=Math.abs(t.axes[0])>r?t.axes[0]:0,s=Math.abs(t.axes[1])>r?t.axes[1]:0;this.triggerVirtualEntity(e.leftStick,"vector",{x:i,y:s});}if(e?.rightStick){let i=Math.abs(t.axes[2])>r?t.axes[2]:0,s=Math.abs(t.axes[3])>r?t.axes[3]:0;this.triggerVirtualEntity(e.rightStick,"vector",{x:i,y:s});}}triggerVirtualEntity(t,e,r){let i=chunkZHPNS73J_cjs.h.getInstance().getEntity(t);!i||i.activePointerId!=null||(e==="down"&&typeof i.triggerDown=="function"&&i.triggerDown(),e==="up"&&typeof i.triggerUp=="function"&&i.triggerUp(),e==="vector"&&typeof i.triggerVector=="function"&&r&&i.triggerVector(r.x,r.y));}};var b=Symbol.for("omnipad.window_manager.instance"),I=class n{constructor(){chunkZHPNS73J_cjs.a(this,"_isListening",false);chunkZHPNS73J_cjs.a(this,"throttledReset");chunkZHPNS73J_cjs.a(this,"handleGlobalReset",()=>{undefined?.DEV&&console.debug("[OmniPad-Core] Safety reset triggered by environment change."),chunkZHPNS73J_cjs.h.getInstance().resetAll(),chunkZHPNS73J_cjs.h.getInstance().markAllRectDirty();});chunkZHPNS73J_cjs.a(this,"handleResizeReset",()=>{this.throttledReset(null);});chunkZHPNS73J_cjs.a(this,"handleBlurReset",()=>{this.handleGlobalReset();});chunkZHPNS73J_cjs.a(this,"handleScrollReset",()=>{this.throttledReset(null);});chunkZHPNS73J_cjs.a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=chunkVHF3K5X6_cjs.a(()=>{this.handleGlobalReset();});}static getInstance(){let t=globalThis;return t[b]||(t[b]=new n),t[b]}init(){this._isListening||(window.addEventListener("resize",this.handleResizeReset),window.addEventListener("blur",this.handleBlurReset),window.addEventListener("scroll",this.handleScrollReset,{capture:true,passive:true}),document.addEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=true,undefined?.DEV&&console.log("[OmniPad-Core] Global WindowManager monitoring started."));}async toggleFullscreen(t){let e=t||document.documentElement;try{document.fullscreenElement?(this.handleGlobalReset(),await document.exitFullscreen()):(this.handleGlobalReset(),await e.requestFullscreen());}catch(r){console.error("[OmniPad-Core] Fullscreen toggle failed:",r);}}isFullscreen(){return !!document.fullscreenElement}destroy(){window.removeEventListener("resize",this.handleResizeReset),window.removeEventListener("blur",this.handleBlurReset),window.removeEventListener("scroll",this.handleScrollReset,{capture:true}),window.removeEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=false;}};exports.ElementObserver=y;exports.GamepadManager=P;exports.WindowManager=I;exports.createPointerBridge=O;exports.createWebStickyProvider=U;exports.dispatchKeyboardEvent=M;exports.dispatchPointerEventAtPos=D;exports.focusElement=x;exports.getDeepActiveElement=g;exports.getDeepElement=m;exports.reclaimFocusAtPos=L;exports.safeReleaseCapture=f;exports.safeSetCapture=w;exports.smartQuerySelector=R;exports.supportsContainerQueries=z;
|
|
1
|
+
'use strict';var chunkNB4FTDOP_cjs=require('../chunk-NB4FTDOP.cjs'),chunk45F3BQT7_cjs=require('../chunk-45F3BQT7.cjs'),chunk52YF3VHH_cjs=require('../chunk-52YF3VHH.cjs'),chunk42WBUPM3_cjs=require('../chunk-42WBUPM3.cjs'),chunkHCOFKHVV_cjs=require('../chunk-HCOFKHVV.cjs');var I=Symbol.for("omnipad.element_observer.instance"),m=class r{constructor(){chunkHCOFKHVV_cjs.a(this,"_ro");chunkHCOFKHVV_cjs.a(this,"_roRegistry",new Map);chunkHCOFKHVV_cjs.a(this,"_elToRoCb",new WeakMap);chunkHCOFKHVV_cjs.a(this,"_io");chunkHCOFKHVV_cjs.a(this,"_ioRegistry",new Map);chunkHCOFKHVV_cjs.a(this,"_elToIoCb",new WeakMap);let e=chunkNB4FTDOP_cjs.e(t=>{for(let n of t)this._elToRoCb.get(n.target)?.();});this._ro=new ResizeObserver(t=>{e(t);}),this._io=new IntersectionObserver(t=>{for(let n of t)this._elToIoCb.get(n.target)?.(n.isIntersecting);},{threshold:0});}static getInstance(){let e=globalThis;return e[I]||(e[I]=new r),e[I]}observeResize(e,t,n){this.unobserveResize(e),this._roRegistry.set(e,t),this._elToRoCb.set(t,n),this._ro.observe(t);}unobserveResize(e){let t=this._roRegistry.get(e);t&&(this._ro.unobserve(t),this._elToRoCb.delete(t),this._roRegistry.delete(e));}observeIntersect(e,t,n){this.unobserveIntersect(e),this._ioRegistry.set(e,t),this._elToIoCb.set(t,n),this._io.observe(t);}unobserveIntersect(e){let t=this._ioRegistry.get(e);t&&(this._io.unobserve(t),this._elToIoCb.delete(t),this._ioRegistry.delete(e));}disconnect(e){this.unobserveResize(e),this.unobserveIntersect(e);}};var R=Symbol.for("omnipad.iframe_manager.instance"),u=class r{constructor(){chunkHCOFKHVV_cjs.a(this,"trustedOrigins",new Set);chunkHCOFKHVV_cjs.a(this,"managedIframes",new Map);chunkHCOFKHVV_cjs.a(this,"deniedIframes",new WeakSet);this.trustedOrigins.add(window.location.origin);}static getInstance(){let e=globalThis;return e[R]||(e[R]=new r),e[R]}addTrustedOrigin(e){e==="*"&&undefined?.DEV&&console.warn('[OmniPad-Security] Wildcard origin "*" is dangerous!'),this.trustedOrigins.add(e);}getVerifiedIframeData(e){let t=this.managedIframes.get(e);if(t)return t;if(this.deniedIframes.has(e))return null;let n=this.getSecureOrigin(e);if(!(this.trustedOrigins.has("*")||this.trustedOrigins.has(n)))return undefined?.DEV&&console.warn(`[OmniPad-Security] Blocking untrusted iframe from origin: ${n}`),this.deniedIframes.add(e),null;let s=chunk52YF3VHH_cjs.g("iframe-proxy"),a=this.captureRect(e),c={uid:s,rect:a,origin:n,isVisible:true};this.managedIframes.set(e,c);let l=m.getInstance();return l.observeResize(s,e,()=>{c.rect=this.captureRect(e);}),l.observeIntersect(s,e,g=>{c.isVisible=g,g||(undefined?.DEV&&console.debug(`[OmniPad-IPC] Iframe ${s} hidden, sending safety reset.`),this.forwardKeyboardEvent(e,chunk52YF3VHH_cjs.c.KEYUP,{all:true}));}),c}forwardPointerEvent(e,t,n,i,s){if(!e.contentWindow||!Number.isFinite(n)||!Number.isFinite(i))return;let a=this.getVerifiedIframeData(e);if(!a)return;let c=n-a.rect.left,l=i-a.rect.top;e.contentWindow.postMessage({signature:chunkHCOFKHVV_cjs.b,type:"pointer",action:t,payload:{x:c,y:l,opts:s}},a.origin);}forwardKeyboardEvent(e,t,n){if(!e.contentWindow)return;let i=this.getVerifiedIframeData(e);i&&e.contentWindow.postMessage({signature:chunkHCOFKHVV_cjs.b,type:"keyboard",action:t,payload:n},i.origin);}captureRect(e){let t=e.getBoundingClientRect();return chunk45F3BQT7_cjs.a(t)}getSecureOrigin(e){try{if(!e.src)return "null";let t=new URL(e.src,window.location.href);return ["about:","blob:","data:"].includes(t.protocol)?"null":t.origin}catch{return "null"}}markAllRectDirty(){undefined?.DEV&&console.debug("[OmniPad-IPC] Refreshing all iframe rects due to environment change."),this.managedIframes.forEach((e,t)=>{if(!document.contains(t)){this.unmanageIframe(t,e.uid);return}e.rect=this.captureRect(t);});}unmanageIframe(e,t){m.getInstance().disconnect(t),this.managedIframes.set(e,void 0),this.managedIframes.delete(e),this.deniedIframes.delete(e);}clearAll(){this.managedIframes.forEach((e,t)=>{this.unmanageIframe(t,e.uid);});}};var V=r=>{chunk42WBUPM3_cjs.b()!==r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus());},J=(r,e)=>{let t=chunk42WBUPM3_cjs.b();if(t&&t.tagName.toLowerCase()==="iframe"){u.getInstance().forwardKeyboardEvent(t,r,e);return}chunk42WBUPM3_cjs.e(r,e);},Z=(r,e,t,n)=>{let i=chunk42WBUPM3_cjs.a(e,t);if(i){if(i.tagName.toLowerCase()==="iframe"){u.getInstance().forwardPointerEvent(i,r,e,t,n);return}chunk42WBUPM3_cjs.g(i,r,e,t,n);}},ee=(r,e,t)=>{let n=chunk42WBUPM3_cjs.a(r,e);if(!n)return;chunk42WBUPM3_cjs.b()!==n&&(V(n),t());};var _=(r,e)=>{if(r instanceof Element)try{r.setPointerCapture(e);}catch(t){undefined?.DEV&&console.warn("[OmniPad-DOM] Failed to set pointer capture:",t);}},w=(r,e)=>{if(r instanceof Element&&r.hasPointerCapture(e))try{r.releasePointerCapture(e);}catch{}};function ie(r,e={}){return {onPointerDown(t){if(!t.isTrusted||e?.requireDirectHit&&t.target!==t.currentTarget||r.activePointerId!=null)return;t.cancelable&&t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n&&_(n,t.pointerId),r.onPointerDown(t);},onPointerMove(t){t.isTrusted&&(r.activePointerId!=null&&r.activePointerId!==t.pointerId||(t.cancelable&&t.preventDefault(),r.onPointerMove(t)));},onPointerUp(t){if(!t.isTrusted||r.activePointerId!=null&&r.activePointerId!==t.pointerId)return;t.cancelable&&t.preventDefault();let n=t.currentTarget;n&&w(n,t.pointerId),r.onPointerUp(t);},onPointerCancel(t){if(!t.isTrusted||r.activePointerId!=null&&r.activePointerId!==t.pointerId)return;let n=t.currentTarget;n&&w(n,t.pointerId),r.onPointerCancel(t);}}}var v,se=()=>(v!==void 0||(v=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),v);function B(r,e){if(!r)return 0;switch(r.unit){case "px":return r.value;case "%":return r.value/100*e;case "vw":return r.value/100*window.innerWidth;case "vh":return r.value/100*window.innerHeight;case "vmin":return r.value/100*Math.min(window.innerWidth,window.innerHeight);case "vmax":return r.value/100*Math.max(window.innerWidth,window.innerHeight);case "rem":case "em":{let t=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return r.value*t}default:return r.value}}function le(r,e){return chunk52YF3VHH_cjs.O(r,e,B)}var fe=r=>new chunkNB4FTDOP_cjs.c(r,e=>chunk42WBUPM3_cjs.c(e),e=>{let t=e.getBoundingClientRect();return chunk45F3BQT7_cjs.a(t)},e=>document.contains(e));var y=Symbol.for("omnipad.gamepad_manager.instance"),G={A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,Select:8,Start:9,L3:10,R3:11,Up:12,Down:13,Left:14,Right:15},D=class r{constructor(){chunkHCOFKHVV_cjs.a(this,"isRunning",false);chunkHCOFKHVV_cjs.a(this,"config",null);chunkHCOFKHVV_cjs.a(this,"lastButtonStates",[]);chunkHCOFKHVV_cjs.a(this,"loop",()=>{if(!this.isRunning)return;let e=navigator.getGamepads();this.config?.forEach((t,n)=>{let i=e[n];i&&i.connected&&t&&(this.lastButtonStates[n]||(this.lastButtonStates[n]=[]),this.processButtons(i,t,n),this.processDPad(i,t),this.processAxes(i,t));}),requestAnimationFrame(this.loop);});}static getInstance(){let e=globalThis;return e[y]||(e[y]=new r),e[y]}setConfig(e){this.config=e;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",e=>{undefined?.DEV&&console.log("[OmniPad-DOM] Gamepad Connected:",e.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{undefined?.DEV&&console.log("[OmniPad-DOM] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(e,t,n){t.buttons&&Object.entries(t.buttons).forEach(([i,s])=>{let a=G[i];if(a===void 0||!e.buttons[a])return;let c=e.buttons[a].pressed,l=this.lastButtonStates[n][a]||false;c&&!l?this.triggerVirtualEntity(s,"down"):!c&&l&&this.triggerVirtualEntity(s,"up"),this.lastButtonStates[n][a]=c;});}processDPad(e,t){let n=t?.dpad;if(!n)return;let i=e.buttons[12]?.pressed?-1:0,s=e.buttons[13]?.pressed?1:0,a=e.buttons[14]?.pressed?-1:0,c=e.buttons[15]?.pressed?1:0,l=a+c,g=i+s;this.triggerVirtualEntity(n,"vector",{x:l,y:g});}processAxes(e,t){let n=t?.deadzone??.1;if(t?.leftStick){let i=Math.abs(e.axes[0])>n?e.axes[0]:0,s=Math.abs(e.axes[1])>n?e.axes[1]:0;this.triggerVirtualEntity(t.leftStick,"vector",{x:i,y:s});}if(t?.rightStick){let i=Math.abs(e.axes[2])>n?e.axes[2]:0,s=Math.abs(e.axes[3])>n?e.axes[3]:0;this.triggerVirtualEntity(t.rightStick,"vector",{x:i,y:s});}}triggerVirtualEntity(e,t,n){let i=chunkNB4FTDOP_cjs.b.getInstance().getEntity(e);!i||i.activePointerId!=null||(t==="down"&&typeof i.triggerDown=="function"&&i.triggerDown(),t==="up"&&typeof i.triggerUp=="function"&&i.triggerUp(),t==="vector"&&typeof i.triggerVector=="function"&&n&&i.triggerVector(n.x,n.y));}};var P=Symbol.for("omnipad.window_manager.instance"),A=class r{constructor(){chunkHCOFKHVV_cjs.a(this,"_isListening",false);chunkHCOFKHVV_cjs.a(this,"throttledReset");chunkHCOFKHVV_cjs.a(this,"handleGlobalReset",()=>{undefined?.DEV&&console.debug("[OmniPad-DOM] Safety reset triggered by environment change."),chunkNB4FTDOP_cjs.b.getInstance().resetAll(),chunkNB4FTDOP_cjs.b.getInstance().markAllRectDirty(),u.getInstance().markAllRectDirty();});chunkHCOFKHVV_cjs.a(this,"handleResizeReset",()=>{this.throttledReset(null);});chunkHCOFKHVV_cjs.a(this,"handleBlurReset",()=>{this.handleGlobalReset();});chunkHCOFKHVV_cjs.a(this,"handleScrollReset",()=>{this.throttledReset(null);});chunkHCOFKHVV_cjs.a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=chunkNB4FTDOP_cjs.e(()=>{this.handleGlobalReset();});}static getInstance(){let e=globalThis;return e[P]||(e[P]=new r),e[P]}init(){this._isListening||(window.addEventListener("resize",this.handleResizeReset),window.addEventListener("blur",this.handleBlurReset),window.addEventListener("scroll",this.handleScrollReset,{capture:true,passive:true}),document.addEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=true,undefined?.DEV&&console.log("[OmniPad-DOM] Global WindowManager monitoring started."));}async toggleFullscreen(e){let t=e||document.documentElement;try{document.fullscreenElement?(this.handleGlobalReset(),await document.exitFullscreen()):(this.handleGlobalReset(),await t.requestFullscreen());}catch(n){console.error("[OmniPad-DOM] Fullscreen toggle failed:",n);}}isFullscreen(){return !!document.fullscreenElement}destroy(){window.removeEventListener("resize",this.handleResizeReset),window.removeEventListener("blur",this.handleBlurReset),window.removeEventListener("scroll",this.handleScrollReset,{capture:true}),window.removeEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=false;}};Object.defineProperty(exports,"getDeepActiveElement",{enumerable:true,get:function(){return chunk42WBUPM3_cjs.b}});Object.defineProperty(exports,"getDeepElement",{enumerable:true,get:function(){return chunk42WBUPM3_cjs.a}});Object.defineProperty(exports,"smartQuerySelector",{enumerable:true,get:function(){return chunk42WBUPM3_cjs.c}});exports.ElementObserver=m;exports.GamepadManager=D;exports.IframeManager=u;exports.WindowManager=A;exports.createPointerBridge=ie;exports.createWebStickyProvider=fe;exports.dispatchKeyboardEvent=J;exports.dispatchPointerEventAtPos=Z;exports.flattenToHostLayout=le;exports.focusElement=V;exports.reclaimFocusAtPos=ee;exports.safeReleaseCapture=w;exports.safeSetCapture=_;exports.supportsContainerQueries=se;exports.toAbsolutePx=B;
|
package/dist/dom/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { G as GamepadMappingConfig } from '../index-DVegtw8s.cjs';
|
|
1
|
+
import { f as IPointerHandler, S as StickyProvider, a as IElementObserver } from '../sticky-CCj0ECTY.cjs';
|
|
2
|
+
import { L as LayoutBox, a as AbstractRect, P as ParsedLength, G as GamepadMappingConfig } from '../index-Dd0aHJaA.cjs';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Forcefully focuses an element.
|
|
@@ -101,6 +100,36 @@ declare const safeReleaseCapture: (el: EventTarget | null, pointerId: number) =>
|
|
|
101
100
|
|
|
102
101
|
declare const supportsContainerQueries: () => boolean;
|
|
103
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Converts various CSS units into absolute pixel values based on the browser environment.
|
|
105
|
+
*
|
|
106
|
+
* Supports: `px`, `%` (relative to `baseSize`), `vw`, `vh`, `vmin`, `vmax`, `rem`, and `em`.
|
|
107
|
+
*
|
|
108
|
+
* **Note:** `rem` and `em` are both resolved using the root element's font size for simplicity.
|
|
109
|
+
*
|
|
110
|
+
* @param p - The parsed length object containing the value and unit.
|
|
111
|
+
* @param baseSize - The reference dimension (width or height) used to resolve percentage (%) values.
|
|
112
|
+
* @returns The computed numerical value in pixels.
|
|
113
|
+
*/
|
|
114
|
+
declare function toAbsolutePx(p: ParsedLength | undefined, baseSize: number): number;
|
|
115
|
+
/**
|
|
116
|
+
* Flattens a relative layout into the coordinate system of its reference rectangle.
|
|
117
|
+
*
|
|
118
|
+
* **Core Logic:**
|
|
119
|
+
* This function takes a layout that is defined relative to `refRect` (the "guest" space)
|
|
120
|
+
* and calculates its equivalent position in the coordinate space that `refRect`
|
|
121
|
+
* itself inhabits (the "host" space).
|
|
122
|
+
*
|
|
123
|
+
* It resolves mixed units, calculates dimensions based on directional constraints
|
|
124
|
+
* (like stretching via left+right), and returns a normalized box where all values
|
|
125
|
+
* are absolute pixel strings.
|
|
126
|
+
*
|
|
127
|
+
* @param layout - The layout properties relative to the reference rectangle.
|
|
128
|
+
* @param refRect - The host rectangle defining the reference coordinate system.
|
|
129
|
+
* @returns A normalized `LayoutBox` with pixel-based `left`, `top`, `width`, and `height`.
|
|
130
|
+
*/
|
|
131
|
+
declare function flattenToHostLayout(layout: LayoutBox, refRect: AbstractRect): LayoutBox;
|
|
132
|
+
|
|
104
133
|
/**
|
|
105
134
|
* Recursively penetrates Shadow DOM boundaries to find the deepest element at the
|
|
106
135
|
* specified viewport coordinates.
|
|
@@ -135,7 +164,7 @@ declare const smartQuerySelector: (selector: string) => Element | null;
|
|
|
135
164
|
/**
|
|
136
165
|
* Creates a StickyProvider pre-configured for the Web environment.
|
|
137
166
|
*/
|
|
138
|
-
declare const createWebStickyProvider: (selector: string) => StickyProvider
|
|
167
|
+
declare const createWebStickyProvider: (selector: string) => StickyProvider<Element>;
|
|
139
168
|
|
|
140
169
|
/**
|
|
141
170
|
* A centralized observation pool for DOM elements.
|
|
@@ -149,7 +178,7 @@ declare const createWebStickyProvider: (selector: string) => StickyProvider;
|
|
|
149
178
|
* framework adapters (like Vue or React) where DOM references may become unstable
|
|
150
179
|
* during unmounting.
|
|
151
180
|
*/
|
|
152
|
-
declare class ElementObserver {
|
|
181
|
+
declare class ElementObserver implements IElementObserver<Element> {
|
|
153
182
|
private _ro;
|
|
154
183
|
private _roRegistry;
|
|
155
184
|
private _elToRoCb;
|
|
@@ -158,40 +187,10 @@ declare class ElementObserver {
|
|
|
158
187
|
private _elToIoCb;
|
|
159
188
|
private constructor();
|
|
160
189
|
static getInstance(): ElementObserver;
|
|
161
|
-
/**
|
|
162
|
-
* Starts observing size changes for a specific element.
|
|
163
|
-
*
|
|
164
|
-
* @param uid - The unique entity ID associated with the observation.
|
|
165
|
-
* @param el - The target DOM element to observe.
|
|
166
|
-
* @param cb - Callback triggered when the element's size changes.
|
|
167
|
-
*/
|
|
168
190
|
observeResize(uid: string, el: Element, cb: () => void): void;
|
|
169
|
-
/**
|
|
170
|
-
* Stops observing size changes for the entity identified by the UID.
|
|
171
|
-
*
|
|
172
|
-
* @param uid - The unique entity ID to unregister.
|
|
173
|
-
*/
|
|
174
191
|
unobserveResize(uid: string): void;
|
|
175
|
-
/**
|
|
176
|
-
* Starts observing visibility (intersection) changes for a specific element.
|
|
177
|
-
*
|
|
178
|
-
* @param uid - The unique entity ID associated with the observation.
|
|
179
|
-
* @param el - The target DOM element to observe.
|
|
180
|
-
* @param cb - Callback triggered when visibility enters or exits the viewport.
|
|
181
|
-
*/
|
|
182
192
|
observeIntersect(uid: string, el: Element, cb: (isIntersecting: boolean) => void): void;
|
|
183
|
-
/**
|
|
184
|
-
* Stops observing intersection changes for the entity identified by the UID.
|
|
185
|
-
*
|
|
186
|
-
* @param uid - The unique entity ID to unregister.
|
|
187
|
-
*/
|
|
188
193
|
unobserveIntersect(uid: string): void;
|
|
189
|
-
/**
|
|
190
|
-
* Disconnects all observers (RO and IO) associated with a specific UID.
|
|
191
|
-
* Usually called during component destruction for thorough cleanup.
|
|
192
|
-
*
|
|
193
|
-
* @param uid - The unique entity ID to fully disconnect.
|
|
194
|
-
*/
|
|
195
194
|
disconnect(uid: string): void;
|
|
196
195
|
}
|
|
197
196
|
|
|
@@ -258,6 +257,76 @@ declare class GamepadManager {
|
|
|
258
257
|
private triggerVirtualEntity;
|
|
259
258
|
}
|
|
260
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Global Iframe Manager.
|
|
262
|
+
*
|
|
263
|
+
* Manages cross-origin communication between the host page and embedded iframes.
|
|
264
|
+
* Handles coordinate transformation, security whitelisting, and spatial tracking.
|
|
265
|
+
*/
|
|
266
|
+
declare class IframeManager {
|
|
267
|
+
/** Whitelist of trusted origins for postMessage communication */
|
|
268
|
+
private trustedOrigins;
|
|
269
|
+
/** Cache for verified and managed iframes mapping Element -> Metadata */
|
|
270
|
+
private managedIframes;
|
|
271
|
+
/** Use WeakSet to track denied iframes to avoid repeated parsing and prevent memory leaks */
|
|
272
|
+
private deniedIframes;
|
|
273
|
+
private constructor();
|
|
274
|
+
/**
|
|
275
|
+
* Retrieves the global singleton instance of IframeManager.
|
|
276
|
+
*/
|
|
277
|
+
static getInstance(): IframeManager;
|
|
278
|
+
/**
|
|
279
|
+
* Adds a domain to the trusted whitelist.
|
|
280
|
+
*
|
|
281
|
+
* @param origin - The origin to trust (e.g., "https://example.com").
|
|
282
|
+
*/
|
|
283
|
+
addTrustedOrigin(origin: string): void;
|
|
284
|
+
/**
|
|
285
|
+
* Core admission logic: Checks cache -> Validates whitelist -> Starts monitoring.
|
|
286
|
+
*
|
|
287
|
+
* @internal
|
|
288
|
+
* @param iframe - The iframe element to verify.
|
|
289
|
+
* @returns Verified cache data or null if untrusted/invalid.
|
|
290
|
+
*/
|
|
291
|
+
private getVerifiedIframeData;
|
|
292
|
+
/**
|
|
293
|
+
* Transforms and forwards a pointer event to the target iframe.
|
|
294
|
+
*
|
|
295
|
+
* @param iframe - The destination iframe.
|
|
296
|
+
* @param type - Event type (e.g., 'pointermove').
|
|
297
|
+
* @param globalX - X coordinate in the host viewport.
|
|
298
|
+
* @param globalY - Y coordinate in the host viewport.
|
|
299
|
+
* @param opts - Original event options.
|
|
300
|
+
*/
|
|
301
|
+
forwardPointerEvent(iframe: HTMLIFrameElement, type: string, globalX: number, globalY: number, opts: any): void;
|
|
302
|
+
/**
|
|
303
|
+
* Forwards a keyboard event to the target iframe.
|
|
304
|
+
*
|
|
305
|
+
* @param iframe - The destination iframe.
|
|
306
|
+
* @param type - Event type (e.g., 'keydown').
|
|
307
|
+
* @param payload - Key mapping data.
|
|
308
|
+
*/
|
|
309
|
+
forwardKeyboardEvent(iframe: HTMLIFrameElement, type: string, payload: any): void;
|
|
310
|
+
private captureRect;
|
|
311
|
+
private getSecureOrigin;
|
|
312
|
+
/**
|
|
313
|
+
* Forcefully invalidates and refreshes all cached iframe rectangles.
|
|
314
|
+
* Called during global window resize or scroll events.
|
|
315
|
+
*/
|
|
316
|
+
markAllRectDirty(): void;
|
|
317
|
+
/**
|
|
318
|
+
* Unregisters an iframe and disconnects its observers.
|
|
319
|
+
*
|
|
320
|
+
* @param iframe - The element to remove.
|
|
321
|
+
* @param uid - The unique ID associated with the iframe.
|
|
322
|
+
*/
|
|
323
|
+
private unmanageIframe;
|
|
324
|
+
/**
|
|
325
|
+
* Fully clears the manager state.
|
|
326
|
+
*/
|
|
327
|
+
clearAll(): void;
|
|
328
|
+
}
|
|
329
|
+
|
|
261
330
|
/**
|
|
262
331
|
* Global Input Manager Singleton.
|
|
263
332
|
*
|
|
@@ -303,4 +372,4 @@ declare class WindowManager {
|
|
|
303
372
|
destroy(): void;
|
|
304
373
|
}
|
|
305
374
|
|
|
306
|
-
export { ElementObserver, GamepadManager, WindowManager, createPointerBridge, createWebStickyProvider, dispatchKeyboardEvent, dispatchPointerEventAtPos, focusElement, getDeepActiveElement, getDeepElement, reclaimFocusAtPos, safeReleaseCapture, safeSetCapture, smartQuerySelector, supportsContainerQueries };
|
|
375
|
+
export { ElementObserver, GamepadManager, IframeManager, WindowManager, createPointerBridge, createWebStickyProvider, dispatchKeyboardEvent, dispatchPointerEventAtPos, flattenToHostLayout, focusElement, getDeepActiveElement, getDeepElement, reclaimFocusAtPos, safeReleaseCapture, safeSetCapture, smartQuerySelector, supportsContainerQueries, toAbsolutePx };
|
package/dist/dom/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { G as GamepadMappingConfig } from '../index-DVegtw8s.js';
|
|
1
|
+
import { f as IPointerHandler, S as StickyProvider, a as IElementObserver } from '../sticky-d_z_GU83.js';
|
|
2
|
+
import { L as LayoutBox, a as AbstractRect, P as ParsedLength, G as GamepadMappingConfig } from '../index-Dd0aHJaA.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Forcefully focuses an element.
|
|
@@ -101,6 +100,36 @@ declare const safeReleaseCapture: (el: EventTarget | null, pointerId: number) =>
|
|
|
101
100
|
|
|
102
101
|
declare const supportsContainerQueries: () => boolean;
|
|
103
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Converts various CSS units into absolute pixel values based on the browser environment.
|
|
105
|
+
*
|
|
106
|
+
* Supports: `px`, `%` (relative to `baseSize`), `vw`, `vh`, `vmin`, `vmax`, `rem`, and `em`.
|
|
107
|
+
*
|
|
108
|
+
* **Note:** `rem` and `em` are both resolved using the root element's font size for simplicity.
|
|
109
|
+
*
|
|
110
|
+
* @param p - The parsed length object containing the value and unit.
|
|
111
|
+
* @param baseSize - The reference dimension (width or height) used to resolve percentage (%) values.
|
|
112
|
+
* @returns The computed numerical value in pixels.
|
|
113
|
+
*/
|
|
114
|
+
declare function toAbsolutePx(p: ParsedLength | undefined, baseSize: number): number;
|
|
115
|
+
/**
|
|
116
|
+
* Flattens a relative layout into the coordinate system of its reference rectangle.
|
|
117
|
+
*
|
|
118
|
+
* **Core Logic:**
|
|
119
|
+
* This function takes a layout that is defined relative to `refRect` (the "guest" space)
|
|
120
|
+
* and calculates its equivalent position in the coordinate space that `refRect`
|
|
121
|
+
* itself inhabits (the "host" space).
|
|
122
|
+
*
|
|
123
|
+
* It resolves mixed units, calculates dimensions based on directional constraints
|
|
124
|
+
* (like stretching via left+right), and returns a normalized box where all values
|
|
125
|
+
* are absolute pixel strings.
|
|
126
|
+
*
|
|
127
|
+
* @param layout - The layout properties relative to the reference rectangle.
|
|
128
|
+
* @param refRect - The host rectangle defining the reference coordinate system.
|
|
129
|
+
* @returns A normalized `LayoutBox` with pixel-based `left`, `top`, `width`, and `height`.
|
|
130
|
+
*/
|
|
131
|
+
declare function flattenToHostLayout(layout: LayoutBox, refRect: AbstractRect): LayoutBox;
|
|
132
|
+
|
|
104
133
|
/**
|
|
105
134
|
* Recursively penetrates Shadow DOM boundaries to find the deepest element at the
|
|
106
135
|
* specified viewport coordinates.
|
|
@@ -135,7 +164,7 @@ declare const smartQuerySelector: (selector: string) => Element | null;
|
|
|
135
164
|
/**
|
|
136
165
|
* Creates a StickyProvider pre-configured for the Web environment.
|
|
137
166
|
*/
|
|
138
|
-
declare const createWebStickyProvider: (selector: string) => StickyProvider
|
|
167
|
+
declare const createWebStickyProvider: (selector: string) => StickyProvider<Element>;
|
|
139
168
|
|
|
140
169
|
/**
|
|
141
170
|
* A centralized observation pool for DOM elements.
|
|
@@ -149,7 +178,7 @@ declare const createWebStickyProvider: (selector: string) => StickyProvider;
|
|
|
149
178
|
* framework adapters (like Vue or React) where DOM references may become unstable
|
|
150
179
|
* during unmounting.
|
|
151
180
|
*/
|
|
152
|
-
declare class ElementObserver {
|
|
181
|
+
declare class ElementObserver implements IElementObserver<Element> {
|
|
153
182
|
private _ro;
|
|
154
183
|
private _roRegistry;
|
|
155
184
|
private _elToRoCb;
|
|
@@ -158,40 +187,10 @@ declare class ElementObserver {
|
|
|
158
187
|
private _elToIoCb;
|
|
159
188
|
private constructor();
|
|
160
189
|
static getInstance(): ElementObserver;
|
|
161
|
-
/**
|
|
162
|
-
* Starts observing size changes for a specific element.
|
|
163
|
-
*
|
|
164
|
-
* @param uid - The unique entity ID associated with the observation.
|
|
165
|
-
* @param el - The target DOM element to observe.
|
|
166
|
-
* @param cb - Callback triggered when the element's size changes.
|
|
167
|
-
*/
|
|
168
190
|
observeResize(uid: string, el: Element, cb: () => void): void;
|
|
169
|
-
/**
|
|
170
|
-
* Stops observing size changes for the entity identified by the UID.
|
|
171
|
-
*
|
|
172
|
-
* @param uid - The unique entity ID to unregister.
|
|
173
|
-
*/
|
|
174
191
|
unobserveResize(uid: string): void;
|
|
175
|
-
/**
|
|
176
|
-
* Starts observing visibility (intersection) changes for a specific element.
|
|
177
|
-
*
|
|
178
|
-
* @param uid - The unique entity ID associated with the observation.
|
|
179
|
-
* @param el - The target DOM element to observe.
|
|
180
|
-
* @param cb - Callback triggered when visibility enters or exits the viewport.
|
|
181
|
-
*/
|
|
182
192
|
observeIntersect(uid: string, el: Element, cb: (isIntersecting: boolean) => void): void;
|
|
183
|
-
/**
|
|
184
|
-
* Stops observing intersection changes for the entity identified by the UID.
|
|
185
|
-
*
|
|
186
|
-
* @param uid - The unique entity ID to unregister.
|
|
187
|
-
*/
|
|
188
193
|
unobserveIntersect(uid: string): void;
|
|
189
|
-
/**
|
|
190
|
-
* Disconnects all observers (RO and IO) associated with a specific UID.
|
|
191
|
-
* Usually called during component destruction for thorough cleanup.
|
|
192
|
-
*
|
|
193
|
-
* @param uid - The unique entity ID to fully disconnect.
|
|
194
|
-
*/
|
|
195
194
|
disconnect(uid: string): void;
|
|
196
195
|
}
|
|
197
196
|
|
|
@@ -258,6 +257,76 @@ declare class GamepadManager {
|
|
|
258
257
|
private triggerVirtualEntity;
|
|
259
258
|
}
|
|
260
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Global Iframe Manager.
|
|
262
|
+
*
|
|
263
|
+
* Manages cross-origin communication between the host page and embedded iframes.
|
|
264
|
+
* Handles coordinate transformation, security whitelisting, and spatial tracking.
|
|
265
|
+
*/
|
|
266
|
+
declare class IframeManager {
|
|
267
|
+
/** Whitelist of trusted origins for postMessage communication */
|
|
268
|
+
private trustedOrigins;
|
|
269
|
+
/** Cache for verified and managed iframes mapping Element -> Metadata */
|
|
270
|
+
private managedIframes;
|
|
271
|
+
/** Use WeakSet to track denied iframes to avoid repeated parsing and prevent memory leaks */
|
|
272
|
+
private deniedIframes;
|
|
273
|
+
private constructor();
|
|
274
|
+
/**
|
|
275
|
+
* Retrieves the global singleton instance of IframeManager.
|
|
276
|
+
*/
|
|
277
|
+
static getInstance(): IframeManager;
|
|
278
|
+
/**
|
|
279
|
+
* Adds a domain to the trusted whitelist.
|
|
280
|
+
*
|
|
281
|
+
* @param origin - The origin to trust (e.g., "https://example.com").
|
|
282
|
+
*/
|
|
283
|
+
addTrustedOrigin(origin: string): void;
|
|
284
|
+
/**
|
|
285
|
+
* Core admission logic: Checks cache -> Validates whitelist -> Starts monitoring.
|
|
286
|
+
*
|
|
287
|
+
* @internal
|
|
288
|
+
* @param iframe - The iframe element to verify.
|
|
289
|
+
* @returns Verified cache data or null if untrusted/invalid.
|
|
290
|
+
*/
|
|
291
|
+
private getVerifiedIframeData;
|
|
292
|
+
/**
|
|
293
|
+
* Transforms and forwards a pointer event to the target iframe.
|
|
294
|
+
*
|
|
295
|
+
* @param iframe - The destination iframe.
|
|
296
|
+
* @param type - Event type (e.g., 'pointermove').
|
|
297
|
+
* @param globalX - X coordinate in the host viewport.
|
|
298
|
+
* @param globalY - Y coordinate in the host viewport.
|
|
299
|
+
* @param opts - Original event options.
|
|
300
|
+
*/
|
|
301
|
+
forwardPointerEvent(iframe: HTMLIFrameElement, type: string, globalX: number, globalY: number, opts: any): void;
|
|
302
|
+
/**
|
|
303
|
+
* Forwards a keyboard event to the target iframe.
|
|
304
|
+
*
|
|
305
|
+
* @param iframe - The destination iframe.
|
|
306
|
+
* @param type - Event type (e.g., 'keydown').
|
|
307
|
+
* @param payload - Key mapping data.
|
|
308
|
+
*/
|
|
309
|
+
forwardKeyboardEvent(iframe: HTMLIFrameElement, type: string, payload: any): void;
|
|
310
|
+
private captureRect;
|
|
311
|
+
private getSecureOrigin;
|
|
312
|
+
/**
|
|
313
|
+
* Forcefully invalidates and refreshes all cached iframe rectangles.
|
|
314
|
+
* Called during global window resize or scroll events.
|
|
315
|
+
*/
|
|
316
|
+
markAllRectDirty(): void;
|
|
317
|
+
/**
|
|
318
|
+
* Unregisters an iframe and disconnects its observers.
|
|
319
|
+
*
|
|
320
|
+
* @param iframe - The element to remove.
|
|
321
|
+
* @param uid - The unique ID associated with the iframe.
|
|
322
|
+
*/
|
|
323
|
+
private unmanageIframe;
|
|
324
|
+
/**
|
|
325
|
+
* Fully clears the manager state.
|
|
326
|
+
*/
|
|
327
|
+
clearAll(): void;
|
|
328
|
+
}
|
|
329
|
+
|
|
261
330
|
/**
|
|
262
331
|
* Global Input Manager Singleton.
|
|
263
332
|
*
|
|
@@ -303,4 +372,4 @@ declare class WindowManager {
|
|
|
303
372
|
destroy(): void;
|
|
304
373
|
}
|
|
305
374
|
|
|
306
|
-
export { ElementObserver, GamepadManager, WindowManager, createPointerBridge, createWebStickyProvider, dispatchKeyboardEvent, dispatchPointerEventAtPos, focusElement, getDeepActiveElement, getDeepElement, reclaimFocusAtPos, safeReleaseCapture, safeSetCapture, smartQuerySelector, supportsContainerQueries };
|
|
375
|
+
export { ElementObserver, GamepadManager, IframeManager, WindowManager, createPointerBridge, createWebStickyProvider, dispatchKeyboardEvent, dispatchPointerEventAtPos, flattenToHostLayout, focusElement, getDeepActiveElement, getDeepElement, reclaimFocusAtPos, safeReleaseCapture, safeSetCapture, smartQuerySelector, supportsContainerQueries, toAbsolutePx };
|
package/dist/dom/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'../chunk-ZM2LX5IW.mjs';import {k}from'../chunk-MKVX5ALC.mjs';import {a,h as h$1}from'../chunk-PACTGVBB.mjs';var m=(n,t,e="omnipad-prevent")=>{let i=document.elementsFromPoint(n,t).find(s=>!s.classList.contains(e));if(!i)return null;for(;i&&i.shadowRoot;){let a=i.shadowRoot.elementsFromPoint(n,t).find(l=>!l.classList.contains(e));if(!a||a===i)break;i=a;}return i},g=()=>{let n=document.activeElement;for(;n&&n.shadowRoot&&n.shadowRoot.activeElement;)n=n.shadowRoot.activeElement;return n},R=n=>{if(!n)return null;if(n.startsWith("#")){let t=n.slice(1),e=document.getElementById(t);if(e)return e}try{return document.querySelector(n)}catch{return null}};var x=n=>{g()!==n&&(n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus());},M=(n,t)=>{let e=new KeyboardEvent(n,{...t,which:t.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(e);},D=(n,t,e,r)=>{let i=m(t,e);if(!i)return;let s={bubbles:true,cancelable:true,composed:true,clientX:t,clientY:e,view:window,...r};if(n.startsWith("pointer")){i.dispatchEvent(new PointerEvent(n,{isPrimary:true,pointerId:9999,pointerType:"mouse",...s}));let a=n.replace("pointer","mouse");i.dispatchEvent(new MouseEvent(a,s));}else i.dispatchEvent(new MouseEvent(n,s));},L=(n,t,e)=>{let r=m(n,t);if(!r)return;g()!==r&&(x(r),e());};var w=(n,t)=>{if(n instanceof Element)try{n.setPointerCapture(t);}catch(e){import.meta.env?.DEV&&console.warn("[OmniPad-DOM] Failed to set pointer capture:",e);}},f=(n,t)=>{if(n instanceof Element&&n.hasPointerCapture(t))try{n.releasePointerCapture(t);}catch{}};function O(n,t={}){return {onPointerDown(e){if(!e.isTrusted||t?.requireDirectHit&&e.target!==e.currentTarget||n.activePointerId!=null)return;e.cancelable&&e.preventDefault(),e.stopPropagation();let r=e.currentTarget;r&&w(r,e.pointerId),n.onPointerDown(e);},onPointerMove(e){e.isTrusted&&(n.activePointerId!=null&&n.activePointerId!==e.pointerId||(e.cancelable&&e.preventDefault(),n.onPointerMove(e)));},onPointerUp(e){if(!e.isTrusted||n.activePointerId!=null&&n.activePointerId!==e.pointerId)return;e.cancelable&&e.preventDefault();let r=e.currentTarget;r&&f(r,e.pointerId),n.onPointerUp(e);},onPointerCancel(e){if(!e.isTrusted||n.activePointerId!=null&&n.activePointerId!==e.pointerId)return;let r=e.currentTarget;r&&f(r,e.pointerId),n.onPointerCancel(e);}}}var p,z=()=>(p!==void 0||(p=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),p);var U=n=>new k(n,t=>R(t),t=>t.getBoundingClientRect(),t=>document.contains(t));var h=Symbol.for("omnipad.element_observer.instance"),y=class n{constructor(){a(this,"_ro");a(this,"_roRegistry",new Map);a(this,"_elToRoCb",new WeakMap);a(this,"_io");a(this,"_ioRegistry",new Map);a(this,"_elToIoCb",new WeakMap);let t=a$1(e=>{for(let r of e)this._elToRoCb.get(r.target)?.();});this._ro=new ResizeObserver(e=>{t(e);}),this._io=new IntersectionObserver(e=>{for(let r of e)this._elToIoCb.get(r.target)?.(r.isIntersecting);},{threshold:0});}static getInstance(){let t=globalThis;return t[h]||(t[h]=new n),t[h]}observeResize(t,e,r){this.unobserveResize(t),this._roRegistry.set(t,e),this._elToRoCb.set(e,r),this._ro.observe(e);}unobserveResize(t){let e=this._roRegistry.get(t);e&&(this._ro.unobserve(e),this._elToRoCb.delete(e),this._roRegistry.delete(t));}observeIntersect(t,e,r){this.unobserveIntersect(t),this._ioRegistry.set(t,e),this._elToIoCb.set(e,r),this._io.observe(e);}unobserveIntersect(t){let e=this._ioRegistry.get(t);e&&(this._io.unobserve(e),this._elToIoCb.delete(e),this._ioRegistry.delete(t));}disconnect(t){this.unobserveResize(t),this.unobserveIntersect(t);}};var v=Symbol.for("omnipad.gamepad_manager.instance"),_={A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,Select:8,Start:9,L3:10,R3:11,Up:12,Down:13,Left:14,Right:15},P=class n{constructor(){a(this,"isRunning",false);a(this,"config",null);a(this,"lastButtonStates",[]);a(this,"loop",()=>{if(!this.isRunning)return;let t=navigator.getGamepads();this.config?.forEach((e,r)=>{let i=t[r];i&&i.connected&&e&&(this.lastButtonStates[r]||(this.lastButtonStates[r]=[]),this.processButtons(i,e,r),this.processDPad(i,e),this.processAxes(i,e));}),requestAnimationFrame(this.loop);});}static getInstance(){let t=globalThis;return t[v]||(t[v]=new n),t[v]}setConfig(t){this.config=t;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",t=>{import.meta.env?.DEV&&console.log("[OmniPad-DOM] Gamepad Connected:",t.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{import.meta.env?.DEV&&console.log("[OmniPad-DOM] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(t,e,r){e.buttons&&Object.entries(e.buttons).forEach(([i,s])=>{let a=_[i];if(a===void 0||!t.buttons[a])return;let l=t.buttons[a].pressed,u=this.lastButtonStates[r][a]||false;l&&!u?this.triggerVirtualEntity(s,"down"):!l&&u&&this.triggerVirtualEntity(s,"up"),this.lastButtonStates[r][a]=l;});}processDPad(t,e){let r=e?.dpad;if(!r)return;let i=t.buttons[12]?.pressed?-1:0,s=t.buttons[13]?.pressed?1:0,a=t.buttons[14]?.pressed?-1:0,l=t.buttons[15]?.pressed?1:0,u=a+l,C=i+s;this.triggerVirtualEntity(r,"vector",{x:u,y:C});}processAxes(t,e){let r=e?.deadzone??.1;if(e?.leftStick){let i=Math.abs(t.axes[0])>r?t.axes[0]:0,s=Math.abs(t.axes[1])>r?t.axes[1]:0;this.triggerVirtualEntity(e.leftStick,"vector",{x:i,y:s});}if(e?.rightStick){let i=Math.abs(t.axes[2])>r?t.axes[2]:0,s=Math.abs(t.axes[3])>r?t.axes[3]:0;this.triggerVirtualEntity(e.rightStick,"vector",{x:i,y:s});}}triggerVirtualEntity(t,e,r){let i=h$1.getInstance().getEntity(t);!i||i.activePointerId!=null||(e==="down"&&typeof i.triggerDown=="function"&&i.triggerDown(),e==="up"&&typeof i.triggerUp=="function"&&i.triggerUp(),e==="vector"&&typeof i.triggerVector=="function"&&r&&i.triggerVector(r.x,r.y));}};var b=Symbol.for("omnipad.window_manager.instance"),I=class n{constructor(){a(this,"_isListening",false);a(this,"throttledReset");a(this,"handleGlobalReset",()=>{import.meta.env?.DEV&&console.debug("[OmniPad-Core] Safety reset triggered by environment change."),h$1.getInstance().resetAll(),h$1.getInstance().markAllRectDirty();});a(this,"handleResizeReset",()=>{this.throttledReset(null);});a(this,"handleBlurReset",()=>{this.handleGlobalReset();});a(this,"handleScrollReset",()=>{this.throttledReset(null);});a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=a$1(()=>{this.handleGlobalReset();});}static getInstance(){let t=globalThis;return t[b]||(t[b]=new n),t[b]}init(){this._isListening||(window.addEventListener("resize",this.handleResizeReset),window.addEventListener("blur",this.handleBlurReset),window.addEventListener("scroll",this.handleScrollReset,{capture:true,passive:true}),document.addEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=true,import.meta.env?.DEV&&console.log("[OmniPad-Core] Global WindowManager monitoring started."));}async toggleFullscreen(t){let e=t||document.documentElement;try{document.fullscreenElement?(this.handleGlobalReset(),await document.exitFullscreen()):(this.handleGlobalReset(),await e.requestFullscreen());}catch(r){console.error("[OmniPad-Core] Fullscreen toggle failed:",r);}}isFullscreen(){return !!document.fullscreenElement}destroy(){window.removeEventListener("resize",this.handleResizeReset),window.removeEventListener("blur",this.handleBlurReset),window.removeEventListener("scroll",this.handleScrollReset,{capture:true}),window.removeEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=false;}};export{y as ElementObserver,P as GamepadManager,I as WindowManager,O as createPointerBridge,U as createWebStickyProvider,M as dispatchKeyboardEvent,D as dispatchPointerEventAtPos,x as focusElement,g as getDeepActiveElement,m as getDeepElement,L as reclaimFocusAtPos,f as safeReleaseCapture,w as safeSetCapture,R as smartQuerySelector,z as supportsContainerQueries};
|
|
1
|
+
import {c,e,b as b$2}from'../chunk-YAS6LFBF.mjs';import {a as a$1}from'../chunk-J5SVBM6K.mjs';import {g,c as c$1,O}from'../chunk-EYKCVOUA.mjs';import {b as b$1,e as e$1,a as a$2,g as g$1,c as c$2}from'../chunk-6XY2ZHZ3.mjs';export{b as getDeepActiveElement,a as getDeepElement,c as smartQuerySelector}from'../chunk-6XY2ZHZ3.mjs';import {a,b}from'../chunk-HQNUZXP5.mjs';var I=Symbol.for("omnipad.element_observer.instance"),m=class r{constructor(){a(this,"_ro");a(this,"_roRegistry",new Map);a(this,"_elToRoCb",new WeakMap);a(this,"_io");a(this,"_ioRegistry",new Map);a(this,"_elToIoCb",new WeakMap);let e$1=e(t=>{for(let n of t)this._elToRoCb.get(n.target)?.();});this._ro=new ResizeObserver(t=>{e$1(t);}),this._io=new IntersectionObserver(t=>{for(let n of t)this._elToIoCb.get(n.target)?.(n.isIntersecting);},{threshold:0});}static getInstance(){let e=globalThis;return e[I]||(e[I]=new r),e[I]}observeResize(e,t,n){this.unobserveResize(e),this._roRegistry.set(e,t),this._elToRoCb.set(t,n),this._ro.observe(t);}unobserveResize(e){let t=this._roRegistry.get(e);t&&(this._ro.unobserve(t),this._elToRoCb.delete(t),this._roRegistry.delete(e));}observeIntersect(e,t,n){this.unobserveIntersect(e),this._ioRegistry.set(e,t),this._elToIoCb.set(t,n),this._io.observe(t);}unobserveIntersect(e){let t=this._ioRegistry.get(e);t&&(this._io.unobserve(t),this._elToIoCb.delete(t),this._ioRegistry.delete(e));}disconnect(e){this.unobserveResize(e),this.unobserveIntersect(e);}};var R=Symbol.for("omnipad.iframe_manager.instance"),u=class r{constructor(){a(this,"trustedOrigins",new Set);a(this,"managedIframes",new Map);a(this,"deniedIframes",new WeakSet);this.trustedOrigins.add(window.location.origin);}static getInstance(){let e=globalThis;return e[R]||(e[R]=new r),e[R]}addTrustedOrigin(e){e==="*"&&import.meta.env?.DEV&&console.warn('[OmniPad-Security] Wildcard origin "*" is dangerous!'),this.trustedOrigins.add(e);}getVerifiedIframeData(e){let t=this.managedIframes.get(e);if(t)return t;if(this.deniedIframes.has(e))return null;let n=this.getSecureOrigin(e);if(!(this.trustedOrigins.has("*")||this.trustedOrigins.has(n)))return import.meta.env?.DEV&&console.warn(`[OmniPad-Security] Blocking untrusted iframe from origin: ${n}`),this.deniedIframes.add(e),null;let s=g("iframe-proxy"),a=this.captureRect(e),c={uid:s,rect:a,origin:n,isVisible:true};this.managedIframes.set(e,c);let l=m.getInstance();return l.observeResize(s,e,()=>{c.rect=this.captureRect(e);}),l.observeIntersect(s,e,g=>{c.isVisible=g,g||(import.meta.env?.DEV&&console.debug(`[OmniPad-IPC] Iframe ${s} hidden, sending safety reset.`),this.forwardKeyboardEvent(e,c$1.KEYUP,{all:true}));}),c}forwardPointerEvent(e,t,n,i,s){if(!e.contentWindow||!Number.isFinite(n)||!Number.isFinite(i))return;let a=this.getVerifiedIframeData(e);if(!a)return;let c=n-a.rect.left,l=i-a.rect.top;e.contentWindow.postMessage({signature:b,type:"pointer",action:t,payload:{x:c,y:l,opts:s}},a.origin);}forwardKeyboardEvent(e,t,n){if(!e.contentWindow)return;let i=this.getVerifiedIframeData(e);i&&e.contentWindow.postMessage({signature:b,type:"keyboard",action:t,payload:n},i.origin);}captureRect(e){let t=e.getBoundingClientRect();return a$1(t)}getSecureOrigin(e){try{if(!e.src)return "null";let t=new URL(e.src,window.location.href);return ["about:","blob:","data:"].includes(t.protocol)?"null":t.origin}catch{return "null"}}markAllRectDirty(){import.meta.env?.DEV&&console.debug("[OmniPad-IPC] Refreshing all iframe rects due to environment change."),this.managedIframes.forEach((e,t)=>{if(!document.contains(t)){this.unmanageIframe(t,e.uid);return}e.rect=this.captureRect(t);});}unmanageIframe(e,t){m.getInstance().disconnect(t),this.managedIframes.set(e,void 0),this.managedIframes.delete(e),this.deniedIframes.delete(e);}clearAll(){this.managedIframes.forEach((e,t)=>{this.unmanageIframe(t,e.uid);});}};var V=r=>{b$1()!==r&&(r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus());},J=(r,e)=>{let t=b$1();if(t&&t.tagName.toLowerCase()==="iframe"){u.getInstance().forwardKeyboardEvent(t,r,e);return}e$1(r,e);},Z=(r,e,t,n)=>{let i=a$2(e,t);if(i){if(i.tagName.toLowerCase()==="iframe"){u.getInstance().forwardPointerEvent(i,r,e,t,n);return}g$1(i,r,e,t,n);}},ee=(r,e,t)=>{let n=a$2(r,e);if(!n)return;b$1()!==n&&(V(n),t());};var _=(r,e)=>{if(r instanceof Element)try{r.setPointerCapture(e);}catch(t){import.meta.env?.DEV&&console.warn("[OmniPad-DOM] Failed to set pointer capture:",t);}},w=(r,e)=>{if(r instanceof Element&&r.hasPointerCapture(e))try{r.releasePointerCapture(e);}catch{}};function ie(r,e={}){return {onPointerDown(t){if(!t.isTrusted||e?.requireDirectHit&&t.target!==t.currentTarget||r.activePointerId!=null)return;t.cancelable&&t.preventDefault(),t.stopPropagation();let n=t.currentTarget;n&&_(n,t.pointerId),r.onPointerDown(t);},onPointerMove(t){t.isTrusted&&(r.activePointerId!=null&&r.activePointerId!==t.pointerId||(t.cancelable&&t.preventDefault(),r.onPointerMove(t)));},onPointerUp(t){if(!t.isTrusted||r.activePointerId!=null&&r.activePointerId!==t.pointerId)return;t.cancelable&&t.preventDefault();let n=t.currentTarget;n&&w(n,t.pointerId),r.onPointerUp(t);},onPointerCancel(t){if(!t.isTrusted||r.activePointerId!=null&&r.activePointerId!==t.pointerId)return;let n=t.currentTarget;n&&w(n,t.pointerId),r.onPointerCancel(t);}}}var v,se=()=>(v!==void 0||(v=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),v);function B(r,e){if(!r)return 0;switch(r.unit){case "px":return r.value;case "%":return r.value/100*e;case "vw":return r.value/100*window.innerWidth;case "vh":return r.value/100*window.innerHeight;case "vmin":return r.value/100*Math.min(window.innerWidth,window.innerHeight);case "vmax":return r.value/100*Math.max(window.innerWidth,window.innerHeight);case "rem":case "em":{let t=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return r.value*t}default:return r.value}}function le(r,e){return O(r,e,B)}var fe=r=>new c(r,e=>c$2(e),e=>{let t=e.getBoundingClientRect();return a$1(t)},e=>document.contains(e));var y=Symbol.for("omnipad.gamepad_manager.instance"),G={A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,Select:8,Start:9,L3:10,R3:11,Up:12,Down:13,Left:14,Right:15},D=class r{constructor(){a(this,"isRunning",false);a(this,"config",null);a(this,"lastButtonStates",[]);a(this,"loop",()=>{if(!this.isRunning)return;let e=navigator.getGamepads();this.config?.forEach((t,n)=>{let i=e[n];i&&i.connected&&t&&(this.lastButtonStates[n]||(this.lastButtonStates[n]=[]),this.processButtons(i,t,n),this.processDPad(i,t),this.processAxes(i,t));}),requestAnimationFrame(this.loop);});}static getInstance(){let e=globalThis;return e[y]||(e[y]=new r),e[y]}setConfig(e){this.config=e;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",e=>{import.meta.env?.DEV&&console.log("[OmniPad-DOM] Gamepad Connected:",e.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{import.meta.env?.DEV&&console.log("[OmniPad-DOM] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(e,t,n){t.buttons&&Object.entries(t.buttons).forEach(([i,s])=>{let a=G[i];if(a===void 0||!e.buttons[a])return;let c=e.buttons[a].pressed,l=this.lastButtonStates[n][a]||false;c&&!l?this.triggerVirtualEntity(s,"down"):!c&&l&&this.triggerVirtualEntity(s,"up"),this.lastButtonStates[n][a]=c;});}processDPad(e,t){let n=t?.dpad;if(!n)return;let i=e.buttons[12]?.pressed?-1:0,s=e.buttons[13]?.pressed?1:0,a=e.buttons[14]?.pressed?-1:0,c=e.buttons[15]?.pressed?1:0,l=a+c,g=i+s;this.triggerVirtualEntity(n,"vector",{x:l,y:g});}processAxes(e,t){let n=t?.deadzone??.1;if(t?.leftStick){let i=Math.abs(e.axes[0])>n?e.axes[0]:0,s=Math.abs(e.axes[1])>n?e.axes[1]:0;this.triggerVirtualEntity(t.leftStick,"vector",{x:i,y:s});}if(t?.rightStick){let i=Math.abs(e.axes[2])>n?e.axes[2]:0,s=Math.abs(e.axes[3])>n?e.axes[3]:0;this.triggerVirtualEntity(t.rightStick,"vector",{x:i,y:s});}}triggerVirtualEntity(e,t,n){let i=b$2.getInstance().getEntity(e);!i||i.activePointerId!=null||(t==="down"&&typeof i.triggerDown=="function"&&i.triggerDown(),t==="up"&&typeof i.triggerUp=="function"&&i.triggerUp(),t==="vector"&&typeof i.triggerVector=="function"&&n&&i.triggerVector(n.x,n.y));}};var P=Symbol.for("omnipad.window_manager.instance"),A=class r{constructor(){a(this,"_isListening",false);a(this,"throttledReset");a(this,"handleGlobalReset",()=>{import.meta.env?.DEV&&console.debug("[OmniPad-DOM] Safety reset triggered by environment change."),b$2.getInstance().resetAll(),b$2.getInstance().markAllRectDirty(),u.getInstance().markAllRectDirty();});a(this,"handleResizeReset",()=>{this.throttledReset(null);});a(this,"handleBlurReset",()=>{this.handleGlobalReset();});a(this,"handleScrollReset",()=>{this.throttledReset(null);});a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=e(()=>{this.handleGlobalReset();});}static getInstance(){let e=globalThis;return e[P]||(e[P]=new r),e[P]}init(){this._isListening||(window.addEventListener("resize",this.handleResizeReset),window.addEventListener("blur",this.handleBlurReset),window.addEventListener("scroll",this.handleScrollReset,{capture:true,passive:true}),document.addEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=true,import.meta.env?.DEV&&console.log("[OmniPad-DOM] Global WindowManager monitoring started."));}async toggleFullscreen(e){let t=e||document.documentElement;try{document.fullscreenElement?(this.handleGlobalReset(),await document.exitFullscreen()):(this.handleGlobalReset(),await t.requestFullscreen());}catch(n){console.error("[OmniPad-DOM] Fullscreen toggle failed:",n);}}isFullscreen(){return !!document.fullscreenElement}destroy(){window.removeEventListener("resize",this.handleResizeReset),window.removeEventListener("blur",this.handleBlurReset),window.removeEventListener("scroll",this.handleScrollReset,{capture:true}),window.removeEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=false;}};export{m as ElementObserver,D as GamepadManager,u as IframeManager,A as WindowManager,ie as createPointerBridge,fe as createWebStickyProvider,J as dispatchKeyboardEvent,Z as dispatchPointerEventAtPos,le as flattenToHostLayout,V as focusElement,ee as reclaimFocusAtPos,w as safeReleaseCapture,_ as safeSetCapture,se as supportsContainerQueries,B as toAbsolutePx};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk42WBUPM3_cjs=require('../chunk-42WBUPM3.cjs'),chunkHCOFKHVV_cjs=require('../chunk-HCOFKHVV.cjs');var d=false,t=[];function g(c){d||(t=c.allowedOrigins,d=true,window.addEventListener("message",r=>{if(t!=="*"){if(!t.includes(r.origin)){undefined?.DEV&&console.warn(`[OmniPad-IPC] Blocked message from unauthorized origin: ${r.origin}`);return}}else if(!undefined?.DEV)throw new Error("Security Risk: Origin wildcard '*' is forbidden in production.");let e=r.data;if(e?.signature===chunkHCOFKHVV_cjs.b)try{if(e.type==="pointer"){let{x:i,y:o,opts:l}=e.payload;if(!Number.isFinite(i)||!Number.isFinite(o))return;chunk42WBUPM3_cjs.f(e.action,i,o,l);}else e.type==="keyboard"&&chunk42WBUPM3_cjs.d(e.action,e.payload);}catch(i){console.error("[OmniPad-IPC] Error dispatching guest event:",i);}}),undefined?.DEV&&console.log("[OmniPad-IPC] Iframe receiver active and listening for Host commands."));}exports.initIframeReceiver=g;
|