c64-ready 1.1.0 → 2.0.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 +17 -12
- package/dist/assets/index-B3vw_7xz.js +169 -0
- package/dist/index.html +1 -1
- package/dist-ts/emulator/c64-emulator.d.ts +5 -2
- package/dist-ts/emulator/c64-emulator.d.ts.map +1 -1
- package/dist-ts/emulator/c64-emulator.js +24 -12
- package/dist-ts/emulator/c64-emulator.js.map +1 -1
- package/dist-ts/emulator/c64-wasm.d.ts +1 -1
- package/dist-ts/emulator/constants.d.ts +3 -1
- package/dist-ts/emulator/constants.d.ts.map +1 -1
- package/dist-ts/emulator/constants.js +2 -0
- package/dist-ts/emulator/constants.js.map +1 -1
- package/dist-ts/emulator/input.d.ts +26 -3
- package/dist-ts/emulator/input.d.ts.map +1 -1
- package/dist-ts/emulator/input.js +287 -10
- package/dist-ts/emulator/input.js.map +1 -1
- package/dist-ts/headless/audio-capture.d.ts +1 -1
- package/dist-ts/headless/c64-headless.d.ts +2 -2
- package/dist-ts/headless/c64-headless.js +4 -4
- package/dist-ts/headless/frame-capture.d.ts +1 -1
- package/dist-ts/headless/input-bridge.d.ts +1 -1
- package/dist-ts/player/audio-engine.d.ts +73 -0
- package/dist-ts/player/audio-engine.d.ts.map +1 -0
- package/dist-ts/{src/player → player}/audio-engine.js +7 -2
- package/dist-ts/player/audio-engine.js.map +1 -0
- package/dist-ts/player/c64-player.d.ts +69 -0
- package/dist-ts/player/c64-player.d.ts.map +1 -0
- package/dist-ts/player/c64-player.js +416 -0
- package/dist-ts/player/c64-player.js.map +1 -0
- package/dist-ts/player/canvas-renderer.d.ts +21 -0
- package/dist-ts/player/canvas-renderer.d.ts.map +1 -0
- package/dist-ts/{src/player → player}/canvas-renderer.js +55 -44
- package/dist-ts/player/canvas-renderer.js.map +1 -0
- package/dist-ts/player/index.d.ts +10 -0
- package/dist-ts/player/index.d.ts.map +1 -0
- package/dist-ts/player/index.js +6 -0
- package/dist-ts/player/index.js.map +1 -0
- package/dist-ts/player/input-handler.d.ts +21 -0
- package/dist-ts/player/input-handler.d.ts.map +1 -0
- package/dist-ts/player/input-handler.js +122 -0
- package/dist-ts/player/input-handler.js.map +1 -0
- package/dist-ts/player/load-formats.d.ts +15 -0
- package/dist-ts/player/load-formats.d.ts.map +1 -0
- package/dist-ts/player/load-formats.js +38 -0
- package/dist-ts/player/load-formats.js.map +1 -0
- package/dist-ts/player/ui-controller.d.ts +44 -0
- package/dist-ts/player/ui-controller.d.ts.map +1 -0
- package/dist-ts/player/ui-controller.js +844 -0
- package/dist-ts/player/ui-controller.js.map +1 -0
- package/dist-ts/types/emulator.d.ts +2 -2
- package/dist-ts/types/emulator.d.ts.map +1 -1
- package/package.json +31 -3
- package/src/emulator/c64-emulator.ts +15 -5
- package/src/emulator/constants.ts +5 -1
- package/src/emulator/input.ts +131 -39
- package/src/headless/webrtc-server.mjs +73 -8
- package/src/player/audio-engine.ts +13 -2
- package/src/player/c64-player.ts +128 -58
- package/src/player/canvas-renderer.ts +57 -5
- package/src/player/index.ts +7 -0
- package/src/player/ui-controller.ts +34 -14
- package/src/types/emulator.ts +1 -1
- package/dist/assets/CHANGELOG-0a7A8Ekq.js +0 -391
- package/dist/assets/index-BESofQoh.js +0 -627
- package/dist-ts/emulator/c64-emulator.test.js +0 -104
- package/dist-ts/emulator/c64-wasm.test.js +0 -65
- package/dist-ts/emulator/input.test.js +0 -53
- package/dist-ts/src/counter.js +0 -9
- package/dist-ts/src/emulator/c64-emulator.js +0 -308
- package/dist-ts/src/emulator/c64-emulator.test.js +0 -104
- package/dist-ts/src/emulator/c64-wasm.js +0 -149
- package/dist-ts/src/emulator/c64-wasm.test.js +0 -65
- package/dist-ts/src/emulator/constants.js +0 -9
- package/dist-ts/src/emulator/input.js +0 -62
- package/dist-ts/src/emulator/input.test.js +0 -53
- package/dist-ts/src/emulator/memory.js +0 -1
- package/dist-ts/src/headless/audio-capture.js +0 -23
- package/dist-ts/src/headless/c64-headless.js +0 -85
- package/dist-ts/src/headless/ffmpeg-runner.js +0 -33
- package/dist-ts/src/headless/frame-capture.js +0 -23
- package/dist-ts/src/headless/headless.cli.test.js +0 -46
- package/dist-ts/src/headless/input-bridge.js +0 -37
- package/dist-ts/src/main.js +0 -57
- package/dist-ts/src/player/audio-engine.test.js +0 -284
- package/dist-ts/src/player/c64-player.js +0 -105
- package/dist-ts/src/player/c64-player.test.js +0 -165
- package/dist-ts/src/player/canvas-renderer.test.js +0 -135
- package/dist-ts/src/player/input-handler.js +0 -13
- package/dist-ts/src/player/ui-controller.js +0 -575
- package/dist-ts/src/player/ui-controller.test.js +0 -67
- package/dist-ts/src/types/emulator.js +0 -1
- package/dist-ts/src/types/index.js +0 -4
- package/dist-ts/tools/run-wrapper.js +0 -36
- /package/dist/assets/{marked.esm-BOXuzyNF.js → marked.esm--kBm026b.js} +0 -0
- /package/dist/assets/{purify.es-y41lKIN9.js → purify.es-BcoGFDcJ.js} +0 -0
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import http from 'http';
|
|
23
|
+
import crypto from 'crypto';
|
|
23
24
|
import { WebSocketServer } from 'ws';
|
|
24
25
|
import wrtc from '@roamhq/wrtc';
|
|
25
26
|
|
|
@@ -32,15 +33,51 @@ function parseCsvList(raw) {
|
|
|
32
33
|
.filter(Boolean);
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
function normalizeTurnTtlSeconds(rawTtl, fallback = 24 * 3600) {
|
|
37
|
+
const parsed = Number.parseInt(String(rawTtl ?? ''), 10);
|
|
38
|
+
if (Number.isFinite(parsed) && parsed > 0) return parsed;
|
|
39
|
+
return fallback;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function buildTimedTurnCredentials({
|
|
43
|
+
secret,
|
|
44
|
+
ttlSeconds = 24 * 3600,
|
|
45
|
+
usernameLabel = 'c64live',
|
|
46
|
+
nowSeconds = Math.floor(Date.now() / 1000),
|
|
47
|
+
} = {}) {
|
|
48
|
+
const safeSecret = String(secret ?? '').trim();
|
|
49
|
+
if (!safeSecret) throw new Error('TURN secret is required');
|
|
50
|
+
|
|
51
|
+
const safeLabel = String(usernameLabel ?? '').trim() || 'c64live';
|
|
52
|
+
const expiresAt = Math.floor(nowSeconds) + normalizeTurnTtlSeconds(ttlSeconds);
|
|
53
|
+
const username = `${expiresAt}:${safeLabel}`;
|
|
54
|
+
const credential = crypto
|
|
55
|
+
.createHmac('sha1', safeSecret)
|
|
56
|
+
.update(username)
|
|
57
|
+
.digest('base64');
|
|
58
|
+
|
|
59
|
+
return { username, credential };
|
|
60
|
+
}
|
|
61
|
+
|
|
35
62
|
function buildIceServers({
|
|
36
63
|
iceStunUrls,
|
|
37
64
|
iceTurnUrls,
|
|
65
|
+
iceTurnSecret,
|
|
66
|
+
iceTurnTtlSeconds,
|
|
67
|
+
iceTurnUsernameLabel,
|
|
38
68
|
iceTurnUsername,
|
|
39
69
|
iceTurnPassword,
|
|
40
70
|
verbose = false,
|
|
41
71
|
} = {}) {
|
|
42
72
|
const stunUrls = parseCsvList(iceStunUrls ?? process.env.ICE_STUN_URLS);
|
|
43
73
|
const turnUrls = parseCsvList(iceTurnUrls ?? process.env.ICE_TURN_URLS);
|
|
74
|
+
const turnSecret = String(iceTurnSecret ?? process.env.ICE_TURN_SECRET ?? '').trim();
|
|
75
|
+
const turnTtlSeconds = normalizeTurnTtlSeconds(
|
|
76
|
+
iceTurnTtlSeconds ?? process.env.ICE_TURN_TTL_SECONDS,
|
|
77
|
+
);
|
|
78
|
+
const turnUsernameLabel = String(
|
|
79
|
+
iceTurnUsernameLabel ?? process.env.ICE_TURN_USERNAME_LABEL ?? 'c64live',
|
|
80
|
+
).trim();
|
|
44
81
|
const turnUsername = String(iceTurnUsername ?? process.env.ICE_TURN_USERNAME ?? '').trim();
|
|
45
82
|
const turnPassword = String(iceTurnPassword ?? process.env.ICE_TURN_PASSWORD ?? '').trim();
|
|
46
83
|
|
|
@@ -49,7 +86,18 @@ function buildIceServers({
|
|
|
49
86
|
iceServers.push({ urls: stunUrls });
|
|
50
87
|
}
|
|
51
88
|
|
|
52
|
-
if (turnUrls.length > 0 &&
|
|
89
|
+
if (turnUrls.length > 0 && turnSecret) {
|
|
90
|
+
const creds = buildTimedTurnCredentials({
|
|
91
|
+
secret: turnSecret,
|
|
92
|
+
ttlSeconds: turnTtlSeconds,
|
|
93
|
+
usernameLabel: turnUsernameLabel,
|
|
94
|
+
});
|
|
95
|
+
iceServers.push({
|
|
96
|
+
urls: turnUrls,
|
|
97
|
+
username: creds.username,
|
|
98
|
+
credential: creds.credential,
|
|
99
|
+
});
|
|
100
|
+
} else if (turnUrls.length > 0 && turnUsername && turnPassword) {
|
|
53
101
|
iceServers.push({
|
|
54
102
|
urls: turnUrls,
|
|
55
103
|
username: turnUsername,
|
|
@@ -57,7 +105,7 @@ function buildIceServers({
|
|
|
57
105
|
});
|
|
58
106
|
} else if (turnUrls.length > 0 && verbose) {
|
|
59
107
|
console.error(
|
|
60
|
-
'[webrtc] ICE_TURN_URLS provided without ICE_TURN_USERNAME/ICE_TURN_PASSWORD; skipping TURN',
|
|
108
|
+
'[webrtc] ICE_TURN_URLS provided without ICE_TURN_SECRET or ICE_TURN_USERNAME/ICE_TURN_PASSWORD; skipping TURN',
|
|
61
109
|
);
|
|
62
110
|
}
|
|
63
111
|
|
|
@@ -68,9 +116,13 @@ function buildIceServers({
|
|
|
68
116
|
if (verbose) {
|
|
69
117
|
const stunCount = stunUrls.length;
|
|
70
118
|
const turnCount = turnUrls.length;
|
|
71
|
-
const
|
|
119
|
+
const turnMode = turnUrls.length > 0 && turnSecret
|
|
120
|
+
? 'timed'
|
|
121
|
+
: turnUrls.length > 0 && turnUsername && turnPassword
|
|
122
|
+
? 'static'
|
|
123
|
+
: 'disabled';
|
|
72
124
|
console.error(
|
|
73
|
-
`[webrtc] ICE config stunUrls=${stunCount} turnUrls=${turnCount}
|
|
125
|
+
`[webrtc] ICE config stunUrls=${stunCount} turnUrls=${turnCount} turnMode=${turnMode}`,
|
|
74
126
|
);
|
|
75
127
|
}
|
|
76
128
|
|
|
@@ -92,6 +144,9 @@ function buildIceServers({
|
|
|
92
144
|
* @param {number} [opts.maxBitrateKbps=600] SDP x-google-max-bitrate for VP8 answer
|
|
93
145
|
* @param {string|string[]} [opts.iceStunUrls] Optional STUN URL list
|
|
94
146
|
* @param {string|string[]} [opts.iceTurnUrls] Optional TURN URL list
|
|
147
|
+
* @param {string} [opts.iceTurnSecret] Optional TURN shared secret for timed creds
|
|
148
|
+
* @param {number} [opts.iceTurnTtlSeconds] Optional TURN credential TTL in seconds
|
|
149
|
+
* @param {string} [opts.iceTurnUsernameLabel] Optional TURN username suffix for timed creds
|
|
95
150
|
* @param {string} [opts.iceTurnUsername] Optional TURN username
|
|
96
151
|
* @param {string} [opts.iceTurnPassword] Optional TURN credential/password
|
|
97
152
|
* @param {(pc: RTCPeerConnection) => void} opts.onOffer
|
|
@@ -113,20 +168,28 @@ export function createWebRTCServer({
|
|
|
113
168
|
maxBitrateKbps = 600,
|
|
114
169
|
iceStunUrls,
|
|
115
170
|
iceTurnUrls,
|
|
171
|
+
iceTurnSecret,
|
|
172
|
+
iceTurnTtlSeconds,
|
|
173
|
+
iceTurnUsernameLabel,
|
|
116
174
|
iceTurnUsername,
|
|
117
175
|
iceTurnPassword,
|
|
118
176
|
onOffer,
|
|
119
177
|
onPeerConnected,
|
|
120
178
|
onDataChannelInput,
|
|
121
179
|
} = {}) {
|
|
122
|
-
const
|
|
180
|
+
const buildRuntimeIceServers = () => buildIceServers({
|
|
123
181
|
iceStunUrls,
|
|
124
182
|
iceTurnUrls,
|
|
183
|
+
iceTurnSecret,
|
|
184
|
+
iceTurnTtlSeconds,
|
|
185
|
+
iceTurnUsernameLabel,
|
|
125
186
|
iceTurnUsername,
|
|
126
187
|
iceTurnPassword,
|
|
127
188
|
verbose,
|
|
128
189
|
});
|
|
129
190
|
|
|
191
|
+
const iceServers = buildRuntimeIceServers();
|
|
192
|
+
|
|
130
193
|
/** Emit a structured [event] line — same format as input-server.mjs. */
|
|
131
194
|
function logEv(tag, fields = {}) {
|
|
132
195
|
if (!logEvents) return;
|
|
@@ -468,11 +531,13 @@ export function createWebRTCServer({
|
|
|
468
531
|
|
|
469
532
|
const httpServer = http.createServer((req, res) => {
|
|
470
533
|
if (req.method === 'GET' && (req.url === '/' || req.url === '/index.html')) {
|
|
534
|
+
const requestIceServers = buildRuntimeIceServers();
|
|
471
535
|
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
472
|
-
res.end(buildBrowserHtml(inputPort, minBitrateKbpsSafe, maxBitrateKbpsSafe,
|
|
536
|
+
res.end(buildBrowserHtml(inputPort, minBitrateKbpsSafe, maxBitrateKbpsSafe, requestIceServers));
|
|
473
537
|
} else if (req.method === 'GET' && req.url === '/ice-config') {
|
|
538
|
+
const requestIceServers = buildRuntimeIceServers();
|
|
474
539
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
475
|
-
res.end(JSON.stringify({ iceServers }));
|
|
540
|
+
res.end(JSON.stringify({ iceServers: requestIceServers }));
|
|
476
541
|
} else if (req.url === '/favicon.ico') {
|
|
477
542
|
// Return a minimal 1×1 transparent ICO so browsers don't log a 404
|
|
478
543
|
res.writeHead(204);
|
|
@@ -554,7 +619,7 @@ export function createWebRTCServer({
|
|
|
554
619
|
logEv('webrtc-peer-connected', { addr: remoteAddr });
|
|
555
620
|
logLoadSnapshot('webrtc-load-change', { reason: 'peer-connected' });
|
|
556
621
|
|
|
557
|
-
const pc = new RTCPeerConnection({ iceServers });
|
|
622
|
+
const pc = new RTCPeerConnection({ iceServers: buildRuntimeIceServers() });
|
|
558
623
|
const controller = {
|
|
559
624
|
pc,
|
|
560
625
|
ws,
|
|
@@ -30,6 +30,11 @@ const DEFAULT_SAMPLE_RATE = 44_100;
|
|
|
30
30
|
/** Function the AudioEngine calls to read the current SID audio buffer */
|
|
31
31
|
export type SidBufferReader = () => Float32Array | null;
|
|
32
32
|
|
|
33
|
+
export interface AudioEngineOptions {
|
|
34
|
+
workletUrl?: string;
|
|
35
|
+
assetBaseUrl?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
export class AudioEngine {
|
|
34
39
|
private ctx: AudioContext | null = null;
|
|
35
40
|
private workletNode: AudioWorkletNode | null = null;
|
|
@@ -40,6 +45,7 @@ export class AudioEngine {
|
|
|
40
45
|
private _suspended = true;
|
|
41
46
|
private _initialised = false;
|
|
42
47
|
private _ready = false;
|
|
48
|
+
private readonly options: AudioEngineOptions;
|
|
43
49
|
|
|
44
50
|
/** Called when the worklet needs more samples */
|
|
45
51
|
private _readSidBuffer: SidBufferReader | null = null;
|
|
@@ -47,6 +53,10 @@ export class AudioEngine {
|
|
|
47
53
|
/** Optional callback fired whenever muted / volume / suspended state changes */
|
|
48
54
|
onStateChange?: AudioStateChangeCallback;
|
|
49
55
|
|
|
56
|
+
constructor(options: AudioEngineOptions = {}) {
|
|
57
|
+
this.options = options;
|
|
58
|
+
}
|
|
59
|
+
|
|
50
60
|
// ── Public getters ────────────────────────────────────────────────────────
|
|
51
61
|
|
|
52
62
|
get muted(): boolean {
|
|
@@ -114,8 +124,9 @@ export class AudioEngine {
|
|
|
114
124
|
|
|
115
125
|
private async loadWorklet(): Promise<void> {
|
|
116
126
|
if (!this.ctx || !this.gainNode) return;
|
|
117
|
-
const base =
|
|
118
|
-
const processorUrl =
|
|
127
|
+
const base = this.options.assetBaseUrl ?? '/';
|
|
128
|
+
const processorUrl =
|
|
129
|
+
this.options.workletUrl ?? `${base.replace(/\/+$/, '')}/audio-worklet-processor.js`;
|
|
119
130
|
await this.ctx.audioWorklet.addModule(processorUrl);
|
|
120
131
|
|
|
121
132
|
this.workletNode = new AudioWorkletNode(this.ctx, 'c64-audio-processor', {
|
package/src/player/c64-player.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { GameLoadOptions } from '../types';
|
|
|
5
5
|
import type { JoystickPort } from '../emulator/constants';
|
|
6
6
|
import type { InputMode } from '../emulator/input';
|
|
7
7
|
import type CanvasRenderer from './canvas-renderer';
|
|
8
|
-
import { AudioEngine } from './audio-engine';
|
|
8
|
+
import { AudioEngine, type AudioEngineOptions } from './audio-engine';
|
|
9
9
|
import InputHandler from './input-handler';
|
|
10
10
|
import { getLoadTypeLabel, inferLoadTypeFromFilename } from './load-formats';
|
|
11
11
|
|
|
@@ -14,36 +14,50 @@ export type ProgressCallback = (percent: number, label: string) => void;
|
|
|
14
14
|
export interface C64PlayerOptions {
|
|
15
15
|
wasmUrl: string;
|
|
16
16
|
gameUrl: string;
|
|
17
|
+
gameData?: Uint8Array<ArrayBufferLike> | ArrayBufferLike | string;
|
|
18
|
+
gameSource?: string;
|
|
17
19
|
gameType?: GameLoadOptions['type'];
|
|
18
20
|
renderer: CanvasRenderer;
|
|
19
21
|
onProgress?: ProgressCallback;
|
|
22
|
+
audio?: AudioEngineOptions;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export class C64Player {
|
|
23
26
|
private emulator: C64Emulator | null = null;
|
|
24
27
|
private inputHandler: InputHandler | null = null;
|
|
25
28
|
private disableCrtPreloadChecks: boolean = false;
|
|
26
|
-
|
|
29
|
+
private destroyed: boolean = false;
|
|
30
|
+
readonly audio: AudioEngine;
|
|
27
31
|
private readonly options: Required<Pick<C64PlayerOptions, 'wasmUrl' | 'gameUrl' | 'gameType'>> &
|
|
28
32
|
C64PlayerOptions;
|
|
29
33
|
|
|
30
34
|
constructor(options: C64PlayerOptions) {
|
|
31
35
|
this.options = { gameType: 'crt', ...options };
|
|
36
|
+
this.audio = new AudioEngine(options.audio);
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
async start(): Promise<void> {
|
|
35
|
-
|
|
40
|
+
this.destroyed = false;
|
|
41
|
+
const { wasmUrl, gameUrl, gameData, gameSource, gameType, renderer, onProgress } = this.options;
|
|
36
42
|
|
|
37
43
|
onProgress?.(10, 'INITIALISING WASM...');
|
|
38
44
|
this.emulator = await C64Emulator.load(wasmUrl);
|
|
39
45
|
this.emulator.setCrtPreloadChecksEnabled(!this.disableCrtPreloadChecks);
|
|
40
46
|
this.attachInputAndRenderer(this.emulator, renderer);
|
|
47
|
+
let shouldAutoRunPrgAfterStart = false;
|
|
41
48
|
|
|
42
|
-
if (
|
|
49
|
+
if (gameData !== undefined && gameData !== null) {
|
|
50
|
+
await this.loadGameData(gameData, gameType, gameSource ?? 'inline game data', onProgress);
|
|
51
|
+
shouldAutoRunPrgAfterStart = gameType === 'prg';
|
|
52
|
+
} else if (gameUrl && gameUrl !== 'null') {
|
|
43
53
|
await this.loadGame(gameUrl, gameType, onProgress);
|
|
54
|
+
shouldAutoRunPrgAfterStart = gameType === 'prg';
|
|
44
55
|
}
|
|
45
56
|
|
|
46
57
|
this.emulator.start();
|
|
58
|
+
if (shouldAutoRunPrgAfterStart) {
|
|
59
|
+
await this.autoRunPrgIfRunning();
|
|
60
|
+
}
|
|
47
61
|
|
|
48
62
|
// Initialise audio in the background — never blocks game startup
|
|
49
63
|
this.initAudio();
|
|
@@ -122,31 +136,21 @@ export class C64Player {
|
|
|
122
136
|
}
|
|
123
137
|
|
|
124
138
|
onProgress?.(90, `INSERTING ${formatLoadProgressLabel(type)}...`);
|
|
125
|
-
this.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
onProgress?.(0, 'FAILED');
|
|
141
|
-
console.error('Failed to insert cartridge or load game:', err);
|
|
142
|
-
// Surface a global event so UI can react if needed
|
|
143
|
-
window.dispatchEvent(
|
|
144
|
-
new CustomEvent('c64-load-error', {
|
|
145
|
-
detail: { error: err instanceof Error ? err.message : String(err), url, type },
|
|
146
|
-
}),
|
|
147
|
-
);
|
|
148
|
-
throw err;
|
|
149
|
-
}
|
|
139
|
+
await this.insertGameData(data, type, url, { url }, onProgress);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async loadGameData(
|
|
143
|
+
gameData: Uint8Array<ArrayBufferLike> | ArrayBufferLike | string,
|
|
144
|
+
type: GameLoadOptions['type'] = 'crt',
|
|
145
|
+
source: string = 'inline game data',
|
|
146
|
+
onProgress: ProgressCallback | undefined = this.options.onProgress,
|
|
147
|
+
): Promise<void> {
|
|
148
|
+
if (!this.emulator) throw new Error('Emulator not initialised — call start() first');
|
|
149
|
+
|
|
150
|
+
onProgress?.(20, 'LOADING GAME DATA...');
|
|
151
|
+
const data = normaliseGameData(gameData);
|
|
152
|
+
onProgress?.(90, `INSERTING ${formatLoadProgressLabel(type)}...`);
|
|
153
|
+
await this.insertGameData(data, type, source, { source }, onProgress);
|
|
150
154
|
}
|
|
151
155
|
|
|
152
156
|
// Load a game from a File/Blob provided by the user (drag & drop / file input)
|
|
@@ -159,34 +163,10 @@ export class C64Player {
|
|
|
159
163
|
const ab = await file.arrayBuffer();
|
|
160
164
|
const data = new Uint8Array(ab);
|
|
161
165
|
onProgress?.(90, `INSERTING ${formatLoadProgressLabel(resolvedType)}...`);
|
|
162
|
-
this.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this.handleCrtPreloadChecks(data, file.name, onProgress);
|
|
167
|
-
}
|
|
168
|
-
this.emulator.loadGame({ type: resolvedType, data });
|
|
169
|
-
if (resolvedType === 'prg') {
|
|
170
|
-
await this.autoRunPrgIfRunning();
|
|
171
|
-
}
|
|
172
|
-
onProgress?.(100, 'READY!');
|
|
173
|
-
window.dispatchEvent(
|
|
174
|
-
new CustomEvent('c64-close-dialog', { detail: { file: file.name, type: resolvedType } }),
|
|
175
|
-
);
|
|
176
|
-
} catch (err) {
|
|
177
|
-
onProgress?.(0, 'FAILED');
|
|
178
|
-
console.error('Failed to insert cartridge from file:', err);
|
|
179
|
-
window.dispatchEvent(
|
|
180
|
-
new CustomEvent('c64-load-error', {
|
|
181
|
-
detail: {
|
|
182
|
-
error: err instanceof Error ? err.message : String(err),
|
|
183
|
-
file: file.name,
|
|
184
|
-
type: resolvedType,
|
|
185
|
-
},
|
|
186
|
-
}),
|
|
187
|
-
);
|
|
188
|
-
throw err;
|
|
189
|
-
}
|
|
166
|
+
await this.insertGameData(data, resolvedType, file.name, { file: file.name }, onProgress);
|
|
167
|
+
window.dispatchEvent(
|
|
168
|
+
new CustomEvent('c64-close-dialog', { detail: { file: file.name, type: resolvedType } }),
|
|
169
|
+
);
|
|
190
170
|
} catch (err) {
|
|
191
171
|
onProgress?.(0, 'FAILED');
|
|
192
172
|
throw err;
|
|
@@ -252,6 +232,23 @@ export class C64Player {
|
|
|
252
232
|
}
|
|
253
233
|
}
|
|
254
234
|
|
|
235
|
+
async destroy(): Promise<void> {
|
|
236
|
+
if (this.destroyed) return;
|
|
237
|
+
this.destroyed = true;
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
this.emulator?.pause();
|
|
241
|
+
} finally {
|
|
242
|
+
this.inputHandler?.detach();
|
|
243
|
+
this.inputHandler = null;
|
|
244
|
+
this.options.renderer.detach();
|
|
245
|
+
this.audio.onStateChange = undefined;
|
|
246
|
+
this.audio.setSidBufferReader(() => null);
|
|
247
|
+
await this.audio.destroy();
|
|
248
|
+
this.emulator = null;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
255
252
|
/**
|
|
256
253
|
* Change which joystick port keyboard events map to (1 or 2).
|
|
257
254
|
* Delegates to the InputHandler created during start().
|
|
@@ -279,13 +276,17 @@ export class C64Player {
|
|
|
279
276
|
return this.inputHandler?.getActiveGamepadIndex() ?? -1;
|
|
280
277
|
}
|
|
281
278
|
|
|
282
|
-
getSnapshot(): Uint8Array {
|
|
279
|
+
getSnapshot(): Uint8Array<ArrayBufferLike> {
|
|
283
280
|
if (!this.emulator) {
|
|
284
281
|
throw new Error('Emulator not initialised');
|
|
285
282
|
}
|
|
286
283
|
return this.emulator.getSnapshot();
|
|
287
284
|
}
|
|
288
285
|
|
|
286
|
+
setVoiceEnabled(voice: number, enabled: boolean): void {
|
|
287
|
+
this.emulator?.setVoiceEnabled(voice, enabled);
|
|
288
|
+
}
|
|
289
|
+
|
|
289
290
|
setCrtPreloadChecksDisabled(disabled: boolean): void {
|
|
290
291
|
this.disableCrtPreloadChecks = disabled;
|
|
291
292
|
this.emulator?.setCrtPreloadChecksEnabled(!disabled);
|
|
@@ -297,6 +298,39 @@ export class C64Player {
|
|
|
297
298
|
await this.typeCommand('run\n');
|
|
298
299
|
}
|
|
299
300
|
|
|
301
|
+
private async insertGameData(
|
|
302
|
+
data: Uint8Array<ArrayBufferLike>,
|
|
303
|
+
type: GameLoadOptions['type'],
|
|
304
|
+
source: string,
|
|
305
|
+
eventDetail: Record<string, unknown>,
|
|
306
|
+
onProgress?: ProgressCallback,
|
|
307
|
+
): Promise<void> {
|
|
308
|
+
if (!this.emulator) throw new Error('Emulator not initialised — call start() first');
|
|
309
|
+
|
|
310
|
+
this.assertSnapshotFormatSupported(data, type, source);
|
|
311
|
+
this.emitSnapshotLoadInfo(type, source);
|
|
312
|
+
try {
|
|
313
|
+
if (type === 'crt') {
|
|
314
|
+
this.handleCrtPreloadChecks(data, source, onProgress);
|
|
315
|
+
}
|
|
316
|
+
this.emulator.loadGame({ type, data });
|
|
317
|
+
if (type === 'prg') {
|
|
318
|
+
await this.autoRunPrgIfRunning();
|
|
319
|
+
}
|
|
320
|
+
onProgress?.(100, 'READY!');
|
|
321
|
+
window.dispatchEvent(new CustomEvent('c64-load-success', { detail: { ...eventDetail, type } }));
|
|
322
|
+
} catch (err) {
|
|
323
|
+
onProgress?.(0, 'FAILED');
|
|
324
|
+
console.error('Failed to insert cartridge or load game:', err);
|
|
325
|
+
window.dispatchEvent(
|
|
326
|
+
new CustomEvent('c64-load-error', {
|
|
327
|
+
detail: { error: err instanceof Error ? err.message : String(err), ...eventDetail, type },
|
|
328
|
+
}),
|
|
329
|
+
);
|
|
330
|
+
throw err;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
300
334
|
private async typeCommand(command: string): Promise<void> {
|
|
301
335
|
if (!this.emulator) return;
|
|
302
336
|
|
|
@@ -428,6 +462,42 @@ function waitMs(ms: number): Promise<void> {
|
|
|
428
462
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
429
463
|
}
|
|
430
464
|
|
|
465
|
+
function normaliseGameData(
|
|
466
|
+
gameData: Uint8Array<ArrayBufferLike> | ArrayBufferLike | string,
|
|
467
|
+
): Uint8Array<ArrayBufferLike> {
|
|
468
|
+
if (gameData instanceof Uint8Array) {
|
|
469
|
+
return gameData;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (typeof gameData !== 'string') {
|
|
473
|
+
return new Uint8Array(gameData);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const trimmed = gameData.trim();
|
|
477
|
+
const base64Match = trimmed.match(/^data:[^,]*;base64,(.*)$/s);
|
|
478
|
+
const payload = base64Match ? base64Match[1] : trimmed;
|
|
479
|
+
|
|
480
|
+
if (base64Match || looksLikeBase64(payload)) {
|
|
481
|
+
const binary = globalThis.atob(payload.replace(/\s/g, ''));
|
|
482
|
+
return binaryStringToBytes(binary);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return binaryStringToBytes(gameData);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function binaryStringToBytes(value: string): Uint8Array<ArrayBufferLike> {
|
|
489
|
+
const data = new Uint8Array(value.length);
|
|
490
|
+
for (let i = 0; i < value.length; i++) {
|
|
491
|
+
data[i] = value.charCodeAt(i) & 0xff;
|
|
492
|
+
}
|
|
493
|
+
return data;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function looksLikeBase64(value: string): boolean {
|
|
497
|
+
const compact = value.replace(/\s/g, '');
|
|
498
|
+
return compact.length > 0 && compact.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(compact);
|
|
499
|
+
}
|
|
500
|
+
|
|
431
501
|
function hasViceSnapshotMagic(data: Uint8Array<ArrayBufferLike>): boolean {
|
|
432
502
|
const magic = 'VICE Snapshot File\x1a';
|
|
433
503
|
if (data.length < magic.length) return false;
|
|
@@ -1,12 +1,53 @@
|
|
|
1
1
|
import type { FrameBuffer } from '../types';
|
|
2
2
|
import type { C64Emulator } from '../emulator/c64-emulator';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const loaderCss = `
|
|
5
|
+
.c64-loader {
|
|
6
|
+
position: relative;
|
|
7
|
+
width: 768px;
|
|
8
|
+
margin-top: 12px;
|
|
9
|
+
transition: opacity 0.6s ease, transform 0.6s ease;
|
|
10
|
+
}
|
|
11
|
+
.c64-loader.hidden {
|
|
12
|
+
opacity: 0;
|
|
13
|
+
transform: translateY(-6px);
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
}
|
|
16
|
+
.c64-loader-label {
|
|
17
|
+
font-family: monospace;
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
color: #7b71d5;
|
|
20
|
+
margin-bottom: 4px;
|
|
21
|
+
letter-spacing: 1px;
|
|
22
|
+
}
|
|
23
|
+
.c64-loader-track {
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 10px;
|
|
26
|
+
background: #222;
|
|
27
|
+
border: 1px solid #444;
|
|
28
|
+
border-radius: 2px;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
}
|
|
31
|
+
.c64-loader-fill {
|
|
32
|
+
height: 100%;
|
|
33
|
+
width: 0;
|
|
34
|
+
background: linear-gradient(90deg, #6c6cff 0%, #a8a8ff 50%, #6c6cff 100%);
|
|
35
|
+
background-size: 200% 100%;
|
|
36
|
+
border-radius: 2px;
|
|
37
|
+
transition: width 0.5s cubic-bezier(.22,.61,.36,1);
|
|
38
|
+
animation: c64-shimmer 1.5s linear infinite;
|
|
39
|
+
}
|
|
40
|
+
@keyframes c64-shimmer {
|
|
41
|
+
0% { background-position: 200% 0; }
|
|
42
|
+
100% { background-position: -200% 0; }
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
5
45
|
|
|
6
46
|
export default class CanvasRenderer {
|
|
7
47
|
private readonly canvas: HTMLCanvasElement;
|
|
8
48
|
private readonly ctx: CanvasRenderingContext2D;
|
|
9
49
|
private animationFrameId: number | null = null;
|
|
50
|
+
private attachedEmulator: C64Emulator | null = null;
|
|
10
51
|
|
|
11
52
|
// Loader elements (created lazily)
|
|
12
53
|
private loaderEl: HTMLElement | null = null;
|
|
@@ -116,14 +157,13 @@ export default class CanvasRenderer {
|
|
|
116
157
|
}
|
|
117
158
|
|
|
118
159
|
attachTo(emulator: C64Emulator): void {
|
|
160
|
+
this.detach();
|
|
161
|
+
this.attachedEmulator = emulator;
|
|
162
|
+
|
|
119
163
|
emulator.onFrame = (frame) => {
|
|
120
164
|
this.render(frame);
|
|
121
165
|
};
|
|
122
166
|
|
|
123
|
-
if (this.animationFrameId !== null) {
|
|
124
|
-
cancelAnimationFrame(this.animationFrameId);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
167
|
let lastTimestamp = 0;
|
|
128
168
|
|
|
129
169
|
const runFrame = (timestamp: number) => {
|
|
@@ -136,4 +176,16 @@ export default class CanvasRenderer {
|
|
|
136
176
|
|
|
137
177
|
this.animationFrameId = requestAnimationFrame(runFrame);
|
|
138
178
|
}
|
|
179
|
+
|
|
180
|
+
detach(): void {
|
|
181
|
+
if (this.animationFrameId !== null) {
|
|
182
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
183
|
+
this.animationFrameId = null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (this.attachedEmulator) {
|
|
187
|
+
this.attachedEmulator.onFrame = undefined;
|
|
188
|
+
this.attachedEmulator = null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
139
191
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as CanvasRenderer } from './canvas-renderer';
|
|
2
|
+
export { C64Player } from './c64-player';
|
|
3
|
+
export type { C64PlayerOptions, ProgressCallback } from './c64-player';
|
|
4
|
+
export { AudioEngine } from './audio-engine';
|
|
5
|
+
export type { AudioEngineOptions, AudioStateChangeCallback, SidBufferReader } from './audio-engine';
|
|
6
|
+
export { default as InputHandler } from './input-handler';
|
|
7
|
+
export type { C64Config, C64State, FrameBuffer, AudioBuffer, InputEvent, GameLoadOptions } from '../types';
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const css = `
|
|
2
|
+
.c64-help-btn,.c64-hamburger,.c64-unmute-btn{position:fixed;top:12px;width:36px;height:36px;border-radius:6px;border:2px solid #444;background:#111;color:#ddd;cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:1000}.c64-help-btn{right:12px;border-radius:50%;color:#7b71d5;font-family:monospace;font-size:18px;font-weight:bold}.c64-hamburger{left:12px;font-family:monospace}.c64-unmute-btn{left:56px;color:#f44;z-index:1010}.c64-unmute-btn.hidden{opacity:0;pointer-events:none}.c64-help-overlay,.c64-menu-overlay{position:fixed;inset:0;background:rgba(0,0,0,.7);display:flex;align-items:center;justify-content:center;z-index:1001;opacity:0;transition:opacity .25s ease;pointer-events:none}.c64-help-overlay.visible,.c64-menu-overlay.visible{opacity:1;pointer-events:auto}.c64-help-dialog,.c64-menu-panel{background:#1a1a2e;border:2px solid #555;border-radius:6px;padding:24px 32px;max-width:760px;width:90%;font-family:monospace;color:#ccc;position:relative}.c64-changelog-dialog{max-height:70vh;overflow:auto}.c64-help-dialog h2{margin:0 0 8px;font-size:16px;color:#7b71d5;letter-spacing:1px}.c64-help-dialog p{margin:0 0 16px;font-size:13px;line-height:1.5;color:#aaa}.c64-help-dialog a{color:#a8a8ff;text-decoration:none}.c64-help-controls,.c64-help-special{margin:0 0 12px;padding:0;list-style:none;font-size:13px}.c64-help-controls li,.c64-help-special li{display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid #2a2a3e}.c64-help-key{background:#2a2a3e;border:1px solid #444;border-radius:3px;padding:1px 8px;font-size:12px;color:#ddd}.c64-help-close{position:absolute;top:10px;right:14px;background:none;border:none;color:#888;font-size:20px;cursor:pointer}.c64-version{display:flex;justify-content:end;font-size:12px;color:#999;margin-top:36px}.c64-menu-overlay{align-items:flex-start;justify-content:flex-start;padding:48px 24px;background:rgba(0,0,0,.5);z-index:1002}.c64-menu-panel{min-width:320px;max-width:520px;padding:16px;background:#0f0f1a;border-color:#333}.c64-menu-header{display:flex;align-items:center;justify-content:space-between}.c64-settings-tabs,.c64-menu-actions,.c64-system-actions,.c64-radio-row,.c64-gamepad-list{display:flex;gap:8px;flex-wrap:wrap}.c64-settings-tab,.c64-btn,.c64-mute-btn{background:#222;border:1px solid #444;color:#ddd;padding:6px 10px;border-radius:4px;cursor:pointer}.c64-settings-tab.active,.c64-gamepad-btn.active{border-color:#7b71d5;color:#fff;background:#25253d}.c64-select{background:#171729;color:#ddd;border:1px solid #444;border-radius:4px;padding:4px 8px;font-family:monospace}.c64-form-row,.c64-audio-row,.c64-cart-preview{display:flex;align-items:center;gap:10px;margin-bottom:10px}.c64-section-label,.c64-audio-section label{display:block;margin:0 0 8px;font-size:13px;color:#aaa}.c64-section-hint,.c64-volume-label,.c64-cart-type{font-size:11px;color:#888}.c64-dragarea{border:2px dashed #2a2a3e;border-radius:6px;padding:12px;margin-top:12px;text-align:center;color:#aaa}.c64-dragarea.dragover{border-color:#7b71d5;color:#fff}.c64-file-input{display:none}.c64-volume-slider{flex:1}.c64-cart-filename{font-size:13px;color:#ccc;word-break:break-all}.c64-checkbox-row{display:inline-flex;gap:8px;align-items:center;color:#ccc;font-size:13px}
|
|
3
|
+
`;
|
|
4
|
+
|
|
5
|
+
export interface UIControllerOptions {
|
|
6
|
+
assetBaseUrl?: string;
|
|
7
|
+
appVersion?: string;
|
|
8
|
+
gitHash?: string;
|
|
9
|
+
changelogUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function resolveAssetUrl(baseUrl: string | undefined, path: string): string {
|
|
13
|
+
const base = baseUrl ?? '/';
|
|
14
|
+
return `${base.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`;
|
|
15
|
+
}
|
|
3
16
|
|
|
4
17
|
const CONTROLS = [
|
|
5
18
|
['Move Up', '↑'],
|
|
@@ -54,6 +67,7 @@ export default class UIController {
|
|
|
54
67
|
private settingsOverlay: HTMLElement | null = null;
|
|
55
68
|
private fileInput: HTMLInputElement | null = null;
|
|
56
69
|
private player: C64Player | null = null;
|
|
70
|
+
private readonly options: UIControllerOptions;
|
|
57
71
|
// Save previous overflow styles so we can restore them when exiting full/stretch
|
|
58
72
|
private savedHtmlOverflow: string | null = null;
|
|
59
73
|
private savedBodyOverflow: string | null = null;
|
|
@@ -74,6 +88,10 @@ export default class UIController {
|
|
|
74
88
|
this.renderGamepadButtons();
|
|
75
89
|
};
|
|
76
90
|
|
|
91
|
+
constructor(options: UIControllerOptions = {}) {
|
|
92
|
+
this.options = options;
|
|
93
|
+
}
|
|
94
|
+
|
|
77
95
|
init(player?: C64Player): void {
|
|
78
96
|
this.player = player ?? null;
|
|
79
97
|
this.syncConnectedGamepads();
|
|
@@ -159,6 +177,12 @@ export default class UIController {
|
|
|
159
177
|
document.head.appendChild(style);
|
|
160
178
|
}
|
|
161
179
|
|
|
180
|
+
private getVersionLabel(): string {
|
|
181
|
+
const version = this.options.appVersion ?? '0.0.0';
|
|
182
|
+
const gitHash = this.options.gitHash;
|
|
183
|
+
return `v${version}${gitHash ? ` (build: ${gitHash})` : ''}`;
|
|
184
|
+
}
|
|
185
|
+
|
|
162
186
|
private createButton(): void {
|
|
163
187
|
const btn = document.createElement('button');
|
|
164
188
|
btn.className = 'c64-help-btn';
|
|
@@ -193,11 +217,7 @@ export default class UIController {
|
|
|
193
217
|
<ul class="c64-help-controls">${controlItems}</ul>
|
|
194
218
|
<h2>SPECIAL KEYS</h2>
|
|
195
219
|
<ul class="c64-help-special">${specialItems}</ul>
|
|
196
|
-
<div class="c64-version">${
|
|
197
|
-
'v' +
|
|
198
|
-
(import.meta.env.VITE_APP_VERSION ?? '0.0.0') +
|
|
199
|
-
(import.meta.env.VITE_GIT_HASH ? ` (build: ${import.meta.env.VITE_GIT_HASH})` : '')
|
|
200
|
-
}</div>
|
|
220
|
+
<div class="c64-version">${this.getVersionLabel()}</div>
|
|
201
221
|
</div>
|
|
202
222
|
`;
|
|
203
223
|
|
|
@@ -234,8 +254,11 @@ export default class UIController {
|
|
|
234
254
|
private async loadAndShowChangelog(container: HTMLElement) {
|
|
235
255
|
container.classList.add('visible');
|
|
236
256
|
try {
|
|
237
|
-
const
|
|
238
|
-
|
|
257
|
+
const res = await fetch(this.options.changelogUrl ?? resolveAssetUrl(this.options.assetBaseUrl, 'CHANGELOG.md'), {
|
|
258
|
+
cache: 'no-store',
|
|
259
|
+
});
|
|
260
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
261
|
+
const raw = await res.text();
|
|
239
262
|
|
|
240
263
|
// Filter: keep headers, blank lines, and only feat:/fix: bullet lines
|
|
241
264
|
const filtered = raw
|
|
@@ -537,10 +560,7 @@ export default class UIController {
|
|
|
537
560
|
.map((part) => encodeURIComponent(part))
|
|
538
561
|
.join('/');
|
|
539
562
|
const normalizedPath = encodedPath.replace(/^\/+/, '');
|
|
540
|
-
const url =
|
|
541
|
-
/([^:]\/)\/+/,
|
|
542
|
-
'$1',
|
|
543
|
-
);
|
|
563
|
+
const url = resolveAssetUrl(this.options.assetBaseUrl, `tools/${normalizedPath}`);
|
|
544
564
|
return { name: filename, url, type } satisfies ToolItem;
|
|
545
565
|
})
|
|
546
566
|
.filter((v: ToolItem | null): v is ToolItem => !!v);
|
|
@@ -548,7 +568,7 @@ export default class UIController {
|
|
|
548
568
|
|
|
549
569
|
const loadToolsManifest = async () => {
|
|
550
570
|
try {
|
|
551
|
-
const url =
|
|
571
|
+
const url = resolveAssetUrl(this.options.assetBaseUrl, 'tools/tools.json');
|
|
552
572
|
const res = await fetch(url, { cache: 'no-store' });
|
|
553
573
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
554
574
|
const raw = await res.json();
|