@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.
@@ -0,0 +1,1047 @@
1
+ /** Standard buttons for Gamepad API */
2
+ type StandardButton = 'A' | 'B' | 'X' | 'Y' | 'LB' | 'RB' | 'LT' | 'RT' | 'Select' | 'Start' | 'L3' | 'R3' | 'Up' | 'Down' | 'Left' | 'Right';
3
+ interface GamepadMappingConfig {
4
+ /**
5
+ * Mapping of standard gamepad buttons to virtual component CIDs.
6
+ * Key: Standard button name (e.g., 'A', 'X', 'RT').
7
+ * Value: Configuration ID (CID) of the target virtual widget.
8
+ */
9
+ buttons?: Partial<Record<StandardButton, string>>;
10
+ /**
11
+ * CID of the virtual widget (D-Pad) to be driven by the physical d-pad.
12
+ */
13
+ dpad?: string;
14
+ /**
15
+ * CID of the virtual widget (Joystick or D-Pad) to be driven by the physical left stick.
16
+ */
17
+ leftStick?: string;
18
+ /**
19
+ * CID of the virtual widget (Joystick or D-Pad) to be driven by the physical right stick.
20
+ */
21
+ rightStick?: string;
22
+ /**
23
+ * Minimum axial displacement required to trigger input (0.0 to 1.0).
24
+ * Prevents drift issues on older controllers.
25
+ * @default 0.1
26
+ */
27
+ deadzone?: number;
28
+ }
29
+
30
+ /**
31
+ * Interface defining the structure of a keyboard key mapping.
32
+ * Ensures compatibility between modern web standards and legacy Flash requirements.
33
+ */
34
+ interface KeyMapping {
35
+ /**
36
+ * The key value, corresponding to `KeyboardEvent.key`.
37
+ * Represented as a string (e.g., " ", "Enter", "a").
38
+ */
39
+ key: string;
40
+ /**
41
+ * The physical key code, corresponding to `KeyboardEvent.code`.
42
+ * Describes the physical location of the key (e.g., "Space", "Enter", "KeyA").
43
+ */
44
+ code: string;
45
+ /**
46
+ * The legacy numerical key code, corresponding to `KeyboardEvent.keyCode`.
47
+ * Essential for Flash engines (AS2/AS3) running via Ruffle.
48
+ * e.g., 32 for Space, 13 for Enter.
49
+ */
50
+ keyCode: number;
51
+ }
52
+ /**
53
+ * Unified action definition.
54
+ * Discriminated by the 'type' field, but shares a common structure for ease of use.
55
+ */
56
+ interface ActionMapping {
57
+ /** 指定动作类型:'keyboard' | 'mouse' */
58
+ type: 'keyboard' | 'mouse';
59
+ key?: string;
60
+ code?: string;
61
+ keyCode?: number;
62
+ /** 0: Left, 1: Middle, 2: Right */
63
+ button?: 0 | 1 | 2;
64
+ /** Fixed coordinate (0-100 percentage) */
65
+ fixedPoint?: Vec2;
66
+ }
67
+ /**
68
+ * Standard collection of key mappings.
69
+ * Allows developers to quickly retrieve mapping data using physical key codes as keys.
70
+ */
71
+ declare const KEYS: {
72
+ readonly Backspace: {
73
+ readonly key: "Backspace";
74
+ readonly code: "Backspace";
75
+ readonly keyCode: 8;
76
+ };
77
+ readonly Tab: {
78
+ readonly key: "Tab";
79
+ readonly code: "Tab";
80
+ readonly keyCode: 9;
81
+ };
82
+ readonly Enter: {
83
+ readonly key: "Enter";
84
+ readonly code: "Enter";
85
+ readonly keyCode: 13;
86
+ };
87
+ readonly ShiftLeft: {
88
+ readonly key: "Shift";
89
+ readonly code: "ShiftLeft";
90
+ readonly keyCode: 16;
91
+ };
92
+ readonly ControlLeft: {
93
+ readonly key: "Control";
94
+ readonly code: "ControlLeft";
95
+ readonly keyCode: 17;
96
+ };
97
+ readonly AltLeft: {
98
+ readonly key: "Alt";
99
+ readonly code: "AltLeft";
100
+ readonly keyCode: 18;
101
+ };
102
+ readonly Pause: {
103
+ readonly key: "Pause";
104
+ readonly code: "Pause";
105
+ readonly keyCode: 19;
106
+ };
107
+ readonly CapsLock: {
108
+ readonly key: "CapsLock";
109
+ readonly code: "CapsLock";
110
+ readonly keyCode: 20;
111
+ };
112
+ readonly Escape: {
113
+ readonly key: "Escape";
114
+ readonly code: "Escape";
115
+ readonly keyCode: 27;
116
+ };
117
+ readonly Space: {
118
+ readonly key: " ";
119
+ readonly code: "Space";
120
+ readonly keyCode: 32;
121
+ };
122
+ readonly PageUp: {
123
+ readonly key: "PageUp";
124
+ readonly code: "PageUp";
125
+ readonly keyCode: 33;
126
+ };
127
+ readonly PageDown: {
128
+ readonly key: "PageDown";
129
+ readonly code: "PageDown";
130
+ readonly keyCode: 34;
131
+ };
132
+ readonly End: {
133
+ readonly key: "End";
134
+ readonly code: "End";
135
+ readonly keyCode: 35;
136
+ };
137
+ readonly Home: {
138
+ readonly key: "Home";
139
+ readonly code: "Home";
140
+ readonly keyCode: 36;
141
+ };
142
+ readonly ArrowLeft: {
143
+ readonly key: "ArrowLeft";
144
+ readonly code: "ArrowLeft";
145
+ readonly keyCode: 37;
146
+ };
147
+ readonly ArrowUp: {
148
+ readonly key: "ArrowUp";
149
+ readonly code: "ArrowUp";
150
+ readonly keyCode: 38;
151
+ };
152
+ readonly ArrowRight: {
153
+ readonly key: "ArrowRight";
154
+ readonly code: "ArrowRight";
155
+ readonly keyCode: 39;
156
+ };
157
+ readonly ArrowDown: {
158
+ readonly key: "ArrowDown";
159
+ readonly code: "ArrowDown";
160
+ readonly keyCode: 40;
161
+ };
162
+ readonly PrintScreen: {
163
+ readonly key: "PrintScreen";
164
+ readonly code: "PrintScreen";
165
+ readonly keyCode: 44;
166
+ };
167
+ readonly Insert: {
168
+ readonly key: "Insert";
169
+ readonly code: "Insert";
170
+ readonly keyCode: 45;
171
+ };
172
+ readonly Delete: {
173
+ readonly key: "Delete";
174
+ readonly code: "Delete";
175
+ readonly keyCode: 46;
176
+ };
177
+ readonly Digit0: {
178
+ readonly key: "0";
179
+ readonly code: "Digit0";
180
+ readonly keyCode: 48;
181
+ };
182
+ readonly Digit1: {
183
+ readonly key: "1";
184
+ readonly code: "Digit1";
185
+ readonly keyCode: 49;
186
+ };
187
+ readonly Digit2: {
188
+ readonly key: "2";
189
+ readonly code: "Digit2";
190
+ readonly keyCode: 50;
191
+ };
192
+ readonly Digit3: {
193
+ readonly key: "3";
194
+ readonly code: "Digit3";
195
+ readonly keyCode: 51;
196
+ };
197
+ readonly Digit4: {
198
+ readonly key: "4";
199
+ readonly code: "Digit4";
200
+ readonly keyCode: 52;
201
+ };
202
+ readonly Digit5: {
203
+ readonly key: "5";
204
+ readonly code: "Digit5";
205
+ readonly keyCode: 53;
206
+ };
207
+ readonly Digit6: {
208
+ readonly key: "6";
209
+ readonly code: "Digit6";
210
+ readonly keyCode: 54;
211
+ };
212
+ readonly Digit7: {
213
+ readonly key: "7";
214
+ readonly code: "Digit7";
215
+ readonly keyCode: 55;
216
+ };
217
+ readonly Digit8: {
218
+ readonly key: "8";
219
+ readonly code: "Digit8";
220
+ readonly keyCode: 56;
221
+ };
222
+ readonly Digit9: {
223
+ readonly key: "9";
224
+ readonly code: "Digit9";
225
+ readonly keyCode: 57;
226
+ };
227
+ readonly KeyA: {
228
+ readonly key: "a";
229
+ readonly code: "KeyA";
230
+ readonly keyCode: 65;
231
+ };
232
+ readonly KeyB: {
233
+ readonly key: "b";
234
+ readonly code: "KeyB";
235
+ readonly keyCode: 66;
236
+ };
237
+ readonly KeyC: {
238
+ readonly key: "c";
239
+ readonly code: "KeyC";
240
+ readonly keyCode: 67;
241
+ };
242
+ readonly KeyD: {
243
+ readonly key: "d";
244
+ readonly code: "KeyD";
245
+ readonly keyCode: 68;
246
+ };
247
+ readonly KeyE: {
248
+ readonly key: "e";
249
+ readonly code: "KeyE";
250
+ readonly keyCode: 69;
251
+ };
252
+ readonly KeyF: {
253
+ readonly key: "f";
254
+ readonly code: "KeyF";
255
+ readonly keyCode: 70;
256
+ };
257
+ readonly KeyG: {
258
+ readonly key: "g";
259
+ readonly code: "KeyG";
260
+ readonly keyCode: 71;
261
+ };
262
+ readonly KeyH: {
263
+ readonly key: "h";
264
+ readonly code: "KeyH";
265
+ readonly keyCode: 72;
266
+ };
267
+ readonly KeyI: {
268
+ readonly key: "i";
269
+ readonly code: "KeyI";
270
+ readonly keyCode: 73;
271
+ };
272
+ readonly KeyJ: {
273
+ readonly key: "j";
274
+ readonly code: "KeyJ";
275
+ readonly keyCode: 74;
276
+ };
277
+ readonly KeyK: {
278
+ readonly key: "k";
279
+ readonly code: "KeyK";
280
+ readonly keyCode: 75;
281
+ };
282
+ readonly KeyL: {
283
+ readonly key: "l";
284
+ readonly code: "KeyL";
285
+ readonly keyCode: 76;
286
+ };
287
+ readonly KeyM: {
288
+ readonly key: "m";
289
+ readonly code: "KeyM";
290
+ readonly keyCode: 77;
291
+ };
292
+ readonly KeyN: {
293
+ readonly key: "n";
294
+ readonly code: "KeyN";
295
+ readonly keyCode: 78;
296
+ };
297
+ readonly KeyO: {
298
+ readonly key: "o";
299
+ readonly code: "KeyO";
300
+ readonly keyCode: 79;
301
+ };
302
+ readonly KeyP: {
303
+ readonly key: "p";
304
+ readonly code: "KeyP";
305
+ readonly keyCode: 80;
306
+ };
307
+ readonly KeyQ: {
308
+ readonly key: "q";
309
+ readonly code: "KeyQ";
310
+ readonly keyCode: 81;
311
+ };
312
+ readonly KeyR: {
313
+ readonly key: "r";
314
+ readonly code: "KeyR";
315
+ readonly keyCode: 82;
316
+ };
317
+ readonly KeyS: {
318
+ readonly key: "s";
319
+ readonly code: "KeyS";
320
+ readonly keyCode: 83;
321
+ };
322
+ readonly KeyT: {
323
+ readonly key: "t";
324
+ readonly code: "KeyT";
325
+ readonly keyCode: 84;
326
+ };
327
+ readonly KeyU: {
328
+ readonly key: "u";
329
+ readonly code: "KeyU";
330
+ readonly keyCode: 85;
331
+ };
332
+ readonly KeyV: {
333
+ readonly key: "v";
334
+ readonly code: "KeyV";
335
+ readonly keyCode: 86;
336
+ };
337
+ readonly KeyW: {
338
+ readonly key: "w";
339
+ readonly code: "KeyW";
340
+ readonly keyCode: 87;
341
+ };
342
+ readonly KeyX: {
343
+ readonly key: "x";
344
+ readonly code: "KeyX";
345
+ readonly keyCode: 88;
346
+ };
347
+ readonly KeyY: {
348
+ readonly key: "y";
349
+ readonly code: "KeyY";
350
+ readonly keyCode: 89;
351
+ };
352
+ readonly KeyZ: {
353
+ readonly key: "z";
354
+ readonly code: "KeyZ";
355
+ readonly keyCode: 90;
356
+ };
357
+ readonly MetaLeft: {
358
+ readonly key: "Meta";
359
+ readonly code: "MetaLeft";
360
+ readonly keyCode: 91;
361
+ };
362
+ readonly ContextMenu: {
363
+ readonly key: "ContextMenu";
364
+ readonly code: "ContextMenu";
365
+ readonly keyCode: 93;
366
+ };
367
+ readonly Numpad0: {
368
+ readonly key: "0";
369
+ readonly code: "Numpad0";
370
+ readonly keyCode: 96;
371
+ };
372
+ readonly Numpad1: {
373
+ readonly key: "1";
374
+ readonly code: "Numpad1";
375
+ readonly keyCode: 97;
376
+ };
377
+ readonly Numpad2: {
378
+ readonly key: "2";
379
+ readonly code: "Numpad2";
380
+ readonly keyCode: 98;
381
+ };
382
+ readonly Numpad3: {
383
+ readonly key: "3";
384
+ readonly code: "Numpad3";
385
+ readonly keyCode: 99;
386
+ };
387
+ readonly Numpad4: {
388
+ readonly key: "4";
389
+ readonly code: "Numpad4";
390
+ readonly keyCode: 100;
391
+ };
392
+ readonly Numpad5: {
393
+ readonly key: "5";
394
+ readonly code: "Numpad5";
395
+ readonly keyCode: 101;
396
+ };
397
+ readonly Numpad6: {
398
+ readonly key: "6";
399
+ readonly code: "Numpad6";
400
+ readonly keyCode: 102;
401
+ };
402
+ readonly Numpad7: {
403
+ readonly key: "7";
404
+ readonly code: "Numpad7";
405
+ readonly keyCode: 103;
406
+ };
407
+ readonly Numpad8: {
408
+ readonly key: "8";
409
+ readonly code: "Numpad8";
410
+ readonly keyCode: 104;
411
+ };
412
+ readonly Numpad9: {
413
+ readonly key: "9";
414
+ readonly code: "Numpad9";
415
+ readonly keyCode: 105;
416
+ };
417
+ readonly NumpadMultiply: {
418
+ readonly key: "*";
419
+ readonly code: "NumpadMultiply";
420
+ readonly keyCode: 106;
421
+ };
422
+ readonly NumpadAdd: {
423
+ readonly key: "+";
424
+ readonly code: "NumpadAdd";
425
+ readonly keyCode: 107;
426
+ };
427
+ readonly NumpadSubtract: {
428
+ readonly key: "-";
429
+ readonly code: "NumpadSubtract";
430
+ readonly keyCode: 109;
431
+ };
432
+ readonly NumpadDecimal: {
433
+ readonly key: ".";
434
+ readonly code: "NumpadDecimal";
435
+ readonly keyCode: 110;
436
+ };
437
+ readonly NumpadDivide: {
438
+ readonly key: "/";
439
+ readonly code: "NumpadDivide";
440
+ readonly keyCode: 111;
441
+ };
442
+ readonly F1: {
443
+ readonly key: "F1";
444
+ readonly code: "F1";
445
+ readonly keyCode: 112;
446
+ };
447
+ readonly F2: {
448
+ readonly key: "F2";
449
+ readonly code: "F2";
450
+ readonly keyCode: 113;
451
+ };
452
+ readonly F3: {
453
+ readonly key: "F3";
454
+ readonly code: "F3";
455
+ readonly keyCode: 114;
456
+ };
457
+ readonly F4: {
458
+ readonly key: "F4";
459
+ readonly code: "F4";
460
+ readonly keyCode: 115;
461
+ };
462
+ readonly F5: {
463
+ readonly key: "F5";
464
+ readonly code: "F5";
465
+ readonly keyCode: 116;
466
+ };
467
+ readonly F6: {
468
+ readonly key: "F6";
469
+ readonly code: "F6";
470
+ readonly keyCode: 117;
471
+ };
472
+ readonly F7: {
473
+ readonly key: "F7";
474
+ readonly code: "F7";
475
+ readonly keyCode: 118;
476
+ };
477
+ readonly F8: {
478
+ readonly key: "F8";
479
+ readonly code: "F8";
480
+ readonly keyCode: 119;
481
+ };
482
+ readonly F9: {
483
+ readonly key: "F9";
484
+ readonly code: "F9";
485
+ readonly keyCode: 120;
486
+ };
487
+ readonly F10: {
488
+ readonly key: "F10";
489
+ readonly code: "F10";
490
+ readonly keyCode: 121;
491
+ };
492
+ readonly F11: {
493
+ readonly key: "F11";
494
+ readonly code: "F11";
495
+ readonly keyCode: 122;
496
+ };
497
+ readonly F12: {
498
+ readonly key: "F12";
499
+ readonly code: "F12";
500
+ readonly keyCode: 123;
501
+ };
502
+ readonly NumLock: {
503
+ readonly key: "NumLock";
504
+ readonly code: "NumLock";
505
+ readonly keyCode: 144;
506
+ };
507
+ readonly ScrollLock: {
508
+ readonly key: "ScrollLock";
509
+ readonly code: "ScrollLock";
510
+ readonly keyCode: 145;
511
+ };
512
+ readonly Semicolon: {
513
+ readonly key: ";";
514
+ readonly code: "Semicolon";
515
+ readonly keyCode: 186;
516
+ };
517
+ readonly Equal: {
518
+ readonly key: "=";
519
+ readonly code: "Equal";
520
+ readonly keyCode: 187;
521
+ };
522
+ readonly Comma: {
523
+ readonly key: ",";
524
+ readonly code: "Comma";
525
+ readonly keyCode: 188;
526
+ };
527
+ readonly Minus: {
528
+ readonly key: "-";
529
+ readonly code: "Minus";
530
+ readonly keyCode: 189;
531
+ };
532
+ readonly Period: {
533
+ readonly key: ".";
534
+ readonly code: "Period";
535
+ readonly keyCode: 190;
536
+ };
537
+ readonly Slash: {
538
+ readonly key: "/";
539
+ readonly code: "Slash";
540
+ readonly keyCode: 191;
541
+ };
542
+ readonly Backquote: {
543
+ readonly key: "`";
544
+ readonly code: "Backquote";
545
+ readonly keyCode: 192;
546
+ };
547
+ readonly BracketLeft: {
548
+ readonly key: "[";
549
+ readonly code: "BracketLeft";
550
+ readonly keyCode: 219;
551
+ };
552
+ readonly Backslash: {
553
+ readonly key: "\\";
554
+ readonly code: "Backslash";
555
+ readonly keyCode: 220;
556
+ };
557
+ readonly BracketRight: {
558
+ readonly key: "]";
559
+ readonly code: "BracketRight";
560
+ readonly keyCode: 221;
561
+ };
562
+ readonly Quote: {
563
+ readonly key: "'";
564
+ readonly code: "Quote";
565
+ readonly keyCode: 222;
566
+ };
567
+ };
568
+
569
+ /**
570
+ * Defines the spatial properties of a component.
571
+ * Supports various CSS units (px, %, vh, vw) via FlexibleLength.
572
+ */
573
+ interface LayoutBox {
574
+ /** Offset from the left edge of the parent container. */
575
+ left?: FlexibleLength;
576
+ /** Offset from the top edge of the parent container. */
577
+ top?: FlexibleLength;
578
+ /** Offset from the right edge of the parent container. */
579
+ right?: FlexibleLength;
580
+ /** Offset from the bottom edge of the parent container. */
581
+ bottom?: FlexibleLength;
582
+ /** Width of the component. */
583
+ width?: FlexibleLength;
584
+ /** Height of the component. */
585
+ height?: FlexibleLength;
586
+ /** Whether equal width and length. (aspect-ratio: 1/1) */
587
+ isSquare?: boolean;
588
+ /**
589
+ * The alignment point of the component relative to its (left, top) coordinates.
590
+ * @example 'center' will center the component on its position.
591
+ */
592
+ anchor?: AnchorPoint;
593
+ /** Rotation angle in degrees. */
594
+ /** Z-index for layering control. */
595
+ zIndex?: number;
596
+ }
597
+ /**
598
+ * Base configuration interface for all components.
599
+ */
600
+ interface BaseConfig {
601
+ /**
602
+ * Config ID (CID) used in persistent storage.
603
+ * If omitted, a random UID will be generated during parsing.
604
+ * If starts with '$', it points to a global static entity. (UID = CID)
605
+ */
606
+ id?: string;
607
+ /** The unique type identifier for the component. */
608
+ baseType: string;
609
+ /** CID of the parent component. Root components have no parentId. */
610
+ parentId?: string;
611
+ /** Spatial layout configuration relative to its parent zone. */
612
+ layout: LayoutBox;
613
+ /**
614
+ * Custom CSS class names or style tags.
615
+ * For visual decoration only; must not include layout attributes such as top/left/width/height.
616
+ */
617
+ cssClasses?: string | string[];
618
+ }
619
+ /**
620
+ * Configuration for a virtual keyboard/mouse button.
621
+ */
622
+ interface ButtonConfig extends BaseConfig {
623
+ baseType: typeof CMP_TYPES.BUTTON;
624
+ /** The text or symbol displayed on the button surface. */
625
+ label?: string;
626
+ /** CID of the TargetZone where signals should be dispatched. */
627
+ targetStageId?: string;
628
+ /** Keyboard or mouse event metadata to be emitted when triggered. */
629
+ mapping?: ActionMapping;
630
+ }
631
+ /**
632
+ * Configuration for a virtual trackpad.
633
+ */
634
+ interface TrackpadConfig extends BaseConfig {
635
+ baseType: typeof CMP_TYPES.TRACKPAD;
636
+ /** The text or symbol displayed on the trackpad surface. */
637
+ label?: string;
638
+ /** Determines the mapping ratio between the physical displacement of the trackpad and the movement of the screen cursor. */
639
+ sensitivity?: number;
640
+ /** CID of the TargetZone where signals should be dispatched. */
641
+ targetStageId?: string;
642
+ /** Optional: Mouse or keyboard event metadata to be emitted when triggered. */
643
+ mapping?: ActionMapping;
644
+ }
645
+ /**
646
+ * Configuration for a virtual d-pad.
647
+ */
648
+ interface DPadConfig extends BaseConfig {
649
+ baseType: typeof CMP_TYPES.D_PAD;
650
+ /** CID of the TargetZone where signals should be dispatched. */
651
+ targetStageId?: string;
652
+ /** Defines the specific actions or key signals emitted for each cardinal direction. */
653
+ mapping?: {
654
+ up: ActionMapping;
655
+ down: ActionMapping;
656
+ left: ActionMapping;
657
+ right: ActionMapping;
658
+ };
659
+ /** Determines the minimum travel distance required to trigger a direction. */
660
+ threshold?: number;
661
+ showStick?: boolean;
662
+ }
663
+ interface JoystickConfig extends BaseConfig {
664
+ baseType: typeof CMP_TYPES.JOYSTICK;
665
+ /** The text or symbol displayed on the stick button surface. */
666
+ label?: string;
667
+ /** CID of the TargetZone where signals should be dispatched. */
668
+ targetStageId?: string;
669
+ /** Determines the minimum travel distance required to trigger a direction. */
670
+ threshold?: number;
671
+ /** Whether enable cursor displacement simulation. */
672
+ cursorMode?: boolean;
673
+ /** Determines the mapping velocity between the physical displacement of the joystick and the movement of the screen cursor. */
674
+ cursorSensitivity?: number;
675
+ /** Defines the specific actions or key signals emitted for each cardinal direction and stick button. */
676
+ mapping?: {
677
+ up?: ActionMapping;
678
+ down?: ActionMapping;
679
+ left?: ActionMapping;
680
+ right?: ActionMapping;
681
+ stick?: ActionMapping;
682
+ };
683
+ }
684
+ /**
685
+ * Configuration for an Input Zone.
686
+ * Input Zones act as containers and can handle dynamic (floating) widgets.
687
+ */
688
+ interface InputZoneConfig extends BaseConfig {
689
+ baseType: typeof CMP_TYPES.INPUT_ZONE;
690
+ /** If true, prevents the browser focus from leaving the game area when touching this zone. */
691
+ preventFocusLoss?: boolean;
692
+ /**
693
+ * The CID of a child component intended to be used as a dynamic (floating) widget.
694
+ */
695
+ dynamicWidgetId?: string;
696
+ }
697
+ /**
698
+ * Configuration for a Target Focus Zone.
699
+ * Acts as the bridge between virtual signals and the actual game/app DOM.
700
+ */
701
+ interface TargetZoneConfig extends BaseConfig {
702
+ baseType: typeof CMP_TYPES.TARGET_ZONE;
703
+ /** Whether to render a visual virtual cursor. */
704
+ cursorEnabled?: boolean;
705
+ /** Delay in milliseconds before the virtual cursor auto-hides after inactivity (0 to disable). */
706
+ cursorAutoDelay?: number;
707
+ }
708
+ /**
709
+ * Union type representing any valid component configuration.
710
+ */
711
+ type AnyConfig = ButtonConfig | InputZoneConfig | TargetZoneConfig | TrackpadConfig | DPadConfig | JoystickConfig | any;
712
+ /**
713
+ * Representation of a single item in a flattened configuration profile.
714
+ * Ideal for database storage and flat-list editing.
715
+ */
716
+ interface FlatConfigItem {
717
+ /** Unique identifier (CID) in the scope of the profile. */
718
+ id: string;
719
+ /** Component type string. */
720
+ type: string;
721
+ /** Parent CID. Empty if this is the root node. */
722
+ parentId?: string;
723
+ /** Flattened business logic and layout properties. */
724
+ config?: Record<string, any>;
725
+ }
726
+ /**
727
+ * The root structure of a Gamepad configuration file.
728
+ */
729
+ interface GamepadProfile {
730
+ /** Metadata about the profile creator and version. */
731
+ meta: {
732
+ name: string;
733
+ version: string;
734
+ author?: string;
735
+ description?: string;
736
+ };
737
+ /** List of all components in the profile. Hierarchies are defined via parentId. */
738
+ items: FlatConfigItem[];
739
+ /**
740
+ * Global mapping configuration for physical gamepad hardware.
741
+ * Defines how hardware inputs interact with the virtual components listed in 'items'.
742
+ */
743
+ gamepadMappings?: GamepadMappingConfig[];
744
+ }
745
+ /**
746
+ * A recursive tree structure representing the runtime hierarchy of components.
747
+ * Used by the adapter layer (e.g., Vue) to render components recursively.
748
+ */
749
+ interface ConfigTreeNode {
750
+ /** Runtime Unique Entity ID (UID), unique across the entire application. */
751
+ uid: string;
752
+ /** Component type string. */
753
+ type: string;
754
+ /** Component properties (layout, mapping, etc.), stripped of hierarchy data. */
755
+ config?: Record<string, any>;
756
+ /** Nested children tree nodes. */
757
+ children?: ConfigTreeNode[];
758
+ }
759
+
760
+ /**
761
+ * Trait: Provides identity with a unique ID and specific entity type.
762
+ */
763
+ interface IIdentifiable {
764
+ readonly uid: string;
765
+ readonly type: EntityType;
766
+ }
767
+ /**
768
+ * Trait: Provides lifecycle management hooks.
769
+ */
770
+ interface ILifecycle {
771
+ /**
772
+ * Performs cleanup, unregisters the entity, and releases resources.
773
+ */
774
+ destroy(): void;
775
+ }
776
+ /**
777
+ * The core contract for any object that can be managed by the Registry.
778
+ * Only objects implementing this interface are eligible for registration.
779
+ */
780
+ interface ICoreEntity extends IIdentifiable, ILifecycle {
781
+ }
782
+ /**
783
+ * Trait: Enables spatial awareness for DOM/UI-related components.
784
+ */
785
+ interface ISpatial {
786
+ readonly rect: AbstractRect | null;
787
+ /**
788
+ * Dynamically obtain dimensions and position to ensure the most precise real-time screen coordinates are obtained during each interaction.
789
+ */
790
+ bindRectProvider(provider: () => AbstractRect): void;
791
+ }
792
+ /**
793
+ * Trait: Provides configuration management.
794
+ */
795
+ interface IConfigurable<TConfig> {
796
+ /**
797
+ * Dynamically updates the current configuration.
798
+ * @param config - Partial configuration object to merge.
799
+ */
800
+ updateConfig(config: Partial<TConfig>): void;
801
+ /**
802
+ * Retrieves a snapshot of the current configuration.
803
+ */
804
+ getConfig(): TConfig;
805
+ }
806
+ /**
807
+ * Trait: Enables state subscription for the adapter layer (e.g., Vue/React).
808
+ */
809
+ interface IObservable<TState> {
810
+ /**
811
+ * Subscribes to state changes.
812
+ * @param cb - Callback function triggered on state updates.
813
+ * @returns An unsubscribe function.
814
+ */
815
+ subscribe(cb: (state: TState) => void): () => void;
816
+ /**
817
+ * Retrieves the current state snapshot.
818
+ */
819
+ getState(): TState;
820
+ }
821
+ /**
822
+ * Trait: Allows resetting the entity to its idle/safe state.
823
+ */
824
+ interface IResettable {
825
+ /**
826
+ * Forcefully clears active states and cuts off outgoing signals.
827
+ */
828
+ reset(): void;
829
+ }
830
+ /**
831
+ * Trait: Handles raw pointer input (Touch/Mouse).
832
+ */
833
+ interface IPointerHandler {
834
+ readonly activePointerId: number | null;
835
+ onPointerDown(e: AbstractPointerEvent): void;
836
+ onPointerMove(e: AbstractPointerEvent): void;
837
+ onPointerUp(e: AbstractPointerEvent): void;
838
+ onPointerCancel(e: AbstractPointerEvent): void;
839
+ }
840
+ /**
841
+ * Trait: Receives and processes input signals (e.g., TargetZone).
842
+ */
843
+ interface ISignalReceiver {
844
+ /**
845
+ * Handles incoming signals from widgets.
846
+ * @param signal - The signal data containing action type and payload.
847
+ */
848
+ handleSignal(signal: InputActionSignal): void;
849
+ }
850
+ /**
851
+ * Capability for an entity to receive and store external functional dependencies.
852
+ *
853
+ * This enables Runtime Dependency Injection (DI), allowing core logic to invoke
854
+ * host-specific methods (such as DOM event dispatchers or custom triggers)
855
+ * without being tightly coupled to the environment.
856
+ */
857
+ interface IDependencyBindable {
858
+ /**
859
+ * Binds a functional delegate by a specific identifier key.
860
+ *
861
+ * @param key - The unique lookup identifier for the dependency (e.g., 'domDispatcher').
862
+ * @param delegate - The function implementation provided by the adapter layer.
863
+ */
864
+ bindDelegate(key: string, delegate: AnyFunction): void;
865
+ }
866
+ /**
867
+ * Contract for widgets that support programmatic control.
868
+ *
869
+ * This interface allows external systems—such as a Physical Gamepad Manager or
870
+ * automation scripts—to directly drive the state and behavior of a widget,
871
+ * bypassing native DOM pointer events.
872
+ */
873
+ interface IProgrammatic {
874
+ /**
875
+ * Manually triggers the 'down' (pressed) state of the widget.
876
+ * Primarily used for Button-type components to simulate a physical press.
877
+ */
878
+ triggerDown?(): void;
879
+ /**
880
+ * Manually triggers the 'up' (released) state of the widget.
881
+ * Primarily used for Button-type components to simulate a physical release.
882
+ */
883
+ triggerUp?(): void;
884
+ /**
885
+ * Manually updates the directional input vector of the widget.
886
+ * Primarily used for Joystick or D-Pad components.
887
+ *
888
+ * @param x - The horizontal component, normalized between -1.0 and 1.0.
889
+ * @param y - The vertical component, normalized between -1.0 and 1.0.
890
+ */
891
+ triggerVector?(x: number, y: number): void;
892
+ }
893
+
894
+ /**
895
+ * =================================================================
896
+ * 1. Constants Definition
897
+ * Used for runtime logic and as a baseline for type definitions.
898
+ * =================================================================
899
+ */
900
+ /**
901
+ * Core entity types supported by the library.
902
+ */
903
+ declare const CMP_TYPES: {
904
+ /** Area responsible for capturing touches and spawning dynamic widgets */
905
+ readonly INPUT_ZONE: "input-zone";
906
+ /** Area responsible for receiving signals and simulating DOM events */
907
+ readonly TARGET_ZONE: "target-zone";
908
+ readonly BUTTON: "button";
909
+ /** Simulates a physical keyboard key press */
910
+ readonly KEYBOARD_BUTTON: "keyboard-button";
911
+ /** Simulates a mouse button click/hold */
912
+ readonly MOUSE_BUTTON: "mouse-button";
913
+ /** A joystick that outputs 360-degree or locked direction vectors */
914
+ readonly JOYSTICK: "joystick";
915
+ /** Classic 4/8-way directional pad */
916
+ readonly D_PAD: "d-pad";
917
+ /** Trackpad-style relative movement area */
918
+ readonly TRACKPAD: "trackpad";
919
+ /** Logic for the on-screen visual cursor */
920
+ readonly VIRTUAL_CURSOR: "virtual-cursor";
921
+ /** The top-level managed container */
922
+ readonly ROOT_LAYER: "root-layer";
923
+ };
924
+ /**
925
+ * Standardized input action types for the signal protocol.
926
+ */
927
+ declare const ACTION_TYPES: {
928
+ readonly KEYDOWN: "keydown";
929
+ readonly KEYUP: "keyup";
930
+ readonly POINTER: "pointer";
931
+ readonly POINTERMOVE: "pointermove";
932
+ readonly POINTERDOWN: "pointerdown";
933
+ readonly POINTERUP: "pointerup";
934
+ readonly MOUSE: "mouse";
935
+ readonly MOUSEMOVE: "mousemove";
936
+ readonly MOUSEDOWN: "mousedown";
937
+ readonly MOUSEUP: "mouseup";
938
+ readonly CLICK: "click";
939
+ };
940
+ /**
941
+ * =================================================================
942
+ * 2. Type Definitions
943
+ * =================================================================
944
+ */
945
+ /** * Represents an abstract bounding box, typically used as a
946
+ * lightweight alternative to the DOMRect interface.
947
+ */
948
+ interface AbstractRect {
949
+ left: number;
950
+ top: number;
951
+ width: number;
952
+ height: number;
953
+ }
954
+ /** * Represents abstract pointer data, providing a platform-agnostic
955
+ * alternative to the native PointerEvent.
956
+ */
957
+ interface AbstractPointerEvent {
958
+ pointerId: number;
959
+ clientX: number;
960
+ clientY: number;
961
+ button: number;
962
+ }
963
+ /**
964
+ * Represents a 2D coordinate or vector.
965
+ * Typically used for percentage-based positioning (0-100).
966
+ */
967
+ interface Vec2 {
968
+ x: number;
969
+ y: number;
970
+ }
971
+ /** Unique identifier for a Stage (TargetZone) */
972
+ type StageId = string;
973
+ /** Unique identifier for an Input Widget */
974
+ type WidgetId = string;
975
+ /** Unique identifier for a Zone container (InputZone) */
976
+ type ZoneId = string;
977
+ /** Union type of all built-in entity values */
978
+ type AnyEntityType = (typeof CMP_TYPES)[keyof typeof CMP_TYPES];
979
+ /** Supported Widget type strings, allowing for custom string extensions */
980
+ type WidgetType = typeof CMP_TYPES.BUTTON | typeof CMP_TYPES.KEYBOARD_BUTTON | typeof CMP_TYPES.MOUSE_BUTTON | typeof CMP_TYPES.JOYSTICK | typeof CMP_TYPES.D_PAD | typeof CMP_TYPES.TRACKPAD | (string & {});
981
+ /** Supported Zone type strings, allowing for custom string extensions */
982
+ type ZoneType = typeof CMP_TYPES.INPUT_ZONE | typeof CMP_TYPES.TARGET_ZONE | (string & {});
983
+ /** General node type identifier for ConfigTreeNode or Registry lookups */
984
+ type EntityType = AnyEntityType | (string & {});
985
+ /** Built-in input action identifiers */
986
+ type BuiltInActionType = (typeof ACTION_TYPES)[keyof typeof ACTION_TYPES];
987
+ /** Input action type strings, allowing for custom action extensions */
988
+ type InputActionType = BuiltInActionType | (string & {});
989
+ /** Supported CSS units for layout calculation */
990
+ type Unit = 'px' | '%' | 'vh' | 'vw' | 'rem';
991
+ /**
992
+ * Flexible length input.
993
+ * Supports numbers (interpreted as px) or strings (e.g., '50%', '10vh').
994
+ */
995
+ type FlexibleLength = string | number;
996
+ /**
997
+ * Anchor position used to determine the alignment of an element relative to its coordinates.
998
+ */
999
+ type AnchorPoint = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
1000
+ /**
1001
+ * =================================================================
1002
+ * 3. Signal Protocol
1003
+ * Data structure for communication between Widgets and Stages.
1004
+ * =================================================================
1005
+ */
1006
+ /**
1007
+ * Represents a signal emitted by an input widget to be processed by a target zone.
1008
+ */
1009
+ interface InputActionSignal {
1010
+ /** The unique identifier of the destination TargetZone */
1011
+ targetStageId: StageId;
1012
+ /** The action type to perform (e.g., keydown, mousemove) */
1013
+ type: InputActionType;
1014
+ /** The payload containing specific input details */
1015
+ payload: {
1016
+ /** Character value of the key (e.g., ' ') */
1017
+ key?: string;
1018
+ /** Physical key code (e.g., 'Space') */
1019
+ code?: string;
1020
+ /** Legacy numeric key code (e.g., 32) */
1021
+ keyCode?: number;
1022
+ /** Coordinate point in percentage (0-100) */
1023
+ point?: Vec2;
1024
+ /** Relative displacement in percentage (0-100) */
1025
+ delta?: Vec2;
1026
+ /** Mouse button index (0: Left, 1: Middle, 2: Right) */
1027
+ button?: 0 | 1 | 2;
1028
+ /** Input pressure or force (0.0 to 1.0) */
1029
+ pressure?: number;
1030
+ /** Allows for arbitrary custom data to support widget extensions */
1031
+ [key: string]: any;
1032
+ };
1033
+ }
1034
+ /**
1035
+ * Cross-framework context keys for dependency injection (e.g., Provide/Inject).
1036
+ */
1037
+ declare const CONTEXT: {
1038
+ /** The key used to propagate Parent IDs through the component tree */
1039
+ readonly PARENT_ID_KEY: "omnipad-parent-id-link";
1040
+ };
1041
+ /**
1042
+ * A safe alternative to the global 'Function' type.
1043
+ * Represents any callable function with any arguments.
1044
+ */
1045
+ type AnyFunction = (...args: any[]) => void;
1046
+
1047
+ export { type AbstractRect as A, type ButtonConfig as B, CMP_TYPES as C, type DPadConfig as D, type EntityType as E, type FlatConfigItem as F, type GamepadMappingConfig as G, type InputActionType as H, type ICoreEntity as I, type JoystickConfig as J, KEYS as K, type KeyMapping as L, type LayoutBox as M, type StandardButton as N, type WidgetType as O, type ZoneType as P, type StageId as S, type TargetZoneConfig as T, type Unit as U, type Vec2 as V, type WidgetId as W, type ZoneId as Z, type ISpatial as a, type IResettable as b, type IConfigurable as c, type IObservable as d, type IPointerHandler as e, type IProgrammatic as f, type AbstractPointerEvent as g, type InputZoneConfig as h, type IDependencyBindable as i, type AnyFunction as j, type BaseConfig as k, type ISignalReceiver as l, type InputActionSignal as m, type TrackpadConfig as n, ACTION_TYPES as o, type ActionMapping as p, type AnchorPoint as q, type AnyConfig as r, type AnyEntityType as s, type BuiltInActionType as t, CONTEXT as u, type ConfigTreeNode as v, type FlexibleLength as w, type GamepadProfile as x, type IIdentifiable as y, type ILifecycle as z };