@energy8platform/game-engine 0.15.0 → 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/index.cjs.js +14 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +14 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/react-jsx.d.ts +68 -48
- package/dist/react.cjs.js +14 -9
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.d.ts +600 -1
- package/dist/react.esm.js +14 -9
- package/dist/react.esm.js.map +1 -1
- package/dist/ui.cjs.js +14 -9
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.esm.js +14 -9
- 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 +14 -9
package/dist/react-jsx.d.ts
CHANGED
|
@@ -322,19 +322,28 @@ interface ToggleConfig {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
|
-
*
|
|
325
|
+
* JSX prop types for the PixiJS React reconciler.
|
|
326
326
|
*
|
|
327
|
-
*
|
|
327
|
+
* The engine auto-augments `react`'s module-scoped `JSX.IntrinsicElements`
|
|
328
|
+
* with every registered element (`<flexContainer>`, `<button>`, `<label>`,
|
|
329
|
+
* `<labelValue>`, etc). Because the augmentation is scoped to the `react`
|
|
330
|
+
* module (not the legacy global `JSX` namespace), it reliably wins over
|
|
331
|
+
* `@types/react`'s HTML defaults for colliding names like `<button>` / `<label>`.
|
|
328
332
|
*
|
|
329
|
-
*
|
|
333
|
+
* **Consumers don't need any shim.** Any import from `@energy8platform/game-engine/react`
|
|
334
|
+
* (e.g. `createPixiRoot`, `extendUIElements`, `ReactScene` — you're already
|
|
335
|
+
* importing these to boot the reconciler) pulls this module in and the JSX
|
|
336
|
+
* types activate automatically.
|
|
330
337
|
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
338
|
+
* If a project imports only from `/ui` or `/core` and never touches `/react`,
|
|
339
|
+
* add a one-line side-effect import to trigger the augmentation:
|
|
333
340
|
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
341
|
+
* ```ts
|
|
342
|
+
* // app/src/pixi-jsx.d.ts
|
|
343
|
+
* import '@energy8platform/game-engine/react-jsx';
|
|
344
|
+
* ```
|
|
336
345
|
*
|
|
337
|
-
* Dash-notation
|
|
346
|
+
* Dash-notation for nested config objects is supported:
|
|
338
347
|
* <button colors-default={0xff0000} colors-hover={0x00ff00} />
|
|
339
348
|
*/
|
|
340
349
|
|
|
@@ -435,6 +444,26 @@ interface GraphicsProps extends BaseProps {
|
|
|
435
444
|
width?: number;
|
|
436
445
|
height?: number;
|
|
437
446
|
}
|
|
447
|
+
interface AnimatedSpriteProps extends BaseProps {
|
|
448
|
+
textures?: Texture[];
|
|
449
|
+
animationSpeed?: number;
|
|
450
|
+
loop?: boolean;
|
|
451
|
+
playing?: boolean;
|
|
452
|
+
}
|
|
453
|
+
interface NineSliceSpriteProps extends BaseProps {
|
|
454
|
+
texture?: string | Texture;
|
|
455
|
+
leftWidth?: number;
|
|
456
|
+
topHeight?: number;
|
|
457
|
+
rightWidth?: number;
|
|
458
|
+
bottomHeight?: number;
|
|
459
|
+
}
|
|
460
|
+
interface TilingSpriteProps extends BaseProps {
|
|
461
|
+
texture?: string | Texture;
|
|
462
|
+
tilePosition?: {
|
|
463
|
+
x: number;
|
|
464
|
+
y: number;
|
|
465
|
+
};
|
|
466
|
+
}
|
|
438
467
|
interface ButtonComponentProps extends BaseProps, Omit<ButtonConfig, 'colors' | 'textStyle'> {
|
|
439
468
|
colors?: Partial<Record<ButtonState, number>>;
|
|
440
469
|
textStyle?: Record<string, unknown>;
|
|
@@ -536,47 +565,38 @@ interface ToggleComponentProps extends BaseProps, Omit<ToggleConfig, 'width' | '
|
|
|
536
565
|
offView?: ViewInput;
|
|
537
566
|
onChange?: (value: boolean) => void;
|
|
538
567
|
}
|
|
539
|
-
|
|
568
|
+
/**
|
|
569
|
+
* Complete element → prop-type map for all engine-registered JSX elements.
|
|
570
|
+
* Also consumable directly for typing custom wrappers around engine elements.
|
|
571
|
+
*/
|
|
572
|
+
interface EngineIntrinsicElements {
|
|
573
|
+
container: BaseProps;
|
|
574
|
+
sprite: SpriteProps;
|
|
575
|
+
text: TextProps;
|
|
576
|
+
graphics: GraphicsProps;
|
|
577
|
+
animatedSprite: AnimatedSpriteProps;
|
|
578
|
+
nineSliceSprite: NineSliceSpriteProps;
|
|
579
|
+
tilingSprite: TilingSpriteProps;
|
|
580
|
+
button: ButtonComponentProps;
|
|
581
|
+
label: LabelComponentProps;
|
|
582
|
+
labelValue: LabelValueComponentProps;
|
|
583
|
+
panel: PanelComponentProps;
|
|
584
|
+
flexContainer: FlexContainerComponentProps;
|
|
585
|
+
progressBar: ProgressBarComponentProps;
|
|
586
|
+
scrollContainer: ScrollContainerComponentProps;
|
|
587
|
+
modal: ModalComponentProps;
|
|
588
|
+
toast: ToastComponentProps;
|
|
589
|
+
balanceDisplay: BalanceDisplayComponentProps;
|
|
590
|
+
winDisplay: WinDisplayComponentProps;
|
|
591
|
+
layout: LayoutComponentProps;
|
|
592
|
+
slider: SliderComponentProps;
|
|
593
|
+
toggle: ToggleComponentProps;
|
|
594
|
+
}
|
|
595
|
+
declare module 'react' {
|
|
540
596
|
namespace JSX {
|
|
541
|
-
interface IntrinsicElements {
|
|
542
|
-
container: BaseProps;
|
|
543
|
-
sprite: SpriteProps;
|
|
544
|
-
text: TextProps;
|
|
545
|
-
graphics: GraphicsProps;
|
|
546
|
-
animatedSprite: BaseProps & {
|
|
547
|
-
textures?: Texture[];
|
|
548
|
-
animationSpeed?: number;
|
|
549
|
-
loop?: boolean;
|
|
550
|
-
playing?: boolean;
|
|
551
|
-
};
|
|
552
|
-
nineSliceSprite: BaseProps & {
|
|
553
|
-
texture?: string | Texture;
|
|
554
|
-
leftWidth?: number;
|
|
555
|
-
topHeight?: number;
|
|
556
|
-
rightWidth?: number;
|
|
557
|
-
bottomHeight?: number;
|
|
558
|
-
};
|
|
559
|
-
tilingSprite: BaseProps & {
|
|
560
|
-
texture?: string | Texture;
|
|
561
|
-
tilePosition?: {
|
|
562
|
-
x: number;
|
|
563
|
-
y: number;
|
|
564
|
-
};
|
|
565
|
-
};
|
|
566
|
-
button: ButtonComponentProps;
|
|
567
|
-
label: LabelComponentProps;
|
|
568
|
-
labelValue: LabelValueComponentProps;
|
|
569
|
-
panel: PanelComponentProps;
|
|
570
|
-
flexContainer: FlexContainerComponentProps;
|
|
571
|
-
progressBar: ProgressBarComponentProps;
|
|
572
|
-
scrollContainer: ScrollContainerComponentProps;
|
|
573
|
-
modal: ModalComponentProps;
|
|
574
|
-
toast: ToastComponentProps;
|
|
575
|
-
balanceDisplay: BalanceDisplayComponentProps;
|
|
576
|
-
winDisplay: WinDisplayComponentProps;
|
|
577
|
-
layout: LayoutComponentProps;
|
|
578
|
-
slider: SliderComponentProps;
|
|
579
|
-
toggle: ToggleComponentProps;
|
|
597
|
+
interface IntrinsicElements extends EngineIntrinsicElements {
|
|
580
598
|
}
|
|
581
599
|
}
|
|
582
600
|
}
|
|
601
|
+
|
|
602
|
+
export type { AnimatedSpriteProps, BalanceDisplayComponentProps, BaseProps, ButtonComponentProps, EngineIntrinsicElements, FlexContainerComponentProps, GraphicsProps, LabelComponentProps, LabelValueComponentProps, LayoutComponentProps, ModalComponentProps, NineSliceSpriteProps, PanelComponentProps, PixiEventProps, ProgressBarComponentProps, ScrollContainerComponentProps, SliderComponentProps, SpriteProps, TextProps, TilingSpriteProps, ToastComponentProps, ToggleComponentProps, WinDisplayComponentProps };
|
package/dist/react.cjs.js
CHANGED
|
@@ -820,30 +820,35 @@ class FlexContainer extends pixi_js.Container {
|
|
|
820
820
|
this._computedHeight = this._explicitHeight > 0 ? this._explicitHeight : (pt + naturalMainSize + pb);
|
|
821
821
|
}
|
|
822
822
|
// Position flexExclude children (absolute positioning).
|
|
823
|
-
// All position props describe the visual (bounds) rectangle
|
|
824
|
-
//
|
|
823
|
+
// All position props describe the visual (bounds) rectangle. We derive the
|
|
824
|
+
// visual rectangle directly from `getLocalBounds()` rather than the
|
|
825
|
+
// layout-config `w`/`h` returned by measureChild — those may differ from
|
|
826
|
+
// actual bounds when the user pins `layoutWidth`/`layoutHeight` to a value
|
|
827
|
+
// that doesn't match the child's real visual extent (e.g. a Button whose
|
|
828
|
+
// text overflows its configured `width`). Mixing layout size with real
|
|
829
|
+
// bounds-origin would shift the visual center off the requested point.
|
|
825
830
|
// `centerX/centerY` take precedence over `left/right` / `top/bottom` on each axis.
|
|
826
831
|
for (const child of this._layoutChildren) {
|
|
827
832
|
if (!child._flexConfig?.flexExclude)
|
|
828
833
|
continue;
|
|
829
834
|
const cfg = child._flexConfig;
|
|
830
|
-
const
|
|
835
|
+
const bounds = child.getLocalBounds();
|
|
831
836
|
const cw = this._computedWidth;
|
|
832
837
|
const ch = this._computedHeight;
|
|
833
838
|
const centerX = resolveDimension(cfg.centerX, pctRefW);
|
|
834
839
|
if (centerX !== undefined)
|
|
835
|
-
child.x = centerX -
|
|
840
|
+
child.x = centerX - bounds.x - bounds.width / 2;
|
|
836
841
|
else if (cfg.left !== undefined)
|
|
837
|
-
child.x = cfg.left -
|
|
842
|
+
child.x = cfg.left - bounds.x;
|
|
838
843
|
else if (cfg.right !== undefined)
|
|
839
|
-
child.x = cw -
|
|
844
|
+
child.x = cw - cfg.right - bounds.x - bounds.width;
|
|
840
845
|
const centerY = resolveDimension(cfg.centerY, pctRefH);
|
|
841
846
|
if (centerY !== undefined)
|
|
842
|
-
child.y = centerY -
|
|
847
|
+
child.y = centerY - bounds.y - bounds.height / 2;
|
|
843
848
|
else if (cfg.top !== undefined)
|
|
844
|
-
child.y = cfg.top -
|
|
849
|
+
child.y = cfg.top - bounds.y;
|
|
845
850
|
else if (cfg.bottom !== undefined)
|
|
846
|
-
child.y = ch -
|
|
851
|
+
child.y = ch - cfg.bottom - bounds.y - bounds.height;
|
|
847
852
|
}
|
|
848
853
|
}
|
|
849
854
|
/** Computed content size (after layout) */
|