| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 /// This will make a physical element appear on the page showing build logs. | 82 /// This will make a physical element appear on the page showing build logs. |
| 83 /// It will only appear when ![releaseMode] even if this is true. | 83 /// It will only appear when ![releaseMode] even if this is true. |
| 84 final bool injectBuildLogsInOutput; | 84 final bool injectBuildLogsInOutput; |
| 85 | 85 |
| 86 /// Rules to determine whether to run liner on an html file. | 86 /// Rules to determine whether to run liner on an html file. |
| 87 // TODO(jmesserly): instead of this flag, we should only run linter on | 87 // TODO(jmesserly): instead of this flag, we should only run linter on |
| 88 // reachable (entry point+imported) html if deploying. See dartbug.com/17199. | 88 // reachable (entry point+imported) html if deploying. See dartbug.com/17199. |
| 89 final LintOptions lint; | 89 final LintOptions lint; |
| 90 | 90 |
| 91 /// This will automatically inject `platform.js` from the `web_components` | 91 /// This will automatically inject the polyfills from the `web_components` |
| 92 /// package in all entry points, if it is not already included. | 92 /// package in all entry points, if it is not already included. |
| 93 final bool injectPlatformJs; | 93 final bool injectWebComponentsJs; |
| 94 | 94 |
| 95 TransformOptions({entryPoints, this.inlineStylesheets, | 95 TransformOptions({entryPoints, this.inlineStylesheets, |
| 96 this.contentSecurityPolicy: false, this.directlyIncludeJS: true, | 96 this.contentSecurityPolicy: false, this.directlyIncludeJS: true, |
| 97 this.releaseMode: true, this.lint: const LintOptions(), | 97 this.releaseMode: true, this.lint: const LintOptions(), |
| 98 this.injectBuildLogsInOutput: false, this.injectPlatformJs: true}) | 98 this.injectBuildLogsInOutput: false, this.injectWebComponentsJs: true}) |
| 99 : entryPoints = entryPoints == null ? null | 99 : entryPoints = entryPoints == null ? null |
| 100 : entryPoints.map(systemToAssetPath).toList(); | 100 : entryPoints.map(systemToAssetPath).toList(); |
| 101 | 101 |
| 102 /// Whether an asset with [id] is an entry point HTML file. | 102 /// Whether an asset with [id] is an entry point HTML file. |
| 103 bool isHtmlEntryPoint(AssetId id) { | 103 bool isHtmlEntryPoint(AssetId id) { |
| 104 if (id.extension != '.html') return false; | 104 if (id.extension != '.html') return false; |
| 105 | 105 |
| 106 // Note: [id.path] is a relative path from the root of a package. | 106 // Note: [id.path] is a relative path from the root of a package. |
| 107 if (entryPoints == null) { | 107 if (entryPoints == null) { |
| 108 return id.path.startsWith('web/') || id.path.startsWith('test/'); | 108 return id.path.startsWith('web/') || id.path.startsWith('test/'); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 /// Returns true if this is a valid custom element name. See: | 264 /// Returns true if this is a valid custom element name. See: |
| 265 /// <http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type> | 265 /// <http://w3c.github.io/webcomponents/spec/custom/#dfn-custom-element-type> |
| 266 bool isCustomTagName(String name) { | 266 bool isCustomTagName(String name) { |
| 267 if (name == null || !name.contains('-')) return false; | 267 if (name == null || !name.contains('-')) return false; |
| 268 return !invalidTagNames.containsKey(name); | 268 return !invalidTagNames.containsKey(name); |
| 269 } | 269 } |
| 270 | 270 |
| 271 /// Regex to split names in the 'attributes' attribute, which supports 'a b c', | 271 /// Regex to split names in the 'attributes' attribute, which supports 'a b c', |
| 272 /// 'a,b,c', or even 'a b,c'. This is the same as in `lib/src/declaration.dart`. | 272 /// 'a,b,c', or even 'a b,c'. This is the same as in `lib/src/declaration.dart`. |
| 273 final ATTRIBUTES_REGEX = new RegExp(r'\s|,'); | 273 final ATTRIBUTES_REGEX = new RegExp(r'\s|,'); |
| OLD | NEW |