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 pub.barback; | 5 library pub.barback; |
6 | 6 |
7 import 'package:barback/barback.dart'; | 7 import 'package:barback/barback.dart'; |
8 import 'package:path/path.dart' as p; | 8 import 'package:path/path.dart' as p; |
9 | 9 |
10 import 'version.dart'; | 10 import 'version.dart'; |
11 | 11 |
12 /// The currently supported versions of the Barback package that this version of | 12 /// The currently supported versions of packages that this version of pub works |
13 /// pub works with. | 13 /// with. |
14 /// | 14 /// |
15 /// Pub implicitly constrains barback to these versions. | 15 /// Pub implicitly constrains these packages to these versions as long as |
| 16 /// barback is a dependency. |
16 /// | 17 /// |
17 /// Barback is in a unique position. Pub imports it, so a copy of Barback is | 18 /// Users' transformers are loaded in an isolate that uses the entrypoint |
18 /// physically included in the SDK. Packages also depend on Barback (from | 19 /// package's dependency versions. However, that isolate also loads code |
19 /// pub.dartlang.org) when they implement their own transformers. Pub's plug-in | 20 /// provided by pub (`asset/dart/transformer_isolate.dart` and associated |
20 /// API dynamically loads transformers into their own isolate. | 21 /// files). This code uses these packages as well, so these constraints exist to |
| 22 /// ensure that its usage of the packages remains valid. |
21 /// | 23 /// |
22 /// This includes a Dart file (`asset/dart/transformer_isolate.dart`) which | 24 /// Most constraints here are like normal version constraints in that their |
23 /// imports "package:barback/barback.dart". This file is included in the SDK, | 25 /// upper bound is the next major version of the package (or minor version for |
24 /// but that import is resolved using the application’s version of Barback. That | 26 /// pre-1.0.0 packages). If a new major version of the package is released, |
25 /// means pub must tightly control which version of Barback the application is | 27 /// these *must* be incremented to synchronize with that. |
26 /// using so that it's one that pub supports. | 28 /// |
| 29 /// The constraint on barback is different. Its upper bound is the next *patch* |
| 30 /// version of barback—that is, the next version with new features. This is |
| 31 /// because most barback features need additional serialization code to be fully |
| 32 /// supported in pub, even if they're otherwise backwards-compatible. |
27 /// | 33 /// |
28 /// Whenever a new minor or patch version of barback is published, this *must* | 34 /// Whenever a new minor or patch version of barback is published, this *must* |
29 /// be incremented to synchronize with that. See the barback [compatibility | 35 /// be incremented to synchronize with that. See the barback [compatibility |
30 /// documentation][compat] for details on the relationship between this | 36 /// documentation][compat] for details on the relationship between this |
31 /// constraint and barback's version. | 37 /// constraint and barback's version. |
32 /// | 38 /// |
33 /// [compat]: https://gist.github.com/nex3/10942218 | 39 /// [compat]: https://gist.github.com/nex3/10942218 |
34 final supportedVersions = new VersionConstraint.parse(">=0.13.0 <0.14.2"); | 40 final pubConstraints = { |
| 41 "barback": new VersionConstraint.parse(">=0.13.0 <0.14.2"), |
| 42 "source_maps": new VersionConstraint.parse(">=0.9.0 <0.10.0"), |
| 43 "stack_trace": new VersionConstraint.parse(">=0.9.1 <2.0.0") |
| 44 }; |
35 | 45 |
36 /// Converts [id] to a "package:" URI. | 46 /// Converts [id] to a "package:" URI. |
37 /// | 47 /// |
38 /// This will throw an [ArgumentError] if [id] doesn't represent a library in | 48 /// This will throw an [ArgumentError] if [id] doesn't represent a library in |
39 /// `lib/`. | 49 /// `lib/`. |
40 Uri idToPackageUri(AssetId id) { | 50 Uri idToPackageUri(AssetId id) { |
41 if (!id.path.startsWith('lib/')) { | 51 if (!id.path.startsWith('lib/')) { |
42 throw new ArgumentError("Asset id $id doesn't identify a library."); | 52 throw new ArgumentError("Asset id $id doesn't identify a library."); |
43 } | 53 } |
44 | 54 |
(...skipping 26 matching lines...) Expand all Loading... |
71 if (parts.length <= index + 1) { | 81 if (parts.length <= index + 1) { |
72 throw new FormatException( | 82 throw new FormatException( |
73 'Invalid URL path "${url.path}". Expected package name ' | 83 'Invalid URL path "${url.path}". Expected package name ' |
74 'after "packages".'); | 84 'after "packages".'); |
75 } | 85 } |
76 | 86 |
77 var package = parts[index + 1]; | 87 var package = parts[index + 1]; |
78 var assetPath = p.url.join("lib", p.url.joinAll(parts.skip(index + 2))); | 88 var assetPath = p.url.join("lib", p.url.joinAll(parts.skip(index + 2))); |
79 return new AssetId(package, assetPath); | 89 return new AssetId(package, assetPath); |
80 } | 90 } |
OLD | NEW |