@energy8platform/game-engine 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/host.d.ts +3 -5
  2. package/dist/index.cjs.js +0 -2532
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +3 -1020
  5. package/dist/index.esm.js +2 -2522
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/slot.cjs.js +0 -30
  8. package/dist/slot.cjs.js.map +1 -1
  9. package/dist/slot.d.ts +2 -25
  10. package/dist/slot.esm.js +1 -30
  11. package/dist/slot.esm.js.map +1 -1
  12. package/dist/vite.cjs.js +0 -5
  13. package/dist/vite.cjs.js.map +1 -1
  14. package/dist/vite.esm.js +0 -5
  15. package/dist/vite.esm.js.map +1 -1
  16. package/package.json +4 -37
  17. package/src/host/index.ts +0 -1
  18. package/src/host/types.ts +0 -3
  19. package/src/index.ts +0 -28
  20. package/src/slot/index.ts +0 -2
  21. package/src/vite/index.ts +0 -5
  22. package/dist/react-jsx.cjs.js +0 -3
  23. package/dist/react-jsx.cjs.js.map +0 -1
  24. package/dist/react-jsx.d.ts +0 -602
  25. package/dist/react-jsx.esm.js +0 -2
  26. package/dist/react-jsx.esm.js.map +0 -1
  27. package/dist/react.cjs.js +0 -3802
  28. package/dist/react.cjs.js.map +0 -1
  29. package/dist/react.d.ts +0 -1467
  30. package/dist/react.esm.js +0 -3786
  31. package/dist/react.esm.js.map +0 -1
  32. package/dist/ui.cjs.js +0 -3014
  33. package/dist/ui.cjs.js.map +0 -1
  34. package/dist/ui.d.ts +0 -1116
  35. package/dist/ui.esm.js +0 -2998
  36. package/dist/ui.esm.js.map +0 -1
  37. package/src/react/EngineContext.ts +0 -26
  38. package/src/react/ReactScene.ts +0 -88
  39. package/src/react/applyProps.ts +0 -271
  40. package/src/react/catalogue.ts +0 -17
  41. package/src/react/createPixiRoot.ts +0 -31
  42. package/src/react/extendAll.ts +0 -74
  43. package/src/react/hooks.ts +0 -46
  44. package/src/react/index.ts +0 -29
  45. package/src/react/jsx-runtime.ts +0 -346
  46. package/src/react/reconciler.ts +0 -338
  47. package/src/slot/freeSpins/FreeSpinsSession.ts +0 -40
  48. package/src/state/StateMachine.ts +0 -231
  49. package/src/state/index.ts +0 -1
  50. package/src/ui/BalanceDisplay.ts +0 -159
  51. package/src/ui/Button.ts +0 -304
  52. package/src/ui/FlexContainer.ts +0 -775
  53. package/src/ui/Label.ts +0 -124
  54. package/src/ui/LabelValue.ts +0 -122
  55. package/src/ui/Layout.ts +0 -291
  56. package/src/ui/Modal.ts +0 -170
  57. package/src/ui/Panel.ts +0 -204
  58. package/src/ui/ProgressBar.ts +0 -170
  59. package/src/ui/ScrollContainer.ts +0 -478
  60. package/src/ui/Slider.ts +0 -241
  61. package/src/ui/Toast.ts +0 -150
  62. package/src/ui/Toggle.ts +0 -201
  63. package/src/ui/WinDisplay.ts +0 -145
  64. package/src/ui/index.ts +0 -33
  65. package/src/ui/view.ts +0 -28
package/src/ui/Panel.ts DELETED
@@ -1,204 +0,0 @@
1
- import { Container, Graphics, NineSliceSprite, Texture } from 'pixi.js';
2
- import { FlexContainer } from './FlexContainer';
3
- import type { FlexContainerConfig } from './FlexContainer';
4
-
5
- export interface PanelConfig {
6
- /** Width */
7
- width?: number;
8
- /** Height */
9
- height?: number;
10
- /** Background color (for Graphics-based panel) */
11
- backgroundColor?: number;
12
- /** Background alpha */
13
- backgroundAlpha?: number;
14
- /** Corner radius */
15
- borderRadius?: number;
16
- /** Border color */
17
- borderColor?: number;
18
- /** Border width */
19
- borderWidth?: number;
20
- /** 9-slice texture (if provided, uses NineSliceSprite instead of Graphics) */
21
- nineSliceTexture?: string | Texture;
22
- /** 9-slice borders [left, top, right, bottom] */
23
- nineSliceBorders?: [number, number, number, number];
24
- /** Padding inside the panel */
25
- padding?: number;
26
- /** Flex layout config for content */
27
- layout?: Partial<FlexContainerConfig>;
28
- }
29
-
30
- /**
31
- * Background panel with optional flexbox content layout.
32
- *
33
- * Supports both Graphics-based (color + border) and 9-slice sprite backgrounds.
34
- * Children added via `addContent()` participate in flex layout automatically.
35
- *
36
- * @example
37
- * ```ts
38
- * // Simple colored panel
39
- * const panel = new Panel({ width: 400, height: 300, backgroundColor: 0x222222, borderRadius: 12 });
40
- *
41
- * // 9-slice panel (texture-based)
42
- * const panel = new Panel({
43
- * nineSliceTexture: 'panel-bg',
44
- * nineSliceBorders: [20, 20, 20, 20],
45
- * width: 400, height: 300,
46
- * });
47
- * ```
48
- */
49
- export class Panel extends Container {
50
- readonly __uiComponent = true as const;
51
-
52
- private _bg: Container;
53
- private _content: FlexContainer;
54
- private _internalSetup = true;
55
- private _panelConfig: Required<
56
- Pick<PanelConfig, 'width' | 'height' | 'padding' | 'backgroundAlpha'>
57
- > & PanelConfig;
58
-
59
- constructor(config: PanelConfig = {}) {
60
- super();
61
-
62
- const resolvedConfig = {
63
- width: config.width ?? 400,
64
- height: config.height ?? 300,
65
- padding: config.padding ?? 16,
66
- backgroundAlpha: config.backgroundAlpha ?? 1,
67
- ...config,
68
- };
69
-
70
- this._panelConfig = resolvedConfig;
71
-
72
- // Create background
73
- if (config.nineSliceTexture) {
74
- const texture =
75
- typeof config.nineSliceTexture === 'string'
76
- ? Texture.from(config.nineSliceTexture)
77
- : config.nineSliceTexture;
78
- const [left, top, right, bottom] = config.nineSliceBorders ?? [10, 10, 10, 10];
79
- const nineSlice = new NineSliceSprite({
80
- texture,
81
- leftWidth: left,
82
- topHeight: top,
83
- rightWidth: right,
84
- bottomHeight: bottom,
85
- });
86
- nineSlice.width = resolvedConfig.width;
87
- nineSlice.height = resolvedConfig.height;
88
- nineSlice.alpha = resolvedConfig.backgroundAlpha;
89
- this._bg = nineSlice;
90
- } else {
91
- const g = new Graphics();
92
- const bgColor = config.backgroundColor ?? 0x1a1a2e;
93
- const radius = config.borderRadius ?? 0;
94
- g.roundRect(0, 0, resolvedConfig.width, resolvedConfig.height, radius).fill(bgColor);
95
- if (config.borderColor !== undefined && config.borderWidth) {
96
- g.roundRect(0, 0, resolvedConfig.width, resolvedConfig.height, radius)
97
- .stroke({ color: config.borderColor, width: config.borderWidth });
98
- }
99
- g.alpha = resolvedConfig.backgroundAlpha;
100
- this._bg = g;
101
- }
102
- this.addChild(this._bg);
103
-
104
- // Create content flex container
105
- this._content = new FlexContainer({
106
- ...config.layout,
107
- direction: config.layout?.direction ?? 'column',
108
- justifyContent: config.layout?.justifyContent ?? 'start',
109
- alignItems: config.layout?.alignItems ?? 'start',
110
- gap: config.layout?.gap ?? 0,
111
- padding: resolvedConfig.padding,
112
- width: resolvedConfig.width,
113
- height: resolvedConfig.height,
114
- });
115
- this.addChild(this._content);
116
- this._internalSetup = false;
117
- }
118
-
119
- /** Access the content flex container — add children here for layout */
120
- get content(): FlexContainer {
121
- return this._content;
122
- }
123
-
124
- /** Suspend content layout recalculation. Call resumeLayout() to flush. */
125
- suspendLayout(): void {
126
- this._content.suspendLayout();
127
- }
128
-
129
- /** Resume content layout and flush if dirty. */
130
- resumeLayout(): void {
131
- this._content.resumeLayout();
132
- }
133
-
134
- /** Convenience: add a child to the content layout */
135
- addContent(child: Container): this {
136
- this._content.addFlexChild(child);
137
- this._content.updateLayout();
138
- return this;
139
- }
140
-
141
- /** Resize the panel */
142
- setSize(width: number, height: number): void {
143
- this._panelConfig.width = width;
144
- this._panelConfig.height = height;
145
-
146
- // Resize background
147
- if (this._bg instanceof NineSliceSprite) {
148
- this._bg.width = width;
149
- this._bg.height = height;
150
- } else if (this._bg instanceof Graphics) {
151
- const radius = this._panelConfig.borderRadius ?? 0;
152
- const bgColor = this._panelConfig.backgroundColor ?? 0x1a1a2e;
153
- this._bg.clear();
154
- (this._bg as Graphics).roundRect(0, 0, width, height, radius).fill(bgColor);
155
- if (this._panelConfig.borderColor !== undefined && this._panelConfig.borderWidth) {
156
- (this._bg as Graphics).roundRect(0, 0, width, height, radius)
157
- .stroke({ color: this._panelConfig.borderColor, width: this._panelConfig.borderWidth });
158
- }
159
- this._bg.alpha = this._panelConfig.backgroundAlpha;
160
- }
161
-
162
- this._content.resize(width, height);
163
- }
164
-
165
- /**
166
- * Override addChild so external children are routed to content FlexContainer.
167
- * Enables `<panel><label /><button /></panel>` in React JSX.
168
- */
169
- override addChild<T extends Container>(...children: T[]): T {
170
- if (this._internalSetup) {
171
- return super.addChild(...children);
172
- }
173
- for (const child of children) {
174
- this._content.addFlexChild(child as any);
175
- }
176
- this._content.updateLayout();
177
- return children[0];
178
- }
179
-
180
- override removeChild<T extends Container>(...children: T[]): T {
181
- if (this._internalSetup) {
182
- return super.removeChild(...children);
183
- }
184
- for (const child of children) {
185
- this._content.removeFlexChild(child as any);
186
- }
187
- return children[0];
188
- }
189
-
190
- /** React reconciler update hook */
191
- updateConfig(changed: Record<string, any>): void {
192
- if ('width' in changed || 'height' in changed) {
193
- this.setSize(changed.width ?? this._panelConfig.width, changed.height ?? this._panelConfig.height);
194
- }
195
- if ('backgroundAlpha' in changed) {
196
- this._panelConfig.backgroundAlpha = changed.backgroundAlpha;
197
- this._bg.alpha = changed.backgroundAlpha;
198
- }
199
- }
200
-
201
- override destroy(options?: boolean | { children?: boolean; texture?: boolean; textureSource?: boolean }): void {
202
- super.destroy(options);
203
- }
204
- }
@@ -1,170 +0,0 @@
1
- import { Container, Graphics } from 'pixi.js';
2
- import { resolveView } from './view';
3
- import type { ViewInput } from './view';
4
-
5
- export interface ProgressBarConfig {
6
- /** Width of the bar */
7
- width?: number;
8
- /** Height of the bar */
9
- height?: number;
10
- /** Corner radius (for Graphics-based bar) */
11
- borderRadius?: number;
12
- /** Fill color (for Graphics-based bar, ignored when fillView provided) */
13
- fillColor?: number;
14
- /** Track background color (for Graphics-based bar, ignored when trackView provided) */
15
- trackColor?: number;
16
- /** Border color */
17
- borderColor?: number;
18
- /** Border width */
19
- borderWidth?: number;
20
- /** Animated fill (smoothly interpolate) */
21
- animated?: boolean;
22
- /** Animation speed (0..1 per frame, default: 0.1) */
23
- animationSpeed?: number;
24
-
25
- /** Custom track background (string texture name, Texture, or Container) */
26
- trackView?: ViewInput;
27
- /** Custom fill bar (string texture name, Texture, or Container) */
28
- fillView?: ViewInput;
29
- }
30
-
31
- /**
32
- * Horizontal progress bar with optional custom track/fill views.
33
- *
34
- * Supports asset-based skinning: provide `trackView` and/or `fillView`
35
- * as texture names, Textures, or any Container (NineSliceSprite, custom artwork, etc).
36
- * Falls back to colored Graphics when no custom views are provided.
37
- *
38
- * @example
39
- * ```ts
40
- * // Graphics-based (quick prototyping)
41
- * const bar = new ProgressBar({ width: 300, height: 20, fillColor: 0x22cc22 });
42
- * bar.progress = 0.5;
43
- *
44
- * // Asset-based (production art)
45
- * const bar = new ProgressBar({
46
- * width: 300, height: 20,
47
- * trackView: 'bar-track',
48
- * fillView: new NineSliceSprite({ texture: 'bar-fill', ... }),
49
- * });
50
- * bar.progress = 0.75;
51
- * ```
52
- */
53
- export class ProgressBar extends Container {
54
- readonly __uiComponent = true as const;
55
-
56
- private _track: Container;
57
- private _fill: Container;
58
- private _fillMask: Graphics;
59
- private _borderGfx: Graphics;
60
- private _config: Required<Pick<ProgressBarConfig, 'width' | 'height' | 'borderRadius' | 'fillColor' | 'trackColor' | 'borderColor' | 'borderWidth' | 'animated' | 'animationSpeed'>>;
61
- private _progress = 0;
62
- private _displayedProgress = 0;
63
-
64
- constructor(config: ProgressBarConfig = {}) {
65
- super();
66
-
67
- this._config = {
68
- width: config.width ?? 300,
69
- height: config.height ?? 16,
70
- borderRadius: config.borderRadius ?? 8,
71
- fillColor: config.fillColor ?? 0xffd700,
72
- trackColor: config.trackColor ?? 0x333333,
73
- borderColor: config.borderColor ?? 0x555555,
74
- borderWidth: config.borderWidth ?? 1,
75
- animated: config.animated ?? true,
76
- animationSpeed: config.animationSpeed ?? 0.1,
77
- };
78
-
79
- const { width, height, borderRadius, fillColor, trackColor, borderColor, borderWidth } = this._config;
80
-
81
- // Track background — custom view or Graphics
82
- const customTrack = resolveView(config.trackView);
83
- if (customTrack) {
84
- customTrack.width = width;
85
- customTrack.height = height;
86
- this._track = customTrack;
87
- } else {
88
- const g = new Graphics();
89
- g.roundRect(0, 0, width, height, borderRadius).fill(trackColor);
90
- this._track = g;
91
- }
92
- this.addChild(this._track);
93
-
94
- // Fill bar — custom view or Graphics
95
- const customFill = resolveView(config.fillView);
96
- if (customFill) {
97
- customFill.x = borderWidth;
98
- customFill.y = borderWidth;
99
- customFill.width = width - borderWidth * 2;
100
- customFill.height = height - borderWidth * 2;
101
- this._fill = customFill;
102
- } else {
103
- const g = new Graphics();
104
- g.roundRect(
105
- borderWidth, borderWidth,
106
- width - borderWidth * 2, height - borderWidth * 2,
107
- Math.max(0, borderRadius - 1),
108
- ).fill(fillColor);
109
- this._fill = g;
110
- }
111
- this.addChild(this._fill);
112
-
113
- // Mask for the fill (controls visible width)
114
- this._fillMask = new Graphics();
115
- this._fillMask.rect(0, 0, 0, height).fill(0xffffff);
116
- this.addChild(this._fillMask);
117
- this._fill.mask = this._fillMask;
118
-
119
- // Border overlay
120
- this._borderGfx = new Graphics();
121
- if (borderColor !== undefined && borderWidth > 0) {
122
- this._borderGfx
123
- .roundRect(0, 0, width, height, borderRadius)
124
- .stroke({ color: borderColor, width: borderWidth });
125
- }
126
- this.addChild(this._borderGfx);
127
- }
128
-
129
- /** Get/set progress (0..1) */
130
- get progress(): number {
131
- return this._progress;
132
- }
133
-
134
- set progress(value: number) {
135
- this._progress = Math.max(0, Math.min(1, value));
136
- if (!this._config.animated) {
137
- this._displayedProgress = this._progress;
138
- this.updateMask();
139
- }
140
- }
141
-
142
- /**
143
- * Call each frame if animated is true.
144
- */
145
- update(_dt: number): void {
146
- if (!this._config.animated) return;
147
- if (Math.abs(this._displayedProgress - this._progress) < 0.001) {
148
- this._displayedProgress = this._progress;
149
- this.updateMask();
150
- return;
151
- }
152
-
153
- this._displayedProgress +=
154
- (this._progress - this._displayedProgress) * this._config.animationSpeed;
155
- this.updateMask();
156
- }
157
-
158
- /** React reconciler update hook */
159
- updateConfig(changed: Record<string, any>): void {
160
- if ('progress' in changed) this.progress = changed.progress;
161
- if ('animated' in changed) this._config.animated = changed.animated;
162
- if ('animationSpeed' in changed) this._config.animationSpeed = changed.animationSpeed;
163
- }
164
-
165
- private updateMask(): void {
166
- const w = this._config.width * this._displayedProgress;
167
- this._fillMask.clear();
168
- this._fillMask.rect(0, 0, w, this._config.height).fill(0xffffff);
169
- }
170
- }