@@ -35,53 +35,16 @@ extension JSRemote where T == JSObject {
3535 public func withJSObject< R: Sendable , E: Error > (
3636 _ body: @Sendable @escaping ( JSObject) throws( E ) -> R
3737 ) async throws ( E) -> sending R {
38- #if _runtime(_multithreaded)
39- if storage. sourceTid == swjs_get_worker_thread_id_cached ( ) {
40- return try body ( storage. sourceObject)
41- }
42- return try await withCheckedThrowingContinuation { continuation in
43- let context = _JSRemoteContext (
44- sourceObject: storage. sourceObject,
45- body: body,
46- continuation: continuation
47- )
48- swjs_request_remote_jsobject_body (
49- storage. sourceTid,
50- Unmanaged . passRetained ( context) . toOpaque ( )
51- )
38+ do {
39+ return try await _withJSObjectAnyError ( body)
40+ } catch {
41+ throw error as! E
5242 }
53- #else
54- return try body ( storage. sourceObject)
55- #endif
56- }
57-
58- @available ( * , deprecated, message: " Use typed-throws withJSObject(_:) " )
59- private func _withJSObjectAnyError< R: Sendable > (
60- _ body: @Sendable @escaping ( JSObject) throws( any Error ) -> R
61- ) async throws ( any Error) -> sending R {
62- #if _runtime(_multithreaded)
63- if storage. sourceTid == swjs_get_worker_thread_id_cached ( ) {
64- return try body ( storage. sourceObject)
65- }
66- return try await withCheckedThrowingContinuation { continuation in
67- let context = _JSRemoteContext (
68- sourceObject: storage. sourceObject,
69- body: body,
70- continuation: continuation
71- )
72- swjs_request_remote_jsobject_body (
73- storage. sourceTid,
74- Unmanaged . passRetained ( context) . toOpaque ( )
75- )
76- }
77- #else
78- return try body ( storage. sourceObject)
79- #endif
8043 }
8144
8245 private func _withJSObjectAnyError< R: Sendable > (
8346 _ body: @Sendable @escaping ( JSObject) throws( any Error ) -> R
84- ) async throws ( any Error ) -> sending R {
47+ ) async throws -> sending R {
8548 #if _runtime(_multithreaded)
8649 if storage. sourceTid == swjs_get_worker_thread_id_cached ( ) {
8750 return try body ( storage. sourceObject)
0 commit comments