@@ -70,14 +70,14 @@ pub trait StreamChunks<'a> {
7070 fn stream_chunks (
7171 & ' a self ,
7272 options : & MapOptions ,
73- on_chunk : OnChunk ,
73+ on_chunk : OnChunk < ' _ , ' a > ,
7474 on_source : OnSource < ' _ , ' a > ,
7575 on_name : OnName < ' _ , ' a > ,
7676 ) -> GeneratedInfo ;
7777}
7878
7979/// [OnChunk] abstraction, see [webpack-sources onChunk](https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/helpers/streamChunks.js#L13).
80- pub type OnChunk < ' a > = & ' a mut dyn FnMut ( Option < & str > , Mapping ) ;
80+ pub type OnChunk < ' a , ' b > = & ' a mut dyn FnMut ( Option < & ' b str > , Mapping ) ;
8181
8282/// [OnSource] abstraction, see [webpack-sources onSource](https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/helpers/streamChunks.js#L13).
8383pub type OnSource < ' a , ' b > = & ' a mut dyn FnMut ( u32 , & str , Option < & ' b str > ) ;
@@ -90,7 +90,7 @@ pub fn stream_chunks_default<'a>(
9090 source : & ' a str ,
9191 source_map : Option < & ' a SourceMap > ,
9292 options : & MapOptions ,
93- on_chunk : OnChunk ,
93+ on_chunk : OnChunk < ' _ , ' a > ,
9494 on_source : OnSource < ' _ , ' a > ,
9595 on_name : OnName < ' _ , ' a > ,
9696) -> GeneratedInfo {
@@ -506,12 +506,12 @@ pub fn get_generated_source_info(source: &str) -> GeneratedInfo {
506506 }
507507}
508508
509- pub fn stream_chunks_of_raw_source (
510- source : & str ,
509+ pub fn stream_chunks_of_raw_source < ' a > (
510+ source : & ' a str ,
511511 options : & MapOptions ,
512- on_chunk : OnChunk ,
513- _on_source : OnSource ,
514- _on_name : OnName ,
512+ on_chunk : OnChunk < ' _ , ' a > ,
513+ _on_source : OnSource < ' _ , ' a > ,
514+ _on_name : OnName < ' _ , ' a > ,
515515) -> GeneratedInfo {
516516 if options. final_source {
517517 return get_generated_source_info ( source) ;
@@ -549,7 +549,7 @@ pub fn stream_chunks_of_raw_source(
549549pub fn stream_chunks_of_source_map < ' a > (
550550 source : & ' a str ,
551551 source_map : & ' a SourceMap ,
552- on_chunk : OnChunk ,
552+ on_chunk : OnChunk < ' _ , ' a > ,
553553 on_source : OnSource < ' _ , ' a > ,
554554 on_name : OnName < ' _ , ' a > ,
555555 options : & MapOptions ,
@@ -651,7 +651,7 @@ fn stream_chunks_of_source_map_final<'a>(
651651fn stream_chunks_of_source_map_full < ' a > (
652652 source : & ' a str ,
653653 source_map : & ' a SourceMap ,
654- on_chunk : OnChunk ,
654+ on_chunk : OnChunk < ' _ , ' a > ,
655655 on_source : OnSource < ' _ , ' a > ,
656656 on_name : OnName < ' _ , ' a > ,
657657) -> GeneratedInfo {
@@ -807,7 +807,7 @@ fn stream_chunks_of_source_map_lines_final<'a>(
807807fn stream_chunks_of_source_map_lines_full < ' a > (
808808 source : & ' a str ,
809809 source_map : & ' a SourceMap ,
810- on_chunk : OnChunk ,
810+ on_chunk : OnChunk < ' _ , ' a > ,
811811 on_source : OnSource < ' _ , ' a > ,
812812 _on_name : OnName ,
813813) -> GeneratedInfo {
@@ -895,19 +895,19 @@ fn stream_chunks_of_source_map_lines_full<'a>(
895895}
896896
897897#[ derive( Debug ) ]
898- struct SourceMapLineData {
898+ struct SourceMapLineData < ' a > {
899899 pub mappings_data : Vec < i64 > ,
900- pub chunks : Vec < SourceMapLineChunk > ,
900+ pub chunks : Vec < SourceMapLineChunk < ' a > > ,
901901}
902902
903903#[ derive( Debug ) ]
904- struct SourceMapLineChunk {
905- content : ArcStr ,
906- cached : OnceCell < WithIndices < ArcStr > > ,
904+ struct SourceMapLineChunk < ' a > {
905+ content : & ' a str ,
906+ cached : OnceCell < WithIndices < & ' a str > > ,
907907}
908908
909- impl SourceMapLineChunk {
910- pub fn new ( content : ArcStr ) -> Self {
909+ impl < ' a > SourceMapLineChunk < ' a > {
910+ pub fn new ( content : & ' a str ) -> Self {
911911 Self {
912912 content,
913913 cached : OnceCell :: new ( ) ,
@@ -917,7 +917,7 @@ impl SourceMapLineChunk {
917917 pub fn substring ( & self , start_index : usize , end_index : usize ) -> & str {
918918 let cached = self
919919 . cached
920- . get_or_init ( || WithIndices :: new ( self . content . clone ( ) ) ) ;
920+ . get_or_init ( || WithIndices :: new ( self . content ) ) ;
921921 cached. substring ( start_index, end_index)
922922 }
923923}
@@ -930,14 +930,14 @@ pub fn stream_chunks_of_combined_source_map<'a>(
930930 inner_source : Option < & ' a str > ,
931931 inner_source_map : & ' a SourceMap ,
932932 remove_inner_source : bool ,
933- on_chunk : OnChunk ,
933+ on_chunk : OnChunk < ' _ , ' a > ,
934934 on_source : OnSource < ' _ , ' a > ,
935935 on_name : OnName < ' _ , ' a > ,
936936 options : & MapOptions ,
937937) -> GeneratedInfo {
938938 let on_source = RefCell :: new ( on_source) ;
939- let inner_source: RefCell < Option < & ' a str > > = RefCell :: new ( inner_source) ;
940- let source_mapping: RefCell < HashMap < ArcStr , u32 > > =
939+ let inner_source: RefCell < Option < & str > > = RefCell :: new ( inner_source) ;
940+ let source_mapping: RefCell < HashMap < String , u32 > > =
941941 RefCell :: new ( HashMap :: default ( ) ) ;
942942 let mut name_mapping: HashMap < & str , u32 > = HashMap :: default ( ) ;
943943 let source_index_mapping: RefCell < HashMap < i64 , i64 > > =
@@ -950,9 +950,9 @@ pub fn stream_chunks_of_combined_source_map<'a>(
950950 let inner_source_index_mapping: RefCell < HashMap < i64 , i64 > > =
951951 RefCell :: new ( HashMap :: default ( ) ) ;
952952 let inner_source_index_value_mapping: RefCell <
953- HashMap < i64 , ( ArcStr , Option < & ' a str > ) > ,
953+ HashMap < i64 , ( String , Option < & str > ) > ,
954954 > = RefCell :: new ( HashMap :: default ( ) ) ;
955- let inner_source_contents: RefCell < HashMap < i64 , Option < ArcStr > > > =
955+ let inner_source_contents: RefCell < HashMap < i64 , Option < & str > > > =
956956 RefCell :: new ( HashMap :: default ( ) ) ;
957957 let inner_source_content_lines: InnerSourceContentLine =
958958 RefCell :: new ( HashMap :: default ( ) ) ;
@@ -1083,10 +1083,10 @@ pub fn stream_chunks_of_combined_source_map<'a>(
10831083 . cloned ( )
10841084 . unwrap_or ( ( "" . into ( ) , None ) ) ;
10851085 let mut source_mapping = source_mapping. borrow_mut ( ) ;
1086- let mut global_index = source_mapping. get ( & source) . copied ( ) ;
1086+ let mut global_index = source_mapping. get ( & source. to_string ( ) ) . copied ( ) ;
10871087 if global_index. is_none ( ) {
10881088 let len = source_mapping. len ( ) as u32 ;
1089- source_mapping. insert ( source. clone ( ) , len) ;
1089+ source_mapping. insert ( source. to_string ( ) , len) ;
10901090 on_source. borrow_mut ( ) ( len, & source, source_content) ;
10911091 global_index = Some ( len) ;
10921092 }
@@ -1363,7 +1363,7 @@ pub fn stream_chunks_of_combined_source_map<'a>(
13631363 inner_source_index_mapping. borrow_mut ( ) . insert ( i, -2 ) ;
13641364 inner_source_index_value_mapping
13651365 . borrow_mut ( )
1366- . insert ( i, ( source. into ( ) , source_content. map ( Into :: into ) ) ) ;
1366+ . insert ( i, ( source. to_string ( ) , source_content) ) ;
13671367 } ,
13681368 & mut |i, name| {
13691369 let i = i as i64 ;
@@ -1380,7 +1380,7 @@ pub fn stream_chunks_of_combined_source_map<'a>(
13801380 let mut global_index = source_mapping. get ( source) . copied ( ) ;
13811381 if global_index. is_none ( ) {
13821382 let len = source_mapping. len ( ) as u32 ;
1383- source_mapping. insert ( source. into ( ) , len) ;
1383+ source_mapping. insert ( source. to_string ( ) , len) ;
13841384 on_source. borrow_mut ( ) ( len, source, source_content) ;
13851385 global_index = Some ( len) ;
13861386 }
@@ -1401,7 +1401,7 @@ pub fn stream_chunks_of_combined_source_map<'a>(
14011401pub fn stream_and_get_source_and_map < ' a , S : StreamChunks < ' a > > (
14021402 input_source : & ' a S ,
14031403 options : & MapOptions ,
1404- on_chunk : OnChunk ,
1404+ on_chunk : OnChunk < ' _ , ' a > ,
14051405 on_source : OnSource < ' _ , ' a > ,
14061406 on_name : OnName < ' _ , ' a > ,
14071407) -> ( GeneratedInfo , Option < SourceMap > ) {
0 commit comments