| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Compiles Dart Web Components from within a Chrome extension. | 6 * Compiles Dart Web Components from within a Chrome extension. |
| 7 * The Chrome extension logic exists outside of Dart as Dart does not support | 7 * The Chrome extension logic exists outside of Dart as Dart does not support |
| 8 * Chrome extension APIs at this time. | 8 * Chrome extension APIs at this time. |
| 9 */ | 9 */ |
| 10 library dwc_browser; | 10 library dwc_browser; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 * See extension/background.js. | 35 * See extension/background.js. |
| 36 */ | 36 */ |
| 37 void parse(js.Proxy sourcePagePort, String sourceUri) { | 37 void parse(js.Proxy sourcePagePort, String sourceUri) { |
| 38 // TODO(jacobr): we need to send error messages back to sourcePagePort. | 38 // TODO(jacobr): we need to send error messages back to sourcePagePort. |
| 39 js.retain(sourcePagePort); | 39 js.retain(sourcePagePort); |
| 40 print("Processing: $sourceUri"); | 40 print("Processing: $sourceUri"); |
| 41 Uri uri = new Uri.fromString(sourceUri); | 41 Uri uri = new Uri.fromString(sourceUri); |
| 42 fileSystem = new BrowserFileSystem(uri.scheme, sourcePagePort); | 42 fileSystem = new BrowserFileSystem(uri.scheme, sourcePagePort); |
| 43 // TODO(jacobr): provide a way to pass in options. | 43 // TODO(jacobr): provide a way to pass in options. |
| 44 var options = CompilerOptions.parse(['--no-colors', uri.path]); | 44 var options = CompilerOptions.parse(['--no-colors', uri.path]); |
| 45 messages = new Messages(options: options); | 45 messages = new Messages(options: options, shouldPrint: false); |
| 46 asyncTime('Compiled $sourceUri', () { | 46 asyncTime('Compiled $sourceUri', () { |
| 47 var compiler = new Compiler(fileSystem, options); | 47 var compiler = new Compiler(fileSystem, options); |
| 48 return compiler.run().chain((_) { | 48 return compiler.run().chain((_) { |
| 49 for (var file in compiler.output) { | 49 for (var file in compiler.output) { |
| 50 fileSystem.writeString(file.path, file.contents); | 50 fileSystem.writeString(file.path, file.contents); |
| 51 } | 51 } |
| 52 var ret = fileSystem.flush(); | 52 var ret = fileSystem.flush(); |
| 53 js.scoped(() { |
| 54 js.context.proxyMessages(sourcePagePort, |
| 55 js.array(messages.messages.map( |
| 56 (m) => [m.level.name, m.toString()]))); |
| 57 }); |
| 53 js.release(sourcePagePort); | 58 js.release(sourcePagePort); |
| 54 return ret; | 59 return ret; |
| 55 }); | 60 }); |
| 56 }, printTime: true); | 61 }, printTime: true); |
| 57 } | 62 } |
| OLD | NEW |