| 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 source_file_provider; | 5 library source_file_provider; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 return out.resolve('$outPath.$extension'); | 242 return out.resolve('$outPath.$extension'); |
| 243 } else { | 243 } else { |
| 244 return out.resolve(extension); | 244 return out.resolve(extension); |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 EventSink<String> call(String name, String extension) { | 248 EventSink<String> call(String name, String extension) { |
| 249 Uri uri; | 249 Uri uri; |
| 250 String sourceMapFileName; | 250 String sourceMapFileName; |
| 251 bool isPrimaryOutput = false; | 251 bool isPrimaryOutput = false; |
| 252 if (name == '') { | 252 // TODO (johnniwinther, sigurdm): Make a better interface for |
| 253 // output-providers. |
| 254 if (extension == "deferred_map") { |
| 255 uri = out.resolve(name); |
| 256 } else if (name == '') { |
| 253 if (extension == 'js' || extension == 'dart') { | 257 if (extension == 'js' || extension == 'dart') { |
| 254 isPrimaryOutput = true; | 258 isPrimaryOutput = true; |
| 255 uri = out; | 259 uri = out; |
| 256 sourceMapFileName = | 260 sourceMapFileName = |
| 257 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); | 261 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); |
| 258 } else if (extension == 'precompiled.js') { | 262 } else if (extension == 'precompiled.js') { |
| 259 uri = computePrecompiledUri(out); | 263 uri = computePrecompiledUri(out); |
| 260 onInfo("File ($uri) is compatible with header" | 264 onInfo("File ($uri) is compatible with header" |
| 261 " \"Content-Security-Policy: script-src 'self'\""); | 265 " \"Content-Security-Policy: script-src 'self'\""); |
| 262 } else if (extension == 'js.map' || extension == 'dart.map') { | 266 } else if (extension == 'js.map' || extension == 'dart.map') { |
| 263 uri = sourceMapOut; | 267 uri = sourceMapOut; |
| 264 } else if (extension == 'info.html' || extension == "info.json") { | 268 } else if (extension == "info.json") { |
| 265 String outName = out.path.substring(out.path.lastIndexOf('/') + 1); | 269 String outName = out.path.substring(out.path.lastIndexOf('/') + 1); |
| 266 uri = out.resolve('$outName.$extension'); | 270 uri = out.resolve('$outName.$extension'); |
| 267 } else { | 271 } else { |
| 268 onFailure('Unknown extension: $extension'); | 272 onFailure('Unknown extension: $extension'); |
| 269 } | 273 } |
| 270 } else { | 274 } else { |
| 271 uri = out.resolve('$name.$extension'); | 275 uri = out.resolve('$name.$extension'); |
| 272 } | 276 } |
| 273 | 277 |
| 274 if (uri.scheme != 'file') { | 278 if (uri.scheme != 'file') { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 var onAdd, onClose; | 318 var onAdd, onClose; |
| 315 | 319 |
| 316 EventSinkWrapper(this.onAdd, this.onClose); | 320 EventSinkWrapper(this.onAdd, this.onClose); |
| 317 | 321 |
| 318 void add(String data) => onAdd(data); | 322 void add(String data) => onAdd(data); |
| 319 | 323 |
| 320 void addError(error, [StackTrace stackTrace]) => throw error; | 324 void addError(error, [StackTrace stackTrace]) => throw error; |
| 321 | 325 |
| 322 void close() => onClose(); | 326 void close() => onClose(); |
| 323 } | 327 } |
| OLD | NEW |