| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dev_compiler.src.codegen.html_codegen; | 5 library dev_compiler.src.codegen.html_codegen; |
| 6 | 6 |
| 7 import 'package:html/dom.dart'; | 7 import 'package:html/dom.dart'; |
| 8 import 'package:html/parser.dart' show parseFragment; | 8 import 'package:html/parser.dart' show parseFragment; |
| 9 import 'package:logging/logging.dart' show Logger; | 9 import 'package:logging/logging.dart' show Logger; |
| 10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 /// A script tag that loads the .js code for a compiled library. | 97 /// A script tag that loads the .js code for a compiled library. |
| 98 Node _libraryInclude(String jsUrl) => | 98 Node _libraryInclude(String jsUrl) => |
| 99 parseFragment('<script src="$jsUrl"></script>\n'); | 99 parseFragment('<script src="$jsUrl"></script>\n'); |
| 100 | 100 |
| 101 /// A script tag that invokes the main function on the entry point library. | 101 /// A script tag that invokes the main function on the entry point library. |
| 102 Node _invokeMain(String mainLibraryName) { | 102 Node _invokeMain(String mainLibraryName) { |
| 103 var code = mainLibraryName == null | 103 var code = mainLibraryName == null |
| 104 ? 'console.error("dev_compiler error: main was not generated");' | 104 ? 'console.error("dev_compiler error: main was not generated");' |
| 105 // TODO(vsm): Can we simplify this? | 105 // TODO(vsm): Can we simplify this? |
| 106 // See: https://github.com/dart-lang/dev_compiler/issues/164 | 106 // See: https://github.com/dart-lang/dev_compiler/issues/164 |
| 107 : "dart.start('$mainLibraryName');"; | 107 : "loader.start('$mainLibraryName');"; |
| 108 return parseFragment('<script>$code</script>\n'); | 108 return parseFragment('<script>$code</script>\n'); |
| 109 } | 109 } |
| 110 | 110 |
| 111 /// Convert the outputPath to include the hash in it. This function is the | 111 /// Convert the outputPath to include the hash in it. This function is the |
| 112 /// reverse of what the server does to determine whether a request needs to have | 112 /// reverse of what the server does to determine whether a request needs to have |
| 113 /// cache headers added to it. | 113 /// cache headers added to it. |
| 114 _addHash(String outPath, String hash) { | 114 _addHash(String outPath, String hash) { |
| 115 // (the ____ prefix makes it look better in the web inspector) | 115 // (the ____ prefix makes it look better in the web inspector) |
| 116 return '$outPath?____cached=$hash'; | 116 return '$outPath?____cached=$hash'; |
| 117 } | 117 } |
| 118 | 118 |
| 119 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); | 119 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); |
| OLD | NEW |