@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.
- package/dist/chunk-FSJTQU4W.cjs +1 -0
- package/dist/chunk-MKVX5ALC.mjs +1 -0
- package/dist/{chunk-W7OR5ESR.mjs → chunk-PACTGVBB.mjs} +1 -1
- package/dist/chunk-U52W5J3K.cjs +1 -0
- package/dist/chunk-V7AHGFPB.mjs +1 -0
- package/dist/chunk-VHF3K5X6.cjs +1 -0
- package/dist/{chunk-4J2ZANLB.cjs → chunk-ZHPNS73J.cjs} +1 -1
- package/dist/chunk-ZM2LX5IW.mjs +1 -0
- package/dist/dom/index.cjs +1 -0
- package/dist/dom/index.d.cts +306 -0
- package/dist/dom/index.d.ts +306 -0
- package/dist/dom/index.mjs +1 -0
- package/dist/{index-CT1fDlB9.d.cts → index-DVegtw8s.d.cts} +14 -155
- package/dist/{index-CT1fDlB9.d.ts → index-DVegtw8s.d.ts} +14 -155
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -169
- package/dist/index.d.ts +5 -169
- package/dist/index.mjs +1 -1
- package/dist/sticky-4yk5DLzG.d.cts +59 -0
- package/dist/sticky-CLBq1EPa.d.ts +59 -0
- package/dist/traits-D6ePqSA6.d.cts +152 -0
- package/dist/traits-dAndzyWS.d.ts +152 -0
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +39 -125
- package/dist/utils/index.d.ts +39 -125
- package/dist/utils/index.mjs +1 -1
- package/package.json +9 -1
|
@@ -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
|
-
*
|
|
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
|
-
|
|
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
|
|
733
|
+
* The root structure of a OmniPad configuration file.
|
|
728
734
|
*/
|
|
729
|
-
interface
|
|
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
|
|
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 };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunk4J2ZANLB_cjs=require('./chunk-4J2ZANLB.cjs');var x=Symbol.for("omnipad.gamepad_manager.instance"),it={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(){chunk4J2ZANLB_cjs.a(this,"isRunning",false);chunk4J2ZANLB_cjs.a(this,"config",null);chunk4J2ZANLB_cjs.a(this,"lastButtonStates",[]);chunk4J2ZANLB_cjs.a(this,"loop",()=>{if(!this.isRunning)return;let i=navigator.getGamepads();this.config?.forEach((t,e)=>{let s=i[e];s&&s.connected&&t&&(this.lastButtonStates[e]||(this.lastButtonStates[e]=[]),this.processButtons(s,t,e),this.processDPad(s,t),this.processAxes(s,t));}),requestAnimationFrame(this.loop);});}static getInstance(){let i=globalThis;return i[x]||(i[x]=new c),i[x]}setConfig(i){this.config=i;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",i=>{undefined?.DEV&&console.log("[Omnipad-Core] Gamepad Connected:",i.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{undefined?.DEV&&console.log("[Omnipad-Core] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(i,t,e){t.buttons&&Object.entries(t.buttons).forEach(([s,o])=>{let n=it[s];if(n===void 0||!i.buttons[n])return;let l=i.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(i,t){let e=t?.dpad;if(!e)return;let s=i.buttons[12]?.pressed?-1:0,o=i.buttons[13]?.pressed?1:0,n=i.buttons[14]?.pressed?-1:0,l=i.buttons[15]?.pressed?1:0,u=n+l,v=s+o;this.triggerVirtualEntity(e,"vector",{x:u,y:v});}processAxes(i,t){let e=t?.deadzone??.1;if(t?.leftStick){let s=Math.abs(i.axes[0])>e?i.axes[0]:0,o=Math.abs(i.axes[1])>e?i.axes[1]:0;this.triggerVirtualEntity(t.leftStick,"vector",{x:s,y:o});}if(t?.rightStick){let s=Math.abs(i.axes[2])>e?i.axes[2]:0,o=Math.abs(i.axes[3])>e?i.axes[3]:0;this.triggerVirtualEntity(t.rightStick,"vector",{x:s,y:o});}}triggerVirtualEntity(i,t,e){let s=chunk4J2ZANLB_cjs.h.getInstance().getEntity(i);!s||s.activePointerId!=null||(t==="down"&&typeof s.triggerDown=="function"&&s.triggerDown(),t==="up"&&typeof s.triggerUp=="function"&&s.triggerUp(),t==="vector"&&typeof s.triggerVector=="function"&&e&&s.triggerVector(e.x,e.y));}};var R=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):c=>setTimeout(c,16),st=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):c=>clearTimeout(c);function T(c){let i=false,t;return function(e){t=e,i||(i=true,R(()=>{c(t),i=false;}));}}function z(c){let i=null,t=()=>{c(),i=R(t);};return {start:()=>{i===null&&t();},stop:()=>{i!==null&&(st(i),i=null);}}}var Z=(c=2)=>new Promise(i=>{let t=0,e=()=>{++t>=c?i():R(e);};R(e);});var O=Symbol.for("omnipad.element_observer.instance"),k=class c{constructor(){chunk4J2ZANLB_cjs.a(this,"_ro");chunk4J2ZANLB_cjs.a(this,"_roRegistry",new Map);chunk4J2ZANLB_cjs.a(this,"_elToRoCb",new WeakMap);chunk4J2ZANLB_cjs.a(this,"_io");chunk4J2ZANLB_cjs.a(this,"_ioRegistry",new Map);chunk4J2ZANLB_cjs.a(this,"_elToIoCb",new WeakMap);let i=T(t=>{for(let e of t)this._elToRoCb.get(e.target)?.();});this._ro=new ResizeObserver(t=>{i(t);}),this._io=new IntersectionObserver(t=>{for(let e of t)this._elToIoCb.get(e.target)?.(e.isIntersecting);},{threshold:0});}static getInstance(){let i=globalThis;return i[O]||(i[O]=new c),i[O]}observeResize(i,t,e){this.unobserveResize(i),this._roRegistry.set(i,t),this._elToRoCb.set(t,e),this._ro.observe(t);}unobserveResize(i){let t=this._roRegistry.get(i);t&&(this._ro.unobserve(t),this._elToRoCb.delete(t),this._roRegistry.delete(i));}observeIntersect(i,t,e){this.unobserveIntersect(i),this._ioRegistry.set(i,t),this._elToIoCb.set(t,e),this._io.observe(t);}unobserveIntersect(i){let t=this._ioRegistry.get(i);t&&(this._io.unobserve(t),this._elToIoCb.delete(t),this._ioRegistry.delete(i));}disconnect(i){this.unobserveResize(i),this.unobserveIntersect(i);}};var _=Symbol.for("omnipad.window_manager.instance"),Y=class c{constructor(){chunk4J2ZANLB_cjs.a(this,"_isListening",false);chunk4J2ZANLB_cjs.a(this,"throttledReset");chunk4J2ZANLB_cjs.a(this,"handleGlobalReset",()=>{undefined?.DEV&&console.debug("[OmniPad-Core] Safety reset triggered by environment change."),chunk4J2ZANLB_cjs.h.getInstance().resetAll(),chunk4J2ZANLB_cjs.h.getInstance().markAllRectDirty();});chunk4J2ZANLB_cjs.a(this,"handleResizeReset",()=>{this.throttledReset(null);});chunk4J2ZANLB_cjs.a(this,"handleBlurReset",()=>{this.handleGlobalReset();});chunk4J2ZANLB_cjs.a(this,"handleScrollReset",()=>{this.throttledReset(null);});chunk4J2ZANLB_cjs.a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=T(()=>{this.handleGlobalReset();});}static getInstance(){let i=globalThis;return i[_]||(i[_]=new c),i[_]}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(i){let t=i||document.documentElement;try{document.fullscreenElement?(this.handleGlobalReset(),await document.exitFullscreen()):(this.handleGlobalReset(),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 A=class{constructor(){chunk4J2ZANLB_cjs.a(this,"listeners",new Set);}subscribe(i){return this.listeners.add(i),()=>this.listeners.delete(i)}emit(i){this.listeners.forEach(t=>{try{t(i);}catch(e){console.error("[OmniPad-Core] Emitter callback error:",e);}});}clear(){this.listeners.clear();}};var d=class{constructor(i,t,e,s){chunk4J2ZANLB_cjs.a(this,"uid");chunk4J2ZANLB_cjs.a(this,"type");chunk4J2ZANLB_cjs.a(this,"config");chunk4J2ZANLB_cjs.a(this,"state");chunk4J2ZANLB_cjs.a(this,"rectProvider",null);chunk4J2ZANLB_cjs.a(this,"_onMarkDirtyCb",null);chunk4J2ZANLB_cjs.a(this,"stateEmitter",new A);chunk4J2ZANLB_cjs.a(this,"configEmitter",new A);this.uid=i,this.type=t,this.config=e,this.state=s;}getConfig(){return this.config}subscribeConfig(i){return i(this.config),this.configEmitter.subscribe(i)}updateConfig(i){this.config={...this.config,...i},this.configEmitter.emit(this.config);}getState(){return this.state}setState(i){this.state={...this.state,...i},this.stateEmitter.emit(this.state);}subscribeState(i){return i(this.state),this.stateEmitter.subscribe(i)}destroy(){this.reset(),this.stateEmitter.clear(),this.configEmitter.clear(),chunk4J2ZANLB_cjs.h.getInstance().unregister(this.uid);}get rect(){return this.rectProvider?this.rectProvider():null}bindRectProvider(i,t){this.rectProvider=i,t&&(this._onMarkDirtyCb=t);}markRectDirty(){this._onMarkDirtyCb?.();}};var p=class{constructor(i,t){chunk4J2ZANLB_cjs.a(this,"isPressed",false);chunk4J2ZANLB_cjs.a(this,"mapping");chunk4J2ZANLB_cjs.a(this,"targetId");this.update(i,t);}update(i,t){this.isPressed&&this.reset(),this.targetId=i,this.mapping=this.hydrate(t);}hydrate(i){if(!i)return;let t={...i};if(t.type==="mouse")return t.button=t.button??0,t;let{key:e,code:s,keyCode:o}=t;if(e||s||o){t.type="keyboard";let n=Object.values(chunk4J2ZANLB_cjs.b).find(l=>l.code===s||l.key===e||l.keyCode===o);n&&(t.key=e??n.key,t.code=s??n.code,t.keyCode=o??n.keyCode);}return t}press(){if(!this.mapping||this.isPressed)return;this.isPressed=true;let i=this.mapping.type==="keyboard"?chunk4J2ZANLB_cjs.d.KEYDOWN:chunk4J2ZANLB_cjs.d.MOUSEDOWN;this.emitSignal(i);}release(i=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let t=this.mapping.type==="keyboard"?chunk4J2ZANLB_cjs.d.KEYUP:chunk4J2ZANLB_cjs.d.MOUSEUP;this.emitSignal(t),this.mapping.type==="mouse"&&i&&this.emitSignal(chunk4J2ZANLB_cjs.d.CLICK);}move(i){this.mapping?.type==="mouse"&&this.emitSignal(chunk4J2ZANLB_cjs.d.MOUSEMOVE,i);}reset(){this.isPressed&&this.release(false);}async tap(i=true){this.isPressed||(this.press(),await Z(2),this.isPressed&&this.release(i));}emitSignal(i,t={}){!this.targetId||!this.mapping||chunk4J2ZANLB_cjs.h.getInstance().broadcastSignal({targetStageId:this.targetId,type:i,payload:{key:this.mapping.key,code:this.mapping.code,keyCode:this.mapping.keyCode,button:this.mapping.button,point:this.mapping.fixedPoint,...t}});}};var V={isActive:false,isPressed:false,pointerId:null,value:0},B=class extends d{constructor(t,e,s){super(t,s||chunk4J2ZANLB_cjs.c.BUTTON,e,V);chunk4J2ZANLB_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(V),this.emitter.reset();}updateConfig(t){super.updateConfig(t),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(t){this.setState(V),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 q={isActive:false,pointerId:null,vector:{x:0,y:0}},j=.002,J=.3,G=class extends d{constructor(t,e,s){super(t,s||chunk4J2ZANLB_cjs.c.D_PAD,e,q);chunk4J2ZANLB_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 s=this.rect;if(!s)return;let o=s.left+s.width/2,n=s.top+s.height/2,l=s.width/2,u=s.height/2,v=(t.clientX-o)/l,P=(t.clientY-n)/u;if(e&&(v!=chunk4J2ZANLB_cjs.l(v,-1,1)||P!=chunk4J2ZANLB_cjs.l(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let C={x:chunk4J2ZANLB_cjs.l(v,-1,1),y:chunk4J2ZANLB_cjs.l(P,-1,1)};chunk4J2ZANLB_cjs.A(C,this.state.vector,j)||(this.setState({vector:C}),this.handleDigitalKeys(C));}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(q);}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 s=this.config.threshold??.3;if(Math.abs(t)<s&&Math.abs(e)<s){this.state.isActive&&this.reset();return}this.state.isActive||this.setState({isActive:true});let o=chunk4J2ZANLB_cjs.m(this.state.vector.x,t,J),n=chunk4J2ZANLB_cjs.m(this.state.vector.y,e,J),l={x:o,y:n};chunk4J2ZANLB_cjs.A(l,this.state.vector,j)||(this.setState({vector:l}),this.handleDigitalKeys(l));}};var rt={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},H=class extends d{constructor(t,e,s){super(t,s||chunk4J2ZANLB_cjs.c.INPUT_ZONE,e,rt);chunk4J2ZANLB_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 s=this.rect;return s?{x:chunk4J2ZANLB_cjs.w(t-s.left,s.width),y:chunk4J2ZANLB_cjs.w(e-s.top,s.height)}:{x:0,y:0}}get isInterceptorRequired(){return !!(this.config.dynamicWidgetId||this.config.preventFocusLoss)}reset(){this.setState({isDynamicActive:false,dynamicPointerId:null});}};var I=class{constructor(i={}){chunk4J2ZANLB_cjs.a(this,"options");chunk4J2ZANLB_cjs.a(this,"startTime",0);chunk4J2ZANLB_cjs.a(this,"startPos",{x:0,y:0});chunk4J2ZANLB_cjs.a(this,"lastTapTime",0);chunk4J2ZANLB_cjs.a(this,"hasMoved",false);chunk4J2ZANLB_cjs.a(this,"isDoubleTapHolding",false);this.options={tapTime:250,tapDistance:10,doubleTapGap:300,...i};}onPointerDown(i,t){let e=Date.now();this.startTime=e,this.startPos={x:i,y:t},this.hasMoved=false,e-this.lastTapTime<this.options.doubleTapGap?(this.isDoubleTapHolding=true,this.options.onDoubleTapHoldStart?.()):this.isDoubleTapHolding=false;}onPointerMove(i,t){this.hasMoved||Math.hypot(i-this.startPos.x,t-this.startPos.y)>this.options.tapDistance&&(this.hasMoved=true);}onPointerUp(){let i=Date.now(),t=i-this.startTime;this.isDoubleTapHolding?(this.isDoubleTapHolding=false,this.options.onDoubleTapHoldEnd?.(),this.lastTapTime=0):t<=this.options.tapTime&&!this.hasMoved&&(this.options.onTap?.(),i-this.lastTapTime<this.options.doubleTapGap?(this.options.onDoubleTap?.(),this.lastTapTime=0):this.lastTapTime=i);}reset(){this.isDoubleTapHolding&&this.options.onDoubleTapHoldEnd?.(),this.isDoubleTapHolding=false,this.hasMoved=false,this.startTime=0,this.lastTapTime=0;}};var $={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},U=.002,Q=.3,L=class extends d{constructor(t,e,s){super(t,s||chunk4J2ZANLB_cjs.c.JOYSTICK,e,$);chunk4J2ZANLB_cjs.a(this,"emitters");chunk4J2ZANLB_cjs.a(this,"stickEmitter");chunk4J2ZANLB_cjs.a(this,"cursorEmitter");chunk4J2ZANLB_cjs.a(this,"gesture");chunk4J2ZANLB_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 I({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=z(()=>{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 s=this.rect;if(!s)return;let o=s.left+s.width/2,n=s.top+s.height/2,l=s.width/2,u=s.height/2,v=(t.clientX-o)/l,P=(t.clientY-n)/u;if(e&&(v!=chunk4J2ZANLB_cjs.l(v,-1,1)||P!=chunk4J2ZANLB_cjs.l(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let D=chunk4J2ZANLB_cjs.C({x:v,y:P},1,this.config.threshold||.15);chunk4J2ZANLB_cjs.A(D,this.state.vector,U)||(this.setState({vector:D}),this.handleDigitalKeys(D));}handleCursorTick(){let{vector:t,isActive:e}=this.state;if(!e||!this.config.cursorMode||chunk4J2ZANLB_cjs.A(t,{x:0,y:0},U)){this.ticker.stop();return}let s=this.config.cursorSensitivity??1,o={x:t.x*Math.abs(t.x)*s,y:t.y*Math.abs(t.y)*s};(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($),this.gesture.reset(),this.handleRelease(),this.stickEmitter.reset(),this.cursorEmitter.reset();}updateConfig(t){super.updateConfig(t);let e=this.config.targetStageId,s=this.config.mapping||{};this.emitters.up.update(e,s.up),this.emitters.down.update(e,s.down),this.emitters.left.update(e,s.left),this.emitters.right.update(e,s.right),this.stickEmitter.update(e,s.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 s=this.config.threshold??.15;if(Math.hypot(t,e)<s){this.state.isActive&&this.handleRelease();return}this.state.isActive||this.setState({isActive:true});let n=chunk4J2ZANLB_cjs.m(this.state.vector.x,t,Q),l=chunk4J2ZANLB_cjs.m(this.state.vector.y,e,Q),u={x:n,y:l};chunk4J2ZANLB_cjs.A(u,this.state.vector,U)||(this.setState({vector:u}),this.handleDigitalKeys(u)),this.config.cursorMode&&this.ticker.start();}};var ot={isHighlighted:false},F=class extends d{constructor(i,t,e){super(i,e||chunk4J2ZANLB_cjs.c.ROOT_LAYER,t,ot);}reset(){}};var nt={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},y=1,N=class extends d{constructor(t,e,s){super(t,s||chunk4J2ZANLB_cjs.c.TARGET_ZONE,e,nt);chunk4J2ZANLB_cjs.a(this,"hideTimer",null);chunk4J2ZANLB_cjs.a(this,"focusFeedbackTimer",null);chunk4J2ZANLB_cjs.a(this,"throttledMoveExecution");chunk4J2ZANLB_cjs.a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledMoveExecution=T(o=>{this.executeMouseAction(chunk4J2ZANLB_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,chunk4J2ZANLB_cjs.d.MOUSEDOWN);}onPointerMove(t){this.processPhysicalEvent(t,chunk4J2ZANLB_cjs.d.MOUSEMOVE);}onPointerUp(t){this.processPhysicalEvent(t,chunk4J2ZANLB_cjs.d.MOUSEUP),this.processPhysicalEvent(t,chunk4J2ZANLB_cjs.d.CLICK);}onPointerCancel(t){this.processPhysicalEvent(t,chunk4J2ZANLB_cjs.d.MOUSEUP);}processPhysicalEvent(t,e){let s=this.rect;if(!s)return;let o={x:chunk4J2ZANLB_cjs.w(t.clientX-s.left,s.width),y:chunk4J2ZANLB_cjs.w(t.clientY-s.top,s.height)};this.handleSignal({targetStageId:this.uid,type:e,payload:{point:o,button:t.button}});}handleSignal(t){let{type:e,payload:s}=t;switch(this.ensureFocus(),e){case chunk4J2ZANLB_cjs.d.KEYDOWN:case chunk4J2ZANLB_cjs.d.KEYUP:this.delegates.dispatchKeyboardEvent?.(e,s);break;case chunk4J2ZANLB_cjs.d.MOUSEMOVE:s.point?this.updateCursorPosition(s.point):s.delta&&this.updateCursorPositionByDelta(s.delta),this.config.cursorEnabled&&this.showCursor(),this.throttledMoveExecution(s);break;case chunk4J2ZANLB_cjs.d.MOUSEDOWN:case chunk4J2ZANLB_cjs.d.MOUSEUP:case chunk4J2ZANLB_cjs.d.CLICK:s.point&&this.updateCursorPosition(s.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(e.startsWith(chunk4J2ZANLB_cjs.d.MOUSE)?e.replace(chunk4J2ZANLB_cjs.d.MOUSE,chunk4J2ZANLB_cjs.d.POINTER):e,s);break}}executeMouseAction(t,e){let s=this.rect;if(!s)return;t===chunk4J2ZANLB_cjs.d.POINTERDOWN&&this.setState({isPointerDown:true}),t===chunk4J2ZANLB_cjs.d.POINTERUP&&this.setState({isPointerDown:false});let o=e.point||this.state.position,n=chunk4J2ZANLB_cjs.l(s.left+chunk4J2ZANLB_cjs.v(o.x,s.width),s.left+y,s.left+s.width-y),l=chunk4J2ZANLB_cjs.l(s.top+chunk4J2ZANLB_cjs.v(o.y,s.height),s.top+y,s.top+s.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=chunk4J2ZANLB_cjs.l(t.left+chunk4J2ZANLB_cjs.v(this.state.position.x,t.width),t.left+y,t.left+t.width-y),s=chunk4J2ZANLB_cjs.l(t.top+chunk4J2ZANLB_cjs.v(this.state.position.y,t.height),t.top+y,t.top+t.height-y);this.delegates.reclaimFocusAtPos?.(e,s,()=>this.triggerFocusFeedback());}triggerFocusFeedback(){this.setState({isFocusReturning:true}),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.focusFeedbackTimer=setTimeout(()=>this.setState({isFocusReturning:false}),500);}updateCursorPosition(t){chunk4J2ZANLB_cjs.A(t,this.state.position)||this.setState({position:{...t}});}updateCursorPositionByDelta(t){if(chunk4J2ZANLB_cjs.A(t,{x:0,y:0}))return;let e=this.rect;if(!e)return;let s=chunk4J2ZANLB_cjs.w(t.x,e.width),o=chunk4J2ZANLB_cjs.w(t.y,e.height);this.updateCursorPosition({x:chunk4J2ZANLB_cjs.l(this.state.position.x+s,0,100),y:chunk4J2ZANLB_cjs.l(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(chunk4J2ZANLB_cjs.d.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:false,isPointerDown:false,isFocusReturning:false});}};var tt={isActive:false,isPressed:false,pointerId:null,value:0},W=class extends d{constructor(t,e,s){super(t,s||chunk4J2ZANLB_cjs.c.TRACKPAD,e,tt);chunk4J2ZANLB_cjs.a(this,"lastPointerPos",{x:0,y:0});chunk4J2ZANLB_cjs.a(this,"gesture");chunk4J2ZANLB_cjs.a(this,"emitter");let o=e.mapping||{type:"mouse"};this.emitter=new p(e.targetStageId,o),this.gesture=new I({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,s=t.clientY-this.lastPointerPos.y,o=this.rect;if(!o)return;let n=e/o.width*100*(this.config.sensitivity??1),l=s/o.height*100*(this.config.sensitivity??1),u={x:n,y:l};chunk4J2ZANLB_cjs.A(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(tt);}};var Ue={ActionTypes:chunk4J2ZANLB_cjs.d,Context:chunk4J2ZANLB_cjs.f,Keys:chunk4J2ZANLB_cjs.b,Types:chunk4J2ZANLB_cjs.c};Object.defineProperty(exports,"ACTION_TYPES",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.d}});Object.defineProperty(exports,"CMP_TYPES",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.c}});Object.defineProperty(exports,"CONTEXT",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.f}});Object.defineProperty(exports,"KEYS",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.b}});Object.defineProperty(exports,"Registry",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.h}});Object.defineProperty(exports,"VALID_UNITS",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.e}});Object.defineProperty(exports,"setGlobalSignalHandler",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.g}});exports.BaseEntity=d;exports.ButtonCore=B;exports.DPadCore=G;exports.ElementObserver=k;exports.GamepadManager=M;exports.InputZoneCore=H;exports.JoystickCore=L;exports.OmniPad=Ue;exports.RootLayerCore=F;exports.TargetZoneCore=N;exports.TrackpadCore=W;exports.WindowManager=Y;
|
|
1
|
+
'use strict';var chunkU52W5J3K_cjs=require('./chunk-U52W5J3K.cjs'),chunkVHF3K5X6_cjs=require('./chunk-VHF3K5X6.cjs'),chunkZHPNS73J_cjs=require('./chunk-ZHPNS73J.cjs');var S=class{constructor(){chunkZHPNS73J_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 l=class{constructor(s,t,e,i){chunkZHPNS73J_cjs.a(this,"uid");chunkZHPNS73J_cjs.a(this,"type");chunkZHPNS73J_cjs.a(this,"config");chunkZHPNS73J_cjs.a(this,"state");chunkZHPNS73J_cjs.a(this,"rectProvider",null);chunkZHPNS73J_cjs.a(this,"_onMarkDirtyCb",null);chunkZHPNS73J_cjs.a(this,"stateEmitter",new S);chunkZHPNS73J_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(),chunkZHPNS73J_cjs.h.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 c=class{constructor(s,t){chunkZHPNS73J_cjs.a(this,"isPressed",false);chunkZHPNS73J_cjs.a(this,"mapping");chunkZHPNS73J_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 a=Object.values(chunkZHPNS73J_cjs.b).find(p=>p.code===i||p.key===e||p.keyCode===o);a&&(t.key=e??a.key,t.code=i??a.code,t.keyCode=o??a.keyCode);}return t}press(){if(!this.mapping||this.isPressed)return;this.isPressed=true;let s=this.mapping.type==="keyboard"?chunkZHPNS73J_cjs.d.KEYDOWN:chunkZHPNS73J_cjs.d.MOUSEDOWN;this.emitSignal(s);}release(s=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let t=this.mapping.type==="keyboard"?chunkZHPNS73J_cjs.d.KEYUP:chunkZHPNS73J_cjs.d.MOUSEUP;this.emitSignal(t),this.mapping.type==="mouse"&&s&&this.emitSignal(chunkZHPNS73J_cjs.d.CLICK);}move(s){this.mapping?.type==="mouse"&&this.emitSignal(chunkZHPNS73J_cjs.d.MOUSEMOVE,s);}reset(){this.isPressed&&this.release(false);}async tap(s=true){this.isPressed||(this.press(),await chunkVHF3K5X6_cjs.c(2),this.isPressed&&this.release(s));}emitSignal(s,t={}){this.mapping&&chunkZHPNS73J_cjs.h.getInstance().broadcastSignal({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 x={isActive:false,isPressed:false,pointerId:null,value:0},w=class extends l{constructor(t,e,i){super(t,i||chunkZHPNS73J_cjs.c.BUTTON,e,x);chunkZHPNS73J_cjs.a(this,"emitter");this.emitter=new c(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(x),this.emitter.reset();}updateConfig(t){super.updateConfig(t),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(t){this.setState(x),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 K={isActive:false,pointerId:null,vector:{x:0,y:0}},X=.002,L=.3,M=class extends l{constructor(t,e,i){super(t,i||chunkZHPNS73J_cjs.c.D_PAD,e,K);chunkZHPNS73J_cjs.a(this,"emitters");let o=e.targetStageId;this.emitters={up:new c(o,e.mapping?.up),down:new c(o,e.mapping?.down),left:new c(o,e.mapping?.left),right:new c(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,a=i.top+i.height/2,p=i.width/2,f=i.height/2,P=(t.clientX-o)/p,b=(t.clientY-a)/f;if(e&&(P!=chunkU52W5J3K_cjs.d(P,-1,1)||b!=chunkU52W5J3K_cjs.d(b,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let A={x:chunkU52W5J3K_cjs.d(P,-1,1),y:chunkU52W5J3K_cjs.d(b,-1,1)};chunkU52W5J3K_cjs.s(A,this.state.vector,X)||(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(K);}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=chunkU52W5J3K_cjs.e(this.state.vector.x,t,L),a=chunkU52W5J3K_cjs.e(this.state.vector.y,e,L),p={x:o,y:a};chunkU52W5J3K_cjs.s(p,this.state.vector,X)||(this.setState({vector:p}),this.handleDigitalKeys(p));}};var q={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},k=class extends l{constructor(t,e,i){super(t,i||chunkZHPNS73J_cjs.c.INPUT_ZONE,e,q);chunkZHPNS73J_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:chunkU52W5J3K_cjs.o(t-i.left,i.width),y:chunkU52W5J3K_cjs.o(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={}){chunkZHPNS73J_cjs.a(this,"options");chunkZHPNS73J_cjs.a(this,"startTime",0);chunkZHPNS73J_cjs.a(this,"startPos",{x:0,y:0});chunkZHPNS73J_cjs.a(this,"lastTapTime",0);chunkZHPNS73J_cjs.a(this,"hasMoved",false);chunkZHPNS73J_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 W={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},O=.002,G=.3,R=class extends l{constructor(t,e,i){super(t,i||chunkZHPNS73J_cjs.c.JOYSTICK,e,W);chunkZHPNS73J_cjs.a(this,"emitters");chunkZHPNS73J_cjs.a(this,"stickEmitter");chunkZHPNS73J_cjs.a(this,"cursorEmitter");chunkZHPNS73J_cjs.a(this,"gesture");chunkZHPNS73J_cjs.a(this,"ticker");let o=e.targetStageId,a=e.mapping||{};this.emitters={up:new c(o,a.up),down:new c(o,a.down),left:new c(o,a.left),right:new c(o,a.right)},this.stickEmitter=new c(o,a.stick),this.cursorEmitter=new c(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=chunkVHF3K5X6_cjs.b(()=>{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,a=i.top+i.height/2,p=i.width/2,f=i.height/2,P=(t.clientX-o)/p,b=(t.clientY-a)/f;if(e&&(P!=chunkU52W5J3K_cjs.d(P,-1,1)||b!=chunkU52W5J3K_cjs.d(b,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let D=chunkU52W5J3K_cjs.u({x:P,y:b},1,this.config.threshold||.15);chunkU52W5J3K_cjs.s(D,this.state.vector,O)||(this.setState({vector:D}),this.handleDigitalKeys(D));}handleCursorTick(){let{vector:t,isActive:e}=this.state;if(!e||!this.config.cursorMode||chunkU52W5J3K_cjs.s(t,{x:0,y:0},O)){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(W),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 a=chunkU52W5J3K_cjs.e(this.state.vector.x,t,G),p=chunkU52W5J3K_cjs.e(this.state.vector.y,e,G),f={x:a,y:p};chunkU52W5J3K_cjs.s(f,this.state.vector,O)||(this.setState({vector:f}),this.handleDigitalKeys(f)),this.config.cursorMode&&this.ticker.start();}};var z={isHighlighted:false},Y=class extends l{constructor(s,t,e){super(s,e||chunkZHPNS73J_cjs.c.ROOT_LAYER,t,z);}reset(){}};var j={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},v=1,H=class extends l{constructor(t,e,i){super(t,i||chunkZHPNS73J_cjs.c.TARGET_ZONE,e,j);chunkZHPNS73J_cjs.a(this,"hideTimer",null);chunkZHPNS73J_cjs.a(this,"focusFeedbackTimer",null);chunkZHPNS73J_cjs.a(this,"throttledMoveExecution");chunkZHPNS73J_cjs.a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledMoveExecution=chunkVHF3K5X6_cjs.a(o=>{this.executeMouseAction(chunkZHPNS73J_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,chunkZHPNS73J_cjs.d.MOUSEDOWN);}onPointerMove(t){this.processPhysicalEvent(t,chunkZHPNS73J_cjs.d.MOUSEMOVE);}onPointerUp(t){this.processPhysicalEvent(t,chunkZHPNS73J_cjs.d.MOUSEUP),this.processPhysicalEvent(t,chunkZHPNS73J_cjs.d.CLICK);}onPointerCancel(t){this.processPhysicalEvent(t,chunkZHPNS73J_cjs.d.MOUSEUP);}processPhysicalEvent(t,e){let i=this.rect;if(!i)return;let o={x:chunkU52W5J3K_cjs.o(t.clientX-i.left,i.width),y:chunkU52W5J3K_cjs.o(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 chunkZHPNS73J_cjs.d.KEYDOWN:case chunkZHPNS73J_cjs.d.KEYUP:this.delegates.dispatchKeyboardEvent?.(e,i);break;case chunkZHPNS73J_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 chunkZHPNS73J_cjs.d.MOUSEDOWN:case chunkZHPNS73J_cjs.d.MOUSEUP:case chunkZHPNS73J_cjs.d.CLICK:i.point&&this.updateCursorPosition(i.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(e.startsWith(chunkZHPNS73J_cjs.d.MOUSE)?e.replace(chunkZHPNS73J_cjs.d.MOUSE,chunkZHPNS73J_cjs.d.POINTER):e,i);break}}executeMouseAction(t,e){let i=this.rect;if(!i)return;t===chunkZHPNS73J_cjs.d.POINTERDOWN&&this.setState({isPointerDown:true}),t===chunkZHPNS73J_cjs.d.POINTERUP&&this.setState({isPointerDown:false});let o=e.point||this.state.position,a=chunkU52W5J3K_cjs.d(i.left+chunkU52W5J3K_cjs.n(o.x,i.width),i.left+v,i.left+i.width-v),p=chunkU52W5J3K_cjs.d(i.top+chunkU52W5J3K_cjs.n(o.y,i.height),i.top+v,i.top+i.height-v);this.delegates.dispatchPointerEventAtPos?.(t,a,p,{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=chunkU52W5J3K_cjs.d(t.left+chunkU52W5J3K_cjs.n(this.state.position.x,t.width),t.left+v,t.left+t.width-v),i=chunkU52W5J3K_cjs.d(t.top+chunkU52W5J3K_cjs.n(this.state.position.y,t.height),t.top+v,t.top+t.height-v);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){chunkU52W5J3K_cjs.s(t,this.state.position)||this.setState({position:{...t}});}updateCursorPositionByDelta(t){if(chunkU52W5J3K_cjs.s(t,{x:0,y:0}))return;let e=this.rect;if(!e)return;let i=chunkU52W5J3K_cjs.o(t.x,e.width),o=chunkU52W5J3K_cjs.o(t.y,e.height);this.updateCursorPosition({x:chunkU52W5J3K_cjs.d(this.state.position.x+i,0,100),y:chunkU52W5J3K_cjs.d(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(chunkZHPNS73J_cjs.d.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:false,isPointerDown:false,isFocusReturning:false});}};var Z={isActive:false,isPressed:false,pointerId:null,value:0},U=class extends l{constructor(t,e,i){super(t,i||chunkZHPNS73J_cjs.c.TRACKPAD,e,Z);chunkZHPNS73J_cjs.a(this,"lastPointerPos",{x:0,y:0});chunkZHPNS73J_cjs.a(this,"gesture");chunkZHPNS73J_cjs.a(this,"emitter");let o=e.mapping||{type:"mouse"};this.emitter=new c(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 a=e/o.width*100*(this.config.sensitivity??1),p=i/o.height*100*(this.config.sensitivity??1),f={x:a,y:p};chunkU52W5J3K_cjs.s(f,{x:0,y:0})||this.emitter.move({delta:f}),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(Z);}};var ye={ActionTypes:chunkZHPNS73J_cjs.d,Context:chunkZHPNS73J_cjs.f,Keys:chunkZHPNS73J_cjs.b,Types:chunkZHPNS73J_cjs.c};Object.defineProperty(exports,"ACTION_TYPES",{enumerable:true,get:function(){return chunkZHPNS73J_cjs.d}});Object.defineProperty(exports,"CMP_TYPES",{enumerable:true,get:function(){return chunkZHPNS73J_cjs.c}});Object.defineProperty(exports,"CONTEXT",{enumerable:true,get:function(){return chunkZHPNS73J_cjs.f}});Object.defineProperty(exports,"KEYS",{enumerable:true,get:function(){return chunkZHPNS73J_cjs.b}});Object.defineProperty(exports,"Registry",{enumerable:true,get:function(){return chunkZHPNS73J_cjs.h}});Object.defineProperty(exports,"VALID_UNITS",{enumerable:true,get:function(){return chunkZHPNS73J_cjs.e}});Object.defineProperty(exports,"setGlobalSignalHandler",{enumerable:true,get:function(){return chunkZHPNS73J_cjs.g}});exports.BaseEntity=l;exports.ButtonCore=w;exports.DPadCore=M;exports.InputZoneCore=k;exports.JoystickCore=R;exports.OmniPad=ye;exports.RootLayerCore=Y;exports.TargetZoneCore=H;exports.TrackpadCore=U;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { I as
|
|
2
|
-
export {
|
|
1
|
+
import { I as InputActionSignal, V as Vec2, E as EntityType, A as AbstractRect, B as ButtonConfig, a as AbstractPointerEvent, D as DPadConfig, b as InputZoneConfig, c as AnyFunction, J as JoystickConfig, d as BaseConfig, T as TargetZoneConfig, e as TrackpadConfig } from './index-DVegtw8s.cjs';
|
|
2
|
+
export { f as ACTION_TYPES, g as ActionMapping, h as AnchorPoint, i as AnyConfig, j as AnyEntityType, k as BuiltInActionType, C as CMP_TYPES, l as CONTEXT, m as ConfigTreeNode, n as CssUnit, F as FlatConfigItem, o as FlexibleLength, G as GamepadMappingConfig, p as InputActionType, K as KEYS, q as KeyMapping, L as LayoutBox, O as OmniPadProfile, P as ParsedLength, S as StageId, r as StandardButton, s as VALID_UNITS, W as WidgetId, t as WidgetType, Z as ZoneId, u as ZoneType } from './index-DVegtw8s.cjs';
|
|
3
|
+
import { I as ICoreEntity, a as ISpatial, b as IResettable, c as IConfigurable, d as IStateful, e as IPointerHandler, f as IProgrammatic, g as IDependencyBindable, h as ISignalReceiver } from './traits-D6ePqSA6.cjs';
|
|
4
|
+
export { i as IIdentifiable, j as ILifecycle } from './traits-D6ePqSA6.cjs';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Interface for the global Registry singleton.
|
|
@@ -170,127 +172,6 @@ interface DPadState extends InteractionState, AxisLogicState {
|
|
|
170
172
|
interface JoystickState extends InteractionState, AxisLogicState, ButtonLogicState {
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
/**
|
|
174
|
-
* GamepadManager
|
|
175
|
-
*
|
|
176
|
-
* A singleton service that polls the browser Gamepad API via requestAnimationFrame.
|
|
177
|
-
* It translates physical hardware inputs into programmatic signals sent to
|
|
178
|
-
* virtual entities registered in the system.
|
|
179
|
-
*
|
|
180
|
-
* Handles:
|
|
181
|
-
* 1. Button edge detection (Down/Up).
|
|
182
|
-
* 2. D-Pad to vector conversion.
|
|
183
|
-
* 3. Analog stick deadzone processing.
|
|
184
|
-
*/
|
|
185
|
-
declare class GamepadManager {
|
|
186
|
-
private isRunning;
|
|
187
|
-
private config;
|
|
188
|
-
private lastButtonStates;
|
|
189
|
-
private constructor();
|
|
190
|
-
/**
|
|
191
|
-
* Retrieves the global singleton instance of the GamepadManager.
|
|
192
|
-
*/
|
|
193
|
-
static getInstance(): GamepadManager;
|
|
194
|
-
/**
|
|
195
|
-
* Updates the current gamepad mapping configuration.
|
|
196
|
-
*
|
|
197
|
-
* @param config - The mapping of physical inputs to virtual component IDs (UID).
|
|
198
|
-
*/
|
|
199
|
-
setConfig(config: GamepadMappingConfig[]): void;
|
|
200
|
-
/** Return the current gamepad mapping configuration. */
|
|
201
|
-
getConfig(): Readonly<GamepadMappingConfig[] | null>;
|
|
202
|
-
/**
|
|
203
|
-
* Starts the polling loop and listens for gamepad connection events.
|
|
204
|
-
*/
|
|
205
|
-
start(): void;
|
|
206
|
-
/**
|
|
207
|
-
* Stops the polling loop.
|
|
208
|
-
*/
|
|
209
|
-
stop(): void;
|
|
210
|
-
/**
|
|
211
|
-
* The core polling loop executing at the browser's refresh rate.
|
|
212
|
-
*/
|
|
213
|
-
private loop;
|
|
214
|
-
/**
|
|
215
|
-
* Process binary button inputs with edge detection.
|
|
216
|
-
*/
|
|
217
|
-
private processButtons;
|
|
218
|
-
/**
|
|
219
|
-
* Translates physical D-Pad buttons into a normalized vector.
|
|
220
|
-
*/
|
|
221
|
-
private processDPad;
|
|
222
|
-
/**
|
|
223
|
-
* Process analog stick movements with deadzone logic.
|
|
224
|
-
*/
|
|
225
|
-
private processAxes;
|
|
226
|
-
/**
|
|
227
|
-
* Locates a virtual entity and triggers its programmatic interface.
|
|
228
|
-
*
|
|
229
|
-
* @param uid - The Entity ID (UID) of the target.
|
|
230
|
-
* @param action - The type of trigger ('down', 'up', or 'vector').
|
|
231
|
-
* @param payload - Optional data for vector movements.
|
|
232
|
-
*/
|
|
233
|
-
private triggerVirtualEntity;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* A centralized observation pool for DOM elements.
|
|
238
|
-
*
|
|
239
|
-
* This class provides a high-performance wrapper around `ResizeObserver` (RO) and
|
|
240
|
-
* `IntersectionObserver` (IO). By pooling all element observations into single
|
|
241
|
-
* native observer instances and utilizing `requestAnimationFrame` (rAF) throttling,
|
|
242
|
-
* it significantly reduces memory footprint and prevents layout thrashing.
|
|
243
|
-
*
|
|
244
|
-
* It supports deterministic unregistration via UIDs, making it ideal for
|
|
245
|
-
* framework adapters (like Vue or React) where DOM references may become unstable
|
|
246
|
-
* during unmounting.
|
|
247
|
-
*/
|
|
248
|
-
declare class ElementObserver {
|
|
249
|
-
private _ro;
|
|
250
|
-
private _roRegistry;
|
|
251
|
-
private _elToRoCb;
|
|
252
|
-
private _io;
|
|
253
|
-
private _ioRegistry;
|
|
254
|
-
private _elToIoCb;
|
|
255
|
-
private constructor();
|
|
256
|
-
static getInstance(): ElementObserver;
|
|
257
|
-
/**
|
|
258
|
-
* Starts observing size changes for a specific element.
|
|
259
|
-
*
|
|
260
|
-
* @param uid - The unique entity ID associated with the observation.
|
|
261
|
-
* @param el - The target DOM element to observe.
|
|
262
|
-
* @param cb - Callback triggered when the element's size changes.
|
|
263
|
-
*/
|
|
264
|
-
observeResize(uid: string, el: Element, cb: () => void): void;
|
|
265
|
-
/**
|
|
266
|
-
* Stops observing size changes for the entity identified by the UID.
|
|
267
|
-
*
|
|
268
|
-
* @param uid - The unique entity ID to unregister.
|
|
269
|
-
*/
|
|
270
|
-
unobserveResize(uid: string): void;
|
|
271
|
-
/**
|
|
272
|
-
* Starts observing visibility (intersection) changes for a specific element.
|
|
273
|
-
*
|
|
274
|
-
* @param uid - The unique entity ID associated with the observation.
|
|
275
|
-
* @param el - The target DOM element to observe.
|
|
276
|
-
* @param cb - Callback triggered when visibility enters or exits the viewport.
|
|
277
|
-
*/
|
|
278
|
-
observeIntersect(uid: string, el: Element, cb: (isIntersecting: boolean) => void): void;
|
|
279
|
-
/**
|
|
280
|
-
* Stops observing intersection changes for the entity identified by the UID.
|
|
281
|
-
*
|
|
282
|
-
* @param uid - The unique entity ID to unregister.
|
|
283
|
-
*/
|
|
284
|
-
unobserveIntersect(uid: string): void;
|
|
285
|
-
/**
|
|
286
|
-
* Disconnects all observers (RO and IO) associated with a specific UID.
|
|
287
|
-
* Usually called during component destruction for thorough cleanup.
|
|
288
|
-
*
|
|
289
|
-
* @param uid - The unique entity ID to fully disconnect.
|
|
290
|
-
*/
|
|
291
|
-
disconnect(uid: string): void;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
175
|
/**
|
|
295
176
|
* Configures the global fallback handler for action signals.
|
|
296
177
|
*
|
|
@@ -334,51 +215,6 @@ declare class Registry implements IRegistry {
|
|
|
334
215
|
broadcastSignal(signal: InputActionSignal): void;
|
|
335
216
|
}
|
|
336
217
|
|
|
337
|
-
/**
|
|
338
|
-
* Global Input Manager Singleton.
|
|
339
|
-
*
|
|
340
|
-
* Responsible for monitoring global browser events (resize, blur, visibility)
|
|
341
|
-
* and coordinating system-wide resets to prevent stuck inputs.
|
|
342
|
-
*/
|
|
343
|
-
declare class WindowManager {
|
|
344
|
-
/** Internal flag to prevent multiple event registrations */
|
|
345
|
-
private _isListening;
|
|
346
|
-
/** A throttled version of the reset logic */
|
|
347
|
-
private throttledReset;
|
|
348
|
-
private constructor();
|
|
349
|
-
/**
|
|
350
|
-
* Retrieves the global instance of the WindowManager.
|
|
351
|
-
* Ensures uniqueness across multiple bundles or modules.
|
|
352
|
-
*/
|
|
353
|
-
static getInstance(): WindowManager;
|
|
354
|
-
/**
|
|
355
|
-
* Manually triggers a system-wide input reset via Registry.
|
|
356
|
-
*/
|
|
357
|
-
private handleGlobalReset;
|
|
358
|
-
private handleResizeReset;
|
|
359
|
-
private handleBlurReset;
|
|
360
|
-
private handleScrollReset;
|
|
361
|
-
private handleVisibilityChangeReset;
|
|
362
|
-
/**
|
|
363
|
-
* Initializes global safety listeners.
|
|
364
|
-
* Should be called once at the root component lifecycle (e.g., VirtualLayer).
|
|
365
|
-
*/
|
|
366
|
-
init(): void;
|
|
367
|
-
/**
|
|
368
|
-
* Toggle full-screen state of the page.
|
|
369
|
-
* @param element Target HTMLElement
|
|
370
|
-
*/
|
|
371
|
-
toggleFullscreen(element?: HTMLElement): Promise<void>;
|
|
372
|
-
/**
|
|
373
|
-
* Full-screen status query provided to the UI layer.
|
|
374
|
-
*/
|
|
375
|
-
isFullscreen(): boolean;
|
|
376
|
-
/**
|
|
377
|
-
* Detaches all global listeners.
|
|
378
|
-
*/
|
|
379
|
-
destroy(): void;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
218
|
/**
|
|
383
219
|
* Represents a callback function for the emitter.
|
|
384
220
|
* @template T - The type of data being broadcasted.
|
|
@@ -1198,4 +1034,4 @@ declare const OmniPad: {
|
|
|
1198
1034
|
};
|
|
1199
1035
|
};
|
|
1200
1036
|
|
|
1201
|
-
export { AbstractPointerEvent, AbstractRect, AnyFunction, type AxisLogicState, BaseConfig, BaseEntity, ButtonConfig, ButtonCore, type ButtonLogicState, type ButtonState, type CursorState, DPadConfig, DPadCore, type DPadState,
|
|
1037
|
+
export { AbstractPointerEvent, AbstractRect, AnyFunction, type AxisLogicState, BaseConfig, BaseEntity, ButtonConfig, ButtonCore, type ButtonLogicState, type ButtonState, type CursorState, DPadConfig, DPadCore, type DPadState, EntityType, 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, setGlobalSignalHandler };
|