@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
package/dist/pixi.d.ts ADDED
@@ -0,0 +1,682 @@
1
+ import { Container, Application } from 'pixi.js';
2
+
3
+ /**
4
+ * Minimal typed event emitter — internal utility for platform-core.
5
+ *
6
+ * Supports `void` event types — events that carry no data can be emitted
7
+ * without arguments: `emitter.emit('eventName')`.
8
+ *
9
+ * Mirrors the EventEmitter shipped from game-engine's core, copied here
10
+ * so platform-core has no upward dependency on game-engine.
11
+ */
12
+ declare class EventEmitter<TEvents extends {}> {
13
+ private listeners;
14
+ on<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
15
+ once<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
16
+ off<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): this;
17
+ emit<K extends keyof TEvents>(...args: TEvents[K] extends void ? [event: K] : [event: K, data: TEvents[K]]): void;
18
+ removeAllListeners(event?: keyof TEvents): this;
19
+ }
20
+
21
+ type ShellMode = 'base' | 'freeSpins' | 'replay';
22
+ interface CurrencyConfig {
23
+ symbol: string;
24
+ position: 'left' | 'right';
25
+ /** Maximum fraction digits (default 2). Win / total-win readouts are rounded to this precision;
26
+ * balance / bet / prices stay fixed at `minDecimals`. */
27
+ maxDecimals?: number;
28
+ /** Minimum fraction digits (defaults to `maxDecimals`). For win / total-win, trailing zeros are
29
+ * trimmed down to this many places so small wins keep their significant digits (e.g. 0.0673)
30
+ * while round amounts stay compact (e.g. 0.30). Everything else is shown at exactly this many. */
31
+ minDecimals?: number;
32
+ separator?: {
33
+ thousands?: string;
34
+ decimal?: string;
35
+ };
36
+ }
37
+ interface BonusOption$1 {
38
+ id: string;
39
+ /** 'bonus' buys into a bonus round, 'feature' toggles a base-game modifier (e.g. Ante).
40
+ * Drives the card/button label and accent. Defaults to 'bonus'. */
41
+ type?: 'feature' | 'bonus';
42
+ title: string;
43
+ description: string;
44
+ /** Transparent art image shown at the top of the card (no background plate). */
45
+ thumbnail?: string;
46
+ volatility?: 1 | 2 | 3 | 4 | 5;
47
+ /** Card price = priceMultiplier × current bet, rendered in the shell currency. */
48
+ priceMultiplier: number;
49
+ /** Per-option accent override. Falls back to the type default (bonus → purple, feature → gold). */
50
+ accentColor?: string;
51
+ /** Override the card UI. Return the card's inner content; the shell keeps the grid wrapper,
52
+ * accent vars and live re-pricing, and runs the normal buy flow when you call `ctx.select()`.
53
+ * Core uses `unknown`; each renderer re-exports a typed alias (ui/html → HTMLElement,
54
+ * ui/pixi → Container). */
55
+ custom?: (ctx: BonusCardContext) => unknown;
56
+ }
57
+ /** Context passed to a `BonusOption.custom` renderer. Render the card however you like and wire
58
+ * your own control to `select()` — the buy/confirm flow stays internal to the shell. */
59
+ interface BonusCardContext {
60
+ bonus: BonusOption$1;
61
+ /** Current bet. */
62
+ bet: number;
63
+ /** Card price = `bonus.priceMultiplier × bet`. */
64
+ price: number;
65
+ /** `price` formatted in the shell currency. */
66
+ priceText: string;
67
+ /** True when the option can't be bought right now (unaffordable / busy / buy-bonus disabled);
68
+ * reflect it in your UI. `select()` is a no-op while disabled. */
69
+ disabled: boolean;
70
+ /** Card accent (per-option override or the type default); also set as the `--card-acc` CSS var. */
71
+ accent: string;
72
+ /** Proceed through the shell's normal flow: opens the confirm modal, then emits `buyBonusSelect`
73
+ * / activates the feature. No-op while `disabled`. */
74
+ select: () => void;
75
+ }
76
+ interface ThemeConfig {
77
+ /** Palette scheme: 'dark' (default) for dark games, 'light' for light backgrounds. */
78
+ scheme?: 'dark' | 'light';
79
+ /** Brand accent — active states, the SPIN hover glow, and the BUY BONUS button.
80
+ * (Per-bonus card accents are set on each `BonusOption.accentColor`.) */
81
+ accent?: string;
82
+ }
83
+ /** One paytable entry: a symbol (text/image) and its win tiers, rendered "<count> x<multiplier>". */
84
+ interface PaytableRow {
85
+ symbol: {
86
+ text?: string;
87
+ image?: string;
88
+ };
89
+ wins: Array<{
90
+ count?: string;
91
+ multiplier: number;
92
+ }>;
93
+ }
94
+ /** One payline over a cols×rows grid: the row index (0 = top) the line takes in each column. */
95
+ interface PaylineDef {
96
+ /** length must equal grid.cols; each value in 0..rows-1 */
97
+ pattern: number[];
98
+ label?: string;
99
+ }
100
+ /** A single grid cell, 0-based, row 0 = top. */
101
+ type CellRef = [col: number, row: number];
102
+ /** A named winning shape: an arbitrary set of grid cells (not one-per-column like a payline),
103
+ * shown as a grid illustration with its name and optional description. */
104
+ interface ShapeDef {
105
+ /** The lit cells, in any pattern. */
106
+ cells: CellRef[];
107
+ name: string;
108
+ description?: string;
109
+ }
110
+ /** How a game pays — drives the GameInfo win-section illustration. One section = one kind.
111
+ * `example`/`winExample`/`loseExample` are optional; omit them for an auto-drawn illustration
112
+ * sized to `grid`. */
113
+ type WinSection = {
114
+ type: 'wins';
115
+ title?: string;
116
+ order?: number;
117
+ grid: {
118
+ cols: number;
119
+ rows: number;
120
+ };
121
+ /** Optional prose shown alongside the illustration. */
122
+ description?: string;
123
+ } & ({
124
+ kind: 'classic';
125
+ lines: Array<number[] | PaylineDef>;
126
+ } | {
127
+ kind: 'cluster';
128
+ minCount: number;
129
+ example?: CellRef[];
130
+ } | {
131
+ kind: 'anywhere';
132
+ minCount: number;
133
+ example?: CellRef[];
134
+ } | {
135
+ kind: 'ways';
136
+ winExample?: CellRef[];
137
+ loseExample?: CellRef[];
138
+ } | {
139
+ kind: 'shapes';
140
+ shapes: ShapeDef[];
141
+ });
142
+ /** A playable mode / bonus-buy option, shown for comparison (informational only). */
143
+ interface GameMode {
144
+ title: string;
145
+ price?: string;
146
+ rtp?: number;
147
+ maxWin?: string;
148
+ description?: string;
149
+ }
150
+ /** A preset game-info section. `order` overrides placement; by default `modes` comes
151
+ * first, `controls` second, and the rest follow in declaration order. */
152
+ type GameInfoSection$1 = {
153
+ type: 'modes';
154
+ title?: string;
155
+ order?: number;
156
+ modes: GameMode[];
157
+ } | {
158
+ type: 'controls';
159
+ title?: string;
160
+ order?: number;
161
+ } | {
162
+ type: 'hotkeys';
163
+ title?: string;
164
+ order?: number;
165
+ } | {
166
+ type: 'paytable';
167
+ title?: string;
168
+ order?: number;
169
+ rows: PaytableRow[];
170
+ } | WinSection | {
171
+ type: 'custom';
172
+ title?: string;
173
+ order?: number;
174
+ node?: unknown;
175
+ html?: string;
176
+ };
177
+ interface GameInfoContent {
178
+ sections?: GameInfoSection$1[];
179
+ }
180
+ /** Autoplay limits. Presence of this object (vs `null`) is what enables autoplay. */
181
+ interface AutoplayConfig {
182
+ /** Maximum selectable spin count in the autoplay picker. Caps the built-in presets and
183
+ * drops the unlimited (∞) choice; if it isn't already a preset it becomes the top choice.
184
+ * Omit for the default presets (including ∞). */
185
+ maxCount?: number;
186
+ }
187
+ interface ShellFeatures {
188
+ turbo: 0 | 1 | 2 | 3;
189
+ /** Master keyboard-shortcut switch. Defaults to `true`; set `false` to disable ALL hotkeys
190
+ * (overrides `spacebar` and any future hotkey). */
191
+ hotkeys?: boolean;
192
+ /** Spacebar starts a spin in base mode. Defaults to `true`; set `false` to disable the
193
+ * keyboard shortcut (e.g. jurisdictions that forbid quick-spin keys). */
194
+ spacebar?: boolean;
195
+ /** Autoplay: `null` (or omitted) disables it; an object enables it (optionally with limits). */
196
+ autoplay?: AutoplayConfig | null;
197
+ buyBonus: BonusOption$1[] | false;
198
+ }
199
+ interface AutoplayOptions {
200
+ active: boolean;
201
+ remaining: number;
202
+ }
203
+ interface FreeSpinsState {
204
+ /** Spin index for the `current / total` counter. Set to `null` (or omit) to instead show just
205
+ * `total` as a single number — drive a countdown by decrementing `total` each spin. */
206
+ current?: number | null;
207
+ total: number;
208
+ totalWin: number;
209
+ }
210
+ /** One footer button of a generic modal. Clicking it runs `on` (if any), then closes the modal. */
211
+ interface ModalAction {
212
+ title: string;
213
+ /** Button fill colour (any CSS colour). Omit for a neutral/secondary button. */
214
+ color?: string;
215
+ on?: () => void;
216
+ }
217
+ /** Options for `shell.openReplay()` — a non-dismissable replay summary modal.
218
+ * `bonusId` is matched against `features.buyBonus` to label the mode and read the cost
219
+ * multiplier. There is no ✕ and the backdrop never closes it; the only action is START
220
+ * REPLAY, which closes the modal, runs `onReplay`, then reopens it. */
221
+ interface ReplayModalOptions {
222
+ bonusId: string;
223
+ /** Base bet the replay was recorded at. */
224
+ bet: number;
225
+ payoutMultiplier: number;
226
+ /** Runs after the modal closes; the modal reopens once it resolves (immediately for sync). */
227
+ onReplay: () => void | Promise<void>;
228
+ }
229
+ /** Options for `shell.openModal()` — a generic, externally-triggered card modal. */
230
+ interface ModalOptions {
231
+ /** Show the ✕ in the overlay's top-right corner. */
232
+ availableClose: boolean;
233
+ title: string;
234
+ body: string;
235
+ /** Footer buttons; each closes the modal (after running its `on`). */
236
+ actions?: ModalAction[];
237
+ /** Backdrop blur in px (defaults to the shell's standard blur). */
238
+ blurLevel?: number;
239
+ /** Optional keyboard handler — called by the shell keyboard controller while this modal is
240
+ * open. Return true to consume the key (prevents bar actions + Escape close); false to let
241
+ * the controller handle it (Escape → closeModal). */
242
+ onKey?: (e: KeyboardEvent) => boolean;
243
+ }
244
+ interface ShellConfig {
245
+ theme?: ThemeConfig;
246
+ gameInfo: GameInfoContent;
247
+ language: string;
248
+ /** Game version shown in the game-info footer (e.g. '1.2.0'). Defaults to '1.0.0'. The footer
249
+ * stamp is `${version}.${engineVersionWithoutDots}` — e.g. game 1.0.0 on engine 0.24.6 → '1.0.0.0246'. */
250
+ version?: string;
251
+ /** When true, all built-in shell text is shown in the social-casino vocabulary (derived from
252
+ * English via word-swap rules), regardless of `language`. Game-supplied content is untouched. */
253
+ isSocial?: boolean;
254
+ currency: CurrencyConfig;
255
+ availableBets: number[];
256
+ defaultBet: number;
257
+ currentBet: number | null;
258
+ balance: number;
259
+ win: number;
260
+ mode: ShellMode;
261
+ /** Mark this shell as a read-only historical-round replay. A replay never shows the player's
262
+ * balance (there's no live wallet), even while its free-spins phase runs in `freeSpins` mode.
263
+ * Defaults to `mode === 'replay'`; set explicitly when a replay starts in another mode. */
264
+ replay?: boolean;
265
+ features: ShellFeatures;
266
+ /** Override the BUY BONUS bar button's action: when set, tapping it calls this instead of
267
+ * opening the built-in buy-bonus overlay (e.g. the game shows its own bonus UI). The button
268
+ * is shown whenever this OR `features.buyBonus` is set. */
269
+ onBonusBuy?: () => void;
270
+ }
271
+ /** ShellConfig after the controller applies defaults (version, isSocial, replay, theme). No mount. */
272
+ type ResolvedShellConfig = Required<Pick<ShellConfig, 'language' | 'currency' | 'availableBets' | 'defaultBet' | 'balance' | 'win' | 'mode' | 'features' | 'gameInfo' | 'version' | 'isSocial' | 'replay'>> & Pick<ShellConfig, 'currentBet' | 'theme' | 'onBonusBuy'>;
273
+ interface ShellState {
274
+ mode: ShellMode;
275
+ /** Sticky replay marker — true for a historical-round replay, regardless of the current
276
+ * `mode`. Set once (from config or when `mode` becomes 'replay') and never cleared, since a
277
+ * shell instance is either a live game or a replay viewer for its whole lifetime. */
278
+ replay: boolean;
279
+ balance: number;
280
+ win: number;
281
+ bet: number;
282
+ availableBets: number[];
283
+ busy: boolean;
284
+ autoplay: AutoplayOptions;
285
+ turbo: number;
286
+ buyBonusEnabled: boolean;
287
+ freeSpins: FreeSpinsState;
288
+ /** The currently activated `feature` option (e.g. Ante), or null. Drives the
289
+ * effective-bet readout tint and the BUY BONUS → DISABLE toggle on the bar. */
290
+ activeFeature: BonusOption$1 | null;
291
+ }
292
+ interface ShellEvents {
293
+ spin: void;
294
+ betChange: number;
295
+ autoplayStart: AutoplayOptions;
296
+ autoplayStop: void;
297
+ turboChange: number;
298
+ buyBonusSelect: {
299
+ id: string;
300
+ };
301
+ featureActivate: {
302
+ id: string;
303
+ };
304
+ featureDeactivate: {
305
+ id: string;
306
+ };
307
+ menuOpen: void;
308
+ settingsOpen: void;
309
+ infoOpen: void;
310
+ settingChange: {
311
+ key: string;
312
+ value: unknown;
313
+ };
314
+ }
315
+
316
+ declare const DEFAULT_ACCENT = "#8b5cf6";
317
+ /** Resolved colour tokens for the shell — scheme palette + the scheme-independent
318
+ * "plaque" language shared by the control bar and overlays, plus the game-overridable accent. */
319
+ interface ShellTokens {
320
+ fg: string;
321
+ muted: string;
322
+ icon: string;
323
+ iconActive: string;
324
+ surface: string;
325
+ hairline: string;
326
+ veil: string;
327
+ veilStrong: string;
328
+ track: string;
329
+ soft: string;
330
+ spin: string;
331
+ spinFg: string;
332
+ plaqueDark: string;
333
+ plaqueGlass: string;
334
+ plaqueGlassHover: string;
335
+ plaqueSolid: string;
336
+ plaqueLine: string;
337
+ plaqueLabel: string;
338
+ bar: string;
339
+ btn: string;
340
+ btnInk: string;
341
+ accent: string;
342
+ backdrop: string;
343
+ white: string;
344
+ winOk: string;
345
+ winNo: string;
346
+ }
347
+ declare const SCHEMES: readonly ["dark", "light"];
348
+ declare function resolveTheme(theme?: ThemeConfig): ShellTokens;
349
+
350
+ type ShellLayoutMode = 'wide' | 'mobile';
351
+ /** The view side the controller drives. A renderer holds its own mount target (DOM element /
352
+ * Pixi app) and translates state → pixels; it never owns logic. */
353
+ interface ShellRenderer {
354
+ /** Bind to the brain. Called once during createShell, before the first renderBar. */
355
+ mount(host: ShellHost): void;
356
+ /** (Re)build the bottom bar from host.state. MUST cancel any in-flight money count-up first. */
357
+ renderBar(): void;
358
+ /** Switch bar layout. The controller derives wide|mobile from host.notifyResize. */
359
+ setLayout(layout: ShellLayoutMode): void;
360
+ /** Apply colour tokens (CSS vars in DOM / repaint in Pixi). */
361
+ applyTheme(tokens: ShellTokens): void;
362
+ /** Count a money readout from→to on the freshly-rendered bar (DOM rAF / Pixi ticker). */
363
+ animateMoney(field: 'balance' | 'win', from: number, to: number): void;
364
+ /** Build + show an overlay from a controller-supplied model; return a handle for key routing
365
+ * and programmatic close. Returns void when nothing was shown. */
366
+ openOverlay(req: OverlayRequest): OverlayHandle | void;
367
+ /** Tear down any open overlay. */
368
+ closeOverlay(): void;
369
+ /** If the open overlay registered a sound-icon refresher, the controller calls this to refresh it. */
370
+ refreshSoundIcon?(on: boolean): void;
371
+ /** Fade out + remove all nodes; resolve when gone. */
372
+ destroy(): Promise<void> | void;
373
+ /** Insets a scene should avoid (only the bottom bar is reserved; the rest is full-bleed). */
374
+ readonly safeArea?: SafeArea;
375
+ /** Height of the bottom control bar in px (0 before first layout / when there's no bar). */
376
+ readonly barHeight?: number;
377
+ /** Show/hide the whole shell (bar + overlays). */
378
+ setVisible?(visible: boolean): void;
379
+ }
380
+ /** Bottom-bar inset a host reserves for scene content. */
381
+ interface SafeArea {
382
+ top: number;
383
+ right: number;
384
+ bottom: number;
385
+ left: number;
386
+ }
387
+ /** The surface facade createShell() guarantees on the returned shell, delegating to the renderer
388
+ * (inert defaults when the renderer omits a member). Hosts embedding a shell read these. */
389
+ interface ShellSurface {
390
+ readonly safeArea: SafeArea;
391
+ readonly barHeight: number;
392
+ setVisible(visible: boolean): void;
393
+ }
394
+ /** What the renderer (and its components) read from the brain. */
395
+ interface ShellHost {
396
+ readonly state: ShellState;
397
+ readonly config: ResolvedShellConfig;
398
+ readonly tokens: ShellTokens;
399
+ readonly layout: ShellLayoutMode;
400
+ readonly soundOn: boolean;
401
+ /** Resolve a built-in string (translation + optional socialize). */
402
+ t(text: string): string;
403
+ /** Currency-aware money formatting (win=true ⇒ variable decimals). */
404
+ formatCurrency(n: number, win?: boolean): string;
405
+ /** Typed event emit — same signature as the shells. */
406
+ emit: EventEmitter<ShellEvents>['emit'];
407
+ /** Renderer reports its surface size; the controller recomputes layout + re-renders. */
408
+ notifyResize(w: number, h: number): void;
409
+ /** Flip shared sound state (emits settingChange + refreshes an open Settings icon). */
410
+ setSound(on: boolean): void;
411
+ /** An open Settings overlay registers an icon updater here (null clears it on close). */
412
+ setSoundRefresh(fn: ((on: boolean) => void) | null): void;
413
+ /** Logic-bearing actions invoked by renderer controls. */
414
+ readonly actions: ShellActions;
415
+ }
416
+ /** Every state-changing thing a control can do. Each runs logic in the controller, emits the
417
+ * matching event, and triggers a re-render. Renderers MUST route input through these. */
418
+ interface ShellActions {
419
+ spin(): void;
420
+ stepBet(dir: 1 | -1): void;
421
+ setBet(n: number): void;
422
+ cycleTurbo(): void;
423
+ toggleAutoplay(): void;
424
+ startAutoplay(remaining: number): void;
425
+ stopAutoplay(): void;
426
+ openMenu(): void;
427
+ openSettings(): void;
428
+ openInfo(): void;
429
+ openBuyBonus(): void;
430
+ openBetPicker(): void;
431
+ openAutoplayPicker(): void;
432
+ selectBuyBonus(id: string): void;
433
+ activateFeature(b: BonusOption$1): void;
434
+ deactivateFeature(): void;
435
+ setSound(on: boolean): void;
436
+ closeOverlay(): void;
437
+ }
438
+ interface OverlayHandle {
439
+ /** Overlay-specific keys (e.g. arrows in a picker). Return true to consume. */
440
+ onKey?(e: KeyboardEvent): boolean;
441
+ /** Programmatically close this overlay. */
442
+ close(): void;
443
+ }
444
+ type OverlayRequest = {
445
+ kind: 'settings';
446
+ } | {
447
+ kind: 'gameInfo';
448
+ } | {
449
+ kind: 'buyBonus';
450
+ } | {
451
+ kind: 'betPicker';
452
+ } | {
453
+ kind: 'autoplayPicker';
454
+ } | {
455
+ kind: 'replay';
456
+ opts: ReplayModalOptions;
457
+ } | {
458
+ kind: 'modal';
459
+ opts: ModalOptions;
460
+ };
461
+
462
+ interface CreateShellOptions extends ShellConfig {
463
+ renderer: ShellRenderer;
464
+ }
465
+ /** Apply defaults to the raw config (the mount target lives on the renderer, not here). */
466
+ declare function resolveConfig(config: ShellConfig): ResolvedShellConfig;
467
+ /** The renderer-agnostic brain. Owns state, events, keyboard, i18n, theme, overlay flow and the
468
+ * game-facing public API; drives a ShellRenderer for the view. Implements ShellHost so the
469
+ * renderer + its components read everything they need through one interface. */
470
+ declare class ShellController extends EventEmitter<ShellEvents> implements ShellHost {
471
+ readonly config: ResolvedShellConfig;
472
+ state: ShellState;
473
+ tokens: ShellTokens;
474
+ layout: ShellLayoutMode;
475
+ soundOn: boolean;
476
+ readonly engineVersion = "0.2.0";
477
+ readonly actions: ShellActions;
478
+ private renderer;
479
+ private i18n;
480
+ private kbd?;
481
+ private overlay;
482
+ private soundRefresh;
483
+ private prevBalance;
484
+ private prevWin;
485
+ private destroyed;
486
+ constructor(opts: CreateShellOptions);
487
+ t(text: string): string;
488
+ formatCurrency(n: number, win?: boolean): string;
489
+ formatWin(value: number): string;
490
+ notifyResize(w: number, h: number): void;
491
+ private buildActions;
492
+ private attachKeyboard;
493
+ private pullFocus;
494
+ private show;
495
+ openMenu(): void;
496
+ openSettings(): void;
497
+ openInfo(): void;
498
+ openBuyBonus(): void;
499
+ openBetPicker(): void;
500
+ openAutoplayPicker(): void;
501
+ openReplay(opts: ReplayModalOptions): void;
502
+ openModal(opts: ModalOptions): void;
503
+ /** Programmatically dismiss whatever overlay/modal is open. No-op when nothing is shown. */
504
+ closeModal(): void;
505
+ setSound(on: boolean): void;
506
+ setSoundRefresh(fn: ((on: boolean) => void) | null): void;
507
+ activateFeature(bonus: BonusOption$1): void;
508
+ deactivateFeature(): void;
509
+ private money;
510
+ setBalance(n: number): void;
511
+ setWin(n: number): void;
512
+ setBet(n: number): void;
513
+ setMode(mode: ShellMode): void;
514
+ setBusy(busy: boolean): void;
515
+ setAutoplay(a: AutoplayOptions): void;
516
+ setTurbo(level: number): void;
517
+ setBuyBonusEnabled(enabled: boolean): void;
518
+ setFreeSpins(fs: FreeSpinsState): void;
519
+ setTheme(theme: ThemeConfig): void;
520
+ setLanguage(lang: string): void;
521
+ setSocial(isSocial: boolean): void;
522
+ setLayout(layout: ShellLayoutMode): void;
523
+ destroy(): Promise<void>;
524
+ }
525
+
526
+ /** Rewrite restricted gambling terms in `text` to social-safe phrasing, preserving case. */
527
+ declare function socialize(text: string): string;
528
+ type Lang = 'de' | 'en' | 'es' | 'fi' | 'fr' | 'hi' | 'id' | 'ja' | 'ko' | 'pl' | 'pt' | 'ru' | 'tr' | 'vi' | 'zh' | 'da';
529
+ declare function normalizeLang(code: string | null | undefined): Lang;
530
+ interface I18nOptions {
531
+ language: string;
532
+ isSocial?: boolean;
533
+ messages?: Partial<Record<Lang, Record<string, string>>>;
534
+ }
535
+ interface I18n {
536
+ readonly lang: Lang;
537
+ t(src: string): string;
538
+ }
539
+ declare function createI18n(opts: I18nOptions): I18n;
540
+
541
+ /** The @energy8platform/shell package version, stamped into the game-info footer. */
542
+ declare const PACKAGE_VERSION = "0.2.0";
543
+
544
+ /** A shell: the renderer-agnostic controller plus the surface facade (safeArea/barHeight/setVisible)
545
+ * an embedding host reads. `createShell`, `createGameShell` and `createPixiShell` all return this. */
546
+ type Shell = ShellController & ShellSurface;
547
+ /** Create a shell with an explicit renderer instance (custom or a built-in HtmlRenderer/PixiRenderer).
548
+ * Built-in renderers also have the createGameShell/createPixiShell sugar in /html and /pixi.
549
+ *
550
+ * The returned controller is augmented with the `ShellSurface` facade, delegating to the renderer's
551
+ * optional surface members (inert defaults when it has none) — so any renderer, custom included, is
552
+ * drivable by an embedding host (e.g. game-engine's createSlotGame) without Pixi-specific glue. */
553
+ declare function createShell(opts: CreateShellOptions): Shell;
554
+
555
+ /** A pushed full-screen layer (overlay or centred modal). Optional hooks let the host re-fit it
556
+ * on resize. */
557
+ interface ShellLayer extends Container {
558
+ /** Re-flow to a new screen size (overlays fill it; cards re-centre + fit-scale). */
559
+ resize?(w: number, h: number): void;
560
+ /** Re-run the card fit-scale backstop for short popouts. */
561
+ fit?(): void;
562
+ /** Called right before the layer is removed, so it can detach DOM listeners etc. */
563
+ onRemove?(): void;
564
+ /** Called by the shell keyboard controller while this layer is open.
565
+ * Return true to consume the key (prevents bar actions + Escape close); false to pass through
566
+ * (Escape → closeLayer). */
567
+ onKey?(e: KeyboardEvent): boolean;
568
+ }
569
+ interface LayerHandle {
570
+ root: ShellLayer;
571
+ close(): void;
572
+ }
573
+
574
+ interface PixiRendererOptions {
575
+ app: Application;
576
+ parent?: Container;
577
+ }
578
+ /** The Pixi VIEW half of the shell — the renderer the controller drives. Owns the root/bar/modal
579
+ * containers, builds the BottomBar + overlays, runs money count-ups + the frosted backdrop, and
580
+ * reports its surface size back to the controller. All the keyboard / pull-focus / overlay-flow
581
+ * logic lives in the ShellController; this class is pure Pixi rendering — a 1:1 port of the
582
+ * PixiGameShell rendering methods. */
583
+ declare class PixiRenderer implements ShellRenderer {
584
+ private app;
585
+ private parent?;
586
+ private host;
587
+ private ctx;
588
+ private root;
589
+ private barLayer;
590
+ private modalLayer;
591
+ private bar?;
592
+ private currentLayer;
593
+ private backdrop?;
594
+ private moneyAnims;
595
+ private destroyed;
596
+ constructor(opts: PixiRendererOptions);
597
+ private get ticker();
598
+ private get screenW();
599
+ private get screenH();
600
+ mount(host: ShellHost): void;
601
+ renderBar(): void;
602
+ setLayout(): void;
603
+ /** Tokens are read live from host.tokens by the components, so a theme change is just a re-render
604
+ * (mirrors PixiGameShell.setTheme which re-rendered). */
605
+ applyTheme(_tokens: ShellTokens): void;
606
+ /** Count a money readout from→to on the freshly-rendered bar's value Text node. Mirrors
607
+ * PixiGameShell.animateMoney (which counted on the just-built bar's value Texts). */
608
+ animateMoney(field: 'balance' | 'win', from: number, to: number): void;
609
+ private cancelMoneyAnims;
610
+ openOverlay(req: OverlayRequest): OverlayHandle | void;
611
+ closeOverlay(): void;
612
+ refreshSoundIcon(_on: boolean): void;
613
+ /** Fade out (≈250ms, like GameShell's REMOVE_FADE_MS) then tear down; resolves when removed. */
614
+ destroy(): Promise<void>;
615
+ pushLayer(node: ShellLayer): LayerHandle;
616
+ closeLayer(): void;
617
+ private clearLayer;
618
+ fitModals(): void;
619
+ /** Replay's reopen path: a replay modal can rebuild itself (e.g. after a replay completes). It is
620
+ * routed back through the controller-equivalent open flow so the layer stack + backdrop stay in
621
+ * sync — mirrors PixiGameShell.openReplay (push a fresh replay modal). */
622
+ private openReplayInternal;
623
+ /** Snapshot the scene behind the modal layer and blur it — the Pixi analogue of the overlay's
624
+ * `backdrop-filter: blur(20px) saturate(120%)`. Static (captured at open time): the game is paused
625
+ * under a modal, so a live re-blur each frame isn't worth the cost. */
626
+ private makeBackdrop;
627
+ private removeBackdrop;
628
+ /** Height of the bottom control bar in px (0 before first layout, or in replay-only chrome). */
629
+ get barHeight(): number;
630
+ /** Insets a scene should avoid. Only the bottom bar is reserved; the rest is full-bleed. */
631
+ get safeArea(): {
632
+ top: number;
633
+ right: number;
634
+ bottom: number;
635
+ left: number;
636
+ };
637
+ /** Show/hide the whole shell (bar + overlays). */
638
+ setVisible(visible: boolean): void;
639
+ private onResize;
640
+ /** Build the surface pixi components read: the core brain (host) plus the Pixi-specific members
641
+ * (ticker, canvas, screen size, the layer-stack methods, fmt/fmtWin shorthands). */
642
+ private makeContext;
643
+ }
644
+
645
+ /** Config for the Pixi shell: the renderer-agnostic ShellConfig plus the Pixi mount target.
646
+ * `app` is the PixiJS Application; `parent` (defaults to `app.stage`) is where the shell root
647
+ * attaches. */
648
+ interface PixiShellConfig extends ShellConfig {
649
+ app: Application;
650
+ parent?: Container;
651
+ }
652
+ /** A bonus-buy option whose `custom` card renderer returns a Pixi `Container` (vs core's `unknown`
653
+ * / ui/html's `HTMLElement`). */
654
+ interface BonusOption extends BonusOption$1 {
655
+ custom?: (ctx: BonusCardContext) => Container;
656
+ }
657
+ /** A `custom` game-info section renders a game-supplied Pixi `Container` (`node`). The other section
658
+ * kinds are unchanged from core. */
659
+ type GameInfoSection = Exclude<GameInfoSection$1, {
660
+ type: 'custom';
661
+ }> | {
662
+ type: 'custom';
663
+ title?: string;
664
+ order?: number;
665
+ node?: Container;
666
+ html?: string;
667
+ };
668
+ /** The surface game scenes use to position themselves. Identical to the renderer-agnostic
669
+ * `ShellSurface` (kept as a named alias for back-compat). */
670
+ type PixiShellSurface = ShellSurface;
671
+ /** The Pixi shell handle: the renderer-agnostic controller + the surface game scenes use. */
672
+ type PixiGameShell = Shell;
673
+ /** Create the Pixi game shell. Like `createGameShell`, only one is active at a time. Returns the
674
+ * existing instance if one is already active. The `ShellSurface` facade (safeArea/barHeight/
675
+ * setVisible) is wired by `createShell`, delegating to the PixiRenderer. */
676
+ declare function createPixiShell(config: PixiShellConfig): PixiGameShell;
677
+ /** Tear down the active Pixi shell (fade out, detach listeners, remove its display objects).
678
+ * Resolves when removed — mirrors `removePixiShell` in the legacy package. */
679
+ declare function removePixiShell(): Promise<void>;
680
+
681
+ export { DEFAULT_ACCENT, PACKAGE_VERSION, PixiRenderer, SCHEMES, ShellController, createI18n, createPixiShell, createShell, normalizeLang, removePixiShell, resolveConfig, resolveTheme, socialize };
682
+ export type { AutoplayConfig, AutoplayOptions, BonusCardContext, BonusOption, CellRef, CreateShellOptions, CurrencyConfig, FreeSpinsState, GameInfoContent, GameInfoSection, GameMode, I18n, I18nOptions, Lang, ModalAction, ModalOptions, OverlayHandle, OverlayRequest, PaylineDef, PaytableRow, PixiGameShell, PixiShellConfig, PixiShellSurface, ReplayModalOptions, ResolvedShellConfig, SafeArea, ShapeDef, Shell, ShellActions, ShellConfig, ShellEvents, ShellFeatures, ShellHost, ShellLayoutMode, ShellMode, ShellRenderer, ShellState, ShellSurface, ShellTokens, ThemeConfig, WinSection };