Skip to content

Commit 697f06b

Browse files
Use _Concurrency module only if non-Embedded or Embedded on WASI
1 parent 5b40703 commit 697f06b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Sources/JavaScriptKit/BasicObjects/JSPromise.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public final class JSPromise: JSBridgedClass {
9393
return JSPromise(unsafelyWrapping: jsObject.then!(closure).object!)
9494
}
9595

96-
#if compiler(>=5.5)
96+
#if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
9797
/// Schedules the `success` closure to be invoked on successful completion of `self`.
9898
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
9999
@discardableResult
@@ -122,7 +122,7 @@ public final class JSPromise: JSBridgedClass {
122122
return JSPromise(unsafelyWrapping: jsObject.then!(successClosure, failureClosure).object!)
123123
}
124124

125-
#if compiler(>=5.5)
125+
#if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
126126
/// Schedules the `success` closure to be invoked on successful completion of `self`.
127127
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
128128
@discardableResult
@@ -153,7 +153,7 @@ public final class JSPromise: JSBridgedClass {
153153
return .init(unsafelyWrapping: jsObject.catch!(closure).object!)
154154
}
155155

156-
#if compiler(>=5.5)
156+
#if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
157157
/// Schedules the `failure` closure to be invoked on rejected completion of `self`.
158158
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
159159
@discardableResult

Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import _CJavaScriptKit
2+
#if hasFeature(Embedded) && os(WASI)
23
import _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, *)
154156
private func makeAsyncClosure(
155157
_ body: sending @escaping (sending [JSValue]) async throws -> JSValue

0 commit comments

Comments
 (0)