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 19 matching lines...) Expand all Loading... |
30 /** | 30 /** |
31 * Process the input file at [sourceUri] with the 'dwc' compiler. | 31 * Process the input file at [sourceUri] with the 'dwc' compiler. |
32 * [sourcePagePort] is a Chrome extension port used to communicate back to the | 32 * [sourcePagePort] is a Chrome extension port used to communicate back to the |
33 * source page that will consume these proxied urls. | 33 * source page that will consume these proxied urls. |
34 * See extension/background.js. | 34 * See extension/background.js. |
35 */ | 35 */ |
36 void parse(js.Proxy sourcePagePort, String sourceUri) { | 36 void parse(js.Proxy sourcePagePort, String sourceUri) { |
37 // TODO(jacobr): we need to send error messages back to sourcePagePort. | 37 // TODO(jacobr): we need to send error messages back to sourcePagePort. |
38 js.retain(sourcePagePort); | 38 js.retain(sourcePagePort); |
39 print("Processing: $sourceUri"); | 39 print("Processing: $sourceUri"); |
40 Uri uri = new Uri.fromString(sourceUri); | 40 Uri uri = Uri.parse(sourceUri); |
41 fileSystem = new BrowserFileSystem(uri.scheme, sourcePagePort); | 41 fileSystem = new BrowserFileSystem(uri.scheme, sourcePagePort); |
42 // TODO(jacobr): provide a way to pass in options. | 42 // TODO(jacobr): provide a way to pass in options. |
43 var options = CompilerOptions.parse(['--no-colors', uri.path]); | 43 var options = CompilerOptions.parse(['--no-colors', uri.path]); |
44 var messages = new Messages(options: options, shouldPrint: false); | 44 var messages = new Messages(options: options, shouldPrint: false); |
45 asyncTime('Compiled $sourceUri', () { | 45 asyncTime('Compiled $sourceUri', () { |
46 var compiler = new Compiler(fileSystem, options, messages); | 46 var compiler = new Compiler(fileSystem, options, messages); |
47 return compiler.run().then((_) { | 47 return compiler.run().then((_) { |
48 for (var file in compiler.output) { | 48 for (var file in compiler.output) { |
49 fileSystem.writeString(file.path, file.contents); | 49 fileSystem.writeString(file.path, file.contents); |
50 } | 50 } |
51 var ret = fileSystem.flush(); | 51 var ret = fileSystem.flush(); |
52 js.scoped(() { | 52 js.scoped(() { |
53 js.context.proxyMessages(sourcePagePort, | 53 js.context.proxyMessages(sourcePagePort, |
54 js.array(messages.messages.map( | 54 js.array(messages.messages.map( |
55 (m) => [m.level.name, m.toString()]).toList())); | 55 (m) => [m.level.name, m.toString()]).toList())); |
56 }); | 56 }); |
57 js.release(sourcePagePort); | 57 js.release(sourcePagePort); |
58 return ret; | 58 return ret; |
59 }); | 59 }); |
60 }, printTime: true); | 60 }, printTime: true); |
61 } | 61 } |
OLD | NEW |