Skip to content
Prev Previous commit
Use _Concurrency module only if non-Embedded or Embedded on WASI
  • Loading branch information
kateinoigakukun committed May 1, 2025
commit 697f06bdf820460867b577c66eef29c31b05b70d
6 changes: 3 additions & 3 deletions Sources/JavaScriptKit/BasicObjects/JSPromise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public final class JSPromise: JSBridgedClass {
return JSPromise(unsafelyWrapping: jsObject.then!(closure).object!)
}

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

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

#if compiler(>=5.5)
#if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
/// Schedules the `failure` closure to be invoked on rejected completion of `self`.
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
@discardableResult
Expand Down
8 changes: 5 additions & 3 deletions Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import _CJavaScriptKit
#if hasFeature(Embedded) && os(WASI)
import _Concurrency
#endif

/// `JSClosureProtocol` wraps Swift closure objects for use in JavaScript. Conforming types
/// are responsible for managing the lifetime of the closure they wrap, but can delegate that
Expand Down Expand Up @@ -41,7 +43,7 @@ public class JSOneshotClosure: JSObject, JSClosureProtocol {
fatalError("JSOneshotClosure does not support dictionary literal initialization")
}

#if compiler(>=5.5)
#if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public static func async(_ body: sending @escaping (sending [JSValue]) async throws -> JSValue) -> JSOneshotClosure
{
Expand Down Expand Up @@ -133,7 +135,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
fatalError("JSClosure does not support dictionary literal initialization")
}

#if compiler(>=5.5) && !hasFeature(Embedded)
#if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public static func async(_ body: @Sendable @escaping (sending [JSValue]) async throws -> JSValue) -> JSClosure {
JSClosure(makeAsyncClosure(body))
Expand All @@ -149,7 +151,7 @@ public class JSClosure: JSFunction, JSClosureProtocol {
#endif
}

#if compiler(>=5.5) && !hasFeature(Embedded)
#if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
private func makeAsyncClosure(
_ body: sending @escaping (sending [JSValue]) async throws -> JSValue
Expand Down