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

Unified Diff: pkg/polymer/lib/src/build/add_log_injector.dart

Issue 427623002: Polymer transformer logs now show on the frontend for pub serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Moved some logic to the isPrimary function Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/polymer/lib/src/build/common.dart » ('j') | pkg/polymer/lib/src/build/import_inliner.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ });
+ }
+
+}
« no previous file with comments | « no previous file | pkg/polymer/lib/src/build/common.dart » ('j') | pkg/polymer/lib/src/build/import_inliner.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698