canvasengine 2.0.0-beta.6 → 2.0.0-beta.61
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/DebugRenderer-DkjTAc48.js +1384 -0
- package/dist/DebugRenderer-DkjTAc48.js.map +1 -0
- 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/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/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/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/Text.d.ts +24 -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/index.d.ts +20 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/types/DisplayObject.d.ts +118 -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/FogVisibility.d.ts +47 -0
- package/dist/directives/FogVisibility.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 +36 -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 +14 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/dist-BOOc43Qm.js +778 -0
- package/dist/dist-BOOc43Qm.js.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 +52 -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 +135 -0
- package/dist/engine/reactive.d.ts.map +1 -0
- package/dist/engine/signal.d.ts +73 -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.d.ts +19 -1107
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +8 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +14708 -3135
- 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 +16 -9
- package/src/components/Button.ts +399 -0
- package/src/components/Canvas.ts +82 -51
- 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 +422 -201
- package/src/components/FocusContainer.ts +368 -0
- package/src/components/Graphic.ts +239 -73
- 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 +418 -52
- package/src/components/Text.ts +270 -26
- package/src/components/Viewport.ts +122 -63
- package/src/components/index.ts +9 -2
- package/src/components/types/DisplayObject.ts +53 -5
- 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/FogVisibility.ts +273 -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 +21 -5
- 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 +13 -6
- package/src/engine/FocusManager.ts +510 -0
- package/src/engine/animation.ts +175 -21
- package/src/engine/bootstrap.ts +140 -6
- package/src/engine/directive.ts +4 -4
- package/src/engine/reactive.ts +980 -177
- package/src/engine/signal.ts +241 -47
- 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,224 @@
|
|
|
1
|
+
import { ControlsBase, Controls } from './ControlsBase';
|
|
2
|
+
import { WritableSignal } from '@signe/reactive';
|
|
3
|
+
/**
|
|
4
|
+
* Gamepad configuration interface
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const gamepadConfig: GamepadConfig = {
|
|
9
|
+
* enabled: true,
|
|
10
|
+
* buttonMapping: {
|
|
11
|
+
* 'button_0': 'action',
|
|
12
|
+
* 'button_1': 'back'
|
|
13
|
+
* },
|
|
14
|
+
* axisMapping: {
|
|
15
|
+
* 'top': 'up',
|
|
16
|
+
* 'bottom': 'down',
|
|
17
|
+
* 'left': 'left',
|
|
18
|
+
* 'right': 'right'
|
|
19
|
+
* },
|
|
20
|
+
* moveInterval: 400,
|
|
21
|
+
* onConnect: () => console.log('Gamepad connected!'),
|
|
22
|
+
* onDisconnect: () => console.log('Gamepad disconnected!')
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export interface GamepadConfig {
|
|
27
|
+
/** Whether gamepad is enabled (default: true) */
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/** Mapping of gamepad button names to control names */
|
|
30
|
+
buttonMapping?: {
|
|
31
|
+
[buttonName: string]: string;
|
|
32
|
+
};
|
|
33
|
+
/** Mapping of axis directions to control directions */
|
|
34
|
+
axisMapping?: {
|
|
35
|
+
[axisDirection: string]: string;
|
|
36
|
+
};
|
|
37
|
+
/** Threshold for axis movement detection (default: 0.5) */
|
|
38
|
+
axisThreshold?: number;
|
|
39
|
+
/** Interval in milliseconds for repeating movement actions (default: 400) */
|
|
40
|
+
moveInterval?: number;
|
|
41
|
+
/** Callback called when a gamepad is connected */
|
|
42
|
+
onConnect?: () => void;
|
|
43
|
+
/** Callback called when a gamepad is disconnected */
|
|
44
|
+
onDisconnect?: () => void;
|
|
45
|
+
/** Signal that tracks gamepad connection status (optional) */
|
|
46
|
+
gamepadConnected?: WritableSignal<boolean>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Gamepad input controls implementation
|
|
50
|
+
*
|
|
51
|
+
* Handles gamepad input events using joypad.js library and maps them to control actions.
|
|
52
|
+
* Supports button presses and analog stick movement with configurable mappings.
|
|
53
|
+
*
|
|
54
|
+
* The gamepad controls are automatically activated when joypad.js is available and enabled.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const gamepadControls = new GamepadControls();
|
|
59
|
+
* gamepadControls.setInputs({
|
|
60
|
+
* up: {
|
|
61
|
+
* repeat: true,
|
|
62
|
+
* bind: 'up',
|
|
63
|
+
* keyDown() {
|
|
64
|
+
* console.log('Up pressed');
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* });
|
|
68
|
+
* gamepadControls.updateGamepadConfig({
|
|
69
|
+
* enabled: true,
|
|
70
|
+
* buttonMapping: {
|
|
71
|
+
* 'button_0': 'action'
|
|
72
|
+
* }
|
|
73
|
+
* });
|
|
74
|
+
* gamepadControls.start();
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare class GamepadControls extends ControlsBase {
|
|
78
|
+
private gamepadEnabled;
|
|
79
|
+
private gamepadConfig;
|
|
80
|
+
private gamepadMoving;
|
|
81
|
+
private gamepadDirections;
|
|
82
|
+
private gamepadAxisDate;
|
|
83
|
+
private gamepadMoveInterval;
|
|
84
|
+
private joypad;
|
|
85
|
+
private connectCallbacks;
|
|
86
|
+
private disconnectCallbacks;
|
|
87
|
+
private currentPower;
|
|
88
|
+
/**
|
|
89
|
+
* Setup gamepad event listeners
|
|
90
|
+
* Initializes joypad.js if available
|
|
91
|
+
*/
|
|
92
|
+
protected setupListeners(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Cleanup gamepad event listeners and intervals
|
|
95
|
+
*/
|
|
96
|
+
protected cleanup(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Initialize joypad.js library if available
|
|
99
|
+
*/
|
|
100
|
+
private initGamepad;
|
|
101
|
+
/**
|
|
102
|
+
* Handle gamepad connection event
|
|
103
|
+
*/
|
|
104
|
+
private handleGamepadConnect;
|
|
105
|
+
/**
|
|
106
|
+
* Handle gamepad disconnection event
|
|
107
|
+
*/
|
|
108
|
+
private handleGamepadDisconnect;
|
|
109
|
+
/**
|
|
110
|
+
* Handle gamepad button press event
|
|
111
|
+
*
|
|
112
|
+
* @param e - Button press event from joypad.js
|
|
113
|
+
*/
|
|
114
|
+
private handleGamepadButtonPress;
|
|
115
|
+
/**
|
|
116
|
+
* Handle gamepad axis movement event
|
|
117
|
+
*
|
|
118
|
+
* @param e - Axis move event from joypad.js
|
|
119
|
+
*/
|
|
120
|
+
private handleGamepadAxisMove;
|
|
121
|
+
/**
|
|
122
|
+
* Process continuous gamepad movement
|
|
123
|
+
* Called at intervals to repeat movement actions while axes are active
|
|
124
|
+
*/
|
|
125
|
+
private processGamepadMovement;
|
|
126
|
+
/**
|
|
127
|
+
* Process gamepad inputs each step
|
|
128
|
+
* Handles timeout for stopping movements after axis inactivity
|
|
129
|
+
*/
|
|
130
|
+
protected preStep(): void;
|
|
131
|
+
/**
|
|
132
|
+
* Update gamepad configuration
|
|
133
|
+
* Merges provided config with defaults
|
|
134
|
+
* Automatically registers callbacks from config
|
|
135
|
+
*
|
|
136
|
+
* @param config - Partial gamepad configuration
|
|
137
|
+
*/
|
|
138
|
+
updateGamepadConfig(config: Partial<GamepadConfig>): void;
|
|
139
|
+
/**
|
|
140
|
+
* Extract gamepad config from controls configuration and update
|
|
141
|
+
* Note: Callbacks are stored but not automatically registered, they should be registered in mount()
|
|
142
|
+
*
|
|
143
|
+
* @param inputs - Controls configuration that may contain a 'gamepad' property
|
|
144
|
+
*/
|
|
145
|
+
extractGamepadConfig(inputs: Controls & {
|
|
146
|
+
gamepad?: GamepadConfig;
|
|
147
|
+
}): void;
|
|
148
|
+
/**
|
|
149
|
+
* Get the current gamepad configuration
|
|
150
|
+
*
|
|
151
|
+
* @returns The gamepad configuration object
|
|
152
|
+
*/
|
|
153
|
+
getGamepadConfig(): GamepadConfig;
|
|
154
|
+
/**
|
|
155
|
+
* Apply a control action programmatically
|
|
156
|
+
* Uses the bound controls to trigger actions
|
|
157
|
+
*
|
|
158
|
+
* @param controlName - Name of the control
|
|
159
|
+
* @param isDown - Whether the control is pressed (true) or released (false)
|
|
160
|
+
* @param payload - Optional payload to pass to keyDown/keyUp callbacks (e.g., { power: 0.8 })
|
|
161
|
+
* @returns Promise that resolves when the action is complete
|
|
162
|
+
*/
|
|
163
|
+
applyControl(controlName: string | number, isDown?: boolean, payload?: any): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Override setInputs to extract gamepad config
|
|
166
|
+
*/
|
|
167
|
+
setInputs(inputs: Controls & {
|
|
168
|
+
gamepad?: GamepadConfig;
|
|
169
|
+
}): void;
|
|
170
|
+
/**
|
|
171
|
+
* Register a callback to be called when a gamepad is connected
|
|
172
|
+
*
|
|
173
|
+
* @param callback - Function to call when gamepad connects
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* gamepadControls.onConnect(() => {
|
|
177
|
+
* console.log('Gamepad connected!');
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
onConnect(callback: () => void): void;
|
|
182
|
+
/**
|
|
183
|
+
* Register a callback to be called when a gamepad is disconnected
|
|
184
|
+
*
|
|
185
|
+
* @param callback - Function to call when gamepad disconnects
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* gamepadControls.onDisconnect(() => {
|
|
189
|
+
* console.log('Gamepad disconnected!');
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
onDisconnect(callback: () => void): void;
|
|
194
|
+
/**
|
|
195
|
+
* Remove a connect callback
|
|
196
|
+
*
|
|
197
|
+
* @param callback - Callback to remove
|
|
198
|
+
*/
|
|
199
|
+
offConnect(callback: () => void): void;
|
|
200
|
+
/**
|
|
201
|
+
* Remove a disconnect callback
|
|
202
|
+
*
|
|
203
|
+
* @param callback - Callback to remove
|
|
204
|
+
*/
|
|
205
|
+
offDisconnect(callback: () => void): void;
|
|
206
|
+
/**
|
|
207
|
+
* Check if gamepad is currently connected
|
|
208
|
+
*
|
|
209
|
+
* @returns true if gamepad is connected, false otherwise
|
|
210
|
+
*/
|
|
211
|
+
isConnected(): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Reinitialize gamepad listeners
|
|
214
|
+
* Useful if joypad.js becomes available after initialization
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* // If joypad.js loads later
|
|
219
|
+
* gamepadControls.reinit();
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
reinit(): void;
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=GamepadControls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GamepadControls.d.ts","sourceRoot":"","sources":["../../src/directives/GamepadControls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,WAAW,CAAA;AAElB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,aAAa;IAC1B,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,aAAa,CAAC,EAAE;QACZ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;KAChC,CAAC;IACF,uDAAuD;IACvD,WAAW,CAAC,EAAE;QACV,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;KACnC,CAAC;IACF,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,cAAc,CAAC,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sDhG;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG;QAAE,OAAO,CAAC,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI;IAK/D;;;;;;;;;;OAUG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIrC;;;;;;;;;;OAUG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIxC;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAOtC;;;;OAIG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAOzC;;;;OAIG;IACH,WAAW,IAAI,OAAO;IAItB;;;;;;;;;OASG;IACH,MAAM,IAAI,IAAI;CAKjB"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { ControlsBase, Controls } from './ControlsBase';
|
|
2
|
+
/**
|
|
3
|
+
* Joystick directions reported by the Joystick component
|
|
4
|
+
*/
|
|
5
|
+
export type JoystickDirection = 'left' | 'right' | 'top' | 'bottom' | 'top_left' | 'top_right' | 'bottom_left' | 'bottom_right';
|
|
6
|
+
/**
|
|
7
|
+
* Joystick change event payload
|
|
8
|
+
*/
|
|
9
|
+
export interface JoystickChangeEvent {
|
|
10
|
+
angle: number;
|
|
11
|
+
direction: JoystickDirection;
|
|
12
|
+
power: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Joystick configuration interface
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const joystickConfig: JoystickConfig = {
|
|
20
|
+
* enabled: true,
|
|
21
|
+
* directionMapping: {
|
|
22
|
+
* 'top': 'up',
|
|
23
|
+
* 'bottom': 'down',
|
|
24
|
+
* 'left': 'left',
|
|
25
|
+
* 'right': 'right',
|
|
26
|
+
* 'top_left': ['up', 'left'],
|
|
27
|
+
* 'top_right': ['up', 'right'],
|
|
28
|
+
* 'bottom_left': ['down', 'left'],
|
|
29
|
+
* 'bottom_right': ['down', 'right']
|
|
30
|
+
* },
|
|
31
|
+
* moveInterval: 50,
|
|
32
|
+
* threshold: 0.1
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export interface JoystickConfig {
|
|
37
|
+
/** Whether joystick is enabled (default: true) */
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
/** Mapping of joystick direction names to control names (can be single string or array for diagonals) */
|
|
40
|
+
directionMapping?: {
|
|
41
|
+
[joystickDirection: string]: string | string[];
|
|
42
|
+
};
|
|
43
|
+
/** Interval in milliseconds for repeating movement actions (default: 50) */
|
|
44
|
+
moveInterval?: number;
|
|
45
|
+
/** Threshold for power value to trigger movement (default: 0.1) */
|
|
46
|
+
threshold?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Joystick input controls implementation
|
|
50
|
+
*
|
|
51
|
+
* Handles joystick input events from the Joystick component and maps them to control actions.
|
|
52
|
+
* Supports directional movement with configurable mappings, including diagonal directions.
|
|
53
|
+
*
|
|
54
|
+
* The joystick controls work by receiving change events from a Joystick component instance.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const joystickControls = new JoystickControls();
|
|
59
|
+
* joystickControls.setInputs({
|
|
60
|
+
* up: {
|
|
61
|
+
* repeat: true,
|
|
62
|
+
* bind: 'up',
|
|
63
|
+
* keyDown() {
|
|
64
|
+
* console.log('Up pressed');
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* });
|
|
68
|
+
* joystickControls.updateJoystickConfig({
|
|
69
|
+
* enabled: true,
|
|
70
|
+
* directionMapping: {
|
|
71
|
+
* 'top': 'up'
|
|
72
|
+
* }
|
|
73
|
+
* });
|
|
74
|
+
* joystickControls.start();
|
|
75
|
+
*
|
|
76
|
+
* // Later, when joystick changes:
|
|
77
|
+
* joystickControls.handleJoystickChange({ angle: 90, direction: Direction.TOP, power: 0.8 });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare class JoystickControls extends ControlsBase {
|
|
81
|
+
private joystickEnabled;
|
|
82
|
+
private joystickConfig;
|
|
83
|
+
private joystickMoving;
|
|
84
|
+
private joystickDirections;
|
|
85
|
+
private joystickLastUpdate;
|
|
86
|
+
private joystickMoveInterval;
|
|
87
|
+
private currentPower;
|
|
88
|
+
/**
|
|
89
|
+
* Setup joystick event listeners
|
|
90
|
+
* Note: Joystick events are handled via handleJoystickChange() method
|
|
91
|
+
*/
|
|
92
|
+
protected setupListeners(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Cleanup joystick intervals
|
|
95
|
+
*/
|
|
96
|
+
protected cleanup(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Process joystick inputs each step
|
|
99
|
+
* Continuous actions are handled by the interval; no inactivity timeout here.
|
|
100
|
+
*/
|
|
101
|
+
protected preStep(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Handle joystick change event
|
|
104
|
+
* Called by the Joystick component when its position changes
|
|
105
|
+
*
|
|
106
|
+
* @param event - Joystick change event containing angle, direction, and power
|
|
107
|
+
*/
|
|
108
|
+
handleJoystickChange(event: JoystickChangeEvent): void;
|
|
109
|
+
/**
|
|
110
|
+
* Handle joystick start event
|
|
111
|
+
* Called when user starts interacting with the joystick
|
|
112
|
+
*/
|
|
113
|
+
handleJoystickStart(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Handle joystick end event
|
|
116
|
+
* Called when user stops interacting with the joystick
|
|
117
|
+
*/
|
|
118
|
+
handleJoystickEnd(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Stop all active joystick movements
|
|
121
|
+
*/
|
|
122
|
+
private stopAllMovements;
|
|
123
|
+
/**
|
|
124
|
+
* Process continuous joystick movement
|
|
125
|
+
* Called at intervals to repeat movement actions while joystick is active
|
|
126
|
+
*/
|
|
127
|
+
private processJoystickMovement;
|
|
128
|
+
/**
|
|
129
|
+
* Update joystick configuration
|
|
130
|
+
* Merges provided config with defaults
|
|
131
|
+
*
|
|
132
|
+
* @param config - Partial joystick configuration
|
|
133
|
+
*/
|
|
134
|
+
updateJoystickConfig(config: Partial<JoystickConfig>): void;
|
|
135
|
+
/**
|
|
136
|
+
* Extract joystick config from controls configuration and update
|
|
137
|
+
*
|
|
138
|
+
* @param inputs - Controls configuration that may contain a 'joystick' property
|
|
139
|
+
*/
|
|
140
|
+
extractJoystickConfig(inputs: Controls & {
|
|
141
|
+
joystick?: JoystickConfig;
|
|
142
|
+
}): void;
|
|
143
|
+
/**
|
|
144
|
+
* Get the current joystick configuration
|
|
145
|
+
*
|
|
146
|
+
* @returns The joystick configuration object
|
|
147
|
+
*/
|
|
148
|
+
getJoystickConfig(): JoystickConfig;
|
|
149
|
+
/**
|
|
150
|
+
* Apply a control action programmatically
|
|
151
|
+
* Uses the bound controls to trigger actions
|
|
152
|
+
*
|
|
153
|
+
* @param controlName - Name of the control
|
|
154
|
+
* @param isDown - Whether the control is pressed (true) or released (false)
|
|
155
|
+
* @returns Promise that resolves when the action is complete
|
|
156
|
+
*/
|
|
157
|
+
applyControl(controlName: string | number, isDown?: boolean, payload?: any): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Override setInputs to extract joystick config
|
|
160
|
+
*/
|
|
161
|
+
setInputs(inputs: Controls & {
|
|
162
|
+
joystick?: JoystickConfig;
|
|
163
|
+
}): void;
|
|
164
|
+
/**
|
|
165
|
+
* Check if joystick is currently active
|
|
166
|
+
*
|
|
167
|
+
* @returns true if joystick is moving, false otherwise
|
|
168
|
+
*/
|
|
169
|
+
isActive(): boolean;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=JoystickControls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JoystickControls.d.ts","sourceRoot":"","sources":["../../src/directives/JoystickControls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,g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IAKzB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;IAS3D;;;;OAIG;IACH,qBAAqB,CAAC,MAAM,EAAE,QAAQ,GAAG;QAAE,QAAQ,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IAM7E;;;;OAIG;IACH,iBAAiB,IAAI,cAAc;IAInC;;;;;;;OAOG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAsDhG;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG;QAAE,QAAQ,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IAKjE;;;;OAIG;IACH,QAAQ,IAAI,OAAO;CAGtB"}
|
|
@@ -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,oBA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IAChC,SAAS,MAAM;IACf,KAAK,UAAU;CAClB;AAGD,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAmLnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;IAC9C,OAAO,CAAC,QAAQ,CAKV;IACN,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,eAAe,CAA6B;IACpD,OAAO,CAAC,cAAc,CAUhB;IAEN;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;IAKhC;;OAEG;IACH,SAAS,CAAC,OAAO,IAAI,IAAI;IAKzB;;OAEG;IACH,SAAS,CAAC,OAAO;IAsBjB;;;OAGG;IACH,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM;IAiCpC,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,WAAW;IAgCnB,OAAO,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,36 @@
|
|
|
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 running;
|
|
19
|
+
private tick;
|
|
20
|
+
onInit(element: Element): void;
|
|
21
|
+
onDestroy(): void;
|
|
22
|
+
onMount(element: Element): void;
|
|
23
|
+
onUpdate(props: any): void;
|
|
24
|
+
nextTick(timestamp: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* start the schedule
|
|
27
|
+
* @return {Scheduler} returns this scheduler instance
|
|
28
|
+
*/
|
|
29
|
+
start(options?: {
|
|
30
|
+
maxFps?: number;
|
|
31
|
+
fps?: number;
|
|
32
|
+
delay?: number;
|
|
33
|
+
}): this;
|
|
34
|
+
stop(): void;
|
|
35
|
+
}
|
|
36
|
+
//# 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,OAAO,CAAiB;IAChC,OAAO,CAAC,IAAI,CAA6B;IAEzC,MAAM,CAAC,OAAO,EAAE,OAAO;IAIvB,SAAS;IAGT,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;IA+CN,IAAI;CAIP"}
|