| OLD | NEW |
| 1 /// <reference path="../typings/chai/chai.d.ts"/> | 1 /// <reference path="../typings/chai/chai.d.ts"/> |
| 2 /// <reference path="../typings/mocha/mocha.d.ts"/> | 2 /// <reference path="../typings/mocha/mocha.d.ts"/> |
| 3 /// <reference path="../typings/node/node.d.ts"/> | 3 /// <reference path="../typings/node/node.d.ts"/> |
| 4 import chai = require('chai'); | 4 import chai = require('chai'); |
| 5 import fs = require('fs'); | 5 import fs = require('fs'); |
| 6 import main = require('../lib/main'); | 6 import main = require('../lib/main'); |
| 7 import ts = require('typescript'); | 7 import ts = require('typescript'); |
| 8 | 8 |
| 9 export type StringMap = { | 9 export type StringMap = { |
| 10 [k: string]: string | 10 [k: string]: string |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } else { | 76 } else { |
| 77 namesToContent = contents; | 77 namesToContent = contents; |
| 78 } | 78 } |
| 79 options.enforceUnderscoreConventions = true; | 79 options.enforceUnderscoreConventions = true; |
| 80 let transpiler = new main.Transpiler(options); | 80 let transpiler = new main.Transpiler(options); |
| 81 let program = parseFiles(namesToContent); | 81 let program = parseFiles(namesToContent); |
| 82 return transpiler.translateProgram(program); | 82 return transpiler.translateProgram(program); |
| 83 } | 83 } |
| 84 | 84 |
| 85 export function translateSource(contents: Input, options: main.TranspilerOptions
= {}): string { | 85 export function translateSource(contents: Input, options: main.TranspilerOptions
= {}): string { |
| 86 options.useHtml = true; | |
| 87 | |
| 88 let results = translateSources(contents, options); | 86 let results = translateSources(contents, options); |
| 89 // Return the main outcome, from 'main.ts'. | 87 // Return the main outcome, from 'main.ts'. |
| 90 let result = results[FAKE_MAIN]; | 88 let result = results[FAKE_MAIN]; |
| 91 // strip out the package:js import as it clutters the output. | 89 // strip out the package:js import as it clutters the output. |
| 92 result = result.replace(/import "package:js\/js.dart";\s+/g, ''); | 90 result = result.replace(/import "package:js\/js.dart";\s+/g, ''); |
| 93 result = result.replace(/^@JS\(\)\s+library [^;]+;\s+/g, ''); | 91 result = result.replace(/^@JS\("?[^)]*"?\)\s+library [^;]+;\s+/g, ''); |
| 94 return result.trim(); | 92 return result.trim(); |
| 95 } | 93 } |
| OLD | NEW |