@energy8platform/shell 0.2.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 (67) hide show
  1. package/dist/html.cjs.js +3894 -0
  2. package/dist/html.cjs.js.map +1 -0
  3. package/dist/html.d.ts +616 -0
  4. package/dist/html.esm.js +3879 -0
  5. package/dist/html.esm.js.map +1 -0
  6. package/dist/index.cjs.js +1593 -0
  7. package/dist/index.cjs.js.map +1 -0
  8. package/dist/index.d.ts +554 -0
  9. package/dist/index.esm.js +1582 -0
  10. package/dist/index.esm.js.map +1 -0
  11. package/dist/pixi.cjs.js +5740 -0
  12. package/dist/pixi.cjs.js.map +1 -0
  13. package/dist/pixi.d.ts +682 -0
  14. package/dist/pixi.esm.js +5726 -0
  15. package/dist/pixi.esm.js.map +1 -0
  16. package/package.json +79 -0
  17. package/src/core/EventEmitter.ts +55 -0
  18. package/src/core/ShellController.ts +234 -0
  19. package/src/core/colors.ts +32 -0
  20. package/src/core/fonts-digits.ts +12 -0
  21. package/src/core/fonts.ts +13 -0
  22. package/src/core/format.ts +39 -0
  23. package/src/core/i18n.ts +96 -0
  24. package/src/core/index.ts +35 -0
  25. package/src/core/keyboard.ts +229 -0
  26. package/src/core/locales.ts +864 -0
  27. package/src/core/motion.ts +10 -0
  28. package/src/core/renderer.ts +121 -0
  29. package/src/core/state.ts +31 -0
  30. package/src/core/theme.ts +81 -0
  31. package/src/core/types.ts +269 -0
  32. package/src/core/version.ts +3 -0
  33. package/src/ui/html/HtmlRenderer.ts +292 -0
  34. package/src/ui/html/components/BottomBar.ts +240 -0
  35. package/src/ui/html/components/BuyBonus.ts +326 -0
  36. package/src/ui/html/components/GameInfo.ts +384 -0
  37. package/src/ui/html/components/Modal.ts +36 -0
  38. package/src/ui/html/components/ReplayModal.ts +58 -0
  39. package/src/ui/html/components/Settings.ts +59 -0
  40. package/src/ui/html/components/pickers.ts +146 -0
  41. package/src/ui/html/icons-preview.svg +224 -0
  42. package/src/ui/html/icons.ts +31 -0
  43. package/src/ui/html/index.ts +36 -0
  44. package/src/ui/html/motion-dom.ts +29 -0
  45. package/src/ui/html/primitives.ts +85 -0
  46. package/src/ui/html/shell.css.ts +528 -0
  47. package/src/ui/html/theme-css.ts +21 -0
  48. package/src/ui/pixi/PixiRenderer.ts +350 -0
  49. package/src/ui/pixi/components/BottomBar.ts +477 -0
  50. package/src/ui/pixi/components/BuyBonus.ts +763 -0
  51. package/src/ui/pixi/components/GameInfo.ts +559 -0
  52. package/src/ui/pixi/components/Modal.ts +40 -0
  53. package/src/ui/pixi/components/ReplayModal.ts +80 -0
  54. package/src/ui/pixi/components/Settings.ts +117 -0
  55. package/src/ui/pixi/components/pickers.ts +170 -0
  56. package/src/ui/pixi/context.ts +52 -0
  57. package/src/ui/pixi/icons.ts +45 -0
  58. package/src/ui/pixi/index.ts +56 -0
  59. package/src/ui/pixi/motion-pixi.ts +58 -0
  60. package/src/ui/pixi/pixi-icon.ts +119 -0
  61. package/src/ui/pixi/primitives/card.ts +227 -0
  62. package/src/ui/pixi/primitives/controls.ts +243 -0
  63. package/src/ui/pixi/primitives/flex.ts +335 -0
  64. package/src/ui/pixi/primitives/overlay.ts +181 -0
  65. package/src/ui/pixi/primitives/scroll.ts +117 -0
  66. package/src/ui/pixi/primitives/widgets.ts +680 -0
  67. package/src/ui/pixi/text.ts +131 -0
@@ -0,0 +1,10 @@
1
+ /** True when the user (or environment) prefers no motion. Missing matchMedia (jsdom/SSR) is
2
+ * treated as reduced so animations never block. */
3
+ export function prefersReducedMotion(): boolean {
4
+ const mm = (globalThis as { matchMedia?: (q: string) => { matches: boolean } }).matchMedia;
5
+ if (typeof mm !== 'function') return true;
6
+ return mm('(prefers-reduced-motion: reduce)').matches;
7
+ }
8
+
9
+ export const easeOutCubic = (p: number): number => 1 - Math.pow(1 - p, 3);
10
+ export const easeInOutQuad = (p: number): number => (p < 0.5 ? 2 * p * p : 1 - Math.pow(-2 * p + 2, 2) / 2);
@@ -0,0 +1,121 @@
1
+ import type { EventEmitter } from './EventEmitter';
2
+ import type { ShellTokens } from './theme';
3
+ import type {
4
+ ResolvedShellConfig, ShellState, ShellEvents, BonusOption,
5
+ ModalOptions, ReplayModalOptions,
6
+ } from './types';
7
+
8
+ export type ShellLayoutMode = 'wide' | 'mobile';
9
+
10
+ /** The view side the controller drives. A renderer holds its own mount target (DOM element /
11
+ * Pixi app) and translates state → pixels; it never owns logic. */
12
+ export interface ShellRenderer {
13
+ /** Bind to the brain. Called once during createShell, before the first renderBar. */
14
+ mount(host: ShellHost): void;
15
+ /** (Re)build the bottom bar from host.state. MUST cancel any in-flight money count-up first. */
16
+ renderBar(): void;
17
+ /** Switch bar layout. The controller derives wide|mobile from host.notifyResize. */
18
+ setLayout(layout: ShellLayoutMode): void;
19
+ /** Apply colour tokens (CSS vars in DOM / repaint in Pixi). */
20
+ applyTheme(tokens: ShellTokens): void;
21
+ /** Count a money readout from→to on the freshly-rendered bar (DOM rAF / Pixi ticker). */
22
+ animateMoney(field: 'balance' | 'win', from: number, to: number): void;
23
+ /** Build + show an overlay from a controller-supplied model; return a handle for key routing
24
+ * and programmatic close. Returns void when nothing was shown. */
25
+ openOverlay(req: OverlayRequest): OverlayHandle | void;
26
+ /** Tear down any open overlay. */
27
+ closeOverlay(): void;
28
+ /** If the open overlay registered a sound-icon refresher, the controller calls this to refresh it. */
29
+ refreshSoundIcon?(on: boolean): void;
30
+ /** Fade out + remove all nodes; resolve when gone. */
31
+ destroy(): Promise<void> | void;
32
+
33
+ // ── optional surface facade ──────────────────────────────────────────────
34
+ // A renderer that draws a bottom bar exposes these so an embedding host can reserve space for it
35
+ // and toggle the whole shell. createShell() forwards them onto the returned shell (with inert
36
+ // defaults when a renderer omits them), so every renderer — built-in or custom — is host-drivable.
37
+ /** Insets a scene should avoid (only the bottom bar is reserved; the rest is full-bleed). */
38
+ readonly safeArea?: SafeArea;
39
+ /** Height of the bottom control bar in px (0 before first layout / when there's no bar). */
40
+ readonly barHeight?: number;
41
+ /** Show/hide the whole shell (bar + overlays). */
42
+ setVisible?(visible: boolean): void;
43
+ }
44
+
45
+ /** Bottom-bar inset a host reserves for scene content. */
46
+ export interface SafeArea {
47
+ top: number;
48
+ right: number;
49
+ bottom: number;
50
+ left: number;
51
+ }
52
+
53
+ /** The surface facade createShell() guarantees on the returned shell, delegating to the renderer
54
+ * (inert defaults when the renderer omits a member). Hosts embedding a shell read these. */
55
+ export interface ShellSurface {
56
+ readonly safeArea: SafeArea;
57
+ readonly barHeight: number;
58
+ setVisible(visible: boolean): void;
59
+ }
60
+
61
+ /** What the renderer (and its components) read from the brain. */
62
+ export interface ShellHost {
63
+ readonly state: ShellState;
64
+ readonly config: ResolvedShellConfig;
65
+ readonly tokens: ShellTokens;
66
+ readonly layout: ShellLayoutMode;
67
+ readonly soundOn: boolean;
68
+ /** Resolve a built-in string (translation + optional socialize). */
69
+ t(text: string): string;
70
+ /** Currency-aware money formatting (win=true ⇒ variable decimals). */
71
+ formatCurrency(n: number, win?: boolean): string;
72
+ /** Typed event emit — same signature as the shells. */
73
+ emit: EventEmitter<ShellEvents>['emit'];
74
+ /** Renderer reports its surface size; the controller recomputes layout + re-renders. */
75
+ notifyResize(w: number, h: number): void;
76
+ /** Flip shared sound state (emits settingChange + refreshes an open Settings icon). */
77
+ setSound(on: boolean): void;
78
+ /** An open Settings overlay registers an icon updater here (null clears it on close). */
79
+ setSoundRefresh(fn: ((on: boolean) => void) | null): void;
80
+ /** Logic-bearing actions invoked by renderer controls. */
81
+ readonly actions: ShellActions;
82
+ }
83
+
84
+ /** Every state-changing thing a control can do. Each runs logic in the controller, emits the
85
+ * matching event, and triggers a re-render. Renderers MUST route input through these. */
86
+ export interface ShellActions {
87
+ spin(): void;
88
+ stepBet(dir: 1 | -1): void;
89
+ setBet(n: number): void;
90
+ cycleTurbo(): void;
91
+ toggleAutoplay(): void;
92
+ startAutoplay(remaining: number): void;
93
+ stopAutoplay(): void;
94
+ openMenu(): void;
95
+ openSettings(): void;
96
+ openInfo(): void;
97
+ openBuyBonus(): void;
98
+ openBetPicker(): void;
99
+ openAutoplayPicker(): void;
100
+ selectBuyBonus(id: string): void;
101
+ activateFeature(b: BonusOption): void;
102
+ deactivateFeature(): void;
103
+ setSound(on: boolean): void;
104
+ closeOverlay(): void;
105
+ }
106
+
107
+ export interface OverlayHandle {
108
+ /** Overlay-specific keys (e.g. arrows in a picker). Return true to consume. */
109
+ onKey?(e: KeyboardEvent): boolean;
110
+ /** Programmatically close this overlay. */
111
+ close(): void;
112
+ }
113
+
114
+ export type OverlayRequest =
115
+ | { kind: 'settings' }
116
+ | { kind: 'gameInfo' }
117
+ | { kind: 'buyBonus' }
118
+ | { kind: 'betPicker' }
119
+ | { kind: 'autoplayPicker' }
120
+ | { kind: 'replay'; opts: ReplayModalOptions }
121
+ | { kind: 'modal'; opts: ModalOptions };
@@ -0,0 +1,31 @@
1
+ import type { ShellConfig, ShellState } from './types';
2
+
3
+ export function createInitialState(config: ShellConfig): ShellState {
4
+ return {
5
+ mode: config.mode,
6
+ replay: config.replay ?? config.mode === 'replay',
7
+ balance: config.balance,
8
+ win: config.win,
9
+ bet: config.currentBet ?? config.defaultBet,
10
+ availableBets: [...config.availableBets],
11
+ busy: false,
12
+ autoplay: { active: false, remaining: 0 },
13
+ turbo: 0,
14
+ buyBonusEnabled: true,
15
+ freeSpins: { current: 0, total: 0, totalWin: 0 },
16
+ activeFeature: null,
17
+ };
18
+ }
19
+
20
+ /** Step bet up/down within availableBets, clamped at the ends. */
21
+ export function stepBet(state: ShellState, direction: 1 | -1): number {
22
+ const idx = state.availableBets.indexOf(state.bet);
23
+ const next = Math.max(0, Math.min(state.availableBets.length - 1, idx + direction));
24
+ return state.availableBets[next];
25
+ }
26
+
27
+ /** Cycle turbo level 0..maxLevels (wraps back to 0). */
28
+ export function nextTurbo(current: number, maxLevels: number): number {
29
+ if (maxLevels <= 0) return 0;
30
+ return current >= maxLevels ? 0 : current + 1;
31
+ }
@@ -0,0 +1,81 @@
1
+ import type { ThemeConfig } from './types';
2
+ import { BRAND_ACCENT } from './colors';
3
+
4
+ // Ported 1:1 from platform-core/src/shell/theme.ts. The DOM shell emits these as CSS custom
5
+ // properties; the Pixi shell resolves them to plain colour strings (Pixi's Color accepts hex
6
+ // AND rgba()/rgb() strings) so every surface paints with the exact same value.
7
+
8
+ export const DEFAULT_ACCENT = BRAND_ACCENT; // brand purple — BUY BONUS + active states (single source: colors.ts)
9
+
10
+ const PALETTE = {
11
+ dark: {
12
+ fg: '#f3f5fa', muted: '#9aa3b6', icon: '#c7cedb', iconActive: '#ffffff',
13
+ surface: '#0c111c', hairline: 'rgba(255,255,255,.07)',
14
+ veil: 'rgba(255,255,255,.05)', veilStrong: 'rgba(255,255,255,.1)', track: 'rgba(255,255,255,.16)',
15
+ soft: '#dfe4ee', spin: '#f4f6fb', spinFg: '#141a28',
16
+ },
17
+ light: {
18
+ fg: '#15202e', muted: '#5a6678', icon: '#3c4658', iconActive: '#0b1220',
19
+ surface: '#eef1f7', hairline: 'rgba(15,23,42,.12)',
20
+ veil: 'rgba(15,23,42,.05)', veilStrong: 'rgba(15,23,42,.09)', track: 'rgba(15,23,42,.22)',
21
+ soft: '#3a4453', spin: '#1c2434', spinFg: '#f3f6fb',
22
+ },
23
+ } as const;
24
+
25
+ /** Resolved colour tokens for the shell — scheme palette + the scheme-independent
26
+ * "plaque" language shared by the control bar and overlays, plus the game-overridable accent. */
27
+ export interface ShellTokens {
28
+ fg: string;
29
+ muted: string;
30
+ icon: string;
31
+ iconActive: string;
32
+ surface: string;
33
+ hairline: string;
34
+ veil: string;
35
+ veilStrong: string;
36
+ track: string;
37
+ soft: string;
38
+ spin: string;
39
+ spinFg: string;
40
+ // Plaque tokens (always dark, white-on-dark) — identical in both schemes so the bar +
41
+ // overlays stay visually identical regardless of the dark/light scheme.
42
+ plaqueDark: string;
43
+ plaqueGlass: string;
44
+ plaqueGlassHover: string;
45
+ plaqueSolid: string;
46
+ plaqueLine: string;
47
+ plaqueLabel: string;
48
+ // The continuous desktop control-bar surface + the white-disc buttons that sit on it.
49
+ bar: string;
50
+ btn: string;
51
+ btnInk: string;
52
+ accent: string;
53
+ // Fixed chrome colours used inline by the CSS (frosted backdrop tint, ways win/lose ticks).
54
+ backdrop: string;
55
+ white: string;
56
+ winOk: string;
57
+ winNo: string;
58
+ }
59
+
60
+ export const SCHEMES = ['dark', 'light'] as const;
61
+
62
+ export function resolveTheme(theme: ThemeConfig = {}): ShellTokens {
63
+ const p = PALETTE[theme.scheme === 'light' ? 'light' : 'dark'];
64
+ return {
65
+ ...p,
66
+ plaqueDark: 'rgba(6,9,15,.86)',
67
+ plaqueGlass: 'rgba(30,36,48,.70)',
68
+ plaqueGlassHover: 'rgba(40,48,64,.86)',
69
+ plaqueSolid: '#1a2030',
70
+ plaqueLine: 'rgba(255,255,255,.22)',
71
+ plaqueLabel: 'rgba(255,255,255,.6)',
72
+ bar: 'rgba(6,9,15,.86)',
73
+ btn: '#f4f6fb',
74
+ btnInk: '#0b0e16',
75
+ accent: theme.accent ?? DEFAULT_ACCENT,
76
+ backdrop: 'rgba(12,17,28,.5)',
77
+ white: '#ffffff',
78
+ winOk: '#4ade80',
79
+ winNo: '#f87171',
80
+ };
81
+ }
@@ -0,0 +1,269 @@
1
+ export type ShellMode = 'base' | 'freeSpins' | 'replay';
2
+
3
+ export interface CurrencyConfig {
4
+ symbol: string;
5
+ position: 'left' | 'right';
6
+ /** Maximum fraction digits (default 2). Win / total-win readouts are rounded to this precision;
7
+ * balance / bet / prices stay fixed at `minDecimals`. */
8
+ maxDecimals?: number;
9
+ /** Minimum fraction digits (defaults to `maxDecimals`). For win / total-win, trailing zeros are
10
+ * trimmed down to this many places so small wins keep their significant digits (e.g. 0.0673)
11
+ * while round amounts stay compact (e.g. 0.30). Everything else is shown at exactly this many. */
12
+ minDecimals?: number;
13
+ separator?: { thousands?: string; decimal?: string };
14
+ }
15
+
16
+ export interface BonusOption {
17
+ id: string;
18
+ /** 'bonus' buys into a bonus round, 'feature' toggles a base-game modifier (e.g. Ante).
19
+ * Drives the card/button label and accent. Defaults to 'bonus'. */
20
+ type?: 'feature' | 'bonus';
21
+ title: string;
22
+ description: string;
23
+ /** Transparent art image shown at the top of the card (no background plate). */
24
+ thumbnail?: string;
25
+ volatility?: 1 | 2 | 3 | 4 | 5;
26
+ /** Card price = priceMultiplier × current bet, rendered in the shell currency. */
27
+ priceMultiplier: number;
28
+ /** Per-option accent override. Falls back to the type default (bonus → purple, feature → gold). */
29
+ accentColor?: string;
30
+ /** Override the card UI. Return the card's inner content; the shell keeps the grid wrapper,
31
+ * accent vars and live re-pricing, and runs the normal buy flow when you call `ctx.select()`.
32
+ * Core uses `unknown`; each renderer re-exports a typed alias (ui/html → HTMLElement,
33
+ * ui/pixi → Container). */
34
+ custom?: (ctx: BonusCardContext) => unknown;
35
+ }
36
+
37
+ /** Context passed to a `BonusOption.custom` renderer. Render the card however you like and wire
38
+ * your own control to `select()` — the buy/confirm flow stays internal to the shell. */
39
+ export interface BonusCardContext {
40
+ bonus: BonusOption;
41
+ /** Current bet. */
42
+ bet: number;
43
+ /** Card price = `bonus.priceMultiplier × bet`. */
44
+ price: number;
45
+ /** `price` formatted in the shell currency. */
46
+ priceText: string;
47
+ /** True when the option can't be bought right now (unaffordable / busy / buy-bonus disabled);
48
+ * reflect it in your UI. `select()` is a no-op while disabled. */
49
+ disabled: boolean;
50
+ /** Card accent (per-option override or the type default); also set as the `--card-acc` CSS var. */
51
+ accent: string;
52
+ /** Proceed through the shell's normal flow: opens the confirm modal, then emits `buyBonusSelect`
53
+ * / activates the feature. No-op while `disabled`. */
54
+ select: () => void;
55
+ }
56
+
57
+ export interface ThemeConfig {
58
+ /** Palette scheme: 'dark' (default) for dark games, 'light' for light backgrounds. */
59
+ scheme?: 'dark' | 'light';
60
+ /** Brand accent — active states, the SPIN hover glow, and the BUY BONUS button.
61
+ * (Per-bonus card accents are set on each `BonusOption.accentColor`.) */
62
+ accent?: string;
63
+ }
64
+
65
+ /** One paytable entry: a symbol (text/image) and its win tiers, rendered "<count> x<multiplier>". */
66
+ export interface PaytableRow {
67
+ symbol: { text?: string; image?: string };
68
+ wins: Array<{ count?: string; multiplier: number }>;
69
+ }
70
+
71
+ /** One payline over a cols×rows grid: the row index (0 = top) the line takes in each column. */
72
+ export interface PaylineDef {
73
+ /** length must equal grid.cols; each value in 0..rows-1 */
74
+ pattern: number[];
75
+ label?: string;
76
+ }
77
+
78
+ /** A single grid cell, 0-based, row 0 = top. */
79
+ export type CellRef = [col: number, row: number];
80
+
81
+ /** A named winning shape: an arbitrary set of grid cells (not one-per-column like a payline),
82
+ * shown as a grid illustration with its name and optional description. */
83
+ export interface ShapeDef {
84
+ /** The lit cells, in any pattern. */
85
+ cells: CellRef[];
86
+ name: string;
87
+ description?: string;
88
+ }
89
+
90
+ /** How a game pays — drives the GameInfo win-section illustration. One section = one kind.
91
+ * `example`/`winExample`/`loseExample` are optional; omit them for an auto-drawn illustration
92
+ * sized to `grid`. */
93
+ export type WinSection = {
94
+ type: 'wins';
95
+ title?: string;
96
+ order?: number;
97
+ grid: { cols: number; rows: number };
98
+ /** Optional prose shown alongside the illustration. */
99
+ description?: string;
100
+ } & (
101
+ | { kind: 'classic'; lines: Array<number[] | PaylineDef> }
102
+ | { kind: 'cluster'; minCount: number; example?: CellRef[] }
103
+ | { kind: 'anywhere'; minCount: number; example?: CellRef[] }
104
+ | { kind: 'ways'; winExample?: CellRef[]; loseExample?: CellRef[] }
105
+ | { kind: 'shapes'; shapes: ShapeDef[] }
106
+ );
107
+
108
+ /** A playable mode / bonus-buy option, shown for comparison (informational only). */
109
+ export interface GameMode {
110
+ title: string;
111
+ price?: string;
112
+ rtp?: number;
113
+ maxWin?: string;
114
+ description?: string;
115
+ }
116
+
117
+ /** A preset game-info section. `order` overrides placement; by default `modes` comes
118
+ * first, `controls` second, and the rest follow in declaration order. */
119
+ export type GameInfoSection =
120
+ | { type: 'modes'; title?: string; order?: number; modes: GameMode[] }
121
+ | { type: 'controls'; title?: string; order?: number }
122
+ | { type: 'hotkeys'; title?: string; order?: number }
123
+ | { type: 'paytable'; title?: string; order?: number; rows: PaytableRow[] }
124
+ | WinSection
125
+ | { type: 'custom'; title?: string; order?: number; node?: unknown; html?: string };
126
+
127
+ export interface GameInfoContent {
128
+ sections?: GameInfoSection[];
129
+ }
130
+
131
+ /** Autoplay limits. Presence of this object (vs `null`) is what enables autoplay. */
132
+ export interface AutoplayConfig {
133
+ /** Maximum selectable spin count in the autoplay picker. Caps the built-in presets and
134
+ * drops the unlimited (∞) choice; if it isn't already a preset it becomes the top choice.
135
+ * Omit for the default presets (including ∞). */
136
+ maxCount?: number;
137
+ }
138
+
139
+ export interface ShellFeatures {
140
+ turbo: 0 | 1 | 2 | 3;
141
+ /** Master keyboard-shortcut switch. Defaults to `true`; set `false` to disable ALL hotkeys
142
+ * (overrides `spacebar` and any future hotkey). */
143
+ hotkeys?: boolean;
144
+ /** Spacebar starts a spin in base mode. Defaults to `true`; set `false` to disable the
145
+ * keyboard shortcut (e.g. jurisdictions that forbid quick-spin keys). */
146
+ spacebar?: boolean;
147
+ /** Autoplay: `null` (or omitted) disables it; an object enables it (optionally with limits). */
148
+ autoplay?: AutoplayConfig | null;
149
+ buyBonus: BonusOption[] | false;
150
+ }
151
+
152
+ export interface AutoplayOptions {
153
+ active: boolean;
154
+ remaining: number;
155
+ }
156
+
157
+ export interface FreeSpinsState {
158
+ /** Spin index for the `current / total` counter. Set to `null` (or omit) to instead show just
159
+ * `total` as a single number — drive a countdown by decrementing `total` each spin. */
160
+ current?: number | null;
161
+ total: number;
162
+ totalWin: number;
163
+ }
164
+
165
+ /** One footer button of a generic modal. Clicking it runs `on` (if any), then closes the modal. */
166
+ export interface ModalAction {
167
+ title: string;
168
+ /** Button fill colour (any CSS colour). Omit for a neutral/secondary button. */
169
+ color?: string;
170
+ on?: () => void;
171
+ }
172
+
173
+ /** Options for `shell.openReplay()` — a non-dismissable replay summary modal.
174
+ * `bonusId` is matched against `features.buyBonus` to label the mode and read the cost
175
+ * multiplier. There is no ✕ and the backdrop never closes it; the only action is START
176
+ * REPLAY, which closes the modal, runs `onReplay`, then reopens it. */
177
+ export interface ReplayModalOptions {
178
+ bonusId: string;
179
+ /** Base bet the replay was recorded at. */
180
+ bet: number;
181
+ payoutMultiplier: number;
182
+ /** Runs after the modal closes; the modal reopens once it resolves (immediately for sync). */
183
+ onReplay: () => void | Promise<void>;
184
+ }
185
+
186
+ /** Options for `shell.openModal()` — a generic, externally-triggered card modal. */
187
+ export interface ModalOptions {
188
+ /** Show the ✕ in the overlay's top-right corner. */
189
+ availableClose: boolean;
190
+ title: string;
191
+ body: string;
192
+ /** Footer buttons; each closes the modal (after running its `on`). */
193
+ actions?: ModalAction[];
194
+ /** Backdrop blur in px (defaults to the shell's standard blur). */
195
+ blurLevel?: number;
196
+ /** Optional keyboard handler — called by the shell keyboard controller while this modal is
197
+ * open. Return true to consume the key (prevents bar actions + Escape close); false to let
198
+ * the controller handle it (Escape → closeModal). */
199
+ onKey?: (e: KeyboardEvent) => boolean;
200
+ }
201
+
202
+ export interface ShellConfig {
203
+ // NOTE: `mount: HTMLElement` is intentionally omitted — mount target is a renderer concern.
204
+ theme?: ThemeConfig;
205
+ gameInfo: GameInfoContent;
206
+ language: string;
207
+ /** Game version shown in the game-info footer (e.g. '1.2.0'). Defaults to '1.0.0'. The footer
208
+ * stamp is `${version}.${engineVersionWithoutDots}` — e.g. game 1.0.0 on engine 0.24.6 → '1.0.0.0246'. */
209
+ version?: string;
210
+ /** When true, all built-in shell text is shown in the social-casino vocabulary (derived from
211
+ * English via word-swap rules), regardless of `language`. Game-supplied content is untouched. */
212
+ isSocial?: boolean;
213
+ currency: CurrencyConfig;
214
+ availableBets: number[];
215
+ defaultBet: number;
216
+ currentBet: number | null;
217
+ balance: number;
218
+ win: number;
219
+ mode: ShellMode;
220
+ /** Mark this shell as a read-only historical-round replay. A replay never shows the player's
221
+ * balance (there's no live wallet), even while its free-spins phase runs in `freeSpins` mode.
222
+ * Defaults to `mode === 'replay'`; set explicitly when a replay starts in another mode. */
223
+ replay?: boolean;
224
+ features: ShellFeatures;
225
+ /** Override the BUY BONUS bar button's action: when set, tapping it calls this instead of
226
+ * opening the built-in buy-bonus overlay (e.g. the game shows its own bonus UI). The button
227
+ * is shown whenever this OR `features.buyBonus` is set. */
228
+ onBonusBuy?: () => void;
229
+ }
230
+
231
+ /** ShellConfig after the controller applies defaults (version, isSocial, replay, theme). No mount. */
232
+ export type ResolvedShellConfig = Required<Pick<ShellConfig,
233
+ 'language' | 'currency' | 'availableBets' | 'defaultBet' | 'balance' | 'win' | 'mode' | 'features' | 'gameInfo' | 'version' | 'isSocial' | 'replay'>>
234
+ & Pick<ShellConfig, 'currentBet' | 'theme' | 'onBonusBuy'>;
235
+
236
+ export interface ShellState {
237
+ mode: ShellMode;
238
+ /** Sticky replay marker — true for a historical-round replay, regardless of the current
239
+ * `mode`. Set once (from config or when `mode` becomes 'replay') and never cleared, since a
240
+ * shell instance is either a live game or a replay viewer for its whole lifetime. */
241
+ replay: boolean;
242
+ balance: number;
243
+ win: number;
244
+ bet: number;
245
+ availableBets: number[];
246
+ busy: boolean;
247
+ autoplay: AutoplayOptions;
248
+ turbo: number;
249
+ buyBonusEnabled: boolean;
250
+ freeSpins: FreeSpinsState;
251
+ /** The currently activated `feature` option (e.g. Ante), or null. Drives the
252
+ * effective-bet readout tint and the BUY BONUS → DISABLE toggle on the bar. */
253
+ activeFeature: BonusOption | null;
254
+ }
255
+
256
+ export interface ShellEvents {
257
+ spin: void;
258
+ betChange: number;
259
+ autoplayStart: AutoplayOptions;
260
+ autoplayStop: void;
261
+ turboChange: number;
262
+ buyBonusSelect: { id: string };
263
+ featureActivate: { id: string };
264
+ featureDeactivate: { id: string };
265
+ menuOpen: void;
266
+ settingsOpen: void;
267
+ infoOpen: void;
268
+ settingChange: { key: string; value: unknown };
269
+ }
@@ -0,0 +1,3 @@
1
+ // AUTO-GENERATED by scripts/gen-version.mjs — do not edit. Mirrors package.json "version".
2
+ /** The @energy8platform/shell package version, stamped into the game-info footer. */
3
+ export const PACKAGE_VERSION = '0.2.0';