| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 @JS() | 6 @JS() |
| 7 library dev_compiler.web.main; | 7 library dev_compiler.web.main; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| 11 import 'package:args/command_runner.dart'; | 11 import 'package:args/command_runner.dart'; |
| 12 import 'package:js/js.dart'; | 12 import 'package:js/js.dart'; |
| 13 | 13 |
| 14 import 'web_command.dart'; | 14 import 'web_command.dart'; |
| 15 | 15 |
| 16 @JS(r'$setUpDartDevCompilerInBrowser') | 16 @JS(r'$setUpDartDevCompilerInBrowser') |
| 17 external set setUpCompilerInBrowser(Function function); | 17 external set setUpCompilerInBrowser(Function function); |
| 18 | 18 |
| 19 Future<Function> _setUpCompilerInBrowser; | 19 Future<Function> _setUpCompilerInBrowser; |
| 20 main() { | 20 main() { |
| 21 var args = ['compile', '--repl-compile']; | 21 var args = ['compile', '--repl-compile']; |
| 22 | 22 |
| 23 // Avoid race condition when users try to call $setUpDartDevCompilerInBrowser | 23 // Avoid race condition when users try to call $setUpDartDevCompilerInBrowser |
| 24 // before it is ready by installing the method immediately and making the body | 24 // before it is ready by installing the method immediately and making the body |
| 25 // of the method async. | 25 // of the method async. |
| 26 setUpCompilerInBrowser = allowInterop((String summaryRoot, String sdkUrl, | 26 setUpCompilerInBrowser = allowInterop((String summaryRoot, |
| 27 String sdkUrl, |
| 27 List<String> summaryUrls, | 28 List<String> summaryUrls, |
| 28 Function onCompileReady, | 29 Function onCompileReady, |
| 29 Function onError) async { | 30 Function onError) async { |
| 30 (await _setUpCompilerInBrowser)( | 31 (await _setUpCompilerInBrowser)( |
| 31 summaryRoot, sdkUrl, summaryUrls, onCompileReady, onError); | 32 summaryRoot, sdkUrl, summaryUrls, onCompileReady, onError); |
| 32 }); | 33 }); |
| 33 _runCommand(args); | 34 _runCommand(args); |
| 34 } | 35 } |
| 35 | 36 |
| 36 /// Runs a single compile command, and returns an exit code. | 37 /// Runs a single compile command, and returns an exit code. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 "any other information that may help us track it down. Thanks!"); | 77 "any other information that may help us track it down. Thanks!"); |
| 77 messageHandler(""); | 78 messageHandler(""); |
| 78 messageHandler(" dartdevc arguments: " + args.join(' ')); | 79 messageHandler(" dartdevc arguments: " + args.join(' ')); |
| 79 messageHandler(""); | 80 messageHandler(""); |
| 80 messageHandler("```"); | 81 messageHandler("```"); |
| 81 messageHandler(error); | 82 messageHandler(error); |
| 82 messageHandler(stackTrace); | 83 messageHandler(stackTrace); |
| 83 messageHandler("```"); | 84 messageHandler("```"); |
| 84 } | 85 } |
| 85 } | 86 } |
| OLD | NEW |