canvasengine 2.0.0-beta.5 → 2.0.0-beta.50
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/components/Button.d.ts +185 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Canvas.d.ts +17 -0
- package/dist/components/Canvas.d.ts.map +1 -0
- package/dist/components/Container.d.ts +86 -0
- package/dist/components/Container.d.ts.map +1 -0
- package/dist/components/DOMContainer.d.ts +98 -0
- package/dist/components/DOMContainer.d.ts.map +1 -0
- package/dist/components/DOMElement.d.ts +54 -0
- package/dist/components/DOMElement.d.ts.map +1 -0
- package/dist/components/DOMSprite.d.ts +127 -0
- package/dist/components/DOMSprite.d.ts.map +1 -0
- package/dist/components/DisplayObject.d.ts +94 -0
- package/dist/components/DisplayObject.d.ts.map +1 -0
- package/dist/components/FocusContainer.d.ts +129 -0
- package/dist/components/FocusContainer.d.ts.map +1 -0
- package/dist/components/Graphic.d.ts +64 -0
- package/dist/components/Graphic.d.ts.map +1 -0
- package/dist/components/Joystick.d.ts +36 -0
- package/dist/components/Joystick.d.ts.map +1 -0
- package/dist/components/Mesh.d.ts +208 -0
- package/dist/components/Mesh.d.ts.map +1 -0
- package/dist/components/NineSliceSprite.d.ts +16 -0
- package/dist/components/NineSliceSprite.d.ts.map +1 -0
- package/dist/components/ParticleEmitter.d.ts +4 -0
- package/dist/components/ParticleEmitter.d.ts.map +1 -0
- package/dist/components/Scene.d.ts +2 -0
- package/dist/components/Scene.d.ts.map +1 -0
- package/dist/components/Sprite.d.ts +242 -0
- package/dist/components/Sprite.d.ts.map +1 -0
- package/dist/components/Text.d.ts +25 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/TilingSprite.d.ts +17 -0
- package/dist/components/TilingSprite.d.ts.map +1 -0
- package/dist/components/Video.d.ts +14 -0
- package/dist/components/Video.d.ts.map +1 -0
- package/dist/components/Viewport.d.ts +121 -0
- package/dist/components/Viewport.d.ts.map +1 -0
- package/dist/components/index.d.ts +20 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/types/DisplayObject.d.ts +106 -0
- package/dist/components/types/DisplayObject.d.ts.map +1 -0
- package/dist/components/types/MouseEvent.d.ts +4 -0
- package/dist/components/types/MouseEvent.d.ts.map +1 -0
- package/dist/components/types/Spritesheet.d.ts +248 -0
- package/dist/components/types/Spritesheet.d.ts.map +1 -0
- package/dist/components/types/index.d.ts +4 -0
- package/dist/components/types/index.d.ts.map +1 -0
- package/dist/directives/Controls.d.ts +112 -0
- package/dist/directives/Controls.d.ts.map +1 -0
- package/dist/directives/ControlsBase.d.ts +199 -0
- package/dist/directives/ControlsBase.d.ts.map +1 -0
- package/dist/directives/Drag.d.ts +69 -0
- package/dist/directives/Drag.d.ts.map +1 -0
- package/dist/directives/Flash.d.ts +116 -0
- package/dist/directives/Flash.d.ts.map +1 -0
- package/dist/directives/FocusNavigation.d.ts +52 -0
- package/dist/directives/FocusNavigation.d.ts.map +1 -0
- package/dist/directives/GamepadControls.d.ts +224 -0
- package/dist/directives/GamepadControls.d.ts.map +1 -0
- package/dist/directives/JoystickControls.d.ts +171 -0
- package/dist/directives/JoystickControls.d.ts.map +1 -0
- package/dist/directives/KeyboardControls.d.ts +219 -0
- package/dist/directives/KeyboardControls.d.ts.map +1 -0
- package/dist/directives/Scheduler.d.ts +35 -0
- package/dist/directives/Scheduler.d.ts.map +1 -0
- package/dist/directives/Shake.d.ts +98 -0
- package/dist/directives/Shake.d.ts.map +1 -0
- package/dist/directives/Sound.d.ts +25 -0
- package/dist/directives/Sound.d.ts.map +1 -0
- package/dist/directives/Transition.d.ts +10 -0
- package/dist/directives/Transition.d.ts.map +1 -0
- package/dist/directives/ViewportCull.d.ts +11 -0
- package/dist/directives/ViewportCull.d.ts.map +1 -0
- package/dist/directives/ViewportFollow.d.ts +18 -0
- package/dist/directives/ViewportFollow.d.ts.map +1 -0
- package/dist/directives/index.d.ts +13 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/engine/FocusManager.d.ts +174 -0
- package/dist/engine/FocusManager.d.ts.map +1 -0
- package/dist/engine/animation.d.ts +72 -0
- package/dist/engine/animation.d.ts.map +1 -0
- package/dist/engine/bootstrap.d.ts +48 -0
- package/dist/engine/bootstrap.d.ts.map +1 -0
- package/dist/engine/directive.d.ts +13 -0
- package/dist/engine/directive.d.ts.map +1 -0
- package/dist/engine/reactive.d.ts +134 -0
- package/dist/engine/reactive.d.ts.map +1 -0
- package/dist/engine/signal.d.ts +71 -0
- package/dist/engine/signal.d.ts.map +1 -0
- package/dist/engine/trigger.d.ts +54 -0
- package/dist/engine/trigger.d.ts.map +1 -0
- package/dist/engine/utils.d.ts +89 -0
- package/dist/engine/utils.d.ts.map +1 -0
- package/dist/hooks/addContext.d.ts +2 -0
- package/dist/hooks/addContext.d.ts.map +1 -0
- package/dist/hooks/useFocus.d.ts +60 -0
- package/dist/hooks/useFocus.d.ts.map +1 -0
- package/dist/hooks/useProps.d.ts +42 -0
- package/dist/hooks/useProps.d.ts.map +1 -0
- package/dist/hooks/useRef.d.ts +4 -0
- package/dist/hooks/useRef.d.ts.map +1 -0
- package/dist/index-DaGekQUW.js +2218 -0
- package/dist/index-DaGekQUW.js.map +1 -0
- package/dist/index.d.ts +19 -1099
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +5 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +11749 -2901
- package/dist/index.js.map +1 -1
- package/dist/utils/Ease.d.ts +17 -0
- package/dist/utils/Ease.d.ts.map +1 -0
- package/dist/utils/GlobalAssetLoader.d.ts +141 -0
- package/dist/utils/GlobalAssetLoader.d.ts.map +1 -0
- package/dist/utils/RadialGradient.d.ts +57 -0
- package/dist/utils/RadialGradient.d.ts.map +1 -0
- package/dist/utils/functions.d.ts +2 -0
- package/dist/utils/functions.d.ts.map +1 -0
- package/dist/utils/tabindex.d.ts +16 -0
- package/dist/utils/tabindex.d.ts.map +1 -0
- package/package.json +13 -7
- package/src/components/Button.ts +399 -0
- package/src/components/Canvas.ts +62 -46
- package/src/components/Container.ts +21 -2
- package/src/components/DOMContainer.ts +379 -0
- package/src/components/DOMElement.ts +556 -0
- package/src/components/DOMSprite.ts +1040 -0
- package/src/components/DisplayObject.ts +392 -201
- package/src/components/FocusContainer.ts +368 -0
- package/src/components/Graphic.ts +227 -66
- package/src/components/Joystick.ts +363 -0
- package/src/components/Mesh.ts +222 -0
- package/src/components/NineSliceSprite.ts +4 -1
- package/src/components/ParticleEmitter.ts +12 -8
- package/src/components/Sprite.ts +297 -31
- package/src/components/Text.ts +125 -18
- package/src/components/Video.ts +2 -2
- package/src/components/Viewport.ts +118 -63
- package/src/components/index.ts +9 -2
- package/src/components/types/DisplayObject.ts +41 -4
- package/src/components/types/Spritesheet.ts +0 -118
- package/src/directives/Controls.ts +254 -0
- package/src/directives/ControlsBase.ts +267 -0
- package/src/directives/Drag.ts +357 -52
- package/src/directives/Flash.ts +419 -0
- package/src/directives/FocusNavigation.ts +113 -0
- package/src/directives/GamepadControls.ts +537 -0
- package/src/directives/JoystickControls.ts +396 -0
- package/src/directives/KeyboardControls.ts +85 -430
- package/src/directives/Scheduler.ts +12 -4
- package/src/directives/Shake.ts +298 -0
- package/src/directives/Sound.ts +94 -31
- package/src/directives/ViewportFollow.ts +40 -9
- package/src/directives/index.ts +12 -6
- package/src/engine/FocusManager.ts +510 -0
- package/src/engine/animation.ts +175 -21
- package/src/engine/bootstrap.ts +93 -3
- package/src/engine/directive.ts +4 -4
- package/src/engine/reactive.ts +901 -161
- package/src/engine/signal.ts +113 -25
- package/src/engine/trigger.ts +34 -7
- package/src/engine/utils.ts +19 -3
- package/src/hooks/useFocus.ts +91 -0
- package/src/hooks/useProps.ts +1 -1
- package/src/index.ts +8 -2
- package/src/types/pixi-cull.d.ts +7 -0
- package/src/utils/GlobalAssetLoader.ts +257 -0
- package/src/utils/functions.ts +7 -0
- package/src/utils/tabindex.ts +70 -0
- package/testing/index.ts +35 -4
- package/tsconfig.json +18 -0
- package/vite.config.ts +39 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { ControlsBase, ControlOptions, Controls, BoundKey } from './ControlsBase';
|
|
2
|
+
export declare enum Input {
|
|
3
|
+
Break = "break",
|
|
4
|
+
Backspace = "backspace",
|
|
5
|
+
Tab = "tab",
|
|
6
|
+
Clear = "clear",
|
|
7
|
+
Enter = "enter",
|
|
8
|
+
Shift = "shift",
|
|
9
|
+
Ctrl = "ctrl",
|
|
10
|
+
Alt = "alt",
|
|
11
|
+
Pause = "pause/break",
|
|
12
|
+
CapsLock = "caps lock",
|
|
13
|
+
Escape = "escape",
|
|
14
|
+
Conversion = "conversion",
|
|
15
|
+
NonConversion = "non-conversion",
|
|
16
|
+
Space = "space",
|
|
17
|
+
PageUp = "page up",
|
|
18
|
+
PageDown = "page down",
|
|
19
|
+
End = "end",
|
|
20
|
+
Home = "home",
|
|
21
|
+
Left = 4,
|
|
22
|
+
Up = 1,
|
|
23
|
+
Right = 2,
|
|
24
|
+
Down = 3,
|
|
25
|
+
Select = "select",
|
|
26
|
+
Print = "print",
|
|
27
|
+
Execute = "execute",
|
|
28
|
+
PrintScreen = "Print Screen",
|
|
29
|
+
Insert = "insert",
|
|
30
|
+
Delete = "delete",
|
|
31
|
+
Zero = "0",
|
|
32
|
+
One = "1",
|
|
33
|
+
Two = "2",
|
|
34
|
+
Three = "3",
|
|
35
|
+
Four = "4",
|
|
36
|
+
Five = "5",
|
|
37
|
+
Six = "6",
|
|
38
|
+
Seven = "7",
|
|
39
|
+
Height = "8",
|
|
40
|
+
Nine = "9",
|
|
41
|
+
Equal = "=",
|
|
42
|
+
Semicolon = "semicolon (firefox), equals",
|
|
43
|
+
LessThan = "<",
|
|
44
|
+
Equals = "equals (firefox)",
|
|
45
|
+
Beta = "\u00DF",
|
|
46
|
+
At = "@",
|
|
47
|
+
A = "a",
|
|
48
|
+
B = "b",
|
|
49
|
+
C = "c",
|
|
50
|
+
D = "d",
|
|
51
|
+
E = "e",
|
|
52
|
+
F = "f",
|
|
53
|
+
G = "g",
|
|
54
|
+
H = "h",
|
|
55
|
+
I = "i",
|
|
56
|
+
J = "j",
|
|
57
|
+
K = "k",
|
|
58
|
+
L = "l",
|
|
59
|
+
M = "m",
|
|
60
|
+
N = "n",
|
|
61
|
+
O = "o",
|
|
62
|
+
P = "p",
|
|
63
|
+
Q = "q",
|
|
64
|
+
R = "r",
|
|
65
|
+
S = "s",
|
|
66
|
+
T = "t",
|
|
67
|
+
U = "u",
|
|
68
|
+
V = "v",
|
|
69
|
+
W = "w",
|
|
70
|
+
X = "x",
|
|
71
|
+
Y = "y",
|
|
72
|
+
Z = "z",
|
|
73
|
+
SearchKey = "Windows Key / Left \u2318 / Chromebook Search key",
|
|
74
|
+
NumPad0 = "numpad 0",
|
|
75
|
+
NumPad1 = "numpad 1",
|
|
76
|
+
NumPad2 = "numpad 2",
|
|
77
|
+
NumPad3 = "numpad 3",
|
|
78
|
+
NumPad4 = "numpad 4",
|
|
79
|
+
NumPad5 = "numpad 5",
|
|
80
|
+
NumPad6 = "numpad 6",
|
|
81
|
+
NumPad7 = "numpad 7",
|
|
82
|
+
NumPad8 = "numpad 8",
|
|
83
|
+
NumPad9 = "numpad 9",
|
|
84
|
+
Multiply = "multiply",
|
|
85
|
+
Add = "add",
|
|
86
|
+
Subtract = "subtract",
|
|
87
|
+
DecimalPoint = "decimal point",
|
|
88
|
+
Divide = "divide",
|
|
89
|
+
F1 = "f1",
|
|
90
|
+
F2 = "f2",
|
|
91
|
+
F3 = "f3",
|
|
92
|
+
F4 = "f4",
|
|
93
|
+
F5 = "f5",
|
|
94
|
+
F6 = "f6",
|
|
95
|
+
F7 = "f7",
|
|
96
|
+
F8 = "f8",
|
|
97
|
+
F9 = "f9",
|
|
98
|
+
F10 = "f10",
|
|
99
|
+
F11 = "f11",
|
|
100
|
+
F12 = "f12",
|
|
101
|
+
F13 = "f13",
|
|
102
|
+
F14 = "f14",
|
|
103
|
+
F15 = "f15",
|
|
104
|
+
F16 = "f16",
|
|
105
|
+
F17 = "f17",
|
|
106
|
+
F18 = "f18",
|
|
107
|
+
F19 = "f19",
|
|
108
|
+
F20 = "f20",
|
|
109
|
+
F21 = "f21",
|
|
110
|
+
F22 = "f22",
|
|
111
|
+
F23 = "f23",
|
|
112
|
+
F24 = "f24",
|
|
113
|
+
NumLock = "num lock",
|
|
114
|
+
ScrollLock = "scroll lock",
|
|
115
|
+
CircumflexAccent = "^",
|
|
116
|
+
ExclamationMark = "!",
|
|
117
|
+
Hash = "#",
|
|
118
|
+
Dollar = "$",
|
|
119
|
+
AccentU = "\u00F9",
|
|
120
|
+
PageBackward = "page backward",
|
|
121
|
+
PageForWard = "page forward",
|
|
122
|
+
Star = "*",
|
|
123
|
+
DecreaseVolume = "decrease volume level",
|
|
124
|
+
IncreaseVolume = "increase volume level",
|
|
125
|
+
Next = "next",
|
|
126
|
+
Previous = "previous",
|
|
127
|
+
Stop = "stop",
|
|
128
|
+
PlayPause = "play/pause",
|
|
129
|
+
Email = "e-mail",
|
|
130
|
+
SemiColon = "semi-colon / \u00F1",
|
|
131
|
+
EqualSign = "equal sign",
|
|
132
|
+
Comma = "comma",
|
|
133
|
+
Dash = "dash",
|
|
134
|
+
FowardSlach = "forward slash / \u00E7",
|
|
135
|
+
GraveAccent = "grave accent / \u00F1 / \u00E6",
|
|
136
|
+
OpenBracket = "open bracket",
|
|
137
|
+
BackSlach = "back slash",
|
|
138
|
+
CloseBracket = "close bracket / \u00E5",
|
|
139
|
+
SingleQuote = "single quote / \u00F8",
|
|
140
|
+
BackQuote = "`",
|
|
141
|
+
Altgr = "altgr"
|
|
142
|
+
}
|
|
143
|
+
export type { ControlOptions, Controls, BoundKey };
|
|
144
|
+
/**
|
|
145
|
+
* Keyboard input controls implementation
|
|
146
|
+
*
|
|
147
|
+
* Handles keyboard input events and maps them to control actions.
|
|
148
|
+
* Supports composite directions (diagonal movement) and key repeat functionality.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* const keyboardControls = new KeyboardControls();
|
|
153
|
+
* keyboardControls.setInputs({
|
|
154
|
+
* up: {
|
|
155
|
+
* repeat: true,
|
|
156
|
+
* bind: Input.Up,
|
|
157
|
+
* keyDown() {
|
|
158
|
+
* console.log('Up pressed');
|
|
159
|
+
* }
|
|
160
|
+
* }
|
|
161
|
+
* });
|
|
162
|
+
* keyboardControls.start();
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare class KeyboardControls extends ControlsBase {
|
|
166
|
+
private keyState;
|
|
167
|
+
private lastKeyPressed;
|
|
168
|
+
private lastActionTimes;
|
|
169
|
+
private directionState;
|
|
170
|
+
/**
|
|
171
|
+
* Setup keyboard event listeners
|
|
172
|
+
*/
|
|
173
|
+
protected setupListeners(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Cleanup keyboard event listeners
|
|
176
|
+
*/
|
|
177
|
+
protected cleanup(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Process keyboard inputs each step
|
|
180
|
+
*/
|
|
181
|
+
protected preStep(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Apply input for a keyboard key
|
|
184
|
+
* Overrides base implementation to handle key state and repeat logic
|
|
185
|
+
*/
|
|
186
|
+
protected applyInput(keyName: string): void;
|
|
187
|
+
private applyKeyDown;
|
|
188
|
+
private applyKeyUp;
|
|
189
|
+
private applyKeyPress;
|
|
190
|
+
private onKeyChange;
|
|
191
|
+
private updateDirectionState;
|
|
192
|
+
private getDirection;
|
|
193
|
+
/**
|
|
194
|
+
* Apply a control action programmatically
|
|
195
|
+
* Triggers keyboard events to simulate key presses
|
|
196
|
+
*
|
|
197
|
+
* @param controlName - Name of the control
|
|
198
|
+
* @param isDown - Whether the key is pressed (true) or released (false)
|
|
199
|
+
* @returns Promise that resolves when the action is complete
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* // Press a key
|
|
203
|
+
* await keyboardControls.applyControl('action', true);
|
|
204
|
+
*
|
|
205
|
+
* // Release a key
|
|
206
|
+
* await keyboardControls.applyControl('action', false);
|
|
207
|
+
*
|
|
208
|
+
* // Press and release (default)
|
|
209
|
+
* await keyboardControls.applyControl('action');
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
applyControl(controlName: string | number, isDown?: boolean | undefined): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Resume listening to inputs after stopInputs() was called
|
|
215
|
+
* Also resets keyboard state
|
|
216
|
+
*/
|
|
217
|
+
listenInputs(): void;
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=KeyboardControls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyboardControls.d.ts","sourceRoot":"","sources":["../../src/directives/KeyboardControls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAElF,oBAAY,KAAK;IACb,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;IACf,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,gBAAgB;IACrB,QAAQ,cAAc;IACtB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,aAAa,mBAAmB;IAChC,KAAK,UAAU;IACf,MAAM,YAAY;IAClB,QAAQ,cAAc;IACtB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,IAAI,IAAI;IACR,EAAE,IAAI;IACN,KAAK,IAAI;IACT,IAAI,IAAI;IACR,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,WAAW,iBAAiB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,IAAI,MAAM;IACV,GAAG,MAAM;IACT,GAAG,MAAM;IACT,KAAK,MAAM;IACX,IAAI,MAAM;IACV,IAAI,MAAM;IAC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O,CAAC,oBAAoB;IAiB5B,OAAO,CAAC,YAAY;IAepB;;;;;;;;;;;;;;;;;;OAkBG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7F;;;OAGG;IACH,YAAY;CAKf"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Directive } from '../engine/directive';
|
|
2
|
+
import { Element } from '../engine/reactive';
|
|
3
|
+
export interface Tick {
|
|
4
|
+
timestamp: number;
|
|
5
|
+
deltaTime: number;
|
|
6
|
+
frame: number;
|
|
7
|
+
deltaRatio: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class Scheduler extends Directive {
|
|
10
|
+
private maxFps?;
|
|
11
|
+
private fps;
|
|
12
|
+
private deltaTime;
|
|
13
|
+
frame: number;
|
|
14
|
+
private timestamp;
|
|
15
|
+
private requestedDelay;
|
|
16
|
+
private lastTimestamp;
|
|
17
|
+
private _stop;
|
|
18
|
+
private tick;
|
|
19
|
+
onInit(element: Element): void;
|
|
20
|
+
onDestroy(): void;
|
|
21
|
+
onMount(element: Element): void;
|
|
22
|
+
onUpdate(props: any): void;
|
|
23
|
+
nextTick(timestamp: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* start the schedule
|
|
26
|
+
* @return {Scheduler} returns this scheduler instance
|
|
27
|
+
*/
|
|
28
|
+
start(options?: {
|
|
29
|
+
maxFps?: number;
|
|
30
|
+
fps?: number;
|
|
31
|
+
delay?: number;
|
|
32
|
+
}): this;
|
|
33
|
+
stop(): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=Scheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scheduler.d.ts","sourceRoot":"","sources":["../../src/directives/Scheduler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,MAAM,WAAW,IAAI;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;CACrB;AAED,qBAAa,SAAU,SAAQ,SAAS;IACpC,OAAO,CAAC,MAAM,CAAC,CAAQ;IACvB,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,SAAS,CAAY;IACtB,KAAK,EAAE,MAAM,CAAI;IACxB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,IAAI,CAA6B;IAEzC,MAAM,CAAC,OAAO,EAAE,OAAO;IAIvB,SAAS;IACT,OAAO,CAAC,OAAO,EAAE,OAAO;IACxB,QAAQ,CAAC,KAAK,EAAE,GAAG;IAEnB,QAAQ,CAAC,SAAS,EAAE,MAAM;IAqB1B;;;OAGG;IACH,KAAK,CAAC,OAAO,GAAE;QACX,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;KACZ;IA2CN,IAAI;CAGP"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { Directive } from '../engine/directive';
|
|
3
|
+
import { Element } from '../engine/reactive';
|
|
4
|
+
import { Trigger } from '../engine/trigger';
|
|
5
|
+
import { SignalOrPrimitive } from '../components/types';
|
|
6
|
+
export type ShakeProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Trigger that activates the shake animation
|
|
9
|
+
* When the trigger is activated, the shake animation will start
|
|
10
|
+
*/
|
|
11
|
+
trigger?: Trigger<any>;
|
|
12
|
+
/**
|
|
13
|
+
* Intensity of the shake effect (in pixels)
|
|
14
|
+
* @default 10
|
|
15
|
+
*/
|
|
16
|
+
intensity?: SignalOrPrimitive<number>;
|
|
17
|
+
/**
|
|
18
|
+
* Duration of the shake animation in milliseconds
|
|
19
|
+
* @default 500
|
|
20
|
+
*/
|
|
21
|
+
duration?: SignalOrPrimitive<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Number of shake oscillations during the animation
|
|
24
|
+
* Higher values create more rapid shaking
|
|
25
|
+
* @default 10
|
|
26
|
+
*/
|
|
27
|
+
frequency?: SignalOrPrimitive<number>;
|
|
28
|
+
/**
|
|
29
|
+
* Direction of the shake: 'x', 'y', or 'both'
|
|
30
|
+
* @default 'both'
|
|
31
|
+
*/
|
|
32
|
+
direction?: SignalOrPrimitive<'x' | 'y' | 'both'>;
|
|
33
|
+
/**
|
|
34
|
+
* Callback function called when shake starts
|
|
35
|
+
*/
|
|
36
|
+
onStart?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback function called when shake completes
|
|
39
|
+
*/
|
|
40
|
+
onComplete?: () => void;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Shake directive that animates a display object's position when a trigger is activated.
|
|
44
|
+
* Creates a shake effect by rapidly oscillating the x and/or y position.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Basic usage with trigger
|
|
49
|
+
* const shakeTrigger = trigger();
|
|
50
|
+
*
|
|
51
|
+
* onMount(element) {
|
|
52
|
+
* // Element will shake when trigger is activated
|
|
53
|
+
* element.props.shake = { trigger: shakeTrigger };
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* // Trigger the shake
|
|
57
|
+
* shakeTrigger.start();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class Shake extends Directive {
|
|
61
|
+
private elementRef;
|
|
62
|
+
private originalPosition;
|
|
63
|
+
private progressSignal;
|
|
64
|
+
private shakeSubscription;
|
|
65
|
+
private positionEffect;
|
|
66
|
+
private currentShakeConfig;
|
|
67
|
+
/**
|
|
68
|
+
* Initializes the shake directive
|
|
69
|
+
* @param element - The element to attach the shake effect to
|
|
70
|
+
*/
|
|
71
|
+
onInit(element: Element<Container>): void;
|
|
72
|
+
/**
|
|
73
|
+
* Mounts the shake directive and sets up trigger listener
|
|
74
|
+
* @param element - The element being mounted
|
|
75
|
+
*/
|
|
76
|
+
onMount(element: Element<Container>): void;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the shake props with default values
|
|
79
|
+
* @returns ShakeProps with defaults applied
|
|
80
|
+
*/
|
|
81
|
+
get shakeProps(): ShakeProps;
|
|
82
|
+
private resolveSignalValue;
|
|
83
|
+
/**
|
|
84
|
+
* Performs the shake animation using animatedSignal
|
|
85
|
+
* @param data - Optional data passed from the trigger that can override default options
|
|
86
|
+
*/
|
|
87
|
+
private performShake;
|
|
88
|
+
/**
|
|
89
|
+
* Updates the shake directive when props change
|
|
90
|
+
* @param props - Updated props
|
|
91
|
+
*/
|
|
92
|
+
onUpdate(props: any): void;
|
|
93
|
+
/**
|
|
94
|
+
* Cleans up the shake directive
|
|
95
|
+
*/
|
|
96
|
+
onDestroy(): void;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=Shake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Shake.d.ts","sourceRoot":"","sources":["../../src/directives/Shake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAiB,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,MAAM,MAAM,UAAU,GAAG;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,iBAAiB,CAAC,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC;IAClD;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,KAAM,SAAQ,SAAS;IAChC,OAAO,CAAC,UAAU,CAAmC;IACrD,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,cAAc,CAAuC;IAC7D,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,kBAAkB,CAKV;IAEhB;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAIlC;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IA0BnC;;;OAGG;IACH,IAAI,UAAU,IAAI,UAAU,CAQ3B;IAED,OAAO,CAAC,kBAAkB;IAI1B;;;OAGG;YACW,YAAY;IA6G1B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG;IAUnB;;OAEG;IACH,SAAS;CA+BZ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { Directive } from '../engine/directive';
|
|
3
|
+
import { Element } from '../engine/reactive';
|
|
4
|
+
/**
|
|
5
|
+
* Sound directive for playing audio with support for spatial audio and multiple sound sources
|
|
6
|
+
*
|
|
7
|
+
* This directive manages audio playback using Howler.js library. It supports:
|
|
8
|
+
* - Single or multiple sound sources
|
|
9
|
+
* - Spatial audio with distance-based volume calculation
|
|
10
|
+
* - All standard audio controls (play, pause, volume, etc.)
|
|
11
|
+
* - Event handling for audio lifecycle
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export declare class Sound extends Directive {
|
|
15
|
+
private sounds;
|
|
16
|
+
private eventsFn;
|
|
17
|
+
private maxVolume;
|
|
18
|
+
private maxDistance;
|
|
19
|
+
private tickSubscription?;
|
|
20
|
+
onInit(element: Element<Container>): void;
|
|
21
|
+
onMount(element: Element<Container>): void;
|
|
22
|
+
onUpdate(props: any): void;
|
|
23
|
+
onDestroy(): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=Sound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sound.d.ts","sourceRoot":"","sources":["../../src/directives/Sound.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK7C;;;;;;;;;GASG;AACH,qBAAa,KAAM,SAAQ,SAAS;IAChC,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,gBAAgB,CAAC,CAAc;IAEvC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAElC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IA0DnC,QAAQ,CAAC,KAAK,EAAE,GAAG;IAuBnB,SAAS;CAkBZ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { Directive } from '../engine/directive';
|
|
3
|
+
import { Element } from '../engine/reactive';
|
|
4
|
+
export declare class Transition extends Directive {
|
|
5
|
+
onInit(element: Element<Container>): void;
|
|
6
|
+
onMount(element: Element<Container>): void;
|
|
7
|
+
onUpdate(props: any): void;
|
|
8
|
+
onDestroy(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Transition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transition.d.ts","sourceRoot":"","sources":["../../src/directives/Transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmD,MAAM,SAAS,CAAC;AAErF,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,qBAAa,UAAW,SAAQ,SAAS;IAGrC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAGlC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAuBnC,QAAQ,CAAC,KAAK,EAAE,GAAG;IAInB,SAAS;CAGZ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { Directive } from '../engine/directive';
|
|
3
|
+
import { Element } from '../engine/reactive';
|
|
4
|
+
export declare class ViewportCull extends Directive {
|
|
5
|
+
private cull;
|
|
6
|
+
onInit(element: any): void;
|
|
7
|
+
onMount(element: Element<Container>): void;
|
|
8
|
+
onUpdate(props: any): void;
|
|
9
|
+
onDestroy(): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ViewportCull.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewportCull.d.ts","sourceRoot":"","sources":["../../src/directives/ViewportCull.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,qBAAa,YAAa,SAAQ,SAAS;IACvC,OAAO,CAAC,IAAI,CAAQ;IAEpB,MAAM,CAAC,OAAO,KAAA;IAKd,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAoBnC,QAAQ,CAAC,KAAK,EAAE,GAAG;IACnB,SAAS;CACZ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ComponentInstance } from '../components/DisplayObject';
|
|
2
|
+
import { SignalOrPrimitive } from '../components/types';
|
|
3
|
+
import { Directive } from '../engine/directive';
|
|
4
|
+
import { Element } from '../engine/reactive';
|
|
5
|
+
export type ViewportFollowProps = {
|
|
6
|
+
viewportFollow?: boolean | {
|
|
7
|
+
speed?: SignalOrPrimitive<number>;
|
|
8
|
+
acceleration?: SignalOrPrimitive<number>;
|
|
9
|
+
radius?: SignalOrPrimitive<number>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare class ViewportFollow extends Directive {
|
|
13
|
+
onInit(element: Element<ComponentInstance>): void;
|
|
14
|
+
onMount(element: Element): void;
|
|
15
|
+
onUpdate(viewportFollow: any, element: Element): void;
|
|
16
|
+
onDestroy(element: Element): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ViewportFollow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewportFollow.d.ts","sourceRoot":"","sources":["../../src/directives/ViewportFollow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C,MAAM,MAAM,mBAAmB,GAAG;IAC9B,cAAc,CAAC,EAAE,OAAO,GAAG;QACvB,KAAK,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAClC,YAAY,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;KACtC,CAAC;CACL,CAAA;AAED,qBAAa,cAAe,SAAQ,SAAS;IACzC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAG1C,OAAO,CAAC,OAAO,EAAE,OAAO;IAGxB,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO;IA2B9C,SAAS,CAAC,OAAO,EAAE,OAAO;CAK7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './ControlsBase';
|
|
2
|
+
export * from './KeyboardControls';
|
|
3
|
+
export * from './GamepadControls';
|
|
4
|
+
export * from './JoystickControls';
|
|
5
|
+
export * from './Controls';
|
|
6
|
+
export * from './Scheduler';
|
|
7
|
+
export * from './ViewportFollow';
|
|
8
|
+
export * from './Sound';
|
|
9
|
+
export * from './Drag';
|
|
10
|
+
export * from './Transition';
|
|
11
|
+
export * from './Shake';
|
|
12
|
+
export * from './Flash';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/directives/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAEhC,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Signal, WritableSignal, WritableObjectSignal } from '@signe/reactive';
|
|
2
|
+
import { Element } from './reactive';
|
|
3
|
+
import { CanvasViewport } from '../components/Viewport';
|
|
4
|
+
import { SignalOrPrimitive } from '../components/types';
|
|
5
|
+
/**
|
|
6
|
+
* Options for scroll behavior when navigating to focused elements
|
|
7
|
+
*
|
|
8
|
+
* @property padding - Padding around the element in pixels (default: 0)
|
|
9
|
+
* @property smooth - Enable smooth scrolling animation (default: false)
|
|
10
|
+
* @property center - Center the element in the viewport (default: true)
|
|
11
|
+
* @property duration - Animation duration in ms if smooth=true (default: 300)
|
|
12
|
+
*/
|
|
13
|
+
export interface ScrollOptions {
|
|
14
|
+
padding?: number;
|
|
15
|
+
smooth?: boolean;
|
|
16
|
+
center?: boolean;
|
|
17
|
+
duration?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Data structure for a focus container
|
|
21
|
+
*/
|
|
22
|
+
type WritableElementSignal = WritableSignal<Element | null> | WritableObjectSignal<Element | null>;
|
|
23
|
+
interface FocusContainerData {
|
|
24
|
+
id: string;
|
|
25
|
+
element?: Element<any>;
|
|
26
|
+
focusables: Map<number, Element<any>>;
|
|
27
|
+
currentIndex: WritableSignal<number | null>;
|
|
28
|
+
focusedElement: WritableElementSignal;
|
|
29
|
+
onFocusChange?: (index: number, element: Element | null) => void;
|
|
30
|
+
autoScroll?: boolean | ScrollOptions;
|
|
31
|
+
viewport?: CanvasViewport;
|
|
32
|
+
tabindex?: SignalOrPrimitive<number> | null;
|
|
33
|
+
tabindexSubscription?: any;
|
|
34
|
+
pendingIndex?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Central manager for focus navigation system
|
|
38
|
+
*
|
|
39
|
+
* Manages focusable elements within containers, handles navigation,
|
|
40
|
+
* and provides scroll integration with Viewport.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const manager = FocusManager.getInstance();
|
|
45
|
+
* manager.registerContainer('menu', containerData);
|
|
46
|
+
* manager.navigate('menu', 'next');
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class FocusManager {
|
|
50
|
+
private static instance;
|
|
51
|
+
private containers;
|
|
52
|
+
private scrollAnimations;
|
|
53
|
+
/**
|
|
54
|
+
* Get the singleton instance of FocusManager
|
|
55
|
+
*
|
|
56
|
+
* @returns The FocusManager instance
|
|
57
|
+
*/
|
|
58
|
+
static getInstance(): FocusManager;
|
|
59
|
+
/**
|
|
60
|
+
* Register a focus container
|
|
61
|
+
*
|
|
62
|
+
* @param id - Unique identifier for the container
|
|
63
|
+
* @param data - Container data including signals and callbacks
|
|
64
|
+
*/
|
|
65
|
+
registerContainer(id: string, data: Omit<FocusContainerData, 'id'>): void;
|
|
66
|
+
/**
|
|
67
|
+
* Update a focus container's data
|
|
68
|
+
*
|
|
69
|
+
* @param id - Container identifier
|
|
70
|
+
* @param data - Partial container data to update
|
|
71
|
+
*/
|
|
72
|
+
updateContainer(id: string, data: Partial<Omit<FocusContainerData, 'id'>>): void;
|
|
73
|
+
setTabindex(id: string, tabindex?: SignalOrPrimitive<number> | null): void;
|
|
74
|
+
/**
|
|
75
|
+
* Unregister a focus container
|
|
76
|
+
*
|
|
77
|
+
* @param id - Container identifier to remove
|
|
78
|
+
*/
|
|
79
|
+
unregisterContainer(id: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Register a focusable element in a container
|
|
82
|
+
*
|
|
83
|
+
* @param containerId - Container identifier
|
|
84
|
+
* @param element - Element to register
|
|
85
|
+
* @param index - Focus index for this element
|
|
86
|
+
*/
|
|
87
|
+
registerFocusable(containerId: string, element: Element, index: number): void;
|
|
88
|
+
/**
|
|
89
|
+
* Unregister a focusable element from a container
|
|
90
|
+
*
|
|
91
|
+
* @param containerId - Container identifier
|
|
92
|
+
* @param index - Focus index to remove
|
|
93
|
+
*/
|
|
94
|
+
unregisterFocusable(containerId: string, index: number): void;
|
|
95
|
+
/**
|
|
96
|
+
* Navigate to next or previous focusable element
|
|
97
|
+
*
|
|
98
|
+
* @param containerId - Container identifier
|
|
99
|
+
* @param direction - Navigation direction ('next' or 'previous')
|
|
100
|
+
*/
|
|
101
|
+
navigate(containerId: string, direction: 'next' | 'previous'): void;
|
|
102
|
+
/**
|
|
103
|
+
* Set the focus index for a container
|
|
104
|
+
*
|
|
105
|
+
* @param containerId - Container identifier
|
|
106
|
+
* @param index - Focus index to set
|
|
107
|
+
*/
|
|
108
|
+
setIndex(containerId: string, index: number): void;
|
|
109
|
+
private applyFocus;
|
|
110
|
+
/**
|
|
111
|
+
* Get the element at a specific index
|
|
112
|
+
*
|
|
113
|
+
* @param containerId - Container identifier
|
|
114
|
+
* @param index - Focus index
|
|
115
|
+
* @returns Element at index or null
|
|
116
|
+
*/
|
|
117
|
+
getElement(containerId: string, index: number): Element | null;
|
|
118
|
+
/**
|
|
119
|
+
* Get current focus index for a container
|
|
120
|
+
*
|
|
121
|
+
* @param containerId - Container identifier
|
|
122
|
+
* @returns Current index signal
|
|
123
|
+
*/
|
|
124
|
+
getCurrentIndexSignal(containerId: string): Signal<number | null> | null;
|
|
125
|
+
/**
|
|
126
|
+
* Get current focused element signal for a container
|
|
127
|
+
*
|
|
128
|
+
* @param containerId - Container identifier
|
|
129
|
+
* @returns Current element signal
|
|
130
|
+
*/
|
|
131
|
+
getFocusedElementSignal(containerId: string): Signal<Element | null> | null;
|
|
132
|
+
/**
|
|
133
|
+
* Check if an element is visible in the viewport
|
|
134
|
+
*
|
|
135
|
+
* @param element - Element to check
|
|
136
|
+
* @param viewport - Viewport to check against (optional)
|
|
137
|
+
* @returns True if element is visible
|
|
138
|
+
*/
|
|
139
|
+
isElementVisible(element: Element, viewport?: CanvasViewport): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Get global bounds of an element
|
|
142
|
+
*
|
|
143
|
+
* @param element - Element to get bounds for
|
|
144
|
+
* @returns Bounds object with x, y, width, height
|
|
145
|
+
*/
|
|
146
|
+
getElementBounds(element: Element): {
|
|
147
|
+
x: number;
|
|
148
|
+
y: number;
|
|
149
|
+
width: number;
|
|
150
|
+
height: number;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Scroll viewport to show an element
|
|
154
|
+
*
|
|
155
|
+
* @param containerId - Container identifier
|
|
156
|
+
* @param index - Focus index of element to scroll to
|
|
157
|
+
* @param viewport - Viewport instance (optional, uses container's viewport if not provided)
|
|
158
|
+
* @param options - Scroll options
|
|
159
|
+
*/
|
|
160
|
+
scrollToElement(containerId: string, index: number, viewport?: CanvasViewport, options?: ScrollOptions): void;
|
|
161
|
+
/**
|
|
162
|
+
* Animate smooth scrolling
|
|
163
|
+
*
|
|
164
|
+
* @param containerId - Container identifier
|
|
165
|
+
* @param viewport - Viewport instance
|
|
166
|
+
* @param targetX - Target X position
|
|
167
|
+
* @param targetY - Target Y position
|
|
168
|
+
* @param duration - Animation duration in ms
|
|
169
|
+
*/
|
|
170
|
+
private animateScroll;
|
|
171
|
+
}
|
|
172
|
+
export declare const focusManager: FocusManager;
|
|
173
|
+
export {};
|
|
174
|
+
//# sourceMappingURL=FocusManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FocusManager.d.ts","sourceRoot":"","sources":["../../src/engine/FocusManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAAE,OAAO,EAAmB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ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