@omnipad/core 0.4.5 → 0.5.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.
@@ -0,0 +1,306 @@
1
+ import { e as IPointerHandler } from '../traits-dAndzyWS.js';
2
+ import { S as StickyProvider } from '../sticky-CLBq1EPa.js';
3
+ import { G as GamepadMappingConfig } from '../index-DVegtw8s.js';
4
+
5
+ /**
6
+ * Forcefully focuses an element.
7
+ * Automatically handles the 'tabindex' attribute to ensure non-focusable elements (like Canvas)
8
+ * can receive focus.
9
+ *
10
+ * @param el - The target HTMLElement to focus.
11
+ */
12
+ declare const focusElement: (el: HTMLElement) => void;
13
+ /**
14
+ * Dispatches a synthetic KeyboardEvent to the window object.
15
+ *
16
+ * @param type - The event type, e.g., 'keydown' or 'keyup'.
17
+ * @param payload - Key mapping data including key, code, and legacy keyCode.
18
+ */
19
+ declare const dispatchKeyboardEvent: (type: string, payload: {
20
+ key: string;
21
+ code: string;
22
+ keyCode: number;
23
+ }) => void;
24
+ /**
25
+ * Dispatches a high-fidelity sequence of Pointer and Mouse events at specific pixel coordinates.
26
+ * Finds the target element dynamically at the moment of dispatch.
27
+ *
28
+ * @param type - The event type (should start with 'pointer' for best compatibility).
29
+ * @param x - Viewport X coordinate (px).
30
+ * @param y - Viewport Y coordinate (px).
31
+ * @param opts - Additional PointerEvent options (button, pressure, etc.).
32
+ */
33
+ declare const dispatchPointerEventAtPos: (type: string, x: number, y: number, opts: {
34
+ button: number;
35
+ buttons: number;
36
+ pressure: number;
37
+ }) => void;
38
+ /**
39
+ * Reclaims browser focus for the element located at the specified viewport coordinates.
40
+ *
41
+ * This utility identifies the deepest element (penetrating Shadow DOM) at the given position
42
+ * and ensures it becomes the active element. It is essential for ensuring that
43
+ * game engines (like Ruffle) receive keyboard events immediately after a virtual interaction.
44
+ *
45
+ * @param x - The horizontal coordinate relative to the viewport.
46
+ * @param y - The vertical coordinate relative to the viewport.
47
+ * @returns True if the focus was successfully moved to the target; false if it was already focused or no target found.
48
+ */
49
+ declare const reclaimFocusAtPos: (x: number, y: number, callback: () => void) => void;
50
+
51
+ /**
52
+ * Creates a standardized bridge between native DOM PointerEvents and Core abstract handlers.
53
+ * Handles event prevention, stop propagation, pointer capture, and multi-touch filtering.
54
+ *
55
+ * @param coreHandler - The logic core instance that implements IPointerHandler.
56
+ * @param getElement - A getter function to retrieve the DOM element for pointer capture.
57
+ * @returns An object containing mapped event handlers for Vue/React template binding.
58
+ */
59
+ declare function createPointerBridge(coreHandler: IPointerHandler & {
60
+ activePointerId?: number | null;
61
+ }, options?: {
62
+ /** Respond only to direct clicks (without responding to events bubbled up from child elements) */
63
+ requireDirectHit?: boolean;
64
+ }): {
65
+ /**
66
+ * Entry point for a pointer interaction.
67
+ * Establishes capture and initializes core logic.
68
+ */
69
+ onPointerDown(e: PointerEvent): void;
70
+ /**
71
+ * Continuous movement handling.
72
+ * Throttling should be handled within the core implementation.
73
+ */
74
+ onPointerMove(e: PointerEvent): void;
75
+ /**
76
+ * Successful interaction completion.
77
+ * Filters by pointerId to ensure only the capturing finger triggers release.
78
+ */
79
+ onPointerUp(e: PointerEvent): void;
80
+ /**
81
+ * System-level interaction cancellation (e.g., alert popups, browser gestures).
82
+ */
83
+ onPointerCancel(e: PointerEvent): void;
84
+ };
85
+
86
+ /**
87
+ * Safely sets pointer capture on an element.
88
+ *
89
+ * @param el - The target element to capture the pointer.
90
+ * @param pointerId - The unique ID of the pointer (from PointerEvent).
91
+ */
92
+ declare const safeSetCapture: (el: EventTarget | null, pointerId: number) => void;
93
+ /**
94
+ * Safely releases pointer capture from an element.
95
+ * Checks for current capture state and wraps in try-catch to prevent crashes.
96
+ *
97
+ * @param el - The target element.
98
+ * @param pointerId - The unique ID of the pointer to release.
99
+ */
100
+ declare const safeReleaseCapture: (el: EventTarget | null, pointerId: number) => void;
101
+
102
+ declare const supportsContainerQueries: () => boolean;
103
+
104
+ /**
105
+ * Recursively penetrates Shadow DOM boundaries to find the deepest element at the
106
+ * specified viewport coordinates.
107
+ *
108
+ * @param x - Viewport X coordinate (px)
109
+ * @param y - Viewport Y coordinate (px)
110
+ * @param ignoreClass - Style class of DOM elements to be ignored
111
+ * @returns The deepmost Element or null if none found at the position.
112
+ */
113
+ declare const getDeepElement: (x: number, y: number, ignoreClass?: string) => Element | null;
114
+ /**
115
+ * Recursively finds the truly focused element by traversing Shadow DOM boundaries.
116
+ *
117
+ * @returns The deepmost active Element in focus or null.
118
+ */
119
+ declare const getDeepActiveElement: () => Element | null;
120
+ /**
121
+ * A robust wrapper for selecting a single DOM element.
122
+ *
123
+ *
124
+ * @param selector - A string containing one or more selectors to match.
125
+ * @returns The first {@link Element} that matches the specified selector, or `null` if no matches are found or the selector is invalid.
126
+ *
127
+ * @example
128
+ * // Handles special characters in IDs gracefully
129
+ * smartQuerySelector('#my.id$with:special-chars');
130
+ * // Falls back to standard CSS selectors
131
+ * smartQuerySelector('.container > div:first-child');
132
+ */
133
+ declare const smartQuerySelector: (selector: string) => Element | null;
134
+
135
+ /**
136
+ * Creates a StickyProvider pre-configured for the Web environment.
137
+ */
138
+ declare const createWebStickyProvider: (selector: string) => StickyProvider;
139
+
140
+ /**
141
+ * A centralized observation pool for DOM elements.
142
+ *
143
+ * This class provides a high-performance wrapper around `ResizeObserver` (RO) and
144
+ * `IntersectionObserver` (IO). By pooling all element observations into single
145
+ * native observer instances and utilizing `requestAnimationFrame` (rAF) throttling,
146
+ * it significantly reduces memory footprint and prevents layout thrashing.
147
+ *
148
+ * It supports deterministic unregistration via UIDs, making it ideal for
149
+ * framework adapters (like Vue or React) where DOM references may become unstable
150
+ * during unmounting.
151
+ */
152
+ declare class ElementObserver {
153
+ private _ro;
154
+ private _roRegistry;
155
+ private _elToRoCb;
156
+ private _io;
157
+ private _ioRegistry;
158
+ private _elToIoCb;
159
+ private constructor();
160
+ static getInstance(): ElementObserver;
161
+ /**
162
+ * Starts observing size changes for a specific element.
163
+ *
164
+ * @param uid - The unique entity ID associated with the observation.
165
+ * @param el - The target DOM element to observe.
166
+ * @param cb - Callback triggered when the element's size changes.
167
+ */
168
+ observeResize(uid: string, el: Element, cb: () => void): void;
169
+ /**
170
+ * Stops observing size changes for the entity identified by the UID.
171
+ *
172
+ * @param uid - The unique entity ID to unregister.
173
+ */
174
+ unobserveResize(uid: string): void;
175
+ /**
176
+ * Starts observing visibility (intersection) changes for a specific element.
177
+ *
178
+ * @param uid - The unique entity ID associated with the observation.
179
+ * @param el - The target DOM element to observe.
180
+ * @param cb - Callback triggered when visibility enters or exits the viewport.
181
+ */
182
+ observeIntersect(uid: string, el: Element, cb: (isIntersecting: boolean) => void): void;
183
+ /**
184
+ * Stops observing intersection changes for the entity identified by the UID.
185
+ *
186
+ * @param uid - The unique entity ID to unregister.
187
+ */
188
+ unobserveIntersect(uid: string): void;
189
+ /**
190
+ * Disconnects all observers (RO and IO) associated with a specific UID.
191
+ * Usually called during component destruction for thorough cleanup.
192
+ *
193
+ * @param uid - The unique entity ID to fully disconnect.
194
+ */
195
+ disconnect(uid: string): void;
196
+ }
197
+
198
+ /**
199
+ * GamepadManager
200
+ *
201
+ * A singleton service that polls the browser Gamepad API via requestAnimationFrame.
202
+ * It translates physical hardware inputs into programmatic signals sent to
203
+ * virtual entities registered in the system.
204
+ *
205
+ * Handles:
206
+ * 1. Button edge detection (Down/Up).
207
+ * 2. D-Pad to vector conversion.
208
+ * 3. Analog stick deadzone processing.
209
+ */
210
+ declare class GamepadManager {
211
+ private isRunning;
212
+ private config;
213
+ private lastButtonStates;
214
+ private constructor();
215
+ /**
216
+ * Retrieves the global singleton instance of the GamepadManager.
217
+ */
218
+ static getInstance(): GamepadManager;
219
+ /**
220
+ * Updates the current gamepad mapping configuration.
221
+ *
222
+ * @param config - The mapping of physical inputs to virtual component IDs (UID).
223
+ */
224
+ setConfig(config: GamepadMappingConfig[]): void;
225
+ /** Return the current gamepad mapping configuration. */
226
+ getConfig(): Readonly<GamepadMappingConfig[] | null>;
227
+ /**
228
+ * Starts the polling loop and listens for gamepad connection events.
229
+ */
230
+ start(): void;
231
+ /**
232
+ * Stops the polling loop.
233
+ */
234
+ stop(): void;
235
+ /**
236
+ * The core polling loop executing at the browser's refresh rate.
237
+ */
238
+ private loop;
239
+ /**
240
+ * Process binary button inputs with edge detection.
241
+ */
242
+ private processButtons;
243
+ /**
244
+ * Translates physical D-Pad buttons into a normalized vector.
245
+ */
246
+ private processDPad;
247
+ /**
248
+ * Process analog stick movements with deadzone logic.
249
+ */
250
+ private processAxes;
251
+ /**
252
+ * Locates a virtual entity and triggers its programmatic interface.
253
+ *
254
+ * @param uid - The Entity ID (UID) of the target.
255
+ * @param action - The type of trigger ('down', 'up', or 'vector').
256
+ * @param payload - Optional data for vector movements.
257
+ */
258
+ private triggerVirtualEntity;
259
+ }
260
+
261
+ /**
262
+ * Global Input Manager Singleton.
263
+ *
264
+ * Responsible for monitoring global browser events (resize, blur, visibility)
265
+ * and coordinating system-wide resets to prevent stuck inputs.
266
+ */
267
+ declare class WindowManager {
268
+ /** Internal flag to prevent multiple event registrations */
269
+ private _isListening;
270
+ /** A throttled version of the reset logic */
271
+ private throttledReset;
272
+ private constructor();
273
+ /**
274
+ * Retrieves the global instance of the WindowManager.
275
+ * Ensures uniqueness across multiple bundles or modules.
276
+ */
277
+ static getInstance(): WindowManager;
278
+ /**
279
+ * Manually triggers a system-wide input reset via Registry.
280
+ */
281
+ private handleGlobalReset;
282
+ private handleResizeReset;
283
+ private handleBlurReset;
284
+ private handleScrollReset;
285
+ private handleVisibilityChangeReset;
286
+ /**
287
+ * Initializes global safety listeners.
288
+ * Should be called once at the root component lifecycle (e.g., VirtualLayer).
289
+ */
290
+ init(): void;
291
+ /**
292
+ * Toggle full-screen state of the page.
293
+ * @param element Target HTMLElement
294
+ */
295
+ toggleFullscreen(element?: HTMLElement): Promise<void>;
296
+ /**
297
+ * Full-screen status query provided to the UI layer.
298
+ */
299
+ isFullscreen(): boolean;
300
+ /**
301
+ * Detaches all global listeners.
302
+ */
303
+ destroy(): void;
304
+ }
305
+
306
+ export { ElementObserver, GamepadManager, WindowManager, createPointerBridge, createWebStickyProvider, dispatchKeyboardEvent, dispatchPointerEventAtPos, focusElement, getDeepActiveElement, getDeepElement, reclaimFocusAtPos, safeReleaseCapture, safeSetCapture, smartQuerySelector, supportsContainerQueries };
@@ -0,0 +1 @@
1
+ import {a as a$1}from'../chunk-ZM2LX5IW.mjs';import {k}from'../chunk-MKVX5ALC.mjs';import {a,h as h$1}from'../chunk-PACTGVBB.mjs';var m=(n,t,e="omnipad-prevent")=>{let i=document.elementsFromPoint(n,t).find(s=>!s.classList.contains(e));if(!i)return null;for(;i&&i.shadowRoot;){let a=i.shadowRoot.elementsFromPoint(n,t).find(l=>!l.classList.contains(e));if(!a||a===i)break;i=a;}return i},g=()=>{let n=document.activeElement;for(;n&&n.shadowRoot&&n.shadowRoot.activeElement;)n=n.shadowRoot.activeElement;return n},R=n=>{if(!n)return null;if(n.startsWith("#")){let t=n.slice(1),e=document.getElementById(t);if(e)return e}try{return document.querySelector(n)}catch{return null}};var x=n=>{g()!==n&&(n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1"),n.focus());},M=(n,t)=>{let e=new KeyboardEvent(n,{...t,which:t.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(e);},D=(n,t,e,r)=>{let i=m(t,e);if(!i)return;let s={bubbles:true,cancelable:true,composed:true,clientX:t,clientY:e,view:window,...r};if(n.startsWith("pointer")){i.dispatchEvent(new PointerEvent(n,{isPrimary:true,pointerId:9999,pointerType:"mouse",...s}));let a=n.replace("pointer","mouse");i.dispatchEvent(new MouseEvent(a,s));}else i.dispatchEvent(new MouseEvent(n,s));},L=(n,t,e)=>{let r=m(n,t);if(!r)return;g()!==r&&(x(r),e());};var w=(n,t)=>{if(n instanceof Element)try{n.setPointerCapture(t);}catch(e){import.meta.env?.DEV&&console.warn("[OmniPad-DOM] Failed to set pointer capture:",e);}},f=(n,t)=>{if(n instanceof Element&&n.hasPointerCapture(t))try{n.releasePointerCapture(t);}catch{}};function O(n,t={}){return {onPointerDown(e){if(!e.isTrusted||t?.requireDirectHit&&e.target!==e.currentTarget||n.activePointerId!=null)return;e.cancelable&&e.preventDefault(),e.stopPropagation();let r=e.currentTarget;r&&w(r,e.pointerId),n.onPointerDown(e);},onPointerMove(e){e.isTrusted&&(n.activePointerId!=null&&n.activePointerId!==e.pointerId||(e.cancelable&&e.preventDefault(),n.onPointerMove(e)));},onPointerUp(e){if(!e.isTrusted||n.activePointerId!=null&&n.activePointerId!==e.pointerId)return;e.cancelable&&e.preventDefault();let r=e.currentTarget;r&&f(r,e.pointerId),n.onPointerUp(e);},onPointerCancel(e){if(!e.isTrusted||n.activePointerId!=null&&n.activePointerId!==e.pointerId)return;let r=e.currentTarget;r&&f(r,e.pointerId),n.onPointerCancel(e);}}}var p,z=()=>(p!==void 0||(p=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),p);var U=n=>new k(n,t=>R(t),t=>t.getBoundingClientRect(),t=>document.contains(t));var h=Symbol.for("omnipad.element_observer.instance"),y=class n{constructor(){a(this,"_ro");a(this,"_roRegistry",new Map);a(this,"_elToRoCb",new WeakMap);a(this,"_io");a(this,"_ioRegistry",new Map);a(this,"_elToIoCb",new WeakMap);let t=a$1(e=>{for(let r of e)this._elToRoCb.get(r.target)?.();});this._ro=new ResizeObserver(e=>{t(e);}),this._io=new IntersectionObserver(e=>{for(let r of e)this._elToIoCb.get(r.target)?.(r.isIntersecting);},{threshold:0});}static getInstance(){let t=globalThis;return t[h]||(t[h]=new n),t[h]}observeResize(t,e,r){this.unobserveResize(t),this._roRegistry.set(t,e),this._elToRoCb.set(e,r),this._ro.observe(e);}unobserveResize(t){let e=this._roRegistry.get(t);e&&(this._ro.unobserve(e),this._elToRoCb.delete(e),this._roRegistry.delete(t));}observeIntersect(t,e,r){this.unobserveIntersect(t),this._ioRegistry.set(t,e),this._elToIoCb.set(e,r),this._io.observe(e);}unobserveIntersect(t){let e=this._ioRegistry.get(t);e&&(this._io.unobserve(e),this._elToIoCb.delete(e),this._ioRegistry.delete(t));}disconnect(t){this.unobserveResize(t),this.unobserveIntersect(t);}};var v=Symbol.for("omnipad.gamepad_manager.instance"),_={A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,Select:8,Start:9,L3:10,R3:11,Up:12,Down:13,Left:14,Right:15},P=class n{constructor(){a(this,"isRunning",false);a(this,"config",null);a(this,"lastButtonStates",[]);a(this,"loop",()=>{if(!this.isRunning)return;let t=navigator.getGamepads();this.config?.forEach((e,r)=>{let i=t[r];i&&i.connected&&e&&(this.lastButtonStates[r]||(this.lastButtonStates[r]=[]),this.processButtons(i,e,r),this.processDPad(i,e),this.processAxes(i,e));}),requestAnimationFrame(this.loop);});}static getInstance(){let t=globalThis;return t[v]||(t[v]=new n),t[v]}setConfig(t){this.config=t;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",t=>{import.meta.env?.DEV&&console.log("[OmniPad-DOM] Gamepad Connected:",t.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{import.meta.env?.DEV&&console.log("[OmniPad-DOM] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(t,e,r){e.buttons&&Object.entries(e.buttons).forEach(([i,s])=>{let a=_[i];if(a===void 0||!t.buttons[a])return;let l=t.buttons[a].pressed,u=this.lastButtonStates[r][a]||false;l&&!u?this.triggerVirtualEntity(s,"down"):!l&&u&&this.triggerVirtualEntity(s,"up"),this.lastButtonStates[r][a]=l;});}processDPad(t,e){let r=e?.dpad;if(!r)return;let i=t.buttons[12]?.pressed?-1:0,s=t.buttons[13]?.pressed?1:0,a=t.buttons[14]?.pressed?-1:0,l=t.buttons[15]?.pressed?1:0,u=a+l,C=i+s;this.triggerVirtualEntity(r,"vector",{x:u,y:C});}processAxes(t,e){let r=e?.deadzone??.1;if(e?.leftStick){let i=Math.abs(t.axes[0])>r?t.axes[0]:0,s=Math.abs(t.axes[1])>r?t.axes[1]:0;this.triggerVirtualEntity(e.leftStick,"vector",{x:i,y:s});}if(e?.rightStick){let i=Math.abs(t.axes[2])>r?t.axes[2]:0,s=Math.abs(t.axes[3])>r?t.axes[3]:0;this.triggerVirtualEntity(e.rightStick,"vector",{x:i,y:s});}}triggerVirtualEntity(t,e,r){let i=h$1.getInstance().getEntity(t);!i||i.activePointerId!=null||(e==="down"&&typeof i.triggerDown=="function"&&i.triggerDown(),e==="up"&&typeof i.triggerUp=="function"&&i.triggerUp(),e==="vector"&&typeof i.triggerVector=="function"&&r&&i.triggerVector(r.x,r.y));}};var b=Symbol.for("omnipad.window_manager.instance"),I=class n{constructor(){a(this,"_isListening",false);a(this,"throttledReset");a(this,"handleGlobalReset",()=>{import.meta.env?.DEV&&console.debug("[OmniPad-Core] Safety reset triggered by environment change."),h$1.getInstance().resetAll(),h$1.getInstance().markAllRectDirty();});a(this,"handleResizeReset",()=>{this.throttledReset(null);});a(this,"handleBlurReset",()=>{this.handleGlobalReset();});a(this,"handleScrollReset",()=>{this.throttledReset(null);});a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=a$1(()=>{this.handleGlobalReset();});}static getInstance(){let t=globalThis;return t[b]||(t[b]=new n),t[b]}init(){this._isListening||(window.addEventListener("resize",this.handleResizeReset),window.addEventListener("blur",this.handleBlurReset),window.addEventListener("scroll",this.handleScrollReset,{capture:true,passive:true}),document.addEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=true,import.meta.env?.DEV&&console.log("[OmniPad-Core] Global WindowManager monitoring started."));}async toggleFullscreen(t){let e=t||document.documentElement;try{document.fullscreenElement?(this.handleGlobalReset(),await document.exitFullscreen()):(this.handleGlobalReset(),await e.requestFullscreen());}catch(r){console.error("[OmniPad-Core] Fullscreen toggle failed:",r);}}isFullscreen(){return !!document.fullscreenElement}destroy(){window.removeEventListener("resize",this.handleResizeReset),window.removeEventListener("blur",this.handleBlurReset),window.removeEventListener("scroll",this.handleScrollReset,{capture:true}),window.removeEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=false;}};export{y as ElementObserver,P as GamepadManager,I as WindowManager,O as createPointerBridge,U as createWebStickyProvider,M as dispatchKeyboardEvent,D as dispatchPointerEventAtPos,x as focusElement,g as getDeepActiveElement,m as getDeepElement,L as reclaimFocusAtPos,f as safeReleaseCapture,w as safeSetCapture,R as smartQuerySelector,z as supportsContainerQueries};
@@ -590,9 +590,13 @@ interface LayoutBox {
590
590
  * @example 'center' will center the component on its position.
591
591
  */
592
592
  anchor?: AnchorPoint;
593
- /** Rotation angle in degrees. */
594
593
  /** Z-index for layering control. */
595
594
  zIndex?: number;
595
+ /**
596
+ * CSS selector for the target element (e.g., "#game-canvas").
597
+ * If provided, the component switches to "Sticky" mode and positions itself relative to this element.
598
+ */
599
+ stickySelector?: string;
596
600
  }
597
601
  /**
598
602
  * Base configuration interface for all components.
@@ -600,6 +604,7 @@ interface LayoutBox {
600
604
  interface BaseConfig {
601
605
  /**
602
606
  * Config ID (CID) used in persistent storage.
607
+ *
603
608
  * If omitted, a random UID will be generated during parsing.
604
609
  * If starts with '$', it points to a global static entity. (UID = CID)
605
610
  */
@@ -612,9 +617,10 @@ interface BaseConfig {
612
617
  layout: LayoutBox;
613
618
  /**
614
619
  * Custom CSS class names or style tags.
615
- * For visual decoration only; must not include layout attributes such as top/left/width/height.
620
+ *
621
+ * For visual decoration only; must not include layout attributes such as top/left/width/height while the same properties are set in `layout: LayoutBox`.
616
622
  */
617
- cssClasses?: string | string[];
623
+ cssClass?: string;
618
624
  }
619
625
  /**
620
626
  * Configuration for a virtual keyboard/mouse button.
@@ -724,9 +730,9 @@ interface FlatConfigItem {
724
730
  config?: Record<string, any>;
725
731
  }
726
732
  /**
727
- * The root structure of a Gamepad configuration file.
733
+ * The root structure of a OmniPad configuration file.
728
734
  */
729
- interface GamepadProfile {
735
+ interface OmniPadProfile {
730
736
  /** Metadata about the profile creator and version. */
731
737
  meta: {
732
738
  name: string;
@@ -757,155 +763,6 @@ interface ConfigTreeNode {
757
763
  children?: ConfigTreeNode[];
758
764
  }
759
765
 
760
- /**
761
- * Trait: Provides identity with a unique ID and specific entity type.
762
- */
763
- interface IIdentifiable {
764
- readonly uid: string;
765
- readonly type: EntityType;
766
- }
767
- /**
768
- * Trait: Provides lifecycle management hooks.
769
- */
770
- interface ILifecycle {
771
- /**
772
- * Performs cleanup, unregisters the entity, and releases resources.
773
- */
774
- destroy(): void;
775
- }
776
- /**
777
- * The core contract for any object that can be managed by the Registry.
778
- * Only objects implementing this interface are eligible for registration.
779
- */
780
- interface ICoreEntity extends IIdentifiable, ILifecycle {
781
- }
782
- /**
783
- * Trait: Enables spatial awareness for DOM/UI-related components.
784
- */
785
- interface ISpatial {
786
- readonly rect: AbstractRect | null;
787
- /**
788
- * Dynamically obtain dimensions and position to ensure the most precise real-time screen coordinates are obtained during each interaction.
789
- */
790
- bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
791
- /**
792
- * Trigger a cache invalidation.
793
- */
794
- markRectDirty(): void;
795
- }
796
- /**
797
- * Trait: Provides configuration management.
798
- */
799
- interface IConfigurable<TConfig> {
800
- /**
801
- * Retrieves a snapshot of the current configuration.
802
- */
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;
815
- }
816
- /**
817
- * Trait: Provides state management.
818
- */
819
- interface IStateful<TState> {
820
- /**
821
- * Retrieves the current state snapshot.
822
- */
823
- getState(): TState;
824
- /**
825
- * Subscribes to state changes.
826
- * @param cb - Callback function triggered on state updates.
827
- * @returns An unsubscribe function.
828
- */
829
- subscribeState(cb: (state: TState) => void): () => void;
830
- /**
831
- * Updates the internal state and notifies all subscribers.
832
- * @param state - Partial object containing updated state values.
833
- */
834
- setState(state: Partial<TState>): void;
835
- }
836
- /**
837
- * Trait: Allows resetting the entity to its idle/safe state.
838
- */
839
- interface IResettable {
840
- /**
841
- * Forcefully clears active states and cuts off outgoing signals.
842
- */
843
- reset(): void;
844
- }
845
- /**
846
- * Trait: Handles raw pointer input (Touch/Mouse).
847
- */
848
- interface IPointerHandler {
849
- readonly activePointerId: number | null;
850
- onPointerDown(e: AbstractPointerEvent): void;
851
- onPointerMove(e: AbstractPointerEvent): void;
852
- onPointerUp(e: AbstractPointerEvent): void;
853
- onPointerCancel(e: AbstractPointerEvent): void;
854
- }
855
- /**
856
- * Trait: Receives and processes input signals (e.g., TargetZone).
857
- */
858
- interface ISignalReceiver {
859
- /**
860
- * Handles incoming signals from widgets.
861
- * @param signal - The signal data containing action type and payload.
862
- */
863
- handleSignal(signal: InputActionSignal): void;
864
- }
865
- /**
866
- * Capability for an entity to receive and store external functional dependencies.
867
- *
868
- * This enables Runtime Dependency Injection (DI), allowing core logic to invoke
869
- * host-specific methods (such as DOM event dispatchers or custom triggers)
870
- * without being tightly coupled to the environment.
871
- */
872
- interface IDependencyBindable {
873
- /**
874
- * Binds a functional delegate by a specific identifier key.
875
- *
876
- * @param key - The unique lookup identifier for the dependency (e.g., 'domDispatcher').
877
- * @param delegate - The function implementation provided by the adapter layer.
878
- */
879
- bindDelegate(key: string, delegate: AnyFunction): void;
880
- }
881
- /**
882
- * Contract for widgets that support programmatic control.
883
- *
884
- * This interface allows external systems—such as a Physical Gamepad Manager or
885
- * automation scripts—to directly drive the state and behavior of a widget,
886
- * bypassing native DOM pointer events.
887
- */
888
- interface IProgrammatic {
889
- /**
890
- * Manually triggers the 'down' (pressed) state of the widget.
891
- * Primarily used for Button-type components to simulate a physical press.
892
- */
893
- triggerDown?(): void;
894
- /**
895
- * Manually triggers the 'up' (released) state of the widget.
896
- * Primarily used for Button-type components to simulate a physical release.
897
- */
898
- triggerUp?(): void;
899
- /**
900
- * Manually updates the directional input vector of the widget.
901
- * Primarily used for Joystick or D-Pad components.
902
- *
903
- * @param x - The horizontal component, normalized between -1.0 and 1.0.
904
- * @param y - The vertical component, normalized between -1.0 and 1.0.
905
- */
906
- triggerVector?(x: number, y: number): void;
907
- }
908
-
909
766
  /**
910
767
  * =================================================================
911
768
  * 1. Constants Definition
@@ -962,7 +819,9 @@ declare const ACTION_TYPES: {
962
819
  */
963
820
  interface AbstractRect {
964
821
  left: number;
822
+ right: number;
965
823
  top: number;
824
+ bottom: number;
966
825
  width: number;
967
826
  height: number;
968
827
  }
@@ -1073,4 +932,4 @@ declare const CONTEXT: {
1073
932
  */
1074
933
  type AnyFunction = (...args: any[]) => void;
1075
934
 
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 InputActionSignal as a, type ISpatial as b, type IResettable as c, type IConfigurable as d, type IStateful as e, type IPointerHandler as f, type IProgrammatic as g, type AbstractPointerEvent as h, type InputZoneConfig as i, type IDependencyBindable as j, type AnyFunction as k, type BaseConfig as l, type ISignalReceiver 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 };
935
+ 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 InputActionSignal as I, type JoystickConfig as J, KEYS as K, type LayoutBox as L, type OmniPadProfile as O, type ParsedLength as P, type StageId as S, type TargetZoneConfig as T, type Vec2 as V, type WidgetId as W, type ZoneId as Z, type AbstractPointerEvent as a, type InputZoneConfig as b, type AnyFunction as c, type BaseConfig as d, type TrackpadConfig as e, ACTION_TYPES as f, type ActionMapping as g, type AnchorPoint as h, type AnyConfig as i, type AnyEntityType as j, type BuiltInActionType as k, CONTEXT as l, type ConfigTreeNode as m, type CssUnit as n, type FlexibleLength as o, type InputActionType as p, type KeyMapping as q, type StandardButton as r, VALID_UNITS as s, type WidgetType as t, type ZoneType as u };