@@ -29,9 +29,12 @@ export class ScriptsSourceCode {
2929
3030 public readonly attrs : Record < string , string | undefined > ;
3131
32- private _separate = "" ;
33-
34- private _appendScriptLets : string | null = null ;
32+ private _appendScriptLets : {
33+ separate : string ;
34+ beforeSpaces : string ;
35+ render : string ;
36+ generics : string ;
37+ } | null = null ;
3538
3639 public separateIndexes : number [ ] = [ ] ;
3740
@@ -49,16 +52,28 @@ export class ScriptsSourceCode {
4952 if ( this . _appendScriptLets == null ) {
5053 return this . raw ;
5154 }
52- return this . trimmedRaw + this . _separate + this . _appendScriptLets ;
55+ return (
56+ this . trimmedRaw +
57+ this . _appendScriptLets . separate +
58+ this . _appendScriptLets . beforeSpaces +
59+ this . _appendScriptLets . render +
60+ this . _appendScriptLets . generics
61+ ) ;
5362 }
5463
55- public getCurrentVirtualCodeInfo ( ) : { script : string ; render : string } {
64+ public getCurrentVirtualCodeInfo ( ) : {
65+ script : string ;
66+ render : string ;
67+ generics : string ;
68+ } {
5669 if ( this . _appendScriptLets == null ) {
57- return { script : this . raw , render : "" } ;
70+ return { script : this . raw , render : "" , generics : "" } ;
5871 }
5972 return {
60- script : this . trimmedRaw + this . _separate ,
61- render : this . _appendScriptLets ,
73+ script : this . trimmedRaw + this . _appendScriptLets . separate ,
74+ render :
75+ this . _appendScriptLets . beforeSpaces + this . _appendScriptLets . render ,
76+ generics : this . _appendScriptLets . generics ,
6277 } ;
6378 }
6479
@@ -68,22 +83,30 @@ export class ScriptsSourceCode {
6883 }
6984 return (
7085 this . trimmedRaw . length +
71- this . _separate . length +
72- this . _appendScriptLets . length
86+ this . _appendScriptLets . separate . length +
87+ this . _appendScriptLets . beforeSpaces . length +
88+ this . _appendScriptLets . render . length +
89+ this . _appendScriptLets . generics . length
7390 ) ;
7491 }
7592
76- public addLet ( letCode : string ) : { start : number ; end : number } {
93+ public addLet (
94+ letCode : string ,
95+ kind : "generics" | "render" ,
96+ ) : { start : number ; end : number } {
7797 if ( this . _appendScriptLets == null ) {
78- this . _appendScriptLets = "" ;
79- const currentLength = this . getCurrentVirtualCodeLength ( ) ;
98+ const currentLength = this . trimmedRaw . length ;
8099 this . separateIndexes = [ currentLength , currentLength + 1 ] ;
81- this . _separate += "\n;" ;
82- const after = this . raw . slice ( this . getCurrentVirtualCodeLength ( ) ) ;
83- this . _appendScriptLets += after ;
100+ const after = this . raw . slice ( currentLength + 2 ) ;
101+ this . _appendScriptLets = {
102+ separate : "\n;" ,
103+ beforeSpaces : after ,
104+ render : "" ,
105+ generics : "" ,
106+ } ;
84107 }
85108 const start = this . getCurrentVirtualCodeLength ( ) ;
86- this . _appendScriptLets += letCode ;
109+ this . _appendScriptLets [ kind ] += letCode ;
87110 return {
88111 start,
89112 end : this . getCurrentVirtualCodeLength ( ) ,
0 commit comments