| 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:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 for (var e in parser.errors) { | 29 for (var e in parser.errors) { |
| 30 if (checkDocType || e.errorCode != 'expected-doctype-but-got-start-tag') { | 30 if (checkDocType || e.errorCode != 'expected-doctype-but-got-start-tag') { |
| 31 logger.warning(e.message, span: e.span); | 31 logger.warning(e.message, span: e.span); |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 return document; | 34 return document; |
| 35 } | 35 } |
| 36 | 36 |
| 37 /** Additional options used by polymer transformers */ | 37 /** Additional options used by polymer transformers */ |
| 38 class TransformOptions { | 38 class TransformOptions { |
| 39 List<String> entryPoints; | 39 /** |
| 40 * List of entrypoints paths. The paths are relative to the package root and |
| 41 * are represented using posix style, which matches the representation used in |
| 42 * asset ids in barback. If null, anything under 'web/' or 'test/' is |
| 43 * considered an entry point. |
| 44 */ |
| 45 final List<String> entryPoints; |
| 40 | 46 |
| 41 /** | 47 /** |
| 42 * True to enable Content Security Policy. | 48 * True to enable Content Security Policy. |
| 43 * This means the HTML page will include *.dart.precompiled.js | 49 * This means the HTML page will include *.dart.precompiled.js |
| 44 * | 50 * |
| 45 * This flag has no effect unless [directlyIncludeJS] is enabled. | 51 * This flag has no effect unless [directlyIncludeJS] is enabled. |
| 46 */ | 52 */ |
| 47 bool contentSecurityPolicy; | 53 final bool contentSecurityPolicy; |
| 48 | 54 |
| 49 /** | 55 /** |
| 50 * True to include the compiled JavaScript directly from the HTML page. | 56 * True to include the compiled JavaScript directly from the HTML page. |
| 51 * If enabled this will remove "packages/browser/dart.js" and replace | 57 * If enabled this will remove "packages/browser/dart.js" and replace |
| 52 * `type="application/dart"` scripts with equivalent *.dart.js files. | 58 * `type="application/dart"` scripts with equivalent *.dart.js files. |
| 53 * | 59 * |
| 54 * If [contentSecurityPolicy] enabled, this will reference files | 60 * If [contentSecurityPolicy] enabled, this will reference files |
| 55 * named *.dart.precompiled.js. | 61 * named *.dart.precompiled.js. |
| 56 */ | 62 */ |
| 57 bool directlyIncludeJS; | 63 final bool directlyIncludeJS; |
| 58 | 64 |
| 59 TransformOptions({entryPoints, this.contentSecurityPolicy: false, | 65 TransformOptions({entryPoints, this.contentSecurityPolicy: false, |
| 60 this.directlyIncludeJS: true}) | 66 this.directlyIncludeJS: true}) |
| 61 : entryPoints = entryPoints == null ? null | 67 : entryPoints = entryPoints == null ? null |
| 62 : entryPoints.map(_systemToAssetPath).toList(); | 68 : entryPoints.map(_systemToAssetPath).toList(); |
| 63 | 69 |
| 64 /** Whether an asset with [id] is an entry point HTML file. */ | 70 /** Whether an asset with [id] is an entry point HTML file. */ |
| 65 bool isHtmlEntryPoint(AssetId id) { | 71 bool isHtmlEntryPoint(AssetId id) { |
| 66 if (id.extension != '.html') return false; | 72 if (id.extension != '.html') return false; |
| 67 | 73 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return builder.relative(builder.join('/', id.path), | 178 return builder.relative(builder.join('/', id.path), |
| 173 from: builder.join('/', builder.dirname(sourceId.path))); | 179 from: builder.join('/', builder.dirname(sourceId.path))); |
| 174 } | 180 } |
| 175 | 181 |
| 176 | 182 |
| 177 /** Convert system paths to asset paths (asset paths are posix style). */ | 183 /** Convert system paths to asset paths (asset paths are posix style). */ |
| 178 String _systemToAssetPath(String assetPath) { | 184 String _systemToAssetPath(String assetPath) { |
| 179 if (path.Style.platform != path.Style.windows) return assetPath; | 185 if (path.Style.platform != path.Style.windows) return assetPath; |
| 180 return path.posix.joinAll(path.split(assetPath)); | 186 return path.posix.joinAll(path.split(assetPath)); |
| 181 } | 187 } |
| OLD | NEW |