Skip to content

Commit

Permalink
Expose getters indicating which color fields a color has calculated (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
nex3 committed Aug 28, 2021
1 parent 7230371 commit 57ea9f1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.38.2

* No user-visible changes

## 1.38.1

* No user-visible changes
Expand Down
2 changes: 1 addition & 1 deletion lib/sass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export 'src/exception.dart' show SassException;
export 'src/importer.dart';
export 'src/logger.dart';
export 'src/syntax.dart';
export 'src/value.dart';
export 'src/value.dart' hide SassApiColor;
export 'src/visitor/serialize.dart' show OutputStyle;
export 'src/warn.dart' show warn;

Expand Down
22 changes: 22 additions & 0 deletions lib/src/value/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,25 @@ class SassColor extends Value {
return buffer.toString();
}
}

/// Extension methods that are only visible through the `sass_api` package.
///
/// These methods are considered less general-purpose and more liable to change
/// than the main [SassColor] interface.
extension SassApiColor on SassColor {
/// Whether the `red`, `green`, and `blue` fields have already been computed
/// for this value.
///
/// Note that these fields can always be safely computed after the fact; this
/// just allows users such as the Sass embedded compiler to access whichever
/// representation is readily available.
bool get hasCalculatedRgb => _red != null;

/// Whether the `hue`, `saturation`, and `lightness` fields have already been
/// computed for this value.
///
/// Note that these fields can always be safely computed after the fact; this
/// just allows users such as the Sass embedded compiler to access whichever
/// representation is readily available.
bool get hasCalculatedHsl => _saturation != null;
}
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0-beta.5

* Add `SassColor.hasCalculatedRgb` and `.hasCalculatedHsl` extension getters.

## 1.0.0-beta.4

* `UseRule`, `ForwardRule`, and `DynamicImport` now share a common `Dependency`
Expand Down
1 change: 1 addition & 0 deletions pkg/sass_api/lib/sass_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export 'package:sass/src/ast/sass.dart' hide AtRootQuery;
export 'package:sass/src/async_import_cache.dart';
export 'package:sass/src/exception.dart' show SassFormatException;
export 'package:sass/src/import_cache.dart';
export 'package:sass/src/value/color.dart';
export 'package:sass/src/visitor/find_dependencies.dart';
export 'package:sass/src/visitor/interface/expression.dart';
export 'package:sass/src/visitor/interface/statement.dart';
Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 1.0.0-beta.4
version: 1.0.0-beta.5
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
sass: 1.38.1
sass: 1.38.2

dependency_overrides:
sass: {path: ../..}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.38.1
version: 1.38.2
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit 57ea9f1

Please sign in to comment.