| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:convert'; | 6 import 'dart:convert'; |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:async/async.dart'; | 9 import 'package:async/async.dart'; |
| 10 import 'package:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 asset.id.extension == '.dart' && | 202 asset.id.extension == '.dart' && |
| 203 topLevelDir(asset.id.path) == moduleDir); | 203 topLevelDir(asset.id.path) == moduleDir); |
| 204 if (moduleAssets.isEmpty) throw new AssetNotFoundException(id); | 204 if (moduleAssets.isEmpty) throw new AssetNotFoundException(id); |
| 205 var moduleMode = | 205 var moduleMode = |
| 206 moduleDir == 'lib' ? ModuleMode.public : ModuleMode.private; | 206 moduleDir == 'lib' ? ModuleMode.public : ModuleMode.private; |
| 207 var modules = await computeModules(moduleMode, moduleAssets); | 207 var modules = await computeModules(moduleMode, moduleAssets); |
| 208 var encoded = JSON.encode(modules); | 208 var encoded = JSON.encode(modules); |
| 209 return new Asset.fromString(id, encoded); | 209 return new Asset.fromString(id, encoded); |
| 210 } | 210 } |
| 211 | 211 |
| 212 /// Whether [_sdkResources] has an asset matching [id]. |
| 212 bool _hasJsResource(AssetId id) => | 213 bool _hasJsResource(AssetId id) => |
| 213 _sdkResources.containsKey(p.url.basename(id.path)); | 214 _sdkResources.containsKey(p.url.basename(id.path)); |
| 214 | 215 |
| 215 /// Builds [_sdkResources] assets by copying them from the SDK. | 216 /// Builds [_sdkResources] assets by copying them from the SDK. |
| 216 Future<Asset> _buildJsResource(AssetId id) async { | 217 Future<Asset> _buildJsResource(AssetId id) async { |
| 217 var sdk = cli_util.getSdkDir(); | 218 var sdk = cli_util.getSdkDir(); |
| 218 var basename = p.url.basename(id.path); | 219 var basename = p.url.basename(id.path); |
| 219 var resourcePath = _sdkResources[basename]; | 220 var resourcePath = _sdkResources[basename]; |
| 220 if (resourcePath == null) return null; | 221 if (resourcePath == null) return null; |
| 221 return new Asset.fromPath(id, p.url.join(sdk.path, resourcePath)); | 222 return new Asset.fromPath(id, p.url.join(sdk.path, resourcePath)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 309 |
| 309 /// Reads a [Result] from the actual underlying caches, or returns `null`. | 310 /// Reads a [Result] from the actual underlying caches, or returns `null`. |
| 310 Future<Result> _getResult(AssetId id) { | 311 Future<Result> _getResult(AssetId id) { |
| 311 var packageCache = _assets[id.package]; | 312 var packageCache = _assets[id.package]; |
| 312 if (packageCache == null) return null; | 313 if (packageCache == null) return null; |
| 313 var futureResult = packageCache[id.path]; | 314 var futureResult = packageCache[id.path]; |
| 314 if (futureResult == null) return null; | 315 if (futureResult == null) return null; |
| 315 return futureResult; | 316 return futureResult; |
| 316 } | 317 } |
| 317 } | 318 } |
| OLD | NEW |