@@ -24,15 +24,15 @@ function logErr(message: any, ...rest: any[]): void {
2424 util . log ( util . colors . red ( '[monaco.d.ts]' ) , message , ...rest ) ;
2525}
2626
27- function moduleIdToPath ( out :string , moduleId :string ) : string {
27+ function moduleIdToPath ( out : string , moduleId : string ) : string {
2828 if ( / \. d \. t s / . test ( moduleId ) ) {
2929 return path . join ( SRC , moduleId ) ;
3030 }
3131 return path . join ( OUT_ROOT , out , moduleId ) + '.d.ts' ;
3232}
3333
34- let SOURCE_FILE_MAP : { [ moduleId :string ] :ts . SourceFile ; } = { } ;
35- function getSourceFile ( out :string , inputFiles : { [ file : string ] : string ; } , moduleId :string ) : ts . SourceFile {
34+ let SOURCE_FILE_MAP : { [ moduleId : string ] : ts . SourceFile ; } = { } ;
35+ function getSourceFile ( out : string , inputFiles : { [ file : string ] : string ; } , moduleId : string ) : ts . SourceFile {
3636 if ( ! SOURCE_FILE_MAP [ moduleId ] ) {
3737 let filePath = path . normalize ( moduleIdToPath ( out , moduleId ) ) ;
3838
@@ -53,7 +53,7 @@ function getSourceFile(out:string, inputFiles: { [file: string]: string; }, modu
5353type TSTopLevelDeclaration = ts . InterfaceDeclaration | ts . EnumDeclaration | ts . ClassDeclaration | ts . TypeAliasDeclaration | ts . FunctionDeclaration | ts . ModuleDeclaration ;
5454type TSTopLevelDeclare = TSTopLevelDeclaration | ts . VariableStatement ;
5555
56- function isDeclaration ( a :TSTopLevelDeclare ) : a is TSTopLevelDeclaration {
56+ function isDeclaration ( a : TSTopLevelDeclare ) : a is TSTopLevelDeclaration {
5757 return (
5858 a . kind === ts . SyntaxKind . InterfaceDeclaration
5959 || a . kind === ts . SyntaxKind . EnumDeclaration
@@ -64,7 +64,7 @@ function isDeclaration(a:TSTopLevelDeclare): a is TSTopLevelDeclaration {
6464 ) ;
6565}
6666
67- function visitTopLevelDeclarations ( sourceFile :ts . SourceFile , visitor :( node :TSTopLevelDeclare ) => boolean ) : void {
67+ function visitTopLevelDeclarations ( sourceFile : ts . SourceFile , visitor : ( node : TSTopLevelDeclare ) => boolean ) : void {
6868 let stop = false ;
6969
7070 let visit = ( node : ts . Node ) : void => {
@@ -100,8 +100,8 @@ function visitTopLevelDeclarations(sourceFile:ts.SourceFile, visitor:(node:TSTop
100100}
101101
102102
103- function getAllTopLevelDeclarations ( sourceFile :ts . SourceFile ) : TSTopLevelDeclare [ ] {
104- let all :TSTopLevelDeclare [ ] = [ ] ;
103+ function getAllTopLevelDeclarations ( sourceFile : ts . SourceFile ) : TSTopLevelDeclare [ ] {
104+ let all : TSTopLevelDeclare [ ] = [ ] ;
105105 visitTopLevelDeclarations ( sourceFile , ( node ) => {
106106 if ( node . kind === ts . SyntaxKind . InterfaceDeclaration || node . kind === ts . SyntaxKind . ClassDeclaration || node . kind === ts . SyntaxKind . ModuleDeclaration ) {
107107 let interfaceDeclaration = < ts . InterfaceDeclaration > node ;
@@ -128,8 +128,8 @@ function getAllTopLevelDeclarations(sourceFile:ts.SourceFile): TSTopLevelDeclare
128128}
129129
130130
131- function getTopLevelDeclaration ( sourceFile :ts . SourceFile , typeName :string ) : TSTopLevelDeclare {
132- let result :TSTopLevelDeclare = null ;
131+ function getTopLevelDeclaration ( sourceFile : ts . SourceFile , typeName : string ) : TSTopLevelDeclare {
132+ let result : TSTopLevelDeclare = null ;
133133 visitTopLevelDeclarations ( sourceFile , ( node ) => {
134134 if ( isDeclaration ( node ) ) {
135135 if ( node . name . text === typeName ) {
@@ -149,12 +149,12 @@ function getTopLevelDeclaration(sourceFile:ts.SourceFile, typeName:string): TSTo
149149}
150150
151151
152- function getNodeText ( sourceFile :ts . SourceFile , node :{ pos :number ; end :number ; } ) : string {
152+ function getNodeText ( sourceFile : ts . SourceFile , node : { pos : number ; end : number ; } ) : string {
153153 return sourceFile . getFullText ( ) . substring ( node . pos , node . end ) ;
154154}
155155
156156
157- function getMassagedTopLevelDeclarationText ( sourceFile :ts . SourceFile , declaration : TSTopLevelDeclare ) : string {
157+ function getMassagedTopLevelDeclarationText ( sourceFile : ts . SourceFile , declaration : TSTopLevelDeclare ) : string {
158158 let result = getNodeText ( sourceFile , declaration ) ;
159159 // if (result.indexOf('MonacoWorker') >= 0) {
160160 // console.log('here!');
@@ -163,7 +163,7 @@ function getMassagedTopLevelDeclarationText(sourceFile:ts.SourceFile, declaratio
163163 if ( declaration . kind === ts . SyntaxKind . InterfaceDeclaration || declaration . kind === ts . SyntaxKind . ClassDeclaration ) {
164164 let interfaceDeclaration = < ts . InterfaceDeclaration | ts . ClassDeclaration > declaration ;
165165
166- let members :ts . NodeArray < ts . Node > = interfaceDeclaration . members ;
166+ let members : ts . NodeArray < ts . Node > = interfaceDeclaration . members ;
167167 members . forEach ( ( member ) => {
168168 try {
169169 let memberText = getNodeText ( sourceFile , member ) ;
@@ -182,7 +182,7 @@ function getMassagedTopLevelDeclarationText(sourceFile:ts.SourceFile, declaratio
182182 return result ;
183183}
184184
185- function format ( text :string ) : string {
185+ function format ( text : string ) : string {
186186
187187 // Parse the source text
188188 let sourceFile = ts . createSourceFile ( 'file.ts' , text , ts . ScriptTarget . Latest , /*setParentPointers*/ true ) ;
@@ -214,10 +214,10 @@ function format(text:string): string {
214214 }
215215}
216216
217- function createReplacer ( data :string ) : ( str :string ) => string {
217+ function createReplacer ( data : string ) : ( str : string ) => string {
218218 data = data || '' ;
219219 let rawDirectives = data . split ( ';' ) ;
220- let directives : [ RegExp , string ] [ ] = [ ] ;
220+ let directives : [ RegExp , string ] [ ] = [ ] ;
221221 rawDirectives . forEach ( ( rawDirective ) => {
222222 if ( rawDirective . length === 0 ) {
223223 return ;
@@ -231,18 +231,19 @@ function createReplacer(data:string): (str:string)=>string {
231231 directives . push ( [ new RegExp ( findStr , 'g' ) , replaceStr ] ) ;
232232 } ) ;
233233
234- return ( str :string ) => {
234+ return ( str : string ) => {
235235 for ( let i = 0 ; i < directives . length ; i ++ ) {
236236 str = str . replace ( directives [ i ] [ 0 ] , directives [ i ] [ 1 ] ) ;
237237 }
238238 return str ;
239239 } ;
240240}
241241
242- function generateDeclarationFile ( out : string , inputFiles : { [ file : string ] : string ; } , recipe :string ) : string {
243- let lines = recipe . split ( / \r \n | \n | \r / ) ;
244- let result = [ ] ;
242+ function generateDeclarationFile ( out : string , inputFiles : { [ file : string ] : string ; } , recipe : string ) : string {
243+ const endl = / \r \n / . test ( recipe ) ? '\r\n' : '\n' ;
245244
245+ let lines = recipe . split ( endl ) ;
246+ let result = [ ] ;
246247
247248 lines . forEach ( line => {
248249
@@ -285,7 +286,7 @@ function generateDeclarationFile(out: string, inputFiles: { [file: string]: stri
285286 let replacer = createReplacer ( m2 [ 2 ] ) ;
286287
287288 let typeNames = m2 [ 3 ] . split ( / , / ) ;
288- let typesToExcludeMap : { [ typeName :string ] :boolean ; } = { } ;
289+ let typesToExcludeMap : { [ typeName : string ] : boolean ; } = { } ;
289290 let typesToExcludeArr : string [ ] = [ ] ;
290291 typeNames . forEach ( ( typeName ) => {
291292 typeName = typeName . trim ( ) ;
@@ -318,18 +319,17 @@ function generateDeclarationFile(out: string, inputFiles: { [file: string]: stri
318319 result . push ( line ) ;
319320 } ) ;
320321
321- let resultTxt = result . join ( '\n' ) ;
322+ let resultTxt = result . join ( endl ) ;
322323 resultTxt = resultTxt . replace ( / \b U R I \b / g, 'Uri' ) ;
323324 resultTxt = resultTxt . replace ( / \b E v e n t < / g, 'IEvent<' ) ;
324325 resultTxt = resultTxt . replace ( / \b T P r o m i s e < / g, 'Promise<' ) ;
325326
326327 resultTxt = format ( resultTxt ) ;
327328
328- resultTxt = resultTxt . replace ( / \r \n / g, '\n' ) ;
329329 return resultTxt ;
330330}
331331
332- export function getFilesToWatch ( out :string ) : string [ ] {
332+ export function getFilesToWatch ( out : string ) : string [ ] {
333333 let recipe = fs . readFileSync ( RECIPE_PATH ) . toString ( ) ;
334334 let lines = recipe . split ( / \r \n | \n | \r / ) ;
335335 let result = [ ] ;
0 commit comments