File tree Expand file tree Collapse file tree 3 files changed +45
-18
lines changed
Expand file tree Collapse file tree 3 files changed +45
-18
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,13 @@ use deno_core::SourceMapGetter;
3434#[ derive( Clone ) ]
3535struct SourceMapStore ( Rc < RefCell < HashMap < String , Vec < u8 > > > > ) ;
3636
37- impl SourceMapGetter for SourceMapStore {
37+ struct TypescriptModuleLoader {
38+ source_maps : SourceMapStore ,
39+ }
40+
41+ impl SourceMapGetter for TypescriptModuleLoader {
3842 fn get_source_map ( & self , specifier : & str ) -> Option < Vec < u8 > > {
39- self . 0 . borrow ( ) . get ( specifier) . cloned ( )
43+ self . source_maps . 0 . borrow ( ) . get ( specifier) . cloned ( )
4044 }
4145
4246 fn get_source_line (
@@ -48,10 +52,6 @@ impl SourceMapGetter for SourceMapStore {
4852 }
4953}
5054
51- struct TypescriptModuleLoader {
52- source_maps : SourceMapStore ,
53- }
54-
5555impl ModuleLoader for TypescriptModuleLoader {
5656 fn resolve (
5757 & self ,
@@ -129,6 +129,18 @@ impl ModuleLoader for TypescriptModuleLoader {
129129
130130 ModuleLoadResponse :: Sync ( load ( source_maps, module_specifier) )
131131 }
132+
133+ fn new_get_source_map ( & self , specifier : & str ) -> Option < Vec < u8 > > {
134+ self . source_maps . 0 . borrow ( ) . get ( specifier) . cloned ( )
135+ }
136+
137+ fn new_get_source_line (
138+ & self ,
139+ _file_name : & str ,
140+ _line_number : usize ,
141+ ) -> Option < String > {
142+ None
143+ }
132144}
133145
134146fn main ( ) -> Result < ( ) , Error > {
Original file line number Diff line number Diff line change @@ -96,7 +96,22 @@ pub trait ModuleLoader {
9696 async { } . boxed_local ( )
9797 }
9898
99- fn get_source_map ( & self , _path : & str ) -> Option < Vec < u8 > > {
99+ fn get_source_map_from_mapping_url ( & self , _path : & str ) -> Option < Vec < u8 > > {
100+ None
101+ }
102+
103+ // TODO(bartlomieju): remove `new_` once `SourceMapGetter` trait is removed
104+ /// Returns the raw source map file.
105+ fn new_get_source_map ( & self , _file_name : & str ) -> Option < Vec < u8 > > {
106+ None
107+ }
108+
109+ // TODO(bartlomieju): remove `new_` once `SourceMapGetter` trait is removed
110+ fn new_get_source_line (
111+ & self ,
112+ _file_name : & str ,
113+ _line_number : usize ,
114+ ) -> Option < String > {
100115 None
101116 }
102117}
Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ use std::collections::HashMap;
1515use std:: rc:: Rc ;
1616use std:: str;
1717
18- pub trait SourceMapGetter {
19- /// Returns the raw source map file.
20- fn get_source_map ( & self , file_name : & str ) -> Option < Vec < u8 > > ;
21- fn get_source_line (
22- & self ,
23- file_name : & str ,
24- line_number : usize ,
25- ) -> Option < String > ;
26- }
18+ // pub trait SourceMapGetter {
19+ // /// Returns the raw source map file.
20+ // fn get_source_map(&self, file_name: &str) -> Option<Vec<u8>>;
21+ // fn get_source_line(
22+ // &self,
23+ // file_name: &str,
24+ // line_number: usize,
25+ // ) -> Option<String>;
26+ // }
2727
2828#[ derive( Debug ) ]
2929pub enum SourceMapApplication {
@@ -56,7 +56,7 @@ pub struct SourceMapper {
5656}
5757
5858impl SourceMapper {
59- pub fn new ( getter : Option < Rc < dyn SourceMapGetter > > ) -> Self {
59+ pub fn new ( getter : Option < Rc < dyn ModuleLoader > > ) -> Self {
6060 Self {
6161 maps : Default :: default ( ) ,
6262 source_lines : Default :: default ( ) ,
@@ -142,7 +142,7 @@ impl SourceMapper {
142142 let contents = module_map
143143 . loader
144144 . borrow ( )
145- . get_source_map ( & url. to_file_path ( ) . ok ( ) ?. to_str ( ) ?) ?;
145+ . get_source_map_from_mapping_url ( url. to_file_path ( ) . ok ( ) ?. to_str ( ) ?) ?;
146146 SourceMap :: from_slice ( & contents) . ok ( ) ?
147147 } ;
148148
You can’t perform that action at this time.
0 commit comments