@wasm-gaming/engine-specs 0.2.6 → 0.3.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 +63 -55
- package/demo/app.html +227 -0
- package/demo/canvas-renderer.js +153 -0
- package/demo/components/asset-picker.html +137 -0
- package/demo/components/call-log.html +33 -0
- package/demo/components/engine-header.html +78 -0
- package/demo/components/lifecycle-bar.html +69 -0
- package/demo/components/property-table.html +119 -0
- package/demo/demo.css +26 -130
- package/demo/demo.sdk.js +405 -203
- package/demo/index.html +7 -56
- package/demo/tsconfig.json +17 -0
- package/dist/engine-specs.d.ts +99 -0
- package/dist/engine-specs.d.ts.map +1 -0
- package/dist/engine-specs.js +3 -0
- package/dist/engine-specs.js.map +1 -0
- package/package.json +8 -12
- package/src/engine-specs.ts +110 -0
- package/demo/README.md +0 -155
- package/demo/checksums.js +0 -101
- package/demo/components/drop-area.html +0 -171
- package/demo/components/esc-menu.html +0 -540
- package/demo/components/launcher.html +0 -220
- package/demo/components/sdk-info.html +0 -54
- package/demo/demo.js +0 -622
- package/demo/sdk.js +0 -19
- package/demo/storage.js +0 -88
- package/dist/engine.d.ts +0 -78
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -8
- package/dist/engine.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -1
- package/dist/manifest.d.ts +0 -69
- package/dist/manifest.d.ts.map +0 -1
- package/dist/manifest.js +0 -8
- package/dist/manifest.js.map +0 -1
- package/dist/validate.d.ts +0 -10
- package/dist/validate.d.ts.map +0 -1
- package/dist/validate.js +0 -79
- package/dist/validate.js.map +0 -1
- package/schema/engine-manifest.schema.json +0 -74
- package/src/engine.ts +0 -88
- package/src/index.ts +0 -32
- package/src/manifest.ts +0 -82
- package/src/validate.ts +0 -92
package/demo/storage.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OPFS Asset Storage Helper for Engine Demo
|
|
3
|
-
* Persists ROM and BIOS files in the Origin Private File System (OPFS) across page reloads.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const DIR_NAME = "wasm-gaming-demo";
|
|
7
|
-
|
|
8
|
-
async function getStorageDir() {
|
|
9
|
-
if (typeof navigator === "undefined" || !navigator.storage?.getDirectory) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
const root = await navigator.storage.getDirectory();
|
|
14
|
-
return await root.getDirectoryHandle(DIR_NAME, { create: true });
|
|
15
|
-
} catch (err) {
|
|
16
|
-
console.warn("OPFS storage not accessible:", err);
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Save an asset File into OPFS.
|
|
23
|
-
*/
|
|
24
|
-
export async function saveStoredAsset(key, file) {
|
|
25
|
-
const dir = await getStorageDir();
|
|
26
|
-
if (!dir || !file) return;
|
|
27
|
-
try {
|
|
28
|
-
const fileHandle = await dir.getFileHandle(`${key}.bin`, { create: true });
|
|
29
|
-
const writable = await fileHandle.createWritable();
|
|
30
|
-
const bytes = await file.arrayBuffer();
|
|
31
|
-
await writable.write(bytes);
|
|
32
|
-
await writable.close();
|
|
33
|
-
|
|
34
|
-
// Store file metadata
|
|
35
|
-
const metaHandle = await dir.getFileHandle(`${key}.json`, { create: true });
|
|
36
|
-
const metaWritable = await metaHandle.createWritable();
|
|
37
|
-
await metaWritable.write(
|
|
38
|
-
JSON.stringify({
|
|
39
|
-
name: file.name,
|
|
40
|
-
size: file.size || bytes.byteLength,
|
|
41
|
-
type: file.type || "application/octet-stream",
|
|
42
|
-
lastModified: file.lastModified || Date.now(),
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
await metaWritable.close();
|
|
46
|
-
} catch (err) {
|
|
47
|
-
console.warn(`Failed to save ${key} in OPFS:`, err);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Retrieve a stored asset File from OPFS.
|
|
53
|
-
*/
|
|
54
|
-
export async function loadStoredAsset(key) {
|
|
55
|
-
const dir = await getStorageDir();
|
|
56
|
-
if (!dir) return null;
|
|
57
|
-
try {
|
|
58
|
-
const fileHandle = await dir.getFileHandle(`${key}.bin`);
|
|
59
|
-
const metaHandle = await dir.getFileHandle(`${key}.json`);
|
|
60
|
-
|
|
61
|
-
const fileObj = await fileHandle.getFile();
|
|
62
|
-
const metaText = await (await metaHandle.getFile()).text();
|
|
63
|
-
const meta = JSON.parse(metaText);
|
|
64
|
-
|
|
65
|
-
const bytes = await fileObj.arrayBuffer();
|
|
66
|
-
return new File([bytes], meta.name, {
|
|
67
|
-
type: meta.type,
|
|
68
|
-
lastModified: meta.lastModified,
|
|
69
|
-
});
|
|
70
|
-
} catch {
|
|
71
|
-
// File or meta doesn't exist yet
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Clear a stored asset from OPFS.
|
|
78
|
-
*/
|
|
79
|
-
export async function clearStoredAsset(key) {
|
|
80
|
-
const dir = await getStorageDir();
|
|
81
|
-
if (!dir) return;
|
|
82
|
-
try {
|
|
83
|
-
await dir.removeEntry(`${key}.bin`);
|
|
84
|
-
} catch {}
|
|
85
|
-
try {
|
|
86
|
-
await dir.removeEntry(`${key}.json`);
|
|
87
|
-
} catch {}
|
|
88
|
-
}
|
package/dist/engine.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { EngineManifest, KeyMap, InputPreset } from './manifest.js';
|
|
2
|
-
/** Binary asset payload accepted by `load()`. */
|
|
3
|
-
export type AssetData = Uint8Array | ArrayBuffer | string;
|
|
4
|
-
/** Where an engine may persist saves/SRAM. */
|
|
5
|
-
export type PersistMode = 'idbfs' | 'opfs' | null;
|
|
6
|
-
type EngineConfigBase = {
|
|
7
|
-
/** Runtime files keyed by `AssetSpec.key`. Required specs must be present. */
|
|
8
|
-
assets: Record<string, AssetData>;
|
|
9
|
-
/** Engine-specific settings, validated against `manifest.options`. */
|
|
10
|
-
options?: Record<string, unknown>;
|
|
11
|
-
/** Persistence backend for saves, when the engine supports it. */
|
|
12
|
-
persist?: PersistMode;
|
|
13
|
-
/**
|
|
14
|
-
* Optional storage namespace under the engine's working dir.
|
|
15
|
-
* Hosts can use this to isolate per-game persisted assets (e.g. sonic1/sonic2).
|
|
16
|
-
*/
|
|
17
|
-
storageNamespace?: string;
|
|
18
|
-
/** Lifecycle/telemetry sink. Handlers must not throw. */
|
|
19
|
-
onEvent?: (e: EngineEvent) => void;
|
|
20
|
-
/** Override artifact locations (e.g. host-fetched Release assets). */
|
|
21
|
-
jsUrl?: string;
|
|
22
|
-
wasmUrl?: string;
|
|
23
|
-
};
|
|
24
|
-
export type EngineConfig = EngineConfigBase & ({
|
|
25
|
-
/** Render target. The SDK is responsible for the `#canvas` id if the engine needs it. */
|
|
26
|
-
canvasEl: HTMLCanvasElement;
|
|
27
|
-
/** Optional container element for SDK-owned DOM when a canvas element is present. */
|
|
28
|
-
attachTo?: HTMLElement;
|
|
29
|
-
} | {
|
|
30
|
-
/** Optional render target when the SDK primarily mounts into a container element. */
|
|
31
|
-
canvasEl?: HTMLCanvasElement;
|
|
32
|
-
/** Container element the SDK can use to mount engine-owned DOM. */
|
|
33
|
-
attachTo: HTMLElement;
|
|
34
|
-
});
|
|
35
|
-
export type EngineEvent = {
|
|
36
|
-
type: 'ready';
|
|
37
|
-
} | {
|
|
38
|
-
type: 'error';
|
|
39
|
-
error: Error;
|
|
40
|
-
} | {
|
|
41
|
-
type: 'exit';
|
|
42
|
-
} | {
|
|
43
|
-
type: 'frame';
|
|
44
|
-
fps: number;
|
|
45
|
-
};
|
|
46
|
-
export interface EngineInstance {
|
|
47
|
-
/** Begin running. `load()` may auto-start; then this is a no-op. */
|
|
48
|
-
start(): void;
|
|
49
|
-
pause(): void;
|
|
50
|
-
resume(): void;
|
|
51
|
-
/** Reset to power-on. May throw if the engine cannot reset in-process. */
|
|
52
|
-
reset(): void;
|
|
53
|
-
/** Swap the active input preset/map at runtime. */
|
|
54
|
-
setInput(map: InputPreset | KeyMap): void;
|
|
55
|
-
saveState?(): Promise<Uint8Array>;
|
|
56
|
-
loadState?(data: Uint8Array): Promise<void>;
|
|
57
|
-
screenshot?(): Promise<Blob>;
|
|
58
|
-
/**
|
|
59
|
-
* Optional targeted purge of persisted runtime files for the active namespace.
|
|
60
|
-
* Engines that do not persist assets can omit this method.
|
|
61
|
-
*/
|
|
62
|
-
purgeStorage?(): {
|
|
63
|
-
data: boolean;
|
|
64
|
-
settings: boolean;
|
|
65
|
-
} | Promise<{
|
|
66
|
-
data: boolean;
|
|
67
|
-
settings: boolean;
|
|
68
|
-
}>;
|
|
69
|
-
/** Tear down: stop the loop, release listeners/DOM, free the instance. */
|
|
70
|
-
destroy(): void;
|
|
71
|
-
}
|
|
72
|
-
/** The default export shape every engine package must provide. */
|
|
73
|
-
export interface EngineSDK {
|
|
74
|
-
manifest: EngineManifest;
|
|
75
|
-
load(config: EngineConfig): Promise<EngineInstance>;
|
|
76
|
-
}
|
|
77
|
-
export {};
|
|
78
|
-
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzE,iDAAiD;AACjD,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;AAE1D,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;AAElD,KAAK,gBAAgB,GAAG;IACtB,8EAA8E;IAC9E,MAAM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AO,CAAC,UAAU,CAAC,CAAC;IAClC,SAAS,CAAC,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B;;;OAGG;IACH,YAAY,CAAC,IACT;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,GACpC,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAElD,0EAA0E;IAC1E,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,cAAc,CAAC;IACzB,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACrD"}
|
package/dist/engine.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Layer B — the imperative contract.
|
|
2
|
-
//
|
|
3
|
-
// Every engine subproject's SDK exposes `{ manifest, load }` (an `EngineSDK`).
|
|
4
|
-
// `load()` boots the engine and returns an `EngineInstance` the host controls.
|
|
5
|
-
// The interface is identical across engines; per-engine differences are absorbed
|
|
6
|
-
// by `manifest` (Layer A) and the `assets`/`options` payloads.
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=engine.js.map
|
package/dist/engine.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,iFAAiF;AACjF,+DAA+D"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { EngineManifest, EngineArtifacts, AssetSpec, AssetValidation, VideoSpec, EngineCapabilities, KeyMap, InputPreset, JSONSchema, } from './manifest.js';
|
|
2
|
-
export type { EngineSDK, EngineInstance, EngineConfig, EngineEvent, AssetData, PersistMode, } from './engine.js';
|
|
3
|
-
export { validateManifest, assertManifest } from './validate.js';
|
|
4
|
-
export type { ValidationResult } from './validate.js';
|
|
5
|
-
/** The contract version. Bump on breaking changes to the shapes above. */
|
|
6
|
-
export declare const CONTRACT_VERSION = "0.1.1";
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,YAAY,EACV,cAAc,EACd,eAAe,EACf,SAAS,EACT,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,SAAS,EACT,cAAc,EACd,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,UAAU,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// @wasm-gaming/engine-specs — the engine contract.
|
|
2
|
-
//
|
|
3
|
-
// Layer A (declarative): EngineManifest & friends — what an engine ships/needs.
|
|
4
|
-
// Layer B (imperative): EngineSDK / EngineInstance — how the host drives it.
|
|
5
|
-
// Plus a runtime validator for the manifest.
|
|
6
|
-
export { validateManifest, assertManifest } from './validate.js';
|
|
7
|
-
/** The contract version. Bump on breaking changes to the shapes above. */
|
|
8
|
-
export const CONTRACT_VERSION = '0.1.1';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,6CAA6C;AAuB7C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGjE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC"}
|
package/dist/manifest.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/** A loose JSON Schema object (Draft 2020-12 subset). Kept dependency-free. */
|
|
2
|
-
export type JSONSchema = Record<string, unknown>;
|
|
3
|
-
/** A gamepad→keyboard key map, or the name of a built-in preset (e.g. "rsdkv4"). */
|
|
4
|
-
export type KeyMap = Record<string, string>;
|
|
5
|
-
export type InputPreset = string;
|
|
6
|
-
/** How the host validates a user-provided asset before mounting it. */
|
|
7
|
-
export interface AssetValidation {
|
|
8
|
-
/** Exact byte length, if the asset has a fixed size (e.g. a known ROM dump). */
|
|
9
|
-
bytes?: number;
|
|
10
|
-
/** Lowercase hex SHA-1 the asset must match. */
|
|
11
|
-
sha1?: string;
|
|
12
|
-
}
|
|
13
|
-
/** A file the host must supply at runtime, mounted into the engine's VFS. */
|
|
14
|
-
export interface AssetSpec {
|
|
15
|
-
/** Stable key the host uses in `EngineConfig.assets` (e.g. "data", "rom", "bios"). */
|
|
16
|
-
key: string;
|
|
17
|
-
/** Absolute VFS path the engine reads from (e.g. "/Data.rsdk", "/roms/neogeo.zip"). */
|
|
18
|
-
mountPath: string;
|
|
19
|
-
/** If true, `load()` must reject when the asset is absent. */
|
|
20
|
-
required: boolean;
|
|
21
|
-
/** Suggested file extensions for a host file picker (e.g. [".rsdk"]). */
|
|
22
|
-
accept?: string[];
|
|
23
|
-
/** Integrity/shape constraints the host may enforce before mounting. */
|
|
24
|
-
validate?: AssetValidation;
|
|
25
|
-
/** Human-readable note shown in host UI. */
|
|
26
|
-
description?: string;
|
|
27
|
-
}
|
|
28
|
-
/** Where the CI-built artifacts live (relative paths or URLs; host resolves them). */
|
|
29
|
-
export interface EngineArtifacts {
|
|
30
|
-
/** The `.wasm` binary. */
|
|
31
|
-
wasm: string;
|
|
32
|
-
/** The JS glue/loader (an ES module factory). */
|
|
33
|
-
js: string;
|
|
34
|
-
/** Optional preloaded Emscripten `.data` package (engines that bundle assets). */
|
|
35
|
-
data?: string;
|
|
36
|
-
}
|
|
37
|
-
/** Native render surface geometry. */
|
|
38
|
-
export interface VideoSpec {
|
|
39
|
-
baseWidth: number;
|
|
40
|
-
baseHeight: number;
|
|
41
|
-
/** Display aspect ratio, e.g. "16:9" or "4:3". Defaults to baseWidth:baseHeight. */
|
|
42
|
-
aspect?: string;
|
|
43
|
-
}
|
|
44
|
-
/** Optional features an engine may or may not implement. Gate calls on these. */
|
|
45
|
-
export interface EngineCapabilities {
|
|
46
|
-
saveStates?: boolean;
|
|
47
|
-
sram?: boolean;
|
|
48
|
-
/** Part of a swappable set of cores for one platform (e.g. Megadrive: JGenesis/BlastEm). */
|
|
49
|
-
coreSelectable?: boolean;
|
|
50
|
-
}
|
|
51
|
-
export interface EngineManifest {
|
|
52
|
-
/** Stable engine id, e.g. "rsdkv4" | "fbneo" | "blastem" | "jgenesis" | "smw". */
|
|
53
|
-
id: string;
|
|
54
|
-
/** SemVer of this engine build/contract implementation. */
|
|
55
|
-
version: string;
|
|
56
|
-
/** Human-readable name. */
|
|
57
|
-
name?: string;
|
|
58
|
-
description?: string;
|
|
59
|
-
artifacts: EngineArtifacts;
|
|
60
|
-
/** Files supplied at runtime. May be empty (e.g. engines with baked-in assets). */
|
|
61
|
-
assets: AssetSpec[];
|
|
62
|
-
/** Input preset name or an explicit key map. */
|
|
63
|
-
input: InputPreset | KeyMap;
|
|
64
|
-
video: VideoSpec;
|
|
65
|
-
/** JSON Schema for engine-specific `EngineConfig.options`. */
|
|
66
|
-
options?: JSONSchema;
|
|
67
|
-
capabilities: EngineCapabilities;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=manifest.d.ts.map
|
package/dist/manifest.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAOA,+EAA+E;AAC/E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,oFAAoF;AACpF,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC5C,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,6EAA6E;AAC7E,MAAM,WAAW,SAAS;IACxB,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAC;IACZ,uFAAuF;IACvF,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,QAAQ,EAAE,OAAO,CAAC;IAClB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,sCAAsC;AACtC,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4FAA4F;IAC5F,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,kFAAkF;IAClF,EAAE,EAAE,MAAM,CAAC;IACX,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;IAC3B,mFAAmF;IACnF,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,gDAAgD;IAChD,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,YAAY,EAAE,kBAAkB,CAAC;CAClC"}
|
package/dist/manifest.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Layer A — the declarative contract.
|
|
2
|
-
//
|
|
3
|
-
// An EngineManifest describes what an engine subproject ships and needs. It drives
|
|
4
|
-
// the host's launcher UI, asset pickers and validation. Everything that differs
|
|
5
|
-
// between engines (Data.rsdk vs a ROM zip + BIOS vs baked-in assets) is expressed
|
|
6
|
-
// as *data* here, so the imperative interface (Layer B) can stay identical.
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=manifest.js.map
|
package/dist/manifest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,mFAAmF;AACnF,gFAAgF;AAChF,kFAAkF;AAClF,4EAA4E"}
|
package/dist/validate.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { EngineManifest } from './manifest.js';
|
|
2
|
-
export interface ValidationResult {
|
|
3
|
-
valid: boolean;
|
|
4
|
-
errors: string[];
|
|
5
|
-
}
|
|
6
|
-
/** Validate an unknown value as an EngineManifest. Never throws. */
|
|
7
|
-
export declare function validateManifest(input: unknown): ValidationResult;
|
|
8
|
-
/** Validate and throw on failure. Returns the value narrowed to EngineManifest. */
|
|
9
|
-
export declare function assertManifest(input: unknown): EngineManifest;
|
|
10
|
-
//# sourceMappingURL=validate.d.ts.map
|
package/dist/validate.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAgED,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAMjE;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAO7D"}
|
package/dist/validate.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// Runtime validation of an EngineManifest against the contract.
|
|
2
|
-
// Engine CIs can run this to fail a build that drifts from the spec; hosts can run
|
|
3
|
-
// it on manifests fetched from Releases before trusting them.
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
const AssetValidationSchema = z.object({
|
|
6
|
-
bytes: z.int().nonnegative().optional(),
|
|
7
|
-
sha1: z.string().optional(),
|
|
8
|
-
}).strict();
|
|
9
|
-
const AssetSpecSchema = z.object({
|
|
10
|
-
key: z.string().min(1),
|
|
11
|
-
mountPath: z.string().regex(/^\//),
|
|
12
|
-
required: z.boolean(),
|
|
13
|
-
accept: z.array(z.string()).optional(),
|
|
14
|
-
validate: AssetValidationSchema.optional(),
|
|
15
|
-
description: z.string().optional(),
|
|
16
|
-
}).strict();
|
|
17
|
-
const InputSchema = z.union([
|
|
18
|
-
z.string(),
|
|
19
|
-
z.record(z.string(), z.string()),
|
|
20
|
-
]);
|
|
21
|
-
const VideoSpecSchema = z.object({
|
|
22
|
-
baseWidth: z.int().positive(),
|
|
23
|
-
baseHeight: z.int().positive(),
|
|
24
|
-
aspect: z.string().optional(),
|
|
25
|
-
}).strict();
|
|
26
|
-
const EngineArtifactsSchema = z.object({
|
|
27
|
-
wasm: z.string(),
|
|
28
|
-
js: z.string(),
|
|
29
|
-
data: z.string().optional(),
|
|
30
|
-
}).strict();
|
|
31
|
-
const EngineCapabilitiesSchema = z.object({
|
|
32
|
-
saveStates: z.boolean().optional(),
|
|
33
|
-
sram: z.boolean().optional(),
|
|
34
|
-
coreSelectable: z.boolean().optional(),
|
|
35
|
-
}).strict();
|
|
36
|
-
const EngineManifestSchema = z.object({
|
|
37
|
-
id: z.string().min(1),
|
|
38
|
-
version: z.string().min(1),
|
|
39
|
-
name: z.string().optional(),
|
|
40
|
-
description: z.string().optional(),
|
|
41
|
-
artifacts: EngineArtifactsSchema,
|
|
42
|
-
assets: z.array(AssetSpecSchema),
|
|
43
|
-
input: InputSchema,
|
|
44
|
-
video: VideoSpecSchema,
|
|
45
|
-
options: z.record(z.string(), z.unknown()).optional(),
|
|
46
|
-
capabilities: EngineCapabilitiesSchema,
|
|
47
|
-
}).strict();
|
|
48
|
-
function formatIssuePath(path) {
|
|
49
|
-
if (path.length === 0)
|
|
50
|
-
return 'manifest';
|
|
51
|
-
let out = 'manifest';
|
|
52
|
-
for (const part of path) {
|
|
53
|
-
if (typeof part === 'number')
|
|
54
|
-
out += `[${part}]`;
|
|
55
|
-
else if (typeof part === 'string')
|
|
56
|
-
out += `.${part}`;
|
|
57
|
-
else
|
|
58
|
-
out += '.[symbol]';
|
|
59
|
-
}
|
|
60
|
-
return out;
|
|
61
|
-
}
|
|
62
|
-
/** Validate an unknown value as an EngineManifest. Never throws. */
|
|
63
|
-
export function validateManifest(input) {
|
|
64
|
-
const result = EngineManifestSchema.safeParse(input);
|
|
65
|
-
if (result.success)
|
|
66
|
-
return { valid: true, errors: [] };
|
|
67
|
-
const errors = result.error.issues.map((issue) => `${formatIssuePath(issue.path)}: ${issue.message}`);
|
|
68
|
-
return { valid: false, errors };
|
|
69
|
-
}
|
|
70
|
-
/** Validate and throw on failure. Returns the value narrowed to EngineManifest. */
|
|
71
|
-
export function assertManifest(input) {
|
|
72
|
-
const result = EngineManifestSchema.safeParse(input);
|
|
73
|
-
if (!result.success) {
|
|
74
|
-
const errors = result.error.issues.map((issue) => `${formatIssuePath(issue.path)}: ${issue.message}`);
|
|
75
|
-
throw new Error(`Invalid EngineManifest:\n- ${errors.join('\n- ')}`);
|
|
76
|
-
}
|
|
77
|
-
return result.data;
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=validate.js.map
|
package/dist/validate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,mFAAmF;AACnF,8DAA8D;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC,MAAM,EAAE,CAAC;AAEZ,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;IAClC,QAAQ,EAAE,CAAC,CA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,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAEvD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACtG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,MAAM,MAAM,GAAG,oBAAoB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACtG,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,MAAM,CAAC,IAAsB,CAAC;AACvC,CAAC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://github.com/wasm-gaming/engine-specs/schema/engine-manifest.json",
|
|
4
|
-
"title": "EngineManifest",
|
|
5
|
-
"description": "The declarative contract an engine subproject ships (mirror of src/manifest.ts).",
|
|
6
|
-
"type": "object",
|
|
7
|
-
"required": ["id", "version", "artifacts", "assets", "input", "video", "capabilities"],
|
|
8
|
-
"additionalProperties": false,
|
|
9
|
-
"properties": {
|
|
10
|
-
"id": { "type": "string", "minLength": 1 },
|
|
11
|
-
"version": { "type": "string", "minLength": 1 },
|
|
12
|
-
"name": { "type": "string" },
|
|
13
|
-
"description": { "type": "string" },
|
|
14
|
-
"artifacts": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"required": ["wasm", "js"],
|
|
17
|
-
"additionalProperties": false,
|
|
18
|
-
"properties": {
|
|
19
|
-
"wasm": { "type": "string" },
|
|
20
|
-
"js": { "type": "string" },
|
|
21
|
-
"data": { "type": "string" }
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"assets": {
|
|
25
|
-
"type": "array",
|
|
26
|
-
"items": {
|
|
27
|
-
"type": "object",
|
|
28
|
-
"required": ["key", "mountPath", "required"],
|
|
29
|
-
"additionalProperties": false,
|
|
30
|
-
"properties": {
|
|
31
|
-
"key": { "type": "string", "minLength": 1 },
|
|
32
|
-
"mountPath": { "type": "string", "pattern": "^/" },
|
|
33
|
-
"required": { "type": "boolean" },
|
|
34
|
-
"accept": { "type": "array", "items": { "type": "string" } },
|
|
35
|
-
"validate": {
|
|
36
|
-
"type": "object",
|
|
37
|
-
"additionalProperties": false,
|
|
38
|
-
"properties": {
|
|
39
|
-
"bytes": { "type": "integer", "minimum": 0 },
|
|
40
|
-
"sha1": { "type": "string" }
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"description": { "type": "string" }
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"input": {
|
|
48
|
-
"oneOf": [
|
|
49
|
-
{ "type": "string" },
|
|
50
|
-
{ "type": "object", "additionalProperties": { "type": "string" } }
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
"video": {
|
|
54
|
-
"type": "object",
|
|
55
|
-
"required": ["baseWidth", "baseHeight"],
|
|
56
|
-
"additionalProperties": false,
|
|
57
|
-
"properties": {
|
|
58
|
-
"baseWidth": { "type": "integer", "exclusiveMinimum": 0 },
|
|
59
|
-
"baseHeight": { "type": "integer", "exclusiveMinimum": 0 },
|
|
60
|
-
"aspect": { "type": "string" }
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"options": { "type": "object" },
|
|
64
|
-
"capabilities": {
|
|
65
|
-
"type": "object",
|
|
66
|
-
"additionalProperties": false,
|
|
67
|
-
"properties": {
|
|
68
|
-
"saveStates": { "type": "boolean" },
|
|
69
|
-
"sram": { "type": "boolean" },
|
|
70
|
-
"coreSelectable": { "type": "boolean" }
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
package/src/engine.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
// Layer B — the imperative contract.
|
|
2
|
-
//
|
|
3
|
-
// Every engine subproject's SDK exposes `{ manifest, load }` (an `EngineSDK`).
|
|
4
|
-
// `load()` boots the engine and returns an `EngineInstance` the host controls.
|
|
5
|
-
// The interface is identical across engines; per-engine differences are absorbed
|
|
6
|
-
// by `manifest` (Layer A) and the `assets`/`options` payloads.
|
|
7
|
-
|
|
8
|
-
import type { EngineManifest, KeyMap, InputPreset } from './manifest.js';
|
|
9
|
-
|
|
10
|
-
/** Binary asset payload accepted by `load()`. */
|
|
11
|
-
export type AssetData = Uint8Array | ArrayBuffer | string;
|
|
12
|
-
|
|
13
|
-
/** Where an engine may persist saves/SRAM. */
|
|
14
|
-
export type PersistMode = 'idbfs' | 'opfs' | null;
|
|
15
|
-
|
|
16
|
-
type EngineConfigBase = {
|
|
17
|
-
/** Runtime files keyed by `AssetSpec.key`. Required specs must be present. */
|
|
18
|
-
assets: Record<string, AssetData>;
|
|
19
|
-
/** Engine-specific settings, validated against `manifest.options`. */
|
|
20
|
-
options?: Record<string, unknown>;
|
|
21
|
-
/** Persistence backend for saves, when the engine supports it. */
|
|
22
|
-
persist?: PersistMode;
|
|
23
|
-
/**
|
|
24
|
-
* Optional storage namespace under the engine's working dir.
|
|
25
|
-
* Hosts can use this to isolate per-game persisted assets (e.g. sonic1/sonic2).
|
|
26
|
-
*/
|
|
27
|
-
storageNamespace?: string;
|
|
28
|
-
/** Lifecycle/telemetry sink. Handlers must not throw. */
|
|
29
|
-
onEvent?: (e: EngineEvent) => void;
|
|
30
|
-
/** Override artifact locations (e.g. host-fetched Release assets). */
|
|
31
|
-
jsUrl?: string;
|
|
32
|
-
wasmUrl?: string;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type EngineConfig = EngineConfigBase &
|
|
36
|
-
(
|
|
37
|
-
| {
|
|
38
|
-
/** Render target. The SDK is responsible for the `#canvas` id if the engine needs it. */
|
|
39
|
-
canvasEl: HTMLCanvasElement;
|
|
40
|
-
/** Optional container element for SDK-owned DOM when a canvas element is present. */
|
|
41
|
-
attachTo?: HTMLElement;
|
|
42
|
-
}
|
|
43
|
-
| {
|
|
44
|
-
/** Optional render target when the SDK primarily mounts into a container element. */
|
|
45
|
-
canvasEl?: HTMLCanvasElement;
|
|
46
|
-
/** Container element the SDK can use to mount engine-owned DOM. */
|
|
47
|
-
attachTo: HTMLElement;
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
export type EngineEvent =
|
|
52
|
-
| { type: 'ready' }
|
|
53
|
-
| { type: 'error'; error: Error }
|
|
54
|
-
| { type: 'exit' }
|
|
55
|
-
| { type: 'frame'; fps: number };
|
|
56
|
-
|
|
57
|
-
export interface EngineInstance {
|
|
58
|
-
/** Begin running. `load()` may auto-start; then this is a no-op. */
|
|
59
|
-
start(): void;
|
|
60
|
-
pause(): void;
|
|
61
|
-
resume(): void;
|
|
62
|
-
/** Reset to power-on. May throw if the engine cannot reset in-process. */
|
|
63
|
-
reset(): void;
|
|
64
|
-
/** Swap the active input preset/map at runtime. */
|
|
65
|
-
setInput(map: InputPreset | KeyMap): void;
|
|
66
|
-
|
|
67
|
-
// Capability-gated (see manifest.capabilities). Present only when supported.
|
|
68
|
-
saveState?(): Promise<Uint8Array>;
|
|
69
|
-
loadState?(data: Uint8Array): Promise<void>;
|
|
70
|
-
screenshot?(): Promise<Blob>;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Optional targeted purge of persisted runtime files for the active namespace.
|
|
74
|
-
* Engines that do not persist assets can omit this method.
|
|
75
|
-
*/
|
|
76
|
-
purgeStorage?():
|
|
77
|
-
| { data: boolean; settings: boolean }
|
|
78
|
-
| Promise<{ data: boolean; settings: boolean }>;
|
|
79
|
-
|
|
80
|
-
/** Tear down: stop the loop, release listeners/DOM, free the instance. */
|
|
81
|
-
destroy(): void;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** The default export shape every engine package must provide. */
|
|
85
|
-
export interface EngineSDK {
|
|
86
|
-
manifest: EngineManifest;
|
|
87
|
-
load(config: EngineConfig): Promise<EngineInstance>;
|
|
88
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// @wasm-gaming/engine-specs — the engine contract.
|
|
2
|
-
//
|
|
3
|
-
// Layer A (declarative): EngineManifest & friends — what an engine ships/needs.
|
|
4
|
-
// Layer B (imperative): EngineSDK / EngineInstance — how the host drives it.
|
|
5
|
-
// Plus a runtime validator for the manifest.
|
|
6
|
-
|
|
7
|
-
export type {
|
|
8
|
-
EngineManifest,
|
|
9
|
-
EngineArtifacts,
|
|
10
|
-
AssetSpec,
|
|
11
|
-
AssetValidation,
|
|
12
|
-
VideoSpec,
|
|
13
|
-
EngineCapabilities,
|
|
14
|
-
KeyMap,
|
|
15
|
-
InputPreset,
|
|
16
|
-
JSONSchema,
|
|
17
|
-
} from './manifest.js';
|
|
18
|
-
|
|
19
|
-
export type {
|
|
20
|
-
EngineSDK,
|
|
21
|
-
EngineInstance,
|
|
22
|
-
EngineConfig,
|
|
23
|
-
EngineEvent,
|
|
24
|
-
AssetData,
|
|
25
|
-
PersistMode,
|
|
26
|
-
} from './engine.js';
|
|
27
|
-
|
|
28
|
-
export { validateManifest, assertManifest } from './validate.js';
|
|
29
|
-
export type { ValidationResult } from './validate.js';
|
|
30
|
-
|
|
31
|
-
/** The contract version. Bump on breaking changes to the shapes above. */
|
|
32
|
-
export const CONTRACT_VERSION = '0.1.1';
|