Skip to content

Commit

Permalink
fix: fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed Jan 28, 2025
1 parent b13df97 commit 1a9dced
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
29 changes: 19 additions & 10 deletions src/classes/emulator-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,22 @@ export class EmulatorOptions {
const biosFiles = Array.isArray(bios) ? bios : [bios]
this.bios = await Promise.all(
biosFiles.map((raw) =>
ResolvableFile.create({
raw,
signal: this.signal,
urlResolver: () => resolveBios(raw, this.nostalgistOptions),
}),
ResolvableFile.create(
typeof raw === 'string'
? { raw, signal: this.signal, urlResolver: () => resolveBios(raw, this.nostalgistOptions) }
: { raw, signal: this.signal },
),
),
)
}

private async updateCore() {
const { core, resolveCoreJs, resolveCoreWasm } = this.nostalgistOptions

if (typeof core === 'object' && 'js' in core && 'name' in core && 'wasm' in core) {
return core
}

const [coreResolvable, coreWasmResolvable] = await Promise.all(
[resolveCoreJs, resolveCoreWasm].map((resolver) =>
ResolvableFile.create({
Expand All @@ -201,11 +205,11 @@ export class EmulatorOptions {

this.rom = await Promise.all(
romFiles.map((romFile) =>
ResolvableFile.create({
raw: romFile,
signal: this.signal,
urlResolver: () => resolveRom(romFile, this.nostalgistOptions),
}),
ResolvableFile.create(
typeof romFile === 'string'
? { raw: romFile, signal: this.signal, urlResolver: () => resolveRom(romFile, this.nostalgistOptions) }
: { raw: romFile, signal: this.signal },
),
),
)
}
Expand All @@ -215,7 +219,12 @@ export class EmulatorOptions {
if (!shader) {
return []
}

const rawShaderFile = await resolveShader(shader, this.nostalgistOptions)
if (!rawShaderFile) {
return []
}

const rawShaderFiles = Array.isArray(rawShaderFile) ? rawShaderFile : [rawShaderFile]
this.shader = await Promise.all(
rawShaderFiles.map((rawShaderFile) => ResolvableFile.create({ raw: rawShaderFile, signal: this.signal })),
Expand Down
4 changes: 2 additions & 2 deletions src/classes/resolvable-file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { extractValidFileName, getResult, isNil } from '../libs/utils'
import { vendors } from '../libs/vendors'
import { extractValidFileName, getResult, isNil } from '../libs/utils.ts'
import { vendors } from '../libs/vendors.ts'

const { path } = vendors

Expand Down
8 changes: 4 additions & 4 deletions src/types/nostalgist-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export interface NostalgistCoreDict {
/** the name of core */
name: string

/** the url of core's js file */
js: string
/** the resolvable file of core's js file */
js: ResolvableFileInput

/** the url or array buffer of core's js file */
wasm: ArrayBuffer | string
/** the resolvable file of core's wasm file */
wasm: ResolvableFileInput
}

export type NostalgistResolveFileFunction = (
Expand Down

0 comments on commit 1a9dced

Please sign in to comment.