@@ -37,125 +37,93 @@ pub trait RemoteDesktopApi {
37
37
#[ macro_export]
38
38
macro_rules! make_bridge {
39
39
( $api: ty) => {
40
- use wasm_bindgen:: prelude:: * ;
41
- use web_sys:: { js_sys, HtmlCanvasElement } ;
42
40
use $crate:: {
43
41
ClipboardData as _, ClipboardItem as _, DeviceEvent as _, InputTransaction as _, IronError as _,
44
- RemoteDesktopApi , Session as _, SessionBuilder as _, SessionTerminationInfo as _,
42
+ Session as _, SessionBuilder as _, SessionTerminationInfo as _,
45
43
} ;
46
44
47
- #[ wasm_bindgen]
48
- pub fn setup( log_level: & str ) {
49
- <$api as RemoteDesktopApi >:: pre_setup( ) ;
50
- $crate:: internal:: setup( log_level) ;
51
- <$api as RemoteDesktopApi >:: post_setup( ) ;
52
- }
53
-
54
- #[ wasm_bindgen]
55
- pub struct DeviceEvent ( <$api as RemoteDesktopApi >:: DeviceEvent ) ;
45
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
46
+ pub struct Session ( <$api as $crate:: RemoteDesktopApi >:: Session ) ;
56
47
57
- impl From <<$api as RemoteDesktopApi >:: DeviceEvent > for DeviceEvent {
58
- fn from( value: <$api as RemoteDesktopApi >:: DeviceEvent ) -> Self {
59
- Self ( value)
60
- }
61
- }
48
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
49
+ pub struct SessionBuilder ( <$api as $crate:: RemoteDesktopApi >:: SessionBuilder ) ;
62
50
63
- #[ wasm_bindgen]
64
- impl DeviceEvent {
65
- pub fn mouse_button_pressed( button: u8 ) -> Self {
66
- Self ( <<$api as RemoteDesktopApi >:: DeviceEvent >:: mouse_button_pressed(
67
- button,
68
- ) )
69
- }
70
-
71
- pub fn mouse_button_released( button: u8 ) -> Self {
72
- Self ( <<$api as RemoteDesktopApi >:: DeviceEvent >:: mouse_button_released(
73
- button,
74
- ) )
75
- }
51
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
52
+ pub struct SessionTerminationInfo ( <$api as $crate:: RemoteDesktopApi >:: SessionTerminationInfo ) ;
76
53
77
- pub fn mouse_move( x: u16 , y: u16 ) -> Self {
78
- Self ( <<$api as RemoteDesktopApi >:: DeviceEvent >:: mouse_move( x, y) )
79
- }
54
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
55
+ pub struct DeviceEvent ( <$api as $crate:: RemoteDesktopApi >:: DeviceEvent ) ;
80
56
81
- pub fn wheel_rotations( vertical: bool , rotation_units: i16 ) -> Self {
82
- Self ( <<$api as RemoteDesktopApi >:: DeviceEvent >:: wheel_rotations(
83
- vertical,
84
- rotation_units,
85
- ) )
86
- }
57
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
58
+ pub struct InputTransaction ( <$api as $crate:: RemoteDesktopApi >:: InputTransaction ) ;
87
59
88
- pub fn key_pressed( scancode: u16 ) -> Self {
89
- Self ( <<$api as RemoteDesktopApi >:: DeviceEvent >:: key_pressed( scancode) )
90
- }
60
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
61
+ pub struct ClipboardData ( <$api as $crate:: RemoteDesktopApi >:: ClipboardData ) ;
91
62
92
- pub fn key_released( scancode: u16 ) -> Self {
93
- Self ( <<$api as RemoteDesktopApi >:: DeviceEvent >:: key_released( scancode) )
94
- }
63
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
64
+ pub struct ClipboardItem ( <$api as $crate:: RemoteDesktopApi >:: ClipboardItem ) ;
95
65
96
- pub fn unicode_pressed( unicode: char ) -> Self {
97
- Self ( <<$api as RemoteDesktopApi >:: DeviceEvent >:: unicode_pressed(
98
- unicode,
99
- ) )
100
- }
66
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
67
+ pub struct IronError ( <$api as $crate:: RemoteDesktopApi >:: Error ) ;
101
68
102
- pub fn unicode_released( unicode: char ) -> Self {
103
- Self ( <<$api as RemoteDesktopApi >:: DeviceEvent >:: unicode_released(
104
- unicode,
105
- ) )
69
+ impl From <<$api as $crate:: RemoteDesktopApi >:: Session > for Session {
70
+ fn from( value: <$api as $crate:: RemoteDesktopApi >:: Session ) -> Self {
71
+ Self ( value)
106
72
}
107
73
}
108
74
109
- #[ wasm_bindgen]
110
- pub struct InputTransaction ( <$api as RemoteDesktopApi >:: InputTransaction ) ;
111
-
112
- impl From <<$api as RemoteDesktopApi >:: InputTransaction > for InputTransaction {
113
- fn from( value: <$api as RemoteDesktopApi >:: InputTransaction ) -> Self {
75
+ impl From <<$api as $crate:: RemoteDesktopApi >:: SessionBuilder > for SessionBuilder {
76
+ fn from( value: <$api as $crate:: RemoteDesktopApi >:: SessionBuilder ) -> Self {
114
77
Self ( value)
115
78
}
116
79
}
117
80
118
- #[ wasm_bindgen]
119
- impl InputTransaction {
120
- pub fn init( ) -> Self {
121
- Self ( <<$api as RemoteDesktopApi >:: InputTransaction >:: init( ) )
81
+ impl From <<$api as $crate:: RemoteDesktopApi >:: SessionTerminationInfo > for SessionTerminationInfo {
82
+ fn from( value: <$api as $crate:: RemoteDesktopApi >:: SessionTerminationInfo ) -> Self {
83
+ Self ( value)
122
84
}
85
+ }
123
86
124
- pub fn add_event( & mut self , event: DeviceEvent ) {
125
- self . 0 . add_event( event. 0 ) ;
87
+ impl From <<$api as $crate:: RemoteDesktopApi >:: DeviceEvent > for DeviceEvent {
88
+ fn from( value: <$api as $crate:: RemoteDesktopApi >:: DeviceEvent ) -> Self {
89
+ Self ( value)
126
90
}
127
91
}
128
92
129
- #[ wasm_bindgen]
130
- pub struct IronError ( <$api as RemoteDesktopApi >:: Error ) ;
131
-
132
- impl From <<$api as RemoteDesktopApi >:: Error > for IronError {
133
- fn from( value: <$api as RemoteDesktopApi >:: Error ) -> Self {
93
+ impl From <<$api as $crate:: RemoteDesktopApi >:: InputTransaction > for InputTransaction {
94
+ fn from( value: <$api as $crate:: RemoteDesktopApi >:: InputTransaction ) -> Self {
134
95
Self ( value)
135
96
}
136
97
}
137
98
138
- #[ wasm_bindgen]
139
- impl IronError {
140
- pub fn backtrace( & self ) -> String {
141
- self . 0 . backtrace( )
99
+ impl From <<$api as $crate:: RemoteDesktopApi >:: ClipboardData > for ClipboardData {
100
+ fn from( value: <$api as $crate:: RemoteDesktopApi >:: ClipboardData ) -> Self {
101
+ Self ( value)
142
102
}
103
+ }
143
104
144
- pub fn kind( & self ) -> $crate:: IronErrorKind {
145
- self . 0 . kind( )
105
+ impl From <<$api as $crate:: RemoteDesktopApi >:: ClipboardItem > for ClipboardItem {
106
+ fn from( value: <$api as $crate:: RemoteDesktopApi >:: ClipboardItem ) -> Self {
107
+ Self ( value)
146
108
}
147
109
}
148
110
149
- #[ wasm_bindgen]
150
- pub struct Session ( <$api as RemoteDesktopApi >:: Session ) ;
151
-
152
- impl From <<$api as RemoteDesktopApi >:: Session > for Session {
153
- fn from( value: <$api as RemoteDesktopApi >:: Session ) -> Self {
111
+ impl From <<$api as $crate:: RemoteDesktopApi >:: Error > for IronError {
112
+ fn from( value: <$api as $crate:: RemoteDesktopApi >:: Error ) -> Self {
154
113
Self ( value)
155
114
}
156
115
}
157
116
158
- #[ wasm_bindgen]
117
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
118
+ #[ doc( hidden) ]
119
+ pub fn setup( log_level: & str ) {
120
+ <$api as $crate:: RemoteDesktopApi >:: pre_setup( ) ;
121
+ $crate:: internal:: setup( log_level) ;
122
+ <$api as $crate:: RemoteDesktopApi >:: post_setup( ) ;
123
+ }
124
+
125
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
126
+ #[ doc( hidden) ]
159
127
impl Session {
160
128
pub async fn run( & self ) -> Result <SessionTerminationInfo , IronError > {
161
129
self . 0 . run( ) . await . map( SessionTerminationInfo ) . map_err( IronError )
@@ -209,24 +177,18 @@ macro_rules! make_bridge {
209
177
self . 0 . supports_unicode_keyboard_shortcuts( )
210
178
}
211
179
212
- pub fn extension_call( ext: $crate:: Extension ) -> Result <JsValue , IronError > {
213
- <<$api as RemoteDesktopApi >:: Session >:: extension_call( ext) . map_err( IronError )
180
+ pub fn extension_call(
181
+ ext: $crate:: Extension ,
182
+ ) -> Result <$crate:: internal:: wasm_bindgen:: JsValue , IronError > {
183
+ <<$api as $crate:: RemoteDesktopApi >:: Session >:: extension_call( ext) . map_err( IronError )
214
184
}
215
185
}
216
186
217
- #[ wasm_bindgen]
218
- pub struct SessionBuilder ( <$api as RemoteDesktopApi >:: SessionBuilder ) ;
219
-
220
- impl From <<$api as RemoteDesktopApi >:: SessionBuilder > for SessionBuilder {
221
- fn from( value: <$api as RemoteDesktopApi >:: SessionBuilder ) -> Self {
222
- Self ( value)
223
- }
224
- }
225
-
226
- #[ wasm_bindgen]
187
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
188
+ #[ doc( hidden) ]
227
189
impl SessionBuilder {
228
190
pub fn init( ) -> Self {
229
- Self ( <<$api as RemoteDesktopApi >:: SessionBuilder >:: init( ) )
191
+ Self ( <<$api as $crate :: RemoteDesktopApi >:: SessionBuilder >:: init( ) )
230
192
}
231
193
232
194
pub fn username( & self , username: String ) -> Self {
@@ -257,27 +219,36 @@ macro_rules! make_bridge {
257
219
Self ( self . 0 . desktop_size( desktop_size) )
258
220
}
259
221
260
- pub fn render_canvas( & self , canvas: HtmlCanvasElement ) -> Self {
222
+ pub fn render_canvas( & self , canvas: $crate :: internal :: web_sys :: HtmlCanvasElement ) -> Self {
261
223
Self ( self . 0 . render_canvas( canvas) )
262
224
}
263
225
264
- pub fn set_cursor_style_callback( & self , callback: js_sys:: Function ) -> Self {
226
+ pub fn set_cursor_style_callback( & self , callback: $crate :: internal :: web_sys :: js_sys:: Function ) -> Self {
265
227
Self ( self . 0 . set_cursor_style_callback( callback) )
266
228
}
267
229
268
- pub fn set_cursor_style_callback_context( & self , context: JsValue ) -> Self {
230
+ pub fn set_cursor_style_callback_context( & self , context: $crate :: internal :: wasm_bindgen :: JsValue ) -> Self {
269
231
Self ( self . 0 . set_cursor_style_callback_context( context) )
270
232
}
271
233
272
- pub fn remote_clipboard_changed_callback( & self , callback: js_sys:: Function ) -> Self {
234
+ pub fn remote_clipboard_changed_callback(
235
+ & self ,
236
+ callback: $crate:: internal:: web_sys:: js_sys:: Function ,
237
+ ) -> Self {
273
238
Self ( self . 0 . remote_clipboard_changed_callback( callback) )
274
239
}
275
240
276
- pub fn remote_received_format_list_callback( & self , callback: js_sys:: Function ) -> Self {
241
+ pub fn remote_received_format_list_callback(
242
+ & self ,
243
+ callback: $crate:: internal:: web_sys:: js_sys:: Function ,
244
+ ) -> Self {
277
245
Self ( self . 0 . remote_received_format_list_callback( callback) )
278
246
}
279
247
280
- pub fn force_clipboard_update_callback( & self , callback: js_sys:: Function ) -> Self {
248
+ pub fn force_clipboard_update_callback(
249
+ & self ,
250
+ callback: $crate:: internal:: web_sys:: js_sys:: Function ,
251
+ ) -> Self {
281
252
Self ( self . 0 . force_clipboard_update_callback( callback) )
282
253
}
283
254
@@ -290,35 +261,73 @@ macro_rules! make_bridge {
290
261
}
291
262
}
292
263
293
- #[ wasm_bindgen]
294
- pub struct SessionTerminationInfo ( <$api as RemoteDesktopApi >:: SessionTerminationInfo ) ;
295
-
296
- impl From <<$api as RemoteDesktopApi >:: SessionTerminationInfo > for SessionTerminationInfo {
297
- fn from( value: <$api as RemoteDesktopApi >:: SessionTerminationInfo ) -> Self {
298
- Self ( value)
299
- }
300
- }
301
-
302
- #[ wasm_bindgen]
264
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
265
+ #[ doc( hidden) ]
303
266
impl SessionTerminationInfo {
304
267
pub fn reason( & self ) -> String {
305
268
self . 0 . reason( )
306
269
}
307
270
}
308
271
309
- #[ wasm_bindgen]
310
- pub struct ClipboardData ( <$api as RemoteDesktopApi >:: ClipboardData ) ;
272
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
273
+ #[ doc( hidden) ]
274
+ impl DeviceEvent {
275
+ pub fn mouse_button_pressed( button: u8 ) -> Self {
276
+ Self ( <<$api as $crate:: RemoteDesktopApi >:: DeviceEvent >:: mouse_button_pressed( button) )
277
+ }
311
278
312
- impl From <<$api as RemoteDesktopApi >:: ClipboardData > for ClipboardData {
313
- fn from( value: <$api as RemoteDesktopApi >:: ClipboardData ) -> Self {
314
- Self ( value)
279
+ pub fn mouse_button_released( button: u8 ) -> Self {
280
+ Self ( <<$api as $crate:: RemoteDesktopApi >:: DeviceEvent >:: mouse_button_released( button) )
281
+ }
282
+
283
+ pub fn mouse_move( x: u16 , y: u16 ) -> Self {
284
+ Self ( <<$api as $crate:: RemoteDesktopApi >:: DeviceEvent >:: mouse_move(
285
+ x, y,
286
+ ) )
287
+ }
288
+
289
+ pub fn wheel_rotations( vertical: bool , rotation_units: i16 ) -> Self {
290
+ Self ( <<$api as $crate:: RemoteDesktopApi >:: DeviceEvent >:: wheel_rotations( vertical, rotation_units) )
291
+ }
292
+
293
+ pub fn key_pressed( scancode: u16 ) -> Self {
294
+ Self ( <<$api as $crate:: RemoteDesktopApi >:: DeviceEvent >:: key_pressed(
295
+ scancode,
296
+ ) )
297
+ }
298
+
299
+ pub fn key_released( scancode: u16 ) -> Self {
300
+ Self ( <<$api as $crate:: RemoteDesktopApi >:: DeviceEvent >:: key_released(
301
+ scancode,
302
+ ) )
303
+ }
304
+
305
+ pub fn unicode_pressed( unicode: char ) -> Self {
306
+ Self ( <<$api as $crate:: RemoteDesktopApi >:: DeviceEvent >:: unicode_pressed( unicode) )
307
+ }
308
+
309
+ pub fn unicode_released( unicode: char ) -> Self {
310
+ Self ( <<$api as $crate:: RemoteDesktopApi >:: DeviceEvent >:: unicode_released( unicode) )
315
311
}
316
312
}
317
313
318
- #[ wasm_bindgen]
314
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
315
+ #[ doc( hidden) ]
316
+ impl InputTransaction {
317
+ pub fn init( ) -> Self {
318
+ Self ( <<$api as $crate:: RemoteDesktopApi >:: InputTransaction >:: init( ) )
319
+ }
320
+
321
+ pub fn add_event( & mut self , event: DeviceEvent ) {
322
+ self . 0 . add_event( event. 0 ) ;
323
+ }
324
+ }
325
+
326
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
327
+ #[ doc( hidden) ]
319
328
impl ClipboardData {
320
329
pub fn init( ) -> Self {
321
- Self ( <<$api as RemoteDesktopApi >:: ClipboardData >:: init( ) )
330
+ Self ( <<$api as $crate :: RemoteDesktopApi >:: ClipboardData >:: init( ) )
322
331
}
323
332
324
333
pub fn add_text( & mut self , mime_type: & str , text: & str ) {
@@ -338,30 +347,40 @@ macro_rules! make_bridge {
338
347
}
339
348
}
340
349
341
- #[ wasm_bindgen]
342
- pub struct ClipboardItem ( <$api as RemoteDesktopApi >:: ClipboardItem ) ;
343
-
344
- impl From <<$api as RemoteDesktopApi >:: ClipboardItem > for ClipboardItem {
345
- fn from( value: <$api as RemoteDesktopApi >:: ClipboardItem ) -> Self {
346
- Self ( value)
347
- }
348
- }
349
-
350
- #[ wasm_bindgen]
350
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
351
+ #[ doc( hidden) ]
351
352
impl ClipboardItem {
352
353
pub fn mime_type( & self ) -> String {
353
354
self . 0 . mime_type( ) . to_owned( )
354
355
}
355
356
356
- pub fn value( & self ) -> JsValue {
357
+ pub fn value( & self ) -> $crate :: internal :: wasm_bindgen :: JsValue {
357
358
self . 0 . value( ) . into( )
358
359
}
359
360
}
361
+
362
+ #[ $crate:: internal:: wasm_bindgen:: prelude:: wasm_bindgen]
363
+ #[ doc( hidden) ]
364
+ impl IronError {
365
+ pub fn backtrace( & self ) -> String {
366
+ self . 0 . backtrace( )
367
+ }
368
+
369
+ pub fn kind( & self ) -> $crate:: IronErrorKind {
370
+ self . 0 . kind( )
371
+ }
372
+ }
360
373
} ;
361
374
}
362
375
363
376
#[ doc( hidden) ]
364
377
pub mod internal {
378
+ #[ doc( hidden) ]
379
+ pub use web_sys;
380
+
381
+ #[ doc( hidden) ]
382
+ pub use wasm_bindgen;
383
+
365
384
#[ doc( hidden) ]
366
385
pub fn setup ( log_level : & str ) {
367
386
// When the `console_error_panic_hook` feature is enabled, we can call the
0 commit comments