Chromium Code Reviews| Index: pkg/polymer/lib/src/build/add_log_injector.dart |
| diff --git a/pkg/polymer/lib/src/build/add_log_injector.dart b/pkg/polymer/lib/src/build/add_log_injector.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..61beaaf4d056f391241c6d39677e55d01b86e913 |
| --- /dev/null |
| +++ b/pkg/polymer/lib/src/build/add_log_injector.dart |
| @@ -0,0 +1,45 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/// Logic to add the log_injector script. |
| +library polymer.src.build.add_log_injector; |
| + |
| +import 'dart:async'; |
| + |
| +import 'package:barback/barback.dart'; |
| + |
| +import 'common.dart'; |
| + |
| +/// Simply injects the script and stylesheet for the log_injector for entry |
| +/// points when not in release mode. |
| +class AddLogInjector extends Transformer with PolymerTransformer { |
| + |
| + final TransformOptions options; |
| + |
| + AddLogInjector(this.options); |
| + |
| + |
|
Siggi Cherem (dart-lang)
2014/08/01 21:31:51
nit: remove empty line
jakemac
2014/08/04 19:49:58
Done.
|
| + // Run only on entry point html files in !releaseMode. |
| + 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.
|
| + if (options.releaseMode) return false; |
| + var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id; |
| + return new Future.value(options.isHtmlEntryPoint(id)); |
| + } |
| + |
| + Future apply(Transform transform) { |
| + return readPrimaryAsHtml(transform).then((document) { |
| + document.body.innerHtml = ''' |
| +<script type="application/dart" |
| + 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
|
| +<link rel="stylesheet" type="text/css" |
| + 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
|
| +${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.
|
| + |
| + var output = |
| + new Asset.fromString(transform.primaryInput.id, document.outerHtml); |
| + transform.addOutput(output); |
| + }); |
| + } |
| + |
| +} |