@omnipad/core 0.4.3 → 0.4.5
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-4J2ZANLB.cjs +1 -0
- package/dist/chunk-W7OR5ESR.mjs +1 -0
- package/dist/{index-DlGCSMP1.d.cts → index-CT1fDlB9.d.cts} +39 -14
- package/dist/{index-DlGCSMP1.d.ts → index-CT1fDlB9.d.ts} +39 -14
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +105 -22
- package/dist/index.d.ts +105 -22
- package/dist/index.mjs +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +36 -2
- package/dist/utils/index.d.ts +36 -2
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-MSERY5BP.mjs +0 -1
- package/dist/chunk-PAGWIRTX.cjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as ICoreEntity, V as Vec2, G as GamepadMappingConfig,
|
|
2
|
-
export { o as ACTION_TYPES, p as ActionMapping, q as AnchorPoint, r as AnyConfig, s as AnyEntityType, t as BuiltInActionType, C as CMP_TYPES, u as CONTEXT, v as ConfigTreeNode, F as FlatConfigItem,
|
|
1
|
+
import { I as ICoreEntity, a as InputActionSignal, V as Vec2, G as GamepadMappingConfig, b as ISpatial, c as IResettable, d as IConfigurable, e as IStateful, E as EntityType, A as AbstractRect, B as ButtonConfig, f as IPointerHandler, g as IProgrammatic, h as AbstractPointerEvent, D as DPadConfig, i as InputZoneConfig, j as IDependencyBindable, k as AnyFunction, J as JoystickConfig, l as BaseConfig, T as TargetZoneConfig, m as ISignalReceiver, n as TrackpadConfig } from './index-CT1fDlB9.js';
|
|
2
|
+
export { o as ACTION_TYPES, p as ActionMapping, q as AnchorPoint, r as AnyConfig, s as AnyEntityType, t as BuiltInActionType, C as CMP_TYPES, u as CONTEXT, v as ConfigTreeNode, w as CssUnit, F as FlatConfigItem, x as FlexibleLength, y as GamepadProfile, z as IIdentifiable, H as ILifecycle, K as InputActionType, L as KEYS, M as KeyMapping, N as LayoutBox, P as ParsedLength, S as StageId, O as StandardButton, Q as VALID_UNITS, W as WidgetId, R as WidgetType, Z as ZoneId, U as ZoneType } from './index-CT1fDlB9.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Interface for the global Registry singleton.
|
|
@@ -55,11 +55,26 @@ interface IRegistry {
|
|
|
55
55
|
* Essential for cutting off active input signals (e.g., stuck keys) during profile reloads.
|
|
56
56
|
*/
|
|
57
57
|
resetAll(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Triggers the markRectDirty() method on all compatible entities.
|
|
60
|
+
* Essential for calibrating logical position during window resizes or scrolls.
|
|
61
|
+
*/
|
|
62
|
+
markAllRectDirty(): void;
|
|
58
63
|
/**
|
|
59
64
|
* Clears all registered entities.
|
|
60
65
|
* Used for system resets or full application unmounts.
|
|
61
66
|
*/
|
|
62
67
|
clear(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Dispatches an input action signal to a specific target entity or a global handler.
|
|
70
|
+
*
|
|
71
|
+
* @param signal - The action signal object containing the target ID and payload data.
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* dispatcher.broadcastSignal({ targetStageId: 'player_1', type: 'KEYDOWN' });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
broadcastSignal(signal: InputActionSignal): void;
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
/**
|
|
@@ -218,6 +233,76 @@ declare class GamepadManager {
|
|
|
218
233
|
private triggerVirtualEntity;
|
|
219
234
|
}
|
|
220
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
|
+
/**
|
|
295
|
+
* Configures the global fallback handler for action signals.
|
|
296
|
+
*
|
|
297
|
+
* @param handler - A callback function that processes signals when no specific
|
|
298
|
+
* entity target is found.
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* // In a browser environment:
|
|
302
|
+
* setGlobalSignalHandler((signal) => window.postMessage(signal, '*'));
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
declare function setGlobalSignalHandler(handler: (signal: InputActionSignal) => void): void;
|
|
221
306
|
/**
|
|
222
307
|
* Global Registry Singleton.
|
|
223
308
|
*
|
|
@@ -245,7 +330,8 @@ declare class Registry implements IRegistry {
|
|
|
245
330
|
destroyByRoot(rootUid: string): void;
|
|
246
331
|
clear(): void;
|
|
247
332
|
resetAll(): void;
|
|
248
|
-
|
|
333
|
+
markAllRectDirty(): void;
|
|
334
|
+
broadcastSignal(signal: InputActionSignal): void;
|
|
249
335
|
}
|
|
250
336
|
|
|
251
337
|
/**
|
|
@@ -332,7 +418,7 @@ declare class SimpleEmitter<T> {
|
|
|
332
418
|
* Base abstract class for all logic entities in the system.
|
|
333
419
|
* Provides fundamental identity management, state subscription, and spatial awareness.
|
|
334
420
|
*/
|
|
335
|
-
declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpatial, IResettable, IConfigurable<TConfig>,
|
|
421
|
+
declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpatial, IResettable, IConfigurable<TConfig>, IStateful<TState> {
|
|
336
422
|
readonly uid: string;
|
|
337
423
|
readonly type: EntityType;
|
|
338
424
|
protected config: TConfig;
|
|
@@ -340,22 +426,19 @@ declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpat
|
|
|
340
426
|
protected rectProvider: (() => AbstractRect) | null;
|
|
341
427
|
private _onMarkDirtyCb;
|
|
342
428
|
protected stateEmitter: SimpleEmitter<TState>;
|
|
429
|
+
protected configEmitter: SimpleEmitter<TConfig>;
|
|
343
430
|
constructor(uid: string, type: EntityType, initialConfig: TConfig, initialState: TState);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
protected setState(partialState: Partial<TState>): void;
|
|
431
|
+
getConfig(): Readonly<TConfig>;
|
|
432
|
+
subscribeConfig(cb: (config: TConfig) => void): () => void;
|
|
433
|
+
updateConfig(newConfig: Partial<TConfig>): void;
|
|
434
|
+
getState(): Readonly<TState>;
|
|
435
|
+
setState(partialState: Partial<TState>): void;
|
|
436
|
+
subscribeState(cb: (state: TState) => void): () => void;
|
|
351
437
|
destroy(): void;
|
|
352
438
|
abstract reset(): void;
|
|
353
439
|
get rect(): AbstractRect | null;
|
|
354
440
|
bindRectProvider(provider: () => AbstractRect, onMarkDirty?: () => void): void;
|
|
355
441
|
markRectDirty(): void;
|
|
356
|
-
updateConfig(newConfig: Partial<TConfig>): void;
|
|
357
|
-
getState(): Readonly<TState>;
|
|
358
|
-
getConfig(): Readonly<TConfig>;
|
|
359
442
|
}
|
|
360
443
|
|
|
361
444
|
/**
|
|
@@ -370,7 +453,7 @@ declare class ButtonCore extends BaseEntity<ButtonConfig, ButtonState> implement
|
|
|
370
453
|
* @param uid - The unique entity ID.
|
|
371
454
|
* @param config - The flat configuration object for the button.
|
|
372
455
|
*/
|
|
373
|
-
constructor(uid: string, config: ButtonConfig);
|
|
456
|
+
constructor(uid: string, config: ButtonConfig, customTypeName?: EntityType);
|
|
374
457
|
get activePointerId(): number | null;
|
|
375
458
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
376
459
|
onPointerUp(e: AbstractPointerEvent): void;
|
|
@@ -394,7 +477,7 @@ declare class ButtonCore extends BaseEntity<ButtonConfig, ButtonState> implement
|
|
|
394
477
|
*/
|
|
395
478
|
declare class DPadCore extends BaseEntity<DPadConfig, DPadState> implements IPointerHandler, IProgrammatic {
|
|
396
479
|
private emitters;
|
|
397
|
-
constructor(uid: string, config: DPadConfig);
|
|
480
|
+
constructor(uid: string, config: DPadConfig, customTypeName?: EntityType);
|
|
398
481
|
get activePointerId(): number | null;
|
|
399
482
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
400
483
|
onPointerMove(e: AbstractPointerEvent): void;
|
|
@@ -422,7 +505,7 @@ declare class DPadCore extends BaseEntity<DPadConfig, DPadState> implements IPoi
|
|
|
422
505
|
*/
|
|
423
506
|
declare class InputZoneCore extends BaseEntity<InputZoneConfig, InputZoneState> implements IPointerHandler, IDependencyBindable {
|
|
424
507
|
private delegates;
|
|
425
|
-
constructor(uid: string, config: InputZoneConfig);
|
|
508
|
+
constructor(uid: string, config: InputZoneConfig, customTypeName?: EntityType);
|
|
426
509
|
bindDelegate(key: string, delegate: AnyFunction): void;
|
|
427
510
|
get activePointerId(): number | null;
|
|
428
511
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
@@ -453,7 +536,7 @@ declare class JoystickCore extends BaseEntity<JoystickConfig, JoystickState> imp
|
|
|
453
536
|
private cursorEmitter;
|
|
454
537
|
private gesture;
|
|
455
538
|
private ticker;
|
|
456
|
-
constructor(uid: string, config: JoystickConfig);
|
|
539
|
+
constructor(uid: string, config: JoystickConfig, customTypeName?: EntityType);
|
|
457
540
|
get activePointerId(): number | null;
|
|
458
541
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
459
542
|
onPointerMove(e: AbstractPointerEvent): void;
|
|
@@ -489,7 +572,7 @@ declare class JoystickCore extends BaseEntity<JoystickConfig, JoystickState> imp
|
|
|
489
572
|
* identity (UID) and coordinate reference for all descendant components.
|
|
490
573
|
*/
|
|
491
574
|
declare class RootLayerCore extends BaseEntity<BaseConfig, LayerState> {
|
|
492
|
-
constructor(uid: string, config: BaseConfig);
|
|
575
|
+
constructor(uid: string, config: BaseConfig, customTypeName?: EntityType);
|
|
493
576
|
reset(): void;
|
|
494
577
|
}
|
|
495
578
|
|
|
@@ -504,7 +587,7 @@ declare class TargetZoneCore extends BaseEntity<TargetZoneConfig, CursorState> i
|
|
|
504
587
|
private focusFeedbackTimer;
|
|
505
588
|
private throttledMoveExecution;
|
|
506
589
|
private delegates;
|
|
507
|
-
constructor(uid: string, config: TargetZoneConfig);
|
|
590
|
+
constructor(uid: string, config: TargetZoneConfig, customTypeName?: EntityType);
|
|
508
591
|
bindDelegate(key: string, delegate: AnyFunction): void;
|
|
509
592
|
get activePointerId(): number | null;
|
|
510
593
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
@@ -566,7 +649,7 @@ declare class TrackpadCore extends BaseEntity<TrackpadConfig, TrackpadState> imp
|
|
|
566
649
|
* @param uid - Unique entity ID.
|
|
567
650
|
* @param config - Configuration for the trackpad.
|
|
568
651
|
*/
|
|
569
|
-
constructor(uid: string, config: TrackpadConfig);
|
|
652
|
+
constructor(uid: string, config: TrackpadConfig, customTypeName?: EntityType);
|
|
570
653
|
get activePointerId(): number | null;
|
|
571
654
|
onPointerDown(e: AbstractPointerEvent): void;
|
|
572
655
|
onPointerMove(e: AbstractPointerEvent): void;
|
|
@@ -1115,4 +1198,4 @@ declare const OmniPad: {
|
|
|
1115
1198
|
};
|
|
1116
1199
|
};
|
|
1117
1200
|
|
|
1118
|
-
export { AbstractPointerEvent, AbstractRect, AnyFunction, type AxisLogicState, BaseConfig, BaseEntity, ButtonConfig, ButtonCore, type ButtonLogicState, type ButtonState, type CursorState, DPadConfig, DPadCore, type DPadState, EntityType, GamepadManager, GamepadMappingConfig, IConfigurable, ICoreEntity, IDependencyBindable,
|
|
1201
|
+
export { AbstractPointerEvent, AbstractRect, AnyFunction, type AxisLogicState, BaseConfig, BaseEntity, ButtonConfig, ButtonCore, type ButtonLogicState, type ButtonState, type CursorState, DPadConfig, DPadCore, type DPadState, ElementObserver, EntityType, GamepadManager, GamepadMappingConfig, IConfigurable, ICoreEntity, IDependencyBindable, IPointerHandler, IProgrammatic, type IRegistry, IResettable, ISignalReceiver, ISpatial, IStateful, InputActionSignal, InputZoneConfig, InputZoneCore, type InputZoneState, type InteractionState, JoystickConfig, JoystickCore, type JoystickState, type KeyboardButtonState, type LayerState, type MouseButtonState, OmniPad, Registry, RootLayerCore, TargetZoneConfig, TargetZoneCore, TrackpadConfig, TrackpadCore, type TrackpadState, Vec2, WindowManager, setGlobalSignalHandler };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,b as b$1,f,u as u$1,g,q as q$1,w as w$1,p as p$1}from'./chunk-MSERY5BP.mjs';export{b as Registry}from'./chunk-MSERY5BP.mjs';var $={Backspace:{key:"Backspace",code:"Backspace",keyCode:8},Tab:{key:"Tab",code:"Tab",keyCode:9},Enter:{key:"Enter",code:"Enter",keyCode:13},ShiftLeft:{key:"Shift",code:"ShiftLeft",keyCode:16},ControlLeft:{key:"Control",code:"ControlLeft",keyCode:17},AltLeft:{key:"Alt",code:"AltLeft",keyCode:18},Pause:{key:"Pause",code:"Pause",keyCode:19},CapsLock:{key:"CapsLock",code:"CapsLock",keyCode:20},Escape:{key:"Escape",code:"Escape",keyCode:27},Space:{key:" ",code:"Space",keyCode:32},PageUp:{key:"PageUp",code:"PageUp",keyCode:33},PageDown:{key:"PageDown",code:"PageDown",keyCode:34},End:{key:"End",code:"End",keyCode:35},Home:{key:"Home",code:"Home",keyCode:36},ArrowLeft:{key:"ArrowLeft",code:"ArrowLeft",keyCode:37},ArrowUp:{key:"ArrowUp",code:"ArrowUp",keyCode:38},ArrowRight:{key:"ArrowRight",code:"ArrowRight",keyCode:39},ArrowDown:{key:"ArrowDown",code:"ArrowDown",keyCode:40},PrintScreen:{key:"PrintScreen",code:"PrintScreen",keyCode:44},Insert:{key:"Insert",code:"Insert",keyCode:45},Delete:{key:"Delete",code:"Delete",keyCode:46},Digit0:{key:"0",code:"Digit0",keyCode:48},Digit1:{key:"1",code:"Digit1",keyCode:49},Digit2:{key:"2",code:"Digit2",keyCode:50},Digit3:{key:"3",code:"Digit3",keyCode:51},Digit4:{key:"4",code:"Digit4",keyCode:52},Digit5:{key:"5",code:"Digit5",keyCode:53},Digit6:{key:"6",code:"Digit6",keyCode:54},Digit7:{key:"7",code:"Digit7",keyCode:55},Digit8:{key:"8",code:"Digit8",keyCode:56},Digit9:{key:"9",code:"Digit9",keyCode:57},KeyA:{key:"a",code:"KeyA",keyCode:65},KeyB:{key:"b",code:"KeyB",keyCode:66},KeyC:{key:"c",code:"KeyC",keyCode:67},KeyD:{key:"d",code:"KeyD",keyCode:68},KeyE:{key:"e",code:"KeyE",keyCode:69},KeyF:{key:"f",code:"KeyF",keyCode:70},KeyG:{key:"g",code:"KeyG",keyCode:71},KeyH:{key:"h",code:"KeyH",keyCode:72},KeyI:{key:"i",code:"KeyI",keyCode:73},KeyJ:{key:"j",code:"KeyJ",keyCode:74},KeyK:{key:"k",code:"KeyK",keyCode:75},KeyL:{key:"l",code:"KeyL",keyCode:76},KeyM:{key:"m",code:"KeyM",keyCode:77},KeyN:{key:"n",code:"KeyN",keyCode:78},KeyO:{key:"o",code:"KeyO",keyCode:79},KeyP:{key:"p",code:"KeyP",keyCode:80},KeyQ:{key:"q",code:"KeyQ",keyCode:81},KeyR:{key:"r",code:"KeyR",keyCode:82},KeyS:{key:"s",code:"KeyS",keyCode:83},KeyT:{key:"t",code:"KeyT",keyCode:84},KeyU:{key:"u",code:"KeyU",keyCode:85},KeyV:{key:"v",code:"KeyV",keyCode:86},KeyW:{key:"w",code:"KeyW",keyCode:87},KeyX:{key:"x",code:"KeyX",keyCode:88},KeyY:{key:"y",code:"KeyY",keyCode:89},KeyZ:{key:"z",code:"KeyZ",keyCode:90},MetaLeft:{key:"Meta",code:"MetaLeft",keyCode:91},ContextMenu:{key:"ContextMenu",code:"ContextMenu",keyCode:93},Numpad0:{key:"0",code:"Numpad0",keyCode:96},Numpad1:{key:"1",code:"Numpad1",keyCode:97},Numpad2:{key:"2",code:"Numpad2",keyCode:98},Numpad3:{key:"3",code:"Numpad3",keyCode:99},Numpad4:{key:"4",code:"Numpad4",keyCode:100},Numpad5:{key:"5",code:"Numpad5",keyCode:101},Numpad6:{key:"6",code:"Numpad6",keyCode:102},Numpad7:{key:"7",code:"Numpad7",keyCode:103},Numpad8:{key:"8",code:"Numpad8",keyCode:104},Numpad9:{key:"9",code:"Numpad9",keyCode:105},NumpadMultiply:{key:"*",code:"NumpadMultiply",keyCode:106},NumpadAdd:{key:"+",code:"NumpadAdd",keyCode:107},NumpadSubtract:{key:"-",code:"NumpadSubtract",keyCode:109},NumpadDecimal:{key:".",code:"NumpadDecimal",keyCode:110},NumpadDivide:{key:"/",code:"NumpadDivide",keyCode:111},F1:{key:"F1",code:"F1",keyCode:112},F2:{key:"F2",code:"F2",keyCode:113},F3:{key:"F3",code:"F3",keyCode:114},F4:{key:"F4",code:"F4",keyCode:115},F5:{key:"F5",code:"F5",keyCode:116},F6:{key:"F6",code:"F6",keyCode:117},F7:{key:"F7",code:"F7",keyCode:118},F8:{key:"F8",code:"F8",keyCode:119},F9:{key:"F9",code:"F9",keyCode:120},F10:{key:"F10",code:"F10",keyCode:121},F11:{key:"F11",code:"F11",keyCode:122},F12:{key:"F12",code:"F12",keyCode:123},NumLock:{key:"NumLock",code:"NumLock",keyCode:144},ScrollLock:{key:"ScrollLock",code:"ScrollLock",keyCode:145},Semicolon:{key:";",code:"Semicolon",keyCode:186},Equal:{key:"=",code:"Equal",keyCode:187},Comma:{key:",",code:"Comma",keyCode:188},Minus:{key:"-",code:"Minus",keyCode:189},Period:{key:".",code:"Period",keyCode:190},Slash:{key:"/",code:"Slash",keyCode:191},Backquote:{key:"`",code:"Backquote",keyCode:192},BracketLeft:{key:"[",code:"BracketLeft",keyCode:219},Backslash:{key:"\\",code:"Backslash",keyCode:220},BracketRight:{key:"]",code:"BracketRight",keyCode:221},Quote:{key:"'",code:"Quote",keyCode:222}},S=$;var u={INPUT_ZONE:"input-zone",TARGET_ZONE:"target-zone",BUTTON:"button",KEYBOARD_BUTTON:"keyboard-button",MOUSE_BUTTON:"mouse-button",JOYSTICK:"joystick",D_PAD:"d-pad",TRACKPAD:"trackpad",VIRTUAL_CURSOR:"virtual-cursor",ROOT_LAYER:"root-layer"},n={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},G={PARENT_ID_KEY:"omnipad-parent-id-link"};var w=Symbol.for("omnipad.gamepad_manager.instance"),ee={A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,Select:8,Start:9,L3:10,R3:11,Up:12,Down:13,Left:14,Right:15},R=class a$1{constructor(){a(this,"isRunning",false);a(this,"config",null);a(this,"lastButtonStates",[]);a(this,"loop",()=>{if(!this.isRunning)return;let o=navigator.getGamepads();this.config?.forEach((e,t)=>{let i=o[t];i&&i.connected&&e&&(this.lastButtonStates[t]||(this.lastButtonStates[t]=[]),this.processButtons(i,e,t),this.processDPad(i,e),this.processAxes(i,e));}),requestAnimationFrame(this.loop);});}static getInstance(){let o=globalThis;return o[w]||(o[w]=new a$1),o[w]}setConfig(o){this.config=o;}getConfig(){return this.config}start(){this.isRunning||(this.isRunning=true,window.addEventListener("gamepadconnected",o=>{import.meta.env?.DEV&&console.log("[Omnipad-Core] Gamepad Connected:",o.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{import.meta.env?.DEV&&console.log("[Omnipad-Core] Gamepad disconnected.");}),this.loop());}stop(){this.isRunning=false;}processButtons(o,e,t){e.buttons&&Object.entries(e.buttons).forEach(([i,r])=>{let c=ee[i];if(c===void 0||!o.buttons[c])return;let d=o.buttons[c].pressed,h=this.lastButtonStates[t][c]||false;d&&!h?this.triggerVirtualEntity(r,"down"):!d&&h&&this.triggerVirtualEntity(r,"up"),this.lastButtonStates[t][c]=d;});}processDPad(o,e){let t=e?.dpad;if(!t)return;let i=o.buttons[12]?.pressed?-1:0,r=o.buttons[13]?.pressed?1:0,c=o.buttons[14]?.pressed?-1:0,d=o.buttons[15]?.pressed?1:0,h=c+d,f=i+r;this.triggerVirtualEntity(t,"vector",{x:h,y:f});}processAxes(o,e){let t=e?.deadzone??.1;if(e?.leftStick){let i=Math.abs(o.axes[0])>t?o.axes[0]:0,r=Math.abs(o.axes[1])>t?o.axes[1]:0;this.triggerVirtualEntity(e.leftStick,"vector",{x:i,y:r});}if(e?.rightStick){let i=Math.abs(o.axes[2])>t?o.axes[2]:0,r=Math.abs(o.axes[3])>t?o.axes[3]:0;this.triggerVirtualEntity(e.rightStick,"vector",{x:i,y:r});}}triggerVirtualEntity(o,e,t){let i=b$1.getInstance().getEntity(o);!i||i.activePointerId!=null||(e==="down"&&i.triggerDown&&i.triggerDown(),e==="up"&&i.triggerUp&&i.triggerUp(),e==="vector"&&i.triggerVector&&t&&i.triggerVector(t.x,t.y));}};var A=typeof globalThis<"u"&&globalThis.requestAnimationFrame?globalThis.requestAnimationFrame.bind(globalThis):a=>setTimeout(a,16),te=typeof globalThis<"u"&&globalThis.cancelAnimationFrame?globalThis.cancelAnimationFrame.bind(globalThis):a=>clearTimeout(a);function I(a){let o=false,e;return function(t){e=t,o||(o=true,A(()=>{a(e),o=false;}));}}function W(a){let o=null,e=()=>{a(),o=A(e);};return {start:()=>{o===null&&e();},stop:()=>{o!==null&&(te(o),o=null);}}}var X=(a=2)=>new Promise(o=>{let e=0,t=()=>{++e>=a?o():A(t);};A(t);});var M=Symbol.for("omnipad.window_manager.instance"),O=class a$1{constructor(){a(this,"_isListening",false);a(this,"throttledReset");a(this,"handleGlobalReset",()=>{import.meta.env?.DEV&&console.debug("[OmniPad-Core] Safety reset triggered by environment change."),b$1.getInstance().resetAll();});a(this,"handleResizeReset",()=>{this.throttledReset(null);});a(this,"handleBlurReset",()=>{this.handleGlobalReset();});a(this,"handleScrollReset",()=>{this.throttledReset(null);});a(this,"handleVisibilityChangeReset",()=>{document.visibilityState==="hidden"&&this.handleGlobalReset();});this.throttledReset=I(()=>{this.handleGlobalReset();});}static getInstance(){let o=globalThis;return o[M]||(o[M]=new a$1),o[M]}init(){this._isListening||(window.addEventListener("resize",this.handleResizeReset),window.addEventListener("blur",this.handleBlurReset),window.addEventListener("scroll",this.handleScrollReset,{capture:true,passive:true}),document.addEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=true,import.meta.env?.DEV&&console.log("[OmniPad-Core] Global WindowManager monitoring started."));}async toggleFullscreen(o){let e=o||document.documentElement;try{document.fullscreenElement?(b$1.getInstance().resetAll(),await document.exitFullscreen()):(b$1.getInstance().resetAll(),await e.requestFullscreen());}catch(t){console.error("[OmniPad-Core] Fullscreen toggle failed:",t);}}isFullscreen(){return !!document.fullscreenElement}destroy(){window.removeEventListener("resize",this.handleResizeReset),window.removeEventListener("blur",this.handleBlurReset),window.removeEventListener("scroll",this.handleScrollReset,{capture:true}),window.removeEventListener("visibilitychange",this.handleVisibilityChangeReset),this._isListening=false;}};var D=class{constructor(){a(this,"listeners",new Set);}subscribe(o){return this.listeners.add(o),()=>this.listeners.delete(o)}emit(o){this.listeners.forEach(e=>{try{e(o);}catch(t){console.error("[OmniPad-Core] Emitter callback error:",t);}});}clear(){this.listeners.clear();}};var l=class{constructor(o,e,t,i){a(this,"uid");a(this,"type");a(this,"config");a(this,"state");a(this,"rectProvider",null);a(this,"_onMarkDirtyCb",null);a(this,"stateEmitter",new D);this.uid=o,this.type=e,this.config=t,this.state=i;}subscribe(o){return o(this.state),this.stateEmitter.subscribe(o)}setState(o){this.state={...this.state,...o},this.stateEmitter.emit(this.state);}destroy(){this.reset(),this.stateEmitter.clear(),b$1.getInstance().unregister(this.uid);}get rect(){return this.rectProvider?this.rectProvider():null}bindRectProvider(o,e){this.rectProvider=o,e&&(this._onMarkDirtyCb=e);}markRectDirty(){this._onMarkDirtyCb?.();}updateConfig(o){this.config={...this.config,...o},this.stateEmitter.emit(this.state);}getState(){return this.state}getConfig(){return this.config}};var p=class{constructor(o,e){a(this,"isPressed",false);a(this,"mapping");a(this,"targetId");this.update(o,e);}update(o,e){this.isPressed&&this.reset(),this.targetId=o,this.mapping=this.hydrate(e);}hydrate(o){if(!o)return;let e={...o};if(e.type==="mouse")return e.button=e.button??0,e;let{key:t,code:i,keyCode:r}=e;if(t||i||r){e.type="keyboard";let c=Object.values(S).find(d=>d.code===i||d.key===t||d.keyCode===r);c&&(e.key=t??c.key,e.code=i??c.code,e.keyCode=r??c.keyCode);}return e}press(){if(!this.mapping||this.isPressed)return;this.isPressed=true;let o=this.mapping.type==="keyboard"?n.KEYDOWN:n.MOUSEDOWN;this.emitSignal(o);}release(o=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let e=this.mapping.type==="keyboard"?n.KEYUP:n.MOUSEUP;this.emitSignal(e),this.mapping.type==="mouse"&&o&&this.emitSignal(n.CLICK);}move(o){this.mapping?.type==="mouse"&&this.emitSignal(n.MOUSEMOVE,o);}reset(){this.isPressed&&this.release(false);}async tap(o=true){this.isPressed||(this.press(),await X(2),this.isPressed&&this.release(o));}emitSignal(o,e={}){if(!this.targetId||!this.mapping)return;let t=b$1.getInstance().getEntity(this.targetId);t&&t.handleSignal({targetStageId:this.targetId,type:o,payload:{key:this.mapping.key,code:this.mapping.code,keyCode:this.mapping.keyCode,button:this.mapping.button,point:this.mapping.fixedPoint,...e}});}};var N={isActive:false,isPressed:false,pointerId:null,value:0},K=class extends l{constructor(e,t){super(e,u.BUTTON,t,N);a(this,"emitter");this.emitter=new p(t.targetStageId,t.mapping);}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,isPressed:true,pointerId:e.pointerId}),this.emitter.press();}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.handleRelease(true);}onPointerCancel(){this.handleRelease(false);}onPointerMove(){}reset(){this.setState(N),this.emitter.reset();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(e){this.setState(N),this.emitter.release(e);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.emitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.emitter.release(true));}};var Z={isActive:false,pointerId:null,vector:{x:0,y:0}},q=.002,z=.3,F=class extends l{constructor(e,t){super(e,u.D_PAD,t,Z);a(this,"emitters");let i=t.targetStageId;this.emitters={up:new p(i,t.mapping?.up),down:new p(i,t.mapping?.down),left:new p(i,t.mapping?.left),right:new p(i,t.mapping?.right)};}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}}),this.processInput(e,true);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.processInput(e);}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||this.reset();}onPointerCancel(){this.reset();}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let r=i.left+i.width/2,c=i.top+i.height/2,d=i.width/2,h=i.height/2,f$1=(e.clientX-r)/d,P=(e.clientY-c)/h;if(t&&(f$1!=f(f$1,-1,1)||P!=f(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let C={x:f(f$1,-1,1),y:f(P,-1,1)};u$1(C,this.state.vector,q)||(this.setState({vector:C}),this.handleDigitalKeys(C));}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.emitters.up.reset(),this.emitters.down.reset(),this.emitters.left.reset(),this.emitters.right.reset(),this.setState(Z);}updateConfig(e){super.updateConfig(e),this.emitters.up.update(this.config.targetStageId,this.config.mapping?.up),this.emitters.down.update(this.config.targetStageId,this.config.mapping?.down),this.emitters.left.update(this.config.targetStageId,this.config.mapping?.left),this.emitters.right.update(this.config.targetStageId,this.config.mapping?.right);}triggerVector(e,t){let i=this.config.threshold??.3;if(Math.abs(e)<i&&Math.abs(t)<i){this.state.isActive&&this.reset();return}this.state.isActive||this.setState({isActive:true});let r=g(this.state.vector.x,e,z),c=g(this.state.vector.y,t,z),d={x:r,y:c};u$1(d,this.state.vector,q)||(this.setState({vector:d}),this.handleDigitalKeys(d));}};var ie={isDynamicActive:false,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},Y=class extends l{constructor(e,t){super(e,u.INPUT_ZONE,t,ie);a(this,"delegates",{dynamicWidgetPointerDown:()=>{},dynamicWidgetPointerMove:()=>{},dynamicWidgetPointerUp:()=>{},dynamicWidgetPointerCancel:()=>{}});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return this.state.dynamicPointerId}onPointerDown(e){if(this.state.isDynamicActive)return;let t=this.calculateRelativePosition(e.clientX,e.clientY);this.setState({isDynamicActive:true,dynamicPointerId:e.pointerId,dynamicPosition:t}),this.delegates.dynamicWidgetPointerDown?.(e);}onPointerMove(e){this.state.isDynamicActive&&this.delegates.dynamicWidgetPointerMove?.(e);}onPointerUp(e){this.delegates.dynamicWidgetPointerUp?.(e),this.reset();}onPointerCancel(e){this.delegates.dynamicWidgetPointerCancel?.(e),this.reset();}calculateRelativePosition(e,t){let i=this.rect;return i?{x:q$1(e-i.left,i.width),y:q$1(t-i.top,i.height)}:{x:0,y:0}}get isInterceptorRequired(){return !!(this.config.dynamicWidgetId||this.config.preventFocusLoss)}reset(){this.setState({isDynamicActive:false,dynamicPointerId:null});}};var T=class{constructor(o={}){a(this,"options");a(this,"startTime",0);a(this,"startPos",{x:0,y:0});a(this,"lastTapTime",0);a(this,"hasMoved",false);a(this,"isDoubleTapHolding",false);this.options={tapTime:250,tapDistance:10,doubleTapGap:300,...o};}onPointerDown(o,e){let t=Date.now();this.startTime=t,this.startPos={x:o,y:e},this.hasMoved=false,t-this.lastTapTime<this.options.doubleTapGap?(this.isDoubleTapHolding=true,this.options.onDoubleTapHoldStart?.()):this.isDoubleTapHolding=false;}onPointerMove(o,e){this.hasMoved||Math.hypot(o-this.startPos.x,e-this.startPos.y)>this.options.tapDistance&&(this.hasMoved=true);}onPointerUp(){let o=Date.now(),e=o-this.startTime;this.isDoubleTapHolding?(this.isDoubleTapHolding=false,this.options.onDoubleTapHoldEnd?.(),this.lastTapTime=0):e<=this.options.tapTime&&!this.hasMoved&&(this.options.onTap?.(),o-this.lastTapTime<this.options.doubleTapGap?(this.options.onDoubleTap?.(),this.lastTapTime=0):this.lastTapTime=o);}reset(){this.isDoubleTapHolding&&this.options.onDoubleTapHoldEnd?.(),this.isDoubleTapHolding=false,this.hasMoved=false,this.startTime=0,this.lastTapTime=0;}};var J={isActive:false,isPressed:false,pointerId:null,value:0,vector:{x:0,y:0}},_=.002,j=.3,U=class extends l{constructor(e,t){super(e,u.JOYSTICK,t,J);a(this,"emitters");a(this,"stickEmitter");a(this,"cursorEmitter");a(this,"gesture");a(this,"ticker");let i=t.targetStageId,r=t.mapping||{};this.emitters={up:new p(i,r.up),down:new p(i,r.down),left:new p(i,r.left),right:new p(i,r.right)},this.stickEmitter=new p(i,r.stick),this.cursorEmitter=new p(i,{type:"mouse"}),this.gesture=new T({onTap:async()=>{this.setState({isPressed:true}),await this.stickEmitter.tap(),this.setState({isPressed:false});},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.stickEmitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.stickEmitter.release(false);}}),this.ticker=W(()=>{this.handleCursorTick();});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.setState({isActive:true,pointerId:e.pointerId,vector:{x:0,y:0}}),this.gesture.onPointerDown(e.clientX,e.clientY),this.processInput(e,true);}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.config.cursorMode&&this.ticker.start(),this.processInput(e));}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}handleRelease(){this.setState({isActive:false,pointerId:null,vector:{x:0,y:0}}),this.ticker.stop(),Object.values(this.emitters).forEach(e=>e?.reset());}processInput(e,t=false){if(!this.state.isActive)return;let i=this.rect;if(!i)return;let r=i.left+i.width/2,c=i.top+i.height/2,d=i.width/2,h=i.height/2,f$1=(e.clientX-r)/d,P=(e.clientY-c)/h;if(t&&(f$1!=f(f$1,-1,1)||P!=f(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let x=w$1({x:f$1,y:P},1,this.config.threshold||.15);u$1(x,this.state.vector,_)||(this.setState({vector:x}),this.handleDigitalKeys(x));}handleCursorTick(){let{vector:e,isActive:t}=this.state;if(!t||!this.config.cursorMode||u$1(e,{x:0,y:0},_)){this.ticker.stop();return}let i=this.config.cursorSensitivity??1,r={x:e.x*Math.abs(e.x)*i,y:e.y*Math.abs(e.y)*i};(Math.abs(r.x)>0||Math.abs(r.y)>0)&&this.cursorEmitter.move({delta:r});}handleDigitalKeys(e){let t=this.config.threshold??.3;e.y<-t?(this.emitters.up.press(),this.emitters.down.release()):e.y>t?(this.emitters.down.press(),this.emitters.up.release()):(this.emitters.up.release(),this.emitters.down.release()),e.x<-t?(this.emitters.left.press(),this.emitters.right.release()):e.x>t?(this.emitters.right.press(),this.emitters.left.release()):(this.emitters.left.release(),this.emitters.right.release());}reset(){this.setState(J),this.gesture.reset(),this.handleRelease(),this.stickEmitter.reset(),this.cursorEmitter.reset();}updateConfig(e){super.updateConfig(e);let t=this.config.targetStageId,i=this.config.mapping||{};this.emitters.up.update(t,i.up),this.emitters.down.update(t,i.down),this.emitters.left.update(t,i.left),this.emitters.right.update(t,i.right),this.stickEmitter.update(t,i.stick),this.cursorEmitter.update(t);}triggerDown(){this.state.isPressed||(this.setState({isActive:true,isPressed:true}),this.stickEmitter.press());}triggerUp(){this.state.isPressed&&(this.setState({isActive:false,isPressed:false}),this.stickEmitter.release(true));}triggerVector(e,t){let i=this.config.threshold??.15;if(Math.hypot(e,t)<i){this.state.isActive&&this.handleRelease();return}this.state.isActive||this.setState({isActive:true});let c=g(this.state.vector.x,e,j),d=g(this.state.vector.y,t,j),h={x:c,y:d};u$1(h,this.state.vector,_)||(this.setState({vector:h}),this.handleDigitalKeys(h)),this.config.cursorMode&&this.ticker.start();}};var oe={isHighlighted:false},L=class extends l{constructor(o,e){super(o,u.ROOT_LAYER,e,oe);}reset(){}};var se={position:{x:50,y:50},isVisible:false,isPointerDown:false,isFocusReturning:false},b=1,B=class extends l{constructor(e,t){super(e,u.TARGET_ZONE,t,se);a(this,"hideTimer",null);a(this,"focusFeedbackTimer",null);a(this,"throttledMoveExecution");a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledMoveExecution=I(i=>{this.executeMouseAction(n.POINTERMOVE,i);});}bindDelegate(e,t){Object.prototype.hasOwnProperty.call(this.delegates,e)?this.delegates[e]=t:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${e}`);}get activePointerId(){return null}onPointerDown(e){this.processPhysicalEvent(e,n.MOUSEDOWN);}onPointerMove(e){this.processPhysicalEvent(e,n.MOUSEMOVE);}onPointerUp(e){this.processPhysicalEvent(e,n.MOUSEUP),this.processPhysicalEvent(e,n.CLICK);}onPointerCancel(e){this.processPhysicalEvent(e,n.MOUSEUP);}processPhysicalEvent(e,t){let i=this.rect;if(!i)return;let r={x:q$1(e.clientX-i.left,i.width),y:q$1(e.clientY-i.top,i.height)};this.handleSignal({targetStageId:this.uid,type:t,payload:{point:r,button:e.button}});}handleSignal(e){let{type:t,payload:i}=e;switch(this.ensureFocus(),t){case n.KEYDOWN:case n.KEYUP:this.delegates.dispatchKeyboardEvent?.(t,i);break;case n.MOUSEMOVE:i.point?this.updateCursorPosition(i.point):i.delta&&this.updateCursorPositionByDelta(i.delta),this.config.cursorEnabled&&this.showCursor(),this.throttledMoveExecution(i);break;case n.MOUSEDOWN:case n.MOUSEUP:case n.CLICK:i.point&&this.updateCursorPosition(i.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(t.startsWith(n.MOUSE)?t.replace(n.MOUSE,n.POINTER):t,i);break}}executeMouseAction(e,t){let i=this.rect;if(!i)return;e===n.POINTERDOWN&&this.setState({isPointerDown:true}),e===n.POINTERUP&&this.setState({isPointerDown:false});let r=t.point||this.state.position,c=f(i.left+p$1(r.x,i.width),i.left+b,i.left+i.width-b),d=f(i.top+p$1(r.y,i.height),i.top+b,i.top+i.height-b);this.delegates.dispatchPointerEventAtPos?.(e,c,d,{button:t.button??0,buttons:this.state.isPointerDown?1:0,pressure:this.state.isPointerDown?.5:0});}ensureFocus(){let e=this.rect;if(!e)return;let t=f(e.left+p$1(this.state.position.x,e.width),e.left+b,e.left+e.width-b),i=f(e.top+p$1(this.state.position.y,e.height),e.top+b,e.top+e.height-b);this.delegates.reclaimFocusAtPos?.(t,i,()=>this.triggerFocusFeedback());}triggerFocusFeedback(){this.setState({isFocusReturning:true}),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.focusFeedbackTimer=setTimeout(()=>this.setState({isFocusReturning:false}),500);}updateCursorPosition(e){u$1(e,this.state.position)||this.setState({position:{...e}});}updateCursorPositionByDelta(e){if(u$1(e,{x:0,y:0}))return;let t=this.rect;if(!t)return;let i=q$1(e.x,t.width),r=q$1(e.y,t.height);this.updateCursorPosition({x:f(this.state.position.x+i,0,100),y:f(this.state.position.y+r,0,100)});}showCursor(){this.setState({isVisible:true}),this.hideTimer&&clearTimeout(this.hideTimer),this.config.cursorAutoDelay&&this.config.cursorAutoDelay>0&&(this.hideTimer=setTimeout(()=>this.setState({isVisible:false}),this.config.cursorAutoDelay));}reset(){this.state.isPointerDown&&this.executeMouseAction(n.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:false,isPointerDown:false,isFocusReturning:false});}};var Q={isActive:false,isPressed:false,pointerId:null,value:0},V=class extends l{constructor(e,t){super(e,u.TRACKPAD,t,Q);a(this,"lastPointerPos",{x:0,y:0});a(this,"gesture");a(this,"emitter");let i=t.mapping||{type:"mouse"};this.emitter=new p(t.targetStageId,i),this.gesture=new T({onTap:()=>{this.setState({isPressed:true}),this.emitter.tap();},onDoubleTapHoldStart:()=>{this.setState({isPressed:true}),this.emitter.press();},onDoubleTapHoldEnd:()=>{this.setState({isPressed:false}),this.emitter.release(false);}});}get activePointerId(){return this.state.pointerId}onPointerDown(e){this.lastPointerPos={x:e.clientX,y:e.clientY},this.gesture.onPointerDown(e.clientX,e.clientY),this.setState({isActive:true,pointerId:e.pointerId});}onPointerMove(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerMove(e.clientX,e.clientY),this.processInput(e));}processInput(e){if(!this.state.isActive)return;let t=e.clientX-this.lastPointerPos.x,i=e.clientY-this.lastPointerPos.y,r=this.rect;if(!r)return;let c=t/r.width*100*(this.config.sensitivity??1),d=i/r.height*100*(this.config.sensitivity??1),h={x:c,y:d};u$1(h,{x:0,y:0})||this.emitter.move({delta:h}),this.lastPointerPos={x:e.clientX,y:e.clientY};}onPointerUp(e){!this.state.isActive||e.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}reset(){this.gesture.reset(),this.emitter.reset(),this.handleRelease();}updateConfig(e){super.updateConfig(e),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(){this.setState(Q);}};var Kt={ActionTypes:n,Context:G,Keys:S,Types:u};export{n as ACTION_TYPES,l as BaseEntity,K as ButtonCore,u as CMP_TYPES,G as CONTEXT,F as DPadCore,R as GamepadManager,Y as InputZoneCore,U as JoystickCore,S as KEYS,Kt as OmniPad,L as RootLayerCore,B as TargetZoneCore,V as TrackpadCore,O as WindowManager};
|
|
1
|
+
import {c,b,f,d as d$1,a,h,l,A as A$1,m,w,C,v}from'./chunk-W7OR5ESR.mjs';export{d as ACTION_TYPES,c as CMP_TYPES,f as CONTEXT,b as KEYS,h as Registry,e as VALID_UNITS,g as setGlobalSignalHandler}from'./chunk-W7OR5ESR.mjs';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(){a(this,"isRunning",false);a(this,"config",null);a(this,"lastButtonStates",[]);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=>{import.meta.env?.DEV&&console.log("[Omnipad-Core] Gamepad Connected:",i.gamepad.id);}),window.addEventListener("gamepaddisconnected",()=>{import.meta.env?.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=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(){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 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(){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.getInstance().resetAll(),h.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=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,import.meta.env?.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(){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){a(this,"uid");a(this,"type");a(this,"config");a(this,"state");a(this,"rectProvider",null);a(this,"_onMarkDirtyCb",null);a(this,"stateEmitter",new A);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(),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){a(this,"isPressed",false);a(this,"mapping");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(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"?d$1.KEYDOWN:d$1.MOUSEDOWN;this.emitSignal(i);}release(i=true){if(!this.mapping||!this.isPressed)return;this.isPressed=false;let t=this.mapping.type==="keyboard"?d$1.KEYUP:d$1.MOUSEUP;this.emitSignal(t),this.mapping.type==="mouse"&&i&&this.emitSignal(d$1.CLICK);}move(i){this.mapping?.type==="mouse"&&this.emitSignal(d$1.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||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||c.BUTTON,e,V);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||c.D_PAD,e,q);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$1=s.width/2,u=s.height/2,v=(t.clientX-o)/l$1,P=(t.clientY-n)/u;if(e&&(v!=l(v,-1,1)||P!=l(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let C={x:l(v,-1,1),y:l(P,-1,1)};A$1(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=m(this.state.vector.x,t,J),n=m(this.state.vector.y,e,J),l={x:o,y:n};A$1(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||c.INPUT_ZONE,e,rt);a(this,"delegates",{dynamicWidgetPointerDown:()=>{},dynamicWidgetPointerMove:()=>{},dynamicWidgetPointerUp:()=>{},dynamicWidgetPointerCancel:()=>{}});}bindDelegate(t,e){Object.prototype.hasOwnProperty.call(this.delegates,t)?this.delegates[t]=e:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${t}`);}get activePointerId(){return this.state.dynamicPointerId}onPointerDown(t){if(this.state.isDynamicActive)return;let e=this.calculateRelativePosition(t.clientX,t.clientY);this.setState({isDynamicActive:true,dynamicPointerId:t.pointerId,dynamicPosition:e}),this.delegates.dynamicWidgetPointerDown?.(t);}onPointerMove(t){this.state.isDynamicActive&&this.delegates.dynamicWidgetPointerMove?.(t);}onPointerUp(t){this.delegates.dynamicWidgetPointerUp?.(t),this.reset();}onPointerCancel(t){this.delegates.dynamicWidgetPointerCancel?.(t),this.reset();}calculateRelativePosition(t,e){let s=this.rect;return s?{x:w(t-s.left,s.width),y: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={}){a(this,"options");a(this,"startTime",0);a(this,"startPos",{x:0,y:0});a(this,"lastTapTime",0);a(this,"hasMoved",false);a(this,"isDoubleTapHolding",false);this.options={tapTime:250,tapDistance:10,doubleTapGap:300,...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||c.JOYSTICK,e,$);a(this,"emitters");a(this,"stickEmitter");a(this,"cursorEmitter");a(this,"gesture");a(this,"ticker");let o=e.targetStageId,n=e.mapping||{};this.emitters={up:new p(o,n.up),down:new p(o,n.down),left:new p(o,n.left),right:new p(o,n.right)},this.stickEmitter=new p(o,n.stick),this.cursorEmitter=new p(o,{type:"mouse"}),this.gesture=new 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$1=s.width/2,u=s.height/2,v=(t.clientX-o)/l$1,P=(t.clientY-n)/u;if(e&&(v!=l(v,-1,1)||P!=l(P,-1,1))){this.setState({vector:{x:0,y:0}}),this.markRectDirty();return}let D=C({x:v,y:P},1,this.config.threshold||.15);A$1(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||A$1(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=m(this.state.vector.x,t,Q),l=m(this.state.vector.y,e,Q),u={x:n,y:l};A$1(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||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||c.TARGET_ZONE,e,nt);a(this,"hideTimer",null);a(this,"focusFeedbackTimer",null);a(this,"throttledMoveExecution");a(this,"delegates",{dispatchKeyboardEvent:()=>{},dispatchPointerEventAtPos:()=>{},reclaimFocusAtPos:()=>{}});this.throttledMoveExecution=T(o=>{this.executeMouseAction(d$1.POINTERMOVE,o);});}bindDelegate(t,e){Object.prototype.hasOwnProperty.call(this.delegates,t)?this.delegates[t]=e:import.meta.env?.DEV&&console.warn(`[Omnipad-Core] TargetZone attempted to bind unknown delegate: ${t}`);}get activePointerId(){return null}onPointerDown(t){this.processPhysicalEvent(t,d$1.MOUSEDOWN);}onPointerMove(t){this.processPhysicalEvent(t,d$1.MOUSEMOVE);}onPointerUp(t){this.processPhysicalEvent(t,d$1.MOUSEUP),this.processPhysicalEvent(t,d$1.CLICK);}onPointerCancel(t){this.processPhysicalEvent(t,d$1.MOUSEUP);}processPhysicalEvent(t,e){let s=this.rect;if(!s)return;let o={x:w(t.clientX-s.left,s.width),y: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 d$1.KEYDOWN:case d$1.KEYUP:this.delegates.dispatchKeyboardEvent?.(e,s);break;case d$1.MOUSEMOVE:s.point?this.updateCursorPosition(s.point):s.delta&&this.updateCursorPositionByDelta(s.delta),this.config.cursorEnabled&&this.showCursor(),this.throttledMoveExecution(s);break;case d$1.MOUSEDOWN:case d$1.MOUSEUP:case d$1.CLICK:s.point&&this.updateCursorPosition(s.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(e.startsWith(d$1.MOUSE)?e.replace(d$1.MOUSE,d$1.POINTER):e,s);break}}executeMouseAction(t,e){let s=this.rect;if(!s)return;t===d$1.POINTERDOWN&&this.setState({isPointerDown:true}),t===d$1.POINTERUP&&this.setState({isPointerDown:false});let o=e.point||this.state.position,n=l(s.left+v(o.x,s.width),s.left+y,s.left+s.width-y),l$1=l(s.top+v(o.y,s.height),s.top+y,s.top+s.height-y);this.delegates.dispatchPointerEventAtPos?.(t,n,l$1,{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=l(t.left+v(this.state.position.x,t.width),t.left+y,t.left+t.width-y),s=l(t.top+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){A$1(t,this.state.position)||this.setState({position:{...t}});}updateCursorPositionByDelta(t){if(A$1(t,{x:0,y:0}))return;let e=this.rect;if(!e)return;let s=w(t.x,e.width),o=w(t.y,e.height);this.updateCursorPosition({x:l(this.state.position.x+s,0,100),y: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(d$1.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||c.TRACKPAD,e,tt);a(this,"lastPointerPos",{x:0,y:0});a(this,"gesture");a(this,"emitter");let o=e.mapping||{type:"mouse"};this.emitter=new p(e.targetStageId,o),this.gesture=new 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};A$1(u,{x:0,y:0})||this.emitter.move({delta:u}),this.lastPointerPos={x:t.clientX,y:t.clientY};}onPointerUp(t){!this.state.isActive||t.pointerId!==this.state.pointerId||(this.gesture.onPointerUp(),this.handleRelease());}onPointerCancel(){this.handleRelease();}reset(){this.gesture.reset(),this.emitter.reset(),this.handleRelease();}updateConfig(t){super.updateConfig(t),this.emitter.update(this.config.targetStageId,this.config.mapping);}handleRelease(){this.setState(tt);}};var Ue={ActionTypes:d$1,Context:f,Keys:b,Types:c};export{d as BaseEntity,B as ButtonCore,G as DPadCore,k as ElementObserver,M as GamepadManager,H as InputZoneCore,L as JoystickCore,Ue as OmniPad,F as RootLayerCore,N as TargetZoneCore,W as TrackpadCore,Y as WindowManager};
|
package/dist/utils/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk4J2ZANLB_cjs=require('../chunk-4J2ZANLB.cjs');function Z(t){let r=null,e=true;return {get:()=>((e||!r)&&(r=t(),e=false),r),markDirty:()=>{e=true;}}}function tt(t,r){let e={};return t?(Object.keys(r).forEach(o=>{let i=r[o],a=t[o];typeof i=="object"&&i!==null?JSON.stringify(i)!==JSON.stringify(a)&&(e[o]=i):i!==a&&(e[o]=i);}),e):{...r}}var v=(t,r,e="omnipad-prevent")=>{let i=document.elementsFromPoint(t,r).find(a=>!a.classList.contains(e));if(!i)return null;for(;i&&i.shadowRoot;){let c=i.shadowRoot.elementsFromPoint(t,r).find(f=>!f.classList.contains(e));if(!c||c===i)break;i=c;}return i},E=()=>{let t=document.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},M=t=>{E()!==t&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus());},nt=(t,r)=>{let e=new KeyboardEvent(t,{...r,which:r.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(e);},rt=(t,r,e,o)=>{let i=v(r,e);if(!i)return;let a={bubbles:true,cancelable:true,composed:true,clientX:r,clientY:e,view:window,...o};if(t.startsWith("pointer")){i.dispatchEvent(new PointerEvent(t,{isPrimary:true,pointerId:9999,pointerType:"mouse",...a}));let c=t.replace("pointer","mouse");i.dispatchEvent(new MouseEvent(c,a));}else i.dispatchEvent(new MouseEvent(t,a));},it=(t,r,e)=>{let o=v(t,r);if(!o)return;E()!==o&&(M(o),e());},g,ot=()=>(g!==void 0||(g=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),g),T=(t,r)=>{if(t instanceof Element)try{t.setPointerCapture(r);}catch(e){undefined?.DEV&&console.warn("[Omnipad-DOM] Failed to set pointer capture:",e);}},I=(t,r)=>{if(t instanceof Element&&t.hasPointerCapture(r))try{t.releasePointerCapture(r);}catch{}};function at(t,r={}){return {onPointerDown(e){if(!e.isTrusted||r?.requireDirectHit&&e.target!==e.currentTarget||t.activePointerId!=null)return;e.cancelable&&e.preventDefault(),e.stopPropagation();let o=e.currentTarget;o&&T(o,e.pointerId),t.onPointerDown(e);},onPointerMove(e){e.isTrusted&&(t.activePointerId!=null&&t.activePointerId!==e.pointerId||(e.cancelable&&e.preventDefault(),t.onPointerMove(e)));},onPointerUp(e){if(!e.isTrusted||t.activePointerId!=null&&t.activePointerId!==e.pointerId)return;e.cancelable&&e.preventDefault();let o=e.currentTarget;o&&I(o,e.pointerId),t.onPointerUp(e);},onPointerCancel(e){if(!e.isTrusted||t.activePointerId!=null&&t.activePointerId!==e.pointerId)return;let o=e.currentTarget;o&&I(o,e.pointerId),t.onPointerCancel(e);}}}var S=(t="omnipad")=>{let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,6);return `${t}-${r}-${e}`};function m(t){return t.startsWith("$")}function k(t){if(t==null)return {value:0,unit:"px"};if(typeof t=="number")return {value:Number.isFinite(t)?t:0,unit:"px"};let r=t.trim(),e=parseFloat(r);if(isNaN(e))return {value:0,unit:"px"};let o=r.match(/[a-z%]+$/i),i=o?o[0].toLowerCase():"px";return C({value:e,unit:i})}var C=t=>{let{value:r,unit:e}=t;return chunk4J2ZANLB_cjs.e.includes(e)?{value:r,unit:e}:(console.warn(`[Omnipad-Core] Blocked invalid CSS unit: ${e}`),{value:r,unit:"px"})},x=t=>`${t.value}${t.unit}`,gt=t=>{if(Object.keys(t??{}).length===0)return {};let r={};r.position="absolute",t.isSquare&&(r.aspectRatio="1/1"),["left","top","right","bottom","width","height"].forEach(i=>{let a=t[i];if(a!=null){if(typeof a=="object"&&"unit"in a){let c=C(a);r[i]=x(c);}else if(typeof a=="string"||typeof a=="number"){let c=k(a);r[i]=x(c);}}}),t.zIndex!==void 0&&(r.zIndex=t.zIndex);let o={"top-left":"translate(0, 0)","top-center":"translate(-50%, 0)","top-right":"translate(-100%, 0)","center-left":"translate(0, -50%)",center:"translate(-50%, -50%)","center-right":"translate(-100%, -50%)","bottom-left":"translate(0, -100%)","bottom-center":"translate(-50%, -100%)","bottom-right":"translate(-100%, -100%)"};return t.anchor&&(r.transform=o[t.anchor]),r};function Pt(t){if(!t||typeof t!="object")throw new Error("[OmniPad-Validation] Profile must be a valid JSON object.");if(!Array.isArray(t.items))throw new Error('[OmniPad-Validation] "items" must be an array.');let r={name:t.meta?.name||"Untitled Profile",version:t.meta?.version||"1.0.0",author:t.meta?.author||"Unknown"},e=t.items.map((i,a)=>{if(!i.id||!i.type)throw new Error(`[OmniPad-Validation] Item at index ${a} is missing "id" or "type".`);return {id:String(i.id),type:String(i.type),parentId:i.parentId?String(i.parentId):void 0,config:i.config||{}}}),o=t.gamepadMappings;return {meta:r,items:e,gamepadMappings:o}}function yt(t){let{items:r,gamepadMappings:e}=t,o=new Map,i=(n,s="node")=>m(n)?n:(o.has(n)||o.set(n,S(s)),o.get(n));r.forEach(n=>i(n.id,n.type));let a=[];e&&e.forEach(n=>{let s={};if(n.buttons){s.buttons={};for(let[u,d]of Object.entries(n.buttons))s.buttons[u]=i(d);}n.dpad&&(s.dpad=i(n.dpad)),n.leftStick&&(s.leftStick=i(n.leftStick)),n.rightStick&&(s.rightStick=i(n.rightStick)),a.push(s);});let c=new Map,f=[];r.forEach(n=>{n.parentId?(c.has(n.parentId)||c.set(n.parentId,[]),c.get(n.parentId).push(n)):f.push(n);});let l=(n,s)=>{if(s.has(n.id))throw new Error(`[Omnipad-Core] Circular dependency detected at node: ${n.id}`);s.add(n.id);let u={...n.config};u?.targetStageId&&(u.targetStageId=i(u.targetStageId)),u?.dynamicWidgetId&&(u.dynamicWidgetId=i(u.dynamicWidgetId));let h=(c.get(n.id)||[]).map(b=>l(b,new Set(s)));return {uid:i(n.id),type:n.type,config:u,children:h}},p={};return f.forEach(n=>{p[n.id]=l(n,new Set);}),{roots:p,runtimeGamepadMappings:a}}function It(t,r,e){let o=chunk4J2ZANLB_cjs.h.getInstance(),i=[];if(!r||r.length===0)i=o.getAllEntities();else {let n=new Set;r.forEach(s=>{o.getEntitiesByRoot(s).forEach(d=>n.add(d));}),i=Array.from(n);}let a=new Map,c=0,f=n=>m(n)?n:(a.has(n)||a.set(n,`node_${++c}`),a.get(n)),l=i.map(n=>{let s=n.getConfig(),u=n.uid,d={...s};d.targetStageId&&(d.targetStageId=f(d.targetStageId)),d.dynamicWidgetId&&(d.dynamicWidgetId=f(d.dynamicWidgetId));let{id:h,parentId:b,...w}=d;return {id:f(u),type:n.type,parentId:s.parentId?f(s.parentId):void 0,config:w}}),p=[];return e&&e.forEach(n=>{let s={};if(n.buttons){s.buttons={};for(let[u,d]of Object.entries(n.buttons))a.has(d)&&(s.buttons[u]=a.get(d));}n.dpad&&a.has(n.dpad)&&(s.dpad=a.get(n.dpad)),n.leftStick&&a.has(n.leftStick)&&(s.leftStick=a.get(n.leftStick)),n.rightStick&&a.has(n.rightStick)&&(s.rightStick=a.get(n.rightStick)),Object.keys(s).length>0?p.push(s):p.push({});}),{meta:t,items:l,gamepadMappings:Object.keys(p).length>0?p:void 0}}function vt(t,r){let e={};for(let o in t)t[o]!==void 0&&!r.has(o)&&(e[o]=t[o]);return e}Object.defineProperty(exports,"addVec",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.j}});Object.defineProperty(exports,"applyAxialDeadzone",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.D}});Object.defineProperty(exports,"applyRadialDeadzone",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.C}});Object.defineProperty(exports,"clamp",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.l}});Object.defineProperty(exports,"clampVector",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.s}});Object.defineProperty(exports,"degToRad",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.r}});Object.defineProperty(exports,"getAngle",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.p}});Object.defineProperty(exports,"getDeadzoneScalar",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.B}});Object.defineProperty(exports,"getDistance",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.o}});Object.defineProperty(exports,"isVec2Equal",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.A}});Object.defineProperty(exports,"lerp",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.m}});Object.defineProperty(exports,"lockTo4Directions",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.u}});Object.defineProperty(exports,"lockTo8Directions",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.t}});Object.defineProperty(exports,"normalizeVec",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.x}});Object.defineProperty(exports,"percentToPx",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.v}});Object.defineProperty(exports,"pxToPercent",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.w}});Object.defineProperty(exports,"radToDeg",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.q}});Object.defineProperty(exports,"radToVec",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.y}});Object.defineProperty(exports,"remap",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.z}});Object.defineProperty(exports,"roundTo",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.n}});Object.defineProperty(exports,"scaleVec",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.k}});Object.defineProperty(exports,"subVec",{enumerable:true,get:function(){return chunk4J2ZANLB_cjs.i}});exports.createCachedProvider=Z;exports.createPointerBridge=at;exports.dispatchKeyboardEvent=nt;exports.dispatchPointerEventAtPos=rt;exports.exportProfile=It;exports.focusElement=M;exports.generateUID=S;exports.getBusinessProps=vt;exports.getDeepActiveElement=E;exports.getDeepElement=v;exports.getObjectDiff=tt;exports.isGlobalID=m;exports.lengthToCss=x;exports.parseLength=k;exports.parseProfileJson=Pt;exports.parseProfileTrees=yt;exports.reclaimFocusAtPos=it;exports.resolveLayoutStyle=gt;exports.safeReleaseCapture=I;exports.safeSetCapture=T;exports.sanitizeParsedLength=C;exports.supportsContainerQueries=ot;
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as IPointerHandler, P as ParsedLength, N as LayoutBox, V as Vec2, v as ConfigTreeNode, G as GamepadMappingConfig, y as GamepadProfile } from '../index-CT1fDlB9.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a provider wrapper that caches the result of a value-producing function.
|
|
@@ -24,6 +24,19 @@ declare function createCachedProvider<T>(provider: () => T): {
|
|
|
24
24
|
markDirty: () => void;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Compares two objects and extracts the properties that have changed.
|
|
29
|
+
*
|
|
30
|
+
* This function performs a shallow comparison of keys. For nested objects,
|
|
31
|
+
* it performs a structural check to determine if
|
|
32
|
+
* the contents have changed.
|
|
33
|
+
*
|
|
34
|
+
* @param oldObj - The previous state or snapshot of the object.
|
|
35
|
+
* @param newObj - The new state of the object to compare against the old one.
|
|
36
|
+
* @returns A partial record containing only the key-value pairs that differ from the original.
|
|
37
|
+
*/
|
|
38
|
+
declare function getObjectDiff(oldObj: any, newObj: any): Record<string, any>;
|
|
39
|
+
|
|
27
40
|
/**
|
|
28
41
|
* Recursively penetrates Shadow DOM boundaries to find the deepest element at the
|
|
29
42
|
* specified viewport coordinates.
|
|
@@ -166,6 +179,21 @@ declare const generateUID: (prefix?: string) => string;
|
|
|
166
179
|
*/
|
|
167
180
|
declare function isGlobalID(id: string): boolean;
|
|
168
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Convert the length input into a sanitized ParsedLength
|
|
184
|
+
*
|
|
185
|
+
* @param input - The raw length input.
|
|
186
|
+
* @returns A sanitized ParsedLength.
|
|
187
|
+
*/
|
|
188
|
+
declare function parseLength(input: string | number | undefined): ParsedLength;
|
|
189
|
+
/**
|
|
190
|
+
* Check the whitelist of verification units and sanitize ParsedLength.
|
|
191
|
+
*/
|
|
192
|
+
declare const sanitizeParsedLength: (parsed: ParsedLength) => ParsedLength;
|
|
193
|
+
/**
|
|
194
|
+
* Convert the ParsedLength back to a CSS string
|
|
195
|
+
*/
|
|
196
|
+
declare const lengthToCss: (parsed: ParsedLength) => string;
|
|
169
197
|
/**
|
|
170
198
|
* Converts a LayoutBox configuration into a CSS style object suitable for Vue/React.
|
|
171
199
|
*
|
|
@@ -330,5 +358,11 @@ declare function parseProfileTrees(profile: GamepadProfile): ParsedProfileForest
|
|
|
330
358
|
* @returns A flat GamepadProfile ready for storage.
|
|
331
359
|
*/
|
|
332
360
|
declare function exportProfile(meta: GamepadProfile['meta'], rootUids?: string[], runtimeGamepadMappings?: Readonly<GamepadMappingConfig[]>): GamepadProfile;
|
|
361
|
+
/**
|
|
362
|
+
* Extract filtered business configurations.
|
|
363
|
+
* @param props Original Props object (e.g. Vue's props)
|
|
364
|
+
* @param skipKeys Ignore key set
|
|
365
|
+
*/
|
|
366
|
+
declare function getBusinessProps(props: Record<string, any>, skipKeys: Set<string>): Record<string, any>;
|
|
333
367
|
|
|
334
|
-
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createCachedProvider, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, isGlobalID, isVec2Equal, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, scaleVec, subVec, supportsContainerQueries };
|
|
368
|
+
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createCachedProvider, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getBusinessProps, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, getObjectDiff, isGlobalID, isVec2Equal, lengthToCss, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseLength, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, sanitizeParsedLength, scaleVec, subVec, supportsContainerQueries };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as IPointerHandler, P as ParsedLength, N as LayoutBox, V as Vec2, v as ConfigTreeNode, G as GamepadMappingConfig, y as GamepadProfile } from '../index-CT1fDlB9.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a provider wrapper that caches the result of a value-producing function.
|
|
@@ -24,6 +24,19 @@ declare function createCachedProvider<T>(provider: () => T): {
|
|
|
24
24
|
markDirty: () => void;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Compares two objects and extracts the properties that have changed.
|
|
29
|
+
*
|
|
30
|
+
* This function performs a shallow comparison of keys. For nested objects,
|
|
31
|
+
* it performs a structural check to determine if
|
|
32
|
+
* the contents have changed.
|
|
33
|
+
*
|
|
34
|
+
* @param oldObj - The previous state or snapshot of the object.
|
|
35
|
+
* @param newObj - The new state of the object to compare against the old one.
|
|
36
|
+
* @returns A partial record containing only the key-value pairs that differ from the original.
|
|
37
|
+
*/
|
|
38
|
+
declare function getObjectDiff(oldObj: any, newObj: any): Record<string, any>;
|
|
39
|
+
|
|
27
40
|
/**
|
|
28
41
|
* Recursively penetrates Shadow DOM boundaries to find the deepest element at the
|
|
29
42
|
* specified viewport coordinates.
|
|
@@ -166,6 +179,21 @@ declare const generateUID: (prefix?: string) => string;
|
|
|
166
179
|
*/
|
|
167
180
|
declare function isGlobalID(id: string): boolean;
|
|
168
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Convert the length input into a sanitized ParsedLength
|
|
184
|
+
*
|
|
185
|
+
* @param input - The raw length input.
|
|
186
|
+
* @returns A sanitized ParsedLength.
|
|
187
|
+
*/
|
|
188
|
+
declare function parseLength(input: string | number | undefined): ParsedLength;
|
|
189
|
+
/**
|
|
190
|
+
* Check the whitelist of verification units and sanitize ParsedLength.
|
|
191
|
+
*/
|
|
192
|
+
declare const sanitizeParsedLength: (parsed: ParsedLength) => ParsedLength;
|
|
193
|
+
/**
|
|
194
|
+
* Convert the ParsedLength back to a CSS string
|
|
195
|
+
*/
|
|
196
|
+
declare const lengthToCss: (parsed: ParsedLength) => string;
|
|
169
197
|
/**
|
|
170
198
|
* Converts a LayoutBox configuration into a CSS style object suitable for Vue/React.
|
|
171
199
|
*
|
|
@@ -330,5 +358,11 @@ declare function parseProfileTrees(profile: GamepadProfile): ParsedProfileForest
|
|
|
330
358
|
* @returns A flat GamepadProfile ready for storage.
|
|
331
359
|
*/
|
|
332
360
|
declare function exportProfile(meta: GamepadProfile['meta'], rootUids?: string[], runtimeGamepadMappings?: Readonly<GamepadMappingConfig[]>): GamepadProfile;
|
|
361
|
+
/**
|
|
362
|
+
* Extract filtered business configurations.
|
|
363
|
+
* @param props Original Props object (e.g. Vue's props)
|
|
364
|
+
* @param skipKeys Ignore key set
|
|
365
|
+
*/
|
|
366
|
+
declare function getBusinessProps(props: Record<string, any>, skipKeys: Set<string>): Record<string, any>;
|
|
333
367
|
|
|
334
|
-
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createCachedProvider, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, isGlobalID, isVec2Equal, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, scaleVec, subVec, supportsContainerQueries };
|
|
368
|
+
export { type ParsedProfileForest, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, createCachedProvider, createPointerBridge, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAngle, getBusinessProps, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, getObjectDiff, isGlobalID, isVec2Equal, lengthToCss, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseLength, parseProfileJson, parseProfileTrees, percentToPx, pxToPercent, radToDeg, radToVec, reclaimFocusAtPos, remap, resolveLayoutStyle, roundTo, safeReleaseCapture, safeSetCapture, sanitizeParsedLength, scaleVec, subVec, supportsContainerQueries };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {e,h}from'../chunk-W7OR5ESR.mjs';export{j as addVec,D as applyAxialDeadzone,C as applyRadialDeadzone,l as clamp,s as clampVector,r as degToRad,p as getAngle,B as getDeadzoneScalar,o as getDistance,A as isVec2Equal,m as lerp,u as lockTo4Directions,t as lockTo8Directions,x as normalizeVec,v as percentToPx,w as pxToPercent,q as radToDeg,y as radToVec,z as remap,n as roundTo,k as scaleVec,i as subVec}from'../chunk-W7OR5ESR.mjs';function Z(t){let r=null,e=true;return {get:()=>((e||!r)&&(r=t(),e=false),r),markDirty:()=>{e=true;}}}function tt(t,r){let e={};return t?(Object.keys(r).forEach(o=>{let i=r[o],a=t[o];typeof i=="object"&&i!==null?JSON.stringify(i)!==JSON.stringify(a)&&(e[o]=i):i!==a&&(e[o]=i);}),e):{...r}}var v=(t,r,e="omnipad-prevent")=>{let i=document.elementsFromPoint(t,r).find(a=>!a.classList.contains(e));if(!i)return null;for(;i&&i.shadowRoot;){let c=i.shadowRoot.elementsFromPoint(t,r).find(f=>!f.classList.contains(e));if(!c||c===i)break;i=c;}return i},E=()=>{let t=document.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},M=t=>{E()!==t&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus());},nt=(t,r)=>{let e=new KeyboardEvent(t,{...r,which:r.keyCode,bubbles:true,cancelable:true,view:window});window.dispatchEvent(e);},rt=(t,r,e,o)=>{let i=v(r,e);if(!i)return;let a={bubbles:true,cancelable:true,composed:true,clientX:r,clientY:e,view:window,...o};if(t.startsWith("pointer")){i.dispatchEvent(new PointerEvent(t,{isPrimary:true,pointerId:9999,pointerType:"mouse",...a}));let c=t.replace("pointer","mouse");i.dispatchEvent(new MouseEvent(c,a));}else i.dispatchEvent(new MouseEvent(t,a));},it=(t,r,e)=>{let o=v(t,r);if(!o)return;E()!==o&&(M(o),e());},g,ot=()=>(g!==void 0||(g=typeof window<"u"&&!!window.CSS?.supports?.("width: 1cqw")),g),T=(t,r)=>{if(t instanceof Element)try{t.setPointerCapture(r);}catch(e){import.meta.env?.DEV&&console.warn("[Omnipad-DOM] Failed to set pointer capture:",e);}},I=(t,r)=>{if(t instanceof Element&&t.hasPointerCapture(r))try{t.releasePointerCapture(r);}catch{}};function at(t,r={}){return {onPointerDown(e){if(!e.isTrusted||r?.requireDirectHit&&e.target!==e.currentTarget||t.activePointerId!=null)return;e.cancelable&&e.preventDefault(),e.stopPropagation();let o=e.currentTarget;o&&T(o,e.pointerId),t.onPointerDown(e);},onPointerMove(e){e.isTrusted&&(t.activePointerId!=null&&t.activePointerId!==e.pointerId||(e.cancelable&&e.preventDefault(),t.onPointerMove(e)));},onPointerUp(e){if(!e.isTrusted||t.activePointerId!=null&&t.activePointerId!==e.pointerId)return;e.cancelable&&e.preventDefault();let o=e.currentTarget;o&&I(o,e.pointerId),t.onPointerUp(e);},onPointerCancel(e){if(!e.isTrusted||t.activePointerId!=null&&t.activePointerId!==e.pointerId)return;let o=e.currentTarget;o&&I(o,e.pointerId),t.onPointerCancel(e);}}}var S=(t="omnipad")=>{let r=Date.now().toString(36),e=Math.random().toString(36).substring(2,6);return `${t}-${r}-${e}`};function m(t){return t.startsWith("$")}function k(t){if(t==null)return {value:0,unit:"px"};if(typeof t=="number")return {value:Number.isFinite(t)?t:0,unit:"px"};let r=t.trim(),e=parseFloat(r);if(isNaN(e))return {value:0,unit:"px"};let o=r.match(/[a-z%]+$/i),i=o?o[0].toLowerCase():"px";return C({value:e,unit:i})}var C=t=>{let{value:r,unit:e$1}=t;return e.includes(e$1)?{value:r,unit:e$1}:(console.warn(`[Omnipad-Core] Blocked invalid CSS unit: ${e$1}`),{value:r,unit:"px"})},x=t=>`${t.value}${t.unit}`,gt=t=>{if(Object.keys(t??{}).length===0)return {};let r={};r.position="absolute",t.isSquare&&(r.aspectRatio="1/1"),["left","top","right","bottom","width","height"].forEach(i=>{let a=t[i];if(a!=null){if(typeof a=="object"&&"unit"in a){let c=C(a);r[i]=x(c);}else if(typeof a=="string"||typeof a=="number"){let c=k(a);r[i]=x(c);}}}),t.zIndex!==void 0&&(r.zIndex=t.zIndex);let o={"top-left":"translate(0, 0)","top-center":"translate(-50%, 0)","top-right":"translate(-100%, 0)","center-left":"translate(0, -50%)",center:"translate(-50%, -50%)","center-right":"translate(-100%, -50%)","bottom-left":"translate(0, -100%)","bottom-center":"translate(-50%, -100%)","bottom-right":"translate(-100%, -100%)"};return t.anchor&&(r.transform=o[t.anchor]),r};function Pt(t){if(!t||typeof t!="object")throw new Error("[OmniPad-Validation] Profile must be a valid JSON object.");if(!Array.isArray(t.items))throw new Error('[OmniPad-Validation] "items" must be an array.');let r={name:t.meta?.name||"Untitled Profile",version:t.meta?.version||"1.0.0",author:t.meta?.author||"Unknown"},e=t.items.map((i,a)=>{if(!i.id||!i.type)throw new Error(`[OmniPad-Validation] Item at index ${a} is missing "id" or "type".`);return {id:String(i.id),type:String(i.type),parentId:i.parentId?String(i.parentId):void 0,config:i.config||{}}}),o=t.gamepadMappings;return {meta:r,items:e,gamepadMappings:o}}function yt(t){let{items:r,gamepadMappings:e}=t,o=new Map,i=(n,s="node")=>m(n)?n:(o.has(n)||o.set(n,S(s)),o.get(n));r.forEach(n=>i(n.id,n.type));let a=[];e&&e.forEach(n=>{let s={};if(n.buttons){s.buttons={};for(let[u,d]of Object.entries(n.buttons))s.buttons[u]=i(d);}n.dpad&&(s.dpad=i(n.dpad)),n.leftStick&&(s.leftStick=i(n.leftStick)),n.rightStick&&(s.rightStick=i(n.rightStick)),a.push(s);});let c=new Map,f=[];r.forEach(n=>{n.parentId?(c.has(n.parentId)||c.set(n.parentId,[]),c.get(n.parentId).push(n)):f.push(n);});let l=(n,s)=>{if(s.has(n.id))throw new Error(`[Omnipad-Core] Circular dependency detected at node: ${n.id}`);s.add(n.id);let u={...n.config};u?.targetStageId&&(u.targetStageId=i(u.targetStageId)),u?.dynamicWidgetId&&(u.dynamicWidgetId=i(u.dynamicWidgetId));let h=(c.get(n.id)||[]).map(b=>l(b,new Set(s)));return {uid:i(n.id),type:n.type,config:u,children:h}},p={};return f.forEach(n=>{p[n.id]=l(n,new Set);}),{roots:p,runtimeGamepadMappings:a}}function It(t,r,e){let o=h.getInstance(),i=[];if(!r||r.length===0)i=o.getAllEntities();else {let n=new Set;r.forEach(s=>{o.getEntitiesByRoot(s).forEach(d=>n.add(d));}),i=Array.from(n);}let a=new Map,c=0,f=n=>m(n)?n:(a.has(n)||a.set(n,`node_${++c}`),a.get(n)),l=i.map(n=>{let s=n.getConfig(),u=n.uid,d={...s};d.targetStageId&&(d.targetStageId=f(d.targetStageId)),d.dynamicWidgetId&&(d.dynamicWidgetId=f(d.dynamicWidgetId));let{id:h,parentId:b,...w}=d;return {id:f(u),type:n.type,parentId:s.parentId?f(s.parentId):void 0,config:w}}),p=[];return e&&e.forEach(n=>{let s={};if(n.buttons){s.buttons={};for(let[u,d]of Object.entries(n.buttons))a.has(d)&&(s.buttons[u]=a.get(d));}n.dpad&&a.has(n.dpad)&&(s.dpad=a.get(n.dpad)),n.leftStick&&a.has(n.leftStick)&&(s.leftStick=a.get(n.leftStick)),n.rightStick&&a.has(n.rightStick)&&(s.rightStick=a.get(n.rightStick)),Object.keys(s).length>0?p.push(s):p.push({});}),{meta:t,items:l,gamepadMappings:Object.keys(p).length>0?p:void 0}}function vt(t,r){let e={};for(let o in t)t[o]!==void 0&&!r.has(o)&&(e[o]=t[o]);return e}export{Z as createCachedProvider,at as createPointerBridge,nt as dispatchKeyboardEvent,rt as dispatchPointerEventAtPos,It as exportProfile,M as focusElement,S as generateUID,vt as getBusinessProps,E as getDeepActiveElement,v as getDeepElement,tt as getObjectDiff,m as isGlobalID,x as lengthToCss,k as parseLength,Pt as parseProfileJson,yt as parseProfileTrees,it as reclaimFocusAtPos,gt as resolveLayoutStyle,I as safeReleaseCapture,T as safeSetCapture,C as sanitizeParsedLength,ot as supportsContainerQueries};
|
package/package.json
CHANGED
package/dist/chunk-MSERY5BP.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var g=Object.defineProperty;var f=(e,t,n)=>t in e?g(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var b=(e,t,n)=>f(e,typeof t!="symbol"?t+"":t,n);var m=Symbol.for("omnipad.registry.instance"),h=class e{constructor(){b(this,"entities",new Map);import.meta.env?.DEV&&console.log("[OmniPad-Core] Registry initialized.");}static getInstance(){let t=globalThis;return t[m]||(t[m]=new e),t[m]}register(t){if(!t.uid){console.warn("[OmniPad-Core] Registry: Attempted to register entity without UID.",t);return}this.entities.has(t.uid),this.entities.set(t.uid,t);}unregister(t){this.entities.has(t)&&this.entities.delete(t);}getEntity(t){return this.entities.get(t)}getAllEntities(){return Array.from(this.entities.values())}getEntitiesByRoot(t){let n=this.getAllEntities();if(!t)return n;if(!this.entities.get(t))return console.warn(`[OmniPad-Core] Registry: Root entity ${t} not found.`),[];let o=new Map;n.forEach(c=>{let a=c;if(typeof a.getConfig=="function"){let u=a.getConfig();u.parentId&&(o.has(u.parentId)||o.set(u.parentId,[]),o.get(u.parentId).push(c));}});let i=[],s=[t],y=new Set;for(;s.length>0;){let c=s.shift();if(y.has(c))continue;y.add(c);let a=this.entities.get(c);if(a){i.push(a);let u=o.get(c);u&&u.forEach(d=>s.push(d.uid));}}return i}destroyByRoot(t){let n=this.getEntitiesByRoot(t);for(let r=n.length-1;r>=0;r--){let o=n[r];try{o.destroy();}catch(i){console.error(`[OmniPad-Core] Error during destroyByRoot at ${o.uid}:`,i);}}}clear(){this.entities.clear();}resetAll(){this.entities.forEach(t=>{"reset"in t&&t.reset(),"markRectDirty"in t&&t.markRectDirty();});}debugGetSnapshot(){return new Map(this.entities)}};var R=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),T=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),V=(e,t)=>({x:e.x*t,y:e.y*t}),x=(e,t,n)=>Math.max(t,Math.min(n,e)),M=(e,t,n)=>e+(t-e)*n,l=(e,t=2)=>{let n=Math.pow(10,t);return Math.round(e*n)/n},D=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),w=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),P=e=>e*180/Math.PI,A=e=>e*Math.PI/180,O=(e,t,n)=>{let r=t.x-e.x,o=t.y-e.y;if(Math.hypot(r,o)<=n)return t;let s=Math.atan2(o,r);return {x:e.x+Math.cos(s)*n,y:e.y+Math.sin(s)*n}},z=e=>{let t=Math.PI/4;return Math.round(e/t)*t},B=e=>{let t=Math.PI/2;return Math.round(e/t)*t},S=(e,t)=>l(e*t/100),k=(e,t)=>t===0?0:l(e*100/t),G=e=>{let t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},q=e=>({x:Math.cos(e),y:Math.sin(e)}),L=(e,t,n,r,o)=>{let i=(e-t)/(n-t);return M(r,o,x(i,0,1))},Y=(e,t,n=1e-4)=>Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n,p=(e,t,n)=>{if(e<t)return 0;let r=(e-t)/(n-t);return x(r,0,1)},$=(e,t,n)=>{let r=Math.hypot(e.x,e.y),o=t*n,i=p(r,o,t);if(i===0)return {x:0,y:0};let s={x:e.x/r,y:e.y/r};return V(s,i)},j=(e,t,n)=>({x:p(Math.abs(e.x),t,n)*Math.sign(e.x),y:p(Math.abs(e.y),t,n)*Math.sign(e.y)});export{b as a,h as b,R as c,T as d,V as e,x as f,M as g,l as h,D as i,w as j,P as k,A as l,O as m,z as n,B as o,S as p,k as q,G as r,q as s,L as t,Y as u,p as v,$ as w,j as x};
|