| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** Transfomer that combines multiple dart script tags into a single one. */ | 5 /** Transfomer that combines multiple dart script tags into a single one. */ |
| 6 library polymer.src.build.script_compactor; | 6 library polymer.src.build.script_compactor; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 /** Only run on entry point .html files. */ | 35 /** Only run on entry point .html files. */ |
| 36 Future<bool> isPrimary(Asset input) => | 36 Future<bool> isPrimary(Asset input) => |
| 37 new Future.value(options.isHtmlEntryPoint(input.id)); | 37 new Future.value(options.isHtmlEntryPoint(input.id)); |
| 38 | 38 |
| 39 Future apply(Transform transform) { | 39 Future apply(Transform transform) { |
| 40 var id = transform.primaryInput.id; | 40 var id = transform.primaryInput.id; |
| 41 var secondaryId = id.addExtension('.scriptUrls'); | 41 var secondaryId = id.addExtension('.scriptUrls'); |
| 42 var logger = transform.logger; | 42 var logger = transform.logger; |
| 43 return readPrimaryAsHtml(transform).then((document) { | 43 return readPrimaryAsHtml(transform).then((document) { |
| 44 return transform.readInputAsString(secondaryId).then((libraryIds) { | 44 return transform.readInputAsString(secondaryId).then((libraryIds) { |
| 45 var libraries = JSON.decode(libraryIds).map( | 45 var libraries = (JSON.decode(libraryIds) as Iterable).map( |
| 46 (data) => new AssetId.deserialize(data)).toList(); | 46 (data) => new AssetId.deserialize(data)).toList(); |
| 47 var mainLibraryId; | 47 var mainLibraryId; |
| 48 var mainScriptTag; | 48 var mainScriptTag; |
| 49 bool changed = false; | 49 bool changed = false; |
| 50 | 50 |
| 51 for (var tag in document.queryAll('script')) { | 51 for (var tag in document.queryAll('script')) { |
| 52 var src = tag.attributes['src']; | 52 var src = tag.attributes['src']; |
| 53 if (src == 'packages/polymer/boot.js') { | 53 if (src == 'packages/polymer/boot.js') { |
| 54 tag.remove(); | 54 tag.remove(); |
| 55 continue; | 55 continue; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 }); | 112 }); |
| 113 }); | 113 }); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 const MAIN_HEADER = """ | 117 const MAIN_HEADER = """ |
| 118 library app_bootstrap; | 118 library app_bootstrap; |
| 119 | 119 |
| 120 import 'package:polymer/polymer.dart'; | 120 import 'package:polymer/polymer.dart'; |
| 121 """; | 121 """; |
| OLD | NEW |