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 library barback.transformer; | 5 library barback.transformer; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'asset.dart'; | 9 import 'asset.dart'; |
10 import 'transform.dart'; | 10 import 'transform.dart'; |
11 | 11 |
12 /// A [Transformer] represents a processor that takes in one or more input | 12 /// A [Transformer] represents a processor that takes in one or more input |
13 /// assets and uses them to generate one or more output assets. | 13 /// assets and uses them to generate one or more output assets. |
14 /// | 14 /// |
15 /// Dart2js, a SASS->CSS processor, a CSS spriter, and a tool to concatenate | 15 /// Dart2js, a SASS->CSS processor, a CSS spriter, and a tool to concatenate |
16 /// files are all examples of transformers. To define your own transformation | 16 /// files are all examples of transformers. To define your own transformation |
17 /// step, extend (or implement) this class. | 17 /// step, extend (or implement) this class. |
| 18 /// |
| 19 /// If possible, transformers should implement [DeclaringTransformer] as well to |
| 20 /// help barback optimize the package graph. |
18 abstract class Transformer { | 21 abstract class Transformer { |
19 /// Override this to return a space-separated list of file extensions | 22 /// Override this to return a space-separated list of file extensions |
20 /// (with leading `.`) that are allowed for the primary inputs to this | 23 /// (with leading `.`) that are allowed for the primary inputs to this |
21 /// transformer. | 24 /// transformer. |
22 /// | 25 /// |
23 /// If you don't override [isPrimary] yourself, it defaults to allowing any | 26 /// If you don't override [isPrimary] yourself, it defaults to allowing any |
24 /// asset whose extension matches one of the ones returned by this. If you | 27 /// asset whose extension matches one of the ones returned by this. If you |
25 /// don't override [isPrimary] *or* this, it allows all files. | 28 /// don't override [isPrimary] *or* this, it allows all files. |
26 String get allowedExtensions => null; | 29 String get allowedExtensions => null; |
27 | 30 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 /// generated assets back to the system. Either can be called multiple times, | 63 /// generated assets back to the system. Either can be called multiple times, |
61 /// in any order. | 64 /// in any order. |
62 /// | 65 /// |
63 /// In other words, a Transformer's job is to find all inputs for a | 66 /// In other words, a Transformer's job is to find all inputs for a |
64 /// transform, starting at the primary input, then generate all output assets | 67 /// transform, starting at the primary input, then generate all output assets |
65 /// and yield them back to the transform. | 68 /// and yield them back to the transform. |
66 Future apply(Transform transform); | 69 Future apply(Transform transform); |
67 | 70 |
68 String toString() => runtimeType.toString().replaceAll("Transformer", ""); | 71 String toString() => runtimeType.toString().replaceAll("Transformer", ""); |
69 } | 72 } |
OLD | NEW |