Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: lib/src/codegen/html_codegen.dart

Issue 1235293004: Fix server mode (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/server/server.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 if (ext == '.js') { 74 if (ext == '.js') {
75 fragment.nodes.add(libraryInclude(resourcePath)); 75 fragment.nodes.add(libraryInclude(resourcePath));
76 } else if (ext == '.css') { 76 } else if (ext == '.css') {
77 var stylesheetLink = '<link rel="stylesheet" href="$resourcePath">\n'; 77 var stylesheetLink = '<link rel="stylesheet" href="$resourcePath">\n';
78 fragment.nodes.add(parseFragment(stylesheetLink)); 78 fragment.nodes.add(parseFragment(stylesheetLink));
79 } 79 }
80 } 80 }
81 81
82 String mainLibraryName; 82 String mainLibraryName;
83 var src = scripts[0].attributes["src"];
84 var scriptUri = root.source.resolveRelativeUri(Uri.parse(src));
85
83 for (var lib in libraries) { 86 for (var lib in libraries) {
84 var info = lib.info; 87 var info = lib.info;
85 if (info == null) continue; 88 if (info == null) continue;
86 var uri = info.library.source.uri; 89 var uri = info.library.source.uri;
87 var jsPath = compiler.getModulePath(uri); 90 var jsPath = compiler.getModulePath(uri);
88 if (info.isEntry) mainLibraryName = compiler.getModuleName(uri); 91 if (uri == scriptUri) mainLibraryName = compiler.getModuleName(uri);
89 if (lib.cachingHash != null) { 92 if (lib.cachingHash != null) {
90 jsPath = _addHash(jsPath, lib.cachingHash); 93 jsPath = _addHash(jsPath, lib.cachingHash);
91 } 94 }
92 fragment.nodes.add(libraryInclude(jsPath)); 95 fragment.nodes.add(libraryInclude(jsPath));
93 } 96 }
94 fragment.nodes.add(invokeMain(mainLibraryName)); 97 fragment.nodes.add(invokeMain(mainLibraryName));
95 scripts[0].replaceWith(fragment); 98 scripts[0].replaceWith(fragment);
96 return '${document.outerHtml}\n'; 99 return '${document.outerHtml}\n';
97 } 100 }
98 101
(...skipping 17 matching lines...) Expand all
116 119
117 /// 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
118 /// 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
119 /// cache headers added to it. 122 /// cache headers added to it.
120 _addHash(String outPath, String hash) { 123 _addHash(String outPath, String hash) {
121 // (the ____ prefix makes it look better in the web inspector) 124 // (the ____ prefix makes it look better in the web inspector)
122 return '$outPath?____cached=$hash'; 125 return '$outPath?____cached=$hash';
123 } 126 }
124 127
125 final _log = new Logger('dev_compiler.src.codegen.html_codegen'); 128 final _log = new Logger('dev_compiler.src.codegen.html_codegen');
OLDNEW
« no previous file with comments | « no previous file | lib/src/server/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698