1
1
use bumpalo:: { Bump , BumpAllocSafe } ;
2
+ use std:: sync:: Once ;
2
3
use wasm_bindgen:: prelude:: * ;
3
4
4
5
pub mod js {
5
6
use wasm_bindgen:: prelude:: * ;
6
7
7
- #[ wasm_bindgen( module = "dodrio/change-list" ) ]
8
+ #[ wasm_bindgen]
8
9
extern "C" {
9
10
#[ derive( Clone , Debug ) ]
10
11
pub type ChangeList ;
11
12
12
13
#[ wasm_bindgen( constructor) ]
13
14
pub fn new ( container : & web_sys:: Node ) -> ChangeList ;
14
15
15
- #[ wasm_bindgen( method, js_name = addChangeListRange) ]
16
+ #[ wasm_bindgen( structural , method, js_name = addChangeListRange) ]
16
17
pub fn add_change_list_range ( this : & ChangeList , start : usize , len : usize ) ;
17
18
18
- #[ wasm_bindgen( method, js_name = applyChanges) ]
19
+ #[ wasm_bindgen( structural , method, js_name = applyChanges) ]
19
20
pub fn apply_changes ( this : & ChangeList , memory : JsValue ) ;
20
21
}
21
22
}
@@ -27,6 +28,17 @@ pub(crate) struct ChangeList {
27
28
28
29
impl ChangeList {
29
30
pub ( crate ) fn new ( container : & web_sys:: Node ) -> ChangeList {
31
+ // XXX: Because wasm-bindgen-test doesn't support third party JS
32
+ // dependencies, we can't use `wasm_bindgen(module = "...")` for our
33
+ // `ChangeList` JS import. Instead, this *should* be a local JS snippet,
34
+ // but that isn't implemented yet:
35
+ // https://github.com/rustwasm/rfcs/pull/6
36
+ static EVAL : Once = Once :: new ( ) ;
37
+ EVAL . call_once ( || {
38
+ js_sys:: eval ( include_str ! ( "../js/change-list.js" ) )
39
+ . expect ( "should eval change-list.js OK" ) ;
40
+ } ) ;
41
+
30
42
let bump = Bump :: new ( ) ;
31
43
let js = js:: ChangeList :: new ( container) ;
32
44
ChangeList { bump, js }
0 commit comments