@energy8platform/game-engine 0.14.10 → 0.15.1
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/audio.cjs.js +6 -1
- package/dist/audio.cjs.js.map +1 -1
- package/dist/audio.esm.js +6 -1
- package/dist/audio.esm.js.map +1 -1
- package/dist/core.cjs.js +6 -1
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.esm.js +6 -1
- package/dist/core.esm.js.map +1 -1
- package/dist/index.cjs.js +28 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +24 -5
- package/dist/index.esm.js +28 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/react-jsx.cjs.js +3 -0
- package/dist/react-jsx.cjs.js.map +1 -0
- package/dist/react-jsx.d.ts +602 -0
- package/dist/react-jsx.esm.js +2 -0
- package/dist/react-jsx.esm.js.map +1 -0
- package/dist/react.cjs.js +146 -11
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.d.ts +600 -1
- package/dist/react.esm.js +146 -11
- package/dist/react.esm.js.map +1 -1
- package/dist/ui.cjs.js +114 -8
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.d.ts +82 -7
- package/dist/ui.esm.js +114 -9
- package/dist/ui.esm.js.map +1 -1
- package/package.json +6 -1
- package/src/audio/AudioManager.ts +6 -1
- package/src/react/applyProps.ts +32 -1
- package/src/react/extendAll.ts +2 -2
- package/src/react/index.ts +6 -0
- package/src/react/jsx-runtime.ts +346 -0
- package/src/react/reconciler.ts +1 -1
- package/src/ui/FlexContainer.ts +44 -11
- package/src/ui/LabelValue.ts +122 -0
- package/src/ui/index.ts +2 -0
- package/src/react/jsx.d.ts +0 -261
package/dist/react.esm.js
CHANGED
|
@@ -22,7 +22,7 @@ function extend(components) {
|
|
|
22
22
|
|
|
23
23
|
const RESERVED = new Set(['children', 'key', 'ref']);
|
|
24
24
|
/** Props handled by the reconciler as flex item config, not forwarded to components */
|
|
25
|
-
const FLEX_ITEM_PROPS$1 = new Set(['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude', 'top', 'right', 'bottom', 'left']);
|
|
25
|
+
const FLEX_ITEM_PROPS$1 = new Set(['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude', 'top', 'right', 'bottom', 'left', 'centerX', 'centerY']);
|
|
26
26
|
/** Base Container props applied directly to the instance (not via config) */
|
|
27
27
|
const CONTAINER_PROPS = new Set([
|
|
28
28
|
'x', 'y', 'alpha', 'visible', 'rotation', 'angle', 'zIndex',
|
|
@@ -149,6 +149,34 @@ function hasEventProps(props) {
|
|
|
149
149
|
}
|
|
150
150
|
return false;
|
|
151
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Graphics does not have an intrinsic size — its bounds come from the `draw` callback.
|
|
154
|
+
* PixiJS's `Container.width` setter applies a scale transform to match the requested
|
|
155
|
+
* value, which silently makes the rendered size diverge from `getLocalBounds()` and
|
|
156
|
+
* breaks downstream flex layout. For Graphics we treat `width`/`height` as layout
|
|
157
|
+
* hints instead, storing them on `_flexConfig.layoutWidth`/`layoutHeight` so parent
|
|
158
|
+
* FlexContainers measure correctly without touching the child's scale.
|
|
159
|
+
*/
|
|
160
|
+
function isGraphicsLike(instance) {
|
|
161
|
+
return typeof instance?.clear === 'function'
|
|
162
|
+
&& typeof instance?.fill === 'function'
|
|
163
|
+
&& typeof instance?.rect === 'function';
|
|
164
|
+
}
|
|
165
|
+
/** Redirect a width/height write on a Graphics into its flex layout hint. Returns true if handled. */
|
|
166
|
+
function applyGraphicsDimension(instance, key, value) {
|
|
167
|
+
if ((key !== 'width' && key !== 'height') || !isGraphicsLike(instance))
|
|
168
|
+
return false;
|
|
169
|
+
const target = key === 'width' ? 'layoutWidth' : 'layoutHeight';
|
|
170
|
+
if (value === undefined) {
|
|
171
|
+
if (instance._flexConfig)
|
|
172
|
+
delete instance._flexConfig[target];
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if (!instance._flexConfig)
|
|
176
|
+
instance._flexConfig = {};
|
|
177
|
+
instance._flexConfig[target] = value;
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
152
180
|
function setNestedValue(target, path, value) {
|
|
153
181
|
let obj = target;
|
|
154
182
|
for (let i = 0; i < path.length - 1; i++) {
|
|
@@ -213,6 +241,7 @@ function applyProps(instance, newProps, oldProps = {}) {
|
|
|
213
241
|
}
|
|
214
242
|
else if (key === 'draw') ;
|
|
215
243
|
else if (key.includes('-')) ;
|
|
244
|
+
else if (applyGraphicsDimension(instance, key, undefined)) ;
|
|
216
245
|
else {
|
|
217
246
|
try {
|
|
218
247
|
instance[key] = undefined;
|
|
@@ -239,6 +268,7 @@ function applyProps(instance, newProps, oldProps = {}) {
|
|
|
239
268
|
const parts = key.split('-');
|
|
240
269
|
setNestedValue(instance, parts, value);
|
|
241
270
|
}
|
|
271
|
+
else if (applyGraphicsDimension(instance, key, value)) ;
|
|
242
272
|
else {
|
|
243
273
|
try {
|
|
244
274
|
instance[key] = value;
|
|
@@ -787,22 +817,36 @@ class FlexContainer extends Container {
|
|
|
787
817
|
this._computedWidth = this._explicitWidth > 0 ? this._explicitWidth : (pl + totalCrossNatural + pr);
|
|
788
818
|
this._computedHeight = this._explicitHeight > 0 ? this._explicitHeight : (pt + naturalMainSize + pb);
|
|
789
819
|
}
|
|
790
|
-
// Position flexExclude children (absolute positioning)
|
|
820
|
+
// Position flexExclude children (absolute positioning).
|
|
821
|
+
// All position props describe the visual (bounds) rectangle. We derive the
|
|
822
|
+
// visual rectangle directly from `getLocalBounds()` rather than the
|
|
823
|
+
// layout-config `w`/`h` returned by measureChild — those may differ from
|
|
824
|
+
// actual bounds when the user pins `layoutWidth`/`layoutHeight` to a value
|
|
825
|
+
// that doesn't match the child's real visual extent (e.g. a Button whose
|
|
826
|
+
// text overflows its configured `width`). Mixing layout size with real
|
|
827
|
+
// bounds-origin would shift the visual center off the requested point.
|
|
828
|
+
// `centerX/centerY` take precedence over `left/right` / `top/bottom` on each axis.
|
|
791
829
|
for (const child of this._layoutChildren) {
|
|
792
830
|
if (!child._flexConfig?.flexExclude)
|
|
793
831
|
continue;
|
|
794
832
|
const cfg = child._flexConfig;
|
|
795
|
-
const
|
|
833
|
+
const bounds = child.getLocalBounds();
|
|
796
834
|
const cw = this._computedWidth;
|
|
797
835
|
const ch = this._computedHeight;
|
|
798
|
-
|
|
799
|
-
|
|
836
|
+
const centerX = resolveDimension(cfg.centerX, pctRefW);
|
|
837
|
+
if (centerX !== undefined)
|
|
838
|
+
child.x = centerX - bounds.x - bounds.width / 2;
|
|
839
|
+
else if (cfg.left !== undefined)
|
|
840
|
+
child.x = cfg.left - bounds.x;
|
|
800
841
|
else if (cfg.right !== undefined)
|
|
801
|
-
child.x = cw -
|
|
802
|
-
|
|
803
|
-
|
|
842
|
+
child.x = cw - cfg.right - bounds.x - bounds.width;
|
|
843
|
+
const centerY = resolveDimension(cfg.centerY, pctRefH);
|
|
844
|
+
if (centerY !== undefined)
|
|
845
|
+
child.y = centerY - bounds.y - bounds.height / 2;
|
|
846
|
+
else if (cfg.top !== undefined)
|
|
847
|
+
child.y = cfg.top - bounds.y;
|
|
804
848
|
else if (cfg.bottom !== undefined)
|
|
805
|
-
child.y = ch -
|
|
849
|
+
child.y = ch - cfg.bottom - bounds.y - bounds.height;
|
|
806
850
|
}
|
|
807
851
|
}
|
|
808
852
|
/** Computed content size (after layout) */
|
|
@@ -861,7 +905,7 @@ class FlexContainer extends Container {
|
|
|
861
905
|
}
|
|
862
906
|
|
|
863
907
|
/** Flex item prop names that should be forwarded to _flexConfig on the child */
|
|
864
|
-
const FLEX_ITEM_PROPS = ['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude', 'top', 'right', 'bottom', 'left'];
|
|
908
|
+
const FLEX_ITEM_PROPS = ['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude', 'top', 'right', 'bottom', 'left', 'centerX', 'centerY'];
|
|
865
909
|
function isSuspendable(obj) {
|
|
866
910
|
return typeof obj?.suspendLayout === 'function' && typeof obj?.resumeLayout === 'function';
|
|
867
911
|
}
|
|
@@ -1860,6 +1904,97 @@ class Label extends Container {
|
|
|
1860
1904
|
}
|
|
1861
1905
|
}
|
|
1862
1906
|
|
|
1907
|
+
/**
|
|
1908
|
+
* Two-row text cell with a muted caption above and a prominent value below —
|
|
1909
|
+
* the archetypal casino UI pattern (BALANCE/€500, BET/€1, WIN/€0.00).
|
|
1910
|
+
*
|
|
1911
|
+
* Extends FlexContainer, so it participates in parent flex layouts directly
|
|
1912
|
+
* (you can pass `flexGrow`, `alignSelf`, etc. when it's a child of another
|
|
1913
|
+
* FlexContainer) and auto-sizes to its contents when no explicit size is set.
|
|
1914
|
+
*
|
|
1915
|
+
* @example
|
|
1916
|
+
* ```tsx
|
|
1917
|
+
* <labelValue
|
|
1918
|
+
* label="BALANCE"
|
|
1919
|
+
* value={`€${balance.toFixed(2)}`}
|
|
1920
|
+
* labelStyle={{ fontSize: 12, fill: 0x888888 }}
|
|
1921
|
+
* valueStyle={{ fontSize: 22, fill: 0xffffff, fontWeight: 'bold' }}
|
|
1922
|
+
* gap={6}
|
|
1923
|
+
* align="center"
|
|
1924
|
+
* />
|
|
1925
|
+
* ```
|
|
1926
|
+
*/
|
|
1927
|
+
class LabelValue extends FlexContainer {
|
|
1928
|
+
_labelEl;
|
|
1929
|
+
_valueEl;
|
|
1930
|
+
_valueMaxWidth;
|
|
1931
|
+
constructor(config = {}) {
|
|
1932
|
+
super({
|
|
1933
|
+
direction: 'column',
|
|
1934
|
+
alignItems: toAlignItems(config.align ?? 'center'),
|
|
1935
|
+
gap: config.gap ?? 4,
|
|
1936
|
+
padding: config.padding,
|
|
1937
|
+
});
|
|
1938
|
+
this._valueMaxWidth = config.maxWidth ?? Infinity;
|
|
1939
|
+
this._labelEl = new Label({
|
|
1940
|
+
text: config.label ?? '',
|
|
1941
|
+
style: config.labelStyle,
|
|
1942
|
+
});
|
|
1943
|
+
this._valueEl = new Label({
|
|
1944
|
+
text: config.value ?? '',
|
|
1945
|
+
style: config.valueStyle,
|
|
1946
|
+
maxWidth: config.maxWidth,
|
|
1947
|
+
autoFit: config.maxWidth !== undefined,
|
|
1948
|
+
});
|
|
1949
|
+
this.addFlexChild(this._labelEl);
|
|
1950
|
+
this.addFlexChild(this._valueEl);
|
|
1951
|
+
}
|
|
1952
|
+
/** Get the caption Label (for advanced styling / animation) */
|
|
1953
|
+
get labelElement() {
|
|
1954
|
+
return this._labelEl;
|
|
1955
|
+
}
|
|
1956
|
+
/** Get the value Label */
|
|
1957
|
+
get valueElement() {
|
|
1958
|
+
return this._valueEl;
|
|
1959
|
+
}
|
|
1960
|
+
/** Update caption text */
|
|
1961
|
+
setLabel(text) {
|
|
1962
|
+
this._labelEl.text = text;
|
|
1963
|
+
this.updateLayout();
|
|
1964
|
+
}
|
|
1965
|
+
/** Update value text */
|
|
1966
|
+
setValue(text) {
|
|
1967
|
+
this._valueEl.text = text;
|
|
1968
|
+
this.updateLayout();
|
|
1969
|
+
}
|
|
1970
|
+
/** React reconciler update hook */
|
|
1971
|
+
updateConfig(changed) {
|
|
1972
|
+
if ('label' in changed)
|
|
1973
|
+
this._labelEl.text = changed.label ?? '';
|
|
1974
|
+
if ('value' in changed)
|
|
1975
|
+
this._valueEl.text = changed.value ?? '';
|
|
1976
|
+
if ('labelStyle' in changed && typeof changed.labelStyle === 'object') {
|
|
1977
|
+
Object.assign(this._labelEl.style, changed.labelStyle);
|
|
1978
|
+
}
|
|
1979
|
+
if ('valueStyle' in changed && typeof changed.valueStyle === 'object') {
|
|
1980
|
+
Object.assign(this._valueEl.style, changed.valueStyle);
|
|
1981
|
+
}
|
|
1982
|
+
if ('maxWidth' in changed) {
|
|
1983
|
+
this._valueMaxWidth = changed.maxWidth ?? Infinity;
|
|
1984
|
+
this._valueEl.maxWidth = this._valueMaxWidth;
|
|
1985
|
+
}
|
|
1986
|
+
if ('gap' in changed)
|
|
1987
|
+
this.setGap(changed.gap);
|
|
1988
|
+
if ('align' in changed)
|
|
1989
|
+
this.setAlignItems(toAlignItems(changed.align));
|
|
1990
|
+
// Forward remaining FlexContainer props (e.g. padding, width, height)
|
|
1991
|
+
super.updateConfig(changed);
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
function toAlignItems(align) {
|
|
1995
|
+
return align;
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1863
1998
|
/**
|
|
1864
1999
|
* Background panel with optional flexbox content layout.
|
|
1865
2000
|
*
|
|
@@ -3457,7 +3592,7 @@ function extendPixiElements() {
|
|
|
3457
3592
|
*/
|
|
3458
3593
|
function extendUIElements() {
|
|
3459
3594
|
extend({
|
|
3460
|
-
Button, Label, Panel, FlexContainer, ProgressBar,
|
|
3595
|
+
Button, Label, LabelValue, Panel, FlexContainer, ProgressBar,
|
|
3461
3596
|
ScrollContainer, Modal, Toast, BalanceDisplay, WinDisplay, Layout,
|
|
3462
3597
|
Slider, Toggle,
|
|
3463
3598
|
});
|