11import _CJavaScriptKit
2+ #if hasFeature(Embedded) && os(WASI)
23import _Concurrency
4+ #endif
35
46/// `JSClosureProtocol` wraps Swift closure objects for use in JavaScript. Conforming types
57/// are responsible for managing the lifetime of the closure they wrap, but can delegate that
@@ -41,7 +43,7 @@ public class JSOneshotClosure: JSObject, JSClosureProtocol {
4143 fatalError ( " JSOneshotClosure does not support dictionary literal initialization " )
4244 }
4345
44- #if compiler(>=5.5)
46+ #if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
4547 @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
4648 public static func async ( _ body: sending @escaping ( sending [ JSValue ] ) async throws -> JSValue ) -> JSOneshotClosure
4749 {
@@ -133,7 +135,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
133135 fatalError ( " JSClosure does not support dictionary literal initialization " )
134136 }
135137
136- #if compiler(>=5.5) && !hasFeature(Embedded)
138+ #if compiler(>=5.5) && ( !hasFeature(Embedded) || os(WASI) )
137139 @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
138140 public static func async ( _ body: @Sendable @escaping ( sending [ JSValue] ) async throws -> JSValue ) -> JSClosure {
139141 JSClosure ( makeAsyncClosure ( body) )
@@ -149,7 +151,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
149151 #endif
150152}
151153
152- #if compiler(>=5.5) && !hasFeature(Embedded)
154+ #if compiler(>=5.5) && ( !hasFeature(Embedded) || os(WASI) )
153155@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
154156private func makeAsyncClosure(
155157 _ body: sending @escaping ( sending [ JSValue ] ) async throws -> JSValue
0 commit comments