@omnipad/core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/chunk-42WBUPM3.cjs +1 -0
  2. package/dist/chunk-45F3BQT7.cjs +1 -0
  3. package/dist/chunk-52YF3VHH.cjs +1 -0
  4. package/dist/chunk-6XY2ZHZ3.mjs +1 -0
  5. package/dist/chunk-AK3RL7NL.mjs +1 -0
  6. package/dist/chunk-EYKCVOUA.mjs +1 -0
  7. package/dist/chunk-HCOFKHVV.cjs +1 -0
  8. package/dist/chunk-HQNUZXP5.mjs +1 -0
  9. package/dist/chunk-J5SVBM6K.mjs +1 -0
  10. package/dist/chunk-NB4FTDOP.cjs +1 -0
  11. package/dist/chunk-OVV5DKL6.cjs +1 -0
  12. package/dist/chunk-YAS6LFBF.mjs +1 -0
  13. package/dist/dom/index.cjs +1 -1
  14. package/dist/dom/index.d.cts +105 -36
  15. package/dist/dom/index.d.ts +105 -36
  16. package/dist/dom/index.mjs +1 -1
  17. package/dist/guest/index.cjs +1 -0
  18. package/dist/guest/index.d.cts +21 -0
  19. package/dist/guest/index.d.ts +21 -0
  20. package/dist/guest/index.mjs +1 -0
  21. package/dist/{index-DVegtw8s.d.cts → index-Dd0aHJaA.d.cts} +739 -27
  22. package/dist/{index-DVegtw8s.d.ts → index-Dd0aHJaA.d.ts} +739 -27
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.cts +282 -5
  25. package/dist/index.d.ts +282 -5
  26. package/dist/index.mjs +1 -1
  27. package/dist/sticky-CCj0ECTY.d.cts +285 -0
  28. package/dist/sticky-d_z_GU83.d.ts +285 -0
  29. package/dist/utils/index.cjs +1 -1
  30. package/dist/utils/index.d.cts +122 -69
  31. package/dist/utils/index.d.ts +122 -69
  32. package/dist/utils/index.mjs +1 -1
  33. package/package.json +9 -1
  34. package/dist/chunk-FSJTQU4W.cjs +0 -1
  35. package/dist/chunk-MKVX5ALC.mjs +0 -1
  36. package/dist/chunk-PACTGVBB.mjs +0 -1
  37. package/dist/chunk-U52W5J3K.cjs +0 -1
  38. package/dist/chunk-V7AHGFPB.mjs +0 -1
  39. package/dist/chunk-VHF3K5X6.cjs +0 -1
  40. package/dist/chunk-ZHPNS73J.cjs +0 -1
  41. package/dist/chunk-ZM2LX5IW.mjs +0 -1
  42. package/dist/sticky-4yk5DLzG.d.cts +0 -59
  43. package/dist/sticky-CLBq1EPa.d.ts +0 -59
  44. package/dist/traits-D6ePqSA6.d.cts +0 -152
  45. package/dist/traits-dAndzyWS.d.ts +0 -152
@@ -1 +0,0 @@
1
- 'use strict';var chunkZHPNS73J_cjs=require('./chunk-ZHPNS73J.cjs');function x(t){let e=null,n=true;return {get:()=>((n||!e)&&(e=t(),n=false),e),markDirty:()=>{n=true;}}}var C=/^[a-zA-Z0-9\s._#$\-*>+~]+$/,y=Object.freeze(["script","onerror","eval","onload","javascript"]);function L(t,e=""){if(!t)return e;let n=t.trim();return n.length>256?e:C.test(n)?y.some(i=>n.toLowerCase().includes(i))?e:n:(undefined?.DEV&&console.warn(`[OmniPad-Core] Unsafe DOM string blocked: "${n}"`),e)}var P=/^[a-zA-Z0-9\-_]+$/;function A(t){return t?t.split(/\s+/).filter(e=>P.test(e)).join(" "):""}function r(t){if(t==null)return;if(typeof t=="object"&&"unit"in t&&"value"in t)return v(t);if(typeof t=="number")return {value:Number.isFinite(t)?t:0,unit:"px"};let e=t.trim().toLowerCase(),n=parseFloat(e);if(isNaN(n))return {value:0,unit:"px"};let i=e.slice(String(n).length).trim();return v({value:n,unit:i})}var v=t=>{let{value:e,unit:n}=t;return !isNaN(e)&&chunkZHPNS73J_cjs.e.includes(n)?{value:e,unit:n}:(console.warn(`[OmniPad-Core] Blocked invalid CSS unit: ${n}`),{value:isNaN(e)?0:e,unit:"px"})},a=t=>t==null?void 0:`${t.value}${t.unit}`;function I(t){return {...t,left:r(t.left),top:r(t.top),right:r(t.right),bottom:r(t.bottom),width:r(t.width),height:r(t.height),stickySelector:L(t.stickySelector)}}function j(t){return {...t,left:a(t.left),top:a(t.top),right:a(t.right),bottom:a(t.bottom),width:a(t.width),height:a(t.height)}}var w=t=>{if(Object.keys(t??{}).length===0)return {};let e={};e.position=t.stickySelector?"fixed":"absolute",t.isSquare&&(e.aspectRatio="1/1"),["left","top","right","bottom","width","height"].forEach(l=>{let o=t[l];if(o!=null){let h=r(o);h!=null&&(e[l]=a(h));}}),t.zIndex!==void 0&&(e.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&&(e.transform=i[t.anchor]),e};var T=class{constructor(e,n,i,l){this.finder=n;this.rectProvider=i;this.presenceChecker=l;chunkZHPNS73J_cjs.a(this,"_selector");chunkZHPNS73J_cjs.a(this,"_cachedTarget",null);chunkZHPNS73J_cjs.a(this,"_rectCache");this._selector=e,this._rectCache=x(()=>{let o=this.getTarget();return o?this.rectProvider(o):null});}getTarget(){return this._cachedTarget&&this.presenceChecker(this._cachedTarget)?this._cachedTarget:(this._cachedTarget=this.finder(this._selector),this._cachedTarget)}getRect(){return this._rectCache.get()}markDirty(){this._rectCache.markDirty();}updateSelector(e){return this._selector===e?false:(this._selector=e,this._cachedTarget=null,this.markDirty(),true)}};function W(t,e){let n=t.left!==void 0?r(t.left):null,i=t.right!==void 0?r(t.right):null,l=t.top!==void 0?r(t.top):null,o=t.bottom!==void 0?r(t.bottom):null,h=t.width!==void 0?r(t.width):null,f=t.height!==void 0?r(t.height):null,s=(d,_)=>d?d.unit==="%"?d.value/100*_:d.value:0,g,u;n!==null&&i!==null&&h===null?(u=e.left+s(n,e.width),g=e.right-s(i,e.width)-u):(g=h?s(h,e.width):0,n!==null?u=e.left+s(n,e.width):i!==null?u=e.right-s(i,e.width)-g:u=e.left);let p,c;return l!==null&&o!==null&&f===null?(c=e.top+s(l,e.height),p=e.bottom-s(o,e.height)-c):(p=f?s(f,e.height):0,l!==null?c=e.top+s(l,e.height):o!==null?c=e.bottom-s(o,e.height)-p:c=e.top),{...t,left:`${u}px`,top:`${c}px`,width:h||n&&i?`${g}px`:t.width,height:f||l&&o?`${p}px`:t.height,right:void 0,bottom:void 0}}exports.a=x;exports.b=y;exports.c=L;exports.d=A;exports.e=r;exports.f=v;exports.g=a;exports.h=I;exports.i=j;exports.j=w;exports.k=T;exports.l=W;
@@ -1 +0,0 @@
1
- import {e,a as a$1}from'./chunk-PACTGVBB.mjs';function x(t){let e=null,n=true;return {get:()=>((n||!e)&&(e=t(),n=false),e),markDirty:()=>{n=true;}}}var C=/^[a-zA-Z0-9\s._#$\-*>+~]+$/,y=Object.freeze(["script","onerror","eval","onload","javascript"]);function L(t,e=""){if(!t)return e;let n=t.trim();return n.length>256?e:C.test(n)?y.some(i=>n.toLowerCase().includes(i))?e:n:(import.meta.env?.DEV&&console.warn(`[OmniPad-Core] Unsafe DOM string blocked: "${n}"`),e)}var P=/^[a-zA-Z0-9\-_]+$/;function A(t){return t?t.split(/\s+/).filter(e=>P.test(e)).join(" "):""}function r(t){if(t==null)return;if(typeof t=="object"&&"unit"in t&&"value"in t)return v(t);if(typeof t=="number")return {value:Number.isFinite(t)?t:0,unit:"px"};let e=t.trim().toLowerCase(),n=parseFloat(e);if(isNaN(n))return {value:0,unit:"px"};let i=e.slice(String(n).length).trim();return v({value:n,unit:i})}var v=t=>{let{value:e$1,unit:n}=t;return !isNaN(e$1)&&e.includes(n)?{value:e$1,unit:n}:(console.warn(`[OmniPad-Core] Blocked invalid CSS unit: ${n}`),{value:isNaN(e$1)?0:e$1,unit:"px"})},a=t=>t==null?void 0:`${t.value}${t.unit}`;function I(t){return {...t,left:r(t.left),top:r(t.top),right:r(t.right),bottom:r(t.bottom),width:r(t.width),height:r(t.height),stickySelector:L(t.stickySelector)}}function j(t){return {...t,left:a(t.left),top:a(t.top),right:a(t.right),bottom:a(t.bottom),width:a(t.width),height:a(t.height)}}var w=t=>{if(Object.keys(t??{}).length===0)return {};let e={};e.position=t.stickySelector?"fixed":"absolute",t.isSquare&&(e.aspectRatio="1/1"),["left","top","right","bottom","width","height"].forEach(l=>{let o=t[l];if(o!=null){let h=r(o);h!=null&&(e[l]=a(h));}}),t.zIndex!==void 0&&(e.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&&(e.transform=i[t.anchor]),e};var T=class{constructor(e,n,i,l){this.finder=n;this.rectProvider=i;this.presenceChecker=l;a$1(this,"_selector");a$1(this,"_cachedTarget",null);a$1(this,"_rectCache");this._selector=e,this._rectCache=x(()=>{let o=this.getTarget();return o?this.rectProvider(o):null});}getTarget(){return this._cachedTarget&&this.presenceChecker(this._cachedTarget)?this._cachedTarget:(this._cachedTarget=this.finder(this._selector),this._cachedTarget)}getRect(){return this._rectCache.get()}markDirty(){this._rectCache.markDirty();}updateSelector(e){return this._selector===e?false:(this._selector=e,this._cachedTarget=null,this.markDirty(),true)}};function W(t,e){let n=t.left!==void 0?r(t.left):null,i=t.right!==void 0?r(t.right):null,l=t.top!==void 0?r(t.top):null,o=t.bottom!==void 0?r(t.bottom):null,h=t.width!==void 0?r(t.width):null,f=t.height!==void 0?r(t.height):null,s=(d,_)=>d?d.unit==="%"?d.value/100*_:d.value:0,g,u;n!==null&&i!==null&&h===null?(u=e.left+s(n,e.width),g=e.right-s(i,e.width)-u):(g=h?s(h,e.width):0,n!==null?u=e.left+s(n,e.width):i!==null?u=e.right-s(i,e.width)-g:u=e.left);let p,c;return l!==null&&o!==null&&f===null?(c=e.top+s(l,e.height),p=e.bottom-s(o,e.height)-c):(p=f?s(f,e.height):0,l!==null?c=e.top+s(l,e.height):o!==null?c=e.bottom-s(o,e.height)-p:c=e.top),{...t,left:`${u}px`,top:`${c}px`,width:h||n&&i?`${g}px`:t.width,height:f||l&&o?`${p}px`:t.height,right:void 0,bottom:void 0}}export{x as a,y as b,L as c,A as d,r as e,v as f,a as g,I as h,j as i,w as j,T as k,W as l};
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var m=(t,e,o)=>e in t?l(t,e,{enumerable:true,configurable:true,writable:true,value:o}):t[e]=o;var C=(t,e,o)=>m(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}},T=f;var P={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"},S={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},A=["px","%","vh","vw","rem","em"],N={PARENT_ID_KEY:"omnipad-parent-id-link"};var a=Symbol.for("omnipad.registry.instance"),p=null;function F(t){p=t;}var u=class t{constructor(){C(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 y=new Map;o.forEach(d=>{let n=d;if(typeof n.getConfig=="function"){let i=n.getConfig();i.parentId&&(y.has(i.parentId)||y.set(i.parentId,[]),y.get(i.parentId).push(d));}});let c=[],k=[e],s=new Set;for(;k.length>0;){let d=k.shift();if(s.has(d))continue;s.add(d);let n=this.entities.get(d);if(n){c.push(n);let i=y.get(d);i&&i.forEach(g=>k.push(g.uid));}}return c}destroyByRoot(e){let o=this.getEntitiesByRoot(e);for(let r=o.length-1;r>=0;r--){let y=o[r];try{y.destroy();}catch(c){console.error(`[OmniPad-Core] Error during destroyByRoot at ${y.uid}:`,c);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(e=>{"reset"in e&&e.reset();});}markAllRectDirty(){this.entities.forEach(e=>{"markRectDirty"in e&&e.markRectDirty();});}broadcastSignal(e){let o=this.getEntity(e.targetStageId);o&&"handleSignal"in o?o.handleSignal(e):p&&p(e);}};export{C as a,T as b,P as c,S as d,A as e,N as f,F as g,u as h};
@@ -1 +0,0 @@
1
- 'use strict';var y=(e,n)=>({x:e.x-n.x,y:e.y-n.y}),p=(e,n)=>({x:e.x+n.x,y:e.y+n.y}),b=(e,n)=>({x:e.x*n,y:e.y*n}),a=(e,n,r)=>Math.max(n,Math.min(r,e)),s=(e,n,r)=>e+(n-e)*r,m=(e,n=2)=>{let r=Math.pow(10,n);return Math.round(e*r)/r},V=(e,n)=>Math.hypot(n.x-e.x,n.y-e.y),h=(e,n)=>Math.atan2(n.y-e.y,n.x-e.x),M=e=>e*180/Math.PI,d=e=>e*Math.PI/180,l=(e,n,r)=>{let t=n.x-e.x,c=n.y-e.y;if(Math.hypot(t,c)<=r)return n;let u=Math.atan2(c,t);return {x:e.x+Math.cos(u)*r,y:e.y+Math.sin(u)*r}},i=e=>{let n=Math.PI/4;return Math.round(e/n)*n},T=e=>{let n=Math.PI/2;return Math.round(e/n)*n},D=(e,n)=>m(e*n/100),f=(e,n)=>n===0?0:m(e*100/n),g=e=>{let n=Math.hypot(e.x,e.y);return n===0?{x:0,y:0}:{x:e.x/n,y:e.y/n}},P=e=>({x:Math.cos(e),y:Math.sin(e)}),z=(e,n,r,t,c)=>{let o=(e-n)/(r-n);return s(t,c,a(o,0,1))},I=(e,n,r=1e-4)=>Math.abs(e.x-n.x)<r&&Math.abs(e.y-n.y)<r,x=(e,n,r)=>{if(e<n)return 0;let t=(e-n)/(r-n);return a(t,0,1)},k=(e,n,r)=>{let t=Math.hypot(e.x,e.y),c=n*r,o=x(t,c,n);if(o===0)return {x:0,y:0};let u={x:e.x/t,y:e.y/t};return b(u,o)},A=(e,n,r)=>({x:x(Math.abs(e.x),n,r)*Math.sign(e.x),y:x(Math.abs(e.y),n,r)*Math.sign(e.y)});exports.a=y;exports.b=p;exports.c=b;exports.d=a;exports.e=s;exports.f=m;exports.g=V;exports.h=h;exports.i=M;exports.j=d;exports.k=l;exports.l=i;exports.m=T;exports.n=D;exports.o=f;exports.p=g;exports.q=P;exports.r=z;exports.s=I;exports.t=x;exports.u=k;exports.v=A;
@@ -1 +0,0 @@
1
- var y=(e,n)=>({x:e.x-n.x,y:e.y-n.y}),p=(e,n)=>({x:e.x+n.x,y:e.y+n.y}),b=(e,n)=>({x:e.x*n,y:e.y*n}),a=(e,n,r)=>Math.max(n,Math.min(r,e)),s=(e,n,r)=>e+(n-e)*r,m=(e,n=2)=>{let r=Math.pow(10,n);return Math.round(e*r)/r},V=(e,n)=>Math.hypot(n.x-e.x,n.y-e.y),h=(e,n)=>Math.atan2(n.y-e.y,n.x-e.x),M=e=>e*180/Math.PI,d=e=>e*Math.PI/180,l=(e,n,r)=>{let t=n.x-e.x,c=n.y-e.y;if(Math.hypot(t,c)<=r)return n;let u=Math.atan2(c,t);return {x:e.x+Math.cos(u)*r,y:e.y+Math.sin(u)*r}},i=e=>{let n=Math.PI/4;return Math.round(e/n)*n},T=e=>{let n=Math.PI/2;return Math.round(e/n)*n},D=(e,n)=>m(e*n/100),f=(e,n)=>n===0?0:m(e*100/n),g=e=>{let n=Math.hypot(e.x,e.y);return n===0?{x:0,y:0}:{x:e.x/n,y:e.y/n}},P=e=>({x:Math.cos(e),y:Math.sin(e)}),z=(e,n,r,t,c)=>{let o=(e-n)/(r-n);return s(t,c,a(o,0,1))},I=(e,n,r=1e-4)=>Math.abs(e.x-n.x)<r&&Math.abs(e.y-n.y)<r,x=(e,n,r)=>{if(e<n)return 0;let t=(e-n)/(r-n);return a(t,0,1)},k=(e,n,r)=>{let t=Math.hypot(e.x,e.y),c=n*r,o=x(t,c,n);if(o===0)return {x:0,y:0};let u={x:e.x/t,y:e.y/t};return b(u,o)},A=(e,n,r)=>({x:x(Math.abs(e.x),n,r)*Math.sign(e.x),y:x(Math.abs(e.y),n,r)*Math.sign(e.y)});export{y as a,p as b,b as c,a as d,s as e,m as f,V as g,h,M as i,d as j,l as k,i as l,T as m,D as n,f as o,g as p,P as q,z as r,I as s,x as t,k as u,A as v};
@@ -1 +0,0 @@
1
- 'use strict';var l=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):n=>setTimeout(n,16),i=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):n=>clearTimeout(n);function a(n){let e=false,t;return function(o){t=o,e||(e=true,l(()=>{n(t),e=false;}));}}function r(n){let e=null,t=()=>{n(),e=l(t);};return {start:()=>{e===null&&t();},stop:()=>{e!==null&&(i(e),e=null);}}}var s=(n=2)=>new Promise(e=>{let t=0,o=()=>{++t>=n?e():l(o);};l(o);});exports.a=a;exports.b=r;exports.c=s;
@@ -1 +0,0 @@
1
- 'use strict';var l=Object.defineProperty;var m=(t,e,o)=>e in t?l(t,e,{enumerable:true,configurable:true,writable:true,value:o}):t[e]=o;var C=(t,e,o)=>m(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}},T=f;var P={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"},S={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},A=["px","%","vh","vw","rem","em"],N={PARENT_ID_KEY:"omnipad-parent-id-link"};var a=Symbol.for("omnipad.registry.instance"),p=null;function F(t){p=t;}var u=class t{constructor(){C(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 y=new Map;o.forEach(d=>{let n=d;if(typeof n.getConfig=="function"){let i=n.getConfig();i.parentId&&(y.has(i.parentId)||y.set(i.parentId,[]),y.get(i.parentId).push(d));}});let c=[],k=[e],s=new Set;for(;k.length>0;){let d=k.shift();if(s.has(d))continue;s.add(d);let n=this.entities.get(d);if(n){c.push(n);let i=y.get(d);i&&i.forEach(g=>k.push(g.uid));}}return c}destroyByRoot(e){let o=this.getEntitiesByRoot(e);for(let r=o.length-1;r>=0;r--){let y=o[r];try{y.destroy();}catch(c){console.error(`[OmniPad-Core] Error during destroyByRoot at ${y.uid}:`,c);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(e=>{"reset"in e&&e.reset();});}markAllRectDirty(){this.entities.forEach(e=>{"markRectDirty"in e&&e.markRectDirty();});}broadcastSignal(e){let o=this.getEntity(e.targetStageId);o&&"handleSignal"in o?o.handleSignal(e):p&&p(e);}};exports.a=C;exports.b=T;exports.c=P;exports.d=S;exports.e=A;exports.f=N;exports.g=F;exports.h=u;
@@ -1 +0,0 @@
1
- var l=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):n=>setTimeout(n,16),i=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):n=>clearTimeout(n);function a(n){let e=false,t;return function(o){t=o,e||(e=true,l(()=>{n(t),e=false;}));}}function r(n){let e=null,t=()=>{n(),e=l(t);};return {start:()=>{e===null&&t();},stop:()=>{e!==null&&(i(e),e=null);}}}var s=(n=2)=>new Promise(e=>{let t=0,o=()=>{++t>=n?e():l(o);};l(o);});export{a,r as b,s as c};
@@ -1,59 +0,0 @@
1
- import { A as AbstractRect, L as LayoutBox } from './index-DVegtw8s.cjs';
2
-
3
- /**
4
- * Headless Sticky Provider.
5
- * Manages reference coordinate tracking without direct DOM dependency.
6
- *
7
- * It relies on an externally injected 'finder' function to resolve
8
- * the reference object and a 'rectProvider' to get its dimensions.
9
- */
10
- declare class StickyProvider {
11
- private finder;
12
- private rectProvider;
13
- private presenceChecker;
14
- private _selector;
15
- private _cachedTarget;
16
- private _rectCache;
17
- /**
18
- * @param selector - The selector (e.g. selector) of the reference.
19
- * @param finder - A function that resolves the selector to a physical object.
20
- * @param rectProvider - A function that returns the bounds of the resolved object.
21
- * @param presenceChecker - A function to check if the target is still valid/attached.
22
- */
23
- constructor(selector: string, finder: (id: string) => any, rectProvider: (target: any) => AbstractRect | null, presenceChecker: (target: any) => boolean);
24
- /**
25
- * Resolves and returns the target object.
26
- */
27
- getTarget(): any | null;
28
- /**
29
- * Returns the current Rect of the sticky target.
30
- * Uses internal cache to prevent layout thrashing.
31
- */
32
- getRect(): AbstractRect | null;
33
- /**
34
- * Invalidates the current Rect cache.
35
- * Should be called during window resize, scroll, or manual re-alignments.
36
- */
37
- markDirty(): void;
38
- /**
39
- * Updates the selector and clears the current element cache.
40
- *
41
- * @param newSelector - The new CSS selector.
42
- * @returns Whether the selector is updated.
43
- */
44
- updateSelector(newSelector: string): boolean;
45
- }
46
- /**
47
- * Resolves a relative "Sticky" layout into absolute viewport coordinates.
48
- *
49
- * This function calculates the exact pixel positions required for `fixed` CSS positioning
50
- * by mapping a relative `LayoutBox` (which may use percentages or offsets) onto the
51
- * physical coordinate system of a target reference element (e.g., a game canvas).
52
- *
53
- * @param layout - The relative layout configuration containing sticky instructions.
54
- * @param targetRect - The current physical bounding box of the reference element.
55
- * @returns A new LayoutBox with all dimensions resolved to absolute pixel strings.
56
- */
57
- declare function resolveStickyLayout(layout: LayoutBox, targetRect: AbstractRect): LayoutBox;
58
-
59
- export { StickyProvider as S, resolveStickyLayout as r };
@@ -1,59 +0,0 @@
1
- import { A as AbstractRect, L as LayoutBox } from './index-DVegtw8s.js';
2
-
3
- /**
4
- * Headless Sticky Provider.
5
- * Manages reference coordinate tracking without direct DOM dependency.
6
- *
7
- * It relies on an externally injected 'finder' function to resolve
8
- * the reference object and a 'rectProvider' to get its dimensions.
9
- */
10
- declare class StickyProvider {
11
- private finder;
12
- private rectProvider;
13
- private presenceChecker;
14
- private _selector;
15
- private _cachedTarget;
16
- private _rectCache;
17
- /**
18
- * @param selector - The selector (e.g. selector) of the reference.
19
- * @param finder - A function that resolves the selector to a physical object.
20
- * @param rectProvider - A function that returns the bounds of the resolved object.
21
- * @param presenceChecker - A function to check if the target is still valid/attached.
22
- */
23
- constructor(selector: string, finder: (id: string) => any, rectProvider: (target: any) => AbstractRect | null, presenceChecker: (target: any) => boolean);
24
- /**
25
- * Resolves and returns the target object.
26
- */
27
- getTarget(): any | null;
28
- /**
29
- * Returns the current Rect of the sticky target.
30
- * Uses internal cache to prevent layout thrashing.
31
- */
32
- getRect(): AbstractRect | null;
33
- /**
34
- * Invalidates the current Rect cache.
35
- * Should be called during window resize, scroll, or manual re-alignments.
36
- */
37
- markDirty(): void;
38
- /**
39
- * Updates the selector and clears the current element cache.
40
- *
41
- * @param newSelector - The new CSS selector.
42
- * @returns Whether the selector is updated.
43
- */
44
- updateSelector(newSelector: string): boolean;
45
- }
46
- /**
47
- * Resolves a relative "Sticky" layout into absolute viewport coordinates.
48
- *
49
- * This function calculates the exact pixel positions required for `fixed` CSS positioning
50
- * by mapping a relative `LayoutBox` (which may use percentages or offsets) onto the
51
- * physical coordinate system of a target reference element (e.g., a game canvas).
52
- *
53
- * @param layout - The relative layout configuration containing sticky instructions.
54
- * @param targetRect - The current physical bounding box of the reference element.
55
- * @returns A new LayoutBox with all dimensions resolved to absolute pixel strings.
56
- */
57
- declare function resolveStickyLayout(layout: LayoutBox, targetRect: AbstractRect): LayoutBox;
58
-
59
- export { StickyProvider as S, resolveStickyLayout as r };
@@ -1,152 +0,0 @@
1
- import { E as EntityType, A as AbstractRect, a as AbstractPointerEvent, c as AnyFunction, I as InputActionSignal } from './index-DVegtw8s.cjs';
2
-
3
- /**
4
- * Trait: Provides identity with a unique ID and specific entity type.
5
- */
6
- interface IIdentifiable {
7
- readonly uid: string;
8
- readonly type: EntityType;
9
- }
10
- /**
11
- * Trait: Provides lifecycle management hooks.
12
- */
13
- interface ILifecycle {
14
- /**
15
- * Performs cleanup, unregisters the entity, and releases resources.
16
- */
17
- destroy(): void;
18
- }
19
- /**
20
- * The core contract for any object that can be managed by the Registry.
21
- * Only objects implementing this interface are eligible for registration.
22
- */
23
- interface ICoreEntity extends IIdentifiable, ILifecycle {
24
- }
25
- /**
26
- * Trait: Enables spatial awareness for DOM/UI-related components.
27
- */
28
- interface ISpatial {
29
- readonly rect: AbstractRect | null;
30
- /**
31
- * Dynamically obtain dimensions and position to ensure the most precise real-time screen coordinates are obtained during each interaction.
32
- */
33
- bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
34
- /**
35
- * Trigger a cache invalidation.
36
- */
37
- markRectDirty(): void;
38
- }
39
- /**
40
- * Trait: Provides configuration management.
41
- */
42
- interface IConfigurable<TConfig> {
43
- /**
44
- * Retrieves a snapshot of the current configuration.
45
- */
46
- getConfig(): TConfig;
47
- /**
48
- * Subscribes to config changes.
49
- * @param cb - Callback function triggered on config updates.
50
- * @returns An unsubscribe function.
51
- */
52
- subscribeConfig(cb: (config: TConfig) => void): () => void;
53
- /**
54
- * Updates the internal config and notifies all subscribers.
55
- * @param config - Partial configuration object to merge.
56
- */
57
- updateConfig(config: Partial<TConfig>): void;
58
- }
59
- /**
60
- * Trait: Provides state management.
61
- */
62
- interface IStateful<TState> {
63
- /**
64
- * Retrieves the current state snapshot.
65
- */
66
- getState(): TState;
67
- /**
68
- * Subscribes to state changes.
69
- * @param cb - Callback function triggered on state updates.
70
- * @returns An unsubscribe function.
71
- */
72
- subscribeState(cb: (state: TState) => void): () => void;
73
- /**
74
- * Updates the internal state and notifies all subscribers.
75
- * @param state - Partial object containing updated state values.
76
- */
77
- setState(state: Partial<TState>): void;
78
- }
79
- /**
80
- * Trait: Allows resetting the entity to its idle/safe state.
81
- */
82
- interface IResettable {
83
- /**
84
- * Forcefully clears active states and cuts off outgoing signals.
85
- */
86
- reset(): void;
87
- }
88
- /**
89
- * Trait: Handles raw pointer input (Touch/Mouse).
90
- */
91
- interface IPointerHandler {
92
- readonly activePointerId: number | null;
93
- onPointerDown(e: AbstractPointerEvent): void;
94
- onPointerMove(e: AbstractPointerEvent): void;
95
- onPointerUp(e: AbstractPointerEvent): void;
96
- onPointerCancel(e: AbstractPointerEvent): void;
97
- }
98
- /**
99
- * Trait: Receives and processes input signals (e.g., TargetZone).
100
- */
101
- interface ISignalReceiver {
102
- /**
103
- * Handles incoming signals from widgets.
104
- * @param signal - The signal data containing action type and payload.
105
- */
106
- handleSignal(signal: InputActionSignal): void;
107
- }
108
- /**
109
- * Capability for an entity to receive and store external functional dependencies.
110
- *
111
- * This enables Runtime Dependency Injection (DI), allowing core logic to invoke
112
- * host-specific methods (such as DOM event dispatchers or custom triggers)
113
- * without being tightly coupled to the environment.
114
- */
115
- interface IDependencyBindable {
116
- /**
117
- * Binds a functional delegate by a specific identifier key.
118
- *
119
- * @param key - The unique lookup identifier for the dependency (e.g., 'domDispatcher').
120
- * @param delegate - The function implementation provided by the adapter layer.
121
- */
122
- bindDelegate(key: string, delegate: AnyFunction): void;
123
- }
124
- /**
125
- * Contract for widgets that support programmatic control.
126
- *
127
- * This interface allows external systems—such as a Physical Gamepad Manager or
128
- * automation scripts—to directly drive the state and behavior of a widget,
129
- * bypassing native DOM pointer events.
130
- */
131
- interface IProgrammatic {
132
- /**
133
- * Manually triggers the 'down' (pressed) state of the widget.
134
- * Primarily used for Button-type components to simulate a physical press.
135
- */
136
- triggerDown?(): void;
137
- /**
138
- * Manually triggers the 'up' (released) state of the widget.
139
- * Primarily used for Button-type components to simulate a physical release.
140
- */
141
- triggerUp?(): void;
142
- /**
143
- * Manually updates the directional input vector of the widget.
144
- * Primarily used for Joystick or D-Pad components.
145
- *
146
- * @param x - The horizontal component, normalized between -1.0 and 1.0.
147
- * @param y - The vertical component, normalized between -1.0 and 1.0.
148
- */
149
- triggerVector?(x: number, y: number): void;
150
- }
151
-
152
- export type { ICoreEntity as I, ISpatial as a, IResettable as b, IConfigurable as c, IStateful as d, IPointerHandler as e, IProgrammatic as f, IDependencyBindable as g, ISignalReceiver as h, IIdentifiable as i, ILifecycle as j };
@@ -1,152 +0,0 @@
1
- import { E as EntityType, A as AbstractRect, a as AbstractPointerEvent, c as AnyFunction, I as InputActionSignal } from './index-DVegtw8s.js';
2
-
3
- /**
4
- * Trait: Provides identity with a unique ID and specific entity type.
5
- */
6
- interface IIdentifiable {
7
- readonly uid: string;
8
- readonly type: EntityType;
9
- }
10
- /**
11
- * Trait: Provides lifecycle management hooks.
12
- */
13
- interface ILifecycle {
14
- /**
15
- * Performs cleanup, unregisters the entity, and releases resources.
16
- */
17
- destroy(): void;
18
- }
19
- /**
20
- * The core contract for any object that can be managed by the Registry.
21
- * Only objects implementing this interface are eligible for registration.
22
- */
23
- interface ICoreEntity extends IIdentifiable, ILifecycle {
24
- }
25
- /**
26
- * Trait: Enables spatial awareness for DOM/UI-related components.
27
- */
28
- interface ISpatial {
29
- readonly rect: AbstractRect | null;
30
- /**
31
- * Dynamically obtain dimensions and position to ensure the most precise real-time screen coordinates are obtained during each interaction.
32
- */
33
- bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
34
- /**
35
- * Trigger a cache invalidation.
36
- */
37
- markRectDirty(): void;
38
- }
39
- /**
40
- * Trait: Provides configuration management.
41
- */
42
- interface IConfigurable<TConfig> {
43
- /**
44
- * Retrieves a snapshot of the current configuration.
45
- */
46
- getConfig(): TConfig;
47
- /**
48
- * Subscribes to config changes.
49
- * @param cb - Callback function triggered on config updates.
50
- * @returns An unsubscribe function.
51
- */
52
- subscribeConfig(cb: (config: TConfig) => void): () => void;
53
- /**
54
- * Updates the internal config and notifies all subscribers.
55
- * @param config - Partial configuration object to merge.
56
- */
57
- updateConfig(config: Partial<TConfig>): void;
58
- }
59
- /**
60
- * Trait: Provides state management.
61
- */
62
- interface IStateful<TState> {
63
- /**
64
- * Retrieves the current state snapshot.
65
- */
66
- getState(): TState;
67
- /**
68
- * Subscribes to state changes.
69
- * @param cb - Callback function triggered on state updates.
70
- * @returns An unsubscribe function.
71
- */
72
- subscribeState(cb: (state: TState) => void): () => void;
73
- /**
74
- * Updates the internal state and notifies all subscribers.
75
- * @param state - Partial object containing updated state values.
76
- */
77
- setState(state: Partial<TState>): void;
78
- }
79
- /**
80
- * Trait: Allows resetting the entity to its idle/safe state.
81
- */
82
- interface IResettable {
83
- /**
84
- * Forcefully clears active states and cuts off outgoing signals.
85
- */
86
- reset(): void;
87
- }
88
- /**
89
- * Trait: Handles raw pointer input (Touch/Mouse).
90
- */
91
- interface IPointerHandler {
92
- readonly activePointerId: number | null;
93
- onPointerDown(e: AbstractPointerEvent): void;
94
- onPointerMove(e: AbstractPointerEvent): void;
95
- onPointerUp(e: AbstractPointerEvent): void;
96
- onPointerCancel(e: AbstractPointerEvent): void;
97
- }
98
- /**
99
- * Trait: Receives and processes input signals (e.g., TargetZone).
100
- */
101
- interface ISignalReceiver {
102
- /**
103
- * Handles incoming signals from widgets.
104
- * @param signal - The signal data containing action type and payload.
105
- */
106
- handleSignal(signal: InputActionSignal): void;
107
- }
108
- /**
109
- * Capability for an entity to receive and store external functional dependencies.
110
- *
111
- * This enables Runtime Dependency Injection (DI), allowing core logic to invoke
112
- * host-specific methods (such as DOM event dispatchers or custom triggers)
113
- * without being tightly coupled to the environment.
114
- */
115
- interface IDependencyBindable {
116
- /**
117
- * Binds a functional delegate by a specific identifier key.
118
- *
119
- * @param key - The unique lookup identifier for the dependency (e.g., 'domDispatcher').
120
- * @param delegate - The function implementation provided by the adapter layer.
121
- */
122
- bindDelegate(key: string, delegate: AnyFunction): void;
123
- }
124
- /**
125
- * Contract for widgets that support programmatic control.
126
- *
127
- * This interface allows external systems—such as a Physical Gamepad Manager or
128
- * automation scripts—to directly drive the state and behavior of a widget,
129
- * bypassing native DOM pointer events.
130
- */
131
- interface IProgrammatic {
132
- /**
133
- * Manually triggers the 'down' (pressed) state of the widget.
134
- * Primarily used for Button-type components to simulate a physical press.
135
- */
136
- triggerDown?(): void;
137
- /**
138
- * Manually triggers the 'up' (released) state of the widget.
139
- * Primarily used for Button-type components to simulate a physical release.
140
- */
141
- triggerUp?(): void;
142
- /**
143
- * Manually updates the directional input vector of the widget.
144
- * Primarily used for Joystick or D-Pad components.
145
- *
146
- * @param x - The horizontal component, normalized between -1.0 and 1.0.
147
- * @param y - The vertical component, normalized between -1.0 and 1.0.
148
- */
149
- triggerVector?(x: number, y: number): void;
150
- }
151
-
152
- export type { ICoreEntity as I, ISpatial as a, IResettable as b, IConfigurable as c, IStateful as d, IPointerHandler as e, IProgrammatic as f, IDependencyBindable as g, ISignalReceiver as h, IIdentifiable as i, ILifecycle as j };