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:html5lib/dom.dart'; | 7 import 'package:html5lib/dom.dart'; |
8 import 'package:html5lib/parser.dart' show parseFragment; | 8 import 'package:html5lib/parser.dart' show parseFragment; |
9 import 'package:logging/logging.dart' show Logger; | 9 import 'package:logging/logging.dart' show Logger; |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 'unexpected script. Only one Dart script tag allowed ' | 36 'unexpected script. Only one Dart script tag allowed ' |
37 '(see https://github.com/dart-lang/dart-dev-compiler/issues/53).', | 37 '(see https://github.com/dart-lang/dart-dev-compiler/issues/53).', |
38 color: options.useColors ? colorOf('warning') : false)); | 38 color: options.useColors ? colorOf('warning') : false)); |
39 s.remove(); | 39 s.remove(); |
40 }); | 40 }); |
41 | 41 |
42 if (options.outputDart) return '${document.outerHtml}\n'; | 42 if (options.outputDart) return '${document.outerHtml}\n'; |
43 | 43 |
44 var libraries = []; | 44 var libraries = []; |
45 visitInPostOrder(root, (n) { | 45 visitInPostOrder(root, (n) { |
46 if (n is LibrarySourceNode) libraries.add(n); | 46 if (n is DartSourceNode) libraries.add(n); |
47 }); | 47 }, includeParts: false); |
48 | 48 |
49 String mainLibraryName; | 49 String mainLibraryName; |
50 var fragment = _loadRuntimeScripts(); | 50 var fragment = _loadRuntimeScripts(); |
51 if (!options.checkSdk) fragment.nodes.add(_miniMockSdk); | 51 if (!options.checkSdk) fragment.nodes.add(_miniMockSdk); |
52 for (var lib in libraries) { | 52 for (var lib in libraries) { |
53 var info = lib.info; | 53 var info = lib.info; |
54 if (info == null) continue; | 54 if (info == null) continue; |
55 if (info.isEntry) mainLibraryName = jsLibraryName(info.library); | 55 if (info.isEntry) mainLibraryName = jsLibraryName(info.library); |
56 fragment.nodes.add(_libraryInclude(jsOutputPath(info, root.uri))); | 56 fragment.nodes.add(_libraryInclude(jsOutputPath(info, root.uri))); |
57 } | 57 } |
(...skipping 21 matching lines...) Expand all Loading... |
79 /// some small samples. | 79 /// some small samples. |
80 // TODO(sigmund,jmesserly): remove. | 80 // TODO(sigmund,jmesserly): remove. |
81 Node get _miniMockSdk => parseFragment(''' | 81 Node get _miniMockSdk => parseFragment(''' |
82 <script> | 82 <script> |
83 /* placehorder for unimplemented code libraries */ | 83 /* placehorder for unimplemented code libraries */ |
84 var math = Math; | 84 var math = Math; |
85 var core = { int: { parse: Number }, print: e => console.log(e) }; | 85 var core = { int: { parse: Number }, print: e => console.log(e) }; |
86 var dom = { document: document }; | 86 var dom = { document: document }; |
87 </script>'''); | 87 </script>'''); |
88 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); | 88 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); |
OLD | NEW |