@wasm-gaming/rsdkv3-wasm 0.1.2 → 0.1.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wasm-gaming/rsdkv3-wasm",
3
- "version": "0.1.2",
4
- "description": "RSDKv3 (Retro Software Development Kit v3) compiled to WebAssembly, with a JS SDK conforming to the wasm-gaming engine contract. Runs Sonic CD by loading Data.rsdk at runtime.",
3
+ "version": "0.1.5",
4
+ "description": "RSDKv3 (Sonic CD decompilation) compiled to WebAssembly, with a self-contained JS SDK implementing the wasm-gaming engine contract. Data.rsdk is loaded at runtime.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/wasm-gaming/rsdkv3-wasm.git"
@@ -21,30 +21,21 @@
21
21
  "./options": {
22
22
  "types": "./dist/rsdkv3/rsdkv3.options.d.ts",
23
23
  "import": "./dist/rsdkv3/rsdkv3.options.js"
24
- },
25
- "./manifest": "./dist/manifest.json"
24
+ }
26
25
  },
27
26
  "files": [
28
27
  "dist/rsdkv3/",
29
- "dist/manifest.json",
30
- "src/rsdkv3.manifest.ts",
31
28
  "src/rsdkv3.options.ts",
32
29
  "src/rsdkv3.sdk.ts",
33
- "src/wasm-specs.ts",
34
30
  "README.md"
35
31
  ],
36
32
  "comment:scripts": "Build logic lives in the Makefile, not here (make build / build-sdk / build-wasm / preview).",
37
33
  "scripts": {},
38
- "peerDependencies": {
39
- "@wasm-gaming/engine-specs": "*"
40
- },
41
- "peerDependenciesMeta": {
42
- "@wasm-gaming/engine-specs": {
43
- "optional": true
44
- }
34
+ "comment:dependencies": "engine-specs is the one wasm-gaming package an engine depends on. Its runtime is also copied into dist/rsdkv3/ and imported relatively, so the built SDK loads without a bundler or an import map; the dependency carries the types.",
35
+ "dependencies": {
36
+ "@wasm-gaming/engine-specs": "^0.3.2"
45
37
  },
46
38
  "devDependencies": {
47
- "@wasm-gaming/engine-specs": "^0.1.0",
48
39
  "typescript": "^5.5.0"
49
40
  },
50
41
  "engineContract": "https://github.com/wasm-gaming/engine-specs",
@@ -1,68 +1,116 @@
1
- // Engine-specific options for RSDKv3.
2
- //
3
- // This is the authoritative description of what `EngineConfig.options` accepts
4
- // for this engine. It provides both:
5
- // - `Rsdkv3Options` — compile-time type for TS hosts
6
- // - `RSDKV3_OPTIONS_SCHEMA` — JSON Schema mirrored into manifest.json
7
- // - `DEFAULT_RSDKV3_OPTIONS` — defaults used when no settings.ini is supplied
8
- //
9
- // At runtime these options are serialized into Sonic CD's `settings.ini` format
10
- // when the host does not pass an explicit `settings` asset.
1
+ /**
2
+ * What RSDKv3 accepts, as types and as data.
3
+ *
4
+ * The four payloads of the wasm-gaming engine contract, closed for this engine, and
5
+ * {@link RSDKV3_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';
11
9
 
12
- import type { JSONSchema } from '@wasm-gaming/engine-specs';
10
+ /** Bytes, or a thunk that produces them only when the engine actually needs them. */
11
+ export type Rsdkv3Asset =
12
+ | Uint8Array
13
+ | ArrayBuffer
14
+ | null
15
+ | (() => Uint8Array | ArrayBuffer | null | Promise<Uint8Array | ArrayBuffer | null>);
13
16
 
14
- export interface Rsdkv3Options {
15
- /**
16
- * RSDKv3's native in-canvas Dev Menu. Kept off by default: the launcher owns
17
- * the debug/stage-select UI (via `instance.devMenu`), and leaving this on has
18
- * historically produced a native menu-like screen at boot.
19
- */
17
+ /** The engine, written into the generated `settings.ini`. Fixed for the life of the wasm. */
18
+ export interface Rsdkv3Config {
19
+ /** RSDKv3's native in-canvas Dev Menu. A host draws its own from `play.devMenu`. */
20
20
  devMenu?: boolean;
21
- /** RSDKv3 EngineDebugMode — enables the web devmenu embind bridge hooks. */
21
+ /** RSDKv3 `EngineDebugMode`. */
22
22
  engineDebugMode?: boolean;
23
- /** VSync setting in the generated settings.ini. */
24
23
  vsync?: boolean;
25
- /** 0 = JP/EU soundtrack, 1 = US soundtrack. */
26
- soundtrack?: number;
27
- /** 0 = English. Matches RSDKv3 language numeric value. */
24
+ /** Sonic CD soundtrack: 0 = JP/EU, 1 = US. */
25
+ soundtrack?: 0 | 1;
26
+ /** RSDKv3 language index (0 = English). */
28
27
  language?: number;
29
- /** Toggle touch controls in the generated settings.ini. */
30
28
  disableTouchControls?: boolean;
29
+ /** Emscripten glue URL. Defaults to `./rsdkv3.js` next to the SDK. */
30
+ jsUrl?: string;
31
+ /** WASM URL. Defaults to `./rsdkv3.wasm` next to the SDK. */
32
+ wasmUrl?: string;
31
33
  }
32
34
 
33
- export const DEFAULT_RSDKV3_OPTIONS: Required<Rsdkv3Options> = {
34
- devMenu: false,
35
- engineDebugMode: false,
36
- vsync: false,
37
- soundtrack: 0,
38
- language: 0,
39
- disableTouchControls: true,
40
- };
35
+ /** The session. Nothing per-session yet. */
36
+ export type Rsdkv3Options = Record<string, never>;
37
+
38
+ export interface Rsdkv3Assets {
39
+ /** The game's `Data.rsdk` (Sonic CD). Required to start. */
40
+ data?: Rsdkv3Asset;
41
+ /** A ready-made `settings.ini`; omitted, one is generated from `config`. */
42
+ settings?: Rsdkv3Asset;
43
+ }
41
44
 
42
- export const RSDKV3_OPTIONS_SCHEMA: JSONSchema = {
43
- type: 'object',
44
- additionalProperties: false,
45
- properties: {
45
+ /** Where this engine's files live, and whether they outlive the page. */
46
+ export interface Rsdkv3Storage {
47
+ /**
48
+ * Per-game folder, relative to the engine's own: files land in `rsdkv3/<namespace>/`
49
+ * (WASMFS `/data/rsdkv3/<namespace>`, and the OPFS folder the save is mirrored to).
50
+ * Segments are cleaned (`.`/`..` dropped, odd characters → `_`); a leading
51
+ * `rsdkv3/` is stripped once. `play.storagePath` gives the result.
52
+ *
53
+ * @defaultValue `"default"`
54
+ */
55
+ namespace?: string;
56
+ /** `null` keeps nothing; otherwise `SData.bin` is mirrored to OPFS. */
57
+ persist?: 'opfs' | null;
58
+ }
59
+
60
+ export interface Rsdkv3Events {
61
+ /** `SData.bin` changed and was written to `rsdkv3/<namespace>/`. */
62
+ saves: { files: string[] };
63
+ }
64
+
65
+ export interface Rsdkv3Payloads extends EnginePayloads {
66
+ config: Rsdkv3Config;
67
+ options: Rsdkv3Options;
68
+ assets: Rsdkv3Assets;
69
+ storage: Rsdkv3Storage;
70
+ events: Rsdkv3Events;
71
+ }
72
+
73
+ /** The native picture, which the SDK scales to fit its mount. */
74
+ export const RSDKV3_VIDEO = { width: 426, height: 240, aspect: '16:9' } as const;
75
+
76
+ export const RSDKV3_SPEC: EngineSpec<Rsdkv3Payloads> = {
77
+ config: {
46
78
  devMenu: {
47
- type: 'boolean',
48
79
  default: false,
49
- description:
50
- "RSDKv3's native in-canvas Dev Menu. The launcher provides its own overlay via instance.devMenu, so keep this off.",
80
+ live: false,
81
+ description: "RSDKv3's native Dev Menu; keep it off and draw your own from play.devMenu.",
51
82
  },
52
- engineDebugMode: {
53
- type: 'boolean',
54
- default: false,
55
- description: 'Enables the web devmenu embind bridge (stage list / warp / pause).',
83
+ engineDebugMode: { default: false, live: false, description: 'RSDKv3 EngineDebugMode.' },
84
+ vsync: { default: false, live: false, description: 'VSync in the generated settings.ini.' },
85
+ soundtrack: { default: 0, enum: [0, 1], live: false, description: 'Sonic CD soundtrack: 0 = JP/EU, 1 = US.' },
86
+ language: { default: 0, live: false, description: 'RSDKv3 language index (0 = English).' },
87
+ disableTouchControls: { default: true, live: false, description: 'Hide the touch controls.' },
88
+ jsUrl: { live: false, description: 'Emscripten glue URL. Defaults to ./rsdkv3.js.' },
89
+ wasmUrl: { live: false, description: 'WASM URL. Defaults to ./rsdkv3.wasm.' },
90
+ },
91
+ options: {},
92
+ assets: {
93
+ data: {
94
+ allowedTypes: ['.rsdk'],
95
+ live: false,
96
+ description: 'The RSDKv3 game data pack (Sonic CD). Required to start.',
97
+ },
98
+ settings: {
99
+ allowedTypes: ['.ini'],
100
+ live: false,
101
+ description: 'A ready-made settings.ini. Omitted, one is generated from config.',
102
+ },
103
+ },
104
+ storage: {
105
+ namespace: {
106
+ default: 'default',
107
+ live: false,
108
+ description: "Folder for this game's save, inside the engine's own rsdkv3/ folder (OPFS rsdkv3/<namespace>/).",
56
109
  },
57
- vsync: { type: 'boolean', default: false },
58
- soundtrack: {
59
- type: 'integer',
60
- minimum: 0,
61
- maximum: 1,
62
- default: 0,
63
- description: 'Sonic CD soundtrack selector: 0=JP/EU, 1=US.',
110
+ persist: {
111
+ enum: ['opfs', null],
112
+ live: false,
113
+ description: 'null keeps nothing; otherwise SData.bin is mirrored to OPFS.',
64
114
  },
65
- language: { type: 'integer', minimum: 0, default: 0 },
66
- disableTouchControls: { type: 'boolean', default: true },
67
115
  },
68
116
  };