@@ -11,6 +11,7 @@ extension JSObject {
11
11
///
12
12
/// ``JSObject`` itself is not `Sendable`, but ``Transferring`` is `Sendable` because it's
13
13
/// intended to be shared across threads.
14
+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
14
15
public struct Transferring : @unchecked Sendable {
15
16
fileprivate struct CriticalState {
16
17
var continuation : CheckedContinuation < JavaScriptObjectRef , Error > ?
@@ -70,6 +71,7 @@ extension JSObject {
70
71
/// let canvas = try await transferring.receive()
71
72
/// }
72
73
/// ```
74
+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
73
75
public func receive( isolation: isolated ( any Actor ) ? = #isolation, file: StaticString = #file, line: UInt = #line) async throws -> JSObject {
74
76
#if compiler(>=6.1) && _runtime(_multithreaded)
75
77
swjs_request_transferring_object (
@@ -99,6 +101,7 @@ extension JSObject {
99
101
///
100
102
/// - Parameter object: The ``JSObject`` to be transferred.
101
103
/// - Returns: A ``Transferring`` instance that can be shared across threads.
104
+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
102
105
public static func transfer( _ object: JSObject ) -> Transferring {
103
106
return Transferring ( sourceObject: object)
104
107
}
@@ -115,6 +118,7 @@ extension JSObject {
115
118
@_expose ( wasm, " swjs_receive_object " )
116
119
@_cdecl ( " swjs_receive_object " )
117
120
#endif
121
+ @available ( macOS 10 . 15 , iOS 13 . 0 , watchOS 6 . 0 , tvOS 13 . 0 , * )
118
122
func _swjs_receive_object( _ object: JavaScriptObjectRef , _ transferring: UnsafeRawPointer ) {
119
123
#if compiler(>=6.1) && _runtime(_multithreaded)
120
124
let storage = Unmanaged < JSObject . Transferring . Storage > . fromOpaque ( transferring) . takeRetainedValue ( )
0 commit comments