@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/ui.d.ts
CHANGED
|
@@ -37,16 +37,35 @@ interface FlexItemConfig {
|
|
|
37
37
|
layoutHeight?: number | string;
|
|
38
38
|
/** Override parent's alignItems for this child */
|
|
39
39
|
alignSelf?: AlignSelf;
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Exclude from flex layout (acts like position: absolute).
|
|
42
|
+
*
|
|
43
|
+
* Positioning props (`top`/`right`/`bottom`/`left`/`centerX`/`centerY`) describe
|
|
44
|
+
* the **visual bounding rectangle**, so children with a centered internal
|
|
45
|
+
* origin (Button, Label — `anchor = 0.5`) are positioned intuitively.
|
|
46
|
+
* `left: 100` places the visible left edge at 100px, regardless of origin.
|
|
47
|
+
*/
|
|
41
48
|
flexExclude?: boolean;
|
|
42
|
-
/**
|
|
49
|
+
/** Distance from top edge of parent content area to the child's visual top */
|
|
43
50
|
top?: number;
|
|
44
|
-
/**
|
|
51
|
+
/** Distance from right edge of parent content area to the child's visual right */
|
|
45
52
|
right?: number;
|
|
46
|
-
/**
|
|
53
|
+
/** Distance from bottom edge of parent content area to the child's visual bottom */
|
|
47
54
|
bottom?: number;
|
|
48
|
-
/**
|
|
55
|
+
/** Distance from left edge of parent content area to the child's visual left */
|
|
49
56
|
left?: number;
|
|
57
|
+
/**
|
|
58
|
+
* X coordinate of the child's visual center within parent content area.
|
|
59
|
+
* Accepts pixels (`200`) or a percentage of parent content width (`'50%'`).
|
|
60
|
+
* Takes precedence over `left`/`right`.
|
|
61
|
+
*/
|
|
62
|
+
centerX?: number | string;
|
|
63
|
+
/**
|
|
64
|
+
* Y coordinate of the child's visual center within parent content area.
|
|
65
|
+
* Accepts pixels or a percentage of parent content height (`'50%'`).
|
|
66
|
+
* Takes precedence over `top`/`bottom`.
|
|
67
|
+
*/
|
|
68
|
+
centerY?: number | string;
|
|
50
69
|
}
|
|
51
70
|
interface FlexContainerConfig {
|
|
52
71
|
/** Layout direction (default: 'row') */
|
|
@@ -391,6 +410,62 @@ declare class Label extends Container {
|
|
|
391
410
|
private fitText;
|
|
392
411
|
}
|
|
393
412
|
|
|
413
|
+
type LabelValueAlign = 'start' | 'center' | 'end';
|
|
414
|
+
interface LabelValueConfig {
|
|
415
|
+
/** Caption text (top row, typically smaller/muted) */
|
|
416
|
+
label?: string;
|
|
417
|
+
/** Value text (bottom row, typically larger/prominent) */
|
|
418
|
+
value?: string;
|
|
419
|
+
/** Style for the caption Label */
|
|
420
|
+
labelStyle?: Partial<TextStyle>;
|
|
421
|
+
/** Style for the value Label */
|
|
422
|
+
valueStyle?: Partial<TextStyle>;
|
|
423
|
+
/** Gap in pixels between caption and value (default: 4) */
|
|
424
|
+
gap?: number;
|
|
425
|
+
/** Horizontal alignment of both rows (default: 'center') */
|
|
426
|
+
align?: LabelValueAlign;
|
|
427
|
+
/** Maximum width — value will be auto-scaled to fit when exceeded */
|
|
428
|
+
maxWidth?: number;
|
|
429
|
+
/** Optional padding (forwarded to the underlying FlexContainer) */
|
|
430
|
+
padding?: FlexContainerConfig['padding'];
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Two-row text cell with a muted caption above and a prominent value below —
|
|
434
|
+
* the archetypal casino UI pattern (BALANCE/€500, BET/€1, WIN/€0.00).
|
|
435
|
+
*
|
|
436
|
+
* Extends FlexContainer, so it participates in parent flex layouts directly
|
|
437
|
+
* (you can pass `flexGrow`, `alignSelf`, etc. when it's a child of another
|
|
438
|
+
* FlexContainer) and auto-sizes to its contents when no explicit size is set.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```tsx
|
|
442
|
+
* <labelValue
|
|
443
|
+
* label="BALANCE"
|
|
444
|
+
* value={`€${balance.toFixed(2)}`}
|
|
445
|
+
* labelStyle={{ fontSize: 12, fill: 0x888888 }}
|
|
446
|
+
* valueStyle={{ fontSize: 22, fill: 0xffffff, fontWeight: 'bold' }}
|
|
447
|
+
* gap={6}
|
|
448
|
+
* align="center"
|
|
449
|
+
* />
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
declare class LabelValue extends FlexContainer {
|
|
453
|
+
private readonly _labelEl;
|
|
454
|
+
private readonly _valueEl;
|
|
455
|
+
private _valueMaxWidth;
|
|
456
|
+
constructor(config?: LabelValueConfig);
|
|
457
|
+
/** Get the caption Label (for advanced styling / animation) */
|
|
458
|
+
get labelElement(): Label;
|
|
459
|
+
/** Get the value Label */
|
|
460
|
+
get valueElement(): Label;
|
|
461
|
+
/** Update caption text */
|
|
462
|
+
setLabel(text: string): void;
|
|
463
|
+
/** Update value text */
|
|
464
|
+
setValue(text: string): void;
|
|
465
|
+
/** React reconciler update hook */
|
|
466
|
+
updateConfig(changed: Record<string, any>): void;
|
|
467
|
+
}
|
|
468
|
+
|
|
394
469
|
interface PanelConfig {
|
|
395
470
|
/** Width */
|
|
396
471
|
width?: number;
|
|
@@ -1037,5 +1112,5 @@ declare class Toggle extends Container {
|
|
|
1037
1112
|
}): void;
|
|
1038
1113
|
}
|
|
1039
1114
|
|
|
1040
|
-
export { BalanceDisplay, Button, FlexContainer, Label, Layout, Modal, Panel, ProgressBar, ScrollContainer, Slider, Toast, Toggle, WinDisplay, resolveView };
|
|
1041
|
-
export type { AlignContent, AlignItems, AlignSelf, BalanceDisplayConfig, ButtonConfig, ButtonState, FlexContainerConfig, FlexDirection, FlexItemConfig, JustifyContent, LabelConfig, LayoutAlignment, LayoutAnchor, LayoutConfig, LayoutDirection, ModalConfig, PanelConfig, ProgressBarConfig, ScrollContainerConfig, ScrollDirection, SliderConfig, ToastConfig, ToastType, ToggleConfig, ViewInput, WinDisplayConfig };
|
|
1115
|
+
export { BalanceDisplay, Button, FlexContainer, Label, LabelValue, Layout, Modal, Panel, ProgressBar, ScrollContainer, Slider, Toast, Toggle, WinDisplay, resolveView };
|
|
1116
|
+
export type { AlignContent, AlignItems, AlignSelf, BalanceDisplayConfig, ButtonConfig, ButtonState, FlexContainerConfig, FlexDirection, FlexItemConfig, JustifyContent, LabelConfig, LabelValueAlign, LabelValueConfig, LayoutAlignment, LayoutAnchor, LayoutConfig, LayoutDirection, ModalConfig, PanelConfig, ProgressBarConfig, ScrollContainerConfig, ScrollDirection, SliderConfig, ToastConfig, ToastType, ToggleConfig, ViewInput, WinDisplayConfig };
|
package/dist/ui.esm.js
CHANGED
|
@@ -558,22 +558,36 @@ class FlexContainer extends Container {
|
|
|
558
558
|
this._computedWidth = this._explicitWidth > 0 ? this._explicitWidth : (pl + totalCrossNatural + pr);
|
|
559
559
|
this._computedHeight = this._explicitHeight > 0 ? this._explicitHeight : (pt + naturalMainSize + pb);
|
|
560
560
|
}
|
|
561
|
-
// Position flexExclude children (absolute positioning)
|
|
561
|
+
// Position flexExclude children (absolute positioning).
|
|
562
|
+
// All position props describe the visual (bounds) rectangle. We derive the
|
|
563
|
+
// visual rectangle directly from `getLocalBounds()` rather than the
|
|
564
|
+
// layout-config `w`/`h` returned by measureChild — those may differ from
|
|
565
|
+
// actual bounds when the user pins `layoutWidth`/`layoutHeight` to a value
|
|
566
|
+
// that doesn't match the child's real visual extent (e.g. a Button whose
|
|
567
|
+
// text overflows its configured `width`). Mixing layout size with real
|
|
568
|
+
// bounds-origin would shift the visual center off the requested point.
|
|
569
|
+
// `centerX/centerY` take precedence over `left/right` / `top/bottom` on each axis.
|
|
562
570
|
for (const child of this._layoutChildren) {
|
|
563
571
|
if (!child._flexConfig?.flexExclude)
|
|
564
572
|
continue;
|
|
565
573
|
const cfg = child._flexConfig;
|
|
566
|
-
const
|
|
574
|
+
const bounds = child.getLocalBounds();
|
|
567
575
|
const cw = this._computedWidth;
|
|
568
576
|
const ch = this._computedHeight;
|
|
569
|
-
|
|
570
|
-
|
|
577
|
+
const centerX = resolveDimension(cfg.centerX, pctRefW);
|
|
578
|
+
if (centerX !== undefined)
|
|
579
|
+
child.x = centerX - bounds.x - bounds.width / 2;
|
|
580
|
+
else if (cfg.left !== undefined)
|
|
581
|
+
child.x = cfg.left - bounds.x;
|
|
571
582
|
else if (cfg.right !== undefined)
|
|
572
|
-
child.x = cw -
|
|
573
|
-
|
|
574
|
-
|
|
583
|
+
child.x = cw - cfg.right - bounds.x - bounds.width;
|
|
584
|
+
const centerY = resolveDimension(cfg.centerY, pctRefH);
|
|
585
|
+
if (centerY !== undefined)
|
|
586
|
+
child.y = centerY - bounds.y - bounds.height / 2;
|
|
587
|
+
else if (cfg.top !== undefined)
|
|
588
|
+
child.y = cfg.top - bounds.y;
|
|
575
589
|
else if (cfg.bottom !== undefined)
|
|
576
|
-
child.y = ch -
|
|
590
|
+
child.y = ch - cfg.bottom - bounds.y - bounds.height;
|
|
577
591
|
}
|
|
578
592
|
}
|
|
579
593
|
/** Computed content size (after layout) */
|
|
@@ -1310,6 +1324,97 @@ class Label extends Container {
|
|
|
1310
1324
|
}
|
|
1311
1325
|
}
|
|
1312
1326
|
|
|
1327
|
+
/**
|
|
1328
|
+
* Two-row text cell with a muted caption above and a prominent value below —
|
|
1329
|
+
* the archetypal casino UI pattern (BALANCE/€500, BET/€1, WIN/€0.00).
|
|
1330
|
+
*
|
|
1331
|
+
* Extends FlexContainer, so it participates in parent flex layouts directly
|
|
1332
|
+
* (you can pass `flexGrow`, `alignSelf`, etc. when it's a child of another
|
|
1333
|
+
* FlexContainer) and auto-sizes to its contents when no explicit size is set.
|
|
1334
|
+
*
|
|
1335
|
+
* @example
|
|
1336
|
+
* ```tsx
|
|
1337
|
+
* <labelValue
|
|
1338
|
+
* label="BALANCE"
|
|
1339
|
+
* value={`€${balance.toFixed(2)}`}
|
|
1340
|
+
* labelStyle={{ fontSize: 12, fill: 0x888888 }}
|
|
1341
|
+
* valueStyle={{ fontSize: 22, fill: 0xffffff, fontWeight: 'bold' }}
|
|
1342
|
+
* gap={6}
|
|
1343
|
+
* align="center"
|
|
1344
|
+
* />
|
|
1345
|
+
* ```
|
|
1346
|
+
*/
|
|
1347
|
+
class LabelValue extends FlexContainer {
|
|
1348
|
+
_labelEl;
|
|
1349
|
+
_valueEl;
|
|
1350
|
+
_valueMaxWidth;
|
|
1351
|
+
constructor(config = {}) {
|
|
1352
|
+
super({
|
|
1353
|
+
direction: 'column',
|
|
1354
|
+
alignItems: toAlignItems(config.align ?? 'center'),
|
|
1355
|
+
gap: config.gap ?? 4,
|
|
1356
|
+
padding: config.padding,
|
|
1357
|
+
});
|
|
1358
|
+
this._valueMaxWidth = config.maxWidth ?? Infinity;
|
|
1359
|
+
this._labelEl = new Label({
|
|
1360
|
+
text: config.label ?? '',
|
|
1361
|
+
style: config.labelStyle,
|
|
1362
|
+
});
|
|
1363
|
+
this._valueEl = new Label({
|
|
1364
|
+
text: config.value ?? '',
|
|
1365
|
+
style: config.valueStyle,
|
|
1366
|
+
maxWidth: config.maxWidth,
|
|
1367
|
+
autoFit: config.maxWidth !== undefined,
|
|
1368
|
+
});
|
|
1369
|
+
this.addFlexChild(this._labelEl);
|
|
1370
|
+
this.addFlexChild(this._valueEl);
|
|
1371
|
+
}
|
|
1372
|
+
/** Get the caption Label (for advanced styling / animation) */
|
|
1373
|
+
get labelElement() {
|
|
1374
|
+
return this._labelEl;
|
|
1375
|
+
}
|
|
1376
|
+
/** Get the value Label */
|
|
1377
|
+
get valueElement() {
|
|
1378
|
+
return this._valueEl;
|
|
1379
|
+
}
|
|
1380
|
+
/** Update caption text */
|
|
1381
|
+
setLabel(text) {
|
|
1382
|
+
this._labelEl.text = text;
|
|
1383
|
+
this.updateLayout();
|
|
1384
|
+
}
|
|
1385
|
+
/** Update value text */
|
|
1386
|
+
setValue(text) {
|
|
1387
|
+
this._valueEl.text = text;
|
|
1388
|
+
this.updateLayout();
|
|
1389
|
+
}
|
|
1390
|
+
/** React reconciler update hook */
|
|
1391
|
+
updateConfig(changed) {
|
|
1392
|
+
if ('label' in changed)
|
|
1393
|
+
this._labelEl.text = changed.label ?? '';
|
|
1394
|
+
if ('value' in changed)
|
|
1395
|
+
this._valueEl.text = changed.value ?? '';
|
|
1396
|
+
if ('labelStyle' in changed && typeof changed.labelStyle === 'object') {
|
|
1397
|
+
Object.assign(this._labelEl.style, changed.labelStyle);
|
|
1398
|
+
}
|
|
1399
|
+
if ('valueStyle' in changed && typeof changed.valueStyle === 'object') {
|
|
1400
|
+
Object.assign(this._valueEl.style, changed.valueStyle);
|
|
1401
|
+
}
|
|
1402
|
+
if ('maxWidth' in changed) {
|
|
1403
|
+
this._valueMaxWidth = changed.maxWidth ?? Infinity;
|
|
1404
|
+
this._valueEl.maxWidth = this._valueMaxWidth;
|
|
1405
|
+
}
|
|
1406
|
+
if ('gap' in changed)
|
|
1407
|
+
this.setGap(changed.gap);
|
|
1408
|
+
if ('align' in changed)
|
|
1409
|
+
this.setAlignItems(toAlignItems(changed.align));
|
|
1410
|
+
// Forward remaining FlexContainer props (e.g. padding, width, height)
|
|
1411
|
+
super.updateConfig(changed);
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
function toAlignItems(align) {
|
|
1415
|
+
return align;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1313
1418
|
/**
|
|
1314
1419
|
* Background panel with optional flexbox content layout.
|
|
1315
1420
|
*
|
|
@@ -2869,5 +2974,5 @@ class Toggle extends Container {
|
|
|
2869
2974
|
}
|
|
2870
2975
|
}
|
|
2871
2976
|
|
|
2872
|
-
export { BalanceDisplay, Button, FlexContainer, Label, Layout, Modal, Panel, ProgressBar, ScrollContainer, Slider, Toast, Toggle, WinDisplay, resolveView };
|
|
2977
|
+
export { BalanceDisplay, Button, FlexContainer, Label, LabelValue, Layout, Modal, Panel, ProgressBar, ScrollContainer, Slider, Toast, Toggle, WinDisplay, resolveView };
|
|
2873
2978
|
//# sourceMappingURL=ui.esm.js.map
|