@wasm-gaming/sonic3air-wasm 0.0.0 → 0.0.1

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.
@@ -0,0 +1,79 @@
1
+ # Third-party notices
2
+
3
+ `sonic3air.wasm`, `sonic3air.data` and the code inside `sonic3air.js` are **Sonic 3 A.I.R.**
4
+ ("Sonic 3 - Angel Island Revisited") by Eukaryot and contributors, taken unchanged from its official
5
+ release. Sonic 3 A.I.R. is free software under the **GNU General Public License v3** (see
6
+ [LICENSE](LICENSE)). This package ships none of SEGA's game: the player provides the
7
+ Sonic & Knuckles + Sonic 3 ROM.
8
+
9
+ | Component | Version | Licence | Where it comes from |
10
+ | --- | --- | --- | --- |
11
+ | Sonic 3 A.I.R. (Oxygen Engine, lemonscript, rmx) | `v26.03.28.0-stable` | GPL-3.0 | https://github.com/Eukaryot/sonic3air — release asset `sonic3air_web_data.zip`, SHA-256 `227ceb546388fe37051bb770fcfebcf2128cedc55646b27831f29f8b664b4b3c`, checked by `scripts/fetch-upstream.mjs` |
12
+ | SDL2 | 2.32.8 | zlib | Emscripten's `sdl2` port, linked into the binary by upstream |
13
+ | Dear ImGui | 1.92.4 | MIT | vendored by upstream (`framework/external/imgui`) |
14
+ | ProggyClean font | — | MIT (as distributed with Dear ImGui) | Dear ImGui's default font, Tristan Grimmer |
15
+
16
+ The components above are the ones identifiable in the binary. Upstream vendors its other
17
+ dependencies in its source tree (`framework/external/` at the tag above); that tree, with their
18
+ licences, is the corresponding source of this binary.
19
+
20
+ ## Sonic 3 A.I.R.
21
+
22
+ Copyright Eukaryot and contributors. Sonic 3 A.I.R. is a non-profit fan game project, not affiliated
23
+ with SEGA or Sonic Team. It is distributed under the terms of the GNU General Public License version
24
+ 3; see [LICENSE](LICENSE). **Corresponding source:** https://github.com/Eukaryot/sonic3air/tree/v26.03.28.0-stable
25
+ (build recipe: `Oxygen/sonic3air/build/_emscripten/`).
26
+
27
+ ## SDL2 (zlib licence)
28
+
29
+ ```
30
+ Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
31
+
32
+ This software is provided 'as-is', without any express or implied
33
+ warranty. In no event will the authors be held liable for any damages
34
+ arising from the use of this software.
35
+
36
+ Permission is granted to anyone to use this software for any purpose,
37
+ including commercial applications, and to alter it and redistribute it
38
+ freely, subject to the following restrictions:
39
+
40
+ 1. The origin of this software must not be misrepresented; you must not
41
+ claim that you wrote the original software. If you use this software
42
+ in a product, an acknowledgment in the product documentation would be
43
+ appreciated but is not required.
44
+ 2. Altered source versions must be plainly marked as such, and must not be
45
+ misrepresented as being the original software.
46
+ 3. This notice may not be removed or altered from any source distribution.
47
+
48
+ ```
49
+
50
+ ## Dear ImGui (MIT)
51
+
52
+ ```
53
+ The MIT License (MIT)
54
+
55
+ Copyright (c) 2014-2025 Omar Cornut
56
+
57
+ Permission is hereby granted, free of charge, to any person obtaining a copy
58
+ of this software and associated documentation files (the "Software"), to deal
59
+ in the Software without restriction, including without limitation the rights
60
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
61
+ copies of the Software, and to permit persons to whom the Software is
62
+ furnished to do so, subject to the following conditions:
63
+
64
+ The above copyright notice and this permission notice shall be included in all
65
+ copies or substantial portions of the Software.
66
+
67
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
68
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
69
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
70
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
71
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
72
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
73
+ SOFTWARE.
74
+ ```
75
+
76
+ ## ProggyClean font
77
+
78
+ Copyright (c) 2004, 2005 Tristan Grimmer. Distributed with Dear ImGui under the MIT licence above
79
+ (https://github.com/bluescan/proggyfonts).
@@ -0,0 +1,104 @@
1
+ /* sonic3air app — boot screen and pause menu (the look of the rsdk apps).
2
+ Tokens come from engine-specs (UI_TOKENS, `--wg-*`) when the host sets them; the
3
+ fallbacks are the same values, so the app looks right on a bare page too. */
4
+
5
+ .s3air-app {
6
+ --ring: var(--wg-focus-ring, 0 0 0 3px #fff);
7
+ --surface: var(--wg-surface, rgb(18 20 28 / 0.78));
8
+ --line: var(--wg-line, rgb(255 255 255 / 0.12));
9
+ --text: var(--wg-text, #f4f6fb);
10
+ --muted: var(--wg-muted, #8e97a9);
11
+ --danger: var(--wg-danger, #f87171);
12
+ --ui: var(--wg-font-ui, 'Inter Variable', 'Inter', system-ui, sans-serif);
13
+ --display: var(--wg-font-display, 'Unbounded Variable', 'Unbounded', system-ui, sans-serif);
14
+ --ease: var(--wg-ease, cubic-bezier(0.2, 0.8, 0.2, 1));
15
+ position: absolute;
16
+ inset: 0;
17
+ overflow: hidden;
18
+ background: #000;
19
+ color: var(--text);
20
+ font-family: var(--ui);
21
+ user-select: none;
22
+ -webkit-tap-highlight-color: transparent;
23
+ }
24
+ .s3air-app * { box-sizing: border-box; }
25
+ .s3air-stage { position: absolute; inset: 0; display: grid; place-items: center; }
26
+ .s3air-stage canvas { outline: none; }
27
+ .s3air-overlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
28
+ .s3air-overlay > * { pointer-events: auto; }
29
+ .s3air-app[data-screen='game'] .s3air-overlay { display: none; }
30
+
31
+ /* Everything but the game sits on a backdrop that keeps the game visible underneath. */
32
+ .s3air-app:not([data-screen='game']) .s3air-overlay {
33
+ background:
34
+ radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 70%),
35
+ rgb(4 6 12 / 0.72);
36
+ backdrop-filter: blur(14px) saturate(1.2);
37
+ -webkit-backdrop-filter: blur(14px) saturate(1.2);
38
+ }
39
+ .s3air-app[data-screen='boot'] .s3air-overlay { background-color: rgb(4 6 12 / 0.9); }
40
+
41
+ .kicker { margin: 0; font: 600 0.72rem var(--ui); letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
42
+ .s3air-app h2 { margin: 0; font: 700 clamp(1.4rem, 3vw, 2.1rem) var(--display); letter-spacing: -0.02em; }
43
+
44
+ /* ---- boot ---- */
45
+ .s3air-boot { display: grid; justify-items: center; gap: 22px; }
46
+ .s3air-boot img { width: min(260px, 50vw); border-radius: 22px; box-shadow: 0 30px 80px -30px #000; animation: s3air-breathe 2.4s var(--ease) infinite alternate; }
47
+ .s3air-boot p { margin: 0; color: var(--muted); font-weight: 500; }
48
+ @keyframes s3air-breathe { from { opacity: 0.55; transform: scale(0.98); } to { opacity: 1; transform: none; } }
49
+
50
+ /* ---- pause & confirm ---- */
51
+ .s3air-panel {
52
+ width: min(440px, 92vw); display: grid; gap: 10px; padding: 26px; border-radius: 28px;
53
+ background: rgb(20 22 31 / 0.9); border: 1px solid var(--line); box-shadow: 0 40px 100px -30px #000;
54
+ }
55
+ .s3air-panel h2 { margin-bottom: 8px; }
56
+ .s3air-panel .text { margin: 0 0 8px; color: var(--muted); line-height: 1.5; }
57
+ .item {
58
+ all: unset; box-sizing: border-box; display: grid; gap: 2px; padding: 13px 16px; border-radius: 14px;
59
+ background: rgb(255 255 255 / 0.05); font-weight: 600; cursor: pointer; transition: background 0.15s, box-shadow 0.15s;
60
+ }
61
+ .item small { font-weight: 500; font-size: 0.78rem; color: var(--muted); }
62
+ .item.is-focused { background: #fff; color: #0b0d12; box-shadow: var(--ring); }
63
+ .item.is-focused small { color: #4b5563; }
64
+ .item.is-danger.is-focused { background: var(--danger); color: #1a0505; box-shadow: 0 0 0 3px var(--danger); }
65
+ .s3air-panel .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
66
+ .s3air-panel .row .item { text-align: center; }
67
+ /* A dialog sits on its own layer, above anything the screen under it positions (the
68
+ character art on the slot cards is z-index 1), on a backdrop that hides that screen. */
69
+ .s3air-confirm {
70
+ position: absolute; inset: 0; z-index: 10; display: grid; place-items: center;
71
+ background: rgb(4 6 12 / 0.78);
72
+ backdrop-filter: blur(10px) saturate(0.8);
73
+ -webkit-backdrop-filter: blur(10px) saturate(0.8);
74
+ }
75
+ .s3air-confirm h2 { font-size: clamp(1.15rem, 2.2vw, 1.55rem); line-height: 1.2; }
76
+ .s3air-confirm .s3air-panel {
77
+ width: min(500px, 92vw);
78
+ background:
79
+ radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
80
+ #151821;
81
+ border-color: rgb(255 255 255 / 0.14);
82
+ box-shadow: 0 40px 120px -20px #000, 0 0 0 1px rgb(0 0 0 / 0.4);
83
+ }
84
+
85
+ /* ---- hints ---- */
86
+ .s3air-hints { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; color: var(--muted); font-size: 0.78rem; font-weight: 500; }
87
+ .s3air-hints span { display: inline-flex; align-items: center; gap: 7px; }
88
+ .s3air-hints kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: rgb(255 255 255 / 0.12); color: var(--text); font: 700 0.68rem var(--ui); }
89
+ .s3air-panel .s3air-hints { justify-content: flex-start; margin-top: 6px; }
90
+
91
+ @media (prefers-reduced-motion: reduce) {
92
+ .s3air-boot img { transition: none; animation: none; }
93
+ }
94
+
95
+ /* ---- touch: the pause button (UX.md: it replaces Select + Start on a touch screen) ---- */
96
+ .s3air-pause {
97
+ all: unset; position: absolute; z-index: 5; display: none; place-items: center;
98
+ top: max(10px, env(safe-area-inset-top)); left: 50%; translate: -50% 0;
99
+ width: 48px; height: 48px; border-radius: 24px; cursor: pointer;
100
+ background: rgb(0 0 0 / 0.35); border: 1px solid rgb(255 255 255 / 0.25); color: #fff; opacity: 0.7;
101
+ }
102
+ .s3air-pause::before { content: ''; width: 14px; height: 16px; border-inline: 5px solid currentColor; box-sizing: border-box; }
103
+ .s3air-app[data-screen='game'][data-touch] .s3air-pause { display: grid; }
104
+ .s3air-panel .text.is-error { color: var(--danger); }
@@ -0,0 +1,305 @@
1
+ // sonic3air's own app: what a host gets when it mounts this engine instead of driving
2
+ // the SDK itself — a boot screen, then the game with its OWN title, save select,
3
+ // options and mods, and a pause menu on the wasm-gaming usability scheme
4
+ // (engine-specs UX.md).
5
+ //
6
+ // import * as app from '<engines>/sonic3air/app/app.js'
7
+ // const handle = await app.mount(target, host) // EngineApp.mount
8
+ // await handle.unmount()
9
+ //
10
+ // `host` is engine-specs' EngineAppHost: { game, storage, assets, input, exit }.
11
+ // `assets.rom` is required (Sonic_Knuckles_wSonic3.bin), `assets.audioremaster` is
12
+ // optional. The input is the host's createInput(): resumed it delivers menu actions;
13
+ // suspended (in game) only Select+Start and Escape come through, as `menu`.
14
+ //
15
+ // No load-game screen and no save states: the game's own save select is the load
16
+ // screen, and the engine has no state to snapshot (see RECORD/).
17
+ //
18
+ // Plain JS and DOM on purpose: the app ships inside the engine's package next to the
19
+ // SDK and loads from a static server, so it imports nothing but the SDK.
20
+
21
+ import Sonic3AirSDK from '../sonic3air.sdk.js';
22
+
23
+ const ENGINE = 'sonic3air';
24
+ const OWNER = 'app';
25
+
26
+ const esc = (text) => String(text ?? '').replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
27
+
28
+ /** The error a player reads: the SDK's message without its `sonic3air: ` prefix, capitalised. */
29
+ export const describeError = (error) => {
30
+ const text = String(error?.message ?? error ?? '').replace(/^sonic3air:\s*/, '');
31
+ return text ? text[0].toUpperCase() + text.slice(1) : 'Error desconocido';
32
+ };
33
+
34
+ let cssLoaded = null;
35
+ const loadCss = () =>
36
+ (cssLoaded ??= new Promise((resolve) => {
37
+ const link = document.createElement('link');
38
+ link.rel = 'stylesheet';
39
+ link.href = new URL('./app.css', import.meta.url).href;
40
+ link.onload = link.onerror = () => resolve();
41
+ document.head.append(link);
42
+ }));
43
+
44
+ export async function mount(target, host) {
45
+ await loadCss();
46
+
47
+ const root = document.createElement('div');
48
+ root.className = 's3air-app';
49
+ root.style.setProperty('--accent', host.game?.accent ?? '#2563eb');
50
+ const stage = document.createElement('div');
51
+ stage.className = 's3air-stage';
52
+ const overlay = document.createElement('div');
53
+ overlay.className = 's3air-overlay';
54
+ const pauseButton = document.createElement('button');
55
+ pauseButton.className = 's3air-pause';
56
+ pauseButton.setAttribute('aria-label', 'Pausa');
57
+ root.append(stage, overlay, pauseButton);
58
+ target.append(root);
59
+
60
+ /** screen: 'boot' | 'game' | 'pause' | 'confirm' | 'error' */
61
+ const state = {
62
+ screen: 'boot',
63
+ status: 'Arrancando el motor…',
64
+ error: null,
65
+ pause: { items: [], focus: 0 },
66
+ confirm: null, // { title, text, yes, no, onYes, onNo, focus, under }
67
+ };
68
+
69
+ let play = null;
70
+ let leaving = false;
71
+ let destroyed = false;
72
+
73
+ const canvasFocus = () => stage.querySelector('canvas')?.focus({ preventScroll: true });
74
+ const title = () => host.game?.title ?? 'Sonic 3 A.I.R.';
75
+
76
+ // ---- screens ------------------------------------------------------------------
77
+
78
+ const hints = (pairs) =>
79
+ `<footer class="s3air-hints">${pairs.map(([k, t]) => `<span><kbd>${k}</kbd>${t}</span>`).join('')}</footer>`;
80
+
81
+ const render = () => {
82
+ if (destroyed) return;
83
+ root.dataset.screen = state.screen;
84
+ const s = state.screen;
85
+ if (s === 'game') {
86
+ overlay.innerHTML = '';
87
+ return;
88
+ }
89
+ if (s === 'boot') {
90
+ overlay.innerHTML = `<section class="s3air-boot">
91
+ ${host.game?.art ? `<img src="${esc(host.game.art)}" alt="">` : ''}
92
+ <p>${esc(state.status)}</p>
93
+ </section>`;
94
+ return;
95
+ }
96
+ if (s === 'error') {
97
+ overlay.innerHTML = `<section class="s3air-panel">
98
+ <p class="kicker">${esc(title())}</p>
99
+ <h2>No se pudo arrancar</h2>
100
+ <p class="text is-error">${esc(state.error)}</p>
101
+ <button class="item is-focused" data-exit>Volver</button>
102
+ </section>`;
103
+ return;
104
+ }
105
+ let html = '';
106
+ const base = s === 'confirm' ? state.confirm.under : s;
107
+ if (base === 'pause') {
108
+ html += `<section class="s3air-panel">
109
+ <p class="kicker">${esc(title())}</p>
110
+ <h2>Pausa</h2>
111
+ ${state.pause.items.map((item, i) => `<button class="item${i === state.pause.focus && s !== 'confirm' ? ' is-focused' : ''}" data-item="${i}">${esc(item.label)}${item.hint ? `<small>${esc(item.hint)}</small>` : ''}</button>`).join('')}
112
+ ${hints([['A', 'elegir'], ['B', 'continuar']])}
113
+ </section>`;
114
+ }
115
+ if (s === 'confirm') {
116
+ const c = state.confirm;
117
+ html += `<div class="s3air-confirm"><section class="s3air-panel">
118
+ <h2>${esc(c.title)}</h2>
119
+ ${c.text ? `<p class="text">${esc(c.text)}</p>` : ''}
120
+ <div class="row">
121
+ <button class="item${c.focus === 0 ? ' is-focused' : ''}" data-confirm="0">${esc(c.no)}</button>
122
+ <button class="item is-danger${c.focus === 1 ? ' is-focused' : ''}" data-confirm="1">${esc(c.yes)}</button>
123
+ </div>
124
+ </section></div>`;
125
+ }
126
+ overlay.innerHTML = html;
127
+ };
128
+
129
+ // ---- transitions --------------------------------------------------------------
130
+
131
+ const enterGame = () => {
132
+ state.screen = 'game';
133
+ render();
134
+ host.input.suspend();
135
+ canvasFocus();
136
+ };
137
+
138
+ const openPause = () => {
139
+ play?.pause(OWNER);
140
+ state.pause = {
141
+ focus: 0,
142
+ items: [
143
+ { label: 'Continuar', run: closePause },
144
+ { label: 'Volver al lanzador', run: askExit },
145
+ ],
146
+ };
147
+ state.screen = 'pause';
148
+ host.input.resume();
149
+ render();
150
+ };
151
+
152
+ const closePause = () => {
153
+ enterGame();
154
+ play?.resume(OWNER);
155
+ };
156
+
157
+ // A confirm sits on top of the screen it was asked from and goes back to it.
158
+ const ask = (options) => {
159
+ state.confirm = { focus: 0, under: state.screen, ...options };
160
+ state.screen = 'confirm';
161
+ render();
162
+ };
163
+ const answer = (yes) => {
164
+ const c = state.confirm;
165
+ state.screen = c.under;
166
+ state.confirm = null;
167
+ render();
168
+ (yes ? c.onYes : c.onNo)?.();
169
+ };
170
+
171
+ const exit = async () => {
172
+ if (leaving) return;
173
+ leaving = true;
174
+ try {
175
+ await play?.destroy();
176
+ } catch (error) {
177
+ console.warn(`[${ENGINE} app] destroy failed`, error);
178
+ }
179
+ play = null;
180
+ host.exit();
181
+ };
182
+
183
+ const askExit = () =>
184
+ ask({ title: '¿Volver al lanzador?', text: 'La partida se guarda donde la guarde el juego.', yes: 'Salir', no: 'Seguir', onYes: exit });
185
+
186
+ // ---- input ----------------------------------------------------------------------
187
+
188
+ const onPause = (action) => {
189
+ const p = state.pause;
190
+ if (action === 'up') p.focus = (p.focus + p.items.length - 1) % p.items.length;
191
+ else if (action === 'down') p.focus = (p.focus + 1) % p.items.length;
192
+ else if (action === 'accept') return p.items[p.focus].run();
193
+ else if (action === 'back' || action === 'menu') return closePause();
194
+ else return;
195
+ render();
196
+ };
197
+
198
+ const onConfirm = (action) => {
199
+ const c = state.confirm;
200
+ if (action === 'left' || action === 'up') c.focus = 0;
201
+ else if (action === 'right' || action === 'down') c.focus = 1;
202
+ else if (action === 'accept') return answer(c.focus === 1);
203
+ else if (action === 'back') return answer(false);
204
+ else return;
205
+ render();
206
+ };
207
+
208
+ const off = host.input.on((action) => {
209
+ if (leaving) return;
210
+ const s = state.screen;
211
+ if (s === 'game') {
212
+ if (action === 'menu') openPause();
213
+ } else if (s === 'pause') onPause(action);
214
+ else if (s === 'confirm') onConfirm(action);
215
+ else if (s === 'error' && (action === 'accept' || action === 'back')) exit();
216
+ else if (s === 'boot' && action === 'back') exit();
217
+ });
218
+
219
+ // Pointer: hover focuses, click activates — the same paths as the pad. Hover is read
220
+ // from real movement only: every render replaces the buttons, and the browser fires
221
+ // a fresh pointerover for whatever lands under a resting cursor.
222
+ let lastPointer = '';
223
+ const onPointer = (event) => {
224
+ if (event.type === 'pointermove') {
225
+ const at = `${event.clientX},${event.clientY}`;
226
+ if (at === lastPointer) return;
227
+ lastPointer = at;
228
+ }
229
+ const el = event.target.closest('[data-item],[data-confirm],[data-exit]');
230
+ if (!el || leaving) return;
231
+ if (event.type === 'pointermove') {
232
+ if (el.dataset.item != null && state.screen === 'pause' && state.pause.focus !== +el.dataset.item) {
233
+ state.pause.focus = +el.dataset.item;
234
+ render();
235
+ }
236
+ return;
237
+ }
238
+ if (el.dataset.item != null) state.pause.items[+el.dataset.item].run();
239
+ else if (el.dataset.confirm != null) answer(el.dataset.confirm === '1');
240
+ else if (el.dataset.exit != null) exit();
241
+ };
242
+ overlay.addEventListener('click', onPointer);
243
+ overlay.addEventListener('pointermove', onPointer);
244
+
245
+ // Touch: the game draws its own on-screen pad; the app adds the pause button, shown
246
+ // once a finger has touched the screen (UX.md), hidden again by a key press.
247
+ const onTouch = (event) => {
248
+ if (event.pointerType === 'touch') root.dataset.touch = '';
249
+ };
250
+ const onKey = () => delete root.dataset.touch;
251
+ root.addEventListener('pointerdown', onTouch, { capture: true });
252
+ window.addEventListener('keydown', onKey, { capture: true });
253
+ pauseButton.addEventListener('click', (event) => {
254
+ event.stopPropagation();
255
+ if (state.screen === 'game' && !leaving) openPause();
256
+ });
257
+
258
+ const handle = {
259
+ async unmount() {
260
+ destroyed = true;
261
+ leaving = true;
262
+ off();
263
+ overlay.removeEventListener('click', onPointer);
264
+ overlay.removeEventListener('pointermove', onPointer);
265
+ root.removeEventListener('pointerdown', onTouch, { capture: true });
266
+ window.removeEventListener('keydown', onKey, { capture: true });
267
+ try {
268
+ await play?.destroy();
269
+ } catch {
270
+ /* already gone */
271
+ }
272
+ play = null;
273
+ root.remove();
274
+ },
275
+ };
276
+
277
+ // ---- boot -----------------------------------------------------------------------
278
+
279
+ render();
280
+ host.input.resume();
281
+ try {
282
+ play = await new Sonic3AirSDK()
283
+ .mount(stage)
284
+ .assets(host.assets)
285
+ .storage(host.storage)
286
+ .on('error', ({ detail }) => console.error(`[${ENGINE} app]`, detail))
287
+ // The game's own quit ends the session (the SDK destroys itself): leave too.
288
+ .on('exit', () => exit())
289
+ .start();
290
+ if (destroyed) {
291
+ // Unmounted while booting: nothing to show any more.
292
+ await play.destroy().catch(() => {});
293
+ play = null;
294
+ return handle;
295
+ }
296
+ enterGame();
297
+ } catch (error) {
298
+ console.error(`[${ENGINE} app]`, error);
299
+ state.error = describeError(error);
300
+ state.screen = 'error';
301
+ render();
302
+ }
303
+
304
+ return handle;
305
+ }