From cfa8dc6a4824e24719bc93e9792c47e9a1b3fd9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Jan 2023 23:32:28 +0000 Subject: [PATCH 01/52] Bump minipass from 3.2.1 to 4.0.0 (#193) Bumps [minipass](https://github.com/isaacs/minipass) from 3.2.1 to 4.0.0. - [Release notes](https://github.com/isaacs/minipass/releases) - [Commits](https://github.com/isaacs/minipass/compare/v3.2.1...v4.0.0) --- updated-dependencies: - dependency-name: minipass dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 64e08f05..50317c77 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "extract-zip": "^2.0.1", "gts": "^4.0.0", "jest": "^27.2.5", - "minipass": "3.2.1", + "minipass": "4.0.0", "node-fetch": "^2.6.0", "npm-run-all": "^4.1.5", "protoc": "1.0.4", From 91fd955ad7472261250701e28477e98ce810e760 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Jan 2023 23:56:53 +0000 Subject: [PATCH 02/52] Bump node-fetch from 2.6.8 to 3.3.0 (#191) Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.8 to 3.3.0. - [Release notes](https://github.com/node-fetch/node-fetch/releases) - [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.8...v3.3.0) --- updated-dependencies: - dependency-name: node-fetch dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 50317c77..f6427c91 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "gts": "^4.0.0", "jest": "^27.2.5", "minipass": "4.0.0", - "node-fetch": "^2.6.0", + "node-fetch": "^3.3.0", "npm-run-all": "^4.1.5", "protoc": "1.0.4", "shelljs": "^0.8.4", From 20a17d85f57d1cd87df662a05e66801f725cd561 Mon Sep 17 00:00:00 2001 From: Jennifer Thakar Date: Tue, 24 Jan 2023 16:04:55 -0800 Subject: [PATCH 03/52] Update CI Node versions to 18/16/14 (#187) --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 311323b2..8358a7f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ defaults: env: PROTOC_VERSION: 3.x - DEFAULT_NODE_VERSION: 15.x # If changing this, also change jobs.tests.strategy.matrix.node_version + DEFAULT_NODE_VERSION: 18.x # If changing this, also change jobs.tests.strategy.matrix.node_version on: push: @@ -52,7 +52,7 @@ jobs: strategy: matrix: os: [ubuntu, macos, windows] - node-version: [15.x, 14.x, 12.x] # If changing this, also change env.DEFAULT_NODE_VERSION + node-version: [18.x, 16.x, 14.x] # If changing this, also change env.DEFAULT_NODE_VERSION fail-fast: false steps: @@ -111,13 +111,13 @@ jobs: fail-fast: false matrix: os: [ubuntu, windows, macos] - node_version: [16] + node_version: [18] include: # Include LTS versions on Ubuntu - os: ubuntu - node_version: 14 + node_version: 16 - os: ubuntu - node_version: 12 + node_version: 14 steps: - uses: actions/checkout@v2 From 8a88faefb4fa4be421a5574a04f58ab94df25dd9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Jan 2023 17:03:37 -0800 Subject: [PATCH 04/52] Bump yaml from 1.10.2 to 2.2.1 (#186) Bumps [yaml](https://github.com/eemeli/yaml) from 1.10.2 to 2.2.1. - [Release notes](https://github.com/eemeli/yaml/releases) - [Commits](https://github.com/eemeli/yaml/compare/v1.10.2...v2.2.1) --- updated-dependencies: - dependency-name: yaml dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f6427c91..6b1ba131 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "ts-node": "^10.2.1", "ts-protoc-gen": "^0.15.0", "typescript": "^4.4.3", - "yaml": "^1.10.2", + "yaml": "^2.2.1", "yargs": "^17.2.1" } } From bc70b7bd01bf5839f8007e32c079ab41789bdf60 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 21:45:34 +0000 Subject: [PATCH 05/52] Bump minipass from 4.0.0 to 4.0.1 (#195) Bumps [minipass](https://github.com/isaacs/minipass) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/isaacs/minipass/releases) - [Commits](https://github.com/isaacs/minipass/compare/v4.0.0...v4.0.1) --- updated-dependencies: - dependency-name: minipass dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b1ba131..5f949f76 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "extract-zip": "^2.0.1", "gts": "^4.0.0", "jest": "^27.2.5", - "minipass": "4.0.0", + "minipass": "4.0.1", "node-fetch": "^3.3.0", "npm-run-all": "^4.1.5", "protoc": "1.0.4", From a33bf6d3da00e4f2f13e9a5c93f24e68a80b4955 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Thu, 2 Feb 2023 00:02:44 +0000 Subject: [PATCH 06/52] Update compiler version and release --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 44 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f530226..b64a1a8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +## 1.58.0 + +* Remove sourcemap comments from Sass sources. The generated sourcemap comment + for the compiled CSS output remains unaffected. + +* Fix a bug in `@extend` logic where certain selectors with three or more + combinators were incorrectly considered superselectors of similar selectors + with fewer combinators, causing them to be incorrectly trimmed from the + output. + +* Produce a better error message for a number with a leading `+` or `-`, a + decimal point, but no digits. + +* Produce a better error message for a nested property whose name starts with + `--`. + +* Fix a crash when a selector ends in an escaped backslash. + +* Add the relative length units from CSS Values 4 and CSS Contain 3 as known + units to validate bad computation in `calc`. + +### Command Line Interface + +* The `--watch` flag will now track loads through calls to `meta.load-css()` as + long as their URLs are literal strings without any interpolation. + ## 1.57.1 * No user-visible changes. diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 21273c19..621b1ef3 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.57.1", + "version": "1.58.0", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index a8fd6f06..5a7ea1a9 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.57.1", + "version": "1.58.0", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 13f8c4a5..85a58077 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.57.1", + "version": "1.58.0", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 5dea4da0..b551a258 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.57.1", + "version": "1.58.0", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 5ea3d9ab..adda4c13 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.57.1", + "version": "1.58.0", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index aa82361b..e1516d78 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.57.1", + "version": "1.58.0", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 0a257b66..fe8bb6eb 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.57.1", + "version": "1.58.0", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 8392b3ff..e1edbc01 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.57.1", + "version": "1.58.0", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 5f949f76..b32599b5 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.57.1", + "version": "1.58.0", "protocol-version": "1.1.0", - "compiler-version": "1.57.1", + "compiler-version": "1.58.0", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.57.1", - "sass-embedded-darwin-x64": "1.57.1", - "sass-embedded-linux-arm": "1.57.1", - "sass-embedded-linux-arm64": "1.57.1", - "sass-embedded-linux-ia32": "1.57.1", - "sass-embedded-linux-x64": "1.57.1", - "sass-embedded-win32-ia32": "1.57.1", - "sass-embedded-win32-x64": "1.57.1" + "sass-embedded-darwin-arm64": "1.58.0", + "sass-embedded-darwin-x64": "1.58.0", + "sass-embedded-linux-arm": "1.58.0", + "sass-embedded-linux-arm64": "1.58.0", + "sass-embedded-linux-ia32": "1.58.0", + "sass-embedded-linux-x64": "1.58.0", + "sass-embedded-win32-ia32": "1.58.0", + "sass-embedded-win32-x64": "1.58.0" }, "dependencies": { "buffer-builder": "^0.2.0", From 9c1a898efd95ba9c4e6cb35b859619660d150a09 Mon Sep 17 00:00:00 2001 From: Jennifer Thakar Date: Mon, 6 Feb 2023 14:47:50 -0800 Subject: [PATCH 07/52] Bump jest packages to latest versions (#196) * Bump jest and @types/jest to latest versions * Also update ts-jest --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b32599b5..91fd7f92 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "devDependencies": { "@types/buffer-builder": "^0.2.0", "@types/google-protobuf": "^3.7.2", - "@types/jest": "^27.0.2", + "@types/jest": "^29.4.0", "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.0", "@types/shelljs": "^0.8.8", @@ -56,7 +56,7 @@ "del": "^6.0.0", "extract-zip": "^2.0.1", "gts": "^4.0.0", - "jest": "^27.2.5", + "jest": "^29.4.1", "minipass": "4.0.1", "node-fetch": "^3.3.0", "npm-run-all": "^4.1.5", @@ -64,7 +64,7 @@ "shelljs": "^0.8.4", "source-map-js": "^1.0.2", "tar": "^6.0.5", - "ts-jest": "^27.0.5", + "ts-jest": "^29.0.5", "ts-node": "^10.2.1", "ts-protoc-gen": "^0.15.0", "typescript": "^4.4.3", From d40088fd0c599a097073ee52c76bbd6a889ca350 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 8 Feb 2023 15:50:49 -0800 Subject: [PATCH 08/52] Switch from google-protobuf to protobuf-es (#198) --- .github/workflows/ci.yml | 12 -- lib/src/compile.ts | 97 ++++++------ lib/src/deprotofy-span.ts | 32 ++-- lib/src/dispatcher.ts | 157 ++++++++---------- lib/src/exception.ts | 10 +- lib/src/function-registry.ts | 72 ++++----- lib/src/importer-registry.ts | 163 ++++++++++--------- lib/src/message-transformer.test.ts | 113 ++++--------- lib/src/message-transformer.ts | 165 ++----------------- lib/src/messages.ts | 70 ++++++++ lib/src/packet-transformer.ts | 8 +- lib/src/protofier.ts | 237 +++++++++++++--------------- lib/src/request-tracker.test.ts | 67 ++++---- lib/src/request-tracker.ts | 2 +- lib/src/utils.ts | 4 +- package.json | 6 +- test/utils.ts | 8 +- tool/get-embedded-protocol.ts | 19 +-- 18 files changed, 519 insertions(+), 723 deletions(-) create mode 100644 lib/src/messages.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8358a7f4..eb29e0f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,10 +24,6 @@ jobs: with: node-version: ${{ env.DEFAULT_NODE_VERSION }} check-latest: true - - uses: arduino/setup-protoc@v1 - with: - version: ${{ env.PROTOC_VERSION }} - repo-token: '${{ github.token }}' - name: Check out the embedded protocol uses: sass/clone-linked-repo@v1 @@ -63,10 +59,6 @@ jobs: check-latest: true - uses: frenck/action-setup-yq@v1 with: {version: v4.30.5} # frenck/action-setup-yq#35 - - uses: arduino/setup-protoc@v1 - with: - version: ${{ env.PROTOC_VERSION }} - repo-token: '${{ github.token }}' - uses: dart-lang/setup-dart@v1 with: {sdk: stable} - run: dart --version @@ -127,10 +119,6 @@ jobs: with: {node-version: "${{ matrix.node_version }}"} - uses: frenck/action-setup-yq@v1 with: {version: v4.30.5} # frenck/action-setup-yq#35 - - uses: arduino/setup-protoc@v1 - with: - version: ${{ env.PROTOC_VERSION }} - repo-token: '${{ github.token }}' - name: Check out the embedded protocol uses: sass/clone-linked-repo@v1 diff --git a/lib/src/compile.ts b/lib/src/compile.ts index 195bc447..87c9ad63 100644 --- a/lib/src/compile.ts +++ b/lib/src/compile.ts @@ -73,9 +73,9 @@ function newCompilePathRequest( path: string, importers: ImporterRegistry<'sync' | 'async'>, options?: Options<'sync' | 'async'> -): proto.InboundMessage.CompileRequest { +): proto.InboundMessage_CompileRequest { const request = newCompileRequest(importers, options); - request.setPath(path); + request.input = {case: 'path', value: path}; return request; } @@ -84,29 +84,30 @@ function newCompileStringRequest( source: string, importers: ImporterRegistry<'sync' | 'async'>, options?: StringOptions<'sync' | 'async'> -): proto.InboundMessage.CompileRequest { - const input = new proto.InboundMessage.CompileRequest.StringInput(); - input.setSource(source); - input.setSyntax(utils.protofySyntax(options?.syntax ?? 'scss')); +): proto.InboundMessage_CompileRequest { + const input = new proto.InboundMessage_CompileRequest_StringInput({ + source, + syntax: utils.protofySyntax(options?.syntax ?? 'scss'), + }); const url = options?.url?.toString(); if (url && url !== legacyImporterProtocol) { - input.setUrl(url); + input.url = url; } if (options && 'importer' in options && options.importer) { - input.setImporter(importers.register(options.importer)); + input.importer = importers.register(options.importer); } else if (url === legacyImporterProtocol) { - const importer = new proto.InboundMessage.CompileRequest.Importer(); - importer.setPath(p.resolve('.')); - input.setImporter(importer); + input.importer = new proto.InboundMessage_CompileRequest_Importer({ + importer: {case: 'path', value: p.resolve('.')}, + }); } else { // When importer is not set on the host, the compiler will set a // FileSystemImporter if `url` is set to a file: url or a NoOpImporter. } const request = newCompileRequest(importers, options); - request.setString(input); + request.input = {case: 'string', value: input}; return request; } @@ -115,25 +116,26 @@ function newCompileStringRequest( function newCompileRequest( importers: ImporterRegistry<'sync' | 'async'>, options?: Options<'sync' | 'async'> -): proto.InboundMessage.CompileRequest { - const request = new proto.InboundMessage.CompileRequest(); - request.setImportersList(importers.importers); - request.setGlobalFunctionsList(Object.keys(options?.functions ?? {})); - request.setSourceMap(!!options?.sourceMap); - request.setSourceMapIncludeSources(!!options?.sourceMapIncludeSources); - request.setAlertColor(options?.alertColor ?? !!supportsColor.stdout); - request.setAlertAscii(!!options?.alertAscii); - request.setQuietDeps(!!options?.quietDeps); - request.setVerbose(!!options?.verbose); - request.setCharset(!!(options?.charset ?? true)); +): proto.InboundMessage_CompileRequest { + const request = new proto.InboundMessage_CompileRequest({ + importers: importers.importers, + globalFunctions: Object.keys(options?.functions ?? {}), + sourceMap: !!options?.sourceMap, + sourceMapIncludeSources: !!options?.sourceMapIncludeSources, + alertColor: options?.alertColor ?? !!supportsColor.stdout, + alertAscii: !!options?.alertAscii, + quietDeps: !!options?.quietDeps, + verbose: !!options?.verbose, + charset: !!(options?.charset ?? true), + }); switch (options?.style ?? 'expanded') { case 'expanded': - request.setStyle(proto.OutputStyle.EXPANDED); + request.style = proto.OutputStyle.EXPANDED; break; case 'compressed': - request.setStyle(proto.OutputStyle.COMPRESSED); + request.style = proto.OutputStyle.COMPRESSED; break; default: @@ -147,7 +149,7 @@ function newCompileRequest( // resolves with the CompileResult. Throws if there were any protocol or // compilation errors. Shuts down the compiler after compilation. async function compileRequestAsync( - request: proto.InboundMessage.CompileRequest, + request: proto.InboundMessage_CompileRequest, importers: ImporterRegistry<'async'>, options?: Options<'async'> ): Promise { @@ -172,7 +174,7 @@ async function compileRequestAsync( dispatcher.logEvents$.subscribe(event => handleLogEvent(options, event)); return handleCompileResponse( - await new Promise( + await new Promise( (resolve, reject) => dispatcher.sendCompileRequest(request, (err, response) => { if (err) { @@ -193,7 +195,7 @@ async function compileRequestAsync( // resolves with the CompileResult. Throws if there were any protocol or // compilation errors. Shuts down the compiler after compilation. function compileRequestSync( - request: proto.InboundMessage.CompileRequest, + request: proto.InboundMessage_CompileRequest, importers: ImporterRegistry<'sync'>, options?: Options<'sync'> ): CompileResult { @@ -218,7 +220,7 @@ function compileRequestSync( dispatcher.logEvents$.subscribe(event => handleLogEvent(options, event)); let error: unknown; - let response: proto.OutboundMessage.CompileResponse | undefined; + let response: proto.OutboundMessage_CompileResponse | undefined; dispatcher.sendCompileRequest(request, (error_, response_) => { if (error_) { error = error_; @@ -266,33 +268,32 @@ function createDispatcher( /** Handles a log event according to `options`. */ function handleLogEvent( options: Options<'sync' | 'async'> | undefined, - event: proto.OutboundMessage.LogEvent + event: proto.OutboundMessage_LogEvent ): void { - if (event.getType() === proto.LogEventType.DEBUG) { + if (event.type === proto.LogEventType.DEBUG) { if (options?.logger?.debug) { - options.logger.debug(event.getMessage(), { - span: deprotofySourceSpan(event.getSpan()!), + options.logger.debug(event.message, { + span: deprotofySourceSpan(event.span!), }); } else { - console.error(event.getFormatted()); + console.error(event.formatted); } } else { if (options?.logger?.warn) { const params: {deprecation: boolean; span?: SourceSpan; stack?: string} = { - deprecation: - event.getType() === proto.LogEventType.DEPRECATION_WARNING, + deprecation: event.type === proto.LogEventType.DEPRECATION_WARNING, }; - const spanProto = event.getSpan(); + const spanProto = event.span; if (spanProto) params.span = deprotofySourceSpan(spanProto); - const stack = event.getStackTrace(); + const stack = event.stackTrace; if (stack) params.stack = stack; - options.logger.warn(event.getMessage(), params); + options.logger.warn(event.message, params); } else { - console.error(event.getFormatted()); + console.error(event.formatted); } } } @@ -303,20 +304,20 @@ function handleLogEvent( * Throws a `SassException` if the compilation failed. */ function handleCompileResponse( - response: proto.OutboundMessage.CompileResponse + response: proto.OutboundMessage_CompileResponse ): CompileResult { - if (response.getSuccess()) { - const success = response.getSuccess()!; + if (response.result.case === 'success') { + const success = response.result.value; const result: CompileResult = { - css: success.getCss(), - loadedUrls: success.getLoadedUrlsList().map(url => new URL(url)), + css: success.css, + loadedUrls: success.loadedUrls.map(url => new URL(url)), }; - const sourceMap = success.getSourceMap(); + const sourceMap = success.sourceMap; if (sourceMap) result.sourceMap = JSON.parse(sourceMap); return result; - } else if (response.getFailure()) { - throw new Exception(response.getFailure()!); + } else if (response.result.case === 'failure') { + throw new Exception(response.result.value); } else { throw utils.compilerError('Compiler sent empty CompileResponse.'); } diff --git a/lib/src/deprotofy-span.ts b/lib/src/deprotofy-span.ts index 950ecce4..2b8ec9fa 100644 --- a/lib/src/deprotofy-span.ts +++ b/lib/src/deprotofy-span.ts @@ -5,53 +5,41 @@ import {URL} from 'url'; import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; -import {SourceLocation, SourceSpan} from './vendor/sass'; +import {SourceSpan} from './vendor/sass'; import {compilerError} from './utils'; // Creates a SourceSpan from the given protocol `buffer`. Throws if the buffer // has invalid fields. export function deprotofySourceSpan(buffer: proto.SourceSpan): SourceSpan { - const text = buffer.getText(); + const text = buffer.text; - if (buffer.getStart() === undefined) { + if (buffer.start === undefined) { throw compilerError('Expected SourceSpan to have start.'); } - const start = deprotofySourceLocation(buffer.getStart()!); let end; - if (buffer.getEnd() === undefined) { + if (buffer.end === undefined) { if (text !== '') { throw compilerError('Expected SourceSpan text to be empty.'); } else { - end = start; + end = buffer.start; } } else { - end = deprotofySourceLocation(buffer.getEnd()!); - if (end.offset < start.offset) { + end = buffer.end; + if (end.offset < buffer.start.offset) { throw compilerError('Expected SourceSpan end to be after start.'); } } - const url = buffer.getUrl() === '' ? undefined : new URL(buffer.getUrl()); + const url = buffer.url === '' ? undefined : new URL(buffer.url); - const context = buffer.getContext() === '' ? undefined : buffer.getContext(); + const context = buffer.context === '' ? undefined : buffer.context; return { text, - start, + start: buffer.start, end, url, context, }; } - -// Creates a SourceLocation from the given protocol `buffer`. -function deprotofySourceLocation( - buffer: proto.SourceSpan.SourceLocation -): SourceLocation { - return { - offset: buffer.getOffset(), - line: buffer.getLine(), - column: buffer.getColumn(), - }; -} diff --git a/lib/src/dispatcher.ts b/lib/src/dispatcher.ts index 2dc77426..912df2e4 100644 --- a/lib/src/dispatcher.ts +++ b/lib/src/dispatcher.ts @@ -6,21 +6,13 @@ import {Observable, Subject} from 'rxjs'; import {filter, map, mergeMap} from 'rxjs/operators'; import { - InboundMessage, - OutboundMessage, -} from './vendor/embedded-protocol/embedded_sass_pb'; -import { - InboundRequest, InboundRequestType, - InboundResponse, - InboundResponseType, - InboundTypedMessage, OutboundResponse, OutboundResponseType, - OutboundTypedMessage, -} from './message-transformer'; +} from './messages'; +import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; import {RequestTracker} from './request-tracker'; -import {PromiseOr, thenOr} from './utils'; +import {PromiseOr, compilerError, thenOr, hostError} from './utils'; /** * Dispatches requests, responses, and events. @@ -53,7 +45,7 @@ export class Dispatcher { // All outbound messages. If we detect any errors while dispatching messages, // this completes. - private readonly messages$ = new Subject(); + private readonly messages$ = new Subject(); // If the dispatcher encounters an error, this errors out. It is publicly // exposed as a readonly Observable. @@ -71,14 +63,14 @@ export class Dispatcher { * silently. */ readonly logEvents$ = this.messages$.pipe( - filter(message => message.type === OutboundMessage.MessageCase.LOG_EVENT), - map(message => message.payload as OutboundMessage.LogEvent) + filter(message => message.message.case === 'logEvent'), + map(message => message.message.value as proto.OutboundMessage_LogEvent) ); constructor( - private readonly outboundMessages$: Observable, + private readonly outboundMessages$: Observable, private readonly writeInboundMessage: ( - message: InboundTypedMessage + message: proto.InboundMessage ) => void, private readonly outboundRequestHandlers: DispatcherHandlers ) { @@ -110,16 +102,15 @@ export class Dispatcher { * events synchronously, `callback` will be called synchronously. */ sendCompileRequest( - request: InboundMessage.CompileRequest, + request: proto.InboundMessage_CompileRequest, callback: ( err: unknown, - response: OutboundMessage.CompileResponse | undefined + response: proto.OutboundMessage_CompileResponse | undefined ) => void ): void { this.handleInboundRequest( - request, - InboundMessage.MessageCase.COMPILE_REQUEST, - OutboundMessage.MessageCase.COMPILE_RESPONSE, + {value: request, case: 'compileRequest'}, + 'compileResponse', callback ); } @@ -136,83 +127,86 @@ export class Dispatcher { // contains a request, runs the appropriate callback to generate an inbound // response, and then sends it inbound. private handleOutboundMessage( - message: OutboundTypedMessage + message: proto.OutboundMessage ): PromiseOr { - switch (message.type) { - case OutboundMessage.MessageCase.LOG_EVENT: + switch (message.message.case) { + case 'logEvent': + // Handled separately by `logEvents$`. return undefined; - case OutboundMessage.MessageCase.COMPILE_RESPONSE: + case 'compileResponse': this.pendingInboundRequests.resolve( - (message.payload as OutboundResponse).getId(), - message.type + message.message.value.id, + message.message.case ); return undefined; - case OutboundMessage.MessageCase.IMPORT_REQUEST: { - const request = message.payload as OutboundMessage.ImportRequest; - const id = request.getId(); - const type = InboundMessage.MessageCase.IMPORT_RESPONSE; + case 'importRequest': { + const request = message.message.value; + const id = request.id; + const type = 'importResponse'; this.pendingOutboundRequests.add(id, type); return thenOr( this.outboundRequestHandlers.handleImportRequest(request), response => { - this.sendInboundMessage(id, response, type); + this.sendInboundMessage(id, {case: type, value: response}); } ); } - case OutboundMessage.MessageCase.FILE_IMPORT_REQUEST: { - const request = message.payload as OutboundMessage.FileImportRequest; - const id = request.getId(); - const type = InboundMessage.MessageCase.FILE_IMPORT_RESPONSE; + case 'fileImportRequest': { + const request = message.message.value; + const id = request.id; + const type = 'fileImportResponse'; this.pendingOutboundRequests.add(id, type); return thenOr( this.outboundRequestHandlers.handleFileImportRequest(request), response => { - this.sendInboundMessage(id, response, type); + this.sendInboundMessage(id, {case: type, value: response}); } ); } - case OutboundMessage.MessageCase.CANONICALIZE_REQUEST: { - const request = message.payload as OutboundMessage.CanonicalizeRequest; - const id = request.getId(); - const type = InboundMessage.MessageCase.CANONICALIZE_RESPONSE; + case 'canonicalizeRequest': { + const request = message.message.value; + const id = request.id; + const type = 'canonicalizeResponse'; this.pendingOutboundRequests.add(id, type); return thenOr( this.outboundRequestHandlers.handleCanonicalizeRequest(request), response => { - this.sendInboundMessage(id, response, type); + this.sendInboundMessage(id, {case: type, value: response}); } ); } - case OutboundMessage.MessageCase.FUNCTION_CALL_REQUEST: { - const request = message.payload as OutboundMessage.FunctionCallRequest; - const id = request.getId(); - const type = InboundMessage.MessageCase.FUNCTION_CALL_RESPONSE; + case 'functionCallRequest': { + const request = message.message.value; + const id = request.id; + const type = 'functionCallResponse'; this.pendingOutboundRequests.add(id, type); return thenOr( this.outboundRequestHandlers.handleFunctionCallRequest(request), response => { - this.sendInboundMessage(id, response, type); + this.sendInboundMessage(id, {case: type, value: response}); } ); } + case 'error': + throw hostError(message.message.value.message); + default: - throw Error(`Unknown message type ${message.type}`); + throw compilerError(`Unknown message type ${message.message.case}`); } } - // Sends a `request` of type `requestType` inbound. Returns a promise that - // will either resolve with the corresponding outbound response of type - // `responseType`, or error if any Protocol Errors were encountered. + // Sends `request` inbound. Once it's done, calls `callback` with either the + // corresponding outbound response of type `responseType`, or an error if any + // protocol errors were encountered. private handleInboundRequest( - request: InboundRequest, - requestType: InboundRequestType, + request: proto.InboundMessage['message'] & {case: InboundRequestType}, responseType: OutboundResponseType, callback: (err: unknown, response: OutboundResponse | undefined) => void ): void { @@ -223,20 +217,16 @@ export class Dispatcher { this.messages$ .pipe( - filter(message => message.type === responseType), - map(message => message.payload as OutboundResponse), - filter(response => response.getId() === request.getId()) + filter(message => message.message.case === responseType), + map(message => message.message.value as OutboundResponse), + filter(response => response.id === request.value.id) ) .subscribe({next: response => callback(null, response)}); this.error$.subscribe({error: error => callback(error, undefined)}); try { - this.sendInboundMessage( - this.pendingInboundRequests.nextId, - request, - requestType - ); + this.sendInboundMessage(this.pendingInboundRequests.nextId, request); } catch (error) { this.throwAndClose(error); } @@ -245,31 +235,24 @@ export class Dispatcher { // Sends a message inbound. Keeps track of all pending inbound requests. private sendInboundMessage( id: number, - payload: InboundRequest | InboundResponse, - type: InboundRequestType | InboundResponseType + message: Exclude ): void { - payload.setId(id); + message.value.id = id; - if (type === InboundMessage.MessageCase.COMPILE_REQUEST) { - this.pendingInboundRequests.add( - id, - OutboundMessage.MessageCase.COMPILE_RESPONSE - ); + if (message.case === 'compileRequest') { + this.pendingInboundRequests.add(id, 'compileResponse'); } else if ( - type === InboundMessage.MessageCase.IMPORT_RESPONSE || - type === InboundMessage.MessageCase.FILE_IMPORT_RESPONSE || - type === InboundMessage.MessageCase.CANONICALIZE_RESPONSE || - type === InboundMessage.MessageCase.FUNCTION_CALL_RESPONSE + message.case === 'importResponse' || + message.case === 'fileImportResponse' || + message.case === 'canonicalizeResponse' || + message.case === 'functionCallResponse' ) { - this.pendingOutboundRequests.resolve(id, type); + this.pendingOutboundRequests.resolve(id, message.case); } else { - throw Error(`Unknown message type ${type}`); + throw Error(`Unknown message type ${message.case}`); } - this.writeInboundMessage({ - payload, - type, - }); + this.writeInboundMessage(new proto.InboundMessage({message})); } } @@ -278,15 +261,15 @@ export class Dispatcher { */ export interface DispatcherHandlers { handleImportRequest: ( - request: OutboundMessage.ImportRequest - ) => PromiseOr; + request: proto.OutboundMessage_ImportRequest + ) => PromiseOr; handleFileImportRequest: ( - request: OutboundMessage.FileImportRequest - ) => PromiseOr; + request: proto.OutboundMessage_FileImportRequest + ) => PromiseOr; handleCanonicalizeRequest: ( - request: OutboundMessage.CanonicalizeRequest - ) => PromiseOr; + request: proto.OutboundMessage_CanonicalizeRequest + ) => PromiseOr; handleFunctionCallRequest: ( - request: OutboundMessage.FunctionCallRequest - ) => PromiseOr; + request: proto.OutboundMessage_FunctionCallRequest + ) => PromiseOr; } diff --git a/lib/src/exception.ts b/lib/src/exception.ts index ca2a2a58..932676c2 100644 --- a/lib/src/exception.ts +++ b/lib/src/exception.ts @@ -11,12 +11,12 @@ export class Exception extends Error implements SassException { readonly sassStack: string; readonly span: SourceSpan; - constructor(failure: proto.OutboundMessage.CompileResponse.CompileFailure) { - super(failure.getFormatted()); + constructor(failure: proto.OutboundMessage_CompileResponse_CompileFailure) { + super(failure.formatted); - this.sassMessage = failure.getMessage(); - this.sassStack = failure.getStackTrace(); - this.span = deprotofySourceSpan(failure.getSpan()!); + this.sassMessage = failure.message; + this.sassStack = failure.stackTrace; + this.span = deprotofySourceSpan(failure.span!); } toString() { diff --git a/lib/src/function-registry.ts b/lib/src/function-registry.ts index dc0c0e62..dfd36f02 100644 --- a/lib/src/function-registry.ts +++ b/lib/src/function-registry.ts @@ -7,11 +7,8 @@ import {inspect} from 'util'; import * as types from './vendor/sass'; import * as utils from './utils'; import {CustomFunction} from './vendor/sass'; -import { - InboundMessage, - OutboundMessage, -} from './vendor/embedded-protocol/embedded_sass_pb'; -import {PromiseOr, catchOr, thenOr} from './utils'; +import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import {PromiseOr, catchOr, compilerError, thenOr} from './utils'; import {Protofier} from './protofier'; import {Value} from './value'; @@ -55,8 +52,8 @@ export class FunctionRegistry { * Returns the function to which `request` refers and returns its response. */ call( - request: OutboundMessage.FunctionCallRequest - ): PromiseOr { + request: proto.OutboundMessage_FunctionCallRequest + ): PromiseOr { const protofier = new Protofier(this); const fn = this.get(request); @@ -64,61 +61,60 @@ export class FunctionRegistry { () => { return thenOr( fn( - request - .getArgumentsList() - .map(value => protofier.deprotofy(value) as types.Value) + request.arguments.map( + value => protofier.deprotofy(value) as types.Value + ) ), result => { if (!(result instanceof Value)) { const name = - request.getName().length === 0 - ? 'anonymous function' - : `"${request.getName()}"`; + request.identifier.case === 'name' + ? `"${request.identifier.value}"` + : 'anonymous function'; throw ( `options.functions: ${name} returned non-Value: ` + inspect(result) ); } - const response = new InboundMessage.FunctionCallResponse(); - response.setSuccess(protofier.protofy(result)); - response.setAccessedArgumentListsList( - protofier.accessedArgumentLists - ); - return response; + return new proto.InboundMessage_FunctionCallResponse({ + result: {case: 'success', value: protofier.protofy(result)}, + accessedArgumentLists: protofier.accessedArgumentLists, + }); } ); }, - error => { - const response = new InboundMessage.FunctionCallResponse(); - response.setError(`${error}`); - return response; - } + error => + new proto.InboundMessage_FunctionCallResponse({ + result: {case: 'error', value: `${error}`}, + }) ); } /** Returns the function to which `request` refers. */ private get( - request: OutboundMessage.FunctionCallRequest + request: proto.OutboundMessage_FunctionCallRequest ): CustomFunction { - if ( - request.getIdentifierCase() === - OutboundMessage.FunctionCallRequest.IdentifierCase.NAME - ) { - const fn = this.functionsByName.get(request.getName()); + if (request.identifier.case === 'name') { + const fn = this.functionsByName.get(request.identifier.value); if (fn) return fn; - throw new Error( - 'Invalid OutboundMessage.FunctionCallRequest: there is no function ' + - `named "${request.getName()}"` + throw compilerError( + 'Invalid OutboundMessage_FunctionCallRequest: there is no function ' + + `named "${request.identifier.value}"` ); - } else { - const fn = this.functionsById.get(request.getFunctionId()); + } else if (request.identifier.case === 'functionId') { + const fn = this.functionsById.get(request.identifier.value); if (fn) return fn; - throw new Error( - 'Invalid OutboundMessage.FunctionCallRequest: there is no function ' + - `with ID "${request.getFunctionId()}"` + throw compilerError( + 'Invalid OutboundMessage_FunctionCallRequest: there is no function ' + + `with ID "${request.identifier.value}"` + ); + } else { + throw compilerError( + 'Invalid OutboundMessage_FunctionCallRequest: function identifier is ' + + 'unset' ); } } diff --git a/lib/src/importer-registry.ts b/lib/src/importer-registry.ts index 94e3a046..4dbb268a 100644 --- a/lib/src/importer-registry.ts +++ b/lib/src/importer-registry.ts @@ -8,10 +8,7 @@ import {inspect} from 'util'; import * as utils from './utils'; import {FileImporter, Importer, Options} from './vendor/sass'; -import { - InboundMessage, - OutboundMessage, -} from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; import {catchOr, thenOr, PromiseOr} from './utils'; /** @@ -20,7 +17,7 @@ import {catchOr, thenOr, PromiseOr} from './utils'; */ export class ImporterRegistry { /** Protocol buffer representations of the registered importers. */ - readonly importers: InboundMessage.CompileRequest.Importer[]; + readonly importers: proto.InboundMessage_CompileRequest_Importer[]; /** A map from importer IDs to their corresponding importers. */ private readonly importersById = new Map>(); @@ -35,19 +32,20 @@ export class ImporterRegistry { this.importers = (options?.importers ?? []) .map(importer => this.register(importer)) .concat( - (options?.loadPaths ?? []).map(path => { - const proto = new InboundMessage.CompileRequest.Importer(); - proto.setPath(p.resolve(path)); - return proto; - }) + (options?.loadPaths ?? []).map( + path => + new proto.InboundMessage_CompileRequest_Importer({ + importer: {case: 'path', value: p.resolve(path)}, + }) + ) ); } /** Converts an importer to a proto without adding it to `this.importers`. */ register( importer: Importer | FileImporter - ): InboundMessage.CompileRequest.Importer { - const proto = new InboundMessage.CompileRequest.Importer(); + ): proto.InboundMessage_CompileRequest_Importer { + const response = new proto.InboundMessage_CompileRequest_Importer(); if ('canonicalize' in importer) { if ('findFileUrl' in importer) { throw new Error( @@ -56,21 +54,21 @@ export class ImporterRegistry { ); } - proto.setImporterId(this.id); + response.importer = {case: 'importerId', value: this.id}; this.importersById.set(this.id, importer); } else { - proto.setFileImporterId(this.id); + response.importer = {case: 'fileImporterId', value: this.id}; this.fileImportersById.set(this.id, importer); } this.id += 1; - return proto; + return response; } /** Handles a canonicalization request. */ canonicalize( - request: OutboundMessage.CanonicalizeRequest - ): PromiseOr { - const importer = this.importersById.get(request.getImporterId()); + request: proto.OutboundMessage_CanonicalizeRequest + ): PromiseOr { + const importer = this.importersById.get(request.importerId); if (!importer) { throw utils.compilerError('Unknown CanonicalizeRequest.importer_id'); } @@ -78,77 +76,78 @@ export class ImporterRegistry { return catchOr( () => { return thenOr( - importer.canonicalize(request.getUrl(), { - fromImport: request.getFromImport(), + importer.canonicalize(request.url, { + fromImport: request.fromImport, }), - url => { - const proto = new InboundMessage.CanonicalizeResponse(); - if (url !== null) proto.setUrl(url.toString()); - return proto; - } + url => + new proto.InboundMessage_CanonicalizeResponse({ + result: + url === null + ? {case: undefined} + : {case: 'url', value: url.toString()}, + }) ); }, - error => { - const proto = new InboundMessage.CanonicalizeResponse(); - proto.setError(`${error}`); - return proto; - } + error => + new proto.InboundMessage_CanonicalizeResponse({ + result: {case: 'error', value: `${error}`}, + }) ); } /** Handles an import request. */ import( - request: OutboundMessage.ImportRequest - ): PromiseOr { - const importer = this.importersById.get(request.getImporterId()); + request: proto.OutboundMessage_ImportRequest + ): PromiseOr { + const importer = this.importersById.get(request.importerId); if (!importer) { throw utils.compilerError('Unknown ImportRequest.importer_id'); } return catchOr( () => { - return thenOr(importer.load(new URL(request.getUrl())), result => { - const proto = new InboundMessage.ImportResponse(); - if (result) { - if (typeof result.contents !== 'string') { - throw Error( - `Invalid argument (contents): must be a string but was: ${ - (result.contents as {}).constructor.name - }` - ); - } - - if (result.sourceMapUrl && !result.sourceMapUrl.protocol) { - throw Error( - 'Invalid argument (sourceMapUrl): must be absolute but was: ' + - result.sourceMapUrl - ); - } + return thenOr(importer.load(new URL(request.url)), result => { + if (!result) return new proto.InboundMessage_ImportResponse(); + + if (typeof result.contents !== 'string') { + throw Error( + `Invalid argument (contents): must be a string but was: ${ + (result.contents as {}).constructor.name + }` + ); + } - const success = new InboundMessage.ImportResponse.ImportSuccess(); - success.setContents(result.contents); - success.setSyntax(utils.protofySyntax(result.syntax)); - if (result.sourceMapUrl) { - success.setSourceMapUrl(result.sourceMapUrl.toString()); - } - proto.setSuccess(success); + if (result.sourceMapUrl && !result.sourceMapUrl.protocol) { + throw Error( + 'Invalid argument (sourceMapUrl): must be absolute but was: ' + + result.sourceMapUrl + ); } - return proto; + + return new proto.InboundMessage_ImportResponse({ + result: { + case: 'success', + value: new proto.InboundMessage_ImportResponse_ImportSuccess({ + contents: result.contents, + syntax: utils.protofySyntax(result.syntax), + sourceMapUrl: result.sourceMapUrl?.toString() ?? '', + }), + }, + }); }); }, - error => { - const proto = new InboundMessage.ImportResponse(); - proto.setError(`${error}`); - return proto; - } + error => + new proto.InboundMessage_ImportResponse({ + result: {case: 'error', value: `${error}`}, + }) ); } /** Handles a file import request. */ fileImport( - request: OutboundMessage.FileImportRequest - ): PromiseOr { - const importer = this.fileImportersById.get(request.getImporterId()); + request: proto.OutboundMessage_FileImportRequest + ): PromiseOr { + const importer = this.fileImportersById.get(request.importerId); if (!importer) { throw utils.compilerError('Unknown FileImportRequest.importer_id'); } @@ -156,29 +155,27 @@ export class ImporterRegistry { return catchOr( () => { return thenOr( - importer.findFileUrl(request.getUrl(), { - fromImport: request.getFromImport(), + importer.findFileUrl(request.url, { + fromImport: request.fromImport, }), url => { - const proto = new InboundMessage.FileImportResponse(); - if (url) { - if (url.protocol !== 'file:') { - throw ( - `FileImporter ${inspect(importer)} returned non-file: URL ` + - +`"${url}" for URL "${request.getUrl()}".` - ); - } - proto.setFileUrl(url.toString()); + if (!url) return new proto.InboundMessage_FileImportResponse(); + if (url.protocol !== 'file:') { + throw ( + `FileImporter ${inspect(importer)} returned non-file: URL ` + + +`"${url}" for URL "${request.url}".` + ); } - return proto; + return new proto.InboundMessage_FileImportResponse({ + result: {case: 'fileUrl', value: url.toString()}, + }); } ); }, - error => { - const proto = new InboundMessage.FileImportResponse(); - proto.setError(`${error}`); - return proto; - } + error => + new proto.InboundMessage_FileImportResponse({ + result: {case: 'error', value: `${error}`}, + }) ); } } diff --git a/lib/src/message-transformer.test.ts b/lib/src/message-transformer.test.ts index 641ac325..5d075840 100644 --- a/lib/src/message-transformer.test.ts +++ b/lib/src/message-transformer.test.ts @@ -5,28 +5,30 @@ import {Subject, Observable} from 'rxjs'; import {expectObservableToError} from '../../test/utils'; -import {MessageTransformer, OutboundTypedMessage} from './message-transformer'; -import { - InboundMessage, - OutboundMessage, - ProtocolError, -} from './vendor/embedded-protocol/embedded_sass_pb'; +import {MessageTransformer} from './message-transformer'; +import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; describe('message transformer', () => { let messages: MessageTransformer; - function validInboundMessage(source: string): InboundMessage { - const input = new InboundMessage.CompileRequest.StringInput(); - input.setSource(source); - const request = new InboundMessage.CompileRequest(); - request.setString(input); - const message = new InboundMessage(); - message.setCompileRequest(request); - return message; + function validInboundMessage(source: string): proto.InboundMessage { + return new proto.InboundMessage({ + message: { + case: 'compileRequest', + value: new proto.InboundMessage_CompileRequest({ + input: { + case: 'string', + value: new proto.InboundMessage_CompileRequest_StringInput({ + source, + }), + }, + }), + }, + }); } describe('encode', () => { - let encodedProtobufs: Buffer[]; + let encodedProtobufs: Uint8Array[]; beforeEach(() => { encodedProtobufs = []; @@ -37,21 +39,14 @@ describe('message transformer', () => { it('encodes an InboundMessage to buffer', () => { const message = validInboundMessage('a {b: c}'); - - messages.writeInboundMessage({ - payload: message.getCompileRequest()!, - type: InboundMessage.MessageCase.COMPILE_REQUEST, - }); - - expect(encodedProtobufs).toEqual([ - Buffer.from(message.serializeBinary()), - ]); + messages.writeInboundMessage(message); + expect(encodedProtobufs).toEqual([message.toBinary()]); }); }); describe('decode', () => { let protobufs$: Subject; - let decodedMessages: OutboundTypedMessage[]; + let decodedMessages: proto.OutboundMessage[]; beforeEach(() => { protobufs$ = new Subject(); @@ -66,16 +61,21 @@ describe('message transformer', () => { next: message => decodedMessages.push(message), complete: () => { expect(decodedMessages.length).toBe(1); - const response = decodedMessages[0] - .payload as OutboundMessage.CompileResponse; - expect(response.getSuccess()?.getCss()).toBe('a {b: c}'); - const type = decodedMessages[0].type; - expect(type).toEqual(OutboundMessage.MessageCase.COMPILE_RESPONSE); + expect(decodedMessages[0].message.case).toBe('compileResponse'); + const response = decodedMessages[0].message + .value as proto.OutboundMessage_CompileResponse; + expect(response.result.case).toBe('success'); + expect( + ( + response.result + .value as proto.OutboundMessage_CompileResponse_CompileSuccess + ).css + ).toBe('a {b: c}'); done(); }, }); - protobufs$.next(Buffer.from(message.serializeBinary())); + protobufs$.next(Buffer.from(message.toBinary())); protobufs$.complete(); }); @@ -89,57 +89,6 @@ describe('message transformer', () => { protobufs$.next(Buffer.from([-1])); }); - - it('fails on empty message', done => { - expectObservableToError( - messages.outboundMessages$, - 'Compiler caused error: OutboundMessage.message is not set.', - done - ); - - protobufs$.next(Buffer.from(new OutboundMessage().serializeBinary())); - }); - - it('fails on compile response with missing result', done => { - expectObservableToError( - messages.outboundMessages$, - 'Compiler caused error: OutboundMessage.CompileResponse.result is not set.', - done - ); - - const response = new OutboundMessage.CompileResponse(); - const message = new OutboundMessage(); - message.setCompileResponse(response); - protobufs$.next(Buffer.from(message.serializeBinary())); - }); - - it('fails on function call request with missing identifier', done => { - expectObservableToError( - messages.outboundMessages$, - 'Compiler caused error: OutboundMessage.FunctionCallRequest.identifier is not set.', - done - ); - - const request = new OutboundMessage.FunctionCallRequest(); - const message = new OutboundMessage(); - message.setFunctionCallRequest(request); - protobufs$.next(Buffer.from(message.serializeBinary())); - }); - - it('fails if message contains a protocol error', done => { - const errorMessage = 'sad'; - expectObservableToError( - messages.outboundMessages$, - `Compiler reported error: ${errorMessage}.`, - done - ); - - const error = new ProtocolError(); - error.setMessage(errorMessage); - const message = new OutboundMessage(); - message.setError(error); - protobufs$.next(Buffer.from(message.serializeBinary())); - }); }); }); }); diff --git a/lib/src/message-transformer.ts b/lib/src/message-transformer.ts index bce04283..cfdd8be5 100644 --- a/lib/src/message-transformer.ts +++ b/lib/src/message-transformer.ts @@ -5,84 +5,30 @@ import {Observable, Subject} from 'rxjs'; import {map} from 'rxjs/operators'; -import {compilerError, hostError} from './utils'; +import {compilerError} from './utils'; import { InboundMessage, OutboundMessage, } from './vendor/embedded-protocol/embedded_sass_pb'; -export type InboundRequestType = InboundMessage.MessageCase.COMPILE_REQUEST; - -export type InboundRequest = InboundMessage.CompileRequest; - -export type InboundResponseType = - | InboundMessage.MessageCase.IMPORT_RESPONSE - | InboundMessage.MessageCase.FILE_IMPORT_RESPONSE - | InboundMessage.MessageCase.CANONICALIZE_RESPONSE - | InboundMessage.MessageCase.FUNCTION_CALL_RESPONSE; - -export type InboundResponse = - | InboundMessage.ImportResponse - | InboundMessage.FileImportResponse - | InboundMessage.CanonicalizeResponse - | InboundMessage.FunctionCallResponse; - -export type OutboundRequestType = - | OutboundMessage.MessageCase.IMPORT_REQUEST - | OutboundMessage.MessageCase.FILE_IMPORT_REQUEST - | OutboundMessage.MessageCase.CANONICALIZE_REQUEST - | OutboundMessage.MessageCase.FUNCTION_CALL_REQUEST; - -export type OutboundRequest = - | OutboundMessage.ImportRequest - | OutboundMessage.FileImportRequest - | OutboundMessage.CanonicalizeRequest - | OutboundMessage.FunctionCallRequest; - -export type OutboundResponseType = OutboundMessage.MessageCase.COMPILE_RESPONSE; - -export type OutboundResponse = OutboundMessage.CompileResponse; - -export type OutboundEventType = OutboundMessage.MessageCase.LOG_EVENT; - -export type OutboundEvent = OutboundMessage.LogEvent; - -export type InboundTypedMessage = { - payload: InboundRequest | InboundResponse; - type: InboundRequestType | InboundResponseType; -}; - -export type OutboundTypedMessage = { - payload: OutboundRequest | OutboundResponse | OutboundEvent; - type: OutboundRequestType | OutboundResponseType | OutboundEventType; -}; - /** - * Encodes InboundTypedMessages into protocol buffers and decodes protocol - * buffers into OutboundTypedMessages. Any Embedded Protocol violations that can - * be detected at the message level are encapsulated here and reported as - * errors. - * - * This transformer communicates via In/OutboundTypedMessages instead of raw - * In/OutboundMessages in order to expose more type information to consumers. - * This makes the stream of messages from the transformer easier to interact - * with. + * Encodes InboundMessages into protocol buffers and decodes protocol buffers + * into OutboundMessages. */ export class MessageTransformer { // The decoded messages are written to this Subject. It is publicly exposed // as a readonly Observable. - private readonly outboundMessagesInternal$ = - new Subject(); + private readonly outboundMessagesInternal$ = new Subject(); /** - * The OutboundTypedMessages, decoded from protocol buffers. If any errors are - * detected while encoding/decoding, this Observable will error out. + * The OutboundMessages, decoded from protocol buffers. If this fails to + * decode a message, it will emit an error. */ readonly outboundMessages$ = this.outboundMessagesInternal$.pipe(); constructor( - private readonly outboundProtobufs$: Observable, - private readonly writeInboundProtobuf: (buffer: Buffer) => void + private readonly outboundProtobufs$: Observable, + private readonly writeInboundProtobuf: (buffer: Uint8Array) => void ) { this.outboundProtobufs$ .pipe(map(decode)) @@ -92,107 +38,22 @@ export class MessageTransformer { /** * Converts the inbound `message` to a protocol buffer. */ - writeInboundMessage(message: InboundTypedMessage): void { + writeInboundMessage(message: InboundMessage): void { try { - this.writeInboundProtobuf(encode(message)); + this.writeInboundProtobuf(message.toBinary()); } catch (error) { this.outboundMessagesInternal$.error(error); } } } -// Decodes a protobuf `buffer` into an OutboundTypedMessage, ensuring that all +// Decodes a protobuf `buffer` into an OutboundMessage, ensuring that all // mandatory message fields are populated. Throws if `buffer` cannot be decoded // into a valid message, or if the message itself contains a Protocol Error. -function decode(buffer: Buffer): OutboundTypedMessage { - let message; +function decode(buffer: Uint8Array): OutboundMessage { try { - message = OutboundMessage.deserializeBinary(buffer); + return OutboundMessage.fromBinary(buffer); } catch (error) { throw compilerError('Invalid buffer'); } - - let payload; - const type = message.getMessageCase(); - switch (type) { - case OutboundMessage.MessageCase.LOG_EVENT: - payload = message.getLogEvent(); - break; - case OutboundMessage.MessageCase.COMPILE_RESPONSE: - if ( - message.getCompileResponse()?.getResultCase() === - OutboundMessage.CompileResponse.ResultCase.RESULT_NOT_SET - ) { - throw compilerError( - 'OutboundMessage.CompileResponse.result is not set' - ); - } - payload = message.getCompileResponse(); - break; - case OutboundMessage.MessageCase.IMPORT_REQUEST: - payload = message.getImportRequest(); - break; - case OutboundMessage.MessageCase.FILE_IMPORT_REQUEST: - payload = message.getFileImportRequest(); - break; - case OutboundMessage.MessageCase.CANONICALIZE_REQUEST: - payload = message.getCanonicalizeRequest(); - break; - case OutboundMessage.MessageCase.FUNCTION_CALL_REQUEST: - if ( - message.getFunctionCallRequest()?.getIdentifierCase() === - OutboundMessage.FunctionCallRequest.IdentifierCase.IDENTIFIER_NOT_SET - ) { - throw compilerError( - 'OutboundMessage.FunctionCallRequest.identifier is not set' - ); - } - payload = message.getFunctionCallRequest(); - break; - case OutboundMessage.MessageCase.ERROR: - throw hostError(`${message.getError()?.getMessage()}`); - case OutboundMessage.MessageCase.MESSAGE_NOT_SET: - throw compilerError('OutboundMessage.message is not set'); - default: - throw compilerError(`Unknown message type ${message.toString()}`); - } - - if (!payload) throw compilerError('OutboundMessage missing payload'); - return { - payload, - type, - }; -} - -// Encodes an InboundTypedMessage into a protocol buffer. -function encode(message: InboundTypedMessage): Buffer { - const inboundMessage = new InboundMessage(); - switch (message.type) { - case InboundMessage.MessageCase.COMPILE_REQUEST: - inboundMessage.setCompileRequest( - message.payload as InboundMessage.CompileRequest - ); - break; - case InboundMessage.MessageCase.IMPORT_RESPONSE: - inboundMessage.setImportResponse( - message.payload as InboundMessage.ImportResponse - ); - break; - case InboundMessage.MessageCase.FILE_IMPORT_RESPONSE: - inboundMessage.setFileImportResponse( - message.payload as InboundMessage.FileImportResponse - ); - break; - case InboundMessage.MessageCase.CANONICALIZE_RESPONSE: - inboundMessage.setCanonicalizeResponse( - message.payload as InboundMessage.CanonicalizeResponse - ); - break; - case InboundMessage.MessageCase.FUNCTION_CALL_RESPONSE: - inboundMessage.setFunctionCallResponse( - message.payload as InboundMessage.FunctionCallResponse - ); - break; - } - return Buffer.from(inboundMessage.serializeBinary()); } diff --git a/lib/src/messages.ts b/lib/src/messages.ts new file mode 100644 index 00000000..5d827845 --- /dev/null +++ b/lib/src/messages.ts @@ -0,0 +1,70 @@ +// Copyright 2023 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. + +import { + InboundMessage, + OutboundMessage, +} from './vendor/embedded-protocol/embedded_sass_pb'; + +// Given a message type `M` (either `InboundMessage` or `OutboundMessage`) and a +// union of possible message cases `T`, returns all the child types `M` contains +// whose cases match `T`. +type MessagesOfType = (M & { + message: {case: T; value: unknown}; +})['message']['value']; + +/** + * The names of inbound messages that are requests from the host to the + * compiler. + */ +export type InboundRequestType = 'compileRequest'; + +/** Inbound messages that are requests from the host to the compiler. */ +export type InboundRequest = MessagesOfType; + +/** + * The names of inbound of messages that are responses to `OutboundRequest`s. + */ +export type InboundResponseType = + | 'importResponse' + | 'fileImportResponse' + | 'canonicalizeResponse' + | 'functionCallResponse'; + +/** Inbound messages that are responses to `OutboundRequest`s. */ +export type InboundResponse = MessagesOfType< + InboundMessage, + InboundResponseType +>; + +/** + * The names of outbound messages that are requests from the host to the + * compiler. + */ +export type OutboundRequestType = + | 'importRequest' + | 'fileImportRequest' + | 'canonicalizeRequest' + | 'functionCallRequest'; + +/** Outbound messages that are requests from the host to the compiler. */ +export type OutboundRequest = MessagesOfType< + OutboundMessage, + OutboundRequestType +>; + +/** The names of inbound messages that are responses to `InboundRequest`s. */ +export type OutboundResponseType = 'compileResponse'; + +/** Inbound messages that are responses to `InboundRequest`s. */ +export type OutboundResponse = MessagesOfType< + OutboundMessage, + OutboundResponseType +>; + +/** The names of outbound messages that don't require responses. */ +export type OutboundEventType = 'logEvent'; + +/** Outbound messages that don't require responses. */ +export type OutboundEvent = MessagesOfType; diff --git a/lib/src/packet-transformer.ts b/lib/src/packet-transformer.ts index 2d1e8e35..0322216b 100644 --- a/lib/src/packet-transformer.ts +++ b/lib/src/packet-transformer.ts @@ -35,7 +35,7 @@ export class PacketTransformer { readonly outboundProtobufs$ = this.outboundProtobufsInternal$.pipe(); constructor( - private readonly outboundBuffers$: Observable, + private readonly outboundBuffers$: Observable, private readonly writeInboundBuffer: (buffer: Buffer) => void ) { this.outboundBuffers$ @@ -47,7 +47,7 @@ export class PacketTransformer { * Encodes a packet by pre-fixing `protobuf` with a header that describes its * length. */ - writeInboundProtobuf(protobuf: Buffer): void { + writeInboundProtobuf(protobuf: Uint8Array): void { try { let length = protobuf.length; if (length === 0) { @@ -77,7 +77,7 @@ export class PacketTransformer { // Decodes a buffer, filling up the packet that is actively being decoded. // Returns a list of decoded payloads. - private decode(buffer: Buffer): Buffer[] { + private decode(buffer: Uint8Array): Buffer[] { const payloads: Buffer[] = []; let decodedBytes = 0; while (decodedBytes < buffer.length) { @@ -124,7 +124,7 @@ class Packet { * packet. This method can be called repeatedly, incrementally building * up the packet until it is complete. */ - write(source: Buffer): number { + write(source: Uint8Array): number { if (this.isComplete) { throw Error('Cannot write to a completed Packet.'); } diff --git a/lib/src/protofier.ts b/lib/src/protofier.ts index 5ea355dc..ba5420db 100644 --- a/lib/src/protofier.ts +++ b/lib/src/protofier.ts @@ -51,97 +51,85 @@ export class Protofier { protofy(value: Value): proto.Value { const result = new proto.Value(); if (value instanceof SassString) { - const string = new proto.Value.String(); - string.setText(value.text); - string.setQuoted(value.hasQuotes); - result.setString(string); + const string = new proto.Value_String(); + string.text = value.text; + string.quoted = value.hasQuotes; + result.value = {case: 'string', value: string}; } else if (value instanceof SassNumber) { - result.setNumber(this.protofyNumber(value)); + const number = new proto.Value_Number(); + number.value = value.value; + number.numerators = value.numeratorUnits.toArray(); + number.denominators = value.denominatorUnits.toArray(); + result.value = {case: 'number', value: number}; } else if (value instanceof SassColor) { if (value.hasCalculatedHsl) { - const color = new proto.Value.HslColor(); - color.setHue(value.hue); - color.setSaturation(value.saturation); - color.setLightness(value.lightness); - color.setAlpha(value.alpha); - result.setHslColor(color); + const color = new proto.Value_HslColor(); + color.hue = value.hue; + color.saturation = value.saturation; + color.lightness = value.lightness; + color.alpha = value.alpha; + result.value = {case: 'hslColor', value: color}; } else { - const color = new proto.Value.RgbColor(); - color.setRed(value.red); - color.setGreen(value.green); - color.setBlue(value.blue); - color.setAlpha(value.alpha); - result.setRgbColor(color); + const color = new proto.Value_RgbColor(); + color.red = value.red; + color.green = value.green; + color.blue = value.blue; + color.alpha = value.alpha; + result.value = {case: 'rgbColor', value: color}; } } else if (value instanceof SassList) { - const list = new proto.Value.List(); - list.setSeparator(this.protofySeparator(value.separator)); - list.setHasBrackets(value.hasBrackets); + const list = new proto.Value_List(); + list.separator = this.protofySeparator(value.separator); + list.hasBrackets = value.hasBrackets; for (const element of value.asList) { - list.addContents(this.protofy(element)); + list.contents.push(this.protofy(element)); } - result.setList(list); + result.value = {case: 'list', value: list}; } else if (value instanceof SassArgumentList) { - const list = new proto.Value.ArgumentList(); - list.setId(value.id); - list.setSeparator(this.protofySeparator(value.separator)); - for (const element of value.asList) { - list.addContents(this.protofy(element)); - } - const keywords = list.getKeywordsMap(); + const list = new proto.Value_ArgumentList(); + list.id = value.id; + list.separator = this.protofySeparator(value.separator); + list.contents = value.asList + .map(element => this.protofy(element)) + .toArray(); for (const [key, mapValue] of value.keywordsInternal) { - keywords.set(key, this.protofy(mapValue)); + list.keywords[key] = this.protofy(mapValue); } - result.setArgumentList(list); + result.value = {case: 'argumentList', value: list}; } else if (value instanceof SassMap) { - const map = new proto.Value.Map(); + const map = new proto.Value_Map(); for (const [key, mapValue] of value.contents) { - const entry = new proto.Value.Map.Entry(); - entry.setKey(this.protofy(key)); - entry.setValue(this.protofy(mapValue)); - map.addEntries(entry); + const entry = new proto.Value_Map_Entry(); + entry.key = this.protofy(key); + entry.value = this.protofy(mapValue); + map.entries.push(entry); } - result.setMap(map); + result.value = {case: 'map', value: map}; } else if (value instanceof SassFunction) { if (value.id !== undefined) { - const fn = new proto.Value.CompilerFunction(); - fn.setId(value.id); - result.setCompilerFunction(fn); + const fn = new proto.Value_CompilerFunction(); + fn.id = value.id; + result.value = {case: 'compilerFunction', value: fn}; } else { - const fn = new proto.Value.HostFunction(); - fn.setId(this.functions.register(value.callback!)); - fn.setSignature(value.signature!); - result.setHostFunction(fn); + const fn = new proto.Value_HostFunction(); + fn.id = this.functions.register(value.callback!); + fn.signature = value.signature!; + result.value = {case: 'hostFunction', value: fn}; } } else if (value === sassTrue) { - result.setSingleton(proto.SingletonValue.TRUE); + result.value = {case: 'singleton', value: proto.SingletonValue.TRUE}; } else if (value === sassFalse) { - result.setSingleton(proto.SingletonValue.FALSE); + result.value = {case: 'singleton', value: proto.SingletonValue.FALSE}; } else if (value === sassNull) { - result.setSingleton(proto.SingletonValue.NULL); + result.value = {case: 'singleton', value: proto.SingletonValue.NULL}; } else { throw utils.compilerError(`Unknown Value ${value}`); } return result; } - /** Converts `number` to its protocol buffer representation. */ - private protofyNumber(number: SassNumber): proto.Value.Number { - const value = new proto.Value.Number(); - value.setValue(number.value); - for (const unit of number.numeratorUnits) { - value.addNumerators(unit); - } - for (const unit of number.denominatorUnits) { - value.addDenominators(unit); - } - return value; - } - /** Converts `separator` to its protocol buffer representation. */ - private protofySeparator( - separator: ListSeparator - ): proto.ListSeparatorMap[keyof proto.ListSeparatorMap] { + private protofySeparator(separator: ListSeparator): proto.ListSeparator { switch (separator) { case ',': return proto.ListSeparator.COMMA; @@ -158,138 +146,125 @@ export class Protofier { /** Converts `value` to its JS representation. */ deprotofy(value: proto.Value): Value { - switch (value.getValueCase()) { - case proto.Value.ValueCase.STRING: { - const string = value.getString()!; - return string.getText().length === 0 - ? SassString.empty({quotes: string.getQuoted()}) - : new SassString(string.getText(), {quotes: string.getQuoted()}); + switch (value.value.case) { + case 'string': { + const string = value.value.value; + return string.text.length === 0 + ? SassString.empty({quotes: string.quoted}) + : new SassString(string.text, {quotes: string.quoted}); } - case proto.Value.ValueCase.NUMBER: - return this.deprotofyNumber(value.getNumber()!); + case 'number': { + const number = value.value.value; + return new SassNumber(number.value, { + numeratorUnits: number.numerators, + denominatorUnits: number.denominators, + }); + } - case proto.Value.ValueCase.RGB_COLOR: { - const color = value.getRgbColor()!; + case 'rgbColor': { + const color = value.value.value; return new SassColor({ - red: color.getRed(), - green: color.getGreen(), - blue: color.getBlue(), - alpha: color.getAlpha(), + red: color.red, + green: color.green, + blue: color.blue, + alpha: color.alpha, }); } - case proto.Value.ValueCase.HSL_COLOR: { - const color = value.getHslColor()!; + case 'hslColor': { + const color = value.value.value; return new SassColor({ - hue: color.getHue(), - saturation: color.getSaturation(), - lightness: color.getLightness(), - alpha: color.getAlpha(), + hue: color.hue, + saturation: color.saturation, + lightness: color.lightness, + alpha: color.alpha, }); } - case proto.Value.ValueCase.LIST: { - const list = value.getList()!; - const separator = this.deprotofySeparator(list.getSeparator()); + case 'list': { + const list = value.value.value; + const separator = this.deprotofySeparator(list.separator); - const contents = list.getContentsList(); - if (separator === null && contents.length > 1) { + if (separator === null && list.contents.length > 1) { throw utils.compilerError( `Value.List ${list} can't have an undecided separator because it ` + - `has ${contents.length} elements` + `has ${list.contents.length} elements` ); } return new SassList( - contents.map(element => this.deprotofy(element)), - {separator, brackets: list.getHasBrackets()} + list.contents.map(element => this.deprotofy(element)), + {separator, brackets: list.hasBrackets} ); } - case proto.Value.ValueCase.ARGUMENT_LIST: { - const list = value.getArgumentList()!; - const separator = this.deprotofySeparator(list.getSeparator()); + case 'argumentList': { + const list = value.value.value; + const separator = this.deprotofySeparator(list.separator); - const contents = list.getContentsList(); - if (separator === null && contents.length > 1) { + if (separator === null && list.contents.length > 1) { throw utils.compilerError( `Value.List ${list} can't have an undecided separator because it ` + - `has ${contents.length} elements` + `has ${list.contents.length} elements` ); } const result = new SassArgumentList( - contents.map(element => this.deprotofy(element)), + list.contents.map(element => this.deprotofy(element)), OrderedMap( - [...list.getKeywordsMap().entries()].map(([key, value]) => [ + Object.entries(list.keywords).map(([key, value]) => [ key, this.deprotofy(value), ]) ), separator, - list.getId() + list.id ); this.argumentLists.push(result); return result; } - case proto.Value.ValueCase.MAP: + case 'map': return new SassMap( OrderedMap( - value - .getMap()! - .getEntriesList() - .map(entry => { - const key = entry.getKey(); - if (!key) throw utils.mandatoryError('Value.Map.Entry.key'); - const value = entry.getValue(); - if (!value) throw utils.mandatoryError('Value.Map.Entry.value'); + value.value.value.entries.map(entry => { + const key = entry.key; + if (!key) throw utils.mandatoryError('Value.Map.Entry.key'); + const value = entry.value; + if (!value) throw utils.mandatoryError('Value.Map.Entry.value'); - return [this.deprotofy(key), this.deprotofy(value)]; - }) + return [this.deprotofy(key), this.deprotofy(value)]; + }) ) ); - case proto.Value.ValueCase.COMPILER_FUNCTION: - return new SassFunction(value.getCompilerFunction()!.getId()); + case 'compilerFunction': + return new SassFunction(value.value.value.id); - case proto.Value.ValueCase.HOST_FUNCTION: + case 'hostFunction': throw utils.compilerError( 'The compiler may not send Value.host_function.' ); - case proto.Value.ValueCase.SINGLETON: - switch (value.getSingleton()) { + case 'singleton': + switch (value.value.value) { case proto.SingletonValue.TRUE: return sassTrue; case proto.SingletonValue.FALSE: return sassFalse; case proto.SingletonValue.NULL: return sassNull; - default: - throw utils.compilerError( - `Unknown Value.singleton ${value.getSingleton()}` - ); } + // eslint-disable-next-line no-fallthrough default: throw utils.mandatoryError('Value.value'); } } - /** Converts `number` to its JS representation. */ - private deprotofyNumber(number: proto.Value.Number): SassNumber { - return new SassNumber(number.getValue(), { - numeratorUnits: number.getNumeratorsList(), - denominatorUnits: number.getDenominatorsList(), - }); - } - /** Converts `separator` to its JS representation. */ - private deprotofySeparator( - separator: proto.ListSeparatorMap[keyof proto.ListSeparatorMap] - ): ListSeparator { + private deprotofySeparator(separator: proto.ListSeparator): ListSeparator { switch (separator) { case proto.ListSeparator.COMMA: return ','; diff --git a/lib/src/request-tracker.test.ts b/lib/src/request-tracker.test.ts index e74501e6..dd90cba3 100644 --- a/lib/src/request-tracker.test.ts +++ b/lib/src/request-tracker.test.ts @@ -2,10 +2,6 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import { - InboundMessage, - OutboundMessage, -} from './vendor/embedded-protocol/embedded_sass_pb'; import {RequestTracker} from './request-tracker'; describe('request tracker', () => { @@ -21,74 +17,73 @@ describe('request tracker', () => { describe('tracking requests', () => { it('tracks when empty', () => { - tracker.add(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); + tracker.add(0, 'compileResponse'); expect(tracker.nextId).toBe(1); }); it('tracks multiple requests', () => { - tracker.add(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.add(1, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.add(2, OutboundMessage.MessageCase.COMPILE_RESPONSE); + tracker.add(0, 'compileResponse'); + tracker.add(1, 'compileResponse'); + tracker.add(2, 'compileResponse'); expect(tracker.nextId).toBe(3); }); it('tracks starting from a non-zero ID', () => { - tracker.add(1, OutboundMessage.MessageCase.COMPILE_RESPONSE); + tracker.add(1, 'compileResponse'); expect(tracker.nextId).toBe(0); - tracker.add(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); + tracker.add(0, 'compileResponse'); expect(tracker.nextId).toBe(2); }); it('errors if the request ID is invalid', () => { - expect(() => - tracker.add(-1, OutboundMessage.MessageCase.COMPILE_RESPONSE) - ).toThrowError('Invalid request ID -1.'); + expect(() => tracker.add(-1, 'compileResponse')).toThrowError( + 'Invalid request ID -1.' + ); }); it('errors if the request ID overlaps that of an existing in-flight request', () => { - tracker.add(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); - expect(() => - tracker.add(0, OutboundMessage.MessageCase.COMPILE_RESPONSE) - ).toThrowError('Request ID 0 is already in use by an in-flight request.'); + tracker.add(0, 'compileResponse'); + expect(() => tracker.add(0, 'compileResponse')).toThrowError( + 'Request ID 0 is already in use by an in-flight request.' + ); }); }); describe('resolving requests', () => { it('resolves a single request', () => { - tracker.add(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.resolve(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); + tracker.add(0, 'compileResponse'); + tracker.resolve(0, 'compileResponse'); expect(tracker.nextId).toBe(0); }); it('resolves multiple requests', () => { - tracker.add(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.add(1, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.add(2, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.resolve(1, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.resolve(2, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.resolve(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); + tracker.add(0, 'compileResponse'); + tracker.add(1, 'compileResponse'); + tracker.add(2, 'compileResponse'); + tracker.resolve(1, 'compileResponse'); + tracker.resolve(2, 'compileResponse'); + tracker.resolve(0, 'compileResponse'); expect(tracker.nextId).toBe(0); }); it('reuses the ID of a resolved request', () => { - tracker.add(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.add(1, OutboundMessage.MessageCase.COMPILE_RESPONSE); - tracker.resolve(0, OutboundMessage.MessageCase.COMPILE_RESPONSE); + tracker.add(0, 'compileResponse'); + tracker.add(1, 'compileResponse'); + tracker.resolve(0, 'compileResponse'); expect(tracker.nextId).toBe(0); }); it('errors if the response ID does not match any existing request IDs', () => { - expect(() => - tracker.resolve(0, OutboundMessage.MessageCase.COMPILE_RESPONSE) - ).toThrowError('Response ID 0 does not match any pending requests.'); + expect(() => tracker.resolve(0, 'compileResponse')).toThrowError( + 'Response ID 0 does not match any pending requests.' + ); }); it('errors if the response type does not match what the request is expecting', () => { - tracker.add(0, InboundMessage.MessageCase.IMPORT_RESPONSE); - expect(() => - tracker.resolve(0, InboundMessage.MessageCase.FILE_IMPORT_RESPONSE) - ).toThrowError( - "Response with ID 0 does not match pending request's type. Expected 4 but received 5." + tracker.add(0, 'importResponse'); + expect(() => tracker.resolve(0, 'fileImportResponse')).toThrowError( + "Response with ID 0 does not match pending request's type. Expected " + + 'importResponse but received fileImportResponse.' ); }); }); diff --git a/lib/src/request-tracker.ts b/lib/src/request-tracker.ts index 5c8cbbbf..f26db4ca 100644 --- a/lib/src/request-tracker.ts +++ b/lib/src/request-tracker.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {InboundResponseType, OutboundResponseType} from './message-transformer'; +import {InboundResponseType, OutboundResponseType} from './messages'; /** * Manages pending inbound and outbound requests. Ensures that requests and diff --git a/lib/src/utils.ts b/lib/src/utils.ts index ef108bf9..bd6f4c71 100644 --- a/lib/src/utils.ts +++ b/lib/src/utils.ts @@ -121,9 +121,7 @@ export function withoutExtension(path: string): string { } /** Converts a JS syntax string into a protobuf syntax enum. */ -export function protofySyntax( - syntax: Syntax -): proto.SyntaxMap[keyof proto.SyntaxMap] { +export function protofySyntax(syntax: Syntax): proto.Syntax { switch (syntax) { case 'scss': return proto.Syntax.SCSS; diff --git a/package.json b/package.json index 91fd7f92..427882c0 100644 --- a/package.json +++ b/package.json @@ -37,13 +37,15 @@ "sass-embedded-win32-x64": "1.58.0" }, "dependencies": { + "@bufbuild/protobuf": "^1.0.0", + "@bufbuild/protoc-gen-es": "^1.0.0", "buffer-builder": "^0.2.0", - "google-protobuf": "^3.11.4", "immutable": "^4.0.0", "rxjs": "^7.4.0", "supports-color": "^8.1.1" }, "devDependencies": { + "@protobuf-ts/protoc": "^2.8.2", "@types/buffer-builder": "^0.2.0", "@types/google-protobuf": "^3.7.2", "@types/jest": "^29.4.0", @@ -60,13 +62,11 @@ "minipass": "4.0.1", "node-fetch": "^3.3.0", "npm-run-all": "^4.1.5", - "protoc": "1.0.4", "shelljs": "^0.8.4", "source-map-js": "^1.0.2", "tar": "^6.0.5", "ts-jest": "^29.0.5", "ts-node": "^10.2.1", - "ts-protoc-gen": "^0.15.0", "typescript": "^4.4.3", "yaml": "^2.2.1", "yargs": "^17.2.1" diff --git a/test/utils.ts b/test/utils.ts index 1634b5ec..f8733917 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -15,12 +15,16 @@ export function expectObservableToError( done: () => void ): void { observable.subscribe({ - next: () => fail('expected error'), + next: () => { + throw new Error('expected error'); + }, error: error => { expect(error.message).toBe(errorMessage); done(); }, - complete: () => fail('expected error'), + complete: () => { + throw new Error('expected error'); + }, }); } diff --git a/tool/get-embedded-protocol.ts b/tool/get-embedded-protocol.ts index 4c443ab3..850619dc 100644 --- a/tool/get-embedded-protocol.ts +++ b/tool/get-embedded-protocol.ts @@ -44,27 +44,18 @@ export async function getEmbeddedProtocol( // Builds the embedded proto at `repoPath` into a pbjs with TS declaration file. function buildEmbeddedProtocol(repoPath: string): void { const proto = p.join(repoPath, 'embedded_sass.proto'); - const protocPath = - process.platform === 'win32' - ? '%CD%/node_modules/protoc/protoc/bin/protoc.exe' - : 'node_modules/protoc/protoc/bin/protoc'; const version = shell - .exec(`${protocPath} --version`, {silent: true}) + .exec('npx protoc --version', {silent: true}) .stdout.trim(); console.log( - `Building pbjs and TS declaration file from ${proto} with ${version}.` + `Building pbjs and TS declaration file from ${proto} with protoc ` + + `${version}.` ); - const pluginPath = - process.platform === 'win32' - ? '%CD%/node_modules/.bin/protoc-gen-ts.cmd' - : 'node_modules/.bin/protoc-gen-ts'; mkdirSync('build/embedded-protocol', {recursive: true}); shell.exec( - `${protocPath} \ - --plugin="protoc-gen-ts=${pluginPath}" \ - --js_out="import_style=commonjs,binary:build/embedded-protocol" \ - --ts_out="build/embedded-protocol" \ + `npx protoc \ + --es_out="target=ts:build/embedded-protocol" \ --proto_path="${repoPath}" \ ${proto}`, {silent: true} From 6aeb8a0f3954c83abcb7ac50d58de2891683f41a Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 8 Feb 2023 17:59:50 -0800 Subject: [PATCH 09/52] Use buf to compile protobufs (#201) We were using @protobuf-ts/protoc, but that downloads protoc versions live at runtime which causes many problems for CI. buf supports both a standalone GitHub action and an npm installation. --- buf.gen.yaml | 5 ++++ buf.work.yaml | 2 ++ lib/src/compile.ts | 2 +- lib/src/deprotofy-span.ts | 2 +- lib/src/dispatcher.ts | 2 +- lib/src/exception.ts | 2 +- lib/src/function-registry.ts | 2 +- lib/src/importer-registry.ts | 2 +- lib/src/message-transformer.test.ts | 2 +- lib/src/message-transformer.ts | 5 +--- lib/src/messages.ts | 5 +--- lib/src/protofier.ts | 2 +- lib/src/utils.ts | 2 +- package.json | 5 ++-- test/dependencies.test.ts | 2 +- tool/get-embedded-compiler.ts | 4 +-- tool/get-embedded-protocol.ts | 41 ++++++++--------------------- tool/utils.ts | 2 +- tsconfig.json | 1 - 19 files changed, 36 insertions(+), 54 deletions(-) create mode 100644 buf.gen.yaml create mode 100644 buf.work.yaml diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 00000000..e128634a --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,5 @@ +version: v1 +plugins: +- plugin: es + out: lib/src/vendor + opt: target=ts diff --git a/buf.work.yaml b/buf.work.yaml new file mode 100644 index 00000000..0cc295bc --- /dev/null +++ b/buf.work.yaml @@ -0,0 +1,2 @@ +version: v1 +directories: [build/embedded-protocol] diff --git a/lib/src/compile.ts b/lib/src/compile.ts index 87c9ad63..ef29f0aa 100644 --- a/lib/src/compile.ts +++ b/lib/src/compile.ts @@ -6,7 +6,7 @@ import * as p from 'path'; import {Observable} from 'rxjs'; import * as supportsColor from 'supports-color'; -import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded_sass_pb'; import * as utils from './utils'; import {AsyncEmbeddedCompiler} from './async-compiler'; import {CompileResult, Options, SourceSpan, StringOptions} from './vendor/sass'; diff --git a/lib/src/deprotofy-span.ts b/lib/src/deprotofy-span.ts index 2b8ec9fa..bd32762f 100644 --- a/lib/src/deprotofy-span.ts +++ b/lib/src/deprotofy-span.ts @@ -4,7 +4,7 @@ import {URL} from 'url'; -import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded_sass_pb'; import {SourceSpan} from './vendor/sass'; import {compilerError} from './utils'; diff --git a/lib/src/dispatcher.ts b/lib/src/dispatcher.ts index 912df2e4..c04249f7 100644 --- a/lib/src/dispatcher.ts +++ b/lib/src/dispatcher.ts @@ -10,7 +10,7 @@ import { OutboundResponse, OutboundResponseType, } from './messages'; -import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded_sass_pb'; import {RequestTracker} from './request-tracker'; import {PromiseOr, compilerError, thenOr, hostError} from './utils'; diff --git a/lib/src/exception.ts b/lib/src/exception.ts index 932676c2..48eb6dfd 100644 --- a/lib/src/exception.ts +++ b/lib/src/exception.ts @@ -2,7 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded_sass_pb'; import {Exception as SassException, SourceSpan} from './vendor/sass'; import {deprotofySourceSpan} from './deprotofy-span'; diff --git a/lib/src/function-registry.ts b/lib/src/function-registry.ts index dfd36f02..d82acc4a 100644 --- a/lib/src/function-registry.ts +++ b/lib/src/function-registry.ts @@ -7,7 +7,7 @@ import {inspect} from 'util'; import * as types from './vendor/sass'; import * as utils from './utils'; import {CustomFunction} from './vendor/sass'; -import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded_sass_pb'; import {PromiseOr, catchOr, compilerError, thenOr} from './utils'; import {Protofier} from './protofier'; import {Value} from './value'; diff --git a/lib/src/importer-registry.ts b/lib/src/importer-registry.ts index 4dbb268a..7b734940 100644 --- a/lib/src/importer-registry.ts +++ b/lib/src/importer-registry.ts @@ -8,7 +8,7 @@ import {inspect} from 'util'; import * as utils from './utils'; import {FileImporter, Importer, Options} from './vendor/sass'; -import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded_sass_pb'; import {catchOr, thenOr, PromiseOr} from './utils'; /** diff --git a/lib/src/message-transformer.test.ts b/lib/src/message-transformer.test.ts index 5d075840..26a97e88 100644 --- a/lib/src/message-transformer.test.ts +++ b/lib/src/message-transformer.test.ts @@ -6,7 +6,7 @@ import {Subject, Observable} from 'rxjs'; import {expectObservableToError} from '../../test/utils'; import {MessageTransformer} from './message-transformer'; -import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded_sass_pb'; describe('message transformer', () => { let messages: MessageTransformer; diff --git a/lib/src/message-transformer.ts b/lib/src/message-transformer.ts index cfdd8be5..1aa2c64f 100644 --- a/lib/src/message-transformer.ts +++ b/lib/src/message-transformer.ts @@ -6,10 +6,7 @@ import {Observable, Subject} from 'rxjs'; import {map} from 'rxjs/operators'; import {compilerError} from './utils'; -import { - InboundMessage, - OutboundMessage, -} from './vendor/embedded-protocol/embedded_sass_pb'; +import {InboundMessage, OutboundMessage} from './vendor/embedded_sass_pb'; /** * Encodes InboundMessages into protocol buffers and decodes protocol buffers diff --git a/lib/src/messages.ts b/lib/src/messages.ts index 5d827845..03757ab6 100644 --- a/lib/src/messages.ts +++ b/lib/src/messages.ts @@ -2,10 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import { - InboundMessage, - OutboundMessage, -} from './vendor/embedded-protocol/embedded_sass_pb'; +import {InboundMessage, OutboundMessage} from './vendor/embedded_sass_pb'; // Given a message type `M` (either `InboundMessage` or `OutboundMessage`) and a // union of possible message cases `T`, returns all the child types `M` contains diff --git a/lib/src/protofier.ts b/lib/src/protofier.ts index ba5420db..f379f3c0 100644 --- a/lib/src/protofier.ts +++ b/lib/src/protofier.ts @@ -4,7 +4,7 @@ import {OrderedMap} from 'immutable'; -import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded_sass_pb'; import * as utils from './utils'; import {FunctionRegistry} from './function-registry'; import {SassArgumentList} from './value/argument-list'; diff --git a/lib/src/utils.ts b/lib/src/utils.ts index bd6f4c71..8b33b1f5 100644 --- a/lib/src/utils.ts +++ b/lib/src/utils.ts @@ -6,7 +6,7 @@ import {List} from 'immutable'; import * as p from 'path'; import * as url from 'url'; -import * as proto from './vendor/embedded-protocol/embedded_sass_pb'; +import * as proto from './vendor/embedded_sass_pb'; import {Syntax} from './vendor/sass'; export type PromiseOr< diff --git a/package.json b/package.json index 427882c0..813a06df 100644 --- a/package.json +++ b/package.json @@ -38,14 +38,14 @@ }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", - "@bufbuild/protoc-gen-es": "^1.0.0", "buffer-builder": "^0.2.0", "immutable": "^4.0.0", "rxjs": "^7.4.0", "supports-color": "^8.1.1" }, "devDependencies": { - "@protobuf-ts/protoc": "^2.8.2", + "@bufbuild/buf": "^1.13.1-4", + "@bufbuild/protoc-gen-es": "^1.0.0", "@types/buffer-builder": "^0.2.0", "@types/google-protobuf": "^3.7.2", "@types/jest": "^29.4.0", @@ -62,6 +62,7 @@ "minipass": "4.0.1", "node-fetch": "^3.3.0", "npm-run-all": "^4.1.5", + "path-equal": "^1.2.5", "shelljs": "^0.8.4", "source-map-js": "^1.0.2", "tar": "^6.0.5", diff --git a/test/dependencies.test.ts b/test/dependencies.test.ts index e3d6746c..7da6ab0a 100644 --- a/test/dependencies.test.ts +++ b/test/dependencies.test.ts @@ -19,7 +19,7 @@ it('declares a compatible dependency on the embedded protocol', () => { expect( fs .readFileSync( - p.join(__dirname, '../lib/src/vendor/embedded-protocol/VERSION'), + p.join(__dirname, '../build/embedded-protocol/VERSION'), 'utf-8' ) .trim() diff --git a/tool/get-embedded-compiler.ts b/tool/get-embedded-compiler.ts index f05d7118..894465d0 100644 --- a/tool/get-embedded-compiler.ts +++ b/tool/get-embedded-compiler.ts @@ -25,10 +25,10 @@ export async function getEmbeddedCompiler( if (!options || 'ref' in options) { utils.fetchRepo({ repo, - outPath: utils.BUILD_PATH, + outPath: 'build', ref: options?.ref ?? 'main', }); - source = p.join(utils.BUILD_PATH, repo); + source = p.join('build', repo); await maybeOverrideSassDependency(source); } else { source = options.path; diff --git a/tool/get-embedded-protocol.ts b/tool/get-embedded-protocol.ts index 850619dc..8ae32a4c 100644 --- a/tool/get-embedded-protocol.ts +++ b/tool/get-embedded-protocol.ts @@ -2,8 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {mkdirSync} from 'fs'; -import * as p from 'path'; +import {pathEqual} from 'path-equal'; import * as shell from 'shelljs'; import * as pkg from '../package.json'; @@ -21,9 +20,6 @@ export async function getEmbeddedProtocol( outPath: string, options?: {ref: string} | {path: string} ): Promise { - const repo = 'embedded-protocol'; - - let source: string; if (!options || 'ref' in options) { let ref = options?.ref; if (ref === undefined) { @@ -31,33 +27,18 @@ export async function getEmbeddedProtocol( ref = version.endsWith('-dev') ? 'main' : version; } - utils.fetchRepo({repo, outPath: utils.BUILD_PATH, ref}); - source = p.join(utils.BUILD_PATH, repo); - } else { - source = options.path; + utils.fetchRepo({repo: 'embedded-protocol', outPath: 'build', ref}); + } else if (!pathEqual(options.path, 'build/embedded-protocol')) { + await utils.cleanDir('build/embedded-protocol'); + await utils.link(options.path, 'build/embedded-protocol'); } - buildEmbeddedProtocol(source); - await utils.link('build/embedded-protocol', p.join(outPath, repo)); + buildEmbeddedProtocol(); } -// Builds the embedded proto at `repoPath` into a pbjs with TS declaration file. -function buildEmbeddedProtocol(repoPath: string): void { - const proto = p.join(repoPath, 'embedded_sass.proto'); - const version = shell - .exec('npx protoc --version', {silent: true}) - .stdout.trim(); - console.log( - `Building pbjs and TS declaration file from ${proto} with protoc ` + - `${version}.` - ); - - mkdirSync('build/embedded-protocol', {recursive: true}); - shell.exec( - `npx protoc \ - --es_out="target=ts:build/embedded-protocol" \ - --proto_path="${repoPath}" \ - ${proto}`, - {silent: true} - ); +// Builds the embedded proto into a TS file. +function buildEmbeddedProtocol(): void { + const version = shell.exec('npx buf --version', {silent: true}).stdout.trim(); + console.log(`Building TS with buf ${version}.`); + shell.exec('npx buf generate'); } diff --git a/tool/utils.ts b/tool/utils.ts index 2c6fbd0a..36a2cc5f 100644 --- a/tool/utils.ts +++ b/tool/utils.ts @@ -57,7 +57,7 @@ export async function link(source: string, destination: string): Promise { export async function cleanDir(dir: string): Promise { await fs.mkdir(p.dirname(dir), {recursive: true}); try { - await fs.rmdir(dir, {recursive: true}); + await fs.rm(dir, {force: true, recursive: true}); } catch (_) { // If dir doesn't exist yet, that's fine. } diff --git a/tsconfig.json b/tsconfig.json index 70d28a2d..6f1a6a42 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,6 @@ }, "include": [ "lib/**/*.ts", - "lib/src/vendor/embedded-protocol/embedded_sass_pb.js", "tool/*.ts" ], "exclude": ["**/*.test.ts"] From 2a189e56fac812273324f3a7d3c49fb0910b6e8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Feb 2023 18:00:03 -0800 Subject: [PATCH 10/52] Bump minipass from 4.0.1 to 4.0.3 (#200) Bumps [minipass](https://github.com/isaacs/minipass) from 4.0.1 to 4.0.3. - [Release notes](https://github.com/isaacs/minipass/releases) - [Commits](https://github.com/isaacs/minipass/compare/v4.0.1...v4.0.3) --- updated-dependencies: - dependency-name: minipass dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 813a06df..228500e0 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "extract-zip": "^2.0.1", "gts": "^4.0.0", "jest": "^29.4.1", - "minipass": "4.0.1", + "minipass": "4.0.3", "node-fetch": "^3.3.0", "npm-run-all": "^4.1.5", "path-equal": "^1.2.5", From 449171418e852827a5d48800e7b087a5f25d8b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Thu, 16 Feb 2023 13:33:40 -0800 Subject: [PATCH 11/52] Replace node-fetch with fetch (#203) --- package.json | 8 +++----- tool/prepare-optional-release.ts | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 228500e0..a7d76905 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.58.0", - "protocol-version": "1.1.0", - "compiler-version": "1.58.0", + "version": "1.58.1", + "protocol-version": "1.2.0", + "compiler-version": "1.58.1", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -50,7 +50,6 @@ "@types/google-protobuf": "^3.7.2", "@types/jest": "^29.4.0", "@types/node": "^18.11.18", - "@types/node-fetch": "^2.6.0", "@types/shelljs": "^0.8.8", "@types/supports-color": "^8.1.1", "@types/tar": "^6.1.0", @@ -60,7 +59,6 @@ "gts": "^4.0.0", "jest": "^29.4.1", "minipass": "4.0.3", - "node-fetch": "^3.3.0", "npm-run-all": "^4.1.5", "path-equal": "^1.2.5", "shelljs": "^0.8.4", diff --git a/tool/prepare-optional-release.ts b/tool/prepare-optional-release.ts index 1847d1fd..64c076c3 100644 --- a/tool/prepare-optional-release.ts +++ b/tool/prepare-optional-release.ts @@ -1,6 +1,5 @@ import extractZip = require('extract-zip'); import {promises as fs} from 'fs'; -import fetch from 'node-fetch'; import * as p from 'path'; import {extract as extractTar} from 'tar'; import yargs from 'yargs'; @@ -80,7 +79,7 @@ async function downloadRelease(options: { `Failed to download ${options.repo} release asset: ${response.statusText}` ); } - const releaseAsset = await response.buffer(); + const releaseAsset = Buffer.from(await response.arrayBuffer()); console.log(`Unzipping ${options.repo} release asset to ${options.outPath}.`); await utils.cleanDir(p.join(options.outPath, options.repo)); From 050f43c2425718141e2f5deab85ee33fe4c6a37e Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Fri, 17 Feb 2023 01:57:25 +0000 Subject: [PATCH 12/52] Update compiler version and release --- CHANGELOG.md | 15 +++++++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 33 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b64a1a8d..f1b15203 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +## 1.58.2 + +### Command Line Interface + +* Add a timestamp to messages printed in `--watch` mode. + +* Print better `calc()`-based suggestions for `/`-as-division expression that + contain calculation-incompatible constructs like unary minus. + +## 1.58.1 + +* Emit a unitless hue when serializing `hsl()` colors. The `deg` unit is + incompatible with IE, and while that officially falls outside our + compatibility policy, it's better to lean towards greater compatibility. + ## 1.58.0 * Remove sourcemap comments from Sass sources. The generated sourcemap comment diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 621b1ef3..9fd93479 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.58.0", + "version": "1.58.2", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 5a7ea1a9..bec681a9 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.58.0", + "version": "1.58.2", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 85a58077..e9bea8ef 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.58.0", + "version": "1.58.2", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index b551a258..25dac07a 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.58.0", + "version": "1.58.2", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index adda4c13..f490961a 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.58.0", + "version": "1.58.2", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index e1516d78..d5f7b726 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.58.0", + "version": "1.58.2", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index fe8bb6eb..c750efc5 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.58.0", + "version": "1.58.2", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index e1edbc01..0ced6bbe 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.58.0", + "version": "1.58.2", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index a7d76905..ede9272e 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.58.1", + "version": "1.58.2", "protocol-version": "1.2.0", - "compiler-version": "1.58.1", + "compiler-version": "1.58.2", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.58.0", - "sass-embedded-darwin-x64": "1.58.0", - "sass-embedded-linux-arm": "1.58.0", - "sass-embedded-linux-arm64": "1.58.0", - "sass-embedded-linux-ia32": "1.58.0", - "sass-embedded-linux-x64": "1.58.0", - "sass-embedded-win32-ia32": "1.58.0", - "sass-embedded-win32-x64": "1.58.0" + "sass-embedded-darwin-arm64": "1.58.2", + "sass-embedded-darwin-x64": "1.58.2", + "sass-embedded-linux-arm": "1.58.2", + "sass-embedded-linux-arm64": "1.58.2", + "sass-embedded-linux-ia32": "1.58.2", + "sass-embedded-linux-x64": "1.58.2", + "sass-embedded-win32-ia32": "1.58.2", + "sass-embedded-win32-x64": "1.58.2" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 7c22749f543dfda093a0a680f730692596911109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 17 Feb 2023 15:19:21 -0800 Subject: [PATCH 13/52] Fix npm release (#206) --- tool/prepare-release.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tool/prepare-release.ts b/tool/prepare-release.ts index 20de61d8..afbc1f7c 100644 --- a/tool/prepare-release.ts +++ b/tool/prepare-release.ts @@ -24,11 +24,6 @@ import {getJSApi} from './get-js-api'; shell.cp('-R', 'lib/src/vendor/sass', 'dist/types'); await fs.unlink('dist/types/README.md'); - // .gitignore needs to exist in dist for `npm publish` to correctly exclude - // files from the published tarball. - console.log('Copying .gitignore to dist.'); - await fs.copyFile('.gitignore', 'dist/.gitignore'); - console.log('Ready for publishing to npm.'); } catch (error) { console.error(error); From 12e87331f43081003148a4c9750d4351be3301a0 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Sat, 18 Feb 2023 00:57:55 +0000 Subject: [PATCH 14/52] Update compiler version and release --- CHANGELOG.md | 4 ++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1b15203..9cae5bed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.58.3 + +* No user-visible changes. + ## 1.58.2 ### Command Line Interface diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 9fd93479..2a67f81b 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.58.2", + "version": "1.58.3", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index bec681a9..9e5bcd35 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.58.2", + "version": "1.58.3", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index e9bea8ef..8093a187 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.58.2", + "version": "1.58.3", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 25dac07a..ec567136 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.58.2", + "version": "1.58.3", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index f490961a..0ee521b5 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.58.2", + "version": "1.58.3", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index d5f7b726..8614e1ed 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.58.2", + "version": "1.58.3", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index c750efc5..49de937a 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.58.2", + "version": "1.58.3", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 0ced6bbe..e718e91e 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.58.2", + "version": "1.58.3", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index ede9272e..1c5a0c08 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.58.2", + "version": "1.58.3", "protocol-version": "1.2.0", - "compiler-version": "1.58.2", + "compiler-version": "1.58.3", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.58.2", - "sass-embedded-darwin-x64": "1.58.2", - "sass-embedded-linux-arm": "1.58.2", - "sass-embedded-linux-arm64": "1.58.2", - "sass-embedded-linux-ia32": "1.58.2", - "sass-embedded-linux-x64": "1.58.2", - "sass-embedded-win32-ia32": "1.58.2", - "sass-embedded-win32-x64": "1.58.2" + "sass-embedded-darwin-arm64": "1.58.3", + "sass-embedded-darwin-x64": "1.58.3", + "sass-embedded-linux-arm": "1.58.3", + "sass-embedded-linux-arm64": "1.58.3", + "sass-embedded-linux-ia32": "1.58.3", + "sass-embedded-linux-x64": "1.58.3", + "sass-embedded-win32-ia32": "1.58.3", + "sass-embedded-win32-x64": "1.58.3" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 308862033e00f7a28a83c3114941efb053c395f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Tue, 28 Feb 2023 13:30:28 -0800 Subject: [PATCH 15/52] Improve launch performance by skipping wrapper script (#207) --- lib/src/async-compiler.ts | 8 ++++++-- lib/src/compiler-path.ts | 34 ++++++++++++++++++++++++++-------- lib/src/sync-compiler.ts | 8 ++++++-- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/lib/src/async-compiler.ts b/lib/src/async-compiler.ts index a78b0268..f4a0dc7f 100644 --- a/lib/src/async-compiler.ts +++ b/lib/src/async-compiler.ts @@ -6,7 +6,7 @@ import {spawn} from 'child_process'; import {Observable} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; -import {compilerPath} from './compiler-path'; +import {compilerCommand} from './compiler-path'; /** * An asynchronous wrapper for the embedded Sass compiler that exposes its stdio @@ -14,7 +14,11 @@ import {compilerPath} from './compiler-path'; */ export class AsyncEmbeddedCompiler { /** The underlying process that's being wrapped. */ - private readonly process = spawn(compilerPath, {windowsHide: true}); + private readonly process = spawn( + compilerCommand[0], + compilerCommand.slice(1), + {windowsHide: true} + ); /** The child process's exit event. */ readonly exit$ = new Promise(resolve => { diff --git a/lib/src/compiler-path.ts b/lib/src/compiler-path.ts index 6f8c7a1b..8f7342f5 100644 --- a/lib/src/compiler-path.ts +++ b/lib/src/compiler-path.ts @@ -6,8 +6,8 @@ import * as fs from 'fs'; import * as p from 'path'; import {isErrnoException} from './utils'; -/** The path to the embedded compiler executable. */ -export const compilerPath = (() => { +/** The full command for the embedded compiler executable. */ +export const compilerCommand = (() => { // find for development for (const path of ['vendor', '../../../lib/src/vendor']) { const executable = p.resolve( @@ -18,15 +18,33 @@ export const compilerPath = (() => { }` ); - if (fs.existsSync(executable)) return executable; + if (fs.existsSync(executable)) return [executable]; } try { - return require.resolve( - `sass-embedded-${process.platform}-${process.arch}/` + - 'dart-sass-embedded/dart-sass-embedded' + - (process.platform === 'win32' ? '.bat' : '') - ); + return [ + require.resolve( + `sass-embedded-${process.platform}-${process.arch}/` + + 'dart-sass-embedded/src/dart' + + (process.platform === 'win32' ? '.exe' : '') + ), + require.resolve( + `sass-embedded-${process.platform}-${process.arch}/` + + 'dart-sass-embedded/src/dart-sass-embedded.snapshot' + ), + ]; + } catch (ignored) { + // ignored + } + + try { + return [ + require.resolve( + `sass-embedded-${process.platform}-${process.arch}/` + + 'dart-sass-embedded/dart-sass-embedded' + + (process.platform === 'win32' ? '.bat' : '') + ), + ]; } catch (e: unknown) { if (!(isErrnoException(e) && e.code === 'MODULE_NOT_FOUND')) { throw e; diff --git a/lib/src/sync-compiler.ts b/lib/src/sync-compiler.ts index 4aec442a..84bf7784 100644 --- a/lib/src/sync-compiler.ts +++ b/lib/src/sync-compiler.ts @@ -5,7 +5,7 @@ import {Subject} from 'rxjs'; import {SyncProcess} from './sync-process'; -import {compilerPath} from './compiler-path'; +import {compilerCommand} from './compiler-path'; /** * A synchronous wrapper for the embedded Sass compiler that exposes its stdio @@ -13,7 +13,11 @@ import {compilerPath} from './compiler-path'; */ export class SyncEmbeddedCompiler { /** The underlying process that's being wrapped. */ - private readonly process = new SyncProcess(compilerPath, {windowsHide: true}); + private readonly process = new SyncProcess( + compilerCommand[0], + compilerCommand.slice(1), + {windowsHide: true} + ); /** The buffers emitted by the child process's stdout. */ readonly stdout$ = new Subject(); From 003bc451763c7719e8787780f1f4163f2ea66c43 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Sat, 11 Mar 2023 01:37:52 +0000 Subject: [PATCH 16/52] Update compiler version and release --- CHANGELOG.md | 43 +++++++++++++++++++++++++++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++-------- 10 files changed, 61 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cae5bed..ebc7ec3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,46 @@ +## 1.59.2 + +* No user-visible changes. + +## 1.59.1 + +* No user-visible changes. + +## 1.59.0 + +### Command Line Interface + +* Added a new `--fatal-deprecation` flag that lets you treat a deprecation + warning as an error. You can pass an individual deprecation ID + (e.g. `slash-div`) or you can pass a Dart Sass version to treat all + deprecations initially emitted in that version or earlier as errors. + +* New `--future-deprecation` flag that lets you opt into warning for use of + certain features that will be deprecated in the future. At the moment, the + only option is `--future-deprecation=import`, which will emit warnings for + Sass `@import` rules, which are not yet deprecated, but will be in the future. + +### Dart API + +* New `Deprecation` enum, which contains the different current and future + deprecations used by the new CLI flags. + +* The `compile` methods now take in `fatalDeprecations` and `futureDeprecations` + parameters, which work similarly to the CLI flags. + +## 1.58.4 + +* Pull `@font-face` to the root rather than bubbling the style rule selector + inwards. + +* Improve error messages for invalid CSS values passed to plain CSS functions. + +* Improve error messages involving selectors. + +### Embedded Sass + +* Improve the performance of starting up a compilation. + ## 1.58.3 * No user-visible changes. diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 2a67f81b..513dee4c 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.58.3", + "version": "1.59.2", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 9e5bcd35..dd5d90b9 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.58.3", + "version": "1.59.2", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 8093a187..54160822 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.58.3", + "version": "1.59.2", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index ec567136..1c88b7d4 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.58.3", + "version": "1.59.2", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 0ee521b5..05cd5fb3 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.58.3", + "version": "1.59.2", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index 8614e1ed..a17fe9d1 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.58.3", + "version": "1.59.2", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 49de937a..753f72da 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.58.3", + "version": "1.59.2", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index e718e91e..2f91f2a0 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.58.3", + "version": "1.59.2", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 1c5a0c08..f29c8544 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.58.3", + "version": "1.59.2", "protocol-version": "1.2.0", - "compiler-version": "1.58.3", + "compiler-version": "1.59.2", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.58.3", - "sass-embedded-darwin-x64": "1.58.3", - "sass-embedded-linux-arm": "1.58.3", - "sass-embedded-linux-arm64": "1.58.3", - "sass-embedded-linux-ia32": "1.58.3", - "sass-embedded-linux-x64": "1.58.3", - "sass-embedded-win32-ia32": "1.58.3", - "sass-embedded-win32-x64": "1.58.3" + "sass-embedded-darwin-arm64": "1.59.2", + "sass-embedded-darwin-x64": "1.59.2", + "sass-embedded-linux-arm": "1.59.2", + "sass-embedded-linux-arm64": "1.59.2", + "sass-embedded-linux-ia32": "1.59.2", + "sass-embedded-linux-x64": "1.59.2", + "sass-embedded-win32-ia32": "1.59.2", + "sass-embedded-win32-x64": "1.59.2" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 7548747df8e26d77db93efa0052609cdb4be7430 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Tue, 14 Mar 2023 21:39:48 +0000 Subject: [PATCH 17/52] Update compiler version and release --- CHANGELOG.md | 10 ++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 28 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebc7ec3f..4618111f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 1.59.3 + +* Fix a performance regression introduced in 1.59.0. + +* The NPM release of 1.59.0 dropped support for Node 12 without actually + indicating so in its pubspec. This release temporarily adds back support so + that the latest Sass version that declares it supports Node 12 actually does + so. However, Node 12 is now end-of-life, so we will drop support for it + properly in an upcoming release. + ## 1.59.2 * No user-visible changes. diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 513dee4c..5b35ba6d 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.59.2", + "version": "1.59.3", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index dd5d90b9..e0becc67 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.59.2", + "version": "1.59.3", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 54160822..f55a0cb7 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.59.2", + "version": "1.59.3", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 1c88b7d4..06b85355 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.59.2", + "version": "1.59.3", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 05cd5fb3..151d0841 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.59.2", + "version": "1.59.3", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index a17fe9d1..4e33af11 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.59.2", + "version": "1.59.3", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 753f72da..b955cb2e 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.59.2", + "version": "1.59.3", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 2f91f2a0..9011b79a 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.59.2", + "version": "1.59.3", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index f29c8544..d1cb0d25 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.59.2", + "version": "1.59.3", "protocol-version": "1.2.0", - "compiler-version": "1.59.2", + "compiler-version": "1.59.3", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.59.2", - "sass-embedded-darwin-x64": "1.59.2", - "sass-embedded-linux-arm": "1.59.2", - "sass-embedded-linux-arm64": "1.59.2", - "sass-embedded-linux-ia32": "1.59.2", - "sass-embedded-linux-x64": "1.59.2", - "sass-embedded-win32-ia32": "1.59.2", - "sass-embedded-win32-x64": "1.59.2" + "sass-embedded-darwin-arm64": "1.59.3", + "sass-embedded-darwin-x64": "1.59.3", + "sass-embedded-linux-arm": "1.59.3", + "sass-embedded-linux-arm64": "1.59.3", + "sass-embedded-linux-ia32": "1.59.3", + "sass-embedded-linux-x64": "1.59.3", + "sass-embedded-win32-ia32": "1.59.3", + "sass-embedded-win32-x64": "1.59.3" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From a26694933f581b35c9e91447639be3ec98cd6863 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 14:21:26 -0700 Subject: [PATCH 18/52] Bump typescript from 4.9.5 to 5.0.2 (#211) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.9.5 to 5.0.2. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.9.5...v5.0.2) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d1cb0d25..596efc14 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "tar": "^6.0.5", "ts-jest": "^29.0.5", "ts-node": "^10.2.1", - "typescript": "^4.4.3", + "typescript": "^5.0.2", "yaml": "^2.2.1", "yargs": "^17.2.1" } From 74af907b512092e9d3ee0f67f2a40f2e4462d3a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 14:21:42 -0700 Subject: [PATCH 19/52] Bump minipass from 4.0.3 to 4.2.5 (#209) Bumps [minipass](https://github.com/isaacs/minipass) from 4.0.3 to 4.2.5. - [Release notes](https://github.com/isaacs/minipass/releases) - [Changelog](https://github.com/isaacs/minipass/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/minipass/compare/v4.0.3...v4.2.5) --- updated-dependencies: - dependency-name: minipass dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 596efc14..0fd8b63a 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "extract-zip": "^2.0.1", "gts": "^4.0.0", "jest": "^29.4.1", - "minipass": "4.0.3", + "minipass": "4.2.5", "npm-run-all": "^4.1.5", "path-equal": "^1.2.5", "shelljs": "^0.8.4", From 8612f48f502904d4553b5ee0f871b305711a5f73 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Thu, 23 Mar 2023 23:32:09 +0000 Subject: [PATCH 20/52] Update compiler version and release --- CHANGELOG.md | 12 ++++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 30 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4618111f..2075cc82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 1.60.0 + +* Add support for the `pi`, `e`, `infinity`, `-infinity`, and `NaN` constants in + calculations. These will be interpreted as the corresponding numbers. + +* Add support for unknown constants in calculations. These will be interpreted + as unquoted strings. + +* Serialize numbers with value `infinity`, `-infinity`, and `NaN` to `calc()` + expressions rather than CSS-invalid identifiers. Numbers with complex units + still can't be serialized. + ## 1.59.3 * Fix a performance regression introduced in 1.59.0. diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 5b35ba6d..cdbed997 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.59.3", + "version": "1.60.0", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index e0becc67..60ebb884 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.59.3", + "version": "1.60.0", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index f55a0cb7..29733509 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.59.3", + "version": "1.60.0", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 06b85355..7315d839 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.59.3", + "version": "1.60.0", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 151d0841..96a06890 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.59.3", + "version": "1.60.0", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index 4e33af11..a48c54de 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.59.3", + "version": "1.60.0", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index b955cb2e..59550f21 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.59.3", + "version": "1.60.0", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 9011b79a..01781bb0 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.59.3", + "version": "1.60.0", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 0fd8b63a..3f22a956 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.59.3", + "version": "1.60.0", "protocol-version": "1.2.0", - "compiler-version": "1.59.3", + "compiler-version": "1.60.0", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.59.3", - "sass-embedded-darwin-x64": "1.59.3", - "sass-embedded-linux-arm": "1.59.3", - "sass-embedded-linux-arm64": "1.59.3", - "sass-embedded-linux-ia32": "1.59.3", - "sass-embedded-linux-x64": "1.59.3", - "sass-embedded-win32-ia32": "1.59.3", - "sass-embedded-win32-x64": "1.59.3" + "sass-embedded-darwin-arm64": "1.60.0", + "sass-embedded-darwin-x64": "1.60.0", + "sass-embedded-linux-arm": "1.60.0", + "sass-embedded-linux-arm64": "1.60.0", + "sass-embedded-linux-ia32": "1.60.0", + "sass-embedded-linux-x64": "1.60.0", + "sass-embedded-win32-ia32": "1.60.0", + "sass-embedded-win32-x64": "1.60.0" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From c537b03e9f229241d2f5e1a9240401ab296bbce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 5 Apr 2023 17:40:03 -0700 Subject: [PATCH 21/52] Fix resolving against the working directory in legacy API (#212) --- lib/src/legacy/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/src/legacy/index.ts b/lib/src/legacy/index.ts index 41fafec4..1631a534 100644 --- a/lib/src/legacy/index.ts +++ b/lib/src/legacy/index.ts @@ -83,6 +83,10 @@ function adjustOptions( throw new Error('Either options.data or options.file must be set.'); } + // In legacy API, the current working directory is always attempted before + // any load path. + options.includePaths = [process.cwd(), ...(options.includePaths ?? [])]; + if ( !isStringOptions(options) && // The `indentedSyntax` option takes precedence over the file extension in the @@ -200,9 +204,7 @@ function pluginThis( context: undefined as unknown as LegacyPluginThis, file: options.file, data: options.data, - includePaths: [process.cwd(), ...(options.includePaths ?? [])].join( - p.delimiter - ), + includePaths: (options.includePaths ?? []).join(p.delimiter), precision: 10, style: 1, indentType: 0, From d66b12feef10c781e9ec2646a543324f825816ee Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Thu, 6 Apr 2023 22:16:27 +0000 Subject: [PATCH 22/52] Update compiler version and release --- CHANGELOG.md | 11 +++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 29 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2075cc82..446755eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## 1.61.0 + +* **Potentially breaking change:** Drop support for End-of-Life Node.js 12. + +* Fix remaining cases for the performance regression introduced in 1.59.0. + +### Embedded Sass + +* The JS embedded host now loads files from the working directory when using the + legacy API. + ## 1.60.0 * Add support for the `pi`, `e`, `infinity`, `-infinity`, and `NaN` constants in diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index cdbed997..b0d3c7e7 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.60.0", + "version": "1.61.0", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 60ebb884..c0ff3196 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.60.0", + "version": "1.61.0", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 29733509..189334e6 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.60.0", + "version": "1.61.0", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 7315d839..4fa73100 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.60.0", + "version": "1.61.0", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 96a06890..25a28e8b 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.60.0", + "version": "1.61.0", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index a48c54de..eea19648 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.60.0", + "version": "1.61.0", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 59550f21..666d33d9 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.60.0", + "version": "1.61.0", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 01781bb0..61717506 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.60.0", + "version": "1.61.0", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 3f22a956..122b0f7f 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.60.0", + "version": "1.61.0", "protocol-version": "1.2.0", - "compiler-version": "1.60.0", + "compiler-version": "1.61.0", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.60.0", - "sass-embedded-darwin-x64": "1.60.0", - "sass-embedded-linux-arm": "1.60.0", - "sass-embedded-linux-arm64": "1.60.0", - "sass-embedded-linux-ia32": "1.60.0", - "sass-embedded-linux-x64": "1.60.0", - "sass-embedded-win32-ia32": "1.60.0", - "sass-embedded-win32-x64": "1.60.0" + "sass-embedded-darwin-arm64": "1.61.0", + "sass-embedded-darwin-x64": "1.61.0", + "sass-embedded-linux-arm": "1.61.0", + "sass-embedded-linux-arm64": "1.61.0", + "sass-embedded-linux-ia32": "1.61.0", + "sass-embedded-linux-x64": "1.61.0", + "sass-embedded-win32-ia32": "1.61.0", + "sass-embedded-win32-x64": "1.61.0" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 60df05b866096fa3be4e1beefd37eccc0b3cd607 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Tue, 11 Apr 2023 23:13:44 +0000 Subject: [PATCH 23/52] Update compiler version and release --- CHANGELOG.md | 13 +++++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 31 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 446755eb..e7ab81f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## 1.62.0 + +* Deprecate the use of multiple `!global` or `!default` flags on the same + variable. This deprecation is named `duplicate-var-flags`. + +* Allow special numbers like `var()` or `calc()` in the global functions: + `grayscale()`, `invert()`, `saturate()`, and `opacity()`. These are also + native CSS `filter` functions. This is in addition to number values which were + already allowed. + +* Fix a cosmetic bug where an outer rule could be duplicated after nesting was + resolved, instead of re-using a shared rule. + ## 1.61.0 * **Potentially breaking change:** Drop support for End-of-Life Node.js 12. diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index b0d3c7e7..1f437b67 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.61.0", + "version": "1.62.0", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index c0ff3196..a8ecb1fb 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.61.0", + "version": "1.62.0", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 189334e6..e6678227 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.61.0", + "version": "1.62.0", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 4fa73100..1a4de66f 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.61.0", + "version": "1.62.0", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 25a28e8b..e798561c 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.61.0", + "version": "1.62.0", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index eea19648..947b67bd 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.61.0", + "version": "1.62.0", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 666d33d9..3fdf1948 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.61.0", + "version": "1.62.0", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 61717506..205c1c77 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.61.0", + "version": "1.62.0", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 122b0f7f..69e1b430 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.61.0", + "version": "1.62.0", "protocol-version": "1.2.0", - "compiler-version": "1.61.0", + "compiler-version": "1.62.0", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.61.0", - "sass-embedded-darwin-x64": "1.61.0", - "sass-embedded-linux-arm": "1.61.0", - "sass-embedded-linux-arm64": "1.61.0", - "sass-embedded-linux-ia32": "1.61.0", - "sass-embedded-linux-x64": "1.61.0", - "sass-embedded-win32-ia32": "1.61.0", - "sass-embedded-win32-x64": "1.61.0" + "sass-embedded-darwin-arm64": "1.62.0", + "sass-embedded-darwin-x64": "1.62.0", + "sass-embedded-linux-arm": "1.62.0", + "sass-embedded-linux-arm64": "1.62.0", + "sass-embedded-linux-ia32": "1.62.0", + "sass-embedded-linux-x64": "1.62.0", + "sass-embedded-win32-ia32": "1.62.0", + "sass-embedded-win32-x64": "1.62.0" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 65abf8da59e3cccaf7c81300536afaea5d8d55cd Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Tue, 25 Apr 2023 23:48:15 +0000 Subject: [PATCH 24/52] Update compiler version and release --- CHANGELOG.md | 5 +++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 23 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7ab81f9..74dd0ba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.62.1 + +* Fix a bug where `:has(+ &)` and related constructs would drop the leading + combinator. + ## 1.62.0 * Deprecate the use of multiple `!global` or `!default` flags on the same diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 1f437b67..9a30c575 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.62.0", + "version": "1.62.1", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index a8ecb1fb..45f1abd0 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.62.0", + "version": "1.62.1", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index e6678227..7b9719ac 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.62.0", + "version": "1.62.1", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 1a4de66f..40fafb1b 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.62.0", + "version": "1.62.1", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index e798561c..55932880 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.62.0", + "version": "1.62.1", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index 947b67bd..dd583734 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.62.0", + "version": "1.62.1", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 3fdf1948..b432ba12 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.62.0", + "version": "1.62.1", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 205c1c77..2e2e72d3 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.62.0", + "version": "1.62.1", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 69e1b430..cf86c023 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.62.0", + "version": "1.62.1", "protocol-version": "1.2.0", - "compiler-version": "1.62.0", + "compiler-version": "1.62.1", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.62.0", - "sass-embedded-darwin-x64": "1.62.0", - "sass-embedded-linux-arm": "1.62.0", - "sass-embedded-linux-arm64": "1.62.0", - "sass-embedded-linux-ia32": "1.62.0", - "sass-embedded-linux-x64": "1.62.0", - "sass-embedded-win32-ia32": "1.62.0", - "sass-embedded-win32-x64": "1.62.0" + "sass-embedded-darwin-arm64": "1.62.1", + "sass-embedded-darwin-x64": "1.62.1", + "sass-embedded-linux-arm": "1.62.1", + "sass-embedded-linux-arm64": "1.62.1", + "sass-embedded-linux-ia32": "1.62.1", + "sass-embedded-linux-x64": "1.62.1", + "sass-embedded-win32-ia32": "1.62.1", + "sass-embedded-win32-x64": "1.62.1" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From c99ccf8dcdbf3c9fca63496a0734ada47c7e5f51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 13:56:36 -0700 Subject: [PATCH 25/52] Bump @types/node from 18.16.5 to 20.1.0 (#217) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.16.5 to 20.1.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cf86c023..9b720b99 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@types/buffer-builder": "^0.2.0", "@types/google-protobuf": "^3.7.2", "@types/jest": "^29.4.0", - "@types/node": "^18.11.18", + "@types/node": "^20.1.0", "@types/shelljs": "^0.8.8", "@types/supports-color": "^8.1.1", "@types/tar": "^6.1.0", From 0ac7ec871592147111929ecbeb105fbe8f98a8b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 14:12:42 -0700 Subject: [PATCH 26/52] Bump minipass from 4.2.5 to 6.0.0 (#219) Bumps [minipass](https://github.com/isaacs/minipass) from 4.2.5 to 6.0.0. - [Changelog](https://github.com/isaacs/minipass/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/minipass/compare/v4.2.5...v6.0.0) --- updated-dependencies: - dependency-name: minipass dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9b720b99..1d4dbf4a 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "extract-zip": "^2.0.1", "gts": "^4.0.0", "jest": "^29.4.1", - "minipass": "4.2.5", + "minipass": "6.0.0", "npm-run-all": "^4.1.5", "path-equal": "^1.2.5", "shelljs": "^0.8.4", From e019192885002ae22bc8d31076a49312af57cd46 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 15 May 2023 14:49:54 -0700 Subject: [PATCH 27/52] Use Dart Sass directly as the embedded compiler (#218) See sass/dart-sass#1889 --- .github/workflows/ci.yml | 24 +++--------------------- .gitignore | 2 +- CONTRIBUTING.md | 23 ++++++++++------------- README.md | 2 +- lib/src/async-compiler.ts | 2 +- lib/src/compiler-path.ts | 10 ++++------ lib/src/sync-compiler.ts | 2 +- npm/darwin-arm64/package.json | 5 ++++- npm/darwin-x64/package.json | 5 ++++- npm/linux-arm/package.json | 5 ++++- npm/linux-arm64/package.json | 5 ++++- npm/linux-ia32/package.json | 5 ++++- npm/linux-x64/package.json | 5 ++++- npm/win32-ia32/package.json | 5 ++++- npm/win32-x64/package.json | 5 ++++- package.json | 2 +- test/dependencies.test.ts | 6 ++---- tool/get-embedded-compiler.ts | 31 +++---------------------------- tool/prepare-optional-release.ts | 10 +++------- 19 files changed, 62 insertions(+), 92 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb29e0f9..6a7ebc7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,15 +71,6 @@ jobs: uses: sass/clone-linked-repo@v1 with: {repo: sass/dart-sass} - - name: Check out the embedded compiler - uses: sass/clone-linked-repo@v1 - with: {repo: sass/dart-sass-embedded} - - - name: Link the embedded compiler to Dart Sass - run: | - yq -i '.dependency_overrides.sass = {"path": "../dart-sass"}' \ - dart-sass-embedded/pubspec.yaml - - name: Check out the JS API definition uses: sass/clone-linked-repo@v1 with: {repo: sass/sass, path: language} @@ -88,7 +79,7 @@ jobs: - name: npm run init run: | if [[ -d embedded-protocol ]]; then args=--protocol-path=embedded-protocol; fi - npm run init -- --compiler-path=dart-sass-embedded --api-path=language $args + npm run init -- --compiler-path=dart-sass --api-path=language $args - run: npm run test @@ -128,15 +119,6 @@ jobs: uses: sass/clone-linked-repo@v1 with: {repo: sass/dart-sass} - - name: Check out the embedded compiler - uses: sass/clone-linked-repo@v1 - with: {repo: sass/dart-sass-embedded} - - - name: Link the embedded compiler to Dart Sass - run: | - yq -i '.dependency_overrides.sass = {"path": "../dart-sass"}' \ - dart-sass-embedded/pubspec.yaml - - name: Check out the JS API definition uses: sass/clone-linked-repo@v1 with: {repo: sass/sass, path: language} @@ -145,7 +127,7 @@ jobs: - name: npm run init run: | if [[ -d embedded-protocol ]]; then args=--protocol-path=embedded-protocol; fi - npm run init -- --compiler-path=dart-sass-embedded --api-path=language $args + npm run init -- --compiler-path=dart-sass --api-path=language $args - name: Check out sass-spec uses: sass/clone-linked-repo@v1 @@ -158,7 +140,7 @@ jobs: - name: Compile run: | npm run compile - ln -s {`pwd`/,dist/}lib/src/vendor/dart-sass-embedded + ln -s {`pwd`/,dist/}lib/src/vendor/dart-sass - name: Run tests run: npm run js-api-spec -- --sassPackage .. --sassSassRepo ../language diff --git a/.gitignore b/.gitignore index 1f8d93b7..cc631e31 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ node_modules npm-debug.log* package-lock.json test/sandbox -npm/*/dart-sass-embedded/ +npm/*/dart-sass/ # Editors .idea diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 20e63a3a..34d80af5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,13 +41,11 @@ such, manual commits should never: The embedded host depends on several different components which come from different repositories: -* The [Dart Sass embedded compiler]. -* [Dart Sass] (transitively through the embedded compiler). +* The [Dart Sass compiler]. * The [Sass embedded protocol]. * The [Sass JS API definition]. -[Dart Sass embedded compiler]: https://github.com/sass/dart-sass-embedded -[Dart Sass]: https://github.com/sass/dart-sass +[Dart Sass compiler]: https://github.com/sass/dart-sass [Sass embedded protocol]: https://github.com/sass/embedded-protocol [JS API definition]: https://github.com/sass/sass/tree/main/spec/js-api @@ -77,15 +75,14 @@ By default: revision on GitHub. * This uses the Dart Sass version from the latest revision on GitHub, unless the - embedded `--compiler-path` was passed in which case it uses whatever version - of Dart Sass that package references. + `--compiler-path` was passed in which case it uses that version of Dart Sass. ## Continuous Integration CI tests also use `npm run init`, so they use the same defaults as local development. However, if the pull request description includes a link to a pull -request for the embedded compiler, Dart Sass, the embedded protocol, or the JS -API, this will check out that version and run tests against it instead. +request for Dart Sass, the embedded protocol, or the JS API, this will check out +that version and run tests against it instead. ## Release @@ -93,11 +90,11 @@ When this package is released to npm, it downloads the embedded protocol version that matches `protocol-version` in `package.json`. It downloads the latest JS API revision on GitHub. -The release version of the `sass-embedded` package does *not* include the -embedded compiler or Dart Sass. Instead, we release optional packages of the -form `sass-embedded--`. Each of these contains the published version -of the embedded compiler that matches `compiler-version` in `package.json` for -the given operating system/architecture combination. +The release version of the `sass-embedded` package does *not* include Dart Sass. +Instead, we release optional packages of the form `sass-embedded--`. +Each of these contains the published version of Dart Sass that matches +`compiler-version` in `package.json` for the given operating system/architecture +combination. If either `protocol-version` or `compiler-version` ends with `-dev`, the release will fail. diff --git a/README.md b/README.md index 7a1681b1..da8b66a8 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ to start a Sass compilation, but to control aspects of it that are exposed by an API. This includes defining custom importers, functions, and loggers, all of which are invoked by messages from the embedded compiler back to the host. -[embedded compiler]: https://github.com/sass/dart-sass-embedded +[embedded compiler]: https://github.com/sass/dart-sass#embedded-dart-sass [Embedded Sass Protocol]: https://github.com/sass/embedded-protocol#readme Although this sort of two-way communication with an embedded process is diff --git a/lib/src/async-compiler.ts b/lib/src/async-compiler.ts index f4a0dc7f..90aa0c88 100644 --- a/lib/src/async-compiler.ts +++ b/lib/src/async-compiler.ts @@ -16,7 +16,7 @@ export class AsyncEmbeddedCompiler { /** The underlying process that's being wrapped. */ private readonly process = spawn( compilerCommand[0], - compilerCommand.slice(1), + [...compilerCommand.slice(1), '--embedded'], {windowsHide: true} ); diff --git a/lib/src/compiler-path.ts b/lib/src/compiler-path.ts index 8f7342f5..0e193c95 100644 --- a/lib/src/compiler-path.ts +++ b/lib/src/compiler-path.ts @@ -13,9 +13,7 @@ export const compilerCommand = (() => { const executable = p.resolve( __dirname, path, - `dart-sass-embedded/dart-sass-embedded${ - process.platform === 'win32' ? '.bat' : '' - }` + `dart-sass/sass${process.platform === 'win32' ? '.bat' : ''}` ); if (fs.existsSync(executable)) return [executable]; @@ -25,12 +23,12 @@ export const compilerCommand = (() => { return [ require.resolve( `sass-embedded-${process.platform}-${process.arch}/` + - 'dart-sass-embedded/src/dart' + + 'dart-sass/src/dart' + (process.platform === 'win32' ? '.exe' : '') ), require.resolve( `sass-embedded-${process.platform}-${process.arch}/` + - 'dart-sass-embedded/src/dart-sass-embedded.snapshot' + 'dart-sass/src/sass.snapshot' ), ]; } catch (ignored) { @@ -41,7 +39,7 @@ export const compilerCommand = (() => { return [ require.resolve( `sass-embedded-${process.platform}-${process.arch}/` + - 'dart-sass-embedded/dart-sass-embedded' + + 'dart-sass/sass' + (process.platform === 'win32' ? '.bat' : '') ), ]; diff --git a/lib/src/sync-compiler.ts b/lib/src/sync-compiler.ts index 84bf7784..2950fbdc 100644 --- a/lib/src/sync-compiler.ts +++ b/lib/src/sync-compiler.ts @@ -15,7 +15,7 @@ export class SyncEmbeddedCompiler { /** The underlying process that's being wrapped. */ private readonly process = new SyncProcess( compilerCommand[0], - compilerCommand.slice(1), + [...compilerCommand.slice(1), '--embedded'], {windowsHide: true} ); diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 9a30c575..bd9a6524 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -6,11 +6,14 @@ "author": "Google Inc.", "license": "MIT", "files": [ - "dart-sass-embedded/**/*" + "dart-sass/**/*" ], "engines": { "node": ">=14.0.0" }, + "bin": { + "sass": "./dart-sass/sass" + }, "os": [ "darwin" ], diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 45f1abd0..c074c3a9 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -6,11 +6,14 @@ "author": "Google Inc.", "license": "MIT", "files": [ - "dart-sass-embedded/**/*" + "dart-sass/**/*" ], "engines": { "node": ">=14.0.0" }, + "bin": { + "sass": "./dart-sass/sass" + }, "os": [ "darwin" ], diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 7b9719ac..902c48bc 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -6,11 +6,14 @@ "author": "Google Inc.", "license": "MIT", "files": [ - "dart-sass-embedded/**/*" + "dart-sass/**/*" ], "engines": { "node": ">=14.0.0" }, + "bin": { + "sass": "./dart-sass/sass" + }, "os": [ "linux" ], diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 40fafb1b..da837b26 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -6,11 +6,14 @@ "author": "Google Inc.", "license": "MIT", "files": [ - "dart-sass-embedded/**/*" + "dart-sass/**/*" ], "engines": { "node": ">=14.0.0" }, + "bin": { + "sass": "./dart-sass/sass" + }, "os": [ "linux" ], diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 55932880..b9fda742 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -6,11 +6,14 @@ "author": "Google Inc.", "license": "MIT", "files": [ - "dart-sass-embedded/**/*" + "dart-sass/**/*" ], "engines": { "node": ">=14.0.0" }, + "bin": { + "sass": "./dart-sass/sass" + }, "os": [ "linux" ], diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index dd583734..7b9d0cf5 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -6,11 +6,14 @@ "author": "Google Inc.", "license": "MIT", "files": [ - "dart-sass-embedded/**/*" + "dart-sass/**/*" ], "engines": { "node": ">=14.0.0" }, + "bin": { + "sass": "./dart-sass/sass" + }, "os": [ "linux" ], diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index b432ba12..0e3aa7a6 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -6,11 +6,14 @@ "author": "Google Inc.", "license": "MIT", "files": [ - "dart-sass-embedded/**/*" + "dart-sass/**/*" ], "engines": { "node": ">=14.0.0" }, + "bin": { + "sass": "./dart-sass/sass.bat" + }, "os": [ "win32" ], diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 2e2e72d3..4245453c 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -6,11 +6,14 @@ "author": "Google Inc.", "license": "MIT", "files": [ - "dart-sass-embedded/**/*" + "dart-sass/**/*" ], "engines": { "node": ">=14.0.0" }, + "bin": { + "sass": "./dart-sass/sass.bat" + }, "os": [ "win32" ], diff --git a/package.json b/package.json index 1d4dbf4a..c46fea6b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "sass-embedded", "version": "1.62.1", "protocol-version": "1.2.0", - "compiler-version": "1.62.1", + "compiler-version": "1.63.0-dev", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/test/dependencies.test.ts b/test/dependencies.test.ts index 7da6ab0a..c3beabde 100644 --- a/test/dependencies.test.ts +++ b/test/dependencies.test.ts @@ -31,10 +31,8 @@ it('declares a compatible dependency on the embedded compiler', () => { const version = JSON.parse( child_process.execSync( - p.join( - __dirname, - '../lib/src/vendor/dart-sass-embedded/dart-sass-embedded' - ) + ' --version', + p.join(__dirname, '../lib/src/vendor/dart-sass/sass') + + ' --embedded --version', {encoding: 'utf-8'} ) ); diff --git a/tool/get-embedded-compiler.ts b/tool/get-embedded-compiler.ts index 894465d0..997953a5 100644 --- a/tool/get-embedded-compiler.ts +++ b/tool/get-embedded-compiler.ts @@ -2,9 +2,7 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import {promises as fs} from 'fs'; import * as p from 'path'; -import * as yaml from 'yaml'; import * as shell from 'shelljs'; import * as utils from './utils'; @@ -19,7 +17,7 @@ export async function getEmbeddedCompiler( outPath: string, options?: {ref: string} | {path: string} ): Promise { - const repo = 'dart-sass-embedded'; + const repo = 'dart-sass'; let source: string; if (!options || 'ref' in options) { @@ -29,7 +27,6 @@ export async function getEmbeddedCompiler( ref: options?.ref ?? 'main', }); source = p.join('build', repo); - await maybeOverrideSassDependency(source); } else { source = options.path; } @@ -38,37 +35,15 @@ export async function getEmbeddedCompiler( await utils.link(p.join(source, 'build'), p.join(outPath, repo)); } -/** - * Overrides Embedded Dart Sass compiler's dependency on Dart Sass to use the - * latest version of Dart Sass from the `main` branch. - * - * This allows us to avoid needing to commit a dependency override to the - * embedded compiler when it doesn't actually require any local changes. - */ -async function maybeOverrideSassDependency(repo: string): Promise { - const pubspecPath = p.join(repo, 'pubspec.yaml'); - const pubspec = yaml.parse( - await fs.readFile(pubspecPath, {encoding: 'utf-8'}) - ); - - console.log(`Overriding ${repo} to load Dart Sass from HEAD.`); - - pubspec['dependency_overrides'] = { - ...pubspec['dependency_overrides'], - sass: {git: 'https://github.com/sass/dart-sass.git'}, - }; - await fs.writeFile(pubspecPath, yaml.stringify(pubspec), {encoding: 'utf-8'}); -} - // Builds the Embedded Dart Sass executable from the source at `repoPath`. function buildDartSassEmbedded(repoPath: string): void { - console.log('Downloading dart-sass-embedded dependencies.'); + console.log("Downloading Dart Sass's dependencies."); shell.exec('dart pub upgrade', { cwd: repoPath, silent: true, }); - console.log('Building dart-sass-embedded executable.'); + console.log('Building the Dart Sass executable.'); shell.exec('dart run grinder protobuf pkg-standalone-dev', { cwd: repoPath, silent: true, diff --git a/tool/prepare-optional-release.ts b/tool/prepare-optional-release.ts index 64c076c3..71daeb1d 100644 --- a/tool/prepare-optional-release.ts +++ b/tool/prepare-optional-release.ts @@ -118,17 +118,13 @@ async function downloadRelease(options: { const dartArch = nodeArchToDartArch(nodeArch); const outPath = p.join('npm', argv.package); await downloadRelease({ - repo: 'dart-sass-embedded', + repo: 'dart-sass', assetUrl: - 'https://github.com/sass/dart-sass-embedded/releases/download/' + - `${version}/sass_embedded-${version}-` + + 'https://github.com/sass/dart-sass/releases/download/' + + `${version}/sass-${version}-` + `${dartPlatform}-${dartArch}${getArchiveExtension(dartPlatform)}`, outPath, }); - await fs.rename( - p.join(outPath, 'sass_embedded'), - p.join(outPath, 'dart-sass-embedded') - ); } catch (error) { console.error(error); process.exitCode = 1; From 8776b611ca4361477478a8cfa1116a52679dc67c Mon Sep 17 00:00:00 2001 From: Goodwine <2022649+Goodwine@users.noreply.github.com> Date: Tue, 16 May 2023 15:58:09 -0700 Subject: [PATCH 28/52] Revert "Bump minipass from 4.2.5 to 6.0.0 (#219)" (#220) This reverts commit 0ac7ec871592147111929ecbeb105fbe8f98a8b5. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c46fea6b..3fb53077 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "extract-zip": "^2.0.1", "gts": "^4.0.0", "jest": "^29.4.1", - "minipass": "6.0.0", + "minipass": "4.2.5", "npm-run-all": "^4.1.5", "path-equal": "^1.2.5", "shelljs": "^0.8.4", From 353c5bb78ee0f98a6b5ea049a0453a43e5631d01 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 16 May 2023 17:52:17 -0700 Subject: [PATCH 29/52] Use the embedded protocol from the language repo --- .eslintignore | 1 - .github/workflows/ci.yml | 27 +++++--------------- CONTRIBUTING.md | 2 +- README.md | 2 +- buf.work.yaml | 2 +- package.json | 1 - test/dependencies.test.ts | 2 +- tool/get-embedded-protocol.ts | 44 -------------------------------- tool/get-js-api.ts | 34 ------------------------- tool/get-language-repo.ts | 42 ++++++++++++++++++++++++++++++ tool/init.ts | 48 ++++++++++------------------------- tool/prepare-release.ts | 7 ++--- 12 files changed, 67 insertions(+), 145 deletions(-) delete mode 100644 tool/get-embedded-protocol.ts delete mode 100644 tool/get-js-api.ts create mode 100644 tool/get-language-repo.ts diff --git a/.eslintignore b/.eslintignore index 41fc7bf4..1505e1ca 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,5 @@ build/ dist/ language/ -embedded-protocol/ lib/src/vendor/ **/*.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a7ebc7a..1d94262d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,19 +25,14 @@ jobs: node-version: ${{ env.DEFAULT_NODE_VERSION }} check-latest: true - - name: Check out the embedded protocol - uses: sass/clone-linked-repo@v1 - with: {repo: sass/embedded-protocol, default-ref: null} - - - name: Check out the JS API definition + - name: Check out the language repo uses: sass/clone-linked-repo@v1 with: {repo: sass/sass, path: language} - run: npm install - name: npm run init run: | - if [[ -d embedded-protocol ]]; then args=--protocol-path=embedded-protocol; fi - npm run init -- --skip-compiler --api-path=language $args + npm run init -- --skip-compiler --language-path=language $args - run: npm run check @@ -63,23 +58,18 @@ jobs: with: {sdk: stable} - run: dart --version - - name: Check out the embedded protocol - uses: sass/clone-linked-repo@v1 - with: {repo: sass/embedded-protocol, default-ref: null} - - name: Check out Dart Sass uses: sass/clone-linked-repo@v1 with: {repo: sass/dart-sass} - - name: Check out the JS API definition + - name: Check out the language repo uses: sass/clone-linked-repo@v1 with: {repo: sass/sass, path: language} - run: npm install - name: npm run init run: | - if [[ -d embedded-protocol ]]; then args=--protocol-path=embedded-protocol; fi - npm run init -- --compiler-path=dart-sass --api-path=language $args + npm run init -- --compiler-path=dart-sass --language-path=language $args - run: npm run test @@ -111,23 +101,18 @@ jobs: - uses: frenck/action-setup-yq@v1 with: {version: v4.30.5} # frenck/action-setup-yq#35 - - name: Check out the embedded protocol - uses: sass/clone-linked-repo@v1 - with: {repo: sass/embedded-protocol, default-ref: null} - - name: Check out Dart Sass uses: sass/clone-linked-repo@v1 with: {repo: sass/dart-sass} - - name: Check out the JS API definition + - name: Check out the language repo uses: sass/clone-linked-repo@v1 with: {repo: sass/sass, path: language} - run: npm install - name: npm run init run: | - if [[ -d embedded-protocol ]]; then args=--protocol-path=embedded-protocol; fi - npm run init -- --compiler-path=dart-sass --api-path=language $args + npm run init -- --compiler-path=dart-sass --language-path=language $args - name: Check out sass-spec uses: sass/clone-linked-repo@v1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 34d80af5..e7c61af0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ different repositories: * The [Sass JS API definition]. [Dart Sass compiler]: https://github.com/sass/dart-sass -[Sass embedded protocol]: https://github.com/sass/embedded-protocol +[Sass embedded protocol]: https://github.com/sass/sass/tree/main/spec/embedded-protocol.md [JS API definition]: https://github.com/sass/sass/tree/main/spec/js-api These dependencies are made available in different ways depending on context. diff --git a/README.md b/README.md index da8b66a8..5cbc44b8 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ API. This includes defining custom importers, functions, and loggers, all of which are invoked by messages from the embedded compiler back to the host. [embedded compiler]: https://github.com/sass/dart-sass#embedded-dart-sass -[Embedded Sass Protocol]: https://github.com/sass/embedded-protocol#readme +[Embedded Sass Protocol]: https://github.com/sass/sass/tree/main/spec/embedded-protocol.md Although this sort of two-way communication with an embedded process is inherently asynchronous in Node.js, this package supports the synchronous diff --git a/buf.work.yaml b/buf.work.yaml index 0cc295bc..005eb6a0 100644 --- a/buf.work.yaml +++ b/buf.work.yaml @@ -1,2 +1,2 @@ version: v1 -directories: [build/embedded-protocol] +directories: [build/sass/spec] diff --git a/package.json b/package.json index 3fb53077..184c1e72 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "jest": "^29.4.1", "minipass": "4.2.5", "npm-run-all": "^4.1.5", - "path-equal": "^1.2.5", "shelljs": "^0.8.4", "source-map-js": "^1.0.2", "tar": "^6.0.5", diff --git a/test/dependencies.test.ts b/test/dependencies.test.ts index c3beabde..cbf9b5a9 100644 --- a/test/dependencies.test.ts +++ b/test/dependencies.test.ts @@ -19,7 +19,7 @@ it('declares a compatible dependency on the embedded protocol', () => { expect( fs .readFileSync( - p.join(__dirname, '../build/embedded-protocol/VERSION'), + p.join(__dirname, '../build/sass/spec/EMBEDDED_PROTOCOL_VERSION'), 'utf-8' ) .trim() diff --git a/tool/get-embedded-protocol.ts b/tool/get-embedded-protocol.ts deleted file mode 100644 index 8ae32a4c..00000000 --- a/tool/get-embedded-protocol.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2022 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. - -import {pathEqual} from 'path-equal'; -import * as shell from 'shelljs'; - -import * as pkg from '../package.json'; -import * as utils from './utils'; - -/** - * Downloads and builds the Embedded Sass protocol definition. - * - * Can check out and build the source from a Git `ref` or build from the source - * at `path`. By default, checks out the tagged version specified in - * package.json's `protocol-version` field. If this version ends in `-dev`, - * checks out the latest revision from GitHub instead. - */ -export async function getEmbeddedProtocol( - outPath: string, - options?: {ref: string} | {path: string} -): Promise { - if (!options || 'ref' in options) { - let ref = options?.ref; - if (ref === undefined) { - const version = pkg['protocol-version'] as string; - ref = version.endsWith('-dev') ? 'main' : version; - } - - utils.fetchRepo({repo: 'embedded-protocol', outPath: 'build', ref}); - } else if (!pathEqual(options.path, 'build/embedded-protocol')) { - await utils.cleanDir('build/embedded-protocol'); - await utils.link(options.path, 'build/embedded-protocol'); - } - - buildEmbeddedProtocol(); -} - -// Builds the embedded proto into a TS file. -function buildEmbeddedProtocol(): void { - const version = shell.exec('npx buf --version', {silent: true}).stdout.trim(); - console.log(`Building TS with buf ${version}.`); - shell.exec('npx buf generate'); -} diff --git a/tool/get-js-api.ts b/tool/get-js-api.ts deleted file mode 100644 index adf73070..00000000 --- a/tool/get-js-api.ts +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2022 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. - -import * as p from 'path'; - -import * as utils from './utils'; - -/** - * Checks out JS API type definitions from the Sass language repo. - * - * Can check out a Git `ref` or link to the source at `path`. By default, checks - * out the latest revision from GitHub. - */ -export async function getJSApi( - outPath: string, - options?: {ref: string} | {path: string} -): Promise { - const repo = 'sass'; - - let source: string; - if (!options || 'ref' in options) { - utils.fetchRepo({ - repo, - outPath: utils.BUILD_PATH, - ref: options?.ref ?? 'main', - }); - source = p.join(utils.BUILD_PATH, repo); - } else { - source = options.path; - } - - await utils.link(p.join(source, 'js-api-doc'), p.join(outPath, repo)); -} diff --git a/tool/get-language-repo.ts b/tool/get-language-repo.ts new file mode 100644 index 00000000..4afec967 --- /dev/null +++ b/tool/get-language-repo.ts @@ -0,0 +1,42 @@ +// Copyright 2022 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. + +import * as p from 'path'; +import * as shell from 'shelljs'; + +import * as utils from './utils'; + +/** + * Downloads the Sass language repo and buids the Embedded Sass protocol + * definition. + * + * Can check out and build the source from a Git `ref` or build from the source + * at `path`. By default, checks out the latest revision from GitHub. + */ +export async function getLanguageRepo( + outPath: string, + options?: {ref: string} | {path: string} +): Promise { + if (!options || 'ref' in options) { + utils.fetchRepo({ + repo: 'sass', + outPath: utils.BUILD_PATH, + ref: options?.ref ?? 'main', + }); + } else { + await utils.cleanDir('build/sass'); + await utils.link(options.path, 'build/sass'); + } + + await utils.link('build/sass/js-api-doc', p.join(outPath, 'sass')); + + buildEmbeddedProtocol(); +} + +// Builds the embedded proto into a TS file. +function buildEmbeddedProtocol(): void { + const version = shell.exec('npx buf --version', {silent: true}).stdout.trim(); + console.log(`Building TS with buf ${version}.`); + shell.exec('npx buf generate'); +} diff --git a/tool/init.ts b/tool/init.ts index 2106a62e..cb50c12b 100644 --- a/tool/init.ts +++ b/tool/init.ts @@ -5,8 +5,7 @@ import yargs from 'yargs'; import {getEmbeddedCompiler} from './get-embedded-compiler'; -import {getEmbeddedProtocol} from './get-embedded-protocol'; -import {getJSApi} from './get-js-api'; +import {getLanguageRepo} from './get-language-repo'; const argv = yargs(process.argv.slice(2)) .option('compiler-path', { @@ -22,27 +21,18 @@ const argv = yargs(process.argv.slice(2)) type: 'boolean', description: "Don't Embedded Dart Sass at all.", }) - .option('protocol-path', { + .option('language-path', { type: 'string', - description: 'Build the Embedded Protocol from the source at this path.', + description: 'Use the Sass language repo from the source at this path.', }) - .option('protocol-ref', { + .option('language-ref', { type: 'string', - description: 'Build the Embedded Protocol from this Git ref.', - }) - .option('api-path', { - type: 'string', - description: 'Use the JS API definitions from the source at this path.', - }) - .option('api-ref', { - type: 'string', - description: 'Build the JS API definitions from this Git ref.', + description: 'Use the Sass language repo from this Git ref.', }) .conflicts({ 'compiler-path': ['compiler-ref', 'skip-compiler'], 'compiler-ref': ['skip-compiler'], - 'protocol-path': ['protocol-ref'], - 'api-path': 'api-ref', + 'language-path': ['language-ref'], }) .parseSync(); @@ -50,16 +40,16 @@ const argv = yargs(process.argv.slice(2)) try { const outPath = 'lib/src/vendor'; - if (argv['protocol-ref']) { - await getEmbeddedProtocol(outPath, { - ref: argv['protocol-ref'], + if (argv['language-ref']) { + await getLanguageRepo(outPath, { + ref: argv['language-ref'], }); - } else if (argv['protocol-path']) { - await getEmbeddedProtocol(outPath, { - path: argv['protocol-path'], + } else if (argv['language-path']) { + await getLanguageRepo(outPath, { + path: argv['language-path'], }); } else { - await getEmbeddedProtocol(outPath); + await getLanguageRepo(outPath); } if (!argv['skip-compiler']) { @@ -75,18 +65,6 @@ const argv = yargs(process.argv.slice(2)) await getEmbeddedCompiler(outPath); } } - - if (argv['api-ref']) { - await getJSApi(outPath, { - ref: argv['api-ref'], - }); - } else if (argv['api-path']) { - await getJSApi(outPath, { - path: argv['api-path'], - }); - } else { - await getJSApi(outPath); - } } catch (error) { console.error(error); process.exitCode = 1; diff --git a/tool/prepare-release.ts b/tool/prepare-release.ts index afbc1f7c..cc741c21 100644 --- a/tool/prepare-release.ts +++ b/tool/prepare-release.ts @@ -6,16 +6,13 @@ import {promises as fs} from 'fs'; import * as shell from 'shelljs'; import * as pkg from '../package.json'; -import {getEmbeddedProtocol} from './get-embedded-protocol'; -import {getJSApi} from './get-js-api'; +import {getLanguageRepo} from './get-language-repo'; (async () => { try { await sanityCheckBeforeRelease(); - await getEmbeddedProtocol('lib/src/vendor'); - - await getJSApi('lib/src/vendor'); + await getLanguageRepo('lib/src/vendor'); console.log('Transpiling TS into dist.'); shell.exec('tsc'); From aec00b292cc6298eb6cf71ddd93d94e9bb6c3672 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 16 May 2023 18:47:38 -0700 Subject: [PATCH 30/52] Don't try to compile TypeScript in the Dart Sass repo --- tsconfig.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 6f1a6a42..693fadcb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,5 +14,8 @@ "lib/**/*.ts", "tool/*.ts" ], - "exclude": ["**/*.test.ts"] + "exclude": [ + "**/*.test.ts", + "lib/src/vendor/dart-sass/**" + ] } From 938b9281a78fd8accd85372a587b951e9ce4c13f Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 5 Jun 2023 18:05:27 -0700 Subject: [PATCH 31/52] Don't try to symlink on Windows in the CI (#225) --- .github/workflows/ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d94262d..58ec7fd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,15 @@ jobs: - name: Compile run: | npm run compile - ln -s {`pwd`/,dist/}lib/src/vendor/dart-sass + if [[ "$RUNNER_OS" == "Windows" ]]; then + # Avoid copying the entire Dart Sass build directory on Windows, + # since it may contain symlinks that cp will choke on. + mkdir -p dist/lib/src/vendor/dart-sass/ + cp {`pwd`/,dist/}lib/src/vendor/dart-sass/sass.bat + cp {`pwd`/,dist/}lib/src/vendor/dart-sass/sass.snapshot + else + ln -s {`pwd`/,dist/}lib/src/vendor/dart-sass + fi - name: Run tests run: npm run js-api-spec -- --sassPackage .. --sassSassRepo ../language From 9ac699771896e5ffe3c26e82c45c7e4bec90a353 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Jun 2023 13:11:37 -0700 Subject: [PATCH 32/52] Bump minipass from 4.2.5 to 6.0.2 (#222) Bumps [minipass](https://github.com/isaacs/minipass) from 4.2.5 to 6.0.2. - [Changelog](https://github.com/isaacs/minipass/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/minipass/compare/v4.2.5...v6.0.2) --- updated-dependencies: - dependency-name: minipass dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 184c1e72..36bd21d7 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "extract-zip": "^2.0.1", "gts": "^4.0.0", "jest": "^29.4.1", - "minipass": "4.2.5", + "minipass": "6.0.2", "npm-run-all": "^4.1.5", "shelljs": "^0.8.4", "source-map-js": "^1.0.2", From ae912fc63eea46fd016b64c8db1a70555ec18d5c Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 6 Jun 2023 14:23:15 -0700 Subject: [PATCH 33/52] Support the Embedded Protocol 2 (#224) --- lib/src/compile.ts | 7 +- lib/src/dispatcher.ts | 113 +++++++++++++--------------- lib/src/message-transformer.test.ts | 29 ++++--- lib/src/message-transformer.ts | 45 ++++++++--- package.json | 6 +- tool/get-embedded-compiler.ts | 12 ++- tool/utils.ts | 23 +++++- 7 files changed, 149 insertions(+), 86 deletions(-) diff --git a/lib/src/compile.ts b/lib/src/compile.ts index ef29f0aa..c60cbf57 100644 --- a/lib/src/compile.ts +++ b/lib/src/compile.ts @@ -259,6 +259,11 @@ function createDispatcher( ); return new Dispatcher( + // Since we only use one compilation per process, we can get away with + // hardcoding a compilation ID. Once we support multiple concurrent + // compilations with the same process, we'll need to ensure each one uses a + // unique ID. + 1, messageTransformer.outboundMessages$, message => messageTransformer.writeInboundMessage(message), handlers @@ -310,7 +315,7 @@ function handleCompileResponse( const success = response.result.value; const result: CompileResult = { css: success.css, - loadedUrls: success.loadedUrls.map(url => new URL(url)), + loadedUrls: response.loadedUrls.map(url => new URL(url)), }; const sourceMap = success.sourceMap; diff --git a/lib/src/dispatcher.ts b/lib/src/dispatcher.ts index c04249f7..08d1271a 100644 --- a/lib/src/dispatcher.ts +++ b/lib/src/dispatcher.ts @@ -5,17 +5,13 @@ import {Observable, Subject} from 'rxjs'; import {filter, map, mergeMap} from 'rxjs/operators'; -import { - InboundRequestType, - OutboundResponse, - OutboundResponseType, -} from './messages'; +import {OutboundResponse} from './messages'; import * as proto from './vendor/embedded_sass_pb'; import {RequestTracker} from './request-tracker'; import {PromiseOr, compilerError, thenOr, hostError} from './utils'; /** - * Dispatches requests, responses, and events. + * Dispatches requests, responses, and events for a single compilation. * * Accepts callbacks for processing different types of outbound requests. When * an outbound request arrives, this runs the appropriate callback to process @@ -35,16 +31,12 @@ import {PromiseOr, compilerError, thenOr, hostError} from './utils'; * perform proper error handling. */ export class Dispatcher { - // Tracks the IDs of all inbound requests. An outbound response with matching - // ID and type will remove the ID. - private readonly pendingInboundRequests = new RequestTracker(); - // Tracks the IDs of all outbound requests. An inbound response with matching // ID and type will remove the ID. private readonly pendingOutboundRequests = new RequestTracker(); - // All outbound messages. If we detect any errors while dispatching messages, - // this completes. + // All outbound messages for this compilation. If we detect any errors while + // dispatching messages, this completes. private readonly messages$ = new Subject(); // If the dispatcher encounters an error, this errors out. It is publicly @@ -68,14 +60,23 @@ export class Dispatcher { ); constructor( - private readonly outboundMessages$: Observable, + private readonly compilationId: number, + private readonly outboundMessages$: Observable< + [number, proto.OutboundMessage] + >, private readonly writeInboundMessage: ( - message: proto.InboundMessage + message: [number, proto.InboundMessage] ) => void, private readonly outboundRequestHandlers: DispatcherHandlers ) { + if (compilationId < 1) { + throw Error(`Invalid compilation ID ${compilationId}.`); + } + this.outboundMessages$ .pipe( + filter(([compilationId]) => compilationId === this.compilationId), + map(([, message]) => message), mergeMap(message => { const result = this.handleOutboundMessage(message); return result instanceof Promise @@ -108,11 +109,30 @@ export class Dispatcher { response: proto.OutboundMessage_CompileResponse | undefined ) => void ): void { - this.handleInboundRequest( - {value: request, case: 'compileRequest'}, - 'compileResponse', - callback - ); + if (this.messages$.isStopped) { + callback(new Error('Tried writing to closed dispatcher'), undefined); + return; + } + + this.messages$ + .pipe( + filter(message => message.message.case === 'compileResponse'), + map(message => message.message.value as OutboundResponse) + ) + .subscribe({next: response => callback(null, response)}); + + this.error$.subscribe({error: error => callback(error, undefined)}); + + try { + this.writeInboundMessage([ + this.compilationId, + new proto.InboundMessage({ + message: {value: request, case: 'compileRequest'}, + }), + ]); + } catch (error) { + this.throwAndClose(error); + } } // Rejects with `error` all promises awaiting an outbound response, and @@ -135,10 +155,7 @@ export class Dispatcher { return undefined; case 'compileResponse': - this.pendingInboundRequests.resolve( - message.message.value.id, - message.message.case - ); + // Handled separately by `sendCompileRequest`. return undefined; case 'importRequest': { @@ -202,57 +219,31 @@ export class Dispatcher { } } - // Sends `request` inbound. Once it's done, calls `callback` with either the - // corresponding outbound response of type `responseType`, or an error if any - // protocol errors were encountered. - private handleInboundRequest( - request: proto.InboundMessage['message'] & {case: InboundRequestType}, - responseType: OutboundResponseType, - callback: (err: unknown, response: OutboundResponse | undefined) => void - ): void { - if (this.messages$.isStopped) { - callback(new Error('Tried writing to closed dispatcher'), undefined); - return; - } - - this.messages$ - .pipe( - filter(message => message.message.case === responseType), - map(message => message.message.value as OutboundResponse), - filter(response => response.id === request.value.id) - ) - .subscribe({next: response => callback(null, response)}); - - this.error$.subscribe({error: error => callback(error, undefined)}); - - try { - this.sendInboundMessage(this.pendingInboundRequests.nextId, request); - } catch (error) { - this.throwAndClose(error); - } - } - // Sends a message inbound. Keeps track of all pending inbound requests. private sendInboundMessage( - id: number, - message: Exclude + requestId: number, + message: Exclude< + proto.InboundMessage['message'], + {case: undefined | 'compileRequest'} + > ): void { - message.value.id = id; + message.value.id = requestId; - if (message.case === 'compileRequest') { - this.pendingInboundRequests.add(id, 'compileResponse'); - } else if ( + if ( message.case === 'importResponse' || message.case === 'fileImportResponse' || message.case === 'canonicalizeResponse' || message.case === 'functionCallResponse' ) { - this.pendingOutboundRequests.resolve(id, message.case); + this.pendingOutboundRequests.resolve(requestId, message.case); } else { throw Error(`Unknown message type ${message.case}`); } - this.writeInboundMessage(new proto.InboundMessage({message})); + this.writeInboundMessage([ + this.compilationId, + new proto.InboundMessage({message}), + ]); } } diff --git a/lib/src/message-transformer.test.ts b/lib/src/message-transformer.test.ts index 26a97e88..d74f2e28 100644 --- a/lib/src/message-transformer.test.ts +++ b/lib/src/message-transformer.test.ts @@ -3,6 +3,7 @@ // https://opensource.org/licenses/MIT. import {Subject, Observable} from 'rxjs'; +import * as varint from 'varint'; import {expectObservableToError} from '../../test/utils'; import {MessageTransformer} from './message-transformer'; @@ -39,14 +40,16 @@ describe('message transformer', () => { it('encodes an InboundMessage to buffer', () => { const message = validInboundMessage('a {b: c}'); - messages.writeInboundMessage(message); - expect(encodedProtobufs).toEqual([message.toBinary()]); + messages.writeInboundMessage([1234, message]); + expect(encodedProtobufs).toEqual([ + Uint8Array.from([...varint.encode(1234), ...message.toBinary()]), + ]); }); }); describe('decode', () => { - let protobufs$: Subject; - let decodedMessages: proto.OutboundMessage[]; + let protobufs$: Subject; + let decodedMessages: Array<[number, proto.OutboundMessage]>; beforeEach(() => { protobufs$ = new Subject(); @@ -55,14 +58,14 @@ describe('message transformer', () => { }); it('decodes buffer to OutboundMessage', done => { - const message = validInboundMessage('a {b: c}'); - messages.outboundMessages$.subscribe({ next: message => decodedMessages.push(message), complete: () => { expect(decodedMessages.length).toBe(1); - expect(decodedMessages[0].message.case).toBe('compileResponse'); - const response = decodedMessages[0].message + const [id, message] = decodedMessages[0]; + expect(id).toBe(1234); + expect(message.message.case).toBe('compileResponse'); + const response = message.message .value as proto.OutboundMessage_CompileResponse; expect(response.result.case).toBe('success'); expect( @@ -75,7 +78,12 @@ describe('message transformer', () => { }, }); - protobufs$.next(Buffer.from(message.toBinary())); + protobufs$.next( + Uint8Array.from([ + ...varint.encode(1234), + ...validInboundMessage('a {b: c}').toBinary(), + ]) + ); protobufs$.complete(); }); @@ -83,7 +91,8 @@ describe('message transformer', () => { it('fails on invalid buffer', done => { expectObservableToError( messages.outboundMessages$, - 'Compiler caused error: Invalid buffer.', + 'Compiler caused error: Invalid compilation ID varint: RangeError: ' + + 'Could not decode varint.', done ); diff --git a/lib/src/message-transformer.ts b/lib/src/message-transformer.ts index 1aa2c64f..703b0c96 100644 --- a/lib/src/message-transformer.ts +++ b/lib/src/message-transformer.ts @@ -4,6 +4,7 @@ import {Observable, Subject} from 'rxjs'; import {map} from 'rxjs/operators'; +import * as varint from 'varint'; import {compilerError} from './utils'; import {InboundMessage, OutboundMessage} from './vendor/embedded_sass_pb'; @@ -15,7 +16,9 @@ import {InboundMessage, OutboundMessage} from './vendor/embedded_sass_pb'; export class MessageTransformer { // The decoded messages are written to this Subject. It is publicly exposed // as a readonly Observable. - private readonly outboundMessagesInternal$ = new Subject(); + private readonly outboundMessagesInternal$ = new Subject< + [number, OutboundMessage] + >(); /** * The OutboundMessages, decoded from protocol buffers. If this fails to @@ -33,24 +36,46 @@ export class MessageTransformer { } /** - * Converts the inbound `message` to a protocol buffer. + * Converts the inbound `compilationId` and `message` to a protocol buffer. */ - writeInboundMessage(message: InboundMessage): void { + writeInboundMessage([compilationId, message]: [ + number, + InboundMessage + ]): void { + const compilationIdLength = varint.encodingLength(compilationId); + const encodedMessage = message.toBinary(); + const buffer = new Uint8Array(compilationIdLength + encodedMessage.length); + varint.encode(compilationId, buffer); + buffer.set(encodedMessage, compilationIdLength); + try { - this.writeInboundProtobuf(message.toBinary()); + this.writeInboundProtobuf(buffer); } catch (error) { this.outboundMessagesInternal$.error(error); } } } -// Decodes a protobuf `buffer` into an OutboundMessage, ensuring that all -// mandatory message fields are populated. Throws if `buffer` cannot be decoded -// into a valid message, or if the message itself contains a Protocol Error. -function decode(buffer: Uint8Array): OutboundMessage { +// Decodes a protobuf `buffer` into a compilation ID and an OutboundMessage, +// ensuring that all mandatory message fields are populated. Throws if `buffer` +// cannot be decoded into a valid message, or if the message itself contains a +// Protocol Error. +function decode(buffer: Uint8Array): [number, OutboundMessage] { + let compilationId: number; + try { + compilationId = varint.decode(buffer); + } catch (error) { + throw compilerError(`Invalid compilation ID varint: ${error}`); + } + try { - return OutboundMessage.fromBinary(buffer); + return [ + compilationId, + OutboundMessage.fromBinary( + new Uint8Array(buffer.buffer, varint.decode.bytes) + ), + ]; } catch (error) { - throw compilerError('Invalid buffer'); + throw compilerError(`Invalid protobuf: ${error}`); } } diff --git a/package.json b/package.json index 36bd21d7..88fd127c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sass-embedded", "version": "1.62.1", - "protocol-version": "1.2.0", + "protocol-version": "2.0.0", "compiler-version": "1.63.0-dev", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", @@ -41,7 +41,8 @@ "buffer-builder": "^0.2.0", "immutable": "^4.0.0", "rxjs": "^7.4.0", - "supports-color": "^8.1.1" + "supports-color": "^8.1.1", + "varint": "^6.0.0" }, "devDependencies": { "@bufbuild/buf": "^1.13.1-4", @@ -53,6 +54,7 @@ "@types/shelljs": "^0.8.8", "@types/supports-color": "^8.1.1", "@types/tar": "^6.1.0", + "@types/varint": "^6.0.1", "@types/yargs": "^17.0.4", "del": "^6.0.0", "extract-zip": "^2.0.1", diff --git a/tool/get-embedded-compiler.ts b/tool/get-embedded-compiler.ts index 997953a5..2b702a2a 100644 --- a/tool/get-embedded-compiler.ts +++ b/tool/get-embedded-compiler.ts @@ -31,6 +31,16 @@ export async function getEmbeddedCompiler( source = options.path; } + // Make sure the compiler sees the same version of the language repo that the + // host is using, but if they're already the same directory (as in the Dart + // Sass CI environment) we don't need to do anything. + const languageInHost = p.resolve('build/sass'); + const languageInCompiler = p.resolve(p.join(source, 'build/language')); + if (!(await utils.sameTarget(languageInHost, languageInCompiler))) { + await utils.cleanDir(languageInCompiler); + await utils.link(languageInHost, languageInCompiler); + } + buildDartSassEmbedded(source); await utils.link(p.join(source, 'build'), p.join(outPath, repo)); } @@ -46,6 +56,6 @@ function buildDartSassEmbedded(repoPath: string): void { console.log('Building the Dart Sass executable.'); shell.exec('dart run grinder protobuf pkg-standalone-dev', { cwd: repoPath, - silent: true, + env: {...process.env, UPDATE_SASS_PROTOCOL: 'false'}, }); } diff --git a/tool/utils.ts b/tool/utils.ts index 36a2cc5f..3e4a343c 100644 --- a/tool/utils.ts +++ b/tool/utils.ts @@ -47,9 +47,10 @@ export async function link(source: string, destination: string): Promise { console.log(`Copying ${source} into ${destination}.`); shell.cp('-R', source, destination); } else { + source = p.resolve(source); console.log(`Linking ${source} into ${destination}.`); // Symlinking doesn't play nice with Jasmine's test globbing on Windows. - await fs.symlink(p.resolve(source), destination); + await fs.symlink(source, destination); } } @@ -62,3 +63,23 @@ export async function cleanDir(dir: string): Promise { // If dir doesn't exist yet, that's fine. } } + +/// Returns whether [path1] and [path2] are symlinks that refer to the same file. +export async function sameTarget( + path1: string, + path2: string +): Promise { + const realpath1 = await tryRealpath(path1); + if (realpath1 === null) return false; + + return realpath1 === (await tryRealpath(path2)); +} + +/// Like `fs.realpath()`, but returns `null` if the path doesn't exist on disk. +async function tryRealpath(path: string): Promise { + try { + return await fs.realpath(p.resolve(path)); + } catch (_) { + return null; + } +} From 8351cae47bd817c9918887acd294d9625a1e942c Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Thu, 8 Jun 2023 01:49:43 +0000 Subject: [PATCH 34/52] Update Dart Sass version and release --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 +++++++++---------- 10 files changed, 55 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74dd0ba2..4356ef08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,40 @@ +## 1.63.2 + +* No user-visible changes. + +## 1.63.1 + +* No user-visible changes. + +## 1.63.0 + +### JavaScript API + +* Dart Sass's JS API now supports running in the browser. Further details and + instructions for use are in [the README](README.md#dart-sass-in-the-browser). + +### Embedded Sass + +* The Dart Sass embedded compiler is now included as part of the primary Dart + Sass distribution, rather than a separate executable. To use the embedded + compiler, just run `sass --embedded` from any Sass executable (other than the + pure JS executable). + + The Node.js embedded host will still be distributed as the `sass-embedded` + package on npm. The only change is that it will now provide direct access to a + `sass` executable with the same CLI as the `sass` package. + +* The Dart Sass embedded compiler now uses version 2.0.0 of the Sass embedded + protocol. See [the spec][embedded-protocol-spec] for a full description of the + protocol, and [the changelog][embedded-protocol-changelog] for a summary of + changes since version 1.2.0. + + [embedded-protocol-spec]: https://github.com/sass/sass/blob/main/spec/embedded-protocol.md + [embedded-protocol-changelog]: https://github.com/sass/sass/blob/main/EMBEDDED_PROTOCOL_CHANGELOG.md + +* The Dart Sass embedded compiler now runs multiple simultaneous compilations in + parallel, rather than serially. + ## 1.62.1 * Fix a bug where `:has(+ &)` and related constructs would drop the leading diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index bd9a6524..ff027982 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.62.1", + "version": "1.63.2", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index c074c3a9..0313d777 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.62.1", + "version": "1.63.2", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 902c48bc..f703c79b 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.62.1", + "version": "1.63.2", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index da837b26..20b23879 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.62.1", + "version": "1.63.2", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index b9fda742..099f6c93 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.62.1", + "version": "1.63.2", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index 7b9d0cf5..488ce81d 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.62.1", + "version": "1.63.2", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 0e3aa7a6..217679b9 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.62.1", + "version": "1.63.2", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 4245453c..577fd98e 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.62.1", + "version": "1.63.2", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 88fd127c..dabdd62b 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.62.1", + "version": "1.63.2", "protocol-version": "2.0.0", - "compiler-version": "1.63.0-dev", + "compiler-version": "1.63.2", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.62.1", - "sass-embedded-darwin-x64": "1.62.1", - "sass-embedded-linux-arm": "1.62.1", - "sass-embedded-linux-arm64": "1.62.1", - "sass-embedded-linux-ia32": "1.62.1", - "sass-embedded-linux-x64": "1.62.1", - "sass-embedded-win32-ia32": "1.62.1", - "sass-embedded-win32-x64": "1.62.1" + "sass-embedded-darwin-arm64": "1.63.2", + "sass-embedded-darwin-x64": "1.63.2", + "sass-embedded-linux-arm": "1.63.2", + "sass-embedded-linux-arm64": "1.63.2", + "sass-embedded-linux-ia32": "1.63.2", + "sass-embedded-linux-x64": "1.63.2", + "sass-embedded-win32-ia32": "1.63.2", + "sass-embedded-win32-x64": "1.63.2" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 1381f56f2ed672ad3f8ce922a45107f755192db8 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 8 Jun 2023 14:12:34 -0700 Subject: [PATCH 35/52] Fix the asset URL for Dart Sass (#227) --- tool/prepare-optional-release.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/prepare-optional-release.ts b/tool/prepare-optional-release.ts index 71daeb1d..9ad7cb68 100644 --- a/tool/prepare-optional-release.ts +++ b/tool/prepare-optional-release.ts @@ -121,7 +121,7 @@ async function downloadRelease(options: { repo: 'dart-sass', assetUrl: 'https://github.com/sass/dart-sass/releases/download/' + - `${version}/sass-${version}-` + + `${version}/dart-sass-${version}-` + `${dartPlatform}-${dartArch}${getArchiveExtension(dartPlatform)}`, outPath, }); From 9fce9b2b25f6ef298fd06fb0ba04b226a0c3dddf Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Fri, 9 Jun 2023 16:04:21 +0000 Subject: [PATCH 36/52] Update Dart Sass version and release --- CHANGELOG.md | 6 ++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4356ef08..b754168a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.63.3 + +### JavaScript API + +* Fix loading Sass as an ECMAScript module on Node.js. + ## 1.63.2 * No user-visible changes. diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index ff027982..51a59b09 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.63.2", + "version": "1.63.3", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 0313d777..b1a1d4a2 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.63.2", + "version": "1.63.3", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index f703c79b..0c210005 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.63.2", + "version": "1.63.3", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 20b23879..37802dba 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.63.2", + "version": "1.63.3", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 099f6c93..b908ca50 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.63.2", + "version": "1.63.3", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index 488ce81d..3e5eb3ca 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.63.2", + "version": "1.63.3", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 217679b9..fd365999 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.63.2", + "version": "1.63.3", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 577fd98e..6f86f5c0 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.63.2", + "version": "1.63.3", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index dabdd62b..e7907ab0 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.63.2", + "version": "1.63.3", "protocol-version": "2.0.0", - "compiler-version": "1.63.2", + "compiler-version": "1.63.3", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -27,14 +27,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.63.2", - "sass-embedded-darwin-x64": "1.63.2", - "sass-embedded-linux-arm": "1.63.2", - "sass-embedded-linux-arm64": "1.63.2", - "sass-embedded-linux-ia32": "1.63.2", - "sass-embedded-linux-x64": "1.63.2", - "sass-embedded-win32-ia32": "1.63.2", - "sass-embedded-win32-x64": "1.63.2" + "sass-embedded-darwin-arm64": "1.63.3", + "sass-embedded-darwin-x64": "1.63.3", + "sass-embedded-linux-arm": "1.63.3", + "sass-embedded-linux-arm64": "1.63.3", + "sass-embedded-linux-ia32": "1.63.3", + "sass-embedded-linux-x64": "1.63.3", + "sass-embedded-win32-ia32": "1.63.3", + "sass-embedded-win32-x64": "1.63.3" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 4e12a1a0b035ac4b53eb94c474c102c7f341ef3c Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 9 Jun 2023 15:50:32 -0700 Subject: [PATCH 37/52] Bump the protocol version (#228) Also stop testing for a compatible embedded compiler version. Now that we've got linked pull requests and pull from main by default, keeping this up-to-date is just busywork. --- package.json | 2 +- test/dependencies.test.ts | 19 ++----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index e7907ab0..4d39dd78 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sass-embedded", "version": "1.63.3", - "protocol-version": "2.0.0", + "protocol-version": "2.1.0", "compiler-version": "1.63.3", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", diff --git a/test/dependencies.test.ts b/test/dependencies.test.ts index cbf9b5a9..25b3bea6 100644 --- a/test/dependencies.test.ts +++ b/test/dependencies.test.ts @@ -8,10 +8,8 @@ import * as p from 'path'; import * as pkg from '../package.json'; -// These tests assert that our declared dependencies on the embedded protocol -// and compiler are either -dev versions (which download the latest main -// branches of each repo and block release) or the same versions as the versions -// we're testing against. +// These tests assert that our declared dependency on the embedded protocol is +// either a -dev version or the same version we're testing against. it('declares a compatible dependency on the embedded protocol', () => { if (pkg['protocol-version'].endsWith('-dev')) return; @@ -25,16 +23,3 @@ it('declares a compatible dependency on the embedded protocol', () => { .trim() ).toBe(pkg['protocol-version']); }); - -it('declares a compatible dependency on the embedded compiler', () => { - if (pkg['compiler-version'].endsWith('-dev')) return; - - const version = JSON.parse( - child_process.execSync( - p.join(__dirname, '../lib/src/vendor/dart-sass/sass') + - ' --embedded --version', - {encoding: 'utf-8'} - ) - ); - expect(version.compilerVersion).toBe(pkg['compiler-version']); -}); From ad48f1cd9dcddffb49033bd889dffb17a00d6976 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 13 Jun 2023 16:33:56 -0700 Subject: [PATCH 38/52] Emit a deprecation warning when loaded as a default export (#230) See #229 --- .github/workflows/ci.yml | 6 +- lib/index.mjs | 154 ++++++++++++++++++++++++++++++++++++ package.json | 6 +- test/after-compile-test.mjs | 33 ++++++++ test/dependencies.test.ts | 1 - tool/prepare-release.ts | 1 + 6 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 lib/index.mjs create mode 100644 test/after-compile-test.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58ec7fd9..70129465 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,8 +52,6 @@ jobs: with: node-version: ${{ matrix.node-version }} check-latest: true - - uses: frenck/action-setup-yq@v1 - with: {version: v4.30.5} # frenck/action-setup-yq#35 - uses: dart-lang/setup-dart@v1 with: {sdk: stable} - run: dart --version @@ -72,6 +70,8 @@ jobs: npm run init -- --compiler-path=dart-sass --language-path=language $args - run: npm run test + - run: npm run compile + - run: node test/after-compile-test.mjs # The versions should be kept up-to-date with the latest LTS Node releases. # They next need to be rotated October 2021. See @@ -98,8 +98,6 @@ jobs: with: {sdk: stable} - uses: actions/setup-node@v2 with: {node-version: "${{ matrix.node_version }}"} - - uses: frenck/action-setup-yq@v1 - with: {version: v4.30.5} # frenck/action-setup-yq#35 - name: Check out Dart Sass uses: sass/clone-linked-repo@v1 diff --git a/lib/index.mjs b/lib/index.mjs new file mode 100644 index 00000000..31a57f8e --- /dev/null +++ b/lib/index.mjs @@ -0,0 +1,154 @@ +import * as sass from './index.js'; + +export const compile = sass.compile; +export const compileAsync = sass.compileAsync; +export const compileString = sass.compileString; +export const compileStringAsync = sass.compileStringAsync; +export const Logger = sass.Logger; +export const SassArgumentList = sass.SassArgumentList; +export const SassBoolean = sass.SassBoolean; +export const SassColor = sass.SassColor; +export const SassFunction = sass.SassFunction; +export const SassList = sass.SassList; +export const SassMap = sass.SassMap; +export const SassNumber = sass.SassNumber; +export const SassString = sass.SassString; +export const Value = sass.Value; +export const CustomFunction = sass.CustomFunction; +export const ListSeparator = sass.ListSeparator; +export const sassFalse = sass.sassFalse; +export const sassNull = sass.sassNull; +export const sassTrue = sass.sassTrue; +export const Exception = sass.Exception; +export const PromiseOr = sass.PromiseOr; +export const info = sass.info; +export const render = sass.render; +export const renderSync = sass.renderSync; +export const TRUE = sass.TRUE; +export const FALSE = sass.FALSE; +export const NULL = sass.NULL; +export const types = sass.types; + +let printedDefaultExportDeprecation = false; +function defaultExportDeprecation() { + if (printedDefaultExportDeprecation) return; + printedDefaultExportDeprecation = true; + console.error( + "`import sass from 'sass'` is deprecated.\n" + + "Please use `import * as sass from 'sass'` instead."); +} + +export default { + get compile() { + defaultExportDeprecation(); + return sass.compile; + }, + get compileAsync() { + defaultExportDeprecation(); + return sass.compileAsync; + }, + get compileString() { + defaultExportDeprecation(); + return sass.compileString; + }, + get compileStringAsync() { + defaultExportDeprecation(); + return sass.compileStringAsync; + }, + get Logger() { + defaultExportDeprecation(); + return sass.Logger; + }, + get SassArgumentList() { + defaultExportDeprecation(); + return sass.SassArgumentList; + }, + get SassBoolean() { + defaultExportDeprecation(); + return sass.SassBoolean; + }, + get SassColor() { + defaultExportDeprecation(); + return sass.SassColor; + }, + get SassFunction() { + defaultExportDeprecation(); + return sass.SassFunction; + }, + get SassList() { + defaultExportDeprecation(); + return sass.SassList; + }, + get SassMap() { + defaultExportDeprecation(); + return sass.SassMap; + }, + get SassNumber() { + defaultExportDeprecation(); + return sass.SassNumber; + }, + get SassString() { + defaultExportDeprecation(); + return sass.SassString; + }, + get Value() { + defaultExportDeprecation(); + return sass.Value; + }, + get CustomFunction() { + defaultExportDeprecation(); + return sass.CustomFunction; + }, + get ListSeparator() { + defaultExportDeprecation(); + return sass.ListSeparator; + }, + get sassFalse() { + defaultExportDeprecation(); + return sass.sassFalse; + }, + get sassNull() { + defaultExportDeprecation(); + return sass.sassNull; + }, + get sassTrue() { + defaultExportDeprecation(); + return sass.sassTrue; + }, + get Exception() { + defaultExportDeprecation(); + return sass.Exception; + }, + get PromiseOr() { + defaultExportDeprecation(); + return sass.PromiseOr; + }, + get info() { + defaultExportDeprecation(); + return sass.info; + }, + get render() { + defaultExportDeprecation(); + return sass.render; + }, + get renderSync() { + defaultExportDeprecation(); + return sass.renderSync; + }, + get TRUE() { + defaultExportDeprecation(); + return sass.TRUE; + }, + get FALSE() { + defaultExportDeprecation(); + return sass.FALSE; + }, + get NULL() { + defaultExportDeprecation(); + return sass.NULL; + }, + get types() { + defaultExportDeprecation(); + return sass.types; + }, +}; diff --git a/package.json b/package.json index 4d39dd78..0d0414ac 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,10 @@ "repository": "sass/embedded-host-node", "author": "Google Inc.", "license": "MIT", + "exports": { + "import": "dist/lib/index.mjs", + "default": "dist/lib/index.js" + }, "main": "dist/lib/index.js", "types": "dist/types/index.d.ts", "files": [ @@ -21,7 +25,7 @@ "check:gts": "gts check", "check:tsc": "tsc --noEmit", "clean": "gts clean", - "compile": "tsc", + "compile": "tsc && cp lib/index.mjs dist/lib/index.mjs", "fix": "gts fix", "prepublishOnly": "npm run clean && ts-node ./tool/prepare-release.ts", "test": "jest" diff --git a/test/after-compile-test.mjs b/test/after-compile-test.mjs new file mode 100644 index 00000000..805cbca6 --- /dev/null +++ b/test/after-compile-test.mjs @@ -0,0 +1,33 @@ +// Copyright 2023 Google LLC. 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. + +import * as fs from 'fs'; + +// Note: this file isn't .test.ts specifically because we _don't_ want Jest to +// handle it, because Jest chokes on dynamic imports of literal ESM modules. + +// This file should only be run _after_ `npm run compile`. +if (!fs.existsSync('dist/package.json')) { + throw new Error('after-compile.test.ts must be run after `npm run compile`.'); +} + +// Load these dynamically so we have a better error mesage if `npm run compile` +// hasn't been run. +const cjs = await import('../dist/lib/index.js'); +const esm = await import('../dist/lib/index.mjs'); + +for (const [name, value] of Object.entries(cjs)) { + if (name === '__esModule' || name === 'default') continue; + if (!esm[name]) { + throw new Error(`ESM module is missing export ${name}.`); + } else if (esm[name] !== value) { + throw new Error(`ESM ${name} isn't the same as CJS.`); + } + + if (!esm.default[name]) { + throw new Error(`ESM default export is missing export ${name}.`); + } else if (esm.default[name] !== value) { + throw new Error(`ESM default export ${name} isn't the same as CJS.`); + } +} diff --git a/test/dependencies.test.ts b/test/dependencies.test.ts index 25b3bea6..e29f547a 100644 --- a/test/dependencies.test.ts +++ b/test/dependencies.test.ts @@ -2,7 +2,6 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import * as child_process from 'child_process'; import * as fs from 'fs'; import * as p from 'path'; diff --git a/tool/prepare-release.ts b/tool/prepare-release.ts index cc741c21..8d4c08b4 100644 --- a/tool/prepare-release.ts +++ b/tool/prepare-release.ts @@ -16,6 +16,7 @@ import {getLanguageRepo} from './get-language-repo'; console.log('Transpiling TS into dist.'); shell.exec('tsc'); + shell.cp('lib/index.mjs', 'dist/lib/index.mjs'); console.log('Copying JS API types to dist.'); shell.cp('-R', 'lib/src/vendor/sass', 'dist/types'); From cbaede36114d0c74657ed15c862027862aa689a5 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Wed, 14 Jun 2023 00:59:22 +0000 Subject: [PATCH 39/52] Update Dart Sass version and release --- CHANGELOG.md | 23 +++++++++++++++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 41 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b754168a..411bfe56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +## 1.63.4 + +### JavaScript API + +* Re-enable support for `import sass from 'sass'` when loading the package from + an ESM module in Node.js. However, this syntax is now deprecated; ESM users + should use `import * as sass from 'sass'` instead. + + On the browser and other ESM-only platforms, only `import * as sass from + 'sass'` is supported. + +* Properly export the legacy API values `TRUE`, `FALSE`, `NULL`, and `types` from + the ECMAScript module API. + +### Embedded Sass + +* Fix a race condition where closing standard input while requests are in-flight + could sometimes cause the process to hang rather than shutting down + gracefully. + +* Properly include the root stylesheet's URL in the set of loaded URLs when it + fails to parse. + ## 1.63.3 ### JavaScript API diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 51a59b09..2635faef 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.63.3", + "version": "1.63.4", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index b1a1d4a2..2f972af3 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.63.3", + "version": "1.63.4", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 0c210005..e8d4ad62 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.63.3", + "version": "1.63.4", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 37802dba..b4d073ca 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.63.3", + "version": "1.63.4", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index b908ca50..9d0bdc28 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.63.3", + "version": "1.63.4", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index 3e5eb3ca..c73cf35d 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.63.3", + "version": "1.63.4", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index fd365999..9e141054 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.63.3", + "version": "1.63.4", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 6f86f5c0..d3509eb2 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.63.3", + "version": "1.63.4", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 0d0414ac..5ca1f09e 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.63.3", + "version": "1.63.4", "protocol-version": "2.1.0", - "compiler-version": "1.63.3", + "compiler-version": "1.63.4", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -31,14 +31,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.63.3", - "sass-embedded-darwin-x64": "1.63.3", - "sass-embedded-linux-arm": "1.63.3", - "sass-embedded-linux-arm64": "1.63.3", - "sass-embedded-linux-ia32": "1.63.3", - "sass-embedded-linux-x64": "1.63.3", - "sass-embedded-win32-ia32": "1.63.3", - "sass-embedded-win32-x64": "1.63.3" + "sass-embedded-darwin-arm64": "1.63.4", + "sass-embedded-darwin-x64": "1.63.4", + "sass-embedded-linux-arm": "1.63.4", + "sass-embedded-linux-arm64": "1.63.4", + "sass-embedded-linux-ia32": "1.63.4", + "sass-embedded-linux-x64": "1.63.4", + "sass-embedded-win32-ia32": "1.63.4", + "sass-embedded-win32-x64": "1.63.4" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From f698ad1c661431102dace3b8ac50599744547835 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Wed, 21 Jun 2023 01:22:02 +0000 Subject: [PATCH 40/52] Update Dart Sass version and release --- CHANGELOG.md | 14 ++++++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 32 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 411bfe56..dd4a720e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## 1.63.5 + +### JavaScript API + +* Fix a bug where loading the package through both CJS `require()` and ESM + `import` could crash on Node.js. + +### Embedded Sass + +* Fix a deadlock when running at high concurrency on 32-bit systems. + +* Fix a race condition where the embedded compiler could deadlock or crash if a + compilation ID was reused immediately after the compilation completed. + ## 1.63.4 ### JavaScript API diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 2635faef..c822ed10 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.63.4", + "version": "1.63.5", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 2f972af3..5850e7de 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.63.4", + "version": "1.63.5", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index e8d4ad62..a8e7cad6 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.63.4", + "version": "1.63.5", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index b4d073ca..793b8e11 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.63.4", + "version": "1.63.5", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 9d0bdc28..b899a8a3 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.63.4", + "version": "1.63.5", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index c73cf35d..2e1490d3 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.63.4", + "version": "1.63.5", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 9e141054..ce979549 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.63.4", + "version": "1.63.5", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index d3509eb2..4bcbf7e8 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.63.4", + "version": "1.63.5", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 5ca1f09e..7de595d9 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.63.4", + "version": "1.63.5", "protocol-version": "2.1.0", - "compiler-version": "1.63.4", + "compiler-version": "1.63.5", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -31,14 +31,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.63.4", - "sass-embedded-darwin-x64": "1.63.4", - "sass-embedded-linux-arm": "1.63.4", - "sass-embedded-linux-arm64": "1.63.4", - "sass-embedded-linux-ia32": "1.63.4", - "sass-embedded-linux-x64": "1.63.4", - "sass-embedded-win32-ia32": "1.63.4", - "sass-embedded-win32-x64": "1.63.4" + "sass-embedded-darwin-arm64": "1.63.5", + "sass-embedded-darwin-x64": "1.63.5", + "sass-embedded-linux-arm": "1.63.5", + "sass-embedded-linux-arm64": "1.63.5", + "sass-embedded-linux-ia32": "1.63.5", + "sass-embedded-linux-x64": "1.63.5", + "sass-embedded-win32-ia32": "1.63.5", + "sass-embedded-win32-x64": "1.63.5" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 35dafed90200320f092162d167bf29af05a3768b Mon Sep 17 00:00:00 2001 From: BCaspari Date: Wed, 21 Jun 2023 22:11:38 +0200 Subject: [PATCH 41/52] Update package.json (#231) Fixed exports paths in package.json - they have to start with ./ according to https://nodejs.org/api/packages.html#exports The current paths break the build when using sass-loader with sass-embedded and webpack 5.86.0: [webpack-cli] Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "dist/lib/index.js" defined in the package config /home/runner/work/ProcessHub/ProcessHub/app/node_modules/sass-embedded/package.json; targets must start with "./" --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7de595d9..a4e5f7fd 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "author": "Google Inc.", "license": "MIT", "exports": { - "import": "dist/lib/index.mjs", - "default": "dist/lib/index.js" + "import": "./dist/lib/index.mjs", + "default": "./dist/lib/index.js" }, "main": "dist/lib/index.js", "types": "dist/types/index.d.ts", From 886dba4ab8260076c64e131bb0cca282e1495d4f Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Wed, 21 Jun 2023 22:18:44 +0000 Subject: [PATCH 42/52] Update Dart Sass version and release --- CHANGELOG.md | 10 ++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 28 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd4a720e..5ee952d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 1.63.6 + +### JavaScript API + +* Fix `import sass from 'sass'` again after it was broken in the last release. + +### Embedded Sass + +* Fix the `exports` declaration in `package.json`. + ## 1.63.5 ### JavaScript API diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index c822ed10..b6e50c17 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.63.5", + "version": "1.63.6", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 5850e7de..2be3705b 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.63.5", + "version": "1.63.6", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index a8e7cad6..a9c271ca 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.63.5", + "version": "1.63.6", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 793b8e11..6e7e206a 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.63.5", + "version": "1.63.6", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index b899a8a3..6102d10f 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.63.5", + "version": "1.63.6", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index 2e1490d3..28097ece 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.63.5", + "version": "1.63.6", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index ce979549..ccca0225 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.63.5", + "version": "1.63.6", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 4bcbf7e8..3a9dd423 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.63.5", + "version": "1.63.6", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index a4e5f7fd..e2d37ced 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.63.5", + "version": "1.63.6", "protocol-version": "2.1.0", - "compiler-version": "1.63.5", + "compiler-version": "1.63.6", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -31,14 +31,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.63.5", - "sass-embedded-darwin-x64": "1.63.5", - "sass-embedded-linux-arm": "1.63.5", - "sass-embedded-linux-arm64": "1.63.5", - "sass-embedded-linux-ia32": "1.63.5", - "sass-embedded-linux-x64": "1.63.5", - "sass-embedded-win32-ia32": "1.63.5", - "sass-embedded-win32-x64": "1.63.5" + "sass-embedded-darwin-arm64": "1.63.6", + "sass-embedded-darwin-x64": "1.63.6", + "sass-embedded-linux-arm": "1.63.6", + "sass-embedded-linux-arm64": "1.63.6", + "sass-embedded-linux-ia32": "1.63.6", + "sass-embedded-linux-x64": "1.63.6", + "sass-embedded-win32-ia32": "1.63.6", + "sass-embedded-win32-x64": "1.63.6" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From c73d448f3fcdc071b7b252457401c290f9f3e20a Mon Sep 17 00:00:00 2001 From: Goodwine <2022649+Goodwine@users.noreply.github.com> Date: Fri, 30 Jun 2023 19:06:23 -0700 Subject: [PATCH 43/52] Workaround for shelljs in windows to fix CI (#236) * Workaround shelljs in windows to fix CI shell.cp() creates invalid symlinks when copying directories See: https://github.com/shelljs/shelljs/issues/198 * delete the file in init.ts instead of ci.yml so it fixes CI on other repos too --- tool/get-language-repo.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tool/get-language-repo.ts b/tool/get-language-repo.ts index 4afec967..e01c816a 100644 --- a/tool/get-language-repo.ts +++ b/tool/get-language-repo.ts @@ -27,6 +27,11 @@ export async function getLanguageRepo( } else { await utils.cleanDir('build/sass'); await utils.link(options.path, 'build/sass'); + + // Workaround for https://github.com/shelljs/shelljs/issues/198 + // This file is a symlink which gets messed up by `shell.cp` (called from + // `utils.link`) on Windows. + shell.rm('build/sass/spec/README.md'); } await utils.link('build/sass/js-api-doc', p.join(outPath, 'sass')); From 4d0ccbce3c7622d58ee94bcdecb19bd1d11c77a9 Mon Sep 17 00:00:00 2001 From: Goodwine <2022649+Goodwine@users.noreply.github.com> Date: Fri, 30 Jun 2023 19:17:00 -0700 Subject: [PATCH 44/52] Legacy importer wrapper only searches for relative URLs if the URL is not canonicalized (#226) * Legacy importer wrapper only searches for relative URLs if the URL is not canonicalized --- lib/src/legacy/importer.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/legacy/importer.ts b/lib/src/legacy/importer.ts index 0921c329..149c55cf 100644 --- a/lib/src/legacy/importer.ts +++ b/lib/src/legacy/importer.ts @@ -125,7 +125,9 @@ export class LegacyImporterWrapper this.expectingRelativeLoad = false; return null; - } else { + } else if (!url.startsWith('file:')) { + // We'll only search for another relative import when the URL isn't + // absolute. this.expectingRelativeLoad = true; } From 3049867152a4ae90a31d77617a06feb0b8d41df7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jul 2023 20:58:03 +0000 Subject: [PATCH 45/52] Bump minipass from 6.0.2 to 7.0.1 (#238) Bumps [minipass](https://github.com/isaacs/minipass) from 6.0.2 to 7.0.1. - [Changelog](https://github.com/isaacs/minipass/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/minipass/compare/v6.0.2...v7.0.1) --- updated-dependencies: - dependency-name: minipass dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e2d37ced..e1e2f929 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "extract-zip": "^2.0.1", "gts": "^4.0.0", "jest": "^29.4.1", - "minipass": "6.0.2", + "minipass": "7.0.1", "npm-run-all": "^4.1.5", "shelljs": "^0.8.4", "source-map-js": "^1.0.2", From acfb215682210919ea47fcd2dca88beeaad5e437 Mon Sep 17 00:00:00 2001 From: Goodwine <2022649+Goodwine@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:42:10 -0700 Subject: [PATCH 46/52] Remove README symlink when cloning sass/sass. (#239) Workaround for shelljs issue in Windows: https://github.com/shelljs/shelljs/issues/198 --- tool/get-language-repo.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tool/get-language-repo.ts b/tool/get-language-repo.ts index e01c816a..83a264b8 100644 --- a/tool/get-language-repo.ts +++ b/tool/get-language-repo.ts @@ -27,13 +27,13 @@ export async function getLanguageRepo( } else { await utils.cleanDir('build/sass'); await utils.link(options.path, 'build/sass'); - - // Workaround for https://github.com/shelljs/shelljs/issues/198 - // This file is a symlink which gets messed up by `shell.cp` (called from - // `utils.link`) on Windows. - shell.rm('build/sass/spec/README.md'); } + // Workaround for https://github.com/shelljs/shelljs/issues/198 + // This file is a symlink which gets messed up by `shell.cp` (called from + // `utils.link`) on Windows. + shell.rm('build/sass/spec/README.md'); + await utils.link('build/sass/js-api-doc', p.join(outPath, 'sass')); buildEmbeddedProtocol(); From 786ab6c769230fd7048ff244ef4ee7299db61c98 Mon Sep 17 00:00:00 2001 From: Ed Rivas Date: Wed, 19 Jul 2023 15:36:24 -0600 Subject: [PATCH 47/52] Add support for SassCalculation (#237) --- lib/index.mjs | 20 ++++ lib/index.ts | 6 + lib/src/protofier.ts | 202 ++++++++++++++++++++++++++++++++-- lib/src/value/calculations.ts | 137 +++++++++++++++++++++++ lib/src/value/index.ts | 11 ++ 5 files changed, 366 insertions(+), 10 deletions(-) create mode 100644 lib/src/value/calculations.ts diff --git a/lib/index.mjs b/lib/index.mjs index 31a57f8e..374e98e9 100644 --- a/lib/index.mjs +++ b/lib/index.mjs @@ -5,8 +5,12 @@ export const compileAsync = sass.compileAsync; export const compileString = sass.compileString; export const compileStringAsync = sass.compileStringAsync; export const Logger = sass.Logger; +export const CalculationInterpolation = sass.CalculationInterpolation +export const CalculationOperation = sass.CalculationOperation +export const CalculationOperator = sass.CalculationOperator export const SassArgumentList = sass.SassArgumentList; export const SassBoolean = sass.SassBoolean; +export const SassCalculation = sass.SassCalculation export const SassColor = sass.SassColor; export const SassFunction = sass.SassFunction; export const SassList = sass.SassList; @@ -59,6 +63,18 @@ export default { defaultExportDeprecation(); return sass.Logger; }, + get CalculationOperation() { + defaultExportDeprecation(); + return sass.CalculationOperation; + }, + get CalculationOperator() { + defaultExportDeprecation(); + return sass.CalculationOperator; + }, + get CalculationInterpolation() { + defaultExportDeprecation(); + return sass.CalculationInterpolation; + }, get SassArgumentList() { defaultExportDeprecation(); return sass.SassArgumentList; @@ -67,6 +83,10 @@ export default { defaultExportDeprecation(); return sass.SassBoolean; }, + get SassCalculation() { + defaultExportDeprecation(); + return sass.SassCalculation; + }, get SassColor() { defaultExportDeprecation(); return sass.SassColor; diff --git a/lib/index.ts b/lib/index.ts index 3d75ea05..c79ffec2 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -16,6 +16,12 @@ export {SassNumber} from './src/value/number'; export {SassString} from './src/value/string'; export {Value} from './src/value'; export {sassNull} from './src/value/null'; +export { + CalculationOperation, + CalculationOperator, + CalculationInterpolation, + SassCalculation, +} from './src/value/calculations'; export * as types from './src/legacy/value'; export {Exception} from './src/exception'; diff --git a/lib/src/protofier.ts b/lib/src/protofier.ts index f379f3c0..a4c4ac61 100644 --- a/lib/src/protofier.ts +++ b/lib/src/protofier.ts @@ -17,6 +17,13 @@ import {SassString} from './value/string'; import {Value} from './value'; import {sassNull} from './value/null'; import {sassTrue, sassFalse} from './value/boolean'; +import { + CalculationValue, + SassCalculation, + CalculationInterpolation, + CalculationOperation, + CalculationOperator, +} from './value/calculations'; /** * A class that converts [Value] objects into protobufs. @@ -56,11 +63,7 @@ export class Protofier { string.quoted = value.hasQuotes; result.value = {case: 'string', value: string}; } else if (value instanceof SassNumber) { - const number = new proto.Value_Number(); - number.value = value.value; - number.numerators = value.numeratorUnits.toArray(); - number.denominators = value.denominatorUnits.toArray(); - result.value = {case: 'number', value: number}; + result.value = {case: 'number', value: this.protofyNumber(value)}; } else if (value instanceof SassColor) { if (value.hasCalculatedHsl) { const color = new proto.Value_HslColor(); @@ -116,6 +119,11 @@ export class Protofier { fn.signature = value.signature!; result.value = {case: 'hostFunction', value: fn}; } + } else if (value instanceof SassCalculation) { + result.value = { + case: 'calculation', + value: this.protofyCalculation(value), + }; } else if (value === sassTrue) { result.value = {case: 'singleton', value: proto.SingletonValue.TRUE}; } else if (value === sassFalse) { @@ -128,6 +136,15 @@ export class Protofier { return result; } + /** Converts `number` to its protocol buffer representation. */ + private protofyNumber(number: SassNumber): proto.Value_Number { + return new proto.Value_Number({ + value: number.value, + numerators: number.numeratorUnits.toArray(), + denominators: number.denominatorUnits.toArray(), + }); + } + /** Converts `separator` to its protocol buffer representation. */ private protofySeparator(separator: ListSeparator): proto.ListSeparator { switch (separator) { @@ -144,6 +161,68 @@ export class Protofier { } } + /** Converts `calculation` to its protocol buffer representation. */ + private protofyCalculation( + calculation: SassCalculation + ): proto.Value_Calculation { + return new proto.Value_Calculation({ + name: calculation.name, + arguments: calculation.arguments + .map(this.protofyCalculationValue.bind(this)) + .toArray(), + }); + } + + /** Converts a CalculationValue that appears within a `SassCalculation` to + * its protocol buffer representation. */ + private protofyCalculationValue( + value: Object + ): proto.Value_Calculation_CalculationValue { + const result = new proto.Value_Calculation_CalculationValue(); + if (value instanceof SassCalculation) { + result.value = { + case: 'calculation', + value: this.protofyCalculation(value), + }; + } else if (value instanceof CalculationOperation) { + result.value = { + case: 'operation', + value: new proto.Value_Calculation_CalculationOperation({ + operator: this.protofyCalculationOperator(value.operator), + left: this.protofyCalculationValue(value.left), + right: this.protofyCalculationValue(value.right), + }), + }; + } else if (value instanceof CalculationInterpolation) { + result.value = {case: 'interpolation', value: value.value}; + } else if (value instanceof SassString) { + result.value = {case: 'string', value: value.text}; + } else if (value instanceof SassNumber) { + result.value = {case: 'number', value: this.protofyNumber(value)}; + } else { + throw utils.compilerError(`Unknown CalculationValue ${value}`); + } + return result; + } + + /** Converts `operator` to its protocol buffer representation. */ + private protofyCalculationOperator( + operator: CalculationOperator + ): proto.CalculationOperator { + switch (operator) { + case '+': + return proto.CalculationOperator.PLUS; + case '-': + return proto.CalculationOperator.MINUS; + case '*': + return proto.CalculationOperator.TIMES; + case '/': + return proto.CalculationOperator.DIVIDE; + default: + throw utils.compilerError(`Unknown CalculationOperator ${operator}`); + } + } + /** Converts `value` to its JS representation. */ deprotofy(value: proto.Value): Value { switch (value.value.case) { @@ -155,11 +234,7 @@ export class Protofier { } case 'number': { - const number = value.value.value; - return new SassNumber(number.value, { - numeratorUnits: number.numerators, - denominatorUnits: number.denominators, - }); + return this.deprotofyNumber(value.value.value); } case 'rgbColor': { @@ -247,6 +322,9 @@ export class Protofier { 'The compiler may not send Value.host_function.' ); + case 'calculation': + return this.deprotofyCalculation(value.value.value); + case 'singleton': switch (value.value.value) { case proto.SingletonValue.TRUE: @@ -263,6 +341,14 @@ export class Protofier { } } + /** Converts `number` to its JS representation. */ + private deprotofyNumber(number: proto.Value_Number): SassNumber { + return new SassNumber(number.value, { + numeratorUnits: number.numerators, + denominatorUnits: number.denominators, + }); + } + /** Converts `separator` to its JS representation. */ private deprotofySeparator(separator: proto.ListSeparator): ListSeparator { switch (separator) { @@ -278,4 +364,100 @@ export class Protofier { throw utils.compilerError(`Unknown separator ${separator}`); } } + + /** Converts `calculation` to its Sass representation. */ + private deprotofyCalculation( + calculation: proto.Value_Calculation + ): SassCalculation { + switch (calculation.name) { + case 'calc': + if (calculation.arguments.length !== 1) { + throw utils.compilerError( + 'Value.Calculation.arguments must have exactly one argument for calc().' + ); + } + return SassCalculation.calc( + this.deprotofyCalculationValue(calculation.arguments[0]) + ); + case 'clamp': + if (calculation.arguments.length !== 3) { + throw utils.compilerError( + 'Value.Calculation.arguments must have exactly 3 arguments for clamp().' + ); + } + return SassCalculation.clamp( + this.deprotofyCalculationValue(calculation.arguments[0]), + this.deprotofyCalculationValue(calculation.arguments[1]), + this.deprotofyCalculationValue(calculation.arguments[2]) + ); + case 'min': + if (calculation.arguments.length === 0) { + throw utils.compilerError( + 'Value.Calculation.arguments must have at least 1 argument for min().' + ); + } + return SassCalculation.min( + calculation.arguments.map(this.deprotofyCalculationValue) + ); + case 'max': + if (calculation.arguments.length === 0) { + throw utils.compilerError( + 'Value.Calculation.arguments must have at least 1 argument for max().' + ); + } + return SassCalculation.max( + calculation.arguments.map(this.deprotofyCalculationValue) + ); + default: + throw utils.compilerError( + `Value.Calculation.name "${calculation.name}" is not a recognized calculation type.` + ); + } + } + + /** Converts `value` to its Sass representation. */ + private deprotofyCalculationValue( + value: proto.Value_Calculation_CalculationValue + ): CalculationValue { + switch (value.value.case) { + case 'number': + return this.deprotofyNumber(value.value.value); + case 'calculation': + return this.deprotofyCalculation(value.value.value); + case 'string': + return new SassString(value.value.value, {quotes: false}); + case 'operation': + return new CalculationOperation( + this.deprotofyCalculationOperator(value.value.value.operator), + this.deprotofyCalculationValue( + value.value.value.left as proto.Value_Calculation_CalculationValue + ), + this.deprotofyCalculationValue( + value.value.value.right as proto.Value_Calculation_CalculationValue + ) + ); + case 'interpolation': + return new CalculationInterpolation(value.value.value); + default: + throw utils.mandatoryError('Calculation.CalculationValue.value'); + } + } + + /** Converts `operator` to its Sass representation. */ + private deprotofyCalculationOperator( + operator: proto.CalculationOperator + ): CalculationOperator { + switch (operator) { + case proto.CalculationOperator.PLUS: + return '+'; + case proto.CalculationOperator.MINUS: + return '-'; + case proto.CalculationOperator.TIMES: + return '*'; + case proto.CalculationOperator.DIVIDE: + return '/'; + default: + throw utils.compilerError(`Unknown CalculationOperator ${operator}`); + } + } } diff --git a/lib/src/value/calculations.ts b/lib/src/value/calculations.ts new file mode 100644 index 00000000..aa160e67 --- /dev/null +++ b/lib/src/value/calculations.ts @@ -0,0 +1,137 @@ +// Copyright 2023 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. + +import {hash, List, ValueObject} from 'immutable'; + +import {Value} from './index'; +import {SassNumber} from './number'; +import {SassString} from './string'; + +export type CalculationValue = + | SassNumber + | SassCalculation + | SassString + | CalculationOperation + | CalculationInterpolation; + +type CalculationValueIterable = CalculationValue[] | List; + +function assertCalculationValue(value: CalculationValue): void { + if (value instanceof SassString && value.hasQuotes) { + throw new Error(`Expected ${value} to be an unquoted string.`); + } +} + +const isValidClampArg = (value: CalculationValue): boolean => + value instanceof CalculationInterpolation || + (value instanceof SassString && !value.hasQuotes); + +/* A SassScript calculation */ +export class SassCalculation extends Value { + readonly arguments: List; + + private constructor(readonly name: string, args: CalculationValueIterable) { + super(); + this.arguments = List(args); + } + + static calc(argument: CalculationValue): SassCalculation { + assertCalculationValue(argument); + return new SassCalculation('calc', [argument]); + } + + static min(args: CalculationValueIterable): SassCalculation { + args.forEach(assertCalculationValue); + return new SassCalculation('min', args); + } + + static max(args: CalculationValueIterable): SassCalculation { + args.forEach(assertCalculationValue); + return new SassCalculation('max', args); + } + + static clamp( + min: CalculationValue, + value?: CalculationValue, + max?: CalculationValue + ): SassCalculation { + if ( + (value === undefined && !isValidClampArg(min)) || + (max === undefined && ![min, value].some(x => x && isValidClampArg(x))) + ) { + throw new Error( + 'Argument must be an unquoted SassString or CalculationInterpolation.' + ); + } + const args = [min]; + if (value !== undefined) args.push(value); + if (max !== undefined) args.push(max); + args.forEach(assertCalculationValue); + return new SassCalculation('clamp', args); + } + + assertCalculation(): SassCalculation { + return this; + } + + equals(other: unknown): boolean { + return ( + other instanceof SassCalculation && + this.name === other.name && + this.arguments.equals(other.arguments) + ); + } + + hashCode(): number { + return hash(this.name) ^ this.arguments.hashCode(); + } + + toString(): string { + return `${this.name}(${this.arguments.join(', ')})`; + } +} + +const operators = ['+', '-', '*', '/'] as const; +export type CalculationOperator = typeof operators[number]; + +export class CalculationOperation implements ValueObject { + constructor( + readonly operator: CalculationOperator, + readonly left: CalculationValue, + readonly right: CalculationValue + ) { + if (!operators.includes(operator)) { + throw new Error(`Invalid operator: ${operator}`); + } + assertCalculationValue(left); + assertCalculationValue(right); + } + + equals(other: unknown): boolean { + return ( + other instanceof CalculationOperation && + this.operator === other.operator && + this.left === other.left && + this.right === other.right + ); + } + + hashCode(): number { + return hash(this.operator) ^ hash(this.left) ^ hash(this.right); + } +} + +export class CalculationInterpolation implements ValueObject { + constructor(readonly value: string) {} + + equals(other: unknown): boolean { + return ( + other instanceof CalculationInterpolation && this.value === other.value + ); + } + + hashCode(): number { + return hash(this.value); + } +} diff --git a/lib/src/value/index.ts b/lib/src/value/index.ts index 536eab64..d7c95f8e 100644 --- a/lib/src/value/index.ts +++ b/lib/src/value/index.ts @@ -11,6 +11,7 @@ import {SassMap} from './map'; import {SassNumber} from './number'; import {SassString} from './string'; import {valueError} from '../utils'; +import {SassCalculation} from './calculations'; /** * A SassScript value. @@ -106,6 +107,16 @@ export abstract class Value implements ValueObject { throw valueError(`${this} is not a boolean`, name); } + /** + * Casts `this` to `SassCalculation`; throws if `this` isn't a calculation. + * + * If `this` came from a function argument, `name` is the argument name + * (without the `$`) and is used for error reporting. + */ + assertCalculation(name?: string): SassCalculation { + throw valueError(`${this} is not a calculation`, name); + } + /** * Casts `this` to `SassColor`; throws if `this` isn't a color. * From 2b1f4ecaf83a9e949976427f522291f674a04a57 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Thu, 20 Jul 2023 00:23:14 +0000 Subject: [PATCH 48/52] Update Dart Sass version and release --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 44 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ee952d6..8ddedb98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +## 1.64.0 + +* Comments that appear before or between `@use` and `@forward` rules are now + emitted in source order as much as possible, instead of always being emitted + after the CSS of all module dependencies. + +* Fix a bug where an interpolation in a custom property name crashed if the file + was loaded by a `@use` nested in an `@import`. + +### JavaScript API + +* Add a new `SassCalculation` type that represents the calculation objects added + in Dart Sass 1.40.0. + +* Add `Value.assertCalculation()`, which returns the value if it's a + `SassCalculation` and throws an error otherwise. + +* Produce a better error message when an environment that supports some Node.js + APIs loads the browser entrypoint but attempts to access the filesystem. + +### Embedded Sass + +* Fix a bug where nested relative `@imports` failed to load when using the + deprecated functions `render` or `renderSync` and those relative imports were + loaded multiple times across different files. + ## 1.63.6 ### JavaScript API diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index b6e50c17..8dd419cb 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.63.6", + "version": "1.64.0", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 2be3705b..f141ef1f 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.63.6", + "version": "1.64.0", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index a9c271ca..3dfac52e 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.63.6", + "version": "1.64.0", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 6e7e206a..0c541b64 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.63.6", + "version": "1.64.0", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 6102d10f..a956a1f7 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.63.6", + "version": "1.64.0", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index 28097ece..bb8c3346 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.63.6", + "version": "1.64.0", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index ccca0225..3557345c 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.63.6", + "version": "1.64.0", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index 3a9dd423..bda82d65 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.63.6", + "version": "1.64.0", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index e1e2f929..7b40774a 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.63.6", + "version": "1.64.0", "protocol-version": "2.1.0", - "compiler-version": "1.63.6", + "compiler-version": "1.64.0", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -31,14 +31,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.63.6", - "sass-embedded-darwin-x64": "1.63.6", - "sass-embedded-linux-arm": "1.63.6", - "sass-embedded-linux-arm64": "1.63.6", - "sass-embedded-linux-ia32": "1.63.6", - "sass-embedded-linux-x64": "1.63.6", - "sass-embedded-win32-ia32": "1.63.6", - "sass-embedded-win32-x64": "1.63.6" + "sass-embedded-darwin-arm64": "1.64.0", + "sass-embedded-darwin-x64": "1.64.0", + "sass-embedded-linux-arm": "1.64.0", + "sass-embedded-linux-arm64": "1.64.0", + "sass-embedded-linux-ia32": "1.64.0", + "sass-embedded-linux-x64": "1.64.0", + "sass-embedded-win32-ia32": "1.64.0", + "sass-embedded-win32-x64": "1.64.0" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 3110a4cf9ca630457caa59e159f982638f069dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 21 Jul 2023 15:08:07 -0700 Subject: [PATCH 49/52] Fix deprotofy SassCalculation.clamp (#241) --- lib/src/protofier.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/src/protofier.ts b/lib/src/protofier.ts index a4c4ac61..0092cc11 100644 --- a/lib/src/protofier.ts +++ b/lib/src/protofier.ts @@ -380,15 +380,22 @@ export class Protofier { this.deprotofyCalculationValue(calculation.arguments[0]) ); case 'clamp': - if (calculation.arguments.length !== 3) { + if ( + calculation.arguments.length === 0 || + calculation.arguments.length > 3 + ) { throw utils.compilerError( - 'Value.Calculation.arguments must have exactly 3 arguments for clamp().' + 'Value.Calculation.arguments must have 1 to 3 arguments for clamp().' ); } return SassCalculation.clamp( this.deprotofyCalculationValue(calculation.arguments[0]), - this.deprotofyCalculationValue(calculation.arguments[1]), - this.deprotofyCalculationValue(calculation.arguments[2]) + calculation.arguments.length > 1 + ? this.deprotofyCalculationValue(calculation.arguments[1]) + : undefined, + calculation.arguments.length > 2 + ? this.deprotofyCalculationValue(calculation.arguments[2]) + : undefined ); case 'min': if (calculation.arguments.length === 0) { From da21436155f4c59ee867efa8d1479e1476b16626 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Sat, 22 Jul 2023 00:18:24 +0000 Subject: [PATCH 50/52] Update Dart Sass version and release --- CHANGELOG.md | 7 +++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 25 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ddedb98..6e74c00a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.64.1 + +### Embedded Sass + +* Fix a bug where a valid `SassCalculation.clamp()` with less than 3 arguments + would throw an error. + ## 1.64.0 * Comments that appear before or between `@use` and `@forward` rules are now diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 8dd419cb..ae721415 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.64.0", + "version": "1.64.1", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index f141ef1f..e1f5b6fb 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.64.0", + "version": "1.64.1", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 3dfac52e..2f339d54 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.64.0", + "version": "1.64.1", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 0c541b64..1077dc20 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.64.0", + "version": "1.64.1", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index a956a1f7..35d16707 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.64.0", + "version": "1.64.1", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index bb8c3346..76a0232e 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.64.0", + "version": "1.64.1", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 3557345c..2b26d991 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.64.0", + "version": "1.64.1", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index bda82d65..a536d6fe 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.64.0", + "version": "1.64.1", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index 7b40774a..85024291 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.64.0", + "version": "1.64.1", "protocol-version": "2.1.0", - "compiler-version": "1.64.0", + "compiler-version": "1.64.1", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -31,14 +31,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.64.0", - "sass-embedded-darwin-x64": "1.64.0", - "sass-embedded-linux-arm": "1.64.0", - "sass-embedded-linux-arm64": "1.64.0", - "sass-embedded-linux-ia32": "1.64.0", - "sass-embedded-linux-x64": "1.64.0", - "sass-embedded-win32-ia32": "1.64.0", - "sass-embedded-win32-x64": "1.64.0" + "sass-embedded-darwin-arm64": "1.64.1", + "sass-embedded-darwin-x64": "1.64.1", + "sass-embedded-linux-arm": "1.64.1", + "sass-embedded-linux-arm64": "1.64.1", + "sass-embedded-linux-ia32": "1.64.1", + "sass-embedded-linux-x64": "1.64.1", + "sass-embedded-win32-ia32": "1.64.1", + "sass-embedded-win32-x64": "1.64.1" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0", From 2eca516d174256dbaaa9db019cac80cb864f9cca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 13:52:14 -0700 Subject: [PATCH 51/52] Bump minipass from 7.0.1 to 7.0.2 (#240) Bumps [minipass](https://github.com/isaacs/minipass) from 7.0.1 to 7.0.2. - [Changelog](https://github.com/isaacs/minipass/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/minipass/compare/v7.0.1...v7.0.2) --- updated-dependencies: - dependency-name: minipass dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 85024291..ab0d846c 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "extract-zip": "^2.0.1", "gts": "^4.0.0", "jest": "^29.4.1", - "minipass": "7.0.1", + "minipass": "7.0.2", "npm-run-all": "^4.1.5", "shelljs": "^0.8.4", "source-map-js": "^1.0.2", From 4426f815c628df78b3406f0cca911f0b4727eeb3 Mon Sep 17 00:00:00 2001 From: Sass Bot Date: Mon, 31 Jul 2023 23:47:59 +0000 Subject: [PATCH 52/52] Update Dart Sass version and release --- CHANGELOG.md | 6 ++++++ npm/darwin-arm64/package.json | 2 +- npm/darwin-x64/package.json | 2 +- npm/linux-arm/package.json | 2 +- npm/linux-arm64/package.json | 2 +- npm/linux-ia32/package.json | 2 +- npm/linux-x64/package.json | 2 +- npm/win32-ia32/package.json | 2 +- npm/win32-x64/package.json | 2 +- package.json | 20 ++++++++++---------- 10 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e74c00a..3c81a93c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.64.2 + +### Dart API + +* Include protocol buffer definitions when uploading the `sass` package to pub. + ## 1.64.1 ### Embedded Sass diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index ae721415..4bde48d2 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-arm64", - "version": "1.64.1", + "version": "1.64.2", "description": "The darwin-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index e1f5b6fb..2531813d 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-darwin-x64", - "version": "1.64.1", + "version": "1.64.2", "description": "The darwin-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm/package.json b/npm/linux-arm/package.json index 2f339d54..42779010 100644 --- a/npm/linux-arm/package.json +++ b/npm/linux-arm/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm", - "version": "1.64.1", + "version": "1.64.2", "description": "The linux-arm binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-arm64/package.json b/npm/linux-arm64/package.json index 1077dc20..d5d17040 100644 --- a/npm/linux-arm64/package.json +++ b/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-arm64", - "version": "1.64.1", + "version": "1.64.2", "description": "The linux-arm64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-ia32/package.json b/npm/linux-ia32/package.json index 35d16707..b334ab9d 100644 --- a/npm/linux-ia32/package.json +++ b/npm/linux-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-ia32", - "version": "1.64.1", + "version": "1.64.2", "description": "The linux-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/linux-x64/package.json b/npm/linux-x64/package.json index 76a0232e..5bb0f833 100644 --- a/npm/linux-x64/package.json +++ b/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-linux-x64", - "version": "1.64.1", + "version": "1.64.2", "description": "The linux-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-ia32/package.json b/npm/win32-ia32/package.json index 2b26d991..8620225d 100644 --- a/npm/win32-ia32/package.json +++ b/npm/win32-ia32/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-ia32", - "version": "1.64.1", + "version": "1.64.2", "description": "The win32-ia32 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/npm/win32-x64/package.json b/npm/win32-x64/package.json index a536d6fe..7ae36f8c 100644 --- a/npm/win32-x64/package.json +++ b/npm/win32-x64/package.json @@ -1,6 +1,6 @@ { "name": "sass-embedded-win32-x64", - "version": "1.64.1", + "version": "1.64.2", "description": "The win32-x64 binary for sass-embedded", "repository": "sass/embedded-host-node", "author": "Google Inc.", diff --git a/package.json b/package.json index ab0d846c..c7e90b74 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "sass-embedded", - "version": "1.64.1", + "version": "1.64.2", "protocol-version": "2.1.0", - "compiler-version": "1.64.1", + "compiler-version": "1.64.2", "description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol", "repository": "sass/embedded-host-node", "author": "Google Inc.", @@ -31,14 +31,14 @@ "test": "jest" }, "optionalDependencies": { - "sass-embedded-darwin-arm64": "1.64.1", - "sass-embedded-darwin-x64": "1.64.1", - "sass-embedded-linux-arm": "1.64.1", - "sass-embedded-linux-arm64": "1.64.1", - "sass-embedded-linux-ia32": "1.64.1", - "sass-embedded-linux-x64": "1.64.1", - "sass-embedded-win32-ia32": "1.64.1", - "sass-embedded-win32-x64": "1.64.1" + "sass-embedded-darwin-arm64": "1.64.2", + "sass-embedded-darwin-x64": "1.64.2", + "sass-embedded-linux-arm": "1.64.2", + "sass-embedded-linux-arm64": "1.64.2", + "sass-embedded-linux-ia32": "1.64.2", + "sass-embedded-linux-x64": "1.64.2", + "sass-embedded-win32-ia32": "1.64.2", + "sass-embedded-win32-x64": "1.64.2" }, "dependencies": { "@bufbuild/protobuf": "^1.0.0",