| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 parseFragment('<script src="$jsUrl"></script>\n'); | 83 parseFragment('<script src="$jsUrl"></script>\n'); |
| 84 | 84 |
| 85 /// A tag that loads the .css code. | 85 /// A tag that loads the .css code. |
| 86 Node _cssInclude(String cssUrl) => | 86 Node _cssInclude(String cssUrl) => |
| 87 parseFragment('<link rel="stylesheet" href="$cssUrl">\n'); | 87 parseFragment('<link rel="stylesheet" href="$cssUrl">\n'); |
| 88 | 88 |
| 89 /// A script tag that invokes the main function on the entry point library. | 89 /// A script tag that invokes the main function on the entry point library. |
| 90 Node _invokeMain(String mainLibraryName) { | 90 Node _invokeMain(String mainLibraryName) { |
| 91 var code = mainLibraryName == null | 91 var code = mainLibraryName == null |
| 92 ? 'console.error("dev_compiler error: main was not generated");' | 92 ? 'console.error("dev_compiler error: main was not generated");' |
| 93 : '$mainLibraryName.main();'; | 93 // TODO(vsm): Can we simplify this? |
| 94 // See: https://github.com/dart-lang/dev_compiler/issues/164 |
| 95 : '_isolate_helper.startRootIsolate($mainLibraryName.main, []);'; |
| 94 return parseFragment('<script>$code</script>\n'); | 96 return parseFragment('<script>$code</script>\n'); |
| 95 } | 97 } |
| 96 | 98 |
| 97 /// Convert the outputPath to include the hash in it. This function is the | 99 /// Convert the outputPath to include the hash in it. This function is the |
| 98 /// reverse of what the server does to determine whether a request needs to have | 100 /// reverse of what the server does to determine whether a request needs to have |
| 99 /// cache headers added to it. | 101 /// cache headers added to it. |
| 100 _addHash(String outPath, String hash) { | 102 _addHash(String outPath, String hash) { |
| 101 // (the ____ prefix makes it look better in the web inspector) | 103 // (the ____ prefix makes it look better in the web inspector) |
| 102 return '$outPath?____cached=$hash'; | 104 return '$outPath?____cached=$hash'; |
| 103 } | 105 } |
| 104 | 106 |
| 105 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); | 107 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); |
| OLD | NEW |