Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /// Logic to add the log_injector script. | |
| 6 library polymer.src.build.add_log_injector; | |
| 7 | |
| 8 import 'dart:async'; | |
| 9 | |
| 10 import 'package:barback/barback.dart'; | |
| 11 | |
| 12 import 'common.dart'; | |
| 13 | |
| 14 /// Simply injects the script and stylesheet for the log_injector for entry | |
| 15 /// points when not in release mode. | |
| 16 class AddLogInjector extends Transformer with PolymerTransformer { | |
| 17 | |
| 18 final TransformOptions options; | |
| 19 | |
| 20 AddLogInjector(this.options); | |
| 21 | |
| 22 | |
|
Siggi Cherem (dart-lang)
2014/08/01 21:31:51
nit: remove empty line
jakemac
2014/08/04 19:49:58
Done.
| |
| 23 // Run only on entry point html files in !releaseMode. | |
| 24 Future<bool> isPrimary(idOrAsset) { | |
|
Siggi Cherem (dart-lang)
2014/08/01 21:31:51
let's remove the type (since we return bool or Fut
jakemac
2014/08/04 19:49:58
Done, good call.
| |
| 25 if (options.releaseMode) return false; | |
| 26 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id; | |
| 27 return new Future.value(options.isHtmlEntryPoint(id)); | |
| 28 } | |
| 29 | |
| 30 Future apply(Transform transform) { | |
| 31 return readPrimaryAsHtml(transform).then((document) { | |
| 32 document.body.innerHtml = ''' | |
| 33 <script type="application/dart" | |
| 34 src="packages/polymer/src/build/log_injector.dart"></script> | |
|
Siggi Cherem (dart-lang)
2014/08/01 21:31:51
this line is not necessary since this file is impo
jakemac
2014/08/04 19:49:57
Removed it here, previously it was working because
| |
| 35 <link rel="stylesheet" type="text/css" | |
| 36 href="packages/polymer/src/build/log_injector.css"> | |
|
Siggi Cherem (dart-lang)
2014/08/01 21:31:51
since this is the only thing left to add on this p
jakemac
2014/08/04 19:49:57
Added it to the log_combiner phase since that one
Siggi Cherem (dart-lang)
2014/08/04 20:38:37
makes sense, this might be premature optimization
| |
| 37 ${document.body.innerHtml}'''; | |
|
Siggi Cherem (dart-lang)
2014/08/01 21:31:51
let's use append, that way we don't serialize and
jakemac
2014/08/04 19:49:57
Done.
| |
| 38 | |
| 39 var output = | |
| 40 new Asset.fromString(transform.primaryInput.id, document.outerHtml); | |
| 41 transform.addOutput(output); | |
| 42 }); | |
| 43 } | |
| 44 | |
| 45 } | |
| OLD | NEW |