@energy8platform/game-engine 0.15.0 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +29 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +29 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/react-jsx.d.ts +68 -48
- package/dist/react.cjs.js +29 -19
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.d.ts +600 -1
- package/dist/react.esm.js +29 -19
- package/dist/react.esm.js.map +1 -1
- package/dist/ui.cjs.js +29 -19
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.esm.js +29 -19
- package/dist/ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/react/index.ts +6 -0
- package/src/react/jsx-runtime.ts +102 -57
- package/src/ui/FlexContainer.ts +29 -19
package/dist/react.d.ts
CHANGED
|
@@ -1,8 +1,607 @@
|
|
|
1
|
-
import { Container, ApplicationOptions, Application } from 'pixi.js';
|
|
1
|
+
import { Texture, Container, TextStyle, ColorSource, ApplicationOptions, Application } from 'pixi.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactElement } from 'react';
|
|
4
4
|
import { CasinoGameSDK, InitData, GameConfigData, SessionData } from '@energy8platform/game-sdk';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Universal view input type for UI component visual slots.
|
|
8
|
+
*
|
|
9
|
+
* - `string` — texture name, resolved via `Sprite.from()`
|
|
10
|
+
* - `Texture` — wrapped in a `Sprite`
|
|
11
|
+
* - `Container` — used as-is (Sprite, Graphics, NineSliceSprite, AnimatedSprite, custom...)
|
|
12
|
+
*/
|
|
13
|
+
type ViewInput = string | Texture | Container;
|
|
14
|
+
|
|
15
|
+
type ButtonState = 'default' | 'hover' | 'pressed' | 'disabled';
|
|
16
|
+
interface ButtonConfig {
|
|
17
|
+
/** Custom view for default state (string texture name, Texture, or Container) */
|
|
18
|
+
defaultView?: ViewInput;
|
|
19
|
+
/** Custom view for hover state */
|
|
20
|
+
hoverView?: ViewInput;
|
|
21
|
+
/** Custom view for pressed state */
|
|
22
|
+
pressedView?: ViewInput;
|
|
23
|
+
/** Custom view for disabled state */
|
|
24
|
+
disabledView?: ViewInput;
|
|
25
|
+
/** Width (for Graphics-based button, ignored when custom views provided) */
|
|
26
|
+
width?: number;
|
|
27
|
+
/** Height (for Graphics-based button) */
|
|
28
|
+
height?: number;
|
|
29
|
+
/** Corner radius (for Graphics-based button) */
|
|
30
|
+
borderRadius?: number;
|
|
31
|
+
/** Colors for each state (for Graphics-based button) */
|
|
32
|
+
colors?: Partial<Record<ButtonState, number>>;
|
|
33
|
+
/** Scale on press */
|
|
34
|
+
pressScale?: number;
|
|
35
|
+
/** Scale animation duration (ms) */
|
|
36
|
+
animationDuration?: number;
|
|
37
|
+
/** Start disabled */
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** Button text (rendered on top of the view) */
|
|
40
|
+
text?: string;
|
|
41
|
+
/** Button text style */
|
|
42
|
+
textStyle?: Record<string, unknown>;
|
|
43
|
+
/** Press callback */
|
|
44
|
+
onPress?: () => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface LabelConfig {
|
|
48
|
+
text?: string;
|
|
49
|
+
style?: Partial<TextStyle>;
|
|
50
|
+
/** Maximum width — text will be scaled down to fit */
|
|
51
|
+
maxWidth?: number;
|
|
52
|
+
/** Auto-fit: scale text to fit maxWidth */
|
|
53
|
+
autoFit?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type FlexDirection = 'row' | 'column';
|
|
57
|
+
type JustifyContent = 'start' | 'center' | 'end' | 'space-between' | 'space-around';
|
|
58
|
+
type AlignItems = 'start' | 'center' | 'end' | 'stretch';
|
|
59
|
+
type AlignContent = 'start' | 'center' | 'end' | 'space-between' | 'stretch';
|
|
60
|
+
type AlignSelf = 'auto' | 'start' | 'center' | 'end' | 'stretch';
|
|
61
|
+
interface FlexContainerConfig {
|
|
62
|
+
/** Layout direction (default: 'row') */
|
|
63
|
+
direction?: FlexDirection;
|
|
64
|
+
/** Main-axis distribution (default: 'start') */
|
|
65
|
+
justifyContent?: JustifyContent;
|
|
66
|
+
/** Cross-axis alignment (default: 'start') */
|
|
67
|
+
alignItems?: AlignItems;
|
|
68
|
+
/** Gap between children in pixels (default: 0) */
|
|
69
|
+
gap?: number;
|
|
70
|
+
/** Padding [top, right, bottom, left] or single number (default: 0) */
|
|
71
|
+
padding?: number | [number, number, number, number];
|
|
72
|
+
/** Individual padding overrides (take priority over `padding`) */
|
|
73
|
+
paddingTop?: number;
|
|
74
|
+
paddingRight?: number;
|
|
75
|
+
paddingBottom?: number;
|
|
76
|
+
paddingLeft?: number;
|
|
77
|
+
/** Enable wrapping to next line (default: false) */
|
|
78
|
+
flexWrap?: boolean;
|
|
79
|
+
/** Distribution of lines along the cross axis when wrapping (default: 'start') */
|
|
80
|
+
alignContent?: AlignContent;
|
|
81
|
+
/** Maximum width before wrapping (only with flexWrap) */
|
|
82
|
+
maxWidth?: number;
|
|
83
|
+
/** Maximum height before wrapping (only with flexWrap + column) */
|
|
84
|
+
maxHeight?: number;
|
|
85
|
+
/** Explicit container width — number in pixels, or string percentage (e.g. "50%") resolved against parent */
|
|
86
|
+
width?: number | string;
|
|
87
|
+
/** Explicit container height — number in pixels, or string percentage (e.g. "50%") resolved against parent */
|
|
88
|
+
height?: number | string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type LabelValueAlign = 'start' | 'center' | 'end';
|
|
92
|
+
interface LabelValueConfig {
|
|
93
|
+
/** Caption text (top row, typically smaller/muted) */
|
|
94
|
+
label?: string;
|
|
95
|
+
/** Value text (bottom row, typically larger/prominent) */
|
|
96
|
+
value?: string;
|
|
97
|
+
/** Style for the caption Label */
|
|
98
|
+
labelStyle?: Partial<TextStyle>;
|
|
99
|
+
/** Style for the value Label */
|
|
100
|
+
valueStyle?: Partial<TextStyle>;
|
|
101
|
+
/** Gap in pixels between caption and value (default: 4) */
|
|
102
|
+
gap?: number;
|
|
103
|
+
/** Horizontal alignment of both rows (default: 'center') */
|
|
104
|
+
align?: LabelValueAlign;
|
|
105
|
+
/** Maximum width — value will be auto-scaled to fit when exceeded */
|
|
106
|
+
maxWidth?: number;
|
|
107
|
+
/** Optional padding (forwarded to the underlying FlexContainer) */
|
|
108
|
+
padding?: FlexContainerConfig['padding'];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface PanelConfig {
|
|
112
|
+
/** Width */
|
|
113
|
+
width?: number;
|
|
114
|
+
/** Height */
|
|
115
|
+
height?: number;
|
|
116
|
+
/** Background color (for Graphics-based panel) */
|
|
117
|
+
backgroundColor?: number;
|
|
118
|
+
/** Background alpha */
|
|
119
|
+
backgroundAlpha?: number;
|
|
120
|
+
/** Corner radius */
|
|
121
|
+
borderRadius?: number;
|
|
122
|
+
/** Border color */
|
|
123
|
+
borderColor?: number;
|
|
124
|
+
/** Border width */
|
|
125
|
+
borderWidth?: number;
|
|
126
|
+
/** 9-slice texture (if provided, uses NineSliceSprite instead of Graphics) */
|
|
127
|
+
nineSliceTexture?: string | Texture;
|
|
128
|
+
/** 9-slice borders [left, top, right, bottom] */
|
|
129
|
+
nineSliceBorders?: [number, number, number, number];
|
|
130
|
+
/** Padding inside the panel */
|
|
131
|
+
padding?: number;
|
|
132
|
+
/** Flex layout config for content */
|
|
133
|
+
layout?: Partial<FlexContainerConfig>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface ProgressBarConfig {
|
|
137
|
+
/** Width of the bar */
|
|
138
|
+
width?: number;
|
|
139
|
+
/** Height of the bar */
|
|
140
|
+
height?: number;
|
|
141
|
+
/** Corner radius (for Graphics-based bar) */
|
|
142
|
+
borderRadius?: number;
|
|
143
|
+
/** Fill color (for Graphics-based bar, ignored when fillView provided) */
|
|
144
|
+
fillColor?: number;
|
|
145
|
+
/** Track background color (for Graphics-based bar, ignored when trackView provided) */
|
|
146
|
+
trackColor?: number;
|
|
147
|
+
/** Border color */
|
|
148
|
+
borderColor?: number;
|
|
149
|
+
/** Border width */
|
|
150
|
+
borderWidth?: number;
|
|
151
|
+
/** Animated fill (smoothly interpolate) */
|
|
152
|
+
animated?: boolean;
|
|
153
|
+
/** Animation speed (0..1 per frame, default: 0.1) */
|
|
154
|
+
animationSpeed?: number;
|
|
155
|
+
/** Custom track background (string texture name, Texture, or Container) */
|
|
156
|
+
trackView?: ViewInput;
|
|
157
|
+
/** Custom fill bar (string texture name, Texture, or Container) */
|
|
158
|
+
fillView?: ViewInput;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
type ScrollDirection = 'vertical' | 'horizontal' | 'both';
|
|
162
|
+
interface ScrollContainerConfig {
|
|
163
|
+
/** Visible viewport width */
|
|
164
|
+
width: number;
|
|
165
|
+
/** Visible viewport height */
|
|
166
|
+
height: number;
|
|
167
|
+
/** Scroll direction (default: 'vertical') */
|
|
168
|
+
direction?: ScrollDirection;
|
|
169
|
+
/** Background color (undefined = transparent) */
|
|
170
|
+
backgroundColor?: ColorSource;
|
|
171
|
+
/** Border radius for the mask (default: 0) */
|
|
172
|
+
borderRadius?: number;
|
|
173
|
+
/** Gap between items (default: 0) */
|
|
174
|
+
elementsMargin?: number;
|
|
175
|
+
/** Padding */
|
|
176
|
+
padding?: number;
|
|
177
|
+
/** Disable easing/inertia */
|
|
178
|
+
disableEasing?: boolean;
|
|
179
|
+
/** Show scrollbar indicator (default: false) */
|
|
180
|
+
scrollbar?: boolean;
|
|
181
|
+
/** Custom scrollbar thumb view (string texture name, Texture, or Container) */
|
|
182
|
+
thumbView?: ViewInput;
|
|
183
|
+
/** Scrollbar width in px (default: 6) */
|
|
184
|
+
scrollbarWidth?: number;
|
|
185
|
+
/** Scrollbar padding from edge (default: 4) */
|
|
186
|
+
scrollbarPadding?: number;
|
|
187
|
+
/** Scrollbar color (when no thumbView, default: 0xaaaaaa) */
|
|
188
|
+
scrollbarColor?: number;
|
|
189
|
+
/** Scrollbar alpha (default: 0.5) */
|
|
190
|
+
scrollbarAlpha?: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface ModalConfig {
|
|
194
|
+
/** Overlay color */
|
|
195
|
+
overlayColor?: number;
|
|
196
|
+
/** Overlay alpha */
|
|
197
|
+
overlayAlpha?: number;
|
|
198
|
+
/** Close on overlay tap */
|
|
199
|
+
closeOnOverlay?: boolean;
|
|
200
|
+
/** Animation duration */
|
|
201
|
+
animationDuration?: number;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
interface ToastConfig {
|
|
205
|
+
/** Auto-dismiss after this many ms (0 = manual dismiss only) */
|
|
206
|
+
duration?: number;
|
|
207
|
+
/** Toast position from bottom */
|
|
208
|
+
bottomOffset?: number;
|
|
209
|
+
/** Custom background view (string texture name, Texture, or Container). Sized to fit text. */
|
|
210
|
+
backgroundView?: ViewInput;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
interface BalanceDisplayConfig {
|
|
214
|
+
/** Label prefix (e.g., "BALANCE") */
|
|
215
|
+
prefix?: string;
|
|
216
|
+
/** Text style overrides */
|
|
217
|
+
style?: Record<string, unknown>;
|
|
218
|
+
/** Currency code */
|
|
219
|
+
currency?: string;
|
|
220
|
+
/** Locale for number formatting */
|
|
221
|
+
locale?: string;
|
|
222
|
+
/** Max width */
|
|
223
|
+
maxWidth?: number;
|
|
224
|
+
/** Animate value changes */
|
|
225
|
+
animated?: boolean;
|
|
226
|
+
/** Animation duration in ms */
|
|
227
|
+
animationDuration?: number;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
interface WinDisplayConfig {
|
|
231
|
+
/** Text style overrides */
|
|
232
|
+
style?: Record<string, unknown>;
|
|
233
|
+
/** Currency code */
|
|
234
|
+
currency?: string;
|
|
235
|
+
/** Locale for number formatting */
|
|
236
|
+
locale?: string;
|
|
237
|
+
/** Countup duration in ms */
|
|
238
|
+
countupDuration?: number;
|
|
239
|
+
/** Scale pop animation on win */
|
|
240
|
+
popScale?: number;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
type LayoutDirection = 'horizontal' | 'vertical' | 'grid' | 'wrap';
|
|
244
|
+
type LayoutAlignment = 'start' | 'center' | 'end' | 'stretch';
|
|
245
|
+
type LayoutAnchor = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
246
|
+
interface LayoutConfig {
|
|
247
|
+
/** Layout direction (default: 'vertical') */
|
|
248
|
+
direction?: LayoutDirection;
|
|
249
|
+
/** Gap between children in pixels (default: 0) */
|
|
250
|
+
gap?: number;
|
|
251
|
+
/** Padding inside the layout container [top, right, bottom, left] or a single number */
|
|
252
|
+
padding?: number | [number, number, number, number];
|
|
253
|
+
/** Alignment of children on the cross axis (default: 'start') */
|
|
254
|
+
alignment?: LayoutAlignment;
|
|
255
|
+
/** Anchor point determining where the layout is positioned relative to its coordinates */
|
|
256
|
+
anchor?: LayoutAnchor;
|
|
257
|
+
/** Number of columns (only for 'grid' direction) */
|
|
258
|
+
columns?: number;
|
|
259
|
+
/** Maximum width for 'wrap' direction before wrapping to next line */
|
|
260
|
+
maxWidth?: number;
|
|
261
|
+
/** Whether to auto-layout when children change (default: true) */
|
|
262
|
+
autoLayout?: boolean;
|
|
263
|
+
/** Breakpoints: map of max viewport widths to override configs */
|
|
264
|
+
breakpoints?: Record<number, Partial<LayoutConfig>>;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
interface SliderConfig {
|
|
268
|
+
/** Minimum value (default: 0) */
|
|
269
|
+
min?: number;
|
|
270
|
+
/** Maximum value (default: 1) */
|
|
271
|
+
max?: number;
|
|
272
|
+
/** Step increment (0 = continuous, default: 0) */
|
|
273
|
+
step?: number;
|
|
274
|
+
/** Initial value (default: min) */
|
|
275
|
+
value?: number;
|
|
276
|
+
/** Track width in pixels (default: 200) */
|
|
277
|
+
width?: number;
|
|
278
|
+
/** Track height in pixels (default: 8) */
|
|
279
|
+
height?: number;
|
|
280
|
+
/** Corner radius for Graphics-based track/fill (default: 4) */
|
|
281
|
+
borderRadius?: number;
|
|
282
|
+
/** Track background color (ignored when trackView provided) */
|
|
283
|
+
trackColor?: number;
|
|
284
|
+
/** Fill bar color (ignored when fillView provided) */
|
|
285
|
+
fillColor?: number;
|
|
286
|
+
/** Handle radius (for Graphics-based handle, default: 12) */
|
|
287
|
+
handleRadius?: number;
|
|
288
|
+
/** Handle color (for Graphics-based handle, ignored when handleView provided) */
|
|
289
|
+
handleColor?: number;
|
|
290
|
+
/** Custom track background view */
|
|
291
|
+
trackView?: ViewInput;
|
|
292
|
+
/** Custom fill bar view */
|
|
293
|
+
fillView?: ViewInput;
|
|
294
|
+
/** Custom handle view */
|
|
295
|
+
handleView?: ViewInput;
|
|
296
|
+
/** Called when value changes during drag */
|
|
297
|
+
onUpdate?: (value: number) => void;
|
|
298
|
+
/** Called when drag ends */
|
|
299
|
+
onChange?: (value: number) => void;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface ToggleConfig {
|
|
303
|
+
/** Initial state (default: false) */
|
|
304
|
+
value?: boolean;
|
|
305
|
+
/** Custom view for the ON state */
|
|
306
|
+
onView?: ViewInput;
|
|
307
|
+
/** Custom view for the OFF state */
|
|
308
|
+
offView?: ViewInput;
|
|
309
|
+
/** Width (for Graphics-based toggle, default: 52) */
|
|
310
|
+
width?: number;
|
|
311
|
+
/** Height (for Graphics-based toggle, default: 28) */
|
|
312
|
+
height?: number;
|
|
313
|
+
/** Track color when ON (ignored when custom views provided) */
|
|
314
|
+
onColor?: number;
|
|
315
|
+
/** Track color when OFF (ignored when custom views provided) */
|
|
316
|
+
offColor?: number;
|
|
317
|
+
/** Handle color (for Graphics-based toggle) */
|
|
318
|
+
handleColor?: number;
|
|
319
|
+
/** Handle radius (for Graphics-based toggle, default: auto) */
|
|
320
|
+
handleRadius?: number;
|
|
321
|
+
/** Animation duration in ms (default: 200) */
|
|
322
|
+
animationDuration?: number;
|
|
323
|
+
/** Called when value changes */
|
|
324
|
+
onChange?: (value: boolean) => void;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* JSX prop types for the PixiJS React reconciler.
|
|
329
|
+
*
|
|
330
|
+
* The engine auto-augments `react`'s module-scoped `JSX.IntrinsicElements`
|
|
331
|
+
* with every registered element (`<flexContainer>`, `<button>`, `<label>`,
|
|
332
|
+
* `<labelValue>`, etc). Because the augmentation is scoped to the `react`
|
|
333
|
+
* module (not the legacy global `JSX` namespace), it reliably wins over
|
|
334
|
+
* `@types/react`'s HTML defaults for colliding names like `<button>` / `<label>`.
|
|
335
|
+
*
|
|
336
|
+
* **Consumers don't need any shim.** Any import from `@energy8platform/game-engine/react`
|
|
337
|
+
* (e.g. `createPixiRoot`, `extendUIElements`, `ReactScene` — you're already
|
|
338
|
+
* importing these to boot the reconciler) pulls this module in and the JSX
|
|
339
|
+
* types activate automatically.
|
|
340
|
+
*
|
|
341
|
+
* If a project imports only from `/ui` or `/core` and never touches `/react`,
|
|
342
|
+
* add a one-line side-effect import to trigger the augmentation:
|
|
343
|
+
*
|
|
344
|
+
* ```ts
|
|
345
|
+
* // app/src/pixi-jsx.d.ts
|
|
346
|
+
* import '@energy8platform/game-engine/react-jsx';
|
|
347
|
+
* ```
|
|
348
|
+
*
|
|
349
|
+
* Dash-notation for nested config objects is supported:
|
|
350
|
+
* <button colors-default={0xff0000} colors-hover={0x00ff00} />
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
interface PixiEventProps {
|
|
354
|
+
onClick?: (e: any) => void;
|
|
355
|
+
onPointerDown?: (e: any) => void;
|
|
356
|
+
onPointerUp?: (e: any) => void;
|
|
357
|
+
onPointerMove?: (e: any) => void;
|
|
358
|
+
onPointerOver?: (e: any) => void;
|
|
359
|
+
onPointerOut?: (e: any) => void;
|
|
360
|
+
onPointerEnter?: (e: any) => void;
|
|
361
|
+
onPointerLeave?: (e: any) => void;
|
|
362
|
+
onPointerCancel?: (e: any) => void;
|
|
363
|
+
onPointerTap?: (e: any) => void;
|
|
364
|
+
onPointerUpOutside?: (e: any) => void;
|
|
365
|
+
onMouseDown?: (e: any) => void;
|
|
366
|
+
onMouseUp?: (e: any) => void;
|
|
367
|
+
onMouseMove?: (e: any) => void;
|
|
368
|
+
onMouseOver?: (e: any) => void;
|
|
369
|
+
onMouseOut?: (e: any) => void;
|
|
370
|
+
onWheel?: (e: any) => void;
|
|
371
|
+
onTap?: (e: any) => void;
|
|
372
|
+
onRightClick?: (e: any) => void;
|
|
373
|
+
}
|
|
374
|
+
interface BaseProps extends PixiEventProps {
|
|
375
|
+
key?: React.Key;
|
|
376
|
+
ref?: React.Ref<any>;
|
|
377
|
+
children?: React.ReactNode;
|
|
378
|
+
x?: number;
|
|
379
|
+
y?: number;
|
|
380
|
+
width?: number;
|
|
381
|
+
height?: number;
|
|
382
|
+
alpha?: number;
|
|
383
|
+
visible?: boolean;
|
|
384
|
+
rotation?: number;
|
|
385
|
+
angle?: number;
|
|
386
|
+
zIndex?: number;
|
|
387
|
+
label?: string;
|
|
388
|
+
cursor?: string;
|
|
389
|
+
eventMode?: 'auto' | 'none' | 'passive' | 'static' | 'dynamic';
|
|
390
|
+
'scale-x'?: number;
|
|
391
|
+
'scale-y'?: number;
|
|
392
|
+
'pivot-x'?: number;
|
|
393
|
+
'pivot-y'?: number;
|
|
394
|
+
'position-x'?: number;
|
|
395
|
+
'position-y'?: number;
|
|
396
|
+
'anchor-x'?: number;
|
|
397
|
+
'anchor-y'?: number;
|
|
398
|
+
scale?: number | {
|
|
399
|
+
x: number;
|
|
400
|
+
y: number;
|
|
401
|
+
};
|
|
402
|
+
flexGrow?: number;
|
|
403
|
+
flexShrink?: number;
|
|
404
|
+
layoutWidth?: number | string;
|
|
405
|
+
layoutHeight?: number | string;
|
|
406
|
+
alignSelf?: AlignSelf;
|
|
407
|
+
flexExclude?: boolean;
|
|
408
|
+
top?: number;
|
|
409
|
+
right?: number;
|
|
410
|
+
bottom?: number;
|
|
411
|
+
left?: number;
|
|
412
|
+
/** X coordinate of the visual center within parent (px or `'50%'`). Overrides left/right. */
|
|
413
|
+
centerX?: number | string;
|
|
414
|
+
/** Y coordinate of the visual center within parent (px or `'50%'`). Overrides top/bottom. */
|
|
415
|
+
centerY?: number | string;
|
|
416
|
+
}
|
|
417
|
+
interface SpriteProps extends BaseProps {
|
|
418
|
+
texture?: string | Texture;
|
|
419
|
+
anchor?: number | {
|
|
420
|
+
x: number;
|
|
421
|
+
y: number;
|
|
422
|
+
};
|
|
423
|
+
tint?: number;
|
|
424
|
+
}
|
|
425
|
+
interface TextProps extends BaseProps {
|
|
426
|
+
text?: string;
|
|
427
|
+
style?: Partial<TextStyle>;
|
|
428
|
+
anchor?: number | {
|
|
429
|
+
x: number;
|
|
430
|
+
y: number;
|
|
431
|
+
};
|
|
432
|
+
'style-fontSize'?: number;
|
|
433
|
+
'style-fill'?: number | string;
|
|
434
|
+
'style-fontFamily'?: string;
|
|
435
|
+
'style-fontWeight'?: string;
|
|
436
|
+
'style-letterSpacing'?: number;
|
|
437
|
+
}
|
|
438
|
+
interface GraphicsProps extends BaseProps {
|
|
439
|
+
/** Draw function: receives the Graphics instance, called on mount and updates */
|
|
440
|
+
draw?: (g: any) => void;
|
|
441
|
+
/**
|
|
442
|
+
* Layout size hint (pixels). For Graphics, `width`/`height` do NOT apply a scale
|
|
443
|
+
* transform (unlike Container.width). They're forwarded to the parent
|
|
444
|
+
* FlexContainer as `layoutWidth`/`layoutHeight` so layout measures the element
|
|
445
|
+
* at the requested size while the actual geometry stays in the `draw` callback.
|
|
446
|
+
*/
|
|
447
|
+
width?: number;
|
|
448
|
+
height?: number;
|
|
449
|
+
}
|
|
450
|
+
interface AnimatedSpriteProps extends BaseProps {
|
|
451
|
+
textures?: Texture[];
|
|
452
|
+
animationSpeed?: number;
|
|
453
|
+
loop?: boolean;
|
|
454
|
+
playing?: boolean;
|
|
455
|
+
}
|
|
456
|
+
interface NineSliceSpriteProps extends BaseProps {
|
|
457
|
+
texture?: string | Texture;
|
|
458
|
+
leftWidth?: number;
|
|
459
|
+
topHeight?: number;
|
|
460
|
+
rightWidth?: number;
|
|
461
|
+
bottomHeight?: number;
|
|
462
|
+
}
|
|
463
|
+
interface TilingSpriteProps extends BaseProps {
|
|
464
|
+
texture?: string | Texture;
|
|
465
|
+
tilePosition?: {
|
|
466
|
+
x: number;
|
|
467
|
+
y: number;
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
interface ButtonComponentProps extends BaseProps, Omit<ButtonConfig, 'colors' | 'textStyle'> {
|
|
471
|
+
colors?: Partial<Record<ButtonState, number>>;
|
|
472
|
+
textStyle?: Record<string, unknown>;
|
|
473
|
+
defaultView?: ViewInput;
|
|
474
|
+
hoverView?: ViewInput;
|
|
475
|
+
pressedView?: ViewInput;
|
|
476
|
+
disabledView?: ViewInput;
|
|
477
|
+
'colors-default'?: number;
|
|
478
|
+
'colors-hover'?: number;
|
|
479
|
+
'colors-pressed'?: number;
|
|
480
|
+
'colors-disabled'?: number;
|
|
481
|
+
'textStyle-fontSize'?: number;
|
|
482
|
+
'textStyle-fill'?: number | string;
|
|
483
|
+
'textStyle-fontFamily'?: string;
|
|
484
|
+
'textStyle-fontWeight'?: string;
|
|
485
|
+
'textStyle-fontStyle'?: string;
|
|
486
|
+
'textStyle-letterSpacing'?: number;
|
|
487
|
+
onPress?: () => void;
|
|
488
|
+
}
|
|
489
|
+
interface LabelComponentProps extends BaseProps, Omit<LabelConfig, 'style'> {
|
|
490
|
+
style?: Partial<TextStyle>;
|
|
491
|
+
'style-fontSize'?: number;
|
|
492
|
+
'style-fill'?: number | string;
|
|
493
|
+
'style-fontFamily'?: string;
|
|
494
|
+
'style-fontWeight'?: string;
|
|
495
|
+
'style-letterSpacing'?: number;
|
|
496
|
+
}
|
|
497
|
+
interface LabelValueComponentProps extends Omit<BaseProps, 'width' | 'height' | 'label'>, Omit<LabelValueConfig, 'labelStyle' | 'valueStyle'> {
|
|
498
|
+
labelStyle?: Partial<TextStyle>;
|
|
499
|
+
valueStyle?: Partial<TextStyle>;
|
|
500
|
+
width?: number | string;
|
|
501
|
+
height?: number | string;
|
|
502
|
+
'labelStyle-fontSize'?: number;
|
|
503
|
+
'labelStyle-fill'?: number | string;
|
|
504
|
+
'labelStyle-fontFamily'?: string;
|
|
505
|
+
'labelStyle-fontWeight'?: string;
|
|
506
|
+
'valueStyle-fontSize'?: number;
|
|
507
|
+
'valueStyle-fill'?: number | string;
|
|
508
|
+
'valueStyle-fontFamily'?: string;
|
|
509
|
+
'valueStyle-fontWeight'?: string;
|
|
510
|
+
}
|
|
511
|
+
interface PanelComponentProps extends BaseProps, Omit<PanelConfig, 'layout'> {
|
|
512
|
+
layout?: Partial<FlexContainerConfig>;
|
|
513
|
+
}
|
|
514
|
+
interface FlexContainerComponentProps extends Omit<BaseProps, 'width' | 'height'>, FlexContainerConfig {
|
|
515
|
+
padding?: number | [number, number, number, number];
|
|
516
|
+
paddingTop?: number;
|
|
517
|
+
paddingRight?: number;
|
|
518
|
+
paddingBottom?: number;
|
|
519
|
+
paddingLeft?: number;
|
|
520
|
+
alignContent?: AlignContent;
|
|
521
|
+
width?: number | string;
|
|
522
|
+
height?: number | string;
|
|
523
|
+
}
|
|
524
|
+
interface ProgressBarComponentProps extends BaseProps, ProgressBarConfig {
|
|
525
|
+
progress?: number;
|
|
526
|
+
/** Custom track background (string texture name, Texture, or Container) */
|
|
527
|
+
trackView?: ViewInput;
|
|
528
|
+
/** Custom fill bar */
|
|
529
|
+
fillView?: ViewInput;
|
|
530
|
+
}
|
|
531
|
+
interface ScrollContainerComponentProps extends BaseProps, Omit<ScrollContainerConfig, 'width' | 'height'> {
|
|
532
|
+
width: number;
|
|
533
|
+
height: number;
|
|
534
|
+
/** Show scrollbar indicator */
|
|
535
|
+
scrollbar?: boolean;
|
|
536
|
+
/** Custom scrollbar thumb view */
|
|
537
|
+
thumbView?: ViewInput;
|
|
538
|
+
scrollbarWidth?: number;
|
|
539
|
+
scrollbarPadding?: number;
|
|
540
|
+
scrollbarColor?: number;
|
|
541
|
+
scrollbarAlpha?: number;
|
|
542
|
+
}
|
|
543
|
+
interface ModalComponentProps extends BaseProps, ModalConfig {
|
|
544
|
+
onClose?: () => void;
|
|
545
|
+
}
|
|
546
|
+
interface ToastComponentProps extends BaseProps, ToastConfig {
|
|
547
|
+
/** Custom background view */
|
|
548
|
+
backgroundView?: ViewInput;
|
|
549
|
+
}
|
|
550
|
+
interface BalanceDisplayComponentProps extends BaseProps, BalanceDisplayConfig {
|
|
551
|
+
/** Current balance value */
|
|
552
|
+
value?: number;
|
|
553
|
+
}
|
|
554
|
+
interface WinDisplayComponentProps extends BaseProps, WinDisplayConfig {
|
|
555
|
+
}
|
|
556
|
+
interface LayoutComponentProps extends BaseProps, LayoutConfig {
|
|
557
|
+
}
|
|
558
|
+
interface SliderComponentProps extends BaseProps, Omit<SliderConfig, 'width' | 'height'> {
|
|
559
|
+
width?: number;
|
|
560
|
+
height?: number;
|
|
561
|
+
onUpdate?: (value: number) => void;
|
|
562
|
+
onChange?: (value: number) => void;
|
|
563
|
+
}
|
|
564
|
+
interface ToggleComponentProps extends BaseProps, Omit<ToggleConfig, 'width' | 'height'> {
|
|
565
|
+
width?: number;
|
|
566
|
+
height?: number;
|
|
567
|
+
onView?: ViewInput;
|
|
568
|
+
offView?: ViewInput;
|
|
569
|
+
onChange?: (value: boolean) => void;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Complete element → prop-type map for all engine-registered JSX elements.
|
|
573
|
+
* Also consumable directly for typing custom wrappers around engine elements.
|
|
574
|
+
*/
|
|
575
|
+
interface EngineIntrinsicElements {
|
|
576
|
+
container: BaseProps;
|
|
577
|
+
sprite: SpriteProps;
|
|
578
|
+
text: TextProps;
|
|
579
|
+
graphics: GraphicsProps;
|
|
580
|
+
animatedSprite: AnimatedSpriteProps;
|
|
581
|
+
nineSliceSprite: NineSliceSpriteProps;
|
|
582
|
+
tilingSprite: TilingSpriteProps;
|
|
583
|
+
button: ButtonComponentProps;
|
|
584
|
+
label: LabelComponentProps;
|
|
585
|
+
labelValue: LabelValueComponentProps;
|
|
586
|
+
panel: PanelComponentProps;
|
|
587
|
+
flexContainer: FlexContainerComponentProps;
|
|
588
|
+
progressBar: ProgressBarComponentProps;
|
|
589
|
+
scrollContainer: ScrollContainerComponentProps;
|
|
590
|
+
modal: ModalComponentProps;
|
|
591
|
+
toast: ToastComponentProps;
|
|
592
|
+
balanceDisplay: BalanceDisplayComponentProps;
|
|
593
|
+
winDisplay: WinDisplayComponentProps;
|
|
594
|
+
layout: LayoutComponentProps;
|
|
595
|
+
slider: SliderComponentProps;
|
|
596
|
+
toggle: ToggleComponentProps;
|
|
597
|
+
}
|
|
598
|
+
declare module 'react' {
|
|
599
|
+
namespace JSX {
|
|
600
|
+
interface IntrinsicElements extends EngineIntrinsicElements {
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
6
605
|
interface PixiRoot {
|
|
7
606
|
render(element: ReactElement): void;
|
|
8
607
|
unmount(): void;
|
package/dist/react.esm.js
CHANGED
|
@@ -312,24 +312,29 @@ function measureChild(child, parentContentW = 0, parentContentH = 0) {
|
|
|
312
312
|
const cfg = child._flexConfig;
|
|
313
313
|
const resolvedLW = resolveDimension(cfg?.layoutWidth, parentContentW);
|
|
314
314
|
const resolvedLH = resolveDimension(cfg?.layoutHeight, parentContentH);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
// For FlexContainers, use their explicit or computed size
|
|
315
|
+
// FlexContainer children are top-left origin by construction, so `ox/oy = 0`
|
|
316
|
+
// is correct and we can skip the `getLocalBounds()` call entirely.
|
|
319
317
|
if (child instanceof FlexContainer) {
|
|
320
318
|
const fc = child;
|
|
321
319
|
const w = fc._explicitWidth > 0 ? fc._explicitWidth : (fc._computedWidth > 0 ? fc._computedWidth : undefined);
|
|
322
320
|
const h = fc._explicitHeight > 0 ? fc._explicitHeight : (fc._computedHeight > 0 ? fc._computedHeight : undefined);
|
|
323
321
|
if (w !== undefined && h !== undefined) {
|
|
324
|
-
return { w, h, ox: 0, oy: 0 };
|
|
322
|
+
return { w: resolvedLW ?? w, h: resolvedLH ?? h, ox: 0, oy: 0 };
|
|
325
323
|
}
|
|
326
324
|
}
|
|
327
|
-
// Use localBounds to get the true visual
|
|
328
|
-
//
|
|
325
|
+
// Use localBounds to get the true visual origin offset.
|
|
326
|
+
// We take `ox/oy` from bounds unconditionally — a user-supplied `layoutWidth/Height`
|
|
327
|
+
// overrides the SIZE used by flex (protection against pre-paint bounds of 0), but
|
|
328
|
+
// it must NOT erase the center-anchor compensation: Button/Label views are drawn at
|
|
329
|
+
// `(-w/2..w/2)` and their bounds.x = -w/2 is what lets `layoutLine` place the
|
|
330
|
+
// visible rectangle where the layout intends.
|
|
329
331
|
const bounds = child.getLocalBounds();
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
332
|
+
return {
|
|
333
|
+
w: resolvedLW ?? bounds.width,
|
|
334
|
+
h: resolvedLH ?? bounds.height,
|
|
335
|
+
ox: bounds.x,
|
|
336
|
+
oy: bounds.y,
|
|
337
|
+
};
|
|
333
338
|
}
|
|
334
339
|
/**
|
|
335
340
|
* Set a child's main or cross dimension.
|
|
@@ -818,30 +823,35 @@ class FlexContainer extends Container {
|
|
|
818
823
|
this._computedHeight = this._explicitHeight > 0 ? this._explicitHeight : (pt + naturalMainSize + pb);
|
|
819
824
|
}
|
|
820
825
|
// Position flexExclude children (absolute positioning).
|
|
821
|
-
// All position props describe the visual (bounds) rectangle
|
|
822
|
-
//
|
|
826
|
+
// All position props describe the visual (bounds) rectangle. We derive the
|
|
827
|
+
// visual rectangle directly from `getLocalBounds()` rather than the
|
|
828
|
+
// layout-config `w`/`h` returned by measureChild — those may differ from
|
|
829
|
+
// actual bounds when the user pins `layoutWidth`/`layoutHeight` to a value
|
|
830
|
+
// that doesn't match the child's real visual extent (e.g. a Button whose
|
|
831
|
+
// text overflows its configured `width`). Mixing layout size with real
|
|
832
|
+
// bounds-origin would shift the visual center off the requested point.
|
|
823
833
|
// `centerX/centerY` take precedence over `left/right` / `top/bottom` on each axis.
|
|
824
834
|
for (const child of this._layoutChildren) {
|
|
825
835
|
if (!child._flexConfig?.flexExclude)
|
|
826
836
|
continue;
|
|
827
837
|
const cfg = child._flexConfig;
|
|
828
|
-
const
|
|
838
|
+
const bounds = child.getLocalBounds();
|
|
829
839
|
const cw = this._computedWidth;
|
|
830
840
|
const ch = this._computedHeight;
|
|
831
841
|
const centerX = resolveDimension(cfg.centerX, pctRefW);
|
|
832
842
|
if (centerX !== undefined)
|
|
833
|
-
child.x = centerX -
|
|
843
|
+
child.x = centerX - bounds.x - bounds.width / 2;
|
|
834
844
|
else if (cfg.left !== undefined)
|
|
835
|
-
child.x = cfg.left -
|
|
845
|
+
child.x = cfg.left - bounds.x;
|
|
836
846
|
else if (cfg.right !== undefined)
|
|
837
|
-
child.x = cw -
|
|
847
|
+
child.x = cw - cfg.right - bounds.x - bounds.width;
|
|
838
848
|
const centerY = resolveDimension(cfg.centerY, pctRefH);
|
|
839
849
|
if (centerY !== undefined)
|
|
840
|
-
child.y = centerY -
|
|
850
|
+
child.y = centerY - bounds.y - bounds.height / 2;
|
|
841
851
|
else if (cfg.top !== undefined)
|
|
842
|
-
child.y = cfg.top -
|
|
852
|
+
child.y = cfg.top - bounds.y;
|
|
843
853
|
else if (cfg.bottom !== undefined)
|
|
844
|
-
child.y = ch -
|
|
854
|
+
child.y = ch - cfg.bottom - bounds.y - bounds.height;
|
|
845
855
|
}
|
|
846
856
|
}
|
|
847
857
|
/** Computed content size (after layout) */
|