| 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 part of polymer; | 5 part of polymer; |
| 6 | 6 |
| 7 /// Annotation used to automatically register polymer elements. | 7 /// Annotation used to automatically register polymer elements. |
| 8 class CustomTag { | 8 class CustomTag { |
| 9 final String tagName; | 9 final String tagName; |
| 10 const CustomTag(this.tagName); | 10 const CustomTag(this.tagName); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 'Please check that the list of entry points in your pubspec.yaml ' | 61 'Please check that the list of entry points in your pubspec.yaml ' |
| 62 'is correct. If you are using pub-serve, you may need to restart it.'; | 62 'is correct. If you are using pub-serve, you may need to restart it.'; |
| 63 } | 63 } |
| 64 | 64 |
| 65 Polymer.registerSync('auto-binding-dart', AutoBindingElement, | 65 Polymer.registerSync('auto-binding-dart', AutoBindingElement, |
| 66 extendsTag: 'template'); | 66 extendsTag: 'template'); |
| 67 | 67 |
| 68 for (var initializer in initializers) { | 68 for (var initializer in initializers) { |
| 69 initializer(); | 69 initializer(); |
| 70 } | 70 } |
| 71 |
| 72 _watchWaitingFor(); |
| 71 } | 73 } |
| 72 | 74 |
| 73 /// Configures [initPolymer] making it optimized for deployment to the internet. | 75 /// Configures [initPolymer] making it optimized for deployment to the internet. |
| 74 /// With this setup the initializer list is supplied instead of searched for | 76 /// With this setup the initializer list is supplied instead of searched for |
| 75 /// at runtime. Additionally, after this method is called [initPolymer] omits | 77 /// at runtime. Additionally, after this method is called [initPolymer] omits |
| 76 /// the [Zone] that automatically invokes [Observable.dirtyCheck]. | 78 /// the [Zone] that automatically invokes [Observable.dirtyCheck]. |
| 77 void configureForDeployment(List<Function> initializers) { | 79 void configureForDeployment(List<Function> initializers) { |
| 78 loader.initializers = initializers; | 80 loader.initializers = initializers; |
| 79 loader.deployMode = true; | 81 loader.deployMode = true; |
| 80 } | 82 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 return; | 155 return; |
| 154 } | 156 } |
| 155 | 157 |
| 156 // Disable the loggers that were not specified. | 158 // Disable the loggers that were not specified. |
| 157 loggers.where((logger) => logFlags[logger.name] != true) | 159 loggers.where((logger) => logFlags[logger.name] != true) |
| 158 .forEach((logger) {logger.level = Level.OFF;}); | 160 .forEach((logger) {logger.level = Level.OFF;}); |
| 159 | 161 |
| 160 // Listen to the polymer logs and print them to the console. | 162 // Listen to the polymer logs and print them to the console. |
| 161 polymerLogger.onRecord.listen((rec) {print(rec);}); | 163 polymerLogger.onRecord.listen((rec) {print(rec);}); |
| 162 } | 164 } |
| 165 |
| 166 /// Watches the waitingFor queue and if it fails to make progress then prints |
| 167 /// a message to the console. |
| 168 void _watchWaitingFor() { |
| 169 int lastWaiting = Polymer.waitingFor.length; |
| 170 int lastAlert; |
| 171 new Timer.periodic(new Duration(seconds: 1), (Timer timer) { |
| 172 var waiting = Polymer.waitingFor; |
| 173 // Done, cancel timer. |
| 174 if (waiting.isEmpty) { |
| 175 timer.cancel(); |
| 176 return; |
| 177 } |
| 178 // Made progress, don't alert. |
| 179 if (waiting.length != lastWaiting) { |
| 180 lastWaiting = waiting.length; |
| 181 return; |
| 182 } |
| 183 // Only alert once per waiting state. |
| 184 if (lastAlert == lastWaiting) return; |
| 185 lastAlert = lastWaiting; |
| 186 |
| 187 print('No elements registered in a while, but still waiting on ' |
| 188 '${waiting.length} elements to be registered. Check that you have a ' |
| 189 'class with an @CustomTag annotation for each of the following tags: ' |
| 190 '${waiting.map((e) => "'${e.attributes['name']}'").join(', ')}'); |
| 191 }); |
| 192 } |
| OLD | NEW |