@@ -79,6 +79,7 @@ public struct JSSending<T>: @unchecked Sendable {
79
79
}
80
80
}
81
81
82
+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
82
83
extension JSSending where T == JSObject {
83
84
private init ( _ object: JSObject , transferring: Bool ) {
84
85
self . init (
@@ -165,6 +166,7 @@ extension JSSending where T == JSObject {
165
166
}
166
167
}
167
168
169
+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
168
170
extension JSSending {
169
171
170
172
/// Receives a sent `JSObject` from a thread.
@@ -257,10 +259,12 @@ extension JSSending {
257
259
/// - isolation: The actor isolation context for this call, used in Swift concurrency.
258
260
/// - Returns: A tuple containing the received objects.
259
261
/// - Throws: `JSSendingError` if any sending operation fails, or `JSException` if a JavaScript error occurs.
262
+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
260
263
public static func receive< each U > (
261
264
_ sendings: repeat JSSending < each U > ,
262
265
isolation: isolated ( any Actor ) ? = #isolation, file: StaticString = #file, line: UInt = #line
263
266
) async throws -> ( repeat each U ) where T == ( repeat each U ) {
267
+ #if compiler(>=6.1) && _runtime(_multithreaded)
264
268
var sendingObjects : [ JavaScriptObjectRef ] = [ ]
265
269
var transferringObjects : [ JavaScriptObjectRef ] = [ ]
266
270
var sourceTid : Int32 ?
@@ -302,9 +306,13 @@ extension JSSending {
302
306
return sending. storage. construct ( result. object!)
303
307
}
304
308
return ( repeat extract( each sendings) )
309
+ #else
310
+ return ( repeat each sendings. receive ( ) )
311
+ #endif
305
312
}
306
313
}
307
314
315
+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
308
316
fileprivate final class _JSSendingContext : Sendable {
309
317
let continuation : CheckedContinuation < JavaScriptObjectRef , Error >
310
318
0 commit comments