@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.
- package/dist/sonic3air/LICENSE +674 -0
- package/dist/sonic3air/THIRD_PARTY_NOTICES.md +79 -0
- package/dist/sonic3air/app/app.css +104 -0
- package/dist/sonic3air/app/app.js +305 -0
- package/dist/sonic3air/engine-specs.js +1546 -0
- package/dist/sonic3air/sonic3air.data +0 -0
- package/dist/sonic3air/sonic3air.data.json +64 -0
- package/dist/sonic3air/sonic3air.js +42 -0
- package/dist/sonic3air/sonic3air.options.d.ts +68 -0
- package/dist/sonic3air/sonic3air.options.d.ts.map +1 -0
- package/dist/sonic3air/sonic3air.options.js +35 -0
- package/dist/sonic3air/sonic3air.options.js.map +1 -0
- package/dist/sonic3air/sonic3air.sdk.d.ts +100 -0
- package/dist/sonic3air/sonic3air.sdk.d.ts.map +1 -0
- package/dist/sonic3air/sonic3air.sdk.js +604 -0
- package/dist/sonic3air/sonic3air.sdk.js.map +1 -0
- package/dist/sonic3air/sonic3air.wasm +0 -0
- package/package.json +1 -1
- package/src/sonic3air.sdk.ts +1 -1
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine package's entry point: an `EngineSDK` for Sonic 3 A.I.R.
|
|
3
|
+
*
|
|
4
|
+
* ```js
|
|
5
|
+
* import Sonic3AirSDK from '@wasm-gaming/sonic3air-wasm';
|
|
6
|
+
*
|
|
7
|
+
* const play = await new Sonic3AirSDK()
|
|
8
|
+
* .assets({ rom: () => readRom() }) // Sonic_Knuckles_wSonic3.bin: bytes, or a thunk
|
|
9
|
+
* .storage({ namespace: 'sonic3air' }) // → OPFS sonic3air/sonic3air/
|
|
10
|
+
* .mount(document.querySelector('#stage'))
|
|
11
|
+
* .start();
|
|
12
|
+
*
|
|
13
|
+
* play.pause('menu'); play.resume('menu');
|
|
14
|
+
* await play.destroy(); // save data flushed, loop stopped, audio closed
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The engine is Eukaryot's **official** WebAssembly build, unchanged (see
|
|
18
|
+
* scripts/fetch-upstream.mjs): `sonic3air.js` is its Emscripten glue scoped in an ES
|
|
19
|
+
* factory, `sonic3air.data` its own data package, unpacked into `/sonic3air/`. The
|
|
20
|
+
* game's menus — title, save select, options, mods — are its own.
|
|
21
|
+
*
|
|
22
|
+
* What the official page did, this does instead:
|
|
23
|
+
* - the ROM comes from `assets.rom` (validated here) — no file prompt;
|
|
24
|
+
* - the save data folder `/sonic3air/savedata` is in memory, seeded from OPFS
|
|
25
|
+
* `sonic3air/<namespace>/` before the game starts and mirrored back when the game
|
|
26
|
+
* syncs it, every 10 s, on pause, on page hide and on destroy — no IndexedDB;
|
|
27
|
+
* - the remastered soundtrack is `assets.audioremaster`, never downloaded;
|
|
28
|
+
* - the in-game file manager's hooks (import, export, rename) are provided while a
|
|
29
|
+
* session runs.
|
|
30
|
+
*/
|
|
31
|
+
import { EnginePlayBase, EngineSDKBase, EventEmitter, } from './engine-specs.js';
|
|
32
|
+
import { SONIC3AIR_SPEC, SONIC3AIR_VIDEO, } from './sonic3air.options.js';
|
|
33
|
+
export { SONIC3AIR_SPEC, SONIC3AIR_VIDEO } from './sonic3air.options.js';
|
|
34
|
+
const ENGINE_ID = 'sonic3air';
|
|
35
|
+
const DEFAULT_STORAGE_NAMESPACE = 'default';
|
|
36
|
+
const GAME_ROOT = '/sonic3air';
|
|
37
|
+
const SAVEDATA = `${GAME_ROOT}/savedata`;
|
|
38
|
+
/** The name and place the engine reads the ROM from (its `RomPath`). */
|
|
39
|
+
export const ROM_FILE = 'Sonic_Knuckles_wSonic3.bin';
|
|
40
|
+
export const AUDIO_REMASTER_FILE = 'audioremaster.bin';
|
|
41
|
+
/** Inputs the host owns, and the engine's log: never mirrored. */
|
|
42
|
+
const NOT_SAVES = new Set([ROM_FILE, AUDIO_REMASTER_FILE, 'logfile.txt']);
|
|
43
|
+
const SAVE_INTERVAL_MS = 10_000;
|
|
44
|
+
/** Sonic & Knuckles with Sonic 3 locked on: 4 MB, serial `MK-1563` in the header. */
|
|
45
|
+
export const ROM_SIZE = 4 * 1024 * 1024;
|
|
46
|
+
const SERIAL_OFFSET = 0x180;
|
|
47
|
+
/**
|
|
48
|
+
* Where an engine keeps one namespace: `<engineId>/<namespace>`, relative to the OPFS
|
|
49
|
+
* root. Identical in every wasm-gaming engine: segments cleaned, `.` and `..` dropped,
|
|
50
|
+
* anything outside `[A-Za-z0-9._-]` → `_`, nothing usable → `default`; a leading
|
|
51
|
+
* `<engineId>/` is stripped once.
|
|
52
|
+
*/
|
|
53
|
+
export function storagePath(engineId, namespace) {
|
|
54
|
+
const segments = typeof namespace === 'string'
|
|
55
|
+
? namespace
|
|
56
|
+
.split('/')
|
|
57
|
+
.map((segment) => segment.trim())
|
|
58
|
+
.filter((segment) => segment && segment !== '.' && segment !== '..')
|
|
59
|
+
.map((segment) => segment.replace(/[^A-Za-z0-9._-]/g, '_'))
|
|
60
|
+
: [];
|
|
61
|
+
const prefixed = segments.length > 1 && segments[0] === engineId;
|
|
62
|
+
if (prefixed)
|
|
63
|
+
segments.shift();
|
|
64
|
+
const cleaned = segments.join('/') || DEFAULT_STORAGE_NAMESPACE;
|
|
65
|
+
return { namespace: cleaned, path: `${engineId}/${cleaned}`, prefixed };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Is this the ROM Sonic 3 A.I.R. needs? The same test as the official page: 4 MB and
|
|
69
|
+
* serial MK-1563 (Sonic & Knuckles, with Sonic 3 locked on) at 0x180. `reason` says
|
|
70
|
+
* what is wrong in words a player can act on.
|
|
71
|
+
*/
|
|
72
|
+
export function checkRom(bytes) {
|
|
73
|
+
if (!bytes || bytes.length === 0) {
|
|
74
|
+
return { ok: false, reason: `no ROM — Sonic 3 A.I.R. needs ${ROM_FILE} (Sonic & Knuckles + Sonic 3)` };
|
|
75
|
+
}
|
|
76
|
+
const serial = String.fromCharCode(...bytes.subarray(SERIAL_OFFSET, SERIAL_OFFSET + 14));
|
|
77
|
+
const isLockOn = /MK-1563/.test(serial);
|
|
78
|
+
if (bytes.length === ROM_SIZE && isLockOn)
|
|
79
|
+
return { ok: true };
|
|
80
|
+
if (bytes.length === ROM_SIZE / 2) {
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
reason: 'this is Sonic 3 or Sonic & Knuckles on its own (2 MB); Sonic 3 A.I.R. needs both locked on: ' +
|
|
84
|
+
`"Sonic & Knuckles + Sonic 3" (${ROM_FILE}, 4 MB)`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (bytes.length !== ROM_SIZE) {
|
|
88
|
+
return { ok: false, reason: `the ROM is ${bytes.length} bytes; ${ROM_FILE} has ${ROM_SIZE} (4 MB)` };
|
|
89
|
+
}
|
|
90
|
+
return { ok: false, reason: `not Sonic & Knuckles + Sonic 3 (serial "${serial.trim()}", expected MK-1563)` };
|
|
91
|
+
}
|
|
92
|
+
async function resolveAsset(asset, name) {
|
|
93
|
+
const value = typeof asset === 'function' ? await asset() : asset;
|
|
94
|
+
if (value == null)
|
|
95
|
+
return null;
|
|
96
|
+
if (value instanceof Uint8Array)
|
|
97
|
+
return value;
|
|
98
|
+
if (value instanceof ArrayBuffer)
|
|
99
|
+
return new Uint8Array(value);
|
|
100
|
+
throw new TypeError(`sonic3air: assets.${name} must be a Uint8Array, an ArrayBuffer or a thunk returning one`);
|
|
101
|
+
}
|
|
102
|
+
async function fetchBytes(url) {
|
|
103
|
+
const response = await fetch(url);
|
|
104
|
+
if (!response.ok)
|
|
105
|
+
throw new Error(`sonic3air: ${response.status} ${response.statusText} for ${url}`);
|
|
106
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
107
|
+
}
|
|
108
|
+
/** Write `sonic3air.data`'s files into the FS, as the official loader did. */
|
|
109
|
+
function unpackData(FS, data, pkg) {
|
|
110
|
+
if (data.length !== pkg.size)
|
|
111
|
+
throw new Error(`sonic3air: sonic3air.data is ${data.length} bytes, expected ${pkg.size}`);
|
|
112
|
+
for (const file of pkg.files) {
|
|
113
|
+
const dir = file.path.slice(0, file.path.lastIndexOf('/'));
|
|
114
|
+
FS.mkdirTree(dir);
|
|
115
|
+
FS.writeFile(file.path, data.subarray(file.start, file.end));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async function opfsDir(path, create) {
|
|
119
|
+
if (typeof navigator === 'undefined' || !navigator.storage?.getDirectory)
|
|
120
|
+
return null;
|
|
121
|
+
try {
|
|
122
|
+
let dir = await navigator.storage.getDirectory();
|
|
123
|
+
for (const segment of path.split('/').filter(Boolean)) {
|
|
124
|
+
dir = await dir.getDirectoryHandle(segment, { create });
|
|
125
|
+
}
|
|
126
|
+
return dir;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** Every file under `dir` (OPFS), as `[relative path, handle]`. */
|
|
133
|
+
async function* opfsFiles(dir, prefix = '') {
|
|
134
|
+
for await (const [name, handle] of dir.entries()) {
|
|
135
|
+
if (handle.kind === 'file')
|
|
136
|
+
yield [`${prefix}${name}`, handle];
|
|
137
|
+
else
|
|
138
|
+
yield* opfsFiles(handle, `${prefix}${name}/`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** A file's identity for the mirror: changes whenever the game writes it. */
|
|
142
|
+
const stamp = (stat) => `${stat.size}:${stat.mtime instanceof Date ? stat.mtime.getTime() : stat.mtime}`;
|
|
143
|
+
/** Is this save-data path (relative to savedata) one the mirror keeps? */
|
|
144
|
+
export const isMirrored = (relative) => !NOT_SAVES.has(relative);
|
|
145
|
+
/** The live engine: one booted Sonic 3 A.I.R. and its session. */
|
|
146
|
+
export class Sonic3AirPlay extends EnginePlayBase {
|
|
147
|
+
#module = null;
|
|
148
|
+
#destroyed = false;
|
|
149
|
+
#pauseOwner = null;
|
|
150
|
+
#muted = false;
|
|
151
|
+
#canvas = null;
|
|
152
|
+
#ownsCanvas = false;
|
|
153
|
+
#box = null;
|
|
154
|
+
#boxObserver = null;
|
|
155
|
+
#onResize = () => this.#fit();
|
|
156
|
+
#namespace = DEFAULT_STORAGE_NAMESPACE;
|
|
157
|
+
#storagePath = `${ENGINE_ID}/${DEFAULT_STORAGE_NAMESPACE}`;
|
|
158
|
+
#persist = true;
|
|
159
|
+
#saveTimer = null;
|
|
160
|
+
/** Mirrored files (relative to savedata) → the stamp they had when last written to OPFS. */
|
|
161
|
+
#mirrored = new Map();
|
|
162
|
+
#flushing = null;
|
|
163
|
+
#flushAgain = false;
|
|
164
|
+
#onHidden = () => {
|
|
165
|
+
if (document.visibilityState === 'hidden')
|
|
166
|
+
void this.flushSaves();
|
|
167
|
+
};
|
|
168
|
+
#onPageHide = () => void this.flushSaves();
|
|
169
|
+
#hooks = null;
|
|
170
|
+
#fileInput = null;
|
|
171
|
+
constructor(init, events) {
|
|
172
|
+
super(SONIC3AIR_SPEC, init, events);
|
|
173
|
+
}
|
|
174
|
+
get namespace() {
|
|
175
|
+
return this.#namespace;
|
|
176
|
+
}
|
|
177
|
+
/** Where this session's save data lives, relative to the OPFS root: `sonic3air/<namespace>`. */
|
|
178
|
+
get storagePath() {
|
|
179
|
+
return this.#storagePath;
|
|
180
|
+
}
|
|
181
|
+
get pausedBy() {
|
|
182
|
+
return this.#pauseOwner;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Freeze the game and its sound. The first caller owns the pause; only that owner's
|
|
186
|
+
* {@link resume} lifts it. The save data is flushed.
|
|
187
|
+
*/
|
|
188
|
+
pause(owner = 'host') {
|
|
189
|
+
const Module = this.#module;
|
|
190
|
+
if (!Module || this.#pauseOwner)
|
|
191
|
+
return;
|
|
192
|
+
this.#pauseOwner = owner;
|
|
193
|
+
Module.pauseMainLoop();
|
|
194
|
+
void Module.SDL2?.audioContext?.suspend();
|
|
195
|
+
void this.flushSaves();
|
|
196
|
+
this.emit('pause', { owner });
|
|
197
|
+
}
|
|
198
|
+
resume(owner = 'host') {
|
|
199
|
+
const Module = this.#module;
|
|
200
|
+
if (!Module || this.#pauseOwner !== owner)
|
|
201
|
+
return;
|
|
202
|
+
this.#pauseOwner = null;
|
|
203
|
+
if (!this.#muted)
|
|
204
|
+
void Module.SDL2?.audioContext?.resume();
|
|
205
|
+
Module.resumeMainLoop();
|
|
206
|
+
this.emit('resume', { owner });
|
|
207
|
+
}
|
|
208
|
+
/** Silence the game without stopping it. Independent of {@link pause}. */
|
|
209
|
+
mute(muted = true) {
|
|
210
|
+
this.#muted = muted;
|
|
211
|
+
const context = this.#module?.SDL2?.audioContext;
|
|
212
|
+
if (muted)
|
|
213
|
+
void context?.suspend();
|
|
214
|
+
else if (!this.#pauseOwner)
|
|
215
|
+
void context?.resume();
|
|
216
|
+
}
|
|
217
|
+
get muted() {
|
|
218
|
+
return this.#muted;
|
|
219
|
+
}
|
|
220
|
+
/** Copy the game's changed save data to OPFS `sonic3air/<namespace>/`; emits `saves`. */
|
|
221
|
+
flushSaves() {
|
|
222
|
+
if (this.#flushing) {
|
|
223
|
+
// Something changed while a flush was walking the folder: run once more after it.
|
|
224
|
+
this.#flushAgain = true;
|
|
225
|
+
return this.#flushing;
|
|
226
|
+
}
|
|
227
|
+
this.#flushing = (async () => {
|
|
228
|
+
do {
|
|
229
|
+
this.#flushAgain = false;
|
|
230
|
+
await this.#flush();
|
|
231
|
+
} while (this.#flushAgain);
|
|
232
|
+
})().finally(() => {
|
|
233
|
+
this.#flushing = null;
|
|
234
|
+
});
|
|
235
|
+
return this.#flushing;
|
|
236
|
+
}
|
|
237
|
+
// ---- Contract hooks ----
|
|
238
|
+
mounted(target) {
|
|
239
|
+
if (target instanceof HTMLCanvasElement) {
|
|
240
|
+
this.#canvas = target;
|
|
241
|
+
this.#ownsCanvas = false;
|
|
242
|
+
this.#box = target.parentElement;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.#canvas = document.createElement('canvas');
|
|
246
|
+
this.#ownsCanvas = true;
|
|
247
|
+
this.#box = target;
|
|
248
|
+
target.appendChild(this.#canvas);
|
|
249
|
+
}
|
|
250
|
+
// Emscripten's SDL2 port also finds its window with querySelector('#canvas').
|
|
251
|
+
this.#canvas.id = 'canvas';
|
|
252
|
+
this.#canvas.tabIndex = 0;
|
|
253
|
+
this.#canvas.style.display = 'block';
|
|
254
|
+
this.#canvas.addEventListener('contextmenu', (event) => event.preventDefault());
|
|
255
|
+
if (this.#ownsCanvas && this.#box) {
|
|
256
|
+
this.#boxObserver?.disconnect();
|
|
257
|
+
this.#boxObserver = new ResizeObserver(() => this.#fit());
|
|
258
|
+
this.#boxObserver.observe(this.#box);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
async open(_options) {
|
|
262
|
+
if (this.#destroyed || this.#module) {
|
|
263
|
+
// main() runs once per page and owns the loop.
|
|
264
|
+
throw new Error('sonic3air: the engine cannot be restarted in process — destroy() and start a new page (or iframe)');
|
|
265
|
+
}
|
|
266
|
+
await this.#boot();
|
|
267
|
+
}
|
|
268
|
+
patched(_kind, _patch) {
|
|
269
|
+
// Nothing in SONIC3AIR_SPEC is live.
|
|
270
|
+
}
|
|
271
|
+
async close() {
|
|
272
|
+
if (this.#saveTimer)
|
|
273
|
+
clearInterval(this.#saveTimer);
|
|
274
|
+
this.#saveTimer = null;
|
|
275
|
+
document.removeEventListener('visibilitychange', this.#onHidden);
|
|
276
|
+
window.removeEventListener('pagehide', this.#onPageHide);
|
|
277
|
+
window.removeEventListener('resize', this.#onResize);
|
|
278
|
+
const Module = this.#module;
|
|
279
|
+
if (Module) {
|
|
280
|
+
await this.flushSaves();
|
|
281
|
+
try {
|
|
282
|
+
Module.pauseMainLoop();
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
/* already stopped */
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
await Module.SDL2?.audioContext?.close();
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
/* already closed */
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
this.#removeFileManagerHooks();
|
|
295
|
+
this.#boxObserver?.disconnect();
|
|
296
|
+
this.#boxObserver = null;
|
|
297
|
+
if (this.#ownsCanvas)
|
|
298
|
+
this.#canvas?.remove();
|
|
299
|
+
this.#canvas = null;
|
|
300
|
+
this.#module = null;
|
|
301
|
+
this.#pauseOwner = null;
|
|
302
|
+
this.#destroyed = true;
|
|
303
|
+
}
|
|
304
|
+
// ---- Boot ----
|
|
305
|
+
async #boot() {
|
|
306
|
+
const config = await this.#values('config');
|
|
307
|
+
const assets = await this.#values('assets');
|
|
308
|
+
const storage = await this.#values('storage');
|
|
309
|
+
if (!this.#canvas)
|
|
310
|
+
throw new Error('sonic3air: mount() an element (or a canvas) before start()');
|
|
311
|
+
// The ROM first: a wrong file is the likeliest failure, and it needs no engine.
|
|
312
|
+
const rom = await resolveAsset(assets.rom, 'rom');
|
|
313
|
+
const verdict = checkRom(rom);
|
|
314
|
+
if (!verdict.ok)
|
|
315
|
+
throw new Error(`sonic3air: ${verdict.reason}`);
|
|
316
|
+
const resolved = storagePath(ENGINE_ID, storage.namespace);
|
|
317
|
+
if (resolved.prefixed) {
|
|
318
|
+
console.warn(`[sonic3air] storage.namespace no longer needs the "${ENGINE_ID}/" prefix. Pass "${resolved.namespace}".`);
|
|
319
|
+
}
|
|
320
|
+
this.#namespace = resolved.namespace;
|
|
321
|
+
this.#storagePath = resolved.path;
|
|
322
|
+
this.#persist = storage.persist !== null;
|
|
323
|
+
const jsUrl = config.jsUrl ?? new URL('./sonic3air.js', import.meta.url).href;
|
|
324
|
+
const wasmUrl = config.wasmUrl ?? new URL('./sonic3air.wasm', import.meta.url).href;
|
|
325
|
+
const dataUrl = config.dataUrl ?? new URL('./sonic3air.data', import.meta.url).href;
|
|
326
|
+
// The data package downloads while the wasm compiles.
|
|
327
|
+
const data = Promise.all([
|
|
328
|
+
fetchBytes(dataUrl),
|
|
329
|
+
fetch(`${dataUrl}.json`).then((response) => {
|
|
330
|
+
if (!response.ok)
|
|
331
|
+
throw new Error(`sonic3air: ${response.status} for ${dataUrl}.json`);
|
|
332
|
+
return response.json();
|
|
333
|
+
}),
|
|
334
|
+
]);
|
|
335
|
+
data.catch(() => { }); // awaited below; never an unhandled rejection meanwhile
|
|
336
|
+
const { default: createSonic3Air } = (await import(/* @vite-ignore */ jsUrl));
|
|
337
|
+
const Module = await createSonic3Air({
|
|
338
|
+
canvas: this.#canvas,
|
|
339
|
+
noInitialRun: true,
|
|
340
|
+
locateFile: (path) => (path.endsWith('.wasm') ? wasmUrl : new URL(path, jsUrl).href),
|
|
341
|
+
print: (text) => console.debug('[sonic3air]', text.trimEnd()),
|
|
342
|
+
printErr: (text) => console.warn('[sonic3air]', text.trimEnd()),
|
|
343
|
+
// The game quit by itself (its own "exit"): the session ends like a destroy().
|
|
344
|
+
onExit: () => {
|
|
345
|
+
if (!this.#destroyed)
|
|
346
|
+
void this.destroy().catch(() => { });
|
|
347
|
+
},
|
|
348
|
+
// A crash once running (one while starting rejects the factory instead).
|
|
349
|
+
onAbort: (what) => {
|
|
350
|
+
if (this.#module)
|
|
351
|
+
this.emit('error', new Error(`sonic3air: aborted — ${String(what)}`));
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
this.#module = Module;
|
|
355
|
+
const FS = Module.FS;
|
|
356
|
+
const [bytes, pkg] = await data;
|
|
357
|
+
unpackData(FS, bytes, pkg);
|
|
358
|
+
FS.mkdirTree(SAVEDATA);
|
|
359
|
+
FS.mkdirTree(`${GAME_ROOT}/___internal`);
|
|
360
|
+
if (this.#persist)
|
|
361
|
+
await this.#restoreSaves();
|
|
362
|
+
FS.writeFile(`${SAVEDATA}/${ROM_FILE}`, rom);
|
|
363
|
+
const remaster = await resolveAsset(assets.audioremaster, 'audioremaster');
|
|
364
|
+
if (remaster)
|
|
365
|
+
FS.writeFile(`${GAME_ROOT}/data/${AUDIO_REMASTER_FILE}`, remaster);
|
|
366
|
+
// The game calls FS.syncfs(false) right after it writes its save data: that is
|
|
367
|
+
// when the mirror copies it out (the official page synced IndexedDB there).
|
|
368
|
+
const syncfs = FS.syncfs.bind(FS);
|
|
369
|
+
FS.syncfs = (populate, callback) => {
|
|
370
|
+
syncfs(populate, callback);
|
|
371
|
+
if (populate !== true)
|
|
372
|
+
void this.flushSaves();
|
|
373
|
+
};
|
|
374
|
+
this.#installFileManagerHooks(Module);
|
|
375
|
+
FS.chdir(GAME_ROOT);
|
|
376
|
+
Module.callMain([]);
|
|
377
|
+
if (this.#persist) {
|
|
378
|
+
this.#saveTimer = setInterval(() => void this.flushSaves(), SAVE_INTERVAL_MS);
|
|
379
|
+
document.addEventListener('visibilitychange', this.#onHidden);
|
|
380
|
+
window.addEventListener('pagehide', this.#onPageHide);
|
|
381
|
+
}
|
|
382
|
+
window.addEventListener('resize', this.#onResize);
|
|
383
|
+
this.#fit();
|
|
384
|
+
}
|
|
385
|
+
async #values(kind) {
|
|
386
|
+
const described = (await this[kind]());
|
|
387
|
+
const out = {};
|
|
388
|
+
for (const [key, property] of Object.entries(described))
|
|
389
|
+
out[key] = property.value;
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
392
|
+
// ---- Save data mirror ----
|
|
393
|
+
/** Every file under savedata the mirror keeps, relative path → stamp. */
|
|
394
|
+
#walk() {
|
|
395
|
+
const FS = this.#module.FS;
|
|
396
|
+
const found = new Map();
|
|
397
|
+
const visit = (dir, prefix) => {
|
|
398
|
+
let names;
|
|
399
|
+
try {
|
|
400
|
+
names = FS.readdir(dir);
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
for (const name of names) {
|
|
406
|
+
if (name === '.' || name === '..')
|
|
407
|
+
continue;
|
|
408
|
+
const path = `${dir}/${name}`;
|
|
409
|
+
const stat = FS.stat(path);
|
|
410
|
+
if (FS.isDir(stat.mode))
|
|
411
|
+
visit(path, `${prefix}${name}/`);
|
|
412
|
+
else if (FS.isFile(stat.mode) && isMirrored(`${prefix}${name}`))
|
|
413
|
+
found.set(`${prefix}${name}`, stamp(stat));
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
visit(SAVEDATA, '');
|
|
417
|
+
return found;
|
|
418
|
+
}
|
|
419
|
+
async #restoreSaves() {
|
|
420
|
+
const dir = await opfsDir(this.#storagePath, false);
|
|
421
|
+
const Module = this.#module;
|
|
422
|
+
if (!dir || !Module)
|
|
423
|
+
return;
|
|
424
|
+
for await (const [relative, handle] of opfsFiles(dir)) {
|
|
425
|
+
if (!isMirrored(relative))
|
|
426
|
+
continue;
|
|
427
|
+
const bytes = new Uint8Array(await (await handle.getFile()).arrayBuffer());
|
|
428
|
+
const path = `${SAVEDATA}/${relative}`;
|
|
429
|
+
Module.FS.mkdirTree(path.slice(0, path.lastIndexOf('/')));
|
|
430
|
+
Module.FS.writeFile(path, bytes);
|
|
431
|
+
this.#mirrored.set(relative, stamp(Module.FS.stat(path)));
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
async #flush() {
|
|
435
|
+
const Module = this.#module;
|
|
436
|
+
if (!Module || !this.#persist)
|
|
437
|
+
return;
|
|
438
|
+
const now = this.#walk();
|
|
439
|
+
const changed = [...now].filter(([relative, current]) => this.#mirrored.get(relative) !== current);
|
|
440
|
+
const removed = [...this.#mirrored.keys()].filter((relative) => !now.has(relative));
|
|
441
|
+
if (changed.length === 0 && removed.length === 0)
|
|
442
|
+
return;
|
|
443
|
+
const root = await opfsDir(this.#storagePath, true);
|
|
444
|
+
if (!root)
|
|
445
|
+
return;
|
|
446
|
+
const folder = async (relative, create) => {
|
|
447
|
+
let dir = root;
|
|
448
|
+
for (const segment of relative.split('/').slice(0, -1)) {
|
|
449
|
+
try {
|
|
450
|
+
dir = await dir.getDirectoryHandle(segment, { create });
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return dir;
|
|
457
|
+
};
|
|
458
|
+
const written = [];
|
|
459
|
+
for (const [relative, current] of changed) {
|
|
460
|
+
try {
|
|
461
|
+
const bytes = Module.FS.readFile(`${SAVEDATA}/${relative}`);
|
|
462
|
+
const dir = await folder(relative, true);
|
|
463
|
+
if (!dir)
|
|
464
|
+
continue;
|
|
465
|
+
const writable = await (await dir.getFileHandle(relative.split('/').pop(), { create: true })).createWritable();
|
|
466
|
+
await writable.write(new Uint8Array(bytes));
|
|
467
|
+
await writable.close();
|
|
468
|
+
this.#mirrored.set(relative, current);
|
|
469
|
+
written.push(relative);
|
|
470
|
+
}
|
|
471
|
+
catch (error) {
|
|
472
|
+
console.warn(`[sonic3air] could not persist ${relative}`, error);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const gone = [];
|
|
476
|
+
for (const relative of removed) {
|
|
477
|
+
try {
|
|
478
|
+
const dir = await folder(relative, false);
|
|
479
|
+
await dir?.removeEntry(relative.split('/').pop());
|
|
480
|
+
}
|
|
481
|
+
catch {
|
|
482
|
+
/* already gone */
|
|
483
|
+
}
|
|
484
|
+
this.#mirrored.delete(relative);
|
|
485
|
+
gone.push(relative);
|
|
486
|
+
}
|
|
487
|
+
if (written.length || gone.length)
|
|
488
|
+
this.emit('saves', { files: written, removed: gone });
|
|
489
|
+
}
|
|
490
|
+
// ---- The game's file manager (Options → its own file browser) ----
|
|
491
|
+
#installFileManagerHooks(Module) {
|
|
492
|
+
const win = window;
|
|
493
|
+
const done = () => {
|
|
494
|
+
try {
|
|
495
|
+
Module._ImGuiFileBrowser_OnWebImportDone?.();
|
|
496
|
+
}
|
|
497
|
+
catch {
|
|
498
|
+
/* the browser was closed meanwhile */
|
|
499
|
+
}
|
|
500
|
+
void this.flushSaves();
|
|
501
|
+
};
|
|
502
|
+
const input = document.createElement('input');
|
|
503
|
+
input.type = 'file';
|
|
504
|
+
input.hidden = true;
|
|
505
|
+
input.addEventListener('change', async () => {
|
|
506
|
+
const file = input.files?.[0];
|
|
507
|
+
input.value = '';
|
|
508
|
+
if (!file)
|
|
509
|
+
return;
|
|
510
|
+
let folder = win.__s3airFileUploadPath || `${SAVEDATA}/`;
|
|
511
|
+
if (!folder.endsWith('/'))
|
|
512
|
+
folder += '/';
|
|
513
|
+
try {
|
|
514
|
+
Module.FS.writeFile(`${folder}${file.name}`, new Uint8Array(await file.arrayBuffer()));
|
|
515
|
+
}
|
|
516
|
+
catch (error) {
|
|
517
|
+
console.warn('[sonic3air] import failed', error);
|
|
518
|
+
}
|
|
519
|
+
done();
|
|
520
|
+
});
|
|
521
|
+
document.body.append(input);
|
|
522
|
+
this.#fileInput = input;
|
|
523
|
+
this.#hooks = {
|
|
524
|
+
// Called from the game's frame, right after the key or click that chose "import":
|
|
525
|
+
// still within the browser's user activation, so the picker may open.
|
|
526
|
+
triggerFileSelect: () => input.click(),
|
|
527
|
+
fileManagerExportFile: (path) => {
|
|
528
|
+
try {
|
|
529
|
+
const bytes = new Uint8Array(Module.FS.readFile(path));
|
|
530
|
+
const url = URL.createObjectURL(new Blob([bytes], { type: 'application/octet-stream' }));
|
|
531
|
+
const link = document.createElement('a');
|
|
532
|
+
link.href = url;
|
|
533
|
+
link.download = path.split('/').filter(Boolean).pop() ?? 'download.bin';
|
|
534
|
+
link.click();
|
|
535
|
+
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
536
|
+
}
|
|
537
|
+
catch (error) {
|
|
538
|
+
console.warn('[sonic3air] export failed', error);
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
fileManagerPromptRename: (oldName, currentPath, isFile, isCreateDirectory) => {
|
|
542
|
+
// Deferred: prompt() blocks, and this is called from inside a frame.
|
|
543
|
+
setTimeout(() => {
|
|
544
|
+
const creating = !!isCreateDirectory;
|
|
545
|
+
const value = window.prompt(creating ? 'Create folder:' : isFile ? 'Rename file:' : 'Rename folder:', oldName || '');
|
|
546
|
+
const name = value?.trim();
|
|
547
|
+
if (!name || (!creating && name === oldName) || /[\\/*?:|<>"]/.test(name))
|
|
548
|
+
return;
|
|
549
|
+
try {
|
|
550
|
+
if (creating)
|
|
551
|
+
Module.FS.mkdir(`${currentPath}${name}`);
|
|
552
|
+
else
|
|
553
|
+
Module.FS.rename(`${currentPath}${oldName}`, `${currentPath}${name}`);
|
|
554
|
+
}
|
|
555
|
+
catch (error) {
|
|
556
|
+
console.warn('[sonic3air] rename failed', error);
|
|
557
|
+
}
|
|
558
|
+
done();
|
|
559
|
+
}, 0);
|
|
560
|
+
},
|
|
561
|
+
};
|
|
562
|
+
Object.assign(win, this.#hooks);
|
|
563
|
+
}
|
|
564
|
+
#removeFileManagerHooks() {
|
|
565
|
+
const win = window;
|
|
566
|
+
for (const [name, hook] of Object.entries(this.#hooks ?? {})) {
|
|
567
|
+
if (win[name] === hook)
|
|
568
|
+
delete win[name];
|
|
569
|
+
}
|
|
570
|
+
delete win.__s3airFileUploadPath;
|
|
571
|
+
this.#hooks = null;
|
|
572
|
+
this.#fileInput?.remove();
|
|
573
|
+
this.#fileInput = null;
|
|
574
|
+
}
|
|
575
|
+
// ---- Picture ----
|
|
576
|
+
/** The engine draws 16:9 at the window's width; show it whole, centred, in the box. */
|
|
577
|
+
#fit() {
|
|
578
|
+
const canvas = this.#canvas;
|
|
579
|
+
const box = this.#box;
|
|
580
|
+
if (!canvas || !box || !this.#ownsCanvas)
|
|
581
|
+
return;
|
|
582
|
+
const { width, height } = box.getBoundingClientRect();
|
|
583
|
+
if (!width || !height)
|
|
584
|
+
return;
|
|
585
|
+
const w = Math.min(width, height * SONIC3AIR_VIDEO.ratio);
|
|
586
|
+
canvas.style.width = `${Math.floor(w)}px`;
|
|
587
|
+
canvas.style.height = `${Math.floor(w / SONIC3AIR_VIDEO.ratio)}px`;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
/** The factory a host constructs: static identity, the configuration chain, `start()`. */
|
|
591
|
+
export class Sonic3AirSDK extends EngineSDKBase {
|
|
592
|
+
static id = ENGINE_ID;
|
|
593
|
+
/** Kept in step with package.json by `node scripts/sync-version.mjs`. */
|
|
594
|
+
static version = '0.0.1';
|
|
595
|
+
static name = 'Sonic 3 A.I.R.';
|
|
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
|
+
createPlay(init, events) {
|
|
598
|
+
return new Sonic3AirPlay(init, events);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
/** CI's conformance line: if this class stops satisfying the contract, `make test` fails. */
|
|
602
|
+
export const SONIC3AIR_ENGINE = Sonic3AirSDK;
|
|
603
|
+
export default Sonic3AirSDK;
|
|
604
|
+
//# sourceMappingURL=sonic3air.sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sonic3air.sdk.js","sourceRoot":"","sources":["../../src/sonic3air.sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EACL,cAAc,EACd,aAAa,EACb,YAAY,GAKb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,EACd,eAAe,GAKhB,MAAM,wBAAwB,CAAC;AAWhC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzE,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,yBAAyB,GAAG,SAAS,CAAC;AAC5C,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,MAAM,QAAQ,GAAG,GAAG,SAAS,WAAW,CAAC;AACzC,wEAAwE;AACxE,MAAM,CAAC,MAAM,QAAQ,GAAG,4BAA4B,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,kEAAkE;AAClE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC;AAC1E,MAAM,gBAA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U,OAAO,GAAG,OAAO,CAAC;IAClC,MAAM,CAAU,IAAI,GAAG,gBAAgB,CAAC;IACxC,MAAM,CAAU,WAAW,GACzB,6LAA6L,CAAC;IAE7K,UAAU,CAC3B,IAAmC,EACnC,MAAiD;QAEjD,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;;AAGH,6FAA6F;AAC7F,MAAM,CAAC,MAAM,gBAAgB,GAA4C,YAAY,CAAC;AAEtF,eAAe,YAAY,CAAC"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wasm-gaming/sonic3air-wasm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
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",
|
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.0.1';
|
|
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.";
|