@energy8platform/platform-core 0.16.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 (57) hide show
  1. package/README.md +482 -0
  2. package/bin/simulate.ts +139 -0
  3. package/dist/dev-bridge.cjs.js +237 -0
  4. package/dist/dev-bridge.cjs.js.map +1 -0
  5. package/dist/dev-bridge.d.ts +141 -0
  6. package/dist/dev-bridge.esm.js +235 -0
  7. package/dist/dev-bridge.esm.js.map +1 -0
  8. package/dist/index.cjs.js +569 -0
  9. package/dist/index.cjs.js.map +1 -0
  10. package/dist/index.d.ts +439 -0
  11. package/dist/index.esm.js +560 -0
  12. package/dist/index.esm.js.map +1 -0
  13. package/dist/loading.cjs.js +190 -0
  14. package/dist/loading.cjs.js.map +1 -0
  15. package/dist/loading.d.ts +86 -0
  16. package/dist/loading.esm.js +185 -0
  17. package/dist/loading.esm.js.map +1 -0
  18. package/dist/lua.cjs.js +1129 -0
  19. package/dist/lua.cjs.js.map +1 -0
  20. package/dist/lua.d.ts +319 -0
  21. package/dist/lua.esm.js +1119 -0
  22. package/dist/lua.esm.js.map +1 -0
  23. package/dist/simulation.cjs.js +374 -0
  24. package/dist/simulation.cjs.js.map +1 -0
  25. package/dist/simulation.d.ts +190 -0
  26. package/dist/simulation.esm.js +368 -0
  27. package/dist/simulation.esm.js.map +1 -0
  28. package/dist/vite.cjs.js +179 -0
  29. package/dist/vite.cjs.js.map +1 -0
  30. package/dist/vite.d.ts +13 -0
  31. package/dist/vite.esm.js +176 -0
  32. package/dist/vite.esm.js.map +1 -0
  33. package/package.json +100 -0
  34. package/scripts/install-simulate.mjs +101 -0
  35. package/src/EventEmitter.ts +55 -0
  36. package/src/PlatformSession.ts +156 -0
  37. package/src/dev-bridge/DevBridge.ts +305 -0
  38. package/src/dev-bridge/index.ts +2 -0
  39. package/src/index.ts +98 -0
  40. package/src/loading/CSSPreloader.ts +129 -0
  41. package/src/loading/index.ts +3 -0
  42. package/src/loading/logo.ts +95 -0
  43. package/src/lua/ActionRouter.ts +132 -0
  44. package/src/lua/LuaEngine.ts +412 -0
  45. package/src/lua/LuaEngineAPI.ts +314 -0
  46. package/src/lua/PersistentState.ts +80 -0
  47. package/src/lua/SessionManager.ts +227 -0
  48. package/src/lua/SimulationRunner.ts +192 -0
  49. package/src/lua/fengari.d.ts +10 -0
  50. package/src/lua/index.ts +28 -0
  51. package/src/lua/types.ts +149 -0
  52. package/src/simulation/NativeSimulationRunner.ts +367 -0
  53. package/src/simulation/ParallelSimulationRunner.ts +156 -0
  54. package/src/simulation/SimulationWorker.ts +44 -0
  55. package/src/simulation/index.ts +21 -0
  56. package/src/types.ts +85 -0
  57. package/src/vite/index.ts +196 -0
@@ -0,0 +1,560 @@
1
+ import { Bridge, CasinoGameSDK } from '@energy8platform/game-sdk';
2
+
3
+ const DEFAULT_CONFIG = {
4
+ balance: 10000,
5
+ currency: 'USD',
6
+ gameConfig: {
7
+ id: 'dev-game',
8
+ type: 'slot',
9
+ version: '1.0.0',
10
+ viewport: { width: 1920, height: 1080 },
11
+ betLevels: [0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50],
12
+ },
13
+ assetsUrl: '/assets/',
14
+ session: null,
15
+ onPlay: () => ({}),
16
+ networkDelay: 200,
17
+ debug: true,
18
+ };
19
+ /**
20
+ * Mock host bridge for local development.
21
+ *
22
+ * Uses the SDK's `Bridge` class in `devMode` to communicate with
23
+ * `CasinoGameSDK` via a shared in-memory `MemoryChannel`, removing
24
+ * the need for postMessage and iframes.
25
+ *
26
+ * When `luaScript` is set, play requests are sent to the Vite dev server
27
+ * which runs LuaEngine in Node.js — no fengari in the browser.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { DevBridge } from '@energy8platform/platform-core/dev-bridge';
32
+ *
33
+ * const devBridge = new DevBridge({
34
+ * balance: 5000,
35
+ * currency: 'EUR',
36
+ * gameConfig: { id: 'my-slot', type: 'slot', betLevels: [0.2, 0.5, 1, 2] },
37
+ * onPlay: ({ action, bet }) => ({
38
+ * totalWin: Math.random() > 0.5 ? bet * (Math.random() * 20) : 0,
39
+ * data: { matrix: [[1,2,3],[4,5,6],[7,8,9]] },
40
+ * }),
41
+ * });
42
+ * devBridge.start();
43
+ * ```
44
+ */
45
+ class DevBridge {
46
+ _config;
47
+ _balance;
48
+ _roundCounter = 0;
49
+ _bridge = null;
50
+ _useLuaServer;
51
+ constructor(config = {}) {
52
+ this._config = { ...DEFAULT_CONFIG, ...config };
53
+ this._balance = this._config.balance;
54
+ this._useLuaServer = !!(this._config.luaScript && this._config.gameDefinition);
55
+ }
56
+ /** Current mock balance */
57
+ get balance() {
58
+ return this._balance;
59
+ }
60
+ /** Start listening for SDK messages */
61
+ start() {
62
+ if (this._bridge)
63
+ return;
64
+ console.debug('[DevBridge] Starting with config:', this._config);
65
+ this._bridge = new Bridge({ devMode: true, debug: this._config.debug });
66
+ this._bridge.on('GAME_READY', (_payload, id) => {
67
+ this.handleGameReady(id);
68
+ });
69
+ this._bridge.on('PLAY_REQUEST', (payload, id) => {
70
+ this.handlePlayRequest(payload, id);
71
+ });
72
+ this._bridge.on('PLAY_RESULT_ACK', (payload) => {
73
+ this.handlePlayAck(payload);
74
+ });
75
+ this._bridge.on('GET_BALANCE', (_payload, id) => {
76
+ this.handleGetBalance(id);
77
+ });
78
+ this._bridge.on('GET_STATE', (_payload, id) => {
79
+ this.handleGetState(id);
80
+ });
81
+ this._bridge.on('OPEN_DEPOSIT', () => {
82
+ this.handleOpenDeposit();
83
+ });
84
+ if (this._config.debug) {
85
+ const mode = this._useLuaServer ? 'Lua (server-side)' : 'onPlay callback';
86
+ console.log(`[DevBridge] Started — mode: ${mode}`);
87
+ }
88
+ }
89
+ /** Stop listening */
90
+ stop() {
91
+ if (this._bridge) {
92
+ this._bridge.destroy();
93
+ this._bridge = null;
94
+ }
95
+ if (this._config.debug) {
96
+ console.log('[DevBridge] Stopped');
97
+ }
98
+ }
99
+ /** Set mock balance */
100
+ setBalance(balance) {
101
+ this._balance = balance;
102
+ this._bridge?.send('BALANCE_UPDATE', { balance: this._balance });
103
+ }
104
+ /** Destroy the dev bridge */
105
+ destroy() {
106
+ this.stop();
107
+ }
108
+ // ─── Message Handling ──────────────────────────────────
109
+ handleGameReady(id) {
110
+ const initData = {
111
+ balance: this._balance,
112
+ currency: this._config.currency,
113
+ config: this._config.gameConfig,
114
+ session: this._config.session,
115
+ assetsUrl: this._config.assetsUrl,
116
+ };
117
+ this.delayedSend('INIT', initData, id);
118
+ }
119
+ handlePlayRequest(payload, id) {
120
+ const { action, bet, roundId, params } = payload;
121
+ this._roundCounter++;
122
+ if (this._useLuaServer) {
123
+ // Debit bet (server deducts before Lua execution)
124
+ // For session actions (free spins), debit is 0 — LuaEngine handles bet from session
125
+ this._balance -= bet;
126
+ this.executeLuaOnServer({ action, bet, roundId, params })
127
+ .then((result) => {
128
+ this._bridge?.send('PLAY_RESULT', result, id);
129
+ })
130
+ .catch((err) => {
131
+ console.error('[DevBridge] Lua server error:', err);
132
+ this._balance += bet;
133
+ this._bridge?.send('PLAY_RESULT', this.buildFallbackResult(action, bet, roundId), id);
134
+ });
135
+ }
136
+ else {
137
+ // Fallback to onPlay callback
138
+ const customResult = this._config.onPlay({ action, bet, roundId, params });
139
+ const totalWin = customResult.totalWin ?? (Math.random() > 0.6 ? bet * (1 + Math.random() * 10) : 0);
140
+ this._balance += totalWin;
141
+ const result = {
142
+ roundId: roundId ?? `dev-round-${this._roundCounter}`,
143
+ action,
144
+ balanceAfter: this._balance,
145
+ totalWin: Math.round(totalWin * 100) / 100,
146
+ data: customResult.data ?? {},
147
+ nextActions: customResult.nextActions ?? ['spin'],
148
+ session: customResult.session ?? null,
149
+ creditPending: false,
150
+ bonusFreeSpin: customResult.bonusFreeSpin ?? null,
151
+ currency: this._config.currency,
152
+ gameId: this._config.gameConfig?.id ?? 'dev-game',
153
+ };
154
+ this.delayedSend('PLAY_RESULT', result, id);
155
+ }
156
+ }
157
+ async executeLuaOnServer(params) {
158
+ const response = await fetch('/__lua-play', {
159
+ method: 'POST',
160
+ headers: { 'Content-Type': 'application/json' },
161
+ body: JSON.stringify(params),
162
+ });
163
+ if (!response.ok) {
164
+ const err = await response.json().catch(() => ({ error: 'Unknown error' }));
165
+ throw new Error(err.error ?? `HTTP ${response.status}`);
166
+ }
167
+ const luaResult = await response.json();
168
+ // Server credit logic:
169
+ // shouldCredit = (no session) OR (session.completed)
170
+ // creditAmount = result.totalWin
171
+ const shouldCredit = !luaResult.session || luaResult.session.completed;
172
+ if (shouldCredit && luaResult.totalWin > 0) {
173
+ this._balance += luaResult.totalWin;
174
+ }
175
+ return {
176
+ roundId: params.roundId ?? `dev-round-${this._roundCounter}`,
177
+ action: params.action,
178
+ balanceAfter: this._balance,
179
+ totalWin: Math.round(luaResult.totalWin * 100) / 100,
180
+ data: luaResult.data,
181
+ nextActions: luaResult.nextActions,
182
+ session: luaResult.session,
183
+ creditPending: !shouldCredit,
184
+ bonusFreeSpin: null,
185
+ currency: this._config.currency,
186
+ gameId: this._config.gameConfig?.id ?? 'dev-game',
187
+ };
188
+ }
189
+ buildFallbackResult(action, bet, roundId) {
190
+ return {
191
+ roundId: roundId ?? `dev-round-${this._roundCounter}`,
192
+ action,
193
+ balanceAfter: this._balance,
194
+ totalWin: 0,
195
+ data: { error: 'Lua execution failed' },
196
+ nextActions: ['spin'],
197
+ session: null,
198
+ creditPending: false,
199
+ bonusFreeSpin: null,
200
+ currency: this._config.currency,
201
+ gameId: this._config.gameConfig?.id ?? 'dev-game',
202
+ };
203
+ }
204
+ handlePlayAck(_payload) {
205
+ if (this._config.debug) {
206
+ console.log('[DevBridge] Play acknowledged');
207
+ }
208
+ }
209
+ handleGetBalance(id) {
210
+ this.delayedSend('BALANCE_UPDATE', { balance: this._balance }, id);
211
+ }
212
+ handleGetState(id) {
213
+ this.delayedSend('STATE_RESPONSE', { session: this._config.session ?? null }, id);
214
+ }
215
+ handleOpenDeposit() {
216
+ if (this._config.debug) {
217
+ console.log('[DevBridge] Open deposit requested (mock: adding 1000)');
218
+ }
219
+ this._balance += 1000;
220
+ this._bridge?.send('BALANCE_UPDATE', { balance: this._balance });
221
+ }
222
+ // ─── Communication ─────────────────────────────────────
223
+ delayedSend(type, payload, id) {
224
+ const delay = this._config.networkDelay;
225
+ if (delay > 0) {
226
+ setTimeout(() => this._bridge?.send(type, payload, id), delay);
227
+ }
228
+ else {
229
+ this._bridge?.send(type, payload, id);
230
+ }
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Minimal typed event emitter — internal utility for platform-core.
236
+ *
237
+ * Supports `void` event types — events that carry no data can be emitted
238
+ * without arguments: `emitter.emit('eventName')`.
239
+ *
240
+ * Mirrors the EventEmitter shipped from game-engine's core, copied here
241
+ * so platform-core has no upward dependency on game-engine.
242
+ */
243
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
244
+ class EventEmitter {
245
+ listeners = new Map();
246
+ on(event, handler) {
247
+ if (!this.listeners.has(event)) {
248
+ this.listeners.set(event, new Set());
249
+ }
250
+ this.listeners.get(event).add(handler);
251
+ return this;
252
+ }
253
+ once(event, handler) {
254
+ const wrapper = (data) => {
255
+ this.off(event, wrapper);
256
+ handler(data);
257
+ };
258
+ return this.on(event, wrapper);
259
+ }
260
+ off(event, handler) {
261
+ this.listeners.get(event)?.delete(handler);
262
+ return this;
263
+ }
264
+ emit(...args) {
265
+ const [event, data] = args;
266
+ const handlers = this.listeners.get(event);
267
+ if (handlers) {
268
+ for (const handler of handlers) {
269
+ handler(data);
270
+ }
271
+ }
272
+ }
273
+ removeAllListeners(event) {
274
+ if (event) {
275
+ this.listeners.delete(event);
276
+ }
277
+ else {
278
+ this.listeners.clear();
279
+ }
280
+ return this;
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Lifecycle wrapper around CasinoGameSDK + (optional) DevBridge.
286
+ *
287
+ * Use `createPlatformSession()` to construct one. The session owns the SDK
288
+ * handshake, optional in-process dev host, and a typed event bus that
289
+ * forwards SDK events upward.
290
+ *
291
+ * Phaser/Three/custom-engine consumers use this directly:
292
+ *
293
+ * ```ts
294
+ * const session = await createPlatformSession({
295
+ * dev: { luaScript, gameDefinition, balance: 10000, currency: 'EUR' },
296
+ * });
297
+ *
298
+ * session.on('balanceUpdate', ({ balance }) => updateHud(balance));
299
+ * const result = await session.play({ action: 'spin', bet: 1 });
300
+ * ```
301
+ */
302
+ class PlatformSession extends EventEmitter {
303
+ /** SDK instance, or null when `sdk: false` was passed. */
304
+ sdk;
305
+ /** Data returned by the SDK handshake, or null in offline mode. */
306
+ initData;
307
+ /** DevBridge mock host, or null when `dev` was not provided. */
308
+ devBridge;
309
+ constructor(opts) {
310
+ super();
311
+ this.sdk = opts.sdk;
312
+ this.initData = opts.initData;
313
+ this.devBridge = opts.devBridge;
314
+ }
315
+ /** Current player balance from the SDK (0 if no SDK). */
316
+ get balance() {
317
+ return this.sdk?.balance ?? 0;
318
+ }
319
+ /** Current currency from the SDK ('USD' fallback). */
320
+ get currency() {
321
+ return this.sdk?.currency ?? 'USD';
322
+ }
323
+ /**
324
+ * Send a play request through the SDK and resolve with the host result.
325
+ * Throws if the session was constructed with `sdk: false`.
326
+ */
327
+ async play(params) {
328
+ if (!this.sdk) {
329
+ throw new Error('[PlatformSession] play() requires an active SDK (constructed with sdk: false)');
330
+ }
331
+ return this.sdk.play(params);
332
+ }
333
+ /** Tear down the SDK, DevBridge, and clear listeners. */
334
+ destroy() {
335
+ this.sdk?.destroy();
336
+ this.devBridge?.destroy();
337
+ this.removeAllListeners();
338
+ }
339
+ }
340
+ /**
341
+ * Build a PlatformSession.
342
+ *
343
+ * Steps performed:
344
+ * 1. If `config.dev` is set → start a DevBridge with those options
345
+ * 2. Unless `config.sdk === false` → construct CasinoGameSDK and await its handshake
346
+ * 3. Forward `error` and `balanceUpdate` events from the SDK
347
+ */
348
+ async function createPlatformSession(config = {}) {
349
+ // 1. Optionally start the DevBridge mock host
350
+ let devBridge = null;
351
+ if (config.dev) {
352
+ devBridge = new DevBridge(config.dev);
353
+ devBridge.start();
354
+ }
355
+ // 2. Initialize SDK (unless explicitly disabled)
356
+ let sdk = null;
357
+ let initData = null;
358
+ if (config.sdk !== false) {
359
+ const sdkOpts = typeof config.sdk === 'object' ? config.sdk : {};
360
+ sdk = new CasinoGameSDK(sdkOpts);
361
+ initData = await sdk.ready();
362
+ }
363
+ // 3. Build the session and wire SDK event forwarding
364
+ const session = new PlatformSession({ sdk, initData, devBridge });
365
+ if (sdk) {
366
+ sdk.on('error', (err) => {
367
+ session.emit('error', err);
368
+ });
369
+ sdk.on('balanceUpdate', (data) => {
370
+ session.emit('balanceUpdate', data);
371
+ });
372
+ }
373
+ return session;
374
+ }
375
+
376
+ /**
377
+ * Shared Energy8 SVG logo with an embedded loader bar.
378
+ *
379
+ * The loader bar fill is controlled via a `<clipPath>` whose `<rect>` width
380
+ * is animatable. Different consumers customise gradient IDs and the clip
381
+ * element's ID/class to avoid collisions when both CSSPreloader and
382
+ * LoadingScene appear in the same DOM.
383
+ */
384
+ /** SVG path data for the Energy8 wordmark — reused across loaders */
385
+ const WORDMARK_PATHS = `
386
+ <path d="m241 81.75h-19.28c-1.77 0-6.73 4.98-7.43 6.99l-4.36 12.22c-0.49 1.37 0.05 2.92 1.06 4.32-2.07 1.19-3.69 3.08-4.36 5.43l-3.25 10.41c-0.86 2.89 2.39 6.63 4.31 6.63h19.28c1.96 0 7.4-5.56 7.96-7.51l2.96-10.22c0.63-2.25 0.1-3.98-1.22-4.99 2.55-1.56 3.86-4.14 4.55-6.31l2.77-9.31c0.74-2.57-1.37-7.66-2.99-7.66zm-13.36 28.31-2.27 7.03h-8.28l2.58-8.28h8.28l-0.31 1.25zm4.06-16.97-2.11 6.7h-7.04l2.25-7.34h7.26l-0.36 0.64z" fill="url(#GID0)"/>
387
+ <path d="m202.5 81.75-9.31 14.97-2.32-14.97h-11.82l4.32 25.15-0.57 4.91-8.64 26.44 15.31-12.76 5.63-16.48 19.96-27.26h-12.56z" fill="url(#GID1)"/>
388
+ <path d="m174.2 81.75h-19.78l-5.75 5.16-10.79 33.2c-0.77 2.53 2.48 6.93 4.87 6.93h17.38c2.63 0 7.85-5.34 8.32-6.83l5.37-18.14h-15.17l-2.2 7.64h3.78l-2.25 7.2h-8.01l7.1-25.52h7.58l-1.48 8.4 12.78-5.98c1.28-0.63 1.97-3.99 1.61-6.61-0.36-2.34-1.64-5.45-3.36-5.45z" fill="url(#GID2)"/>
389
+ <path d="m140.6 81.75h-70.6l-5.36 19.37-4.26-19.37h-46.76l2.95 5.88-10.58 39.28h26.84l2.95-9.52-15.63-0.13 2.55-8.34h8.74l8.47-9.81h-14.61l2.11-7.3h15.47l2.54-8.71 2.58 4.74-11.4 39.07h11.05l6.46-21.49 8.84 36.33 19.18-55.67-1.83-3.36 3.68 4.09-12.07 40.1h28.18l3.39-10.31h-17.01l2.67-8.03h9.98l7.58-9.52h-14.28l1.93-6.6h14.61l3.25-9.73 2.81 5.12-11.3 38.89h11.05l5.23-17.81h1.62l1.48 17.6h10.69l-1.48-16.81c4.75-1.28 7.52-5.9 8.64-9.81l2.95-11.3c0.86-2.73-1.43-6.85-3.3-6.85zm-9.8 17.3h-8.69l2.54-7.84h8.35l-2.2 7.84z" fill="url(#GID3)"/>
390
+ <path d="m205.9 148.9h-122.6l-2.61-3.12h-32.4l-2.51 3.12h-1.59c-5.34 0-7.94 4.88-7.94 7.65v0.03c0 4.2 3.55 7.6 7.74 7.6h103.6l2.11 3.12h36.09l1.82-3.12h18.3c5.25 0 6.64-5.3 6.64-7.35v-0.25c0-4.23-2.9-7.68-6.64-7.68zm-0.7 12.83h-160.6c-3.69 0-6.11-2.58-6.11-5.47v-0.03c0-2.89 2.1-5.47 5.61-5.47h161.1c3.45 0 4.89 3.12 4.89 5.65v0.17c0 2.57-2.11 5.15-4.89 5.15z" fill="url(#GID4)"/>`;
391
+ /** Gradient definitions template (gradient IDs are replaced per-consumer) */
392
+ const GRADIENT_DEFS = `
393
+ <linearGradient id="GID0" x1="223.7" x2="223.7" y1="81.75" y2="127.8" gradientUnits="userSpaceOnUse">
394
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
395
+ </linearGradient>
396
+ <linearGradient id="GID1" x1="194.6" x2="194.6" y1="81.75" y2="138.3" gradientUnits="userSpaceOnUse">
397
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
398
+ </linearGradient>
399
+ <linearGradient id="GID2" x1="157.8" x2="157.8" y1="81.75" y2="127" gradientUnits="userSpaceOnUse">
400
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
401
+ </linearGradient>
402
+ <linearGradient id="GID3" x1="79.96" x2="79.96" y1="81.75" y2="141.8" gradientUnits="userSpaceOnUse">
403
+ <stop stop-color="#663BA6"/><stop stop-color="#7939C2" offset=".349"/><stop stop-color="#8A2FC0" offset=".6615"/><stop stop-color="#791BA3" offset="1"/>
404
+ </linearGradient>
405
+ <linearGradient id="GID4" x1="36.18" x2="212.5" y1="156.6" y2="156.6" gradientUnits="userSpaceOnUse">
406
+ <stop stop-color="#316FB0"/><stop stop-color="#1FCDE6" offset=".5"/><stop stop-color="#29FEE7" offset="1"/>
407
+ </linearGradient>
408
+ <linearGradient id="GID5" x1="40.27" x2="208.2" y1="156.4" y2="156.4" gradientUnits="userSpaceOnUse">
409
+ <stop stop-color="#316FB0"/><stop stop-color="#1FCDE6" offset=".5"/><stop stop-color="#29FEE7" offset="1"/>
410
+ </linearGradient>`;
411
+ /** Max width of the loader bar in SVG units */
412
+ const LOADER_BAR_MAX_WIDTH = 174;
413
+ /**
414
+ * Build the Energy8 SVG logo with a loader bar, using unique IDs.
415
+ *
416
+ * @param opts - Configuration to avoid element ID collisions
417
+ * @returns SVG markup string
418
+ */
419
+ function buildLogoSVG(opts) {
420
+ const { idPrefix, svgClass, svgStyle, clipRectClass, clipRectId, textId, textContent, textClass } = opts;
421
+ // Replace gradient ID placeholders with prefixed versions
422
+ const paths = WORDMARK_PATHS.replace(/GID(\d)/g, `${idPrefix}$1`);
423
+ const defs = GRADIENT_DEFS.replace(/GID(\d)/g, `${idPrefix}$1`);
424
+ const clipId = `${idPrefix}-loader-clip`;
425
+ const fillGradientId = `${idPrefix}5`;
426
+ const classAttr = svgClass ? ` class="${svgClass}"` : '';
427
+ const styleAttr = svgStyle ? ` style="${svgStyle}"` : '';
428
+ const rectClassAttr = clipRectClass ? ` class="${clipRectClass}"` : '';
429
+ const rectIdAttr = clipRectId ? ` id="${clipRectId}"` : '';
430
+ const txtIdAttr = textId ? ` id="${textId}"` : '';
431
+ const txtClassAttr = textClass ? ` class="${textClass}"` : '';
432
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 250 200" fill="none"${classAttr}${styleAttr}>
433
+ ${paths}
434
+ <clipPath id="${clipId}">
435
+ <rect${rectIdAttr} x="37" y="148" width="0" height="20"${rectClassAttr}/>
436
+ </clipPath>
437
+ <path d="m204.5 152.6h-159.8c-2.78 0-4.45 1.69-4.45 3.99v0.11c0 2.04 1.42 3.43 3.64 3.43h160.6c2.88 0 3.67-2.07 3.67-3.43v-0.25c0-2.04-1.48-3.85-3.67-3.85z" fill="url(#${fillGradientId})" clip-path="url(#${clipId})"/>
438
+ <text${txtIdAttr} x="125" y="196" text-anchor="middle" fill="rgba(255,255,255,0.6)" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif" font-size="8" font-weight="600" letter-spacing="1.5"${txtClassAttr}>${textContent ?? 'Loading...'}</text>
439
+ <defs>
440
+ ${defs}
441
+ </defs>
442
+ </svg>`;
443
+ }
444
+
445
+ const PRELOADER_ID = '__ge-css-preloader__';
446
+ /**
447
+ * Inline SVG logo with animated loader bar.
448
+ * The `#loader` path acts as the progress fill — animated via clipPath.
449
+ */
450
+ const LOGO_SVG = buildLogoSVG({
451
+ idPrefix: 'pl',
452
+ svgClass: 'ge-logo-svg',
453
+ clipRectClass: 'ge-clip-rect',
454
+ textClass: 'ge-preloader-svg-text',
455
+ });
456
+ /**
457
+ * Creates a lightweight CSS-only preloader that appears instantly,
458
+ * BEFORE PixiJS/WebGL is initialized.
459
+ *
460
+ * Displays the Energy8 logo SVG with an animated loader bar.
461
+ */
462
+ function createCSSPreloader(container, config) {
463
+ if (document.getElementById(PRELOADER_ID))
464
+ return;
465
+ const bgColor = typeof config?.backgroundColor === 'string'
466
+ ? config.backgroundColor
467
+ : typeof config?.backgroundColor === 'number'
468
+ ? `#${config.backgroundColor.toString(16).padStart(6, '0')}`
469
+ : '#0a0a1a';
470
+ const bgGradient = config?.backgroundGradient ?? `linear-gradient(135deg, ${bgColor} 0%, #1a1a3e 100%)`;
471
+ const customHTML = config?.cssPreloaderHTML ?? '';
472
+ const el = document.createElement('div');
473
+ el.id = PRELOADER_ID;
474
+ el.innerHTML = customHTML || `
475
+ <div class="ge-preloader-content">
476
+ ${LOGO_SVG}
477
+ </div>
478
+ `;
479
+ const style = document.createElement('style');
480
+ style.textContent = `
481
+ #${PRELOADER_ID} {
482
+ position: absolute;
483
+ top: 0; left: 0;
484
+ width: 100%; height: 100%;
485
+ background: ${bgGradient};
486
+ display: flex;
487
+ align-items: center;
488
+ justify-content: center;
489
+ z-index: 10000;
490
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
491
+ transition: opacity 0.4s ease-out;
492
+ }
493
+
494
+ #${PRELOADER_ID}.ge-preloader-hidden {
495
+ opacity: 0;
496
+ pointer-events: none;
497
+ }
498
+
499
+ .ge-preloader-content {
500
+ display: flex;
501
+ flex-direction: column;
502
+ align-items: center;
503
+ width: 80%;
504
+ max-width: 700px;
505
+ }
506
+
507
+ .ge-logo-svg {
508
+ width: 100%;
509
+ height: auto;
510
+ filter: drop-shadow(0 0 30px rgba(121, 57, 194, 0.4));
511
+ }
512
+
513
+ /* Animate the loader clip-rect to shimmer while waiting */
514
+ .ge-clip-rect {
515
+ animation: ge-loader-fill 2s ease-in-out infinite;
516
+ }
517
+
518
+ @keyframes ge-loader-fill {
519
+ 0% { width: 0; }
520
+ 50% { width: 174; }
521
+ 100% { width: 0; }
522
+ }
523
+
524
+ /* Animate the SVG text opacity */
525
+ .ge-preloader-svg-text {
526
+ animation: ge-pulse 1.5s ease-in-out infinite;
527
+ }
528
+
529
+ @keyframes ge-pulse {
530
+ 0%, 100% { opacity: 0.4; }
531
+ 50% { opacity: 1; }
532
+ }
533
+ `;
534
+ container.style.position = container.style.position || 'relative';
535
+ container.appendChild(style);
536
+ container.appendChild(el);
537
+ }
538
+ /**
539
+ * Remove the CSS preloader with a smooth fade-out transition.
540
+ */
541
+ function removeCSSPreloader(container) {
542
+ const el = document.getElementById(PRELOADER_ID);
543
+ if (!el)
544
+ return;
545
+ el.classList.add('ge-preloader-hidden');
546
+ // Remove after transition
547
+ el.addEventListener('transitionend', () => {
548
+ el.remove();
549
+ // Also remove the style element
550
+ const styles = container.querySelectorAll('style');
551
+ for (const style of styles) {
552
+ if (style.textContent?.includes(PRELOADER_ID)) {
553
+ style.remove();
554
+ }
555
+ }
556
+ });
557
+ }
558
+
559
+ export { DevBridge, EventEmitter, LOADER_BAR_MAX_WIDTH, PlatformSession, buildLogoSVG, createCSSPreloader, createPlatformSession, removeCSSPreloader };
560
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/dev-bridge/DevBridge.ts","../src/EventEmitter.ts","../src/PlatformSession.ts","../src/loading/logo.ts","../src/loading/CSSPreloader.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;AAqCA,MAAM,cAAc,GAAgF;AAClG,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,UAAU,EAAE;AACV,QAAA,EA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