@omnipad/core 0.4.0 → 0.4.2
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/LICENSE +21 -0
- package/dist/{chunk-K6RXCH3Q.mjs → chunk-MSERY5BP.mjs} +1 -1
- package/dist/{chunk-FWW6DLM7.cjs → chunk-PAGWIRTX.cjs} +1 -1
- package/dist/{index-DRA1rw5_.d.cts → index-DlGCSMP1.d.cts} +5 -1
- package/dist/{index-DRA1rw5_.d.ts → index-DlGCSMP1.d.ts} +5 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +40 -37
- package/dist/index.d.ts +40 -37
- package/dist/index.mjs +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +26 -2
- package/dist/utils/index.d.ts +26 -2
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 omnipad-js
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var g=Object.defineProperty;var f=(e,t,n)=>t in e?g(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var b=(e,t,n)=>f(e,typeof t!="symbol"?t+"":t,n);var m=Symbol.for("omnipad.registry.instance"),h=class e{constructor(){b(this,"entities",new Map);import.meta.env?.DEV&&console.log("[OmniPad-Core] Registry initialized.");}static getInstance(){let t=globalThis;return t[m]||(t[m]=new e),t[m]}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 n=this.getAllEntities();if(!t)return n;if(!this.entities.get(t))return console.warn(`[OmniPad-Core] Registry: Root entity ${t} not found.`),[];let o=new Map;n.forEach(c=>{let a=c;if(typeof a.getConfig=="function"){let u=a.getConfig();u.parentId&&(o.has(u.parentId)||o.set(u.parentId,[]),o.get(u.parentId).push(c));}});let i=[],s=[t],y=new Set;for(;s.length>0;){let c=s.shift();if(y.has(c))continue;y.add(c);let a=this.entities.get(c);if(a){i.push(a);let u=o.get(c);u&&u.forEach(d=>s.push(d.uid));}}return i}destroyByRoot(t){let n=this.getEntitiesByRoot(t);for(let r=n.length-1;r>=0;r--){let o=n[r];try{o.destroy();}catch(i){console.error(`[OmniPad-Core] Error during destroyByRoot at ${o.uid}:`,i);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(t=>{"reset"in t&&t.reset();});}debugGetSnapshot(){return new Map(this.entities)}};var R=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),T=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),V=(e,t)=>({x:e.x*t,y:e.y*t}),x=(e,t,n)=>Math.max(t,Math.min(n,e)),M=(e,t,n)=>e+(t-e)*n,l=(e,t=2)=>{let n=Math.pow(10,t);return Math.round(e*n)/n},
|
|
1
|
+
var g=Object.defineProperty;var f=(e,t,n)=>t in e?g(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var b=(e,t,n)=>f(e,typeof t!="symbol"?t+"":t,n);var m=Symbol.for("omnipad.registry.instance"),h=class e{constructor(){b(this,"entities",new Map);import.meta.env?.DEV&&console.log("[OmniPad-Core] Registry initialized.");}static getInstance(){let t=globalThis;return t[m]||(t[m]=new e),t[m]}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 n=this.getAllEntities();if(!t)return n;if(!this.entities.get(t))return console.warn(`[OmniPad-Core] Registry: Root entity ${t} not found.`),[];let o=new Map;n.forEach(c=>{let a=c;if(typeof a.getConfig=="function"){let u=a.getConfig();u.parentId&&(o.has(u.parentId)||o.set(u.parentId,[]),o.get(u.parentId).push(c));}});let i=[],s=[t],y=new Set;for(;s.length>0;){let c=s.shift();if(y.has(c))continue;y.add(c);let a=this.entities.get(c);if(a){i.push(a);let u=o.get(c);u&&u.forEach(d=>s.push(d.uid));}}return i}destroyByRoot(t){let n=this.getEntitiesByRoot(t);for(let r=n.length-1;r>=0;r--){let o=n[r];try{o.destroy();}catch(i){console.error(`[OmniPad-Core] Error during destroyByRoot at ${o.uid}:`,i);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(t=>{"reset"in t&&t.reset(),"markRectDirty"in t&&t.markRectDirty();});}debugGetSnapshot(){return new Map(this.entities)}};var R=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),T=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),V=(e,t)=>({x:e.x*t,y:e.y*t}),x=(e,t,n)=>Math.max(t,Math.min(n,e)),M=(e,t,n)=>e+(t-e)*n,l=(e,t=2)=>{let n=Math.pow(10,t);return Math.round(e*n)/n},D=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),w=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),P=e=>e*180/Math.PI,A=e=>e*Math.PI/180,O=(e,t,n)=>{let r=t.x-e.x,o=t.y-e.y;if(Math.hypot(r,o)<=n)return t;let s=Math.atan2(o,r);return {x:e.x+Math.cos(s)*n,y:e.y+Math.sin(s)*n}},z=e=>{let t=Math.PI/4;return Math.round(e/t)*t},B=e=>{let t=Math.PI/2;return Math.round(e/t)*t},S=(e,t)=>l(e*t/100),k=(e,t)=>t===0?0:l(e*100/t),G=e=>{let t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},q=e=>({x:Math.cos(e),y:Math.sin(e)}),L=(e,t,n,r,o)=>{let i=(e-t)/(n-t);return M(r,o,x(i,0,1))},Y=(e,t,n=1e-4)=>Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n,p=(e,t,n)=>{if(e<t)return 0;let r=(e-t)/(n-t);return x(r,0,1)},$=(e,t,n)=>{let r=Math.hypot(e.x,e.y),o=t*n,i=p(r,o,t);if(i===0)return {x:0,y:0};let s={x:e.x/r,y:e.y/r};return V(s,i)},j=(e,t,n)=>({x:p(Math.abs(e.x),t,n)*Math.sign(e.x),y:p(Math.abs(e.y),t,n)*Math.sign(e.y)});export{b as a,h as b,R as c,T as d,V as e,x as f,M as g,l as h,D as i,w as j,P as k,A as l,O as m,z as n,B as o,S as p,k as q,G as r,q as s,L as t,Y as u,p as v,$ as w,j as x};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var g=Object.defineProperty;var f=(e,t,n)=>t in e?g(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var b=(e,t,n)=>f(e,typeof t!="symbol"?t+"":t,n);var m=Symbol.for("omnipad.registry.instance"),h=class e{constructor(){b(this,"entities",new Map);undefined?.DEV&&console.log("[OmniPad-Core] Registry initialized.");}static getInstance(){let t=globalThis;return t[m]||(t[m]=new e),t[m]}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 n=this.getAllEntities();if(!t)return n;if(!this.entities.get(t))return console.warn(`[OmniPad-Core] Registry: Root entity ${t} not found.`),[];let o=new Map;n.forEach(c=>{let a=c;if(typeof a.getConfig=="function"){let u=a.getConfig();u.parentId&&(o.has(u.parentId)||o.set(u.parentId,[]),o.get(u.parentId).push(c));}});let i=[],s=[t],y=new Set;for(;s.length>0;){let c=s.shift();if(y.has(c))continue;y.add(c);let a=this.entities.get(c);if(a){i.push(a);let u=o.get(c);u&&u.forEach(d=>s.push(d.uid));}}return i}destroyByRoot(t){let n=this.getEntitiesByRoot(t);for(let r=n.length-1;r>=0;r--){let o=n[r];try{o.destroy();}catch(i){console.error(`[OmniPad-Core] Error during destroyByRoot at ${o.uid}:`,i);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(t=>{"reset"in t&&t.reset();});}debugGetSnapshot(){return new Map(this.entities)}};var R=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),T=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),V=(e,t)=>({x:e.x*t,y:e.y*t}),x=(e,t,n)=>Math.max(t,Math.min(n,e)),M=(e,t,n)=>e+(t-e)*n,l=(e,t=2)=>{let n=Math.pow(10,t);return Math.round(e*n)/n},
|
|
1
|
+
'use strict';var g=Object.defineProperty;var f=(e,t,n)=>t in e?g(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var b=(e,t,n)=>f(e,typeof t!="symbol"?t+"":t,n);var m=Symbol.for("omnipad.registry.instance"),h=class e{constructor(){b(this,"entities",new Map);undefined?.DEV&&console.log("[OmniPad-Core] Registry initialized.");}static getInstance(){let t=globalThis;return t[m]||(t[m]=new e),t[m]}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 n=this.getAllEntities();if(!t)return n;if(!this.entities.get(t))return console.warn(`[OmniPad-Core] Registry: Root entity ${t} not found.`),[];let o=new Map;n.forEach(c=>{let a=c;if(typeof a.getConfig=="function"){let u=a.getConfig();u.parentId&&(o.has(u.parentId)||o.set(u.parentId,[]),o.get(u.parentId).push(c));}});let i=[],s=[t],y=new Set;for(;s.length>0;){let c=s.shift();if(y.has(c))continue;y.add(c);let a=this.entities.get(c);if(a){i.push(a);let u=o.get(c);u&&u.forEach(d=>s.push(d.uid));}}return i}destroyByRoot(t){let n=this.getEntitiesByRoot(t);for(let r=n.length-1;r>=0;r--){let o=n[r];try{o.destroy();}catch(i){console.error(`[OmniPad-Core] Error during destroyByRoot at ${o.uid}:`,i);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(t=>{"reset"in t&&t.reset(),"markRectDirty"in t&&t.markRectDirty();});}debugGetSnapshot(){return new Map(this.entities)}};var R=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),T=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),V=(e,t)=>({x:e.x*t,y:e.y*t}),x=(e,t,n)=>Math.max(t,Math.min(n,e)),M=(e,t,n)=>e+(t-e)*n,l=(e,t=2)=>{let n=Math.pow(10,t);return Math.round(e*n)/n},D=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),w=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),P=e=>e*180/Math.PI,A=e=>e*Math.PI/180,O=(e,t,n)=>{let r=t.x-e.x,o=t.y-e.y;if(Math.hypot(r,o)<=n)return t;let s=Math.atan2(o,r);return {x:e.x+Math.cos(s)*n,y:e.y+Math.sin(s)*n}},z=e=>{let t=Math.PI/4;return Math.round(e/t)*t},B=e=>{let t=Math.PI/2;return Math.round(e/t)*t},S=(e,t)=>l(e*t/100),k=(e,t)=>t===0?0:l(e*100/t),G=e=>{let t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},q=e=>({x:Math.cos(e),y:Math.sin(e)}),L=(e,t,n,r,o)=>{let i=(e-t)/(n-t);return M(r,o,x(i,0,1))},Y=(e,t,n=1e-4)=>Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n,p=(e,t,n)=>{if(e<t)return 0;let r=(e-t)/(n-t);return x(r,0,1)},$=(e,t,n)=>{let r=Math.hypot(e.x,e.y),o=t*n,i=p(r,o,t);if(i===0)return {x:0,y:0};let s={x:e.x/r,y:e.y/r};return V(s,i)},j=(e,t,n)=>({x:p(Math.abs(e.x),t,n)*Math.sign(e.x),y:p(Math.abs(e.y),t,n)*Math.sign(e.y)});exports.a=b;exports.b=h;exports.c=R;exports.d=T;exports.e=V;exports.f=x;exports.g=M;exports.h=l;exports.i=D;exports.j=w;exports.k=P;exports.l=A;exports.m=O;exports.n=z;exports.o=B;exports.p=S;exports.q=k;exports.r=G;exports.s=q;exports.t=L;exports.u=Y;exports.v=p;exports.w=$;exports.x=j;
|
|
@@ -787,7 +787,11 @@ interface ISpatial {
|
|
|
787
787
|
/**
|
|
788
788
|
* Dynamically obtain dimensions and position to ensure the most precise real-time screen coordinates are obtained during each interaction.
|
|
789
789
|
*/
|
|
790
|
-
bindRectProvider(provider: () => AbstractRect): void;
|
|
790
|
+
bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
|
|
791
|
+
/**
|
|
792
|
+
* Trigger a cache invalidation.
|
|
793
|
+
*/
|
|
794
|
+
markRectDirty(): void;
|
|
791
795
|
}
|
|
792
796
|
/**
|
|
793
797
|
* Trait: Provides configuration management.
|
|
@@ -787,7 +787,11 @@ interface ISpatial {
|
|
|
787
787
|
/**
|
|
788
788
|
* Dynamically obtain dimensions and position to ensure the most precise real-time screen coordinates are obtained during each interaction.
|
|
789
789
|
*/
|
|
790
|
-
bindRectProvider(provider: () => AbstractRect): void;
|
|
790
|
+
bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
|
|
791
|
+
/**
|
|
792
|
+
* Trigger a cache invalidation.
|
|
793
|
+
*/
|
|
794
|
+
markRectDirty(): void;
|
|
791
795
|
}
|
|
792
796
|
/**
|
|
793
797
|
* Trait: Provides configuration management.
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunkFWW6DLM7_cjs=require('./chunk-FWW6DLM7.cjs');var X={Backspace:{key:"Backspace",code:"Backspace",keyCode:8},Tab:{key:"Tab",code:"Tab",keyCode:9},Enter:{key:"Enter",code:"Enter",keyCode:13},ShiftLeft:{key:"Shift",code:"ShiftLeft",keyCode:16},ControlLeft:{key:"Control",code:"ControlLeft",keyCode:17},AltLeft:{key:"Alt",code:"AltLeft",keyCode:18},Pause:{key:"Pause",code:"Pause",keyCode:19},CapsLock:{key:"CapsLock",code:"CapsLock",keyCode:20},Escape:{key:"Escape",code:"Escape",keyCode:27},Space:{key:" ",code:"Space",keyCode:32},PageUp:{key:"PageUp",code:"PageUp",keyCode:33},PageDown:{key:"PageDown",code:"PageDown",keyCode:34},End:{key:"End",code:"End",keyCode:35},Home:{key:"Home",code:"Home",keyCode:36},ArrowLeft:{key:"ArrowLeft",code:"ArrowLeft",keyCode:37},ArrowUp:{key:"ArrowUp",code:"ArrowUp",keyCode:38},ArrowRight:{key:"ArrowRight",code:"ArrowRight",keyCode:39},ArrowDown:{key:"ArrowDown",code:"ArrowDown",keyCode:40},PrintScreen:{key:"PrintScreen",code:"PrintScreen",keyCode:44},Insert:{key:"Insert",code:"Insert",keyCode:45},Delete:{key:"Delete",code:"Delete",keyCode:46},Digit0:{key:"0",code:"Digit0",keyCode:48},Digit1:{key:"1",code:"Digit1",keyCode:49},Digit2:{key:"2",code:"Digit2",keyCode:50},Digit3:{key:"3",code:"Digit3",keyCode:51},Digit4:{key:"4",code:"Digit4",keyCode:52},Digit5:{key:"5",code:"Digit5",keyCode:53},Digit6:{key:"6",code:"Digit6",keyCode:54},Digit7:{key:"7",code:"Digit7",keyCode:55},Digit8:{key:"8",code:"Digit8",keyCode:56},Digit9:{key:"9",code:"Digit9",keyCode:57},KeyA:{key:"a",code:"KeyA",keyCode:65},KeyB:{key:"b",code:"KeyB",keyCode:66},KeyC:{key:"c",code:"KeyC",keyCode:67},KeyD:{key:"d",code:"KeyD",keyCode:68},KeyE:{key:"e",code:"KeyE",keyCode:69},KeyF:{key:"f",code:"KeyF",keyCode:70},KeyG:{key:"g",code:"KeyG",keyCode:71},KeyH:{key:"h",code:"KeyH",keyCode:72},KeyI:{key:"i",code:"KeyI",keyCode:73},KeyJ:{key:"j",code:"KeyJ",keyCode:74},KeyK:{key:"k",code:"KeyK",keyCode:75},KeyL:{key:"l",code:"KeyL",keyCode:76},KeyM:{key:"m",code:"KeyM",keyCode:77},KeyN:{key:"n",code:"KeyN",keyCode:78},KeyO:{key:"o",code:"KeyO",keyCode:79},KeyP:{key:"p",code:"KeyP",keyCode:80},KeyQ:{key:"q",code:"KeyQ",keyCode:81},KeyR:{key:"r",code:"KeyR",keyCode:82},KeyS:{key:"s",code:"KeyS",keyCode:83},KeyT:{key:"t",code:"KeyT",keyCode:84},KeyU:{key:"u",code:"KeyU",keyCode:85},KeyV:{key:"v",code:"KeyV",keyCode:86},KeyW:{key:"w",code:"KeyW",keyCode:87},KeyX:{key:"x",code:"KeyX",keyCode:88},KeyY:{key:"y",code:"KeyY",keyCode:89},KeyZ:{key:"z",code:"KeyZ",keyCode:90},MetaLeft:{key:"Meta",code:"MetaLeft",keyCode:91},ContextMenu:{key:"ContextMenu",code:"ContextMenu",keyCode:93},Numpad0:{key:"0",code:"Numpad0",keyCode:96},Numpad1:{key:"1",code:"Numpad1",keyCode:97},Numpad2:{key:"2",code:"Numpad2",keyCode:98},Numpad3:{key:"3",code:"Numpad3",keyCode:99},Numpad4:{key:"4",code:"Numpad4",keyCode:100},Numpad5:{key:"5",code:"Numpad5",keyCode:101},Numpad6:{key:"6",code:"Numpad6",keyCode:102},Numpad7:{key:"7",code:"Numpad7",keyCode:103},Numpad8:{key:"8",code:"Numpad8",keyCode:104},Numpad9:{key:"9",code:"Numpad9",keyCode:105},NumpadMultiply:{key:"*",code:"NumpadMultiply",keyCode:106},NumpadAdd:{key:"+",code:"NumpadAdd",keyCode:107},NumpadSubtract:{key:"-",code:"NumpadSubtract",keyCode:109},NumpadDecimal:{key:".",code:"NumpadDecimal",keyCode:110},NumpadDivide:{key:"/",code:"NumpadDivide",keyCode:111},F1:{key:"F1",code:"F1",keyCode:112},F2:{key:"F2",code:"F2",keyCode:113},F3:{key:"F3",code:"F3",keyCode:114},F4:{key:"F4",code:"F4",keyCode:115},F5:{key:"F5",code:"F5",keyCode:116},F6:{key:"F6",code:"F6",keyCode:117},F7:{key:"F7",code:"F7",keyCode:118},F8:{key:"F8",code:"F8",keyCode:119},F9:{key:"F9",code:"F9",keyCode:120},F10:{key:"F10",code:"F10",keyCode:121},F11:{key:"F11",code:"F11",keyCode:122},F12:{key:"F12",code:"F12",keyCode:123},NumLock:{key:"NumLock",code:"NumLock",keyCode:144},ScrollLock:{key:"ScrollLock",code:"ScrollLock",keyCode:145},Semicolon:{key:";",code:"Semicolon",keyCode:186},Equal:{key:"=",code:"Equal",keyCode:187},Comma:{key:",",code:"Comma",keyCode:188},Minus:{key:"-",code:"Minus",keyCode:189},Period:{key:".",code:"Period",keyCode:190},Slash:{key:"/",code:"Slash",keyCode:191},Backquote:{key:"`",code:"Backquote",keyCode:192},BracketLeft:{key:"[",code:"BracketLeft",keyCode:219},Backslash:{key:"\\",code:"Backslash",keyCode:220},BracketRight:{key:"]",code:"BracketRight",keyCode:221},Quote:{key:"'",code:"Quote",keyCode:222}},E=X;var u={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"},n={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},_={PARENT_ID_KEY:"omnipad-parent-id-link"};var I=Symbol.for("omnipad.gamepad_manager.instance"),z={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 a{constructor(){chunkFWW6DLM7_cjs.a(this,"isRunning",false);chunkFWW6DLM7_cjs.a(this,"config",null);chunkFWW6DLM7_cjs.a(this,"lastButtonStates",[]);chunkFWW6DLM7_cjs.a(this,"loop",()=>{if(!this.isRunning)return;let o=navigator.getGamepads();this.config?.forEach((e,t)=>{let i=o[t];i&&i.connected&&e&&(this.lastButtonStates[t]||(this.lastButtonStates[t]=[]),this.processButtons(i,e,t),this.processDPad(i,e),this.processAxes(i,e));}),requestAnimationFrame(this.loop);});}static getInstance(){let o=globalThis;return o[I]||(o[I]=new a),o[I]}setConfig(o){this.config=o;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",o=>{undefined?.DEV&&console.log("[Omnipad-Core] Gamepad Connected:",o.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{undefined?.DEV&&console.log("[Omnipad-Core] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(o,e,t){e.buttons&&Object.entries(e.buttons).forEach(([i,r])=>{let c=z[i];if(c===void 0||!o.buttons[c])return;let p=o.buttons[c].pressed,h=this.lastButtonStates[t][c]||false;p&&!h?this.triggerVirtualEntity(r,"down"):!p&&h&&this.triggerVirtualEntity(r,"up"),this.lastButtonStates[t][c]=p;});}processDPad(o,e){let t=e?.dpad;if(!t)return;let i=o.buttons[12]?.pressed?-1:0,r=o.buttons[13]?.pressed?1:0,c=o.buttons[14]?.pressed?-1:0,p=o.buttons[15]?.pressed?1:0,h=c+p,f=i+r;this.triggerVirtualEntity(t,"vector",{x:h,y:f});}processAxes(o,e){let t=e?.deadzone??.1;if(e?.leftStick){let i=Math.abs(o.axes[0])>t?o.axes[0]:0,r=Math.abs(o.axes[1])>t?o.axes[1]:0;this.triggerVirtualEntity(e.leftStick,"vector",{x:i,y:r});}if(e?.rightStick){let i=Math.abs(o.axes[2])>t?o.axes[2]:0,r=Math.abs(o.axes[3])>t?o.axes[3]:0;this.triggerVirtualEntity(e.rightStick,"vector",{x:i,y:r});}}triggerVirtualEntity(o,e,t){let i=chunkFWW6DLM7_cjs.b.getInstance().getEntity(o);!i||i.activePointerId!=null||(e==="down"&&i.triggerDown&&i.triggerDown(),e==="up"&&i.triggerUp&&i.triggerUp(),e==="vector"&&i.triggerVector&&t&&i.triggerVector(t.x,t.y));}};var C=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):a=>setTimeout(a,16),q=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):a=>clearTimeout(a);function g(a){let o=false,e=null;return function(t){e=t,o||(o=true,C(()=>{e!==null&&a(e),o=false;}));}}function V(a){let o=null,e=()=>{a(),o=C(e);};return {start:()=>{o===null&&e();},stop:()=>{o!==null&&(q(o),o=null);}}}var H=(a=2)=>new Promise(o=>{let e=0,t=()=>{++e>=a?o():C(t);};C(t);});var x=Symbol.for("omnipad.input_manager.instance"),w=class a{constructor(){chunkFWW6DLM7_cjs.a(this,"_isListening",false);chunkFWW6DLM7_cjs.a(this,"throttledReset");chunkFWW6DLM7_cjs.a(this,"handleGlobalReset",()=>{undefined?.DEV&&console.debug("[OmniPad-Core] Safety reset triggered by environment change."),chunkFWW6DLM7_cjs.b.getInstance().resetAll();});chunkFWW6DLM7_cjs.a(this,"handleResizeReset",()=>{this.throttledReset(null);});chunkFWW6DLM7_cjs.a(this,"handleBlurReset",()=>{this.handleGlobalReset();});chunkFWW6DLM7_cjs.a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=g(()=>{this.handleGlobalReset();});}static getInstance(){let o=globalThis;return o[x]||(o[x]=new a),o[x]}init(){this._isListening||(window.addEventListener("resize",this.handleResizeReset),window.addEventListener("blur",this.handleBlurReset),document.addEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=true,undefined?.DEV&&console.log("[OmniPad-Core] Global InputManager monitoring started."));}async toggleFullscreen(o){let e=o||document.documentElement;try{document.fullscreenElement?(chunkFWW6DLM7_cjs.b.getInstance().resetAll(),await document.exitFullscreen()):(chunkFWW6DLM7_cjs.b.getInstance().resetAll(),await e.requestFullscreen());}catch(t){console.error("[OmniPad-Core] Fullscreen toggle failed:",t);}}isFullscreen(){return !!document.fullscreenElement}destroy(){window.removeEventListener("resize",this.handleResizeReset),window.removeEventListener("blur",this.handleBlurReset),window.removeEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=false;}};var A=class{constructor(){chunkFWW6DLM7_cjs.a(this,"listeners",new Set);}subscribe(o){return this.listeners.add(o),()=>this.listeners.delete(o)}emit(o){this.listeners.forEach(e=>{try{e(o);}catch(t){console.error("[OmniPad-Core] Emitter callback error:",t);}});}clear(){this.listeners.clear();}};var l=class{constructor(o,e,t,i){chunkFWW6DLM7_cjs.a(this,"uid");chunkFWW6DLM7_cjs.a(this,"type");chunkFWW6DLM7_cjs.a(this,"config");chunkFWW6DLM7_cjs.a(this,"state");chunkFWW6DLM7_cjs.a(this,"rectProvider",null);chunkFWW6DLM7_cjs.a(this,"stateEmitter",new A);this.uid=o,this.type=e,this.config=t,this.state=i;}subscribe(o){return o(this.state),this.stateEmitter.subscribe(o)}setState(o){this.state={...this.state,...o},this.stateEmitter.emit(this.state);}destroy(){this.reset(),this.stateEmitter.clear(),chunkFWW6DLM7_cjs.b.getInstance().unregister(this.uid);}get rect(){return this.rectProvider?this.rectProvider():null}bindRectProvider(o){this.rectProvider=o;}updateConfig(o){this.config={...this.config,...o},this.stateEmitter.emit(this.state);}getState(){return this.state}getConfig(){return this.config}};var d=class{constructor(o,e){chunkFWW6DLM7_cjs.a(this,"isPressed",false);chunkFWW6DLM7_cjs.a(this,"mapping");chunkFWW6DLM7_cjs.a(this,"targetId");this.update(o,e);}update(o,e){this.isPressed&&this.reset(),this.targetId=o,this.mapping=this.hydrate(e);}hydrate(o){if(!o)return;let e={...o};if(e.type==="mouse")return e.button=e.button??0,e;let{key:t,code:i,keyCode:r}=e;if(t||i||r){e.type="keyboard";let c=Object.values(E).find(p=>p.code===i||p.key===t||p.keyCode===r);c&&(e.key=t??c.key,e.code=i??c.code,e.keyCode=r??c.keyCode);}return e}press(){if(!this.mapping||this.isPressed)return;this.isPressed=true;let o=this.mapping.type==="keyboard"?n.KEYDOWN:n.MOUSEDOWN;this.emitSignal(o);}release(o=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let e=this.mapping.type==="keyboard"?n.KEYUP:n.MOUSEUP;this.emitSignal(e),this.mapping.type==="mouse"&&o&&this.emitSignal(n.CLICK);}move(o){this.mapping?.type==="mouse"&&this.emitSignal(n.MOUSEMOVE,o);}reset(){this.isPressed&&this.release(false);}async tap(o=true){this.isPressed||(this.press(),await H(2),this.isPressed&&this.release(o));}emitSignal(o,e={}){if(!this.targetId||!this.mapping)return;let t=chunkFWW6DLM7_cjs.b.getInstance().getEntity(this.targetId);t&&t.handleSignal({targetStageId:this.targetId,type:o,payload:{key:this.mapping.key,code:this.mapping.code,keyCode:this.mapping.keyCode,button:this.mapping.button,point:this.mapping.fixedPoint,...e}});}};var M={isActive:false,isPressed:false,pointerId:null,value:0},R=class extends l{constructor(e,t){super(e,u.BUTTON,t,M);chunkFWW6DLM7_cjs.a(this,"emitter");this.emitter=new d(t.targetStageId,t.mapping);}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,isPressed:true,pointerId:e.pointerId}),this.emitter.press();}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.handleRelease(true);}onPointerCancel(){this.handleRelease(false);}onPointerMove(){}reset(){this.setState(M),this.emitter.reset();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(e){this.setState(M),this.emitter.release(e);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.emitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.emitter.release(true));}};var G={isActive:false,pointerId:null,vector:{x:0,y:0}},O=class extends l{constructor(e,t){super(e,u.D_PAD,t,G);chunkFWW6DLM7_cjs.a(this,"emitters");chunkFWW6DLM7_cjs.a(this,"throttledPointerMove");let i=t.targetStageId;this.emitters={up:new d(i,t.mapping?.up),down:new d(i,t.mapping?.down),left:new d(i,t.mapping?.left),right:new d(i,t.mapping?.right)},this.throttledPointerMove=g(r=>{this.processInput(r);});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}});}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.throttledPointerMove(e);}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.reset();}onPointerCancel(){this.reset();}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let r=i.left+i.width/2,c=i.top+i.height/2,p=i.width/2,h=i.height/2,f=(e.clientX-r)/p,b=(e.clientY-c)/h;if(t&&(f!=chunkFWW6DLM7_cjs.f(f,-1,1)||b!=chunkFWW6DLM7_cjs.f(b,-1,1))){this.setState({vector:{x:0,y:0}});return}let S={x:chunkFWW6DLM7_cjs.f(f,-1,1),y:chunkFWW6DLM7_cjs.f(b,-1,1)};this.setState({vector:S}),this.handleDigitalKeys(S);}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.emitters.up.reset(),this.emitters.down.reset(),this.emitters.left.reset(),this.emitters.right.reset(),this.setState(G);}updateConfig(e){super.updateConfig(e),this.emitters.up.update(this.config.targetStageId,this.config.mapping?.up),this.emitters.down.update(this.config.targetStageId,this.config.mapping?.down),this.emitters.left.update(this.config.targetStageId,this.config.mapping?.left),this.emitters.right.update(this.config.targetStageId,this.config.mapping?.right);}triggerVector(e,t){let i={x:e,y:t},r=this.config.threshold??.3;Math.abs(e)>=r||Math.abs(t)>=r?(this.setState({isActive:true,vector:i}),this.handleDigitalKeys(i)):this.reset();}};var J={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},K=class extends l{constructor(e,t){super(e,u.INPUT_ZONE,t,J);chunkFWW6DLM7_cjs.a(this,"delegates",{dynamicWidgetPointerDown:()=>{},dynamicWidgetPointerMove:()=>{},dynamicWidgetPointerUp:()=>{},dynamicWidgetPointerCancel:()=>{}});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:undefined?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return this.state.dynamicPointerId}onPointerDown(e){if(this.state.isDynamicActive)return;let t=this.calculateRelativePosition(e.clientX,e.clientY);this.setState({isDynamicActive:true,dynamicPointerId:e.pointerId,dynamicPosition:t}),this.delegates.dynamicWidgetPointerDown?.(e);}onPointerMove(e){this.state.isDynamicActive&&this.delegates.dynamicWidgetPointerMove?.(e);}onPointerUp(e){this.delegates.dynamicWidgetPointerUp?.(e),this.reset();}onPointerCancel(e){this.delegates.dynamicWidgetPointerCancel?.(e),this.reset();}calculateRelativePosition(e,t){let i=this.rect;return i?{x:chunkFWW6DLM7_cjs.q(e-i.left,i.width),y:chunkFWW6DLM7_cjs.q(t-i.top,i.height)}:{x:0,y:0}}get isInterceptorRequired(){return !!(this.config.dynamicWidgetId||this.config.preventFocusLoss)}reset(){this.setState({isDynamicActive:false,dynamicPointerId:null});}};var P=class{constructor(o={}){chunkFWW6DLM7_cjs.a(this,"options");chunkFWW6DLM7_cjs.a(this,"startTime",0);chunkFWW6DLM7_cjs.a(this,"startPos",{x:0,y:0});chunkFWW6DLM7_cjs.a(this,"lastTapTime",0);chunkFWW6DLM7_cjs.a(this,"hasMoved",false);chunkFWW6DLM7_cjs.a(this,"isDoubleTapHolding",false);this.options={tapTime:250,tapDistance:10,doubleTapGap:300,...o};}onPointerDown(o,e){let t=Date.now();this.startTime=t,this.startPos={x:o,y:e},this.hasMoved=false,t-this.lastTapTime<this.options.doubleTapGap?(this.isDoubleTapHolding=true,this.options.onDoubleTapHoldStart?.()):this.isDoubleTapHolding=false;}onPointerMove(o,e){this.hasMoved||Math.hypot(o-this.startPos.x,e-this.startPos.y)>this.options.tapDistance&&(this.hasMoved=true);}onPointerUp(){let o=Date.now(),e=o-this.startTime;this.isDoubleTapHolding?(this.isDoubleTapHolding=false,this.options.onDoubleTapHoldEnd?.(),this.lastTapTime=0):e<=this.options.tapTime&&!this.hasMoved&&(this.options.onTap?.(),o-this.lastTapTime<this.options.doubleTapGap?(this.options.onDoubleTap?.(),this.lastTapTime=0):this.lastTapTime=o);}reset(){this.isDoubleTapHolding&&this.options.onDoubleTapHoldEnd?.(),this.isDoubleTapHolding=false,this.hasMoved=false,this.startTime=0,this.lastTapTime=0;}};var W={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},N=class extends l{constructor(e,t){super(e,u.JOYSTICK,t,W);chunkFWW6DLM7_cjs.a(this,"emitters");chunkFWW6DLM7_cjs.a(this,"stickEmitter");chunkFWW6DLM7_cjs.a(this,"cursorEmitter");chunkFWW6DLM7_cjs.a(this,"gesture");chunkFWW6DLM7_cjs.a(this,"ticker");chunkFWW6DLM7_cjs.a(this,"throttledUpdate");let i=t.targetStageId,r=t.mapping||{};this.emitters={up:new d(i,r.up),down:new d(i,r.down),left:new d(i,r.left),right:new d(i,r.right)},this.stickEmitter=new d(i,r.stick),this.cursorEmitter=new d(i,{type:"mouse"}),this.gesture=new P({onTap:async()=>{this.setState({isPressed:true}),await this.stickEmitter.tap(),this.setState({isPressed:false});},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.stickEmitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.stickEmitter.release(false);}}),this.ticker=V(()=>{this.handleCursorTick();}),this.throttledUpdate=g(c=>{this.processInput(c);});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}}),this.gesture.onPointerDown(e.clientX,e.clientY);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.config.cursorMode&&this.ticker.start(),this.throttledUpdate(e));}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}handleRelease(){this.setState({isActive:false,pointerId:null,vector:{x:0,y:0}}),this.ticker.stop(),Object.values(this.emitters).forEach(e=>e?.reset());}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let r=i.left+i.width/2,c=i.top+i.height/2,p=i.width/2,h=i.height/2,f=(e.clientX-r)/p,b=(e.clientY-c)/h;if(t&&(f!=chunkFWW6DLM7_cjs.f(f,-1,1)||b!=chunkFWW6DLM7_cjs.f(b,-1,1))){this.setState({vector:{x:0,y:0}});return}let B=chunkFWW6DLM7_cjs.w({x:f,y:b},1,this.config.threshold||.15);this.setState({vector:B}),this.handleDigitalKeys(B);}handleCursorTick(){let{vector:e,isActive:t}=this.state;if(!t||!this.config.cursorMode)return;let i=this.config.cursorSensitivity??1,r={x:e.x*i,y:e.y*i};(Math.abs(r.x)>0||Math.abs(r.y)>0)&&this.cursorEmitter.move({delta:r});}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.setState(W),this.gesture.reset(),this.handleRelease(),this.stickEmitter.reset(),this.cursorEmitter.reset();}updateConfig(e){super.updateConfig(e);let t=this.config.targetStageId,i=this.config.mapping||{};this.emitters.up.update(t,i.up),this.emitters.down.update(t,i.down),this.emitters.left.update(t,i.left),this.emitters.right.update(t,i.right),this.stickEmitter.update(t,i.stick),this.cursorEmitter.update(t);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.stickEmitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.stickEmitter.release(true));}triggerVector(e,t){let i={x:e,y:t},r=this.config.threshold??.3;Math.abs(e)>=r||Math.abs(t)>=r?(this.setState({isActive:true,vector:i}),this.handleDigitalKeys(i),this.config.cursorMode&&this.ticker.start()):this.handleRelease();}};var j={isHighlighted:false},F=class extends l{constructor(o,e){super(o,u.ROOT_LAYER,e,j);}reset(){}};var Q={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},U=class extends l{constructor(e,t){super(e,u.TARGET_ZONE,t,Q);chunkFWW6DLM7_cjs.a(this,"hideTimer",null);chunkFWW6DLM7_cjs.a(this,"focusFeedbackTimer",null);chunkFWW6DLM7_cjs.a(this,"throttledPointerMove");chunkFWW6DLM7_cjs.a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledPointerMove=g(i=>{this.processPhysicalEvent(i,n.MOUSEMOVE);});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:undefined?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return null}onPointerDown(e){this.processPhysicalEvent(e,n.MOUSEDOWN);}onPointerMove(e){this.throttledPointerMove(e);}onPointerUp(e){this.processPhysicalEvent(e,n.MOUSEUP),this.processPhysicalEvent(e,n.CLICK);}onPointerCancel(e){this.processPhysicalEvent(e,n.MOUSEUP);}processPhysicalEvent(e,t){let i=this.rect;if(!i)return;let r={x:chunkFWW6DLM7_cjs.q(e.clientX-i.left,i.width),y:chunkFWW6DLM7_cjs.q(e.clientY-i.top,i.height)};this.handleSignal({targetStageId:this.uid,type:t,payload:{point:r,button:e.button}});}handleSignal(e){let{type:t,payload:i}=e;switch(this.ensureFocus(),t){case n.KEYDOWN:case n.KEYUP:this.delegates.dispatchKeyboardEvent?.(t,i);break;case n.MOUSEMOVE:i.point?this.updateCursorPosition(i.point):i.delta&&this.updateCursorPositionByDelta(i.delta),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(n.POINTERMOVE,i);break;case n.MOUSEDOWN:case n.MOUSEUP:case n.CLICK:i.point&&this.updateCursorPosition(i.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(t.startsWith(n.MOUSE)?t.replace(n.MOUSE,n.POINTER):t,i);break}}executeMouseAction(e,t){let i=this.rect;if(!i)return;e===n.POINTERDOWN&&this.setState({isPointerDown:true}),e===n.POINTERUP&&this.setState({isPointerDown:false});let r=t.point||this.state.position,c=i.left+chunkFWW6DLM7_cjs.p(r.x,i.width),p=i.top+chunkFWW6DLM7_cjs.p(r.y,i.height);this.delegates.dispatchPointerEventAtPos?.(e,c,p,{button:t.button??0,buttons:this.state.isPointerDown?1:0,pressure:this.state.isPointerDown?.5:0});}ensureFocus(){let e=this.rect;if(!e)return;let t=e.left+chunkFWW6DLM7_cjs.p(this.state.position.x,e.width),i=e.top+chunkFWW6DLM7_cjs.p(this.state.position.y,e.height);this.delegates.reclaimFocusAtPos?.(t,i,()=>this.triggerFocusFeedback());}triggerFocusFeedback(){this.setState({isFocusReturning:true}),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.focusFeedbackTimer=setTimeout(()=>this.setState({isFocusReturning:false}),500);}updateCursorPosition(e){chunkFWW6DLM7_cjs.u(e,this.state.position)||this.setState({position:{...e}});}updateCursorPositionByDelta(e){if(chunkFWW6DLM7_cjs.u(e,{x:0,y:0}))return;let t=this.rect;if(!t)return;let i=chunkFWW6DLM7_cjs.q(e.x,t.width),r=chunkFWW6DLM7_cjs.q(e.y,t.height);this.updateCursorPosition({x:chunkFWW6DLM7_cjs.f(this.state.position.x+i,0,100),y:chunkFWW6DLM7_cjs.f(this.state.position.y+r,0,100)});}showCursor(){this.setState({isVisible:true}),this.hideTimer&&clearTimeout(this.hideTimer),this.config.cursorAutoDelay&&this.config.cursorAutoDelay>0&&(this.hideTimer=setTimeout(()=>this.setState({isVisible:false}),this.config.cursorAutoDelay));}reset(){this.state.isPointerDown&&this.executeMouseAction(n.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:false,isPointerDown:false,isFocusReturning:false});}};var Z={isActive:false,isPressed:false,pointerId:null,value:0},Y=class extends l{constructor(e,t){super(e,u.TRACKPAD,t,Z);chunkFWW6DLM7_cjs.a(this,"lastPointerPos",{x:0,y:0});chunkFWW6DLM7_cjs.a(this,"throttledPointerMove");chunkFWW6DLM7_cjs.a(this,"gesture");chunkFWW6DLM7_cjs.a(this,"emitter");let i=t.mapping||{type:"mouse"};this.emitter=new d(t.targetStageId,i),this.throttledPointerMove=g(r=>{this.processPointerMove(r);}),this.gesture=new P({onTap:()=>{this.setState({isPressed:true}),this.emitter.tap();},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.emitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.emitter.release(false);}});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.lastPointerPos={x:e.clientX,y:e.clientY},this.gesture.onPointerDown(e.clientX,e.clientY),this.setState({isActive:true,pointerId:e.pointerId});}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.throttledPointerMove(e));}processPointerMove(e){if(!this.state.isActive)return;let t=e.clientX-this.lastPointerPos.x,i=e.clientY-this.lastPointerPos.y,r=this.rect;if(!r)return;let c=t/r.width*100*(this.config.sensitivity??1),p=i/r.height*100*(this.config.sensitivity??1),h={x:c,y:p};chunkFWW6DLM7_cjs.u(h,{x:0,y:0})||this.emitter.move({delta:h}),this.lastPointerPos={x:e.clientX,y:e.clientY};}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}reset(){this.gesture.reset(),this.emitter.reset(),this.handleRelease();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(){this.setState(Z);}};var Mt={ActionTypes:n,Context:_,Keys:E,Types:u};Object.defineProperty(exports,"Registry",{enumerable:true,get:function(){return chunkFWW6DLM7_cjs.b}});exports.ACTION_TYPES=n;exports.BaseEntity=l;exports.ButtonCore=R;exports.CMP_TYPES=u;exports.CONTEXT=_;exports.DPadCore=O;exports.GamepadManager=D;exports.InputManager=w;exports.InputZoneCore=K;exports.JoystickCore=N;exports.KEYS=E;exports.OmniPad=Mt;exports.RootLayerCore=F;exports.TargetZoneCore=U;exports.TrackpadCore=Y;
|
|
1
|
+
'use strict';var chunkPAGWIRTX_cjs=require('./chunk-PAGWIRTX.cjs');var X={Backspace:{key:"Backspace",code:"Backspace",keyCode:8},Tab:{key:"Tab",code:"Tab",keyCode:9},Enter:{key:"Enter",code:"Enter",keyCode:13},ShiftLeft:{key:"Shift",code:"ShiftLeft",keyCode:16},ControlLeft:{key:"Control",code:"ControlLeft",keyCode:17},AltLeft:{key:"Alt",code:"AltLeft",keyCode:18},Pause:{key:"Pause",code:"Pause",keyCode:19},CapsLock:{key:"CapsLock",code:"CapsLock",keyCode:20},Escape:{key:"Escape",code:"Escape",keyCode:27},Space:{key:" ",code:"Space",keyCode:32},PageUp:{key:"PageUp",code:"PageUp",keyCode:33},PageDown:{key:"PageDown",code:"PageDown",keyCode:34},End:{key:"End",code:"End",keyCode:35},Home:{key:"Home",code:"Home",keyCode:36},ArrowLeft:{key:"ArrowLeft",code:"ArrowLeft",keyCode:37},ArrowUp:{key:"ArrowUp",code:"ArrowUp",keyCode:38},ArrowRight:{key:"ArrowRight",code:"ArrowRight",keyCode:39},ArrowDown:{key:"ArrowDown",code:"ArrowDown",keyCode:40},PrintScreen:{key:"PrintScreen",code:"PrintScreen",keyCode:44},Insert:{key:"Insert",code:"Insert",keyCode:45},Delete:{key:"Delete",code:"Delete",keyCode:46},Digit0:{key:"0",code:"Digit0",keyCode:48},Digit1:{key:"1",code:"Digit1",keyCode:49},Digit2:{key:"2",code:"Digit2",keyCode:50},Digit3:{key:"3",code:"Digit3",keyCode:51},Digit4:{key:"4",code:"Digit4",keyCode:52},Digit5:{key:"5",code:"Digit5",keyCode:53},Digit6:{key:"6",code:"Digit6",keyCode:54},Digit7:{key:"7",code:"Digit7",keyCode:55},Digit8:{key:"8",code:"Digit8",keyCode:56},Digit9:{key:"9",code:"Digit9",keyCode:57},KeyA:{key:"a",code:"KeyA",keyCode:65},KeyB:{key:"b",code:"KeyB",keyCode:66},KeyC:{key:"c",code:"KeyC",keyCode:67},KeyD:{key:"d",code:"KeyD",keyCode:68},KeyE:{key:"e",code:"KeyE",keyCode:69},KeyF:{key:"f",code:"KeyF",keyCode:70},KeyG:{key:"g",code:"KeyG",keyCode:71},KeyH:{key:"h",code:"KeyH",keyCode:72},KeyI:{key:"i",code:"KeyI",keyCode:73},KeyJ:{key:"j",code:"KeyJ",keyCode:74},KeyK:{key:"k",code:"KeyK",keyCode:75},KeyL:{key:"l",code:"KeyL",keyCode:76},KeyM:{key:"m",code:"KeyM",keyCode:77},KeyN:{key:"n",code:"KeyN",keyCode:78},KeyO:{key:"o",code:"KeyO",keyCode:79},KeyP:{key:"p",code:"KeyP",keyCode:80},KeyQ:{key:"q",code:"KeyQ",keyCode:81},KeyR:{key:"r",code:"KeyR",keyCode:82},KeyS:{key:"s",code:"KeyS",keyCode:83},KeyT:{key:"t",code:"KeyT",keyCode:84},KeyU:{key:"u",code:"KeyU",keyCode:85},KeyV:{key:"v",code:"KeyV",keyCode:86},KeyW:{key:"w",code:"KeyW",keyCode:87},KeyX:{key:"x",code:"KeyX",keyCode:88},KeyY:{key:"y",code:"KeyY",keyCode:89},KeyZ:{key:"z",code:"KeyZ",keyCode:90},MetaLeft:{key:"Meta",code:"MetaLeft",keyCode:91},ContextMenu:{key:"ContextMenu",code:"ContextMenu",keyCode:93},Numpad0:{key:"0",code:"Numpad0",keyCode:96},Numpad1:{key:"1",code:"Numpad1",keyCode:97},Numpad2:{key:"2",code:"Numpad2",keyCode:98},Numpad3:{key:"3",code:"Numpad3",keyCode:99},Numpad4:{key:"4",code:"Numpad4",keyCode:100},Numpad5:{key:"5",code:"Numpad5",keyCode:101},Numpad6:{key:"6",code:"Numpad6",keyCode:102},Numpad7:{key:"7",code:"Numpad7",keyCode:103},Numpad8:{key:"8",code:"Numpad8",keyCode:104},Numpad9:{key:"9",code:"Numpad9",keyCode:105},NumpadMultiply:{key:"*",code:"NumpadMultiply",keyCode:106},NumpadAdd:{key:"+",code:"NumpadAdd",keyCode:107},NumpadSubtract:{key:"-",code:"NumpadSubtract",keyCode:109},NumpadDecimal:{key:".",code:"NumpadDecimal",keyCode:110},NumpadDivide:{key:"/",code:"NumpadDivide",keyCode:111},F1:{key:"F1",code:"F1",keyCode:112},F2:{key:"F2",code:"F2",keyCode:113},F3:{key:"F3",code:"F3",keyCode:114},F4:{key:"F4",code:"F4",keyCode:115},F5:{key:"F5",code:"F5",keyCode:116},F6:{key:"F6",code:"F6",keyCode:117},F7:{key:"F7",code:"F7",keyCode:118},F8:{key:"F8",code:"F8",keyCode:119},F9:{key:"F9",code:"F9",keyCode:120},F10:{key:"F10",code:"F10",keyCode:121},F11:{key:"F11",code:"F11",keyCode:122},F12:{key:"F12",code:"F12",keyCode:123},NumLock:{key:"NumLock",code:"NumLock",keyCode:144},ScrollLock:{key:"ScrollLock",code:"ScrollLock",keyCode:145},Semicolon:{key:";",code:"Semicolon",keyCode:186},Equal:{key:"=",code:"Equal",keyCode:187},Comma:{key:",",code:"Comma",keyCode:188},Minus:{key:"-",code:"Minus",keyCode:189},Period:{key:".",code:"Period",keyCode:190},Slash:{key:"/",code:"Slash",keyCode:191},Backquote:{key:"`",code:"Backquote",keyCode:192},BracketLeft:{key:"[",code:"BracketLeft",keyCode:219},Backslash:{key:"\\",code:"Backslash",keyCode:220},BracketRight:{key:"]",code:"BracketRight",keyCode:221},Quote:{key:"'",code:"Quote",keyCode:222}},E=X;var u={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"},n={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},_={PARENT_ID_KEY:"omnipad-parent-id-link"};var I=Symbol.for("omnipad.gamepad_manager.instance"),z={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 a{constructor(){chunkPAGWIRTX_cjs.a(this,"isRunning",false);chunkPAGWIRTX_cjs.a(this,"config",null);chunkPAGWIRTX_cjs.a(this,"lastButtonStates",[]);chunkPAGWIRTX_cjs.a(this,"loop",()=>{if(!this.isRunning)return;let o=navigator.getGamepads();this.config?.forEach((e,t)=>{let i=o[t];i&&i.connected&&e&&(this.lastButtonStates[t]||(this.lastButtonStates[t]=[]),this.processButtons(i,e,t),this.processDPad(i,e),this.processAxes(i,e));}),requestAnimationFrame(this.loop);});}static getInstance(){let o=globalThis;return o[I]||(o[I]=new a),o[I]}setConfig(o){this.config=o;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",o=>{undefined?.DEV&&console.log("[Omnipad-Core] Gamepad Connected:",o.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{undefined?.DEV&&console.log("[Omnipad-Core] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(o,e,t){e.buttons&&Object.entries(e.buttons).forEach(([i,s])=>{let c=z[i];if(c===void 0||!o.buttons[c])return;let p=o.buttons[c].pressed,h=this.lastButtonStates[t][c]||false;p&&!h?this.triggerVirtualEntity(s,"down"):!p&&h&&this.triggerVirtualEntity(s,"up"),this.lastButtonStates[t][c]=p;});}processDPad(o,e){let t=e?.dpad;if(!t)return;let i=o.buttons[12]?.pressed?-1:0,s=o.buttons[13]?.pressed?1:0,c=o.buttons[14]?.pressed?-1:0,p=o.buttons[15]?.pressed?1:0,h=c+p,f=i+s;this.triggerVirtualEntity(t,"vector",{x:h,y:f});}processAxes(o,e){let t=e?.deadzone??.1;if(e?.leftStick){let i=Math.abs(o.axes[0])>t?o.axes[0]:0,s=Math.abs(o.axes[1])>t?o.axes[1]:0;this.triggerVirtualEntity(e.leftStick,"vector",{x:i,y:s});}if(e?.rightStick){let i=Math.abs(o.axes[2])>t?o.axes[2]:0,s=Math.abs(o.axes[3])>t?o.axes[3]:0;this.triggerVirtualEntity(e.rightStick,"vector",{x:i,y:s});}}triggerVirtualEntity(o,e,t){let i=chunkPAGWIRTX_cjs.b.getInstance().getEntity(o);!i||i.activePointerId!=null||(e==="down"&&i.triggerDown&&i.triggerDown(),e==="up"&&i.triggerUp&&i.triggerUp(),e==="vector"&&i.triggerVector&&t&&i.triggerVector(t.x,t.y));}};var C=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):a=>setTimeout(a,16),q=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):a=>clearTimeout(a);function g(a){let o=false,e;return function(t){e=t,o||(o=true,C(()=>{a(e),o=false;}));}}function V(a){let o=null,e=()=>{a(),o=C(e);};return {start:()=>{o===null&&e();},stop:()=>{o!==null&&(q(o),o=null);}}}var H=(a=2)=>new Promise(o=>{let e=0,t=()=>{++e>=a?o():C(t);};C(t);});var w=Symbol.for("omnipad.window_manager.instance"),x=class a{constructor(){chunkPAGWIRTX_cjs.a(this,"_isListening",false);chunkPAGWIRTX_cjs.a(this,"throttledReset");chunkPAGWIRTX_cjs.a(this,"handleGlobalReset",()=>{undefined?.DEV&&console.debug("[OmniPad-Core] Safety reset triggered by environment change."),chunkPAGWIRTX_cjs.b.getInstance().resetAll();});chunkPAGWIRTX_cjs.a(this,"handleResizeReset",()=>{this.throttledReset(null);});chunkPAGWIRTX_cjs.a(this,"handleBlurReset",()=>{this.handleGlobalReset();});chunkPAGWIRTX_cjs.a(this,"handleScrollReset",()=>{this.throttledReset(null);});chunkPAGWIRTX_cjs.a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=g(()=>{this.handleGlobalReset();});}static getInstance(){let o=globalThis;return o[w]||(o[w]=new a),o[w]}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(o){let e=o||document.documentElement;try{document.fullscreenElement?(chunkPAGWIRTX_cjs.b.getInstance().resetAll(),await document.exitFullscreen()):(chunkPAGWIRTX_cjs.b.getInstance().resetAll(),await e.requestFullscreen());}catch(t){console.error("[OmniPad-Core] Fullscreen toggle failed:",t);}}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;}};var A=class{constructor(){chunkPAGWIRTX_cjs.a(this,"listeners",new Set);}subscribe(o){return this.listeners.add(o),()=>this.listeners.delete(o)}emit(o){this.listeners.forEach(e=>{try{e(o);}catch(t){console.error("[OmniPad-Core] Emitter callback error:",t);}});}clear(){this.listeners.clear();}};var l=class{constructor(o,e,t,i){chunkPAGWIRTX_cjs.a(this,"uid");chunkPAGWIRTX_cjs.a(this,"type");chunkPAGWIRTX_cjs.a(this,"config");chunkPAGWIRTX_cjs.a(this,"state");chunkPAGWIRTX_cjs.a(this,"rectProvider",null);chunkPAGWIRTX_cjs.a(this,"_onMarkDirtyCb",null);chunkPAGWIRTX_cjs.a(this,"stateEmitter",new A);this.uid=o,this.type=e,this.config=t,this.state=i;}subscribe(o){return o(this.state),this.stateEmitter.subscribe(o)}setState(o){this.state={...this.state,...o},this.stateEmitter.emit(this.state);}destroy(){this.reset(),this.stateEmitter.clear(),chunkPAGWIRTX_cjs.b.getInstance().unregister(this.uid);}get rect(){return this.rectProvider?this.rectProvider():null}bindRectProvider(o,e){this.rectProvider=o,e&&(this._onMarkDirtyCb=e);}markRectDirty(){this._onMarkDirtyCb?.();}updateConfig(o){this.config={...this.config,...o},this.stateEmitter.emit(this.state);}getState(){return this.state}getConfig(){return this.config}};var d=class{constructor(o,e){chunkPAGWIRTX_cjs.a(this,"isPressed",false);chunkPAGWIRTX_cjs.a(this,"mapping");chunkPAGWIRTX_cjs.a(this,"targetId");this.update(o,e);}update(o,e){this.isPressed&&this.reset(),this.targetId=o,this.mapping=this.hydrate(e);}hydrate(o){if(!o)return;let e={...o};if(e.type==="mouse")return e.button=e.button??0,e;let{key:t,code:i,keyCode:s}=e;if(t||i||s){e.type="keyboard";let c=Object.values(E).find(p=>p.code===i||p.key===t||p.keyCode===s);c&&(e.key=t??c.key,e.code=i??c.code,e.keyCode=s??c.keyCode);}return e}press(){if(!this.mapping||this.isPressed)return;this.isPressed=true;let o=this.mapping.type==="keyboard"?n.KEYDOWN:n.MOUSEDOWN;this.emitSignal(o);}release(o=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let e=this.mapping.type==="keyboard"?n.KEYUP:n.MOUSEUP;this.emitSignal(e),this.mapping.type==="mouse"&&o&&this.emitSignal(n.CLICK);}move(o){this.mapping?.type==="mouse"&&this.emitSignal(n.MOUSEMOVE,o);}reset(){this.isPressed&&this.release(false);}async tap(o=true){this.isPressed||(this.press(),await H(2),this.isPressed&&this.release(o));}emitSignal(o,e={}){if(!this.targetId||!this.mapping)return;let t=chunkPAGWIRTX_cjs.b.getInstance().getEntity(this.targetId);t&&t.handleSignal({targetStageId:this.targetId,type:o,payload:{key:this.mapping.key,code:this.mapping.code,keyCode:this.mapping.keyCode,button:this.mapping.button,point:this.mapping.fixedPoint,...e}});}};var M={isActive:false,isPressed:false,pointerId:null,value:0},R=class extends l{constructor(e,t){super(e,u.BUTTON,t,M);chunkPAGWIRTX_cjs.a(this,"emitter");this.emitter=new d(t.targetStageId,t.mapping);}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,isPressed:true,pointerId:e.pointerId}),this.emitter.press();}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.handleRelease(true);}onPointerCancel(){this.handleRelease(false);}onPointerMove(){}reset(){this.setState(M),this.emitter.reset();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(e){this.setState(M),this.emitter.release(e);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.emitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.emitter.release(true));}};var G={isActive:false,pointerId:null,vector:{x:0,y:0}},O=class extends l{constructor(e,t){super(e,u.D_PAD,t,G);chunkPAGWIRTX_cjs.a(this,"emitters");chunkPAGWIRTX_cjs.a(this,"throttledPointerMove");let i=t.targetStageId;this.emitters={up:new d(i,t.mapping?.up),down:new d(i,t.mapping?.down),left:new d(i,t.mapping?.left),right:new d(i,t.mapping?.right)},this.throttledPointerMove=g(s=>{this.processInput(s);});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}});}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.throttledPointerMove(e);}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.reset();}onPointerCancel(){this.reset();}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let s=i.left+i.width/2,c=i.top+i.height/2,p=i.width/2,h=i.height/2,f=(e.clientX-s)/p,b=(e.clientY-c)/h;if(t&&(f!=chunkPAGWIRTX_cjs.f(f,-1,1)||b!=chunkPAGWIRTX_cjs.f(b,-1,1))){this.setState({vector:{x:0,y:0}});return}let S={x:chunkPAGWIRTX_cjs.f(f,-1,1),y:chunkPAGWIRTX_cjs.f(b,-1,1)};this.setState({vector:S}),this.handleDigitalKeys(S);}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.emitters.up.reset(),this.emitters.down.reset(),this.emitters.left.reset(),this.emitters.right.reset(),this.setState(G);}updateConfig(e){super.updateConfig(e),this.emitters.up.update(this.config.targetStageId,this.config.mapping?.up),this.emitters.down.update(this.config.targetStageId,this.config.mapping?.down),this.emitters.left.update(this.config.targetStageId,this.config.mapping?.left),this.emitters.right.update(this.config.targetStageId,this.config.mapping?.right);}triggerVector(e,t){let i={x:e,y:t},s=this.config.threshold??.3;Math.abs(e)>=s||Math.abs(t)>=s?(this.setState({isActive:true,vector:i}),this.handleDigitalKeys(i)):this.reset();}};var J={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},K=class extends l{constructor(e,t){super(e,u.INPUT_ZONE,t,J);chunkPAGWIRTX_cjs.a(this,"delegates",{dynamicWidgetPointerDown:()=>{},dynamicWidgetPointerMove:()=>{},dynamicWidgetPointerUp:()=>{},dynamicWidgetPointerCancel:()=>{}});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:undefined?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return this.state.dynamicPointerId}onPointerDown(e){if(this.state.isDynamicActive)return;let t=this.calculateRelativePosition(e.clientX,e.clientY);this.setState({isDynamicActive:true,dynamicPointerId:e.pointerId,dynamicPosition:t}),this.delegates.dynamicWidgetPointerDown?.(e);}onPointerMove(e){this.state.isDynamicActive&&this.delegates.dynamicWidgetPointerMove?.(e);}onPointerUp(e){this.delegates.dynamicWidgetPointerUp?.(e),this.reset();}onPointerCancel(e){this.delegates.dynamicWidgetPointerCancel?.(e),this.reset();}calculateRelativePosition(e,t){let i=this.rect;return i?{x:chunkPAGWIRTX_cjs.q(e-i.left,i.width),y:chunkPAGWIRTX_cjs.q(t-i.top,i.height)}:{x:0,y:0}}get isInterceptorRequired(){return !!(this.config.dynamicWidgetId||this.config.preventFocusLoss)}reset(){this.setState({isDynamicActive:false,dynamicPointerId:null});}};var P=class{constructor(o={}){chunkPAGWIRTX_cjs.a(this,"options");chunkPAGWIRTX_cjs.a(this,"startTime",0);chunkPAGWIRTX_cjs.a(this,"startPos",{x:0,y:0});chunkPAGWIRTX_cjs.a(this,"lastTapTime",0);chunkPAGWIRTX_cjs.a(this,"hasMoved",false);chunkPAGWIRTX_cjs.a(this,"isDoubleTapHolding",false);this.options={tapTime:250,tapDistance:10,doubleTapGap:300,...o};}onPointerDown(o,e){let t=Date.now();this.startTime=t,this.startPos={x:o,y:e},this.hasMoved=false,t-this.lastTapTime<this.options.doubleTapGap?(this.isDoubleTapHolding=true,this.options.onDoubleTapHoldStart?.()):this.isDoubleTapHolding=false;}onPointerMove(o,e){this.hasMoved||Math.hypot(o-this.startPos.x,e-this.startPos.y)>this.options.tapDistance&&(this.hasMoved=true);}onPointerUp(){let o=Date.now(),e=o-this.startTime;this.isDoubleTapHolding?(this.isDoubleTapHolding=false,this.options.onDoubleTapHoldEnd?.(),this.lastTapTime=0):e<=this.options.tapTime&&!this.hasMoved&&(this.options.onTap?.(),o-this.lastTapTime<this.options.doubleTapGap?(this.options.onDoubleTap?.(),this.lastTapTime=0):this.lastTapTime=o);}reset(){this.isDoubleTapHolding&&this.options.onDoubleTapHoldEnd?.(),this.isDoubleTapHolding=false,this.hasMoved=false,this.startTime=0,this.lastTapTime=0;}};var W={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},N=class extends l{constructor(e,t){super(e,u.JOYSTICK,t,W);chunkPAGWIRTX_cjs.a(this,"emitters");chunkPAGWIRTX_cjs.a(this,"stickEmitter");chunkPAGWIRTX_cjs.a(this,"cursorEmitter");chunkPAGWIRTX_cjs.a(this,"gesture");chunkPAGWIRTX_cjs.a(this,"ticker");chunkPAGWIRTX_cjs.a(this,"throttledUpdate");let i=t.targetStageId,s=t.mapping||{};this.emitters={up:new d(i,s.up),down:new d(i,s.down),left:new d(i,s.left),right:new d(i,s.right)},this.stickEmitter=new d(i,s.stick),this.cursorEmitter=new d(i,{type:"mouse"}),this.gesture=new P({onTap:async()=>{this.setState({isPressed:true}),await this.stickEmitter.tap(),this.setState({isPressed:false});},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.stickEmitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.stickEmitter.release(false);}}),this.ticker=V(()=>{this.handleCursorTick();}),this.throttledUpdate=g(c=>{this.processInput(c);});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}}),this.gesture.onPointerDown(e.clientX,e.clientY);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.config.cursorMode&&this.ticker.start(),this.throttledUpdate(e));}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}handleRelease(){this.setState({isActive:false,pointerId:null,vector:{x:0,y:0}}),this.ticker.stop(),Object.values(this.emitters).forEach(e=>e?.reset());}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let s=i.left+i.width/2,c=i.top+i.height/2,p=i.width/2,h=i.height/2,f=(e.clientX-s)/p,b=(e.clientY-c)/h;if(t&&(f!=chunkPAGWIRTX_cjs.f(f,-1,1)||b!=chunkPAGWIRTX_cjs.f(b,-1,1))){this.setState({vector:{x:0,y:0}});return}let L=chunkPAGWIRTX_cjs.w({x:f,y:b},1,this.config.threshold||.15);this.setState({vector:L}),this.handleDigitalKeys(L);}handleCursorTick(){let{vector:e,isActive:t}=this.state;if(!t||!this.config.cursorMode)return;let i=this.config.cursorSensitivity??1,s={x:e.x*i,y:e.y*i};(Math.abs(s.x)>0||Math.abs(s.y)>0)&&this.cursorEmitter.move({delta:s});}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.setState(W),this.gesture.reset(),this.handleRelease(),this.stickEmitter.reset(),this.cursorEmitter.reset();}updateConfig(e){super.updateConfig(e);let t=this.config.targetStageId,i=this.config.mapping||{};this.emitters.up.update(t,i.up),this.emitters.down.update(t,i.down),this.emitters.left.update(t,i.left),this.emitters.right.update(t,i.right),this.stickEmitter.update(t,i.stick),this.cursorEmitter.update(t);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.stickEmitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.stickEmitter.release(true));}triggerVector(e,t){let i={x:e,y:t},s=this.config.threshold??.3;Math.abs(e)>=s||Math.abs(t)>=s?(this.setState({isActive:true,vector:i}),this.handleDigitalKeys(i),this.config.cursorMode&&this.ticker.start()):this.handleRelease();}};var j={isHighlighted:false},F=class extends l{constructor(o,e){super(o,u.ROOT_LAYER,e,j);}reset(){}};var Q={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},U=class extends l{constructor(e,t){super(e,u.TARGET_ZONE,t,Q);chunkPAGWIRTX_cjs.a(this,"hideTimer",null);chunkPAGWIRTX_cjs.a(this,"focusFeedbackTimer",null);chunkPAGWIRTX_cjs.a(this,"throttledPointerMove");chunkPAGWIRTX_cjs.a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledPointerMove=g(i=>{this.processPhysicalEvent(i,n.MOUSEMOVE);});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:undefined?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return null}onPointerDown(e){this.processPhysicalEvent(e,n.MOUSEDOWN);}onPointerMove(e){this.throttledPointerMove(e);}onPointerUp(e){this.processPhysicalEvent(e,n.MOUSEUP),this.processPhysicalEvent(e,n.CLICK);}onPointerCancel(e){this.processPhysicalEvent(e,n.MOUSEUP);}processPhysicalEvent(e,t){let i=this.rect;if(!i)return;let s={x:chunkPAGWIRTX_cjs.q(e.clientX-i.left,i.width),y:chunkPAGWIRTX_cjs.q(e.clientY-i.top,i.height)};this.handleSignal({targetStageId:this.uid,type:t,payload:{point:s,button:e.button}});}handleSignal(e){let{type:t,payload:i}=e;switch(this.ensureFocus(),t){case n.KEYDOWN:case n.KEYUP:this.delegates.dispatchKeyboardEvent?.(t,i);break;case n.MOUSEMOVE:i.point?this.updateCursorPosition(i.point):i.delta&&this.updateCursorPositionByDelta(i.delta),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(n.POINTERMOVE,i);break;case n.MOUSEDOWN:case n.MOUSEUP:case n.CLICK:i.point&&this.updateCursorPosition(i.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(t.startsWith(n.MOUSE)?t.replace(n.MOUSE,n.POINTER):t,i);break}}executeMouseAction(e,t){let i=this.rect;if(!i)return;e===n.POINTERDOWN&&this.setState({isPointerDown:true}),e===n.POINTERUP&&this.setState({isPointerDown:false});let s=t.point||this.state.position,c=i.left+chunkPAGWIRTX_cjs.p(s.x,i.width),p=i.top+chunkPAGWIRTX_cjs.p(s.y,i.height);this.delegates.dispatchPointerEventAtPos?.(e,c,p,{button:t.button??0,buttons:this.state.isPointerDown?1:0,pressure:this.state.isPointerDown?.5:0});}ensureFocus(){let e=this.rect;if(!e)return;let t=e.left+chunkPAGWIRTX_cjs.p(this.state.position.x,e.width),i=e.top+chunkPAGWIRTX_cjs.p(this.state.position.y,e.height);this.delegates.reclaimFocusAtPos?.(t,i,()=>this.triggerFocusFeedback());}triggerFocusFeedback(){this.setState({isFocusReturning:true}),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.focusFeedbackTimer=setTimeout(()=>this.setState({isFocusReturning:false}),500);}updateCursorPosition(e){chunkPAGWIRTX_cjs.u(e,this.state.position)||this.setState({position:{...e}});}updateCursorPositionByDelta(e){if(chunkPAGWIRTX_cjs.u(e,{x:0,y:0}))return;let t=this.rect;if(!t)return;let i=chunkPAGWIRTX_cjs.q(e.x,t.width),s=chunkPAGWIRTX_cjs.q(e.y,t.height);this.updateCursorPosition({x:chunkPAGWIRTX_cjs.f(this.state.position.x+i,0,100),y:chunkPAGWIRTX_cjs.f(this.state.position.y+s,0,100)});}showCursor(){this.setState({isVisible:true}),this.hideTimer&&clearTimeout(this.hideTimer),this.config.cursorAutoDelay&&this.config.cursorAutoDelay>0&&(this.hideTimer=setTimeout(()=>this.setState({isVisible:false}),this.config.cursorAutoDelay));}reset(){this.state.isPointerDown&&this.executeMouseAction(n.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:false,isPointerDown:false,isFocusReturning:false});}};var Z={isActive:false,isPressed:false,pointerId:null,value:0},Y=class extends l{constructor(e,t){super(e,u.TRACKPAD,t,Z);chunkPAGWIRTX_cjs.a(this,"lastPointerPos",{x:0,y:0});chunkPAGWIRTX_cjs.a(this,"throttledPointerMove");chunkPAGWIRTX_cjs.a(this,"gesture");chunkPAGWIRTX_cjs.a(this,"emitter");let i=t.mapping||{type:"mouse"};this.emitter=new d(t.targetStageId,i),this.throttledPointerMove=g(s=>{this.processPointerMove(s);}),this.gesture=new P({onTap:()=>{this.setState({isPressed:true}),this.emitter.tap();},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.emitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.emitter.release(false);}});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.lastPointerPos={x:e.clientX,y:e.clientY},this.gesture.onPointerDown(e.clientX,e.clientY),this.setState({isActive:true,pointerId:e.pointerId});}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.throttledPointerMove(e));}processPointerMove(e){if(!this.state.isActive)return;let t=e.clientX-this.lastPointerPos.x,i=e.clientY-this.lastPointerPos.y,s=this.rect;if(!s)return;let c=t/s.width*100*(this.config.sensitivity??1),p=i/s.height*100*(this.config.sensitivity??1),h={x:c,y:p};chunkPAGWIRTX_cjs.u(h,{x:0,y:0})||this.emitter.move({delta:h}),this.lastPointerPos={x:e.clientX,y:e.clientY};}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}reset(){this.gesture.reset(),this.emitter.reset(),this.handleRelease();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(){this.setState(Z);}};var Mt={ActionTypes:n,Context:_,Keys:E,Types:u};Object.defineProperty(exports,"Registry",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.b}});exports.ACTION_TYPES=n;exports.BaseEntity=l;exports.ButtonCore=R;exports.CMP_TYPES=u;exports.CONTEXT=_;exports.DPadCore=O;exports.GamepadManager=D;exports.InputZoneCore=K;exports.JoystickCore=N;exports.KEYS=E;exports.OmniPad=Mt;exports.RootLayerCore=F;exports.TargetZoneCore=U;exports.TrackpadCore=Y;exports.WindowManager=x;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as ICoreEntity, V as Vec2, G as GamepadMappingConfig, a as ISpatial, b as IResettable, c as IConfigurable, d as IObservable, E as EntityType, A as AbstractRect, B as ButtonConfig, e as IPointerHandler, f as IProgrammatic, g as AbstractPointerEvent, D as DPadConfig, h as InputZoneConfig, i as IDependencyBindable, j as AnyFunction, J as JoystickConfig, k as BaseConfig, T as TargetZoneConfig, l as ISignalReceiver, m as InputActionSignal, n as TrackpadConfig } from './index-
|
|
2
|
-
export { o as ACTION_TYPES, p as ActionMapping, q as AnchorPoint, r as AnyConfig, s as AnyEntityType, t as BuiltInActionType, C as CMP_TYPES, u as CONTEXT, v as ConfigTreeNode, F as FlatConfigItem, w as FlexibleLength, x as GamepadProfile, y as IIdentifiable, z as ILifecycle, H as InputActionType, K as KEYS, L as KeyMapping, M as LayoutBox, S as StageId, N as StandardButton, U as Unit, W as WidgetId, O as WidgetType, Z as ZoneId, P as ZoneType } from './index-
|
|
1
|
+
import { I as ICoreEntity, V as Vec2, G as GamepadMappingConfig, a as ISpatial, b as IResettable, c as IConfigurable, d as IObservable, E as EntityType, A as AbstractRect, B as ButtonConfig, e as IPointerHandler, f as IProgrammatic, g as AbstractPointerEvent, D as DPadConfig, h as InputZoneConfig, i as IDependencyBindable, j as AnyFunction, J as JoystickConfig, k as BaseConfig, T as TargetZoneConfig, l as ISignalReceiver, m as InputActionSignal, n as TrackpadConfig } from './index-DlGCSMP1.cjs';
|
|
2
|
+
export { o as ACTION_TYPES, p as ActionMapping, q as AnchorPoint, r as AnyConfig, s as AnyEntityType, t as BuiltInActionType, C as CMP_TYPES, u as CONTEXT, v as ConfigTreeNode, F as FlatConfigItem, w as FlexibleLength, x as GamepadProfile, y as IIdentifiable, z as ILifecycle, H as InputActionType, K as KEYS, L as KeyMapping, M as LayoutBox, S as StageId, N as StandardButton, U as Unit, W as WidgetId, O as WidgetType, Z as ZoneId, P as ZoneType } from './index-DlGCSMP1.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Interface for the global Registry singleton.
|
|
@@ -218,29 +218,60 @@ declare class GamepadManager {
|
|
|
218
218
|
private triggerVirtualEntity;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Global Registry Singleton.
|
|
223
|
+
*
|
|
224
|
+
* Acts as the "Census Bureau" for the system, maintaining references to all active
|
|
225
|
+
* logic entities (Stages, Widgets, Layers). It enables cross-component communication
|
|
226
|
+
* and coordinate mapping by allowing entities to look each other up via UIDs.
|
|
227
|
+
*/
|
|
228
|
+
declare class Registry implements IRegistry {
|
|
229
|
+
/** Internal storage: Mapping of Entity UID to Entity Instance */
|
|
230
|
+
private entities;
|
|
231
|
+
/**
|
|
232
|
+
* Private constructor to enforce singleton pattern.
|
|
233
|
+
*/
|
|
234
|
+
private constructor();
|
|
235
|
+
/**
|
|
236
|
+
* Retrieves the global instance of the Registry.
|
|
237
|
+
* Uses globalThis to ensure the instance is unique even if the library is loaded multiple times.
|
|
238
|
+
*/
|
|
239
|
+
static getInstance(): Registry;
|
|
240
|
+
register(entity: ICoreEntity): void;
|
|
241
|
+
unregister(uid: string): void;
|
|
242
|
+
getEntity<T extends ICoreEntity = ICoreEntity>(uid: string): T | undefined;
|
|
243
|
+
getAllEntities(): ICoreEntity[];
|
|
244
|
+
getEntitiesByRoot(rootUid: string): ICoreEntity[];
|
|
245
|
+
destroyByRoot(rootUid: string): void;
|
|
246
|
+
clear(): void;
|
|
247
|
+
resetAll(): void;
|
|
248
|
+
debugGetSnapshot(): Map<string, ICoreEntity>;
|
|
249
|
+
}
|
|
250
|
+
|
|
221
251
|
/**
|
|
222
252
|
* Global Input Manager Singleton.
|
|
223
253
|
*
|
|
224
254
|
* Responsible for monitoring global browser events (resize, blur, visibility)
|
|
225
255
|
* and coordinating system-wide resets to prevent stuck inputs.
|
|
226
256
|
*/
|
|
227
|
-
declare class
|
|
257
|
+
declare class WindowManager {
|
|
228
258
|
/** Internal flag to prevent multiple event registrations */
|
|
229
259
|
private _isListening;
|
|
230
260
|
/** A throttled version of the reset logic */
|
|
231
261
|
private throttledReset;
|
|
232
262
|
private constructor();
|
|
233
263
|
/**
|
|
234
|
-
* Retrieves the global instance of the
|
|
264
|
+
* Retrieves the global instance of the WindowManager.
|
|
235
265
|
* Ensures uniqueness across multiple bundles or modules.
|
|
236
266
|
*/
|
|
237
|
-
static getInstance():
|
|
267
|
+
static getInstance(): WindowManager;
|
|
238
268
|
/**
|
|
239
269
|
* Manually triggers a system-wide input reset via Registry.
|
|
240
270
|
*/
|
|
241
271
|
private handleGlobalReset;
|
|
242
272
|
private handleResizeReset;
|
|
243
273
|
private handleBlurReset;
|
|
274
|
+
private handleScrollReset;
|
|
244
275
|
private handleVisibilityChangeReset;
|
|
245
276
|
/**
|
|
246
277
|
* Initializes global safety listeners.
|
|
@@ -262,36 +293,6 @@ declare class InputManager {
|
|
|
262
293
|
destroy(): void;
|
|
263
294
|
}
|
|
264
295
|
|
|
265
|
-
/**
|
|
266
|
-
* Global Registry Singleton.
|
|
267
|
-
*
|
|
268
|
-
* Acts as the "Census Bureau" for the system, maintaining references to all active
|
|
269
|
-
* logic entities (Stages, Widgets, Layers). It enables cross-component communication
|
|
270
|
-
* and coordinate mapping by allowing entities to look each other up via UIDs.
|
|
271
|
-
*/
|
|
272
|
-
declare class Registry implements IRegistry {
|
|
273
|
-
/** Internal storage: Mapping of Entity UID to Entity Instance */
|
|
274
|
-
private entities;
|
|
275
|
-
/**
|
|
276
|
-
* Private constructor to enforce singleton pattern.
|
|
277
|
-
*/
|
|
278
|
-
private constructor();
|
|
279
|
-
/**
|
|
280
|
-
* Retrieves the global instance of the Registry.
|
|
281
|
-
* Uses globalThis to ensure the instance is unique even if the library is loaded multiple times.
|
|
282
|
-
*/
|
|
283
|
-
static getInstance(): Registry;
|
|
284
|
-
register(entity: ICoreEntity): void;
|
|
285
|
-
unregister(uid: string): void;
|
|
286
|
-
getEntity<T extends ICoreEntity = ICoreEntity>(uid: string): T | undefined;
|
|
287
|
-
getAllEntities(): ICoreEntity[];
|
|
288
|
-
getEntitiesByRoot(rootUid: string): ICoreEntity[];
|
|
289
|
-
destroyByRoot(rootUid: string): void;
|
|
290
|
-
clear(): void;
|
|
291
|
-
resetAll(): void;
|
|
292
|
-
debugGetSnapshot(): Map<string, ICoreEntity>;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
296
|
/**
|
|
296
297
|
* Represents a callback function for the emitter.
|
|
297
298
|
* @template T - The type of data being broadcasted.
|
|
@@ -337,6 +338,7 @@ declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpat
|
|
|
337
338
|
protected config: TConfig;
|
|
338
339
|
protected state: TState;
|
|
339
340
|
protected rectProvider: (() => AbstractRect) | null;
|
|
341
|
+
private _onMarkDirtyCb;
|
|
340
342
|
protected stateEmitter: SimpleEmitter<TState>;
|
|
341
343
|
constructor(uid: string, type: EntityType, initialConfig: TConfig, initialState: TState);
|
|
342
344
|
subscribe(cb: (state: TState) => void): () => void;
|
|
@@ -349,7 +351,8 @@ declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpat
|
|
|
349
351
|
destroy(): void;
|
|
350
352
|
abstract reset(): void;
|
|
351
353
|
get rect(): AbstractRect | null;
|
|
352
|
-
bindRectProvider(provider: () => AbstractRect): void;
|
|
354
|
+
bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
|
|
355
|
+
markRectDirty(): void;
|
|
353
356
|
updateConfig(newConfig: Partial<TConfig>): void;
|
|
354
357
|
getState(): Readonly<TState>;
|
|
355
358
|
getConfig(): Readonly<TConfig>;
|
|
@@ -1115,4 +1118,4 @@ declare const OmniPad: {
|
|
|
1115
1118
|
};
|
|
1116
1119
|
};
|
|
1117
1120
|
|
|
1118
|
-
export { AbstractPointerEvent, AbstractRect, AnyFunction, type AxisLogicState, BaseConfig, BaseEntity, ButtonConfig, ButtonCore, type ButtonLogicState, type ButtonState, type CursorState, DPadConfig, DPadCore, type DPadState, EntityType, GamepadManager, GamepadMappingConfig, IConfigurable, ICoreEntity, IDependencyBindable, IObservable, IPointerHandler, IProgrammatic, type IRegistry, IResettable, ISignalReceiver, ISpatial, InputActionSignal,
|
|
1121
|
+
export { AbstractPointerEvent, AbstractRect, AnyFunction, type AxisLogicState, BaseConfig, BaseEntity, ButtonConfig, ButtonCore, type ButtonLogicState, type ButtonState, type CursorState, DPadConfig, DPadCore, type DPadState, EntityType, GamepadManager, GamepadMappingConfig, IConfigurable, ICoreEntity, IDependencyBindable, IObservable, IPointerHandler, IProgrammatic, type IRegistry, IResettable, ISignalReceiver, ISpatial, InputActionSignal, InputZoneConfig, InputZoneCore, type InputZoneState, type InteractionState, JoystickConfig, JoystickCore, type JoystickState, type KeyboardButtonState, type LayerState, type MouseButtonState, OmniPad, Registry, RootLayerCore, TargetZoneConfig, TargetZoneCore, TrackpadConfig, TrackpadCore, type TrackpadState, Vec2, WindowManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as ICoreEntity, V as Vec2, G as GamepadMappingConfig, a as ISpatial, b as IResettable, c as IConfigurable, d as IObservable, E as EntityType, A as AbstractRect, B as ButtonConfig, e as IPointerHandler, f as IProgrammatic, g as AbstractPointerEvent, D as DPadConfig, h as InputZoneConfig, i as IDependencyBindable, j as AnyFunction, J as JoystickConfig, k as BaseConfig, T as TargetZoneConfig, l as ISignalReceiver, m as InputActionSignal, n as TrackpadConfig } from './index-
|
|
2
|
-
export { o as ACTION_TYPES, p as ActionMapping, q as AnchorPoint, r as AnyConfig, s as AnyEntityType, t as BuiltInActionType, C as CMP_TYPES, u as CONTEXT, v as ConfigTreeNode, F as FlatConfigItem, w as FlexibleLength, x as GamepadProfile, y as IIdentifiable, z as ILifecycle, H as InputActionType, K as KEYS, L as KeyMapping, M as LayoutBox, S as StageId, N as StandardButton, U as Unit, W as WidgetId, O as WidgetType, Z as ZoneId, P as ZoneType } from './index-
|
|
1
|
+
import { I as ICoreEntity, V as Vec2, G as GamepadMappingConfig, a as ISpatial, b as IResettable, c as IConfigurable, d as IObservable, E as EntityType, A as AbstractRect, B as ButtonConfig, e as IPointerHandler, f as IProgrammatic, g as AbstractPointerEvent, D as DPadConfig, h as InputZoneConfig, i as IDependencyBindable, j as AnyFunction, J as JoystickConfig, k as BaseConfig, T as TargetZoneConfig, l as ISignalReceiver, m as InputActionSignal, n as TrackpadConfig } from './index-DlGCSMP1.js';
|
|
2
|
+
export { o as ACTION_TYPES, p as ActionMapping, q as AnchorPoint, r as AnyConfig, s as AnyEntityType, t as BuiltInActionType, C as CMP_TYPES, u as CONTEXT, v as ConfigTreeNode, F as FlatConfigItem, w as FlexibleLength, x as GamepadProfile, y as IIdentifiable, z as ILifecycle, H as InputActionType, K as KEYS, L as KeyMapping, M as LayoutBox, S as StageId, N as StandardButton, U as Unit, W as WidgetId, O as WidgetType, Z as ZoneId, P as ZoneType } from './index-DlGCSMP1.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Interface for the global Registry singleton.
|
|
@@ -218,29 +218,60 @@ declare class GamepadManager {
|
|
|
218
218
|
private triggerVirtualEntity;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Global Registry Singleton.
|
|
223
|
+
*
|
|
224
|
+
* Acts as the "Census Bureau" for the system, maintaining references to all active
|
|
225
|
+
* logic entities (Stages, Widgets, Layers). It enables cross-component communication
|
|
226
|
+
* and coordinate mapping by allowing entities to look each other up via UIDs.
|
|
227
|
+
*/
|
|
228
|
+
declare class Registry implements IRegistry {
|
|
229
|
+
/** Internal storage: Mapping of Entity UID to Entity Instance */
|
|
230
|
+
private entities;
|
|
231
|
+
/**
|
|
232
|
+
* Private constructor to enforce singleton pattern.
|
|
233
|
+
*/
|
|
234
|
+
private constructor();
|
|
235
|
+
/**
|
|
236
|
+
* Retrieves the global instance of the Registry.
|
|
237
|
+
* Uses globalThis to ensure the instance is unique even if the library is loaded multiple times.
|
|
238
|
+
*/
|
|
239
|
+
static getInstance(): Registry;
|
|
240
|
+
register(entity: ICoreEntity): void;
|
|
241
|
+
unregister(uid: string): void;
|
|
242
|
+
getEntity<T extends ICoreEntity = ICoreEntity>(uid: string): T | undefined;
|
|
243
|
+
getAllEntities(): ICoreEntity[];
|
|
244
|
+
getEntitiesByRoot(rootUid: string): ICoreEntity[];
|
|
245
|
+
destroyByRoot(rootUid: string): void;
|
|
246
|
+
clear(): void;
|
|
247
|
+
resetAll(): void;
|
|
248
|
+
debugGetSnapshot(): Map<string, ICoreEntity>;
|
|
249
|
+
}
|
|
250
|
+
|
|
221
251
|
/**
|
|
222
252
|
* Global Input Manager Singleton.
|
|
223
253
|
*
|
|
224
254
|
* Responsible for monitoring global browser events (resize, blur, visibility)
|
|
225
255
|
* and coordinating system-wide resets to prevent stuck inputs.
|
|
226
256
|
*/
|
|
227
|
-
declare class
|
|
257
|
+
declare class WindowManager {
|
|
228
258
|
/** Internal flag to prevent multiple event registrations */
|
|
229
259
|
private _isListening;
|
|
230
260
|
/** A throttled version of the reset logic */
|
|
231
261
|
private throttledReset;
|
|
232
262
|
private constructor();
|
|
233
263
|
/**
|
|
234
|
-
* Retrieves the global instance of the
|
|
264
|
+
* Retrieves the global instance of the WindowManager.
|
|
235
265
|
* Ensures uniqueness across multiple bundles or modules.
|
|
236
266
|
*/
|
|
237
|
-
static getInstance():
|
|
267
|
+
static getInstance(): WindowManager;
|
|
238
268
|
/**
|
|
239
269
|
* Manually triggers a system-wide input reset via Registry.
|
|
240
270
|
*/
|
|
241
271
|
private handleGlobalReset;
|
|
242
272
|
private handleResizeReset;
|
|
243
273
|
private handleBlurReset;
|
|
274
|
+
private handleScrollReset;
|
|
244
275
|
private handleVisibilityChangeReset;
|
|
245
276
|
/**
|
|
246
277
|
* Initializes global safety listeners.
|
|
@@ -262,36 +293,6 @@ declare class InputManager {
|
|
|
262
293
|
destroy(): void;
|
|
263
294
|
}
|
|
264
295
|
|
|
265
|
-
/**
|
|
266
|
-
* Global Registry Singleton.
|
|
267
|
-
*
|
|
268
|
-
* Acts as the "Census Bureau" for the system, maintaining references to all active
|
|
269
|
-
* logic entities (Stages, Widgets, Layers). It enables cross-component communication
|
|
270
|
-
* and coordinate mapping by allowing entities to look each other up via UIDs.
|
|
271
|
-
*/
|
|
272
|
-
declare class Registry implements IRegistry {
|
|
273
|
-
/** Internal storage: Mapping of Entity UID to Entity Instance */
|
|
274
|
-
private entities;
|
|
275
|
-
/**
|
|
276
|
-
* Private constructor to enforce singleton pattern.
|
|
277
|
-
*/
|
|
278
|
-
private constructor();
|
|
279
|
-
/**
|
|
280
|
-
* Retrieves the global instance of the Registry.
|
|
281
|
-
* Uses globalThis to ensure the instance is unique even if the library is loaded multiple times.
|
|
282
|
-
*/
|
|
283
|
-
static getInstance(): Registry;
|
|
284
|
-
register(entity: ICoreEntity): void;
|
|
285
|
-
unregister(uid: string): void;
|
|
286
|
-
getEntity<T extends ICoreEntity = ICoreEntity>(uid: string): T | undefined;
|
|
287
|
-
getAllEntities(): ICoreEntity[];
|
|
288
|
-
getEntitiesByRoot(rootUid: string): ICoreEntity[];
|
|
289
|
-
destroyByRoot(rootUid: string): void;
|
|
290
|
-
clear(): void;
|
|
291
|
-
resetAll(): void;
|
|
292
|
-
debugGetSnapshot(): Map<string, ICoreEntity>;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
296
|
/**
|
|
296
297
|
* Represents a callback function for the emitter.
|
|
297
298
|
* @template T - The type of data being broadcasted.
|
|
@@ -337,6 +338,7 @@ declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpat
|
|
|
337
338
|
protected config: TConfig;
|
|
338
339
|
protected state: TState;
|
|
339
340
|
protected rectProvider: (() => AbstractRect) | null;
|
|
341
|
+
private _onMarkDirtyCb;
|
|
340
342
|
protected stateEmitter: SimpleEmitter<TState>;
|
|
341
343
|
constructor(uid: string, type: EntityType, initialConfig: TConfig, initialState: TState);
|
|
342
344
|
subscribe(cb: (state: TState) => void): () => void;
|
|
@@ -349,7 +351,8 @@ declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpat
|
|
|
349
351
|
destroy(): void;
|
|
350
352
|
abstract reset(): void;
|
|
351
353
|
get rect(): AbstractRect | null;
|
|
352
|
-
bindRectProvider(provider: () => AbstractRect): void;
|
|
354
|
+
bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
|
|
355
|
+
markRectDirty(): void;
|
|
353
356
|
updateConfig(newConfig: Partial<TConfig>): void;
|
|
354
357
|
getState(): Readonly<TState>;
|
|
355
358
|
getConfig(): Readonly<TConfig>;
|
|
@@ -1115,4 +1118,4 @@ declare const OmniPad: {
|
|
|
1115
1118
|
};
|
|
1116
1119
|
};
|
|
1117
1120
|
|
|
1118
|
-
export { AbstractPointerEvent, AbstractRect, AnyFunction, type AxisLogicState, BaseConfig, BaseEntity, ButtonConfig, ButtonCore, type ButtonLogicState, type ButtonState, type CursorState, DPadConfig, DPadCore, type DPadState, EntityType, GamepadManager, GamepadMappingConfig, IConfigurable, ICoreEntity, IDependencyBindable, IObservable, IPointerHandler, IProgrammatic, type IRegistry, IResettable, ISignalReceiver, ISpatial, InputActionSignal,
|
|
1121
|
+
export { AbstractPointerEvent, AbstractRect, AnyFunction, type AxisLogicState, BaseConfig, BaseEntity, ButtonConfig, ButtonCore, type ButtonLogicState, type ButtonState, type CursorState, DPadConfig, DPadCore, type DPadState, EntityType, GamepadManager, GamepadMappingConfig, IConfigurable, ICoreEntity, IDependencyBindable, IObservable, IPointerHandler, IProgrammatic, type IRegistry, IResettable, ISignalReceiver, ISpatial, InputActionSignal, InputZoneConfig, InputZoneCore, type InputZoneState, type InteractionState, JoystickConfig, JoystickCore, type JoystickState, type KeyboardButtonState, type LayerState, type MouseButtonState, OmniPad, Registry, RootLayerCore, TargetZoneConfig, TargetZoneCore, TrackpadConfig, TrackpadCore, type TrackpadState, Vec2, WindowManager };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,b,f,q as q$1,w as w$1,p,u as u$1}from'./chunk-K6RXCH3Q.mjs';export{b as Registry}from'./chunk-K6RXCH3Q.mjs';var X={Backspace:{key:"Backspace",code:"Backspace",keyCode:8},Tab:{key:"Tab",code:"Tab",keyCode:9},Enter:{key:"Enter",code:"Enter",keyCode:13},ShiftLeft:{key:"Shift",code:"ShiftLeft",keyCode:16},ControlLeft:{key:"Control",code:"ControlLeft",keyCode:17},AltLeft:{key:"Alt",code:"AltLeft",keyCode:18},Pause:{key:"Pause",code:"Pause",keyCode:19},CapsLock:{key:"CapsLock",code:"CapsLock",keyCode:20},Escape:{key:"Escape",code:"Escape",keyCode:27},Space:{key:" ",code:"Space",keyCode:32},PageUp:{key:"PageUp",code:"PageUp",keyCode:33},PageDown:{key:"PageDown",code:"PageDown",keyCode:34},End:{key:"End",code:"End",keyCode:35},Home:{key:"Home",code:"Home",keyCode:36},ArrowLeft:{key:"ArrowLeft",code:"ArrowLeft",keyCode:37},ArrowUp:{key:"ArrowUp",code:"ArrowUp",keyCode:38},ArrowRight:{key:"ArrowRight",code:"ArrowRight",keyCode:39},ArrowDown:{key:"ArrowDown",code:"ArrowDown",keyCode:40},PrintScreen:{key:"PrintScreen",code:"PrintScreen",keyCode:44},Insert:{key:"Insert",code:"Insert",keyCode:45},Delete:{key:"Delete",code:"Delete",keyCode:46},Digit0:{key:"0",code:"Digit0",keyCode:48},Digit1:{key:"1",code:"Digit1",keyCode:49},Digit2:{key:"2",code:"Digit2",keyCode:50},Digit3:{key:"3",code:"Digit3",keyCode:51},Digit4:{key:"4",code:"Digit4",keyCode:52},Digit5:{key:"5",code:"Digit5",keyCode:53},Digit6:{key:"6",code:"Digit6",keyCode:54},Digit7:{key:"7",code:"Digit7",keyCode:55},Digit8:{key:"8",code:"Digit8",keyCode:56},Digit9:{key:"9",code:"Digit9",keyCode:57},KeyA:{key:"a",code:"KeyA",keyCode:65},KeyB:{key:"b",code:"KeyB",keyCode:66},KeyC:{key:"c",code:"KeyC",keyCode:67},KeyD:{key:"d",code:"KeyD",keyCode:68},KeyE:{key:"e",code:"KeyE",keyCode:69},KeyF:{key:"f",code:"KeyF",keyCode:70},KeyG:{key:"g",code:"KeyG",keyCode:71},KeyH:{key:"h",code:"KeyH",keyCode:72},KeyI:{key:"i",code:"KeyI",keyCode:73},KeyJ:{key:"j",code:"KeyJ",keyCode:74},KeyK:{key:"k",code:"KeyK",keyCode:75},KeyL:{key:"l",code:"KeyL",keyCode:76},KeyM:{key:"m",code:"KeyM",keyCode:77},KeyN:{key:"n",code:"KeyN",keyCode:78},KeyO:{key:"o",code:"KeyO",keyCode:79},KeyP:{key:"p",code:"KeyP",keyCode:80},KeyQ:{key:"q",code:"KeyQ",keyCode:81},KeyR:{key:"r",code:"KeyR",keyCode:82},KeyS:{key:"s",code:"KeyS",keyCode:83},KeyT:{key:"t",code:"KeyT",keyCode:84},KeyU:{key:"u",code:"KeyU",keyCode:85},KeyV:{key:"v",code:"KeyV",keyCode:86},KeyW:{key:"w",code:"KeyW",keyCode:87},KeyX:{key:"x",code:"KeyX",keyCode:88},KeyY:{key:"y",code:"KeyY",keyCode:89},KeyZ:{key:"z",code:"KeyZ",keyCode:90},MetaLeft:{key:"Meta",code:"MetaLeft",keyCode:91},ContextMenu:{key:"ContextMenu",code:"ContextMenu",keyCode:93},Numpad0:{key:"0",code:"Numpad0",keyCode:96},Numpad1:{key:"1",code:"Numpad1",keyCode:97},Numpad2:{key:"2",code:"Numpad2",keyCode:98},Numpad3:{key:"3",code:"Numpad3",keyCode:99},Numpad4:{key:"4",code:"Numpad4",keyCode:100},Numpad5:{key:"5",code:"Numpad5",keyCode:101},Numpad6:{key:"6",code:"Numpad6",keyCode:102},Numpad7:{key:"7",code:"Numpad7",keyCode:103},Numpad8:{key:"8",code:"Numpad8",keyCode:104},Numpad9:{key:"9",code:"Numpad9",keyCode:105},NumpadMultiply:{key:"*",code:"NumpadMultiply",keyCode:106},NumpadAdd:{key:"+",code:"NumpadAdd",keyCode:107},NumpadSubtract:{key:"-",code:"NumpadSubtract",keyCode:109},NumpadDecimal:{key:".",code:"NumpadDecimal",keyCode:110},NumpadDivide:{key:"/",code:"NumpadDivide",keyCode:111},F1:{key:"F1",code:"F1",keyCode:112},F2:{key:"F2",code:"F2",keyCode:113},F3:{key:"F3",code:"F3",keyCode:114},F4:{key:"F4",code:"F4",keyCode:115},F5:{key:"F5",code:"F5",keyCode:116},F6:{key:"F6",code:"F6",keyCode:117},F7:{key:"F7",code:"F7",keyCode:118},F8:{key:"F8",code:"F8",keyCode:119},F9:{key:"F9",code:"F9",keyCode:120},F10:{key:"F10",code:"F10",keyCode:121},F11:{key:"F11",code:"F11",keyCode:122},F12:{key:"F12",code:"F12",keyCode:123},NumLock:{key:"NumLock",code:"NumLock",keyCode:144},ScrollLock:{key:"ScrollLock",code:"ScrollLock",keyCode:145},Semicolon:{key:";",code:"Semicolon",keyCode:186},Equal:{key:"=",code:"Equal",keyCode:187},Comma:{key:",",code:"Comma",keyCode:188},Minus:{key:"-",code:"Minus",keyCode:189},Period:{key:".",code:"Period",keyCode:190},Slash:{key:"/",code:"Slash",keyCode:191},Backquote:{key:"`",code:"Backquote",keyCode:192},BracketLeft:{key:"[",code:"BracketLeft",keyCode:219},Backslash:{key:"\\",code:"Backslash",keyCode:220},BracketRight:{key:"]",code:"BracketRight",keyCode:221},Quote:{key:"'",code:"Quote",keyCode:222}},E=X;var u={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"},n={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},_={PARENT_ID_KEY:"omnipad-parent-id-link"};var I=Symbol.for("omnipad.gamepad_manager.instance"),z={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 a$1{constructor(){a(this,"isRunning",false);a(this,"config",null);a(this,"lastButtonStates",[]);a(this,"loop",()=>{if(!this.isRunning)return;let o=navigator.getGamepads();this.config?.forEach((e,t)=>{let i=o[t];i&&i.connected&&e&&(this.lastButtonStates[t]||(this.lastButtonStates[t]=[]),this.processButtons(i,e,t),this.processDPad(i,e),this.processAxes(i,e));}),requestAnimationFrame(this.loop);});}static getInstance(){let o=globalThis;return o[I]||(o[I]=new a$1),o[I]}setConfig(o){this.config=o;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",o=>{import.meta.env?.DEV&&console.log("[Omnipad-Core] Gamepad Connected:",o.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{import.meta.env?.DEV&&console.log("[Omnipad-Core] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(o,e,t){e.buttons&&Object.entries(e.buttons).forEach(([i,r])=>{let c=z[i];if(c===void 0||!o.buttons[c])return;let p=o.buttons[c].pressed,h=this.lastButtonStates[t][c]||false;p&&!h?this.triggerVirtualEntity(r,"down"):!p&&h&&this.triggerVirtualEntity(r,"up"),this.lastButtonStates[t][c]=p;});}processDPad(o,e){let t=e?.dpad;if(!t)return;let i=o.buttons[12]?.pressed?-1:0,r=o.buttons[13]?.pressed?1:0,c=o.buttons[14]?.pressed?-1:0,p=o.buttons[15]?.pressed?1:0,h=c+p,f=i+r;this.triggerVirtualEntity(t,"vector",{x:h,y:f});}processAxes(o,e){let t=e?.deadzone??.1;if(e?.leftStick){let i=Math.abs(o.axes[0])>t?o.axes[0]:0,r=Math.abs(o.axes[1])>t?o.axes[1]:0;this.triggerVirtualEntity(e.leftStick,"vector",{x:i,y:r});}if(e?.rightStick){let i=Math.abs(o.axes[2])>t?o.axes[2]:0,r=Math.abs(o.axes[3])>t?o.axes[3]:0;this.triggerVirtualEntity(e.rightStick,"vector",{x:i,y:r});}}triggerVirtualEntity(o,e,t){let i=b.getInstance().getEntity(o);!i||i.activePointerId!=null||(e==="down"&&i.triggerDown&&i.triggerDown(),e==="up"&&i.triggerUp&&i.triggerUp(),e==="vector"&&i.triggerVector&&t&&i.triggerVector(t.x,t.y));}};var C=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):a=>setTimeout(a,16),q=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):a=>clearTimeout(a);function g(a){let o=false,e=null;return function(t){e=t,o||(o=true,C(()=>{e!==null&&a(e),o=false;}));}}function V(a){let o=null,e=()=>{a(),o=C(e);};return {start:()=>{o===null&&e();},stop:()=>{o!==null&&(q(o),o=null);}}}var H=(a=2)=>new Promise(o=>{let e=0,t=()=>{++e>=a?o():C(t);};C(t);});var x=Symbol.for("omnipad.input_manager.instance"),w=class a$1{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."),b.getInstance().resetAll();});a(this,"handleResizeReset",()=>{this.throttledReset(null);});a(this,"handleBlurReset",()=>{this.handleGlobalReset();});a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=g(()=>{this.handleGlobalReset();});}static getInstance(){let o=globalThis;return o[x]||(o[x]=new a$1),o[x]}init(){this._isListening||(window.addEventListener("resize",this.handleResizeReset),window.addEventListener("blur",this.handleBlurReset),document.addEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=true,import.meta.env?.DEV&&console.log("[OmniPad-Core] Global InputManager monitoring started."));}async toggleFullscreen(o){let e=o||document.documentElement;try{document.fullscreenElement?(b.getInstance().resetAll(),await document.exitFullscreen()):(b.getInstance().resetAll(),await e.requestFullscreen());}catch(t){console.error("[OmniPad-Core] Fullscreen toggle failed:",t);}}isFullscreen(){return !!document.fullscreenElement}destroy(){window.removeEventListener("resize",this.handleResizeReset),window.removeEventListener("blur",this.handleBlurReset),window.removeEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=false;}};var A=class{constructor(){a(this,"listeners",new Set);}subscribe(o){return this.listeners.add(o),()=>this.listeners.delete(o)}emit(o){this.listeners.forEach(e=>{try{e(o);}catch(t){console.error("[OmniPad-Core] Emitter callback error:",t);}});}clear(){this.listeners.clear();}};var l=class{constructor(o,e,t,i){a(this,"uid");a(this,"type");a(this,"config");a(this,"state");a(this,"rectProvider",null);a(this,"stateEmitter",new A);this.uid=o,this.type=e,this.config=t,this.state=i;}subscribe(o){return o(this.state),this.stateEmitter.subscribe(o)}setState(o){this.state={...this.state,...o},this.stateEmitter.emit(this.state);}destroy(){this.reset(),this.stateEmitter.clear(),b.getInstance().unregister(this.uid);}get rect(){return this.rectProvider?this.rectProvider():null}bindRectProvider(o){this.rectProvider=o;}updateConfig(o){this.config={...this.config,...o},this.stateEmitter.emit(this.state);}getState(){return this.state}getConfig(){return this.config}};var d=class{constructor(o,e){a(this,"isPressed",false);a(this,"mapping");a(this,"targetId");this.update(o,e);}update(o,e){this.isPressed&&this.reset(),this.targetId=o,this.mapping=this.hydrate(e);}hydrate(o){if(!o)return;let e={...o};if(e.type==="mouse")return e.button=e.button??0,e;let{key:t,code:i,keyCode:r}=e;if(t||i||r){e.type="keyboard";let c=Object.values(E).find(p=>p.code===i||p.key===t||p.keyCode===r);c&&(e.key=t??c.key,e.code=i??c.code,e.keyCode=r??c.keyCode);}return e}press(){if(!this.mapping||this.isPressed)return;this.isPressed=true;let o=this.mapping.type==="keyboard"?n.KEYDOWN:n.MOUSEDOWN;this.emitSignal(o);}release(o=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let e=this.mapping.type==="keyboard"?n.KEYUP:n.MOUSEUP;this.emitSignal(e),this.mapping.type==="mouse"&&o&&this.emitSignal(n.CLICK);}move(o){this.mapping?.type==="mouse"&&this.emitSignal(n.MOUSEMOVE,o);}reset(){this.isPressed&&this.release(false);}async tap(o=true){this.isPressed||(this.press(),await H(2),this.isPressed&&this.release(o));}emitSignal(o,e={}){if(!this.targetId||!this.mapping)return;let t=b.getInstance().getEntity(this.targetId);t&&t.handleSignal({targetStageId:this.targetId,type:o,payload:{key:this.mapping.key,code:this.mapping.code,keyCode:this.mapping.keyCode,button:this.mapping.button,point:this.mapping.fixedPoint,...e}});}};var M={isActive:false,isPressed:false,pointerId:null,value:0},R=class extends l{constructor(e,t){super(e,u.BUTTON,t,M);a(this,"emitter");this.emitter=new d(t.targetStageId,t.mapping);}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,isPressed:true,pointerId:e.pointerId}),this.emitter.press();}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.handleRelease(true);}onPointerCancel(){this.handleRelease(false);}onPointerMove(){}reset(){this.setState(M),this.emitter.reset();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(e){this.setState(M),this.emitter.release(e);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.emitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.emitter.release(true));}};var G={isActive:false,pointerId:null,vector:{x:0,y:0}},O=class extends l{constructor(e,t){super(e,u.D_PAD,t,G);a(this,"emitters");a(this,"throttledPointerMove");let i=t.targetStageId;this.emitters={up:new d(i,t.mapping?.up),down:new d(i,t.mapping?.down),left:new d(i,t.mapping?.left),right:new d(i,t.mapping?.right)},this.throttledPointerMove=g(r=>{this.processInput(r);});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}});}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.throttledPointerMove(e);}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.reset();}onPointerCancel(){this.reset();}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let r=i.left+i.width/2,c=i.top+i.height/2,p=i.width/2,h=i.height/2,f$1=(e.clientX-r)/p,b=(e.clientY-c)/h;if(t&&(f$1!=f(f$1,-1,1)||b!=f(b,-1,1))){this.setState({vector:{x:0,y:0}});return}let S={x:f(f$1,-1,1),y:f(b,-1,1)};this.setState({vector:S}),this.handleDigitalKeys(S);}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.emitters.up.reset(),this.emitters.down.reset(),this.emitters.left.reset(),this.emitters.right.reset(),this.setState(G);}updateConfig(e){super.updateConfig(e),this.emitters.up.update(this.config.targetStageId,this.config.mapping?.up),this.emitters.down.update(this.config.targetStageId,this.config.mapping?.down),this.emitters.left.update(this.config.targetStageId,this.config.mapping?.left),this.emitters.right.update(this.config.targetStageId,this.config.mapping?.right);}triggerVector(e,t){let i={x:e,y:t},r=this.config.threshold??.3;Math.abs(e)>=r||Math.abs(t)>=r?(this.setState({isActive:true,vector:i}),this.handleDigitalKeys(i)):this.reset();}};var J={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},K=class extends l{constructor(e,t){super(e,u.INPUT_ZONE,t,J);a(this,"delegates",{dynamicWidgetPointerDown:()=>{},dynamicWidgetPointerMove:()=>{},dynamicWidgetPointerUp:()=>{},dynamicWidgetPointerCancel:()=>{}});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return this.state.dynamicPointerId}onPointerDown(e){if(this.state.isDynamicActive)return;let t=this.calculateRelativePosition(e.clientX,e.clientY);this.setState({isDynamicActive:true,dynamicPointerId:e.pointerId,dynamicPosition:t}),this.delegates.dynamicWidgetPointerDown?.(e);}onPointerMove(e){this.state.isDynamicActive&&this.delegates.dynamicWidgetPointerMove?.(e);}onPointerUp(e){this.delegates.dynamicWidgetPointerUp?.(e),this.reset();}onPointerCancel(e){this.delegates.dynamicWidgetPointerCancel?.(e),this.reset();}calculateRelativePosition(e,t){let i=this.rect;return i?{x:q$1(e-i.left,i.width),y:q$1(t-i.top,i.height)}:{x:0,y:0}}get isInterceptorRequired(){return !!(this.config.dynamicWidgetId||this.config.preventFocusLoss)}reset(){this.setState({isDynamicActive:false,dynamicPointerId:null});}};var P=class{constructor(o={}){a(this,"options");a(this,"startTime",0);a(this,"startPos",{x:0,y:0});a(this,"lastTapTime",0);a(this,"hasMoved",false);a(this,"isDoubleTapHolding",false);this.options={tapTime:250,tapDistance:10,doubleTapGap:300,...o};}onPointerDown(o,e){let t=Date.now();this.startTime=t,this.startPos={x:o,y:e},this.hasMoved=false,t-this.lastTapTime<this.options.doubleTapGap?(this.isDoubleTapHolding=true,this.options.onDoubleTapHoldStart?.()):this.isDoubleTapHolding=false;}onPointerMove(o,e){this.hasMoved||Math.hypot(o-this.startPos.x,e-this.startPos.y)>this.options.tapDistance&&(this.hasMoved=true);}onPointerUp(){let o=Date.now(),e=o-this.startTime;this.isDoubleTapHolding?(this.isDoubleTapHolding=false,this.options.onDoubleTapHoldEnd?.(),this.lastTapTime=0):e<=this.options.tapTime&&!this.hasMoved&&(this.options.onTap?.(),o-this.lastTapTime<this.options.doubleTapGap?(this.options.onDoubleTap?.(),this.lastTapTime=0):this.lastTapTime=o);}reset(){this.isDoubleTapHolding&&this.options.onDoubleTapHoldEnd?.(),this.isDoubleTapHolding=false,this.hasMoved=false,this.startTime=0,this.lastTapTime=0;}};var W={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},N=class extends l{constructor(e,t){super(e,u.JOYSTICK,t,W);a(this,"emitters");a(this,"stickEmitter");a(this,"cursorEmitter");a(this,"gesture");a(this,"ticker");a(this,"throttledUpdate");let i=t.targetStageId,r=t.mapping||{};this.emitters={up:new d(i,r.up),down:new d(i,r.down),left:new d(i,r.left),right:new d(i,r.right)},this.stickEmitter=new d(i,r.stick),this.cursorEmitter=new d(i,{type:"mouse"}),this.gesture=new P({onTap:async()=>{this.setState({isPressed:true}),await this.stickEmitter.tap(),this.setState({isPressed:false});},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.stickEmitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.stickEmitter.release(false);}}),this.ticker=V(()=>{this.handleCursorTick();}),this.throttledUpdate=g(c=>{this.processInput(c);});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}}),this.gesture.onPointerDown(e.clientX,e.clientY);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.config.cursorMode&&this.ticker.start(),this.throttledUpdate(e));}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}handleRelease(){this.setState({isActive:false,pointerId:null,vector:{x:0,y:0}}),this.ticker.stop(),Object.values(this.emitters).forEach(e=>e?.reset());}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let r=i.left+i.width/2,c=i.top+i.height/2,p=i.width/2,h=i.height/2,f$1=(e.clientX-r)/p,b=(e.clientY-c)/h;if(t&&(f$1!=f(f$1,-1,1)||b!=f(b,-1,1))){this.setState({vector:{x:0,y:0}});return}let B=w$1({x:f$1,y:b},1,this.config.threshold||.15);this.setState({vector:B}),this.handleDigitalKeys(B);}handleCursorTick(){let{vector:e,isActive:t}=this.state;if(!t||!this.config.cursorMode)return;let i=this.config.cursorSensitivity??1,r={x:e.x*i,y:e.y*i};(Math.abs(r.x)>0||Math.abs(r.y)>0)&&this.cursorEmitter.move({delta:r});}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.setState(W),this.gesture.reset(),this.handleRelease(),this.stickEmitter.reset(),this.cursorEmitter.reset();}updateConfig(e){super.updateConfig(e);let t=this.config.targetStageId,i=this.config.mapping||{};this.emitters.up.update(t,i.up),this.emitters.down.update(t,i.down),this.emitters.left.update(t,i.left),this.emitters.right.update(t,i.right),this.stickEmitter.update(t,i.stick),this.cursorEmitter.update(t);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.stickEmitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.stickEmitter.release(true));}triggerVector(e,t){let i={x:e,y:t},r=this.config.threshold??.3;Math.abs(e)>=r||Math.abs(t)>=r?(this.setState({isActive:true,vector:i}),this.handleDigitalKeys(i),this.config.cursorMode&&this.ticker.start()):this.handleRelease();}};var j={isHighlighted:false},F=class extends l{constructor(o,e){super(o,u.ROOT_LAYER,e,j);}reset(){}};var Q={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},U=class extends l{constructor(e,t){super(e,u.TARGET_ZONE,t,Q);a(this,"hideTimer",null);a(this,"focusFeedbackTimer",null);a(this,"throttledPointerMove");a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledPointerMove=g(i=>{this.processPhysicalEvent(i,n.MOUSEMOVE);});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return null}onPointerDown(e){this.processPhysicalEvent(e,n.MOUSEDOWN);}onPointerMove(e){this.throttledPointerMove(e);}onPointerUp(e){this.processPhysicalEvent(e,n.MOUSEUP),this.processPhysicalEvent(e,n.CLICK);}onPointerCancel(e){this.processPhysicalEvent(e,n.MOUSEUP);}processPhysicalEvent(e,t){let i=this.rect;if(!i)return;let r={x:q$1(e.clientX-i.left,i.width),y:q$1(e.clientY-i.top,i.height)};this.handleSignal({targetStageId:this.uid,type:t,payload:{point:r,button:e.button}});}handleSignal(e){let{type:t,payload:i}=e;switch(this.ensureFocus(),t){case n.KEYDOWN:case n.KEYUP:this.delegates.dispatchKeyboardEvent?.(t,i);break;case n.MOUSEMOVE:i.point?this.updateCursorPosition(i.point):i.delta&&this.updateCursorPositionByDelta(i.delta),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(n.POINTERMOVE,i);break;case n.MOUSEDOWN:case n.MOUSEUP:case n.CLICK:i.point&&this.updateCursorPosition(i.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(t.startsWith(n.MOUSE)?t.replace(n.MOUSE,n.POINTER):t,i);break}}executeMouseAction(e,t){let i=this.rect;if(!i)return;e===n.POINTERDOWN&&this.setState({isPointerDown:true}),e===n.POINTERUP&&this.setState({isPointerDown:false});let r=t.point||this.state.position,c=i.left+p(r.x,i.width),p$1=i.top+p(r.y,i.height);this.delegates.dispatchPointerEventAtPos?.(e,c,p$1,{button:t.button??0,buttons:this.state.isPointerDown?1:0,pressure:this.state.isPointerDown?.5:0});}ensureFocus(){let e=this.rect;if(!e)return;let t=e.left+p(this.state.position.x,e.width),i=e.top+p(this.state.position.y,e.height);this.delegates.reclaimFocusAtPos?.(t,i,()=>this.triggerFocusFeedback());}triggerFocusFeedback(){this.setState({isFocusReturning:true}),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.focusFeedbackTimer=setTimeout(()=>this.setState({isFocusReturning:false}),500);}updateCursorPosition(e){u$1(e,this.state.position)||this.setState({position:{...e}});}updateCursorPositionByDelta(e){if(u$1(e,{x:0,y:0}))return;let t=this.rect;if(!t)return;let i=q$1(e.x,t.width),r=q$1(e.y,t.height);this.updateCursorPosition({x:f(this.state.position.x+i,0,100),y:f(this.state.position.y+r,0,100)});}showCursor(){this.setState({isVisible:true}),this.hideTimer&&clearTimeout(this.hideTimer),this.config.cursorAutoDelay&&this.config.cursorAutoDelay>0&&(this.hideTimer=setTimeout(()=>this.setState({isVisible:false}),this.config.cursorAutoDelay));}reset(){this.state.isPointerDown&&this.executeMouseAction(n.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:false,isPointerDown:false,isFocusReturning:false});}};var Z={isActive:false,isPressed:false,pointerId:null,value:0},Y=class extends l{constructor(e,t){super(e,u.TRACKPAD,t,Z);a(this,"lastPointerPos",{x:0,y:0});a(this,"throttledPointerMove");a(this,"gesture");a(this,"emitter");let i=t.mapping||{type:"mouse"};this.emitter=new d(t.targetStageId,i),this.throttledPointerMove=g(r=>{this.processPointerMove(r);}),this.gesture=new P({onTap:()=>{this.setState({isPressed:true}),this.emitter.tap();},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.emitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.emitter.release(false);}});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.lastPointerPos={x:e.clientX,y:e.clientY},this.gesture.onPointerDown(e.clientX,e.clientY),this.setState({isActive:true,pointerId:e.pointerId});}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.throttledPointerMove(e));}processPointerMove(e){if(!this.state.isActive)return;let t=e.clientX-this.lastPointerPos.x,i=e.clientY-this.lastPointerPos.y,r=this.rect;if(!r)return;let c=t/r.width*100*(this.config.sensitivity??1),p=i/r.height*100*(this.config.sensitivity??1),h={x:c,y:p};u$1(h,{x:0,y:0})||this.emitter.move({delta:h}),this.lastPointerPos={x:e.clientX,y:e.clientY};}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}reset(){this.gesture.reset(),this.emitter.reset(),this.handleRelease();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(){this.setState(Z);}};var Mt={ActionTypes:n,Context:_,Keys:E,Types:u};export{n as ACTION_TYPES,l as BaseEntity,R as ButtonCore,u as CMP_TYPES,_ as CONTEXT,O as DPadCore,D as GamepadManager,w as InputManager,K as InputZoneCore,N as JoystickCore,E as KEYS,Mt as OmniPad,F as RootLayerCore,U as TargetZoneCore,Y as TrackpadCore};
|
|
1
|
+
import {a,b,f,q as q$1,w as w$1,p,u as u$1}from'./chunk-MSERY5BP.mjs';export{b as Registry}from'./chunk-MSERY5BP.mjs';var X={Backspace:{key:"Backspace",code:"Backspace",keyCode:8},Tab:{key:"Tab",code:"Tab",keyCode:9},Enter:{key:"Enter",code:"Enter",keyCode:13},ShiftLeft:{key:"Shift",code:"ShiftLeft",keyCode:16},ControlLeft:{key:"Control",code:"ControlLeft",keyCode:17},AltLeft:{key:"Alt",code:"AltLeft",keyCode:18},Pause:{key:"Pause",code:"Pause",keyCode:19},CapsLock:{key:"CapsLock",code:"CapsLock",keyCode:20},Escape:{key:"Escape",code:"Escape",keyCode:27},Space:{key:" ",code:"Space",keyCode:32},PageUp:{key:"PageUp",code:"PageUp",keyCode:33},PageDown:{key:"PageDown",code:"PageDown",keyCode:34},End:{key:"End",code:"End",keyCode:35},Home:{key:"Home",code:"Home",keyCode:36},ArrowLeft:{key:"ArrowLeft",code:"ArrowLeft",keyCode:37},ArrowUp:{key:"ArrowUp",code:"ArrowUp",keyCode:38},ArrowRight:{key:"ArrowRight",code:"ArrowRight",keyCode:39},ArrowDown:{key:"ArrowDown",code:"ArrowDown",keyCode:40},PrintScreen:{key:"PrintScreen",code:"PrintScreen",keyCode:44},Insert:{key:"Insert",code:"Insert",keyCode:45},Delete:{key:"Delete",code:"Delete",keyCode:46},Digit0:{key:"0",code:"Digit0",keyCode:48},Digit1:{key:"1",code:"Digit1",keyCode:49},Digit2:{key:"2",code:"Digit2",keyCode:50},Digit3:{key:"3",code:"Digit3",keyCode:51},Digit4:{key:"4",code:"Digit4",keyCode:52},Digit5:{key:"5",code:"Digit5",keyCode:53},Digit6:{key:"6",code:"Digit6",keyCode:54},Digit7:{key:"7",code:"Digit7",keyCode:55},Digit8:{key:"8",code:"Digit8",keyCode:56},Digit9:{key:"9",code:"Digit9",keyCode:57},KeyA:{key:"a",code:"KeyA",keyCode:65},KeyB:{key:"b",code:"KeyB",keyCode:66},KeyC:{key:"c",code:"KeyC",keyCode:67},KeyD:{key:"d",code:"KeyD",keyCode:68},KeyE:{key:"e",code:"KeyE",keyCode:69},KeyF:{key:"f",code:"KeyF",keyCode:70},KeyG:{key:"g",code:"KeyG",keyCode:71},KeyH:{key:"h",code:"KeyH",keyCode:72},KeyI:{key:"i",code:"KeyI",keyCode:73},KeyJ:{key:"j",code:"KeyJ",keyCode:74},KeyK:{key:"k",code:"KeyK",keyCode:75},KeyL:{key:"l",code:"KeyL",keyCode:76},KeyM:{key:"m",code:"KeyM",keyCode:77},KeyN:{key:"n",code:"KeyN",keyCode:78},KeyO:{key:"o",code:"KeyO",keyCode:79},KeyP:{key:"p",code:"KeyP",keyCode:80},KeyQ:{key:"q",code:"KeyQ",keyCode:81},KeyR:{key:"r",code:"KeyR",keyCode:82},KeyS:{key:"s",code:"KeyS",keyCode:83},KeyT:{key:"t",code:"KeyT",keyCode:84},KeyU:{key:"u",code:"KeyU",keyCode:85},KeyV:{key:"v",code:"KeyV",keyCode:86},KeyW:{key:"w",code:"KeyW",keyCode:87},KeyX:{key:"x",code:"KeyX",keyCode:88},KeyY:{key:"y",code:"KeyY",keyCode:89},KeyZ:{key:"z",code:"KeyZ",keyCode:90},MetaLeft:{key:"Meta",code:"MetaLeft",keyCode:91},ContextMenu:{key:"ContextMenu",code:"ContextMenu",keyCode:93},Numpad0:{key:"0",code:"Numpad0",keyCode:96},Numpad1:{key:"1",code:"Numpad1",keyCode:97},Numpad2:{key:"2",code:"Numpad2",keyCode:98},Numpad3:{key:"3",code:"Numpad3",keyCode:99},Numpad4:{key:"4",code:"Numpad4",keyCode:100},Numpad5:{key:"5",code:"Numpad5",keyCode:101},Numpad6:{key:"6",code:"Numpad6",keyCode:102},Numpad7:{key:"7",code:"Numpad7",keyCode:103},Numpad8:{key:"8",code:"Numpad8",keyCode:104},Numpad9:{key:"9",code:"Numpad9",keyCode:105},NumpadMultiply:{key:"*",code:"NumpadMultiply",keyCode:106},NumpadAdd:{key:"+",code:"NumpadAdd",keyCode:107},NumpadSubtract:{key:"-",code:"NumpadSubtract",keyCode:109},NumpadDecimal:{key:".",code:"NumpadDecimal",keyCode:110},NumpadDivide:{key:"/",code:"NumpadDivide",keyCode:111},F1:{key:"F1",code:"F1",keyCode:112},F2:{key:"F2",code:"F2",keyCode:113},F3:{key:"F3",code:"F3",keyCode:114},F4:{key:"F4",code:"F4",keyCode:115},F5:{key:"F5",code:"F5",keyCode:116},F6:{key:"F6",code:"F6",keyCode:117},F7:{key:"F7",code:"F7",keyCode:118},F8:{key:"F8",code:"F8",keyCode:119},F9:{key:"F9",code:"F9",keyCode:120},F10:{key:"F10",code:"F10",keyCode:121},F11:{key:"F11",code:"F11",keyCode:122},F12:{key:"F12",code:"F12",keyCode:123},NumLock:{key:"NumLock",code:"NumLock",keyCode:144},ScrollLock:{key:"ScrollLock",code:"ScrollLock",keyCode:145},Semicolon:{key:";",code:"Semicolon",keyCode:186},Equal:{key:"=",code:"Equal",keyCode:187},Comma:{key:",",code:"Comma",keyCode:188},Minus:{key:"-",code:"Minus",keyCode:189},Period:{key:".",code:"Period",keyCode:190},Slash:{key:"/",code:"Slash",keyCode:191},Backquote:{key:"`",code:"Backquote",keyCode:192},BracketLeft:{key:"[",code:"BracketLeft",keyCode:219},Backslash:{key:"\\",code:"Backslash",keyCode:220},BracketRight:{key:"]",code:"BracketRight",keyCode:221},Quote:{key:"'",code:"Quote",keyCode:222}},E=X;var u={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"},n={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},_={PARENT_ID_KEY:"omnipad-parent-id-link"};var I=Symbol.for("omnipad.gamepad_manager.instance"),z={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 a$1{constructor(){a(this,"isRunning",false);a(this,"config",null);a(this,"lastButtonStates",[]);a(this,"loop",()=>{if(!this.isRunning)return;let o=navigator.getGamepads();this.config?.forEach((e,t)=>{let i=o[t];i&&i.connected&&e&&(this.lastButtonStates[t]||(this.lastButtonStates[t]=[]),this.processButtons(i,e,t),this.processDPad(i,e),this.processAxes(i,e));}),requestAnimationFrame(this.loop);});}static getInstance(){let o=globalThis;return o[I]||(o[I]=new a$1),o[I]}setConfig(o){this.config=o;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",o=>{import.meta.env?.DEV&&console.log("[Omnipad-Core] Gamepad Connected:",o.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{import.meta.env?.DEV&&console.log("[Omnipad-Core] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(o,e,t){e.buttons&&Object.entries(e.buttons).forEach(([i,s])=>{let c=z[i];if(c===void 0||!o.buttons[c])return;let p=o.buttons[c].pressed,h=this.lastButtonStates[t][c]||false;p&&!h?this.triggerVirtualEntity(s,"down"):!p&&h&&this.triggerVirtualEntity(s,"up"),this.lastButtonStates[t][c]=p;});}processDPad(o,e){let t=e?.dpad;if(!t)return;let i=o.buttons[12]?.pressed?-1:0,s=o.buttons[13]?.pressed?1:0,c=o.buttons[14]?.pressed?-1:0,p=o.buttons[15]?.pressed?1:0,h=c+p,f=i+s;this.triggerVirtualEntity(t,"vector",{x:h,y:f});}processAxes(o,e){let t=e?.deadzone??.1;if(e?.leftStick){let i=Math.abs(o.axes[0])>t?o.axes[0]:0,s=Math.abs(o.axes[1])>t?o.axes[1]:0;this.triggerVirtualEntity(e.leftStick,"vector",{x:i,y:s});}if(e?.rightStick){let i=Math.abs(o.axes[2])>t?o.axes[2]:0,s=Math.abs(o.axes[3])>t?o.axes[3]:0;this.triggerVirtualEntity(e.rightStick,"vector",{x:i,y:s});}}triggerVirtualEntity(o,e,t){let i=b.getInstance().getEntity(o);!i||i.activePointerId!=null||(e==="down"&&i.triggerDown&&i.triggerDown(),e==="up"&&i.triggerUp&&i.triggerUp(),e==="vector"&&i.triggerVector&&t&&i.triggerVector(t.x,t.y));}};var C=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):a=>setTimeout(a,16),q=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):a=>clearTimeout(a);function g(a){let o=false,e;return function(t){e=t,o||(o=true,C(()=>{a(e),o=false;}));}}function V(a){let o=null,e=()=>{a(),o=C(e);};return {start:()=>{o===null&&e();},stop:()=>{o!==null&&(q(o),o=null);}}}var H=(a=2)=>new Promise(o=>{let e=0,t=()=>{++e>=a?o():C(t);};C(t);});var w=Symbol.for("omnipad.window_manager.instance"),x=class a$1{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."),b.getInstance().resetAll();});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=g(()=>{this.handleGlobalReset();});}static getInstance(){let o=globalThis;return o[w]||(o[w]=new a$1),o[w]}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(o){let e=o||document.documentElement;try{document.fullscreenElement?(b.getInstance().resetAll(),await document.exitFullscreen()):(b.getInstance().resetAll(),await e.requestFullscreen());}catch(t){console.error("[OmniPad-Core] Fullscreen toggle failed:",t);}}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;}};var A=class{constructor(){a(this,"listeners",new Set);}subscribe(o){return this.listeners.add(o),()=>this.listeners.delete(o)}emit(o){this.listeners.forEach(e=>{try{e(o);}catch(t){console.error("[OmniPad-Core] Emitter callback error:",t);}});}clear(){this.listeners.clear();}};var l=class{constructor(o,e,t,i){a(this,"uid");a(this,"type");a(this,"config");a(this,"state");a(this,"rectProvider",null);a(this,"_onMarkDirtyCb",null);a(this,"stateEmitter",new A);this.uid=o,this.type=e,this.config=t,this.state=i;}subscribe(o){return o(this.state),this.stateEmitter.subscribe(o)}setState(o){this.state={...this.state,...o},this.stateEmitter.emit(this.state);}destroy(){this.reset(),this.stateEmitter.clear(),b.getInstance().unregister(this.uid);}get rect(){return this.rectProvider?this.rectProvider():null}bindRectProvider(o,e){this.rectProvider=o,e&&(this._onMarkDirtyCb=e);}markRectDirty(){this._onMarkDirtyCb?.();}updateConfig(o){this.config={...this.config,...o},this.stateEmitter.emit(this.state);}getState(){return this.state}getConfig(){return this.config}};var d=class{constructor(o,e){a(this,"isPressed",false);a(this,"mapping");a(this,"targetId");this.update(o,e);}update(o,e){this.isPressed&&this.reset(),this.targetId=o,this.mapping=this.hydrate(e);}hydrate(o){if(!o)return;let e={...o};if(e.type==="mouse")return e.button=e.button??0,e;let{key:t,code:i,keyCode:s}=e;if(t||i||s){e.type="keyboard";let c=Object.values(E).find(p=>p.code===i||p.key===t||p.keyCode===s);c&&(e.key=t??c.key,e.code=i??c.code,e.keyCode=s??c.keyCode);}return e}press(){if(!this.mapping||this.isPressed)return;this.isPressed=true;let o=this.mapping.type==="keyboard"?n.KEYDOWN:n.MOUSEDOWN;this.emitSignal(o);}release(o=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let e=this.mapping.type==="keyboard"?n.KEYUP:n.MOUSEUP;this.emitSignal(e),this.mapping.type==="mouse"&&o&&this.emitSignal(n.CLICK);}move(o){this.mapping?.type==="mouse"&&this.emitSignal(n.MOUSEMOVE,o);}reset(){this.isPressed&&this.release(false);}async tap(o=true){this.isPressed||(this.press(),await H(2),this.isPressed&&this.release(o));}emitSignal(o,e={}){if(!this.targetId||!this.mapping)return;let t=b.getInstance().getEntity(this.targetId);t&&t.handleSignal({targetStageId:this.targetId,type:o,payload:{key:this.mapping.key,code:this.mapping.code,keyCode:this.mapping.keyCode,button:this.mapping.button,point:this.mapping.fixedPoint,...e}});}};var M={isActive:false,isPressed:false,pointerId:null,value:0},R=class extends l{constructor(e,t){super(e,u.BUTTON,t,M);a(this,"emitter");this.emitter=new d(t.targetStageId,t.mapping);}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,isPressed:true,pointerId:e.pointerId}),this.emitter.press();}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.handleRelease(true);}onPointerCancel(){this.handleRelease(false);}onPointerMove(){}reset(){this.setState(M),this.emitter.reset();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(e){this.setState(M),this.emitter.release(e);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.emitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.emitter.release(true));}};var G={isActive:false,pointerId:null,vector:{x:0,y:0}},O=class extends l{constructor(e,t){super(e,u.D_PAD,t,G);a(this,"emitters");a(this,"throttledPointerMove");let i=t.targetStageId;this.emitters={up:new d(i,t.mapping?.up),down:new d(i,t.mapping?.down),left:new d(i,t.mapping?.left),right:new d(i,t.mapping?.right)},this.throttledPointerMove=g(s=>{this.processInput(s);});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}});}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.throttledPointerMove(e);}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.reset();}onPointerCancel(){this.reset();}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let s=i.left+i.width/2,c=i.top+i.height/2,p=i.width/2,h=i.height/2,f$1=(e.clientX-s)/p,b=(e.clientY-c)/h;if(t&&(f$1!=f(f$1,-1,1)||b!=f(b,-1,1))){this.setState({vector:{x:0,y:0}});return}let S={x:f(f$1,-1,1),y:f(b,-1,1)};this.setState({vector:S}),this.handleDigitalKeys(S);}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.emitters.up.reset(),this.emitters.down.reset(),this.emitters.left.reset(),this.emitters.right.reset(),this.setState(G);}updateConfig(e){super.updateConfig(e),this.emitters.up.update(this.config.targetStageId,this.config.mapping?.up),this.emitters.down.update(this.config.targetStageId,this.config.mapping?.down),this.emitters.left.update(this.config.targetStageId,this.config.mapping?.left),this.emitters.right.update(this.config.targetStageId,this.config.mapping?.right);}triggerVector(e,t){let i={x:e,y:t},s=this.config.threshold??.3;Math.abs(e)>=s||Math.abs(t)>=s?(this.setState({isActive:true,vector:i}),this.handleDigitalKeys(i)):this.reset();}};var J={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},K=class extends l{constructor(e,t){super(e,u.INPUT_ZONE,t,J);a(this,"delegates",{dynamicWidgetPointerDown:()=>{},dynamicWidgetPointerMove:()=>{},dynamicWidgetPointerUp:()=>{},dynamicWidgetPointerCancel:()=>{}});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return this.state.dynamicPointerId}onPointerDown(e){if(this.state.isDynamicActive)return;let t=this.calculateRelativePosition(e.clientX,e.clientY);this.setState({isDynamicActive:true,dynamicPointerId:e.pointerId,dynamicPosition:t}),this.delegates.dynamicWidgetPointerDown?.(e);}onPointerMove(e){this.state.isDynamicActive&&this.delegates.dynamicWidgetPointerMove?.(e);}onPointerUp(e){this.delegates.dynamicWidgetPointerUp?.(e),this.reset();}onPointerCancel(e){this.delegates.dynamicWidgetPointerCancel?.(e),this.reset();}calculateRelativePosition(e,t){let i=this.rect;return i?{x:q$1(e-i.left,i.width),y:q$1(t-i.top,i.height)}:{x:0,y:0}}get isInterceptorRequired(){return !!(this.config.dynamicWidgetId||this.config.preventFocusLoss)}reset(){this.setState({isDynamicActive:false,dynamicPointerId:null});}};var P=class{constructor(o={}){a(this,"options");a(this,"startTime",0);a(this,"startPos",{x:0,y:0});a(this,"lastTapTime",0);a(this,"hasMoved",false);a(this,"isDoubleTapHolding",false);this.options={tapTime:250,tapDistance:10,doubleTapGap:300,...o};}onPointerDown(o,e){let t=Date.now();this.startTime=t,this.startPos={x:o,y:e},this.hasMoved=false,t-this.lastTapTime<this.options.doubleTapGap?(this.isDoubleTapHolding=true,this.options.onDoubleTapHoldStart?.()):this.isDoubleTapHolding=false;}onPointerMove(o,e){this.hasMoved||Math.hypot(o-this.startPos.x,e-this.startPos.y)>this.options.tapDistance&&(this.hasMoved=true);}onPointerUp(){let o=Date.now(),e=o-this.startTime;this.isDoubleTapHolding?(this.isDoubleTapHolding=false,this.options.onDoubleTapHoldEnd?.(),this.lastTapTime=0):e<=this.options.tapTime&&!this.hasMoved&&(this.options.onTap?.(),o-this.lastTapTime<this.options.doubleTapGap?(this.options.onDoubleTap?.(),this.lastTapTime=0):this.lastTapTime=o);}reset(){this.isDoubleTapHolding&&this.options.onDoubleTapHoldEnd?.(),this.isDoubleTapHolding=false,this.hasMoved=false,this.startTime=0,this.lastTapTime=0;}};var W={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},N=class extends l{constructor(e,t){super(e,u.JOYSTICK,t,W);a(this,"emitters");a(this,"stickEmitter");a(this,"cursorEmitter");a(this,"gesture");a(this,"ticker");a(this,"throttledUpdate");let i=t.targetStageId,s=t.mapping||{};this.emitters={up:new d(i,s.up),down:new d(i,s.down),left:new d(i,s.left),right:new d(i,s.right)},this.stickEmitter=new d(i,s.stick),this.cursorEmitter=new d(i,{type:"mouse"}),this.gesture=new P({onTap:async()=>{this.setState({isPressed:true}),await this.stickEmitter.tap(),this.setState({isPressed:false});},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.stickEmitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.stickEmitter.release(false);}}),this.ticker=V(()=>{this.handleCursorTick();}),this.throttledUpdate=g(c=>{this.processInput(c);});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}}),this.gesture.onPointerDown(e.clientX,e.clientY);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.config.cursorMode&&this.ticker.start(),this.throttledUpdate(e));}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}handleRelease(){this.setState({isActive:false,pointerId:null,vector:{x:0,y:0}}),this.ticker.stop(),Object.values(this.emitters).forEach(e=>e?.reset());}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let s=i.left+i.width/2,c=i.top+i.height/2,p=i.width/2,h=i.height/2,f$1=(e.clientX-s)/p,b=(e.clientY-c)/h;if(t&&(f$1!=f(f$1,-1,1)||b!=f(b,-1,1))){this.setState({vector:{x:0,y:0}});return}let L=w$1({x:f$1,y:b},1,this.config.threshold||.15);this.setState({vector:L}),this.handleDigitalKeys(L);}handleCursorTick(){let{vector:e,isActive:t}=this.state;if(!t||!this.config.cursorMode)return;let i=this.config.cursorSensitivity??1,s={x:e.x*i,y:e.y*i};(Math.abs(s.x)>0||Math.abs(s.y)>0)&&this.cursorEmitter.move({delta:s});}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.setState(W),this.gesture.reset(),this.handleRelease(),this.stickEmitter.reset(),this.cursorEmitter.reset();}updateConfig(e){super.updateConfig(e);let t=this.config.targetStageId,i=this.config.mapping||{};this.emitters.up.update(t,i.up),this.emitters.down.update(t,i.down),this.emitters.left.update(t,i.left),this.emitters.right.update(t,i.right),this.stickEmitter.update(t,i.stick),this.cursorEmitter.update(t);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.stickEmitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.stickEmitter.release(true));}triggerVector(e,t){let i={x:e,y:t},s=this.config.threshold??.3;Math.abs(e)>=s||Math.abs(t)>=s?(this.setState({isActive:true,vector:i}),this.handleDigitalKeys(i),this.config.cursorMode&&this.ticker.start()):this.handleRelease();}};var j={isHighlighted:false},F=class extends l{constructor(o,e){super(o,u.ROOT_LAYER,e,j);}reset(){}};var Q={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},U=class extends l{constructor(e,t){super(e,u.TARGET_ZONE,t,Q);a(this,"hideTimer",null);a(this,"focusFeedbackTimer",null);a(this,"throttledPointerMove");a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledPointerMove=g(i=>{this.processPhysicalEvent(i,n.MOUSEMOVE);});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return null}onPointerDown(e){this.processPhysicalEvent(e,n.MOUSEDOWN);}onPointerMove(e){this.throttledPointerMove(e);}onPointerUp(e){this.processPhysicalEvent(e,n.MOUSEUP),this.processPhysicalEvent(e,n.CLICK);}onPointerCancel(e){this.processPhysicalEvent(e,n.MOUSEUP);}processPhysicalEvent(e,t){let i=this.rect;if(!i)return;let s={x:q$1(e.clientX-i.left,i.width),y:q$1(e.clientY-i.top,i.height)};this.handleSignal({targetStageId:this.uid,type:t,payload:{point:s,button:e.button}});}handleSignal(e){let{type:t,payload:i}=e;switch(this.ensureFocus(),t){case n.KEYDOWN:case n.KEYUP:this.delegates.dispatchKeyboardEvent?.(t,i);break;case n.MOUSEMOVE:i.point?this.updateCursorPosition(i.point):i.delta&&this.updateCursorPositionByDelta(i.delta),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(n.POINTERMOVE,i);break;case n.MOUSEDOWN:case n.MOUSEUP:case n.CLICK:i.point&&this.updateCursorPosition(i.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(t.startsWith(n.MOUSE)?t.replace(n.MOUSE,n.POINTER):t,i);break}}executeMouseAction(e,t){let i=this.rect;if(!i)return;e===n.POINTERDOWN&&this.setState({isPointerDown:true}),e===n.POINTERUP&&this.setState({isPointerDown:false});let s=t.point||this.state.position,c=i.left+p(s.x,i.width),p$1=i.top+p(s.y,i.height);this.delegates.dispatchPointerEventAtPos?.(e,c,p$1,{button:t.button??0,buttons:this.state.isPointerDown?1:0,pressure:this.state.isPointerDown?.5:0});}ensureFocus(){let e=this.rect;if(!e)return;let t=e.left+p(this.state.position.x,e.width),i=e.top+p(this.state.position.y,e.height);this.delegates.reclaimFocusAtPos?.(t,i,()=>this.triggerFocusFeedback());}triggerFocusFeedback(){this.setState({isFocusReturning:true}),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.focusFeedbackTimer=setTimeout(()=>this.setState({isFocusReturning:false}),500);}updateCursorPosition(e){u$1(e,this.state.position)||this.setState({position:{...e}});}updateCursorPositionByDelta(e){if(u$1(e,{x:0,y:0}))return;let t=this.rect;if(!t)return;let i=q$1(e.x,t.width),s=q$1(e.y,t.height);this.updateCursorPosition({x:f(this.state.position.x+i,0,100),y:f(this.state.position.y+s,0,100)});}showCursor(){this.setState({isVisible:true}),this.hideTimer&&clearTimeout(this.hideTimer),this.config.cursorAutoDelay&&this.config.cursorAutoDelay>0&&(this.hideTimer=setTimeout(()=>this.setState({isVisible:false}),this.config.cursorAutoDelay));}reset(){this.state.isPointerDown&&this.executeMouseAction(n.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:false,isPointerDown:false,isFocusReturning:false});}};var Z={isActive:false,isPressed:false,pointerId:null,value:0},Y=class extends l{constructor(e,t){super(e,u.TRACKPAD,t,Z);a(this,"lastPointerPos",{x:0,y:0});a(this,"throttledPointerMove");a(this,"gesture");a(this,"emitter");let i=t.mapping||{type:"mouse"};this.emitter=new d(t.targetStageId,i),this.throttledPointerMove=g(s=>{this.processPointerMove(s);}),this.gesture=new P({onTap:()=>{this.setState({isPressed:true}),this.emitter.tap();},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.emitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.emitter.release(false);}});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.lastPointerPos={x:e.clientX,y:e.clientY},this.gesture.onPointerDown(e.clientX,e.clientY),this.setState({isActive:true,pointerId:e.pointerId});}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.throttledPointerMove(e));}processPointerMove(e){if(!this.state.isActive)return;let t=e.clientX-this.lastPointerPos.x,i=e.clientY-this.lastPointerPos.y,s=this.rect;if(!s)return;let c=t/s.width*100*(this.config.sensitivity??1),p=i/s.height*100*(this.config.sensitivity??1),h={x:c,y:p};u$1(h,{x:0,y:0})||this.emitter.move({delta:h}),this.lastPointerPos={x:e.clientX,y:e.clientY};}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}reset(){this.gesture.reset(),this.emitter.reset(),this.handleRelease();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(){this.setState(Z);}};var Mt={ActionTypes:n,Context:_,Keys:E,Types:u};export{n as ACTION_TYPES,l as BaseEntity,R as ButtonCore,u as CMP_TYPES,_ as CONTEXT,O as DPadCore,D as GamepadManager,K as InputZoneCore,N as JoystickCore,E as KEYS,Mt as OmniPad,F as RootLayerCore,U as TargetZoneCore,Y as TrackpadCore,x as WindowManager};
|
package/dist/utils/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkPAGWIRTX_cjs=require('../chunk-PAGWIRTX.cjs');function Q(t){let r=null,n=true;return {get:()=>((n||!r)&&(r=t(),n=false),r),markDirty:()=>{n=true;}}}var I=(t,r,n="omnipad-prevent")=>{let o=document.elementsFromPoint(t,r).find(i=>!i.classList.contains(n));if(!o)return null;for(;o&&o.shadowRoot;){let f=o.shadowRoot.elementsFromPoint(t,r).find(u=>!u.classList.contains(n));if(!f||f===o)break;o=f;}return o},E=()=>{let t=document.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},S=t=>{E()!==t&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus());},X=(t,r)=>{let n=new KeyboardEvent(t,{...r,which:r.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(n);},Y=(t,r,n,a)=>{let o=I(r,n);if(!o)return;let i={bubbles:true,cancelable:true,composed:true,clientX:r,clientY:n,view:window,...a};if(t.startsWith("pointer")){o.dispatchEvent(new PointerEvent(t,{isPrimary:true,pointerId:9999,pointerType:"mouse",...i}));let f=t.replace("pointer","mouse");o.dispatchEvent(new MouseEvent(f,i));}else o.dispatchEvent(new MouseEvent(t,i));},Z=(t,r,n)=>{let a=I(t,r);if(!a)return;E()!==a&&(S(a),n());},g,H=()=>(g!==void 0||(g=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),g),C=(t,r)=>{if(t instanceof Element)try{t.setPointerCapture(r);}catch(n){undefined?.DEV&&console.warn("[Omnipad-DOM] Failed to set pointer capture:",n);}},y=(t,r)=>{if(t instanceof Element&&t.hasPointerCapture(r))try{t.releasePointerCapture(r);}catch{}};function tt(t,r={}){return {onPointerDown(n){if(!n.isTrusted||r?.requireDirectHit&&n.target!==n.currentTarget||t.activePointerId!=null)return;n.cancelable&&n.preventDefault(),n.stopPropagation();let a=n.currentTarget;a&&C(a,n.pointerId),t.onPointerDown(n);},onPointerMove(n){n.isTrusted&&(t.activePointerId!=null&&t.activePointerId!==n.pointerId||(n.cancelable&&n.preventDefault(),t.onPointerMove(n)));},onPointerUp(n){if(!n.isTrusted||t.activePointerId!=null&&t.activePointerId!==n.pointerId)return;n.cancelable&&n.preventDefault();let a=n.currentTarget;a&&y(a,n.pointerId),t.onPointerUp(n);},onPointerCancel(n){if(!n.isTrusted||t.activePointerId!=null&&t.activePointerId!==n.pointerId)return;let a=n.currentTarget;a&&y(a,n.pointerId),t.onPointerCancel(n);}}}var v=(t="omnipad")=>{let r=Date.now().toString(36),n=Math.random().toString(36).substring(2,6);return `${t}-${r}-${n}`};function m(t){return t.startsWith("$")}var rt=t=>{if(Object.keys(t??{}).length===0)return {};let r={};r.position="absolute",t.isSquare&&(r.aspectRatio="1/1"),["left","top","right","bottom","width","height"].forEach(o=>{let i=t[o];i!==void 0&&typeof i=="number"?r[o]=`${i}px`:i!==void 0&&typeof i=="string"&&(r[o]=i);}),t.zIndex!==void 0&&(r.zIndex=t.zIndex);let a={"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 t.anchor&&(r.transform=a[t.anchor]),r};function st(t){if(!t||typeof t!="object")throw new Error("[OmniPad-Validation] Profile must be a valid JSON object.");if(!Array.isArray(t.items))throw new Error('[OmniPad-Validation] "items" must be an array.');let r={name:t.meta?.name||"Untitled Profile",version:t.meta?.version||"1.0.0",author:t.meta?.author||"Unknown"},n=t.items.map((o,i)=>{if(!o.id||!o.type)throw new Error(`[OmniPad-Validation] Item at index ${i} is missing "id" or "type".`);return {id:String(o.id),type:String(o.type),parentId:o.parentId?String(o.parentId):void 0,config:o.config||{}}}),a=t.gamepadMappings;return {meta:r,items:n,gamepadMappings:a}}function dt(t){let{items:r,gamepadMappings:n}=t,a=new Map,o=(e,s="node")=>m(e)?e:(a.has(e)||a.set(e,v(s)),a.get(e));r.forEach(e=>o(e.id,e.type));let i=[];n&&n.forEach(e=>{let s={};if(e.buttons){s.buttons={};for(let[c,d]of Object.entries(e.buttons))s.buttons[c]=o(d);}e.dpad&&(s.dpad=o(e.dpad)),e.leftStick&&(s.leftStick=o(e.leftStick)),e.rightStick&&(s.rightStick=o(e.rightStick)),i.push(s);});let f=new Map,u=[];r.forEach(e=>{e.parentId?(f.has(e.parentId)||f.set(e.parentId,[]),f.get(e.parentId).push(e)):u.push(e);});let l=(e,s)=>{if(s.has(e.id))throw new Error(`[Omnipad-Core] Circular dependency detected at node: ${e.id}`);s.add(e.id);let c={...e.config};c?.targetStageId&&(c.targetStageId=o(c.targetStageId)),c?.dynamicWidgetId&&(c.dynamicWidgetId=o(c.dynamicWidgetId));let h=(f.get(e.id)||[]).map(b=>l(b,new Set(s)));return {uid:o(e.id),type:e.type,config:c,children:h}},p={};return u.forEach(e=>{p[e.id]=l(e,new Set);}),{roots:p,runtimeGamepadMappings:i}}function ct(t,r,n){let a=chunkPAGWIRTX_cjs.b.getInstance(),o=[];if(!r||r.length===0)o=a.getAllEntities();else {let e=new Set;r.forEach(s=>{a.getEntitiesByRoot(s).forEach(d=>e.add(d));}),o=Array.from(e);}let i=new Map,f=0,u=e=>m(e)?e:(i.has(e)||i.set(e,`node_${++f}`),i.get(e)),l=o.map(e=>{let s=e.getConfig(),c=e.uid,d={...s};d.targetStageId&&(d.targetStageId=u(d.targetStageId)),d.dynamicWidgetId&&(d.dynamicWidgetId=u(d.dynamicWidgetId));let{id:h,parentId:b,...w}=d;return {id:u(c),type:e.type,parentId:s.parentId?u(s.parentId):void 0,config:w}}),p=[];return n&&n.forEach(e=>{let s={};if(e.buttons){s.buttons={};for(let[c,d]of Object.entries(e.buttons))i.has(d)&&(s.buttons[c]=i.get(d));}e.dpad&&i.has(e.dpad)&&(s.dpad=i.get(e.dpad)),e.leftStick&&i.has(e.leftStick)&&(s.leftStick=i.get(e.leftStick)),e.rightStick&&i.has(e.rightStick)&&(s.rightStick=i.get(e.rightStick)),Object.keys(s).length>0?p.push(s):p.push({});}),{meta:t,items:l,gamepadMappings:Object.keys(p).length>0?p:void 0}}Object.defineProperty(exports,"addVec",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.d}});Object.defineProperty(exports,"applyAxialDeadzone",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.x}});Object.defineProperty(exports,"applyRadialDeadzone",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.w}});Object.defineProperty(exports,"clamp",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.f}});Object.defineProperty(exports,"clampVector",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.m}});Object.defineProperty(exports,"degToRad",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.l}});Object.defineProperty(exports,"getAngle",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.j}});Object.defineProperty(exports,"getDeadzoneScalar",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.v}});Object.defineProperty(exports,"getDistance",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.i}});Object.defineProperty(exports,"isVec2Equal",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.u}});Object.defineProperty(exports,"lerp",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.g}});Object.defineProperty(exports,"lockTo4Directions",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.o}});Object.defineProperty(exports,"lockTo8Directions",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.n}});Object.defineProperty(exports,"normalizeVec",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.r}});Object.defineProperty(exports,"percentToPx",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.p}});Object.defineProperty(exports,"pxToPercent",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.q}});Object.defineProperty(exports,"radToDeg",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.k}});Object.defineProperty(exports,"radToVec",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.s}});Object.defineProperty(exports,"remap",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.t}});Object.defineProperty(exports,"roundTo",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.h}});Object.defineProperty(exports,"scaleVec",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.e}});Object.defineProperty(exports,"subVec",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.c}});exports.createCachedProvider=Q;exports.createPointerBridge=tt;exports.dispatchKeyboardEvent=X;exports.dispatchPointerEventAtPos=Y;exports.exportProfile=ct;exports.focusElement=S;exports.generateUID=v;exports.getDeepActiveElement=E;exports.getDeepElement=I;exports.isGlobalID=m;exports.parseProfileJson=st;exports.parseProfileTrees=dt;exports.reclaimFocusAtPos=Z;exports.resolveLayoutStyle=rt;exports.safeReleaseCapture=y;exports.safeSetCapture=C;exports.supportsContainerQueries=H;
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
import { e as IPointerHandler, M as LayoutBox, V as Vec2, v as ConfigTreeNode, G as GamepadMappingConfig, x as GamepadProfile } from '../index-
|
|
1
|
+
import { e as IPointerHandler, M as LayoutBox, V as Vec2, v as ConfigTreeNode, G as GamepadMappingConfig, x as GamepadProfile } from '../index-DlGCSMP1.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a provider wrapper that caches the result of a value-producing function.
|
|
5
|
+
* * This utility implements a lazy-loading pattern with manual invalidation. The
|
|
6
|
+
* provided function is only executed when the cache is "dirty" or empty,
|
|
7
|
+
* ensuring expensive operations aren't repeated unnecessarily.
|
|
8
|
+
* * @template T - The type of the value returned by the provider.
|
|
9
|
+
* @param provider - A function that computes or retrieves the value to be cached.
|
|
10
|
+
* @returns An object containing methods to access the value and invalidate the cache.
|
|
11
|
+
* * @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const userProvider = createCachedProvider(() => fetchUserData());
|
|
14
|
+
* * // First call executes the provider
|
|
15
|
+
* const data = userProvider.get();
|
|
16
|
+
* * // Subsequent calls return the cached version
|
|
17
|
+
* const cachedData = userProvider.get();
|
|
18
|
+
* * // Forces the provider to re-run on the next .get()
|
|
19
|
+
* userProvider.markDirty();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function createCachedProvider<T>(provider: () => T): {
|
|
23
|
+
get: () => T;
|
|
24
|
+
markDirty: () => void;
|
|
25
|
+
};
|
|
2
26
|
|
|
3
27
|
/**
|
|
4
28
|
* Recursively penetrates Shadow DOM boundaries to find the deepest element at the
|
|
@@ -307,4 +331,4 @@ declare function parseProfileTrees(profile: GamepadProfile): ParsedProfileForest
|
|
|
307
331
|
*/
|
|
308
332
|
declare function exportProfile(meta: GamepadProfile['meta'], rootUids?: string[], runtimeGamepadMappings?: Readonly<GamepadMappingConfig[]>): GamepadProfile;
|
|
309
333
|
|
|
310
|
-
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, isGlobalID, isVec2Equal, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, scaleVec, subVec, supportsContainerQueries };
|
|
334
|
+
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createCachedProvider, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, isGlobalID, isVec2Equal, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, scaleVec, subVec, supportsContainerQueries };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
import { e as IPointerHandler, M as LayoutBox, V as Vec2, v as ConfigTreeNode, G as GamepadMappingConfig, x as GamepadProfile } from '../index-
|
|
1
|
+
import { e as IPointerHandler, M as LayoutBox, V as Vec2, v as ConfigTreeNode, G as GamepadMappingConfig, x as GamepadProfile } from '../index-DlGCSMP1.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a provider wrapper that caches the result of a value-producing function.
|
|
5
|
+
* * This utility implements a lazy-loading pattern with manual invalidation. The
|
|
6
|
+
* provided function is only executed when the cache is "dirty" or empty,
|
|
7
|
+
* ensuring expensive operations aren't repeated unnecessarily.
|
|
8
|
+
* * @template T - The type of the value returned by the provider.
|
|
9
|
+
* @param provider - A function that computes or retrieves the value to be cached.
|
|
10
|
+
* @returns An object containing methods to access the value and invalidate the cache.
|
|
11
|
+
* * @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const userProvider = createCachedProvider(() => fetchUserData());
|
|
14
|
+
* * // First call executes the provider
|
|
15
|
+
* const data = userProvider.get();
|
|
16
|
+
* * // Subsequent calls return the cached version
|
|
17
|
+
* const cachedData = userProvider.get();
|
|
18
|
+
* * // Forces the provider to re-run on the next .get()
|
|
19
|
+
* userProvider.markDirty();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function createCachedProvider<T>(provider: () => T): {
|
|
23
|
+
get: () => T;
|
|
24
|
+
markDirty: () => void;
|
|
25
|
+
};
|
|
2
26
|
|
|
3
27
|
/**
|
|
4
28
|
* Recursively penetrates Shadow DOM boundaries to find the deepest element at the
|
|
@@ -307,4 +331,4 @@ declare function parseProfileTrees(profile: GamepadProfile): ParsedProfileForest
|
|
|
307
331
|
*/
|
|
308
332
|
declare function exportProfile(meta: GamepadProfile['meta'], rootUids?: string[], runtimeGamepadMappings?: Readonly<GamepadMappingConfig[]>): GamepadProfile;
|
|
309
333
|
|
|
310
|
-
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, isGlobalID, isVec2Equal, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, scaleVec, subVec, supportsContainerQueries };
|
|
334
|
+
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createCachedProvider, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, isGlobalID, isVec2Equal, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, scaleVec, subVec, supportsContainerQueries };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b}from'../chunk-
|
|
1
|
+
import {b}from'../chunk-MSERY5BP.mjs';export{d as addVec,x as applyAxialDeadzone,w as applyRadialDeadzone,f as clamp,m as clampVector,l as degToRad,j as getAngle,v as getDeadzoneScalar,i as getDistance,u as isVec2Equal,g as lerp,o as lockTo4Directions,n as lockTo8Directions,r as normalizeVec,p as percentToPx,q as pxToPercent,k as radToDeg,s as radToVec,t as remap,h as roundTo,e as scaleVec,c as subVec}from'../chunk-MSERY5BP.mjs';function Q(t){let r=null,n=true;return {get:()=>((n||!r)&&(r=t(),n=false),r),markDirty:()=>{n=true;}}}var I=(t,r,n="omnipad-prevent")=>{let o=document.elementsFromPoint(t,r).find(i=>!i.classList.contains(n));if(!o)return null;for(;o&&o.shadowRoot;){let f=o.shadowRoot.elementsFromPoint(t,r).find(u=>!u.classList.contains(n));if(!f||f===o)break;o=f;}return o},E=()=>{let t=document.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},S=t=>{E()!==t&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus());},X=(t,r)=>{let n=new KeyboardEvent(t,{...r,which:r.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(n);},Y=(t,r,n,a)=>{let o=I(r,n);if(!o)return;let i={bubbles:true,cancelable:true,composed:true,clientX:r,clientY:n,view:window,...a};if(t.startsWith("pointer")){o.dispatchEvent(new PointerEvent(t,{isPrimary:true,pointerId:9999,pointerType:"mouse",...i}));let f=t.replace("pointer","mouse");o.dispatchEvent(new MouseEvent(f,i));}else o.dispatchEvent(new MouseEvent(t,i));},Z=(t,r,n)=>{let a=I(t,r);if(!a)return;E()!==a&&(S(a),n());},g,H=()=>(g!==void 0||(g=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),g),C=(t,r)=>{if(t instanceof Element)try{t.setPointerCapture(r);}catch(n){import.meta.env?.DEV&&console.warn("[Omnipad-DOM] Failed to set pointer capture:",n);}},y=(t,r)=>{if(t instanceof Element&&t.hasPointerCapture(r))try{t.releasePointerCapture(r);}catch{}};function tt(t,r={}){return {onPointerDown(n){if(!n.isTrusted||r?.requireDirectHit&&n.target!==n.currentTarget||t.activePointerId!=null)return;n.cancelable&&n.preventDefault(),n.stopPropagation();let a=n.currentTarget;a&&C(a,n.pointerId),t.onPointerDown(n);},onPointerMove(n){n.isTrusted&&(t.activePointerId!=null&&t.activePointerId!==n.pointerId||(n.cancelable&&n.preventDefault(),t.onPointerMove(n)));},onPointerUp(n){if(!n.isTrusted||t.activePointerId!=null&&t.activePointerId!==n.pointerId)return;n.cancelable&&n.preventDefault();let a=n.currentTarget;a&&y(a,n.pointerId),t.onPointerUp(n);},onPointerCancel(n){if(!n.isTrusted||t.activePointerId!=null&&t.activePointerId!==n.pointerId)return;let a=n.currentTarget;a&&y(a,n.pointerId),t.onPointerCancel(n);}}}var v=(t="omnipad")=>{let r=Date.now().toString(36),n=Math.random().toString(36).substring(2,6);return `${t}-${r}-${n}`};function m(t){return t.startsWith("$")}var rt=t=>{if(Object.keys(t??{}).length===0)return {};let r={};r.position="absolute",t.isSquare&&(r.aspectRatio="1/1"),["left","top","right","bottom","width","height"].forEach(o=>{let i=t[o];i!==void 0&&typeof i=="number"?r[o]=`${i}px`:i!==void 0&&typeof i=="string"&&(r[o]=i);}),t.zIndex!==void 0&&(r.zIndex=t.zIndex);let a={"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 t.anchor&&(r.transform=a[t.anchor]),r};function st(t){if(!t||typeof t!="object")throw new Error("[OmniPad-Validation] Profile must be a valid JSON object.");if(!Array.isArray(t.items))throw new Error('[OmniPad-Validation] "items" must be an array.');let r={name:t.meta?.name||"Untitled Profile",version:t.meta?.version||"1.0.0",author:t.meta?.author||"Unknown"},n=t.items.map((o,i)=>{if(!o.id||!o.type)throw new Error(`[OmniPad-Validation] Item at index ${i} is missing "id" or "type".`);return {id:String(o.id),type:String(o.type),parentId:o.parentId?String(o.parentId):void 0,config:o.config||{}}}),a=t.gamepadMappings;return {meta:r,items:n,gamepadMappings:a}}function dt(t){let{items:r,gamepadMappings:n}=t,a=new Map,o=(e,s="node")=>m(e)?e:(a.has(e)||a.set(e,v(s)),a.get(e));r.forEach(e=>o(e.id,e.type));let i=[];n&&n.forEach(e=>{let s={};if(e.buttons){s.buttons={};for(let[c,d]of Object.entries(e.buttons))s.buttons[c]=o(d);}e.dpad&&(s.dpad=o(e.dpad)),e.leftStick&&(s.leftStick=o(e.leftStick)),e.rightStick&&(s.rightStick=o(e.rightStick)),i.push(s);});let f=new Map,u=[];r.forEach(e=>{e.parentId?(f.has(e.parentId)||f.set(e.parentId,[]),f.get(e.parentId).push(e)):u.push(e);});let l=(e,s)=>{if(s.has(e.id))throw new Error(`[Omnipad-Core] Circular dependency detected at node: ${e.id}`);s.add(e.id);let c={...e.config};c?.targetStageId&&(c.targetStageId=o(c.targetStageId)),c?.dynamicWidgetId&&(c.dynamicWidgetId=o(c.dynamicWidgetId));let h=(f.get(e.id)||[]).map(b=>l(b,new Set(s)));return {uid:o(e.id),type:e.type,config:c,children:h}},p={};return u.forEach(e=>{p[e.id]=l(e,new Set);}),{roots:p,runtimeGamepadMappings:i}}function ct(t,r,n){let a=b.getInstance(),o=[];if(!r||r.length===0)o=a.getAllEntities();else {let e=new Set;r.forEach(s=>{a.getEntitiesByRoot(s).forEach(d=>e.add(d));}),o=Array.from(e);}let i=new Map,f=0,u=e=>m(e)?e:(i.has(e)||i.set(e,`node_${++f}`),i.get(e)),l=o.map(e=>{let s=e.getConfig(),c=e.uid,d={...s};d.targetStageId&&(d.targetStageId=u(d.targetStageId)),d.dynamicWidgetId&&(d.dynamicWidgetId=u(d.dynamicWidgetId));let{id:h,parentId:b,...w}=d;return {id:u(c),type:e.type,parentId:s.parentId?u(s.parentId):void 0,config:w}}),p=[];return n&&n.forEach(e=>{let s={};if(e.buttons){s.buttons={};for(let[c,d]of Object.entries(e.buttons))i.has(d)&&(s.buttons[c]=i.get(d));}e.dpad&&i.has(e.dpad)&&(s.dpad=i.get(e.dpad)),e.leftStick&&i.has(e.leftStick)&&(s.leftStick=i.get(e.leftStick)),e.rightStick&&i.has(e.rightStick)&&(s.rightStick=i.get(e.rightStick)),Object.keys(s).length>0?p.push(s):p.push({});}),{meta:t,items:l,gamepadMappings:Object.keys(p).length>0?p:void 0}}export{Q as createCachedProvider,tt as createPointerBridge,X as dispatchKeyboardEvent,Y as dispatchPointerEventAtPos,ct as exportProfile,S as focusElement,v as generateUID,E as getDeepActiveElement,I as getDeepElement,m as isGlobalID,st as parseProfileJson,dt as parseProfileTrees,Z as reclaimFocusAtPos,rt as resolveLayoutStyle,y as safeReleaseCapture,C as safeSetCapture,H as supportsContainerQueries};
|