@energy8platform/platform-core 0.27.0 → 0.28.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 (39) hide show
  1. package/dist/index.cjs.js +0 -3682
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +2 -403
  4. package/dist/index.esm.js +1 -3680
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +1 -7
  7. package/src/index.ts +2 -17
  8. package/dist/shell.cjs.js +0 -3739
  9. package/dist/shell.cjs.js.map +0 -1
  10. package/dist/shell.d.ts +0 -436
  11. package/dist/shell.esm.js +0 -3732
  12. package/dist/shell.esm.js.map +0 -1
  13. package/scripts/gen-version.mjs +0 -21
  14. package/src/shell/GameShell.ts +0 -431
  15. package/src/shell/INTER-LICENSE.txt +0 -93
  16. package/src/shell/colors.ts +0 -32
  17. package/src/shell/components/BottomBar.ts +0 -255
  18. package/src/shell/components/BuyBonus.ts +0 -329
  19. package/src/shell/components/GameInfo.ts +0 -384
  20. package/src/shell/components/Modal.ts +0 -36
  21. package/src/shell/components/ReplayModal.ts +0 -57
  22. package/src/shell/components/Settings.ts +0 -59
  23. package/src/shell/components/icons.svg +0 -139
  24. package/src/shell/components/icons.ts +0 -45
  25. package/src/shell/components/pickers.ts +0 -150
  26. package/src/shell/components/primitives.ts +0 -85
  27. package/src/shell/fonts-digits.ts +0 -12
  28. package/src/shell/fonts.ts +0 -13
  29. package/src/shell/format.ts +0 -39
  30. package/src/shell/i18n.ts +0 -56
  31. package/src/shell/index.ts +0 -22
  32. package/src/shell/keyboard.ts +0 -229
  33. package/src/shell/locales.ts +0 -864
  34. package/src/shell/motion.ts +0 -43
  35. package/src/shell/shell.css.ts +0 -499
  36. package/src/shell/state.ts +0 -31
  37. package/src/shell/theme.ts +0 -59
  38. package/src/shell/types.ts +0 -262
  39. package/src/shell/version.ts +0 -3
@@ -1,431 +0,0 @@
1
- import { EventEmitter } from '../EventEmitter';
2
- import type {
3
- AutoplayOptions,
4
- BonusOption,
5
- FreeSpinsState,
6
- ModalOptions,
7
- ReplayModalOptions,
8
- ShellConfig,
9
- ShellEvents,
10
- ShellMode,
11
- ShellState,
12
- ThemeConfig,
13
- } from './types';
14
- import { KeyboardController, type KeyboardHost } from './keyboard';
15
- import { createInitialState, nextTurbo, stepBet } from './state';
16
- import { buildThemeVars } from './theme';
17
- import { SHELL_CSS, SHELL_ROOT_ID } from './shell.css';
18
- import { renderBottomBar } from './components/BottomBar';
19
- import { openSettingsModal } from './components/Settings';
20
- import { openGameInfoModal } from './components/GameInfo';
21
- import { openBuyBonusOverlay } from './components/BuyBonus';
22
- import { openBetModal, openAutoplayModal } from './components/pickers';
23
- import { buildModal } from './components/Modal';
24
- import { buildReplayModal } from './components/ReplayModal';
25
- import { countUp } from './motion';
26
- import { formatCurrency } from './format';
27
- import { createI18n, type I18n } from './i18n';
28
-
29
- const REMOVE_FADE_MS = 300;
30
-
31
- export class GameShell extends EventEmitter<ShellEvents> {
32
- readonly config: ShellConfig;
33
- state: ShellState;
34
- private root: HTMLElement;
35
- private styleEl: HTMLStyleElement;
36
- private barHost = document.createElement('div');
37
- private modalHost = document.createElement('div');
38
- private destroyed = false;
39
- layout: 'wide' | 'mobile' = 'wide';
40
- private ro: ResizeObserver | null = null;
41
- private prevBalance = 0;
42
- private prevWin = 0;
43
- private moneyAnims: Array<() => void> = [];
44
- private kbd!: KeyboardController;
45
- private i18n!: I18n;
46
- /** onKey handler of the currently open modal/overlay, if any (set in showModal, cleared in closeModal). */
47
- private modalOnKey: ((e: KeyboardEvent) => boolean) | undefined = undefined;
48
- /** Shared sound on/off state — Settings speaker toggle and the Shift+M hotkey stay in sync. The
49
- * game listens to `settingChange({ key: 'sound' })` to (un)mute audio. */
50
- soundOn = true;
51
- /** Set by the open Settings modal so Shift+M live-updates its speaker icon; cleared on close. */
52
- private soundRefresh: ((on: boolean) => void) | null = null;
53
-
54
- constructor(config: ShellConfig) {
55
- super();
56
- this.config = config;
57
- this.i18n = createI18n({ language: config.language, isSocial: config.isSocial });
58
- this.state = createInitialState(config);
59
-
60
- this.styleEl = document.createElement('style');
61
- this.styleEl.textContent = SHELL_CSS;
62
-
63
- this.root = document.createElement('div');
64
- this.root.id = SHELL_ROOT_ID;
65
- this.root.setAttribute('style', buildThemeVars(config.theme));
66
-
67
- config.mount.append(this.styleEl, this.root);
68
- this.barHost.className = 'ge-shell-barhost';
69
- this.root.appendChild(this.barHost);
70
- this.modalHost.className = 'ge-shell-modalhost';
71
- this.root.appendChild(this.modalHost);
72
- this.prevBalance = this.state.balance;
73
- this.prevWin = this.state.win;
74
- this.observeLayout();
75
- if (typeof document !== 'undefined') {
76
- // eslint-disable-next-line @typescript-eslint/no-this-alias
77
- const shell = this;
78
- const host: KeyboardHost = {
79
- get state() { return shell.state; },
80
- get hotkeysEnabled() { return shell.config.features.hotkeys !== false; },
81
- get spacebarEnabled() { return shell.config.features.spacebar !== false; },
82
- get turboLevels() { return shell.config.features.turbo; },
83
- get autoplayEnabled() { return shell.config.features.autoplay != null; },
84
- get buyBonusEnabled() { return shell.config.features.buyBonus !== false; },
85
- hasOpenLayer: () => shell.modalHost.childElementCount > 0,
86
- routeToLayer: (e) => shell.modalOnKey?.(e) ?? false,
87
- spin: () => shell.emit('spin'),
88
- stepBet: (dir) => {
89
- const next = stepBet(shell.state, dir);
90
- if (next === shell.state.bet) return;
91
- shell.state.bet = next; shell.emit('betChange', next); shell.render();
92
- },
93
- toggleAutoplay: () => {
94
- if (shell.state.autoplay.active) {
95
- shell.state.autoplay = { active: false, remaining: 0 };
96
- shell.emit('autoplayStop'); shell.render();
97
- } else {
98
- shell.openAutoplayPicker();
99
- }
100
- },
101
- cycleTurbo: () => {
102
- const next = nextTurbo(shell.state.turbo, shell.config.features.turbo);
103
- shell.state.turbo = next; shell.emit('turboChange', next); shell.render();
104
- },
105
- openBuyBonus: () => shell.openBuyBonus(),
106
- openInfo: () => shell.openInfo(),
107
- openMenu: () => shell.openMenu(),
108
- toggleMute: () => shell.setSound(!shell.soundOn),
109
- closeLayer: () => shell.closeModal(),
110
- };
111
- this.kbd = new KeyboardController(host);
112
- this.kbd.attach();
113
- // Stake serves the game in an iframe; on first paint focus is on the HOST page, so a `document`
114
- // keydown never fires and Space scrolls the parent. Pull window focus into the iframe on the
115
- // first pointer interaction so the spacebar shortcut works. Harmless on full-page Energy8.
116
- document.addEventListener('pointerdown', this.pullFocus, true);
117
- }
118
- this.render();
119
- // re-fit once the bundled webfont swaps in (text metrics change → row width changes)
120
- if (typeof document !== 'undefined' && document.fonts) {
121
- document.fonts.ready.then(() => { if (!this.destroyed) this.applyFitScale(); });
122
- }
123
- }
124
-
125
- render(): void {
126
- if (this.destroyed) return;
127
- this.cancelMoneyAnims(); // stop in-flight count-ups before their nodes are torn down below
128
- this.root.classList.toggle('ge-mobile', this.layout === 'mobile');
129
- this.barHost.innerHTML = '';
130
- this.barHost.appendChild(renderBottomBar(this));
131
- this.animateMoney();
132
- this.applyFitScale();
133
- }
134
-
135
- private cancelMoneyAnims(): void {
136
- for (const cancel of this.moneyAnims) cancel();
137
- this.moneyAnims = [];
138
- }
139
-
140
- /** Keep the WIN pill inline between the groups; float it above when it won't fit. */
141
- /**
142
- * Landscape bar fills the width when it fits. When it overflows, the WIN pill is
143
- * lifted above the bar (unscaled, so it stays readable) and the remaining row is
144
- * centred and scaled down to fit — keeping the controls as large as possible.
145
- */
146
- private applyFitScale(): void {
147
- if (this.destroyed) return;
148
- const host = this.barHost;
149
- const bar = host.querySelector('.ge-shell-bottom') as HTMLElement | null;
150
- if (!bar) return;
151
- // reset to baseline (idempotent)
152
- host.classList.remove('ge-fit');
153
- host.style.transform = '';
154
- host.style.transformOrigin = '';
155
- // clear any zoom from a prior pass. We zoom the whole dark PANEL (so the bar surface shrinks with
156
- // its content on a narrow popout), plus BUY BONUS + a lifted WIN pill, which live outside it.
157
- for (const el of host.querySelectorAll('.ge-bar-panel, .ge-shell-buybonus')) {
158
- (el as HTMLElement).style.transform = '';
159
- (el as HTMLElement).style.transformOrigin = '';
160
- (el as HTMLElement).style.removeProperty('zoom');
161
- }
162
- if (this.layout === 'mobile') {
163
- // First shrink long numbers inside the info pill (per-readout) so the buttons row stays
164
- // full-size; then, only if a row still overflows (tiny phones), scale the whole stack.
165
- this.fitBet();
166
- // Shrink the whole stack to fit narrow phones (mobile-s, or big balance/win/total-win
167
- // numbers in a row). The rows use space-between, so on overflow their content is
168
- // left-anchored and spills off the RIGHT edge — scale from the bottom-left corner so
169
- // `avail/need` fits it exactly. (The old centre-origin + 0.7 floor left large numbers
170
- // running past the screen edge; the 0.4 floor only guards a degenerate near-zero bar.)
171
- let need = 0;
172
- for (const row of Array.from(bar.children) as HTMLElement[]) need = Math.max(need, row.scrollWidth);
173
- const avail = bar.clientWidth;
174
- if (need > avail + 1 && avail > 0) {
175
- host.style.transformOrigin = 'bottom left';
176
- host.style.transform = `scale(${Math.max(0.4, avail / need).toFixed(4)})`;
177
- }
178
- return;
179
- }
180
- // ONE fit-scale, from the SCREEN SIZE, applied identically in EVERY mode — switching base⇄replay
181
- // must not resize the bar. The factor is the frame WIDTH vs the bar's design width, never the
182
- // current mode's content width.
183
- //
184
- // It's applied with `zoom` (not `transform`): zoom shrinks the LAYOUT, so the bar genuinely
185
- // takes less room and still sits edge-to-edge (menu hard-left, controls hard-right) even when
186
- // base's wide row would overflow a merely-visually-scaled bar — so there is no per-mode centred
187
- // cluster and no width/mode branching. The WIN pill stays inline in the bar and scales with it
188
- // (no lifting above the row). (Mobile, above, keeps its own stacked fit.)
189
- const zoomBar = (z: number): void => {
190
- const v = z < 0.999 ? z.toFixed(4) : '';
191
- const set = (el: Element | null): void => {
192
- if (!el) return;
193
- if (v) (el as HTMLElement).style.setProperty('zoom', v);
194
- else (el as HTMLElement).style.removeProperty('zoom');
195
- };
196
- // zoom the whole panel (surface + content, incl. the inline WIN pill, shrink together);
197
- // BUY BONUS sits outside the panel, so zoom it too.
198
- set(host.querySelector('.ge-bar-panel'));
199
- set(bar.querySelector('.ge-shell-buybonus'));
200
- };
201
- const s = Math.max(GameShell.BAR_MIN_SCALE, Math.min(1, this.root.clientWidth / GameShell.BAR_REF_WIDTH));
202
- zoomBar(s);
203
- // Safety: a pathologically long balance/win can still overflow the frame at the screen zoom —
204
- // nudge the zoom down just enough that the far control (turbo) isn't clipped. Normal content
205
- // never triggers this, so base and replay keep the SAME zoom (no size change on mode switch).
206
- if (bar.scrollWidth > bar.clientWidth + 1 && bar.scrollWidth > 0) {
207
- zoomBar(s * (bar.clientWidth / bar.scrollWidth));
208
- }
209
- this.fitBet();
210
- }
211
-
212
- /** Keep the BET box a fixed width (so the steppers/divider/SPIN never shift as the stake changes)
213
- * by shrinking just the number when it would overflow the box — e.g. amounts above ~€100,000. */
214
- private fitBet(): void {
215
- // Shrink a readout's value span (.ge-rd-val, inline-block so its true width is measurable even
216
- // inside an overflow:hidden slot) to fit `box`. The label is left untouched.
217
- const fit = (val: HTMLElement | null, box: HTMLElement | null | undefined): void => {
218
- if (!val || !box) return;
219
- val.style.transform = ''; // measure at full size
220
- const avail = box.clientWidth, need = val.scrollWidth;
221
- if (need > avail + 0.5 && need > 0) val.style.transform = `scale(${(avail / need).toFixed(3)})`;
222
- };
223
- // BET (desktop + mobile): the value fits its fixed-width box so +/- never resizes/shifts it
224
- const betBox = this.barHost.querySelector('.ge-bet-value') as HTMLElement | null;
225
- fit(betBox?.querySelector('.ge-rd-val') as HTMLElement | null, betBox);
226
- // mobile info pill: balance/win values fit their flex slots
227
- for (const rd of this.barHost.querySelectorAll('.ge-m-info > .ge-rd')) {
228
- fit(rd.querySelector('.ge-rd-val') as HTMLElement | null, rd as HTMLElement);
229
- }
230
- }
231
-
232
- /** Pull window focus into the iframe on first pointer interaction so `document` keydown (the
233
- * spacebar shortcut) fires. No-op / harmless when already focused or full-page. */
234
- private pullFocus = (): void => { try { window.focus(); } catch { /* cross-origin / non-browser */ } };
235
-
236
- setLayout(layout: 'wide' | 'mobile'): void {
237
- if (layout === this.layout) return;
238
- this.layout = layout;
239
- this.render();
240
- }
241
-
242
- /** Resolve a built-in shell string through the i18n resolver (translation + optional socialize). */
243
- t(text: string): string { return this.i18n.t(text); }
244
-
245
- /** Toggle the social vocabulary at runtime (rebuilds resolver, re-renders bar). */
246
- setSocial(isSocial: boolean): void {
247
- this.config.isSocial = isSocial;
248
- this.i18n = createI18n({ language: this.config.language, isSocial });
249
- this.render();
250
- }
251
-
252
- /** Swap the active language at runtime (rebuilds resolver, re-renders bar). */
253
- setLanguage(lang: string): void {
254
- this.config.language = lang;
255
- this.i18n = createI18n({ language: lang, isSocial: this.config.isSocial });
256
- this.render();
257
- }
258
-
259
- /** Recolour the shell at runtime (e.g. switch dark/light scheme). */
260
- setTheme(theme: ThemeConfig): void {
261
- this.config.theme = theme;
262
- this.root.setAttribute('style', buildThemeVars(theme));
263
- }
264
-
265
- private observeLayout(): void {
266
- const RO = (globalThis as { ResizeObserver?: typeof ResizeObserver }).ResizeObserver;
267
- if (typeof RO !== 'function') return; // jsdom: stays 'wide'
268
- this.ro = new RO((entries) => {
269
- const rect = entries[0]?.contentRect;
270
- const w = rect?.width ?? 0, h = rect?.height ?? 0;
271
- // portrait → stacked mobile; landscape (incl. popouts) → one row, scaled to fit if it overflows
272
- this.setLayout(w !== 0 && h > w ? 'mobile' : 'wide');
273
- this.applyFitScale();
274
- this.fitModals(); // re-scale open card modals when the popout resizes
275
- });
276
- this.ro.observe(this.root);
277
- }
278
-
279
- private animateMoney(): void {
280
- const fmt = (n: number) => formatCurrency(n, this.config.currency);
281
- const fmtWin = (n: number) => formatCurrency(n, this.config.currency, true); // win: variable decimals
282
- const bal = this.barHost.querySelector('[data-ge="balance"]') as HTMLElement | null;
283
- const win = this.barHost.querySelector('[data-ge="win"]') as HTMLElement | null;
284
- if (bal && this.state.balance !== this.prevBalance) this.moneyAnims.push(animateReadout(bal, this.prevBalance, this.state.balance, fmt));
285
- if (win && this.state.win !== this.prevWin) this.moneyAnims.push(animateReadout(win, this.prevWin, this.state.win, fmtWin));
286
- this.prevBalance = this.state.balance;
287
- this.prevWin = this.state.win;
288
- }
289
-
290
- setBalance(n: number): void { this.state.balance = n; this.render(); }
291
- setWin(n: number): void { this.state.win = n; this.render(); }
292
- setBet(n: number): void { this.state.bet = n; this.render(); }
293
- setMode(mode: ShellMode): void {
294
- if (mode === 'replay') this.state.replay = true; // sticky: a replay stays a replay across modes
295
- this.state.mode = mode;
296
- this.render();
297
- }
298
- setBusy(busy: boolean): void { this.state.busy = busy; this.render(); this.kbd?.notifyBusyChanged(busy); }
299
- setAutoplay(a: AutoplayOptions): void { this.state.autoplay = a; this.render(); }
300
- setTurbo(level: number): void { this.state.turbo = level; this.render(); }
301
- /** Currency-aware money formatter for WIN amounts (variable decimals: 0.0041 stays 0.0041, not
302
- * 0.00). The host hands this to a scene so games format money without knowing the currency. */
303
- formatWin(value: number): string { return formatCurrency(value, this.config.currency, true); }
304
- setBuyBonusEnabled(enabled: boolean): void { this.state.buyBonusEnabled = enabled; this.render(); }
305
- setFreeSpins(fs: FreeSpinsState): void { this.state.freeSpins = fs; this.render(); }
306
-
307
- private showModal(el: HTMLElement, onKey?: (e: KeyboardEvent) => boolean): void {
308
- // The control that opened this overlay (menu/buy/auto) keeps DOM focus. Drop it, or a
309
- // stray Space/Enter would natively re-activate that <button> and rebuild the modal — a
310
- // visible flicker. Only relinquish focus we own (a shell control), never the host page's.
311
- const active = document.activeElement as HTMLElement | null;
312
- if (active && this.root.contains(active)) active.blur();
313
- this.modalHost.innerHTML = '';
314
- this.modalHost.appendChild(el);
315
- this.modalOnKey = onKey;
316
- this.fitModals();
317
- }
318
-
319
- /** Uniformly scale every open centred card modal (`.ge-sheet`) down so it fits a short/narrow
320
- * popout — the same idea as the bar's fit-scale. Covers the pickers, generic + replay modals,
321
- * AND the buy-bonus confirm (which is hosted inside the overlay, not directly in modalHost).
322
- * Full-screen overlays handle their own responsiveness (scroll + vh-clamp). */
323
- fitModals(): void {
324
- if (this.destroyed) return;
325
- this.modalHost.querySelectorAll('.ge-sheet').forEach((el) => this.fitSheet(el as HTMLElement));
326
- }
327
-
328
- /** Fraction of the frame a card modal may occupy; the rest is breathing-room margin. Keeps
329
- * modals from filling a small popout edge-to-edge (so even short pickers scale down there). */
330
- private static readonly MODAL_FIT = 0.86;
331
-
332
- /** The bar's design width (px). When the frame is narrower, the bar fit-scales DOWN with the
333
- * screen — the SAME factor in every mode, so replay/free-spins shrink like base instead of
334
- * staying full-size on a popout. */
335
- private static readonly BAR_REF_WIDTH = 840;
336
- /** Lower bound on the bar fit-scale (guards a degenerate near-zero frame). */
337
- private static readonly BAR_MIN_SCALE = 0.5;
338
-
339
- private fitSheet(root: HTMLElement): void {
340
- const card = root.querySelector('.ge-modal-card') as HTMLElement | null;
341
- if (!card) return;
342
- card.style.transform = ''; // reset before measuring the natural size
343
- const availW = root.clientWidth, availH = root.clientHeight;
344
- const w = card.offsetWidth, h = card.offsetHeight;
345
- if (w <= 0 || h <= 0 || availW <= 0 || availH <= 0) return;
346
- const fit = GameShell.MODAL_FIT;
347
- const s = Math.min(1, (availW * fit) / w, (availH * fit) / h);
348
- if (s < 0.999) card.style.transform = `scale(${s.toFixed(4)})`;
349
- }
350
-
351
- /** Activate a `feature` option (e.g. Ante): the bar shows the effective bet, tinted with
352
- * the feature accent, and BUY BONUS becomes DISABLE. */
353
- activateFeature(bonus: BonusOption): void {
354
- this.state.activeFeature = bonus;
355
- this.emit('featureActivate', { id: bonus.id });
356
- this.render();
357
- }
358
-
359
- /** Clear the active feature — reverts the bet readout and the BUY BONUS button. */
360
- deactivateFeature(): void {
361
- const prev = this.state.activeFeature;
362
- if (!prev) return;
363
- this.state.activeFeature = null;
364
- this.emit('featureDeactivate', { id: prev.id });
365
- this.render();
366
- }
367
-
368
- openMenu(): void { this.emit('menuOpen'); this.openSettings(); }
369
- openSettings(): void { this.emit('settingsOpen'); this.showModal(openSettingsModal(this)); }
370
- openInfo(): void { this.emit('infoOpen'); const { root, onKey } = openGameInfoModal(this); this.showModal(root, onKey); }
371
- openBuyBonus(): void {
372
- if (this.config.onBonusBuy) { this.config.onBonusBuy(); return; } // game handles it (own UI)
373
- const result = openBuyBonusOverlay(this);
374
- if (result) this.showModal(result.root, result.onKey);
375
- }
376
- /** Open a generic, externally-driven modal (title + body + optional action buttons).
377
- * Each action runs its `on` then closes; the ✕ shows when `availableClose` is true. */
378
- openModal(opts: ModalOptions): void { this.showModal(buildModal(opts), opts.onKey); }
379
- /** Programmatically dismiss whatever modal/overlay is currently shown (e.g. auto-close the
380
- * reconnect overlay once the link is restored). No-op when nothing is open. */
381
- closeModal(): void { this.modalOnKey = undefined; this.soundRefresh = null; this.modalHost.innerHTML = ''; }
382
-
383
- /** Flip the shared sound state, notify the game (`settingChange({ key: 'sound' })`), and live-update
384
- * the Settings speaker icon if that modal is open. Used by both the Settings toggle and Shift+M. */
385
- setSound(on: boolean): void {
386
- this.soundOn = on;
387
- this.emit('settingChange', { key: 'sound', value: on });
388
- this.soundRefresh?.(on);
389
- }
390
- /** The Settings modal registers an icon-updater while open (cleared on close). */
391
- setSoundRefresh(fn: ((on: boolean) => void) | null): void { this.soundRefresh = fn; }
392
- /** Open the non-dismissable replay summary modal (START REPLAY → onReplay → reopen). */
393
- openReplay(opts: ReplayModalOptions): void {
394
- if (this.destroyed) return;
395
- this.showModal(buildReplayModal(this, opts));
396
- }
397
-
398
- /** Bet picker — list of available bets with an accent Confirm. */
399
- openBetPicker(): void { const { root, onKey } = openBetModal(this); this.showModal(root, onKey); }
400
- /** Autoplay picker — spin-count list; Confirm starts autoplay. */
401
- openAutoplayPicker(): void { const { root, onKey } = openAutoplayModal(this); this.showModal(root, onKey); }
402
-
403
- destroy(): Promise<void> {
404
- if (this.destroyed) return Promise.resolve();
405
- this.destroyed = true;
406
- this.ro?.disconnect();
407
- this.ro = null;
408
- if (typeof document !== 'undefined') {
409
- this.kbd?.detach();
410
- document.removeEventListener('pointerdown', this.pullFocus, true);
411
- }
412
- this.cancelMoneyAnims();
413
- this.removeAllListeners();
414
- this.root.classList.add('ge-shell-hidden');
415
- return new Promise<void>((resolve) => {
416
- setTimeout(() => {
417
- this.root.remove();
418
- this.styleEl.remove();
419
- resolve();
420
- }, REMOVE_FADE_MS);
421
- });
422
- }
423
- }
424
-
425
- /** Count-up the value span (.ge-rd-val) of a readout, leaving its label untouched.
426
- * Returns the count-up canceler so the shell can stop it before the node is replaced. */
427
- function animateReadout(el: HTMLElement, from: number, to: number, fmt: (n: number) => string): () => void {
428
- const val = el.querySelector('.ge-rd-val') as HTMLElement | null;
429
- if (!val) { el.textContent = fmt(to); return () => {}; }
430
- return countUp(val, from, to, fmt);
431
- }
@@ -1,93 +0,0 @@
1
- Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter) Inter-Italic[opsz,wght].ttf: Copyright 2016 The Inter Project Authors (https://github.com/rsms/inter)
2
-
3
- This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
- This license is copied below, and is also available with a FAQ at:
5
- http://scripts.sil.org/OFL
6
-
7
-
8
- -----------------------------------------------------------
9
- SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
- -----------------------------------------------------------
11
-
12
- PREAMBLE
13
- The goals of the Open Font License (OFL) are to stimulate worldwide
14
- development of collaborative font projects, to support the font creation
15
- efforts of academic and linguistic communities, and to provide a free and
16
- open framework in which fonts may be shared and improved in partnership
17
- with others.
18
-
19
- The OFL allows the licensed fonts to be used, studied, modified and
20
- redistributed freely as long as they are not sold by themselves. The
21
- fonts, including any derivative works, can be bundled, embedded,
22
- redistributed and/or sold with any software provided that any reserved
23
- names are not used by derivative works. The fonts and derivatives,
24
- however, cannot be released under any other type of license. The
25
- requirement for fonts to remain under this license does not apply
26
- to any document created using the fonts or their derivatives.
27
-
28
- DEFINITIONS
29
- "Font Software" refers to the set of files released by the Copyright
30
- Holder(s) under this license and clearly marked as such. This may
31
- include source files, build scripts and documentation.
32
-
33
- "Reserved Font Name" refers to any names specified as such after the
34
- copyright statement(s).
35
-
36
- "Original Version" refers to the collection of Font Software components as
37
- distributed by the Copyright Holder(s).
38
-
39
- "Modified Version" refers to any derivative made by adding to, deleting,
40
- or substituting -- in part or in whole -- any of the components of the
41
- Original Version, by changing formats or by porting the Font Software to a
42
- new environment.
43
-
44
- "Author" refers to any designer, engineer, programmer, technical
45
- writer or other person who contributed to the Font Software.
46
-
47
- PERMISSION & CONDITIONS
48
- Permission is hereby granted, free of charge, to any person obtaining
49
- a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
- redistribute, and sell modified and unmodified copies of the Font
51
- Software, subject to the following conditions:
52
-
53
- 1) Neither the Font Software nor any of its individual components,
54
- in Original or Modified Versions, may be sold by itself.
55
-
56
- 2) Original or Modified Versions of the Font Software may be bundled,
57
- redistributed and/or sold with any software, provided that each copy
58
- contains the above copyright notice and this license. These can be
59
- included either as stand-alone text files, human-readable headers or
60
- in the appropriate machine-readable metadata fields within text or
61
- binary files as long as those fields can be easily viewed by the user.
62
-
63
- 3) No Modified Version of the Font Software may use the Reserved Font
64
- Name(s) unless explicit written permission is granted by the corresponding
65
- Copyright Holder. This restriction only applies to the primary font name as
66
- presented to the users.
67
-
68
- 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
- Software shall not be used to promote, endorse or advertise any
70
- Modified Version, except to acknowledge the contribution(s) of the
71
- Copyright Holder(s) and the Author(s) or with their explicit written
72
- permission.
73
-
74
- 5) The Font Software, modified or unmodified, in part or in whole,
75
- must be distributed entirely under this license, and must not be
76
- distributed under any other license. The requirement for fonts to
77
- remain under this license does not apply to any document created
78
- using the Font Software.
79
-
80
- TERMINATION
81
- This license becomes null and void if any of the above conditions are
82
- not met.
83
-
84
- DISCLAIMER
85
- THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
- OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
- COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
- INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
- DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
- FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
- OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -1,32 +0,0 @@
1
- import type { BonusOption } from './types';
2
-
3
- /** The single brand accent (purple). The bar accent default (theme.ts) and the buy-a-bonus
4
- * card default both derive from this, so a rebrand only touches one constant. */
5
- export const BRAND_ACCENT = '#8b5cf6';
6
-
7
- /** Type-default accents for bonus options. A per-option `accentColor` overrides these. */
8
- export const ACCENT_BONUS = BRAND_ACCENT; // brand purple — buy a bonus round
9
- export const ACCENT_FEATURE = '#f0b429'; // gold — activate a base-game feature (e.g. Ante)
10
-
11
- /** The accent a card/button/bet-tint uses: explicit override, else the type default. */
12
- export function effectiveAccent(b: Pick<BonusOption, 'type' | 'accentColor'>): string {
13
- return b.accentColor ?? (b.type === 'feature' ? ACCENT_FEATURE : ACCENT_BONUS);
14
- }
15
-
16
- /** Readable text colour for a solid accent button: dark on light accents, white on dark.
17
- * Only #rgb / #rrggbb are measured; anything else (named, var(), etc.) → white. */
18
- export function contrastText(accent: string): string {
19
- const rgb = parseHex(accent);
20
- if (!rgb) return '#ffffff';
21
- // Relative luminance (sRGB, perceptual-ish). >0.6 → use dark ink.
22
- const lum = (0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]) / 255;
23
- return lum > 0.6 ? '#1a1205' : '#ffffff';
24
- }
25
-
26
- function parseHex(hex: string): [number, number, number] | null {
27
- const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
28
- if (!m) return null;
29
- let h = m[1];
30
- if (h.length === 3) h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2];
31
- return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
32
- }