@@ -16,7 +16,7 @@ use wit_component::{
1616 metadata:: { decode, Bindgen } ,
1717 StringEncoding ,
1818} ;
19- use wit_parser:: { PackageId , Resolve , UnresolvedPackage } ;
19+ use wit_parser:: { PackageId , Resolve } ;
2020
2121wit_bindgen:: generate!( {
2222 world: "spidermonkey-embedding-splicer" ,
@@ -79,9 +79,9 @@ fn map_core_fn(cfn: &bindgen::CoreFn) -> CoreFn {
7979 }
8080}
8181
82- fn parse_wit ( path : & Path ) -> Result < ( Resolve , PackageId ) > {
82+ fn parse_wit ( path : & Path ) -> Result < ( Resolve , Vec < PackageId > ) > {
8383 let mut resolve = Resolve :: default ( ) ;
84- let id = if path. is_dir ( ) {
84+ let ids = if path. is_dir ( ) {
8585 resolve. push_dir ( & path) ?. 0
8686 } else {
8787 let contents =
@@ -90,10 +90,9 @@ fn parse_wit(path: &Path) -> Result<(Resolve, PackageId)> {
9090 Ok ( s) => s,
9191 Err ( _) => bail ! ( "input file is not valid utf-8" ) ,
9292 } ;
93- let pkg = UnresolvedPackage :: parse ( & path, text) ?;
94- resolve. push ( pkg) ?
93+ resolve. push_str ( & path, text) ?
9594 } ;
96- Ok ( ( resolve, id ) )
95+ Ok ( ( resolve, ids ) )
9796}
9897
9998impl Guest for SpidermonkeyEmbeddingSplicerComponent {
@@ -120,20 +119,19 @@ impl Guest for SpidermonkeyEmbeddingSplicerComponent {
120119 ) -> Result < SpliceResult , String > {
121120 let source_name = source_name. unwrap_or ( "source.js" . to_string ( ) ) ;
122121
123- let ( mut resolve, id ) = if let Some ( wit_source) = wit_source {
122+ let ( mut resolve, ids ) = if let Some ( wit_source) = wit_source {
124123 let mut resolve = Resolve :: default ( ) ;
125124 let path = PathBuf :: from ( "component.wit" ) ;
126- let pkg = UnresolvedPackage :: parse ( & path, & wit_source) . map_err ( |e| e. to_string ( ) ) ?;
127-
128- let id = resolve. push ( pkg) . map_err ( |e| e. to_string ( ) ) ?;
129-
130- ( resolve, id)
125+ let ids = resolve
126+ . push_str ( & path, & wit_source)
127+ . map_err ( |e| e. to_string ( ) ) ?;
128+ ( resolve, ids)
131129 } else {
132130 parse_wit ( & PathBuf :: from ( wit_path. unwrap ( ) ) ) . map_err ( |e| format ! ( "{:?}" , e) ) ?
133131 } ;
134132
135133 let world = resolve
136- . select_world ( id , world_name. as_deref ( ) )
134+ . select_world ( & ids , world_name. as_deref ( ) )
137135 . map_err ( |e| e. to_string ( ) ) ?;
138136
139137 let mut wasm_bytes = wit_component:: dummy_module ( & resolve, world) ;
0 commit comments