canvasengine 2.0.0-beta.5 → 2.0.0-beta.51
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,248 @@
|
|
|
1
|
+
export interface TransformOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The global value of opacity (between 0 and 1)
|
|
4
|
+
*
|
|
5
|
+
* @prop {number} [opacity]
|
|
6
|
+
* @memberof Spritesheet
|
|
7
|
+
* */
|
|
8
|
+
opacity?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The global value of pivot.
|
|
11
|
+
*
|
|
12
|
+
* Invariant under rotation, scaling, and skewing. The projection of into the parent's space of the pivot is equal to position, regardless of the other three transformations. In other words, It is the center of rotation, scaling, and skewing.
|
|
13
|
+
*
|
|
14
|
+
* The array has two elements: [x, y]. If y is omitted, both x and y will be set to x.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* pivot: [0.5, 0.8]
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @prop {Array<number>} [pivot]
|
|
21
|
+
* @memberof Spritesheet
|
|
22
|
+
* */
|
|
23
|
+
pivot?: number[];
|
|
24
|
+
/**
|
|
25
|
+
* The global value of anchor.
|
|
26
|
+
*
|
|
27
|
+
* Position of the origin point
|
|
28
|
+
*
|
|
29
|
+
* The array has two elements: [x, y]. If y is omitted, both x and y will be set to x.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* anchor: [0.5, 0.8]
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @prop {Array<number>} [anchor]
|
|
36
|
+
* @memberof Spritesheet
|
|
37
|
+
* */
|
|
38
|
+
anchor?: number[];
|
|
39
|
+
/**
|
|
40
|
+
* Defines the actual size of the sprite that is inside a larger rectangle.
|
|
41
|
+
* For example, if the texture rectangle is 192x192 while the character, which is in the center, is only 64x64 then set `spriteRealSize: 64`. This way the character will be well positioned in relation to the animations that have a different rectangle
|
|
42
|
+
*
|
|
43
|
+
* > You can also put `spriteRealSize: { width: 64, height: 64 }` but be aware that the width is not concerned because it will always be centered while the height depends on the hitbox
|
|
44
|
+
*
|
|
45
|
+
* @prop {{ width: number, height: number } | number} [spriteRealSize]
|
|
46
|
+
* @since 3.2.0
|
|
47
|
+
* @memberof Spritesheet
|
|
48
|
+
* */
|
|
49
|
+
spriteRealSize?: {
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
} | number;
|
|
53
|
+
/**
|
|
54
|
+
* The global value of rotation
|
|
55
|
+
*
|
|
56
|
+
* Rotation. This will rotate the display object's projection by this angle (in radians).
|
|
57
|
+
*
|
|
58
|
+
* @prop {number} [angle]
|
|
59
|
+
* @memberof Spritesheet
|
|
60
|
+
* */
|
|
61
|
+
angle?: number;
|
|
62
|
+
/**
|
|
63
|
+
* The global value of rotation
|
|
64
|
+
*
|
|
65
|
+
* Rotation. This is an alias for rotation, but in degrees.
|
|
66
|
+
*
|
|
67
|
+
* @prop {number} [rotation]
|
|
68
|
+
* @memberof Spritesheet
|
|
69
|
+
* */
|
|
70
|
+
rotation?: number;
|
|
71
|
+
/**
|
|
72
|
+
* The global value of scale.
|
|
73
|
+
*
|
|
74
|
+
* Scaling. This will stretch (or compress) the display object's projection. The scale factors are along the local coordinate axes. In other words, the display object is scaled before rotated or skewed. The center of scaling is the pivot.
|
|
75
|
+
*
|
|
76
|
+
* The array has two elements: [x, y]. If y is omitted, both x and y will be set to x.
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* scale: [0.5, 0.8]
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @prop {Array<number>} [scale]
|
|
83
|
+
* @memberof Spritesheet
|
|
84
|
+
* */
|
|
85
|
+
scale?: number[];
|
|
86
|
+
/**
|
|
87
|
+
* The global value of skew.
|
|
88
|
+
*
|
|
89
|
+
* Skewing. This can be used to deform a rectangular display object into a parallelogram.
|
|
90
|
+
*
|
|
91
|
+
* In PixiJS, skew has a slightly different behaviour than the conventional meaning. It can be thought of the net rotation applied to the coordinate axes (separately). For example, if "skew.x" is ⍺ and "skew.y" is β, then the line x = 0 will be rotated by ⍺ (y = -x*cot⍺) and the line y = 0 will be rotated by β (y = x*tanβ). A line y = x*tanϴ (i.e. a line at angle ϴ to the x-axis in local-space) will be rotated by an angle between ⍺ and β.
|
|
92
|
+
*
|
|
93
|
+
* It can be observed that if skew is applied equally to both axes, then it will be equivalent to applying a rotation. Indeed, if "skew.x" = -ϴ and "skew.y" = ϴ, it will produce an equivalent of "rotation" = ϴ.
|
|
94
|
+
*
|
|
95
|
+
* Another quite interesting observation is that "skew.x", "skew.y", rotation are communtative operations. Indeed, because rotation is essentially a careful combination of the two.
|
|
96
|
+
*
|
|
97
|
+
* The array has two elements: [x, y]. If y is omitted, both x and y will be set to x.
|
|
98
|
+
*
|
|
99
|
+
* @prop {Array<number>} [skew]
|
|
100
|
+
* @memberof Spritesheet
|
|
101
|
+
* */
|
|
102
|
+
skew?: number[];
|
|
103
|
+
/**
|
|
104
|
+
* The global value of X translation
|
|
105
|
+
*
|
|
106
|
+
* @prop {number} [x]
|
|
107
|
+
* @memberof Spritesheet
|
|
108
|
+
* */
|
|
109
|
+
x?: number;
|
|
110
|
+
/**
|
|
111
|
+
* The global value of Y translation
|
|
112
|
+
*
|
|
113
|
+
* @prop {number} [y]
|
|
114
|
+
* @memberof Spritesheet
|
|
115
|
+
* */
|
|
116
|
+
y?: number;
|
|
117
|
+
/**
|
|
118
|
+
* The global value of visible
|
|
119
|
+
*
|
|
120
|
+
* @prop {boolean} [visible]
|
|
121
|
+
* @memberof Spritesheet
|
|
122
|
+
* */
|
|
123
|
+
visible?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Define the sound that will be played for all animations in the spritesheet. Remember to create the sound before with the @Sound decorator
|
|
126
|
+
*
|
|
127
|
+
* @prop {string} [sound]
|
|
128
|
+
* @memberof Spritesheet
|
|
129
|
+
* */
|
|
130
|
+
sound?: string;
|
|
131
|
+
}
|
|
132
|
+
export interface FrameOptions extends TransformOptions {
|
|
133
|
+
time: number;
|
|
134
|
+
frameX?: number;
|
|
135
|
+
frameY?: number;
|
|
136
|
+
}
|
|
137
|
+
export interface TextureOptions {
|
|
138
|
+
/**
|
|
139
|
+
* The number of frames on the width
|
|
140
|
+
*
|
|
141
|
+
* @prop {number} framesWidth
|
|
142
|
+
* @memberof Spritesheet
|
|
143
|
+
* */
|
|
144
|
+
framesWidth?: number;
|
|
145
|
+
/**
|
|
146
|
+
* The number of frames on the height
|
|
147
|
+
*
|
|
148
|
+
* @prop {number} framesHeight
|
|
149
|
+
* @memberof Spritesheet
|
|
150
|
+
* */
|
|
151
|
+
framesHeight?: number;
|
|
152
|
+
/**
|
|
153
|
+
* The width of the image (in pixels)
|
|
154
|
+
*
|
|
155
|
+
* @prop {number} width
|
|
156
|
+
* @memberof Spritesheet
|
|
157
|
+
* */
|
|
158
|
+
width?: number;
|
|
159
|
+
/**
|
|
160
|
+
* The height of the image (in pixels)
|
|
161
|
+
*
|
|
162
|
+
* @prop {number} height
|
|
163
|
+
* @memberof Spritesheet
|
|
164
|
+
* */
|
|
165
|
+
height?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Takes a width of a rectangle in the image. Equivalent to `width / framesWidth`
|
|
168
|
+
*
|
|
169
|
+
* @prop {number} [rectWidth]
|
|
170
|
+
* @memberof Spritesheet
|
|
171
|
+
* */
|
|
172
|
+
rectWidth?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Takes a height of a rectangle in the image. Equivalent to `height / framesHeight`
|
|
175
|
+
*
|
|
176
|
+
* @prop {number} [rectHeight]
|
|
177
|
+
* @memberof Spritesheet
|
|
178
|
+
* */
|
|
179
|
+
rectHeight?: number;
|
|
180
|
+
/**
|
|
181
|
+
* To take the texture, start at a well defined X and Y position. Otherwise, it starts at 0,0
|
|
182
|
+
*
|
|
183
|
+
* @prop {number} [offset]
|
|
184
|
+
* @memberof Spritesheet
|
|
185
|
+
* */
|
|
186
|
+
offset?: {
|
|
187
|
+
x: number;
|
|
188
|
+
y: number;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
export type AnimationFrames = FrameOptions[][] | ((...args: any) => FrameOptions[][]);
|
|
192
|
+
export interface TexturesOptions extends TextureOptions, TransformOptions {
|
|
193
|
+
animations: AnimationFrames;
|
|
194
|
+
}
|
|
195
|
+
export interface SpritesheetOptions extends TransformOptions, TextureOptions {
|
|
196
|
+
textures?: {
|
|
197
|
+
[animationName: string]: Partial<TexturesOptions> & Pick<TexturesOptions, 'animations'>;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
type SpritesheetImageOptions = SpritesheetOptions & {
|
|
201
|
+
/**
|
|
202
|
+
* The link to the image
|
|
203
|
+
*
|
|
204
|
+
* > Do not use the `images` property
|
|
205
|
+
* > Remember to wrap the link to the image with the `require` function.
|
|
206
|
+
*
|
|
207
|
+
* ```ts
|
|
208
|
+
* image: require('./assets/hero.png')
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @prop {string} [image]
|
|
212
|
+
* @memberof Spritesheet
|
|
213
|
+
* */
|
|
214
|
+
image?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Spritesheet identifier.
|
|
217
|
+
*
|
|
218
|
+
* > Do not use the `images` property
|
|
219
|
+
*
|
|
220
|
+
* @prop {string} [id]
|
|
221
|
+
* @memberof Spritesheet
|
|
222
|
+
* */
|
|
223
|
+
id: string;
|
|
224
|
+
};
|
|
225
|
+
type SpritesheetImagesOptions = SpritesheetOptions & {
|
|
226
|
+
/**
|
|
227
|
+
* Put the different images that are concerned by the properties below.
|
|
228
|
+
* The key of the object is the identifier of the spritesheet and the value and the link to the image.
|
|
229
|
+
*
|
|
230
|
+
* > Remember to wrap the link to the image with the `require` function.
|
|
231
|
+
*
|
|
232
|
+
* ```ts
|
|
233
|
+
* images: {
|
|
234
|
+
* hero: require('./assets/hero.png')
|
|
235
|
+
* }
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* @prop { { [id: string]: string } } [images]
|
|
239
|
+
* @memberof Spritesheet
|
|
240
|
+
* */
|
|
241
|
+
images?: {
|
|
242
|
+
[id: string]: string;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
export declare function Spritesheet(options: SpritesheetImageOptions): any;
|
|
246
|
+
export declare function Spritesheet(options: SpritesheetImagesOptions): any;
|
|
247
|
+
export {};
|
|
248
|
+
//# sourceMappingURL=Spritesheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spritesheet.d.ts","sourceRoot":"","sources":["../../../src/components/types/Spritesheet.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC7B;;;;;SAKK;IACL,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;;;;;;;;SAaK;IACL,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAEhB;;;;;;;;;;;;;QAaI;IACJ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IAEjB;;;;;;;;;SASK;IACL,cAAc,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAA;IAE3D;;;;;;;SAOK;IACL,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;;;;SAOK;IACL,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;;;;;;;;;;QAaI;IACJ,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAEhB;;;;;;;;;;;;;;;QAeI;IACJ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IAEf;;;;;QAKI;IACJ,CAAC,CAAC,EAAE,MAAM,CAAA;IAEV;;;;;QAKI;IACJ,CAAC,CAAC,EAAE,MAAM,CAAA;IAEV;;;;;SAKK;IACL,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;QAKI;IACJ,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IAClD,IAAI,EAAE,M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AAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;CACpC,CAAA;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,uBAAuB,OAAC;AAC7D,wBAAgB,WAAW,CAAC,OAAO,EAAE,wBAAwB,OAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Directive } from '../engine/directive';
|
|
2
|
+
import { Element } from '../engine/reactive';
|
|
3
|
+
import { Controls } from './ControlsBase';
|
|
4
|
+
import { KeyboardControls } from './KeyboardControls';
|
|
5
|
+
import { GamepadControls } from './GamepadControls';
|
|
6
|
+
import { JoystickControls } from './JoystickControls';
|
|
7
|
+
/**
|
|
8
|
+
* Controls directive that coordinates keyboard, gamepad, and joystick input systems
|
|
9
|
+
*
|
|
10
|
+
* This directive automatically activates keyboard, gamepad, and joystick controls when available.
|
|
11
|
+
* The gamepad is automatically enabled if joypad.js is detected in the environment.
|
|
12
|
+
*
|
|
13
|
+
* All systems share the same control configuration and can work simultaneously.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```html
|
|
17
|
+
* <Sprite
|
|
18
|
+
* image="path/to/image.png"
|
|
19
|
+
* controls={controlsConfig}
|
|
20
|
+
* x={x}
|
|
21
|
+
* y={y}
|
|
22
|
+
* />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class ControlsDirective extends Directive {
|
|
26
|
+
private keyboardControls;
|
|
27
|
+
private gamepadControls;
|
|
28
|
+
private joystickControls;
|
|
29
|
+
private freezeSubscription;
|
|
30
|
+
private element;
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the controls directive
|
|
33
|
+
* Sets up keyboard, gamepad, and joystick controls if available
|
|
34
|
+
*/
|
|
35
|
+
onInit(element: Element<any>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Mount hook (no specific action needed)
|
|
38
|
+
*/
|
|
39
|
+
onMount(element: Element<any>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Update controls configuration
|
|
42
|
+
* Updates both keyboard and gamepad controls
|
|
43
|
+
*/
|
|
44
|
+
onUpdate(props: any, element: Element<any>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Cleanup and destroy all control systems
|
|
47
|
+
*/
|
|
48
|
+
onDestroy(element: Element<any>): void;
|
|
49
|
+
/**
|
|
50
|
+
* Get a control by input name
|
|
51
|
+
* Delegates to keyboard controls (primary system)
|
|
52
|
+
*
|
|
53
|
+
* @param inputName - Name of the input/key
|
|
54
|
+
* @returns BoundKey if found, undefined otherwise
|
|
55
|
+
*/
|
|
56
|
+
getControl(inputName: string): import('./ControlsBase').BoundKey;
|
|
57
|
+
/**
|
|
58
|
+
* Get all bound controls
|
|
59
|
+
* Delegates to keyboard controls (primary system)
|
|
60
|
+
*
|
|
61
|
+
* @returns Object mapping input names to BoundKey objects
|
|
62
|
+
*/
|
|
63
|
+
getControls(): {
|
|
64
|
+
[key: string]: import('./ControlsBase').BoundKey;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Apply a control action programmatically
|
|
68
|
+
* Applies to both keyboard and gamepad if available
|
|
69
|
+
*
|
|
70
|
+
* @param controlName - Name of the control
|
|
71
|
+
* @param isDown - Whether the control is pressed (true) or released (false)
|
|
72
|
+
* @param payload - Optional payload to pass to keyDown/keyUp callbacks (e.g., { power: 0.8 })
|
|
73
|
+
* @returns Promise that resolves when the action is complete
|
|
74
|
+
*/
|
|
75
|
+
applyControl(controlName: string | number, isDown?: boolean, payload?: any): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Stop listening to inputs
|
|
78
|
+
* Stops keyboard, gamepad, and joystick input processing
|
|
79
|
+
*/
|
|
80
|
+
stopInputs(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Resume listening to inputs
|
|
83
|
+
* Resumes keyboard, gamepad, and joystick input processing
|
|
84
|
+
*/
|
|
85
|
+
listenInputs(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Get the current controls configuration
|
|
88
|
+
* Returns keyboard controls options (both systems share the same config)
|
|
89
|
+
*
|
|
90
|
+
* @returns The controls options object
|
|
91
|
+
*/
|
|
92
|
+
get options(): Controls;
|
|
93
|
+
/**
|
|
94
|
+
* Get the keyboard controls instance
|
|
95
|
+
*
|
|
96
|
+
* @returns KeyboardControls instance or null
|
|
97
|
+
*/
|
|
98
|
+
get keyboard(): KeyboardControls | null;
|
|
99
|
+
/**
|
|
100
|
+
* Get the gamepad controls instance
|
|
101
|
+
*
|
|
102
|
+
* @returns GamepadControls instance or null
|
|
103
|
+
*/
|
|
104
|
+
get gamepad(): GamepadControls | null;
|
|
105
|
+
/**
|
|
106
|
+
* Get the joystick controls instance
|
|
107
|
+
*
|
|
108
|
+
* @returns JoystickControls instance or null
|
|
109
|
+
*/
|
|
110
|
+
get joystick(): JoystickControls | null;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=Controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Controls.d.ts","sourceRoot":"","sources":["../../src/directives/Controls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAmB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAgB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAiB,MAAM,mBAA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|
+
bind: string | string[];
|
|
4
|
+
keyUp?: Function;
|
|
5
|
+
keyDown?: Function;
|
|
6
|
+
throttle?: number;
|
|
7
|
+
delay?: number | {
|
|
8
|
+
duration: number;
|
|
9
|
+
otherControls?: (string)[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface Controls {
|
|
13
|
+
[controlName: string]: ControlOptions;
|
|
14
|
+
}
|
|
15
|
+
export type BoundKey = {
|
|
16
|
+
actionName: string;
|
|
17
|
+
options: ControlOptions;
|
|
18
|
+
parameters?: any;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Abstract base class for control systems (keyboard, gamepad, etc.)
|
|
22
|
+
*
|
|
23
|
+
* This class provides common functionality shared across all control implementations:
|
|
24
|
+
* - Input binding and management
|
|
25
|
+
* - Control configuration
|
|
26
|
+
* - Input state management
|
|
27
|
+
* - Common methods for querying and triggering controls
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* class MyControls extends ControlsBase {
|
|
32
|
+
* protected setupListeners() {
|
|
33
|
+
* // Setup specific input listeners
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* protected cleanup() {
|
|
37
|
+
* // Cleanup specific resources
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* protected preStep() {
|
|
41
|
+
* // Process inputs each frame
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare abstract class ControlsBase {
|
|
47
|
+
protected boundKeys: {
|
|
48
|
+
[keyName: string]: BoundKey;
|
|
49
|
+
};
|
|
50
|
+
protected stop: boolean;
|
|
51
|
+
protected _controlsOptions: Controls;
|
|
52
|
+
protected interval: any;
|
|
53
|
+
protected serverFps: number;
|
|
54
|
+
/**
|
|
55
|
+
* Setup input listeners specific to this control implementation
|
|
56
|
+
* Must be implemented by subclasses
|
|
57
|
+
*/
|
|
58
|
+
protected abstract setupListeners(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Cleanup resources specific to this control implementation
|
|
61
|
+
* Must be implemented by subclasses
|
|
62
|
+
*/
|
|
63
|
+
protected abstract cleanup(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Process inputs each step/frame
|
|
66
|
+
* Must be implemented by subclasses
|
|
67
|
+
*/
|
|
68
|
+
protected abstract preStep(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Start the control processing loop
|
|
71
|
+
* Initializes listeners and starts the interval
|
|
72
|
+
*/
|
|
73
|
+
start(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Stop the control processing and cleanup resources
|
|
76
|
+
*/
|
|
77
|
+
destroy(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Bind a key/input to a control action
|
|
80
|
+
*
|
|
81
|
+
* @param keys - Single key or array of keys to bind
|
|
82
|
+
* @param actionName - Name of the control action
|
|
83
|
+
* @param options - Control options (repeat, keyDown, keyUp, etc.)
|
|
84
|
+
* @param parameters - Optional parameters to pass to the control callbacks
|
|
85
|
+
*/
|
|
86
|
+
protected bindKey(keys: string | string[], actionName: string, options: ControlOptions, parameters?: object): void;
|
|
87
|
+
/**
|
|
88
|
+
* Apply an input action for a bound key
|
|
89
|
+
* Can be overridden by subclasses for custom behavior
|
|
90
|
+
*
|
|
91
|
+
* @param keyName - Name of the key/input to process
|
|
92
|
+
*/
|
|
93
|
+
protected applyInput(keyName: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* Get a control by input name
|
|
96
|
+
*
|
|
97
|
+
* @param inputName - Name of the input/key
|
|
98
|
+
* @returns BoundKey if found, undefined otherwise
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* const control = controls.getControl('up');
|
|
102
|
+
* if (control) {
|
|
103
|
+
* console.log(control.actionName); // 'up'
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
getControl(inputName: string): BoundKey | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Get all bound controls
|
|
110
|
+
*
|
|
111
|
+
* @returns Object mapping input names to BoundKey objects
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const allControls = controls.getControls();
|
|
115
|
+
* console.log(Object.keys(allControls)); // ['up', 'down', 'left', 'right', ...]
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
getControls(): {
|
|
119
|
+
[key: string]: BoundKey;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Apply a control action programmatically
|
|
123
|
+
*
|
|
124
|
+
* Must be implemented by subclasses to provide input-specific behavior
|
|
125
|
+
*
|
|
126
|
+
* @param controlName - Name or identifier of the control
|
|
127
|
+
* @param isDown - Whether the control is pressed down (true) or released (false)
|
|
128
|
+
* @returns Promise that resolves when the control action is complete
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* // Press a control
|
|
132
|
+
* await controls.applyControl('action', true);
|
|
133
|
+
*
|
|
134
|
+
* // Release a control
|
|
135
|
+
* await controls.applyControl('action', false);
|
|
136
|
+
*
|
|
137
|
+
* // Press and release (default)
|
|
138
|
+
* await controls.applyControl('action');
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
abstract applyControl(controlName: string | number, isDown?: boolean): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Stop listening to inputs
|
|
144
|
+
* Input events will be ignored until listenInputs() is called
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* controls.stopInputs();
|
|
149
|
+
* // ... later
|
|
150
|
+
* controls.listenInputs();
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
stopInputs(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Resume listening to inputs after stopInputs() was called
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* controls.stopInputs();
|
|
160
|
+
* // ... later
|
|
161
|
+
* controls.listenInputs();
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
listenInputs(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Configure controls with input mappings
|
|
167
|
+
*
|
|
168
|
+
* This method sets up the binding between input keys/buttons and control actions.
|
|
169
|
+
* It clears existing bindings and creates new ones based on the provided configuration.
|
|
170
|
+
*
|
|
171
|
+
* @param inputs - Control configuration object
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* controls.setInputs({
|
|
175
|
+
* up: {
|
|
176
|
+
* repeat: true,
|
|
177
|
+
* bind: 'up',
|
|
178
|
+
* keyDown() {
|
|
179
|
+
* console.log('Up pressed');
|
|
180
|
+
* }
|
|
181
|
+
* },
|
|
182
|
+
* action: {
|
|
183
|
+
* bind: ['space', 'enter'],
|
|
184
|
+
* keyDown() {
|
|
185
|
+
* console.log('Action triggered');
|
|
186
|
+
* }
|
|
187
|
+
* }
|
|
188
|
+
* });
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
setInputs(inputs: Controls): void;
|
|
192
|
+
/**
|
|
193
|
+
* Get the current controls configuration
|
|
194
|
+
*
|
|
195
|
+
* @returns The controls options object
|
|
196
|
+
*/
|
|
197
|
+
get options(): Controls;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=ControlsBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControlsBase.d.ts","sourceRoot":"","sources":["../../src/directives/ControlsBase.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC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Q,CAAA;KAAE;IAI1C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAEpF;;;;;;;;;;OAUG;IACH,UAAU;IAIV;;;;;;;;;OASG;IACH,YAAY;IAIZ;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,SAAS,CAAC,MAAM,EAAE,QAAQ;IAiB1B;;;;OAIG;IACH,IAAI,OAAO,IAAI,QAAQ,CAEtB;CACJ"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Container, FederatedPointerEvent } from 'pixi.js';
|
|
2
|
+
import { Directive } from '../engine/directive';
|
|
3
|
+
import { Element } from '../engine/reactive';
|
|
4
|
+
import { SignalOrPrimitive } from '../components/types';
|
|
5
|
+
export type DragProps = {
|
|
6
|
+
move?: (event: FederatedPointerEvent) => void;
|
|
7
|
+
start?: () => void;
|
|
8
|
+
end?: () => void;
|
|
9
|
+
snap?: SignalOrPrimitive<number>;
|
|
10
|
+
direction?: SignalOrPrimitive<'x' | 'y' | 'all'>;
|
|
11
|
+
keyToPress?: SignalOrPrimitive<string[]>;
|
|
12
|
+
viewport?: {
|
|
13
|
+
edgeThreshold?: SignalOrPrimitive<number>;
|
|
14
|
+
maxSpeed?: SignalOrPrimitive<number>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare class Drop extends Directive {
|
|
18
|
+
private elementRef;
|
|
19
|
+
onInit(element: Element<Container>): void;
|
|
20
|
+
onMount(element: Element<Container>): void;
|
|
21
|
+
onUpdate(): void;
|
|
22
|
+
onDestroy(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare class Drag extends Directive {
|
|
25
|
+
private elementRef;
|
|
26
|
+
private stageRef;
|
|
27
|
+
private offsetInParent;
|
|
28
|
+
private isDragging;
|
|
29
|
+
private viewport;
|
|
30
|
+
private animationFrameId;
|
|
31
|
+
private lastPointerPosition;
|
|
32
|
+
private pressedKeys;
|
|
33
|
+
private pointerIsDown;
|
|
34
|
+
private onDragMoveHandler;
|
|
35
|
+
private onDragEndHandler;
|
|
36
|
+
private onDragStartHandler;
|
|
37
|
+
private onKeyDownHandler;
|
|
38
|
+
private onKeyUpHandler;
|
|
39
|
+
private subscriptions;
|
|
40
|
+
onInit(element: Element<Container>): void;
|
|
41
|
+
onMount(element: Element<Container>): void;
|
|
42
|
+
get dragProps(): any;
|
|
43
|
+
get axis(): {
|
|
44
|
+
x: boolean;
|
|
45
|
+
y: boolean;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Updates element position when dragging and starts continuous viewport movement
|
|
49
|
+
* @param event The pointer event that triggered the drag move
|
|
50
|
+
*/
|
|
51
|
+
private onDragMove;
|
|
52
|
+
/**
|
|
53
|
+
* Moves the viewport if the dragged element is near screen edges
|
|
54
|
+
* @param globalPosition The global pointer position
|
|
55
|
+
*/
|
|
56
|
+
private updateViewportPosition;
|
|
57
|
+
/**
|
|
58
|
+
* Handles drag end event and stops viewport movement
|
|
59
|
+
*/
|
|
60
|
+
private onDragEnd;
|
|
61
|
+
onKeyDown(event: KeyboardEvent): void;
|
|
62
|
+
onKeyUp(event: KeyboardEvent): void;
|
|
63
|
+
private areRequiredKeysPressed;
|
|
64
|
+
private onPointerDown;
|
|
65
|
+
private startDrag;
|
|
66
|
+
onUpdate(props: any): void;
|
|
67
|
+
onDestroy(): void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=Drag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drag.d.ts","sourceRoot":"","sources":["../../src/directives/Drag.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAoB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,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