@@ -226,6 +226,32 @@ extension JSSending {
226226 /// - Parameter isolation: The actor isolation context for this call, used in Swift concurrency.
227227 /// - Returns: The received object of type `T`.
228228 /// - Throws: `JSSendingError` if the sending operation fails, or `JSException` if a JavaScript error occurs.
229+ #if compiler(>=6.4)
230+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
231+ public func receive(
232+ isolation: isolated ( any Actor ) ? = #isolation,
233+ file: StaticString = #file,
234+ line: UInt = #line
235+ ) async throws ( JSException) -> T {
236+ #if _runtime(_multithreaded)
237+ let idInDestination = try await withCheckedThrowingContinuation { continuation in
238+ let context = _JSSendingContext ( continuation: continuation)
239+ let idInSource = self . storage. idInSource
240+ let transferring = self . storage. transferring ? [ idInSource] : [ ]
241+ swjs_request_sending_object (
242+ idInSource,
243+ transferring,
244+ Int32 ( transferring. count) ,
245+ self . storage. sourceTid,
246+ Unmanaged . passRetained ( context) . toOpaque ( )
247+ )
248+ }
249+ return storage. construct ( JSObject ( id: idInDestination) )
250+ #else
251+ return storage. construct ( storage. sourceObject)
252+ #endif
253+ }
254+ #else
229255 @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
230256 public func receive(
231257 isolation: isolated ( any Actor ) ? = #isolation,
@@ -250,6 +276,7 @@ extension JSSending {
250276 return storage. construct ( storage. sourceObject)
251277 #endif
252278 }
279+ #endif
253280
254281 // 6.0 and below can't compile the following without a compiler crash.
255282 #if compiler(>=6.1)
@@ -341,11 +368,19 @@ extension JSSending {
341368
342369@available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
343370private final class _JSSendingContext : Sendable {
371+ #if compiler(>=6.4)
372+ let continuation : CheckedContinuation < JavaScriptObjectRef , JSException >
373+
374+ init ( continuation: CheckedContinuation < JavaScriptObjectRef , JSException > ) {
375+ self . continuation = continuation
376+ }
377+ #else
344378 let continuation : CheckedContinuation < JavaScriptObjectRef , Error >
345379
346380 init ( continuation: CheckedContinuation < JavaScriptObjectRef , Error > ) {
347381 self . continuation = continuation
348382 }
383+ #endif
349384}
350385
351386/// Error type representing failures during JavaScript object sending operations.
0 commit comments