@wasm-gaming/sonic3air-wasm 0.0.1 → 0.1.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.
|
@@ -89,7 +89,7 @@ export declare class Sonic3AirPlay extends EnginePlayBase<Sonic3AirPayloads> {
|
|
|
89
89
|
export declare class Sonic3AirSDK extends EngineSDKBase<Sonic3AirPayloads> {
|
|
90
90
|
static readonly id = "sonic3air";
|
|
91
91
|
/** Kept in step with package.json by `node scripts/sync-version.mjs`. */
|
|
92
|
-
static readonly version = "0.0
|
|
92
|
+
static readonly version = "0.1.0";
|
|
93
93
|
static readonly name = "Sonic 3 A.I.R.";
|
|
94
94
|
static readonly description = "Sonic 3 - Angel Island Revisited, Eukaryot's official WebAssembly build. Ships none of the game: the player provides the Sonic & Knuckles + Sonic 3 ROM, and it never leaves their browser.";
|
|
95
95
|
protected createPlay(init: EngineInit<Sonic3AirPayloads>, events: EventEmitter<EventsOf<Sonic3AirPayloads>>): Sonic3AirPlay;
|
|
@@ -591,7 +591,7 @@ export class Sonic3AirPlay extends EnginePlayBase {
|
|
|
591
591
|
export class Sonic3AirSDK extends EngineSDKBase {
|
|
592
592
|
static id = ENGINE_ID;
|
|
593
593
|
/** Kept in step with package.json by `node scripts/sync-version.mjs`. */
|
|
594
|
-
static version = '0.0
|
|
594
|
+
static version = '0.1.0';
|
|
595
595
|
static name = 'Sonic 3 A.I.R.';
|
|
596
596
|
static description = "Sonic 3 - Angel Island Revisited, Eukaryot's official WebAssembly build. Ships none of the game: the player provides the Sonic & Knuckles + Sonic 3 ROM, and it never leaves their browser.";
|
|
597
597
|
createPlay(init, events) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wasm-gaming/sonic3air-wasm",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Sonic 3 A.I.R. (Angel Island Revisited, by Eukaryot) for the web: the official WebAssembly build, pinned and checked, with a self-contained JS SDK implementing the wasm-gaming engine contract. The Sonic & Knuckles + Sonic 3 ROM is provided at runtime.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"scripts": {},
|
|
40
40
|
"comment:dependencies": "engine-specs is the one wasm-gaming package an engine depends on. Its runtime is also copied into dist/sonic3air/ and imported relatively, so the built SDK loads without a bundler or an import map; the dependency carries the types.",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@wasm-gaming/engine-specs": "^0.
|
|
42
|
+
"@wasm-gaming/engine-specs": "^0.6.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.5.0"
|
package/src/app/app.js
CHANGED
|
@@ -16,19 +16,44 @@
|
|
|
16
16
|
// screen, and the engine has no state to snapshot (see RECORD/).
|
|
17
17
|
//
|
|
18
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
|
|
19
|
+
// SDK and loads from a static server, so it imports nothing but the SDK and the contract
|
|
20
|
+
// runtime shipped beside it (`../engine-specs.js`).
|
|
20
21
|
|
|
21
22
|
import Sonic3AirSDK from '../sonic3air.sdk.js';
|
|
23
|
+
import { createFullscreenToggle, createWakeLock, resolveLocale } from '../engine-specs.js';
|
|
22
24
|
|
|
23
25
|
const ENGINE = 'sonic3air';
|
|
24
26
|
const OWNER = 'app';
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The app's words, in English and Spanish (engine-specs UX.md, "Languages"). The game's own
|
|
30
|
+
* menus stay as the game ships them.
|
|
31
|
+
*/
|
|
32
|
+
const STRINGS = {
|
|
33
|
+
booting: { en: 'Starting the engine…', es: 'Arrancando el motor…' },
|
|
34
|
+
bootFailed: { en: 'Could not start', es: 'No se pudo arrancar' },
|
|
35
|
+
back: { en: 'Back', es: 'Volver' },
|
|
36
|
+
paused: { en: 'Paused', es: 'Pausa' },
|
|
37
|
+
choose: { en: 'choose', es: 'elegir' },
|
|
38
|
+
continueHint: { en: 'continue', es: 'continuar' },
|
|
39
|
+
continue: { en: 'Continue', es: 'Continuar' },
|
|
40
|
+
fullscreen: { en: 'Fullscreen', es: 'Pantalla completa' },
|
|
41
|
+
fullscreenHint: { en: 'Alt+Enter · Select + Y', es: 'Alt+Enter · Select + Y' },
|
|
42
|
+
fullscreenHintMac: { en: 'Cmd+Enter · Select + Y', es: 'Cmd+Enter · Select + Y' },
|
|
43
|
+
exit: { en: 'Back to the launcher', es: 'Volver al lanzador' },
|
|
44
|
+
leaveAsk: { en: 'Back to the launcher?', es: '¿Volver al lanzador?' },
|
|
45
|
+
leaveText: { en: 'The game saves where the game itself saves.', es: 'La partida se guarda donde la guarde el juego.' },
|
|
46
|
+
leave: { en: 'Leave', es: 'Salir' },
|
|
47
|
+
stay: { en: 'Stay', es: 'Seguir' },
|
|
48
|
+
unknownError: { en: 'Unknown error', es: 'Error desconocido' },
|
|
49
|
+
};
|
|
50
|
+
|
|
26
51
|
const esc = (text) => String(text ?? '').replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
27
52
|
|
|
28
53
|
/** The error a player reads: the SDK's message without its `sonic3air: ` prefix, capitalised. */
|
|
29
|
-
export const describeError = (error) => {
|
|
54
|
+
export const describeError = (error, unknown = STRINGS.unknownError.es) => {
|
|
30
55
|
const text = String(error?.message ?? error ?? '').replace(/^sonic3air:\s*/, '');
|
|
31
|
-
return text ? text[0].toUpperCase() + text.slice(1) :
|
|
56
|
+
return text ? text[0].toUpperCase() + text.slice(1) : unknown;
|
|
32
57
|
};
|
|
33
58
|
|
|
34
59
|
let cssLoaded = null;
|
|
@@ -44,6 +69,9 @@ const loadCss = () =>
|
|
|
44
69
|
export async function mount(target, host) {
|
|
45
70
|
await loadCss();
|
|
46
71
|
|
|
72
|
+
const locale = host.locale ?? resolveLocale();
|
|
73
|
+
const t = (key) => STRINGS[key]?.[locale] ?? STRINGS[key]?.en ?? key;
|
|
74
|
+
|
|
47
75
|
const root = document.createElement('div');
|
|
48
76
|
root.className = 's3air-app';
|
|
49
77
|
root.style.setProperty('--accent', host.game?.accent ?? '#2563eb');
|
|
@@ -53,14 +81,14 @@ export async function mount(target, host) {
|
|
|
53
81
|
overlay.className = 's3air-overlay';
|
|
54
82
|
const pauseButton = document.createElement('button');
|
|
55
83
|
pauseButton.className = 's3air-pause';
|
|
56
|
-
pauseButton.setAttribute('aria-label', '
|
|
84
|
+
pauseButton.setAttribute('aria-label', t('paused'));
|
|
57
85
|
root.append(stage, overlay, pauseButton);
|
|
58
86
|
target.append(root);
|
|
59
87
|
|
|
60
88
|
/** screen: 'boot' | 'game' | 'pause' | 'confirm' | 'error' */
|
|
61
89
|
const state = {
|
|
62
90
|
screen: 'boot',
|
|
63
|
-
status: '
|
|
91
|
+
status: t('booting'),
|
|
64
92
|
error: null,
|
|
65
93
|
pause: { items: [], focus: 0 },
|
|
66
94
|
confirm: null, // { title, text, yes, no, onYes, onNo, focus, under }
|
|
@@ -78,8 +106,15 @@ export async function mount(target, host) {
|
|
|
78
106
|
const hints = (pairs) =>
|
|
79
107
|
`<footer class="s3air-hints">${pairs.map(([k, t]) => `<span><kbd>${k}</kbd>${t}</span>`).join('')}</footer>`;
|
|
80
108
|
|
|
109
|
+
// Fullscreen (Cmd+Enter / Alt+Enter, Select + Y, and the pause-menu entry), and the screen
|
|
110
|
+
// kept on while playing. There is no Ajustes screen here: the game's own Options hold the
|
|
111
|
+
// display settings, so the Wake Lock is always on.
|
|
112
|
+
const fullscreen = createFullscreenToggle(root);
|
|
113
|
+
const wake = createWakeLock();
|
|
114
|
+
|
|
81
115
|
const render = () => {
|
|
82
116
|
if (destroyed) return;
|
|
117
|
+
wake.setActive(state.screen === 'game');
|
|
83
118
|
root.dataset.screen = state.screen;
|
|
84
119
|
const s = state.screen;
|
|
85
120
|
if (s === 'game') {
|
|
@@ -96,9 +131,9 @@ export async function mount(target, host) {
|
|
|
96
131
|
if (s === 'error') {
|
|
97
132
|
overlay.innerHTML = `<section class="s3air-panel">
|
|
98
133
|
<p class="kicker">${esc(title())}</p>
|
|
99
|
-
<h2
|
|
134
|
+
<h2>${esc(t('bootFailed'))}</h2>
|
|
100
135
|
<p class="text is-error">${esc(state.error)}</p>
|
|
101
|
-
<button class="item is-focused" data-exit
|
|
136
|
+
<button class="item is-focused" data-exit>${esc(t('back'))}</button>
|
|
102
137
|
</section>`;
|
|
103
138
|
return;
|
|
104
139
|
}
|
|
@@ -107,9 +142,9 @@ export async function mount(target, host) {
|
|
|
107
142
|
if (base === 'pause') {
|
|
108
143
|
html += `<section class="s3air-panel">
|
|
109
144
|
<p class="kicker">${esc(title())}</p>
|
|
110
|
-
<h2
|
|
145
|
+
<h2>${esc(t('paused'))}</h2>
|
|
111
146
|
${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', '
|
|
147
|
+
${hints([['A', t('choose')], ['B', t('continueHint')]])}
|
|
113
148
|
</section>`;
|
|
114
149
|
}
|
|
115
150
|
if (s === 'confirm') {
|
|
@@ -140,8 +175,13 @@ export async function mount(target, host) {
|
|
|
140
175
|
state.pause = {
|
|
141
176
|
focus: 0,
|
|
142
177
|
items: [
|
|
143
|
-
{ label: '
|
|
144
|
-
{
|
|
178
|
+
{ label: t('continue'), run: closePause },
|
|
179
|
+
{
|
|
180
|
+
label: t('fullscreen'),
|
|
181
|
+
hint: /mac|iphone|ipad/i.test(navigator.userAgentData?.platform || navigator.platform || '') ? t('fullscreenHintMac') : t('fullscreenHint'),
|
|
182
|
+
run: () => fullscreen.toggle(),
|
|
183
|
+
},
|
|
184
|
+
{ label: t('exit'), run: askExit },
|
|
145
185
|
],
|
|
146
186
|
};
|
|
147
187
|
state.screen = 'pause';
|
|
@@ -181,7 +221,7 @@ export async function mount(target, host) {
|
|
|
181
221
|
};
|
|
182
222
|
|
|
183
223
|
const askExit = () =>
|
|
184
|
-
ask({ title: '
|
|
224
|
+
ask({ title: t('leaveAsk'), text: t('leaveText'), yes: t('leave'), no: t('stay'), onYes: exit });
|
|
185
225
|
|
|
186
226
|
// ---- input ----------------------------------------------------------------------
|
|
187
227
|
|
|
@@ -270,6 +310,8 @@ export async function mount(target, host) {
|
|
|
270
310
|
/* already gone */
|
|
271
311
|
}
|
|
272
312
|
play = null;
|
|
313
|
+
fullscreen.destroy();
|
|
314
|
+
wake.destroy();
|
|
273
315
|
root.remove();
|
|
274
316
|
},
|
|
275
317
|
};
|
|
@@ -296,7 +338,7 @@ export async function mount(target, host) {
|
|
|
296
338
|
enterGame();
|
|
297
339
|
} catch (error) {
|
|
298
340
|
console.error(`[${ENGINE} app]`, error);
|
|
299
|
-
state.error = describeError(error);
|
|
341
|
+
state.error = describeError(error, t('unknownError'));
|
|
300
342
|
state.screen = 'error';
|
|
301
343
|
render();
|
|
302
344
|
}
|
package/src/sonic3air.sdk.ts
CHANGED
|
@@ -666,7 +666,7 @@ export class Sonic3AirPlay extends EnginePlayBase<Sonic3AirPayloads> {
|
|
|
666
666
|
export class Sonic3AirSDK extends EngineSDKBase<Sonic3AirPayloads> {
|
|
667
667
|
static readonly id = ENGINE_ID;
|
|
668
668
|
/** Kept in step with package.json by `node scripts/sync-version.mjs`. */
|
|
669
|
-
static readonly version = '0.0
|
|
669
|
+
static readonly version = '0.1.0';
|
|
670
670
|
static readonly name = 'Sonic 3 A.I.R.';
|
|
671
671
|
static readonly description =
|
|
672
672
|
"Sonic 3 - Angel Island Revisited, Eukaryot's official WebAssembly build. Ships none of the game: the player provides the Sonic & Knuckles + Sonic 3 ROM, and it never leaves their browser.";
|