diff --git a/CHANGELOG.md b/CHANGELOG.md index eaf6dcc39..32b1bdd06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 1.91.0 + +* **Potentially breaking change:** `meta.inspect()` (as well as other systems + that use it such as `@debug` and certain error messages) now emits numbers + with as high precision as is available instead of rounding to the nearest + 1e⁻¹⁰ as we do when serializing to CSS. This better fits the purpose of + `meta.inspect()`, which is to provide full information about the structure of + a Sass value. + ## 1.90.0 * Allow a `@forward`ed module to be loaded with a configuration when that module diff --git a/lib/src/functions/color.dart b/lib/src/functions/color.dart index 1cb3640c0..afffa341d 100644 --- a/lib/src/functions/color.dart +++ b/lib/src/functions/color.dart @@ -170,7 +170,7 @@ final global = UnmodifiableListView([ warnForDeprecation( "adjust-hue() is deprecated. Suggestion:\n" "\n" - "color.adjust(\$color, \$hue: $suggestedValue)\n" + "color.adjust(\$color, \$hue: ${suggestedValue.toCssString()})\n" "\n" "More info: https://sass-lang.com/d/color-functions", Deprecation.colorFunctions, @@ -2019,7 +2019,7 @@ String _suggestScaleAndAdjust( var factorNumber = SassNumber(factor * 100, '%'); suggestion += "s:\n" "\n" - "color.scale(\$color, \$$channelName: $factorNumber)\n"; + "color.scale(\$color, \$$channelName: ${factorNumber.toCssString()})\n"; } else { suggestion += ":\n\n"; } @@ -2028,7 +2028,8 @@ String _suggestScaleAndAdjust( adjustment, channel == ColorChannel.alpha ? null : '%', ); - return suggestion + "color.adjust(\$color, \$$channelName: $difference)"; + return suggestion + + "color.adjust(\$color, \$$channelName: ${difference.toCssString()})"; } /// Throws an error indicating that a missing channel named [name] can't be @@ -2037,7 +2038,7 @@ Never _missingChannelError(SassColor color, String channel) => throw SassScriptException( "Because the CSS working group is still deciding on the best behavior, " "Sass doesn't currently support modifying missing channels (color: " - "$color).", + "${color.toCssString()}).", channel, ); diff --git a/lib/src/visitor/serialize.dart b/lib/src/visitor/serialize.dart index 2856a24fa..f0a1908ef 100644 --- a/lib/src/visitor/serialize.dart +++ b/lib/src/visitor/serialize.dart @@ -1192,7 +1192,10 @@ final class _SerializeVisitor // Dart always converts integers to strings in the obvious way, so all we // have to do is clamp doubles that are close to being integers. - if (fuzzyAsInt(number) case var integer?) { + if (fuzzyAsInt(number) case var integer? + // In inspect mode, we want to show the full precision of every number, + // so we only write them as integers when they're precisely equal. + when !_inspect || number == integer) { // JS still uses exponential notation for integers, so we have to handle // it here. buffer.write(_removeExponent(integer.toString())); @@ -1201,6 +1204,12 @@ final class _SerializeVisitor var text = _removeExponent(number.toString()); + // Write the number at full precision in inspect mode. + if (_inspect) { + buffer.write(text); + return; + } + // Any double that's less than `SassNumber.precision + 2` digits long is // guaranteed to be safe to emit directly, since it'll contain at most `0.` // followed by [SassNumber.precision] digits. diff --git a/pkg/sass-parser/CHANGELOG.md b/pkg/sass-parser/CHANGELOG.md index 1c1862ee3..73013a86a 100644 --- a/pkg/sass-parser/CHANGELOG.md +++ b/pkg/sass-parser/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.26 + +* No user-visible changes. + ## 0.4.25 * No user-visible changes. diff --git a/pkg/sass-parser/package.json b/pkg/sass-parser/package.json index bc75673cc..8da5ff799 100644 --- a/pkg/sass-parser/package.json +++ b/pkg/sass-parser/package.json @@ -1,6 +1,6 @@ { "name": "sass-parser", - "version": "0.4.25", + "version": "0.4.26", "description": "A PostCSS-compatible wrapper of the official Sass parser", "repository": "sass/sass", "author": "Google Inc.", diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index aed8ba3e8..2357c7988 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,7 @@ +## 15.9.0 + +* No user-visible changes. + ## 15.8.0 * No user-visible changes. diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index 729f75849..ca8c298cb 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ 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: 15.8.0 +version: 15.9.0 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=3.6.0 <4.0.0" dependencies: - sass: 1.90.0 + sass: 1.91.0 dev_dependencies: dartdoc: ^8.0.14 diff --git a/pubspec.yaml b/pubspec.yaml index 41e3a07bc..efbcd7329 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.90.0 +version: 1.91.0 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass