2016-10-15 03:24:50 +02:00
|
|
|
// Copyright 2016 Google Inc. Use of this source code is governed by an
|
|
|
|
// MIT-style license that can be found in the LICENSE file or at
|
|
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
|
2018-03-20 23:43:02 +01:00
|
|
|
/// We strongly recommend importing this library with the prefix `sass`.
|
|
|
|
library sass;
|
|
|
|
|
2021-03-09 23:36:48 +01:00
|
|
|
import 'package:package_config/package_config_types.dart';
|
2018-04-20 01:51:20 +02:00
|
|
|
import 'package:source_maps/source_maps.dart';
|
|
|
|
|
2018-12-12 02:53:46 +01:00
|
|
|
import 'src/async_import_cache.dart';
|
2018-01-06 02:53:51 +01:00
|
|
|
import 'src/callable.dart';
|
2017-07-08 02:03:31 +02:00
|
|
|
import 'src/compile.dart' as c;
|
2021-07-14 02:15:22 +02:00
|
|
|
import 'src/compile_result.dart';
|
2017-02-04 21:20:34 +01:00
|
|
|
import 'src/exception.dart';
|
2018-12-12 02:53:46 +01:00
|
|
|
import 'src/import_cache.dart';
|
2017-10-06 03:45:26 +02:00
|
|
|
import 'src/importer.dart';
|
2018-03-12 04:38:29 +01:00
|
|
|
import 'src/logger.dart';
|
2018-08-11 00:58:15 +02:00
|
|
|
import 'src/syntax.dart';
|
2021-03-10 02:04:09 +01:00
|
|
|
import 'src/util/nullable.dart';
|
2018-01-15 01:05:19 +01:00
|
|
|
import 'src/visitor/serialize.dart';
|
2016-10-15 03:24:50 +02:00
|
|
|
|
2018-01-06 02:53:51 +01:00
|
|
|
export 'src/callable.dart' show Callable, AsyncCallable;
|
2021-07-14 02:15:22 +02:00
|
|
|
export 'src/compile_result.dart';
|
2018-08-14 21:58:47 +02:00
|
|
|
export 'src/exception.dart' show SassException;
|
2017-10-06 03:45:26 +02:00
|
|
|
export 'src/importer.dart';
|
2018-03-12 04:38:29 +01:00
|
|
|
export 'src/logger.dart';
|
2018-08-11 00:58:15 +02:00
|
|
|
export 'src/syntax.dart';
|
2021-06-25 02:32:57 +02:00
|
|
|
export 'src/value.dart';
|
2018-01-15 01:05:19 +01:00
|
|
|
export 'src/visitor/serialize.dart' show OutputStyle;
|
2019-06-06 20:42:44 +02:00
|
|
|
export 'src/warn.dart' show warn;
|
2017-10-06 03:45:26 +02:00
|
|
|
|
2021-07-14 02:15:22 +02:00
|
|
|
/// Loads the Sass file at [path], compiles it to CSS, and returns a
|
|
|
|
/// [CompileResult] containing the CSS and additional metadata about the
|
|
|
|
/// compilation.
|
2016-10-15 03:24:50 +02:00
|
|
|
///
|
2018-03-12 04:38:29 +01:00
|
|
|
/// If [color] is `true`, this will use terminal colors in warnings. It's
|
|
|
|
/// ignored if [logger] is passed.
|
|
|
|
///
|
|
|
|
/// If [logger] is passed, it's used to emit all messages that are generated by
|
|
|
|
/// Sass code. Users may pass custom subclasses of [Logger].
|
2016-10-20 23:35:45 +02:00
|
|
|
///
|
2017-10-06 03:45:26 +02:00
|
|
|
/// Imports are resolved by trying, in order:
|
|
|
|
///
|
|
|
|
/// * Loading a file relative to [path].
|
|
|
|
///
|
|
|
|
/// * Each importer in [importers].
|
|
|
|
///
|
|
|
|
/// * Each load path in [loadPaths]. Note that this is a shorthand for adding
|
|
|
|
/// [FilesystemImporter]s to [importers].
|
|
|
|
///
|
2018-11-06 00:24:14 +01:00
|
|
|
/// * Each load path specified in the `SASS_PATH` environment variable, which
|
|
|
|
/// should be semicolon-separated on Windows and colon-separated elsewhere.
|
|
|
|
///
|
2021-03-09 23:36:48 +01:00
|
|
|
/// * `package:` resolution using [packageConfig], which is a
|
|
|
|
/// [`PackageConfig`][] from the `package_resolver` package. Note that
|
2017-10-06 03:45:26 +02:00
|
|
|
/// this is a shorthand for adding a [PackageImporter] to [importers].
|
2017-02-03 10:08:06 +01:00
|
|
|
///
|
2021-03-09 23:36:48 +01:00
|
|
|
/// [`PackageConfig`]: https://pub.dev/documentation/package_config/latest/package_config.package_config/PackageConfig-class.html
|
2017-02-03 10:08:06 +01:00
|
|
|
///
|
2018-01-06 02:53:51 +01:00
|
|
|
/// Dart functions that can be called from Sass may be passed using [functions].
|
|
|
|
/// Each [Callable] defines a top-level function that will be invoked when the
|
|
|
|
/// given name is called from Sass.
|
|
|
|
///
|
2018-01-15 01:05:19 +01:00
|
|
|
/// The [style] parameter controls the style of the resulting CSS.
|
|
|
|
///
|
2021-05-22 00:16:20 +02:00
|
|
|
/// If [quietDeps] is `true`, this will silence compiler warnings emitted for
|
|
|
|
/// stylesheets loaded through [importers], [loadPaths], or [packageConfig].
|
|
|
|
///
|
2021-05-22 07:40:30 +02:00
|
|
|
/// By default, once a deprecation warning for a given feature is printed five
|
|
|
|
/// times, further warnings for that feature are silenced. If [verbose] is true,
|
|
|
|
/// all deprecation warnings are printed instead.
|
|
|
|
///
|
2021-07-14 02:15:22 +02:00
|
|
|
/// If [sourceMap] is `true`, [CompileResult.sourceMap] will be set to a
|
|
|
|
/// [SingleMapping] that indicates which sections of the source file(s)
|
|
|
|
/// correspond to which in the resulting CSS. [SingleMapping.targetUrl] will be
|
|
|
|
/// `null`. It's up to the caller to save this mapping to disk and add a source
|
|
|
|
/// map comment to [CompileResult.css] pointing to it. Users using the
|
|
|
|
/// [SourceMap] API should be sure to add the [`source_maps`][] package to their
|
|
|
|
/// pubspec.
|
2018-04-20 01:51:20 +02:00
|
|
|
///
|
|
|
|
/// [`source_maps`]: https://pub.dartlang.org/packages/source_maps
|
|
|
|
///
|
2019-04-08 23:49:08 +02:00
|
|
|
/// If [charset] is `true`, this will include a `@charset` declaration or a
|
|
|
|
/// UTF-8 [byte-order mark][] if the stylesheet contains any non-ASCII
|
|
|
|
/// characters. Otherwise, it will never include a `@charset` declaration or a
|
|
|
|
/// byte-order mark.
|
|
|
|
///
|
|
|
|
/// [byte-order mark]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
|
|
|
|
///
|
2017-07-07 09:57:10 +02:00
|
|
|
/// Throws a [SassException] if conversion fails.
|
2021-07-14 02:15:22 +02:00
|
|
|
CompileResult compileToResult(String path,
|
|
|
|
{bool color = false,
|
|
|
|
Logger? logger,
|
|
|
|
Iterable<Importer>? importers,
|
|
|
|
Iterable<String>? loadPaths,
|
|
|
|
PackageConfig? packageConfig,
|
|
|
|
Iterable<Callable>? functions,
|
|
|
|
OutputStyle? style,
|
|
|
|
bool quietDeps = false,
|
|
|
|
bool verbose = false,
|
|
|
|
bool sourceMap = false,
|
|
|
|
bool charset = true}) =>
|
|
|
|
c.compile(path,
|
|
|
|
logger: logger,
|
|
|
|
importCache: ImportCache(
|
|
|
|
importers: importers,
|
|
|
|
logger: logger ?? Logger.stderr(color: color),
|
|
|
|
loadPaths: loadPaths,
|
|
|
|
packageConfig: packageConfig),
|
|
|
|
functions: functions,
|
|
|
|
style: style,
|
|
|
|
quietDeps: quietDeps,
|
|
|
|
verbose: verbose,
|
|
|
|
sourceMap: sourceMap,
|
|
|
|
charset: charset);
|
2017-07-07 09:57:10 +02:00
|
|
|
|
2021-07-14 02:15:22 +02:00
|
|
|
/// Compiles [source] to CSS and returns a [CompileResult] containing the CSS
|
|
|
|
/// and additional metadata about the compilation..
|
2017-07-07 09:57:10 +02:00
|
|
|
///
|
2018-08-11 00:58:15 +02:00
|
|
|
/// This parses the stylesheet as [syntax], which defaults to [Syntax.scss].
|
2018-03-12 04:38:29 +01:00
|
|
|
///
|
|
|
|
/// If [color] is `true`, this will use terminal colors in warnings. It's
|
|
|
|
/// ignored if [logger] is passed.
|
|
|
|
///
|
|
|
|
/// If [logger] is passed, it's used to emit all messages that are generated by
|
|
|
|
/// Sass code. Users may pass custom subclasses of [Logger].
|
2017-07-07 09:57:10 +02:00
|
|
|
///
|
2017-10-06 03:45:26 +02:00
|
|
|
/// Imports are resolved by trying, in order:
|
|
|
|
///
|
|
|
|
/// * The given [importer], with the imported URL resolved relative to [url].
|
|
|
|
///
|
|
|
|
/// * Each importer in [importers].
|
|
|
|
///
|
|
|
|
/// * Each load path in [loadPaths]. Note that this is a shorthand for adding
|
|
|
|
/// [FilesystemImporter]s to [importers].
|
|
|
|
///
|
2018-11-06 00:24:14 +01:00
|
|
|
/// * Each load path specified in the `SASS_PATH` environment variable, which
|
|
|
|
/// should be semicolon-separated on Windows and colon-separated elsewhere.
|
|
|
|
///
|
2021-03-09 23:36:48 +01:00
|
|
|
/// * `package:` resolution using [packageConfig], which is a
|
|
|
|
/// [`PackageConfig`][] from the `package_resolver` package. Note that
|
2017-10-06 03:45:26 +02:00
|
|
|
/// this is a shorthand for adding a [PackageImporter] to [importers].
|
2017-07-07 09:57:10 +02:00
|
|
|
///
|
2021-03-09 23:36:48 +01:00
|
|
|
/// [`PackageConfig`]: https://pub.dev/documentation/package_config/latest/package_config.package_config/PackageConfig-class.html
|
2017-07-07 09:57:10 +02:00
|
|
|
///
|
2018-01-06 02:53:51 +01:00
|
|
|
/// Dart functions that can be called from Sass may be passed using [functions].
|
|
|
|
/// Each [Callable] defines a top-level function that will be invoked when the
|
|
|
|
/// given name is called from Sass.
|
|
|
|
///
|
2018-01-15 01:05:19 +01:00
|
|
|
/// The [style] parameter controls the style of the resulting CSS.
|
|
|
|
///
|
2017-10-06 03:45:26 +02:00
|
|
|
/// The [url] indicates the location from which [source] was loaded. It may be a
|
|
|
|
/// [String] or a [Uri]. If [importer] is passed, [url] must be passed as well
|
|
|
|
/// and `importer.load(url)` should return `source`.
|
2017-07-07 09:57:10 +02:00
|
|
|
///
|
2021-05-22 00:16:20 +02:00
|
|
|
/// If [quietDeps] is `true`, this will silence compiler warnings emitted for
|
|
|
|
/// stylesheets loaded through [importers], [loadPaths], or [packageConfig].
|
|
|
|
///
|
2021-05-22 07:40:30 +02:00
|
|
|
/// By default, once a deprecation warning for a given feature is printed five
|
|
|
|
/// times, further warnings for that feature are silenced. If [verbose] is true,
|
|
|
|
/// all deprecation warnings are printed instead.
|
|
|
|
///
|
2021-07-14 02:15:22 +02:00
|
|
|
/// If [sourceMap] is `true`, [CompileResult.sourceMap] will be set to a
|
|
|
|
/// [SingleMapping] that indicates which sections of the source file(s)
|
|
|
|
/// correspond to which in the resulting CSS. [SingleMapping.targetUrl] will be
|
|
|
|
/// `null`. It's up to the caller to save this mapping to disk and add a source
|
|
|
|
/// map comment to [CompileResult.css] pointing to it. Users using the
|
|
|
|
/// [SourceMap] API should be sure to add the [`source_maps`][] package to their
|
|
|
|
/// pubspec.
|
2018-04-20 01:51:20 +02:00
|
|
|
///
|
|
|
|
/// [`source_maps`]: https://pub.dartlang.org/packages/source_maps
|
|
|
|
///
|
2019-04-08 23:49:08 +02:00
|
|
|
/// If [charset] is `true`, this will include a `@charset` declaration or a
|
|
|
|
/// UTF-8 [byte-order mark][] if the stylesheet contains any non-ASCII
|
|
|
|
/// characters. Otherwise, it will never include a `@charset` declaration or a
|
|
|
|
/// byte-order mark.
|
|
|
|
///
|
|
|
|
/// [byte-order mark]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
|
|
|
|
///
|
2021-07-14 02:15:22 +02:00
|
|
|
/// Throws a [SassException] if conversion fails.
|
|
|
|
CompileResult compileStringToResult(String source,
|
|
|
|
{Syntax? syntax,
|
|
|
|
bool color = false,
|
|
|
|
Logger? logger,
|
|
|
|
Iterable<Importer>? importers,
|
|
|
|
PackageConfig? packageConfig,
|
|
|
|
Iterable<String>? loadPaths,
|
|
|
|
Iterable<Callable>? functions,
|
|
|
|
OutputStyle? style,
|
|
|
|
Importer? importer,
|
|
|
|
Object? url,
|
|
|
|
bool quietDeps = false,
|
|
|
|
bool verbose = false,
|
|
|
|
bool sourceMap = false,
|
|
|
|
bool charset = true}) =>
|
|
|
|
c.compileString(source,
|
|
|
|
syntax: syntax,
|
|
|
|
logger: logger,
|
|
|
|
importCache: ImportCache(
|
|
|
|
importers: importers,
|
|
|
|
logger: logger ?? Logger.stderr(color: color),
|
|
|
|
packageConfig: packageConfig,
|
|
|
|
loadPaths: loadPaths),
|
|
|
|
functions: functions,
|
|
|
|
style: style,
|
|
|
|
importer: importer,
|
|
|
|
url: url,
|
|
|
|
quietDeps: quietDeps,
|
|
|
|
verbose: verbose,
|
|
|
|
sourceMap: sourceMap,
|
|
|
|
charset: charset);
|
|
|
|
|
|
|
|
/// Like [compileToResult], except it runs asynchronously.
|
|
|
|
///
|
|
|
|
/// Running asynchronously allows this to take [AsyncImporter]s rather than
|
|
|
|
/// synchronous [Importer]s. However, running asynchronously is also somewhat
|
|
|
|
/// slower, so [compileToResult] should be preferred if possible.
|
|
|
|
Future<CompileResult> compileToResultAsync(String path,
|
|
|
|
{bool color = false,
|
|
|
|
Logger? logger,
|
|
|
|
Iterable<AsyncImporter>? importers,
|
|
|
|
PackageConfig? packageConfig,
|
|
|
|
Iterable<String>? loadPaths,
|
|
|
|
Iterable<AsyncCallable>? functions,
|
|
|
|
OutputStyle? style,
|
|
|
|
bool quietDeps = false,
|
|
|
|
bool verbose = false,
|
|
|
|
bool sourceMap = false}) =>
|
|
|
|
c.compileAsync(path,
|
|
|
|
logger: logger,
|
|
|
|
importCache: AsyncImportCache(
|
|
|
|
importers: importers,
|
|
|
|
logger: logger ?? Logger.stderr(color: color),
|
|
|
|
loadPaths: loadPaths,
|
|
|
|
packageConfig: packageConfig),
|
|
|
|
functions: functions,
|
|
|
|
style: style,
|
|
|
|
quietDeps: quietDeps,
|
|
|
|
verbose: verbose,
|
|
|
|
sourceMap: sourceMap);
|
|
|
|
|
|
|
|
/// Like [compileStringToResult], except it runs asynchronously.
|
|
|
|
///
|
|
|
|
/// Running asynchronously allows this to take [AsyncImporter]s rather than
|
|
|
|
/// synchronous [Importer]s. However, running asynchronously is also somewhat
|
|
|
|
/// slower, so [compileStringToResult] should be preferred if possible.
|
|
|
|
Future<CompileResult> compileStringToResultAsync(String source,
|
|
|
|
{Syntax? syntax,
|
|
|
|
bool color = false,
|
|
|
|
Logger? logger,
|
|
|
|
Iterable<AsyncImporter>? importers,
|
|
|
|
PackageConfig? packageConfig,
|
|
|
|
Iterable<String>? loadPaths,
|
|
|
|
Iterable<AsyncCallable>? functions,
|
|
|
|
OutputStyle? style,
|
|
|
|
AsyncImporter? importer,
|
|
|
|
Object? url,
|
|
|
|
bool quietDeps = false,
|
|
|
|
bool verbose = false,
|
|
|
|
bool sourceMap = false,
|
|
|
|
bool charset = true}) =>
|
|
|
|
c.compileStringAsync(source,
|
|
|
|
syntax: syntax,
|
|
|
|
logger: logger,
|
|
|
|
importCache: AsyncImportCache(
|
|
|
|
importers: importers,
|
|
|
|
logger: logger ?? Logger.stderr(color: color),
|
|
|
|
packageConfig: packageConfig,
|
|
|
|
loadPaths: loadPaths),
|
|
|
|
functions: functions,
|
|
|
|
style: style,
|
|
|
|
importer: importer,
|
|
|
|
url: url,
|
|
|
|
quietDeps: quietDeps,
|
|
|
|
verbose: verbose,
|
|
|
|
sourceMap: sourceMap,
|
|
|
|
charset: charset);
|
|
|
|
|
|
|
|
/// Like [compileToResult], but returns [CompileResult.css] rather than
|
|
|
|
/// returning [CompileResult] directly.
|
|
|
|
///
|
|
|
|
/// If [sourceMap] is passed, it's passed a [SingleMapping] that indicates which
|
|
|
|
/// sections of the source file(s) correspond to which in the resulting CSS.
|
|
|
|
/// It's called immediately before this method returns, and only if compilation
|
|
|
|
/// succeeds. Note that [SingleMapping.targetUrl] will always be `null`. Users
|
|
|
|
/// using the [SourceMap] API should be sure to add the [`source_maps`][]
|
|
|
|
/// package to their pubspec.
|
|
|
|
///
|
|
|
|
/// [`source_maps`]: https://pub.dartlang.org/packages/source_maps
|
|
|
|
///
|
2018-04-20 01:51:20 +02:00
|
|
|
/// This parameter is meant to be used as an out parameter, so that users who
|
|
|
|
/// want access to the source map can get it. For example:
|
|
|
|
///
|
|
|
|
/// ```dart
|
|
|
|
/// SingleMapping sourceMap;
|
|
|
|
/// var css = compile(sassPath, sourceMap: (map) => sourceMap = map);
|
|
|
|
/// ```
|
2021-07-14 02:15:22 +02:00
|
|
|
@Deprecated("Use compileToResult() instead.")
|
|
|
|
String compile(
|
|
|
|
String path,
|
|
|
|
{bool color = false,
|
|
|
|
Logger? logger,
|
|
|
|
Iterable<Importer>? importers,
|
|
|
|
Iterable<String>? loadPaths,
|
|
|
|
PackageConfig? packageConfig,
|
|
|
|
Iterable<Callable>? functions,
|
|
|
|
OutputStyle? style,
|
|
|
|
bool quietDeps = false,
|
|
|
|
bool verbose = false,
|
|
|
|
@Deprecated("Use CompileResult.sourceMap from compileToResult() instead.")
|
|
|
|
void sourceMap(SingleMapping map)?,
|
|
|
|
bool charset = true}) {
|
|
|
|
var result = compileToResult(path,
|
|
|
|
logger: logger,
|
|
|
|
importers: importers,
|
|
|
|
loadPaths: loadPaths,
|
|
|
|
packageConfig: packageConfig,
|
|
|
|
functions: functions,
|
|
|
|
style: style,
|
|
|
|
quietDeps: quietDeps,
|
|
|
|
verbose: verbose,
|
|
|
|
sourceMap: sourceMap != null,
|
|
|
|
charset: charset);
|
|
|
|
result.sourceMap.andThen(sourceMap);
|
|
|
|
return result.css;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Like [compileStringToResult], but returns [CompileResult.css] rather than
|
|
|
|
/// returning [CompileResult] directly.
|
2018-04-20 01:51:20 +02:00
|
|
|
///
|
2021-07-14 02:15:22 +02:00
|
|
|
/// If [sourceMap] is passed, it's passed a [SingleMapping] that indicates which
|
|
|
|
/// sections of the source file(s) correspond to which in the resulting CSS.
|
|
|
|
/// It's called immediately before this method returns, and only if compilation
|
|
|
|
/// succeeds. Note that [SingleMapping.targetUrl] will always be `null`. Users
|
|
|
|
/// using the [SourceMap] API should be sure to add the [`source_maps`][]
|
|
|
|
/// package to their pubspec.
|
|
|
|
///
|
|
|
|
/// [`source_maps`]: https://pub.dartlang.org/packages/source_maps
|
|
|
|
///
|
|
|
|
/// This parameter is meant to be used as an out parameter, so that users who
|
|
|
|
/// want access to the source map can get it. For example:
|
|
|
|
///
|
|
|
|
/// ```dart
|
|
|
|
/// SingleMapping sourceMap;
|
|
|
|
/// var css = compileString(sass, sourceMap: (map) => sourceMap = map);
|
|
|
|
/// ```
|
|
|
|
@Deprecated("Use compileStringToResult() instead.")
|
|
|
|
String compileString(
|
|
|
|
String source,
|
2021-03-17 03:25:39 +01:00
|
|
|
{Syntax? syntax,
|
2018-11-16 00:16:24 +01:00
|
|
|
bool color = false,
|
2021-03-17 03:25:39 +01:00
|
|
|
Logger? logger,
|
|
|
|
Iterable<Importer>? importers,
|
|
|
|
PackageConfig? packageConfig,
|
|
|
|
Iterable<String>? loadPaths,
|
|
|
|
Iterable<Callable>? functions,
|
|
|
|
OutputStyle? style,
|
|
|
|
Importer? importer,
|
|
|
|
Object? url,
|
2021-05-22 00:16:20 +02:00
|
|
|
bool quietDeps = false,
|
2021-05-22 07:40:30 +02:00
|
|
|
bool verbose = false,
|
2021-07-14 02:15:22 +02:00
|
|
|
@Deprecated("Use CompileResult.sourceMap from compileStringToResult() instead.")
|
|
|
|
void sourceMap(SingleMapping map)?,
|
2019-04-08 23:49:08 +02:00
|
|
|
bool charset = true,
|
2021-07-14 02:15:22 +02:00
|
|
|
@Deprecated("Use syntax instead.")
|
|
|
|
bool indented = false}) {
|
|
|
|
var result = compileStringToResult(source,
|
2018-08-11 00:58:15 +02:00
|
|
|
syntax: syntax ?? (indented ? Syntax.sass : Syntax.scss),
|
2018-12-12 02:53:46 +01:00
|
|
|
logger: logger,
|
2021-07-14 02:15:22 +02:00
|
|
|
importers: importers,
|
|
|
|
packageConfig: packageConfig,
|
|
|
|
loadPaths: loadPaths,
|
2018-01-06 02:53:51 +01:00
|
|
|
functions: functions,
|
2018-01-15 01:05:19 +01:00
|
|
|
style: style,
|
2017-10-06 03:45:26 +02:00
|
|
|
importer: importer,
|
2018-04-20 01:51:20 +02:00
|
|
|
url: url,
|
2021-05-22 00:16:20 +02:00
|
|
|
quietDeps: quietDeps,
|
2021-05-22 07:40:30 +02:00
|
|
|
verbose: verbose,
|
2019-04-08 23:49:08 +02:00
|
|
|
sourceMap: sourceMap != null,
|
|
|
|
charset: charset);
|
2021-03-10 02:04:09 +01:00
|
|
|
result.sourceMap.andThen(sourceMap);
|
2017-07-09 23:52:14 +02:00
|
|
|
return result.css;
|
|
|
|
}
|
2017-07-08 02:03:31 +02:00
|
|
|
|
2017-11-11 00:47:25 +01:00
|
|
|
/// Like [compile], except it runs asynchronously.
|
|
|
|
///
|
|
|
|
/// Running asynchronously allows this to take [AsyncImporter]s rather than
|
|
|
|
/// synchronous [Importer]s. However, running asynchronously is also somewhat
|
|
|
|
/// slower, so [compile] should be preferred if possible.
|
2021-07-14 02:15:22 +02:00
|
|
|
@Deprecated("Use compileToResultAsync() instead.")
|
|
|
|
Future<String> compileAsync(
|
|
|
|
String path,
|
2018-11-16 00:16:24 +01:00
|
|
|
{bool color = false,
|
2021-03-17 03:25:39 +01:00
|
|
|
Logger? logger,
|
|
|
|
Iterable<AsyncImporter>? importers,
|
|
|
|
PackageConfig? packageConfig,
|
|
|
|
Iterable<String>? loadPaths,
|
|
|
|
Iterable<AsyncCallable>? functions,
|
|
|
|
OutputStyle? style,
|
2021-05-22 00:16:20 +02:00
|
|
|
bool quietDeps = false,
|
2021-05-22 07:40:30 +02:00
|
|
|
bool verbose = false,
|
2021-07-14 02:15:22 +02:00
|
|
|
@Deprecated("Use CompileResult.sourceMap from compileToResultAsync() instead.")
|
|
|
|
void sourceMap(SingleMapping map)?}) async {
|
|
|
|
var result = await compileToResultAsync(path,
|
2018-12-12 02:53:46 +01:00
|
|
|
logger: logger,
|
2021-07-14 02:15:22 +02:00
|
|
|
importers: importers,
|
|
|
|
loadPaths: loadPaths,
|
|
|
|
packageConfig: packageConfig,
|
2018-01-15 01:05:19 +01:00
|
|
|
functions: functions,
|
2018-04-20 01:51:20 +02:00
|
|
|
style: style,
|
2021-05-22 00:16:20 +02:00
|
|
|
quietDeps: quietDeps,
|
2021-05-22 07:40:30 +02:00
|
|
|
verbose: verbose,
|
2018-04-21 02:56:00 +02:00
|
|
|
sourceMap: sourceMap != null);
|
2021-03-10 02:04:09 +01:00
|
|
|
result.sourceMap.andThen(sourceMap);
|
2017-11-11 00:47:25 +01:00
|
|
|
return result.css;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Like [compileString], except it runs asynchronously.
|
|
|
|
///
|
|
|
|
/// Running asynchronously allows this to take [AsyncImporter]s rather than
|
|
|
|
/// synchronous [Importer]s. However, running asynchronously is also somewhat
|
|
|
|
/// slower, so [compileString] should be preferred if possible.
|
2021-07-14 02:15:22 +02:00
|
|
|
@Deprecated("Use compileStringToResultAsync() instead.")
|
|
|
|
Future<String> compileStringAsync(
|
|
|
|
String source,
|
2021-03-17 03:25:39 +01:00
|
|
|
{Syntax? syntax,
|
2018-11-16 00:16:24 +01:00
|
|
|
bool color = false,
|
2021-03-17 03:25:39 +01:00
|
|
|
Logger? logger,
|
|
|
|
Iterable<AsyncImporter>? importers,
|
|
|
|
PackageConfig? packageConfig,
|
|
|
|
Iterable<String>? loadPaths,
|
|
|
|
Iterable<AsyncCallable>? functions,
|
|
|
|
OutputStyle? style,
|
|
|
|
AsyncImporter? importer,
|
|
|
|
Object? url,
|
2021-05-22 00:16:20 +02:00
|
|
|
bool quietDeps = false,
|
2021-05-22 07:40:30 +02:00
|
|
|
bool verbose = false,
|
2021-07-14 02:15:22 +02:00
|
|
|
@Deprecated("Use CompileResult.sourceMap from compileStringToResultAsync() instead.")
|
|
|
|
void sourceMap(SingleMapping map)?,
|
2019-04-08 23:49:08 +02:00
|
|
|
bool charset = true,
|
2021-07-14 02:15:22 +02:00
|
|
|
@Deprecated("Use syntax instead.")
|
|
|
|
bool indented = false}) async {
|
|
|
|
var result = await compileStringToResultAsync(source,
|
2018-08-11 00:58:15 +02:00
|
|
|
syntax: syntax ?? (indented ? Syntax.sass : Syntax.scss),
|
2018-12-12 02:53:46 +01:00
|
|
|
logger: logger,
|
2021-07-14 02:15:22 +02:00
|
|
|
importers: importers,
|
|
|
|
packageConfig: packageConfig,
|
|
|
|
loadPaths: loadPaths,
|
2018-01-06 02:53:51 +01:00
|
|
|
functions: functions,
|
2018-01-15 01:05:19 +01:00
|
|
|
style: style,
|
2017-11-11 00:47:25 +01:00
|
|
|
importer: importer,
|
2018-04-20 01:51:20 +02:00
|
|
|
url: url,
|
2021-05-22 00:16:20 +02:00
|
|
|
quietDeps: quietDeps,
|
2021-05-22 07:40:30 +02:00
|
|
|
verbose: verbose,
|
2019-04-08 23:49:08 +02:00
|
|
|
sourceMap: sourceMap != null,
|
|
|
|
charset: charset);
|
2021-03-10 02:04:09 +01:00
|
|
|
result.sourceMap.andThen(sourceMap);
|
2017-11-11 00:47:25 +01:00
|
|
|
return result.css;
|
|
|
|
}
|