| 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 /// Common methods used by transfomers. | 5 /// Common methods used by transfomers. |
| 6 library polymer.src.build.common; | 6 library polymer.src.build.common; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 /// This will make a physical element appear on the page showing build logs. | 87 /// This will make a physical element appear on the page showing build logs. |
| 88 /// It will only appear when ![releaseMode] even if this is true. | 88 /// It will only appear when ![releaseMode] even if this is true. |
| 89 final bool injectBuildLogsInOutput; | 89 final bool injectBuildLogsInOutput; |
| 90 | 90 |
| 91 /// True to run liner on all html files before starting other phases. | 91 /// True to run liner on all html files before starting other phases. |
| 92 // TODO(jmesserly): instead of this flag, we should only run linter on | 92 // TODO(jmesserly): instead of this flag, we should only run linter on |
| 93 // reachable (entry point+imported) html if deploying. See dartbug.com/17199. | 93 // reachable (entry point+imported) html if deploying. See dartbug.com/17199. |
| 94 final bool lint; | 94 final bool lint; |
| 95 | 95 |
| 96 /// This will automatically inject `platform.js` from the `web_components` |
| 97 /// package in all entry points, if it is not already included. |
| 98 final bool injectPlatformJs; |
| 99 |
| 96 TransformOptions({entryPoints, this.inlineStylesheets, | 100 TransformOptions({entryPoints, this.inlineStylesheets, |
| 97 this.contentSecurityPolicy: false, this.directlyIncludeJS: true, | 101 this.contentSecurityPolicy: false, this.directlyIncludeJS: true, |
| 98 this.releaseMode: true, this.lint: true, | 102 this.releaseMode: true, this.lint: true, |
| 99 this.injectBuildLogsInOutput: false}) | 103 this.injectBuildLogsInOutput: false, this.injectPlatformJs: true}) |
| 100 : entryPoints = entryPoints == null ? null | 104 : entryPoints = entryPoints == null ? null |
| 101 : entryPoints.map(systemToAssetPath).toList(); | 105 : entryPoints.map(systemToAssetPath).toList(); |
| 102 | 106 |
| 103 /// Whether an asset with [id] is an entry point HTML file. | 107 /// Whether an asset with [id] is an entry point HTML file. |
| 104 bool isHtmlEntryPoint(AssetId id) { | 108 bool isHtmlEntryPoint(AssetId id) { |
| 105 if (id.extension != '.html') return false; | 109 if (id.extension != '.html') return false; |
| 106 | 110 |
| 107 // Note: [id.path] is a relative path from the root of a package. | 111 // Note: [id.path] is a relative path from the root of a package. |
| 108 if (entryPoints == null) { | 112 if (entryPoints == null) { |
| 109 return id.path.startsWith('web/') || id.path.startsWith('test/'); | 113 return id.path.startsWith('web/') || id.path.startsWith('test/'); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 /// Returns true if this is a valid custom element name. See: | 227 /// Returns true if this is a valid custom element name. See: |
| 224 /// <http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type> | 228 /// <http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type> |
| 225 bool isCustomTagName(String name) { | 229 bool isCustomTagName(String name) { |
| 226 if (name == null || !name.contains('-')) return false; | 230 if (name == null || !name.contains('-')) return false; |
| 227 return !invalidTagNames.containsKey(name); | 231 return !invalidTagNames.containsKey(name); |
| 228 } | 232 } |
| 229 | 233 |
| 230 /// Regex to split names in the 'attributes' attribute, which supports 'a b c', | 234 /// Regex to split names in the 'attributes' attribute, which supports 'a b c', |
| 231 /// 'a,b,c', or even 'a b,c'. This is the same as in `lib/src/declaration.dart`. | 235 /// 'a,b,c', or even 'a b,c'. This is the same as in `lib/src/declaration.dart`. |
| 232 final ATTRIBUTES_REGEX = new RegExp(r'\s|,'); | 236 final ATTRIBUTES_REGEX = new RegExp(r'\s|,'); |
| OLD | NEW |