@omnipad/core 0.4.5 → 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 -0
- package/dist/dom/index.d.cts +375 -0
- package/dist/dom/index.d.ts +375 -0
- package/dist/dom/index.mjs +1 -0
- 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-CT1fDlB9.d.cts → index-Dd0aHJaA.d.cts} +752 -181
- package/dist/{index-CT1fDlB9.d.ts → index-Dd0aHJaA.d.ts} +752 -181
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +270 -157
- package/dist/index.d.ts +270 -157
- 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 +140 -173
- package/dist/utils/index.d.ts +140 -173
- package/dist/utils/index.mjs +1 -1
- package/package.json +17 -1
- package/dist/chunk-4J2ZANLB.cjs +0 -1
- package/dist/chunk-W7OR5ESR.mjs +0 -1
|
@@ -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};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,375 @@
|
|
|
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';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Forcefully focuses an element.
|
|
6
|
+
* Automatically handles the 'tabindex' attribute to ensure non-focusable elements (like Canvas)
|
|
7
|
+
* can receive focus.
|
|
8
|
+
*
|
|
9
|
+
* @param el - The target HTMLElement to focus.
|
|
10
|
+
*/
|
|
11
|
+
declare const focusElement: (el: HTMLElement) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Dispatches a synthetic KeyboardEvent to the window object.
|
|
14
|
+
*
|
|
15
|
+
* @param type - The event type, e.g., 'keydown' or 'keyup'.
|
|
16
|
+
* @param payload - Key mapping data including key, code, and legacy keyCode.
|
|
17
|
+
*/
|
|
18
|
+
declare const dispatchKeyboardEvent: (type: string, payload: {
|
|
19
|
+
key: string;
|
|
20
|
+
code: string;
|
|
21
|
+
keyCode: number;
|
|
22
|
+
}) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Dispatches a high-fidelity sequence of Pointer and Mouse events at specific pixel coordinates.
|
|
25
|
+
* Finds the target element dynamically at the moment of dispatch.
|
|
26
|
+
*
|
|
27
|
+
* @param type - The event type (should start with 'pointer' for best compatibility).
|
|
28
|
+
* @param x - Viewport X coordinate (px).
|
|
29
|
+
* @param y - Viewport Y coordinate (px).
|
|
30
|
+
* @param opts - Additional PointerEvent options (button, pressure, etc.).
|
|
31
|
+
*/
|
|
32
|
+
declare const dispatchPointerEventAtPos: (type: string, x: number, y: number, opts: {
|
|
33
|
+
button: number;
|
|
34
|
+
buttons: number;
|
|
35
|
+
pressure: number;
|
|
36
|
+
}) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Reclaims browser focus for the element located at the specified viewport coordinates.
|
|
39
|
+
*
|
|
40
|
+
* This utility identifies the deepest element (penetrating Shadow DOM) at the given position
|
|
41
|
+
* and ensures it becomes the active element. It is essential for ensuring that
|
|
42
|
+
* game engines (like Ruffle) receive keyboard events immediately after a virtual interaction.
|
|
43
|
+
*
|
|
44
|
+
* @param x - The horizontal coordinate relative to the viewport.
|
|
45
|
+
* @param y - The vertical coordinate relative to the viewport.
|
|
46
|
+
* @returns True if the focus was successfully moved to the target; false if it was already focused or no target found.
|
|
47
|
+
*/
|
|
48
|
+
declare const reclaimFocusAtPos: (x: number, y: number, callback: () => void) => void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates a standardized bridge between native DOM PointerEvents and Core abstract handlers.
|
|
52
|
+
* Handles event prevention, stop propagation, pointer capture, and multi-touch filtering.
|
|
53
|
+
*
|
|
54
|
+
* @param coreHandler - The logic core instance that implements IPointerHandler.
|
|
55
|
+
* @param getElement - A getter function to retrieve the DOM element for pointer capture.
|
|
56
|
+
* @returns An object containing mapped event handlers for Vue/React template binding.
|
|
57
|
+
*/
|
|
58
|
+
declare function createPointerBridge(coreHandler: IPointerHandler & {
|
|
59
|
+
activePointerId?: number | null;
|
|
60
|
+
}, options?: {
|
|
61
|
+
/** Respond only to direct clicks (without responding to events bubbled up from child elements) */
|
|
62
|
+
requireDirectHit?: boolean;
|
|
63
|
+
}): {
|
|
64
|
+
/**
|
|
65
|
+
* Entry point for a pointer interaction.
|
|
66
|
+
* Establishes capture and initializes core logic.
|
|
67
|
+
*/
|
|
68
|
+
onPointerDown(e: PointerEvent): void;
|
|
69
|
+
/**
|
|
70
|
+
* Continuous movement handling.
|
|
71
|
+
* Throttling should be handled within the core implementation.
|
|
72
|
+
*/
|
|
73
|
+
onPointerMove(e: PointerEvent): void;
|
|
74
|
+
/**
|
|
75
|
+
* Successful interaction completion.
|
|
76
|
+
* Filters by pointerId to ensure only the capturing finger triggers release.
|
|
77
|
+
*/
|
|
78
|
+
onPointerUp(e: PointerEvent): void;
|
|
79
|
+
/**
|
|
80
|
+
* System-level interaction cancellation (e.g., alert popups, browser gestures).
|
|
81
|
+
*/
|
|
82
|
+
onPointerCancel(e: PointerEvent): void;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Safely sets pointer capture on an element.
|
|
87
|
+
*
|
|
88
|
+
* @param el - The target element to capture the pointer.
|
|
89
|
+
* @param pointerId - The unique ID of the pointer (from PointerEvent).
|
|
90
|
+
*/
|
|
91
|
+
declare const safeSetCapture: (el: EventTarget | null, pointerId: number) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Safely releases pointer capture from an element.
|
|
94
|
+
* Checks for current capture state and wraps in try-catch to prevent crashes.
|
|
95
|
+
*
|
|
96
|
+
* @param el - The target element.
|
|
97
|
+
* @param pointerId - The unique ID of the pointer to release.
|
|
98
|
+
*/
|
|
99
|
+
declare const safeReleaseCapture: (el: EventTarget | null, pointerId: number) => void;
|
|
100
|
+
|
|
101
|
+
declare const supportsContainerQueries: () => boolean;
|
|
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
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Recursively penetrates Shadow DOM boundaries to find the deepest element at the
|
|
135
|
+
* specified viewport coordinates.
|
|
136
|
+
*
|
|
137
|
+
* @param x - Viewport X coordinate (px)
|
|
138
|
+
* @param y - Viewport Y coordinate (px)
|
|
139
|
+
* @param ignoreClass - Style class of DOM elements to be ignored
|
|
140
|
+
* @returns The deepmost Element or null if none found at the position.
|
|
141
|
+
*/
|
|
142
|
+
declare const getDeepElement: (x: number, y: number, ignoreClass?: string) => Element | null;
|
|
143
|
+
/**
|
|
144
|
+
* Recursively finds the truly focused element by traversing Shadow DOM boundaries.
|
|
145
|
+
*
|
|
146
|
+
* @returns The deepmost active Element in focus or null.
|
|
147
|
+
*/
|
|
148
|
+
declare const getDeepActiveElement: () => Element | null;
|
|
149
|
+
/**
|
|
150
|
+
* A robust wrapper for selecting a single DOM element.
|
|
151
|
+
*
|
|
152
|
+
*
|
|
153
|
+
* @param selector - A string containing one or more selectors to match.
|
|
154
|
+
* @returns The first {@link Element} that matches the specified selector, or `null` if no matches are found or the selector is invalid.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* // Handles special characters in IDs gracefully
|
|
158
|
+
* smartQuerySelector('#my.id$with:special-chars');
|
|
159
|
+
* // Falls back to standard CSS selectors
|
|
160
|
+
* smartQuerySelector('.container > div:first-child');
|
|
161
|
+
*/
|
|
162
|
+
declare const smartQuerySelector: (selector: string) => Element | null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Creates a StickyProvider pre-configured for the Web environment.
|
|
166
|
+
*/
|
|
167
|
+
declare const createWebStickyProvider: (selector: string) => StickyProvider<Element>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* A centralized observation pool for DOM elements.
|
|
171
|
+
*
|
|
172
|
+
* This class provides a high-performance wrapper around `ResizeObserver` (RO) and
|
|
173
|
+
* `IntersectionObserver` (IO). By pooling all element observations into single
|
|
174
|
+
* native observer instances and utilizing `requestAnimationFrame` (rAF) throttling,
|
|
175
|
+
* it significantly reduces memory footprint and prevents layout thrashing.
|
|
176
|
+
*
|
|
177
|
+
* It supports deterministic unregistration via UIDs, making it ideal for
|
|
178
|
+
* framework adapters (like Vue or React) where DOM references may become unstable
|
|
179
|
+
* during unmounting.
|
|
180
|
+
*/
|
|
181
|
+
declare class ElementObserver implements IElementObserver<Element> {
|
|
182
|
+
private _ro;
|
|
183
|
+
private _roRegistry;
|
|
184
|
+
private _elToRoCb;
|
|
185
|
+
private _io;
|
|
186
|
+
private _ioRegistry;
|
|
187
|
+
private _elToIoCb;
|
|
188
|
+
private constructor();
|
|
189
|
+
static getInstance(): ElementObserver;
|
|
190
|
+
observeResize(uid: string, el: Element, cb: () => void): void;
|
|
191
|
+
unobserveResize(uid: string): void;
|
|
192
|
+
observeIntersect(uid: string, el: Element, cb: (isIntersecting: boolean) => void): void;
|
|
193
|
+
unobserveIntersect(uid: string): void;
|
|
194
|
+
disconnect(uid: string): void;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* GamepadManager
|
|
199
|
+
*
|
|
200
|
+
* A singleton service that polls the browser Gamepad API via requestAnimationFrame.
|
|
201
|
+
* It translates physical hardware inputs into programmatic signals sent to
|
|
202
|
+
* virtual entities registered in the system.
|
|
203
|
+
*
|
|
204
|
+
* Handles:
|
|
205
|
+
* 1. Button edge detection (Down/Up).
|
|
206
|
+
* 2. D-Pad to vector conversion.
|
|
207
|
+
* 3. Analog stick deadzone processing.
|
|
208
|
+
*/
|
|
209
|
+
declare class GamepadManager {
|
|
210
|
+
private isRunning;
|
|
211
|
+
private config;
|
|
212
|
+
private lastButtonStates;
|
|
213
|
+
private constructor();
|
|
214
|
+
/**
|
|
215
|
+
* Retrieves the global singleton instance of the GamepadManager.
|
|
216
|
+
*/
|
|
217
|
+
static getInstance(): GamepadManager;
|
|
218
|
+
/**
|
|
219
|
+
* Updates the current gamepad mapping configuration.
|
|
220
|
+
*
|
|
221
|
+
* @param config - The mapping of physical inputs to virtual component IDs (UID).
|
|
222
|
+
*/
|
|
223
|
+
setConfig(config: GamepadMappingConfig[]): void;
|
|
224
|
+
/** Return the current gamepad mapping configuration. */
|
|
225
|
+
getConfig(): Readonly<GamepadMappingConfig[] | null>;
|
|
226
|
+
/**
|
|
227
|
+
* Starts the polling loop and listens for gamepad connection events.
|
|
228
|
+
*/
|
|
229
|
+
start(): void;
|
|
230
|
+
/**
|
|
231
|
+
* Stops the polling loop.
|
|
232
|
+
*/
|
|
233
|
+
stop(): void;
|
|
234
|
+
/**
|
|
235
|
+
* The core polling loop executing at the browser's refresh rate.
|
|
236
|
+
*/
|
|
237
|
+
private loop;
|
|
238
|
+
/**
|
|
239
|
+
* Process binary button inputs with edge detection.
|
|
240
|
+
*/
|
|
241
|
+
private processButtons;
|
|
242
|
+
/**
|
|
243
|
+
* Translates physical D-Pad buttons into a normalized vector.
|
|
244
|
+
*/
|
|
245
|
+
private processDPad;
|
|
246
|
+
/**
|
|
247
|
+
* Process analog stick movements with deadzone logic.
|
|
248
|
+
*/
|
|
249
|
+
private processAxes;
|
|
250
|
+
/**
|
|
251
|
+
* Locates a virtual entity and triggers its programmatic interface.
|
|
252
|
+
*
|
|
253
|
+
* @param uid - The Entity ID (UID) of the target.
|
|
254
|
+
* @param action - The type of trigger ('down', 'up', or 'vector').
|
|
255
|
+
* @param payload - Optional data for vector movements.
|
|
256
|
+
*/
|
|
257
|
+
private triggerVirtualEntity;
|
|
258
|
+
}
|
|
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
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Global Input Manager Singleton.
|
|
332
|
+
*
|
|
333
|
+
* Responsible for monitoring global browser events (resize, blur, visibility)
|
|
334
|
+
* and coordinating system-wide resets to prevent stuck inputs.
|
|
335
|
+
*/
|
|
336
|
+
declare class WindowManager {
|
|
337
|
+
/** Internal flag to prevent multiple event registrations */
|
|
338
|
+
private _isListening;
|
|
339
|
+
/** A throttled version of the reset logic */
|
|
340
|
+
private throttledReset;
|
|
341
|
+
private constructor();
|
|
342
|
+
/**
|
|
343
|
+
* Retrieves the global instance of the WindowManager.
|
|
344
|
+
* Ensures uniqueness across multiple bundles or modules.
|
|
345
|
+
*/
|
|
346
|
+
static getInstance(): WindowManager;
|
|
347
|
+
/**
|
|
348
|
+
* Manually triggers a system-wide input reset via Registry.
|
|
349
|
+
*/
|
|
350
|
+
private handleGlobalReset;
|
|
351
|
+
private handleResizeReset;
|
|
352
|
+
private handleBlurReset;
|
|
353
|
+
private handleScrollReset;
|
|
354
|
+
private handleVisibilityChangeReset;
|
|
355
|
+
/**
|
|
356
|
+
* Initializes global safety listeners.
|
|
357
|
+
* Should be called once at the root component lifecycle (e.g., VirtualLayer).
|
|
358
|
+
*/
|
|
359
|
+
init(): void;
|
|
360
|
+
/**
|
|
361
|
+
* Toggle full-screen state of the page.
|
|
362
|
+
* @param element Target HTMLElement
|
|
363
|
+
*/
|
|
364
|
+
toggleFullscreen(element?: HTMLElement): Promise<void>;
|
|
365
|
+
/**
|
|
366
|
+
* Full-screen status query provided to the UI layer.
|
|
367
|
+
*/
|
|
368
|
+
isFullscreen(): boolean;
|
|
369
|
+
/**
|
|
370
|
+
* Detaches all global listeners.
|
|
371
|
+
*/
|
|
372
|
+
destroy(): void;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export { ElementObserver, GamepadManager, IframeManager, WindowManager, createPointerBridge, createWebStickyProvider, dispatchKeyboardEvent, dispatchPointerEventAtPos, flattenToHostLayout, focusElement, getDeepActiveElement, getDeepElement, reclaimFocusAtPos, safeReleaseCapture, safeSetCapture, smartQuerySelector, supportsContainerQueries, toAbsolutePx };
|