Skip to content

Commit 57ea9f1

Browse files
authored
Expose getters indicating which color fields a color has calculated (#1453)
These getters are only available through the sass_api package. This will allow the Sass embedded compiler to more explicitly send the color information it has on hand.
1 parent 7230371 commit 57ea9f1

File tree

7 files changed

+35
-4
lines changed

7 files changed

+35
-4
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.38.2
2+
3+
* No user-visible changes
4+
15
## 1.38.1
26

37
* No user-visible changes

lib/sass.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export 'src/exception.dart' show SassException;
2626
export 'src/importer.dart';
2727
export 'src/logger.dart';
2828
export 'src/syntax.dart';
29-
export 'src/value.dart';
29+
export 'src/value.dart' hide SassApiColor;
3030
export 'src/visitor/serialize.dart' show OutputStyle;
3131
export 'src/warn.dart' show warn;
3232

lib/src/value/color.dart

+22
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,25 @@ class SassColor extends Value {
305305
return buffer.toString();
306306
}
307307
}
308+
309+
/// Extension methods that are only visible through the `sass_api` package.
310+
///
311+
/// These methods are considered less general-purpose and more liable to change
312+
/// than the main [SassColor] interface.
313+
extension SassApiColor on SassColor {
314+
/// Whether the `red`, `green`, and `blue` fields have already been computed
315+
/// for this value.
316+
///
317+
/// Note that these fields can always be safely computed after the fact; this
318+
/// just allows users such as the Sass embedded compiler to access whichever
319+
/// representation is readily available.
320+
bool get hasCalculatedRgb => _red != null;
321+
322+
/// Whether the `hue`, `saturation`, and `lightness` fields have already been
323+
/// computed for this value.
324+
///
325+
/// Note that these fields can always be safely computed after the fact; this
326+
/// just allows users such as the Sass embedded compiler to access whichever
327+
/// representation is readily available.
328+
bool get hasCalculatedHsl => _saturation != null;
329+
}

pkg/sass_api/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.0-beta.5
2+
3+
* Add `SassColor.hasCalculatedRgb` and `.hasCalculatedHsl` extension getters.
4+
15
## 1.0.0-beta.4
26

37
* `UseRule`, `ForwardRule`, and `DynamicImport` now share a common `Dependency`

pkg/sass_api/lib/sass_api.dart

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export 'package:sass/src/ast/sass.dart' hide AtRootQuery;
1414
export 'package:sass/src/async_import_cache.dart';
1515
export 'package:sass/src/exception.dart' show SassFormatException;
1616
export 'package:sass/src/import_cache.dart';
17+
export 'package:sass/src/value/color.dart';
1718
export 'package:sass/src/visitor/find_dependencies.dart';
1819
export 'package:sass/src/visitor/interface/expression.dart';
1920
export 'package:sass/src/visitor/interface/statement.dart';

pkg/sass_api/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: sass_api
22
# Note: Every time we add a new Sass AST node, we need to bump the *major*
33
# version because it's a breaking change for anyone who's implementing the
44
# visitor interface(s).
5-
version: 1.0.0-beta.4
5+
version: 1.0.0-beta.5
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

99
environment:
1010
sdk: '>=2.12.0 <3.0.0'
1111

1212
dependencies:
13-
sass: 1.38.1
13+
sass: 1.38.2
1414

1515
dependency_overrides:
1616
sass: {path: ../..}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.38.1
2+
version: 1.38.2
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)