mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-26 20:24:42 +01:00
Work around dart-lang/sdk#33574
This commit is contained in:
parent
6733567f91
commit
f9f0d0e5da
@ -9,12 +9,11 @@ import 'package:path/path.dart' as p;
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import '../../io.dart';
|
||||
import '../../node/function.dart';
|
||||
import '../../node/importer_result.dart';
|
||||
import '../../node/utils.dart';
|
||||
import '../utils.dart';
|
||||
|
||||
typedef _Importer(String url, String prev, [void done(result)]);
|
||||
|
||||
/// An importer that encapsulates Node Sass's import logic.
|
||||
///
|
||||
/// This isn't a normal [Importer] because Node Sass's import behavior isn't
|
||||
@ -46,10 +45,9 @@ class NodeImporter {
|
||||
final List<String> _includePaths;
|
||||
|
||||
/// The importer functions passed in by the user.
|
||||
final List<_Importer> _importers;
|
||||
final List<JSFunction> _importers;
|
||||
|
||||
NodeImporter(this._context, Iterable<String> includePaths,
|
||||
Iterable<_Importer> importers)
|
||||
NodeImporter(this._context, Iterable<String> includePaths, Iterable importers)
|
||||
: _includePaths = new List.unmodifiable(includePaths),
|
||||
_importers = new List.unmodifiable(importers);
|
||||
|
||||
@ -137,8 +135,8 @@ class NodeImporter {
|
||||
: new Tuple2(readFile(resolved), p.toUri(resolved).toString());
|
||||
}
|
||||
|
||||
/// Converts an [_Importer]'s return [value] to a tuple that can be returned
|
||||
/// by [load].
|
||||
/// Converts an importer's return [value] to a tuple that can be returned by
|
||||
/// [load].
|
||||
Tuple2<String, String> _handleImportResult(
|
||||
String url, Uri previous, Object value) {
|
||||
if (isJSError(value)) throw value;
|
||||
@ -164,7 +162,7 @@ class NodeImporter {
|
||||
|
||||
/// Calls an importer that may or may not be asynchronous.
|
||||
Future<Object> _callImporterAsync(
|
||||
_Importer importer, String url, String previousString) async {
|
||||
JSFunction importer, String url, String previousString) async {
|
||||
var completer = new Completer();
|
||||
|
||||
var result = call3(importer, _context, url, previousString,
|
||||
|
@ -6,11 +6,9 @@ import 'dart:async';
|
||||
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
typedef _Importer(String url, String prev, [void done(result)]);
|
||||
|
||||
class NodeImporter {
|
||||
NodeImporter(Object context, Iterable<String> includePaths,
|
||||
Iterable<_Importer> importers);
|
||||
NodeImporter(
|
||||
Object context, Iterable<String> includePaths, Iterable importers);
|
||||
|
||||
Tuple2<String, String> load(String url, Uri previous) => null;
|
||||
|
||||
|
@ -19,6 +19,7 @@ import 'executable.dart' as executable;
|
||||
import 'importer/node.dart';
|
||||
import 'node/error.dart';
|
||||
import 'node/exports.dart';
|
||||
import 'node/function.dart';
|
||||
import 'node/render_context.dart';
|
||||
import 'node/render_context_options.dart';
|
||||
import 'node/render_options.dart';
|
||||
@ -30,8 +31,6 @@ import 'parse/scss.dart';
|
||||
import 'value.dart';
|
||||
import 'visitor/serialize.dart';
|
||||
|
||||
typedef _Importer(String url, String prev, [void done(result)]);
|
||||
|
||||
/// The entrypoint for Node.js.
|
||||
///
|
||||
/// This sets up exports that can be called from JS. These include a private
|
||||
@ -251,13 +250,13 @@ List<AsyncCallable> _parseFunctions(RenderOptions options,
|
||||
/// Parses [importer] and [includePaths] from [RenderOptions] into a
|
||||
/// [NodeImporter].
|
||||
NodeImporter _parseImporter(RenderOptions options, DateTime start) {
|
||||
List<_Importer> importers;
|
||||
List<JSFunction> importers;
|
||||
if (options.importer == null) {
|
||||
importers = [];
|
||||
} else if (options.importer is List) {
|
||||
importers = (options.importer as List).cast();
|
||||
} else {
|
||||
importers = [options.importer as _Importer];
|
||||
importers = [options.importer as JSFunction];
|
||||
}
|
||||
|
||||
var includePaths = options.includePaths ?? [];
|
||||
@ -294,7 +293,7 @@ NodeImporter _parseImporter(RenderOptions options, DateTime start) {
|
||||
}));
|
||||
if (isUndefined(result)) return options.fiber.yield();
|
||||
return result;
|
||||
}) as _Importer;
|
||||
}) as JSFunction;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
import 'package:js/js.dart';
|
||||
|
||||
@JS("Function")
|
||||
class JSFunction {
|
||||
class JSFunction implements Function {
|
||||
external JSFunction(String arg1, [String arg2, String arg3]);
|
||||
|
||||
// Note that this just invokes the function with the given arguments, rather
|
||||
|
@ -40,14 +40,13 @@ external Function get _JSError;
|
||||
bool isJSError(value) => instanceof(value, _JSError);
|
||||
|
||||
/// Invokes [function] with [thisArg] as `this`.
|
||||
R call2<R, A1, A2>(
|
||||
R function(A1 arg1, A2 arg2), Object thisArg, A1 arg1, A2 arg2) =>
|
||||
(function as JSFunction).apply(thisArg, [arg1, arg2]) as R;
|
||||
Object call2(JSFunction function, Object thisArg, Object arg1, Object arg2) =>
|
||||
function.apply(thisArg, [arg1, arg2]);
|
||||
|
||||
/// Invokes [function] with [thisArg] as `this`.
|
||||
R call3<R, A1, A2, A3>(R function(A1 arg1, A2 arg2, A3 arg3), Object thisArg,
|
||||
A1 arg1, A2 arg2, A3 arg3) =>
|
||||
(function as JSFunction).apply(thisArg, [arg1, arg2, arg3]) as R;
|
||||
Object call3(JSFunction function, Object thisArg, Object arg1, Object arg2,
|
||||
Object arg3) =>
|
||||
function.apply(thisArg, [arg1, arg2, arg3]);
|
||||
|
||||
@JS("Object.keys")
|
||||
external List<String> _keys(Object object);
|
||||
|
Loading…
Reference in New Issue
Block a user