| OLD | NEW | 
|---|
| 1 // Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Transformer used for pub serve and pub build | 5 /// Transformer used for pub serve and pub build | 
| 6 library web_components.build.web_components; | 6 library web_components.build.web_components; | 
| 7 | 7 | 
| 8 import 'dart:async'; | 8 import 'dart:async'; | 
| 9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; | 
| 10 import 'package:code_transformers/assets.dart'; | 10 import 'package:code_transformers/assets.dart'; | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 52   final Resolvers _resolvers; | 52   final Resolvers _resolvers; | 
| 53   TransformOptions options; | 53   TransformOptions options; | 
| 54 | 54 | 
| 55   WebComponentsTransformer(this.options) | 55   WebComponentsTransformer(this.options) | 
| 56       : _resolvers = new Resolvers.fromMock(dart_sdk.mockSdkSources); | 56       : _resolvers = new Resolvers.fromMock(dart_sdk.mockSdkSources); | 
| 57 | 57 | 
| 58   bool isPrimary(AssetId id) { | 58   bool isPrimary(AssetId id) { | 
| 59     if (options.entryPoints != null) { | 59     if (options.entryPoints != null) { | 
| 60       return options.entryPoints.contains(id.path); | 60       return options.entryPoints.contains(id.path); | 
| 61     } | 61     } | 
| 62     if (id.path == 'web/index.bootstrap.dart') return true; |  | 
| 63     // If no entry point is supplied, then any html file under web/ or test/ is | 62     // If no entry point is supplied, then any html file under web/ or test/ is | 
| 64     // an entry point. | 63     // an entry point. | 
| 65     return (id.path.startsWith('web/') || id.path.startsWith('test/')) && | 64     return (id.path.startsWith('web/') || id.path.startsWith('test/')) && | 
| 66         id.path.endsWith('.html'); | 65         id.path.endsWith('.html'); | 
| 67   } | 66   } | 
| 68 | 67 | 
| 69   Future apply(Transform transform) { | 68   Future apply(Transform transform) { | 
| 70     var logger = new BuildLogger(transform); | 69     var logger = new BuildLogger(transform); | 
| 71     var primaryInput = transform.primaryInput; | 70     var primaryInput = transform.primaryInput; | 
| 72     return primaryInput.readAsString().then((html) { | 71     return primaryInput.readAsString().then((html) { | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 84             resolver, transform, doc, scriptId, newScriptId); | 83             resolver, transform, doc, scriptId, newScriptId); | 
| 85 | 84 | 
| 86         // Swap out the main script tag for the bootstrap version. | 85         // Swap out the main script tag for the bootstrap version. | 
| 87         mainScriptTag.attributes['src'] = path.url.relative(bootstrap.id.path, | 86         mainScriptTag.attributes['src'] = path.url.relative(bootstrap.id.path, | 
| 88             from: path.url.dirname(primaryInput.id.path)); | 87             from: path.url.dirname(primaryInput.id.path)); | 
| 89 | 88 | 
| 90         // Output the new document and bootstrap file. | 89         // Output the new document and bootstrap file. | 
| 91         transform | 90         transform | 
| 92             .addOutput(new Asset.fromString(primaryInput.id, doc.outerHtml)); | 91             .addOutput(new Asset.fromString(primaryInput.id, doc.outerHtml)); | 
| 93         transform.addOutput(bootstrap); | 92         transform.addOutput(bootstrap); | 
|  | 93         resolver.release(); | 
| 94       }); | 94       }); | 
| 95     }); | 95     }); | 
| 96   } | 96   } | 
| 97 } | 97 } | 
| OLD | NEW | 
|---|