Skip to content

Commit 253ab0b

Browse files
Merge pull request #340 from swiftwasm/yt/expose-unsafe-yield-by-property
Expose UnsafeEventLoopYield by property
2 parents 935c5d9 + 0229735 commit 253ab0b

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

Plugins/PackageToJS/Templates/runtime.d.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
type ref = number;
2+
type pointer = number;
3+
14
declare class Memory {
25
readonly rawMemory: WebAssembly.Memory;
36
private readonly heap;
@@ -18,9 +21,6 @@ declare class Memory {
1821
writeFloat64: (ptr: pointer, value: number) => void;
1922
}
2023

21-
type ref = number;
22-
type pointer = number;
23-
2424
/**
2525
* A thread channel is a set of functions that are used to communicate between
2626
* the main thread and the worker thread. The main thread and the worker thread
@@ -189,6 +189,7 @@ declare class SwiftRuntime {
189189
private textEncoder;
190190
/** The thread ID of the current thread. */
191191
private tid;
192+
UnsafeEventLoopYield: typeof UnsafeEventLoopYield;
192193
constructor(options?: SwiftRuntimeOptions);
193194
setInstance(instance: WebAssembly.Instance): void;
194195
main(): void;
@@ -209,6 +210,8 @@ declare class SwiftRuntime {
209210
private postMessageToMainThread;
210211
private postMessageToWorkerThread;
211212
}
213+
declare class UnsafeEventLoopYield extends Error {
214+
}
212215

213216
export { SwiftRuntime };
214217
export type { SwiftRuntimeOptions, SwiftRuntimeThreadChannel };

Plugins/PackageToJS/Templates/runtime.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@
312312
this.version = 708;
313313
this.textDecoder = new TextDecoder("utf-8");
314314
this.textEncoder = new TextEncoder(); // Only support utf-8
315+
this.UnsafeEventLoopYield = UnsafeEventLoopYield;
315316
/** @deprecated Use `wasmImports` instead */
316317
this.importObjects = () => this.wasmImports;
317318
this._instance = null;

Plugins/PackageToJS/Templates/runtime.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ class SwiftRuntime {
306306
this.version = 708;
307307
this.textDecoder = new TextDecoder("utf-8");
308308
this.textEncoder = new TextEncoder(); // Only support utf-8
309+
this.UnsafeEventLoopYield = UnsafeEventLoopYield;
309310
/** @deprecated Use `wasmImports` instead */
310311
this.importObjects = () => this.wasmImports;
311312
this._instance = null;

Runtime/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export class SwiftRuntime {
3838
/** The thread ID of the current thread. */
3939
private tid: number | null;
4040

41+
UnsafeEventLoopYield = UnsafeEventLoopYield;
42+
4143
constructor(options?: SwiftRuntimeOptions) {
4244
this._instance = null;
4345
this._memory = null;
@@ -749,4 +751,4 @@ export class SwiftRuntime {
749751
/// This error is thrown to unwind the call stack of the Swift program and return the control to
750752
/// the JavaScript side. Otherwise, the `swift_task_asyncMainDrainQueue` ends up with `abort()`
751753
/// because the event loop expects `exit()` call before the end of the event loop.
752-
export class UnsafeEventLoopYield extends Error {}
754+
class UnsafeEventLoopYield extends Error {}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy