@omnipad/core 0.2.0-alpha.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,773 +1,5 @@
1
- /**
2
- * Interface defining the structure of a keyboard key mapping.
3
- * Ensures compatibility between modern web standards and legacy Flash requirements.
4
- */
5
- interface KeyMapping {
6
- /**
7
- * The key value, corresponding to `KeyboardEvent.key`.
8
- * Represented as a string (e.g., " ", "Enter", "a").
9
- */
10
- key: string;
11
- /**
12
- * The physical key code, corresponding to `KeyboardEvent.code`.
13
- * Describes the physical location of the key (e.g., "Space", "Enter", "KeyA").
14
- */
15
- code: string;
16
- /**
17
- * The legacy numerical key code, corresponding to `KeyboardEvent.keyCode`.
18
- * Essential for Flash engines (AS2/AS3) running via Ruffle.
19
- * e.g., 32 for Space, 13 for Enter.
20
- */
21
- keyCode: number;
22
- }
23
- /**
24
- * Standard collection of key mappings.
25
- * Allows developers to quickly retrieve mapping data using physical key codes as keys.
26
- */
27
- declare const KEYS: {
28
- readonly Backspace: {
29
- readonly key: "Backspace";
30
- readonly code: "Backspace";
31
- readonly keyCode: 8;
32
- };
33
- readonly Tab: {
34
- readonly key: "Tab";
35
- readonly code: "Tab";
36
- readonly keyCode: 9;
37
- };
38
- readonly Enter: {
39
- readonly key: "Enter";
40
- readonly code: "Enter";
41
- readonly keyCode: 13;
42
- };
43
- readonly ShiftLeft: {
44
- readonly key: "Shift";
45
- readonly code: "ShiftLeft";
46
- readonly keyCode: 16;
47
- };
48
- readonly ControlLeft: {
49
- readonly key: "Control";
50
- readonly code: "ControlLeft";
51
- readonly keyCode: 17;
52
- };
53
- readonly AltLeft: {
54
- readonly key: "Alt";
55
- readonly code: "AltLeft";
56
- readonly keyCode: 18;
57
- };
58
- readonly Pause: {
59
- readonly key: "Pause";
60
- readonly code: "Pause";
61
- readonly keyCode: 19;
62
- };
63
- readonly CapsLock: {
64
- readonly key: "CapsLock";
65
- readonly code: "CapsLock";
66
- readonly keyCode: 20;
67
- };
68
- readonly Escape: {
69
- readonly key: "Escape";
70
- readonly code: "Escape";
71
- readonly keyCode: 27;
72
- };
73
- readonly Space: {
74
- readonly key: " ";
75
- readonly code: "Space";
76
- readonly keyCode: 32;
77
- };
78
- readonly PageUp: {
79
- readonly key: "PageUp";
80
- readonly code: "PageUp";
81
- readonly keyCode: 33;
82
- };
83
- readonly PageDown: {
84
- readonly key: "PageDown";
85
- readonly code: "PageDown";
86
- readonly keyCode: 34;
87
- };
88
- readonly End: {
89
- readonly key: "End";
90
- readonly code: "End";
91
- readonly keyCode: 35;
92
- };
93
- readonly Home: {
94
- readonly key: "Home";
95
- readonly code: "Home";
96
- readonly keyCode: 36;
97
- };
98
- readonly ArrowLeft: {
99
- readonly key: "ArrowLeft";
100
- readonly code: "ArrowLeft";
101
- readonly keyCode: 37;
102
- };
103
- readonly ArrowUp: {
104
- readonly key: "ArrowUp";
105
- readonly code: "ArrowUp";
106
- readonly keyCode: 38;
107
- };
108
- readonly ArrowRight: {
109
- readonly key: "ArrowRight";
110
- readonly code: "ArrowRight";
111
- readonly keyCode: 39;
112
- };
113
- readonly ArrowDown: {
114
- readonly key: "ArrowDown";
115
- readonly code: "ArrowDown";
116
- readonly keyCode: 40;
117
- };
118
- readonly PrintScreen: {
119
- readonly key: "PrintScreen";
120
- readonly code: "PrintScreen";
121
- readonly keyCode: 44;
122
- };
123
- readonly Insert: {
124
- readonly key: "Insert";
125
- readonly code: "Insert";
126
- readonly keyCode: 45;
127
- };
128
- readonly Delete: {
129
- readonly key: "Delete";
130
- readonly code: "Delete";
131
- readonly keyCode: 46;
132
- };
133
- readonly Digit0: {
134
- readonly key: "0";
135
- readonly code: "Digit0";
136
- readonly keyCode: 48;
137
- };
138
- readonly Digit1: {
139
- readonly key: "1";
140
- readonly code: "Digit1";
141
- readonly keyCode: 49;
142
- };
143
- readonly Digit2: {
144
- readonly key: "2";
145
- readonly code: "Digit2";
146
- readonly keyCode: 50;
147
- };
148
- readonly Digit3: {
149
- readonly key: "3";
150
- readonly code: "Digit3";
151
- readonly keyCode: 51;
152
- };
153
- readonly Digit4: {
154
- readonly key: "4";
155
- readonly code: "Digit4";
156
- readonly keyCode: 52;
157
- };
158
- readonly Digit5: {
159
- readonly key: "5";
160
- readonly code: "Digit5";
161
- readonly keyCode: 53;
162
- };
163
- readonly Digit6: {
164
- readonly key: "6";
165
- readonly code: "Digit6";
166
- readonly keyCode: 54;
167
- };
168
- readonly Digit7: {
169
- readonly key: "7";
170
- readonly code: "Digit7";
171
- readonly keyCode: 55;
172
- };
173
- readonly Digit8: {
174
- readonly key: "8";
175
- readonly code: "Digit8";
176
- readonly keyCode: 56;
177
- };
178
- readonly Digit9: {
179
- readonly key: "9";
180
- readonly code: "Digit9";
181
- readonly keyCode: 57;
182
- };
183
- readonly KeyA: {
184
- readonly key: "a";
185
- readonly code: "KeyA";
186
- readonly keyCode: 65;
187
- };
188
- readonly KeyB: {
189
- readonly key: "b";
190
- readonly code: "KeyB";
191
- readonly keyCode: 66;
192
- };
193
- readonly KeyC: {
194
- readonly key: "c";
195
- readonly code: "KeyC";
196
- readonly keyCode: 67;
197
- };
198
- readonly KeyD: {
199
- readonly key: "d";
200
- readonly code: "KeyD";
201
- readonly keyCode: 68;
202
- };
203
- readonly KeyE: {
204
- readonly key: "e";
205
- readonly code: "KeyE";
206
- readonly keyCode: 69;
207
- };
208
- readonly KeyF: {
209
- readonly key: "f";
210
- readonly code: "KeyF";
211
- readonly keyCode: 70;
212
- };
213
- readonly KeyG: {
214
- readonly key: "g";
215
- readonly code: "KeyG";
216
- readonly keyCode: 71;
217
- };
218
- readonly KeyH: {
219
- readonly key: "h";
220
- readonly code: "KeyH";
221
- readonly keyCode: 72;
222
- };
223
- readonly KeyI: {
224
- readonly key: "i";
225
- readonly code: "KeyI";
226
- readonly keyCode: 73;
227
- };
228
- readonly KeyJ: {
229
- readonly key: "j";
230
- readonly code: "KeyJ";
231
- readonly keyCode: 74;
232
- };
233
- readonly KeyK: {
234
- readonly key: "k";
235
- readonly code: "KeyK";
236
- readonly keyCode: 75;
237
- };
238
- readonly KeyL: {
239
- readonly key: "l";
240
- readonly code: "KeyL";
241
- readonly keyCode: 76;
242
- };
243
- readonly KeyM: {
244
- readonly key: "m";
245
- readonly code: "KeyM";
246
- readonly keyCode: 77;
247
- };
248
- readonly KeyN: {
249
- readonly key: "n";
250
- readonly code: "KeyN";
251
- readonly keyCode: 78;
252
- };
253
- readonly KeyO: {
254
- readonly key: "o";
255
- readonly code: "KeyO";
256
- readonly keyCode: 79;
257
- };
258
- readonly KeyP: {
259
- readonly key: "p";
260
- readonly code: "KeyP";
261
- readonly keyCode: 80;
262
- };
263
- readonly KeyQ: {
264
- readonly key: "q";
265
- readonly code: "KeyQ";
266
- readonly keyCode: 81;
267
- };
268
- readonly KeyR: {
269
- readonly key: "r";
270
- readonly code: "KeyR";
271
- readonly keyCode: 82;
272
- };
273
- readonly KeyS: {
274
- readonly key: "s";
275
- readonly code: "KeyS";
276
- readonly keyCode: 83;
277
- };
278
- readonly KeyT: {
279
- readonly key: "t";
280
- readonly code: "KeyT";
281
- readonly keyCode: 84;
282
- };
283
- readonly KeyU: {
284
- readonly key: "u";
285
- readonly code: "KeyU";
286
- readonly keyCode: 85;
287
- };
288
- readonly KeyV: {
289
- readonly key: "v";
290
- readonly code: "KeyV";
291
- readonly keyCode: 86;
292
- };
293
- readonly KeyW: {
294
- readonly key: "w";
295
- readonly code: "KeyW";
296
- readonly keyCode: 87;
297
- };
298
- readonly KeyX: {
299
- readonly key: "x";
300
- readonly code: "KeyX";
301
- readonly keyCode: 88;
302
- };
303
- readonly KeyY: {
304
- readonly key: "y";
305
- readonly code: "KeyY";
306
- readonly keyCode: 89;
307
- };
308
- readonly KeyZ: {
309
- readonly key: "z";
310
- readonly code: "KeyZ";
311
- readonly keyCode: 90;
312
- };
313
- readonly MetaLeft: {
314
- readonly key: "Meta";
315
- readonly code: "MetaLeft";
316
- readonly keyCode: 91;
317
- };
318
- readonly ContextMenu: {
319
- readonly key: "ContextMenu";
320
- readonly code: "ContextMenu";
321
- readonly keyCode: 93;
322
- };
323
- readonly Numpad0: {
324
- readonly key: "0";
325
- readonly code: "Numpad0";
326
- readonly keyCode: 96;
327
- };
328
- readonly Numpad1: {
329
- readonly key: "1";
330
- readonly code: "Numpad1";
331
- readonly keyCode: 97;
332
- };
333
- readonly Numpad2: {
334
- readonly key: "2";
335
- readonly code: "Numpad2";
336
- readonly keyCode: 98;
337
- };
338
- readonly Numpad3: {
339
- readonly key: "3";
340
- readonly code: "Numpad3";
341
- readonly keyCode: 99;
342
- };
343
- readonly Numpad4: {
344
- readonly key: "4";
345
- readonly code: "Numpad4";
346
- readonly keyCode: 100;
347
- };
348
- readonly Numpad5: {
349
- readonly key: "5";
350
- readonly code: "Numpad5";
351
- readonly keyCode: 101;
352
- };
353
- readonly Numpad6: {
354
- readonly key: "6";
355
- readonly code: "Numpad6";
356
- readonly keyCode: 102;
357
- };
358
- readonly Numpad7: {
359
- readonly key: "7";
360
- readonly code: "Numpad7";
361
- readonly keyCode: 103;
362
- };
363
- readonly Numpad8: {
364
- readonly key: "8";
365
- readonly code: "Numpad8";
366
- readonly keyCode: 104;
367
- };
368
- readonly Numpad9: {
369
- readonly key: "9";
370
- readonly code: "Numpad9";
371
- readonly keyCode: 105;
372
- };
373
- readonly NumpadMultiply: {
374
- readonly key: "*";
375
- readonly code: "NumpadMultiply";
376
- readonly keyCode: 106;
377
- };
378
- readonly NumpadAdd: {
379
- readonly key: "+";
380
- readonly code: "NumpadAdd";
381
- readonly keyCode: 107;
382
- };
383
- readonly NumpadSubtract: {
384
- readonly key: "-";
385
- readonly code: "NumpadSubtract";
386
- readonly keyCode: 109;
387
- };
388
- readonly NumpadDecimal: {
389
- readonly key: ".";
390
- readonly code: "NumpadDecimal";
391
- readonly keyCode: 110;
392
- };
393
- readonly NumpadDivide: {
394
- readonly key: "/";
395
- readonly code: "NumpadDivide";
396
- readonly keyCode: 111;
397
- };
398
- readonly F1: {
399
- readonly key: "F1";
400
- readonly code: "F1";
401
- readonly keyCode: 112;
402
- };
403
- readonly F2: {
404
- readonly key: "F2";
405
- readonly code: "F2";
406
- readonly keyCode: 113;
407
- };
408
- readonly F3: {
409
- readonly key: "F3";
410
- readonly code: "F3";
411
- readonly keyCode: 114;
412
- };
413
- readonly F4: {
414
- readonly key: "F4";
415
- readonly code: "F4";
416
- readonly keyCode: 115;
417
- };
418
- readonly F5: {
419
- readonly key: "F5";
420
- readonly code: "F5";
421
- readonly keyCode: 116;
422
- };
423
- readonly F6: {
424
- readonly key: "F6";
425
- readonly code: "F6";
426
- readonly keyCode: 117;
427
- };
428
- readonly F7: {
429
- readonly key: "F7";
430
- readonly code: "F7";
431
- readonly keyCode: 118;
432
- };
433
- readonly F8: {
434
- readonly key: "F8";
435
- readonly code: "F8";
436
- readonly keyCode: 119;
437
- };
438
- readonly F9: {
439
- readonly key: "F9";
440
- readonly code: "F9";
441
- readonly keyCode: 120;
442
- };
443
- readonly F10: {
444
- readonly key: "F10";
445
- readonly code: "F10";
446
- readonly keyCode: 121;
447
- };
448
- readonly F11: {
449
- readonly key: "F11";
450
- readonly code: "F11";
451
- readonly keyCode: 122;
452
- };
453
- readonly F12: {
454
- readonly key: "F12";
455
- readonly code: "F12";
456
- readonly keyCode: 123;
457
- };
458
- readonly NumLock: {
459
- readonly key: "NumLock";
460
- readonly code: "NumLock";
461
- readonly keyCode: 144;
462
- };
463
- readonly ScrollLock: {
464
- readonly key: "ScrollLock";
465
- readonly code: "ScrollLock";
466
- readonly keyCode: 145;
467
- };
468
- readonly Semicolon: {
469
- readonly key: ";";
470
- readonly code: "Semicolon";
471
- readonly keyCode: 186;
472
- };
473
- readonly Equal: {
474
- readonly key: "=";
475
- readonly code: "Equal";
476
- readonly keyCode: 187;
477
- };
478
- readonly Comma: {
479
- readonly key: ",";
480
- readonly code: "Comma";
481
- readonly keyCode: 188;
482
- };
483
- readonly Minus: {
484
- readonly key: "-";
485
- readonly code: "Minus";
486
- readonly keyCode: 189;
487
- };
488
- readonly Period: {
489
- readonly key: ".";
490
- readonly code: "Period";
491
- readonly keyCode: 190;
492
- };
493
- readonly Slash: {
494
- readonly key: "/";
495
- readonly code: "Slash";
496
- readonly keyCode: 191;
497
- };
498
- readonly Backquote: {
499
- readonly key: "`";
500
- readonly code: "Backquote";
501
- readonly keyCode: 192;
502
- };
503
- readonly BracketLeft: {
504
- readonly key: "[";
505
- readonly code: "BracketLeft";
506
- readonly keyCode: 219;
507
- };
508
- readonly Backslash: {
509
- readonly key: "\\";
510
- readonly code: "Backslash";
511
- readonly keyCode: 220;
512
- };
513
- readonly BracketRight: {
514
- readonly key: "]";
515
- readonly code: "BracketRight";
516
- readonly keyCode: 221;
517
- };
518
- readonly Quote: {
519
- readonly key: "'";
520
- readonly code: "Quote";
521
- readonly keyCode: 222;
522
- };
523
- };
524
-
525
- /**
526
- * Defines the spatial properties of a component.
527
- * Supports various CSS units (px, %, vh, vw) via FlexibleLength.
528
- */
529
- interface LayoutBox {
530
- /** Offset from the left edge of the parent container. */
531
- left?: FlexibleLength;
532
- /** Offset from the top edge of the parent container. */
533
- top?: FlexibleLength;
534
- /** Offset from the right edge of the parent container. */
535
- right?: FlexibleLength;
536
- /** Offset from the bottom edge of the parent container. */
537
- bottom?: FlexibleLength;
538
- /** Width of the component. */
539
- width?: FlexibleLength;
540
- /** Height of the component. */
541
- height?: FlexibleLength;
542
- /**
543
- * The alignment point of the component relative to its (left, top) coordinates.
544
- * @example 'center' will center the component on its position.
545
- */
546
- anchor?: AnchorPoint;
547
- /** Rotation angle in degrees. */
548
- /** Z-index for layering control. */
549
- zIndex?: number;
550
- }
551
- /**
552
- * Base configuration interface for all components.
553
- */
554
- interface BaseConfig {
555
- /**
556
- * Config ID (CID) used in persistent storage.
557
- * If omitted, a random UID will be generated during parsing.
558
- * If starts with '$', it points to a global static entity. (UID = CID)
559
- */
560
- id?: string;
561
- /** The unique type identifier for the component. */
562
- type: string;
563
- /** CID of the parent component. Root components have no parentId. */
564
- parentId?: string;
565
- /** Spatial layout settings. */
566
- layout: LayoutBox;
567
- }
568
- /**
569
- * Configuration for a virtual keyboard button.
570
- */
571
- interface KeyboardButtonConfig extends BaseConfig {
572
- type: typeof CMP_TYPES.KEYBOARD_BUTTON;
573
- /** Visual text displayed on the button. */
574
- label: string;
575
- /** Keyboard event metadata to be emitted when triggered. */
576
- mapping: KeyMapping;
577
- /**
578
- * CID of the TargetZone where signals should be dispatched.
579
- */
580
- targetStageId?: string;
581
- }
582
- /**
583
- * Mouse Button Configuration
584
- */
585
- interface MouseButtonConfig extends BaseConfig {
586
- type: typeof CMP_TYPES.MOUSE_BUTTON;
587
- /** Label displayed on the button */
588
- label: string;
589
- /**
590
- * 0: Left (Main), 1: Middle, 2: Right (Context)
591
- * @default 0
592
- */
593
- button: 0 | 1 | 2;
594
- /** CID of the target Stage to receive clicks */
595
- targetStageId?: string;
596
- /**
597
- * Fixed coordinate to click on (0-100 percentage).
598
- * If provided, the click always hits this spot regardless of cursor position.
599
- */
600
- fixedPoint?: Vec2;
601
- }
602
- interface TrackpadConfig extends BaseConfig {
603
- type: typeof CMP_TYPES.TRACKPAD;
604
- /** Label displayed on the trackpad */
605
- label: string;
606
- /** Simulation sensitivity, e.g. 0.5 - 2.0 */
607
- sensitivity: number;
608
- /** CID of the target Stage to receive clicks */
609
- targetStageId?: string;
610
- }
611
- /**
612
- * Configuration for an Input Zone.
613
- * Input Zones act as containers and can handle dynamic (floating) widgets.
614
- */
615
- interface InputZoneConfig extends BaseConfig {
616
- type: typeof CMP_TYPES.INPUT_ZONE;
617
- /** If true, attempts to regain focus for the target stage when touched. */
618
- preventFocusLoss?: boolean;
619
- /**
620
- * The CID of a child component intended to be used as a dynamic (floating) widget.
621
- */
622
- dynamicWidgetId?: string;
623
- }
624
- /**
625
- * Configuration for a Target Focus Zone.
626
- * Acts as the bridge between virtual signals and the actual game/app DOM.
627
- */
628
- interface TargetZoneConfig extends BaseConfig {
629
- type: typeof CMP_TYPES.TARGET_ZONE;
630
- /** Whether to render a visual virtual cursor. */
631
- cursorEnabled?: boolean;
632
- /** Time in milliseconds before the cursor auto-hides after inactivity. 0 to disable. */
633
- cursorAutoDelay?: number;
634
- }
635
- /**
636
- * Union type representing any valid component configuration.
637
- */
638
- type AnyConfig = KeyboardButtonConfig | InputZoneConfig | TargetZoneConfig | any;
639
- /**
640
- * Representation of a single item in a flattened configuration profile.
641
- * Ideal for database storage and flat-list editing.
642
- */
643
- interface FlatConfigItem {
644
- /** Unique identifier (CID) in the scope of the profile. */
645
- id: string;
646
- /** Component type string. */
647
- type: string;
648
- /** Parent CID. Empty if this is the root node. */
649
- parentId?: string;
650
- /** Flattened business logic and layout properties. */
651
- config?: Record<string, any>;
652
- }
653
- /**
654
- * The root structure of a Gamepad configuration file.
655
- */
656
- interface GamepadProfile {
657
- /** Metadata about the profile creator and version. */
658
- meta: {
659
- name: string;
660
- version: string;
661
- author?: string;
662
- };
663
- /** The CID of the entry-point component (usually a root layer or zone, or widget for individual widget config). */
664
- rootId: string;
665
- /** List of all components in the profile. Hierarchies are defined via parentId. */
666
- items: FlatConfigItem[];
667
- }
668
- /**
669
- * A recursive tree structure representing the runtime hierarchy of components.
670
- * Used by the adapter layer (e.g., Vue) to render components recursively.
671
- */
672
- interface ConfigTreeNode {
673
- /** Runtime Unique Entity ID (UID), unique across the entire application. */
674
- uid: string;
675
- /** Component type string. */
676
- type: string;
677
- /** Component properties (layout, mapping, etc.), stripped of hierarchy data. */
678
- config?: Record<string, any>;
679
- /** Nested children tree nodes. */
680
- children?: ConfigTreeNode[];
681
- }
682
-
683
- /**
684
- * Trait: Provides identity with a unique ID and specific entity type.
685
- */
686
- interface IIdentifiable {
687
- readonly uid: string;
688
- readonly type: EntityType;
689
- }
690
- /**
691
- * Trait: Provides lifecycle management hooks.
692
- */
693
- interface ILifecycle {
694
- /**
695
- * Performs cleanup, unregisters the entity, and releases resources.
696
- */
697
- destroy(): void;
698
- }
699
- /**
700
- * The core contract for any object that can be managed by the Registry.
701
- * Only objects implementing this interface are eligible for registration.
702
- */
703
- interface ICoreEntity extends IIdentifiable, ILifecycle {
704
- }
705
- /**
706
- * Trait: Enables spatial awareness for DOM/UI-related components.
707
- */
708
- interface ISpatial {
709
- /**
710
- * Dynamically obtain dimensions and position to ensure the most precise real-time screen coordinates are obtained during each interaction.
711
- */
712
- bindRectProvider(provider: () => DOMRect): void;
713
- }
714
- /**
715
- * Trait: Provides configuration management.
716
- */
717
- interface IConfigurable<TConfig> {
718
- /**
719
- * Dynamically updates the current configuration.
720
- * @param config - Partial configuration object to merge.
721
- */
722
- updateConfig(config: Partial<TConfig>): void;
723
- /**
724
- * Retrieves a snapshot of the current configuration.
725
- */
726
- getConfig(): TConfig;
727
- }
728
- /**
729
- * Trait: Enables state subscription for the adapter layer (e.g., Vue/React).
730
- */
731
- interface IObservable<TState> {
732
- /**
733
- * Subscribes to state changes.
734
- * @param cb - Callback function triggered on state updates.
735
- * @returns An unsubscribe function.
736
- */
737
- subscribe(cb: (state: TState) => void): () => void;
738
- /**
739
- * Retrieves the current state snapshot.
740
- */
741
- getState(): TState;
742
- }
743
- /**
744
- * Trait: Allows resetting the entity to its idle/safe state.
745
- */
746
- interface IResettable {
747
- /**
748
- * Forcefully clears active states and cuts off outgoing signals.
749
- */
750
- reset(): void;
751
- }
752
- /**
753
- * Trait: Handles raw pointer input (Touch/Mouse).
754
- */
755
- interface IPointerHandler {
756
- onPointerDown(e: PointerEvent): void;
757
- onPointerMove(e: PointerEvent): void;
758
- onPointerUp(e: PointerEvent): void;
759
- onPointerCancel(e: PointerEvent): void;
760
- }
761
- /**
762
- * Trait: Receives and processes input signals (e.g., TargetZone).
763
- */
764
- interface ISignalReceiver {
765
- /**
766
- * Handles incoming signals from widgets.
767
- * @param signal - The signal data containing action type and payload.
768
- */
769
- handleSignal(signal: InputActionSignal): void;
770
- }
1
+ import { I as ICoreEntity, V as Vec2, G as GamepadMappingConfig, a as ISpatial, b as IResettable, c as IConfigurable, d as IObservable, E as EntityType, A as AbstractRect, B as ButtonConfig, e as IPointerHandler, f as IProgrammatic, g as AbstractPointerEvent, D as DPadConfig, h as InputZoneConfig, i as IDependencyBindable, j as AnyFunction, J as JoystickConfig, k as BaseConfig, T as TargetZoneConfig, l as ISignalReceiver, m as InputActionSignal, n as TrackpadConfig } from './index-DRA1rw5_.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, F as FlatConfigItem, w as FlexibleLength, x as GamepadProfile, y as IIdentifiable, z as ILifecycle, H as InputActionType, K as KEYS, L as KeyMapping, M as LayoutBox, S as StageId, N as StandardButton, U as Unit, W as WidgetId, O as WidgetType, Z as ZoneId, P as ZoneType } from './index-DRA1rw5_.js';
771
3
 
772
4
  /**
773
5
  * Interface for the global Registry singleton.
@@ -851,17 +83,15 @@ interface ButtonLogicState {
851
83
  value: number;
852
84
  }
853
85
  /**
854
- * Logic-level state for joystick-type widgets.
855
- * Provides directional data calculated from the stick movement.
86
+ * Logic-level state for axis-type or joystick widgets.
87
+ * Represents the normalized directional input.
856
88
  */
857
- interface JoystickLogicState {
89
+ interface AxisLogicState {
858
90
  /** Normalized direction vector where x and y range from -1.0 to 1.0. */
859
91
  vector: {
860
92
  x: number;
861
93
  y: number;
862
94
  };
863
- /** The current angle of the stick in radians. */
864
- angle: number;
865
95
  }
866
96
  /**
867
97
  * Runtime state for the Virtual Cursor within a TargetZone.
@@ -894,6 +124,11 @@ interface LayerState {
894
124
  /** Visual hint for layout debugging or active selection. */
895
125
  isHighlighted: boolean;
896
126
  }
127
+ /**
128
+ * Combined state for Button components.
129
+ */
130
+ interface ButtonState extends InteractionState, ButtonLogicState {
131
+ }
897
132
  /**
898
133
  * Combined state for Keyboard Button components.
899
134
  */
@@ -910,409 +145,77 @@ interface MouseButtonState extends InteractionState, ButtonLogicState {
910
145
  interface TrackpadState extends InteractionState, ButtonLogicState {
911
146
  }
912
147
  /**
913
- * Combined state for Analog Stick components.
914
- */
915
- interface JoystickState extends InteractionState, JoystickLogicState {
916
- }
917
-
918
- /**
919
- * =================================================================
920
- * 1. Constants Definition
921
- * Used for runtime logic and as a baseline for type definitions.
922
- * =================================================================
148
+ * Combined state for D-pad components.
923
149
  */
924
- /**
925
- * Core entity types supported by the library.
926
- */
927
- declare const CMP_TYPES: {
928
- /** Area responsible for capturing touches and spawning dynamic widgets */
929
- readonly INPUT_ZONE: "input-zone";
930
- /** Area responsible for receiving signals and simulating DOM events */
931
- readonly TARGET_ZONE: "target-zone";
932
- /** Simulates a physical keyboard key press */
933
- readonly KEYBOARD_BUTTON: "keyboard-button";
934
- /** Simulates a mouse button click/hold */
935
- readonly MOUSE_BUTTON: "mouse-button";
936
- /** A joystick that outputs 360-degree or locked direction vectors */
937
- readonly ANALOG_STICK: "analog-stick";
938
- /** Classic 4/8-way directional pad */
939
- readonly D_PAD: "d-pad";
940
- /** Trackpad-style relative movement area */
941
- readonly TRACKPAD: "trackpad";
942
- /** Logic for the on-screen visual cursor */
943
- readonly VIRTUAL_CURSOR: "virtual-cursor";
944
- /** The top-level managed container */
945
- readonly ROOT_LAYER: "root-layer";
946
- };
947
- /**
948
- * Standardized input action types for the signal protocol.
949
- */
950
- declare const ACTION_TYPES: {
951
- readonly KEYDOWN: "keydown";
952
- readonly KEYUP: "keyup";
953
- readonly POINTER: "pointer";
954
- readonly POINTERMOVE: "pointermove";
955
- readonly POINTERDOWN: "pointerdown";
956
- readonly POINTERUP: "pointerup";
957
- readonly MOUSE: "mouse";
958
- readonly MOUSEMOVE: "mousemove";
959
- readonly MOUSEDOWN: "mousedown";
960
- readonly MOUSEUP: "mouseup";
961
- readonly CLICK: "click";
962
- };
963
- /**
964
- * =================================================================
965
- * 2. Type Definitions
966
- * =================================================================
967
- */
968
- /**
969
- * Represents a 2D coordinate or vector.
970
- * Typically used for percentage-based positioning (0-100).
971
- */
972
- interface Vec2 {
973
- x: number;
974
- y: number;
150
+ interface DPadState extends InteractionState, AxisLogicState {
975
151
  }
976
- /** Unique identifier for a Stage (TargetZone) */
977
- type StageId = string;
978
- /** Unique identifier for an Input Widget */
979
- type WidgetId = string;
980
- /** Unique identifier for a Zone container (InputZone) */
981
- type ZoneId = string;
982
- /** Union type of all built-in entity values */
983
- type AnyEntityType = (typeof CMP_TYPES)[keyof typeof CMP_TYPES];
984
- /** Supported Widget type strings, allowing for custom string extensions */
985
- type WidgetType = typeof CMP_TYPES.KEYBOARD_BUTTON | typeof CMP_TYPES.MOUSE_BUTTON | typeof CMP_TYPES.ANALOG_STICK | typeof CMP_TYPES.D_PAD | typeof CMP_TYPES.TRACKPAD | (string & {});
986
- /** Supported Zone type strings, allowing for custom string extensions */
987
- type ZoneType = typeof CMP_TYPES.INPUT_ZONE | typeof CMP_TYPES.TARGET_ZONE | (string & {});
988
- /** General node type identifier for ConfigTreeNode or Registry lookups */
989
- type EntityType = AnyEntityType | (string & {});
990
- /** Built-in input action identifiers */
991
- type BuiltInActionType = (typeof ACTION_TYPES)[keyof typeof ACTION_TYPES];
992
- /** Input action type strings, allowing for custom action extensions */
993
- type InputActionType = BuiltInActionType | (string & {});
994
- /** Supported CSS units for layout calculation */
995
- type Unit = 'px' | '%' | 'vh' | 'vw' | 'rem';
996
- /**
997
- * Flexible length input.
998
- * Supports numbers (interpreted as px) or strings (e.g., '50%', '10vh').
999
- */
1000
- type FlexibleLength = string | number;
1001
- /**
1002
- * Anchor position used to determine the alignment of an element relative to its coordinates.
1003
- */
1004
- type AnchorPoint = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
1005
152
  /**
1006
- * =================================================================
1007
- * 3. Signal Protocol
1008
- * Data structure for communication between Widgets and Stages.
1009
- * =================================================================
153
+ * Combined state for Joystick components.
1010
154
  */
1011
- /**
1012
- * Represents a signal emitted by an input widget to be processed by a target zone.
1013
- */
1014
- interface InputActionSignal {
1015
- /** The unique identifier of the destination TargetZone */
1016
- targetStageId: StageId;
1017
- /** The action type to perform (e.g., keydown, mousemove) */
1018
- type: InputActionType;
1019
- /** The payload containing specific input details */
1020
- payload: {
1021
- /** Character value of the key (e.g., ' ') */
1022
- key?: string;
1023
- /** Physical key code (e.g., 'Space') */
1024
- code?: string;
1025
- /** Legacy numeric key code (e.g., 32) */
1026
- keyCode?: number;
1027
- /** Coordinate point in percentage (0-100) */
1028
- point?: Vec2;
1029
- /** Relative displacement in percentage (0-100) */
1030
- delta?: Vec2;
1031
- /** Mouse button index (0: Left, 1: Middle, 2: Right) */
1032
- button?: 0 | 1 | 2;
1033
- /** Input pressure or force (0.0 to 1.0) */
1034
- pressure?: number;
1035
- /** Allows for arbitrary custom data to support widget extensions */
1036
- [key: string]: any;
1037
- };
155
+ interface JoystickState extends InteractionState, AxisLogicState, ButtonLogicState {
1038
156
  }
1039
- /**
1040
- * Cross-framework context keys for dependency injection (e.g., Provide/Inject).
1041
- */
1042
- declare const CONTEXT: {
1043
- /** The key used to propagate Parent IDs through the component tree */
1044
- readonly PARENT_ID_KEY: "omnipad-parent-id-link";
1045
- };
1046
157
 
1047
158
  /**
1048
- * Subtracts vector v2 from v1.
1049
- * @param v1 - The source vector.
1050
- * @param v2 - The vector to subtract.
1051
- */
1052
- declare const subVec: (v1: Vec2, v2: Vec2) => Vec2;
1053
- /**
1054
- * Adds vector v2 to v1.
1055
- */
1056
- declare const addVec: (v1: Vec2, v2: Vec2) => Vec2;
1057
- /**
1058
- * Scales a vector by a scalar value.
1059
- * Useful for mapping normalized vectors back to specific pixel magnitudes.
1060
- */
1061
- declare const scaleVec: (v: Vec2, s: number) => Vec2;
1062
- /**
1063
- * Clamps a numeric value between a minimum and maximum range.
1064
- */
1065
- declare const clamp: (val: number, min: number, max: number) => number;
1066
- /**
1067
- * Linearly interpolates between two values.
1068
- */
1069
- declare const lerp: (start: number, end: number, t: number) => number;
1070
- /**
1071
- * Rounds a number to a specific decimal precision.
1072
- * Solves floating-point precision issues in pixel calculations.
1073
- */
1074
- declare const roundTo: (val: number, precision?: number) => number;
1075
- /**
1076
- * Calculates the Euclidean distance between two points.
1077
- */
1078
- declare const getDistance: (p1: Vec2, p2: Vec2) => number;
1079
- /**
1080
- * Calculates the angle in radians from point p1 to p2.
1081
- * Range: -PI to PI.
1082
- */
1083
- declare const getAngle: (p1: Vec2, p2: Vec2) => number;
1084
- /**
1085
- * Converts radians to degrees.
1086
- */
1087
- declare const radToDeg: (rad: number) => number;
1088
- /**
1089
- * Converts degrees to radians.
1090
- */
1091
- declare const degToRad: (deg: number) => number;
1092
- /**
1093
- * Constrains a target point within a circular radius relative to an origin.
1094
- * Commonly used for joystick physical displacement limits.
1095
- */
1096
- declare const clampVector: (origin: Vec2, target: Vec2, radius: number) => Vec2;
1097
- /**
1098
- * Snaps a radian angle to the nearest of 8 directions (45-degree steps).
1099
- */
1100
- declare const lockTo8Directions: (rad: number) => number;
1101
- /**
1102
- * Snaps a radian angle to the nearest of 4 directions (90-degree steps).
1103
- */
1104
- declare const lockTo4Directions: (rad: number) => number;
1105
- /**
1106
- * Converts percentage (0-100) to pixel values (px).
1107
- */
1108
- declare const percentToPx: (percent: number, totalPx: number) => number;
1109
- /**
1110
- * Converts pixel values (px) to percentage (0-100).
1111
- */
1112
- declare const pxToPercent: (px: number, totalPx: number) => number;
1113
- /**
1114
- * Normalizes a vector to a length of 1.
1115
- * Returns {0, 0} if the vector magnitude is 0.
1116
- */
1117
- declare const normalizeVec: (v: Vec2) => Vec2;
1118
- /**
1119
- * Converts a radian angle to a unit vector.
1120
- */
1121
- declare const radToVec: (rad: number) => Vec2;
1122
- /**
1123
- * Linearly remaps a value from one range [inMin, inMax] to another [outMin, outMax].
1124
- */
1125
- declare const remap: (val: number, inMin: number, inMax: number, outMin: number, outMax: number) => number;
1126
- /**
1127
- * Performs a dirty check to see if two Vec2 points are different within an epsilon.
1128
- */
1129
- declare const isVec2Equal: (v1: Vec2, v2: Vec2, epsilon?: number) => boolean;
1130
- /**
1131
- * Core deadzone logic.
1132
- * Maps a value from [threshold, max] to a normalized scale [0, 1].
1133
- * @returns A scalar value between 0 and 1.
1134
- */
1135
- declare const getDeadzoneScalar: (magnitude: number, threshold: number, max: number) => number;
1136
- /**
1137
- * Applies a radial deadzone to a vector.
1138
- * Suitable for analog sticks to ensure a smooth transition from center.
1139
- * @param v - Input vector.
1140
- * @param radius - The total radius of the joystick base.
1141
- * @param deadzonePercent - Deadzone threshold (0.0 to 1.0).
1142
- */
1143
- declare const applyRadialDeadzone: (v: Vec2, radius: number, deadzonePercent: number) => Vec2;
1144
- /**
1145
- * Applies an axial deadzone to a vector.
1146
- * Independently processes X and Y axes. Useful for D-Pads or precision directional inputs.
1147
- * @param v - Input vector.
1148
- * @param threshold - The deadzone threshold value.
1149
- * @param max - Maximum value for the axis.
1150
- */
1151
- declare const applyAxialDeadzone: (v: Vec2, threshold: number, max: number) => Vec2;
1152
-
1153
- /**
1154
- * Recursively penetrates Shadow DOM boundaries to find the deepest element at the
1155
- * specified viewport coordinates.
159
+ * GamepadManager
1156
160
  *
1157
- * @param x - Viewport X coordinate (px)
1158
- * @param y - Viewport Y coordinate (px)
1159
- * @param ignoreClass - Style class of DOM elements to be ignored
1160
- * @returns The deepmost Element or null if none found at the position.
1161
- */
1162
- declare const getDeepElement: (x: number, y: number, ignoreClass?: string) => Element | null;
1163
- /**
1164
- * Recursively finds the truly focused element by traversing Shadow DOM boundaries.
161
+ * A singleton service that polls the browser Gamepad API via requestAnimationFrame.
162
+ * It translates physical hardware inputs into programmatic signals sent to
163
+ * virtual entities registered in the system.
1165
164
  *
1166
- * @returns The deepmost active Element in focus or null.
1167
- */
1168
- declare const getDeepActiveElement: () => Element | null;
1169
- /**
1170
- * Forcefully focuses an element.
1171
- * Automatically handles the 'tabindex' attribute to ensure non-focusable elements (like Canvas)
1172
- * can receive focus.
1173
- *
1174
- * @param el - The target HTMLElement to focus.
1175
- */
1176
- declare const focusElement: (el: HTMLElement) => void;
1177
- /**
1178
- * Dispatches a synthetic KeyboardEvent to the window object.
1179
- *
1180
- * @param type - The event type, e.g., 'keydown' or 'keyup'.
1181
- * @param payload - Key mapping data including key, code, and legacy keyCode.
1182
- */
1183
- declare const dispatchKeyboardEvent: (type: string, payload: {
1184
- key: string;
1185
- code: string;
1186
- keyCode: number;
1187
- }) => void;
1188
- /**
1189
- * Dispatches a high-fidelity sequence of Pointer and Mouse events at specific pixel coordinates.
1190
- * Finds the target element dynamically at the moment of dispatch.
1191
- *
1192
- * @param type - The event type (should start with 'pointer' for best compatibility).
1193
- * @param x - Viewport X coordinate (px).
1194
- * @param y - Viewport Y coordinate (px).
1195
- * @param opts - Additional PointerEvent options (button, pressure, etc.).
1196
- */
1197
- declare const dispatchPointerEventAtPos: (type: string, x: number, y: number, opts?: PointerEventInit) => void;
1198
- /**
1199
- * Calculates the pixel coordinate of an anchor point within a given DOMRect.
1200
- * Used to translate relative layout definitions into screen-space pixels.
1201
- *
1202
- * @param rect - The bounding box of the container.
1203
- * @param anchor - The defined anchor point (e.g., 'center', 'top-left').
1204
- * @returns The absolute viewport coordinates {x, y}.
1205
- */
1206
- declare const getAnchorPosition: (rect: DOMRect, anchor: AnchorPoint) => Vec2;
1207
-
1208
- /**
1209
- * Generates a globally unique identifier (UID) for runtime entity management and DOM keys.
1210
- *
1211
- * The generated ID follows the format: `[prefix]-[timestamp_base36]-[random_string]`.
1212
- * This ensures that components generated at different times or across multiple sessions
1213
- * remain unique within the current page instance.
1214
- *
1215
- * @param prefix - A string prefix for the ID, typically the component type (e.g., 'btn', 'joy'). Defaults to 'omnipad'.
1216
- * @returns A unique string identifier.
1217
- *
1218
- * @example
1219
- * generateUID('button') // returns "button-m7x8k1p2-f4k2"
1220
- */
1221
- declare const generateUID: (prefix?: string) => string;
1222
- /**
1223
- * Checks if the provided ID is a reserved global identifier.
1224
- *
1225
- * In OmniPad, IDs starting with the `$` symbol are considered "Global IDs".
1226
- * These identifiers are treated as static references and are not transformed
1227
- * into dynamic UIDs during configuration parsing.
1228
- *
1229
- * @param id - The identifier string to check.
1230
- * @returns `true` if the ID starts with `$`, otherwise `false`.
1231
- *
1232
- * @example
1233
- * isGlobalID('$root-layer') // returns true
1234
- * isGlobalID('btn-up') // returns false
1235
- */
1236
- declare function isGlobalID(id: string): boolean;
1237
-
1238
- /**
1239
- * Converts a LayoutBox configuration into a CSS style object suitable for Vue/React.
1240
- *
1241
- * This utility handles:
1242
- * 1. Unit normalization: Converts numeric values to 'px' strings while preserving unit strings (vh, %, etc.).
1243
- * 2. Positioning: Sets 'absolute' positioning by default.
1244
- * 3. Anchoring: Maps AnchorPoint values to CSS 'transform' translations to ensure
1245
- * the component's origin matches its defined coordinates.
1246
- *
1247
- * @param layout - The LayoutBox configuration object.
1248
- * @returns A CSS style record object.
1249
- *
1250
- * @example
1251
- * // returns { position: 'absolute', left: '50%', top: '50%', transform: 'translate(-50%, -50%)' }
1252
- * resolveLayoutStyle({ left: '50%', top: '50%', anchor: 'center' });
1253
- */
1254
- declare const resolveLayoutStyle: (layout: LayoutBox) => Record<string, string | number>;
1255
-
1256
- /**
1257
- * Validates and normalizes raw JSON data into a standard GamepadProfile.
1258
- * Performs structural checks and injects default metadata.
1259
- *
1260
- * @param raw - The raw JSON object from disk or network.
1261
- * @returns A validated GamepadProfile object.
1262
- * @throws Error if the core structure is invalid.
1263
- */
1264
- declare function parseProfileJson(raw: any): GamepadProfile;
1265
- /**
1266
- * Converts a flat GamepadProfile into a hierarchical ConfigTreeNode tree for runtime rendering.
1267
- * Handles CID (Config ID) to UID (Entity ID) mapping and reference resolution.
1268
- *
1269
- * @param profile - The normalized profile data.
1270
- * @returns The root node of the configuration tree.
1271
- */
1272
- declare function parseProfileTree(profile: GamepadProfile): ConfigTreeNode;
1273
- /**
1274
- * Serializes the current runtime entities from the Registry back into a flat GamepadProfile.
1275
- * Generates fresh Config IDs (CIDs) for all nodes except global IDs.
1276
- *
1277
- * @param meta - Metadata for the exported profile.
1278
- * @param rootUid - The Entity ID of the node to be treated as the root.
1279
- * @returns A flat GamepadProfile ready for storage.
1280
- */
1281
- declare function exportProfile(meta: GamepadProfile['meta'], rootUid: string): GamepadProfile;
1282
-
1283
- /**
1284
- * Represents a callback function for the emitter.
1285
- * @template T - The type of data being broadcasted.
1286
- */
1287
- type Listener<T> = (data: T) => void;
1288
- /**
1289
- * A lightweight implementation of the Observer pattern.
1290
- * Used primarily within Core Entities to notify the Adapter layer of state changes.
1291
- *
1292
- * @template T - The state or data object type.
1293
- */
1294
- declare class SimpleEmitter<T> {
1295
- private listeners;
165
+ * Handles:
166
+ * 1. Button edge detection (Down/Up).
167
+ * 2. D-Pad to vector conversion.
168
+ * 3. Analog stick deadzone processing.
169
+ */
170
+ declare class GamepadManager {
171
+ private isRunning;
172
+ private config;
173
+ private lastButtonStates;
174
+ private constructor();
1296
175
  /**
1297
- * Registers a callback function to be executed whenever data is emitted.
1298
- *
1299
- * @param fn - The callback function.
1300
- * @returns A function that, when called, unsubscribes the listener.
176
+ * Retrieves the global singleton instance of the GamepadManager.
1301
177
  */
1302
- subscribe(fn: Listener<T>): () => void;
178
+ static getInstance(): GamepadManager;
1303
179
  /**
1304
- * Broadcasts the provided data to all registered listeners.
1305
- * Each listener is executed within a try-catch block to ensure that
1306
- * an error in one subscriber doesn't prevent others from receiving the signal.
180
+ * Updates the current gamepad mapping configuration.
1307
181
  *
1308
- * @param data - The payload to be sent to all subscribers.
182
+ * @param config - The mapping of physical inputs to virtual component IDs (UID).
1309
183
  */
1310
- emit(data: T): void;
184
+ setConfig(config: GamepadMappingConfig[]): void;
185
+ /** Return the current gamepad mapping configuration. */
186
+ getConfig(): Readonly<GamepadMappingConfig[] | null>;
1311
187
  /**
1312
- * Removes all listeners and clears the subscription set.
1313
- * Essential for preventing memory leaks when an Entity is destroyed.
188
+ * Starts the polling loop and listens for gamepad connection events.
1314
189
  */
1315
- clear(): void;
190
+ start(): void;
191
+ /**
192
+ * Stops the polling loop.
193
+ */
194
+ stop(): void;
195
+ /**
196
+ * The core polling loop executing at the browser's refresh rate.
197
+ */
198
+ private loop;
199
+ /**
200
+ * Process binary button inputs with edge detection.
201
+ */
202
+ private processButtons;
203
+ /**
204
+ * Translates physical D-Pad buttons into a normalized vector.
205
+ */
206
+ private processDPad;
207
+ /**
208
+ * Process analog stick movements with deadzone logic.
209
+ */
210
+ private processAxes;
211
+ /**
212
+ * Locates a virtual entity and triggers its programmatic interface.
213
+ *
214
+ * @param uid - The Entity ID (UID) of the target.
215
+ * @param action - The type of trigger ('down', 'up', or 'vector').
216
+ * @param payload - Optional data for vector movements.
217
+ */
218
+ private triggerVirtualEntity;
1316
219
  }
1317
220
 
1318
221
  /**
@@ -1389,6 +292,41 @@ declare class Registry implements IRegistry {
1389
292
  debugGetSnapshot(): Map<string, ICoreEntity>;
1390
293
  }
1391
294
 
295
+ /**
296
+ * Represents a callback function for the emitter.
297
+ * @template T - The type of data being broadcasted.
298
+ */
299
+ type Listener<T> = (data: T) => void;
300
+ /**
301
+ * A lightweight implementation of the Observer pattern.
302
+ * Used primarily within Core Entities to notify the Adapter layer of state changes.
303
+ *
304
+ * @template T - The state or data object type.
305
+ */
306
+ declare class SimpleEmitter<T> {
307
+ private listeners;
308
+ /**
309
+ * Registers a callback function to be executed whenever data is emitted.
310
+ *
311
+ * @param fn - The callback function.
312
+ * @returns A function that, when called, unsubscribes the listener.
313
+ */
314
+ subscribe(fn: Listener<T>): () => void;
315
+ /**
316
+ * Broadcasts the provided data to all registered listeners.
317
+ * Each listener is executed within a try-catch block to ensure that
318
+ * an error in one subscriber doesn't prevent others from receiving the signal.
319
+ *
320
+ * @param data - The payload to be sent to all subscribers.
321
+ */
322
+ emit(data: T): void;
323
+ /**
324
+ * Removes all listeners and clears the subscription set.
325
+ * Essential for preventing memory leaks when an Entity is destroyed.
326
+ */
327
+ clear(): void;
328
+ }
329
+
1392
330
  /**
1393
331
  * Base abstract class for all logic entities in the system.
1394
332
  * Provides fundamental identity management, state subscription, and spatial awareness.
@@ -1398,7 +336,7 @@ declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpat
1398
336
  readonly type: EntityType;
1399
337
  protected config: TConfig;
1400
338
  protected state: TState;
1401
- protected rectProvider: (() => DOMRect) | null;
339
+ protected rectProvider: (() => AbstractRect) | null;
1402
340
  protected stateEmitter: SimpleEmitter<TState>;
1403
341
  constructor(uid: string, type: EntityType, initialConfig: TConfig, initialState: TState);
1404
342
  subscribe(cb: (state: TState) => void): () => void;
@@ -1410,32 +348,85 @@ declare abstract class BaseEntity<TConfig, TState> implements ICoreEntity, ISpat
1410
348
  protected setState(partialState: Partial<TState>): void;
1411
349
  destroy(): void;
1412
350
  abstract reset(): void;
1413
- bindRectProvider(provider: () => DOMRect): void;
1414
- /**
1415
- * Called when triggering interactions, this subclass fetches the latest boundaries in real time.
1416
- */
1417
- getRect(): DOMRect | null;
351
+ get rect(): AbstractRect | null;
352
+ bindRectProvider(provider: () => AbstractRect): void;
1418
353
  updateConfig(newConfig: Partial<TConfig>): void;
1419
354
  getState(): Readonly<TState>;
1420
355
  getConfig(): Readonly<TConfig>;
1421
356
  }
1422
357
 
358
+ /**
359
+ * Core logic implementation for a button widget.
360
+ * Handles pointer interactions and translates them into keyboard signals for a target stage.
361
+ */
362
+ declare class ButtonCore extends BaseEntity<ButtonConfig, ButtonState> implements IPointerHandler, IProgrammatic {
363
+ private emitter;
364
+ /**
365
+ * Creates an instance of KeyboardButtonCore.
366
+ *
367
+ * @param uid - The unique entity ID.
368
+ * @param config - The flat configuration object for the button.
369
+ */
370
+ constructor(uid: string, config: ButtonConfig);
371
+ get activePointerId(): number | null;
372
+ onPointerDown(e: AbstractPointerEvent): void;
373
+ onPointerUp(e: AbstractPointerEvent): void;
374
+ onPointerCancel(): void;
375
+ onPointerMove(): void;
376
+ reset(): void;
377
+ updateConfig(newConfig: Partial<ButtonConfig>): void;
378
+ /**
379
+ * Clean up pointer capture and reset interaction state.
380
+ */
381
+ private handleRelease;
382
+ triggerDown(): void;
383
+ triggerUp(): void;
384
+ }
385
+
386
+ /**
387
+ * Core logic for a virtual D-Pad widget.
388
+ *
389
+ * Acts as a spatial distributor that maps a single touch point to 4 independent ActionEmitters.
390
+ * Supports 8-way input by allowing simultaneous activation of orthogonal directions.
391
+ */
392
+ declare class DPadCore extends BaseEntity<DPadConfig, DPadState> implements IPointerHandler, IProgrammatic {
393
+ private emitters;
394
+ private throttledPointerMove;
395
+ constructor(uid: string, config: DPadConfig);
396
+ get activePointerId(): number | null;
397
+ onPointerDown(e: AbstractPointerEvent): void;
398
+ onPointerMove(e: AbstractPointerEvent): void;
399
+ onPointerUp(e: AbstractPointerEvent): void;
400
+ onPointerCancel(): void;
401
+ /**
402
+ * Evaluates the touch position and updates the 4 emitters accordingly.
403
+ * 使用轴向分割逻辑处理 8 方向输入
404
+ */
405
+ private processInput;
406
+ /**
407
+ * 将摇杆位置转换为 4/8 方向按键信号
408
+ */
409
+ private handleDigitalKeys;
410
+ reset(): void;
411
+ updateConfig(newConfig: Partial<DPadConfig>): void;
412
+ triggerVector(x: number, y: number): void;
413
+ }
414
+
1423
415
  /**
1424
416
  * Logic core for InputZone.
1425
417
  *
1426
418
  * Manages a container for input widgets and handles the lifecycle of
1427
419
  * dynamic (floating) widgets when interacting with empty space.
1428
420
  */
1429
- declare class InputZoneCore extends BaseEntity<InputZoneConfig, InputZoneState> implements IPointerHandler {
421
+ declare class InputZoneCore extends BaseEntity<InputZoneConfig, InputZoneState> implements IPointerHandler, IDependencyBindable {
422
+ private delegates;
1430
423
  constructor(uid: string, config: InputZoneConfig);
1431
- onPointerDown(e: PointerEvent): void;
1432
- onPointerMove(e: PointerEvent): void;
1433
- onPointerUp(e: PointerEvent): void;
1434
- onPointerCancel(e: PointerEvent): void;
1435
- /**
1436
- * Internal helper to handle pointer release and cleanup.
1437
- */
1438
- private handleRelease;
424
+ bindDelegate(key: string, delegate: AnyFunction): void;
425
+ get activePointerId(): number | null;
426
+ onPointerDown(e: AbstractPointerEvent): void;
427
+ onPointerMove(e: AbstractPointerEvent): void;
428
+ onPointerUp(e: AbstractPointerEvent): void;
429
+ onPointerCancel(e: AbstractPointerEvent): void;
1439
430
  /**
1440
431
  * Converts viewport pixels to percentage coordinates relative to the zone.
1441
432
  */
@@ -1448,60 +439,46 @@ declare class InputZoneCore extends BaseEntity<InputZoneConfig, InputZoneState>
1448
439
  }
1449
440
 
1450
441
  /**
1451
- * Core logic implementation for a keyboard button widget.
1452
- * Handles pointer interactions and translates them into keyboard signals for a target stage.
1453
- */
1454
- declare class KeyboardButtonCore extends BaseEntity<KeyboardButtonConfig, KeyboardButtonState> implements IPointerHandler {
1455
- /**
1456
- * Creates an instance of KeyboardButtonCore.
1457
- *
1458
- * @param uid - The unique entity ID.
1459
- * @param config - The flat configuration object for the button.
1460
- */
1461
- constructor(uid: string, config: KeyboardButtonConfig);
1462
- onPointerDown(e: PointerEvent): void;
1463
- onPointerUp(e: PointerEvent): void;
1464
- onPointerCancel(e: PointerEvent): void;
1465
- onPointerMove(e: PointerEvent): void;
442
+ * Joystick Core Implementation.
443
+ *
444
+ * Supports dual-mode output:
445
+ * 1. Digital: Maps angles to 4/8-way key signals.
446
+ * 2. Analog/Cursor: Maps vector to continuous cursor movement via Tick mechanism.
447
+ */
448
+ declare class JoystickCore extends BaseEntity<JoystickConfig, JoystickState> implements IPointerHandler, IProgrammatic {
449
+ private emitters;
450
+ private stickEmitter;
451
+ private cursorEmitter;
452
+ private gesture;
453
+ private ticker;
454
+ private throttledUpdate;
455
+ constructor(uid: string, config: JoystickConfig);
456
+ get activePointerId(): number | null;
457
+ onPointerDown(e: AbstractPointerEvent): void;
458
+ onPointerMove(e: AbstractPointerEvent): void;
459
+ onPointerUp(e: AbstractPointerEvent): void;
460
+ onPointerCancel(): void;
1466
461
  /**
1467
- * Common logic for releasing the button state.
1468
- *
1469
- * @param e - The pointer event that triggered the release.
462
+ * Clean up pointer capture and reset interaction state.
1470
463
  */
1471
464
  private handleRelease;
1472
465
  /**
1473
- * Dispatches input signals to the registered target stage.
1474
- *
1475
- * @param type - The action type (keydown or keyup).
466
+ * 计算位移向量并驱动按键逻辑 / Calculate vector and drive key logic
1476
467
  */
1477
- private sendInputSignal;
1478
- reset(): void;
1479
- }
1480
-
1481
- /**
1482
- * Core logic implementation for a mouse button widget.
1483
- * Handles pointer interactions and translates them into mouse signals (down, up, click) for a target stage.
1484
- */
1485
- declare class MouseButtonCore extends BaseEntity<MouseButtonConfig, MouseButtonState> implements IPointerHandler {
1486
- constructor(uid: string, config: MouseButtonConfig);
1487
- onPointerDown(e: PointerEvent): void;
1488
- onPointerUp(e: PointerEvent): void;
1489
- onPointerCancel(e: PointerEvent): void;
1490
- onPointerMove(e: PointerEvent): void;
468
+ private processInput;
1491
469
  /**
1492
- * Handles the release of the button.
1493
- *
1494
- * @param e - The pointer event.
1495
- * @param isNormalRelease - If true, a 'click' event will also be dispatched.
470
+ * Ticker 回调:处理每帧的光标位移输出
1496
471
  */
1497
- private handleRelease;
472
+ private handleCursorTick;
1498
473
  /**
1499
- * Dispatches input signals to the registered target stage.
1500
- *
1501
- * @param type - The action type (mousedown, mouseup, or click).
474
+ * 将摇杆位置转换为 4/8 方向按键信号
1502
475
  */
1503
- private sendInputSignal;
476
+ private handleDigitalKeys;
1504
477
  reset(): void;
478
+ updateConfig(newConfig: Partial<JoystickConfig>): void;
479
+ triggerDown(): void;
480
+ triggerUp(): void;
481
+ triggerVector(x: number, y: number): void;
1505
482
  }
1506
483
 
1507
484
  /**
@@ -1521,15 +498,18 @@ declare class RootLayerCore extends BaseEntity<BaseConfig, LayerState> {
1521
498
  * It acts as a receiver that translates abstract input signals into native browser events,
1522
499
  * while maintaining virtual cursor positioning and ensuring the game maintains focus.
1523
500
  */
1524
- declare class TargetZoneCore extends BaseEntity<TargetZoneConfig, CursorState> implements IPointerHandler, ISignalReceiver {
501
+ declare class TargetZoneCore extends BaseEntity<TargetZoneConfig, CursorState> implements IPointerHandler, ISignalReceiver, IDependencyBindable {
1525
502
  private hideTimer;
1526
503
  private focusFeedbackTimer;
1527
504
  private throttledPointerMove;
505
+ private delegates;
1528
506
  constructor(uid: string, config: TargetZoneConfig);
1529
- onPointerDown(e: PointerEvent): void;
1530
- onPointerMove(e: PointerEvent): void;
1531
- onPointerUp(e: PointerEvent): void;
1532
- onPointerCancel(e: PointerEvent): void;
507
+ bindDelegate(key: string, delegate: AnyFunction): void;
508
+ get activePointerId(): number | null;
509
+ onPointerDown(e: AbstractPointerEvent): void;
510
+ onPointerMove(e: AbstractPointerEvent): void;
511
+ onPointerUp(e: AbstractPointerEvent): void;
512
+ onPointerCancel(e: AbstractPointerEvent): void;
1533
513
  /**
1534
514
  * Convert physical DOM events into internal signals
1535
515
  */
@@ -1567,16 +547,19 @@ declare class TargetZoneCore extends BaseEntity<TargetZoneConfig, CursorState> i
1567
547
 
1568
548
  /**
1569
549
  * Core logic implementation for a trackpad widget.
550
+ *
1570
551
  * Translates pointer gestures into relative mouse movements and click actions.
1571
- * Supports tap-to-click and double-tap-to-drag scenarios.
552
+ * Supports:
553
+ * - Single Tap: Dispatches a 'click' signal.
554
+ * - Swipe: Dispatches incremental 'mousemove' signals.
555
+ * - Double-tap and Hold: Enters drag mode (mousedown + mousemove).
1572
556
  */
1573
557
  declare class TrackpadCore extends BaseEntity<TrackpadConfig, TrackpadState> implements IPointerHandler {
558
+ /** Stores the last processed client coordinates to calculate delta / 存储上次处理的客户端坐标以计算增量 */
1574
559
  private lastPointerPos;
1575
- private startTime;
1576
- private startPos;
1577
- private lastClickTime;
1578
- private isDragMode;
1579
560
  private throttledPointerMove;
561
+ private gesture;
562
+ private emitter;
1580
563
  /**
1581
564
  * Creates an instance of TrackpadCore.
1582
565
  *
@@ -1584,8 +567,9 @@ declare class TrackpadCore extends BaseEntity<TrackpadConfig, TrackpadState> imp
1584
567
  * @param config - Configuration for the trackpad.
1585
568
  */
1586
569
  constructor(uid: string, config: TrackpadConfig);
1587
- onPointerDown(e: PointerEvent): void;
1588
- onPointerMove(e: PointerEvent): void;
570
+ get activePointerId(): number | null;
571
+ onPointerDown(e: AbstractPointerEvent): void;
572
+ onPointerMove(e: AbstractPointerEvent): void;
1589
573
  /**
1590
574
  * Internal logic for processing pointer movement.
1591
575
  * Calculates displacement and emits relative move signals.
@@ -1593,20 +577,14 @@ declare class TrackpadCore extends BaseEntity<TrackpadConfig, TrackpadState> imp
1593
577
  * @param e - The pointer event.
1594
578
  */
1595
579
  private processPointerMove;
1596
- onPointerUp(e: PointerEvent): void;
1597
- onPointerCancel(e: PointerEvent): void;
580
+ onPointerUp(e: AbstractPointerEvent): void;
581
+ onPointerCancel(): void;
1598
582
  reset(): void;
583
+ updateConfig(newConfig: Partial<TrackpadConfig>): void;
1599
584
  /**
1600
585
  * Clean up pointer capture and reset interaction state.
1601
586
  */
1602
587
  private handleRelease;
1603
- /**
1604
- * Helper to send signals to the target stage via Registry.
1605
- *
1606
- * @param type - Signal action type.
1607
- * @param extraPayload - Additional data like delta or point.
1608
- */
1609
- private sendSignal;
1610
588
  }
1611
589
 
1612
590
  declare const OmniPad: {
@@ -2126,9 +1104,10 @@ declare const OmniPad: {
2126
1104
  Types: {
2127
1105
  readonly INPUT_ZONE: "input-zone";
2128
1106
  readonly TARGET_ZONE: "target-zone";
1107
+ readonly BUTTON: "button";
2129
1108
  readonly KEYBOARD_BUTTON: "keyboard-button";
2130
1109
  readonly MOUSE_BUTTON: "mouse-button";
2131
- readonly ANALOG_STICK: "analog-stick";
1110
+ readonly JOYSTICK: "joystick";
2132
1111
  readonly D_PAD: "d-pad";
2133
1112
  readonly TRACKPAD: "trackpad";
2134
1113
  readonly VIRTUAL_CURSOR: "virtual-cursor";
@@ -2136,4 +1115,4 @@ declare const OmniPad: {
2136
1115
  };
2137
1116
  };
2138
1117
 
2139
- export { ACTION_TYPES, type AnchorPoint, type AnyConfig, type AnyEntityType, type BaseConfig, BaseEntity, type BuiltInActionType, type ButtonLogicState, CMP_TYPES, CONTEXT, type ConfigTreeNode, type CursorState, type EntityType, type FlatConfigItem, type FlexibleLength, type GamepadProfile, type IConfigurable, type ICoreEntity, type IIdentifiable, type ILifecycle, type IObservable, type IPointerHandler, type IRegistry, type IResettable, type ISignalReceiver, type ISpatial, type InputActionSignal, type InputActionType, InputManager, type InputZoneConfig, InputZoneCore, type InputZoneState, type InteractionState, type JoystickLogicState, type JoystickState, KEYS, type KeyMapping, type KeyboardButtonConfig, KeyboardButtonCore, type KeyboardButtonState, type LayerState, type LayoutBox, type Listener, type MouseButtonConfig, MouseButtonCore, type MouseButtonState, OmniPad, Registry, RootLayerCore, SimpleEmitter, type StageId, type TargetZoneConfig, TargetZoneCore, type TrackpadConfig, TrackpadCore, type TrackpadState, type Unit, type Vec2, type WidgetId, type WidgetType, type ZoneId, type ZoneType, addVec, applyAxialDeadzone, applyRadialDeadzone, clamp, clampVector, degToRad, dispatchKeyboardEvent, dispatchPointerEventAtPos, exportProfile, focusElement, generateUID, getAnchorPosition, getAngle, getDeadzoneScalar, getDeepActiveElement, getDeepElement, getDistance, isGlobalID, isVec2Equal, lerp, lockTo4Directions, lockTo8Directions, normalizeVec, parseProfileJson, parseProfileTree, percentToPx, pxToPercent, radToDeg, radToVec, remap, resolveLayoutStyle, roundTo, scaleVec, subVec };
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, IObservable, IPointerHandler, IProgrammatic, type IRegistry, IResettable, ISignalReceiver, ISpatial, InputActionSignal, InputManager, 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 };