From 951aca87439e209c0b959941f45b0f1c10ca467a Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 25 Jul 2025 14:35:57 +0900 Subject: [PATCH] PackageToJS: Use non-class type for SwiftRuntime in instantiate.d.ts Use of class type for `SwiftRuntime` in `instantiate.d.ts` makes it difficult to union types of two `instantiate` variants. --- Plugins/PackageToJS/Templates/instantiate.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Plugins/PackageToJS/Templates/instantiate.d.ts b/Plugins/PackageToJS/Templates/instantiate.d.ts index e42e4f2f..86ea6e56 100644 --- a/Plugins/PackageToJS/Templates/instantiate.d.ts +++ b/Plugins/PackageToJS/Templates/instantiate.d.ts @@ -1,4 +1,6 @@ -import type { /* #if USE_SHARED_MEMORY */SwiftRuntimeThreadChannel, /* #endif */SwiftRuntime } from "./runtime.js"; +/* #if USE_SHARED_MEMORY */ +import type { SwiftRuntimeThreadChannel } from "./runtime.js"; +/* #endif */ /* #if HAS_BRIDGE */ export type { Imports, Exports } from "./bridge-js.js"; @@ -50,6 +52,12 @@ export interface WASI { extractFile?(path: string): Uint8Array | undefined } +export type SwiftRuntime = { + UnsafeEventLoopYield: { [Symbol.hasInstance]: (value: unknown) => boolean } + main(): void; + startThread(tid: number, startArg: number): void; +} + export type ModuleSource = WebAssembly.Module | ArrayBufferView | ArrayBuffer | Response | PromiseLike /**