@@ -84,21 +84,22 @@ public final class JSPromise: JSBridgedClass {
8484 }
8585 #endif
8686
87- #if !hasFeature(Embedded)
8887 /// Schedules the `success` closure to be invoked on successful completion of `self`.
8988 @discardableResult
90- public func then( success: @escaping ( JSValue ) -> ConvertibleToJSValue ) -> JSPromise {
89+ public func then( success: @escaping ( JSValue ) -> JSValue ) -> JSPromise {
9190 let closure = JSOneshotClosure {
9291 success ( $0 [ 0 ] ) . jsValue
9392 }
9493 return JSPromise ( unsafelyWrapping: jsObject. then!( closure) . object!)
9594 }
9695
97- #if compiler(>=5.5)
96+ #if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
9897 /// Schedules the `success` closure to be invoked on successful completion of `self`.
9998 @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
10099 @discardableResult
101- public func then( success: sending @escaping ( sending JSValue) async throws -> ConvertibleToJSValue ) -> JSPromise {
100+ public func then(
101+ success: sending @escaping ( sending JSValue) async throws -> JSValue
102+ ) -> JSPromise {
102103 let closure = JSOneshotClosure . async {
103104 try await success ( $0 [ 0 ] ) . jsValue
104105 }
@@ -109,8 +110,8 @@ public final class JSPromise: JSBridgedClass {
109110 /// Schedules the `success` closure to be invoked on successful completion of `self`.
110111 @discardableResult
111112 public func then(
112- success: @escaping ( sending JSValue) -> ConvertibleToJSValue ,
113- failure: @escaping ( sending JSValue) -> ConvertibleToJSValue
113+ success: @escaping ( sending JSValue) -> JSValue ,
114+ failure: @escaping ( sending JSValue) -> JSValue
114115 ) -> JSPromise {
115116 let successClosure = JSOneshotClosure {
116117 success ( $0 [ 0 ] ) . jsValue
@@ -121,13 +122,13 @@ public final class JSPromise: JSBridgedClass {
121122 return JSPromise ( unsafelyWrapping: jsObject. then!( successClosure, failureClosure) . object!)
122123 }
123124
124- #if compiler(>=5.5)
125+ #if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
125126 /// Schedules the `success` closure to be invoked on successful completion of `self`.
126127 @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
127128 @discardableResult
128129 public func then(
129- success: sending @escaping ( sending JSValue) async throws -> ConvertibleToJSValue ,
130- failure: sending @escaping ( sending JSValue) async throws -> ConvertibleToJSValue
130+ success: sending @escaping ( sending JSValue) async throws -> JSValue ,
131+ failure: sending @escaping ( sending JSValue) async throws -> JSValue
131132 ) -> JSPromise {
132133 let successClosure = JSOneshotClosure . async {
133134 try await success ( $0 [ 0 ] ) . jsValue
@@ -141,19 +142,24 @@ public final class JSPromise: JSBridgedClass {
141142
142143 /// Schedules the `failure` closure to be invoked on rejected completion of `self`.
143144 @discardableResult
144- public func `catch`( failure: @escaping ( sending JSValue) -> ConvertibleToJSValue ) -> JSPromise {
145+ public func `catch`(
146+ failure: @escaping ( sending JSValue) -> JSValue
147+ )
148+ -> JSPromise
149+ {
145150 let closure = JSOneshotClosure {
146151 failure ( $0 [ 0 ] ) . jsValue
147152 }
148153 return . init( unsafelyWrapping: jsObject. catch!( closure) . object!)
149154 }
150155
151- #if compiler(>=5.5)
156+ #if compiler(>=5.5) && (!hasFeature(Embedded) || os(WASI))
152157 /// Schedules the `failure` closure to be invoked on rejected completion of `self`.
153158 @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
154159 @discardableResult
155- public func `catch`( failure: sending @escaping ( sending JSValue) async throws -> ConvertibleToJSValue ) -> JSPromise
156- {
160+ public func `catch`(
161+ failure: sending @escaping ( sending JSValue) async throws -> JSValue
162+ ) -> JSPromise {
157163 let closure = JSOneshotClosure . async {
158164 try await failure ( $0 [ 0 ] ) . jsValue
159165 }
@@ -171,5 +177,4 @@ public final class JSPromise: JSBridgedClass {
171177 }
172178 return . init( unsafelyWrapping: jsObject. finally!( closure) . object!)
173179 }
174- #endif
175180}
0 commit comments