OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library barback.package_provider; | |
6 | |
7 import 'dart:async'; | |
8 | |
9 import 'asset/asset.dart'; | |
10 import 'asset/asset_id.dart'; | |
11 | |
12 /// API for locating and accessing packages on disk. | |
13 /// | |
14 /// Implemented by pub and provided to barback so that it isn't coupled | |
15 /// directly to pub. | |
16 abstract class PackageProvider { | |
17 /// The names of all packages that can be provided by this provider. | |
18 /// | |
19 /// This is equal to the transitive closure of the entrypoint package | |
20 /// dependencies. | |
21 Iterable<String> get packages; | |
22 | |
23 /// Loads an asset from disk. | |
24 /// | |
25 /// This should be re-entrant; it may be called multiple times with the same | |
26 /// id before the previously returned future has completed. | |
27 /// | |
28 /// If no asset with [id] exists, the provider should throw an | |
29 /// [AssetNotFoundException]. | |
30 Future<Asset> getAsset(AssetId id); | |
31 } | |
32 | |
33 /// A PackageProvider for which some packages are known to be static—that is, | |
34 /// the package has no transformers and its assets won't ever change. | |
35 /// | |
36 /// For static packages, rather than telling barback up-front which assets that | |
37 /// package contains via [Barback.updateSources], barback will lazily query the | |
38 /// provider for an asset when it's needed. This is much more efficient. | |
39 abstract class StaticPackageProvider implements PackageProvider { | |
40 /// The names of all static packages provided by this provider. | |
41 /// | |
42 /// This must be disjoint from [packages]. | |
43 Iterable<String> get staticPackages; | |
44 | |
45 /// Returns all ids of assets in [package]. | |
46 /// | |
47 /// This is used for [Barback.getAllAssets]. | |
48 Stream<AssetId> getAllAssetIds(String package); | |
49 } | |
OLD | NEW |