@wasm-gaming/rsdkv5-wasm 0.1.1 → 0.2.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.
@@ -1,58 +1,111 @@
1
- // Engine-specific options for RSDKv5U (Sonic Mania).
1
+ /**
2
+ * What RSDKv5 accepts, as types and as data.
3
+ *
4
+ * The four payloads of the wasm-gaming engine contract, closed for this engine, and
5
+ * {@link RSDKV5_SPEC} — the same thing as data the contract's base class reads:
6
+ * every default lives there and nowhere else.
7
+ */
8
+ import type { EnginePayloads, EngineSpec } from '@wasm-gaming/engine-specs';
2
9
 
3
- // This is the authoritative description of what `EngineConfig.options` accepts
4
- // for this engine. It provides both:
5
- // - `Rsdkv5Options` — the compile-time type (for TS hosts/launchers)
6
- // - `RSDKV5_OPTIONS_SCHEMA` — the JSON Schema mirrored into manifest.json's
7
- // `options` (for runtime host UI + validation)
8
- // - `DEFAULT_RSDKV5_OPTIONS` — defaults the SDK falls back to.
9
- //
10
- // At runtime these options are serialized into Sonic Mania's `Settings.ini`
11
- // when the host does not pass an explicit `settings` asset.
10
+ /** Bytes, or a thunk that produces them only when the engine actually needs them. */
11
+ export type Rsdkv5Asset =
12
+ | Uint8Array
13
+ | ArrayBuffer
14
+ | null
15
+ | (() => Uint8Array | ArrayBuffer | null | Promise<Uint8Array | ArrayBuffer | null>);
12
16
 
13
- import type { JSONSchema } from '@wasm-gaming/engine-specs';
14
-
15
- export interface Rsdkv5Options {
16
- /**
17
- * Sonic Mania's native dev menu. Kept off by default: the launcher owns its
18
- * own overlay, and leaving this on can hijack boot flow.
19
- */
17
+ /** The engine, written into the generated `Settings.ini`. Fixed for the life of the wasm. */
18
+ export interface Rsdkv5Config {
19
+ /** Sonic Mania's native dev menu. A host draws its own from `play.devMenu`. */
20
20
  devMenu?: boolean;
21
- /** Enables the debug hooks exposed by the web build. */
22
- engineDebugMode?: boolean;
23
- /** VSync the engine's SDL window. */
24
21
  vsync?: boolean;
25
- /** Language numeric value used by the build's settings.ini. */
22
+ /** RSDKv5 language index (0 = English). */
26
23
  language?: number;
27
- /** Region numeric value used by the build's settings.ini. */
24
+ /** RSDKv5 region (-1 = auto). */
28
25
  region?: number;
26
+ /** Emscripten glue URL. Defaults to `./rsdkv5.js` next to the SDK. */
27
+ jsUrl?: string;
28
+ /** WASM URL. Defaults to `./rsdkv5.wasm` next to the SDK. */
29
+ wasmUrl?: string;
29
30
  }
30
31
 
31
- export const DEFAULT_RSDKV5_OPTIONS: Required<Rsdkv5Options> = {
32
- devMenu: false,
33
- engineDebugMode: true,
34
- vsync: true,
35
- language: 0,
36
- region: -1,
37
- };
32
+ /** The session. Nothing per-session yet. */
33
+ export type Rsdkv5Options = Record<string, never>;
34
+
35
+ export interface Rsdkv5Assets {
36
+ /** The game's `Data.rsdk` (Sonic Mania). Required to start. */
37
+ data?: Rsdkv5Asset;
38
+ /** A ready-made `Settings.ini`; omitted, one is generated from `config`. */
39
+ settings?: Rsdkv5Asset;
40
+ }
41
+
42
+ /** Where this engine's files live, and whether they outlive the page. */
43
+ export interface Rsdkv5Storage {
44
+ /**
45
+ * Per-game folder, relative to the engine's own: files land in `rsdkv5/<namespace>/`
46
+ * (WASMFS `/data/rsdkv5/<namespace>`, and the OPFS folder the save is mirrored to).
47
+ * Segments are cleaned (`.`/`..` dropped, odd characters → `_`); a leading
48
+ * `rsdkv5/` is stripped once. `play.storagePath` gives the result.
49
+ *
50
+ * @defaultValue `"default"`
51
+ */
52
+ namespace?: string;
53
+ /** `null` keeps nothing; otherwise the game's user files are mirrored to OPFS. */
54
+ persist?: 'opfs' | null;
55
+ }
38
56
 
39
- export const RSDKV5_OPTIONS_SCHEMA: JSONSchema = {
40
- type: 'object',
41
- additionalProperties: false,
42
- properties: {
57
+ export interface Rsdkv5Events {
58
+ /** Save files changed and were written to `rsdkv5/<namespace>/`. */
59
+ saves: { files: string[] };
60
+ }
61
+
62
+ export interface Rsdkv5Payloads extends EnginePayloads {
63
+ config: Rsdkv5Config;
64
+ options: Rsdkv5Options;
65
+ assets: Rsdkv5Assets;
66
+ storage: Rsdkv5Storage;
67
+ events: Rsdkv5Events;
68
+ }
69
+
70
+ /** The native picture, which the SDK scales to fit its mount. */
71
+ export const RSDKV5_VIDEO = { width: 424, height: 240, aspect: '16:9' } as const;
72
+
73
+ export const RSDKV5_SPEC: EngineSpec<Rsdkv5Payloads> = {
74
+ config: {
43
75
  devMenu: {
44
- type: 'boolean',
45
76
  default: false,
46
- description:
47
- "Sonic Mania's native dev menu. The launcher provides its own overlay, so keep this off.",
77
+ live: false,
78
+ description: "Sonic Mania's native dev menu; keep it off and draw your own from play.devMenu.",
79
+ },
80
+ vsync: { default: true, live: false, description: 'VSync in the generated Settings.ini.' },
81
+ language: { default: 0, live: false, description: 'RSDKv5 language index (0 = English).' },
82
+ region: { default: -1, live: false, description: 'RSDKv5 region (-1 = auto).' },
83
+ jsUrl: { live: false, description: 'Emscripten glue URL. Defaults to ./rsdkv5.js.' },
84
+ wasmUrl: { live: false, description: 'WASM URL. Defaults to ./rsdkv5.wasm.' },
85
+ },
86
+ options: {},
87
+ assets: {
88
+ data: {
89
+ allowedTypes: ['.rsdk'],
90
+ live: false,
91
+ description: 'The RSDKv5 game data pack (Sonic Mania). Required to start.',
92
+ },
93
+ settings: {
94
+ allowedTypes: ['.ini'],
95
+ live: false,
96
+ description: 'A ready-made Settings.ini. Omitted, one is generated from config.',
97
+ },
98
+ },
99
+ storage: {
100
+ namespace: {
101
+ default: 'default',
102
+ live: false,
103
+ description: "Folder for this game's saves, inside the engine's own rsdkv5/ folder (OPFS rsdkv5/<namespace>/).",
48
104
  },
49
- engineDebugMode: {
50
- type: 'boolean',
51
- default: true,
52
- description: 'Enables the web debug hooks.',
105
+ persist: {
106
+ enum: ['opfs', null],
107
+ live: false,
108
+ description: "null keeps nothing; otherwise the game's user files are mirrored to OPFS.",
53
109
  },
54
- vsync: { type: 'boolean', default: true },
55
- language: { type: 'integer', default: 0, minimum: 0 },
56
- region: { type: 'integer', default: -1 },
57
110
  },
58
111
  };