Skip to content

Commit

Permalink
Merge branch 'main' of github.com:sass/dart-sass into feature.color-4
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Sep 11, 2024
2 parents fb7ba8f + 05e1691 commit 519ce69
Show file tree
Hide file tree
Showing 165 changed files with 10,954 additions and 565 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ updates:
- "/.github/util/*/"
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directories:
- "/"
- "/package"
- "/pkg/sass-parser"
ignore:
dependency-name: "sass"
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/util/initialize/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
- run: npm install
shell: ${{ runner.os == 'Windows' && 'powershell' || 'bash' }}

- uses: bufbuild/buf-setup-action@v1.35.1
- uses: bufbuild/buf-setup-action@v1.40.1
with: {github_token: "${{ inputs.github-token }}"}

# This composite action requires bash, but bash is not available on windows-arm64 runner.
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ jobs:
run: dart run grinder protobuf pkg-pub-deploy
env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"}

deploy_sub_packages:
name: Deploy Sub-Packages
deploy_sass_api:
name: Deploy sass_api
runs-on: ubuntu-latest
needs: [deploy_pub]

Expand All @@ -113,12 +113,38 @@ jobs:
with: {github-token: "${{ github.token }}"}

- name: Deploy
run: dart run grinder deploy-sub-packages
run: dart run grinder deploy-sass-api
env:
PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"
GH_TOKEN: "${{ secrets.GH_TOKEN }}"
GH_USER: sassbot

deploy_sass_parser:
name: Deploy sass-parser
runs-on: ubuntu-latest
needs: [deploy_npm]

steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
# Set up .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
version: 'lts/*'
check-latest: true
registry-url: 'https://registry.npmjs.org'
- run: npm publish
env:
NODE_AUTH_TOKEN: '${{ secrets.NPM_TOKEN }}'

- name: Get version
id: version
run: |
echo "version=$(jq .version pkg/sass-parser/package.json)" | tee --append "$GITHUB_OUTPUT"
- run: git tag sass-parser/${{ steps.version.outputs.version }}
- run: git push --tag

deploy_homebrew:
name: Deploy Homebrew
runs-on: ubuntu-latest
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,75 @@ jobs:
run: dart run test -p chrome -j 2
env:
CHROME_EXECUTABLE: chrome

sass_parser_tests:
name: "sass-parser Tests | Dart ${{ matrix.dart_channel }} | Node ${{ matrix.node-version }}"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
dart_channel: [stable]
node-version: ['lts/*']
include:
# Test older LTS versions
#
# TODO: Test on lts/-2 and lts/-3 once they support
# `structuredClone()` (that is, once they're v18 or later).
- os: ubuntu-latest
dart_channel: stable
node-version: lts/-1
# Test LTS version with dart dev channel
- os: ubuntu-latest
dart_channel: dev
node-version: 'lts/*'

steps:
- uses: actions/checkout@v4
- uses: ./.github/util/initialize
with:
dart-sdk: ${{ matrix.dart_channel }}
github-token: ${{ github.token }}
node-version: ${{ matrix.node-version }}

- run: dart run grinder pkg-npm-dev
env: {UPDATE_SASS_SASS_REPO: false}
- run: npm link
working-directory: build/npm
- run: npm install
working-directory: pkg/sass-parser/
- run: npm link sass
working-directory: pkg/sass-parser/
- name: Run tests
run: npm test
working-directory: pkg/sass-parser/

sass_parser_static_analysis:
name: "sass-parser Static Analysis"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: {node-version: 'lts/*'}
- run: npm install
working-directory: pkg/sass-parser/
- name: Run static analysis
run: npm run check
working-directory: pkg/sass-parser/

# TODO - postcss/postcss#1958: Enable this once PostCSS doesn't have TypeDoc
# warnings.

# sass_parser_typedoc:
# name: "sass-parser Typedoc"
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with: {node-version: 'lts/*'}
# - run: npm install
# working-directory: pkg/sass-parser/
# - run: npm run typedoc
# working-directory: pkg/sass-parser/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ pubspec.lock
package-lock.json
/benchmark/source
node_modules/
dist/
/doc/api
/pkg/*/doc/api
/pkg/sass-parser/doc

# Generated protocol buffer files.
*.pb*.dart
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
`darken()`, `transaprentize()`, `fade-out()`, `opacify()`, and `fade-in()`
functions should be replaced by `color.adjust()` or `color.scale()`.

* Add a `global-builtin` future deprecation, which can be opted-into with the
`--future-deprecation` flag or the `futureDeprecations` option in the JS or
Dart API. This emits warnings when any global built-in functions that are
now available in `sass:` modules are called. It will become active by default
in an upcoming release alongside the `@import` deprecation.

### Dart API

* Added a `ColorSpace` class which represents the various color spaces defined
Expand Down Expand Up @@ -190,6 +196,23 @@

## 1.78.0

* The `meta.feature-exists` function is now deprecated. This deprecation is
named `feature-exists`.

* Fix a crash when using `@at-root` without any queries or children in the
indented syntax.

### JS API

* Backport the deprecation options (`fatalDeprecations`, `futureDeprecations`,
and `silenceDeprecations`) to the legacy JS API. The legacy JS API is itself
deprecated, and you should move off of it if possible, but this will allow
users of bundlers and other tools that are still using the legacy API to
still control deprecation warnings.

* Fix a bug where accessing `SourceSpan.url` would crash when a relative URL was
passed to the Sass API.

### Embedded Sass

* Explicitly expose a `sass` executable from the `sass-embedded` npm package.
Expand All @@ -204,6 +227,12 @@
* Fix an edge case where the Dart VM could hang when shutting down when requests
were in flight.

* Fix a race condition where the embedded host could fail to shut down if it was
closed around the same time a new compilation was started.

* Fix a bug where parse-time deprecation warnings could not be controlled by
the deprecation options in some circumstances.

## 1.77.8

* No user-visible changes.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A [Dart][dart] implementation of [Sass][sass]. **Sass makes CSS fun**.
<table>
<tr>
<td>
<img width="118px" alt="Sass logo" src="https://rawgit.com/sass/sass-site/master/source/assets/img/logos/logo.svg" />
<img width="118px" alt="Sass logo" src="https://rawgit.com/sass/sass-site/main/source/assets/img/logos/logo.svg" />
</td>
<td valign="middle">
<a href="https://www.npmjs.com/package/sass"><img width="100%" alt="npm statistics" src="https://nodei.co/npm/sass.png?downloads=true"></a>
Expand All @@ -14,6 +14,8 @@ A [Dart][dart] implementation of [Sass][sass]. **Sass makes CSS fun**.
<a href="https://github.com/sass/dart-sass/actions"><img alt="GitHub actions build status" src="https://github.com/sass/dart-sass/workflows/CI/badge.svg"></a>
</td>
<td>
<a href="https://front-end.social/@sass"><img alt="@[email protected] on Fediverse" src="https://img.shields.io/mastodon/follow/110159358073946175?domain=https%3A%2F%2Ffront-end.social"></a>
<br>
<a href="https://twitter.com/SassCSS"><img alt="@SassCSS on Twitter" src="https://img.shields.io/twitter/follow/SassCSS?label=%40SassCSS&style=social"></a>
<br>
<a href="https://stackoverflow.com/questions/tagged/sass"><img alt="stackoverflow" src="https://img.shields.io/stackexchange/stackoverflow/t/sass?label=Sass%20questions&logo=stackoverflow&style=social"></a>
Expand Down Expand Up @@ -201,7 +203,7 @@ files, you'll need to pass a [custom importer] to [`compileString()`] or

[`compile()`]: https://sass-lang.com/documentation/js-api/functions/compile
[`compileAsync()`]: https://sass-lang.com/documentation/js-api/functions/compileAsync
[custom importer]: https://sass-lang.com/documentation/js-api/interfaces/StringOptionsWithImporter#importer
[custom importer]: https://sass-lang.com/documentation/js-api/interfaces/stringoptions/#importer
[`compileString()`]: https://sass-lang.com/documentation/js-api/functions/compileString
[`compileStringAsync()`]: https://sass-lang.com/documentation/js-api/functions/compileStringAsync
[legacy API]: #legacy-javascript-api
Expand Down
16 changes: 5 additions & 11 deletions bin/sass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import 'package:sass/src/executable/watch.dart';
import 'package:sass/src/import_cache.dart';
import 'package:sass/src/importer/filesystem.dart';
import 'package:sass/src/io.dart';
import 'package:sass/src/logger/deprecation_processing.dart';
import 'package:sass/src/stylesheet_graph.dart';
import 'package:sass/src/utils.dart';
import 'package:sass/src/embedded/executable.dart'
Expand Down Expand Up @@ -48,16 +47,11 @@ Future<void> main(List<String> args) async {
var graph = StylesheetGraph(ImportCache(
importers: [...options.pkgImporters, FilesystemImporter.noLoadPath],
loadPaths: options.loadPaths,
// This logger is only used for handling fatal/future deprecations
// during parsing, and is re-used across parses, so we don't want to
// limit repetition. A separate DeprecationHandlingLogger is created for
// each compilation, which will limit repetition if verbose is not
// passed in addition to handling fatal/future deprecations.
logger: DeprecationProcessingLogger(options.logger,
silenceDeprecations: options.silenceDeprecations,
fatalDeprecations: options.fatalDeprecations,
futureDeprecations: options.futureDeprecations,
limitRepetition: false)));
logger: ImportCache.wrapLogger(
options.logger,
options.silenceDeprecations,
options.fatalDeprecations,
options.futureDeprecations)));
if (options.watch) {
await watch(options, graph);
return;
Expand Down
16 changes: 12 additions & 4 deletions lib/sass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ CompileResult compileToResult(String path,
logger: logger,
importCache: ImportCache(
importers: importers,
logger: logger ?? Logger.stderr(color: color),
logger: ImportCache.wrapLogger(logger, silenceDeprecations,
fatalDeprecations, futureDeprecations,
color: color),
loadPaths: loadPaths,
packageConfig: packageConfig),
functions: functions,
Expand Down Expand Up @@ -222,7 +224,9 @@ CompileResult compileStringToResult(String source,
logger: logger,
importCache: ImportCache(
importers: importers,
logger: logger ?? Logger.stderr(color: color),
logger: ImportCache.wrapLogger(logger, silenceDeprecations,
fatalDeprecations, futureDeprecations,
color: color),
packageConfig: packageConfig,
loadPaths: loadPaths),
functions: functions,
Expand Down Expand Up @@ -261,7 +265,9 @@ Future<CompileResult> compileToResultAsync(String path,
logger: logger,
importCache: AsyncImportCache(
importers: importers,
logger: logger ?? Logger.stderr(color: color),
logger: AsyncImportCache.wrapLogger(logger, silenceDeprecations,
fatalDeprecations, futureDeprecations,
color: color),
loadPaths: loadPaths,
packageConfig: packageConfig),
functions: functions,
Expand Down Expand Up @@ -304,7 +310,9 @@ Future<CompileResult> compileStringToResultAsync(String source,
logger: logger,
importCache: AsyncImportCache(
importers: importers,
logger: logger ?? Logger.stderr(color: color),
logger: AsyncImportCache.wrapLogger(logger, silenceDeprecations,
fatalDeprecations, futureDeprecations,
color: color),
packageConfig: packageConfig,
loadPaths: loadPaths),
functions: functions,
Expand Down
7 changes: 6 additions & 1 deletion lib/src/ast/sass/expression.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ import '../../value.dart';
import '../../visitor/interface/expression.dart';
import '../sass.dart';

// Note: despite not defining any methods here, this has to be a concrete class
// so we can expose its accept() function to the JS parser.

/// A SassScript expression in a Sass syntax tree.
///
/// {@category AST}
/// {@category Parsing}
@sealed
abstract interface class Expression implements SassNode {
abstract class Expression implements SassNode {
/// Calls the appropriate visit method on [visitor].
T accept<T>(ExpressionVisitor<T> visitor);

Expression();

/// Parses an expression from [contents].
///
/// If passed, [url] is the name of the file from which [contents] comes.
Expand Down
5 changes: 4 additions & 1 deletion lib/src/ast/sass/expression/binary_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'list.dart';
/// A binary operator, as in `1 + 2` or `$this and $other`.
///
/// {@category AST}
final class BinaryOperationExpression implements Expression {
final class BinaryOperationExpression extends Expression {
/// The operator being invoked.
final BinaryOperator operator;

Expand Down Expand Up @@ -111,6 +111,9 @@ final class BinaryOperationExpression implements Expression {
///
/// {@category AST}
enum BinaryOperator {
// Note: When updating these operators, also update
// pkg/sass-parser/lib/src/expression/binary-operation.ts.

/// The Microsoft equals operator, `=`.
singleEquals('single equals', '=', 0),

Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/sass/expression/boolean.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '../expression.dart';
/// A boolean literal, `true` or `false`.
///
/// {@category AST}
final class BooleanExpression implements Expression {
final class BooleanExpression extends Expression {
/// The value of this expression.
final bool value;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/sass/expression/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import '../expression.dart';
/// A color literal.
///
/// {@category AST}
final class ColorExpression implements Expression {
final class ColorExpression extends Expression {
/// The value of this color.
final SassColor value;

Expand Down
4 changes: 2 additions & 2 deletions lib/src/ast/sass/expression/function.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import '../reference.dart';
/// interpolation.
///
/// {@category AST}
final class FunctionExpression
implements Expression, CallableInvocation, SassReference {
final class FunctionExpression extends Expression
implements CallableInvocation, SassReference {
/// The namespace of the function being invoked, or `null` if it's invoked
/// without a namespace.
final String? namespace;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/sass/expression/if.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import '../../../visitor/interface/expression.dart';
/// evaluated.
///
/// {@category AST}
final class IfExpression implements Expression, CallableInvocation {
final class IfExpression extends Expression implements CallableInvocation {
/// The declaration of `if()`, as though it were a normal function.
static final declaration = ArgumentDeclaration.parse(
r"@function if($condition, $if-true, $if-false) {");
Expand Down
Loading

0 comments on commit 519ce69

Please sign in to comment.