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 23 matching lines...) Expand all Loading... |
34 // TODO(sigmund): allow more than one Dart script tags? | 34 // TODO(sigmund): allow more than one Dart script tags? |
35 _log.warning(s.sourceSpan.message( | 35 _log.warning(s.sourceSpan.message( |
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 var libraries = []; | 42 var libraries = []; |
43 var resources = new Set(); | 43 var resources = new Set(); |
44 visitInPostOrder( | 44 visitInPostOrder(root, (n) { |
45 root, | 45 if (n is DartSourceNode) libraries.add(n); |
46 (n) { | 46 if (n is ResourceSourceNode) resources.add(n); |
47 if (n is DartSourceNode) libraries.add(n); | 47 }, includeParts: false); |
48 if (n is ResourceSourceNode) resources.add(n); | |
49 }, | |
50 includeParts: false); | |
51 | 48 |
52 root.htmlResourceNodes.forEach((element, resource) { | 49 root.htmlResourceNodes.forEach((element, resource) { |
53 // Make sure we don't try and add this node again. | 50 // Make sure we don't try and add this node again. |
54 resources.remove(resource); | 51 resources.remove(resource); |
55 | 52 |
56 var resourcePath = | 53 var resourcePath = |
57 resourceOutputPath(resource.uri, root.uri, options.runtimeDir); | 54 resourceOutputPath(resource.uri, root.uri, options.runtimeDir); |
58 if (resource.cachingHash != null) { | 55 if (resource.cachingHash != null) { |
59 resourcePath = _addHash(resourcePath, resource.cachingHash); | 56 resourcePath = _addHash(resourcePath, resource.cachingHash); |
60 } | 57 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 119 |
123 /// Convert the outputPath to include the hash in it. This function is the | 120 /// Convert the outputPath to include the hash in it. This function is the |
124 /// reverse of what the server does to determine whether a request needs to have | 121 /// reverse of what the server does to determine whether a request needs to have |
125 /// cache headers added to it. | 122 /// cache headers added to it. |
126 _addHash(String outPath, String hash) { | 123 _addHash(String outPath, String hash) { |
127 // (the ____ prefix makes it look better in the web inspector) | 124 // (the ____ prefix makes it look better in the web inspector) |
128 return '$outPath?____cached=$hash'; | 125 return '$outPath?____cached=$hash'; |
129 } | 126 } |
130 | 127 |
131 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); | 128 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); |
OLD | NEW |