From e6b980d3c7d176c341d59dfd7178fb72d21a6c0f Mon Sep 17 00:00:00 2001 From: Arianrhod Sandlot Date: Wed, 29 Jan 2025 15:16:35 +0800 Subject: [PATCH] fix: fix types of resolvers in the parameter of launch --- docs/src/content/docs/apis/launch.md | 4 ++-- src/types/nostalgist-options.ts | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/docs/src/content/docs/apis/launch.md b/docs/src/content/docs/apis/launch.md index 349f64b..1cad271 100644 --- a/docs/src/content/docs/apis/launch.md +++ b/docs/src/content/docs/apis/launch.md @@ -392,12 +392,12 @@ const nostalgist = await Nostalgist.launch({ + #### `resolveRom` **type:** `Function` - A custom function used for resolving a ROM. The return value of this function should be a [resolvable file](/apis/resolvable-file) or an Array of [resolvable file](/apis/resolvable-file). + A custom function used for resolving a ROM. The return value of this function should be a [resolvable file](/apis/resolvable-file). + #### `resolveBios` **type:** `Function` - A custom function used for resolving a BIOS. The return value of this function should be a [resolvable file](/apis/resolvable-file) or an Array of [resolvable file](/apis/resolvable-file). + A custom function used for resolving a BIOS. The return value of this function should be a [resolvable file](/apis/resolvable-file). + #### `resolveShader` **type:** `Function` diff --git a/src/types/nostalgist-options.ts b/src/types/nostalgist-options.ts index 90c12a5..f583057 100644 --- a/src/types/nostalgist-options.ts +++ b/src/types/nostalgist-options.ts @@ -3,8 +3,6 @@ import type { ResolvableFileInput } from '../classes/resolvable-file' import type { RetroArchConfig } from './retroarch-config' import type { RetroArchEmscriptenModuleOptions } from './retroarch-emscripten' -type MaybePromise = Promise | T - type NostalgistOptionsFiles = ResolvableFileInput | ResolvableFileInput[] export interface NostalgistCoreDict { @@ -18,10 +16,7 @@ export interface NostalgistCoreDict { wasm: ResolvableFileInput } -export type NostalgistResolveFileFunction = ( - file: string, - options: NostalgistOptions, -) => MaybePromise +export type NostalgistResolveFileFunction = (file: string, options: NostalgistOptions) => ResolvableFileInput export interface NostalgistOptions { /** @@ -190,13 +185,13 @@ export interface NostalgistOptions { beforeLaunch?: (nostalgist: Nostalgist) => Promise | void onLaunch?: (nostalgist: Nostalgist) => Promise | void resolveBios: NostalgistResolveFileFunction - resolveCoreJs: (core: NostalgistOptions['core'], options: NostalgistOptions) => MaybePromise - resolveCoreWasm: (core: NostalgistOptions['core'], options: NostalgistOptions) => MaybePromise + resolveCoreJs: (core: NostalgistOptions['core'], options: NostalgistOptions) => ResolvableFileInput + resolveCoreWasm: (core: NostalgistOptions['core'], options: NostalgistOptions) => ResolvableFileInput resolveRom: NostalgistResolveFileFunction resolveShader: ( shader: NostalgistOptions['shader'], options: NostalgistOptions, - ) => MaybePromise + ) => ResolvableFileInput | ResolvableFileInput[] waitForInteraction?: (params: { done: () => void }) => void }