@@ -791,6 +791,25 @@ impl SourceMapIndex {
791791 pub fn new (
792792 file : Option < String > ,
793793 sections : Vec < SourceMapSection > ,
794+ ) -> SourceMapIndex {
795+ SourceMapIndex {
796+ file,
797+ sections,
798+ x_facebook_offsets : None ,
799+ x_metro_module_paths : None ,
800+ }
801+ }
802+
803+ /// Constructs a new sourcemap index from raw components including the
804+ /// facebook RAM bundle extensions.
805+ ///
806+ /// - `file`: an optional filename of the index
807+ /// - `sections`: a vector of source map index sections
808+ /// - `x_facebook_offsets`: a vector of facebook offsets
809+ /// - `x_metro_module_paths`: a vector of metro module paths
810+ pub fn new_ram_bundle_compatible (
811+ file : Option < String > ,
812+ sections : Vec < SourceMapSection > ,
794813 x_facebook_offsets : Option < Vec < Option < u32 > > > ,
795814 x_metro_module_paths : Option < Vec < String > > ,
796815 ) -> SourceMapIndex {
@@ -905,16 +924,19 @@ impl SourceMapIndex {
905924 self . flatten ( ) ?. rewrite ( options)
906925 }
907926
908- pub fn is_for_react_native ( & self ) -> bool {
927+ /// Returns `true` if this sourcemap is for a RAM bundle.
928+ pub fn is_for_ram_bundle ( & self ) -> bool {
909929 self . x_facebook_offsets . is_some ( ) && self . x_metro_module_paths . is_some ( )
910930 }
911931
912- pub fn x_facebook_offsets ( & self ) -> Option < & Vec < Option < u32 > > > {
913- self . x_facebook_offsets . as_ref ( )
932+ /// Returns embeded x-facebook-offset values.
933+ pub fn x_facebook_offsets ( & self ) -> Option < & [ Option < u32 > ] > {
934+ self . x_facebook_offsets . as_ref ( ) . map ( |x| & x[ ..] )
914935 }
915936
916- pub fn x_metro_module_paths ( & self ) -> Option < & Vec < String > > {
917- self . x_metro_module_paths . as_ref ( )
937+ /// Returns embedded metro module paths.
938+ pub fn x_metro_module_paths ( & self ) -> Option < & [ String ] > {
939+ self . x_metro_module_paths . as_ref ( ) . map ( |x| & x[ ..] )
918940 }
919941}
920942
0 commit comments