@wasm-gaming/engine-specs 0.1.9 → 0.2.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/README.md CHANGED
@@ -23,6 +23,10 @@ Every engine package default-exports an `EngineSDK` = `{ manifest, load }`.
23
23
  (`start`/`pause`/`resume`/`reset`/`setInput`/`destroy`, plus capability-gated
24
24
  `saveState`/`loadState`/`screenshot`).
25
25
 
26
+ `EngineConfig` requires at least one render mount target: `canvasEl`, `attachTo`,
27
+ or both. `attachTo` is the host container element where an SDK can mount
28
+ engine-owned DOM.
29
+
26
30
  `EngineConfig.storageNamespace` is an optional host hint for per-game storage
27
31
  segregation (for example OPFS folders like `sonic1` and `sonic2`).
28
32
  `EngineInstance.purgeStorage()` is an optional method for engines that can remove
package/dist/engine.d.ts CHANGED
@@ -3,9 +3,7 @@ import type { EngineManifest, KeyMap, InputPreset } from './manifest.js';
3
3
  export type AssetData = Uint8Array | ArrayBuffer | string;
4
4
  /** Where an engine may persist saves/SRAM. */
5
5
  export type PersistMode = 'idbfs' | 'opfs' | null;
6
- export interface EngineConfig {
7
- /** Render target. The SDK is responsible for the `#canvas` id if the engine needs it. */
8
- canvas: HTMLCanvasElement;
6
+ type EngineConfigBase = {
9
7
  /** Runtime files keyed by `AssetSpec.key`. Required specs must be present. */
10
8
  assets: Record<string, AssetData>;
11
9
  /** Engine-specific settings, validated against `manifest.options`. */
@@ -22,7 +20,18 @@ export interface EngineConfig {
22
20
  /** Override artifact locations (e.g. host-fetched Release assets). */
23
21
  jsUrl?: string;
24
22
  wasmUrl?: string;
25
- }
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
+ });
26
35
  export type EngineEvent = {
27
36
  type: 'ready';
28
37
  } | {
@@ -65,4 +74,5 @@ export interface EngineSDK {
65
74
  manifest: EngineManifest;
66
75
  load(config: EngineConfig): Promise<EngineInstance>;
67
76
  }
77
+ export {};
68
78
  //# sourceMappingURL=engine.d.ts.map
@@ -1 +1 @@
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,MAAM,WAAW,YAAY;IAC3B,yFAAyF;IACzF,MAAM,EAAE,iBAAiB,CAAC;IAC1B,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAClC,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,kEAAkE;IAClE,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yDAAyD;IACzD,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;IACnC,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC/B;IA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QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IAG1C,SAAS,CAAC,IAAI,OAAO,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasm-gaming/engine-specs",
3
- "version": "0.1.9",
3
+ "version": "0.2.1",
4
4
  "description": "The wasm-gaming engine contract: the single shared interface every WASM game/emulator engine and the host app conform to. TypeScript types + JSON Schema + a Zod runtime validator.",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
package/src/engine.ts CHANGED
@@ -13,9 +13,7 @@ export type AssetData = Uint8Array | ArrayBuffer | string;
13
13
  /** Where an engine may persist saves/SRAM. */
14
14
  export type PersistMode = 'idbfs' | 'opfs' | null;
15
15
 
16
- export interface EngineConfig {
17
- /** Render target. The SDK is responsible for the `#canvas` id if the engine needs it. */
18
- canvas: HTMLCanvasElement;
16
+ type EngineConfigBase = {
19
17
  /** Runtime files keyed by `AssetSpec.key`. Required specs must be present. */
20
18
  assets: Record<string, AssetData>;
21
19
  /** Engine-specific settings, validated against `manifest.options`. */
@@ -32,7 +30,23 @@ export interface EngineConfig {
32
30
  /** Override artifact locations (e.g. host-fetched Release assets). */
33
31
  jsUrl?: string;
34
32
  wasmUrl?: string;
35
- }
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
+ );
36
50
 
37
51
  export type EngineEvent =
38
52
  | { type: 'ready' }