@energy8platform/platform-core 0.20.0 → 0.22.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.
- package/README.md +196 -0
- package/dist/index.cjs.js +1958 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +314 -2
- package/dist/index.esm.js +1956 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/shell.cjs.js +2011 -0
- package/dist/shell.cjs.js.map +1 -0
- package/dist/shell.d.ts +332 -0
- package/dist/shell.esm.js +2007 -0
- package/dist/shell.esm.js.map +1 -0
- package/package.json +6 -1
- package/scripts/build-shell-font.mjs +64 -0
- package/src/index.ts +17 -0
- package/src/shell/GameShell.ts +296 -0
- package/src/shell/INTER-LICENSE.txt +93 -0
- package/src/shell/colors.ts +32 -0
- package/src/shell/components/BottomBar.ts +217 -0
- package/src/shell/components/BuyBonus.ts +163 -0
- package/src/shell/components/GameInfo.ts +253 -0
- package/src/shell/components/Modal.ts +36 -0
- package/src/shell/components/ReplayModal.ts +56 -0
- package/src/shell/components/Settings.ts +60 -0
- package/src/shell/components/icons.ts +40 -0
- package/src/shell/components/pickers.ts +89 -0
- package/src/shell/components/primitives.ts +84 -0
- package/src/shell/fonts.ts +13 -0
- package/src/shell/format.ts +36 -0
- package/src/shell/i18n.ts +67 -0
- package/src/shell/index.ts +20 -0
- package/src/shell/motion.ts +43 -0
- package/src/shell/shell.css.ts +371 -0
- package/src/shell/state.ts +30 -0
- package/src/shell/theme.ts +56 -0
- package/src/shell/types.ts +203 -0
|
@@ -0,0 +1,203 @@
|
|
|
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). The value is rounded to this precision. */
|
|
7
|
+
decimals?: number;
|
|
8
|
+
/** Minimum fraction digits (defaults to `decimals`). Trailing zeros are trimmed down to
|
|
9
|
+
* this many places, so small wins keep their significant digits (e.g. 0.0673) while round
|
|
10
|
+
* amounts stay compact (e.g. 0.30). */
|
|
11
|
+
minDecimals?: number;
|
|
12
|
+
separator?: { thousands?: string; decimal?: string };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BonusOption {
|
|
16
|
+
id: string;
|
|
17
|
+
/** 'bonus' buys into a bonus round, 'feature' toggles a base-game modifier (e.g. Ante).
|
|
18
|
+
* Drives the card/button label and accent. Defaults to 'bonus'. */
|
|
19
|
+
type?: 'feature' | 'bonus';
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
/** Transparent art image shown at the top of the card (no background plate). */
|
|
23
|
+
thumbnail?: string;
|
|
24
|
+
volatility?: 1 | 2 | 3 | 4 | 5;
|
|
25
|
+
/** Card price = priceMultiplier × current bet, rendered in the shell currency. */
|
|
26
|
+
priceMultiplier: number;
|
|
27
|
+
/** Per-option accent override. Falls back to the type default (bonus → purple, feature → gold). */
|
|
28
|
+
accentColor?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ThemeConfig {
|
|
32
|
+
/** Palette scheme: 'dark' (default) for dark games, 'light' for light backgrounds. */
|
|
33
|
+
scheme?: 'dark' | 'light';
|
|
34
|
+
accent?: string;
|
|
35
|
+
buyBonusColor?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** One paytable entry: a symbol (text/image) and its win tiers, rendered "<count> x<multiplier>". */
|
|
39
|
+
export interface PaytableRow {
|
|
40
|
+
symbol: { text?: string; image?: string };
|
|
41
|
+
wins: Array<{ count?: string; multiplier: number }>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One payline over a cols×rows grid: the row index (0 = top) the line takes in each column. */
|
|
45
|
+
export interface PaylineDef {
|
|
46
|
+
/** length must equal grid.cols; each value in 0..rows-1 */
|
|
47
|
+
pattern: number[];
|
|
48
|
+
label?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A single grid cell, 0-based, row 0 = top. */
|
|
52
|
+
export type CellRef = [col: number, row: number];
|
|
53
|
+
|
|
54
|
+
/** How a game pays — drives the GameInfo win-section illustration. One section = one kind.
|
|
55
|
+
* `example`/`winExample`/`loseExample` are optional; omit them for an auto-drawn illustration
|
|
56
|
+
* sized to `grid`. */
|
|
57
|
+
export type WinSection = {
|
|
58
|
+
type: 'wins';
|
|
59
|
+
title?: string;
|
|
60
|
+
order?: number;
|
|
61
|
+
grid: { cols: number; rows: number };
|
|
62
|
+
/** Optional prose shown alongside the illustration. */
|
|
63
|
+
description?: string;
|
|
64
|
+
} & (
|
|
65
|
+
| { kind: 'classic'; lines: Array<number[] | PaylineDef> }
|
|
66
|
+
| { kind: 'cluster'; minCount: number; example?: CellRef[] }
|
|
67
|
+
| { kind: 'anywhere'; minCount: number; example?: CellRef[] }
|
|
68
|
+
| { kind: 'ways'; winExample?: CellRef[]; loseExample?: CellRef[] }
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
/** A playable mode / bonus-buy option, shown for comparison (informational only). */
|
|
72
|
+
export interface GameMode {
|
|
73
|
+
title: string;
|
|
74
|
+
price?: string;
|
|
75
|
+
rtp?: number;
|
|
76
|
+
maxWin?: string;
|
|
77
|
+
description?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A preset game-info section. `order` overrides placement; by default `modes` comes
|
|
81
|
+
* first, `controls` second, and the rest follow in declaration order. */
|
|
82
|
+
export type GameInfoSection =
|
|
83
|
+
| { type: 'modes'; title?: string; order?: number; modes: GameMode[] }
|
|
84
|
+
| { type: 'controls'; title?: string; order?: number }
|
|
85
|
+
| { type: 'paytable'; title?: string; order?: number; rows: PaytableRow[] }
|
|
86
|
+
| WinSection
|
|
87
|
+
| { type: 'custom'; title?: string; order?: number; node?: HTMLElement; html?: string };
|
|
88
|
+
|
|
89
|
+
export interface GameInfoContent {
|
|
90
|
+
sections?: GameInfoSection[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Autoplay limits. Presence of this object (vs `null`) is what enables autoplay. */
|
|
94
|
+
export interface AutoplayConfig {
|
|
95
|
+
/** Maximum selectable spin count in the autoplay picker. Caps the built-in presets and
|
|
96
|
+
* drops the unlimited (∞) choice; if it isn't already a preset it becomes the top choice.
|
|
97
|
+
* Omit for the default presets (including ∞). */
|
|
98
|
+
maxCount?: number;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface ShellFeatures {
|
|
102
|
+
turbo: 0 | 1 | 2 | 3;
|
|
103
|
+
/** Spacebar starts a spin in base mode. Defaults to `true`; set `false` to disable the
|
|
104
|
+
* keyboard shortcut (e.g. jurisdictions that forbid quick-spin keys). */
|
|
105
|
+
spacebar?: boolean;
|
|
106
|
+
/** Autoplay: `null` (or omitted) disables it; an object enables it (optionally with limits). */
|
|
107
|
+
autoplay?: AutoplayConfig | null;
|
|
108
|
+
buyBonus: BonusOption[] | false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface AutoplayOptions {
|
|
112
|
+
active: boolean;
|
|
113
|
+
remaining: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface FreeSpinsState {
|
|
117
|
+
current: number;
|
|
118
|
+
total: number;
|
|
119
|
+
totalWin: number;
|
|
120
|
+
lastWin: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** One footer button of a generic modal. Clicking it runs `on` (if any), then closes the modal. */
|
|
124
|
+
export interface ModalAction {
|
|
125
|
+
title: string;
|
|
126
|
+
/** Button fill colour (any CSS colour). Omit for a neutral/secondary button. */
|
|
127
|
+
color?: string;
|
|
128
|
+
on?: () => void;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Options for `shell.openReplay()` — a non-dismissable replay summary modal.
|
|
132
|
+
* `bonusId` is matched against `features.buyBonus` to label the mode and read the cost
|
|
133
|
+
* multiplier. There is no ✕ and the backdrop never closes it; the only action is START
|
|
134
|
+
* REPLAY, which closes the modal, runs `onReplay`, then reopens it. */
|
|
135
|
+
export interface ReplayModalOptions {
|
|
136
|
+
bonusId: string;
|
|
137
|
+
/** Base bet the replay was recorded at. */
|
|
138
|
+
bet: number;
|
|
139
|
+
payoutMultiplier: number;
|
|
140
|
+
/** Runs after the modal closes; the modal reopens once it resolves (immediately for sync). */
|
|
141
|
+
onReplay: () => void | Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Options for `shell.openModal()` — a generic, externally-triggered card modal. */
|
|
145
|
+
export interface ModalOptions {
|
|
146
|
+
/** Show the ✕ in the overlay's top-right corner. */
|
|
147
|
+
availableClose: boolean;
|
|
148
|
+
title: string;
|
|
149
|
+
body: string;
|
|
150
|
+
/** Footer buttons; each closes the modal (after running its `on`). */
|
|
151
|
+
actions?: ModalAction[];
|
|
152
|
+
/** Backdrop blur in px (defaults to the shell's standard blur). */
|
|
153
|
+
blurLevel?: number;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface ShellConfig {
|
|
157
|
+
mount: HTMLElement;
|
|
158
|
+
theme?: ThemeConfig;
|
|
159
|
+
gameInfo: GameInfoContent;
|
|
160
|
+
language: string;
|
|
161
|
+
/** When true, all built-in shell text is shown in the social-casino vocabulary (derived from
|
|
162
|
+
* English via word-swap rules), regardless of `language`. Game-supplied content is untouched. */
|
|
163
|
+
isSocial?: boolean;
|
|
164
|
+
currency: CurrencyConfig;
|
|
165
|
+
availableBets: number[];
|
|
166
|
+
defaultBet: number;
|
|
167
|
+
currentBet: number | null;
|
|
168
|
+
balance: number;
|
|
169
|
+
win: number;
|
|
170
|
+
mode: ShellMode;
|
|
171
|
+
features: ShellFeatures;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface ShellState {
|
|
175
|
+
mode: ShellMode;
|
|
176
|
+
balance: number;
|
|
177
|
+
win: number;
|
|
178
|
+
bet: number;
|
|
179
|
+
availableBets: number[];
|
|
180
|
+
busy: boolean;
|
|
181
|
+
autoplay: AutoplayOptions;
|
|
182
|
+
turbo: number;
|
|
183
|
+
buyBonusEnabled: boolean;
|
|
184
|
+
freeSpins: FreeSpinsState;
|
|
185
|
+
/** The currently activated `feature` option (e.g. Ante), or null. Drives the
|
|
186
|
+
* effective-bet readout tint and the BUY BONUS → DISABLE toggle on the bar. */
|
|
187
|
+
activeFeature: BonusOption | null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface ShellEvents {
|
|
191
|
+
spin: void;
|
|
192
|
+
betChange: number;
|
|
193
|
+
autoplayStart: AutoplayOptions;
|
|
194
|
+
autoplayStop: void;
|
|
195
|
+
turboChange: number;
|
|
196
|
+
buyBonusSelect: { id: string };
|
|
197
|
+
featureActivate: { id: string };
|
|
198
|
+
featureDeactivate: { id: string };
|
|
199
|
+
menuOpen: void;
|
|
200
|
+
settingsOpen: void;
|
|
201
|
+
infoOpen: void;
|
|
202
|
+
settingChange: { key: string; value: unknown };
|
|
203
|
+
}
|