1
1
import _CJavaScriptKit
2
+ #if hasFeature(Embedded) && os(WASI)
2
3
import _Concurrency
4
+ #endif
3
5
4
6
/// `JSClosureProtocol` wraps Swift closure objects for use in JavaScript. Conforming types
5
7
/// are responsible for managing the lifetime of the closure they wrap, but can delegate that
@@ -41,7 +43,7 @@ public class JSOneshotClosure: JSObject, JSClosureProtocol {
41
43
fatalError ( " JSOneshotClosure does not support dictionary literal initialization " )
42
44
}
43
45
44
- #if compiler(>=5.5)
46
+ #if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
45
47
@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
46
48
public static func async ( _ body: sending @escaping ( sending [ JSValue ] ) async throws -> JSValue ) -> JSOneshotClosure
47
49
{
@@ -133,7 +135,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
133
135
fatalError ( " JSClosure does not support dictionary literal initialization " )
134
136
}
135
137
136
- #if compiler(>=5.5) && !hasFeature(Embedded)
138
+ #if compiler(>=5.5) && ( !hasFeature(Embedded) || os(WASI) )
137
139
@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
138
140
public static func async ( _ body: @Sendable @escaping ( sending [ JSValue] ) async throws -> JSValue ) -> JSClosure {
139
141
JSClosure ( makeAsyncClosure ( body) )
@@ -149,7 +151,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
149
151
#endif
150
152
}
151
153
152
- #if compiler(>=5.5) && !hasFeature(Embedded)
154
+ #if compiler(>=5.5) && ( !hasFeature(Embedded) || os(WASI) )
153
155
@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
154
156
private func makeAsyncClosure(
155
157
_ body: sending @escaping ( sending [ JSValue ] ) async throws -> JSValue
0 commit comments