@omnipad/core 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-ETLJK7NP.mjs +1 -0
- package/dist/chunk-FAVAOSNA.cjs +1 -0
- package/dist/{index-DlGCSMP1.d.cts → index-CTJog5sj.d.cts} +39 -14
- package/dist/{index-DlGCSMP1.d.ts → index-CTJog5sj.d.ts} +39 -14
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +18 -21
- package/dist/index.d.ts +18 -21
- package/dist/index.mjs +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +30 -2
- package/dist/utils/index.d.ts +30 -2
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-MSERY5BP.mjs +0 -1
- package/dist/chunk-PAGWIRTX.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var b=Object.defineProperty;var x=(t,e,o)=>e in t?b(t,e,{enumerable:true,configurable:true,writable:true,value:o}):t[e]=o;var u=(t,e,o)=>x(t,typeof e!="symbol"?e+"":e,o);var f={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}},K=f;var M={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"},D={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},N=["px","%","vh","vw","rem","em"],A={PARENT_ID_KEY:"omnipad-parent-id-link"};var a=Symbol.for("omnipad.registry.instance"),m=class t{constructor(){u(this,"entities",new Map);import.meta.env?.DEV&&console.log("[OmniPad-Core] Registry initialized.");}static getInstance(){let e=globalThis;return e[a]||(e[a]=new t),e[a]}register(e){if(!e.uid){console.warn("[OmniPad-Core] Registry: Attempted to register entity without UID.",e);return}this.entities.has(e.uid),this.entities.set(e.uid,e);}unregister(e){this.entities.has(e)&&this.entities.delete(e);}getEntity(e){return this.entities.get(e)}getAllEntities(){return Array.from(this.entities.values())}getEntitiesByRoot(e){let o=this.getAllEntities();if(!e)return o;if(!this.entities.get(e))return console.warn(`[OmniPad-Core] Registry: Root entity ${e} not found.`),[];let n=new Map;o.forEach(d=>{let k=d;if(typeof k.getConfig=="function"){let i=k.getConfig();i.parentId&&(n.has(i.parentId)||n.set(i.parentId,[]),n.get(i.parentId).push(d));}});let y=[],c=[e],p=new Set;for(;c.length>0;){let d=c.shift();if(p.has(d))continue;p.add(d);let k=this.entities.get(d);if(k){y.push(k);let i=n.get(d);i&&i.forEach(l=>c.push(l.uid));}}return y}destroyByRoot(e){let o=this.getEntitiesByRoot(e);for(let r=o.length-1;r>=0;r--){let n=o[r];try{n.destroy();}catch(y){console.error(`[OmniPad-Core] Error during destroyByRoot at ${n.uid}:`,y);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(e=>{"reset"in e&&e.reset(),"markRectDirty"in e&&e.markRectDirty();});}debugGetSnapshot(){return new Map(this.entities)}};var U=(t,e)=>({x:t.x-e.x,y:t.y-e.y}),Y=(t,e)=>({x:t.x+e.x,y:t.y+e.y}),E=(t,e)=>({x:t.x*e,y:t.y*e}),C=(t,e,o)=>Math.max(e,Math.min(o,t)),h=(t,e,o)=>t+(e-t)*o,g=(t,e=2)=>{let o=Math.pow(10,e);return Math.round(t*o)/o},B=(t,e)=>Math.hypot(e.x-t.x,e.y-t.y),z=(t,e)=>Math.atan2(e.y-t.y,e.x-t.x),Z=t=>t*180/Math.PI,q=t=>t*Math.PI/180,G=(t,e,o)=>{let r=e.x-t.x,n=e.y-t.y;if(Math.hypot(r,n)<=o)return e;let c=Math.atan2(n,r);return {x:t.x+Math.cos(c)*o,y:t.y+Math.sin(c)*o}},W=t=>{let e=Math.PI/4;return Math.round(t/e)*e},v=t=>{let e=Math.PI/2;return Math.round(t/e)*e},H=(t,e)=>g(t*e/100),J=(t,e)=>e===0?0:g(t*100/e),Q=t=>{let e=Math.hypot(t.x,t.y);return e===0?{x:0,y:0}:{x:t.x/e,y:t.y/e}},X=t=>({x:Math.cos(t),y:Math.sin(t)}),j=(t,e,o,r,n)=>{let y=(t-e)/(o-e);return h(r,n,C(y,0,1))},$=(t,e,o=1e-4)=>Math.abs(t.x-e.x)<o&&Math.abs(t.y-e.y)<o,s=(t,e,o)=>{if(t<e)return 0;let r=(t-e)/(o-e);return C(r,0,1)},ee=(t,e,o)=>{let r=Math.hypot(t.x,t.y),n=e*o,y=s(r,n,e);if(y===0)return {x:0,y:0};let c={x:t.x/r,y:t.y/r};return E(c,y)},te=(t,e,o)=>({x:s(Math.abs(t.x),e,o)*Math.sign(t.x),y:s(Math.abs(t.y),e,o)*Math.sign(t.y)});export{s as A,ee as B,te as C,u as a,K as b,M as c,D as d,N as e,A as f,m as g,U as h,Y as i,E as j,C as k,h as l,g as m,B as n,z as o,Z as p,q,G as r,W as s,v as t,H as u,J as v,Q as w,X as x,j as y,$ as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var b=Object.defineProperty;var x=(t,e,o)=>e in t?b(t,e,{enumerable:true,configurable:true,writable:true,value:o}):t[e]=o;var u=(t,e,o)=>x(t,typeof e!="symbol"?e+"":e,o);var f={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}},K=f;var M={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"},D={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},N=["px","%","vh","vw","rem","em"],A={PARENT_ID_KEY:"omnipad-parent-id-link"};var a=Symbol.for("omnipad.registry.instance"),m=class t{constructor(){u(this,"entities",new Map);undefined?.DEV&&console.log("[OmniPad-Core] Registry initialized.");}static getInstance(){let e=globalThis;return e[a]||(e[a]=new t),e[a]}register(e){if(!e.uid){console.warn("[OmniPad-Core] Registry: Attempted to register entity without UID.",e);return}this.entities.has(e.uid),this.entities.set(e.uid,e);}unregister(e){this.entities.has(e)&&this.entities.delete(e);}getEntity(e){return this.entities.get(e)}getAllEntities(){return Array.from(this.entities.values())}getEntitiesByRoot(e){let o=this.getAllEntities();if(!e)return o;if(!this.entities.get(e))return console.warn(`[OmniPad-Core] Registry: Root entity ${e} not found.`),[];let n=new Map;o.forEach(d=>{let k=d;if(typeof k.getConfig=="function"){let i=k.getConfig();i.parentId&&(n.has(i.parentId)||n.set(i.parentId,[]),n.get(i.parentId).push(d));}});let y=[],c=[e],p=new Set;for(;c.length>0;){let d=c.shift();if(p.has(d))continue;p.add(d);let k=this.entities.get(d);if(k){y.push(k);let i=n.get(d);i&&i.forEach(l=>c.push(l.uid));}}return y}destroyByRoot(e){let o=this.getEntitiesByRoot(e);for(let r=o.length-1;r>=0;r--){let n=o[r];try{n.destroy();}catch(y){console.error(`[OmniPad-Core] Error during destroyByRoot at ${n.uid}:`,y);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(e=>{"reset"in e&&e.reset(),"markRectDirty"in e&&e.markRectDirty();});}debugGetSnapshot(){return new Map(this.entities)}};var U=(t,e)=>({x:t.x-e.x,y:t.y-e.y}),Y=(t,e)=>({x:t.x+e.x,y:t.y+e.y}),E=(t,e)=>({x:t.x*e,y:t.y*e}),C=(t,e,o)=>Math.max(e,Math.min(o,t)),h=(t,e,o)=>t+(e-t)*o,g=(t,e=2)=>{let o=Math.pow(10,e);return Math.round(t*o)/o},B=(t,e)=>Math.hypot(e.x-t.x,e.y-t.y),z=(t,e)=>Math.atan2(e.y-t.y,e.x-t.x),Z=t=>t*180/Math.PI,q=t=>t*Math.PI/180,G=(t,e,o)=>{let r=e.x-t.x,n=e.y-t.y;if(Math.hypot(r,n)<=o)return e;let c=Math.atan2(n,r);return {x:t.x+Math.cos(c)*o,y:t.y+Math.sin(c)*o}},W=t=>{let e=Math.PI/4;return Math.round(t/e)*e},v=t=>{let e=Math.PI/2;return Math.round(t/e)*e},H=(t,e)=>g(t*e/100),J=(t,e)=>e===0?0:g(t*100/e),Q=t=>{let e=Math.hypot(t.x,t.y);return e===0?{x:0,y:0}:{x:t.x/e,y:t.y/e}},X=t=>({x:Math.cos(t),y:Math.sin(t)}),j=(t,e,o,r,n)=>{let y=(t-e)/(o-e);return h(r,n,C(y,0,1))},$=(t,e,o=1e-4)=>Math.abs(t.x-e.x)<o&&Math.abs(t.y-e.y)<o,s=(t,e,o)=>{if(t<e)return 0;let r=(t-e)/(o-e);return C(r,0,1)},ee=(t,e,o)=>{let r=Math.hypot(t.x,t.y),n=e*o,y=s(r,n,e);if(y===0)return {x:0,y:0};let c={x:t.x/r,y:t.y/r};return E(c,y)},te=(t,e,o)=>({x:s(Math.abs(t.x),e,o)*Math.sign(t.x),y:s(Math.abs(t.y),e,o)*Math.sign(t.y)});exports.A=s;exports.B=ee;exports.C=te;exports.a=u;exports.b=K;exports.c=M;exports.d=D;exports.e=N;exports.f=A;exports.g=m;exports.h=U;exports.i=Y;exports.j=E;exports.k=C;exports.l=h;exports.m=g;exports.n=B;exports.o=z;exports.p=Z;exports.q=q;exports.r=G;exports.s=W;exports.t=v;exports.u=H;exports.v=J;exports.w=Q;exports.x=X;exports.y=j;exports.z=$;
|
|
@@ -797,30 +797,41 @@ interface ISpatial {
|
|
|
797
797
|
* Trait: Provides configuration management.
|
|
798
798
|
*/
|
|
799
799
|
interface IConfigurable<TConfig> {
|
|
800
|
-
/**
|
|
801
|
-
* Dynamically updates the current configuration.
|
|
802
|
-
* @param config - Partial configuration object to merge.
|
|
803
|
-
*/
|
|
804
|
-
updateConfig(config: Partial<TConfig>): void;
|
|
805
800
|
/**
|
|
806
801
|
* Retrieves a snapshot of the current configuration.
|
|
807
802
|
*/
|
|
808
803
|
getConfig(): TConfig;
|
|
804
|
+
/**
|
|
805
|
+
* Subscribes to config changes.
|
|
806
|
+
* @param cb - Callback function triggered on config updates.
|
|
807
|
+
* @returns An unsubscribe function.
|
|
808
|
+
*/
|
|
809
|
+
subscribeConfig(cb: (config: TConfig) => void): () => void;
|
|
810
|
+
/**
|
|
811
|
+
* Updates the internal config and notifies all subscribers.
|
|
812
|
+
* @param config - Partial configuration object to merge.
|
|
813
|
+
*/
|
|
814
|
+
updateConfig(config: Partial<TConfig>): void;
|
|
809
815
|
}
|
|
810
816
|
/**
|
|
811
|
-
* Trait:
|
|
817
|
+
* Trait: Provides state management.
|
|
812
818
|
*/
|
|
813
|
-
interface
|
|
819
|
+
interface IStateful<TState> {
|
|
820
|
+
/**
|
|
821
|
+
* Retrieves the current state snapshot.
|
|
822
|
+
*/
|
|
823
|
+
getState(): TState;
|
|
814
824
|
/**
|
|
815
825
|
* Subscribes to state changes.
|
|
816
826
|
* @param cb - Callback function triggered on state updates.
|
|
817
827
|
* @returns An unsubscribe function.
|
|
818
828
|
*/
|
|
819
|
-
|
|
829
|
+
subscribeState(cb: (state: TState) => void): () => void;
|
|
820
830
|
/**
|
|
821
|
-
*
|
|
831
|
+
* Updates the internal state and notifies all subscribers.
|
|
832
|
+
* @param state - Partial object containing updated state values.
|
|
822
833
|
*/
|
|
823
|
-
|
|
834
|
+
setState(state: Partial<TState>): void;
|
|
824
835
|
}
|
|
825
836
|
/**
|
|
826
837
|
* Trait: Allows resetting the entity to its idle/safe state.
|
|
@@ -990,13 +1001,27 @@ type EntityType = AnyEntityType | (string & {});
|
|
|
990
1001
|
type BuiltInActionType = (typeof ACTION_TYPES)[keyof typeof ACTION_TYPES];
|
|
991
1002
|
/** Input action type strings, allowing for custom action extensions */
|
|
992
1003
|
type InputActionType = BuiltInActionType | (string & {});
|
|
993
|
-
/**
|
|
994
|
-
|
|
1004
|
+
/**
|
|
1005
|
+
* Supported CSS units for layout calculation.
|
|
1006
|
+
* Using a constant array for runtime validation.
|
|
1007
|
+
*/
|
|
1008
|
+
declare const VALID_UNITS: readonly ["px", "%", "vh", "vw", "rem", "em"];
|
|
1009
|
+
/**
|
|
1010
|
+
* Derived type for type safety in TS
|
|
1011
|
+
*/
|
|
1012
|
+
type CssUnit = (typeof VALID_UNITS)[number];
|
|
1013
|
+
/**
|
|
1014
|
+
* Parsed length input.
|
|
1015
|
+
*/
|
|
1016
|
+
interface ParsedLength {
|
|
1017
|
+
value: number;
|
|
1018
|
+
unit: CssUnit;
|
|
1019
|
+
}
|
|
995
1020
|
/**
|
|
996
1021
|
* Flexible length input.
|
|
997
1022
|
* Supports numbers (interpreted as px) or strings (e.g., '50%', '10vh').
|
|
998
1023
|
*/
|
|
999
|
-
type FlexibleLength = string | number;
|
|
1024
|
+
type FlexibleLength = ParsedLength | string | number;
|
|
1000
1025
|
/**
|
|
1001
1026
|
* Anchor position used to determine the alignment of an element relative to its coordinates.
|
|
1002
1027
|
*/
|
|
@@ -1048,4 +1073,4 @@ declare const CONTEXT: {
|
|
|
1048
1073
|
*/
|
|
1049
1074
|
type AnyFunction = (...args: any[]) => void;
|
|
1050
1075
|
|
|
1051
|
-
export { type AbstractRect as A, type ButtonConfig as B, CMP_TYPES as C, type DPadConfig as D, type EntityType as E, type FlatConfigItem as F, type GamepadMappingConfig as G, type
|
|
1076
|
+
export { type AbstractRect as A, type ButtonConfig as B, CMP_TYPES as C, type DPadConfig as D, type EntityType as E, type FlatConfigItem as F, type GamepadMappingConfig as G, type ILifecycle as H, type ICoreEntity as I, type JoystickConfig as J, type InputActionType as K, KEYS as L, type KeyMapping as M, type LayoutBox as N, type StandardButton as O, type ParsedLength as P, VALID_UNITS as Q, type WidgetType as R, type StageId as S, type TargetZoneConfig as T, type ZoneType as U, type Vec2 as V, type WidgetId as W, type ZoneId as Z, type ISpatial as a, type IResettable as b, type IConfigurable as c, type IStateful as d, type IPointerHandler as e, type IProgrammatic as f, type AbstractPointerEvent as g, type InputZoneConfig as h, type IDependencyBindable as i, type AnyFunction as j, type BaseConfig as k, type ISignalReceiver as l, type InputActionSignal as m, type TrackpadConfig as n, ACTION_TYPES as o, type ActionMapping as p, type AnchorPoint as q, type AnyConfig as r, type AnyEntityType as s, type BuiltInActionType as t, CONTEXT as u, type ConfigTreeNode as v, type CssUnit as w, type FlexibleLength as x, type GamepadProfile as y, type IIdentifiable as z };
|
|
@@ -797,30 +797,41 @@ interface ISpatial {
|
|
|
797
797
|
* Trait: Provides configuration management.
|
|
798
798
|
*/
|
|
799
799
|
interface IConfigurable<TConfig> {
|
|
800
|
-
/**
|
|
801
|
-
* Dynamically updates the current configuration.
|
|
802
|
-
* @param config - Partial configuration object to merge.
|
|
803
|
-
*/
|
|
804
|
-
updateConfig(config: Partial<TConfig>): void;
|
|
805
800
|
/**
|
|
806
801
|
* Retrieves a snapshot of the current configuration.
|
|
807
802
|
*/
|
|
808
803
|
getConfig(): TConfig;
|
|
804
|
+
/**
|
|
805
|
+
* Subscribes to config changes.
|
|
806
|
+
* @param cb - Callback function triggered on config updates.
|
|
807
|
+
* @returns An unsubscribe function.
|
|
808
|
+
*/
|
|
809
|
+
subscribeConfig(cb: (config: TConfig) => void): () => void;
|
|
810
|
+
/**
|
|
811
|
+
* Updates the internal config and notifies all subscribers.
|
|
812
|
+
* @param config - Partial configuration object to merge.
|
|
813
|
+
*/
|
|
814
|
+
updateConfig(config: Partial<TConfig>): void;
|
|
809
815
|
}
|
|
810
816
|
/**
|
|
811
|
-
* Trait:
|
|
817
|
+
* Trait: Provides state management.
|
|
812
818
|
*/
|
|
813
|
-
interface
|
|
819
|
+
interface IStateful<TState> {
|
|
820
|
+
/**
|
|
821
|
+
* Retrieves the current state snapshot.
|
|
822
|
+
*/
|
|
823
|
+
getState(): TState;
|
|
814
824
|
/**
|
|
815
825
|
* Subscribes to state changes.
|
|
816
826
|
* @param cb - Callback function triggered on state updates.
|
|
817
827
|
* @returns An unsubscribe function.
|
|
818
828
|
*/
|
|
819
|
-
|
|
829
|
+
subscribeState(cb: (state: TState) => void): () => void;
|
|
820
830
|
/**
|
|
821
|
-
*
|
|
831
|
+
* Updates the internal state and notifies all subscribers.
|
|
832
|
+
* @param state - Partial object containing updated state values.
|
|
822
833
|
*/
|
|
823
|
-
|
|
834
|
+
setState(state: Partial<TState>): void;
|
|
824
835
|
}
|
|
825
836
|
/**
|
|
826
837
|
* Trait: Allows resetting the entity to its idle/safe state.
|
|
@@ -990,13 +1001,27 @@ type EntityType = AnyEntityType | (string & {});
|
|
|
990
1001
|
type BuiltInActionType = (typeof ACTION_TYPES)[keyof typeof ACTION_TYPES];
|
|
991
1002
|
/** Input action type strings, allowing for custom action extensions */
|
|
992
1003
|
type InputActionType = BuiltInActionType | (string & {});
|
|
993
|
-
/**
|
|
994
|
-
|
|
1004
|
+
/**
|
|
1005
|
+
* Supported CSS units for layout calculation.
|
|
1006
|
+
* Using a constant array for runtime validation.
|
|
1007
|
+
*/
|
|
1008
|
+
declare const VALID_UNITS: readonly ["px", "%", "vh", "vw", "rem", "em"];
|
|
1009
|
+
/**
|
|
1010
|
+
* Derived type for type safety in TS
|
|
1011
|
+
*/
|
|
1012
|
+
type CssUnit = (typeof VALID_UNITS)[number];
|
|
1013
|
+
/**
|
|
1014
|
+
* Parsed length input.
|
|
1015
|
+
*/
|
|
1016
|
+
interface ParsedLength {
|
|
1017
|
+
value: number;
|
|
1018
|
+
unit: CssUnit;
|
|
1019
|
+
}
|
|
995
1020
|
/**
|
|
996
1021
|
* Flexible length input.
|
|
997
1022
|
* Supports numbers (interpreted as px) or strings (e.g., '50%', '10vh').
|
|
998
1023
|
*/
|
|
999
|
-
type FlexibleLength = string | number;
|
|
1024
|
+
type FlexibleLength = ParsedLength | string | number;
|
|
1000
1025
|
/**
|
|
1001
1026
|
* Anchor position used to determine the alignment of an element relative to its coordinates.
|
|
1002
1027
|
*/
|
|
@@ -1048,4 +1073,4 @@ declare const CONTEXT: {
|
|
|
1048
1073
|
*/
|
|
1049
1074
|
type AnyFunction = (...args: any[]) => void;
|
|
1050
1075
|
|
|
1051
|
-
export { type AbstractRect as A, type ButtonConfig as B, CMP_TYPES as C, type DPadConfig as D, type EntityType as E, type FlatConfigItem as F, type GamepadMappingConfig as G, type
|
|
1076
|
+
export { type AbstractRect as A, type ButtonConfig as B, CMP_TYPES as C, type DPadConfig as D, type EntityType as E, type FlatConfigItem as F, type GamepadMappingConfig as G, type ILifecycle as H, type ICoreEntity as I, type JoystickConfig as J, type InputActionType as K, KEYS as L, type KeyMapping as M, type LayoutBox as N, type StandardButton as O, type ParsedLength as P, VALID_UNITS as Q, type WidgetType as R, type StageId as S, type TargetZoneConfig as T, type ZoneType as U, type Vec2 as V, type WidgetId as W, type ZoneId as Z, type ISpatial as a, type IResettable as b, type IConfigurable as c, type IStateful as d, type IPointerHandler as e, type IProgrammatic as f, type AbstractPointerEvent as g, type InputZoneConfig as h, type IDependencyBindable as i, type AnyFunction as j, type BaseConfig as k, type ISignalReceiver as l, type InputActionSignal as m, type TrackpadConfig as n, ACTION_TYPES as o, type ActionMapping as p, type AnchorPoint as q, type AnyConfig as r, type AnyEntityType as s, type BuiltInActionType as t, CONTEXT as u, type ConfigTreeNode as v, type CssUnit as w, type FlexibleLength as x, type GamepadProfile as y, type IIdentifiable as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunkPAGWIRTX_cjs=require('./chunk-PAGWIRTX.cjs');var $={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}},S=$;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"},G={PARENT_ID_KEY:"omnipad-parent-id-link"};var w=Symbol.for("omnipad.gamepad_manager.instance"),ee={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},R=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[w]||(o[w]=new a),o[w]}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=ee[i];if(c===void 0||!o.buttons[c])return;let d=o.buttons[c].pressed,h=this.lastButtonStates[t][c]||false;d&&!h?this.triggerVirtualEntity(r,"down"):!d&&h&&this.triggerVirtualEntity(r,"up"),this.lastButtonStates[t][c]=d;});}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,d=o.buttons[15]?.pressed?1:0,h=c+d,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=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 A=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):a=>setTimeout(a,16),te=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):a=>clearTimeout(a);function I(a){let o=false,e;return function(t){e=t,o||(o=true,A(()=>{a(e),o=false;}));}}function W(a){let o=null,e=()=>{a(),o=A(e);};return {start:()=>{o===null&&e();},stop:()=>{o!==null&&(te(o),o=null);}}}var X=(a=2)=>new Promise(o=>{let e=0,t=()=>{++e>=a?o():A(t);};A(t);});var M=Symbol.for("omnipad.window_manager.instance"),O=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=I(()=>{this.handleGlobalReset();});}static getInstance(){let o=globalThis;return o[M]||(o[M]=new a),o[M]}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 D=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 D);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 p=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:r}=e;if(t||i||r){e.type="keyboard";let c=Object.values(S).find(d=>d.code===i||d.key===t||d.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 X(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 N={isActive:false,isPressed:false,pointerId:null,value:0},K=class extends l{constructor(e,t){super(e,u.BUTTON,t,N);chunkPAGWIRTX_cjs.a(this,"emitter");this.emitter=new p(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(N),this.emitter.reset();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(e){this.setState(N),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 Z={isActive:false,pointerId:null,vector:{x:0,y:0}},q=.002,z=.3,F=class extends l{constructor(e,t){super(e,u.D_PAD,t,Z);chunkPAGWIRTX_cjs.a(this,"emitters");let i=t.targetStageId;this.emitters={up:new p(i,t.mapping?.up),down:new p(i,t.mapping?.down),left:new p(i,t.mapping?.left),right:new p(i,t.mapping?.right)};}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}}),this.processInput(e,true);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.processInput(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,d=i.width/2,h=i.height/2,f=(e.clientX-r)/d,P=(e.clientY-c)/h;if(t&&(f!=chunkPAGWIRTX_cjs.f(f,-1,1)||P!=chunkPAGWIRTX_cjs.f(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let C={x:chunkPAGWIRTX_cjs.f(f,-1,1),y:chunkPAGWIRTX_cjs.f(P,-1,1)};chunkPAGWIRTX_cjs.u(C,this.state.vector,q)||(this.setState({vector:C}),this.handleDigitalKeys(C));}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(Z);}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=this.config.threshold??.3;if(Math.abs(e)<i&&Math.abs(t)<i){this.state.isActive&&this.reset();return}this.state.isActive||this.setState({isActive:true});let r=chunkPAGWIRTX_cjs.g(this.state.vector.x,e,z),c=chunkPAGWIRTX_cjs.g(this.state.vector.y,t,z),d={x:r,y:c};chunkPAGWIRTX_cjs.u(d,this.state.vector,q)||(this.setState({vector:d}),this.handleDigitalKeys(d));}};var ie={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},Y=class extends l{constructor(e,t){super(e,u.INPUT_ZONE,t,ie);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 T=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 J={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},_=.002,j=.3,U=class extends l{constructor(e,t){super(e,u.JOYSTICK,t,J);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");let i=t.targetStageId,r=t.mapping||{};this.emitters={up:new p(i,r.up),down:new p(i,r.down),left:new p(i,r.left),right:new p(i,r.right)},this.stickEmitter=new p(i,r.stick),this.cursorEmitter=new p(i,{type:"mouse"}),this.gesture=new T({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=W(()=>{this.handleCursorTick();});}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),this.processInput(e,true);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.config.cursorMode&&this.ticker.start(),this.processInput(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,d=i.width/2,h=i.height/2,f=(e.clientX-r)/d,P=(e.clientY-c)/h;if(t&&(f!=chunkPAGWIRTX_cjs.f(f,-1,1)||P!=chunkPAGWIRTX_cjs.f(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let x=chunkPAGWIRTX_cjs.w({x:f,y:P},1,this.config.threshold||.15);chunkPAGWIRTX_cjs.u(x,this.state.vector,_)||(this.setState({vector:x}),this.handleDigitalKeys(x));}handleCursorTick(){let{vector:e,isActive:t}=this.state;if(!t||!this.config.cursorMode||chunkPAGWIRTX_cjs.u(e,{x:0,y:0},_)){this.ticker.stop();return}let i=this.config.cursorSensitivity??1,r={x:e.x*Math.abs(e.x)*i,y:e.y*Math.abs(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(J),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=this.config.threshold??.15;if(Math.hypot(e,t)<i){this.state.isActive&&this.handleRelease();return}this.state.isActive||this.setState({isActive:true});let c=chunkPAGWIRTX_cjs.g(this.state.vector.x,e,j),d=chunkPAGWIRTX_cjs.g(this.state.vector.y,t,j),h={x:c,y:d};chunkPAGWIRTX_cjs.u(h,this.state.vector,_)||(this.setState({vector:h}),this.handleDigitalKeys(h)),this.config.cursorMode&&this.ticker.start();}};var oe={isHighlighted:false},L=class extends l{constructor(o,e){super(o,u.ROOT_LAYER,e,oe);}reset(){}};var se={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},b=1,B=class extends l{constructor(e,t){super(e,u.TARGET_ZONE,t,se);chunkPAGWIRTX_cjs.a(this,"hideTimer",null);chunkPAGWIRTX_cjs.a(this,"focusFeedbackTimer",null);chunkPAGWIRTX_cjs.a(this,"throttledMoveExecution");chunkPAGWIRTX_cjs.a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledMoveExecution=I(i=>{this.executeMouseAction(n.POINTERMOVE,i);});}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.processPhysicalEvent(e,n.MOUSEMOVE);}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: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: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.throttledMoveExecution(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=chunkPAGWIRTX_cjs.f(i.left+chunkPAGWIRTX_cjs.p(r.x,i.width),i.left+b,i.left+i.width-b),d=chunkPAGWIRTX_cjs.f(i.top+chunkPAGWIRTX_cjs.p(r.y,i.height),i.top+b,i.top+i.height-b);this.delegates.dispatchPointerEventAtPos?.(e,c,d,{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=chunkPAGWIRTX_cjs.f(e.left+chunkPAGWIRTX_cjs.p(this.state.position.x,e.width),e.left+b,e.left+e.width-b),i=chunkPAGWIRTX_cjs.f(e.top+chunkPAGWIRTX_cjs.p(this.state.position.y,e.height),e.top+b,e.top+e.height-b);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),r=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+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 Q={isActive:false,isPressed:false,pointerId:null,value:0},V=class extends l{constructor(e,t){super(e,u.TRACKPAD,t,Q);chunkPAGWIRTX_cjs.a(this,"lastPointerPos",{x:0,y:0});chunkPAGWIRTX_cjs.a(this,"gesture");chunkPAGWIRTX_cjs.a(this,"emitter");let i=t.mapping||{type:"mouse"};this.emitter=new p(t.targetStageId,i),this.gesture=new T({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.processInput(e));}processInput(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),d=i/r.height*100*(this.config.sensitivity??1),h={x:c,y:d};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(Q);}};var Kt={ActionTypes:n,Context:G,Keys:S,Types:u};Object.defineProperty(exports,"Registry",{enumerable:true,get:function(){return chunkPAGWIRTX_cjs.b}});exports.ACTION_TYPES=n;exports.BaseEntity=l;exports.ButtonCore=K;exports.CMP_TYPES=u;exports.CONTEXT=G;exports.DPadCore=F;exports.GamepadManager=R;exports.InputZoneCore=Y;exports.JoystickCore=U;exports.KEYS=S;exports.OmniPad=Kt;exports.RootLayerCore=L;exports.TargetZoneCore=B;exports.TrackpadCore=V;exports.WindowManager=O;
|
|
1
|
+
'use strict';var chunkFAVAOSNA_cjs=require('./chunk-FAVAOSNA.cjs');var R=Symbol.for("omnipad.gamepad_manager.instance"),Q={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},M=class c{constructor(){chunkFAVAOSNA_cjs.a(this,"isRunning",false);chunkFAVAOSNA_cjs.a(this,"config",null);chunkFAVAOSNA_cjs.a(this,"lastButtonStates",[]);chunkFAVAOSNA_cjs.a(this,"loop",()=>{if(!this.isRunning)return;let s=navigator.getGamepads();this.config?.forEach((t,e)=>{let i=s[e];i&&i.connected&&t&&(this.lastButtonStates[e]||(this.lastButtonStates[e]=[]),this.processButtons(i,t,e),this.processDPad(i,t),this.processAxes(i,t));}),requestAnimationFrame(this.loop);});}static getInstance(){let s=globalThis;return s[R]||(s[R]=new c),s[R]}setConfig(s){this.config=s;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",s=>{undefined?.DEV&&console.log("[Omnipad-Core] Gamepad Connected:",s.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{undefined?.DEV&&console.log("[Omnipad-Core] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(s,t,e){t.buttons&&Object.entries(t.buttons).forEach(([i,o])=>{let n=Q[i];if(n===void 0||!s.buttons[n])return;let l=s.buttons[n].pressed,u=this.lastButtonStates[e][n]||false;l&&!u?this.triggerVirtualEntity(o,"down"):!l&&u&&this.triggerVirtualEntity(o,"up"),this.lastButtonStates[e][n]=l;});}processDPad(s,t){let e=t?.dpad;if(!e)return;let i=s.buttons[12]?.pressed?-1:0,o=s.buttons[13]?.pressed?1:0,n=s.buttons[14]?.pressed?-1:0,l=s.buttons[15]?.pressed?1:0,u=n+l,v=i+o;this.triggerVirtualEntity(e,"vector",{x:u,y:v});}processAxes(s,t){let e=t?.deadzone??.1;if(t?.leftStick){let i=Math.abs(s.axes[0])>e?s.axes[0]:0,o=Math.abs(s.axes[1])>e?s.axes[1]:0;this.triggerVirtualEntity(t.leftStick,"vector",{x:i,y:o});}if(t?.rightStick){let i=Math.abs(s.axes[2])>e?s.axes[2]:0,o=Math.abs(s.axes[3])>e?s.axes[3]:0;this.triggerVirtualEntity(t.rightStick,"vector",{x:i,y:o});}}triggerVirtualEntity(s,t,e){let i=chunkFAVAOSNA_cjs.g.getInstance().getEntity(s);!i||i.activePointerId!=null||(t==="down"&&i.triggerDown&&i.triggerDown(),t==="up"&&i.triggerUp&&i.triggerUp(),t==="vector"&&i.triggerVector&&e&&i.triggerVector(e.x,e.y));}};var w=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):c=>setTimeout(c,16),tt=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):c=>clearTimeout(c);function D(c){let s=false,t;return function(e){t=e,s||(s=true,w(()=>{c(t),s=false;}));}}function K(c){let s=null,t=()=>{c(),s=w(t);};return {start:()=>{s===null&&t();},stop:()=>{s!==null&&(tt(s),s=null);}}}var X=(c=2)=>new Promise(s=>{let t=0,e=()=>{++t>=c?s():w(e);};w(e);});var k=Symbol.for("omnipad.window_manager.instance"),O=class c{constructor(){chunkFAVAOSNA_cjs.a(this,"_isListening",false);chunkFAVAOSNA_cjs.a(this,"throttledReset");chunkFAVAOSNA_cjs.a(this,"handleGlobalReset",()=>{undefined?.DEV&&console.debug("[OmniPad-Core] Safety reset triggered by environment change."),chunkFAVAOSNA_cjs.g.getInstance().resetAll();});chunkFAVAOSNA_cjs.a(this,"handleResizeReset",()=>{this.throttledReset(null);});chunkFAVAOSNA_cjs.a(this,"handleBlurReset",()=>{this.handleGlobalReset();});chunkFAVAOSNA_cjs.a(this,"handleScrollReset",()=>{this.throttledReset(null);});chunkFAVAOSNA_cjs.a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=D(()=>{this.handleGlobalReset();});}static getInstance(){let s=globalThis;return s[k]||(s[k]=new c),s[k]}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(s){let t=s||document.documentElement;try{document.fullscreenElement?(chunkFAVAOSNA_cjs.g.getInstance().resetAll(),await document.exitFullscreen()):(chunkFAVAOSNA_cjs.g.getInstance().resetAll(),await t.requestFullscreen());}catch(e){console.error("[OmniPad-Core] Fullscreen toggle failed:",e);}}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 S=class{constructor(){chunkFAVAOSNA_cjs.a(this,"listeners",new Set);}subscribe(s){return this.listeners.add(s),()=>this.listeners.delete(s)}emit(s){this.listeners.forEach(t=>{try{t(s);}catch(e){console.error("[OmniPad-Core] Emitter callback error:",e);}});}clear(){this.listeners.clear();}};var d=class{constructor(s,t,e,i){chunkFAVAOSNA_cjs.a(this,"uid");chunkFAVAOSNA_cjs.a(this,"type");chunkFAVAOSNA_cjs.a(this,"config");chunkFAVAOSNA_cjs.a(this,"state");chunkFAVAOSNA_cjs.a(this,"rectProvider",null);chunkFAVAOSNA_cjs.a(this,"_onMarkDirtyCb",null);chunkFAVAOSNA_cjs.a(this,"stateEmitter",new S);chunkFAVAOSNA_cjs.a(this,"configEmitter",new S);this.uid=s,this.type=t,this.config=e,this.state=i;}getConfig(){return this.config}subscribeConfig(s){return s(this.config),this.configEmitter.subscribe(s)}updateConfig(s){this.config={...this.config,...s},this.configEmitter.emit(this.config);}getState(){return this.state}setState(s){this.state={...this.state,...s},this.stateEmitter.emit(this.state);}subscribeState(s){return s(this.state),this.stateEmitter.subscribe(s)}destroy(){this.reset(),this.stateEmitter.clear(),this.configEmitter.clear(),chunkFAVAOSNA_cjs.g.getInstance().unregister(this.uid);}get rect(){return this.rectProvider?this.rectProvider():null}bindRectProvider(s,t){this.rectProvider=s,t&&(this._onMarkDirtyCb=t);}markRectDirty(){this._onMarkDirtyCb?.();}};var p=class{constructor(s,t){chunkFAVAOSNA_cjs.a(this,"isPressed",false);chunkFAVAOSNA_cjs.a(this,"mapping");chunkFAVAOSNA_cjs.a(this,"targetId");this.update(s,t);}update(s,t){this.isPressed&&this.reset(),this.targetId=s,this.mapping=this.hydrate(t);}hydrate(s){if(!s)return;let t={...s};if(t.type==="mouse")return t.button=t.button??0,t;let{key:e,code:i,keyCode:o}=t;if(e||i||o){t.type="keyboard";let n=Object.values(chunkFAVAOSNA_cjs.b).find(l=>l.code===i||l.key===e||l.keyCode===o);n&&(t.key=e??n.key,t.code=i??n.code,t.keyCode=o??n.keyCode);}return t}press(){if(!this.mapping||this.isPressed)return;this.isPressed=true;let s=this.mapping.type==="keyboard"?chunkFAVAOSNA_cjs.d.KEYDOWN:chunkFAVAOSNA_cjs.d.MOUSEDOWN;this.emitSignal(s);}release(s=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let t=this.mapping.type==="keyboard"?chunkFAVAOSNA_cjs.d.KEYUP:chunkFAVAOSNA_cjs.d.MOUSEUP;this.emitSignal(t),this.mapping.type==="mouse"&&s&&this.emitSignal(chunkFAVAOSNA_cjs.d.CLICK);}move(s){this.mapping?.type==="mouse"&&this.emitSignal(chunkFAVAOSNA_cjs.d.MOUSEMOVE,s);}reset(){this.isPressed&&this.release(false);}async tap(s=true){this.isPressed||(this.press(),await X(2),this.isPressed&&this.release(s));}emitSignal(s,t={}){if(!this.targetId||!this.mapping)return;let e=chunkFAVAOSNA_cjs.g.getInstance().getEntity(this.targetId);e&&e.handleSignal({targetStageId:this.targetId,type:s,payload:{key:this.mapping.key,code:this.mapping.code,keyCode:this.mapping.keyCode,button:this.mapping.button,point:this.mapping.fixedPoint,...t}});}};var Y={isActive:false,isPressed:false,pointerId:null,value:0},V=class extends d{constructor(t,e,i){super(t,i||chunkFAVAOSNA_cjs.c.BUTTON,e,Y);chunkFAVAOSNA_cjs.a(this,"emitter");this.emitter=new p(e.targetStageId,e.mapping);}get activePointerId(){return this.state.pointerId}onPointerDown(t){this.setState({isActive:true,isPressed:true,pointerId:t.pointerId}),this.emitter.press();}onPointerUp(t){!this.state.isActive||t.pointerId!==this.state.pointerId||this.handleRelease(true);}onPointerCancel(){this.handleRelease(false);}onPointerMove(){}reset(){this.setState(Y),this.emitter.reset();}updateConfig(t){super.updateConfig(t),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(t){this.setState(Y),this.emitter.release(t);}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 Z={isActive:false,pointerId:null,vector:{x:0,y:0}},z=.002,q=.3,_=class extends d{constructor(t,e,i){super(t,i||chunkFAVAOSNA_cjs.c.D_PAD,e,Z);chunkFAVAOSNA_cjs.a(this,"emitters");let o=e.targetStageId;this.emitters={up:new p(o,e.mapping?.up),down:new p(o,e.mapping?.down),left:new p(o,e.mapping?.left),right:new p(o,e.mapping?.right)};}get activePointerId(){return this.state.pointerId}onPointerDown(t){this.setState({isActive:true,pointerId:t.pointerId,vector:{x:0,y:0}}),this.processInput(t,true);}onPointerMove(t){!this.state.isActive||t.pointerId!==this.state.pointerId||this.processInput(t);}onPointerUp(t){!this.state.isActive||t.pointerId!==this.state.pointerId||this.reset();}onPointerCancel(){this.reset();}processInput(t,e=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let o=i.left+i.width/2,n=i.top+i.height/2,l=i.width/2,u=i.height/2,v=(t.clientX-o)/l,P=(t.clientY-n)/u;if(e&&(v!=chunkFAVAOSNA_cjs.k(v,-1,1)||P!=chunkFAVAOSNA_cjs.k(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let A={x:chunkFAVAOSNA_cjs.k(v,-1,1),y:chunkFAVAOSNA_cjs.k(P,-1,1)};chunkFAVAOSNA_cjs.z(A,this.state.vector,z)||(this.setState({vector:A}),this.handleDigitalKeys(A));}handleDigitalKeys(t){let e=this.config.threshold??.3;t.y<-e?(this.emitters.up.press(),this.emitters.down.release()):t.y>e?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),t.x<-e?(this.emitters.left.press(),this.emitters.right.release()):t.x>e?(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(Z);}updateConfig(t){super.updateConfig(t),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(t,e){let i=this.config.threshold??.3;if(Math.abs(t)<i&&Math.abs(e)<i){this.state.isActive&&this.reset();return}this.state.isActive||this.setState({isActive:true});let o=chunkFAVAOSNA_cjs.l(this.state.vector.x,t,q),n=chunkFAVAOSNA_cjs.l(this.state.vector.y,e,q),l={x:o,y:n};chunkFAVAOSNA_cjs.z(l,this.state.vector,z)||(this.setState({vector:l}),this.handleDigitalKeys(l));}};var et={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},B=class extends d{constructor(t,e,i){super(t,i||chunkFAVAOSNA_cjs.c.INPUT_ZONE,e,et);chunkFAVAOSNA_cjs.a(this,"delegates",{dynamicWidgetPointerDown:()=>{},dynamicWidgetPointerMove:()=>{},dynamicWidgetPointerUp:()=>{},dynamicWidgetPointerCancel:()=>{}});}bindDelegate(t,e){Object.prototype.hasOwnProperty.call(this.delegates,t)?this.delegates[t]=e:undefined?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${t}`);}get activePointerId(){return this.state.dynamicPointerId}onPointerDown(t){if(this.state.isDynamicActive)return;let e=this.calculateRelativePosition(t.clientX,t.clientY);this.setState({isDynamicActive:true,dynamicPointerId:t.pointerId,dynamicPosition:e}),this.delegates.dynamicWidgetPointerDown?.(t);}onPointerMove(t){this.state.isDynamicActive&&this.delegates.dynamicWidgetPointerMove?.(t);}onPointerUp(t){this.delegates.dynamicWidgetPointerUp?.(t),this.reset();}onPointerCancel(t){this.delegates.dynamicWidgetPointerCancel?.(t),this.reset();}calculateRelativePosition(t,e){let i=this.rect;return i?{x:chunkFAVAOSNA_cjs.v(t-i.left,i.width),y:chunkFAVAOSNA_cjs.v(e-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 T=class{constructor(s={}){chunkFAVAOSNA_cjs.a(this,"options");chunkFAVAOSNA_cjs.a(this,"startTime",0);chunkFAVAOSNA_cjs.a(this,"startPos",{x:0,y:0});chunkFAVAOSNA_cjs.a(this,"lastTapTime",0);chunkFAVAOSNA_cjs.a(this,"hasMoved",false);chunkFAVAOSNA_cjs.a(this,"isDoubleTapHolding",false);this.options={tapTime:250,tapDistance:10,doubleTapGap:300,...s};}onPointerDown(s,t){let e=Date.now();this.startTime=e,this.startPos={x:s,y:t},this.hasMoved=false,e-this.lastTapTime<this.options.doubleTapGap?(this.isDoubleTapHolding=true,this.options.onDoubleTapHoldStart?.()):this.isDoubleTapHolding=false;}onPointerMove(s,t){this.hasMoved||Math.hypot(s-this.startPos.x,t-this.startPos.y)>this.options.tapDistance&&(this.hasMoved=true);}onPointerUp(){let s=Date.now(),t=s-this.startTime;this.isDoubleTapHolding?(this.isDoubleTapHolding=false,this.options.onDoubleTapHoldEnd?.(),this.lastTapTime=0):t<=this.options.tapTime&&!this.hasMoved&&(this.options.onTap?.(),s-this.lastTapTime<this.options.doubleTapGap?(this.options.onDoubleTap?.(),this.lastTapTime=0):this.lastTapTime=s);}reset(){this.isDoubleTapHolding&&this.options.onDoubleTapHoldEnd?.(),this.isDoubleTapHolding=false,this.hasMoved=false,this.startTime=0,this.lastTapTime=0;}};var J={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},U=.002,j=.3,H=class extends d{constructor(t,e,i){super(t,i||chunkFAVAOSNA_cjs.c.JOYSTICK,e,J);chunkFAVAOSNA_cjs.a(this,"emitters");chunkFAVAOSNA_cjs.a(this,"stickEmitter");chunkFAVAOSNA_cjs.a(this,"cursorEmitter");chunkFAVAOSNA_cjs.a(this,"gesture");chunkFAVAOSNA_cjs.a(this,"ticker");let o=e.targetStageId,n=e.mapping||{};this.emitters={up:new p(o,n.up),down:new p(o,n.down),left:new p(o,n.left),right:new p(o,n.right)},this.stickEmitter=new p(o,n.stick),this.cursorEmitter=new p(o,{type:"mouse"}),this.gesture=new T({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=K(()=>{this.handleCursorTick();});}get activePointerId(){return this.state.pointerId}onPointerDown(t){this.setState({isActive:true,pointerId:t.pointerId,vector:{x:0,y:0}}),this.gesture.onPointerDown(t.clientX,t.clientY),this.processInput(t,true);}onPointerMove(t){!this.state.isActive||t.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(t.clientX,t.clientY),this.config.cursorMode&&this.ticker.start(),this.processInput(t));}onPointerUp(t){!this.state.isActive||t.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(t=>t?.reset());}processInput(t,e=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let o=i.left+i.width/2,n=i.top+i.height/2,l=i.width/2,u=i.height/2,v=(t.clientX-o)/l,P=(t.clientY-n)/u;if(e&&(v!=chunkFAVAOSNA_cjs.k(v,-1,1)||P!=chunkFAVAOSNA_cjs.k(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let x=chunkFAVAOSNA_cjs.B({x:v,y:P},1,this.config.threshold||.15);chunkFAVAOSNA_cjs.z(x,this.state.vector,U)||(this.setState({vector:x}),this.handleDigitalKeys(x));}handleCursorTick(){let{vector:t,isActive:e}=this.state;if(!e||!this.config.cursorMode||chunkFAVAOSNA_cjs.z(t,{x:0,y:0},U)){this.ticker.stop();return}let i=this.config.cursorSensitivity??1,o={x:t.x*Math.abs(t.x)*i,y:t.y*Math.abs(t.y)*i};(Math.abs(o.x)>0||Math.abs(o.y)>0)&&this.cursorEmitter.move({delta:o});}handleDigitalKeys(t){let e=this.config.threshold??.3;t.y<-e?(this.emitters.up.press(),this.emitters.down.release()):t.y>e?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),t.x<-e?(this.emitters.left.press(),this.emitters.right.release()):t.x>e?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.setState(J),this.gesture.reset(),this.handleRelease(),this.stickEmitter.reset(),this.cursorEmitter.reset();}updateConfig(t){super.updateConfig(t);let e=this.config.targetStageId,i=this.config.mapping||{};this.emitters.up.update(e,i.up),this.emitters.down.update(e,i.down),this.emitters.left.update(e,i.left),this.emitters.right.update(e,i.right),this.stickEmitter.update(e,i.stick),this.cursorEmitter.update(e);}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(t,e){let i=this.config.threshold??.15;if(Math.hypot(t,e)<i){this.state.isActive&&this.handleRelease();return}this.state.isActive||this.setState({isActive:true});let n=chunkFAVAOSNA_cjs.l(this.state.vector.x,t,j),l=chunkFAVAOSNA_cjs.l(this.state.vector.y,e,j),u={x:n,y:l};chunkFAVAOSNA_cjs.z(u,this.state.vector,U)||(this.setState({vector:u}),this.handleDigitalKeys(u)),this.config.cursorMode&&this.ticker.start();}};var it={isHighlighted:false},F=class extends d{constructor(s,t,e){super(s,e||chunkFAVAOSNA_cjs.c.ROOT_LAYER,t,it);}reset(){}};var st={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},y=1,G=class extends d{constructor(t,e,i){super(t,i||chunkFAVAOSNA_cjs.c.TARGET_ZONE,e,st);chunkFAVAOSNA_cjs.a(this,"hideTimer",null);chunkFAVAOSNA_cjs.a(this,"focusFeedbackTimer",null);chunkFAVAOSNA_cjs.a(this,"throttledMoveExecution");chunkFAVAOSNA_cjs.a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledMoveExecution=D(o=>{this.executeMouseAction(chunkFAVAOSNA_cjs.d.POINTERMOVE,o);});}bindDelegate(t,e){Object.prototype.hasOwnProperty.call(this.delegates,t)?this.delegates[t]=e:undefined?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${t}`);}get activePointerId(){return null}onPointerDown(t){this.processPhysicalEvent(t,chunkFAVAOSNA_cjs.d.MOUSEDOWN);}onPointerMove(t){this.processPhysicalEvent(t,chunkFAVAOSNA_cjs.d.MOUSEMOVE);}onPointerUp(t){this.processPhysicalEvent(t,chunkFAVAOSNA_cjs.d.MOUSEUP),this.processPhysicalEvent(t,chunkFAVAOSNA_cjs.d.CLICK);}onPointerCancel(t){this.processPhysicalEvent(t,chunkFAVAOSNA_cjs.d.MOUSEUP);}processPhysicalEvent(t,e){let i=this.rect;if(!i)return;let o={x:chunkFAVAOSNA_cjs.v(t.clientX-i.left,i.width),y:chunkFAVAOSNA_cjs.v(t.clientY-i.top,i.height)};this.handleSignal({targetStageId:this.uid,type:e,payload:{point:o,button:t.button}});}handleSignal(t){let{type:e,payload:i}=t;switch(this.ensureFocus(),e){case chunkFAVAOSNA_cjs.d.KEYDOWN:case chunkFAVAOSNA_cjs.d.KEYUP:this.delegates.dispatchKeyboardEvent?.(e,i);break;case chunkFAVAOSNA_cjs.d.MOUSEMOVE:i.point?this.updateCursorPosition(i.point):i.delta&&this.updateCursorPositionByDelta(i.delta),this.config.cursorEnabled&&this.showCursor(),this.throttledMoveExecution(i);break;case chunkFAVAOSNA_cjs.d.MOUSEDOWN:case chunkFAVAOSNA_cjs.d.MOUSEUP:case chunkFAVAOSNA_cjs.d.CLICK:i.point&&this.updateCursorPosition(i.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(e.startsWith(chunkFAVAOSNA_cjs.d.MOUSE)?e.replace(chunkFAVAOSNA_cjs.d.MOUSE,chunkFAVAOSNA_cjs.d.POINTER):e,i);break}}executeMouseAction(t,e){let i=this.rect;if(!i)return;t===chunkFAVAOSNA_cjs.d.POINTERDOWN&&this.setState({isPointerDown:true}),t===chunkFAVAOSNA_cjs.d.POINTERUP&&this.setState({isPointerDown:false});let o=e.point||this.state.position,n=chunkFAVAOSNA_cjs.k(i.left+chunkFAVAOSNA_cjs.u(o.x,i.width),i.left+y,i.left+i.width-y),l=chunkFAVAOSNA_cjs.k(i.top+chunkFAVAOSNA_cjs.u(o.y,i.height),i.top+y,i.top+i.height-y);this.delegates.dispatchPointerEventAtPos?.(t,n,l,{button:e.button??0,buttons:this.state.isPointerDown?1:0,pressure:this.state.isPointerDown?.5:0});}ensureFocus(){let t=this.rect;if(!t)return;let e=chunkFAVAOSNA_cjs.k(t.left+chunkFAVAOSNA_cjs.u(this.state.position.x,t.width),t.left+y,t.left+t.width-y),i=chunkFAVAOSNA_cjs.k(t.top+chunkFAVAOSNA_cjs.u(this.state.position.y,t.height),t.top+y,t.top+t.height-y);this.delegates.reclaimFocusAtPos?.(e,i,()=>this.triggerFocusFeedback());}triggerFocusFeedback(){this.setState({isFocusReturning:true}),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.focusFeedbackTimer=setTimeout(()=>this.setState({isFocusReturning:false}),500);}updateCursorPosition(t){chunkFAVAOSNA_cjs.z(t,this.state.position)||this.setState({position:{...t}});}updateCursorPositionByDelta(t){if(chunkFAVAOSNA_cjs.z(t,{x:0,y:0}))return;let e=this.rect;if(!e)return;let i=chunkFAVAOSNA_cjs.v(t.x,e.width),o=chunkFAVAOSNA_cjs.v(t.y,e.height);this.updateCursorPosition({x:chunkFAVAOSNA_cjs.k(this.state.position.x+i,0,100),y:chunkFAVAOSNA_cjs.k(this.state.position.y+o,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(chunkFAVAOSNA_cjs.d.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:false,isPointerDown:false,isFocusReturning:false});}};var $={isActive:false,isPressed:false,pointerId:null,value:0},L=class extends d{constructor(t,e,i){super(t,i||chunkFAVAOSNA_cjs.c.TRACKPAD,e,$);chunkFAVAOSNA_cjs.a(this,"lastPointerPos",{x:0,y:0});chunkFAVAOSNA_cjs.a(this,"gesture");chunkFAVAOSNA_cjs.a(this,"emitter");let o=e.mapping||{type:"mouse"};this.emitter=new p(e.targetStageId,o),this.gesture=new T({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(t){this.lastPointerPos={x:t.clientX,y:t.clientY},this.gesture.onPointerDown(t.clientX,t.clientY),this.setState({isActive:true,pointerId:t.pointerId});}onPointerMove(t){!this.state.isActive||t.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(t.clientX,t.clientY),this.processInput(t));}processInput(t){if(!this.state.isActive)return;let e=t.clientX-this.lastPointerPos.x,i=t.clientY-this.lastPointerPos.y,o=this.rect;if(!o)return;let n=e/o.width*100*(this.config.sensitivity??1),l=i/o.height*100*(this.config.sensitivity??1),u={x:n,y:l};chunkFAVAOSNA_cjs.z(u,{x:0,y:0})||this.emitter.move({delta:u}),this.lastPointerPos={x:t.clientX,y:t.clientY};}onPointerUp(t){!this.state.isActive||t.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}reset(){this.gesture.reset(),this.emitter.reset(),this.handleRelease();}updateConfig(t){super.updateConfig(t),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(){this.setState($);}};var Ye={ActionTypes:chunkFAVAOSNA_cjs.d,Context:chunkFAVAOSNA_cjs.f,Keys:chunkFAVAOSNA_cjs.b,Types:chunkFAVAOSNA_cjs.c};Object.defineProperty(exports,"ACTION_TYPES",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.d}});Object.defineProperty(exports,"CMP_TYPES",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.c}});Object.defineProperty(exports,"CONTEXT",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.f}});Object.defineProperty(exports,"KEYS",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.b}});Object.defineProperty(exports,"Registry",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.g}});Object.defineProperty(exports,"VALID_UNITS",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.e}});exports.BaseEntity=d;exports.ButtonCore=V;exports.DPadCore=_;exports.GamepadManager=M;exports.InputZoneCore=B;exports.JoystickCore=H;exports.OmniPad=Ye;exports.RootLayerCore=F;exports.TargetZoneCore=G;exports.TrackpadCore=L;exports.WindowManager=O;
|
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
|
|
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,
|
|
1
|
+
import { I as ICoreEntity, V as Vec2, G as GamepadMappingConfig, a as ISpatial, b as IResettable, c as IConfigurable, d as IStateful, 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-CTJog5sj.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, w as CssUnit, F as FlatConfigItem, x as FlexibleLength, y as GamepadProfile, z as IIdentifiable, H as ILifecycle, K as InputActionType, L as KEYS, M as KeyMapping, N as LayoutBox, P as ParsedLength, S as StageId, O as StandardButton, Q as VALID_UNITS, W as WidgetId, R as WidgetType, Z as ZoneId, U as ZoneType } from './index-CTJog5sj.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Interface for the global Registry singleton.
|
|
@@ -332,7 +332,7 @@ declare class SimpleEmitter<T> {
|
|
|
332
332
|
* Base abstract class for all logic entities in the system.
|
|
333
333
|
* Provides fundamental identity management, state subscription, and spatial awareness.
|
|
334
334
|
*/
|
|
335
|
-
declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpatial, IResettable, IConfigurable<TConfig>,
|
|
335
|
+
declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpatial, IResettable, IConfigurable<TConfig>, IStateful<TState> {
|
|
336
336
|
readonly uid: string;
|
|
337
337
|
readonly type: EntityType;
|
|
338
338
|
protected config: TConfig;
|
|
@@ -340,22 +340,19 @@ declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpat
|
|
|
340
340
|
protected rectProvider: (() => AbstractRect) | null;
|
|
341
341
|
private _onMarkDirtyCb;
|
|
342
342
|
protected stateEmitter: SimpleEmitter<TState>;
|
|
343
|
+
protected configEmitter: SimpleEmitter<TConfig>;
|
|
343
344
|
constructor(uid: string, type: EntityType, initialConfig: TConfig, initialState: TState);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
protected setState(partialState: Partial<TState>): void;
|
|
345
|
+
getConfig(): Readonly<TConfig>;
|
|
346
|
+
subscribeConfig(cb: (config: TConfig) => void): () => void;
|
|
347
|
+
updateConfig(newConfig: Partial<TConfig>): void;
|
|
348
|
+
getState(): Readonly<TState>;
|
|
349
|
+
setState(partialState: Partial<TState>): void;
|
|
350
|
+
subscribeState(cb: (state: TState) => void): () => void;
|
|
351
351
|
destroy(): void;
|
|
352
352
|
abstract reset(): void;
|
|
353
353
|
get rect(): AbstractRect | null;
|
|
354
354
|
bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
|
|
355
355
|
markRectDirty(): void;
|
|
356
|
-
updateConfig(newConfig: Partial<TConfig>): void;
|
|
357
|
-
getState(): Readonly<TState>;
|
|
358
|
-
getConfig(): Readonly<TConfig>;
|
|
359
356
|
}
|
|
360
357
|
|
|
361
358
|
/**
|
|
@@ -370,7 +367,7 @@ declare class ButtonCore extends BaseEntity<ButtonConfig, ButtonState> implement
|
|
|
370
367
|
* @param uid - The unique entity ID.
|
|
371
368
|
* @param config - The flat configuration object for the button.
|
|
372
369
|
*/
|
|
373
|
-
constructor(uid: string, config: ButtonConfig);
|
|
370
|
+
constructor(uid: string, config: ButtonConfig, customTypeName?: EntityType);
|
|
374
371
|
get activePointerId(): number | null;
|
|
375
372
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
376
373
|
onPointerUp(e: AbstractPointerEvent): void;
|
|
@@ -394,7 +391,7 @@ declare class ButtonCore extends BaseEntity<ButtonConfig, ButtonState> implement
|
|
|
394
391
|
*/
|
|
395
392
|
declare class DPadCore extends BaseEntity<DPadConfig, DPadState> implements IPointerHandler, IProgrammatic {
|
|
396
393
|
private emitters;
|
|
397
|
-
constructor(uid: string, config: DPadConfig);
|
|
394
|
+
constructor(uid: string, config: DPadConfig, customTypeName?: EntityType);
|
|
398
395
|
get activePointerId(): number | null;
|
|
399
396
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
400
397
|
onPointerMove(e: AbstractPointerEvent): void;
|
|
@@ -422,7 +419,7 @@ declare class DPadCore extends BaseEntity<DPadConfig, DPadState> implements IPoi
|
|
|
422
419
|
*/
|
|
423
420
|
declare class InputZoneCore extends BaseEntity<InputZoneConfig, InputZoneState> implements IPointerHandler, IDependencyBindable {
|
|
424
421
|
private delegates;
|
|
425
|
-
constructor(uid: string, config: InputZoneConfig);
|
|
422
|
+
constructor(uid: string, config: InputZoneConfig, customTypeName?: EntityType);
|
|
426
423
|
bindDelegate(key: string, delegate: AnyFunction): void;
|
|
427
424
|
get activePointerId(): number | null;
|
|
428
425
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
@@ -453,7 +450,7 @@ declare class JoystickCore extends BaseEntity<JoystickConfig, JoystickState> imp
|
|
|
453
450
|
private cursorEmitter;
|
|
454
451
|
private gesture;
|
|
455
452
|
private ticker;
|
|
456
|
-
constructor(uid: string, config: JoystickConfig);
|
|
453
|
+
constructor(uid: string, config: JoystickConfig, customTypeName?: EntityType);
|
|
457
454
|
get activePointerId(): number | null;
|
|
458
455
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
459
456
|
onPointerMove(e: AbstractPointerEvent): void;
|
|
@@ -489,7 +486,7 @@ declare class JoystickCore extends BaseEntity<JoystickConfig, JoystickState> imp
|
|
|
489
486
|
* identity (UID) and coordinate reference for all descendant components.
|
|
490
487
|
*/
|
|
491
488
|
declare class RootLayerCore extends BaseEntity<BaseConfig, LayerState> {
|
|
492
|
-
constructor(uid: string, config: BaseConfig);
|
|
489
|
+
constructor(uid: string, config: BaseConfig, customTypeName?: EntityType);
|
|
493
490
|
reset(): void;
|
|
494
491
|
}
|
|
495
492
|
|
|
@@ -504,7 +501,7 @@ declare class TargetZoneCore extends BaseEntity<TargetZoneConfig, CursorState> i
|
|
|
504
501
|
private focusFeedbackTimer;
|
|
505
502
|
private throttledMoveExecution;
|
|
506
503
|
private delegates;
|
|
507
|
-
constructor(uid: string, config: TargetZoneConfig);
|
|
504
|
+
constructor(uid: string, config: TargetZoneConfig, customTypeName?: EntityType);
|
|
508
505
|
bindDelegate(key: string, delegate: AnyFunction): void;
|
|
509
506
|
get activePointerId(): number | null;
|
|
510
507
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
@@ -566,7 +563,7 @@ declare class TrackpadCore extends BaseEntity<TrackpadConfig, TrackpadState> imp
|
|
|
566
563
|
* @param uid - Unique entity ID.
|
|
567
564
|
* @param config - Configuration for the trackpad.
|
|
568
565
|
*/
|
|
569
|
-
constructor(uid: string, config: TrackpadConfig);
|
|
566
|
+
constructor(uid: string, config: TrackpadConfig, customTypeName?: EntityType);
|
|
570
567
|
get activePointerId(): number | null;
|
|
571
568
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
572
569
|
onPointerMove(e: AbstractPointerEvent): void;
|
|
@@ -1115,4 +1112,4 @@ declare const OmniPad: {
|
|
|
1115
1112
|
};
|
|
1116
1113
|
};
|
|
1117
1114
|
|
|
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,
|
|
1115
|
+
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, IPointerHandler, IProgrammatic, type IRegistry, IResettable, ISignalReceiver, ISpatial, IStateful, 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
|
|
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,
|
|
1
|
+
import { I as ICoreEntity, V as Vec2, G as GamepadMappingConfig, a as ISpatial, b as IResettable, c as IConfigurable, d as IStateful, 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-CTJog5sj.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, w as CssUnit, F as FlatConfigItem, x as FlexibleLength, y as GamepadProfile, z as IIdentifiable, H as ILifecycle, K as InputActionType, L as KEYS, M as KeyMapping, N as LayoutBox, P as ParsedLength, S as StageId, O as StandardButton, Q as VALID_UNITS, W as WidgetId, R as WidgetType, Z as ZoneId, U as ZoneType } from './index-CTJog5sj.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Interface for the global Registry singleton.
|
|
@@ -332,7 +332,7 @@ declare class SimpleEmitter<T> {
|
|
|
332
332
|
* Base abstract class for all logic entities in the system.
|
|
333
333
|
* Provides fundamental identity management, state subscription, and spatial awareness.
|
|
334
334
|
*/
|
|
335
|
-
declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpatial, IResettable, IConfigurable<TConfig>,
|
|
335
|
+
declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpatial, IResettable, IConfigurable<TConfig>, IStateful<TState> {
|
|
336
336
|
readonly uid: string;
|
|
337
337
|
readonly type: EntityType;
|
|
338
338
|
protected config: TConfig;
|
|
@@ -340,22 +340,19 @@ declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpat
|
|
|
340
340
|
protected rectProvider: (() => AbstractRect) | null;
|
|
341
341
|
private _onMarkDirtyCb;
|
|
342
342
|
protected stateEmitter: SimpleEmitter<TState>;
|
|
343
|
+
protected configEmitter: SimpleEmitter<TConfig>;
|
|
343
344
|
constructor(uid: string, type: EntityType, initialConfig: TConfig, initialState: TState);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
protected setState(partialState: Partial<TState>): void;
|
|
345
|
+
getConfig(): Readonly<TConfig>;
|
|
346
|
+
subscribeConfig(cb: (config: TConfig) => void): () => void;
|
|
347
|
+
updateConfig(newConfig: Partial<TConfig>): void;
|
|
348
|
+
getState(): Readonly<TState>;
|
|
349
|
+
setState(partialState: Partial<TState>): void;
|
|
350
|
+
subscribeState(cb: (state: TState) => void): () => void;
|
|
351
351
|
destroy(): void;
|
|
352
352
|
abstract reset(): void;
|
|
353
353
|
get rect(): AbstractRect | null;
|
|
354
354
|
bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
|
|
355
355
|
markRectDirty(): void;
|
|
356
|
-
updateConfig(newConfig: Partial<TConfig>): void;
|
|
357
|
-
getState(): Readonly<TState>;
|
|
358
|
-
getConfig(): Readonly<TConfig>;
|
|
359
356
|
}
|
|
360
357
|
|
|
361
358
|
/**
|
|
@@ -370,7 +367,7 @@ declare class ButtonCore extends BaseEntity<ButtonConfig, ButtonState> implement
|
|
|
370
367
|
* @param uid - The unique entity ID.
|
|
371
368
|
* @param config - The flat configuration object for the button.
|
|
372
369
|
*/
|
|
373
|
-
constructor(uid: string, config: ButtonConfig);
|
|
370
|
+
constructor(uid: string, config: ButtonConfig, customTypeName?: EntityType);
|
|
374
371
|
get activePointerId(): number | null;
|
|
375
372
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
376
373
|
onPointerUp(e: AbstractPointerEvent): void;
|
|
@@ -394,7 +391,7 @@ declare class ButtonCore extends BaseEntity<ButtonConfig, ButtonState> implement
|
|
|
394
391
|
*/
|
|
395
392
|
declare class DPadCore extends BaseEntity<DPadConfig, DPadState> implements IPointerHandler, IProgrammatic {
|
|
396
393
|
private emitters;
|
|
397
|
-
constructor(uid: string, config: DPadConfig);
|
|
394
|
+
constructor(uid: string, config: DPadConfig, customTypeName?: EntityType);
|
|
398
395
|
get activePointerId(): number | null;
|
|
399
396
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
400
397
|
onPointerMove(e: AbstractPointerEvent): void;
|
|
@@ -422,7 +419,7 @@ declare class DPadCore extends BaseEntity<DPadConfig, DPadState> implements IPoi
|
|
|
422
419
|
*/
|
|
423
420
|
declare class InputZoneCore extends BaseEntity<InputZoneConfig, InputZoneState> implements IPointerHandler, IDependencyBindable {
|
|
424
421
|
private delegates;
|
|
425
|
-
constructor(uid: string, config: InputZoneConfig);
|
|
422
|
+
constructor(uid: string, config: InputZoneConfig, customTypeName?: EntityType);
|
|
426
423
|
bindDelegate(key: string, delegate: AnyFunction): void;
|
|
427
424
|
get activePointerId(): number | null;
|
|
428
425
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
@@ -453,7 +450,7 @@ declare class JoystickCore extends BaseEntity<JoystickConfig, JoystickState> imp
|
|
|
453
450
|
private cursorEmitter;
|
|
454
451
|
private gesture;
|
|
455
452
|
private ticker;
|
|
456
|
-
constructor(uid: string, config: JoystickConfig);
|
|
453
|
+
constructor(uid: string, config: JoystickConfig, customTypeName?: EntityType);
|
|
457
454
|
get activePointerId(): number | null;
|
|
458
455
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
459
456
|
onPointerMove(e: AbstractPointerEvent): void;
|
|
@@ -489,7 +486,7 @@ declare class JoystickCore extends BaseEntity<JoystickConfig, JoystickState> imp
|
|
|
489
486
|
* identity (UID) and coordinate reference for all descendant components.
|
|
490
487
|
*/
|
|
491
488
|
declare class RootLayerCore extends BaseEntity<BaseConfig, LayerState> {
|
|
492
|
-
constructor(uid: string, config: BaseConfig);
|
|
489
|
+
constructor(uid: string, config: BaseConfig, customTypeName?: EntityType);
|
|
493
490
|
reset(): void;
|
|
494
491
|
}
|
|
495
492
|
|
|
@@ -504,7 +501,7 @@ declare class TargetZoneCore extends BaseEntity<TargetZoneConfig, CursorState> i
|
|
|
504
501
|
private focusFeedbackTimer;
|
|
505
502
|
private throttledMoveExecution;
|
|
506
503
|
private delegates;
|
|
507
|
-
constructor(uid: string, config: TargetZoneConfig);
|
|
504
|
+
constructor(uid: string, config: TargetZoneConfig, customTypeName?: EntityType);
|
|
508
505
|
bindDelegate(key: string, delegate: AnyFunction): void;
|
|
509
506
|
get activePointerId(): number | null;
|
|
510
507
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
@@ -566,7 +563,7 @@ declare class TrackpadCore extends BaseEntity<TrackpadConfig, TrackpadState> imp
|
|
|
566
563
|
* @param uid - Unique entity ID.
|
|
567
564
|
* @param config - Configuration for the trackpad.
|
|
568
565
|
*/
|
|
569
|
-
constructor(uid: string, config: TrackpadConfig);
|
|
566
|
+
constructor(uid: string, config: TrackpadConfig, customTypeName?: EntityType);
|
|
570
567
|
get activePointerId(): number | null;
|
|
571
568
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
572
569
|
onPointerMove(e: AbstractPointerEvent): void;
|
|
@@ -1115,4 +1112,4 @@ declare const OmniPad: {
|
|
|
1115
1112
|
};
|
|
1116
1113
|
};
|
|
1117
1114
|
|
|
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,
|
|
1115
|
+
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, IPointerHandler, IProgrammatic, type IRegistry, IResettable, ISignalReceiver, ISpatial, IStateful, 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 as b$1,f,u as u$1,g,q as q$1,w as w$1,p as p$1}from'./chunk-MSERY5BP.mjs';export{b as Registry}from'./chunk-MSERY5BP.mjs';var $={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}},S=$;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"},G={PARENT_ID_KEY:"omnipad-parent-id-link"};var w=Symbol.for("omnipad.gamepad_manager.instance"),ee={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},R=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[w]||(o[w]=new a$1),o[w]}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=ee[i];if(c===void 0||!o.buttons[c])return;let d=o.buttons[c].pressed,h=this.lastButtonStates[t][c]||false;d&&!h?this.triggerVirtualEntity(r,"down"):!d&&h&&this.triggerVirtualEntity(r,"up"),this.lastButtonStates[t][c]=d;});}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,d=o.buttons[15]?.pressed?1:0,h=c+d,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$1.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 A=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):a=>setTimeout(a,16),te=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):a=>clearTimeout(a);function I(a){let o=false,e;return function(t){e=t,o||(o=true,A(()=>{a(e),o=false;}));}}function W(a){let o=null,e=()=>{a(),o=A(e);};return {start:()=>{o===null&&e();},stop:()=>{o!==null&&(te(o),o=null);}}}var X=(a=2)=>new Promise(o=>{let e=0,t=()=>{++e>=a?o():A(t);};A(t);});var M=Symbol.for("omnipad.window_manager.instance"),O=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$1.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=I(()=>{this.handleGlobalReset();});}static getInstance(){let o=globalThis;return o[M]||(o[M]=new a$1),o[M]}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$1.getInstance().resetAll(),await document.exitFullscreen()):(b$1.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 D=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 D);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$1.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 p=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(S).find(d=>d.code===i||d.key===t||d.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 X(2),this.isPressed&&this.release(o));}emitSignal(o,e={}){if(!this.targetId||!this.mapping)return;let t=b$1.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 N={isActive:false,isPressed:false,pointerId:null,value:0},K=class extends l{constructor(e,t){super(e,u.BUTTON,t,N);a(this,"emitter");this.emitter=new p(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(N),this.emitter.reset();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(e){this.setState(N),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 Z={isActive:false,pointerId:null,vector:{x:0,y:0}},q=.002,z=.3,F=class extends l{constructor(e,t){super(e,u.D_PAD,t,Z);a(this,"emitters");let i=t.targetStageId;this.emitters={up:new p(i,t.mapping?.up),down:new p(i,t.mapping?.down),left:new p(i,t.mapping?.left),right:new p(i,t.mapping?.right)};}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}}),this.processInput(e,true);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.processInput(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,d=i.width/2,h=i.height/2,f$1=(e.clientX-r)/d,P=(e.clientY-c)/h;if(t&&(f$1!=f(f$1,-1,1)||P!=f(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let C={x:f(f$1,-1,1),y:f(P,-1,1)};u$1(C,this.state.vector,q)||(this.setState({vector:C}),this.handleDigitalKeys(C));}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(Z);}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=this.config.threshold??.3;if(Math.abs(e)<i&&Math.abs(t)<i){this.state.isActive&&this.reset();return}this.state.isActive||this.setState({isActive:true});let r=g(this.state.vector.x,e,z),c=g(this.state.vector.y,t,z),d={x:r,y:c};u$1(d,this.state.vector,q)||(this.setState({vector:d}),this.handleDigitalKeys(d));}};var ie={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},Y=class extends l{constructor(e,t){super(e,u.INPUT_ZONE,t,ie);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 T=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 J={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},_=.002,j=.3,U=class extends l{constructor(e,t){super(e,u.JOYSTICK,t,J);a(this,"emitters");a(this,"stickEmitter");a(this,"cursorEmitter");a(this,"gesture");a(this,"ticker");let i=t.targetStageId,r=t.mapping||{};this.emitters={up:new p(i,r.up),down:new p(i,r.down),left:new p(i,r.left),right:new p(i,r.right)},this.stickEmitter=new p(i,r.stick),this.cursorEmitter=new p(i,{type:"mouse"}),this.gesture=new T({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=W(()=>{this.handleCursorTick();});}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),this.processInput(e,true);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.config.cursorMode&&this.ticker.start(),this.processInput(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,d=i.width/2,h=i.height/2,f$1=(e.clientX-r)/d,P=(e.clientY-c)/h;if(t&&(f$1!=f(f$1,-1,1)||P!=f(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let x=w$1({x:f$1,y:P},1,this.config.threshold||.15);u$1(x,this.state.vector,_)||(this.setState({vector:x}),this.handleDigitalKeys(x));}handleCursorTick(){let{vector:e,isActive:t}=this.state;if(!t||!this.config.cursorMode||u$1(e,{x:0,y:0},_)){this.ticker.stop();return}let i=this.config.cursorSensitivity??1,r={x:e.x*Math.abs(e.x)*i,y:e.y*Math.abs(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(J),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=this.config.threshold??.15;if(Math.hypot(e,t)<i){this.state.isActive&&this.handleRelease();return}this.state.isActive||this.setState({isActive:true});let c=g(this.state.vector.x,e,j),d=g(this.state.vector.y,t,j),h={x:c,y:d};u$1(h,this.state.vector,_)||(this.setState({vector:h}),this.handleDigitalKeys(h)),this.config.cursorMode&&this.ticker.start();}};var oe={isHighlighted:false},L=class extends l{constructor(o,e){super(o,u.ROOT_LAYER,e,oe);}reset(){}};var se={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},b=1,B=class extends l{constructor(e,t){super(e,u.TARGET_ZONE,t,se);a(this,"hideTimer",null);a(this,"focusFeedbackTimer",null);a(this,"throttledMoveExecution");a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledMoveExecution=I(i=>{this.executeMouseAction(n.POINTERMOVE,i);});}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.processPhysicalEvent(e,n.MOUSEMOVE);}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.throttledMoveExecution(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=f(i.left+p$1(r.x,i.width),i.left+b,i.left+i.width-b),d=f(i.top+p$1(r.y,i.height),i.top+b,i.top+i.height-b);this.delegates.dispatchPointerEventAtPos?.(e,c,d,{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=f(e.left+p$1(this.state.position.x,e.width),e.left+b,e.left+e.width-b),i=f(e.top+p$1(this.state.position.y,e.height),e.top+b,e.top+e.height-b);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 Q={isActive:false,isPressed:false,pointerId:null,value:0},V=class extends l{constructor(e,t){super(e,u.TRACKPAD,t,Q);a(this,"lastPointerPos",{x:0,y:0});a(this,"gesture");a(this,"emitter");let i=t.mapping||{type:"mouse"};this.emitter=new p(t.targetStageId,i),this.gesture=new T({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.processInput(e));}processInput(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),d=i/r.height*100*(this.config.sensitivity??1),h={x:c,y:d};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(Q);}};var Kt={ActionTypes:n,Context:G,Keys:S,Types:u};export{n as ACTION_TYPES,l as BaseEntity,K as ButtonCore,u as CMP_TYPES,G as CONTEXT,F as DPadCore,R as GamepadManager,Y as InputZoneCore,U as JoystickCore,S as KEYS,Kt as OmniPad,L as RootLayerCore,B as TargetZoneCore,V as TrackpadCore,O as WindowManager};
|
|
1
|
+
import {c,b,f,d as d$1,a,g,k as k$1,z as z$1,l,v,B as B$1,u}from'./chunk-ETLJK7NP.mjs';export{d as ACTION_TYPES,c as CMP_TYPES,f as CONTEXT,b as KEYS,g as Registry,e as VALID_UNITS}from'./chunk-ETLJK7NP.mjs';var R=Symbol.for("omnipad.gamepad_manager.instance"),Q={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},M=class c{constructor(){a(this,"isRunning",false);a(this,"config",null);a(this,"lastButtonStates",[]);a(this,"loop",()=>{if(!this.isRunning)return;let s=navigator.getGamepads();this.config?.forEach((t,e)=>{let i=s[e];i&&i.connected&&t&&(this.lastButtonStates[e]||(this.lastButtonStates[e]=[]),this.processButtons(i,t,e),this.processDPad(i,t),this.processAxes(i,t));}),requestAnimationFrame(this.loop);});}static getInstance(){let s=globalThis;return s[R]||(s[R]=new c),s[R]}setConfig(s){this.config=s;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",s=>{import.meta.env?.DEV&&console.log("[Omnipad-Core] Gamepad Connected:",s.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{import.meta.env?.DEV&&console.log("[Omnipad-Core] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(s,t,e){t.buttons&&Object.entries(t.buttons).forEach(([i,o])=>{let n=Q[i];if(n===void 0||!s.buttons[n])return;let l=s.buttons[n].pressed,u=this.lastButtonStates[e][n]||false;l&&!u?this.triggerVirtualEntity(o,"down"):!l&&u&&this.triggerVirtualEntity(o,"up"),this.lastButtonStates[e][n]=l;});}processDPad(s,t){let e=t?.dpad;if(!e)return;let i=s.buttons[12]?.pressed?-1:0,o=s.buttons[13]?.pressed?1:0,n=s.buttons[14]?.pressed?-1:0,l=s.buttons[15]?.pressed?1:0,u=n+l,v=i+o;this.triggerVirtualEntity(e,"vector",{x:u,y:v});}processAxes(s,t){let e=t?.deadzone??.1;if(t?.leftStick){let i=Math.abs(s.axes[0])>e?s.axes[0]:0,o=Math.abs(s.axes[1])>e?s.axes[1]:0;this.triggerVirtualEntity(t.leftStick,"vector",{x:i,y:o});}if(t?.rightStick){let i=Math.abs(s.axes[2])>e?s.axes[2]:0,o=Math.abs(s.axes[3])>e?s.axes[3]:0;this.triggerVirtualEntity(t.rightStick,"vector",{x:i,y:o});}}triggerVirtualEntity(s,t,e){let i=g.getInstance().getEntity(s);!i||i.activePointerId!=null||(t==="down"&&i.triggerDown&&i.triggerDown(),t==="up"&&i.triggerUp&&i.triggerUp(),t==="vector"&&i.triggerVector&&e&&i.triggerVector(e.x,e.y));}};var w=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):c=>setTimeout(c,16),tt=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):c=>clearTimeout(c);function D(c){let s=false,t;return function(e){t=e,s||(s=true,w(()=>{c(t),s=false;}));}}function K(c){let s=null,t=()=>{c(),s=w(t);};return {start:()=>{s===null&&t();},stop:()=>{s!==null&&(tt(s),s=null);}}}var X=(c=2)=>new Promise(s=>{let t=0,e=()=>{++t>=c?s():w(e);};w(e);});var k=Symbol.for("omnipad.window_manager.instance"),O=class c{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."),g.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=D(()=>{this.handleGlobalReset();});}static getInstance(){let s=globalThis;return s[k]||(s[k]=new c),s[k]}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(s){let t=s||document.documentElement;try{document.fullscreenElement?(g.getInstance().resetAll(),await document.exitFullscreen()):(g.getInstance().resetAll(),await t.requestFullscreen());}catch(e){console.error("[OmniPad-Core] Fullscreen toggle failed:",e);}}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 S=class{constructor(){a(this,"listeners",new Set);}subscribe(s){return this.listeners.add(s),()=>this.listeners.delete(s)}emit(s){this.listeners.forEach(t=>{try{t(s);}catch(e){console.error("[OmniPad-Core] Emitter callback error:",e);}});}clear(){this.listeners.clear();}};var d=class{constructor(s,t,e,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 S);a(this,"configEmitter",new S);this.uid=s,this.type=t,this.config=e,this.state=i;}getConfig(){return this.config}subscribeConfig(s){return s(this.config),this.configEmitter.subscribe(s)}updateConfig(s){this.config={...this.config,...s},this.configEmitter.emit(this.config);}getState(){return this.state}setState(s){this.state={...this.state,...s},this.stateEmitter.emit(this.state);}subscribeState(s){return s(this.state),this.stateEmitter.subscribe(s)}destroy(){this.reset(),this.stateEmitter.clear(),this.configEmitter.clear(),g.getInstance().unregister(this.uid);}get rect(){return this.rectProvider?this.rectProvider():null}bindRectProvider(s,t){this.rectProvider=s,t&&(this._onMarkDirtyCb=t);}markRectDirty(){this._onMarkDirtyCb?.();}};var p=class{constructor(s,t){a(this,"isPressed",false);a(this,"mapping");a(this,"targetId");this.update(s,t);}update(s,t){this.isPressed&&this.reset(),this.targetId=s,this.mapping=this.hydrate(t);}hydrate(s){if(!s)return;let t={...s};if(t.type==="mouse")return t.button=t.button??0,t;let{key:e,code:i,keyCode:o}=t;if(e||i||o){t.type="keyboard";let n=Object.values(b).find(l=>l.code===i||l.key===e||l.keyCode===o);n&&(t.key=e??n.key,t.code=i??n.code,t.keyCode=o??n.keyCode);}return t}press(){if(!this.mapping||this.isPressed)return;this.isPressed=true;let s=this.mapping.type==="keyboard"?d$1.KEYDOWN:d$1.MOUSEDOWN;this.emitSignal(s);}release(s=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let t=this.mapping.type==="keyboard"?d$1.KEYUP:d$1.MOUSEUP;this.emitSignal(t),this.mapping.type==="mouse"&&s&&this.emitSignal(d$1.CLICK);}move(s){this.mapping?.type==="mouse"&&this.emitSignal(d$1.MOUSEMOVE,s);}reset(){this.isPressed&&this.release(false);}async tap(s=true){this.isPressed||(this.press(),await X(2),this.isPressed&&this.release(s));}emitSignal(s,t={}){if(!this.targetId||!this.mapping)return;let e=g.getInstance().getEntity(this.targetId);e&&e.handleSignal({targetStageId:this.targetId,type:s,payload:{key:this.mapping.key,code:this.mapping.code,keyCode:this.mapping.keyCode,button:this.mapping.button,point:this.mapping.fixedPoint,...t}});}};var Y={isActive:false,isPressed:false,pointerId:null,value:0},V=class extends d{constructor(t,e,i){super(t,i||c.BUTTON,e,Y);a(this,"emitter");this.emitter=new p(e.targetStageId,e.mapping);}get activePointerId(){return this.state.pointerId}onPointerDown(t){this.setState({isActive:true,isPressed:true,pointerId:t.pointerId}),this.emitter.press();}onPointerUp(t){!this.state.isActive||t.pointerId!==this.state.pointerId||this.handleRelease(true);}onPointerCancel(){this.handleRelease(false);}onPointerMove(){}reset(){this.setState(Y),this.emitter.reset();}updateConfig(t){super.updateConfig(t),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(t){this.setState(Y),this.emitter.release(t);}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 Z={isActive:false,pointerId:null,vector:{x:0,y:0}},z=.002,q=.3,_=class extends d{constructor(t,e,i){super(t,i||c.D_PAD,e,Z);a(this,"emitters");let o=e.targetStageId;this.emitters={up:new p(o,e.mapping?.up),down:new p(o,e.mapping?.down),left:new p(o,e.mapping?.left),right:new p(o,e.mapping?.right)};}get activePointerId(){return this.state.pointerId}onPointerDown(t){this.setState({isActive:true,pointerId:t.pointerId,vector:{x:0,y:0}}),this.processInput(t,true);}onPointerMove(t){!this.state.isActive||t.pointerId!==this.state.pointerId||this.processInput(t);}onPointerUp(t){!this.state.isActive||t.pointerId!==this.state.pointerId||this.reset();}onPointerCancel(){this.reset();}processInput(t,e=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let o=i.left+i.width/2,n=i.top+i.height/2,l=i.width/2,u=i.height/2,v=(t.clientX-o)/l,P=(t.clientY-n)/u;if(e&&(v!=k$1(v,-1,1)||P!=k$1(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let A={x:k$1(v,-1,1),y:k$1(P,-1,1)};z$1(A,this.state.vector,z)||(this.setState({vector:A}),this.handleDigitalKeys(A));}handleDigitalKeys(t){let e=this.config.threshold??.3;t.y<-e?(this.emitters.up.press(),this.emitters.down.release()):t.y>e?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),t.x<-e?(this.emitters.left.press(),this.emitters.right.release()):t.x>e?(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(Z);}updateConfig(t){super.updateConfig(t),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(t,e){let i=this.config.threshold??.3;if(Math.abs(t)<i&&Math.abs(e)<i){this.state.isActive&&this.reset();return}this.state.isActive||this.setState({isActive:true});let o=l(this.state.vector.x,t,q),n=l(this.state.vector.y,e,q),l$1={x:o,y:n};z$1(l$1,this.state.vector,z)||(this.setState({vector:l$1}),this.handleDigitalKeys(l$1));}};var et={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},B=class extends d{constructor(t,e,i){super(t,i||c.INPUT_ZONE,e,et);a(this,"delegates",{dynamicWidgetPointerDown:()=>{},dynamicWidgetPointerMove:()=>{},dynamicWidgetPointerUp:()=>{},dynamicWidgetPointerCancel:()=>{}});}bindDelegate(t,e){Object.prototype.hasOwnProperty.call(this.delegates,t)?this.delegates[t]=e:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${t}`);}get activePointerId(){return this.state.dynamicPointerId}onPointerDown(t){if(this.state.isDynamicActive)return;let e=this.calculateRelativePosition(t.clientX,t.clientY);this.setState({isDynamicActive:true,dynamicPointerId:t.pointerId,dynamicPosition:e}),this.delegates.dynamicWidgetPointerDown?.(t);}onPointerMove(t){this.state.isDynamicActive&&this.delegates.dynamicWidgetPointerMove?.(t);}onPointerUp(t){this.delegates.dynamicWidgetPointerUp?.(t),this.reset();}onPointerCancel(t){this.delegates.dynamicWidgetPointerCancel?.(t),this.reset();}calculateRelativePosition(t,e){let i=this.rect;return i?{x:v(t-i.left,i.width),y:v(e-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 T=class{constructor(s={}){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,...s};}onPointerDown(s,t){let e=Date.now();this.startTime=e,this.startPos={x:s,y:t},this.hasMoved=false,e-this.lastTapTime<this.options.doubleTapGap?(this.isDoubleTapHolding=true,this.options.onDoubleTapHoldStart?.()):this.isDoubleTapHolding=false;}onPointerMove(s,t){this.hasMoved||Math.hypot(s-this.startPos.x,t-this.startPos.y)>this.options.tapDistance&&(this.hasMoved=true);}onPointerUp(){let s=Date.now(),t=s-this.startTime;this.isDoubleTapHolding?(this.isDoubleTapHolding=false,this.options.onDoubleTapHoldEnd?.(),this.lastTapTime=0):t<=this.options.tapTime&&!this.hasMoved&&(this.options.onTap?.(),s-this.lastTapTime<this.options.doubleTapGap?(this.options.onDoubleTap?.(),this.lastTapTime=0):this.lastTapTime=s);}reset(){this.isDoubleTapHolding&&this.options.onDoubleTapHoldEnd?.(),this.isDoubleTapHolding=false,this.hasMoved=false,this.startTime=0,this.lastTapTime=0;}};var J={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},U=.002,j=.3,H=class extends d{constructor(t,e,i){super(t,i||c.JOYSTICK,e,J);a(this,"emitters");a(this,"stickEmitter");a(this,"cursorEmitter");a(this,"gesture");a(this,"ticker");let o=e.targetStageId,n=e.mapping||{};this.emitters={up:new p(o,n.up),down:new p(o,n.down),left:new p(o,n.left),right:new p(o,n.right)},this.stickEmitter=new p(o,n.stick),this.cursorEmitter=new p(o,{type:"mouse"}),this.gesture=new T({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=K(()=>{this.handleCursorTick();});}get activePointerId(){return this.state.pointerId}onPointerDown(t){this.setState({isActive:true,pointerId:t.pointerId,vector:{x:0,y:0}}),this.gesture.onPointerDown(t.clientX,t.clientY),this.processInput(t,true);}onPointerMove(t){!this.state.isActive||t.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(t.clientX,t.clientY),this.config.cursorMode&&this.ticker.start(),this.processInput(t));}onPointerUp(t){!this.state.isActive||t.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(t=>t?.reset());}processInput(t,e=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let o=i.left+i.width/2,n=i.top+i.height/2,l=i.width/2,u=i.height/2,v=(t.clientX-o)/l,P=(t.clientY-n)/u;if(e&&(v!=k$1(v,-1,1)||P!=k$1(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let x=B$1({x:v,y:P},1,this.config.threshold||.15);z$1(x,this.state.vector,U)||(this.setState({vector:x}),this.handleDigitalKeys(x));}handleCursorTick(){let{vector:t,isActive:e}=this.state;if(!e||!this.config.cursorMode||z$1(t,{x:0,y:0},U)){this.ticker.stop();return}let i=this.config.cursorSensitivity??1,o={x:t.x*Math.abs(t.x)*i,y:t.y*Math.abs(t.y)*i};(Math.abs(o.x)>0||Math.abs(o.y)>0)&&this.cursorEmitter.move({delta:o});}handleDigitalKeys(t){let e=this.config.threshold??.3;t.y<-e?(this.emitters.up.press(),this.emitters.down.release()):t.y>e?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),t.x<-e?(this.emitters.left.press(),this.emitters.right.release()):t.x>e?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.setState(J),this.gesture.reset(),this.handleRelease(),this.stickEmitter.reset(),this.cursorEmitter.reset();}updateConfig(t){super.updateConfig(t);let e=this.config.targetStageId,i=this.config.mapping||{};this.emitters.up.update(e,i.up),this.emitters.down.update(e,i.down),this.emitters.left.update(e,i.left),this.emitters.right.update(e,i.right),this.stickEmitter.update(e,i.stick),this.cursorEmitter.update(e);}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(t,e){let i=this.config.threshold??.15;if(Math.hypot(t,e)<i){this.state.isActive&&this.handleRelease();return}this.state.isActive||this.setState({isActive:true});let n=l(this.state.vector.x,t,j),l$1=l(this.state.vector.y,e,j),u={x:n,y:l$1};z$1(u,this.state.vector,U)||(this.setState({vector:u}),this.handleDigitalKeys(u)),this.config.cursorMode&&this.ticker.start();}};var it={isHighlighted:false},F=class extends d{constructor(s,t,e){super(s,e||c.ROOT_LAYER,t,it);}reset(){}};var st={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},y=1,G=class extends d{constructor(t,e,i){super(t,i||c.TARGET_ZONE,e,st);a(this,"hideTimer",null);a(this,"focusFeedbackTimer",null);a(this,"throttledMoveExecution");a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledMoveExecution=D(o=>{this.executeMouseAction(d$1.POINTERMOVE,o);});}bindDelegate(t,e){Object.prototype.hasOwnProperty.call(this.delegates,t)?this.delegates[t]=e:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${t}`);}get activePointerId(){return null}onPointerDown(t){this.processPhysicalEvent(t,d$1.MOUSEDOWN);}onPointerMove(t){this.processPhysicalEvent(t,d$1.MOUSEMOVE);}onPointerUp(t){this.processPhysicalEvent(t,d$1.MOUSEUP),this.processPhysicalEvent(t,d$1.CLICK);}onPointerCancel(t){this.processPhysicalEvent(t,d$1.MOUSEUP);}processPhysicalEvent(t,e){let i=this.rect;if(!i)return;let o={x:v(t.clientX-i.left,i.width),y:v(t.clientY-i.top,i.height)};this.handleSignal({targetStageId:this.uid,type:e,payload:{point:o,button:t.button}});}handleSignal(t){let{type:e,payload:i}=t;switch(this.ensureFocus(),e){case d$1.KEYDOWN:case d$1.KEYUP:this.delegates.dispatchKeyboardEvent?.(e,i);break;case d$1.MOUSEMOVE:i.point?this.updateCursorPosition(i.point):i.delta&&this.updateCursorPositionByDelta(i.delta),this.config.cursorEnabled&&this.showCursor(),this.throttledMoveExecution(i);break;case d$1.MOUSEDOWN:case d$1.MOUSEUP:case d$1.CLICK:i.point&&this.updateCursorPosition(i.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(e.startsWith(d$1.MOUSE)?e.replace(d$1.MOUSE,d$1.POINTER):e,i);break}}executeMouseAction(t,e){let i=this.rect;if(!i)return;t===d$1.POINTERDOWN&&this.setState({isPointerDown:true}),t===d$1.POINTERUP&&this.setState({isPointerDown:false});let o=e.point||this.state.position,n=k$1(i.left+u(o.x,i.width),i.left+y,i.left+i.width-y),l=k$1(i.top+u(o.y,i.height),i.top+y,i.top+i.height-y);this.delegates.dispatchPointerEventAtPos?.(t,n,l,{button:e.button??0,buttons:this.state.isPointerDown?1:0,pressure:this.state.isPointerDown?.5:0});}ensureFocus(){let t=this.rect;if(!t)return;let e=k$1(t.left+u(this.state.position.x,t.width),t.left+y,t.left+t.width-y),i=k$1(t.top+u(this.state.position.y,t.height),t.top+y,t.top+t.height-y);this.delegates.reclaimFocusAtPos?.(e,i,()=>this.triggerFocusFeedback());}triggerFocusFeedback(){this.setState({isFocusReturning:true}),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.focusFeedbackTimer=setTimeout(()=>this.setState({isFocusReturning:false}),500);}updateCursorPosition(t){z$1(t,this.state.position)||this.setState({position:{...t}});}updateCursorPositionByDelta(t){if(z$1(t,{x:0,y:0}))return;let e=this.rect;if(!e)return;let i=v(t.x,e.width),o=v(t.y,e.height);this.updateCursorPosition({x:k$1(this.state.position.x+i,0,100),y:k$1(this.state.position.y+o,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(d$1.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:false,isPointerDown:false,isFocusReturning:false});}};var $={isActive:false,isPressed:false,pointerId:null,value:0},L=class extends d{constructor(t,e,i){super(t,i||c.TRACKPAD,e,$);a(this,"lastPointerPos",{x:0,y:0});a(this,"gesture");a(this,"emitter");let o=e.mapping||{type:"mouse"};this.emitter=new p(e.targetStageId,o),this.gesture=new T({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(t){this.lastPointerPos={x:t.clientX,y:t.clientY},this.gesture.onPointerDown(t.clientX,t.clientY),this.setState({isActive:true,pointerId:t.pointerId});}onPointerMove(t){!this.state.isActive||t.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(t.clientX,t.clientY),this.processInput(t));}processInput(t){if(!this.state.isActive)return;let e=t.clientX-this.lastPointerPos.x,i=t.clientY-this.lastPointerPos.y,o=this.rect;if(!o)return;let n=e/o.width*100*(this.config.sensitivity??1),l=i/o.height*100*(this.config.sensitivity??1),u={x:n,y:l};z$1(u,{x:0,y:0})||this.emitter.move({delta:u}),this.lastPointerPos={x:t.clientX,y:t.clientY};}onPointerUp(t){!this.state.isActive||t.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}reset(){this.gesture.reset(),this.emitter.reset(),this.handleRelease();}updateConfig(t){super.updateConfig(t),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(){this.setState($);}};var Ye={ActionTypes:d$1,Context:f,Keys:b,Types:c};export{d as BaseEntity,V as ButtonCore,_ as DPadCore,M as GamepadManager,B as InputZoneCore,H as JoystickCore,Ye as OmniPad,F as RootLayerCore,G as TargetZoneCore,L as TrackpadCore,O as WindowManager};
|
package/dist/utils/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkFAVAOSNA_cjs=require('../chunk-FAVAOSNA.cjs');function Z(t){let r=null,e=true;return {get:()=>((e||!r)&&(r=t(),e=false),r),markDirty:()=>{e=true;}}}function tt(t,r){let e={};return t?(Object.keys(r).forEach(i=>{let o=r[i],a=t[i];typeof o=="object"&&o!==null?JSON.stringify(o)!==JSON.stringify(a)&&(e[i]=o):o!==a&&(e[i]=o);}),e):{...r}}var v=(t,r,e="omnipad-prevent")=>{let o=document.elementsFromPoint(t,r).find(a=>!a.classList.contains(e));if(!o)return null;for(;o&&o.shadowRoot;){let d=o.shadowRoot.elementsFromPoint(t,r).find(f=>!f.classList.contains(e));if(!d||d===o)break;o=d;}return o},E=()=>{let t=document.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},M=t=>{E()!==t&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus());},nt=(t,r)=>{let e=new KeyboardEvent(t,{...r,which:r.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(e);},rt=(t,r,e,i)=>{let o=v(r,e);if(!o)return;let a={bubbles:true,cancelable:true,composed:true,clientX:r,clientY:e,view:window,...i};if(t.startsWith("pointer")){o.dispatchEvent(new PointerEvent(t,{isPrimary:true,pointerId:9999,pointerType:"mouse",...a}));let d=t.replace("pointer","mouse");o.dispatchEvent(new MouseEvent(d,a));}else o.dispatchEvent(new MouseEvent(t,a));},ot=(t,r,e)=>{let i=v(t,r);if(!i)return;E()!==i&&(M(i),e());},g,it=()=>(g!==void 0||(g=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),g),T=(t,r)=>{if(t instanceof Element)try{t.setPointerCapture(r);}catch(e){undefined?.DEV&&console.warn("[Omnipad-DOM] Failed to set pointer capture:",e);}},I=(t,r)=>{if(t instanceof Element&&t.hasPointerCapture(r))try{t.releasePointerCapture(r);}catch{}};function at(t,r={}){return {onPointerDown(e){if(!e.isTrusted||r?.requireDirectHit&&e.target!==e.currentTarget||t.activePointerId!=null)return;e.cancelable&&e.preventDefault(),e.stopPropagation();let i=e.currentTarget;i&&T(i,e.pointerId),t.onPointerDown(e);},onPointerMove(e){e.isTrusted&&(t.activePointerId!=null&&t.activePointerId!==e.pointerId||(e.cancelable&&e.preventDefault(),t.onPointerMove(e)));},onPointerUp(e){if(!e.isTrusted||t.activePointerId!=null&&t.activePointerId!==e.pointerId)return;e.cancelable&&e.preventDefault();let i=e.currentTarget;i&&I(i,e.pointerId),t.onPointerUp(e);},onPointerCancel(e){if(!e.isTrusted||t.activePointerId!=null&&t.activePointerId!==e.pointerId)return;let i=e.currentTarget;i&&I(i,e.pointerId),t.onPointerCancel(e);}}}var C=(t="omnipad")=>{let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,6);return `${t}-${r}-${e}`};function m(t){return t.startsWith("$")}function k(t){if(t==null)return {value:0,unit:"px"};if(typeof t=="number")return {value:Number.isFinite(t)?t:0,unit:"px"};let r=t.trim(),e=parseFloat(r);if(isNaN(e))return {value:0,unit:"px"};let i=r.match(/[a-z%]+$/i),o=i?i[0].toLowerCase():"px";return w({value:e,unit:o})}var w=t=>{let{value:r,unit:e}=t;return chunkFAVAOSNA_cjs.e.includes(e)?{value:r,unit:e}:(console.warn(`[Omnipad-Core] Blocked invalid CSS unit: ${e}`),{value:r,unit:"px"})},S=t=>`${t.value}${t.unit}`,gt=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 a=t[o];if(a!=null){if(typeof a=="object"&&"unit"in a){let d=w(a);r[o]=S(d);}else if(typeof a=="string"||typeof a=="number"){let d=k(a);r[o]=S(d);}}}),t.zIndex!==void 0&&(r.zIndex=t.zIndex);let i={"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=i[t.anchor]),r};function Pt(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"},e=t.items.map((o,a)=>{if(!o.id||!o.type)throw new Error(`[OmniPad-Validation] Item at index ${a} 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||{}}}),i=t.gamepadMappings;return {meta:r,items:e,gamepadMappings:i}}function yt(t){let{items:r,gamepadMappings:e}=t,i=new Map,o=(n,s="node")=>m(n)?n:(i.has(n)||i.set(n,C(s)),i.get(n));r.forEach(n=>o(n.id,n.type));let a=[];e&&e.forEach(n=>{let s={};if(n.buttons){s.buttons={};for(let[u,c]of Object.entries(n.buttons))s.buttons[u]=o(c);}n.dpad&&(s.dpad=o(n.dpad)),n.leftStick&&(s.leftStick=o(n.leftStick)),n.rightStick&&(s.rightStick=o(n.rightStick)),a.push(s);});let d=new Map,f=[];r.forEach(n=>{n.parentId?(d.has(n.parentId)||d.set(n.parentId,[]),d.get(n.parentId).push(n)):f.push(n);});let l=(n,s)=>{if(s.has(n.id))throw new Error(`[Omnipad-Core] Circular dependency detected at node: ${n.id}`);s.add(n.id);let u={...n.config};u?.targetStageId&&(u.targetStageId=o(u.targetStageId)),u?.dynamicWidgetId&&(u.dynamicWidgetId=o(u.dynamicWidgetId));let h=(d.get(n.id)||[]).map(b=>l(b,new Set(s)));return {uid:o(n.id),type:n.type,config:u,children:h}},p={};return f.forEach(n=>{p[n.id]=l(n,new Set);}),{roots:p,runtimeGamepadMappings:a}}function It(t,r,e){let i=chunkFAVAOSNA_cjs.g.getInstance(),o=[];if(!r||r.length===0)o=i.getAllEntities();else {let n=new Set;r.forEach(s=>{i.getEntitiesByRoot(s).forEach(c=>n.add(c));}),o=Array.from(n);}let a=new Map,d=0,f=n=>m(n)?n:(a.has(n)||a.set(n,`node_${++d}`),a.get(n)),l=o.map(n=>{let s=n.getConfig(),u=n.uid,c={...s};c.targetStageId&&(c.targetStageId=f(c.targetStageId)),c.dynamicWidgetId&&(c.dynamicWidgetId=f(c.dynamicWidgetId));let{id:h,parentId:b,...x}=c;return {id:f(u),type:n.type,parentId:s.parentId?f(s.parentId):void 0,config:x}}),p=[];return e&&e.forEach(n=>{let s={};if(n.buttons){s.buttons={};for(let[u,c]of Object.entries(n.buttons))a.has(c)&&(s.buttons[u]=a.get(c));}n.dpad&&a.has(n.dpad)&&(s.dpad=a.get(n.dpad)),n.leftStick&&a.has(n.leftStick)&&(s.leftStick=a.get(n.leftStick)),n.rightStick&&a.has(n.rightStick)&&(s.rightStick=a.get(n.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 chunkFAVAOSNA_cjs.i}});Object.defineProperty(exports,"applyAxialDeadzone",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.C}});Object.defineProperty(exports,"applyRadialDeadzone",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.B}});Object.defineProperty(exports,"clamp",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.k}});Object.defineProperty(exports,"clampVector",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.r}});Object.defineProperty(exports,"degToRad",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.q}});Object.defineProperty(exports,"getAngle",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.o}});Object.defineProperty(exports,"getDeadzoneScalar",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.A}});Object.defineProperty(exports,"getDistance",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.n}});Object.defineProperty(exports,"isVec2Equal",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.z}});Object.defineProperty(exports,"lerp",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.l}});Object.defineProperty(exports,"lockTo4Directions",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.t}});Object.defineProperty(exports,"lockTo8Directions",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.s}});Object.defineProperty(exports,"normalizeVec",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.w}});Object.defineProperty(exports,"percentToPx",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.u}});Object.defineProperty(exports,"pxToPercent",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.v}});Object.defineProperty(exports,"radToDeg",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.p}});Object.defineProperty(exports,"radToVec",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.x}});Object.defineProperty(exports,"remap",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.y}});Object.defineProperty(exports,"roundTo",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.m}});Object.defineProperty(exports,"scaleVec",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.j}});Object.defineProperty(exports,"subVec",{enumerable:true,get:function(){return chunkFAVAOSNA_cjs.h}});exports.createCachedProvider=Z;exports.createPointerBridge=at;exports.dispatchKeyboardEvent=nt;exports.dispatchPointerEventAtPos=rt;exports.exportProfile=It;exports.focusElement=M;exports.generateUID=C;exports.getDeepActiveElement=E;exports.getDeepElement=v;exports.getObjectDiff=tt;exports.isGlobalID=m;exports.lengthToCss=S;exports.parseLength=k;exports.parseProfileJson=Pt;exports.parseProfileTrees=yt;exports.reclaimFocusAtPos=ot;exports.resolveLayoutStyle=gt;exports.safeReleaseCapture=I;exports.safeSetCapture=T;exports.sanitizeParsedLength=w;exports.supportsContainerQueries=it;
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as IPointerHandler,
|
|
1
|
+
import { e as IPointerHandler, P as ParsedLength, N as LayoutBox, V as Vec2, v as ConfigTreeNode, G as GamepadMappingConfig, y as GamepadProfile } from '../index-CTJog5sj.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a provider wrapper that caches the result of a value-producing function.
|
|
@@ -24,6 +24,19 @@ declare function createCachedProvider<T>(provider: () => T): {
|
|
|
24
24
|
markDirty: () => void;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Compares two objects and extracts the properties that have changed.
|
|
29
|
+
*
|
|
30
|
+
* This function performs a shallow comparison of keys. For nested objects,
|
|
31
|
+
* it performs a structural check to determine if
|
|
32
|
+
* the contents have changed.
|
|
33
|
+
*
|
|
34
|
+
* @param oldObj - The previous state or snapshot of the object.
|
|
35
|
+
* @param newObj - The new state of the object to compare against the old one.
|
|
36
|
+
* @returns A partial record containing only the key-value pairs that differ from the original.
|
|
37
|
+
*/
|
|
38
|
+
declare function getObjectDiff(oldObj: any, newObj: any): Record<string, any>;
|
|
39
|
+
|
|
27
40
|
/**
|
|
28
41
|
* Recursively penetrates Shadow DOM boundaries to find the deepest element at the
|
|
29
42
|
* specified viewport coordinates.
|
|
@@ -166,6 +179,21 @@ declare const generateUID: (prefix?: string) => string;
|
|
|
166
179
|
*/
|
|
167
180
|
declare function isGlobalID(id: string): boolean;
|
|
168
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Convert the length input into a sanitized ParsedLength
|
|
184
|
+
*
|
|
185
|
+
* @param input - The raw length input.
|
|
186
|
+
* @returns A sanitized ParsedLength.
|
|
187
|
+
*/
|
|
188
|
+
declare function parseLength(input: string | number | undefined): ParsedLength;
|
|
189
|
+
/**
|
|
190
|
+
* Check the whitelist of verification units and sanitize ParsedLength.
|
|
191
|
+
*/
|
|
192
|
+
declare const sanitizeParsedLength: (parsed: ParsedLength) => ParsedLength;
|
|
193
|
+
/**
|
|
194
|
+
* Convert the ParsedLength back to a CSS string
|
|
195
|
+
*/
|
|
196
|
+
declare const lengthToCss: (parsed: ParsedLength) => string;
|
|
169
197
|
/**
|
|
170
198
|
* Converts a LayoutBox configuration into a CSS style object suitable for Vue/React.
|
|
171
199
|
*
|
|
@@ -331,4 +359,4 @@ declare function parseProfileTrees(profile: GamepadProfile): ParsedProfileForest
|
|
|
331
359
|
*/
|
|
332
360
|
declare function exportProfile(meta: GamepadProfile['meta'], rootUids?: string[], runtimeGamepadMappings?: Readonly<GamepadMappingConfig[]>): GamepadProfile;
|
|
333
361
|
|
|
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 };
|
|
362
|
+
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createCachedProvider, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, getObjectDiff, isGlobalID, isVec2Equal, lengthToCss, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseLength, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, sanitizeParsedLength, scaleVec, subVec, supportsContainerQueries };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as IPointerHandler,
|
|
1
|
+
import { e as IPointerHandler, P as ParsedLength, N as LayoutBox, V as Vec2, v as ConfigTreeNode, G as GamepadMappingConfig, y as GamepadProfile } from '../index-CTJog5sj.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a provider wrapper that caches the result of a value-producing function.
|
|
@@ -24,6 +24,19 @@ declare function createCachedProvider<T>(provider: () => T): {
|
|
|
24
24
|
markDirty: () => void;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Compares two objects and extracts the properties that have changed.
|
|
29
|
+
*
|
|
30
|
+
* This function performs a shallow comparison of keys. For nested objects,
|
|
31
|
+
* it performs a structural check to determine if
|
|
32
|
+
* the contents have changed.
|
|
33
|
+
*
|
|
34
|
+
* @param oldObj - The previous state or snapshot of the object.
|
|
35
|
+
* @param newObj - The new state of the object to compare against the old one.
|
|
36
|
+
* @returns A partial record containing only the key-value pairs that differ from the original.
|
|
37
|
+
*/
|
|
38
|
+
declare function getObjectDiff(oldObj: any, newObj: any): Record<string, any>;
|
|
39
|
+
|
|
27
40
|
/**
|
|
28
41
|
* Recursively penetrates Shadow DOM boundaries to find the deepest element at the
|
|
29
42
|
* specified viewport coordinates.
|
|
@@ -166,6 +179,21 @@ declare const generateUID: (prefix?: string) => string;
|
|
|
166
179
|
*/
|
|
167
180
|
declare function isGlobalID(id: string): boolean;
|
|
168
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Convert the length input into a sanitized ParsedLength
|
|
184
|
+
*
|
|
185
|
+
* @param input - The raw length input.
|
|
186
|
+
* @returns A sanitized ParsedLength.
|
|
187
|
+
*/
|
|
188
|
+
declare function parseLength(input: string | number | undefined): ParsedLength;
|
|
189
|
+
/**
|
|
190
|
+
* Check the whitelist of verification units and sanitize ParsedLength.
|
|
191
|
+
*/
|
|
192
|
+
declare const sanitizeParsedLength: (parsed: ParsedLength) => ParsedLength;
|
|
193
|
+
/**
|
|
194
|
+
* Convert the ParsedLength back to a CSS string
|
|
195
|
+
*/
|
|
196
|
+
declare const lengthToCss: (parsed: ParsedLength) => string;
|
|
169
197
|
/**
|
|
170
198
|
* Converts a LayoutBox configuration into a CSS style object suitable for Vue/React.
|
|
171
199
|
*
|
|
@@ -331,4 +359,4 @@ declare function parseProfileTrees(profile: GamepadProfile): ParsedProfileForest
|
|
|
331
359
|
*/
|
|
332
360
|
declare function exportProfile(meta: GamepadProfile['meta'], rootUids?: string[], runtimeGamepadMappings?: Readonly<GamepadMappingConfig[]>): GamepadProfile;
|
|
333
361
|
|
|
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 };
|
|
362
|
+
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createCachedProvider, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, getObjectDiff, isGlobalID, isVec2Equal, lengthToCss, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseLength, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, sanitizeParsedLength, scaleVec, subVec, supportsContainerQueries };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {e,g as g$1}from'../chunk-ETLJK7NP.mjs';export{i as addVec,C as applyAxialDeadzone,B as applyRadialDeadzone,k as clamp,r as clampVector,q as degToRad,o as getAngle,A as getDeadzoneScalar,n as getDistance,z as isVec2Equal,l as lerp,t as lockTo4Directions,s as lockTo8Directions,w as normalizeVec,u as percentToPx,v as pxToPercent,p as radToDeg,x as radToVec,y as remap,m as roundTo,j as scaleVec,h as subVec}from'../chunk-ETLJK7NP.mjs';function Z(t){let r=null,e=true;return {get:()=>((e||!r)&&(r=t(),e=false),r),markDirty:()=>{e=true;}}}function tt(t,r){let e={};return t?(Object.keys(r).forEach(i=>{let o=r[i],a=t[i];typeof o=="object"&&o!==null?JSON.stringify(o)!==JSON.stringify(a)&&(e[i]=o):o!==a&&(e[i]=o);}),e):{...r}}var v=(t,r,e="omnipad-prevent")=>{let o=document.elementsFromPoint(t,r).find(a=>!a.classList.contains(e));if(!o)return null;for(;o&&o.shadowRoot;){let d=o.shadowRoot.elementsFromPoint(t,r).find(f=>!f.classList.contains(e));if(!d||d===o)break;o=d;}return o},E=()=>{let t=document.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},M=t=>{E()!==t&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus());},nt=(t,r)=>{let e=new KeyboardEvent(t,{...r,which:r.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(e);},rt=(t,r,e,i)=>{let o=v(r,e);if(!o)return;let a={bubbles:true,cancelable:true,composed:true,clientX:r,clientY:e,view:window,...i};if(t.startsWith("pointer")){o.dispatchEvent(new PointerEvent(t,{isPrimary:true,pointerId:9999,pointerType:"mouse",...a}));let d=t.replace("pointer","mouse");o.dispatchEvent(new MouseEvent(d,a));}else o.dispatchEvent(new MouseEvent(t,a));},ot=(t,r,e)=>{let i=v(t,r);if(!i)return;E()!==i&&(M(i),e());},g,it=()=>(g!==void 0||(g=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),g),T=(t,r)=>{if(t instanceof Element)try{t.setPointerCapture(r);}catch(e){import.meta.env?.DEV&&console.warn("[Omnipad-DOM] Failed to set pointer capture:",e);}},I=(t,r)=>{if(t instanceof Element&&t.hasPointerCapture(r))try{t.releasePointerCapture(r);}catch{}};function at(t,r={}){return {onPointerDown(e){if(!e.isTrusted||r?.requireDirectHit&&e.target!==e.currentTarget||t.activePointerId!=null)return;e.cancelable&&e.preventDefault(),e.stopPropagation();let i=e.currentTarget;i&&T(i,e.pointerId),t.onPointerDown(e);},onPointerMove(e){e.isTrusted&&(t.activePointerId!=null&&t.activePointerId!==e.pointerId||(e.cancelable&&e.preventDefault(),t.onPointerMove(e)));},onPointerUp(e){if(!e.isTrusted||t.activePointerId!=null&&t.activePointerId!==e.pointerId)return;e.cancelable&&e.preventDefault();let i=e.currentTarget;i&&I(i,e.pointerId),t.onPointerUp(e);},onPointerCancel(e){if(!e.isTrusted||t.activePointerId!=null&&t.activePointerId!==e.pointerId)return;let i=e.currentTarget;i&&I(i,e.pointerId),t.onPointerCancel(e);}}}var C=(t="omnipad")=>{let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,6);return `${t}-${r}-${e}`};function m(t){return t.startsWith("$")}function k(t){if(t==null)return {value:0,unit:"px"};if(typeof t=="number")return {value:Number.isFinite(t)?t:0,unit:"px"};let r=t.trim(),e=parseFloat(r);if(isNaN(e))return {value:0,unit:"px"};let i=r.match(/[a-z%]+$/i),o=i?i[0].toLowerCase():"px";return w({value:e,unit:o})}var w=t=>{let{value:r,unit:e$1}=t;return e.includes(e$1)?{value:r,unit:e$1}:(console.warn(`[Omnipad-Core] Blocked invalid CSS unit: ${e$1}`),{value:r,unit:"px"})},S=t=>`${t.value}${t.unit}`,gt=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 a=t[o];if(a!=null){if(typeof a=="object"&&"unit"in a){let d=w(a);r[o]=S(d);}else if(typeof a=="string"||typeof a=="number"){let d=k(a);r[o]=S(d);}}}),t.zIndex!==void 0&&(r.zIndex=t.zIndex);let i={"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=i[t.anchor]),r};function Pt(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"},e=t.items.map((o,a)=>{if(!o.id||!o.type)throw new Error(`[OmniPad-Validation] Item at index ${a} 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||{}}}),i=t.gamepadMappings;return {meta:r,items:e,gamepadMappings:i}}function yt(t){let{items:r,gamepadMappings:e}=t,i=new Map,o=(n,s="node")=>m(n)?n:(i.has(n)||i.set(n,C(s)),i.get(n));r.forEach(n=>o(n.id,n.type));let a=[];e&&e.forEach(n=>{let s={};if(n.buttons){s.buttons={};for(let[u,c]of Object.entries(n.buttons))s.buttons[u]=o(c);}n.dpad&&(s.dpad=o(n.dpad)),n.leftStick&&(s.leftStick=o(n.leftStick)),n.rightStick&&(s.rightStick=o(n.rightStick)),a.push(s);});let d=new Map,f=[];r.forEach(n=>{n.parentId?(d.has(n.parentId)||d.set(n.parentId,[]),d.get(n.parentId).push(n)):f.push(n);});let l=(n,s)=>{if(s.has(n.id))throw new Error(`[Omnipad-Core] Circular dependency detected at node: ${n.id}`);s.add(n.id);let u={...n.config};u?.targetStageId&&(u.targetStageId=o(u.targetStageId)),u?.dynamicWidgetId&&(u.dynamicWidgetId=o(u.dynamicWidgetId));let h=(d.get(n.id)||[]).map(b=>l(b,new Set(s)));return {uid:o(n.id),type:n.type,config:u,children:h}},p={};return f.forEach(n=>{p[n.id]=l(n,new Set);}),{roots:p,runtimeGamepadMappings:a}}function It(t,r,e){let i=g$1.getInstance(),o=[];if(!r||r.length===0)o=i.getAllEntities();else {let n=new Set;r.forEach(s=>{i.getEntitiesByRoot(s).forEach(c=>n.add(c));}),o=Array.from(n);}let a=new Map,d=0,f=n=>m(n)?n:(a.has(n)||a.set(n,`node_${++d}`),a.get(n)),l=o.map(n=>{let s=n.getConfig(),u=n.uid,c={...s};c.targetStageId&&(c.targetStageId=f(c.targetStageId)),c.dynamicWidgetId&&(c.dynamicWidgetId=f(c.dynamicWidgetId));let{id:h,parentId:b,...x}=c;return {id:f(u),type:n.type,parentId:s.parentId?f(s.parentId):void 0,config:x}}),p=[];return e&&e.forEach(n=>{let s={};if(n.buttons){s.buttons={};for(let[u,c]of Object.entries(n.buttons))a.has(c)&&(s.buttons[u]=a.get(c));}n.dpad&&a.has(n.dpad)&&(s.dpad=a.get(n.dpad)),n.leftStick&&a.has(n.leftStick)&&(s.leftStick=a.get(n.leftStick)),n.rightStick&&a.has(n.rightStick)&&(s.rightStick=a.get(n.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{Z as createCachedProvider,at as createPointerBridge,nt as dispatchKeyboardEvent,rt as dispatchPointerEventAtPos,It as exportProfile,M as focusElement,C as generateUID,E as getDeepActiveElement,v as getDeepElement,tt as getObjectDiff,m as isGlobalID,S as lengthToCss,k as parseLength,Pt as parseProfileJson,yt as parseProfileTrees,ot as reclaimFocusAtPos,gt as resolveLayoutStyle,I as safeReleaseCapture,T as safeSetCapture,w as sanitizeParsedLength,it as supportsContainerQueries};
|
package/package.json
CHANGED
package/dist/chunk-MSERY5BP.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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};
|
package/dist/chunk-PAGWIRTX.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;
|